@snagset/server 0.1.63 → 0.1.65

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 (90) hide show
  1. package/package.json +1 -1
  2. package/static/dashboard/assets/{CompositeItem-D7THTrjT.js → CompositeItem-DUU2dBBI.js} +1 -1
  3. package/static/dashboard/assets/{CompositeList-CeLQBvjs.js → CompositeList-nzDbuttJ.js} +1 -1
  4. package/static/dashboard/assets/{ConfirmDialog-Ca4nB0gY.js → ConfirmDialog-CHFBH7e-.js} +1 -1
  5. package/static/dashboard/assets/{CopyButton-baCHDy5v.js → CopyButton-U3SFd-HD.js} +1 -1
  6. package/static/dashboard/assets/{FieldItemContext-DU1NZyaa.js → FieldItemContext-Ctu8Sx36.js} +1 -1
  7. package/static/dashboard/assets/{InstallTag-COg-5qzp.js → InstallTag-Dv3gaL4O.js} +1 -1
  8. package/static/dashboard/assets/InstanceRows-DPIpELtc.js +1 -0
  9. package/static/dashboard/assets/McpTokens-yimU884S.js +1 -0
  10. package/static/dashboard/assets/{Picker-BGAVkehH.js → Picker-CCAp0603.js} +2 -2
  11. package/static/dashboard/assets/{SaveState-v3jQ1_XP.js → SaveState-zj94ZTUn.js} +1 -1
  12. package/static/dashboard/assets/_-C2HgkYw_.js +1 -0
  13. package/static/dashboard/assets/{_app-Bhuo6WVN.js → _app-Boi8G11t.js} +2 -2
  14. package/static/dashboard/assets/{_app-BynrR78o.js → _app-CPD7sbIv.js} +1 -1
  15. package/static/dashboard/assets/_app-Cy8QntP-.js +1 -0
  16. package/static/dashboard/assets/activity-BXgHGBG-.js +1 -0
  17. package/static/dashboard/assets/{arrow-left-DuT_fV3X.js → arrow-left-BWxLUUtR.js} +1 -1
  18. package/static/dashboard/assets/{avatar-f4OTBv_u.js → avatar-C272UWe3.js} +1 -1
  19. package/static/dashboard/assets/{badge-1x3gEOj5.js → badge-CYPTl0cy.js} +1 -1
  20. package/static/dashboard/assets/{check-DnU_QrcS.js → check-2F6z9BBy.js} +1 -1
  21. package/static/dashboard/assets/{chevron-down-CBtD71Qj.js → chevron-down-Co3oKci1.js} +1 -1
  22. package/static/dashboard/assets/{chevron-right-C5AqW-nF.js → chevron-right-DMXTfy_h.js} +1 -1
  23. package/static/dashboard/assets/{copy-C0sdzqxc.js → copy-B-mCACcx.js} +1 -1
  24. package/static/dashboard/assets/{createBaseUIEventDetails-4JZNAnON.js → createBaseUIEventDetails-67bayC1B.js} +1 -1
  25. package/static/dashboard/assets/{dialog-CIAPdljP.js → dialog-l22OkYXh.js} +2 -2
  26. package/static/dashboard/assets/{dropdown-menu-CCSKS7Vl.js → dropdown-menu-CIJhCtDQ.js} +2 -2
  27. package/static/dashboard/assets/{forgot-Chc103l7.js → forgot-ykPZ1Kdg.js} +1 -1
  28. package/static/dashboard/assets/{getPseudoElementBounds-B9DhGoL1.js → getPseudoElementBounds-D9YqITSR.js} +1 -1
  29. package/static/dashboard/assets/{image-off-Cq8_byd8.js → image-off-BkVnePLU.js} +1 -1
  30. package/static/dashboard/assets/index-BC1mWQy8.js +172 -0
  31. package/static/dashboard/assets/{inertValue-9Ojj3uf7.js → inertValue-Dy4HJtbg.js} +1 -1
  32. package/static/dashboard/assets/invite-DDvCZ3v_.js +1 -0
  33. package/static/dashboard/assets/{label-qbrDzIaf.js → label-Des6lF0o.js} +1 -1
  34. package/static/dashboard/assets/{layout-grid-CFzUr6JC.js → layout-grid-ojTM11RH.js} +1 -1
  35. package/static/dashboard/assets/me-DWKKjc2l.js +1 -0
  36. package/static/dashboard/assets/{plus-EpJ2hlJL.js → plus-CqHIH0K8.js} +1 -1
  37. package/static/dashboard/assets/{reset-BDWJBuHV.js → reset-GkTsanrN.js} +1 -1
  38. package/static/dashboard/assets/{s._site-D81hm-l9.js → s._site-DuFqROtI.js} +1 -1
  39. package/static/dashboard/assets/{s._site.comments-DQ3i0QSi.js → s._site.comments-DwPDdi_u.js} +8 -8
  40. package/static/dashboard/assets/s._site.reviewers-BdujL59q.js +1 -0
  41. package/static/dashboard/assets/s._site.settings-0uXBXAn-.js +1 -0
  42. package/static/dashboard/assets/{setup-D5LmXbcW.js → setup-CGKTYRhS.js} +1 -1
  43. package/static/dashboard/assets/{sign-in-Bl09bVJL.js → sign-in-BFx4q3Vl.js} +1 -1
  44. package/static/dashboard/assets/{sign-up-B1XMq41Y.js → sign-up-BeS3OqBr.js} +1 -1
  45. package/static/dashboard/assets/sites-DWQtdLHK.js +1 -0
  46. package/static/dashboard/assets/{studio-DRa8t2VU.js → studio-DxClsYRz.js} +1 -1
  47. package/static/dashboard/assets/studio-gXJp7MI3.js +1 -0
  48. package/static/dashboard/assets/studio.index-BKeRxtvS.js +1 -0
  49. package/static/dashboard/assets/{studio.integrations-CtUgczTe.js → studio.integrations-BDKRHU8R.js} +2 -2
  50. package/static/dashboard/assets/studio.members-Dnw8MvSM.js +6 -0
  51. package/static/dashboard/assets/studio.plan-CV9lR0OF.js +1 -0
  52. package/static/dashboard/assets/{sun-BSvDJaml.js → sun-BDbnQON-.js} +1 -1
  53. package/static/dashboard/assets/{switch-BXyi-44q.js → switch-BQZZEckg.js} +1 -1
  54. package/static/dashboard/assets/{table-D6MQ3yct.js → table-B41i9RfM.js} +1 -1
  55. package/static/dashboard/assets/{useAriaLabelledBy-DWswad3y.js → useAriaLabelledBy-hDZ_Qzgg.js} +1 -1
  56. package/static/dashboard/assets/{useBaseQuery-B90MJ7He.js → useBaseQuery-Di_lHTAg.js} +1 -1
  57. package/static/dashboard/assets/{useCompositeItem-DGreOIU-.js → useCompositeItem-R43gS2Zb.js} +1 -1
  58. package/static/dashboard/assets/useQuery-B1QbR4lk.js +1 -0
  59. package/static/dashboard/assets/useRender-bF5mRtl9.js +1 -0
  60. package/static/dashboard/assets/useScrollLock-DV1FkBvY.js +1 -0
  61. package/static/dashboard/assets/{useValueChanged-DQAqpQ0y.js → useValueChanged-CxAXjLUw.js} +1 -1
  62. package/static/dashboard/assets/{users-DuEepqIK.js → users-jxEArjZq.js} +1 -1
  63. package/static/dashboard/assets/{welcome-DwOgRPZN.js → welcome-D7cMtm0u.js} +3 -3
  64. package/static/dashboard/assets/widget-signin-BtBII7zp.js +1 -0
  65. package/static/dashboard/assets/you-DcgRgPxz.js +1 -0
  66. package/static/dashboard/assets/{zod-DF2MI65D.js → zod-DxcG0x06.js} +1 -1
  67. package/static/dashboard/index.html +1 -1
  68. package/static/widget/build.json +2 -2
  69. package/static/widget/snag.js +1 -1
  70. package/static/widget/snag.runtime.js +1 -1
  71. package/static/dashboard/assets/InstanceRows-BmiUo_5h.js +0 -1
  72. package/static/dashboard/assets/McpTokens-CvESgbHd.js +0 -1
  73. package/static/dashboard/assets/activity-BfXjGG77.js +0 -1
  74. package/static/dashboard/assets/card-C1bRD7dG.js +0 -1
  75. package/static/dashboard/assets/index-DIf_7lV5.js +0 -162
  76. package/static/dashboard/assets/invite-DSynOAj4.js +0 -1
  77. package/static/dashboard/assets/me-cdROrEZn.js +0 -1
  78. package/static/dashboard/assets/parts-DnonT_sc.js +0 -6
  79. package/static/dashboard/assets/s._site.reviewers-BS-Kr36t.js +0 -1
  80. package/static/dashboard/assets/s._site.settings-CUhYg-Ye.js +0 -1
  81. package/static/dashboard/assets/sites-umID164r.js +0 -1
  82. package/static/dashboard/assets/studio-DR-PqCVa.js +0 -1
  83. package/static/dashboard/assets/studio.index-CzwRs37G.js +0 -1
  84. package/static/dashboard/assets/studio.members-B4I6YBkd.js +0 -6
  85. package/static/dashboard/assets/studio.plan-Z50-owr0.js +0 -1
  86. package/static/dashboard/assets/useQuery-CYC6DPXm.js +0 -1
  87. package/static/dashboard/assets/useRender-DP2er8v5.js +0 -1
  88. package/static/dashboard/assets/useScrollLock-DSPnO43v.js +0 -1
  89. package/static/dashboard/assets/widget-signin-C-VdT35d.js +0 -1
  90. package/static/dashboard/assets/you-NBZzam76.js +0 -1
