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