import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1753954525509";import{k as a,P as l,r,e as t,U as o,V as s,Q as i,a2 as u,W as p,X as n,l as c,v as d,a1 as f,al as m}from"./vue.js?v=1753954525509";import{aP as y,f$ as v,w as _,k as w,g0 as b,g1 as h}from"./page_layout.js?v=1753954525509";import{cG as g,cA as x,c1 as A,_ as S}from"./naive.js?v=1753954525509";import"./__commonjsHelpers__.js?v=1753954525509";import"./common.js?v=1753954525509";import"./public.js?v=1753954525509";const F={class:"px-20px pt-24px pb-8px"},j={class:"w-240px"},U={class:"w-240px"},k={class:"w-240px"},$={class:"w-240px"},E=a({__name:"form",props:{row:{},isEdit:{type:Boolean,default:!1}},emits:["refresh"],setup(a,{expose:E,emit:P}){const C=a,H=P,{t:B}=l(),{isEdit:G,row:I}=C,Q=r(null),R=t({types:"drop",choose:"all",ports:null,country:["United States"],is_update:!1}),V={country:{trigger:"change",validator:()=>0!==R.country.length||new Error(B("Security.Firewall.Area.form_8"))},ports:{trigger:["blur","input"],validator:()=>{if("point"===R.choose){if(!R.ports)return new Error(B("Security.Firewall.Area.form_9"));if(!y("".concat(R.ports)))return new Error(B("Security.Firewall.Area.form_10"))}return!0}}},W=[{label:B("Security.Firewall.Area.form_11"),value:"all"},{label:B("Security.Firewall.Area.form_3"),value:"point"}],X=[{label:B("Security.Firewall.Area.form_12"),value:"drop"}],q=r(!1),z=r([]);return(async()=>{try{q.value=!0;const{message:e}=await v();_(e)&&(z.value=e.map((e=>({label:e.CH,value:e.CH,brief:e.brief}))))}finally{q.value=!1}})(),G&&I&&(R.types=I.types,R.choose=I.ports?"point":"all",R.ports=I.ports?w(I.ports):null,R.country=I.country),E({onConfirm:async()=>{var e,a;await(null==(e=Q.value)?void 0:e.validate());const l={types:R.types,choose:R.choose,ports:"point"===R.choose?"".concat(R.ports||""):"",country:R.country,brief:"",is_update:R.is_update};G&&I?(l.brief="".concat((null==(a=z.value.find((e=>e.label===I.country)))?void 0:a.brief)||""),await b({...l,id:I.id})):await h(l),H("refresh")}}),(a,l)=>{const r=g,t=x,y=A,v=S,_=e;return o(),s("div",F,[i(_,{ref_key:"formRef",ref:Q,model:n(R),rules:V},{default:u((()=>[i(t,{label:a.$t("Security.Firewall.Area.form_1"),path:"types"},{default:u((()=>[p("div",j,[i(r,{value:n(R).types,"onUpdate:value":l[0]||(l[0]=e=>n(R).types=e),options:X},null,8,["value"])])])),_:1},8,["label"]),i(t,{label:a.$t("Security.Firewall.Area.form_2"),path:"choose"},{default:u((()=>[p("div",U,[i(r,{value:n(R).choose,"onUpdate:value":l[1]||(l[1]=e=>n(R).choose=e),options:W},null,8,["value"])])])),_:1},8,["label"]),c(i(t,{label:a.$t("Security.Firewall.Area.form_3"),path:"ports"},{default:u((()=>[p("div",k,[i(y,{value:n(R).ports,"onUpdate:value":l[2]||(l[2]=e=>n(R).ports=e),min:1,max:65535,"show-button":!1,placeholder:a.$t("Security.Firewall.Area.form_4")},null,8,["value","placeholder"])])])),_:1},8,["label"]),[[d,"point"===n(R).choose]]),i(t,{label:a.$t("Security.Firewall.Area.form_5"),path:"country"},{default:u((()=>[p("div",$,[i(r,{value:n(R).country,"onUpdate:value":l[3]||(l[3]=e=>n(R).country=e),filterable:"","max-tag-count":"responsive",multiple:!n(G),loading:n(q),options:n(z)},null,8,["value","multiple","loading","options"])])])),_:1},8,["label"]),n(G)?m("",!0):(o(),f(t,{key:0,label:" "},{default:u((()=>[i(v,{checked:n(R).is_update,"onUpdate:checked":l[4]||(l[4]=e=>n(R).is_update=e),label:"Update IP Pool"},null,8,["checked"])])),_:1}))])),_:1},8,["model"])])}}});export{E as default};
