import{_ as O}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{k as P,R,r as d,e as V,$ as v,Z as D,a0 as a,a9 as p,_ as m,S as o,l as H,v as I,a8 as L,ak as Z}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{n as j}from"./index-BTglIPU2.js?v=1773287522785";import{g as q}from"./data-BVsViUMm.js?v=1773287522785";import{a as z}from"./check-CNel7fTH.js?v=1773287522785";import{D as G,E as J,F as K}from"./firewall-jQIxKxfN.js?v=1773287522785";import{a1 as M,a6 as Q,_ as T,al as W}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";const X={class:"px-20px pt-24px pb-8px"},Y={class:"w-240px"},ee={class:"w-240px"},te={class:"w-240px"},oe={class:"w-240px"},ce=P({__name:"form",props:{row:{},isEdit:{type:Boolean,default:!1}},emits:["refresh"],setup(b,{expose:w,emit:h}){const g=b,S=h,{t:i}=R(),{isEdit:c,row:s}=g,y=d(null),e=V({types:"drop",choose:"all",ports:null,country:["United States"],is_update:!1}),F={country:{trigger:"change",validator:()=>e.country.length===0?new Error(i("Security.Firewall.Area.form_8")):!0},ports:{trigger:["blur","input"],validator:()=>{if(e.choose==="point"){if(!e.ports)return new Error(i("Security.Firewall.Area.form_9"));if(!z("".concat(e.ports)))return new Error(i("Security.Firewall.Area.form_10"))}return!0}}},k=[{label:i("Security.Firewall.Area.form_11"),value:"all"},{label:i("Security.Firewall.Area.form_3"),value:"point"}],A=[{label:i("Security.Firewall.Area.form_12"),value:"drop"}],f=d(!1),_=d([]),x=async()=>{try{f.value=!0;const{message:r}=await G();j(r)&&(_.value=r.map(t=>({label:t.CH,value:t.CH,brief:t.brief})))}finally{f.value=!1}},C=()=>{c&&s&&(e.types=s.types,e.choose=s.ports?"point":"all",e.ports=s.ports?q(s.ports):null,e.country=s.country)},$=()=>({types:e.types,choose:e.choose,ports:e.choose==="point"?"".concat(e.ports||""):"",country:e.country,brief:"",is_update:e.is_update}),E=async()=>{var t,u;await((t=y.value)==null?void 0:t.validate());const r=$();c&&s?(r.brief="".concat(((u=_.value.find(n=>n.label===s.country))==null?void 0:u.brief)||""),await J({...r,id:s.id})):await K(r),S("refresh")};return x(),C(),w({onConfirm:E}),(r,t)=>{const u=Q,n=M,U=T,B=W,N=O;return v(),D("div",X,[a(N,{ref_key:"formRef",ref:y,model:o(e),rules:F},{default:p(()=>[a(n,{label:r.$t("Security.Firewall.Area.form_1"),path:"types"},{default:p(()=>[m("div",Y,[a(u,{value:o(e).types,"onUpdate:value":t[0]||(t[0]=l=>o(e).types=l),options:A},null,8,["value"])])]),_:1},8,["label"]),a(n,{label:r.$t("Security.Firewall.Area.form_2"),path:"choose"},{default:p(()=>[m("div",ee,[a(u,{value:o(e).choose,"onUpdate:value":t[1]||(t[1]=l=>o(e).choose=l),options:k},null,8,["value"])])]),_:1},8,["label"]),H(a(n,{label:r.$t("Security.Firewall.Area.form_3"),path:"ports"},{default:p(()=>[m("div",te,[a(U,{value:o(e).ports,"onUpdate:value":t[2]||(t[2]=l=>o(e).ports=l),min:1,max:65535,"show-button":!1,placeholder:r.$t("Security.Firewall.Area.form_4")},null,8,["value","placeholder"])])]),_:1},8,["label"]),[[I,o(e).choose==="point"]]),a(n,{label:r.$t("Security.Firewall.Area.form_5"),path:"country"},{default:p(()=>[m("div",oe,[a(u,{value:o(e).country,"onUpdate:value":t[3]||(t[3]=l=>o(e).country=l),filterable:"","max-tag-count":"responsive",multiple:!o(c),loading:o(f),options:o(_)},null,8,["value","multiple","loading","options"])])]),_:1},8,["label"]),o(c)?Z("",!0):(v(),L(n,{key:0,label:" "},{default:p(()=>[a(B,{checked:o(e).is_update,"onUpdate:checked":t[4]||(t[4]=l=>o(e).is_update=l),label:"Update IP Pool"},null,8,["checked"])]),_:1}))]),_:1},8,["model"])])}}});export{ce as default};
