import{aL as j,aA as T}from"./index.17037962789732.js";import"./index.1703796278973303.js";import"./index.1703796278973304.js";import{b as v,c as w,a as x,g as A}from"./apiPage.1703796278973.js";import{d as P,k as p,p as D,r as I,o as B,c as C,a as m,b as g,u as f,M,t as R,A as E}from"./vue.1703796278973.js";const K=P({__name:"LeftTree",props:{mode:null,hasHome:{type:Boolean},code:null},emits:["select"],setup(y,{emit:d}){const r=y,h=p([]),l=p([]),i=p(!1),O=()=>{let e=[];i.value=!0,v().then(s=>{e=s.urls.map(t=>({...t,key:t.url}));const o=e.map(t=>w(t.name));r.mode==="appManger"?o.push(x()):r.mode==="home"&&o.push(A(r.code)),Promise.all(o).then(t=>{t.forEach((a,n)=>{if(r.mode==="api")e[n].schemas=a.components.schemas,e[n].children=u(a.paths);else if(n<t.length-1){const c=b(a.paths,t[t.length-1].result);e[n].children=u(c),e[n].schemas=a.components.schemas}}),r.hasHome&&(e.unshift({key:"home",name:"首页",schemas:{},children:[]}),l.value=["home"]),h.value=e}).finally(()=>{i.value=!1})})},k=(e,s)=>{var o;if(e[0]==="home")return d("select",s.node.dataRef,{});!s.node.parent&&e[0]!=="home"||d("select",s.node.dataRef,(o=s.node)==null?void 0:o.parent.node.schemas)};D(()=>{O()});const u=e=>{const s=[];return Object.keys(e).forEach(t=>{var _;const a=Object.keys(e[t]||{})[0],n=e[t][a].tags[0];let c=s.find(L=>L.name===n);c?(_=c.apiList)==null||_.push({url:t,method:e[t]}):(c={name:n,key:n,apiList:[{url:t,method:e[t]}]},s.push(c))}),s},b=(e,s)=>{for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const t=e[o];for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const n=t[a];s.includes(n.operationId)||delete t[a]}Object.keys(t).length===0&&delete e[o]}return e};return(e,s)=>{const o=I("AIcon"),t=j,a=T;return B(),C(a,{spinning:f(i)},{indicator:m(()=>[g(o,{type:"LoadingOutlined"})]),default:m(()=>[g(t,{"tree-data":f(h),onSelect:k,"selected-keys":f(l),"onUpdate:selected-keys":s[0]||(s[0]=n=>M(l)?l.value=n:null),showLine:"",class:"left-tree-container"},{title:m(({name:n})=>[R(E(n),1)]),_:1},8,["tree-data","selected-keys"])]),_:1},8,["spinning"])}}});export{K as _};
