@maudecode/kanvil 0.4.0 → 0.4.2

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 (109) hide show
  1. package/apps/server/.env.example +4 -0
  2. package/apps/server/dist/{auth-Cuo7ECLh.mjs → auth-CLAZTAoL.mjs} +33 -9
  3. package/apps/server/dist/client.mjs +1 -1
  4. package/apps/server/dist/{config-DtNfVSnB.mjs → config-DOT1SDQO.mjs} +3 -1
  5. package/apps/server/dist/index.mjs +6 -6
  6. package/apps/server/dist/migrate.mjs +1 -1
  7. package/apps/server/dist/recover.mjs +3 -3
  8. package/apps/server/dist/{src-tQ82UI8k.mjs → src-VxR5jZiK.mjs} +145 -8
  9. package/apps/web/dist/assets/{CompositeItem-DgnfVvrF.js → CompositeItem-B5Qlh5m0.js} +1 -1
  10. package/apps/web/dist/assets/{Trans-f2VYVS9z.js → Trans-DxqBaUXP.js} +1 -1
  11. package/apps/web/dist/assets/{admin-settings-DBZL4siY.js → admin-settings-Bp7V2t1V.js} +1 -1
  12. package/apps/web/dist/assets/{archive-restore-CGuLxoHC.js → archive-restore-wsAzhqi-.js} +1 -1
  13. package/apps/web/dist/assets/az-AZ-DlsPlUZi.js +1 -0
  14. package/apps/web/dist/assets/{az-BE5iqNIE.js → az-C4KDjOOw.js} +1 -1
  15. package/apps/web/dist/assets/{corner-left-up-BCro--Gl.js → corner-left-up-arA2ipmM.js} +1 -1
  16. package/apps/web/dist/assets/de-DE-DLCaqUUe.js +1 -0
  17. package/apps/web/dist/assets/{de-DLGjUGf_.js → de-Z599ZW7b.js} +1 -1
  18. package/apps/web/dist/assets/default-6QIAyMq2.js +56 -0
  19. package/apps/web/dist/assets/{delivery-settings-CZOtb4X8.js → delivery-settings-D5NKPlhN.js} +1 -1
  20. package/apps/web/dist/assets/el-GR-P2XcwrSU.js +1 -0
  21. package/apps/web/dist/assets/{el-CG6Xy42v.js → el-xsvq992p.js} +1 -1
  22. package/apps/web/dist/assets/{ellipsis-ZJM26JNS.js → ellipsis-UOkL14vq.js} +1 -1
  23. package/apps/web/dist/assets/{es-Bbj5WuMM.js → es-D3e9L5_i.js} +1 -1
  24. package/apps/web/dist/assets/es-ES-CJoX8f3w.js +1 -0
  25. package/apps/web/dist/assets/{forms-C3pNy-qY.js → forms-BbWAl0BZ.js} +1 -1
  26. package/apps/web/dist/assets/{fr-CjuIKc1o.js → fr-CY35Bcpp.js} +1 -1
  27. package/apps/web/dist/assets/fr-FR-yLkQdy6a.js +1 -0
  28. package/apps/web/dist/assets/{hi-BVVrZ-zZ.js → hi-Cqfv-E5P.js} +1 -1
  29. package/apps/web/dist/assets/hi-IN-y8dqej7z.js +1 -0
  30. package/apps/web/dist/assets/{highlight-CKyEM4jx.js → highlight-Ds7xUUQv.js} +1 -1
  31. package/apps/web/dist/assets/{id-BhNWOQnp.js → id-CFBOVDUC.js} +1 -1
  32. package/apps/web/dist/assets/id-ID-DSvh8mGH.js +1 -0
  33. package/apps/web/dist/assets/{index-BIuqxnJn.js → index-2V6MWx63.js} +5 -5
  34. package/apps/web/dist/assets/{invitations-D5unaga2.js → invitations-BPk5fwwU.js} +1 -1
  35. package/apps/web/dist/assets/{it-Cav3_-xd.js → it-DNLponcC.js} +1 -1
  36. package/apps/web/dist/assets/it-IT-BUcfUqNo.js +1 -0
  37. package/apps/web/dist/assets/{item-Cj8xpMLk.js → item-DED0Ikqi.js} +1 -1
  38. package/apps/web/dist/assets/ja-JP-C-jLP_Ay.js +1 -0
  39. package/apps/web/dist/assets/{ja-DTmZE0Qe.js → ja-ZXGlS4WA.js} +1 -1
  40. package/apps/web/dist/assets/{ko-BuYCMOUj.js → ko-CSoj1hQM.js} +1 -1
  41. package/apps/web/dist/assets/ko-KR-C5Ozdm2E.js +1 -0
  42. package/apps/web/dist/assets/{label-settings-B89Ehf78.js → label-settings-D12QOkDs.js} +1 -1
  43. package/apps/web/dist/assets/{markdown-blocks-DSEA68s5.js → markdown-blocks-DbsqN1T2.js} +1 -1
  44. package/apps/web/dist/assets/{member-directory-48yD01yN.js → member-directory-BRhEIYZ6.js} +1 -1
  45. package/apps/web/dist/assets/{mk-BZ2Rg2sU.js → mk-D77vceoz.js} +1 -1
  46. package/apps/web/dist/assets/mk-MK-BdM_SsE8.js +1 -0
  47. package/apps/web/dist/assets/{nl-BtnPzRih.js → nl-Bew8-xmX.js} +1 -1
  48. package/apps/web/dist/assets/nl-NL-CwjB5sva.js +1 -0
  49. package/apps/web/dist/assets/{pl-Beg8hEdK.js → pl-CEBl_oa9.js} +1 -1
  50. package/apps/web/dist/assets/pl-PL-6-PMhTBd.js +1 -0
  51. package/apps/web/dist/assets/{project-lifecycle-CIAMJ-SX.js → project-lifecycle-DGHAmEB2.js} +1 -1
  52. package/apps/web/dist/assets/{project-settings-C7lolDSl.js → project-settings-DY8Ossd-.js} +1 -1
  53. package/apps/web/dist/assets/{pt-BR-B4VZ35N_.js → pt-BR-BDTQeKcp.js} +1 -1
  54. package/apps/web/dist/assets/pt-BR-TD_wt6Hr.js +1 -0
  55. package/apps/web/dist/assets/{public-project-DvvfaUd2.js → public-project-BeXla8TL.js} +1 -1
  56. package/apps/web/dist/assets/{rotate-ccw-GjVJPDML.js → rotate-ccw-DGM890Fc.js} +1 -1
  57. package/apps/web/dist/assets/{ru-DjVJVHzv.js → ru-BeH0eXQq.js} +1 -1
  58. package/apps/web/dist/assets/ru-RU-Bk1a6Oln.js +1 -0
  59. package/apps/web/dist/assets/{search-ZaQmVnj1.js → search-B3-w3oCd.js} +3 -3
  60. package/apps/web/dist/assets/{send-Dr9bXHhf.js → send-B9baaCnt.js} +1 -1
  61. package/apps/web/dist/assets/{settings-DXvrVvyS.js → settings-BKZfEkVk.js} +1 -1
  62. package/apps/web/dist/assets/{sliders-horizontal-C1t_zA7D.js → sliders-horizontal-yKgghk8h.js} +1 -1
  63. package/apps/web/dist/assets/{switch-D-WTDajm.js → switch-ByOrazEW.js} +1 -1
  64. package/apps/web/dist/assets/{table-BaRMFP84.js → table-Cm6NQXfq.js} +1 -1
  65. package/apps/web/dist/assets/{ticket-detail-CFJI4qoK.js → ticket-detail-Cd3_e2jz.js} +2 -2
  66. package/apps/web/dist/assets/{ticket-editor-DL3nHG_q.js → ticket-editor-CLDBUk0n.js} +2 -2
  67. package/apps/web/dist/assets/{ticket-list-CDkweYGS.js → ticket-list-BC9acNl4.js} +1 -1
  68. package/apps/web/dist/assets/{ticket-list-controls-CmTgFQQ-.js → ticket-list-controls-CRQk5ghe.js} +1 -1
  69. package/apps/web/dist/assets/{tr-Ckc4TA71.js → tr-BNApk6Hc.js} +1 -1
  70. package/apps/web/dist/assets/tr-TR-CUfBb7K9.js +1 -0
  71. package/apps/web/dist/assets/{uk-B4ZvJ8xG.js → uk-CjShsgpN.js} +1 -1
  72. package/apps/web/dist/assets/uk-UA-BDaXBsDP.js +1 -0
  73. package/apps/web/dist/assets/{upload-BwGa8shS.js → upload-BzLq4CMS.js} +1 -1
  74. package/apps/web/dist/assets/{useQueries-sQEHjB0a.js → useQueries-D64vLhM6.js} +1 -1
  75. package/apps/web/dist/assets/vi-VN-Bgb-L6mE.js +1 -0
  76. package/apps/web/dist/assets/{vi-Dq2krfY8.js → vi-s5Hfv1Y-.js} +1 -1
  77. package/apps/web/dist/assets/{visual-editor-CBhwqTDu.js → visual-editor-KE96mwCg.js} +1 -1
  78. package/apps/web/dist/assets/{workspace-settings-DgLyieJN.js → workspace-settings-C-Phmi9i.js} +1 -1
  79. package/apps/web/dist/assets/{zh-CN-B7Rxc3Mp.js → zh-CN-BBnpHJ9R.js} +1 -1
  80. package/apps/web/dist/assets/zh-CN-BypkvBe6.js +1 -0
  81. package/apps/web/dist/assets/zh-TW-CgMsT_XS.js +1 -0
  82. package/apps/web/dist/assets/{zh-TW-awiwHjeM.js → zh-TW-sSWkqSLN.js} +1 -1
  83. package/apps/web/dist/index.html +7 -7
  84. package/compose.yml +2 -0
  85. package/docs/api.md +3 -3
  86. package/docs/self-hosting.md +5 -1
  87. package/package.json +1 -1
  88. package/apps/server/dist/instance-CCeXRJ6m.mjs +0 -133
  89. package/apps/web/dist/assets/az-AZ-DesqXNg5.js +0 -1
  90. package/apps/web/dist/assets/de-DE-BIGY9SNm.js +0 -1
  91. package/apps/web/dist/assets/default-BgvtI7HK.js +0 -56
  92. package/apps/web/dist/assets/el-GR-D2TjImt0.js +0 -1
  93. package/apps/web/dist/assets/es-ES-C_fRqLGU.js +0 -1
  94. package/apps/web/dist/assets/fr-FR-_tnQsn4j.js +0 -1
  95. package/apps/web/dist/assets/hi-IN-CcmFsZYy.js +0 -1
  96. package/apps/web/dist/assets/id-ID-C59tC61D.js +0 -1
  97. package/apps/web/dist/assets/it-IT-BAP5O3gK.js +0 -1
  98. package/apps/web/dist/assets/ja-JP-vQa7mEdh.js +0 -1
  99. package/apps/web/dist/assets/ko-KR-CXlpmX0-.js +0 -1
  100. package/apps/web/dist/assets/mk-MK-BU5BLpXM.js +0 -1
  101. package/apps/web/dist/assets/nl-NL-2aSpdZkg.js +0 -1
  102. package/apps/web/dist/assets/pl-PL-C5Wvnv7f.js +0 -1
  103. package/apps/web/dist/assets/pt-BR-CVvI-ZB7.js +0 -1
  104. package/apps/web/dist/assets/ru-RU-C7UUdGIh.js +0 -1
  105. package/apps/web/dist/assets/tr-TR-VVsL3uMp.js +0 -1
  106. package/apps/web/dist/assets/uk-UA-DRpCbOps.js +0 -1
  107. package/apps/web/dist/assets/vi-VN-C0YFqq9j.js +0 -1
  108. package/apps/web/dist/assets/zh-CN-pcgTdR8c.js +0 -1
  109. package/apps/web/dist/assets/zh-TW-DymSXkFg.js +0 -1
