import x from"./mCard.49b5181b.js";import{X as I}from"./index.ad3efb29.js";import{d as M,r as m,k,E as C,w as f,o as u,c as d,F as V,a8 as B,M as y}from"./vue.adf17aba.js";import{_ as E}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.05a2d588.js";import"./elementPlus.4833989a.js";import"./echarts.72dc8373.js";const U={class:"metrics-cards"},F=M({__name:"index",props:{modelValue:{},metricItems:{}},emits:["change","update:modelValue"],setup(v,{emit:p}){const n={},c=v,r=p,l=m(c.modelValue),s=m([]),i=k(()=>{const e={};for(const o of c.metricItems)e[o.value]=o.label;return e});C(()=>{const e={};for(const o of l.value)s.value.push({metric:o.metric,color:o.color}),e[o.metric]=!0,o.color&&(n[o.color]=!0)});const _=()=>{for(const[e,o]of Object.entries(n))if(!o)return n[e]=!0,e;return""},h=e=>{I.has(n,e)&&(n[e]=!1)},g=(e,o)=>{for(const a of c.metricItems)a.value===e?a.disabled=!0:a.value===o&&(a.disabled=!1);const t=l.value.findIndex(a=>a.metric===o);t>-1&&(l.value[t].metric=e,l.value[t].label=i.value[e],r("update:modelValue",l.value),r("change",l.value))},b=e=>{const o=l.value.findIndex(t=>t.metric===e);if(o>-1){if(l.value.length<=1)return;const t=l.value[o];l.value.splice(o,1),h(t.color),r("update:modelValue",l.value),r("change",l.value)}else{if(l.value.length===3)l.value[2].metric=e,l.value[2].label=i.value[e];else{const t=_();l.value.push({metric:e,color:t,label:i.value[e]})}r("update:modelValue",l.value),r("change",l.value)}};return f(l.value,()=>{const e={};for(const o of l.value)e[o.metric]=o.color;for(const o of s.value){const t=e[o.metric];t?o.color=t:o.color=void 0}}),f(c.metricItems,()=>{const e={};for(const t of s.value)e[t.metric]=!0;let o=6-s.value.length;if(o>0){for(const t of c.metricItems)if(!e[t.value]&&(s.value.push({metric:t.value}),e[t.value]=!0,o--,o===0))break}for(const t of c.metricItems)e[t.value]?t.disabled=!0:t.disabled=!1}),(e,o)=>(u(),d("div",U,[(u(!0),d(V,null,B(s.value,t=>(u(),y(x,{modelValue:t.metric,"onUpdate:modelValue":a=>t.metric=a,"metric-items":c.metricItems,color:t.color,onChangeMetric:g,onClick:a=>b(t.metric)},null,8,["modelValue","onUpdate:modelValue","metric-items","color","onClick"]))),256))]))}});const w=E(F,[["__scopeId","data-v-f14f8593"]]);export{w as default};
