minerva-design 1.5.0 → 1.6.0
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/CHANGELOG.md +6 -0
- package/custom-elements.json +122 -5
- package/dist/angular/fesm2022/minerva-angular.mjs +55 -0
- package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
- package/dist/angular/types/minerva-angular.d.ts +23 -2
- package/dist/charts/canvas.d.cts +2 -1
- package/dist/charts/canvas.d.ts +2 -1
- package/dist/charts/core.d.cts +1 -1
- package/dist/charts/core.d.ts +1 -1
- package/dist/charts/engine/canvas.cjs +1 -1
- package/dist/charts/engine/canvas.cjs.map +1 -1
- package/dist/charts/engine/canvas.js +2 -1
- package/dist/charts/engine/canvas.js.map +1 -1
- package/dist/charts/engine/chart.cjs +1 -1
- package/dist/charts/engine/chart.cjs.map +1 -1
- package/dist/charts/engine/chart.js +144 -143
- package/dist/charts/engine/chart.js.map +1 -1
- package/dist/charts/engine/controller.cjs +2 -2
- package/dist/charts/engine/controller.cjs.map +1 -1
- package/dist/charts/engine/controller.d.cts +3 -1
- package/dist/charts/engine/controller.d.ts +3 -1
- package/dist/charts/engine/controller.js +130 -132
- package/dist/charts/engine/controller.js.map +1 -1
- package/dist/charts/engine/defaults.cjs.map +1 -1
- package/dist/charts/engine/defaults.d.cts +4 -4
- package/dist/charts/engine/defaults.d.ts +4 -4
- package/dist/charts/engine/defaults.js.map +1 -1
- package/dist/charts/engine/graph/chart.cjs +1 -1
- package/dist/charts/engine/graph/chart.cjs.map +1 -1
- package/dist/charts/engine/graph/chart.js +740 -597
- package/dist/charts/engine/graph/chart.js.map +1 -1
- package/dist/charts/engine/graph/dag.cjs +1 -1
- package/dist/charts/engine/graph/dag.cjs.map +1 -1
- package/dist/charts/engine/graph/dag.js +191 -166
- package/dist/charts/engine/graph/dag.js.map +1 -1
- package/dist/charts/engine/graph/force.cjs +1 -1
- package/dist/charts/engine/graph/force.cjs.map +1 -1
- package/dist/charts/engine/graph/force.d.cts +9 -0
- package/dist/charts/engine/graph/force.d.ts +9 -0
- package/dist/charts/engine/graph/force.js +279 -181
- package/dist/charts/engine/graph/force.js.map +1 -1
- package/dist/charts/engine/graph/geometry.cjs +1 -1
- package/dist/charts/engine/graph/geometry.cjs.map +1 -1
- package/dist/charts/engine/graph/geometry.d.cts +14 -1
- package/dist/charts/engine/graph/geometry.d.ts +14 -1
- package/dist/charts/engine/graph/geometry.js +77 -24
- package/dist/charts/engine/graph/geometry.js.map +1 -1
- package/dist/charts/engine/graph/model.cjs +1 -1
- package/dist/charts/engine/graph/model.cjs.map +1 -1
- package/dist/charts/engine/graph/model.d.cts +9 -0
- package/dist/charts/engine/graph/model.d.ts +9 -0
- package/dist/charts/engine/graph/model.js +63 -43
- package/dist/charts/engine/graph/model.js.map +1 -1
- package/dist/charts/engine/graph/types.d.cts +14 -0
- package/dist/charts/engine/graph/types.d.ts +14 -0
- package/dist/charts/engine/graph/worker.cjs +12 -6
- package/dist/charts/engine/graph/worker.cjs.map +1 -1
- package/dist/charts/engine/graph/worker.js +12 -6
- package/dist/charts/engine/graph/worker.js.map +1 -1
- package/dist/charts/engine/labels.cjs.map +1 -1
- package/dist/charts/engine/labels.d.cts +17 -0
- package/dist/charts/engine/labels.d.ts +17 -0
- package/dist/charts/engine/labels.js.map +1 -1
- package/dist/charts/engine/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +33 -0
- package/dist/charts/engine/model.d.ts +33 -0
- package/dist/charts/engine/model.js +149 -126
- package/dist/charts/engine/model.js.map +1 -1
- package/dist/charts/engine/orderbook/field.cjs +37 -0
- package/dist/charts/engine/orderbook/field.cjs.map +1 -0
- package/dist/charts/engine/orderbook/field.d.cts +92 -0
- package/dist/charts/engine/orderbook/field.d.ts +92 -0
- package/dist/charts/engine/orderbook/field.js +297 -0
- package/dist/charts/engine/orderbook/field.js.map +1 -0
- package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
- package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
- package/dist/charts/engine/orderbook/heatmap.js +413 -441
- package/dist/charts/engine/orderbook/heatmap.js.map +1 -1
- package/dist/charts/engine/orderbook/host.cjs +1 -1
- package/dist/charts/engine/orderbook/host.cjs.map +1 -1
- package/dist/charts/engine/orderbook/host.d.cts +8 -1
- package/dist/charts/engine/orderbook/host.d.ts +8 -1
- package/dist/charts/engine/orderbook/host.js +27 -5
- package/dist/charts/engine/orderbook/host.js.map +1 -1
- package/dist/charts/engine/orderbook/ladder.cjs +1 -1
- package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
- package/dist/charts/engine/orderbook/ladder.js +1 -1
- package/dist/charts/engine/orderbook/ladder.js.map +1 -1
- package/dist/charts/engine/orderbook/layout.cjs +1 -1
- package/dist/charts/engine/orderbook/layout.cjs.map +1 -1
- package/dist/charts/engine/orderbook/layout.d.cts +5 -0
- package/dist/charts/engine/orderbook/layout.d.ts +5 -0
- package/dist/charts/engine/orderbook/layout.js +8 -2
- package/dist/charts/engine/orderbook/layout.js.map +1 -1
- package/dist/charts/engine/orderbook/tape.cjs +1 -1
- package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
- package/dist/charts/engine/orderbook/tape.js +3 -3
- package/dist/charts/engine/orderbook/tape.js.map +1 -1
- package/dist/charts/engine/orderbook/types.d.cts +12 -4
- package/dist/charts/engine/orderbook/types.d.ts +12 -4
- package/dist/charts/engine/overlay.cjs +1 -1
- package/dist/charts/engine/overlay.cjs.map +1 -1
- package/dist/charts/engine/overlay.d.cts +17 -0
- package/dist/charts/engine/overlay.d.ts +17 -0
- package/dist/charts/engine/overlay.js +29 -13
- package/dist/charts/engine/overlay.js.map +1 -1
- package/dist/charts/engine/presets.cjs +1 -1
- package/dist/charts/engine/presets.cjs.map +1 -1
- package/dist/charts/engine/presets.d.cts +12 -2
- package/dist/charts/engine/presets.d.ts +12 -2
- package/dist/charts/engine/presets.js +8 -2
- package/dist/charts/engine/presets.js.map +1 -1
- package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
- package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
- package/dist/charts/engine/renderers/canvas2d.js +13 -9
- package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
- package/dist/charts/engine/renderers/follow.cjs +2 -0
- package/dist/charts/engine/renderers/follow.cjs.map +1 -0
- package/dist/charts/engine/renderers/follow.d.cts +8 -0
- package/dist/charts/engine/renderers/follow.d.ts +8 -0
- package/dist/charts/engine/renderers/follow.js +10 -0
- package/dist/charts/engine/renderers/follow.js.map +1 -0
- package/dist/charts/engine/renderers/gl-budget.cjs +2 -0
- package/dist/charts/engine/renderers/gl-budget.cjs.map +1 -0
- package/dist/charts/engine/renderers/gl-budget.d.cts +32 -0
- package/dist/charts/engine/renderers/gl-budget.d.ts +32 -0
- package/dist/charts/engine/renderers/gl-budget.js +95 -0
- package/dist/charts/engine/renderers/gl-budget.js.map +1 -0
- package/dist/charts/engine/renderers/gl.cjs +1 -1
- package/dist/charts/engine/renderers/gl.cjs.map +1 -1
- package/dist/charts/engine/renderers/gl.js +1 -1
- package/dist/charts/engine/renderers/gl.js.map +1 -1
- package/dist/charts/engine/renderers/shaders.cjs +9 -6
- package/dist/charts/engine/renderers/shaders.cjs.map +1 -1
- package/dist/charts/engine/renderers/shaders.d.cts +1 -1
- package/dist/charts/engine/renderers/shaders.d.ts +1 -1
- package/dist/charts/engine/renderers/shaders.js +9 -6
- package/dist/charts/engine/renderers/shaders.js.map +1 -1
- package/dist/charts/engine/renderers/types.cjs.map +1 -1
- package/dist/charts/engine/renderers/types.d.cts +2 -0
- package/dist/charts/engine/renderers/types.d.ts +2 -0
- package/dist/charts/engine/renderers/types.js.map +1 -1
- package/dist/charts/engine/renderers/webgl.cjs +1 -1
- package/dist/charts/engine/renderers/webgl.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgl.js +85 -64
- package/dist/charts/engine/renderers/webgl.js.map +1 -1
- package/dist/charts/engine/renderers/webgl2.cjs +1 -1
- package/dist/charts/engine/renderers/webgl2.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgl2.js +72 -58
- package/dist/charts/engine/renderers/webgl2.js.map +1 -1
- package/dist/charts/engine/renderers/webgpu.cjs +1 -1
- package/dist/charts/engine/renderers/webgpu.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgpu.js +1 -1
- package/dist/charts/engine/renderers/webgpu.js.map +1 -1
- package/dist/charts/engine/scene.cjs +1 -1
- package/dist/charts/engine/scene.cjs.map +1 -1
- package/dist/charts/engine/scene.d.cts +51 -4
- package/dist/charts/engine/scene.d.ts +51 -4
- package/dist/charts/engine/scene.js +188 -122
- package/dist/charts/engine/scene.js.map +1 -1
- package/dist/charts/engine/shapes/chord.cjs +1 -1
- package/dist/charts/engine/shapes/chord.cjs.map +1 -1
- package/dist/charts/engine/shapes/chord.js +108 -103
- package/dist/charts/engine/shapes/chord.js.map +1 -1
- package/dist/charts/engine/shapes/types.d.cts +5 -3
- package/dist/charts/engine/shapes/types.d.ts +5 -3
- package/dist/charts/engine/three-d/canvas2d.cjs +1 -1
- package/dist/charts/engine/three-d/canvas2d.cjs.map +1 -1
- package/dist/charts/engine/three-d/canvas2d.d.cts +36 -1
- package/dist/charts/engine/three-d/canvas2d.d.ts +36 -1
- package/dist/charts/engine/three-d/canvas2d.js +155 -80
- package/dist/charts/engine/three-d/canvas2d.js.map +1 -1
- package/dist/charts/engine/three-d/chart.cjs +1 -1
- package/dist/charts/engine/three-d/chart.cjs.map +1 -1
- package/dist/charts/engine/three-d/chart.js +219 -215
- package/dist/charts/engine/three-d/chart.js.map +1 -1
- package/dist/charts/engine/three-d/oit.cjs +109 -0
- package/dist/charts/engine/three-d/oit.cjs.map +1 -0
- package/dist/charts/engine/three-d/oit.d.cts +34 -0
- package/dist/charts/engine/three-d/oit.d.ts +34 -0
- package/dist/charts/engine/three-d/oit.js +111 -0
- package/dist/charts/engine/three-d/oit.js.map +1 -0
- package/dist/charts/engine/three-d/render-types.cjs +1 -1
- package/dist/charts/engine/three-d/render-types.cjs.map +1 -1
- package/dist/charts/engine/three-d/render-types.d.cts +16 -3
- package/dist/charts/engine/three-d/render-types.d.ts +16 -3
- package/dist/charts/engine/three-d/render-types.js +6 -9
- package/dist/charts/engine/three-d/render-types.js.map +1 -1
- package/dist/charts/engine/three-d/shaders.cjs +52 -26
- package/dist/charts/engine/three-d/shaders.cjs.map +1 -1
- package/dist/charts/engine/three-d/shaders.d.cts +11 -3
- package/dist/charts/engine/three-d/shaders.d.ts +11 -3
- package/dist/charts/engine/three-d/shaders.js +84 -40
- package/dist/charts/engine/three-d/shaders.js.map +1 -1
- package/dist/charts/engine/three-d/sort.cjs +1 -1
- package/dist/charts/engine/three-d/sort.cjs.map +1 -1
- package/dist/charts/engine/three-d/sort.d.cts +6 -4
- package/dist/charts/engine/three-d/sort.d.ts +6 -4
- package/dist/charts/engine/three-d/sort.js +51 -39
- package/dist/charts/engine/three-d/sort.js.map +1 -1
- package/dist/charts/engine/three-d/types.d.cts +9 -0
- package/dist/charts/engine/three-d/types.d.ts +9 -0
- package/dist/charts/engine/three-d/webgl.cjs +1 -1
- package/dist/charts/engine/three-d/webgl.cjs.map +1 -1
- package/dist/charts/engine/three-d/webgl.d.cts +9 -0
- package/dist/charts/engine/three-d/webgl.d.ts +9 -0
- package/dist/charts/engine/three-d/webgl.js +199 -76
- package/dist/charts/engine/three-d/webgl.js.map +1 -1
- package/dist/charts/engine/three-d/webgpu.cjs +1 -1
- package/dist/charts/engine/three-d/webgpu.cjs.map +1 -1
- package/dist/charts/engine/three-d/webgpu.js +225 -99
- package/dist/charts/engine/three-d/webgpu.js.map +1 -1
- package/dist/charts/engine/trading/chart.cjs +1 -1
- package/dist/charts/engine/trading/chart.cjs.map +1 -1
- package/dist/charts/engine/trading/chart.d.cts +0 -1
- package/dist/charts/engine/trading/chart.d.ts +0 -1
- package/dist/charts/engine/trading/chart.js +1048 -883
- package/dist/charts/engine/trading/chart.js.map +1 -1
- package/dist/charts/engine/trading/drawings.cjs +2 -2
- package/dist/charts/engine/trading/drawings.cjs.map +1 -1
- package/dist/charts/engine/trading/drawings.d.cts +6 -0
- package/dist/charts/engine/trading/drawings.d.ts +6 -0
- package/dist/charts/engine/trading/drawings.js +100 -88
- package/dist/charts/engine/trading/drawings.js.map +1 -1
- package/dist/charts/engine/trading/format.cjs +1 -1
- package/dist/charts/engine/trading/format.cjs.map +1 -1
- package/dist/charts/engine/trading/format.d.cts +6 -0
- package/dist/charts/engine/trading/format.d.ts +6 -0
- package/dist/charts/engine/trading/format.js +42 -30
- package/dist/charts/engine/trading/format.js.map +1 -1
- package/dist/charts/engine/trading/geometry.cjs +1 -1
- package/dist/charts/engine/trading/geometry.cjs.map +1 -1
- package/dist/charts/engine/trading/geometry.d.cts +16 -0
- package/dist/charts/engine/trading/geometry.d.ts +16 -0
- package/dist/charts/engine/trading/geometry.js +19 -4
- package/dist/charts/engine/trading/geometry.js.map +1 -1
- package/dist/charts/engine/trading/labels.cjs +1 -1
- package/dist/charts/engine/trading/labels.cjs.map +1 -1
- package/dist/charts/engine/trading/labels.js +24 -4
- package/dist/charts/engine/trading/labels.js.map +1 -1
- package/dist/charts/engine/trading/studies.cjs +1 -1
- package/dist/charts/engine/trading/studies.cjs.map +1 -1
- package/dist/charts/engine/trading/studies.d.cts +8 -0
- package/dist/charts/engine/trading/studies.d.ts +8 -0
- package/dist/charts/engine/trading/studies.js +4 -1
- package/dist/charts/engine/trading/studies.js.map +1 -1
- package/dist/charts/engine/trading/types.d.cts +34 -11
- package/dist/charts/engine/trading/types.d.ts +34 -11
- package/dist/charts/engine/types.d.cts +25 -4
- package/dist/charts/engine/types.d.ts +25 -4
- package/dist/charts/react/charts.cjs +1 -1
- package/dist/charts/react/charts.cjs.map +1 -1
- package/dist/charts/react/charts.js +20 -15
- package/dist/charts/react/charts.js.map +1 -1
- package/dist/charts/react/graph.cjs +1 -1
- package/dist/charts/react/graph.cjs.map +1 -1
- package/dist/charts/react/graph.d.cts +6 -0
- package/dist/charts/react/graph.d.ts +6 -0
- package/dist/charts/react/graph.js +28 -27
- package/dist/charts/react/graph.js.map +1 -1
- package/dist/charts/react/orderbook.cjs +1 -1
- package/dist/charts/react/orderbook.cjs.map +1 -1
- package/dist/charts/react/orderbook.d.cts +3 -1
- package/dist/charts/react/orderbook.d.ts +3 -1
- package/dist/charts/react/orderbook.js +1 -0
- package/dist/charts/react/orderbook.js.map +1 -1
- package/dist/charts/react/shapes.cjs.map +1 -1
- package/dist/charts/react/shapes.d.cts +4 -3
- package/dist/charts/react/shapes.d.ts +4 -3
- package/dist/charts/react/shapes.js.map +1 -1
- package/dist/charts/react/three-d.cjs +1 -1
- package/dist/charts/react/three-d.cjs.map +1 -1
- package/dist/charts/react/three-d.d.cts +7 -0
- package/dist/charts/react/three-d.d.ts +7 -0
- package/dist/charts/react/three-d.js +14 -13
- package/dist/charts/react/three-d.js.map +1 -1
- package/dist/charts/react/trading.cjs.map +1 -1
- package/dist/charts/react/trading.d.cts +3 -3
- package/dist/charts/react/trading.d.ts +3 -3
- package/dist/charts/react/trading.js.map +1 -1
- package/dist/core/contracts.cjs +1 -1
- package/dist/core/contracts.cjs.map +1 -1
- package/dist/core/contracts.js +1 -1
- package/dist/core/contracts.js.map +1 -1
- package/dist/native/charts/src/canvas.cjs +1 -1
- package/dist/native/charts/src/canvas.js +4 -3
- package/dist/native/charts/src/engine/controller.cjs +2 -2
- package/dist/native/charts/src/engine/controller.cjs.map +1 -1
- package/dist/native/charts/src/engine/controller.js +102 -104
- package/dist/native/charts/src/engine/controller.js.map +1 -1
- package/dist/native/charts/src/engine/labels.cjs +1 -1
- package/dist/native/charts/src/engine/labels.cjs.map +1 -1
- package/dist/native/charts/src/engine/labels.js +14 -1
- package/dist/native/charts/src/engine/labels.js.map +1 -1
- package/dist/native/charts/src/engine/model.cjs +1 -1
- package/dist/native/charts/src/engine/model.cjs.map +1 -1
- package/dist/native/charts/src/engine/model.js +180 -157
- package/dist/native/charts/src/engine/model.js.map +1 -1
- package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
- package/dist/native/charts/src/engine/overlay.js.map +1 -1
- package/dist/native/charts/src/engine/presets.cjs +1 -1
- package/dist/native/charts/src/engine/presets.cjs.map +1 -1
- package/dist/native/charts/src/engine/presets.js +8 -2
- package/dist/native/charts/src/engine/presets.js.map +1 -1
- package/dist/native/charts/src/engine/scene.cjs +1 -1
- package/dist/native/charts/src/engine/scene.cjs.map +1 -1
- package/dist/native/charts/src/engine/scene.js +188 -122
- package/dist/native/charts/src/engine/scene.js.map +1 -1
- package/dist/native/charts/src/engine/shapes/chord.cjs +1 -1
- package/dist/native/charts/src/engine/shapes/chord.cjs.map +1 -1
- package/dist/native/charts/src/engine/shapes/chord.js +108 -103
- package/dist/native/charts/src/engine/shapes/chord.js.map +1 -1
- package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
- package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
- package/dist/native/charts/src/engine/shapes/layout.js +88 -73
- package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
- package/dist/native/components/Chart/ChartBase.cjs +1 -1
- package/dist/native/components/Chart/ChartBase.cjs.map +1 -1
- package/dist/native/components/Chart/ChartBase.js +127 -115
- package/dist/native/components/Chart/ChartBase.js.map +1 -1
- package/dist/native/components/Chart/charts.cjs +1 -1
- package/dist/native/components/Chart/charts.cjs.map +1 -1
- package/dist/native/components/Chart/charts.js +8 -5
- package/dist/native/components/Chart/charts.js.map +1 -1
- package/dist/native/components/Chart/scene.cjs +1 -1
- package/dist/native/components/Chart/scene.cjs.map +1 -1
- package/dist/native/components/Chart/scene.d.cts +6 -1
- package/dist/native/components/Chart/scene.d.ts +6 -1
- package/dist/native/components/Chart/scene.js +99 -50
- package/dist/native/components/Chart/scene.js.map +1 -1
- package/dist/native/components/Chart/types.d.cts +7 -1
- package/dist/native/components/Chart/types.d.ts +7 -1
- package/dist/native/components/Charts/charts.cjs +1 -1
- package/dist/native/components/Charts/charts.cjs.map +1 -1
- package/dist/native/components/Charts/charts.js +23 -18
- package/dist/native/components/Charts/charts.js.map +1 -1
- package/dist/native/components/ShapeChart/ShapeChartBase.cjs +1 -1
- package/dist/native/components/ShapeChart/ShapeChartBase.cjs.map +1 -1
- package/dist/native/components/ShapeChart/ShapeChartBase.d.cts +1 -1
- package/dist/native/components/ShapeChart/ShapeChartBase.d.ts +1 -1
- package/dist/native/components/ShapeChart/ShapeChartBase.js +97 -107
- package/dist/native/components/ShapeChart/ShapeChartBase.js.map +1 -1
- package/dist/native/components/ShapeChart/geometry.cjs +1 -1
- package/dist/native/components/ShapeChart/geometry.cjs.map +1 -1
- package/dist/native/components/ShapeChart/geometry.js +120 -36
- package/dist/native/components/ShapeChart/geometry.js.map +1 -1
- package/dist/native/components/ShapeChart/types.d.cts +6 -4
- package/dist/native/components/ShapeChart/types.d.ts +6 -4
- package/dist/native/source/components/Chart/ChartBase.tsx +19 -6
- package/dist/native/source/components/Chart/charts.tsx +10 -3
- package/dist/native/source/components/Chart/scene.tsx +85 -0
- package/dist/native/source/components/Chart/types.ts +7 -0
- package/dist/native/source/components/Charts/charts.tsx +7 -0
- package/dist/native/source/components/ShapeChart/ShapeChartBase.tsx +10 -36
- package/dist/native/source/components/ShapeChart/geometry.ts +188 -18
- package/dist/native/source/components/ShapeChart/types.ts +6 -4
- package/dist/taro/chart-a11y.d.ts +7 -0
- package/dist/taro/charts.d.ts +4 -1
- package/dist/taro/index.js +3212 -3049
- package/dist/taro/shape-charts.d.ts +6 -4
- package/dist/uni/AreaChart.vue +2 -1
- package/dist/uni/AreaChart.vue.d.ts +1 -1
- package/dist/uni/BarChart.vue +2 -1
- package/dist/uni/BarChart.vue.d.ts +1 -1
- package/dist/uni/BoxPlotChart.vue +2 -1
- package/dist/uni/BubbleChart.vue +2 -1
- package/dist/uni/CandlestickChart.vue +2 -1
- package/dist/uni/Chart.vue +2 -1
- package/dist/uni/Divider.vue.d.ts +1 -1
- package/dist/uni/DonutChart.vue.d.ts +1 -1
- package/dist/uni/GanttChart.vue +2 -1
- package/dist/uni/GanttChart.vue.d.ts +11 -0
- package/dist/uni/GaugeChart.vue.d.ts +1 -1
- package/dist/uni/HeatmapChart.vue +2 -1
- package/dist/uni/HistogramChart.vue +2 -1
- package/dist/uni/HorizontalBarChart.vue +2 -1
- package/dist/uni/HorizontalBarChart.vue.d.ts +1 -1
- package/dist/uni/LineChart.vue +2 -1
- package/dist/uni/MixedChart.vue +2 -1
- package/dist/uni/PieChart.vue.d.ts +1 -1
- package/dist/uni/QuadrantChart.vue +2 -1
- package/dist/uni/RangeAreaChart.vue +2 -1
- package/dist/uni/ScatterChart.vue +2 -1
- package/dist/uni/Sparkline.vue +2 -1
- package/dist/uni/WaterfallChart.vue +2 -1
- package/dist/uni/chart-a11y.d.ts +7 -0
- package/dist/uni/chart-a11y.js +29 -0
- package/dist/uni/chart-canvas.d.ts +9 -0
- package/dist/uni/chart-canvas.js +11 -1
- package/dist/uni/chart-types.d.ts +8 -1
- package/dist/uni/chart-types.js +5 -1
- package/dist/uni/charts-canvas.js +2 -1
- package/dist/uni/named-chart-options.d.ts +2 -0
- package/dist/uni/named-chart-options.js +3 -0
- package/dist/uni/shape-chart-canvas.d.ts +0 -2
- package/dist/uni/shape-chart-canvas.js +4 -36
- package/dist/uni/shape-chart-types.d.ts +2 -2
- package/dist/uni/shape-chart-types.js +2 -2
- package/dist/vue/components/Chart/Bar3DChart.vue.d.ts +2 -0
- package/dist/vue/components/Chart/DependencyGraph.vue.d.ts +2 -0
- package/dist/vue/components/Chart/GanttChart.vue.d.ts +15 -0
- package/dist/vue/components/Chart/GanttChart.vue.js.map +1 -1
- package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js +8 -0
- package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/vue/components/Chart/GraphChart.vue.d.ts +2 -0
- package/dist/vue/components/Chart/Line3DChart.vue.d.ts +2 -0
- package/dist/vue/components/Chart/Scatter3DChart.vue.d.ts +2 -0
- package/dist/vue/components/Chart/Surface3DChart.vue.d.ts +2 -0
- package/dist/vue/components/Chart/TradingChart.vue.d.ts +9 -0
- package/dist/vue/components/Chart/TreeChart.vue.d.ts +2 -0
- package/dist/vue/components/Chart/graph.d.ts +3 -0
- package/dist/vue/components/Chart/graph.js +2 -0
- package/dist/vue/components/Chart/graph.js.map +1 -1
- package/dist/vue/components/Chart/three-d.d.ts +3 -0
- package/dist/vue/components/Chart/three-d.js +2 -0
- package/dist/vue/components/Chart/three-d.js.map +1 -1
- package/dist/vue/components/Chart/trading.d.ts +7 -2
- package/dist/vue/components/Chart/trading.js +1 -0
- package/dist/vue/components/Chart/trading.js.map +1 -1
- package/dist/weapp/area-chart/index.wxml +1 -1
- package/dist/weapp/bar-chart/index.wxml +1 -1
- package/dist/weapp/box-plot-chart/index.wxml +1 -1
- package/dist/weapp/bubble-chart/index.wxml +1 -1
- package/dist/weapp/candlestick-chart/index.wxml +1 -1
- package/dist/weapp/chart/index.wxml +1 -1
- package/dist/weapp/charts/canvas.js +326 -54
- package/dist/weapp/charts/core.js +2 -0
- package/dist/weapp/controls.js +58 -27
- package/dist/weapp/gantt-chart/index.wxml +1 -1
- package/dist/weapp/heatmap-chart/index.wxml +1 -1
- package/dist/weapp/histogram-chart/index.wxml +1 -1
- package/dist/weapp/horizontal-bar-chart/index.wxml +1 -1
- package/dist/weapp/line-chart/index.wxml +1 -1
- package/dist/weapp/mixed-chart/index.wxml +1 -1
- package/dist/weapp/quadrant-chart/index.wxml +1 -1
- package/dist/weapp/range-area-chart/index.wxml +1 -1
- package/dist/weapp/scatter-chart/index.wxml +1 -1
- package/dist/weapp/sparkline/index.wxml +1 -1
- package/dist/weapp/types.d.ts +11 -2
- package/dist/weapp/waterfall-chart/index.wxml +1 -1
- package/dist/web-components/components/chart/extended.d.ts +4 -0
- package/dist/web-components/components/chart/extended.js +8 -2
- package/dist/web-components/components/chart/extended.js.map +1 -1
- package/dist/web-components/components/chart-3d/chart-3d.d.ts +1 -1
- package/dist/web-components/components/chart-3d/chart-3d.js.map +1 -1
- package/dist/web-components/components/graph/graph.d.ts +2 -0
- package/dist/web-components/components/graph/graph.js +3 -2
- package/dist/web-components/components/graph/graph.js.map +1 -1
- package/dist/web-components/components/trading-chart/trading-chart.d.ts +1 -1
- package/dist/web-components/components/trading-chart/trading-chart.js.map +1 -1
- package/dist/web-components/html-custom-data.json +45 -0
- package/dist/web-components/types/react.d.ts +4 -4
- package/dist/web-components/types/solid.d.ts +8 -8
- package/dist/web-components/types/svelte.d.ts +8 -8
- package/dist/web-components/types/vue.d.ts +4 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu.js","names":["BUFFER_INDEX","BUFFER_VERTEX","BUFFER_COPY_DST","TEXTURE_RENDER_ATTACHMENT","SAMPLES","createWebGpu3D","gpu","adapter","fallback","requireHardware","device","context","canvas","format","destroyed","onLost","bindGroupLayout","layout","blend","additive","pipeline","module","blending","depthWrite","pointBuffers","meshBuffers","lineBuffers","pipelines","WGSL_POINTS","WGSL_MESH","WGSL_LINES","additivePoints","pipelineOf","item","variants","writesDepth","targets","renderTargets","width","height","resources","uniformData","buffer","bytes","data","gpuBuffer","usage","release","res","upload","indices","vertex","index","uniform","encoder","pass","color","depth","seen","drawOrder","items","count","itemUniforms","frame","chosen","key"],"sources":["../../../../../charts/src/engine/three-d/webgpu.ts"],"sourcesContent":["// WebGPU backend of the 3D charts: 4× MSAA, a depth buffer, one draw per\n// item (instanced billboards / segments, indexed triangles).\n\nimport type { RendererLostHandler } from \"../renderers/types\";\nimport {\n POINT_STRIDE,\n SEGMENT_STRIDE,\n VERTEX_STRIDE,\n drawOrder,\n type Item3D,\n type Renderer3D,\n} from \"./render-types\";\nimport {\n UNIFORM_BYTES,\n WGSL_LINES,\n WGSL_MESH,\n WGSL_POINTS,\n itemUniforms,\n writesDepth,\n} from \"./shaders\";\n\n// lib.dom has the WebGPU interfaces but not these constant objects\nconst BUFFER_INDEX = 0x10;\nconst BUFFER_VERTEX = 0x20;\nconst BUFFER_UNIFORM = 0x40;\nconst BUFFER_COPY_DST = 0x08;\nconst STAGE_VERTEX = 0x1;\nconst STAGE_FRAGMENT = 0x2;\nconst TEXTURE_RENDER_ATTACHMENT = 0x10;\n\nconst SAMPLES = 4;\n\ninterface ItemResources {\n version: number;\n kind: Item3D[\"kind\"];\n vertex: GPUBuffer | null;\n index: GPUBuffer | null;\n /** `order` of the uploaded indices (meshes) */\n order: number;\n uniform: GPUBuffer;\n bindGroup: GPUBindGroup;\n}\n\ntype GpuNavigator = Navigator & { gpu?: GPU };\n\nexport const createWebGpu3D = async (\n canvas: HTMLCanvasElement,\n onLost: RendererLostHandler,\n /** Refuses fallback (software) adapters */\n requireHardware = false,\n): Promise<Renderer3D | null> => {\n const gpu =\n typeof navigator !== \"undefined\"\n ? (navigator as GpuNavigator).gpu\n : undefined;\n if (!gpu) return null;\n const adapter = await gpu.requestAdapter();\n if (!adapter) return null;\n const fallback = adapter as GPUAdapter & {\n isFallbackAdapter?: boolean;\n info?: { isFallbackAdapter?: boolean };\n };\n if (\n requireHardware &&\n (fallback.info?.isFallbackAdapter || fallback.isFallbackAdapter)\n ) {\n return null;\n }\n const device = await adapter.requestDevice();\n const context = canvas.getContext(\"webgpu\") as GPUCanvasContext | null;\n if (!context) {\n device.destroy();\n return null;\n }\n const format = gpu.getPreferredCanvasFormat();\n context.configure({ device, format, alphaMode: \"premultiplied\" });\n\n let destroyed = false;\n void device.lost.then(() => {\n if (!destroyed) onLost();\n });\n\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: STAGE_VERTEX | STAGE_FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n const layout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n const blend: GPUBlendState = {\n color: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n };\n // additive points: the colors add up, the coverage composites as usual\n const additive: GPUBlendState = {\n color: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n alpha: blend.alpha,\n };\n const pipeline = (\n code: string,\n buffers: GPUVertexBufferLayout[],\n topology: GPUPrimitiveTopology,\n depthWrite: boolean,\n blending: GPUBlendState = blend,\n ) => {\n const module = device.createShaderModule({ code });\n return device.createRenderPipeline({\n layout,\n vertex: { module, entryPoint: \"vs\", buffers },\n fragment: {\n module,\n entryPoint: \"fs\",\n targets: [{ format, blend: blending }],\n },\n primitive: { topology, cullMode: \"none\" },\n depthStencil: {\n format: \"depth24plus\",\n depthWriteEnabled: depthWrite,\n depthCompare: \"less-equal\",\n },\n multisample: { count: SAMPLES },\n });\n };\n const pointBuffers: GPUVertexBufferLayout[] = [\n {\n arrayStride: POINT_STRIDE,\n stepMode: \"instance\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x3\" },\n { shaderLocation: 1, offset: 12, format: \"float32\" },\n { shaderLocation: 2, offset: 16, format: \"unorm8x4\" },\n ],\n },\n ];\n const meshBuffers: GPUVertexBufferLayout[] = [\n {\n arrayStride: VERTEX_STRIDE,\n stepMode: \"vertex\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x3\" },\n { shaderLocation: 1, offset: 12, format: \"float32x3\" },\n { shaderLocation: 2, offset: 24, format: \"unorm8x4\" },\n ],\n },\n ];\n const lineBuffers: GPUVertexBufferLayout[] = [\n {\n arrayStride: SEGMENT_STRIDE,\n stepMode: \"instance\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x3\" },\n { shaderLocation: 1, offset: 12, format: \"float32x3\" },\n { shaderLocation: 2, offset: 24, format: \"unorm8x4\" },\n ],\n },\n ];\n const pipelines = {\n points: [\n pipeline(WGSL_POINTS, pointBuffers, \"triangle-strip\", false),\n pipeline(WGSL_POINTS, pointBuffers, \"triangle-strip\", true),\n ],\n mesh: [\n pipeline(WGSL_MESH, meshBuffers, \"triangle-list\", false),\n pipeline(WGSL_MESH, meshBuffers, \"triangle-list\", true),\n ],\n lines: [\n pipeline(WGSL_LINES, lineBuffers, \"triangle-strip\", false),\n pipeline(WGSL_LINES, lineBuffers, \"triangle-strip\", true),\n ],\n };\n let additivePoints: GPURenderPipeline | null = null;\n const pipelineOf = (item: Item3D) => {\n if (item.kind === \"points\" && item.additive) {\n additivePoints ??= pipeline(\n WGSL_POINTS,\n pointBuffers,\n \"triangle-strip\",\n false,\n additive,\n );\n return additivePoints;\n }\n const variants = pipelines[item.kind];\n return variants[writesDepth(item) ? variants.length - 1 : 0];\n };\n\n let targets: {\n width: number;\n height: number;\n color: GPUTexture;\n depth: GPUTexture;\n } | null = null;\n const renderTargets = () => {\n const width = canvas.width;\n const height = canvas.height;\n if (targets && targets.width === width && targets.height === height)\n return targets;\n targets?.color.destroy();\n targets?.depth.destroy();\n targets = {\n width,\n height,\n color: device.createTexture({\n size: [width, height],\n sampleCount: SAMPLES,\n format,\n usage: TEXTURE_RENDER_ATTACHMENT,\n }),\n depth: device.createTexture({\n size: [width, height],\n sampleCount: SAMPLES,\n format: \"depth24plus\",\n usage: TEXTURE_RENDER_ATTACHMENT,\n }),\n };\n return targets;\n };\n\n const resources = new Map<string, ItemResources>();\n const uniformData = new Float32Array(UNIFORM_BYTES / 4);\n\n const buffer = (data: ArrayBuffer | Uint32Array, usage: number) => {\n const bytes = data.byteLength;\n if (bytes <= 0) return null;\n const gpuBuffer = device.createBuffer({\n size: Math.max(16, Math.ceil(bytes / 4) * 4),\n usage: usage | BUFFER_COPY_DST,\n });\n if (data instanceof Uint32Array) {\n device.queue.writeBuffer(\n gpuBuffer,\n 0,\n data.buffer,\n data.byteOffset,\n bytes,\n );\n } else {\n device.queue.writeBuffer(gpuBuffer, 0, data);\n }\n return gpuBuffer;\n };\n\n const release = (res: ItemResources) => {\n res.vertex?.destroy();\n res.index?.destroy();\n };\n\n const upload = (item: Item3D): ItemResources => {\n let res = resources.get(item.key);\n if (res && res.version === item.version && res.kind === item.kind) {\n // same mesh, triangles in a new order (transparent, sorted by depth)\n if (\n item.kind === \"mesh\" &&\n res.index &&\n (item.order ?? 0) !== res.order\n ) {\n const { indices } = item;\n device.queue.writeBuffer(\n res.index,\n 0,\n indices.buffer,\n indices.byteOffset,\n indices.byteLength,\n );\n res.order = item.order ?? 0;\n }\n return res;\n }\n if (res) release(res);\n const vertex = buffer(\n item.kind === \"mesh\" ? item.vertices : item.data,\n BUFFER_VERTEX,\n );\n const index =\n item.kind === \"mesh\" ? buffer(item.indices, BUFFER_INDEX) : null;\n if (!res) {\n const uniform = device.createBuffer({\n size: UNIFORM_BYTES,\n usage: BUFFER_UNIFORM | BUFFER_COPY_DST,\n });\n res = {\n version: item.version,\n kind: item.kind,\n vertex,\n index,\n order: item.kind === \"mesh\" ? (item.order ?? 0) : 0,\n uniform,\n bindGroup: device.createBindGroup({\n layout: bindGroupLayout,\n entries: [{ binding: 0, resource: { buffer: uniform } }],\n }),\n };\n resources.set(item.key, res);\n } else {\n res.version = item.version;\n res.kind = item.kind;\n res.vertex = vertex;\n res.index = index;\n res.order = item.kind === \"mesh\" ? (item.order ?? 0) : 0;\n }\n return res;\n };\n\n return {\n kind: \"webgpu\",\n canvas,\n resize(width, height) {\n canvas.width = Math.max(1, width);\n canvas.height = Math.max(1, height);\n },\n render(items, frame) {\n if (destroyed) return;\n const { color, depth } = renderTargets();\n const encoder = device.createCommandEncoder();\n const pass = encoder.beginRenderPass({\n colorAttachments: [\n {\n view: color.createView(),\n resolveTarget: context.getCurrentTexture().createView(),\n clearValue: { r: 0, g: 0, b: 0, a: 0 },\n loadOp: \"clear\",\n storeOp: \"discard\",\n },\n ],\n depthStencilAttachment: {\n view: depth.createView(),\n depthClearValue: 1,\n depthLoadOp: \"clear\",\n depthStoreOp: \"discard\",\n },\n });\n const seen = new Set<string>();\n for (const item of drawOrder(items)) {\n seen.add(item.key);\n const count = item.kind === \"mesh\" ? item.indices.length : item.count;\n if (count <= 0) continue;\n const res = upload(item);\n if (!res.vertex) continue;\n device.queue.writeBuffer(\n res.uniform,\n 0,\n itemUniforms(item, frame, uniformData),\n );\n const chosen = pipelineOf(item);\n if (!chosen) continue;\n pass.setPipeline(chosen);\n pass.setBindGroup(0, res.bindGroup);\n pass.setVertexBuffer(0, res.vertex);\n if (item.kind === \"mesh\") {\n if (!res.index) continue;\n pass.setIndexBuffer(res.index, \"uint32\");\n pass.drawIndexed(count);\n } else {\n pass.draw(4, count);\n }\n }\n pass.end();\n device.queue.submit([encoder.finish()]);\n for (const [key, res] of resources) {\n if (!seen.has(key)) {\n release(res);\n res.uniform.destroy();\n resources.delete(key);\n }\n }\n },\n destroy() {\n destroyed = true;\n for (const res of resources.values()) {\n release(res);\n res.uniform.destroy();\n }\n resources.clear();\n targets?.color.destroy();\n targets?.depth.destroy();\n targets = null;\n context.unconfigure();\n device.destroy();\n },\n };\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"webgpu.js","names":["BUFFER_INDEX","BUFFER_VERTEX","BUFFER_COPY_DST","STAGE_FRAGMENT","TEXTURE_RENDER_ATTACHMENT","SAMPLES","OIT_FORMAT","createWebGpu3D","gpu","adapter","fallback","requireHardware","device","context","canvas","format","destroyed","onLost","bindGroupLayout","layout","blend","additive","sum","pipeline","module","oit","blending","depthWrite","pointBuffers","meshBuffers","lineBuffers","pipelines","WGSL_POINTS","WGSL_MESH","WGSL_LINES","additivePoints","pipelineOf","item","variants","writesDepth","compositeLayout","compositeModule","WGSL_COMPOSITE","oitPipelines","orderIndependent","targets","destroyOit","renderTargets","width","height","oitTargets","t","texture","samples","accumResolved","extraResolved","resources","uniformData","buffer","bytes","data","gpuBuffer","usage","release","res","upload","indices","vertex","index","uniform","ordered","drawOrder","items","blended","drawRank","encoder","screen","seen","draw","count","itemUniforms","frame","pass","chosen","main","transparent","last","key"],"sources":["../../../../../charts/src/engine/three-d/webgpu.ts"],"sourcesContent":["// WebGPU backend of the 3D charts: 4× MSAA, a depth buffer, one draw per\n// item (instanced billboards / segments, indexed triangles). With blended\n// items (transparent meshes, blended or additive points), three passes:\n// the opaque items; the blended ones into the float targets of the\n// weighted blended order-independent transparency (`oit.ts`, multisampled,\n// testing the opaque depth, resolved); then their composite and the lines.\n\nimport type { RendererLostHandler } from \"../renderers/types\";\nimport { WGSL_COMPOSITE } from \"./oit\";\nimport {\n POINT_STRIDE,\n SEGMENT_STRIDE,\n VERTEX_STRIDE,\n drawOrder,\n drawRank,\n type Item3D,\n type Renderer3D,\n} from \"./render-types\";\nimport {\n UNIFORM_BYTES,\n WGSL_LINES,\n WGSL_MESH,\n WGSL_POINTS,\n itemUniforms,\n writesDepth,\n} from \"./shaders\";\n\n// lib.dom has the WebGPU interfaces but not these constant objects\nconst BUFFER_INDEX = 0x10;\nconst BUFFER_VERTEX = 0x20;\nconst BUFFER_UNIFORM = 0x40;\nconst BUFFER_COPY_DST = 0x08;\nconst STAGE_VERTEX = 0x1;\nconst STAGE_FRAGMENT = 0x2;\nconst TEXTURE_BINDING = 0x04;\nconst TEXTURE_RENDER_ATTACHMENT = 0x10;\n\nconst SAMPLES = 4;\n/** Format of the transparency targets (renderable, blendable, resolvable) */\nconst OIT_FORMAT: GPUTextureFormat = \"rgba16float\";\n\ninterface ItemResources {\n version: number;\n kind: Item3D[\"kind\"];\n vertex: GPUBuffer | null;\n index: GPUBuffer | null;\n /** `order` of the uploaded indices (meshes) */\n order: number;\n uniform: GPUBuffer;\n bindGroup: GPUBindGroup;\n}\n\ntype GpuNavigator = Navigator & { gpu?: GPU };\n\nexport const createWebGpu3D = async (\n canvas: HTMLCanvasElement,\n onLost: RendererLostHandler,\n /** Refuses fallback (software) adapters */\n requireHardware = false,\n): Promise<Renderer3D | null> => {\n const gpu =\n typeof navigator !== \"undefined\"\n ? (navigator as GpuNavigator).gpu\n : undefined;\n if (!gpu) return null;\n const adapter = await gpu.requestAdapter();\n if (!adapter) return null;\n const fallback = adapter as GPUAdapter & {\n isFallbackAdapter?: boolean;\n info?: { isFallbackAdapter?: boolean };\n };\n if (\n requireHardware &&\n (fallback.info?.isFallbackAdapter || fallback.isFallbackAdapter)\n ) {\n return null;\n }\n const device = await adapter.requestDevice();\n const context = canvas.getContext(\"webgpu\") as GPUCanvasContext | null;\n if (!context) {\n device.destroy();\n return null;\n }\n const format = gpu.getPreferredCanvasFormat();\n context.configure({ device, format, alphaMode: \"premultiplied\" });\n\n let destroyed = false;\n void device.lost.then(() => {\n if (!destroyed) onLost();\n });\n\n const bindGroupLayout = device.createBindGroupLayout({\n entries: [\n {\n binding: 0,\n visibility: STAGE_VERTEX | STAGE_FRAGMENT,\n buffer: { type: \"uniform\" },\n },\n ],\n });\n const layout = device.createPipelineLayout({\n bindGroupLayouts: [bindGroupLayout],\n });\n const blend: GPUBlendState = {\n color: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n alpha: {\n srcFactor: \"one\",\n dstFactor: \"one-minus-src-alpha\",\n operation: \"add\",\n },\n };\n // additive points: the colors add up, the coverage composites as usual\n const additive: GPUBlendState = {\n color: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n alpha: blend.alpha,\n };\n // transparency targets: plain sums\n const sum: GPUBlendState = {\n color: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n };\n const pipeline = (\n code: string,\n buffers: GPUVertexBufferLayout[],\n topology: GPUPrimitiveTopology,\n depthWrite: boolean,\n blending: GPUBlendState = blend,\n oit = false,\n ) => {\n const module = device.createShaderModule({ code });\n return device.createRenderPipeline({\n layout,\n vertex: { module, entryPoint: \"vs\", buffers },\n fragment: {\n module,\n entryPoint: oit ? \"fsOit\" : \"fs\",\n targets: oit\n ? [\n { format: OIT_FORMAT, blend: sum },\n { format: OIT_FORMAT, blend: sum },\n ]\n : [{ format, blend: blending }],\n },\n primitive: { topology, cullMode: \"none\" },\n depthStencil: {\n format: \"depth24plus\",\n depthWriteEnabled: depthWrite,\n depthCompare: \"less-equal\",\n },\n multisample: { count: SAMPLES },\n });\n };\n const pointBuffers: GPUVertexBufferLayout[] = [\n {\n arrayStride: POINT_STRIDE,\n stepMode: \"instance\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x3\" },\n { shaderLocation: 1, offset: 12, format: \"float32\" },\n { shaderLocation: 2, offset: 16, format: \"unorm8x4\" },\n ],\n },\n ];\n const meshBuffers: GPUVertexBufferLayout[] = [\n {\n arrayStride: VERTEX_STRIDE,\n stepMode: \"vertex\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x3\" },\n { shaderLocation: 1, offset: 12, format: \"float32x3\" },\n { shaderLocation: 2, offset: 24, format: \"unorm8x4\" },\n ],\n },\n ];\n const lineBuffers: GPUVertexBufferLayout[] = [\n {\n arrayStride: SEGMENT_STRIDE,\n stepMode: \"instance\",\n attributes: [\n { shaderLocation: 0, offset: 0, format: \"float32x3\" },\n { shaderLocation: 1, offset: 12, format: \"float32x3\" },\n { shaderLocation: 2, offset: 24, format: \"unorm8x4\" },\n ],\n },\n ];\n const pipelines = {\n points: [\n pipeline(WGSL_POINTS, pointBuffers, \"triangle-strip\", false),\n pipeline(WGSL_POINTS, pointBuffers, \"triangle-strip\", true),\n ],\n mesh: [\n pipeline(WGSL_MESH, meshBuffers, \"triangle-list\", false),\n pipeline(WGSL_MESH, meshBuffers, \"triangle-list\", true),\n ],\n lines: [\n pipeline(WGSL_LINES, lineBuffers, \"triangle-strip\", false),\n pipeline(WGSL_LINES, lineBuffers, \"triangle-strip\", true),\n ],\n };\n let additivePoints: GPURenderPipeline | null = null;\n const pipelineOf = (item: Item3D) => {\n if (item.kind === \"points\" && item.additive) {\n additivePoints ??= pipeline(\n WGSL_POINTS,\n pointBuffers,\n \"triangle-strip\",\n false,\n additive,\n );\n return additivePoints;\n }\n const variants = pipelines[item.kind];\n return variants[writesDepth(item) ? variants.length - 1 : 0];\n };\n\n // order-independent transparency: validated once (rgba16float targets are\n // core, but a failing driver falls back to the sorted blending)\n device.pushErrorScope(\"validation\");\n const compositeLayout = device.createBindGroupLayout({\n entries: [0, 1].map((binding) => ({\n binding,\n visibility: STAGE_FRAGMENT,\n texture: { sampleType: \"unfilterable-float\" as const },\n })),\n });\n const compositeModule = device.createShaderModule({ code: WGSL_COMPOSITE });\n const oitPipelines = {\n points: pipeline(\n WGSL_POINTS,\n pointBuffers,\n \"triangle-strip\",\n false,\n blend,\n true,\n ),\n mesh: pipeline(WGSL_MESH, meshBuffers, \"triangle-list\", false, blend, true),\n composite: device.createRenderPipeline({\n layout: device.createPipelineLayout({\n bindGroupLayouts: [compositeLayout],\n }),\n vertex: { module: compositeModule, entryPoint: \"vs\" },\n fragment: {\n module: compositeModule,\n entryPoint: \"fs\",\n targets: [{ format, blend }],\n },\n primitive: { topology: \"triangle-list\" },\n depthStencil: {\n format: \"depth24plus\",\n depthWriteEnabled: false,\n depthCompare: \"always\",\n },\n multisample: { count: SAMPLES },\n }),\n };\n const orderIndependent = !(await device.popErrorScope());\n\n let targets: {\n width: number;\n height: number;\n color: GPUTexture;\n depth: GPUTexture;\n /** Transparency targets, created on first use */\n oit: {\n accum: GPUTexture;\n extra: GPUTexture;\n accumResolved: GPUTexture;\n extraResolved: GPUTexture;\n bindGroup: GPUBindGroup;\n } | null;\n } | null = null;\n const destroyOit = () => {\n const oit = targets?.oit;\n if (!oit) return;\n oit.accum.destroy();\n oit.extra.destroy();\n oit.accumResolved.destroy();\n oit.extraResolved.destroy();\n };\n const renderTargets = () => {\n const width = canvas.width;\n const height = canvas.height;\n if (targets && targets.width === width && targets.height === height)\n return targets;\n targets?.color.destroy();\n targets?.depth.destroy();\n destroyOit();\n targets = {\n width,\n height,\n color: device.createTexture({\n size: [width, height],\n sampleCount: SAMPLES,\n format,\n usage: TEXTURE_RENDER_ATTACHMENT,\n }),\n depth: device.createTexture({\n size: [width, height],\n sampleCount: SAMPLES,\n format: \"depth24plus\",\n usage: TEXTURE_RENDER_ATTACHMENT,\n }),\n oit: null,\n };\n return targets;\n };\n const oitTargets = (t: NonNullable<typeof targets>) => {\n if (t.oit) return t.oit;\n const texture = (samples: number) =>\n device.createTexture({\n size: [t.width, t.height],\n sampleCount: samples,\n format: OIT_FORMAT,\n usage:\n samples > 1\n ? TEXTURE_RENDER_ATTACHMENT\n : TEXTURE_RENDER_ATTACHMENT | TEXTURE_BINDING,\n });\n const accumResolved = texture(1);\n const extraResolved = texture(1);\n t.oit = {\n accum: texture(SAMPLES),\n extra: texture(SAMPLES),\n accumResolved,\n extraResolved,\n bindGroup: device.createBindGroup({\n layout: compositeLayout,\n entries: [\n { binding: 0, resource: accumResolved.createView() },\n { binding: 1, resource: extraResolved.createView() },\n ],\n }),\n };\n return t.oit;\n };\n\n const resources = new Map<string, ItemResources>();\n const uniformData = new Float32Array(UNIFORM_BYTES / 4);\n\n const buffer = (data: ArrayBuffer | Uint32Array, usage: number) => {\n const bytes = data.byteLength;\n if (bytes <= 0) return null;\n const gpuBuffer = device.createBuffer({\n size: Math.max(16, Math.ceil(bytes / 4) * 4),\n usage: usage | BUFFER_COPY_DST,\n });\n if (data instanceof Uint32Array) {\n device.queue.writeBuffer(\n gpuBuffer,\n 0,\n data.buffer,\n data.byteOffset,\n bytes,\n );\n } else {\n device.queue.writeBuffer(gpuBuffer, 0, data);\n }\n return gpuBuffer;\n };\n\n const release = (res: ItemResources) => {\n res.vertex?.destroy();\n res.index?.destroy();\n };\n\n const upload = (item: Item3D): ItemResources => {\n let res = resources.get(item.key);\n if (res && res.version === item.version && res.kind === item.kind) {\n // same mesh, triangles in a new order (transparent, sorted by depth)\n if (\n item.kind === \"mesh\" &&\n res.index &&\n (item.order ?? 0) !== res.order\n ) {\n const { indices } = item;\n device.queue.writeBuffer(\n res.index,\n 0,\n indices.buffer,\n indices.byteOffset,\n indices.byteLength,\n );\n res.order = item.order ?? 0;\n }\n return res;\n }\n if (res) release(res);\n const vertex = buffer(\n item.kind === \"mesh\" ? item.vertices : item.data,\n BUFFER_VERTEX,\n );\n const index =\n item.kind === \"mesh\" ? buffer(item.indices, BUFFER_INDEX) : null;\n if (!res) {\n const uniform = device.createBuffer({\n size: UNIFORM_BYTES,\n usage: BUFFER_UNIFORM | BUFFER_COPY_DST,\n });\n res = {\n version: item.version,\n kind: item.kind,\n vertex,\n index,\n order: item.kind === \"mesh\" ? (item.order ?? 0) : 0,\n uniform,\n bindGroup: device.createBindGroup({\n layout: bindGroupLayout,\n entries: [{ binding: 0, resource: { buffer: uniform } }],\n }),\n };\n resources.set(item.key, res);\n } else {\n res.version = item.version;\n res.kind = item.kind;\n res.vertex = vertex;\n res.index = index;\n res.order = item.kind === \"mesh\" ? (item.order ?? 0) : 0;\n }\n return res;\n };\n\n return {\n kind: \"webgpu\",\n canvas,\n orderIndependent,\n resize(width, height) {\n canvas.width = Math.max(1, width);\n canvas.height = Math.max(1, height);\n },\n render(items, frame) {\n if (destroyed) return;\n const t = renderTargets();\n const ordered = drawOrder(items);\n const blended =\n orderIndependent && ordered.some((item) => drawRank(item) === 2);\n const encoder = device.createCommandEncoder();\n const screen = context.getCurrentTexture().createView();\n const seen = new Set<string>();\n /** Draws an item; false when it has nothing to draw */\n const draw = (\n pass: GPURenderPassEncoder,\n item: Item3D,\n chosen: GPURenderPipeline,\n ) => {\n const count = item.kind === \"mesh\" ? item.indices.length : item.count;\n if (count <= 0) return;\n const res = upload(item);\n if (!res.vertex) return;\n device.queue.writeBuffer(\n res.uniform,\n 0,\n itemUniforms(item, frame, uniformData),\n );\n pass.setPipeline(chosen);\n pass.setBindGroup(0, res.bindGroup);\n pass.setVertexBuffer(0, res.vertex);\n if (item.kind === \"mesh\") {\n if (!res.index) return;\n pass.setIndexBuffer(res.index, \"uint32\");\n pass.drawIndexed(count);\n } else {\n pass.draw(4, count);\n }\n };\n\n // opaque items (every item without blended ones)\n const main = encoder.beginRenderPass({\n colorAttachments: [\n {\n view: t.color.createView(),\n resolveTarget: blended ? undefined : screen,\n clearValue: { r: 0, g: 0, b: 0, a: 0 },\n loadOp: \"clear\",\n storeOp: blended ? \"store\" : \"discard\",\n },\n ],\n depthStencilAttachment: {\n view: t.depth.createView(),\n depthClearValue: 1,\n depthLoadOp: \"clear\",\n depthStoreOp: blended ? \"store\" : \"discard\",\n },\n });\n for (const item of ordered) {\n if (blended && drawRank(item) > 1) break;\n seen.add(item.key);\n draw(main, item, pipelineOf(item));\n }\n main.end();\n\n if (blended) {\n // blended items, in any order, into the transparency targets\n const oit = oitTargets(t);\n const transparent = encoder.beginRenderPass({\n colorAttachments: [\n {\n view: oit.accum.createView(),\n resolveTarget: oit.accumResolved.createView(),\n clearValue: { r: 0, g: 0, b: 0, a: 0 },\n loadOp: \"clear\",\n storeOp: \"discard\",\n },\n {\n view: oit.extra.createView(),\n resolveTarget: oit.extraResolved.createView(),\n clearValue: { r: 0, g: 0, b: 0, a: 0 },\n loadOp: \"clear\",\n storeOp: \"discard\",\n },\n ],\n depthStencilAttachment: {\n view: t.depth.createView(),\n depthReadOnly: true,\n },\n });\n for (const item of ordered) {\n if (drawRank(item) !== 2 || item.kind === \"lines\") continue;\n seen.add(item.key);\n draw(transparent, item, oitPipelines[item.kind]);\n }\n transparent.end();\n\n // their composite over the opaque items, then the lines\n const last = encoder.beginRenderPass({\n colorAttachments: [\n {\n view: t.color.createView(),\n resolveTarget: screen,\n loadOp: \"load\",\n storeOp: \"discard\",\n },\n ],\n depthStencilAttachment: {\n view: t.depth.createView(),\n depthLoadOp: \"load\",\n depthStoreOp: \"discard\",\n },\n });\n last.setPipeline(oitPipelines.composite);\n last.setBindGroup(0, oit.bindGroup);\n last.draw(3);\n for (const item of ordered) {\n if (drawRank(item) < 3) continue;\n seen.add(item.key);\n draw(last, item, pipelineOf(item));\n }\n last.end();\n }\n device.queue.submit([encoder.finish()]);\n for (const [key, res] of resources) {\n if (!seen.has(key)) {\n release(res);\n res.uniform.destroy();\n resources.delete(key);\n }\n }\n },\n destroy() {\n destroyed = true;\n for (const res of resources.values()) {\n release(res);\n res.uniform.destroy();\n }\n resources.clear();\n targets?.color.destroy();\n targets?.depth.destroy();\n destroyOit();\n targets = null;\n context.unconfigure();\n device.destroy();\n },\n };\n};\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../dom.cjs"),t=require("../color.cjs"),n=require("../locale.cjs"),r=require("../scale.cjs"),i=require("../renderers/detect.cjs"),a=require("../theme.cjs"),o=require("./drawings.cjs"),s=require("./format.cjs"),c=require("./geometry.cjs"),l=require("./indicators.cjs"),u=require("./labels.cjs"),d=require("./scale.cjs"),f=require("./store.cjs"),p=require("./studies.cjs");var m=28,h=60,g=60,_=48,v=`price`,y=`var(--success-color, #089981)`,b=`var(--danger-color, #f23645)`,x=`var(--warning-color, #f59e0b)`,S=`var(--primary-color, #2962ff)`,C=100,w=[`#2962ff`,`#089981`,`#f23645`,`#f59e0b`,`#a855f7`,`#0ea5e9`,`#ec4899`,`#787b86`],ee=[`solid`,`dashed`,`dotted`],T=new WeakMap,te={order:`limit`,position:`position`,takeProfit:`takeProfit`,stopLoss:`stopLoss`,alert:`alert`},E=(e,t,n)=>e<t?t:e>n?n:e,ne=e=>{let n=t.parseColor(e);return n&&t.luminance(n)>.5?`#0b0e11`:`#fff`},D=Number.isFinite,re=(re,ie={})=>{let O=re.ownerDocument,ae=O.defaultView,k={...ie},oe=!1,se=(t,n)=>e.styleElement(O.createElement(t),n),A=se(`div`,{position:`relative`,width:`100%`,height:`100%`,minHeight:`0`,overflow:`hidden`,outline:`none`,userSelect:`none`,touchAction:`pan-y`,fontFamily:`var(--font-family-sans, system-ui, sans-serif)`,color:`var(--text-color, #1f2937)`,cursor:`crosshair`});A.className=`minerva-trading-chart`,A.tabIndex=0,A.setAttribute(`role`,`figure`),A.setAttribute(`aria-roledescription`,`chart`);let ce=e=>se(e,{position:`absolute`,left:`0`,top:`0`,pointerEvents:`none`}),le=ce(`canvas`),ue=ce(`canvas`);le.setAttribute(`aria-hidden`,`true`),ue.setAttribute(`aria-hidden`,`true`);let de=ce(`div`);de.style.right=`0`,de.style.bottom=`0`;let fe=se(`button`,{position:`absolute`,display:`none`,alignItems:`center`,justifyContent:`center`,width:`28px`,height:`28px`,padding:`0`,borderRadius:`50%`,border:`1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 80%, transparent)`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,color:`var(--text-color, #1f2937)`,boxShadow:`0 4px 14px -4px rgba(15, 23, 42, 0.25)`,cursor:`pointer`});fe.type=`button`,fe.innerHTML=`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l5 5-5 5M9 3l5 5-5 5"/></svg>`;let pe=se(`div`,{position:`absolute`,width:`1px`,height:`1px`,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`});pe.setAttribute(`aria-live`,`polite`);let j=se(`div`,{position:`absolute`,display:`none`,alignItems:`center`,gap:`1px`,padding:`3px`,borderRadius:`8px`,border:`1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 85%, transparent)`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,boxShadow:`0 8px 24px -8px rgba(15, 23, 42, 0.35)`,zIndex:`2`,cursor:`default`});j.className=`minerva-trading-toolbar`,j.setAttribute(`role`,`toolbar`);let M=se(`textarea`,{position:`absolute`,display:`none`,minWidth:`120px`,minHeight:`28px`,padding:`5px 9px`,resize:`none`,border:`1px solid var(--primary-color, #2962ff)`,borderRadius:`5px`,outline:`none`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,color:`var(--text-color, #1f2937)`,font:`500 13px var(--font-family-sans, system-ui, sans-serif)`,boxShadow:`0 6px 18px -6px rgba(15, 23, 42, 0.3)`,zIndex:`3`});M.rows=1;let me=se(`style`,{});me.textContent=`.minerva-trading-toolbar button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:26px;padding:0 5px;border-radius:5px;cursor:pointer;color:var(--text-color,#1f2937)}.minerva-trading-toolbar button:hover{background:color-mix(in srgb,var(--text-color,#1f2937) 9%,transparent)}.minerva-trading-toolbar button:focus-visible{box-shadow:inset 0 0 0 2px var(--primary-color,#2962ff)}.minerva-trading-toolbar button[aria-pressed="true"]{background:color-mix(in srgb,var(--primary-color,#2962ff) 16%,transparent);color:var(--primary-color,#2962ff)}.minerva-trading-toolbar .sep{width:1px;height:18px;margin:0 3px;background:var(--border-color,#e5e7eb)}`,A.append(me,le,ue,de,fe,j,M,pe),re.appendChild(A);let N=f.createStore(),he=f.createPyramid(),ge={time:N.time,open:new Float64Array,high:new Float64Array,low:new Float64Array,close:new Float64Array,volume:N.volume},_e=0,ve=f.createPyramid(),P=[],ye=new Map,be=new Map,xe=[],Se=new WeakMap,Ce=0,we=0,Te=2,Ee=s.DAY,F=k.barSpacing??8,I=NaN,L=0,R=0,De=h,Oe=0,ke=0,z=[],Ae=new Map,je=new Map,Me=null,Ne=0,B=a.readTheme(A),Pe=0,Fe=0,V=null,Ie=0,Le=0,Re=[],ze=``,Be=-1,Ve=0,He,Ue=new Promise(e=>{He=e}),H=null,U=null,W=null,We=new Map,Ge=null,Ke=null,qe=null,Je=null,G=k.drawings??[],Ye=null,Xe=G,Ze=[],Qe=[],$e=`false|false`,et=k.drawingMode??`cursor`,tt=null,nt=null,K=null,rt=0,it=v,at=0,ot=new Map,st=null,ct=``,lt=!1,ut=new Map,dt=null,ft=[],pt=-1,mt=null,ht=!1,gt=null,_t=``,vt=NaN,yt=null,q=null,bt=!1,xt=4,St=null,Ct=new Map,J=(e,t)=>{Ct.get(e)?.forEach(e=>e(t))},Y=n.resolveLocale(k.locale),wt=n.localeLabels(u.TRADING_LABELS,Y,k.labels),Tt=()=>{Y=n.resolveLocale(k.locale),wt=n.localeLabels(u.TRADING_LABELS,Y,k.labels)},Et=()=>wt,X=()=>N.length,Dt=()=>k.chartStyle??`candles`,Ot=()=>k.colorConvention===`redUp`,kt=()=>k.upColor??(Ot()?b:y),At=()=>k.downColor??(Ot()?y:b),jt=(e,t=B.primary)=>B.resolve?B.resolve(e,t):t,Z=(e,n=1)=>t.toCss(jt(e),n),Mt=()=>k.precision??Te,Nt=s.priceFormatter(2,void 0),Pt=``,Ft=e=>{if(k.formatPrice)return k.formatPrice(e);let t=`${Mt()}|${Y}`;return t!==Pt&&(Nt=s.priceFormatter(Mt(),Y),Pt=t),Nt(e)},It=()=>(k.timeframe===void 0?null:l.parseTimeframe(k.timeframe))??{unit:`ms`,count:Ee,ms:Ee},Lt=()=>It().ms,Rt=(e,t=400)=>`${t} ${e}px ${B.fontFamily}`,zt=e=>be.get(e.id)??e.config.visible??!0,Q=e=>L+(e-I)*F,Bt=e=>I-(L-e)/F,Vt=e=>{let t=X();if(!t)return 0;let n=Math.round(e);return n<0?N.time[0]+n*Lt():n>=t?N.time[t-1]+(n-t+1)*Lt():N.time[n]},Ht=e=>{let t=X();if(!t)return 0;let n=Math.floor(e);if(n<0||n>=t-1){let r=n<0?0:t-1;return N.time[r]+(e-r)*Lt()}let r=e-n;return N.time[n]+r*(N.time[n+1]-N.time[n])},Ut=e=>{let t=X();if(!t)return 0;if(e>=N.time[t-1])return t-1+(e-N.time[t-1])/Lt();if(e<=N.time[0])return(e-N.time[0])/Lt();let n=f.indexOfTime(N.time,t,e),r=N.time[n+1]-N.time[n];return n+(r>0?(e-N.time[n])/r:0)},Wt,Gt=e=>k.utcOffset??(Wt?s.zoneOffset(e,Wt):-new Date(D(e)?e:0).getTimezoneOffset()),Kt=e=>Gt(e),qt=e=>e+Gt(e)*s.MINUTE,Jt=e=>e===`up`?kt():e===`down`?At():e,Yt=(e,t,n)=>e.level?f.rangeLevel(n,t,X(),e.level):{min:t,max:t,last:t},Xt=e=>{let t=Se.get(e);return t||Se.set(e,t=f.createRangePyramid()),t},Zt=e=>{let t=X();if(!t)return 0;let n=N.time[t-1];return e>n?t-1+(e-n)/Lt():e<N.time[0]?(e-N.time[0])/Lt():f.indexOfTime(N.time,t,e)},Qt=()=>Dt()===`heikinAshi`?ge:N,$t=e=>{for(let t of P){ye.set(t,Math.min(ye.get(t)??0,e));for(let n of t.outputs){let t=Se.get(n);t&&f.invalidateRangePyramid(t,e)}}_e=Math.min(_e,e);for(let t of xe)t.valid=Math.min(t.valid,e),f.invalidateRangePyramid(t.lod,e);St=null;let t=t=>{for(let n of t.levels)n&&(n.valid=Math.min(n.valid,Math.floor(e/n.size)))};t(he),t(ve)},en=()=>{let e=X();for(let t of P){let n=ye.get(t)??0;n<e&&(t.compute(N,n),ye.set(t,e))}if(ge.time=N.time,ge.volume=N.volume,Dt()===`heikinAshi`&&_e<e){if(ge.open.length<N.capacity)for(let e of[`open`,`high`,`low`,`close`]){let t=new Float64Array(N.capacity);t.set(ge[e].subarray(0,_e)),ge[e]=t}l.heikinAshiInto(N.open,N.high,N.low,N.close,e,ge,_e),_e=e}for(let t of xe)if(!(t.valid>=e)){if(t.values.length<N.capacity){let e=new Float64Array(N.capacity).fill(NaN);e.set(t.values.subarray(0,t.valid)),t.values=e}for(let n=t.valid;n<e;n++){let e=f.lowerBoundTime(t.times,t.times.length,N.time[n]+.5)-1;t.values[n]=e>=0?t.data[e]:NaN}t.valid=e}},tn=e=>{$t(e);let t=X();e<t-1&&Ce++,we++,t&&(Te=Math.max(e===0?0:Te,s.detectPrecision(N.close,e,t),s.detectPrecision(N.open,Math.max(e,t-50),t)),(e===0||t<80)&&(Ee=s.inferTimeframe(N.time,t))),$()},nn=()=>{let{studies:e,reused:t}=p.buildStudies(k.indicators??[],P,Kt);for(let e of P)t.has(e)||ye.delete(e);for(let n of e)t.has(n)||ye.set(n,0);P=e;for(let e of[...be.keys()])P.some(t=>t.id===e)||be.delete(e)},rn=()=>{xe=(k.compare??[]).map((e,t)=>{let n=[...e.data].sort((e,t)=>e.time-t.time);return{id:e.id??e.name,name:e.name,color:e.color??p.LINE_COLORS[(t+2)%p.LINE_COLORS.length],width:e.lineWidth??1.5,times:Float64Array.from(n,e=>e.time),data:Float64Array.from(n,e=>e.value),values:new Float64Array,valid:0,lod:f.createRangePyramid()}})},an=()=>{let e=X();if(!e||!D(I))return!0;let t=Q(e-1);return t>=0&&t<=L+F*.5},on=e=>{f.setBars(N,e),he=f.createPyramid(),ve=f.createPyramid(),_e=0,vt=NaN;for(let e of Ae.values())e.auto=!0;I=X()-1+(k.rightOffset??8),Ke=null,qe=null,tn(0)},sn=e=>{let t=X(),n=f.inputLength(e);if(t>=2&&n>=t){let r=f.barAt(e,0).time,i=N.time[t-1];if(r===N.time[0]&&f.barAt(e,t-2).time===N.time[t-2]){let r=an(),i=t,a=t;for(let r=t-1;r<n;r++){let t=f.updateBar(N,f.barAt(e,r));t>=0&&(a=Math.min(a,t))}r&&(I+=X()-i),a<X()&&tn(a);return}if(f.barAt(e,n-1).time===i&&n>t){let r=n-t;f.setBars(N,e),he=f.createPyramid(),ve=f.createPyramid(),_e=0,I+=r,tn(0);return}}on(e)},cn=()=>{let e=P.filter(e=>!e.overlay),t=R,n=e.map(e=>je.get(e.id)??e.height),r=n.reduce((e,t)=>e+t,0),i=Math.max(0,t*.62),a=r>i&&r>0?i/r:1,o=n.map(e=>Math.max(_*Math.min(1,a*2),e*a)),s=Math.max(40,t-o.reduce((e,t)=>e+t,0)),c=[],l=(e,t)=>{let n=Ae.get(e);return n||(n=d.createScale(t),Ae.set(e,n)),n.mode!==t&&(n.mode=t,n.auto=!0),n},u=l(v,k.scaleMode??`linear`);u.top=0,u.height=s,u.marginTop=.1,u.marginBottom=.08,c.push({id:v,study:null,scale:u,top:0,height:s,ticks:[],step:0});let f=s;e.forEach((e,t)=>{let n=l(e.id,`linear`);n.top=f,n.height=o[t],n.marginTop=e.type===`volume`?.18:.14,n.marginBottom=e.type===`volume`?0:.1,e.range&&(n.marginTop=n.marginBottom=.06),c.push({id:e.id,study:e,scale:n,top:f,height:o[t],ticks:[],step:0}),f+=o[t]});for(let e of[...Ae.keys()])c.some(t=>t.id===e)||Ae.delete(e);z=c},ln=e=>z.find(t=>e>=t.top&&e<t.top+t.height)??null,un=()=>{let e=X(),t=Math.min(1,L*.8/Math.max(1,e));F=E(F,Math.max(1e-4,t),g);let n=L/F;D(I)||(I=e-1+(k.rightOffset??8));let r=Math.max(0,e-1)+Math.max(k.rightOffset??8,n*.75),i=Math.min(n*.25,r);I=E(I,i,r)},dn=()=>{let e=X();if(!e)return null;let t=I-L/F,n=F>=2?0:Math.ceil(Math.log2(2/F)),r=2**n,i=Qt(),a=n?f.pyramidLevel(Dt()===`heikinAshi`?ve:he,i,e,n):i,o=Math.floor((e-1)/r),s=E(Math.floor(t)-1,0,e-1),c=E(Math.ceil(I)+1,0,e-1),l=E(Math.ceil(t-.5),0,e-1),u=E(Math.floor(I+.5),0,e-1);return{left:t,level:n,size:r,cols:a,g0:Math.floor(s/r),g1:Math.floor(c/r),s0:Math.floor(l/r),s1:Math.floor(u/r),last:o}},fn=(e,t)=>t*e.size+(e.size-1)/2,pn=(e,t)=>Math.min(e.size,X()-t*e.size),mn=()=>E(Math.ceil(I-L/F-.5),0,Math.max(0,X()-1)),hn=e=>{let t=X();for(let n=mn();n<t;n++){let t=e.values[n];if(D(t)&&t!==0)return t}return NaN},gn=(e,t,n)=>e.mode===`percent`?(t/n-1)*100:d.toScaled(e,t),_n=()=>k.baselinePrice??Qt().close[mn()],vn=(e,t,n,r,i)=>{let a=Yt(e,t,n),o=Math.round(r/e.size),s=E(e.s0-o,0,e.last),c=E(e.s1-o,0,e.last);for(let e=s;e<=c;e++)a.min[e]<i[0]&&(i[0]=a.min[e]),a.max[e]>i[1]&&(i[1]=a.max[e])},yn=e=>{Ne=0;for(let t of z){let n=t.scale;if(!e)continue;if(t.id===v){n.base=N.close[mn()]||1;let{cols:t}=e,r=Dt(),i=r===`line`||r===`area`||r===`baseline`,a=[1/0,-1/0];for(let n=e.s0;n<=e.s1;n++){let e=i?t.close[n]:t.low[n],r=i?t.close[n]:t.high[n];e<a[0]&&(a[0]=e),r>a[1]&&(a[1]=r)}for(let n of P)if(n.overlay&&zt(n)){if(n.type===`volume`){for(let n=e.s0;n<=e.s1;n++){let r=t.volume[n]/pn(e,n);r>Ne&&(Ne=r)}continue}for(let t of n.outputs)vn(e,t.values,Xt(t),t.shift,a)}let[o,s]=a;if(r===`baseline`){let e=_n();e<o&&(o=e),e>s&&(s=e)}if(!n.auto)continue;let c=d.toScaled(n,o),l=d.toScaled(n,s);n.mode===`log`&&!(o>0)&&(c=d.toScaled(n,Math.max(s*.001,1e-12)));for(let t of xe){let r=hn(t),i=[1/0,-1/0];vn(e,t.values,t.lod,0,i);for(let e of i){let t=gn(n,e,r);t<c&&(c=t),t>l&&(l=t)}}n.mode===`percent`&&xe.length&&(c=Math.min(c,0),l=Math.max(l,0)),d.fitScale(n,c,l);continue}let r=t.study;if(!r||!n.auto)continue;if(r.range){d.fitScale(n,r.range[0],r.range[1]);continue}let i=[1/0,-1/0];r.type===`volume`&&(i[0]=0);for(let t of r.outputs){if(t.kind===`volume`){for(let t=e.s0;t<=e.s1;t++){let n=e.cols.volume[t]/pn(e,t);n>i[1]&&(i[1]=n)}continue}vn(e,t.values,Xt(t),t.shift,i)}let[a,o]=i;if(r.bands&&D(a)&&D(o))for(let e of r.bands)a=Math.min(a,e),o=Math.max(o,e);r.zero&&D(a)&&D(o)&&(a=Math.min(a,0),o=Math.max(o,0)),d.fitScale(n,a,o)}},bn=(e,t)=>{let n=X();if(!n||!e)return[];let r=Lt(),i=r<s.DAY,a=Math.floor(Math.max(0,Math.ceil(I))/e.size),o=t=>t<=e.last?e.cols.time[t]:N.time[n-1]+(t*e.size-(n-1))*r,c=[],l=e.g0>0?qt(o(e.g0-1)):NaN;for(let t=e.g0;t<=a;t++){let n=qt(o(t)),r=Q(fn(e,t)),i=s.boundaryWeight(l,n);r>=-20&&r<=L+20&&i>10&&c.push({x:r,weight:i,time:n}),l=n}t.font=Rt(B.fontSize);let u=i?`00:00`:`Sep 30`,d=Math.max(t.measureText(u).width,t.measureText(`2024`).width)+34;return s.pickTicks(c,d).filter(e=>e.x>8&&e.x<L-8).map(e=>({x:e.x,text:s.tickText(e.time,e.weight,Y,i),bold:e.weight>=(i?50:60)}))},xn=(e,t)=>e.id===v?e.scale.mode===`percent`?s.formatPercent(t,Y,Math.min(2,r.stepDecimals(e.step))):Ft(d.fromScaled(e.scale,t)):e.study?.compact?s.formatVolume(t,Y):s.formatFixed(t,Math.min(4,r.stepDecimals(e.step)),Y),Sn=(e,t)=>e.overlay&&e.type!==`volume`?Ft(t):e.compact?s.formatVolume(t,Y):s.formatFixed(t,e.range?2:Math.max(2,Math.min(6,Mt())),Y),Cn=(e,n)=>{let r=[],i=e.cols,a=jt(kt()),o=jt(At()),s=t.packColor(a),l=t.packColor(o),u=B.background,f=c.candleMetrics(F*e.size*n,n),p=t=>Q(fn(e,t))*n,m=Dt(),h=Math.max(.5,f.body/2),g={up:t.packColor([a[0],a[1],a[2],.5]),down:t.packColor([o[0],o[1],o[2],.5])};for(let _ of z){let y=_.top*n,b=(_.top+_.height)*n,x=_.scale,C=e=>d.yOf(x,e)*n,w=(t,n,r,i=C)=>(a,o,s)=>{let l=new c.LineBuffer(y,b);for(let n=s?Math.max(e.g0,a-1):a;n<=o;n++)l.push(p(n),i(t(n)));return l.count>1?[l.item(``,0,n,r)]:[]},ee=(t,r,i,a,o=0,s=C)=>(l,u,d)=>{let f=Yt(e,t,r),m=o*F*n,h=Math.ceil(Math.abs(o)/e.size)+1,g=d?Math.max(0,l-1):l,_=u;!d&&o>0&&(g=Math.max(0,g-h)),!d&&o<0&&(_=Math.min(e.last-1,_+h));let v=new c.LineBuffer(y,b),x=NaN;for(let t=g;t<=_;t++){let n=p(t)+m,r=f.min[t],i=f.max[t];if(!e.level||r===i||!D(r)||!D(i)){x=s(f.last[t]),v.push(n,x);continue}let a=s(r),o=s(i),c=D(x)&&Math.abs(x-o)<Math.abs(x-a)?o:a,l=c===o?a:o;v.push(n,c),v.push(n,l),x=l}return v.count>1?[v.item(``,0,i,a)]:[]};if(_.id===v){if(P.find(e=>e.overlay&&e.type===`volume`&&zt(e))&&Ne>0){let t=(b-y)*.2;r.push((n,r)=>{let a=new c.BarBuffer;for(let o=n;o<=r;o++){let n=i.volume[o]/pn(e,o);if(!(n>0))continue;let r=b-n/Ne*t,[s,l]=c.pixelRange(r,b);a.push(f.snap(p(o)),s,l,i.close[o]>=i.open[o]?g.up:g.down)}return[a.item(``,0,h)]})}for(let e of xe){let t=hn(e),i=jt(e.color);r.push(ee(e.values,e.lod,i,e.width,0,e=>d.yOfScaled(x,gn(x,e,t))*n))}if(m===`line`||m===`area`||m===`baseline`){let t=jt(S);if(m===`area`&&r.push((n,r,a)=>{let o=new c.AreaBuffer(y,b);for(let t=a?Math.max(e.g0,n-1):n;t<=r;t++)o.push(p(t),C(i.close[t]),b);return o.count>1?[o.item(``,0,t,.28)]:[]}),m===`baseline`){let t=C(_n());r.push((n,r,s)=>{let l=new c.AreaBuffer(y,b),u=new c.AreaBuffer(y,b),d=new c.LineBuffer(y,b),f=new c.LineBuffer(y,b),m=NaN,h=NaN,g=(e,n)=>{l.push(e,Math.min(n,t),t),u.push(e,Math.max(n,t),t),n<=t?d.push(e,n):d.break(),n>=t?f.push(e,n):f.break()};for(let a=s?Math.max(e.g0,n-1):n;a<=r;a++){let e=p(a),n=C(i.close[a]);if(D(h)&&(h-t)*(n-t)<0){let r=(t-h)/(n-h);g(m+(e-m)*r,t)}g(e,n),m=e,h=n}let _=[];return l.count>1&&_.push(l.item(`u`,0,a,.22),u.item(`d`,0,o,.22)),d.count>1&&_.push(d.item(`ul`,0,a,2)),f.count>1&&_.push(f.item(`dl`,0,o,2)),_})}else r.push(w(e=>i.close[e],t,2))}else{let e=m===`hollowCandles`,t=m===`bars`,n=f.wick,a=f.body;r.push((r,o)=>{let u=new c.BarBuffer,d=new c.BarBuffer,m=new c.BarBuffer,h=new c.BarBuffer,g=Math.max(n,Math.round((a-n)/2));for(let _=r;_<=o;_++){let r=i.open[_],o=i.high[_],v=i.low[_],x=i.close[_];if(!D(r)||!D(x))continue;let S=(e?x>=(_>0?i.close[_-1]:r):x>=r)?s:l,w=f.snap(p(_)),[ee,T]=c.pixelRange(C(o),C(v));if(t){let e=c.clampRange(ee,T,y,b);e&&u.push(w,e[0],e[1],S);for(let[e,t]of[[r,-1],[x,1]]){let r=Math.round(C(e)-n/2);r<y||r+n>b||h.push(w+t*(n/2+g/2),r,r+n,S)}continue}let[te,E]=c.pixelRange(C(r),C(x));if(a<=n){let e=c.clampRange(ee,T,y,b);e&&u.push(w,e[0],e[1],S);continue}if(e&&x>r){let e=[[ee,te],[E,T]];for(let[t,n]of e){let e=n>t?c.clampRange(t,n,y,b):null;e&&u.push(w,e[0],e[1],S)}let t=c.clampRange(te,E,y,b);t&&(u.push(w-a/2+n/2,t[0],t[1],S),u.push(w+a/2-n/2,t[0],t[1],S));for(let e of[te,E-n])e>=y&&e+n<=b&&m.push(w,e,e+n,S);continue}let ne=c.clampRange(ee,T,y,b);ne&&u.push(w,ne[0],ne[1],S);let re=c.clampRange(te,E,y,b);re&&d.push(w,re[0],re[1],S)}let _=[u.item(`w`,0,n/2)];return d.count&&_.push(d.item(`b`,0,a/2)),m.count&&_.push(m.item(`c`,0,a/2)),h.count&&_.push(h.item(`t`,0,g/2)),_})}}let T=_.id===v?P.filter(e=>e.overlay&&e.type!==`volume`):_.study?[_.study]:[];for(let d of T)if(zt(d))for(let m of d.outputs)if(m.kind===`volume`){let t=C(0);r.push((n,r)=>{let a=new c.BarBuffer;for(let o=n;o<=r;o++){let n=i.volume[o]/pn(e,o);if(!(n>0))continue;let r=c.clampRange(...c.pixelRange(C(n),t),y,b);r&&a.push(f.snap(p(o)),r[0],r[1],i.close[o]>=i.open[o]?g.up:g.down)}return[a.item(``,0,h)]})}else if(m.kind===`histogram`){let n=C(0),i={up:s,down:l},d={up:t.packColor(t.mix(u,a,.45)),down:t.packColor(t.mix(u,o,.45))},g=Xt(m);r.push((t,r)=>{let a=Yt(e,m.values,g),o=new c.BarBuffer;for(let s=t;s<=r;s++){let t=a.last[s];if(!D(t))continue;let r=s>0?a.last[s-1]:t,l=t>=0?t>=r?i.up:d.up:t<=r?i.down:d.down,u=Math.min(0,D(a.min[s])?a.min[s]:t),m=Math.max(0,D(a.max[s])?a.max[s]:t),h=c.clampRange(...e.level?c.pixelRange(C(m),C(u)):c.pixelRange(C(t),n),y,b);h&&o.push(f.snap(p(s)),h[0],h[1],l)}return[o.item(``,0,h)]})}else if(m.kind===`dots`){let a=m.color?t.packColor(jt(Jt(m.color))):0,o=E(F*e.size*.22,1.25,2.6),u=o*n;r.push((t,n)=>{let r=new c.BarBuffer;for(let o=t;o<=n;o++){let t=e.level?m.values[Math.min(X()-1,o*e.size+e.size-1)]:m.values[o];if(!D(t))continue;let n=C(t);if(n<y||n>b)continue;let c=a||(t<=i.close[o]?s:l);r.push(p(o),n-u,n+u,c)}return r.count?[r.item(``,0,u,0,o)]:[]})}else{let e=jt(Jt(m.color));r.push(ee(m.values,Xt(m),[e[0],e[1],e[2],e[3]*m.alpha],m.width,m.shift))}}return r},wn=(e,t,n,r)=>{let i=Math.min(n.g1,n.last-1),a=r?n.last>=n.g0&&n.last<=n.g1?e(n.last,n.last,!0):[]:i>=n.g0?e(n.g0,i,!1):[],o=++Ve;return a.map((e,n)=>({...e,key:`L${t}:${n}:${e.kind}:${e.key}${r?`:live`:``}`,version:o}))},Tn=(t,n)=>{if(!V)return;let r=V.canvas;e.styleElement(r,{left:`0px`,top:`0px`,width:`${L}px`,height:`${R}px`});let i=Math.max(1,Math.round(L*n)),a=Math.max(1,Math.round(R*n));if((r.width!==i||r.height!==a)&&V.resize(i,a),t){let e=[i,a,n,F,I,t.level,Dt(),Ce,Pe,Fe,Ne,Dt()===`baseline`?_n():0,...z.map(e=>`${e.id}:${e.top}:${e.height}:${e.scale.min}:${e.scale.max}:${e.scale.base}:${e.scale.mode}`),...P.map(e=>`${e.id}:${zt(e)}`)].join(`|`);e===ze?Be!==we&&(Be=we,Re.forEach((e,n)=>{e.live=wn(e.fn,n,t,!0)})):(ze=e,Be=we,Re=Cn(t,n).map(e=>({fn:e,main:[],live:[]})),Re.forEach((e,n)=>{e.main=wn(e.fn,n,t,!1),e.live=wn(e.fn,n,t,!0)}))}else Re=[],ze=``;let o=Re.flatMap(e=>[...e.main,...e.live]);V.render(o,{transform:{xScale:2/i,xOffset:-1,yScale:-2/a,yOffset:1},width:i,height:a,dpr:n})},En=(e,t)=>{let n=Math.max(1,Math.round(Oe*t)),r=Math.max(1,Math.round(ke*t));e.width!==n&&(e.width=n),e.height!==r&&(e.height=r),e.style.width=`${Oe}px`,e.style.height=`${ke}px`},Dn=(e,t,n,r,i,a)=>{e.beginPath(),typeof e.roundRect==`function`?e.roundRect(t,n,r,i,a):e.rect(t,n,r,i)},On=(e,t,n,r,i)=>{let a=r.outputs[i.a],o=r.outputs[i.b];if(!a||!o)return;let s=Yt(t,a.values,Xt(a)),c=Yt(t,o.values,Xt(o)),l=a.shift,u=Math.ceil(Math.abs(l)/t.size)+1,f=Math.max(0,t.g0-(l>0?u:0)),p=Math.min(t.last,t.g1+(l<0?u:0)),m=Z(Jt(i.color),i.opacity),h=Z(Jt(i.colorBelow??i.color),i.opacity);e.save(),e.beginPath(),e.rect(0,n.top,L,n.height),e.clip();let g=[],_=0,v=()=>{if(g.length>1){e.fillStyle=_>=0?m:h,e.beginPath(),g.forEach((t,n)=>n?e.lineTo(t.x,t.ya):e.moveTo(t.x,t.ya));for(let t=g.length-1;t>=0;t--){let n=g[t];n&&e.lineTo(n.x,n.yb)}e.closePath(),e.fill()}g=[]};for(let e=f;e<=p;e++){let r=s.last[e],i=c.last[e];if(!D(r)||!D(i)){v(),_=0;continue}let a=Q(fn(t,e)+l),o=d.yOf(n.scale,r),u=d.yOf(n.scale,i),f=r>=i?1:-1,p=g[g.length-1];if(p&&f!==_){let e=p.ya-p.yb,t=e/(e-(o-u)),n=p.x+(a-p.x)*t,r=p.ya+(o-p.ya)*t;g.push({x:n,ya:r,yb:r}),v(),g.push({x:n,ya:r,yb:r})}_=f,g.push({x:a,ya:o,yb:u})}v(),e.restore()},kn=(e,n)=>{if(!k.sessionBreaks||Lt()>=864e5)return;let r=[],i=NaN;for(let e=Math.max(0,n.g0-1);e<=Math.min(n.g1,n.last);e++){let t=Math.floor(qt(n.cols.time[e])/s.DAY);if(D(i)&&t!==i){let t=Math.round(Q(e*n.size-.5))+.5;if(t>0&&t<L&&r.push(t),r.length>L/6)return}i=t}if(r.length){e.save(),e.strokeStyle=t.toCss(B.textMuted,.4),e.setLineDash([4,4]),e.beginPath();for(let t of r)e.moveTo(t,0),e.lineTo(t,R);e.stroke(),e.restore()}},An=()=>{let e=k.volumeProfile;return e?e===!0?{}:e:null},jn=(e,n)=>{let r=An(),i=z[0];if(!r||!i||!N.hasVolume)return;let a=E(Math.floor(r.rows??24),2,400),o=[n.level,n.s0,n.s1,a,r.valueArea??.7,Ce,we].join(`|`);if(!St||St.key!==o){let e=n.level?f.pyramidLevel(he,N,X(),n.level):N;St={key:o,result:l.volumeProfile(e,{from:n.s0,to:n.s1,rows:a,valueArea:r.valueArea})}}let s=St.result;if(s.poc<0)return;let c=0;for(let e=0;e<a;e++)c=Math.max(c,(s.up[e]??0)+(s.down[e]??0));if(!(c>0))return;let u=L*E(r.width??.28,.05,.9),p=(r.side??`right`)===`right`,m=jt(Jt(r.upColor??`up`)),h=jt(Jt(r.downColor??`down`));e.save(),e.beginPath(),e.rect(0,i.top,L,i.height),e.clip();for(let n=0;n<a;n++){let r=s.up[n]??0,a=s.down[n]??0;if(!(r+a>0))continue;let o=d.yOf(i.scale,s.low+n*s.step),l=d.yOf(i.scale,s.low+(n+1)*s.step),f=Math.min(o,l),g=Math.max(1,Math.abs(l-o)-+(Math.abs(l-o)>4)),_=n>=s.valueAreaFrom&&n<=s.valueAreaTo?.42:.17,v=r/c*u,y=a/c*u,b=p?L:0,x=p?-1:1;e.fillStyle=t.toCss(m,_),e.fillRect(Math.min(b,b+x*v),f,v,g),e.fillStyle=t.toCss(h,_);let S=b+x*v;e.fillRect(Math.min(S,S+x*y),f,y,g)}let g=Math.round(d.yOf(i.scale,s.low+(s.poc+.5)*s.step))+.5;e.strokeStyle=Z(r.pocColor??x,.9),e.lineWidth=1,e.beginPath(),e.moveTo(0,g),e.lineTo(L,g),e.stroke(),e.restore()},Mn=(e,n,r)=>{let i=t.toCss(B.grid),a=k.grid!==!1;if(e.lineWidth=1,a){e.strokeStyle=i,e.beginPath();for(let t of r){let n=Math.round(t.x)+.5;e.moveTo(n,0),e.lineTo(n,R)}for(let t of z)for(let n of t.ticks){let r=Math.round(d.yOfScaled(t.scale,n))+.5;r<t.top+2||r>t.top+t.height-2||(e.moveTo(0,r),e.lineTo(L,r))}e.stroke()}if(k.watermark){let n=z[0];e.save(),e.font=Rt(Math.min(56,Math.max(22,L/14)),700),e.fillStyle=t.toCss(B.text,.07),e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(k.watermark,L/2,n.top+n.height/2),e.restore()}for(let n of z){let r=n.study;if(r?.bands&&zt(r)){let i=jt(Jt(r.outputs[0]?.color??S)),a=r.bands.map(e=>Math.round(d.yOf(n.scale,e))+.5);r.bandFill&&a.length===2&&(e.fillStyle=t.toCss(i,.07),e.fillRect(0,Math.min(a[0],a[1]),L,Math.abs(a[1]-a[0]))),e.save(),e.setLineDash([4,4]),e.strokeStyle=t.toCss(B.textMuted,.45),e.beginPath();for(let t of a)t<n.top||t>n.top+n.height||(e.moveTo(0,t),e.lineTo(L,t));e.stroke(),e.restore()}}if(n){kn(e,n);for(let t of P){if(!t.fills.length||!zt(t))continue;let r=t.overlay?z[0]:z.find(e=>e.study===t);if(r)for(let i of t.fills)On(e,n,r,t,i)}let r=z[0];if(r&&r.scale.mode===`percent`&&xe.length){let n=Math.round(d.yOfScaled(r.scale,0))+.5;n>r.top&&n<r.top+r.height&&(e.save(),e.strokeStyle=t.toCss(B.textMuted,.6),e.setLineDash([2,3]),e.beginPath(),e.moveTo(0,n),e.lineTo(L,n),e.stroke(),e.restore())}jn(e,n)}e.strokeStyle=t.toCss(B.axis),e.beginPath();for(let t of z.slice(1)){let n=Math.round(t.top)+.5;e.moveTo(0,n),e.lineTo(Oe,n)}e.moveTo(Math.round(L)+.5,0),e.lineTo(Math.round(L)+.5,ke),e.moveTo(0,Math.round(R)+.5),e.lineTo(Oe,Math.round(R)+.5),e.stroke()},Nn=(e,t,n,r,i,a)=>{let o=a?32:18,s=E(Math.round(t-9),0,R-o);Dn(e,L+1,s,De-2,o,3),e.fillStyle=r,e.fill(),e.fillStyle=i,e.textAlign=`left`,e.textBaseline=`middle`,e.font=Rt(B.fontSize,500),e.fillText(n,L+7,s+9.5),a&&(e.font=Rt(B.fontSize-1),e.fillText(a,L+7,s+24))},Pn=e=>z[0]?.scale.mode===`percent`?s.formatPercent(d.toScaled(z[0].scale,e),Y):Ft(e),Fn=e=>{if(e.color)return Z(e.color);let t=e.kind??`line`;return Z(t===`takeProfit`?kt():t===`stopLoss`?At():t===`alert`?x:t===`line`?S:e.side===`sell`?At():kt())},In=e=>ut.get(e.id)??e.price,Ln=()=>{if(!Me||!z.length)return null;if(U!==null){let e=U,t=e>=0&&e<X()?Qt().close[e]:NaN;return{index:e,pane:z[0],y:d.yOf(z[0].scale,t),price:t}}if(!H&>){let e=Math.round(Zt(gt.time)),t=gt.price;return{index:e,pane:z[0],y:D(t)?d.yOf(z[0].scale,t):NaN,price:t}}if(!H||H.x>L||H.y>R)return null;let e=ln(H.y);if(!e)return null;let t=Math.round(Bt(H.x)),n=H.y,r=d.valueAt(e.scale,n);if(e.id===v&&k.crosshair!==`free`&&t>=0&&t<X()&&et===`cursor`){let i=Qt(),a=1/0;for(let o of[i.open[t],i.high[t],i.low[t],i.close[t]]){let t=d.yOf(e.scale,o);Math.abs(t-H.y)<a&&(a=Math.abs(t-H.y),n=t,r=o)}}return{index:t,pane:e,y:n,price:r}},Rn=e=>z.find(t=>t.id===(e??v))??null,zn=e=>e?{x:Q,y:t=>d.yOf(e.scale,t),index:Zt,left:0,right:L,top:e.top,bottom:e.top+e.height}:null,Bn=(e,t)=>{let n=Et(),r=Math.abs(t),i=[],a=Math.floor(r/s.DAY),o=Math.floor(r%s.DAY/s.HOUR),c=Math.floor(r%s.HOUR/s.MINUTE);return a&&i.push(u.fill(n.days,{count:a})),o&&i.push(u.fill(n.hours,{count:o})),c&&!a&&i.push(u.fill(n.minutes,{count:c})),`${u.fill(Et().bars,{count:e})}, ${i.join(` `)||u.fill(n.minutes,{count:0})}`},Vn=(e,t)=>e.id===v?Ft(t):xn(e,t),Hn=e=>{let t=10**-Mt();return Number((Math.round(e/t)*t).toFixed(Mt()))},Un=(e,t,n,r,i,a=`center`)=>{e.font=Rt(B.fontSize,500);let o=e.measureText(t).width+16,s=E(a===`center`?n-o/2:a===`right`?n-o:n,2,Math.max(2,L-o-2));return Dn(e,s,r,o,22,11),e.fillStyle=i,e.fill(),e.fillStyle=ne(i),e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(t,s+o/2,r+11.5),o},Wn=(e,t,n,r,i)=>(ft.push({x:e,y:t,w:n,h:r,action:i}),pt===ft.length-1),Gn=(e,t)=>{let n=X(),r=n?N.close[n-1]:NaN,i=K?[...G,K]:G;if(!i.length)return;let a=Et(),c={target:a.target,stop:a.stop,riskReward:a.riskReward,profit:a.profit,long:a.long,short:a.short};for(let n of z){let l=zn(n);if(!l)continue;let d=i.filter(e=>(e.pane??v)===n.id);if(d.length){e.save(),e.beginPath(),e.rect(0,n.top,L,n.height),e.clip();for(let i of d){let d=o.paintDrawing(e,i,l,{...t,color:Z(i.color??S),font:Rt(B.fontSize,500),fontFamily:B.fontFamily,formatPrice:e=>Vn(n,e),formatPercent:e=>s.formatPercent(e,Y),formatSpan:Bn,textOn:ne,defaultText:a.text,position:c,last:n.id===v?r:NaN,fill:u.fill},{selected:i===K||i.id===tt,hovered:i.id===nt});d&&ot.set(i.id,d)}e.restore()}}},Kn=(e,n,r)=>{let i=z[0];if(!i)return;ft=[];let a=X(),c=t.toCss(B.text),l=t.toCss(B.textMuted),f=t.toCss(B.background),p=Z(kt()),h=Z(At()),g=Et();if(e.save(),e.beginPath(),e.rect(0,i.top,L,i.height),e.clip(),n&&k.highLowMarkers!==!1&&Dt()!==`line`&&Dt()!==`area`&&Dt()!==`baseline`){let t=-1/0,r=1/0,a=-1,o=-1;for(let e=n.s0;e<=n.s1;e++)n.cols.high[e]>t&&(t=n.cols.high[e],a=e),n.cols.low[e]<r&&(r=n.cols.low[e],o=e);e.font=Rt(B.fontSize),e.fillStyle=l,e.strokeStyle=l,e.lineWidth=1;for(let[s,c,l]of[[a,t,!1],[o,r,!0]]){if(s<0||!D(c))continue;let t=Q(fn(n,s)),r=Ft(c),a=e.measureText(r).width,o=E(d.yOf(i.scale,c)+(l?9:-9),i.top+8,i.top+i.height-8),u=Math.min(t,t+(t>L*.6?-17-a:17+a));for(let e of Jn)u<e.right&&o-7<e.bottom&&o+7>e.top&&e.bottom+10<i.top+i.height-8&&(o=e.bottom+10);let f=L-4-(t+17+a),p=t-17-a-4,m=(f<0||t>L*.6)&&p>=Math.min(0,f),h=m?-1:1;e.textBaseline=`middle`,e.textAlign=`left`,e.beginPath(),e.moveTo(t,o),e.lineTo(t+h*14,o),e.stroke();let g=E(m?t-17-a:t+17,2,L-a-2);e.fillText(r,g,o)}}if(n&&k.markers?.length){let t=new Map;e.font=Rt(B.fontSize,600),e.textAlign=`center`;let r=k.markers.length>400;for(let o of k.markers){let s=Zt(o.time);if(s<0||s>a-1)continue;let c=Math.floor(s/n.size);if(c<n.g0||c>n.g1)continue;let l=Math.round(Q(fn(n,c))),u=o.side===`sell`,m=o.color?Z(o.color):u?h:p,g=`${c}:${u}`,_=t.get(g)??0;t.set(g,_+(o.text&&!r?30:16));let v=d.yOf(i.scale,u?n.cols.high[c]:n.cols.low[c]),y=u?-1:1,b=v+y*(6+_);e.fillStyle=m,e.beginPath(),e.moveTo(l,b),e.lineTo(l-5.5,b+y*7),e.lineTo(l-2,b+y*7),e.lineTo(l-2,b+y*12),e.lineTo(l+2,b+y*12),e.lineTo(l+2,b+y*7),e.lineTo(l+5.5,b+y*7),e.closePath(),e.fill(),o.text&&!r&&(e.textBaseline=u?`bottom`:`top`,e.fillText(o.text,l,b+y*14)),o.price!==void 0&&D(o.price)&&(e.beginPath(),e.arc(l,d.yOf(i.scale,o.price),3,0,Math.PI*2),e.fill(),e.lineWidth=1.5,e.strokeStyle=f,e.stroke())}}e.restore(),Gn(e,{text:c,background:f,up:p,down:h}),e.save(),e.beginPath(),e.rect(0,i.top,L,i.height),e.clip();let _=a?N.close[a-1]:NaN;for(let t of k.priceLines??[]){let n=In(t),r=Math.round(d.yOf(i.scale,n))+.5;if(!D(r)||r<i.top||r>i.top+i.height)continue;let a=Fn(t),s=t.kind??`line`,c=t.lineStyle??(s===`position`||s===`line`?`solid`:`dashed`);e.save(),e.strokeStyle=a,e.lineWidth=dt===t.id||W?.kind===`order`&&W.line.id===t.id?1.5:1,o.setDash(e,c,1),e.beginPath(),e.moveTo(0,r),e.lineTo(L,r),e.stroke(),e.restore();let l=te[s],u=t.title??(l?g[l]:``),m=[];if(u&&m.push({text:u,fill:a,color:ne(a)}),t.quantity!==void 0&&t.quantity!==``&&m.push({text:String(t.quantity),fill:f,color:a}),s===`position`&&typeof t.quantity==`number`&&D(_)){let e=(_-n)*t.quantity*(t.side===`sell`?-1:1),r=e>=0?p:h;m.push({text:`${e>=0?`+`:`−`}${Ft(Math.abs(e))}`,fill:r,color:ne(r)})}if(t.cancellable&&m.push({text:`×`,fill:f,color:a,cancel:!0}),!m.length&&!t.draggable)continue;e.font=Rt(B.fontSize,600);let v=m.map(t=>t.cancel?20:e.measureText(t.text).width+12),y=t.draggable?14:0,b=v.reduce((e,t)=>e+t,0)+y,x=Math.round(L-b-56),S=Math.round(r-9.5);if(Dn(e,x-.5,S-.5,b+1,19,3),e.fillStyle=f,e.fill(),e.strokeStyle=a,e.lineWidth=1,e.setLineDash([]),e.stroke(),y){e.fillStyle=a;for(let t=0;t<3;t++)e.fillRect(x+4,S+5+t*3.5,6,1.5);x+=y}e.textBaseline=`middle`,e.textAlign=`center`,m.forEach((n,r)=>{let i=v[r]??0,o=n.fill;n.cancel&&(Wn(x,S,i,18,()=>J(`orderCancel`,{id:t.id,line:t}))&&(o=a),e.fillStyle=a,e.fillRect(x,S+3,1,12)),o!==f&&(e.fillStyle=o,e.fillRect(x,S,i,18)),e.fillStyle=n.cancel&&o!==f?ne(a):n.color,n.cancel&&(e.font=Rt(B.fontSize+3,500)),e.fillText(n.text,x+i/2,S+(n.cancel?9:9.5)),e.font=Rt(B.fontSize,600),x+=i})}let y=k.lastPriceLine!==!1&&a>0,b=a>0&&N.close[a-1]>=N.open[a-1],x=Dt()===`line`||Dt()===`area`?Z(S):b?p:h;if(y){let t=Math.round(d.yOf(i.scale,_))+.5;e.save(),e.strokeStyle=x,e.setLineDash([1,2]),e.beginPath(),e.moveTo(0,t),e.lineTo(L,t),e.stroke(),e.restore()}e.restore();let C=[];for(let e of xe){let t=a-1;for(;t>=0&&!D(e.values[t]);)t--;if(t<0)continue;let n=e.values[t],r=gn(i.scale,n,hn(e)),o=d.yOfScaled(i.scale,r);!D(o)||o<i.top||o>i.top+i.height||C.push({y:o,text:i.scale.mode===`percent`?s.formatPercent(r,Y):Ft(n),color:Z(e.color)})}let w=[];for(let e of k.priceLines??[])w.push({pane:v,y:d.yOf(i.scale,In(e))});for(let e of G){let t=Rn(e.pane);t&&e.type===`horizontalLine`&&e.points[0]&&w.push({pane:t.id,y:d.yOf(t.scale,e.points[0].price)})}for(let e of C)w.push({pane:v,y:e.y});y&&w.push({pane:v,y:d.yOf(i.scale,_)+(k.countdown?7:0)}),e.font=Rt(B.fontSize),e.textAlign=`left`,e.textBaseline=`middle`,e.fillStyle=l;for(let t of z)for(let n of t.ticks){let r=d.yOfScaled(t.scale,n);if(r<t.top+8||r>t.top+t.height-8)continue;let i=k.countdown&&t.id===v?18:14;w.some(e=>e.pane===t.id&&Math.abs(e.y-r)<i)||e.fillText(xn(t,n),L+8,r)}e.textAlign=`center`;for(let t of r)e.font=Rt(B.fontSize,t.bold?600:400),e.fillStyle=t.bold?c:l,e.fillText(t.text,t.x,R+m/2);for(let t of k.priceLines??[]){let n=In(t),r=d.yOf(i.scale,n);if(!D(r)||r<i.top||r>i.top+i.height)continue;let a=Fn(t);Nn(e,r,Pn(n),a,ne(a))}for(let t of G){let n=Rn(t.pane);if(!n||t.type!==`horizontalLine`||!t.points[0])continue;let r=t.points[0].price,i=d.yOf(n.scale,r);if(i<n.top||i>n.top+n.height)continue;let a=Z(t.color??S);Nn(e,i,n.id===v?Pn(r):Vn(n,r),a,ne(a))}for(let t of C)Nn(e,t.y,t.text,t.color,ne(t.color));if(y){let t;if(k.countdown){let e=It(),n=N.time[a-1],r=n+e.ms;if(e.unit===`month`){let t=new Date(n);r=Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+e.count,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes())}t=s.formatCountdown(r-Date.now(),g)}Nn(e,d.yOf(i.scale,_),Pn(_),x,ne(x),t)}let ee=i.top+i.height-32;if(bt){let n=H&&H.x<=L?H.x:NaN;D(n)&&(e.fillStyle=t.toCss(B.background,.62),e.fillRect(n,0,L-n,R),e.strokeStyle=Z(S),e.lineWidth=1.5,e.beginPath(),e.moveTo(Math.round(n)+.5,0),e.lineTo(Math.round(n)+.5,R),e.stroke()),Un(e,g.replayHint,L/2,ee,Z(S))}else q&&a&&Un(e,u.fill(g.replay,{time:s.formatCrosshairTime(qt(N.time[a-1]),Lt(),Y)}),L/2,ee,Z(S));let T=Ln();if(T&&n&&!bt){let n=Math.round(Q(T.index))+.5;e.save(),e.strokeStyle=t.toCss(B.textMuted,.75),e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),n>=0&&n<=L&&(e.moveTo(n,0),e.lineTo(n,R));let r=Math.round(T.y)+.5;D(r)&&r>=T.pane.top&&r<=T.pane.top+T.pane.height&&(e.moveTo(0,r),e.lineTo(L,r)),e.stroke(),e.restore();let o=t.toCss(B.text);if(D(T.y)&&T.y>=T.pane.top&&T.y<=T.pane.top+T.pane.height){let t=d.scaledAt(T.pane.scale,T.y),n=T.pane.id===v?Pn(d.fromScaled(T.pane.scale,t)):xn(T.pane,t);Nn(e,T.y,n,o,f)}if(n>=0&&n<=L&&a){let t=s.formatCrosshairTime(qt(Vt(T.index)),Lt(),Y);e.font=Rt(B.fontSize,500);let r=e.measureText(t).width+16,i=E(n-r/2,0,Oe-r);Dn(e,i,R+3,r,21,3),e.fillStyle=o,e.fill(),e.fillStyle=f,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(t,i+r/2,R+14)}if(k.orderEntry&&H&&T.pane.id===v&&D(T.y)&&et===`cursor`&&!W&&a){let t=L-18-4,n=E(Math.round(T.y-9),i.top+1,i.top+i.height-18-1),r=Hn(T.price),a=r<_?`buy`:`sell`,s=Wn(t,n,18,18,()=>J(`orderCreate`,{price:r,side:a}));Dn(e,t,n,18,18,4),e.fillStyle=s?Z(S):o,e.fill(),e.strokeStyle=s?ne(Z(S)):f,e.lineWidth=1.5,e.beginPath(),e.moveTo(t+5,n+9),e.lineTo(t+18-5,n+9),e.moveTo(t+9,n+5),e.lineTo(t+9,n+18-5),e.stroke(),s&&Un(e,u.fill(a===`buy`?g.buyLimit:g.sellLimit,{price:Ft(r)}),t-6,n-2,a===`buy`?p:h,`right`)}}},qn=``,Jn=[],Yn=new Map,Xn=new Map,Zn=e=>{let t=Xn.get(e);return t||(t=se(`div`,{position:`absolute`,left:`8px`,display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`1px`,maxWidth:`calc(100% - 16px)`,fontSize:`12px`,lineHeight:`18px`,fontVariantNumeric:`tabular-nums`,whiteSpace:`nowrap`,pointerEvents:`none`}),de.appendChild(t),Xn.set(e,t)),t},Qn=(e,t,n,r)=>{let i=se(`div`,{display:`flex`,flexWrap:`wrap`,alignItems:`center`,columnGap:`6px`,padding:`0 4px`,marginLeft:`-4px`,borderRadius:`4px`,background:`color-mix(in srgb, var(--surface-color, var(--background-color, #fff)) 86%, transparent)`}),a=null;if(n)a=se(`button`,{all:`unset`,cursor:`pointer`,pointerEvents:`auto`,color:`var(--text-color, #1f2937)`,fontWeight:`500`,borderRadius:`3px`}),a.type=`button`,a.textContent=t,a.setAttribute(`aria-label`,u.fill(Et().toggleIndicator,{name:t})),a.addEventListener(`click`,e=>{e.stopPropagation();let t=!zt(n);be.set(n.id,t),J(`indicatorToggle`,{id:n.id,visible:t}),nr(),$()}),a.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.appendChild(a);else if(t){let e=se(`span`,{fontWeight:`600`});e.textContent=t,i.appendChild(e)}let o=[];for(let e=0;e<r;e++){let e=se(`span`,{});i.appendChild(e),o.push(e)}return e.appendChild(i),{row:i,values:o,button:a}},$n=()=>{Yn.clear();for(let e of Xn.values())e.remove();if(Xn.clear(),k.legend===!1)return;let e=Zn(v),t=[k.symbol,k.labels?.timeframe??(typeof k.timeframe==`string`?k.timeframe:``)].filter(Boolean).join(` · `);Yn.set(`ohlc`,Qn(e,t,null,1));for(let t of P){let n=t.mergeLegend?1:t.outputs.length;t.overlay&&t.type===`volume`?Yn.set(t.id,Qn(e,er(t),t,1)):t.overlay&&Yn.set(t.id,Qn(e,er(t),t,n))}for(let t of xe)Yn.set(`compare:${t.id}`,Qn(e,``,null,1));for(let e of P)e.overlay||Yn.set(e.id,Qn(Zn(e.id),er(e),e,e.mergeLegend?1:e.outputs.length))},er=e=>e.type===`volume`?Et().volume:e.titleKey?`${Et()[e.titleKey]} ${e.title}`:e.title,tr=(e,t,n)=>{if(!e)return;e.textContent!==t&&(e.textContent=t);let r=n??``;e.style.color!==r&&(e.style.color=r)},nr=()=>{let e=[k.legend!==!1,k.symbol,k.timeframe,...P.map(e=>`${e.id}:${er(e)}:${e.outputs.length}`),...xe.map(e=>e.id),wt.toggleIndicator,k.labels?.timeframe].join(`|`);if(e!==qn&&(qn=e,$n()),k.legend===!1)return;for(let e of z){let t=Xn.get(e.id);if(!t)continue;t.style.top=`${e.top+6}px`;let n=`${Math.max(80,Math.floor(L-14))}px`;t.style.maxWidth!==n&&(t.style.maxWidth=n)}let t=Xn.get(v);Jn=t?Array.from(t.children,e=>({right:t.offsetLeft+e.offsetLeft+e.offsetWidth,top:t.offsetTop+e.offsetTop,bottom:t.offsetTop+e.offsetTop+e.offsetHeight})):[];let n=X(),r=Ln(),i=E(r&&r.index>=0&&r.index<n?r.index:n-1,0,Math.max(0,n-1)),a=Et(),o=Yn.get(`ohlc`),c=Z(kt()),l=Z(At());if(o&&n){let e=Qt(),t=e.open[i],n=e.close[i],r=i>0?e.close[i-1]:t,u=n-r,d=n>=t?c:l,f=o.values[0],p=[[a.open,e.open[i]],[a.high,e.high[i]],[a.low,e.low[i]],[a.close,n]].map(([e,t])=>`<span style="color:var(--text-secondary-color,#6b7280)">${rr(String(e))}</span><span style="color:${d}">${rr(Ft(t))}</span>`).join(` `),m=r?u/r*100:NaN,h=`${p} ${`${a.change?`<span style="color:var(--text-secondary-color,#6b7280)">${rr(a.change)}</span>`:``}<span style="color:${u>=0?c:l}">${u>=0?`+`:`−`}${rr(Ft(Math.abs(u)))} (${rr(s.formatPercent(m,Y))})</span>`}${N.hasVolume?` <span style="color:var(--text-secondary-color,#6b7280)">${rr(a.volume)}</span>${rr(s.formatVolume(N.volume[i],Y))}`:``}`;f&&f.dataset.html!==h&&(f.innerHTML=h,f.dataset.html=h,f.style.display=`inline-flex`,f.style.gap=`4px`,f.style.flexWrap=`wrap`)}for(let e of P){let t=Yn.get(e.id);if(!t)continue;let r=zt(e);t.row.style.opacity=r?`1`:`0.5`,t.button&&(t.button.setAttribute(`aria-pressed`,String(r)),t.button.style.textDecoration=r?`none`:`line-through`);let a=e.outputs.length;if(e.mergeLegend){let a=e.outputs.find(e=>D(e.values[i]));tr(t.values[0],r&&n&&a?Sn(e,a.values[i]):``,a?Z(Jt(a.color)):void 0);continue}e.outputs.forEach((o,u)=>{let d=t.values[e.type===`macd`?(u+a-1)%a:u];if(!r||!n){tr(d,``);return}if(o.kind===`volume`){let e=N.close[i]>=N.open[i]?c:l;tr(d,s.formatVolume(N.volume[i],Y),e);return}let f=i-o.shift,p=f>=0&&f<n?o.values[f]:NaN,m=o.color?Z(Jt(o.color)):void 0;o.kind===`histogram`&&(m=p>=0?c:l),o.kind===`dots`&&!o.color&&(m=p<=N.close[i]?c:l);let h=e.outputs.length>1&&!e.plainLegend?`${o.label} `:``;tr(d,`${h}${Sn(e,p)}`,m)})}for(let e of xe){let t=Yn.get(`compare:${e.id}`);if(!t)continue;let n=e.values[i],r=hn(e),a=D(r)?(n/r-1)*100:NaN;tr(t.values[0],`${e.name} ${Ft(n)} ${s.formatPercent(a,Y)}`,Z(e.color))}},rr=e=>e.replace(/[&<>"]/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:`"`),$=()=>{oe||Le||(Le=ae?.requestAnimationFrame?ae.requestAnimationFrame(or):setTimeout(()=>or(Date.now()),16))},ir=e=>{let t=!1;if(qe){let n=Math.min(1,(e-qe.start)/320),r=1-(1-n)**3;I=qe.from+(qe.to-qe.from)*r,n>=1?qe=null:t=!0}if(Ke){let n=Math.min(64,e-Ke.t);Ke.t=e;let r=I;I-=Ke.v*n/F,Ke.v*=Math.exp(-n/320),un(),Math.abs(Ke.v)<.02||I===r?Ke=null:t=!0}return t},ar=e=>{e.font=Rt(B.fontSize,500);let t=0;for(let n of z)for(let r of n.ticks)t=Math.max(t,e.measureText(xn(n,r)).width);let n=X();n&&(t=Math.max(t,e.measureText(Pn(N.close[n-1])).width),k.countdown&&(t=Math.max(t,e.measureText(`00:00:00`).width)));let r=Math.max(h,Math.ceil(t+18));(r>De||r<De-12)&&(De=r)};function or(e){if(Le=0,oe||(Oe=A.clientWidth,ke=A.clientHeight,Oe<=0||ke<=0))return;let t=ir(typeof performance<`u`?performance.now():e??Date.now()),n=ae?.devicePixelRatio||1;en(),En(le,n),En(ue,n);let r=le.getContext(`2d`),i=ue.getContext(`2d`);R=Math.max(1,ke-m);for(let e=0;e<2;e++){L=Math.max(1,Oe-De),cn(),Je&&dr(Je),un(),Me=dn(),yn(Me);for(let e of z){let t=d.scaleTicks(e.scale,e.id===v?44:30),n=e.study?.range,r=e.study?.bands;e.ticks=n&&r?[...r,(n[0]+n[1])/2].sort((e,t)=>e-t):t.scaled,e.step=t.step}let e=De;if(i&&ar(i),De===e)break}let a=Me;Je=null;let o=i?bn(a,i):[];Tn(a,n),r&&(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,Oe,ke),Mn(r,a,o)),i&&(i.setTransform(n,0,0,n,0,0),i.clearRect(0,0,Oe,ke),Kn(i,a,o)),nr(),sr(),Br(),Nr(),lr(),H&&!W&&Ar(H.x,H.y)!==pt&&(Xr(H.x,H.y),$()),t&&$()}let sr=()=>{let e=X(),t=z[0],n=e>0&&t&&Q(e-1)>L+F*.5;if(fe.style.display=n?`flex`:`none`,n&&t){fe.style.left=`${L-40}px`,fe.style.top=`${t.top+t.height-40}px`;let e=Et().scrollToRealtime;fe.getAttribute(`aria-label`)!==e&&(fe.setAttribute(`aria-label`,e),fe.title=e)}},cr=()=>{let e=I-L/F;return{from:e,to:I,fromTime:Vt(e),toTime:Vt(I)}},lr=()=>{let e=X();if(!e)return;let t=cr();(!mt||Math.abs(mt.from-t.from)>1e-6||Math.abs(mt.to-t.to)>1e-6)&&(mt=t,ht||J(`visibleRangeChange`,t)),ht=!1,t.from<10&&vt!==N.time[0]&&(vt=N.time[0],J(`historyRequest`,{firstTime:N.time[0],count:e}));let n=Ln(),r=n&&(H||U!==null)?n:null,i=r?`${r.index}|${r.price}|${r.pane.id}`:``;if(i!==_t){if(_t=i,!r)J(`crosshairMove`,null);else{let t={index:r.index,time:Vt(r.index),bar:r.index>=0&&r.index<e?f.readBar(N,r.index):null,price:r.price,pane:r.pane.id,x:Q(r.index),y:r.y};J(`crosshairMove`,t)}}},ur=e=>{let t=A.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},dr=e=>{F=L/(e.to-e.from),I=e.to,un()},fr=(e,t)=>{let n=X();n&&an()&&(e=Math.min(L,Q(n-1)));let r=Bt(e);F*=t,un(),I=r+(L-e)/F,un(),Ke=null,qe=null,$()},pr=(e,t,n)=>{let r=Math.round(Bt(e));return{time:Vt(r),price:d.valueAt(n.scale,t)}},mr=(e,t)=>{e!==et&&(et=e,K=null,rt=0,t&&J(`drawingToolChange`,e),$())},hr=e=>{e!==tt&&(tt=e,lt=!1,J(`drawingSelect`,e),$())},gr=()=>({canUndo:Ze.length>0,canRedo:Qe.length>0}),_r=()=>{let e=gr(),t=`${e.canUndo}|${e.canRedo}`;t!==$e&&($e=t,J(`undoChange`,e))},vr=(e,t=!0)=>{e!==Xe&&(Ze.push(Xe),Ze.length>C&&Ze.shift(),Qe.length=0,Xe=e),G=e,t&&(Ye=e,J(`drawingsChange`,e)),tt&&!e.some(e=>e.id===tt)&&hr(null),_r(),$()},yr=e=>{Xe=e,G=e,Ye=e,K=null,tt&&!e.some(e=>e.id===tt)&&hr(null),J(`drawingsChange`,e),_r(),$()},br=()=>{let e=Ze.pop();e&&(st&&Fr(!1),Qe.push(Xe),yr(e))},xr=()=>{let e=Qe.pop();e&&(Ze.push(Xe),yr(e))},Sr=(e,t)=>{G.some(t=>t.id===e)&&vr(G.map(n=>n.id===e?{...n,...t,id:n.id,type:n.type}:n))},Cr=e=>{G.some(t=>t.id===e)&&(tt===e&&hr(null),vr(G.filter(t=>t.id!==e)))},wr=(e,t,n)=>{let r=d.yOf(t.scale,e.price),i=Math.max(12,t.height*.07),a=d.valueAt(t.scale,r+(n?-2:2)*i),o=d.valueAt(t.scale,r+(n?1:-1)*i),s=Math.max(6,Math.round(L*.16/F)),c=Vt(Math.round(Zt(e.time))+s);return[e,{time:c,price:Hn(a)},{time:c,price:Hn(o)}]},Tr=()=>{if(!K)return;let e=K;K=null,rt=0,vr([...G,e]),hr(e.id),k.keepDrawingMode||mr(`cursor`,!0),e.type===`text`&&Pr(e.id,!0)},Er=()=>{if(!K)return;if(rt--,rt<=0){Tr();return}let e=K.points[K.points.length-1];e&&(K={...K,points:[...K.points,e]})},Dr=(e,t)=>{let n=Rn(it);!K||!n||rt<=0||(K={...K,points:[...K.points.slice(0,-1),pr(e,t,n)]})},Or=(e,t)=>{let n=z[0];if(!n||e>L)return null;for(let e of k.priceLines??[])if(e.draggable&&Math.abs(d.yOf(n.scale,In(e))-t)<=5)return e;return null},kr=(e,t)=>{if(e>L)return null;let n=ln(t),r=zn(n);if(!n||!r)return null;for(let i=G.length-1;i>=0;i--){let a=G[i];if(!a||(a.pane??v)!==n.id)continue;let s=o.hitDrawing(a,r,{x:e,y:t},6,ot.get(a.id));if(s)return{drawing:a,hit:s,pane:n}}return null},Ar=(e,t)=>ft.findIndex(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h),jr=e=>{for(let t=1;t<z.length;t++)if(Math.abs(z[t].top-e)<=4)return t;return-1},Mr=()=>{M.style.height=`auto`,M.style.height=`${Math.max(28,M.scrollHeight+2)}px`},Nr=()=>{if(!st)return;let e=st.id,t=G.find(t=>t.id===e),n=t?Rn(t.pane):null,r=t?.points[0];if(!t||!n||!r)return;let i=Q(Zt(r.time)),a=d.yOf(n.scale,r.price);M.style.left=`${E(i,2,Math.max(2,L-160))}px`,M.style.top=`${E(a,2,Math.max(2,R-40))}px`};function Pr(e,t){let n=G.find(t=>t.id===e);n&&!n.locked&&(st={id:e,created:t},M.value=t?``:n.text??``,M.placeholder=Et().text,M.setAttribute(`aria-label`,Et().editText),M.style.display=`block`,Nr(),Mr(),M.focus(),M.select(),$())}function Fr(e){if(!st)return;let{id:t,created:n}=st;st=null,M.style.display=`none`;let r=M.value.replace(/\s+$/,``),i=G.find(e=>e.id===t);if(i&&n&&(!e||!r)){let e=Ze.pop();yr(e??G.filter(e=>e.id!==t))}else if(i&&e&&r!==(i.text??``)){if(n){let e=G.map(e=>e.id===t?{...e,text:r}:e);Xe=e,G=e,Ye=e,J(`drawingsChange`,e)}else Sr(t,{text:r})}(O.activeElement===M||O.activeElement===O.body)&&A.focus(),$()}M.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),Fr(!0)):e.key===`Escape`&&(e.preventDefault(),Fr(!1))}),M.addEventListener(`input`,Mr),M.addEventListener(`blur`,()=>Fr(!0)),M.addEventListener(`pointerdown`,e=>e.stopPropagation()),M.addEventListener(`dblclick`,e=>e.stopPropagation());let Ir=(e,t=``,n=1.5)=>`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round"${t?` stroke-dasharray="${t}"`:``} aria-hidden="true"><path d="${e}"/></svg>`,Lr=(e,t,n,r)=>{let i=O.createElement(`button`);return i.type=`button`,i.setAttribute(`aria-label`,e),i.title=e,r!==void 0&&i.setAttribute(`aria-pressed`,String(r)),i.innerHTML=t,i.addEventListener(`click`,e=>{e.stopPropagation(),n()}),i},Rr=()=>{let e=O.createElement(`span`);return e.className=`sep`,e},zr=e=>{j.textContent=``;let t=Et();j.setAttribute(`aria-label`,t.lineStyle);let n=e.id,r=[];if(!e.locked){let i=Z(e.color??S),a=Lr(t.color,`<span style="display:block;width:14px;height:14px;border-radius:50%;background:${i};box-shadow:inset 0 0 0 1px rgba(127,127,127,.35)"></span>`,()=>{lt=!lt,ct=``,Br()});a.setAttribute(`aria-expanded`,String(lt)),r.push(a);let s=e.lineWidth??1.5,c=[1,2,3,4];r.push(Lr(`${t.lineWidth}: ${s}px`,`${Ir(`M2 8h12`,``,Math.min(4,s))}<span style="font-size:11px;margin-left:3px">${s}</span>`,()=>Sr(n,{lineWidth:c.find(e=>e>s)??c[0]})));let l=e.lineStyle??`solid`;r.push(Lr(t.lineStyle,Ir(`M2 8h12`,l===`dashed`?`3.5 2.5`:l===`dotted`?`0.1 3`:``,l===`dotted`?2.2:1.6),()=>Sr(n,{lineStyle:ee[(ee.indexOf(l)+1)%ee.length]}))),o.isFillable(e.type)&&r.push(Lr(t.fill,`<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="9" rx="1.5" fill="currentColor" fill-opacity=".3" stroke="currentColor" stroke-width="1.3"/></svg>`,()=>Sr(n,{fill:e.fill===!1}),e.fill!==!1)),e.type===`text`&&r.push(Lr(t.editText,Ir(`M3 13h3l7-7-3-3-7 7zM9 4l3 3`),()=>Pr(n,!1))),r.push(Rr())}if(r.push(Lr(t.lock,e.locked?Ir(`M4.5 7.5h7v6h-7zM6 7.5V5.5a2 2 0 0 1 4 0v2`):Ir(`M4.5 7.5h7v6h-7zM6 7.5V5.5a2 2 0 0 1 3.8-.9`),()=>Sr(n,{locked:!e.locked}),!!e.locked)),!e.locked){let e=Lr(t.remove,Ir(`M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.7 8.5h5.6l.7-8.5`),()=>Cr(n));e.style.color=`var(--danger-color, #f23645)`,r.push(e)}if(j.append(...r),lt&&!e.locked){let r=se(`div`,{position:`absolute`,left:`0`,top:`calc(100% + 4px)`,display:`flex`,gap:`2px`,padding:`4px`,borderRadius:`8px`,border:`1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 85%, transparent)`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,boxShadow:`0 8px 24px -8px rgba(15, 23, 42, 0.35)`});for(let i of w){let a=Lr(`${t.color} ${i}`,`<span style="display:block;width:16px;height:16px;border-radius:50%;background:${i}"></span>`,()=>{lt=!1,Sr(n,{color:i})},(e.color??``).toLowerCase()===i);r.appendChild(a)}j.appendChild(r)}};function Br(){let e=tt?G.find(e=>e.id===tt):void 0,t=e?Rn(e.pane):null,n=zn(t),r=W?.kind===`drawing`&&W.moved;if(!e||!t||!n||k.drawingToolbar===!1||st||r||K){j.style.display=`none`,ct=``,lt=!1;return}let i=[e.id,e.color,e.lineWidth,e.lineStyle,e.fill,e.locked,lt,Y,Pe].join(`|`);i!==ct&&(ct=i,zr(e)),j.style.display=`flex`;let a=o.handlePoints(e,n,ot.get(e.id)),s=ot.get(e.id);e.type===`text`&&s&&a.push({x:s.x+s.w,y:s.y+s.h});let c=1/0,l=-1/0,u=1/0,d=-1/0;for(let e of a)c=Math.min(c,E(e.x,0,L)),l=Math.max(l,E(e.x,0,L)),u=Math.min(u,E(e.y,t.top,t.top+t.height)),d=Math.max(d,E(e.y,t.top,t.top+t.height));e.type===`horizontalLine`&&(c=L*.35,l=L*.65);let f=j.offsetWidth||200,p=j.offsetHeight||34,m=E((c+l)/2-f/2,4,Math.max(4,L-f-4)),h=u-p-14;h<4&&(h=d+32),j.style.left=`${Math.round(m)}px`,j.style.top=`${Math.round(E(h,4,Math.max(4,R-p-4)))}px`}j.addEventListener(`pointerdown`,e=>e.stopPropagation()),j.addEventListener(`dblclick`,e=>e.stopPropagation()),j.addEventListener(`pointermove`,e=>e.stopPropagation()),j.addEventListener(`pointerenter`,()=>{H=null,nt=null,A.style.cursor=`default`,$()});let Vr=()=>({active:!!q,picking:bt,playing:!!q?.playing,speed:q?.speed??xt,index:X(),total:q?q.source.length:X(),time:X()?N.time[X()-1]:NaN}),Hr=()=>J(`replayChange`,Vr()),Ur=(e,t)=>({time:e.time.subarray(0,t),open:e.open.subarray(0,t),high:e.high.subarray(0,t),low:e.low.subarray(0,t),close:e.close.subarray(0,t),volume:e.volume.subarray(0,t)}),Wr=(e,t)=>{let n=e.hasVolume;f.setBars(N,Ur(e,t)),N.hasVolume=n,he=f.createPyramid(),ve=f.createPyramid(),_e=0,vt=NaN,tn(0)},Gr=()=>{q?.timer&&clearInterval(q.timer),q&&(q.timer=null,q.playing=!1)},Kr=e=>{if(bt=!1,!q){if(!X())return;let e=f.createStore();f.setBars(e,Ur(N,X())),e.hasVolume=N.hasVolume,q={source:e,playing:!1,speed:xt,timer:null}}Gr();let t=E(Math.round(e)+1,1,q.source.length);Wr(q.source,t),I=t-1+(k.rightOffset??8);for(let e of Ae.values())e.auto=!0;Hr()},qr=e=>{if(!q)return;let t=q.source,n=X(),r=an(),i=-1;for(let n=0;n<e&&X()<t.length;n++){let e=f.updateBar(N,f.readBar(t,X()));i<0&&(i=e)}N.hasVolume=t.hasVolume,i>=0&&(r&&(I+=X()-n),tn(i)),X()>=t.length&&Gr(),Hr()},Jr=e=>{if(!q)return;if(e!==void 0&&e>0&&(q.speed=xt=e),Gr(),X()>=q.source.length){Hr();return}let t=Math.max(16,1e3/q.speed),n=Math.max(1,Math.round(q.speed*t/1e3));q.playing=!0,q.timer=setInterval(()=>qr(n),t),Hr()},Yr=e=>{let t=bt;if(bt=!1,!q){t&&(Hr(),$());return}Gr();let n=q.source;q=null,e&&Wr(n,n.length),Hr()},Xr=(e,t)=>{let n=`crosshair`;dt=null;let r=null,i=W?-1:Ar(e,t);if(i!==pt&&(pt=i),W?.kind===`pan`&&W.moved)n=`grabbing`;else if(i>=0)n=`pointer`;else if(bt&&e<=L&&t<=R)n=`pointer`;else if(jr(t)>0)n=`row-resize`;else if(e>L&&t<R)n=`ns-resize`;else if(t>R)n=`ew-resize`;else if(et===`cursor`){let i=Or(e,t);if(i)n=`ns-resize`,dt=i.id;else{let i=kr(e,t);i&&(r=i.drawing.id,n=i.drawing.locked?`pointer`:i.hit.part===`handle`?`move`:`pointer`)}}r!==nt&&(nt=r),A.style.cursor!==n&&(A.style.cursor=n)},Zr=e=>{if(e.button!==0&&e.pointerType===`mouse`)return;let{x:t,y:n}=ur(e);if(H={x:t,y:n},U=null,Ke=null,qe=null,st&&Fr(!0),lt&&(lt=!1,$()),e.pointerType===`touch`&&(We.set(e.pointerId,{x:t,y:n}),We.size===2)){let[e,t]=[...We.values()];Ge={distance:Math.hypot(e.x-t.x,e.y-t.y),spacing:F},W=null;return}try{A.setPointerCapture(e.pointerId)}catch{}let r=Ar(t,n),i=ft[r];if(i){W={kind:`button`,action:i.action};return}if(bt&&t<=L&&n<=R){Kr(Math.min(X()-1,Math.round(Bt(t))));return}let a=jr(n);if(a>0){let e=z[a-1],t=z[a];W={kind:`separator`,index:a,y:n,above:e.height,below:t.height};return}if(t>L&&n<R){let e=ln(n);e&&(W={kind:`axisY`,pane:e,y:n,min:e.scale.min,max:e.scale.max});return}if(n>R){W={kind:`axisX`,x:t,spacing:F};return}let s=ln(n);if(et!==`cursor`&&s&&X()){if(K){Dr(t,n),Er(),W=null,$();return}let e=et,r=o.isPosition(e),i=r?z[0]:s,a=pr(t,E(n,i.top,i.top+i.height),i),c=o.anchorCount(e);if(it=i.id,K={id:`drawing-${Date.now().toString(36)}-${++at}`,type:e,points:r?wr({...a,price:Hn(a.price)},i,e===`longPosition`):c===1?[a]:[a,a],...i.id===v?{}:{pane:i.id}},c===1){Tr();return}rt=c-1,W={kind:`create`,pane:i,x:t,y:n,moved:!1},$();return}if(et===`cursor`){let e=Or(t,n);if(e){W={kind:`order`,line:e,startPrice:e.price};return}let r=kr(t,n);if(r){hr(r.drawing.id),r.drawing.locked||(W={kind:`drawing`,id:r.drawing.id,pane:r.pane,handle:r.hit.part===`handle`?r.hit.index:-1,x:t,y:n,original:r.drawing,moved:!1});return}}W={kind:`pan`,x:t,y:n,right:I,pane:s,moved:!1,lastX:t,lastY:n,lastT:e.timeStamp,velocity:0}},Qr=e=>{let{x:t,y:n}=ur(e);if(H={x:t,y:n},e.pointerType===`touch`&&We.has(e.pointerId)&&(We.set(e.pointerId,{x:t,y:n}),Ge&&We.size===2)){let[e,t]=[...We.values()],n=Math.hypot(e.x-t.x,e.y-t.y),r=X(),i=r&&an()?Math.min(L,Q(r-1)):(e.x+t.x)/2,a=Bt(i);F=Ge.spacing*n/Math.max(1,Ge.distance),un(),I=a+(L-i)/F,un(),$();return}let r=W;if(!r){K&&Dr(t,n),Xr(t,n),$();return}switch(r.kind){case`pan`:{let i=t-r.x;if(!r.moved&&Math.hypot(i,n-r.y)<3)break;r.moved=!0,I=r.right-i/F,r.pane&&!r.pane.scale.auto&&d.panScale(r.pane.scale,n-r.lastY),r.lastY=n;let a=Math.max(1,e.timeStamp-r.lastT);r.velocity=.6*((t-r.lastX)/a)+.4*r.velocity,r.lastX=t,r.lastT=e.timeStamp,un(),A.style.cursor=`grabbing`;break}case`axisY`:{let e=r.pane.scale;e.min=r.min,e.max=r.max,d.zoomScale(e,Math.exp((n-r.y)*.006));break}case`axisX`:{let e=I;F=r.spacing*Math.exp((t-r.x)*.006),un(),I=e,un();break}case`separator`:{let e=n-r.y,t=z[r.index-1],i=z[r.index];if(!t||!i)break;let a=r.above+r.below,o=E(r.below-e,_,a-_);je.set(i.id,o),t.id!==v&&je.set(t.id,a-o);break}case`order`:ut.set(r.line.id,Hn(d.valueAt(z[0].scale,n)));break;case`drawing`:{if(!r.moved&&Math.hypot(t-r.x,n-r.y)<3)break;r.moved=!0;let e=r.pane.scale,i;if(r.handle>=0)i=o.moveHandle(r.original,r.handle,pr(t,n,r.pane));else{let a=Math.round(Bt(t)-Bt(r.x)),o=d.scaledAt(e,n)-d.scaledAt(e,r.y);i=r.original.points.map(t=>({time:Vt(Math.round(Zt(t.time))+a),price:d.fromScaled(e,d.toScaled(e,t.price)+o)}))}G=G.map(e=>e.id===r.id?{...e,points:i}:e);break}case`create`:Math.hypot(t-r.x,n-r.y)>=4&&(r.moved=!0),Dr(t,n);break;default:Xr(t,n)}$()},$r=e=>{We.delete(e.pointerId),We.size<2&&(Ge=null);let t=W;W=null;let{x:n,y:r}=ur(e);if(e.pointerType===`touch`&&(H=null),!t){$();return}switch(t.kind){case`pan`:if(t.moved)k.kineticScroll!==!1&&e.timeStamp-t.lastT<60&&Math.abs(t.velocity)>.25&&(Ke={v:t.velocity,t:typeof performance<`u`?performance.now():Date.now()});else{tt&&hr(null);let e=ln(r);e&&n<=L&&J(`click`,{index:Math.round(Bt(n)),time:Vt(Math.round(Bt(n))),price:d.valueAt(e.scale,r),pane:e.id})}break;case`order`:{let e=ut.get(t.line.id);e!==void 0&&e!==t.startPrice?J(`orderMove`,{id:t.line.id,price:e,previousPrice:t.startPrice,line:t.line}):ut.delete(t.line.id);break}case`drawing`:t.moved&&vr(G);break;case`create`:t.moved&&Er();break;case`button`:Ar(n,r)>=0&&t.action()}Xr(n,r),$()},ei=e=>{W||e.pointerType===`touch`||(H=null,nt=null,dt=null,$())},ti=e=>{let t=k.wheel??`zoom`;if(t===`none`)return;let{x:n}=ur(e),r=e.deltaMode===1?16:e.deltaMode===2?L:1,i=e.deltaX*r,a=e.deltaY*r,o=e.ctrlKey||e.metaKey;if(t===`modifier`&&!o&&Math.abs(i)<=Math.abs(a))return;if(e.preventDefault(),U=null,Math.abs(i)>Math.abs(a)||e.shiftKey){I+=(Math.abs(i)>Math.abs(a)?i:a)/F,un(),Ke=null,$();return}let s=Math.exp(-a*(e.ctrlKey?.01:.0015));fr(Math.min(n,L),s)},ni=e=>{let{x:t,y:n}=ur(e),r=et===`cursor`?kr(t,n):null;if(r?.drawing.type===`text`){Pr(r.drawing.id,!1);return}if(t>L&&n<R){let e=ln(n);e&&(e.scale.auto=!0)}else if(n>R)F=k.barSpacing??8,mi.scrollToRealtime(!0);else for(let e of Ae.values())e.auto=!0;$()},ri=e=>{if(e<0||e>=X())return;let t=Qt(),n=Et();pe.textContent=u.fill(n.announcement,{time:s.formatCrosshairTime(qt(N.time[e]),Lt(),Y),open:Ft(t.open[e]),high:Ft(t.high[e]),low:Ft(t.low[e]),close:Ft(t.close[e])})};A.addEventListener(`pointerdown`,Zr),A.addEventListener(`pointermove`,Qr),A.addEventListener(`pointerup`,$r),A.addEventListener(`pointercancel`,$r),A.addEventListener(`pointerleave`,ei),A.addEventListener(`wheel`,ti,{passive:!1}),A.addEventListener(`dblclick`,ni),A.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&!e.altKey){let t=e.key.toLowerCase();(t===`z`||t===`y`)&&(t===`y`||e.shiftKey?xr():br(),e.preventDefault());return}let t=X(),n=Math.max(1,Math.floor(L/F/2)),r=e=>{U=E(e,0,Math.max(0,t-1));let n=Q(U);n<F&&(I+=(F-n)/F+1),n>L-F&&(I-=(n-L+F)/F-1),un(),ri(U)},i=U??Math.min(t-1,Math.round(I));switch(e.key){case`ArrowLeft`:r(i-(e.shiftKey?10:1));break;case`ArrowRight`:r(i+(e.shiftKey?10:1));break;case`PageUp`:r(i-n);break;case`PageDown`:r(i+n);break;case`Home`:r(0);break;case`End`:r(t-1),mi.scrollToRealtime(!0);break;case`+`:case`=`:case`ArrowUp`:fr(U===null?L:Q(U),1.2);break;case`-`:case`_`:case`ArrowDown`:fr(U===null?L:Q(U),1/1.2);break;case`Escape`:lt?lt=!1:bt?Yr(!1):K?(K=null,rt=0):et===`cursor`?tt?hr(null):U=null:mr(`cursor`,!0);break;case`Delete`:case`Backspace`:{let e=G.find(e=>e.id===tt);if(!e||e.locked)return;Cr(e.id);break}default:return}e.preventDefault(),$()}),A.addEventListener(`focus`,()=>{let e=!0;try{e=A.matches(`:focus-visible`)}catch{}e&&(A.style.boxShadow=`inset 0 0 0 2px ${t.toCss(B.primary,.6)}`)}),A.addEventListener(`blur`,()=>{A.style.boxShadow=``,U!==null&&(U=null,$())}),fe.addEventListener(`pointerdown`,e=>e.stopPropagation()),fe.addEventListener(`click`,()=>mi.scrollToRealtime(!0));let ii=typeof ResizeObserver==`function`?new ResizeObserver(()=>$()):null;ii?.observe(A);let ai=()=>{if(oe)return;let e=a.readTheme(A);a.themeColorsChanged(B,e)&&Pe++,B=e,qn=``,$()},oi=a.watchTheme(ai),si=null;typeof MutationObserver==`function`&&A.ownerDocument&&(si=new MutationObserver(()=>{if(k.locale)return;let e=Y;Tt(),Y!==e&&(qn=``,Fe++,fi(),$())}),si.observe(A.ownerDocument.documentElement,{attributes:!0,attributeFilter:[`lang`]}));let ci=()=>{if(oe)return null;Le&&(ae?.cancelAnimationFrame?ae.cancelAnimationFrame(Le):clearTimeout(Le),Le=0),or();let e=ae?.devicePixelRatio||1,n=O.createElement(`canvas`);n.width=Math.max(1,Math.round(Oe*e)),n.height=Math.max(1,Math.round(ke*e));let r=n.getContext(`2d`);if(!r)return null;r.fillStyle=t.toCss(B.background),r.fillRect(0,0,n.width,n.height);try{r.drawImage(le,0,0),V&&r.drawImage(V.canvas,0,0,Math.round(L*e),Math.round(R*e)),r.drawImage(ue,0,0)}catch{}r.setTransform(e,0,0,e,0,0);let i=A.getBoundingClientRect(),a=ae??null;return de.querySelectorAll(`span, button`).forEach(e=>{let n=e.textContent??``;if(e.children.length||!n.trim()||!a)return;let o=e.getBoundingClientRect(),s=a.getComputedStyle(e);r.font=`${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,r.fillStyle=s.color||t.toCss(B.text),r.textAlign=`left`,r.textBaseline=`middle`,r.fillText(n,o.left-i.left,o.top-i.top+o.height/2)}),n},li=!1,ui=()=>{let e=O.fullscreenElement===A;e!==li&&(li=e,A.style.background=e?t.toCss(B.background):``,J(`fullscreenChange`,e),$())};O.addEventListener(`fullscreenchange`,ui);let di=async(t=new Set)=>{let n=++Ie,r=await i.createRenderer(k.renderer??`auto`,()=>e.createDataCanvas(O),e=>{oe||V?.kind!==e||(V.destroy(),V.canvas.remove(),V=null,di(new Set([...t,e])))},t);if(oe||n!==Ie){r?.destroy();return}V&&(V.destroy(),V.canvas.remove()),V=r,ze=``,r&&(A.dataset.renderer=r.kind,A.insertBefore(r.canvas,ue),J(`renderer`,r.kind)),He(r?.kind??null),$()},fi=()=>{let e=k.symbol??``;A.setAttribute(`aria-label`,k.ariaLabel??u.fill(Et().chart,{symbol:e}).trim());let t=!!k.countdown&&k.lastPriceLine!==!1;t&&!yt&&(yt=setInterval($,1e3)),!t&&yt&&(clearInterval(yt),yt=null)},pi=e=>{let t=k;Tt();let n=t.timeZone&&s.isTimeZone(t.timeZone)?t.timeZone:void 0,r=!!e&&(t.utcOffset!==e.utcOffset||n!==Wt);if(Wt=n,(!e||t.indicators!==e.indicators)&&nn(),r)for(let e of P)ye.set(e,0);if((!e||t.compare!==e.compare)&&rn(),t.bars&&(!e||t.bars!==e.bars)?(q&&Yr(!1),e?sn(t.bars):on(t.bars)):!t.bars&&e?.bars&&(q&&Yr(!1),on([])),e&&t.barSpacing!==e.barSpacing&&t.barSpacing&&(F=t.barSpacing),e&&t.scaleMode!==e.scaleMode){let e=Ae.get(v);e&&(e.auto=!0)}t.drawings&&t.drawings!==Ye&&(!e||t.drawings!==e.drawings)&&(e?vr(t.drawings,!1):G=Xe=t.drawings),e&&(t.drawingMode??`cursor`)!==(e.drawingMode??`cursor`)&&mr(t.drawingMode??`cursor`,!1),e&&t.priceLines!==e.priceLines&&ut.clear(),e&&t.chartStyle!==e.chartStyle&&(_e=Math.min(_e,0)),Fe++,fi(),$()};pi(null),di();let mi={setOptions(e){if(oe)return;let t=k;k={...e},pi(t),(e.renderer??`auto`)!==(t.renderer??`auto`)&&di()},setBars(e){q&&Yr(!1),on(e)},update(e){if(q){f.updateBar(q.source,e);return}let t=X(),n=an(),r=f.updateBar(N,e);r<0||(X()>t&&n&&(I+=X()-t),tn(r))},appendBars(e){if(q){f.appendBars(q.source,e);return}let t=X(),n=an(),r=f.appendBars(N,e);r<0||(n&&(I+=X()-t),tn(r))},prependBars(e){q&&f.prependBars(q.source,e);let t=f.prependBars(N,e);t&&(he=f.createPyramid(),ve=f.createPyramid(),_e=0,I+=t,U!==null&&(U+=t),tn(0))},getBarCount:()=>X(),getBar:e=>e>=0&&e<X()?f.readBar(N,Math.floor(e)):null,scrollToRealtime(e=!0){let t=X()-1+(k.rightOffset??8);Ke=null,e&&D(I)&&Math.abs(t-I)*F<L*6?qe={from:I,to:t,start:typeof performance<`u`?performance.now():Date.now()}:I=t,$()},fitContent(){let e=X();e&&mi.setVisibleRange({from:-.5,to:e-1+(k.rightOffset??8)})},getVisibleRange:()=>cr(),setVisibleRange({from:e,to:t}){t>e&&(Ke=null,qe=null,Je={from:e,to:t},dr(Je),$())},getVisibleTimeRange(){let e=cr();return{from:Ht(e.from),to:Ht(e.to)}},setVisibleTimeRange({from:e,to:t}){X()&&t>e&&mi.setVisibleRange({from:Ut(e),to:Ut(t)})},setCrosshair(e,t){gt=e===null||!D(e)?null:{time:e,price:t??NaN},$()},setScaleMode(e){k={...k,scaleMode:e};let t=Ae.get(v);t&&(t.auto=!0),$()},resetPriceScales(){for(let e of Ae.values())e.auto=!0;$()},setDrawingTool:e=>mr(e,!0),getDrawingTool:()=>et,getDrawings:()=>G,setDrawings(e){vr(e,!1)},removeDrawing:Cr,updateDrawing:Sr,selectDrawing:e=>hr(e),undo:br,redo:xr,getUndoState:gr,startReplay(e){if(!X()&&!q)return;if(e===void 0){q&&Yr(!0),bt=!0,Hr(),$();return}let t=q?q.source:N;Kr(f.indexOfTime(t.time,t.length,e))},replayStep:(e=1)=>qr(Math.max(1,Math.floor(e))),replayPlay:e=>Jr(e),replayPause(){q&&(Gr(),Hr())},stopReplay:()=>Yr(!0),getReplayState:Vr,toDataURL(e=`image/png`,t){return ci()?.toDataURL(e,t)??``},toBlob(e=`image/png`,t){let n=ci();return new Promise(r=>{!n||typeof n.toBlob!=`function`?r(null):n.toBlob(r,e,t)})},async requestFullscreen(){typeof A.requestFullscreen==`function`&&await A.requestFullscreen()},async exitFullscreen(){O.fullscreenElement===A&&typeof O.exitFullscreen==`function`&&await O.exitFullscreen()},isFullscreen:()=>O.fullscreenElement===A,setIndicatorVisible(e,t){be.set(e,t),$()},getRenderer:()=>V?.kind??null,ready:Ue,refreshTheme:ai,resize:()=>$(),on(e,t){let n=Ct.get(e);return n||Ct.set(e,n=new Set),n.add(t),()=>n.delete(t)},destroy(){oe||(oe=!0,Le&&(ae?.cancelAnimationFrame?ae.cancelAnimationFrame(Le):clearTimeout(Le)),yt&&clearInterval(yt),q?.timer&&clearInterval(q.timer),O.removeEventListener(`fullscreenchange`,ui),ii?.disconnect(),oi(),si?.disconnect(),A.removeEventListener(`wheel`,ti),V?.destroy(),V=null,He(null),Ct.clear(),A.remove())}};return T.set(mi,{setTimeRange(e){ht=!0,mi.setVisibleTimeRange(e)}}),mi};exports.createTradingChart=re,exports.syncHooks=T;
|
|
1
|
+
const e=require("../dom.cjs"),t=require("../color.cjs"),n=require("../locale.cjs"),r=require("../scale.cjs"),i=require("../renderers/detect.cjs"),a=require("../renderers/follow.cjs"),o=require("../theme.cjs"),s=require("./drawings.cjs"),c=require("./format.cjs"),l=require("./geometry.cjs"),u=require("./indicators.cjs"),d=require("./labels.cjs"),f=require("./scale.cjs"),p=require("./store.cjs"),m=require("./studies.cjs");var h=28,g=60,_=60,v=48,y=`price`,b=`var(--success-color, #089981)`,x=`var(--danger-color, #f23645)`,S=`var(--warning-color, #f59e0b)`,C=`var(--primary-color, #2962ff)`,ee=100,te=[`#2962ff`,`#089981`,`#f23645`,`#f59e0b`,`#a855f7`,`#0ea5e9`,`#ec4899`,`#787b86`],w=[`solid`,`dashed`,`dotted`],ne=new WeakMap,re={order:`limit`,position:`position`,takeProfit:`takeProfit`,stopLoss:`stopLoss`,alert:`alert`},T=(e,t,n)=>e<t?t:e>n?n:e,ie=e=>{let n=t.parseColor(e);return n&&t.luminance(n)>.5?`#0b0e11`:`#fff`},E=Number.isFinite,ae=`B S O Shift+O ArrowUp ArrowDown Shift+ArrowUp Shift+ArrowDown Enter Escape Delete`,oe={minWidth:`0`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`},se=`display:inline-flex;gap:3px;max-width:100%;overflow:hidden;text-overflow:ellipsis`,ce=(ce,le={})=>{let ue=ce.ownerDocument,de=ue.defaultView,D={...le},fe=!1,pe=(t,n)=>e.styleElement(ue.createElement(t),n),O=pe(`div`,{position:`relative`,width:`100%`,height:`100%`,minHeight:`0`,overflow:`hidden`,outline:`none`,userSelect:`none`,touchAction:`pan-y`,fontFamily:`var(--font-family-sans, system-ui, sans-serif)`,color:`var(--text-color, #1f2937)`,cursor:`crosshair`});O.className=`minerva-trading-chart`,O.tabIndex=0,O.setAttribute(`role`,`figure`),O.setAttribute(`aria-roledescription`,`chart`);let me=e=>pe(e,{position:`absolute`,left:`0`,top:`0`,pointerEvents:`none`}),he=me(`canvas`),ge=me(`canvas`);he.setAttribute(`aria-hidden`,`true`),ge.setAttribute(`aria-hidden`,`true`);let _e=me(`div`);_e.style.right=`0`,_e.style.bottom=`0`;let ve=pe(`button`,{position:`absolute`,display:`none`,alignItems:`center`,justifyContent:`center`,width:`28px`,height:`28px`,padding:`0`,borderRadius:`50%`,border:`1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 80%, transparent)`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,color:`var(--text-color, #1f2937)`,boxShadow:`0 4px 14px -4px rgba(15, 23, 42, 0.25)`,cursor:`pointer`});ve.type=`button`,ve.innerHTML=`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l5 5-5 5M9 3l5 5-5 5"/></svg>`;let ye=pe(`div`,{position:`absolute`,width:`1px`,height:`1px`,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`});ye.setAttribute(`aria-live`,`polite`);let k=pe(`div`,{position:`absolute`,display:`none`,alignItems:`center`,gap:`1px`,padding:`3px`,borderRadius:`8px`,border:`1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 85%, transparent)`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,boxShadow:`0 8px 24px -8px rgba(15, 23, 42, 0.35)`,zIndex:`2`,cursor:`default`});k.className=`minerva-trading-toolbar`,k.setAttribute(`role`,`toolbar`);let A=pe(`textarea`,{position:`absolute`,display:`none`,minWidth:`120px`,minHeight:`28px`,padding:`5px 9px`,resize:`none`,border:`1px solid var(--primary-color, #2962ff)`,borderRadius:`5px`,outline:`none`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,color:`var(--text-color, #1f2937)`,font:`500 13px var(--font-family-sans, system-ui, sans-serif)`,boxShadow:`0 6px 18px -6px rgba(15, 23, 42, 0.3)`,zIndex:`3`});A.rows=1;let be=pe(`style`,{});be.textContent=`.minerva-trading-toolbar button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:26px;padding:0 5px;border-radius:5px;cursor:pointer;color:var(--text-color,#1f2937)}.minerva-trading-toolbar button:hover{background:color-mix(in srgb,var(--text-color,#1f2937) 9%,transparent)}.minerva-trading-toolbar button:focus-visible{box-shadow:inset 0 0 0 2px var(--primary-color,#2962ff)}.minerva-trading-toolbar button[aria-pressed="true"]{background:color-mix(in srgb,var(--primary-color,#2962ff) 16%,transparent);color:var(--primary-color,#2962ff)}.minerva-trading-toolbar .sep{width:1px;height:18px;margin:0 3px;background:var(--border-color,#e5e7eb)}`,O.append(be,he,ge,_e,ve,k,A,ye),ce.appendChild(O);let j=p.createStore(),xe=p.createPyramid(),Se={time:j.time,open:new Float64Array,high:new Float64Array,low:new Float64Array,close:new Float64Array,volume:j.volume},Ce=0,we=p.createPyramid(),M=[],Te=new Map,Ee=new Map,De=[],Oe=new WeakMap,ke=new WeakMap,Ae=0,je=0,Me=2,Ne=c.DAY,N=D.barSpacing??8,P=NaN,F=0,I=0,Pe=g,Fe=0,Ie=0,L=[],Le=new Map,Re=new Map,ze=null,Be=0,R=o.readTheme(O),Ve=0,He=0,z=null,Ue=0,We=0,Ge=[],Ke=``,qe=-1,Je=0,Ye,Xe=new Promise(e=>{Ye=e}),B=null,V=null,H=null,U=null,Ze=new Map,Qe=null,$e=null,et=null,tt=null,W=D.drawings??[],nt=null,rt=W,it=[],at=[],ot=`false|false`,st=D.drawingMode??`cursor`,ct=null,lt=null,G=null,ut=0,dt=y,ft=0,pt=new Map,mt=null,ht=``,gt=!1,_t=new Map,vt=null,yt=[],bt=-1,xt=null,St=!1,Ct=null,wt=``,Tt=NaN,Et=null,K=null,Dt=!1,Ot=4,kt=null,At=new Map,q=(e,t)=>{At.get(e)?.forEach(e=>e(t))},J=n.resolveLocale(D.locale),jt=n.localeLabels(d.TRADING_LABELS,J,D.labels),Mt=()=>{J=n.resolveLocale(D.locale),jt=n.localeLabels(d.TRADING_LABELS,J,D.labels)},Nt=()=>jt,Y=()=>j.length,Pt=()=>D.chartStyle??`candles`,Ft=()=>D.colorConvention===`redUp`||D.colorConvention===`auto`&&c.redUpLocale(J),It=()=>D.upColor??(Ft()?x:b),Lt=()=>D.downColor??(Ft()?b:x),Rt=(e,t=R.primary)=>R.resolve?R.resolve(e,t):t,X=(e,n=1)=>t.toCss(Rt(e),n),zt=()=>D.precision??Me,Bt=c.priceFormatter(2,void 0),Vt=``,Z=e=>{if(D.formatPrice)return D.formatPrice(e);let t=`${zt()}|${J}`;return t!==Vt&&(Bt=c.priceFormatter(zt(),J),Vt=t),Bt(e)},Ht=()=>(D.timeframe===void 0?null:u.parseTimeframe(D.timeframe))??{unit:`ms`,count:Ne,ms:Ne},Ut=()=>Ht().ms,Wt=(e,t=400)=>`${t} ${e}px ${R.fontFamily}`,Gt=e=>Ee.get(e.id)??e.config.visible??!0,Q=e=>F+(e-P)*N,Kt=e=>P-(F-e)/N,qt=e=>{let t=Y();if(!t)return 0;let n=Math.round(e);return n<0?j.time[0]+n*Ut():n>=t?j.time[t-1]+(n-t+1)*Ut():j.time[n]},Jt=e=>{let t=Y();if(!t)return 0;let n=Math.floor(e);if(n<0||n>=t-1){let r=n<0?0:t-1;return j.time[r]+(e-r)*Ut()}let r=e-n;return j.time[n]+r*(j.time[n+1]-j.time[n])},Yt=e=>{let t=Y();if(!t)return 0;if(e>=j.time[t-1])return t-1+(e-j.time[t-1])/Ut();if(e<=j.time[0])return(e-j.time[0])/Ut();let n=p.indexOfTime(j.time,t,e),r=j.time[n+1]-j.time[n];return n+(r>0?(e-j.time[n])/r:0)},Xt,Zt=e=>D.utcOffset??(Xt?c.zoneOffset(e,Xt):-new Date(E(e)?e:0).getTimezoneOffset()),Qt=e=>Zt(e),$t=e=>e+Zt(e)*c.MINUTE,en=e=>e===`up`?It():e===`down`?Lt():e,tn=(e,t,n)=>e.level?p.rangeLevel(n,t,Y(),e.level):{min:t,max:t,last:t},nn=e=>{let t=ke.get(e);return t||ke.set(e,t=p.createRangePyramid()),t},rn=e=>{let t=Oe.get(e);return t||Oe.set(e,t=p.createRangePyramid()),t},an=e=>{let t=Y();if(!t)return 0;let n=j.time[t-1];return e>n?t-1+(e-n)/Ut():e<j.time[0]?(e-j.time[0])/Ut():p.indexOfTime(j.time,t,e)},on=()=>Pt()===`heikinAshi`?Se:j,sn=e=>{for(let t of M){Te.set(t,Math.min(Te.get(t)??0,e));for(let n of t.outputs){let t=Oe.get(n);t&&p.invalidateRangePyramid(t,e)}let n=ke.get(t);n&&p.invalidateRangePyramid(n,e)}Ce=Math.min(Ce,e);for(let t of De)t.valid=Math.min(t.valid,e),p.invalidateRangePyramid(t.lod,e);kt=null;let t=t=>{for(let n of t.levels)n&&(n.valid=Math.min(n.valid,Math.floor(e/n.size)))};t(xe),t(we)},cn=()=>{let e=Y();for(let t of M){let n=Te.get(t)??0;n<e&&(t.compute(j,n),Te.set(t,e))}if(Se.time=j.time,Se.volume=j.volume,Pt()===`heikinAshi`&&Ce<e){if(Se.open.length<j.capacity)for(let e of[`open`,`high`,`low`,`close`]){let t=new Float64Array(j.capacity);t.set(Se[e].subarray(0,Ce)),Se[e]=t}u.heikinAshiInto(j.open,j.high,j.low,j.close,e,Se,Ce),Ce=e}for(let t of De)if(!(t.valid>=e)){if(t.values.length<j.capacity){let e=new Float64Array(j.capacity).fill(NaN);e.set(t.values.subarray(0,t.valid)),t.values=e}for(let n=t.valid;n<e;n++){let e=p.lowerBoundTime(t.times,t.times.length,j.time[n]+.5)-1;t.values[n]=e>=0?t.data[e]:NaN}t.valid=e}},ln=e=>{sn(e);let t=Y();e<t-1&&Ae++,je++,t&&(Me=Math.max(e===0?0:Me,c.detectPrecision(j.close,e,t),c.detectPrecision(j.open,Math.max(e,t-50),t)),(e===0||t<80)&&(Ne=c.inferTimeframe(j.time,t))),$()},un=()=>{let{studies:e,reused:t}=m.buildStudies(D.indicators??[],M,Qt);for(let e of M)t.has(e)||Te.delete(e);for(let n of e)t.has(n)||Te.set(n,0);M=e;for(let e of[...Ee.keys()])M.some(t=>t.id===e)||Ee.delete(e)},dn=()=>{De=(D.compare??[]).map((e,t)=>{let n=[...e.data].sort((e,t)=>e.time-t.time);return{id:e.id??e.name,name:e.name,color:e.color??m.LINE_COLORS[(t+2)%m.LINE_COLORS.length],width:e.lineWidth??1.5,times:Float64Array.from(n,e=>e.time),data:Float64Array.from(n,e=>e.value),values:new Float64Array,valid:0,lod:p.createRangePyramid()}})},fn=()=>{let e=Y();if(!e||!E(P))return!0;let t=Q(e-1);return t>=0&&t<=F+N*.5},pn=e=>{p.setBars(j,e),xe=p.createPyramid(),we=p.createPyramid(),Ce=0,Tt=NaN;for(let e of Le.values())e.auto=!0;P=Y()-1+(D.rightOffset??8),$e=null,et=null,ln(0)},mn=e=>{let t=Y(),n=p.inputLength(e);if(t>=2&&n>=t){let r=p.barAt(e,0).time,i=j.time[t-1];if(r===j.time[0]&&p.barAt(e,t-2).time===j.time[t-2]){let r=fn(),i=t,a=t;for(let r=t-1;r<n;r++){let t=p.updateBar(j,p.barAt(e,r));t>=0&&(a=Math.min(a,t))}r&&(P+=Y()-i),a<Y()&&ln(a);return}if(p.barAt(e,n-1).time===i&&n>t){let r=n-t;p.setBars(j,e),xe=p.createPyramid(),we=p.createPyramid(),Ce=0,P+=r,ln(0);return}}pn(e)},hn=()=>{let e=M.filter(e=>!e.overlay),t=I,n=e.map(e=>Re.get(e.id)??e.height),r=n.reduce((e,t)=>e+t,0),i=Math.max(0,t*.62),a=r>i&&r>0?i/r:1,o=n.map(e=>Math.max(v*Math.min(1,a*2),e*a)),s=Math.max(40,t-o.reduce((e,t)=>e+t,0)),c=[],l=(e,t)=>{let n=Le.get(e);return n||(n=f.createScale(t),Le.set(e,n)),n.mode!==t&&(n.mode=t,n.auto=!0),n},u=l(y,D.scaleMode??`linear`);u.top=0,u.height=s,u.marginTop=.1,u.marginBottom=.08,c.push({id:y,study:null,scale:u,top:0,height:s,ticks:[],step:0});let d=s;e.forEach((e,t)=>{let n=l(e.id,`linear`);n.top=d,n.height=o[t],n.marginTop=e.type===`volume`?.18:.14,n.marginBottom=e.type===`volume`?0:.1,e.range&&(n.marginTop=n.marginBottom=.06),c.push({id:e.id,study:e,scale:n,top:d,height:o[t],ticks:[],step:0}),d+=o[t]});for(let e of[...Le.keys()])c.some(t=>t.id===e)||Le.delete(e);L=c},gn=e=>L.find(t=>e>=t.top&&e<t.top+t.height)??null,_n=()=>{let e=Y(),t=Math.min(1,F*.8/Math.max(1,e));N=T(N,Math.max(1e-4,t),_);let n=F/N;E(P)||(P=e-1+(D.rightOffset??8));let r=Math.max(0,e-1)+Math.max(D.rightOffset??8,n*.75),i=Math.min(n*.25,r);P=T(P,i,r)},vn=()=>{let e=Y();if(!e)return null;let t=P-F/N,n=N>=2?0:Math.ceil(Math.log2(2/N)),r=2**n,i=on(),a=n?p.pyramidLevel(Pt()===`heikinAshi`?we:xe,i,e,n):i,o=Math.floor((e-1)/r),s=T(Math.floor(t)-1,0,e-1),c=T(Math.ceil(P)+1,0,e-1),l=T(Math.ceil(t-.5),0,e-1),u=T(Math.floor(P+.5),0,e-1);return{left:t,level:n,size:r,cols:a,g0:Math.floor(s/r),g1:Math.floor(c/r),s0:Math.floor(l/r),s1:Math.floor(u/r),last:o}},yn=(e,t)=>t*e.size+(e.size-1)/2,bn=(e,t)=>Math.min(e.size,Y()-t*e.size),xn=()=>T(Math.ceil(P-F/N-.5),0,Math.max(0,Y()-1)),Sn=e=>{let t=Y();for(let n=xn();n<t;n++){let t=e.values[n];if(E(t)&&t!==0)return t}return NaN},Cn=(e,t,n)=>e.mode===`percent`?(t/n-1)*100:f.toScaled(e,t),wn=()=>D.baselinePrice??on().close[xn()],Tn=(e,t,n,r,i)=>{let a=tn(e,t,n),o=Math.round(r/e.size),s=T(e.s0-o,0,e.last),c=T(e.s1-o,0,e.last);for(let e=s;e<=c;e++)a.min[e]<i[0]&&(i[0]=a.min[e]),a.max[e]>i[1]&&(i[1]=a.max[e])},En=(e,t)=>{if(!D.autoscaleIncludesDrawings||!W.length)return;let n=P-F/N,r=U?.kind===`drawing`?U:null;for(let i of W){if((i.pane??y)!==e)continue;let a=r&&r.id===i.id?r.original:i;for(let e of s.drawingPrices(a,an,n,P))e<t[0]&&(t[0]=e),e>t[1]&&(t[1]=e)}},Dn=e=>{Be=0;for(let t of L){let n=t.scale;if(!e)continue;if(t.id===y){n.base=j.close[xn()]||1;let{cols:t}=e,r=Pt(),i=r===`line`||r===`area`||r===`baseline`,a=[1/0,-1/0];for(let n=e.s0;n<=e.s1;n++){let e=i?t.close[n]:t.low[n],r=i?t.close[n]:t.high[n];e<a[0]&&(a[0]=e),r>a[1]&&(a[1]=r)}for(let n of M)if(n.overlay&&Gt(n)){if(n.type===`volume`){for(let n=e.s0;n<=e.s1;n++){let r=t.volume[n]/bn(e,n);r>Be&&(Be=r)}continue}for(let t of n.outputs)Tn(e,t.values,rn(t),t.shift,a)}En(y,a);let[o,s]=a;if(r===`baseline`){let e=wn();e<o&&(o=e),e>s&&(s=e)}if(!n.auto)continue;let c=f.toScaled(n,o),l=f.toScaled(n,s);n.mode===`log`&&!(o>0)&&(c=f.toScaled(n,Math.max(s*.001,1e-12)));for(let t of De){let r=Sn(t),i=[1/0,-1/0];Tn(e,t.values,t.lod,0,i);for(let e of i){let t=Cn(n,e,r);t<c&&(c=t),t>l&&(l=t)}}n.mode===`percent`&&De.length&&(c=Math.min(c,0),l=Math.max(l,0)),f.fitScale(n,c,l);continue}let r=t.study;if(!r||!n.auto)continue;if(r.range){f.fitScale(n,r.range[0],r.range[1]);continue}let i=[1/0,-1/0];r.type===`volume`&&(i[0]=0);for(let t of r.outputs){if(t.kind===`volume`){for(let t=e.s0;t<=e.s1;t++){let n=e.cols.volume[t]/bn(e,t);n>i[1]&&(i[1]=n)}continue}Tn(e,t.values,rn(t),t.shift,i)}En(t.id,i);let[a,o]=i;if(r.bands&&E(a)&&E(o))for(let e of r.bands)a=Math.min(a,e),o=Math.max(o,e);r.zero&&E(a)&&E(o)&&(a=Math.min(a,0),o=Math.max(o,0)),f.fitScale(n,a,o)}},On=(e,t)=>{let n=Y();if(!n||!e)return[];let r=Ut(),i=r<c.DAY,a=Math.floor(Math.max(0,Math.ceil(P))/e.size),o=t=>t<=e.last?e.cols.time[t]:j.time[n-1]+(t*e.size-(n-1))*r,s=[],l=e.g0>0?$t(o(e.g0-1)):NaN;for(let t=e.g0;t<=a;t++){let n=$t(o(t)),r=Q(yn(e,t)),i=c.boundaryWeight(l,n);r>=-20&&r<=F+20&&i>10&&s.push({x:r,weight:i,time:n}),l=n}t.font=Wt(R.fontSize);let u=i?`00:00`:`Sep 30`,d=Math.max(t.measureText(u).width,t.measureText(`2024`).width)+34;return c.pickTicks(s,d).filter(e=>e.x>8&&e.x<F-8).map(e=>({x:e.x,text:c.tickText(e.time,e.weight,J,i),bold:e.weight>=(i?50:60)}))},kn=(e,t)=>e.id===y?e.scale.mode===`percent`?c.formatPercent(t,J,Math.min(2,r.stepDecimals(e.step))):Z(f.fromScaled(e.scale,t)):e.study?.compact?c.formatVolume(t,J):c.formatFixed(t,Math.min(4,r.stepDecimals(e.step)),J),An=(e,t)=>e.overlay&&e.type!==`volume`?Z(t):e.compact?c.formatVolume(t,J):c.formatFixed(t,e.range?2:Math.max(2,Math.min(6,zt())),J),jn=(e,n)=>{let r=[],i=e.cols,a=Rt(It()),o=Rt(Lt()),s=t.packColor(a),c=t.packColor(o),u=R.background,d=l.candleMetrics(N*e.size*n,n),p=t=>Q(yn(e,t))*n,m=Pt(),h=Math.max(.5,d.body/2),g={up:t.packColor([a[0],a[1],a[2],.5]),down:t.packColor([o[0],o[1],o[2],.5])};for(let _ of L){let v=_.top*n,b=(_.top+_.height)*n,x=_.scale,S=e=>f.yOf(x,e)*n,ee=(t,n,r,i=S)=>(a,o,s)=>{let c=new l.LineBuffer(v,b);for(let n=s?Math.max(e.g0,a-1):a;n<=o;n++)c.push(p(n),i(t(n)));return c.count>1?[c.item(``,0,n,r)]:[]},te=(t,r,i,a,o=0,s=S)=>(c,u,d)=>{let f=tn(e,t,r),m=o*N*n,h=Math.ceil(Math.abs(o)/e.size)+1,g=d?Math.max(0,c-1):c,_=u;!d&&o>0&&(g=Math.max(0,g-h)),!d&&o<0&&(_=Math.min(e.last-1,_+h));let y=new l.LineBuffer(v,b),x=NaN;for(let t=g;t<=_;t++){let n=p(t)+m,r=f.min[t],i=f.max[t];if(!e.level||r===i||!E(r)||!E(i)){x=s(f.last[t]),y.push(n,x);continue}let a=s(r),o=s(i),c=E(x)&&Math.abs(x-o)<Math.abs(x-a)?o:a,l=c===o?a:o;y.push(n,c),y.push(n,l),x=l}return y.count>1?[y.item(``,0,i,a)]:[]},w=(t,n,r,i,a)=>(o,s,c)=>{let d=tn(e,t.value,n),f=Y(),m=new l.TrendBuffer(v,b),h=NaN;for(let n=c?Math.max(0,o-1):o;n<=s;n++){let r=d.min[n],i=d.max[n];if(!E(r)||!E(i)){m.break(),h=NaN;continue}let a=t.direction[Math.min(f-1,n*e.size+e.size-1)]!==-1,o=p(n),s=S(r),c=S(i),l=E(h)&&Math.abs(h-c)<Math.abs(h-s)?c:s,u=l===c?s:c;m.push(o,l,a),u!==l&&m.push(o,u,a),h=u}let g=[u[0],u[1],u[2],.9],_=[];for(let[e,t]of[[m.up,`u`],[m.down,`d`]])e.count>1&&_.push(e.item(`${t}h`,0,g,a+2.5));return m.up.count>1&&_.push(m.up.item(`u`,0,r,a)),m.down.count>1&&_.push(m.down.item(`d`,0,i,a)),_};if(_.id===y){if(M.find(e=>e.overlay&&e.type===`volume`&&Gt(e))&&Be>0){let t=(b-v)*.2;r.push((n,r)=>{let a=new l.BarBuffer;for(let o=n;o<=r;o++){let n=i.volume[o]/bn(e,o);if(!(n>0))continue;let r=b-n/Be*t,[s,c]=l.pixelRange(r,b);a.push(d.snap(p(o)),s,c,i.close[o]>=i.open[o]?g.up:g.down)}return[a.item(``,0,h)]})}for(let e of De){let t=Sn(e),i=Rt(e.color);r.push(te(e.values,e.lod,i,e.width,0,e=>f.yOfScaled(x,Cn(x,e,t))*n))}if(m===`line`||m===`area`||m===`baseline`){let t=Rt(C);if(m===`area`&&r.push((n,r,a)=>{let o=new l.AreaBuffer(v,b);for(let t=a?Math.max(e.g0,n-1):n;t<=r;t++)o.push(p(t),S(i.close[t]),b);return o.count>1?[o.item(``,0,t,.28)]:[]}),m===`baseline`){let t=S(wn());r.push((n,r,s)=>{let c=new l.AreaBuffer(v,b),u=new l.AreaBuffer(v,b),d=new l.LineBuffer(v,b),f=new l.LineBuffer(v,b),m=NaN,h=NaN,g=(e,n)=>{c.push(e,Math.min(n,t),t),u.push(e,Math.max(n,t),t),n<=t?d.push(e,n):d.break(),n>=t?f.push(e,n):f.break()};for(let a=s?Math.max(e.g0,n-1):n;a<=r;a++){let e=p(a),n=S(i.close[a]);if(E(h)&&(h-t)*(n-t)<0){let r=(t-h)/(n-h);g(m+(e-m)*r,t)}g(e,n),m=e,h=n}let _=[];return c.count>1&&_.push(c.item(`u`,0,a,.22),u.item(`d`,0,o,.22)),d.count>1&&_.push(d.item(`ul`,0,a,2)),f.count>1&&_.push(f.item(`dl`,0,o,2)),_})}else r.push(ee(e=>i.close[e],t,2))}else{let e=m===`hollowCandles`,t=m===`bars`,n=d.wick,a=d.body;r.push((r,o)=>{let u=new l.BarBuffer,f=new l.BarBuffer,m=new l.BarBuffer,h=new l.BarBuffer,g=Math.max(n,Math.round((a-n)/2));for(let _=r;_<=o;_++){let r=i.open[_],o=i.high[_],y=i.low[_],x=i.close[_];if(!E(r)||!E(x))continue;let C=(e?x>=(_>0?i.close[_-1]:r):x>=r)?s:c,ee=d.snap(p(_)),[te,w]=l.pixelRange(S(o),S(y));if(t){let e=l.clampRange(te,w,v,b);e&&u.push(ee,e[0],e[1],C);for(let[e,t]of[[r,-1],[x,1]]){let r=Math.round(S(e)-n/2);r<v||r+n>b||h.push(ee+t*(n/2+g/2),r,r+n,C)}continue}let[ne,re]=l.pixelRange(S(r),S(x));if(a<=n){let e=l.clampRange(te,w,v,b);e&&u.push(ee,e[0],e[1],C);continue}if(e&&x>r){let e=[[te,ne],[re,w]];for(let[t,n]of e){let e=n>t?l.clampRange(t,n,v,b):null;e&&u.push(ee,e[0],e[1],C)}let t=l.clampRange(ne,re,v,b);t&&(u.push(ee-a/2+n/2,t[0],t[1],C),u.push(ee+a/2-n/2,t[0],t[1],C));for(let e of[ne,re-n])e>=v&&e+n<=b&&m.push(ee,e,e+n,C);continue}let T=l.clampRange(te,w,v,b);T&&u.push(ee,T[0],T[1],C);let ie=l.clampRange(ne,re,v,b);ie&&f.push(ee,ie[0],ie[1],C)}let _=[u.item(`w`,0,n/2)];return f.count&&_.push(f.item(`b`,0,a/2)),m.count&&_.push(m.item(`c`,0,a/2)),h.count&&_.push(h.item(`t`,0,g/2)),_})}}let ne=_.id===y?M.filter(e=>e.overlay&&e.type!==`volume`):_.study?[_.study]:[];for(let f of ne){if(!Gt(f))continue;let m=f.trend,[_,y]=f.outputs;if(m&&e.level&&_&&y){r.push(w(m,nn(f),Rt(en(_.color)),Rt(en(y.color)),_.width));continue}for(let m of f.outputs)if(m.kind===`volume`){let t=S(0);r.push((n,r)=>{let a=new l.BarBuffer;for(let o=n;o<=r;o++){let n=i.volume[o]/bn(e,o);if(!(n>0))continue;let r=l.clampRange(...l.pixelRange(S(n),t),v,b);r&&a.push(d.snap(p(o)),r[0],r[1],i.close[o]>=i.open[o]?g.up:g.down)}return[a.item(``,0,h)]})}else if(m.kind===`histogram`){let n=S(0),i={up:s,down:c},f={up:t.packColor(t.mix(u,a,.45)),down:t.packColor(t.mix(u,o,.45))},g=rn(m);r.push((t,r)=>{let a=tn(e,m.values,g),o=new l.BarBuffer;for(let s=t;s<=r;s++){let t=a.last[s];if(!E(t))continue;let r=s>0?a.last[s-1]:t,c=t>=0?t>=r?i.up:f.up:t<=r?i.down:f.down,u=Math.min(0,E(a.min[s])?a.min[s]:t),m=Math.max(0,E(a.max[s])?a.max[s]:t),h=l.clampRange(...e.level?l.pixelRange(S(m),S(u)):l.pixelRange(S(t),n),v,b);h&&o.push(d.snap(p(s)),h[0],h[1],c)}return[o.item(``,0,h)]})}else if(m.kind===`dots`){let a=m.color?t.packColor(Rt(en(m.color))):0,o=T(N*e.size*.22,1.25,2.6),u=o*n;r.push((t,n)=>{let r=new l.BarBuffer;for(let o=t;o<=n;o++){let t=e.level?m.values[Math.min(Y()-1,o*e.size+e.size-1)]:m.values[o];if(!E(t))continue;let n=S(t);if(n<v||n>b)continue;let l=a||(t<=i.close[o]?s:c);r.push(p(o),n-u,n+u,l)}return r.count?[r.item(``,0,u,0,o)]:[]})}else{let e=Rt(en(m.color));r.push(te(m.values,rn(m),[e[0],e[1],e[2],e[3]*m.alpha],m.width,m.shift))}}}return r},Mn=(e,t,n,r)=>{let i=Math.min(n.g1,n.last-1),a=r?n.last>=n.g0&&n.last<=n.g1?e(n.last,n.last,!0):[]:i>=n.g0?e(n.g0,i,!1):[],o=++Je;return a.map((e,n)=>({...e,key:`L${t}:${n}:${e.kind}:${e.key}${r?`:live`:``}`,version:o}))},Nn=(t,n)=>{if(!z)return;let r=z.canvas;e.styleElement(r,{left:`0px`,top:`0px`,width:`${F}px`,height:`${I}px`});let i=Math.max(1,Math.round(F*n)),a=Math.max(1,Math.round(I*n));if((r.width!==i||r.height!==a)&&z.resize(i,a),t){let e=[i,a,n,N,P,t.level,Pt(),Ae,Ve,He,Be,Pt()===`baseline`?wn():0,...L.map(e=>`${e.id}:${e.top}:${e.height}:${e.scale.min}:${e.scale.max}:${e.scale.base}:${e.scale.mode}`),...M.map(e=>`${e.id}:${Gt(e)}`)].join(`|`);e===Ke?qe!==je&&(qe=je,Ge.forEach((e,n)=>{e.live=Mn(e.fn,n,t,!0)})):(Ke=e,qe=je,Ge=jn(t,n).map(e=>({fn:e,main:[],live:[]})),Ge.forEach((e,n)=>{e.main=Mn(e.fn,n,t,!1),e.live=Mn(e.fn,n,t,!0)}))}else Ge=[],Ke=``;let o=Ge.flatMap(e=>[...e.main,...e.live]);z.render(o,{transform:{xScale:2/i,xOffset:-1,yScale:-2/a,yOffset:1},width:i,height:a,dpr:n})},Pn=(e,t)=>{let n=Math.max(1,Math.round(Fe*t)),r=Math.max(1,Math.round(Ie*t));e.width!==n&&(e.width=n),e.height!==r&&(e.height=r),e.style.width=`${Fe}px`,e.style.height=`${Ie}px`},Fn=(e,t,n,r,i,a)=>{e.beginPath(),typeof e.roundRect==`function`?e.roundRect(t,n,r,i,a):e.rect(t,n,r,i)},In=(e,t,n,r,i)=>{let a=r.outputs[i.a],o=r.outputs[i.b];if(!a||!o)return;let s=tn(t,a.values,rn(a)),c=tn(t,o.values,rn(o)),l=a.shift,u=Math.ceil(Math.abs(l)/t.size)+1,d=Math.max(0,t.g0-(l>0?u:0)),p=Math.min(t.last,t.g1+(l<0?u:0)),m=X(en(i.color),i.opacity),h=X(en(i.colorBelow??i.color),i.opacity);e.save(),e.beginPath(),e.rect(0,n.top,F,n.height),e.clip();let g=[],_=0,v=()=>{if(g.length>1){e.fillStyle=_>=0?m:h,e.beginPath(),g.forEach((t,n)=>n?e.lineTo(t.x,t.ya):e.moveTo(t.x,t.ya));for(let t=g.length-1;t>=0;t--){let n=g[t];n&&e.lineTo(n.x,n.yb)}e.closePath(),e.fill()}g=[]};for(let e=d;e<=p;e++){let r=s.last[e],i=c.last[e];if(!E(r)||!E(i)){v(),_=0;continue}let a=Q(yn(t,e)+l),o=f.yOf(n.scale,r),u=f.yOf(n.scale,i),d=r>=i?1:-1,p=g[g.length-1];if(p&&d!==_){let e=p.ya-p.yb,t=e/(e-(o-u)),n=p.x+(a-p.x)*t,r=p.ya+(o-p.ya)*t;g.push({x:n,ya:r,yb:r}),v(),g.push({x:n,ya:r,yb:r})}_=d,g.push({x:a,ya:o,yb:u})}v(),e.restore()},Ln=(e,n)=>{if(!D.sessionBreaks||Ut()>=864e5)return;let r=[],i=NaN;for(let e=Math.max(0,n.g0-1);e<=Math.min(n.g1,n.last);e++){let t=Math.floor($t(n.cols.time[e])/c.DAY);if(E(i)&&t!==i){let t=Math.round(Q(e*n.size-.5))+.5;if(t>0&&t<F&&r.push(t),r.length>F/6)return}i=t}if(r.length){e.save(),e.strokeStyle=t.toCss(R.textMuted,.4),e.setLineDash([4,4]),e.beginPath();for(let t of r)e.moveTo(t,0),e.lineTo(t,I);e.stroke(),e.restore()}},Rn=()=>{let e=D.volumeProfile;return e?e===!0?{}:e:null},zn=(e,n)=>{let r=Rn(),i=L[0];if(!r||!i||!j.hasVolume)return;let a=T(Math.floor(r.rows??24),2,400),o=[n.level,n.s0,n.s1,a,r.valueArea??.7,Ae,je].join(`|`);if(!kt||kt.key!==o){let e=n.level?p.pyramidLevel(xe,j,Y(),n.level):j;kt={key:o,result:u.volumeProfile(e,{from:n.s0,to:n.s1,rows:a,valueArea:r.valueArea})}}let s=kt.result;if(s.poc<0)return;let c=0;for(let e=0;e<a;e++)c=Math.max(c,(s.up[e]??0)+(s.down[e]??0));if(!(c>0))return;let l=F*T(r.width??.28,.05,.9),d=(r.side??`right`)===`right`,m=Rt(en(r.upColor??`up`)),h=Rt(en(r.downColor??`down`));e.save(),e.beginPath(),e.rect(0,i.top,F,i.height),e.clip();for(let n=0;n<a;n++){let r=s.up[n]??0,a=s.down[n]??0;if(!(r+a>0))continue;let o=f.yOf(i.scale,s.low+n*s.step),u=f.yOf(i.scale,s.low+(n+1)*s.step),p=Math.min(o,u),g=Math.max(1,Math.abs(u-o)-+(Math.abs(u-o)>4)),_=n>=s.valueAreaFrom&&n<=s.valueAreaTo?.42:.17,v=r/c*l,y=a/c*l,b=d?F:0,x=d?-1:1;e.fillStyle=t.toCss(m,_),e.fillRect(Math.min(b,b+x*v),p,v,g),e.fillStyle=t.toCss(h,_);let S=b+x*v;e.fillRect(Math.min(S,S+x*y),p,y,g)}let g=Math.round(f.yOf(i.scale,s.low+(s.poc+.5)*s.step))+.5;e.strokeStyle=X(r.pocColor??S,.9),e.lineWidth=1,e.beginPath(),e.moveTo(0,g),e.lineTo(F,g),e.stroke(),e.restore()},Bn=(e,n,r)=>{let i=t.toCss(R.grid),a=D.grid!==!1;if(e.lineWidth=1,a){e.strokeStyle=i,e.beginPath();for(let t of r){let n=Math.round(t.x)+.5;e.moveTo(n,0),e.lineTo(n,I)}for(let t of L)for(let n of t.ticks){let r=Math.round(f.yOfScaled(t.scale,n))+.5;r<t.top+2||r>t.top+t.height-2||(e.moveTo(0,r),e.lineTo(F,r))}e.stroke()}if(D.watermark){let n=L[0];e.save(),e.font=Wt(Math.min(56,Math.max(22,F/14)),700),e.fillStyle=t.toCss(R.text,.07),e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(D.watermark,F/2,n.top+n.height/2),e.restore()}for(let n of L){let r=n.study;if(r?.bands&&Gt(r)){let i=Rt(en(r.outputs[0]?.color??C)),a=r.bands.map(e=>Math.round(f.yOf(n.scale,e))+.5);r.bandFill&&a.length===2&&(e.fillStyle=t.toCss(i,.07),e.fillRect(0,Math.min(a[0],a[1]),F,Math.abs(a[1]-a[0]))),e.save(),e.setLineDash([4,4]),e.strokeStyle=t.toCss(R.textMuted,.45),e.beginPath();for(let t of a)t<n.top||t>n.top+n.height||(e.moveTo(0,t),e.lineTo(F,t));e.stroke(),e.restore()}}if(n){Ln(e,n);for(let t of M){if(!t.fills.length||!Gt(t))continue;let r=t.overlay?L[0]:L.find(e=>e.study===t);if(r)for(let i of t.fills)In(e,n,r,t,i)}let r=L[0];if(r&&r.scale.mode===`percent`&&De.length){let n=Math.round(f.yOfScaled(r.scale,0))+.5;n>r.top&&n<r.top+r.height&&(e.save(),e.strokeStyle=t.toCss(R.textMuted,.6),e.setLineDash([2,3]),e.beginPath(),e.moveTo(0,n),e.lineTo(F,n),e.stroke(),e.restore())}zn(e,n)}e.strokeStyle=t.toCss(R.axis),e.beginPath();for(let t of L.slice(1)){let n=Math.round(t.top)+.5;e.moveTo(0,n),e.lineTo(Fe,n)}e.moveTo(Math.round(F)+.5,0),e.lineTo(Math.round(F)+.5,Ie),e.moveTo(0,Math.round(I)+.5),e.lineTo(Fe,Math.round(I)+.5),e.stroke()},Vn=(e,t,n,r,i,a)=>{let o=a?32:18,s=T(Math.round(t-9),0,I-o);Fn(e,F+1,s,Pe-2,o,3),e.fillStyle=r,e.fill(),e.fillStyle=i,e.textAlign=`left`,e.textBaseline=`middle`,e.font=Wt(R.fontSize,500),e.fillText(n,F+7,s+9.5),a&&(e.font=Wt(R.fontSize-1),e.fillText(a,F+7,s+24))},Hn=e=>L[0]?.scale.mode===`percent`?c.formatPercent(f.toScaled(L[0].scale,e),J):Z(e),Un=e=>{if(e.color)return X(e.color);let t=e.kind??`line`;return X(t===`takeProfit`?It():t===`stopLoss`?Lt():t===`alert`?S:t===`line`?C:e.side===`sell`?Lt():It())},Wn=e=>_t.get(e.id)??e.price,Gn=()=>{if(!ze||!L.length)return null;if(V!==null){let e=V,t=e>=0&&e<Y()?on().close[e]:NaN;return{index:e,pane:L[0],y:f.yOf(L[0].scale,t),price:t}}if(!B&&Ct){let e=Math.round(an(Ct.time)),t=Ct.price;return{index:e,pane:L[0],y:E(t)?f.yOf(L[0].scale,t):NaN,price:t}}if(!B||B.x>F||B.y>I)return null;let e=gn(B.y);if(!e)return null;let t=Math.round(Kt(B.x)),n=B.y,r=f.valueAt(e.scale,n);if(e.id===y&&D.crosshair!==`free`&&t>=0&&t<Y()&&st===`cursor`){let i=on(),a=1/0;for(let o of[i.open[t],i.high[t],i.low[t],i.close[t]]){let t=f.yOf(e.scale,o);Math.abs(t-B.y)<a&&(a=Math.abs(t-B.y),n=t,r=o)}}return{index:t,pane:e,y:n,price:r}},Kn=e=>L.find(t=>t.id===(e??y))??null,qn=e=>e?{x:Q,y:t=>f.yOf(e.scale,t),index:an,left:0,right:F,top:e.top,bottom:e.top+e.height}:null,Jn=(e,t)=>{let n=Nt(),r=Math.abs(t),i=[],a=Math.floor(r/c.DAY),o=Math.floor(r%c.DAY/c.HOUR),s=Math.floor(r%c.HOUR/c.MINUTE);return a&&i.push(d.fill(n.days,{count:a})),o&&i.push(d.fill(n.hours,{count:o})),s&&!a&&i.push(d.fill(n.minutes,{count:s})),`${d.fill(Nt().bars,{count:e})}, ${i.join(` `)||d.fill(n.minutes,{count:0})}`},Yn=(e,t)=>e.id===y?Z(t):kn(e,t),Xn=e=>{let t=10**-zt();return Number((Math.round(e/t)*t).toFixed(zt()))},Zn=(e,t,n,r,i,a=`center`)=>{e.font=Wt(R.fontSize,500);let o=e.measureText(t).width+16,s=T(a===`center`?n-o/2:a===`right`?n-o:n,2,Math.max(2,F-o-2));return Fn(e,s,r,o,22,11),e.fillStyle=i,e.fill(),e.fillStyle=ie(i),e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(t,s+o/2,r+11.5),o},Qn=(e,t,n,r,i)=>(yt.push({x:e,y:t,w:n,h:r,action:i}),bt===yt.length-1),$n=(e,t)=>{let n=Y(),r=n?j.close[n-1]:NaN,i=G?[...W,G]:W;if(!i.length)return;let a=Nt(),o={target:a.target,stop:a.stop,riskReward:a.riskReward,profit:a.profit,long:a.long,short:a.short};for(let n of L){let l=qn(n);if(!l)continue;let u=i.filter(e=>(e.pane??y)===n.id);if(u.length){e.save(),e.beginPath(),e.rect(0,n.top,F,n.height),e.clip();for(let i of u){let u=s.paintDrawing(e,i,l,{...t,color:X(i.color??C),font:Wt(R.fontSize,500),fontFamily:R.fontFamily,formatPrice:e=>Yn(n,e),formatPercent:e=>c.formatPercent(e,J),formatSpan:Jn,textOn:ie,defaultText:a.text,position:o,last:n.id===y?r:NaN,fill:d.fill},{selected:i===G||i.id===ct,hovered:i.id===lt});u&&pt.set(i.id,u)}e.restore()}}},er=(e,n,r)=>{let i=L[0];if(!i)return;yt=[];let a=Y(),o=t.toCss(R.text),l=t.toCss(R.textMuted),u=t.toCss(R.background),p=X(It()),m=X(Lt()),g=Nt();if(e.save(),e.beginPath(),e.rect(0,i.top,F,i.height),e.clip(),n&&D.highLowMarkers!==!1&&Pt()!==`line`&&Pt()!==`area`&&Pt()!==`baseline`){let t=-1/0,r=1/0,a=-1,o=-1;for(let e=n.s0;e<=n.s1;e++)n.cols.high[e]>t&&(t=n.cols.high[e],a=e),n.cols.low[e]<r&&(r=n.cols.low[e],o=e);e.font=Wt(R.fontSize),e.fillStyle=l,e.strokeStyle=l,e.lineWidth=1;for(let[s,c,l]of[[a,t,!1],[o,r,!0]]){if(s<0||!E(c))continue;let t=Q(yn(n,s)),r=Z(c),a=e.measureText(r).width,o=T(f.yOf(i.scale,c)+(l?9:-9),i.top+8,i.top+i.height-8),u=Math.min(t,t+(t>F*.6?-17-a:17+a));for(let e of nr)u<e.right&&o-7<e.bottom&&o+7>e.top&&e.bottom+10<i.top+i.height-8&&(o=e.bottom+10);let d=F-4-(t+17+a),p=t-17-a-4,m=(d<0||t>F*.6)&&p>=Math.min(0,d),h=m?-1:1;e.textBaseline=`middle`,e.textAlign=`left`,e.beginPath(),e.moveTo(t,o),e.lineTo(t+h*14,o),e.stroke();let g=T(m?t-17-a:t+17,2,F-a-2);e.fillText(r,g,o)}}if(n&&D.markers?.length){let t=new Map;e.font=Wt(R.fontSize,600),e.textAlign=`center`;let r=D.markers.length>400;for(let o of D.markers){let s=an(o.time);if(s<0||s>a-1)continue;let c=Math.floor(s/n.size);if(c<n.g0||c>n.g1)continue;let l=Math.round(Q(yn(n,c))),d=o.side===`sell`,h=o.color?X(o.color):d?m:p,g=`${c}:${d}`,_=t.get(g)??0;t.set(g,_+(o.text&&!r?30:16));let v=f.yOf(i.scale,d?n.cols.high[c]:n.cols.low[c]),y=d?-1:1,b=v+y*(6+_);e.fillStyle=h,e.beginPath(),e.moveTo(l,b),e.lineTo(l-5.5,b+y*7),e.lineTo(l-2,b+y*7),e.lineTo(l-2,b+y*12),e.lineTo(l+2,b+y*12),e.lineTo(l+2,b+y*7),e.lineTo(l+5.5,b+y*7),e.closePath(),e.fill(),o.text&&!r&&(e.textBaseline=d?`bottom`:`top`,e.fillText(o.text,l,b+y*14)),o.price!==void 0&&E(o.price)&&(e.beginPath(),e.arc(l,f.yOf(i.scale,o.price),3,0,Math.PI*2),e.fill(),e.lineWidth=1.5,e.strokeStyle=u,e.stroke())}}e.restore(),$n(e,{text:o,background:u,up:p,down:m}),e.save(),e.beginPath(),e.rect(0,i.top,F,i.height),e.clip();let _=a?j.close[a-1]:NaN;for(let t of D.priceLines??[]){let n=Wn(t),r=Math.round(f.yOf(i.scale,n))+.5;if(!E(r)||r<i.top||r>i.top+i.height)continue;let a=Un(t),o=t.kind??`line`,c=t.lineStyle??(o===`position`||o===`line`?`solid`:`dashed`);e.save(),e.strokeStyle=a,e.lineWidth=vt===t.id||U?.kind===`order`&&U.line.id===t.id||H?.kind===`move`&&H.id===t.id?1.5:1,s.setDash(e,c,1),e.beginPath(),e.moveTo(0,r),e.lineTo(F,r),e.stroke(),e.restore();let l=re[o],d=t.title??(l?g[l]:``),h=[];if(d&&h.push({text:d,fill:a,color:ie(a)}),t.quantity!==void 0&&t.quantity!==``&&h.push({text:String(t.quantity),fill:u,color:a}),o===`position`&&typeof t.quantity==`number`&&E(_)){let e=(_-n)*t.quantity*(t.side===`sell`?-1:1),r=e>=0?p:m;h.push({text:`${e>=0?`+`:`−`}${Z(Math.abs(e))}`,fill:r,color:ie(r)})}if(t.cancellable&&h.push({text:`×`,fill:u,color:a,cancel:!0}),!h.length&&!t.draggable)continue;e.font=Wt(R.fontSize,600);let v=h.map(t=>t.cancel?20:e.measureText(t.text).width+12),y=t.draggable?14:0,b=v.reduce((e,t)=>e+t,0)+y,x=Math.round(F-b-56),S=Math.round(r-9.5);if(H?.kind===`move`&&H.id===t.id&&(Fn(e,x-3.5,S-3.5,b+7,25,5),e.strokeStyle=X(C),e.lineWidth=2,e.setLineDash([]),e.stroke()),Fn(e,x-.5,S-.5,b+1,19,3),e.fillStyle=u,e.fill(),e.strokeStyle=a,e.lineWidth=1,e.setLineDash([]),e.stroke(),y){e.fillStyle=a;for(let t=0;t<3;t++)e.fillRect(x+4,S+5+t*3.5,6,1.5);x+=y}e.textBaseline=`middle`,e.textAlign=`center`,h.forEach((n,r)=>{let i=v[r]??0,o=n.fill;n.cancel&&(Qn(x,S,i,18,()=>q(`orderCancel`,{id:t.id,line:t}))&&(o=a),e.fillStyle=a,e.fillRect(x,S+3,1,12)),o!==u&&(e.fillStyle=o,e.fillRect(x,S,i,18)),e.fillStyle=n.cancel&&o!==u?ie(a):n.color,n.cancel&&(e.font=Wt(R.fontSize+3,500)),e.fillText(n.text,x+i/2,S+(n.cancel?9:9.5)),e.font=Wt(R.fontSize,600),x+=i})}let v=D.lastPriceLine!==!1&&a>0,b=a>0&&j.close[a-1]>=j.open[a-1],x=Pt()===`line`||Pt()===`area`?X(C):b?p:m;if(v){let t=Math.round(f.yOf(i.scale,_))+.5;e.save(),e.strokeStyle=x,e.setLineDash([1,2]),e.beginPath(),e.moveTo(0,t),e.lineTo(F,t),e.stroke(),e.restore()}e.restore();let S=[];for(let e of De){let t=a-1;for(;t>=0&&!E(e.values[t]);)t--;if(t<0)continue;let n=e.values[t],r=Cn(i.scale,n,Sn(e)),o=f.yOfScaled(i.scale,r);!E(o)||o<i.top||o>i.top+i.height||S.push({y:o,text:i.scale.mode===`percent`?c.formatPercent(r,J):Z(n),color:X(e.color)})}let ee=[];for(let e of D.priceLines??[])ee.push({pane:y,y:f.yOf(i.scale,Wn(e))});for(let e of W){let t=Kn(e.pane);t&&e.type===`horizontalLine`&&e.points[0]&&ee.push({pane:t.id,y:f.yOf(t.scale,e.points[0].price)})}for(let e of S)ee.push({pane:y,y:e.y});v&&ee.push({pane:y,y:f.yOf(i.scale,_)+(D.countdown?7:0)}),e.font=Wt(R.fontSize),e.textAlign=`left`,e.textBaseline=`middle`,e.fillStyle=l;for(let t of L)for(let n of t.ticks){let r=f.yOfScaled(t.scale,n);if(r<t.top+8||r>t.top+t.height-8)continue;let i=D.countdown&&t.id===y?18:14;ee.some(e=>e.pane===t.id&&Math.abs(e.y-r)<i)||e.fillText(kn(t,n),F+8,r)}e.textAlign=`center`;for(let t of r)e.font=Wt(R.fontSize,t.bold?600:400),e.fillStyle=t.bold?o:l,e.fillText(t.text,t.x,I+h/2);for(let t of D.priceLines??[]){let n=Wn(t),r=f.yOf(i.scale,n);if(!E(r)||r<i.top||r>i.top+i.height)continue;let a=Un(t);Vn(e,r,Hn(n),a,ie(a))}for(let t of W){let n=Kn(t.pane);if(!n||t.type!==`horizontalLine`||!t.points[0])continue;let r=t.points[0].price,i=f.yOf(n.scale,r);if(i<n.top||i>n.top+n.height)continue;let a=X(t.color??C);Vn(e,i,n.id===y?Hn(r):Yn(n,r),a,ie(a))}for(let t of S)Vn(e,t.y,t.text,t.color,ie(t.color));if(v){let t;if(D.countdown){let e=Ht(),n=j.time[a-1],r=n+e.ms;if(e.unit===`month`){let t=new Date(n);r=Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+e.count,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes())}t=c.formatCountdown(r-Date.now(),g)}Vn(e,f.yOf(i.scale,_),Hn(_),x,ie(x),t)}let te=i.top+i.height-32;if(Dt){let n=B&&B.x<=F?B.x:NaN;E(n)&&(e.fillStyle=t.toCss(R.background,.62),e.fillRect(n,0,F-n,I),e.strokeStyle=X(C),e.lineWidth=1.5,e.beginPath(),e.moveTo(Math.round(n)+.5,0),e.lineTo(Math.round(n)+.5,I),e.stroke()),Zn(e,g.replayHint,F/2,te,X(C))}else K&&a&&Zn(e,d.fill(g.replay,{time:c.formatCrosshairTime($t(j.time[a-1]),Ut(),J)}),F/2,te,X(C));if(H&&a){if(H.kind===`create`){let t=H.side===`buy`?p:m,n=Math.round(f.yOf(i.scale,H.price))+.5;E(n)&&n>=i.top&&n<=i.top+i.height&&(e.save(),e.strokeStyle=t,e.lineWidth=1.5,e.setLineDash([6,4]),e.beginPath(),e.moveTo(0,n),e.lineTo(F,n),e.stroke(),e.restore(),Zn(e,d.fill(H.side===`buy`?g.buyLimit:g.sellLimit,{price:Z(H.price)}),F-56,T(n-11,i.top+2,i.top+i.height-24),t,`right`),Vn(e,n,Hn(H.price),t,ie(t)))}!K&&!Dt&&Zn(e,g.orderHint,8,te,t.toCss(R.text,.86),`left`)}let w=Gn();if(w&&n&&!Dt){let n=Math.round(Q(w.index))+.5;e.save(),e.strokeStyle=t.toCss(R.textMuted,.75),e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),n>=0&&n<=F&&(e.moveTo(n,0),e.lineTo(n,I));let r=Math.round(w.y)+.5;E(r)&&r>=w.pane.top&&r<=w.pane.top+w.pane.height&&(e.moveTo(0,r),e.lineTo(F,r)),e.stroke(),e.restore();let o=t.toCss(R.text);if(E(w.y)&&w.y>=w.pane.top&&w.y<=w.pane.top+w.pane.height){let t=f.scaledAt(w.pane.scale,w.y),n=w.pane.id===y?Hn(f.fromScaled(w.pane.scale,t)):kn(w.pane,t);Vn(e,w.y,n,o,u)}if(n>=0&&n<=F&&a){let t=c.formatCrosshairTime($t(qt(w.index)),Ut(),J);e.font=Wt(R.fontSize,500);let r=e.measureText(t).width+16,i=T(n-r/2,0,Fe-r);Fn(e,i,I+3,r,21,3),e.fillStyle=o,e.fill(),e.fillStyle=u,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(t,i+r/2,I+14)}if(D.orderEntry&&B&&w.pane.id===y&&E(w.y)&&st===`cursor`&&!U&&a){let t=F-18-4,n=T(Math.round(w.y-9),i.top+1,i.top+i.height-18-1),r=Xn(w.price),a=r<_?`buy`:`sell`,s=Qn(t,n,18,18,()=>q(`orderCreate`,{price:r,side:a}));Fn(e,t,n,18,18,4),e.fillStyle=s?X(C):o,e.fill(),e.strokeStyle=s?ie(X(C)):u,e.lineWidth=1.5,e.beginPath(),e.moveTo(t+5,n+9),e.lineTo(t+18-5,n+9),e.moveTo(t+9,n+5),e.lineTo(t+9,n+18-5),e.stroke(),s&&Zn(e,d.fill(a===`buy`?g.buyLimit:g.sellLimit,{price:Z(r)}),t-6,n-2,a===`buy`?p:m,`right`)}}},tr=``,nr=[],rr=new Map,ir=new Map,ar=e=>{let t=ir.get(e);return t||(t=pe(`div`,{position:`absolute`,left:`4px`,display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:`1px`,maxWidth:`calc(100% - 12px)`,overflow:`hidden`,fontSize:`12px`,lineHeight:`18px`,fontVariantNumeric:`tabular-nums`,whiteSpace:`nowrap`,pointerEvents:`none`}),_e.appendChild(t),ir.set(e,t)),t},or=(e,t,n,r)=>{let i=pe(`div`,{display:`flex`,flexWrap:`wrap`,alignItems:`center`,columnGap:`6px`,maxWidth:`100%`,minWidth:`0`,boxSizing:`border-box`,padding:`0 4px`,borderRadius:`4px`,background:`color-mix(in srgb, var(--surface-color, var(--background-color, #fff)) 86%, transparent)`}),a=null;if(n)a=pe(`button`,{all:`unset`,cursor:`pointer`,pointerEvents:`auto`,color:`var(--text-color, #1f2937)`,fontWeight:`500`,borderRadius:`3px`,...oe}),a.type=`button`,a.textContent=t,a.setAttribute(`aria-label`,d.fill(Nt().toggleIndicator,{name:t})),a.addEventListener(`click`,e=>{e.stopPropagation();let t=!Gt(n);Ee.set(n.id,t),q(`indicatorToggle`,{id:n.id,visible:t}),ur(),$()}),a.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.appendChild(a);else if(t){let e=pe(`span`,{fontWeight:`600`,...oe});e.textContent=t,i.appendChild(e)}let o=[];for(let e=0;e<r;e++){let e=pe(`span`,oe);i.appendChild(e),o.push(e)}return e.appendChild(i),{row:i,values:o,button:a}},sr=()=>{rr.clear();for(let e of ir.values())e.remove();if(ir.clear(),D.legend===!1)return;let e=ar(y),t=[D.symbol,D.labels?.timeframe??(typeof D.timeframe==`string`?D.timeframe:``)].filter(Boolean).join(` · `);rr.set(`ohlc`,or(e,t,null,1));for(let t of M){let n=t.mergeLegend?1:t.outputs.length;t.overlay&&t.type===`volume`?rr.set(t.id,or(e,cr(t),t,1)):t.overlay&&rr.set(t.id,or(e,cr(t),t,n))}for(let t of De)rr.set(`compare:${t.id}`,or(e,``,null,1));for(let e of M)e.overlay||rr.set(e.id,or(ar(e.id),cr(e),e,e.mergeLegend?1:e.outputs.length))},cr=e=>e.type===`volume`?Nt().volume:e.titleKey?`${Nt()[e.titleKey]} ${e.title}`:e.title,lr=(e,t,n)=>{if(!e)return;e.textContent!==t&&(e.textContent=t);let r=n??``;e.style.color!==r&&(e.style.color=r)},ur=()=>{let e=[D.legend!==!1,D.symbol,D.timeframe,...M.map(e=>`${e.id}:${cr(e)}:${e.outputs.length}`),...De.map(e=>e.id),jt.toggleIndicator,D.labels?.timeframe].join(`|`);if(e!==tr&&(tr=e,sr()),D.legend===!1)return;for(let e of L){let t=ir.get(e.id);if(!t)continue;t.style.top=`${e.top+6}px`;let n=`${Math.max(60,Math.floor(F-10))}px`;t.style.maxWidth!==n&&(t.style.maxWidth=n);let r=`${Math.max(18,Math.floor(e.height-10))}px`;t.style.maxHeight!==r&&(t.style.maxHeight=r)}let t=ir.get(y),n=t?Array.from(t.children,e=>({right:t.offsetLeft+e.offsetLeft+e.offsetWidth,top:t.offsetTop+e.offsetTop,bottom:t.offsetTop+e.offsetTop+e.offsetHeight})):[],r=n.length!==nr.length||n.some((e,t)=>{let n=nr[t];return!n||n.right!==e.right||n.top!==e.top||n.bottom!==e.bottom});nr=n,r&&$();let i=Y(),a=Gn(),o=T(a&&a.index>=0&&a.index<i?a.index:i-1,0,Math.max(0,i-1)),s=Nt(),l=rr.get(`ohlc`),u=X(It()),d=X(Lt());if(l&&i){let e=on(),t=e.open[o],n=e.close[o],r=o>0?e.close[o-1]:t,i=n-r,a=n>=t?u:d,f=l.values[0],p=[[s.open,e.open[o]],[s.high,e.high[o]],[s.low,e.low[o]],[s.close,n]].map(([e,t])=>`<span style="${se}"><span style="color:var(--text-secondary-color,#6b7280)">${dr(String(e))}</span><span style="color:${a}">${dr(Z(t))}</span></span>`).join(``),m=r?i/r*100:NaN,h=`${p}${`<span style="${se}">${s.change?`<span style="color:var(--text-secondary-color,#6b7280)">${dr(s.change)}</span>`:``}<span style="color:${i>=0?u:d}">${i>=0?`+`:`−`}${dr(Z(Math.abs(i)))} (${dr(c.formatPercent(m,J))})</span></span>`}${j.hasVolume?`<span style="${se}"><span style="color:var(--text-secondary-color,#6b7280)">${dr(s.volume)}</span>${dr(c.formatVolume(j.volume[o],J))}</span>`:``}`;f&&f.dataset.html!==h&&(f.innerHTML=h,f.dataset.html=h,f.style.display=`inline-flex`,f.style.columnGap=`6px`,f.style.flexWrap=`wrap`)}for(let e of M){let t=rr.get(e.id);if(!t)continue;let n=Gt(e);t.row.style.opacity=n?`1`:`0.5`,t.button&&(t.button.setAttribute(`aria-pressed`,String(n)),t.button.style.textDecoration=n?`none`:`line-through`);let r=e.outputs.length;if(e.mergeLegend){let r=e.outputs.find(e=>E(e.values[o]));lr(t.values[0],n&&i&&r?An(e,r.values[o]):``,r?X(en(r.color)):void 0);continue}e.outputs.forEach((a,s)=>{let l=t.values[e.type===`macd`?(s+r-1)%r:s];if(!n||!i){lr(l,``);return}if(a.kind===`volume`){let e=j.close[o]>=j.open[o]?u:d;lr(l,c.formatVolume(j.volume[o],J),e);return}let f=o-a.shift,p=f>=0&&f<i?a.values[f]:NaN,m=a.color?X(en(a.color)):void 0;a.kind===`histogram`&&(m=p>=0?u:d),a.kind===`dots`&&!a.color&&(m=p<=j.close[o]?u:d);let h=e.outputs.length>1&&!e.plainLegend?`${a.label} `:``;lr(l,`${h}${An(e,p)}`,m)})}for(let e of De){let t=rr.get(`compare:${e.id}`);if(!t)continue;let n=e.values[o],r=Sn(e),i=E(r)?(n/r-1)*100:NaN;lr(t.values[0],`${e.name} ${Z(n)} ${c.formatPercent(i,J)}`,X(e.color))}},dr=e=>e.replace(/[&<>"]/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:`"`),$=()=>{fe||We||(We=de?.requestAnimationFrame?de.requestAnimationFrame(mr):setTimeout(()=>mr(Date.now()),16))},fr=e=>{let t=!1;if(et){let n=Math.min(1,(e-et.start)/320),r=1-(1-n)**3;P=et.from+(et.to-et.from)*r,n>=1?et=null:t=!0}if($e){let n=Math.min(64,e-$e.t);$e.t=e;let r=P;P-=$e.v*n/N,$e.v*=Math.exp(-n/320),_n(),Math.abs($e.v)<.02||P===r?$e=null:t=!0}return t},pr=e=>{e.font=Wt(R.fontSize,500);let t=0;for(let n of L)for(let r of n.ticks)t=Math.max(t,e.measureText(kn(n,r)).width);let n=Y();n&&(t=Math.max(t,e.measureText(Hn(j.close[n-1])).width),D.countdown&&(t=Math.max(t,e.measureText(`00:00:00`).width)));let r=Math.max(g,Math.ceil(t+18));(r>Pe||r<Pe-12)&&(Pe=r)};function mr(e){if(We=0,fe||(Fe=O.clientWidth,Ie=O.clientHeight,Fe<=0||Ie<=0))return;let t=fr(typeof performance<`u`?performance.now():e??Date.now()),n=de?.devicePixelRatio||1;cn(),Pn(he,n),Pn(ge,n);let r=he.getContext(`2d`),i=ge.getContext(`2d`);I=Math.max(1,Ie-h);for(let e=0;e<2;e++){F=Math.max(1,Fe-Pe),hn(),tt&&yr(tt),_n(),ze=vn(),Dn(ze);for(let e of L){let t=f.scaleTicks(e.scale,e.id===y?44:30),n=e.study?.range,r=e.study?.bands;e.ticks=n&&r?[...r,(n[0]+n[1])/2].sort((e,t)=>e-t):t.scaled,e.step=t.step}let e=Pe;if(i&&pr(i),Pe===e)break}let a=ze;tt=null;let o=i?On(a,i):[];Nn(a,n),r&&(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,Fe,Ie),Bn(r,a,o)),i&&(i.setTransform(n,0,0,n,0,0),i.clearRect(0,0,Fe,Ie),er(i,a,o)),ur(),hr(),Jr(),Vr(),_r(),B&&!U&&Rr(B.x,B.y)!==bt&&(ii(B.x,B.y),$()),t&&$()}let hr=()=>{let e=Y(),t=L[0],n=e>0&&t&&Q(e-1)>F+N*.5;if(ve.style.display=n?`flex`:`none`,n&&t){ve.style.left=`${F-40}px`,ve.style.top=`${t.top+t.height-40}px`;let e=Nt().scrollToRealtime;ve.getAttribute(`aria-label`)!==e&&(ve.setAttribute(`aria-label`,e),ve.title=e)}},gr=()=>{let e=P-F/N;return{from:e,to:P,fromTime:qt(e),toTime:qt(P)}},_r=()=>{let e=Y();if(!e)return;let t=gr();(!xt||Math.abs(xt.from-t.from)>1e-6||Math.abs(xt.to-t.to)>1e-6)&&(xt=t,St||q(`visibleRangeChange`,t)),St=!1,t.from<10&&Tt!==j.time[0]&&(Tt=j.time[0],q(`historyRequest`,{firstTime:j.time[0],count:e}));let n=Gn(),r=n&&(B||V!==null)?n:null,i=r?`${r.index}|${r.price}|${r.pane.id}`:``;if(i!==wt){if(wt=i,!r)q(`crosshairMove`,null);else{let t={index:r.index,time:qt(r.index),bar:r.index>=0&&r.index<e?p.readBar(j,r.index):null,price:r.price,pane:r.pane.id,x:Q(r.index),y:r.y};q(`crosshairMove`,t)}}},vr=e=>{let t=O.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},yr=e=>{N=F/(e.to-e.from),P=e.to,_n()},br=(e,t)=>{let n=Y();n&&fn()&&(e=Math.min(F,Q(n-1)));let r=Kt(e);N*=t,_n(),P=r+(F-e)/N,_n(),$e=null,et=null,$()},xr=(e,t,n)=>{let r=Math.round(Kt(e));return{time:qt(r),price:f.valueAt(n.scale,t)}},Sr=(e,t)=>{e!==st&&(st=e,G=null,ut=0,t&&q(`drawingToolChange`,e),$())},Cr=e=>{e!==ct&&(ct=e,gt=!1,q(`drawingSelect`,e),$())},wr=()=>({canUndo:it.length>0,canRedo:at.length>0}),Tr=()=>{let e=wr(),t=`${e.canUndo}|${e.canRedo}`;t!==ot&&(ot=t,q(`undoChange`,e))},Er=(e,t=!0)=>{e!==rt&&(it.push(rt),it.length>ee&&it.shift(),at.length=0,rt=e),W=e,t&&(nt=e,q(`drawingsChange`,e)),ct&&!e.some(e=>e.id===ct)&&Cr(null),Tr(),$()},Dr=e=>{rt=e,W=e,nt=e,G=null,ct&&!e.some(e=>e.id===ct)&&Cr(null),q(`drawingsChange`,e),Tr(),$()},Or=()=>{let e=it.pop();e&&(mt&&Ur(!1),at.push(rt),Dr(e))},kr=()=>{let e=at.pop();e&&(it.push(rt),Dr(e))},Ar=(e,t)=>{W.some(t=>t.id===e)&&Er(W.map(n=>n.id===e?{...n,...t,id:n.id,type:n.type}:n))},jr=e=>{W.some(t=>t.id===e)&&(ct===e&&Cr(null),Er(W.filter(t=>t.id!==e)))},Mr=(e,t,n)=>{let r=f.yOf(t.scale,e.price),i=Math.max(12,t.height*.07),a=f.valueAt(t.scale,r+(n?-2:2)*i),o=f.valueAt(t.scale,r+(n?1:-1)*i),s=Math.max(6,Math.round(F*.16/N)),c=qt(Math.round(an(e.time))+s);return[e,{time:c,price:Xn(a)},{time:c,price:Xn(o)}]},Nr=()=>{if(!G)return;let e=G;G=null,ut=0,Er([...W,e]),Cr(e.id),D.keepDrawingMode||Sr(`cursor`,!0),e.type===`text`&&Hr(e.id,!0)},Pr=()=>{if(!G)return;if(ut--,ut<=0){Nr();return}let e=G.points[G.points.length-1];e&&(G={...G,points:[...G.points,e]})},Fr=(e,t)=>{let n=Kn(dt);!G||!n||ut<=0||(G={...G,points:[...G.points.slice(0,-1),xr(e,t,n)]})},Ir=(e,t)=>{let n=L[0];if(!n||e>F)return null;for(let e of D.priceLines??[])if(e.draggable&&Math.abs(f.yOf(n.scale,Wn(e))-t)<=5)return e;return null},Lr=(e,t)=>{if(e>F)return null;let n=gn(t),r=qn(n);if(!n||!r)return null;for(let i=W.length-1;i>=0;i--){let a=W[i];if(!a||(a.pane??y)!==n.id)continue;let o=s.hitDrawing(a,r,{x:e,y:t},6,pt.get(a.id));if(o)return{drawing:a,hit:o,pane:n}}return null},Rr=(e,t)=>yt.findIndex(n=>e>=n.x&&e<=n.x+n.w&&t>=n.y&&t<=n.y+n.h),zr=e=>{for(let t=1;t<L.length;t++)if(Math.abs(L[t].top-e)<=4)return t;return-1},Br=()=>{A.style.height=`auto`,A.style.height=`${Math.max(28,A.scrollHeight+2)}px`},Vr=()=>{if(!mt)return;let e=mt.id,t=W.find(t=>t.id===e),n=t?Kn(t.pane):null,r=t?.points[0];if(!t||!n||!r)return;let i=Q(an(r.time)),a=f.yOf(n.scale,r.price);A.style.left=`${T(i,2,Math.max(2,F-160))}px`,A.style.top=`${T(a,2,Math.max(2,I-40))}px`};function Hr(e,t){let n=W.find(t=>t.id===e);n&&!n.locked&&(mt={id:e,created:t},A.value=t?``:n.text??``,A.placeholder=Nt().text,A.setAttribute(`aria-label`,Nt().editText),A.style.display=`block`,Vr(),Br(),A.focus(),A.select(),$())}function Ur(e){if(!mt)return;let{id:t,created:n}=mt;mt=null,A.style.display=`none`;let r=A.value.replace(/\s+$/,``),i=W.find(e=>e.id===t);if(i&&n&&(!e||!r)){let e=it.pop();Dr(e??W.filter(e=>e.id!==t))}else if(i&&e&&r!==(i.text??``)){if(n){let e=W.map(e=>e.id===t?{...e,text:r}:e);rt=e,W=e,nt=e,q(`drawingsChange`,e)}else Ar(t,{text:r})}(ue.activeElement===A||ue.activeElement===ue.body)&&O.focus(),$()}A.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),Ur(!0)):e.key===`Escape`&&(e.preventDefault(),Ur(!1))}),A.addEventListener(`input`,Br),A.addEventListener(`blur`,()=>Ur(!0)),A.addEventListener(`pointerdown`,e=>e.stopPropagation()),A.addEventListener(`dblclick`,e=>e.stopPropagation());let Wr=(e,t=``,n=1.5)=>`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round"${t?` stroke-dasharray="${t}"`:``} aria-hidden="true"><path d="${e}"/></svg>`,Gr=(e,t,n,r)=>{let i=ue.createElement(`button`);return i.type=`button`,i.setAttribute(`aria-label`,e),i.title=e,r!==void 0&&i.setAttribute(`aria-pressed`,String(r)),i.innerHTML=t,i.addEventListener(`click`,e=>{e.stopPropagation(),n()}),i},Kr=()=>{let e=ue.createElement(`span`);return e.className=`sep`,e},qr=e=>{k.textContent=``;let t=Nt();k.setAttribute(`aria-label`,t.lineStyle);let n=e.id,r=[];if(!e.locked){let i=X(e.color??C),a=Gr(t.color,`<span style="display:block;width:14px;height:14px;border-radius:50%;background:${i};box-shadow:inset 0 0 0 1px rgba(127,127,127,.35)"></span>`,()=>{gt=!gt,ht=``,Jr()});a.setAttribute(`aria-expanded`,String(gt)),r.push(a);let o=e.lineWidth??1.5,c=[1,2,3,4];r.push(Gr(`${t.lineWidth}: ${o}px`,`${Wr(`M2 8h12`,``,Math.min(4,o))}<span style="font-size:11px;margin-left:3px">${o}</span>`,()=>Ar(n,{lineWidth:c.find(e=>e>o)??c[0]})));let l=e.lineStyle??`solid`;r.push(Gr(t.lineStyle,Wr(`M2 8h12`,l===`dashed`?`3.5 2.5`:l===`dotted`?`0.1 3`:``,l===`dotted`?2.2:1.6),()=>Ar(n,{lineStyle:w[(w.indexOf(l)+1)%w.length]}))),s.isFillable(e.type)&&r.push(Gr(t.fill,`<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="9" rx="1.5" fill="currentColor" fill-opacity=".3" stroke="currentColor" stroke-width="1.3"/></svg>`,()=>Ar(n,{fill:e.fill===!1}),e.fill!==!1)),e.type===`text`&&r.push(Gr(t.editText,Wr(`M3 13h3l7-7-3-3-7 7zM9 4l3 3`),()=>Hr(n,!1))),r.push(Kr())}if(r.push(Gr(t.lock,e.locked?Wr(`M4.5 7.5h7v6h-7zM6 7.5V5.5a2 2 0 0 1 4 0v2`):Wr(`M4.5 7.5h7v6h-7zM6 7.5V5.5a2 2 0 0 1 3.8-.9`),()=>Ar(n,{locked:!e.locked}),!!e.locked)),!e.locked){let e=Gr(t.remove,Wr(`M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.7 8.5h5.6l.7-8.5`),()=>jr(n));e.style.color=`var(--danger-color, #f23645)`,r.push(e)}if(k.append(...r),gt&&!e.locked){let r=pe(`div`,{position:`absolute`,left:`0`,top:`calc(100% + 4px)`,display:`flex`,gap:`2px`,padding:`4px`,borderRadius:`8px`,border:`1px solid color-mix(in srgb, var(--border-color, #e5e7eb) 85%, transparent)`,background:`var(--surface-elevated-color, var(--surface-color, #fff))`,boxShadow:`0 8px 24px -8px rgba(15, 23, 42, 0.35)`});for(let i of te){let a=Gr(`${t.color} ${i}`,`<span style="display:block;width:16px;height:16px;border-radius:50%;background:${i}"></span>`,()=>{gt=!1,Ar(n,{color:i})},(e.color??``).toLowerCase()===i);r.appendChild(a)}k.appendChild(r)}};function Jr(){let e=ct?W.find(e=>e.id===ct):void 0,t=e?Kn(e.pane):null,n=qn(t),r=U?.kind===`drawing`&&U.moved;if(!e||!t||!n||D.drawingToolbar===!1||mt||r||G){k.style.display=`none`,ht=``,gt=!1;return}let i=[e.id,e.color,e.lineWidth,e.lineStyle,e.fill,e.locked,gt,J,Ve].join(`|`);i!==ht&&(ht=i,qr(e)),k.style.display=`flex`;let a=s.handlePoints(e,n,pt.get(e.id)),o=pt.get(e.id);e.type===`text`&&o&&a.push({x:o.x+o.w,y:o.y+o.h});let c=1/0,l=-1/0,u=1/0,d=-1/0;for(let e of a)c=Math.min(c,T(e.x,0,F)),l=Math.max(l,T(e.x,0,F)),u=Math.min(u,T(e.y,t.top,t.top+t.height)),d=Math.max(d,T(e.y,t.top,t.top+t.height));e.type===`horizontalLine`&&(c=F*.35,l=F*.65);let f=k.offsetWidth||200,p=k.offsetHeight||34,m=T((c+l)/2-f/2,4,Math.max(4,F-f-4)),h=u-p-14;h<4&&(h=d+32),k.style.left=`${Math.round(m)}px`,k.style.top=`${Math.round(T(h,4,Math.max(4,I-p-4)))}px`}k.addEventListener(`pointerdown`,e=>e.stopPropagation()),k.addEventListener(`dblclick`,e=>e.stopPropagation()),k.addEventListener(`pointermove`,e=>e.stopPropagation()),k.addEventListener(`pointerenter`,()=>{B=null,lt=null,O.style.cursor=`default`,$()});let Yr=()=>({active:!!K,picking:Dt,playing:!!K?.playing,speed:K?.speed??Ot,index:Y(),total:K?K.source.length:Y(),time:Y()?j.time[Y()-1]:NaN}),Xr=()=>q(`replayChange`,Yr()),Zr=(e,t)=>({time:e.time.subarray(0,t),open:e.open.subarray(0,t),high:e.high.subarray(0,t),low:e.low.subarray(0,t),close:e.close.subarray(0,t),volume:e.volume.subarray(0,t)}),Qr=(e,t)=>{let n=e.hasVolume;p.setBars(j,Zr(e,t)),j.hasVolume=n,xe=p.createPyramid(),we=p.createPyramid(),Ce=0,Tt=NaN,ln(0)},$r=()=>{K?.timer&&clearInterval(K.timer),K&&(K.timer=null,K.playing=!1)},ei=e=>{if(Dt=!1,!K){if(!Y())return;let e=p.createStore();p.setBars(e,Zr(j,Y())),e.hasVolume=j.hasVolume,K={source:e,playing:!1,speed:Ot,timer:null}}$r();let t=T(Math.round(e)+1,1,K.source.length);Qr(K.source,t),P=t-1+(D.rightOffset??8);for(let e of Le.values())e.auto=!0;Xr()},ti=e=>{if(!K)return;let t=K.source,n=Y(),r=fn(),i=-1;for(let n=0;n<e&&Y()<t.length;n++){let e=p.updateBar(j,p.readBar(t,Y()));i<0&&(i=e)}j.hasVolume=t.hasVolume,i>=0&&(r&&(P+=Y()-n),ln(i)),Y()>=t.length&&$r(),Xr()},ni=e=>{if(!K)return;if(e!==void 0&&e>0&&(K.speed=Ot=e),$r(),Y()>=K.source.length){Xr();return}let t=Math.max(16,1e3/K.speed),n=Math.max(1,Math.round(K.speed*t/1e3));K.playing=!0,K.timer=setInterval(()=>ti(n),t),Xr()},ri=e=>{let t=Dt;if(Dt=!1,!K){t&&(Xr(),$());return}$r();let n=K.source;K=null,e&&Qr(n,n.length),Xr()},ii=(e,t)=>{let n=`crosshair`;vt=null;let r=null,i=U?-1:Rr(e,t);if(i!==bt&&(bt=i),U?.kind===`pan`&&U.moved)n=`grabbing`;else if(i>=0)n=`pointer`;else if(Dt&&e<=F&&t<=I)n=`pointer`;else if(zr(t)>0)n=`row-resize`;else if(e>F&&t<I)n=`ns-resize`;else if(t>I)n=`ew-resize`;else if(st===`cursor`){let i=Ir(e,t);if(i)n=`ns-resize`,vt=i.id;else{let i=Lr(e,t);i&&(r=i.drawing.id,n=i.drawing.locked?`pointer`:i.hit.part===`handle`?`move`:`pointer`)}}r!==lt&&(lt=r),O.style.cursor!==n&&(O.style.cursor=n)},ai=e=>{if(e.button!==0&&e.pointerType===`mouse`)return;let{x:t,y:n}=vr(e);if(B={x:t,y:n},V=null,H&&hi(!0),$e=null,et=null,mt&&Ur(!0),gt&&(gt=!1,$()),e.pointerType===`touch`&&(Ze.set(e.pointerId,{x:t,y:n}),Ze.size===2)){let[e,t]=[...Ze.values()];Qe={distance:Math.hypot(e.x-t.x,e.y-t.y),spacing:N},U=null;return}try{O.setPointerCapture(e.pointerId)}catch{}let r=Rr(t,n),i=yt[r];if(i){U={kind:`button`,action:i.action};return}if(Dt&&t<=F&&n<=I){ei(Math.min(Y()-1,Math.round(Kt(t))));return}let a=zr(n);if(a>0){let e=L[a-1],t=L[a];U={kind:`separator`,index:a,y:n,above:e.height,below:t.height};return}if(t>F&&n<I){let e=gn(n);e&&(U={kind:`axisY`,pane:e,y:n,min:e.scale.min,max:e.scale.max});return}if(n>I){U={kind:`axisX`,x:t,spacing:N};return}let o=gn(n);if(st!==`cursor`&&o&&Y()){if(G){Fr(t,n),Pr(),U=null,$();return}let e=st,r=s.isPosition(e),i=r?L[0]:o,a=xr(t,T(n,i.top,i.top+i.height),i),c=s.anchorCount(e);if(dt=i.id,G={id:`drawing-${Date.now().toString(36)}-${++ft}`,type:e,points:r?Mr({...a,price:Xn(a.price)},i,e===`longPosition`):c===1?[a]:[a,a],...i.id===y?{}:{pane:i.id}},c===1){Nr();return}ut=c-1,U={kind:`create`,pane:i,x:t,y:n,moved:!1},$();return}if(st===`cursor`){let e=Ir(t,n);if(e){U={kind:`order`,line:e,startPrice:e.price};return}let r=Lr(t,n);if(r){Cr(r.drawing.id),r.drawing.locked||(U={kind:`drawing`,id:r.drawing.id,pane:r.pane,handle:r.hit.part===`handle`?r.hit.index:-1,x:t,y:n,original:r.drawing,moved:!1});return}}U={kind:`pan`,x:t,y:n,right:P,pane:o,moved:!1,lastX:t,lastY:n,lastT:e.timeStamp,velocity:0}},oi=e=>{let{x:t,y:n}=vr(e);if(B={x:t,y:n},e.pointerType===`touch`&&Ze.has(e.pointerId)&&(Ze.set(e.pointerId,{x:t,y:n}),Qe&&Ze.size===2)){let[e,t]=[...Ze.values()],n=Math.hypot(e.x-t.x,e.y-t.y),r=Y(),i=r&&fn()?Math.min(F,Q(r-1)):(e.x+t.x)/2,a=Kt(i);N=Qe.spacing*n/Math.max(1,Qe.distance),_n(),P=a+(F-i)/N,_n(),$();return}let r=U;if(!r){G&&Fr(t,n),ii(t,n),$();return}switch(r.kind){case`pan`:{let i=t-r.x;if(!r.moved&&Math.hypot(i,n-r.y)<3)break;r.moved=!0,P=r.right-i/N,r.pane&&!r.pane.scale.auto&&f.panScale(r.pane.scale,n-r.lastY),r.lastY=n;let a=Math.max(1,e.timeStamp-r.lastT);r.velocity=.6*((t-r.lastX)/a)+.4*r.velocity,r.lastX=t,r.lastT=e.timeStamp,_n(),O.style.cursor=`grabbing`;break}case`axisY`:{let e=r.pane.scale;e.min=r.min,e.max=r.max,f.zoomScale(e,Math.exp((n-r.y)*.006));break}case`axisX`:{let e=P;N=r.spacing*Math.exp((t-r.x)*.006),_n(),P=e,_n();break}case`separator`:{let e=n-r.y,t=L[r.index-1],i=L[r.index];if(!t||!i)break;let a=r.above+r.below,o=T(r.below-e,v,a-v);Re.set(i.id,o),t.id!==y&&Re.set(t.id,a-o);break}case`order`:_t.set(r.line.id,Xn(f.valueAt(L[0].scale,n)));break;case`drawing`:{if(!r.moved&&Math.hypot(t-r.x,n-r.y)<3)break;r.moved=!0;let e=r.pane.scale,i;if(r.handle>=0)i=s.moveHandle(r.original,r.handle,xr(t,n,r.pane));else{let a=Math.round(Kt(t)-Kt(r.x)),o=f.scaledAt(e,n)-f.scaledAt(e,r.y);i=r.original.points.map(t=>({time:qt(Math.round(an(t.time))+a),price:f.fromScaled(e,f.toScaled(e,t.price)+o)}))}W=W.map(e=>e.id===r.id?{...e,points:i}:e);break}case`create`:Math.hypot(t-r.x,n-r.y)>=4&&(r.moved=!0),Fr(t,n);break;default:ii(t,n)}$()},si=e=>{Ze.delete(e.pointerId),Ze.size<2&&(Qe=null);let t=U;U=null;let{x:n,y:r}=vr(e);if(e.pointerType===`touch`&&(B=null),!t){$();return}switch(t.kind){case`pan`:if(t.moved)D.kineticScroll!==!1&&e.timeStamp-t.lastT<60&&Math.abs(t.velocity)>.25&&($e={v:t.velocity,t:typeof performance<`u`?performance.now():Date.now()});else{ct&&Cr(null);let e=gn(r);e&&n<=F&&q(`click`,{index:Math.round(Kt(n)),time:qt(Math.round(Kt(n))),price:f.valueAt(e.scale,r),pane:e.id})}break;case`order`:{let e=_t.get(t.line.id);e!==void 0&&e!==t.startPrice?q(`orderMove`,{id:t.line.id,price:e,previousPrice:t.startPrice,line:t.line}):_t.delete(t.line.id);break}case`drawing`:t.moved&&Er(W);break;case`create`:t.moved&&Pr();break;case`button`:Rr(n,r)>=0&&t.action()}ii(n,r),$()},ci=e=>{U||e.pointerType===`touch`||(B=null,lt=null,vt=null,$())},li=e=>{let t=D.wheel??`zoom`;if(t===`none`)return;let{x:n}=vr(e),r=e.deltaMode===1?16:e.deltaMode===2?F:1,i=e.deltaX*r,a=e.deltaY*r,o=e.ctrlKey||e.metaKey;if(t===`modifier`&&!o&&Math.abs(i)<=Math.abs(a))return;if(e.preventDefault(),V=null,Math.abs(i)>Math.abs(a)||e.shiftKey){P+=(Math.abs(i)>Math.abs(a)?i:a)/N,_n(),$e=null,$();return}let s=Math.exp(-a*(e.ctrlKey?.01:.0015));br(Math.min(n,F),s)},ui=e=>{let{x:t,y:n}=vr(e),r=st===`cursor`?Lr(t,n):null;if(r?.drawing.type===`text`){Hr(r.drawing.id,!1);return}if(t>F&&n<I){let e=gn(n);e&&(e.scale.auto=!0)}else if(n>I)N=D.barSpacing??8,Oi.scrollToRealtime(!0);else for(let e of Le.values())e.auto=!0;$()},di=e=>{if(e<0||e>=Y())return;let t=on(),n=Nt();ye.textContent=d.fill(n.announcement,{time:c.formatCrosshairTime($t(j.time[e]),Ut(),J),open:Z(t.open[e]),high:Z(t.high[e]),low:Z(t.low[e]),close:Z(t.close[e])})},fi=e=>{ye.textContent=e},pi=()=>(D.priceLines??[]).filter(e=>e.draggable||e.cancellable),mi=e=>{let t=re[e.kind??`line`];return e.title??(t?Nt()[t]:``)},hi=e=>{H?.kind===`move`&&e&&(H.override===void 0?_t.delete(H.id):_t.set(H.id,H.override)),H=null},gi=e=>{let t=Y();if(!D.orderEntry||!t||e.altKey||e.ctrlKey||e.metaKey)return!1;let n=Nt(),r=e.key.length===1?e.key.toLowerCase():e.key,i=(e,t)=>d.fill(e===`buy`?n.buyLimit:n.sellLimit,{price:Z(t)});if(r===`b`||r===`s`){hi(!0);let e=Gn(),a=e&&e.pane.id===y&&E(e.price)?e.price:j.close[t-1],o=r===`b`?`buy`:`sell`;return H={kind:`create`,side:o,price:Xn(a)},fi(`${i(o,H.price)}. ${n.orderHint}`),!0}if(r===`o`){let t=pi();if(!t.length)return!1;let r=H?.kind===`move`?H.id:null;hi(!0);let i=t.findIndex(e=>e.id===r),a=e.shiftKey?-1:1,o=t[i<0?a>0?0:t.length-1:(i+a+t.length)%t.length];if(!o)return!1;H={kind:`move`,id:o.id,start:Wn(o),override:_t.get(o.id)};let s=d.fill(n.orderLine,{title:mi(o),price:Z(Wn(o))});return fi([s,o.draggable?n.orderHint:``,o.cancellable?n.orderCancelHint:``].filter(Boolean).join(`. `)),!0}if(!H)return!1;let a=H.kind===`move`?H.id:null,o=(D.priceLines??[]).find(e=>e.id===a);switch(e.key){case`ArrowUp`:case`ArrowDown`:{let t=10**-zt()*(e.shiftKey?10:1)*(e.key===`ArrowUp`?1:-1);if(H.kind===`create`)H.price=Xn(H.price+t),fi(i(H.side,H.price));else if(o?.draggable){let e=Xn(Wn(o)+t);_t.set(o.id,e),fi(Z(e))}return!0}case`Enter`:{if(H.kind===`create`){let{price:e,side:t}=H;return hi(!1),q(`orderCreate`,{price:e,side:t}),fi(d.fill(n.orderPlaced,{price:Z(e)})),!0}let e=H.start;hi(!1);let t=o?_t.get(o.id):void 0;return o&&t!==void 0&&t!==e&&(q(`orderMove`,{id:o.id,price:t,previousPrice:e,line:o}),fi(d.fill(n.orderPlaced,{price:Z(t)}))),!0}case`Escape`:return H.kind===`create`?fi(n.orderCancelled):o&&fi(d.fill(n.orderLine,{title:mi(o),price:Z(H.start)})),hi(!0),!0;case`Delete`:case`Backspace`:return o?.cancellable&&(hi(!0),q(`orderCancel`,{id:o.id,line:o}),fi(n.orderCancelled)),!0;default:return!1}};O.addEventListener(`pointerdown`,ai),O.addEventListener(`pointermove`,oi),O.addEventListener(`pointerup`,si),O.addEventListener(`pointercancel`,si),O.addEventListener(`pointerleave`,ci),O.addEventListener(`wheel`,li,{passive:!1}),O.addEventListener(`dblclick`,ui),O.addEventListener(`keydown`,e=>{if(e.target===O&&gi(e)){e.preventDefault(),$();return}if((e.ctrlKey||e.metaKey)&&!e.altKey){let t=e.key.toLowerCase();(t===`z`||t===`y`)&&(t===`y`||e.shiftKey?kr():Or(),e.preventDefault());return}let t=Y(),n=Math.max(1,Math.floor(F/N/2)),r=e=>{V=T(e,0,Math.max(0,t-1));let n=Q(V);n<N&&(P+=(N-n)/N+1),n>F-N&&(P-=(n-F+N)/N-1),_n(),di(V)},i=V??Math.min(t-1,Math.round(P));switch(e.key){case`ArrowLeft`:r(i-(e.shiftKey?10:1));break;case`ArrowRight`:r(i+(e.shiftKey?10:1));break;case`PageUp`:r(i-n);break;case`PageDown`:r(i+n);break;case`Home`:r(0);break;case`End`:r(t-1),Oi.scrollToRealtime(!0);break;case`+`:case`=`:case`ArrowUp`:br(V===null?F:Q(V),1.2);break;case`-`:case`_`:case`ArrowDown`:br(V===null?F:Q(V),1/1.2);break;case`Escape`:gt?gt=!1:Dt?ri(!1):G?(G=null,ut=0):st===`cursor`?ct?Cr(null):V=null:Sr(`cursor`,!0);break;case`Delete`:case`Backspace`:{let e=W.find(e=>e.id===ct);if(!e||e.locked)return;jr(e.id);break}default:return}e.preventDefault(),$()}),O.addEventListener(`focus`,()=>{let e=!0;try{e=O.matches(`:focus-visible`)}catch{}e&&(O.style.boxShadow=`inset 0 0 0 2px ${t.toCss(R.primary,.6)}`)}),O.addEventListener(`blur`,()=>{O.style.boxShadow=``,H&&(hi(!0),$()),V!==null&&(V=null,$())}),ve.addEventListener(`pointerdown`,e=>e.stopPropagation()),ve.addEventListener(`click`,()=>Oi.scrollToRealtime(!0));let _i=typeof ResizeObserver==`function`?new ResizeObserver(()=>$()):null;_i?.observe(O);let vi=()=>{if(fe)return;let e=o.readTheme(O);o.themeColorsChanged(R,e)&&Ve++,R=e,tr=``,$()},yi=o.watchTheme(vi),bi=null;typeof MutationObserver==`function`&&O.ownerDocument&&(bi=new MutationObserver(()=>{if(D.locale)return;let e=J;Mt(),J!==e&&(tr=``,He++,Ti(),$())}),bi.observe(O.ownerDocument.documentElement,{attributes:!0,attributeFilter:[`lang`]}));let xi=()=>{if(fe)return null;We&&(de?.cancelAnimationFrame?de.cancelAnimationFrame(We):clearTimeout(We),We=0),mr();let e=de?.devicePixelRatio||1,n=ue.createElement(`canvas`);n.width=Math.max(1,Math.round(Fe*e)),n.height=Math.max(1,Math.round(Ie*e));let r=n.getContext(`2d`);if(!r)return null;r.fillStyle=t.toCss(R.background),r.fillRect(0,0,n.width,n.height);try{r.drawImage(he,0,0),z&&r.drawImage(z.canvas,0,0,Math.round(F*e),Math.round(I*e)),r.drawImage(ge,0,0)}catch{}r.setTransform(e,0,0,e,0,0);let i=O.getBoundingClientRect(),a=de??null;return _e.querySelectorAll(`span, button`).forEach(e=>{let n=e.textContent??``;if(e.children.length||!n.trim()||!a)return;let o=e.getBoundingClientRect(),s=a.getComputedStyle(e);r.font=`${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,r.fillStyle=s.color||t.toCss(R.text),r.textAlign=`left`,r.textBaseline=`middle`,r.fillText(n,o.left-i.left,o.top-i.top+o.height/2)}),n},Si=!1,Ci=()=>{let e=ue.fullscreenElement===O;e!==Si&&(Si=e,O.style.background=e?t.toCss(R.background):``,q(`fullscreenChange`,e),$())};ue.addEventListener(`fullscreenchange`,Ci);let wi=async(t=new Set)=>{let n=++Ue,r=await i.createRenderer(D.renderer??`auto`,()=>e.createDataCanvas(ue),e=>{fe||z?.kind!==e||(z.destroy(),z.canvas.remove(),z=null,wi(new Set([...t,e])))},t);if(fe||n!==Ue){r?.destroy();return}z&&(z.destroy(),z.canvas.remove()),z=r,Ke=``,r&&(O.dataset.renderer=r.kind,O.insertBefore(r.canvas,ge),q(`renderer`,r.kind)),Ye(r?.kind??null),$()},Ti=()=>{let e=D.symbol??``;O.setAttribute(`aria-label`,D.ariaLabel??d.fill(Nt().chart,{symbol:e}).trim());let t=!!D.countdown&&D.lastPriceLine!==!1;t&&!Et&&(Et=setInterval($,1e3)),!t&&Et&&(clearInterval(Et),Et=null)},Ei=e=>{let t=D;Mt();let n=t.timeZone&&c.isTimeZone(t.timeZone)?t.timeZone:void 0,r=!!e&&(t.utcOffset!==e.utcOffset||n!==Xt);if(Xt=n,(!e||t.indicators!==e.indicators)&&un(),r)for(let e of M)Te.set(e,0);if((!e||t.compare!==e.compare)&&dn(),t.bars&&(!e||t.bars!==e.bars)?(K&&ri(!1),e?mn(t.bars):pn(t.bars)):!t.bars&&e?.bars&&(K&&ri(!1),pn([])),e&&t.barSpacing!==e.barSpacing&&t.barSpacing&&(N=t.barSpacing),e&&t.scaleMode!==e.scaleMode){let e=Le.get(y);e&&(e.auto=!0)}if(t.drawings&&t.drawings!==nt&&(!e||t.drawings!==e.drawings)&&(e?Er(t.drawings,!1):W=rt=t.drawings),e&&(t.drawingMode??`cursor`)!==(e.drawingMode??`cursor`)&&Sr(t.drawingMode??`cursor`,!1),e&&t.priceLines!==e.priceLines&&(_t.clear(),H?.kind===`move`)){let e=H.id,t=pi().find(t=>t.id===e);H=t?{kind:`move`,id:e,start:t.price,override:void 0}:null}t.orderEntry?O.setAttribute(`aria-keyshortcuts`,ae):(O.removeAttribute(`aria-keyshortcuts`),H&&hi(!0)),e&&t.chartStyle!==e.chartStyle&&(Ce=Math.min(Ce,0)),He++,Ti(),$()};Ei(null),wi();let Di=a.followDefaultRenderer(()=>D.renderer,()=>void wi()),Oi={setOptions(e){if(fe)return;let t=D;D={...e},Ei(t),(e.renderer??`auto`)!==(t.renderer??`auto`)&&wi()},setBars(e){K&&ri(!1),pn(e)},update(e){if(K){p.updateBar(K.source,e);return}let t=Y(),n=fn(),r=p.updateBar(j,e);r<0||(Y()>t&&n&&(P+=Y()-t),ln(r))},appendBars(e){if(K){p.appendBars(K.source,e);return}let t=Y(),n=fn(),r=p.appendBars(j,e);r<0||(n&&(P+=Y()-t),ln(r))},prependBars(e){K&&p.prependBars(K.source,e);let t=p.prependBars(j,e);t&&(xe=p.createPyramid(),we=p.createPyramid(),Ce=0,P+=t,V!==null&&(V+=t),ln(0))},getBarCount:()=>Y(),getBar:e=>e>=0&&e<Y()?p.readBar(j,Math.floor(e)):null,scrollToRealtime(e=!0){let t=Y()-1+(D.rightOffset??8);$e=null,e&&E(P)&&Math.abs(t-P)*N<F*6?et={from:P,to:t,start:typeof performance<`u`?performance.now():Date.now()}:P=t,$()},fitContent(){let e=Y();e&&Oi.setVisibleRange({from:-.5,to:e-1+(D.rightOffset??8)})},getVisibleRange:()=>gr(),setVisibleRange({from:e,to:t}){t>e&&($e=null,et=null,tt={from:e,to:t},yr(tt),$())},getVisibleTimeRange(){let e=gr();return{from:Jt(e.from),to:Jt(e.to)}},setVisibleTimeRange({from:e,to:t}){Y()&&t>e&&Oi.setVisibleRange({from:Yt(e),to:Yt(t)})},setCrosshair(e,t){Ct=e===null||!E(e)?null:{time:e,price:t??NaN},$()},setScaleMode(e){D={...D,scaleMode:e};let t=Le.get(y);t&&(t.auto=!0),$()},resetPriceScales(){for(let e of Le.values())e.auto=!0;$()},setDrawingTool:e=>Sr(e,!0),getDrawingTool:()=>st,getDrawings:()=>W,setDrawings(e){Er(e,!1)},removeDrawing:jr,updateDrawing:Ar,selectDrawing:e=>Cr(e),undo:Or,redo:kr,getUndoState:wr,startReplay(e){if(!Y()&&!K)return;if(e===void 0){K&&ri(!0),Dt=!0,Xr(),$();return}let t=K?K.source:j;ei(p.indexOfTime(t.time,t.length,e))},replayStep:(e=1)=>ti(Math.max(1,Math.floor(e))),replayPlay:e=>ni(e),replayPause(){K&&($r(),Xr())},stopReplay:()=>ri(!0),getReplayState:Yr,toDataURL(e=`image/png`,t){return xi()?.toDataURL(e,t)??``},toBlob(e=`image/png`,t){let n=xi();return new Promise(r=>{!n||typeof n.toBlob!=`function`?r(null):n.toBlob(r,e,t)})},async requestFullscreen(){typeof O.requestFullscreen==`function`&&await O.requestFullscreen()},async exitFullscreen(){ue.fullscreenElement===O&&typeof ue.exitFullscreen==`function`&&await ue.exitFullscreen()},isFullscreen:()=>ue.fullscreenElement===O,setIndicatorVisible(e,t){Ee.set(e,t),$()},getRenderer:()=>z?.kind??null,ready:Xe,refreshTheme:vi,resize:()=>$(),on(e,t){let n=At.get(e);return n||At.set(e,n=new Set),n.add(t),()=>n.delete(t)},destroy(){fe||(fe=!0,We&&(de?.cancelAnimationFrame?de.cancelAnimationFrame(We):clearTimeout(We)),Et&&clearInterval(Et),K?.timer&&clearInterval(K.timer),ue.removeEventListener(`fullscreenchange`,Ci),_i?.disconnect(),Di(),yi(),bi?.disconnect(),O.removeEventListener(`wheel`,li),z?.destroy(),z=null,Ye(null),At.clear(),O.remove())}};return ne.set(Oi,{setTimeRange(e){St=!0,Oi.setVisibleTimeRange(e)}}),Oi};exports.createTradingChart=ce,exports.syncHooks=ne;
|
|
2
2
|
//# sourceMappingURL=chart.cjs.map
|