@snagset/server 0.1.51 → 0.1.52

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 (74) hide show
  1. package/package.json +1 -1
  2. package/static/dashboard/assets/CompositeItem-DTWd-USH.js +1 -0
  3. package/static/dashboard/assets/{CompositeList-BRoUQLZ7.js → CompositeList-B4njw0mu.js} +1 -1
  4. package/static/dashboard/assets/{ConfirmDialog-CKQ2LE2m.js → ConfirmDialog-CMhBnMda.js} +1 -1
  5. package/static/dashboard/assets/{CopyButton-Et1g5isE.js → CopyButton-BeKLr-HL.js} +1 -1
  6. package/static/dashboard/assets/{FieldItemContext-DCpv0Ox1.js → FieldItemContext-e_7kirJu.js} +1 -1
  7. package/static/dashboard/assets/{InstallTag-Dgm3LPul.js → InstallTag-FQEroW67.js} +1 -1
  8. package/static/dashboard/assets/{InstanceRows-BNvGpofx.js → InstanceRows-g_itJcJn.js} +1 -1
  9. package/static/dashboard/assets/{McpTokens-Dopxwnwy.js → McpTokens-Bnomst3Z.js} +1 -1
  10. package/static/dashboard/assets/{SaveState-DT_ZtqN6.js → SaveState-BHP4ix-R.js} +1 -1
  11. package/static/dashboard/assets/{_app-BRCkQPN9.js → _app-Dow8BzDi.js} +1 -1
  12. package/static/dashboard/assets/{_app-BSR3Hyuo.js → _app-VV0MiNwC.js} +1 -1
  13. package/static/dashboard/assets/{activity-C7wAfXpX.js → activity-DE2pBEeo.js} +1 -1
  14. package/static/dashboard/assets/{arrow-left-BnaT-Fbe.js → arrow-left-CkkevAm7.js} +1 -1
  15. package/static/dashboard/assets/{avatar-BH-hU7Qh.js → avatar-3CJf9_jk.js} +1 -1
  16. package/static/dashboard/assets/{badge-BaViqDz3.js → badge-ixRisPgI.js} +1 -1
  17. package/static/dashboard/assets/{card-XWz6Setp.js → card-VzmwyX4K.js} +1 -1
  18. package/static/dashboard/assets/{check-CsTK2ZlT.js → check-oVlGjqlI.js} +1 -1
  19. package/static/dashboard/assets/{chevron-down-DPOV2aTJ.js → chevron-down-3JSK4KJk.js} +1 -1
  20. package/static/dashboard/assets/{chevron-right-DaVBytqm.js → chevron-right-d2kzhQsc.js} +1 -1
  21. package/static/dashboard/assets/{copy-74WsRINA.js → copy-C9jwRSea.js} +1 -1
  22. package/static/dashboard/assets/{dialog-CbKDGxpa.js → dialog-CNe7vaQT.js} +1 -1
  23. package/static/dashboard/assets/{dropdown-menu-CJcFUaVg.js → dropdown-menu-Co_KnEvk.js} +1 -1
  24. package/static/dashboard/assets/{forgot-Ba8VynCy.js → forgot-C-l4CDgp.js} +1 -1
  25. package/static/dashboard/assets/{image-off-C79CMi04.js → image-off-zWL0q8lp.js} +1 -1
  26. package/static/dashboard/assets/index-DVRHlt-r.css +1 -0
  27. package/static/dashboard/assets/{index-Bjyhj6ZB.js → index-jVSWkcSK.js} +3 -3
  28. package/static/dashboard/assets/{inertValue-B5n_awh1.js → inertValue-D5-xyRX6.js} +1 -1
  29. package/static/dashboard/assets/{invite-BF88t7QH.js → invite-CeFOk_KD.js} +1 -1
  30. package/static/dashboard/assets/{label-C3zh-elW.js → label-CzNjVuJl.js} +1 -1
  31. package/static/dashboard/assets/{layout-grid-oG1simZW.js → layout-grid-804CjQp4.js} +1 -1
  32. package/static/dashboard/assets/me-HGkftAh1.js +1 -0
  33. package/static/dashboard/assets/{parts-DoQ2TEp-.js → parts-OimeyxOU.js} +1 -1
  34. package/static/dashboard/assets/{plus-cmPSXDaO.js → plus-JDUOLC5V.js} +1 -1
  35. package/static/dashboard/assets/{reset-BpU9fRSp.js → reset-BgjV0ibh.js} +1 -1
  36. package/static/dashboard/assets/{s._site-D2r1l61r.js → s._site-CqhbaILH.js} +1 -1
  37. package/static/dashboard/assets/{s._site.comments-DwaUmd00.js → s._site.comments-CUJ6gfP_.js} +1 -1
  38. package/static/dashboard/assets/{s._site.reviewers-DRScBd1i.js → s._site.reviewers-mVG7kXC6.js} +1 -1
  39. package/static/dashboard/assets/{s._site.settings-qspOmIrK.js → s._site.settings-BxmHhbgy.js} +1 -1
  40. package/static/dashboard/assets/{setup-BkYyqis5.js → setup-DXSpmOXt.js} +1 -1
  41. package/static/dashboard/assets/{sign-in-lrKREplo.js → sign-in-BQKwrHAZ.js} +1 -1
  42. package/static/dashboard/assets/{sign-up-Cz1mnlMx.js → sign-up-Bkz7pD7p.js} +1 -1
  43. package/static/dashboard/assets/{sites-Dw1vM12C.js → sites-CAymJiTT.js} +1 -1
  44. package/static/dashboard/assets/{studio-yUvPcZ3O.js → studio-BKmWJ117.js} +1 -1
  45. package/static/dashboard/assets/studio-CEcq06yC.js +1 -0
  46. package/static/dashboard/assets/studio.index-C1S6bTah.js +1 -0
  47. package/static/dashboard/assets/{studio.integrations-qLy4n2Db.js → studio.integrations-BHZx3da-.js} +1 -1
  48. package/static/dashboard/assets/{studio.members-BCByOoP6.js → studio.members-DFLy8pUA.js} +1 -1
  49. package/static/dashboard/assets/{studio.plan-VWSLPHcb.js → studio.plan-Bw9piNdr.js} +1 -1
  50. package/static/dashboard/assets/{sun-BpsiEWtf.js → sun-i-qGe4pR.js} +1 -1
  51. package/static/dashboard/assets/{switch-ByUmW5H2.js → switch-BCvzokd6.js} +1 -1
  52. package/static/dashboard/assets/{table-C5ApoOFC.js → table-CJ9qkwn1.js} +1 -1
  53. package/static/dashboard/assets/{useAriaLabelledBy-CvsQoCZu.js → useAriaLabelledBy-B4z1WZse.js} +1 -1
  54. package/static/dashboard/assets/{useBaseQuery-0a7T0HmH.js → useBaseQuery-CDoR88Fa.js} +1 -1
  55. package/static/dashboard/assets/{useCompositeItem-CsYzexWF.js → useCompositeItem-MHMarTaJ.js} +1 -1
  56. package/static/dashboard/assets/useQuery-hBVmWzEl.js +1 -0
  57. package/static/dashboard/assets/useRender-mrNZQnpJ.js +1 -0
  58. package/static/dashboard/assets/{useValueChanged-CQWizfo3.js → useValueChanged-ERXEloZc.js} +1 -1
  59. package/static/dashboard/assets/{users-Df1_iduv.js → users-Dhqkqlui.js} +1 -1
  60. package/static/dashboard/assets/{welcome-DXLh7SqO.js → welcome-LbC7b_-p.js} +1 -1
  61. package/static/dashboard/assets/{widget-signin-E1tpKlR7.js → widget-signin-DgOTYROi.js} +1 -1
  62. package/static/dashboard/assets/{you-CQElYVq9.js → you-DEoU_kOm.js} +1 -1
  63. package/static/dashboard/assets/{zod-CuCSHm2e.js → zod-8bzEaiHG.js} +1 -1
  64. package/static/dashboard/index.html +2 -2
  65. package/static/widget/build.json +2 -2
  66. package/static/widget/snag.js +1 -1
  67. package/static/widget/snag.runtime.js +1 -1
  68. package/static/dashboard/assets/CompositeItem-Dr9UcOhm.js +0 -1
  69. package/static/dashboard/assets/index-vKxPrBs3.css +0 -1
  70. package/static/dashboard/assets/me-CtDXQ1_u.js +0 -1
  71. package/static/dashboard/assets/studio-DXL_Yf0t.js +0 -1
  72. package/static/dashboard/assets/studio.index-BQaRfibu.js +0 -1
  73. package/static/dashboard/assets/useQuery-ClGE3W7i.js +0 -1
  74. package/static/dashboard/assets/useRender-tS6QvoXj.js +0 -1
