import{M as e,P as a,j as l}from"./utils-lib.js?v=1761009159";import{c as s,r as t,o,v as n,x as u,e as r,B as p,I as i,y as c,G as f,b3 as d,J as m,C as _,z as y,F as w,b0 as v,al as b,ak as h}from"./base-lib.js?v=1761009159";import{x as k,y as x}from"./firewall.js?v=1761009159";const g=s({__name:"index",emits:["upload-success"],setup(a,{expose:l,emit:s}){const _=s,y={"x-http-token":window.vite_public_request_token},w=window.location.protocol+"//"+window.location.host+"/files?action=upload",v=t([]),b=t(null),h=t(null),k=[".json"].join(","),x=o({f_size:0,f_path:"/www/server/panel/data/firewall",f_name:"",f_start:0}),g=()=>{_("upload-success")},P=()=>{e.error("导入失败")},U=e=>{e.value=e,x.f_size=e.size,x.f_name=e.name,x.f_start=0},j=(e,a)=>{v.value=a},L=(e,a,l)=>{x.f_start=e.percent,v.value=l.map(l=>(l.uid===a.uid&&(l.percentage=e.percent),l))};return l({onConfirm:()=>b.value.submit(),open:()=>h.value.$el.click(),fileData:x}),(e,a)=>{const l=f,s=d;return n(),u("div",null,[r(s,{class:"upload-demo",ref_key:"uploadRef",ref:b,name:"blob",data:c(x),action:w,headers:y,accept:c(k),"on-error":P,multiple:!1,"show-file-list":!1,"auto-upload":!0,"on-success":g,"on-progress":L,"file-list":c(v),"on-change":j,"before-upload":U},{default:p(()=>[i(r(l,{ref_key:"uploadButtonRef",ref:h,size:"small",type:"primary"},null,512),[[m,!1]])]),_:1},8,["data","accept","file-list"])])}}}),P={class:"mx-8px inline-block"},U={class:"p-20px flex items-center"},j=s({__name:"index",props:{type:{default:"ALL"},refreshFn:{type:Function,default:()=>{}}},setup(s){const i=s,d=t(null),m=o({showPopup:!1,type:"ALL"}),j=[{label:"所有方向",value:"ALL"},{label:"入站",value:"INPUT"},{label:"出站",value:"OUTPUT"}],L=()=>{d.value.open()},V=async()=>{"port"!==i.type&&"ip"!==i.type?z():m.showPopup=!0},z=async l=>{let s={rule:i.type};l&&(s={...s,chain:l}),"country_rule"===i.type&&(s={rule_name:i.type});const t=await a({loading:"正在导出中，请稍后...",request:k(s),data:{status:Boolean,msg:String}});t.status?window.open("/download?filename="+t.msg):e.request(t)},C=async()=>{m.showPopup=!1,z(m.type)},q=async()=>{const e=d.value.fileData.f_name,l=d.value.fileData.f_path;let s={};s="country_rule"===i.type?{rule_name:i.type,file_name:e}:{rule:i.type,file:l+"/"+e},await a({loading:"正在导入中，请稍后...",request:x(s),message:!0}),i.refreshFn()};return(e,a)=>{const s=f,t=h,o=b,i=l;return n(),u("div",P,[r(s,{onClick:L},{default:p(()=>a[2]||(a[2]=[_("导入规则",-1)])),_:1,__:[2]}),r(s,{onClick:V},{default:p(()=>a[3]||(a[3]=[_("导出规则",-1)])),_:1,__:[3]}),r(g,{ref_key:"fileUploadRef",ref:d,onUploadSuccess:q,class:"w-0 h-0"},null,512),r(i,{title:"导出规则","show-footer":"",modelValue:c(m).showPopup,"onUpdate:modelValue":a[1]||(a[1]=e=>c(m).showPopup=e),area:42,onConfirm:C},{default:p(()=>[y("div",U,[a[4]||(a[4]=y("div",{class:"inline-block mr-[2rem]"},"导出方向",-1)),r(o,{modelValue:c(m).type,"onUpdate:modelValue":a[0]||(a[0]=e=>c(m).type=e),class:"!w-[30rem]",placeholder:"请选择导出方向"},{default:p(()=>[(n(),u(w,null,v(j,e=>r(t,{key:e.value,label:e.label,value:e.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])])]),_:1},8,["modelValue"])])}}});export{j as _};
