@tinyrack/issuary-server 0.28.0 → 0.29.1

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 (139) hide show
  1. package/dist/entities/oauth-client.entity.d.ts +18 -0
  2. package/dist/entities/oauth-client.entity.d.ts.map +1 -1
  3. package/dist/entities/oauth-client.entity.js +12 -0
  4. package/dist/entities/oauth-client.entity.js.map +1 -1
  5. package/dist/entities/oauth-code.entity.d.ts +18 -0
  6. package/dist/entities/oauth-code.entity.d.ts.map +1 -1
  7. package/dist/entities/oauth-device-code.entity.d.ts +18 -0
  8. package/dist/entities/oauth-device-code.entity.d.ts.map +1 -1
  9. package/dist/entities/revoked-token.entity.d.ts +18 -0
  10. package/dist/entities/revoked-token.entity.d.ts.map +1 -1
  11. package/dist/entities/user-consent.entity.d.ts +18 -0
  12. package/dist/entities/user-consent.entity.d.ts.map +1 -1
  13. package/dist/entrypoints/app.d.ts +124 -30
  14. package/dist/entrypoints/app.d.ts.map +1 -1
  15. package/dist/entrypoints/database/postgres/compiled-functions.d.ts +10 -4
  16. package/dist/entrypoints/database/postgres/compiled-functions.js +111 -24
  17. package/dist/entrypoints/database/postgres/compiled-functions.js.map +1 -1
  18. package/dist/entrypoints/database/sqlite/compiled-functions.d.ts +10 -4
  19. package/dist/entrypoints/database/sqlite/compiled-functions.js +111 -24
  20. package/dist/entrypoints/database/sqlite/compiled-functions.js.map +1 -1
  21. package/dist/lib/config/cleanup.d.ts +8 -0
  22. package/dist/lib/config/cleanup.d.ts.map +1 -1
  23. package/dist/lib/config/cleanup.js +16 -0
  24. package/dist/lib/config/cleanup.js.map +1 -1
  25. package/dist/lib/config/resolved.d.ts +4 -0
  26. package/dist/lib/config/resolved.d.ts.map +1 -1
  27. package/dist/migrations/postgres/Migration20260904090000_add_oauth_client_lifecycle.d.ts +6 -0
  28. package/dist/migrations/postgres/Migration20260904090000_add_oauth_client_lifecycle.d.ts.map +1 -0
  29. package/dist/migrations/postgres/Migration20260904090000_add_oauth_client_lifecycle.js +14 -0
  30. package/dist/migrations/postgres/Migration20260904090000_add_oauth_client_lifecycle.js.map +1 -0
  31. package/dist/migrations/postgres/index.d.ts.map +1 -1
  32. package/dist/migrations/postgres/index.js +2 -0
  33. package/dist/migrations/postgres/index.js.map +1 -1
  34. package/dist/migrations/sqlite/Migration20260904090000_add_oauth_client_lifecycle.d.ts +6 -0
  35. package/dist/migrations/sqlite/Migration20260904090000_add_oauth_client_lifecycle.d.ts.map +1 -0
  36. package/dist/migrations/sqlite/Migration20260904090000_add_oauth_client_lifecycle.js +14 -0
  37. package/dist/migrations/sqlite/Migration20260904090000_add_oauth_client_lifecycle.js.map +1 -0
  38. package/dist/migrations/sqlite/index.d.ts.map +1 -1
  39. package/dist/migrations/sqlite/index.js +2 -0
  40. package/dist/migrations/sqlite/index.js.map +1 -1
  41. package/dist/routes/api/admin/console/index.d.ts +91 -1
  42. package/dist/routes/api/admin/console/index.d.ts.map +1 -1
  43. package/dist/routes/api/admin/console/index.js +10 -2
  44. package/dist/routes/api/admin/console/index.js.map +1 -1
  45. package/dist/routes/api/admin/index.d.ts +91 -1
  46. package/dist/routes/api/admin/index.d.ts.map +1 -1
  47. package/dist/routes/api/auth/accounts/select.post.d.ts +6 -6
  48. package/dist/routes/api/auth/index.d.ts +11 -11
  49. package/dist/routes/api/index.d.ts +120 -30
  50. package/dist/routes/api/index.d.ts.map +1 -1
  51. package/dist/routes/api/oauth/_provider/callback/post.d.ts +9 -9
  52. package/dist/routes/index.d.ts +91 -1
  53. package/dist/routes/index.d.ts.map +1 -1
  54. package/dist/routes/oauth/index.d.ts +9 -9
  55. package/dist/schemas/error.d.ts +75 -0
  56. package/dist/schemas/error.d.ts.map +1 -1
  57. package/dist/schemas/error.js +3 -0
  58. package/dist/schemas/error.js.map +1 -1
  59. package/dist/schemas/response.d.ts +1 -0
  60. package/dist/schemas/response.d.ts.map +1 -1
  61. package/dist/schemas/response.js +4 -0
  62. package/dist/schemas/response.js.map +1 -1
  63. package/dist/seeders/config.seeder.js +14 -11
  64. package/dist/seeders/config.seeder.js.map +1 -1
  65. package/dist/services/admin-console.service.d.ts +47 -0
  66. package/dist/services/admin-console.service.d.ts.map +1 -1
  67. package/dist/services/admin-console.service.js +75 -6
  68. package/dist/services/admin-console.service.js.map +1 -1
  69. package/dist/services/cleanup.service.d.ts +2 -0
  70. package/dist/services/cleanup.service.d.ts.map +1 -1
  71. package/dist/services/cleanup.service.js +61 -0
  72. package/dist/services/cleanup.service.js.map +1 -1
  73. package/dist/services/container.d.ts +4 -0
  74. package/dist/services/container.d.ts.map +1 -1
  75. package/dist/services/jwt.service.d.ts +2 -0
  76. package/dist/services/jwt.service.d.ts.map +1 -1
  77. package/dist/services/jwt.service.js +6 -0
  78. package/dist/services/jwt.service.js.map +1 -1
  79. package/dist/services/oauth-client.service.d.ts.map +1 -1
  80. package/dist/services/oauth-client.service.js +9 -5
  81. package/dist/services/oauth-client.service.js.map +1 -1
  82. package/dist/services/oauth-token.service.d.ts.map +1 -1
  83. package/dist/services/oauth-token.service.js +8 -1
  84. package/dist/services/oauth-token.service.js.map +1 -1
  85. package/frontend/client/assets/admin-console-BVGtfvzy.js +1 -0
  86. package/frontend/client/assets/admin-users-notice-DcKE5B43.js +1 -0
  87. package/frontend/client/assets/auth-choice-row-DBHleTc9.js +1 -0
  88. package/frontend/client/assets/{auth-layout-BFD6Jwkd.js → auth-layout-CFKu8bHI.js} +1 -1
  89. package/frontend/client/assets/{auth-page-header-DWIuRJtG.js → auth-page-header-D5Z-EA6V.js} +1 -1
  90. package/frontend/client/assets/{authorization-context-banner-WE0b3j97.js → authorization-context-banner-Cqtzj9A1.js} +1 -1
  91. package/frontend/client/assets/i18n-BY3irWek.js +1 -0
  92. package/frontend/client/assets/{language-selector-BZipfWXO.js → language-selector-CGXk9vW_.js} +1 -1
  93. package/frontend/client/assets/manifest-9217f574.js +1 -0
  94. package/frontend/client/assets/{passkey-DoR9gw8n.js → passkey-C9bzur2Z.js} +1 -1
  95. package/frontend/client/assets/{promise-C4eJsjRN.js → promise-CFWkfv2A.js} +1 -1
  96. package/frontend/client/assets/{root-DxmAI0wD.css → root-BzgVDKW8.css} +1 -1
  97. package/frontend/client/assets/{root-sdYEeZVs.js → root-DTCHNfT8.js} +1 -1
  98. package/frontend/client/assets/{route-BPss6aNC.js → route-48mZ_bkD.js} +1 -1
  99. package/frontend/client/assets/route-9i9rqQdx.js +4 -0
  100. package/frontend/client/assets/{route-BI7lRSrf.js → route-Bc48Eq7F.js} +1 -1
  101. package/frontend/client/assets/{route-BA8SLA-y.js → route-Bx9hz_OF.js} +1 -1
  102. package/frontend/client/assets/{route-B4n6iLak.js → route-C5Pe2AZT.js} +1 -1
  103. package/frontend/client/assets/{route-DHyl9fg6.js → route-C9TWgUZf.js} +1 -1
  104. package/frontend/client/assets/{route-DCxEMgcG.js → route-CBjporWj.js} +1 -1
  105. package/frontend/client/assets/{route-BbumhNTg.js → route-CLo3eo-R.js} +1 -1
  106. package/frontend/client/assets/route-CPIXY7eE.js +1 -0
  107. package/frontend/client/assets/{route--ygtU3xf.js → route-Caw4ohFV.js} +1 -1
  108. package/frontend/client/assets/{route-O04gqlmz.js → route-Ceht21dJ.js} +1 -1
  109. package/frontend/client/assets/route-CkS9fAlL.js +1 -0
  110. package/frontend/client/assets/{route-CCs0-fO0.js → route-CsT5EJEh.js} +1 -1
  111. package/frontend/client/assets/{route-DQlEYlRT.js → route-Cvob9_0Q.js} +1 -1
  112. package/frontend/client/assets/{route-OeZDuFSb.js → route-DCfkikii.js} +1 -1
  113. package/frontend/client/assets/{route-B1MD0P12.js → route-DHEnEwHa.js} +1 -1
  114. package/frontend/client/assets/{route-BLq7NTd1.js → route-DLNoCW7x.js} +1 -1
  115. package/frontend/client/assets/{route-WG7qPhB_.js → route-DVMfGHhl.js} +1 -1
  116. package/frontend/client/assets/{route-BUTlt8Ui.js → route-DlKXugZV.js} +1 -1
  117. package/frontend/client/assets/{route-D9cK2_2t.js → route-DokK6Iod.js} +1 -1
  118. package/frontend/client/assets/{route-D98zlsIA.js → route-ID67gqvy.js} +1 -1
  119. package/frontend/client/assets/{route-Cmo_MXuL.js → route-OWWRYmAT.js} +1 -1
  120. package/frontend/client/assets/{route-DitctEyz.js → route-R-BJj3-W.js} +1 -1
  121. package/frontend/client/assets/{route-CgqKzu4o.js → route-_DMD2pp1.js} +1 -1
  122. package/frontend/client/assets/{route-BukKUAfo.js → route-goGP2kXu.js} +1 -1
  123. package/frontend/client/assets/{route-DtL-KJ0k.js → route-xuoylbDO.js} +1 -1
  124. package/frontend/client/assets/{shell-header-bar-CtUdWFmD.js → shell-header-bar-C3KYib1D.js} +1 -1
  125. package/frontend/client/assets/{terms-BEja7rHN.js → terms-BReb6uEz.js} +1 -1
  126. package/frontend/client/assets/{use-totp-setup-BwOsP75D.js → use-totp-setup-BOSkSnYG.js} +1 -1
  127. package/frontend/server/assets/{hydration-CzMpuxhN.js → hydration-yaDCGSA8.js} +1 -1
  128. package/frontend/server/assets/{root-loader.server-BjcO3GtR.js → root-loader.server-Cwm-l9OS.js} +3 -3
  129. package/frontend/server/assets/{route-runtime.server-DnkciJ0v.js → route-runtime.server-CjDbp5w6.js} +1 -1
  130. package/frontend/server/assets/{session-CEJThdQg.js → session-CSnQWUgx.js} +30 -0
  131. package/frontend/server/index.js +384 -259
  132. package/package.json +1 -1
  133. package/frontend/client/assets/admin-console-DL8Kf5fu.js +0 -1
  134. package/frontend/client/assets/auth-choice-row-vQ3LzZiF.js +0 -1
  135. package/frontend/client/assets/i18n-wAvPXBC2.js +0 -1
  136. package/frontend/client/assets/manifest-6d4cda98.js +0 -1
  137. package/frontend/client/assets/route-CEunl4H1.js +0 -1
  138. package/frontend/client/assets/route-CZFY6zgn.js +0 -4
  139. package/frontend/client/assets/route-DUp2lTDn.js +0 -1