@@ -1 +1 @@
1
- import{q as K,j as e,L as U,t as _,d as se,r as i,a5 as P,a6 as T,a2 as M,s as F,a7 as D,B as x,$ as ne,C as G,A as oe}from"./index-Bjyhj6ZB.js";import{u as V}from"./useQuery-ClGE3W7i.js";import{B}from"./badge-BaViqDz3.js";import{C as E,E as O,H as R,G as W,I as J,J as H}from"./dialog-CbKDGxpa.js";import{L as S,I}from"./label-C3zh-elW.js";import{C as ae}from"./ConfirmDialog-CKQ2LE2m.js";import{A as re,P as ie,a as ce}from"./parts-DoQ2TEp-.js";import{u as Q}from"./me-CtDXQ1_u.js";import{C as q}from"./CopyButton-Et1g5isE.js";import{b as le}from"./labels--UUyt9uB.js";import{M as de}from"./McpTokens-Dopxwnwy.js";import"./useBaseQuery-0a7T0HmH.js";import"./useRender-tS6QvoXj.js";import"./inertValue-B5n_awh1.js";import"./check-CsTK2ZlT.js";import"./copy-74WsRINA.js";import"./card-XWz6Setp.js";import"./switch-ByUmW5H2.js";import"./useAriaLabelledBy-CvsQoCZu.js";import"./useValueChanged-CQWizfo3.js";const he={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function me(){const o=Q(),l=K(o.user.role,"settings"),f=K(o.user.role,"studio")&&_(o),j=V(oe.integrations()),A=se(),N=()=>A.invalidateQueries({queryKey:["integrations"]}),[d,g]=i.useState(null),[c,b]=i.useState(null),[k,u]=i.useState(null),v=P({mutationFn:t=>F.regenerateGitHubWebhook(t),onSuccess:({webhook:t},r)=>u({site:r,provider:"github",hook:t,fresh:!1}),onError:t=>T.error(M(t))}),C=P({mutationFn:({uid:t,provider:r})=>F.testTracker(t,r).then(L=>({...L,provider:r})),onSuccess:t=>{T[t.ok?"success":"error"](t.ok?`${D[t.provider]} can see ${t.target}`:t.detail??`${D[t.provider]} refused the token`),N()},onError:t=>T.error(M(t))}),y=P({mutationFn:({uid:t,provider:r})=>F.disconnectTracker(t,r),onSuccess:()=>{b(null),N()},onError:t=>T.error(M(t))}),w=j.data?.data??[],m=t=>w.filter(r=>r.provider===t),p=o.projects.filter(t=>!t.archived&&!t.locked),a=t=>p.filter(r=>!m(t).some(L=>L.site===r.uid)),s=l?o.limits.integrations?p.length===0?"site":null:"plan":null;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(ie,{title:"Integrations",sub:"Mirrors converge on the comment's status here; Slack only announces"}),s&&e.jsxs("div",{role:"note",className:"flex max-w-[1040px] flex-wrap items-center gap-x-4 gap-y-2 rounded-lg border border-border bg-muted/40 px-4 py-3 text-[13px]",children:[e.jsx("span",{className:"min-w-0 flex-1",children:s==="plan"?o.user.role==="owner"?"This studio's plan does not include integrations. A plan that does lets you connect each site to GitHub, Linear, Jira and Slack.":"This studio's plan does not include integrations. An owner can change the plan.":o.projects.length===0?"An integration connects one site to one repository, team, project or channel. Add a site first, then connect it here.":"An integration connects one site at a time, and every site here is archived or read-only. Restore one, or add a site, then connect it here."}),s==="plan"?o.user.role==="owner"&&e.jsx(x,{variant:"outline",size:"sm",render:e.jsx(U,{to:"/studio/plan"}),children:"See plans"}):e.jsx(x,{variant:"outline",size:"sm",render:e.jsx(U,{to:"/sites"}),children:"Go to Sites"})]}),["github","linear","jira","slack"].map(t=>{const r=m(t),L=a(t);return e.jsxs(ce,{title:D[t],description:t==="github"?"A comment becomes an issue in the site's repository, with the brief as its body; resolving it here closes the issue there, and closing it there resolves it here. A fine-grained token per site — no OAuth app to register.":t==="linear"?"A comment becomes an issue in the site's team, with the brief as its body; our status moves it between the team's workflow states by type, and a webhook from Linear moves it back. A personal API key per site — no OAuth app to register.":t==="jira"?"A comment becomes an issue in the site's Jira project, with the brief as its description; our status moves it through the workflow by status category, and a webhook from Jira moves it back. An API token with the account's email — what Atlassian gives a self-hoster.":"One message per comment in a channel, edited in place as the status moves — never a second message, never a reply. A bot token from an app you create in a click from our manifest; Slack sends nothing back.",children:[j.isPending&&e.jsx(ne,{rows:2}),j.isSuccess&&r.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(B,{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."})]}),r.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:r.map(n=>{const h=he[n.health]??{label:n.health,tone:"warn"};return e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border px-3 py-2.5 text-[13px]",children:[e.jsx("span",{className:"font-medium",children:n.siteName??n.site}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("code",{className:"font-mono text-[12.5px]",children:n.provider==="github"?`${n.owner}/${n.repo}`:n.provider==="linear"?`${n.teamKey} · ${n.teamName}`:n.provider==="jira"?`${n.projectKey} · ${n.projectName}`:`#${n.channelName} · ${n.teamName}`}),e.jsx(B,{variant:"outline",className:h.tone==="ok"?"border-ok text-ok":h.tone==="bad"?"border-destructive text-destructive":"",children:h.label}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[n.provider==="slack"?n.createOn==="thread.created"?"A message for every new comment":"Messages when you ask, from the brief":n.createOn==="thread.created"?"An issue for every new comment":"Issues when you ask, from the brief",n.provider==="github"&&n.labels.length?` · labels ${n.labels.join(", ")}`:"",n.provider!=="github"&&n.provider!=="slack"&&!n.hasWebhookSecret?` · no webhook secret yet, so ${D[n.provider]} cannot move comments here`:""," · ",le(n.updatedAt)]}),n.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:n.lastError}),l&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[n.provider==="github"?e.jsx(x,{variant:"ghost",size:"sm",loading:v.isPending,onClick:()=>v.mutate(n.site),children:"Webhook…"}):n.provider==="slack"?null:e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>u({site:n.site,provider:n.provider,hook:{url:`${location.origin}/api/v1/integrations/${n.provider}/inbound`},fresh:!1}),children:"Webhook…"}),e.jsx(x,{variant:"ghost",size:"sm",loading:C.isPending,onClick:()=>C.mutate({uid:n.site,provider:n.provider}),children:"Test"}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>b(n),children:"Disconnect"})]})]},`${n.provider}:${n.site}`)})}),l&&!s&&L.length>0&&e.jsx("div",{children:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>g(t),children:"Connect a site…"})})]},t)}),e.jsx(de,{owner:l,instanceOwner:f,operator:_(o),sites:o.projects}),e.jsx(ue,{open:d==="github",onOpenChange:t=>!t&&g(null),sites:a("github"),onDone:(t,r)=>{N(),r&&u({site:t,provider:"github",hook:r,fresh:!0})}}),e.jsx(xe,{open:d==="linear",onOpenChange:t=>!t&&g(null),sites:a("linear"),onDone:(t,r)=>{N(),u({site:t,provider:"linear",hook:r,fresh:!0})}}),e.jsx(ge,{open:d==="jira",onOpenChange:t=>!t&&g(null),sites:a("jira"),onDone:(t,r)=>{N(),u({site:t,provider:"jira",hook:r,fresh:!0})}}),e.jsx(fe,{open:d==="slack",onOpenChange:t=>!t&&g(null),sites:a("slack"),onDone:()=>void N()}),e.jsx(pe,{state:k,onClose:()=>u(null),siteName:t=>w.find(r=>r.site===t)?.siteName??"the site"}),e.jsx(ae,{open:c!==null,onOpenChange:t=>!t&&b(null),title:`Disconnect ${c?.siteName??"this site"} from ${c?D[c.provider]:"the tracker"}?`,description:c?.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:y.isPending,onConfirm:async()=>{c&&await y.mutateAsync({uid:c.site,provider:c.provider})}})]})}function ue({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(""),[v,C]=i.useState(!1),[y,w]=i.useState(""),m=P({mutationFn:s=>F.connectTracker(s,"github",{repository:d.trim(),token:c.trim(),labels:k,createOn:v?"thread.created":"manual"})}),p=A||f[0]?.uid||"",a=async s=>{s.preventDefault(),w("");try{const t=await m.mutateAsync(p);g(""),b(""),u(""),C(!1),l(!1),j(p,t.webhook&&"secret"in t.webhook?t.webhook:void 0),T.success("GitHub connected")}catch(t){w(t instanceof G?t.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void a(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to GitHub"}),e.jsxs(J,{children:["A fine-grained personal access token with ",e.jsx("b",{children:"Issues: read and write"})," on that one repository. It is checked against the repository before it is saved, and stored encrypted with this instance's secret key."]})]}),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(S,{htmlFor:"gh-site",children:"Site"}),e.jsx("select",{id:"gh-site",value:p,onChange:s=>N(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"gh-repo",children:"Repository"}),e.jsx(I,{id:"gh-repo",placeholder:"kilnwork/site",value:d,onChange:s=>g(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"gh-token",children:"Token"}),e.jsx(I,{id:"gh-token",type:"password",placeholder:"github_pat_…",value:c,onChange:s=>b(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"gh-labels",children:"Labels"}),e.jsx(I,{id:"gh-labels",placeholder:"review, bug",value:k,onChange:s=>u(s.target.value)}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Applied to every issue this makes. Optional."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:v,onChange:s=>C(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:'Off by default: a reviewer walking a site leaves twenty comments and half are "never mind". Make issues from the brief when you mean it.'})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:m.isPending,disabled:!d.trim()||!c.trim()||!p,children:m.isPending?"Checking…":"Connect"})]})]})})})}function pe({state:o,onClose:l,siteName:f}){const j=o&&"secret"in o.hook?o.hook.secret:null;return e.jsx(E,{open:o!==null,onOpenChange:A=>!A&&l(),children:e.jsxs(O,{children:[e.jsxs(R,{children:[e.jsx(W,{children:o?.fresh?"Connected — now the webhook":"Webhook for "+(o?f(o.site):"")}),e.jsx(J,{children:o?.provider==="linear"?"Issues moved in Linear move the comment here. In Linear › Settings › API › Webhooks, create one for the team with this URL and Issue events; then paste its signing secret when connecting or replacing the connection.":o?.provider==="jira"?"Issues moved in Jira move the comment here. In Jira › Settings › System › Webhooks, create one with this URL, the events Issue updated and Issue deleted, and a secret; then paste the same secret when connecting or replacing the connection.":`Issues closed or reopened on GitHub move the comment here. Add a webhook to the repository — Settings › Webhooks › Add webhook — with these values. The secret is shown this once${o?.fresh?"":", and the previous one has stopped working"}.`})]}),o&&e.jsxs("dl",{className:"m-0 grid grid-cols-[110px_1fr] gap-x-3 gap-y-2 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Payload URL"}),e.jsxs("dd",{className:"m-0 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[12px]",children:o.hook.url}),e.jsx(q,{text:o.hook.url,label:"Copy the payload URL"})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Content type"}),e.jsx("dd",{className:"m-0",children:e.jsx("code",{className:"font-mono text-[12px]",children:"application/json"})}),j&&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:j}),e.jsx(q,{text:j,label:"Copy the secret"})]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Events"}),e.jsx("dd",{className:"m-0",children:o.provider==="linear"?"Issues":o.provider==="jira"?"Issue: updated, deleted":"Let me select individual events → Issues"})]}),e.jsx(H,{children:e.jsx(x,{type:"button",onClick:l,children:"Done"})})]})})}function xe({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(""),[v,C]=i.useState(!1),[y,w]=i.useState(""),m=P({mutationFn:s=>F.connectTracker(s,"linear",{team:d.trim(),apiKey:c.trim(),...k.trim()?{webhookSecret:k.trim()}:{},createOn:v?"thread.created":"manual"})}),p=A||f[0]?.uid||"",a=async s=>{s.preventDefault(),w("");try{const t=await m.mutateAsync(p);g(""),b(""),u(""),C(!1),l(!1),j(p,t.webhook??{url:`${location.origin}/api/v1/integrations/linear/inbound`}),T.success("Linear connected")}catch(t){w(t instanceof G?t.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void a(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to Linear"}),e.jsx(J,{children:"A personal API key from Linear › Settings › API, belonging to a member of the team. It is checked against the team before it is saved, and stored encrypted with this instance's secret key."})]}),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(S,{htmlFor:"ln-site",children:"Site"}),e.jsx("select",{id:"ln-site",value:p,onChange:s=>N(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"ln-team",children:"Team key"}),e.jsx(I,{id:"ln-team",placeholder:"ENG",value:d,onChange:s=>g(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"The prefix of the team's issues, like the ENG in ENG-123."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"ln-key",children:"API key"}),e.jsx(I,{id:"ln-key",type:"password",placeholder:"lin_api_…",value:c,onChange:s=>b(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"ln-secret",children:"Webhook signing secret"}),e.jsx(I,{id:"ln-secret",type:"password",placeholder:"from Linear's webhook, optional",value:k,onChange:s=>u(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Lets Linear move comments here when issues move there. The URL to give Linear is shown after connecting."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:v,onChange:s=>C(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:m.isPending,disabled:!d.trim()||!c.trim()||!p,children:m.isPending?"Checking…":"Connect"})]})]})})})}function ge({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(""),[v,C]=i.useState(""),[y,w]=i.useState(""),[m,p]=i.useState(!1),[a,s]=i.useState(""),t=P({mutationFn:h=>F.connectTracker(h,"jira",{siteUrl:d.trim(),project:c.trim(),email:k.trim(),apiToken:v.trim(),...y.trim()?{webhookSecret:y.trim()}:{},createOn:m?"thread.created":"manual"})}),r=A||f[0]?.uid||"",L=async h=>{h.preventDefault(),s("");try{const $=await t.mutateAsync(r);b(""),C(""),w(""),p(!1),l(!1),j(r,$.webhook??{url:`${location.origin}/api/v1/integrations/jira/inbound`}),T.success("Jira connected")}catch($){s($ instanceof G?$.message:"Could not reach the server.")}},n=(h,$,Y,X,Z,ee="text",z)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:`jr-${h}`,children:$}),e.jsx(I,{id:`jr-${h}`,type:ee,placeholder:Z,value:Y,onChange:te=>X(te.target.value),autoComplete:"off"}),z&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:z})]});return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:h=>void L(h),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to Jira"}),e.jsx(J,{children:"An API token from id.atlassian.com › Security, with the email of the account it belongs to. It is checked against the project before it is saved, and stored encrypted with this instance's secret key."})]}),a&&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:a}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"jr-site",children:"Site"}),e.jsx("select",{id:"jr-site",value:r,onChange:h=>N(h.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(h=>e.jsx("option",{value:h.uid,children:h.name},h.uid))})]}),n("url","Jira site",d,g,"https://kilnwork.atlassian.net"),n("project","Project key",c,b,"KAN","text","The prefix of the project's issues, like the KAN in KAN-12."),n("email","Account email",k,u,"you@kilnwork.studio","email"),n("token","API token",v,C,"","password"),n("secret","Webhook secret",y,w,"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:m,onChange:h=>p(h.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:t.isPending,disabled:!d.trim()||!c.trim()||!k.trim()||!v.trim()||!r,children:t.isPending?"Checking…":"Connect"})]})]})})})}function fe({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(!0),[v,C]=i.useState(""),y=V({queryKey:["integrations","slack","manifest"],queryFn:()=>F.slackManifest(),enabled:o,staleTime:1/0}),w=P({mutationFn:a=>F.connectTracker(a,"slack",{channel:d.trim(),token:c.trim(),createOn:k?"thread.created":"manual"})}),m=A||f[0]?.uid||"",p=async a=>{a.preventDefault(),C("");try{await w.mutateAsync(m),g(""),b(""),u(!0),l(!1),j(m),T.success("Slack connected")}catch(s){C(s instanceof G?s.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:a=>void p(a),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to Slack"}),e.jsx(J,{children:"Create the app in your workspace from our manifest — one click, the scopes are filled in — install it, and paste its Bot User OAuth Token. The token is checked against the channel before it is saved, and stored encrypted with this instance's secret key."})]}),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(S,{htmlFor:"sl-site",children:"Site"}),e.jsx("select",{id:"sl-site",value:m,onChange:a=>N(a.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(a=>e.jsx("option",{value:a.uid,children:a.name},a.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(x,{type:"button",variant:"outline",size:"sm",disabled:!y.data,render:e.jsx("a",{href:y.data?.url??"#",target:"_blank",rel:"noreferrer"}),children:"Create app…"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"sl-token",children:"2. Bot User OAuth Token"}),e.jsx(I,{id:"sl-token",type:"password",placeholder:"xoxb-…",value:c,onChange:a=>b(a.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(S,{htmlFor:"sl-channel",children:"3. Channel"}),e.jsx(I,{id:"sl-channel",placeholder:"#reviews",value:d,onChange:a=>g(a.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:k,onChange:a=>u(a.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"A message for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"On by default: a channel is where people are told. Turn it off to post from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:w.isPending,disabled:!d.trim()||!c.trim()||!m,children:w.isPending?"Checking…":"Connect"})]})]})})})}const We=()=>K(Q().user.role,"settings")?e.jsx(me,{}):e.jsx(re,{title:"Integrations",children:e.jsxs("p",{className:"m-0",children:["Connecting a site to GitHub, Linear, Jira or Slack is done by an owner or an admin. Your own agent tokens are on"," ",e.jsx(U,{to:"/you",className:"text-brand hover:underline",children:"You"}),"."]})});export{We as component};
1
+ import{q as K,j as e,L as U,t as _,d as se,r as i,a5 as P,a6 as T,a2 as M,s as F,a8 as D,B as x,$ as ne,C as G,A as oe}from"./index-jVSWkcSK.js";import{u as V}from"./useQuery-hBVmWzEl.js";import{B}from"./badge-ixRisPgI.js";import{C as E,E as O,H as R,G as W,I as J,J as H}from"./dialog-CNe7vaQT.js";import{L as S,I}from"./label-CzNjVuJl.js";import{C as ae}from"./ConfirmDialog-CMhBnMda.js";import{A as re,P as ie,a as ce}from"./parts-OimeyxOU.js";import{u as Q}from"./me-HGkftAh1.js";import{C as q}from"./CopyButton-BeKLr-HL.js";import{b as le}from"./labels--UUyt9uB.js";import{M as de}from"./McpTokens-Bnomst3Z.js";import"./useBaseQuery-CDoR88Fa.js";import"./useRender-mrNZQnpJ.js";import"./inertValue-D5-xyRX6.js";import"./check-oVlGjqlI.js";import"./copy-C9jwRSea.js";import"./card-VzmwyX4K.js";import"./switch-BCvzokd6.js";import"./useAriaLabelledBy-B4z1WZse.js";import"./useValueChanged-ERXEloZc.js";const he={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function me(){const o=Q(),l=K(o.user.role,"settings"),f=K(o.user.role,"studio")&&_(o),j=V(oe.integrations()),A=se(),N=()=>A.invalidateQueries({queryKey:["integrations"]}),[d,g]=i.useState(null),[c,b]=i.useState(null),[k,u]=i.useState(null),v=P({mutationFn:t=>F.regenerateGitHubWebhook(t),onSuccess:({webhook:t},r)=>u({site:r,provider:"github",hook:t,fresh:!1}),onError:t=>T.error(M(t))}),C=P({mutationFn:({uid:t,provider:r})=>F.testTracker(t,r).then(L=>({...L,provider:r})),onSuccess:t=>{T[t.ok?"success":"error"](t.ok?`${D[t.provider]} can see ${t.target}`:t.detail??`${D[t.provider]} refused the token`),N()},onError:t=>T.error(M(t))}),y=P({mutationFn:({uid:t,provider:r})=>F.disconnectTracker(t,r),onSuccess:()=>{b(null),N()},onError:t=>T.error(M(t))}),w=j.data?.data??[],m=t=>w.filter(r=>r.provider===t),p=o.projects.filter(t=>!t.archived&&!t.locked),a=t=>p.filter(r=>!m(t).some(L=>L.site===r.uid)),s=l?o.limits.integrations?p.length===0?"site":null:"plan":null;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(ie,{title:"Integrations",sub:"Mirrors converge on the comment's status here; Slack only announces"}),s&&e.jsxs("div",{role:"note",className:"flex max-w-[1040px] flex-wrap items-center gap-x-4 gap-y-2 rounded-lg border border-border bg-muted/40 px-4 py-3 text-[13px]",children:[e.jsx("span",{className:"min-w-0 flex-1",children:s==="plan"?o.user.role==="owner"?"This studio's plan does not include integrations. A plan that does lets you connect each site to GitHub, Linear, Jira and Slack.":"This studio's plan does not include integrations. An owner can change the plan.":o.projects.length===0?"An integration connects one site to one repository, team, project or channel. Add a site first, then connect it here.":"An integration connects one site at a time, and every site here is archived or read-only. Restore one, or add a site, then connect it here."}),s==="plan"?o.user.role==="owner"&&e.jsx(x,{variant:"outline",size:"sm",render:e.jsx(U,{to:"/studio/plan"}),children:"See plans"}):e.jsx(x,{variant:"outline",size:"sm",render:e.jsx(U,{to:"/sites"}),children:"Go to Sites"})]}),["github","linear","jira","slack"].map(t=>{const r=m(t),L=a(t);return e.jsxs(ce,{title:D[t],description:t==="github"?"A comment becomes an issue in the site's repository, with the brief as its body; resolving it here closes the issue there, and closing it there resolves it here. A fine-grained token per site — no OAuth app to register.":t==="linear"?"A comment becomes an issue in the site's team, with the brief as its body; our status moves it between the team's workflow states by type, and a webhook from Linear moves it back. A personal API key per site — no OAuth app to register.":t==="jira"?"A comment becomes an issue in the site's Jira project, with the brief as its description; our status moves it through the workflow by status category, and a webhook from Jira moves it back. An API token with the account's email — what Atlassian gives a self-hoster.":"One message per comment in a channel, edited in place as the status moves — never a second message, never a reply. A bot token from an app you create in a click from our manifest; Slack sends nothing back.",children:[j.isPending&&e.jsx(ne,{rows:2}),j.isSuccess&&r.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(B,{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."})]}),r.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:r.map(n=>{const h=he[n.health]??{label:n.health,tone:"warn"};return e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border px-3 py-2.5 text-[13px]",children:[e.jsx("span",{className:"font-medium",children:n.siteName??n.site}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("code",{className:"font-mono text-[12.5px]",children:n.provider==="github"?`${n.owner}/${n.repo}`:n.provider==="linear"?`${n.teamKey} · ${n.teamName}`:n.provider==="jira"?`${n.projectKey} · ${n.projectName}`:`#${n.channelName} · ${n.teamName}`}),e.jsx(B,{variant:"outline",className:h.tone==="ok"?"border-ok text-ok":h.tone==="bad"?"border-destructive text-destructive":"",children:h.label}),e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[n.provider==="slack"?n.createOn==="thread.created"?"A message for every new comment":"Messages when you ask, from the brief":n.createOn==="thread.created"?"An issue for every new comment":"Issues when you ask, from the brief",n.provider==="github"&&n.labels.length?` · labels ${n.labels.join(", ")}`:"",n.provider!=="github"&&n.provider!=="slack"&&!n.hasWebhookSecret?` · no webhook secret yet, so ${D[n.provider]} cannot move comments here`:""," · ",le(n.updatedAt)]}),n.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:n.lastError}),l&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[n.provider==="github"?e.jsx(x,{variant:"ghost",size:"sm",loading:v.isPending,onClick:()=>v.mutate(n.site),children:"Webhook…"}):n.provider==="slack"?null:e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>u({site:n.site,provider:n.provider,hook:{url:`${location.origin}/api/v1/integrations/${n.provider}/inbound`},fresh:!1}),children:"Webhook…"}),e.jsx(x,{variant:"ghost",size:"sm",loading:C.isPending,onClick:()=>C.mutate({uid:n.site,provider:n.provider}),children:"Test"}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>b(n),children:"Disconnect"})]})]},`${n.provider}:${n.site}`)})}),l&&!s&&L.length>0&&e.jsx("div",{children:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>g(t),children:"Connect a site…"})})]},t)}),e.jsx(de,{owner:l,instanceOwner:f,operator:_(o),sites:o.projects}),e.jsx(ue,{open:d==="github",onOpenChange:t=>!t&&g(null),sites:a("github"),onDone:(t,r)=>{N(),r&&u({site:t,provider:"github",hook:r,fresh:!0})}}),e.jsx(xe,{open:d==="linear",onOpenChange:t=>!t&&g(null),sites:a("linear"),onDone:(t,r)=>{N(),u({site:t,provider:"linear",hook:r,fresh:!0})}}),e.jsx(ge,{open:d==="jira",onOpenChange:t=>!t&&g(null),sites:a("jira"),onDone:(t,r)=>{N(),u({site:t,provider:"jira",hook:r,fresh:!0})}}),e.jsx(fe,{open:d==="slack",onOpenChange:t=>!t&&g(null),sites:a("slack"),onDone:()=>void N()}),e.jsx(pe,{state:k,onClose:()=>u(null),siteName:t=>w.find(r=>r.site===t)?.siteName??"the site"}),e.jsx(ae,{open:c!==null,onOpenChange:t=>!t&&b(null),title:`Disconnect ${c?.siteName??"this site"} from ${c?D[c.provider]:"the tracker"}?`,description:c?.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:y.isPending,onConfirm:async()=>{c&&await y.mutateAsync({uid:c.site,provider:c.provider})}})]})}function ue({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(""),[v,C]=i.useState(!1),[y,w]=i.useState(""),m=P({mutationFn:s=>F.connectTracker(s,"github",{repository:d.trim(),token:c.trim(),labels:k,createOn:v?"thread.created":"manual"})}),p=A||f[0]?.uid||"",a=async s=>{s.preventDefault(),w("");try{const t=await m.mutateAsync(p);g(""),b(""),u(""),C(!1),l(!1),j(p,t.webhook&&"secret"in t.webhook?t.webhook:void 0),T.success("GitHub connected")}catch(t){w(t instanceof G?t.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void a(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to GitHub"}),e.jsxs(J,{children:["A fine-grained personal access token with ",e.jsx("b",{children:"Issues: read and write"})," on that one repository. It is checked against the repository before it is saved, and stored encrypted with this instance's secret key."]})]}),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(S,{htmlFor:"gh-site",children:"Site"}),e.jsx("select",{id:"gh-site",value:p,onChange:s=>N(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"gh-repo",children:"Repository"}),e.jsx(I,{id:"gh-repo",placeholder:"kilnwork/site",value:d,onChange:s=>g(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"gh-token",children:"Token"}),e.jsx(I,{id:"gh-token",type:"password",placeholder:"github_pat_…",value:c,onChange:s=>b(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"gh-labels",children:"Labels"}),e.jsx(I,{id:"gh-labels",placeholder:"review, bug",value:k,onChange:s=>u(s.target.value)}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Applied to every issue this makes. Optional."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:v,onChange:s=>C(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:'Off by default: a reviewer walking a site leaves twenty comments and half are "never mind". Make issues from the brief when you mean it.'})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:m.isPending,disabled:!d.trim()||!c.trim()||!p,children:m.isPending?"Checking…":"Connect"})]})]})})})}function pe({state:o,onClose:l,siteName:f}){const j=o&&"secret"in o.hook?o.hook.secret:null;return e.jsx(E,{open:o!==null,onOpenChange:A=>!A&&l(),children:e.jsxs(O,{children:[e.jsxs(R,{children:[e.jsx(W,{children:o?.fresh?"Connected — now the webhook":"Webhook for "+(o?f(o.site):"")}),e.jsx(J,{children:o?.provider==="linear"?"Issues moved in Linear move the comment here. In Linear › Settings › API › Webhooks, create one for the team with this URL and Issue events; then paste its signing secret when connecting or replacing the connection.":o?.provider==="jira"?"Issues moved in Jira move the comment here. In Jira › Settings › System › Webhooks, create one with this URL, the events Issue updated and Issue deleted, and a secret; then paste the same secret when connecting or replacing the connection.":`Issues closed or reopened on GitHub move the comment here. Add a webhook to the repository — Settings › Webhooks › Add webhook — with these values. The secret is shown this once${o?.fresh?"":", and the previous one has stopped working"}.`})]}),o&&e.jsxs("dl",{className:"m-0 grid grid-cols-[110px_1fr] gap-x-3 gap-y-2 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Payload URL"}),e.jsxs("dd",{className:"m-0 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[12px]",children:o.hook.url}),e.jsx(q,{text:o.hook.url,label:"Copy the payload URL"})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Content type"}),e.jsx("dd",{className:"m-0",children:e.jsx("code",{className:"font-mono text-[12px]",children:"application/json"})}),j&&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:j}),e.jsx(q,{text:j,label:"Copy the secret"})]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Events"}),e.jsx("dd",{className:"m-0",children:o.provider==="linear"?"Issues":o.provider==="jira"?"Issue: updated, deleted":"Let me select individual events → Issues"})]}),e.jsx(H,{children:e.jsx(x,{type:"button",onClick:l,children:"Done"})})]})})}function xe({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(""),[v,C]=i.useState(!1),[y,w]=i.useState(""),m=P({mutationFn:s=>F.connectTracker(s,"linear",{team:d.trim(),apiKey:c.trim(),...k.trim()?{webhookSecret:k.trim()}:{},createOn:v?"thread.created":"manual"})}),p=A||f[0]?.uid||"",a=async s=>{s.preventDefault(),w("");try{const t=await m.mutateAsync(p);g(""),b(""),u(""),C(!1),l(!1),j(p,t.webhook??{url:`${location.origin}/api/v1/integrations/linear/inbound`}),T.success("Linear connected")}catch(t){w(t instanceof G?t.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:s=>void a(s),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to Linear"}),e.jsx(J,{children:"A personal API key from Linear › Settings › API, belonging to a member of the team. It is checked against the team before it is saved, and stored encrypted with this instance's secret key."})]}),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(S,{htmlFor:"ln-site",children:"Site"}),e.jsx("select",{id:"ln-site",value:p,onChange:s=>N(s.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(s=>e.jsx("option",{value:s.uid,children:s.name},s.uid))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"ln-team",children:"Team key"}),e.jsx(I,{id:"ln-team",placeholder:"ENG",value:d,onChange:s=>g(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"The prefix of the team's issues, like the ENG in ENG-123."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"ln-key",children:"API key"}),e.jsx(I,{id:"ln-key",type:"password",placeholder:"lin_api_…",value:c,onChange:s=>b(s.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"ln-secret",children:"Webhook signing secret"}),e.jsx(I,{id:"ln-secret",type:"password",placeholder:"from Linear's webhook, optional",value:k,onChange:s=>u(s.target.value),autoComplete:"off"}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Lets Linear move comments here when issues move there. The URL to give Linear is shown after connecting."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:v,onChange:s=>C(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:m.isPending,disabled:!d.trim()||!c.trim()||!p,children:m.isPending?"Checking…":"Connect"})]})]})})})}function ge({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(""),[v,C]=i.useState(""),[y,w]=i.useState(""),[m,p]=i.useState(!1),[a,s]=i.useState(""),t=P({mutationFn:h=>F.connectTracker(h,"jira",{siteUrl:d.trim(),project:c.trim(),email:k.trim(),apiToken:v.trim(),...y.trim()?{webhookSecret:y.trim()}:{},createOn:m?"thread.created":"manual"})}),r=A||f[0]?.uid||"",L=async h=>{h.preventDefault(),s("");try{const $=await t.mutateAsync(r);b(""),C(""),w(""),p(!1),l(!1),j(r,$.webhook??{url:`${location.origin}/api/v1/integrations/jira/inbound`}),T.success("Jira connected")}catch($){s($ instanceof G?$.message:"Could not reach the server.")}},n=(h,$,Y,X,Z,ee="text",z)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:`jr-${h}`,children:$}),e.jsx(I,{id:`jr-${h}`,type:ee,placeholder:Z,value:Y,onChange:te=>X(te.target.value),autoComplete:"off"}),z&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:z})]});return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:h=>void L(h),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to Jira"}),e.jsx(J,{children:"An API token from id.atlassian.com › Security, with the email of the account it belongs to. It is checked against the project before it is saved, and stored encrypted with this instance's secret key."})]}),a&&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:a}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"jr-site",children:"Site"}),e.jsx("select",{id:"jr-site",value:r,onChange:h=>N(h.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(h=>e.jsx("option",{value:h.uid,children:h.name},h.uid))})]}),n("url","Jira site",d,g,"https://kilnwork.atlassian.net"),n("project","Project key",c,b,"KAN","text","The prefix of the project's issues, like the KAN in KAN-12."),n("email","Account email",k,u,"you@kilnwork.studio","email"),n("token","API token",v,C,"","password"),n("secret","Webhook secret",y,w,"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:m,onChange:h=>p(h.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Off by default. Make issues from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:t.isPending,disabled:!d.trim()||!c.trim()||!k.trim()||!v.trim()||!r,children:t.isPending?"Checking…":"Connect"})]})]})})})}function fe({open:o,onOpenChange:l,sites:f,onDone:j}){const[A,N]=i.useState(""),[d,g]=i.useState(""),[c,b]=i.useState(""),[k,u]=i.useState(!0),[v,C]=i.useState(""),y=V({queryKey:["integrations","slack","manifest"],queryFn:()=>F.slackManifest(),enabled:o,staleTime:1/0}),w=P({mutationFn:a=>F.connectTracker(a,"slack",{channel:d.trim(),token:c.trim(),createOn:k?"thread.created":"manual"})}),m=A||f[0]?.uid||"",p=async a=>{a.preventDefault(),C("");try{await w.mutateAsync(m),g(""),b(""),u(!0),l(!1),j(m),T.success("Slack connected")}catch(s){C(s instanceof G?s.message:"Could not reach the server.")}};return e.jsx(E,{open:o,onOpenChange:l,children:e.jsx(O,{children:e.jsxs("form",{onSubmit:a=>void p(a),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(W,{children:"Connect a site to Slack"}),e.jsx(J,{children:"Create the app in your workspace from our manifest — one click, the scopes are filled in — install it, and paste its Bot User OAuth Token. The token is checked against the channel before it is saved, and stored encrypted with this instance's secret key."})]}),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(S,{htmlFor:"sl-site",children:"Site"}),e.jsx("select",{id:"sl-site",value:m,onChange:a=>N(a.target.value),className:"h-8 rounded-md border border-input bg-background px-2.5 text-[13px]",children:f.map(a=>e.jsx("option",{value:a.uid,children:a.name},a.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(x,{type:"button",variant:"outline",size:"sm",disabled:!y.data,render:e.jsx("a",{href:y.data?.url??"#",target:"_blank",rel:"noreferrer"}),children:"Create app…"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(S,{htmlFor:"sl-token",children:"2. Bot User OAuth Token"}),e.jsx(I,{id:"sl-token",type:"password",placeholder:"xoxb-…",value:c,onChange:a=>b(a.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(S,{htmlFor:"sl-channel",children:"3. Channel"}),e.jsx(I,{id:"sl-channel",placeholder:"#reviews",value:d,onChange:a=>g(a.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:k,onChange:a=>u(a.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"A message for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"On by default: a channel is where people are told. Turn it off to post from the brief when you mean it."})]})]}),e.jsxs(H,{children:[e.jsx(x,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(x,{type:"submit",loading:w.isPending,disabled:!d.trim()||!c.trim()||!m,children:w.isPending?"Checking…":"Connect"})]})]})})})}const We=()=>K(Q().user.role,"settings")?e.jsx(me,{}):e.jsx(re,{title:"Integrations",children:e.jsxs("p",{className:"m-0",children:["Connecting a site to GitHub, Linear, Jira or Slack is done by an owner or an admin. Your own agent tokens are on"," ",e.jsx(U,{to:"/you",className:"text-brand hover:underline",children:"You"}),"."]})});export{We as component};
@@ -1,4 +1,4 @@
1
- import{c as Wt,a9 as Yt,e as xe,l as xn,r as l,j as n,h as Be,i as jt,aa as Vt,f as Fe,m as St,E as bn,ab as vn,ac as Gt,k as Ce,g as bt,q as Xt,ad as yn,B as He,ae as it,af as Kt,a2 as kt,I as Sn,D as wn,ag as Rn,ah as In,ai as jn,F as Tn,A as Lt}from"./index-Bjyhj6ZB.js";import{u as Ot}from"./useQuery-ClGE3W7i.js";import{u as Cn,a as An}from"./zod-CuCSHm2e.js";import{c as Mn,d as En,e as Pn,f as Nn,i as Vn,h as kn,u as Ln,a as On,j as Dn,p as Fn,r as Hn,g as Bn,A as Un,b as _n}from"./avatar-BH-hU7Qh.js";import{B as zn}from"./badge-BaViqDz3.js";import{C as Jt}from"./card-XWz6Setp.js";import{K as $n,L as qn,P as Wn,R as Yn,M as p,v as Qt,q as Gn,F as Xn,N as Kn,O as Jn,w as rt,Q as Qn,S as Zn,x as es,U as ts,V as ns,W as ss,Y as os,a as rs,Z as ls,B as is,_ as as,X as cs,C as us,E as ds,H as Dt,G as Ft,I as Ht,J as Bt}from"./dialog-CbKDGxpa.js";import{e as fs,f as ps,h as Zt,j as en,k as Ut,l as ms,m as gs,o as hs,c as Te,n as at,p as xs,q as bs,r as wt,a as vt,s as vs,w as ys,v as yt,L as _t,I as Ss}from"./label-C3zh-elW.js";import{T as tn,a as nn,b as ct,c as Ie,d as sn,e as je}from"./table-C5ApoOFC.js";import{C as ws}from"./ConfirmDialog-CKQ2LE2m.js";import{C as Rs}from"./CopyButton-Et1g5isE.js";import{C as on}from"./chevron-down-DPOV2aTJ.js";import{C as Is}from"./check-CsTK2ZlT.js";import{i as js}from"./isElementDisabled-CwHw_lZC.js";import{a as Tt,u as pt,i as Ts,b as Cs,t as Ct,C as As}from"./inertValue-B5n_awh1.js";import{s as Rt}from"./serializeValue-B8e3iXO-.js";import{u as Ms}from"./useValueChanged-CQWizfo3.js";import{C as Es,u as Ps,a as Ns}from"./CompositeList-BRoUQLZ7.js";import{A as Vs,P as ks,b as Ls}from"./parts-DoQ2TEp-.js";import{u as rn}from"./me-CtDXQ1_u.js";import{a as Os}from"./labels--UUyt9uB.js";import{c as Ds,d as Fs,e as Hs,f as Bs,g as Us}from"./studio-yUvPcZ3O.js";import{P as _s}from"./plus-cmPSXDaO.js";import"./useBaseQuery-0a7T0HmH.js";import"./useRender-tS6QvoXj.js";import"./copy-74WsRINA.js";/**
1
+ import{c as Wt,aa as Yt,e as xe,l as xn,r as l,j as n,h as Be,i as jt,ab as Vt,f as Fe,m as St,E as bn,ac as vn,ad as Gt,k as Ce,g as bt,q as Xt,ae as yn,B as He,af as it,ag as Kt,a2 as kt,I as Sn,D as wn,ah as Rn,ai as In,aj as jn,F as Tn,A as Lt}from"./index-jVSWkcSK.js";import{u as Ot}from"./useQuery-hBVmWzEl.js";import{u as Cn,a as An}from"./zod-8bzEaiHG.js";import{c as Mn,d as En,e as Pn,f as Nn,i as Vn,h as kn,u as Ln,a as On,j as Dn,p as Fn,r as Hn,g as Bn,A as Un,b as _n}from"./avatar-3CJf9_jk.js";import{B as zn}from"./badge-ixRisPgI.js";import{C as Jt}from"./card-VzmwyX4K.js";import{K as $n,L as qn,P as Wn,R as Yn,M as p,v as Qt,q as Gn,F as Xn,N as Kn,O as Jn,w as rt,Q as Qn,S as Zn,x as es,U as ts,V as ns,W as ss,Y as os,a as rs,Z as ls,B as is,_ as as,X as cs,C as us,E as ds,H as Dt,G as Ft,I as Ht,J as Bt}from"./dialog-CNe7vaQT.js";import{e as fs,f as ps,h as Zt,j as en,k as Ut,l as ms,m as gs,o as hs,c as Te,n as at,p as xs,q as bs,r as wt,a as vt,s as vs,w as ys,v as yt,L as _t,I as Ss}from"./label-CzNjVuJl.js";import{T as tn,a as nn,b as ct,c as Ie,d as sn,e as je}from"./table-CJ9qkwn1.js";import{C as ws}from"./ConfirmDialog-CMhBnMda.js";import{C as Rs}from"./CopyButton-BeKLr-HL.js";import{C as on}from"./chevron-down-3JSK4KJk.js";import{C as Is}from"./check-oVlGjqlI.js";import{i as js}from"./isElementDisabled-CwHw_lZC.js";import{a as Tt,u as pt,i as Ts,b as Cs,t as Ct,C as As}from"./inertValue-D5-xyRX6.js";import{s as Rt}from"./serializeValue-B8e3iXO-.js";import{u as Ms}from"./useValueChanged-ERXEloZc.js";import{C as Es,u as Ps,a as Ns}from"./CompositeList-B4njw0mu.js";import{A as Vs,P as ks,b as Ls}from"./parts-OimeyxOU.js";import{u as rn}from"./me-HGkftAh1.js";import{a as Os}from"./labels--UUyt9uB.js";import{c as Ds,d as Fs,e as Hs,f as Bs,g as Us}from"./studio-BKmWJ117.js";import{P as _s}from"./plus-JDUOLC5V.js";import"./useBaseQuery-CDoR88Fa.js";import"./useRender-mrNZQnpJ.js";import"./copy-C9jwRSea.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{j as e,aj as Y,r as d,p as M,d as A,A as $,S as B,h as m,B as P}from"./index-Bjyhj6ZB.js";import{u as _}from"./useQuery-ClGE3W7i.js";import{b as j}from"./InstanceRows-BNvGpofx.js";import{A as D,P as K}from"./parts-DoQ2TEp-.js";import{u as y}from"./me-CtDXQ1_u.js";import{C as U}from"./check-CsTK2ZlT.js";import"./useBaseQuery-0a7T0HmH.js";import"./dialog-CbKDGxpa.js";import"./label-C3zh-elW.js";import"./inertValue-B5n_awh1.js";import"./ConfirmDialog-CKQ2LE2m.js";import"./copy-74WsRINA.js";import"./labels--UUyt9uB.js";import"./card-XWz6Setp.js";function L(){const s=y(),{said:r}=Y.useSearch(),[a,o]=d.useState(r),[c]=d.useState(()=>Date.now()),u=M(),p=A();d.useEffect(()=>{r&&u({to:"/studio/plan",search:{},replace:!0})},[r,u]);const w=_($.setupState()),i=w.data?.billingUrl??null,v=_({queryKey:["plan-state",i],enabled:!!i,refetchInterval:()=>a&&Date.now()-c<3e4?3e3:!1,queryFn:async()=>{const t=await fetch(`${i.replace(/\/+$/,"")}/state`,{credentials:"include",headers:{accept:"application/json"}});if(!t.ok)throw new Error(String(t.status));return await t.json()}}),n=v.data,b=d.useRef(null),f=n?.current?.name??null;d.useEffect(()=>{f&&(b.current===null?b.current=f:f!==b.current&&(o(void 0),p.invalidateQueries({queryKey:$.me().queryKey})))},[f,p]);const[h,R]=d.useState(!1),q=!!n?.plans.some(t=>t.yearly),S=n?.plans.find(t=>t.current);return e.jsxs("div",{className:"flex flex-col gap-8 p-7",children:[e.jsx(K,{title:"Plan & billing",sub:s.org.name}),a&&e.jsx("p",{role:"status",className:"m-0 max-w-[1040px] rounded-md border border-border bg-card px-3 py-2 text-[13px]",children:a}),w.isSuccess&&!i?e.jsx("p",{className:"m-0 text-muted-foreground",children:"This instance has no plans: everything is included."}):v.isError?e.jsx("p",{className:"m-0 text-muted-foreground",children:"The plans could not be loaded. Reload to try again."}):n?e.jsxs("div",{className:"flex max-w-[1040px] flex-col",children:[e.jsxs("section",{"aria-label":"Your plan",className:"grid grid-cols-1 gap-5 rounded-xl border border-border bg-card px-6 py-5 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"m-0 text-[11.5px] font-medium uppercase tracking-wider text-muted-foreground",children:"Your plan"}),e.jsxs("p",{className:"m-0 mt-1 text-[28px] font-bold leading-tight",children:[n.current?.name??S?.name,e.jsx("span",{className:"ml-2 text-[15px] font-normal text-muted-foreground",children:n.current?.price??S?.price})]}),n.current?.period&&e.jsx("p",{className:"m-0 mt-1 text-[13px] text-ink-soft",children:n.current.period})]}),n.manage&&e.jsx("div",{children:e.jsx(g,{base:i,form:n.manage})}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Q,{})}),n.current?.warning&&e.jsx("p",{role:"status",className:"m-0 rounded-md bg-warn-soft px-3.5 py-2.5 text-[13px] sm:col-span-2",children:n.current.warning}),n.nudge&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-lg bg-brand-soft px-3.5 py-2.5 sm:col-span-2",children:[e.jsx("p",{className:"m-0 min-w-[220px] flex-1 text-[13px]",children:n.nudge.text}),e.jsx(g,{base:i,form:n.nudge.action})]})]}),e.jsxs("div",{className:"mb-4 mt-9 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h2",{id:"compare",className:"m-0 text-[17px] font-semibold",children:"Compare plans"}),q&&e.jsx("div",{role:"radiogroup","aria-label":"Billing period",className:"inline-flex rounded-full border border-border bg-card p-0.5",children:[!1,!0].map(t=>e.jsx("button",{type:"button",role:"radio","aria-checked":h===t,onClick:()=>R(t),className:m("rounded-full px-3.5 py-1 text-[13px]",h===t?"bg-foreground text-background":"text-ink-soft"),children:t?e.jsxs(e.Fragment,{children:["Yearly ",e.jsx("span",{className:m("font-medium",h?"opacity-80":"text-brand"),children:"2 months free"})]}):"Monthly"},String(t)))})]}),e.jsx("div",{"aria-labelledby":"compare",className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:n.plans.map(t=>{const x=h&&t.yearly?t.yearly:null,k=x?x.actions:t.actions,E=t.relation==="downgrade";return e.jsxs("div",{className:m("relative flex min-w-0 flex-col gap-4 rounded-xl border bg-card p-5",t.recommended?"border-brand shadow-[0_0_0_1px_var(--color-brand),0_10px_30px_rgb(61_97_217/.12)]":"border-border"),children:[(t.current||t.recommended)&&e.jsx("span",{className:m("absolute -top-2.5 left-5 rounded-full px-2.5 py-px text-[11.5px] font-semibold",t.current?"bg-foreground text-background":"bg-brand text-white"),children:t.current?"Your plan":"Recommended"}),e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 text-[16px] font-semibold",children:t.name}),t.pitch&&e.jsx("p",{className:"m-0 mt-0.5 text-[13px] text-muted-foreground",children:t.pitch})]}),e.jsxs("p",{className:"m-0 text-[34px] font-bold leading-none tracking-tight",children:[x?.amount??t.amount??t.price,(x?.unit??t.unit)&&e.jsx("span",{className:"ml-1 text-[13px] font-normal tracking-normal text-muted-foreground",children:x?.unit??t.unit})]}),e.jsx("ul",{className:"m-0 flex flex-1 list-none flex-col gap-2 p-0",children:t.features.map(l=>e.jsxs("li",{className:m("flex gap-2 text-[13.5px]",t.added?.includes(l)&&"font-semibold"),children:[e.jsx(U,{className:"mt-0.5 size-4 shrink-0 text-ok","aria-hidden":!0}),l]},l))}),t.current?e.jsx(P,{type:"button",variant:"outline",disabled:!0,className:"w-full",children:"Current plan"}):E?k.map(l=>e.jsx(O,{base:i,form:l,warning:t.warning??null},l.label)):k.map(l=>e.jsx(g,{base:i,form:{...l,primary:!!t.recommended||l.primary},wide:!0},l.label))]},t.id)})}),e.jsxs("p",{className:"m-0 mt-5 text-center text-[13px] text-muted-foreground",children:[n.footer?e.jsxs("b",{className:"font-semibold text-foreground",children:[n.footer.split(". ")[0],"."]}):n.intro," ",n.footer?.split(". ").slice(1).join(". ")]}),n.notes.length>0&&e.jsx("p",{className:"m-0 mt-1.5 text-center text-[12px] text-muted-foreground",children:n.notes.join(" ")})]}):e.jsx(B,{})]})}function O({base:s,form:r,warning:a}){const[o,c]=d.useState(!1);return a&&o?e.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-warn-soft px-3 py-2.5 text-[12.5px]",children:[e.jsx("p",{className:"m-0",children:a}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{base:s,form:{...r,label:"Downgrade anyway",primary:!1}}),e.jsx("button",{type:"button",className:"text-[13px] text-muted-foreground underline underline-offset-2",onClick:()=>c(!1),children:"Keep my plan"})]})]}):a?e.jsx("button",{type:"button",className:"self-center text-[13px] text-muted-foreground underline underline-offset-[3px]",onClick:()=>c(!0),children:r.label}):e.jsxs("form",{method:"post",action:new URL(r.action,s).toString(),className:"m-0 self-center",children:[Object.entries(r.fields).map(([u,p])=>e.jsx("input",{type:"hidden",name:u,value:p},u)),e.jsx("button",{type:"submit",className:"text-[13px] text-muted-foreground underline underline-offset-[3px]",children:r.label})]})}function g({base:s,form:r,wide:a}){return e.jsxs("form",{method:"post",action:new URL(r.action,s).toString(),className:"m-0",children:[Object.entries(r.fields).map(([o,c])=>e.jsx("input",{type:"hidden",name:o,value:c},o)),e.jsx(P,{type:"submit",variant:r.primary?"default":"outline",className:a?"w-full":void 0,children:r.label})]})}function Q(){const{limits:s}=y(),r=[{label:"Sites",text:C(s.projects.used,s.projects.limit,"site","sites"),share:N(s.projects.used,s.projects.limit)},{label:"Members",text:C(s.members.used,s.members.limit,"member","members"),share:N(s.members.used,s.members.limit)},{label:"Screenshots",text:s.screenshots?s.storage.limit===null?`${j(s.storage.used)} used`:`${j(s.storage.used)} of ${j(s.storage.limit)}`:"Not on this plan",share:s.screenshots?N(s.storage.used,s.storage.limit):null}];return e.jsx("dl",{className:"m-0 grid grid-cols-1 gap-5 border-t border-border pt-4 sm:grid-cols-3",children:r.map(a=>e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("dt",{className:"text-[12px] text-muted-foreground",children:a.label}),e.jsx("dd",{className:"m-0 text-[13px]",children:a.text}),a.share!==null&&e.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:e.jsx("div",{className:m("h-full rounded-full",a.share>=1?"bg-destructive":"bg-brand"),style:{width:`${Math.min(100,Math.round(a.share*100))}%`}})})]},a.label))})}const N=(s,r)=>r===null||r===0?null:s/r,C=(s,r,a,o)=>r===null?`${s} ${s===1?a:o}, unlimited`:`${s} of ${r} ${r===1?a:o}`,re=()=>y().user.role==="owner"?e.jsx(L,{}):e.jsx(D,{title:"Plan & billing"});export{re as component};
1
+ import{j as e,ak as Y,r as d,p as M,d as A,A as $,S as B,h as m,B as P}from"./index-jVSWkcSK.js";import{u as _}from"./useQuery-hBVmWzEl.js";import{b as j}from"./InstanceRows-g_itJcJn.js";import{A as D,P as K}from"./parts-OimeyxOU.js";import{u as y}from"./me-HGkftAh1.js";import{C as U}from"./check-oVlGjqlI.js";import"./useBaseQuery-CDoR88Fa.js";import"./dialog-CNe7vaQT.js";import"./label-CzNjVuJl.js";import"./inertValue-D5-xyRX6.js";import"./ConfirmDialog-CMhBnMda.js";import"./copy-C9jwRSea.js";import"./labels--UUyt9uB.js";import"./card-VzmwyX4K.js";function L(){const s=y(),{said:r}=Y.useSearch(),[a,o]=d.useState(r),[c]=d.useState(()=>Date.now()),u=M(),p=A();d.useEffect(()=>{r&&u({to:"/studio/plan",search:{},replace:!0})},[r,u]);const w=_($.setupState()),i=w.data?.billingUrl??null,v=_({queryKey:["plan-state",i],enabled:!!i,refetchInterval:()=>a&&Date.now()-c<3e4?3e3:!1,queryFn:async()=>{const t=await fetch(`${i.replace(/\/+$/,"")}/state`,{credentials:"include",headers:{accept:"application/json"}});if(!t.ok)throw new Error(String(t.status));return await t.json()}}),n=v.data,b=d.useRef(null),f=n?.current?.name??null;d.useEffect(()=>{f&&(b.current===null?b.current=f:f!==b.current&&(o(void 0),p.invalidateQueries({queryKey:$.me().queryKey})))},[f,p]);const[h,R]=d.useState(!1),q=!!n?.plans.some(t=>t.yearly),k=n?.plans.find(t=>t.current);return e.jsxs("div",{className:"flex flex-col gap-8 p-7",children:[e.jsx(K,{title:"Plan & billing",sub:s.org.name}),a&&e.jsx("p",{role:"status",className:"m-0 max-w-[1040px] rounded-md border border-border bg-card px-3 py-2 text-[13px]",children:a}),w.isSuccess&&!i?e.jsx("p",{className:"m-0 text-muted-foreground",children:"This instance has no plans: everything is included."}):v.isError?e.jsx("p",{className:"m-0 text-muted-foreground",children:"The plans could not be loaded. Reload to try again."}):n?e.jsxs("div",{className:"flex max-w-[1040px] flex-col",children:[e.jsxs("section",{"aria-label":"Your plan",className:"grid grid-cols-1 gap-5 rounded-xl border border-border bg-card px-6 py-5 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"m-0 text-[11.5px] font-medium uppercase tracking-wider text-muted-foreground",children:"Your plan"}),e.jsxs("p",{className:"m-0 mt-1 text-[28px] font-bold leading-tight",children:[n.current?.name??k?.name,e.jsx("span",{className:"ml-2 text-[15px] font-normal text-muted-foreground",children:n.current?.price??k?.price})]}),n.current?.period&&e.jsx("p",{className:"m-0 mt-1 text-[13px] text-ink-soft",children:n.current.period})]}),n.manage&&e.jsx("div",{children:e.jsx(g,{base:i,form:n.manage})}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Q,{})}),n.current?.warning&&e.jsx("p",{role:"status",className:"m-0 rounded-md bg-warn-soft px-3.5 py-2.5 text-[13px] sm:col-span-2",children:n.current.warning}),n.nudge&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-lg bg-brand-soft px-3.5 py-2.5 sm:col-span-2",children:[e.jsx("p",{className:"m-0 min-w-[220px] flex-1 text-[13px]",children:n.nudge.text}),e.jsx(g,{base:i,form:n.nudge.action})]})]}),e.jsxs("div",{className:"mb-4 mt-9 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h2",{id:"compare",className:"m-0 text-[17px] font-semibold",children:"Compare plans"}),q&&e.jsx("div",{role:"radiogroup","aria-label":"Billing period",className:"inline-flex rounded-full border border-border bg-card p-0.5",children:[!1,!0].map(t=>e.jsx("button",{type:"button",role:"radio","aria-checked":h===t,onClick:()=>R(t),className:m("rounded-full px-3.5 py-1 text-[13px]",h===t?"bg-foreground text-background":"text-ink-soft"),children:t?e.jsxs(e.Fragment,{children:["Yearly ",e.jsx("span",{className:m("font-medium",h?"opacity-80":"text-brand"),children:"2 months free"})]}):"Monthly"},String(t)))})]}),e.jsx("div",{"aria-labelledby":"compare",className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:n.plans.map(t=>{const x=h&&t.yearly?t.yearly:null,S=x?x.actions:t.actions,E=t.relation==="downgrade";return e.jsxs("div",{className:m("relative flex min-w-0 flex-col gap-4 rounded-xl border bg-card p-5",t.recommended?"border-brand shadow-[0_0_0_1px_var(--color-brand),0_10px_30px_rgb(61_97_217/.12)]":"border-border"),children:[(t.current||t.recommended)&&e.jsx("span",{className:m("absolute -top-2.5 left-5 rounded-full px-2.5 py-px text-[11.5px] font-semibold",t.current?"bg-foreground text-background":"bg-brand text-white"),children:t.current?"Your plan":"Recommended"}),e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 text-[16px] font-semibold",children:t.name}),t.pitch&&e.jsx("p",{className:"m-0 mt-0.5 text-[13px] text-muted-foreground",children:t.pitch})]}),e.jsxs("p",{className:"m-0 text-[34px] font-bold leading-none tracking-tight",children:[x?.amount??t.amount??t.price,(x?.unit??t.unit)&&e.jsx("span",{className:"ml-1 text-[13px] font-normal tracking-normal text-muted-foreground",children:x?.unit??t.unit})]}),e.jsx("ul",{className:"m-0 flex flex-1 list-none flex-col gap-2 p-0",children:t.features.map(l=>e.jsxs("li",{className:m("flex gap-2 text-[13.5px]",t.added?.includes(l)&&"font-semibold"),children:[e.jsx(U,{className:"mt-0.5 size-4 shrink-0 text-ok","aria-hidden":!0}),l]},l))}),t.current?e.jsx(P,{type:"button",variant:"outline",disabled:!0,className:"w-full",children:"Current plan"}):E?S.map(l=>e.jsx(O,{base:i,form:l,warning:t.warning??null},l.label)):S.map(l=>e.jsx(g,{base:i,form:{...l,primary:!!t.recommended||l.primary},wide:!0},l.label))]},t.id)})}),e.jsxs("p",{className:"m-0 mt-5 text-center text-[13px] text-muted-foreground",children:[n.footer?e.jsxs("b",{className:"font-semibold text-foreground",children:[n.footer.split(". ")[0],"."]}):n.intro," ",n.footer?.split(". ").slice(1).join(". ")]}),n.notes.length>0&&e.jsx("p",{className:"m-0 mt-1.5 text-center text-[12px] text-muted-foreground",children:n.notes.join(" ")})]}):e.jsx(B,{})]})}function O({base:s,form:r,warning:a}){const[o,c]=d.useState(!1);return a&&o?e.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-warn-soft px-3 py-2.5 text-[12.5px]",children:[e.jsx("p",{className:"m-0",children:a}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{base:s,form:{...r,label:"Downgrade anyway",primary:!1}}),e.jsx("button",{type:"button",className:"text-[13px] text-muted-foreground underline underline-offset-2",onClick:()=>c(!1),children:"Keep my plan"})]})]}):a?e.jsx("button",{type:"button",className:"self-center text-[13px] text-muted-foreground underline underline-offset-[3px]",onClick:()=>c(!0),children:r.label}):e.jsxs("form",{method:"post",action:new URL(r.action,s).toString(),className:"m-0 self-center",children:[Object.entries(r.fields).map(([u,p])=>e.jsx("input",{type:"hidden",name:u,value:p},u)),e.jsx("button",{type:"submit",className:"text-[13px] text-muted-foreground underline underline-offset-[3px]",children:r.label})]})}function g({base:s,form:r,wide:a}){return e.jsxs("form",{method:"post",action:new URL(r.action,s).toString(),className:"m-0",children:[Object.entries(r.fields).map(([o,c])=>e.jsx("input",{type:"hidden",name:o,value:c},o)),e.jsx(P,{type:"submit",variant:r.primary?"default":"outline",className:a?"w-full":void 0,children:r.label})]})}function Q(){const{limits:s}=y(),r=[{label:"Sites",text:C(s.projects.used,s.projects.limit,"site","sites"),share:N(s.projects.used,s.projects.limit)},{label:"Members",text:C(s.members.used,s.members.limit,"member","members"),share:N(s.members.used,s.members.limit)},{label:"Screenshots",text:s.screenshots?s.storage.limit===null?`${j(s.storage.used)} used`:`${j(s.storage.used)} of ${j(s.storage.limit)}`:"Not on this plan",share:s.screenshots?N(s.storage.used,s.storage.limit):null}];return e.jsx("dl",{className:"m-0 grid grid-cols-1 gap-5 border-t border-border pt-4 sm:grid-cols-3",children:r.map(a=>e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("dt",{className:"text-[12px] text-muted-foreground",children:a.label}),e.jsx("dd",{className:"m-0 text-[13px]",children:a.text}),a.share!==null&&e.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:e.jsx("div",{className:m("h-full rounded-full",a.share>=1?"bg-destructive":"bg-brand"),style:{width:`${Math.min(100,Math.round(a.share*100))}%`}})})]},a.label))})}const N=(s,r)=>r===null||r===0?null:s/r,C=(s,r,a,o)=>r===null?`${s} ${s===1?a:o}, unlimited`:`${s} of ${r} ${r===1?a:o}`,re=()=>y().user.role==="owner"?e.jsx(L,{}):e.jsx(D,{title:"Plan & billing"});export{re as component};
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-Bjyhj6ZB.js";/**
1
+ import{c as t}from"./index-jVSWkcSK.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,i as ae,ab as re,e as se,ac as ie,E as ne,k as j,j as f,al as oe,h as de}from"./index-Bjyhj6ZB.js";import{q as ce,f as le,h as ue,p as fe,u as pe,j as he,k as be,l as ge,c as me,n as ve}from"./label-C3zh-elW.js";import{N as ke,O as xe}from"./dialog-CbKDGxpa.js";import{u as we}from"./useAriaLabelledBy-CvsQoCZu.js";import{u as ye}from"./useValueChanged-CQWizfo3.js";const M=i.createContext(void 0);function Ce(){const r=i.useContext(M);if(r===void 0)throw new Error(ae(63));return r}const D={...ce,checked(r){return r?{"data-checked":""}:{"data-unchecked":""}}},Re=i.forwardRef(function(s,o){const{checked:k,className:F,defaultChecked:x,"aria-labelledby":m,form:p,id:L,inputRef:N,name:w,nativeButton:h=!1,onCheckedChange:T,readOnly:d=!1,required:b=!1,disabled:V=!1,render:ze,uncheckedValue:y,value:C,style:Ee,...q}=s,{clearErrors:H}=le(),{state:R,setTouched:O,setDirty:A,validityData:W,setFilled:v,setFocused:P,validationMode:J,disabled:U,name:Y,validation:c}=ue(),{labelId:_}=fe(),t=U||V,l=Y??w,n=i.useRef(null),G=re(n,N,c.inputRef),g=i.useRef(null),z=pe(),E=he({id:L,implicit:!1,controlRef:g}),B=h?void 0:E,[a,K]=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),A(a!==W.initialValue),v(a),c.change(a)});const{getButtonProps:Q,buttonRef:X}=ie({disabled:t,native:h}),Z=we(m,_,n,!h,B),$={id:h?E:z,role:"switch","aria-checked":a,"aria-readonly":d||void 0,"aria-required":b||void 0,"aria-labelledby":Z,onFocus(){t||P(!0)},onBlur(){const e=n.current;!e||t||(O(!0),P(!1),J==="onBlur"&&c.commit(e.checked))},onClick(e){if(d||t)return;e.preventDefault();const u=n.current;u&&oe(u,e)}},ee={...c.getValidationProps(t),checked:a,disabled:t,form:p,id:B,name:l,required:b,style:l?ke:xe,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:G,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(d){e.preventDefault();return}const u=e.currentTarget.checked,S=me(ve,e.nativeEvent);T?.(u,S),!S.isCanceled&&K(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=j("span",s,{state:I,ref:[o,g,X],props:[$,q,Q,e=>c.getValidationProps(t,e)],stateAttributesMapping:D});return f.jsxs(M.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 j("span",s,{state:p,ref:o,stateAttributesMapping:D,props:m})});function De({className:r,size:s="default",...o}){return f.jsx(Re,{"data-slot":"switch","data-size":s,className:de("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",r),...o,children:f.jsx(Pe,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}export{De as S};
1
+ import{r as i,i as ae,ac as re,e as se,ad as ie,E as ne,k as j,j as f,am as oe,h as de}from"./index-jVSWkcSK.js";import{q as ce,f as le,h as ue,p as fe,u as pe,j as he,k as be,l as me,c as ge,n as ve}from"./label-CzNjVuJl.js";import{N as ke,O as xe}from"./dialog-CNe7vaQT.js";import{u as we}from"./useAriaLabelledBy-B4z1WZse.js";import{u as ye}from"./useValueChanged-ERXEloZc.js";const M=i.createContext(void 0);function Ce(){const r=i.useContext(M);if(r===void 0)throw new Error(ae(63));return r}const D={...ce,checked(r){return r?{"data-checked":""}:{"data-unchecked":""}}},Re=i.forwardRef(function(s,o){const{checked:k,className:F,defaultChecked:x,"aria-labelledby":g,form:p,id:L,inputRef:N,name:w,nativeButton:h=!1,onCheckedChange:T,readOnly:d=!1,required:b=!1,disabled:V=!1,render:ze,uncheckedValue:y,value:C,style:Ee,...q}=s,{clearErrors:H}=le(),{state:R,setTouched:O,setDirty:A,validityData:W,setFilled:v,setFocused:P,validationMode:J,disabled:U,name:Y,validation:c}=ue(),{labelId:_}=fe(),t=U||V,l=Y??w,n=i.useRef(null),G=re(n,N,c.inputRef),m=i.useRef(null),z=pe(),E=he({id:L,implicit:!1,controlRef:m}),B=h?void 0:E,[a,K]=be({controlled:k,default:!!x,name:"Switch",state:"checked"});me(m,z,a,void 0,!t,w),se(()=>{n.current&&v(n.current.checked)},[v]),ye(a,()=>{H(l),A(a!==W.initialValue),v(a),c.change(a)});const{getButtonProps:Q,buttonRef:X}=ie({disabled:t,native:h}),Z=we(g,_,n,!h,B),$={id:h?E:z,role:"switch","aria-checked":a,"aria-readonly":d||void 0,"aria-required":b||void 0,"aria-labelledby":Z,onFocus(){t||P(!0)},onBlur(){const e=n.current;!e||t||(O(!0),P(!1),J==="onBlur"&&c.commit(e.checked))},onClick(e){if(d||t)return;e.preventDefault();const u=n.current;u&&oe(u,e)}},ee={...c.getValidationProps(t),checked:a,disabled:t,form:p,id:B,name:l,required:b,style:l?ke:xe,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:G,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(d){e.preventDefault();return}const u=e.currentTarget.checked,S=ge(ve,e.nativeEvent);T?.(u,S),!S.isCanceled&&K(u)},onClick(e){e.stopPropagation()},onFocus(){m.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=j("span",s,{state:I,ref:[o,m,X],props:[$,q,Q,e=>c.getValidationProps(t,e)],stateAttributesMapping:D});return f.jsxs(M.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,...g}=s,p=Ce();return j("span",s,{state:p,ref:o,stateAttributesMapping:D,props:g})});function De({className:r,size:s="default",...o}){return f.jsx(Re,{"data-slot":"switch","data-size":s,className:de("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",r),...o,children:f.jsx(Pe,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}export{De as S};
@@ -1 +1 @@
1
- import{j as t,h as l}from"./index-Bjyhj6ZB.js";function o({className:a,...e}){return t.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm",a),...e})})}function r({className:a,...e}){return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b",a),...e})}function d({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function n({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...e})}function b({className:a,...e}){return t.jsx("th",{"data-slot":"table-head",className:l("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",a),...e})}function c({className:a,...e}){return t.jsx("td",{"data-slot":"table-cell",className:l("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...e})}export{o as T,r as a,n as b,b as c,d,c as e};
1
+ import{j as t,h as l}from"./index-jVSWkcSK.js";function o({className:a,...e}){return t.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:t.jsx("table",{"data-slot":"table",className:l("w-full caption-bottom text-sm",a),...e})})}function r({className:a,...e}){return t.jsx("thead",{"data-slot":"table-header",className:l("[&_tr]:border-b",a),...e})}function d({className:a,...e}){return t.jsx("tbody",{"data-slot":"table-body",className:l("[&_tr:last-child]:border-0",a),...e})}function n({className:a,...e}){return t.jsx("tr",{"data-slot":"table-row",className:l("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...e})}function b({className:a,...e}){return t.jsx("th",{"data-slot":"table-head",className:l("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",a),...e})}function c({className:a,...e}){return t.jsx("td",{"data-slot":"table-cell",className:l("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...e})}export{o as T,r as a,n as b,b as c,d,c as e};
@@ -1 +1 @@
1
- import{r as u,e as l}from"./index-Bjyhj6ZB.js";import{u as c}from"./label-C3zh-elW.js";function y(e,n,t,r=!0,i){const[a,d]=u.useState(),f=c(i?`${i}-label`:void 0),o=e??n??a;return l(()=>{const s=e||n||!r?void 0:L(t.current,f);a!==s&&d(s)}),o}function L(e,n){const t=b(e);if(t)return!t.id&&n&&(t.id=n),t.id||void 0}function b(e){if(!e)return;const n=e.parentElement;if(n&&n.tagName==="LABEL")return n;const t=e.id;if(t){const i=e.nextElementSibling;if(i&&i.htmlFor===t)return i}const r=e.labels;return r&&r[0]}export{y as u};
1
+ import{r as u,e as l}from"./index-jVSWkcSK.js";import{u as c}from"./label-CzNjVuJl.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{bb as N,bc as h,bd as O,be as U,bf as k,bg as B,bh as A,bi as y,bj as H,bk as V,bl as M,bm as x,r as p,bn as F,d as j}from"./index-Bjyhj6ZB.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#m())}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.#S(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#S();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||H.isFocused())&&this.#h()},this.#r))}#m(){this.#R(),this.#y(this.#v())}#S(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const m=n.fetchStatus==="fetching",S=b==="pending",g=b==="error",T=S&&m,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:S,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:m,isRefetching:m&&!S,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();x.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#m()}};function W(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return W(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const _=p.createContext(!1),z=()=>p.useContext(_);_.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const G=p.createContext(K()),J=()=>p.useContext(G),X=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?F(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},Y=t=>{p.useEffect(()=>{t.clearReset()},[t])},Z=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||F(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,$=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=z(),r=J(),c=j(),a=c.defaultQueryOptions(t),u=c.getQueryCache().get(a.queryHash),l=t.subscribed!==!1;a._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(a),X(a,r,u),Y(r);const[n]=p.useState(()=>new e(c,a)),d=n.getOptimisticResult(a),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?n.subscribe(x.batchCalls(R)):U;return n.updateResult(),v},[n,o]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setOptions(a)},[a,n]),q(a,d))throw tt(a,n,r);if(Z({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw d.error;return a.notifyOnChangeProps?d:n.trackResult(d)}export{st as Q,it as d,rt as u};
1
+ import{bc as N,bd as h,be as O,bf as U,bg as k,bh as B,bi as A,bj as y,bk as H,bl as V,bm as M,bn as x,r as p,bo as F,d as j}from"./index-jVSWkcSK.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#m())}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.#S(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#S();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||H.isFocused())&&this.#h()},this.#r))}#m(){this.#R(),this.#y(this.#v())}#S(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const m=n.fetchStatus==="fetching",S=b==="pending",g=b==="error",T=S&&m,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:S,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:m,isRefetching:m&&!S,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();x.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#m()}};function W(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return W(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const _=p.createContext(!1),z=()=>p.useContext(_);_.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const G=p.createContext(K()),J=()=>p.useContext(G),X=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?F(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},Y=t=>{p.useEffect(()=>{t.clearReset()},[t])},Z=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||F(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,$=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=z(),r=J(),c=j(),a=c.defaultQueryOptions(t),u=c.getQueryCache().get(a.queryHash),l=t.subscribed!==!1;a._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(a),X(a,r,u),Y(r);const[n]=p.useState(()=>new e(c,a)),d=n.getOptimisticResult(a),o=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=o?n.subscribe(x.batchCalls(R)):U;return n.updateResult(),v},[n,o]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setOptions(a)},[a,n]),q(a,d))throw tt(a,n,r);if(Z({result:d,errorResetBoundary:r,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw d.error;return a.notifyOnChangeProps?d:n.trackResult(d)}export{st as Q,it as d,rt as u};
@@ -1 +1 @@
1
- import{aH as d,r as f,ab as h}from"./index-Bjyhj6ZB.js";import{a as p}from"./CompositeList-BRoUQLZ7.js";function b(i={}){const{highlightItemOnHover:n,highlightedIndex:r,onHighlightedIndexChange:a}=d(),{ref:c,index:t}=p(i),o=r===t,s=f.useRef(null),m=h(c,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){a(t)},onMouseMove(){const e=s.current;if(!n||!e)return;const u=e.hasAttribute("disabled")||e.ariaDisabled==="true";!o&&!u&&e.focus()}},compositeRef:m,index:t}}export{b as u};
1
+ import{aI as d,r as f,ac as h}from"./index-jVSWkcSK.js";import{a as p}from"./CompositeList-B4njw0mu.js";function I(i={}){const{highlightItemOnHover:n,highlightedIndex:r,onHighlightedIndexChange:a}=d(),{ref:c,index:t}=p(i),o=r===t,s=f.useRef(null),m=h(c,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){a(t)},onMouseMove(){const e=s.current;if(!n||!e)return;const u=e.hasAttribute("disabled")||e.ariaDisabled==="true";!o&&!u&&e.focus()}},compositeRef:m,index:t}}export{I as u};
@@ -0,0 +1 @@
1
+ import{u as r,Q as u}from"./useBaseQuery-CDoR88Fa.js";function a(e,s){return r(e,u)}export{a as u};
@@ -0,0 +1 @@
1
+ import{k as n}from"./index-jVSWkcSK.js";function u(e){return n(e.defaultTagName??"div",e,e)}export{u};
@@ -1 +1 @@
1
- import{r as s,f as c,e as n}from"./index-Bjyhj6ZB.js";function u(e,r){const t=s.useRef(e),a=c(r);n(()=>{t.current!==e&&a(t.current),t.current=e},[e,a])}export{u};
1
+ import{r as s,f as c,e as n}from"./index-jVSWkcSK.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-Bjyhj6ZB.js";/**
1
+ import{c as e}from"./index-jVSWkcSK.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as z,V as E,p as F,d as B,r as l,j as e,G as L,h as k,B as n,s as w,A as x,C as S}from"./index-Bjyhj6ZB.js";import{C as f}from"./card-XWz6Setp.js";import{L as C,I as q}from"./label-C3zh-elW.js";import{I as P}from"./InstallTag-Dgm3LPul.js";import{C as R}from"./check-CsTK2ZlT.js";import{A}from"./arrow-left-BnaT-Fbe.js";import"./CompositeList-BRoUQLZ7.js";import"./isElementDisabled-CwHw_lZC.js";import"./inertValue-B5n_awh1.js";import"./useCompositeItem-CsYzexWF.js";import"./copy-74WsRINA.js";/**
1
+ import{c as z,V as E,p as F,d as B,r as l,j as e,G as L,h as k,B as n,s as w,A as x,C as S}from"./index-jVSWkcSK.js";import{C as f}from"./card-VzmwyX4K.js";import{L as C,I as q}from"./label-CzNjVuJl.js";import{I as P}from"./InstallTag-FQEroW67.js";import{C as R}from"./check-oVlGjqlI.js";import{A}from"./arrow-left-CkkevAm7.js";import"./CompositeList-B4njw0mu.js";import"./isElementDisabled-CwHw_lZC.js";import"./inertValue-D5-xyRX6.js";import"./useCompositeItem-MHMarTaJ.js";import"./copy-C9jwRSea.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{W as h,r as x,j as e,B as a,G as N,s as y,X as b}from"./index-Bjyhj6ZB.js";const S=`${b}session`;function E(){const{project:o,origin:t,env:g}=h.useSearch(),{me:n}=h.useRouteContext(),[l,d]=x.useState(""),[f,u]=x.useState(!1),i=n.projects.find(s=>s.uid===o),m=typeof window<"u"?window.opener:null,r=()=>window.close();if(!o||!t||!m)return e.jsx(c,{title:"Nothing to sign in to",children:e.jsxs("p",{className:"m-0 text-muted-foreground",children:["This window is opened by the comment box on a site you are reviewing. Open it from there — choose"," ",e.jsx("em",{children:"Studio member? Sign in"})," — and it will ask you here."]})});if(!i)return e.jsxs(c,{title:"Not one of this studio's sites",children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["You are signed in to ",n.org.name,", and that site is not one of its sites. If it belongs to another studio you are in, switch to it in the dashboard and try again."]}),e.jsx(a,{variant:"outline",onClick:r,children:"Close"})]});const p=async()=>{d(""),u(!0);try{const s=await y.memberSession(i.uid,t,g);if(s.origin!==t)throw new Error("The address changed while signing in. Try again from the site.");const{origin:j,...w}=s;m.postMessage({type:S,session:w},j),r()}catch(s){d(s instanceof Error?s.message:"Could not reach the server."),u(!1)}};return e.jsxs(c,{title:`Sign in to ${i.name}`,children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["Comment on ",e.jsx("span",{className:"font-medium text-foreground",children:t})," as"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.user.name||n.user.email}),", from ",n.org.name,". Your comments there and your replies here will be one author."]}),l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"lg",className:"flex-1",loading:f,onClick:()=>void p(),children:"Continue"}),e.jsx(a,{size:"lg",variant:"outline",onClick:r,children:"Cancel"})]})]})}function c({title:o,children:t}){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold tracking-tight",children:o}),t]})})}export{E as component};
1
+ import{W as h,r as x,j as e,B as a,G as N,s as y,X as b}from"./index-jVSWkcSK.js";const S=`${b}session`;function E(){const{project:o,origin:t,env:g}=h.useSearch(),{me:n}=h.useRouteContext(),[l,d]=x.useState(""),[f,u]=x.useState(!1),i=n.projects.find(s=>s.uid===o),m=typeof window<"u"?window.opener:null,r=()=>window.close();if(!o||!t||!m)return e.jsx(c,{title:"Nothing to sign in to",children:e.jsxs("p",{className:"m-0 text-muted-foreground",children:["This window is opened by the comment box on a site you are reviewing. Open it from there — choose"," ",e.jsx("em",{children:"Studio member? Sign in"})," — and it will ask you here."]})});if(!i)return e.jsxs(c,{title:"Not one of this studio's sites",children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["You are signed in to ",n.org.name,", and that site is not one of its sites. If it belongs to another studio you are in, switch to it in the dashboard and try again."]}),e.jsx(a,{variant:"outline",onClick:r,children:"Close"})]});const p=async()=>{d(""),u(!0);try{const s=await y.memberSession(i.uid,t,g);if(s.origin!==t)throw new Error("The address changed while signing in. Try again from the site.");const{origin:j,...w}=s;m.postMessage({type:S,session:w},j),r()}catch(s){d(s instanceof Error?s.message:"Could not reach the server."),u(!1)}};return e.jsxs(c,{title:`Sign in to ${i.name}`,children:[e.jsxs("p",{className:"m-0 text-muted-foreground",children:["Comment on ",e.jsx("span",{className:"font-medium text-foreground",children:t})," as"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.user.name||n.user.email}),", from ",n.org.name,". Your comments there and your replies here will be one author."]}),l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"lg",className:"flex-1",loading:f,onClick:()=>void p(),children:"Continue"}),e.jsx(a,{size:"lg",variant:"outline",onClick:r,children:"Cancel"})]})]})}function c({title:o,children:t}){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"m-0 text-[22px] font-semibold tracking-tight",children:o}),t]})})}export{E as component};
@@ -1 +1 @@
1
- import{r,x as b,j as e,h as y,y as N,B as j,q as f,t as S,a2 as C}from"./index-Bjyhj6ZB.js";import{L as c,I as d}from"./label-C3zh-elW.js";import{P,a as h}from"./parts-DoQ2TEp-.js";import{S as A}from"./SaveState-DT_ZtqN6.js";import{M as k}from"./McpTokens-Dopxwnwy.js";import{u as M}from"./me-CtDXQ1_u.js";import{u as F,a as E}from"./studio-yUvPcZ3O.js";import{M as T,S as D,a as z}from"./sun-BpsiEWtf.js";import"./card-XWz6Setp.js";import"./labels--UUyt9uB.js";import"./useQuery-ClGE3W7i.js";import"./useBaseQuery-0a7T0HmH.js";import"./badge-BaViqDz3.js";import"./useRender-tS6QvoXj.js";import"./dialog-CbKDGxpa.js";import"./inertValue-B5n_awh1.js";import"./switch-ByUmW5H2.js";import"./useAriaLabelledBy-CvsQoCZu.js";import"./useValueChanged-CQWizfo3.js";import"./ConfirmDialog-CKQ2LE2m.js";import"./check-CsTK2ZlT.js";import"./copy-74WsRINA.js";import"./CopyButton-Et1g5isE.js";function H({items:s}){const[a,o]=r.useState(b);return e.jsx("div",{className:"flex gap-2",role:"radiogroup","aria-label":"Theme",children:s.map(t=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===t.value,onClick:()=>{N(t.value),o(t.value)},className:y("inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[12.5px] font-medium text-ink-soft",a===t.value&&"border-line-strong bg-muted text-foreground"),children:[t.icon,t.label]},t.value))})}function ne(){const s=M(),a=F(),[o,t]=r.useState(s.user.name),[u,i]=r.useState(null);r.useEffect(()=>t(s.user.name),[s.user.name]);const m=o.trim()!==s.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(P,{title:"You",sub:"Your own account on this studio",actions:e.jsx(A,{saving:a.isPending,savedAt:u})}),e.jsxs(h,{title:"Profile",description:"How you appear on replies and in the members list.",children:[e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:l=>{l.preventDefault(),m&&a.mutate(o.trim(),{onSuccess:()=>i(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"your-name",value:o,onChange:l=>t(l.target.value)}),m&&e.jsx(j,{type:"submit",variant:"outline",children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"your-email",children:"Email"}),e.jsx(d,{id:"your-email",value:s.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(L,{})}),!f(s.user.role,"settings")&&f(s.user.role,"review")&&e.jsx(k,{owner:!0,mine:!0,instanceOwner:!1,operator:S(s),sites:s.projects}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(H,{items:[{value:"system",label:"System",icon:e.jsx(T,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(D,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(z,{className:"size-3.5"})}]})})]})}function L(){const s=E(),[a,o]=r.useState(""),[t,u]=r.useState(""),[i,m]=r.useState(""),[l,g]=r.useState(""),[v,p]=r.useState(!1),x=a.length>0&&t.length>=12&&t===i;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async n=>{if(n.preventDefault(),!(!x||s.isPending)){g("");try{await s.mutateAsync({current:a,next:t}),o(""),u(""),m(""),p(!0)}catch(w){g(C(w))}}},children:[l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(d,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:n=>{o(n.target.value),p(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(d,{id:"pw-next",type:"password",autoComplete:"new-password",value:t,onChange:n=>{u(n.target.value),p(!1)}}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters. No composition rules — length is what matters."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-again",children:"Confirm new password"}),e.jsx(d,{id:"pw-again",type:"password",autoComplete:"new-password",value:i,onChange:n=>{m(n.target.value),p(!1)}}),i.length>0&&t!==i&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Those do not match yet."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{type:"submit",loading:s.isPending,disabled:!x,children:s.isPending?"Changing…":v&&!x?"Changed":"Change password"})})]})}export{ne as component};
1
+ import{r,x as b,j as e,h as y,y as N,B as j,q as f,t as S,a2 as C}from"./index-jVSWkcSK.js";import{L as c,I as d}from"./label-CzNjVuJl.js";import{P,a as h}from"./parts-OimeyxOU.js";import{S as A}from"./SaveState-BHP4ix-R.js";import{M as k}from"./McpTokens-Bnomst3Z.js";import{u as M}from"./me-HGkftAh1.js";import{u as F,a as E}from"./studio-BKmWJ117.js";import{M as T,S as D,a as z}from"./sun-i-qGe4pR.js";import"./card-VzmwyX4K.js";import"./labels--UUyt9uB.js";import"./useQuery-hBVmWzEl.js";import"./useBaseQuery-CDoR88Fa.js";import"./badge-ixRisPgI.js";import"./useRender-mrNZQnpJ.js";import"./dialog-CNe7vaQT.js";import"./inertValue-D5-xyRX6.js";import"./switch-BCvzokd6.js";import"./useAriaLabelledBy-B4z1WZse.js";import"./useValueChanged-ERXEloZc.js";import"./ConfirmDialog-CMhBnMda.js";import"./check-oVlGjqlI.js";import"./copy-C9jwRSea.js";import"./CopyButton-BeKLr-HL.js";function H({items:s}){const[a,o]=r.useState(b);return e.jsx("div",{className:"flex gap-2",role:"radiogroup","aria-label":"Theme",children:s.map(t=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===t.value,onClick:()=>{N(t.value),o(t.value)},className:y("inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[12.5px] font-medium text-ink-soft",a===t.value&&"border-line-strong bg-muted text-foreground"),children:[t.icon,t.label]},t.value))})}function ne(){const s=M(),a=F(),[o,t]=r.useState(s.user.name),[u,i]=r.useState(null);r.useEffect(()=>t(s.user.name),[s.user.name]);const m=o.trim()!==s.user.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(P,{title:"You",sub:"Your own account on this studio",actions:e.jsx(A,{saving:a.isPending,savedAt:u})}),e.jsxs(h,{title:"Profile",description:"How you appear on replies and in the members list.",children:[e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:l=>{l.preventDefault(),m&&a.mutate(o.trim(),{onSuccess:()=>i(Date.now())})},children:[e.jsx(c,{htmlFor:"your-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"your-name",value:o,onChange:l=>t(l.target.value)}),m&&e.jsx(j,{type:"submit",variant:"outline",children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"your-email",children:"Email"}),e.jsx(d,{id:"your-email",value:s.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(L,{})}),!f(s.user.role,"settings")&&f(s.user.role,"review")&&e.jsx(k,{owner:!0,mine:!0,instanceOwner:!1,operator:S(s),sites:s.projects}),e.jsx(h,{title:"Appearance",description:"Also in your menu at the bottom of the sidebar.",children:e.jsx(H,{items:[{value:"system",label:"System",icon:e.jsx(T,{className:"size-3.5"})},{value:"light",label:"Light",icon:e.jsx(D,{className:"size-3.5"})},{value:"dark",label:"Dark",icon:e.jsx(z,{className:"size-3.5"})}]})})]})}function L(){const s=E(),[a,o]=r.useState(""),[t,u]=r.useState(""),[i,m]=r.useState(""),[l,g]=r.useState(""),[v,p]=r.useState(!1),x=a.length>0&&t.length>=12&&t===i;return e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:async n=>{if(n.preventDefault(),!(!x||s.isPending)){g("");try{await s.mutateAsync({current:a,next:t}),o(""),u(""),m(""),p(!0)}catch(w){g(C(w))}}},children:[l&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:l}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-current",children:"Current password"}),e.jsx(d,{id:"pw-current",type:"password",autoComplete:"current-password",value:a,onChange:n=>{o(n.target.value),p(!1)}})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-next",children:"New password"}),e.jsx(d,{id:"pw-next",type:"password",autoComplete:"new-password",value:t,onChange:n=>{u(n.target.value),p(!1)}}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"At least 12 characters. No composition rules — length is what matters."})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(c,{htmlFor:"pw-again",children:"Confirm new password"}),e.jsx(d,{id:"pw-again",type:"password",autoComplete:"new-password",value:i,onChange:n=>{m(n.target.value),p(!1)}}),i.length>0&&t!==i&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Those do not match yet."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{type:"submit",loading:s.isPending,disabled:!x,children:s.isPending?"Changing…":v&&!x?"Changed":"Change password"})})]})}export{ne as component};
@@ -1 +1 @@
1
- import{aX as I}from"./index-Bjyhj6ZB.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"},Q={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},X={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dr="root",je=["__proto__","constructor","prototype"],Xr=/^\w*$/;var ne=e=>Xr.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 Jr=I.createContext(null);Jr.displayName="HookFormControlContext";var Qr=(e,s,r,i=!0)=>{const l={};for(const u in e)Object.defineProperty(l,u,{get:()=>{const o=u;return s._proxyFormState[o]!==Q.all&&(s._proxyFormState[o]=!i||Q.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 J(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))?!J(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();J(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===Q.onSubmit,isOnBlur:e===Q.onBlur,isOnChange:e===Q.onChange,isOnAll:e===Q.all,isOnTouch:e===Q.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=X.maxLength,K=X.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:X.required,message:x,ref:ee,...se(X.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,X.max,X.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:X.pattern,message:x,ref:o,...se(X.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(X.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)):J(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||Q.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:Q.onSubmit,reValidateMode:Q.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===Q.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 _=J(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?!J(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||X.validate})}else M(n)||!n?Ee(pe,{message:n||"",type:X.validate}):Qe(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),!J(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=J(_,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(!J(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())||J(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))}},Xe=(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,Xe,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)),Je=(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)}},Qe=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,Xe,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&&!J(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:Je,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:Qe,unregister:Le,setError:Ee,setFocus:jr,getFieldState:Je};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&&!J(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(()=>Qr(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{aY as I}from"./index-jVSWkcSK.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)},Ye=e=>e.type==="radio",Oe=e=>e instanceof RegExp,ze=(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=Ye(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=ze.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",z=o.type=="week";M(R.value)&&w&&(D=we?q(w)>q(R.value):z?w>R.value:K>new Date(R.value)),M(W.value)&&w&&(x=we?q(w)<q(W.value):z?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=>Ye(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:Ye(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:z(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)&&(z()||(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=!_||z(),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),Y=A.validatingFields||A.isValidating||F.validatingFields||F.isValidating;L&&Y&&S([g.name],!0);const Z=await hr(h,c.disabled,u,w,s.shouldUseNativeValidation&&!a,V);if(L&&Y&&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},z=(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:z(t,g)}));else{const L=Array.isArray(g)&&!g.length||B(g),Y=!V&&!d;!y||y._f||p(g)||L?Re(t,g,n,f,d,Y):Ge(t,g,n,f,d,Y)}if(!V&&!d){const L=Ue(t,c),Y=f?u:C(u);if(b.state.next({...L&&r,name:o.mount||L?t:void 0,values:Y}),!h)for(const Z of ft(c.array,t))b.state.next({name:Z,values:Y})}},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,Y=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),Yr=!B(ge)||Z;if(!V&&b.state.next({name:n,type:t.type,...T?{values:C(u)}:{}}),Y)return(!L||!r.isValid)&&(A.isValid||F.isValid)&&(s.mode==="onBlur"?V&&P():V||P()),Yr&&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 zr=br(r.errors,i,n),or=br(ve,i,zr.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:z()}}),!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?z(t,C(v(l,t))):z()),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,_),Y=v(y,_);V&&!O(L)?k(y,_,L):!V&&!O(Y)&&he(_,Y)}}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?z():!!(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:z,_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]=ze(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]=ze(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};
@@ -21,8 +21,8 @@
21
21
  </script>
22
22
  <link rel="icon" href="/mark.svg" type="image/svg+xml" />
23
23
  <title>Snagset</title>
24
- <script type="module" crossorigin src="/assets/index-Bjyhj6ZB.js"></script>
25
- <link rel="stylesheet" crossorigin href="/assets/index-vKxPrBs3.css">
24
+ <script type="module" crossorigin src="/assets/index-jVSWkcSK.js"></script>
25
+ <link rel="stylesheet" crossorigin href="/assets/index-DVRHlt-r.css">
26
26
  </head>
27
27
  <body>
28
28
  <div id="app"></div>
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.1.51",
3
- "cv": "0.1.51+2d8838"
2
+ "version": "0.1.52",
3
+ "cv": "0.1.52+e90504"
4
4
  }