@plumix/admin 0.1.0 → 0.1.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 (50) hide show
  1. package/dist/assets/{-errors-D-cmkYbY.js → -errors-BJp83S61.js} +1 -1
  2. package/dist/assets/{-locale-param-R7YAVhAm.js → -locale-param-Y_oYVkUX.js} +1 -1
  3. package/dist/assets/{_-BgcFcUpb.js → _-DJH2KLIq.js} +1 -1
  4. package/dist/assets/{_authenticated-DabO2Qyv.js → _authenticated-CPS6rcL1.js} +1 -1
  5. package/dist/assets/{_authenticated-B2GjUlkG.js → _authenticated-DECJJkSG.js} +1 -1
  6. package/dist/assets/{_editor-Cj750bOw.js → _editor-DTQYo5H1.js} +1 -1
  7. package/dist/assets/{_name-4UEpyf0-.js → _name-Cn1TxMiD.js} +1 -1
  8. package/dist/assets/{_page-CW9_6SD1.js → _page-6Dt_H-t-.js} +1 -1
  9. package/dist/assets/{_page-B65xT7CY.js → _page-Dd9iXh9Y.js} +1 -1
  10. package/dist/assets/{_slug-B4JG-9fs.js → _slug-DfiOgvp-.js} +1 -1
  11. package/dist/assets/{_token-DbYWXSFn.js → _token-B5HSAv6u.js} +1 -1
  12. package/dist/assets/{allowed-domains-DYhKp_Ib.js → allowed-domains-C45hb_hj.js} +1 -1
  13. package/dist/assets/{bootstrap-DJz3cWv9.js → bootstrap-BGjxcccw.js} +1 -1
  14. package/dist/assets/breadcrumb-BV7HWDmi.js +1 -0
  15. package/dist/assets/{create-GWJoFtGc.js → create-Drjr9dfU.js} +1 -1
  16. package/dist/assets/{create-BBUSAO26.js → create-YjhP8uPI.js} +1 -1
  17. package/dist/assets/{create-CoSsIQco.js → create-twMn3ZJK.js} +1 -1
  18. package/dist/assets/{device-EMoc4lMH.js → device-CU0nQStx.js} +1 -1
  19. package/dist/assets/dist-9yav4OBD.js +46 -0
  20. package/dist/assets/{edit-DlHnrl_y.js → edit-BfhVPnGf.js} +1 -1
  21. package/dist/assets/{edit-DR0NupUB.js → edit-Bv4iDBop.js} +1 -1
  22. package/dist/assets/{edit-Bz9riMHP.js → edit-C7ilZiba.js} +1 -1
  23. package/dist/assets/{edit-BsC2RNOq.js → edit-CrzTOGqo.js} +1 -1
  24. package/dist/assets/edit-DVuHDSbc.js +2 -0
  25. package/dist/assets/{edit-C1985Bqy.js → edit-DwrFb_ta.js} +1 -1
  26. package/dist/assets/{form-BhMVtuYF.js → form-5CBmFjhZ.js} +1 -1
  27. package/dist/assets/{index-bWipSZdM.js → index-8CVr3Qp5.js} +4 -4
  28. package/dist/assets/{login-Cky2mine.js → login-CxdAEUCn.js} +1 -1
  29. package/dist/assets/{mailer-CnGqwCP4.js → mailer-DT9FFkYI.js} +1 -1
  30. package/dist/assets/{meta-box-CjxoPlkT.js → meta-box-B-N73b0I.js} +1 -1
  31. package/dist/assets/{meta-box-field-Cgn0DXDv.js → meta-box-field-gLyOLbwB.js} +1 -1
  32. package/dist/assets/{meta-box-grid-DJBtTRhe.js → meta-box-grid-CRboB-BG.js} +1 -1
  33. package/dist/assets/{plugin-error-boundary-3Oze9sdd.js → plugin-error-boundary-DlVIsgFV.js} +1 -1
  34. package/dist/assets/{rich-text-field-DGbPE_N0.js → rich-text-field-CHHhfy_b.js} +3 -3
  35. package/dist/assets/{search-input-BpOKuC8D.js → search-input-BSW1rAKi.js} +1 -1
  36. package/dist/assets/{separator-DCQAFSsS.js → separator-u9O31sRo.js} +1 -1
  37. package/dist/assets/{settings-DCqQvJiy.js → settings-szU4x17b.js} +1 -1
  38. package/dist/assets/{textarea-BoWLuA0I.js → textarea-BsZaGkV-.js} +1 -1
  39. package/dist/assets/{toast-CQk_AYCo.js → toast-UQxADDWA.js} +1 -1
  40. package/dist/assets/{toggle-Bfw56q6s.js → toggle-BfrQLxbv.js} +1 -1
  41. package/dist/assets/{tooltip-Pch4JgRX.js → tooltip-Dm_CbtVl.js} +1 -1
  42. package/dist/assets/{use-formatters-BlYPsMo8.js → use-formatters-HWxEQWaC.js} +1 -1
  43. package/dist/assets/{users-CYvrBtzp.js → users-BHorpfgX.js} +1 -1
  44. package/dist/assets/{utils-BBTvNyQG.js → utils-BtfRir_X.js} +2 -2
  45. package/dist/assets/{valibot-BKzEbLVK.js → valibot-D1tw6tkr.js} +1 -1
  46. package/dist/index.html +2 -2
  47. package/package.json +9 -9
  48. package/dist/assets/breadcrumb-TUgLmtOo.js +0 -1
  49. package/dist/assets/dist-Bdi1pykC.js +0 -46
  50. package/dist/assets/edit-CG12fZGb.js +0 -2
