@tinyrack/issuary-server 0.29.3 → 0.30.0

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 (199) hide show
  1. package/dist/entities/oauth-client.entity.d.ts +6 -6
  2. package/dist/entities/oauth-code.entity.d.ts +6 -6
  3. package/dist/entities/oauth-device-code.entity.d.ts +6 -6
  4. package/dist/entities/revoked-token.entity.d.ts +6 -6
  5. package/dist/entities/terms-content.entity.d.ts +3 -3
  6. package/dist/entities/terms.entity.d.ts +3 -3
  7. package/dist/entities/user-consent.entity.d.ts +6 -6
  8. package/dist/entities/user-passkey.entity.d.ts +4 -4
  9. package/dist/entities/user-passkey.entity.d.ts.map +1 -1
  10. package/dist/entities/user-passkey.entity.js.map +1 -1
  11. package/dist/entities/user-terms-consent.entity.d.ts +3 -3
  12. package/dist/entities/user-totp-recovery-code.entity.d.ts +3 -3
  13. package/dist/entities/user-totp.entity.d.ts +3 -3
  14. package/dist/entities/user.entity.d.ts +3 -3
  15. package/dist/entrypoints/app.d.ts +252 -4
  16. package/dist/entrypoints/app.d.ts.map +1 -1
  17. package/dist/entrypoints/database/postgres/compiled-functions.js +1 -1
  18. package/dist/entrypoints/database/postgres/compiled-functions.js.map +1 -1
  19. package/dist/entrypoints/database/sqlite/compiled-functions.js +1 -1
  20. package/dist/entrypoints/database/sqlite/compiled-functions.js.map +1 -1
  21. package/dist/repositories/user-passkey.repository.d.ts +3 -3
  22. package/dist/repositories/user-totp-recovery-code.repository.d.ts +2 -2
  23. package/dist/repositories/user-totp.repository.d.ts +3 -3
  24. package/dist/routes/api/auth/accounts/remove.post.d.ts +5 -5
  25. package/dist/routes/api/auth/index.d.ts +126 -2
  26. package/dist/routes/api/auth/index.d.ts.map +1 -1
  27. package/dist/routes/api/auth/passkey/options/post.d.ts +126 -2
  28. package/dist/routes/api/auth/passkey/options/post.d.ts.map +1 -1
  29. package/dist/routes/api/index.d.ts +252 -4
  30. package/dist/routes/api/index.d.ts.map +1 -1
  31. package/dist/routes/api/user/index.d.ts +126 -2
  32. package/dist/routes/api/user/index.d.ts.map +1 -1
  33. package/dist/routes/api/user/passkeys/register/options/post.d.ts +126 -2
  34. package/dist/routes/api/user/passkeys/register/options/post.d.ts.map +1 -1
  35. package/dist/routes/index.d.ts +272 -24
  36. package/dist/routes/index.d.ts.map +1 -1
  37. package/dist/routes/oauth/index.d.ts +9 -9
  38. package/dist/services/passkey.service.d.ts.map +1 -1
  39. package/dist/services/passkey.service.js +8 -1
  40. package/dist/services/passkey.service.js.map +1 -1
  41. package/frontend/client/assets/{CompositeItem-VmYWaHnv.js → CompositeItem-JwkStZhq.js} +1 -1
  42. package/frontend/client/assets/{FieldControl-D6zWw018.js → FieldControl-CwHXFt7p.js} +1 -1
  43. package/frontend/client/assets/{FieldItemContext-CPjig163.js → FieldItemContext-B3N2qWH8.js} +1 -1
  44. package/frontend/client/assets/{HydrationBoundary-CGOTaz3j.js → HydrationBoundary-C71PwQKm.js} +1 -1
  45. package/frontend/client/assets/{NullStore-BxU9yW8l.js → NullStore-UyCsFQfz.js} +1 -1
  46. package/frontend/client/assets/{Separator-eMrsmRws.js → Separator-Bu_799IG.js} +1 -1
  47. package/frontend/client/assets/{admin-console-BVGtfvzy.js → admin-console-Ej5TUkij.js} +1 -1
  48. package/frontend/client/assets/{admin-users-notice-DcKE5B43.js → admin-users-notice-D3rf-k5S.js} +1 -1
  49. package/frontend/client/assets/{alert-B9BFeQs3.js → alert-BIM0hnda.js} +1 -1
  50. package/frontend/client/assets/{alert-CFUBsmUN.js → alert-DS8e0Gvg.js} +1 -1
  51. package/frontend/client/assets/api-CfCwvXbU.js +1 -0
  52. package/frontend/client/assets/auth-choice-row-DNB3B1Vs.js +1 -0
  53. package/frontend/client/assets/auth-field-CDCz-y27.js +1 -0
  54. package/frontend/client/assets/{auth-footer-DgRsLHyD.js → auth-footer-LG_gGuJv.js} +1 -1
  55. package/frontend/client/assets/{auth-layout-CFKu8bHI.js → auth-layout-B4h13HhN.js} +1 -1
  56. package/frontend/client/assets/{auth-outcome-B7tCCKZC.js → auth-outcome-DyY0JgWG.js} +1 -1
  57. package/frontend/client/assets/{auth-page-header-D5Z-EA6V.js → auth-page-header-BVY4zRzF.js} +1 -1
  58. package/frontend/client/assets/authorization-context-banner-az4f8FCY.js +1 -0
  59. package/frontend/client/assets/{avatar-BacTFLjX.js → avatar-DupqO5iP.js} +1 -1
  60. package/frontend/client/assets/badge-Cr0iG_iG.js +1 -0
  61. package/frontend/client/assets/{card-CTv8DubK.js → card-BaQElRNE.js} +1 -1
  62. package/frontend/client/assets/checkbox-BymOAmaw.js +1 -0
  63. package/frontend/client/assets/circle-alert-BZCKPkRn.js +1 -0
  64. package/frontend/client/assets/circle-check-BW_XcUlv.js +1 -0
  65. package/frontend/client/assets/code-Dc5QnXCh.js +1 -0
  66. package/frontend/client/assets/components-DF4L3dSB.js +1 -0
  67. package/frontend/client/assets/{entry.client-wT_SpBr6.js → entry.client-DVFGkhCN.js} +1 -1
  68. package/frontend/client/assets/{errorBoundaries-BmdAyh9C.js → errorBoundaries-C_UC4h4T.js} +2 -2
  69. package/frontend/client/assets/field-Du5xBKGW.js +2 -0
  70. package/frontend/client/assets/fingerprint-pattern-AUfgwio5.js +1 -0
  71. package/frontend/client/assets/i18n-CMepi_uj.js +1 -0
  72. package/frontend/client/assets/{initial-avatar-D4aPMV9z.js → initial-avatar-ByHiX-IF.js} +1 -1
  73. package/frontend/client/assets/{input-BFJdEx8B.js → input-Dyj4-3JM.js} +1 -1
  74. package/frontend/client/assets/{jsx-runtime-BFZ_fnNJ.js → jsx-runtime-B-57GDDH.js} +1 -1
  75. package/frontend/client/assets/key-round-BlUAV-K9.js +1 -0
  76. package/frontend/client/assets/{labeled-separator-DkexQjxp.js → labeled-separator-JGa2pO6H.js} +1 -1
  77. package/frontend/client/assets/language-selector-Chn-k7Pw.js +1 -0
  78. package/frontend/client/assets/{link-DcBltZGP.js → link-Dsq51NsW.js} +1 -1
  79. package/frontend/client/assets/{link-button-qvSTUE1n.js → link-button-DGt9hwk7.js} +1 -1
  80. package/frontend/client/assets/lock-Cr_egoXD.js +1 -0
  81. package/frontend/client/assets/logout-DpMjBzc5.js +1 -0
  82. package/frontend/client/assets/mail-B2PK2vlI.js +1 -0
  83. package/frontend/client/assets/manifest-8c4a603f.js +1 -0
  84. package/frontend/client/assets/{modal-LoTH9Ttl.js → modal-BDu41alh.js} +1 -1
  85. package/frontend/client/assets/{mutation-C0KT2UXZ.js → mutation-DMG1qWFd.js} +1 -1
  86. package/frontend/client/assets/{oauth-search-BtLPTIS7.js → oauth-search-DybZ6VWp.js} +1 -1
  87. package/frontend/client/assets/passkey-CWcdr7Vy.js +1 -0
  88. package/frontend/client/assets/{passkey-error-CZnhXTc7.js → passkey-error-C3DrncLi.js} +1 -1
  89. package/frontend/client/assets/{password-reset-BuDycpfY.js → password-reset-BhkJhVQ4.js} +1 -1
  90. package/frontend/client/assets/{password-strength-DLtV7dBZ.js → password-strength-B1w3RCA1.js} +1 -1
  91. package/frontend/client/assets/{pin-input-DtemAOnm.js → pin-input-DiWLndxH.js} +1 -1
  92. package/frontend/client/assets/{progress-xdWpxn2G.js → progress-vGb7EZn1.js} +1 -1
  93. package/frontend/client/assets/promise-EbDcmV0j.js +1 -0
  94. package/frontend/client/assets/provider-mark-CCOkSxh7.js +1 -0
  95. package/frontend/client/assets/{react-dom-BxmrrPTH.js → react-dom-oT9-I0GD.js} +1 -1
  96. package/frontend/client/assets/{root-DTCHNfT8.js → root-C2SlHCkE.js} +1 -1
  97. package/frontend/client/assets/route-3IIrVTOK.js +1 -0
  98. package/frontend/client/assets/route-3gQ9Nsqa.js +1 -0
  99. package/frontend/client/assets/route-9FLiqn21.js +4 -0
  100. package/frontend/client/assets/route-BFU8OK2a.js +1 -0
  101. package/frontend/client/assets/{route-ID67gqvy.js → route-BKFb9RYA.js} +1 -1
  102. package/frontend/client/assets/{route-DHEnEwHa.js → route-BKI6LDOW.js} +1 -1
  103. package/frontend/client/assets/{route-CsT5EJEh.js → route-BUM2hTU8.js} +1 -1
  104. package/frontend/client/assets/{route-Cvob9_0Q.js → route-BYWFA1fQ.js} +1 -1
  105. package/frontend/client/assets/{route-Ceht21dJ.js → route-C4_l_qs9.js} +1 -1
  106. package/frontend/client/assets/{route-DlKXugZV.js → route-CkpB3-_U.js} +1 -1
  107. package/frontend/client/assets/{route-Caw4ohFV.js → route-CrswLAAa.js} +1 -1
  108. package/frontend/client/assets/{route-DLNoCW7x.js → route-CusK9Y2K.js} +1 -1
  109. package/frontend/client/assets/{route-CkS9fAlL.js → route-D9Y1oCUO.js} +1 -1
  110. package/frontend/client/assets/{route-DCfkikii.js → route-DEVG2czp.js} +1 -1
  111. package/frontend/client/assets/route-DFwqLWT0.js +1 -0
  112. package/frontend/client/assets/route-DH6kQz8L.js +1 -0
  113. package/frontend/client/assets/route-DO38I3ML.js +1 -0
  114. package/frontend/client/assets/{route-DVMfGHhl.js → route-DQpLeFuG.js} +1 -1
  115. package/frontend/client/assets/{route-_DMD2pp1.js → route-DSD60oyb.js} +1 -1
  116. package/frontend/client/assets/route-DjCJn53Y.js +1 -0
  117. package/frontend/client/assets/route-E-_SSP-x.js +1 -0
  118. package/frontend/client/assets/{route-R-BJj3-W.js → route-J9z_OG4L.js} +1 -1
  119. package/frontend/client/assets/{route-xuoylbDO.js → route-LjqDZz5f.js} +1 -1
  120. package/frontend/client/assets/{route-Bx9hz_OF.js → route-N586tYcn.js} +1 -1
  121. package/frontend/client/assets/route-bKG0wKRh.js +1 -0
  122. package/frontend/client/assets/{route-error-fallback-C2OHu3JW.js → route-error-fallback-CRL2Et8O.js} +1 -1
  123. package/frontend/client/assets/{route-module-Bm4sHkx9.js → route-module-2foR49uh.js} +1 -1
  124. package/frontend/client/assets/{route-C9TWgUZf.js → route-nHjY3_n0.js} +1 -1
  125. package/frontend/client/assets/route-sHm4cfOd.js +1 -0
  126. package/frontend/client/assets/{sanitized-rich-text-nFi_4i6F.js → sanitized-rich-text-uZcpKo6H.js} +1 -1
  127. package/frontend/client/assets/{schemas-Dxi9xZo6.js → schemas-B87iTMww.js} +2 -2
  128. package/frontend/client/assets/search-QwZZIij9.js +1 -0
  129. package/frontend/client/assets/select-C_WHBpl_.js +1 -0
  130. package/frontend/client/assets/separator-nIgnJSXV.js +1 -0
  131. package/frontend/client/assets/shell-header-bar-Bg85QIAq.js +1 -0
  132. package/frontend/client/assets/shield-check-2DKLuF9J.js +1 -0
  133. package/frontend/client/assets/{standard-schema-C8Td_miB.js → standard-schema-kM5DbC12.js} +1 -1
  134. package/frontend/client/assets/{table-D2oRcUKc.js → table-BpQCtRY7.js} +1 -1
  135. package/frontend/client/assets/{terms-BReb6uEz.js → terms-DV0oDTRf.js} +1 -1
  136. package/frontend/client/assets/text-CBHShrvS.js +1 -0
  137. package/frontend/client/assets/{toast-_zV1SGz6.js → toast-XXVYYXim.js} +1 -1
  138. package/frontend/client/assets/{totp-BW4BoCpi.js → totp-4989Pb-o.js} +1 -1
  139. package/frontend/client/assets/trash-C7RyeTUJ.js +1 -0
  140. package/frontend/client/assets/triangle-alert-B0lTzZDi.js +1 -0
  141. package/frontend/client/assets/use-admin-selection-i-WvRvvB.js +1 -0
  142. package/frontend/client/assets/use-totp-setup-D7XZ6Nos.js +2 -0
  143. package/frontend/client/assets/{useAriaLabelledBy-CYSspZIu.js → useAriaLabelledBy-CQ_H8SUl.js} +1 -1
  144. package/frontend/client/assets/{useMutation-C4CmK9Sb.js → useMutation-BkuKGzks.js} +1 -1
  145. package/frontend/client/assets/usePositioner-CrQOY-iw.js +1 -0
  146. package/frontend/client/assets/useQuery-BLm0XsTI.js +1 -0
  147. package/frontend/client/assets/useRender-DSFiJ2Vm.js +1 -0
  148. package/frontend/server/assets/{hydration-yaDCGSA8.js → hydration-Cvbp7-6s.js} +1 -1
  149. package/frontend/server/assets/{root-loader.server-Cwm-l9OS.js → root-loader.server-DaTcVcNU.js} +3 -3
  150. package/frontend/server/assets/{route-runtime.server-CjDbp5w6.js → route-runtime.server-CEa264cW.js} +1 -1
  151. package/frontend/server/assets/{session-CSnQWUgx.js → session-QqvIIQ6R.js} +13 -13
  152. package/frontend/server/index.js +2200 -1697
  153. package/package.json +18 -18
  154. package/frontend/client/assets/api-0SzZx6X7.js +0 -1
  155. package/frontend/client/assets/auth-choice-row-DBHleTc9.js +0 -1
  156. package/frontend/client/assets/auth-field-1EM9pnWe.js +0 -1
  157. package/frontend/client/assets/authorization-context-banner-Cqtzj9A1.js +0 -1
  158. package/frontend/client/assets/badge-BCQspax5.js +0 -1
  159. package/frontend/client/assets/checkbox-OA4CFk-6.js +0 -1
  160. package/frontend/client/assets/circle-alert-DGTJ9B9k.js +0 -1
  161. package/frontend/client/assets/circle-check-CGasu2tI.js +0 -1
  162. package/frontend/client/assets/code-RrwtZcA2.js +0 -1
  163. package/frontend/client/assets/components-C1SipCbb.js +0 -1
  164. package/frontend/client/assets/field-DzNLNMM0.js +0 -2
  165. package/frontend/client/assets/fingerprint-pattern-V_eTEvnZ.js +0 -1
  166. package/frontend/client/assets/i18n-BY3irWek.js +0 -1
  167. package/frontend/client/assets/key-round-DgCbGqQL.js +0 -1
  168. package/frontend/client/assets/language-selector-CGXk9vW_.js +0 -1
  169. package/frontend/client/assets/lock-m97gMmUy.js +0 -1
  170. package/frontend/client/assets/logout-CBTnIosZ.js +0 -1
  171. package/frontend/client/assets/mail-tgQpWyoC.js +0 -1
  172. package/frontend/client/assets/manifest-9217f574.js +0 -1
  173. package/frontend/client/assets/passkey-C9bzur2Z.js +0 -1
  174. package/frontend/client/assets/promise-CFWkfv2A.js +0 -1
  175. package/frontend/client/assets/provider-mark-B05f08GZ.js +0 -1
  176. package/frontend/client/assets/route-48mZ_bkD.js +0 -1
  177. package/frontend/client/assets/route-9i9rqQdx.js +0 -4
  178. package/frontend/client/assets/route-Bc48Eq7F.js +0 -1
  179. package/frontend/client/assets/route-C5Pe2AZT.js +0 -1
  180. package/frontend/client/assets/route-CBjporWj.js +0 -1
  181. package/frontend/client/assets/route-CLo3eo-R.js +0 -1
  182. package/frontend/client/assets/route-CPIXY7eE.js +0 -1
  183. package/frontend/client/assets/route-D-ycfUyo.js +0 -1
  184. package/frontend/client/assets/route-DokK6Iod.js +0 -1
  185. package/frontend/client/assets/route-OWWRYmAT.js +0 -1
  186. package/frontend/client/assets/route-goGP2kXu.js +0 -1
  187. package/frontend/client/assets/search-DSkOjYwI.js +0 -1
  188. package/frontend/client/assets/select--ltVnlVl.js +0 -1
  189. package/frontend/client/assets/separator-C5dnwYaA.js +0 -1
  190. package/frontend/client/assets/shell-header-bar-C3KYib1D.js +0 -1
  191. package/frontend/client/assets/shield-check-93-WFkyJ.js +0 -1
  192. package/frontend/client/assets/text-CGN4ZtUZ.js +0 -1
  193. package/frontend/client/assets/trash-2-BOsxjkzU.js +0 -1
  194. package/frontend/client/assets/triangle-alert-DSSurAZ_.js +0 -1
  195. package/frontend/client/assets/use-admin-selection-CAegSKw5.js +0 -1
  196. package/frontend/client/assets/use-totp-setup-BOSkSnYG.js +0 -2
  197. package/frontend/client/assets/usePositioner-DcBnB2-O.js +0 -1
  198. package/frontend/client/assets/useQuery-BtUeFnRt.js +0 -1
  199. package/frontend/client/assets/useRender-BF5_Ad3C.js +0 -1