@@ -0,0 +1 @@
1
+ import{q as w,aa as y,r as p,j as e,a4 as N,B as m,_ as A,ab as k,L as S,a7 as $,p as _,d as C,v as D,H as E,I as F,J as g}from"./index-BC1mWQy8.js";import{u as I,a as L}from"./zod-DxcG0x06.js";import{i as P,j as T,l as z,k as q,m as H,n as R}from"./dialog-l22OkYXh.js";import{L as f,I as j}from"./label-Des6lF0o.js";import{u as B}from"./me-DWKKjc2l.js";import{P as v}from"./plus-CqHIH0K8.js";import{L as K}from"./layout-grid-ojTM11RH.js";import{I as Q}from"./image-off-BkVnePLU.js";import"./useScrollLock-DV1FkBvY.js";import"./inertValue-Dy4HJtbg.js";import"./createBaseUIEventDetails-67bayC1B.js";import"./useBaseQuery-Di_lHTAg.js";function ae(){const s=B(),i=w(s.user.role,"settings"),{add:d}=y.useSearch(),[x,n]=p.useState(!!d&&i);p.useEffect(()=>{d&&i&&n(!0)},[d,i]);const a=s.projects.filter(r=>!r.archived),l=s.projects.filter(r=>r.archived),h=a.reduce((r,o)=>r+o.unresolved,0),t=s.limits.projects.limit,c=t!==null&&a.length>=t,u=t!==null&&a.length>t;return e.jsxs("div",{className:"p-7",children:[e.jsx(N,{title:"Sites",sub:a.length?`${a.length}${t!==null?` of ${t}`:""} site${a.length===1&&t===null?"":"s"} · ${h} open`:t!==null?`0 of ${t} sites`:void 0,actions:i?e.jsxs(m,{onClick:()=>n(!0),disabled:c,title:c?`This studio's plan allows ${t} sites.`:void 0,children:[e.jsx(v,{}),"Add a site"]}):void 0}),u&&e.jsxs("div",{role:"status",className:"mb-5 max-w-[1100px] rounded-md border border-border bg-warn-soft px-4 py-3 text-[13px]",children:["This studio has ",a.length," sites and its plan includes ",t,". The newest ",a.length-t," ",a.length-t===1?"is":"are"," ","read-only: comments can be read, nothing new comes in."," ",i?"Archive a site you have finished with, or move to a plan with more.":"An owner or an admin can archive a site or change the plan."]}),a.length===0?e.jsx(A,{className:"max-w-[1100px]",children:e.jsx(k,{icon:e.jsx(K,{className:"size-5"}),title:"No sites yet",action:i?e.jsxs(m,{onClick:()=>n(!0),children:[e.jsx(v,{}),"Add a site"]}):void 0,children:i?"A site is one client website. Add it, paste the tag, and comments start arriving here.":"A site is one client website. An owner or an admin adds it, and its comments appear here."})}):e.jsx("div",{className:"grid max-w-[1100px] grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:a.map(r=>e.jsx(b,{p:r},r.uid))}),l.length>0&&e.jsxs("section",{className:"mt-10 max-w-[1100px]","aria-labelledby":"archived-sites",children:[e.jsx("h2",{id:"archived-sites",className:"m-0 mb-1 text-[14px] font-semibold",children:"Archived"}),e.jsx("p",{className:"m-0 mb-4 text-[12.5px] text-muted-foreground",children:"Finished or put away. Every comment is kept and can be read; nothing new comes in, and they do not count toward the plan."}),e.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:l.map(r=>e.jsx(b,{p:r},r.uid))})]}),e.jsx(G,{open:x,onOpenChange:n})]})}function b({p:s}){const i=s.archived?"Archived":s.locked?"Read-only":s.status==="paused"?"Paused":null;return e.jsxs(S,{to:"/s/$site/comments",params:{site:s.uid},className:"block overflow-hidden rounded-lg border border-border bg-card text-foreground transition-shadow hover:shadow-[0_1px_2px_rgb(24_23_22/.06),0_8px_24px_rgb(24_23_22/.08)]",children:[e.jsx("div",{className:`flex h-[150px] items-center justify-center border-b border-border bg-background${s.archived?" opacity-70 grayscale":""}`,children:s.previewUrl?e.jsx("img",{src:s.previewUrl,alt:"",className:"size-full object-cover object-top"}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-[12px] text-muted-foreground",children:[e.jsx("span",{className:"flex size-8 items-center justify-center rounded-md bg-muted",children:e.jsx(Q,{className:"size-4"})}),"No screenshot yet"]})}),e.jsxs("div",{className:"px-3.5 pb-3.5 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[14px] font-semibold",children:[e.jsx("span",{className:"truncate",children:s.name}),i&&e.jsx("span",{className:"rounded-sm bg-muted px-1.5 py-px text-[10.5px] font-medium uppercase tracking-wide text-muted-foreground",children:i})]}),s.domain&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[12px] text-muted-foreground",children:s.domain}),e.jsx("div",{className:"mt-2 text-[12.5px] text-ink-soft",children:s.threads===0?"Nothing filed yet":`${s.unresolved} open of ${s.threads}${s.lastActivityAt?` · ${$(s.lastActivityAt)}`:""}`})]})]})}const U=F({name:g().trim().min(1,"A name"),domain:g().trim().min(1,"Its domain")});function G({open:s,onOpenChange:i}){const d=_(),x=C(),[n,a]=p.useState(""),{register:l,handleSubmit:h,formState:t,reset:c}=I({resolver:L(U)}),u=h(async r=>{a("");try{const o=await D.createProject(r.name,"",r.domain);await x.invalidateQueries({queryKey:["me"]}),c(),i(!1),d({to:"/s/$site/comments",params:{site:o.uid}})}catch(o){a(o instanceof E?o.message:"Could not add the site.")}});return e.jsx(P,{open:s,onOpenChange:i,children:e.jsx(T,{children:e.jsxs("form",{onSubmit:u,className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(z,{children:[e.jsx(q,{children:"Add a site"}),e.jsx(H,{children:"One client website. The tag it needs is shown right after."})]}),n&&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:n}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(f,{htmlFor:"site-name",children:"Name"}),e.jsx(j,{id:"site-name",placeholder:"Kilnwork","aria-invalid":!!t.errors.name,...l("name")})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(f,{htmlFor:"site-domain",children:"Domain"}),e.jsx(j,{id:"site-domain",placeholder:"kilnwork.studio","aria-invalid":!!t.errors.domain,...l("domain")}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:"Every subdomain, scheme and port of it may run the widget — staging, previews, and localhost while you build. Exact addresses elsewhere can be added in Settings."})]}),e.jsxs(R,{children:[e.jsx(m,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(m,{type:"submit",loading:t.isSubmitting,children:t.isSubmitting?"Adding…":"Add site"})]})]})})})}export{ae as component};
@@ -1 +1 @@
1
- import{d as o,A as s,a5 as u,s as i,a6 as y,a2 as c}from"./index-DIf_7lV5.js";function Q(){const e=o(),t=s.me().queryKey;return u({mutationFn:a=>i.renameOrg(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{...r,org:{...r.org,name:a}}),{was:r}},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))},onSettled:()=>e.invalidateQueries({queryKey:t})})}function q(){const e=o(),t=s.me().queryKey;return u({mutationFn:a=>i.renameMe(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{...r,user:{...r.user,name:a}}),{was:r}},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))},onSettled:()=>{e.invalidateQueries({queryKey:t}),e.invalidateQueries({queryKey:s.members().queryKey})}})}function f(){return u({mutationFn:e=>i.changePassword(e.current,e.next)})}function l(){const e=o();return u({mutationFn:t=>i.createInvite(t),onSuccess:()=>void e.invalidateQueries({queryKey:s.invites().queryKey})})}function w(){const e=o(),t=s.invites().queryKey;return u({mutationFn:a=>i.revokeInvite(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{...r,data:r.data.filter(n=>n.id!==a)}),{was:r}},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))},onSettled:()=>e.invalidateQueries({queryKey:t})})}function v(){return u({mutationFn:e=>i.sendInvite(e.id,e.token)})}function K(){const e=o(),t=s.members().queryKey;return u({mutationFn:a=>i.setMemberRole(a.email,a.role),onMutate:async({email:a,role:r})=>{await e.cancelQueries({queryKey:t});const n=e.getQueryData(t);return n&&e.setQueryData(t,{data:n.data.map(m=>m.email===a?{...m,role:r}:m)}),{was:n}},onSuccess:(a,{email:r})=>{e.setQueryData(t,a),a.data.find(n=>n.email===r)?.you&&e.invalidateQueries({queryKey:s.me().queryKey})},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))}})}function D(){const e=o(),t=s.members().queryKey;return u({mutationFn:a=>i.removeMember(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{data:r.data.filter(n=>n.email!==a)}),{was:r}},onSuccess:a=>e.setQueryData(t,a),onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))}})}export{f as a,Q as b,K as c,D as d,w as e,l as f,v as g,q as u};
1
+ import{d as o,F as s,ah as u,v as i,ai as y,ad as c}from"./index-BC1mWQy8.js";function Q(){const e=o(),t=s.me().queryKey;return u({mutationFn:a=>i.renameOrg(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{...r,org:{...r.org,name:a}}),{was:r}},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))},onSettled:()=>e.invalidateQueries({queryKey:t})})}function q(){const e=o(),t=s.me().queryKey;return u({mutationFn:a=>i.renameMe(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{...r,user:{...r.user,name:a}}),{was:r}},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))},onSettled:()=>{e.invalidateQueries({queryKey:t}),e.invalidateQueries({queryKey:s.members().queryKey})}})}function f(){return u({mutationFn:e=>i.changePassword(e.current,e.next)})}function l(){const e=o();return u({mutationFn:t=>i.createInvite(t),onSuccess:()=>void e.invalidateQueries({queryKey:s.invites().queryKey})})}function w(){const e=o(),t=s.invites().queryKey;return u({mutationFn:a=>i.revokeInvite(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{...r,data:r.data.filter(n=>n.id!==a)}),{was:r}},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))},onSettled:()=>e.invalidateQueries({queryKey:t})})}function v(){return u({mutationFn:e=>i.sendInvite(e.id,e.token)})}function K(){const e=o(),t=s.members().queryKey;return u({mutationFn:a=>i.setMemberRole(a.email,a.role),onMutate:async({email:a,role:r})=>{await e.cancelQueries({queryKey:t});const n=e.getQueryData(t);return n&&e.setQueryData(t,{data:n.data.map(m=>m.email===a?{...m,role:r}:m)}),{was:n}},onSuccess:(a,{email:r})=>{e.setQueryData(t,a),a.data.find(n=>n.email===r)?.you&&e.invalidateQueries({queryKey:s.me().queryKey})},onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))}})}function D(){const e=o(),t=s.members().queryKey;return u({mutationFn:a=>i.removeMember(a),onMutate:async a=>{await e.cancelQueries({queryKey:t});const r=e.getQueryData(t);return r&&e.setQueryData(t,{data:r.data.filter(n=>n.email!==a)}),{was:r}},onSuccess:a=>e.setQueryData(t,a),onError:(a,r,n)=>{n?.was&&e.setQueryData(t,n.was),y.error(c(a))}})}export{f as a,Q as b,K as c,D as d,w as e,l as f,v as g,q as u};
@@ -0,0 +1 @@
1
+ import{j as t,O as o}from"./index-BC1mWQy8.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -0,0 +1 @@
1
+ import{q as y,j as e,af as C,w as k,ag as A,r as c,a4 as E,ac as p,B as x,t as F,d as O,ah as R,ad as D,F as h,ai as I,v as U,aj as L}from"./index-BC1mWQy8.js";import{u as f}from"./useQuery-B1QbR4lk.js";import{L as P,I as N}from"./label-Des6lF0o.js";import{I as T,S as q}from"./InstanceRows-DPIpELtc.js";import{u as S}from"./me-DWKKjc2l.js";import{S as z}from"./SaveState-zj94ZTUn.js";import{C as B}from"./ConfirmDialog-CHFBH7e-.js";import{b as _}from"./studio-DxClsYRz.js";import{c as M}from"./update-duXzIzFS.js";import"./useBaseQuery-Di_lHTAg.js";import"./createBaseUIEventDetails-67bayC1B.js";import"./dialog-l22OkYXh.js";import"./useScrollLock-DV1FkBvY.js";import"./inertValue-Dy4HJtbg.js";import"./check-2F6z9BBy.js";import"./copy-B-mCACcx.js";function Q(){const t=S(),s=f(h.meta()),o=f(h.members()),a=_(),r=y(t.user.role,"studio"),u=k(t),m=A(t),i=f(h.setupState()),l=!i.data?.billingUrl,d=t.user.role==="owner"?i.data?.closeUrl??null:null,[n,j]=c.useState(t.org.name),[b,w]=c.useState(null);c.useEffect(()=>j(t.org.name),[t.org.name]);const v=r&&n.trim().length>0&&n.trim()!==t.org.name;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(E,{title:"Studio settings",sub:t.org.name,actions:e.jsx(z,{saving:a.isPending,savedAt:b})}),e.jsx(p,{title:"Studio",description:"The name at the top of every screen.",children:e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:g=>{g.preventDefault(),v&&a.mutate(n.trim(),{onSuccess:()=>w(Date.now())})},children:[e.jsx(P,{htmlFor:"studio-name",children:"Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{id:"studio-name",value:n,readOnly:!r,onChange:g=>j(g.target.value)}),v&&e.jsx(x,{type:"submit",variant:"outline",children:"Save"})]}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:r?"Shown at the top of the sidebar, above every site.":"Only an owner can change it."})]})}),u?e.jsx(p,{title:"This instance",description:"What is running, and where.",children:e.jsxs("dl",{className:"m-0 grid grid-cols-[130px_1fr] gap-x-3 gap-y-1.5 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Version"}),e.jsxs("dd",{className:"m-0",children:[s.data?.version??"—"," ",e.jsx(G,{version:s.data?.version??""})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Address"}),e.jsx("dd",{className:"m-0",children:e.jsx(H,{owner:r})}),s.data?.commit&&s.data.commit!=="unknown"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Commit"}),e.jsxs("dd",{className:"m-0 font-mono text-[12px] text-ink-soft",children:[s.data.commit.slice(0,12),s.data.modified?" · modified":""]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Sites · members"}),e.jsxs("dd",{className:"m-0",children:[t.projects.length," · ",o.data?.data.length??"—"]})]})]})}):l?e.jsx(p,{title:"This studio",description:"What is in it.",children:e.jsxs("dl",{className:"m-0 grid grid-cols-[130px_1fr] gap-x-3 gap-y-1.5 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Sites"}),e.jsx("dd",{className:"m-0",children:t.projects.length}),e.jsx("dt",{className:"text-muted-foreground",children:"Members"}),e.jsx("dd",{className:"m-0",children:o.data?.data.length??"—"})]})}):null,m==="instance"?e.jsx(T,{owner:r}):m==="usage"?e.jsx(q,{}):null,d&&e.jsx(W,{url:d,name:t.org.name})]})}function W({url:t,name:s}){const[o,a]=c.useState(!1),[r,u]=c.useState(!1),m=()=>{u(!0);const i=document.createElement("form");i.method="post",i.action=t;for(const[l,d]of[["csrf",L()],["confirm",s]]){const n=document.createElement("input");n.type="hidden",n.name=l,n.value=d,i.append(n)}document.body.append(i),i.submit()};return e.jsxs(p,{danger:!0,title:"Close this studio",description:"Its sites stop, and after a grace period it is erased with everything in it.",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-4",children:e.jsxs(x,{variant:"outline",className:"border-destructive text-destructive",onClick:()=>a(!0),children:["Close ",s,"…"]})}),e.jsx(B,{open:o,onOpenChange:a,title:`Close ${s}`,description:"Closing stops the studio now and erases it thirty days later.",confirmLabel:"Close this studio",confirmWord:s,busy:r,onConfirm:m,children:e.jsxs("ul",{className:"m-0 flex list-disc flex-col gap-1.5 pl-5 text-[13px] text-ink-soft",children:[e.jsx("li",{children:"Every site stops at once: the widget leaves your clients' pages, nobody can comment, and the dashboard closes for everyone in the studio."}),e.jsx("li",{children:"If the studio pays for a plan, it is cancelled now, with no refund for the rest of the period."}),e.jsx("li",{children:"For thirty days you can reopen it, with every site as it was."}),e.jsx("li",{children:"After that it is erased for good: its sites, threads, comments and screenshots. People who belong to no other studio lose their account with it."})]})})]})}function G({version:t}){const[s,o]=c.useState({s:"idle"});return s.s==="idle"?e.jsxs(e.Fragment,{children:["·"," ",e.jsx("button",{type:"button",className:"text-brand hover:underline",onClick:()=>{o({s:"checking"}),M(t).then(a=>o({s:"done",r:a})).catch(()=>o({s:"failed"}))},children:"Check for updates"})," ",e.jsx("span",{className:"text-[12px] text-muted-foreground",children:"— from your browser, never from the server"})]}):s.s==="checking"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:["· ",e.jsx(F,{className:"size-3"})," checking…"]}):s.s==="failed"?e.jsx("span",{className:"text-muted-foreground",children:"· could not reach npm"}):e.jsx("span",{className:"text-muted-foreground",children:s.r?.newer?`· ${s.r.latest} is out`:"· up to date"})}function H({owner:t}){const s=O(),o=f(h.instance()),[a,r]=c.useState(null),[u,m]=c.useState(""),i=R({mutationFn:n=>U.setAddress(n),onSuccess:n=>{s.setQueryData(h.instance().queryKey,n),r(null),m(""),I.success("Address saved — every new link is built from it")},onError:n=>m(D(n))}),l=o.data?.address;if(!l)return e.jsx("span",{className:"font-mono text-[12px] text-ink-soft",children:location.origin});const d=l.source==="env";return a===null||!t||d?e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-[12px] text-ink-soft",children:l.url}),e.jsx("span",{className:"text-[12px] text-muted-foreground",children:d?"· set by the environment (SNAGSET_BASE_URL)":l.source==="stored"?"· set at claim; every link is built from it":"· this machine's default"}),t&&!d&&e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>r(l.url),children:"Change…"})]}):e.jsxs("form",{className:"flex flex-col gap-1.5",onSubmit:n=>{n.preventDefault(),i.mutate(a.trim())},children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(N,{"aria-label":"Address",value:a,onChange:n=>r(n.target.value),className:"h-8 max-w-[360px] font-mono text-[12px]",autoFocus:!0}),e.jsx(x,{type:"submit",size:"sm",loading:i.isPending,disabled:!a.trim(),children:i.isPending?"Saving…":"Save"}),e.jsx(x,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(null),children:"Cancel"})]}),u&&e.jsx("span",{className:"text-[12px] text-destructive",children:u}),e.jsx("span",{className:"text-[12px] text-muted-foreground",children:"https:// unless it is this machine; the origin only. Review links, issues and emails are built from it."})]})}const de=()=>y(S().user.role,"settings")?e.jsx(Q,{}):e.jsx(C,{title:"Studio settings"});export{de as component};
@@ -1,4 +1,4 @@
1
- import{c as he,d as me,r,a5 as W,s as S,a6 as J,a8 as C,j as e,B as b,C as Re,h as De,A as Ee,a9 as Ge,q as ce,L as de,t as $e,a2 as Te,$ as Qe}from"./index-DIf_7lV5.js";import{P as X}from"./Picker-BGAVkehH.js";import{u as ue}from"./useQuery-CYC6DPXm.js";import{B as Pe}from"./badge-1x3gEOj5.js";import{i as pe,j as xe,l as ge,k as fe,m as be,n as ke}from"./dialog-CIAPdljP.js";import{I as _,L as Z}from"./label-qbrDzIaf.js";import{C as Ye}from"./ConfirmDialog-Ca4nB0gY.js";import{A as Ve,P as Xe,a as Ze}from"./parts-DnonT_sc.js";import{u as Le}from"./me-cdROrEZn.js";import{v as B}from"./useScrollLock-DSPnO43v.js";import{M as et}from"./McpTokens-CvESgbHd.js";import{C as Fe}from"./CopyButton-baCHDy5v.js";import{C as We}from"./check-DnU_QrcS.js";import"./chevron-down-CBtD71Qj.js";import"./isElementDisabled-CwHw_lZC.js";import"./createBaseUIEventDetails-4JZNAnON.js";import"./inertValue-9Ojj3uf7.js";import"./serializeValue-B8e3iXO-.js";import"./useValueChanged-DQAqpQ0y.js";import"./getPseudoElementBounds-B9DhGoL1.js";import"./CompositeList-CeLQBvjs.js";import"./useBaseQuery-B90MJ7He.js";import"./useRender-DP2er8v5.js";import"./copy-C0sdzqxc.js";import"./card-C1bRD7dG.js";import"./switch-BXyi-44q.js";import"./useAriaLabelledBy-DWswad3y.js";/**
1
+ import{c as he,d as me,r,ah as W,v as S,ai as J,ak as C,j as e,B as b,H as Re,h as De,F as Ee,al as Ge,a7 as B,q as ce,af as Qe,L as de,w as $e,ad as Te,a4 as Ye,ac as Ve,a5 as Xe}from"./index-BC1mWQy8.js";import{P as X}from"./Picker-CCAp0603.js";import{u as ue}from"./useQuery-B1QbR4lk.js";import{B as Fe}from"./badge-CYPTl0cy.js";import{i as pe,j as xe,l as ge,k as fe,m as be,n as ke}from"./dialog-l22OkYXh.js";import{I as _,L as Z}from"./label-Des6lF0o.js";import{C as Ze}from"./ConfirmDialog-CHFBH7e-.js";import{u as Le}from"./me-DWKKjc2l.js";import{M as et}from"./McpTokens-yimU884S.js";import{C as Pe}from"./CopyButton-U3SFd-HD.js";import{C as We}from"./check-2F6z9BBy.js";import"./chevron-down-Co3oKci1.js";import"./useScrollLock-DV1FkBvY.js";import"./inertValue-Dy4HJtbg.js";import"./createBaseUIEventDetails-67bayC1B.js";import"./isElementDisabled-CwHw_lZC.js";import"./serializeValue-B8e3iXO-.js";import"./useValueChanged-CxAXjLUw.js";import"./getPseudoElementBounds-D9YqITSR.js";import"./CompositeList-nzDbuttJ.js";import"./useBaseQuery-Di_lHTAg.js";import"./useRender-bF5mRtl9.js";import"./copy-B-mCACcx.js";import"./switch-BQZZEckg.js";import"./useAriaLabelledBy-hDZ_Qzgg.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{c as he,d as me,r,a5 as W,s as S,a6 as J,a8 as C,j as e,B as b,C as Re,h
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ot=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],it=he("eye",ot),_e="https://snagset.com/docs/integrations/",Oe={github:"Repository",linear:"Team",jira:"Project",trello:"Board"},le="__new_board__",rt=t=>`https://trello.com/1/authorize?expiration=never&scope=read,write&response_type=token&name=Snagset&key=${encodeURIComponent(t.trim())}`;function Ie(t){const i=h=>t.find(m=>h.test(m.label))?.value,l=i(/^(to ?do|backlog|open|new|inbox)/i)??t[0]?.value??"",o=i(/^(done|complete|resolved|shipped|fixed)/i)??t[t.length-1]?.value??"",x=i(/(doing|progress|review|working)/i)??t.find(h=>h.value!==l&&h.value!==o)?.value??"";return{open:l,progress:x,resolved:o}}function je({id:t,value:i,onChange:l,placeholder:o,disabled:x}){const[h,m]=r.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsx(_,{id:t,type:h?"text":"password",placeholder:o,value:i,onChange:j=>l(j.target.value),disabled:x,autoComplete:"off",spellCheck:!1,className:"pr-9 font-mono text-[12.5px]"}),e.jsx("button",{type:"button",onClick:()=>m(j=>!j),"aria-label":h?"Hide":"Show","aria-pressed":h,className:"absolute inset-y-0 right-0 flex w-9 items-center justify-center rounded-r-md text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:h?e.jsx(at,{className:"size-4"}):e.jsx(it,{className:"size-4"})})]})}function lt({at:t}){const i=["Access","Connect","Way back"];return e.jsx("ol",{className:"m-0 flex list-none items-center gap-2 p-0 text-[12px]","aria-label":"Steps",children:i.map((l,o)=>{const x=o+1;return e.jsxs("li",{"aria-current":x===t?"step":void 0,className:"flex items-center gap-2",children:[e.jsx("span",{className:De("flex size-5 items-center justify-center rounded-full border text-[11px] tabular-nums",x<t&&"border-transparent bg-primary text-primary-foreground",x===t&&"border-primary text-foreground",x>t&&"border-border text-muted-foreground"),children:x<t?e.jsx(We,{className:"size-3"}):x}),e.jsx("span",{className:x===t?"font-medium text-foreground":"text-muted-foreground",children:l}),o<i.length-1&&e.jsx("span",{className:"h-px w-5 bg-border","aria-hidden":!0})]},l)})})}function P({id:t,label:i,hint:l,children:o}){return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{htmlFor:t,children:i}),o,l&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:l})]})}function ze({children:t}){return e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:t})}function F({href:t,children:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-foreground underline underline-offset-2",children:i})}const K=t=>t instanceof Re?t.message:"Could not reach the server.";function ct({provider:t,jiraSite:i,trelloKey:l=""}){const o=t==="trello"?[e.jsxs(e.Fragment,{children:["Open ",e.jsx(F,{href:"https://trello.com/power-ups/admin",children:"Trello › Power-Ups admin"})," › New. Name it Snagset, any workspace, and tick that it does not use Power-Up capabilities. Skip the OAuth 2.0 page."]}),e.jsx(e.Fragment,{children:"Open its API key tab, generate a key, and paste the key below."}),e.jsxs(e.Fragment,{children:["On that same page, click the Token link beside the key",l.trim()?e.jsxs(e.Fragment,{children:[" ","(or ",e.jsx(F,{href:rt(l),children:"this one"}),")"]}):null,": Allow, then copy the whole token (it starts ATTA) and paste it below."]})]:t==="github"?[e.jsxs(e.Fragment,{children:["Open ",e.jsx(F,{href:"https://github.com/settings/personal-access-tokens/new",children:"GitHub › Fine-grained tokens › Generate new token"}),"."]}),e.jsx(e.Fragment,{children:"Repository access: only the site's repository. Permissions › Issues: Read and write."}),e.jsx(e.Fragment,{children:"Generate, copy the token, paste it below."})]:t==="linear"?[e.jsxs(e.Fragment,{children:["Open ",e.jsx(F,{href:"https://linear.app/settings/account/security",children:"Linear › Settings › Security & access"}),"."]}),e.jsx(e.Fragment,{children:"Under Personal API keys, make a new key. It acts as you, so you must be in the team."}),e.jsx(e.Fragment,{children:"Copy the key, paste it below."})]:[e.jsxs(e.Fragment,{children:["Open ",e.jsx(F,{href:"https://id.atlassian.com/manage-profile/security/api-tokens",children:"Atlassian account › Security › API tokens"}),"."]}),e.jsx(e.Fragment,{children:'Create API token — the plain one, not "with scopes". Name it Snagset.'}),e.jsxs(e.Fragment,{children:["Copy it, paste it below with the email you sign in to ",i?i.replace(/^https?:\/\//,""):"Jira"," with."]})];return e.jsx("ol",{className:"m-0 flex list-decimal flex-col gap-1 pl-5 text-[13px] text-muted-foreground",children:o.map((x,h)=>e.jsx("li",{children:x},h))})}function Be({provider:t,site:i,shownSecret:l,target:o,onSecret:x}){const h=me(),m=`${location.origin}/api/v1/integrations/${t}/inbound`,[j]=r.useState(()=>Date.now()),[k,A]=r.useState(""),[f,N]=r.useState(""),[T,O]=r.useState(!1),[g,$]=r.useState(null),p=ue({...Ee.integrations(),refetchInterval:3e3}).data?.data.find(w=>w.site===i&&w.provider===t),u=W({mutationFn:w=>S.setWebhookSecret(i,t,w),onSuccess:w=>{N(""),A(""),O(!0),$(w.check??null),x(w.webhook.secret??null),h.invalidateQueries({queryKey:["integrations"]}),J.success(t==="linear"?"Signing secret saved":t==="trello"?"Secret saved":"New secret made — the old one has stopped working")},onError:w=>N(K(w))}),a=p?.lastDeliveryAt?Date.parse(p.lastDeliveryAt):0,c=p?.lastRefusedAt?Date.parse(p.lastRefusedAt):0,d=(t==="linear"||t==="trello")&&p&&!p.hasWebhookSecret?"nosecret":a?"ok":c?"refused":"waiting",n=d==="ok"&&c>a,D=t==="linear"||t==="trello",H=t==="trello"||t==="linear"||t==="jira",I=H&&!!g?.sent&&d==="waiting",M=W({mutationFn:()=>S.checkWebhook(i,t),onSuccess:w=>{$(w.check),h.invalidateQueries({queryKey:["integrations"]})},onError:w=>N(K(w))}),q=g?.left?` It could not delete ${g.left} afterwards; delete it by hand.`:"",[v,E]=r.useState(!1),U=D&&(d!=="ok"||v),G=t==="github"?"GitHub sends a test delivery the moment the webhook is saved.":t==="trello"?g?.sent?`Snagset made a check card on ${o.label} and deleted it again; Trello's delivery for it confirms the secret in a moment.`:g?`Snagset could not make its check card (${g.detail}). Move any card on ${o.label} to another list once instead.`:`Saving the secret makes a check card on ${o.label} and deletes it again; Trello's delivery for it confirms the secret.`:t==="linear"?g?.sent?`Snagset made a check issue in ${o.label} and deleted it again; Linear's delivery for it confirms the secret in a moment.`:g?`Snagset could not make its check issue (${g.detail}). Move any issue in ${o.label} to another status once instead.`:`Saving the secret makes a check issue in ${o.label} and deletes it again; Linear's delivery for it confirms the secret.`:g?.sent?`Snagset made a check issue in ${o.label}, edited it and deleted it; Jira's delivery for it confirms the webhook in a moment.${q}`:g?`Snagset could not make its check issue (${g.detail}). Move any issue in ${o.label} once instead.`:`Once the webhook is created in Jira, Check it makes an issue in ${o.label}, edits it and deletes it; Jira's delivery for it confirms the webhook.`;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[f&&e.jsx(ze,{children:f}),e.jsx("ol",{className:"m-0 flex list-decimal flex-col gap-1 pl-5 text-[13px] text-muted-foreground",children:t==="github"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Open"," ",e.jsx(F,{href:o.repo?`https://github.com/${o.repo}/settings/hooks/new`:"https://github.com",children:"the repository's Settings › Webhooks › Add webhook"}),"."]}),e.jsx("li",{children:"Paste the address and the secret below; content type application/json."}),e.jsx("li",{children:'"Let me select individual events" → tick Issues only. Add webhook.'})]}):t==="trello"?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:p&&!p.webhookRegistered?`Snagset could not register the webhook on ${o.label}${o.trelloNote?`: ${o.trelloNote}`:""}. Trello must be able to reach this server's address; connect again once it can.`:`Snagset registered the webhook on ${o.label} for you: nothing to set up in Trello.`}),U&&e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Trello signs each delivery with your Power-Up's secret. Open ",e.jsx(F,{href:"https://trello.com/power-ups/admin",children:"Trello › Power-Ups admin"}),", your Power-Up's API key tab, and copy the Secret."]}),e.jsx("li",{children:"Paste it below."})]})]}):t==="linear"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Open ",e.jsx(F,{href:"https://linear.app/settings/api",children:"Linear › Settings › API"}),", then Webhooks › New webhook."]}),e.jsxs("li",{children:["Paste the address; pick the team ",o.label,"; under data change events tick Issues. Create."]}),U&&e.jsx("li",{children:"Linear shows a signing secret: copy it and paste it below."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Open"," ",e.jsx(F,{href:o.jiraSite?`${o.jiraSite}/plugins/servlet/webhooks`:"https://admin.atlassian.com",children:"Jira › Settings › System › WebHooks"})," ","› Create a WebHook. It needs a Jira admin."]}),e.jsx("li",{children:"Paste the address and the secret below."}),e.jsx("li",{children:"Under Issue, tick updated and deleted. Create."})]})}),e.jsxs("dl",{className:"m-0 grid grid-cols-[88px_minmax(0,1fr)] items-center gap-x-3 gap-y-2.5 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Address"}),e.jsxs("dd",{className:"m-0 flex min-w-0 items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all rounded-md bg-muted px-2 py-1 font-mono text-[12px]","data-testid":"webhook-url",children:m}),e.jsx(Fe,{text:m,label:"Copy the address"})]}),t!=="linear"&&t!=="trello"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Secret"}),e.jsx("dd",{className:"m-0 flex min-w-0 items-center gap-2",children:l?e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"min-w-0 flex-1 break-all rounded-md bg-muted px-2 py-1 font-mono text-[12px]","data-testid":"webhook-secret",children:l}),e.jsx(Fe,{text:l,label:"Copy the secret"})]}):e.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2 text-muted-foreground",children:["Shown once, when it was made.",e.jsx(b,{type:"button",size:"sm",variant:"outline",loading:u.isPending,onClick:()=>u.mutate(void 0),children:"Make a new secret"})]})})]}),t==="github"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Content type"}),e.jsx("dd",{className:"m-0 font-mono text-[12px]",children:"application/json"})]})]}),l&&e.jsx("p",{className:"m-0 -mt-2 text-[12px] text-muted-foreground",children:"Copy it now: it is not shown again. A new one can be made here any time."}),U&&e.jsx(P,{id:"wb-secret",label:t==="linear"?"Signing secret":"Power-Up secret",hint:I?`Checking it with ${C[t]}…`:d==="refused"?`That secret did not match. Copy the Secret from the ${t==="linear"?"webhook in Linear":"Power-Up's API key tab"} again and paste it here.`:T||p?.hasWebhookSecret?"Saved. Paste a new one to replace it.":t==="linear"?"From the webhook Linear just made.":"Next to the API key in Trello.",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(je,{id:"wb-secret",value:k,onChange:A,placeholder:t==="linear"?"lin_wh_…":"",disabled:I})}),e.jsx(b,{type:"button",variant:"outline",disabled:!k.trim()||I,loading:u.isPending||I,onClick:()=>{E(!1),u.mutate(k.trim())},children:"Save"})]})}),e.jsxs("div",{role:"status","aria-live":"polite","data-testid":"webhook-check","data-state":d,className:De("flex items-start gap-2.5 rounded-md border px-3 py-2.5 text-[13px]",d==="ok"&&"border-emerald-500/40 bg-emerald-500/10",d==="refused"&&"border-destructive/40 bg-warn-soft",(d==="waiting"||d==="nosecret")&&"border-border bg-muted/40"),children:[d==="ok"?e.jsx(We,{className:"mt-0.5 size-4 shrink-0 text-emerald-600"}):d==="refused"?e.jsx(st,{className:"mt-0.5 size-4 shrink-0 text-destructive"}):e.jsx(Ge,{className:"mt-0.5 size-4 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none"}),e.jsx("span",{className:"min-w-0",children:d==="ok"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"The webhook works."})," Last delivery ",a>=j?"just now":B(p.lastDeliveryAt),".",D&&!v&&e.jsx("button",{type:"button",className:"ml-1 underline underline-offset-2 text-muted-foreground hover:text-foreground",onClick:()=>E(!0),children:"Replace the secret…"}),n&&e.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["A later delivery was refused (",B(p.lastRefusedAt),"): ",p.lastRefusedError," If you did not change the secret, it may not have come from ",C[t],"."]})]}):d==="refused"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"A delivery arrived and was refused"})," (",B(p.lastRefusedAt),"). ",p.lastRefusedError,e.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["A refused delivery is unsigned, so it may not be from ",C[t],". Check the delivery log on ",C[t],"'s webhook before changing anything."]})]}):d==="nosecret"?e.jsxs(e.Fragment,{children:["Waiting for the ",t==="linear"?"signing secret":"Power-Up's secret",". Without it, ",C[t],"'s deliveries are refused."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:I?t==="jira"?"Checking the webhook…":"Checking the secret…":"Waiting for the first delivery."})," ",G]})})]}),H&&p?.hasWebhookSecret&&(d==="waiting"||d==="refused")&&e.jsx("div",{className:"-mt-2 flex justify-end",children:e.jsx(b,{type:"button",size:"sm",variant:"outline",loading:M.isPending||I,disabled:I,onClick:()=>M.mutate(),children:g?"Check again":"Check it"})})]})}function dt({provider:t,open:i,onOpenChange:l,sites:o}){const x=me(),h=C[t],[m,j]=r.useState(1),[k,A]=r.useState(""),[f,N]=r.useState(""),[T,O]=r.useState(""),[g,$]=r.useState(""),[y,p]=r.useState(""),[u,a]=r.useState([]),[c,d]=r.useState({open:"",progress:"",resolved:""}),[n,D]=r.useState(""),[H,I]=r.useState(""),[M,q]=r.useState([]),[v,E]=r.useState(""),[U,G]=r.useState(""),[w,ye]=r.useState(!1),[Me,ee]=r.useState(null),[Ue,we]=r.useState(""),[ve,L]=r.useState("");r.useEffect(()=>{i||(j(1),A(""),N(""),O(""),$(""),p(""),a([]),d({open:"",progress:"",resolved:""}),D(""),I(""),q([]),E(""),G(""),ye(!1),ee(null),we(""),L(""))},[i]);const z=k||o[0]?.uid||"",Q=T.trim().replace(/\/+$/,"").replace(/^(?!https?:\/\/)/,"https://"),Ke=t==="github"?{token:f.trim()}:t==="linear"?{apiKey:f.trim()}:t==="trello"?{apiKey:y.trim(),token:f.trim()}:{siteUrl:Q,email:g.trim(),apiToken:f.trim()},Y=r.useRef(""),te=W({mutationFn:s=>S.discoverTracker("trello",{apiKey:y.trim(),token:f.trim(),boardId:s}),onSuccess:(s,R)=>{R===Y.current&&(L(""),a(s.options),d(Ie(s.options)))},onError:(s,R)=>{R===Y.current&&L(K(s))}}),[V,se]=r.useState(!1),[ne,Je]=r.useState("Snagset feedback"),Ne=W({mutationFn:s=>S.discoverTracker("trello",{apiKey:y.trim(),token:f.trim(),newBoard:s}),onSuccess:s=>{s.board&&(L(""),se(!1),q(R=>[...R,s.board]),Y.current=s.board.value,E(s.board.value),a(s.options),d(Ie(s.options)))},onError:s=>L(K(s))}),Se=s=>{if(s===le){se(!0);return}se(!1),Y.current=s,E(s),a([]),d({open:"",progress:"",resolved:""}),s&&te.mutate(s)},ae=W({mutationFn:()=>S.discoverTracker(t,Ke),onSuccess:s=>{L(""),I(s.who),q(s.options);const R=s.options.find(re=>re.canWrite!==!1)?.value??s.options[0]?.value??"";t==="trello"?Se(R):E(R),j(2)},onError:s=>L(K(s))}),oe=W({mutationFn:()=>{const s=w?"thread.created":"manual";return t==="github"?S.connectTracker(z,"github",{repository:v.trim(),token:f.trim(),labels:U.trim(),createOn:s}):t==="linear"?S.connectTracker(z,"linear",{team:v.trim(),apiKey:f.trim(),createOn:s}):t==="trello"?S.connectTracker(z,"trello",{apiKey:y.trim(),token:f.trim(),boardId:v,openList:c.open,progressList:c.progress,resolvedList:c.resolved,createOn:s}):S.connectTracker(z,"jira",{siteUrl:Q,project:v.trim(),email:g.trim(),apiToken:f.trim(),createOn:s})},onSuccess:s=>{L(""),N(""),ee(s.webhook?.secret??null),D(s.webhook?.error??""),we(z),x.invalidateQueries({queryKey:["integrations"]}),J.success(`${h} connected`),j(3)},onError:s=>L(K(s))}),Ce=!!z&&!!f.trim()&&(t!=="jira"||!!T.trim()&&!!g.trim())&&(t!=="trello"||!!y.trim()),ie=t!=="trello"||!V&&!!c.open&&!!c.progress&&!!c.resolved&&new Set([c.open,c.progress,c.resolved]).size===3,Ae=M.find(s=>s.value===v),He=Ae?.label??v;return e.jsx(pe,{open:i,onOpenChange:l,children:e.jsx(xe,{className:"sm:max-w-[560px]",children:e.jsxs("form",{className:"flex min-w-0 flex-col gap-4",noValidate:!0,onSubmit:s=>{s.preventDefault(),m===1&&Ce?ae.mutate():m===2&&v.trim()&&ie?oe.mutate():m===3&&l(!1)},children:[e.jsxs(ge,{children:[e.jsxs(fe,{children:["Connect a site to ",h]}),e.jsxs(be,{children:[m===1?`Give Snagset access to ${h}. The key is checked now and stored encrypted with this instance's secret key.`:m===2?`Signed in to ${h}${H?` as ${H}`:""}. Choose where this site's comments go.`:`Connected. Now the way back: a webhook, so that moving ${t==="trello"?"a card":"an issue"} in ${h} moves the comment here.`," ",e.jsx(F,{href:`${_e}#${t}`,children:"Step-by-step guide"})]})]}),e.jsx(lt,{at:m}),ve&&m!==3&&e.jsx(ze,{children:ve}),m===1&&e.jsxs(e.Fragment,{children:[e.jsx(P,{id:"ct-site",label:"Site",children:e.jsx(X,{id:"ct-site",value:z,onChange:A,options:o.map(s=>({value:s.uid,label:s.name}))})}),e.jsx(ct,{provider:t,jiraSite:Q,trelloKey:y}),t==="trello"&&e.jsx(P,{id:"ct-trello-key",label:"API key",children:e.jsx(_,{id:"ct-trello-key",value:y,onChange:s=>p(s.target.value),autoComplete:"off",spellCheck:!1})}),t==="jira"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{id:"ct-jira-site",label:"Jira site",hint:"The address you open Jira at.",children:e.jsx(_,{id:"ct-jira-site",placeholder:"https://kilnwork.atlassian.net",value:T,onChange:s=>O(s.target.value),autoComplete:"off"})}),e.jsx(P,{id:"ct-email",label:"Account email",children:e.jsx(_,{id:"ct-email",type:"email",placeholder:"you@kilnwork.studio",value:g,onChange:s=>$(s.target.value),autoComplete:"off"})})]}),e.jsx(P,{id:"ct-token",label:t==="github"||t==="trello"?"Token":t==="linear"?"API key":"API token",children:e.jsx(je,{id:"ct-token",value:f,onChange:N,placeholder:t==="github"?"github_pat_…":t==="linear"?"lin_api_…":""})})]}),m===2&&e.jsxs(e.Fragment,{children:[M.length>0||t==="trello"?e.jsx(P,{id:"ct-target",label:Oe[t],hint:Ae?.canWrite===!1?"This token can only read that repository: give it Issues › Read and write, or pick another.":t==="jira"?"Jira calls these spaces; the key in brackets is the prefix on its issues.":void 0,children:e.jsx(X,{id:"ct-target",value:V?le:v,onChange:t==="trello"?Se:E,options:[...M.map(s=>({value:s.value,label:s.label})),...t==="trello"?[{value:le,label:"New board…"}]:[]]})}):e.jsx(P,{id:"ct-target",label:Oe[t],hint:`${h} listed nothing this key can see. Type it instead: ${t==="github"?"owner/name":"the prefix on its issues, like ENG"}.`,children:e.jsx(_,{id:"ct-target",value:v,onChange:s=>E(s.target.value),autoComplete:"off"})}),t==="trello"&&V&&e.jsx(P,{id:"ct-new-board",label:"Board name",hint:"Snagset makes it, private to you, with three lists: To do, Doing and Done.",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{id:"ct-new-board",value:ne,onChange:s=>Je(s.target.value),autoComplete:"off",className:"min-w-0 flex-1"}),e.jsx(b,{type:"button",variant:"outline",disabled:!ne.trim(),loading:Ne.isPending,onClick:()=>Ne.mutate(ne.trim()),children:"Make board"})]})}),t==="trello"&&!V&&(te.isPending?e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"Reading the board's lists…"}):u.length>0?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"A card's list is its status. Moving a card between these three moves the comment here, and back."}),[["open","Open"],["progress","In progress"],["resolved","Resolved"]].map(([s,R])=>e.jsx(P,{id:`ct-list-${s}`,label:R,children:e.jsx(X,{id:`ct-list-${s}`,value:c[s],onChange:re=>d(qe=>({...qe,[s]:re})),options:u})},s)),!ie&&e.jsx("p",{className:"m-0 text-[12px] text-destructive",children:"Pick three different lists."})]}):v?e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"This board has no open lists. Add three in Trello (for example To do, Doing, Done), then pick it again."}):null),t==="github"&&e.jsx(P,{id:"ct-labels",label:"Labels",hint:"Optional, comma-separated. Put on every issue Snagset opens.",children:e.jsx(_,{id:"ct-labels",placeholder:"review",value:U,onChange:s=>G(s.target.value),autoComplete:"off"})}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md border border-border px-3 py-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:w,onChange:s=>ye(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:t==="trello"?"A card for every new comment":"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:t==="trello"?"Off: you make a card from a comment's brief when you mean it. On: every new comment makes one.":"Off: you make an issue from a comment's brief when you mean it. On: every new comment opens one."})]})]})]}),m===3&&e.jsx(Be,{provider:t,site:Ue,shownSecret:Me,onSecret:ee,target:{label:He,...t==="jira"?{jiraSite:Q}:{},...t==="github"?{repo:v}:{},...t==="trello"&&n?{trelloNote:n}:{}}}),e.jsxs(ke,{children:[m===1&&e.jsxs(e.Fragment,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(b,{type:"submit",loading:ae.isPending,disabled:!Ce,children:ae.isPending?"Checking…":"Check access"})]}),m===2&&e.jsxs(e.Fragment,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>j(1),children:"Back"}),e.jsx(b,{type:"submit",loading:oe.isPending,disabled:!v.trim()||!ie||te.isPending,children:oe.isPending?"Connecting…":"Connect"})]}),m===3&&e.jsx(b,{type:"submit",children:"Done"})]})]})})})}function ht({state:t,onClose:i}){const[l,o]=r.useState(null);return r.useEffect(()=>{t||o(null)},[t]),e.jsx(pe,{open:t!==null,onOpenChange:x=>!x&&i(),children:e.jsx(xe,{className:"sm:max-w-[560px]",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs(ge,{children:[e.jsxs(fe,{children:[C[t.provider]," webhook for ",t.siteName]}),e.jsxs(be,{children:["The way back: moving ",t.provider==="trello"?"a card":"an issue"," in ",C[t.provider]," moves the comment here. ",e.jsx(F,{href:`${_e}#${t.provider}`,children:"Step-by-step guide"})]})]}),e.jsx(Be,{provider:t.provider,site:t.site,shownSecret:l,onSecret:o,target:t.target}),e.jsx(ke,{children:e.jsx(b,{type:"button",onClick:i,children:"Done"})})]})})})}const mt={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function ut(){const t=Le(),i=ce(t.user.role,"settings"),l=ce(t.user.role,"studio")&&$e(t),o=ue(Ee.integrations()),x=me(),h=()=>x.invalidateQueries({queryKey:["integrations"]}),[m,j]=r.useState(null),[k,A]=r.useState(null),[f,N]=r.useState(null),T=W({mutationFn:({uid:a,provider:c})=>S.testTracker(a,c).then(d=>({...d,provider:c})),onSuccess:a=>{J[a.ok?"success":"error"](a.ok?`${C[a.provider]} can see ${a.target}`:a.detail??`${C[a.provider]} refused the token`),h()},onError:a=>J.error(Te(a))}),O=W({mutationFn:({uid:a,provider:c})=>S.disconnectTracker(a,c),onSuccess:()=>{A(null),h()},onError:a=>J.error(Te(a))}),g=o.data?.data??[],$=a=>g.filter(c=>c.provider===a),y=t.projects.filter(a=>!a.archived&&!a.locked),p=a=>y.filter(c=>!$(a).some(d=>d.site===c.uid)),u=i?t.limits.integrations?y.length===0?"site":null:"plan":null;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(Xe,{title:"Integrations",sub:"Your coding agent first, then the trackers that mirror a comment's status, then Slack, which only announces"}),e.jsx(et,{owner:i,instanceOwner:l,operator:$e(t),sites:t.projects}),u&&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:u==="plan"?t.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.":t.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."}),u==="plan"?t.user.role==="owner"&&e.jsx(b,{variant:"outline",size:"sm",render:e.jsx(de,{to:"/studio/plan"}),children:"See plans"}):e.jsx(b,{variant:"outline",size:"sm",render:e.jsx(de,{to:"/sites"}),children:"Go to Sites"})]}),["github","linear","jira","trello","slack"].map(a=>{const c=$(a),d=p(a);return e.jsxs(Ze,{title:C[a],description:a==="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.":a==="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.":a==="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.":a==="trello"?"A comment becomes a card on the site's board, with the brief as its description. A card's list is its status: our status moves it between the three lists you pick, and moving it there moves the comment here. An API key and token from your own Power-Up; Snagset sets up the webhook.":"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:[o.isPending&&e.jsx(Qe,{rows:2}),o.isSuccess&&c.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pe,{variant:"outline",children:"Not connected"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:a==="github"?"No site is connected to a repository yet.":a==="linear"?"No site is connected to a team yet.":a==="jira"?"No site is connected to a project yet.":a==="trello"?"No site is connected to a board yet.":"No site is connected to a channel yet."})]}),c.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:c.map(n=>{const D=mt[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.provider==="trello"?`${n.boardName} · ${n.listNames.open} / ${n.listNames.progress} / ${n.listNames.resolved}`:`#${n.channelName} · ${n.teamName}`}),e.jsx(Pe,{variant:"outline",className:D.tone==="ok"?"border-ok text-ok":D.tone==="bad"?"border-destructive text-destructive":"",children:D.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.provider==="trello"?n.createOn==="thread.created"?"A card for every new comment":"Cards 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(", ")}`:""," · ",B(n.updatedAt)]}),n.provider!=="slack"&&e.jsx(xt,{r:n}),n.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:n.lastError}),i&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[n.provider!=="slack"&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>N({provider:n.provider,site:n.site,siteName:n.siteName??n.site,target:n.provider==="github"?{label:`${n.owner}/${n.repo}`,repo:`${n.owner}/${n.repo}`}:n.provider==="linear"?{label:n.teamName}:n.provider==="trello"?{label:n.boardName}:{label:n.projectName,jiraSite:n.siteUrl}}),children:"Webhook…"}),e.jsx(b,{variant:"ghost",size:"sm",loading:T.isPending,onClick:()=>T.mutate({uid:n.site,provider:n.provider}),children:"Test"}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>A(n),children:"Disconnect"})]})]},`${n.provider}:${n.site}`)})}),i&&!u&&d.length>0&&e.jsx("div",{children:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>j(a),children:"Connect a site…"})})]},a)}),["github","linear","jira","trello"].map(a=>e.jsx(dt,{provider:a,open:m===a,onOpenChange:c=>!c&&j(null),sites:p(a)},a)),e.jsx(pt,{open:m==="slack",onOpenChange:a=>!a&&j(null),sites:p("slack"),onDone:()=>void h()}),e.jsx(ht,{state:f,onClose:()=>N(null)}),e.jsx(Ye,{open:k!==null,onOpenChange:a=>!a&&A(null),title:`Disconnect ${k?.siteName??"this site"} from ${k?C[k.provider]:"the tracker"}?`,description:k?.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:O.isPending,onConfirm:async()=>{k&&await O.mutateAsync({uid:k.site,provider:k.provider})}})]})}function pt({open:t,onOpenChange:i,sites:l,onDone:o}){const[x,h]=r.useState(""),[m,j]=r.useState(""),[k,A]=r.useState(""),[f,N]=r.useState(!0),[T,O]=r.useState(""),g=ue({queryKey:["integrations","slack","manifest"],queryFn:()=>S.slackManifest(),enabled:t,staleTime:1/0}),$=W({mutationFn:u=>S.connectTracker(u,"slack",{channel:m.trim(),token:k.trim(),createOn:f?"thread.created":"manual"})}),y=x||l[0]?.uid||"",p=async u=>{u.preventDefault(),O("");try{await $.mutateAsync(y),j(""),A(""),N(!0),i(!1),o(y),J.success("Slack connected")}catch(a){O(a instanceof Re?a.message:"Could not reach the server.")}};return e.jsx(pe,{open:t,onOpenChange:i,children:e.jsx(xe,{children:e.jsxs("form",{onSubmit:u=>void p(u),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(ge,{children:[e.jsx(fe,{children:"Connect a site to Slack"}),e.jsx(be,{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."})]}),T&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:T}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{htmlFor:"sl-site",children:"Site"}),e.jsx(X,{id:"sl-site",value:y,onChange:h,options:l.map(u=>({value:u.uid,label:u.name}))})]}),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(b,{type:"button",variant:"outline",size:"sm",disabled:!g.data,render:e.jsx("a",{href:g.data?.url??"#",target:"_blank",rel:"noreferrer"}),children:"Create app…"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{htmlFor:"sl-token",children:"2. Bot User OAuth Token"}),e.jsx(je,{id:"sl-token",placeholder:"xoxb-…",value:k,onChange:A}),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(Z,{htmlFor:"sl-channel",children:"3. Channel"}),e.jsx(_,{id:"sl-channel",placeholder:"#reviews",value:m,onChange:u=>j(u.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:f,onChange:u=>N(u.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(ke,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(b,{type:"submit",loading:$.isPending,disabled:!m.trim()||!k.trim()||!y,children:$.isPending?"Checking…":"Connect"})]})]})})})}function xt({r:t}){const i=C[t.provider];if(t.lastDeliveryAt){const l=t.lastRefusedAt&&Date.parse(t.lastRefusedAt)>Date.parse(t.lastDeliveryAt);return e.jsxs("span",{className:"basis-full text-[12px] text-muted-foreground",children:["Webhook works · last delivery ",B(t.lastDeliveryAt),l?` · a later one was refused ${B(t.lastRefusedAt)}`:""]})}return t.lastRefusedAt?e.jsxs("span",{className:"basis-full text-[12px] text-destructive",children:["Webhook refused ",B(t.lastRefusedAt),": ",t.lastRefusedError," Unsigned, so check ",i,"'s webhook log first."]}):t.provider==="trello"&&!t.webhookRegistered?e.jsxs("span",{className:"basis-full text-[12px] text-destructive",children:["Snagset could not register the webhook on ",t.boardName,": Trello must reach this server's address. Connect again once it can."]}):(t.provider==="linear"||t.provider==="trello")&&!t.hasWebhookSecret?e.jsxs("span",{className:"basis-full text-[12px] text-muted-foreground",children:["No webhook yet, so ",i," cannot move comments here. Webhook… sets it up."]}):e.jsx("span",{className:"basis-full text-[12px] text-muted-foreground",children:"No webhook delivery seen yet. Webhook… shows how to set it up."})}const Ut=()=>ce(Le().user.role,"settings")?e.jsx(ut,{}):e.jsx(Ve,{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(de,{to:"/you",className:"text-brand hover:underline",children:"You"}),"."]})});export{Ut as component};
16
+ */const ot=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],it=he("eye",ot),_e="https://snagset.com/docs/integrations/",Oe={github:"Repository",linear:"Team",jira:"Project",trello:"Board"},le="__new_board__",rt=t=>`https://trello.com/1/authorize?expiration=never&scope=read,write&response_type=token&name=Snagset&key=${encodeURIComponent(t.trim())}`;function Ie(t){const i=h=>t.find(m=>h.test(m.label))?.value,l=i(/^(to ?do|backlog|open|new|inbox)/i)??t[0]?.value??"",o=i(/^(done|complete|resolved|shipped|fixed)/i)??t[t.length-1]?.value??"",x=i(/(doing|progress|review|working)/i)??t.find(h=>h.value!==l&&h.value!==o)?.value??"";return{open:l,progress:x,resolved:o}}function je({id:t,value:i,onChange:l,placeholder:o,disabled:x}){const[h,m]=r.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsx(_,{id:t,type:h?"text":"password",placeholder:o,value:i,onChange:j=>l(j.target.value),disabled:x,autoComplete:"off",spellCheck:!1,className:"pr-9 font-mono text-[12.5px]"}),e.jsx("button",{type:"button",onClick:()=>m(j=>!j),"aria-label":h?"Hide":"Show","aria-pressed":h,className:"absolute inset-y-0 right-0 flex w-9 items-center justify-center rounded-r-md text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:h?e.jsx(at,{className:"size-4"}):e.jsx(it,{className:"size-4"})})]})}function lt({at:t}){const i=["Access","Connect","Way back"];return e.jsx("ol",{className:"m-0 flex list-none items-center gap-2 p-0 text-[12px]","aria-label":"Steps",children:i.map((l,o)=>{const x=o+1;return e.jsxs("li",{"aria-current":x===t?"step":void 0,className:"flex items-center gap-2",children:[e.jsx("span",{className:De("flex size-5 items-center justify-center rounded-full border text-[11px] tabular-nums",x<t&&"border-transparent bg-primary text-primary-foreground",x===t&&"border-primary text-foreground",x>t&&"border-border text-muted-foreground"),children:x<t?e.jsx(We,{className:"size-3"}):x}),e.jsx("span",{className:x===t?"font-medium text-foreground":"text-muted-foreground",children:l}),o<i.length-1&&e.jsx("span",{className:"h-px w-5 bg-border","aria-hidden":!0})]},l)})})}function F({id:t,label:i,hint:l,children:o}){return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{htmlFor:t,children:i}),o,l&&e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:l})]})}function ze({children:t}){return e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:t})}function P({href:t,children:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-foreground underline underline-offset-2",children:i})}const K=t=>t instanceof Re?t.message:"Could not reach the server.";function ct({provider:t,jiraSite:i,trelloKey:l=""}){const o=t==="trello"?[e.jsxs(e.Fragment,{children:["Open ",e.jsx(P,{href:"https://trello.com/power-ups/admin",children:"Trello › Power-Ups admin"})," › New. Name it Snagset, any workspace, and tick that it does not use Power-Up capabilities. Skip the OAuth 2.0 page."]}),e.jsx(e.Fragment,{children:"Open its API key tab, generate a key, and paste the key below."}),e.jsxs(e.Fragment,{children:["On that same page, click the Token link beside the key",l.trim()?e.jsxs(e.Fragment,{children:[" ","(or ",e.jsx(P,{href:rt(l),children:"this one"}),")"]}):null,": Allow, then copy the whole token (it starts ATTA) and paste it below."]})]:t==="github"?[e.jsxs(e.Fragment,{children:["Open ",e.jsx(P,{href:"https://github.com/settings/personal-access-tokens/new",children:"GitHub › Fine-grained tokens › Generate new token"}),"."]}),e.jsx(e.Fragment,{children:"Repository access: only the site's repository. Permissions › Issues: Read and write."}),e.jsx(e.Fragment,{children:"Generate, copy the token, paste it below."})]:t==="linear"?[e.jsxs(e.Fragment,{children:["Open ",e.jsx(P,{href:"https://linear.app/settings/account/security",children:"Linear › Settings › Security & access"}),"."]}),e.jsx(e.Fragment,{children:"Under Personal API keys, make a new key. It acts as you, so you must be in the team."}),e.jsx(e.Fragment,{children:"Copy the key, paste it below."})]:[e.jsxs(e.Fragment,{children:["Open ",e.jsx(P,{href:"https://id.atlassian.com/manage-profile/security/api-tokens",children:"Atlassian account › Security › API tokens"}),"."]}),e.jsx(e.Fragment,{children:'Create API token — the plain one, not "with scopes". Name it Snagset.'}),e.jsxs(e.Fragment,{children:["Copy it, paste it below with the email you sign in to ",i?i.replace(/^https?:\/\//,""):"Jira"," with."]})];return e.jsx("ol",{className:"m-0 flex list-decimal flex-col gap-1 pl-5 text-[13px] text-muted-foreground",children:o.map((x,h)=>e.jsx("li",{children:x},h))})}function Be({provider:t,site:i,shownSecret:l,target:o,onSecret:x}){const h=me(),m=`${location.origin}/api/v1/integrations/${t}/inbound`,[j]=r.useState(()=>Date.now()),[k,A]=r.useState(""),[f,N]=r.useState(""),[T,O]=r.useState(!1),[g,$]=r.useState(null),p=ue({...Ee.integrations(),refetchInterval:3e3}).data?.data.find(w=>w.site===i&&w.provider===t),u=W({mutationFn:w=>S.setWebhookSecret(i,t,w),onSuccess:w=>{N(""),A(""),O(!0),$(w.check??null),x(w.webhook.secret??null),h.invalidateQueries({queryKey:["integrations"]}),J.success(t==="linear"?"Signing secret saved":t==="trello"?"Secret saved":"New secret made — the old one has stopped working")},onError:w=>N(K(w))}),a=p?.lastDeliveryAt?Date.parse(p.lastDeliveryAt):0,c=p?.lastRefusedAt?Date.parse(p.lastRefusedAt):0,d=(t==="linear"||t==="trello")&&p&&!p.hasWebhookSecret?"nosecret":a?"ok":c?"refused":"waiting",n=d==="ok"&&c>a,D=t==="linear"||t==="trello",H=t==="trello"||t==="linear"||t==="jira",I=H&&!!g?.sent&&d==="waiting",M=W({mutationFn:()=>S.checkWebhook(i,t),onSuccess:w=>{$(w.check),h.invalidateQueries({queryKey:["integrations"]})},onError:w=>N(K(w))}),q=g?.left?` It could not delete ${g.left} afterwards; delete it by hand.`:"",[v,E]=r.useState(!1),U=D&&(d!=="ok"||v),G=t==="github"?"GitHub sends a test delivery the moment the webhook is saved.":t==="trello"?g?.sent?`Snagset made a check card on ${o.label} and deleted it again; Trello's delivery for it confirms the secret in a moment.`:g?`Snagset could not make its check card (${g.detail}). Move any card on ${o.label} to another list once instead.`:`Saving the secret makes a check card on ${o.label} and deletes it again; Trello's delivery for it confirms the secret.`:t==="linear"?g?.sent?`Snagset made a check issue in ${o.label} and deleted it again; Linear's delivery for it confirms the secret in a moment.`:g?`Snagset could not make its check issue (${g.detail}). Move any issue in ${o.label} to another status once instead.`:`Saving the secret makes a check issue in ${o.label} and deletes it again; Linear's delivery for it confirms the secret.`:g?.sent?`Snagset made a check issue in ${o.label}, edited it and deleted it; Jira's delivery for it confirms the webhook in a moment.${q}`:g?`Snagset could not make its check issue (${g.detail}). Move any issue in ${o.label} once instead.`:`Once the webhook is created in Jira, Check it makes an issue in ${o.label}, edits it and deletes it; Jira's delivery for it confirms the webhook.`;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[f&&e.jsx(ze,{children:f}),e.jsx("ol",{className:"m-0 flex list-decimal flex-col gap-1 pl-5 text-[13px] text-muted-foreground",children:t==="github"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Open"," ",e.jsx(P,{href:o.repo?`https://github.com/${o.repo}/settings/hooks/new`:"https://github.com",children:"the repository's Settings › Webhooks › Add webhook"}),"."]}),e.jsx("li",{children:"Paste the address and the secret below; content type application/json."}),e.jsx("li",{children:'"Let me select individual events" → tick Issues only. Add webhook.'})]}):t==="trello"?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:p&&!p.webhookRegistered?`Snagset could not register the webhook on ${o.label}${o.trelloNote?`: ${o.trelloNote}`:""}. Trello must be able to reach this server's address; connect again once it can.`:`Snagset registered the webhook on ${o.label} for you: nothing to set up in Trello.`}),U&&e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Trello signs each delivery with your Power-Up's secret. Open ",e.jsx(P,{href:"https://trello.com/power-ups/admin",children:"Trello › Power-Ups admin"}),", your Power-Up's API key tab, and copy the Secret."]}),e.jsx("li",{children:"Paste it below."})]})]}):t==="linear"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Open ",e.jsx(P,{href:"https://linear.app/settings/api",children:"Linear › Settings › API"}),", then Webhooks › New webhook."]}),e.jsxs("li",{children:["Paste the address; pick the team ",o.label,"; under data change events tick Issues. Create."]}),U&&e.jsx("li",{children:"Linear shows a signing secret: copy it and paste it below."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Open"," ",e.jsx(P,{href:o.jiraSite?`${o.jiraSite}/plugins/servlet/webhooks`:"https://admin.atlassian.com",children:"Jira › Settings › System › WebHooks"})," ","› Create a WebHook. It needs a Jira admin."]}),e.jsx("li",{children:"Paste the address and the secret below."}),e.jsx("li",{children:"Under Issue, tick updated and deleted. Create."})]})}),e.jsxs("dl",{className:"m-0 grid grid-cols-[88px_minmax(0,1fr)] items-center gap-x-3 gap-y-2.5 text-[13px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Address"}),e.jsxs("dd",{className:"m-0 flex min-w-0 items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all rounded-md bg-muted px-2 py-1 font-mono text-[12px]","data-testid":"webhook-url",children:m}),e.jsx(Pe,{text:m,label:"Copy the address"})]}),t!=="linear"&&t!=="trello"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Secret"}),e.jsx("dd",{className:"m-0 flex min-w-0 items-center gap-2",children:l?e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"min-w-0 flex-1 break-all rounded-md bg-muted px-2 py-1 font-mono text-[12px]","data-testid":"webhook-secret",children:l}),e.jsx(Pe,{text:l,label:"Copy the secret"})]}):e.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2 text-muted-foreground",children:["Shown once, when it was made.",e.jsx(b,{type:"button",size:"sm",variant:"outline",loading:u.isPending,onClick:()=>u.mutate(void 0),children:"Make a new secret"})]})})]}),t==="github"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Content type"}),e.jsx("dd",{className:"m-0 font-mono text-[12px]",children:"application/json"})]})]}),l&&e.jsx("p",{className:"m-0 -mt-2 text-[12px] text-muted-foreground",children:"Copy it now: it is not shown again. A new one can be made here any time."}),U&&e.jsx(F,{id:"wb-secret",label:t==="linear"?"Signing secret":"Power-Up secret",hint:I?`Checking it with ${C[t]}…`:d==="refused"?`That secret did not match. Copy the Secret from the ${t==="linear"?"webhook in Linear":"Power-Up's API key tab"} again and paste it here.`:T||p?.hasWebhookSecret?"Saved. Paste a new one to replace it.":t==="linear"?"From the webhook Linear just made.":"Next to the API key in Trello.",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(je,{id:"wb-secret",value:k,onChange:A,placeholder:t==="linear"?"lin_wh_…":"",disabled:I})}),e.jsx(b,{type:"button",variant:"outline",disabled:!k.trim()||I,loading:u.isPending||I,onClick:()=>{E(!1),u.mutate(k.trim())},children:"Save"})]})}),e.jsxs("div",{role:"status","aria-live":"polite","data-testid":"webhook-check","data-state":d,className:De("flex items-start gap-2.5 rounded-md border px-3 py-2.5 text-[13px]",d==="ok"&&"border-emerald-500/40 bg-emerald-500/10",d==="refused"&&"border-destructive/40 bg-warn-soft",(d==="waiting"||d==="nosecret")&&"border-border bg-muted/40"),children:[d==="ok"?e.jsx(We,{className:"mt-0.5 size-4 shrink-0 text-emerald-600"}):d==="refused"?e.jsx(st,{className:"mt-0.5 size-4 shrink-0 text-destructive"}):e.jsx(Ge,{className:"mt-0.5 size-4 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none"}),e.jsx("span",{className:"min-w-0",children:d==="ok"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"The webhook works."})," Last delivery ",a>=j?"just now":B(p.lastDeliveryAt),".",D&&!v&&e.jsx("button",{type:"button",className:"ml-1 underline underline-offset-2 text-muted-foreground hover:text-foreground",onClick:()=>E(!0),children:"Replace the secret…"}),n&&e.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["A later delivery was refused (",B(p.lastRefusedAt),"): ",p.lastRefusedError," If you did not change the secret, it may not have come from ",C[t],"."]})]}):d==="refused"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"A delivery arrived and was refused"})," (",B(p.lastRefusedAt),"). ",p.lastRefusedError,e.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["A refused delivery is unsigned, so it may not be from ",C[t],". Check the delivery log on ",C[t],"'s webhook before changing anything."]})]}):d==="nosecret"?e.jsxs(e.Fragment,{children:["Waiting for the ",t==="linear"?"signing secret":"Power-Up's secret",". Without it, ",C[t],"'s deliveries are refused."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:I?t==="jira"?"Checking the webhook…":"Checking the secret…":"Waiting for the first delivery."})," ",G]})})]}),H&&p?.hasWebhookSecret&&(d==="waiting"||d==="refused")&&e.jsx("div",{className:"-mt-2 flex justify-end",children:e.jsx(b,{type:"button",size:"sm",variant:"outline",loading:M.isPending||I,disabled:I,onClick:()=>M.mutate(),children:g?"Check again":"Check it"})})]})}function dt({provider:t,open:i,onOpenChange:l,sites:o}){const x=me(),h=C[t],[m,j]=r.useState(1),[k,A]=r.useState(""),[f,N]=r.useState(""),[T,O]=r.useState(""),[g,$]=r.useState(""),[y,p]=r.useState(""),[u,a]=r.useState([]),[c,d]=r.useState({open:"",progress:"",resolved:""}),[n,D]=r.useState(""),[H,I]=r.useState(""),[M,q]=r.useState([]),[v,E]=r.useState(""),[U,G]=r.useState(""),[w,ye]=r.useState(!1),[Me,ee]=r.useState(null),[Ue,we]=r.useState(""),[ve,L]=r.useState("");r.useEffect(()=>{i||(j(1),A(""),N(""),O(""),$(""),p(""),a([]),d({open:"",progress:"",resolved:""}),D(""),I(""),q([]),E(""),G(""),ye(!1),ee(null),we(""),L(""))},[i]);const z=k||o[0]?.uid||"",Q=T.trim().replace(/\/+$/,"").replace(/^(?!https?:\/\/)/,"https://"),Ke=t==="github"?{token:f.trim()}:t==="linear"?{apiKey:f.trim()}:t==="trello"?{apiKey:y.trim(),token:f.trim()}:{siteUrl:Q,email:g.trim(),apiToken:f.trim()},Y=r.useRef(""),te=W({mutationFn:s=>S.discoverTracker("trello",{apiKey:y.trim(),token:f.trim(),boardId:s}),onSuccess:(s,R)=>{R===Y.current&&(L(""),a(s.options),d(Ie(s.options)))},onError:(s,R)=>{R===Y.current&&L(K(s))}}),[V,se]=r.useState(!1),[ne,Je]=r.useState("Snagset feedback"),Ne=W({mutationFn:s=>S.discoverTracker("trello",{apiKey:y.trim(),token:f.trim(),newBoard:s}),onSuccess:s=>{s.board&&(L(""),se(!1),q(R=>[...R,s.board]),Y.current=s.board.value,E(s.board.value),a(s.options),d(Ie(s.options)))},onError:s=>L(K(s))}),Se=s=>{if(s===le){se(!0);return}se(!1),Y.current=s,E(s),a([]),d({open:"",progress:"",resolved:""}),s&&te.mutate(s)},ae=W({mutationFn:()=>S.discoverTracker(t,Ke),onSuccess:s=>{L(""),I(s.who),q(s.options);const R=s.options.find(re=>re.canWrite!==!1)?.value??s.options[0]?.value??"";t==="trello"?Se(R):E(R),j(2)},onError:s=>L(K(s))}),oe=W({mutationFn:()=>{const s=w?"thread.created":"manual";return t==="github"?S.connectTracker(z,"github",{repository:v.trim(),token:f.trim(),labels:U.trim(),createOn:s}):t==="linear"?S.connectTracker(z,"linear",{team:v.trim(),apiKey:f.trim(),createOn:s}):t==="trello"?S.connectTracker(z,"trello",{apiKey:y.trim(),token:f.trim(),boardId:v,openList:c.open,progressList:c.progress,resolvedList:c.resolved,createOn:s}):S.connectTracker(z,"jira",{siteUrl:Q,project:v.trim(),email:g.trim(),apiToken:f.trim(),createOn:s})},onSuccess:s=>{L(""),N(""),ee(s.webhook?.secret??null),D(s.webhook?.error??""),we(z),x.invalidateQueries({queryKey:["integrations"]}),J.success(`${h} connected`),j(3)},onError:s=>L(K(s))}),Ce=!!z&&!!f.trim()&&(t!=="jira"||!!T.trim()&&!!g.trim())&&(t!=="trello"||!!y.trim()),ie=t!=="trello"||!V&&!!c.open&&!!c.progress&&!!c.resolved&&new Set([c.open,c.progress,c.resolved]).size===3,Ae=M.find(s=>s.value===v),He=Ae?.label??v;return e.jsx(pe,{open:i,onOpenChange:l,children:e.jsx(xe,{className:"sm:max-w-[560px]",children:e.jsxs("form",{className:"flex min-w-0 flex-col gap-4",noValidate:!0,onSubmit:s=>{s.preventDefault(),m===1&&Ce?ae.mutate():m===2&&v.trim()&&ie?oe.mutate():m===3&&l(!1)},children:[e.jsxs(ge,{children:[e.jsxs(fe,{children:["Connect a site to ",h]}),e.jsxs(be,{children:[m===1?`Give Snagset access to ${h}. The key is checked now and stored encrypted with this instance's secret key.`:m===2?`Signed in to ${h}${H?` as ${H}`:""}. Choose where this site's comments go.`:`Connected. Now the way back: a webhook, so that moving ${t==="trello"?"a card":"an issue"} in ${h} moves the comment here.`," ",e.jsx(P,{href:`${_e}#${t}`,children:"Step-by-step guide"})]})]}),e.jsx(lt,{at:m}),ve&&m!==3&&e.jsx(ze,{children:ve}),m===1&&e.jsxs(e.Fragment,{children:[e.jsx(F,{id:"ct-site",label:"Site",children:e.jsx(X,{id:"ct-site",value:z,onChange:A,options:o.map(s=>({value:s.uid,label:s.name}))})}),e.jsx(ct,{provider:t,jiraSite:Q,trelloKey:y}),t==="trello"&&e.jsx(F,{id:"ct-trello-key",label:"API key",children:e.jsx(_,{id:"ct-trello-key",value:y,onChange:s=>p(s.target.value),autoComplete:"off",spellCheck:!1})}),t==="jira"&&e.jsxs(e.Fragment,{children:[e.jsx(F,{id:"ct-jira-site",label:"Jira site",hint:"The address you open Jira at.",children:e.jsx(_,{id:"ct-jira-site",placeholder:"https://kilnwork.atlassian.net",value:T,onChange:s=>O(s.target.value),autoComplete:"off"})}),e.jsx(F,{id:"ct-email",label:"Account email",children:e.jsx(_,{id:"ct-email",type:"email",placeholder:"you@kilnwork.studio",value:g,onChange:s=>$(s.target.value),autoComplete:"off"})})]}),e.jsx(F,{id:"ct-token",label:t==="github"||t==="trello"?"Token":t==="linear"?"API key":"API token",children:e.jsx(je,{id:"ct-token",value:f,onChange:N,placeholder:t==="github"?"github_pat_…":t==="linear"?"lin_api_…":""})})]}),m===2&&e.jsxs(e.Fragment,{children:[M.length>0||t==="trello"?e.jsx(F,{id:"ct-target",label:Oe[t],hint:Ae?.canWrite===!1?"This token can only read that repository: give it Issues › Read and write, or pick another.":t==="jira"?"Jira calls these spaces; the key in brackets is the prefix on its issues.":void 0,children:e.jsx(X,{id:"ct-target",value:V?le:v,onChange:t==="trello"?Se:E,options:[...M.map(s=>({value:s.value,label:s.label})),...t==="trello"?[{value:le,label:"New board…"}]:[]]})}):e.jsx(F,{id:"ct-target",label:Oe[t],hint:`${h} listed nothing this key can see. Type it instead: ${t==="github"?"owner/name":"the prefix on its issues, like ENG"}.`,children:e.jsx(_,{id:"ct-target",value:v,onChange:s=>E(s.target.value),autoComplete:"off"})}),t==="trello"&&V&&e.jsx(F,{id:"ct-new-board",label:"Board name",hint:"Snagset makes it, private to you, with three lists: To do, Doing and Done.",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{id:"ct-new-board",value:ne,onChange:s=>Je(s.target.value),autoComplete:"off",className:"min-w-0 flex-1"}),e.jsx(b,{type:"button",variant:"outline",disabled:!ne.trim(),loading:Ne.isPending,onClick:()=>Ne.mutate(ne.trim()),children:"Make board"})]})}),t==="trello"&&!V&&(te.isPending?e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"Reading the board's lists…"}):u.length>0?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"A card's list is its status. Moving a card between these three moves the comment here, and back."}),[["open","Open"],["progress","In progress"],["resolved","Resolved"]].map(([s,R])=>e.jsx(F,{id:`ct-list-${s}`,label:R,children:e.jsx(X,{id:`ct-list-${s}`,value:c[s],onChange:re=>d(qe=>({...qe,[s]:re})),options:u})},s)),!ie&&e.jsx("p",{className:"m-0 text-[12px] text-destructive",children:"Pick three different lists."})]}):v?e.jsx("p",{className:"m-0 text-[13px] text-muted-foreground",children:"This board has no open lists. Add three in Trello (for example To do, Doing, Done), then pick it again."}):null),t==="github"&&e.jsx(F,{id:"ct-labels",label:"Labels",hint:"Optional, comma-separated. Put on every issue Snagset opens.",children:e.jsx(_,{id:"ct-labels",placeholder:"review",value:U,onChange:s=>G(s.target.value),autoComplete:"off"})}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md border border-border px-3 py-2.5 text-[13px]",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:w,onChange:s=>ye(s.target.checked)}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:t==="trello"?"A card for every new comment":"An issue for every new comment"}),e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:t==="trello"?"Off: you make a card from a comment's brief when you mean it. On: every new comment makes one.":"Off: you make an issue from a comment's brief when you mean it. On: every new comment opens one."})]})]})]}),m===3&&e.jsx(Be,{provider:t,site:Ue,shownSecret:Me,onSecret:ee,target:{label:He,...t==="jira"?{jiraSite:Q}:{},...t==="github"?{repo:v}:{},...t==="trello"&&n?{trelloNote:n}:{}}}),e.jsxs(ke,{children:[m===1&&e.jsxs(e.Fragment,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(b,{type:"submit",loading:ae.isPending,disabled:!Ce,children:ae.isPending?"Checking…":"Check access"})]}),m===2&&e.jsxs(e.Fragment,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>j(1),children:"Back"}),e.jsx(b,{type:"submit",loading:oe.isPending,disabled:!v.trim()||!ie||te.isPending,children:oe.isPending?"Connecting…":"Connect"})]}),m===3&&e.jsx(b,{type:"submit",children:"Done"})]})]})})})}function ht({state:t,onClose:i}){const[l,o]=r.useState(null);return r.useEffect(()=>{t||o(null)},[t]),e.jsx(pe,{open:t!==null,onOpenChange:x=>!x&&i(),children:e.jsx(xe,{className:"sm:max-w-[560px]",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs(ge,{children:[e.jsxs(fe,{children:[C[t.provider]," webhook for ",t.siteName]}),e.jsxs(be,{children:["The way back: moving ",t.provider==="trello"?"a card":"an issue"," in ",C[t.provider]," moves the comment here. ",e.jsx(P,{href:`${_e}#${t.provider}`,children:"Step-by-step guide"})]})]}),e.jsx(Be,{provider:t.provider,site:t.site,shownSecret:l,onSecret:o,target:t.target}),e.jsx(ke,{children:e.jsx(b,{type:"button",onClick:i,children:"Done"})})]})})})}const mt={ok:{label:"Healthy",tone:"ok"},needs_reauth:{label:"Needs a new token",tone:"bad"},error:{label:"Failing",tone:"bad"}};function ut(){const t=Le(),i=ce(t.user.role,"settings"),l=ce(t.user.role,"studio")&&$e(t),o=ue(Ee.integrations()),x=me(),h=()=>x.invalidateQueries({queryKey:["integrations"]}),[m,j]=r.useState(null),[k,A]=r.useState(null),[f,N]=r.useState(null),T=W({mutationFn:({uid:a,provider:c})=>S.testTracker(a,c).then(d=>({...d,provider:c})),onSuccess:a=>{J[a.ok?"success":"error"](a.ok?`${C[a.provider]} can see ${a.target}`:a.detail??`${C[a.provider]} refused the token`),h()},onError:a=>J.error(Te(a))}),O=W({mutationFn:({uid:a,provider:c})=>S.disconnectTracker(a,c),onSuccess:()=>{A(null),h()},onError:a=>J.error(Te(a))}),g=o.data?.data??[],$=a=>g.filter(c=>c.provider===a),y=t.projects.filter(a=>!a.archived&&!a.locked),p=a=>y.filter(c=>!$(a).some(d=>d.site===c.uid)),u=i?t.limits.integrations?y.length===0?"site":null:"plan":null;return e.jsxs("div",{className:"flex flex-col gap-10 p-7",children:[e.jsx(Ye,{title:"Integrations",sub:"Your coding agent first, then the trackers that mirror a comment's status, then Slack, which only announces"}),e.jsx(et,{owner:i,instanceOwner:l,operator:$e(t),sites:t.projects}),u&&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:u==="plan"?t.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.":t.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."}),u==="plan"?t.user.role==="owner"&&e.jsx(b,{variant:"outline",size:"sm",render:e.jsx(de,{to:"/studio/plan"}),children:"See plans"}):e.jsx(b,{variant:"outline",size:"sm",render:e.jsx(de,{to:"/sites"}),children:"Go to Sites"})]}),["github","linear","jira","trello","slack"].map(a=>{const c=$(a),d=p(a);return e.jsxs(Ve,{title:C[a],description:a==="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.":a==="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.":a==="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.":a==="trello"?"A comment becomes a card on the site's board, with the brief as its description. A card's list is its status: our status moves it between the three lists you pick, and moving it there moves the comment here. An API key and token from your own Power-Up; Snagset sets up the webhook.":"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:[o.isPending&&e.jsx(Xe,{rows:2}),o.isSuccess&&c.length===0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Fe,{variant:"outline",children:"Not connected"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:a==="github"?"No site is connected to a repository yet.":a==="linear"?"No site is connected to a team yet.":a==="jira"?"No site is connected to a project yet.":a==="trello"?"No site is connected to a board yet.":"No site is connected to a channel yet."})]}),c.length>0&&e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:c.map(n=>{const D=mt[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.provider==="trello"?`${n.boardName} · ${n.listNames.open} / ${n.listNames.progress} / ${n.listNames.resolved}`:`#${n.channelName} · ${n.teamName}`}),e.jsx(Fe,{variant:"outline",className:D.tone==="ok"?"border-ok text-ok":D.tone==="bad"?"border-destructive text-destructive":"",children:D.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.provider==="trello"?n.createOn==="thread.created"?"A card for every new comment":"Cards 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(", ")}`:""," · ",B(n.updatedAt)]}),n.provider!=="slack"&&e.jsx(xt,{r:n}),n.lastError&&e.jsx("span",{className:"basis-full text-[12px] text-destructive",children:n.lastError}),i&&e.jsxs("span",{className:"ml-auto flex gap-1",children:[n.provider!=="slack"&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>N({provider:n.provider,site:n.site,siteName:n.siteName??n.site,target:n.provider==="github"?{label:`${n.owner}/${n.repo}`,repo:`${n.owner}/${n.repo}`}:n.provider==="linear"?{label:n.teamName}:n.provider==="trello"?{label:n.boardName}:{label:n.projectName,jiraSite:n.siteUrl}}),children:"Webhook…"}),e.jsx(b,{variant:"ghost",size:"sm",loading:T.isPending,onClick:()=>T.mutate({uid:n.site,provider:n.provider}),children:"Test"}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>A(n),children:"Disconnect"})]})]},`${n.provider}:${n.site}`)})}),i&&!u&&d.length>0&&e.jsx("div",{children:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>j(a),children:"Connect a site…"})})]},a)}),["github","linear","jira","trello"].map(a=>e.jsx(dt,{provider:a,open:m===a,onOpenChange:c=>!c&&j(null),sites:p(a)},a)),e.jsx(pt,{open:m==="slack",onOpenChange:a=>!a&&j(null),sites:p("slack"),onDone:()=>void h()}),e.jsx(ht,{state:f,onClose:()=>N(null)}),e.jsx(Ze,{open:k!==null,onOpenChange:a=>!a&&A(null),title:`Disconnect ${k?.siteName??"this site"} from ${k?C[k.provider]:"the tracker"}?`,description:k?.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:O.isPending,onConfirm:async()=>{k&&await O.mutateAsync({uid:k.site,provider:k.provider})}})]})}function pt({open:t,onOpenChange:i,sites:l,onDone:o}){const[x,h]=r.useState(""),[m,j]=r.useState(""),[k,A]=r.useState(""),[f,N]=r.useState(!0),[T,O]=r.useState(""),g=ue({queryKey:["integrations","slack","manifest"],queryFn:()=>S.slackManifest(),enabled:t,staleTime:1/0}),$=W({mutationFn:u=>S.connectTracker(u,"slack",{channel:m.trim(),token:k.trim(),createOn:f?"thread.created":"manual"})}),y=x||l[0]?.uid||"",p=async u=>{u.preventDefault(),O("");try{await $.mutateAsync(y),j(""),A(""),N(!0),i(!1),o(y),J.success("Slack connected")}catch(a){O(a instanceof Re?a.message:"Could not reach the server.")}};return e.jsx(pe,{open:t,onOpenChange:i,children:e.jsx(xe,{children:e.jsxs("form",{onSubmit:u=>void p(u),className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(ge,{children:[e.jsx(fe,{children:"Connect a site to Slack"}),e.jsx(be,{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."})]}),T&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:T}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{htmlFor:"sl-site",children:"Site"}),e.jsx(X,{id:"sl-site",value:y,onChange:h,options:l.map(u=>({value:u.uid,label:u.name}))})]}),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(b,{type:"button",variant:"outline",size:"sm",disabled:!g.data,render:e.jsx("a",{href:g.data?.url??"#",target:"_blank",rel:"noreferrer"}),children:"Create app…"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{htmlFor:"sl-token",children:"2. Bot User OAuth Token"}),e.jsx(je,{id:"sl-token",placeholder:"xoxb-…",value:k,onChange:A}),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(Z,{htmlFor:"sl-channel",children:"3. Channel"}),e.jsx(_,{id:"sl-channel",placeholder:"#reviews",value:m,onChange:u=>j(u.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:f,onChange:u=>N(u.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(ke,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(b,{type:"submit",loading:$.isPending,disabled:!m.trim()||!k.trim()||!y,children:$.isPending?"Checking…":"Connect"})]})]})})})}function xt({r:t}){const i=C[t.provider];if(t.lastDeliveryAt){const l=t.lastRefusedAt&&Date.parse(t.lastRefusedAt)>Date.parse(t.lastDeliveryAt);return e.jsxs("span",{className:"basis-full text-[12px] text-muted-foreground",children:["Webhook works · last delivery ",B(t.lastDeliveryAt),l?` · a later one was refused ${B(t.lastRefusedAt)}`:""]})}return t.lastRefusedAt?e.jsxs("span",{className:"basis-full text-[12px] text-destructive",children:["Webhook refused ",B(t.lastRefusedAt),": ",t.lastRefusedError," Unsigned, so check ",i,"'s webhook log first."]}):t.provider==="trello"&&!t.webhookRegistered?e.jsxs("span",{className:"basis-full text-[12px] text-destructive",children:["Snagset could not register the webhook on ",t.boardName,": Trello must reach this server's address. Connect again once it can."]}):(t.provider==="linear"||t.provider==="trello")&&!t.hasWebhookSecret?e.jsxs("span",{className:"basis-full text-[12px] text-muted-foreground",children:["No webhook yet, so ",i," cannot move comments here. Webhook… sets it up."]}):e.jsx("span",{className:"basis-full text-[12px] text-muted-foreground",children:"No webhook delivery seen yet. Webhook… shows how to set it up."})}const Bt=()=>ce(Le().user.role,"settings")?e.jsx(ut,{}):e.jsx(Qe,{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(de,{to:"/you",className:"text-brand hover:underline",children:"You"}),"."]})});export{Bt as component};
@@ -0,0 +1,6 @@
1
+ import{c as U,q as P,j as e,af as W,an as X,r as g,a4 as K,B as h,_ as D,A as Z,ao as v,ap as E,aq as ee,ad as C,P as se,I as ae,ar as te,as as ie,at as ne,J as le,F as S}from"./index-BC1mWQy8.js";import{u as k}from"./useQuery-B1QbR4lk.js";import{u as re,a as oe,C as me}from"./zod-DxcG0x06.js";import{S as de,a as ce,b as xe,c as he,d as ue,P as pe}from"./Picker-CCAp0603.js";import{A as je,a as ge}from"./avatar-C272UWe3.js";import{B as ve}from"./badge-CYPTl0cy.js";import{X as fe,i as be,j as ye,l as R,k as A,m as I,n as L}from"./dialog-l22OkYXh.js";import{L as M,I as we}from"./label-Des6lF0o.js";import{T,a as $,b as f,c,d as B,e as x}from"./table-B41i9RfM.js";import{C as Ne}from"./ConfirmDialog-CHFBH7e-.js";import{C as Ce}from"./CopyButton-U3SFd-HD.js";import{u as O}from"./me-DWKKjc2l.js";import{c as Se,d as ke,e as Re,f as Ae,g as Ie}from"./studio-DxClsYRz.js";import{P as Le}from"./plus-CqHIH0K8.js";import"./useBaseQuery-Di_lHTAg.js";import"./chevron-down-Co3oKci1.js";import"./check-2F6z9BBy.js";import"./useScrollLock-DV1FkBvY.js";import"./inertValue-Dy4HJtbg.js";import"./createBaseUIEventDetails-67bayC1B.js";import"./isElementDisabled-CwHw_lZC.js";import"./serializeValue-B8e3iXO-.js";import"./useValueChanged-CxAXjLUw.js";import"./getPseudoElementBounds-D9YqITSR.js";import"./CompositeList-nzDbuttJ.js";import"./useRender-bF5mRtl9.js";import"./copy-B-mCACcx.js";/**
2
+ * @license lucide-react v1.39.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Me=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Pe=U("mail",Me);function De(){const s=O(),l=P(s.user.role,"people"),n=X(s.user.role),d=k(S.members()),a=k(S.invites()),[m,t]=g.useState(!1),r=s.limits.members.limit,i=r!==null&&s.limits.members.used>=r;return e.jsxs("div",{className:"p-7",children:[e.jsx(K,{title:"Members",sub:`${l?"Only owners change roles or remove people.":"Admins invite members. Ask an owner to change a role or remove someone."}${r!==null?` ${s.limits.members.used} of ${r} members.`:""}`,actions:n.length?e.jsxs(h,{onClick:()=>t(!0),disabled:i,title:i?`This studio's plan allows ${r} members.`:void 0,children:[e.jsx(Le,{}),"Invite"]}):void 0}),e.jsx(D,{className:"max-w-[1040px] overflow-hidden py-0",children:e.jsxs(T,{children:[e.jsx($,{children:e.jsxs(f,{children:[e.jsx(c,{children:"Name"}),e.jsx(c,{children:"Email"}),e.jsx(c,{children:"Role"}),l&&e.jsx(c,{className:"w-0"})]})}),e.jsx(B,{children:(d.data?.data??[]).map(p=>e.jsx($e,{m:p,owner:l},p.email))})]})}),e.jsx(Ee,{}),(a.data?.data.length??0)>0&&e.jsx(Te,{invites:a.data.data,roles:n}),e.jsxs("p",{className:"m-0 mt-3 max-w-[1040px] text-[12.5px] text-muted-foreground",children:["People join through an invite link and choose their own password. A forgotten one is reset on the server with ",e.jsx("code",{className:"font-mono text-[12px]",children:"snagset passwd"}),"."]}),n.length>0&&e.jsx(Oe,{open:m,onOpenChange:t,mail:a.data?.mail??!1,roles:n})]})}const _=s=>new Date(s).toLocaleDateString(void 0,{day:"numeric",month:"short"}),b={owner:"Owner",admin:"Admin",member:"Member"};function Ee(){return e.jsx("dl",{className:"m-0 mt-3 grid max-w-[1040px] grid-cols-[70px_1fr] gap-x-3 gap-y-1 text-[12.5px]","aria-label":"Roles",children:v.map(s=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"font-medium",children:b[s]}),e.jsx("dd",{className:"m-0 text-muted-foreground",children:E[s]})]},s))})}function Te({invites:s,roles:l}){const n=Re(),d=l.length>0;return e.jsxs("section",{className:"mt-6 max-w-[1040px]","aria-labelledby":"pending-invites",children:[e.jsx("div",{id:"pending-invites",className:"mb-2",children:e.jsx(ee,{children:"Pending invites"})}),e.jsx(D,{className:"overflow-hidden py-0",children:e.jsxs(T,{children:[e.jsx($,{children:e.jsxs(f,{children:[e.jsx(c,{children:"For"}),e.jsx(c,{children:"Role"}),e.jsx(c,{children:"Invited by"}),e.jsx(c,{children:"Expires"}),d&&e.jsx(c,{className:"w-0"})]})}),e.jsx(B,{children:s.map(a=>e.jsxs(f,{children:[e.jsx(x,{className:a.email?"":"text-muted-foreground",children:a.email??"Anyone with the link"}),e.jsx(x,{className:"capitalize",children:a.role}),e.jsx(x,{className:"text-muted-foreground",children:a.createdBy?a.createdBy.name||a.createdBy.email:"—"}),e.jsx(x,{className:"text-muted-foreground",children:_(a.expiresAt)}),d&&e.jsx(x,{className:"text-right",children:l.includes(a.role)&&e.jsx(h,{variant:"ghost",size:"sm","aria-label":`Revoke the invite for ${a.email??"anyone with the link"}`,disabled:n.isPending&&n.variables===a.id,onClick:()=>n.mutate(a.id),children:"Revoke"})})]},a.id))})]})})]})}function $e({m:s,owner:l}){const n=Se(),d=ke(),[a,m]=g.useState(!1);return e.jsxs(f,{children:[e.jsx(x,{children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(je,{className:"size-6",children:e.jsx(ge,{className:"bg-brand-soft text-[10px] font-semibold text-brand",children:Z(s.name,s.email)})}),e.jsx("span",{className:"font-medium",children:s.name||s.email}),s.you&&e.jsx(ve,{variant:"outline",className:"text-[11px]",children:"you"})]})}),e.jsx(x,{className:"text-muted-foreground",children:s.email}),e.jsx(x,{children:l?e.jsxs(de,{items:v.map(t=>({value:t,label:b[t]})),value:s.role,onValueChange:t=>t&&t!==s.role&&n.mutate({email:s.email,role:t}),children:[e.jsx(ce,{size:"sm","aria-label":`Role for ${s.email}`,className:"min-w-[104px] bg-card",children:e.jsx(xe,{})}),e.jsx(he,{children:v.map(t=>e.jsx(ue,{value:t,children:b[t]},t))})]}):e.jsx("span",{className:"capitalize",children:s.role})}),l&&e.jsxs(x,{className:"text-right",children:[!s.you&&e.jsx(h,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${s.email}`,onClick:()=>m(!0),children:e.jsx(fe,{})}),e.jsx(Ne,{open:a,onOpenChange:m,title:`Remove ${s.name||s.email}?`,description:"Every session of theirs ends now. Nothing they wrote is destroyed.",confirmLabel:"Remove",busy:d.isPending,onConfirm:()=>{m(!1),d.mutate(s.email)}})]})]})}const Be=ae({email:ie([ne(""),le().trim().email("An email address, or leave it empty")]),role:te(v)});function Oe({open:s,onOpenChange:l,mail:n,roles:d}){const a=Ae(),m=Ie(),[t,r]=g.useState(""),[i,p]=g.useState(null),[w,N]=g.useState(null),{register:z,handleSubmit:F,formState:j,reset:q,watch:H,control:V}=re({resolver:oe(Be),defaultValues:{role:"member",email:""}}),G=H("role"),y=o=>{l(o),o||(p(null),N(null),r(""),m.reset(),q())},Y=F(async o=>{r("");try{p(await a.mutateAsync({role:o.role,...o.email?{email:o.email}:{}}))}catch(u){r(C(u))}}),J=async()=>{if(i){r("");try{N((await m.mutateAsync({id:i.invite.id,token:i.token})).to)}catch(o){r(C(o))}}},Q=(i?.mail??n)&&!!i?.invite.email;return e.jsx(be,{open:s,onOpenChange:y,children:e.jsx(ye,{children:i?e.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[e.jsxs(R,{children:[e.jsx(A,{children:"Invite link"}),e.jsxs(I,{children:[i.invite.email?`${i.invite.email} can`:"Anyone with this link can"," join as ",se(i.invite.role)," ","until ",_(i.invite.expiresAt),". It works once, and this is the only time it is shown."]})]}),t&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1.5 font-mono text-[12px]","data-testid":"invite-url",children:i.url}),e.jsx(Ce,{text:i.url,label:"Copy link",withText:!0})]}),Q&&(w?e.jsxs("p",{role:"status",className:"m-0 text-[13px] [overflow-wrap:anywhere] text-muted-foreground",children:["Sent to ",w,"."]}):e.jsxs(h,{type:"button",variant:"outline",className:"max-w-full min-w-0 self-start",title:i.invite.email?`Send by email to ${i.invite.email}`:void 0,loading:m.isPending,onClick:()=>void J(),children:[e.jsx(Pe,{}),e.jsx("span",{className:"min-w-0 truncate",children:m.isPending?"Sending…":`Send by email to ${i.invite.email}`})]})),e.jsx(L,{children:e.jsx(h,{type:"button",onClick:()=>y(!1),children:"Done"})})]}):e.jsxs("form",{onSubmit:Y,className:"flex flex-col gap-4",noValidate:!0,children:[e.jsxs(R,{children:[e.jsx(A,{children:"Invite someone"}),e.jsx(I,{children:"You get a link to send them. Whoever opens it chooses their own name and password, and is signed in. It works once and lasts seven days."})]}),t&&e.jsx("p",{role:"alert",className:"m-0 rounded-md border border-destructive/40 bg-warn-soft px-3 py-2 text-[13px] text-destructive",children:t}),e.jsxs("fieldset",{disabled:j.isSubmitting,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(M,{htmlFor:"invite-role",children:"Role"}),e.jsx(me,{control:V,name:"role",render:({field:o})=>e.jsx(pe,{id:"invite-role",value:o.value,onChange:o.onChange,options:["member","admin","owner"].filter(u=>d.includes(u)).map(u=>({value:u,label:b[u]}))})}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground","data-testid":"invite-role-summary",children:E[G]??""})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(M,{htmlFor:"invite-email",children:["Email ",e.jsx("span",{className:"font-normal text-muted-foreground",children:"optional"})]}),e.jsx(we,{id:"invite-email",type:"email",autoComplete:"off","aria-invalid":!!j.errors.email,...z("email")}),e.jsx("p",{className:"m-0 text-[12px] text-muted-foreground",children:j.errors.email?.message??(n?"Given, only that address can use the link, and you can mail it to them.":"Given, only that address can use the link.")})]}),e.jsxs(L,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(h,{type:"submit",loading:j.isSubmitting,children:j.isSubmitting?"Creating…":"Create invite"})]})]})]})})})}const xs=()=>P(O().user.role,"settings")?e.jsx(De,{}):e.jsx(W,{title:"Members"});export{xs as component};
@@ -0,0 +1 @@
1
+ import{j as e,af as Y,au as M,r as d,p as B,d as D,F as $,a4 as K,t as U,h as m,B as P}from"./index-BC1mWQy8.js";import{u as _}from"./useQuery-B1QbR4lk.js";import{b as j}from"./InstanceRows-DPIpELtc.js";import{u as y}from"./me-DWKKjc2l.js";import{C as F}from"./check-2F6z9BBy.js";import"./useBaseQuery-Di_lHTAg.js";import"./dialog-l22OkYXh.js";import"./useScrollLock-DV1FkBvY.js";import"./inertValue-Dy4HJtbg.js";import"./createBaseUIEventDetails-67bayC1B.js";import"./label-Des6lF0o.js";import"./ConfirmDialog-CHFBH7e-.js";import"./copy-B-mCACcx.js";function L(){const s=y(),{said:r}=M.useSearch(),[a,o]=d.useState(r),[c]=d.useState(()=>Date.now()),u=B(),p=D();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(F,{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(U,{})]})}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}`,se=()=>y().user.role==="owner"?e.jsx(L,{}):e.jsx(Y,{title:"Plan & billing"});export{se as component};
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-DIf_7lV5.js";/**
1
+ import{c as t}from"./index-BC1mWQy8.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,al as re,e as se,aj as ie,E as ne,k as j,j as f,am as oe,h as de}from"./index-DIf_7lV5.js";import{f as ce,e as le,h as ue,j as fe,u as pe,A as he,k as be,l as me,c as ge,n as ve}from"./createBaseUIEventDetails-4JZNAnON.js";import{x as ke,y as xe}from"./useScrollLock-DSPnO43v.js";import{u as we}from"./useAriaLabelledBy-DWswad3y.js";import{u as ye}from"./useValueChanged-DQAqpQ0y.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:T,name:w,nativeButton:h=!1,onCheckedChange:V,readOnly:d=!1,required:b=!1,disabled:N=!1,render:ze,uncheckedValue:y,value:C,style:Ee,...A}=s,{clearErrors:H}=le(),{state:R,setTouched:q,setDirty:O,validityData:W,setFilled:v,setFocused:P,validationMode:J,disabled:U,name:Y,validation:c}=ue(),{labelId:_}=fe(),t=U||N,l=Y??w,n=i.useRef(null),G=re(n,T,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),O(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||(q(!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);V?.(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:[$,A,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
+ import{r as i,i as ae,ay as re,e as se,aw as ie,E as ne,k as j,j as f,az as oe,h as de}from"./index-BC1mWQy8.js";import{f as ce,e as le,h as ue,j as fe,u as pe,A as he,k as be,l as ge,c as me,n as ve}from"./createBaseUIEventDetails-67bayC1B.js";import{v as ke,r as xe}from"./useScrollLock-DV1FkBvY.js";import{u as we}from"./useAriaLabelledBy-hDZ_Qzgg.js";import{u as ye}from"./useValueChanged-CxAXjLUw.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:T,name:w,nativeButton:h=!1,onCheckedChange:V,readOnly:d=!1,required:b=!1,disabled:N=!1,render:Pe,uncheckedValue:y,value:C,style:Ee,...A}=s,{clearErrors:H}=le(),{state:R,setTouched:q,setDirty:O,validityData:W,setFilled:v,setFocused:z,validationMode:J,disabled:U,name:Y,validation:c}=ue(),{labelId:_}=fe(),t=U||N,l=Y??w,n=i.useRef(null),G=re(n,T,c.inputRef),g=i.useRef(null),P=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,P,a,void 0,!t,w),se(()=>{n.current&&v(n.current.checked)},[v]),ye(a,()=>{H(l),O(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:P,role:"switch","aria-checked":a,"aria-readonly":d||void 0,"aria-required":b||void 0,"aria-labelledby":Z,onFocus(){t||z(!0)},onBlur(){const e=n.current;!e||t||(q(!0),z(!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);V?.(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:[$,A,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})]})}),ze=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(ze,{"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-DIf_7lV5.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-BC1mWQy8.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-DIf_7lV5.js";import{u as c}from"./createBaseUIEventDetails-4JZNAnON.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-BC1mWQy8.js";import{u as c}from"./createBaseUIEventDetails-67bayC1B.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{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-DIf_7lV5.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{bp as N,bq as h,br as O,bs as U,bt as k,bu as B,bv as A,bw as y,bx as H,by as V,bz as M,bA as x,r as p,bB as F,d as z}from"./index-BC1mWQy8.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#n;#c;#i;#p;#u;#l;#a;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return E(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return E(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof h(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#O(),this.#t.setOptions(this.options),e._defaulted&&!O(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||h(this.options.enabled,this.#t)!==h(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return O(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(a=>{r=a,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),a(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const a=this.createResult(s,e);return r?.(a),a}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#O();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&h(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#m();const t=h(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#a=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||H.isFocused())&&this.#h()},this.#r))}#S(){this.#R(),this.#y(this.#v())}#m(){this.#a!==void 0&&(y.clearTimeout(this.#a),this.#a=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#n,a=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let n={...l},d=!1,o;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(n={...n,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=n;o=n.data;let I=!1;if(e.placeholderData!==void 0&&o===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(f=r.data,I=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",o=M(r?.data,f,e),d=!0)}if(e.select&&o!==void 0&&!I)if(r&&o===c?.data&&e.select===this.#p)o=this.#u;else try{this.#p=e.select,o=e.select(o),o=M(r?.data,o,e),this.#u=o,this.#i=null}catch(f){this.#i=f}else o===void 0&&(this.#i=null);this.#i&&(R=this.#i,o=this.#u,v=Date.now(),b="error",d=!1);const S=n.fetchStatus==="fetching",m=b==="pending",g=b==="error",T=m&&S,w=o!==void 0;return{status:b,fetchStatus:n.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:T,isLoading:T,data:o,dataUpdatedAt:n.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:n.dataUpdateCount>u.dataUpdateCount||n.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!w,isPaused:n.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&w,isStale:C(t,e),refetch:this.refetch,isEnabled:h(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#c=this.options,this.#n.data!==void 0&&(this.#l=this.#t),O(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const a=new Set(c??this.#d);return this.options.throwOnError&&a.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&a.has(l)})})();x.batch(()=>{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#O(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}};function W(t,e){return h(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&h(e.retryOnMount,t)===!1)}function Q(t,e){return W(t,e)||t.state.data!==void 0&&E(t,e,e.refetchOnMount)}function E(t,e,s){if(h(e.enabled,t)!==!1&&h(e.staleTime,t)!=="static"){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||h(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return h(e.enabled,t)!==!1&&t.isStaleByTime(h(e.staleTime,t))}const _=p.createContext(!1),j=()=>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=j(),r=J(),c=z(),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{aJ as d,r as f,al as h}from"./index-DIf_7lV5.js";import{u as p}from"./CompositeList-CeLQBvjs.js";function I(i={}){const{highlightItemOnHover:n,highlightedIndex:r,onHighlightedIndexChange:u}=d(),{ref:a,index:t}=p(i),o=r===t,s=f.useRef(null),c=h(a,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){u(t)},onMouseMove(){const e=s.current;if(!n||!e)return;const m=e.hasAttribute("disabled")||e.ariaDisabled==="true";!o&&!m&&e.focus()}},compositeRef:c,index:t}}export{I as u};
1
+ import{aW as d,r as f,ay as h}from"./index-BC1mWQy8.js";import{u as p}from"./CompositeList-nzDbuttJ.js";function I(i={}){const{highlightItemOnHover:n,highlightedIndex:r,onHighlightedIndexChange:u}=d(),{ref:a,index:t}=p(i),o=r===t,s=f.useRef(null),c=h(a,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){u(t)},onMouseMove(){const e=s.current;if(!n||!e)return;const m=e.hasAttribute("disabled")||e.ariaDisabled==="true";!o&&!m&&e.focus()}},compositeRef:c,index:t}}export{I as u};
@@ -0,0 +1 @@
1
+ import{u as r,Q as u}from"./useBaseQuery-Di_lHTAg.js";function a(e,s){return r(e,u)}export{a as u};
@@ -0,0 +1 @@
1
+ import{k as n}from"./index-BC1mWQy8.js";function u(e){return n(e.defaultTagName??"div",e,e)}export{u};
@@ -0,0 +1 @@
1
+ import{j as Dt,b as Tn,T as bt,t as Rn,d as vn,r as he,a as xn,u as Cn,p as In}from"./inertValue-Dy4HJtbg.js";import{aS as te,l as ve,b5 as se,bj as ct,b0 as Ht,av as De,e as D,r as a,j as ne,ax as Vt,n as ut,E as Be,f as U,bk as On,k as wn,ay as mt,g as Ue,aU as qe,aV as Pn,bl as kn,bm as Fn,bn as An,b6 as Mn}from"./index-BC1mWQy8.js";import{a as w,o as W,m as pe,c as xe,x as Wt,w as at,b as _t,s as Bt,g as Se,t as jt,q as Yt,n as Nn,p as Ln}from"./createBaseUIEventDetails-67bayC1B.js";function Dn(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:Hn,platform:Vn,maxTouchPoints:Wn}=Dn(),Xe=Hn.toLowerCase(),Ne=Vn.toLowerCase(),lt=/^i(os$|p)/.test(Ne)||Ne==="macintel"&&Wn>1,yt="android",tt=Ne===yt||Xe.includes(yt),_n=!lt&&Ne.startsWith("mac");Ne.startsWith("win");const Bn=_n||lt,Ie=typeof CSS<"u"&&!!CSS.supports?.("-webkit-backdrop-filter:none");!Ie&&Xe.includes("firefox");!Ie&&Xe.includes("chrom");const jn=Bn,Gt=/jsdom|happydom/.test(Xe),nt="data-base-ui-focusable",Ut="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Xr="ArrowLeft",Kr="ArrowRight",$r="ArrowUp",qr="ArrowDown";function zr(e,t){if(!ve(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute("data-trigger-disabled");for(const[,r]of t.entries())if(w(r,n))return!r.hasAttribute("data-trigger-disabled");return!1}function ze(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Yn(e){return e.matches("html,body")}function Xt(e){return te(e)&&e.matches(Ut)}function Jr(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Ut}`)!=null}function Et(e){return e?e.getAttribute("role")==="combobox"&&Xt(e):!1}function Qr(e){if(!e||Gt)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function St(e){return e?e.hasAttribute(nt)?e:e.querySelector(`[${nt}]`)||e:null}function Le(e,t,n=!0){return e.filter(s=>s.parentId===t).flatMap(s=>[...!n||s.context?.open?[s]:[],...Le(e,s.id,n)])}function Tt(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(o=>o.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function Gn(e){e.preventDefault(),e.stopPropagation()}function Un(e){return"nativeEvent"in e}function Xn(e){return e.pointerType===""&&e.isTrusted?!0:tt&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Kn(e){return Gt?!1:!tt&&e.width===0&&e.height===0||tt&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function Zr(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function $n(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const qn='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function zn(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return ct(n)?n.host:null}function rt(e){for(const t of Array.from(e.children))if(se(t)==="summary")return t;return null}function Jn(e,t){const n=rt(t);return!!n&&(e===n||w(n,e))}function Kt(e){const t=e?se(e):"";return e!=null&&e.matches(qn)&&(t!=="summary"||e.parentElement!=null&&se(e.parentElement)==="details"&&rt(e.parentElement)===e)&&(t!=="details"||rt(e)==null)&&(t!=="input"||e.type!=="hidden")}function $t(e){if(!Kt(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=zn(t)){const n=t!==e,r=se(t)==="slot";if(t.hasAttribute("inert")||n&&se(t)==="details"&&!t.open&&!Jn(e,t)||t.hasAttribute("hidden")||!r&&!Qn(t,n))return!1}return!0}function Qn(e,t){const n=Ht(e);return t?n.display!=="none":Dt(e,n)}function qt(e){const t=e.tabIndex;if(t<0){const n=se(e);if(n==="details"||n==="audio"||n==="video"||te(e)&&e.isContentEditable)return 0}return t}function Je(e){if(se(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function Zn(e,t){const n=Je(e);if(!n)return!0;const r=t.find(s=>{const o=Je(s);return o?.name===n.name&&o.form===n.form&&o.checked});return r?r===n:t.find(s=>{const o=Je(s);return o?.name===n.name&&o.form===n.form})===n}function zt(e){if(te(e)&&se(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return te(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Jt(e,t){zt(e).forEach(n=>{Kt(n)&&t.push(n),Jt(n,t)})}function Qt(e,t,n){zt(e).forEach(r=>{te(r)&&r.matches(t)&&n.push(r),Qt(r,t,n)})}function ft(e){return $t(e)&&qt(e)>=0}function Zt(e){const t=[];return Jt(e,t),t.filter($t)}function He(e){const t=Zt(e);return t.filter(n=>qt(n)>=0&&Zn(n,t))}function en(e,t){const n=He(e),r=n.length;if(r===0)return;const s=pe(W(e)),o=n.indexOf(s),i=o===-1?t===1?0:r-1:o+t;return n[i]}function tn(e){return en(W(e).body,1)||e}function nn(e){return en(W(e).body,-1)||e}function rn(e,t){if(!e)return null;const n=He(W(e).body),r=n.length;if(r===0)return null;const s=n.indexOf(e);if(s===-1)return null;const o=(s+t+r)%r;return n[o]}function es(e){return rn(e,1)}function ts(e){return rn(e,-1)}function Me(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!w(n,r)}function er(e){He(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Rt(e){const t=[];Qt(e,"[data-tabindex]",t),t.forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const Fe=0;class Te{static create(){return new Te}currentId=Fe;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Fe,n()},t)}isStarted(){return this.currentId!==Fe}clear=()=>{this.currentId!==Fe&&(clearTimeout(this.currentId),this.currentId=Fe)};disposeEffect=()=>this.clear}function je(){const e=De(Te.create).current;return Tn(e.disposeEffect),e}(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=bt.startingStyle]="startingStyle",e[e.endingStyle=bt.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({});const tr={"data-popup-open":""},nr={"data-popup-open":"","data-pressed":""},rr={"data-open":""},sr={"data-closed":""},or={"data-anchor-hidden":""},ns={open(e){return e?tr:null}},rs={open(e){return e?nr:null}},ir={open(e){return e?rr:sr},anchorHidden(e){return e?or:null}},ss={...ir,...Rn};function P(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Ce(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}function We(e){const t=De(cr,e).current;return t.next=e,D(t.effect),t}function cr(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}const sn={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},ur={...sn,position:"fixed",top:0,left:0},os={...sn,position:"absolute"},Ye=a.forwardRef(function(t,n){const[r,s]=a.useState();D(()=>{jn&&Ie&&s("button")},[]);const o={tabIndex:0,role:r};return ne.jsx("span",{...t,ref:n,style:ur,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});function Ge(e){return`data-base-ui-${e}`}let _e=0;function Qe(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:s}=t;cancelAnimationFrame(_e);function o(){s&&!s()||e?.focus({preventScroll:n})}if(r)return o(),Vt;const i=requestAnimationFrame(o);return _e=i,()=>{_e===i&&(cancelAnimationFrame(i),_e=0)}}const Ze={inert:new WeakMap,"aria-hidden":new WeakMap},vt="data-base-ui-inert",st={inert:new WeakSet,"aria-hidden":new WeakSet};let Ae=new WeakMap,et=0;function ar(e){return st[e]}function on(e){return e?ct(e)?e.host:on(e.parentNode):null}const xt=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=on(n);return e.contains(r)?r:null}).filter(n=>n!=null),Ct=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},It=(e,t,n)=>{const r=[],s=o=>{!o||n.has(o)||Array.from(o.children).forEach(i=>{se(i)!=="script"&&(t.has(i)?s(i):r.push(i))})};return s(e),r};function lr(e,t,n,r,{mark:s=!0}){let o=null;r?o="inert":n&&(o="aria-hidden");let i=null,u=null;const p=xt(t,e),c=s?It(t,Ct(p),new Set(p)):[],y=[],C=[];if(o){const d=Ze[o],g=ar(o);u=g,i=d;const v=xt(t,Array.from(t.querySelectorAll("[aria-live]"))),k=p.concat(v);It(t,Ct(k),new Set(k)).forEach(R=>{const b=R.getAttribute(o),q=b!==null&&b!=="false",V=(d.get(R)||0)+1;d.set(R,V),y.push(R),V===1&&q&&g.add(R),q||R.setAttribute(o,o==="inert"?"":"true")})}return s&&c.forEach(d=>{const g=(Ae.get(d)||0)+1;Ae.set(d,g),C.push(d),g===1&&d.setAttribute(vt,"")}),et+=1,()=>{i&&y.forEach(d=>{const v=(i.get(d)||0)-1;i.set(d,v),v||(!u?.has(d)&&o&&d.removeAttribute(o),u?.delete(d))}),s&&C.forEach(d=>{const g=(Ae.get(d)||0)-1;Ae.set(d,g),g||d.removeAttribute(vt)}),et-=1,et||(Ze.inert=new WeakMap,Ze["aria-hidden"]=new WeakMap,st.inert=new WeakSet,st["aria-hidden"]=new WeakSet,Ae=new WeakMap)}}function Ot(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:s=!0}=t,o=W(e[0]).body;return lr(e,o,n,r,{mark:s})}const is=500,cs=500,us={style:{transition:"none"}},fr="data-base-ui-click-trigger",as={fallbackAxisSide:"none"},ls={fallbackAxisSide:"end"},dr={clipPath:"inset(50%)",position:"fixed",top:0,left:0},cn=a.createContext(null),un=()=>a.useContext(cn),pr=Ge("portal");function gr(e={}){const{ref:t,container:n,componentProps:r=Be,elementProps:s}=e,o=at(),u=un()?.portalNode,[p,c]=a.useState(null),[y,C]=a.useState(null),d=U(S=>{S!==null&&C(S)}),g=a.useRef(null);D(()=>{if(n===null){g.current&&(g.current=null,C(null),c(null));return}const S=(n&&(On(n)?n:n.current))??u??document.body;if(S==null){g.current&&(g.current=null,C(null),c(null));return}g.current!==S&&(g.current=S,C(null),c(S))},[n,u]);const v=wn("div",r,{ref:[t,d],props:[{id:o,[pr]:""},s]}),k=p&&v?ut.createPortal(v,p):null;return{node:y,nodeId:a.isValidElement(v)?v.props.id:void 0,subtree:k}}const fs=a.forwardRef(function(t,n){const{render:r,className:s,style:o,children:i,container:u,...p}=t,{node:c,nodeId:y,subtree:C}=gr({container:u,ref:n,componentProps:t,elementProps:p}),d=a.useRef(null),g=a.useRef(null),v=a.useRef(null),k=a.useRef(null),[S,R]=a.useState(null),b=a.useRef(!1),q=S?.modal,V=S?.open,Y=!!S&&!S.modal&&S.open&&!!c;a.useEffect(()=>{if(!c||q)return;function F(G){c&&G.relatedTarget&&Me(G)&&(G.type==="focusin"?b.current&&(Rt(c),b.current=!1):(er(c),b.current=!0))}return Ce(P(c,"focusin",F,!0),P(c,"focusout",F,!0))},[c,q]),D(()=>{!c||V!==!0||!b.current||(Rt(c),b.current=!1)},[V,c]);const z=a.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:g,beforeInsideRef:v,afterInsideRef:k,portalNode:c,setFocusManagerState:R}),[c]);return ne.jsxs(a.Fragment,{children:[C,ne.jsxs(cn.Provider,{value:z,children:[Y&&c&&ne.jsx(Ye,{"data-type":"outside",ref:d,onFocus:F=>{if(Me(F,c))v.current?.focus();else{const G=S?S.domReference:null;nn(G)?.focus()}}}),Y&&c&&ne.jsx("span",{"aria-owns":y,style:dr}),c&&ut.createPortal(i,c),Y&&c&&ne.jsx(Ye,{"data-type":"outside",ref:g,onFocus:F=>{if(Me(F,c))k.current?.focus();else{const G=S?S.domReference:null;tn(G)?.focus(),S?.closeOnFocusOut&&S?.onOpenChange(!1,xe(Wt,F.nativeEvent))}}})]})]})});function an(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class hr{nodesRef={current:[]};events=an();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const ln=a.createContext(null),fn=a.createContext(null),dt=()=>a.useContext(ln)?.id||null,pt=e=>{const t=a.useContext(fn);return e??t};function ds(e){const t=at(),n=pt(e),r=dt();return D(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function ps(e){const{children:t,id:n}=e,r=dt();return ne.jsx(ln.Provider,{value:a.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function gs(e){const{children:t,externalTree:n}=e,r=De(()=>n??new hr).current;return ne.jsx(fn.Provider,{value:r,children:t})}function br(e,t){const n=Ue(Se(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const wt=20;let be=[];function gt(){be=be.filter(e=>e.deref()?.isConnected)}function Pt(e){gt(),e&&se(e)!=="body"&&(be.push(new WeakRef(e)),be.length>wt&&(be=be.slice(-wt)))}function kt(){return gt(),be[be.length-1]?.deref()}function mr(e){return e?ft(e)?e:He(e)[0]||e:null}function Ft(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;const n=Zt(e).filter(s=>{const o=s.getAttribute("data-tabindex")||"";return ft(s)||s.hasAttribute("data-tabindex")&&!o.startsWith("-")}),r=e.getAttribute("tabindex");n.length===0?r!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(r!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function hs(e){const{context:t,children:n,disabled:r=!1,initialFocus:s=!0,returnFocus:o=!0,restoreFocus:i=!1,modal:u=!0,closeOnFocusOut:p=!0,openInteractionType:c="",nextFocusableElement:y,previousFocusableElement:C,beforeContentFocusGuardRef:d,externalTree:g,getInsideElements:v}=e,k="rootStore"in t?t.rootStore:t,S=k.useState("open"),R=k.useState("domReferenceElement"),b=k.useState("floatingElement"),{events:q,dataRef:V}=k.context,Y=U(()=>V.current.floatingContext?.nodeId),z=s===!1,F=Et(R)&&z,G=We(s),M=We(o),J=We(c),Oe=We(S),_=pt(g),x=un(),j=a.useRef(!1),ae=a.useRef(!1),oe=a.useRef(!1),ie=a.useRef(null),me=a.useRef(""),ge=a.useRef(""),ye=a.useRef(null),Re=a.useRef(null),I=mt(ye,d,x?.beforeInsideRef),Q=mt(Re,x?.afterInsideRef),le=je(),fe=je(),we=vn(),Ve=x!=null,E=St(b),ce=U((T=E)=>T?He(T):[]),re=U(()=>v?.().filter(T=>T!=null)??[]);a.useEffect(()=>{if(r||!u)return;function T(B){B.key==="Tab"&&w(E,pe(W(E)))&&ce().length===0&&!F&&Gn(B)}const L=W(E);return P(L,"keydown",T)},[r,E,u,F,ce]),a.useEffect(()=>{if(r||!S)return;const T=W(E);function L(){oe.current=!1}function B(Z){const m=Se(Z),A=re(),h=w(b,m)||w(R,m)||w(x?.portalNode,m)||A.some(H=>H===m||w(H,m));oe.current=!h,ge.current=Z.pointerType||"keyboard",m?.closest(`[${fr}]`)&&(ae.current=!0,fe.start(0,()=>{ae.current=!1}))}function X(){ge.current="keyboard"}return Ce(P(T,"pointerdown",B,!0),P(T,"pointerup",L,!0),P(T,"pointercancel",L,!0),P(T,"keydown",X,!0),L)},[r,b,R,E,S,x,fe,re]),a.useEffect(()=>{if(r||!p)return;const T=W(E);function L(){ae.current=!0,fe.start(0,()=>{ae.current=!1})}function B(A){const h=Se(A);ft(h)&&(ie.current=h)}function X(A){const h=A.relatedTarget,H=A.currentTarget,K=Se(A);u&&h==null&&K!=null&&w(b,K)&&Pt(K),queueMicrotask(()=>{const N=Y(),ee=k.context.triggerElements,l=re(),f=h?.hasAttribute(Ge("focus-guard"))&&[ye.current,Re.current,x?.beforeInsideRef.current,x?.afterInsideRef.current,x?.beforeOutsideRef.current,x?.afterOutsideRef.current,he(C),he(y)].includes(h),$=!(w(R,h)||w(b,h)||w(h,b)||w(x?.portalNode,h)||l.some(O=>O===h||w(O,h))||ee.hasMatchingElement(O=>w(O,h))||f||_&&(Le(_.nodesRef.current,N).find(O=>w(O.context?.elements.floating,h)||w(O.context?.elements.domReference,h))||Tt(_.nodesRef.current,N).find(O=>[O.context?.elements.floating,St(O.context?.elements.floating)].includes(h)||O.context?.elements.domReference===h)));if(H===R&&E&&Ft(E),i&&H!==R&&!Dt(K)&&pe(T)===T.body){if(te(E)&&(E.focus(),i==="popup")){we.request(()=>{E.focus()});return}const O=ce(),de=ie.current,Pe=(de&&O.includes(de)?de:null)||O[O.length-1]||E;te(Pe)&&Pe.focus()}if(V.current.insideReactTree){V.current.insideReactTree=!1;return}(F||!u)&&h&&$&&!ae.current&&(F||h!==kt())&&(j.current=!0,k.setOpen(!1,xe(Wt,A)))})}function Z(){oe.current||(V.current.insideReactTree=!0,le.start(0,()=>{V.current.insideReactTree=!1}))}const m=te(R)?R:null;if(!(!b&&!m))return Ce(m&&P(m,"focusout",X),m&&P(m,"pointerdown",L),b&&P(b,"focusin",B),b&&P(b,"focusout",X),b&&x&&P(b,"focusout",Z,!0))},[r,R,b,E,u,_,x,k,p,i,ce,F,Y,V,le,fe,we,y,C,re]),a.useEffect(()=>{if(r||!b||!S)return;const T=Array.from(x?.portalNode?.querySelectorAll(`[${Ge("portal")}]`)||[]),B=(_?Tt(_.nodesRef.current,Y()):[]).find(H=>Et(H.context?.elements.domReference||null))?.context?.elements.domReference,Z=[...[b,...T,ye.current,Re.current,x?.beforeOutsideRef.current,x?.afterOutsideRef.current,...re()],B,he(C),he(y),F?R:null].filter(H=>H!=null),m=Ot(Z,{ariaHidden:u||F,mark:!1}),A=[b,...T].filter(H=>H!=null),h=Ot(A);return()=>{h(),m()}},[S,r,R,b,u,x,F,_,Y,y,C,re]),D(()=>{if(!S||r||!te(E))return;me.current="",ge.current="";const T=W(E),L=pe(T);queueMicrotask(()=>{const B=G.current,X=typeof B=="function"?B(J.current||""):B;if(X===void 0||X===!1||w(E,L))return;let m=null;const A=()=>(m==null&&(m=ce(E)),m[0]||E);let h;X===!0||X===null?h=A():h=he(X),h=h||A();const H=w(E,pe(T));Qe(h,{preventScroll:h===E,shouldFocus(){if(!Oe.current)return!1;if(H)return!0;const K=pe(T);return!(K!==h&&w(E,K))}})})},[r,S,E,ce,G,J,Oe]),D(()=>{if(r||!E)return;const T=W(E),L=pe(T),B=J.current==null;Pt(L);function X(m){if(m.open||(me.current=br(m.nativeEvent,ge.current)),m.reason===_t&&m.nativeEvent.type==="mouseleave"&&(j.current=!0),m.reason===Bt)if(m.nested)j.current=!1;else if(Xn(m.nativeEvent)||Kn(m.nativeEvent))j.current=!1;else{let A=!1;W(E).createElement("div").focus({get preventScroll(){return A=!0,!1}}),A?j.current=!1:j.current=!0}}q.on("openchange",X);function Z(m){const A=M.current;let h=typeof A=="function"?A(m):A;if(h===void 0||h===!1)return null;h===null&&(h=!0);const H=R?.isConnected?R:null,K=L?.isConnected&&se(L)!=="body"?L:null;let N=B?K||H:H||K;return N||(N=kt()||null),typeof h=="boolean"?N:he(h)||N||null}return()=>{q.off("openchange",X);const m=pe(T),A=re(),h=w(b,m)||A.some(ee=>ee===m||w(ee,m))||_&&Le(_.nodesRef.current,Y(),!1).some(ee=>w(ee.context?.elements.floating,m)),H=M.current,K=me.current,N=Z(K);queueMicrotask(()=>{const ee=mr(N),l=typeof H!="boolean";if(H&&!j.current&&te(ee)&&(!(!l&&ee!==m&&m!==T.body)||h)){const f={preventScroll:!0};K==="keyboard"&&(f.focusVisible=!0),ee.focus(f)}j.current=!1})}},[r,b,E,M,J,q,_,R,Y,re]),D(()=>{if(!Ie||S||!b)return;const T=pe(W(b));!te(T)||!Xt(T)||w(b,T)&&T.blur()},[S,b]),D(()=>{if(!(r||!x))return x.setFocusManagerState({modal:u,closeOnFocusOut:p,open:S,onOpenChange:k.setOpen,domReference:R}),()=>{x.setFocusManagerState(null)}},[r,x,u,S,k,p,R]),D(()=>{if(!(r||!E))return Ft(E),()=>{queueMicrotask(gt)}},[r,E]);const Ee=!r&&(u?!F:!0)&&(Ve||u);return ne.jsxs(a.Fragment,{children:[Ee&&ne.jsx(Ye,{"data-type":"inside",ref:I,onFocus:T=>{if(u){const L=ce();Qe(L[L.length-1])}else x?.portalNode&&(j.current=!1,Me(T,x.portalNode)?tn(R)?.focus():he(C??x.beforeOutsideRef)?.focus())}}),n,Ee&&ne.jsx(Ye,{"data-type":"inside",ref:Q,onFocus:T=>{u?Qe(ce()[0]):x?.portalNode&&(p&&(j.current=!0),Me(T,x.portalNode)?nn(R)?.focus():he(y??x.afterOutsideRef)?.focus())}})]})}function yr(){return!1}function Er(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function bs(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:s=!0,outsidePressEvent:o="sloppy",referencePress:i=yr,bubbles:u,externalTree:p}=t,c="rootStore"in e?e.rootStore:e,y=c.useState("open"),C=c.useState("floatingElement"),{dataRef:d}=c.context,g=pt(p),v=U(typeof s=="function"?s:()=>!1),k=typeof s=="function"?v:s,S=k!==!1,R=U(()=>o),{escapeKey:b,outsidePress:q}=Er(u),V=a.useRef(!1),Y=a.useRef(!1),z=a.useRef(!1),F=a.useRef(!1),G=a.useRef(""),M=a.useRef(null),J=je(),Oe=je(),_=U(()=>{Oe.clear(),d.current.insideReactTree=!1}),x=U(I=>{const Q=d.current.floatingContext?.nodeId;return(g?Le(g.nodesRef.current,Q):[]).some(fe=>fe.context?.open&&!fe.context.dataRef.current[I])}),j=U(I=>ze(I,c.select("floatingElement"))||ze(I,c.select("domReferenceElement"))),ae=U(I=>{i()&&c.setOpen(!1,xe(jt,I.nativeEvent))}),oe=U(I=>{if(!y||!n||!r||I.key!=="Escape"||F.current||!b&&x("__escapeKeyBubbles"))return;const Q=Un(I)?I.nativeEvent:I,le=xe(Yt,Q);c.setOpen(!1,le),le.isCanceled||I.preventDefault(),!b&&!le.isPropagationAllowed&&I.stopPropagation()}),ie=U(()=>{d.current.insideReactTree=!0,Oe.start(0,_)}),me=U(I=>{if(!y||!n||I.button!==0)return;const Q=Se(I.nativeEvent);w(c.select("floatingElement"),Q)&&(V.current||(V.current=!0,Y.current=!1))}),ge=U(I=>{!y||!n||(I.defaultPrevented||I.nativeEvent.defaultPrevented)&&V.current&&(Y.current=!0)});a.useEffect(()=>{if(!y||!n)return _;d.current.__escapeKeyBubbles=b,d.current.__outsidePressBubbles=q;const I=new Te,Q=new Te;function le(){I.clear(),F.current=!0}function fe(){I.start(Ie?5:0,()=>{F.current=!1})}function we(){z.current=!0,Q.start(0,()=>{z.current=!1})}function Ve(){V.current=!1,Y.current=!1}function E(){const l=G.current,f=l==="pen"||!l?"mouse":l,$=R(),O=typeof $=="function"?$():$;return typeof O=="string"?O:O[f]}function ce(l){const f=E();return f==="intentional"&&l.type!=="click"||f==="sloppy"&&l.type==="click"}function re(l){const f=d.current.floatingContext?.nodeId,$=g&&Le(g.nodesRef.current,f).some(O=>ze(l,O.context?.elements.floating));return j(l)||$}function Ee(l){if(ce(l)){l.type!=="click"&&!j(l)&&(Q.clear(),z.current=!1),_();return}if(d.current.insideReactTree){_();return}const f=Se(l),$=`[${Ge("inert")}]`,O=ve(f)?f.getRootNode():null,de=Array.from((ct(O)?O:W(c.select("floatingElement"))).querySelectorAll($)),Pe=c.context.triggerElements;if(f&&(Pe.hasElement(f)||Pe.hasMatchingElement(ue=>w(ue,f))))return;let ke=ve(f)?f:null;for(;ke&&!qe(ke);){const ue=Pn(ke);if(qe(ue)||!ve(ue))break;ke=ue}if(!(de.length&&ve(f)&&!Yn(f)&&!w(f,c.select("floatingElement"))&&de.every(ue=>!w(ke,ue)))){if(te(f)&&!("touches"in l)){const ue=qe(f),$e=Ht(f),ht=/auto|scroll/,gn=ue||ht.test($e.overflowX),hn=ue||ht.test($e.overflowY),bn=gn&&f.clientWidth>0&&f.scrollWidth>f.clientWidth,mn=hn&&f.clientHeight>0&&f.scrollHeight>f.clientHeight,yn=$e.direction==="rtl",En=mn&&(yn?l.offsetX<=f.offsetWidth-f.clientWidth:l.offsetX>f.clientWidth),Sn=bn&&l.offsetY>f.clientHeight;if(En||Sn)return}if(!re(l)){if(E()==="intentional"&&z.current){Q.clear(),z.current=!1;return}typeof k=="function"&&!k(l)||x("__outsidePressBubbles")||(c.setOpen(!1,xe(Bt,l)),_())}}}function T(l){E()!=="sloppy"||l.pointerType==="touch"||!c.select("open")||!n||j(l)||Ee(l)}function L(l){if(E()!=="sloppy"||!c.select("open")||!n||j(l))return;const f=l.touches[0];f&&(M.current={startTime:Date.now(),startX:f.clientX,startY:f.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},J.start(1e3,()=>{M.current&&(M.current.dismissOnTouchEnd=!1,M.current.dismissOnMouseDown=!1)}))}function B(l,f){const $=Se(l);if(!$)return;const O=P($,l.type,()=>{f(l),O()})}function X(l){G.current="touch",B(l,L)}function Z(l){J.clear(),l.type==="pointerdown"&&(G.current=l.pointerType),!(l.type==="mousedown"&&M.current&&!M.current.dismissOnMouseDown)&&B(l,f=>{f.type==="pointerdown"?T(f):Ee(f)})}function m(l){if(!V.current)return;const f=Y.current;if(Ve(),E()==="intentional"){if(l.type==="pointercancel"){f&&we();return}if(!re(l)){if(f){we();return}typeof k=="function"&&!k(l)||(Q.clear(),z.current=!0,_())}}}function A(l){if(E()!=="sloppy"||!M.current||j(l))return;const f=l.touches[0];if(!f)return;const $=Math.abs(f.clientX-M.current.startX),O=Math.abs(f.clientY-M.current.startY),de=Math.sqrt($*$+O*O);de>5&&(M.current.dismissOnTouchEnd=!0),de>10&&(Ee(l),J.clear(),M.current=null)}function h(l){B(l,A)}function H(l){E()!=="sloppy"||!M.current||j(l)||(M.current.dismissOnTouchEnd&&Ee(l),J.clear(),M.current=null)}function K(l){B(l,H)}const N=W(C),ee=Ce(r&&Ce(P(N,"keydown",oe),P(N,"compositionstart",le),P(N,"compositionend",fe)),S&&Ce(P(N,"click",Z,!0),P(N,"pointerdown",Z,!0),P(N,"pointerup",m,!0),P(N,"pointercancel",m,!0),P(N,"mousedown",Z,!0),P(N,"mouseup",m,!0),P(N,"touchstart",X,!0),P(N,"touchmove",h,!0),P(N,"touchend",K,!0)));return()=>{ee(),I.clear(),Q.clear(),Ve(),z.current=!1,_()}},[d,C,r,S,k,y,n,b,q,oe,_,R,x,j,g,c,J]);const ye=a.useMemo(()=>({onKeyDown:oe,onPointerDown:ae,onClick:ae}),[oe,ae]),Re=a.useMemo(()=>({onKeyDown:oe,onPointerDown:ge,onMouseDown:ge,onClickCapture:ie,onMouseDownCapture(I){ie(),me(I)},onPointerDownCapture(I){ie(),me(I)},onMouseUpCapture:ie,onTouchEndCapture:ie,onTouchMoveCapture:ie}),[oe,ie,me,ge]);return a.useMemo(()=>n?{reference:ye,floating:Re,trigger:ye}:{},[n,ye,Re])}var dn=kn();const ot=[];let it;function Sr(){return it}function Tr(e){ot.push(e)}function Rr(e){const t=(n,r)=>{const s=De(vr).current;let o;try{it=s;for(const i of ot)i.before(s);o=e(n,r);for(const i of ot)i.after(s);s.didInitialize=!0}finally{it=void 0}return o};return t.displayName=e.displayName||e.name,t}function ms(e){return a.forwardRef(Rr(e))}function vr(){return{didInitialize:!1}}const xr=Fn(19),Cr=xr?Or:wr;function pn(e,t,n,r,s){return Cr(e,t,n,r,s)}function Ir(e,t,n,r,s){const o=a.useCallback(()=>t(e.getSnapshot(),n,r,s),[e,t,n,r,s]);return dn.useSyncExternalStore(e.subscribe,o,o)}Tr({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],s=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,s)||(t=!0,r.value=s)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const s of e.syncHooks)n.add(s.store);const r=[];for(const s of n)r.push(s.subscribe(t));return()=>{for(const s of r)s()}}),dn.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Or(e,t,n,r,s){const o=Sr();if(!o)return Ir(e,t,n,r,s);const i=o.syncIndex;o.syncIndex+=1;let u;return o.didInitialize?(u=o.syncHooks[i],(u.store!==e||u.selector!==t||!Object.is(u.a1,n)||!Object.is(u.a2,r)||!Object.is(u.a3,s))&&(u.store!==e&&(o.didChangeStore=!0),u.store=e,u.selector=t,u.a1=n,u.a2=r,u.a3=s,u.value=t(e.getSnapshot(),n,r,s))):(u={store:e,selector:t,a1:n,a2:r,a3:s,value:t(e.getSnapshot(),n,r,s)},o.syncHooks.push(u)),u.value}function wr(e,t,n,r,s){return An.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,r,s))}class Pr{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,r,s){return pn(this,t,n,r,s)}}class kr extends Pr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}useSyncedValue(t,n){a.useDebugValue(t);const r=this;D(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(t,n){const r=this;D(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);D(()=>{n.update(t)},[n,...r])}useControlledProp(t,n){a.useDebugValue(t);const r=this,s=n!==void 0;D(()=>{s&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,s])}select(t,n,r,s){const o=this.selectors[t];return o(this.state,n,r,s)}useState(t,n,r,s){return a.useDebugValue(t),pn(this,this.selectors[t],n,r,s)}useContextCallback(t,n){a.useDebugValue(t);const r=U(n??Vt);this.context[t]=r}useStateSetter(t){const n=a.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let s=r(this.state);return n(s,s,this),this.subscribe(o=>{const i=r(o);if(!Object.is(s,i)){const u=s;s=i,n(i,u,this)}})}}const Fr={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};class Ar extends kr{constructor(t){const{syncOnly:n,nested:r,onOpenChange:s,triggerElements:o,...i}=t;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:an(),nested:r,triggerElements:o},Fr),this.syncOnly=n}syncOpenEvent=(t,n)=>{(!t||!this.state.open||n!=null&&$n(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)};dispatchOpenChange=(t,n)=>{this.syncOpenEvent(t,n.event);const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)};setOpen=(t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)}}function Mr(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:s,nested:o,onOpenChange:i}=e,u=t.useState("open"),p=t.useState("activeTriggerElement"),c=t.useState(n?"popupElement":"positionerElement"),y=t.context.triggerElements,C=i,d=a.useRef(null);r===void 0&&d.current===null&&(d.current=new Ar({open:u,transitionStatus:void 0,referenceElement:p,floatingElement:c,triggerElements:y,onOpenChange:C,floatingId:s,syncOnly:!0,nested:o}));const g=r??d.current;return t.useSyncedValue("floatingId",s),D(()=>{const v={open:u,floatingId:s,referenceElement:p,floatingElement:c};ve(p)&&(v.domReferenceElement=p),g.state.positionReference===g.state.referenceElement&&(v.positionReference=p),g.update(v)},[u,s,p,c,g]),g.context.onOpenChange=C,g.context.nested=o,g}const ys={tabIndex:-1,[nt]:""};function Es(e){return t=>t==="touch"?e.current:!0}function Ss(e,t=!1){const n=at(),r=dt()!=null,s=De(()=>e(n,r)).current;return Mr({popupStore:s,treatPopupAsFloatingElement:t,floatingRootContext:s.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:s.setOpen}),s}function Ts({handle:e,store:t}){return D(()=>e.attachStore(t),[e,t]),null}function Nr(e,t){const n=a.useRef(null),r=a.useRef(null);return a.useCallback(s=>{if(e===void 0)return;let o=!1;if(n.current!==null){const i=n.current,u=r.current,p=t.context.triggerElements.getById(i);u&&p===u&&(t.context.triggerElements.delete(i),o=!0),n.current=null,r.current=null}if(s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s),o=!0),o){const i=t.context.triggerElements.size;t.select("open")&&t.state.triggerCount!==i&&t.set("triggerCount",i)}},[t,e])}function Lr(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);const s=n?.id??null;(s||t)&&(e.activeTriggerId=s,e.activeTriggerElement=n??null)}function Dr(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Rs(e,t,n,r={}){const s=n.reason,o=s===_t,i=t&&s===Ln,u=!t&&(s===jt||s===Yt),p=Dr(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);const c=()=>{const y={...r.extraState,open:t};i?y.instantType="focus":u?y.instantType="dismiss":o&&(y.instantType=void 0),Lr(y,t,n.trigger,p()),e.update(y)};o?ut.flushSync(c):c()}function vs(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Nr(e,n),i=U(p=>{const c=n.select("open"),y=n.select("activeTriggerId");if(y===e){n.update({activeTriggerElement:p,...c?r:null});return}y==null&&c&&n.update({activeTriggerId:e,activeTriggerElement:p,...r})}),u=a.useCallback(p=>{o(p),p&&i(p)},[o,i]);return D(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:u,isMountedByThisTrigger:s}}function xs(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,r=a.useRef(null),s=e.useState("open"),o=e.useState("triggerCount"),i=e.useState("activeTriggerId"),u=e.useState("activeTriggerElement");D(()=>{if(!s){r.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0);return}const p=e.context.triggerElements.size,c={};e.state.triggerCount!==p&&(c.triggerCount=p);const y=e.select("activeTriggerId");let C=null;if(y){const d=e.context.triggerElements.getById(y);if(d)r.current=y,d!==e.state.activeTriggerElement&&(c.activeTriggerElement=d);else{for(const[g,v]of e.context.triggerElements.entries())if(v===e.state.activeTriggerElement){c.activeTriggerId=g,c.activeTriggerElement=v,r.current=g;break}c.activeTriggerId===void 0&&(r.current===y?C=y:r.current=null)}}else r.current=null;if(!C&&!y&&p===1){const d=e.context.triggerElements.entries().next();if(!d.done){const[g,v]=d.value;c.activeTriggerId=g,c.activeTriggerElement=v,r.current=g}}(c.triggerCount!==void 0||c.activeTriggerId!==void 0||c.activeTriggerElement!==void 0)&&e.update(c),C&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===C&&!e.context.triggerElements.getById(C)){const d=xe(Nn);e.setOpen(!1,d),d.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[s,e,o,i,u,n])}function Cs(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=xn(e),i=t.useState("preventUnmountingOnClose"),u=e?!1:i;t.useSyncedValues({mounted:r,transitionStatus:o,preventUnmountingOnClose:u});const p=U(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return Cn({enabled:r&&!e&&!u,open:e,ref:t.context.popupRef,onComplete(){e||p()}}),{forceUnmount:p,transitionStatus:o}}function Is(e,t){e.useSyncedValues(t),D(()=>()=>{e.update({activeTriggerProps:Be,inactiveTriggerProps:Be,popupProps:Be})},[e])}function Os(e,t){D(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),D(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class ws{constructor(){this.idMap=new Map}add(t,n){this.idMap.set(t,n)}delete(t){this.idMap.delete(t)}hasElement(t){for(const n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(const n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}}const Ps=a.forwardRef(function(t,n){const{cutout:r,...s}=t;let o;if(r){const i=r.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return ne.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})});let At={},Mt={},Nt="";function Ke(e,t){return Mn(e)?e:t}function Lt(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Ke(t,n)).overflowY)}function Hr(e){if(typeof document>"u")return!1;const t=W(e);return Ue(t).innerWidth-t.documentElement.clientWidth>0}function Vr(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=W(e),r=n.documentElement,s=n.body,o=Ke(r,s),i=o.style.overflowY,u=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",o.style.overflowY="scroll";const p=o.offsetWidth;o.style.overflowY="hidden";const c=o.offsetWidth;return o.style.overflowY=i,r.style.scrollbarGutter=u,p===c}function Wr(e){const t=W(e),n=t.documentElement,r=t.body,s=Ke(n,r),o={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,o)}}function _r(e){const t=W(e),n=t.documentElement,r=t.body,s=Ue(n);let o=0,i=0,u=!1;const p=In.create();if(Ie&&(s.visualViewport?.scale??1)!==1)return()=>{};function c(){const g=s.getComputedStyle(n),v=s.getComputedStyle(r),R=(g.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,At={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Nt=n.style.scrollBehavior,Mt={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const b=n.scrollHeight>n.clientHeight,q=n.scrollWidth>n.clientWidth,V=g.overflowY==="scroll"||v.overflowY==="scroll",Y=g.overflowX==="scroll"||v.overflowX==="scroll",z=Math.max(0,s.innerWidth-r.clientWidth),F=Math.max(0,s.innerHeight-r.clientHeight),G=parseFloat(v.marginTop)+parseFloat(v.marginBottom),M=parseFloat(v.marginLeft)+parseFloat(v.marginRight),J=Ke(n,r);if(u=Vr(e),u){n.style.scrollbarGutter=R,J.style.overflowY="hidden",J.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:R,overflowY:"hidden",overflowX:"hidden"}),(b||V)&&(n.style.overflowY="scroll"),(q||Y)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:G||F?`calc(100dvh - ${G+F}px)`:"100dvh",width:M||z?`calc(100vw - ${M+z}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function y(){Object.assign(n.style,At),Object.assign(r.style,Mt),u||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Nt)}function C(){y(),p.request(c)}c();const d=P(s,"resize",C);return()=>{p.cancel(),y(),typeof s.removeEventListener=="function"&&d()}}class Br{lockCount=0;restore=null;timeoutLock=Te.create();timeoutUnlock=Te.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const n=W(t),r=n.documentElement,s=n.body,o=Ue(r);if(Lt(o,r,s)){const u=new o.MutationObserver(()=>{Lt(o,r,s)||(u.disconnect(),this.restore=null,this.lock(t))}),p={attributes:!0};u.observe(r,p),u.observe(s,p),this.restore=()=>u.disconnect();return}const i=lt||!Hr(t);this.restore=i?Wr(t):_r(t)}}const jr=new Br;function ks(e=!0,t=null){D(()=>{if(e)return jr.acquire(t)},[e,t])}export{rs as $,zr as A,Xt as B,Qr as C,pt as D,dt as E,ys as F,Jr as G,Le as H,hs as I,fs as J,as as K,Ps as L,ps as M,hr as N,ds as O,ws as P,Dr as Q,kr as R,Lr as S,Te as T,Mr as U,is as V,gs as W,Me as X,es as Y,tn as Z,ts as _,P as a,Ye as a0,cs as a1,Ar as a2,pn as a3,St as a4,Xn as a5,Kn as a6,Et as a7,Qe as a8,Gn as a9,Xr as aa,Kr as ab,$r as ac,qr as ad,lt as ae,us as af,ks as ag,Gt as ah,Es as ai,Os as aj,Rs as b,xs as c,Cs as d,Ts as e,Rr as f,bs as g,Is as h,Zr as i,ms as j,vs as k,We as l,je as m,gr as n,ls as o,ss as p,ir as q,ur as r,dn as s,ns as t,Ss as u,os as v,Ce as w,_n as x,Ie as y,Ge as z};
@@ -1 +1 @@
1
- import{r as s,f as c,e as n}from"./index-DIf_7lV5.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-BC1mWQy8.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-DIf_7lV5.js";/**
1
+ import{c as e}from"./index-BC1mWQy8.js";/**
2
2
  * @license lucide-react v1.39.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.