@@ -1 +1 @@
1
- import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{n as r}from"./dist-BL2bKHuR.js";import{t as i,u as a}from"./orpc-DURDArDu.js";import{n as o,r as s,t as c}from"./textarea-BoWLuA0I.js";import{t as l}from"./use-label-CykSHq9A.js";import{D as u,d,h as f,l as p,v as m,w as h,y as g}from"./dist-ClOzYsk5.js";import{o as _}from"./validation-CwFumc7a.js";import{a as v,i as y,n as b,r as x,t as S}from"./card-L2-kK5VK.js";import{C,Pt as w}from"./index-bWipSZdM.js";import{t as T}from"./input-xYuLUQID.js";import{a as E,c as D,f as O,i as k,n as A,o as j,p as M,s as N,t as P}from"./form-BhMVtuYF.js";import{n as F,t as I}from"./alert-cwX3fWUu.js";import{t as L}from"./valibot-BKzEbLVK.js";import{n as R,t as z}from"./orpc-errors-DWk96ZMY.js";import{t as B}from"./scopes-C_7AiPdH.js";var V=e(n()),H=e(t()),U={userCodePlaceholder:{id:`auth.device.userCode.placeholder`},tokenNamePlaceholder:{id:`auth.device.tokenName.placeholder`},scopesPlaceholder:{id:`auth.device.scopes.placeholder`},defaultTokenName:{id:`auth.device.tokenName.default`},errLookupNotFound:{id:`auth.device.lookup.error.notFound`},errLookupExpired:{id:`auth.device.lookup.error.expired`},errLookupAlreadyApproved:{id:`auth.device.lookup.error.alreadyApproved`},errLookupAlreadyDenied:{id:`auth.device.lookup.error.alreadyDenied`},errLookupFallback:{id:`auth.device.lookup.error.fallback`},errApproveExpired:{id:`auth.device.approve.error.expired`},errApproveAlreadyApproved:{id:`auth.device.approve.error.alreadyApproved`},errApproveAlreadyDenied:{id:`auth.device.approve.error.alreadyDenied`},errApproveFallback:{id:`auth.device.approve.error.fallback`}},W=`access_denied`,G=f({userCode:g(h(),u(),p(32))}),K=f({tokenName:g(h(),u(),d(1,_({id:`auth.device.tokenName.required`})),p(64,_({id:`auth.device.tokenName.tooLong`}))),scopeMode:m([`inherit`,`restrict`]),scopesText:g(h(),p(4096))});function q(){let e=C.useSearch(),[t,n]=(0,V.useState)(()=>e.user_code?{kind:`approve`,userCode:e.user_code}:{kind:`lookup`}),[a,o]=(0,V.useState)(null);return(0,V.useEffect)(()=>{t.kind===`approve`&&i.auth.deviceFlow.lookup.call({userCode:t.userCode}).catch(e=>{o(X(e)),n({kind:`lookup`})})},[]),(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-4`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h1`,{className:`text-2xl font-semibold`,"data-testid":`auth-device-heading`,children:(0,H.jsx)(r,{id:`auth.device.title`,message:`Authorize CLI access`})}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,H.jsx)(r,{id:`auth.device.description`,message:`A CLI is requesting an API token for your account. Confirm the code your CLI is showing matches the one below before approving.`})})]}),t.kind===`lookup`?(0,H.jsx)(J,{initialError:a,onValid:e=>{o(null),n({kind:`approve`,userCode:e})}}):null,t.kind===`approve`?(0,H.jsx)(Y,{userCode:t.userCode,onApproved:()=>n({kind:`approved`}),onDenied:()=>n({kind:`denied`}),onCancel:()=>n({kind:`lookup`})}):null,t.kind===`approved`?(0,H.jsx)(I,{"data-testid":`auth-device-approved-alert`,children:(0,H.jsx)(F,{children:(0,H.jsx)(r,{id:`auth.device.approved`,message:`Approved. Your CLI should pick up the token within a few seconds — you can close this tab.`})})}):null,t.kind===`denied`?(0,H.jsx)(I,{variant:`destructive`,"data-testid":`auth-device-denied-alert`,children:(0,H.jsx)(F,{children:(0,H.jsx)(r,{id:`auth.device.denied`,message:`Denied. The CLI will get a(n) <0>{accessDenied}</0> response and stop polling.`,values:{accessDenied:W},components:{0:(0,H.jsx)(`code`,{className:`font-mono text-xs`})},comment:`accessDenied: the literal OAuth error code string (e.g. 'access_denied') — do not translate`})})}):null]})}function J({initialError:e,onValid:t}){let n=l(),[o,s]=(0,V.useState)(e),c=O({resolver:L(G),defaultValues:{userCode:``},mode:`onSubmit`}),u=a({mutationFn:e=>i.auth.deviceFlow.lookup.call({userCode:e}),onMutate:()=>s(null),onSuccess:(e,n)=>t(n),onError:e=>{s(X(e))}});return(0,H.jsxs)(S,{children:[(0,H.jsxs)(y,{children:[(0,H.jsx)(v,{children:(0,H.jsx)(r,{id:`auth.device.lookup.title`,message:`Enter the code from your CLI`})}),(0,H.jsx)(x,{children:(0,H.jsx)(r,{id:`auth.device.lookup.description`,message:`The CLI shows an 8-character code split with a dash — "ABCD-EFGH". Letters and digits only, no zeros or ones.`})})]}),(0,H.jsx)(b,{children:(0,H.jsx)(P,{...c,children:(0,H.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:c.handleSubmit(e=>{u.mutate(e.userCode)}),children:[(0,H.jsx)(k,{control:c.control,name:`userCode`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{children:(0,H.jsx)(r,{id:`auth.device.lookup.userCode.label`,message:`User code`})}),(0,H.jsx)(A,{children:(0,H.jsx)(T,{autoFocus:!0,autoComplete:`off`,placeholder:n(U.userCodePlaceholder),disabled:u.isPending,"data-testid":`auth-device-usercode-input`,...e})}),(0,H.jsx)(N,{})]})}),o?(0,H.jsx)(I,{variant:`destructive`,"data-testid":`auth-device-lookup-error`,children:(0,H.jsx)(F,{children:n(o)})}):null,(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(w,{type:`submit`,disabled:u.isPending,"data-testid":`auth-device-lookup-submit`,children:u.isPending?(0,H.jsx)(r,{id:`auth.device.lookup.submit.pending`,message:`Checking…`}):(0,H.jsx)(r,{id:`auth.device.lookup.submit.idle`,message:`Continue`})})})]})})})]})}function Y({userCode:e,onApproved:t,onDenied:n,onCancel:u}){let d=l(),[f,p]=(0,V.useState)(null),m=O({resolver:L(K),defaultValues:{tokenName:d(U.defaultTokenName),scopeMode:`inherit`,scopesText:``},mode:`onBlur`}),h=M({control:m.control,name:`scopeMode`}),g=a({mutationFn:t=>i.auth.deviceFlow.approve.call({userCode:e,tokenName:t.tokenName,scopes:t.scopes===null?null:[...t.scopes]}),onMutate:()=>p(null),onSuccess:()=>t(),onError:e=>{p(Z(e))}}),_=a({mutationFn:()=>i.auth.deviceFlow.deny.call({userCode:e}),onMutate:()=>p(null),onSuccess:()=>n(),onError:e=>{p(Z(e))}}),C=g.isPending||_.isPending;return(0,H.jsxs)(S,{children:[(0,H.jsxs)(y,{children:[(0,H.jsx)(v,{children:(0,H.jsx)(r,{id:`auth.device.approve.confirmTitle`,message:`Confirm "{userCode}"`,values:{userCode:e},comment:`userCode: the short device-flow code the CLI displayed (e.g. 'WDJB-MJHT'); pass through verbatim`})}),(0,H.jsx)(x,{children:(0,H.jsx)(r,{id:`auth.device.approve.description`,message:`A new API token will be minted for your account and handed to the CLI. Name it so you can find it later under your profile, and optionally restrict what it can do.`})})]}),(0,H.jsx)(b,{children:(0,H.jsx)(P,{...m,children:(0,H.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:m.handleSubmit(e=>{let t=e.scopeMode===`inherit`?null:B(e.scopesText);g.mutate({tokenName:e.tokenName,scopes:t})}),children:[(0,H.jsx)(k,{control:m.control,name:`tokenName`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{children:(0,H.jsx)(r,{id:`auth.device.tokenName.label`,message:`Token name`})}),(0,H.jsx)(A,{children:(0,H.jsx)(T,{placeholder:d(U.tokenNamePlaceholder),disabled:C,"data-testid":`auth-device-tokenname-input`,...e})}),(0,H.jsx)(N,{})]})}),(0,H.jsx)(k,{control:m.control,name:`scopeMode`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{id:`auth-device-scope-label`,children:(0,H.jsx)(r,{id:`auth.device.scopeMode.label`,message:`Permissions`})}),(0,H.jsx)(A,{children:(0,H.jsxs)(o,{name:e.name,value:e.value,onValueChange:e.onChange,disabled:C,"aria-labelledby":`auth-device-scope-label`,className:`gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(s,{value:`inherit`,id:`auth-device-scope-inherit`,"data-testid":`auth-device-scope-inherit-radio`}),(0,H.jsx)(D,{htmlFor:`auth-device-scope-inherit`,className:`font-normal`,children:(0,H.jsx)(r,{id:`auth.device.scopeMode.inherit`,message:`Inherit all my permissions`})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(s,{value:`restrict`,id:`auth-device-scope-restrict`,"data-testid":`auth-device-scope-restrict-radio`}),(0,H.jsx)(D,{htmlFor:`auth-device-scope-restrict`,className:`font-normal`,children:(0,H.jsx)(r,{id:`auth.device.scopeMode.restrict`,message:`Restrict to specific capabilities`})})]})]})}),(0,H.jsx)(N,{})]})}),h===`restrict`?(0,H.jsx)(k,{control:m.control,name:`scopesText`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{children:(0,H.jsx)(r,{id:`auth.device.scopes.label`,message:`Capabilities`})}),(0,H.jsx)(A,{children:(0,H.jsx)(c,{rows:4,placeholder:d(U.scopesPlaceholder),disabled:C,"data-testid":`auth-device-scopes-textarea`,className:`font-mono`,...e})}),(0,H.jsx)(N,{})]})}):null,f?(0,H.jsx)(I,{variant:`destructive`,"data-testid":`auth-device-error`,children:(0,H.jsx)(F,{children:d(f)})}):null,(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(w,{type:`button`,variant:`ghost`,disabled:C,onClick:u,"data-testid":`auth-device-cancel-button`,children:(0,H.jsx)(r,{id:`auth.device.cancel`,message:`Cancel`})}),(0,H.jsx)(w,{type:`button`,variant:`outline`,disabled:C,onClick:()=>_.mutate(),"data-testid":`auth-device-deny-button`,children:_.isPending?(0,H.jsx)(r,{id:`auth.device.deny.pending`,message:`Denying…`}):(0,H.jsx)(r,{id:`auth.device.deny.idle`,message:`Deny`})}),(0,H.jsx)(w,{type:`submit`,disabled:C,"data-testid":`auth-device-approve-button`,children:g.isPending?(0,H.jsx)(r,{id:`auth.device.approve.pending`,message:`Approving…`}):(0,H.jsx)(r,{id:`auth.device.approve.idle`,message:`Approve`})})]})]})})})]})}function X(e){let t=z(e);if(t===`NOT_FOUND`)return U.errLookupNotFound;if(t===`CONFLICT`){let t=R(e);if(t===`expired`)return U.errLookupExpired;if(t===`already_approved`)return U.errLookupAlreadyApproved;if(t===`already_denied`)return U.errLookupAlreadyDenied}return U.errLookupFallback}function Z(e){if(z(e)===`CONFLICT`){let t=R(e);if(t===`expired`)return U.errApproveExpired;if(t===`already_approved`)return U.errApproveAlreadyApproved;if(t===`already_denied`)return U.errApproveAlreadyDenied}return U.errApproveFallback}export{q as component};
1
+ import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-DbyrFoBd.js";import{n as r}from"./dist-BL2bKHuR.js";import{t as i,u as a}from"./orpc-DURDArDu.js";import{n as o,r as s,t as c}from"./textarea-BsZaGkV-.js";import{t as l}from"./use-label-CykSHq9A.js";import{D as u,d,h as f,l as p,v as m,w as h,y as g}from"./dist-ClOzYsk5.js";import{o as _}from"./validation-CwFumc7a.js";import{a as v,i as y,n as b,r as x,t as S}from"./card-L2-kK5VK.js";import{C,Pt as w}from"./index-8CVr3Qp5.js";import{t as T}from"./input-xYuLUQID.js";import{a as E,c as D,f as O,i as k,n as A,o as j,p as M,s as N,t as P}from"./form-5CBmFjhZ.js";import{n as F,t as I}from"./alert-cwX3fWUu.js";import{t as L}from"./valibot-D1tw6tkr.js";import{n as R,t as z}from"./orpc-errors-DWk96ZMY.js";import{t as B}from"./scopes-C_7AiPdH.js";var V=e(n()),H=e(t()),U={userCodePlaceholder:{id:`auth.device.userCode.placeholder`},tokenNamePlaceholder:{id:`auth.device.tokenName.placeholder`},scopesPlaceholder:{id:`auth.device.scopes.placeholder`},defaultTokenName:{id:`auth.device.tokenName.default`},errLookupNotFound:{id:`auth.device.lookup.error.notFound`},errLookupExpired:{id:`auth.device.lookup.error.expired`},errLookupAlreadyApproved:{id:`auth.device.lookup.error.alreadyApproved`},errLookupAlreadyDenied:{id:`auth.device.lookup.error.alreadyDenied`},errLookupFallback:{id:`auth.device.lookup.error.fallback`},errApproveExpired:{id:`auth.device.approve.error.expired`},errApproveAlreadyApproved:{id:`auth.device.approve.error.alreadyApproved`},errApproveAlreadyDenied:{id:`auth.device.approve.error.alreadyDenied`},errApproveFallback:{id:`auth.device.approve.error.fallback`}},W=`access_denied`,G=f({userCode:g(h(),u(),p(32))}),K=f({tokenName:g(h(),u(),d(1,_({id:`auth.device.tokenName.required`})),p(64,_({id:`auth.device.tokenName.tooLong`}))),scopeMode:m([`inherit`,`restrict`]),scopesText:g(h(),p(4096))});function q(){let e=C.useSearch(),[t,n]=(0,V.useState)(()=>e.user_code?{kind:`approve`,userCode:e.user_code}:{kind:`lookup`}),[a,o]=(0,V.useState)(null);return(0,V.useEffect)(()=>{t.kind===`approve`&&i.auth.deviceFlow.lookup.call({userCode:t.userCode}).catch(e=>{o(X(e)),n({kind:`lookup`})})},[]),(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-4`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h1`,{className:`text-2xl font-semibold`,"data-testid":`auth-device-heading`,children:(0,H.jsx)(r,{id:`auth.device.title`,message:`Authorize CLI access`})}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:(0,H.jsx)(r,{id:`auth.device.description`,message:`A CLI is requesting an API token for your account. Confirm the code your CLI is showing matches the one below before approving.`})})]}),t.kind===`lookup`?(0,H.jsx)(J,{initialError:a,onValid:e=>{o(null),n({kind:`approve`,userCode:e})}}):null,t.kind===`approve`?(0,H.jsx)(Y,{userCode:t.userCode,onApproved:()=>n({kind:`approved`}),onDenied:()=>n({kind:`denied`}),onCancel:()=>n({kind:`lookup`})}):null,t.kind===`approved`?(0,H.jsx)(I,{"data-testid":`auth-device-approved-alert`,children:(0,H.jsx)(F,{children:(0,H.jsx)(r,{id:`auth.device.approved`,message:`Approved. Your CLI should pick up the token within a few seconds — you can close this tab.`})})}):null,t.kind===`denied`?(0,H.jsx)(I,{variant:`destructive`,"data-testid":`auth-device-denied-alert`,children:(0,H.jsx)(F,{children:(0,H.jsx)(r,{id:`auth.device.denied`,message:`Denied. The CLI will get a(n) <0>{accessDenied}</0> response and stop polling.`,values:{accessDenied:W},components:{0:(0,H.jsx)(`code`,{className:`font-mono text-xs`})},comment:`accessDenied: the literal OAuth error code string (e.g. 'access_denied') — do not translate`})})}):null]})}function J({initialError:e,onValid:t}){let n=l(),[o,s]=(0,V.useState)(e),c=O({resolver:L(G),defaultValues:{userCode:``},mode:`onSubmit`}),u=a({mutationFn:e=>i.auth.deviceFlow.lookup.call({userCode:e}),onMutate:()=>s(null),onSuccess:(e,n)=>t(n),onError:e=>{s(X(e))}});return(0,H.jsxs)(S,{children:[(0,H.jsxs)(y,{children:[(0,H.jsx)(v,{children:(0,H.jsx)(r,{id:`auth.device.lookup.title`,message:`Enter the code from your CLI`})}),(0,H.jsx)(x,{children:(0,H.jsx)(r,{id:`auth.device.lookup.description`,message:`The CLI shows an 8-character code split with a dash — "ABCD-EFGH". Letters and digits only, no zeros or ones.`})})]}),(0,H.jsx)(b,{children:(0,H.jsx)(P,{...c,children:(0,H.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:c.handleSubmit(e=>{u.mutate(e.userCode)}),children:[(0,H.jsx)(k,{control:c.control,name:`userCode`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{children:(0,H.jsx)(r,{id:`auth.device.lookup.userCode.label`,message:`User code`})}),(0,H.jsx)(A,{children:(0,H.jsx)(T,{autoFocus:!0,autoComplete:`off`,placeholder:n(U.userCodePlaceholder),disabled:u.isPending,"data-testid":`auth-device-usercode-input`,...e})}),(0,H.jsx)(N,{})]})}),o?(0,H.jsx)(I,{variant:`destructive`,"data-testid":`auth-device-lookup-error`,children:(0,H.jsx)(F,{children:n(o)})}):null,(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(w,{type:`submit`,disabled:u.isPending,"data-testid":`auth-device-lookup-submit`,children:u.isPending?(0,H.jsx)(r,{id:`auth.device.lookup.submit.pending`,message:`Checking…`}):(0,H.jsx)(r,{id:`auth.device.lookup.submit.idle`,message:`Continue`})})})]})})})]})}function Y({userCode:e,onApproved:t,onDenied:n,onCancel:u}){let d=l(),[f,p]=(0,V.useState)(null),m=O({resolver:L(K),defaultValues:{tokenName:d(U.defaultTokenName),scopeMode:`inherit`,scopesText:``},mode:`onBlur`}),h=M({control:m.control,name:`scopeMode`}),g=a({mutationFn:t=>i.auth.deviceFlow.approve.call({userCode:e,tokenName:t.tokenName,scopes:t.scopes===null?null:[...t.scopes]}),onMutate:()=>p(null),onSuccess:()=>t(),onError:e=>{p(Z(e))}}),_=a({mutationFn:()=>i.auth.deviceFlow.deny.call({userCode:e}),onMutate:()=>p(null),onSuccess:()=>n(),onError:e=>{p(Z(e))}}),C=g.isPending||_.isPending;return(0,H.jsxs)(S,{children:[(0,H.jsxs)(y,{children:[(0,H.jsx)(v,{children:(0,H.jsx)(r,{id:`auth.device.approve.confirmTitle`,message:`Confirm "{userCode}"`,values:{userCode:e},comment:`userCode: the short device-flow code the CLI displayed (e.g. 'WDJB-MJHT'); pass through verbatim`})}),(0,H.jsx)(x,{children:(0,H.jsx)(r,{id:`auth.device.approve.description`,message:`A new API token will be minted for your account and handed to the CLI. Name it so you can find it later under your profile, and optionally restrict what it can do.`})})]}),(0,H.jsx)(b,{children:(0,H.jsx)(P,{...m,children:(0,H.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:m.handleSubmit(e=>{let t=e.scopeMode===`inherit`?null:B(e.scopesText);g.mutate({tokenName:e.tokenName,scopes:t})}),children:[(0,H.jsx)(k,{control:m.control,name:`tokenName`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{children:(0,H.jsx)(r,{id:`auth.device.tokenName.label`,message:`Token name`})}),(0,H.jsx)(A,{children:(0,H.jsx)(T,{placeholder:d(U.tokenNamePlaceholder),disabled:C,"data-testid":`auth-device-tokenname-input`,...e})}),(0,H.jsx)(N,{})]})}),(0,H.jsx)(k,{control:m.control,name:`scopeMode`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{id:`auth-device-scope-label`,children:(0,H.jsx)(r,{id:`auth.device.scopeMode.label`,message:`Permissions`})}),(0,H.jsx)(A,{children:(0,H.jsxs)(o,{name:e.name,value:e.value,onValueChange:e.onChange,disabled:C,"aria-labelledby":`auth-device-scope-label`,className:`gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(s,{value:`inherit`,id:`auth-device-scope-inherit`,"data-testid":`auth-device-scope-inherit-radio`}),(0,H.jsx)(D,{htmlFor:`auth-device-scope-inherit`,className:`font-normal`,children:(0,H.jsx)(r,{id:`auth.device.scopeMode.inherit`,message:`Inherit all my permissions`})})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(s,{value:`restrict`,id:`auth-device-scope-restrict`,"data-testid":`auth-device-scope-restrict-radio`}),(0,H.jsx)(D,{htmlFor:`auth-device-scope-restrict`,className:`font-normal`,children:(0,H.jsx)(r,{id:`auth.device.scopeMode.restrict`,message:`Restrict to specific capabilities`})})]})]})}),(0,H.jsx)(N,{})]})}),h===`restrict`?(0,H.jsx)(k,{control:m.control,name:`scopesText`,render:({field:e})=>(0,H.jsxs)(E,{children:[(0,H.jsx)(j,{children:(0,H.jsx)(r,{id:`auth.device.scopes.label`,message:`Capabilities`})}),(0,H.jsx)(A,{children:(0,H.jsx)(c,{rows:4,placeholder:d(U.scopesPlaceholder),disabled:C,"data-testid":`auth-device-scopes-textarea`,className:`font-mono`,...e})}),(0,H.jsx)(N,{})]})}):null,f?(0,H.jsx)(I,{variant:`destructive`,"data-testid":`auth-device-error`,children:(0,H.jsx)(F,{children:d(f)})}):null,(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(w,{type:`button`,variant:`ghost`,disabled:C,onClick:u,"data-testid":`auth-device-cancel-button`,children:(0,H.jsx)(r,{id:`auth.device.cancel`,message:`Cancel`})}),(0,H.jsx)(w,{type:`button`,variant:`outline`,disabled:C,onClick:()=>_.mutate(),"data-testid":`auth-device-deny-button`,children:_.isPending?(0,H.jsx)(r,{id:`auth.device.deny.pending`,message:`Denying…`}):(0,H.jsx)(r,{id:`auth.device.deny.idle`,message:`Deny`})}),(0,H.jsx)(w,{type:`submit`,disabled:C,"data-testid":`auth-device-approve-button`,children:g.isPending?(0,H.jsx)(r,{id:`auth.device.approve.pending`,message:`Approving…`}):(0,H.jsx)(r,{id:`auth.device.approve.idle`,message:`Approve`})})]})]})})})]})}function X(e){let t=z(e);if(t===`NOT_FOUND`)return U.errLookupNotFound;if(t===`CONFLICT`){let t=R(e);if(t===`expired`)return U.errLookupExpired;if(t===`already_approved`)return U.errLookupAlreadyApproved;if(t===`already_denied`)return U.errLookupAlreadyDenied}return U.errLookupFallback}function Z(e){if(z(e)===`CONFLICT`){let t=R(e);if(t===`expired`)return U.errApproveExpired;if(t===`already_approved`)return U.errApproveAlreadyApproved;if(t===`already_denied`)return U.errApproveAlreadyDenied}return U.errApproveFallback}export{q as component};