UNPKG

decocms

Version:

Deco CMS โ€” Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) โ€ข 38.8 kB
import{aK as ne,cs as Fe,c as P,j as n,a6 as A,an as F,K as z,i as le,q as H,e as G,aJ as de,b as I,r as $,B as O,av as X,D as je,v as ye,w as ve,x as Ne,aW as Se,e3 as oe,y as Pe,a9 as Le,t as re,I as Ce,o as Ie,m as fe,h as he,dR as He}from"./index-ztdGKvBm.js";import{i as ae}from"./ArrowLeft-B0PZnf1E.js";import{s as ue}from"./Plus-DWySsEmB.js";import{c as Ge,T as qe,a as Ke}from"./tooltip-Bm0P1gm_.js";import{L as we}from"./label-8UxgpYiA.js";import{G as Ue}from"./github-icon-Bq9Ot22_.js";import{u as We}from"./useInfiniteQuery-Ypmdjx1e.js";import{C as Te}from"./collection-search-DkVgkcUC.js";import{n as Me}from"./BookOpen01-DU-B3R7s.js";import{t as Be}from"./ShoppingBag01-BbjW7cod.js";import{u as Qe}from"./use-debounced-value-DO5dvp6c.js";import{u as Ye}from"./use-organization-settings-C2vcrj4S.js";const ge="deco-sites",Ve=[{id:"storefront",repo:{owner:ge,name:"storefront-tanstack"}},{id:"blog",repo:{owner:ge,name:"blog-tanstack"}}];Fe(["storefront","blog"]);const Je=ne().trim().min(1).max(100).regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,"Use lower-case letters, numbers and hyphens, starting and ending with a letter or number"),Ee={github:"github.com",gitlab:"gitlab.com",bitbucket:"bitbucket.org"},Xe=new Set(["github","bitbucket"]);function Ze(t){const e=t.toLowerCase();return e==="github.com"||e==="www.github.com"?"github":e==="gitlab.com"||e==="www.gitlab.com"?"gitlab":e==="bitbucket.org"||e==="www.bitbucket.org"?"bitbucket":/(^|[.-])gitlab([.-]|$)/.test(e)?"gitlab":null}function et(t){const e=t.toLowerCase();return e.startsWith("www.")?e.slice(4):e}function It(t,e){const o=t.trim();if(!o)return null;let r,i;const s=/^(?:[\w.-]+@)?([\w.-]+(?::\d+)?):(?!\/\/)(.+)$/.exec(o);if(s&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(o))r=s[1],i=s[2];else if(/^[a-z][a-z0-9+.-]*:\/\//i.test(o)){let d;try{d=new URL(o)}catch{return null}if(!/^(https?|ssh|git)(\+ssh)?:$/.test(d.protocol))return null;r=d.host,i=d.pathname}else if(e?.provider)r=e.host??Ee[e.provider],i=o;else return null;r=et(r);const l=e?.provider??Ze(r);if(!l)return null;let c=i.split("/").map(d=>d.trim()).filter(Boolean);const a=c.indexOf("-");if(a>=0&&(c=c.slice(0,a)),Xe.has(l)&&(c=c.slice(0,2)),c.length<2)return null;const f=c[c.length-1];return c[c.length-1]=f.replace(/\.git$/i,""),c.some(d=>d.length===0||d==="."||d==="..")?null:{provider:l,host:r,path:c.join("/")}}function Ht(t){return`https://${t.host}/${t.path}`}function tt(t){const e=P.c(4),{size:o,className:r}=t,i=o===void 0?24:o;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("path",{d:"M.778 1.213a.768.768 0 00-.768.892l3.263 19.81c.084.5.515.868 1.022.873H19.95a.772.772 0 00.77-.646l3.27-20.03a.768.768 0 00-.768-.891zM14.52 15.53H9.522L8.17 8.466h7.561z"}),e[0]=s):s=e[0];let l;return e[1]!==r||e[2]!==i?(l=n.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:r,children:s}),e[1]=r,e[2]=i,e[3]=l):l=e[3],l}function st(t){const e=P.c(4),{size:o,className:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("path",{d:"M23.6004 9.5927l-.0337-.0862L20.3.9814a.851.851 0 00-.3362-.405.8748.8748 0 00-.9997.0539.8748.8748 0 00-.29.4399l-2.2055 6.748H7.5375L5.3318 1.0702a.8573.8573 0 00-.29-.4412.8748.8748 0 00-.9997-.0537.8585.8585 0 00-.3361.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 002.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 001.2197 0l1.4995-1.1321 2.462-1.8633 5.0062-3.7489.0125-.01a6.0682 6.0682 0 002.0094-7.003z"}),e[0]=i):i=e[0];let s;return e[1]!==r||e[2]!==o?(s=n.jsx("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:r,children:i}),e[1]=r,e[2]=o,e[3]=s):s=e[3],s}const it={github:Ue,gitlab:st,bitbucket:tt};function me(t){const e=P.c(4),{provider:o,size:r,className:i}=t,s=r===void 0?16:r,l=it[o];let c;return e[0]!==l||e[1]!==i||e[2]!==s?(c=n.jsx(l,{size:s,className:i}),e[0]=l,e[1]=i,e[2]=s,e[3]=c):c=e[3],c}const nt=5*6e4;function ot(){const t=P.c(7),{org:e}=A(),o=F();let r;t[0]!==e.id?(r=z.gitProviderCapabilities(e.id),t[0]=e.id,t[1]=r):r=t[1];let i;t[2]!==o?(i=()=>o.call("GIT_PROVIDER_CAPABILITIES",{}),t[2]=o,t[3]=i):i=t[3];let s;return t[4]!==r||t[5]!==i?(s={queryKey:r,staleTime:nt,queryFn:i},t[4]=r,t[5]=i,t[6]=s):s=t[6],le(s)}function rt(){const t=P.c(7),{org:e}=A(),o=F();let r;t[0]!==e.id?(r=z.gitAccounts(e.id),t[0]=e.id,t[1]=r):r=t[1];let i;t[2]!==o?(i=async()=>(await o.call("GIT_ACCOUNT_LIST",{})).accounts,t[2]=o,t[3]=i):i=t[3];let s;return t[4]!==r||t[5]!==i?(s={queryKey:r,staleTime:6e4,queryFn:i},t[4]=r,t[5]=i,t[6]=s):s=t[6],le(s)}function lt(t){const e=P.c(9),{org:o}=A(),r=F();let i;e[0]!==t||e[1]!==o.id?(i=z.repositories(o.id,t),e[0]=t,e[1]=o.id,e[2]=i):i=e[2];let s;e[3]!==t||e[4]!==r?(s=async()=>(await r.call("REPOSITORY_LIST",{})).repositories,e[3]=t,e[4]=r,e[5]=s):s=e[5];let l;return e[6]!==i||e[7]!==s?(l={queryKey:i,staleTime:6e4,queryFn:s},e[6]=i,e[7]=s,e[8]=l):l=e[8],le(l)}function Gt(t){const e=P.c(9),{org:o}=A(),r=F();let i;e[0]!==o.id||e[1]!==t?(i=z.repositoryDeploys(o.id,t),e[0]=o.id,e[1]=t,e[2]=i):i=e[2];const s=t.length>0;let l;e[3]!==r?(l=async()=>(await r.call("REPOSITORY_DEPLOYS_LIST",{})).deploys,e[3]=r,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==s||e[7]!==l?(c={queryKey:i,enabled:s,staleTime:6e4,queryFn:l},e[5]=i,e[6]=s,e[7]=l,e[8]=c):c=e[8],le(c)}function at(t,e){const o=P.c(12),{org:r}=A(),i=F();let s;o[0]!==t||o[1]!==r.id||o[2]!==e?(s=z.providerRepoSearch(r.id,t??"",e),o[0]=t,o[1]=r.id,o[2]=e,o[3]=s):s=o[3];const l=t!==null;let c;o[4]!==t||o[5]!==e||o[6]!==i?(c=async f=>{const{pageParam:d}=f;return t===null?{repositories:[],hasMore:!1}:await i.call("REPOSITORY_SEARCH",{accountId:t,page:d,perPage:100,...e?{query:e}:{}})},o[4]=t,o[5]=e,o[6]=i,o[7]=c):c=o[7];let a;return o[8]!==s||o[9]!==l||o[10]!==c?(a={queryKey:s,enabled:l,initialPageParam:1,getNextPageParam:ct,staleTime:3e4,retry:!1,queryFn:c},o[8]=s,o[9]=l,o[10]=c,o[11]=a):a=o[11],We(a)}function ct(t,e){return t.hasMore?e.length+1:void 0}function dt(){const t=P.c(8),{org:e}=A(),o=F(),r=H();let i;t[0]!==o?(i=async c=>(await o.call("GIT_ACCOUNT_CONNECT_TOKEN",c)).account,t[0]=o,t[1]=i):i=t[1];let s;t[2]!==e||t[3]!==r?(s=()=>r.invalidateQueries({queryKey:z.gitAccounts(e.id)}),t[2]=e,t[3]=r,t[4]=s):s=t[4];let l;return t[5]!==i||t[6]!==s?(l={mutationFn:i,onSettled:s},t[5]=i,t[6]=s,t[7]=l):l=t[7],G(l)}function ut(){const t=P.c(8),{org:e}=A(),o=H();let r;t[0]!==e?(r=async()=>{const l=await fetch(`/api/${encodeURIComponent(e.slug)}/git-providers/github/cli/connect`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}),c=await l.json().catch(mt);if(!l.ok){const a=de({error:ne()}).safeParse(c);throw new Error(a.success?a.data.error:l.statusText)}return de({account:de({id:ne(),login:ne()})}).parse(c).account},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==o?(i=()=>o.invalidateQueries({queryKey:z.gitAccounts(e.id)}),t[2]=e,t[3]=o,t[4]=i):i=t[4];let s;return t[5]!==r||t[6]!==i?(s={mutationFn:r,onSettled:i},t[5]=r,t[6]=i,t[7]=s):s=t[7],G(s)}function mt(){return null}function qt(){const t=P.c(8),{org:e}=A(),o=F(),r=H();let i;t[0]!==o?(i=c=>o.call("GIT_ACCOUNT_DELETE",{id:c}),t[0]=o,t[1]=i):i=t[1];let s;t[2]!==e||t[3]!==r?(s=()=>{r.invalidateQueries({queryKey:z.gitAccounts(e.id)}),r.invalidateQueries({queryKey:z.repositories(e.id)})},t[2]=e,t[3]=r,t[4]=s):s=t[4];let l;return t[5]!==i||t[6]!==s?(l={mutationFn:i,onSettled:s},t[5]=i,t[6]=s,t[7]=l):l=t[7],G(l)}function pt(){const t=P.c(8),{org:e}=A(),o=F(),r=H();let i;t[0]!==o?(i=async c=>(await o.call("REPOSITORY_LINK",c)).repository,t[0]=o,t[1]=i):i=t[1];let s;t[2]!==e||t[3]!==r?(s=()=>r.invalidateQueries({queryKey:z.repositories(e.id)}),t[2]=e,t[3]=r,t[4]=s):s=t[4];let l;return t[5]!==i||t[6]!==s?(l={mutationFn:i,onSettled:s},t[5]=i,t[6]=s,t[7]=l):l=t[7],G(l)}function ft(){const t=P.c(8),{org:e}=A(),o=F(),r=H();let i;t[0]!==o?(i=async c=>(await o.call("REPOSITORY_CREATE_FROM_TEMPLATE",c)).repository,t[0]=o,t[1]=i):i=t[1];let s;t[2]!==e||t[3]!==r?(s=()=>{r.invalidateQueries({queryKey:z.repositories(e.id)}),r.invalidateQueries({queryKey:z.gitAccounts(e.id)})},t[2]=e,t[3]=r,t[4]=s):s=t[4];let l;return t[5]!==i||t[6]!==s?(l={mutationFn:i,onSettled:s},t[5]=i,t[6]=s,t[7]=l):l=t[7],G(l)}function Kt(){const t=P.c(8),{org:e}=A(),o=F(),r=H();let i;t[0]!==o?(i=async c=>(await o.call("REPOSITORY_UPDATE",c)).repository,t[0]=o,t[1]=i):i=t[1];let s;t[2]!==e||t[3]!==r?(s=()=>r.invalidateQueries({queryKey:z.repositories(e.id)}),t[2]=e,t[3]=r,t[4]=s):s=t[4];let l;return t[5]!==i||t[6]!==s?(l={mutationFn:i,onSettled:s},t[5]=i,t[6]=s,t[7]=l):l=t[7],G(l)}function Ut(){const t=P.c(8),{org:e}=A(),o=F(),r=H();let i;t[0]!==o?(i=c=>o.call("REPOSITORY_DELETE",{id:c}),t[0]=o,t[1]=i):i=t[1];let s;t[2]!==e||t[3]!==r?(s=()=>r.invalidateQueries({queryKey:z.repositories(e.id)}),t[2]=e,t[3]=r,t[4]=s):s=t[4];let l;return t[5]!==i||t[6]!==s?(l={mutationFn:i,onSettled:s},t[5]=i,t[6]=s,t[7]=l):l=t[7],G(l)}function _e(t,e){return t instanceof Error&&t.message?t.message:e}const be={github:{label:"settings.repositories.providerGithub"},gitlab:{label:"settings.repositories.providerGitlab"},bitbucket:{label:"settings.repositories.providerBitbucket"}};function ht(t,e){return e.length===0?"settings.repositories.githubUnavailable":t==="github"?e.some(o=>o.kind==="cli")?"settings.repositories.githubCliHint":"settings.repositories.providerGithubHint":e.length>1?"settings.repositories.providerTokenOrOauthHint":"settings.repositories.providerTokenOnlyHint"}const pe={gitlab:{title:"settings.repositories.tokenDialogTitle",description:"settings.repositories.tokenDialogDescription",placeholder:"settings.repositories.tokenPlaceholder",steps:["settings.repositories.gitlabStep1","settings.repositories.gitlabStep2","settings.repositories.gitlabStep3","settings.repositories.gitlabStep4"],askHost:!0,askWorkspace:!1,askProject:!0},bitbucket:{title:"settings.repositories.tokenDialogTitleBitbucket",description:"settings.repositories.tokenDialogDescriptionBitbucket",placeholder:"settings.repositories.tokenPlaceholderBitbucket",steps:["settings.repositories.bitbucketStep1","settings.repositories.bitbucketStep2","settings.repositories.bitbucketStep3","settings.repositories.bitbucketStep4"],askHost:!1,askWorkspace:!0,askProject:!1}},xt=["github","gitlab","bitbucket"];function se(t,e,o){if(t==="github"){const s=e?.github;return s?.cliConnectPath?[{kind:"cli"}]:s?.configured&&s.connectPath?[{kind:"app",href:o(s.connectPath)}]:[]}const r=t==="gitlab"?e?.gitlab:e?.bitbucket,i=[{kind:"token"}];return r&&r.oauthHosts.length>0&&r.connectPath&&i.push({kind:"oauth",href:o(r.connectPath)}),i}function gt(t,e){if(t==="bitbucket"){const s=e.workspace.trim();return s?`https://bitbucket.org/${encodeURIComponent(s)}/workspace/repositories`:null}const o=e.host.trim();if(!o)return null;const r=e.project.trim().replace(/^\/+|\/+$/g,""),i="?name=Studio&scopes=api";return r?`https://${o}/${r}/-/settings/access_tokens${i}`:`https://${o}/-/user_settings/personal_access_tokens${i}`}function $e(t){const e=P.c(10),{layout:o,disabled:r}=t,i=o===void 0?"buttons":o,s=r===void 0?!1:r,l=I(),[c,a]=$.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>a({name:"provider"}),e[0]=f):f=e[0];const d=f;let u;e[1]!==s||e[2]!==i||e[3]!==l?(u=i==="picker"?n.jsxs(O,{variant:"ghost",size:"sm",disabled:s,onClick:d,"aria-label":l("settings.repositories.addAccount"),className:"w-full h-auto justify-start gap-3 rounded-none px-4 py-3 hover:bg-accent",children:[n.jsx("span",{className:"size-8 rounded-lg bg-muted flex items-center justify-center shrink-0",children:n.jsx(ue,{size:16})}),n.jsxs("span",{className:"flex-1 min-w-0 text-left",children:[n.jsx("span",{className:"block text-sm font-medium",children:l("settings.repositories.addAccount")}),n.jsx("span",{className:"block text-xs font-normal text-muted-foreground whitespace-normal",children:l("settings.repositories.addAccountDescription")})]}),n.jsx("span",{className:"shrink-0 text-muted-foreground",children:n.jsx(X,{size:16})})]}):n.jsxs(O,{variant:"outline",size:"sm",disabled:s,onClick:d,children:[n.jsx(ue,{size:16}),l("settings.repositories.addAccount")]}),e[1]=s,e[2]=i,e[3]=l,e[4]=u):u=e[4];let p;e[5]!==c?(p=c&&n.jsx(bt,{stage:c,onStage:a,onClose:()=>a(null)}),e[5]=c,e[6]=p):p=e[6];let m;return e[7]!==u||e[8]!==p?(m=n.jsxs(n.Fragment,{children:[u,p]}),e[7]=u,e[8]=p,e[9]=m):m=e[9],m}function bt({stage:t,onStage:e,onClose:o}){const r=I(),i=ot(),s=ut(),{org:l}=A(),c=`/${l.slug}/settings/repositories`,a=m=>`${m}?returnTo=${encodeURIComponent(c)}`;function f(m){const h=se(m,i.data,a),x=h.length===1?h[0]:void 0;if(x?.kind==="cli"){s.mutate(void 0,{onSuccess:g=>{re.success(r("settings.repositories.connected",{login:g.login})),o()},onError:g=>re.error(_e(g,r("settings.repositories.failed")))});return}if(x?.href){globalThis.location.href=x.href;return}if(x?.kind==="token"){e({name:"token",provider:m});return}e({name:"method",provider:m})}const d=m=>e(se(m,i.data,a).length>1?{name:"method",provider:m}:{name:"provider"}),u=t.name==="token"?r(pe[t.provider].title):t.name==="method"?r(be[t.provider].label):r("settings.repositories.addAccountTitle"),p=t.name==="token"?r(pe[t.provider].description):t.name==="method"?r("settings.repositories.chooseMethodDescription"):r("settings.repositories.addAccountDescription");return n.jsx(je,{open:!0,onOpenChange:m=>!m&&o(),children:n.jsxs(ye,{className:"sm:max-w-md",children:[n.jsxs(ve,{children:[n.jsx(Ne,{children:u}),n.jsx(Se,{children:p})]}),t.name==="token"?n.jsx(kt,{provider:t.provider,onBack:()=>d(t.provider),onClose:o}):i.isError?n.jsxs("div",{className:"flex flex-col items-start gap-2",children:[n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:r("settings.repositories.failed")}),n.jsx(O,{variant:"outline",size:"sm",onClick:()=>i.refetch(),children:r("settings.repositories.tryAgain")})]}):i.isPending?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(oe,{className:"h-14 w-full"}),n.jsx(oe,{className:"h-14 w-full"})]}):t.name==="provider"?n.jsx("div",{className:"flex flex-col gap-1",children:xt.map(m=>{const h=se(m,i.data,a);return n.jsx(ke,{icon:n.jsx(me,{provider:m,size:16}),label:r(h[0]?.kind==="cli"?"settings.repositories.connectGithubCli":be[m].label),description:r(ht(m,h)),disabled:h.length===0||s.isPending,onClick:()=>f(m)},m)})}):n.jsx("div",{className:"flex flex-col gap-1",children:se(t.provider,i.data,a).map(m=>n.jsx(ke,{icon:n.jsx(me,{provider:t.provider,size:16}),label:r(m.kind==="cli"?"settings.repositories.connectGithubCli":m.kind==="token"?"settings.repositories.methodToken":m.kind==="oauth"?"settings.repositories.methodOauth":"settings.repositories.methodApp"),description:r(m.kind==="cli"?"settings.repositories.githubCliHint":m.kind==="token"?"settings.repositories.methodTokenHint":m.kind==="oauth"?"settings.repositories.methodOauthHint":"settings.repositories.methodAppHint"),note:m.kind==="oauth"?r("settings.repositories.methodOauthScopeNote"):void 0,href:m.href,onClick:m.kind==="cli"?()=>f(t.provider):m.kind==="token"?()=>e({name:"token",provider:t.provider}):void 0},m.kind))}),t.name==="method"&&n.jsx(Pe,{className:"sm:justify-start",children:n.jsxs(O,{variant:"ghost",size:"sm",onClick:()=>e({name:"provider"}),children:[n.jsx(ae,{size:16}),r("settings.repositories.back")]})})]})})}function ke(t){const e=P.c(32),{icon:o,label:r,description:i,note:s,href:l,onClick:c,disabled:a}=t;let f;e[0]!==o?(f=n.jsx("span",{className:"size-8 rounded-lg bg-muted flex items-center justify-center shrink-0",children:o}),e[0]=o,e[1]=f):f=e[1];let d;e[2]!==r?(d=n.jsx("span",{className:"block text-sm font-medium",children:r}),e[2]=r,e[3]=d):d=e[3];let u;e[4]!==i?(u=n.jsx("span",{className:"block text-xs font-normal text-muted-foreground whitespace-normal",children:i}),e[4]=i,e[5]=u):u=e[5];let p;e[6]!==s?(p=s&&n.jsx("span",{className:"block text-xs font-normal text-warning whitespace-normal mt-0.5",children:s}),e[6]=s,e[7]=p):p=e[7];let m;e[8]!==d||e[9]!==u||e[10]!==p?(m=n.jsxs("span",{className:"flex-1 min-w-0 text-left",children:[d,u,p]}),e[8]=d,e[9]=u,e[10]=p,e[11]=m):m=e[11];let h;e[12]!==a?(h=!a&&n.jsx("span",{className:"shrink-0 text-muted-foreground",children:n.jsx(X,{size:16})}),e[12]=a,e[13]=h):h=e[13];let x;e[14]!==f||e[15]!==m||e[16]!==h?(x=n.jsxs(n.Fragment,{children:[f,m,h]}),e[14]=f,e[15]=m,e[16]=h,e[17]=x):x=e[17];const g=x,k=!!l&&!a;let b;e[18]!==g||e[19]!==a||e[20]!==l?(b=l&&!a?n.jsx("a",{href:l,children:g}):g,e[18]=g,e[19]=a,e[20]=l,e[21]=b):b=e[21];let j;e[22]!==a||e[23]!==r||e[24]!==c||e[25]!==k||e[26]!==b?(j=n.jsx(O,{variant:"ghost","aria-label":r,disabled:a,asChild:k,onClick:c,className:"w-full h-auto justify-start gap-3 px-3 py-3 hover:bg-accent",children:b}),e[22]=a,e[23]=r,e[24]=c,e[25]=k,e[26]=b,e[27]=j):j=e[27];const v=j;let S;return e[28]!==v||e[29]!==i||e[30]!==a?(S=a?n.jsxs(Ge,{children:[n.jsx(qe,{asChild:!0,children:n.jsx("span",{tabIndex:0,children:v})}),n.jsx(Ke,{children:i})]}):v,e[28]=v,e[29]=i,e[30]=a,e[31]=S):S=e[31],S}function kt(t){const e=P.c(89),{provider:o,onBack:r,onClose:i}=t,s=I(),l=pe[o],c=dt(),[a,f]=$.useState(Ee[o]),[d,u]=$.useState(""),[p,m]=$.useState(""),[h,x]=$.useState("");let g;e[0]!==l.askWorkspace||e[1]!==a||e[2]!==h||e[3]!==d?(g=!!a.trim()&&!!h.trim()&&(!l.askWorkspace||!!d.trim()),e[0]=l.askWorkspace,e[1]=a,e[2]=h,e[3]=d,e[4]=g):g=e[4];const k=g;let b;e[5]!==a||e[6]!==p||e[7]!==o||e[8]!==d?(b=gt(o,{host:a,workspace:d,project:p}),e[5]=a,e[6]=p,e[7]=o,e[8]=d,e[9]=b):b=e[9];const j=b;let v;e[10]!==c||e[11]!==l.askWorkspace||e[12]!==a||e[13]!==i||e[14]!==o||e[15]!==k||e[16]!==s||e[17]!==h||e[18]!==d?(v=function(){k&&c.mutate({type:o,host:a.trim(),token:h.trim(),...l.askWorkspace?{workspace:d.trim()}:{}},{onSuccess:J=>{re.success(s("settings.repositories.connected",{login:J.login})),x(""),i()},onError:J=>re.error(_e(J,s("settings.repositories.failed")))})},e[10]=c,e[11]=l.askWorkspace,e[12]=a,e[13]=i,e[14]=o,e[15]=k,e[16]=s,e[17]=h,e[18]=d,e[19]=v):v=e[19];const S=v;let C;e[20]!==l.askHost||e[21]!==a||e[22]!==o||e[23]!==s?(C=l.askHost&&n.jsx(ie,{id:`${o}-host`,label:s("settings.repositories.tokenHostLabel"),value:a,onChange:f,placeholder:s("settings.repositories.tokenHostPlaceholder")}),e[20]=l.askHost,e[21]=a,e[22]=o,e[23]=s,e[24]=C):C=e[24];let N;e[25]!==l.askWorkspace||e[26]!==o||e[27]!==s||e[28]!==d?(N=l.askWorkspace&&n.jsx(ie,{id:`${o}-workspace`,label:s("settings.repositories.tokenWorkspaceLabel"),value:d,onChange:u,placeholder:s("settings.repositories.tokenWorkspacePlaceholder"),hint:s("settings.repositories.tokenWorkspaceHint")}),e[25]=l.askWorkspace,e[26]=o,e[27]=s,e[28]=d,e[29]=N):N=e[29];let T;e[30]!==l.askProject||e[31]!==p||e[32]!==o||e[33]!==s?(T=l.askProject&&n.jsx(ie,{id:`${o}-project`,label:s("settings.repositories.tokenProjectLabel"),value:p,onChange:m,placeholder:s("settings.repositories.tokenProjectPlaceholder"),hint:s("settings.repositories.tokenProjectHint")}),e[30]=l.askProject,e[31]=p,e[32]=o,e[33]=s,e[34]=T):T=e[34];let y;e[35]!==s?(y=s("settings.repositories.tokenStepsTitle"),e[35]=s,e[36]=y):y=e[36];let w;e[37]!==y?(w=n.jsx("p",{className:"text-xs font-medium",children:y}),e[37]=y,e[38]=w):w=e[38];let E;if(e[39]!==l.steps||e[40]!==s){let Z;e[42]!==s?(Z=J=>n.jsx("li",{children:s(J)},J),e[42]=s,e[43]=Z):Z=e[43],E=l.steps.map(Z),e[39]=l.steps,e[40]=s,e[41]=E}else E=e[41];let _;e[44]!==E?(_=n.jsx("ol",{className:"flex flex-col gap-1 list-decimal pl-4 text-xs text-muted-foreground",children:E}),e[44]=E,e[45]=_):_=e[45];let R;e[46]!==j||e[47]!==s?(R=j&&n.jsx(O,{variant:"outline",size:"sm",className:"self-start",asChild:!0,children:n.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",children:[n.jsx(Le,{size:14}),s("settings.repositories.openProvider")]})}),e[46]=j,e[47]=s,e[48]=R):R=e[48];let D;e[49]!==_||e[50]!==R||e[51]!==w?(D=n.jsxs("div",{className:"rounded-lg border border-border/60 bg-muted/40 p-3 flex flex-col gap-2",children:[w,_,R]}),e[49]=_,e[50]=R,e[51]=w,e[52]=D):D=e[52];const q=`${o}-token`;let L;e[53]!==s?(L=s("settings.repositories.tokenLabel"),e[53]=s,e[54]=L):L=e[54];let K;e[55]!==l.placeholder||e[56]!==s?(K=s(l.placeholder),e[55]=l.placeholder,e[56]=s,e[57]=K):K=e[57];let U;e[58]!==q||e[59]!==L||e[60]!==K||e[61]!==h?(U=n.jsx(ie,{id:q,label:L,value:h,onChange:x,placeholder:K,type:"password"}),e[58]=q,e[59]=L,e[60]=K,e[61]=h,e[62]=U):U=e[62];let W;e[63]!==D||e[64]!==U||e[65]!==C||e[66]!==N||e[67]!==T?(W=n.jsxs("div",{className:"flex flex-col gap-3",children:[C,N,T,D,U]}),e[63]=D,e[64]=U,e[65]=C,e[66]=N,e[67]=T,e[68]=W):W=e[68];const De=c.isPending;let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx(ae,{size:16}),e[69]=ee):ee=e[69];let M;e[70]!==s?(M=s("settings.repositories.back"),e[70]=s,e[71]=M):M=e[71];let B;e[72]!==c.isPending||e[73]!==r||e[74]!==M?(B=n.jsxs(O,{variant:"ghost",size:"sm",onClick:r,disabled:De,children:[ee,M]}),e[72]=c.isPending,e[73]=r,e[74]=M,e[75]=B):B=e[75];const ce=!k||c.isPending;let Q;e[76]!==c.isPending||e[77]!==s?(Q=c.isPending?s("settings.repositories.connecting"):s("settings.repositories.connect"),e[76]=c.isPending,e[77]=s,e[78]=Q):Q=e[78];let Y;e[79]!==S||e[80]!==ce||e[81]!==Q?(Y=n.jsx(O,{onClick:S,disabled:ce,children:Q}),e[79]=S,e[80]=ce,e[81]=Q,e[82]=Y):Y=e[82];let V;e[83]!==B||e[84]!==Y?(V=n.jsxs(Pe,{className:"sm:justify-between",children:[B,Y]}),e[83]=B,e[84]=Y,e[85]=V):V=e[85];let te;return e[86]!==W||e[87]!==V?(te=n.jsxs(n.Fragment,{children:[W,V]}),e[86]=W,e[87]=V,e[88]=te):te=e[88],te}function ie(t){const e=P.c(17),{id:o,label:r,value:i,onChange:s,placeholder:l,hint:c,type:a}=t;let f;e[0]!==o||e[1]!==r?(f=n.jsx(we,{htmlFor:o,children:r}),e[0]=o,e[1]=r,e[2]=f):f=e[2];let d;e[3]!==s?(d=h=>s(h.target.value),e[3]=s,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==l||e[7]!==d||e[8]!==a||e[9]!==i?(u=n.jsx(Ce,{id:o,type:a,value:i,onChange:d,placeholder:l,autoComplete:"off"}),e[5]=o,e[6]=l,e[7]=d,e[8]=a,e[9]=i,e[10]=u):u=e[10];let p;e[11]!==c?(p=c&&n.jsx("p",{className:"text-xs text-muted-foreground",children:c}),e[11]=c,e[12]=p):p=e[12];let m;return e[13]!==f||e[14]!==u||e[15]!==p?(m=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[f,u,p]}),e[13]=f,e[14]=u,e[15]=p,e[16]=m):m=e[16],m}function ze(t){const e=P.c(3),{provider:o,className:r}=t;let i;return e[0]!==r||e[1]!==o?(i=n.jsx(me,{provider:o,size:16,className:r}),e[0]=r,e[1]=o,e[2]=i):i=e[2],i}function xe(t){const e=P.c(8),{account:o,className:r}=t;let i;e[0]!==o.avatarUrl?(i=o.avatarUrl?.trim()||void 0,e[0]=o.avatarUrl,e[1]=i):i=e[1];let s;e[2]!==o.type?(s=n.jsx(ze,{provider:o.type,className:"text-muted-foreground"}),e[2]=o.type,e[3]=s):s=e[3];let l;return e[4]!==r||e[5]!==i||e[6]!==s?(l=n.jsx(Ie,{url:i,fallback:s,shape:"circle",size:"sm",className:r,muted:!0}),e[4]=r,e[5]=i,e[6]=s,e[7]=l):l=e[7],l}function jt(t){return(t??[]).filter(e=>e.status==="active"&&e.servable)}function Re(t){const e=P.c(12),{title:o,accounts:r,onSelect:i,disabled:s}=t;let l;e[0]!==o?(l=n.jsx("p",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:o}),e[0]=o,e[1]=l):l=e[1];let c;if(e[2]!==r||e[3]!==s||e[4]!==i){let f;e[6]!==s||e[7]!==i?(f=d=>n.jsxs("button",{type:"button",onClick:()=>i(d),disabled:s,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-accent transition-colors focus-visible:outline-none focus-visible:bg-accent disabled:opacity-50",children:[n.jsx(xe,{account:d,className:"size-8"}),n.jsxs("span",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium truncate",children:d.login}),n.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:d.host})]}),n.jsx(X,{size:16,className:"text-muted-foreground"})]},d.id),e[6]=s,e[7]=i,e[8]=f):f=e[8],c=r.map(f),e[2]=r,e[3]=s,e[4]=i,e[5]=c}else c=e[5];let a;return e[9]!==l||e[10]!==c?(a=n.jsxs("div",{className:"py-2",children:[l,c]}),e[9]=l,e[10]=c,e[11]=a):a=e[11],a}const Ae={storefront:{icon:Be,title:"common.createSite.templates.storefront.title",description:"common.createSite.templates.storefront.description"},blog:{icon:Me,title:"common.createSite.templates.blog.title",description:"common.createSite.templates.blog.description"}};function Wt(t){return Ae[t].title}function yt(t){const e=P.c(41),{accounts:o,pending:r,onExit:i,onCreate:s}=t,l=I();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"template"},e[0]=c):c=e[0];const[a,f]=$.useState(c);let d;e[1]!==i||e[2]!==a.kind||e[3]!==a.template?(d=function(){a.kind==="template"?i():a.kind==="account"?f({kind:"template"}):f({kind:"account",template:a.template})},e[1]=i,e[2]=a.kind,e[3]=a.template,e[4]=d):d=e[4];const u=d;let p;e[5]!==l?(p=l("common.repositoryPicker.back"),e[5]=l,e[6]=p):p=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ae,{size:16}),e[7]=m):m=e[7];let h;e[8]!==u||e[9]!==r||e[10]!==p?(h=n.jsx(O,{size:"icon-xs",variant:"ghost",className:"-ml-1",disabled:r,onClick:u,"aria-label":p,children:m}),e[8]=u,e[9]=r,e[10]=p,e[11]=h):h=e[11];let x;e[12]!==l?(x=l("common.createSite.entry"),e[12]=l,e[13]=x):x=e[13];let g;e[14]!==x?(g=n.jsx("span",{className:"text-sm font-medium truncate",children:x}),e[14]=x,e[15]=g):g=e[15];let k;e[16]!==h||e[17]!==g?(k=n.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 pr-12 gap-3 shrink-0",children:[h,g]}),e[16]=h,e[17]=g,e[18]=k):k=e[18];let b;e[19]!==a.kind||e[20]!==l?(b=a.kind==="template"&&n.jsxs("div",{className:"py-2",children:[n.jsx("p",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:l("common.createSite.templateSection")}),Ve.map(N=>{const{id:T}=N,y=Ae[T],w=y.icon;return n.jsxs("button",{type:"button",onClick:()=>f({kind:"account",template:T}),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-accent transition-colors focus-visible:outline-none focus-visible:bg-accent",children:[n.jsx("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center shrink-0",children:n.jsx(w,{size:16,className:"text-muted-foreground"})}),n.jsxs("span",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium truncate",children:l(y.title)}),n.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:l(y.description)})]}),n.jsx(X,{size:16,className:"shrink-0 text-muted-foreground"})]},T)})]}),e[19]=a.kind,e[20]=l,e[21]=b):b=e[21];let j;e[22]!==o||e[23]!==r||e[24]!==a.kind||e[25]!==a.template||e[26]!==l?(j=a.kind==="account"&&n.jsxs(n.Fragment,{children:[o.length>0?n.jsx(Re,{title:l("common.createSite.accountSection"),accounts:o,onSelect:N=>f({kind:"name",template:a.template,account:N}),disabled:r}):n.jsx("p",{className:"px-4 pt-4 pb-2 text-sm text-muted-foreground",children:l("common.createSite.noGithubAccount")}),n.jsxs("div",{className:"border-t border-border py-2",children:[n.jsx("p",{className:"px-4 py-2 text-xs text-muted-foreground leading-relaxed",children:l("common.createSite.accountHint")}),n.jsx($e,{layout:"picker",disabled:r})]})]}),e[22]=o,e[23]=r,e[24]=a.kind,e[25]=a.template,e[26]=l,e[27]=j):j=e[27];let v;e[28]!==s||e[29]!==r||e[30]!==a.account||e[31]!==a.kind||e[32]!==a.template?(v=a.kind==="name"&&n.jsx(vt,{account:a.account,pending:r,onSubmit:N=>s({template:a.template,account:a.account,name:N})}),e[28]=s,e[29]=r,e[30]=a.account,e[31]=a.kind,e[32]=a.template,e[33]=v):v=e[33];let S;e[34]!==j||e[35]!==v||e[36]!==b?(S=n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[b,j,v]}),e[34]=j,e[35]=v,e[36]=b,e[37]=S):S=e[37];let C;return e[38]!==S||e[39]!==k?(C=n.jsxs(n.Fragment,{children:[k,S]}),e[38]=S,e[39]=k,e[40]=C):C=e[40],C}function vt(t){const e=P.c(53),{account:o,pending:r,onSubmit:i}=t,s=I(),[l,c]=$.useState("");let a;e[0]!==l?(a=Je.safeParse(l),e[0]=l,e[1]=a):a=e[1];const f=a,d=l.length>0&&!f.success;let u;e[2]!==i||e[3]!==f.data||e[4]!==f.success||e[5]!==r?(u=function(L){L.preventDefault(),f.success&&!r&&i(f.data)},e[2]=i,e[3]=f.data,e[4]=f.success,e[5]=r,e[6]=u):u=e[6];const p=u;let m;e[7]!==o?(m=n.jsx(xe,{account:o,className:"size-6"}),e[7]=o,e[8]=m):m=e[8];let h;e[9]!==o.login?(h=n.jsx("span",{className:"font-medium truncate",children:o.login}),e[9]=o.login,e[10]=h):h=e[10];let x;e[11]!==m||e[12]!==h?(x=n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[m,h]}),e[11]=m,e[12]=h,e[13]=x):x=e[13];let g;e[14]!==s?(g=s("common.createSite.nameLabel"),e[14]=s,e[15]=g):g=e[15];let k;e[16]!==g?(k=n.jsx(we,{htmlFor:"create-site-name",children:g}),e[16]=g,e[17]=k):k=e[17];let b;e[18]!==s?(b=s("common.createSite.namePlaceholder"),e[18]=s,e[19]=b):b=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=q=>c(q.target.value.toLowerCase().replace(/[\s_]+/g,"-")),e[20]=j):j=e[20];let v;e[21]!==l||e[22]!==r||e[23]!==d||e[24]!==b?(v=n.jsx(Ce,{id:"create-site-name",autoFocus:!0,autoComplete:"off",spellCheck:!1,value:l,disabled:r,placeholder:b,"aria-invalid":d,onChange:j}),e[21]=l,e[22]=r,e[23]=d,e[24]=b,e[25]=v):v=e[25];const S=d?"text-destructive":"text-muted-foreground";let C;e[26]!==S?(C=fe("text-xs",S),e[26]=S,e[27]=C):C=e[27];let N;e[28]!==o.login||e[29]!==l||e[30]!==d||e[31]!==s?(N=d?s("common.createSite.nameInvalid"):s("common.createSite.nameHint",{path:`${o.login}/${l.trim()||s("common.createSite.namePlaceholder")}`}),e[28]=o.login,e[29]=l,e[30]=d,e[31]=s,e[32]=N):N=e[32];let T;e[33]!==C||e[34]!==N?(T=n.jsx("p",{className:C,children:N}),e[33]=C,e[34]=N,e[35]=T):T=e[35];let y;e[36]!==v||e[37]!==T||e[38]!==k?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[k,v,T]}),e[36]=v,e[37]=T,e[38]=k,e[39]=y):y=e[39];const w=!f.success||r;let E;e[40]!==r?(E=r&&n.jsx(he,{className:"size-4"}),e[40]=r,e[41]=E):E=e[41];let _;e[42]!==s?(_=s("common.createSite.create"),e[42]=s,e[43]=_):_=e[43];let R;e[44]!==w||e[45]!==E||e[46]!==_?(R=n.jsxs(O,{type:"submit",disabled:w,children:[E,_]}),e[44]=w,e[45]=E,e[46]=_,e[47]=R):R=e[47];let D;return e[48]!==p||e[49]!==y||e[50]!==R||e[51]!==x?(D=n.jsxs("form",{onSubmit:p,className:"p-4 flex flex-col gap-4",children:[x,y,R]}),e[48]=p,e[49]=y,e[50]=R,e[51]=x,e[52]=D):D=e[52],D}const Nt="create-site";function Oe(t){const e=P.c(20),{provider:o,path:r,host:i,hint:s,disabled:l,busy:c,onSelect:a}=t,f=l&&"opacity-60 cursor-not-allowed";let d;e[0]!==f?(d=fe("w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-accent transition-colors focus-visible:outline-none focus-visible:bg-accent",f),e[0]=f,e[1]=d):d=e[1];let u;e[2]!==o?(u=n.jsx("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center shrink-0",children:n.jsx(ze,{provider:o,className:"text-muted-foreground"})}),e[2]=o,e[3]=u):u=e[3];let p;e[4]!==r?(p=n.jsx("span",{className:"block text-sm font-medium truncate",children:r}),e[4]=r,e[5]=p):p=e[5];const m=s?`${i} ยท ${s}`:i;let h;e[6]!==m?(h=n.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:m}),e[6]=m,e[7]=h):h=e[7];let x;e[8]!==p||e[9]!==h?(x=n.jsxs("span",{className:"flex-1 min-w-0",children:[p,h]}),e[8]=p,e[9]=h,e[10]=x):x=e[10];let g;e[11]!==c?(g=c?n.jsx(he,{className:"size-4 text-muted-foreground"}):n.jsx(X,{size:16,className:"shrink-0 text-muted-foreground"}),e[11]=c,e[12]=g):g=e[12];let k;return e[13]!==l||e[14]!==a||e[15]!==d||e[16]!==u||e[17]!==x||e[18]!==g?(k=n.jsxs("button",{type:"button",disabled:l,onClick:a,className:d,children:[u,x,g]}),e[13]=l,e[14]=a,e[15]=d,e[16]=u,e[17]=x,e[18]=g,e[19]=k):k=e[19],k}function St(t){const e=P.c(25),{onPick:o,pendingPath:r}=t,i=I(),s=lt(),[l,c]=$.useState("");if(s.isPending){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(oe,{className:"h-24 w-full"}),e[0]=d):d=e[0],d}if(s.isError){let d;return e[1]!==s.error.message?(d=n.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:s.error.message}),e[1]=s.error.message,e[2]=d):d=e[2],d}let a,f;if(e[3]!==o||e[4]!==r||e[5]!==l||e[6]!==s.data||e[7]!==i){f=Symbol.for("react.early_return_sentinel");e:{const d=s.data??[];if(d.length===0){f=null;break e}let u;e[10]!==l?(u=j=>j.path.toLowerCase().includes(l.trim().toLowerCase()),e[10]=l,e[11]=u):u=e[11];const p=d.filter(u);let m;e[12]!==i?(m=i("common.repositoryPicker.searchPlaceholder"),e[12]=i,e[13]=m):m=e[13];const h=r!==null;let x;e[14]!==l||e[15]!==m||e[16]!==h?(x=n.jsx(Te,{value:l,onChange:c,placeholder:m,disabled:h}),e[14]=l,e[15]=m,e[16]=h,e[17]=x):x=e[17];let g;e[18]!==i?(g=i("common.repositoryPicker.linkedSection"),e[18]=i,e[19]=g):g=e[19];let k;e[20]!==g?(k=n.jsx("p",{className:"px-4 pt-4 pb-2 text-xs font-medium text-muted-foreground",children:g}),e[20]=g,e[21]=k):k=e[21];let b;e[22]!==o||e[23]!==r?(b=j=>n.jsx(Oe,{provider:j.provider,path:j.path,host:j.host,hint:j.defaultBranch,disabled:r!==null,busy:r===j.id,onSelect:()=>o(j)},j.id),e[22]=o,e[23]=r,e[24]=b):b=e[24],a=n.jsxs("div",{className:"pb-2",children:[x,k,p.length===0&&n.jsx("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:i("common.repositoryPicker.searchEmpty")}),p.map(b)]})}e[3]=o,e[4]=r,e[5]=l,e[6]=s.data,e[7]=i,e[8]=a,e[9]=f}else a=e[8],f=e[9];return f!==Symbol.for("react.early_return_sentinel")?f:a}function Pt(t){const e=P.c(35),{account:o,onLink:r,pendingPath:i}=t,s=I(),[l,c]=$.useState(""),a=Qe(l,300),f=$.useDeferredValue(a),d=l!==f,u=at(o.id,f);let p,m,h,x;if(e[0]!==d||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==u.data?.pages||e[5]!==u.error||e[6]!==u.hasNextPage||e[7]!==u.isError||e[8]!==u.isFetching||e[9]!==u.isPending||e[10]!==s){const j=u.data?.pages.flatMap(Ct)??[];h="h-80 min-h-0 flex flex-col overflow-hidden";let v;e[15]!==s?(v=s("common.repositoryPicker.searchPlaceholder"),e[15]=s,e[16]=v):v=e[16];const S=d||u.isFetching;e[17]!==l||e[18]!==v||e[19]!==S?(x=n.jsx(Te,{placeholder:v,value:l,onChange:c,isSearching:S}),e[17]=l,e[18]=v,e[19]=S,e[20]=x):x=e[20];const C=d?"opacity-40":"opacity-100";e[21]!==C?(p=fe("flex-1 overflow-y-auto transition-opacity duration-150",C),e[21]=C,e[22]=p):p=e[22],m=u.isPending?n.jsx("div",{className:"flex-1 flex items-center justify-center py-10",children:n.jsx(he,{className:"size-4.5 text-muted-foreground"})}):u.isError?n.jsx("p",{className:"px-4 py-10 text-center text-sm text-muted-foreground",children:u.error instanceof Error?u.error.message:s("common.repositoryPicker.searchFailed")}):j.length===0?n.jsx("p",{className:"px-4 py-10 text-center text-sm text-muted-foreground",children:s(u.hasNextPage?"common.repositoryPicker.searchMore":"common.repositoryPicker.searchEmpty")}):j.map(N=>n.jsx(Oe,{provider:N.ref.provider,path:N.ref.path,host:N.ref.host,hint:N.visibility,disabled:i!==null,busy:i===N.ref.path,onSelect:()=>r(N.webUrl,N.ref.path)},`${N.ref.host}/${N.ref.path}`)),e[0]=d,e[1]=r,e[2]=i,e[3]=l,e[4]=u.data?.pages,e[5]=u.error,e[6]=u.hasNextPage,e[7]=u.isError,e[8]=u.isFetching,e[9]=u.isPending,e[10]=s,e[11]=p,e[12]=m,e[13]=h,e[14]=x}else p=e[11],m=e[12],h=e[13],x=e[14];let g;e[23]!==i||e[24]!==u||e[25]!==s?(g=u.hasNextPage&&n.jsx(O,{variant:"ghost",className:"w-full",disabled:u.isFetchingNextPage||i!==null,onClick:()=>{u.fetchNextPage()},children:s("common.repositoryPicker.loadMore")}),e[23]=i,e[24]=u,e[25]=s,e[26]=g):g=e[26];let k;e[27]!==p||e[28]!==m||e[29]!==g?(k=n.jsxs("div",{className:p,children:[m,g]}),e[27]=p,e[28]=m,e[29]=g,e[30]=k):k=e[30];let b;return e[31]!==h||e[32]!==x||e[33]!==k?(b=n.jsxs("div",{className:h,children:[x,k]}),e[31]=h,e[32]=x,e[33]=k,e[34]=b):b=e[34],b}function Ct(t){return t.repositories}function Mt({open:t,onOpenChange:e,title:o,onPicked:r,onError:i,allowCreateSite:s=!1}){const l=I(),c=rt(),a=pt(),f=ft(),d=Ye("site_create_enabled")&&s,[u,p]=$.useState(null),[m,h]=$.useState(!1),[x,g]=$.useState(null),[k,b]=$.useState(null),j=jt(c.data),v=j.filter(y=>y.type==="github");function S(y){const w=y instanceof Error?y.message:l("common.repositoryPicker.linkFailed");b(w),i?.(w)}async function C(y){g(y.id),b(null);try{await r({repository:y})}catch(w){S(w)}finally{g(null)}}async function N(y,w){if(u){g(w),b(null);try{const E=await a.mutateAsync({url:y,accountId:u.id});await r({repository:E})}catch(E){S(E)}finally{g(null)}}}async function T({template:y,account:w,name:E}){g(Nt),b(null);try{const _=await f.mutateAsync({accountId:w.id,name:E,template:y});await r({repository:_,createdFromTemplate:y})}catch(_){S(_)}finally{g(null)}}return n.jsx(je,{open:t,onOpenChange:y=>{x===null&&(y||(p(null),h(!1),b(null)),e(y))},children:n.jsxs(ye,{className:"sm:max-w-lg max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[n.jsxs(ve,{className:"sr-only",children:[n.jsx(Ne,{children:o}),n.jsx(Se,{children:l("common.repositoryPicker.description")})]}),m?n.jsx(yt,{accounts:v,pending:x!==null,onExit:()=>{h(!1),b(null)},onCreate:y=>{T(y)}}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 pr-12 gap-3 shrink-0",children:[u?n.jsx(O,{size:"icon-xs",variant:"ghost",className:"-ml-1",disabled:x!==null,onClick:()=>p(null),"aria-label":l("common.repositoryPicker.back"),children:n.jsx(ae,{size:16})}):n.jsx(He,{size:16,className:"text-muted-foreground shrink-0"}),u&&n.jsx(xe,{account:u,className:"size-6"}),n.jsx("span",{className:"text-sm font-medium truncate",children:u?u.login:o})]}),c.isPending?n.jsx("div",{className:"p-4",children:n.jsx(oe,{className:"h-24 w-full"})}):c.isError?n.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:c.error.message}):u?n.jsx(Pt,{account:u,onLink:(y,w)=>{N(y,w)},pendingPath:x},u.id):n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d&&n.jsx("div",{className:"border-b border-border py-2",children:n.jsxs("button",{type:"button",disabled:x!==null,onClick:()=>{h(!0),b(null)},className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-accent transition-colors focus-visible:outline-none focus-visible:bg-accent disabled:opacity-50",children:[n.jsx("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center shrink-0",children:n.jsx(ue,{size:16,className:"text-muted-foreground"})}),n.jsxs("span",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium truncate",children:l("common.createSite.entry")}),n.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:l("common.createSite.entryHint")})]}),n.jsx(X,{size:16,className:"shrink-0 text-muted-foreground"})]})}),n.jsx(St,{onPick:C,pendingPath:x}),j.length>0&&n.jsx(Re,{title:l("common.repositoryPicker.browseSection"),accounts:j,onSelect:p,disabled:x!==null}),n.jsxs("div",{className:"border-t border-border py-2",children:[n.jsx("p",{className:"px-4 py-2 text-xs text-muted-foreground leading-relaxed",children:l("common.repositoryPicker.description")}),n.jsx($e,{layout:"picker",disabled:x!==null})]})]})]}),k&&n.jsx("p",{role:"alert",className:"px-4 pb-3 text-sm text-destructive",children:k})]})})}export{Ee as D,me as G,Mt as R,Kt as a,Gt as b,ot as c,rt as d,qt as e,Ut as f,_e as g,$e as h,It as p,Ht as r,Wt as t,lt as u};