import{aa as J,r as i,J as q,ak as G,o as u,g as d,d as H,e as K,u as o,a,F as y,D as V,c as v,w as n,f as r,t as P,i as T,b as f,L as O,h as c,bb as $}from"./app-DnroACXc.js";import{T as Q}from"./app-B8VsrFxM.js";import{a as p,_ as A}from"./app-DntYVxd7.js";import{T as X}from"./app-LqsmzyUT.js";import{P as Y}from"./app-z7Z_Uo-k.js";const Z={class:"label-group"},ee=["name","value"],te=["onClick"],oe=a("i",{class:"icon remove small"},null,-1),le=[oe],ue={key:0,style:{"margin-bottom":"1em"}},ae={class:"ui table definition"},ne=a("td",{class:"title"},"选择类型 *",-1),se=a("optgroup",{label:"---"},null,-1),ie={key:4,label:"---"},re=a("td",null,"选择线路 *",-1),de={key:0},ce=a("td",null,"选择省/州",-1),pe={key:2,class:"comment"},Re={__name:"NSRoutesSelector",props:["v-routes","name"],emits:["add","cancel","change","change"],setup(U,{emit:W}){const E=J("$Tea"),x=U,k=W,{routeCode:s,inputName:F,routes:b,provinces:g,provinceRouteCode:m,isAdding:C,routeType:_,selectedRoutes:h,supportChinaProvinceRoutes:N,supportISPRoutes:w,supportWorldRegionRoutes:S,supportAgentRoutes:D,supportPublicRoutes:I,publicCategories:B}=function(){let t=x.vRoutes;t==null&&(t=[]);let e=x.name;return(typeof e!="string"||e.length==0)&&(e="routeCodes"),{routeCode:i("default"),inputName:i(e),routes:i([]),provinces:i({}),provinceRouteCode:i(""),isAdding:i(!1),routeType:i("default"),selectedRoutes:i(t),supportChinaProvinceRoutes:i(!1),supportISPRoutes:i(!1),supportWorldRegionRoutes:i(!1),supportAgentRoutes:i(!1),supportPublicRoutes:i(!1),publicCategories:i([])}}(),M=function(){C.value=!0,_.value="default",s.value="default",m.value="",k("add")},L=function(){C.value=!1,k("cancel")},j=function(){if(s.value.length==0)return;let t=null;for(const e of b.value)if(e.code==s.value){t=e;break}if(t!=null){if(m.value.length>0&&g.value[s.value]!=null){for(const e of g.value[s.value])if(e.code==m.value){t={name:t.name+"-"+e.name,code:e.code};break}}h.value.push(t)}k("change",h.value),L()},z=function(t){h.value.$remove(t),k("change",h.value)};return q(_,function(t){s.value="",b.value.forEach(function(e){e.type==t&&s.value.length==0&&(s.value=e.code)})}),G(()=>{E.action("/ns/routes/options").post().success(function(t){b.value=t.data.routes,N.value=t.data.supportChinaProvinceRoutes,w.value=t.data.supportISPRoutes,S.value=t.data.supportWorldRegionRoutes,D.value=t.data.supportAgentRoutes,B.value=t.data.publicCategories,I.value=t.data.supportPublicRoutes;let e={};if(t.data.provinces!=null&&t.data.provinces.length>0)for(const l of t.data.provinces){let R=l.countryCode;typeof e[R]>"u"&&(e[R]=[]),e[R].push({name:l.name,code:l.code})}g.value=e})}),(t,e)=>(u(),d("div",null,[H(a("div",Z,[(u(!0),d(y,null,V(o(h),(l,R)=>(u(),v(Q,{outlined:""},{default:n(()=>[a("input",{type:"hidden",name:o(F),value:l.code},null,8,ee),r(" "+P(l.name)+"   ",1),a("a",{href:"",title:"删除",onClick:T(ve=>z(R),["prevent"])},le,8,te)]),_:2},1024))),256)),f(O)],512),[[K,o(h).length>0]]),o(C)?(u(),d("div",ue,[a("table",ae,[a("tr",null,[ne,a("td",null,[f(A,{modelValue:o(_),"onUpdate:modelValue":e[0]||(e[0]=l=>$(_)?_.value=l:null)},{default:n(()=>[f(p,{value:"default"},{default:n(()=>[r("[默认线路]")]),_:1}),f(p,{value:"user"},{default:n(()=>[r("自定义线路")]),_:1}),se,o(w)?(u(),v(p,{key:0,value:"isp"},{default:n(()=>[r("运营商")]),_:1})):c("",!0),o(N)?(u(),v(p,{key:1,value:"china"},{default:n(()=>[r("中国省市")]),_:1})):c("",!0),o(S)?(u(),v(p,{key:2,value:"world"},{default:n(()=>[r("全球国家地区")]),_:1})):c("",!0),o(D)?(u(),v(p,{key:3,value:"agent"},{default:n(()=>[r("搜索引擎")]),_:1})):c("",!0),o(B).length>0?(u(),d("optgroup",ie)):c("",!0),(u(!0),d(y,null,V(o(B),l=>(u(),v(p,{value:l.type},{default:n(()=>[r(P(l.name),1)]),_:2},1032,["value"]))),256))]),_:1},8,["modelValue"])])]),a("tr",null,[re,a("td",null,[f(A,{modelValue:o(s),"onUpdate:modelValue":e[1]||(e[1]=l=>$(s)?s.value=l:null)},{default:n(()=>[(u(!0),d(y,null,V(o(b),l=>(u(),d(y,null,[l.type==o(_)?(u(),v(p,{key:0,value:l.code},{default:n(()=>[r(P(l.name),1)]),_:2},1032,["value"])):c("",!0)],64))),256))]),_:1},8,["modelValue"])])]),o(s).length>0&&o(g)[o(s)]!=null?(u(),d("tr",de,[ce,a("td",null,[f(A,{modelValue:o(m),"onUpdate:modelValue":e[2]||(e[2]=l=>$(m)?m.value=l:null)},{default:n(()=>[f(p,{value:""},{default:n(()=>[r("[全域]")]),_:1}),(u(!0),d(y,null,V(o(g)[o(s)],l=>(u(),v(p,{value:l.code},{default:n(()=>[r(P(l.name),1)]),_:2},1032,["value"]))),256))]),_:1},8,["modelValue"])])])):c("",!0)]),a("div",null,[f(X,{secondary:"",type:"button",size:"small",onClick:T(j,["prevent"])},{default:n(()=>[r("确定")]),_:1}),r("   "),a("a",{href:"",title:"取消",onClick:T(L,["prevent"])},"取消")])])):c("",!0),o(C)?c("",!0):(u(),v(Y,{key:1,type:"button",onClick:T(M,["prevent"])})),!o(w)||!o(N)||!o(S)||!o(I)?(u(),d("p",pe,"由于套餐限制，当前用户只能使用部分线路。")):c("",!0)]))}};export{Re as _};