@@ -1 +1 @@
1
- import{a as e}from"./components-C1SipCbb.js";import{t}from"./jsx-runtime-BFZ_fnNJ.js";import{a as n}from"./api-0SzZx6X7.js";import{t as r}from"./text-CGN4ZtUZ.js";import{B as i,t as a,z as o}from"./select--ltVnlVl.js";import{s}from"./i18n-BY3irWek.js";import{t as c}from"./language-selector-CGXk9vW_.js";import{n as l}from"./route-module-Bm4sHkx9.js";var u=t();function d(){let{t:e}=n(),{colorScheme:t,setColorScheme:l}=s(),d=[[`light`,e(`common.theme.light`)],[`dark`,e(`common.theme.dark`)]];return(0,u.jsxs)(`div`,{className:`mx-auto flex w-full max-w-tinyrack-measure-xl flex-col gap-tinyrack-2xl`,children:[(0,u.jsxs)(`header`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h1`,variant:`headingMd`,weight:`heading`,children:e(`admin.settings.title`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.description`)})]}),(0,u.jsxs)(`section`,{className:`grid items-start gap-tinyrack-md sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h2`,variant:`headingSm`,children:e(`admin.settings.language`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.languageDescription`)})]}),(0,u.jsx)(c,{alwaysVisible:!0,className:`w-full sm:justify-self-end`,presentation:`field`,triggerClassName:`w-full min-w-full`,uiSize:`md`})]}),(0,u.jsxs)(`section`,{className:`grid items-start gap-tinyrack-md sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h2`,variant:`headingSm`,children:e(`admin.settings.theme`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.themeDescription`)})]}),(0,u.jsxs)(a.Root,{onValueChange:e=>{(e===`light`||e===`dark`)&&l(e)},value:t,children:[(0,u.jsxs)(a.Trigger,{appearance:`solid`,"aria-label":e(`admin.settings.theme`),className:`w-full sm:justify-self-end`,uiSize:`md`,children:[(0,u.jsx)(a.Value,{children:d.find(([e])=>e===t)?.[1]}),(0,u.jsx)(a.Icon,{children:(0,u.jsx)(o,{"aria-hidden":!0})})]}),(0,u.jsx)(a.Portal,{children:(0,u.jsx)(a.Positioner,{children:(0,u.jsx)(a.Popup,{children:(0,u.jsx)(a.List,{children:d.map(([e,t])=>(0,u.jsxs)(a.Item,{value:e,children:[(0,u.jsx)(a.ItemText,{children:t}),(0,u.jsx)(a.ItemIndicator,{children:(0,u.jsx)(i,{"aria-hidden":!0})})]},e))})})})})]})]})]})}var f=e(function({loaderData:e}){return(0,u.jsx)(l,{state:e.dehydratedState,children:(0,u.jsx)(d,{})})});export{f as default};
1
+ import{a as e}from"./components-DF4L3dSB.js";import{t}from"./jsx-runtime-B-57GDDH.js";import{a as n}from"./api-CfCwvXbU.js";import{t as r}from"./text-CBHShrvS.js";import{B as i,t as a,z as o}from"./select-C_WHBpl_.js";import{s}from"./i18n-CMepi_uj.js";import{t as c}from"./language-selector-Chn-k7Pw.js";import{n as l}from"./route-module-2foR49uh.js";var u=t();function d(){let{t:e}=n(),{colorScheme:t,setColorScheme:l}=s(),d=[[`light`,e(`common.theme.light`)],[`dark`,e(`common.theme.dark`)]];return(0,u.jsxs)(`div`,{className:`mx-auto flex w-full max-w-tinyrack-measure-xl flex-col gap-tinyrack-2xl`,children:[(0,u.jsxs)(`header`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h1`,variant:`headingMd`,weight:`heading`,children:e(`admin.settings.title`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.description`)})]}),(0,u.jsxs)(`section`,{className:`grid items-start gap-tinyrack-md sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h2`,variant:`headingSm`,children:e(`admin.settings.language`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.languageDescription`)})]}),(0,u.jsx)(c,{alwaysVisible:!0,className:`w-full sm:justify-self-end`,presentation:`field`,triggerClassName:`w-full min-w-full`,uiSize:`md`})]}),(0,u.jsxs)(`section`,{className:`grid items-start gap-tinyrack-md sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h2`,variant:`headingSm`,children:e(`admin.settings.theme`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.themeDescription`)})]}),(0,u.jsxs)(a.Root,{onValueChange:e=>{(e===`light`||e===`dark`)&&l(e)},value:t,children:[(0,u.jsxs)(a.Trigger,{appearance:`solid`,"aria-label":e(`admin.settings.theme`),className:`w-full sm:justify-self-end`,uiSize:`md`,children:[(0,u.jsx)(a.Value,{children:d.find(([e])=>e===t)?.[1]}),(0,u.jsx)(a.Icon,{children:(0,u.jsx)(o,{"aria-hidden":!0})})]}),(0,u.jsx)(a.Portal,{children:(0,u.jsx)(a.Positioner,{children:(0,u.jsx)(a.Popup,{children:(0,u.jsx)(a.List,{children:d.map(([e,t])=>(0,u.jsxs)(a.Item,{value:e,children:[(0,u.jsx)(a.ItemText,{children:t}),(0,u.jsx)(a.ItemIndicator,{children:(0,u.jsx)(i,{"aria-hidden":!0})})]},e))})})})})]})]})]})}var f=e(function({loaderData:e}){return(0,u.jsx)(l,{state:e.dehydratedState,children:(0,u.jsx)(d,{})})});export{f as default};
@@ -1 +1 @@
1
- import{a as e}from"./components-C1SipCbb.js";import{t}from"./jsx-runtime-BFZ_fnNJ.js";import{a as n}from"./api-0SzZx6X7.js";import{r,t as i}from"./text-CGN4ZtUZ.js";import{t as a}from"./badge-BCQspax5.js";import{n as o}from"./route-module-Bm4sHkx9.js";import{n as s}from"./admin-console-BVGtfvzy.js";import{t as c}from"./table-D2oRcUKc.js";var l=t();function u(){let{t:e}=n(),{data:t}=r(s),o=[[`admin.overview.activeUsers`,t.metrics.active_users],[`admin.overview.admins`,t.metrics.admins],[`admin.overview.activeClients`,t.metrics.active_clients],[`admin.overview.requiredTerms`,t.metrics.required_terms]];return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`grid grid-cols-2 bg-tinyrack-surface lg:grid-cols-4`,children:o.map(([t,n])=>(0,l.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs px-tinyrack-lg py-tinyrack-md`,children:[(0,l.jsx)(i,{color:`muted`,variant:`label`,children:e(String(t))}),(0,l.jsx)(i,{as:`p`,variant:`headingLg`,children:n})]},t))}),(0,l.jsxs)(`div`,{className:`grid gap-tinyrack-lg xl:grid-cols-2`,children:[(0,l.jsx)(d,{rows:[[e(`admin.source.config`),t.users.source.config],[e(`admin.source.database`),t.users.source.database]],title:e(`admin.overview.userSource`)}),(0,l.jsx)(d,{rows:[[e(`admin.overview.emailVerified`),t.users.authentication.email_verified],[e(`admin.overview.twoFactor`),t.users.authentication.two_factor],[e(`admin.overview.unverified`),t.users.authentication.remaining]],title:e(`admin.overview.authentication`)})]}),(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`header`,{className:`bg-tinyrack-surface px-tinyrack-lg py-tinyrack-md`,children:(0,l.jsx)(i,{as:`h2`,variant:`headingSm`,children:e(`admin.overview.serviceStatus`)})}),(0,l.jsx)(c.Root,{density:`compact`,children:(0,l.jsx)(c.Body,{children:Object.entries(t.status).map(([t,n])=>(0,l.jsxs)(c.Row,{children:[(0,l.jsx)(c.Cell,{children:e(`admin.status.${t}`)}),(0,l.jsx)(c.Cell,{className:`text-right`,children:(0,l.jsx)(a,{variant:n===!1||n===`disabled`?`neutral`:`success`,children:e(typeof n==`boolean`?n?`common.on`:`common.off`:`admin.statusValue.${n}`)})})]},t))})})]})]})}function d({title:e,rows:t}){return(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`header`,{className:`bg-tinyrack-surface px-tinyrack-lg py-tinyrack-md`,children:(0,l.jsx)(i,{as:`h2`,variant:`headingSm`,children:e})}),(0,l.jsx)(c.Root,{density:`compact`,children:(0,l.jsx)(c.Body,{children:t.map(([e,t])=>(0,l.jsxs)(c.Row,{children:[(0,l.jsx)(c.Cell,{children:e}),(0,l.jsx)(c.Cell,{className:`text-right font-tinyrack-medium`,children:t})]},e))})})]})}var f=e(function({loaderData:e}){return(0,l.jsx)(o,{state:e.dehydratedState,children:(0,l.jsx)(u,{})})});export{f as default};
1
+ import{a as e}from"./components-DF4L3dSB.js";import{t}from"./jsx-runtime-B-57GDDH.js";import{a as n}from"./api-CfCwvXbU.js";import{r,t as i}from"./text-CBHShrvS.js";import{t as a}from"./badge-Cr0iG_iG.js";import{n as o}from"./route-module-2foR49uh.js";import{n as s}from"./admin-console-Ej5TUkij.js";import{t as c}from"./table-BpQCtRY7.js";var l=t();function u(){let{t:e}=n(),{data:t}=r(s),o=[[`admin.overview.activeUsers`,t.metrics.active_users],[`admin.overview.admins`,t.metrics.admins],[`admin.overview.activeClients`,t.metrics.active_clients],[`admin.overview.requiredTerms`,t.metrics.required_terms]];return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`grid grid-cols-2 bg-tinyrack-surface lg:grid-cols-4`,children:o.map(([t,n])=>(0,l.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs px-tinyrack-lg py-tinyrack-md`,children:[(0,l.jsx)(i,{color:`muted`,variant:`label`,children:e(String(t))}),(0,l.jsx)(i,{as:`p`,variant:`headingLg`,children:n})]},t))}),(0,l.jsxs)(`div`,{className:`grid gap-tinyrack-lg xl:grid-cols-2`,children:[(0,l.jsx)(d,{rows:[[e(`admin.source.config`),t.users.source.config],[e(`admin.source.database`),t.users.source.database]],title:e(`admin.overview.userSource`)}),(0,l.jsx)(d,{rows:[[e(`admin.overview.emailVerified`),t.users.authentication.email_verified],[e(`admin.overview.twoFactor`),t.users.authentication.two_factor],[e(`admin.overview.unverified`),t.users.authentication.remaining]],title:e(`admin.overview.authentication`)})]}),(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`header`,{className:`bg-tinyrack-surface px-tinyrack-lg py-tinyrack-md`,children:(0,l.jsx)(i,{as:`h2`,variant:`headingSm`,children:e(`admin.overview.serviceStatus`)})}),(0,l.jsx)(c.Root,{density:`compact`,children:(0,l.jsx)(c.Body,{children:Object.entries(t.status).map(([t,n])=>(0,l.jsxs)(c.Row,{children:[(0,l.jsx)(c.Cell,{children:e(`admin.status.${t}`)}),(0,l.jsx)(c.Cell,{className:`text-right`,children:(0,l.jsx)(a,{variant:n===!1||n===`disabled`?`neutral`:`success`,children:e(typeof n==`boolean`?n?`common.on`:`common.off`:`admin.statusValue.${n}`)})})]},t))})})]})]})}function d({title:e,rows:t}){return(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`header`,{className:`bg-tinyrack-surface px-tinyrack-lg py-tinyrack-md`,children:(0,l.jsx)(i,{as:`h2`,variant:`headingSm`,children:e})}),(0,l.jsx)(c.Root,{density:`compact`,children:(0,l.jsx)(c.Body,{children:t.map(([e,t])=>(0,l.jsxs)(c.Row,{children:[(0,l.jsx)(c.Cell,{children:e}),(0,l.jsx)(c.Cell,{className:`text-right font-tinyrack-medium`,children:t})]},e))})})]})}var f=e(function({loaderData:e}){return(0,l.jsx)(o,{state:e.dehydratedState,children:(0,l.jsx)(u,{})})});export{f as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n}from"./components-C1SipCbb.js";import{t as r}from"./jsx-runtime-BFZ_fnNJ.js";import{L as i,a,u as o}from"./api-0SzZx6X7.js";import{r as s,t as c}from"./text-CGN4ZtUZ.js";import{t as l}from"./useMutation-C4CmK9Sb.js";import{Bn as u,On as d,Vn as f,wn as p}from"./usePositioner-DcBnB2-O.js";import{t as m}from"./select--ltVnlVl.js";import{r as h}from"./NullStore-BxU9yW8l.js";import{a as g,c as _,d as v,f as ee,i as y,l as b,n as x,o as S,p as C,r as w,s as T,t as E,u as D}from"./use-admin-selection-CAegSKw5.js";import{n as O,t as k}from"./modal-LoTH9Ttl.js";import{r as A}from"./FieldItemContext-CPjig163.js";import{n as j,r as M,t as N}from"./field-DzNLNMM0.js";import{t as P}from"./FieldControl-D6zWw018.js";import{t as F}from"./input-BFJdEx8B.js";import{t as I}from"./badge-BCQspax5.js";import{t as L}from"./checkbox-OA4CFk-6.js";import{n as R}from"./route-module-Bm4sHkx9.js";import{c as z,i as B,m as V,o as H}from"./admin-console-BVGtfvzy.js";import{t as U}from"./table-D2oRcUKc.js";var W=e(t(),1),G=r(),K=W.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,...o}=e,[s,c]=W.useState(void 0),l=M(!0)?.disabled||a,u=d(`fieldset`,e,{ref:t,state:{disabled:l},props:[{"aria-labelledby":s,disabled:l},o]}),f=W.useMemo(()=>({legendId:s,setLegendId:c,disabled:l}),[s,c,l]);return(0,G.jsx)(j.Provider,{value:f,children:u})}),q=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{disabled:s,setLegendId:c}=M(),l=p(a,c);return d(`div`,e,{state:{disabled:s},ref:t,props:[{id:l},o]})});function J({ref:e,render:t=(0,G.jsx)(`legend`,{}),...n}){return(0,G.jsx)(q,{...n,ref:e,render:t})}var te=u(J,`tr-fieldset-legend`),Y={Root:u(K,`tr-fieldset`),Legend:te};function ne({className:e,uiSize:t=`md`,appearance:n=`solid`,...r}){return f(),(0,G.jsx)(P,{...r,className:o(`tr-textarea`,e),"data-appearance":n,"data-ui-size":t,render:(0,G.jsx)(`textarea`,{})})}function re(){let{t:e}=a(),t=i(),[n,r]=(0,W.useState)(``),[o,u]=(0,W.useState)({page:1,pageSize:20}),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),{data:O}=s(B(o)),k=E(O.terms.map(e=>e.id)),A=()=>t.invalidateQueries({queryKey:[`admin`]}),j=l({mutationFn:z,onSuccess:()=>{A(),f(null)}}),M=l({mutationFn:({id:e,input:t})=>V(e,t),onSuccess:()=>{A(),f(null)}}),N=l({mutationFn:H,onSuccess:()=>{A(),k.clear(),m(null)}}),P=o.page??1,F=o.pageSize??20,L=k.selection.kind===`filter`?O.pagination.total:k.selectedCount??0,R=k.selection.kind===`filter`?{kind:`filter`,filter:{query:o.query,managed_by:o.managedBy,archived:o.archived}}:{kind:`ids`,ids:[...k.selection.ids]},K=e=>{k.clear(),u(e)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,G.jsxs)(y,{onCreate:()=>f(`create`),onQueryChange:r,onSearch:()=>K({...o,query:n.trim(),page:1}),query:n,title:e(`admin.terms.title`),total:O.pagination.total,children:[(0,G.jsx)(w,{label:e(`admin.terms.required`),onChange:e=>K({...o,required:e===`all`?void 0:e===`required`,page:1}),options:[[`all`,e(`admin.filter.allRequirements`)],[`required`,e(`admin.terms.required`)],[`optional`,e(`admin.terms.optional`)]],value:o.required===void 0?`all`:o.required?`required`:`optional`}),(0,G.jsx)(w,{label:e(`admin.terms.consentMode`),onChange:e=>K({...o,consentMode:e===`explicit`?`explicit`:e===`implicit`?`implicit`:void 0,page:1}),options:[[`all`,e(`admin.filter.allModes`)],[`explicit`,e(`admin.terms.explicit`)],[`implicit`,e(`admin.terms.implicit`)]],value:o.consentMode??`all`}),(0,G.jsx)(w,{label:e(`admin.table.status`),onChange:e=>K({...o,archived:e===`all`?void 0:e===`archived`,page:1}),options:[[`all`,e(`admin.filter.allStatuses`)],[`active`,e(`admin.status.active`)],[`archived`,e(`admin.status.archived`)]],value:o.archived===void 0?`all`:o.archived?`archived`:`active`})]}),(0,G.jsxs)(C,{children:[(0,G.jsxs)(ee,{label:e(`admin.terms.title`),children:[(0,G.jsx)(U.Header,{className:`sticky top-0 z-tinyrack-component-raised`,children:(0,G.jsxs)(U.Row,{children:[(0,G.jsx)(v,{header:!0,children:(0,G.jsx)(T,{checked:k.allOnPage,indeterminate:k.someOnPage,onChange:k.togglePage})}),(0,G.jsx)(D,{header:!0,children:(0,G.jsx)(_,{direction:o.direction??`asc`,label:e(`admin.terms.id`),onClick:()=>K({...o,direction:o.direction===`desc`?`asc`:`desc`,page:1})})}),(0,G.jsx)(U.Head,{children:e(`admin.terms.titleLabel`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.version`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.required`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.consentMode`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.languages`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.source`)}),(0,G.jsx)(U.Head,{children:e(`admin.table.status`)}),(0,G.jsx)(b,{header:!0,children:e(`admin.table.actions`)})]})}),(0,G.jsx)(U.Body,{children:O.terms.length===0?(0,G.jsx)(U.Row,{children:(0,G.jsx)(U.Cell,{className:`py-tinyrack-3xl text-center`,colSpan:10,children:e(`admin.table.empty`)})}):O.terms.map(t=>(0,G.jsxs)(U.Row,{className:k.isSelected(t.id)?`bg-tinyrack-surface-selected`:void 0,"data-selected":k.isSelected(t.id)?``:void 0,children:[(0,G.jsx)(v,{selected:k.isSelected(t.id),children:(0,G.jsx)(S,{checked:k.isSelected(t.id),label:e(`admin.selection.row`,{name:t.id}),onChange:e=>k.toggleOne(t.id,e)})}),(0,G.jsx)(D,{selected:k.isSelected(t.id),children:(0,G.jsx)(c,{as:`span`,variant:`code`,children:t.id})}),(0,G.jsx)(U.Cell,{children:t.contents[0]?.title??t.id}),(0,G.jsx)(U.Cell,{children:t.version}),(0,G.jsx)(U.Cell,{children:e(t.required?`common.yes`:`common.no`)}),(0,G.jsx)(U.Cell,{children:e(`admin.terms.${t.consent_mode}`)}),(0,G.jsx)(U.Cell,{children:t.contents.map(e=>e.lang.toUpperCase()).join(`, `)}),(0,G.jsx)(U.Cell,{children:e(`admin.source.${t.managed_by}`)}),(0,G.jsx)(U.Cell,{children:(0,G.jsx)(I,{className:`whitespace-nowrap`,variant:t.archived_at?`neutral`:`success`,children:e(t.archived_at?`admin.status.archived`:`admin.status.active`)})}),(0,G.jsx)(b,{selected:k.isSelected(t.id),children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,G.jsx)(h,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>f(t),type:`button`,uiSize:`sm`,children:e(`admin.actions.edit`)}),(0,G.jsx)(h,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>N.mutate({target:{kind:`ids`,ids:[t.id]},active:!!t.archived_at}),type:`button`,uiSize:`sm`,children:e(t.archived_at?`admin.actions.restore`:`admin.actions.archive`)})]})})]},t.id))})]}),(0,G.jsx)(g,{onPageChange:e=>K({...o,page:e}),onPageSizeChange:e=>K({...o,page:1,pageSize:e}),page:P,pageSize:F,total:O.pagination.total})]})]}),L>0?(0,G.jsx)(x,{canExpand:k.allOnPage&&O.pagination.total>O.terms.length,filterSelected:k.selection.kind===`filter`,onActivate:()=>m(!0),onClear:k.clear,onDeactivate:()=>m(!1),onExpand:k.selectFilter,pending:N.isPending,selected:L,total:O.pagination.total}):null,(0,G.jsx)(ae,{active:p,count:L,filterSelected:k.selection.kind===`filter`,onClose:()=>m(null),onRun:()=>N.mutate({target:R,active:p??!0})}),(0,G.jsx)(ie,{isOpen:d!==null,onClose:()=>f(null),onSubmit:e=>{if(d&&d!==`create`){let{id:t,...n}=e;M.mutate({id:d.id,input:n})}else j.mutate(e)},pending:j.isPending||M.isPending,term:d===`create`?void 0:d??void 0})]})}function X(e,t){let n=e.get(t);return typeof n==`string`?n.trim():``}var Z=[`ko`,`en`,`ja`];function ie({isOpen:e,term:t,pending:n,onClose:r,onSubmit:i}){let{t:o}=a();return(0,G.jsx)(k,{description:o(t?`admin.terms.editDescription`:`admin.terms.createDescription`),isOpen:e,onClose:r,title:o(t?`admin.terms.editTitle`:`admin.terms.createTitle`),children:(0,G.jsxs)(A,{className:`flex flex-col gap-tinyrack-md pt-tinyrack-lg`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),n=X(t,`consent_mode`),r=[];for(let e of Z){let n=X(t,`${e}_title`),i=X(t,`${e}_content`),a=X(t,`${e}_type`);n&&i&&r.push({lang:e,title:n,type:a===`text`?`text`:`link`,content:i})}i({id:X(t,`id`),required:t.get(`required`)===`on`,consent_mode:n===`implicit`?`implicit`:`explicit`,version:X(t,`version`),contents:r})},children:[(0,G.jsxs)(`div`,{className:`grid gap-tinyrack-md sm:grid-cols-2`,children:[(0,G.jsx)(Q,{defaultValue:t?.id,disabled:!!t,label:o(`admin.terms.id`),name:`id`}),(0,G.jsx)(Q,{defaultValue:t?.version??`1.0.0`,label:o(`admin.terms.version`),name:`version`}),(0,G.jsx)($,{defaultValue:t?.consent_mode??`explicit`,label:o(`admin.terms.consentMode`),name:`consent_mode`,options:[[`explicit`,o(`admin.terms.explicit`)],[`implicit`,o(`admin.terms.implicit`)]]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,G.jsx)(L.Root,{"aria-label":o(`admin.terms.required`),defaultChecked:t?.required??!0,name:`required`,value:`on`,children:(0,G.jsx)(L.Indicator,{})}),(0,G.jsx)(c,{variant:`caption`,children:o(`admin.terms.required`)})]})]}),t?(0,G.jsx)(c,{color:`warning`,variant:`bodySm`,children:o(`admin.terms.versionWarning`)}):null,Z.map(e=>{let n=t?.contents.find(t=>t.lang===e);return(0,G.jsxs)(Y.Root,{className:`grid gap-tinyrack-sm pt-tinyrack-md sm:grid-cols-2`,children:[(0,G.jsx)(Y.Legend,{children:e.toUpperCase()}),(0,G.jsx)(Q,{defaultValue:n?.title,label:o(`admin.terms.titleLabel`),name:`${e}_title`}),(0,G.jsx)($,{defaultValue:n?.type??`link`,label:o(`admin.terms.contentType`),name:`${e}_type`,options:[[`link`,o(`admin.terms.link`)],[`text`,o(`admin.terms.text`)]]}),(0,G.jsx)(ne,{className:`sm:col-span-2`,defaultValue:n?.content,name:`${e}_content`,placeholder:o(`admin.terms.content`)})]},e)}),(0,G.jsxs)(O,{children:[(0,G.jsx)(h,{disabled:n,onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,G.jsx)(h,{disabled:n,intent:`primary`,type:`submit`,children:o(`admin.actions.save`)})]})]})})}function Q({label:e,name:t,defaultValue:n,disabled:r}){return(0,G.jsxs)(N.Root,{children:[(0,G.jsx)(N.Label,{children:e}),(0,G.jsx)(F,{defaultValue:n,disabled:r,name:t,required:!0,uiSize:`sm`})]})}function $({label:e,name:t,defaultValue:n,options:r}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs text-tinyrack-xs`,children:[(0,G.jsx)(c,{as:`span`,variant:`caption`,children:e}),(0,G.jsxs)(m.Root,{defaultValue:n,name:t,children:[(0,G.jsx)(m.Trigger,{"aria-label":e,uiSize:`sm`,children:(0,G.jsx)(m.Value,{children:r.find(([e])=>e===n)?.[1]??n})}),(0,G.jsx)(m.Positioner,{children:(0,G.jsx)(m.Popup,{children:(0,G.jsx)(m.List,{children:r.map(([e,t])=>(0,G.jsx)(m.Item,{value:e,children:(0,G.jsx)(m.ItemText,{children:t})},e))})})})]})]})}function ae({active:e,count:t,filterSelected:n,onClose:r,onRun:i}){let{t:o}=a();return(0,G.jsx)(k,{isOpen:e!==null,onClose:r,title:o(e?`admin.bulk.restoreTitle`:`admin.bulk.archiveTitle`),children:(0,G.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,G.jsx)(c,{color:`muted`,variant:`bodySm`,children:o(`admin.bulk.confirm`,{count:t,scope:o(n?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,G.jsxs)(O,{children:[(0,G.jsx)(h,{onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,G.jsx)(h,{intent:e?`primary`:`danger`,onClick:i,type:`button`,children:o(`admin.bulk.run`)})]})]})})}var oe=n(function({loaderData:e}){return(0,G.jsx)(R,{state:e.dehydratedState,children:(0,G.jsx)(re,{})})});export{oe as default};
1
+ import{$ as e,J as t,a as n}from"./components-DF4L3dSB.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{L as i,a,u as o}from"./api-CfCwvXbU.js";import{r as s,t as c}from"./text-CBHShrvS.js";import{t as l}from"./useMutation-BkuKGzks.js";import{Bn as u,On as d,Vn as f,wn as p}from"./usePositioner-CrQOY-iw.js";import{t as m}from"./select-C_WHBpl_.js";import{r as h}from"./NullStore-UyCsFQfz.js";import{a as g,c as _,d as v,f as ee,i as y,l as b,n as x,o as S,p as C,r as w,s as T,t as E,u as D}from"./use-admin-selection-i-WvRvvB.js";import{n as O,t as k}from"./modal-BDu41alh.js";import{r as A}from"./FieldItemContext-B3N2qWH8.js";import{n as j,r as M,t as N}from"./field-Du5xBKGW.js";import{t as P}from"./FieldControl-CwHXFt7p.js";import{t as F}from"./input-Dyj4-3JM.js";import{t as I}from"./badge-Cr0iG_iG.js";import{t as L}from"./checkbox-BymOAmaw.js";import{n as R}from"./route-module-2foR49uh.js";import{c as z,i as B,m as V,o as H}from"./admin-console-Ej5TUkij.js";import{t as U}from"./table-BpQCtRY7.js";var W=e(t(),1),G=r(),K=W.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,...o}=e,[s,c]=W.useState(void 0),l=M(!0)?.disabled||a,u=d(`fieldset`,e,{ref:t,state:{disabled:l},props:[{"aria-labelledby":s,disabled:l},o]}),f=W.useMemo(()=>({legendId:s,setLegendId:c,disabled:l}),[s,c,l]);return(0,G.jsx)(j.Provider,{value:f,children:u})}),q=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{disabled:s,setLegendId:c}=M(),l=p(a,c);return d(`div`,e,{state:{disabled:s},ref:t,props:[{id:l},o]})});function J({ref:e,render:t=(0,G.jsx)(`legend`,{}),...n}){return(0,G.jsx)(q,{...n,ref:e,render:t})}var te=u(J,`tr-fieldset-legend`),Y={Root:u(K,`tr-fieldset`),Legend:te};function ne({className:e,uiSize:t=`md`,appearance:n=`solid`,...r}){return f(),(0,G.jsx)(P,{...r,className:o(`tr-textarea`,e),"data-appearance":n,"data-ui-size":t,render:(0,G.jsx)(`textarea`,{})})}function re(){let{t:e}=a(),t=i(),[n,r]=(0,W.useState)(``),[o,u]=(0,W.useState)({page:1,pageSize:20}),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),{data:O}=s(B(o)),k=E(O.terms.map(e=>e.id)),A=()=>t.invalidateQueries({queryKey:[`admin`]}),j=l({mutationFn:z,onSuccess:()=>{A(),f(null)}}),M=l({mutationFn:({id:e,input:t})=>V(e,t),onSuccess:()=>{A(),f(null)}}),N=l({mutationFn:H,onSuccess:()=>{A(),k.clear(),m(null)}}),P=o.page??1,F=o.pageSize??20,L=k.selection.kind===`filter`?O.pagination.total:k.selectedCount??0,R=k.selection.kind===`filter`?{kind:`filter`,filter:{query:o.query,managed_by:o.managedBy,archived:o.archived}}:{kind:`ids`,ids:[...k.selection.ids]},K=e=>{k.clear(),u(e)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,G.jsxs)(y,{onCreate:()=>f(`create`),onQueryChange:r,onSearch:()=>K({...o,query:n.trim(),page:1}),query:n,title:e(`admin.terms.title`),total:O.pagination.total,children:[(0,G.jsx)(w,{label:e(`admin.terms.required`),onChange:e=>K({...o,required:e===`all`?void 0:e===`required`,page:1}),options:[[`all`,e(`admin.filter.allRequirements`)],[`required`,e(`admin.terms.required`)],[`optional`,e(`admin.terms.optional`)]],value:o.required===void 0?`all`:o.required?`required`:`optional`}),(0,G.jsx)(w,{label:e(`admin.terms.consentMode`),onChange:e=>K({...o,consentMode:e===`explicit`?`explicit`:e===`implicit`?`implicit`:void 0,page:1}),options:[[`all`,e(`admin.filter.allModes`)],[`explicit`,e(`admin.terms.explicit`)],[`implicit`,e(`admin.terms.implicit`)]],value:o.consentMode??`all`}),(0,G.jsx)(w,{label:e(`admin.table.status`),onChange:e=>K({...o,archived:e===`all`?void 0:e===`archived`,page:1}),options:[[`all`,e(`admin.filter.allStatuses`)],[`active`,e(`admin.status.active`)],[`archived`,e(`admin.status.archived`)]],value:o.archived===void 0?`all`:o.archived?`archived`:`active`})]}),(0,G.jsxs)(C,{children:[(0,G.jsxs)(ee,{label:e(`admin.terms.title`),children:[(0,G.jsx)(U.Header,{className:`sticky top-0 z-tinyrack-component-raised`,children:(0,G.jsxs)(U.Row,{children:[(0,G.jsx)(v,{header:!0,children:(0,G.jsx)(T,{checked:k.allOnPage,indeterminate:k.someOnPage,onChange:k.togglePage})}),(0,G.jsx)(D,{header:!0,children:(0,G.jsx)(_,{direction:o.direction??`asc`,label:e(`admin.terms.id`),onClick:()=>K({...o,direction:o.direction===`desc`?`asc`:`desc`,page:1})})}),(0,G.jsx)(U.Head,{children:e(`admin.terms.titleLabel`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.version`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.required`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.consentMode`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.languages`)}),(0,G.jsx)(U.Head,{children:e(`admin.terms.source`)}),(0,G.jsx)(U.Head,{children:e(`admin.table.status`)}),(0,G.jsx)(b,{header:!0,children:e(`admin.table.actions`)})]})}),(0,G.jsx)(U.Body,{children:O.terms.length===0?(0,G.jsx)(U.Row,{children:(0,G.jsx)(U.Cell,{className:`py-tinyrack-3xl text-center`,colSpan:10,children:e(`admin.table.empty`)})}):O.terms.map(t=>(0,G.jsxs)(U.Row,{className:k.isSelected(t.id)?`bg-tinyrack-surface-selected`:void 0,"data-selected":k.isSelected(t.id)?``:void 0,children:[(0,G.jsx)(v,{selected:k.isSelected(t.id),children:(0,G.jsx)(S,{checked:k.isSelected(t.id),label:e(`admin.selection.row`,{name:t.id}),onChange:e=>k.toggleOne(t.id,e)})}),(0,G.jsx)(D,{selected:k.isSelected(t.id),children:(0,G.jsx)(c,{as:`span`,variant:`code`,children:t.id})}),(0,G.jsx)(U.Cell,{children:t.contents[0]?.title??t.id}),(0,G.jsx)(U.Cell,{children:t.version}),(0,G.jsx)(U.Cell,{children:e(t.required?`common.yes`:`common.no`)}),(0,G.jsx)(U.Cell,{children:e(`admin.terms.${t.consent_mode}`)}),(0,G.jsx)(U.Cell,{children:t.contents.map(e=>e.lang.toUpperCase()).join(`, `)}),(0,G.jsx)(U.Cell,{children:e(`admin.source.${t.managed_by}`)}),(0,G.jsx)(U.Cell,{children:(0,G.jsx)(I,{className:`whitespace-nowrap`,variant:t.archived_at?`neutral`:`success`,children:e(t.archived_at?`admin.status.archived`:`admin.status.active`)})}),(0,G.jsx)(b,{selected:k.isSelected(t.id),children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,G.jsx)(h,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>f(t),type:`button`,uiSize:`sm`,children:e(`admin.actions.edit`)}),(0,G.jsx)(h,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>N.mutate({target:{kind:`ids`,ids:[t.id]},active:!!t.archived_at}),type:`button`,uiSize:`sm`,children:e(t.archived_at?`admin.actions.restore`:`admin.actions.archive`)})]})})]},t.id))})]}),(0,G.jsx)(g,{onPageChange:e=>K({...o,page:e}),onPageSizeChange:e=>K({...o,page:1,pageSize:e}),page:P,pageSize:F,total:O.pagination.total})]})]}),L>0?(0,G.jsx)(x,{canExpand:k.allOnPage&&O.pagination.total>O.terms.length,filterSelected:k.selection.kind===`filter`,onActivate:()=>m(!0),onClear:k.clear,onDeactivate:()=>m(!1),onExpand:k.selectFilter,pending:N.isPending,selected:L,total:O.pagination.total}):null,(0,G.jsx)(ae,{active:p,count:L,filterSelected:k.selection.kind===`filter`,onClose:()=>m(null),onRun:()=>N.mutate({target:R,active:p??!0})}),(0,G.jsx)(ie,{isOpen:d!==null,onClose:()=>f(null),onSubmit:e=>{if(d&&d!==`create`){let{id:t,...n}=e;M.mutate({id:d.id,input:n})}else j.mutate(e)},pending:j.isPending||M.isPending,term:d===`create`?void 0:d??void 0})]})}function X(e,t){let n=e.get(t);return typeof n==`string`?n.trim():``}var Z=[`ko`,`en`,`ja`];function ie({isOpen:e,term:t,pending:n,onClose:r,onSubmit:i}){let{t:o}=a();return(0,G.jsx)(k,{description:o(t?`admin.terms.editDescription`:`admin.terms.createDescription`),isOpen:e,onClose:r,title:o(t?`admin.terms.editTitle`:`admin.terms.createTitle`),children:(0,G.jsxs)(A,{className:`flex flex-col gap-tinyrack-md pt-tinyrack-lg`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),n=X(t,`consent_mode`),r=[];for(let e of Z){let n=X(t,`${e}_title`),i=X(t,`${e}_content`),a=X(t,`${e}_type`);n&&i&&r.push({lang:e,title:n,type:a===`text`?`text`:`link`,content:i})}i({id:X(t,`id`),required:t.get(`required`)===`on`,consent_mode:n===`implicit`?`implicit`:`explicit`,version:X(t,`version`),contents:r})},children:[(0,G.jsxs)(`div`,{className:`grid gap-tinyrack-md sm:grid-cols-2`,children:[(0,G.jsx)(Q,{defaultValue:t?.id,disabled:!!t,label:o(`admin.terms.id`),name:`id`}),(0,G.jsx)(Q,{defaultValue:t?.version??`1.0.0`,label:o(`admin.terms.version`),name:`version`}),(0,G.jsx)($,{defaultValue:t?.consent_mode??`explicit`,label:o(`admin.terms.consentMode`),name:`consent_mode`,options:[[`explicit`,o(`admin.terms.explicit`)],[`implicit`,o(`admin.terms.implicit`)]]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,G.jsx)(L.Root,{"aria-label":o(`admin.terms.required`),defaultChecked:t?.required??!0,name:`required`,value:`on`,children:(0,G.jsx)(L.Indicator,{})}),(0,G.jsx)(c,{variant:`caption`,children:o(`admin.terms.required`)})]})]}),t?(0,G.jsx)(c,{color:`warning`,variant:`bodySm`,children:o(`admin.terms.versionWarning`)}):null,Z.map(e=>{let n=t?.contents.find(t=>t.lang===e);return(0,G.jsxs)(Y.Root,{className:`grid gap-tinyrack-sm pt-tinyrack-md sm:grid-cols-2`,children:[(0,G.jsx)(Y.Legend,{children:e.toUpperCase()}),(0,G.jsx)(Q,{defaultValue:n?.title,label:o(`admin.terms.titleLabel`),name:`${e}_title`}),(0,G.jsx)($,{defaultValue:n?.type??`link`,label:o(`admin.terms.contentType`),name:`${e}_type`,options:[[`link`,o(`admin.terms.link`)],[`text`,o(`admin.terms.text`)]]}),(0,G.jsx)(ne,{className:`sm:col-span-2`,defaultValue:n?.content,name:`${e}_content`,placeholder:o(`admin.terms.content`)})]},e)}),(0,G.jsxs)(O,{children:[(0,G.jsx)(h,{disabled:n,onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,G.jsx)(h,{disabled:n,intent:`primary`,type:`submit`,children:o(`admin.actions.save`)})]})]})})}function Q({label:e,name:t,defaultValue:n,disabled:r}){return(0,G.jsxs)(N.Root,{children:[(0,G.jsx)(N.Label,{children:e}),(0,G.jsx)(F,{defaultValue:n,disabled:r,name:t,required:!0,uiSize:`sm`})]})}function $({label:e,name:t,defaultValue:n,options:r}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs text-tinyrack-xs`,children:[(0,G.jsx)(c,{as:`span`,variant:`caption`,children:e}),(0,G.jsxs)(m.Root,{defaultValue:n,name:t,children:[(0,G.jsx)(m.Trigger,{"aria-label":e,uiSize:`sm`,children:(0,G.jsx)(m.Value,{children:r.find(([e])=>e===n)?.[1]??n})}),(0,G.jsx)(m.Positioner,{children:(0,G.jsx)(m.Popup,{children:(0,G.jsx)(m.List,{children:r.map(([e,t])=>(0,G.jsx)(m.Item,{value:e,children:(0,G.jsx)(m.ItemText,{children:t})},e))})})})]})]})}function ae({active:e,count:t,filterSelected:n,onClose:r,onRun:i}){let{t:o}=a();return(0,G.jsx)(k,{isOpen:e!==null,onClose:r,title:o(e?`admin.bulk.restoreTitle`:`admin.bulk.archiveTitle`),children:(0,G.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,G.jsx)(c,{color:`muted`,variant:`bodySm`,children:o(`admin.bulk.confirm`,{count:t,scope:o(n?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,G.jsxs)(O,{children:[(0,G.jsx)(h,{onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,G.jsx)(h,{intent:e?`primary`:`danger`,onClick:i,type:`button`,children:o(`admin.bulk.run`)})]})]})})}var oe=n(function({loaderData:e}){return(0,G.jsx)(R,{state:e.dehydratedState,children:(0,G.jsx)(re,{})})});export{oe as default};
@@ -1 +1 @@
1
- import{a as e}from"./components-C1SipCbb.js";import{c as t}from"./toast-_zV1SGz6.js";import{t as n}from"./jsx-runtime-BFZ_fnNJ.js";import{a as r}from"./api-0SzZx6X7.js";import{t as i}from"./text-CGN4ZtUZ.js";import{r as a}from"./NullStore-BxU9yW8l.js";import{t as o}from"./circle-alert-DGTJ9B9k.js";import{t as s}from"./link-button-qvSTUE1n.js";import{t as c}from"./code-RrwtZcA2.js";import{t as l}from"./auth-outcome-B7tCCKZC.js";import{n as u}from"./route-module-Bm4sHkx9.js";import{t as d}from"./auth-layout-CFKu8bHI.js";import{n as f,t as p}from"./auth-footer-DgRsLHyD.js";var m=n();function h({search:e}){let{t:n}=r(),u=e.code||`UNKNOWN_ERROR`,h=e.message||n(`error.defaultMessage`);return(0,m.jsxs)(d,{children:[(0,m.jsxs)(l,{description:h,icon:o,title:n(`error.subtitle`),tone:`danger`,children:[(0,m.jsxs)(i,{color:`muted`,variant:`caption`,children:[n(`error.codeLabel`),` `,(0,m.jsx)(c,{"data-testid":`error-code`,children:u})]}),(0,m.jsx)(s,{className:`w-full`,intent:`primary`,render:(0,m.jsx)(t,{to:`/login`}),uiSize:`lg`,children:n(`error.goToLogin`)}),(0,m.jsx)(a,{appearance:`ghost`,className:`w-full`,intent:`neutral`,onClick:()=>window.history.back(),type:`button`,uiSize:`lg`,children:n(`error.goBack`)})]}),(0,m.jsx)(p,{children:(0,m.jsx)(f,{link:(0,m.jsx)(`a`,{href:`mailto:support@example.com`,children:n(`error.footer.contactSupport`)}),text:n(`error.footer.needHelp`)})})]})}var g=e(function({loaderData:e}){return(0,m.jsx)(u,{state:e.dehydratedState,children:(0,m.jsx)(h,{search:e.search})})});export{g as default};
1
+ import{a as e}from"./components-DF4L3dSB.js";import{c as t}from"./toast-XXVYYXim.js";import{t as n}from"./jsx-runtime-B-57GDDH.js";import{a as r}from"./api-CfCwvXbU.js";import{t as i}from"./text-CBHShrvS.js";import{r as a}from"./NullStore-UyCsFQfz.js";import{t as o}from"./circle-alert-BZCKPkRn.js";import{t as s}from"./link-button-DGt9hwk7.js";import{t as c}from"./code-Dc5QnXCh.js";import{t as l}from"./auth-outcome-DyY0JgWG.js";import{n as u}from"./route-module-2foR49uh.js";import{t as d}from"./auth-layout-B4h13HhN.js";import{n as f,t as p}from"./auth-footer-LG_gGuJv.js";var m=n();function h({search:e}){let{t:n}=r(),u=e.code||`UNKNOWN_ERROR`,h=e.message||n(`error.defaultMessage`);return(0,m.jsxs)(d,{children:[(0,m.jsxs)(l,{description:h,icon:o,title:n(`error.subtitle`),tone:`danger`,children:[(0,m.jsxs)(i,{color:`muted`,variant:`caption`,children:[n(`error.codeLabel`),` `,(0,m.jsx)(c,{"data-testid":`error-code`,children:u})]}),(0,m.jsx)(s,{className:`w-full`,intent:`primary`,render:(0,m.jsx)(t,{to:`/login`}),uiSize:`lg`,children:n(`error.goToLogin`)}),(0,m.jsx)(a,{appearance:`ghost`,className:`w-full`,intent:`neutral`,onClick:()=>window.history.back(),type:`button`,uiSize:`lg`,children:n(`error.goBack`)})]}),(0,m.jsx)(p,{children:(0,m.jsx)(f,{link:(0,m.jsx)(`a`,{href:`mailto:support@example.com`,children:n(`error.footer.contactSupport`)}),text:n(`error.footer.needHelp`)})})]})}var g=e(function({loaderData:e}){return(0,m.jsx)(u,{state:e.dehydratedState,children:(0,m.jsx)(h,{search:e.search})})});export{g as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n,f as r}from"./components-C1SipCbb.js";import{c as i}from"./toast-_zV1SGz6.js";import{t as a}from"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s,n as c,t as l}from"./api-0SzZx6X7.js";import{n as u,t as d}from"./text-CGN4ZtUZ.js";import{t as f}from"./useMutation-C4CmK9Sb.js";import{t as p}from"./useQuery-BtUeFnRt.js";import{i as m,r as h}from"./NullStore-BxU9yW8l.js";import{t as g}from"./circle-alert-DGTJ9B9k.js";import{t as _}from"./fingerprint-pattern-V_eTEvnZ.js";import{r as v}from"./language-selector-CGXk9vW_.js";import{t as y}from"./auth-page-header-D5Z-EA6V.js";import{t as b}from"./link-button-qvSTUE1n.js";import{t as x}from"./alert-CFUBsmUN.js";import{n as S,t as C}from"./promise-CFWkfv2A.js";import{t as w}from"./passkey-C9bzur2Z.js";import{t as T}from"./document-navigation-Cnp3Alf0.js";import{n as E,r as D}from"./route-module-Bm4sHkx9.js";import{t as O}from"./auth-layout-CFKu8bHI.js";import{n as k,t as A}from"./auth-footer-DgRsLHyD.js";import{a as j,r as M,t as N}from"./oauth-search-BtLPTIS7.js";import{t as P}from"./passkey-error-CZnhXTc7.js";var F=e(t(),1),I=u({queryKey:v.pendingSecondFactorMethods(),queryFn:async()=>{let e=await l.api.auth[`2fa`].methods.$get();return c(e)},retry:!1}),L=a();function R({search:e}){let{t}=s(),n=r(),a=o(),[c,l]=(0,F.useState)(null),u=(0,F.useRef)(!1),v=p({...I,enabled:c!==null}).data?.methods.includes(`totp`)??!1,E=e=>{switch(e){case`unsupported`:return t(`verifyPasskey.error.unsupported`);case`not_allowed`:return t(`verifyPasskey.error.notAllowed`);case`expired`:return t(`verifyPasskey.error.expired`);case`user_mismatch`:return t(`verifyPasskey.error.userMismatch`);case`verification_failed`:return t(`verifyPasskey.error.failed`)}},R=f({...w,onSuccess:async t=>{t.user&&(a.setQueryData(S.queryKey,{user:t.user}),await C(),j(e)?T(N(e)):await n(`/profile`))},onError:async e=>{let t=P(e);l({message:E(t),reason:t})}});return(0,F.useEffect)(()=>{u.current||(u.current=!0,R.mutate())},[R]),(0,L.jsxs)(O,{children:[(0,L.jsx)(y,{align:`center`,subtitle:t(`verifyPasskey.subtitle`),title:t(`verifyPasskey.title`)}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-lg`,children:[(0,L.jsx)(`div`,{className:`flex size-tinyrack-3xl items-center justify-center rounded-tinyrack-full bg-tinyrack-surface-muted`,children:(0,L.jsx)(_,{"aria-hidden":!0,className:`size-tinyrack-2xl text-tinyrack-text-muted`})}),R.isPending&&(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-sm`,children:[(0,L.jsx)(m,{uiSize:`md`}),(0,L.jsx)(d,{align:`center`,as:`p`,color:`muted`,variant:`bodySm`,children:t(`verifyPasskey.waiting`)})]}),c&&(0,L.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-tinyrack-md`,children:[(0,L.jsx)(x,{className:`w-full`,icon:g,type:`error`,children:c.message}),v&&(0,L.jsx)(b,{className:`w-full`,intent:`primary`,render:(0,L.jsx)(i,{to:D(`/verify/totp`,M(e))}),uiSize:`lg`,children:t(`verifyPasskey.useTotp`)}),(0,L.jsx)(h,{appearance:v?`outline`:`solid`,className:`w-full`,intent:v?`neutral`:`primary`,onClick:()=>{l(null),R.mutate()},type:`button`,uiSize:`lg`,children:t(`verifyPasskey.retry`)})]})]}),(0,L.jsx)(A,{children:(0,L.jsx)(k,{link:(0,L.jsx)(i,{to:D(`/login`,e),children:t(`verifyPasskey.backToLogin`)})})})]})}var z=n(function({loaderData:e}){return(0,L.jsx)(E,{state:e.dehydratedState,children:(0,L.jsx)(R,{search:e.search})})});export{z as default};
1
+ import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,n as c,t as l}from"./api-CfCwvXbU.js";import{n as u,t as d}from"./text-CBHShrvS.js";import{t as f}from"./useMutation-BkuKGzks.js";import{t as p}from"./useQuery-BLm0XsTI.js";import{i as m,r as h}from"./NullStore-UyCsFQfz.js";import{t as g}from"./circle-alert-BZCKPkRn.js";import{t as _}from"./fingerprint-pattern-AUfgwio5.js";import{r as v}from"./language-selector-Chn-k7Pw.js";import{t as y}from"./auth-page-header-BVY4zRzF.js";import{t as b}from"./link-button-DGt9hwk7.js";import{t as x}from"./alert-DS8e0Gvg.js";import{n as S,t as C}from"./promise-EbDcmV0j.js";import{t as w}from"./passkey-CWcdr7Vy.js";import{t as T}from"./document-navigation-Cnp3Alf0.js";import{n as E,r as D}from"./route-module-2foR49uh.js";import{t as O}from"./auth-layout-B4h13HhN.js";import{n as k,t as A}from"./auth-footer-LG_gGuJv.js";import{a as j,r as M,t as N}from"./oauth-search-DybZ6VWp.js";import{t as P}from"./passkey-error-C3DrncLi.js";var F=e(t(),1),I=u({queryKey:v.pendingSecondFactorMethods(),queryFn:async()=>{let e=await l.api.auth[`2fa`].methods.$get();return c(e)},retry:!1}),L=a();function R({search:e}){let{t}=s(),n=r(),a=o(),[c,l]=(0,F.useState)(null),u=(0,F.useRef)(!1),v=p({...I,enabled:c!==null}).data?.methods.includes(`totp`)??!1,E=e=>{switch(e){case`unsupported`:return t(`verifyPasskey.error.unsupported`);case`not_allowed`:return t(`verifyPasskey.error.notAllowed`);case`expired`:return t(`verifyPasskey.error.expired`);case`user_mismatch`:return t(`verifyPasskey.error.userMismatch`);case`verification_failed`:return t(`verifyPasskey.error.failed`)}},R=f({...w,onSuccess:async t=>{t.user&&(a.setQueryData(S.queryKey,{user:t.user}),await C(),j(e)?T(N(e)):await n(`/profile`))},onError:async e=>{let t=P(e);l({message:E(t),reason:t})}});return(0,F.useEffect)(()=>{u.current||(u.current=!0,R.mutate())},[R]),(0,L.jsxs)(O,{children:[(0,L.jsx)(y,{align:`center`,subtitle:t(`verifyPasskey.subtitle`),title:t(`verifyPasskey.title`)}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-lg`,children:[(0,L.jsx)(`div`,{className:`flex size-tinyrack-3xl items-center justify-center rounded-tinyrack-full bg-tinyrack-surface-muted`,children:(0,L.jsx)(_,{"aria-hidden":!0,className:`size-tinyrack-2xl text-tinyrack-text-muted`})}),R.isPending&&(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-sm`,children:[(0,L.jsx)(m,{uiSize:`md`}),(0,L.jsx)(d,{align:`center`,as:`p`,color:`muted`,variant:`bodySm`,children:t(`verifyPasskey.waiting`)})]}),c&&(0,L.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-tinyrack-md`,children:[(0,L.jsx)(x,{className:`w-full`,icon:g,type:`error`,children:c.message}),v&&(0,L.jsx)(b,{className:`w-full`,intent:`primary`,render:(0,L.jsx)(i,{to:D(`/verify/totp`,M(e))}),uiSize:`lg`,children:t(`verifyPasskey.useTotp`)}),(0,L.jsx)(h,{appearance:v?`outline`:`solid`,className:`w-full`,intent:v?`neutral`:`primary`,onClick:()=>{l(null),R.mutate()},type:`button`,uiSize:`lg`,children:t(`verifyPasskey.retry`)})]})]}),(0,L.jsx)(A,{children:(0,L.jsx)(k,{link:(0,L.jsx)(i,{to:D(`/login`,e),children:t(`verifyPasskey.backToLogin`)})})})]})}var z=n(function({loaderData:e}){return(0,L.jsx)(E,{state:e.dehydratedState,children:(0,L.jsx)(R,{search:e.search})})});export{z as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n,f as r,o as i}from"./components-C1SipCbb.js";import{c as a}from"./toast-_zV1SGz6.js";import{t as o}from"./jsx-runtime-BFZ_fnNJ.js";import{L as s,a as c}from"./api-0SzZx6X7.js";import{r as l,t as u}from"./text-CGN4ZtUZ.js";import{t as d}from"./useMutation-C4CmK9Sb.js";import{c as f}from"./shell-header-bar-C3KYib1D.js";import{r as p}from"./NullStore-BxU9yW8l.js";import{t as m}from"./circle-alert-DGTJ9B9k.js";import{t as h}from"./fingerprint-pattern-V_eTEvnZ.js";import{t as g}from"./authorization-context-banner-Cqtzj9A1.js";import{n as _}from"./language-selector-CGXk9vW_.js";import{n as v,t as y}from"./provider-mark-B05f08GZ.js";import{t as b}from"./mail-tgQpWyoC.js";import{t as x}from"./link-button-qvSTUE1n.js";import{t as S}from"./alert-CFUBsmUN.js";import{t as C}from"./route-error-fallback-C2OHu3JW.js";import{n as w,t as T}from"./promise-CFWkfv2A.js";import{t as E}from"./passkey-C9bzur2Z.js";import{n as D,t as O}from"./document-navigation-Cnp3Alf0.js";import{n as k,t as A}from"./route-module-Bm4sHkx9.js";import{t as j}from"./auth-layout-CFKu8bHI.js";import{a as M,r as N,t as P}from"./oauth-search-BtLPTIS7.js";import{t as F}from"./sanitized-rich-text-nFi_4i6F.js";import{t as I}from"./passkey-error-CZnhXTc7.js";var L=e(t(),1),R=o(),z={google:(0,R.jsx)(y,{"aria-hidden":!0,className:`size-tinyrack-xl`,provider:`google`}),github:(0,R.jsx)(y,{"aria-hidden":!0,className:`size-tinyrack-xl`,provider:`github`}),apple:(0,R.jsx)(y,{"aria-hidden":!0,className:`size-tinyrack-xl`,provider:`apple`})};function B({icon:e,label:t,providerType:n,render:r,onClick:i,isLoading:a,disabled:o}){let s;s=n&&n!==`generic_oauth`?z[n]:typeof e==`string`&&e.length>0?(0,R.jsx)(`img`,{alt:``,className:`size-tinyrack-xl`,src:e}):e||(0,R.jsx)(v,{"aria-hidden":!0,className:`size-tinyrack-xl`});let c=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`flex size-tinyrack-xl shrink-0 items-center justify-center`,children:s}),(0,R.jsx)(u,{truncate:!0,variant:`body`,children:t})]}),l=`w-full justify-start gap-tinyrack-md transition-colors duration-tinyrack-fast ease-tinyrack-standard [&>.tr-spinner]:order-last [&>.tr-spinner]:ms-auto`;return r?(0,R.jsx)(x,{appearance:`outline`,className:`cursor-pointer ${l}`,intent:`neutral`,render:r,uiSize:`lg`,children:c}):(0,R.jsx)(p,{appearance:`outline`,className:l,disabled:o,intent:`neutral`,loading:a,onClick:i,type:`button`,uiSize:`lg`,children:c})}var V={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`,registration_email_not_allowed:`oauth.error.registrationEmailNotAllowed`};function H({search:e}){let{t,i18n:n}=c(),i=r(),o=s(),p=e.lang??n.language,{data:v}=l(_),{loginMethodDescription:y}=f(),x=v.registration.signup_notice?.[p]??v.registration.signup_notice?.[v.i18n.fallback_language],C=v.identity_providers,k=e.oauth_error,A=k?t(V[k]??`oauth.error.failed`):void 0,z=v.auth.password.enabled,H=v.auth.passkey.enabled,[U,W]=(0,L.useState)(null),G=async t=>{t.user&&(o.setQueryData(w.queryKey,t),await T(),M(e)?O(P(e)):i(`/profile`))},K=d({...E,onSuccess:e=>{W(null),G(e)},onError:e=>{if(I(e)===`unsupported`){W(t(`login.passkey.error.unsupported`));return}W(t(`login.passkey.error.failed`))}}),q=t=>{let n=`/api/oauth/${t}/authorize?mode=login`;if(M(e)){let t=P(e);n+=`&return_url=${encodeURIComponent(t)}`}return n};return(0,R.jsxs)(j,{showBrandSubtitle:!0,children:[y&&(0,R.jsx)(u,{as:`p`,className:`-mb-tinyrack-sm`,color:`muted`,variant:`body`,children:y}),(0,R.jsx)(g,{search:e}),A&&(0,R.jsx)(S,{icon:m,type:`error`,children:A}),U&&(0,R.jsx)(S,{icon:m,type:`error`,children:U}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[C.map(e=>(0,R.jsx)(B,{icon:e.icon_url,label:e.display_name,providerType:e.type,render:(0,R.jsx)(`a`,{href:q(e.id),onClick:D})},e.id)),z&&(0,R.jsx)(B,{icon:(0,R.jsx)(b,{"aria-hidden":!0,className:`size-tinyrack-xl`}),label:t(`login.method.password`),render:(0,R.jsx)(a,{to:(()=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(N(e)))if(r!==void 0){let e=String(r);t.set(n,n===`account_selected`?decodeURIComponent(e).replaceAll(`"`,``):e)}let n=t.toString();return n?`/login/password?${n}`:`/login/password`})()})}),H&&(0,R.jsx)(B,{disabled:K.isPending,icon:(0,R.jsx)(h,{"aria-hidden":!0,className:`size-tinyrack-xl`}),isLoading:K.isPending,label:t(`login.method.passkey`),onClick:()=>{W(null),K.mutate()}})]}),x&&(0,R.jsx)(F,{html:x,variant:`notice`})]})}var U=i(function({error:e}){return(0,R.jsx)(A,{component:C,error:e})}),W=n(function({loaderData:e}){return(0,R.jsx)(k,{state:e.dehydratedState,children:(0,R.jsx)(H,{search:e.search})})});export{U as ErrorBoundary,W as default};
1
+ import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{c as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c}from"./api-CfCwvXbU.js";import{r as l,t as u}from"./text-CBHShrvS.js";import{t as d}from"./useMutation-BkuKGzks.js";import{c as f}from"./shell-header-bar-Bg85QIAq.js";import{r as p}from"./NullStore-UyCsFQfz.js";import{t as m}from"./circle-alert-BZCKPkRn.js";import{t as h}from"./fingerprint-pattern-AUfgwio5.js";import{t as g}from"./authorization-context-banner-az4f8FCY.js";import{n as _}from"./language-selector-Chn-k7Pw.js";import{n as v,t as y}from"./provider-mark-CCOkSxh7.js";import{t as b}from"./mail-B2PK2vlI.js";import{t as x}from"./link-button-DGt9hwk7.js";import{t as S}from"./alert-DS8e0Gvg.js";import{t as C}from"./route-error-fallback-CRL2Et8O.js";import{n as w,t as T}from"./promise-EbDcmV0j.js";import{t as E}from"./passkey-CWcdr7Vy.js";import{n as D,t as O}from"./document-navigation-Cnp3Alf0.js";import{n as k,t as A}from"./route-module-2foR49uh.js";import{t as j}from"./auth-layout-B4h13HhN.js";import{a as M,r as N,t as P}from"./oauth-search-DybZ6VWp.js";import{t as F}from"./sanitized-rich-text-uZcpKo6H.js";import{t as I}from"./passkey-error-C3DrncLi.js";var L=e(t(),1),R=o(),z={google:(0,R.jsx)(y,{"aria-hidden":!0,className:`size-tinyrack-xl`,provider:`google`}),github:(0,R.jsx)(y,{"aria-hidden":!0,className:`size-tinyrack-xl`,provider:`github`}),apple:(0,R.jsx)(y,{"aria-hidden":!0,className:`size-tinyrack-xl`,provider:`apple`})};function B({icon:e,label:t,providerType:n,render:r,onClick:i,isLoading:a,disabled:o}){let s;s=n&&n!==`generic_oauth`?z[n]:typeof e==`string`&&e.length>0?(0,R.jsx)(`img`,{alt:``,className:`size-tinyrack-xl`,src:e}):e||(0,R.jsx)(v,{"aria-hidden":!0,className:`size-tinyrack-xl`});let c=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`flex size-tinyrack-xl shrink-0 items-center justify-center`,children:s}),(0,R.jsx)(u,{truncate:!0,variant:`body`,children:t})]}),l=`w-full justify-start gap-tinyrack-md transition-colors duration-tinyrack-fast ease-tinyrack-standard [&>.tr-spinner]:order-last [&>.tr-spinner]:ms-auto`;return r?(0,R.jsx)(x,{appearance:`outline`,className:`cursor-pointer ${l}`,intent:`neutral`,render:r,uiSize:`lg`,children:c}):(0,R.jsx)(p,{appearance:`outline`,className:l,disabled:o,intent:`neutral`,loading:a,onClick:i,type:`button`,uiSize:`lg`,children:c})}var V={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`,registration_email_not_allowed:`oauth.error.registrationEmailNotAllowed`};function H({search:e}){let{t,i18n:n}=c(),i=r(),o=s(),p=e.lang??n.language,{data:v}=l(_),{loginMethodDescription:y}=f(),x=v.registration.signup_notice?.[p]??v.registration.signup_notice?.[v.i18n.fallback_language],C=v.identity_providers,k=e.oauth_error,A=k?t(V[k]??`oauth.error.failed`):void 0,z=v.auth.password.enabled,H=v.auth.passkey.enabled,[U,W]=(0,L.useState)(null),G=async t=>{t.user&&(o.setQueryData(w.queryKey,t),await T(),M(e)?O(P(e)):i(`/profile`))},K=d({...E,onSuccess:e=>{W(null),G(e)},onError:e=>{if(I(e)===`unsupported`){W(t(`login.passkey.error.unsupported`));return}W(t(`login.passkey.error.failed`))}}),q=t=>{let n=`/api/oauth/${t}/authorize?mode=login`;if(M(e)){let t=P(e);n+=`&return_url=${encodeURIComponent(t)}`}return n};return(0,R.jsxs)(j,{showBrandSubtitle:!0,children:[y&&(0,R.jsx)(u,{as:`p`,className:`-mb-tinyrack-sm`,color:`muted`,variant:`body`,children:y}),(0,R.jsx)(g,{search:e}),A&&(0,R.jsx)(S,{icon:m,type:`error`,children:A}),U&&(0,R.jsx)(S,{icon:m,type:`error`,children:U}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[C.map(e=>(0,R.jsx)(B,{icon:e.icon_url,label:e.display_name,providerType:e.type,render:(0,R.jsx)(`a`,{href:q(e.id),onClick:D})},e.id)),z&&(0,R.jsx)(B,{icon:(0,R.jsx)(b,{"aria-hidden":!0,className:`size-tinyrack-xl`}),label:t(`login.method.password`),render:(0,R.jsx)(a,{to:(()=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(N(e)))if(r!==void 0){let e=String(r);t.set(n,n===`account_selected`?decodeURIComponent(e).replaceAll(`"`,``):e)}let n=t.toString();return n?`/login/password?${n}`:`/login/password`})()})}),H&&(0,R.jsx)(B,{disabled:K.isPending,icon:(0,R.jsx)(h,{"aria-hidden":!0,className:`size-tinyrack-xl`}),isLoading:K.isPending,label:t(`login.method.passkey`),onClick:()=>{W(null),K.mutate()}})]}),x&&(0,R.jsx)(F,{html:x,variant:`notice`})]})}var U=i(function({error:e}){return(0,R.jsx)(A,{component:C,error:e})}),W=n(function({loaderData:e}){return(0,R.jsx)(k,{state:e.dehydratedState,children:(0,R.jsx)(H,{search:e.search})})});export{U as ErrorBoundary,W as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n}from"./components-C1SipCbb.js";import{t as r}from"./jsx-runtime-BFZ_fnNJ.js";import{L as i,a,n as o,t as s}from"./api-0SzZx6X7.js";import{n as c,r as l,t as u}from"./text-CGN4ZtUZ.js";import{t as d}from"./useMutation-C4CmK9Sb.js";import{B as f,t as p}from"./select--ltVnlVl.js";import{r as m}from"./NullStore-BxU9yW8l.js";import{a as h,c as g,d as _,f as ee,i as v,l as y,n as b,o as te,p as x,r as S,s as ne,t as re,u as C}from"./use-admin-selection-CAegSKw5.js";import{t as w}from"./triangle-alert-DSSurAZ_.js";import{n as T,t as E}from"./modal-LoTH9Ttl.js";import{r as D}from"./FieldItemContext-CPjig163.js";import{t as O}from"./field-DzNLNMM0.js";import{t as k}from"./input-BFJdEx8B.js";import{t as A}from"./badge-BCQspax5.js";import{t as j}from"./checkbox-OA4CFk-6.js";import{n as M}from"./route-module-Bm4sHkx9.js";import{n as N,t as P}from"./format-admin-user-BiqYL7ZT.js";import{t as F}from"./table-D2oRcUKc.js";import{t as ie}from"./admin-users-notice-DcKE5B43.js";var I=e(t(),1);function L(e){return e===`admin`?`admin`:`user`}var R=r();function z({modal:e,isMutating:t,onClose:n,onCreate:r,onUpdate:i,onDelete:o}){let{t:s}=a(),c=(0,I.useMemo)(()=>e?.type===`edit`?e.user:null,[e]);if(!e)return null;if(e.type===`delete`)return(0,R.jsxs)(E,{isOpen:!0,onClose:n,title:s(`admin.users.deleteTitle`,{email:e.user.email}),variant:`destructive`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs rounded-tinyrack-md border border-tinyrack-danger-border bg-tinyrack-danger-surface p-tinyrack-lg text-tinyrack-danger-foreground`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,R.jsx)(w,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,R.jsx)(u,{as:`p`,weight:`medium`,children:s(`admin.users.deleteWarning`)})]}),(0,R.jsx)(u,{as:`p`,variant:`bodySm`,children:s(`admin.users.deleteDescription`)})]}),(0,R.jsxs)(T,{children:[(0,R.jsx)(m,{disabled:t,onClick:n,type:`button`,uiSize:`sm`,children:s(`admin.users.cancel`)}),(0,R.jsx)(m,{disabled:t,intent:`danger`,onClick:()=>o(e.user.sub),type:`button`,uiSize:`sm`,children:s(`admin.users.deleteConfirm`)})]})]});let l=e.type===`create`?s(`admin.users.create`):s(`admin.users.editTitle`),d=e.type===`create`?s(`admin.users.createSubmit`):s(`admin.users.save`);return(0,R.jsx)(E,{description:e.type===`create`?s(`admin.users.createHint`):s(`admin.users.editHint`),isOpen:!0,onClose:n,title:l,children:(0,R.jsxs)(D,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-lg`,onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget),a={email:String(n.get(`email`)??``),role:L(n.get(`role`)),email_verified:n.get(`email_verified`)===`on`};e.type===`create`?r({...a,password:String(n.get(`password`)??``)}):i({sub:e.user.sub,...a})},children:[(0,R.jsxs)(O.Root,{children:[(0,R.jsx)(O.Label,{htmlFor:`admin-user-email`,children:s(`profile.email.label`)}),(0,R.jsx)(k,{defaultValue:c?.email??``,id:`admin-user-email`,name:`email`,required:!0,type:`email`,uiSize:`sm`})]}),e.type===`create`?(0,R.jsxs)(O.Root,{children:[(0,R.jsx)(O.Label,{htmlFor:`admin-user-password`,children:s(`admin.users.password`)}),(0,R.jsx)(k,{id:`admin-user-password`,name:`password`,required:!0,type:`password`,uiSize:`sm`})]}):null,(0,R.jsxs)(O.Root,{children:[(0,R.jsx)(O.Label,{htmlFor:`admin-user-role`,children:s(`admin.users.role`)}),(0,R.jsxs)(p.Root,{defaultValue:c?.role??`user`,name:`role`,children:[(0,R.jsx)(p.Trigger,{id:`admin-user-role`,uiSize:`sm`,children:(0,R.jsx)(p.Value,{})}),(0,R.jsx)(p.Positioner,{children:(0,R.jsx)(p.Popup,{children:(0,R.jsx)(p.List,{children:[`user`,`admin`].map(e=>(0,R.jsxs)(p.Item,{value:e,children:[(0,R.jsx)(p.ItemText,{children:s(`admin.users.role${e===`user`?`User`:`Admin`}`)}),(0,R.jsx)(p.ItemIndicator,{children:(0,R.jsx)(f,{"aria-hidden":!0})})]},e))})})})]})]}),(0,R.jsx)(O.Root,{children:(0,R.jsxs)(`div`,{className:`flex items-center gap-tinyrack-md rounded-tinyrack-md border border-tinyrack-border bg-tinyrack-surface px-tinyrack-md py-tinyrack-sm`,children:[(0,R.jsx)(j.Root,{"aria-label":s(`admin.users.emailVerified`),defaultChecked:c?.email_verified??!1,name:`email_verified`,uiSize:`lg`,value:`on`,children:(0,R.jsx)(j.Indicator,{})}),(0,R.jsx)(O.Label,{className:`cursor-pointer`,children:s(`admin.users.emailVerified`)})]})}),(0,R.jsxs)(T,{children:[(0,R.jsx)(m,{disabled:t,onClick:n,type:`button`,uiSize:`sm`,children:s(`admin.users.cancel`)}),(0,R.jsx)(m,{disabled:t,intent:`primary`,type:`submit`,uiSize:`sm`,children:d})]})]})})}var B={query:``,page:1,pageSize:20,includeDeleted:!1,sort:`email`,direction:`asc`};function V(e={}){return{...B,...e}}async function H(e,{query:t,page:n,pageSize:r,includeDeleted:i,managedBy:a,role:s,emailVerified:c,twoFactor:l,sort:u,direction:d}){return o(await e.api.admin.users.$get({query:{query:t,page:String(n),page_size:String(r),include_deleted:String(i),managed_by:a,role:s,email_verified:c===void 0?void 0:String(c),two_factor:l===void 0?void 0:String(l),sort:u,direction:d}}))}async function U(e){return o(await s.api.admin.users.$post({json:e}))}async function W({sub:e,...t}){return o(await s.api.admin.users[`:sub`].$patch({param:{sub:e},json:t}))}async function G(e){return o(await s.api.admin.users[`:sub`].$delete({param:{sub:e}}))}async function K(e){return o(await s.api.admin.users[`:sub`].restore.$post({param:{sub:e}}))}async function q(e){return o(await s.api.admin.users[`bulk-status`].$post({json:e}))}var J=(e,t={})=>{let n=V(t);return c({queryKey:[`admin`,`users`,n],queryFn:async()=>H(e,n)})},ae=(e={})=>J(s,e);function Y({user:e}){let{t}=a(),n=i(),[r,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(()=>V()),[f,p]=(0,I.useState)(null),[w,D]=(0,I.useState)(null),[O,k]=(0,I.useState)(null),{data:j}=l(ae(s)),M=re(j.users.map(e=>e.sub)),L=()=>n.invalidateQueries({queryKey:[`admin`]}),B=()=>p({tone:`error`,message:t(`admin.users.operationFailed`)}),H=e=>p({tone:`success`,message:e}),J=d({mutationFn:U,onSuccess:({user:e})=>{L(),H(t(`admin.users.createdNotice`,{email:e.email})),D(null)},onError:B}),Y=d({mutationFn:W,onSuccess:({user:e})=>{L(),H(t(`admin.users.updatedNotice`,{email:e.email})),D(null)},onError:B}),X=d({mutationFn:G,onSuccess:({user:e})=>{L(),H(t(`admin.users.deletedNotice`,{email:e.email})),D(null)},onError:B}),oe=d({mutationFn:K,onSuccess:({user:e})=>{L(),H(t(`admin.users.restoredNotice`,{email:e.email}))},onError:B}),Z=d({mutationFn:q,onSuccess:e=>{L(),M.clear(),k(null),H(t(`admin.selection.result`,e))},onError:B}),Q=e=>{M.clear(),c(e)},se=()=>Q({...s,query:r.trim(),page:1}),ce=M.selection.kind===`filter`?{kind:`filter`,filter:{query:s.query||void 0,include_deleted:s.includeDeleted,managed_by:s.managedBy,role:s.role,email_verified:s.emailVerified}}:{kind:`ids`,ids:[...M.selection.ids]},$=M.selection.kind===`filter`?j.pagination.total:M.selectedCount??0,le=J.isPending||Y.isPending||X.isPending;return(0,R.jsxs)(R.Fragment,{children:[f?(0,R.jsx)(ie,{notice:f,onDismiss:()=>p(null)}):null,(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-testid":`admin-users-directory`,children:[(0,R.jsxs)(v,{onCreate:()=>D({type:`create`}),onQueryChange:o,onSearch:se,query:r,title:t(`admin.users.title`),total:j.pagination.total,children:[(0,R.jsx)(S,{label:t(`admin.users.managedBy`),onChange:e=>Q({...s,managedBy:e===`database`?`database`:e===`config`?`config`:void 0,page:1}),options:[[`all`,t(`admin.filter.allSources`)],[`database`,t(`admin.source.database`)],[`config`,t(`admin.source.config`)]],value:s.managedBy??`all`}),(0,R.jsx)(S,{label:t(`admin.users.role`),onChange:e=>Q({...s,role:e===`user`?`user`:e===`admin`?`admin`:void 0,page:1}),options:[[`all`,t(`admin.filter.allRoles`)],[`user`,t(`admin.users.roleUser`)],[`admin`,t(`admin.users.roleAdmin`)]],value:s.role??`all`}),(0,R.jsx)(S,{label:t(`admin.table.status`),onChange:e=>Q({...s,includeDeleted:e===`all`,page:1}),options:[[`active`,t(`admin.status.active`)],[`all`,t(`admin.filter.includeInactive`)]],value:s.includeDeleted?`all`:`active`})]}),(0,R.jsxs)(x,{children:[(0,R.jsxs)(ee,{label:t(`admin.users.title`),children:[(0,R.jsx)(F.Header,{className:`sticky top-0 z-tinyrack-component-raised`,children:(0,R.jsxs)(F.Row,{children:[(0,R.jsx)(_,{header:!0,children:(0,R.jsx)(ne,{checked:M.allOnPage,indeterminate:M.someOnPage,onChange:M.togglePage})}),(0,R.jsx)(C,{header:!0,children:(0,R.jsx)(g,{direction:s.sort===`email`?s.direction:void 0,label:t(`admin.users.email`),onClick:()=>Q({...s,sort:`email`,direction:s.sort===`email`&&s.direction===`asc`?`desc`:`asc`,page:1})})}),(0,R.jsx)(F.Head,{children:(0,R.jsx)(g,{direction:s.sort===`role`?s.direction:void 0,label:t(`admin.users.role`),onClick:()=>Q({...s,sort:`role`,direction:s.sort===`role`&&s.direction===`asc`?`desc`:`asc`,page:1})})}),(0,R.jsx)(F.Head,{children:t(`admin.users.managedBy`)}),(0,R.jsx)(F.Head,{children:t(`admin.users.emailVerified`)}),(0,R.jsx)(F.Head,{children:t(`admin.users.twoFactor`)}),(0,R.jsx)(F.Head,{children:t(`admin.table.status`)}),(0,R.jsx)(F.Head,{children:t(`admin.users.sub`)}),(0,R.jsx)(y,{header:!0,children:t(`admin.table.actions`)})]})}),(0,R.jsx)(F.Body,{children:j.users.length===0?(0,R.jsx)(F.Row,{children:(0,R.jsx)(F.Cell,{className:`py-tinyrack-3xl text-center`,colSpan:9,children:t(`admin.table.empty`)})}):j.users.map(n=>(0,R.jsxs)(F.Row,{className:M.isSelected(n.sub)?`bg-tinyrack-surface-selected`:void 0,"data-selected":M.isSelected(n.sub)?``:void 0,children:[(0,R.jsx)(_,{selected:M.isSelected(n.sub),children:(0,R.jsx)(te,{checked:M.isSelected(n.sub),label:t(`admin.selection.row`,{name:n.email}),onChange:e=>M.toggleOne(n.sub,e)})}),(0,R.jsx)(C,{selected:M.isSelected(n.sub),children:(0,R.jsx)(u,{as:`p`,truncate:!0,variant:`bodySm`,weight:`medium`,children:n.email})}),(0,R.jsx)(F.Cell,{children:(0,R.jsx)(A,{variant:n.role===`admin`?`info`:`neutral`,children:P(t,n.role)})}),(0,R.jsx)(F.Cell,{children:N(t,n.managed_by)}),(0,R.jsx)(F.Cell,{children:t(n.email_verified?`common.yes`:`common.no`)}),(0,R.jsx)(F.Cell,{children:t(n.totp_registered||n.passkey_count>0?`common.yes`:`common.no`)}),(0,R.jsx)(F.Cell,{children:(0,R.jsx)(A,{className:`whitespace-nowrap`,variant:n.deleted_at?`neutral`:`success`,children:t(n.deleted_at?`admin.status.inactive`:`admin.status.active`)})}),(0,R.jsx)(F.Cell,{children:(0,R.jsx)(u,{as:`span`,variant:`code`,children:n.sub})}),(0,R.jsx)(y,{selected:M.isSelected(n.sub),children:n.deleted_at?(0,R.jsx)(m,{disabled:n.managed_by===`config`,onClick:()=>oe.mutate(n.sub),type:`button`,uiSize:`sm`,children:t(`admin.actions.restore`)}):(0,R.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,R.jsx)(m,{appearance:`ghost`,disabled:n.managed_by===`config`,onClick:()=>D({type:`edit`,user:n}),type:`button`,uiSize:`sm`,children:t(`admin.actions.edit`)}),(0,R.jsx)(m,{appearance:`ghost`,disabled:n.managed_by===`config`||n.sub===e.sub,onClick:()=>D({type:`delete`,user:n}),type:`button`,uiSize:`sm`,children:t(`admin.actions.deactivate`)})]})})]},n.sub))})]}),(0,R.jsx)(h,{onPageChange:e=>{M.clear(),c({...s,page:e})},onPageSizeChange:e=>Q({...s,page:1,pageSize:e}),page:s.page,pageSize:s.pageSize,total:j.pagination.total})]})]}),$>0?(0,R.jsx)(b,{canExpand:M.allOnPage&&j.pagination.total>j.users.length,filterSelected:M.selection.kind===`filter`,onActivate:()=>k(!0),onClear:M.clear,onDeactivate:()=>k(!1),onExpand:M.selectFilter,pending:Z.isPending,selected:$,total:j.pagination.total}):null,(0,R.jsx)(E,{isOpen:O!==null,onClose:()=>k(null),title:t(O?`admin.bulk.activateTitle`:`admin.bulk.deactivateTitle`),children:(0,R.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,R.jsx)(u,{color:`muted`,variant:`bodySm`,children:t(`admin.bulk.confirm`,{count:$,scope:t(M.selection.kind===`filter`?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,R.jsxs)(T,{children:[(0,R.jsx)(m,{onClick:()=>k(null),type:`button`,children:t(`common.dismiss`)}),(0,R.jsx)(m,{intent:O?`primary`:`danger`,onClick:()=>Z.mutate({target:ce,active:O??!0}),type:`button`,children:t(`admin.bulk.run`)})]})]})}),(0,R.jsx)(z,{isMutating:le,modal:w,onClose:()=>D(null),onCreate:e=>J.mutate(e),onDelete:e=>X.mutate(e),onUpdate:e=>Y.mutate(e)})]})}var X=n(function({loaderData:e}){return e.user?(0,R.jsx)(M,{state:e.dehydratedState,children:(0,R.jsx)(Y,{user:e.user})}):null});export{X as default};
1
+ import{$ as e,J as t,a as n}from"./components-DF4L3dSB.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{L as i,a,n as o,t as s}from"./api-CfCwvXbU.js";import{n as c,r as l,t as u}from"./text-CBHShrvS.js";import{t as d}from"./useMutation-BkuKGzks.js";import{B as f,t as p}from"./select-C_WHBpl_.js";import{r as m}from"./NullStore-UyCsFQfz.js";import{a as h,c as g,d as _,f as ee,i as v,l as y,n as b,o as te,p as x,r as S,s as ne,t as re,u as C}from"./use-admin-selection-i-WvRvvB.js";import{t as w}from"./triangle-alert-B0lTzZDi.js";import{n as T,t as E}from"./modal-BDu41alh.js";import{r as D}from"./FieldItemContext-B3N2qWH8.js";import{t as O}from"./field-Du5xBKGW.js";import{t as k}from"./input-Dyj4-3JM.js";import{t as A}from"./badge-Cr0iG_iG.js";import{t as j}from"./checkbox-BymOAmaw.js";import{n as M}from"./route-module-2foR49uh.js";import{n as N,t as P}from"./format-admin-user-BiqYL7ZT.js";import{t as F}from"./table-BpQCtRY7.js";import{t as ie}from"./admin-users-notice-D3rf-k5S.js";var I=e(t(),1);function L(e){return e===`admin`?`admin`:`user`}var R=r();function z({modal:e,isMutating:t,onClose:n,onCreate:r,onUpdate:i,onDelete:o}){let{t:s}=a(),c=(0,I.useMemo)(()=>e?.type===`edit`?e.user:null,[e]);if(!e)return null;if(e.type===`delete`)return(0,R.jsxs)(E,{isOpen:!0,onClose:n,title:s(`admin.users.deleteTitle`,{email:e.user.email}),variant:`destructive`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs rounded-tinyrack-md border border-tinyrack-danger-border bg-tinyrack-danger-surface p-tinyrack-lg text-tinyrack-danger-foreground`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,R.jsx)(w,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,R.jsx)(u,{as:`p`,weight:`medium`,children:s(`admin.users.deleteWarning`)})]}),(0,R.jsx)(u,{as:`p`,variant:`bodySm`,children:s(`admin.users.deleteDescription`)})]}),(0,R.jsxs)(T,{children:[(0,R.jsx)(m,{disabled:t,onClick:n,type:`button`,uiSize:`sm`,children:s(`admin.users.cancel`)}),(0,R.jsx)(m,{disabled:t,intent:`danger`,onClick:()=>o(e.user.sub),type:`button`,uiSize:`sm`,children:s(`admin.users.deleteConfirm`)})]})]});let l=e.type===`create`?s(`admin.users.create`):s(`admin.users.editTitle`),d=e.type===`create`?s(`admin.users.createSubmit`):s(`admin.users.save`);return(0,R.jsx)(E,{description:e.type===`create`?s(`admin.users.createHint`):s(`admin.users.editHint`),isOpen:!0,onClose:n,title:l,children:(0,R.jsxs)(D,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-lg`,onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget),a={email:String(n.get(`email`)??``),role:L(n.get(`role`)),email_verified:n.get(`email_verified`)===`on`};e.type===`create`?r({...a,password:String(n.get(`password`)??``)}):i({sub:e.user.sub,...a})},children:[(0,R.jsxs)(O.Root,{children:[(0,R.jsx)(O.Label,{htmlFor:`admin-user-email`,children:s(`profile.email.label`)}),(0,R.jsx)(k,{defaultValue:c?.email??``,id:`admin-user-email`,name:`email`,required:!0,type:`email`,uiSize:`sm`})]}),e.type===`create`?(0,R.jsxs)(O.Root,{children:[(0,R.jsx)(O.Label,{htmlFor:`admin-user-password`,children:s(`admin.users.password`)}),(0,R.jsx)(k,{id:`admin-user-password`,name:`password`,required:!0,type:`password`,uiSize:`sm`})]}):null,(0,R.jsxs)(O.Root,{children:[(0,R.jsx)(O.Label,{htmlFor:`admin-user-role`,children:s(`admin.users.role`)}),(0,R.jsxs)(p.Root,{defaultValue:c?.role??`user`,name:`role`,children:[(0,R.jsx)(p.Trigger,{id:`admin-user-role`,uiSize:`sm`,children:(0,R.jsx)(p.Value,{})}),(0,R.jsx)(p.Positioner,{children:(0,R.jsx)(p.Popup,{children:(0,R.jsx)(p.List,{children:[`user`,`admin`].map(e=>(0,R.jsxs)(p.Item,{value:e,children:[(0,R.jsx)(p.ItemText,{children:s(`admin.users.role${e===`user`?`User`:`Admin`}`)}),(0,R.jsx)(p.ItemIndicator,{children:(0,R.jsx)(f,{"aria-hidden":!0})})]},e))})})})]})]}),(0,R.jsx)(O.Root,{children:(0,R.jsxs)(`div`,{className:`flex items-center gap-tinyrack-md rounded-tinyrack-md border border-tinyrack-border bg-tinyrack-surface px-tinyrack-md py-tinyrack-sm`,children:[(0,R.jsx)(j.Root,{"aria-label":s(`admin.users.emailVerified`),defaultChecked:c?.email_verified??!1,name:`email_verified`,uiSize:`lg`,value:`on`,children:(0,R.jsx)(j.Indicator,{})}),(0,R.jsx)(O.Label,{className:`cursor-pointer`,children:s(`admin.users.emailVerified`)})]})}),(0,R.jsxs)(T,{children:[(0,R.jsx)(m,{disabled:t,onClick:n,type:`button`,uiSize:`sm`,children:s(`admin.users.cancel`)}),(0,R.jsx)(m,{disabled:t,intent:`primary`,type:`submit`,uiSize:`sm`,children:d})]})]})})}var B={query:``,page:1,pageSize:20,includeDeleted:!1,sort:`email`,direction:`asc`};function V(e={}){return{...B,...e}}async function H(e,{query:t,page:n,pageSize:r,includeDeleted:i,managedBy:a,role:s,emailVerified:c,twoFactor:l,sort:u,direction:d}){return o(await e.api.admin.users.$get({query:{query:t,page:String(n),page_size:String(r),include_deleted:String(i),managed_by:a,role:s,email_verified:c===void 0?void 0:String(c),two_factor:l===void 0?void 0:String(l),sort:u,direction:d}}))}async function U(e){return o(await s.api.admin.users.$post({json:e}))}async function W({sub:e,...t}){return o(await s.api.admin.users[`:sub`].$patch({param:{sub:e},json:t}))}async function G(e){return o(await s.api.admin.users[`:sub`].$delete({param:{sub:e}}))}async function K(e){return o(await s.api.admin.users[`:sub`].restore.$post({param:{sub:e}}))}async function q(e){return o(await s.api.admin.users[`bulk-status`].$post({json:e}))}var J=(e,t={})=>{let n=V(t);return c({queryKey:[`admin`,`users`,n],queryFn:async()=>H(e,n)})},ae=(e={})=>J(s,e);function Y({user:e}){let{t}=a(),n=i(),[r,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(()=>V()),[f,p]=(0,I.useState)(null),[w,D]=(0,I.useState)(null),[O,k]=(0,I.useState)(null),{data:j}=l(ae(s)),M=re(j.users.map(e=>e.sub)),L=()=>n.invalidateQueries({queryKey:[`admin`]}),B=()=>p({tone:`error`,message:t(`admin.users.operationFailed`)}),H=e=>p({tone:`success`,message:e}),J=d({mutationFn:U,onSuccess:({user:e})=>{L(),H(t(`admin.users.createdNotice`,{email:e.email})),D(null)},onError:B}),Y=d({mutationFn:W,onSuccess:({user:e})=>{L(),H(t(`admin.users.updatedNotice`,{email:e.email})),D(null)},onError:B}),X=d({mutationFn:G,onSuccess:({user:e})=>{L(),H(t(`admin.users.deletedNotice`,{email:e.email})),D(null)},onError:B}),oe=d({mutationFn:K,onSuccess:({user:e})=>{L(),H(t(`admin.users.restoredNotice`,{email:e.email}))},onError:B}),Z=d({mutationFn:q,onSuccess:e=>{L(),M.clear(),k(null),H(t(`admin.selection.result`,e))},onError:B}),Q=e=>{M.clear(),c(e)},se=()=>Q({...s,query:r.trim(),page:1}),ce=M.selection.kind===`filter`?{kind:`filter`,filter:{query:s.query||void 0,include_deleted:s.includeDeleted,managed_by:s.managedBy,role:s.role,email_verified:s.emailVerified}}:{kind:`ids`,ids:[...M.selection.ids]},$=M.selection.kind===`filter`?j.pagination.total:M.selectedCount??0,le=J.isPending||Y.isPending||X.isPending;return(0,R.jsxs)(R.Fragment,{children:[f?(0,R.jsx)(ie,{notice:f,onDismiss:()=>p(null)}):null,(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"data-testid":`admin-users-directory`,children:[(0,R.jsxs)(v,{onCreate:()=>D({type:`create`}),onQueryChange:o,onSearch:se,query:r,title:t(`admin.users.title`),total:j.pagination.total,children:[(0,R.jsx)(S,{label:t(`admin.users.managedBy`),onChange:e=>Q({...s,managedBy:e===`database`?`database`:e===`config`?`config`:void 0,page:1}),options:[[`all`,t(`admin.filter.allSources`)],[`database`,t(`admin.source.database`)],[`config`,t(`admin.source.config`)]],value:s.managedBy??`all`}),(0,R.jsx)(S,{label:t(`admin.users.role`),onChange:e=>Q({...s,role:e===`user`?`user`:e===`admin`?`admin`:void 0,page:1}),options:[[`all`,t(`admin.filter.allRoles`)],[`user`,t(`admin.users.roleUser`)],[`admin`,t(`admin.users.roleAdmin`)]],value:s.role??`all`}),(0,R.jsx)(S,{label:t(`admin.table.status`),onChange:e=>Q({...s,includeDeleted:e===`all`,page:1}),options:[[`active`,t(`admin.status.active`)],[`all`,t(`admin.filter.includeInactive`)]],value:s.includeDeleted?`all`:`active`})]}),(0,R.jsxs)(x,{children:[(0,R.jsxs)(ee,{label:t(`admin.users.title`),children:[(0,R.jsx)(F.Header,{className:`sticky top-0 z-tinyrack-component-raised`,children:(0,R.jsxs)(F.Row,{children:[(0,R.jsx)(_,{header:!0,children:(0,R.jsx)(ne,{checked:M.allOnPage,indeterminate:M.someOnPage,onChange:M.togglePage})}),(0,R.jsx)(C,{header:!0,children:(0,R.jsx)(g,{direction:s.sort===`email`?s.direction:void 0,label:t(`admin.users.email`),onClick:()=>Q({...s,sort:`email`,direction:s.sort===`email`&&s.direction===`asc`?`desc`:`asc`,page:1})})}),(0,R.jsx)(F.Head,{children:(0,R.jsx)(g,{direction:s.sort===`role`?s.direction:void 0,label:t(`admin.users.role`),onClick:()=>Q({...s,sort:`role`,direction:s.sort===`role`&&s.direction===`asc`?`desc`:`asc`,page:1})})}),(0,R.jsx)(F.Head,{children:t(`admin.users.managedBy`)}),(0,R.jsx)(F.Head,{children:t(`admin.users.emailVerified`)}),(0,R.jsx)(F.Head,{children:t(`admin.users.twoFactor`)}),(0,R.jsx)(F.Head,{children:t(`admin.table.status`)}),(0,R.jsx)(F.Head,{children:t(`admin.users.sub`)}),(0,R.jsx)(y,{header:!0,children:t(`admin.table.actions`)})]})}),(0,R.jsx)(F.Body,{children:j.users.length===0?(0,R.jsx)(F.Row,{children:(0,R.jsx)(F.Cell,{className:`py-tinyrack-3xl text-center`,colSpan:9,children:t(`admin.table.empty`)})}):j.users.map(n=>(0,R.jsxs)(F.Row,{className:M.isSelected(n.sub)?`bg-tinyrack-surface-selected`:void 0,"data-selected":M.isSelected(n.sub)?``:void 0,children:[(0,R.jsx)(_,{selected:M.isSelected(n.sub),children:(0,R.jsx)(te,{checked:M.isSelected(n.sub),label:t(`admin.selection.row`,{name:n.email}),onChange:e=>M.toggleOne(n.sub,e)})}),(0,R.jsx)(C,{selected:M.isSelected(n.sub),children:(0,R.jsx)(u,{as:`p`,truncate:!0,variant:`bodySm`,weight:`medium`,children:n.email})}),(0,R.jsx)(F.Cell,{children:(0,R.jsx)(A,{variant:n.role===`admin`?`info`:`neutral`,children:P(t,n.role)})}),(0,R.jsx)(F.Cell,{children:N(t,n.managed_by)}),(0,R.jsx)(F.Cell,{children:t(n.email_verified?`common.yes`:`common.no`)}),(0,R.jsx)(F.Cell,{children:t(n.totp_registered||n.passkey_count>0?`common.yes`:`common.no`)}),(0,R.jsx)(F.Cell,{children:(0,R.jsx)(A,{className:`whitespace-nowrap`,variant:n.deleted_at?`neutral`:`success`,children:t(n.deleted_at?`admin.status.inactive`:`admin.status.active`)})}),(0,R.jsx)(F.Cell,{children:(0,R.jsx)(u,{as:`span`,variant:`code`,children:n.sub})}),(0,R.jsx)(y,{selected:M.isSelected(n.sub),children:n.deleted_at?(0,R.jsx)(m,{disabled:n.managed_by===`config`,onClick:()=>oe.mutate(n.sub),type:`button`,uiSize:`sm`,children:t(`admin.actions.restore`)}):(0,R.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,R.jsx)(m,{appearance:`ghost`,disabled:n.managed_by===`config`,onClick:()=>D({type:`edit`,user:n}),type:`button`,uiSize:`sm`,children:t(`admin.actions.edit`)}),(0,R.jsx)(m,{appearance:`ghost`,disabled:n.managed_by===`config`||n.sub===e.sub,onClick:()=>D({type:`delete`,user:n}),type:`button`,uiSize:`sm`,children:t(`admin.actions.deactivate`)})]})})]},n.sub))})]}),(0,R.jsx)(h,{onPageChange:e=>{M.clear(),c({...s,page:e})},onPageSizeChange:e=>Q({...s,page:1,pageSize:e}),page:s.page,pageSize:s.pageSize,total:j.pagination.total})]})]}),$>0?(0,R.jsx)(b,{canExpand:M.allOnPage&&j.pagination.total>j.users.length,filterSelected:M.selection.kind===`filter`,onActivate:()=>k(!0),onClear:M.clear,onDeactivate:()=>k(!1),onExpand:M.selectFilter,pending:Z.isPending,selected:$,total:j.pagination.total}):null,(0,R.jsx)(E,{isOpen:O!==null,onClose:()=>k(null),title:t(O?`admin.bulk.activateTitle`:`admin.bulk.deactivateTitle`),children:(0,R.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,R.jsx)(u,{color:`muted`,variant:`bodySm`,children:t(`admin.bulk.confirm`,{count:$,scope:t(M.selection.kind===`filter`?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,R.jsxs)(T,{children:[(0,R.jsx)(m,{onClick:()=>k(null),type:`button`,children:t(`common.dismiss`)}),(0,R.jsx)(m,{intent:O?`primary`:`danger`,onClick:()=>Z.mutate({target:ce,active:O??!0}),type:`button`,children:t(`admin.bulk.run`)})]})]})}),(0,R.jsx)(z,{isMutating:le,modal:w,onClose:()=>D(null),onCreate:e=>J.mutate(e),onDelete:e=>X.mutate(e),onUpdate:e=>Y.mutate(e)})]})}var X=n(function({loaderData:e}){return e.user?(0,R.jsx)(M,{state:e.dehydratedState,children:(0,R.jsx)(Y,{user:e.user})}):null});export{X as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n,f as r}from"./components-C1SipCbb.js";import{c as i}from"./toast-_zV1SGz6.js";import{t as a}from"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s,i as c}from"./api-0SzZx6X7.js";import{t as l}from"./text-CGN4ZtUZ.js";import{t as u}from"./useMutation-C4CmK9Sb.js";import{r as d}from"./NullStore-BxU9yW8l.js";import{t as f}from"./circle-alert-DGTJ9B9k.js";import{t as p}from"./auth-page-header-D5Z-EA6V.js";import{t as m}from"./alert-CFUBsmUN.js";import{r as h,t as g}from"./standard-schema-C8Td_miB.js";import{r as _}from"./FieldItemContext-CPjig163.js";import{a as v,s as y}from"./schemas-Dxi9xZo6.js";import{t as b}from"./field-DzNLNMM0.js";import{t as x}from"./input-BFJdEx8B.js";import{n as S,t as C}from"./promise-CFWkfv2A.js";import{a as w}from"./totp-BW4BoCpi.js";import{t as T}from"./document-navigation-Cnp3Alf0.js";import{n as E,r as D}from"./route-module-Bm4sHkx9.js";import{t as O}from"./auth-layout-CFKu8bHI.js";import{n as k,t as A}from"./auth-footer-DgRsLHyD.js";import{t as j}from"./labeled-separator-DkexQjxp.js";import{a as M,r as N,t as P}from"./oauth-search-BtLPTIS7.js";var F=e(t(),1),I=a(),L={SECOND_FACTOR_SESSION_EXPIRED:`SECOND_FACTOR_SESSION_EXPIRED`,INVALID_RECOVERY_CODE:`INVALID_RECOVERY_CODE`,NO_RECOVERY_CODES_AVAILABLE:`NO_RECOVERY_CODES_AVAILABLE`,TOTP_NOT_ENABLED:`TOTP_NOT_ENABLED`},R=5;function z({search:e}){let{t}=s(),n=r(),a=o(),E=(0,F.useRef)(null),[z,B]=(0,F.useState)(!1),[V,H]=(0,F.useState)(R),U=(0,F.useMemo)(()=>v({code:y().transform(e=>e.toUpperCase()).pipe(y().regex(/^[A-HJ-NP-TV-Z2-9]{4}(?:-[A-HJ-NP-TV-Z2-9]{4}){3}$/,t(`verifyRecovery.error.invalid`)))}),[t]),W=u({...w,onSuccess:async t=>{a.setQueryData(S.queryKey,{user:t.user}),await C(),M(e)?T(P(e)):n(`/profile`)},onSettled:()=>{a.invalidateQueries({queryKey:S.queryKey})}}),{register:G,setError:K,handleSubmit:q,setValue:J,formState:{errors:Y}}=h({defaultValues:{code:``},resolver:g(U)}),X=(0,F.useCallback)(()=>{n(D(`/login`,N(e)))},[n,e]);(0,F.useEffect)(()=>{if(!z)return;let e=setInterval(()=>{H(t=>t<=1?(clearInterval(e),X(),0):t-1)},1e3);return()=>clearInterval(e)},[z,X]);let Z=async e=>{try{await W.mutateAsync(e)}catch(e){if(e instanceof c)switch(e.code){case L.SECOND_FACTOR_SESSION_EXPIRED:B(!0),H(R);return;case L.TOTP_NOT_ENABLED:X();return;case L.NO_RECOVERY_CODES_AVAILABLE:K(`code`,{type:`manual`,message:t(`verifyRecovery.error.noCodesAvailable`)}),J(`code`,``),E.current?.focus();return;case L.INVALID_RECOVERY_CODE:K(`code`,{type:`manual`,message:t(`verifyRecovery.error.invalid`)}),J(`code`,``),E.current?.focus();return}K(`code`,{type:`manual`,message:t(`verifyRecovery.error.invalid`)}),J(`code`,``),E.current?.focus()}},{ref:Q,...$}=G(`code`);return(0,I.jsxs)(O,{children:[(0,I.jsx)(p,{subtitle:t(`verifyRecovery.subtitle`),title:t(`verifyRecovery.title`)}),z&&(0,I.jsx)(m,{"data-testid":`recovery-session-expired`,icon:f,type:`warning`,children:(0,I.jsxs)(`div`,{className:`flex flex-col items-start gap-tinyrack-3xs`,children:[(0,I.jsx)(l,{as:`span`,variant:`bodySm`,children:t(`verifyRecovery.error.expired`)}),(0,I.jsx)(l,{as:`span`,color:`muted`,variant:`caption`,children:t(`verifyRecovery.redirecting`,{seconds:V})}),(0,I.jsx)(d,{appearance:`ghost`,intent:`neutral`,onClick:X,type:`button`,uiSize:`sm`,children:t(`verifyRecovery.redirectNow`)})]})}),(0,I.jsxs)(_,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:q(Z),children:[(0,I.jsxs)(b.Root,{children:[(0,I.jsx)(x,{...$,autoComplete:`off`,className:`w-full text-center font-tinyrack-mono`,"data-testid":`recovery-code-input`,disabled:z,placeholder:t(`verifyRecovery.placeholder`),ref:e=>{Q(e),E.current=e},type:`text`,uiSize:`lg`}),(0,I.jsx)(b.Error,{"data-testid":`recovery-error`,match:!!Y.code,children:Y.code?.message})]}),z?(0,I.jsx)(d,{className:`w-full`,disabled:!0,intent:`primary`,type:`button`,uiSize:`lg`,children:t(`verifyRecovery.submit`)}):(0,I.jsx)(d,{className:`w-full`,intent:`primary`,loading:W.isPending,loadingLabel:t(`verifyRecovery.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyRecovery.submit`)})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,I.jsx)(j,{label:t(`common.or`)}),(0,I.jsx)(d,{appearance:`ghost`,className:`w-full`,"data-testid":`recovery-back-to-totp`,intent:`neutral`,onClick:()=>n(D(`/verify/totp`,N(e))),type:`button`,uiSize:`lg`,children:t(`verifyRecovery.backToTotp`)})]}),(0,I.jsx)(A,{children:(0,I.jsx)(k,{link:(0,I.jsx)(i,{to:D(`/login`,N(e)),children:t(`verifyRecovery.backToLogin`)})})})]})}var B=n(function({loaderData:e}){return(0,I.jsx)(E,{state:e.dehydratedState,children:(0,I.jsx)(z,{search:e.search})})});export{B as default};
1
+ import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,i as c}from"./api-CfCwvXbU.js";import{t as l}from"./text-CBHShrvS.js";import{t as u}from"./useMutation-BkuKGzks.js";import{r as d}from"./NullStore-UyCsFQfz.js";import{t as f}from"./circle-alert-BZCKPkRn.js";import{t as p}from"./auth-page-header-BVY4zRzF.js";import{t as m}from"./alert-DS8e0Gvg.js";import{r as h,t as g}from"./standard-schema-kM5DbC12.js";import{r as _}from"./FieldItemContext-B3N2qWH8.js";import{a as v,s as y}from"./schemas-B87iTMww.js";import{t as b}from"./field-Du5xBKGW.js";import{t as x}from"./input-Dyj4-3JM.js";import{n as S,t as C}from"./promise-EbDcmV0j.js";import{a as w}from"./totp-4989Pb-o.js";import{t as T}from"./document-navigation-Cnp3Alf0.js";import{n as E,r as D}from"./route-module-2foR49uh.js";import{t as O}from"./auth-layout-B4h13HhN.js";import{n as k,t as A}from"./auth-footer-LG_gGuJv.js";import{t as j}from"./labeled-separator-JGa2pO6H.js";import{a as M,r as N,t as P}from"./oauth-search-DybZ6VWp.js";var F=e(t(),1),I=a(),L={SECOND_FACTOR_SESSION_EXPIRED:`SECOND_FACTOR_SESSION_EXPIRED`,INVALID_RECOVERY_CODE:`INVALID_RECOVERY_CODE`,NO_RECOVERY_CODES_AVAILABLE:`NO_RECOVERY_CODES_AVAILABLE`,TOTP_NOT_ENABLED:`TOTP_NOT_ENABLED`},R=5;function z({search:e}){let{t}=s(),n=r(),a=o(),E=(0,F.useRef)(null),[z,B]=(0,F.useState)(!1),[V,H]=(0,F.useState)(R),U=(0,F.useMemo)(()=>v({code:y().transform(e=>e.toUpperCase()).pipe(y().regex(/^[A-HJ-NP-TV-Z2-9]{4}(?:-[A-HJ-NP-TV-Z2-9]{4}){3}$/,t(`verifyRecovery.error.invalid`)))}),[t]),W=u({...w,onSuccess:async t=>{a.setQueryData(S.queryKey,{user:t.user}),await C(),M(e)?T(P(e)):n(`/profile`)},onSettled:()=>{a.invalidateQueries({queryKey:S.queryKey})}}),{register:G,setError:K,handleSubmit:q,setValue:J,formState:{errors:Y}}=h({defaultValues:{code:``},resolver:g(U)}),X=(0,F.useCallback)(()=>{n(D(`/login`,N(e)))},[n,e]);(0,F.useEffect)(()=>{if(!z)return;let e=setInterval(()=>{H(t=>t<=1?(clearInterval(e),X(),0):t-1)},1e3);return()=>clearInterval(e)},[z,X]);let Z=async e=>{try{await W.mutateAsync(e)}catch(e){if(e instanceof c)switch(e.code){case L.SECOND_FACTOR_SESSION_EXPIRED:B(!0),H(R);return;case L.TOTP_NOT_ENABLED:X();return;case L.NO_RECOVERY_CODES_AVAILABLE:K(`code`,{type:`manual`,message:t(`verifyRecovery.error.noCodesAvailable`)}),J(`code`,``),E.current?.focus();return;case L.INVALID_RECOVERY_CODE:K(`code`,{type:`manual`,message:t(`verifyRecovery.error.invalid`)}),J(`code`,``),E.current?.focus();return}K(`code`,{type:`manual`,message:t(`verifyRecovery.error.invalid`)}),J(`code`,``),E.current?.focus()}},{ref:Q,...$}=G(`code`);return(0,I.jsxs)(O,{children:[(0,I.jsx)(p,{subtitle:t(`verifyRecovery.subtitle`),title:t(`verifyRecovery.title`)}),z&&(0,I.jsx)(m,{"data-testid":`recovery-session-expired`,icon:f,type:`warning`,children:(0,I.jsxs)(`div`,{className:`flex flex-col items-start gap-tinyrack-3xs`,children:[(0,I.jsx)(l,{as:`span`,variant:`bodySm`,children:t(`verifyRecovery.error.expired`)}),(0,I.jsx)(l,{as:`span`,color:`muted`,variant:`caption`,children:t(`verifyRecovery.redirecting`,{seconds:V})}),(0,I.jsx)(d,{appearance:`ghost`,intent:`neutral`,onClick:X,type:`button`,uiSize:`sm`,children:t(`verifyRecovery.redirectNow`)})]})}),(0,I.jsxs)(_,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:q(Z),children:[(0,I.jsxs)(b.Root,{children:[(0,I.jsx)(x,{...$,autoComplete:`off`,className:`w-full text-center font-tinyrack-mono`,"data-testid":`recovery-code-input`,disabled:z,placeholder:t(`verifyRecovery.placeholder`),ref:e=>{Q(e),E.current=e},type:`text`,uiSize:`lg`}),(0,I.jsx)(b.Error,{"data-testid":`recovery-error`,match:!!Y.code,children:Y.code?.message})]}),z?(0,I.jsx)(d,{className:`w-full`,disabled:!0,intent:`primary`,type:`button`,uiSize:`lg`,children:t(`verifyRecovery.submit`)}):(0,I.jsx)(d,{className:`w-full`,intent:`primary`,loading:W.isPending,loadingLabel:t(`verifyRecovery.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyRecovery.submit`)})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,I.jsx)(j,{label:t(`common.or`)}),(0,I.jsx)(d,{appearance:`ghost`,className:`w-full`,"data-testid":`recovery-back-to-totp`,intent:`neutral`,onClick:()=>n(D(`/verify/totp`,N(e))),type:`button`,uiSize:`lg`,children:t(`verifyRecovery.backToTotp`)})]}),(0,I.jsx)(A,{children:(0,I.jsx)(k,{link:(0,I.jsx)(i,{to:D(`/login`,N(e)),children:t(`verifyRecovery.backToLogin`)})})})]})}var B=n(function({loaderData:e}){return(0,I.jsx)(E,{state:e.dehydratedState,children:(0,I.jsx)(z,{search:e.search})})});export{B as default};
@@ -0,0 +1 @@
1
+ import{a as e}from"./components-DF4L3dSB.js";var t=e(function(){return null});export{t as default};
@@ -0,0 +1 @@
1
+ import{a as e,o as t}from"./components-DF4L3dSB.js";import{c as n}from"./toast-XXVYYXim.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{L as i,a,n as o,t as s}from"./api-CfCwvXbU.js";import{n as c,r as l}from"./text-CBHShrvS.js";import{t as u}from"./useMutation-BkuKGzks.js";import{t as d}from"./mutationOptions-Dfvzj6n2.js";import{V as f}from"./select-C_WHBpl_.js";import{n as p}from"./shell-header-bar-Bg85QIAq.js";import{r as m}from"./NullStore-UyCsFQfz.js";import{t as h}from"./auth-choice-row-DNB3B1Vs.js";import{r as g}from"./language-selector-Chn-k7Pw.js";import{t as _}from"./trash-C7RyeTUJ.js";import{t as v}from"./auth-page-header-BVY4zRzF.js";import{t as y}from"./link-button-DGt9hwk7.js";import{t as b}from"./alert-DS8e0Gvg.js";import{t as x}from"./initial-avatar-ByHiX-IF.js";import{t as S}from"./route-error-fallback-CRL2Et8O.js";import{t as C}from"./badge-Cr0iG_iG.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-2foR49uh.js";import{t as D}from"./auth-layout-B4h13HhN.js";import{n as O,r as k}from"./oauth-search-DybZ6VWp.js";var A={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};A.node;var j=f(A),M={name:`circle-user-round`,size:24,node:[[`path`,{d:`M17.925 20.056a6 6 0 0 0-11.851.001`,key:`z69sun`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]],aliases:[`user-circle-2`]};M.node;var N=f(M),P={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};P.node;var F=f(P);function I(e,t){return c({queryKey:g.accounts(t),queryFn:async()=>{let n=await e.api.auth.accounts.$get({query:t?{client_id:t}:{}});return o(n)}})}function L(e){return I(s,e)}var R=d({mutationFn:async e=>{let t=await s.api.auth.accounts.select.$post({json:e});return o(t)}}),z=d({mutationFn:async e=>{let t=await s.api.auth.accounts.remove.$post({json:e});return o(t)}}),B=r();function V(e){let t=e?.split(` `).filter(Boolean)??[];return t.includes(`login`)||t.push(`login`),t.join(` `)}function H(e){let t=k(e),n=new URLSearchParams;for(let[e,r]of Object.entries({...t,prompt:V(t.prompt),account_selected:1}))r!==void 0&&n.set(e,String(r));return`/login?${n.toString()}`}function U({search:e}){let{t}=a(),r=i(),{data:o}=l(L(e.client_id)),s=o.accounts.length===0&&!o.allow_add_account,c=()=>{w(O({...e,account_selected:1}))},d=u({...R,onSuccess:c}),f=u({...z,onSuccess:()=>{r.invalidateQueries({queryKey:g.accounts(e.client_id)})}});return(0,B.jsxs)(D,{width:`wide`,children:[(0,B.jsx)(v,{subtitle:t(`accountSelect.subtitle`),title:t(`accountSelect.title`)}),o.accounts.length===0?(0,B.jsx)(b,{icon:N,type:`info`,children:t(s?`accountSelect.unavailable`:`accountSelect.noRememberedAccounts`)}):(0,B.jsx)(`div`,{className:`flex flex-col gap-tinyrack-sm`,"data-testid":`account-list`,children:o.accounts.map(e=>(0,B.jsx)(`div`,{"data-testid":`remembered-account-${e.sub}`,children:(0,B.jsx)(h,{description:e.current?t(`accountSelect.currentAccount`):t(`accountSelect.rememberedAccount`),indicator:e.current?(0,B.jsx)(C,{className:`shrink-0 whitespace-nowrap`,uiSize:`md`,variant:`info`,children:t(`accountSelect.current`)}):null,label:e.email,leading:(0,B.jsx)(x,{email:e.email,size:`md`}),render:(0,B.jsx)(m,{"data-testid":`select-account-${e.sub}`,disabled:d.isPending,onClick:()=>d.mutate({sub:e.sub}),type:`button`,uiSize:`lg`}),selected:e.current,surface:`card`,trailing:o.allow_remove_account&&!e.current?(0,B.jsx)(p,{appearance:`ghost`,"aria-label":t(`accountSelect.removeAccount`,{email:e.email}),"data-testid":`remove-account-${e.sub}`,disabled:f.isPending,intent:`neutral`,onClick:()=>f.mutate({sub:e.sub}),type:`button`,uiSize:`sm`,children:(0,B.jsx)(_,{"aria-hidden":!0,className:`size-tinyrack-lg`})}):null})},e.sub))}),o.allow_add_account?(0,B.jsxs)(y,{appearance:`ghost`,className:`w-full justify-between`,intent:`neutral`,render:(0,B.jsx)(n,{to:H(e)}),uiSize:`lg`,children:[(0,B.jsx)(F,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`accountSelect.useAnotherAccount`),(0,B.jsx)(j,{"aria-hidden":!0,className:`size-tinyrack-lg`})]}):null]})}var W=t(function({error:e}){return(0,B.jsx)(E,{component:S,error:e})}),G=e(function({loaderData:e}){return(0,B.jsx)(T,{state:e.dehydratedState,children:(0,B.jsx)(U,{search:e.search})})});export{W as ErrorBoundary,G as default};
@@ -0,0 +1 @@
1
+ import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{c as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{a as s}from"./api-CfCwvXbU.js";import{r as c}from"./text-CBHShrvS.js";import{t as l}from"./useMutation-BkuKGzks.js";import{V as u}from"./select-C_WHBpl_.js";import{r as d}from"./NullStore-UyCsFQfz.js";import{t as f}from"./circle-alert-BZCKPkRn.js";import{t as p}from"./circle-check-BW_XcUlv.js";import{t as m}from"./auth-field-CDCz-y27.js";import{t as h}from"./key-round-BlUAV-K9.js";import{n as g}from"./language-selector-Chn-k7Pw.js";import{t as _}from"./lock-Cr_egoXD.js";import{t as v}from"./auth-page-header-BVY4zRzF.js";import{t as y}from"./alert-DS8e0Gvg.js";import{t as b}from"./auth-outcome-DyY0JgWG.js";import{t as x}from"./route-error-fallback-CRL2Et8O.js";import{r as S,t as C}from"./standard-schema-kM5DbC12.js";import{r as w}from"./FieldItemContext-B3N2qWH8.js";import{a as T,s as E}from"./schemas-B87iTMww.js";import{n as D,t as O}from"./route-module-2foR49uh.js";import{t as k}from"./auth-layout-B4h13HhN.js";import{n as A,t as j}from"./auth-footer-LG_gGuJv.js";import{n as M}from"./password-reset-BhkJhVQ4.js";import{t as N}from"./password-strength-B1w3RCA1.js";var P={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};P.node;var F=u(P),I=e(t(),1),L=o();function R({search:e}){let{t}=s(),n=r(),{token:i}=e,[o,u]=(0,I.useState)(!1),{data:x}=c(g),D=x.auth.password.policy,O=(0,I.useMemo)(()=>T({token:E().min(1,t(`validation.token.required`)),password:E().min(D.min_length,t(`validation.password.min`,{count:D.min_length})).max(D.max_length,t(`validation.password.max`,{count:D.max_length})),confirmPassword:E().min(1,t(`validation.confirmPassword.required`))}).refine(e=>e.password===e.confirmPassword,{message:t(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[D.max_length,D.min_length,t]),P=l({...M,onSuccess:()=>{u(!0)}}),{register:R,setError:z,handleSubmit:B,watch:V,formState:{errors:H}}=S({defaultValues:{token:i||``,password:``,confirmPassword:``},resolver:C(O)}),U=V(`password`);return o?(0,L.jsx)(k,{children:(0,L.jsx)(`div`,{"data-testid":`alert-success`,children:(0,L.jsx)(b,{description:(0,L.jsxs)(L.Fragment,{children:[t(`resetPassword.success.subtitle`),(0,L.jsx)(`br`,{}),t(`resetPassword.success.description`)]}),icon:p,title:t(`resetPassword.success.title`),tone:`success`,children:(0,L.jsx)(d,{className:`w-full`,"data-testid":`reset-password-go-login`,intent:`primary`,onClick:()=>n(`/login`),type:`button`,uiSize:`lg`,children:t(`resetPassword.success.goToLogin`)})})})}):(0,L.jsxs)(k,{children:[(0,L.jsx)(v,{subtitle:t(`resetPassword.subtitle`),title:t(`resetPassword.title`)}),(0,L.jsxs)(w,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:B(async e=>{try{await P.mutateAsync({token:e.token,password:e.password})}catch(e){e&&typeof e==`object`&&`code`in e?e.code===`INVALID_PASSWORD_RESET_TOKEN`?z(`token`,{type:`manual`,message:t(`resetPassword.error.invalidToken`)}):e.code===`USER_NOT_EDITABLE`&&z(`token`,{type:`manual`,message:t(`resetPassword.error.notEditable`)}):z(`token`,{type:`manual`,message:t(`resetPassword.error.invalidToken`)})}}),children:[!i&&(0,L.jsx)(m,{error:H.token,icon:h,label:t(`resetPassword.token.label`),placeholder:t(`resetPassword.token.placeholder`),...R(`token`),type:`text`}),i&&H.token&&(0,L.jsx)(y,{"data-testid":`reset-password-token-error`,icon:f,type:`error`,children:H.token.message}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,L.jsx)(m,{autoComplete:`new-password`,error:H.password,icon:_,label:t(`resetPassword.password.label`),placeholder:t(`resetPassword.password.placeholder`),...R(`password`),type:`password`}),(0,L.jsx)(N,{password:U,policy:D})]}),(0,L.jsx)(m,{autoComplete:`new-password`,error:H.confirmPassword,icon:F,label:t(`resetPassword.confirmPassword.label`),placeholder:t(`resetPassword.confirmPassword.placeholder`),...R(`confirmPassword`),type:`password`}),(0,L.jsx)(d,{className:`w-full`,intent:`primary`,loading:P.isPending,loadingLabel:t(`resetPassword.submitting`),type:`submit`,uiSize:`lg`,children:t(`resetPassword.submit`)})]}),(0,L.jsx)(j,{children:(0,L.jsx)(A,{link:(0,L.jsx)(a,{"data-testid":`reset-password-back-to-login`,to:`/login`,children:t(`resetPassword.backToLogin`)})})})]})}var z=i(function({error:e}){return(0,L.jsx)(O,{component:x,error:e})}),B=n(function({loaderData:e}){return(0,L.jsx)(D,{state:e.dehydratedState,children:(0,L.jsx)(R,{search:e.search})})});export{z as ErrorBoundary,B as default};
@@ -1 +1 @@
1
- import{a as e,o as t}from"./components-C1SipCbb.js";import{c as n}from"./toast-_zV1SGz6.js";import{t as r}from"./jsx-runtime-BFZ_fnNJ.js";import{a as i}from"./api-0SzZx6X7.js";import{r as a}from"./text-CGN4ZtUZ.js";import{t as o}from"./auth-choice-row-DBHleTc9.js";import{t as s}from"./fingerprint-pattern-V_eTEvnZ.js";import{n as c}from"./language-selector-CGXk9vW_.js";import{t as l}from"./shield-check-93-WFkyJ.js";import{t as u}from"./auth-page-header-D5Z-EA6V.js";import{t as d}from"./route-error-fallback-C2OHu3JW.js";import{n as f,r as p,t as m}from"./route-module-Bm4sHkx9.js";import{t as h}from"./auth-layout-CFKu8bHI.js";import{n as g,t as _}from"./auth-footer-DgRsLHyD.js";import{r as v}from"./oauth-search-BtLPTIS7.js";var y=r();function b({search:e}){let{t}=i(),r=v(e),{data:d}=a(c);return(0,y.jsxs)(h,{children:[(0,y.jsx)(u,{subtitle:t(`verify2fa.subtitle`),title:t(`verify2fa.title`)}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[d.auth.password.enabled&&d.auth.password.totp.enabled&&(0,y.jsx)(o,{description:t(`verify2fa.totp.description`),icon:l,label:t(`verify2fa.totp.title`),render:(0,y.jsx)(n,{to:p(`/verify/totp`,r)})}),d.auth.passkey.enabled&&(0,y.jsx)(o,{description:t(`verify2fa.passkey.description`),icon:s,label:t(`verify2fa.passkey.title`),render:(0,y.jsx)(n,{to:p(`/verify/passkey`,r)})})]}),(0,y.jsx)(_,{children:(0,y.jsx)(g,{link:(0,y.jsx)(n,{to:p(`/login`,r),children:t(`verify2fa.backToLogin`)})})})]})}var x=t(function({error:e}){return(0,y.jsx)(m,{component:d,error:e})}),S=e(function({loaderData:e}){return(0,y.jsx)(f,{state:e.dehydratedState,children:(0,y.jsx)(b,{search:e.search})})});export{x as ErrorBoundary,S as default};
1
+ import{a as e,o as t}from"./components-DF4L3dSB.js";import{c as n}from"./toast-XXVYYXim.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{a as i}from"./api-CfCwvXbU.js";import{r as a}from"./text-CBHShrvS.js";import{t as o}from"./auth-choice-row-DNB3B1Vs.js";import{t as s}from"./fingerprint-pattern-AUfgwio5.js";import{n as c}from"./language-selector-Chn-k7Pw.js";import{t as l}from"./shield-check-2DKLuF9J.js";import{t as u}from"./auth-page-header-BVY4zRzF.js";import{t as d}from"./route-error-fallback-CRL2Et8O.js";import{n as f,r as p,t as m}from"./route-module-2foR49uh.js";import{t as h}from"./auth-layout-B4h13HhN.js";import{n as g,t as _}from"./auth-footer-LG_gGuJv.js";import{r as v}from"./oauth-search-DybZ6VWp.js";var y=r();function b({search:e}){let{t}=i(),r=v(e),{data:d}=a(c);return(0,y.jsxs)(h,{children:[(0,y.jsx)(u,{subtitle:t(`verify2fa.subtitle`),title:t(`verify2fa.title`)}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[d.auth.password.enabled&&d.auth.password.totp.enabled&&(0,y.jsx)(o,{description:t(`verify2fa.totp.description`),icon:l,label:t(`verify2fa.totp.title`),render:(0,y.jsx)(n,{to:p(`/verify/totp`,r)})}),d.auth.passkey.enabled&&(0,y.jsx)(o,{description:t(`verify2fa.passkey.description`),icon:s,label:t(`verify2fa.passkey.title`),render:(0,y.jsx)(n,{to:p(`/verify/passkey`,r)})})]}),(0,y.jsx)(_,{children:(0,y.jsx)(g,{link:(0,y.jsx)(n,{to:p(`/login`,r),children:t(`verify2fa.backToLogin`)})})})]})}var x=t(function({error:e}){return(0,y.jsx)(m,{component:d,error:e})}),S=e(function({loaderData:e}){return(0,y.jsx)(f,{state:e.dehydratedState,children:(0,y.jsx)(b,{search:e.search})})});export{x as ErrorBoundary,S as default};
@@ -1 +1 @@
1
- import{a as e,o as t}from"./components-C1SipCbb.js";import{c as n}from"./toast-_zV1SGz6.js";import{t as r}from"./jsx-runtime-BFZ_fnNJ.js";import{a as i}from"./api-0SzZx6X7.js";import{r as a}from"./text-CGN4ZtUZ.js";import{t as o}from"./auth-choice-row-DBHleTc9.js";import{t as s}from"./fingerprint-pattern-V_eTEvnZ.js";import{n as c}from"./language-selector-CGXk9vW_.js";import{t as l}from"./shield-check-93-WFkyJ.js";import{t as u}from"./auth-page-header-D5Z-EA6V.js";import{t as d}from"./alert-CFUBsmUN.js";import{t as f}from"./route-error-fallback-C2OHu3JW.js";import{n as p,r as m,t as h}from"./route-module-Bm4sHkx9.js";import{t as g}from"./auth-layout-CFKu8bHI.js";import{n as _,t as v}from"./auth-footer-DgRsLHyD.js";import{r as y}from"./oauth-search-BtLPTIS7.js";var b=r();function x({search:e}){let{t}=i(),{data:r}=a(c),f=y(e);return(0,b.jsxs)(g,{children:[(0,b.jsx)(u,{subtitle:t(`setup2fa.subtitle`),title:t(`setup2fa.title`)}),(0,b.jsx)(d,{icon:l,type:`info`,children:t(`setup2fa.required`)}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[r.auth.password.enabled&&r.auth.password.totp.enabled&&(0,b.jsx)(o,{description:t(`setup2fa.totp.description`),icon:l,label:t(`setup2fa.totp.title`),render:(0,b.jsx)(n,{to:m(`/setup/totp`,f)})}),r.auth.passkey.enabled&&(0,b.jsx)(o,{description:t(`setup2fa.passkey.description`),icon:s,label:t(`setup2fa.passkey.title`),render:(0,b.jsx)(n,{to:m(`/setup/passkey`,{...f,passkey_name:`default`})})})]}),(0,b.jsx)(v,{children:(0,b.jsx)(_,{link:(0,b.jsx)(n,{to:m(`/login`,f),children:t(`setup2fa.backToLogin`)})})})]})}var S=t(function({error:e}){return(0,b.jsx)(h,{component:f,error:e})}),C=e(function({loaderData:e}){return(0,b.jsx)(p,{state:e.dehydratedState,children:(0,b.jsx)(x,{search:e.search})})});export{S as ErrorBoundary,C as default};
1
+ import{a as e,o as t}from"./components-DF4L3dSB.js";import{c as n}from"./toast-XXVYYXim.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{a as i}from"./api-CfCwvXbU.js";import{r as a}from"./text-CBHShrvS.js";import{t as o}from"./auth-choice-row-DNB3B1Vs.js";import{t as s}from"./fingerprint-pattern-AUfgwio5.js";import{n as c}from"./language-selector-Chn-k7Pw.js";import{t as l}from"./shield-check-2DKLuF9J.js";import{t as u}from"./auth-page-header-BVY4zRzF.js";import{t as d}from"./alert-DS8e0Gvg.js";import{t as f}from"./route-error-fallback-CRL2Et8O.js";import{n as p,r as m,t as h}from"./route-module-2foR49uh.js";import{t as g}from"./auth-layout-B4h13HhN.js";import{n as _,t as v}from"./auth-footer-LG_gGuJv.js";import{r as y}from"./oauth-search-DybZ6VWp.js";var b=r();function x({search:e}){let{t}=i(),{data:r}=a(c),f=y(e);return(0,b.jsxs)(g,{children:[(0,b.jsx)(u,{subtitle:t(`setup2fa.subtitle`),title:t(`setup2fa.title`)}),(0,b.jsx)(d,{icon:l,type:`info`,children:t(`setup2fa.required`)}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[r.auth.password.enabled&&r.auth.password.totp.enabled&&(0,b.jsx)(o,{description:t(`setup2fa.totp.description`),icon:l,label:t(`setup2fa.totp.title`),render:(0,b.jsx)(n,{to:m(`/setup/totp`,f)})}),r.auth.passkey.enabled&&(0,b.jsx)(o,{description:t(`setup2fa.passkey.description`),icon:s,label:t(`setup2fa.passkey.title`),render:(0,b.jsx)(n,{to:m(`/setup/passkey`,{...f,passkey_name:`default`})})})]}),(0,b.jsx)(v,{children:(0,b.jsx)(_,{link:(0,b.jsx)(n,{to:m(`/login`,f),children:t(`setup2fa.backToLogin`)})})})]})}var S=t(function({error:e}){return(0,b.jsx)(h,{component:f,error:e})}),C=e(function({loaderData:e}){return(0,b.jsx)(p,{state:e.dehydratedState,children:(0,b.jsx)(x,{search:e.search})})});export{S as ErrorBoundary,C as default};
@@ -0,0 +1 @@
1
+ import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,i as c,n as l,t as u}from"./api-CfCwvXbU.js";import{n as d,r as f,t as p}from"./text-CBHShrvS.js";import{t as m}from"./useMutation-BkuKGzks.js";import{t as h}from"./useQuery-BLm0XsTI.js";import{t as g}from"./mutationOptions-Dfvzj6n2.js";import{V as _}from"./select-C_WHBpl_.js";import{a as v,i as y,r as b,t as x}from"./shell-header-bar-Bg85QIAq.js";import{i as S,r as C}from"./NullStore-UyCsFQfz.js";import{t as w}from"./card-BaQElRNE.js";import{t as T}from"./circle-alert-BZCKPkRn.js";import{a as E,i as D,n as ee,r as O,t as k}from"./use-totp-setup-D7XZ6Nos.js";import{t as A}from"./auth-field-CDCz-y27.js";import{t as j}from"./fingerprint-pattern-AUfgwio5.js";import{t as M}from"./key-round-BlUAV-K9.js";import{n as N,r as P}from"./language-selector-Chn-k7Pw.js";import{n as F,t as I}from"./provider-mark-CCOkSxh7.js";import{n as te,r as ne,t as re}from"./logout-DpMjBzc5.js";import{t as L}from"./shield-check-2DKLuF9J.js";import{t as R}from"./trash-C7RyeTUJ.js";import{t as z}from"./triangle-alert-B0lTzZDi.js";import{t as ie}from"./auth-page-header-BVY4zRzF.js";import{t as ae}from"./link-button-DGt9hwk7.js";import{t as B}from"./alert-DS8e0Gvg.js";import{n as V,t as H}from"./modal-BDu41alh.js";import{t as oe}from"./initial-avatar-ByHiX-IF.js";import{t as U}from"./route-error-fallback-CRL2Et8O.js";import{r as W,t as G}from"./standard-schema-kM5DbC12.js";import{r as K}from"./FieldItemContext-B3N2qWH8.js";import{a as q,s as J}from"./schemas-B87iTMww.js";import{n as Y,t as se}from"./promise-EbDcmV0j.js";import{n as ce,r as le}from"./totp-4989Pb-o.js";import{t as ue}from"./badge-Cr0iG_iG.js";import{a as de,i as fe,n as pe,r as me}from"./passkey-CWcdr7Vy.js";import{t as he}from"./document-navigation-Cnp3Alf0.js";import{n as ge,t as _e}from"./route-module-2foR49uh.js";var ve={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};ve.node;var ye=_(ve),be={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};be.node;var xe=_(be),Se={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Se.node;var Ce=_(Se),we={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};we.node;var Te=_(we),X=e(t(),1),Z=a();function Ee({isConfigManaged:e,isDeletionEnabled:t,onDeleteClick:n}){let{t:r}=s();return t?(0,Z.jsxs)(w.Root,{className:`border-tinyrack-danger-border bg-tinyrack-danger-surface`,variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-danger-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,Z.jsx)(z,{"aria-hidden":!0,className:`size-tinyrack-lg text-tinyrack-danger-foreground`}),(0,Z.jsx)(w.Title,{className:`text-tinyrack-danger-foreground`,children:r(`profile.dangerZone.title`)})]}),(0,Z.jsx)(w.Description,{children:r(`profile.dangerZone.description`)})]}),(0,Z.jsx)(w.Content,{className:`px-tinyrack-lg py-tinyrack-md`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(p,{as:`p`,variant:`bodySm`,weight:`medium`,children:r(`profile.deleteAccount.title`)}),(0,Z.jsx)(p,{as:`p`,color:`muted`,variant:`caption`,children:r(e?`profile.deleteAccount.configManaged`:`profile.deleteAccount.description`)})]}),(0,Z.jsxs)(C,{appearance:`outline`,"data-testid":`profile-delete-account`,disabled:e,intent:`danger`,onClick:n,type:`button`,uiSize:`sm`,children:[(0,Z.jsx)(R,{"aria-hidden":!0,className:`size-tinyrack-lg`}),r(`profile.deleteAccount.button`)]})]})})]}):null}function De({providerId:e,iconUrl:t,className:n=`size-tinyrack-xl`}){return e===`google`||e===`github`||e===`apple`?(0,Z.jsx)(I,{"aria-hidden":!0,className:n,provider:e}):t?(0,Z.jsx)(`img`,{alt:``,className:n,src:t}):(0,Z.jsx)(F,{"aria-hidden":!0,className:n})}function Q({icon:e,active:t,title:n,status:r,note:i,actions:a}){let o;return o=(0,X.isValidElement)(e)?e:(0,Z.jsx)(e,{"aria-hidden":!0,className:`size-tinyrack-lg ${t?`text-tinyrack-success-foreground`:`text-tinyrack-text-muted`}`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg p-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-tinyrack-md`,children:[(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-tinyrack-md ${t?`bg-tinyrack-success-surface`:`bg-tinyrack-surface-muted`}`,children:o}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(p,{variant:`bodySm`,weight:`medium`,children:n}),(0,Z.jsx)(p,{color:`muted`,variant:`caption`,children:r}),i]})]}),a&&(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-tinyrack-xs`,children:a})]})}function Oe({providers:e,unlinkingProvider:t,getAuthorizeUrl:n,onUnlinkRequest:r}){let{t:i}=s();return e.length===0?null:(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:i(`profile.linkedAccounts.title`)}),(0,Z.jsx)(w.Description,{children:i(`profile.linkedAccounts.description`)})]}),(0,Z.jsx)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:e.map(e=>(0,Z.jsx)(Q,{actions:e.linked?(0,Z.jsx)(C,{appearance:`ghost`,intent:`danger`,loading:t===e.id,loadingLabel:i(`profile.linkedAccounts.unlinking`),onClick:()=>r(e),type:`button`,uiSize:`sm`,children:t===e.id?void 0:i(`profile.linkedAccounts.unlink`)}):(0,Z.jsx)(ae,{appearance:`outline`,intent:`neutral`,render:(0,Z.jsx)(`a`,{href:n(e.id,`link`,`/profile`)}),uiSize:`sm`,children:i(`profile.linkedAccounts.link`)}),active:e.linked,icon:(0,Z.jsx)(De,{className:`size-tinyrack-lg`,iconUrl:e.icon_url,providerId:e.id}),status:e.linked?i(`profile.linkedAccounts.connected`):i(`profile.linkedAccounts.notConnected`),title:e.display_name},e.id))})]})}function ke({passkeyCount:e,onOpenModal:t}){let{t:n}=s(),r=e>0;return(0,Z.jsx)(Q,{actions:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:()=>t(r?`manage`:`setup`),type:`button`,uiSize:`sm`,children:n(r?`profile.passkey.manage`:`profile.passkey.add`)}),active:r,icon:j,status:r?n(`profile.passkey.status.enabled`,{count:e}):n(`profile.passkey.status.disabled`),title:n(`profile.passkey.title`)})}function Ae({hasPassword:e,hasLinkedOAuth:t,isConfigManaged:n,hasSecondFactorOnly:r,onOpenModal:i}){let{t:a}=s();return(0,Z.jsx)(Q,{actions:n?void 0:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-change`,intent:`primary`,onClick:()=>i(`change`),type:`button`,uiSize:`sm`,children:a(`profile.password.change`)}),t?(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-remove`,intent:`danger`,onClick:()=>i(`remove`),type:`button`,uiSize:`sm`,children:a(`profile.password.remove`)}):null,!t&&r&&(0,Z.jsxs)(v.Root,{children:[(0,Z.jsx)(v.Trigger,{render:(0,Z.jsx)(C,{appearance:`ghost`,disabled:!0,type:`button`,uiSize:`sm`,children:a(`profile.password.remove`)})}),(0,Z.jsx)(v.Portal,{children:(0,Z.jsx)(v.Positioner,{children:(0,Z.jsx)(v.Popup,{className:`max-w-tinyrack-measure-lg rounded-tinyrack-md border border-tinyrack-border bg-tinyrack-surface p-tinyrack-md text-tinyrack-text text-tinyrack-xs shadow-tinyrack-overlay`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-tinyrack-sm`,children:[(0,Z.jsx)(E,{"aria-hidden":!0,className:`size-tinyrack-lg shrink-0 text-tinyrack-warning-foreground`}),(0,Z.jsx)(p,{variant:`caption`,children:a(`profile.password.removeDisabledReason`)})]})})})})]})]}):(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-set`,intent:`primary`,onClick:()=>i(`set`),type:`button`,uiSize:`sm`,children:a(`profile.password.set`)}),active:e,icon:M,note:n?(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-xs`,children:[(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-tinyrack-md shrink-0`}),(0,Z.jsx)(p,{as:`span`,color:`muted`,variant:`caption`,children:a(`profile.password.configManaged`)})]}):void 0,status:a(e?`profile.password.status.set`:`profile.password.status.notSet`),title:a(`profile.password.title`)})}function je({totpEnabled:e,recoveryCodesMissing:t,onOpenModal:n}){let{t:r}=s();return(0,Z.jsx)(Q,{actions:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-regenerate`,intent:`primary`,onClick:()=>n(`regenerate`),type:`button`,uiSize:`sm`,children:r(`profile.totp.regenerate`)}),(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-disable`,intent:`danger`,onClick:()=>n(`disable`),type:`button`,uiSize:`sm`,children:r(`profile.totp.disable`)})]}):(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-enable`,intent:`primary`,onClick:()=>n(`setup`),type:`button`,uiSize:`sm`,children:r(`profile.totp.enable`)}),active:e,icon:L,status:r(e?t?`profile.totp.status.recoveryCodesMissing`:`profile.totp.status.enabled`:`profile.totp.status.disabled`),title:r(`profile.totp.title`)})}var Me={error:T,warning:z,info:E};function $({variant:e,children:t}){return(0,Z.jsx)(B,{"data-testid":`alert-banner-${e}`,icon:Me[e],type:e,children:t})}function Ne({isOpen:e,onClose:t,providerName:n,isPending:r,onConfirm:i}){let{t:a}=s(),[o,c]=(0,X.useState)(null),l=()=>{r||(c(null),t())};return(0,Z.jsx)(H,{description:a(`profile.linkedAccounts.unlinkModal.description`,{provider:n}),icon:xe,isOpen:e,onClose:l,preventClose:r,title:a(`profile.linkedAccounts.unlinkModal.title`),variant:`destructive`,children:(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,children:[(0,Z.jsx)($,{variant:`warning`,children:a(`profile.linkedAccounts.unlinkModal.warning`,{provider:n})}),o&&(0,Z.jsx)($,{variant:`error`,children:o}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`unlink-oauth-cancel`,disabled:r,intent:`neutral`,onClick:l,type:`button`,uiSize:`sm`,children:a(`profile.linkedAccounts.unlinkModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`unlink-oauth-unlink`,disabled:r,intent:`danger`,loading:r,loadingLabel:a(`profile.linkedAccounts.unlinking`),onClick:async()=>{c(null);try{await i(),l()}catch{c(a(`profile.linkedAccounts.unlinkError`))}},type:`button`,uiSize:`sm`,children:a(`profile.linkedAccounts.unlink`)})]})]})})}function Pe({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(p,{className:`shrink-0`,color:`muted`,variant:`caption`,children:e}),(0,Z.jsx)(p,{truncate:!0,variant:`bodySm`,weight:`medium`,children:t})]})}function Fe({user:e}){let{t}=s();return(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:t(`profile.account.title`)}),(0,Z.jsx)(w.Description,{children:t(`profile.account.description`)})]}),(0,Z.jsxs)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:[(0,Z.jsx)(Pe,{label:t(`profile.id.label`),value:e.sub}),(0,Z.jsx)(Pe,{label:t(`profile.email.label`),value:e.email})]})]})}function Ie({children:e,headerActions:t}){return(0,Z.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-tinyrack-surface`,children:[(0,Z.jsx)(y,{}),(0,Z.jsx)(x,{actions:t,brand:!0}),(0,Z.jsx)(`main`,{className:`flex flex-1 justify-center px-tinyrack-lg py-tinyrack-xl`,children:(0,Z.jsx)(`div`,{className:`auth-enter flex w-full max-w-tinyrack-overlay-width-md flex-col gap-tinyrack-xl`,children:e})}),(0,Z.jsx)(b,{})]})}var Le=g({mutationFn:async e=>{let t=await u.api.user.password.$post({json:e});return l(t)}}),Re=g({mutationFn:async e=>{let t=await u.api.user.password.$put({json:e});return l(t)}}),ze=g({mutationFn:async e=>{let t=await u.api.user.password.$delete({json:e});return l(t)}});function Be({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),{data:i}=f(N),a=i.auth.password.policy,l=(0,X.useMemo)(()=>q({currentPassword:J().min(1,n(`validation.password.required`)),newPassword:J().min(a.min_length,n(`validation.password.min`,{count:a.min_length})).max(a.max_length,n(`validation.password.max`,{count:a.max_length})),confirmPassword:J()}).refine(e=>e.newPassword===e.confirmPassword,{message:n(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[a.max_length,a.min_length,n]),u=W({resolver:G(l),defaultValues:{currentPassword:``,newPassword:``,confirmPassword:``}}),d=m({...Re,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),p()}}),p=()=>{u.reset(),t()},h=u.handleSubmit(async e=>{try{await d.mutateAsync({current_password:e.currentPassword,new_password:e.newPassword})}catch(e){e instanceof c&&e.code===`INVALID_CURRENT_PASSWORD`?u.setError(`currentPassword`,{message:n(`profile.password.changeModal.invalidCurrent`)}):u.setError(`root`,{message:n(`profile.password.changeModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.changeModal.description`),icon:M,isOpen:e,onClose:p,title:n(`profile.password.changeModal.title`),children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:h,children:[(0,Z.jsx)(A,{error:u.formState.errors.currentPassword,errorTestId:`change-password-error-currentPassword`,id:`current-password`,label:n(`profile.password.changeModal.currentPassword`),placeholder:n(`profile.password.changeModal.currentPasswordPlaceholder`),...u.register(`currentPassword`),type:`password`}),(0,Z.jsx)(A,{error:u.formState.errors.newPassword,errorTestId:`change-password-error-newPassword`,id:`new-password-change`,label:n(`profile.password.changeModal.newPassword`),placeholder:n(`profile.password.changeModal.newPasswordPlaceholder`),...u.register(`newPassword`),type:`password`}),(0,Z.jsx)(A,{error:u.formState.errors.confirmPassword,errorTestId:`change-password-error-confirmPassword`,id:`confirm-password-change`,label:n(`profile.password.changeModal.confirmPassword`),placeholder:n(`profile.password.changeModal.confirmPasswordPlaceholder`),...u.register(`confirmPassword`),type:`password`}),u.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:u.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`change-password-cancel`,disabled:d.isPending,intent:`neutral`,onClick:p,type:`button`,uiSize:`sm`,children:n(`profile.password.changeModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`change-password-submit`,disabled:d.isPending,intent:`primary`,loading:d.isPending,loadingLabel:n(`profile.password.changeModal.submitting`),type:`submit`,uiSize:`sm`,children:d.isPending?void 0:n(`profile.password.changeModal.submit`)})]})]})})}var Ve=g({mutationFn:async()=>{let e=await u.api.user.$delete();return l(e)}});function He({isOpen:e,onClose:t,retentionDays:n}){let{t:i}=s(),a=r(),c=o(),l=(0,X.useMemo)(()=>q({confirmation:J().refine(e=>e.toLowerCase()===i(`profile.deleteAccount.modal.confirmPlaceholder`).toLowerCase(),{message:i(`validation.confirmText.mismatch`)})}),[i]),u=W({resolver:G(l),defaultValues:{confirmation:``}}),d=m({...Ve,onSuccess:async()=>{c.setQueryData(Y.queryKey,{user:null}),await se(),a(`/login`)}}),f=()=>{d.isPending||(u.reset(),t())},h=u.handleSubmit(async()=>{try{await d.mutateAsync()}catch{u.setError(`root`,{message:i(`profile.deleteAccount.error`)})}});return(0,Z.jsx)(H,{icon:R,isOpen:e,onClose:f,preventClose:d.isPending,title:i(`profile.deleteAccount.modal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:h,children:[(0,Z.jsxs)($,{variant:`error`,children:[(0,Z.jsx)(p,{as:`span`,variant:`bodySm`,children:i(`profile.deleteAccount.modal.description`,{days:n})}),(0,Z.jsx)(`br`,{}),(0,Z.jsx)(p,{as:`span`,className:`opacity-tinyrack-hover`,variant:`caption`,children:i(`profile.deleteAccount.modal.warning`)})]}),(0,Z.jsx)(A,{autoComplete:`off`,error:u.formState.errors.confirmation,errorTestId:`delete-account-error`,id:`delete-confirmation`,label:i(`profile.deleteAccount.modal.confirmLabel`),placeholder:i(`profile.deleteAccount.modal.confirmPlaceholder`),...u.register(`confirmation`),type:`text`}),u.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:u.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`delete-account-cancel`,disabled:d.isPending,intent:`neutral`,onClick:f,type:`button`,uiSize:`sm`,children:i(`profile.deleteAccount.modal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`delete-account-submit`,disabled:d.isPending,intent:`danger`,loading:d.isPending,loadingLabel:i(`profile.deleteAccount.modal.confirming`),type:`submit`,uiSize:`sm`,children:d.isPending?void 0:i(`profile.deleteAccount.modal.confirm`)})]})]})})}function Ue({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),i=(0,X.useMemo)(()=>q({code:J().length(6,n(`validation.totp.length`)).regex(/^\d{6}$/,n(`validation.totp.digits`))}),[n]),a=W({resolver:G(i),defaultValues:{code:``}}),l=m({...ce,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),u()}}),u=()=>{a.reset(),t()},d=a.handleSubmit(async e=>{try{await l.mutateAsync({code:e.code})}catch(e){if(e instanceof c&&e.code===`CANNOT_REMOVE_LAST_SECOND_FACTOR`){a.setError(`code`,{message:n(`profile.totp.disableModal.cannotRemoveLastSecondFactor`)});return}a.setError(`code`,{message:n(`profile.totp.disableModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.totp.disableModal.description`),icon:L,isOpen:e,onClose:u,title:n(`profile.totp.disableModal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:d,children:[(0,Z.jsx)($,{variant:`warning`,children:n(`profile.totp.disableModal.warning`)}),(0,Z.jsx)(A,{autoComplete:`one-time-code`,error:a.formState.errors.code,errorTestId:`disable-totp-error`,id:`disable-totp-code`,inputMode:`numeric`,label:n(`profile.totp.disableModal.codeLabel`),maxLength:6,pattern:`[0-9]*`,placeholder:`000000`,...a.register(`code`),type:`text`}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`disable-totp-cancel`,disabled:l.isPending,intent:`neutral`,onClick:u,type:`button`,uiSize:`sm`,children:n(`profile.totp.disableModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`disable-totp-submit`,disabled:l.isPending,intent:`danger`,loading:l.isPending,loadingLabel:n(`profile.totp.disableModal.disabling`),type:`submit`,uiSize:`sm`,children:l.isPending?void 0:n(`profile.totp.disableModal.disable`)})]})]})})}function We({isOpen:e,onClose:t,onAddNew:n}){let{t:r}=s(),i=o(),[a,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),{data:y,isLoading:b}=h({...me,enabled:e}),x=m({...pe,onSuccess:()=>{i.invalidateQueries({queryKey:P.passkeys()}),i.invalidateQueries({queryKey:Y.queryKey})},onSettled:()=>{d(null)}}),w=(0,X.useCallback)(()=>{l(null),d(null),g(null),v(null),t()},[t]),T=e=>{g(e.id),v(null)},E=()=>{g(null),v(null)},D=async e=>{d(e.id),g(null);try{await x.mutateAsync({id:e.id})}catch(e){if(e instanceof c&&e.code===`CANNOT_REMOVE_LAST_SECOND_FACTOR`){v(r(`profile.passkey.manageModal.cannotRemoveLastSecondFactor`));return}v(r(`profile.passkey.manageModal.deleteError`))}},ee=e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),O=y?.passkeys||[];return(0,Z.jsxs)(H,{icon:j,isOpen:e,onClose:w,size:`lg`,title:r(`profile.passkey.manageModal.title`),children:[(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-sm`,children:[_&&(0,Z.jsx)($,{variant:`error`,children:_}),b&&(0,Z.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,children:(0,Z.jsx)(S,{uiSize:`md`})}),!b&&O.length===0&&(0,Z.jsx)(p,{align:`center`,className:`py-tinyrack-xl`,color:`muted`,"data-testid":`passkeys-empty`,variant:`bodySm`,children:r(`profile.passkey.manageModal.noPasskeys`)}),!b&&O.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:O.map(e=>(0,Z.jsx)(Ge,{formatDate:ee,isConfirmingDelete:f===e.id,isDeleting:u===e.id,isEditing:a?.id===e.id,onCancelDelete:E,onCancelEdit:()=>l(null),onConfirmDelete:()=>D(e),onEdit:()=>l(e),onRequestDelete:()=>T(e),passkey:e},e.id))})]}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`manage-passkeys-close`,intent:`neutral`,onClick:w,type:`button`,uiSize:`sm`,children:r(`profile.passkey.manageModal.close`)}),(0,Z.jsx)(C,{"data-testid":`manage-passkeys-add-new`,intent:`primary`,onClick:()=>{w(),n()},type:`button`,uiSize:`sm`,children:r(`profile.passkey.manageModal.addNew`)})]})]})}function Ge({passkey:e,isDeleting:t,isEditing:n,isConfirmingDelete:r,onEdit:i,onCancelEdit:a,onRequestDelete:c,onConfirmDelete:l,onCancelDelete:u,formatDate:d}){let{t:f}=s(),h=o(),g=(0,X.useMemo)(()=>q({name:J().min(1,f(`validation.passkey.name.required`)).max(100,f(`validation.passkey.name.max`))}),[f]),_=W({resolver:G(g),defaultValues:{name:e.name||``}}),v=m({...de,onSuccess:()=>{h.invalidateQueries({queryKey:P.passkeys()}),a()}}),y=_.handleSubmit(async t=>{try{await v.mutateAsync({id:e.id,name:t.name})}catch{_.setError(`name`,{message:f(`profile.passkey.manageModal.renameError`)})}});return n?(0,Z.jsxs)(K,{className:`flex flex-col gap-tinyrack-xs rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-sm`,onSubmit:y,children:[(0,Z.jsx)(A,{"data-testid":`passkey-rename-input`,error:_.formState.errors.name,errorTestId:`passkey-rename-error`,hideLabel:!0,label:f(`profile.passkey.manageModal.nameLabel`),placeholder:f(`profile.passkey.manageModal.namePlaceholder`),..._.register(`name`),type:`text`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,disabled:v.isPending,onClick:()=>{_.reset(),a()},type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.cancelEdit`)}),(0,Z.jsx)(C,{disabled:v.isPending,intent:`primary`,type:`submit`,uiSize:`sm`,children:v.isPending?f(`profile.passkey.manageModal.saving`):f(`profile.passkey.manageModal.save`)})]})]}):r?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-tinyrack-md border border-tinyrack-danger-border bg-tinyrack-danger-surface p-tinyrack-sm text-tinyrack-danger-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,Z.jsx)(R,{className:`size-tinyrack-lg`}),(0,Z.jsx)(p,{color:`danger`,variant:`caption`,children:f(`profile.passkey.manageModal.deleteConfirmInline`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,onClick:u,type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.cancelEdit`)}),(0,Z.jsx)(C,{intent:`danger`,onClick:l,type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.delete`)})]})]}):(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-sm`,"data-testid":`passkey-item`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[e.device_type===`multiDevice`?(0,Z.jsx)(ye,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}):(0,Z.jsx)(Te,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(p,{variant:`caption`,weight:`medium`,children:e.name||f(`profile.passkey.manageModal.unnamedPasskey`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-xs`,children:[(0,Z.jsx)(p,{color:`muted`,variant:`caption`,children:f(`profile.passkey.manageModal.createdAt`,{date:d(e.created_at)})}),e.backed_up&&(0,Z.jsx)(ue,{uiSize:`md`,variant:`success`,children:f(`profile.passkey.manageModal.backedUp`)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":f(`profile.passkey.manageModal.rename`),onClick:i,type:`button`,uiSize:`sm`,children:(0,Z.jsx)(Ce,{className:`size-tinyrack-lg`})}),(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":f(`profile.passkey.manageModal.delete`),disabled:t,intent:`danger`,loading:t,onClick:c,type:`button`,uiSize:`sm`,children:t?void 0:(0,Z.jsx)(R,{className:`size-tinyrack-lg`})})]})]})}function Ke({isOpen:e,onClose:t}){let{t:n}=s(),i=r(),a=o(),{data:l}=f(N),[u,d]=(0,X.useState)(`verify`),[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),v=m({...le,onSuccess:async e=>{h(e),d(`recovery`),await a.invalidateQueries({queryKey:Y.queryKey})}}),y=(0,X.useCallback)(()=>{d(`verify`),h(null),_(null),v.reset()},[v]),b=(0,X.useCallback)(()=>{y(),t()},[t,y]),x=(0,X.useCallback)(async e=>{_(null);try{await v.mutateAsync({code:e})}catch(e){if(e instanceof c){if(e.code===`INVALID_TOTP_CODE`)throw e;if(e.code===`UNAUTHORIZED`){a.setQueryData(Y.queryKey,{user:null}),await se(),i(`/login`);return}if(e.code===`TOTP_NOT_ENABLED`||e.code===`VALIDATION_ERROR`){await a.invalidateQueries({queryKey:Y.queryKey}),b();return}}_(n(`profile.totp.regenerateModal.unexpectedError`))}},[b,v,i,a,n]);return l.auth.password.totp.enabled?(0,Z.jsx)(H,{description:n(u===`verify`?`profile.totp.regenerateModal.description`:`profile.totp.regenerateModal.recoveryDescription`),icon:L,isOpen:e,onClose:b,preventClose:u===`recovery`,size:`sm`,title:n(u===`verify`?`profile.totp.regenerateModal.title`:`profile.totp.regenerateModal.recoveryTitle`),children:u===`verify`?(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg`,children:[g&&(0,Z.jsx)(`div`,{className:`mb-tinyrack-md`,children:(0,Z.jsx)($,{variant:`error`,children:g})}),(0,Z.jsx)(O,{invalidMessage:n(`profile.totp.regenerateModal.error`),isPending:v.isPending,onSubmit:x,pendingText:n(`profile.totp.regenerateModal.submitting`),submitLabel:n(`profile.totp.regenerateModal.submit`)})]}):(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(D,{onConfirm:b,recoveryCodes:p?.recovery_codes??[]})})}):null}function qe({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),i=(0,X.useMemo)(()=>q({currentPassword:J().min(1,n(`validation.password.required`))}),[n]),a=W({resolver:G(i),defaultValues:{currentPassword:``}}),l=m({...ze,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),u()}}),u=()=>{a.reset(),t()},d=a.handleSubmit(async e=>{try{await l.mutateAsync({current_password:e.currentPassword})}catch(e){if(e instanceof c){if(e.code===`INVALID_CURRENT_PASSWORD`){a.setError(`currentPassword`,{message:n(`profile.password.removeModal.invalidCurrent`)});return}if(e.code===`CANNOT_REMOVE_LAST_AUTH_METHOD`){a.setError(`root`,{message:n(`profile.password.removeModal.noOAuth`)});return}if(e.code===`CANNOT_REMOVE_PASSWORD_WITH_SECOND_FACTOR_ONLY`){a.setError(`root`,{message:n(`profile.password.removeModal.noOAuthWith2FA`)});return}}a.setError(`root`,{message:n(`profile.password.removeModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.removeModal.description`),icon:M,isOpen:e,onClose:u,title:n(`profile.password.removeModal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:d,children:[(0,Z.jsx)(A,{error:a.formState.errors.currentPassword,errorTestId:`remove-password-error`,id:`current-password-remove`,label:n(`profile.password.removeModal.currentPassword`),placeholder:n(`profile.password.removeModal.currentPasswordPlaceholder`),...a.register(`currentPassword`),type:`password`}),a.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:a.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`remove-password-cancel`,disabled:l.isPending,intent:`neutral`,onClick:u,type:`button`,uiSize:`sm`,children:n(`profile.password.removeModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`remove-password-submit`,disabled:l.isPending,intent:`danger`,loading:l.isPending,loadingLabel:n(`profile.password.removeModal.submitting`),type:`submit`,uiSize:`sm`,children:l.isPending?void 0:n(`profile.password.removeModal.submit`)})]})]})})}function Je({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),{data:i}=f(N),a=i.auth.password.policy,c=(0,X.useMemo)(()=>q({password:J().min(a.min_length,n(`validation.password.min`,{count:a.min_length})).max(a.max_length,n(`validation.password.max`,{count:a.max_length})),confirmPassword:J()}).refine(e=>e.password===e.confirmPassword,{message:n(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[a.max_length,a.min_length,n]),l=W({resolver:G(c),defaultValues:{password:``,confirmPassword:``}}),u=m({...Le,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),d()}}),d=()=>{l.reset(),t()},p=l.handleSubmit(async e=>{try{await u.mutateAsync({password:e.password})}catch{l.setError(`root`,{message:n(`profile.password.setModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.setModal.description`),icon:M,isOpen:e,onClose:d,title:n(`profile.password.setModal.title`),children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:p,children:[(0,Z.jsx)(A,{error:l.formState.errors.password,errorTestId:`set-password-error-password`,id:`new-password`,label:n(`profile.password.setModal.newPassword`),placeholder:n(`profile.password.setModal.newPasswordPlaceholder`),...l.register(`password`),type:`password`}),(0,Z.jsx)(A,{error:l.formState.errors.confirmPassword,errorTestId:`set-password-error-confirmPassword`,id:`confirm-password`,label:n(`profile.password.setModal.confirmPassword`),placeholder:n(`profile.password.setModal.confirmPasswordPlaceholder`),...l.register(`confirmPassword`),type:`password`}),l.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:l.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`set-password-cancel`,disabled:u.isPending,intent:`neutral`,onClick:d,type:`button`,uiSize:`sm`,children:n(`profile.password.setModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`set-password-submit`,disabled:u.isPending,intent:`primary`,loading:u.isPending,loadingLabel:n(`profile.password.setModal.submitting`),type:`submit`,uiSize:`sm`,children:u.isPending?void 0:n(`profile.password.setModal.submit`)})]})]})})}function Ye({isOpen:e,onClose:t,isRequired:n=!1,canSwitchToTotp:r=!1,onSwitchToTotp:i}){let{t:a}=s(),c=o(),[l,u]=(0,X.useState)(`name`),[d,f]=(0,X.useState)(null),h=(0,X.useMemo)(()=>q({name:J().max(100,a(`validation.passkey.name.max`)).optional().transform(e=>e?.trim()||void 0)}),[a]),g=W({resolver:G(h),defaultValues:{name:``}}),_=m({...fe,onSuccess:()=>{c.invalidateQueries({queryKey:P.passkeys()}),c.invalidateQueries({queryKey:Y.queryKey}),v()},onError:e=>{u(`name`),e.name===`NotAllowedError`?f(a(`profile.passkey.setupModal.cancelled`)):f(a(`profile.passkey.setupModal.error`))}}),v=(0,X.useCallback)(()=>{g.reset(),u(`name`),f(null),t()},[g,t]),y=g.handleSubmit(async e=>{u(`register`),f(null);try{await _.mutateAsync({name:e.name})}catch{}}),b=_.isPending;return(0,Z.jsxs)(H,{description:n?a(`profile.passkey.setupModal.requiredDescription`):void 0,icon:j,isOpen:e,onClose:v,preventClose:n,size:`sm`,title:a(`profile.passkey.setupModal.title`),children:[l===`name`&&(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:y,children:[(0,Z.jsx)(p,{as:`p`,color:`muted`,variant:`caption`,children:a(`profile.passkey.setupModal.description`)}),d&&(0,Z.jsx)($,{variant:`error`,children:d}),(0,Z.jsx)(A,{error:g.formState.errors.name,errorTestId:`setup-passkey-error`,hint:a(`profile.passkey.setupModal.nameHint`),id:`passkey-name`,label:a(`profile.passkey.setupModal.nameLabel`),placeholder:a(`profile.passkey.setupModal.namePlaceholder`),...g.register(`name`),type:`text`}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`setup-passkey-cancel`,intent:`neutral`,onClick:v,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`setup-passkey-continue`,intent:`primary`,type:`submit`,uiSize:`sm`,children:a(`profile.passkey.setupModal.continue`)})]}),r&&i&&(0,Z.jsx)(p,{align:`center`,as:`p`,className:`mt-tinyrack-sm`,variant:`caption`,children:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:i,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.switchToTotp`)})})]}),l===`register`&&(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-md py-tinyrack-xl`,"data-testid":`setup-passkey-loading`,children:[(0,Z.jsx)(S,{uiSize:`md`}),(0,Z.jsx)(p,{align:`center`,as:`p`,color:`muted`,variant:`caption`,children:a(`profile.passkey.setupModal.waitingForDevice`)})]}),(0,Z.jsx)(V,{children:(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`setup-passkey-cancel`,disabled:b,intent:`neutral`,onClick:v,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.cancel`)})})]})]})}function Xe({isOpen:e,onClose:t,isRequired:n=!1,canSwitchToPasskey:r=!1,onSwitchToPasskey:i}){let{t:a}=s(),{step:o,setupData:c,recoveryCodes:l,isSetupPending:u,isVerifyPending:d,isConfirmPending:f,startSetup:m,verify:h,goToVerify:g,goToQr:_,confirmRecoveryCodes:v,reset:y}=k({autoStart:!1,onConfirmSuccess:()=>{y(),t()}}),b=(0,X.useCallback)(()=>{y(),t()},[t,y]),x=(0,X.useCallback)(()=>{!c&&!u&&m()},[c,u,m]);e&&!c&&!u&&o!==`error`&&x();let w=(0,X.useCallback)(async e=>{await h(e)},[h]),T=a(o===`recovery`?`setupTotp.recoveryCodes.title`:`profile.totp.setupModal.title`);return(0,Z.jsxs)(H,{description:n?a(`profile.totp.setupModal.requiredDescription`):void 0,icon:L,isOpen:e,onClose:b,preventClose:n||o===`recovery`,size:`sm`,title:T,children:[u&&(0,Z.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,"data-testid":`setup-totp-loading`,children:(0,Z.jsx)(S,{uiSize:`md`})}),o===`error`&&(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,children:[(0,Z.jsx)($,{variant:`error`,children:a(`profile.totp.setupModal.setupError`)}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,intent:`neutral`,onClick:b,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.cancel`)}),(0,Z.jsx)(C,{intent:`primary`,onClick:m,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.retry`)})]})]}),c&&o===`qr`&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(ee,{additionalActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(V,{children:(0,Z.jsx)(C,{appearance:`outline`,intent:`neutral`,onClick:b,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.cancel`)})}),r&&i&&(0,Z.jsx)(p,{align:`center`,as:`p`,className:`mt-tinyrack-sm`,variant:`caption`,children:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:i,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.switchToPasskey`)})})]}),onNext:g,setupData:c})}),c&&o===`verify`&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(O,{isPending:d,onBack:_,onSubmit:w})}),o===`recovery`&&l.length>0&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(D,{isLoading:f,onConfirm:v,recoveryCodes:l})})]})}var Ze=(e=>d({queryKey:P.oauth.accounts(),queryFn:async()=>{let t=await e.api.user[`oauth-accounts`].$get();return l(t)}}))(u),Qe=g({mutationFn:async e=>{let t=await u.api.oauth[`:provider`].$delete({param:{provider:e}});return l(t)}});function $e(e,t=`login`,n){let r=new URLSearchParams({mode:t});return n&&r.set(`return_url`,n),`/api/oauth/${encodeURIComponent(e)}/authorize?${r.toString()}`}var et={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`};function tt(e){return(0,Z.jsx)(U,{...e,onUnauthorized:()=>{he(`/login`)}})}function nt({search:e}){let{t}=s(),n=r(),i=o(),a=e.oauth_error,c=a?t(et[a]??`oauth.error.failed`):void 0,[l,u]=(0,X.useState)(null),[d,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,E]=(0,X.useState)(!1),{data:D}=f(Y),{data:ee}=f(Ze),{data:O}=f(N),k=m({...re,onSuccess:async()=>{i.setQueryData(Y.queryKey,{user:null}),await se(),n(`/login`)},onSettled:()=>{i.invalidateQueries({queryKey:Y.queryKey})}}),A=m({...Qe,onSuccess:()=>{i.invalidateQueries({queryKey:Ze.queryKey})},onSettled:()=>{u(null)}}),j=async()=>{d&&(u(d.id),await A.mutateAsync(d.id))};if(!D.user)return null;let M=D.user,P=ee.available_providers,F=P.some(e=>e.linked),I=M.managed_by===`config`,te=O.auth.password,L=O.auth.passkey,R=te.totp.enabled,z=L.enabled,ae=O.account_deletion.enabled,V=O.account_deletion.retention,H=(()=>{let e=V.match(/^(\d+)([dmy])$/);if(!e)return 30;let t=parseInt(e[1],10);switch(e[2]){case`d`:return t;case`m`:return t*30;case`y`:return t*365;default:return 30}})(),U=!I&&R,W=!I&&z,G=P.length>0;return(0,Z.jsxs)(Ie,{headerActions:(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":t(`profile.logout`),"data-testid":`profile-logout`,disabled:k.isPending,loading:k.isPending,onClick:()=>k.mutate(),type:`button`,uiSize:`sm`,children:k.isPending?void 0:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,Z.jsx)(p,{as:`span`,className:`hidden sm:inline`,variant:`bodySm`,children:t(`profile.logout`)})]})}),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-lg`,children:[(0,Z.jsx)(oe,{email:M.email,size:`lg`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(ie,{title:t(`profile.title`)}),(0,Z.jsx)(p,{as:`p`,color:`muted`,"data-testid":`profile-user-email`,truncate:!0,variant:`bodySm`,children:M.email})]})]}),c&&(0,Z.jsx)(B,{icon:T,type:`error`,children:c}),M&&(0,Z.jsx)(Fe,{user:M}),(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:t(`profile.security.title`)}),(0,Z.jsx)(w.Description,{children:t(`profile.security.description`)})]}),U&&M.totp_recovery_codes_missing&&(0,Z.jsx)(`div`,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,"data-testid":`profile-totp-recovery-warning`,children:(0,Z.jsx)(B,{icon:T,type:`warning`,children:t(`profile.totp.recoveryCodesMissing`)})}),(0,Z.jsxs)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:[(0,Z.jsx)(Ae,{hasLinkedOAuth:F,hasPassword:M.has_password,hasSecondFactorOnly:M.has_password&&!F&&(M.totp_registered||M.passkey_count>0),isConfigManaged:I,onOpenModal:_}),U&&(0,Z.jsx)(je,{onOpenModal:y,recoveryCodesMissing:M.totp_recovery_codes_missing,totpEnabled:M.totp_registered}),W&&(0,Z.jsx)(ke,{onOpenModal:x,passkeyCount:M.passkey_count})]})]}),G&&(0,Z.jsx)(Oe,{getAuthorizeUrl:$e,onUnlinkRequest:e=>h({id:e.id,name:e.display_name}),providers:P,unlinkingProvider:l}),(0,Z.jsx)(Ee,{isConfigManaged:I,isDeletionEnabled:ae,onDeleteClick:()=>E(!0)}),(0,Z.jsx)(Je,{isOpen:g===`set`,onClose:()=>_(null)}),(0,Z.jsx)(Be,{isOpen:g===`change`,onClose:()=>_(null)}),(0,Z.jsx)(qe,{isOpen:g===`remove`,onClose:()=>_(null)}),(0,Z.jsx)(Xe,{isOpen:v===`setup`,onClose:()=>y(null)}),(0,Z.jsx)(Ue,{isOpen:v===`disable`,onClose:()=>y(null)}),(0,Z.jsx)(Ke,{isOpen:v===`regenerate`,onClose:()=>y(null)}),(0,Z.jsx)(Ye,{isOpen:b===`setup`,onClose:()=>x(null)}),(0,Z.jsx)(We,{isOpen:b===`manage`,onAddNew:()=>x(`setup`),onClose:()=>x(null)}),(0,Z.jsx)(Ne,{isOpen:d!==null,isPending:A.isPending,onClose:()=>h(null),onConfirm:j,providerName:d?.name??``}),(0,Z.jsx)(He,{isOpen:S,onClose:()=>E(!1),retentionDays:H})]})}var rt=i(function({error:e}){return(0,Z.jsx)(_e,{component:tt,error:e})}),it=n(function({loaderData:e}){return(0,Z.jsx)(ge,{state:e.dehydratedState,children:(0,Z.jsx)(nt,{search:e.search})})});export{rt as ErrorBoundary,it as default};
@@ -0,0 +1 @@
1
+ import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s}from"./api-CfCwvXbU.js";import{r as c}from"./text-CBHShrvS.js";import{t as l}from"./useMutation-BkuKGzks.js";import{r as u}from"./NullStore-UyCsFQfz.js";import{n as d}from"./language-selector-Chn-k7Pw.js";import{t as f}from"./triangle-alert-B0lTzZDi.js";import{t as p}from"./auth-page-header-BVY4zRzF.js";import{t as m}from"./alert-DS8e0Gvg.js";import{t as h}from"./route-error-fallback-CRL2Et8O.js";import{r as g,t as _}from"./standard-schema-kM5DbC12.js";import{r as v}from"./FieldItemContext-B3N2qWH8.js";import{a as y,i as b,n as x}from"./schemas-B87iTMww.js";import{n as S,t as C}from"./promise-EbDcmV0j.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-2foR49uh.js";import{t as D}from"./auth-layout-B4h13HhN.js";import{t as O}from"./labeled-separator-JGa2pO6H.js";import{t as k}from"./sanitized-rich-text-uZcpKo6H.js";import{n as A,r as j,t as M}from"./terms-DV0oDTRf.js";var N=e(t(),1),P=a();function F(e){return(0,P.jsx)(h,{...e,onUnauthorized:()=>{w(`/login`)}})}function I({search:e}){let{t,i18n:n}=s(),i=r(),a=o(),{data:h}=c(d),T=e.lang??n.language,E=c(M(T)),F=h.registration.signup_notice?.[T]??h.registration.signup_notice?.[h.i18n.fallback_language],I=(0,N.useMemo)(()=>E.data.terms.filter(e=>e.consentMode===`explicit`),[E.data.terms]),L=(0,N.useMemo)(()=>E.data.terms.filter(e=>e.consentMode===`implicit`),[E.data.terms]),R=I.length>0,z=(0,N.useMemo)(()=>y({termsConsents:y(Object.fromEntries(I.map(e=>[e.id,e.required?b(!0,{message:t(`validation.terms.required`)}):x()])))}),[t,I]),{handleSubmit:B,control:V,setValue:H,formState:{errors:U}}=g({defaultValues:{termsConsents:Object.fromEntries(I.map(e=>[e.id,!(!e.userConsent?.agreed||e.userConsent.requiresUpdate)]))},resolver:_(z),mode:`onChange`}),W=l({...A,onSuccess:async()=>{await a.invalidateQueries({queryKey:S.queryKey}),await a.fetchQuery(S),await C(),e.redirect?w(e.redirect):i(`/profile`)}});return(0,P.jsxs)(D,{width:`wide`,children:[(0,P.jsx)(p,{title:t(`terms.title`)}),F&&(0,P.jsx)(k,{html:F,variant:`notice`}),F&&R&&(0,P.jsx)(O,{label:t(`terms.additionalOptionalConsent`)}),(0,P.jsxs)(v,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:B(t=>{let n=Object.entries(t.termsConsents).map(([e,t])=>({termsId:e,agreed:t,consentType:`explicit`})),r=L.map(e=>({termsId:e.id,agreed:!0,consentType:`implicit`}));W.mutate({consents:[...n,...r],...e.registration_token&&{registrationToken:e.registration_token}})}),children:[R&&(0,P.jsx)(j,{control:V,disabled:W.isPending,errors:U,setValue:H,terms:I}),W.isError&&(0,P.jsx)(m,{icon:f,type:`error`,children:t(`terms.error.submitFailed`)}),(0,P.jsx)(`div`,{className:`sticky bottom-0 flex gap-tinyrack-sm border-tinyrack-border border-t-tinyrack-default bg-tinyrack-surface py-tinyrack-md`,children:(0,P.jsx)(u,{className:`w-full`,intent:`primary`,loading:W.isPending,loadingLabel:t(`terms.submit`),type:`submit`,uiSize:`lg`,children:t(`terms.submit`)})})]})]})}var L=i(function({error:e}){return(0,P.jsx)(E,{component:F,error:e})}),R=n(function({loaderData:e}){return(0,P.jsx)(T,{state:e.dehydratedState,children:(0,P.jsx)(I,{search:e.search})})});export{L as ErrorBoundary,R as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n,f as r}from"./components-C1SipCbb.js";import{c as i}from"./toast-_zV1SGz6.js";import{t as a}from"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s,i as c}from"./api-0SzZx6X7.js";import{t as l}from"./text-CGN4ZtUZ.js";import{t as u}from"./useMutation-C4CmK9Sb.js";import{r as d}from"./NullStore-BxU9yW8l.js";import{t as f}from"./circle-alert-DGTJ9B9k.js";import{t as p}from"./auth-page-header-D5Z-EA6V.js";import{t as m}from"./alert-CFUBsmUN.js";import{r as h,t as g}from"./standard-schema-C8Td_miB.js";import{r as _}from"./FieldItemContext-CPjig163.js";import{a as v,s as y}from"./schemas-Dxi9xZo6.js";import{n as b,t as x}from"./promise-CFWkfv2A.js";import{o as S}from"./totp-BW4BoCpi.js";import{t as C}from"./pin-input-DtemAOnm.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,r as E}from"./route-module-Bm4sHkx9.js";import{t as D}from"./auth-layout-CFKu8bHI.js";import{n as O,t as k}from"./auth-footer-DgRsLHyD.js";import{t as A}from"./labeled-separator-DkexQjxp.js";import{a as j,r as M,t as N}from"./oauth-search-BtLPTIS7.js";var P=e(t(),1),F=a(),I={SECOND_FACTOR_SESSION_EXPIRED:`SECOND_FACTOR_SESSION_EXPIRED`,INVALID_TOTP_CODE:`INVALID_TOTP_CODE`,TOTP_NOT_ENABLED:`TOTP_NOT_ENABLED`},L=5;function R({search:e}){let{t}=s(),n=r(),a=o(),T=(0,P.useRef)(null),[R,z]=(0,P.useState)(!1),[B,V]=(0,P.useState)(L),H=(0,P.useMemo)(()=>v({code:y().length(6,t(`validation.totp.length`)).regex(/^\d{6}$/,t(`validation.totp.digits`))}),[t]),U=u({...S,onSuccess:async t=>{a.setQueryData(b.queryKey,{user:t.user}),await x(),j(e)?w(N(e)):n(`/profile`)},onSettled:()=>{a.invalidateQueries({queryKey:b.queryKey})}}),{setValue:W,setError:G,handleSubmit:K,watch:q,formState:{errors:J}}=h({defaultValues:{code:``},resolver:g(H)}),Y=q(`code`),X=(0,P.useCallback)(()=>{n(E(`/login`,M(e)))},[n,e]);(0,P.useEffect)(()=>{if(!R)return;let e=setInterval(()=>{V(t=>t<=1?(clearInterval(e),X(),0):t-1)},1e3);return()=>clearInterval(e)},[R,X]);let Z=async e=>{try{await U.mutateAsync(e)}catch(e){if(e instanceof c)switch(e.code){case I.SECOND_FACTOR_SESSION_EXPIRED:z(!0),V(L);return;case I.TOTP_NOT_ENABLED:X();return;case I.INVALID_TOTP_CODE:G(`code`,{type:`manual`,message:t(`verifyTotp.error.invalid`)}),W(`code`,``),T.current?.focus();return}G(`code`,{type:`manual`,message:t(`verifyTotp.error.invalid`)}),W(`code`,``),T.current?.focus()}};return(0,F.jsxs)(D,{children:[(0,F.jsx)(p,{subtitle:t(`verifyTotp.subtitle`),title:t(`verifyTotp.title`)}),R&&(0,F.jsx)(m,{"data-testid":`totp-verify-session-expired`,icon:f,type:`warning`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-start gap-tinyrack-3xs`,children:[(0,F.jsx)(l,{as:`span`,variant:`bodySm`,children:t(`verifyTotp.error.expired`)}),(0,F.jsx)(l,{as:`span`,color:`muted`,variant:`caption`,children:t(`verifyTotp.redirecting`,{seconds:B})}),(0,F.jsx)(d,{appearance:`ghost`,intent:`neutral`,onClick:X,type:`button`,uiSize:`sm`,children:t(`verifyTotp.redirectNow`)})]})}),(0,F.jsxs)(_,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:K(Z),children:[(0,F.jsx)(C,{autoFocus:!0,disabled:R,error:J.code,length:6,onChange:e=>W(`code`,e),onComplete:()=>K(Z)(),ref:T,value:Y}),R?(0,F.jsx)(d,{className:`w-full`,disabled:!0,intent:`primary`,type:`button`,uiSize:`lg`,children:t(`verifyTotp.submit`)}):(0,F.jsx)(d,{className:`w-full`,intent:`primary`,loading:U.isPending,loadingLabel:t(`verifyTotp.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyTotp.submit`)})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,F.jsx)(A,{label:t(`common.or`)}),(0,F.jsx)(d,{appearance:`ghost`,className:`w-full`,"data-testid":`totp-verify-recovery-link`,intent:`neutral`,onClick:()=>n(E(`/verify/totp/recovery`,M(e))),type:`button`,uiSize:`lg`,children:t(`verifyTotp.useRecoveryCode`)})]}),(0,F.jsx)(k,{children:(0,F.jsx)(O,{link:(0,F.jsx)(i,{to:E(`/login`,M(e)),children:t(`verifyTotp.backToLogin`)})})})]})}var z=n(function({loaderData:e}){return(0,F.jsx)(T,{state:e.dehydratedState,children:(0,F.jsx)(R,{search:e.search})})});export{z as default};
1
+ import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,i as c}from"./api-CfCwvXbU.js";import{t as l}from"./text-CBHShrvS.js";import{t as u}from"./useMutation-BkuKGzks.js";import{r as d}from"./NullStore-UyCsFQfz.js";import{t as f}from"./circle-alert-BZCKPkRn.js";import{t as p}from"./auth-page-header-BVY4zRzF.js";import{t as m}from"./alert-DS8e0Gvg.js";import{r as h,t as g}from"./standard-schema-kM5DbC12.js";import{r as _}from"./FieldItemContext-B3N2qWH8.js";import{a as v,s as y}from"./schemas-B87iTMww.js";import{n as b,t as x}from"./promise-EbDcmV0j.js";import{o as S}from"./totp-4989Pb-o.js";import{t as C}from"./pin-input-DiWLndxH.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,r as E}from"./route-module-2foR49uh.js";import{t as D}from"./auth-layout-B4h13HhN.js";import{n as O,t as k}from"./auth-footer-LG_gGuJv.js";import{t as A}from"./labeled-separator-JGa2pO6H.js";import{a as j,r as M,t as N}from"./oauth-search-DybZ6VWp.js";var P=e(t(),1),F=a(),I={SECOND_FACTOR_SESSION_EXPIRED:`SECOND_FACTOR_SESSION_EXPIRED`,INVALID_TOTP_CODE:`INVALID_TOTP_CODE`,TOTP_NOT_ENABLED:`TOTP_NOT_ENABLED`},L=5;function R({search:e}){let{t}=s(),n=r(),a=o(),T=(0,P.useRef)(null),[R,z]=(0,P.useState)(!1),[B,V]=(0,P.useState)(L),H=(0,P.useMemo)(()=>v({code:y().length(6,t(`validation.totp.length`)).regex(/^\d{6}$/,t(`validation.totp.digits`))}),[t]),U=u({...S,onSuccess:async t=>{a.setQueryData(b.queryKey,{user:t.user}),await x(),j(e)?w(N(e)):n(`/profile`)},onSettled:()=>{a.invalidateQueries({queryKey:b.queryKey})}}),{setValue:W,setError:G,handleSubmit:K,watch:q,formState:{errors:J}}=h({defaultValues:{code:``},resolver:g(H)}),Y=q(`code`),X=(0,P.useCallback)(()=>{n(E(`/login`,M(e)))},[n,e]);(0,P.useEffect)(()=>{if(!R)return;let e=setInterval(()=>{V(t=>t<=1?(clearInterval(e),X(),0):t-1)},1e3);return()=>clearInterval(e)},[R,X]);let Z=async e=>{try{await U.mutateAsync(e)}catch(e){if(e instanceof c)switch(e.code){case I.SECOND_FACTOR_SESSION_EXPIRED:z(!0),V(L);return;case I.TOTP_NOT_ENABLED:X();return;case I.INVALID_TOTP_CODE:G(`code`,{type:`manual`,message:t(`verifyTotp.error.invalid`)}),W(`code`,``),T.current?.focus();return}G(`code`,{type:`manual`,message:t(`verifyTotp.error.invalid`)}),W(`code`,``),T.current?.focus()}};return(0,F.jsxs)(D,{children:[(0,F.jsx)(p,{subtitle:t(`verifyTotp.subtitle`),title:t(`verifyTotp.title`)}),R&&(0,F.jsx)(m,{"data-testid":`totp-verify-session-expired`,icon:f,type:`warning`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-start gap-tinyrack-3xs`,children:[(0,F.jsx)(l,{as:`span`,variant:`bodySm`,children:t(`verifyTotp.error.expired`)}),(0,F.jsx)(l,{as:`span`,color:`muted`,variant:`caption`,children:t(`verifyTotp.redirecting`,{seconds:B})}),(0,F.jsx)(d,{appearance:`ghost`,intent:`neutral`,onClick:X,type:`button`,uiSize:`sm`,children:t(`verifyTotp.redirectNow`)})]})}),(0,F.jsxs)(_,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:K(Z),children:[(0,F.jsx)(C,{autoFocus:!0,disabled:R,error:J.code,length:6,onChange:e=>W(`code`,e),onComplete:()=>K(Z)(),ref:T,value:Y}),R?(0,F.jsx)(d,{className:`w-full`,disabled:!0,intent:`primary`,type:`button`,uiSize:`lg`,children:t(`verifyTotp.submit`)}):(0,F.jsx)(d,{className:`w-full`,intent:`primary`,loading:U.isPending,loadingLabel:t(`verifyTotp.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyTotp.submit`)})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,F.jsx)(A,{label:t(`common.or`)}),(0,F.jsx)(d,{appearance:`ghost`,className:`w-full`,"data-testid":`totp-verify-recovery-link`,intent:`neutral`,onClick:()=>n(E(`/verify/totp/recovery`,M(e))),type:`button`,uiSize:`lg`,children:t(`verifyTotp.useRecoveryCode`)})]}),(0,F.jsx)(k,{children:(0,F.jsx)(O,{link:(0,F.jsx)(i,{to:E(`/login`,M(e)),children:t(`verifyTotp.backToLogin`)})})})]})}var z=n(function({loaderData:e}){return(0,F.jsx)(T,{state:e.dehydratedState,children:(0,F.jsx)(R,{search:e.search})})});export{z as default};
@@ -1 +1 @@
1
- import{a as e,o as t,u as n}from"./components-C1SipCbb.js";import{t as r}from"./jsx-runtime-BFZ_fnNJ.js";import{a as i,n as a,t as o}from"./api-0SzZx6X7.js";import{n as s,r as c,t as l}from"./text-CGN4ZtUZ.js";import{t as u}from"./useMutation-C4CmK9Sb.js";import{t as d}from"./mutationOptions-Dfvzj6n2.js";import{n as f,r as p}from"./NullStore-BxU9yW8l.js";import{t as m}from"./card-CTv8DubK.js";import{r as h}from"./language-selector-CGXk9vW_.js";import{t as g}from"./shield-check-93-WFkyJ.js";import{t as _}from"./auth-page-header-D5Z-EA6V.js";import{t as v}from"./initial-avatar-D4aPMV9z.js";import{t as y}from"./route-error-fallback-C2OHu3JW.js";import{t as b}from"./document-navigation-Cnp3Alf0.js";import{n as x,t as S}from"./route-module-Bm4sHkx9.js";import{t as C}from"./auth-layout-CFKu8bHI.js";import{n as w}from"./oauth-search-BtLPTIS7.js";var T=(e,t)=>s({queryKey:h.consent(t.client_id,t.scope),queryFn:async()=>{let n=await e.api.consent.$get({query:{client_id:t.client_id,scope:t.scope}});return a(n)}}),E=e=>T(o,e),D=d({mutationFn:async e=>{let t=await o.api.consent.$post({json:e});return a(t)}}),O=r();function k(e){let t=n();return(0,O.jsx)(y,{...e,onUnauthorized:()=>{let e=new URLSearchParams(t.search),n=Object.fromEntries(e.entries());b(w(n))}})}function A({search:e}){let{t}=i(),n=c(E({client_id:e.client_id,scope:e.scope})),r=u({...D,onSuccess:e=>{b(e.redirect_url)}}),a=()=>{r.mutate({client_id:e.client_id,redirect_uri:e.redirect_uri,response_type:e.response_type,scope:e.scope,state:e.state,nonce:e.nonce,code_challenge:e.code_challenge,code_challenge_method:e.code_challenge_method,prompt:e.prompt,max_age:e.max_age,reauthenticated:e.reauthenticated,display:e.display,response_mode:e.response_mode,login_hint:e.login_hint,ui_locales:e.ui_locales,id_token_hint:e.id_token_hint,acr_values:e.acr_values,account_selected:e.account_selected,account_selection_state:e.account_selection_state,decision:`allow`})},o=()=>{r.mutate({client_id:e.client_id,redirect_uri:e.redirect_uri,response_type:e.response_type,scope:e.scope,state:e.state,nonce:e.nonce,code_challenge:e.code_challenge,code_challenge_method:e.code_challenge_method,prompt:e.prompt,max_age:e.max_age,reauthenticated:e.reauthenticated,display:e.display,response_mode:e.response_mode,login_hint:e.login_hint,ui_locales:e.ui_locales,id_token_hint:e.id_token_hint,acr_values:e.acr_values,account_selected:e.account_selected,account_selection_state:e.account_selection_state,decision:`deny`})},{client:s,scopes:d,user:h}=n.data;return(0,O.jsxs)(C,{width:`wide`,children:[(0,O.jsx)(_,{subtitle:t(`consent.subtitle`,{app:s.name}),title:t(`consent.title`)}),(0,O.jsx)(m.Root,{padding:`lg`,variant:`outlined`,children:(0,O.jsxs)(m.Content,{className:`flex items-center gap-tinyrack-md`,children:[(0,O.jsx)(v,{email:h.email,size:`sm`}),(0,O.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,O.jsx)(l,{color:`muted`,variant:`caption`,children:t(`consent.loggedInAs`)}),(0,O.jsx)(l,{"data-testid":`consent-user-email`,truncate:!0,variant:`body`,weight:`medium`,children:h.email})]})]})}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,O.jsx)(l,{as:`h3`,variant:`label`,children:t(`consent.permissions.title`)}),(0,O.jsx)(`ul`,{className:`flex flex-col gap-tinyrack-xs`,"data-testid":`consent-scope-list`,children:d.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-tinyrack-sm rounded-tinyrack-md bg-tinyrack-surface-muted px-tinyrack-md py-tinyrack-sm`,children:[(0,O.jsx)(g,{"aria-hidden":!0,className:`size-tinyrack-lg shrink-0 text-tinyrack-info-foreground`}),(0,O.jsx)(l,{variant:`body`,children:t(`consent.scope.${e.name}`,{defaultValue:e.description})})]},e.name))})]}),(0,O.jsxs)(`div`,{className:`sticky bottom-0 flex gap-tinyrack-sm border-tinyrack-border border-t-tinyrack-default bg-tinyrack-surface py-tinyrack-md`,children:[(0,O.jsxs)(p,{appearance:`outline`,className:`flex-1`,"data-testid":`consent-deny`,intent:`neutral`,loading:r.isPending,loadingLabel:t(`consent.deny`),onClick:o,type:`button`,uiSize:`lg`,children:[(0,O.jsx)(f,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`consent.deny`)]}),(0,O.jsxs)(p,{className:`flex-1`,"data-testid":`consent-allow`,intent:`primary`,loading:r.isPending,loadingLabel:t(`consent.allow`),onClick:a,type:`button`,uiSize:`lg`,children:[(0,O.jsx)(g,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`consent.allow`)]})]})]})}var j=t(function({error:e}){return(0,O.jsx)(S,{component:k,error:e})}),M=e(function({loaderData:e}){return(0,O.jsx)(x,{state:e.dehydratedState,children:(0,O.jsx)(A,{search:e.search})})});export{j as ErrorBoundary,M as default};
1
+ import{a as e,o as t,u as n}from"./components-DF4L3dSB.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{a as i,n as a,t as o}from"./api-CfCwvXbU.js";import{n as s,r as c,t as l}from"./text-CBHShrvS.js";import{t as u}from"./useMutation-BkuKGzks.js";import{t as d}from"./mutationOptions-Dfvzj6n2.js";import{n as f,r as p}from"./NullStore-UyCsFQfz.js";import{t as m}from"./card-BaQElRNE.js";import{r as h}from"./language-selector-Chn-k7Pw.js";import{t as g}from"./shield-check-2DKLuF9J.js";import{t as _}from"./auth-page-header-BVY4zRzF.js";import{t as v}from"./initial-avatar-ByHiX-IF.js";import{t as y}from"./route-error-fallback-CRL2Et8O.js";import{t as b}from"./document-navigation-Cnp3Alf0.js";import{n as x,t as S}from"./route-module-2foR49uh.js";import{t as C}from"./auth-layout-B4h13HhN.js";import{n as w}from"./oauth-search-DybZ6VWp.js";var T=(e,t)=>s({queryKey:h.consent(t.client_id,t.scope),queryFn:async()=>{let n=await e.api.consent.$get({query:{client_id:t.client_id,scope:t.scope}});return a(n)}}),E=e=>T(o,e),D=d({mutationFn:async e=>{let t=await o.api.consent.$post({json:e});return a(t)}}),O=r();function k(e){let t=n();return(0,O.jsx)(y,{...e,onUnauthorized:()=>{let e=new URLSearchParams(t.search),n=Object.fromEntries(e.entries());b(w(n))}})}function A({search:e}){let{t}=i(),n=c(E({client_id:e.client_id,scope:e.scope})),r=u({...D,onSuccess:e=>{b(e.redirect_url)}}),a=()=>{r.mutate({client_id:e.client_id,redirect_uri:e.redirect_uri,response_type:e.response_type,scope:e.scope,state:e.state,nonce:e.nonce,code_challenge:e.code_challenge,code_challenge_method:e.code_challenge_method,prompt:e.prompt,max_age:e.max_age,reauthenticated:e.reauthenticated,display:e.display,response_mode:e.response_mode,login_hint:e.login_hint,ui_locales:e.ui_locales,id_token_hint:e.id_token_hint,acr_values:e.acr_values,account_selected:e.account_selected,account_selection_state:e.account_selection_state,decision:`allow`})},o=()=>{r.mutate({client_id:e.client_id,redirect_uri:e.redirect_uri,response_type:e.response_type,scope:e.scope,state:e.state,nonce:e.nonce,code_challenge:e.code_challenge,code_challenge_method:e.code_challenge_method,prompt:e.prompt,max_age:e.max_age,reauthenticated:e.reauthenticated,display:e.display,response_mode:e.response_mode,login_hint:e.login_hint,ui_locales:e.ui_locales,id_token_hint:e.id_token_hint,acr_values:e.acr_values,account_selected:e.account_selected,account_selection_state:e.account_selection_state,decision:`deny`})},{client:s,scopes:d,user:h}=n.data;return(0,O.jsxs)(C,{width:`wide`,children:[(0,O.jsx)(_,{subtitle:t(`consent.subtitle`,{app:s.name}),title:t(`consent.title`)}),(0,O.jsx)(m.Root,{padding:`lg`,variant:`outlined`,children:(0,O.jsxs)(m.Content,{className:`flex items-center gap-tinyrack-md`,children:[(0,O.jsx)(v,{email:h.email,size:`sm`}),(0,O.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,O.jsx)(l,{color:`muted`,variant:`caption`,children:t(`consent.loggedInAs`)}),(0,O.jsx)(l,{"data-testid":`consent-user-email`,truncate:!0,variant:`body`,weight:`medium`,children:h.email})]})]})}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,O.jsx)(l,{as:`h3`,variant:`label`,children:t(`consent.permissions.title`)}),(0,O.jsx)(`ul`,{className:`flex flex-col gap-tinyrack-xs`,"data-testid":`consent-scope-list`,children:d.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-tinyrack-sm rounded-tinyrack-md bg-tinyrack-surface-muted px-tinyrack-md py-tinyrack-sm`,children:[(0,O.jsx)(g,{"aria-hidden":!0,className:`size-tinyrack-lg shrink-0 text-tinyrack-info-foreground`}),(0,O.jsx)(l,{variant:`body`,children:t(`consent.scope.${e.name}`,{defaultValue:e.description})})]},e.name))})]}),(0,O.jsxs)(`div`,{className:`sticky bottom-0 flex gap-tinyrack-sm border-tinyrack-border border-t-tinyrack-default bg-tinyrack-surface py-tinyrack-md`,children:[(0,O.jsxs)(p,{appearance:`outline`,className:`flex-1`,"data-testid":`consent-deny`,intent:`neutral`,loading:r.isPending,loadingLabel:t(`consent.deny`),onClick:o,type:`button`,uiSize:`lg`,children:[(0,O.jsx)(f,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`consent.deny`)]}),(0,O.jsxs)(p,{className:`flex-1`,"data-testid":`consent-allow`,intent:`primary`,loading:r.isPending,loadingLabel:t(`consent.allow`),onClick:a,type:`button`,uiSize:`lg`,children:[(0,O.jsx)(g,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`consent.allow`)]})]})]})}var j=t(function({error:e}){return(0,O.jsx)(S,{component:k,error:e})}),M=e(function({loaderData:e}){return(0,O.jsx)(x,{state:e.dehydratedState,children:(0,O.jsx)(A,{search:e.search})})});export{j as ErrorBoundary,M as default};
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n,f as r,o as i}from"./components-C1SipCbb.js";import{t as a}from"./toast-_zV1SGz6.js";import{t as o}from"./jsx-runtime-BFZ_fnNJ.js";import{L as s,a as c,n as l,t as u}from"./api-0SzZx6X7.js";import{r as d,t as f}from"./text-CGN4ZtUZ.js";import{t as p}from"./useMutation-C4CmK9Sb.js";import{t as m}from"./mutationOptions-Dfvzj6n2.js";import{i as h,r as g}from"./NullStore-BxU9yW8l.js";import{t as _}from"./circle-check-CGasu2tI.js";import{t as v}from"./auth-field-1EM9pnWe.js";import{t as y}from"./key-round-DgCbGqQL.js";import{n as b}from"./language-selector-CGXk9vW_.js";import{t as x}from"./mail-tgQpWyoC.js";import{t as S}from"./auth-page-header-D5Z-EA6V.js";import{t as C}from"./alert-CFUBsmUN.js";import{t as w}from"./auth-outcome-B7tCCKZC.js";import{t as T}from"./route-error-fallback-C2OHu3JW.js";import{r as E,t as D}from"./standard-schema-C8Td_miB.js";import{r as O}from"./FieldItemContext-CPjig163.js";import{a as k,s as A}from"./schemas-Dxi9xZo6.js";import{n as j,t as M}from"./promise-CFWkfv2A.js";import{t as N}from"./document-navigation-Cnp3Alf0.js";import{n as P,r as F,t as I}from"./route-module-Bm4sHkx9.js";import{t as L}from"./auth-layout-CFKu8bHI.js";import{t as R}from"./labeled-separator-DkexQjxp.js";import{a as z,r as B,t as V}from"./oauth-search-BtLPTIS7.js";var H=e(t(),1),U=m({mutationFn:async e=>{let t=await u.api.auth.email.verify.$post({json:e});return l(t)}}),W=m({mutationFn:async e=>{let t=await u.api.auth.email.resend.$post({json:e,header:{}});return l(t)}}),G=o();function K({search:e}){let{t}=c(),n=r(),i=s(),o=(e,t)=>n(t?F(e,t):e),{token:l,email:u}=e,[m,T]=(0,H.useState)(!1),[P,I]=(0,H.useState)(!1),K=a.useToastManager(),{data:q}=d(b),J=(0,H.useMemo)(()=>k({token:A().min(1,t(`validation.token.required`))}),[t]),Y=p({...U,onSuccess:async t=>{let n=t.user;if(i.setQueryData(j.queryKey,{user:n}),await M(),n.second_factor_required){let t=[];return q.auth.password.totp.enabled&&t.push(`totp`),q.auth.passkey.enabled&&t.push(`passkey`),t.length===1?t[0]===`totp`?o(`/setup/totp`,B(e)):o(`/setup/passkey`,B(e)):o(`/setup/2fa`,B(e))}z(e)?N(V(e)):T(!0)},onSettled:()=>{i.invalidateQueries({queryKey:j.queryKey})}}),X=p({...W,onSuccess:()=>{K.add({title:t(`verifyEmail.resendSuccess`),type:`success`}),I(!0),setTimeout(()=>I(!1),5e3)}}),{register:Z,setError:Q,handleSubmit:$,formState:{errors:ee}}=E({defaultValues:{token:l||``},resolver:D(J)}),te=async e=>{try{await Y.mutateAsync(e)}catch{Q(`token`,{type:`manual`,message:t(`verifyEmail.error.invalidToken`)})}},ne=async()=>{if(u)try{await X.mutateAsync({email:u})}catch{}};return m?(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{"data-testid":`alert-success`,children:(0,G.jsx)(w,{description:(0,G.jsxs)(G.Fragment,{children:[t(`verifyEmail.success.subtitle`),(0,G.jsx)(`br`,{}),t(`verifyEmail.success.description`)]}),icon:_,title:t(`verifyEmail.success.title`),tone:`success`,children:(0,G.jsx)(g,{className:`w-full`,"data-testid":`email-verify-go-profile`,intent:`primary`,onClick:()=>n(`/profile`),type:`button`,uiSize:`lg`,children:t(`verifyEmail.success.goToProfile`)})})})}):(0,G.jsxs)(L,{children:[(0,G.jsx)(S,{subtitle:t(`verifyEmail.subtitle`),title:t(`verifyEmail.title`)}),u&&(0,G.jsx)(C,{icon:x,type:`info`,children:(0,G.jsxs)(`span`,{className:`flex flex-col gap-tinyrack-3xs text-left`,children:[(0,G.jsx)(f,{variant:`body`,weight:`strong`,children:t(`register.success.subtitle`)}),(0,G.jsx)(f,{color:`muted`,variant:`caption`,children:t(`register.success.description`,{email:u})})]})}),(0,G.jsxs)(O,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:$(te),children:[(0,G.jsx)(v,{error:ee.token,icon:y,label:t(`verifyEmail.token.label`),placeholder:t(`verifyEmail.token.placeholder`),...Z(`token`),type:`text`}),(0,G.jsx)(g,{className:`w-full`,intent:`primary`,loading:Y.isPending,loadingLabel:t(`verifyEmail.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyEmail.submit`)})]}),u&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,G.jsx)(R,{}),(0,G.jsx)(g,{appearance:`ghost`,className:`w-full`,"data-testid":`email-verify-resend`,disabled:X.isPending||P,intent:`neutral`,onClick:ne,type:`button`,uiSize:`lg`,children:X.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(h,{uiSize:`sm`}),t(`verifyEmail.resending`)]}):t(`verifyEmail.resend`)})]})]})}var q=i(function({error:e}){return(0,G.jsx)(I,{component:T,error:e})}),J=n(function({loaderData:e}){return(0,G.jsx)(P,{state:e.dehydratedState,children:(0,G.jsx)(K,{search:e.search})})});export{q as ErrorBoundary,J as default};
1
+ import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c,n as l,t as u}from"./api-CfCwvXbU.js";import{r as d,t as f}from"./text-CBHShrvS.js";import{t as p}from"./useMutation-BkuKGzks.js";import{t as m}from"./mutationOptions-Dfvzj6n2.js";import{i as h,r as g}from"./NullStore-UyCsFQfz.js";import{t as _}from"./circle-check-BW_XcUlv.js";import{t as v}from"./auth-field-CDCz-y27.js";import{t as y}from"./key-round-BlUAV-K9.js";import{n as b}from"./language-selector-Chn-k7Pw.js";import{t as x}from"./mail-B2PK2vlI.js";import{t as S}from"./auth-page-header-BVY4zRzF.js";import{t as C}from"./alert-DS8e0Gvg.js";import{t as w}from"./auth-outcome-DyY0JgWG.js";import{t as T}from"./route-error-fallback-CRL2Et8O.js";import{r as E,t as D}from"./standard-schema-kM5DbC12.js";import{r as O}from"./FieldItemContext-B3N2qWH8.js";import{a as k,s as A}from"./schemas-B87iTMww.js";import{n as j,t as M}from"./promise-EbDcmV0j.js";import{t as N}from"./document-navigation-Cnp3Alf0.js";import{n as P,r as F,t as I}from"./route-module-2foR49uh.js";import{t as L}from"./auth-layout-B4h13HhN.js";import{t as R}from"./labeled-separator-JGa2pO6H.js";import{a as z,r as B,t as V}from"./oauth-search-DybZ6VWp.js";var H=e(t(),1),U=m({mutationFn:async e=>{let t=await u.api.auth.email.verify.$post({json:e});return l(t)}}),W=m({mutationFn:async e=>{let t=await u.api.auth.email.resend.$post({json:e,header:{}});return l(t)}}),G=o();function K({search:e}){let{t}=c(),n=r(),i=s(),o=(e,t)=>n(t?F(e,t):e),{token:l,email:u}=e,[m,T]=(0,H.useState)(!1),[P,I]=(0,H.useState)(!1),K=a.useToastManager(),{data:q}=d(b),J=(0,H.useMemo)(()=>k({token:A().min(1,t(`validation.token.required`))}),[t]),Y=p({...U,onSuccess:async t=>{let n=t.user;if(i.setQueryData(j.queryKey,{user:n}),await M(),n.second_factor_required){let t=[];return q.auth.password.totp.enabled&&t.push(`totp`),q.auth.passkey.enabled&&t.push(`passkey`),t.length===1?t[0]===`totp`?o(`/setup/totp`,B(e)):o(`/setup/passkey`,B(e)):o(`/setup/2fa`,B(e))}z(e)?N(V(e)):T(!0)},onSettled:()=>{i.invalidateQueries({queryKey:j.queryKey})}}),X=p({...W,onSuccess:()=>{K.add({title:t(`verifyEmail.resendSuccess`),type:`success`}),I(!0),setTimeout(()=>I(!1),5e3)}}),{register:Z,setError:Q,handleSubmit:$,formState:{errors:ee}}=E({defaultValues:{token:l||``},resolver:D(J)}),te=async e=>{try{await Y.mutateAsync(e)}catch{Q(`token`,{type:`manual`,message:t(`verifyEmail.error.invalidToken`)})}},ne=async()=>{if(u)try{await X.mutateAsync({email:u})}catch{}};return m?(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{"data-testid":`alert-success`,children:(0,G.jsx)(w,{description:(0,G.jsxs)(G.Fragment,{children:[t(`verifyEmail.success.subtitle`),(0,G.jsx)(`br`,{}),t(`verifyEmail.success.description`)]}),icon:_,title:t(`verifyEmail.success.title`),tone:`success`,children:(0,G.jsx)(g,{className:`w-full`,"data-testid":`email-verify-go-profile`,intent:`primary`,onClick:()=>n(`/profile`),type:`button`,uiSize:`lg`,children:t(`verifyEmail.success.goToProfile`)})})})}):(0,G.jsxs)(L,{children:[(0,G.jsx)(S,{subtitle:t(`verifyEmail.subtitle`),title:t(`verifyEmail.title`)}),u&&(0,G.jsx)(C,{icon:x,type:`info`,children:(0,G.jsxs)(`span`,{className:`flex flex-col gap-tinyrack-3xs text-left`,children:[(0,G.jsx)(f,{variant:`body`,weight:`strong`,children:t(`register.success.subtitle`)}),(0,G.jsx)(f,{color:`muted`,variant:`caption`,children:t(`register.success.description`,{email:u})})]})}),(0,G.jsxs)(O,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:$(te),children:[(0,G.jsx)(v,{error:ee.token,icon:y,label:t(`verifyEmail.token.label`),placeholder:t(`verifyEmail.token.placeholder`),...Z(`token`),type:`text`}),(0,G.jsx)(g,{className:`w-full`,intent:`primary`,loading:Y.isPending,loadingLabel:t(`verifyEmail.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyEmail.submit`)})]}),u&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,G.jsx)(R,{}),(0,G.jsx)(g,{appearance:`ghost`,className:`w-full`,"data-testid":`email-verify-resend`,disabled:X.isPending||P,intent:`neutral`,onClick:ne,type:`button`,uiSize:`lg`,children:X.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(h,{uiSize:`sm`}),t(`verifyEmail.resending`)]}):t(`verifyEmail.resend`)})]})]})}var q=i(function({error:e}){return(0,G.jsx)(I,{component:T,error:e})}),J=n(function({loaderData:e}){return(0,G.jsx)(P,{state:e.dehydratedState,children:(0,G.jsx)(K,{search:e.search})})});export{q as ErrorBoundary,J as default};