@snagset/server 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/app.js +5 -0
  2. package/dist/app.js.map +1 -1
  3. package/dist/config.generated.js +2 -1
  4. package/dist/config.generated.js.map +1 -1
  5. package/package.json +1 -1
  6. package/static/dashboard/assets/CompositeItem-B_Ebe9qQ.js +1 -0
  7. package/static/dashboard/assets/CompositeList-CDAPQTbv.js +1 -0
  8. package/static/dashboard/assets/{ConfirmDialog-D7eZU5Z6.js → ConfirmDialog-D1II2uNE.js} +1 -1
  9. package/static/dashboard/assets/{CopyButton-_X7ITEaj.js → CopyButton-qbA2ZHWn.js} +1 -1
  10. package/static/dashboard/assets/{FieldItemContext-BgajCxI_.js → FieldItemContext-BM_KzVUj.js} +1 -1
  11. package/static/dashboard/assets/{InstallTag-Bxq5AWM0.js → InstallTag-DTpNoMn9.js} +1 -1
  12. package/static/dashboard/assets/InstanceRows-B1z-L92-.js +1 -0
  13. package/static/dashboard/assets/{McpTokens-D_0BEsPb.js → McpTokens-DE2t0iiS.js} +1 -1
  14. package/static/dashboard/assets/{SaveState-WYxHW3VJ.js → SaveState-QQHqDSgx.js} +1 -1
  15. package/static/dashboard/assets/_app-B_DiSFIt.js +61 -0
  16. package/static/dashboard/assets/{_app-Bv20PwQa.js → _app-CaDt6CPJ.js} +1 -1
  17. package/static/dashboard/assets/{activity-Ch0XQ9sf.js → activity-CzEy_J8-.js} +1 -1
  18. package/static/dashboard/assets/{arrow-left-BVcH0ZD5.js → arrow-left-RqdORgcq.js} +1 -1
  19. package/static/dashboard/assets/avatar-D8S5EME4.js +1 -0
  20. package/static/dashboard/assets/{badge-D4-0NV1D.js → badge-anHWhPFa.js} +1 -1
  21. package/static/dashboard/assets/{card-_fRmCPLn.js → card-C01exIzZ.js} +1 -1
  22. package/static/dashboard/assets/{check-BTd2LoGN.js → check-Gm9Xu4rH.js} +1 -1
  23. package/static/dashboard/assets/chevron-down-C-pVPOKU.js +6 -0
  24. package/static/dashboard/assets/{chevron-right-Co0UMSkz.js → chevron-right-BQmYcugl.js} +1 -1
  25. package/static/dashboard/assets/{copy-CEpGdeGb.js → copy-Ckk__4oN.js} +1 -1
  26. package/static/dashboard/assets/{dialog-C7r1DbuZ.js → dialog-D5G50pSW.js} +2 -2
  27. package/static/dashboard/assets/dropdown-menu-Bm_opJ2p.js +11 -0
  28. package/static/dashboard/assets/{forgot-nTWEgSRm.js → forgot-R7JqXxs5.js} +1 -1
  29. package/static/dashboard/assets/{image-off-DP5YbLdB.js → image-off-BtbHLgOM.js} +1 -1
  30. package/static/dashboard/assets/index-CoiIx5MR.css +1 -0
  31. package/static/dashboard/assets/{index-Ddw_j6S-.js → index-p-qD6BlY.js} +21 -21
  32. package/static/dashboard/assets/{invite-CHU_LQYP.js → invite-9eotNL9V.js} +1 -1
  33. package/static/dashboard/assets/label-CuvYMIVd.js +1 -0
  34. package/static/dashboard/assets/{labels-BuZpvtvw.js → labels-DLMjYGNJ.js} +1 -1
  35. package/static/dashboard/assets/{layout-grid-DpWj1k0D.js → layout-grid-D5ek58h7.js} +1 -1
  36. package/static/dashboard/assets/{parts-DuhvDJGT.js → parts-CN1uQywE.js} +1 -1
  37. package/static/dashboard/assets/{plus-fom7ulPf.js → plus-BsxOLtMA.js} +1 -1
  38. package/static/dashboard/assets/{reset-CQMD1ToU.js → reset-8K76tpdp.js} +1 -1
  39. package/static/dashboard/assets/s._site-egkPDOj9.js +1 -0
  40. package/static/dashboard/assets/s._site.comments-DmrtKLHb.js +49 -0
  41. package/static/dashboard/assets/s._site.reviewers-CGKj-NQo.js +1 -0
  42. package/static/dashboard/assets/s._site.settings-DvWbfMac.js +1 -0
  43. package/static/dashboard/assets/serializeValue-DRMAHja_.js +1 -0
  44. package/static/dashboard/assets/{setup-nee74nI7.js → setup-BDZJmgIB.js} +1 -1
  45. package/static/dashboard/assets/{sign-in-DJSdsL9I.js → sign-in-BmweKwDv.js} +1 -1
  46. package/static/dashboard/assets/{sign-up-DeQDeqC_.js → sign-up-C06mQl-c.js} +1 -1
  47. package/static/dashboard/assets/{sites-l8LQQwZW.js → sites-CkGgns1o.js} +1 -1
  48. package/static/dashboard/assets/{studio-CL5TjGsb.js → studio-BHpeuJSq.js} +1 -1
  49. package/static/dashboard/assets/studio-CG1QMBSK.js +1 -0
  50. package/static/dashboard/assets/studio.index-BOkmM7I5.js +1 -0
  51. package/static/dashboard/assets/{studio.integrations-BLkBekJf.js → studio.integrations-BBik3DdK.js} +1 -1
  52. package/static/dashboard/assets/studio.members-CEKrbJHp.js +11 -0
  53. package/static/dashboard/assets/studio.plan-CkOzUaJM.js +1 -0
  54. package/static/dashboard/assets/{sun-C6_OdtRI.js → sun-DXwtJyi5.js} +1 -1
  55. package/static/dashboard/assets/switch-cgJL6ATv.js +1 -0
  56. package/static/dashboard/assets/{table-WdFx8YPW.js → table-B8VTYpZO.js} +1 -1
  57. package/static/dashboard/assets/{useAriaLabelledBy-CYXdXCKz.js → useAriaLabelledBy-BT5NtL2E.js} +1 -1
  58. package/static/dashboard/assets/{useBaseQuery-bYBwKcW7.js → useBaseQuery-DaFWLbWu.js} +1 -1
  59. package/static/dashboard/assets/useQuery-D-9vXtOo.js +1 -0
  60. package/static/dashboard/assets/useRender-BBzDGtxq.js +1 -0
  61. package/static/dashboard/assets/{useValueChanged-DCX5-3sY.js → useValueChanged-cwqHWzY1.js} +1 -1
  62. package/static/dashboard/assets/{users-BSiXsvcu.js → users-CGY0g3mg.js} +1 -1
  63. package/static/dashboard/assets/{welcome-C96YFTXf.js → welcome-CNtwDQMd.js} +1 -1
  64. package/static/dashboard/assets/{widget-signin-DIvRFGYL.js → widget-signin-BOUMPGXt.js} +1 -1
  65. package/static/dashboard/assets/{you-CNN1L9wO.js → you-DH4QMiND.js} +1 -1
  66. package/static/dashboard/assets/{zod-BXAKx0ML.js → zod-DfHlfdUJ.js} +1 -1
  67. package/static/dashboard/index.html +2 -2
  68. package/static/widget/build.json +2 -2
  69. package/static/widget/snag.js +1 -1
  70. package/static/widget/snag.runtime.js +1 -1
  71. package/static/dashboard/assets/CompositeItem-CP7pxc5U.js +0 -1
  72. package/static/dashboard/assets/_app-C4LQnv_m.js +0 -56
  73. package/static/dashboard/assets/avatar-B4uC-2Rd.js +0 -1
  74. package/static/dashboard/assets/dropdown-menu-Clnp0fwC.js +0 -11
  75. package/static/dashboard/assets/index-Do3jpVIF.css +0 -1
  76. package/static/dashboard/assets/label-CeY5IHdJ.js +0 -1
  77. package/static/dashboard/assets/s._site-XzH7h0kY.js +0 -1
  78. package/static/dashboard/assets/s._site.comments-D_QbkDGk.js +0 -54
  79. package/static/dashboard/assets/s._site.reviewers-DKQj9ftE.js +0 -1
  80. package/static/dashboard/assets/s._site.settings-DGhg9pWK.js +0 -1
  81. package/static/dashboard/assets/studio-CLnwa1jr.js +0 -1
  82. package/static/dashboard/assets/studio.index-D4sAU91A.js +0 -1
  83. package/static/dashboard/assets/studio.members-KzPokmYW.js +0 -6
  84. package/static/dashboard/assets/switch-CGYNLqP6.js +0 -1
  85. package/static/dashboard/assets/useQuery-CaIu0ohN.js +0 -1
  86. package/static/dashboard/assets/useRender-Rh7x0Dwc.js +0 -1