@@ -1 +1 @@
1
- import{Ga as e}from"./search-ZaQmVnj1.js";var t={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};t.node;var n=e(t);export{n as t};
1
+ import{Ga as e}from"./search-B3-w3oCd.js";var t={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{At as t,Bt as n,Cn as r,Nn as i,On as a,Sn as o,W as s,an as c,ct as l,dn as u,fn as d,h as f,in as p,jt as m,m as h,mn as g,mt as _,p as ee,r as v,st as te,un as y,vn as b}from"./default-BgvtI7HK.js";import{$n as ne,B as re,Ca as ie,Ct as x,Er as ae,Fr as S,G as oe,Gt as C,Ha as w,Hi as T,Ii as E,Ir as se,J as D,Ji as O,K as k,Ka as A,Ki as j,Li as M,Lr as ce,Nr as le,Oa as N,Pa as P,Pt as F,Q as I,Qn as L,Ri as R,Rr as ue,Ui as z,V as B,X as V,Xr as de,Y as H,Yi as fe,_a as pe,an as me,at as U,ba as he,bt as ge,ca as _e,ci as ve,cr as W,di as G,dr as ye,er as be,ha as xe,hi as Se,hr as Ce,ia as we,ii as Te,ir as Ee,it as K,ka as De,la as Oe,li as ke,ma as Ae,mi as je,ni as Me,nr as Ne,or as Pe,pa as Fe,q as Ie,qa as Le,qi as Re,ra as ze,ri as Be,rr as Ve,rt as He,sa as Ue,si as We,sr as Ge,ti as Ke,tr as qe,ui as Je,ut as Ye,vt as Xe,wo as Ze,xa as Qe,xt as $e}from"./search-ZaQmVnj1.js";import{g as et}from"./item-Cj8xpMLk.js";import{i as tt,t as nt}from"./delivery-settings-CZOtb4X8.js";import{r as rt,u as it}from"./project-lifecycle-CIAMJ-SX.js";import{n as at,r as ot,t as st}from"./CompositeItem-DgnfVvrF.js";import{t as ct}from"./ticket-list-controls-CmTgFQQ-.js";import{t as lt}from"./upload-BwGa8shS.js";import{t as ut}from"./forms-C3pNy-qY.js";import{$t as dt,Ct as ft,Et as pt,Jt as mt,Qt as ht,Tt as gt,Xt as _t,Yt as vt,Zt as yt,_t as bt,bt as q,f as xt,fn as St,ht as Ct,i as J,n as Y,p as wt,r as Tt,rn as Et,sn as Dt,t as Ot,v as kt,xt as At,y as jt}from"./index-BIuqxnJn.js";import{t as Mt}from"./switch-D-WTDajm.js";import{a as Nt,i as X,n as Pt,o as Ft,r as Z,t as It}from"./table-BaRMFP84.js";var Q=e(i(),1),Lt=Q.createContext(void 0);function Rt(e=!1){let t=Q.useContext(Lt);if(!t&&!e)throw Error(xe(86));return t}Object.keys(ke);function zt(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var $=v(),Bt=[`7`,`30`,`90`,`365`,`custom`,`never`],Vt=e=>({name:g(`settings.credentials.permission.${e}.name`),description:g(`settings.credentials.permission.${e}.description`)});function Ht(e){try{return JSON.parse(e??`null`)}catch{return null}}function Ut(e){return{permissions:a({kanvil:r(o(n))}).safeParse(Ht(e.permissions)).data?.kanvil??[],projectIds:(h.safeParse(Ht(e.metadata)).data??{projectIds:[]}).projectIds}}function Wt(){let e=Ze(),t=Re(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,l]=(0,Q.useState)(null),[u]=(0,Q.useState)(Date.now),d=Le({queryKey:[`kanvil`,`credentials`],queryFn:()=>T.request(`/api/v1/credentials`,f)});function p(){r(!1),l(null)}return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.credentials.title`),description:g(`settings.credentials.description`),action:(0,$.jsx)(D,{label:g(`settings.credentials.create`),variant:`default`,disabled:t.isPending,onClick:()=>r(!0),children:(0,$.jsx)(et,{})})}),(0,$.jsx)(k,{error:d.error??t.error}),d.isPending?(0,$.jsx)(V,{}):d.data?.length?(0,$.jsxs)(It,{"aria-label":g(`settings.credentials.title`),mobileLayout:`rows`,children:[(0,$.jsx)(Nt,{children:(0,$.jsxs)(Ft,{children:[(0,$.jsx)(X,{children:g(`settings.credentials.name`)}),(0,$.jsx)(X,{children:g(`settings.credentials.access`)}),(0,$.jsx)(X,{children:g(`settings.credentials.projects`)}),(0,$.jsx)(X,{children:g(`settings.credentials.expires`)}),(0,$.jsx)(X,{children:(0,$.jsx)(`span`,{className:`sr-only`,children:g(`settings.credentials.actions`)})})]})}),(0,$.jsx)(Pt,{children:d.data.map(n=>{let r=Ut(n),i=!!n.expiresAt&&new Date(n.expiresAt).getTime()<=u,a=r.projectIds?.map(e=>t.data?.find(t=>t.id===e)?.name??g(`settings.credentials.unavailableProject`));return(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Z,{className:`max-w-64 whitespace-normal`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,$.jsx)(St,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`strong`,{dir:`auto`,className:`block wrap-anywhere font-medium`,children:n.name||g(`settings.credentials.untitled`)}),(0,$.jsxs)(`code`,{className:`text-xs text-muted-foreground`,children:[n.start,`…`]})]}),(i||!n.enabled)&&(0,$.jsx)(Xe,{variant:`secondary`,children:g(i?`settings.credentials.expired`:`settings.credentials.disabled`)})]})}),(0,$.jsx)(Z,{"data-label":g(`settings.credentials.access`),className:`max-w-72 whitespace-normal`,children:(0,$.jsx)(`span`,{className:`text-sm`,children:r.permissions.length===1&&r.permissions[0]===`read`?g(`settings.credentials.preset.read`):c(r.permissions.map(e=>Vt(e).name))||g(`settings.credentials.custom`)})}),(0,$.jsx)(Z,{"data-label":g(`settings.credentials.projects`),className:`max-w-64 whitespace-normal`,children:r.projectIds===null?g(`settings.credentials.global`):c(a??[])||g(`settings.credentials.noProjects`)}),(0,$.jsx)(Z,{"data-label":g(`settings.credentials.expires`),className:`whitespace-nowrap text-muted-foreground`,children:n.expiresAt?s(n.expiresAt):g(`settings.credentials.never`)}),(0,$.jsx)(Z,{children:(0,$.jsx)(B,{label:g(`settings.credentials.revoke`),icon:(0,$.jsx)(at,{}),danger:!0,description:n.name===null?g(`settings.credentials.revokeUnnamed`):g(`settings.credentials.revokeNamed`,{name:n.name}),onConfirm:async()=>{await T.request(`/api/v1/credentials/${encodeURIComponent(n.id)}`,_,{method:`DELETE`}),await e.invalidateQueries({queryKey:[`kanvil`,`credentials`]})}})})]},n.id)})})]}):(0,$.jsx)(oe,{title:g(`settings.credentials.empty`),icon:St,className:`py-16`,children:(0,$.jsx)(`p`,{className:`mb-0 max-w-sm text-center text-sm text-muted-foreground`,children:g(`settings.credentials.emptyDescription`)})}),(0,$.jsx)(I,{busy:i,title:g(o?`settings.credentials.created`:`settings.credentials.create`),open:n,onOpenChange:e=>{e||p()},children:o?(0,$.jsx)(Gt,{value:o,onDone:p}):(0,$.jsx)(qt,{pending:i,setPending:a,projects:t.data??[],loading:t.isPending,onCancel:p,onCreated:async t=>{l(t),await e.invalidateQueries({queryKey:[`kanvil`,`credentials`]})}})})]})}function Gt({value:e,onDone:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)();return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{children:g(`settings.credentials.copyNow`)}),(0,$.jsx)(H,{label:g(`settings.credentials.newKey`),value:e.key,readOnly:!0,className:`font-mono text-xs`,onFocus:e=>e.target.select()}),(0,$.jsx)(k,{error:i}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(G,{onClick:()=>{E(e.key).then(()=>r(!0)).catch(a)},children:[n?(0,$.jsx)(w,{}):(0,$.jsx)(P,{}),g(n?`common.state.copied`:`settings.credentials.copy`)]}),(0,$.jsx)(G,{variant:`default`,onClick:t,children:g(`common.action.done`)})]})]})}function Kt({scope:e,checked:t,onChange:n}){let r=(0,Q.useId)(),i=Vt(e);return(0,$.jsxs)(Ne,{orientation:`horizontal`,className:`border-b py-3 last:border-0 [&_[data-slot=field-description]]:m-0 [&_[data-slot=field-description]]:text-xs`,children:[(0,$.jsx)(L,{id:r,checked:t,onCheckedChange:n}),(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Pe,{htmlFor:r,children:i.name}),(0,$.jsx)(Ee,{children:i.description})]})]})}function qt({projects:e,loading:t,onCreated:r,onCancel:i,pending:a,setPending:o}){let s=ze(),c=new Map(s.data?.map(e=>[e.id,e.name])),[{tomorrow:l,lastDay:u}]=(0,Q.useState)(()=>{let e=new Date;e.setHours(0,0,0,0),e.setDate(e.getDate()+1);let t=new Date;return t.setDate(t.getDate()+365),{tomorrow:e,lastDay:t}}),[d,f]=(0,Q.useState)(e.length===1&&e[0]?[e[0].id]:[]),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)([`read`]),[v,te]=(0,Q.useState)(()=>{let e=new Date;return e.setDate(e.getDate()+90),e}),[y,b]=(0,Q.useState)(`90`),[ne,ie]=(0,Q.useState)(),[x,ae]=(0,Q.useState)(`read`),[S,oe]=(0,Q.useState)(``),C=e.filter(e=>`${e.name} ${e.key} ${c.get(e.workspaceId)??``}`.toLowerCase().includes(S.toLowerCase()));async function w(e){e.preventDefault(),o(!0),ie(void 0);try{await r(await T.request(`/api/v1/credentials`,ee,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:ut(new FormData(e.currentTarget),`name`),projectIds:p?null:d,scopes:h,expiresIn:y===`never`?null:y===`custom`?bt(v):Number(y)*86400})}))}catch(e){ie(e)}finally{o(!1)}}return t?(0,$.jsx)(V,{}):(0,$.jsx)(`form`,{onSubmit:e=>{w(e)},children:(0,$.jsxs)(W,{disabled:a,children:[(0,$.jsx)(H,{label:g(`settings.credentials.keyName`),name:`name`,required:!0,maxLength:100,placeholder:g(`settings.credentials.keyNamePlaceholder`),autoFocus:!0}),(0,$.jsxs)(W,{className:`gap-2`,children:[(0,$.jsx)(Ge,{variant:`label`,children:g(`settings.credentials.projectAccess`)}),(0,$.jsx)(re,{label:g(`settings.credentials.global`),description:g(`settings.credentials.globalDescription`),checked:p,onCheckedChange:m}),!p&&e.length>6&&(0,$.jsx)(He,{label:g(`settings.credentials.findProject`),value:S,onChange:oe,className:`mb-2`}),!p&&(0,$.jsxs)(`div`,{className:`max-h-44 overflow-y-auto px-3 py-1`,children:[C.map(e=>(0,$.jsx)(re,{label:e.name,description:g(`settings.credentials.projectDescription`,{key:e.key,workspace:c.get(e.workspaceId)??g(`settings.credentials.workspace`)}),checked:d.includes(e.id),onCheckedChange:t=>f(n=>t?[...n,e.id]:n.filter(t=>t!==e.id))},e.id)),C.length===0&&(0,$.jsx)(`p`,{className:`my-4 text-sm text-muted-foreground`,children:g(`settings.credentials.noMatches`)})]}),(0,$.jsx)(Ee,{children:g(`settings.credentials.roleLimit`)})]}),(0,$.jsxs)(U,{label:g(`settings.credentials.accessLevel`),value:x,onValueChange:e=>{let t=e??`read`;ae(t),t!==`custom`&&_(t===`read`?[`read`]:t===`write`?[`read`,`write`]:[`read`,`write`,`claim`])},children:[(0,$.jsx)(F,{value:`read`,children:g(`settings.credentials.preset.read`)}),(0,$.jsx)(F,{value:`write`,children:g(`settings.credentials.preset.write`)}),(0,$.jsx)(F,{value:`automation`,children:g(`settings.credentials.preset.automation`)}),(0,$.jsx)(F,{value:`custom`,children:g(`settings.credentials.preset.custom`)})]}),x===`custom`&&(0,$.jsx)(W,{className:`gap-0`,children:n.map(e=>(0,$.jsx)(Kt,{scope:e,checked:h.includes(e),onChange:t=>_(n=>t?[...n,e]:n.filter(t=>t!==e))},e))}),(0,$.jsx)(U,{label:g(`settings.credentials.expires`),value:y,onValueChange:e=>b(e??`90`),children:Bt.map(e=>(0,$.jsx)(F,{value:e,children:g(`settings.credentials.expiry.${e}`)},e))}),y===`custom`&&(0,$.jsx)(Ct,{label:g(`settings.credentials.expiresOn`),value:v,onChange:e=>{e&&te(e)},bounds:{from:l,to:u}}),y===`never`&&(0,$.jsx)(Ee,{children:g(`settings.credentials.neverDescription`)}),(0,$.jsx)(Ie,{error:ne,pending:a,submitLabel:g(`settings.credentials.create`),pendingLabel:g(`settings.credentials.creating`),submitDisabled:!p&&!d.length||!h.length,onCancel:i})]})})}function Jt(){let e=Ze(),t=O(),n=z.useSession(),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(``);async function f(){await Promise.all([n.refetch(),e.invalidateQueries({queryKey:[`kanvil`]})])}async function p(e){a(!0),s(void 0),d(``);try{await T.request(`/api/v1/profile/photo`,b,e?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(await R(e))}:{method:`DELETE`}),await f(),d(g(e?`settings.profile.photoUpdated`:`settings.profile.photoRemoved`))}catch(e){s(e)}finally{a(!1)}}return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.profile.title`)}),(0,$.jsx)(Ot,{name:t.name,nameLabel:g(`settings.profile.displayName`),withDescription:!1,canEdit:!0,pending:i,error:c,editLabel:g(`settings.profile.edit`),media:(0,$.jsx)(tt,{label:g(`settings.profile.changePhoto`),round:!0,disabled:i,onClick:()=>r.current?.click(),children:(0,$.jsx)(we,{name:t.name,image:t.image,className:`size-16 text-xl`})}),onSave:async({name:e})=>{l(void 0),a(!0);try{let t=await z.updateUser({name:e});if(t.error)throw Error(t.error.message);await f(),d(g(`settings.profile.saved`))}catch(e){throw l(e),e}finally{a(!1)}},children:(0,$.jsx)(`p`,{className:`mb-0 text-sm break-all text-muted-foreground`,children:t.email})}),t.image&&(0,$.jsxs)(G,{className:`mt-5`,variant:`ghost`,disabled:i,onClick:()=>{p()},children:[(0,$.jsx)(at,{}),g(`settings.profile.removePhoto`)]}),(0,$.jsx)(Ce,{ref:r,type:`file`,disabled:i,accept:`image/png,image/jpeg,image/webp`,className:`hidden`,"aria-label":g(`settings.profile.photoFile`),onChange:e=>{let t=e.currentTarget.files?.[0];t&&p(t),e.currentTarget.value=``}}),(0,$.jsx)(k,{error:o}),u&&(0,$.jsx)(`p`,{role:`status`,className:`mt-4 mb-0 text-sm text-muted-foreground`,children:u})]})}function Yt({palette:e,clip:t}){return(0,$.jsxs)(`g`,{clipPath:t,children:[(0,$.jsx)(`rect`,{width:`160`,height:`96`,fill:e.background}),(0,$.jsx)(`rect`,{width:`34`,height:`96`,fill:e.sidebar}),(0,$.jsx)(`rect`,{x:`7`,y:`10`,width:`19`,height:`4`,rx:`2`,fill:e.primary}),[0,1,2].map(t=>(0,$.jsx)(`rect`,{x:`7`,y:27+t*12,width:t===2?12:21,height:`3`,rx:`1.5`,fill:e.foreground,opacity:`.25`},t)),(0,$.jsx)(`rect`,{x:`45`,y:`12`,width:`65`,height:`5`,rx:`2`,fill:e.foreground,opacity:`.8`}),(0,$.jsx)(`rect`,{x:`127`,y:`10`,width:`23`,height:`8`,rx:`3`,fill:e.primary}),[0,1,2].map(t=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:`45`,y:34+t*18,width:`57`,height:`3`,rx:`1.5`,fill:e.foreground,opacity:`.3`}),(0,$.jsx)(`circle`,{cx:`130`,cy:35+t*18,r:`3`,fill:e.primary,opacity:t===1?1:.35}),(0,$.jsx)(`rect`,{x:`45`,y:43+t*18,width:`105`,height:`.6`,fill:e.foreground,opacity:`.12`})]},t))]})}function Xt({theme:e,mode:t=`system`,variant:n=`wireframe`,className:r}){let i=(0,Q.useId)();if(n===`orb`&&t!==`system`){let n=e[t],i=t===`light`;return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:De(`relative block size-14 shrink-0 overflow-hidden rounded-full border-2 border-background`,r),style:{boxShadow:i?`inset 0 0 0 1px rgb(0 0 0 / .1), 0 1px 2px rgb(0 0 0 / .08)`:`inset 0 0 0 1px rgb(255 255 255 / .14), 0 1px 2px rgb(0 0 0 / .18)`},children:(0,$.jsx)(`span`,{className:`absolute inset-0 rounded-full`,style:{backgroundColor:`color-mix(in oklab, ${n.background} 80%, ${i?`#ffffff`:`#09090b`})`,backgroundImage:`radial-gradient(circle at ${i?`72% 22%`:`28% 78%`} in oklab, ${n.primary} 0%, color-mix(in oklab, ${n.primary} ${i?`72%`:`62%`}, transparent) 28%, transparent 58%), radial-gradient(circle at ${i?`18% 82%`:`82% 18%`} in oklab, color-mix(in oklab, ${n.primary} 45%, transparent) 0%, transparent 55%)`,filter:`blur(3px)`,transform:`scale(1.1)`}})})}return(0,$.jsxs)(`svg`,{viewBox:`0 0 160 96`,preserveAspectRatio:`none`,className:De(`w-full rounded-md`,r),"aria-hidden":`true`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`clipPath`,{id:`${i}-light`,children:(0,$.jsx)(`rect`,{width:`80`,height:`96`})}),(0,$.jsx)(`clipPath`,{id:`${i}-dark`,children:(0,$.jsx)(`rect`,{x:`80`,width:`80`,height:`96`})})]}),t===`system`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yt,{palette:e.light,clip:`url(#${i}-light)`}),(0,$.jsx)(Yt,{palette:e.dark,clip:`url(#${i}-dark)`})]}):(0,$.jsx)(Yt,{palette:e[t]})]})}var Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},..._e,...Je},en=Q.createContext(void 0);function tn(){return Q.useContext(en)}var nn=Q.createContext(void 0);function rn(){let e=Q.useContext(nn);if(e===void 0)throw Error(xe(52));return e}var an=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=tn(),{disabled:h,readOnly:g,required:_,form:ee,checkedValue:v,touched:te=!1,validation:y,name:b,setCheckedValue:re=Qe,setTouched:x=Qe,registerInputRef:S=Qe}=m??{},{setTouched:oe,setFilled:C,state:w,disabled:T}=ve(),E=ue(),{labelId:se,getDescriptionProps:D}=Be(),O=T||E.disabled||h||i,k=g||a,A=_||o,j=ee,M=m?v===c:c===``,N=Q.useRef(null),P=ce(O,N),F=Q.useRef(null),I=y?.registerInput,L=Q.useCallback(e=>I?.(e,{controlRef:N,value:void 0}),[I]),R=ie(l,F,S,L);Fe(()=>{F.current?.checked&&C(!0)},[C]),Fe(()=>{F.current&&S(O&&M?null:F.current)},[M,O,S]);let z=Te(),B=Ke({id:d}),V=u?void 0:B,de={role:`radio`,"aria-checked":M,"aria-labelledby":Me(s,se,F,!u,V,p[`aria-label`]),[jt]:M?``:void 0,id:u?B:z,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||O||k)return;e.preventDefault();let t=F.current;t&&Se(t,e)},onFocus(e){P(!0),!(e.defaultPrevented||O||k||!te)&&(F.current?.click(),x(!1))},onBlur(){m||P(!1)}},{getButtonProps:H,buttonRef:fe}=je({disabled:O,native:u,composite:!1}),U={type:`radio`,ref:R,form:j,id:V,name:b,tabIndex:-1,style:b?be:ne,"aria-hidden":!0,...c===void 0?he:{value:me(c)},disabled:O,checked:M,required:A,readOnly:k,onChange(e){if(e.nativeEvent.defaultPrevented||O||k||c===void 0)return;let t=le(ae,e.nativeEvent);re(c,t),!t.isCanceled&&oe(!0)},onClick(e){e.stopPropagation()},onFocus(){N.current?.focus()}},ge=Q.useMemo(()=>({...w,required:A,disabled:O,readOnly:k,checked:M}),[w,O,k,M,A]),_e=ge,W=m!==void 0,G=[t,N,fe],ye=[de,p,H,D,y?e=>y.getValidationProps(O,e):he],xe=pe(`span`,e,{enabled:!W,state:ge,ref:G,props:ye,stateAttributesMapping:$t});return(0,$.jsxs)(nn.Provider,{value:_e,children:[W?(0,$.jsx)(st,{tag:`span`,render:n,className:r,style:f,state:ge,refs:G,props:ye,stateAttributesMapping:$t}):xe,(0,$.jsx)(`input`,{...U,suppressHydrationWarning:!0})]})}),on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=rn(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Ue(c),f={...s,transitionStatus:u},p=Q.useRef(null),m=a||l,h=pe(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:$t});return Oe({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),sn=[C],cn=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:g,setFocused:_,validationMode:ee,name:v,disabled:te,state:y,validation:b,setDirty:ne,setFilled:re,validityData:x}=ve(),{labelId:ae}=Be(),{clearErrors:oe,elementRef:C}=We(),w=Rt(!0),T=te||i,E=v??d,D=Te(p),[O,k]=qe({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[A,j]=Q.useState(!1),M=Ae((e,t)=>{s?.(e,t),!t.isCanceled&&k(e)}),ce=b.getInputControl,le=Q.useMemo(()=>({get current(){return ce()}}),[ce]),N=Q.useRef(null),P=Q.useRef(null),F=ie(N,f),I=Q.useRef(F),L=Ae(e=>{(N.current!==e||I.current!==F)&&(I.current=F,F?.(e))});Fe(()=>{L(N.current)},[F,L]);let R=Ae(e=>{if(e){if(!e.disabled){P.current||=e;let t=N.current;(e.checked||t==null||t.disabled)&&L(e)}return()=>{P.current===e&&(P.current=null),N.current===e&&L(null)}}}),ue=Ae(()=>{let e=C.current;if(!e)return O??null;for(let t of b.registeredInputs.keys())if(t.checked&&zt(t,e))return O??null;return null});se(le,D,O??null,ue,!T,d),S(O,()=>{oe(E),ne(O!==x.initialValue),re(O!=null),b.change(O);let e=P.current;O==null&&e&&!e.disabled&&L(e)});let z=ae??w?.legendId,B={...y,disabled:T??!1,required:o??!1,readOnly:a??!1},V=Q.useMemo(()=>({checkedValue:O,disabled:T,form:u,validation:b,name:E,readOnly:a,registerInputRef:R,required:o,setCheckedValue:M,setTouched:j,touched:A}),[O,T,u,b,E,a,R,o,M,j,A]),H={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":T||void 0,"aria-readonly":a||void 0,"aria-labelledby":z,onBlur(e){de(e.currentTarget,e.relatedTarget)||(j(!1),g(!0),_(!1),ee===`onBlur`&&b.commit(O))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&j(!0)}};return(0,$.jsx)(en.Provider,{value:V,children:(0,$.jsx)(kt,{render:n,className:r,style:m,state:B,props:[H,h,e=>b.getValidationProps(T??!1,e)],refs:[t],stateAttributesMapping:Je,enableHomeAndEndKeys:!1,modifierKeys:sn})})});function ln({className:e,...t}){return(0,$.jsx)(cn,{"data-slot":`radio-group`,className:De(`grid w-full gap-2`,e),...t})}function un({className:e,...t}){return(0,$.jsx)(an,{"data-slot":`radio-group-item`,className:De(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,$.jsx)(on,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,$.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}var dn=[`system`,`light`,`dark`],fn=e=>M(`${e.id}.kanvil-theme.json`,yt([e]));function pn({theme:e,active:t,activeModes:n,onPickMode:r,actions:i}){return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border border-border/70 bg-background transition-colors hover:bg-accent/10 has-[>[data-slot=radio-group-item]:focus-visible]:ring-2 has-[>[data-slot=radio-group-item]:focus-visible]:ring-ring has-[>[data-slot=radio-group-item]:focus-visible]:ring-offset-2 has-[>[data-slot=radio-group-item]:focus-visible]:ring-offset-background data-[selected=true]:bg-accent/30 data-[selected=true]:shadow-[inset_0_0_0_1px_var(--ring)]`,"data-selected":t,children:[(0,$.jsx)(un,{value:e.id,id:`theme-${e.id}`,className:`peer absolute inset-0 size-full aspect-auto rounded-xl opacity-0`}),(0,$.jsx)(`div`,{className:`pointer-events-none relative flex min-h-16 items-center justify-center gap-2.5 px-3 pt-3`,children:[`light`,`dark`].map(t=>{let i=n.includes(t),a=t===`light`?Et:Dt;return(0,$.jsxs)(ge,{children:[(0,$.jsxs)(x,{render:(0,$.jsx)(G,{variant:`ghost`,"aria-label":g(`settings.appearance.useMode.${t}`,{name:e.name}),"aria-pressed":i,className:`pointer-events-auto relative size-[68px] shrink-0 rounded-full p-1 transition-transform hover:scale-105 hover:bg-transparent aria-pressed:hover:scale-100`,onClick:()=>r(t)}),children:[(0,$.jsx)(Xt,{theme:e,mode:t,variant:`orb`}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 rounded-full ring-2 ring-inset ring-ring`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0.5 right-0.5 flex size-5 items-center justify-center rounded-full border border-border/70 bg-background text-foreground shadow-sm`,children:(0,$.jsx)(a,{className:`size-3`})})]})]}),(0,$.jsx)($e,{children:g(`settings.appearance.modeOnly.${t}`)})]},t)})}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-center gap-2 px-3 pb-3 pt-2`,children:[(0,$.jsx)(ye,{htmlFor:`theme-${e.id}`,title:e.name,className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,$.jsx)(`div`,{className:`pointer-events-auto relative flex shrink-0 items-center gap-1`,children:i})]})]})}var mn=e=>e.toLocaleLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``);function hn(){let e=vt(),t=(0,Q.useRef)(null),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(),l={...e.selected,light:e.lightTheme.light,dark:e.darkTheme.dark};function u(e){r({...e,id:`custom-${crypto.getRandomValues(new Uint32Array(2)).join(`-`)}`,name:g(`settings.appearance.copyName`,{name:e.name})})}let d=e.themes.filter(e=>mn(e.name).includes(mn(i)));return(0,$.jsxs)(`section`,{className:`space-y-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-normal text-muted-foreground`,children:g(`settings.appearance.colorScheme`)}),(0,$.jsx)(ln,{value:e.mode,onValueChange:t=>e.setMode(o(dn).parse(t)),"aria-label":g(`settings.appearance.theme`),className:`grid grid-cols-3 gap-3`,children:dn.map(t=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(un,{id:`mode-${t}`,value:t,className:`peer absolute inset-0 z-10 size-full aspect-auto rounded-xl opacity-0`}),(0,$.jsxs)(ye,{htmlFor:`mode-${t}`,className:`theme-choice flex w-full cursor-pointer flex-col gap-2 rounded-lg border border-border bg-background p-2 text-xs font-medium transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-background hover:bg-muted/50 data-[selected=true]:border-primary data-[selected=true]:ring-1 data-[selected=true]:ring-primary [&_svg]:overflow-hidden [&_svg]:border [&_svg]:border-foreground/10`,"data-selected":e.mode===t,children:[(0,$.jsx)(Xt,{theme:l,mode:t,className:`h-[8.75rem]`}),(0,$.jsx)(`span`,{className:`pb-1`,children:mt[t]})]})]},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`mb-0 text-sm font-normal text-muted-foreground`,children:g(`settings.appearance.themes`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1`,children:[(0,$.jsx)(He,{label:g(`settings.appearance.search`),placeholder:g(`settings.appearance.searchPlaceholder`),value:i,onChange:a}),(0,$.jsx)(D,{label:g(`settings.appearance.create`),size:`icon-sm`,onClick:()=>u(l),children:(0,$.jsx)(et,{})}),(0,$.jsx)(D,{label:g(`settings.appearance.add`),size:`icon-sm`,onClick:()=>t.current?.click(),children:(0,$.jsx)(lt,{})})]})]}),(0,$.jsx)(Ce,{ref:t,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":g(`settings.appearance.importFile`),onChange:t=>{let n=t.currentTarget.files?.[0];n&&(c(void 0),n.text().then(t=>e.importThemes(_t(t))).catch(c),t.currentTarget.value=``)}}),(0,$.jsx)(k,{error:s}),(0,$.jsx)(ln,{"aria-label":g(`settings.appearance.colorTheme`),value:e.color,onValueChange:t=>e.setColor(String(t)),className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-2`,children:d.map(t=>(0,$.jsx)(pn,{theme:t,active:t.id===e.color,activeModes:[`light`,`dark`].filter(n=>(n===`light`?e.lightTheme.id:e.darkTheme.id)===t.id),onPickMode:n=>e.setColorForMode(n,t.id),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{label:g(`settings.appearance.duplicate`,{name:t.name}),className:`size-6`,onClick:()=>u(t),children:(0,$.jsx)(P,{})}),t.id.startsWith(`custom-`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{label:g(`settings.appearance.edit`,{name:t.name}),className:`size-6`,onClick:()=>r(t),children:(0,$.jsx)(ot,{})}),(0,$.jsx)(D,{label:g(`settings.appearance.export`,{name:t.name}),className:`size-6`,onClick:()=>fn(t),children:(0,$.jsx)(it,{})}),(0,$.jsx)(B,{label:g(`settings.appearance.delete`,{name:t.name}),description:g(`settings.appearance.deleteDescription`,{name:t.name}),danger:!0,icon:(0,$.jsx)(at,{}),onConfirm:async()=>e.remove(t.id)})]})]})},t.id))}),d.length===0&&(0,$.jsx)(`p`,{role:`status`,className:`mt-4`,children:g(`settings.appearance.noMatches`)})]}),(0,$.jsx)(I,{title:g(`settings.appearance.customTheme`),open:!!n,onOpenChange:e=>{e||r(null)},children:n&&(0,$.jsx)(gn,{initial:n,onSaved:t=>{e.save(t),a(``),r(null)}})})]})}function gn({initial:e,onSaved:t}){let[n,r]=(0,Q.useState)(e),[i,a]=(0,Q.useState)();return(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(void 0);try{t(dt(n))}catch(e){a(e)}},children:[(0,$.jsx)(H,{label:g(`settings.appearance.name`),value:n.name,required:!0,maxLength:60,onChange:e=>r({...n,name:e.target.value})}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-5`,children:[`light`,`dark`].map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:mt[e]}),(0,$.jsx)(Xt,{theme:n,mode:e}),(0,$.jsx)(`div`,{className:`mt-4 space-y-3`,children:ht.keyof().options.map(t=>(0,$.jsx)(H,{label:g(`settings.appearance.paletteColor`,{mode:mt[e],color:g(`settings.appearance.color.${t}`)}),type:`color`,value:n[e][t],onChange:i=>r({...n,[e]:{...n[e],[t]:i.target.value}})},t))})]},e))}),(0,$.jsx)(k,{error:i}),(0,$.jsx)(G,{type:`submit`,variant:`default`,className:`mt-4`,children:g(`settings.appearance.save`)})]})}function _n({section:e}){let[t,n]=xt(),r=O(),i=fe(),a=Le({queryKey:[`accounts`],refetchOnMount:`always`,queryFn:async()=>{let e=await z.listAccounts();if(e.error)throw Error(e.error.message);return e.data}}),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);async function u(e){e.preventDefault(),n(void 0);let t=new FormData(e.currentTarget);if(t.get(`next`)!==t.get(`confirm`))n(Error(g(`settings.account.passwordMismatch`)));else{l(!0);try{let e=await z.changePassword({currentPassword:ut(t,`current`),newPassword:ut(t,`next`),revokeOtherSessions:!0});if(e.error)throw Error(e.error.message);s(!1),N.success(g(`settings.account.passwordUpdated`))}catch(e){n(e)}finally{l(!1)}}}return(0,$.jsxs)(Tt,{title:g(`settings.account.title`),section:e,children:[(0,$.jsxs)(J,{value:`account`,children:[(0,$.jsx)(Jt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.account.security`)}),(0,$.jsx)(Y,{title:g(`settings.account.localPassword`),description:g(`settings.account.localPasswordDescription`),children:(0,$.jsx)(G,{onClick:()=>{n(void 0),s(!0)},children:g(`settings.account.changePassword`)})}),i.data?.providers.map(e=>{let t=a.data?.some(t=>t.providerId===e.id);return(0,$.jsx)(Y,{title:e.name,description:g(t?`settings.account.oidcLinked`:`settings.account.oidcUnlinked`),children:t?(0,$.jsx)(Xe,{variant:`secondary`,children:g(`settings.account.linked`)}):(0,$.jsx)(G,{disabled:c,onClick:()=>{l(!0),n(void 0),z.linkSocial({provider:e.id,callbackURL:`${window.location.origin}/settings?section=account`,errorCallbackURL:`${window.location.origin}/settings?section=account`}).then(e=>{if(e.error)throw Error(e.error.message)}).catch(n).finally(()=>l(!1))},children:g(`settings.account.link`,{name:e.name})})},e.id)}),(0,$.jsx)(rt,{account:r,onDeleted:()=>j(r).catch(()=>{r.clearPrivateData(),window.location.assign(`/login`)})}),!o&&(0,$.jsx)(k,{error:t}),(0,$.jsx)(k,{error:a.error??i.error})]}),(0,$.jsx)(I,{title:g(`settings.account.changePassword`),open:o,onOpenChange:s,busy:c,children:(0,$.jsxs)(`form`,{onSubmit:e=>{u(e)},children:[(0,$.jsx)(H,{label:g(`settings.account.currentPassword`),name:`current`,type:`password`,autoComplete:`current-password`,required:!0}),(0,$.jsx)(H,{label:g(`settings.account.newPassword`),name:`next`,type:`password`,autoComplete:`new-password`,required:!0,minLength:12,maxLength:128}),(0,$.jsx)(H,{label:g(`settings.account.confirmPassword`),name:`confirm`,type:`password`,autoComplete:`new-password`,required:!0,minLength:12,maxLength:128}),(0,$.jsx)(Ie,{error:t,pending:c,submitLabel:g(`settings.account.changePassword`),onCancel:()=>s(!1)})]})})]}),(0,$.jsx)(J,{value:`appearance`,children:(0,$.jsx)(hn,{})}),(0,$.jsx)(J,{value:`preferences`,children:(0,$.jsx)(vn,{})}),(0,$.jsx)(J,{value:`credentials`,children:(0,$.jsx)(Wt,{})}),(0,$.jsxs)(J,{value:`notifications`,children:[(0,$.jsx)(yn,{pushAvailable:i.data?.push??!1}),(0,$.jsx)(nt,{emailAvailable:i.data?.email??!1})]})]})}function vn(){let e=O(),[t,n]=ft(q.weekStart),[r,i]=ft(q.sidebar),{preference:a}=pt();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(K,{title:g(`settings.preferences.behavior`)}),(0,$.jsx)(Y,{title:g(`common.language.label`),description:g(`settings.preferences.languageDescription`),children:(0,$.jsxs)(U,{label:g(`common.language.label`),labelHidden:!0,className:`mb-0 w-44`,value:a,onValueChange:e=>void gt(u.parse(e)).catch(Ye),children:[(0,$.jsx)(F,{value:`system`,children:g(`common.language.system`)}),d.map(e=>(0,$.jsx)(F,{value:e,lang:e,children:y[e].name},e))]})}),(0,$.jsx)(Y,{title:g(`settings.preferences.weekStart`),description:g(`settings.preferences.weekStartDescription`),children:(0,$.jsxs)(U,{label:g(`settings.preferences.weekStart`),labelHidden:!0,className:`mb-0 w-44`,value:t,onValueChange:e=>n(q.weekStart.schema.parse(e)),children:[(0,$.jsx)(F,{value:`language`,children:g(`settings.preferences.weekStartLanguage`)}),(0,$.jsx)(F,{value:`sunday`,children:p(new Date(2023,0,1),{weekday:`long`})}),(0,$.jsx)(F,{value:`monday`,children:p(new Date(2023,0,2),{weekday:`long`})}),(0,$.jsx)(F,{value:`saturday`,children:p(new Date(2023,0,7),{weekday:`long`})})]})}),(0,$.jsx)(Y,{title:g(`settings.preferences.sidebar`),description:g(`settings.preferences.sidebarDescription`),children:(0,$.jsxs)(U,{label:g(`settings.preferences.sidebar`),labelHidden:!0,className:`mb-0 w-44`,value:r,onValueChange:e=>i(q.sidebar.schema.parse(e)),children:[(0,$.jsx)(F,{value:`last`,children:g(`settings.preferences.sidebarLast`)}),(0,$.jsx)(F,{value:`expanded`,children:g(`settings.preferences.sidebarExpanded`)}),(0,$.jsx)(F,{value:`collapsed`,children:g(`settings.preferences.sidebarCollapsed`)})]})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.preferences.ticketLists`)}),(0,$.jsx)(`div`,{className:`grid max-w-sm gap-3`,children:(0,$.jsx)(ct,{})})]}),(0,$.jsx)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:(0,$.jsx)(Y,{title:g(`settings.preferences.reset`),description:g(`settings.preferences.resetDescription`),children:(0,$.jsx)(G,{variant:`outline`,onClick:()=>{At(e.id,Object.values(q)),N.success(g(`settings.preferences.resetDone`))},children:g(`settings.preferences.reset`)})})})]})}function yn({pushAvailable:e}){let n=Ze(),r=T.notificationPreferences(),i=Le(r),a=A({mutationFn:e=>T.setNotificationPreferences(e),networkMode:`always`,retry:!1,onSuccess:e=>n.setQueryData(r.queryKey,e)}),o=a.isPending?a.variables:i.data,s=e=>{o&&a.mutate({...o,...e})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(K,{title:g(`settings.notifications.title`)}),(0,$.jsx)(k,{error:i.error??a.error}),i.isPending?(0,$.jsx)(V,{}):o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{title:g(`settings.notifications.inbox`),description:g(`settings.notifications.inboxDescription`),children:(0,$.jsx)(Mt,{"aria-label":g(`settings.notifications.inboxSwitch`),checked:o.inApp,disabled:a.isPending,onCheckedChange:e=>s({inApp:e})})}),(0,$.jsx)(Y,{title:g(`settings.notifications.push`),description:g(e?`settings.notifications.pushDescription`:`settings.notifications.pushUnavailable`),children:(0,$.jsx)(Mt,{"aria-label":g(`settings.notifications.pushSwitch`),checked:o.push,disabled:a.isPending||!e,onCheckedChange:e=>s({push:e})})})]})]}),o&&(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(K,{title:g(`settings.notifications.categories`)}),te.map(e=>{let t=wt[e];return(0,$.jsx)(Y,{compact:!0,title:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(t,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),l[e]]}),children:(0,$.jsx)(Mt,{"aria-label":g(`settings.notifications.categorySwitch`,{label:l[e]}),checked:o.categories[e],disabled:a.isPending,onCheckedChange:t=>s({categories:{...o.categories,[e]:t}})})},e)}),(0,$.jsx)(Y,{title:g(`settings.notifications.reminder`),description:g(`settings.notifications.reminderDescription`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(bn,{value:o.reminderLead.amount,disabled:a.isPending||!o.categories.due_soon,onCommit:e=>s({reminderLead:{...o.reminderLead,amount:e}})},o.reminderLead.amount),(0,$.jsx)(U,{label:g(`settings.notifications.reminderUnit`),labelHidden:!0,className:`mb-0 w-32`,value:o.reminderLead.unit,disabled:a.isPending||!o.categories.due_soon,onValueChange:e=>s({reminderLead:{...o.reminderLead,unit:t.parse(e)}}),children:m.map(e=>(0,$.jsx)(F,{value:e,children:g(`settings.notifications.unit.${e}`)},e))})]})})]})]})}function bn({value:e,disabled:t,onCommit:n}){let[r,i]=(0,Q.useState)(String(e)),a=()=>{let t=Number(r);Number.isInteger(t)&&t>=1&&t<=999?t!==e&&n(t):i(String(e))};return(0,$.jsx)(H,{label:g(`settings.notifications.reminderAmount`),labelHidden:!0,type:`number`,inputMode:`numeric`,min:1,max:999,className:`w-20`,value:r,disabled:t,onChange:e=>i(e.currentTarget.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()}})}export{_n as AccountSettings};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{At as t,Bt as n,Cn as r,Nn as i,On as a,Sn as o,W as s,an as c,ct as l,dn as u,fn as d,h as f,in as p,jt as m,m as h,mn as g,mt as _,p as ee,r as v,st as te,un as y,vn as b}from"./default-6QIAyMq2.js";import{$n as ne,B as re,Ca as ie,Ct as x,Er as ae,Fr as S,G as oe,Gt as C,Ha as w,Hi as T,Ii as E,Ir as se,J as D,Ji as O,K as k,Ka as A,Ki as j,Li as M,Lr as ce,Nr as le,Oa as N,Pa as P,Pt as F,Q as I,Qn as L,Ri as R,Rr as ue,Ui as z,V as B,X as V,Xr as de,Y as H,Yi as fe,_a as pe,an as me,at as U,ba as he,bt as ge,ca as _e,ci as ve,cr as W,di as G,dr as ye,er as be,ha as xe,hi as Se,hr as Ce,ia as we,ii as Te,ir as Ee,it as K,ka as De,la as Oe,li as ke,ma as Ae,mi as je,ni as Me,nr as Ne,or as Pe,pa as Fe,q as Ie,qa as Le,qi as Re,ra as ze,ri as Be,rr as Ve,rt as He,sa as Ue,si as We,sr as Ge,ti as Ke,tr as qe,ui as Je,ut as Ye,vt as Xe,wo as Ze,xa as Qe,xt as $e}from"./search-B3-w3oCd.js";import{g as et}from"./item-DED0Ikqi.js";import{i as tt,t as nt}from"./delivery-settings-D5NKPlhN.js";import{r as rt,u as it}from"./project-lifecycle-DGHAmEB2.js";import{n as at,r as ot,t as st}from"./CompositeItem-B5Qlh5m0.js";import{t as ct}from"./ticket-list-controls-CRQk5ghe.js";import{t as lt}from"./upload-BzLq4CMS.js";import{t as ut}from"./forms-BbWAl0BZ.js";import{$t as dt,Ct as ft,Et as pt,Jt as mt,Qt as ht,Tt as gt,Xt as _t,Yt as vt,Zt as yt,_t as bt,bt as q,f as xt,fn as St,ht as Ct,i as J,n as Y,p as wt,r as Tt,rn as Et,sn as Dt,t as Ot,v as kt,xt as At,y as jt}from"./index-2V6MWx63.js";import{t as Mt}from"./switch-ByOrazEW.js";import{a as Nt,i as X,n as Pt,o as Ft,r as Z,t as It}from"./table-Cm6NQXfq.js";var Q=e(i(),1),Lt=Q.createContext(void 0);function Rt(e=!1){let t=Q.useContext(Lt);if(!t&&!e)throw Error(xe(86));return t}Object.keys(ke);function zt(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var $=v(),Bt=[`7`,`30`,`90`,`365`,`custom`,`never`],Vt=e=>({name:g(`settings.credentials.permission.${e}.name`),description:g(`settings.credentials.permission.${e}.description`)});function Ht(e){try{return JSON.parse(e??`null`)}catch{return null}}function Ut(e){return{permissions:a({kanvil:r(o(n))}).safeParse(Ht(e.permissions)).data?.kanvil??[],projectIds:(h.safeParse(Ht(e.metadata)).data??{projectIds:[]}).projectIds}}function Wt(){let e=Ze(),t=Re(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,l]=(0,Q.useState)(null),[u]=(0,Q.useState)(Date.now),d=Le({queryKey:[`kanvil`,`credentials`],queryFn:()=>T.request(`/api/v1/credentials`,f)});function p(){r(!1),l(null)}return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.credentials.title`),description:g(`settings.credentials.description`),action:(0,$.jsx)(D,{label:g(`settings.credentials.create`),variant:`default`,disabled:t.isPending,onClick:()=>r(!0),children:(0,$.jsx)(et,{})})}),(0,$.jsx)(k,{error:d.error??t.error}),d.isPending?(0,$.jsx)(V,{}):d.data?.length?(0,$.jsxs)(It,{"aria-label":g(`settings.credentials.title`),mobileLayout:`rows`,children:[(0,$.jsx)(Nt,{children:(0,$.jsxs)(Ft,{children:[(0,$.jsx)(X,{children:g(`settings.credentials.name`)}),(0,$.jsx)(X,{children:g(`settings.credentials.access`)}),(0,$.jsx)(X,{children:g(`settings.credentials.projects`)}),(0,$.jsx)(X,{children:g(`settings.credentials.expires`)}),(0,$.jsx)(X,{children:(0,$.jsx)(`span`,{className:`sr-only`,children:g(`settings.credentials.actions`)})})]})}),(0,$.jsx)(Pt,{children:d.data.map(n=>{let r=Ut(n),i=!!n.expiresAt&&new Date(n.expiresAt).getTime()<=u,a=r.projectIds?.map(e=>t.data?.find(t=>t.id===e)?.name??g(`settings.credentials.unavailableProject`));return(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Z,{className:`max-w-64 whitespace-normal`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,$.jsx)(St,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`strong`,{dir:`auto`,className:`block wrap-anywhere font-medium`,children:n.name||g(`settings.credentials.untitled`)}),(0,$.jsxs)(`code`,{className:`text-xs text-muted-foreground`,children:[n.start,`…`]})]}),(i||!n.enabled)&&(0,$.jsx)(Xe,{variant:`secondary`,children:g(i?`settings.credentials.expired`:`settings.credentials.disabled`)})]})}),(0,$.jsx)(Z,{"data-label":g(`settings.credentials.access`),className:`max-w-72 whitespace-normal`,children:(0,$.jsx)(`span`,{className:`text-sm`,children:r.permissions.length===1&&r.permissions[0]===`read`?g(`settings.credentials.preset.read`):c(r.permissions.map(e=>Vt(e).name))||g(`settings.credentials.custom`)})}),(0,$.jsx)(Z,{"data-label":g(`settings.credentials.projects`),className:`max-w-64 whitespace-normal`,children:r.projectIds===null?g(`settings.credentials.global`):c(a??[])||g(`settings.credentials.noProjects`)}),(0,$.jsx)(Z,{"data-label":g(`settings.credentials.expires`),className:`whitespace-nowrap text-muted-foreground`,children:n.expiresAt?s(n.expiresAt):g(`settings.credentials.never`)}),(0,$.jsx)(Z,{children:(0,$.jsx)(B,{label:g(`settings.credentials.revoke`),icon:(0,$.jsx)(at,{}),danger:!0,description:n.name===null?g(`settings.credentials.revokeUnnamed`):g(`settings.credentials.revokeNamed`,{name:n.name}),onConfirm:async()=>{await T.request(`/api/v1/credentials/${encodeURIComponent(n.id)}`,_,{method:`DELETE`}),await e.invalidateQueries({queryKey:[`kanvil`,`credentials`]})}})})]},n.id)})})]}):(0,$.jsx)(oe,{title:g(`settings.credentials.empty`),icon:St,className:`py-16`,children:(0,$.jsx)(`p`,{className:`mb-0 max-w-sm text-center text-sm text-muted-foreground`,children:g(`settings.credentials.emptyDescription`)})}),(0,$.jsx)(I,{busy:i,title:g(o?`settings.credentials.created`:`settings.credentials.create`),open:n,onOpenChange:e=>{e||p()},children:o?(0,$.jsx)(Gt,{value:o,onDone:p}):(0,$.jsx)(qt,{pending:i,setPending:a,projects:t.data??[],loading:t.isPending,onCancel:p,onCreated:async t=>{l(t),await e.invalidateQueries({queryKey:[`kanvil`,`credentials`]})}})})]})}function Gt({value:e,onDone:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)();return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{children:g(`settings.credentials.copyNow`)}),(0,$.jsx)(H,{label:g(`settings.credentials.newKey`),value:e.key,readOnly:!0,className:`font-mono text-xs`,onFocus:e=>e.target.select()}),(0,$.jsx)(k,{error:i}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(G,{onClick:()=>{E(e.key).then(()=>r(!0)).catch(a)},children:[n?(0,$.jsx)(w,{}):(0,$.jsx)(P,{}),g(n?`common.state.copied`:`settings.credentials.copy`)]}),(0,$.jsx)(G,{variant:`default`,onClick:t,children:g(`common.action.done`)})]})]})}function Kt({scope:e,checked:t,onChange:n}){let r=(0,Q.useId)(),i=Vt(e);return(0,$.jsxs)(Ne,{orientation:`horizontal`,className:`border-b py-3 last:border-0 [&_[data-slot=field-description]]:m-0 [&_[data-slot=field-description]]:text-xs`,children:[(0,$.jsx)(L,{id:r,checked:t,onCheckedChange:n}),(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Pe,{htmlFor:r,children:i.name}),(0,$.jsx)(Ee,{children:i.description})]})]})}function qt({projects:e,loading:t,onCreated:r,onCancel:i,pending:a,setPending:o}){let s=ze(),c=new Map(s.data?.map(e=>[e.id,e.name])),[{tomorrow:l,lastDay:u}]=(0,Q.useState)(()=>{let e=new Date;e.setHours(0,0,0,0),e.setDate(e.getDate()+1);let t=new Date;return t.setDate(t.getDate()+365),{tomorrow:e,lastDay:t}}),[d,f]=(0,Q.useState)(e.length===1&&e[0]?[e[0].id]:[]),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)([`read`]),[v,te]=(0,Q.useState)(()=>{let e=new Date;return e.setDate(e.getDate()+90),e}),[y,b]=(0,Q.useState)(`90`),[ne,ie]=(0,Q.useState)(),[x,ae]=(0,Q.useState)(`read`),[S,oe]=(0,Q.useState)(``),C=e.filter(e=>`${e.name} ${e.key} ${c.get(e.workspaceId)??``}`.toLowerCase().includes(S.toLowerCase()));async function w(e){e.preventDefault(),o(!0),ie(void 0);try{await r(await T.request(`/api/v1/credentials`,ee,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:ut(new FormData(e.currentTarget),`name`),projectIds:p?null:d,scopes:h,expiresIn:y===`never`?null:y===`custom`?bt(v):Number(y)*86400})}))}catch(e){ie(e)}finally{o(!1)}}return t?(0,$.jsx)(V,{}):(0,$.jsx)(`form`,{onSubmit:e=>{w(e)},children:(0,$.jsxs)(W,{disabled:a,children:[(0,$.jsx)(H,{label:g(`settings.credentials.keyName`),name:`name`,required:!0,maxLength:100,placeholder:g(`settings.credentials.keyNamePlaceholder`),autoFocus:!0}),(0,$.jsxs)(W,{className:`gap-2`,children:[(0,$.jsx)(Ge,{variant:`label`,children:g(`settings.credentials.projectAccess`)}),(0,$.jsx)(re,{label:g(`settings.credentials.global`),description:g(`settings.credentials.globalDescription`),checked:p,onCheckedChange:m}),!p&&e.length>6&&(0,$.jsx)(He,{label:g(`settings.credentials.findProject`),value:S,onChange:oe,className:`mb-2`}),!p&&(0,$.jsxs)(`div`,{className:`max-h-44 overflow-y-auto px-3 py-1`,children:[C.map(e=>(0,$.jsx)(re,{label:e.name,description:g(`settings.credentials.projectDescription`,{key:e.key,workspace:c.get(e.workspaceId)??g(`settings.credentials.workspace`)}),checked:d.includes(e.id),onCheckedChange:t=>f(n=>t?[...n,e.id]:n.filter(t=>t!==e.id))},e.id)),C.length===0&&(0,$.jsx)(`p`,{className:`my-4 text-sm text-muted-foreground`,children:g(`settings.credentials.noMatches`)})]}),(0,$.jsx)(Ee,{children:g(`settings.credentials.roleLimit`)})]}),(0,$.jsxs)(U,{label:g(`settings.credentials.accessLevel`),value:x,onValueChange:e=>{let t=e??`read`;ae(t),t!==`custom`&&_(t===`read`?[`read`]:t===`write`?[`read`,`write`]:[`read`,`write`,`claim`])},children:[(0,$.jsx)(F,{value:`read`,children:g(`settings.credentials.preset.read`)}),(0,$.jsx)(F,{value:`write`,children:g(`settings.credentials.preset.write`)}),(0,$.jsx)(F,{value:`automation`,children:g(`settings.credentials.preset.automation`)}),(0,$.jsx)(F,{value:`custom`,children:g(`settings.credentials.preset.custom`)})]}),x===`custom`&&(0,$.jsx)(W,{className:`gap-0`,children:n.map(e=>(0,$.jsx)(Kt,{scope:e,checked:h.includes(e),onChange:t=>_(n=>t?[...n,e]:n.filter(t=>t!==e))},e))}),(0,$.jsx)(U,{label:g(`settings.credentials.expires`),value:y,onValueChange:e=>b(e??`90`),children:Bt.map(e=>(0,$.jsx)(F,{value:e,children:g(`settings.credentials.expiry.${e}`)},e))}),y===`custom`&&(0,$.jsx)(Ct,{label:g(`settings.credentials.expiresOn`),value:v,onChange:e=>{e&&te(e)},bounds:{from:l,to:u}}),y===`never`&&(0,$.jsx)(Ee,{children:g(`settings.credentials.neverDescription`)}),(0,$.jsx)(Ie,{error:ne,pending:a,submitLabel:g(`settings.credentials.create`),pendingLabel:g(`settings.credentials.creating`),submitDisabled:!p&&!d.length||!h.length,onCancel:i})]})})}function Jt(){let e=Ze(),t=O(),n=z.useSession(),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(``);async function f(){await Promise.all([n.refetch(),e.invalidateQueries({queryKey:[`kanvil`]})])}async function p(e){a(!0),s(void 0),d(``);try{await T.request(`/api/v1/profile/photo`,b,e?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(await R(e))}:{method:`DELETE`}),await f(),d(g(e?`settings.profile.photoUpdated`:`settings.profile.photoRemoved`))}catch(e){s(e)}finally{a(!1)}}return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.profile.title`)}),(0,$.jsx)(Ot,{name:t.name,nameLabel:g(`settings.profile.displayName`),withDescription:!1,canEdit:!0,pending:i,error:c,editLabel:g(`settings.profile.edit`),media:(0,$.jsx)(tt,{label:g(`settings.profile.changePhoto`),round:!0,disabled:i,onClick:()=>r.current?.click(),children:(0,$.jsx)(we,{name:t.name,image:t.image,className:`size-16 text-xl`})}),onSave:async({name:e})=>{l(void 0),a(!0);try{let t=await z.updateUser({name:e});if(t.error)throw Error(t.error.message);await f(),d(g(`settings.profile.saved`))}catch(e){throw l(e),e}finally{a(!1)}},children:(0,$.jsx)(`p`,{className:`mb-0 text-sm break-all text-muted-foreground`,children:t.email})}),t.image&&(0,$.jsxs)(G,{className:`mt-5`,variant:`ghost`,disabled:i,onClick:()=>{p()},children:[(0,$.jsx)(at,{}),g(`settings.profile.removePhoto`)]}),(0,$.jsx)(Ce,{ref:r,type:`file`,disabled:i,accept:`image/png,image/jpeg,image/webp`,className:`hidden`,"aria-label":g(`settings.profile.photoFile`),onChange:e=>{let t=e.currentTarget.files?.[0];t&&p(t),e.currentTarget.value=``}}),(0,$.jsx)(k,{error:o}),u&&(0,$.jsx)(`p`,{role:`status`,className:`mt-4 mb-0 text-sm text-muted-foreground`,children:u})]})}function Yt({palette:e,clip:t}){return(0,$.jsxs)(`g`,{clipPath:t,children:[(0,$.jsx)(`rect`,{width:`160`,height:`96`,fill:e.background}),(0,$.jsx)(`rect`,{width:`34`,height:`96`,fill:e.sidebar}),(0,$.jsx)(`rect`,{x:`7`,y:`10`,width:`19`,height:`4`,rx:`2`,fill:e.primary}),[0,1,2].map(t=>(0,$.jsx)(`rect`,{x:`7`,y:27+t*12,width:t===2?12:21,height:`3`,rx:`1.5`,fill:e.foreground,opacity:`.25`},t)),(0,$.jsx)(`rect`,{x:`45`,y:`12`,width:`65`,height:`5`,rx:`2`,fill:e.foreground,opacity:`.8`}),(0,$.jsx)(`rect`,{x:`127`,y:`10`,width:`23`,height:`8`,rx:`3`,fill:e.primary}),[0,1,2].map(t=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:`45`,y:34+t*18,width:`57`,height:`3`,rx:`1.5`,fill:e.foreground,opacity:`.3`}),(0,$.jsx)(`circle`,{cx:`130`,cy:35+t*18,r:`3`,fill:e.primary,opacity:t===1?1:.35}),(0,$.jsx)(`rect`,{x:`45`,y:43+t*18,width:`105`,height:`.6`,fill:e.foreground,opacity:`.12`})]},t))]})}function Xt({theme:e,mode:t=`system`,variant:n=`wireframe`,className:r}){let i=(0,Q.useId)();if(n===`orb`&&t!==`system`){let n=e[t],i=t===`light`;return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:De(`relative block size-14 shrink-0 overflow-hidden rounded-full border-2 border-background`,r),style:{boxShadow:i?`inset 0 0 0 1px rgb(0 0 0 / .1), 0 1px 2px rgb(0 0 0 / .08)`:`inset 0 0 0 1px rgb(255 255 255 / .14), 0 1px 2px rgb(0 0 0 / .18)`},children:(0,$.jsx)(`span`,{className:`absolute inset-0 rounded-full`,style:{backgroundColor:`color-mix(in oklab, ${n.background} 80%, ${i?`#ffffff`:`#09090b`})`,backgroundImage:`radial-gradient(circle at ${i?`72% 22%`:`28% 78%`} in oklab, ${n.primary} 0%, color-mix(in oklab, ${n.primary} ${i?`72%`:`62%`}, transparent) 28%, transparent 58%), radial-gradient(circle at ${i?`18% 82%`:`82% 18%`} in oklab, color-mix(in oklab, ${n.primary} 45%, transparent) 0%, transparent 55%)`,filter:`blur(3px)`,transform:`scale(1.1)`}})})}return(0,$.jsxs)(`svg`,{viewBox:`0 0 160 96`,preserveAspectRatio:`none`,className:De(`w-full rounded-md`,r),"aria-hidden":`true`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`clipPath`,{id:`${i}-light`,children:(0,$.jsx)(`rect`,{width:`80`,height:`96`})}),(0,$.jsx)(`clipPath`,{id:`${i}-dark`,children:(0,$.jsx)(`rect`,{x:`80`,width:`80`,height:`96`})})]}),t===`system`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yt,{palette:e.light,clip:`url(#${i}-light)`}),(0,$.jsx)(Yt,{palette:e.dark,clip:`url(#${i}-dark)`})]}):(0,$.jsx)(Yt,{palette:e[t]})]})}var Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},..._e,...Je},en=Q.createContext(void 0);function tn(){return Q.useContext(en)}var nn=Q.createContext(void 0);function rn(){let e=Q.useContext(nn);if(e===void 0)throw Error(xe(52));return e}var an=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=tn(),{disabled:h,readOnly:g,required:_,form:ee,checkedValue:v,touched:te=!1,validation:y,name:b,setCheckedValue:re=Qe,setTouched:x=Qe,registerInputRef:S=Qe}=m??{},{setTouched:oe,setFilled:C,state:w,disabled:T}=ve(),E=ue(),{labelId:se,getDescriptionProps:D}=Be(),O=T||E.disabled||h||i,k=g||a,A=_||o,j=ee,M=m?v===c:c===``,N=Q.useRef(null),P=ce(O,N),F=Q.useRef(null),I=y?.registerInput,L=Q.useCallback(e=>I?.(e,{controlRef:N,value:void 0}),[I]),R=ie(l,F,S,L);Fe(()=>{F.current?.checked&&C(!0)},[C]),Fe(()=>{F.current&&S(O&&M?null:F.current)},[M,O,S]);let z=Te(),B=Ke({id:d}),V=u?void 0:B,de={role:`radio`,"aria-checked":M,"aria-labelledby":Me(s,se,F,!u,V,p[`aria-label`]),[jt]:M?``:void 0,id:u?B:z,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||O||k)return;e.preventDefault();let t=F.current;t&&Se(t,e)},onFocus(e){P(!0),!(e.defaultPrevented||O||k||!te)&&(F.current?.click(),x(!1))},onBlur(){m||P(!1)}},{getButtonProps:H,buttonRef:fe}=je({disabled:O,native:u,composite:!1}),U={type:`radio`,ref:R,form:j,id:V,name:b,tabIndex:-1,style:b?be:ne,"aria-hidden":!0,...c===void 0?he:{value:me(c)},disabled:O,checked:M,required:A,readOnly:k,onChange(e){if(e.nativeEvent.defaultPrevented||O||k||c===void 0)return;let t=le(ae,e.nativeEvent);re(c,t),!t.isCanceled&&oe(!0)},onClick(e){e.stopPropagation()},onFocus(){N.current?.focus()}},ge=Q.useMemo(()=>({...w,required:A,disabled:O,readOnly:k,checked:M}),[w,O,k,M,A]),_e=ge,W=m!==void 0,G=[t,N,fe],ye=[de,p,H,D,y?e=>y.getValidationProps(O,e):he],xe=pe(`span`,e,{enabled:!W,state:ge,ref:G,props:ye,stateAttributesMapping:$t});return(0,$.jsxs)(nn.Provider,{value:_e,children:[W?(0,$.jsx)(st,{tag:`span`,render:n,className:r,style:f,state:ge,refs:G,props:ye,stateAttributesMapping:$t}):xe,(0,$.jsx)(`input`,{...U,suppressHydrationWarning:!0})]})}),on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=rn(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Ue(c),f={...s,transitionStatus:u},p=Q.useRef(null),m=a||l,h=pe(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:$t});return Oe({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),sn=[C],cn=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:g,setFocused:_,validationMode:ee,name:v,disabled:te,state:y,validation:b,setDirty:ne,setFilled:re,validityData:x}=ve(),{labelId:ae}=Be(),{clearErrors:oe,elementRef:C}=We(),w=Rt(!0),T=te||i,E=v??d,D=Te(p),[O,k]=qe({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[A,j]=Q.useState(!1),M=Ae((e,t)=>{s?.(e,t),!t.isCanceled&&k(e)}),ce=b.getInputControl,le=Q.useMemo(()=>({get current(){return ce()}}),[ce]),N=Q.useRef(null),P=Q.useRef(null),F=ie(N,f),I=Q.useRef(F),L=Ae(e=>{(N.current!==e||I.current!==F)&&(I.current=F,F?.(e))});Fe(()=>{L(N.current)},[F,L]);let R=Ae(e=>{if(e){if(!e.disabled){P.current||=e;let t=N.current;(e.checked||t==null||t.disabled)&&L(e)}return()=>{P.current===e&&(P.current=null),N.current===e&&L(null)}}}),ue=Ae(()=>{let e=C.current;if(!e)return O??null;for(let t of b.registeredInputs.keys())if(t.checked&&zt(t,e))return O??null;return null});se(le,D,O??null,ue,!T,d),S(O,()=>{oe(E),ne(O!==x.initialValue),re(O!=null),b.change(O);let e=P.current;O==null&&e&&!e.disabled&&L(e)});let z=ae??w?.legendId,B={...y,disabled:T??!1,required:o??!1,readOnly:a??!1},V=Q.useMemo(()=>({checkedValue:O,disabled:T,form:u,validation:b,name:E,readOnly:a,registerInputRef:R,required:o,setCheckedValue:M,setTouched:j,touched:A}),[O,T,u,b,E,a,R,o,M,j,A]),H={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":T||void 0,"aria-readonly":a||void 0,"aria-labelledby":z,onBlur(e){de(e.currentTarget,e.relatedTarget)||(j(!1),g(!0),_(!1),ee===`onBlur`&&b.commit(O))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&j(!0)}};return(0,$.jsx)(en.Provider,{value:V,children:(0,$.jsx)(kt,{render:n,className:r,style:m,state:B,props:[H,h,e=>b.getValidationProps(T??!1,e)],refs:[t],stateAttributesMapping:Je,enableHomeAndEndKeys:!1,modifierKeys:sn})})});function ln({className:e,...t}){return(0,$.jsx)(cn,{"data-slot":`radio-group`,className:De(`grid w-full gap-2`,e),...t})}function un({className:e,...t}){return(0,$.jsx)(an,{"data-slot":`radio-group-item`,className:De(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,$.jsx)(on,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,$.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}var dn=[`system`,`light`,`dark`],fn=e=>M(`${e.id}.kanvil-theme.json`,yt([e]));function pn({theme:e,active:t,activeModes:n,onPickMode:r,actions:i}){return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border border-border/70 bg-background transition-colors hover:bg-accent/10 has-[>[data-slot=radio-group-item]:focus-visible]:ring-2 has-[>[data-slot=radio-group-item]:focus-visible]:ring-ring has-[>[data-slot=radio-group-item]:focus-visible]:ring-offset-2 has-[>[data-slot=radio-group-item]:focus-visible]:ring-offset-background data-[selected=true]:bg-accent/30 data-[selected=true]:shadow-[inset_0_0_0_1px_var(--ring)]`,"data-selected":t,children:[(0,$.jsx)(un,{value:e.id,id:`theme-${e.id}`,className:`peer absolute inset-0 size-full aspect-auto rounded-xl opacity-0`}),(0,$.jsx)(`div`,{className:`pointer-events-none relative flex min-h-16 items-center justify-center gap-2.5 px-3 pt-3`,children:[`light`,`dark`].map(t=>{let i=n.includes(t),a=t===`light`?Et:Dt;return(0,$.jsxs)(ge,{children:[(0,$.jsxs)(x,{render:(0,$.jsx)(G,{variant:`ghost`,"aria-label":g(`settings.appearance.useMode.${t}`,{name:e.name}),"aria-pressed":i,className:`pointer-events-auto relative size-[68px] shrink-0 rounded-full p-1 transition-transform hover:scale-105 hover:bg-transparent aria-pressed:hover:scale-100`,onClick:()=>r(t)}),children:[(0,$.jsx)(Xt,{theme:e,mode:t,variant:`orb`}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 rounded-full ring-2 ring-inset ring-ring`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0.5 right-0.5 flex size-5 items-center justify-center rounded-full border border-border/70 bg-background text-foreground shadow-sm`,children:(0,$.jsx)(a,{className:`size-3`})})]})]}),(0,$.jsx)($e,{children:g(`settings.appearance.modeOnly.${t}`)})]},t)})}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-center gap-2 px-3 pb-3 pt-2`,children:[(0,$.jsx)(ye,{htmlFor:`theme-${e.id}`,title:e.name,className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,$.jsx)(`div`,{className:`pointer-events-auto relative flex shrink-0 items-center gap-1`,children:i})]})]})}var mn=e=>e.toLocaleLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``);function hn(){let e=vt(),t=(0,Q.useRef)(null),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(),l={...e.selected,light:e.lightTheme.light,dark:e.darkTheme.dark};function u(e){r({...e,id:`custom-${crypto.getRandomValues(new Uint32Array(2)).join(`-`)}`,name:g(`settings.appearance.copyName`,{name:e.name})})}let d=e.themes.filter(e=>mn(e.name).includes(mn(i)));return(0,$.jsxs)(`section`,{className:`space-y-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-normal text-muted-foreground`,children:g(`settings.appearance.colorScheme`)}),(0,$.jsx)(ln,{value:e.mode,onValueChange:t=>e.setMode(o(dn).parse(t)),"aria-label":g(`settings.appearance.theme`),className:`grid grid-cols-3 gap-3`,children:dn.map(t=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(un,{id:`mode-${t}`,value:t,className:`peer absolute inset-0 z-10 size-full aspect-auto rounded-xl opacity-0`}),(0,$.jsxs)(ye,{htmlFor:`mode-${t}`,className:`theme-choice flex w-full cursor-pointer flex-col gap-2 rounded-lg border border-border bg-background p-2 text-xs font-medium transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-background hover:bg-muted/50 data-[selected=true]:border-primary data-[selected=true]:ring-1 data-[selected=true]:ring-primary [&_svg]:overflow-hidden [&_svg]:border [&_svg]:border-foreground/10`,"data-selected":e.mode===t,children:[(0,$.jsx)(Xt,{theme:l,mode:t,className:`h-[8.75rem]`}),(0,$.jsx)(`span`,{className:`pb-1`,children:mt[t]})]})]},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`mb-0 text-sm font-normal text-muted-foreground`,children:g(`settings.appearance.themes`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1`,children:[(0,$.jsx)(He,{label:g(`settings.appearance.search`),placeholder:g(`settings.appearance.searchPlaceholder`),value:i,onChange:a}),(0,$.jsx)(D,{label:g(`settings.appearance.create`),size:`icon-sm`,onClick:()=>u(l),children:(0,$.jsx)(et,{})}),(0,$.jsx)(D,{label:g(`settings.appearance.add`),size:`icon-sm`,onClick:()=>t.current?.click(),children:(0,$.jsx)(lt,{})})]})]}),(0,$.jsx)(Ce,{ref:t,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":g(`settings.appearance.importFile`),onChange:t=>{let n=t.currentTarget.files?.[0];n&&(c(void 0),n.text().then(t=>e.importThemes(_t(t))).catch(c),t.currentTarget.value=``)}}),(0,$.jsx)(k,{error:s}),(0,$.jsx)(ln,{"aria-label":g(`settings.appearance.colorTheme`),value:e.color,onValueChange:t=>e.setColor(String(t)),className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-2`,children:d.map(t=>(0,$.jsx)(pn,{theme:t,active:t.id===e.color,activeModes:[`light`,`dark`].filter(n=>(n===`light`?e.lightTheme.id:e.darkTheme.id)===t.id),onPickMode:n=>e.setColorForMode(n,t.id),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{label:g(`settings.appearance.duplicate`,{name:t.name}),className:`size-6`,onClick:()=>u(t),children:(0,$.jsx)(P,{})}),t.id.startsWith(`custom-`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{label:g(`settings.appearance.edit`,{name:t.name}),className:`size-6`,onClick:()=>r(t),children:(0,$.jsx)(ot,{})}),(0,$.jsx)(D,{label:g(`settings.appearance.export`,{name:t.name}),className:`size-6`,onClick:()=>fn(t),children:(0,$.jsx)(it,{})}),(0,$.jsx)(B,{label:g(`settings.appearance.delete`,{name:t.name}),description:g(`settings.appearance.deleteDescription`,{name:t.name}),danger:!0,icon:(0,$.jsx)(at,{}),onConfirm:async()=>e.remove(t.id)})]})]})},t.id))}),d.length===0&&(0,$.jsx)(`p`,{role:`status`,className:`mt-4`,children:g(`settings.appearance.noMatches`)})]}),(0,$.jsx)(I,{title:g(`settings.appearance.customTheme`),open:!!n,onOpenChange:e=>{e||r(null)},children:n&&(0,$.jsx)(gn,{initial:n,onSaved:t=>{e.save(t),a(``),r(null)}})})]})}function gn({initial:e,onSaved:t}){let[n,r]=(0,Q.useState)(e),[i,a]=(0,Q.useState)();return(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(void 0);try{t(dt(n))}catch(e){a(e)}},children:[(0,$.jsx)(H,{label:g(`settings.appearance.name`),value:n.name,required:!0,maxLength:60,onChange:e=>r({...n,name:e.target.value})}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-5`,children:[`light`,`dark`].map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:mt[e]}),(0,$.jsx)(Xt,{theme:n,mode:e}),(0,$.jsx)(`div`,{className:`mt-4 space-y-3`,children:ht.keyof().options.map(t=>(0,$.jsx)(H,{label:g(`settings.appearance.paletteColor`,{mode:mt[e],color:g(`settings.appearance.color.${t}`)}),type:`color`,value:n[e][t],onChange:i=>r({...n,[e]:{...n[e],[t]:i.target.value}})},t))})]},e))}),(0,$.jsx)(k,{error:i}),(0,$.jsx)(G,{type:`submit`,variant:`default`,className:`mt-4`,children:g(`settings.appearance.save`)})]})}function _n({section:e}){let[t,n]=xt(),r=O(),i=fe(),a=Le({queryKey:[`accounts`],refetchOnMount:`always`,queryFn:async()=>{let e=await z.listAccounts();if(e.error)throw Error(e.error.message);return e.data}}),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);async function u(e){e.preventDefault(),n(void 0);let t=new FormData(e.currentTarget);if(t.get(`next`)!==t.get(`confirm`))n(Error(g(`settings.account.passwordMismatch`)));else{l(!0);try{let e=await z.changePassword({currentPassword:ut(t,`current`),newPassword:ut(t,`next`),revokeOtherSessions:!0});if(e.error)throw Error(e.error.message);s(!1),N.success(g(`settings.account.passwordUpdated`))}catch(e){n(e)}finally{l(!1)}}}return(0,$.jsxs)(Tt,{title:g(`settings.account.title`),section:e,children:[(0,$.jsxs)(J,{value:`account`,children:[(0,$.jsx)(Jt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.account.security`)}),(0,$.jsx)(Y,{title:g(`settings.account.localPassword`),description:g(`settings.account.localPasswordDescription`),children:(0,$.jsx)(G,{onClick:()=>{n(void 0),s(!0)},children:g(`settings.account.changePassword`)})}),i.data?.providers.map(e=>{let t=a.data?.some(t=>t.providerId===e.id);return(0,$.jsx)(Y,{title:e.name,description:g(t?`settings.account.oidcLinked`:`settings.account.oidcUnlinked`),children:t?(0,$.jsx)(Xe,{variant:`secondary`,children:g(`settings.account.linked`)}):(0,$.jsx)(G,{disabled:c,onClick:()=>{l(!0),n(void 0),z.linkSocial({provider:e.id,callbackURL:`${window.location.origin}/settings?section=account`,errorCallbackURL:`${window.location.origin}/settings?section=account`}).then(e=>{if(e.error)throw Error(e.error.message)}).catch(n).finally(()=>l(!1))},children:g(`settings.account.link`,{name:e.name})})},e.id)}),(0,$.jsx)(rt,{account:r,onDeleted:()=>j(r).catch(()=>{r.clearPrivateData(),window.location.assign(`/login`)})}),!o&&(0,$.jsx)(k,{error:t}),(0,$.jsx)(k,{error:a.error??i.error})]}),(0,$.jsx)(I,{title:g(`settings.account.changePassword`),open:o,onOpenChange:s,busy:c,children:(0,$.jsxs)(`form`,{onSubmit:e=>{u(e)},children:[(0,$.jsx)(H,{label:g(`settings.account.currentPassword`),name:`current`,type:`password`,autoComplete:`current-password`,required:!0}),(0,$.jsx)(H,{label:g(`settings.account.newPassword`),name:`next`,type:`password`,autoComplete:`new-password`,required:!0,minLength:12,maxLength:128}),(0,$.jsx)(H,{label:g(`settings.account.confirmPassword`),name:`confirm`,type:`password`,autoComplete:`new-password`,required:!0,minLength:12,maxLength:128}),(0,$.jsx)(Ie,{error:t,pending:c,submitLabel:g(`settings.account.changePassword`),onCancel:()=>s(!1)})]})})]}),(0,$.jsx)(J,{value:`appearance`,children:(0,$.jsx)(hn,{})}),(0,$.jsx)(J,{value:`preferences`,children:(0,$.jsx)(vn,{})}),(0,$.jsx)(J,{value:`credentials`,children:(0,$.jsx)(Wt,{})}),(0,$.jsxs)(J,{value:`notifications`,children:[(0,$.jsx)(yn,{pushAvailable:i.data?.push??!1}),(0,$.jsx)(nt,{emailAvailable:i.data?.email??!1})]})]})}function vn(){let e=O(),[t,n]=ft(q.weekStart),[r,i]=ft(q.sidebar),{preference:a}=pt();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(K,{title:g(`settings.preferences.behavior`)}),(0,$.jsx)(Y,{title:g(`common.language.label`),description:g(`settings.preferences.languageDescription`),children:(0,$.jsxs)(U,{label:g(`common.language.label`),labelHidden:!0,className:`mb-0 w-44`,value:a,onValueChange:e=>void gt(u.parse(e)).catch(Ye),children:[(0,$.jsx)(F,{value:`system`,children:g(`common.language.system`)}),d.map(e=>(0,$.jsx)(F,{value:e,lang:e,children:y[e].name},e))]})}),(0,$.jsx)(Y,{title:g(`settings.preferences.weekStart`),description:g(`settings.preferences.weekStartDescription`),children:(0,$.jsxs)(U,{label:g(`settings.preferences.weekStart`),labelHidden:!0,className:`mb-0 w-44`,value:t,onValueChange:e=>n(q.weekStart.schema.parse(e)),children:[(0,$.jsx)(F,{value:`language`,children:g(`settings.preferences.weekStartLanguage`)}),(0,$.jsx)(F,{value:`sunday`,children:p(new Date(2023,0,1),{weekday:`long`})}),(0,$.jsx)(F,{value:`monday`,children:p(new Date(2023,0,2),{weekday:`long`})}),(0,$.jsx)(F,{value:`saturday`,children:p(new Date(2023,0,7),{weekday:`long`})})]})}),(0,$.jsx)(Y,{title:g(`settings.preferences.sidebar`),description:g(`settings.preferences.sidebarDescription`),children:(0,$.jsxs)(U,{label:g(`settings.preferences.sidebar`),labelHidden:!0,className:`mb-0 w-44`,value:r,onValueChange:e=>i(q.sidebar.schema.parse(e)),children:[(0,$.jsx)(F,{value:`last`,children:g(`settings.preferences.sidebarLast`)}),(0,$.jsx)(F,{value:`expanded`,children:g(`settings.preferences.sidebarExpanded`)}),(0,$.jsx)(F,{value:`collapsed`,children:g(`settings.preferences.sidebarCollapsed`)})]})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(K,{title:g(`settings.preferences.ticketLists`)}),(0,$.jsx)(`div`,{className:`grid max-w-sm gap-3`,children:(0,$.jsx)(ct,{})})]}),(0,$.jsx)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:(0,$.jsx)(Y,{title:g(`settings.preferences.reset`),description:g(`settings.preferences.resetDescription`),children:(0,$.jsx)(G,{variant:`outline`,onClick:()=>{At(e.id,Object.values(q)),N.success(g(`settings.preferences.resetDone`))},children:g(`settings.preferences.reset`)})})})]})}function yn({pushAvailable:e}){let n=Ze(),r=T.notificationPreferences(),i=Le(r),a=A({mutationFn:e=>T.setNotificationPreferences(e),networkMode:`always`,retry:!1,onSuccess:e=>n.setQueryData(r.queryKey,e)}),o=a.isPending?a.variables:i.data,s=e=>{o&&a.mutate({...o,...e})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(K,{title:g(`settings.notifications.title`)}),(0,$.jsx)(k,{error:i.error??a.error}),i.isPending?(0,$.jsx)(V,{}):o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{title:g(`settings.notifications.inbox`),description:g(`settings.notifications.inboxDescription`),children:(0,$.jsx)(Mt,{"aria-label":g(`settings.notifications.inboxSwitch`),checked:o.inApp,disabled:a.isPending,onCheckedChange:e=>s({inApp:e})})}),(0,$.jsx)(Y,{title:g(`settings.notifications.push`),description:g(e?`settings.notifications.pushDescription`:`settings.notifications.pushUnavailable`),children:(0,$.jsx)(Mt,{"aria-label":g(`settings.notifications.pushSwitch`),checked:o.push,disabled:a.isPending||!e,onCheckedChange:e=>s({push:e})})})]})]}),o&&(0,$.jsxs)(`section`,{className:`[&>.setting-row:last-child]:border-b-0`,children:[(0,$.jsx)(K,{title:g(`settings.notifications.categories`)}),te.map(e=>{let t=wt[e];return(0,$.jsx)(Y,{compact:!0,title:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(t,{"aria-hidden":!0,className:`size-4 text-muted-foreground`}),l[e]]}),children:(0,$.jsx)(Mt,{"aria-label":g(`settings.notifications.categorySwitch`,{label:l[e]}),checked:o.categories[e],disabled:a.isPending,onCheckedChange:t=>s({categories:{...o.categories,[e]:t}})})},e)}),(0,$.jsx)(Y,{title:g(`settings.notifications.reminder`),description:g(`settings.notifications.reminderDescription`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(bn,{value:o.reminderLead.amount,disabled:a.isPending||!o.categories.due_soon,onCommit:e=>s({reminderLead:{...o.reminderLead,amount:e}})},o.reminderLead.amount),(0,$.jsx)(U,{label:g(`settings.notifications.reminderUnit`),labelHidden:!0,className:`mb-0 w-32`,value:o.reminderLead.unit,disabled:a.isPending||!o.categories.due_soon,onValueChange:e=>s({reminderLead:{...o.reminderLead,unit:t.parse(e)}}),children:m.map(e=>(0,$.jsx)(F,{value:e,children:g(`settings.notifications.unit.${e}`)},e))})]})})]})]})}function bn({value:e,disabled:t,onCommit:n}){let[r,i]=(0,Q.useState)(String(e)),a=()=>{let t=Number(r);Number.isInteger(t)&&t>=1&&t<=999?t!==e&&n(t):i(String(e))};return(0,$.jsx)(H,{label:g(`settings.notifications.reminderAmount`),labelHidden:!0,type:`number`,inputMode:`numeric`,min:1,max:999,className:`w-20`,value:r,disabled:t,onChange:e=>i(e.currentTarget.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()}})}export{_n as AccountSettings};
@@ -1 +1 @@
1
- import{Ga as e}from"./search-ZaQmVnj1.js";var t={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};t.node;var n=e(t);export{n as t};
1
+ import{Ga as e}from"./search-B3-w3oCd.js";var t={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Nn as t,r as n}from"./default-BgvtI7HK.js";import{$n as ee,Ca as te,Er as r,Fr as i,Ir as ne,Lr as a,Nr as o,_a as s,ba as re,ci as ie,er as ae,ha as oe,hi as se,ii as ce,ka as c,mi as le,ni as l,pa as u,ri as d,si as f,ti as p,tr as m,ui as h}from"./search-ZaQmVnj1.js";var g=e(t(),1),_=g.createContext(void 0);function v(){let e=g.useContext(_);if(e===void 0)throw Error(oe(63));return e}var y=`data-checked`,b=`data-unchecked`,x={...h,checked(e){return e?{[y]:``}:{[b]:``}}},S=n(),C=g.forwardRef(function(e,t){let{checked:n,className:oe,defaultChecked:c,"aria-labelledby":h,form:v,id:y,inputRef:b,name:C,nativeButton:w=!1,onCheckedChange:T,readOnly:E=!1,required:D=!1,disabled:O=!1,render:ue,uncheckedValue:k,value:A,style:de,...j}=e,{clearErrors:M}=f(),{state:N,setTouched:P,setDirty:F,validityData:I,setFilled:L,validationMode:R,disabled:z,name:B,validation:V}=ie(),{labelId:H}=d(),U=z||O,W=B??C,G=g.useRef(null),fe=te(G,b,V.inputRef),K=g.useRef(null),q=a(U,K),J=ce(),Y=p({id:y}),X=w?void 0:Y,[Z,pe]=m({controlled:n,default:!!c,name:`Switch`,state:`checked`});ne(K,J,Z,void 0,!U,C),u(()=>{L(Z)},[Z,L]),i(Z,()=>{M(W),F(Z!==I.initialValue),V.change(Z)});let{getButtonProps:me,buttonRef:he}=le({disabled:U,native:w}),ge=l(h,H,G,!w,X,j[`aria-label`]),_e={id:w?Y:J,role:`switch`,"aria-checked":Z,"aria-readonly":E||void 0,"aria-required":D||void 0,"aria-labelledby":ge,onFocus(){q(!0)},onBlur(){let e=G.current;e&&!U&&(P(!0),q(!1),R===`onBlur`&&V.commit(e.checked))},onClick(e){if(E||U)return;e.preventDefault();let t=G.current;t&&se(t,e)}},Q={...V.getValidationProps(U),checked:Z,disabled:U,form:v,id:X,name:W,required:D,style:W?ae:ee,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:fe,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(E){e.preventDefault();return}let t=e.currentTarget.checked,n=o(r,e.nativeEvent);T?.(t,n),!n.isCanceled&&pe(t)},onClick(e){e.stopPropagation()},onFocus(){K.current?.focus()},...A===void 0?re:{value:A}},$=g.useMemo(()=>({...N,checked:Z,disabled:U,readOnly:E,required:D}),[N,Z,U,E,D]),ve=s(`span`,e,{state:$,ref:[t,K,he],props:[_e,j,me,e=>V.getValidationProps(U,e)],stateAttributesMapping:x});return(0,S.jsxs)(_.Provider,{value:$,children:[ve,!Z&&W&&k!==void 0&&(0,S.jsx)(`input`,{type:`hidden`,form:v,name:W,value:k,disabled:U}),(0,S.jsx)(`input`,{...Q,suppressHydrationWarning:!0})]})}),w=g.forwardRef(function(e,t){let{render:n,className:ee,style:te,...r}=e,i=v();return s(`span`,e,{state:i,ref:t,stateAttributesMapping:x,props:r})});function T({className:e,size:t=`default`,...n}){return(0,S.jsx)(C,{"data-slot":`switch`,"data-size":t,className:c(`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-transparent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background 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`,e),...n,children:(0,S.jsx)(w,{"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{T as t};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Nn as t,r as n}from"./default-6QIAyMq2.js";import{$n as ee,Ca as te,Er as r,Fr as i,Ir as ne,Lr as a,Nr as o,_a as s,ba as re,ci as ie,er as ae,ha as oe,hi as se,ii as ce,ka as c,mi as le,ni as l,pa as u,ri as d,si as f,ti as p,tr as m,ui as h}from"./search-B3-w3oCd.js";var g=e(t(),1),_=g.createContext(void 0);function v(){let e=g.useContext(_);if(e===void 0)throw Error(oe(63));return e}var y=`data-checked`,b=`data-unchecked`,x={...h,checked(e){return e?{[y]:``}:{[b]:``}}},S=n(),C=g.forwardRef(function(e,t){let{checked:n,className:oe,defaultChecked:c,"aria-labelledby":h,form:v,id:y,inputRef:b,name:C,nativeButton:w=!1,onCheckedChange:T,readOnly:E=!1,required:D=!1,disabled:O=!1,render:ue,uncheckedValue:k,value:A,style:de,...j}=e,{clearErrors:M}=f(),{state:N,setTouched:P,setDirty:F,validityData:I,setFilled:L,validationMode:R,disabled:z,name:B,validation:V}=ie(),{labelId:H}=d(),U=z||O,W=B??C,G=g.useRef(null),fe=te(G,b,V.inputRef),K=g.useRef(null),q=a(U,K),J=ce(),Y=p({id:y}),X=w?void 0:Y,[Z,pe]=m({controlled:n,default:!!c,name:`Switch`,state:`checked`});ne(K,J,Z,void 0,!U,C),u(()=>{L(Z)},[Z,L]),i(Z,()=>{M(W),F(Z!==I.initialValue),V.change(Z)});let{getButtonProps:me,buttonRef:he}=le({disabled:U,native:w}),ge=l(h,H,G,!w,X,j[`aria-label`]),_e={id:w?Y:J,role:`switch`,"aria-checked":Z,"aria-readonly":E||void 0,"aria-required":D||void 0,"aria-labelledby":ge,onFocus(){q(!0)},onBlur(){let e=G.current;e&&!U&&(P(!0),q(!1),R===`onBlur`&&V.commit(e.checked))},onClick(e){if(E||U)return;e.preventDefault();let t=G.current;t&&se(t,e)}},Q={...V.getValidationProps(U),checked:Z,disabled:U,form:v,id:X,name:W,required:D,style:W?ae:ee,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:fe,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(E){e.preventDefault();return}let t=e.currentTarget.checked,n=o(r,e.nativeEvent);T?.(t,n),!n.isCanceled&&pe(t)},onClick(e){e.stopPropagation()},onFocus(){K.current?.focus()},...A===void 0?re:{value:A}},$=g.useMemo(()=>({...N,checked:Z,disabled:U,readOnly:E,required:D}),[N,Z,U,E,D]),ve=s(`span`,e,{state:$,ref:[t,K,he],props:[_e,j,me,e=>V.getValidationProps(U,e)],stateAttributesMapping:x});return(0,S.jsxs)(_.Provider,{value:$,children:[ve,!Z&&W&&k!==void 0&&(0,S.jsx)(`input`,{type:`hidden`,form:v,name:W,value:k,disabled:U}),(0,S.jsx)(`input`,{...Q,suppressHydrationWarning:!0})]})}),w=g.forwardRef(function(e,t){let{render:n,className:ee,style:te,...r}=e,i=v();return s(`span`,e,{state:i,ref:t,stateAttributesMapping:x,props:r})});function T({className:e,size:t=`default`,...n}){return(0,S.jsx)(C,{"data-slot":`switch`,"data-size":t,className:c(`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-transparent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background 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`,e),...n,children:(0,S.jsx)(w,{"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{T as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-COiEfhsA.js";import{Nn as e,r as t}from"./default-BgvtI7HK.js";import{ka as n}from"./search-ZaQmVnj1.js";e();var r=t();function i({className:e,mobileLayout:t=`scroll`,...i}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,role:`table`,"data-mobile-layout":t,className:n(`w-full caption-bottom text-sm`,e),...i})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{role:`rowgroup`,"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{role:`rowgroup`,"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{role:`row`,"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{role:`columnheader`,"data-slot":`table-head`,className:n(`h-8 px-3 text-left align-middle text-xs font-normal whitespace-nowrap text-muted-foreground [&:has([role=checkbox])]:pr-0 text-[10.5px] font-medium tracking-[0.08em] uppercase`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{role:`cell`,"data-slot":`table-cell`,className:n(`px-3 py-2 align-middle text-[13px] whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
1
+ import"./rolldown-runtime-COiEfhsA.js";import{Nn as e,r as t}from"./default-6QIAyMq2.js";import{ka as n}from"./search-B3-w3oCd.js";e();var r=t();function i({className:e,mobileLayout:t=`scroll`,...i}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,role:`table`,"data-mobile-layout":t,className:n(`w-full caption-bottom text-sm`,e),...i})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{role:`rowgroup`,"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{role:`rowgroup`,"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{role:`row`,"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{role:`columnheader`,"data-slot":`table-head`,className:n(`h-8 px-3 text-left align-middle text-xs font-normal whitespace-nowrap text-muted-foreground [&:has([role=checkbox])]:pr-0 text-[10.5px] font-medium tracking-[0.08em] uppercase`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{role:`cell`,"data-slot":`table-cell`,className:n(`px-3 py-2 align-middle text-[13px] whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ticket-editor-DL3nHG_q.js","assets/rolldown-runtime-COiEfhsA.js","assets/default-BgvtI7HK.js","assets/core-jXc03Sty.js","assets/en-EnSRisMz.js","assets/preload-helper-BLdHbfdN.js","assets/search-ZaQmVnj1.js","assets/toDate-B3HYxwtT.js","assets/item-Cj8xpMLk.js","assets/CompositeItem-DgnfVvrF.js","assets/forms-C3pNy-qY.js","assets/corner-left-up-BCro--Gl.js","assets/rotate-ccw-GjVJPDML.js","assets/sliders-horizontal-C1t_zA7D.js","assets/upload-BwGa8shS.js","assets/index-BIuqxnJn.js","assets/Trans-f2VYVS9z.js","assets/en-US-DKYSujv3.js","assets/index-DyQNFS69.css","assets/switch-D-WTDajm.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Dt as t,Nn as n,Ot as r,W as i,i as a,kt as o,mn as s,r as c,vt as l}from"./default-BgvtI7HK.js";import{B as u,Ba as d,G as f,Ga as p,Ha as m,Hi as h,Ii as g,J as _,Ji as v,K as y,Oa as b,Pi as x,Pt as S,Q as C,V as w,Va as ee,X as te,Xn as T,Z as E,Zi as D,_t as O,at as k,di as A,ea as j,et as ne,ft as re,it as M,nt as ie,ot as N,q as P,qa as F,ut as ae,zi as oe}from"./search-ZaQmVnj1.js";import{t as I}from"./preload-helper-BLdHbfdN.js";import{t as L}from"./useQueries-sQEHjB0a.js";import{a as R,g as z,n as B,r as V,t as H}from"./item-Cj8xpMLk.js";import{t as se}from"./archive-restore-CGuLxoHC.js";import{n as ce,r as le,t as ue}from"./Trans-f2VYVS9z.js";import{n as U,r as de}from"./CompositeItem-DgnfVvrF.js";import{t as fe}from"./corner-left-up-BCro--Gl.js";import{t as pe}from"./ellipsis-ZJM26JNS.js";import{t as W}from"./send-Dr9bXHhf.js";import{r as G}from"./forms-C3pNy-qY.js";import{$ as me,A as he,B as ge,Ht as _e,I as ve,J as ye,N as be,R as K,U as xe,Ut as Se,V as Ce,Vt as we,Wt as Te,_ as q,b as J,bn as Ee,cn as De,dt as Y,et as Oe,g as ke,gt as Ae,h as X,j as je,m as Me,pt as Ne,q as Pe,tt as Z,x as Fe,yn as Ie}from"./index-BIuqxnJn.js";import{TicketEditor as Le,a as Re,i as ze,l as Be,n as Ve,o as He,r as Ue,s as We,t as Ge}from"./ticket-editor-DL3nHG_q.js";var Ke={name:`git-branch-plus`,size:24,node:[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]};Ke.node;var qe=p(Ke),Je={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Je.node;var Ye=p(Je),Q=e(n(),1),$=c(),Xe=(0,Q.lazy)(()=>I(()=>import(`./ticket-editor-DL3nHG_q.js`).then(e=>({default:e.TicketEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Ze({ticket:e}){let t=j(e.projectId),n=F(h.query(`list_relations`,{projectId:e.projectId,ticketId:e.id})),[i,a]=(0,Q.useState)(!1),[c,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(0),[g,v]=(0,Q.useState)(),b=F({...h.query(`get_ticket`,{projectId:e.projectId,ticketId:e.parentId??e.id}),enabled:!!e.parentId}),x=F(h.query(`list_tickets`,{projectId:e.projectId,parentId:e.id,archived:`include`,limit:20,offset:p})),w=L({queries:Array.from({length:Math.ceil((n.data?.length??0)/100)},(t,n)=>h.query(`list_tickets`,{projectId:e.projectId,relatedTo:e.id,archived:`include`,sort:`number`,limit:100,offset:n*100}))}),ee=new Map(w.flatMap(e=>e.data?.items??[]).map(e=>[e.id,e])),T=D(`add_relation`),E=D(`remove_relation`);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(M,{compact:!0,title:s(`detail.relations.heading`),action:t.canWrite&&(0,$.jsxs)(ge,{children:[(0,$.jsx)(Pe,{render:(0,$.jsx)(_,{label:s(`detail.relations.add`)}),children:(0,$.jsx)(z,{})}),(0,$.jsxs)(Ce,{align:`end`,className:`w-48`,children:[(0,$.jsxs)(xe,{onClick:()=>{T.reset(),v(void 0),f(null),a(!0)},children:[(0,$.jsx)(Ye,{}),s(`detail.relations.linkExisting`)]}),(0,$.jsxs)(xe,{onClick:()=>u(!0),children:[(0,$.jsx)(qe,{}),s(`detail.relations.newChild`)]})]})]})}),e.parentId&&(0,$.jsxs)(H,{size:`xs`,className:`px-0`,children:[(0,$.jsx)(fe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsxs)(V,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(`detail.field.parent`)}),(0,$.jsx)(J,{projectId:e.projectId,ticketId:e.parentId,ticket:b.data?.ticket})]})]}),x.data&&(x.data.total>0||p>0)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`mt-3 mb-1 text-xs text-muted-foreground`,children:(0,$.jsx)(ue,{i18nKey:`detail.relations.children`,values:{done:x.data.items.filter(e=>e.status===`done`).length,total:x.data.total},components:{count:(0,$.jsx)(`span`,{className:`tabular-nums`})}})}),(0,$.jsx)(R,{className:`gap-0`,children:x.data.items.map(n=>(0,$.jsx)(Qe,{projectId:e.projectId,ticketId:n.id,ticket:n,canWrite:t.canWrite,children:(0,$.jsx)(J,{projectId:e.projectId,ticketId:n.id,ticket:n})},n.id))}),(x.data.total>20||p>0)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(A,{size:`sm`,disabled:!p,onClick:()=>m(Math.max(0,p-20)),children:s(`detail.relations.previousChildren`)}),(0,$.jsx)(A,{size:`sm`,disabled:p+20>=x.data.total,onClick:()=>m(p+20),children:s(`detail.relations.nextChildren`)})]})]}),(0,$.jsx)(R,{className:`gap-0`,children:n.data?.map(n=>{let r=o(n,e.id);return(0,$.jsx)(Qe,{projectId:e.projectId,ticketId:r.id,ticket:ee.get(r.id),canWrite:t.canWrite,label:r.label,action:(0,$.jsx)(_,{size:`icon-sm`,label:s(`detail.relations.remove.${n.type}`),onClick:()=>E.mutate({projectId:e.projectId,relationId:n.id}),children:(0,$.jsx)(Ye,{})}),children:(0,$.jsx)(J,{projectId:e.projectId,ticketId:r.id,children:r.title})},n.id)})}),!e.parentId&&!x.data?.total&&n.data?.length===0&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:s(`detail.relations.empty`)}),(0,$.jsx)(C,{title:s(`detail.relations.add`),open:i,onOpenChange:a,busy:T.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);d&&(v(void 0),T.mutateAsync({projectId:e.projectId,ticketId:e.id,targetId:d,...l(n.get(`type`))}).then(()=>a(!1)).catch(v))},children:[(0,$.jsx)(k,{label:s(`detail.relations.type`),name:`type`,children:r.map(e=>(0,$.jsx)(S,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(We,{projectId:e.projectId,label:s(`detail.relations.ticket`),value:d,onChange:f,exclude:[e.id],allowClear:!1}),(0,$.jsx)(P,{error:g??T.error,pending:T.isPending,submitLabel:s(`detail.relations.add`),submitDisabled:!d,onCancel:()=>a(!1)})]})}),(0,$.jsx)(C,{size:`composer`,title:s(`detail.relations.newChildTitle`,{key:e.key}),open:c,onOpenChange:u,children:c&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(te,{}),children:(0,$.jsx)(Xe,{projectId:e.projectId,initial:{parentId:e.id,labels:e.labels,scopes:e.scopes},onSaved:()=>u(!1)})})}),(0,$.jsx)(y,{error:n.error??E.error??b.error??x.error??w.find(e=>e.error)?.error})]})}function Qe({projectId:e,ticketId:t,ticket:n,canWrite:r,label:i,action:a,children:o}){let{change:c,pending:l}=Ne({id:t,projectId:e,version:n?.version??0}),u=r&&n;return(0,$.jsxs)(H,{size:`xs`,className:`px-0`,children:[u?(0,$.jsx)(Z,{property:`status`,value:Y(n),onChange:e=>void c({status:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,ariaLabel:s(`detail.relations.statusOf`,{key:n.key}),className:`mx-0`}):n&&(0,$.jsx)(me,{property:`status`,value:Y(n),projectId:e,iconOnly:!0}),(0,$.jsxs)(V,{className:`min-w-0 gap-0`,children:[i&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),o]}),(u||n?.assigneeId||r&&a)&&(0,$.jsxs)(B,{className:`gap-0`,children:[u?(0,$.jsx)(Z,{property:`assignee`,value:n.assigneeId,onChange:e=>void c({assignee:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,align:`end`,ariaLabel:s(`detail.relations.assigneeOf`,{key:n.key}),className:`mx-0`}):n?.assigneeId&&(0,$.jsx)(me,{property:`assignee`,value:n.assigneeId,projectId:e,iconOnly:!0}),r&&a]})]})}function $e({ticket:e,anchor:t}){let[n,r]=(0,Q.useState)(0),[i,a]=(0,Q.useState)(``),o=F(h.query(`list_comments`,{projectId:e.projectId,ticketId:e.id,offset:n})),c=t.startsWith(`comment-`)?t.slice(8):null,[l,u]=(0,Q.useState)(c),[d,p]=(0,Q.useState)(c!==null);c!==l&&(u(c),p(c!==null)),d&&o.data&&(o.data.items.some(e=>e.id===c)?p(!1):n+50<o.data.total?r(n+50):p(!1));let m=Re(e.projectId,{ticketId:e.id}),g=D(`add_comment`),_=j(e.projectId);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(y,{error:o.error??g.error}),o.data?.total===0&&(0,$.jsx)(f,{title:s(`detail.discussion.empty`),icon:De,className:`py-8`}),(0,$.jsx)(`div`,{className:`divide-y`,children:o.data?.items.map(e=>(0,$.jsx)(et,{comment:e,linked:e.id===c},e.id))}),((o.data?.total??0)>50||n>0)&&(0,$.jsxs)(He,{className:`mt-5 justify-end`,children:[(0,$.jsx)(A,{size:`sm`,disabled:!n,onClick:()=>r(Math.max(0,n-50)),children:s(`detail.discussion.previous`)}),(0,$.jsx)(A,{size:`sm`,disabled:n+50>=(o.data?.total??0),onClick:()=>r(n+50),children:s(`detail.discussion.next`)})]}),_.canWrite&&(0,$.jsx)(`form`,{onKeyDown:G,className:`mt-6`,onSubmit:t=>{t.preventDefault(),g.mutateAsync({projectId:e.projectId,ticketId:e.id,body:i}).then(()=>a(e=>e===i?``:e)).catch(()=>{})},children:(0,$.jsx)(Be,{label:s(`detail.discussion.comment`),value:i,onChange:a,rows:3,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:m,placeholder:s(`detail.discussion.placeholder`),footer:(0,$.jsxs)(A,{type:`submit`,variant:`default`,disabled:g.isPending||!i.trim(),children:[g.isPending?(0,$.jsx)(O,{}):(0,$.jsx)(W,{}),g.isPending?s(`detail.discussion.posting`):s(`detail.discussion.comment`),(0,$.jsx)(T,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})})})]})}function et({comment:e,linked:t}){let n=v(),r=j(e.projectId),i=D(`update_comment`),a=Re(e.projectId,{ticketId:e.ticketId}),o=D(`delete_comment`),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(e.body),[f,p]=(0,Q.useState)(e.version),m=e.actorId===n.id,h=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{t&&h.current?.scrollIntoView({block:`center`})},[t]),(0,$.jsxs)(`article`,{ref:h,id:`comment-${e.id}`,"data-linked":t,className:`group/comment relative scroll-mt-16 py-4 animate-in fade-in-0 duration-200 data-[linked=true]:animate-row-in data-[linked=true]:shadow-[inset_2px_0_0_var(--primary)] data-[linked=true]:pl-3`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex min-h-8 flex-wrap items-center gap-x-3 gap-y-1 pr-20 text-xs text-muted-foreground`,children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:(0,$.jsx)(oe,{projectId:e.projectId,actorId:e.actorId,avatar:!0})}),(0,$.jsx)(ie,{value:e.createdAt}),e.updatedAt!==e.createdAt&&(0,$.jsx)(`span`,{children:s(`detail.discussion.edited`)})]}),c?(0,$.jsx)(`form`,{onKeyDown:G,onSubmit:t=>{t.preventDefault(),i.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:f,body:u}).then(()=>l(!1)).catch(()=>{})},children:(0,$.jsx)(Be,{label:s(`detail.discussion.edit`),value:u,onChange:d,rows:4,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:a,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{size:`sm`,disabled:i.isPending,onClick:()=>l(!1),children:s(`common.action.cancel`)}),(0,$.jsxs)(A,{type:`submit`,size:`sm`,variant:`default`,disabled:i.isPending||!u.trim(),children:[i.isPending?(0,$.jsx)(O,{}):null,s(`common.action.save`)]})]})})}):(0,$.jsx)(E,{children:e.body}),!c&&r.canWrite&&(m||n.admin)&&(0,$.jsxs)(`div`,{className:`absolute top-3 right-0 flex items-center gap-1 opacity-0 transition-opacity group-hover/comment:opacity-100 focus-within:opacity-100 max-md:opacity-100`,children:[(0,$.jsx)(_,{label:s(`detail.discussion.edit`),size:`icon-sm`,onClick:()=>{d(e.body),p(e.version),l(!0)},children:(0,$.jsx)(de,{})}),(0,$.jsx)(w,{label:s(`detail.discussion.delete`),icon:(0,$.jsx)(U,{}),danger:!0,description:s(`detail.discussion.deleteConfirm`),onConfirm:()=>o.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:e.version})})]}),(0,$.jsx)(y,{error:i.error})]})}function tt({projectId:e,ticketId:n,preview:r}){let o=j(e),c=F(h.query(`get_ticket`,{projectId:e,ticketId:n})),l=D(`set_subscription`),[u,p]=(0,Q.useState)(!1),[v,S]=(0,Q.useState)(!1),w=Te(),[T]=(0,Q.useState)(()=>r?[]:ve(e)),k=r?.order??T,M=k.indexOf(n),N=t=>{let n=M<0?void 0:k[M+t];n&&(r?r.open(n):w({to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:e,ticketId:n}}))},P=r?`[data-slot="sheet-content"]`:void 0;x(`j`,()=>N(1),{enabled:!u,scope:P}),x(`k`,()=>N(-1),{enabled:!u,scope:P});let I=c.data?.ticket,{change:L,pending:R}=Ne(I??{id:n,projectId:e,version:1});x(`e`,()=>{o.canWrite&&p(!0)},{enabled:!!I&&!u,scope:P});let z=c.error instanceof a&&c.error.status===404,B=F({...h.query(`resolve_ticket`,{ticketId:n}),enabled:z,retry:!1}),V=we({select:e=>r||!e.location.search.peek?e.location.hash:``});if(c.isPending||z&&B.isFetching)return(0,$.jsx)(te,{});if(z&&B.data&&B.data.project.id!==e)return r?(0,$.jsx)(nt,{preview:r,target:{projectId:B.data.project.id,ticketId:B.data.ticket.id}}):(0,$.jsx)(Se,{to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:B.data.project.id,ticketId:B.data.ticket.id},replace:!0});if(!c.data||!I||z)return z?(0,$.jsxs)(f,{title:s(`detail.page.unavailable`),children:[(0,$.jsx)(`p`,{children:s(`detail.page.gone`)}),r?(0,$.jsx)(A,{onClick:r.close,children:s(`detail.page.closePreview`)}):(0,$.jsx)(A,{render:(0,$.jsx)(_e,{to:`/projects/$projectId`,params:{projectId:e}}),children:s(`detail.page.backToTickets`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{error:c.error}),(0,$.jsx)(A,{onClick:()=>{c.refetch()},children:s(`common.action.retry`)})]});let{readiness:H,claim:U,canReleaseClaim:fe,subscribed:W}=c.data,G=o.canWrite&&!R;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`article`,{className:`ticket-detail grid w-full grid-cols-[minmax(0,1fr)_280px] gap-x-10 animate-in fade-in-0 duration-200 @max-[850px]:flex @max-[850px]:flex-col [&_section]:border-t [&_section]:py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ne,{title:!r&&(0,$.jsxs)(A,{variant:`ghost`,size:`sm`,className:`-ml-2 text-muted-foreground`,render:(0,$.jsx)(_e,{to:`/projects/$projectId`,params:{projectId:e}}),children:[(0,$.jsx)(Ee,{}),s(`detail.page.tickets`)]}),children:(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[M>=0&&(0,$.jsxs)(`div`,{className:`mr-1 flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,$.jsx)(_,{label:s(`detail.page.previousTicket`),title:s(`detail.page.previousTicketShortcut`),disabled:M===0,onClick:()=>N(-1),children:(0,$.jsx)(d,{})}),(0,$.jsx)(`span`,{children:s(`detail.page.position`,{position:M+1,total:k.length})}),(0,$.jsx)(_,{label:s(`detail.page.nextTicket`),title:s(`detail.page.nextTicketShortcut`),disabled:M===k.length-1,onClick:()=>N(1),children:(0,$.jsx)(ee,{})})]}),(0,$.jsx)(_,{label:s(W?`detail.page.unsubscribe`:`detail.page.subscribe`),disabled:l.isPending,onClick:()=>{l.mutateAsync({projectId:e,ticketId:I.id,enabled:!W}).then(()=>b.success(s(W?`detail.page.unsubscribed`:`detail.page.subscribed`))).catch(ae)},children:W?(0,$.jsx)(Ie,{}):(0,$.jsx)(ce,{})}),(0,$.jsx)(_,{label:K.label,onClick:()=>{be(K,I)},children:(0,$.jsx)(K.icon,{})}),(0,$.jsx)(_,{label:I.archived?s(`detail.page.unarchive`):s(`detail.page.archive`),disabled:!G,onClick:()=>{L({archived:!I.archived}).then(e=>{e&&b.success(I.archived?s(`detail.page.unarchivedToast`):s(`detail.page.archivedToast`))})},children:I.archived?(0,$.jsx)(se,{}):(0,$.jsx)(le,{})}),(0,$.jsx)(_,{label:s(`detail.page.edit`),title:s(`detail.page.editShortcut`),disabled:!o.canWrite,onClick:()=>p(!0),children:(0,$.jsx)(de,{})}),(0,$.jsx)(je,{ticket:I,variant:`dropdown`,onEdit:()=>p(!0),children:(0,$.jsx)(A,{variant:`ghost`,size:`icon`,"aria-label":s(`detail.page.actions`),children:(0,$.jsx)(pe,{})})}),r&&(0,$.jsx)(Fe,{projectId:e,ticketId:I.id,preview:r})]})}),(0,$.jsx)(je,{ticket:I,onEdit:()=>p(!0),children:(0,$.jsxs)(`header`,{className:`ticket-heading`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(A,{variant:`ghost`,size:`xs`,className:`-ml-2 gap-1.5 font-mono text-xs text-muted-foreground`,title:s(`detail.page.copyKey`),onClick:()=>{g(I.key).then(()=>{S(!0),setTimeout(()=>S(!1),1500),b.success(s(`detail.page.keyCopied`,{key:I.key}))}).catch(ae)},children:[I.key,v&&(0,$.jsx)(m,{className:`size-3 text-[var(--success)]`})]}),(0,$.jsx)(me,{property:`status`,value:Y(I),projectId:e}),I.archived&&(0,$.jsx)(`strong`,{children:s(`detail.page.archived`)}),R&&(0,$.jsx)(O,{className:`size-3.5 text-muted-foreground`})]}),r?(0,$.jsx)(he,{render:(0,$.jsx)(`h1`,{}),className:re,children:I.title}):(0,$.jsx)(`h1`,{className:re,children:I.title})]})}),(0,$.jsxs)(`div`,{className:`min-w-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.field.description`)}),(0,$.jsx)(E,{...G?{onChange:e=>L({description:e})}:{},children:I.description||s(`detail.page.noDescription`)})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.field.acceptanceCriteria`)}),(0,$.jsx)(E,{...G?{onChange:e=>L({acceptanceCriteria:e})}:{},children:I.acceptanceCriteria||s(`detail.page.noAcceptanceCriteria`)})]})]}),(0,$.jsxs)(Me,{defaultValue:`discussion`,className:`mt-8 min-w-0 [&_[data-slot=tabs-content]>section]:border-0 [&_[data-slot=tabs-content]>section]:pt-0`,children:[(0,$.jsxs)(ke,{variant:`line`,className:`mb-5`,children:[(0,$.jsx)(q,{value:`discussion`,children:s(`detail.section.discussion`)}),(0,$.jsx)(q,{value:`evidence`,children:s(`detail.section.evidence`)}),(0,$.jsx)(q,{value:`activity`,children:s(`detail.section.activity`)})]}),(0,$.jsx)(X,{value:`discussion`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)($e,{ticket:I,anchor:V})}),(0,$.jsx)(X,{value:`evidence`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ue,{ticket:I})}),(0,$.jsx)(X,{value:`activity`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ge,{ticket:I})})]}),(0,$.jsx)(y,{error:c.error})]}),(0,$.jsxs)(`aside`,{className:`min-w-0 border-l pl-5 @max-[850px]:border-l-0 @max-[850px]:pl-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0 @max-[850px]:[&>section:first-child]:border-t @max-[850px]:[&>section:first-child]:pt-6 [&_h2]:text-xs [&_h2]:font-medium [&_h2]:text-muted-foreground [&_p]:text-xs [&_ul]:mb-4 [&_ul]:list-disc [&_ul]:pl-4 [&_ul]:text-xs [&_ul]:leading-relaxed [&_ul]:text-muted-foreground`,"aria-label":s(`detail.page.coordination`),children:[(0,$.jsxs)(`section`,{"aria-label":s(`detail.page.properties`),className:`ticket-properties`,children:[(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:e,value:Y(I),disabled:!G,onChange:e=>void L({status:e})}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:e,value:I.priority,disabled:!G,onChange:e=>void L({priority:e})}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:e,value:I.assigneeId,disabled:!G,onChange:e=>void L({assignee:e})}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:e,value:I.kind,disabled:!G,onChange:e=>void L({kind:e})}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:e,value:I.difficulty,disabled:!G,onChange:e=>void L({difficulty:e})}),(0,$.jsx)(Ae,{variant:`row`,value:I,disabled:!G,onChange:e=>void L(e)}),(0,$.jsx)(Oe,{variant:`row`,value:I.labels,disabled:!G,onChange:e=>void L({labels:e})}),(I.scopes.length>0||o.canWrite)&&(0,$.jsx)(Oe,{variant:`row`,kind:`scope`,value:I.scopes,disabled:!G,onChange:e=>void L({scopes:e})}),(0,$.jsx)(ye,{variant:`row`,projectId:e,values:I.customFields,disabled:!G,onChange:(e,t)=>void L({customFields:{[e]:t}})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid grid-cols-[80px_minmax(0,1fr)] gap-x-2 gap-y-1.5 border-t pt-4 text-xs [&_dd]:m-0 [&_dd]:min-w-0 [&_dd]:wrap-anywhere [&_dt]:text-muted-foreground`,children:[(0,$.jsx)(`dt`,{children:s(`detail.page.created`)}),(0,$.jsxs)(`dd`,{children:[(0,$.jsx)(oe,{projectId:e,actorId:I.createdBy}),` · `,(0,$.jsx)(ie,{value:I.createdAt})]}),(0,$.jsx)(`dt`,{children:s(`detail.page.updated`)}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(ie,{value:I.updatedAt})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.readiness.heading`)}),(0,$.jsx)(`p`,{className:H.ready?`text-[var(--success)]`:`text-muted-foreground`,children:H.ready?s(`detail.readiness.ready`):s(`detail.readiness.notReady`)}),(0,$.jsx)(`ul`,{children:H.reasons.map((e,n)=>(0,$.jsx)(`li`,{children:t(e,U?.workerId)},`${e.code}:${n}`))}),I.holdReason&&(0,$.jsx)(`p`,{children:s(`detail.readiness.hold`,{reason:I.holdReason})}),U&&(0,$.jsx)(`p`,{children:(0,$.jsx)(ue,{i18nKey:`detail.readiness.claimedUntil`,values:{worker:U.workerId,date:i(U.expiresAt)},components:{strong:(0,$.jsx)(`strong`,{})}})}),U&&(0,$.jsx)(rt,{ticket:I,claim:U,canRelease:fe,canRecover:o.canAdmin&&H.reasons.some(e=>e.code===`claim_recovery_required`)})]}),(0,$.jsx)(Ze,{ticket:I},I.id),(0,$.jsx)(ze,{ticket:I}),(0,$.jsx)(Ve,{ticket:I})]})]}),(0,$.jsx)(C,{size:`composer`,title:s(`detail.page.editTitle`,{key:I.key}),open:u,onOpenChange:p,children:u&&(0,$.jsx)(Le,{projectId:e,ticket:I,onSaved:()=>p(!1)})})]})}function nt({preview:e,target:t}){return(0,Q.useEffect)(()=>e.follow(t),[e,t]),(0,$.jsx)(te,{})}function rt({ticket:e,claim:t,canRelease:n,canRecover:r}){let i=D(`release_claim`),a=D(`recover_claim`),[o,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,$.jsx)(w,{label:s(`detail.claim.release`),description:s(`detail.claim.releaseDescription`),onConfirm:()=>i.mutateAsync({projectId:e.projectId,ticketId:e.id,claimId:t.id})}),r&&(0,$.jsx)(C,{title:s(`detail.claim.recover`),trigger:s(`detail.claim.recover`),children:(0,$.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),l&&a.mutate({projectId:e.projectId,ticketId:e.id,claimId:t.id,reason:o,confirmedStopped:!0})},children:[(0,$.jsx)(`p`,{children:s(`detail.claim.recoverHelp`)}),(0,$.jsx)(N,{label:s(`detail.claim.reason`),required:!0,minLength:10,maxLength:2e3,value:o,onChange:e=>c(e.target.value)}),(0,$.jsx)(u,{label:s(`detail.claim.confirmed`),checked:l,onCheckedChange:e=>d(e)}),(0,$.jsx)(P,{error:a.error,pending:!l,submitLabel:s(`detail.claim.submit`),submitDisabled:a.isPending})]})})]})}export{tt as TicketDetail};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ticket-editor-CLDBUk0n.js","assets/rolldown-runtime-COiEfhsA.js","assets/default-6QIAyMq2.js","assets/core-jXc03Sty.js","assets/en-EnSRisMz.js","assets/preload-helper-BLdHbfdN.js","assets/search-B3-w3oCd.js","assets/toDate-B3HYxwtT.js","assets/item-DED0Ikqi.js","assets/CompositeItem-B5Qlh5m0.js","assets/forms-BbWAl0BZ.js","assets/corner-left-up-arA2ipmM.js","assets/rotate-ccw-DGM890Fc.js","assets/sliders-horizontal-yKgghk8h.js","assets/upload-BzLq4CMS.js","assets/index-2V6MWx63.js","assets/Trans-DxqBaUXP.js","assets/en-US-DKYSujv3.js","assets/index-DyQNFS69.css","assets/switch-ByOrazEW.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Dt as t,Nn as n,Ot as r,W as i,i as a,kt as o,mn as s,r as c,vt as l}from"./default-6QIAyMq2.js";import{B as u,Ba as d,G as f,Ga as p,Ha as m,Hi as h,Ii as g,J as _,Ji as v,K as y,Oa as b,Pi as x,Pt as S,Q as C,V as w,Va as ee,X as te,Xn as T,Z as E,Zi as D,_t as O,at as k,di as A,ea as j,et as ne,ft as re,it as M,nt as ie,ot as N,q as P,qa as F,ut as ae,zi as oe}from"./search-B3-w3oCd.js";import{t as I}from"./preload-helper-BLdHbfdN.js";import{t as L}from"./useQueries-D64vLhM6.js";import{a as R,g as z,n as B,r as V,t as H}from"./item-DED0Ikqi.js";import{t as se}from"./archive-restore-wsAzhqi-.js";import{n as ce,r as le,t as ue}from"./Trans-DxqBaUXP.js";import{n as U,r as de}from"./CompositeItem-B5Qlh5m0.js";import{t as fe}from"./corner-left-up-arA2ipmM.js";import{t as pe}from"./ellipsis-UOkL14vq.js";import{t as W}from"./send-B9baaCnt.js";import{r as G}from"./forms-BbWAl0BZ.js";import{$ as me,A as he,B as ge,Ht as _e,I as ve,J as ye,N as be,R as K,U as xe,Ut as Se,V as Ce,Vt as we,Wt as Te,_ as q,b as J,bn as Ee,cn as De,dt as Y,et as Oe,g as ke,gt as Ae,h as X,j as je,m as Me,pt as Ne,q as Pe,tt as Z,x as Fe,yn as Ie}from"./index-2V6MWx63.js";import{TicketEditor as Le,a as Re,i as ze,l as Be,n as Ve,o as He,r as Ue,s as We,t as Ge}from"./ticket-editor-CLDBUk0n.js";var Ke={name:`git-branch-plus`,size:24,node:[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]};Ke.node;var qe=p(Ke),Je={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Je.node;var Ye=p(Je),Q=e(n(),1),$=c(),Xe=(0,Q.lazy)(()=>I(()=>import(`./ticket-editor-CLDBUk0n.js`).then(e=>({default:e.TicketEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Ze({ticket:e}){let t=j(e.projectId),n=F(h.query(`list_relations`,{projectId:e.projectId,ticketId:e.id})),[i,a]=(0,Q.useState)(!1),[c,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(0),[g,v]=(0,Q.useState)(),b=F({...h.query(`get_ticket`,{projectId:e.projectId,ticketId:e.parentId??e.id}),enabled:!!e.parentId}),x=F(h.query(`list_tickets`,{projectId:e.projectId,parentId:e.id,archived:`include`,limit:20,offset:p})),w=L({queries:Array.from({length:Math.ceil((n.data?.length??0)/100)},(t,n)=>h.query(`list_tickets`,{projectId:e.projectId,relatedTo:e.id,archived:`include`,sort:`number`,limit:100,offset:n*100}))}),ee=new Map(w.flatMap(e=>e.data?.items??[]).map(e=>[e.id,e])),T=D(`add_relation`),E=D(`remove_relation`);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(M,{compact:!0,title:s(`detail.relations.heading`),action:t.canWrite&&(0,$.jsxs)(ge,{children:[(0,$.jsx)(Pe,{render:(0,$.jsx)(_,{label:s(`detail.relations.add`)}),children:(0,$.jsx)(z,{})}),(0,$.jsxs)(Ce,{align:`end`,className:`w-48`,children:[(0,$.jsxs)(xe,{onClick:()=>{T.reset(),v(void 0),f(null),a(!0)},children:[(0,$.jsx)(Ye,{}),s(`detail.relations.linkExisting`)]}),(0,$.jsxs)(xe,{onClick:()=>u(!0),children:[(0,$.jsx)(qe,{}),s(`detail.relations.newChild`)]})]})]})}),e.parentId&&(0,$.jsxs)(H,{size:`xs`,className:`px-0`,children:[(0,$.jsx)(fe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsxs)(V,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s(`detail.field.parent`)}),(0,$.jsx)(J,{projectId:e.projectId,ticketId:e.parentId,ticket:b.data?.ticket})]})]}),x.data&&(x.data.total>0||p>0)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`mt-3 mb-1 text-xs text-muted-foreground`,children:(0,$.jsx)(ue,{i18nKey:`detail.relations.children`,values:{done:x.data.items.filter(e=>e.status===`done`).length,total:x.data.total},components:{count:(0,$.jsx)(`span`,{className:`tabular-nums`})}})}),(0,$.jsx)(R,{className:`gap-0`,children:x.data.items.map(n=>(0,$.jsx)(Qe,{projectId:e.projectId,ticketId:n.id,ticket:n,canWrite:t.canWrite,children:(0,$.jsx)(J,{projectId:e.projectId,ticketId:n.id,ticket:n})},n.id))}),(x.data.total>20||p>0)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(A,{size:`sm`,disabled:!p,onClick:()=>m(Math.max(0,p-20)),children:s(`detail.relations.previousChildren`)}),(0,$.jsx)(A,{size:`sm`,disabled:p+20>=x.data.total,onClick:()=>m(p+20),children:s(`detail.relations.nextChildren`)})]})]}),(0,$.jsx)(R,{className:`gap-0`,children:n.data?.map(n=>{let r=o(n,e.id);return(0,$.jsx)(Qe,{projectId:e.projectId,ticketId:r.id,ticket:ee.get(r.id),canWrite:t.canWrite,label:r.label,action:(0,$.jsx)(_,{size:`icon-sm`,label:s(`detail.relations.remove.${n.type}`),onClick:()=>E.mutate({projectId:e.projectId,relationId:n.id}),children:(0,$.jsx)(Ye,{})}),children:(0,$.jsx)(J,{projectId:e.projectId,ticketId:r.id,children:r.title})},n.id)})}),!e.parentId&&!x.data?.total&&n.data?.length===0&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:s(`detail.relations.empty`)}),(0,$.jsx)(C,{title:s(`detail.relations.add`),open:i,onOpenChange:a,busy:T.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);d&&(v(void 0),T.mutateAsync({projectId:e.projectId,ticketId:e.id,targetId:d,...l(n.get(`type`))}).then(()=>a(!1)).catch(v))},children:[(0,$.jsx)(k,{label:s(`detail.relations.type`),name:`type`,children:r.map(e=>(0,$.jsx)(S,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(We,{projectId:e.projectId,label:s(`detail.relations.ticket`),value:d,onChange:f,exclude:[e.id],allowClear:!1}),(0,$.jsx)(P,{error:g??T.error,pending:T.isPending,submitLabel:s(`detail.relations.add`),submitDisabled:!d,onCancel:()=>a(!1)})]})}),(0,$.jsx)(C,{size:`composer`,title:s(`detail.relations.newChildTitle`,{key:e.key}),open:c,onOpenChange:u,children:c&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(te,{}),children:(0,$.jsx)(Xe,{projectId:e.projectId,initial:{parentId:e.id,labels:e.labels,scopes:e.scopes},onSaved:()=>u(!1)})})}),(0,$.jsx)(y,{error:n.error??E.error??b.error??x.error??w.find(e=>e.error)?.error})]})}function Qe({projectId:e,ticketId:t,ticket:n,canWrite:r,label:i,action:a,children:o}){let{change:c,pending:l}=Ne({id:t,projectId:e,version:n?.version??0}),u=r&&n;return(0,$.jsxs)(H,{size:`xs`,className:`px-0`,children:[u?(0,$.jsx)(Z,{property:`status`,value:Y(n),onChange:e=>void c({status:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,ariaLabel:s(`detail.relations.statusOf`,{key:n.key}),className:`mx-0`}):n&&(0,$.jsx)(me,{property:`status`,value:Y(n),projectId:e,iconOnly:!0}),(0,$.jsxs)(V,{className:`min-w-0 gap-0`,children:[i&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),o]}),(u||n?.assigneeId||r&&a)&&(0,$.jsxs)(B,{className:`gap-0`,children:[u?(0,$.jsx)(Z,{property:`assignee`,value:n.assigneeId,onChange:e=>void c({assignee:e}),projectId:e,disabled:l,variant:`cell`,iconOnly:!0,align:`end`,ariaLabel:s(`detail.relations.assigneeOf`,{key:n.key}),className:`mx-0`}):n?.assigneeId&&(0,$.jsx)(me,{property:`assignee`,value:n.assigneeId,projectId:e,iconOnly:!0}),r&&a]})]})}function $e({ticket:e,anchor:t}){let[n,r]=(0,Q.useState)(0),[i,a]=(0,Q.useState)(``),o=F(h.query(`list_comments`,{projectId:e.projectId,ticketId:e.id,offset:n})),c=t.startsWith(`comment-`)?t.slice(8):null,[l,u]=(0,Q.useState)(c),[d,p]=(0,Q.useState)(c!==null);c!==l&&(u(c),p(c!==null)),d&&o.data&&(o.data.items.some(e=>e.id===c)?p(!1):n+50<o.data.total?r(n+50):p(!1));let m=Re(e.projectId,{ticketId:e.id}),g=D(`add_comment`),_=j(e.projectId);return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(y,{error:o.error??g.error}),o.data?.total===0&&(0,$.jsx)(f,{title:s(`detail.discussion.empty`),icon:De,className:`py-8`}),(0,$.jsx)(`div`,{className:`divide-y`,children:o.data?.items.map(e=>(0,$.jsx)(et,{comment:e,linked:e.id===c},e.id))}),((o.data?.total??0)>50||n>0)&&(0,$.jsxs)(He,{className:`mt-5 justify-end`,children:[(0,$.jsx)(A,{size:`sm`,disabled:!n,onClick:()=>r(Math.max(0,n-50)),children:s(`detail.discussion.previous`)}),(0,$.jsx)(A,{size:`sm`,disabled:n+50>=(o.data?.total??0),onClick:()=>r(n+50),children:s(`detail.discussion.next`)})]}),_.canWrite&&(0,$.jsx)(`form`,{onKeyDown:G,className:`mt-6`,onSubmit:t=>{t.preventDefault(),g.mutateAsync({projectId:e.projectId,ticketId:e.id,body:i}).then(()=>a(e=>e===i?``:e)).catch(()=>{})},children:(0,$.jsx)(Be,{label:s(`detail.discussion.comment`),value:i,onChange:a,rows:3,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:m,placeholder:s(`detail.discussion.placeholder`),footer:(0,$.jsxs)(A,{type:`submit`,variant:`default`,disabled:g.isPending||!i.trim(),children:[g.isPending?(0,$.jsx)(O,{}):(0,$.jsx)(W,{}),g.isPending?s(`detail.discussion.posting`):s(`detail.discussion.comment`),(0,$.jsx)(T,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})})})]})}function et({comment:e,linked:t}){let n=v(),r=j(e.projectId),i=D(`update_comment`),a=Re(e.projectId,{ticketId:e.ticketId}),o=D(`delete_comment`),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(e.body),[f,p]=(0,Q.useState)(e.version),m=e.actorId===n.id,h=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{t&&h.current?.scrollIntoView({block:`center`})},[t]),(0,$.jsxs)(`article`,{ref:h,id:`comment-${e.id}`,"data-linked":t,className:`group/comment relative scroll-mt-16 py-4 animate-in fade-in-0 duration-200 data-[linked=true]:animate-row-in data-[linked=true]:shadow-[inset_2px_0_0_var(--primary)] data-[linked=true]:pl-3`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex min-h-8 flex-wrap items-center gap-x-3 gap-y-1 pr-20 text-xs text-muted-foreground`,children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:(0,$.jsx)(oe,{projectId:e.projectId,actorId:e.actorId,avatar:!0})}),(0,$.jsx)(ie,{value:e.createdAt}),e.updatedAt!==e.createdAt&&(0,$.jsx)(`span`,{children:s(`detail.discussion.edited`)})]}),c?(0,$.jsx)(`form`,{onKeyDown:G,onSubmit:t=>{t.preventDefault(),i.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:f,body:u}).then(()=>l(!1)).catch(()=>{})},children:(0,$.jsx)(Be,{label:s(`detail.discussion.edit`),value:u,onChange:d,rows:4,required:!0,maxLength:5e4,mentions:e.projectId,onUpload:a,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{size:`sm`,disabled:i.isPending,onClick:()=>l(!1),children:s(`common.action.cancel`)}),(0,$.jsxs)(A,{type:`submit`,size:`sm`,variant:`default`,disabled:i.isPending||!u.trim(),children:[i.isPending?(0,$.jsx)(O,{}):null,s(`common.action.save`)]})]})})}):(0,$.jsx)(E,{children:e.body}),!c&&r.canWrite&&(m||n.admin)&&(0,$.jsxs)(`div`,{className:`absolute top-3 right-0 flex items-center gap-1 opacity-0 transition-opacity group-hover/comment:opacity-100 focus-within:opacity-100 max-md:opacity-100`,children:[(0,$.jsx)(_,{label:s(`detail.discussion.edit`),size:`icon-sm`,onClick:()=>{d(e.body),p(e.version),l(!0)},children:(0,$.jsx)(de,{})}),(0,$.jsx)(w,{label:s(`detail.discussion.delete`),icon:(0,$.jsx)(U,{}),danger:!0,description:s(`detail.discussion.deleteConfirm`),onConfirm:()=>o.mutateAsync({projectId:e.projectId,commentId:e.id,expectedVersion:e.version})})]}),(0,$.jsx)(y,{error:i.error})]})}function tt({projectId:e,ticketId:n,preview:r}){let o=j(e),c=F(h.query(`get_ticket`,{projectId:e,ticketId:n})),l=D(`set_subscription`),[u,p]=(0,Q.useState)(!1),[v,S]=(0,Q.useState)(!1),w=Te(),[T]=(0,Q.useState)(()=>r?[]:ve(e)),k=r?.order??T,M=k.indexOf(n),N=t=>{let n=M<0?void 0:k[M+t];n&&(r?r.open(n):w({to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:e,ticketId:n}}))},P=r?`[data-slot="sheet-content"]`:void 0;x(`j`,()=>N(1),{enabled:!u,scope:P}),x(`k`,()=>N(-1),{enabled:!u,scope:P});let I=c.data?.ticket,{change:L,pending:R}=Ne(I??{id:n,projectId:e,version:1});x(`e`,()=>{o.canWrite&&p(!0)},{enabled:!!I&&!u,scope:P});let z=c.error instanceof a&&c.error.status===404,B=F({...h.query(`resolve_ticket`,{ticketId:n}),enabled:z,retry:!1}),V=we({select:e=>r||!e.location.search.peek?e.location.hash:``});if(c.isPending||z&&B.isFetching)return(0,$.jsx)(te,{});if(z&&B.data&&B.data.project.id!==e)return r?(0,$.jsx)(nt,{preview:r,target:{projectId:B.data.project.id,ticketId:B.data.ticket.id}}):(0,$.jsx)(Se,{to:`/projects/$projectId/tickets/$ticketId`,params:{projectId:B.data.project.id,ticketId:B.data.ticket.id},replace:!0});if(!c.data||!I||z)return z?(0,$.jsxs)(f,{title:s(`detail.page.unavailable`),children:[(0,$.jsx)(`p`,{children:s(`detail.page.gone`)}),r?(0,$.jsx)(A,{onClick:r.close,children:s(`detail.page.closePreview`)}):(0,$.jsx)(A,{render:(0,$.jsx)(_e,{to:`/projects/$projectId`,params:{projectId:e}}),children:s(`detail.page.backToTickets`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{error:c.error}),(0,$.jsx)(A,{onClick:()=>{c.refetch()},children:s(`common.action.retry`)})]});let{readiness:H,claim:U,canReleaseClaim:fe,subscribed:W}=c.data,G=o.canWrite&&!R;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`article`,{className:`ticket-detail grid w-full grid-cols-[minmax(0,1fr)_280px] gap-x-10 animate-in fade-in-0 duration-200 @max-[850px]:flex @max-[850px]:flex-col [&_section]:border-t [&_section]:py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ne,{title:!r&&(0,$.jsxs)(A,{variant:`ghost`,size:`sm`,className:`-ml-2 text-muted-foreground`,render:(0,$.jsx)(_e,{to:`/projects/$projectId`,params:{projectId:e}}),children:[(0,$.jsx)(Ee,{}),s(`detail.page.tickets`)]}),children:(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[M>=0&&(0,$.jsxs)(`div`,{className:`mr-1 flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,$.jsx)(_,{label:s(`detail.page.previousTicket`),title:s(`detail.page.previousTicketShortcut`),disabled:M===0,onClick:()=>N(-1),children:(0,$.jsx)(d,{})}),(0,$.jsx)(`span`,{children:s(`detail.page.position`,{position:M+1,total:k.length})}),(0,$.jsx)(_,{label:s(`detail.page.nextTicket`),title:s(`detail.page.nextTicketShortcut`),disabled:M===k.length-1,onClick:()=>N(1),children:(0,$.jsx)(ee,{})})]}),(0,$.jsx)(_,{label:s(W?`detail.page.unsubscribe`:`detail.page.subscribe`),disabled:l.isPending,onClick:()=>{l.mutateAsync({projectId:e,ticketId:I.id,enabled:!W}).then(()=>b.success(s(W?`detail.page.unsubscribed`:`detail.page.subscribed`))).catch(ae)},children:W?(0,$.jsx)(Ie,{}):(0,$.jsx)(ce,{})}),(0,$.jsx)(_,{label:K.label,onClick:()=>{be(K,I)},children:(0,$.jsx)(K.icon,{})}),(0,$.jsx)(_,{label:I.archived?s(`detail.page.unarchive`):s(`detail.page.archive`),disabled:!G,onClick:()=>{L({archived:!I.archived}).then(e=>{e&&b.success(I.archived?s(`detail.page.unarchivedToast`):s(`detail.page.archivedToast`))})},children:I.archived?(0,$.jsx)(se,{}):(0,$.jsx)(le,{})}),(0,$.jsx)(_,{label:s(`detail.page.edit`),title:s(`detail.page.editShortcut`),disabled:!o.canWrite,onClick:()=>p(!0),children:(0,$.jsx)(de,{})}),(0,$.jsx)(je,{ticket:I,variant:`dropdown`,onEdit:()=>p(!0),children:(0,$.jsx)(A,{variant:`ghost`,size:`icon`,"aria-label":s(`detail.page.actions`),children:(0,$.jsx)(pe,{})})}),r&&(0,$.jsx)(Fe,{projectId:e,ticketId:I.id,preview:r})]})}),(0,$.jsx)(je,{ticket:I,onEdit:()=>p(!0),children:(0,$.jsxs)(`header`,{className:`ticket-heading`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(A,{variant:`ghost`,size:`xs`,className:`-ml-2 gap-1.5 font-mono text-xs text-muted-foreground`,title:s(`detail.page.copyKey`),onClick:()=>{g(I.key).then(()=>{S(!0),setTimeout(()=>S(!1),1500),b.success(s(`detail.page.keyCopied`,{key:I.key}))}).catch(ae)},children:[I.key,v&&(0,$.jsx)(m,{className:`size-3 text-[var(--success)]`})]}),(0,$.jsx)(me,{property:`status`,value:Y(I),projectId:e}),I.archived&&(0,$.jsx)(`strong`,{children:s(`detail.page.archived`)}),R&&(0,$.jsx)(O,{className:`size-3.5 text-muted-foreground`})]}),r?(0,$.jsx)(he,{render:(0,$.jsx)(`h1`,{}),className:re,children:I.title}):(0,$.jsx)(`h1`,{className:re,children:I.title})]})}),(0,$.jsxs)(`div`,{className:`min-w-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.field.description`)}),(0,$.jsx)(E,{...G?{onChange:e=>L({description:e})}:{},children:I.description||s(`detail.page.noDescription`)})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.field.acceptanceCriteria`)}),(0,$.jsx)(E,{...G?{onChange:e=>L({acceptanceCriteria:e})}:{},children:I.acceptanceCriteria||s(`detail.page.noAcceptanceCriteria`)})]})]}),(0,$.jsxs)(Me,{defaultValue:`discussion`,className:`mt-8 min-w-0 [&_[data-slot=tabs-content]>section]:border-0 [&_[data-slot=tabs-content]>section]:pt-0`,children:[(0,$.jsxs)(ke,{variant:`line`,className:`mb-5`,children:[(0,$.jsx)(q,{value:`discussion`,children:s(`detail.section.discussion`)}),(0,$.jsx)(q,{value:`evidence`,children:s(`detail.section.evidence`)}),(0,$.jsx)(q,{value:`activity`,children:s(`detail.section.activity`)})]}),(0,$.jsx)(X,{value:`discussion`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)($e,{ticket:I,anchor:V})}),(0,$.jsx)(X,{value:`evidence`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ue,{ticket:I})}),(0,$.jsx)(X,{value:`activity`,className:`animate-in fade-in-0 duration-150`,children:(0,$.jsx)(Ge,{ticket:I})})]}),(0,$.jsx)(y,{error:c.error})]}),(0,$.jsxs)(`aside`,{className:`min-w-0 border-l pl-5 @max-[850px]:border-l-0 @max-[850px]:pl-0 [&>section:first-child]:border-0 [&>section:first-child]:pt-0 @max-[850px]:[&>section:first-child]:border-t @max-[850px]:[&>section:first-child]:pt-6 [&_h2]:text-xs [&_h2]:font-medium [&_h2]:text-muted-foreground [&_p]:text-xs [&_ul]:mb-4 [&_ul]:list-disc [&_ul]:pl-4 [&_ul]:text-xs [&_ul]:leading-relaxed [&_ul]:text-muted-foreground`,"aria-label":s(`detail.page.coordination`),children:[(0,$.jsxs)(`section`,{"aria-label":s(`detail.page.properties`),className:`ticket-properties`,children:[(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:e,value:Y(I),disabled:!G,onChange:e=>void L({status:e})}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:e,value:I.priority,disabled:!G,onChange:e=>void L({priority:e})}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:e,value:I.assigneeId,disabled:!G,onChange:e=>void L({assignee:e})}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:e,value:I.kind,disabled:!G,onChange:e=>void L({kind:e})}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:e,value:I.difficulty,disabled:!G,onChange:e=>void L({difficulty:e})}),(0,$.jsx)(Ae,{variant:`row`,value:I,disabled:!G,onChange:e=>void L(e)}),(0,$.jsx)(Oe,{variant:`row`,value:I.labels,disabled:!G,onChange:e=>void L({labels:e})}),(I.scopes.length>0||o.canWrite)&&(0,$.jsx)(Oe,{variant:`row`,kind:`scope`,value:I.scopes,disabled:!G,onChange:e=>void L({scopes:e})}),(0,$.jsx)(ye,{variant:`row`,projectId:e,values:I.customFields,disabled:!G,onChange:(e,t)=>void L({customFields:{[e]:t}})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid grid-cols-[80px_minmax(0,1fr)] gap-x-2 gap-y-1.5 border-t pt-4 text-xs [&_dd]:m-0 [&_dd]:min-w-0 [&_dd]:wrap-anywhere [&_dt]:text-muted-foreground`,children:[(0,$.jsx)(`dt`,{children:s(`detail.page.created`)}),(0,$.jsxs)(`dd`,{children:[(0,$.jsx)(oe,{projectId:e,actorId:I.createdBy}),` · `,(0,$.jsx)(ie,{value:I.createdAt})]}),(0,$.jsx)(`dt`,{children:s(`detail.page.updated`)}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(ie,{value:I.updatedAt})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:s(`detail.readiness.heading`)}),(0,$.jsx)(`p`,{className:H.ready?`text-[var(--success)]`:`text-muted-foreground`,children:H.ready?s(`detail.readiness.ready`):s(`detail.readiness.notReady`)}),(0,$.jsx)(`ul`,{children:H.reasons.map((e,n)=>(0,$.jsx)(`li`,{children:t(e,U?.workerId)},`${e.code}:${n}`))}),I.holdReason&&(0,$.jsx)(`p`,{children:s(`detail.readiness.hold`,{reason:I.holdReason})}),U&&(0,$.jsx)(`p`,{children:(0,$.jsx)(ue,{i18nKey:`detail.readiness.claimedUntil`,values:{worker:U.workerId,date:i(U.expiresAt)},components:{strong:(0,$.jsx)(`strong`,{})}})}),U&&(0,$.jsx)(rt,{ticket:I,claim:U,canRelease:fe,canRecover:o.canWrite&&H.reasons.some(e=>e.code===`claim_recovery_required`)})]}),(0,$.jsx)(Ze,{ticket:I},I.id),(0,$.jsx)(ze,{ticket:I}),(0,$.jsx)(Ve,{ticket:I})]})]}),(0,$.jsx)(C,{size:`composer`,title:s(`detail.page.editTitle`,{key:I.key}),open:u,onOpenChange:p,children:u&&(0,$.jsx)(Le,{projectId:e,ticket:I,onSaved:()=>p(!1)})})]})}function nt({preview:e,target:t}){return(0,Q.useEffect)(()=>e.follow(t),[e,t]),(0,$.jsx)(te,{})}function rt({ticket:e,claim:t,canRelease:n,canRecover:r}){let i=D(`release_claim`),a=D(`recover_claim`),[o,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,$.jsx)(w,{label:s(`detail.claim.release`),description:s(`detail.claim.releaseDescription`),onConfirm:()=>i.mutateAsync({projectId:e.projectId,ticketId:e.id,claimId:t.id})}),r&&(0,$.jsx)(C,{title:s(`detail.claim.recover`),trigger:s(`detail.claim.recover`),children:(0,$.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),l&&a.mutate({projectId:e.projectId,ticketId:e.id,claimId:t.id,reason:o,confirmedStopped:!0})},children:[(0,$.jsx)(`p`,{children:s(`detail.claim.recoverHelp`)}),(0,$.jsx)(N,{label:s(`detail.claim.reason`),required:!0,minLength:10,maxLength:2e3,value:o,onChange:e=>c(e.target.value)}),(0,$.jsx)(u,{label:s(`detail.claim.confirmed`),checked:l,onCheckedChange:e=>d(e)}),(0,$.jsx)(P,{error:a.error,pending:!l,submitLabel:s(`detail.claim.submit`),submitDisabled:a.isPending})]})})]})}export{tt as TicketDetail};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visual-editor-CBhwqTDu.js","assets/rolldown-runtime-COiEfhsA.js","assets/default-BgvtI7HK.js","assets/core-jXc03Sty.js","assets/en-EnSRisMz.js","assets/preload-helper-BLdHbfdN.js","assets/search-ZaQmVnj1.js","assets/toDate-B3HYxwtT.js","assets/forms-C3pNy-qY.js","assets/index-BIuqxnJn.js","assets/item-Cj8xpMLk.js","assets/Trans-f2VYVS9z.js","assets/CompositeItem-DgnfVvrF.js","assets/en-US-DKYSujv3.js","assets/index-DyQNFS69.css","assets/highlight-CKyEM4jx.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{An as t,Cn as n,F as r,I as i,L as a,Lt as o,Mn as s,Mt as c,Nn as l,On as u,U as d,at as f,i as p,mn as m,o as h,r as g}from"./default-BgvtI7HK.js";import{A as ee,Aa as _,Ai as v,D as y,Fa as b,Fi as te,Ga as x,Ha as S,Hi as C,I as ne,Ia as w,J as T,Ji as E,K as D,M as O,Mi as k,N as A,Ni as j,O as M,Oa as N,P,Pt as F,Q as re,Ra as I,Tt as ie,V as ae,X as oe,Xn as se,Y as L,Z as ce,Zi as R,_t as le,aa as ue,at as de,ct as fe,di as z,ea as B,fr as pe,gt as me,hr as he,ht as ge,it as V,ji as _e,k as ve,ka as H,ki as U,lt as W,mr as ye,mt as be,nr as xe,nt as G,or as K,ot as Se,pi as Ce,pr as we,pt as Te,q,qa as J,ut as Ee,vt as Y,w as De,wo as Oe,za as ke,zi as Ae}from"./search-ZaQmVnj1.js";import{t as je}from"./preload-helper-BLdHbfdN.js";import{a as Me,d as Ne,g as Pe,i as Fe,n as Ie,o as Le,r as Re,s as ze,t as Be}from"./item-Cj8xpMLk.js";import{i as Ve,n as He,r as Ue}from"./CompositeItem-DgnfVvrF.js";import{t as We}from"./corner-left-up-BCro--Gl.js";import{t as Ge}from"./rotate-ccw-GjVJPDML.js";import{t as Ke}from"./sliders-horizontal-C1t_zA7D.js";import{t as qe}from"./upload-BwGa8shS.js";import{r as Je,t as X}from"./forms-C3pNy-qY.js";import{At as Ye,Ct as Xe,J as Ze,Ot as Qe,Z as $e,_ as et,bt as tt,d as nt,dn as rt,dt as it,et as at,g as ot,gt as st,h as ct,hn as lt,it as ut,jt as dt,kt as ft,ln as pt,m as mt,mn as ht,nn as gt,tt as Z,un as _t}from"./index-BIuqxnJn.js";import{t as vt}from"./switch-D-WTDajm.js";var yt={name:`bold`,size:24,node:[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]};yt.node;var bt=x(yt),xt={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};xt.node;var St=x(xt),Ct={name:`heading`,size:24,node:[[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M6 20V4`,key:`1w1bmo`}],[`path`,{d:`M18 20V4`,key:`o2hl4u`}]]};Ct.node;var wt=x(Ct),Tt={name:`italic`,size:24,node:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]};Tt.node;var Et=x(Tt),Dt={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Dt.node;var Ot=x(Dt),kt={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};kt.node;var At=x(kt),jt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};jt.node;var Mt=x(jt),Nt={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};Nt.node;var Pt=x(Nt),Ft={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Ft.node;var It=x(Ft),Lt={name:`square-code`,size:24,node:[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`code-square`]};Lt.node;var Rt=x(Lt),Q=e(l(),1),$=g(),zt=(0,Q.lazy)(()=>je(()=>import(`./visual-editor-CBhwqTDu.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Bt={heading:wt,bold:bt,italic:Et,link:Ot,bullets:Mt,numbers:At,tasks:_t,code:Rt};function Vt(e,t){let n=/(?:^|[\s([{])@([^\s@[\]()]{0,40})$/.exec(e.slice(0,t));return n?.[1]===void 0?null:{from:t-n[1].length-1,query:n[1]}}var Ht=(e,t)=>e.filter(e=>`${e.name} ${e.email}`.toLowerCase().includes(t.toLowerCase())).slice(0,8),Ut=e=>({key:e.userId,content:(0,$.jsx)(ue,{name:e.name,email:e.email,image:e.image})}),Wt=e=>f(e.name,e.userId);function Gt(e){let[t,n]=(0,Q.useState)(``),r=e.includes(t)?t:e[0];return{active:r,setHighlight:n,handleKey:(t,i,a)=>{if(!r||t.isComposing)return!1;let o={ArrowDown:1,ArrowUp:-1}[t.key];if(!o&&![`Enter`,`Tab`,`Escape`].includes(t.key))return!1;t.preventDefault();let s=e.indexOf(r);return o?n(e[(s+o+e.length)%e.length]??``):t.key===`Escape`?a():i(r),!0}}}function Kt({id:e,label:t,open:n,anchor:r,options:i,active:a,onHighlight:o,onChoose:s,onDismiss:c}){return(0,$.jsx)(A,{open:n,onOpenChange:e=>{e||c()},children:(0,$.jsx)(P,{anchor:r,align:`start`,initialFocus:!1,finalFocus:!1,className:`w-[min(20rem,calc(100vw-2rem))] p-1`,children:(0,$.jsx)(`div`,{role:`listbox`,id:e,"aria-label":t,children:i.map(t=>(0,$.jsx)(`div`,{role:`option`,id:`${e}-${t.key}`,"aria-selected":t.key===a,"data-selected":t.key===a||void 0,className:O,onMouseDown:e=>e.preventDefault(),onPointerMove:()=>o(t.key),onClick:()=>s(t.key),children:t.content},t.key))})})})}function qt(e,t,n){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=async e=>{if(t&&e.length){i(t=>t+e.length);for(let r of e)try{n(U(await t(r)))}catch(e){Ee(e)}finally{i(e=>e-1)}}},s=(0,$.jsx)(`input`,{ref:a,type:`file`,multiple:!0,hidden:!0,"aria-label":m(`detail.markdown.insertFileInto`,{label:e}),onChange:e=>{let t=[...e.target.files??[]];e.target.value=``,o(t)}});return{uploading:r>0,send:o,pick:()=>a.current?.click(),input:s}}function Jt({label:e,flush:t,onApply:n,pressed:r,upload:i,children:a}){return(0,$.jsxs)(we,{align:`block-start`,role:`toolbar`,"aria-label":m(`detail.markdown.formatting`,{label:e}),className:H(`gap-0.5 overflow-x-auto border-b py-1 pl-1 text-foreground [scrollbar-width:none] max-md:gap-0 max-md:px-0`,t&&`px-0`),onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r={ArrowRight:1,ArrowLeft:-1}[e.key],i=e.key===`Home`?t[0]:e.key===`End`?t.at(-1):r&&t.at((n+r)%t.length);i&&(e.preventDefault(),i.focus())},children:[k.map((e,t)=>{let i=_e[e],a=Bt[e];return(0,$.jsx)(T,{label:i.label,...`shortcut`in i?{shortcut:i.shortcut}:{},...r?{"aria-pressed":r(e)}:{},size:`icon-sm`,tabIndex:t===0?0:-1,className:`text-muted-foreground hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,onClick:()=>n(e),children:(0,$.jsx)(a,{})},e)}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{label:i.uploading?m(`detail.resource.uploading`):m(`detail.markdown.insertFile`),size:`icon-sm`,tabIndex:-1,disabled:i.uploading,className:`text-muted-foreground hover:text-foreground`,onClick:i.pick,children:i.uploading?(0,$.jsx)(le,{}):(0,$.jsx)(It,{})}),i.input]}),a]})}function Yt(e){return e?.files.length?[...e.files]:[]}function Xt({label:e,value:t,onChange:n,placeholder:r,rows:i=5,variant:a=`compact`,maxLength:o=1e5,required:s=!1,footer:c,mentions:l,onUpload:u}){let d=(0,Q.useId)(),f=(0,Q.useRef)(null),[p,h]=Xe(tt.editor),[g,ee]=(0,Q.useState)(!1),[_,y]=(0,Q.useState)(!1),b=g?`preview`:p===`visual`&&!_?`visual`:`write`,te=J({...C.query(`list_members`,{projectId:l??``}),enabled:!!l}),[x,S]=(0,Q.useState)(0),[ne,w]=(0,Q.useState)(null),T=l?Vt(t,x):null,E=Ht(te.data??[],T?.query??``),D=Gt(E.map(e=>e.userId)),O=!!T&&T.from!==ne&&E.length>0,k=`${d}-mentions`,A=e=>{let t=f.current;t&&(t.focus(),t.setSelectionRange(e.from,e.to),document.execCommand(`insertText`,!1,e.text)||(t.setRangeText(e.text),n(t.value)),t.setSelectionRange(e.start,e.end),S(e.end))},M=e=>{let t=f.current;t&&A(v(t.value,t.selectionStart,t.selectionEnd,e))},N=e=>{let t=E.find(t=>t.userId===e);if(!T||!t)return;let n=`${Wt(t)} `,r=T.from+n.length;A({from:T.from,to:x,text:n,start:r,end:r})},P=qt(e,u,e=>{let t=f.current;if(!t)return;let n=t.selectionEnd+e.length;A({from:t.selectionStart,to:t.selectionEnd,text:e,start:n,end:n})}),F=(e,t)=>{let n=u?Yt(t):[];n.length&&(e.preventDefault(),P.send(n))},re=(0,Q.useCallback)(()=>y(!0),[]),I=a===`document`?`rounded-none border-0 bg-transparent dark:bg-transparent has-[[data-slot=input-group-control]:focus-visible]:ring-0`:void 0,ie=c&&(0,$.jsx)(we,{align:`block-end`,className:`justify-end border-t py-2`,children:c});return(0,$.jsx)(xe,{className:H(`mb-6 [&_[data-slot=tabs-list]]:shrink-0 [&_[data-slot=tabs-trigger]]:text-xs`,a===`compact`&&`[&_textarea]:field-sizing-fixed [&_textarea]:max-h-[28rem] [&_.ProseMirror]:max-h-[28rem] [&_.ProseMirror]:overflow-y-auto`,a===`document`&&`border-t pt-5 has-[[data-slot=input-group-control]:focus]:border-t-primary has-[[data-slot=input-group-control]:focus]:[&_[data-slot=field-label]]:text-primary`),"data-variant":a,"aria-label":m(`detail.markdown.editor`,{label:e}),children:(0,$.jsxs)(mt,{value:b,onValueChange:e=>{ee(e===`preview`),(e===`write`||e===`visual`)&&(h(e),y(!1))},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(K,{htmlFor:d,children:e}),(0,$.jsxs)(ot,{"aria-label":m(`detail.markdown.editor`,{label:e}),variant:`line`,children:[(0,$.jsx)(et,{value:`write`,children:m(`detail.markdown.write`)}),(0,$.jsx)(et,{value:`visual`,children:m(`detail.markdown.visual`)}),(0,$.jsx)(et,{value:`preview`,children:m(`detail.markdown.preview`)})]})]}),(0,$.jsxs)(ct,{value:`write`,children:[_&&p===`visual`&&(0,$.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:m(`detail.markdown.unsupported`)}),(0,$.jsxs)(pe,{className:I,children:[(0,$.jsx)(Jt,{label:e,flush:a===`document`,onApply:M,...u?{upload:P}:{}}),(0,$.jsx)(ye,{ref:f,id:d,className:a===`document`?`field-sizing-content max-h-none resize-y px-1 py-3 text-base md:text-base leading-7 caret-primary`:void 0,style:a===`document`?{minHeight:`${i}lh`}:void 0,value:t,onChange:e=>{S(e.target.selectionStart),n(e.target.value)},onSelect:e=>S(e.currentTarget.selectionStart),onPaste:e=>F(e,e.clipboardData),onDragOver:e=>{u&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>F(e,e.dataTransfer),...l&&{"aria-autocomplete":`list`,"aria-controls":O?k:void 0,"aria-activedescendant":O&&D.active?`${k}-${D.active}`:void 0},onKeyDown:e=>{if(O&&D.handleKey(e.nativeEvent,N,()=>w(T.from))){e.stopPropagation();return}let t=j(e);!t||t===`link`&&e.currentTarget.selectionStart===e.currentTarget.selectionEnd||(e.preventDefault(),e.stopPropagation(),M(t))},placeholder:r,rows:i,maxLength:o,required:s}),l&&(0,$.jsx)(Kt,{id:k,label:m(`detail.markdown.mention`),open:O,anchor:f,options:E.map(Ut),active:D.active,onHighlight:D.setHighlight,onChoose:N,onDismiss:()=>{T&&w(T.from)}}),ie]})]}),(0,$.jsx)(ct,{value:`visual`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(oe,{}),children:(0,$.jsx)(zt,{id:d,label:e,value:t,onChange:n,placeholder:r??``,rows:i,maxLength:o,flush:a===`document`,groupClassName:I,footer:ie,...l?{members:te.data??[]}:{},...u?{onUpload:u}:{},onUnsupported:re})})}),(0,$.jsxs)(ct,{value:`preview`,children:[(0,$.jsx)(`div`,{className:H(`min-h-28 rounded-lg border bg-muted/20 p-4`,a===`document`&&`rounded-none border-0 bg-transparent px-1 py-3 text-base leading-7`),children:t?(0,$.jsx)(ce,{children:t}):(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:m(`detail.markdown.nothingToPreview`)})}),c&&(0,$.jsx)(`div`,{className:`mt-2 flex justify-end`,children:c})]})]})})}function Zt({projectId:e,label:t,value:n,onChange:r,exclude:i=[],allowClear:a=!0,variant:o=`field`,placeholder:c=m(`ticket.picker.placeholder`)}){let l=(0,Q.useId)(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),h=J({...C.query(`list_tickets`,{projectId:e,q:f,archived:`include`,limit:30}),enabled:u}),g=J({...C.query(`get_ticket`,{projectId:e,ticketId:n??``}),enabled:!!n&&s().safeParse(n).success}),_=h.data?.items.filter(e=>!i.includes(e.id))??[],v=g.data?.ticket??h.data?.items.find(e=>e.id===n),b=(0,$.jsxs)(A,{open:u,onOpenChange:e=>{d(e),e&&p(``)},children:[(0,$.jsxs)(ne,{id:l,render:(0,$.jsx)(z,{variant:o===`pill`?`ghost`:`outline`,size:o===`pill`?`sm`:`default`,role:`combobox`,"aria-label":t,className:o===`pill`?`h-7 max-w-64 min-w-0 border border-transparent px-2 font-normal hover:border-border`:`h-auto min-h-8 w-full justify-between whitespace-normal text-left font-normal`}),children:[o===`pill`&&(0,$.jsx)(We,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:o===`pill`?`min-w-0 truncate`:`min-w-0 break-words`,children:v?o===`pill`?v.key:`${v.key} · ${v.title}`:n?m(`ticket.picker.loading`):c}),o!==`pill`&&(0,$.jsx)(Ve,{className:`ml-2 size-3.5 shrink-0 text-muted-foreground`})]}),(0,$.jsx)(P,{align:`start`,className:`w-[min(420px,var(--available-width))] p-0`,children:(0,$.jsxs)(De,{shouldFilter:!1,children:[(0,$.jsx)(M,{"aria-label":m(`ticket.picker.searchLabel`,{label:t}),placeholder:m(`ticket.picker.searchPlaceholder`),value:f,onValueChange:p}),(0,$.jsxs)(ee,{children:[a&&(0,$.jsx)(y,{children:(0,$.jsxs)(ve,{value:`none`,onSelect:()=>{r(null),d(!1)},children:[m(`ticket.picker.noParent`),!n&&(0,$.jsx)(S,{className:`ml-auto`})]})}),h.isPending?(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-6 text-sm text-muted-foreground`,children:m(`ticket.picker.searching`)}):_.length?(0,$.jsx)(y,{children:_.map(e=>(0,$.jsxs)(ve,{value:e.id,className:`items-start py-2`,onSelect:()=>{r(e.id),d(!1)},children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`mb-1 block font-mono text-[11px] text-muted-foreground`,children:e.key}),(0,$.jsx)(`span`,{dir:`auto`,className:`block break-words whitespace-normal`,children:e.title})]}),n===e.id&&(0,$.jsx)(S,{className:`ml-auto shrink-0`})]},e.id))}):(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-6 text-center text-sm text-muted-foreground`,children:m(`ticket.picker.empty`)}),(0,$.jsx)(D,{error:h.error})]})]})})]});return o===`pill`?(0,$.jsxs)($.Fragment,{children:[b,(0,$.jsx)(D,{error:g.error})]}):(0,$.jsxs)(xe,{className:fe,children:[(0,$.jsx)(K,{htmlFor:l,children:t}),b,(0,$.jsx)(D,{error:g.error})]})}var Qt=Ce(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function $t({className:e,orientation:t,...n}){return(0,$.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:H(Qt({orientation:t}),e),...n})}function en({icon:e,href:t,label:n,download:r=!1,compact:i=!1,badges:a,details:o,meta:s,metaId:c,actions:l}){return(0,$.jsxs)(Be,{role:`listitem`,size:i?`xs`:`default`,className:H(`rounded-none border-x-0 border-t-0 border-b-border px-0 animate-in fade-in-0 duration-200 last:border-b-0`,!i&&`items-start py-4`),children:[(0,$.jsx)(Le,{variant:i?`default`:`icon`,children:e}),(0,$.jsxs)(Re,{className:H(`min-w-0`,i?`gap-0`:`gap-1.5`),children:[(0,$.jsxs)(ze,{className:H(`line-clamp-none max-w-full wrap-anywhere`,i&&`text-xs font-normal`),children:[(0,$.jsxs)(`a`,{href:t,"aria-describedby":c,...r?{download:!0,className:`hover:text-primary`}:{target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`},children:[n,!r&&(0,$.jsx)(lt,{className:`size-3 shrink-0`,"aria-hidden":`true`})]}),a]}),o,s&&(0,$.jsx)(Fe,{id:c,className:H(`m-0`,i?`text-[11px]`:`text-xs`),children:s})]}),l&&(0,$.jsx)(Ie,{children:l})]})}function tn(e){if(e.size>1e7)throw Error(m(`detail.attachment.tooLarge`))}var nn=async e=>({name:e.name,contentType:e.type||`application/octet-stream`,data:await te(e)});function rn(e,t){let n=R(`upload_attachment`),r=R(`stage_upload`);return async i=>{tn(i);let a=await nn(i),o=`ticketId`in t?await n.mutateAsync({projectId:e,ticketId:t.ticketId,...a}):await r.mutateAsync({projectId:e,...a});return`onStaged`in t&&t.onStaged(o.id),{url:h(e,o.id),name:o.name,contentType:o.contentType}}}function an({ticket:e}){let t=J(C.query(`list_attachments`,{projectId:e.projectId,ticketId:e.id})),n=R(`upload_attachment`),r=R(`delete_attachment`),i=B(e.projectId),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1);async function f(t){if(t.length){s(void 0),d(!0);try{t.forEach(tn);for(let r of t)await n.mutateAsync({projectId:e.projectId,ticketId:e.id,...await nn(r)});N.success(m(`detail.attachment.attached`,{count:t.length}))}catch(e){s(e)}finally{d(!1)}}}return(0,$.jsxs)(`section`,{onDragOver:e=>{i.canWrite&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:e=>{e.preventDefault(),l(!1),i.canWrite&&f(Array.from(e.dataTransfer.files))},className:H(`rounded-lg transition-colors`,c&&`bg-primary/5 ring-2 ring-primary/40 ring-offset-4 ring-offset-background`),children:[(0,$.jsx)(V,{compact:!0,title:m(`detail.attachment.heading`),action:i.canWrite&&(0,$.jsx)(T,{label:m(u?`detail.resource.uploading`:`detail.attachment.attach`),size:`icon-sm`,disabled:u,onClick:()=>a.current?.click(),children:u?(0,$.jsx)(le,{}):(0,$.jsx)(qe,{})})}),!t.isPending&&!t.data?.length&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:i.canWrite?m(`detail.attachment.emptyWritable`):m(`detail.attachment.empty`)}),(0,$.jsx)(Me,{className:`gap-0`,children:t.data?.map(t=>(0,$.jsx)(en,{compact:!0,download:!0,icon:(0,$.jsx)(ht,{className:`size-4 text-muted-foreground`}),href:h(e.projectId,t.id),label:t.name,meta:W(t.size),metaId:`attachment-size-${t.id}`,actions:i.canWrite&&(0,$.jsx)(ae,{label:m(`detail.attachment.remove`),icon:(0,$.jsx)(He,{}),description:m(`detail.resource.removeConfirm`,{name:t.name}),onConfirm:()=>r.mutateAsync({projectId:e.projectId,attachmentId:t.id})})},t.id))}),(0,$.jsx)(he,{ref:a,type:`file`,multiple:!0,className:`hidden`,"aria-label":m(`detail.attachment.fileInput`),disabled:u,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,f(t)}}),(0,$.jsx)(D,{error:o??t.error??r.error})]})}var on={passed:ke,failed:w,pending:b,reported:I};function sn({ticket:e}){let t=B(e.projectId),n=J(C.query(`list_evidence`,{projectId:e.projectId,ticketId:e.id})),o=R(`add_evidence`),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)();return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(V,{title:m(`detail.section.evidence`),description:m(`detail.evidence.description`),action:t.canWrite&&(0,$.jsx)(T,{label:m(`detail.evidence.add`),onClick:()=>{o.reset(),u(void 0),c(!0)},children:(0,$.jsx)(Pe,{})})}),!n.isPending&&!n.data?.length&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m(`detail.evidence.empty`)}),(0,$.jsx)(Me,{className:`gap-0`,children:n.data?.map(t=>{let n=on[t.outcome]??I;return(0,$.jsx)(en,{icon:(0,$.jsx)(n,{className:H(t.outcome===`passed`&&`text-[var(--success)]`,t.outcome===`failed`&&`text-destructive`)}),href:t.url,label:t.title,badges:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`outline`,className:`ml-2`,children:i[t.kind]}),(0,$.jsx)(Y,{variant:`outline`,className:H(`ml-1`,t.outcome===`passed`&&`text-[var(--success)]`,t.outcome===`failed`&&`text-destructive`),"data-outcome":t.outcome,children:a[t.outcome]})]}),details:(0,$.jsxs)($.Fragment,{children:[t.commit&&(0,$.jsx)(`code`,{className:`w-fit rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] break-all`,children:t.commit}),t.note&&(0,$.jsx)(ce,{children:t.note})]}),meta:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{projectId:e.projectId,actorId:t.actorId}),` ·`,` `,(0,$.jsx)(G,{value:t.createdAt})]})},t.id)})}),(0,$.jsx)(re,{title:m(`detail.evidence.add`),open:s,onOpenChange:c,busy:o.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);o.mutateAsync({projectId:e.projectId,ticketId:e.id,kind:r.shape.kind.parse(n.get(`kind`)),title:X(n,`title`),url:X(n,`url`),commit:X(n,`commit`)||null,outcome:r.shape.outcome.parse(n.get(`outcome`)),note:X(n,`note`)}).then(()=>{c(!1),N.success(m(`detail.evidence.added`))}).catch(u)},children:[(0,$.jsx)(L,{label:m(`detail.field.title`),name:`title`,required:!0,maxLength:200}),(0,$.jsx)(L,{label:m(`detail.field.url`),name:`url`,type:`url`,required:!0}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-5 sm:grid-cols-2`,children:[(0,$.jsx)(de,{label:m(`detail.evidence.kindLabel`),name:`kind`,children:r.shape.kind.options.map(e=>(0,$.jsx)(F,{value:e,children:i[e]},e))}),(0,$.jsx)(de,{label:m(`detail.evidence.outcomeLabel`),name:`outcome`,children:r.shape.outcome.unwrap().options.map(e=>(0,$.jsx)(F,{value:e,children:a[e]},e))})]}),(0,$.jsx)(L,{label:m(`detail.evidence.commit`),name:`commit`,pattern:`[a-fA-F0-9]{40,64}`}),(0,$.jsx)(Se,{label:m(`detail.evidence.note`),name:`note`,maxLength:2e4}),(0,$.jsx)(q,{error:l??o.error,pending:o.isPending,submitLabel:m(`detail.evidence.add`),onCancel:()=>c(!1)})]})}),(0,$.jsx)(D,{error:n.error})]})}var cn=[`open`,`closed`,`merged`,`draft`,`active`,`deleted`];function ln({remoteKind:e,remoteState:t,provider:n}){if(!t)return m(`detail.link.stateUnknown`);let r=cn.find(e=>e===t),i=r?m(`detail.link.remoteState.${r}`):t.charAt(0).toUpperCase()+t.slice(1);return e?m(`detail.link.remote`,{kind:c(e,n),state:i}):i}function un({ticket:e}){let t=B(e.projectId),n=J(C.query(`list_resources`,{projectId:e.projectId,ticketId:e.id})),r=R(`add_resource`),i=R(`update_resource`),a=R(`delete_resource`),[s,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(),p=r.isPending||i.isPending,h=e=>{f(void 0),c(e),u(!0)};return(0,$.jsxs)(`section`,{"aria-label":m(`detail.link.heading`),children:[(0,$.jsx)(V,{compact:!0,title:m(`detail.link.heading`),action:t.canWrite&&(0,$.jsx)(T,{label:m(`detail.link.add`),size:`icon-sm`,onClick:()=>h(),children:(0,$.jsx)(Pe,{})})}),!n.isPending&&!n.data?.length&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:m(`detail.link.empty`)}),(0,$.jsx)(Me,{className:`gap-0`,children:n.data?.map(n=>(0,$.jsx)(en,{compact:!0,icon:(0,$.jsx)(rt,{className:`size-4 text-muted-foreground`}),href:n.url,label:n.title||n.url,meta:n.provider?(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,children:n.provider}),(0,$.jsx)(Y,{variant:`outline`,className:n.remoteState?void 0:`text-muted-foreground`,children:ln(n)})]}):n.title&&o(n.url),actions:t.canWrite&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{size:`icon-sm`,label:m(`detail.link.edit`),onClick:()=>h(n),children:(0,$.jsx)(Ue,{})}),(0,$.jsx)(ae,{label:m(`detail.link.remove`),icon:(0,$.jsx)(He,{}),description:m(`detail.resource.removeConfirm`,{name:n.title||n.url}),onConfirm:()=>a.mutateAsync({projectId:e.projectId,resourceId:n.id,expectedVersion:n.version})})]})},n.id))}),(0,$.jsx)(re,{title:m(s?`detail.link.edit`:`detail.link.add`),open:l,onOpenChange:u,busy:p,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget),a={url:X(n,`url`),title:X(n,`title`)};f(void 0),(s?i.mutateAsync({projectId:e.projectId,resourceId:s.id,expectedVersion:s.version,...a}):r.mutateAsync({projectId:e.projectId,ticketId:e.id,...a})).then(()=>u(!1)).catch(f)},children:[(0,$.jsx)(L,{label:m(`detail.field.url`),name:`url`,type:`url`,required:!0,autoFocus:!0,defaultValue:s?.url}),(0,$.jsx)(L,{label:m(`detail.field.title`),name:`title`,maxLength:200,defaultValue:s?.title}),(0,$.jsx)(q,{error:d,pending:p,submitLabel:m(s?`detail.link.save`:`detail.link.add`),onCancel:()=>u(!1)})]})}),(0,$.jsx)(D,{error:n.error})]})}function dn({ticket:e}){let[t,n]=(0,Q.useState)(0),r=J(C.query(`list_activity`,{projectId:e.projectId,ticketId:e.id,offset:t}));return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:m(`detail.section.activity`)}),(0,$.jsx)(D,{error:r.error}),(0,$.jsx)(`ol`,{className:`m-0 list-none p-0`,children:r.data?.items.map(t=>(0,$.jsxs)(`li`,{className:`relative flex flex-col gap-0.5 border-l py-2.5 pl-5 text-xs before:absolute before:top-4 before:-left-[3px] before:size-[5px] before:rounded-full before:bg-muted-foreground/50`,children:[(0,$.jsx)(`span`,{children:d(t)}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,$.jsx)(Ae,{projectId:e.projectId,actorId:t.actorId}),` ·`,` `,(0,$.jsx)(G,{value:t.createdAt})]})]},t.id))}),((r.data?.total??0)>50||t>0)&&(0,$.jsxs)($t,{className:`mt-5 justify-end`,children:[(0,$.jsx)(z,{size:`sm`,disabled:!t,onClick:()=>n(Math.max(0,t-50)),children:m(`detail.activity.previous`)}),(0,$.jsx)(z,{size:`sm`,disabled:t+50>=(r.data?.total??0),onClick:()=>n(t+50),children:m(`detail.activity.next`)})]})]})}var fn=`h-7 max-w-64 min-w-0 border border-transparent px-2 font-normal hover:border-border aria-pressed:border-border aria-pressed:bg-muted`;function pn({projectId:e,ticket:r,initial:i,onSaved:a}){let o=Te(),s=`kanvil:${E().id}:draft:${e}:${r?.id??`new:${i?.parentId??``}`}`,[c,l]=(0,Q.useState)(()=>{let e=ft(r);return i?{...e,fields:{...e.fields,...i}}:e}),[d,f]=(0,Q.useState)(()=>{try{let e=dt.safeParse(JSON.parse(localStorage.getItem(s)??`null`));if(e.success)return e.data}catch{}return c}),h=(0,Q.useRef)(d);function g(e){h.current=e,f(e)}let ee=`kanvil:composer-expanded`,[v,y]=(0,Q.useState)(()=>{try{return localStorage.getItem(ee)===`1`}catch{return!1}});function b(){y(e=>{try{localStorage.setItem(ee,e?`0`:`1`)}catch{}return!e})}let[te,x]=(0,Q.useState)(()=>!!d.fields.acceptanceCriteria),[S,w]=(0,Q.useState)(),[T,O]=(0,Q.useState)(),[k,j]=(0,Q.useState)(!1),[M,F]=(0,Q.useState)(!1),[re,I]=(0,Q.useState)(),ae=R(`create_ticket`),oe=R(`update_ticket`),ce=R(`discard_upload`),ue=Oe(),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(!1),B=(0,Q.useRef)(0),[pe,he]=(0,Q.useState)(!1);function V(e){g(e),I(void 0);try{localStorage.setItem(s,JSON.stringify(e)),O(void 0),j(!0)}catch{O(Error(m(`detail.editor.storageUnavailable`))),j(!1)}}function _e(){try{localStorage.removeItem(s)}catch{}ve(h.current.uploads),g(c),j(!1)}function ve(e){for(let t of e)ce.mutateAsync({projectId:K,uploadId:t}).catch(()=>{})}let U=e=>V({...h.current,fields:{...h.current.fields,...e}}),W=(e,t)=>U({[e]:t}),ye=(e,t)=>W(`customFields`,{...h.current.fields.customFields,[e]:t});async function xe(t){let n=++B.current;V({...h.current,projectId:t===e?void 0:t,fields:{...h.current.fields,parentId:null,stateId:null,customFields:{}}}),he(!0);let r=[];try{r=await ue.ensureQueryData(C.query(`list_members`,{projectId:t}))}finally{if(n===B.current){let e=h.current,{assigneeId:t}=e.fields;t&&!r.some(e=>e.userId===t)&&V({...e,fields:{...e.fields,assigneeId:null}}),he(!1)}}}let G=d.fields,K=d.projectId??e,Ce=!!r&&d.version!==r.version,we=JSON.stringify(d.fields)!==JSON.stringify(c.fields)||d.projectId!==c.projectId,q=ae.isPending||oe.isPending,J=q||Ce||pe,Y=G.automationReady||G.scopes.length>0||!!G.holdReason,De=rn(K,r?{ticketId:r.id}:{onStaged:e=>V({...h.current,uploads:[...h.current.uploads,e]})});async function ke(t){if(t.preventDefault(),J||fe.current)return;let n=Ye(G),i=d.uploads.filter(e=>G.description.includes(e)||G.acceptanceCriteria.includes(e));fe.current=!0,o?.(!0);try{let t=r?await oe.mutateAsync({projectId:e,ticketId:r.id,expectedVersion:d.version??r.version,changes:n}):await ae.mutateAsync({projectId:K,...n,uploads:i}).catch(e=>{throw Ae(e),e});r||ve(d.uploads.filter(e=>!i.includes(e)));try{localStorage.removeItem(s)}catch{}if(r||!M)return N.success(m(r?`detail.editor.saved`:`detail.editor.created`,{key:t.key})),a(t);let o=h.current.fields,c=e=>o[e]===G[e]?``:o[e],u={...h.current,uploads:h.current.uploads.filter(e=>!d.uploads.includes(e)),fields:{...o,title:c(`title`),description:c(`description`),acceptanceCriteria:c(`acceptanceCriteria`)}};l({...u,fields:{...u.fields,title:``,description:``,acceptanceCriteria:``}}),u.fields.title||u.fields.description||u.fields.acceptanceCriteria?V(u):(g(u),j(!1)),x(!!u.fields.acceptanceCriteria),I(t.key),de.current?.focus()}finally{fe.current=!1,o?.(!1)}}function Ae(e){let r=e instanceof p&&u({uploads:n(t())}).safeParse(e.details).data?.uploads;r&&V({...h.current,uploads:h.current.uploads.filter(e=>!r.includes(e))})}let je=q||d.uploads.length>0,Me=(0,$.jsxs)(`div`,{className:`-mt-3 flex flex-wrap items-center gap-1`,"aria-label":m(`detail.editor.properties`),children:[!r&&(0,$.jsx)($e,{value:K,disabled:je,onChange:e=>void xe(e).catch(Ee)}),(0,$.jsx)(Z,{property:`status`,projectId:K,value:it(G),onChange:e=>U(ut(e))}),(0,$.jsx)(Z,{property:`priority`,projectId:K,value:G.priority,onChange:e=>W(`priority`,e)}),(0,$.jsx)(Z,{property:`assignee`,projectId:K,value:G.assigneeId,onChange:e=>W(`assigneeId`,e)}),(0,$.jsx)(Z,{property:`kind`,projectId:K,value:G.kind,onChange:e=>W(`kind`,e)}),(0,$.jsx)(Z,{property:`difficulty`,projectId:K,value:G.difficulty,onChange:e=>W(`difficulty`,e)}),(0,$.jsx)(at,{value:G.labels,onChange:e=>W(`labels`,e)}),(0,$.jsx)(st,{variant:`pill`,value:G,onChange:U}),(0,$.jsx)(Ze,{variant:`pill`,projectId:K,values:G.customFields,isNew:!r,onChange:ye}),(0,$.jsx)(Zt,{variant:`pill`,label:m(`detail.field.parentTicket`),placeholder:m(`detail.field.parent`),projectId:K,value:G.parentId,onChange:e=>W(`parentId`,e),exclude:r?[r.id]:[]}),(0,$.jsxs)(nt,{size:`sm`,className:H(fn,`gap-1.5`),pressed:G.automationReady,onPressedChange:e=>W(`automationReady`,e),"aria-label":m(`detail.editor.readyForAgents`),title:m(`detail.editor.readyForAgentsHelp`),children:[(0,$.jsx)(St,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),G.automationReady?m(`detail.editor.readyForAgents`):m(`detail.editor.agents`)]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(ne,{render:(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,className:H(`size-7 border border-transparent hover:border-border`,Y&&`text-primary`),"aria-label":m(`detail.editor.moreProperties`)}),children:(0,$.jsx)(Ke,{className:`size-3.5`})}),(0,$.jsxs)(P,{align:`start`,className:`w-[min(24rem,calc(100vw-2rem))] p-4`,children:[(0,$.jsx)(Qe,{label:m(`detail.field.scopes`),kind:`scope`,value:G.scopes,onChange:e=>W(`scopes`,e)}),(0,$.jsx)(L,{label:m(`detail.field.holdReason`),value:G.holdReason??``,maxLength:2e3,placeholder:m(`detail.editor.holdPlaceholder`),onChange:e=>W(`holdReason`,e.target.value||null)}),(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:m(`detail.editor.claimsNote`)})]})]})]}),Pe=(0,$.jsxs)(`form`,{onSubmit:e=>{w(void 0),ke(e).catch(w)},onKeyDown:Je,className:`ticket-composer flex min-h-0 flex-1 flex-col`,"data-expanded":v,children:[(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-11 hidden sm:inline-flex`,"aria-label":m(v?`detail.editor.restoreSize`:`detail.editor.expand`),"aria-pressed":v,disabled:q,onClick:b,children:v?(0,$.jsx)(Pt,{}):(0,$.jsx)(pt,{})}),(0,$.jsxs)(`div`,{className:H(`min-h-0 flex-1 overflow-y-auto overscroll-contain`,v&&`lg:grid lg:grid-cols-[minmax(0,1fr)_320px] lg:items-start`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-4 px-5 py-5 sm:px-8`,children:[Ce&&(0,$.jsxs)(be,{className:`w-auto`,children:[(0,$.jsx)(gt,{}),(0,$.jsx)(me,{children:m(`detail.editor.staleTitle`)}),(0,$.jsxs)(ge,{children:[m(`detail.editor.staleDescription`,{version:d.version}),(0,$.jsx)(z,{size:`sm`,className:`mt-2`,onClick:()=>V(ft(r)),children:m(`detail.editor.discardAndReload`)})]})]}),(0,$.jsx)(D,{error:S??ae.error??oe.error??T}),(0,$.jsx)(`div`,{className:`[&_[data-slot=field-label]]:sr-only`,children:(0,$.jsx)(Se,{label:m(`detail.field.title`),rows:1,value:G.title,onChange:e=>W(`title`,e.target.value),required:!0,maxLength:500,autoFocus:!0,ref:de,placeholder:m(`detail.editor.titlePlaceholder`),className:`field-sizing-content min-h-10 resize-none border-0 bg-transparent px-0 py-1 text-xl! font-semibold leading-snug shadow-none caret-primary focus-visible:ring-0 dark:bg-transparent`})}),!v&&Me,(0,$.jsx)(Xt,{label:m(`detail.field.description`),value:G.description,onChange:e=>W(`description`,e),rows:8,variant:`document`,placeholder:m(`detail.editor.descriptionPlaceholder`),onUpload:De}),te?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Xt,{label:m(`detail.field.acceptanceCriteria`),value:G.acceptanceCriteria,onChange:e=>W(`acceptanceCriteria`,e),rows:4,variant:`document`,maxLength:5e4,placeholder:m(`detail.editor.criteriaPlaceholder`),onUpload:De}),!G.acceptanceCriteria&&(0,$.jsx)(z,{variant:`ghost`,size:`icon-xs`,className:`absolute top-5 right-24 text-muted-foreground`,"aria-label":m(`detail.editor.removeCriteria`),onClick:()=>x(!1),children:(0,$.jsx)(_,{})})]}):(0,$.jsxs)(z,{variant:`ghost`,size:`sm`,className:`w-fit text-muted-foreground`,onClick:()=>x(!0),children:[(0,$.jsx)(_t,{}),m(`detail.editor.addCriteria`)]})]}),v&&(0,$.jsxs)(`aside`,{className:`border-t bg-muted/20 p-5 lg:sticky lg:top-0 lg:min-h-full lg:border-t-0 lg:border-l`,"aria-label":m(`detail.editor.properties`),children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[!r&&(0,$.jsx)($e,{variant:`row`,value:K,disabled:je,onChange:e=>void xe(e).catch(Ee)}),(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:K,value:it(G),onChange:e=>U(ut(e))}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:K,value:G.priority,onChange:e=>W(`priority`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:K,value:G.assigneeId,onChange:e=>W(`assigneeId`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:K,value:G.kind,onChange:e=>W(`kind`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:K,value:G.difficulty,onChange:e=>W(`difficulty`,e)}),(0,$.jsx)(st,{variant:`row`,value:G,onChange:U}),(0,$.jsx)(Ze,{variant:`row`,projectId:K,values:G.customFields,isNew:!r,onChange:ye}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[80px_minmax(0,1fr)] items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`detail.editor.agents`)}),(0,$.jsxs)(nt,{size:`sm`,className:H(fn,`h-7 justify-start gap-1.5`),pressed:G.automationReady,onPressedChange:e=>W(`automationReady`,e),"aria-label":m(`detail.editor.readyForAgents`),children:[(0,$.jsx)(St,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),G.automationReady?m(`detail.editor.readyForAgents`):m(`detail.editor.notReady`)]})]})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t pt-5`,children:[(0,$.jsx)(Qe,{label:m(`detail.field.labels`),value:G.labels,onChange:e=>W(`labels`,e)}),(0,$.jsx)(Zt,{label:m(`detail.field.parentTicket`),projectId:K,value:G.parentId,onChange:e=>W(`parentId`,e),exclude:r?[r.id]:[]}),(0,$.jsx)(Qe,{label:m(`detail.field.scopes`),kind:`scope`,value:G.scopes,onChange:e=>W(`scopes`,e)}),(0,$.jsx)(L,{label:m(`detail.field.holdReason`),value:G.holdReason??``,maxLength:2e3,placeholder:m(`detail.editor.holdPlaceholder`),onChange:e=>W(`holdReason`,e.target.value||null)})]})]})]}),(0,$.jsxs)(`footer`,{className:`z-10 flex shrink-0 flex-wrap items-center justify-between gap-3 border-t bg-muted/40 px-5 py-3`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,role:`status`,children:[re?m(`detail.editor.created`,{key:re}):k?m(`detail.editor.savedLocally`):T?m(`detail.editor.notSavedLocally`):``,we&&!Ce&&(0,$.jsxs)(z,{variant:`ghost`,size:`xs`,disabled:q,onClick:_e,children:[(0,$.jsx)(Ge,{}),m(`detail.editor.discardDraft`)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!r&&(0,$.jsxs)(`label`,{className:`mr-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(vt,{size:`sm`,checked:M,disabled:q,onCheckedChange:F}),m(`detail.editor.createMore`)]}),(0,$.jsx)(ie,{render:(0,$.jsx)(z,{disabled:q}),children:m(`common.action.cancel`)}),(0,$.jsxs)(z,{type:`submit`,variant:`default`,disabled:J,children:[q?(0,$.jsx)(le,{}):null,m(q?`common.state.saving`:r?`detail.editor.save`:`detail.editor.create`),!q&&(0,$.jsx)(se,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})]})]})]});return(0,$.jsx)(Ne,{projectId:K,children:Pe})}export{pn as TicketEditor,It as _,rn as a,Jt as c,Yt as d,Bt as f,Gt as g,qt as h,un as i,Xt as l,Ut as m,an as n,$t as o,Ht as p,sn as r,Zt as s,dn as t,Kt as u};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visual-editor-KE96mwCg.js","assets/rolldown-runtime-COiEfhsA.js","assets/default-6QIAyMq2.js","assets/core-jXc03Sty.js","assets/en-EnSRisMz.js","assets/preload-helper-BLdHbfdN.js","assets/search-B3-w3oCd.js","assets/toDate-B3HYxwtT.js","assets/forms-BbWAl0BZ.js","assets/index-2V6MWx63.js","assets/item-DED0Ikqi.js","assets/Trans-DxqBaUXP.js","assets/CompositeItem-B5Qlh5m0.js","assets/en-US-DKYSujv3.js","assets/index-DyQNFS69.css","assets/highlight-Ds7xUUQv.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{An as t,Cn as n,F as r,I as i,L as a,Lt as o,Mn as s,Mt as c,Nn as l,On as u,U as d,at as f,i as p,mn as m,o as h,r as g}from"./default-6QIAyMq2.js";import{A as ee,Aa as _,Ai as v,D as y,Fa as b,Fi as te,Ga as x,Ha as S,Hi as C,I as ne,Ia as w,J as T,Ji as E,K as D,M as O,Mi as k,N as A,Ni as j,O as M,Oa as N,P,Pt as F,Q as re,Ra as I,Tt as ie,V as ae,X as oe,Xn as se,Y as L,Z as ce,Zi as R,_t as le,aa as ue,at as de,ct as fe,di as z,ea as B,fr as pe,gt as me,hr as he,ht as ge,it as V,ji as _e,k as ve,ka as H,ki as U,lt as W,mr as ye,mt as be,nr as xe,nt as G,or as K,ot as Se,pi as Ce,pr as we,pt as Te,q,qa as J,ut as Ee,vt as Y,w as De,wo as Oe,za as ke,zi as Ae}from"./search-B3-w3oCd.js";import{t as je}from"./preload-helper-BLdHbfdN.js";import{a as Me,d as Ne,g as Pe,i as Fe,n as Ie,o as Le,r as Re,s as ze,t as Be}from"./item-DED0Ikqi.js";import{i as Ve,n as He,r as Ue}from"./CompositeItem-B5Qlh5m0.js";import{t as We}from"./corner-left-up-arA2ipmM.js";import{t as Ge}from"./rotate-ccw-DGM890Fc.js";import{t as Ke}from"./sliders-horizontal-yKgghk8h.js";import{t as qe}from"./upload-BzLq4CMS.js";import{r as Je,t as X}from"./forms-BbWAl0BZ.js";import{At as Ye,Ct as Xe,J as Ze,Ot as Qe,Z as $e,_ as et,bt as tt,d as nt,dn as rt,dt as it,et as at,g as ot,gt as st,h as ct,hn as lt,it as ut,jt as dt,kt as ft,ln as pt,m as mt,mn as ht,nn as gt,tt as Z,un as _t}from"./index-2V6MWx63.js";import{t as vt}from"./switch-ByOrazEW.js";var yt={name:`bold`,size:24,node:[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]};yt.node;var bt=x(yt),xt={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};xt.node;var St=x(xt),Ct={name:`heading`,size:24,node:[[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M6 20V4`,key:`1w1bmo`}],[`path`,{d:`M18 20V4`,key:`o2hl4u`}]]};Ct.node;var wt=x(Ct),Tt={name:`italic`,size:24,node:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]};Tt.node;var Et=x(Tt),Dt={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Dt.node;var Ot=x(Dt),kt={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};kt.node;var At=x(kt),jt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};jt.node;var Mt=x(jt),Nt={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};Nt.node;var Pt=x(Nt),Ft={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Ft.node;var It=x(Ft),Lt={name:`square-code`,size:24,node:[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`code-square`]};Lt.node;var Rt=x(Lt),Q=e(l(),1),$=g(),zt=(0,Q.lazy)(()=>je(()=>import(`./visual-editor-KE96mwCg.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Bt={heading:wt,bold:bt,italic:Et,link:Ot,bullets:Mt,numbers:At,tasks:_t,code:Rt};function Vt(e,t){let n=/(?:^|[\s([{])@([^\s@[\]()]{0,40})$/.exec(e.slice(0,t));return n?.[1]===void 0?null:{from:t-n[1].length-1,query:n[1]}}var Ht=(e,t)=>e.filter(e=>`${e.name} ${e.email}`.toLowerCase().includes(t.toLowerCase())).slice(0,8),Ut=e=>({key:e.userId,content:(0,$.jsx)(ue,{name:e.name,email:e.email,image:e.image})}),Wt=e=>f(e.name,e.userId);function Gt(e){let[t,n]=(0,Q.useState)(``),r=e.includes(t)?t:e[0];return{active:r,setHighlight:n,handleKey:(t,i,a)=>{if(!r||t.isComposing)return!1;let o={ArrowDown:1,ArrowUp:-1}[t.key];if(!o&&![`Enter`,`Tab`,`Escape`].includes(t.key))return!1;t.preventDefault();let s=e.indexOf(r);return o?n(e[(s+o+e.length)%e.length]??``):t.key===`Escape`?a():i(r),!0}}}function Kt({id:e,label:t,open:n,anchor:r,options:i,active:a,onHighlight:o,onChoose:s,onDismiss:c}){return(0,$.jsx)(A,{open:n,onOpenChange:e=>{e||c()},children:(0,$.jsx)(P,{anchor:r,align:`start`,initialFocus:!1,finalFocus:!1,className:`w-[min(20rem,calc(100vw-2rem))] p-1`,children:(0,$.jsx)(`div`,{role:`listbox`,id:e,"aria-label":t,children:i.map(t=>(0,$.jsx)(`div`,{role:`option`,id:`${e}-${t.key}`,"aria-selected":t.key===a,"data-selected":t.key===a||void 0,className:O,onMouseDown:e=>e.preventDefault(),onPointerMove:()=>o(t.key),onClick:()=>s(t.key),children:t.content},t.key))})})})}function qt(e,t,n){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=async e=>{if(t&&e.length){i(t=>t+e.length);for(let r of e)try{n(U(await t(r)))}catch(e){Ee(e)}finally{i(e=>e-1)}}},s=(0,$.jsx)(`input`,{ref:a,type:`file`,multiple:!0,hidden:!0,"aria-label":m(`detail.markdown.insertFileInto`,{label:e}),onChange:e=>{let t=[...e.target.files??[]];e.target.value=``,o(t)}});return{uploading:r>0,send:o,pick:()=>a.current?.click(),input:s}}function Jt({label:e,flush:t,onApply:n,pressed:r,upload:i,children:a}){return(0,$.jsxs)(we,{align:`block-start`,role:`toolbar`,"aria-label":m(`detail.markdown.formatting`,{label:e}),className:H(`gap-0.5 overflow-x-auto border-b py-1 pl-1 text-foreground [scrollbar-width:none] max-md:gap-0 max-md:px-0`,t&&`px-0`),onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r={ArrowRight:1,ArrowLeft:-1}[e.key],i=e.key===`Home`?t[0]:e.key===`End`?t.at(-1):r&&t.at((n+r)%t.length);i&&(e.preventDefault(),i.focus())},children:[k.map((e,t)=>{let i=_e[e],a=Bt[e];return(0,$.jsx)(T,{label:i.label,...`shortcut`in i?{shortcut:i.shortcut}:{},...r?{"aria-pressed":r(e)}:{},size:`icon-sm`,tabIndex:t===0?0:-1,className:`text-muted-foreground hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,onClick:()=>n(e),children:(0,$.jsx)(a,{})},e)}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{label:i.uploading?m(`detail.resource.uploading`):m(`detail.markdown.insertFile`),size:`icon-sm`,tabIndex:-1,disabled:i.uploading,className:`text-muted-foreground hover:text-foreground`,onClick:i.pick,children:i.uploading?(0,$.jsx)(le,{}):(0,$.jsx)(It,{})}),i.input]}),a]})}function Yt(e){return e?.files.length?[...e.files]:[]}function Xt({label:e,value:t,onChange:n,placeholder:r,rows:i=5,variant:a=`compact`,maxLength:o=1e5,required:s=!1,footer:c,mentions:l,onUpload:u}){let d=(0,Q.useId)(),f=(0,Q.useRef)(null),[p,h]=Xe(tt.editor),[g,ee]=(0,Q.useState)(!1),[_,y]=(0,Q.useState)(!1),b=g?`preview`:p===`visual`&&!_?`visual`:`write`,te=J({...C.query(`list_members`,{projectId:l??``}),enabled:!!l}),[x,S]=(0,Q.useState)(0),[ne,w]=(0,Q.useState)(null),T=l?Vt(t,x):null,E=Ht(te.data??[],T?.query??``),D=Gt(E.map(e=>e.userId)),O=!!T&&T.from!==ne&&E.length>0,k=`${d}-mentions`,A=e=>{let t=f.current;t&&(t.focus(),t.setSelectionRange(e.from,e.to),document.execCommand(`insertText`,!1,e.text)||(t.setRangeText(e.text),n(t.value)),t.setSelectionRange(e.start,e.end),S(e.end))},M=e=>{let t=f.current;t&&A(v(t.value,t.selectionStart,t.selectionEnd,e))},N=e=>{let t=E.find(t=>t.userId===e);if(!T||!t)return;let n=`${Wt(t)} `,r=T.from+n.length;A({from:T.from,to:x,text:n,start:r,end:r})},P=qt(e,u,e=>{let t=f.current;if(!t)return;let n=t.selectionEnd+e.length;A({from:t.selectionStart,to:t.selectionEnd,text:e,start:n,end:n})}),F=(e,t)=>{let n=u?Yt(t):[];n.length&&(e.preventDefault(),P.send(n))},re=(0,Q.useCallback)(()=>y(!0),[]),I=a===`document`?`rounded-none border-0 bg-transparent dark:bg-transparent has-[[data-slot=input-group-control]:focus-visible]:ring-0`:void 0,ie=c&&(0,$.jsx)(we,{align:`block-end`,className:`justify-end border-t py-2`,children:c});return(0,$.jsx)(xe,{className:H(`mb-6 [&_[data-slot=tabs-list]]:shrink-0 [&_[data-slot=tabs-trigger]]:text-xs`,a===`compact`&&`[&_textarea]:field-sizing-fixed [&_textarea]:max-h-[28rem] [&_.ProseMirror]:max-h-[28rem] [&_.ProseMirror]:overflow-y-auto`,a===`document`&&`border-t pt-5 has-[[data-slot=input-group-control]:focus]:border-t-primary has-[[data-slot=input-group-control]:focus]:[&_[data-slot=field-label]]:text-primary`),"data-variant":a,"aria-label":m(`detail.markdown.editor`,{label:e}),children:(0,$.jsxs)(mt,{value:b,onValueChange:e=>{ee(e===`preview`),(e===`write`||e===`visual`)&&(h(e),y(!1))},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(K,{htmlFor:d,children:e}),(0,$.jsxs)(ot,{"aria-label":m(`detail.markdown.editor`,{label:e}),variant:`line`,children:[(0,$.jsx)(et,{value:`write`,children:m(`detail.markdown.write`)}),(0,$.jsx)(et,{value:`visual`,children:m(`detail.markdown.visual`)}),(0,$.jsx)(et,{value:`preview`,children:m(`detail.markdown.preview`)})]})]}),(0,$.jsxs)(ct,{value:`write`,children:[_&&p===`visual`&&(0,$.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:m(`detail.markdown.unsupported`)}),(0,$.jsxs)(pe,{className:I,children:[(0,$.jsx)(Jt,{label:e,flush:a===`document`,onApply:M,...u?{upload:P}:{}}),(0,$.jsx)(ye,{ref:f,id:d,className:a===`document`?`field-sizing-content max-h-none resize-y px-1 py-3 text-base md:text-base leading-7 caret-primary`:void 0,style:a===`document`?{minHeight:`${i}lh`}:void 0,value:t,onChange:e=>{S(e.target.selectionStart),n(e.target.value)},onSelect:e=>S(e.currentTarget.selectionStart),onPaste:e=>F(e,e.clipboardData),onDragOver:e=>{u&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>F(e,e.dataTransfer),...l&&{"aria-autocomplete":`list`,"aria-controls":O?k:void 0,"aria-activedescendant":O&&D.active?`${k}-${D.active}`:void 0},onKeyDown:e=>{if(O&&D.handleKey(e.nativeEvent,N,()=>w(T.from))){e.stopPropagation();return}let t=j(e);!t||t===`link`&&e.currentTarget.selectionStart===e.currentTarget.selectionEnd||(e.preventDefault(),e.stopPropagation(),M(t))},placeholder:r,rows:i,maxLength:o,required:s}),l&&(0,$.jsx)(Kt,{id:k,label:m(`detail.markdown.mention`),open:O,anchor:f,options:E.map(Ut),active:D.active,onHighlight:D.setHighlight,onChoose:N,onDismiss:()=>{T&&w(T.from)}}),ie]})]}),(0,$.jsx)(ct,{value:`visual`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(oe,{}),children:(0,$.jsx)(zt,{id:d,label:e,value:t,onChange:n,placeholder:r??``,rows:i,maxLength:o,flush:a===`document`,groupClassName:I,footer:ie,...l?{members:te.data??[]}:{},...u?{onUpload:u}:{},onUnsupported:re})})}),(0,$.jsxs)(ct,{value:`preview`,children:[(0,$.jsx)(`div`,{className:H(`min-h-28 rounded-lg border bg-muted/20 p-4`,a===`document`&&`rounded-none border-0 bg-transparent px-1 py-3 text-base leading-7`),children:t?(0,$.jsx)(ce,{children:t}):(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:m(`detail.markdown.nothingToPreview`)})}),c&&(0,$.jsx)(`div`,{className:`mt-2 flex justify-end`,children:c})]})]})})}function Zt({projectId:e,label:t,value:n,onChange:r,exclude:i=[],allowClear:a=!0,variant:o=`field`,placeholder:c=m(`ticket.picker.placeholder`)}){let l=(0,Q.useId)(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),h=J({...C.query(`list_tickets`,{projectId:e,q:f,archived:`include`,limit:30}),enabled:u}),g=J({...C.query(`get_ticket`,{projectId:e,ticketId:n??``}),enabled:!!n&&s().safeParse(n).success}),_=h.data?.items.filter(e=>!i.includes(e.id))??[],v=g.data?.ticket??h.data?.items.find(e=>e.id===n),b=(0,$.jsxs)(A,{open:u,onOpenChange:e=>{d(e),e&&p(``)},children:[(0,$.jsxs)(ne,{id:l,render:(0,$.jsx)(z,{variant:o===`pill`?`ghost`:`outline`,size:o===`pill`?`sm`:`default`,role:`combobox`,"aria-label":t,className:o===`pill`?`h-7 max-w-64 min-w-0 border border-transparent px-2 font-normal hover:border-border`:`h-auto min-h-8 w-full justify-between whitespace-normal text-left font-normal`}),children:[o===`pill`&&(0,$.jsx)(We,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:o===`pill`?`min-w-0 truncate`:`min-w-0 break-words`,children:v?o===`pill`?v.key:`${v.key} · ${v.title}`:n?m(`ticket.picker.loading`):c}),o!==`pill`&&(0,$.jsx)(Ve,{className:`ml-2 size-3.5 shrink-0 text-muted-foreground`})]}),(0,$.jsx)(P,{align:`start`,className:`w-[min(420px,var(--available-width))] p-0`,children:(0,$.jsxs)(De,{shouldFilter:!1,children:[(0,$.jsx)(M,{"aria-label":m(`ticket.picker.searchLabel`,{label:t}),placeholder:m(`ticket.picker.searchPlaceholder`),value:f,onValueChange:p}),(0,$.jsxs)(ee,{children:[a&&(0,$.jsx)(y,{children:(0,$.jsxs)(ve,{value:`none`,onSelect:()=>{r(null),d(!1)},children:[m(`ticket.picker.noParent`),!n&&(0,$.jsx)(S,{className:`ml-auto`})]})}),h.isPending?(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-6 text-sm text-muted-foreground`,children:m(`ticket.picker.searching`)}):_.length?(0,$.jsx)(y,{children:_.map(e=>(0,$.jsxs)(ve,{value:e.id,className:`items-start py-2`,onSelect:()=>{r(e.id),d(!1)},children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`mb-1 block font-mono text-[11px] text-muted-foreground`,children:e.key}),(0,$.jsx)(`span`,{dir:`auto`,className:`block break-words whitespace-normal`,children:e.title})]}),n===e.id&&(0,$.jsx)(S,{className:`ml-auto shrink-0`})]},e.id))}):(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-6 text-center text-sm text-muted-foreground`,children:m(`ticket.picker.empty`)}),(0,$.jsx)(D,{error:h.error})]})]})})]});return o===`pill`?(0,$.jsxs)($.Fragment,{children:[b,(0,$.jsx)(D,{error:g.error})]}):(0,$.jsxs)(xe,{className:fe,children:[(0,$.jsx)(K,{htmlFor:l,children:t}),b,(0,$.jsx)(D,{error:g.error})]})}var Qt=Ce(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function $t({className:e,orientation:t,...n}){return(0,$.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:H(Qt({orientation:t}),e),...n})}function en({icon:e,href:t,label:n,download:r=!1,compact:i=!1,badges:a,details:o,meta:s,metaId:c,actions:l}){return(0,$.jsxs)(Be,{role:`listitem`,size:i?`xs`:`default`,className:H(`rounded-none border-x-0 border-t-0 border-b-border px-0 animate-in fade-in-0 duration-200 last:border-b-0`,!i&&`items-start py-4`),children:[(0,$.jsx)(Le,{variant:i?`default`:`icon`,children:e}),(0,$.jsxs)(Re,{className:H(`min-w-0`,i?`gap-0`:`gap-1.5`),children:[(0,$.jsxs)(ze,{className:H(`line-clamp-none max-w-full wrap-anywhere`,i&&`text-xs font-normal`),children:[(0,$.jsxs)(`a`,{href:t,"aria-describedby":c,...r?{download:!0,className:`hover:text-primary`}:{target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`},children:[n,!r&&(0,$.jsx)(lt,{className:`size-3 shrink-0`,"aria-hidden":`true`})]}),a]}),o,s&&(0,$.jsx)(Fe,{id:c,className:H(`m-0`,i?`text-[11px]`:`text-xs`),children:s})]}),l&&(0,$.jsx)(Ie,{children:l})]})}function tn(e){if(e.size>1e7)throw Error(m(`detail.attachment.tooLarge`))}var nn=async e=>({name:e.name,contentType:e.type||`application/octet-stream`,data:await te(e)});function rn(e,t){let n=R(`upload_attachment`),r=R(`stage_upload`);return async i=>{tn(i);let a=await nn(i),o=`ticketId`in t?await n.mutateAsync({projectId:e,ticketId:t.ticketId,...a}):await r.mutateAsync({projectId:e,...a});return`onStaged`in t&&t.onStaged(o.id),{url:h(e,o.id),name:o.name,contentType:o.contentType}}}function an({ticket:e}){let t=J(C.query(`list_attachments`,{projectId:e.projectId,ticketId:e.id})),n=R(`upload_attachment`),r=R(`delete_attachment`),i=B(e.projectId),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1);async function f(t){if(t.length){s(void 0),d(!0);try{t.forEach(tn);for(let r of t)await n.mutateAsync({projectId:e.projectId,ticketId:e.id,...await nn(r)});N.success(m(`detail.attachment.attached`,{count:t.length}))}catch(e){s(e)}finally{d(!1)}}}return(0,$.jsxs)(`section`,{onDragOver:e=>{i.canWrite&&(e.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:e=>{e.preventDefault(),l(!1),i.canWrite&&f(Array.from(e.dataTransfer.files))},className:H(`rounded-lg transition-colors`,c&&`bg-primary/5 ring-2 ring-primary/40 ring-offset-4 ring-offset-background`),children:[(0,$.jsx)(V,{compact:!0,title:m(`detail.attachment.heading`),action:i.canWrite&&(0,$.jsx)(T,{label:m(u?`detail.resource.uploading`:`detail.attachment.attach`),size:`icon-sm`,disabled:u,onClick:()=>a.current?.click(),children:u?(0,$.jsx)(le,{}):(0,$.jsx)(qe,{})})}),!t.isPending&&!t.data?.length&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:i.canWrite?m(`detail.attachment.emptyWritable`):m(`detail.attachment.empty`)}),(0,$.jsx)(Me,{className:`gap-0`,children:t.data?.map(t=>(0,$.jsx)(en,{compact:!0,download:!0,icon:(0,$.jsx)(ht,{className:`size-4 text-muted-foreground`}),href:h(e.projectId,t.id),label:t.name,meta:W(t.size),metaId:`attachment-size-${t.id}`,actions:i.canWrite&&(0,$.jsx)(ae,{label:m(`detail.attachment.remove`),icon:(0,$.jsx)(He,{}),description:m(`detail.resource.removeConfirm`,{name:t.name}),onConfirm:()=>r.mutateAsync({projectId:e.projectId,attachmentId:t.id})})},t.id))}),(0,$.jsx)(he,{ref:a,type:`file`,multiple:!0,className:`hidden`,"aria-label":m(`detail.attachment.fileInput`),disabled:u,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,f(t)}}),(0,$.jsx)(D,{error:o??t.error??r.error})]})}var on={passed:ke,failed:w,pending:b,reported:I};function sn({ticket:e}){let t=B(e.projectId),n=J(C.query(`list_evidence`,{projectId:e.projectId,ticketId:e.id})),o=R(`add_evidence`),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)();return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(V,{title:m(`detail.section.evidence`),description:m(`detail.evidence.description`),action:t.canWrite&&(0,$.jsx)(T,{label:m(`detail.evidence.add`),onClick:()=>{o.reset(),u(void 0),c(!0)},children:(0,$.jsx)(Pe,{})})}),!n.isPending&&!n.data?.length&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m(`detail.evidence.empty`)}),(0,$.jsx)(Me,{className:`gap-0`,children:n.data?.map(t=>{let n=on[t.outcome]??I;return(0,$.jsx)(en,{icon:(0,$.jsx)(n,{className:H(t.outcome===`passed`&&`text-[var(--success)]`,t.outcome===`failed`&&`text-destructive`)}),href:t.url,label:t.title,badges:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`outline`,className:`ml-2`,children:i[t.kind]}),(0,$.jsx)(Y,{variant:`outline`,className:H(`ml-1`,t.outcome===`passed`&&`text-[var(--success)]`,t.outcome===`failed`&&`text-destructive`),"data-outcome":t.outcome,children:a[t.outcome]})]}),details:(0,$.jsxs)($.Fragment,{children:[t.commit&&(0,$.jsx)(`code`,{className:`w-fit rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] break-all`,children:t.commit}),t.note&&(0,$.jsx)(ce,{children:t.note})]}),meta:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{projectId:e.projectId,actorId:t.actorId}),` ·`,` `,(0,$.jsx)(G,{value:t.createdAt})]})},t.id)})}),(0,$.jsx)(re,{title:m(`detail.evidence.add`),open:s,onOpenChange:c,busy:o.isPending,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget);o.mutateAsync({projectId:e.projectId,ticketId:e.id,kind:r.shape.kind.parse(n.get(`kind`)),title:X(n,`title`),url:X(n,`url`),commit:X(n,`commit`)||null,outcome:r.shape.outcome.parse(n.get(`outcome`)),note:X(n,`note`)}).then(()=>{c(!1),N.success(m(`detail.evidence.added`))}).catch(u)},children:[(0,$.jsx)(L,{label:m(`detail.field.title`),name:`title`,required:!0,maxLength:200}),(0,$.jsx)(L,{label:m(`detail.field.url`),name:`url`,type:`url`,required:!0}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-5 sm:grid-cols-2`,children:[(0,$.jsx)(de,{label:m(`detail.evidence.kindLabel`),name:`kind`,children:r.shape.kind.options.map(e=>(0,$.jsx)(F,{value:e,children:i[e]},e))}),(0,$.jsx)(de,{label:m(`detail.evidence.outcomeLabel`),name:`outcome`,children:r.shape.outcome.unwrap().options.map(e=>(0,$.jsx)(F,{value:e,children:a[e]},e))})]}),(0,$.jsx)(L,{label:m(`detail.evidence.commit`),name:`commit`,pattern:`[a-fA-F0-9]{40,64}`}),(0,$.jsx)(Se,{label:m(`detail.evidence.note`),name:`note`,maxLength:2e4}),(0,$.jsx)(q,{error:l??o.error,pending:o.isPending,submitLabel:m(`detail.evidence.add`),onCancel:()=>c(!1)})]})}),(0,$.jsx)(D,{error:n.error})]})}var cn=[`open`,`closed`,`merged`,`draft`,`active`,`deleted`];function ln({remoteKind:e,remoteState:t,provider:n}){if(!t)return m(`detail.link.stateUnknown`);let r=cn.find(e=>e===t),i=r?m(`detail.link.remoteState.${r}`):t.charAt(0).toUpperCase()+t.slice(1);return e?m(`detail.link.remote`,{kind:c(e,n),state:i}):i}function un({ticket:e}){let t=B(e.projectId),n=J(C.query(`list_resources`,{projectId:e.projectId,ticketId:e.id})),r=R(`add_resource`),i=R(`update_resource`),a=R(`delete_resource`),[s,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(),p=r.isPending||i.isPending,h=e=>{f(void 0),c(e),u(!0)};return(0,$.jsxs)(`section`,{"aria-label":m(`detail.link.heading`),children:[(0,$.jsx)(V,{compact:!0,title:m(`detail.link.heading`),action:t.canWrite&&(0,$.jsx)(T,{label:m(`detail.link.add`),size:`icon-sm`,onClick:()=>h(),children:(0,$.jsx)(Pe,{})})}),!n.isPending&&!n.data?.length&&(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:m(`detail.link.empty`)}),(0,$.jsx)(Me,{className:`gap-0`,children:n.data?.map(n=>(0,$.jsx)(en,{compact:!0,icon:(0,$.jsx)(rt,{className:`size-4 text-muted-foreground`}),href:n.url,label:n.title||n.url,meta:n.provider?(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,children:n.provider}),(0,$.jsx)(Y,{variant:`outline`,className:n.remoteState?void 0:`text-muted-foreground`,children:ln(n)})]}):n.title&&o(n.url),actions:t.canWrite&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{size:`icon-sm`,label:m(`detail.link.edit`),onClick:()=>h(n),children:(0,$.jsx)(Ue,{})}),(0,$.jsx)(ae,{label:m(`detail.link.remove`),icon:(0,$.jsx)(He,{}),description:m(`detail.resource.removeConfirm`,{name:n.title||n.url}),onConfirm:()=>a.mutateAsync({projectId:e.projectId,resourceId:n.id,expectedVersion:n.version})})]})},n.id))}),(0,$.jsx)(re,{title:m(s?`detail.link.edit`:`detail.link.add`),open:l,onOpenChange:u,busy:p,children:(0,$.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget),a={url:X(n,`url`),title:X(n,`title`)};f(void 0),(s?i.mutateAsync({projectId:e.projectId,resourceId:s.id,expectedVersion:s.version,...a}):r.mutateAsync({projectId:e.projectId,ticketId:e.id,...a})).then(()=>u(!1)).catch(f)},children:[(0,$.jsx)(L,{label:m(`detail.field.url`),name:`url`,type:`url`,required:!0,autoFocus:!0,defaultValue:s?.url}),(0,$.jsx)(L,{label:m(`detail.field.title`),name:`title`,maxLength:200,defaultValue:s?.title}),(0,$.jsx)(q,{error:d,pending:p,submitLabel:m(s?`detail.link.save`:`detail.link.add`),onCancel:()=>u(!1)})]})}),(0,$.jsx)(D,{error:n.error})]})}function dn({ticket:e}){let[t,n]=(0,Q.useState)(0),r=J(C.query(`list_activity`,{projectId:e.projectId,ticketId:e.id,offset:t}));return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{children:m(`detail.section.activity`)}),(0,$.jsx)(D,{error:r.error}),(0,$.jsx)(`ol`,{className:`m-0 list-none p-0`,children:r.data?.items.map(t=>(0,$.jsxs)(`li`,{className:`relative flex flex-col gap-0.5 border-l py-2.5 pl-5 text-xs before:absolute before:top-4 before:-left-[3px] before:size-[5px] before:rounded-full before:bg-muted-foreground/50`,children:[(0,$.jsx)(`span`,{children:d(t)}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,$.jsx)(Ae,{projectId:e.projectId,actorId:t.actorId}),` ·`,` `,(0,$.jsx)(G,{value:t.createdAt})]})]},t.id))}),((r.data?.total??0)>50||t>0)&&(0,$.jsxs)($t,{className:`mt-5 justify-end`,children:[(0,$.jsx)(z,{size:`sm`,disabled:!t,onClick:()=>n(Math.max(0,t-50)),children:m(`detail.activity.previous`)}),(0,$.jsx)(z,{size:`sm`,disabled:t+50>=(r.data?.total??0),onClick:()=>n(t+50),children:m(`detail.activity.next`)})]})]})}var fn=`h-7 max-w-64 min-w-0 border border-transparent px-2 font-normal hover:border-border aria-pressed:border-border aria-pressed:bg-muted`;function pn({projectId:e,ticket:r,initial:i,onSaved:a}){let o=Te(),s=`kanvil:${E().id}:draft:${e}:${r?.id??`new:${i?.parentId??``}`}`,[c,l]=(0,Q.useState)(()=>{let e=ft(r);return i?{...e,fields:{...e.fields,...i}}:e}),[d,f]=(0,Q.useState)(()=>{try{let e=dt.safeParse(JSON.parse(localStorage.getItem(s)??`null`));if(e.success)return e.data}catch{}return c}),h=(0,Q.useRef)(d);function g(e){h.current=e,f(e)}let ee=`kanvil:composer-expanded`,[v,y]=(0,Q.useState)(()=>{try{return localStorage.getItem(ee)===`1`}catch{return!1}});function b(){y(e=>{try{localStorage.setItem(ee,e?`0`:`1`)}catch{}return!e})}let[te,x]=(0,Q.useState)(()=>!!d.fields.acceptanceCriteria),[S,w]=(0,Q.useState)(),[T,O]=(0,Q.useState)(),[k,j]=(0,Q.useState)(!1),[M,F]=(0,Q.useState)(!1),[re,I]=(0,Q.useState)(),ae=R(`create_ticket`),oe=R(`update_ticket`),ce=R(`discard_upload`),ue=Oe(),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(!1),B=(0,Q.useRef)(0),[pe,he]=(0,Q.useState)(!1);function V(e){g(e),I(void 0);try{localStorage.setItem(s,JSON.stringify(e)),O(void 0),j(!0)}catch{O(Error(m(`detail.editor.storageUnavailable`))),j(!1)}}function _e(){try{localStorage.removeItem(s)}catch{}ve(h.current.uploads),g(c),j(!1)}function ve(e){for(let t of e)ce.mutateAsync({projectId:K,uploadId:t}).catch(()=>{})}let U=e=>V({...h.current,fields:{...h.current.fields,...e}}),W=(e,t)=>U({[e]:t}),ye=(e,t)=>W(`customFields`,{...h.current.fields.customFields,[e]:t});async function xe(t){let n=++B.current;V({...h.current,projectId:t===e?void 0:t,fields:{...h.current.fields,parentId:null,stateId:null,customFields:{}}}),he(!0);let r=[];try{r=await ue.ensureQueryData(C.query(`list_members`,{projectId:t}))}finally{if(n===B.current){let e=h.current,{assigneeId:t}=e.fields;t&&!r.some(e=>e.userId===t)&&V({...e,fields:{...e.fields,assigneeId:null}}),he(!1)}}}let G=d.fields,K=d.projectId??e,Ce=!!r&&d.version!==r.version,we=JSON.stringify(d.fields)!==JSON.stringify(c.fields)||d.projectId!==c.projectId,q=ae.isPending||oe.isPending,J=q||Ce||pe,Y=G.automationReady||G.scopes.length>0||!!G.holdReason,De=rn(K,r?{ticketId:r.id}:{onStaged:e=>V({...h.current,uploads:[...h.current.uploads,e]})});async function ke(t){if(t.preventDefault(),J||fe.current)return;let n=Ye(G),i=d.uploads.filter(e=>G.description.includes(e)||G.acceptanceCriteria.includes(e));fe.current=!0,o?.(!0);try{let t=r?await oe.mutateAsync({projectId:e,ticketId:r.id,expectedVersion:d.version??r.version,changes:n}):await ae.mutateAsync({projectId:K,...n,uploads:i}).catch(e=>{throw Ae(e),e});r||ve(d.uploads.filter(e=>!i.includes(e)));try{localStorage.removeItem(s)}catch{}if(r||!M)return N.success(m(r?`detail.editor.saved`:`detail.editor.created`,{key:t.key})),a(t);let o=h.current.fields,c=e=>o[e]===G[e]?``:o[e],u={...h.current,uploads:h.current.uploads.filter(e=>!d.uploads.includes(e)),fields:{...o,title:c(`title`),description:c(`description`),acceptanceCriteria:c(`acceptanceCriteria`)}};l({...u,fields:{...u.fields,title:``,description:``,acceptanceCriteria:``}}),u.fields.title||u.fields.description||u.fields.acceptanceCriteria?V(u):(g(u),j(!1)),x(!!u.fields.acceptanceCriteria),I(t.key),de.current?.focus()}finally{fe.current=!1,o?.(!1)}}function Ae(e){let r=e instanceof p&&u({uploads:n(t())}).safeParse(e.details).data?.uploads;r&&V({...h.current,uploads:h.current.uploads.filter(e=>!r.includes(e))})}let je=q||d.uploads.length>0,Me=(0,$.jsxs)(`div`,{className:`-mt-3 flex flex-wrap items-center gap-1`,"aria-label":m(`detail.editor.properties`),children:[!r&&(0,$.jsx)($e,{value:K,disabled:je,onChange:e=>void xe(e).catch(Ee)}),(0,$.jsx)(Z,{property:`status`,projectId:K,value:it(G),onChange:e=>U(ut(e))}),(0,$.jsx)(Z,{property:`priority`,projectId:K,value:G.priority,onChange:e=>W(`priority`,e)}),(0,$.jsx)(Z,{property:`assignee`,projectId:K,value:G.assigneeId,onChange:e=>W(`assigneeId`,e)}),(0,$.jsx)(Z,{property:`kind`,projectId:K,value:G.kind,onChange:e=>W(`kind`,e)}),(0,$.jsx)(Z,{property:`difficulty`,projectId:K,value:G.difficulty,onChange:e=>W(`difficulty`,e)}),(0,$.jsx)(at,{value:G.labels,onChange:e=>W(`labels`,e)}),(0,$.jsx)(st,{variant:`pill`,value:G,onChange:U}),(0,$.jsx)(Ze,{variant:`pill`,projectId:K,values:G.customFields,isNew:!r,onChange:ye}),(0,$.jsx)(Zt,{variant:`pill`,label:m(`detail.field.parentTicket`),placeholder:m(`detail.field.parent`),projectId:K,value:G.parentId,onChange:e=>W(`parentId`,e),exclude:r?[r.id]:[]}),(0,$.jsxs)(nt,{size:`sm`,className:H(fn,`gap-1.5`),pressed:G.automationReady,onPressedChange:e=>W(`automationReady`,e),"aria-label":m(`detail.editor.readyForAgents`),title:m(`detail.editor.readyForAgentsHelp`),children:[(0,$.jsx)(St,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),G.automationReady?m(`detail.editor.readyForAgents`):m(`detail.editor.agents`)]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(ne,{render:(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,className:H(`size-7 border border-transparent hover:border-border`,Y&&`text-primary`),"aria-label":m(`detail.editor.moreProperties`)}),children:(0,$.jsx)(Ke,{className:`size-3.5`})}),(0,$.jsxs)(P,{align:`start`,className:`w-[min(24rem,calc(100vw-2rem))] p-4`,children:[(0,$.jsx)(Qe,{label:m(`detail.field.scopes`),kind:`scope`,value:G.scopes,onChange:e=>W(`scopes`,e)}),(0,$.jsx)(L,{label:m(`detail.field.holdReason`),value:G.holdReason??``,maxLength:2e3,placeholder:m(`detail.editor.holdPlaceholder`),onChange:e=>W(`holdReason`,e.target.value||null)}),(0,$.jsx)(`p`,{className:`mb-0 text-xs text-muted-foreground`,children:m(`detail.editor.claimsNote`)})]})]})]}),Pe=(0,$.jsxs)(`form`,{onSubmit:e=>{w(void 0),ke(e).catch(w)},onKeyDown:Je,className:`ticket-composer flex min-h-0 flex-1 flex-col`,"data-expanded":v,children:[(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-11 hidden sm:inline-flex`,"aria-label":m(v?`detail.editor.restoreSize`:`detail.editor.expand`),"aria-pressed":v,disabled:q,onClick:b,children:v?(0,$.jsx)(Pt,{}):(0,$.jsx)(pt,{})}),(0,$.jsxs)(`div`,{className:H(`min-h-0 flex-1 overflow-y-auto overscroll-contain`,v&&`lg:grid lg:grid-cols-[minmax(0,1fr)_320px] lg:items-start`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-4 px-5 py-5 sm:px-8`,children:[Ce&&(0,$.jsxs)(be,{className:`w-auto`,children:[(0,$.jsx)(gt,{}),(0,$.jsx)(me,{children:m(`detail.editor.staleTitle`)}),(0,$.jsxs)(ge,{children:[m(`detail.editor.staleDescription`,{version:d.version}),(0,$.jsx)(z,{size:`sm`,className:`mt-2`,onClick:()=>V(ft(r)),children:m(`detail.editor.discardAndReload`)})]})]}),(0,$.jsx)(D,{error:S??ae.error??oe.error??T}),(0,$.jsx)(`div`,{className:`[&_[data-slot=field-label]]:sr-only`,children:(0,$.jsx)(Se,{label:m(`detail.field.title`),rows:1,value:G.title,onChange:e=>W(`title`,e.target.value),required:!0,maxLength:500,autoFocus:!0,ref:de,placeholder:m(`detail.editor.titlePlaceholder`),className:`field-sizing-content min-h-10 resize-none border-0 bg-transparent px-0 py-1 text-xl! font-semibold leading-snug shadow-none caret-primary focus-visible:ring-0 dark:bg-transparent`})}),!v&&Me,(0,$.jsx)(Xt,{label:m(`detail.field.description`),value:G.description,onChange:e=>W(`description`,e),rows:8,variant:`document`,placeholder:m(`detail.editor.descriptionPlaceholder`),onUpload:De}),te?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Xt,{label:m(`detail.field.acceptanceCriteria`),value:G.acceptanceCriteria,onChange:e=>W(`acceptanceCriteria`,e),rows:4,variant:`document`,maxLength:5e4,placeholder:m(`detail.editor.criteriaPlaceholder`),onUpload:De}),!G.acceptanceCriteria&&(0,$.jsx)(z,{variant:`ghost`,size:`icon-xs`,className:`absolute top-5 right-24 text-muted-foreground`,"aria-label":m(`detail.editor.removeCriteria`),onClick:()=>x(!1),children:(0,$.jsx)(_,{})})]}):(0,$.jsxs)(z,{variant:`ghost`,size:`sm`,className:`w-fit text-muted-foreground`,onClick:()=>x(!0),children:[(0,$.jsx)(_t,{}),m(`detail.editor.addCriteria`)]})]}),v&&(0,$.jsxs)(`aside`,{className:`border-t bg-muted/20 p-5 lg:sticky lg:top-0 lg:min-h-full lg:border-t-0 lg:border-l`,"aria-label":m(`detail.editor.properties`),children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[!r&&(0,$.jsx)($e,{variant:`row`,value:K,disabled:je,onChange:e=>void xe(e).catch(Ee)}),(0,$.jsx)(Z,{variant:`row`,property:`status`,projectId:K,value:it(G),onChange:e=>U(ut(e))}),(0,$.jsx)(Z,{variant:`row`,property:`priority`,projectId:K,value:G.priority,onChange:e=>W(`priority`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`assignee`,projectId:K,value:G.assigneeId,onChange:e=>W(`assigneeId`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`kind`,projectId:K,value:G.kind,onChange:e=>W(`kind`,e)}),(0,$.jsx)(Z,{variant:`row`,property:`difficulty`,projectId:K,value:G.difficulty,onChange:e=>W(`difficulty`,e)}),(0,$.jsx)(st,{variant:`row`,value:G,onChange:U}),(0,$.jsx)(Ze,{variant:`row`,projectId:K,values:G.customFields,isNew:!r,onChange:ye}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[80px_minmax(0,1fr)] items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`detail.editor.agents`)}),(0,$.jsxs)(nt,{size:`sm`,className:H(fn,`h-7 justify-start gap-1.5`),pressed:G.automationReady,onPressedChange:e=>W(`automationReady`,e),"aria-label":m(`detail.editor.readyForAgents`),children:[(0,$.jsx)(St,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),G.automationReady?m(`detail.editor.readyForAgents`):m(`detail.editor.notReady`)]})]})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t pt-5`,children:[(0,$.jsx)(Qe,{label:m(`detail.field.labels`),value:G.labels,onChange:e=>W(`labels`,e)}),(0,$.jsx)(Zt,{label:m(`detail.field.parentTicket`),projectId:K,value:G.parentId,onChange:e=>W(`parentId`,e),exclude:r?[r.id]:[]}),(0,$.jsx)(Qe,{label:m(`detail.field.scopes`),kind:`scope`,value:G.scopes,onChange:e=>W(`scopes`,e)}),(0,$.jsx)(L,{label:m(`detail.field.holdReason`),value:G.holdReason??``,maxLength:2e3,placeholder:m(`detail.editor.holdPlaceholder`),onChange:e=>W(`holdReason`,e.target.value||null)})]})]})]}),(0,$.jsxs)(`footer`,{className:`z-10 flex shrink-0 flex-wrap items-center justify-between gap-3 border-t bg-muted/40 px-5 py-3`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,role:`status`,children:[re?m(`detail.editor.created`,{key:re}):k?m(`detail.editor.savedLocally`):T?m(`detail.editor.notSavedLocally`):``,we&&!Ce&&(0,$.jsxs)(z,{variant:`ghost`,size:`xs`,disabled:q,onClick:_e,children:[(0,$.jsx)(Ge,{}),m(`detail.editor.discardDraft`)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!r&&(0,$.jsxs)(`label`,{className:`mr-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(vt,{size:`sm`,checked:M,disabled:q,onCheckedChange:F}),m(`detail.editor.createMore`)]}),(0,$.jsx)(ie,{render:(0,$.jsx)(z,{disabled:q}),children:m(`common.action.cancel`)}),(0,$.jsxs)(z,{type:`submit`,variant:`default`,disabled:J,children:[q?(0,$.jsx)(le,{}):null,m(q?`common.state.saving`:r?`detail.editor.save`:`detail.editor.create`),!q&&(0,$.jsx)(se,{"aria-hidden":`true`,className:`ml-1 hidden border-transparent bg-primary-foreground/20 text-primary-foreground shadow-none sm:inline-flex`,children:`⌘↵`})]})]})]})]});return(0,$.jsx)(Ne,{projectId:K,children:Pe})}export{pn as TicketEditor,It as _,rn as a,Jt as c,Yt as d,Bt as f,Gt as g,qt as h,un as i,Xt as l,Ut as m,an as n,$t as o,Ht as p,sn as r,Zt as s,dn as t,Kt as u};