function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = ["assets/UserDropdown-CBlQ5X4Q.js","assets/index-B-YXshIJ.js","assets/index-7Rg3YT-G.css","assets/default-profile-pic-B1WNOWFq.js","assets/user-DEWqbyPD.js","assets/settings-CXc2CXGp.js"]
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
import{t as o,R as i,j as e,Z as x,L as p,_ as f}from"./index-B-YXshIJ.js";import{S as h,c as l}from"./react-select.esm-OagQDocY.js";import{O as j}from"./organization-icon-Ab84U38q.js";import{C as b}from"./check-DaW7r622.js";import{S}from"./settings-CXc2CXGp.js";import"./extends-vRGLuScH.js";const N="/assets/specmatic_logo-BSuF7w6Y.png",c=t=>{localStorage.setItem("currentOrganization",JSON.stringify(t))},O=t=>{c(t),window.location.href="/demo/settings?auth=true"},y=({children:t,...a})=>e.jsxs(l.Control,{...a,children:[e.jsx("div",{className:"border border-gray-300 rounded-full p-2 mx-2 bg-gray-200 flex item-center",children:e.jsx("img",{src:j,alt:"Organization Icon",className:"w-4"})}),t]}),d=()=>e.jsxs("button",{type:"button",title:"Add New Organization","aria-label":"Add New Organization",className:"flex items-center text-gray-800 p-2",onClick:()=>{window.location.href="/demo/create-organization"},children:[e.jsx("span",{className:"text-gray-800 font-bold",children:"+"})," Add new organization"]}),v=t=>e.jsxs(l.Menu,{...t,children:[t.children,e.jsx("div",{className:"menu-option border-t-2 border-purple-50 p-2",children:e.jsx(d,{})})]}),w=t=>e.jsx(l.Option,{...t,children:e.jsxs("div",{className:"flex justify-between item-center px-4 py-2",children:[e.jsx("p",{className:"text-sm pt-1",children:t.data.label}),e.jsxs("div",{className:"flex gap-0.5",children:[t.isSelected&&e.jsx(b,{className:"inline-block text-purple-900 w-4 "}),e.jsx("button",{type:"button",title:"settings","aria-label":"Organization Settings",onClick:a=>{a.preventDefault(),a.stopPropagation(),O(t.data)},children:e.jsx(S,{className:"inline-block ml-2 w-4"})})]})]})}),C=()=>{const t=o.auth.verifySession.useQuery().data,a=t?o.organization.getOrganizationsForUser.useQuery({userEmail:t==null?void 0:t.email},{keepPreviousData:!0}):null,n=localStorage.getItem("currentOrganization"),u=n?JSON.parse(n):void 0,[s,m]=i.useState(u);return i.useEffect(()=>{s&&localStorage.setItem("currentOrganization",JSON.stringify(s))},[s]),!(a!=null&&a.data)||a.data.length<1?e.jsx(d,{}):e.jsx("div",{className:"flex items-center",children:a!=null&&a.data?e.jsx(h,{className:"react-select w-56",styles:{container:r=>({...r,border:"1px solid #E5E7EB",borderRadius:"6px",backgroundColor:"transparent",fontSize:"14px"}),control:r=>({...r,border:"1px solid #E5E7EB",borderRadius:"6px",backgroundColor:"transparent"}),option:(r,g)=>({...r,cursor:"pointer",color:"#1F2937",backgroundColor:g.isSelected?"#f3e8ff":"transparent",":hover":{backgroundColor:"#faf5ff"}})},options:a.data.map(r=>({value:r._id.toString(),label:r.name})),defaultValue:n?JSON.parse(n):s||{value:a.data[0]._id.toString(),label:a.data[0].name},isSearchable:!1,isMulti:!1,components:{Control:y,Option:w,Menu:v,IndicatorSeparator:()=>null},onChange:r=>{r&&(m(r),c(r))}}):null})},z=C,_=i.lazy(()=>f(()=>import("./UserDropdown-CBlQ5X4Q.js"),__vite__mapDeps([0,1,2,3,4,5]))),L=()=>{const t=x("auth"),a=o.auth.verifySession.useQuery().data;return e.jsxs("div",{children:[e.jsxs("div",{className:"w-[min(100%,_80rem)] mx-auto py-4 px-6 grid grid-flow-col items-center gap-20 justify-between",children:[e.jsx(p,{to:"https://insights.specmatic.in/",className:"outline-offset-8",children:e.jsx("img",{src:N,alt:"Logo",className:"w-64"})}),e.jsx("div",{className:"flex gap-5",children:t&&a?e.jsxs(e.Fragment,{children:[e.jsx(z,{}),e.jsx(_,{})]}):null})]}),t&&a||!t?e.jsx("div",{className:"bg-purple-900",children:e.jsx("div",{className:"w-[min(100%,_80rem)] mx-auto px-6 py-8",children:e.jsx("h1",{className:"text-5xl font-bold text-gray-200 pr-2",children:"Acme Widgets Inc."})})}):null]})};export{L as default};
