{"version":3,"file":"vue-chartjs-vmceop_p.js","sources":["../../../node_modules/vue-chartjs/dist/index.js"],"sourcesContent":["import { Chart as Chart$1, BarController, DoughnutController, LineController, PieController, PolarAreaController, RadarController, BubbleController, ScatterController } from 'chart.js';\nimport { version, isProxy, toRaw, defineComponent, ref, shallowRef, onMounted, onUnmounted, watch, nextTick, h } from 'vue';\n\nconst CommonProps = {\n data: {\n type: Object,\n required: true\n },\n options: {\n type: Object,\n default: ()=>({})\n },\n plugins: {\n type: Array,\n default: ()=>[]\n },\n datasetIdKey: {\n type: String,\n default: \"label\"\n },\n updateMode: {\n type: String,\n default: undefined\n }\n};\nconst A11yProps = {\n ariaLabel: {\n type: String\n },\n ariaDescribedby: {\n type: String\n }\n};\nconst Props = {\n type: {\n type: String,\n required: true\n },\n destroyDelay: {\n type: Number,\n default: 0 // No delay by default\n },\n ...CommonProps,\n ...A11yProps\n};\n\nconst compatProps = version[0] === \"2\" ? (internals, props)=>Object.assign(internals, {\n attrs: props\n }) : (internals, props)=>Object.assign(internals, props);\nfunction toRawIfProxy(obj) {\n return isProxy(obj) ? toRaw(obj) : obj;\n}\nfunction cloneProxy(obj) {\n let src = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : obj;\n return isProxy(src) ? new Proxy(obj, {}) : obj;\n}\nfunction setOptions(chart, nextOptions) {\n const options = chart.options;\n if (options && nextOptions) {\n Object.assign(options, nextOptions);\n }\n}\nfunction setLabels(currentData, nextLabels) {\n currentData.labels = nextLabels;\n}\nfunction setDatasets(currentData, nextDatasets, datasetIdKey) {\n const addedDatasets = [];\n currentData.datasets = nextDatasets.map((nextDataset)=>{\n // given the new set, find it's current match\n const currentDataset = currentData.datasets.find((dataset)=>dataset[datasetIdKey] === nextDataset[datasetIdKey]);\n // There is no original to update, so simply add new one\n if (!currentDataset || !nextDataset.data || addedDatasets.includes(currentDataset)) {\n return {\n ...nextDataset\n };\n }\n addedDatasets.push(currentDataset);\n Object.assign(currentDataset, nextDataset);\n return currentDataset;\n });\n}\nfunction cloneData(data, datasetIdKey) {\n const nextData = {\n labels: [],\n datasets: []\n };\n setLabels(nextData, data.labels);\n setDatasets(nextData, data.datasets, datasetIdKey);\n return nextData;\n}\n/**\n * Get dataset from mouse click event\n * @param chart - Chart.js instance\n * @param event - Mouse click event\n * @returns Dataset\n */ function getDatasetAtEvent(chart, event) {\n return chart.getElementsAtEventForMode(event, \"dataset\", {\n intersect: true\n }, false);\n}\n/**\n * Get single dataset element from mouse click event\n * @param chart - Chart.js instance\n * @param event - Mouse click event\n * @returns Dataset\n */ function getElementAtEvent(chart, event) {\n return chart.getElementsAtEventForMode(event, \"nearest\", {\n intersect: true\n }, false);\n}\n/**\n * Get all dataset elements from mouse click event\n * @param chart - Chart.js instance\n * @param event - Mouse click event\n * @returns Dataset\n */ function getElementsAtEvent(chart, event) {\n return chart.getElementsAtEventForMode(event, \"index\", {\n intersect: true\n }, false);\n}\n\nconst Chart = defineComponent({\n props: Props,\n setup (props, param) {\n let { expose , slots } = param;\n const canvasRef = ref(null);\n const chartRef = shallowRef(null);\n expose({\n chart: chartRef\n });\n const renderChart = ()=>{\n if (!canvasRef.value) return;\n const { type , data , options , plugins , datasetIdKey } = props;\n const clonedData = cloneData(data, datasetIdKey);\n const proxiedData = cloneProxy(clonedData, data);\n chartRef.value = new Chart$1(canvasRef.value, {\n type,\n data: proxiedData,\n options: {\n ...options\n },\n plugins\n });\n };\n const destroyChart = ()=>{\n const chart = toRaw(chartRef.value);\n if (chart) {\n if (props.destroyDelay > 0) {\n setTimeout(()=>{\n chart.destroy();\n chartRef.value = null;\n }, props.destroyDelay);\n } else {\n chart.destroy();\n chartRef.value = null;\n }\n }\n };\n const update = (chart)=>{\n chart.update(props.updateMode);\n };\n onMounted(renderChart);\n onUnmounted(destroyChart);\n watch([\n ()=>props.options,\n ()=>props.data\n ], (param, param1)=>{\n let [nextOptionsProxy, nextDataProxy] = param, [prevOptionsProxy, prevDataProxy] = param1;\n const chart = toRaw(chartRef.value);\n if (!chart) {\n return;\n }\n let shouldUpdate = false;\n if (nextOptionsProxy) {\n const nextOptions = toRawIfProxy(nextOptionsProxy);\n const prevOptions = toRawIfProxy(prevOptionsProxy);\n if (nextOptions && nextOptions !== prevOptions) {\n setOptions(chart, nextOptions);\n shouldUpdate = true;\n }\n }\n if (nextDataProxy) {\n const nextLabels = toRawIfProxy(nextDataProxy.labels);\n const prevLabels = toRawIfProxy(prevDataProxy.labels);\n const nextDatasets = toRawIfProxy(nextDataProxy.datasets);\n const prevDatasets = toRawIfProxy(prevDataProxy.datasets);\n if (nextLabels !== prevLabels) {\n setLabels(chart.config.data, nextLabels);\n shouldUpdate = true;\n }\n if (nextDatasets && nextDatasets !== prevDatasets) {\n setDatasets(chart.config.data, nextDatasets, props.datasetIdKey);\n shouldUpdate = true;\n }\n }\n if (shouldUpdate) {\n nextTick(()=>{\n update(chart);\n });\n }\n }, {\n deep: true\n });\n return ()=>{\n return h(\"canvas\", {\n role: \"img\",\n ariaLabel: props.ariaLabel,\n ariaDescribedby: props.ariaDescribedby,\n ref: canvasRef\n }, [\n h(\"p\", {}, [\n slots.default ? slots.default() : \"\"\n ])\n ]);\n };\n }\n});\n\nfunction createTypedChart(type, registerables) {\n Chart$1.register(registerables);\n return defineComponent({\n props: CommonProps,\n setup (props, param) {\n let { expose } = param;\n const ref = shallowRef(null);\n const reforwardRef = (chartRef)=>{\n ref.value = chartRef?.chart;\n };\n expose({\n chart: ref\n });\n return ()=>{\n return h(Chart, compatProps({\n ref: reforwardRef\n }, {\n type,\n ...props\n }));\n };\n }\n });\n}\nconst Bar = /* #__PURE__ */ createTypedChart(\"bar\", BarController);\nconst Doughnut = /* #__PURE__ */ createTypedChart(\"doughnut\", DoughnutController);\nconst Line = /* #__PURE__ */ createTypedChart(\"line\", LineController);\nconst Pie = /* #__PURE__ */ createTypedChart(\"pie\", PieController);\nconst PolarArea = /* #__PURE__ */ createTypedChart(\"polarArea\", PolarAreaController);\nconst Radar = /* #__PURE__ */ createTypedChart(\"radar\", RadarController);\nconst Bubble = /* #__PURE__ */ createTypedChart(\"bubble\", BubbleController);\nconst Scatter = /* #__PURE__ */ createTypedChart(\"scatter\", ScatterController);\n\nexport { Bar, Bubble, Chart, Doughnut, Line, Pie, PolarArea, Radar, Scatter, createTypedChart, getDatasetAtEvent, getElementAtEvent, getElementsAtEvent };\n//# sourceMappingURL=index.js.map\n"],"names":["CommonProps","A11yProps","Props","compatProps","version","internals","props","toRawIfProxy","obj","isProxy","toRaw","cloneProxy","src","setOptions","chart","nextOptions","options","setLabels","currentData","nextLabels","setDatasets","nextDatasets","datasetIdKey","addedDatasets","nextDataset","currentDataset","dataset","cloneData","data","nextData","Chart","defineComponent","param","expose","slots","canvasRef","ref","chartRef","shallowRef","renderChart","type","plugins","clonedData","proxiedData","Chart$1","destroyChart","update","onMounted","onUnmounted","watch","param1","nextOptionsProxy","nextDataProxy","prevOptionsProxy","prevDataProxy","shouldUpdate","prevOptions","prevLabels","prevDatasets","nextTick","h","createTypedChart","registerables","reforwardRef","Bar","BarController","Pie","PieController"],"mappings":"qKAGA,MAAMA,EAAc,CAChB,KAAM,CACF,KAAM,OACN,SAAU,EACb,EACD,QAAS,CACL,KAAM,OACN,QAAS,KAAK,CAAA,EACjB,EACD,QAAS,CACL,KAAM,MACN,QAAS,IAAI,CAAE,CAClB,EACD,aAAc,CACV,KAAM,OACN,QAAS,OACZ,EACD,WAAY,CACR,KAAM,OACN,QAAS,MACZ,CACL,EACMC,EAAY,CACd,UAAW,CACP,KAAM,MACT,EACD,gBAAiB,CACb,KAAM,MACT,CACL,EACMC,EAAQ,CACV,KAAM,CACF,KAAM,OACN,SAAU,EACb,EACD,aAAc,CACV,KAAM,OACN,QAAS,CACZ,EACD,GAAGF,EACH,GAAGC,CACP,EAEME,EAAcC,EAAQ,CAAC,IAAM,IAAM,CAACC,EAAWC,IAAQ,OAAO,OAAOD,EAAW,CAC9E,MAAOC,CACf,CAAK,EAAI,CAACD,EAAWC,IAAQ,OAAO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