import{K as g,e as c,q as _,n as z,G as C,a as G,r as P}from"./index-DjCrtoJM.js";import{a as h,u as A,W as R}from"./use-mcp-client-Wf5qUXFF.js";const S={organizationId:"",sidebar_items:null,enabled_plugins:null,registry_config:null,simple_mode:null,default_home_agents:null},N={tiers:{fast:null,smart:null,thinking:null,image:null,web_research:null}};function O(t,e){return{queryKey:g.organizationSettings(e),queryFn:async()=>{const n=await t.callTool({name:"ORGANIZATION_SETTINGS_GET",arguments:{}});return n?.isError?{...S,organizationId:e}:n.structuredContent??{...S,organizationId:e}},staleTime:6e4}}function E(t){const e=c.c(9),{org:n}=_();let s;e[0]!==n.id||e[1]!==n.slug?(s={connectionId:h,orgId:n.id,orgSlug:n.slug},e[0]=n.id,e[1]=n.slug,e[2]=s):s=e[2];const r=A(s);let i;e[3]!==r||e[4]!==n.id?(i=O(r,n.id),e[3]=r,e[4]=n.id,e[5]=i):i=e[5];const o=t;let a;return e[6]!==i||e[7]!==o?(a={...i,select:o},e[6]=i,e[7]=o,e[8]=a):a=e[8],z(a)}function Y(t,e){const n=c.c(6);let s;n[0]!==t||n[1]!==e?(s={connectionId:h,orgId:t,orgSlug:e},n[0]=t,n[1]=e,n[2]=s):s=n[2];const r=A(s);let i;n[3]!==r||n[4]!==t?(i=O(r,t),n[3]=r,n[4]=t,n[5]=i):i=n[5];const{data:o}=z(i);return o??null}function T(){const t=c.c(12),{org:e}=_();let n;t[0]!==e.id||t[1]!==e.slug?(n={connectionId:h,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=n):n=t[2];const s=A(n),r=C();let i;t[3]!==s||t[4]!==e.id?(i=async l=>{const u=await s.callTool({name:"ORGANIZATION_SETTINGS_UPDATE",arguments:{organizationId:e.id,...l}});if(u?.isError)throw new Error(u.content?.[0]?.text??"Failed to update organization settings");const f=u.structuredContent;if(!f)throw new Error("ORGANIZATION_SETTINGS_UPDATE returned no payload");return f},t[3]=s,t[4]=e.id,t[5]=i):i=t[5];let o;t[6]!==e.id||t[7]!==r?(o=l=>{r.setQueryData(g.organizationSettings(e.id),u=>({...u??S,...l}))},t[6]=e.id,t[7]=r,t[8]=o):o=t[8];let a;return t[9]!==i||t[10]!==o?(a={mutationFn:i,onSuccess:o},t[9]=i,t[10]=o,t[11]=a):a=t[11],G(a)}function b(t){return t?.tiers?{tiers:{fast:t.tiers.fast??null,smart:t.tiers.smart??null,thinking:t.tiers.thinking??null,image:t.tiers.image??null,web_research:t.tiers.web_research??null}}:N}function H(){const{data:t}=E(Q);return t??N}function Q(t){return b(t.simple_mode)}function L(){const t=c.c(7),e=T();let n,s;t[0]!==e?(n=(i,o)=>e.mutate({simple_mode:i},o),s=(i,o)=>e.mutateAsync({simple_mode:i},o),t[0]=e,t[1]=n,t[2]=s):(n=t[1],s=t[2]);let r;return t[3]!==e||t[4]!==n||t[5]!==s?(r={...e,mutate:n,mutateAsync:s},t[3]=e,t[4]=n,t[5]=s,t[6]=r):r=t[6],r}function $(){const{data:t}=E(x);return t??null}function x(t){return t.registry_config}function W(){const t=c.c(7),e=T();let n,s;t[0]!==e?(n=(i,o)=>e.mutate({registry_config:i},o),s=(i,o)=>e.mutateAsync({registry_config:i},o),t[0]=e,t[1]=n,t[2]=s):(n=t[1],s=t[2]);let r;return t[3]!==e||t[4]!==n||t[5]!==s?(r={...e,mutate:n,mutateAsync:s},t[3]=e,t[4]=n,t[5]=s,t[6]=r):r=t[6],r}function Z(){const{data:t}=E(q);return t??null}function q(t){return t.default_home_agents}function U(){const t=c.c(7),e=T();let n,s;t[0]!==e?(n=(i,o)=>e.mutate({default_home_agents:i},o),s=(i,o)=>e.mutateAsync({default_home_agents:i},o),t[0]=e,t[1]=n,t[2]=s):(n=t[1],s=t[2]);let r;return t[3]!==e||t[4]!==n||t[5]!==s?(r={...e,mutate:n,mutateAsync:s},t[3]=e,t[4]=n,t[5]=s,t[6]=r):r=t[6],r}function j(){const t=c.c(14),{org:e}=_(),n=U(),s=C();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=Promise.resolve(),t[0]=r):r=t[0];const i=P.useRef(r);let o;t[1]!==e.id?(o=g.organizationSettings(e.id),t[1]=e.id,t[2]=o):o=t[2];const a=o;let l;t[3]!==a||t[4]!==s?(l=()=>s.getQueryData(a)?.default_home_agents?.ids??[],t[3]=a,t[4]=s,t[5]=l):l=t[5];const u=l;let f;t[6]!==a||t[7]!==e.slug||t[8]!==s||t[9]!==n?(f=D=>{const I=i.current.then(async()=>{const w=s.getQueryData(a),p=D(w?.default_home_agents?.ids??[]);if(p!==null){s.setQueryData(a,m=>m&&{...m,default_home_agents:{ids:p}});try{await n.mutateAsync({ids:p}),await s.refetchQueries({queryKey:g.homeNextActions(e.slug),type:"active"})}catch(m){const M=m;throw s.setQueryData(a,w),M}}});return i.current=I.catch(k),I},t[6]=a,t[7]=e.slug,t[8]=s,t[9]=n,t[10]=f):f=t[10];const y=f;let d;return t[11]!==y||t[12]!==u?(d={currentIds:u,apply:y},t[11]=y,t[12]=u,t[13]=d):d=t[13],d}function k(){}function B(){const t=c.c(5),{org:e}=_(),n=$();let s;t[0]!==e.id?(s=R.REGISTRY(e.id),t[0]=e.id,t[1]=s):s=t[1];const r=s;let i;return t[2]!==r||t[3]!==n?(i=o=>{if(!n)return o===r;const a=n.registries[o];return a?a.enabled:o===r},t[2]=r,t[3]=n,t[4]=i):i=t[4],i}export{j as a,B as b,Y as c,T as d,H as e,L as f,$ as g,W as h,O as o,Z as u};
