import{u as e,l as t,M as a,ah as l}from"./utils-lib.js?v=20260328163632";import{k as i,ao as s,r as n,ap as o,x as u,o as r,c as p,w as d,l as m,Y as c,V as v,_ as y,O as f,U as h}from"./base-lib.js?v=20260328163632";import{aB as g,n as b}from"./naive-ui.js?v=20260328163632";const w=i({__name:"index",props:s({multiple:{type:Boolean,default:()=>!0},limit:{default:()=>[]},isDefault:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:s(["change"],["update:modelValue"]),setup(i,{expose:s,emit:w}){const{getSenderAlarmListInfo:x,push:k}=e(),j=i,A=n(!1),_=o(i,"modelValue"),C=w,O=u([]),V=(e,t)=>{C("change",e,t)},B=[{title:t("钉钉"),type:"dingding"},{title:t("飞书"),type:"feishu"},{title:t("邮箱"),type:"mail"},{title:t("企业微信"),type:"weixin"},{title:t("微信公众号"),type:"wx_account"},{title:t("短信通知"),type:"sms"},{title:t("自定义消息通道"),type:"webhook"}],D=e=>f(g,{closable:!0,onMousedown:e=>{e.preventDefault()},onClose:t=>{t.stopPropagation(),e.handleClose()}},{default:()=>[e.option.title]}),E=async()=>{try{const e=[...B];A.value=!0,await x(),O.value=[];const a=[];Object.keys(k.value.config).forEach((e=>{const l=k.value.config[e];j.limit.includes(e)||("sms"===e&&(l.data.list={sms:l.data}),l.data&&l.data.list&&Object.keys(l.data.list).length&&(a.push(e),Object.keys(l.data.list).forEach((a=>{var i,s;const n=l.data.list[a];let o=a+((null==(i=null==l?void 0:l.info)?void 0:i.title)?" (".concat(null==(s=null==l?void 0:l.info)?void 0:s.title,")"):"");"sms"===e&&(o=t("短信通知 ({0}) 条",[(null==n?void 0:n.count)||0])),O.value.push({class:"alarm-item",title:o,value:e+"_"+a,user:a,disabled:!1,type:e,label:()=>f("div",{class:"flex justify-between"},[f("span",{class:"mr-[var(--margin-r-10)]"},[o]),f("span",{class:"hover:text-primary cursor-pointer mr-[var(--margin-r-4)]"},[f("span",{onClick:t=>{t.stopPropagation(),M({title:o,data:n,name:e,setup:!0,isSetAlarm:!0})}},["sms"!==e?"["+t("已配置")+"]":""])])])})}))))}));e.filter((e=>!a.some((t=>t===e.type))&&!j.limit.includes(e.type))).forEach((e=>{O.value.push({class:"alarm-item",value:e.title,title:e.title,type:e.type,disabled:!0,label:()=>f("div",{class:"flex justify-between"},[f("span",{class:"mr-[var(--margin-r-10)]"},[e.title]),f("span",{class:"bt-danger mr-[var(--margin-r-4)]",onClick:t=>{t.stopPropagation(),M({...e,setup:!1,name:e.type,data:{},isSetAlarm:!1})}},["sms"!==e.type?"["+t("未配置")+"]":""])])})}));const l=Array.isArray(_.value)?!_.value.length:!_.value;if(j.isDefault&&l){const e=O.value.filter((e=>!e.disabled));e.length&&(_.value=j.multiple?[e[0].value]:e[0].value)}}catch(e){}finally{A.value=!1}},M=async e=>{const i=[{title:t("钉钉机器人配置"),type:"dingding"},{title:t("飞书机器人配置"),type:"feishu"},{title:t("邮箱配置"),type:"mail"},{title:t("企业微信机器人配置"),type:"weixin"},{title:t("微信公众号"),type:"wx_account"},{title:t("自定义消息通道"),type:"webhook"},{title:t("短信通知"),type:"sms"}].find((t=>t.type===e.name))||{title:"",type:"",data:{}};if("webhook"===e.name)return a.warn(t("暂不支持该功能！"));l({...i,data:e,callback:E})};s({refresh:E}),r(E);const P=p((()=>{var e;return(null==(e=j.limit)?void 0:e.length)?O.value.filter((e=>!j.limit.includes(e.type))):O.value}));return d((()=>j.limit),(e=>{if((null==e?void 0:e.length)&&_.value)if(Array.isArray(_.value)){const e=P.value.map((e=>e.value));_.value=_.value.filter((t=>e.includes(t)))}else P.value.some((e=>e.value===_.value))||(_.value="")}),{deep:!0}),(e,a)=>{const l=h("bt-loading");return m((v(),y(c(b),{value:_.value,"onUpdate:value":[a[0]||(a[0]=e=>_.value=e),V],multiple:e.multiple,"render-tag":D,options:c(P),placeholder:c(t)("请选择告警方式")},null,8,["value","multiple","options","placeholder"])),[[l,c(A)]])}}});export{w as _};