@@ -1 +1 @@
1
- import{$ as e,J as t,a as n,l as r,p as i,t as a,u as o,y as s}from"./components-C1SipCbb.js";import{l as c,t as l}from"./toast-_zV1SGz6.js";import{i as u,o as d,r as f}from"./errorBoundaries-BmdAyh9C.js";import{t as p}from"./jsx-runtime-BFZ_fnNJ.js";import{A as m,C as h,D as g,E as _,I as v,N as y,O as b,S as x,T as S,_ as C,a as w,f as T,g as E,i as D,o as O,r as k,v as A,x as j,y as M}from"./api-0SzZx6X7.js";import{t as N}from"./HydrationBoundary-CGOTaz3j.js";import{t as P}from"./mutation-C0KT2UXZ.js";import{t as F}from"./progress-xdWpxn2G.js";import{i as I,o as L}from"./i18n-wAvPXBC2.js";var R=class extends M{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new P({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=z(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=z(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=z(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=z(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){C.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>S(t,e))}findAll(e={}){return this.getAll().filter(t=>S(e,t))}notify(e){C.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return C.batch(()=>Promise.all(e.map(e=>e.continue().catch(g))))}};function z(e){return e.options.scope?.id}var B=class extends M{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??h(r,t),a=this.get(i);return a||(a=new T({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){C.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>_(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>_(e,t)):t}notify(e){C.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){C.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){C.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},V=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new B,this.#t=e.mutationCache||new R,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=A.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=E.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(m(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=j(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return C.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;C.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return C.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=C.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(g).catch(g)}invalidateQueries(e,t={}){return C.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=C.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(g)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(g)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(m(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(m(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(g).catch(g)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(g).catch(g)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return E.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(x(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{b(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(x(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{b(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=h(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===y&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},H=e(t());function U({i18n:e,defaultNS:t,children:n}){let r=(0,H.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,H.createElement)(O.Provider,{value:r},n)}function W(){return new V({defaultOptions:{queries:{retry:(e,t)=>t instanceof D&&t.status>=400&&t.status<500?!1:e<3},mutations:{retry:!1}}})}var G;function K(){return typeof window>`u`?W():(G??=W(),G)}var q=p();function J({loaderData:e}){let t=e?.config.branding.title?.[e.language]??`Issuary`,n=e?.config.branding.subtitle?.[e.language]??`OIDC Provider for everyone`;return[{title:t},{name:`description`,content:n},{name:`robots`,content:`noindex, nofollow`},{tagName:`link`,rel:`icon`,href:e?.config.branding.icon_url??`/issuary-app-icon.svg`}]}function Y({children:e}){let t=s(`root`);return(0,q.jsxs)(`html`,{"data-theme":t?.theme===`dark`?`tinyrack-dark`:`tinyrack-light`,lang:t?.language??`en`,suppressHydrationWarning:!0,children:[(0,q.jsxs)(`head`,{children:[(0,q.jsx)(`meta`,{charSet:`utf-8`}),(0,q.jsx)(`meta`,{content:`width=device-width, initial-scale=1`,name:`viewport`}),(0,q.jsx)(`meta`,{content:`light dark`,name:`color-scheme`}),(0,q.jsx)(u,{}),(0,q.jsx)(f,{})]}),(0,q.jsxs)(`body`,{children:[e,(0,q.jsx)(c,{}),(0,q.jsx)(d,{})]})]})}function X(){let{t:e}=w(),t=i(),n=o(),[r,a]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let e=()=>a(!0),t=()=>a(!1);return window.addEventListener(`issuary-document-navigation`,e),window.addEventListener(`pageshow`,t),()=>{window.removeEventListener(`issuary-document-navigation`,e),window.removeEventListener(`pageshow`,t)}},[]),!(t.state!==`idle`&&t.location!==void 0&&t.location.pathname!==n.pathname||r)||n.pathname.startsWith(`/admin`)?null:(0,q.jsxs)(F.Root,{className:`route-progress`,value:null,children:[(0,q.jsx)(F.Label,{className:`route-progress-label`,children:e(`common.loading`)}),(0,q.jsx)(F.Track,{children:(0,q.jsx)(F.Indicator,{})})]})}var Z=n(function(){let e=r(),t=K(),n=(0,H.useMemo)(()=>I({supportedLanguages:e.config.i18n.supported_languages,defaultLanguage:e.config.i18n.default_language,fallbackLanguage:e.config.i18n.fallback_language},e.language),[e.config.i18n,e.language]);return(0,H.useEffect)(()=>{document.documentElement.dataset.hydrated=`true`,k(n.language);let e=e=>k(e);return n.on(`languageChanged`,e),()=>n.off(`languageChanged`,e)},[n]),(0,q.jsx)(U,{i18n:n,children:(0,q.jsx)(L,{initialColorScheme:e.theme,children:(0,q.jsx)(v,{client:t,children:(0,q.jsx)(N,{state:e.dehydratedState,children:(0,q.jsxs)(l.Provider,{children:[(0,q.jsx)(X,{}),(0,q.jsx)(a,{})]})})})})})});export{Y as Layout,Z as default,J as meta};
1
+ import{$ as e,J as t,a as n,l as r,p as i,t as a,u as o,y as s}from"./components-C1SipCbb.js";import{l as c,t as l}from"./toast-_zV1SGz6.js";import{i as u,o as d,r as f}from"./errorBoundaries-BmdAyh9C.js";import{t as p}from"./jsx-runtime-BFZ_fnNJ.js";import{A as m,C as h,D as g,E as _,I as v,N as y,O as b,S as x,T as S,_ as C,a as w,f as T,g as E,i as D,o as O,r as k,v as A,x as j,y as M}from"./api-0SzZx6X7.js";import{t as N}from"./HydrationBoundary-CGOTaz3j.js";import{t as P}from"./mutation-C0KT2UXZ.js";import{t as F}from"./progress-xdWpxn2G.js";import{i as I,o as L}from"./i18n-BY3irWek.js";var R=class extends M{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new P({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=z(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=z(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=z(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=z(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){C.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>S(t,e))}findAll(e={}){return this.getAll().filter(t=>S(e,t))}notify(e){C.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return C.batch(()=>Promise.all(e.map(e=>e.continue().catch(g))))}};function z(e){return e.options.scope?.id}var B=class extends M{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??h(r,t),a=this.get(i);return a||(a=new T({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){C.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>_(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>_(e,t)):t}notify(e){C.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){C.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){C.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},V=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new B,this.#t=e.mutationCache||new R,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=A.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=E.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(m(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=j(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return C.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;C.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return C.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=C.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(g).catch(g)}invalidateQueries(e,t={}){return C.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=C.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(g)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(g)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(m(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(m(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(g).catch(g)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(g).catch(g)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return E.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(x(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{b(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(x(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{b(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=h(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===y&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},H=e(t());function U({i18n:e,defaultNS:t,children:n}){let r=(0,H.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,H.createElement)(O.Provider,{value:r},n)}function W(){return new V({defaultOptions:{queries:{retry:(e,t)=>t instanceof D&&t.status>=400&&t.status<500?!1:e<3},mutations:{retry:!1}}})}var G;function K(){return typeof window>`u`?W():(G??=W(),G)}var q=p();function J({loaderData:e}){let t=e?.config.branding.title?.[e.language]??`Issuary`,n=e?.config.branding.subtitle?.[e.language]??`OIDC Provider for everyone`;return[{title:t},{name:`description`,content:n},{name:`robots`,content:`noindex, nofollow`},{tagName:`link`,rel:`icon`,href:e?.config.branding.icon_url??`/issuary-app-icon.svg`}]}function Y({children:e}){let t=s(`root`);return(0,q.jsxs)(`html`,{"data-theme":t?.theme===`dark`?`tinyrack-dark`:`tinyrack-light`,lang:t?.language??`en`,suppressHydrationWarning:!0,children:[(0,q.jsxs)(`head`,{children:[(0,q.jsx)(`meta`,{charSet:`utf-8`}),(0,q.jsx)(`meta`,{content:`width=device-width, initial-scale=1`,name:`viewport`}),(0,q.jsx)(`meta`,{content:`light dark`,name:`color-scheme`}),(0,q.jsx)(u,{}),(0,q.jsx)(f,{})]}),(0,q.jsxs)(`body`,{children:[e,(0,q.jsx)(c,{}),(0,q.jsx)(d,{})]})]})}function X(){let{t:e}=w(),t=i(),n=o(),[r,a]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let e=()=>a(!0),t=()=>a(!1);return window.addEventListener(`issuary-document-navigation`,e),window.addEventListener(`pageshow`,t),()=>{window.removeEventListener(`issuary-document-navigation`,e),window.removeEventListener(`pageshow`,t)}},[]),!(t.state!==`idle`&&t.location!==void 0&&t.location.pathname!==n.pathname||r)||n.pathname.startsWith(`/admin`)?null:(0,q.jsxs)(F.Root,{className:`route-progress`,value:null,children:[(0,q.jsx)(F.Label,{className:`route-progress-label`,children:e(`common.loading`)}),(0,q.jsx)(F.Track,{children:(0,q.jsx)(F.Indicator,{})})]})}var Z=n(function(){let e=r(),t=K(),n=(0,H.useMemo)(()=>I({supportedLanguages:e.config.i18n.supported_languages,defaultLanguage:e.config.i18n.default_language,fallbackLanguage:e.config.i18n.fallback_language},e.language),[e.config.i18n,e.language]);return(0,H.useEffect)(()=>{document.documentElement.dataset.hydrated=`true`,k(n.language);let e=e=>k(e);return n.on(`languageChanged`,e),()=>n.off(`languageChanged`,e)},[n]),(0,q.jsx)(U,{i18n:n,children:(0,q.jsx)(L,{initialColorScheme:e.theme,children:(0,q.jsx)(v,{client:t,children:(0,q.jsx)(N,{state:e.dehydratedState,children:(0,q.jsxs)(l.Provider,{children:[(0,q.jsx)(X,{}),(0,q.jsx)(a,{})]})})})})})});export{Y as Layout,Z as default,J as meta};
@@ -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{a as s}from"./api-0SzZx6X7.js";import{r as c}from"./text-CGN4ZtUZ.js";import{t as l}from"./useMutation-C4CmK9Sb.js";import{V as u}from"./select--ltVnlVl.js";import{r as d}from"./NullStore-BxU9yW8l.js";import{t as f}from"./circle-alert-DGTJ9B9k.js";import{t as p}from"./circle-check-CGasu2tI.js";import{t as m}from"./auth-field-1EM9pnWe.js";import{t as h}from"./key-round-DgCbGqQL.js";import{n as g}from"./language-selector-BZipfWXO.js";import{t as _}from"./lock-m97gMmUy.js";import{t as v}from"./auth-page-header-DWIuRJtG.js";import{t as y}from"./alert-CFUBsmUN.js";import{t as b}from"./auth-outcome-B7tCCKZC.js";import{t as x}from"./route-error-fallback-C2OHu3JW.js";import{r as S,t as C}from"./standard-schema-C8Td_miB.js";import{r as w}from"./FieldItemContext-CPjig163.js";import{a as T,s as E}from"./schemas-Dxi9xZo6.js";import{n as D,t as O}from"./route-module-Bm4sHkx9.js";import{t as k}from"./auth-layout-BFD6Jwkd.js";import{n as A,t as j}from"./auth-footer-DgRsLHyD.js";import{n as M}from"./password-reset-BuDycpfY.js";import{t as N}from"./password-strength-DLtV7dBZ.js";var P=u(`lock-keyhole`,[[`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`}]]),F=e(t(),1),I=o();function L({search:e}){let{t}=s(),n=r(),{token:i}=e,[o,u]=(0,F.useState)(!1),{data:x}=c(g),D=x.auth.password.policy,O=(0,F.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]),L=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,I.jsx)(k,{children:(0,I.jsx)(`div`,{"data-testid":`alert-success`,children:(0,I.jsx)(b,{description:(0,I.jsxs)(I.Fragment,{children:[t(`resetPassword.success.subtitle`),(0,I.jsx)(`br`,{}),t(`resetPassword.success.description`)]}),icon:p,title:t(`resetPassword.success.title`),tone:`success`,children:(0,I.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,I.jsxs)(k,{children:[(0,I.jsx)(v,{subtitle:t(`resetPassword.subtitle`),title:t(`resetPassword.title`)}),(0,I.jsxs)(w,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:B(async e=>{try{await L.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,I.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,I.jsx)(y,{"data-testid":`reset-password-token-error`,icon:f,type:`error`,children:H.token.message}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,I.jsx)(m,{autoComplete:`new-password`,error:H.password,icon:_,label:t(`resetPassword.password.label`),placeholder:t(`resetPassword.password.placeholder`),...R(`password`),type:`password`}),(0,I.jsx)(N,{password:U,policy:D})]}),(0,I.jsx)(m,{autoComplete:`new-password`,error:H.confirmPassword,icon:P,label:t(`resetPassword.confirmPassword.label`),placeholder:t(`resetPassword.confirmPassword.placeholder`),...R(`confirmPassword`),type:`password`}),(0,I.jsx)(d,{className:`w-full`,intent:`primary`,loading:L.isPending,loadingLabel:t(`resetPassword.submitting`),type:`submit`,uiSize:`lg`,children:t(`resetPassword.submit`)})]}),(0,I.jsx)(j,{children:(0,I.jsx)(A,{link:(0,I.jsx)(a,{"data-testid":`reset-password-back-to-login`,to:`/login`,children:t(`resetPassword.backToLogin`)})})})]})}var R=i(function({error:e}){return(0,I.jsx)(O,{component:x,error:e})}),z=n(function({loaderData:e}){return(0,I.jsx)(D,{state:e.dehydratedState,children:(0,I.jsx)(L,{search:e.search})})});export{R as ErrorBoundary,z as default};
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{a as s}from"./api-0SzZx6X7.js";import{r as c}from"./text-CGN4ZtUZ.js";import{t as l}from"./useMutation-C4CmK9Sb.js";import{V as u}from"./select--ltVnlVl.js";import{r as d}from"./NullStore-BxU9yW8l.js";import{t as f}from"./circle-alert-DGTJ9B9k.js";import{t as p}from"./circle-check-CGasu2tI.js";import{t as m}from"./auth-field-1EM9pnWe.js";import{t as h}from"./key-round-DgCbGqQL.js";import{n as g}from"./language-selector-CGXk9vW_.js";import{t as _}from"./lock-m97gMmUy.js";import{t as v}from"./auth-page-header-D5Z-EA6V.js";import{t as y}from"./alert-CFUBsmUN.js";import{t as b}from"./auth-outcome-B7tCCKZC.js";import{t as x}from"./route-error-fallback-C2OHu3JW.js";import{r as S,t as C}from"./standard-schema-C8Td_miB.js";import{r as w}from"./FieldItemContext-CPjig163.js";import{a as T,s as E}from"./schemas-Dxi9xZo6.js";import{n as D,t as O}from"./route-module-Bm4sHkx9.js";import{t as k}from"./auth-layout-CFKu8bHI.js";import{n as A,t as j}from"./auth-footer-DgRsLHyD.js";import{n as M}from"./password-reset-BuDycpfY.js";import{t as N}from"./password-strength-DLtV7dBZ.js";var P=u(`lock-keyhole`,[[`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`}]]),F=e(t(),1),I=o();function L({search:e}){let{t}=s(),n=r(),{token:i}=e,[o,u]=(0,F.useState)(!1),{data:x}=c(g),D=x.auth.password.policy,O=(0,F.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]),L=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,I.jsx)(k,{children:(0,I.jsx)(`div`,{"data-testid":`alert-success`,children:(0,I.jsx)(b,{description:(0,I.jsxs)(I.Fragment,{children:[t(`resetPassword.success.subtitle`),(0,I.jsx)(`br`,{}),t(`resetPassword.success.description`)]}),icon:p,title:t(`resetPassword.success.title`),tone:`success`,children:(0,I.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,I.jsxs)(k,{children:[(0,I.jsx)(v,{subtitle:t(`resetPassword.subtitle`),title:t(`resetPassword.title`)}),(0,I.jsxs)(w,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:B(async e=>{try{await L.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,I.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,I.jsx)(y,{"data-testid":`reset-password-token-error`,icon:f,type:`error`,children:H.token.message}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,I.jsx)(m,{autoComplete:`new-password`,error:H.password,icon:_,label:t(`resetPassword.password.label`),placeholder:t(`resetPassword.password.placeholder`),...R(`password`),type:`password`}),(0,I.jsx)(N,{password:U,policy:D})]}),(0,I.jsx)(m,{autoComplete:`new-password`,error:H.confirmPassword,icon:P,label:t(`resetPassword.confirmPassword.label`),placeholder:t(`resetPassword.confirmPassword.placeholder`),...R(`confirmPassword`),type:`password`}),(0,I.jsx)(d,{className:`w-full`,intent:`primary`,loading:L.isPending,loadingLabel:t(`resetPassword.submitting`),type:`submit`,uiSize:`lg`,children:t(`resetPassword.submit`)})]}),(0,I.jsx)(j,{children:(0,I.jsx)(A,{link:(0,I.jsx)(a,{"data-testid":`reset-password-back-to-login`,to:`/login`,children:t(`resetPassword.backToLogin`)})})})]})}var R=i(function({error:e}){return(0,I.jsx)(O,{component:x,error:e})}),z=n(function({loaderData:e}){return(0,I.jsx)(D,{state:e.dehydratedState,children:(0,I.jsx)(L,{search:e.search})})});export{R as ErrorBoundary,z as default};
@@ -0,0 +1,4 @@
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}from"./api-0SzZx6X7.js";import{r as o,t as s}from"./text-CGN4ZtUZ.js";import{t as c}from"./useMutation-C4CmK9Sb.js";import{Bn as l,Dn as u,Mn as d,On as f,Pn as p,Q as m,St as h,Tt as g,Wt as _,Y as v,Z as y,bt as b,jn as x,u as S,wt as C,xt as w,yn as T}from"./usePositioner-DcBnB2-O.js";import{A as E,C as D,F as O,I as k,L as A,M as j,N as M,a as N,c as P,i as F,j as I,k as ee,t as L}from"./select--ltVnlVl.js";import{r as R}from"./NullStore-BxU9yW8l.js";import{a as z,c as B,d as V,f as te,i as ne,l as re,n as ie,o as ae,p as oe,r as H,s as se,t as ce,u as U}from"./use-admin-selection-CAegSKw5.js";import{t as le}from"./triangle-alert-DSSurAZ_.js";import{n as W,t as G}from"./modal-LoTH9Ttl.js";import{t as K}from"./code-RrwtZcA2.js";import{r as ue}from"./FieldItemContext-CPjig163.js";import{t as de}from"./field-DzNLNMM0.js";import{t as fe}from"./input-BFJdEx8B.js";import{t as pe}from"./badge-BCQspax5.js";import{t as me}from"./checkbox-OA4CFk-6.js";import{t as he}from"./Separator-eMrsmRws.js";import{n as ge}from"./route-module-Bm4sHkx9.js";import{t as q}from"./CompositeItem-VmYWaHnv.js";import{a as _e,d as ve,l as ye,p as be,s as xe,t as Se,u as Ce}from"./admin-console-BVGtfvzy.js";import{t as J}from"./table-D2oRcUKc.js";import{t as we}from"./admin-users-notice-DcKE5B43.js";var Y=e(t(),1),X=r(),Te=Y.forwardRef(function(e,t){let n=N().orientation===`vertical`?`horizontal`:`vertical`;return(0,X.jsx)(he,{orientation:n,...e,ref:t})}),Ee=[];function De(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:d,disabledIndices:f,modifierKeys:m=Ee}=e,[v,y]=Y.useState(0),x=r!=null,S=Y.useRef(null),O=p(S,c),N=Y.useRef([]),P=Y.useRef(!1),F=o??v,L=T((e,t=!1)=>{if((s??y)(e),t){let t=N.current[e];A(S.current,t,a,n)}}),R=T(e=>{if(e.size===0||P.current)return;P.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)L(i);else if(g(t,F,f)){let e=b(t,{disabledIndices:f});C(t,e)||L(e)}A(S.current,r,a,n)});u(()=>{if(f==null||o!=null||!P.current)return;let e=N.current;if(g(e,F,f)){let t=b(e,{disabledIndices:f});C(e,t)||L(t)}},[f,o,F,N,L]);let z=T((e,t,n)=>i?i(e,t,n,N):n),B=T(e=>{let o=e.key===`Home`||e.key===`End`;if(!M.has(e.key)||!l&&o||Oe(e,m)||!S.current)return;let s=a===`rtl`,c=s?E:I,u=s?I:E,p=n===`vertical`?ee:c,g=n===`vertical`?j:u,v=_(e.nativeEvent);if(v!=null&&k(v)&&!D(v)){let t=v.selectionStart,n=v.selectionEnd,r=v.value;if(t==null||e.shiftKey||t!==n||e.key!==g&&t<r.length||e.key!==p&&t>0)return}let y=F,T=h(N,f),O=w(N,f);r!=null&&(y=r({disabledIndices:f,elementsRef:N,event:e,highlightedIndex:F,loopFocus:t,maxIndex:O,minIndex:T,onLoop:z,orientation:n,rtl:s}));let A=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,P=n!==`vertical`&&e.key===u||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?y=T:e.key===`End`&&(y=O)),y===F&&(A||P)&&(t&&y===O&&A?(y=T,i&&(y=i(e,F,y,N))):t&&y===T&&P?(y=O,i&&(y=i(e,F,y,N))):y=b(N.current,{startingIndex:y,decrement:P,disabledIndices:f})),y!==F&&!C(N.current,y)&&(d&&e.stopPropagation(),(x||o||A||P)&&e.preventDefault(),L(y,!0),queueMicrotask(()=>{N.current[y]?.focus()}))});return{props:{ref:O,onFocus(e){let t=S.current,n=_(e.nativeEvent);!t||n==null||!k(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:B},highlightedIndex:F,onHighlightedIndexChange:L,elementsRef:N,onMapChange:R,relayKeyboardEvent:B}}function Oe(e,t){for(let n of O)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ke(e){let{render:t,className:n,style:r,refs:i=x,props:a=x,state:o=d,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:p,loopFocus:h,onLoop:g,enableHomeAndEndKeys:_,onMapChange:v,stopEventPropagation:y=!0,rootRef:b,disabledIndices:C,modifierKeys:w,highlightItemOnHover:T=!1,tag:E=`div`,...D}=e,{props:O,highlightedIndex:k,onHighlightedIndexChange:A,elementsRef:j,onMapChange:M,relayKeyboardEvent:N}=De({grid:p,loopFocus:h,onLoop:g,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:b,stopEventPropagation:y,enableHomeAndEndKeys:_,direction:S(),disabledIndices:C,modifierKeys:w}),F=f(E,e,{state:o,ref:i,props:[O,...a,D],stateAttributesMapping:s}),I=Y.useMemo(()=>({highlightedIndex:k,onHighlightedIndexChange:A,highlightItemOnHover:T,relayKeyboardEvent:N}),[k,A,T,N]);return(0,X.jsx)(m.Provider,{value:I,children:(0,X.jsx)(P,{elementsRef:j,onMapChange:e=>{v?.(e),M(e)},children:F})})}var Ae=Y.forwardRef(function(e,t){let{disabled:n=!1,loopFocus:r,orientation:i=`horizontal`,className:a,render:o,style:s,...c}=e,[l,u]=Y.useState(()=>new Map),d=Y.useMemo(()=>{let e=[];for(let t of l.values())t.disabled&&!t.focusableWhenDisabled&&e.push(t.index);return e},[l]),f=Y.useMemo(()=>({disabled:n,orientation:i}),[n,i]),p={disabled:n,orientation:i},m={"aria-orientation":i,role:`toolbar`};return(0,X.jsx)(F.Provider,{value:f,children:(0,X.jsx)(ke,{render:o,className:a,style:s,state:p,refs:[t],props:[m,c],disabledIndices:d,loopFocus:r,onMapChange:u,orientation:i})})}),je=Y.createContext(void 0);function Me(){return Y.useContext(je)}var Ne=Y.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,style:a,...o}=e,{orientation:s,disabled:c}=N(),l=c||r,u=Y.useMemo(()=>({disabled:l}),[l]),d=f(`div`,e,{state:{disabled:l,orientation:s},ref:t,props:[{role:`group`},o]});return(0,X.jsx)(je.Provider,{value:u,children:d})}),Pe=Y.forwardRef(function(e,t){let{className:n,disabled:r=!1,focusableWhenDisabled:i=!0,render:a,nativeButton:o,style:s,...c}=e,{disabled:l,orientation:u}=N(),f=Me(),p=l||(f?.disabled??!1)||r,m=Y.useMemo(()=>({disabled:p,focusableWhenDisabled:i}),[p,i]),{getButtonProps:h,buttonRef:g}=v({disabled:p,focusableWhenDisabled:i,native:o});return(0,X.jsx)(q,{tag:`button`,render:a,className:n,style:s,metadata:m,state:{disabled:p,orientation:u,focusable:i},refs:[t,g],props:[c,a?{disabled:p}:d,h]})}),Fe={disabled:!1,focusableWhenDisabled:!0},Ie=Y.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,{orientation:o}=N();return(0,X.jsx)(q,{tag:`a`,render:r,className:n,style:i,metadata:Fe,state:{orientation:o},refs:[t],props:[a]})}),Le=Y.forwardRef(function(e,t){let{className:n,focusableWhenDisabled:r=!0,render:i,disabled:a=!1,style:o,...s}=e,{disabled:c,orientation:l}=N(),u=Me(),d=c||(u?.disabled??!1)||a,f=Y.useMemo(()=>({disabled:d,focusableWhenDisabled:r}),[d,r]),{props:p}=y({composite:!0,disabled:d,focusableWhenDisabled:r,isNativeButton:!1}),m={disabled:d,orientation:l,focusable:r},h=e=>{d&&e.preventDefault()};return(0,X.jsx)(q,{tag:`input`,render:i,className:n,style:o,metadata:f,state:m,refs:[t],props:[{onClick:h,onPointerDown:h},s,p]})}),Re=l(Pe,`tr-toolbar-button`),ze=l(Ne,`tr-toolbar-group`),Be=l(Le,`tr-toolbar-input`,{tracksFocusModality:!0}),Ve=l(Ie,`tr-toolbar-link`),He={Root:l(Ae,`tr-toolbar`),Group:ze,Button:Re,Link:Ve,Input:Be,Separator:l(Te,`tr-toolbar-separator`)};function Ue(){let{t:e}=a(),t=i(),[n,r]=(0,Y.useState)(``),[l,u]=(0,Y.useState)({page:1,pageSize:20}),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),{data:x}=o(Se(l)),S=ce(x.clients.filter(e=>e.managed_by===`database`&&!e.deleted_at).map(e=>e.id)),C=()=>t.invalidateQueries({queryKey:[`admin`]}),w=c({mutationFn:xe,onSuccess:e=>{C(),f(null),b(e.client_secret??null)}}),T=c({mutationFn:({id:e,input:t})=>be(e,t),onSuccess:()=>{C(),f(null)}}),E=c({mutationFn:ve,onSuccess:e=>{C(),b(e.client_secret)}}),D=c({mutationFn:_e,onSuccess:()=>{C(),S.clear(),m(null)}}),O=c({mutationFn:ye,onSuccess:({client:t})=>{C(),S.clear(),g(null),v({tone:`success`,message:e(`admin.clients.deletedNotice`,{name:t.name})})},onError:()=>v({tone:`error`,message:e(`admin.clients.operationFailed`)})}),k=c({mutationFn:Ce,onSuccess:({client:t})=>{C(),v({tone:`success`,message:e(`admin.clients.restoredNotice`,{name:t.name})})},onError:()=>v({tone:`error`,message:e(`admin.clients.operationFailed`)})}),A=l.page??1,j=l.pageSize??20,M=S.selection.kind===`filter`?x.pagination.total:S.selectedCount??0,N=S.selection.kind===`filter`?{kind:`filter`,filter:{query:l.query,managed_by:l.managedBy,enabled:l.lifecycleStatus===`active`||l.lifecycleStatus!==`inactive`&&void 0}}:{kind:`ids`,ids:[...S.selection.ids]},P=e=>{S.clear(),u(e)};return(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(we,{notice:_,onDismiss:()=>v(null)}):null,(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(ne,{onCreate:()=>f(`create`),onQueryChange:r,onSearch:()=>P({...l,query:n.trim(),page:1}),query:n,title:e(`admin.clients.title`),total:x.pagination.total,children:[(0,X.jsx)(H,{label:e(`admin.clients.type`),onChange:e=>P({...l,type:e===`public`?`public`:e===`confidential`?`confidential`:void 0,page:1}),options:[[`all`,e(`admin.filter.allTypes`)],[`public`,e(`admin.clients.public`)],[`confidential`,e(`admin.clients.confidential`)]],value:l.type??`all`}),(0,X.jsx)(H,{label:e(`admin.table.status`),onChange:e=>P({...l,lifecycleStatus:e===`active`||e===`inactive`||e===`deleted`?e:void 0,page:1}),options:[[`all`,e(`admin.filter.allStatuses`)],[`active`,e(`admin.status.active`)],[`inactive`,e(`admin.status.inactive`)],[`deleted`,e(`admin.status.deleted`)]],value:l.lifecycleStatus??`all`})]}),(0,X.jsxs)(oe,{children:[(0,X.jsxs)(te,{label:e(`admin.clients.title`),children:[(0,X.jsx)(J.Header,{className:`sticky top-0 z-tinyrack-component-raised`,children:(0,X.jsxs)(J.Row,{children:[(0,X.jsx)(V,{header:!0,children:(0,X.jsx)(se,{checked:S.allOnPage,indeterminate:S.someOnPage,onChange:S.togglePage})}),(0,X.jsx)(U,{header:!0,children:(0,X.jsx)(B,{direction:l.direction??`asc`,label:e(`admin.clients.name`),onClick:()=>P({...l,direction:l.direction===`desc`?`asc`:`desc`,page:1})})}),(0,X.jsx)(J.Head,{children:e(`admin.clients.clientId`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.type`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.source`)}),(0,X.jsx)(J.Head,{children:e(`admin.table.status`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.redirects`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.scopes`)}),(0,X.jsx)(re,{header:!0,children:e(`admin.table.actions`)})]})}),(0,X.jsx)(J.Body,{children:x.clients.length===0?(0,X.jsx)(J.Row,{children:(0,X.jsx)(J.Cell,{className:`py-tinyrack-3xl text-center`,colSpan:9,children:e(`admin.table.empty`)})}):x.clients.map(t=>(0,X.jsxs)(J.Row,{className:S.isSelected(t.id)?`bg-tinyrack-surface-selected`:void 0,"data-selected":S.isSelected(t.id)?``:void 0,children:[(0,X.jsx)(V,{selected:S.isSelected(t.id),children:t.managed_by===`database`&&!t.deleted_at?(0,X.jsx)(ae,{checked:S.isSelected(t.id),label:e(`admin.selection.row`,{name:t.name}),onChange:e=>S.toggleOne(t.id,e)}):null}),(0,X.jsx)(U,{selected:S.isSelected(t.id),children:(0,X.jsx)(s,{as:`p`,truncate:!0,variant:`bodySm`,weight:`medium`,children:t.name})}),(0,X.jsx)(J.Cell,{children:(0,X.jsx)(K,{children:t.client_id})}),(0,X.jsx)(J.Cell,{children:e(`admin.clients.${t.type}`)}),(0,X.jsx)(J.Cell,{children:e(`admin.source.${t.managed_by}`)}),(0,X.jsx)(J.Cell,{children:(0,X.jsx)(pe,{className:`whitespace-nowrap`,variant:t.deleted_at?`danger`:t.enabled?`success`:`neutral`,children:e(t.deleted_at?`admin.status.deleted`:t.enabled?`admin.status.active`:`admin.status.inactive`)})}),(0,X.jsx)(J.Cell,{children:t.redirect_uris.length}),(0,X.jsx)(J.Cell,{children:t.scopes.join(`, `)}),(0,X.jsx)(re,{selected:S.isSelected(t.id),children:t.deleted_at?t.managed_by===`database`?(0,X.jsx)(R,{disabled:k.isPending,onClick:()=>k.mutate(t.id),type:`button`,uiSize:`sm`,children:e(`admin.actions.restore`)}):(0,X.jsx)(s,{color:`muted`,variant:`caption`,children:e(`admin.clients.restoreViaConfig`)}):(0,X.jsxs)(He.Root,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>f(t),type:`button`,uiSize:`sm`,children:e(`admin.actions.edit`)}),t.type===`confidential`?(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>E.mutate(t.id),type:`button`,uiSize:`sm`,children:e(`admin.clients.rotateSecret`)}):null,(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>D.mutate({target:{kind:`ids`,ids:[t.id]},active:!t.enabled}),type:`button`,uiSize:`sm`,children:e(t.enabled?`admin.actions.deactivate`:`admin.actions.activate`)}),(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,intent:`danger`,onClick:()=>g(t),type:`button`,uiSize:`sm`,children:e(`admin.actions.delete`)})]})})]},t.id))})]}),(0,X.jsx)(z,{onPageChange:e=>P({...l,page:e}),onPageSizeChange:e=>P({...l,page:1,pageSize:e}),page:A,pageSize:j,total:x.pagination.total})]})]}),M>0?(0,X.jsx)(ie,{canExpand:S.allOnPage&&x.pagination.total>x.clients.length,filterSelected:S.selection.kind===`filter`,onActivate:()=>m(!0),onClear:S.clear,onDeactivate:()=>m(!1),onExpand:S.selectFilter,pending:D.isPending,selected:M,total:x.pagination.total}):null,(0,X.jsx)(Ke,{active:p,count:M,filterSelected:S.selection.kind===`filter`,onClose:()=>m(null),onRun:()=>D.mutate({target:N,active:p??!0})}),(0,X.jsx)(We,{client:d===`create`?void 0:d??void 0,isOpen:d!==null,onClose:()=>f(null),onSubmit:e=>{if(d&&d!==`create`){let{client_id:t,type:n,...r}=e;T.mutate({id:d.id,input:r})}else w.mutate(e)},pending:w.isPending||T.isPending}),(0,X.jsxs)(G,{isOpen:h!==null,onClose:()=>g(null),title:e(`admin.clients.deleteTitle`,{name:h?.name??``}),variant:`destructive`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,X.jsx)(le,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,X.jsx)(s,{as:`p`,weight:`medium`,children:e(`admin.clients.deleteWarning`)})]}),(0,X.jsx)(s,{as:`p`,variant:`bodySm`,children:e(`admin.clients.deleteDescription`)})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{disabled:O.isPending,onClick:()=>g(null),type:`button`,children:e(`common.dismiss`)}),(0,X.jsx)(R,{disabled:O.isPending||!h,intent:`danger`,onClick:()=>{h&&O.mutate(h.id)},type:`button`,children:e(`admin.actions.delete`)})]})]}),(0,X.jsx)(G,{description:e(`admin.clients.secretDescription`),isOpen:y!==null,onClose:()=>b(null),title:e(`admin.clients.secretTitle`),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md pt-tinyrack-lg`,children:[(0,X.jsx)(K,{className:`break-all rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-md`,children:y}),(0,X.jsx)(s,{color:`warning`,variant:`bodySm`,children:e(`admin.clients.secretWarning`)}),(0,X.jsx)(W,{children:(0,X.jsx)(R,{onClick:()=>b(null),type:`button`,children:e(`common.dismiss`)})})]})})]})}function Z(e,t){let n=e.get(t);return typeof n==`string`?n.trim():``}function Q(e,t){return Z(e,t).split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}function We({isOpen:e,client:t,pending:n,onClose:r,onSubmit:i}){let{t:o}=a();return(0,X.jsx)(G,{description:o(t?`admin.clients.editDescription`:`admin.clients.createDescription`),isOpen:e,onClose:r,title:o(t?`admin.clients.editTitle`:`admin.clients.createTitle`),children:(0,X.jsxs)(ue,{className:`grid gap-tinyrack-md pt-tinyrack-lg sm:grid-cols-2`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),n=Z(t,`type`);i({client_id:Z(t,`client_id`),name:Z(t,`name`),type:n===`confidential`?`confidential`:`public`,redirect_uris:Q(t,`redirect_uris`),post_logout_redirect_uris:Q(t,`post_logout_redirect_uris`),web_origins:Q(t,`web_origins`),grant_types:Q(t,`grant_types`),response_types:Q(t,`response_types`),scopes:Q(t,`scopes`),skip_consent:t.get(`skip_consent`)===`on`})},children:[(0,X.jsx)($,{defaultValue:t?.client_id,disabled:!!t,label:o(`admin.clients.clientId`),name:`client_id`,required:!0}),(0,X.jsx)($,{defaultValue:t?.name,label:o(`admin.clients.name`),name:`name`,required:!0}),(0,X.jsx)(Ge,{defaultValue:t?.type??`public`,disabled:!!t,label:o(`admin.clients.type`),name:`type`,options:[[`public`,o(`admin.clients.public`)],[`confidential`,o(`admin.clients.confidential`)]]}),(0,X.jsx)($,{defaultValue:t?.scopes.join(`, `),label:o(`admin.clients.scopes`),name:`scopes`,required:!0}),(0,X.jsx)($,{defaultValue:t?.redirect_uris.join(`
2
+ `),label:o(`admin.clients.redirectUris`),name:`redirect_uris`,required:!0}),(0,X.jsx)($,{defaultValue:t?.post_logout_redirect_uris.join(`
3
+ `),label:o(`admin.clients.postLogoutUris`),name:`post_logout_redirect_uris`}),(0,X.jsx)($,{defaultValue:t?.web_origins.join(`
4
+ `),label:o(`admin.clients.webOrigins`),name:`web_origins`}),(0,X.jsx)($,{defaultValue:t?.grant_types.join(`, `)??`authorization_code`,label:o(`admin.clients.grantTypes`),name:`grant_types`,required:!0}),(0,X.jsx)($,{defaultValue:t?.response_types.join(`, `)??`code`,label:o(`admin.clients.responseTypes`),name:`response_types`,required:!0}),(0,X.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,X.jsx)(me.Root,{"aria-label":o(`admin.clients.skipConsent`),defaultChecked:t?.skip_consent,name:`skip_consent`,value:`on`,children:(0,X.jsx)(me.Indicator,{})}),(0,X.jsx)(s,{variant:`caption`,children:o(`admin.clients.skipConsent`)})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{disabled:n,onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,X.jsx)(R,{disabled:n,intent:`primary`,type:`submit`,children:o(`admin.actions.save`)})]})]})})}function $({label:e,name:t,defaultValue:n,disabled:r,required:i}){return(0,X.jsxs)(de.Root,{children:[(0,X.jsx)(de.Label,{children:e}),(0,X.jsx)(fe,{defaultValue:n,disabled:r,name:t,required:i,uiSize:`sm`})]})}function Ge({label:e,name:t,defaultValue:n,disabled:r,options:i}){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs text-tinyrack-xs`,children:[(0,X.jsx)(s,{as:`span`,variant:`caption`,children:e}),(0,X.jsxs)(L.Root,{defaultValue:n,disabled:r,name:t,children:[(0,X.jsx)(L.Trigger,{"aria-label":e,uiSize:`sm`,children:(0,X.jsx)(L.Value,{children:i.find(([e])=>e===n)?.[1]??n})}),(0,X.jsx)(L.Positioner,{children:(0,X.jsx)(L.Popup,{children:(0,X.jsx)(L.List,{children:i.map(([e,t])=>(0,X.jsx)(L.Item,{value:e,children:(0,X.jsx)(L.ItemText,{children:t})},e))})})})]})]})}function Ke({active:e,count:t,filterSelected:n,onClose:r,onRun:i}){let{t:o}=a();return(0,X.jsx)(G,{isOpen:e!==null,onClose:r,title:o(e?`admin.bulk.activateTitle`:`admin.bulk.deactivateTitle`),children:(0,X.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,X.jsx)(s,{color:`muted`,variant:`bodySm`,children:o(`admin.bulk.confirm`,{count:t,scope:o(n?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,X.jsx)(R,{intent:e?`primary`:`danger`,onClick:i,type:`button`,children:o(`admin.bulk.run`)})]})]})})}var qe=n(function({loaderData:e}){return(0,X.jsx)(ge,{state:e.dehydratedState,children:(0,X.jsx)(Ue,{})})});export{qe 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{L as i,a,n as o,t as s}from"./api-0SzZx6X7.js";import{n as c,r as l}from"./text-CGN4ZtUZ.js";import{t as u}from"./useMutation-C4CmK9Sb.js";import{t as d}from"./mutationOptions-Dfvzj6n2.js";import{V as f}from"./select--ltVnlVl.js";import{n as p}from"./shell-header-bar-CtUdWFmD.js";import{r as m}from"./NullStore-BxU9yW8l.js";import{t as h}from"./auth-choice-row-vQ3LzZiF.js";import{r as g}from"./language-selector-BZipfWXO.js";import{t as _}from"./trash-2-BOsxjkzU.js";import{t as v}from"./auth-page-header-DWIuRJtG.js";import{t as y}from"./link-button-qvSTUE1n.js";import{t as b}from"./alert-CFUBsmUN.js";import{t as x}from"./initial-avatar-D4aPMV9z.js";import{t as S}from"./route-error-fallback-C2OHu3JW.js";import{t as C}from"./badge-BCQspax5.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-Bm4sHkx9.js";import{t as D}from"./auth-layout-BFD6Jwkd.js";import{n as O,r as k}from"./oauth-search-BtLPTIS7.js";var A=f(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),j=f(`circle-user-round`,[[`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`}]]),M=f(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);function N(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 P(e){return N(s,e)}var F=d({mutationFn:async e=>{let t=await s.api.auth.accounts.select.$post({json:e});return o(t)}}),I=d({mutationFn:async e=>{let t=await s.api.auth.accounts.remove.$post({json:e});return o(t)}}),L=r();function R(e){let t=e?.split(` `).filter(Boolean)??[];return t.includes(`login`)||t.push(`login`),t.join(` `)}function z(e){let t=k(e),n=new URLSearchParams;for(let[e,r]of Object.entries({...t,prompt:R(t.prompt),account_selected:1}))r!==void 0&&n.set(e,String(r));return`/login?${n.toString()}`}function B({search:e}){let{t}=a(),r=i(),{data:o}=l(P(e.client_id)),s=o.accounts.length===0&&!o.allow_add_account,c=()=>{w(O({...e,account_selected:1}))},d=u({...F,onSuccess:c}),f=u({...I,onSuccess:()=>{r.invalidateQueries({queryKey:g.accounts(e.client_id)})}});return(0,L.jsxs)(D,{width:`wide`,children:[(0,L.jsx)(v,{subtitle:t(`accountSelect.subtitle`),title:t(`accountSelect.title`)}),o.accounts.length===0?(0,L.jsx)(b,{icon:j,type:`info`,children:t(s?`accountSelect.unavailable`:`accountSelect.noRememberedAccounts`)}):(0,L.jsx)(`div`,{className:`flex flex-col gap-tinyrack-xs`,"data-testid":`account-list`,children:o.accounts.map(e=>(0,L.jsx)(`div`,{"data-testid":`remembered-account`,children:(0,L.jsx)(h,{description:e.current?t(`accountSelect.currentAccount`):t(`accountSelect.rememberedAccount`),label:e.email,leading:(0,L.jsx)(x,{email:e.email,size:`sm`}),render:(0,L.jsx)(m,{"data-testid":`select-account-${e.sub}`,disabled:d.isPending,onClick:()=>d.mutate({sub:e.sub}),type:`button`,uiSize:`lg`}),trailing:(0,L.jsxs)(L.Fragment,{children:[e.current?(0,L.jsx)(C,{uiSize:`md`,variant:`info`,children:t(`accountSelect.current`)}):null,o.allow_remove_account&&!e.current?(0,L.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,L.jsx)(_,{"aria-hidden":!0,className:`size-tinyrack-lg`})}):null]})})},e.sub))}),o.allow_add_account?(0,L.jsxs)(y,{appearance:`outline`,className:`w-full justify-between`,intent:`neutral`,render:(0,L.jsx)(n,{to:z(e)}),uiSize:`lg`,children:[(0,L.jsx)(M,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`accountSelect.useAnotherAccount`),(0,L.jsx)(A,{"aria-hidden":!0,className:`size-tinyrack-lg`})]}):null]})}var V=t(function({error:e}){return(0,L.jsx)(E,{component:S,error:e})}),H=e(function({loaderData:e}){return(0,L.jsx)(T,{state:e.dehydratedState,children:(0,L.jsx)(B,{search:e.search})})});export{V as ErrorBoundary,H as default};
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{L as i,a,n as o,t as s}from"./api-0SzZx6X7.js";import{n as c,r as l}from"./text-CGN4ZtUZ.js";import{t as u}from"./useMutation-C4CmK9Sb.js";import{t as d}from"./mutationOptions-Dfvzj6n2.js";import{V as f}from"./select--ltVnlVl.js";import{n as p}from"./shell-header-bar-C3KYib1D.js";import{r as m}from"./NullStore-BxU9yW8l.js";import{t as h}from"./auth-choice-row-DBHleTc9.js";import{r as g}from"./language-selector-CGXk9vW_.js";import{t as _}from"./trash-2-BOsxjkzU.js";import{t as v}from"./auth-page-header-D5Z-EA6V.js";import{t as y}from"./link-button-qvSTUE1n.js";import{t as b}from"./alert-CFUBsmUN.js";import{t as x}from"./initial-avatar-D4aPMV9z.js";import{t as S}from"./route-error-fallback-C2OHu3JW.js";import{t as C}from"./badge-BCQspax5.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-Bm4sHkx9.js";import{t as D}from"./auth-layout-CFKu8bHI.js";import{n as O,r as k}from"./oauth-search-BtLPTIS7.js";var A=f(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),j=f(`circle-user-round`,[[`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`}]]),M=f(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);function N(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 P(e){return N(s,e)}var F=d({mutationFn:async e=>{let t=await s.api.auth.accounts.select.$post({json:e});return o(t)}}),I=d({mutationFn:async e=>{let t=await s.api.auth.accounts.remove.$post({json:e});return o(t)}}),L=r();function R(e){let t=e?.split(` `).filter(Boolean)??[];return t.includes(`login`)||t.push(`login`),t.join(` `)}function z(e){let t=k(e),n=new URLSearchParams;for(let[e,r]of Object.entries({...t,prompt:R(t.prompt),account_selected:1}))r!==void 0&&n.set(e,String(r));return`/login?${n.toString()}`}function B({search:e}){let{t}=a(),r=i(),{data:o}=l(P(e.client_id)),s=o.accounts.length===0&&!o.allow_add_account,c=()=>{w(O({...e,account_selected:1}))},d=u({...F,onSuccess:c}),f=u({...I,onSuccess:()=>{r.invalidateQueries({queryKey:g.accounts(e.client_id)})}});return(0,L.jsxs)(D,{width:`wide`,children:[(0,L.jsx)(v,{subtitle:t(`accountSelect.subtitle`),title:t(`accountSelect.title`)}),o.accounts.length===0?(0,L.jsx)(b,{icon:j,type:`info`,children:t(s?`accountSelect.unavailable`:`accountSelect.noRememberedAccounts`)}):(0,L.jsx)(`div`,{className:`flex flex-col gap-tinyrack-sm`,"data-testid":`account-list`,children:o.accounts.map(e=>(0,L.jsx)(`div`,{"data-testid":`remembered-account-${e.sub}`,children:(0,L.jsx)(h,{description:e.current?t(`accountSelect.currentAccount`):t(`accountSelect.rememberedAccount`),indicator:e.current?(0,L.jsx)(C,{className:`shrink-0 whitespace-nowrap`,uiSize:`md`,variant:`info`,children:t(`accountSelect.current`)}):null,label:e.email,leading:(0,L.jsx)(x,{email:e.email,size:`md`}),render:(0,L.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,L.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,L.jsx)(_,{"aria-hidden":!0,className:`size-tinyrack-lg`})}):null})},e.sub))}),o.allow_add_account?(0,L.jsxs)(y,{appearance:`ghost`,className:`w-full justify-between`,intent:`neutral`,render:(0,L.jsx)(n,{to:z(e)}),uiSize:`lg`,children:[(0,L.jsx)(M,{"aria-hidden":!0,className:`size-tinyrack-lg`}),t(`accountSelect.useAnotherAccount`),(0,L.jsx)(A,{"aria-hidden":!0,className:`size-tinyrack-lg`})]}):null]})}var V=t(function({error:e}){return(0,L.jsx)(E,{component:S,error:e})}),H=e(function({loaderData:e}){return(0,L.jsx)(T,{state:e.dehydratedState,children:(0,L.jsx)(B,{search:e.search})})});export{V as ErrorBoundary,H 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-BZipfWXO.js";import{t as x}from"./mail-tgQpWyoC.js";import{t as S}from"./auth-page-header-DWIuRJtG.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-C4eJsjRN.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-BFD6Jwkd.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-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 +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"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s}from"./api-0SzZx6X7.js";import{r as c}from"./text-CGN4ZtUZ.js";import{t as l}from"./useMutation-C4CmK9Sb.js";import{r as u}from"./NullStore-BxU9yW8l.js";import{n as d}from"./language-selector-BZipfWXO.js";import{t as f}from"./triangle-alert-DSSurAZ_.js";import{t as p}from"./auth-page-header-DWIuRJtG.js";import{t as m}from"./alert-CFUBsmUN.js";import{t as h}from"./route-error-fallback-C2OHu3JW.js";import{r as g,t as _}from"./standard-schema-C8Td_miB.js";import{r as v}from"./FieldItemContext-CPjig163.js";import{a as y,i as b,n as x}from"./schemas-Dxi9xZo6.js";import{n as S,t as C}from"./promise-C4eJsjRN.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-Bm4sHkx9.js";import{t as D}from"./auth-layout-BFD6Jwkd.js";import{t as O}from"./labeled-separator-DkexQjxp.js";import{t as k}from"./sanitized-rich-text-nFi_4i6F.js";import{n as A,r as j,t as M}from"./terms-BEja7rHN.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
+ import{$ as e,J as t,a as n,f as r,o as i}from"./components-C1SipCbb.js";import{t as a}from"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s}from"./api-0SzZx6X7.js";import{r as c}from"./text-CGN4ZtUZ.js";import{t as l}from"./useMutation-C4CmK9Sb.js";import{r as u}from"./NullStore-BxU9yW8l.js";import{n as d}from"./language-selector-CGXk9vW_.js";import{t as f}from"./triangle-alert-DSSurAZ_.js";import{t as p}from"./auth-page-header-D5Z-EA6V.js";import{t as m}from"./alert-CFUBsmUN.js";import{t as h}from"./route-error-fallback-C2OHu3JW.js";import{r as g,t as _}from"./standard-schema-C8Td_miB.js";import{r as v}from"./FieldItemContext-CPjig163.js";import{a as y,i as b,n as x}from"./schemas-Dxi9xZo6.js";import{n as S,t as C}from"./promise-CFWkfv2A.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-Bm4sHkx9.js";import{t as D}from"./auth-layout-CFKu8bHI.js";import{t as O}from"./labeled-separator-DkexQjxp.js";import{t as k}from"./sanitized-rich-text-nFi_4i6F.js";import{n as A,r as j,t as M}from"./terms-BReb6uEz.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,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 ee,i as c,n as l,t as u}from"./api-0SzZx6X7.js";import{r as d}from"./text-CGN4ZtUZ.js";import{t as te}from"./useMutation-C4CmK9Sb.js";import{t as f}from"./mutationOptions-Dfvzj6n2.js";import{r as p}from"./NullStore-BxU9yW8l.js";import{t as m}from"./auth-field-1EM9pnWe.js";import{t as h}from"./authorization-context-banner-WE0b3j97.js";import{n as g}from"./language-selector-BZipfWXO.js";import{t as _}from"./lock-m97gMmUy.js";import{t as v}from"./mail-tgQpWyoC.js";import{t as y}from"./auth-page-header-DWIuRJtG.js";import{t as b}from"./route-error-fallback-C2OHu3JW.js";import{r as x,t as S}from"./standard-schema-C8Td_miB.js";import{r as ne}from"./FieldItemContext-CPjig163.js";import{a as C,i as re,n as ie,r as ae,s as w}from"./schemas-Dxi9xZo6.js";import{n as T,t as E}from"./promise-C4eJsjRN.js";import{t as D}from"./document-navigation-Cnp3Alf0.js";import{n as O,r as k,t as A}from"./route-module-Bm4sHkx9.js";import{t as j}from"./auth-layout-BFD6Jwkd.js";import{n as M,t as N}from"./auth-footer-DgRsLHyD.js";import{t as P}from"./labeled-separator-DkexQjxp.js";import{a as F,r as I,t as L}from"./oauth-search-BtLPTIS7.js";import{t as R}from"./sanitized-rich-text-nFi_4i6F.js";import{t as z}from"./password-strength-DLtV7dBZ.js";import{r as B,t as oe}from"./terms-BEja7rHN.js";var V=e(t(),1),H=f({mutationFn:async e=>{let t=await u.api.auth.register.$post({json:e,header:{}});return l(t)}}),U=o();function W({search:e}){let{t,i18n:n}=ee(),i=r(),o=s(),l=(e,t)=>i(t?k(e,t):e),u=e.lang??n.language,f=(0,V.useDeferredValue)(u),{data:b}=d(g),{data:O}=d(oe(f)),A=b.auth.password.enabled,W=b.auth.password.policy,G=O.terms.length>0,K=(0,V.useMemo)(()=>O.terms.filter(e=>e.consentMode===`explicit`),[O.terms]),q=K.length>0,J=b.registration.signup_notice?.[u]??b.registration.signup_notice?.[b.i18n.fallback_language],se=(0,V.useMemo)(()=>C({email:w().min(1,t(`validation.email.required`)).pipe(ae(t(`validation.email.invalid`))),password:w().min(W.min_length,t(`validation.password.min`,{count:W.min_length})).max(W.max_length,t(`validation.password.max`,{count:W.max_length})),termsConsents:C(Object.fromEntries(K.map(e=>[e.id,e.required?re(!0,{message:t(`validation.terms.required`)}):ie()])))}),[K,W.max_length,W.min_length,t]),Y=te({...H,onSuccess:async(t,n)=>{let r=t.user;if(r.email_verification_required&&!r.email_verified)return l(`/verify/email`,{email:n.email,...I(e)});if(o.setQueryData(T.queryKey,{user:r}),await E(),r.second_factor_required){let t=[];return b.auth.password.totp.enabled&&t.push(`totp`),b.auth.passkey.enabled&&t.push(`passkey`),t.length===1?t[0]===`totp`?l(`/setup/totp`,I(e)):l(`/setup/passkey`,{...I(e),passkey_name:`default`}):l(`/setup/2fa`,I(e))}F(e)?D(L(e)):i(`/profile`)},onError:e=>{e instanceof c?e.code===`REGISTRATION_EMAIL_NOT_ALLOWED`?Z(`email`,{type:`manual`,message:t(`register.error.emailNotAllowed`)}):e.code===`REGISTRATION_DISABLED`?Z(`email`,{type:`manual`,message:t(`register.error.registrationDisabled`)}):Z(`email`,{type:`manual`,message:t(`register.error.emailExists`)}):Z(`email`,{type:`manual`,message:t(`register.error.emailExists`)})},onSettled:async()=>{await o.invalidateQueries({queryKey:T.queryKey})}}),{register:X,setError:Z,handleSubmit:Q,control:ce,setValue:le,watch:ue,formState:{errors:$}}=x({defaultValues:{email:``,password:``,termsConsents:Object.fromEntries(K.map(e=>[e.id,!1]))},resolver:S(se),mode:`onChange`}),de=ue(`password`);return(0,U.jsxs)(j,{children:[(0,U.jsx)(y,{subtitle:t(`register.subtitle`),title:t(`register.title`)}),(0,U.jsx)(h,{search:e}),A&&(0,U.jsxs)(ne,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:Q(e=>{let t=G?K.map(t=>({termsId:t.id,agreed:e.termsConsents[t.id]??!1})):void 0;Y.mutate({email:e.email,password:e.password,consents:t})}),children:[(0,U.jsx)(m,{autoComplete:`email`,error:$.email,icon:v,label:t(`register.email.label`),placeholder:t(`register.email.placeholder`),...X(`email`),type:`email`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,U.jsx)(m,{autoComplete:`new-password`,error:$.password,hint:t(`register.password.hint`,{count:W.min_length}),icon:_,label:t(`register.password.label`),placeholder:t(`register.password.placeholder`),...X(`password`),type:`password`}),(0,U.jsx)(z,{password:de,policy:W})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[J&&(0,U.jsx)(`div`,{"data-testid":`terms-implicit-notice`,children:(0,U.jsx)(R,{html:J,variant:`notice`})}),J&&q&&(0,U.jsx)(P,{label:t(`terms.additionalOptionalConsent`)}),G&&q&&(0,U.jsx)(B,{control:ce,disabled:Y.isPending,errors:$,setValue:le,terms:K})]}),(0,U.jsx)(p,{className:`w-full`,intent:`primary`,loading:Y.isPending,loadingLabel:t(`register.submitting`),type:`submit`,uiSize:`lg`,children:t(`register.submit`)})]}),(0,U.jsx)(N,{children:(0,U.jsx)(M,{link:(0,U.jsx)(a,{to:k(`/login`,I(e)),children:t(`register.link.login`)}),text:t(`register.footer.haveAccount`)})})]})}var G=i(function({error:e}){return(0,U.jsx)(A,{component:b,error:e})}),K=n(function({loaderData:e}){return(0,U.jsx)(O,{state:e.dehydratedState,children:(0,U.jsx)(W,{search:e.search})})});export{G as ErrorBoundary,K as default};
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 ee,i as c,n as l,t as u}from"./api-0SzZx6X7.js";import{r as d}from"./text-CGN4ZtUZ.js";import{t as te}from"./useMutation-C4CmK9Sb.js";import{t as f}from"./mutationOptions-Dfvzj6n2.js";import{r as p}from"./NullStore-BxU9yW8l.js";import{t as m}from"./auth-field-1EM9pnWe.js";import{t as h}from"./authorization-context-banner-Cqtzj9A1.js";import{n as g}from"./language-selector-CGXk9vW_.js";import{t as _}from"./lock-m97gMmUy.js";import{t as v}from"./mail-tgQpWyoC.js";import{t as y}from"./auth-page-header-D5Z-EA6V.js";import{t as b}from"./route-error-fallback-C2OHu3JW.js";import{r as x,t as S}from"./standard-schema-C8Td_miB.js";import{r as ne}from"./FieldItemContext-CPjig163.js";import{a as C,i as re,n as ie,r as ae,s as w}from"./schemas-Dxi9xZo6.js";import{n as T,t as E}from"./promise-CFWkfv2A.js";import{t as D}from"./document-navigation-Cnp3Alf0.js";import{n as O,r as k,t as A}from"./route-module-Bm4sHkx9.js";import{t as j}from"./auth-layout-CFKu8bHI.js";import{n as M,t as N}from"./auth-footer-DgRsLHyD.js";import{t as P}from"./labeled-separator-DkexQjxp.js";import{a as F,r as I,t as L}from"./oauth-search-BtLPTIS7.js";import{t as R}from"./sanitized-rich-text-nFi_4i6F.js";import{t as z}from"./password-strength-DLtV7dBZ.js";import{r as B,t as oe}from"./terms-BReb6uEz.js";var V=e(t(),1),H=f({mutationFn:async e=>{let t=await u.api.auth.register.$post({json:e,header:{}});return l(t)}}),U=o();function W({search:e}){let{t,i18n:n}=ee(),i=r(),o=s(),l=(e,t)=>i(t?k(e,t):e),u=e.lang??n.language,f=(0,V.useDeferredValue)(u),{data:b}=d(g),{data:O}=d(oe(f)),A=b.auth.password.enabled,W=b.auth.password.policy,G=O.terms.length>0,K=(0,V.useMemo)(()=>O.terms.filter(e=>e.consentMode===`explicit`),[O.terms]),q=K.length>0,J=b.registration.signup_notice?.[u]??b.registration.signup_notice?.[b.i18n.fallback_language],se=(0,V.useMemo)(()=>C({email:w().min(1,t(`validation.email.required`)).pipe(ae(t(`validation.email.invalid`))),password:w().min(W.min_length,t(`validation.password.min`,{count:W.min_length})).max(W.max_length,t(`validation.password.max`,{count:W.max_length})),termsConsents:C(Object.fromEntries(K.map(e=>[e.id,e.required?re(!0,{message:t(`validation.terms.required`)}):ie()])))}),[K,W.max_length,W.min_length,t]),Y=te({...H,onSuccess:async(t,n)=>{let r=t.user;if(r.email_verification_required&&!r.email_verified)return l(`/verify/email`,{email:n.email,...I(e)});if(o.setQueryData(T.queryKey,{user:r}),await E(),r.second_factor_required){let t=[];return b.auth.password.totp.enabled&&t.push(`totp`),b.auth.passkey.enabled&&t.push(`passkey`),t.length===1?t[0]===`totp`?l(`/setup/totp`,I(e)):l(`/setup/passkey`,{...I(e),passkey_name:`default`}):l(`/setup/2fa`,I(e))}F(e)?D(L(e)):i(`/profile`)},onError:e=>{e instanceof c?e.code===`REGISTRATION_EMAIL_NOT_ALLOWED`?Z(`email`,{type:`manual`,message:t(`register.error.emailNotAllowed`)}):e.code===`REGISTRATION_DISABLED`?Z(`email`,{type:`manual`,message:t(`register.error.registrationDisabled`)}):Z(`email`,{type:`manual`,message:t(`register.error.emailExists`)}):Z(`email`,{type:`manual`,message:t(`register.error.emailExists`)})},onSettled:async()=>{await o.invalidateQueries({queryKey:T.queryKey})}}),{register:X,setError:Z,handleSubmit:Q,control:ce,setValue:le,watch:ue,formState:{errors:$}}=x({defaultValues:{email:``,password:``,termsConsents:Object.fromEntries(K.map(e=>[e.id,!1]))},resolver:S(se),mode:`onChange`}),de=ue(`password`);return(0,U.jsxs)(j,{children:[(0,U.jsx)(y,{subtitle:t(`register.subtitle`),title:t(`register.title`)}),(0,U.jsx)(h,{search:e}),A&&(0,U.jsxs)(ne,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:Q(e=>{let t=G?K.map(t=>({termsId:t.id,agreed:e.termsConsents[t.id]??!1})):void 0;Y.mutate({email:e.email,password:e.password,consents:t})}),children:[(0,U.jsx)(m,{autoComplete:`email`,error:$.email,icon:v,label:t(`register.email.label`),placeholder:t(`register.email.placeholder`),...X(`email`),type:`email`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[(0,U.jsx)(m,{autoComplete:`new-password`,error:$.password,hint:t(`register.password.hint`,{count:W.min_length}),icon:_,label:t(`register.password.label`),placeholder:t(`register.password.placeholder`),...X(`password`),type:`password`}),(0,U.jsx)(z,{password:de,policy:W})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[J&&(0,U.jsx)(`div`,{"data-testid":`terms-implicit-notice`,children:(0,U.jsx)(R,{html:J,variant:`notice`})}),J&&q&&(0,U.jsx)(P,{label:t(`terms.additionalOptionalConsent`)}),G&&q&&(0,U.jsx)(B,{control:ce,disabled:Y.isPending,errors:$,setValue:le,terms:K})]}),(0,U.jsx)(p,{className:`w-full`,intent:`primary`,loading:Y.isPending,loadingLabel:t(`register.submitting`),type:`submit`,uiSize:`lg`,children:t(`register.submit`)})]}),(0,U.jsx)(N,{children:(0,U.jsx)(M,{link:(0,U.jsx)(a,{to:k(`/login`,I(e)),children:t(`register.link.login`)}),text:t(`register.footer.haveAccount`)})})]})}var G=i(function({error:e}){return(0,U.jsx)(A,{component:b,error:e})}),K=n(function({loaderData:e}){return(0,U.jsx)(O,{state:e.dehydratedState,children:(0,U.jsx)(W,{search:e.search})})});export{G as ErrorBoundary,K 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"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s,i as c,n as l,t as u}from"./api-0SzZx6X7.js";import{n as d,r as f,t as p}from"./text-CGN4ZtUZ.js";import{t as m}from"./useMutation-C4CmK9Sb.js";import{t as h}from"./useQuery-BtUeFnRt.js";import{t as g}from"./mutationOptions-Dfvzj6n2.js";import{V as _}from"./select--ltVnlVl.js";import{a as v,i as y,r as b,t as x}from"./shell-header-bar-CtUdWFmD.js";import{i as S,r as C}from"./NullStore-BxU9yW8l.js";import{t as w}from"./card-CTv8DubK.js";import{t as T}from"./circle-alert-DGTJ9B9k.js";import{a as E,i as D,n as ee,r as O,t as k}from"./use-totp-setup-BwOsP75D.js";import{t as A}from"./auth-field-1EM9pnWe.js";import{t as j}from"./fingerprint-pattern-V_eTEvnZ.js";import{t as M}from"./key-round-DgCbGqQL.js";import{n as N,r as P}from"./language-selector-BZipfWXO.js";import{n as F,t as I}from"./provider-mark-B05f08GZ.js";import{n as te,r as ne,t as re}from"./logout-CBTnIosZ.js";import{t as L}from"./shield-check-93-WFkyJ.js";import{t as R}from"./trash-2-BOsxjkzU.js";import{t as z}from"./triangle-alert-DSSurAZ_.js";import{t as ie}from"./auth-page-header-DWIuRJtG.js";import{t as ae}from"./link-button-qvSTUE1n.js";import{t as B}from"./alert-CFUBsmUN.js";import{n as V,t as H}from"./modal-LoTH9Ttl.js";import{t as oe}from"./initial-avatar-D4aPMV9z.js";import{t as U}from"./route-error-fallback-C2OHu3JW.js";import{r as W,t as G}from"./standard-schema-C8Td_miB.js";import{r as K}from"./FieldItemContext-CPjig163.js";import{a as q,s as J}from"./schemas-Dxi9xZo6.js";import{n as Y,t as se}from"./promise-C4eJsjRN.js";import{n as ce,r as le}from"./totp-BW4BoCpi.js";import{t as ue}from"./badge-BCQspax5.js";import{a as de,i as fe,n as pe,r as me}from"./passkey-DoR9gw8n.js";import{t as he}from"./document-navigation-Cnp3Alf0.js";import{n as ge,t as _e}from"./route-module-Bm4sHkx9.js";var ve=_(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),ye=_(`link-2-off`,[[`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=_(`pencil`,[[`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`}]]),xe=_(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),X=e(t(),1),Z=a();function Se({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 Ce({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 we({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)(Ce,{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 Te({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 Ee({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 De({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 Oe={error:T,warning:z,info:E};function $({variant:e,children:t}){return(0,Z.jsx)(B,{"data-testid":`alert-banner-${e}`,icon:Oe[e],type:e,children:t})}function ke({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:ye,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 Ae({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 je({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)(Ae,{label:t(`profile.id.label`),value:e.sub}),(0,Z.jsx)(Ae,{label:t(`profile.email.label`),value:e.email})]})]})}function Me({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 Ne=g({mutationFn:async e=>{let t=await u.api.user.password.$post({json:e});return l(t)}}),Pe=g({mutationFn:async e=>{let t=await u.api.user.password.$put({json:e});return l(t)}}),Fe=g({mutationFn:async e=>{let t=await u.api.user.password.$delete({json:e});return l(t)}});function Ie({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({...Pe,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 Le=g({mutationFn:async()=>{let e=await u.api.user.$delete();return l(e)}});function Re({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({...Le,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 ze({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 Be({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)(Ve,{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 Ve({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)(ve,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}):(0,Z.jsx)(xe,{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)(be,{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 He({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 Ue({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({...Fe,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 We({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({...Ne,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 Ge({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 Ke({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 qe=(e=>d({queryKey:P.oauth.accounts(),queryFn:async()=>{let t=await e.api.user[`oauth-accounts`].$get();return l(t)}}))(u),Je=g({mutationFn:async e=>{let t=await u.api.oauth[`:provider`].$delete({param:{provider:e}});return l(t)}});function Ye(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 Xe={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`};function Ze(e){return(0,Z.jsx)(U,{...e,onUnauthorized:()=>{he(`/login`)}})}function Qe({search:e}){let{t}=s(),n=r(),i=o(),a=e.oauth_error,c=a?t(Xe[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(qe),{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({...Je,onSuccess:()=>{i.invalidateQueries({queryKey:qe.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)(Me,{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)(je,{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)(Ee,{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)(De,{onOpenModal:y,recoveryCodesMissing:M.totp_recovery_codes_missing,totpEnabled:M.totp_registered}),W&&(0,Z.jsx)(Te,{onOpenModal:x,passkeyCount:M.passkey_count})]})]}),G&&(0,Z.jsx)(we,{getAuthorizeUrl:Ye,onUnlinkRequest:e=>h({id:e.id,name:e.display_name}),providers:P,unlinkingProvider:l}),(0,Z.jsx)(Se,{isConfigManaged:I,isDeletionEnabled:ae,onDeleteClick:()=>E(!0)}),(0,Z.jsx)(We,{isOpen:g===`set`,onClose:()=>_(null)}),(0,Z.jsx)(Ie,{isOpen:g===`change`,onClose:()=>_(null)}),(0,Z.jsx)(Ue,{isOpen:g===`remove`,onClose:()=>_(null)}),(0,Z.jsx)(Ke,{isOpen:v===`setup`,onClose:()=>y(null)}),(0,Z.jsx)(ze,{isOpen:v===`disable`,onClose:()=>y(null)}),(0,Z.jsx)(He,{isOpen:v===`regenerate`,onClose:()=>y(null)}),(0,Z.jsx)(Ge,{isOpen:b===`setup`,onClose:()=>x(null)}),(0,Z.jsx)(Be,{isOpen:b===`manage`,onAddNew:()=>x(`setup`),onClose:()=>x(null)}),(0,Z.jsx)(ke,{isOpen:d!==null,isPending:A.isPending,onClose:()=>h(null),onConfirm:j,providerName:d?.name??``}),(0,Z.jsx)(Re,{isOpen:S,onClose:()=>E(!1),retentionDays:H})]})}var $e=i(function({error:e}){return(0,Z.jsx)(_e,{component:Ze,error:e})}),et=n(function({loaderData:e}){return(0,Z.jsx)(ge,{state:e.dehydratedState,children:(0,Z.jsx)(Qe,{search:e.search})})});export{$e as ErrorBoundary,et as default};
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"./jsx-runtime-BFZ_fnNJ.js";import{L as o,a as s,i as c,n as l,t as u}from"./api-0SzZx6X7.js";import{n as d,r as f,t as p}from"./text-CGN4ZtUZ.js";import{t as m}from"./useMutation-C4CmK9Sb.js";import{t as h}from"./useQuery-BtUeFnRt.js";import{t as g}from"./mutationOptions-Dfvzj6n2.js";import{V as _}from"./select--ltVnlVl.js";import{a as v,i as y,r as b,t as x}from"./shell-header-bar-C3KYib1D.js";import{i as S,r as C}from"./NullStore-BxU9yW8l.js";import{t as w}from"./card-CTv8DubK.js";import{t as T}from"./circle-alert-DGTJ9B9k.js";import{a as E,i as D,n as ee,r as O,t as k}from"./use-totp-setup-BOSkSnYG.js";import{t as A}from"./auth-field-1EM9pnWe.js";import{t as j}from"./fingerprint-pattern-V_eTEvnZ.js";import{t as M}from"./key-round-DgCbGqQL.js";import{n as N,r as P}from"./language-selector-CGXk9vW_.js";import{n as F,t as I}from"./provider-mark-B05f08GZ.js";import{n as te,r as ne,t as re}from"./logout-CBTnIosZ.js";import{t as L}from"./shield-check-93-WFkyJ.js";import{t as R}from"./trash-2-BOsxjkzU.js";import{t as z}from"./triangle-alert-DSSurAZ_.js";import{t as ie}from"./auth-page-header-D5Z-EA6V.js";import{t as ae}from"./link-button-qvSTUE1n.js";import{t as B}from"./alert-CFUBsmUN.js";import{n as V,t as H}from"./modal-LoTH9Ttl.js";import{t as oe}from"./initial-avatar-D4aPMV9z.js";import{t as U}from"./route-error-fallback-C2OHu3JW.js";import{r as W,t as G}from"./standard-schema-C8Td_miB.js";import{r as K}from"./FieldItemContext-CPjig163.js";import{a as q,s as J}from"./schemas-Dxi9xZo6.js";import{n as Y,t as se}from"./promise-CFWkfv2A.js";import{n as ce,r as le}from"./totp-BW4BoCpi.js";import{t as ue}from"./badge-BCQspax5.js";import{a as de,i as fe,n as pe,r as me}from"./passkey-C9bzur2Z.js";import{t as he}from"./document-navigation-Cnp3Alf0.js";import{n as ge,t as _e}from"./route-module-Bm4sHkx9.js";var ve=_(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),ye=_(`link-2-off`,[[`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=_(`pencil`,[[`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`}]]),xe=_(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),X=e(t(),1),Z=a();function Se({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 Ce({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 we({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)(Ce,{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 Te({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 Ee({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 De({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 Oe={error:T,warning:z,info:E};function $({variant:e,children:t}){return(0,Z.jsx)(B,{"data-testid":`alert-banner-${e}`,icon:Oe[e],type:e,children:t})}function ke({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:ye,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 Ae({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 je({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)(Ae,{label:t(`profile.id.label`),value:e.sub}),(0,Z.jsx)(Ae,{label:t(`profile.email.label`),value:e.email})]})]})}function Me({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 Ne=g({mutationFn:async e=>{let t=await u.api.user.password.$post({json:e});return l(t)}}),Pe=g({mutationFn:async e=>{let t=await u.api.user.password.$put({json:e});return l(t)}}),Fe=g({mutationFn:async e=>{let t=await u.api.user.password.$delete({json:e});return l(t)}});function Ie({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({...Pe,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 Le=g({mutationFn:async()=>{let e=await u.api.user.$delete();return l(e)}});function Re({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({...Le,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 ze({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 Be({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)(Ve,{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 Ve({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)(ve,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}):(0,Z.jsx)(xe,{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)(be,{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 He({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 Ue({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({...Fe,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 We({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({...Ne,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 Ge({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 Ke({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 qe=(e=>d({queryKey:P.oauth.accounts(),queryFn:async()=>{let t=await e.api.user[`oauth-accounts`].$get();return l(t)}}))(u),Je=g({mutationFn:async e=>{let t=await u.api.oauth[`:provider`].$delete({param:{provider:e}});return l(t)}});function Ye(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 Xe={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`};function Ze(e){return(0,Z.jsx)(U,{...e,onUnauthorized:()=>{he(`/login`)}})}function Qe({search:e}){let{t}=s(),n=r(),i=o(),a=e.oauth_error,c=a?t(Xe[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(qe),{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({...Je,onSuccess:()=>{i.invalidateQueries({queryKey:qe.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)(Me,{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)(je,{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)(Ee,{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)(De,{onOpenModal:y,recoveryCodesMissing:M.totp_recovery_codes_missing,totpEnabled:M.totp_registered}),W&&(0,Z.jsx)(Te,{onOpenModal:x,passkeyCount:M.passkey_count})]})]}),G&&(0,Z.jsx)(we,{getAuthorizeUrl:Ye,onUnlinkRequest:e=>h({id:e.id,name:e.display_name}),providers:P,unlinkingProvider:l}),(0,Z.jsx)(Se,{isConfigManaged:I,isDeletionEnabled:ae,onDeleteClick:()=>E(!0)}),(0,Z.jsx)(We,{isOpen:g===`set`,onClose:()=>_(null)}),(0,Z.jsx)(Ie,{isOpen:g===`change`,onClose:()=>_(null)}),(0,Z.jsx)(Ue,{isOpen:g===`remove`,onClose:()=>_(null)}),(0,Z.jsx)(Ke,{isOpen:v===`setup`,onClose:()=>y(null)}),(0,Z.jsx)(ze,{isOpen:v===`disable`,onClose:()=>y(null)}),(0,Z.jsx)(He,{isOpen:v===`regenerate`,onClose:()=>y(null)}),(0,Z.jsx)(Ge,{isOpen:b===`setup`,onClose:()=>x(null)}),(0,Z.jsx)(Be,{isOpen:b===`manage`,onAddNew:()=>x(`setup`),onClose:()=>x(null)}),(0,Z.jsx)(ke,{isOpen:d!==null,isPending:A.isPending,onClose:()=>h(null),onConfirm:j,providerName:d?.name??``}),(0,Z.jsx)(Re,{isOpen:S,onClose:()=>E(!1),retentionDays:H})]})}var $e=i(function({error:e}){return(0,Z.jsx)(_e,{component:Ze,error:e})}),et=n(function({loaderData:e}){return(0,Z.jsx)(ge,{state:e.dehydratedState,children:(0,Z.jsx)(Qe,{search:e.search})})});export{$e as ErrorBoundary,et as default};