import{c as e,r as a,q as l,H as t,v as o,N as s,B as r,e as u,y as i,x as d,b0 as p,F as m,D as n,I as c,C as f,z as y,ak as b,al as _,ab as g,U as v,a9 as V}from"./base-lib.js?v=1761009159";import{X as D,P as h,k}from"./utils-lib.js?v=1761009159";import{b0 as j,b1 as w,b2 as x}from"./firewall.js?v=1761009159";import{a as U,g as C}from"./useMethod6.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./useStore5.js?v=1761009159";import"./validator.js?v=1761009159";const H={class:"mt-20px leading-8 text-small list-disc ml-24px"},I={key:0},P=e({__name:"add-area-rule",props:{compData:{default:()=>{}}},setup(e,{expose:P}){const q=e,E=a(),A=a(!1),F=a([]),N=a({country:["美国"],brief:"",types:"drop",ports:"",choose:"all",is_update:!1}),O=[{title:"所有端口",key:"all"},{title:"指定端口",key:"point"}],R={country:[{required:!0,message:"请选择国家或地区",trigger:"change"}],ports:[{validator:(e,a,l)=>{a.length>0&&(D(a)||l(new Error("端口格式错误，可用范围：1-65535")),l()),l(new Error("请输入源端口"))},trigger:["input"]}]};return l(()=>{if((async()=>{await h({loading:A,request:x(),data:[Array,F]})})(),q.compData.isEdit){const e=q.compData;Object.assign(N.value,{country:e.country,brief:e.brief,types:e.types,ports:e.ports,choose:e.ports?"point":"all"})}}),P({onConfirm:async e=>{await E.value.validate();let a={...N.value};const l=q.compData.isEdit;l&&(a.id=q.compData.id,a.addtime=q.compData.addtime,a.country=N.value.country,a.brief=F.value.find(e=>e.CH===N.value.country).brief),"all"===N.value.choose&&(a.ports=""),a={data:JSON.stringify(a)},await h({loading:"正在设置规则，请稍后...",request:l?j(a):w(a),message:!0}),e(),q.compData.refreshFn(),U(),C()}}),(e,a)=>{const l=b,D=_,h=g,j=k,w=v,x=V,U=t("bt-loading");return o(),s(x,{ref_key:"editAreaRulesRef",ref:E,model:i(N),rules:R,class:"p-[2rem] addfrom"},{default:r(()=>[u(h,{label:"策略"},{default:r(()=>[u(D,{modelValue:i(N).types,"onUpdate:modelValue":a[0]||(a[0]=e=>i(N).types=e),class:"!w-[24rem]"},{default:r(()=>[u(l,{label:"屏蔽",value:"drop"})]),_:1},8,["modelValue"])]),_:1}),u(h,{label:"端口"},{default:r(()=>[u(D,{modelValue:i(N).choose,"onUpdate:modelValue":a[1]||(a[1]=e=>i(N).choose=e),class:"!w-[24rem]"},{default:r(()=>[(o(),d(m,null,p(O,e=>u(l,{key:e.key,label:e.title,value:e.key},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1}),"point"===i(N).choose?(o(),s(h,{key:0,label:"指定端口",prop:"ports"},{default:r(()=>[u(j,{modelValue:i(N).ports,"onUpdate:modelValue":a[2]||(a[2]=e=>i(N).ports=e),type:"number",min:"1",max:"65535",width:"24rem",placeholder:"请输入指定端口"},null,8,["modelValue"])]),_:1})):n("",!0),u(h,{label:"地区",prop:"country"},{default:r(()=>[c((o(),s(D,{modelValue:i(N).country,"onUpdate:modelValue":a[3]||(a[3]=e=>i(N).country=e),class:"!w-[24rem]",multiple:!e.compData.id,filterable:!e.compData.id,"collapse-tags":!e.compData.id},{default:r(()=>[(o(!0),d(m,null,p(i(F),e=>(o(),s(l,{key:e.brief,label:e.CH,value:e.CH},null,8,["label","value"]))),128))]),_:1},8,["modelValue","multiple","filterable","collapse-tags"])),[[U,i(A)]])]),_:1}),e.compData.id?n("",!0):(o(),s(h,{key:1,label:" "},{default:r(()=>[u(w,{modelValue:i(N).is_update,"onUpdate:modelValue":a[4]||(a[4]=e=>i(N).is_update=e)},{default:r(()=>a[5]||(a[5]=[f("更新IP池",-1)])),_:1,__:[5]},8,["modelValue"])]),_:1})),y("ul",H,[a[6]||(a[6]=y("li",null,"地区规则中IP数量较多，添加时可能耗时较长",-1)),e.compData.id?n("",!0):(o(),d("li",I,"勾选【更新IP池】会从云端获取指定地区近1个月最新的IP池")),a[7]||(a[7]=y("li",null,"添加【除中国之外】或多个地区时，可能会导致系统防火墙占用高，添加完成后会恢复",-1)),a[8]||(a[8]=y("li",null,"此操作将重载防火墙，未持久化的 iptables 规则会清空，请先备份保存！",-1))])]),_:1},8,["model"])}}});export{P as default};
