@snagset/server 0.1.8 → 0.1.10

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 (61) hide show
  1. package/dist/serverless.js +11 -1
  2. package/dist/serverless.js.map +1 -1
  3. package/package.json +1 -1
  4. package/static/dashboard/assets/{CompositeItem-B5AtyrD6.js → CompositeItem-Db_8iHSG.js} +1 -1
  5. package/static/dashboard/assets/{ConfirmDialog-ClUMXHe1.js → ConfirmDialog-eCzw7vjK.js} +1 -1
  6. package/static/dashboard/assets/{CopyButton-DCsj-LZV.js → CopyButton-lcjux1TA.js} +1 -1
  7. package/static/dashboard/assets/{FieldItemContext-DVEWRsEB.js → FieldItemContext-i5zdyQYl.js} +1 -1
  8. package/static/dashboard/assets/{InstallTag-B_qg9P2r.js → InstallTag-Eqs3RM9e.js} +1 -1
  9. package/static/dashboard/assets/{SaveState-B-6cG0nU.js → SaveState-Cf_bnJmg.js} +1 -1
  10. package/static/dashboard/assets/{_app-DQfqCcnn.js → _app-CuKLSKZ2.js} +1 -1
  11. package/static/dashboard/assets/{_app-DKjbkrkj.js → _app-qNVG5lsX.js} +1 -1
  12. package/static/dashboard/assets/{activity-D8OAqMBy.js → activity-CQLBFIV4.js} +1 -1
  13. package/static/dashboard/assets/{arrow-left-D2obUiWw.js → arrow-left-CQUHEFUP.js} +1 -1
  14. package/static/dashboard/assets/{avatar-DlHbKa1H.js → avatar-CWT37Ivf.js} +1 -1
  15. package/static/dashboard/assets/{badge-CQoGgFU8.js → badge-thtKAJ0h.js} +1 -1
  16. package/static/dashboard/assets/{card-YnwmM74t.js → card-CsXE7vKD.js} +1 -1
  17. package/static/dashboard/assets/{check-CLHnIgiu.js → check-Bc_1fmPx.js} +1 -1
  18. package/static/dashboard/assets/{chevron-right-BX_QQNXH.js → chevron-right-neQQkaOt.js} +1 -1
  19. package/static/dashboard/assets/{copy-ZOZ0pLVD.js → copy-O3USBatC.js} +1 -1
  20. package/static/dashboard/assets/{dialog-BO8bYmy1.js → dialog-MC-TOvQV.js} +1 -1
  21. package/static/dashboard/assets/{dropdown-menu-NLHjhAUe.js → dropdown-menu-C2ZhmONu.js} +1 -1
  22. package/static/dashboard/assets/{image-off-Dg9jTwH7.js → image-off-Bu6l8gP5.js} +1 -1
  23. package/static/dashboard/assets/{index-B7_Oj3hr.js → index-C6gyyLd5.js} +3 -3
  24. package/static/dashboard/assets/{label-Dpq7t35_.js → label-BTdAT39L.js} +1 -1
  25. package/static/dashboard/assets/{layout-grid-Bf2WS_DV.js → layout-grid-rYWIGaIJ.js} +1 -1
  26. package/static/dashboard/assets/me-CI9giaT9.js +1 -0
  27. package/static/dashboard/assets/{parts-C1QjM02Y.js → parts-kPNZVO9H.js} +1 -1
  28. package/static/dashboard/assets/{plus-D247LXUb.js → plus-CcJ1Zwa7.js} +1 -1
  29. package/static/dashboard/assets/s._site-D0HRtia-.js +1 -0
  30. package/static/dashboard/assets/{s._site.comments-DEzj9S7b.js → s._site.comments-D3ACsr3a.js} +1 -1
  31. package/static/dashboard/assets/{s._site.reviewers-DZ5GqGMU.js → s._site.reviewers-Djq2t6Dx.js} +1 -1
  32. package/static/dashboard/assets/{s._site.settings-BIjpyBsc.js → s._site.settings-D0b6vJci.js} +1 -1
  33. package/static/dashboard/assets/setup-D748SEIm.js +1 -0
  34. package/static/dashboard/assets/{sign-in-H0jNzIrs.js → sign-in-CKSiZWCo.js} +1 -1
  35. package/static/dashboard/assets/{sign-up-DyiLEKht.js → sign-up-BX9j_Ya2.js} +1 -1
  36. package/static/dashboard/assets/{sites-Dnmo-2Me.js → sites-QwJy87Y8.js} +1 -1
  37. package/static/dashboard/assets/studio-B_ma5JGA.js +1 -0
  38. package/static/dashboard/assets/{studio-enyabWEx.js → studio-HH_J6PPv.js} +1 -1
  39. package/static/dashboard/assets/{studio.index-nkeq6PME.js → studio.index-DrtJF7DT.js} +1 -1
  40. package/static/dashboard/assets/{studio.integrations-BWPo36fJ.js → studio.integrations-Cv34ukzT.js} +1 -1
  41. package/static/dashboard/assets/{studio.members-DXS5CJK_.js → studio.members-DTbKcrEI.js} +1 -1
  42. package/static/dashboard/assets/{sun-BzkBukC4.js → sun-CWPmS6_O.js} +1 -1
  43. package/static/dashboard/assets/{switch-ElcxbE6-.js → switch-CzijGUed.js} +1 -1
  44. package/static/dashboard/assets/{table-DdjoxL3-.js → table-CiZO2uuW.js} +1 -1
  45. package/static/dashboard/assets/{useAriaLabelledBy-BNUj3f_d.js → useAriaLabelledBy-oZFqC809.js} +1 -1
  46. package/static/dashboard/assets/{useBaseQuery-yj7uWlSz.js → useBaseQuery-CHgLQD-M.js} +1 -1
  47. package/static/dashboard/assets/useQuery-C6FyjMS-.js +1 -0
  48. package/static/dashboard/assets/useRender-D5jZ1wns.js +1 -0
  49. package/static/dashboard/assets/{useValueChanged-DQ0Iea1L.js → useValueChanged-Dvr7PvAV.js} +1 -1
  50. package/static/dashboard/assets/{users-DDrXwrCG.js → users-Ci-ogubz.js} +1 -1
  51. package/static/dashboard/assets/welcome-BDWw5Qlv.js +11 -0
  52. package/static/dashboard/assets/{you-CP3bZ82A.js → you-DAUNHAFI.js} +1 -1
  53. package/static/dashboard/assets/{zod-BUdBrC5l.js → zod-CtjFmGX5.js} +1 -1
  54. package/static/dashboard/index.html +1 -1
  55. package/static/dashboard/assets/me-DoCJgtG9.js +0 -1
  56. package/static/dashboard/assets/s._site-BDWAQaIb.js +0 -1
  57. package/static/dashboard/assets/setup-ONHVc5kM.js +0 -1
  58. package/static/dashboard/assets/studio-DxOnhxuB.js +0 -1
  59. package/static/dashboard/assets/useQuery-CBgK187B.js +0 -1
  60. package/static/dashboard/assets/useRender-BHlMpPxr.js +0 -1
  61. package/static/dashboard/assets/welcome-Dg1oA1uA.js +0 -11
