import{d as D,r as y,k as f,a9 as g,o as m,E as h,G as T,a as v,A as w,M as N,L as b,H as F,N as L,z as x,v as X,w as U,c as z,F as j,a0 as A}from"./vue.65d9dadc.js";import{T as G}from"./index.4dc9403e.js";import{_ as E}from"./_plugin-vue_export-helper.c27b6911.js";import{X as H}from"./index.373e4c1e.js";const O={class:"metric-value"},q={class:"metric-pre"},J=D({name:"MCard",__name:"mCard",props:{modelValue:{},metricItems:{},color:{}},emits:["update:modelValue","change-metric"],setup(V,{emit:C}){const c=V,n=C,u=y(c.modelValue),l=(a,i)=>{n("update:modelValue",a),n("change-metric",a,i)},s=f(()=>{const a=c.metricItems.find(i=>i.value===u.value);return a||null}),d=f(()=>{const a={"border-top-color":"rgb(232, 244, 255)"};return c.color&&(a["border-top-color"]=c.color),a}),_=f(()=>{var a;return(((a=s.value)==null?void 0:a.gapVal)??-1)>0}),p=f(()=>_.value?"green":"red");return(a,i)=>{const e=g("Top"),o=g("Bottom"),t=g("el-icon"),r=g("el-card");return m(),h(r,{class:"metric-card"},{default:T(()=>{var I,M,k,B,S;return[v("div",{class:"metric-card__color",style:w(d.value)},null,4),N(G,{modelValue:u.value,"onUpdate:modelValue":i[0]||(i[0]=$=>u.value=$),options:c.metricItems,onChange:l},null,8,["modelValue","options"]),v("div",O,b((I=s.value)==null?void 0:I.metricVal),1),v("div",q,[v("span",null,b((M=s.value)==null?void 0:M.preVal)+"  ",1),F(N(t,{style:{display:"inline-block","padding-top":"2px"}},{default:T(()=>[_.value?(m(),h(e,{key:0,class:x(p.value)},null,8,["class"])):(m(),h(o,{key:1,class:x(p.value)},null,8,["class"]))]),_:1},512),[[L,(k=s.value)==null?void 0:k.gapVal]]),v("span",{class:x(p.value)},b((B=s.value)!=null&&B.gapVal?((S=s.value)==null?void 0:S.gapVal)+"%":""),3)])]}),_:1})}}});const K=E(J,[["__scopeId","data-v-08c63995"]]),P={class:"metrics-cards"},Q=D({__name:"index",props:{modelValue:{},metricItems:{}},emits:["change","update:modelValue"],setup(V,{emit:C}){const c={},n=V,u=C,l=y(n.modelValue),s=y([]),d=f(()=>{const e={};for(const o of n.metricItems)e[o.value]=o.label;return e});X(()=>{const e={};for(const o of l.value)s.value.push({metric:o.metric,color:o.color}),e[o.metric]=!0,o.color&&(c[o.color]=!0)});const _=()=>{for(const[e,o]of Object.entries(c))if(!o)return c[e]=!0,e;return""},p=e=>{H.has(c,e)&&(c[e]=!1)},a=(e,o)=>{for(const r of n.metricItems)r.value===e?r.disabled=!0:r.value===o&&(r.disabled=!1);const t=l.value.findIndex(r=>r.metric===o);t>-1&&(l.value[t].metric=e,l.value[t].label=d.value[e],u("update:modelValue",l.value),u("change",l.value))},i=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),p(t.color),u("update:modelValue",l.value),u("change",l.value)}else{if(l.value.length===3)l.value[2].metric=e,l.value[2].label=d.value[e];else{const t=_();l.value.push({metric:e,color:t,label:d.value[e]})}u("update:modelValue",l.value),u("change",l.value)}};return U(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}}),U(n.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 n.metricItems)if(!e[t.value]&&(s.value.push({metric:t.value}),e[t.value]=!0,o--,o===0))break}for(const t of n.metricItems)e[t.value]?t.disabled=!0:t.disabled=!1}),(e,o)=>(m(),z("div",P,[(m(!0),z(j,null,A(s.value,t=>(m(),h(K,{modelValue:t.metric,"onUpdate:modelValue":r=>t.metric=r,"metric-items":n.metricItems,color:t.color,onChangeMetric:a,onClick:r=>i(t.metric)},null,8,["modelValue","onUpdate:modelValue","metric-items","color","onClick"]))),256))]))}});const ee=E(Q,[["__scopeId","data-v-3a3260d4"]]);export{ee as M};
