1import{b as A,g as I,ah as j,a6 as y,a4 as N,x as O,a5 as B,ac as T,$ as U,o as V,A as q}from"./C0UcZJ4B.js";import{w as P}from"./DXf8sJTt.js";import{q as R}from"./Chh3JoXn.js";import{bj as $,a$ as _,b0 as G,bV as z,bo as c,bq as d,bp as C,bi as D,bx as u,bz as S,br as L,a_ as M,bt as m,bs as W,bB as F,b6 as t,bG as H,bA as w}from"./CJrJ7XcP.js";import"./j6JhaW0_.js";import"./GF3J5o6p.js";try{(function(){var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new i.Error().stack;s&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[s]="f34e5c32-461a-45d1-827c-82f5e7acc67c",i._sentryDebugIdIdentifier="sentry-dbid-f34e5c32-461a-45d1-827c-82f5e7acc67c")})()}catch{}const Y=$({__name:"CollectionServerForm",props:{collectionId:{default:""},serverUid:{default:""}},setup(i){const s=i,{activeWorkspaceCollections:o}=A(),{servers:g,serverMutators:f}=I(),n=[{label:"URL",key:"url",placeholder:"https://void.scalar.com",type:"text"},{label:"Description",key:"description",placeholder:"Production",type:"text"}],l=_(()=>{const r=o.value.find(e=>e.uid===s.collectionId);return g[r&&typeof s.serverUid=="string"&&s.serverUid==="default"?r.servers[0]??"":r?.servers.find(e=>e===s.serverUid)??""]}),h=_(()=>{var r,e;return(r=l.value)!=null&&r.url?((e=l.value.url.match(j.PATH))==null?void 0:e.map(a=>a.slice(1,-1)))??[]:[]});G(h,r=>{if(!l.value)return;const e=l.value.variables?{...l.value.variables}:{};Object.keys(e).forEach(a=>{r.includes(a)||delete e[a]}),r.forEach(a=>{e[a]||(e[a]={default:""})}),f.edit(l.value.uid,"variables",e),y(p.value,"store-update-selected-server-properties",{key:"variables",value:e,options:{disableOldStoreUpdate:!0}})},{immediate:!0});const x=(r,e)=>{!o.value||!l.value||(f.edit(l.value.uid,r,e),(r==="url"||r==="description")&&y(p.value,"store-update-selected-server-properties",{key:r,value:e,options:{disableOldStoreUpdate:!0}}))},k=(r,e)=>{if(!l.value)return;const a=l.value.variables||{};a[r]={...a[r],default:e},f.edit(l.value.uid,"variables",a),y(p.value,"store-update-selected-server-properties",{key:"variables",value:a,options:{disableOldStoreUpdate:!0}})},p=z("wrapper-ref");return(r,e)=>{var a;return d(),c("div",{ref:"wrapper-ref",class:L(["divide-0.5 flex w-full flex-col divide-y rounded-b-lg text-sm",((a=l.value)==null?void 0:a.variables)&&"bg-b-1"])},[l.value?(d(),c(D,{key:0},[u(R,{data:l.value,onUpdate:x,options:n},null,8,["data"]),l.value.variables?(d(),S(N,{key:0,variables:l.value.variables,"onUpdate:variable":k},null,8,["variables"])):C("",!0)],64)):C("",!0)],2)}}}),J={ref:"wrapper-ref",class:"flex h-full w-full flex-col gap-12 px-1.5 pt-8"},K={class:"flex flex-col gap-4"},X={class:"rounded-lg border"},Q={class:"bg-b-2 flex items-start justify-between rounded-t-lg py-1 pr-1 pl-3 text-sm"}
1,Z={key:1,class:"self-center"},ee={class:"text-c-3 flex h-full items-center justify-center rounded-lg border p-4"},oe=$({__name:"CollectionServers",setup(i){const{activeCollection:s}=A(),{servers:o,events:g,serverMutators:f}=I(),n=O(),l=M(null),h=_(()=>{var e;return!o||!((e=s.value)!=null&&e.servers)?[]:Object.values(o).filter(a=>{var b;return(b=s.value)==null?void 0:b.servers.includes(a.uid)})}),x=()=>g.commandPalette.emit({commandName:"Add Server"}),k=()=>{var e,a;!((e=s.value)!=null&&e.uid)||!l.value||(f.delete(l.value,s.value.uid),y(r.value,"scalar-delete-server",{url:((a=o[l.value])==null?void 0:a.url)??""}),n.hide())},p=e=>{l.value=e,n.show()},r=z("wrapper-ref");return(e,a)=>{var b;return d(),c("div",J,[m("div",K,[a[2]||(a[2]=W('<div class="flex items-start justify-between gap-2"><div class="flex flex-col gap-2"><div class="flex h-8 items-center"><h3 class="font-bold">Servers</h3></div><p class="text-sm"> Add different base URLs for your API. You can use <code class="font-code text-c-2">{variables}</code> for dynamic parts. </p></div></div>',1)),(d(!0),c(D,null,F(h.value,(v,E)=>(d(),c("div",{key:v.uid},[m("div",X,[m("div",Q,[v.description?(d(),S(t(B),{key:0,class:"self
1-center",value:v.description},null,8,["value"])):(d(),c("span",Z,"Server "+H(E+1),1)),u(t(U),{class:"hover:bg-b-3 hover:text-c-1 h-fit p-1.25",variant:"ghost",onClick:ae=>p(v.uid)},{default:w(()=>[u(t(T),{class:"size-3.5"})]),_:2},1032,["onClick"])]),t(s)?(d(),S(Y,{key:0,collectionId:t(s).uid,serverUid:v.uid},null,8,["collectionId","serverUid"])):C("",!0)])]))),128)),m("div",ee,[u(t(U),{class:"hover:bg-b-2 hover:text-c-1 flex items-center gap-2",size:"sm",variant:"ghost",onClick:x},{default:w(()=>[u(t(V),{class:"inline-flex",icon:"Add",size:"sm",thickness:"1.5"}),a[1]||(a[1]=m("span",null,"Add Server",-1))]),_:1,__:[1]})])]),u(t(q),{size:"xxs",state:t(n),title:`Delete ${l.value?(b=t(o)[l.value])==null?void 0:b.url:"Server"}`},{default:w(()=>[u(P,{variableName:"Server",warningMessage:"Are you sure you want to delete this server? This action cannot be undone.",onClose:a[0]||(a[0]=v=>t(n).hide()),onDelete:k})]),_:1},8,["state","title"])],512)}}});export{oe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.