@@ -1 +1 @@
1
- import{q as U,j as e,L as ee,a4 as te,d as se,r as a,a2 as F,a3 as I,a1 as M,s as T,a6 as D,_ as ne,B as y,A as K,z as oe}from"./index-Ddw_j6S-.js";import{u as B}from"./useQuery-CaIu0ohN.js";import{B as _}from"./badge-D4-0NV1D.js";import{E,G as O,I as W,H as R,J,K as H}from"./dialog-C7r1DbuZ.js";import{L as C,I as A}from"./label-CeY5IHdJ.js";import{C as ae}from"./ConfirmDialog-D7eZU5Z6.js";import{A as re,P as ie,a as ce}from"./parts-DuhvDJGT.js";import{u as q,b as le}from"./labels-BuZpvtvw.js";import{C as z}from"./CopyButton-_X7ITEaj.js";import{M as de}from"./McpTokens-D_0BEsPb.js";import"./useBaseQuery-bYBwKcW7.js";import"./useRender-Rh7x0Dwc.js";import"./card-_fRmCPLn.js";import"./check-BTd2LoGN.js";import"./copy-CEpGdeGb.js";import"./switch-CGYNLqP6.js";import"./useAriaLabelledBy-CYXdXCKz.js";import"./useValueChanged-DCX5-3sY.js";const he={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function me(){const o=q(),i=U(o.user.role,"settings"),x=U(o.user.role,"studio")&&te(o),f=B(oe.integrations()),S=se(),w=()=>S.invalidateQueries({queryKey:["integrations"]}),[l,u]=a.useState(null),[r,g]=a.useState(null),[j,m]=a.useState(null),b=F({mutationFn:t=>T.regenerateGitHubWebhook(t),onSuccess:({webhook:t},s)=>m({site:s,provider:"github",hook:t,fresh:!1}),onError:t=>I.error(M(t))}),N=F({mutationFn:({uid:t,provider:s})=>T.testTracker(t,s).then(c=>({...c,provider:s})),onSuccess:t=>{I[t.ok?"success":"error"](t.ok?`${D[t.provider]} can see ${t.target}`:t.detail??`${D[t.provider]} refused the token`),w()},onError:t=>I.error(M(t))}),k=F({mutationFn:({uid:t,provider:s})=>T.disconnectTracker(t,s),onSuccess:()=>{g(null),w()},onError:t=>I.error(M(t))}),v=f.data?.data??[],h=t=>v.filter(s=>s.provider===t),d=t=>o.projects.filter(s=>!h(t).some(c=>c.site===s.uid));return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(ie,{title:"Integrations",sub:"Mirrors converge on the comment's status here; Slack only announces"}),["github","linear","jira","slack"].map(t=>{const s=h(t),c=d(t);return e.jsxs(ce,{title:D[t],description:t==="github"?"A comment becomes an issue in the site's repository, with the brief as its body; resolving it here closes the issue there, and closing it there resolves it here. A fine-grained token per site — no OAuth app to register.":t==="linear"?"A comment becomes an issue in the site's team, with the brief as its body; our status moves it between the team's workflow states by type, and a webhook from Linear moves it back. A personal API key per site — no OAuth app to register.":t==="jira"?"A comment becomes an issue in the site's Jira project, with the brief as its description; our status moves it through the workflow by status category, and a webhook from Jira moves it back. An API token with the account's email — what Atlassian gives a self-hoster.":"One message per comment in a channel, edited in place as the status moves — never a second message, never a reply. A bot token from an app you create in a click from our manifest; Slack sends nothing back.",children:[f.isPending&&e.jsx(ne,{rows:2}),f.isSuccess&&s.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{variant:"outline",children:"Not connected"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:t==="github"?"No site is connected to a repository yet.":t==="linear"?"No site is connected to a team yet.":t==="jira"?"No site is connected to a project yet.":"No site is connected to a channel yet."})]}),s.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:s.map(n=>{const P=he[n.health]??{label:n.health,tone:"warn"};return e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border px-3 py-2.5 text-[13px]",children:[e.jsx("span",{className:"font-medium",children:n.siteName??n.site}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("code",{className:"font-mono text-[12.5px]",children:n.provider==="github"?`${n.owner}/${n.repo}`:n.provider==="linear"?`${n.teamKey} · ${n.teamName}`:n.provider==="jira"?`${n.projectKey} · ${n.projectName}`:`#${n.channelName} · ${n.teamName}`}),e.jsx(_,{variant:"outline",className:P.tone==="ok"?"border-ok text-ok":P.tone==="bad"?"border-destructive text-destructive":"",children:P.label}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[n.provider==="slack"?n.createOn==="thread.created"?"A message for every new comment":"Messages when you ask, from the brief":n.createOn==="thread.created"?"An issue for every new comment":"Issues when you ask, from the brief",n.provider==="github"&&n.labels.length?` · labels ${n.labels.join(", ")}`:"",n.provider!=="github"&&n.provider!=="slack"&&!n.hasWebhookSecret?` · no webhook secret yet, so ${D[n.provider]} cannot move comments here`:""," · ",le(n.updatedAt)]}),n.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:n.lastError}),i&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[n.provider==="github"?e.jsx(y,{variant:"ghost",size:"sm",loading:b.isPending,onClick:()=>b.mutate(n.site),children:"Webhook…"}):n.provider==="slack"?null:e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>m({site:n.site,provider:n.provider,hook:{url:`${location.origin}/api/v1/integrations/${n.provider}/inbound`},fresh:!1}),children:"Webhook…"}),e.jsx(y,{variant:"ghost",size:"sm",loading:N.isPending,onClick:()=>N.mutate({uid:n.site,provider:n.provider}),children:"Test"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>g(n),children:"Disconnect"})]})]},`${n.provider}:${n.site}`)})}),i&&c.length>0&&e.jsx("div",{children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>u(t),children:"Connect a site…"})})]},t)}),e.jsx(de,{owner:i,instanceOwner:x,sites:o.projects}),e.jsx(ue,{open:l==="github",onOpenChange:t=>!t&&u(null),sites:d("github"),onDone:(t,s)=>{w(),s&&m({site:t,provider:"github",hook:s,fresh:!0})}}),e.jsx(xe,{open:l==="linear",onOpenChange:t=>!t&&u(null),sites:d("linear"),onDone:(t,s)=>{w(),m({site:t,provider:"linear",hook:s,fresh:!0})}}),e.jsx(fe,{open:l==="jira",onOpenChange:t=>!t&&u(null),sites:d("jira"),onDone:(t,s)=>{w(),m({site:t,provider:"jira",hook:s,fresh:!0})}}),e.jsx(ge,{open:l==="slack",onOpenChange:t=>!t&&u(null),sites:d("slack"),onDone:()=>void w()}),e.jsx(pe,{state:j,onClose:()=>m(null),siteName:t=>v.find(s=>s.site===t)?.siteName??"the site"}),e.jsx(ae,{open:r!==null,onOpenChange:t=>!t&&g(null),title:`Disconnect ${r?.siteName??"this site"} from ${r?D[r.provider]:"the tracker"}?`,description:r?.provider==="slack"?e.jsx(e.Fragment,{children:"Messages already posted stay in the channel; no new ones are posted and they stop being updated. The token is forgotten."}):e.jsx(e.Fragment,{children:"Issues already made keep their links; no new ones are made and status stops mirroring. The token is forgotten."}),confirmLabel:"Disconnect",busy:k.isPending,onConfirm:async()=>{r&&await k.mutateAsync({uid:r.site,provider:r.provider})}})]})}function ue({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(""),[b,N]=a.useState(!1),[k,v]=a.useState(""),h=F({mutationFn:s=>T.connectTracker(s,"github",{repository:l.trim(),token:r.trim(),labels:j,createOn:b?"thread.created":"manual"})}),d=S||x[0]?.uid||"",t=async s=>{s.preventDefault(),v("");try{const c=await h.mutateAsync(d);u(""),g(""),m(""),N(!1),i(!1),f(d,c.webhook&&"secret"in c.webhook?c.webhook:void 0),I.success("GitHub connected")}catch(c){v(c instanceof K?c.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void t(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to GitHub"}),e.jsxs(J,{children:["A fine-grained personal access token with ",e.jsx("b",{children:"Issues: read and write"})," on that one repository. It is checked against the repository before it is saved, and stored encrypted with this instance's secret key."]})]}),k&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:k}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-site",children:"Site"}),e.jsx("select",{id:"gh-site",value:d,onChange:s=>w(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-repo",children:"Repository"}),e.jsx(A,{id:"gh-repo",placeholder:"kilnwork/site",value:l,onChange:s=>u(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-token",children:"Token"}),e.jsx(A,{id:"gh-token",type:"password",placeholder:"github_pat_…",value:r,onChange:s=>g(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-labels",children:"Labels"}),e.jsx(A,{id:"gh-labels",placeholder:"review, bug",value:j,onChange:s=>m(s.target.value)}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Applied to every issue this makes. Optional."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:b,onChange:s=>N(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:'Off by default: a reviewer walking a site leaves twenty comments and half are "never mind". Make issues from the brief when you mean it.'})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:h.isPending,disabled:!l.trim()||!r.trim()||!d,children:h.isPending?"Checking…":"Connect"})]})]})})})}function pe({state:o,onClose:i,siteName:x}){const f=o&&"secret"in o.hook?o.hook.secret:null;return e.jsx(E,{open:o!==null,onOpenChange:S=>!S&&i(),children:e.jsxs(O,{children:[e.jsxs(W,{children:[e.jsx(R,{children:o?.fresh?"Connected — now the webhook":"Webhook for "+(o?x(o.site):"")}),e.jsx(J,{children:o?.provider==="linear"?"Issues moved in Linear move the comment here. In Linear › Settings › API › Webhooks, create one for the team with this URL and Issue events; then paste its signing secret when connecting or replacing the connection.":o?.provider==="jira"?"Issues moved in Jira move the comment here. In Jira › Settings › System › Webhooks, create one with this URL, the events Issue updated and Issue deleted, and a secret; then paste the same secret when connecting or replacing the connection.":`Issues closed or reopened on GitHub move the comment here. Add a webhook to the repository — Settings › Webhooks › Add webhook — with these values. The secret is shown this once${o?.fresh?"":", and the previous one has stopped working"}.`})]}),o&&e.jsxs("dl",{className:"m-0 grid grid-cols-[110px_1fr] gap-x-3 gap-y-2 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Payload URL"}),e.jsxs("dd",{className:"m-0 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[12px]",children:o.hook.url}),e.jsx(z,{text:o.hook.url,label:"Copy the payload URL"})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Content type"}),e.jsx("dd",{className:"m-0",children:e.jsx("code",{className:"font-mono text-[12px]",children:"application/json"})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Secret"}),e.jsxs("dd",{className:"m-0 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[12px]","data-testid":"webhook-secret",children:f}),e.jsx(z,{text:f,label:"Copy the secret"})]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Events"}),e.jsx("dd",{className:"m-0",children:o.provider==="linear"?"Issues":o.provider==="jira"?"Issue: updated, deleted":"Let me select individual events → Issues"})]}),e.jsx(H,{children:e.jsx(y,{type:"button",onClick:i,children:"Done"})})]})})}function xe({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(""),[b,N]=a.useState(!1),[k,v]=a.useState(""),h=F({mutationFn:s=>T.connectTracker(s,"linear",{team:l.trim(),apiKey:r.trim(),...j.trim()?{webhookSecret:j.trim()}:{},createOn:b?"thread.created":"manual"})}),d=S||x[0]?.uid||"",t=async s=>{s.preventDefault(),v("");try{const c=await h.mutateAsync(d);u(""),g(""),m(""),N(!1),i(!1),f(d,c.webhook??{url:`${location.origin}/api/v1/integrations/linear/inbound`}),I.success("Linear connected")}catch(c){v(c instanceof K?c.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void t(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to Linear"}),e.jsx(J,{children:"A personal API key from Linear › Settings › API, belonging to a member of the team. It is checked against the team before it is saved, and stored encrypted with this instance's secret key."})]}),k&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:k}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-site",children:"Site"}),e.jsx("select",{id:"ln-site",value:d,onChange:s=>w(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-team",children:"Team key"}),e.jsx(A,{id:"ln-team",placeholder:"ENG",value:l,onChange:s=>u(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"The prefix of the team's issues, like the ENG in ENG-123."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-key",children:"API key"}),e.jsx(A,{id:"ln-key",type:"password",placeholder:"lin_api_…",value:r,onChange:s=>g(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-secret",children:"Webhook signing secret"}),e.jsx(A,{id:"ln-secret",type:"password",placeholder:"from Linear's webhook, optional",value:j,onChange:s=>m(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Lets Linear move comments here when issues move there. The URL to give Linear is shown after connecting."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:b,onChange:s=>N(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:h.isPending,disabled:!l.trim()||!r.trim()||!d,children:h.isPending?"Checking…":"Connect"})]})]})})})}function fe({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(""),[b,N]=a.useState(""),[k,v]=a.useState(""),[h,d]=a.useState(!1),[t,s]=a.useState(""),c=F({mutationFn:p=>T.connectTracker(p,"jira",{siteUrl:l.trim(),project:r.trim(),email:j.trim(),apiToken:b.trim(),...k.trim()?{webhookSecret:k.trim()}:{},createOn:h?"thread.created":"manual"})}),n=S||x[0]?.uid||"",P=async p=>{p.preventDefault(),s("");try{const L=await c.mutateAsync(n);g(""),N(""),v(""),d(!1),i(!1),f(n,L.webhook??{url:`${location.origin}/api/v1/integrations/jira/inbound`}),I.success("Jira connected")}catch(L){s(L instanceof K?L.message:"Could not reach the server.")}},$=(p,L,V,Q,Y,X="text",G)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:`jr-${p}`,children:L}),e.jsx(A,{id:`jr-${p}`,type:X,placeholder:Y,value:V,onChange:Z=>Q(Z.target.value),autoComplete:"off"}),G&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:G})]});return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:p=>void P(p),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to Jira"}),e.jsx(J,{children:"An API token from id.atlassian.com › Security, with the email of the account it belongs to. It is checked against the project before it is saved, and stored encrypted with this instance's secret key."})]}),t&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:t}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"jr-site",children:"Site"}),e.jsx("select",{id:"jr-site",value:n,onChange:p=>w(p.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(p=>e.jsx("option",{value:p.uid,children:p.name},p.uid))})]}),$("url","Jira site",l,u,"https://kilnwork.atlassian.net"),$("project","Project key",r,g,"KAN","text","The prefix of the project's issues, like the KAN in KAN-12."),$("email","Account email",j,m,"you@kilnwork.studio","email"),$("token","API token",b,N,"","password"),$("secret","Webhook secret",k,v,"the secret you typed into Jira's webhook, optional","password","Lets Jira move comments here when issues move there. The URL to give Jira is shown after connecting."),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:h,onChange:p=>d(p.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:c.isPending,disabled:!l.trim()||!r.trim()||!j.trim()||!b.trim()||!n,children:c.isPending?"Checking…":"Connect"})]})]})})})}function ge({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(!0),[b,N]=a.useState(""),k=B({queryKey:["integrations","slack","manifest"],queryFn:()=>T.slackManifest(),enabled:o,staleTime:1/0}),v=F({mutationFn:t=>T.connectTracker(t,"slack",{channel:l.trim(),token:r.trim(),createOn:j?"thread.created":"manual"})}),h=S||x[0]?.uid||"",d=async t=>{t.preventDefault(),N("");try{await v.mutateAsync(h),u(""),g(""),m(!0),i(!1),f(h),I.success("Slack connected")}catch(s){N(s instanceof K?s.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:t=>void d(t),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to Slack"}),e.jsx(J,{children:"Create the app in your workspace from our manifest — one click, the scopes are filled in — install it, and paste its Bot User OAuth Token. The token is checked against the channel before it is saved, and stored encrypted with this instance's secret key."})]}),b&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:b}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"sl-site",children:"Site"}),e.jsx("select",{id:"sl-site",value:h,onChange:t=>w(t.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(t=>e.jsx("option",{value:t.uid,children:t.name},t.uid))})]}),e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2 text-[13px]",children:[e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block font-medium",children:"1. Create the app"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Opens api.slack.com with the manifest pasted; then Install to Workspace."})]}),e.jsx(y,{type:"button",variant:"outline",size:"sm",disabled:!k.data,render:e.jsx("a",{href:k.data?.url??"#",target:"_blank",rel:"noreferrer"}),children:"Create app…"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"sl-token",children:"2. Bot User OAuth Token"}),e.jsx(A,{id:"sl-token",type:"password",placeholder:"xoxb-…",value:r,onChange:t=>g(t.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"On the app's OAuth & Permissions page after installing."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"sl-channel",children:"3. Channel"}),e.jsx(A,{id:"sl-channel",placeholder:"#reviews",value:l,onChange:t=>u(t.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"A public channel by name; a private one needs the app invited first, then its name works too."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:j,onChange:t=>m(t.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"A message for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"On by default: a channel is where people are told. Turn it off to post from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:v.isPending,disabled:!l.trim()||!r.trim()||!h,children:v.isPending?"Checking…":"Connect"})]})]})})})}const Oe=()=>U(q().user.role,"settings")?e.jsx(me,{}):e.jsx(re,{title:"Integrations",children:e.jsxs("p",{className:"m-0",children:["Connecting a site to GitHub, Linear, Jira or Slack is done by an owner or an admin. Your own agent tokens are on"," ",e.jsx(ee,{to:"/you",className:"text-brand hover:underline",children:"You"}),"."]})});export{Oe as component};
1
+ import{q as U,j as e,L as ee,a2 as te,d as se,r as a,a4 as F,a5 as I,a1 as M,s as T,a6 as D,_ as ne,B as y,A as K,z as oe}from"./index-p-qD6BlY.js";import{u as B}from"./useQuery-D-9vXtOo.js";import{B as _}from"./badge-anHWhPFa.js";import{E,G as O,I as W,H as R,J,K as H}from"./dialog-D5G50pSW.js";import{L as C,I as A}from"./label-CuvYMIVd.js";import{C as ae}from"./ConfirmDialog-D1II2uNE.js";import{A as re,P as ie,a as ce}from"./parts-CN1uQywE.js";import{u as q,b as le}from"./labels-DLMjYGNJ.js";import{C as z}from"./CopyButton-qbA2ZHWn.js";import{M as de}from"./McpTokens-DE2t0iiS.js";import"./useBaseQuery-DaFWLbWu.js";import"./useRender-BBzDGtxq.js";import"./card-C01exIzZ.js";import"./check-Gm9Xu4rH.js";import"./copy-Ckk__4oN.js";import"./switch-cgJL6ATv.js";import"./useAriaLabelledBy-BT5NtL2E.js";import"./useValueChanged-cwqHWzY1.js";const he={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function me(){const o=q(),i=U(o.user.role,"settings"),x=U(o.user.role,"studio")&&te(o),f=B(oe.integrations()),S=se(),w=()=>S.invalidateQueries({queryKey:["integrations"]}),[l,u]=a.useState(null),[r,g]=a.useState(null),[j,m]=a.useState(null),b=F({mutationFn:t=>T.regenerateGitHubWebhook(t),onSuccess:({webhook:t},s)=>m({site:s,provider:"github",hook:t,fresh:!1}),onError:t=>I.error(M(t))}),N=F({mutationFn:({uid:t,provider:s})=>T.testTracker(t,s).then(c=>({...c,provider:s})),onSuccess:t=>{I[t.ok?"success":"error"](t.ok?`${D[t.provider]} can see ${t.target}`:t.detail??`${D[t.provider]} refused the token`),w()},onError:t=>I.error(M(t))}),k=F({mutationFn:({uid:t,provider:s})=>T.disconnectTracker(t,s),onSuccess:()=>{g(null),w()},onError:t=>I.error(M(t))}),v=f.data?.data??[],h=t=>v.filter(s=>s.provider===t),d=t=>o.projects.filter(s=>!h(t).some(c=>c.site===s.uid));return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(ie,{title:"Integrations",sub:"Mirrors converge on the comment's status here; Slack only announces"}),["github","linear","jira","slack"].map(t=>{const s=h(t),c=d(t);return e.jsxs(ce,{title:D[t],description:t==="github"?"A comment becomes an issue in the site's repository, with the brief as its body; resolving it here closes the issue there, and closing it there resolves it here. A fine-grained token per site — no OAuth app to register.":t==="linear"?"A comment becomes an issue in the site's team, with the brief as its body; our status moves it between the team's workflow states by type, and a webhook from Linear moves it back. A personal API key per site — no OAuth app to register.":t==="jira"?"A comment becomes an issue in the site's Jira project, with the brief as its description; our status moves it through the workflow by status category, and a webhook from Jira moves it back. An API token with the account's email — what Atlassian gives a self-hoster.":"One message per comment in a channel, edited in place as the status moves — never a second message, never a reply. A bot token from an app you create in a click from our manifest; Slack sends nothing back.",children:[f.isPending&&e.jsx(ne,{rows:2}),f.isSuccess&&s.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{variant:"outline",children:"Not connected"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:t==="github"?"No site is connected to a repository yet.":t==="linear"?"No site is connected to a team yet.":t==="jira"?"No site is connected to a project yet.":"No site is connected to a channel yet."})]}),s.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:s.map(n=>{const P=he[n.health]??{label:n.health,tone:"warn"};return e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border px-3 py-2.5 text-[13px]",children:[e.jsx("span",{className:"font-medium",children:n.siteName??n.site}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("code",{className:"font-mono text-[12.5px]",children:n.provider==="github"?`${n.owner}/${n.repo}`:n.provider==="linear"?`${n.teamKey} · ${n.teamName}`:n.provider==="jira"?`${n.projectKey} · ${n.projectName}`:`#${n.channelName} · ${n.teamName}`}),e.jsx(_,{variant:"outline",className:P.tone==="ok"?"border-ok text-ok":P.tone==="bad"?"border-destructive text-destructive":"",children:P.label}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[n.provider==="slack"?n.createOn==="thread.created"?"A message for every new comment":"Messages when you ask, from the brief":n.createOn==="thread.created"?"An issue for every new comment":"Issues when you ask, from the brief",n.provider==="github"&&n.labels.length?` · labels ${n.labels.join(", ")}`:"",n.provider!=="github"&&n.provider!=="slack"&&!n.hasWebhookSecret?` · no webhook secret yet, so ${D[n.provider]} cannot move comments here`:""," · ",le(n.updatedAt)]}),n.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:n.lastError}),i&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[n.provider==="github"?e.jsx(y,{variant:"ghost",size:"sm",loading:b.isPending,onClick:()=>b.mutate(n.site),children:"Webhook…"}):n.provider==="slack"?null:e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>m({site:n.site,provider:n.provider,hook:{url:`${location.origin}/api/v1/integrations/${n.provider}/inbound`},fresh:!1}),children:"Webhook…"}),e.jsx(y,{variant:"ghost",size:"sm",loading:N.isPending,onClick:()=>N.mutate({uid:n.site,provider:n.provider}),children:"Test"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>g(n),children:"Disconnect"})]})]},`${n.provider}:${n.site}`)})}),i&&c.length>0&&e.jsx("div",{children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>u(t),children:"Connect a site…"})})]},t)}),e.jsx(de,{owner:i,instanceOwner:x,sites:o.projects}),e.jsx(ue,{open:l==="github",onOpenChange:t=>!t&&u(null),sites:d("github"),onDone:(t,s)=>{w(),s&&m({site:t,provider:"github",hook:s,fresh:!0})}}),e.jsx(xe,{open:l==="linear",onOpenChange:t=>!t&&u(null),sites:d("linear"),onDone:(t,s)=>{w(),m({site:t,provider:"linear",hook:s,fresh:!0})}}),e.jsx(fe,{open:l==="jira",onOpenChange:t=>!t&&u(null),sites:d("jira"),onDone:(t,s)=>{w(),m({site:t,provider:"jira",hook:s,fresh:!0})}}),e.jsx(ge,{open:l==="slack",onOpenChange:t=>!t&&u(null),sites:d("slack"),onDone:()=>void w()}),e.jsx(pe,{state:j,onClose:()=>m(null),siteName:t=>v.find(s=>s.site===t)?.siteName??"the site"}),e.jsx(ae,{open:r!==null,onOpenChange:t=>!t&&g(null),title:`Disconnect ${r?.siteName??"this site"} from ${r?D[r.provider]:"the tracker"}?`,description:r?.provider==="slack"?e.jsx(e.Fragment,{children:"Messages already posted stay in the channel; no new ones are posted and they stop being updated. The token is forgotten."}):e.jsx(e.Fragment,{children:"Issues already made keep their links; no new ones are made and status stops mirroring. The token is forgotten."}),confirmLabel:"Disconnect",busy:k.isPending,onConfirm:async()=>{r&&await k.mutateAsync({uid:r.site,provider:r.provider})}})]})}function ue({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(""),[b,N]=a.useState(!1),[k,v]=a.useState(""),h=F({mutationFn:s=>T.connectTracker(s,"github",{repository:l.trim(),token:r.trim(),labels:j,createOn:b?"thread.created":"manual"})}),d=S||x[0]?.uid||"",t=async s=>{s.preventDefault(),v("");try{const c=await h.mutateAsync(d);u(""),g(""),m(""),N(!1),i(!1),f(d,c.webhook&&"secret"in c.webhook?c.webhook:void 0),I.success("GitHub connected")}catch(c){v(c instanceof K?c.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void t(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to GitHub"}),e.jsxs(J,{children:["A fine-grained personal access token with ",e.jsx("b",{children:"Issues: read and write"})," on that one repository. It is checked against the repository before it is saved, and stored encrypted with this instance's secret key."]})]}),k&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:k}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-site",children:"Site"}),e.jsx("select",{id:"gh-site",value:d,onChange:s=>w(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-repo",children:"Repository"}),e.jsx(A,{id:"gh-repo",placeholder:"kilnwork/site",value:l,onChange:s=>u(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-token",children:"Token"}),e.jsx(A,{id:"gh-token",type:"password",placeholder:"github_pat_…",value:r,onChange:s=>g(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-labels",children:"Labels"}),e.jsx(A,{id:"gh-labels",placeholder:"review, bug",value:j,onChange:s=>m(s.target.value)}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Applied to every issue this makes. Optional."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:b,onChange:s=>N(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:'Off by default: a reviewer walking a site leaves twenty comments and half are "never mind". Make issues from the brief when you mean it.'})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:h.isPending,disabled:!l.trim()||!r.trim()||!d,children:h.isPending?"Checking…":"Connect"})]})]})})})}function pe({state:o,onClose:i,siteName:x}){const f=o&&"secret"in o.hook?o.hook.secret:null;return e.jsx(E,{open:o!==null,onOpenChange:S=>!S&&i(),children:e.jsxs(O,{children:[e.jsxs(W,{children:[e.jsx(R,{children:o?.fresh?"Connected — now the webhook":"Webhook for "+(o?x(o.site):"")}),e.jsx(J,{children:o?.provider==="linear"?"Issues moved in Linear move the comment here. In Linear › Settings › API › Webhooks, create one for the team with this URL and Issue events; then paste its signing secret when connecting or replacing the connection.":o?.provider==="jira"?"Issues moved in Jira move the comment here. In Jira › Settings › System › Webhooks, create one with this URL, the events Issue updated and Issue deleted, and a secret; then paste the same secret when connecting or replacing the connection.":`Issues closed or reopened on GitHub move the comment here. Add a webhook to the repository — Settings › Webhooks › Add webhook — with these values. The secret is shown this once${o?.fresh?"":", and the previous one has stopped working"}.`})]}),o&&e.jsxs("dl",{className:"m-0 grid grid-cols-[110px_1fr] gap-x-3 gap-y-2 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Payload URL"}),e.jsxs("dd",{className:"m-0 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[12px]",children:o.hook.url}),e.jsx(z,{text:o.hook.url,label:"Copy the payload URL"})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Content type"}),e.jsx("dd",{className:"m-0",children:e.jsx("code",{className:"font-mono text-[12px]",children:"application/json"})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Secret"}),e.jsxs("dd",{className:"m-0 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[12px]","data-testid":"webhook-secret",children:f}),e.jsx(z,{text:f,label:"Copy the secret"})]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Events"}),e.jsx("dd",{className:"m-0",children:o.provider==="linear"?"Issues":o.provider==="jira"?"Issue: updated, deleted":"Let me select individual events → Issues"})]}),e.jsx(H,{children:e.jsx(y,{type:"button",onClick:i,children:"Done"})})]})})}function xe({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(""),[b,N]=a.useState(!1),[k,v]=a.useState(""),h=F({mutationFn:s=>T.connectTracker(s,"linear",{team:l.trim(),apiKey:r.trim(),...j.trim()?{webhookSecret:j.trim()}:{},createOn:b?"thread.created":"manual"})}),d=S||x[0]?.uid||"",t=async s=>{s.preventDefault(),v("");try{const c=await h.mutateAsync(d);u(""),g(""),m(""),N(!1),i(!1),f(d,c.webhook??{url:`${location.origin}/api/v1/integrations/linear/inbound`}),I.success("Linear connected")}catch(c){v(c instanceof K?c.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void t(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to Linear"}),e.jsx(J,{children:"A personal API key from Linear › Settings › API, belonging to a member of the team. It is checked against the team before it is saved, and stored encrypted with this instance's secret key."})]}),k&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:k}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-site",children:"Site"}),e.jsx("select",{id:"ln-site",value:d,onChange:s=>w(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-team",children:"Team key"}),e.jsx(A,{id:"ln-team",placeholder:"ENG",value:l,onChange:s=>u(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"The prefix of the team's issues, like the ENG in ENG-123."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-key",children:"API key"}),e.jsx(A,{id:"ln-key",type:"password",placeholder:"lin_api_…",value:r,onChange:s=>g(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-secret",children:"Webhook signing secret"}),e.jsx(A,{id:"ln-secret",type:"password",placeholder:"from Linear's webhook, optional",value:j,onChange:s=>m(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Lets Linear move comments here when issues move there. The URL to give Linear is shown after connecting."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:b,onChange:s=>N(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:h.isPending,disabled:!l.trim()||!r.trim()||!d,children:h.isPending?"Checking…":"Connect"})]})]})})})}function fe({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(""),[b,N]=a.useState(""),[k,v]=a.useState(""),[h,d]=a.useState(!1),[t,s]=a.useState(""),c=F({mutationFn:p=>T.connectTracker(p,"jira",{siteUrl:l.trim(),project:r.trim(),email:j.trim(),apiToken:b.trim(),...k.trim()?{webhookSecret:k.trim()}:{},createOn:h?"thread.created":"manual"})}),n=S||x[0]?.uid||"",P=async p=>{p.preventDefault(),s("");try{const L=await c.mutateAsync(n);g(""),N(""),v(""),d(!1),i(!1),f(n,L.webhook??{url:`${location.origin}/api/v1/integrations/jira/inbound`}),I.success("Jira connected")}catch(L){s(L instanceof K?L.message:"Could not reach the server.")}},$=(p,L,V,Q,Y,X="text",G)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:`jr-${p}`,children:L}),e.jsx(A,{id:`jr-${p}`,type:X,placeholder:Y,value:V,onChange:Z=>Q(Z.target.value),autoComplete:"off"}),G&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:G})]});return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:p=>void P(p),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to Jira"}),e.jsx(J,{children:"An API token from id.atlassian.com › Security, with the email of the account it belongs to. It is checked against the project before it is saved, and stored encrypted with this instance's secret key."})]}),t&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:t}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"jr-site",children:"Site"}),e.jsx("select",{id:"jr-site",value:n,onChange:p=>w(p.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(p=>e.jsx("option",{value:p.uid,children:p.name},p.uid))})]}),$("url","Jira site",l,u,"https://kilnwork.atlassian.net"),$("project","Project key",r,g,"KAN","text","The prefix of the project's issues, like the KAN in KAN-12."),$("email","Account email",j,m,"you@kilnwork.studio","email"),$("token","API token",b,N,"","password"),$("secret","Webhook secret",k,v,"the secret you typed into Jira's webhook, optional","password","Lets Jira move comments here when issues move there. The URL to give Jira is shown after connecting."),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:h,onChange:p=>d(p.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:c.isPending,disabled:!l.trim()||!r.trim()||!j.trim()||!b.trim()||!n,children:c.isPending?"Checking…":"Connect"})]})]})})})}function ge({open:o,onOpenChange:i,sites:x,onDone:f}){const[S,w]=a.useState(""),[l,u]=a.useState(""),[r,g]=a.useState(""),[j,m]=a.useState(!0),[b,N]=a.useState(""),k=B({queryKey:["integrations","slack","manifest"],queryFn:()=>T.slackManifest(),enabled:o,staleTime:1/0}),v=F({mutationFn:t=>T.connectTracker(t,"slack",{channel:l.trim(),token:r.trim(),createOn:j?"thread.created":"manual"})}),h=S||x[0]?.uid||"",d=async t=>{t.preventDefault(),N("");try{await v.mutateAsync(h),u(""),g(""),m(!0),i(!1),f(h),I.success("Slack connected")}catch(s){N(s instanceof K?s.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:i,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:t=>void d(t),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(W,{children:[e.jsx(R,{children:"Connect a site to Slack"}),e.jsx(J,{children:"Create the app in your workspace from our manifest — one click, the scopes are filled in — install it, and paste its Bot User OAuth Token. The token is checked against the channel before it is saved, and stored encrypted with this instance's secret key."})]}),b&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:b}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"sl-site",children:"Site"}),e.jsx("select",{id:"sl-site",value:h,onChange:t=>w(t.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:x.map(t=>e.jsx("option",{value:t.uid,children:t.name},t.uid))})]}),e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2 text-[13px]",children:[e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block font-medium",children:"1. Create the app"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Opens api.slack.com with the manifest pasted; then Install to Workspace."})]}),e.jsx(y,{type:"button",variant:"outline",size:"sm",disabled:!k.data,render:e.jsx("a",{href:k.data?.url??"#",target:"_blank",rel:"noreferrer"}),children:"Create app…"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"sl-token",children:"2. Bot User OAuth Token"}),e.jsx(A,{id:"sl-token",type:"password",placeholder:"xoxb-…",value:r,onChange:t=>g(t.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"On the app's OAuth & Permissions page after installing."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"sl-channel",children:"3. Channel"}),e.jsx(A,{id:"sl-channel",placeholder:"#reviews",value:l,onChange:t=>u(t.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"A public channel by name; a private one needs the app invited first, then its name works too."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:j,onChange:t=>m(t.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"A message for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"On by default: a channel is where people are told. Turn it off to post from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(y,{type:"submit",loading:v.isPending,disabled:!l.trim()||!r.trim()||!h,children:v.isPending?"Checking…":"Connect"})]})]})})})}const Oe=()=>U(q().user.role,"settings")?e.jsx(me,{}):e.jsx(re,{title:"Integrations",children:e.jsxs("p",{className:"m-0",children:["Connecting a site to GitHub, Linear, Jira or Slack is done by an owner or an admin. Your own agent tokens are on"," ",e.jsx(ee,{to:"/you",className:"text-brand hover:underline",children:"You"}),"."]})});export{Oe as component};
@@ -0,0 +1,11 @@
1
+ import{c as Wt,a8 as Yt,e as xe,l as xn,r as l,j as n,h as Be,i as jt,a9 as Vt,f as He,m as St,E as bn,aa as vn,ab as Gt,k as Ce,g as bt,q as Xt,ac as yn,B as Fe,ad as it,ae as Kt,a1 as kt,H as Sn,C as wn,af as Rn,ag as In,ah as jn,D as Tn,z as Lt}from"./index-p-qD6BlY.js";import{u as Ot}from"./useQuery-D-9vXtOo.js";import{u as Cn,a as An}from"./zod-DfHlfdUJ.js";import{c as Mn,d as En,e as Pn,f as Nn,i as Vn,h as kn,u as Ln,a as On,j as Dn,p as Hn,r as Fn,g as Bn,A as Un,b as _n}from"./avatar-D8S5EME4.js";import{B as zn}from"./badge-anHWhPFa.js";import{C as Jt}from"./card-C01exIzZ.js";import{L as $n,M as qn,P as Wn,N as Tt,R as Yn,O as p,v as Qt,A as pt,q as Gn,F as Xn,Q as Kn,S as Jn,w as rt,U as Qn,V as Zn,x as es,W as ts,Y as ns,Z as ss,_ as os,$ as rs,a0 as ls,a as is,a1 as as,a2 as Ct,C as cs,a3 as us,a4 as ds,X as fs,E as ps,G as ms,I as Dt,H as Ht,J as Ft,K as Bt}from"./dialog-D5G50pSW.js";import{e as gs,f as hs,h as Zt,j as en,k as Ut,l as xs,m as bs,o as vs,c as Te,n as at,p as ys,q as Ss,r as wt,a as vt,s as ws,w as Rs,v as yt,L as _t,I as Is}from"./label-CuvYMIVd.js";import{T as tn,a as nn,b as ct,c as Ie,d as sn,e as je}from"./table-B8VTYpZO.js";import{C as js}from"./ConfirmDialog-D1II2uNE.js";import{C as Ts}from"./CopyButton-qbA2ZHWn.js";import{C as on}from"./chevron-down-C-pVPOKU.js";import{C as Cs}from"./check-Gm9Xu4rH.js";import{s as Rt,i as As}from"./serializeValue-DRMAHja_.js";import{u as Ms}from"./useValueChanged-cwqHWzY1.js";import{C as Es,u as Ps,a as Ns}from"./CompositeList-CDAPQTbv.js";import{A as Vs,P as ks,b as Ls}from"./parts-CN1uQywE.js";import{u as rn,a as Os}from"./labels-DLMjYGNJ.js";import{c as Ds,d as Hs,e as Fs,f as Bs,g as Us}from"./studio-BHpeuJSq.js";import{P as _s}from"./plus-BsxOLtMA.js";import"./useBaseQuery-DaFWLbWu.js";import"./useRender-BBzDGtxq.js";import"./copy-Ckk__4oN.js";/**
2
+ * @license lucide-react v1.39.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const zs=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],$s=Wt("chevron-up",zs);/**
7
+ * @license lucide-react v1.39.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const qs=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Ws=Wt("mail",qs);function Ys(e){const{open:t=!1,onOpenChange:s,elements:o={}}=e,i=gs(),f=$n()!=null,r=Yt(()=>new qn({open:t,transitionStatus:void 0,onOpenChange:s,referenceElement:o.reference??null,floatingElement:o.floating??null,triggerElements:new Wn,floatingId:i,syncOnly:!1,nested:f})).current;return xe(()=>{const u={open:t,floatingId:i};o.reference!==void 0&&(u.referenceElement=o.reference,u.domReferenceElement=xn(o.reference)?o.reference:null),o.floating!==void 0&&(u.floatingElement=o.floating),r.update(u)},[t,i,o.reference,o.floating,r]),r.context.onOpenChange=s,r.context.nested=f,r}function Gs(e){const[t,s]=l.useState({current:e,previous:null});return Object.is(e,t.current)||s({current:e,previous:t.current}),t.previous}function Xs({className:e,...t}){return n.jsx("select",{className:Be("h-8 rounded-md border border-input bg-card px-2.5 text-[13.5px] text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50",e),...t})}function Ks(e){const t=l.useRef(!0);t.current&&(t.current=!1,e())}const ln=l.createContext(null);function be(){const e=l.useContext(ln);if(e===null)throw new Error(jt(60));return e}const Js=(e,t)=>Object.is(e,t);function Ye(e,t,s){return e==null||t==null?Object.is(e,t):s(e,t)}function lt(e,t,s){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:Ye(o,t,s))}function Qs(e,t,s){return e.filter(o=>!Ye(t,o,s))}function an(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Zs(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(an(t)){for(const s of t)for(const o of s.items)if(o&&o.value==null&&o.label!=null)return!0;return!1}for(const s of t)if(s&&s.value==null&&s.label!=null)return!0;return!1}function cn(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return Rt(e)}function We(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Rt(e.value):Rt(e)}function un(e,t,s){function o(){return cn(e,s)}if(s&&e!=null)return s(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??o();if(Array.isArray(t)){const i=t,f=an(i)?i.flatMap(r=>r.items):i;if(e==null||typeof e!="object"){const r=f.find(u=>u.value===e);return r&&r.label!=null?r.label:o()}if("value"in e){const r=f.find(u=>u&&u.value===e.value);if(r&&r.label!=null)return r.label}}return o()}function eo(e,t,s){return e.reduce((o,i,f)=>(f>0&&o.push(", "),o.push(n.jsx(l.Fragment,{children:un(i,t,s)},f)),o),[])}const d={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:s,itemToStringValue:o}=e;return t==null?!1:s&&Array.isArray(t)?t.length>0:We(t,o)!==""},hasNullItemLabel:(e,t)=>t?Zs(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const s=e.isItemEqualToValue,o=e.value;return e.multiple?Array.isArray(o)&&o.some(i=>Ye(t,i,s)):Ye(t,o,s)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function to(e,t,s=(o,i)=>o===i){return e.length===t.length&&e.every((o,i)=>s(o,t[i]))}function Ke(e,t=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,s))}const me=1;function At(e,t){return Math.max(0,e-t)}function ut(e,t){if(t<=0)return 0;const s=Ke(e,0,t),o=s,i=t-s,f=o<=me,r=i<=me;return f&&r?o<=i?0:t:f?0:r?t:s}function no(e){const{id:t,value:s,defaultValue:o=null,onValueChange:i,open:f,defaultOpen:r=!1,onOpenChange:u,name:c,form:m,autoComplete:x,disabled:b=!1,readOnly:y=!1,required:R=!1,modal:v=!0,actionsRef:D,inputRef:S,onOpenChangeComplete:_,items:N,multiple:I=!1,itemToStringLabel:j,itemToStringValue:V,isItemEqualToValue:w=Js,highlightItemOnHover:k=!0,children:W}=e,{clearErrors:O}=hs(),{setDirty:ue,setTouched:Y,setFocused:le,validityData:K,setFilled:H,name:L,disabled:J,validation:C,validationMode:ne}=Zt(),z=en({id:t}),P=J||b,a=L??c,[h,Q]=Ut({controlled:s,default:I?o??Vt:o,name:"Select",state:"value"}),[F,se]=Ut({controlled:f,default:r,name:"Select",state:"open"}),g=l.useRef([]),T=l.useRef([]),B=l.useRef(null),ee=l.useRef(null),ve=l.useRef(0),M=l.useRef(null),G=l.useRef([]),$=l.useRef(!1),de=l.useRef(null),Z=l.useRef(null),oe=l.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),re=l.useRef(!1),{mounted:ie,setMounted:fe,transitionStatus:q}=Tt(F),{openMethod:X,triggerProps:ae}=Mn(F),E=Yt(()=>new Yn({id:z,labelId:void 0,modal:v,multiple:I,itemToStringLabel:j,itemToStringValue:V,isItemEqualToValue:w,value:h,open:F,mounted:ie,transitionStatus:q,items:N,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,Ae=p(E,d.activeIndex),ye=p(E,d.selectedIndex),Se=p(E,d.triggerElement),ce=p(E,d.positionerElement),ke=Gs(X),Le=X??ke,te=l.useMemo(()=>I?"":We(h,V),[I,h,V]),mt=l.useMemo(()=>I&&Array.isArray(h)?h.map(A=>We(A,V)):We(h,V),[I,h,V]),Qe=Qt(Se),we=He(()=>mt);xs(Qe,z,h,we,!P,c);const gt=l.useRef(h),Ge=I?Array.isArray(h)&&h.length>0:h!=null&&te!=="";xe(()=>{H(Ge)},[Ge,H]),xe(function(){let U=h,Re=!1;if(I){const De=Array.isArray(h)?h:[];Re=De.length===0,U=De[De.length-1]}const Ne=Re?-1:lt(G.current,U,w),Ve=Ne===-1?null:Ne;Ve===null&&(Z.current=null),!F&&E.set("selectedIndex",Ve)},[I,F,h,w,E]);function ge(A){const U=K.initialValue;return Array.isArray(A)&&Array.isArray(U)?!to(A,U,(Re,Ne)=>Ye(Re,Ne,w)):A!==U}Ms(h,()=>{O(a),ue(ge(h)),C.change(h)});const Ue=He((A,U)=>{u?.(A,U),!U.isCanceled&&(se(A),!A&&(U.reason===bs||U.reason===vs)&&(Y(!0),le(!1),ne==="onBlur"&&C.commit(h)))}),_e=He(()=>{fe(!1),E.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});pt({enabled:!D,open:F,ref:B,onComplete(){F||_e()}}),l.useImperativeHandle(D,()=>({unmount:_e}),[_e]);const Me=He((A,U)=>{i?.(A,U),!U.isCanceled&&Q(A)}),he=He(A=>{const U=At(A.scrollHeight,A.clientHeight),Re=ut(A.scrollTop,U),Ne=Re>0,Ve=Re<U;E.set("scrollUpArrowVisible",Ne),E.set("scrollDownArrowVisible",Ve)}),Ee=Ys({open:F,onOpenChange:Ue,elements:{reference:Se,floating:ce}}),ze=En(Ee,{enabled:!y&&!P,event:"mousedown"}),$e=Gn(Ee),Pe=Pn(Ee,{enabled:!y&&!P,listRef:g,activeIndex:Ae,selectedIndex:ye,disabledIndices:Vt,onNavigate(A){A===null&&!F||E.set("activeIndex",A)},focusItemOnHover:k}),Oe=Nn(Ee,{enabled:!y&&!P&&(F||!I),listRef:T,activeIndex:Ae,selectedIndex:ye,disabledIndices:A=>As(g.current[A]),onMatch(A){F?E.set("activeIndex",A):Me(G.current[A],Te(at))},onTyping(A){$.current=A}}),Ze=l.useMemo(()=>St(Oe.reference,Pe.reference,$e.reference,ze.reference,ae),[ze.reference,Oe.reference,Pe.reference,$e.reference,ae]),et=l.useMemo(()=>St(Xn,Oe.floating,Pe.floating,$e.floating),[Oe.floating,Pe.floating,$e.floating]),tt=Pe.item??bn;Ks(()=>{E.update({popupProps:et,triggerProps:Ze})}),E.useSyncedValues({id:z,modal:v,multiple:I,value:h,open:F,mounted:ie,transitionStatus:q,popupProps:et,triggerProps:Ze,items:N,itemToStringLabel:j,itemToStringValue:V,isItemEqualToValue:w,openMethod:Le});const pe=l.useMemo(()=>({store:E,floatingContext:Ee,required:R,disabled:P,readOnly:y,multiple:I,highlightItemOnHover:k,setValue:Me,setOpen:Ue,listRef:g,popupRef:B,scrollHandlerRef:ee,handleScrollArrowVisibility:he,scrollArrowsMountedCountRef:ve,itemProps:tt,valueRef:M,valuesRef:G,labelsRef:T,typingRef:$,selectionRef:oe,firstItemTextRef:de,selectedItemTextRef:Z,validation:C,onOpenChangeComplete:_,alignItemWithTriggerActiveRef:re,initialValueRef:gt}),[E,Ee,R,P,y,I,k,Me,Ue,tt,C,_,he]),qe=vn(S,C.inputRef),Xe=I?void 0:a,ht=l.useMemo(()=>!I||!Array.isArray(h)||!a?null:h.map(A=>{const U=We(A,V);return n.jsx("input",{type:"hidden",form:m,name:a,value:U,disabled:P},U)}),[I,h,m,a,V,P]);return n.jsxs(ln.Provider,{value:pe,children:[W,n.jsx("input",{...C.getValidationProps(P,{onFocus(){E.state.triggerElement?.focus({focusVisible:!0})},onChange(A){if(A.nativeEvent.defaultPrevented||P||y)return;const U=A.currentTarget.value,Re=Te(at,A.nativeEvent);function Ne(){if(I)return;const Ve=U.toLowerCase();let De=G.current.findIndex(xt=>We(xt,V).toLowerCase()===Ve||cn(xt,j).toLowerCase()===Ve);De===-1&&(De=G.current.findIndex((xt,hn)=>{const Nt=T.current[hn];return Nt!=null&&Nt.toLowerCase()===Ve}));const Pt=G.current[De];Pt!=null&&Me(Pt,Re)}E.set("forceMount",!0),queueMicrotask(Ne)}}),id:z&&Xe==null?`${z}-hidden-input`:void 0,form:m,name:Xe,autoComplete:x,value:te,disabled:P,required:R&&!(I&&Ge),readOnly:y,ref:qe,style:a?Kn:Jn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),ht]})}function so(e,t){return e??t}const oo=400,ro={...Zn,...Ss,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},lo=l.forwardRef(function(t,s){const{render:o,className:i,id:f,disabled:r=!1,nativeButton:u=!0,style:c,...m}=t,{setTouched:x,setFocused:b,validationMode:y,state:R,disabled:v}=Zt(),{labelId:D}=ys(),{store:S,setOpen:_,selectionRef:N,validation:I,readOnly:j,required:V,alignItemWithTriggerActiveRef:w,disabled:k}=be(),W=v||k||r,O=p(S,d.open),ue=p(S,d.mounted),Y=p(S,d.value),le=p(S,d.triggerProps),K=p(S,d.positionerElement),H=p(S,d.listElement),L=p(S,d.popupSide),J=p(S,d.id),C=p(S,d.labelId),ne=p(S,d.hasSelectedValue),z=ue&&K?L:null,P=f??J,a=so(D,C);en({id:P});const h=Qt(K),Q=l.useRef(null),{getButtonProps:F,buttonRef:se}=Gt({disabled:W,native:u}),g=S.useStateSetter("triggerElement"),T=rt(),B=rt(),ee=rt();l.useEffect(()=>{if(O)return ee.start(oo,()=>{N.current.allowUnselectedMouseUp=!0,N.current.allowSelectedMouseUp=!0}),()=>{ee.clear()};N.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},B.clear()},[O,N,B,ee]);const ve=St(le,{id:P,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?H?.id??Qn(K)?.id:void 0,"aria-labelledby":a,"aria-readonly":j||void 0,"aria-required":V||void 0,tabIndex:W?-1:0,onFocus($){b(!0),O&&w.current&&_(!1,Te(at,$.nativeEvent)),T.start(0,()=>{S.set("forceMount",!0)})},onBlur($){vt(K,$.relatedTarget)||(x(!0),b(!1),y==="onBlur"&&I.commit(Y))},onMouseDown($){if(O)return;const de=wt($.currentTarget);function Z(oe){if(!Q.current)return;const re=oe.target;vt(Q.current,re)||vt(h.current,re)||Vn(oe,Q.current)||_(!1,Te(ws,oe))}B.start(0,()=>{de.addEventListener("mouseup",Z,{once:!0})})}},m,F),M=I.getValidationProps(W,ve);M.role="combobox";const G={...R,open:O,disabled:W,value:Y,readOnly:j,popupSide:z,placeholder:!ne};return Ce("button",t,{ref:[s,Q,se,g],state:G,stateAttributesMapping:ro,props:M})}),io={value:()=>null},ao=l.forwardRef(function(t,s){const{className:o,render:i,children:f,placeholder:r,style:u,...c}=t,{store:m,valueRef:x}=be(),b=p(m,d.value),y=p(m,d.items),R=p(m,d.itemToStringLabel),v=p(m,d.hasSelectedValue),D=!v&&r!=null&&f==null,S=p(m,d.hasNullItemLabel,D),_={value:b,placeholder:!v};let N=null;return typeof f=="function"?N=f(b):f!=null?N=f:D&&!S?N=r:Array.isArray(b)?N=eo(b,y,R):N=un(b,y,R),Ce("span",t,{state:_,ref:[s,x],props:[{children:N},c],stateAttributesMapping:io})}),co=l.forwardRef(function(t,s){const{render:o,className:i,style:f,...r}=t,{store:u}=be(),m={open:p(u,d.open)};return Ce("span",t,{state:m,ref:s,props:[{"aria-hidden":!0,children:"▼"},r],stateAttributesMapping:es})}),uo=l.forwardRef(function(t,s){const{store:o}=be(),i=p(o,d.mounted),f=p(o,d.forceMount);return i||f?n.jsx(ts,{ref:s,...t}):null}),dn=l.createContext(void 0);function Mt(){const e=l.useContext(dn);if(!e)throw new Error(jt(59));return e}function dt(e,t){e&&Object.assign(e.style,t)}const fn={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},fo={position:"fixed"},po=l.forwardRef(function(t,s){const{anchor:o,className:i,render:f,positionMethod:r,side:u,align:c,sideOffset:m,alignOffset:x,collisionBoundary:b="clipping-ancestors",collisionPadding:y,arrowPadding:R,sticky:v,disableAnchorTracking:D,alignItemWithTrigger:S=!0,collisionAvoidance:_=ns,style:N,...I}=t,{store:j,listRef:V,labelsRef:w,alignItemWithTriggerActiveRef:k,selectedItemTextRef:W,valuesRef:O,initialValueRef:ue,popupRef:Y,setValue:le,floatingContext:K}=be(),H=p(j,d.open),L=p(j,d.mounted),J=p(j,d.modal),C=p(j,d.value),ne=p(j,d.openMethod),z=p(j,d.positionerElement),P=p(j,d.triggerElement),a=p(j,d.isItemEqualToValue),h=p(j,d.transitionStatus),Q=l.useRef(null),F=l.useRef(null),[se,g]=l.useState(S),T=L&&se&&ne!=="touch";!L&&se!==S&&g(S),l.useImperativeHandle(k,()=>T),kn((T||J)&&H,ne==="touch",z,P);const B=Ln({anchor:o,floatingRootContext:K,positionMethod:r,mounted:L,side:u,sideOffset:m,align:c,alignOffset:x,arrowPadding:R,collisionBoundary:b,collisionPadding:y,sticky:v,disableAnchorTracking:D??T,collisionAvoidance:_,keepMounted:!0}),ee=T?"none":B.side,ve=T?fo:B.positionerStyles,M={open:H,side:ee,align:B.align,anchorHidden:B.anchorHidden};xe(()=>{j.set("popupSide",B.side)},[j,B.side]);const G=j.useStateSetter("positionerElement"),$=On(t,M,{styles:ve,transitionStatus:h,props:I,refs:[s,G],hidden:!L,inert:!H}),de=l.useRef(0),Z=He(re=>{if(O.current.length===0)return;const ie=de.current;if(de.current=re.size,re.size===ie)return;const fe=Te(at);if(ie!==0&&!j.state.multiple&&C!==null&&lt(O.current,C,a)===-1){const X=ue.current,E=X!=null&&lt(O.current,X,a)!==-1?X:null;le(E,fe),E===null&&(j.set("selectedIndex",null),W.current=null)}if(ie!==0&&j.state.multiple&&Array.isArray(C)){const q=C.filter(X=>lt(O.current,X,a)!==-1);q.length!==C.length&&(le(q,fe),q.length===0&&(j.set("selectedIndex",null),W.current=null))}if(H&&T){j.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const q={height:""};dt(z,q),dt(Y.current,q)}}),oe=l.useMemo(()=>({...B,side:ee,alignItemWithTriggerActive:T,setControlledAlignItemWithTrigger:g,scrollUpArrowRef:Q,scrollDownArrowRef:F}),[B,ee,T,g]);return n.jsx(Es,{elementsRef:V,labelsRef:w,onMapChange:Z,children:n.jsxs(dn.Provider,{value:oe,children:[L&&J&&n.jsx(ss,{inert:os(!H),cutout:P}),$]})})}),nt="base-ui-disable-scrollbar",It={className:nt,getElement(e){return n.jsx("style",{nonce:e,href:nt,precedence:"base-ui:low",children:`.${nt}{scrollbar-width:none}.${nt}::-webkit-scrollbar{display:none}`})}},mo=l.createContext(void 0),go={disableStyleElements:!1};function ho(){return l.useContext(mo)??go}const xo={...cs,...Ct},bo=l.forwardRef(function(t,s){const{render:o,className:i,style:f,finalFocus:r,...u}=t,{store:c,popupRef:m,onOpenChangeComplete:x,setOpen:b,valueRef:y,firstItemTextRef:R,selectedItemTextRef:v,multiple:D,handleScrollArrowVisibility:S,scrollHandlerRef:_,listRef:N,highlightItemOnHover:I,floatingContext:j}=be(),{side:V,align:w,alignItemWithTriggerActive:k,isPositioned:W,setControlledAlignItemWithTrigger:O}=Mt(),ue=Dn()!=null,Y=Ps(),{nonce:le,disableStyleElements:K}=ho(),H=p(c,d.id),L=p(c,d.open),J=p(c,d.openMethod),C=p(c,d.mounted),ne=p(c,d.popupProps),z=p(c,d.transitionStatus),P=p(c,d.triggerElement),a=p(c,d.positionerElement),h=p(c,d.listElement),Q=l.useRef(!1),F=l.useRef(!1),se=l.useRef({}),g=rs(),T=He(M=>{if(!a||!m.current||!F.current)return;const G=a.style.top==="0px",$=a.style.bottom==="0px";if(Q.current||!k||!G&&!$){S(M);return}const de=$t(a),Z=Je(a.getBoundingClientRect().height,"y",de),oe=wt(a),re=bt(a),ie=re.getComputedStyle(a),fe=parseFloat(ie.marginTop),q=parseFloat(ie.marginBottom),X=zt(re.getComputedStyle(m.current)),ae=Math.min(oe.documentElement.clientHeight-fe-q,X),E=M.scrollTop,Ae=st(M);let ye=null;const Se=te=>{a.style.height=`${te}px`},ce=G?Ae-E:E,ke=Math.min(Z+ce,ae);if(ce<=me){const te=Ke(ce,0,ae-Z);te>0&&Se(Z+te),M.scrollTop=G?Ae:0,ae-(Z+te)<=me&&(Q.current=!0),S(M);return}if(ae-ke>me)ye=G?1/0:0;else if($&&E<Ae){const te=Z+ce-ae;ye=E-(ce-te)}const Le=Math.ceil(ke);if(Le!==0&&Se(Le),ye!=null){const te=Ke(ye,0,st(M));Math.abs(M.scrollTop-te)>me&&(M.scrollTop=te)}Le>=ae-me&&(Q.current=!0),S(M)});l.useImperativeHandle(_,()=>T,[T]),pt({open:L,ref:m,onComplete(){L&&x?.(!0)}});const B={open:L,transitionStatus:z,side:V,align:w};xe(()=>{!a||!m.current||Object.keys(se.current).length||(se.current={top:a.style.top||"0",left:a.style.left||"0",right:a.style.right,height:a.style.height,bottom:a.style.bottom,minHeight:a.style.minHeight,maxHeight:a.style.maxHeight,marginTop:a.style.marginTop,marginBottom:a.style.marginBottom})},[m,a]),xe(()=>{L||k||(F.current=!1,Q.current=!1,dt(a,se.current))},[L,k,a,m]),xe(()=>{const M=m.current;if(!L||!P||!a||!M||k&&!W||c.state.transitionStatus==="ending")return;if(F.current=!0,M.style.removeProperty("--transform-origin"),!k){g.request(()=>S(h||M));return}const G=vo(M);try{let $=v.current;$?.isConnected||($=!d.hasSelectedValue(c.state)&&R.current?.isConnected?R.current:null);const de=y.current,Z=bt(a),oe=Z.getComputedStyle(a),re=Z.getComputedStyle(M),ie=wt(P),fe=$t(P),q=ot(P.getBoundingClientRect(),fe),X=ot(a.getBoundingClientRect(),fe),ae=q.height,E=h||M,Ae=E.scrollHeight,ye=parseFloat(re.borderBottomWidth),Se=parseFloat(oe.marginTop)||10,ce=parseFloat(oe.marginBottom)||10,ke=parseFloat(oe.minHeight)||100,Le=zt(re),te=5,mt=5,Qe=20,we=ie.documentElement.clientHeight-Se-ce,gt=ie.documentElement.clientWidth,Ge=we-q.bottom+ae;let ge,Ue=Y==="rtl"?q.right-X.width:q.left,_e=0;if($&&de){const pe=ot(de.getBoundingClientRect(),fe);ge=ot($.getBoundingClientRect(),fe),Ue=X.left+(Y==="rtl"?pe.right-ge.right:pe.left-ge.left);const qe=pe.top-q.top+pe.height/2;_e=ge.top-X.top+ge.height/2-qe}const Me=Ge+_e+ce+ye;let he=Math.min(we,Me);const Ee=we-Se-ce,ze=Me-he,$e=gt-mt;a.style.left=`${Ke(Ue,te,$e-X.width)}px`,a.style.height=`${he}px`,a.style.maxHeight="none",a.style.marginTop=`${Se}px`,a.style.marginBottom=`${ce}px`,M.style.height="100%";const Pe=st(E),Oe=ze>=Pe-me;Oe&&(he=Math.min(we,X.height)-(ze-Pe));const Ze=q.top<Qe||q.bottom>we-Qe||Math.ceil(he)+me<Math.min(Ae,ke),et=(Z.visualViewport?.scale??1)!==1&&ls;if(Ze||et){dt(a,se.current),O(!1);return}const tt=Math.max(ke,he);if(Oe){const pe=Math.max(0,we-Me);a.style.top=X.height>=Ee?"0":`${pe}px`,a.style.height=`${he}px`,E.scrollTop=st(E)}else a.style.bottom="0",E.scrollTop=ze;if(ge){const pe=X.top,qe=X.height,Xe=ge.top+ge.height/2,ht=Ke(qe>0?(Xe-pe)/qe*100:50,0,100);M.style.setProperty("--transform-origin",`50% ${ht}%`)}(tt===we||he>=Le)&&(Q.current=!0),S(E),I&&c.state.selectedIndex===null&&c.state.activeIndex===null&&N.current[0]!=null&&c.set("activeIndex",0)}finally{G()}},[c,L,a,P,y,R,v,m,S,k,O,g,h,N,I,Y,W]),l.useEffect(()=>{if(!k||!a||!L)return;const M=bt(a);function G($){b(!1,Te(Rs,$))}return is(M,"resize",G)},[b,k,a,L]);const ee={...h?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":D||void 0,id:`${H}-list`},onKeyDown(M){ue&&us.has(M.key)&&M.stopPropagation()},onScroll(M){h||T(M.currentTarget)},...k&&{style:h?{height:"100%"}:fn},className:!h&&k?It.className:void 0},ve=Ce("div",t,{ref:[s,m],state:B,stateAttributesMapping:xo,props:[ne,ee,Bn(z),u]});return n.jsxs(l.Fragment,{children:[!K&&It.getElement(le),n.jsx(as,{context:j,modal:!1,disabled:!C,openInteractionType:J,returnFocus:r,restoreFocus:!0,children:ve})]})});function zt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function st(e){return At(e.scrollHeight,e.clientHeight)}function $t(e){return Hn.getScale(e)}function Je(e,t,s){return e/s[t]}function ot(e,t){return Fn({x:Je(e.x,"x",t),y:Je(e.y,"y",t),width:Je(e.width,"x",t),height:Je(e.height,"y",t)})}const qt=[["transform","none"],["scale","1"],["translate","0 0"]];function vo(e){const{style:t}=e,s={};for(const[o,i]of qt)s[o]=t.getPropertyValue(o),t.setProperty(o,i,"important");return()=>{for(const[o]of qt){const i=s[o];i?t.setProperty(o,i):t.removeProperty(o)}}}const yo=l.forwardRef(function(t,s){const{render:o,className:i,style:f,...r}=t,{store:u,scrollHandlerRef:c,multiple:m}=be(),{alignItemWithTriggerActive:x}=Mt(),b=p(u,d.hasScrollArrows),y=p(u,d.openMethod),v={id:`${p(u,d.id)}-list`,role:"listbox","aria-multiselectable":m||void 0,onScroll(S){c.current?.(S.currentTarget)},...x&&{style:fn},className:b&&y!=="touch"?It.className:void 0},D=u.useStateSetter("listElement");return Ce("div",t,{ref:[s,D],props:[v,r]})}),pn=l.createContext(void 0);function Et(){const e=l.useContext(pn);if(!e)throw new Error(jt(57));return e}const So=l.memo(l.forwardRef(function(t,s){const{render:o,className:i,style:f,value:r=null,label:u,disabled:c=!1,nativeButton:m=!1,...x}=t,b=l.useRef(null),y=Ns({guess:!0,label:u,textRef:b}),{store:R,itemProps:v,setOpen:D,setValue:S,selectionRef:_,typingRef:N,valuesRef:I,multiple:j,selectedItemTextRef:V,disabled:w,readOnly:k}=be(),W=w||c,O=p(R,d.isActive,y.index),ue=p(R,d.open),Y=p(R,d.isSelected,r),le=p(R,d.isSelectedByFocus,y.index),K=p(R,d.isItemEqualToValue),H=y.index,L=l.useRef(null);xe(()=>{const g=I.current;return g[H]=r,()=>{delete g[H]}},[H,r,I]),xe(()=>{const g=R.state.value;let T=g;j&&Array.isArray(g)&&(T=g.length>0?g[g.length-1]:void 0),T!==void 0&&Ye(r,T,K)&&(R.set("selectedIndex",H),b.current&&(V.current=b.current))},[H,j,K,R,r,V]);const J=l.useRef("mouse"),C=l.useRef(!1),{getButtonProps:ne,buttonRef:z}=Gt({disabled:W,focusableWhenDisabled:!0,native:m,composite:!0}),P={disabled:W,selected:Y,highlighted:O};function a(g){if(w||k)return;const T=R.state.value;if(j){const B=Array.isArray(T)?T:[],ee=Y?Qs(B,r,K):[...B,r];S(ee,Te(yt,g))}else S(r,Te(yt,g)),D(!1,Te(yt,g))}function h(){_.current.dragY=0}const Q={role:"option","aria-selected":Y,tabIndex:ue&&O?0:-1,onKeyDown(g){R.set("activeIndex",H),g.key===" "&&N.current&&g.preventDefault()},onClick(g){const T=J.current!=="touch",B=g.nativeEvent.pointerType,ee=T&&ds(g.nativeEvent)&&(B!==void 0||O),ve=T&&!ee&&!C.current;C.current=!1,!(W||ve)&&a(g.nativeEvent)},onPointerEnter(g){J.current=g.pointerType},onPointerMove(g){if(g.pointerType==="mouse"&&g.buttons===1){const T=_.current;T.dragY+=g.movementY,T.dragY**2>=64&&(T.allowUnselectedMouseUp=!0)}},onPointerDown(g){J.current=g.pointerType,C.current=!0,h()},onMouseUp(){if(h(),W||J.current==="touch"||C.current)return;const g=!_.current.allowSelectedMouseUp&&Y,T=!_.current.allowUnselectedMouseUp&&!Y;g||T||(C.current=!0,L.current?.click(),C.current=!1)}},F=Ce("div",t,{ref:[z,s,y.ref,L],state:P,props:[v,Q,x,ne]}),se=l.useMemo(()=>({selected:Y,index:H,textRef:b,selectedByFocus:le}),[Y,H,b,le]);return n.jsx(pn.Provider,{value:se,children:F})})),wo=l.forwardRef(function(t,s){const{selected:o}=Et();return t.keepMounted||o?n.jsx(Ro,{...t,ref:s}):null}),Ro=l.memo(l.forwardRef((e,t)=>{const{render:s,className:o,style:i,keepMounted:f,...r}=e,{selected:u}=Et(),c=l.useRef(null),{transitionStatus:m,setMounted:x}=Tt(u),y=Ce("span",e,{ref:[t,c],state:{selected:u,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},r],stateAttributesMapping:Ct});return pt({open:u,ref:c,onComplete(){u||x(!1)}}),y})),Io=l.memo(l.forwardRef(function(t,s){const{index:o,textRef:i,selectedByFocus:f}=Et(),{firstItemTextRef:r,selectedItemTextRef:u}=be(),{render:c,className:m,style:x,...b}=t,y=l.useCallback(v=>{v&&(o===0&&(r.current=v),f&&(u.current=v))},[r,u,o,f]);return Ce("div",t,{ref:[y,s,i],props:b})})),mn=l.forwardRef(function(t,s){const{render:o,className:i,style:f,direction:r,keepMounted:u,...c}=t,m=r==="up",{store:x,popupRef:b,listRef:y,handleScrollArrowVisibility:R,scrollArrowsMountedCountRef:v}=be(),{side:D,scrollDownArrowRef:S,scrollUpArrowRef:_}=Mt(),N=m?d.scrollUpArrowVisible:d.scrollDownArrowVisible,I=p(x,N),j=p(x,d.openMethod),V=I&&j!=="touch",w=rt(),k=m?_:S,{mounted:W,transitionStatus:O,setMounted:ue}=Tt(V);xe(()=>(v.current+=1,x.set("hasScrollArrows",!0),()=>{v.current=Math.max(0,v.current-1),v.current===0&&x.set("hasScrollArrows",!1)}),[x,v]),pt({open:V,ref:k,onComplete(){V||ue(!1)}});const K=Ce("div",t,{ref:[s,k],state:{direction:r,visible:V,side:D,transitionStatus:O},props:[{"aria-hidden":!0,children:m?"▲":"▼",style:{position:"absolute"},onMouseMove(L){if(L.movementX===0&&L.movementY===0||w.isStarted())return;x.set("activeIndex",null);function J(){const C=x.state.listElement??b.current;if(!C)return;x.set("activeIndex",null),R(C);const ne=At(C.scrollHeight,C.clientHeight),z=ut(C.scrollTop,ne),P=z===(m?0:ne),a=y.current;if(z!==C.scrollTop&&(C.scrollTop=z),P){w.clear();return}if(a.length>0){const h=k.current?.offsetHeight||0;C.scrollTop=jo(a,m,z,C.clientHeight,h,ne)}w.start(40,J)}w.start(40,J)},onMouseLeave(){w.clear()}},c],stateAttributesMapping:Ct});return W||u?K:null});function jo(e,t,s,o,i,f){if(t){let x=0;const b=s+i-me;for(let v=0;v<e.length;v+=1){const D=e[v];if(D&&D.offsetTop>=b){x=v;break}}const y=Math.max(0,x-1),R=e[y];return y<x&&R?ut(R.offsetTop-i,f):0}let r=e.length-1;const u=s+o-i+me;for(let x=0;x<e.length;x+=1){const b=e[x];if(b&&b.offsetTop+b.offsetHeight>u){r=Math.max(0,x-1);break}}const c=Math.min(e.length-1,r+1),m=e[c];return c>r&&m?ut(m.offsetTop+m.offsetHeight-o+i,f):f}const To=l.forwardRef(function(t,s){return n.jsx(mn,{...t,ref:s,direction:"down"})}),Co=l.forwardRef(function(t,s){return n.jsx(mn,{...t,ref:s,direction:"up"})}),Ao=no;function Mo({className:e,...t}){return n.jsx(ao,{"data-slot":"select-value",className:Be("flex flex-1 text-left",e),...t})}function Eo({className:e,size:t="default",children:s,...o}){return n.jsxs(lo,{"data-slot":"select-trigger","data-size":t,className:Be("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[s,n.jsx(co,{render:n.jsx(on,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function Po({className:e,children:t,side:s="bottom",sideOffset:o=4,align:i="center",alignOffset:f=0,alignItemWithTrigger:r=!0,...u}){return n.jsx(uo,{children:n.jsx(po,{side:s,sideOffset:o,align:i,alignOffset:f,alignItemWithTrigger:r,className:"isolate z-50",children:n.jsxs(bo,{"data-slot":"select-content","data-align-trigger":r,className:Be("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...u,children:[n.jsx(Vo,{}),n.jsx(yo,{children:t}),n.jsx(ko,{})]})})})}function No({className:e,children:t,...s}){return n.jsxs(So,{"data-slot":"select-item",className:Be("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[n.jsx(Io,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),n.jsx(wo,{render:n.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:n.jsx(Cs,{className:"pointer-events-none"})})]})}function Vo({className:e,...t}){return n.jsx(Co,{"data-slot":"select-scroll-up-button",className:Be("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:n.jsx($s,{})})}function ko({className:e,...t}){return n.jsx(To,{"data-slot":"select-scroll-down-button",className:Be("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:n.jsx(on,{})})}function Lo(){const e=rn(),t=Xt(e.user.role,"people"),s=yn(e.user.role),o=Ot(Lt.members()),i=Ot(Lt.invites()),[f,r]=l.useState(!1),u=e.limits.members.limit,c=u!==null&&e.limits.members.used>=u;return n.jsxs("div",{className:"p-7",children:[n.jsx(ks,{title:"Members",sub:`${t?"Only owners change roles or remove people.":"Admins invite members. Ask an owner to change a role or remove someone."}${u!==null?` ${e.limits.members.used} of ${u} members.`:""}`,actions:s.length?n.jsxs(Fe,{onClick:()=>r(!0),disabled:c,title:c?`This studio's plan allows ${u} members.`:void 0,children:[n.jsx(_s,{}),"Invite"]}):void 0}),n.jsx(Jt,{className:"max-w-[1040px] overflow-hidden py-0",children:n.jsxs(tn,{children:[n.jsx(nn,{children:n.jsxs(ct,{children:[n.jsx(Ie,{children:"Name"}),n.jsx(Ie,{children:"Email"}),n.jsx(Ie,{children:"Role"}),t&&n.jsx(Ie,{className:"w-0"})]})}),n.jsx(sn,{children:(o.data?.data??[]).map(m=>n.jsx(Ho,{m,owner:t},m.email))})]})}),n.jsx(Oo,{}),(i.data?.data.length??0)>0&&n.jsx(Do,{invites:i.data.data,roles:s}),n.jsxs("p",{className:"m-0 mt-3 max-w-[1040px] text-[12.5px] text-muted-foreground",children:["People join through an invite link and choose their own password. A forgotten one is reset on the server with ",n.jsx("code",{className:"font-mono text-[12px]",children:"snagset passwd"}),"."]}),s.length>0&&n.jsx(Bo,{open:f,onOpenChange:r,mail:i.data?.mail??!1,roles:s})]})}const gn=e=>new Date(e).toLocaleDateString(void 0,{day:"numeric",month:"short"}),ft={owner:"Owner",admin:"Admin",member:"Member"};function Oo(){return n.jsx("dl",{className:"m-0 mt-3 grid max-w-[1040px] grid-cols-[70px_1fr] gap-x-3 gap-y-1 text-[12.5px]","aria-label":"Roles",children:it.map(e=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"font-medium",children:ft[e]}),n.jsx("dd",{className:"m-0 text-muted-foreground",children:Kt[e]})]},e))})}function Do({invites:e,roles:t}){const s=Fs(),o=t.length>0;return n.jsxs("section",{className:"mt-6 max-w-[1040px]","aria-labelledby":"pending-invites",children:[n.jsx("div",{id:"pending-invites",className:"mb-2",children:n.jsx(Ls,{children:"Pending invites"})}),n.jsx(Jt,{className:"overflow-hidden py-0",children:n.jsxs(tn,{children:[n.jsx(nn,{children:n.jsxs(ct,{children:[n.jsx(Ie,{children:"For"}),n.jsx(Ie,{children:"Role"}),n.jsx(Ie,{children:"Invited by"}),n.jsx(Ie,{children:"Expires"}),o&&n.jsx(Ie,{className:"w-0"})]})}),n.jsx(sn,{children:e.map(i=>n.jsxs(ct,{children:[n.jsx(je,{className:i.email?"":"text-muted-foreground",children:i.email??"Anyone with the link"}),n.jsx(je,{className:"capitalize",children:i.role}),n.jsx(je,{className:"text-muted-foreground",children:i.createdBy?i.createdBy.name||i.createdBy.email:"—"}),n.jsx(je,{className:"text-muted-foreground",children:gn(i.expiresAt)}),o&&n.jsx(je,{className:"text-right",children:t.includes(i.role)&&n.jsx(Fe,{variant:"ghost",size:"sm","aria-label":`Revoke the invite for ${i.email??"anyone with the link"}`,disabled:s.isPending&&s.variables===i.id,onClick:()=>s.mutate(i.id),children:"Revoke"})})]},i.id))})]})})]})}function Ho({m:e,owner:t}){const s=Ds(),o=Hs(),[i,f]=l.useState(!1);return n.jsxs(ct,{children:[n.jsx(je,{children:n.jsxs("span",{className:"flex items-center gap-2.5",children:[n.jsx(Un,{className:"size-6",children:n.jsx(_n,{className:"bg-brand-soft text-[10px] font-semibold text-brand",children:Os(e.name,e.email)})}),n.jsx("span",{className:"font-medium",children:e.name||e.email}),e.you&&n.jsx(zn,{variant:"outline",className:"text-[11px]",children:"you"})]})}),n.jsx(je,{className:"text-muted-foreground",children:e.email}),n.jsx(je,{children:t?n.jsxs(Ao,{items:it.map(r=>({value:r,label:ft[r]})),value:e.role,onValueChange:r=>r&&r!==e.role&&s.mutate({email:e.email,role:r}),children:[n.jsx(Eo,{size:"sm","aria-label":`Role for ${e.email}`,className:"min-w-[104px] bg-card",children:n.jsx(Mo,{})}),n.jsx(Po,{children:it.map(r=>n.jsx(No,{value:r,children:ft[r]},r))})]}):n.jsx("span",{className:"capitalize",children:e.role})}),t&&n.jsxs(je,{className:"text-right",children:[!e.you&&n.jsx(Fe,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${e.email}`,onClick:()=>f(!0),children:n.jsx(fs,{})}),n.jsx(js,{open:i,onOpenChange:f,title:`Remove ${e.name||e.email}?`,description:"Every session of theirs ends now. Nothing they wrote is destroyed.",confirmLabel:"Remove",busy:o.isPending,onConfirm:()=>{f(!1),o.mutate(e.email)}})]})]})}const Fo=wn({email:In([jn(""),Tn().trim().email("An email address, or leave it empty")]),role:Rn(it)});function Bo({open:e,onOpenChange:t,mail:s,roles:o}){const i=Bs(),f=Us(),[r,u]=l.useState(""),[c,m]=l.useState(null),[x,b]=l.useState(null),{register:y,handleSubmit:R,formState:v,reset:D,watch:S}=Cn({resolver:An(Fo),defaultValues:{role:"member",email:""}}),_=S("role"),N=w=>{t(w),w||(m(null),b(null),u(""),f.reset(),D())},I=R(async w=>{u("");try{m(await i.mutateAsync({role:w.role,...w.email?{email:w.email}:{}}))}catch(k){u(kt(k))}}),j=async()=>{if(c){u("");try{b((await f.mutateAsync({id:c.invite.id,token:c.token})).to)}catch(w){u(kt(w))}}},V=(c?.mail??s)&&!!c?.invite.email;return n.jsx(ps,{open:e,onOpenChange:N,children:n.jsx(ms,{children:c?n.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[n.jsxs(Dt,{children:[n.jsx(Ht,{children:"Invite link"}),n.jsxs(Ft,{children:[c.invite.email?`${c.invite.email} can`:"Anyone with this link can"," join as ",Sn(c.invite.role)," ","until ",gn(c.invite.expiresAt),". It works once, and this is the only time it is shown."]})]}),r&&n.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:r}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1.5 font-mono text-[12px]","data-testid":"invite-url",children:c.url}),n.jsx(Ts,{text:c.url,label:"Copy link",withText:!0})]}),V&&(x?n.jsxs("p",{role:"status",className:"m-0 text-[13px] [overflow-wrap:anywhere] text-muted-foreground",children:["Sent to ",x,"."]}):n.jsxs(Fe,{type:"button",variant:"outline",className:"max-w-full min-w-0 self-start",title:c.invite.email?`Send by email to ${c.invite.email}`:void 0,loading:f.isPending,onClick:()=>void j(),children:[n.jsx(Ws,{}),n.jsx("span",{className:"min-w-0 truncate",children:f.isPending?"Sending…":`Send by email to ${c.invite.email}`})]})),n.jsx(Bt,{children:n.jsx(Fe,{type:"button",onClick:()=>N(!1),children:"Done"})})]}):n.jsxs("form",{onSubmit:I,className:"flex flex-col gap-4",noValidate:!0,children:[n.jsxs(Dt,{children:[n.jsx(Ht,{children:"Invite someone"}),n.jsx(Ft,{children:"You get a link to send them. Whoever opens it chooses their own name and password, and is signed in. It works once and lasts seven days."})]}),r&&n.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:r}),n.jsxs("fieldset",{disabled:v.isSubmitting,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(_t,{htmlFor:"invite-role",children:"Role"}),n.jsx(Xs,{id:"invite-role",className:"w-full",...y("role"),children:["member","admin","owner"].filter(w=>o.includes(w)).map(w=>n.jsx("option",{value:w,children:ft[w]},w))}),n.jsx("p",{className:"m-0 text-[12px] text-muted-foreground","data-testid":"invite-role-summary",children:Kt[_]??""})]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs(_t,{htmlFor:"invite-email",children:["Email ",n.jsx("span",{className:"font-normal text-muted-foreground",children:"optional"})]}),n.jsx(Is,{id:"invite-email",type:"email",autoComplete:"off","aria-invalid":!!v.errors.email,...y("email")}),n.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:v.errors.email?.message??(s?"Given, only that address can use the link, and you can mail it to them.":"Given, only that address can use the link.")})]}),n.jsxs(Bt,{children:[n.jsx(Fe,{type:"button",variant:"outline",onClick:()=>N(!1),children:"Cancel"}),n.jsx(Fe,{type:"submit",loading:v.isSubmitting,children:v.isSubmitting?"Creating…":"Create invite"})]})]})]})})})}const ur=()=>Xt(rn().user.role,"settings")?n.jsx(Lo,{}):n.jsx(Vs,{title:"Members"});export{ur as component};
@@ -0,0 +1 @@
1
+ import{j as e,ai as x,S as u,h as p,B as g,z as h}from"./index-p-qD6BlY.js";import{u as c}from"./useQuery-D-9vXtOo.js";import{b as d}from"./InstanceRows-B1z-L92-.js";import{A as j,P as f,a as b}from"./parts-CN1uQywE.js";import{u as o}from"./labels-DLMjYGNJ.js";import"./useBaseQuery-DaFWLbWu.js";import"./dialog-D5G50pSW.js";import"./label-CuvYMIVd.js";import"./ConfirmDialog-D1II2uNE.js";import"./card-C01exIzZ.js";function N(){const t=o(),{said:r}=x.useSearch(),i=c(h.setupState()),a=i.data?.billingUrl??null,n=c({queryKey:["plan-state",a],enabled:!!a,queryFn:async()=>{const s=await fetch(`${a.replace(/\/+$/,"")}/state`,{credentials:"include",headers:{accept:"application/json"}});if(!s.ok)throw new Error(String(s.status));return await s.json()}});return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(f,{title:"Plan & billing",sub:t.org.name}),r&&e.jsx("p",{role:"status",className:"m-0 max-w-[1040px] rounded-md border border-border bg-card px-3 py-2 text-[13px]",children:r}),e.jsx(b,{title:"Usage",description:"What this studio uses, against its plan.",children:e.jsx(y,{})}),i.isSuccess&&!a?e.jsx("p",{className:"m-0 text-muted-foreground",children:"This instance has no plans: everything is included."}):n.isError?e.jsx("p",{className:"m-0 text-muted-foreground",children:"The plans could not be loaded. Reload to try again."}):n.data?e.jsxs("section",{className:"flex max-w-[1040px] flex-col gap-4",children:[n.data.intro&&e.jsx("p",{className:"m-0 text-muted-foreground",children:n.data.intro}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:n.data.plans.map(s=>e.jsxs("div",{className:p("flex min-w-0 flex-col gap-2 rounded-lg border bg-card px-4 py-3.5",s.current?"border-brand ring-1 ring-brand":"border-border"),children:[e.jsxs("h2",{className:"m-0 flex items-center gap-2 text-[14px] font-semibold",children:[s.name,s.current&&e.jsx("span",{className:"rounded-full bg-brand-soft px-2 py-px text-[11.5px] font-medium text-brand",children:"Current"})]}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:s.price}),e.jsx("ul",{className:"m-0 flex-1 list-disc pl-4 text-[12.5px] text-muted-foreground",children:s.features.map(l=>e.jsx("li",{children:l},l))}),s.actions.map(l=>e.jsx(m,{base:a,form:l},l.label))]},s.id))}),n.data.manage&&e.jsx("div",{children:e.jsx(m,{base:a,form:n.data.manage})}),n.data.notes.map(s=>e.jsx("p",{className:"m-0 text-[12.5px] text-muted-foreground",children:s},s))]}):e.jsx(u,{})]})}function m({base:t,form:r}){return e.jsxs("form",{method:"post",action:new URL(r.action,t).toString(),className:"m-0",children:[Object.entries(r.fields).map(([i,a])=>e.jsx("input",{type:"hidden",name:i,value:a},i)),e.jsx(g,{type:"submit",variant:r.primary?"default":"outline",className:r.primary?"w-full":void 0,children:r.label})]})}function y(){const{limits:t}=o(),r=(i,a,n,s)=>a===null?`${i} ${i===1?n:s}, unlimited`:`${i} of ${a} ${a===1?n:s}`;return e.jsxs("dl",{className:"m-0 grid grid-cols-[110px_1fr] gap-x-3 gap-y-1.5 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Sites"}),e.jsx("dd",{className:"m-0",children:r(t.projects.used,t.projects.limit,"site","sites")}),e.jsx("dt",{className:"text-muted-foreground",children:"Members"}),e.jsx("dd",{className:"m-0",children:r(t.members.used,t.members.limit,"member","members")}),e.jsx("dt",{className:"text-muted-foreground",children:"Screenshots"}),e.jsx("dd",{className:"m-0",children:t.screenshots?t.storage.limit===null?`${d(t.storage.used)} used`:`${d(t.storage.used)} of ${d(t.storage.limit)}`:"Not on this plan"})]})}const A=()=>o().user.role==="owner"?e.jsx(N,{}):e.jsx(j,{title:"Plan & billing"});export{A as component};
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-Ddw_j6S-.js";/**
1
+ import{c as t}from"./index-p-qD6BlY.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{r as i,i as ae,aa as re,e as se,ab as ie,E as ne,k as j,j as f,ak as oe,h as de}from"./index-p-qD6BlY.js";import{q as ce,f as le,h as ue,p as fe,u as pe,j as he,k as be,l as ge,c as me,n as ke}from"./label-CuvYMIVd.js";import{Q as ve,S as xe}from"./dialog-D5G50pSW.js";import{u as we}from"./useAriaLabelledBy-BT5NtL2E.js";import{u as ye}from"./useValueChanged-cwqHWzY1.js";const M=i.createContext(void 0);function Ce(){const r=i.useContext(M);if(r===void 0)throw new Error(ae(63));return r}const D={...ce,checked(r){return r?{"data-checked":""}:{"data-unchecked":""}}},Re=i.forwardRef(function(s,o){const{checked:v,className:F,defaultChecked:x,"aria-labelledby":m,form:p,id:L,inputRef:T,name:w,nativeButton:h=!1,onCheckedChange:V,readOnly:d=!1,required:b=!1,disabled:N=!1,render:ze,uncheckedValue:y,value:C,style:Ee,...q}=s,{clearErrors:H}=le(),{state:R,setTouched:A,setDirty:O,validityData:W,setFilled:k,setFocused:P,validationMode:J,disabled:Q,name:U,validation:c}=ue(),{labelId:Y}=fe(),t=Q||N,l=U??w,n=i.useRef(null),_=re(n,T,c.inputRef),g=i.useRef(null),z=pe(),E=he({id:L,implicit:!1,controlRef:g}),S=h?void 0:E,[a,G]=be({controlled:v,default:!!x,name:"Switch",state:"checked"});ge(g,z,a,void 0,!t,w),se(()=>{n.current&&k(n.current.checked)},[k]),ye(a,()=>{H(l),O(a!==W.initialValue),k(a),c.change(a)});const{getButtonProps:K,buttonRef:X}=ie({disabled:t,native:h}),Z=we(m,Y,n,!h,S),$={id:h?E:z,role:"switch","aria-checked":a,"aria-readonly":d||void 0,"aria-required":b||void 0,"aria-labelledby":Z,onFocus(){t||P(!0)},onBlur(){const e=n.current;!e||t||(A(!0),P(!1),J==="onBlur"&&c.commit(e.checked))},onClick(e){if(d||t)return;e.preventDefault();const u=n.current;u&&oe(u,e)}},ee={...c.getValidationProps(t),checked:a,disabled:t,form:p,id:S,name:l,required:b,style:l?ve:xe,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:_,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(d){e.preventDefault();return}const u=e.currentTarget.checked,I=me(ke,e.nativeEvent);V?.(u,I),!I.isCanceled&&G(u)},onClick(e){e.stopPropagation()},onFocus(){g.current?.focus()},...C!==void 0?{value:C}:ne},B=i.useMemo(()=>({...R,checked:a,disabled:t,readOnly:d,required:b}),[R,a,t,d,b]),te=j("span",s,{state:B,ref:[o,g,X],props:[$,q,K,e=>c.getValidationProps(t,e)],stateAttributesMapping:D});return f.jsxs(M.Provider,{value:B,children:[te,!a&&l&&y!==void 0&&f.jsx("input",{type:"hidden",form:p,name:l,value:y,disabled:t}),f.jsx("input",{...ee,suppressHydrationWarning:!0})]})}),Pe=i.forwardRef(function(s,o){const{render:v,className:F,style:x,...m}=s,p=Ce();return j("span",s,{state:p,ref:o,stateAttributesMapping:D,props:m})});function De({className:r,size:s="default",...o}){return f.jsx(Re,{"data-slot":"switch","data-size":s,className:de("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",r),...o,children:f.jsx(Pe,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}export{De as S};
@@ -1 +1 @@
1
- import{j as t,h as l}from"./index-Ddw_j6S-.js";function o({className:a,...e}){return t.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm",a),...e})})}function r({className:a,...e}){return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b",a),...e})}function d({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function n({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...e})}function b({className:a,...e}){return t.jsx("th",{"data-slot":"table-head",className:l("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",a),...e})}function c({className:a,...e}){return t.jsx("td",{"data-slot":"table-cell",className:l("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...e})}export{o as T,r as a,n as b,b as c,d,c as e};
1
+ import{j as t,h as l}from"./index-p-qD6BlY.js";function o({className:a,...e}){return t.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm",a),...e})})}function r({className:a,...e}){return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b",a),...e})}function d({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function n({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...e})}function b({className:a,...e}){return t.jsx("th",{"data-slot":"table-head",className:l("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",a),...e})}function c({className:a,...e}){return t.jsx("td",{"data-slot":"table-cell",className:l("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...e})}export{o as T,r as a,n as b,b as c,d,c as e};
@@ -1 +1 @@
1
- import{r as u,e as l}from"./index-Ddw_j6S-.js";import{u as c}from"./label-CeY5IHdJ.js";function y(e,n,t,r=!0,i){const[a,d]=u.useState(),f=c(i?`${i}-label`:void 0),o=e??n??a;return l(()=>{const s=e||n||!r?void 0:L(t.current,f);a!==s&&d(s)}),o}function L(e,n){const t=b(e);if(t)return!t.id&&n&&(t.id=n),t.id||void 0}function b(e){if(!e)return;const n=e.parentElement;if(n&&n.tagName==="LABEL")return n;const t=e.id;if(t){const i=e.nextElementSibling;if(i&&i.htmlFor===t)return i}const r=e.labels;return r&&r[0]}export{y as u};
1
+ import{r as u,e as l}from"./index-p-qD6BlY.js";import{u as c}from"./label-CuvYMIVd.js";function y(e,n,t,r=!0,i){const[a,d]=u.useState(),f=c(i?`${i}-label`:void 0),o=e??n??a;return l(()=>{const s=e||n||!r?void 0:L(t.current,f);a!==s&&d(s)}),o}function L(e,n){const t=b(e);if(t)return!t.id&&n&&(t.id=n),t.id||void 0}function b(e){if(!e)return;const n=e.parentElement;if(n&&n.tagName==="LABEL")return n;const t=e.id;if(t){const i=e.nextElementSibling;if(i&&i.htmlFor===t)return i}const r=e.labels;return r&&r[0]}export{y as u};
@@ -1 +1 @@
1
- import{b8 as N,b9 as h,ba as O,bb as U,bc as k,bd as B,be as A,bf as y,bg as H,bh as V,bi as M,bj as x,r as p,bk as F,d as j}from"./index-Ddw_j6S-.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return E(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return E(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#m();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||H.isFocused())&&this.#h()},this.#r))}#S(){this.#R(),this.#y(this.#v())}#m(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const S=n.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();x.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}};function W(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return W(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const _=p.createContext(!1),z=()=>p.useContext(_);_.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const G=p.createContext(K()),J=()=>p.useContext(G),X=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?F(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},Y=t=>{p.useEffect(()=>{t.clearReset()},[t])},Z=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||F(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,$=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=z(),r=J(),c=j(),a=c.defaultQueryOptions(t),u=c.getQueryCache().get(a.queryHash),l=t.subscribed!==!1;a._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(a),X(a,r,u),Y(r);const[n]=p.useState(()=>new e(c,a)),d=n.getOptimisticResult(a),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?n.subscribe(x.batchCalls(R)):U;return n.updateResult(),v},[n,o]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setOptions(a)},[a,n]),q(a,d))throw tt(a,n,r);if(Z({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw d.error;return a.notifyOnChangeProps?d:n.trackResult(d)}export{st as Q,it as d,rt as u};
1
+ import{b9 as N,ba as h,bb as O,bc as U,bd as k,be as B,bf as A,bg as y,bh as H,bi as V,bj as M,bk as x,r as p,bl as F,d as j}from"./index-p-qD6BlY.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return E(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return E(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#m();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||H.isFocused())&&this.#h()},this.#r))}#S(){this.#R(),this.#y(this.#v())}#m(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const S=n.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();x.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}};function W(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return W(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const _=p.createContext(!1),z=()=>p.useContext(_);_.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const G=p.createContext(K()),J=()=>p.useContext(G),X=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?F(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},Y=t=>{p.useEffect(()=>{t.clearReset()},[t])},Z=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||F(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,$=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=z(),r=J(),c=j(),a=c.defaultQueryOptions(t),u=c.getQueryCache().get(a.queryHash),l=t.subscribed!==!1;a._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(a),X(a,r,u),Y(r);const[n]=p.useState(()=>new e(c,a)),d=n.getOptimisticResult(a),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?n.subscribe(x.batchCalls(R)):U;return n.updateResult(),v},[n,o]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setOptions(a)},[a,n]),q(a,d))throw tt(a,n,r);if(Z({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw d.error;return a.notifyOnChangeProps?d:n.trackResult(d)}export{st as Q,it as d,rt as u};
@@ -0,0 +1 @@
1
+ import{u as r,Q as u}from"./useBaseQuery-DaFWLbWu.js";function a(e,s){return r(e,u)}export{a as u};
@@ -0,0 +1 @@
1
+ import{k as n}from"./index-p-qD6BlY.js";function u(e){return n(e.defaultTagName??"div",e,e)}export{u};
@@ -1 +1 @@
1
- import{r as s,f as c,e as n}from"./index-Ddw_j6S-.js";function u(e,r){const t=s.useRef(e),a=c(r);n(()=>{t.current!==e&&a(t.current),t.current=e},[e,a])}export{u};
1
+ import{r as s,f as c,e as n}from"./index-p-qD6BlY.js";function u(e,r){const t=s.useRef(e),a=c(r);n(()=>{t.current!==e&&a(t.current),t.current=e},[e,a])}export{u};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-Ddw_j6S-.js";/**
1
+ import{c as e}from"./index-p-qD6BlY.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as I,U as E,p as F,d as B,r as l,j as e,G as L,h as k,B as n,s as w,z as x,A as S}from"./index-Ddw_j6S-.js";import{C as f}from"./card-_fRmCPLn.js";import{L as C,I as q}from"./label-CeY5IHdJ.js";import{I as P}from"./InstallTag-Bxq5AWM0.js";import{C as R}from"./check-BTd2LoGN.js";import{A as z}from"./arrow-left-BVcH0ZD5.js";import"./copy-CEpGdeGb.js";/**
1
+ import{c as I,U as E,p as F,d as B,r as l,j as e,G as L,h as k,B as n,s as w,z as x,A as S}from"./index-p-qD6BlY.js";import{C as f}from"./card-C01exIzZ.js";import{L as C,I as q}from"./label-CuvYMIVd.js";import{I as P}from"./InstallTag-DTpNoMn9.js";import{C as R}from"./check-Gm9Xu4rH.js";import{A as z}from"./arrow-left-RqdORgcq.js";import"./copy-Ckk__4oN.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{V as h,r as x,j as e,B as a,G as N,s as y,W as b}from"./index-Ddw_j6S-.js";const S=`${b}session`;function E(){const{project:o,origin:t,env:g}=h.useSearch(),{me:n}=h.useRouteContext(),[l,d]=x.useState(""),[f,u]=x.useState(!1),i=n.projects.find(s=>s.uid===o),m=typeof window<"u"?window.opener:null,r=()=>window.close();if(!o||!t||!m)return e.jsx(c,{title:"Nothing to sign in to",children:e.jsxs("p",{className:"m-0 text-muted-foreground",children:["This window is opened by the comment box on a site you are reviewing. Open it from there — choose"," ",e.jsx("em",{children:"Studio member? Sign in"})," — and it will ask you here."]})});if(!i)return e.jsxs(c,{title:"Not one of this studio's sites",children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["You are signed in to ",n.org.name,", and that site is not one of its sites. If it belongs to another studio you are in, switch to it in the dashboard and try again."]}),e.jsx(a,{variant:"outline",onClick:r,children:"Close"})]});const p=async()=>{d(""),u(!0);try{const s=await y.memberSession(i.uid,t,g);if(s.origin!==t)throw new Error("The address changed while signing in. Try again from the site.");const{origin:j,...w}=s;m.postMessage({type:S,session:w},j),r()}catch(s){d(s instanceof Error?s.message:"Could not reach the server."),u(!1)}};return e.jsxs(c,{title:`Sign in to ${i.name}`,children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["Comment on ",e.jsx("span",{className:"font-medium text-foreground",children:t})," as"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.user.name||n.user.email}),", from ",n.org.name,". Your comments there and your replies here will be one author."]}),l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"lg",className:"flex-1",loading:f,onClick:()=>void p(),children:"Continue"}),e.jsx(a,{size:"lg",variant:"outline",onClick:r,children:"Cancel"})]})]})}function c({title:o,children:t}){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold tracking-tight",children:o}),t]})})}export{E as component};
1
+ import{V as h,r as x,j as e,B as a,G as N,s as y,W as b}from"./index-p-qD6BlY.js";const S=`${b}session`;function E(){const{project:o,origin:t,env:g}=h.useSearch(),{me:n}=h.useRouteContext(),[l,d]=x.useState(""),[f,u]=x.useState(!1),i=n.projects.find(s=>s.uid===o),m=typeof window<"u"?window.opener:null,r=()=>window.close();if(!o||!t||!m)return e.jsx(c,{title:"Nothing to sign in to",children:e.jsxs("p",{className:"m-0 text-muted-foreground",children:["This window is opened by the comment box on a site you are reviewing. Open it from there — choose"," ",e.jsx("em",{children:"Studio member? Sign in"})," — and it will ask you here."]})});if(!i)return e.jsxs(c,{title:"Not one of this studio's sites",children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["You are signed in to ",n.org.name,", and that site is not one of its sites. If it belongs to another studio you are in, switch to it in the dashboard and try again."]}),e.jsx(a,{variant:"outline",onClick:r,children:"Close"})]});const p=async()=>{d(""),u(!0);try{const s=await y.memberSession(i.uid,t,g);if(s.origin!==t)throw new Error("The address changed while signing in. Try again from the site.");const{origin:j,...w}=s;m.postMessage({type:S,session:w},j),r()}catch(s){d(s instanceof Error?s.message:"Could not reach the server."),u(!1)}};return e.jsxs(c,{title:`Sign in to ${i.name}`,children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["Comment on ",e.jsx("span",{className:"font-medium text-foreground",children:t})," as"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.user.name||n.user.email}),", from ",n.org.name,". Your comments there and your replies here will be one author."]}),l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"lg",className:"flex-1",loading:f,onClick:()=>void p(),children:"Continue"}),e.jsx(a,{size:"lg",variant:"outline",onClick:r,children:"Cancel"})]})]})}function c({title:o,children:t}){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold tracking-tight",children:o}),t]})})}export{E as component};
@@ -1 +1 @@
1
- import{r,w as b,j as e,h as y,x as N,B as j,q as f,a1 as S}from"./index-Ddw_j6S-.js";import{L as c,I as d}from"./label-CeY5IHdJ.js";import{P as C,a as h}from"./parts-DuhvDJGT.js";import{S as P}from"./SaveState-WYxHW3VJ.js";import{M as A}from"./McpTokens-D_0BEsPb.js";import{u as k}from"./labels-BuZpvtvw.js";import{u as M,a as F}from"./studio-CL5TjGsb.js";import{M as E,S as T,a as D}from"./sun-C6_OdtRI.js";import"./card-_fRmCPLn.js";import"./useQuery-CaIu0ohN.js";import"./useBaseQuery-bYBwKcW7.js";import"./badge-D4-0NV1D.js";import"./useRender-Rh7x0Dwc.js";import"./dialog-C7r1DbuZ.js";import"./switch-CGYNLqP6.js";import"./useAriaLabelledBy-CYXdXCKz.js";import"./useValueChanged-DCX5-3sY.js";import"./ConfirmDialog-D7eZU5Z6.js";import"./CopyButton-_X7ITEaj.js";import"./check-BTd2LoGN.js";import"./copy-CEpGdeGb.js";function z({items:t}){const[a,n]=r.useState(b);return e.jsx("div",{className:"flex gap-2",role:"radiogroup","aria-label":"Theme",children:t.map(s=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===s.value,onClick:()=>{N(s.value),n(s.value)},className:y("inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[12.5px] font-medium text-ink-soft",a===s.value&&"border-line-strong bg-muted text-foreground"),children:[s.icon,s.label]},s.value))})}function ae(){const t=k(),a=M(),[n,s]=r.useState(t.user.name),[u,i]=r.useState(null);r.useEffect(()=>s(t.user.name),[t.user.name]);const m=n.trim()!==t.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(C,{title:"You",sub:"Your own account on this studio",actions:e.jsx(P,{saving:a.isPending,savedAt:u})}),e.jsxs(h,{title:"Profile",description:"How you appear on replies and in the members list.",children:[e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:l=>{l.preventDefault(),m&&a.mutate(n.trim(),{onSuccess:()=>i(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"your-name",value:n,onChange:l=>s(l.target.value)}),m&&e.jsx(j,{type:"submit",variant:"outline",children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"your-email",children:"Email"}),e.jsx(d,{id:"your-email",value:t.user.email,readOnly:!0,className:"bg-muted text-ink-soft"}),e.jsxs("p",{className:"m-0 text-[12px] text-muted-foreground",children:["How you sign in, and how the server finds you. An owner changes it with"," ",e.jsx("code",{className:"font-mono",children:"snagset passwd"}),"."]})]})]}),e.jsx(h,{title:"Password",description:"Changing it keeps this session and ends every other one.",children:e.jsx(H,{})}),!f(t.user.role,"settings")&&f(t.user.role,"review")&&e.jsx(A,{owner:!0,mine:!0,instanceOwner:!1,sites:t.projects}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(z,{items:[{value:"system",label:"System",icon:e.jsx(E,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(T,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(D,{className:"size-3.5"})}]})})]})}function H(){const t=F(),[a,n]=r.useState(""),[s,u]=r.useState(""),[i,m]=r.useState(""),[l,g]=r.useState(""),[w,p]=r.useState(!1),x=a.length>0&&s.length>=12&&s===i;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async o=>{if(o.preventDefault(),!(!x||t.isPending)){g("");try{await t.mutateAsync({current:a,next:s}),n(""),u(""),m(""),p(!0)}catch(v){g(S(v))}}},children:[l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(d,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:o=>{n(o.target.value),p(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(d,{id:"pw-next",type:"password",autoComplete:"new-password",value:s,onChange:o=>{u(o.target.value),p(!1)}}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters. No composition rules — length is what matters."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-again",children:"Confirm new password"}),e.jsx(d,{id:"pw-again",type:"password",autoComplete:"new-password",value:i,onChange:o=>{m(o.target.value),p(!1)}}),i.length>0&&s!==i&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Those do not match yet."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{type:"submit",loading:t.isPending,disabled:!x,children:t.isPending?"Changing…":w&&!x?"Changed":"Change password"})})]})}export{ae as component};
1
+ import{r,w as b,j as e,h as y,x as N,B as j,q as f,a1 as S}from"./index-p-qD6BlY.js";import{L as c,I as d}from"./label-CuvYMIVd.js";import{P as C,a as h}from"./parts-CN1uQywE.js";import{S as P}from"./SaveState-QQHqDSgx.js";import{M as A}from"./McpTokens-DE2t0iiS.js";import{u as k}from"./labels-DLMjYGNJ.js";import{u as M,a as F}from"./studio-BHpeuJSq.js";import{M as E,S as T,a as D}from"./sun-DXwtJyi5.js";import"./card-C01exIzZ.js";import"./useQuery-D-9vXtOo.js";import"./useBaseQuery-DaFWLbWu.js";import"./badge-anHWhPFa.js";import"./useRender-BBzDGtxq.js";import"./dialog-D5G50pSW.js";import"./switch-cgJL6ATv.js";import"./useAriaLabelledBy-BT5NtL2E.js";import"./useValueChanged-cwqHWzY1.js";import"./ConfirmDialog-D1II2uNE.js";import"./CopyButton-qbA2ZHWn.js";import"./check-Gm9Xu4rH.js";import"./copy-Ckk__4oN.js";function z({items:t}){const[a,n]=r.useState(b);return e.jsx("div",{className:"flex gap-2",role:"radiogroup","aria-label":"Theme",children:t.map(s=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===s.value,onClick:()=>{N(s.value),n(s.value)},className:y("inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[12.5px] font-medium text-ink-soft",a===s.value&&"border-line-strong bg-muted text-foreground"),children:[s.icon,s.label]},s.value))})}function ae(){const t=k(),a=M(),[n,s]=r.useState(t.user.name),[u,i]=r.useState(null);r.useEffect(()=>s(t.user.name),[t.user.name]);const m=n.trim()!==t.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(C,{title:"You",sub:"Your own account on this studio",actions:e.jsx(P,{saving:a.isPending,savedAt:u})}),e.jsxs(h,{title:"Profile",description:"How you appear on replies and in the members list.",children:[e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:l=>{l.preventDefault(),m&&a.mutate(n.trim(),{onSuccess:()=>i(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"your-name",value:n,onChange:l=>s(l.target.value)}),m&&e.jsx(j,{type:"submit",variant:"outline",children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"your-email",children:"Email"}),e.jsx(d,{id:"your-email",value:t.user.email,readOnly:!0,className:"bg-muted text-ink-soft"}),e.jsxs("p",{className:"m-0 text-[12px] text-muted-foreground",children:["How you sign in, and how the server finds you. An owner changes it with"," ",e.jsx("code",{className:"font-mono",children:"snagset passwd"}),"."]})]})]}),e.jsx(h,{title:"Password",description:"Changing it keeps this session and ends every other one.",children:e.jsx(H,{})}),!f(t.user.role,"settings")&&f(t.user.role,"review")&&e.jsx(A,{owner:!0,mine:!0,instanceOwner:!1,sites:t.projects}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(z,{items:[{value:"system",label:"System",icon:e.jsx(E,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(T,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(D,{className:"size-3.5"})}]})})]})}function H(){const t=F(),[a,n]=r.useState(""),[s,u]=r.useState(""),[i,m]=r.useState(""),[l,g]=r.useState(""),[w,p]=r.useState(!1),x=a.length>0&&s.length>=12&&s===i;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async o=>{if(o.preventDefault(),!(!x||t.isPending)){g("");try{await t.mutateAsync({current:a,next:s}),n(""),u(""),m(""),p(!0)}catch(v){g(S(v))}}},children:[l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(d,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:o=>{n(o.target.value),p(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(d,{id:"pw-next",type:"password",autoComplete:"new-password",value:s,onChange:o=>{u(o.target.value),p(!1)}}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters. No composition rules — length is what matters."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-again",children:"Confirm new password"}),e.jsx(d,{id:"pw-again",type:"password",autoComplete:"new-password",value:i,onChange:o=>{m(o.target.value),p(!1)}}),i.length>0&&s!==i&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Those do not match yet."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{type:"submit",loading:t.isPending,disabled:!x,children:t.isPending?"Changing…":w&&!x?"Changed":"Change password"})})]})}export{ae as component};