@@ -1 +1 @@
1
- import{t as z,r as i,Q as P,S as A,P as J,p as T,T as W,j as e,B as N,y as G,U as ne,A as K}from"./index-B7_Oj3hr.js";import{u as B}from"./useQuery-CBgK187B.js";import{B as U}from"./badge-CQoGgFU8.js";import{E,G as $,I as O,H as R,J as D,K as L}from"./dialog-BO8bYmy1.js";import{L as C,I as F}from"./label-Dpq7t35_.js";import{S as oe}from"./switch-ElcxbE6-.js";import{C as Q}from"./ConfirmDialog-ClUMXHe1.js";import{P as ae,a as V}from"./parts-C1QjM02Y.js";import{C as _}from"./CopyButton-DCsj-LZV.js";import{b as X}from"./labels--UUyt9uB.js";import{u as re}from"./me-DoCJgtG9.js";import"./useBaseQuery-yj7uWlSz.js";import"./useRender-BHlMpPxr.js";import"./useAriaLabelledBy-BNUj3f_d.js";import"./useValueChanged-DQ0Iea1L.js";import"./card-YnwmM74t.js";import"./check-CLHnIgiu.js";import"./copy-ZOZ0pLVD.js";const ie={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function Oe(){const r=re(),c=r.user.role==="owner",u=B(G.integrations()),f=z(),g=()=>f.invalidateQueries({queryKey:["integrations"]}),[b,d]=i.useState(null),[m,h]=i.useState(null),[x,l]=i.useState(null),j=P({mutationFn:t=>T.regenerateGitHubWebhook(t),onSuccess:({webhook:t},o)=>l({site:o,provider:"github",hook:t,fresh:!1}),onError:t=>A.error(J(t))}),v=P({mutationFn:({uid:t,provider:o})=>T.testTracker(t,o).then(a=>({...a,provider:o})),onSuccess:t=>{A[t.ok?"success":"error"](t.ok?`${W[t.provider]} can see ${t.target}`:t.detail??`${W[t.provider]} refused the token`),g()},onError:t=>A.error(J(t))}),p=P({mutationFn:({uid:t,provider:o})=>T.disconnectTracker(t,o),onSuccess:()=>{h(null),g()},onError:t=>A.error(J(t))}),k=u.data?.data??[],y=t=>k.filter(o=>o.provider===t),n=t=>r.projects.filter(o=>!y(t).some(a=>a.site===o.uid));return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(ae,{title:"Integrations",sub:"Mirrors converge on the comment's status here; Slack only announces"}),["github","linear","jira","slack"].map(t=>{const o=y(t),a=n(t);return e.jsxs(V,{title:W[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:[u.isPending&&e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"Reading…"}),u.isSuccess&&o.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(U,{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."})]}),o.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:o.map(s=>{const w=ie[s.health]??{label:s.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:s.siteName??s.site}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("code",{className:"font-mono text-[12.5px]",children:s.provider==="github"?`${s.owner}/${s.repo}`:s.provider==="linear"?`${s.teamKey} · ${s.teamName}`:s.provider==="jira"?`${s.projectKey} · ${s.projectName}`:`#${s.channelName} · ${s.teamName}`}),e.jsx(U,{variant:"outline",className:w.tone==="ok"?"border-ok text-ok":w.tone==="bad"?"border-destructive text-destructive":"",children:w.label}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[s.provider==="slack"?s.createOn==="thread.created"?"A message for every new comment":"Messages when you ask, from the brief":s.createOn==="thread.created"?"An issue for every new comment":"Issues when you ask, from the brief",s.provider==="github"&&s.labels.length?` · labels ${s.labels.join(", ")}`:"",s.provider!=="github"&&s.provider!=="slack"&&!s.hasWebhookSecret?` · no webhook secret yet, so ${W[s.provider]} cannot move comments here`:""," · ",X(s.updatedAt)]}),s.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:s.lastError}),c&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[s.provider==="github"?e.jsx(N,{variant:"ghost",size:"sm",loading:j.isPending,onClick:()=>j.mutate(s.site),children:"Webhook…"}):s.provider==="slack"?null:e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>l({site:s.site,provider:s.provider,hook:{url:`${location.origin}/api/v1/integrations/${s.provider}/inbound`},fresh:!1}),children:"Webhook…"}),e.jsx(N,{variant:"ghost",size:"sm",loading:v.isPending,onClick:()=>v.mutate({uid:s.site,provider:s.provider}),children:"Test"}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>h(s),children:"Disconnect"})]})]},`${s.provider}:${s.site}`)})}),c&&a.length>0&&e.jsx("div",{children:e.jsx(N,{variant:"outline",size:"sm",onClick:()=>d(t),children:"Connect a site…"})})]},t)}),e.jsx(ue,{owner:c,sites:r.projects}),e.jsx(ce,{open:b==="github",onOpenChange:t=>!t&&d(null),sites:n("github"),onDone:(t,o)=>{g(),o&&l({site:t,provider:"github",hook:o,fresh:!0})}}),e.jsx(de,{open:b==="linear",onOpenChange:t=>!t&&d(null),sites:n("linear"),onDone:(t,o)=>{g(),l({site:t,provider:"linear",hook:o,fresh:!0})}}),e.jsx(me,{open:b==="jira",onOpenChange:t=>!t&&d(null),sites:n("jira"),onDone:(t,o)=>{g(),l({site:t,provider:"jira",hook:o,fresh:!0})}}),e.jsx(he,{open:b==="slack",onOpenChange:t=>!t&&d(null),sites:n("slack"),onDone:()=>void g()}),e.jsx(le,{state:x,onClose:()=>l(null),siteName:t=>k.find(o=>o.site===t)?.siteName??"the site"}),e.jsx(Q,{open:m!==null,onOpenChange:t=>!t&&h(null),title:`Disconnect ${m?.siteName??"this site"} from ${m?W[m.provider]:"the tracker"}?`,description:m?.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:p.isPending,onConfirm:async()=>{m&&await p.mutateAsync({uid:m.site,provider:m.provider})}})]})}function ce({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(""),[v,p]=i.useState(!1),[k,y]=i.useState(""),n=P({mutationFn:a=>T.connectTracker(a,"github",{repository:d.trim(),token:h.trim(),labels:l,createOn:v?"thread.created":"manual"})}),t=g||u[0]?.uid||"",o=async a=>{a.preventDefault(),y("");try{const s=await n.mutateAsync(t);m(""),x(""),j(""),p(!1),c(!1),f(t,s.webhook&&"secret"in s.webhook?s.webhook:void 0),A.success("GitHub connected")}catch(s){y(s instanceof K?s.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:a=>void o(a),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to GitHub"}),e.jsxs(D,{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:t,onChange:a=>b(a.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(a=>e.jsx("option",{value:a.uid,children:a.name},a.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-repo",children:"Repository"}),e.jsx(F,{id:"gh-repo",placeholder:"kilnwork/site",value:d,onChange:a=>m(a.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(F,{id:"gh-token",type:"password",placeholder:"github_pat_…",value:h,onChange:a=>x(a.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(F,{id:"gh-labels",placeholder:"review, bug",value:l,onChange:a=>j(a.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:v,onChange:a=>p(a.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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:n.isPending,disabled:!d.trim()||!h.trim()||!t,children:n.isPending?"Checking…":"Connect"})]})]})})})}function le({state:r,onClose:c,siteName:u}){const f=r&&"secret"in r.hook?r.hook.secret:null;return e.jsx(E,{open:r!==null,onOpenChange:g=>!g&&c(),children:e.jsxs($,{children:[e.jsxs(O,{children:[e.jsx(R,{children:r?.fresh?"Connected — now the webhook":"Webhook for "+(r?u(r.site):"")}),e.jsx(D,{children:r?.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.":r?.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${r?.fresh?"":", and the previous one has stopped working"}.`})]}),r&&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:r.hook.url}),e.jsx(_,{text:r.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(_,{text:f,label:"Copy the secret"})]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Events"}),e.jsx("dd",{className:"m-0",children:r.provider==="linear"?"Issues":r.provider==="jira"?"Issue: updated, deleted":"Let me select individual events → Issues"})]}),e.jsx(L,{children:e.jsx(N,{type:"button",onClick:c,children:"Done"})})]})})}function de({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(""),[v,p]=i.useState(!1),[k,y]=i.useState(""),n=P({mutationFn:a=>T.connectTracker(a,"linear",{team:d.trim(),apiKey:h.trim(),...l.trim()?{webhookSecret:l.trim()}:{},createOn:v?"thread.created":"manual"})}),t=g||u[0]?.uid||"",o=async a=>{a.preventDefault(),y("");try{const s=await n.mutateAsync(t);m(""),x(""),j(""),p(!1),c(!1),f(t,s.webhook??{url:`${location.origin}/api/v1/integrations/linear/inbound`}),A.success("Linear connected")}catch(s){y(s instanceof K?s.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:a=>void o(a),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to Linear"}),e.jsx(D,{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:t,onChange:a=>b(a.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(a=>e.jsx("option",{value:a.uid,children:a.name},a.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-team",children:"Team key"}),e.jsx(F,{id:"ln-team",placeholder:"ENG",value:d,onChange:a=>m(a.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(F,{id:"ln-key",type:"password",placeholder:"lin_api_…",value:h,onChange:a=>x(a.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(F,{id:"ln-secret",type:"password",placeholder:"from Linear's webhook, optional",value:l,onChange:a=>j(a.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:v,onChange:a=>p(a.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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:n.isPending,disabled:!d.trim()||!h.trim()||!t,children:n.isPending?"Checking…":"Connect"})]})]})})})}function me({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(""),[v,p]=i.useState(""),[k,y]=i.useState(""),[n,t]=i.useState(!1),[o,a]=i.useState(""),s=P({mutationFn:S=>T.connectTracker(S,"jira",{siteUrl:d.trim(),project:h.trim(),email:l.trim(),apiToken:v.trim(),...k.trim()?{webhookSecret:k.trim()}:{},createOn:n?"thread.created":"manual"})}),w=g||u[0]?.uid||"",H=async S=>{S.preventDefault(),a("");try{const M=await s.mutateAsync(w);x(""),p(""),y(""),t(!1),c(!1),f(w,M.webhook??{url:`${location.origin}/api/v1/integrations/jira/inbound`}),A.success("Jira connected")}catch(M){a(M instanceof K?M.message:"Could not reach the server.")}},I=(S,M,Y,Z,ee,te="text",q)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:`jr-${S}`,children:M}),e.jsx(F,{id:`jr-${S}`,type:te,placeholder:ee,value:Y,onChange:se=>Z(se.target.value),autoComplete:"off"}),q&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:q})]});return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:S=>void H(S),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to Jira"}),e.jsx(D,{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."})]}),o&&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:o}),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:w,onChange:S=>b(S.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(S=>e.jsx("option",{value:S.uid,children:S.name},S.uid))})]}),I("url","Jira site",d,m,"https://kilnwork.atlassian.net"),I("project","Project key",h,x,"KAN","text","The prefix of the project's issues, like the KAN in KAN-12."),I("email","Account email",l,j,"you@kilnwork.studio","email"),I("token","API token",v,p,"","password"),I("secret","Webhook secret",k,y,"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:n,onChange:S=>t(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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:s.isPending,disabled:!d.trim()||!h.trim()||!l.trim()||!v.trim()||!w,children:s.isPending?"Checking…":"Connect"})]})]})})})}function he({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(!0),[v,p]=i.useState(""),k=B({queryKey:["integrations","slack","manifest"],queryFn:()=>T.slackManifest(),enabled:r,staleTime:1/0}),y=P({mutationFn:o=>T.connectTracker(o,"slack",{channel:d.trim(),token:h.trim(),createOn:l?"thread.created":"manual"})}),n=g||u[0]?.uid||"",t=async o=>{o.preventDefault(),p("");try{await y.mutateAsync(n),m(""),x(""),j(!0),c(!1),f(n),A.success("Slack connected")}catch(a){p(a instanceof K?a.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:o=>void t(o),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to Slack"}),e.jsx(D,{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."})]}),v&&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:v}),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:n,onChange:o=>b(o.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(o=>e.jsx("option",{value:o.uid,children:o.name},o.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(N,{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(F,{id:"sl-token",type:"password",placeholder:"xoxb-…",value:h,onChange:o=>x(o.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(F,{id:"sl-channel",placeholder:"#reviews",value:d,onChange:o=>m(o.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:l,onChange:o=>j(o.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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:y.isPending,disabled:!d.trim()||!h.trim()||!n,children:y.isPending?"Checking…":"Connect"})]})]})})})}function ue({owner:r,sites:c}){const u=z(),f=B(G.mcpTokens()),[g,b]=i.useState(!1),[d,m]=i.useState(null),[h,x]=i.useState(null),l=P({mutationFn:n=>T.revokeMcpToken(n),onSuccess:()=>{x(null),u.invalidateQueries({queryKey:["mcp-tokens"]})},onError:n=>A.error(J(n))}),j=f.data?.data??[],v=j.filter(n=>!n.revokedAt),p=f.data?.http??null,k=P({mutationFn:n=>T.setMcpHttp(n),onSuccess:(n,t)=>{u.setQueryData(G.instance().queryKey,n),u.invalidateQueries({queryKey:["mcp-tokens"]}),A.success(t?"Remote transport on — the token dialog shows its config":"Remote transport off — the endpoint answers 404 again")},onError:n=>A.error(J(n))}),y=n=>{const t=new Set(n),o=t.has("comments:write")||t.has("threads:write");return!o&&!t.has("context:read")?"Read-only":o?`Writes: ${[t.has("comments:write")?"reply":"",t.has("threads:write")?"mark ready":""].filter(Boolean).join(", ")}`:"Read-only, with capture context"};return e.jsxs(V,{title:"MCP",description:"A coding agent — Claude Code, Cursor, any MCP client — reads the same brief this dashboard copies, maps a comment to the file in its checkout, and can reply or mark a fix ready. It never resolves: whoever reported a snag decides when it is fixed. A token per agent, shown once, revocable here.",children:[f.isPending&&e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"Reading…"}),p&&e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-md border border-border px-3 py-2.5",children:[e.jsxs("div",{children:[e.jsx(C,{htmlFor:"mcp-http-on",className:"text-[13px] font-medium",children:"Remote transport"}),e.jsxs("p",{className:"m-0 mt-0.5 text-[12px] leading-normal text-muted-foreground",children:[p.enabled?e.jsxs(e.Fragment,{children:["On. An agent anywhere talks to this studio at ",e.jsx("code",{className:"font-mono text-[11.5px]",children:p.url})," with a token as a bearer. No source mapping there; a write needs a token minted for it."]}):e.jsxs(e.Fragment,{children:["Off. Agents reach this studio only from a machine with the checkout. On, ",e.jsx("code",{className:"font-mono text-[11.5px]",children:p.url})," serves the same tools to an agent anywhere, with a token as a bearer."]}),p.source==="env"?" Set by the environment (SNAGSET_MCP_HTTP_ENABLED).":""]})]}),e.jsx(oe,{id:"mcp-http-on","aria-label":"Remote transport",checked:p.enabled,disabled:!r||p.source==="env"||k.isPending,onCheckedChange:n=>k.mutate(n)})]}),f.isSuccess&&v.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(U,{variant:"outline",children:"No tokens"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:"No agent can read this studio yet."})]}),j.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0","aria-label":"Agent tokens",children:j.map(n=>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] ${n.revokedAt?"opacity-60":""}`,children:[e.jsx("span",{className:"font-medium",children:n.name}),e.jsxs("code",{className:"font-mono text-[12.5px] text-muted-foreground",children:[n.prefix,"…"]}),e.jsx(U,{variant:"outline",className:n.revokedAt?"":"border-ok text-ok",children:n.revokedAt?"Revoked":y(n.scopes)}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[n.site?n.site.name:"All sites"," · ",n.lastUsedAt?`last used ${X(n.lastUsedAt)}`:"never used",n.expiresAt&&!n.revokedAt?` · expires ${new Date(n.expiresAt).toLocaleDateString()}`:"",n.createdBy?` · by ${n.createdBy}`:""]}),r&&!n.revokedAt&&e.jsx("span",{className:"ml-auto flex gap-1",children:e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>x(n),children:"Revoke"})})]},n.id))}),r&&e.jsx("div",{children:e.jsx(N,{variant:"outline",size:"sm",onClick:()=>b(!0),children:"New token…"})}),e.jsx(xe,{open:g,onOpenChange:b,sites:c,http:f.data?.http??null,onDone:n=>{u.invalidateQueries({queryKey:["mcp-tokens"]}),m(n)}}),e.jsx(pe,{state:d,http:f.data?.http??null,onClose:()=>m(null)}),e.jsx(Q,{open:h!==null,onOpenChange:n=>!n&&x(null),title:`Revoke “${h?.name??""}”?`,description:e.jsx(e.Fragment,{children:"The agent holding it loses access on its next request. Its past replies stay, under its name. This cannot be undone — mint a new token instead."}),confirmLabel:"Revoke",busy:l.isPending,onConfirm:async()=>{h&&await l.mutateAsync(h.id)}})]})}function xe({open:r,onOpenChange:c,sites:u,http:f,onDone:g}){const[b,d]=i.useState(""),[m,h]=i.useState(""),[x,l]=i.useState(["threads:read","source:map"]),[j,v]=i.useState(""),[p,k]=i.useState(!1),[y,n]=i.useState(""),t=P({mutationFn:()=>T.mintMcpToken({name:b.trim(),...m?{site:m}:{},scopes:x,...j?{expiresInDays:Number(j)}:{},...p?{allowRemoteWrites:!0}:{}})}),o=(s,w)=>l(H=>w?[...new Set([...H,s])]:H.filter(I=>I!==s)),a=async s=>{s.preventDefault(),n("");try{const w=await t.mutateAsync();d(""),h(""),l(["threads:read","source:map"]),v(""),k(!1),c(!1),g(w)}catch(w){n(w instanceof K?w.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:s=>void a(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"New agent token"}),e.jsx(D,{children:"Read-only by default, plus mapping a comment to a file in the agent's own checkout. Tick more only for an agent you want writing here — and it still cannot resolve anything."})]}),y&&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:y}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"mcp-name",children:"Name"}),e.jsx(F,{id:"mcp-name",placeholder:"Claude Code",value:b,onChange:s=>d(s.target.value),autoComplete:"off",maxLength:80}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"What a client sees on the agent's replies, so name the agent, not the person."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"mcp-site",children:"Site"}),e.jsxs("select",{id:"mcp-site",value:m,onChange:s=>h(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:[e.jsx("option",{value:"",children:"All sites"}),u.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))]})]}),e.jsxs("fieldset",{className:"m-0 flex flex-col gap-2 border-0 p-0",children:[e.jsx("legend",{className:"mb-1 text-[13px] font-medium",children:"Scopes"}),ne.map(s=>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:x.includes(s.scope),onChange:w=>o(s.scope,w.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:s.label}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:s.hint})]})]},s.scope))]}),f?.enabled&&(x.includes("comments:write")||x.includes("threads:write"))&&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:p,onChange:s=>k(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"May write over the remote transport"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Over POST /mcp the agent is not on a machine you can see; a write there is a decision."})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"mcp-expires",children:"Expires"}),e.jsxs("select",{id:"mcp-expires",value:j,onChange:s=>v(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:[e.jsx("option",{value:"",children:"Never"}),e.jsx("option",{value:"30",children:"In 30 days"}),e.jsx("option",{value:"90",children:"In 90 days"}),e.jsx("option",{value:"365",children:"In a year"})]})]}),e.jsxs(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:t.isPending,disabled:!b.trim()||x.length===0,children:t.isPending?"Minting…":"Create token"})]})]})})})}function pe({state:r,http:c,onClose:u}){const f=typeof location<"u"?location.origin:"",g={SNAGSET_MCP_TOKEN:r?.secret??"",SNAGSET_MCP_HOST:f,...r?.token.site?{SNAGSET_MCP_PROJECT:r.token.site.uid}:{}},b=JSON.stringify({mcpServers:{snagset:{command:"npx",args:["-y","@snagset/mcp"],env:g}}},null,2),d=["claude mcp add snagset",...Object.entries(g).map(([l,j])=>`-e ${l}=${j}`),"--","npx -y @snagset/mcp"].join(" "),m=`Bearer ${r?.secret??""}`,h=["claude mcp add","--transport http","snagset",c?.url??"",`--header "Authorization: ${m}"`].join(" "),x=JSON.stringify({mcpServers:{snagset:{type:"http",url:c?.url??"",headers:{Authorization:m}}}},null,2);return e.jsx(E,{open:r!==null,onOpenChange:l=>!l&&u(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsxs(O,{children:[e.jsxs(R,{children:["Token for “",r?.token.name??"","”"]}),e.jsx(D,{children:"Shown this once — only its hash is stored. Put it in the agent's config, then start the agent from the site's checkout so it can map comments to files."})]}),r&&e.jsxs("div",{className:"flex flex-col gap-4 text-[13px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1.5 font-mono text-[12px]","data-testid":"mcp-token",children:r.secret}),e.jsx(_,{text:r.secret,label:"Copy the token"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Claude Code"}),e.jsx(_,{text:d,label:"Copy the Claude Code command"})]}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:d})]}),c?.enabled&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Remote — an agent that is not on a machine with the checkout"}),e.jsx(_,{text:x,label:"Copy the remote config"})]}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:h}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:x}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"No source mapping there — nothing to search. Writes need the token minted with remote writes allowed."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Cursor, Claude Desktop, any MCP client"}),e.jsx(_,{text:b,label:"Copy the JSON config"})]}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:b}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Cursor reads it from .cursor/mcp.json in the project; Claude Desktop from its claude_desktop_config.json."})]})]}),e.jsx(L,{children:e.jsx(N,{type:"button",onClick:u,children:"Done"})})]})})}export{Oe as component};
1
+ import{t as z,r as i,Q as P,S as A,P as J,p as T,T as W,j as e,B as N,y as G,U as ne,A as K}from"./index-C6gyyLd5.js";import{u as B}from"./useQuery-C6FyjMS-.js";import{B as U}from"./badge-thtKAJ0h.js";import{E,G as $,I as O,H as R,J as D,K as L}from"./dialog-MC-TOvQV.js";import{L as C,I as F}from"./label-BTdAT39L.js";import{S as oe}from"./switch-CzijGUed.js";import{C as Q}from"./ConfirmDialog-eCzw7vjK.js";import{P as ae,a as V}from"./parts-kPNZVO9H.js";import{C as _}from"./CopyButton-lcjux1TA.js";import{b as X}from"./labels--UUyt9uB.js";import{u as re}from"./me-CI9giaT9.js";import"./useBaseQuery-CHgLQD-M.js";import"./useRender-D5jZ1wns.js";import"./useAriaLabelledBy-oZFqC809.js";import"./useValueChanged-Dvr7PvAV.js";import"./card-CsXE7vKD.js";import"./check-Bc_1fmPx.js";import"./copy-O3USBatC.js";const ie={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function Oe(){const r=re(),c=r.user.role==="owner",u=B(G.integrations()),f=z(),g=()=>f.invalidateQueries({queryKey:["integrations"]}),[b,d]=i.useState(null),[m,h]=i.useState(null),[x,l]=i.useState(null),j=P({mutationFn:t=>T.regenerateGitHubWebhook(t),onSuccess:({webhook:t},o)=>l({site:o,provider:"github",hook:t,fresh:!1}),onError:t=>A.error(J(t))}),v=P({mutationFn:({uid:t,provider:o})=>T.testTracker(t,o).then(a=>({...a,provider:o})),onSuccess:t=>{A[t.ok?"success":"error"](t.ok?`${W[t.provider]} can see ${t.target}`:t.detail??`${W[t.provider]} refused the token`),g()},onError:t=>A.error(J(t))}),p=P({mutationFn:({uid:t,provider:o})=>T.disconnectTracker(t,o),onSuccess:()=>{h(null),g()},onError:t=>A.error(J(t))}),k=u.data?.data??[],y=t=>k.filter(o=>o.provider===t),n=t=>r.projects.filter(o=>!y(t).some(a=>a.site===o.uid));return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(ae,{title:"Integrations",sub:"Mirrors converge on the comment's status here; Slack only announces"}),["github","linear","jira","slack"].map(t=>{const o=y(t),a=n(t);return e.jsxs(V,{title:W[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:[u.isPending&&e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"Reading…"}),u.isSuccess&&o.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(U,{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."})]}),o.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:o.map(s=>{const w=ie[s.health]??{label:s.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:s.siteName??s.site}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("code",{className:"font-mono text-[12.5px]",children:s.provider==="github"?`${s.owner}/${s.repo}`:s.provider==="linear"?`${s.teamKey} · ${s.teamName}`:s.provider==="jira"?`${s.projectKey} · ${s.projectName}`:`#${s.channelName} · ${s.teamName}`}),e.jsx(U,{variant:"outline",className:w.tone==="ok"?"border-ok text-ok":w.tone==="bad"?"border-destructive text-destructive":"",children:w.label}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[s.provider==="slack"?s.createOn==="thread.created"?"A message for every new comment":"Messages when you ask, from the brief":s.createOn==="thread.created"?"An issue for every new comment":"Issues when you ask, from the brief",s.provider==="github"&&s.labels.length?` · labels ${s.labels.join(", ")}`:"",s.provider!=="github"&&s.provider!=="slack"&&!s.hasWebhookSecret?` · no webhook secret yet, so ${W[s.provider]} cannot move comments here`:""," · ",X(s.updatedAt)]}),s.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:s.lastError}),c&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[s.provider==="github"?e.jsx(N,{variant:"ghost",size:"sm",loading:j.isPending,onClick:()=>j.mutate(s.site),children:"Webhook…"}):s.provider==="slack"?null:e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>l({site:s.site,provider:s.provider,hook:{url:`${location.origin}/api/v1/integrations/${s.provider}/inbound`},fresh:!1}),children:"Webhook…"}),e.jsx(N,{variant:"ghost",size:"sm",loading:v.isPending,onClick:()=>v.mutate({uid:s.site,provider:s.provider}),children:"Test"}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>h(s),children:"Disconnect"})]})]},`${s.provider}:${s.site}`)})}),c&&a.length>0&&e.jsx("div",{children:e.jsx(N,{variant:"outline",size:"sm",onClick:()=>d(t),children:"Connect a site…"})})]},t)}),e.jsx(ue,{owner:c,sites:r.projects}),e.jsx(ce,{open:b==="github",onOpenChange:t=>!t&&d(null),sites:n("github"),onDone:(t,o)=>{g(),o&&l({site:t,provider:"github",hook:o,fresh:!0})}}),e.jsx(de,{open:b==="linear",onOpenChange:t=>!t&&d(null),sites:n("linear"),onDone:(t,o)=>{g(),l({site:t,provider:"linear",hook:o,fresh:!0})}}),e.jsx(me,{open:b==="jira",onOpenChange:t=>!t&&d(null),sites:n("jira"),onDone:(t,o)=>{g(),l({site:t,provider:"jira",hook:o,fresh:!0})}}),e.jsx(he,{open:b==="slack",onOpenChange:t=>!t&&d(null),sites:n("slack"),onDone:()=>void g()}),e.jsx(le,{state:x,onClose:()=>l(null),siteName:t=>k.find(o=>o.site===t)?.siteName??"the site"}),e.jsx(Q,{open:m!==null,onOpenChange:t=>!t&&h(null),title:`Disconnect ${m?.siteName??"this site"} from ${m?W[m.provider]:"the tracker"}?`,description:m?.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:p.isPending,onConfirm:async()=>{m&&await p.mutateAsync({uid:m.site,provider:m.provider})}})]})}function ce({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(""),[v,p]=i.useState(!1),[k,y]=i.useState(""),n=P({mutationFn:a=>T.connectTracker(a,"github",{repository:d.trim(),token:h.trim(),labels:l,createOn:v?"thread.created":"manual"})}),t=g||u[0]?.uid||"",o=async a=>{a.preventDefault(),y("");try{const s=await n.mutateAsync(t);m(""),x(""),j(""),p(!1),c(!1),f(t,s.webhook&&"secret"in s.webhook?s.webhook:void 0),A.success("GitHub connected")}catch(s){y(s instanceof K?s.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:a=>void o(a),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to GitHub"}),e.jsxs(D,{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:t,onChange:a=>b(a.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(a=>e.jsx("option",{value:a.uid,children:a.name},a.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"gh-repo",children:"Repository"}),e.jsx(F,{id:"gh-repo",placeholder:"kilnwork/site",value:d,onChange:a=>m(a.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(F,{id:"gh-token",type:"password",placeholder:"github_pat_…",value:h,onChange:a=>x(a.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(F,{id:"gh-labels",placeholder:"review, bug",value:l,onChange:a=>j(a.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:v,onChange:a=>p(a.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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:n.isPending,disabled:!d.trim()||!h.trim()||!t,children:n.isPending?"Checking…":"Connect"})]})]})})})}function le({state:r,onClose:c,siteName:u}){const f=r&&"secret"in r.hook?r.hook.secret:null;return e.jsx(E,{open:r!==null,onOpenChange:g=>!g&&c(),children:e.jsxs($,{children:[e.jsxs(O,{children:[e.jsx(R,{children:r?.fresh?"Connected — now the webhook":"Webhook for "+(r?u(r.site):"")}),e.jsx(D,{children:r?.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.":r?.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${r?.fresh?"":", and the previous one has stopped working"}.`})]}),r&&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:r.hook.url}),e.jsx(_,{text:r.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(_,{text:f,label:"Copy the secret"})]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Events"}),e.jsx("dd",{className:"m-0",children:r.provider==="linear"?"Issues":r.provider==="jira"?"Issue: updated, deleted":"Let me select individual events → Issues"})]}),e.jsx(L,{children:e.jsx(N,{type:"button",onClick:c,children:"Done"})})]})})}function de({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(""),[v,p]=i.useState(!1),[k,y]=i.useState(""),n=P({mutationFn:a=>T.connectTracker(a,"linear",{team:d.trim(),apiKey:h.trim(),...l.trim()?{webhookSecret:l.trim()}:{},createOn:v?"thread.created":"manual"})}),t=g||u[0]?.uid||"",o=async a=>{a.preventDefault(),y("");try{const s=await n.mutateAsync(t);m(""),x(""),j(""),p(!1),c(!1),f(t,s.webhook??{url:`${location.origin}/api/v1/integrations/linear/inbound`}),A.success("Linear connected")}catch(s){y(s instanceof K?s.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:a=>void o(a),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to Linear"}),e.jsx(D,{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:t,onChange:a=>b(a.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(a=>e.jsx("option",{value:a.uid,children:a.name},a.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"ln-team",children:"Team key"}),e.jsx(F,{id:"ln-team",placeholder:"ENG",value:d,onChange:a=>m(a.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(F,{id:"ln-key",type:"password",placeholder:"lin_api_…",value:h,onChange:a=>x(a.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(F,{id:"ln-secret",type:"password",placeholder:"from Linear's webhook, optional",value:l,onChange:a=>j(a.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:v,onChange:a=>p(a.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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:n.isPending,disabled:!d.trim()||!h.trim()||!t,children:n.isPending?"Checking…":"Connect"})]})]})})})}function me({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(""),[v,p]=i.useState(""),[k,y]=i.useState(""),[n,t]=i.useState(!1),[o,a]=i.useState(""),s=P({mutationFn:S=>T.connectTracker(S,"jira",{siteUrl:d.trim(),project:h.trim(),email:l.trim(),apiToken:v.trim(),...k.trim()?{webhookSecret:k.trim()}:{},createOn:n?"thread.created":"manual"})}),w=g||u[0]?.uid||"",H=async S=>{S.preventDefault(),a("");try{const M=await s.mutateAsync(w);x(""),p(""),y(""),t(!1),c(!1),f(w,M.webhook??{url:`${location.origin}/api/v1/integrations/jira/inbound`}),A.success("Jira connected")}catch(M){a(M instanceof K?M.message:"Could not reach the server.")}},I=(S,M,Y,Z,ee,te="text",q)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:`jr-${S}`,children:M}),e.jsx(F,{id:`jr-${S}`,type:te,placeholder:ee,value:Y,onChange:se=>Z(se.target.value),autoComplete:"off"}),q&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:q})]});return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:S=>void H(S),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to Jira"}),e.jsx(D,{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."})]}),o&&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:o}),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:w,onChange:S=>b(S.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(S=>e.jsx("option",{value:S.uid,children:S.name},S.uid))})]}),I("url","Jira site",d,m,"https://kilnwork.atlassian.net"),I("project","Project key",h,x,"KAN","text","The prefix of the project's issues, like the KAN in KAN-12."),I("email","Account email",l,j,"you@kilnwork.studio","email"),I("token","API token",v,p,"","password"),I("secret","Webhook secret",k,y,"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:n,onChange:S=>t(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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:s.isPending,disabled:!d.trim()||!h.trim()||!l.trim()||!v.trim()||!w,children:s.isPending?"Checking…":"Connect"})]})]})})})}function he({open:r,onOpenChange:c,sites:u,onDone:f}){const[g,b]=i.useState(""),[d,m]=i.useState(""),[h,x]=i.useState(""),[l,j]=i.useState(!0),[v,p]=i.useState(""),k=B({queryKey:["integrations","slack","manifest"],queryFn:()=>T.slackManifest(),enabled:r,staleTime:1/0}),y=P({mutationFn:o=>T.connectTracker(o,"slack",{channel:d.trim(),token:h.trim(),createOn:l?"thread.created":"manual"})}),n=g||u[0]?.uid||"",t=async o=>{o.preventDefault(),p("");try{await y.mutateAsync(n),m(""),x(""),j(!0),c(!1),f(n),A.success("Slack connected")}catch(a){p(a instanceof K?a.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:o=>void t(o),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"Connect a site to Slack"}),e.jsx(D,{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."})]}),v&&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:v}),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:n,onChange:o=>b(o.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:u.map(o=>e.jsx("option",{value:o.uid,children:o.name},o.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(N,{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(F,{id:"sl-token",type:"password",placeholder:"xoxb-…",value:h,onChange:o=>x(o.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(F,{id:"sl-channel",placeholder:"#reviews",value:d,onChange:o=>m(o.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:l,onChange:o=>j(o.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(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:y.isPending,disabled:!d.trim()||!h.trim()||!n,children:y.isPending?"Checking…":"Connect"})]})]})})})}function ue({owner:r,sites:c}){const u=z(),f=B(G.mcpTokens()),[g,b]=i.useState(!1),[d,m]=i.useState(null),[h,x]=i.useState(null),l=P({mutationFn:n=>T.revokeMcpToken(n),onSuccess:()=>{x(null),u.invalidateQueries({queryKey:["mcp-tokens"]})},onError:n=>A.error(J(n))}),j=f.data?.data??[],v=j.filter(n=>!n.revokedAt),p=f.data?.http??null,k=P({mutationFn:n=>T.setMcpHttp(n),onSuccess:(n,t)=>{u.setQueryData(G.instance().queryKey,n),u.invalidateQueries({queryKey:["mcp-tokens"]}),A.success(t?"Remote transport on — the token dialog shows its config":"Remote transport off — the endpoint answers 404 again")},onError:n=>A.error(J(n))}),y=n=>{const t=new Set(n),o=t.has("comments:write")||t.has("threads:write");return!o&&!t.has("context:read")?"Read-only":o?`Writes: ${[t.has("comments:write")?"reply":"",t.has("threads:write")?"mark ready":""].filter(Boolean).join(", ")}`:"Read-only, with capture context"};return e.jsxs(V,{title:"MCP",description:"A coding agent — Claude Code, Cursor, any MCP client — reads the same brief this dashboard copies, maps a comment to the file in its checkout, and can reply or mark a fix ready. It never resolves: whoever reported a snag decides when it is fixed. A token per agent, shown once, revocable here.",children:[f.isPending&&e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"Reading…"}),p&&e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-md border border-border px-3 py-2.5",children:[e.jsxs("div",{children:[e.jsx(C,{htmlFor:"mcp-http-on",className:"text-[13px] font-medium",children:"Remote transport"}),e.jsxs("p",{className:"m-0 mt-0.5 text-[12px] leading-normal text-muted-foreground",children:[p.enabled?e.jsxs(e.Fragment,{children:["On. An agent anywhere talks to this studio at ",e.jsx("code",{className:"font-mono text-[11.5px]",children:p.url})," with a token as a bearer. No source mapping there; a write needs a token minted for it."]}):e.jsxs(e.Fragment,{children:["Off. Agents reach this studio only from a machine with the checkout. On, ",e.jsx("code",{className:"font-mono text-[11.5px]",children:p.url})," serves the same tools to an agent anywhere, with a token as a bearer."]}),p.source==="env"?" Set by the environment (SNAGSET_MCP_HTTP_ENABLED).":""]})]}),e.jsx(oe,{id:"mcp-http-on","aria-label":"Remote transport",checked:p.enabled,disabled:!r||p.source==="env"||k.isPending,onCheckedChange:n=>k.mutate(n)})]}),f.isSuccess&&v.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(U,{variant:"outline",children:"No tokens"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:"No agent can read this studio yet."})]}),j.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0","aria-label":"Agent tokens",children:j.map(n=>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] ${n.revokedAt?"opacity-60":""}`,children:[e.jsx("span",{className:"font-medium",children:n.name}),e.jsxs("code",{className:"font-mono text-[12.5px] text-muted-foreground",children:[n.prefix,"…"]}),e.jsx(U,{variant:"outline",className:n.revokedAt?"":"border-ok text-ok",children:n.revokedAt?"Revoked":y(n.scopes)}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[n.site?n.site.name:"All sites"," · ",n.lastUsedAt?`last used ${X(n.lastUsedAt)}`:"never used",n.expiresAt&&!n.revokedAt?` · expires ${new Date(n.expiresAt).toLocaleDateString()}`:"",n.createdBy?` · by ${n.createdBy}`:""]}),r&&!n.revokedAt&&e.jsx("span",{className:"ml-auto flex gap-1",children:e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>x(n),children:"Revoke"})})]},n.id))}),r&&e.jsx("div",{children:e.jsx(N,{variant:"outline",size:"sm",onClick:()=>b(!0),children:"New token…"})}),e.jsx(xe,{open:g,onOpenChange:b,sites:c,http:f.data?.http??null,onDone:n=>{u.invalidateQueries({queryKey:["mcp-tokens"]}),m(n)}}),e.jsx(pe,{state:d,http:f.data?.http??null,onClose:()=>m(null)}),e.jsx(Q,{open:h!==null,onOpenChange:n=>!n&&x(null),title:`Revoke “${h?.name??""}”?`,description:e.jsx(e.Fragment,{children:"The agent holding it loses access on its next request. Its past replies stay, under its name. This cannot be undone — mint a new token instead."}),confirmLabel:"Revoke",busy:l.isPending,onConfirm:async()=>{h&&await l.mutateAsync(h.id)}})]})}function xe({open:r,onOpenChange:c,sites:u,http:f,onDone:g}){const[b,d]=i.useState(""),[m,h]=i.useState(""),[x,l]=i.useState(["threads:read","source:map"]),[j,v]=i.useState(""),[p,k]=i.useState(!1),[y,n]=i.useState(""),t=P({mutationFn:()=>T.mintMcpToken({name:b.trim(),...m?{site:m}:{},scopes:x,...j?{expiresInDays:Number(j)}:{},...p?{allowRemoteWrites:!0}:{}})}),o=(s,w)=>l(H=>w?[...new Set([...H,s])]:H.filter(I=>I!==s)),a=async s=>{s.preventDefault(),n("");try{const w=await t.mutateAsync();d(""),h(""),l(["threads:read","source:map"]),v(""),k(!1),c(!1),g(w)}catch(w){n(w instanceof K?w.message:"Could not reach the server.")}};return e.jsx(E,{open:r,onOpenChange:c,children:e.jsx($,{children:e.jsxs("form",{onSubmit:s=>void a(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(O,{children:[e.jsx(R,{children:"New agent token"}),e.jsx(D,{children:"Read-only by default, plus mapping a comment to a file in the agent's own checkout. Tick more only for an agent you want writing here — and it still cannot resolve anything."})]}),y&&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:y}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"mcp-name",children:"Name"}),e.jsx(F,{id:"mcp-name",placeholder:"Claude Code",value:b,onChange:s=>d(s.target.value),autoComplete:"off",maxLength:80}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"What a client sees on the agent's replies, so name the agent, not the person."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"mcp-site",children:"Site"}),e.jsxs("select",{id:"mcp-site",value:m,onChange:s=>h(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:[e.jsx("option",{value:"",children:"All sites"}),u.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))]})]}),e.jsxs("fieldset",{className:"m-0 flex flex-col gap-2 border-0 p-0",children:[e.jsx("legend",{className:"mb-1 text-[13px] font-medium",children:"Scopes"}),ne.map(s=>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:x.includes(s.scope),onChange:w=>o(s.scope,w.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:s.label}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:s.hint})]})]},s.scope))]}),f?.enabled&&(x.includes("comments:write")||x.includes("threads:write"))&&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:p,onChange:s=>k(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"May write over the remote transport"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Over POST /mcp the agent is not on a machine you can see; a write there is a decision."})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"mcp-expires",children:"Expires"}),e.jsxs("select",{id:"mcp-expires",value:j,onChange:s=>v(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:[e.jsx("option",{value:"",children:"Never"}),e.jsx("option",{value:"30",children:"In 30 days"}),e.jsx("option",{value:"90",children:"In 90 days"}),e.jsx("option",{value:"365",children:"In a year"})]})]}),e.jsxs(L,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(N,{type:"submit",loading:t.isPending,disabled:!b.trim()||x.length===0,children:t.isPending?"Minting…":"Create token"})]})]})})})}function pe({state:r,http:c,onClose:u}){const f=typeof location<"u"?location.origin:"",g={SNAGSET_MCP_TOKEN:r?.secret??"",SNAGSET_MCP_HOST:f,...r?.token.site?{SNAGSET_MCP_PROJECT:r.token.site.uid}:{}},b=JSON.stringify({mcpServers:{snagset:{command:"npx",args:["-y","@snagset/mcp"],env:g}}},null,2),d=["claude mcp add snagset",...Object.entries(g).map(([l,j])=>`-e ${l}=${j}`),"--","npx -y @snagset/mcp"].join(" "),m=`Bearer ${r?.secret??""}`,h=["claude mcp add","--transport http","snagset",c?.url??"",`--header "Authorization: ${m}"`].join(" "),x=JSON.stringify({mcpServers:{snagset:{type:"http",url:c?.url??"",headers:{Authorization:m}}}},null,2);return e.jsx(E,{open:r!==null,onOpenChange:l=>!l&&u(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsxs(O,{children:[e.jsxs(R,{children:["Token for “",r?.token.name??"","”"]}),e.jsx(D,{children:"Shown this once — only its hash is stored. Put it in the agent's config, then start the agent from the site's checkout so it can map comments to files."})]}),r&&e.jsxs("div",{className:"flex flex-col gap-4 text-[13px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1.5 font-mono text-[12px]","data-testid":"mcp-token",children:r.secret}),e.jsx(_,{text:r.secret,label:"Copy the token"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Claude Code"}),e.jsx(_,{text:d,label:"Copy the Claude Code command"})]}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:d})]}),c?.enabled&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Remote — an agent that is not on a machine with the checkout"}),e.jsx(_,{text:x,label:"Copy the remote config"})]}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:h}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:x}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"No source mapping there — nothing to search. Writes need the token minted with remote writes allowed."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Cursor, Claude Desktop, any MCP client"}),e.jsx(_,{text:b,label:"Copy the JSON config"})]}),e.jsx("pre",{className:"m-0 overflow-x-auto rounded-md bg-muted px-3 py-2 font-mono text-[12px]",children:b}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Cursor reads it from .cursor/mcp.json in the project; Claude Desktop from its claude_desktop_config.json."})]})]}),e.jsx(L,{children:e.jsx(N,{type:"button",onClick:u,children:"Done"})})]})})}export{Oe as component};
@@ -1 +1 @@
1
- import{j as e,f as y,r as f,B as u,P as N,C as A,D as h,_ as C,y as R}from"./index-B7_Oj3hr.js";import{u as T}from"./useQuery-CBgK187B.js";import{u as S,a as D}from"./zod-BUdBrC5l.js";import{A as M,a as $}from"./avatar-DlHbKa1H.js";import{B as E}from"./badge-CQoGgFU8.js";import{C as F}from"./card-YnwmM74t.js";import{X as P,E as k,G as B,I as H,H as I,J as O,K as z}from"./dialog-BO8bYmy1.js";import{L as d,I as p}from"./label-Dpq7t35_.js";import{T as L,a as V,b,c,d as _,e as x}from"./table-DdjoxL3-.js";import{C as q}from"./ConfirmDialog-ClUMXHe1.js";import{P as G}from"./parts-C1QjM02Y.js";import{a as J}from"./labels--UUyt9uB.js";import{u as K}from"./me-DoCJgtG9.js";import{c as Q,d as X,e as Y}from"./studio-enyabWEx.js";import{P as U}from"./plus-D247LXUb.js";import"./useBaseQuery-yj7uWlSz.js";import"./useRender-BHlMpPxr.js";function j({className:s,...a}){return e.jsx("select",{className:y("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",s),...a})}function je(){const s=K(),a=s.user.role==="owner",n=T(R.members()),[i,o]=f.useState(!1),r=s.limits.members.limit,l=r!==null&&s.limits.members.used>=r;return e.jsxs("div",{className:"p-7",children:[e.jsx(G,{title:"Members",sub:`${a?"Owners and admins can do everything; only owners change this list.":"Owners and admins can do everything. Ask an owner to change this list."}${r!==null?` ${s.limits.members.used} of ${r} members.`:""}`,actions:a?e.jsxs(u,{onClick:()=>o(!0),disabled:l,title:l?`This studio's plan allows ${r} members.`:void 0,children:[e.jsx(U,{}),"Add member"]}):void 0}),e.jsx(F,{className:"max-w-[1040px] overflow-hidden py-0",children:e.jsxs(L,{children:[e.jsx(V,{children:e.jsxs(b,{children:[e.jsx(c,{children:"Name"}),e.jsx(c,{children:"Email"}),e.jsx(c,{children:"Role"}),a&&e.jsx(c,{className:"w-0"})]})}),e.jsx(_,{children:(n.data?.data??[]).map(t=>e.jsx(W,{m:t,owner:a},t.email))})]})}),e.jsx("p",{className:"m-0 mt-3 max-w-[1040px] text-[12.5px] text-muted-foreground",children:"There is no invitation mail: an owner sets an initial password and hands it over, and the person changes it under You."}),a&&e.jsx(ee,{open:i,onOpenChange:o})]})}function W({m:s,owner:a}){const n=Q(),i=X(),[o,r]=f.useState(!1);return e.jsxs(b,{children:[e.jsx(x,{children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(M,{className:"size-6",children:e.jsx($,{className:"bg-brand-soft text-[10px] font-semibold text-brand",children:J(s.name,s.email)})}),e.jsx("span",{className:"font-medium",children:s.name||s.email}),s.you&&e.jsx(E,{variant:"outline",className:"text-[11px]",children:"you"})]})}),e.jsx(x,{className:"text-muted-foreground",children:s.email}),e.jsx(x,{children:a?e.jsxs(j,{"aria-label":`Role for ${s.email}`,value:s.role,onChange:l=>n.mutate({email:s.email,role:l.target.value}),children:[e.jsx("option",{value:"owner",children:"Owner"}),e.jsx("option",{value:"admin",children:"Admin"})]}):e.jsx("span",{className:"capitalize",children:s.role})}),a&&e.jsxs(x,{className:"text-right",children:[!s.you&&e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.email}`,onClick:()=>r(!0),children:e.jsx(P,{})}),e.jsx(q,{open:o,onOpenChange:r,title:`Remove ${s.name||s.email}?`,description:"Every session of theirs ends now. Nothing they wrote is destroyed.",confirmLabel:"Remove",busy:i.isPending,onConfirm:()=>{r(!1),i.mutate(s.email)}})]})]})}const Z=A({email:h().trim().email("An email address"),name:h().trim().max(120).optional(),role:C(["owner","admin"]),password:h().min(12,"At least 12 characters")});function ee({open:s,onOpenChange:a}){const n=Y(),[i,o]=f.useState(""),{register:r,handleSubmit:l,formState:t,reset:g}=S({resolver:D(Z),defaultValues:{role:"admin"}}),w=l(async m=>{o("");try{await n.mutateAsync({email:m.email,name:m.name??"",role:m.role,password:m.password}),g(),a(!1)}catch(v){o(N(v))}});return e.jsx(k,{open:s,onOpenChange:a,children:e.jsx(B,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(H,{children:[e.jsx(I,{children:"Add a member"}),e.jsx(O,{children:"They sign in with this email and the password you set; there is no invitation mail, so you tell them the password yourself."})]}),i&&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:i}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-email",children:"Email"}),e.jsx(p,{id:"member-email",type:"email",autoComplete:"off","aria-invalid":!!t.errors.email,...r("email")})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-name",children:"Name"}),e.jsx(p,{id:"member-name",autoComplete:"off",...r("name")})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-role",children:"Role"}),e.jsxs(j,{id:"member-role",className:"w-full",...r("role"),children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"owner",children:"Owner"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-password",children:"Initial password"}),e.jsx(p,{id:"member-password",type:"text",autoComplete:"off","aria-invalid":!!t.errors.password,...r("password")}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters — a short phrase of real words is fine. They can change it afterwards."})]}),e.jsxs(z,{children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(u,{type:"submit",loading:t.isSubmitting,children:t.isSubmitting?"Adding…":"Add"})]})]})})})}export{je as component};
1
+ import{j as e,f as y,r as f,B as u,P as N,C as A,D as h,_ as C,y as R}from"./index-C6gyyLd5.js";import{u as T}from"./useQuery-C6FyjMS-.js";import{u as S,a as D}from"./zod-CtjFmGX5.js";import{A as M,a as $}from"./avatar-CWT37Ivf.js";import{B as E}from"./badge-thtKAJ0h.js";import{C as F}from"./card-CsXE7vKD.js";import{X as P,E as k,G as B,I as H,H as I,J as O,K as z}from"./dialog-MC-TOvQV.js";import{L as d,I as p}from"./label-BTdAT39L.js";import{T as L,a as V,b,c,d as _,e as x}from"./table-CiZO2uuW.js";import{C as q}from"./ConfirmDialog-eCzw7vjK.js";import{P as G}from"./parts-kPNZVO9H.js";import{a as J}from"./labels--UUyt9uB.js";import{u as K}from"./me-CI9giaT9.js";import{c as Q,d as X,e as Y}from"./studio-HH_J6PPv.js";import{P as U}from"./plus-CcJ1Zwa7.js";import"./useBaseQuery-CHgLQD-M.js";import"./useRender-D5jZ1wns.js";function j({className:s,...a}){return e.jsx("select",{className:y("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",s),...a})}function je(){const s=K(),a=s.user.role==="owner",n=T(R.members()),[i,o]=f.useState(!1),r=s.limits.members.limit,l=r!==null&&s.limits.members.used>=r;return e.jsxs("div",{className:"p-7",children:[e.jsx(G,{title:"Members",sub:`${a?"Owners and admins can do everything; only owners change this list.":"Owners and admins can do everything. Ask an owner to change this list."}${r!==null?` ${s.limits.members.used} of ${r} members.`:""}`,actions:a?e.jsxs(u,{onClick:()=>o(!0),disabled:l,title:l?`This studio's plan allows ${r} members.`:void 0,children:[e.jsx(U,{}),"Add member"]}):void 0}),e.jsx(F,{className:"max-w-[1040px] overflow-hidden py-0",children:e.jsxs(L,{children:[e.jsx(V,{children:e.jsxs(b,{children:[e.jsx(c,{children:"Name"}),e.jsx(c,{children:"Email"}),e.jsx(c,{children:"Role"}),a&&e.jsx(c,{className:"w-0"})]})}),e.jsx(_,{children:(n.data?.data??[]).map(t=>e.jsx(W,{m:t,owner:a},t.email))})]})}),e.jsx("p",{className:"m-0 mt-3 max-w-[1040px] text-[12.5px] text-muted-foreground",children:"There is no invitation mail: an owner sets an initial password and hands it over, and the person changes it under You."}),a&&e.jsx(ee,{open:i,onOpenChange:o})]})}function W({m:s,owner:a}){const n=Q(),i=X(),[o,r]=f.useState(!1);return e.jsxs(b,{children:[e.jsx(x,{children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(M,{className:"size-6",children:e.jsx($,{className:"bg-brand-soft text-[10px] font-semibold text-brand",children:J(s.name,s.email)})}),e.jsx("span",{className:"font-medium",children:s.name||s.email}),s.you&&e.jsx(E,{variant:"outline",className:"text-[11px]",children:"you"})]})}),e.jsx(x,{className:"text-muted-foreground",children:s.email}),e.jsx(x,{children:a?e.jsxs(j,{"aria-label":`Role for ${s.email}`,value:s.role,onChange:l=>n.mutate({email:s.email,role:l.target.value}),children:[e.jsx("option",{value:"owner",children:"Owner"}),e.jsx("option",{value:"admin",children:"Admin"})]}):e.jsx("span",{className:"capitalize",children:s.role})}),a&&e.jsxs(x,{className:"text-right",children:[!s.you&&e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.email}`,onClick:()=>r(!0),children:e.jsx(P,{})}),e.jsx(q,{open:o,onOpenChange:r,title:`Remove ${s.name||s.email}?`,description:"Every session of theirs ends now. Nothing they wrote is destroyed.",confirmLabel:"Remove",busy:i.isPending,onConfirm:()=>{r(!1),i.mutate(s.email)}})]})]})}const Z=A({email:h().trim().email("An email address"),name:h().trim().max(120).optional(),role:C(["owner","admin"]),password:h().min(12,"At least 12 characters")});function ee({open:s,onOpenChange:a}){const n=Y(),[i,o]=f.useState(""),{register:r,handleSubmit:l,formState:t,reset:g}=S({resolver:D(Z),defaultValues:{role:"admin"}}),w=l(async m=>{o("");try{await n.mutateAsync({email:m.email,name:m.name??"",role:m.role,password:m.password}),g(),a(!1)}catch(v){o(N(v))}});return e.jsx(k,{open:s,onOpenChange:a,children:e.jsx(B,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(H,{children:[e.jsx(I,{children:"Add a member"}),e.jsx(O,{children:"They sign in with this email and the password you set; there is no invitation mail, so you tell them the password yourself."})]}),i&&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:i}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-email",children:"Email"}),e.jsx(p,{id:"member-email",type:"email",autoComplete:"off","aria-invalid":!!t.errors.email,...r("email")})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-name",children:"Name"}),e.jsx(p,{id:"member-name",autoComplete:"off",...r("name")})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-role",children:"Role"}),e.jsxs(j,{id:"member-role",className:"w-full",...r("role"),children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"owner",children:"Owner"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(d,{htmlFor:"member-password",children:"Initial password"}),e.jsx(p,{id:"member-password",type:"text",autoComplete:"off","aria-invalid":!!t.errors.password,...r("password")}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters — a short phrase of real words is fine. They can change it afterwards."})]}),e.jsxs(z,{children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(u,{type:"submit",loading:t.isSubmitting,children:t.isSubmitting?"Adding…":"Add"})]})]})})})}export{je as component};
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-B7_Oj3hr.js";/**
1
+ import{c as t}from"./index-C6gyyLd5.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{r as i,h as ae,Y as re,d as se,W as ie,E as ne,i as M,j as f,Z as oe,f as de}from"./index-B7_Oj3hr.js";import{f as ce,e as le,h as ue,j as fe,u as pe,A as he,k as be,l as ge,c as me,n as ve}from"./label-Dpq7t35_.js";import{L as ke,M as xe}from"./dialog-BO8bYmy1.js";import{u as we}from"./useAriaLabelledBy-BNUj3f_d.js";import{u as ye}from"./useValueChanged-DQ0Iea1L.js";const j=i.createContext(void 0);function Ce(){const r=i.useContext(j);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:k,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,...A}=s,{clearErrors:H}=le(),{state:R,setTouched:W,setDirty:q,validityData:O,setFilled:v,setFocused:P,validationMode:Y,disabled:J,name:U,validation:c}=ue(),{labelId:Z}=fe(),t=J||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}),B=h?void 0:E,[a,G]=be({controlled:k,default:!!x,name:"Switch",state:"checked"});ge(g,z,a,void 0,!t,w),se(()=>{n.current&&v(n.current.checked)},[v]),ye(a,()=>{H(l),q(a!==O.initialValue),v(a),c.change(a)});const{getButtonProps:K,buttonRef:Q}=ie({disabled:t,native:h}),X=we(m,Z,n,!h,B),$={id:h?E:z,role:"switch","aria-checked":a,"aria-readonly":d||void 0,"aria-required":b||void 0,"aria-labelledby":X,onFocus(){t||P(!0)},onBlur(){const e=n.current;!e||t||(W(!0),P(!1),Y==="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:B,name:l,required:b,style:l?ke: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,S=me(ve,e.nativeEvent);V?.(u,S),!S.isCanceled&&G(u)},onClick(e){e.stopPropagation()},onFocus(){g.current?.focus()},...C!==void 0?{value:C}:ne},I=i.useMemo(()=>({...R,checked:a,disabled:t,readOnly:d,required:b}),[R,a,t,d,b]),te=M("span",s,{state:I,ref:[o,g,Q],props:[$,A,K,e=>c.getValidationProps(t,e)],stateAttributesMapping:D});return f.jsxs(j.Provider,{value:I,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:k,className:F,style:x,...m}=s,p=Ce();return M("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
+ import{r as i,h as ae,Y as re,d as se,W as ie,E as ne,i as M,j as f,Z as oe,f as de}from"./index-C6gyyLd5.js";import{f as ce,e as le,h as ue,j as fe,u as pe,A as he,k as be,l as ge,c as me,n as ve}from"./label-BTdAT39L.js";import{L as ke,M as xe}from"./dialog-MC-TOvQV.js";import{u as we}from"./useAriaLabelledBy-oZFqC809.js";import{u as ye}from"./useValueChanged-Dvr7PvAV.js";const j=i.createContext(void 0);function Ce(){const r=i.useContext(j);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:k,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,...A}=s,{clearErrors:H}=le(),{state:R,setTouched:W,setDirty:q,validityData:O,setFilled:v,setFocused:P,validationMode:Y,disabled:J,name:U,validation:c}=ue(),{labelId:Z}=fe(),t=J||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}),B=h?void 0:E,[a,G]=be({controlled:k,default:!!x,name:"Switch",state:"checked"});ge(g,z,a,void 0,!t,w),se(()=>{n.current&&v(n.current.checked)},[v]),ye(a,()=>{H(l),q(a!==O.initialValue),v(a),c.change(a)});const{getButtonProps:K,buttonRef:Q}=ie({disabled:t,native:h}),X=we(m,Z,n,!h,B),$={id:h?E:z,role:"switch","aria-checked":a,"aria-readonly":d||void 0,"aria-required":b||void 0,"aria-labelledby":X,onFocus(){t||P(!0)},onBlur(){const e=n.current;!e||t||(W(!0),P(!1),Y==="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:B,name:l,required:b,style:l?ke: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,S=me(ve,e.nativeEvent);V?.(u,S),!S.isCanceled&&G(u)},onClick(e){e.stopPropagation()},onFocus(){g.current?.focus()},...C!==void 0?{value:C}:ne},I=i.useMemo(()=>({...R,checked:a,disabled:t,readOnly:d,required:b}),[R,a,t,d,b]),te=M("span",s,{state:I,ref:[o,g,Q],props:[$,A,K,e=>c.getValidationProps(t,e)],stateAttributesMapping:D});return f.jsxs(j.Provider,{value:I,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:k,className:F,style:x,...m}=s,p=Ce();return M("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,f as l}from"./index-B7_Oj3hr.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,f as l}from"./index-C6gyyLd5.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,d as l}from"./index-B7_Oj3hr.js";import{u as c}from"./label-Dpq7t35_.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,d as l}from"./index-C6gyyLd5.js";import{u as c}from"./label-BTdAT39L.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{aH as N,aI as h,aJ as O,aK as U,aL as k,aM as B,aN as A,aO as y,aP as H,aQ as V,aR as Q,aS as x,r as p,aT as F,t as W}from"./index-B7_Oj3hr.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#a;#c;#i;#p;#u;#l;#n;#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),w(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.#a=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(n=>{r=n,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),n(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const n=this.createResult(s,e);return r?.(n),n}).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.#n=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.#n!==void 0&&(y.clearTimeout(this.#n),this.#n=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.#a,n=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let a={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&w(t,e),L=f&&P(t,s,e,i);(D||L)&&(a={...a,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=a;o=a.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===n?.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=Q(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=Q(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=a.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,M=o!==void 0;return{status:b,fetchStatus:a.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:a.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:a.dataUpdateCount>u.dataUpdateCount||a.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!M,isPaused:a.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&M,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.#a=this.#t.state,this.#c=this.options,this.#a.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 n=new Set(c??this.#d);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&n.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 j(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function w(t,e){return j(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 J=p.createContext(K()),G=()=>p.useContext(J),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=G(),c=W(),n=c.defaultQueryOptions(t),u=c.getQueryCache().get(n.queryHash),l=t.subscribed!==!1;n._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(n),X(n,r,u),Y(r);const[a]=p.useState(()=>new e(c,n)),d=a.getOptimisticResult(n),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?a.subscribe(x.batchCalls(R)):U;return a.updateResult(),v},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setOptions(n)},[n,a]),q(n,d))throw tt(n,a,r);if(Z({result:d,errorResetBoundary:r,throwOnError:n.throwOnError,query:u,suspense:n.suspense}))throw d.error;return n.notifyOnChangeProps?d:a.trackResult(d)}export{st as Q,it as d,rt as u};
1
+ import{aH as N,aI as h,aJ as O,aK as U,aL as k,aM as B,aN as A,aO as y,aP as H,aQ as V,aR as Q,aS as x,r as p,aT as F,t as W}from"./index-C6gyyLd5.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#a;#c;#i;#p;#u;#l;#n;#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),w(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.#a=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(n=>{r=n,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),n(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const n=this.createResult(s,e);return r?.(n),n}).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.#n=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.#n!==void 0&&(y.clearTimeout(this.#n),this.#n=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.#a,n=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let a={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&w(t,e),L=f&&P(t,s,e,i);(D||L)&&(a={...a,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=a;o=a.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===n?.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=Q(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=Q(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=a.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,M=o!==void 0;return{status:b,fetchStatus:a.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:a.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:a.dataUpdateCount>u.dataUpdateCount||a.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!M,isPaused:a.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&M,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.#a=this.#t.state,this.#c=this.options,this.#a.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 n=new Set(c??this.#d);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&n.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 j(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function w(t,e){return j(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 J=p.createContext(K()),G=()=>p.useContext(J),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=G(),c=W(),n=c.defaultQueryOptions(t),u=c.getQueryCache().get(n.queryHash),l=t.subscribed!==!1;n._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(n),X(n,r,u),Y(r);const[a]=p.useState(()=>new e(c,n)),d=a.getOptimisticResult(n),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?a.subscribe(x.batchCalls(R)):U;return a.updateResult(),v},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setOptions(n)},[n,a]),q(n,d))throw tt(n,a,r);if(Z({result:d,errorResetBoundary:r,throwOnError:n.throwOnError,query:u,suspense:n.suspense}))throw d.error;return n.notifyOnChangeProps?d:a.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-CHgLQD-M.js";function a(e,s){return r(e,u)}export{a as u};
@@ -0,0 +1 @@
1
+ import{i as n}from"./index-C6gyyLd5.js";function u(e){return n(e.defaultTagName??"div",e,e)}export{u};
@@ -1 +1 @@
1
- import{r as s,e as c,d as n}from"./index-B7_Oj3hr.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,e as c,d as n}from"./index-C6gyyLd5.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-B7_Oj3hr.js";/**
1
+ import{c as e}from"./index-C6gyyLd5.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,11 @@
1
+ import{c as z,H as Q,o as B,t as K,r as d,j as e,G as L,f as k,B as n,p as w,y as g,A as S}from"./index-C6gyyLd5.js";import{C as f}from"./card-CsXE7vKD.js";import{L as C,I as q}from"./label-BTdAT39L.js";import{I as P}from"./InstallTag-Eqs3RM9e.js";import{C as R}from"./check-Bc_1fmPx.js";import{A}from"./arrow-left-CQUHEFUP.js";import"./copy-O3USBatC.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 T=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],j=z("arrow-right",T);/**
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 _=[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]],G=z("party-popper",_),I=["Site","Address","Install"];function J(){const{me:D,site:r}=Q.useRouteContext(),b=B(),l=K(),[a,c]=d.useState(0),[o,M]=d.useState(r.name==="First project"?"":r.name),[x,E]=d.useState(""),[i,h]=d.useState(!1),[m,y]=d.useState(!1),[v,p]=d.useState(""),F=async()=>{h(!0),y(!0),p("");try{await w.deleteSite(r.uid),l.removeQueries({queryKey:["origins",r.uid]}),await l.fetchQuery(g.me()),b({to:"/sites",replace:!0})}catch(t){p(t instanceof S?t.message:"Something went wrong. Try again."),h(!1),y(!1)}},N=async(t,s)=>{h(!0),p("");try{await w.editSite(r.uid,t),t.domain&&l.setQueryData(g.origins(r.uid).queryKey,{domain:t.domain,origins:[]}),await l.invalidateQueries({queryKey:g.me().queryKey}),await l.fetchQuery(g.me()),s()}catch(u){p(u instanceof S?u.message:"Could not reach the server.")}finally{h(!1)}};return e.jsx("div",{className:"relative min-h-dvh bg-background",children:e.jsxs(L,{width:600,children:[e.jsxs("div",{className:"absolute right-6 top-5 text-[12.5px] text-muted-foreground",children:["Signed in as ",D.user.email]}),a<3&&e.jsx("ol",{className:"m-0 mb-6 flex list-none items-center gap-3.5 p-0","aria-label":"Steps",children:I.map((t,s)=>e.jsxs("li",{className:"flex items-center gap-2.5 text-[13.5px] font-medium",children:[e.jsx("span",{className:k("flex size-7 items-center justify-center rounded-full border-[1.5px] text-[12.5px]",s<a&&"border-brand bg-brand text-brand-foreground",s===a&&"border-brand text-brand ring-[3px] ring-brand-soft",s>a&&"border-line-strong text-muted-foreground"),"aria-current":s===a?"step":void 0,children:s<a?e.jsx(R,{className:"size-3.5"}):s+1}),e.jsx("span",{className:s===a?"text-foreground":"text-muted-foreground",children:t}),s<I.length-1&&e.jsx("span",{className:k("h-px w-[90px]",s<a?"bg-brand":"bg-border")})]},t))}),v&&e.jsx("p",{role:"alert",className:"m-0 mb-4 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:v}),a===0&&e.jsx(f,{className:"gap-4 p-7",children:e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:t=>{t.preventDefault(),!(!o.trim()||i)&&N({name:o.trim()},()=>c(1))},children:[e.jsxs("div",{children:[e.jsx("h1",{className:"m-0 text-[21px] font-semibold leading-tight tracking-tight",children:"What is the site called?"}),e.jsx("p",{className:"m-0 mt-2 text-muted-foreground",children:"One client website. You can add more from Sites later."})]}),e.jsxs("fieldset",{disabled:i,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"first-name",children:"Name"}),e.jsx(q,{id:"first-name",placeholder:"Kilnwork",value:o,onChange:t=>M(t.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(n,{type:"button",variant:"ghost",loading:m,disabled:i&&!m,onClick:()=>void F(),children:"Skip for now"}),e.jsxs(n,{type:"submit",loading:i&&!m,disabled:!o.trim()||m,children:[i&&!m?"Saving…":"Continue",e.jsx(j,{})]})]})]}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"No site yet? Skip, and add one from Sites when it is ready."})]})}),a===1&&e.jsx(f,{className:"gap-4 p-7",children:e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:t=>{t.preventDefault(),!(!x.trim()||i)&&N({domain:x.trim()},()=>c(2))},children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"m-0 text-[21px] font-semibold leading-tight tracking-tight",children:["Where does ",o||r.name," live?"]}),e.jsx("p",{className:"m-0 mt-2 text-muted-foreground",children:"Its domain. Every subdomain, scheme and port of it may run the widget — staging, previews, and localhost while you build. Exact addresses elsewhere can be added in the site's settings."})]}),e.jsxs("fieldset",{disabled:i,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{htmlFor:"first-domain",children:"Domain"}),e.jsx(q,{id:"first-domain",placeholder:"kilnwork.studio",value:x,onChange:t=>E(t.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs(n,{type:"button",variant:"ghost",onClick:()=>c(0),children:[e.jsx(A,{}),"Back"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(n,{type:"submit",loading:i,disabled:!x.trim(),children:[i?"Saving…":"Continue",e.jsx(j,{})]})]})]})]})}),a===2&&e.jsxs(f,{className:"gap-4 p-7",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"m-0 text-[21px] font-semibold leading-tight tracking-tight",children:"Install the widget"}),e.jsxs("p",{className:"m-0 mt-2 text-muted-foreground",children:["Paste this before ",e.jsx("code",{className:"font-mono",children:"</body>"})," on every page you want reviewed, and deploy."]})]}),e.jsx(P,{uid:r.uid}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs(n,{type:"button",variant:"ghost",onClick:()=>c(1),children:[e.jsx(A,{}),"Back"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(n,{type:"button",onClick:()=>c(3),children:["Done",e.jsx(j,{})]})]})]}),a===3&&e.jsxs(f,{className:"items-center gap-4 p-8 text-center",children:[e.jsx("span",{className:"flex size-11 items-center justify-center rounded-[10px] bg-brand-soft text-brand",children:e.jsx(G,{className:"size-5"})}),e.jsxs("h1",{className:"m-0 text-[21px] font-semibold leading-tight tracking-tight",children:[o||r.name," is set up"]}),e.jsx("p",{className:"m-0 text-muted-foreground",children:"Three things left, in this order."}),e.jsx("ol",{className:"m-0 flex w-full list-none flex-col gap-2 p-0 text-left",children:[["Deploy the site with the tag on every page","Comments start arriving here the moment a page loads it."],["Add a reviewer and send them their link","Your client gets their own link; you can revoke it without touching the site."],["Start the first round","A round is one pass of feedback. Starting the next one closes the last."]].map(([t,s],u)=>e.jsxs("li",{className:"flex gap-3 rounded-md border border-border px-3 py-2.5",children:[e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full border border-line-strong text-[11px] text-muted-foreground",children:u+1}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium",children:t}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:s})]})]},t))}),e.jsxs(n,{size:"lg",className:"mt-2 w-full",onClick:()=>void b({to:"/s/$site/comments",params:{site:r.uid},replace:!0}),children:["Go to Comments",e.jsx(j,{})]})]})]})})}export{J as component};
@@ -1 +1 @@
1
- import{r,v as w,j as e,f as b,w as y,B as f,P as N}from"./index-B7_Oj3hr.js";import{L as c,I as m}from"./label-Dpq7t35_.js";import{P as S,a as h}from"./parts-C1QjM02Y.js";import{S as C}from"./SaveState-B-6cG0nU.js";import{u as P}from"./me-DoCJgtG9.js";import{u as A,a as k}from"./studio-enyabWEx.js";import{M as F,S as E,a as M}from"./sun-BzkBukC4.js";import"./card-YnwmM74t.js";import"./labels--UUyt9uB.js";import"./useBaseQuery-yj7uWlSz.js";function T({items:t}){const[a,n]=r.useState(w);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:()=>{y(s.value),n(s.value)},className:b("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 J(){const t=P(),a=A(),[n,s]=r.useState(t.user.name),[u,l]=r.useState(null);r.useEffect(()=>s(t.user.name),[t.user.name]);const d=n.trim()!==t.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(S,{title:"You",sub:"Your own account on this studio",actions:e.jsx(C,{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:i=>{i.preventDefault(),d&&a.mutate(n.trim(),{onSuccess:()=>l(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{id:"your-name",value:n,onChange:i=>s(i.target.value)}),d&&e.jsx(f,{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(m,{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(D,{})}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(T,{items:[{value:"system",label:"System",icon:e.jsx(F,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(E,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(M,{className:"size-3.5"})}]})})]})}function D(){const t=k(),[a,n]=r.useState(""),[s,u]=r.useState(""),[l,d]=r.useState(""),[i,g]=r.useState(""),[j,x]=r.useState(!1),p=a.length>0&&s.length>=12&&s===l;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async o=>{if(o.preventDefault(),!(!p||t.isPending)){g("");try{await t.mutateAsync({current:a,next:s}),n(""),u(""),d(""),x(!0)}catch(v){g(N(v))}}},children:[i&&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:i}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(m,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:o=>{n(o.target.value),x(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(m,{id:"pw-next",type:"password",autoComplete:"new-password",value:s,onChange:o=>{u(o.target.value),x(!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(m,{id:"pw-again",type:"password",autoComplete:"new-password",value:l,onChange:o=>{d(o.target.value),x(!1)}}),l.length>0&&s!==l&&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(f,{type:"submit",loading:t.isPending,disabled:!p,children:t.isPending?"Changing…":j&&!p?"Changed":"Change password"})})]})}export{J as component};
1
+ import{r,v as w,j as e,f as b,w as y,B as f,P as N}from"./index-C6gyyLd5.js";import{L as c,I as m}from"./label-BTdAT39L.js";import{P as S,a as h}from"./parts-kPNZVO9H.js";import{S as C}from"./SaveState-Cf_bnJmg.js";import{u as P}from"./me-CI9giaT9.js";import{u as A,a as k}from"./studio-HH_J6PPv.js";import{M as F,S as E,a as M}from"./sun-CWPmS6_O.js";import"./card-CsXE7vKD.js";import"./labels--UUyt9uB.js";import"./useBaseQuery-CHgLQD-M.js";function T({items:t}){const[a,n]=r.useState(w);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:()=>{y(s.value),n(s.value)},className:b("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 J(){const t=P(),a=A(),[n,s]=r.useState(t.user.name),[u,l]=r.useState(null);r.useEffect(()=>s(t.user.name),[t.user.name]);const d=n.trim()!==t.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(S,{title:"You",sub:"Your own account on this studio",actions:e.jsx(C,{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:i=>{i.preventDefault(),d&&a.mutate(n.trim(),{onSuccess:()=>l(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{id:"your-name",value:n,onChange:i=>s(i.target.value)}),d&&e.jsx(f,{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(m,{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(D,{})}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(T,{items:[{value:"system",label:"System",icon:e.jsx(F,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(E,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(M,{className:"size-3.5"})}]})})]})}function D(){const t=k(),[a,n]=r.useState(""),[s,u]=r.useState(""),[l,d]=r.useState(""),[i,g]=r.useState(""),[j,x]=r.useState(!1),p=a.length>0&&s.length>=12&&s===l;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async o=>{if(o.preventDefault(),!(!p||t.isPending)){g("");try{await t.mutateAsync({current:a,next:s}),n(""),u(""),d(""),x(!0)}catch(v){g(N(v))}}},children:[i&&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:i}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(m,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:o=>{n(o.target.value),x(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(m,{id:"pw-next",type:"password",autoComplete:"new-password",value:s,onChange:o=>{u(o.target.value),x(!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(m,{id:"pw-again",type:"password",autoComplete:"new-password",value:l,onChange:o=>{d(o.target.value),x(!1)}}),l.length>0&&s!==l&&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(f,{type:"submit",loading:t.isPending,disabled:!p,children:t.isPending?"Changing…":j&&!p?"Changed":"Change password"})})]})}export{J as component};
@@ -1 +1 @@
1
- import{au as I}from"./index-B7_Oj3hr.js";var me=e=>e.type==="checkbox",Se=e=>e.type==="file",te=e=>e instanceof Date,p=e=>e==null;const He=e=>typeof e=="object";var N=e=>!p(e)&&!Array.isArray(e)&&He(e)&&!te(e),Gr=e=>N(e)&&e.target?me(e.target)?e.target.checked:Se(e.target)?e.target.files:e.target.value:e;const Kr=/[.[\]'"]/;var ue=e=>e.split(Kr).filter(Boolean),Zr=(e,s)=>s.split(".").some((r,i,l)=>!isNaN(Number(r))&&e.has(l.slice(0,i).join("."))),Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function C(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Te&&(e instanceof Blob||s))return e;const r=Array.isArray(e);if(!r&&e.constructor!==Object)return e;const i=r?[]:Object.create(Object.getPrototypeOf(e));for(const l in e)Object.prototype.hasOwnProperty.call(e,l)&&(i[l]=C(e[l]));return i}const oe={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},X={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},J={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dr="root",je=["__proto__","constructor","prototype"],Jr=/^\w*$/;var ne=e=>Jr.test(e),O=e=>e===void 0,v=(e,s,r)=>{if(!s||!N(e))return r;const i=ne(s)?[s]:ue(s);if(i.some(u=>je.includes(u)))return r;const l=i.reduce((u,o)=>p(u)?void 0:u[o],e);return O(l)||l===e?O(e[s])?r:e[s]:l},re=e=>typeof e=="boolean",G=e=>typeof e=="function",k=(e,s,r)=>{let i=-1;const l=ne(s)?[s]:ue(s),u=l.length,o=u-1;for(;++i<u;){const c=l[i];let m=r;if(i!==o){const E=e[c];m=N(E)||Array.isArray(E)?E:isNaN(+l[i+1])?{}:[]}if(je.includes(c))return;e[c]=m,e=e[c]}};const Qr=I.createContext(null);Qr.displayName="HookFormControlContext";var Xr=(e,s,r,i=!0)=>{const l={};for(const u in e)Object.defineProperty(l,u,{get:()=>{const o=u;return s._proxyFormState[o]!==X.all&&(s._proxyFormState[o]=!i||X.all),e[o]}});return l};const et=Te?I.useLayoutEffect:I.useEffect;var rt=e=>{const s=e.constructor&&e.constructor.prototype;return N(s)&&s.hasOwnProperty("isPrototypeOf")},Me=e=>p(e)||!He(e);const lr=(e,s)=>s.length===0&&!Array.isArray(e)&&!rt(e);function Q(e,s,r=new WeakMap){if(e===s)return!0;if(Me(e)||Me(s))return Object.is(e,s);if(te(e)&&te(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),l=Object.keys(s);if(i.length!==l.length)return!1;if(lr(e,i)||lr(s,l))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const u=r.get(e);if(u&&u.has(s))return!0;if(u)u.add(s);else{const o=new WeakSet;o.add(s),r.set(e,o)}for(const o of i){const c=e[o];if(!(o in s))return!1;if(o!=="ref"){const m=s[o];if(te(c)&&te(m)||(N(c)||Array.isArray(c))&&(N(m)||Array.isArray(m))?!Q(c,m,r):!Object.is(c,m))return!1}}return!0}function tt(e){const s=I.useRef(!1),r=I.useRef(!1),i=I.useRef(void 0),l=I.useRef(0);l.current++,r.current;const u=I.useCallback((c,m,E)=>{if(c&&(s.current||r.current&&l.current>1)){const T=m();Q(i.current,T)||E(T)}s.current=!0},[]),o=I.useCallback((c,m)=>{c&&(i.current=C(m()))},[]);return{resyncIfNeeded:u,snapshot:o}}var M=e=>typeof e=="string",st=(e,s,r,i,l)=>M(e)?(i&&s.watch.add(e),v(r,e,l)):Array.isArray(e)?e.map(u=>(i&&s.watch.add(u),v(r,u,v(l,u)))):(i&&(s.watchAll=!0),r),De=e=>({isOnSubmit:!e||e===X.onSubmit,isOnBlur:e===X.onBlur,isOnChange:e===X.onChange,isOnAll:e===X.all,isOnTouch:e===X.onTouched}),Ue=(e,s,r)=>{if(r)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Ve=(e,s,r,i)=>{for(const l of r||Object.keys(e)){if(l==="_f")continue;const u=r?v(e,l):e[l];if(u){const{_f:o}=u;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],l)&&!i)return!0;if(o.ref&&s(o.ref,o.name)&&!i)return!0;if(Ve(u,s))break}else if((N(u)||Array.isArray(u))&&Ve(u,s))break}}};var ur=(e,s,r)=>{const i=v(e,r),l=Array.isArray(i)?i:[];return k(l,Dr,s[r]),k(e,r,l),e},B=e=>N(e)&&!Object.keys(e).length,ke=e=>{if(!Te)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},ze=e=>e.type==="radio",Oe=e=>e instanceof RegExp,Ye=(e,s,r,i,l)=>s?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[i]:l||!0}}:{};const fr={value:!1,isValid:!1},cr={value:!0,isValid:!0};var xr=e=>{if(!Array.isArray(e))return fr;if(e.length>1){const r=e.filter(i=>i&&i.checked&&!i.disabled).map(i=>i.value);return{value:r,isValid:!!r.length}}const s=e[0];return!s||!s.checked||s.disabled?fr:!s.attributes||!("value"in s.attributes)||O(s.value)||s.value===""?cr:{value:s.value,isValid:!0}};const dr={isValid:!1,value:null};var kr=e=>Array.isArray(e)?e.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,dr):dr;function yr(e,s,r="validate"){if(M(e)||Array.isArray(e)&&e.every(M)||re(e)&&!e)return{type:r,message:M(e)?e:"",ref:s}}var le=e=>N(e)&&!Oe(e)?e:{value:e,message:""},hr=async(e,s,r,i,l,u)=>{const{ref:o,refs:c,required:m,maxLength:E,minLength:T,min:H,max:j,pattern:$,validate:A,name:F,valueAsNumber:b,mount:fe}=e._f,w=v(r,F);if(!fe||s.has(F))return{};const ee=c?c[0]:o,P=D=>{if(l&&ee.reportValidity){const x=re(D)?"":D||"";c?c.forEach(R=>R.setCustomValidity(x)):ee.setCustomValidity(x),ee.reportValidity()}},S={},ce=ze(o),be=me(o),Ae=ce||be,ae=(b||Se(o))&&O(o.value)&&O(w)||ke(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,se=Ye.bind(null,F,i,S),Fe=(D,x,R,W=J.maxLength,K=J.minLength)=>{const q=D?x:R;S[F]={type:D?W:K,message:q,ref:o,...se(D?W:K,q)}};if(u?!Array.isArray(w)||!w.length:m&&(!Ae&&(ae||p(w))||re(w)&&!w||be&&!xr(c).isValid||ce&&!kr(c).isValid)){const{value:D,message:x}=M(m)?{value:!!m,message:m}:le(m);if(D&&(S[F]={type:J.required,message:x,ref:ee,...se(J.required,x)},!i))return P(x),S}if(!ae&&(!p(H)||!p(j))){let D,x;const R=le(j),W=le(H);if(!p(w)&&!te(w)&&!isNaN(w)){const K=o.valueAsNumber||w&&+w;p(R.value)||(D=K>R.value),p(W.value)||(x=K<W.value)}else{const K=o.valueAsDate||new Date(w),q=ye=>new Date(new Date().toDateString()+" "+ye),we=o.type=="time",Y=o.type=="week";M(R.value)&&w&&(D=we?q(w)>q(R.value):Y?w>R.value:K>new Date(R.value)),M(W.value)&&w&&(x=we?q(w)<q(W.value):Y?w<W.value:K<new Date(W.value))}if((D||x)&&(Fe(!!D,R.message,W.message,J.max,J.min),!i))return P(S[F].message),S}if((E||T)&&!ae&&(M(w)||u&&Array.isArray(w))){const D=le(E),x=le(T),R=!p(D.value)&&w.length>+D.value,W=!p(x.value)&&w.length<+x.value;if((R||W)&&(Fe(R,D.message,x.message),!i))return P(S[F].message),S}if($&&!ae&&M(w)){const{value:D,message:x}=le($);if(Oe(D)&&!w.match(D)&&(S[F]={type:J.pattern,message:x,ref:o,...se(J.pattern,x)},!i))return P(x),S}if(A){if(G(A)){const D=await A(w,r),x=yr(D,ee);if(x&&(S[F]={...x,...se(J.validate,x.message)},!i))return P(x.message),S}else if(N(A)){let D={};for(const x in A){if(!B(D)&&!i)break;const R=yr(await A[x](w,r),ee,x);R&&(D={...R,...se(x,R.message)},P(R.message),i&&(S[F]=D))}if(!B(D)&&(S[F]={ref:ee,...D},!i))return S}}const de=S[F];return P(de?de.message:!0),S},xe=e=>Array.isArray(e)?e:[e],Or=e=>Array.isArray(e)?e.filter(Boolean):[];function it(e,s){const r=s.length-1;let i=0;for(;i<r;){if(p(e)){e=void 0;break}e=e[s[i]],i++}return e}function nt(e){for(const s in e)if(e.hasOwnProperty(s)&&!O(e[s]))return!1;return!0}function U(e,s){if(M(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const r=Array.isArray(s)?s:ne(s)?[s]:ue(s);if(r.some(o=>je.includes(String(o))))return e;const i=r.length===1?e:it(e,r),l=r.length-1,u=r[l];return i&&delete i[u],l!==0&&(N(i)&&B(i)||Array.isArray(i)&&nt(i))&&U(e,r.slice(0,-1)),e}const at=I.createContext(null);at.displayName="HookFormContext";var gr=()=>{let e=[];return{get observers(){return e},next:l=>{for(const u of e)u.next&&u.next(l)},subscribe:l=>(e.push(l),{unsubscribe:()=>{e=e.filter(u=>u!==l)}}),unsubscribe:()=>{e=[]}}};function Sr(e,s){const r={};for(const i in e)if(e.hasOwnProperty(i)){const l=e[i],u=s[i];if(l&&N(l)&&u){const o=Sr(l,u);N(o)&&(r[i]=o)}else e[i]&&(r[i]=u)}return r}const vr=(e,s)=>e!==null&&He(e)&&Object.prototype.hasOwnProperty.call(e,s);var ot=(e,s)=>{if(!s)return!1;let r=e;for(const i of ne(s)?[s]:ue(s)){if(!vr(r,i))return vr(e,s);r=r[i]}return!0},Tr=e=>e.type==="select-multiple",lt=e=>ze(e)||me(e),Pe=e=>ke(e)&&e.isConnected;function _r(e){return Array.isArray(e)||N(e)}function Rr(e,s,r="",i=[]){for(const l in e){const u=r?`${r}.${l}`:l,o=e[l];_r(o)&&_r(v(s,u))?Rr(o,s,u,i):i.push(u)}return i}var ut=e=>{for(const s in e)if(G(e[s]))return!0;return!1};function Cr(e){return Array.isArray(e)||N(e)&&!ut(e)}function Lr(e){return!!(e&&"_f"in e)}function Ir(e){return Array.isArray(e)?!e.some(s=>!O(s)):!Object.keys(e).length}function Be(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function $e(e,s={},r){for(const i in e){const l=e[i],u=r&&r[i];Cr(l)&&(!Array.isArray(l)||!Lr(u))?(s[i]=Array.isArray(l)?[]:{},$e(l,s[i],u),Ir(s[i])&&Be(s,i)):O(l)||(s[i]=!0)}return s}function ie(e,s,r,i){r||(r=$e(s,{},i));for(const l in e){const u=e[l],o=i&&i[l];Cr(u)&&(!Array.isArray(u)||!Lr(o))?(O(s)||Me(r[l])?r[l]=$e(u,Array.isArray(u)?[]:{},o):ie(u,p(s)?{}:s[l],r[l],o),Ir(r[l])&&Be(r,l)):Q(u,s[l])?Be(r,l):r[l]=!0}return r}var ft=(e,s)=>{const r=s.split("."),i=[];let l=r[0];for(let u=1;u<r.length;l+="."+r[u++])!isNaN(+r[u])&&e.has(l)&&i.push(`${l}.${r[u]}`);return i},Nr=(e,{valueAsNumber:s,valueAsDate:r,setValueAs:i})=>O(e)?e:s?e===""?NaN:e&&+e:r&&M(e)?new Date(e):i?i(e):e;function Vr(e){const s=e.ref;return Se(s)?s.files:ze(s)?kr(e.refs).value:Tr(s)?[...s.selectedOptions].map(({value:r})=>r):me(s)?xr(e.refs).value:Nr(s.value,e)}var ct=(e,s,r,i)=>{const l={};for(const u of e){const o=v(s,u);o&&k(l,u,o._f)}return{criteriaMode:r,names:[...e],fields:l,shouldUseNativeValidation:i}},_e=e=>O(e)?e:Oe(e)?e.source:N(e)?Oe(e.value)?e.value.source:e.value:e;const mr="AsyncFunction";var dt=e=>{if(!e||!e.validate)return!1;if(G(e.validate))return e.validate.constructor.name===mr;if(N(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===mr)return!0}return!1},yt=e=>e.mount&&(e.required||!O(e.required)&&e.required!==!1||!O(e.min)||!O(e.max)||!O(e.maxLength)||!O(e.minLength)||e.pattern||e.validate);function br(e,s,r){const i=v(e,r);if(i||ne(r))return{error:i,name:r};const l=r.split(".");for(;l.length;){const u=l.join("."),o=v(s,u),c=v(e,u);if(o&&!Array.isArray(o)&&r!==u)return{name:r};if(c&&c.type)return{name:u,error:c};if(c&&c.root&&c.root.type)return{name:`${u}.root`,error:c.root};l.pop()}return{name:r}}var ht=(e,s,r,i)=>{r(e);const l=Object.keys(e).filter(u=>u!=="name");return!l.length||i&&l.length>=Object.keys(s).length||l.find(u=>s[u]===(!i||X.all))},gt=(e,s,r)=>!e||!s||e===s||xe(e).some(i=>i&&(r?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),vt=(e,s,r,i,l)=>l.isOnAll?!1:!r&&l.isOnTouch?!(s||e):(r?i.isOnBlur:l.isOnBlur)?!e:(r?i.isOnChange:l.isOnChange)?e:!0,_t=(e,s)=>{const r=v(e,s);!Or(r).length&&!r?.root&&U(e,s)};const Vt={mode:X.onSubmit,reValidateMode:X.onChange,shouldFocusError:!0},pe="form",mt=(e,s)=>{for(const r in e)r in s||delete e[r];Object.assign(e,s)},Ur={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function bt(e={}){let s={...Vt,...e},r={...C(Ur),isLoading:G(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},l=N(s.defaultValues)||N(s.values)?C(s.defaultValues||s.values)||{}:{},u=s.shouldUnregister?{}:C(l),o={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const m={},E={};let T=0,H=De(s.mode),j=De(s.reValidateMode);const $={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...$};let F={...A};const b={array:gr(),state:gr()};let fe=0;const w=s.criteriaMode===X.all,ee=(t,a)=>n=>{clearTimeout(E[t]),E[t]=setTimeout(a,n)},P=async t=>{if(!o.keepIsValid&&!s.disabled&&(A.isValid||F.isValid||t)){const a=++fe;let n;s.resolver?(n=B((await R()).errors),a===fe&&S()):n=await q({fields:i,onlyCheckValid:!0,eventType:oe.VALID}),a===fe&&n!==r.isValid&&b.state.next({isValid:n})}},S=(t,a)=>{!s.disabled&&(A.isValidating||A.validatingFields||F.isValidating||F.validatingFields)&&((t||c.mount).forEach(n=>{n&&(a?k(r.validatingFields,n,a):U(r.validatingFields,n))}),b.state.next({validatingFields:r.validatingFields,isValidating:!B(r.validatingFields)}))},ce=()=>{r.dirtyFields=ie(l,u,void 0,i)},be=(t,a=[],n,f,d=!0,y=!0)=>{if(f&&n&&!s.disabled){o.action=!0;const h=v(i,t);if(o.actionArrayLengths.has(t)||o.actionArrayLengths.set(t,Array.isArray(h)?h.length:0),y&&Array.isArray(h)){const V=n(h,f.argA,f.argB);d&&k(i,t,V)}const g=v(r.errors,t);if(y&&Array.isArray(g)){const V=g.root,L=n(g,f.argA,f.argB)||g;V&&(L.root=V),d&&k(r.errors,t,L),_t(r.errors,t)}const _=v(r.touchedFields,t);if((A.touchedFields||F.touchedFields)&&y&&Array.isArray(_)){const V=n(_,f.argA,f.argB);d&&k(r.touchedFields,t,V)}(A.dirtyFields||F.dirtyFields)&&ce(),b.state.next({name:t,isDirty:Y(t,a),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else k(u,t,a)},Ae=(t,a)=>{k(r.errors,t,a),r.errors={...r.errors},b.state.next({errors:r.errors})},ae=t=>{r.errors=t,b.state.next({errors:r.errors,isValid:!1})},se=t=>{const a=ne(t)?[t]:ue(t);let n=u,f=l;for(let d=0;d<a.length-1;d++){const y=a[d];if(n=p(n)?n:n[y],f=p(f)?f:f[y],n===null&&f!==null)return!0}return!1},Fe=t=>{if(!o.actionArrayLengths.size)return!1;const a=ne(t)?[t]:ue(t);let n=u,f="",d=-1,y=0;for(let h=0;h<a.length;h++){if(p(n))return!1;const g=a[h];if(f=f?`${f}.${g}`:g,Array.isArray(n)&&+g>=n.length)return d===-1?!1:h===d?+g<y:!0;o.actionArrayLengths.has(f)&&(d=h+1,y=o.actionArrayLengths.get(f)),n=n[g]}return!1},de=(t,a,n,f)=>{const d=v(i,t);if(d){if(se(t)||Fe(t))return;const y=O(v(u,t)),h=v(u,t,O(n)?v(l,t):n);O(h)||f&&f.defaultChecked||a?k(u,t,a?h:Vr(d._f)):Re(t,h),o.mount&&!o.action&&(P(),y&&r.isDirty&&(A.isDirty||F.isDirty)&&(Y()||(r.isDirty=!1,b.state.next({...r}))),e.shouldUnregister&&y&&!O(v(u,t))&&Ue(t,c)&&(o.watch=!0))}},D=(t,a,n,f,d)=>{let y=!1,h=!1;const g={name:t};if(!s.disabled||f===!0){if(!n||f){const _=Q(v(l,t),a);(A.isDirty||F.isDirty)&&(h=r.isDirty,r.isDirty=g.isDirty=!_||Y(),y=h!==g.isDirty),h=!!v(r.dirtyFields,t),_!==r.isDirty?mt(r.dirtyFields,ie(l,u,void 0,i)):_?U(r.dirtyFields,t):k(r.dirtyFields,t,!0),g.dirtyFields=r.dirtyFields,y=y||(A.dirtyFields||F.dirtyFields)&&h!==!_}if(n){const _=v(r.touchedFields,t);_||(k(r.touchedFields,t,n),g.touchedFields=r.touchedFields,y=y||(A.touchedFields||F.touchedFields)&&_!==n)}y&&d&&b.state.next(g)}return y?g:{}},x=(t,a,n,f)=>{const d=v(r.errors,t),y=(A.isValid||F.isValid)&&re(a)&&r.isValid!==a;if(s.delayError&&n?(m[t]=ee(t,()=>Ae(t,n)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t],n?k(r.errors,t,n):U(r.errors,t),r.errors={...r.errors}),(n?!Q(d,n):d)||!B(f)||y){const h={...f,...y&&re(a)?{isValid:a}:{},errors:r.errors,name:t};b.state.next(h)}},R=async t=>(S(t,!0),await s.resolver(u,s.context,ct(t||c.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),W=async t=>{const{errors:a}=await R(t);if(S(t),t){for(const n of t){const f=v(a,n);f?c.array.has(n)&&N(f)&&!Object.keys(f).some(d=>!Number.isNaN(Number(d)))?ur(r.errors,{[n]:f},n):k(r.errors,n,f):U(r.errors,n)}r.errors={...r.errors}}else r.errors=a;return a},K=async({name:t,eventType:a})=>{if(e.validate){const n=await e.validate({formValues:u,formState:r,name:t,eventType:a});if(N(n))for(const f in n){const d=n[f];d&&Ee(`${pe}.${f}`,{message:M(d.message)?d.message:"",type:d.type||J.validate})}else M(n)||!n?Ee(pe,{message:n||"",type:J.validate}):Xe(pe);return n}return!0},q=async({fields:t,onlyCheckValid:a,name:n,eventType:f,context:d={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(d.runRootValidation=!0,!await K({name:n,eventType:f})&&(d.valid=!1,a)))return d.valid;for(const y in t){const h=t[y];if(h){const{_f:g,..._}=h;if(g){const V=c.array.has(g.name),L=h._f&&dt(h._f),z=A.validatingFields||A.isValidating||F.validatingFields||F.isValidating;L&&z&&S([g.name],!0);const Z=await hr(h,c.disabled,u,w,s.shouldUseNativeValidation&&!a,V);if(L&&z&&S([g.name]),Z[g.name]&&(d.valid=!1,a)||(!a&&(v(Z,g.name)?V?ur(r.errors,Z,g.name):k(r.errors,g.name,Z[g.name]):U(r.errors,g.name)),e.shouldUseNativeValidation&&Z[g.name]))break}!B(_)&&await q({context:d,onlyCheckValid:a,fields:_,name:y,eventType:f})}}return d.valid},we=()=>{for(const t of c.unMount){const a=v(i,t);a&&(a._f.refs?a._f.refs.every(n=>!Pe(n)):!Pe(a._f.ref))&&Le(t)}c.unMount=new Set},Y=(t,a)=>(t&&a&&k(u,t,a),!Q(o.mount?u:l,l)),ye=(t,a,n)=>st(t,c,{...o.mount?u:O(a)||M(t)?l:a},n,a),Pr=t=>Or(v(o.mount?u:l,t,s.shouldUnregister?v(l,t,[]):[])),Re=(t,a,n={},f=!1,d=!1,y=!1)=>{const h=v(i,t);let g=a;if(h){const _=h._f;_&&(!_.disabled&&k(u,t,Nr(a,_)),g=ke(_.ref)&&p(a)?"":a,Tr(_.ref)?[..._.ref.options].forEach(V=>V.selected=g.includes(V.value)):_.refs?me(_.ref)?_.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(g)?V.checked=!!g.find(L=>L===V.value):V.checked=g===V.value||!!g)}):_.refs.forEach(V=>V.checked=V.value===g):Se(_.ref)?_.ref.value="":(_.ref.value=g,!_.ref.type&&!d&&!y&&b.state.next({name:t,values:f?u:C(u)})))}(n.shouldDirty||n.shouldTouch)&&D(t,g,n.shouldTouch,n.shouldDirty,!d),n.shouldValidate&&Ce(t,{delayError:n.delayError})},Ge=(t,a,n,f=!1,d=!1,y=!1)=>{c.array.has(t)&&b.array.next({name:t,values:f?u:C(u)});for(const h in a){if(!a.hasOwnProperty(h))continue;const g=a[h],_=t+"."+h,V=v(i,_);(c.array.has(t)||N(g)||V&&!V._f)&&!te(g)?Ge(_,g,n,f,d,y):Re(_,g,n,f,d,y)}},Ke=(t,a,n,f,d=!1)=>{const y=v(i,t),h=c.array.has(t),g=f?a:C(a),_=v(u,t),V=Q(_,g);if(V||k(u,t,g),h)b.array.next({name:t,values:f?u:C(u)}),(A.isDirty||A.dirtyFields||F.isDirty||F.dirtyFields)&&n.shouldDirty&&(ce(),d||b.state.next({name:t,dirtyFields:r.dirtyFields,isDirty:Y(t,g)}));else{const L=Array.isArray(g)&&!g.length||B(g),z=!V&&!d;!y||y._f||p(g)||L?Re(t,g,n,f,d,z):Ge(t,g,n,f,d,z)}if(!V&&!d){const L=Ue(t,c),z=f?u:C(u);if(b.state.next({...L&&r,name:o.mount||L?t:void 0,values:z}),!h)for(const Z of ft(c.array,t))b.state.next({name:Z,values:z})}},he=(t,a,n={})=>Ke(t,a,n,!1),pr=(t,a={})=>{const n=G(t)?t(u):t;if(!Q(u,n)){u={...u,...n};for(const f of c.mount)ot(n,f)&&Ke(f,v(n,f),a,!0,!0);b.state.next({...r,name:void 0,type:void 0,...T?{values:u}:{}}),a.shouldValidate&&P()}},Ze=async t=>{o.mount=!0;const a=t.target;let n=a.name,f=!0;const d=v(i,n),y=h=>{f=Number.isNaN(h)||te(h)&&isNaN(h.getTime())||Q(h,v(u,n,h))};if(d){let h,g;const _=a.type?Vr(d._f):Gr(t),V=t.type===oe.BLUR||t.type===oe.FOCUS_OUT,L=!yt(d._f)&&!e.validate&&!s.resolver&&!v(r.errors,n)&&!d._f.deps,z=L||vt(V,v(r.touchedFields,n),r.isSubmitted,j,H),Z=Ue(n,c,V);if(k(u,n,C(_)),V){if(!a||!a.readOnly){d._f.onBlur&&d._f.onBlur(t);const ve=m[n];ve&&ve(0)}}else d._f.onChange&&d._f.onChange(t);const ge=D(n,_,V),zr=!B(ge)||Z;if(!V&&b.state.next({name:n,type:t.type,...T?{values:C(u)}:{}}),z)return(!L||!r.isValid)&&(A.isValid||F.isValid)&&(s.mode==="onBlur"?V&&P():V||P()),zr&&b.state.next({name:n,...Z?{}:ge});if(!s.resolver&&e.validate&&await K({name:n,eventType:t.type}),!V&&Z&&b.state.next({...r}),s.resolver){const{errors:ve}=await R([n]);if(S([n]),y(_),!f){!B(ge)&&b.state.next(ge);return}const Yr=br(r.errors,i,n),or=br(ve,i,Yr.name||n);h=or.error,n=or.name,g=B(ve)}else S([n],!0),h=(await hr(d,c.disabled,u,w,s.shouldUseNativeValidation))[n],S([n]),y(_),f&&(h?g=!1:(A.isValid||F.isValid)&&(g=await q({fields:i,onlyCheckValid:!0,name:n,eventType:t.type})));f&&(d._f.deps&&(!Array.isArray(d._f.deps)||d._f.deps.length>0)&&Ce(d._f.deps),x(n,g,h,ge))}},Je=(t,a)=>{if(v(r.errors,a)&&t.focus)return t.focus(),1},Ce=async(t,a={})=>{let n,f;const d=xe(t);if(s.resolver){const y=await W(O(t)?t:d);n=B(y),f=t?!d.some(h=>v(y,h)):n}else t?(f=(await Promise.all(d.map(async y=>{const h=v(i,y);return await q({fields:h&&h._f?{[y]:h}:h,eventType:oe.TRIGGER})}))).every(Boolean),!(!f&&!r.isValid)&&P()):f=n=await q({fields:i,name:t,eventType:oe.TRIGGER});if(a.delayError&&s.delayError&&M(t)){const y=v(r.errors,t);y?(U(r.errors,t),m[t]=ee(t,()=>Ae(t,y)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t])}if(a.shouldTouch)for(const y of t?d:c.mount)!c.array.has(y)&&k(r.touchedFields,y,!0);return b.state.next({...!M(t)||(A.isValid||F.isValid)&&n!==r.isValid?{}:{name:t},...s.resolver||!t?{isValid:n}:{},...a.shouldTouch&&(A.touchedFields||F.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),a.shouldFocus&&!f&&Ve(i,Je,t?d:c.mount),f},Mr=(t,a)=>{let n={...o.mount?u:l};return a&&(n=Sr(a.dirtyFields?r.dirtyFields:r.touchedFields,n)),O(t)?n:M(t)?v(n,t):t.map(f=>v(n,f))},Br=t=>O(t)?{...r.errors}:M(t)?v(r.errors,t):t.map(a=>v(r.errors,a)),Qe=(t,a)=>{const n=a||r,f=v(n.errors,t);return{invalid:!!f,isDirty:!!v(n.dirtyFields,t),error:f,isValidating:!!v(r.validatingFields,t),isTouched:!!v(n.touchedFields,t)}},Xe=t=>{const a=t?xe(t):void 0;a?.forEach(n=>U(r.errors,n)),a?a.forEach(n=>{b.state.next({name:n,errors:r.errors})}):(r.errors={},b.state.next({errors:r.errors}))},Ee=(t,a,n)=>{const f=(v(i,t,{_f:{}})._f||{}).ref,d=v(r.errors,t)||{},{ref:y,message:h,type:g,..._}=d;k(r.errors,t,{..._,...a,ref:f}),b.state.next({name:t,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&f&&f.focus&&f.focus()},$r=(t,a)=>{if(G(t)){T++;const{unsubscribe:n}=b.state.subscribe({next:d=>"values"in d&&t(d.values||ye(void 0,a),d)});let f=!1;return{unsubscribe:()=>{f||(f=!0,T--,n())}}}return ye(t,a,!0)},er=t=>{var a;const n=!!(!((a=t.formState)===null||a===void 0)&&a.values);n&&T++;const{unsubscribe:f}=b.state.subscribe({next:y=>{if(gt(t.name,y.name,t.exact)&&ht(y,t.formState||A,nr,t.reRenderRoot)){const h={...u};t.callback({values:h,...r,...y,defaultValues:l})}}});if(!n)return f;let d=!1;return()=>{d||(d=!0,T--,f())}},Wr=t=>(o.mount=!0,F={...F,...t.formState},er({...t,formState:{...$,...t.formState}})),Le=(t,a={})=>{for(const n of t?xe(t):c.mount)c.mount.delete(n),c.array.delete(n),a.keepValue||(U(i,n),U(u,n)),!a.keepError&&U(r.errors,n),!a.keepDirty&&U(r.dirtyFields,n),!a.keepTouched&&U(r.touchedFields,n),!a.keepIsValidating&&U(r.validatingFields,n),!s.shouldUnregister&&!a.keepDefaultValue&&U(l,n);T&&b.state.next({values:C(u)}),b.state.next({...r,...a.keepDirty?{}:{isDirty:Y()}}),!a.keepIsValid&&P()},rr=({disabled:t,name:a})=>{if(re(t)&&o.mount||t||c.disabled.has(a)){const d=c.disabled.has(a)!==!!t;t?c.disabled.add(a):c.disabled.delete(a),d&&o.mount&&!o.action&&P()}},Ie=(t,a={})=>{let n=v(i,t);const f=re(a.disabled)||re(s.disabled),d=!c.registerName.has(t)&&n&&n._f&&!n._f.mount;return k(i,t,{...n||{},_f:{...n&&n._f?n._f:{ref:{name:t}},name:t,mount:!0,...a}}),c.mount.add(t),n&&!d?rr({disabled:re(a.disabled)?a.disabled:s.disabled,name:t}):de(t,!0,a.value),{...f?{disabled:a.disabled||s.disabled}:{},...s.progressive?{required:!!a.required,min:_e(a.min),max:_e(a.max),minLength:_e(a.minLength),maxLength:_e(a.maxLength),pattern:_e(a.pattern)}:{},name:t,onChange:Ze,onBlur:Ze,ref:y=>{if(y){c.registerName.add(t),Ie(t,a),c.registerName.delete(t),n=v(i,t);const h=O(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,g=lt(h),_=n._f.refs||[];if(g?_.find(L=>L===h):h===n._f.ref)return;const V={...n._f};g?(V.refs=[..._.filter(Pe),h,...Array.isArray(v(l,t))?[{}]:[]],V.ref={type:h.type,name:t}):(V.ref=h,delete V.refs),k(i,t,{_f:V}),de(t,!1,void 0,h)}else n=v(i,t,{}),n._f&&(n._f.mount=!1),(s.shouldUnregister||a.shouldUnregister)&&!(Zr(c.array,t)&&o.action)&&c.unMount.add(t)}}},Ne=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ve(i,Je,c.mount),qr=t=>{re(t)&&(b.state.next({disabled:t}),Ve(i,(a,n)=>{const f=v(i,n);f&&(a.disabled=f._f.disabled||t,Array.isArray(f._f.refs)&&f._f.refs.forEach(d=>{d.disabled=f._f.disabled||t}))},0,!1))},tr=(t,a)=>async n=>{let f,d;n&&(n.preventDefault&&n.preventDefault(),n.persist&&n.persist());let y=C(u);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:h,values:g}=await R();S(),r.errors=h,y=C(g)}else await q({fields:i,eventType:oe.SUBMIT});if(c.disabled.size)for(const h of c.disabled)U(y,h);if(U(r.errors,Dr),B(r.errors)){b.state.next({errors:{}});try{f=await t(y,n)}catch(h){d=h}}else a&&await a({...r.errors},n),Ne(),setTimeout(Ne);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(r.errors)&&!d,submitCount:r.submitCount+1,errors:r.errors}),d)throw d;return f},Hr=(t,a={})=>{v(i,t)&&(O(a.defaultValue)?he(t,C(v(l,t))):(he(t,a.defaultValue),k(l,t,C(a.defaultValue))),a.keepTouched||U(r.touchedFields,t),a.keepDirty||(U(r.dirtyFields,t),r.isDirty=a.defaultValue?Y(t,C(v(l,t))):Y()),a.keepError||(U(r.errors,t),P()),b.state.next({...r}))},sr=(t,a={})=>{const n=t?C(t):l,f=C(n),d=B(t),y=f,h=i;if(a.keepDefaultValues||(l=n),!a.keepValues){if(a.keepDirtyValues){const g=new Set([...c.mount,...Rr(ie(l,u,void 0,h),r.dirtyFields)]);for(const _ of g){const V=v(r.dirtyFields,_),L=v(u,_),z=v(y,_);V&&!O(L)?k(y,_,L):!V&&!O(z)&&he(_,z)}}else{if(Te&&O(t))for(const g of c.mount){const _=v(i,g);if(_&&_._f){const V=Array.isArray(_._f.refs)?_._f.refs[0]:_._f.ref;if(ke(V)){const L=V.closest("form");if(L){L.reset();break}}}}if(a.keepFieldsRef)for(const g of c.mount)he(g,v(y,g));else i={}}if(s.shouldUnregister){if(u=a.keepDefaultValues?C(l):{},a.keepFieldsRef)for(const g of c.mount)k(u,g,v(y,g))}else u=C(y);b.array.next({values:{...y}}),b.state.next({name:void 0,type:void 0,values:{...y}})}c={mount:a.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!A.isValid||!!a.keepIsValid||!!a.keepDirtyValues||!s.shouldUnregister&&!B(y),o.watch=!!s.shouldUnregister,o.keepIsValid=!!a.keepIsValid,o.action=!1,o.actionArrayLengths.clear(),a.keepErrors||(r.errors={}),b.state.next({submitCount:a.keepSubmitCount?r.submitCount:0,isDirty:d?!1:a.keepDirty?r.isDirty:a.keepValues?Y():!!(a.keepDefaultValues&&!Q(t,l)),isSubmitted:a.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:d?{}:a.keepDirtyValues?a.keepDefaultValues&&u?ie(l,u,void 0,h):r.dirtyFields:a.keepDefaultValues&&t?ie(l,t,void 0,h):a.keepDirty?r.dirtyFields:{},touchedFields:a.keepTouched?r.touchedFields:{},errors:a.keepErrors?r.errors:{},isSubmitSuccessful:a.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:l})},ir=(t,a)=>sr(G(t)?t(u):t,{...s.resetOptions,...a}),jr=(t,a={})=>{const n=v(i,t),f=n&&n._f;if(f){const d=f.refs?f.refs[0]:f.ref;d.focus&&setTimeout(()=>{d.focus(),a.shouldSelect&&G(d.select)&&d.select()})}},nr=t=>{const{name:a,type:n,values:f,...d}=t;r={...r,...d}};b.state.subscribe({next:nr});const ar={control:{register:Ie,unregister:Le,getFieldState:Qe,handleSubmit:tr,setError:Ee,_subscribe:er,_runSchema:R,_updateIsValidating:S,_focusError:Ne,_getWatch:ye,_getDirty:Y,_setValid:P,_setFieldArray:be,_setDisabledField:rr,_setErrors:ae,_getFieldArray:Pr,_reset:sr,_resetDefaultValues:()=>G(s.defaultValues)&&s.defaultValues().then(t=>{ir(t,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:we,_disableForm:qr,_subjects:b,_proxyFormState:A,get _fields(){return i},get _formValues(){return u},get _state(){return o},set _state(t){o=t},get _defaultValues(){return l},get _names(){return c},set _names(t){c=t},get _formState(){return r},get _options(){return s},set _options(t){s={...s,...t},H=De(s.mode),j=De(s.reValidateMode)}},subscribe:Wr,trigger:Ce,register:Ie,handleSubmit:tr,watch:$r,setValue:he,setValues:pr,getValues:Mr,getErrors:Br,reset:ir,resetField:Hr,resetDefaultValues:(t,a={})=>{if(l=C(t),!a.keepDirty){const n=ie(l,u,void 0,i);r.dirtyFields=n,r.isDirty=!B(n)}a.keepIsValid||P(),b.state.next({...r,defaultValues:l})},clearErrors:Xe,unregister:Le,setError:Ee,setFocus:jr,getFieldState:Qe};return{...ar,formControl:ar}}function kt(e={}){const s=I.useRef(void 0),r=I.useRef(void 0),i=I.useRef(e.formControl),[l,u]=I.useState(()=>({...C(Ur),isLoading:G(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:G(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:l},e.defaultValues&&!G(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:E,...T}=bt(e);s.current={...T,formState:l}}const o=s.current.control;o._options=e;const{resyncIfNeeded:c,snapshot:m}=tt();return et(()=>{const E=()=>({...o._formState,defaultValues:o._defaultValues});c(!0,E,u);const T=o._subscribe({formState:o._proxyFormState,callback:()=>u({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return u(H=>({...H,isReady:!0})),o._formState.isReady=!0,()=>{T(),m(!0,E)}},[o,c,m]),I.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),I.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),I.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),I.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),I.useEffect(()=>{if(o._proxyFormState.isDirty){const E=o._getDirty();E!==l.isDirty&&o._subjects.state.next({isDirty:E})}},[o,l.isDirty]),I.useEffect(()=>{var E;e.values&&!Q(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((E=o._options.resetOptions)===null||E===void 0)&&E.keepIsValid||o._setValid(),r.current=e.values,u(T=>({...T}))):o._resetDefaultValues()},[o,e.values]),I.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=I.useMemo(()=>Xr(l,o),[o,l]),s.current}const Ar=(e,s,r)=>{if(e&&"reportValidity"in e){const i=v(r,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},We=(e,s)=>{for(const r in s.fields){const i=s.fields[r];i&&i.ref&&"reportValidity"in i.ref?Ar(i.ref,r,e):i&&i.refs&&i.refs.forEach(l=>Ar(l,r,e))}},Fr=(e,s)=>{s.shouldUseNativeValidation&&We(e,s);const r={};for(const i in e){const l=v(s.fields,i),u=Object.assign(e[i]||{},{ref:l&&l.refs?l.refs[0]:l&&l.ref});if(At(s.names||Object.keys(e),i)){const o=Object.assign({},v(r,i));k(o,"root",u),k(r,i,o)}else k(r,i,u)}return r},At=(e,s)=>{const r=wr(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>wr(i).match(`^${r}\\.\\d+`))};function wr(e){return e.replace(/\[(\d+)]/g,".$1").replace(/[[\]]/g,"")}function qe(){return qe=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},qe.apply(null,arguments)}function Er(e,s){try{var r=e()}catch(i){return s(i)}return r&&r.then?r.then(void 0,s):r}function Ft(e,s){for(var r=Object.create(null);e.length;){var i=e[0],l=i.code,u=i.message,o=i.path.join(".");if(!r[o])if("unionErrors"in i){var c,m,E=i.unionErrors.reduce(function(j,$){return $.errors.length<j.errors.length?$:j}).errors[0];r[o]={message:(c=E?.message)!=null?c:u,type:(m=E?.code)!=null?m:l}}else r[o]={message:u,type:l};if("unionErrors"in i&&i.unionErrors.forEach(function(j){return j.errors.forEach(function($){return e.push($)})}),s){var T=r[o].types,H=T&&T[i.code];r[o]=Ye(o,s,r,l,H?[].concat(H,i.message):i.message)}e.shift()}return r}function wt(e,s){for(var r=Object.create(null),i=function(){var l=e[0],u=l.code,o=l.message,c=l.path.join(".");if(!r[c])if(l.code==="invalid_union"&&l.errors.length>0){var m,E,T=l.errors.reduce(function($,A){return A.length<$.length?A:$})[0];r[c]={message:(m=T?.message)!=null?m:o,type:(E=T?.code)!=null?E:u}}else r[c]={message:o,type:u};if(l.code==="invalid_union"&&l.errors.forEach(function($){return $.forEach(function(A){return e.push(qe({},A,{path:[].concat(l.path,A.path)}))})}),s){var H=r[c].types,j=H&&H[l.code];r[c]=Ye(c,s,r,u,j?[].concat(j,l.message):l.message)}e.shift()};e.length;)i();return r}function Ot(e,s,r){if(r===void 0&&(r={}),(function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){function o(m){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):m}}var c=e;return r.mode==="sync"?o(c.parse(i,s)):Promise.resolve(c.parseAsync(i,s)).then(o)},function(o){if((function(c){var m;return!(c==null||(m=c._zod)==null||(m=m.traits)==null||!m.has("$ZodError"))})(o))return{values:{},errors:Fr(wt(o.issues,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_def"in i&&typeof i._def=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(o){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):o}})},function(o){if((function(c){return Array.isArray(c?.issues)})(o))return{values:{},errors:Fr(Ft(o.errors,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}export{Ot as a,kt as u};
1
+ import{au as I}from"./index-C6gyyLd5.js";var me=e=>e.type==="checkbox",Se=e=>e.type==="file",te=e=>e instanceof Date,p=e=>e==null;const He=e=>typeof e=="object";var N=e=>!p(e)&&!Array.isArray(e)&&He(e)&&!te(e),Gr=e=>N(e)&&e.target?me(e.target)?e.target.checked:Se(e.target)?e.target.files:e.target.value:e;const Kr=/[.[\]'"]/;var ue=e=>e.split(Kr).filter(Boolean),Zr=(e,s)=>s.split(".").some((r,i,l)=>!isNaN(Number(r))&&e.has(l.slice(0,i).join("."))),Te=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function C(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Te&&(e instanceof Blob||s))return e;const r=Array.isArray(e);if(!r&&e.constructor!==Object)return e;const i=r?[]:Object.create(Object.getPrototypeOf(e));for(const l in e)Object.prototype.hasOwnProperty.call(e,l)&&(i[l]=C(e[l]));return i}const oe={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},X={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},J={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dr="root",je=["__proto__","constructor","prototype"],Jr=/^\w*$/;var ne=e=>Jr.test(e),O=e=>e===void 0,v=(e,s,r)=>{if(!s||!N(e))return r;const i=ne(s)?[s]:ue(s);if(i.some(u=>je.includes(u)))return r;const l=i.reduce((u,o)=>p(u)?void 0:u[o],e);return O(l)||l===e?O(e[s])?r:e[s]:l},re=e=>typeof e=="boolean",G=e=>typeof e=="function",k=(e,s,r)=>{let i=-1;const l=ne(s)?[s]:ue(s),u=l.length,o=u-1;for(;++i<u;){const c=l[i];let m=r;if(i!==o){const E=e[c];m=N(E)||Array.isArray(E)?E:isNaN(+l[i+1])?{}:[]}if(je.includes(c))return;e[c]=m,e=e[c]}};const Qr=I.createContext(null);Qr.displayName="HookFormControlContext";var Xr=(e,s,r,i=!0)=>{const l={};for(const u in e)Object.defineProperty(l,u,{get:()=>{const o=u;return s._proxyFormState[o]!==X.all&&(s._proxyFormState[o]=!i||X.all),e[o]}});return l};const et=Te?I.useLayoutEffect:I.useEffect;var rt=e=>{const s=e.constructor&&e.constructor.prototype;return N(s)&&s.hasOwnProperty("isPrototypeOf")},Me=e=>p(e)||!He(e);const lr=(e,s)=>s.length===0&&!Array.isArray(e)&&!rt(e);function Q(e,s,r=new WeakMap){if(e===s)return!0;if(Me(e)||Me(s))return Object.is(e,s);if(te(e)&&te(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),l=Object.keys(s);if(i.length!==l.length)return!1;if(lr(e,i)||lr(s,l))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const u=r.get(e);if(u&&u.has(s))return!0;if(u)u.add(s);else{const o=new WeakSet;o.add(s),r.set(e,o)}for(const o of i){const c=e[o];if(!(o in s))return!1;if(o!=="ref"){const m=s[o];if(te(c)&&te(m)||(N(c)||Array.isArray(c))&&(N(m)||Array.isArray(m))?!Q(c,m,r):!Object.is(c,m))return!1}}return!0}function tt(e){const s=I.useRef(!1),r=I.useRef(!1),i=I.useRef(void 0),l=I.useRef(0);l.current++,r.current;const u=I.useCallback((c,m,E)=>{if(c&&(s.current||r.current&&l.current>1)){const T=m();Q(i.current,T)||E(T)}s.current=!0},[]),o=I.useCallback((c,m)=>{c&&(i.current=C(m()))},[]);return{resyncIfNeeded:u,snapshot:o}}var M=e=>typeof e=="string",st=(e,s,r,i,l)=>M(e)?(i&&s.watch.add(e),v(r,e,l)):Array.isArray(e)?e.map(u=>(i&&s.watch.add(u),v(r,u,v(l,u)))):(i&&(s.watchAll=!0),r),De=e=>({isOnSubmit:!e||e===X.onSubmit,isOnBlur:e===X.onBlur,isOnChange:e===X.onChange,isOnAll:e===X.all,isOnTouch:e===X.onTouched}),Ue=(e,s,r)=>{if(r)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Ve=(e,s,r,i)=>{for(const l of r||Object.keys(e)){if(l==="_f")continue;const u=r?v(e,l):e[l];if(u){const{_f:o}=u;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],l)&&!i)return!0;if(o.ref&&s(o.ref,o.name)&&!i)return!0;if(Ve(u,s))break}else if((N(u)||Array.isArray(u))&&Ve(u,s))break}}};var ur=(e,s,r)=>{const i=v(e,r),l=Array.isArray(i)?i:[];return k(l,Dr,s[r]),k(e,r,l),e},B=e=>N(e)&&!Object.keys(e).length,ke=e=>{if(!Te)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},ze=e=>e.type==="radio",Oe=e=>e instanceof RegExp,Ye=(e,s,r,i,l)=>s?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[i]:l||!0}}:{};const fr={value:!1,isValid:!1},cr={value:!0,isValid:!0};var xr=e=>{if(!Array.isArray(e))return fr;if(e.length>1){const r=e.filter(i=>i&&i.checked&&!i.disabled).map(i=>i.value);return{value:r,isValid:!!r.length}}const s=e[0];return!s||!s.checked||s.disabled?fr:!s.attributes||!("value"in s.attributes)||O(s.value)||s.value===""?cr:{value:s.value,isValid:!0}};const dr={isValid:!1,value:null};var kr=e=>Array.isArray(e)?e.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,dr):dr;function yr(e,s,r="validate"){if(M(e)||Array.isArray(e)&&e.every(M)||re(e)&&!e)return{type:r,message:M(e)?e:"",ref:s}}var le=e=>N(e)&&!Oe(e)?e:{value:e,message:""},hr=async(e,s,r,i,l,u)=>{const{ref:o,refs:c,required:m,maxLength:E,minLength:T,min:H,max:j,pattern:$,validate:A,name:F,valueAsNumber:b,mount:fe}=e._f,w=v(r,F);if(!fe||s.has(F))return{};const ee=c?c[0]:o,P=D=>{if(l&&ee.reportValidity){const x=re(D)?"":D||"";c?c.forEach(R=>R.setCustomValidity(x)):ee.setCustomValidity(x),ee.reportValidity()}},S={},ce=ze(o),be=me(o),Ae=ce||be,ae=(b||Se(o))&&O(o.value)&&O(w)||ke(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,se=Ye.bind(null,F,i,S),Fe=(D,x,R,W=J.maxLength,K=J.minLength)=>{const q=D?x:R;S[F]={type:D?W:K,message:q,ref:o,...se(D?W:K,q)}};if(u?!Array.isArray(w)||!w.length:m&&(!Ae&&(ae||p(w))||re(w)&&!w||be&&!xr(c).isValid||ce&&!kr(c).isValid)){const{value:D,message:x}=M(m)?{value:!!m,message:m}:le(m);if(D&&(S[F]={type:J.required,message:x,ref:ee,...se(J.required,x)},!i))return P(x),S}if(!ae&&(!p(H)||!p(j))){let D,x;const R=le(j),W=le(H);if(!p(w)&&!te(w)&&!isNaN(w)){const K=o.valueAsNumber||w&&+w;p(R.value)||(D=K>R.value),p(W.value)||(x=K<W.value)}else{const K=o.valueAsDate||new Date(w),q=ye=>new Date(new Date().toDateString()+" "+ye),we=o.type=="time",Y=o.type=="week";M(R.value)&&w&&(D=we?q(w)>q(R.value):Y?w>R.value:K>new Date(R.value)),M(W.value)&&w&&(x=we?q(w)<q(W.value):Y?w<W.value:K<new Date(W.value))}if((D||x)&&(Fe(!!D,R.message,W.message,J.max,J.min),!i))return P(S[F].message),S}if((E||T)&&!ae&&(M(w)||u&&Array.isArray(w))){const D=le(E),x=le(T),R=!p(D.value)&&w.length>+D.value,W=!p(x.value)&&w.length<+x.value;if((R||W)&&(Fe(R,D.message,x.message),!i))return P(S[F].message),S}if($&&!ae&&M(w)){const{value:D,message:x}=le($);if(Oe(D)&&!w.match(D)&&(S[F]={type:J.pattern,message:x,ref:o,...se(J.pattern,x)},!i))return P(x),S}if(A){if(G(A)){const D=await A(w,r),x=yr(D,ee);if(x&&(S[F]={...x,...se(J.validate,x.message)},!i))return P(x.message),S}else if(N(A)){let D={};for(const x in A){if(!B(D)&&!i)break;const R=yr(await A[x](w,r),ee,x);R&&(D={...R,...se(x,R.message)},P(R.message),i&&(S[F]=D))}if(!B(D)&&(S[F]={ref:ee,...D},!i))return S}}const de=S[F];return P(de?de.message:!0),S},xe=e=>Array.isArray(e)?e:[e],Or=e=>Array.isArray(e)?e.filter(Boolean):[];function it(e,s){const r=s.length-1;let i=0;for(;i<r;){if(p(e)){e=void 0;break}e=e[s[i]],i++}return e}function nt(e){for(const s in e)if(e.hasOwnProperty(s)&&!O(e[s]))return!1;return!0}function U(e,s){if(M(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const r=Array.isArray(s)?s:ne(s)?[s]:ue(s);if(r.some(o=>je.includes(String(o))))return e;const i=r.length===1?e:it(e,r),l=r.length-1,u=r[l];return i&&delete i[u],l!==0&&(N(i)&&B(i)||Array.isArray(i)&&nt(i))&&U(e,r.slice(0,-1)),e}const at=I.createContext(null);at.displayName="HookFormContext";var gr=()=>{let e=[];return{get observers(){return e},next:l=>{for(const u of e)u.next&&u.next(l)},subscribe:l=>(e.push(l),{unsubscribe:()=>{e=e.filter(u=>u!==l)}}),unsubscribe:()=>{e=[]}}};function Sr(e,s){const r={};for(const i in e)if(e.hasOwnProperty(i)){const l=e[i],u=s[i];if(l&&N(l)&&u){const o=Sr(l,u);N(o)&&(r[i]=o)}else e[i]&&(r[i]=u)}return r}const vr=(e,s)=>e!==null&&He(e)&&Object.prototype.hasOwnProperty.call(e,s);var ot=(e,s)=>{if(!s)return!1;let r=e;for(const i of ne(s)?[s]:ue(s)){if(!vr(r,i))return vr(e,s);r=r[i]}return!0},Tr=e=>e.type==="select-multiple",lt=e=>ze(e)||me(e),Pe=e=>ke(e)&&e.isConnected;function _r(e){return Array.isArray(e)||N(e)}function Rr(e,s,r="",i=[]){for(const l in e){const u=r?`${r}.${l}`:l,o=e[l];_r(o)&&_r(v(s,u))?Rr(o,s,u,i):i.push(u)}return i}var ut=e=>{for(const s in e)if(G(e[s]))return!0;return!1};function Cr(e){return Array.isArray(e)||N(e)&&!ut(e)}function Lr(e){return!!(e&&"_f"in e)}function Ir(e){return Array.isArray(e)?!e.some(s=>!O(s)):!Object.keys(e).length}function Be(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function $e(e,s={},r){for(const i in e){const l=e[i],u=r&&r[i];Cr(l)&&(!Array.isArray(l)||!Lr(u))?(s[i]=Array.isArray(l)?[]:{},$e(l,s[i],u),Ir(s[i])&&Be(s,i)):O(l)||(s[i]=!0)}return s}function ie(e,s,r,i){r||(r=$e(s,{},i));for(const l in e){const u=e[l],o=i&&i[l];Cr(u)&&(!Array.isArray(u)||!Lr(o))?(O(s)||Me(r[l])?r[l]=$e(u,Array.isArray(u)?[]:{},o):ie(u,p(s)?{}:s[l],r[l],o),Ir(r[l])&&Be(r,l)):Q(u,s[l])?Be(r,l):r[l]=!0}return r}var ft=(e,s)=>{const r=s.split("."),i=[];let l=r[0];for(let u=1;u<r.length;l+="."+r[u++])!isNaN(+r[u])&&e.has(l)&&i.push(`${l}.${r[u]}`);return i},Nr=(e,{valueAsNumber:s,valueAsDate:r,setValueAs:i})=>O(e)?e:s?e===""?NaN:e&&+e:r&&M(e)?new Date(e):i?i(e):e;function Vr(e){const s=e.ref;return Se(s)?s.files:ze(s)?kr(e.refs).value:Tr(s)?[...s.selectedOptions].map(({value:r})=>r):me(s)?xr(e.refs).value:Nr(s.value,e)}var ct=(e,s,r,i)=>{const l={};for(const u of e){const o=v(s,u);o&&k(l,u,o._f)}return{criteriaMode:r,names:[...e],fields:l,shouldUseNativeValidation:i}},_e=e=>O(e)?e:Oe(e)?e.source:N(e)?Oe(e.value)?e.value.source:e.value:e;const mr="AsyncFunction";var dt=e=>{if(!e||!e.validate)return!1;if(G(e.validate))return e.validate.constructor.name===mr;if(N(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===mr)return!0}return!1},yt=e=>e.mount&&(e.required||!O(e.required)&&e.required!==!1||!O(e.min)||!O(e.max)||!O(e.maxLength)||!O(e.minLength)||e.pattern||e.validate);function br(e,s,r){const i=v(e,r);if(i||ne(r))return{error:i,name:r};const l=r.split(".");for(;l.length;){const u=l.join("."),o=v(s,u),c=v(e,u);if(o&&!Array.isArray(o)&&r!==u)return{name:r};if(c&&c.type)return{name:u,error:c};if(c&&c.root&&c.root.type)return{name:`${u}.root`,error:c.root};l.pop()}return{name:r}}var ht=(e,s,r,i)=>{r(e);const l=Object.keys(e).filter(u=>u!=="name");return!l.length||i&&l.length>=Object.keys(s).length||l.find(u=>s[u]===(!i||X.all))},gt=(e,s,r)=>!e||!s||e===s||xe(e).some(i=>i&&(r?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),vt=(e,s,r,i,l)=>l.isOnAll?!1:!r&&l.isOnTouch?!(s||e):(r?i.isOnBlur:l.isOnBlur)?!e:(r?i.isOnChange:l.isOnChange)?e:!0,_t=(e,s)=>{const r=v(e,s);!Or(r).length&&!r?.root&&U(e,s)};const Vt={mode:X.onSubmit,reValidateMode:X.onChange,shouldFocusError:!0},pe="form",mt=(e,s)=>{for(const r in e)r in s||delete e[r];Object.assign(e,s)},Ur={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function bt(e={}){let s={...Vt,...e},r={...C(Ur),isLoading:G(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},l=N(s.defaultValues)||N(s.values)?C(s.defaultValues||s.values)||{}:{},u=s.shouldUnregister?{}:C(l),o={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},c={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const m={},E={};let T=0,H=De(s.mode),j=De(s.reValidateMode);const $={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...$};let F={...A};const b={array:gr(),state:gr()};let fe=0;const w=s.criteriaMode===X.all,ee=(t,a)=>n=>{clearTimeout(E[t]),E[t]=setTimeout(a,n)},P=async t=>{if(!o.keepIsValid&&!s.disabled&&(A.isValid||F.isValid||t)){const a=++fe;let n;s.resolver?(n=B((await R()).errors),a===fe&&S()):n=await q({fields:i,onlyCheckValid:!0,eventType:oe.VALID}),a===fe&&n!==r.isValid&&b.state.next({isValid:n})}},S=(t,a)=>{!s.disabled&&(A.isValidating||A.validatingFields||F.isValidating||F.validatingFields)&&((t||c.mount).forEach(n=>{n&&(a?k(r.validatingFields,n,a):U(r.validatingFields,n))}),b.state.next({validatingFields:r.validatingFields,isValidating:!B(r.validatingFields)}))},ce=()=>{r.dirtyFields=ie(l,u,void 0,i)},be=(t,a=[],n,f,d=!0,y=!0)=>{if(f&&n&&!s.disabled){o.action=!0;const h=v(i,t);if(o.actionArrayLengths.has(t)||o.actionArrayLengths.set(t,Array.isArray(h)?h.length:0),y&&Array.isArray(h)){const V=n(h,f.argA,f.argB);d&&k(i,t,V)}const g=v(r.errors,t);if(y&&Array.isArray(g)){const V=g.root,L=n(g,f.argA,f.argB)||g;V&&(L.root=V),d&&k(r.errors,t,L),_t(r.errors,t)}const _=v(r.touchedFields,t);if((A.touchedFields||F.touchedFields)&&y&&Array.isArray(_)){const V=n(_,f.argA,f.argB);d&&k(r.touchedFields,t,V)}(A.dirtyFields||F.dirtyFields)&&ce(),b.state.next({name:t,isDirty:Y(t,a),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else k(u,t,a)},Ae=(t,a)=>{k(r.errors,t,a),r.errors={...r.errors},b.state.next({errors:r.errors})},ae=t=>{r.errors=t,b.state.next({errors:r.errors,isValid:!1})},se=t=>{const a=ne(t)?[t]:ue(t);let n=u,f=l;for(let d=0;d<a.length-1;d++){const y=a[d];if(n=p(n)?n:n[y],f=p(f)?f:f[y],n===null&&f!==null)return!0}return!1},Fe=t=>{if(!o.actionArrayLengths.size)return!1;const a=ne(t)?[t]:ue(t);let n=u,f="",d=-1,y=0;for(let h=0;h<a.length;h++){if(p(n))return!1;const g=a[h];if(f=f?`${f}.${g}`:g,Array.isArray(n)&&+g>=n.length)return d===-1?!1:h===d?+g<y:!0;o.actionArrayLengths.has(f)&&(d=h+1,y=o.actionArrayLengths.get(f)),n=n[g]}return!1},de=(t,a,n,f)=>{const d=v(i,t);if(d){if(se(t)||Fe(t))return;const y=O(v(u,t)),h=v(u,t,O(n)?v(l,t):n);O(h)||f&&f.defaultChecked||a?k(u,t,a?h:Vr(d._f)):Re(t,h),o.mount&&!o.action&&(P(),y&&r.isDirty&&(A.isDirty||F.isDirty)&&(Y()||(r.isDirty=!1,b.state.next({...r}))),e.shouldUnregister&&y&&!O(v(u,t))&&Ue(t,c)&&(o.watch=!0))}},D=(t,a,n,f,d)=>{let y=!1,h=!1;const g={name:t};if(!s.disabled||f===!0){if(!n||f){const _=Q(v(l,t),a);(A.isDirty||F.isDirty)&&(h=r.isDirty,r.isDirty=g.isDirty=!_||Y(),y=h!==g.isDirty),h=!!v(r.dirtyFields,t),_!==r.isDirty?mt(r.dirtyFields,ie(l,u,void 0,i)):_?U(r.dirtyFields,t):k(r.dirtyFields,t,!0),g.dirtyFields=r.dirtyFields,y=y||(A.dirtyFields||F.dirtyFields)&&h!==!_}if(n){const _=v(r.touchedFields,t);_||(k(r.touchedFields,t,n),g.touchedFields=r.touchedFields,y=y||(A.touchedFields||F.touchedFields)&&_!==n)}y&&d&&b.state.next(g)}return y?g:{}},x=(t,a,n,f)=>{const d=v(r.errors,t),y=(A.isValid||F.isValid)&&re(a)&&r.isValid!==a;if(s.delayError&&n?(m[t]=ee(t,()=>Ae(t,n)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t],n?k(r.errors,t,n):U(r.errors,t),r.errors={...r.errors}),(n?!Q(d,n):d)||!B(f)||y){const h={...f,...y&&re(a)?{isValid:a}:{},errors:r.errors,name:t};b.state.next(h)}},R=async t=>(S(t,!0),await s.resolver(u,s.context,ct(t||c.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),W=async t=>{const{errors:a}=await R(t);if(S(t),t){for(const n of t){const f=v(a,n);f?c.array.has(n)&&N(f)&&!Object.keys(f).some(d=>!Number.isNaN(Number(d)))?ur(r.errors,{[n]:f},n):k(r.errors,n,f):U(r.errors,n)}r.errors={...r.errors}}else r.errors=a;return a},K=async({name:t,eventType:a})=>{if(e.validate){const n=await e.validate({formValues:u,formState:r,name:t,eventType:a});if(N(n))for(const f in n){const d=n[f];d&&Ee(`${pe}.${f}`,{message:M(d.message)?d.message:"",type:d.type||J.validate})}else M(n)||!n?Ee(pe,{message:n||"",type:J.validate}):Xe(pe);return n}return!0},q=async({fields:t,onlyCheckValid:a,name:n,eventType:f,context:d={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(d.runRootValidation=!0,!await K({name:n,eventType:f})&&(d.valid=!1,a)))return d.valid;for(const y in t){const h=t[y];if(h){const{_f:g,..._}=h;if(g){const V=c.array.has(g.name),L=h._f&&dt(h._f),z=A.validatingFields||A.isValidating||F.validatingFields||F.isValidating;L&&z&&S([g.name],!0);const Z=await hr(h,c.disabled,u,w,s.shouldUseNativeValidation&&!a,V);if(L&&z&&S([g.name]),Z[g.name]&&(d.valid=!1,a)||(!a&&(v(Z,g.name)?V?ur(r.errors,Z,g.name):k(r.errors,g.name,Z[g.name]):U(r.errors,g.name)),e.shouldUseNativeValidation&&Z[g.name]))break}!B(_)&&await q({context:d,onlyCheckValid:a,fields:_,name:y,eventType:f})}}return d.valid},we=()=>{for(const t of c.unMount){const a=v(i,t);a&&(a._f.refs?a._f.refs.every(n=>!Pe(n)):!Pe(a._f.ref))&&Le(t)}c.unMount=new Set},Y=(t,a)=>(t&&a&&k(u,t,a),!Q(o.mount?u:l,l)),ye=(t,a,n)=>st(t,c,{...o.mount?u:O(a)||M(t)?l:a},n,a),Pr=t=>Or(v(o.mount?u:l,t,s.shouldUnregister?v(l,t,[]):[])),Re=(t,a,n={},f=!1,d=!1,y=!1)=>{const h=v(i,t);let g=a;if(h){const _=h._f;_&&(!_.disabled&&k(u,t,Nr(a,_)),g=ke(_.ref)&&p(a)?"":a,Tr(_.ref)?[..._.ref.options].forEach(V=>V.selected=g.includes(V.value)):_.refs?me(_.ref)?_.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(g)?V.checked=!!g.find(L=>L===V.value):V.checked=g===V.value||!!g)}):_.refs.forEach(V=>V.checked=V.value===g):Se(_.ref)?_.ref.value="":(_.ref.value=g,!_.ref.type&&!d&&!y&&b.state.next({name:t,values:f?u:C(u)})))}(n.shouldDirty||n.shouldTouch)&&D(t,g,n.shouldTouch,n.shouldDirty,!d),n.shouldValidate&&Ce(t,{delayError:n.delayError})},Ge=(t,a,n,f=!1,d=!1,y=!1)=>{c.array.has(t)&&b.array.next({name:t,values:f?u:C(u)});for(const h in a){if(!a.hasOwnProperty(h))continue;const g=a[h],_=t+"."+h,V=v(i,_);(c.array.has(t)||N(g)||V&&!V._f)&&!te(g)?Ge(_,g,n,f,d,y):Re(_,g,n,f,d,y)}},Ke=(t,a,n,f,d=!1)=>{const y=v(i,t),h=c.array.has(t),g=f?a:C(a),_=v(u,t),V=Q(_,g);if(V||k(u,t,g),h)b.array.next({name:t,values:f?u:C(u)}),(A.isDirty||A.dirtyFields||F.isDirty||F.dirtyFields)&&n.shouldDirty&&(ce(),d||b.state.next({name:t,dirtyFields:r.dirtyFields,isDirty:Y(t,g)}));else{const L=Array.isArray(g)&&!g.length||B(g),z=!V&&!d;!y||y._f||p(g)||L?Re(t,g,n,f,d,z):Ge(t,g,n,f,d,z)}if(!V&&!d){const L=Ue(t,c),z=f?u:C(u);if(b.state.next({...L&&r,name:o.mount||L?t:void 0,values:z}),!h)for(const Z of ft(c.array,t))b.state.next({name:Z,values:z})}},he=(t,a,n={})=>Ke(t,a,n,!1),pr=(t,a={})=>{const n=G(t)?t(u):t;if(!Q(u,n)){u={...u,...n};for(const f of c.mount)ot(n,f)&&Ke(f,v(n,f),a,!0,!0);b.state.next({...r,name:void 0,type:void 0,...T?{values:u}:{}}),a.shouldValidate&&P()}},Ze=async t=>{o.mount=!0;const a=t.target;let n=a.name,f=!0;const d=v(i,n),y=h=>{f=Number.isNaN(h)||te(h)&&isNaN(h.getTime())||Q(h,v(u,n,h))};if(d){let h,g;const _=a.type?Vr(d._f):Gr(t),V=t.type===oe.BLUR||t.type===oe.FOCUS_OUT,L=!yt(d._f)&&!e.validate&&!s.resolver&&!v(r.errors,n)&&!d._f.deps,z=L||vt(V,v(r.touchedFields,n),r.isSubmitted,j,H),Z=Ue(n,c,V);if(k(u,n,C(_)),V){if(!a||!a.readOnly){d._f.onBlur&&d._f.onBlur(t);const ve=m[n];ve&&ve(0)}}else d._f.onChange&&d._f.onChange(t);const ge=D(n,_,V),zr=!B(ge)||Z;if(!V&&b.state.next({name:n,type:t.type,...T?{values:C(u)}:{}}),z)return(!L||!r.isValid)&&(A.isValid||F.isValid)&&(s.mode==="onBlur"?V&&P():V||P()),zr&&b.state.next({name:n,...Z?{}:ge});if(!s.resolver&&e.validate&&await K({name:n,eventType:t.type}),!V&&Z&&b.state.next({...r}),s.resolver){const{errors:ve}=await R([n]);if(S([n]),y(_),!f){!B(ge)&&b.state.next(ge);return}const Yr=br(r.errors,i,n),or=br(ve,i,Yr.name||n);h=or.error,n=or.name,g=B(ve)}else S([n],!0),h=(await hr(d,c.disabled,u,w,s.shouldUseNativeValidation))[n],S([n]),y(_),f&&(h?g=!1:(A.isValid||F.isValid)&&(g=await q({fields:i,onlyCheckValid:!0,name:n,eventType:t.type})));f&&(d._f.deps&&(!Array.isArray(d._f.deps)||d._f.deps.length>0)&&Ce(d._f.deps),x(n,g,h,ge))}},Je=(t,a)=>{if(v(r.errors,a)&&t.focus)return t.focus(),1},Ce=async(t,a={})=>{let n,f;const d=xe(t);if(s.resolver){const y=await W(O(t)?t:d);n=B(y),f=t?!d.some(h=>v(y,h)):n}else t?(f=(await Promise.all(d.map(async y=>{const h=v(i,y);return await q({fields:h&&h._f?{[y]:h}:h,eventType:oe.TRIGGER})}))).every(Boolean),!(!f&&!r.isValid)&&P()):f=n=await q({fields:i,name:t,eventType:oe.TRIGGER});if(a.delayError&&s.delayError&&M(t)){const y=v(r.errors,t);y?(U(r.errors,t),m[t]=ee(t,()=>Ae(t,y)),m[t](s.delayError)):(clearTimeout(E[t]),delete m[t])}if(a.shouldTouch)for(const y of t?d:c.mount)!c.array.has(y)&&k(r.touchedFields,y,!0);return b.state.next({...!M(t)||(A.isValid||F.isValid)&&n!==r.isValid?{}:{name:t},...s.resolver||!t?{isValid:n}:{},...a.shouldTouch&&(A.touchedFields||F.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),a.shouldFocus&&!f&&Ve(i,Je,t?d:c.mount),f},Mr=(t,a)=>{let n={...o.mount?u:l};return a&&(n=Sr(a.dirtyFields?r.dirtyFields:r.touchedFields,n)),O(t)?n:M(t)?v(n,t):t.map(f=>v(n,f))},Br=t=>O(t)?{...r.errors}:M(t)?v(r.errors,t):t.map(a=>v(r.errors,a)),Qe=(t,a)=>{const n=a||r,f=v(n.errors,t);return{invalid:!!f,isDirty:!!v(n.dirtyFields,t),error:f,isValidating:!!v(r.validatingFields,t),isTouched:!!v(n.touchedFields,t)}},Xe=t=>{const a=t?xe(t):void 0;a?.forEach(n=>U(r.errors,n)),a?a.forEach(n=>{b.state.next({name:n,errors:r.errors})}):(r.errors={},b.state.next({errors:r.errors}))},Ee=(t,a,n)=>{const f=(v(i,t,{_f:{}})._f||{}).ref,d=v(r.errors,t)||{},{ref:y,message:h,type:g,..._}=d;k(r.errors,t,{..._,...a,ref:f}),b.state.next({name:t,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&f&&f.focus&&f.focus()},$r=(t,a)=>{if(G(t)){T++;const{unsubscribe:n}=b.state.subscribe({next:d=>"values"in d&&t(d.values||ye(void 0,a),d)});let f=!1;return{unsubscribe:()=>{f||(f=!0,T--,n())}}}return ye(t,a,!0)},er=t=>{var a;const n=!!(!((a=t.formState)===null||a===void 0)&&a.values);n&&T++;const{unsubscribe:f}=b.state.subscribe({next:y=>{if(gt(t.name,y.name,t.exact)&&ht(y,t.formState||A,nr,t.reRenderRoot)){const h={...u};t.callback({values:h,...r,...y,defaultValues:l})}}});if(!n)return f;let d=!1;return()=>{d||(d=!0,T--,f())}},Wr=t=>(o.mount=!0,F={...F,...t.formState},er({...t,formState:{...$,...t.formState}})),Le=(t,a={})=>{for(const n of t?xe(t):c.mount)c.mount.delete(n),c.array.delete(n),a.keepValue||(U(i,n),U(u,n)),!a.keepError&&U(r.errors,n),!a.keepDirty&&U(r.dirtyFields,n),!a.keepTouched&&U(r.touchedFields,n),!a.keepIsValidating&&U(r.validatingFields,n),!s.shouldUnregister&&!a.keepDefaultValue&&U(l,n);T&&b.state.next({values:C(u)}),b.state.next({...r,...a.keepDirty?{}:{isDirty:Y()}}),!a.keepIsValid&&P()},rr=({disabled:t,name:a})=>{if(re(t)&&o.mount||t||c.disabled.has(a)){const d=c.disabled.has(a)!==!!t;t?c.disabled.add(a):c.disabled.delete(a),d&&o.mount&&!o.action&&P()}},Ie=(t,a={})=>{let n=v(i,t);const f=re(a.disabled)||re(s.disabled),d=!c.registerName.has(t)&&n&&n._f&&!n._f.mount;return k(i,t,{...n||{},_f:{...n&&n._f?n._f:{ref:{name:t}},name:t,mount:!0,...a}}),c.mount.add(t),n&&!d?rr({disabled:re(a.disabled)?a.disabled:s.disabled,name:t}):de(t,!0,a.value),{...f?{disabled:a.disabled||s.disabled}:{},...s.progressive?{required:!!a.required,min:_e(a.min),max:_e(a.max),minLength:_e(a.minLength),maxLength:_e(a.maxLength),pattern:_e(a.pattern)}:{},name:t,onChange:Ze,onBlur:Ze,ref:y=>{if(y){c.registerName.add(t),Ie(t,a),c.registerName.delete(t),n=v(i,t);const h=O(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,g=lt(h),_=n._f.refs||[];if(g?_.find(L=>L===h):h===n._f.ref)return;const V={...n._f};g?(V.refs=[..._.filter(Pe),h,...Array.isArray(v(l,t))?[{}]:[]],V.ref={type:h.type,name:t}):(V.ref=h,delete V.refs),k(i,t,{_f:V}),de(t,!1,void 0,h)}else n=v(i,t,{}),n._f&&(n._f.mount=!1),(s.shouldUnregister||a.shouldUnregister)&&!(Zr(c.array,t)&&o.action)&&c.unMount.add(t)}}},Ne=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ve(i,Je,c.mount),qr=t=>{re(t)&&(b.state.next({disabled:t}),Ve(i,(a,n)=>{const f=v(i,n);f&&(a.disabled=f._f.disabled||t,Array.isArray(f._f.refs)&&f._f.refs.forEach(d=>{d.disabled=f._f.disabled||t}))},0,!1))},tr=(t,a)=>async n=>{let f,d;n&&(n.preventDefault&&n.preventDefault(),n.persist&&n.persist());let y=C(u);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:h,values:g}=await R();S(),r.errors=h,y=C(g)}else await q({fields:i,eventType:oe.SUBMIT});if(c.disabled.size)for(const h of c.disabled)U(y,h);if(U(r.errors,Dr),B(r.errors)){b.state.next({errors:{}});try{f=await t(y,n)}catch(h){d=h}}else a&&await a({...r.errors},n),Ne(),setTimeout(Ne);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:B(r.errors)&&!d,submitCount:r.submitCount+1,errors:r.errors}),d)throw d;return f},Hr=(t,a={})=>{v(i,t)&&(O(a.defaultValue)?he(t,C(v(l,t))):(he(t,a.defaultValue),k(l,t,C(a.defaultValue))),a.keepTouched||U(r.touchedFields,t),a.keepDirty||(U(r.dirtyFields,t),r.isDirty=a.defaultValue?Y(t,C(v(l,t))):Y()),a.keepError||(U(r.errors,t),P()),b.state.next({...r}))},sr=(t,a={})=>{const n=t?C(t):l,f=C(n),d=B(t),y=f,h=i;if(a.keepDefaultValues||(l=n),!a.keepValues){if(a.keepDirtyValues){const g=new Set([...c.mount,...Rr(ie(l,u,void 0,h),r.dirtyFields)]);for(const _ of g){const V=v(r.dirtyFields,_),L=v(u,_),z=v(y,_);V&&!O(L)?k(y,_,L):!V&&!O(z)&&he(_,z)}}else{if(Te&&O(t))for(const g of c.mount){const _=v(i,g);if(_&&_._f){const V=Array.isArray(_._f.refs)?_._f.refs[0]:_._f.ref;if(ke(V)){const L=V.closest("form");if(L){L.reset();break}}}}if(a.keepFieldsRef)for(const g of c.mount)he(g,v(y,g));else i={}}if(s.shouldUnregister){if(u=a.keepDefaultValues?C(l):{},a.keepFieldsRef)for(const g of c.mount)k(u,g,v(y,g))}else u=C(y);b.array.next({values:{...y}}),b.state.next({name:void 0,type:void 0,values:{...y}})}c={mount:a.keepDirtyValues?c.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!A.isValid||!!a.keepIsValid||!!a.keepDirtyValues||!s.shouldUnregister&&!B(y),o.watch=!!s.shouldUnregister,o.keepIsValid=!!a.keepIsValid,o.action=!1,o.actionArrayLengths.clear(),a.keepErrors||(r.errors={}),b.state.next({submitCount:a.keepSubmitCount?r.submitCount:0,isDirty:d?!1:a.keepDirty?r.isDirty:a.keepValues?Y():!!(a.keepDefaultValues&&!Q(t,l)),isSubmitted:a.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:d?{}:a.keepDirtyValues?a.keepDefaultValues&&u?ie(l,u,void 0,h):r.dirtyFields:a.keepDefaultValues&&t?ie(l,t,void 0,h):a.keepDirty?r.dirtyFields:{},touchedFields:a.keepTouched?r.touchedFields:{},errors:a.keepErrors?r.errors:{},isSubmitSuccessful:a.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:l})},ir=(t,a)=>sr(G(t)?t(u):t,{...s.resetOptions,...a}),jr=(t,a={})=>{const n=v(i,t),f=n&&n._f;if(f){const d=f.refs?f.refs[0]:f.ref;d.focus&&setTimeout(()=>{d.focus(),a.shouldSelect&&G(d.select)&&d.select()})}},nr=t=>{const{name:a,type:n,values:f,...d}=t;r={...r,...d}};b.state.subscribe({next:nr});const ar={control:{register:Ie,unregister:Le,getFieldState:Qe,handleSubmit:tr,setError:Ee,_subscribe:er,_runSchema:R,_updateIsValidating:S,_focusError:Ne,_getWatch:ye,_getDirty:Y,_setValid:P,_setFieldArray:be,_setDisabledField:rr,_setErrors:ae,_getFieldArray:Pr,_reset:sr,_resetDefaultValues:()=>G(s.defaultValues)&&s.defaultValues().then(t=>{ir(t,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:we,_disableForm:qr,_subjects:b,_proxyFormState:A,get _fields(){return i},get _formValues(){return u},get _state(){return o},set _state(t){o=t},get _defaultValues(){return l},get _names(){return c},set _names(t){c=t},get _formState(){return r},get _options(){return s},set _options(t){s={...s,...t},H=De(s.mode),j=De(s.reValidateMode)}},subscribe:Wr,trigger:Ce,register:Ie,handleSubmit:tr,watch:$r,setValue:he,setValues:pr,getValues:Mr,getErrors:Br,reset:ir,resetField:Hr,resetDefaultValues:(t,a={})=>{if(l=C(t),!a.keepDirty){const n=ie(l,u,void 0,i);r.dirtyFields=n,r.isDirty=!B(n)}a.keepIsValid||P(),b.state.next({...r,defaultValues:l})},clearErrors:Xe,unregister:Le,setError:Ee,setFocus:jr,getFieldState:Qe};return{...ar,formControl:ar}}function kt(e={}){const s=I.useRef(void 0),r=I.useRef(void 0),i=I.useRef(e.formControl),[l,u]=I.useState(()=>({...C(Ur),isLoading:G(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:G(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:l},e.defaultValues&&!G(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:E,...T}=bt(e);s.current={...T,formState:l}}const o=s.current.control;o._options=e;const{resyncIfNeeded:c,snapshot:m}=tt();return et(()=>{const E=()=>({...o._formState,defaultValues:o._defaultValues});c(!0,E,u);const T=o._subscribe({formState:o._proxyFormState,callback:()=>u({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return u(H=>({...H,isReady:!0})),o._formState.isReady=!0,()=>{T(),m(!0,E)}},[o,c,m]),I.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),I.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),I.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),I.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),I.useEffect(()=>{if(o._proxyFormState.isDirty){const E=o._getDirty();E!==l.isDirty&&o._subjects.state.next({isDirty:E})}},[o,l.isDirty]),I.useEffect(()=>{var E;e.values&&!Q(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((E=o._options.resetOptions)===null||E===void 0)&&E.keepIsValid||o._setValid(),r.current=e.values,u(T=>({...T}))):o._resetDefaultValues()},[o,e.values]),I.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=I.useMemo(()=>Xr(l,o),[o,l]),s.current}const Ar=(e,s,r)=>{if(e&&"reportValidity"in e){const i=v(r,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},We=(e,s)=>{for(const r in s.fields){const i=s.fields[r];i&&i.ref&&"reportValidity"in i.ref?Ar(i.ref,r,e):i&&i.refs&&i.refs.forEach(l=>Ar(l,r,e))}},Fr=(e,s)=>{s.shouldUseNativeValidation&&We(e,s);const r={};for(const i in e){const l=v(s.fields,i),u=Object.assign(e[i]||{},{ref:l&&l.refs?l.refs[0]:l&&l.ref});if(At(s.names||Object.keys(e),i)){const o=Object.assign({},v(r,i));k(o,"root",u),k(r,i,o)}else k(r,i,u)}return r},At=(e,s)=>{const r=wr(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>wr(i).match(`^${r}\\.\\d+`))};function wr(e){return e.replace(/\[(\d+)]/g,".$1").replace(/[[\]]/g,"")}function qe(){return qe=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},qe.apply(null,arguments)}function Er(e,s){try{var r=e()}catch(i){return s(i)}return r&&r.then?r.then(void 0,s):r}function Ft(e,s){for(var r=Object.create(null);e.length;){var i=e[0],l=i.code,u=i.message,o=i.path.join(".");if(!r[o])if("unionErrors"in i){var c,m,E=i.unionErrors.reduce(function(j,$){return $.errors.length<j.errors.length?$:j}).errors[0];r[o]={message:(c=E?.message)!=null?c:u,type:(m=E?.code)!=null?m:l}}else r[o]={message:u,type:l};if("unionErrors"in i&&i.unionErrors.forEach(function(j){return j.errors.forEach(function($){return e.push($)})}),s){var T=r[o].types,H=T&&T[i.code];r[o]=Ye(o,s,r,l,H?[].concat(H,i.message):i.message)}e.shift()}return r}function wt(e,s){for(var r=Object.create(null),i=function(){var l=e[0],u=l.code,o=l.message,c=l.path.join(".");if(!r[c])if(l.code==="invalid_union"&&l.errors.length>0){var m,E,T=l.errors.reduce(function($,A){return A.length<$.length?A:$})[0];r[c]={message:(m=T?.message)!=null?m:o,type:(E=T?.code)!=null?E:u}}else r[c]={message:o,type:u};if(l.code==="invalid_union"&&l.errors.forEach(function($){return $.forEach(function(A){return e.push(qe({},A,{path:[].concat(l.path,A.path)}))})}),s){var H=r[c].types,j=H&&H[l.code];r[c]=Ye(c,s,r,u,j?[].concat(j,l.message):l.message)}e.shift()};e.length;)i();return r}function Ot(e,s,r){if(r===void 0&&(r={}),(function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){function o(m){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):m}}var c=e;return r.mode==="sync"?o(c.parse(i,s)):Promise.resolve(c.parseAsync(i,s)).then(o)},function(o){if((function(c){var m;return!(c==null||(m=c._zod)==null||(m=m.traits)==null||!m.has("$ZodError"))})(o))return{values:{},errors:Fr(wt(o.issues,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_def"in i&&typeof i._def=="object"})(e))return function(i,l,u){try{return Promise.resolve(Er(function(){return Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(o){return u.shouldUseNativeValidation&&We({},u),{errors:{},values:r.raw?Object.assign({},i):o}})},function(o){if((function(c){return Array.isArray(c?.issues)})(o))return{values:{},errors:Fr(Ft(o.errors,!u.shouldUseNativeValidation&&u.criteriaMode==="all"),u)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}export{Ot as a,kt as u};