@spencerboucher/switchyard 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/bridge/switchyard-terminal.js +158 -2
- package/dist/switchyard.mjs +1332 -769
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-GCthHkym.js +2 -0
- package/web-dist/assets/AutomationView-GCthHkym.js.map +1 -0
- package/web-dist/assets/Badge-CEMI3YyI.js +2 -0
- package/web-dist/assets/Badge-CEMI3YyI.js.map +1 -0
- package/web-dist/assets/InteractionCard-DaLqafmA.js +6 -0
- package/web-dist/assets/InteractionCard-DaLqafmA.js.map +1 -0
- package/web-dist/assets/{Menu-GymfuHGP.js → Menu-BcKiEc6X.js} +2 -2
- package/web-dist/assets/{Menu-GymfuHGP.js.map → Menu-BcKiEc6X.js.map} +1 -1
- package/web-dist/assets/{SegmentedControl-ChdVilXb.js → SegmentedControl-BZPzNU08.js} +2 -2
- package/web-dist/assets/{SegmentedControl-ChdVilXb.js.map → SegmentedControl-BZPzNU08.js.map} +1 -1
- package/web-dist/assets/Tabs-COH5EMql.js +184 -0
- package/web-dist/assets/Tabs-COH5EMql.js.map +1 -0
- package/web-dist/assets/TextArea-CeMEPZn4.js +2 -0
- package/web-dist/assets/TextArea-CeMEPZn4.js.map +1 -0
- package/web-dist/assets/attention-BAdea2kA.js +2 -0
- package/web-dist/assets/attention-BAdea2kA.js.map +1 -0
- package/web-dist/assets/automations-DSFUzB0w.js +2 -0
- package/web-dist/assets/automations-DSFUzB0w.js.map +1 -0
- package/web-dist/assets/board-eQ3H8yCp.js +10 -0
- package/web-dist/assets/board-eQ3H8yCp.js.map +1 -0
- package/web-dist/assets/c-Cz4nF6n_.js +1 -0
- package/web-dist/assets/c-SSSlmE39.js +2 -0
- package/web-dist/assets/c-SSSlmE39.js.map +1 -0
- package/web-dist/assets/code-D7JmYMKe.js +13 -0
- package/web-dist/assets/code-D7JmYMKe.js.map +1 -0
- package/web-dist/assets/cpp-Cts1PyIS.js +2 -0
- package/web-dist/assets/cpp-Cts1PyIS.js.map +1 -0
- package/web-dist/assets/cpp-DzjeI0uH.js +1 -0
- package/web-dist/assets/css-BGIxQoYs.js +2 -0
- package/web-dist/assets/css-BGIxQoYs.js.map +1 -0
- package/web-dist/assets/css-DgaLhXQH.js +1 -0
- package/web-dist/assets/describe-C1YimBXJ.js +5 -0
- package/web-dist/assets/describe-C1YimBXJ.js.map +1 -0
- package/web-dist/assets/diff-woXpYk--.js +2 -0
- package/web-dist/assets/diff-woXpYk--.js.map +1 -0
- package/web-dist/assets/dist-B_RpNOcK.js +56 -0
- package/web-dist/assets/dist-B_RpNOcK.js.map +1 -0
- package/web-dist/assets/dockerfile-IyjqRm3v.js +2 -0
- package/web-dist/assets/dockerfile-IyjqRm3v.js.map +1 -0
- package/web-dist/assets/enroll-1OCy5r50.js +2 -0
- package/web-dist/assets/enroll-1OCy5r50.js.map +1 -0
- package/web-dist/assets/github-dark-C-LZuMrd.js +2 -0
- package/web-dist/assets/github-dark-C-LZuMrd.js.map +1 -0
- package/web-dist/assets/github-light-EUqPIrTm.js +2 -0
- package/web-dist/assets/github-light-EUqPIrTm.js.map +1 -0
- package/web-dist/assets/go-rLFTqkRN.js +2 -0
- package/web-dist/assets/go-rLFTqkRN.js.map +1 -0
- package/web-dist/assets/html-BMn1ogTm.js +2 -0
- package/web-dist/assets/html-BMn1ogTm.js.map +1 -0
- package/web-dist/assets/html-BWDvXlHg.js +1 -0
- package/web-dist/assets/index-BhpEXLav.js +11 -0
- package/web-dist/assets/index-BhpEXLav.js.map +1 -0
- package/web-dist/assets/index-DUeOwDZ6.css +2 -0
- package/web-dist/assets/java-BtIQNnN0.js +2 -0
- package/web-dist/assets/java-BtIQNnN0.js.map +1 -0
- package/web-dist/assets/java-_ATy9zCa.js +1 -0
- package/web-dist/assets/javascript-BzbQS41l.js +2 -0
- package/web-dist/assets/javascript-BzbQS41l.js.map +1 -0
- package/web-dist/assets/javascript-CpIGwZ_Y.js +1 -0
- package/web-dist/assets/json-qhed-kSA.js +2 -0
- package/web-dist/assets/json-qhed-kSA.js.map +1 -0
- package/web-dist/assets/jsonc-CYpm1nAK.js +2 -0
- package/web-dist/assets/jsonc-CYpm1nAK.js.map +1 -0
- package/web-dist/assets/jsx-C4yDKi0A.js +1 -0
- package/web-dist/assets/jsx-D3KKoC5L.js +2 -0
- package/web-dist/assets/jsx-D3KKoC5L.js.map +1 -0
- package/web-dist/assets/logic-CBvFOyIo.js +2 -0
- package/web-dist/assets/logic-CBvFOyIo.js.map +1 -0
- package/web-dist/assets/lua-DjuecEsk.js +2 -0
- package/web-dist/assets/lua-DjuecEsk.js.map +1 -0
- package/web-dist/assets/lua-fPRBWD-V.js +1 -0
- package/web-dist/assets/{more-CRGJsz6E.js → more-RjVyxPaz.js} +2 -2
- package/web-dist/assets/{more-CRGJsz6E.js.map → more-RjVyxPaz.js.map} +1 -1
- package/web-dist/assets/now-CDjeFSLD.js +2 -0
- package/web-dist/assets/now-CDjeFSLD.js.map +1 -0
- package/web-dist/assets/python-gzcpVVnB.js +2 -0
- package/web-dist/assets/python-gzcpVVnB.js.map +1 -0
- package/web-dist/assets/ruby-Bx-U2qjP.js +2 -0
- package/web-dist/assets/ruby-Bx-U2qjP.js.map +1 -0
- package/web-dist/assets/rust-DpiIf5JO.js +2 -0
- package/web-dist/assets/rust-DpiIf5JO.js.map +1 -0
- package/web-dist/assets/scss-8bKmll0B.js +2 -0
- package/web-dist/assets/scss-8bKmll0B.js.map +1 -0
- package/web-dist/assets/send-BKjswHxB.js +2 -0
- package/web-dist/assets/send-BKjswHxB.js.map +1 -0
- package/web-dist/assets/settings-tH4UuIfJ.js +7 -0
- package/web-dist/assets/settings-tH4UuIfJ.js.map +1 -0
- package/web-dist/assets/shared-CRX6KSBm.js +3 -0
- package/web-dist/assets/shared-CRX6KSBm.js.map +1 -0
- package/web-dist/assets/shellscript-CVTB3cr6.js +1 -0
- package/web-dist/assets/shellscript-CqHdAlCp.js +2 -0
- package/web-dist/assets/shellscript-CqHdAlCp.js.map +1 -0
- package/web-dist/assets/sliders-horizontal-DAoirila.js +2 -0
- package/web-dist/assets/sliders-horizontal-DAoirila.js.map +1 -0
- package/web-dist/assets/sql-CNu3Or2W.js +2 -0
- package/web-dist/assets/sql-CNu3Or2W.js.map +1 -0
- package/web-dist/assets/sql-CfM2IJm3.js +1 -0
- package/web-dist/assets/states-DXozulGZ.js +2 -0
- package/web-dist/assets/states-DXozulGZ.js.map +1 -0
- package/web-dist/assets/swift-CyEgAFGc.js +2 -0
- package/web-dist/assets/swift-CyEgAFGc.js.map +1 -0
- package/web-dist/assets/terminal-login-CW2rE50W.js +2 -0
- package/web-dist/assets/terminal-login-CW2rE50W.js.map +1 -0
- package/web-dist/assets/toml-CcmNWLt0.js +2 -0
- package/web-dist/assets/toml-CcmNWLt0.js.map +1 -0
- package/web-dist/assets/tsx-BOvsFOI6.js +2 -0
- package/web-dist/assets/tsx-BOvsFOI6.js.map +1 -0
- package/web-dist/assets/tsx-CGosfAUg.js +1 -0
- package/web-dist/assets/typescript-Bb1J8qyy.js +1 -0
- package/web-dist/assets/typescript-j_1H8WHN.js +2 -0
- package/web-dist/assets/typescript-j_1H8WHN.js.map +1 -0
- package/web-dist/assets/useNow-C_B7JgMM.js +2 -0
- package/web-dist/assets/{useNow-Bc_NlDY3.js.map → useNow-C_B7JgMM.js.map} +1 -1
- package/web-dist/assets/xml-DuKfbPI6.js +1 -0
- package/web-dist/assets/xml-WY0zc4PG.js +2 -0
- package/web-dist/assets/xml-WY0zc4PG.js.map +1 -0
- package/web-dist/assets/yaml-DDA_XMNu.js +1 -0
- package/web-dist/assets/yaml-DijMHRDA.js +2 -0
- package/web-dist/assets/yaml-DijMHRDA.js.map +1 -0
- package/web-dist/index.html +4 -3
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-DgZn3ltn.js +0 -2
- package/web-dist/assets/AutomationView-DgZn3ltn.js.map +0 -1
- package/web-dist/assets/InteractionCard-cvPWKSu1.js +0 -4
- package/web-dist/assets/InteractionCard-cvPWKSu1.js.map +0 -1
- package/web-dist/assets/Markdown-jXkvZeRp.js +0 -31
- package/web-dist/assets/Markdown-jXkvZeRp.js.map +0 -1
- package/web-dist/assets/Overlay-oYnnwvFM.js +0 -2
- package/web-dist/assets/Overlay-oYnnwvFM.js.map +0 -1
- package/web-dist/assets/TextArea-BsQHOQMe.js +0 -2
- package/web-dist/assets/TextArea-BsQHOQMe.js.map +0 -1
- package/web-dist/assets/attention-Bxg9W15n.js +0 -2
- package/web-dist/assets/attention-Bxg9W15n.js.map +0 -1
- package/web-dist/assets/automations-DdB97dnL.js +0 -2
- package/web-dist/assets/automations-DdB97dnL.js.map +0 -1
- package/web-dist/assets/board-s4LuDPcg.js +0 -10
- package/web-dist/assets/board-s4LuDPcg.js.map +0 -1
- package/web-dist/assets/code-B0KXn7lD.js +0 -8
- package/web-dist/assets/code-B0KXn7lD.js.map +0 -1
- package/web-dist/assets/describe-C_3FJuSs.js +0 -5
- package/web-dist/assets/describe-C_3FJuSs.js.map +0 -1
- package/web-dist/assets/dist-Bgkh2hc5.js +0 -56
- package/web-dist/assets/dist-Bgkh2hc5.js.map +0 -1
- package/web-dist/assets/enroll-DijmoolY.js +0 -2
- package/web-dist/assets/enroll-DijmoolY.js.map +0 -1
- package/web-dist/assets/index-C5n2QB-Y.css +0 -2
- package/web-dist/assets/index-Cf6ZUCfK.js +0 -11
- package/web-dist/assets/index-Cf6ZUCfK.js.map +0 -1
- package/web-dist/assets/logic-D_Eq9DMW.js +0 -2
- package/web-dist/assets/logic-D_Eq9DMW.js.map +0 -1
- package/web-dist/assets/now-D6lDofYy.js +0 -2
- package/web-dist/assets/now-D6lDofYy.js.map +0 -1
- package/web-dist/assets/settings-Csal1F-W.js +0 -8
- package/web-dist/assets/settings-Csal1F-W.js.map +0 -1
- package/web-dist/assets/sliders-horizontal-S3tmwxsP.js +0 -2
- package/web-dist/assets/sliders-horizontal-S3tmwxsP.js.map +0 -1
- package/web-dist/assets/states-DrTQuYXw.js +0 -2
- package/web-dist/assets/states-DrTQuYXw.js.map +0 -1
- package/web-dist/assets/useNow-Bc_NlDY3.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{U as e,V as t,z as n}from"./states-DrTQuYXw.js";function r(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function i(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function a(){return o.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var o={stubThis:e=>e};function s(e){let{id:t}=e;return{...e,id:i(t),transports:e.transports,type:e.type}}function c(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var l=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function u({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new l({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new l({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new l({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new l({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new l({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new l({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new l({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new l({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!c(t))return new l({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new l({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new l({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new l({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var d=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},f=[`cross-platform`,`platform`];function p(e){if(e&&!(f.indexOf(e)<0))return e}async function m(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!a())throw Error(`WebAuthn is not supported in this browser`);let o={...t,challenge:i(t.challenge),user:{...t.user,id:i(t.user.id)},excludeCredentials:t.excludeCredentials?.map(s)},c={};n&&(c.mediation=`conditional`),c.publicKey=o,c.signal=d.createNewAbortSignal();let l;try{l=await navigator.credentials.create(c)}catch(e){throw u({error:e,options:c})}if(!l)throw Error(`Registration was not completed`);let{id:f,rawId:m,response:g,type:_}=l,v;typeof g.getTransports==`function`&&(v=g.getTransports());let y;if(typeof g.getPublicKeyAlgorithm==`function`)try{y=g.getPublicKeyAlgorithm()}catch(e){h(`getPublicKeyAlgorithm()`,e)}let b;if(typeof g.getPublicKey==`function`)try{let e=g.getPublicKey();e!==null&&(b=r(e))}catch(e){h(`getPublicKey()`,e)}let x;if(typeof g.getAuthenticatorData==`function`)try{x=r(g.getAuthenticatorData())}catch(e){h(`getAuthenticatorData()`,e)}return{id:f,rawId:r(m),response:{attestationObject:r(g.attestationObject),clientDataJSON:r(g.clientDataJSON),transports:v,publicKeyAlgorithm:y,publicKey:b,authenticatorData:x},type:_,clientExtensionResults:l.getClientExtensionResults(),authenticatorAttachment:p(l.authenticatorAttachment)}}function h(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function g(){if(!a())return _.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?_.stubThis(new Promise(e=>e(!1))):_.stubThis(e.isConditionalMediationAvailable())}var _={stubThis:e=>e};function v({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new l({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new l({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!c(t))return new l({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new l({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new l({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function y(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:o=!0}=e;if(!a())throw Error(`WebAuthn is not supported in this browser`);let c;t.allowCredentials?.length!==0&&(c=t.allowCredentials?.map(s));let l={...t,challenge:i(t.challenge),allowCredentials:c},u={};if(n){if(!await g())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&o)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');u.mediation=`conditional`,l.allowCredentials=[]}u.publicKey=l,u.signal=d.createNewAbortSignal();let f;try{f=await navigator.credentials.get(u)}catch(e){throw v({error:e,options:u})}if(!f)throw Error(`Authentication was not completed`);let{id:m,rawId:h,response:_,type:y}=f,b;return _.userHandle&&(b=r(_.userHandle)),{id:m,rawId:r(h),response:{authenticatorData:r(_.authenticatorData),clientDataJSON:r(_.clientDataJSON),signature:r(_.signature),userHandle:b},type:y,clientExtensionResults:f.getClientExtensionResults(),authenticatorAttachment:p(f.authenticatorAttachment)}}function b(){return typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}function x(){return typeof window>`u`?!1:window.matchMedia?.(`(display-mode: standalone)`).matches||navigator.standalone===!0}function S(){return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function C(){return b()?Notification.permission:`unsupported`}function w(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(new ArrayBuffer(n.length));for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function T(){return b()?await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription()??null:null}async function E(){if(!b())return`unsupported`;let n=await Notification.requestPermission();if(n!==`granted`)return await O(n).catch(()=>void 0),n;let r=await navigator.serviceWorker.ready,{publicKey:i}=await t(`/api/push/vapid-public-key`);if(!i)throw Error(`The coordinator has no push key configured`);let a=await r.pushManager.getSubscription();a||=await r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w(i)});let o=a.toJSON();return await e(`/api/push/subscriptions`,{endpoint:o.endpoint,keys:{p256dh:o.keys?.p256dh??``,auth:o.keys?.auth??``},permission:`granted`}),`granted`}async function D(){let e=await T();e&&(await n(`/api/push/subscriptions`,{method:`DELETE`,body:{endpoint:e.endpoint}}).catch(()=>void 0),await e.unsubscribe())}async function O(t){let n=await T();if(!n)return;let r=n.toJSON();await e(`/api/push/subscriptions`,{endpoint:r.endpoint,keys:{p256dh:r.keys?.p256dh??``,auth:r.keys?.auth??``},permission:t})}function k(){return e(`/api/push/test`)}var A=2e3;function j(e){return{phase:`waiting`,startedAt:e,message:null}}function M(e,t){if(e.phase!==`waiting`)return e;if(t.type===`cancel`)return{...e,phase:`cancelled`};if(t.now-e.startedAt>=6e5&&t.type!==`claim`)return{...e,phase:`timeout`};switch(t.type){case`tick`:return e;case`claim`:return t.result.status===`done`?{...e,phase:`done`}:t.now-e.startedAt>=6e5?{...e,phase:`timeout`}:e;case`claim_error`:return t.code===`unauthorized`||t.code===`invalid_request`?{...e,phase:`failed`,message:t.message}:e}}function N(e,t){return e.phase===`waiting`&&t}var P=`This account is not allowed to sign in to this server.`,F={enrollment_expired:"This enrollment link has expired. Links are valid for 10 minutes. Create a new one from Settings › Devices › Add device on an enrolled device, or run `switchyard pair` on the server.",enrollment_used:"This enrollment link was already used. Each link enrolls one device. Create a new one from Settings › Devices › Add device, or run `switchyard pair`.",invalid_request:`The enrollment request was rejected. Check the device name and try again.`,network:`Could not reach the coordinator. Check your connection and try again.`,rate_limited:`Too many attempts. Wait a minute and try again.`,unsupported_capability:`This sign-in method is not available on this server.`,unauthorized:`That sign-in was not accepted. Try again, or use another sign-in method.`};function I(e,t){let n=t?.trim()||null;switch(e){case`forbidden`:return n??P;case`oidc_failed`:return`Single sign-on failed: ${n??`the identity provider returned an error.`}`;case`unsupported_capability`:return n??F.unsupported_capability;default:return F[e]??n??`Sign-in failed (${e}).`}}function L(e=navigator.userAgent){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&navigator.maxTouchPoints>1?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`;return`${/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:`Browser`} on ${t}`}export{a as _,M as a,T as c,C as d,k as f,m as g,y as h,I as i,S as l,D as m,A as n,N as o,E as p,L as r,j as s,F as t,x as u};
|
|
2
|
-
//# sourceMappingURL=logic-D_Eq9DMW.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic-D_Eq9DMW.js","names":["apiPost","apiGet","api","bufferToBase64URLString","bytes","buffer","str","charCode","base64URLStringToBuffer","base64","base64URLString","padLength","padded","binary","i","browserSupportsWebAuthn","_browserSupportsWebAuthnInternals","value","toPublicKeyCredentialDescriptor","descriptor","id","isValidDomain","hostname","WebAuthnError","message","name","cause","code","identifyRegistrationError","options","publicKey","error","param","effectiveDomain","WebAuthnAbortService","abortError","newController","attachments","toAuthenticatorAttachment","attachment","startRegistration","optionsJSON","createOptions","useAutoRegister","credential","err","transports","response","responsePublicKeyAlgorithm","warnOnBrokenImplementation","responsePublicKey","_publicKey","responseAuthenticatorData","rawId","methodName","browserSupportsWebAuthnAutofill","_browserSupportsWebAuthnAutofillInternals","resolve","globalPublicKeyCredential","identifyAuthenticationError","startAuthentication","allowCredentials","getOptions","useBrowserAutofill","verifyBrowserAutofillInput","userHandle","pushSupported","isStandalone","isIos","pushPermission","urlBase64ToUint8Array","b64","raw","out","currentSubscription","subscribePush","permission","reportPermission","reg","key","sub","json","unsubscribePush","sendTestNotification","HANDOFF_POLL_MS","startHandoff","now","handoffReduce","state","event","shouldPoll","visible","GENERIC_FORBIDDEN","ERROR_TEXT","enrollErrorText","d","detail","defaultDeviceName","device","ua"],"sources":["../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyRegistrationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startRegistration.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js","../../src/push.ts","../../src/features/enroll/logic.ts"],"sourcesContent":["/**\n * Convert the given array buffer into a Base64URL-encoded string. Ideal for converting various\n * credential response ArrayBuffers to string for sending back to the server as JSON.\n *\n * Helper method to compliment `base64URLStringToBuffer`\n */\nexport function bufferToBase64URLString(buffer) {\n const bytes = new Uint8Array(buffer);\n let str = '';\n for (const charCode of bytes) {\n str += String.fromCharCode(charCode);\n }\n const base64String = btoa(str);\n return base64String.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n}\n","/**\n * Convert from a Base64URL-encoded string to an Array Buffer. Best used when converting a\n * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or\n * excludeCredentials\n *\n * Helper method to compliment `bufferToBase64URLString`\n */\nexport function base64URLStringToBuffer(base64URLString) {\n // Convert from Base64URL to Base64\n const base64 = base64URLString.replace(/-/g, '+').replace(/_/g, '/');\n /**\n * Pad with '=' until it's a multiple of four\n * (4 - (85 % 4 = 1) = 3) % 4 = 3 padding\n * (4 - (86 % 4 = 2) = 2) % 4 = 2 padding\n * (4 - (87 % 4 = 3) = 1) % 4 = 1 padding\n * (4 - (88 % 4 = 0) = 4) % 4 = 0 padding\n */\n const padLength = (4 - (base64.length % 4)) % 4;\n const padded = base64.padEnd(base64.length + padLength, '=');\n // Convert to a binary string\n const binary = atob(padded);\n // Convert binary string to buffer\n const buffer = new ArrayBuffer(binary.length);\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return buffer;\n}\n","/**\n * Determine if the browser is capable of Webauthn\n */\nexport function browserSupportsWebAuthn() {\n return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined &&\n typeof globalThis.PublicKeyCredential === 'function');\n}\n/**\n * Make it possible to stub the return value during testing\n * @ignore Don't include this in docs output\n */\nexport const _browserSupportsWebAuthnInternals = {\n stubThis: (value) => value,\n};\n","import { base64URLStringToBuffer } from './base64URLStringToBuffer.js';\nexport function toPublicKeyCredentialDescriptor(descriptor) {\n const { id } = descriptor;\n return {\n ...descriptor,\n id: base64URLStringToBuffer(id),\n transports: descriptor.transports,\n type: descriptor.type,\n };\n}\n","/**\n * A simple test to determine if a hostname is a properly-formatted domain name\n *\n * A \"valid domain\" is defined here: https://url.spec.whatwg.org/#valid-domain\n *\n * Regex was originally sourced from here, then remixed to add punycode support:\n * https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html\n */\nexport function isValidDomain(hostname) {\n return (\n // Consider localhost valid as well since it's okay wrt Secure Contexts\n hostname === 'localhost' ||\n // Support punycode (ACE) or ascii labels and domains\n /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname));\n}\n","/**\n * A custom Error used to return a more nuanced error detailing _why_ one of the eight documented\n * errors in the spec was raised after calling `navigator.credentials.create()` or\n * `navigator.credentials.get()`:\n *\n * - `AbortError`\n * - `ConstraintError`\n * - `InvalidStateError`\n * - `NotAllowedError`\n * - `NotSupportedError`\n * - `SecurityError`\n * - `TypeError`\n * - `UnknownError`\n *\n * Error messages were determined through investigation of the spec to determine under which\n * scenarios a given error would be raised.\n */\nexport class WebAuthnError extends Error {\n constructor({ message, code, cause, name, }) {\n // @ts-ignore: help Rollup understand that `cause` is okay to set\n super(message, { cause });\n Object.defineProperty(this, \"code\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = name ?? cause.name;\n this.code = code;\n }\n}\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.create()`\n */\nexport function identifyRegistrationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Registration ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'ConstraintError') {\n if (publicKey.authenticatorSelection?.requireResidentKey === true) {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 4)\n return new WebAuthnError({\n message: 'Discoverable credentials were required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT',\n cause: error,\n });\n }\n else if (\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n options.mediation === 'conditional' &&\n publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://w3c.github.io/webauthn/#sctn-createCredential (Step 22.4)\n return new WebAuthnError({\n message: 'User verification was required during automatic registration but it could not be performed',\n code: 'ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE',\n cause: error,\n });\n }\n else if (publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 5)\n return new WebAuthnError({\n message: 'User verification was required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT',\n cause: error,\n });\n }\n }\n else if (error.name === 'InvalidStateError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 20)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 3)\n return new WebAuthnError({\n message: 'The authenticator was previously registered',\n code: 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED',\n cause: error,\n });\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'NotSupportedError') {\n const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === 'public-key');\n if (validPubKeyCredParams.length === 0) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 10)\n return new WebAuthnError({\n message: 'No entry in pubKeyCredParams was of type \"public-key\"',\n code: 'ERROR_MALFORMED_PUBKEYCREDPARAMS',\n cause: error,\n });\n }\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 2)\n return new WebAuthnError({\n message: 'No available authenticator supported any of the specified pubKeyCredParams algorithms',\n code: 'ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 7)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rp.id !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 8)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rp.id}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'TypeError') {\n if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5)\n return new WebAuthnError({\n message: 'User ID was not between 1 and 64 characters',\n code: 'ERROR_INVALID_USER_ID_LENGTH',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 8)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new credential',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","class BaseWebAuthnAbortService {\n constructor() {\n Object.defineProperty(this, \"controller\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n }\n createNewAbortSignal() {\n // Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()\n if (this.controller) {\n const abortError = new Error('Cancelling existing WebAuthn API call for new one');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n }\n const newController = new AbortController();\n this.controller = newController;\n return newController.signal;\n }\n cancelCeremony() {\n if (this.controller) {\n const abortError = new Error('Manually cancelling existing WebAuthn API call');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n this.controller = undefined;\n }\n }\n}\n/**\n * A service singleton to help ensure that only a single WebAuthn ceremony is active at a time.\n *\n * Users of **@simplewebauthn/browser** shouldn't typically need to use this, but it can help e.g.\n * developers building projects that use client-side routing to better control the behavior of\n * their UX in response to router navigation events.\n */\nexport const WebAuthnAbortService = new BaseWebAuthnAbortService();\n","const attachments = ['cross-platform', 'platform'];\n/**\n * If possible coerce a `string` value into a known `AuthenticatorAttachment`\n */\nexport function toAuthenticatorAttachment(attachment) {\n if (!attachment) {\n return;\n }\n if (attachments.indexOf(attachment) < 0) {\n return;\n }\n return attachment;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyRegistrationError } from '../helpers/identifyRegistrationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"registration\" via WebAuthn attestation\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()`\n * @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.\n */\nexport async function startRegistration(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useAutoRegister = false } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n user: {\n ...optionsJSON.user,\n id: base64URLStringToBuffer(optionsJSON.user.id),\n },\n excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor),\n };\n // Prepare options for `.create()`\n const createOptions = {};\n /**\n * Try to use conditional create to register a passkey for the user with the password manager\n * the user just used to authenticate with. The user won't be shown any prominent UI by the\n * browser.\n */\n if (useAutoRegister) {\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n createOptions.mediation = 'conditional';\n }\n // Finalize options\n createOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n createOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete attestation\n let credential;\n try {\n credential = (await navigator.credentials.create(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n createOptions));\n }\n catch (err) {\n throw identifyRegistrationError({ error: err, options: createOptions });\n }\n if (!credential) {\n throw new Error('Registration was not completed');\n }\n const { id, rawId, response, type } = credential;\n // Continue to play it safe with `getTransports()` for now, even when L3 types say it's required\n let transports = undefined;\n if (typeof response.getTransports === 'function') {\n transports = response.getTransports();\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responsePublicKeyAlgorithm = undefined;\n if (typeof response.getPublicKeyAlgorithm === 'function') {\n try {\n responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKeyAlgorithm()', error);\n }\n }\n let responsePublicKey = undefined;\n if (typeof response.getPublicKey === 'function') {\n try {\n const _publicKey = response.getPublicKey();\n if (_publicKey !== null) {\n responsePublicKey = bufferToBase64URLString(_publicKey);\n }\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKey()', error);\n }\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responseAuthenticatorData;\n if (typeof response.getAuthenticatorData === 'function') {\n try {\n responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());\n }\n catch (error) {\n warnOnBrokenImplementation('getAuthenticatorData()', error);\n }\n }\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n attestationObject: bufferToBase64URLString(response.attestationObject),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n transports,\n publicKeyAlgorithm: responsePublicKeyAlgorithm,\n publicKey: responsePublicKey,\n authenticatorData: responseAuthenticatorData,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n/**\n * Visibly warn when we detect an issue related to a passkey provider intercepting WebAuthn API\n * calls\n */\nfunction warnOnBrokenImplementation(methodName, cause) {\n console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.\\n`, cause);\n}\n","import { browserSupportsWebAuthn } from './browserSupportsWebAuthn.js';\n/**\n * Determine if the browser supports conditional UI, so that WebAuthn credentials can\n * be shown to the user in the browser's typical password autofill popup.\n */\nexport function browserSupportsWebAuthnAutofill() {\n if (!browserSupportsWebAuthn()) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n /**\n * I don't like the `as unknown` here but there's a `declare var PublicKeyCredential` in\n * TS' DOM lib that's making it difficult for me to just go `as PublicKeyCredentialFuture` as I\n * want. I think I'm fine with this for now since it's _supposed_ to be temporary, until TS types\n * have a chance to catch up.\n */\n const globalPublicKeyCredential = globalThis\n .PublicKeyCredential;\n if (globalPublicKeyCredential?.isConditionalMediationAvailable === undefined) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());\n}\n// Make it possible to stub the return value during testing\nexport const _browserSupportsWebAuthnAutofillInternals = {\n stubThis: (value) => value,\n};\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.get()`\n */\nexport function identifyAuthenticationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Authentication ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 5)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rpId !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 6)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rpId}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 12)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new assertion signature',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { browserSupportsWebAuthnAutofill } from '../helpers/browserSupportsWebAuthnAutofill.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyAuthenticationError } from '../helpers/identifyAuthenticationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"login\" via WebAuthn assertion\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`\n * @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.\n * @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.\n */\nexport async function startAuthentication(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true, } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to avoid passing empty array to avoid blocking retrieval\n // of public key\n let allowCredentials;\n if (optionsJSON.allowCredentials?.length !== 0) {\n allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n allowCredentials,\n };\n // Prepare options for `.get()`\n const getOptions = {};\n /**\n * Set up the page to prompt the user to select a credential for authentication via the browser's\n * input autofill mechanism.\n */\n if (useBrowserAutofill) {\n if (!(await browserSupportsWebAuthnAutofill())) {\n throw Error('Browser does not support WebAuthn autofill');\n }\n // Check for an <input> with \"webauthn\" in its `autocomplete` attribute\n const eligibleInputs = document.querySelectorAll(\"input[autocomplete$='webauthn']\");\n // WebAuthn autofill requires at least one valid input\n if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {\n throw Error('No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected');\n }\n // `CredentialMediationRequirement` doesn't know about \"conditional\" yet as of\n // typescript@4.6.3\n getOptions.mediation = 'conditional';\n // Conditional UI requires an empty allow list\n publicKey.allowCredentials = [];\n }\n // Finalize options\n getOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n getOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete assertion\n let credential;\n try {\n credential = (await navigator.credentials.get(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n getOptions));\n }\n catch (err) {\n throw identifyAuthenticationError({ error: err, options: getOptions });\n }\n if (!credential) {\n throw new Error('Authentication was not completed');\n }\n const { id, rawId, response, type } = credential;\n let userHandle = undefined;\n if (response.userHandle) {\n userHandle = bufferToBase64URLString(response.userHandle);\n }\n // Convert values to base64 to make it easier to send back to the server\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n authenticatorData: bufferToBase64URLString(response.authenticatorData),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n signature: bufferToBase64URLString(response.signature),\n userHandle,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n","import { api, apiGet, apiPost } from \"./sync/api\";\n\n/** Web push helpers (Settings > Notifications). */\n\nexport type PushPermission = \"granted\" | \"denied\" | \"default\" | \"unknown\" | \"unsupported\";\n\nexport function pushSupported(): boolean {\n return (\n typeof window !== \"undefined\" &&\n \"serviceWorker\" in navigator &&\n \"PushManager\" in window &&\n \"Notification\" in window\n );\n}\n\n/** Whether running as an installed app (iOS only allows push in Home Screen apps). */\nexport function isStandalone(): boolean {\n if (typeof window === \"undefined\") return false;\n return (\n window.matchMedia?.(\"(display-mode: standalone)\").matches ||\n (navigator as Navigator & { standalone?: boolean }).standalone === true\n );\n}\n\nexport function isIos(): boolean {\n return (\n /iPad|iPhone|iPod/.test(navigator.userAgent) ||\n (navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 1)\n );\n}\n\nexport function pushPermission(): PushPermission {\n if (!pushSupported()) return \"unsupported\";\n return Notification.permission as PushPermission;\n}\n\nfunction urlBase64ToUint8Array(base64: string): Uint8Array<ArrayBuffer> {\n const padding = \"=\".repeat((4 - (base64.length % 4)) % 4);\n const b64 = (base64 + padding).replace(/-/g, \"+\").replace(/_/g, \"/\");\n const raw = atob(b64);\n const out = new Uint8Array(new ArrayBuffer(raw.length));\n for (let i = 0; i < raw.length; i++) out[i] = raw.charCodeAt(i);\n return out;\n}\n\nexport async function currentSubscription(): Promise<PushSubscription | null> {\n if (!pushSupported()) return null;\n const reg = await navigator.serviceWorker.getRegistration();\n return (await reg?.pushManager.getSubscription()) ?? null;\n}\n\n/**\n * Ask for permission (must be called from a user gesture), subscribe with the\n * coordinator's VAPID key and register the subscription. Returns the resulting\n * permission.\n */\nexport async function subscribePush(): Promise<PushPermission> {\n if (!pushSupported()) return \"unsupported\";\n const permission = await Notification.requestPermission();\n if (permission !== \"granted\") {\n await reportPermission(permission).catch(() => undefined);\n return permission;\n }\n const reg = await navigator.serviceWorker.ready;\n // Coordinator routes/push.ts: GET /api/push/vapid-public-key -> {publicKey}.\n const { publicKey: key } = await apiGet<{ publicKey: string }>(\"/api/push/vapid-public-key\");\n if (!key) throw new Error(\"The coordinator has no push key configured\");\n let sub = await reg.pushManager.getSubscription();\n if (!sub) {\n sub = await reg.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: urlBase64ToUint8Array(key),\n });\n }\n const json = sub.toJSON();\n await apiPost(\"/api/push/subscriptions\", {\n endpoint: json.endpoint,\n keys: { p256dh: json.keys?.p256dh ?? \"\", auth: json.keys?.auth ?? \"\" },\n permission: \"granted\",\n });\n return \"granted\";\n}\n\n/** Remove this browser's subscription locally and on the coordinator. */\nexport async function unsubscribePush(): Promise<void> {\n const sub = await currentSubscription();\n if (!sub) return;\n await api(\"/api/push/subscriptions\", {\n method: \"DELETE\",\n body: { endpoint: sub.endpoint },\n }).catch(() => undefined);\n await sub.unsubscribe();\n}\n\n/** Tell the coordinator this device's permission state (shown in Settings). */\nexport async function reportPermission(permission: NotificationPermission): Promise<void> {\n const sub = await currentSubscription();\n if (!sub) return;\n const json = sub.toJSON();\n await apiPost(\"/api/push/subscriptions\", {\n endpoint: json.endpoint,\n keys: { p256dh: json.keys?.p256dh ?? \"\", auth: json.keys?.auth ?? \"\" },\n permission,\n });\n}\n\nexport function sendTestNotification(): Promise<unknown> {\n return apiPost(\"/api/push/test\");\n}\n","import type { OidcClaimResponse } from \"@switchyard/protocol\";\n\n/** How often the PWA polls `POST /api/auth/oidc/claim` while the screen is visible. */\nexport const HANDOFF_POLL_MS = 2000;\n/** How long a handoff waits before giving up (the coordinator flow lives 10 minutes). */\nexport const HANDOFF_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport type HandoffPhase = \"waiting\" | \"done\" | \"timeout\" | \"failed\" | \"cancelled\";\n\nexport interface HandoffState {\n phase: HandoffPhase;\n startedAt: number;\n /** Set when `phase` is `failed`. */\n message: string | null;\n}\n\nexport type HandoffEvent =\n | { type: \"claim\"; result: OidcClaimResponse; now: number }\n | { type: \"claim_error\"; code: string; message: string; now: number }\n | { type: \"tick\"; now: number }\n | { type: \"cancel\" };\n\nexport function startHandoff(now: number): HandoffState {\n return { phase: \"waiting\", startedAt: now, message: null };\n}\n\n/**\n * Pure state machine for the PWA single sign-on handoff. Terminal phases\n * never change. A transient error (network, server hiccup) keeps waiting;\n * an expired or unknown flow (`unauthorized`, `invalid_request`) fails.\n */\nexport function handoffReduce(state: HandoffState, event: HandoffEvent): HandoffState {\n if (state.phase !== \"waiting\") return state;\n if (event.type === \"cancel\") return { ...state, phase: \"cancelled\" };\n if (event.now - state.startedAt >= HANDOFF_TIMEOUT_MS && event.type !== \"claim\") {\n return { ...state, phase: \"timeout\" };\n }\n switch (event.type) {\n case \"tick\":\n return state;\n case \"claim\":\n if (event.result.status === \"done\") return { ...state, phase: \"done\" };\n return event.now - state.startedAt >= HANDOFF_TIMEOUT_MS\n ? { ...state, phase: \"timeout\" }\n : state;\n case \"claim_error\":\n if (event.code === \"unauthorized\" || event.code === \"invalid_request\") {\n return { ...state, phase: \"failed\", message: event.message };\n }\n return state;\n }\n}\n\n/** Whether a poll should run now: still waiting and the page is visible. */\nexport function shouldPoll(state: HandoffState, visible: boolean): boolean {\n return state.phase === \"waiting\" && visible;\n}\n\nconst GENERIC_FORBIDDEN = \"This account is not allowed to sign in to this server.\";\n\n/** Static texts for coordinator error codes shown on /enroll. */\nexport const ERROR_TEXT: Record<string, string> = {\n enrollment_expired:\n \"This enrollment link has expired. Links are valid for 10 minutes. Create a new one from Settings › Devices › Add device on an enrolled device, or run `switchyard pair` on the server.\",\n enrollment_used:\n \"This enrollment link was already used. Each link enrolls one device. Create a new one from Settings › Devices › Add device, or run `switchyard pair`.\",\n invalid_request: \"The enrollment request was rejected. Check the device name and try again.\",\n network: \"Could not reach the coordinator. Check your connection and try again.\",\n rate_limited: \"Too many attempts. Wait a minute and try again.\",\n unsupported_capability: \"This sign-in method is not available on this server.\",\n unauthorized: \"That sign-in was not accepted. Try again, or use another sign-in method.\",\n};\n\n/**\n * Message for an error code, with the coordinator's `detail` where it is the\n * useful part (`/enroll?error=forbidden&detail=Signed in as ...`).\n */\nexport function enrollErrorText(code: string, detail?: string | null): string {\n const d = detail?.trim() || null;\n switch (code) {\n case \"forbidden\":\n return d ?? GENERIC_FORBIDDEN;\n case \"oidc_failed\":\n return `Single sign-on failed: ${d ?? \"the identity provider returned an error.\"}`;\n case \"unsupported_capability\":\n return d ?? (ERROR_TEXT.unsupported_capability as string);\n default:\n return ERROR_TEXT[code] ?? d ?? `Sign-in failed (${code}).`;\n }\n}\n\n/** Short heading for an error alert. */\nexport function enrollErrorTitle(code: string): string {\n switch (code) {\n case \"enrollment_expired\":\n return \"Enrollment link expired\";\n case \"enrollment_used\":\n return \"Enrollment link already used\";\n case \"forbidden\":\n return \"Not allowed\";\n case \"oidc_failed\":\n return \"Single sign-on failed\";\n case \"rate_limited\":\n return \"Too many attempts\";\n default:\n return \"Sign-in failed\";\n }\n}\n\n/** A readable default device name from the user agent, e.g. \"Safari on iPhone\". */\nexport function defaultDeviceName(ua: string = navigator.userAgent): string {\n const device = /iPhone/.test(ua)\n ? \"iPhone\"\n : /iPad/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)\n ? \"iPad\"\n : /Android/.test(ua)\n ? \"Android\"\n : /Macintosh|Mac OS X/.test(ua)\n ? \"Mac\"\n : /Windows/.test(ua)\n ? \"Windows\"\n : /Linux/.test(ua)\n ? \"Linux\"\n : \"device\";\n const browser = /Edg\\//.test(ua)\n ? \"Edge\"\n : /Firefox\\/|FxiOS/.test(ua)\n ? \"Firefox\"\n : /Chrome\\/|CriOS/.test(ua)\n ? \"Chrome\"\n : /Safari\\//.test(ua)\n ? \"Safari\"\n : \"Browser\";\n return `${browser} on ${device}`;\n}\n"],"ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12],"mappings":"A,uDAMA,SAAgBG,EAAwB,EAAQ,CAC5C,IAAMC,EAAQ,IAAI,WAAWC,CAAM,EAC/BC,EAAM,GACV,IAAK,IAAMC,KAAYH,EACnB,GAAO,OAAO,aAAaG,CAAQ,EAGvC,OADqB,KAAKD,CACR,CAAC,CAAC,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,KAAM,EAAE,CAChF,CCPA,SAAgBE,EAAwB,EAAiB,CAErD,IAAMC,EAASC,EAAgB,QAAQ,KAAM,GAAG,CAAC,CAAC,QAAQ,KAAM,GAAG,EAQ7DC,GAAa,EAAKF,EAAO,OAAS,GAAM,EACxCG,EAASH,EAAO,OAAOA,EAAO,OAASE,EAAW,GAAG,EAErDE,EAAS,KAAKD,CAAM,EAEpBP,EAAS,IAAI,YAAYQ,EAAO,MAAM,EACtCT,EAAQ,IAAI,WAAWC,CAAM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,d,g as f,i as p,n as m,o as h,p as g,r as _,t as v,u as y}from"./states-DrTQuYXw.js";import{t as b}from"./calendar-clock-B8zE4JsX.js";import{t as x}from"./external-link-3jjTxo92.js";import{P as S,_ as C,a as w,p as T,t as E}from"./useNow-Bc_NlDY3.js";import{t as D}from"./link-2-CaMlUDRG.js";import{C as O,I as k,N as A,c as j,d as M,t as N,v as P,y as F}from"./index-Cf6ZUCfK.js";import{c as I}from"./dist-Bgkh2hc5.js";var L={name:`folder-lock`,size:24,node:[[`rect`,{width:`8`,height:`5`,x:`14`,y:`17`,rx:`1`,key:`19aais`}],[`path`,{d:`M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5`,key:`1w6v7t`}],[`path`,{d:`M20 17v-2a2 2 0 1 0-4 0v2`,key:`pwaxnr`}]]};L.node;var R=r(L),z={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};z.node;var B=r(z),V={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};V.node;var H=r(V),U={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};U.node;var W=r(U),G=e(n(),1),K=i(),q={dependency:D,host_offline:P,project_limit:B,workspace_occupied:R,scheduled_time:b,invalid_configuration:f,dispatch_paused:A,project_automation_disabled:H,not_ready:l,already_dispatched:O,retry_backoff:W};function J(){let e=E(),t=o(e=>e.tasks),n=o(e=>e.runs),r=o(e=>e.hydrated),i=s(),l=a(e.error)&&e.error.status===404,d=!!e.data&&(!Array.isArray(e.data.running)||!Array.isArray(e.data.queued)),f=(0,G.useMemo)(()=>e.data&&!d?e.data.running.map(e=>({taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})):Object.values(n).filter(e=>C(e)&&e.state!==`queued`).map(e=>({taskId:e.taskId,runId:e.id,sessionId:e.sessionId})),[e.data,n,d]),p=(0,G.useMemo)(()=>e.data&&!d?e.data.queued.map(e=>({taskId:e.taskId,eligibility:e.eligibility})):Object.values(t).filter(e=>e.state===`ready`&&!e.hiddenFromBoard).sort((e,t)=>e.priority-t.priority||e.position-t.position).map(e=>({taskId:e.id,eligibility:void 0})),[e.data,t,d]),g=!e.data&&e.loading&&!e.error||!r,y=!!e.error&&!l&&!e.data;return d?(0,K.jsx)(_,{title:`The coordinator sent a queue this version cannot read`,error:`GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.`}):(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl min-w-0 flex-col gap-4 px-4 py-4 safe-pt`,children:[(0,K.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,K.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Now`}),(0,K.jsx)(w,{})]}),(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`Pausing stops new work from starting. Runs already in progress keep going.`}),i.state!==`live`&&e.data&&(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-muted`,children:`Showing the last known queue.`}),l&&(0,K.jsx)(u,{capability:`Queue explanations`,reason:`This coordinator does not report why queued tasks are waiting. The list below comes from local data.`}),e.error!=null&&!l&&(0,K.jsx)(m,{compact:!0,title:`Could not refresh running and queued work`,error:c(e.error),onRetry:e.reload}),g?(0,K.jsx)(h,{label:`Loading running and queued work…`}):y&&f.length===0&&p.length===0?null:f.length===0&&p.length===0?(0,K.jsx)(v,{icon:(0,K.jsx)(F,{className:`size-8`}),title:`Nothing running or queued`,description:`Move a task to Ready on the board and the dispatcher starts it when it is eligible.`,action:{label:`Go to Board`,to:N.board}}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{"aria-labelledby":`now-running`,className:`flex min-w-0 flex-col gap-2`,children:[(0,K.jsxs)(`h2`,{id:`now-running`,className:`text-base font-semibold`,children:[`Running `,(0,K.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,f.length,`)`]})]}),f.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`Nothing is running.`}):(0,K.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:f.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(Y,{taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})},e.runId))})]}),(0,K.jsxs)(`section`,{"aria-labelledby":`now-queued`,className:`flex min-w-0 flex-col gap-2`,children:[(0,K.jsxs)(`h2`,{id:`now-queued`,className:`text-base font-semibold`,children:[`Queued `,(0,K.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,p.length,`)`]})]}),p.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:`No Ready tasks are waiting.`}):(0,K.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:p.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(X,{task:t[e.taskId],taskId:e.taskId,eligibility:e.eligibility})},e.taskId))})]})]})]})}function Y({taskId:e,runId:n,sessionId:r}){let i=o(t=>t.tasks[e]),a=o(e=>e.runs[n]),s=o(e=>a?.hostId?e.hosts[a.hostId]:void 0),c=o(e=>i?e.projects[i.projectId]:void 0),l=!!s&&s.connectivity!==`connected`;return(0,K.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[a?(0,K.jsx)(M,{kind:`run`,value:a.state,size:`sm`}):(0,K.jsx)(M,{kind:`task`,value:`in_progress`,size:`sm`}),(0,K.jsx)(t,{to:N.task(e),className:`min-w-0 flex-1 basis-48 font-medium break-words hover:underline`,children:i?.title??`Task`}),(r??i?.sessionId)&&(0,K.jsxs)(t,{to:N.session(r??i?.sessionId),className:d(`secondary`,`sm`),children:[(0,K.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:[c?.name,s?`on ${s.name}`:null,a?.attempt&&a.attempt>1?`attempt ${a.attempt}`:null,a?.startedAt?`started ${g(a.startedAt)}`:null,a?.controlMode===`human`?`you have control`:`automation`].filter(Boolean).join(` · `)}),a?.state===`uncertain`&&s&&(0,K.jsx)(`p`,{className:`text-sm text-warning`,children:(0,K.jsxs)(`span`,{className:`text-text`,children:[`Waiting for host `,s.name,` to confirm launch. It is never started elsewhere.`]})}),l&&s&&(0,K.jsx)(p,{compact:!0,hostName:s.name,connectivity:s.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:s.lastSeenAt})]})}function X({task:e,taskId:n,eligibility:r}){let i=o(t=>e?t.projects[e.projectId]:void 0),[a,s]=(0,G.useState)(!1),l=(0,G.useId)(),u=r?r.eligible?k:q[r.wait]:F,d=r?r.eligible?`Starting on ${r.hostName}`:T[r.wait]:`Waiting for dispatch`,f=r&&!r.eligible?r.message:null;return(0,K.jsxs)(`article`,{"data-testid":`now-queued-row`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(t,{to:N.task(n),className:`min-w-0 font-medium break-words hover:underline`,children:e?.title??`Task`}),i&&(0,K.jsx)(`span`,{className:`text-xs text-muted`,children:i.name}),(0,K.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1.5 text-sm`,children:[(0,K.jsx)(u,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${r?.eligible?`text-success`:`text-warning`}`}),(0,K.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:d}),f&&f!==d?(0,K.jsxs)(`span`,{className:`text-muted`,children:[`: `,f]}):null]})]})]}),e&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,K.jsx)(`label`,{htmlFor:l,className:`text-sm text-muted`,children:`Priority`}),(0,K.jsx)(`select`,{id:l,value:e.priority,disabled:a,className:`tap h-9 rounded-md border border-border bg-surface px-2 text-base md:text-sm`,onChange:async t=>{let n=Number(t.target.value);s(!0);try{await S(e.id,{priority:n}),j.success(`"${e.title}" is now ${I[n]} priority`)}catch(e){j.error(`Could not change priority: ${c(e)}`)}finally{s(!1)}},children:I.map((e,t)=>(0,K.jsx)(`option`,{value:t,children:e},e))}),a&&(0,K.jsx)(y,{label:`Saving priority`})]})]})}export{J as default};
|
|
2
|
-
//# sourceMappingURL=now-D6lDofYy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"now-D6lDofYy.js","names":["__iconData","__iconData","__iconData","useMemo","_Fragment","useState","useId","__toESM","Link","require_react","createLucideIcon","require_jsx_runtime","isApiError","useSyncStore","useConnection","errorMessage","Inbox","UnsupportedCapability","TriangleAlert","HostUnavailable","ErrorState","LoadingState","formatRelative","FatalError","EmptyState","Spinner","CalendarClock","ExternalLink","updateTask","isRunActive","DispatchToggle","WAIT_LABELS","useNow","Link2","LoaderCircle","CircleCheck","CirclePause","toast","StatusChip","ROUTES","WifiOff","Timer","PRIORITY_LABELS","__iconData$3","FolderLock","__iconData$2","Gauge","__iconData$1","PowerOff","__iconData","RotateCw","import_react","import_jsx_runtime","WAIT_ICONS","NowView","now","tasks","s","runs","hydrated","connection","unsupported","malformed","running","r","queued","q","t","a","b","loading","fatal","RunningRow","QueuedRow","task","taskId","run","runId","host","project","offline","sessionId","buttonClasses","busy","setBusy","id","Icon","eligibility","waitLabel","detail","p","e","err","i","l"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/folder-lock.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/gauge.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/power-off.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.mjs","../../src/features/now/index.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"folder-lock\",\n size: 24,\n node: [\n [\"rect\", { width: \"8\", height: \"5\", x: \"14\", y: \"17\", rx: \"1\", key: \"19aais\" }],\n [\n \"path\",\n {\n d: \"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5\",\n key: \"1w6v7t\"\n }\n ],\n [\"path\", { d: \"M20 17v-2a2 2 0 1 0-4 0v2\", key: \"pwaxnr\" }]\n ]\n};\n__iconData.node;\nconst FolderLock = createLucideIcon(__iconData);\n\nexport { __iconData, FolderLock as default };\n//# sourceMappingURL=folder-lock.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"gauge\",\n size: 24,\n node: [\n [\"path\", { d: \"m12 14 4-4\", key: \"9kzdfg\" }],\n [\"path\", { d: \"M3.34 19a10 10 0 1 1 17.32 0\", key: \"19p75a\" }]\n ]\n};\n__iconData.node;\nconst Gauge = createLucideIcon(__iconData);\n\nexport { __iconData, Gauge as default };\n//# sourceMappingURL=gauge.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"power-off\",\n size: 24,\n node: [\n [\"path\", { d: \"M18.36 6.64A9 9 0 0 1 20.77 15\", key: \"dxknvb\" }],\n [\"path\", { d: \"M6.16 6.16a9 9 0 1 0 12.68 12.68\", key: \"1x7qb5\" }],\n [\"path\", { d: \"M12 2v4\", key: \"3427ic\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n ]\n};\n__iconData.node;\nconst PowerOff = createLucideIcon(__iconData);\n\nexport { __iconData, PowerOff as default };\n//# sourceMappingURL=power-off.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"rotate-cw\",\n size: 24,\n node: [\n [\"path\", { d: \"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\", key: \"1p45f6\" }],\n [\"path\", { d: \"M21 3v5h-5\", key: \"1q7to0\" }]\n ]\n};\n__iconData.node;\nconst RotateCw = createLucideIcon(__iconData);\n\nexport { __iconData, RotateCw as default };\n//# sourceMappingURL=rotate-cw.mjs.map\n","import type { Eligibility, Priority, Task } from \"@switchyard/protocol\";\nimport { PRIORITY_LABELS } from \"@switchyard/protocol\";\nimport {\n CalendarClock,\n CircleCheck,\n CirclePause,\n ExternalLink,\n FolderLock,\n Gauge,\n Inbox,\n Link2,\n LoaderCircle,\n type LucideIcon,\n PowerOff,\n RotateCw,\n Timer,\n TriangleAlert,\n WifiOff,\n} from \"lucide-react\";\nimport { useId, useMemo, useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { ROUTES } from \"../../app/routes\";\nimport { buttonClasses, Spinner } from \"../../components/ui/Button\";\nimport { StatusChip } from \"../../components/ui/StatusChip\";\nimport {\n EmptyState,\n ErrorState,\n FatalError,\n HostUnavailable,\n LoadingState,\n UnsupportedCapability,\n} from \"../../components/ui/states\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { formatRelative } from \"../../lib/time\";\nimport { errorMessage, isApiError } from \"../../sync/api\";\nimport { useConnection, useSyncStore } from \"../../sync/store\";\nimport { updateTask } from \"../board/api\";\nimport { DispatchToggle } from \"../board/BoardChrome\";\nimport { isRunActive, WAIT_LABELS, type WaitReason } from \"../board/logic\";\nimport { useNow } from \"./useNow\";\n\nconst WAIT_ICONS: Record<WaitReason, LucideIcon> = {\n dependency: Link2,\n host_offline: WifiOff,\n project_limit: Gauge,\n workspace_occupied: FolderLock,\n scheduled_time: CalendarClock,\n invalid_configuration: TriangleAlert,\n dispatch_paused: CirclePause,\n project_automation_disabled: PowerOff,\n not_ready: Inbox,\n already_dispatched: LoaderCircle,\n retry_backoff: RotateCw,\n};\n\n/** /now: running and queued work, each queued row explaining its wait. */\nexport default function NowView() {\n const now = useNow();\n const tasks = useSyncStore((s) => s.tasks);\n const runs = useSyncStore((s) => s.runs);\n const hydrated = useSyncStore((s) => s.hydrated);\n const connection = useConnection();\n const unsupported = isApiError(now.error) && now.error.status === 404;\n const malformed =\n !!now.data && (!Array.isArray(now.data.running) || !Array.isArray(now.data.queued));\n\n // Running from the server, or from the store when the endpoint is unavailable.\n const running = useMemo(() => {\n if (now.data && !malformed)\n return now.data.running.map((r) => ({\n taskId: r.taskId,\n runId: r.runId,\n sessionId: r.sessionId,\n }));\n return Object.values(runs)\n .filter((r) => isRunActive(r) && r.state !== \"queued\")\n .map((r) => ({ taskId: r.taskId, runId: r.id, sessionId: r.sessionId }));\n }, [now.data, runs, malformed]);\n const queued = useMemo(() => {\n if (now.data && !malformed)\n return now.data.queued.map((q) => ({\n taskId: q.taskId,\n eligibility: q.eligibility as Eligibility | undefined,\n }));\n return Object.values(tasks)\n .filter((t) => t.state === \"ready\" && !t.hiddenFromBoard)\n .sort((a, b) => a.priority - b.priority || a.position - b.position)\n .map((t) => ({ taskId: t.id, eligibility: undefined as Eligibility | undefined }));\n }, [now.data, tasks, malformed]);\n\n const loading = (!now.data && now.loading && !now.error) || !hydrated;\n const fatal = !!now.error && !unsupported && !now.data;\n if (malformed)\n return (\n <FatalError\n title=\"The coordinator sent a queue this version cannot read\"\n error=\"GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.\"\n />\n );\n\n return (\n <div className=\"mx-auto flex w-full max-w-4xl min-w-0 flex-col gap-4 px-4 py-4 safe-pt\">\n <header className=\"flex min-w-0 flex-wrap items-center gap-3\">\n <h1 className=\"flex-1 text-lg font-semibold\">Now</h1>\n <DispatchToggle />\n </header>\n <p className=\"text-sm text-muted\">\n Pausing stops new work from starting. Runs already in progress keep going.\n </p>\n {connection.state !== \"live\" && now.data && (\n <p role=\"status\" className=\"text-sm text-muted\">\n Showing the last known queue.\n </p>\n )}\n {unsupported && (\n <UnsupportedCapability\n capability=\"Queue explanations\"\n reason=\"This coordinator does not report why queued tasks are waiting. The list below comes from local data.\"\n />\n )}\n {now.error != null && !unsupported && (\n <ErrorState\n compact\n title=\"Could not refresh running and queued work\"\n error={errorMessage(now.error)}\n onRetry={now.reload}\n />\n )}\n\n {loading ? (\n <LoadingState label=\"Loading running and queued work…\" />\n ) : fatal && running.length === 0 && queued.length === 0 ? null : running.length === 0 &&\n queued.length === 0 ? (\n <EmptyState\n icon={<Timer className=\"size-8\" />}\n title=\"Nothing running or queued\"\n description=\"Move a task to Ready on the board and the dispatcher starts it when it is eligible.\"\n action={{ label: \"Go to Board\", to: ROUTES.board }}\n />\n ) : (\n <>\n <section aria-labelledby=\"now-running\" className=\"flex min-w-0 flex-col gap-2\">\n <h2 id=\"now-running\" className=\"text-base font-semibold\">\n Running <span className=\"text-sm font-normal text-muted\">({running.length})</span>\n </h2>\n {running.length === 0 ? (\n <p className=\"text-sm text-muted\">Nothing is running.</p>\n ) : (\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {running.map((r) => (\n <li key={r.runId}>\n <RunningRow taskId={r.taskId} runId={r.runId} sessionId={r.sessionId} />\n </li>\n ))}\n </ul>\n )}\n </section>\n <section aria-labelledby=\"now-queued\" className=\"flex min-w-0 flex-col gap-2\">\n <h2 id=\"now-queued\" className=\"text-base font-semibold\">\n Queued <span className=\"text-sm font-normal text-muted\">({queued.length})</span>\n </h2>\n {queued.length === 0 ? (\n <p className=\"text-sm text-muted\">No Ready tasks are waiting.</p>\n ) : (\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {queued.map((q) => (\n <li key={q.taskId}>\n <QueuedRow\n task={tasks[q.taskId]}\n taskId={q.taskId}\n eligibility={q.eligibility}\n />\n </li>\n ))}\n </ul>\n )}\n </section>\n </>\n )}\n </div>\n );\n}\n\nfunction RunningRow({\n taskId,\n runId,\n sessionId,\n}: {\n taskId: string;\n runId: string;\n sessionId: string | null;\n}) {\n const task = useSyncStore((s) => s.tasks[taskId]);\n const run = useSyncStore((s) => s.runs[runId]);\n const host = useSyncStore((s) => (run?.hostId ? s.hosts[run.hostId] : undefined));\n const project = useSyncStore((s) => (task ? s.projects[task.projectId] : undefined));\n const offline = !!host && host.connectivity !== \"connected\";\n return (\n <article className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3\">\n <div className=\"flex min-w-0 flex-wrap items-start gap-2\">\n {run ? (\n <StatusChip kind=\"run\" value={run.state} size=\"sm\" />\n ) : (\n <StatusChip kind=\"task\" value=\"in_progress\" size=\"sm\" />\n )}\n <Link\n to={ROUTES.task(taskId)}\n className=\"min-w-0 flex-1 basis-48 font-medium break-words hover:underline\"\n >\n {task?.title ?? \"Task\"}\n </Link>\n {(sessionId ?? task?.sessionId) && (\n <Link\n to={ROUTES.session((sessionId ?? task?.sessionId) as string)}\n className={buttonClasses(\"secondary\", \"sm\")}\n >\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n </div>\n <p className=\"text-xs text-muted\">\n {[\n project?.name,\n host ? `on ${host.name}` : null,\n run?.attempt && run.attempt > 1 ? `attempt ${run.attempt}` : null,\n run?.startedAt ? `started ${formatRelative(run.startedAt)}` : null,\n run?.controlMode === \"human\" ? \"you have control\" : \"automation\",\n ]\n .filter(Boolean)\n .join(\" · \")}\n </p>\n {run?.state === \"uncertain\" && host && (\n <p className=\"text-sm text-warning\">\n <span className=\"text-text\">\n Waiting for host {host.name} to confirm launch. It is never started elsewhere.\n </span>\n </p>\n )}\n {offline && host && (\n <HostUnavailable\n compact\n hostName={host.name}\n connectivity={host.connectivity === \"reconnecting\" ? \"reconnecting\" : \"unreachable\"}\n lastSeenAt={host.lastSeenAt}\n />\n )}\n </article>\n );\n}\n\nfunction QueuedRow({\n task,\n taskId,\n eligibility,\n}: {\n task: Task | undefined;\n taskId: string;\n eligibility?: Eligibility;\n}) {\n const project = useSyncStore((s) => (task ? s.projects[task.projectId] : undefined));\n const [busy, setBusy] = useState(false);\n const id = useId();\n const Icon = eligibility\n ? eligibility.eligible\n ? CircleCheck\n : WAIT_ICONS[eligibility.wait]\n : Timer;\n const waitLabel = eligibility\n ? eligibility.eligible\n ? `Starting on ${eligibility.hostName}`\n : WAIT_LABELS[eligibility.wait]\n : \"Waiting for dispatch\";\n const detail = eligibility && !eligibility.eligible ? eligibility.message : null;\n return (\n <article\n data-testid=\"now-queued-row\"\n className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center\"\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <Link to={ROUTES.task(taskId)} className=\"min-w-0 font-medium break-words hover:underline\">\n {task?.title ?? \"Task\"}\n </Link>\n {project && <span className=\"text-xs text-muted\">{project.name}</span>}\n <p className=\"flex min-w-0 items-start gap-1.5 text-sm\">\n <Icon\n aria-hidden\n className={`mt-0.5 size-4 shrink-0 ${eligibility?.eligible ? \"text-success\" : \"text-warning\"}`}\n />\n <span className=\"min-w-0 break-words\">\n <span className=\"font-medium\">{waitLabel}</span>\n {detail && detail !== waitLabel ? <span className=\"text-muted\">: {detail}</span> : null}\n </span>\n </p>\n </div>\n {task && (\n <div className=\"flex shrink-0 items-center gap-2\">\n <label htmlFor={id} className=\"text-sm text-muted\">\n Priority\n </label>\n <select\n id={id}\n value={task.priority}\n disabled={busy}\n className=\"tap h-9 rounded-md border border-border bg-surface px-2 text-base md:text-sm\"\n onChange={async (e) => {\n const p = Number(e.target.value) as Priority;\n setBusy(true);\n try {\n await updateTask(task.id, { priority: p });\n toast.success(`\"${task.title}\" is now ${PRIORITY_LABELS[p]} priority`);\n } catch (err) {\n toast.error(`Could not change priority: ${errorMessage(err)}`);\n } finally {\n setBusy(false);\n }\n }}\n >\n {PRIORITY_LABELS.map((l, i) => (\n <option key={l} value={i}>\n {l}\n </option>\n ))}\n </select>\n {busy && <Spinner label=\"Saving priority\" />}\n </div>\n )}\n </article>\n );\n}\n"],"ignoreList":[0,1,2,3],"mappings":"A,+hBASA,IAAMA,EAAa,CACjB,KAAM,cACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,IAAK,OAAQ,IAAK,EAAG,KAAM,EAAG,KAAM,GAAI,IAAK,IAAK,QAAS,CAAC,EAC9E,CACE,OACA,CACE,EAAG,4GACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,4BAA6B,IAAK,QAAS,CAAC,CAC5D,CACF,EACAA,EAAW,KACX,IAAM4C,EAAalC,EAAiBV,CAAU,EChBxCC,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,aAAc,IAAK,QAAS,CAAC,EAC3C,CAAC,OAAQ,CAAE,EAAG,+BAAgC,IAAK,QAAS,CAAC,CAC/D,CACF,EACAA,EAAW,KAC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jsx-runtime-D13aM9HY.js";import{A as u,B as d,E as f,G as p,H as m,P as h,R as g,T as _,U as v,V as y,W as b,_ as x,c as S,d as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,t as N,v as ee}from"./states-DrTQuYXw.js";import{n as te,t as ne}from"./server-SxFxIScj.js";import{i as re,n as ie,r as ae,t as oe}from"./sliders-horizontal-S3tmwxsP.js";import{t as se}from"./chevron-right-evVLS6hq.js";import{t as ce}from"./copy-oWgGHmkS.js";import{n as le,t as ue}from"./pencil-DI8QbCN8.js";import{t as de}from"./key-round-VDbE9E4X.js";import{t as P}from"./plus-BLP-wIYD.js";import{t as fe}from"./save-DEvZPWlS.js";import{t as pe}from"./trash-C6X2OLrI.js";import{A as me,B as he,C as ge,F as _e,H as ve,I as F,L as ye,T as be,c as I,d as xe,h as Se,j as Ce,k as we,n as Te,r as Ee,s as De,z as Oe}from"./index-Cf6ZUCfK.js";import{n as L,t as ke}from"./TextArea-BsQHOQMe.js";import{i as Ae,l as je,o as Me,s as Ne,t as Pe,u as Fe}from"./dist-Bgkh2hc5.js";import{t as R}from"./Overlay-oYnnwvFM.js";import{_ as Ie,c as Le,d as Re,f as ze,g as Be,l as Ve,m as He,p as Ue,r as We,u as Ge}from"./logic-D_Eq9DMW.js";var Ke={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};Ke.node;var qe=o(Ke),Je={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};Je.node;var Ye=o(Je),Xe={name:`database-backup`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]};Xe.node;var Ze=o(Xe),Qe={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Qe.node;var $e=o(Qe),et={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};et.node;var tt=o(et),nt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};nt.node;var rt=o(nt),it={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};it.node;var at=o(it),ot={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};ot.node;var st=o(ot),ct={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};ct.node;var lt=o(ct),ut={name:`rotate-ccw-clock`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]],aliases:[`history`]};ut.node;var dt=o(ut),ft={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ft.node;var pt=o(ft),mt={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};mt.node;var ht=o(mt),gt={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};gt.node;var _t=o(gt),vt={name:`stethoscope`,size:24,node:[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]};vt.node;var yt=o(vt),bt={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};bt.node;var xt=o(bt),z=e(a(),1),B=c(),St=[{path:`hosts`,label:`Hosts`,description:`Execution hosts, capabilities and versions`,icon:ne},{path:`devices`,label:`Devices`,description:`Signed-in browsers, apps and terminals`,icon:lt},{path:`sign-in`,label:`Sign-in`,description:`Passkeys, single sign-on and signing out`,icon:de},{path:`projects`,label:`Projects`,description:`Repositories, checkouts and workspaces`,icon:ae},{path:`profiles`,label:`Pi profiles`,description:`Provider, model and thinking presets`,icon:oe},{path:`adapters`,label:`Adapters`,description:`Extension adapters on each host`,icon:ee},{path:`notifications`,label:`Notifications`,description:`Push, quiet hours and previews`,icon:ye},{path:`backups`,label:`Backups`,description:`Back up and restore the coordinator`,icon:Ze},{path:`diagnostics`,label:`Diagnostics`,description:`Versions, migrations, events and recent problems`,icon:yt},{path:`device`,label:`This device`,description:`Preferences stored on this device`,icon:rt}],V=e=>e?`/settings/${e}`:`/settings`;function H({title:e,description:t,actions:n,back:i,testId:a,children:o}){let s=Te(),c=i??(s===`mobile`?{to:`/settings`,label:`Settings`}:null);return(0,B.jsxs)(`section`,{"data-testid":a,className:`mx-auto flex w-full min-w-0 max-w-4xl flex-col gap-4 px-4 py-4 md:px-6`,children:[c&&(0,B.jsxs)(r,{to:c.to,className:`tap -ml-2 inline-flex w-fit items-center gap-1 rounded-md px-2 py-1 text-sm font-medium text-accent hover:bg-surface-2`,children:[(0,B.jsx)(re,{"aria-hidden":!0,className:`size-4`}),`Back to `,c.label]}),(0,B.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_15rem]`,children:[(0,B.jsx)(`h1`,{className:`break-words text-lg font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),o]})}function U({title:e,description:t,actions:n,children:r,className:i}){return(0,B.jsxs)(`section`,{className:T(`min-w-0 rounded-lg border border-border bg-surface p-4`,i),children:[(e||n)&&(0,B.jsxs)(`div`,{className:`mb-3 flex min-w-0 flex-wrap items-start gap-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_12rem]`,children:[e&&(0,B.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),t&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),r]})}function W({items:e}){return(0,B.jsx)(`dl`,{className:`grid min-w-0 gap-x-4 gap-y-1 text-sm sm:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)]`,children:e.map(([e,t],n)=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsx)(`dt`,{className:`text-muted`,children:e}),(0,B.jsx)(`dd`,{className:`mb-1 min-w-0 break-words sm:mb-0`,children:t})]},n))})}function G(){let e=_();return e.state===`live`||e.state===`connecting`?null:(0,B.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-sm text-muted`,children:[(0,B.jsx)(dt,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsxs)(`span`,{children:[`Showing last known data`,e.lastSyncedAt?` from ${O(e.lastSyncedAt)}`:``,`. Changes made elsewhere appear after reconnecting.`]})]})}function K(){return h(e=>e.hydrated)}function q({icon:e,label:t,tone:n=`neutral`,spin:r,className:i}){return(0,B.jsxs)(`span`,{className:T(`inline-flex max-w-full items-center gap-1 rounded-full border px-2 text-xs leading-6 font-medium`,Se[n],i),children:[(0,B.jsx)(e,{"aria-hidden":!0,className:T(`size-3.5 shrink-0`,r&&`animate-spin`)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]})}var Ct={darwin:`macOS`,linux:`Linux`};function wt({host:e}){return e.piVersion?e.piCompatible?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Pi ${e.piVersion} (compatible)`}):(0,B.jsx)(q,{icon:w,tone:`danger`,label:`Pi ${e.piVersion} (incompatible, needs ${Pe})`}):(0,B.jsx)(q,{icon:w,tone:`warning`,label:`Pi not detected (incompatible)`})}function J({id:e,label:t,hint:n,error:r,children:i,className:a}){return(0,B.jsxs)(`div`,{className:T(`flex min-w-0 flex-col gap-1`,a),children:[(0,B.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:t}),i,n&&(0,B.jsx)(`p`,{id:`${e}-hint`,className:`text-xs text-muted`,children:n}),r&&(0,B.jsxs)(`p`,{id:`${e}-error`,className:`flex items-start gap-1 text-xs text-danger`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words`,children:r})]})]})}function Y(e,t){let n=[t.hint&&`${e}-hint`,t.error&&`${e}-error`].filter(Boolean);return{"aria-describedby":n.length?n.join(` `):void 0,"aria-invalid":t.error?!0:void 0}}function X({className:e,children:t,...n}){return(0,B.jsx)(`select`,{className:T(`tap block h-9 w-full min-w-0 rounded-md border border-border bg-surface px-2 text-base text-text md:text-sm`,`focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0`,e),...n,children:t})}function Tt({label:e,description:t,checked:n,onChange:r,disabled:i}){let a=(0,z.useId)();return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(`input`,{id:a,type:`checkbox`,role:`switch`,"aria-checked":n,checked:n,disabled:i,onChange:e=>r(e.target.checked),"aria-describedby":t?`${a}-desc`:void 0,className:`peer sr-only`}),(0,B.jsxs)(`label`,{htmlFor:a,className:T(`tap flex min-w-0 flex-1 cursor-pointer items-start gap-3 rounded-md`,`peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--sy-focus)]`,i&&`cursor-not-allowed opacity-60`),children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:T(`relative mt-0.5 inline-flex h-6 w-10 shrink-0 items-center rounded-full border transition-colors`,n?`border-accent bg-accent`:`border-border-strong bg-surface-3`),children:(0,B.jsx)(`span`,{className:T(`absolute size-4 rounded-full bg-surface shadow transition-transform`,n?`translate-x-5`:`translate-x-1`)})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`block text-sm font-medium`,children:[e,` `,(0,B.jsxs)(`span`,{className:`font-normal text-muted`,children:[`(`,n?`On`:`Off`,`)`]})]}),t&&(0,B.jsx)(`span`,{id:`${a}-desc`,className:`block text-sm text-muted`,children:t})]})]})]})}function Et({label:e,description:t,checked:n,onChange:r}){let i=(0,z.useId)();return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,B.jsx)(`input`,{id:i,type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),"aria-describedby":t?`${i}-desc`:void 0,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,B.jsxs)(`label`,{htmlFor:i,className:`min-w-0 flex-1 cursor-pointer text-sm`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:e}),t&&(0,B.jsx)(`span`,{id:`${i}-desc`,className:`block text-muted`,children:t})]})]})}function Dt(e){let t=e.trim();return t?t.startsWith(`/`)?null:`Use an absolute path that starts with /, e.g. /Users/me/src/app.`:`Enter the path of the checkout on the host.`}function Ot(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.passkeys)&&typeof t.passkeyAvailability==`object`}function kt(e){return e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean)}function Z({error:e}){return e?(0,B.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:b(e)})]}):null}async function At(e,t=`Copied to clipboard`){try{return await navigator.clipboard.writeText(e),I.success(t),!0}catch{return I.error(`Could not copy. Select the text and copy it manually.`),!1}}function jt({text:e,label:t=`Copy`,toastMessage:n,size:r=`sm`}){let[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null);return(0,z.useEffect)(()=>()=>void(o.current&&clearTimeout(o.current)),[]),(0,B.jsx)(D,{size:r,icon:i?(0,B.jsx)(te,{className:`size-4`}):(0,B.jsx)(ce,{className:`size-4`}),onClick:async()=>{await At(e,n)&&(a(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),2e3))},children:i?`Copied`:t})}function Mt({text:e,label:t,copyLabel:n=`Copy`}){return(0,B.jsxs)(`figure`,{className:`m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,B.jsx)(`figcaption`,{className:`sr-only`,children:t}),(0,B.jsx)(`pre`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm`,children:e}),(0,B.jsx)(jt,{text:e,label:n})]})}function Nt(e){let[t,n]=(0,z.useState)(()=>Date.now());if((0,z.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Date.parse(e);return Number.isNaN(r)?null:Math.max(0,r-t)}function Pt(e){let t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function Ft({open:e,onClose:t,title:n,description:r,confirmLabel:i,onConfirm:a,busy:o,error:s,danger:c=!0,confirmDisabled:l,disabledReason:u,children:d}){return(0,B.jsx)(R,{open:e,onClose:o?()=>void 0:t,dismissOnBackdrop:!o,title:n,description:r,footer:(0,B.jsxs)(B.Fragment,{children:[l&&u&&(0,B.jsx)(`p`,{className:`mr-auto min-w-0 flex-1 basis-full text-xs text-muted sm:basis-auto`,children:u}),(0,B.jsx)(D,{onClick:t,disabled:o,children:`Cancel`}),(0,B.jsx)(D,{variant:c?`danger`:`primary`,busy:o,disabled:l,onClick:a,children:i})]}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,B.jsx)(Z,{error:s})]})})}var It=class extends Error{constructor(e){super(`Unexpected response from ${e}. The coordinator and this app may be out of sync.`),this.name=`UnexpectedResponseError`}};function Lt(e,t){let[n,r]=(0,z.useState)({data:void 0,error:null,loading:e!==null,fatal:!1}),[i,a]=(0,z.useState)(0);(0,z.useEffect)(()=>{if(!e)return;let n=new AbortController;return r(e=>({...e,loading:!0,error:null,fatal:!1})),y(e,void 0,n.signal).then(i=>{n.signal.aborted||(t&&!t(i)?r(t=>({...t,loading:!1,error:new It(e),fatal:!0})):r({data:i,error:null,loading:!1,fatal:!1}))}).catch(e=>{n.signal.aborted||r(t=>({...t,loading:!1,error:e,fatal:!1}))}),()=>n.abort()},[e,i]);let o=(0,z.useCallback)(()=>a(e=>e+1),[]),s=(0,z.useCallback)(e=>r({data:e,error:null,loading:!1,fatal:!1}),[]);return{...n,reload:o,setData:s}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Rt={active:{icon:F,label:`Active`,tone:`success`},disabled:{icon:Ce,label:`Disabled`,tone:`neutral`},error:{icon:me,label:`Error`,tone:`danger`}};function zt({status:e}){let t=Rt[e]??Rt.error;return(0,B.jsx)(q,{icon:t.icon,label:t.label,tone:t.tone})}var Bt={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},Vt={info:{icon:be,label:`Info`,tone:`info`},warning:{icon:w,label:`Warning`,tone:`warning`},error:{icon:me,label:`Error`,tone:`danger`}};function Ht({level:e}){let t=Vt[e]??Vt.info;return(0,B.jsx)(q,{icon:t.icon,label:t.label,tone:t.tone})}function Ut(e){let t=h(e=>e.diagnostics);return(0,z.useMemo)(()=>{let n=new Set,r=[];for(let i of[...e??[],...t]){let e=`${i.at}|${i.adapterId??``}|${i.sessionId??``}|${i.message}`;n.has(e)||(n.add(e),r.push(i))}return r.sort((e,t)=>t.at.localeCompare(e.at))},[e,t])}function Wt(){let e=K(),t=h(e=>e.adapters),n=h(e=>e.hosts),i=Lt(`/api/diagnostics`,Q),a=Ut(Array.isArray(i.data?.diagnostics)?i.data.diagnostics:void 0),o=(0,z.useMemo)(()=>Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:n[e]?.name??`Unknown host (${e})`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[t,n]);return(0,B.jsxs)(H,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,B.jsx)(G,{}),i.error!==null&&!i.fatal&&(0,B.jsx)(k,{compact:!0,title:`Could not load adapter diagnostics history`,error:i.error,onRetry:i.reload}),e?o.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ee,{className:`size-8`}),title:`No adapters reported`,description:`Hosts report adapters when their agent connects. Check that your hosts are connected.`,action:{label:`Open hosts`,to:V(`hosts`)}}):o.map(e=>(0,B.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,B.jsx)(r,{to:V(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(e=>(0,B.jsx)(Gt,{adapter:e,diagnostics:a.filter(t=>t.adapterId===e.id)},e.id))]},e.hostId)):(0,B.jsx)(A,{label:`Loading adapters…`})]})}function Gt({adapter:e,diagnostics:t}){return(0,B.jsxs)(U,{title:(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,B.jsx)(zt,{status:e.status}),children:[(0,B.jsx)(W,{items:[[`Version`,e.version],[`Tier`,Bt[e.tier]??e.tier],[`Target extension`,(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,B.jsx)(`span`,{className:`font-mono`,children:e.target.versionRange},`r`)],[`Tested versions`,e.target.testedVersions.length?e.target.testedVersions.join(`, `):`None recorded`],[`Capabilities`,e.capabilities.length?e.capabilities.join(`, `):`None`],[`Web renderer`,e.webRenderer?`Yes (runs in a sandboxed frame; mobile uses a fallback)`:`No (native cards only)`],...e.detail?[[`Detail`,e.detail]]:[]]}),(0,B.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:t.slice(0,10).map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,B.jsx)(Ht,{level:e.level}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,B.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:O(e.at)})]},`${e.at}-${e.message}`))})]})}function Kt(e){return Q(e)&&Q(e.versions)}var qt=`/api/diagnostics`,Jt=`switchyard coordinator backup <file>`,Yt=`switchyard coordinator restore <file>`;function Xt(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function Zt(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?O(t):typeof t==`object`?JSON.stringify(t):String(t)}function Qt(){let e=Lt(qt,Kt),t=e.data&&Q(e.data.backup)?e.data.backup:null;return(0,B.jsxs)(H,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,B.jsxs)(U,{title:`Back up`,children:[(0,B.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,B.jsx)(Mt,{text:Jt,label:`Backup command`,copyLabel:`Copy command`})]}),(0,B.jsxs)(U,{title:`Restore`,children:[(0,B.jsxs)(`p`,{className:`mb-2 text-sm`,children:[`Restore refuses to run while the coordinator is running: stop it first. The current database is kept next to it as`,` `,(0,B.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,B.jsx)(Mt,{text:Yt,label:`Restore command`,copyLabel:`Copy command`}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`Hosts keep running sessions during a coordinator restart and replay their events when it comes back.`})]}),(0,B.jsx)(U,{title:`Last backup`,children:e.fatal?(0,B.jsx)(M,{error:e.error}):e.error&&!e.data?(0,B.jsx)(k,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,B.jsx)(W,{items:Object.entries(t).map(([e,t])=>[Xt(e),Zt(e,t)])}):(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No backup info is recorded by the coordinator. Keep track of your backup files yourself, or schedule the backup command with cron or launchd.`}):(0,B.jsx)(A,{label:`Loading backup info…`})})]})}function $t(e){return v(`/api/enrollments`,{kind:e})}function en({expiresAt:e,onRenew:t,busy:n}){let r=Nt(e);return r!==null&&r<=0?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,B.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,B.jsx)(D,{size:`sm`,busy:n,icon:(0,B.jsx)(x,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,B.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,B.jsx)(we,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsxs)(`span`,{children:[`Expires in`,` `,(0,B.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:Pt(r)}),`. Single use.`]})]})}function tn({busy:e,error:t,onRetry:n}){return e?(0,B.jsx)(A,{label:`Creating a single-use link…`}):t?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(Z,{error:t}),(0,B.jsx)(D,{icon:(0,B.jsx)(x,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}var nn={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},rn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function an({kind:e}){return(0,B.jsx)(e===`pwa`?ht:e===`browser`?at:xt,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function on(){let e=K(),t=h(e=>e.devices);ve(e=>e.me);let n=Oe(),r=(0,z.useMemo)(()=>Object.values(t).filter(e=>e.revokedAt===null).sort((e,t)=>Number(t.id===n)-Number(e.id===n)||(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``)),[t,n]),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),g=async()=>{if(o){l(!0),d(null);try{await v(`/api/devices/${encodeURIComponent(o.id)}/revoke`),I.success(`${o.name} revoked`),s(null)}catch(e){d(e)}finally{l(!1)}}},_=async e=>{p(e.id);try{await m(`/api/devices/${encodeURIComponent(e.id)}`,{preferredMobile:!0}),I.success(`${e.name} is now the preferred mobile device`)}catch(e){I.error(`Could not set the preferred device: ${b(e)}`)}finally{p(null)}};return(0,B.jsxs)(H,{testId:`settings-devices`,title:`Devices`,description:`Browsers, Home Screen apps and terminals signed in to this coordinator. Each has its own revocable credential.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>a(!0),children:`Add device`}),children:[(0,B.jsx)(G,{}),e?r.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(lt,{className:`size-8`}),title:`No devices`,description:`Add a phone, tablet or another computer with a single-use QR link.`,action:{label:`Add device`,onClick:()=>a(!0)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=e.id===n;return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,B.jsx)(an,{kind:e.kind}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,B.jsx)(q,{icon:at,tone:`info`,label:`This device`}),e.preferredMobile&&(0,B.jsx)(q,{icon:_t,tone:`success`,label:`Preferred mobile`})]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,B.jsx)(`span`,{children:nn[e.kind]}),(0,B.jsxs)(`span`,{children:[`Last seen `,j(e.lastSeenAt)]}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,B.jsx)(Ye,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,B.jsx)(qe,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission`,` `,rn[e.push.permission]]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!e.preferredMobile&&(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(_t,{className:`size-4`}),busy:f===e.id,onClick:()=>_(e),children:`Set as preferred mobile device`}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pt,{className:`size-4`}),onClick:()=>{d(null),s(e)},children:`Revoke`})]})]},e.id)})}):(0,B.jsx)(A,{label:`Loading devices…`}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,B.jsx)(sn,{open:i,onClose:()=>a(!1)}),(0,B.jsxs)(Ft,{open:o!==null,onClose:()=>s(null),title:o?`Revoke ${o.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:c,error:u,onConfirm:g,children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Its credential stops working immediately and its push subscription is removed. To use it again, add it with a new link.`}),o?.id===n&&(0,B.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:`This is the device you are using now. Revoking it signs you out here.`})]})]})}function sn({open:e,onClose:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=async()=>{a(!0),s(null);try{r(await $t(`device`))}catch(e){s(e)}finally{a(!1)}};(0,z.useEffect)(()=>{e&&c()},[e]);let l=()=>{r(null),s(null),t()};return(0,B.jsx)(R,{open:e,onClose:l,title:`Add device`,description:`Scan the code with the new device's camera, or open the link on it.`,footer:(0,B.jsx)(D,{onClick:l,children:`Done`}),children:(0,B.jsxs)(`div`,{"data-testid":`add-device-dialog`,className:`flex min-w-0 flex-col items-stretch gap-3`,children:[(0,B.jsx)(tn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,B.jsxs)(B.Fragment,{children:[n.qrSvg&&(0,B.jsx)(`div`,{role:`img`,"aria-label":`QR code for the enrollment link`,className:`mx-auto size-56 max-w-full rounded-md bg-white p-2 [&>svg]:size-full`,dangerouslySetInnerHTML:{__html:n.qrSvg}}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,B.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`min-w-0 flex-1 break-all font-mono text-sm text-accent underline`,children:n.url}),(0,B.jsx)(jt,{text:n.url,label:`Copy link`,toastMessage:`Link copied`})]}),(0,B.jsx)(en,{expiresAt:n.expiresAt,onRenew:c,busy:i}),(0,B.jsx)(`p`,{className:`text-xs text-muted`,children:`Anyone with this link can enroll a device until it expires or is used. Share it only with your own devices.`})]})]})})}function cn(){let e=De(e=>e.sendWithEnter),t=De(e=>e.set),n=Te(),r=Ee();ve(e=>e.me);let i=Oe(),a=h(e=>i?e.devices[i]:void 0);return(0,B.jsxs)(H,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,B.jsx)(U,{title:`Composer`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(Tt,{label:`Send with Enter`,description:`On desktop, Enter sends the message and Shift+Enter inserts a newline. When off, Enter inserts a newline; send with the Send button.`,checked:e,onChange:e=>t(`sendWithEnter`,e)}),(0,B.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,n===`mobile`||r?` That applies on this device now.`:``]})]})}),(0,B.jsx)(U,{title:`Identity`,children:(0,B.jsx)(W,{items:[[`Name`,a?.name??`Unknown`],[`Kind`,a?nn[a.kind]:`Unknown`],[`Device ID`,(0,B.jsx)(`span`,{className:`break-all font-mono`,children:i??`Unknown`},`id`)]]})})]})}var $=e=>e==null||e===``?`Unknown`:String(e);function ln(){let e=Lt(qt,Kt),t=e.data,n=Ut(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=h(e=>e.hosts),i=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{icon:(0,B.jsx)(ce,{className:`size-4`}),disabled:!t,onClick:()=>t&&At(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,B.jsx)(D,{busy:e.loading&&!!t,icon:(0,B.jsx)(x,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,B.jsx)(M,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!t)a=(0,B.jsx)(k,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,B.jsx)(A,{label:`Loading diagnostics…`});else{let i=t.migrationLevel!==void 0&&t.latestMigration!==void 0&&t.migrationLevel>=t.latestMigration,o=(t.hosts??[]).filter(e=>!e.revokedAt);a=(0,B.jsxs)(B.Fragment,{children:[e.error?(0,B.jsx)(k,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,B.jsx)(U,{title:`Versions`,children:(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,B.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,B.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,B.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,B.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,B.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,B.jsx)(`td`,{className:`py-1 font-mono break-all`,children:$(t)})]},e)),(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,B.jsx)(`td`,{className:`py-1 font-mono`,children:Pe})]})]})]})})}),(0,B.jsx)(U,{title:`Coordinator`,children:(0,B.jsx)(W,{items:[[`Database migration`,(0,B.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`span`,{children:[`Level `,$(t.migrationLevel),` of `,$(t.latestMigration)]}),i?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Up to date`}):(0,B.jsx)(q,{icon:w,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,B.jsx)(`span`,{className:`break-all`,children:$(t.publicUrl)},`u`)],[`Events`,t.events?`Seq ${$(t.events.minSeq)} to ${$(t.events.maxSeq)} stored (current ${$(t.events.currentSeq)}, oldest retained ${$(t.events.minRetainedSeq)})`:`Unknown`],[`Event retention`,t.events?.retentionDays==null?`Unknown`:`${t.events.retentionDays} days`],[`Push`,t.push?`${t.push.vapidConfigured?`VAPID keys configured`:`VAPID keys not configured`}, ${$(t.push.subscriptions)} subscription(s)`:`Unknown`],[`Connected clients`,`${$(t.clients?.connectedDevices)} device(s)`]]})}),(0,B.jsx)(U,{title:`Hosts`,children:o.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsx)(xe,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,B.jsx)(wt,{host:e})]}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,$(e.agentVersion),` · Last seen `,j(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,B.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,B.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,B.jsx)(U,{title:`Recent diagnostics`,children:n.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,B.jsx)(Ht,{level:e.level}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,B.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,B.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:O(e.at)})]},`${e.at}-${t}`))})})]})}return(0,B.jsxs)(H,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,B.jsx)(G,{}),a]})}function un(e){let t=kt(e),n=t.find(e=>!Ae(e));return n?{folders:t,problem:`"${n}" is not an absolute path or a ~/ path.`}:t.length>20?{folders:t,problem:`Use at most 20 folders.`}:{folders:t,problem:null}}function dn(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${j(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${j(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function fn({host:e}){let t=(0,z.useId)(),n=(e.projectFolders??[]).join(`
|
|
3
|
-
`),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),d=r??n,f=r!==null&&r!==n,{folders:p,problem:h}=un(d),g=e.projectScan,_=s||g?.state===`running`,y=e.connectivity===`connected`,b=n?y?_?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,x=async()=>{o(!0),u(null);try{await m(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:p}),I.success(`Project folders saved`),i(null)}catch(e){u(e)}finally{o(!1)}},S=async()=>{c(!0),u(null);try{let t=await v(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);I.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){u(e)}finally{c(!1)}},C=f?h:null;return(0,B.jsx)(U,{title:`Project folders`,description:`Every Git repository directly inside these folders becomes a project, or another checkout of the project with the same remote. Folders are rescanned when the host connects and every 10 minutes; nothing is removed automatically.`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsx)(J,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:C,children:(0,B.jsx)(ke,{id:`${t}-folders`,value:d,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...Y(`${t}-folders`,{hint:!0,error:C})})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(fe,{className:`size-4`}),busy:a,disabled:!f||!!h,onClick:x,children:`Save folders`}),(0,B.jsx)(D,{icon:(0,B.jsx)(tt,{className:`size-4`}),busy:s,disabled:!!b,title:b??void 0,onClick:S,children:`Scan now`})]}),(0,B.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:dn(g)}),g&&g.state!==`running`&&g.errors.length>0&&(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:g.errors.map(e=>(0,B.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,B.jsx)(Z,{error:l})]})})}var pn={prompt:`Prompt`,steer:`Steer a running turn`,followUp:`Queue follow-up`,abort:`Abort`,resume:`Resume`,rename:`Rename session`,importInactive:`Import inactive sessions`,extensionDialogs:`Extension dialogs`,customUi:`Custom extension UI`,widgetsText:`Text widgets`,widgetsComponent:`Component widgets`,tokenAccounting:`Token accounting`,costAccounting:`Cost accounting`};function mn(){let e=K(),t=f(),[n,r]=(0,z.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,B.jsxs)(H,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,B.jsx)(G,{}),e?t.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ne,{className:`size-8`}),title:`No hosts yet`,description:`Add a host to run Pi sessions. You will get a command to run on that machine.`,action:{label:`Add host`,onClick:()=>r(!0)}}):(0,B.jsxs)(B.Fragment,{children:[i.map(e=>(0,B.jsx)(E,{compact:!0,hostName:e.name,connectivity:e.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:e.lastSeenAt},e.id)),(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsx)(hn,{host:e})},e.id))})]}):(0,B.jsx)(A,{label:`Loading hosts…`}),(0,B.jsx)(vn,{open:n,onClose:()=>r(!1)})]})}function hn({host:e}){return(0,B.jsxs)(r,{to:V(`hosts/${encodeURIComponent(e.id)}`),className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,B.jsx)(ne,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`text-sm text-muted`,children:Ct[e.platform]})]}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(xe,{kind:`host`,value:e.connectivity}),(0,B.jsx)(wt,{host:e}),(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,j(e.lastSeenAt)]})]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}var gn=`@spencerboucher/switchyard`;function _n(e){return[`npm install -g ${gn}`,e,`switchyard host install-service`].join(`
|
|
4
|
-
`)}function vn({open:e,onClose:t}){let[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=async()=>{a(!0),s(null);try{r(await $t(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,B.jsx)(R,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,B.jsx)(D,{onClick:l,children:`Done`}),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Create a single-use enrollment, then run the command it shows on the new host. The host appears here once its agent connects.`}),(0,B.jsx)(D,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,B.jsx)(tn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-sm`,children:`Run this on the host, as the user that should run Pi (it needs Node 24 or newer, git and Pi):`}),(0,B.jsx)(Mt,{text:n.command?_n(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,B.jsx)(en,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function yn(){let{hostId:e=``}=s(),t=K(),i=h(t=>t.hosts[e]),a=h(t=>t.adapters[e]),o=h(e=>e.checkouts),c=h(e=>e.projects),l=n(),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,g]=(0,z.useState)(null),_=(0,z.useMemo)(()=>Object.values(o).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[o,e]),y={to:V(`hosts`),label:`Hosts`};if(!t)return(0,B.jsx)(H,{title:`Host`,back:y,children:(0,B.jsx)(A,{label:`Loading host…`})});if(!i||i.revokedAt)return(0,B.jsx)(H,{title:`Host`,back:y,children:(0,B.jsx)(N,{icon:(0,B.jsx)(ne,{className:`size-8`}),title:i?`This host was revoked`:`Host not found`,description:i?`${i.name} was revoked ${j(i.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:V(`hosts`)}})});let b=async()=>{p(!0),g(null);try{await v(`/api/hosts/${encodeURIComponent(i.id)}/revoke`),I.success(`Host ${i.name} revoked`),d(!1),l(V(`hosts`))}catch(e){g(e)}finally{p(!1)}},x=i.capabilities,C=e=>x?.unsupported.find(t=>t.capability===e)?.reason,w=x?.unsupported.filter(e=>!Me.includes(e.capability))??[];return(0,B.jsxs)(H,{title:i.name,description:`${Ct[i.platform]} host`,back:y,actions:(0,B.jsx)(D,{variant:`danger`,icon:(0,B.jsx)(pt,{className:`size-4`}),onClick:()=>{g(null),d(!0)},children:`Revoke host`}),children:[(0,B.jsx)(G,{}),i.connectivity!==`connected`&&(0,B.jsx)(E,{compact:!0,hostName:i.name,connectivity:i.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i.lastSeenAt}),(0,B.jsx)(U,{title:`Connectivity and versions`,children:(0,B.jsx)(W,{items:[[`Status`,(0,B.jsx)(xe,{kind:`host`,value:i.connectivity},`s`)],[`Last seen`,i.lastSeenAt?`${j(i.lastSeenAt)} (${O(i.lastSeenAt)})`:`Never`],[`Platform`,Ct[i.platform]],[`Agent version`,(0,B.jsx)(`span`,{className:`font-mono`,children:i.agentVersion},`a`)],[`Pi`,(0,B.jsx)(wt,{host:i},`p`)],[`Enrolled`,O(i.createdAt)]]})}),(0,B.jsx)(U,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:x?(0,B.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[Me.map(e=>{let t=x[e],n=C(e);return(0,B.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,B.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,B.jsx)(Ce,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:pn[e]}),(0,B.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,B.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),w.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,B.jsx)(Ce,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,B.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,B.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,B.jsx)(S,{capability:`Capability report`,reason:`This host has not reported its Pi capabilities yet. It may be offline, or Pi may be missing or incompatible.`})}),(0,B.jsx)(fn,{host:i}),(0,B.jsx)(U,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:_.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No checkouts on this host`,description:`Create a project or add a checkout to an existing project.`,action:{label:`Open projects`,to:V(`projects`)}}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:_.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,B.jsx)(r,{to:V(`projects/${encodeURIComponent(e.projectId)}`),className:`font-medium text-accent hover:underline`,children:c[e.projectId]?.name??`Unknown project`}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,B.jsx)(U,{title:`Adapters`,actions:(0,B.jsx)(r,{to:V(`adapters`),className:`text-sm font-medium text-accent`,children:`All adapters`}),children:!a||a.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:a.map(e=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,B.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,B.jsx)(zt,{status:e.status})]},e.id))})}),(0,B.jsx)(Ft,{open:u,onClose:()=>d(!1),title:`Revoke ${i.name}?`,confirmLabel:`Revoke host`,busy:f,error:m,onConfirm:b,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`The host agent is disconnected and its credential stops working. Sessions on it are not moved or restarted elsewhere. To use this machine again, add it as a new host.`})})]})}var bn={granted:{icon:Ye,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:qe,label:`Blocked`,tone:`danger`,guidance:`Notifications are blocked for this site. Allow them in your browser's site settings (or the system notification settings for the Home Screen app), then reload.`},default:{icon:ye,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:ye,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:Ce,label:`Not supported`,tone:`warning`,guidance:`This browser cannot receive web push here. On iPhone and iPad, add Switchyard to the Home Screen first.`}};function xn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function Sn(e){let t=Q(e)&&Q(e.settings)?e.settings:e;return!Q(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:Q(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function Cn(){let[e,t]=(0,z.useState)(()=>Re()),[n,r]=(0,z.useState)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=Ve()&&!Ge();(0,z.useEffect)(()=>{let e=!0;Le().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(Re())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),Ue().then(e=>{t(e),e===`granted`?(r(!0),I.success(`Notifications enabled on this device`)):e===`denied`&&I.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(Re())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await He(),r(!1),I.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await ze(),I.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),I.error(`Test notification failed: ${b(e)}`)}finally{a(null)}},f=bn[e]??bn.unknown;return(0,B.jsxs)(H,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,B.jsx)(U,{title:`This device`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,B.jsx)(q,{icon:f.icon,label:f.label,tone:f.tone}),n!==null&&e===`granted`&&(0,B.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:f.guidance}),c&&(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,B.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,B.jsx)(ht,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,B.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,B.jsx)(`li`,{children:`Tap Share`}),(0,B.jsx)(`li`,{children:`Add to Home Screen`}),(0,B.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,B.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(Ye,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,B.jsx)(D,{icon:(0,B.jsx)(qe,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,B.jsx)(D,{icon:(0,B.jsx)(ie,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,B.jsx)(`p`,{className:`text-xs text-muted`,children:`Enabling is not possible in this browser. A test notification still goes to your other subscribed devices.`}),(0,B.jsx)(Z,{error:o}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`Delivery and clearing are best effort: browsers and operating systems may delay, group or keep notifications even after you answer elsewhere.`})]})}),(0,B.jsx)(wn,{})]})}function wn(){let e=Lt(`/api/me/notification-settings`,e=>!!Sn(e)),t=(0,z.useMemo)(()=>e.data?Sn(e.data):null,[e.data]),n=e.error instanceof g&&e.error.status===404;return(0,B.jsx)(U,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,B.jsx)(S,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,B.jsx)(M,{error:e.error}):e.error&&!t?(0,B.jsx)(k,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,B.jsx)(En,{settings:t,onSaved:t=>e.setData(t)}):(0,B.jsx)(A,{label:`Loading notification settings…`})})}var Tn=/^\d{2}:\d{2}$/;function En({settings:e,onSaved:t}){let n=(0,z.useId)(),r=h(e=>e.devices),i=(0,z.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,z.useState)(e.quietHours!==null),[s,c]=(0,z.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,z.useState)(e.quietHours?.end??`07:00`),[d,f]=(0,z.useState)(e.quietHours?.timezone??xn()),[p,g]=(0,z.useState)(e.privatePreviews),[_,v]=(0,z.useState)(e.preferredDeviceId??``),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(null),C=a&&!Tn.test(s)?`Use a time like 22:00.`:null,w=a&&!Tn.test(l)?`Use a time like 07:00.`:null,T=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,E=!_||i.some(e=>e.id===_);return(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),C||w||T)return;let n={quietHours:a?{start:s,end:l,timezone:d.trim()}:null,privatePreviews:p,preferredDeviceId:_||null};b(!0),S(null);try{t(Sn(await m(`/api/me/notification-settings`,n))??n),I.success(`Notification preferences saved`)}catch(e){S(e)}finally{b(!1)}},noValidate:!0,children:[(0,B.jsx)(Tt,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(J,{id:`${n}-start`,label:`From`,error:C,children:(0,B.jsx)(L,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...Y(`${n}-start`,{error:C})})}),(0,B.jsx)(J,{id:`${n}-end`,label:`Until`,error:w,children:(0,B.jsx)(L,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...Y(`${n}-end`,{error:w})})}),(0,B.jsx)(J,{id:`${n}-tz`,label:`Time zone`,error:T,children:(0,B.jsx)(L,{id:`${n}-tz`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-tz`,{error:T})})})]}),(0,B.jsx)(Tt,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:p,onChange:g}),(0,B.jsx)(J,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,B.jsxs)(X,{id:`${n}-device`,value:_,onChange:e=>v(e.target.value),...Y(`${n}-device`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!E&&(0,B.jsxs)(`option`,{value:_,children:[`Unknown device (`,_,`)`]})]})}),(0,B.jsx)(Z,{error:x}),(0,B.jsx)(`div`,{children:(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:y,icon:(0,B.jsx)(fe,{className:`size-4`}),children:`Save preferences`})})]})}var Dn={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},On={ask:`Ask before trusting project-local Pi settings and extensions.`,approve:`Trust project-local Pi settings and extensions automatically.`,ignore:`Never load project-local Pi settings or extensions.`},kn=je.options,An={all:`Loads your extensions, skills and prompt templates.`,vanilla:`Starts Pi with --no-extensions --no-skills --no-prompt-templates (also no built-in MCP). Your logins, default model and AGENTS.md still apply, and Switchyard's model, effort, context and command controls keep working.`};function jn(e){let t=[];return e.forEach((e,n)=>{let r=Ne.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function Mn(){let e=K(),t=h(e=>e.profiles),n=h(e=>e.projects),r=(0,z.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),[c,l]=(0,z.useState)(!1),[u,f]=(0,z.useState)(null),p=async()=>{if(o){l(!0),f(null);try{await d(`/api/profiles/${encodeURIComponent(o.id)}`),I.success(`Profile ${o.name} deleted`),s(null)}catch(e){f(e)}finally{l(!1)}}},m=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,B.jsxs)(H,{title:`Pi profiles`,description:`Presets for provider, model, thinking level and Pi flags. Sessions keep a snapshot of the profile they started with.`,actions:(0,B.jsx)(D,{variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,B.jsx)(G,{}),e?r.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(oe,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>a(`new`)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=m(e.id);return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,Dn[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,B.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(ue,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),onClick:()=>{f(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,B.jsx)(A,{label:`Loading profiles…`}),i&&(0,B.jsx)(Nn,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,B.jsx)(Ft,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:p,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`Existing sessions keep their snapshot of this profile. Projects that use it as their default must be changed first.`})})]})}function Nn({profile:e,onClose:t}){let n=(0,z.useId)(),[r,i]=(0,z.useState)(e?.name??``),[a,o]=(0,z.useState)(e?.provider??``),[s,c]=(0,z.useState)(e?.model??``),[l,u]=(0,z.useState)(e?.thinking??``),[d,f]=(0,z.useState)(e?.projectTrust??`ask`),[p,h]=(0,z.useState)(e?.resources??`all`),[g,_]=(0,z.useState)((e?.extraArgs??[]).join(`
|
|
5
|
-
`)),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(null),T=kt(g),E=jn(T),O=y&&!r.trim()?`Enter a profile name.`:null,k=E.length?E.join(`
|
|
6
|
-
`):null,A=async n=>{if(n.preventDefault(),b(!0),!r.trim()||E.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:d,resources:p,extraArgs:T};S(!0),w(null);try{e?(await m(`/api/profiles/${encodeURIComponent(e.id)}`,i),I.success(`Profile ${i.name} saved`)):(await v(`/api/profiles`,i),I.success(`Profile ${i.name} created`)),t()}catch(e){w(e)}finally{S(!1)}},j=`${n}-form`;return(0,B.jsx)(R,{open:!0,onClose:x?()=>void 0:t,dismissOnBackdrop:!x,title:e?`Edit ${e.name}`:`New profile`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:t,disabled:x,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:j,variant:`primary`,busy:x,children:e?`Save profile`:`Create profile`})]}),children:(0,B.jsxs)(`form`,{id:j,className:`flex min-w-0 flex-col gap-4`,onSubmit:A,noValidate:!0,children:[(0,B.jsx)(J,{id:`${n}-name`,label:`Name`,error:O,children:(0,B.jsx)(L,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...Y(`${n}-name`,{error:O})})}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,B.jsx)(L,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-provider`,{hint:!0})})}),(0,B.jsx)(J,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,B.jsx)(L,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-model`,{hint:!0})})})]}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${n}-thinking`,label:`Thinking`,children:(0,B.jsxs)(X,{id:`${n}-thinking`,value:l,onChange:e=>u(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Default (none)`}),kn.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})}),(0,B.jsx)(J,{id:`${n}-trust`,label:`Project trust`,hint:On[d],children:(0,B.jsx)(X,{id:`${n}-trust`,value:d,onChange:e=>f(e.target.value),...Y(`${n}-trust`,{hint:!0}),children:Object.keys(Dn).map(e=>(0,B.jsx)(`option`,{value:e,children:Dn[e]},e))})})]}),(0,B.jsx)(J,{id:`${n}-resources`,label:`Resources`,hint:An[p],children:(0,B.jsxs)(X,{id:`${n}-resources`,value:p,onChange:e=>h(e.target.value),...Y(`${n}-resources`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,B.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,B.jsx)(J,{id:`${n}-extra`,label:`Extra Pi arguments`,hint:`One long flag per line, e.g. --max-turns=40. Session, mode and extension flags are managed by Switchyard.`,error:k,children:(0,B.jsx)(ke,{id:`${n}-extra`,value:g,minRows:3,onChange:e=>_(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...Y(`${n}-extra`,{hint:!0,error:k})})}),(0,B.jsx)(Z,{error:C})]})})}var Pn={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},Fn={none:{icon:_e,label:`No setup`,tone:`neutral`},running:{icon:ge,label:`Setup running`,tone:`info`},succeeded:{icon:F,label:`Setup succeeded`,tone:`success`},failed:{icon:me,label:`Setup failed`,tone:`danger`}};function In(e){let t=[e.dirty?`Uncommitted changes (${e.changedFiles} file${e.changedFiles===1?``:`s`})`:`Clean`];return(e.ahead||e.behind)&&t.push(`${e.ahead} ahead, ${e.behind} behind`),t.push(e.unmerged?`Not merged into base`:`Merged`),t.join(` · `)}function Ln({project:e}){let t=h(e=>e.workspaces),n=h(e=>e.hosts),r=(0,z.useMemo)(()=>Object.values(t).filter(t=>t.projectId===e.id&&t.archivedAt===null).sort((e,t)=>Number(t.provenance===`main`)-Number(e.provenance===`main`)||(e.branch??``).localeCompare(t.branch??``)),[t,e.id]),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=async e=>{s(e.id);try{await v(`/api/workspaces/${encodeURIComponent(e.id)}/refresh`),I.success(`Workspace status refreshed`)}catch(e){I.error(`Could not refresh: ${b(e)}`)}finally{s(null)}};return(0,B.jsxs)(U,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[r.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:r.map(e=>{let t=n[e.hostId],r=t?.connectivity!==`connected`,i=Fn[e.setup.state]??Fn.none;return(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(le,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,B.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,B.jsx)(`span`,{className:`text-xs text-muted`,children:Pn[e.provenance]})]}),(0,B.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{children:In(e.git)}),(0,B.jsx)(q,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(x,{className:`size-4`}),busy:o===e.id,disabled:r,onClick:()=>c(e),children:`Refresh status`}),e.provenance!==`main`&&(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),disabled:r,onClick:()=>a(e),children:`Remove`}),e.provenance===`main`&&(0,B.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),r&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Host `,t?.name??`unknown`,` is `,t?.connectivity??`unknown`,`: refresh and removal need it online.`]})]})]},e.id)})}),i&&(0,B.jsx)(Rn,{workspace:t[i.id]??i,onClose:()=>a(null)},i.id)]})}function Rn({workspace:e,onClose:t}){let[n,r]=(0,z.useState)(e.git.dirty),[i,a]=(0,z.useState)(e.git.unmerged),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),[f,m]=(0,z.useState)(null),h=n&&!o||i&&!c;return(0,B.jsxs)(Ft,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:f,onConfirm:async()=>{d(!0),m(null);try{await v(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),I.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){p(e,`workspace_dirty`)&&r(!0),p(e,`workspace_unmerged`)&&a(!0),m(e)}finally{d(!1)}},confirmDisabled:h,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,B.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,B.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,B.jsx)(Et,{label:`Discard uncommitted changes`,description:e.git.dirty?`${e.git.changedFiles} changed file${e.git.changedFiles===1?``:`s`} will be lost.`:`The host reported uncommitted changes; they will be lost.`,checked:o,onChange:s}),i&&(0,B.jsx)(Et,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var zn=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function Bn(e){let t=e.trim();return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.includes(`\\`)?`Use a relative path inside the repository, e.g. .worktrees.`:t.split(`/`).includes(`..`)?`The folder must stay inside the repository (no ..).`:Fe.safeParse(t).success?null:`Use a plain relative path such as .worktrees (no empty or . segments).`:`Enter a folder inside the repository, e.g. .worktrees.`}function Vn(){let{projectId:e=``}=s(),t=K(),n=h(t=>t.projects[e]),r=h(e=>e.hosts),i=h(e=>e.profiles),[a,o]=(0,z.useState)(!1),[c,l]=(0,z.useState)([]),u=f(),d=(0,z.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),p={to:V(`projects`),label:`Projects`};return t?n?(0,B.jsxs)(H,{title:n.name,description:(0,B.jsx)(`span`,{className:`break-all`,children:n.repoIdentity}),back:p,actions:(0,B.jsx)(D,{busy:a,icon:(0,B.jsx)(x,{className:`size-4`}),onClick:async()=>{o(!0);try{let e=await v(`/api/projects/${encodeURIComponent(n.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];l(t),t.length?I.error(`Refreshed with ${t.length} checkout error(s)`):I.success(`Workspaces refreshed`)}catch(e){I.error(`Refresh failed: ${b(e)}`)}finally{o(!1)}},children:`Refresh`}),children:[(0,B.jsx)(G,{}),c&&c.length>0&&(0,B.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,B.jsx)(`ul`,{className:`list-disc pl-5`,children:c.map(e=>(0,B.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,B.jsx)(Hn,{project:n,hosts:u,profiles:d},n.id),(0,B.jsx)(Un,{project:n,hosts:u,hostsById:r}),(0,B.jsx)(Ln,{project:n})]}):(0,B.jsx)(H,{title:`Project`,back:p,children:(0,B.jsx)(N,{icon:(0,B.jsx)(ae,{className:`size-8`}),title:`Project not found`,description:`It may have been removed, or this link is from another coordinator.`,action:{label:`Back to projects`,to:V(`projects`)}})}):(0,B.jsx)(H,{title:`Project`,back:p,children:(0,B.jsx)(A,{label:`Loading project…`})})}function Hn({project:e,hosts:t,profiles:n}){let r=(0,z.useId)(),[i,a]=(0,z.useState)(e.name),[o,s]=(0,z.useState)(e.setupCommand??``),[c,l]=(0,z.useState)(e.checks.join(`
|
|
7
|
-
`)),[u,d]=(0,z.useState)(String(e.maxConcurrentRuns)),[f,p]=(0,z.useState)(e.automationEnabled),[h,g]=(0,z.useState)(e.workspaceSharing),[_,v]=(0,z.useState)(e.defaultProfileId??``),[y,b]=(0,z.useState)(e.defaultHostId??``),[x,S]=(0,z.useState)(e.worktreeDir??`.worktrees`),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(null),O=Number(u),k=i.trim()?null:`Enter a project name.`,A=Number.isInteger(O)&&O>=1&&O<=32?null:`Use a whole number from 1 to 32.`,j=Bn(x),M=async t=>{if(t.preventDefault(),!(k||A||j)){w(!0),E(null);try{await m(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:kt(c),maxConcurrentRuns:O,automationEnabled:f,workspaceSharing:h,defaultProfileId:_||null,defaultHostId:y||null,worktreeDir:x.trim()}),I.success(`Project settings saved`)}catch(e){E(e)}finally{w(!1)}}},N=!y||t.some(e=>e.id===y),ee=!_||n.some(e=>e.id===_);return(0,B.jsx)(U,{title:`Project settings`,children:(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:M,noValidate:!0,children:[(0,B.jsx)(J,{id:`${r}-name`,label:`Name`,error:k,children:(0,B.jsx)(L,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...Y(`${r}-name`,{error:k})})}),(0,B.jsx)(J,{id:`${r}-setup`,label:`Setup command`,hint:`Runs in each new workspace before the first session, e.g. pnpm install. Leave empty for none.`,children:(0,B.jsx)(L,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...Y(`${r}-setup`,{hint:!0})})}),(0,B.jsx)(J,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,B.jsx)(ke,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...Y(`${r}-checks`,{hint:!0})})}),(0,B.jsx)(J,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:A,children:(0,B.jsx)(L,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:u,onChange:e=>d(e.target.value),className:`max-w-32`,...Y(`${r}-runs`,{hint:!0,error:A})})}),(0,B.jsx)(J,{id:`${r}-worktree`,label:`Worktree folder`,hint:zn,error:j,children:(0,B.jsx)(L,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:x,onChange:e=>S(e.target.value),placeholder:`.worktrees`,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...Y(`${r}-worktree`,{hint:!0,error:j})})}),(0,B.jsx)(Tt,{label:`Automation`,description:`When off, ready tasks in this project wait instead of starting automatically.`,checked:f,onChange:p}),(0,B.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Only one run or session writes in a workspace at a time; others wait. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:h===e,onChange:()=>g(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,B.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:t}),(0,B.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,B.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(J,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,B.jsxs)(X,{id:`${r}-profile`,value:_,onChange:e=>v(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id)),!ee&&(0,B.jsxs)(`option`,{value:_,children:[`Unknown profile (`,_,`)`]})]})}),(0,B.jsx)(J,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,B.jsxs)(X,{id:`${r}-host`,value:y,onChange:e=>b(e.target.value),...Y(`${r}-host`,{hint:!0}),children:[(0,B.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!N&&(0,B.jsxs)(`option`,{value:y,children:[`Unknown host (`,y,`)`]})]})})]}),(0,B.jsx)(Z,{error:T}),(0,B.jsx)(`div`,{children:(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:C,icon:(0,B.jsx)(fe,{className:`size-4`}),children:`Save project`})})]})})}function Un({project:e,hosts:t,hostsById:n}){let r=h(e=>e.checkouts),i=(0,z.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,z.useState)(!1);return(0,B.jsxs)(U,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,B.jsx)(D,{size:`sm`,icon:(0,B.jsx)(P,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,B.jsx)(N,{className:`py-4`,title:`No checkouts`,description:`Add a checkout so sessions and runs have somewhere to work.`,action:{label:`Add checkout`,onClick:()=>o(!0)}}):(0,B.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,B.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,B.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,B.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,B.jsx)(Wn,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Wn({open:e,onClose:t,project:n,hosts:r}){let i=(0,z.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),g=o||a[0]?.id||``,_=u||c?Dt(c):null,y=()=>{f||(d(!1),h(null),t())},b=async e=>{if(e.preventDefault(),d(!0),g&&!Dt(c)){p(!0),h(null);try{await v(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:g,path:c.trim()}),I.success(`Checkout added`),l(``),d(!1),t()}catch(e){h(e)}finally{p(!1)}}},x=`${i}-form`;return(0,B.jsx)(R,{open:e,onClose:y,dismissOnBackdrop:!f,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:y,disabled:f,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:x,variant:`primary`,busy:f,disabled:a.length===0,children:`Add checkout`})]}),children:(0,B.jsxs)(`form`,{id:x,className:`flex min-w-0 flex-col gap-4`,onSubmit:b,noValidate:!0,children:[a.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No host is connected. The checkout is inspected on its host, so the host must be online.`}),(0,B.jsx)(J,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,B.jsxs)(X,{id:`${i}-host`,value:g,onChange:e=>s(e.target.value),disabled:a.length===0,...Y(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,B.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(J,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:_,children:(0,B.jsx)(L,{id:`${i}-path`,value:c,onChange:e=>l(e.target.value),placeholder:`/Users/me/src/app`,className:`font-mono`,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,...Y(`${i}-path`,{hint:!0,error:_})})}),(0,B.jsx)(Z,{error:m})]})})}var Gn=e=>V(`projects/${encodeURIComponent(e)}`);function Kn(){let e=K(),t=u(),n=h(e=>e.checkouts),i=h(e=>e.workspaces),a=(0,z.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(n))t(e.projectId).checkouts++;for(let e of Object.values(i))e.archivedAt||t(e.projectId).workspaces++;return e},[n,i]);return(0,B.jsxs)(H,{testId:`settings-projects`,title:`Projects`,description:`A project is one repository. It can have checkouts on several hosts. Repositories in a host's project folders are added automatically.`,actions:(0,B.jsxs)(r,{to:V(`projects/new`),className:C(`primary`),children:[(0,B.jsx)(P,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,B.jsx)(G,{}),e?t.length===0?(0,B.jsx)(N,{icon:(0,B.jsx)(ae,{className:`size-8`}),title:`No projects yet`,description:`Create a project from a Git checkout on one of your hosts.`,action:{label:`New project`,to:V(`projects/new`)}}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsx)(qn,{project:e,counts:a[e.id]})},e.id))}):(0,B.jsx)(A,{label:`Loading projects…`})]})}function qn({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,B.jsxs)(r,{to:Gn(e.id),className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,B.jsx)(ae,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,B.jsx)(`span`,{className:`break-all text-xs text-muted`,children:e.repoIdentity}),(0,B.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 text-xs text-muted`,children:[(0,B.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,B.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),(0,B.jsxs)(`span`,{children:[`Automation `,e.automationEnabled?`on`:`off`]})]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function Jn(){let e=K(),t=f(),i=h(e=>e.profiles),a=(0,z.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),o=t.filter(e=>e.connectivity===`connected`),s=n(),c=(0,z.useId)(),[l,u]=(0,z.useState)(``),[d,p]=(0,z.useState)(``),[m,g]=(0,z.useState)(``),[_,y]=(0,z.useState)(``),[b,x]=(0,z.useState)(`.worktrees`),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(!1),[O,k]=(0,z.useState)(null),j=d||o[0]?.id||``,M=C&&!l.trim()?`Enter a project name.`:null,N=C&&!j?`Choose a connected host.`:null,ee=C||m?Dt(m):null,te=Bn(b),ne=async e=>{if(e.preventDefault(),w(!0),l.trim()&&j&&!Dt(m)&&!te){E(!0),k(null);try{let e=await v(`/api/projects`,{name:l.trim(),hostId:j,path:m.trim(),defaultProfileId:_||null,worktreeDir:b.trim()});I.success(`Project ${l.trim()} created`),s(e?.id?Gn(e.id):V(`projects`))}catch(e){k(e)}finally{E(!1)}}},re={to:V(`projects`),label:`Projects`};return e?(0,B.jsxs)(H,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:re,children:[o.length===0&&(0,B.jsx)(S,{capability:`Creating a project`,reason:t.length===0?`No hosts are enrolled. Add a host first.`:`No host is connected. The checkout is inspected on its host, so the host must be online.`,fallback:(0,B.jsx)(r,{to:V(`hosts`),className:`font-medium text-accent`,children:`Open hosts`})}),(0,B.jsx)(U,{children:(0,B.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:ne,noValidate:!0,children:[(0,B.jsx)(J,{id:`${c}-name`,label:`Name`,error:M,children:(0,B.jsx)(L,{id:`${c}-name`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`,...Y(`${c}-name`,{error:M})})}),(0,B.jsx)(J,{id:`${c}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:N,children:(0,B.jsxs)(X,{id:`${c}-host`,value:j,onChange:e=>p(e.target.value),disabled:o.length===0,...Y(`${c}-host`,{hint:!0,error:N}),children:[o.length===0&&(0,B.jsx)(`option`,{value:``,children:`No connected hosts`}),o.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(J,{id:`${c}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:ee,children:(0,B.jsx)(L,{id:`${c}-path`,value:m,onChange:e=>g(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...Y(`${c}-path`,{hint:!0,error:ee})})}),(0,B.jsx)(J,{id:`${c}-worktree`,label:`Worktree folder`,hint:zn,error:te,children:(0,B.jsx)(L,{id:`${c}-worktree`,value:b,onChange:e=>x(e.target.value),placeholder:`.worktrees`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...Y(`${c}-worktree`,{hint:!0,error:te})})}),(0,B.jsx)(J,{id:`${c}-profile`,label:`Default Pi profile (optional)`,children:(0,B.jsxs)(X,{id:`${c}-profile`,value:_,onChange:e=>y(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`None`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,B.jsx)(Z,{error:O}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(D,{type:`submit`,variant:`primary`,busy:T,icon:(0,B.jsx)($e,{className:`size-4`}),disabled:o.length===0,children:`Create project`}),o.length===0&&(0,B.jsx)(q,{icon:$e,label:`Needs a connected host`})]})]})})]}):(0,B.jsx)(H,{title:`New project`,back:re,children:(0,B.jsx)(A,{})})}function Yn(){let e=Lt(`/api/auth/methods`,Ot),[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(null),g=async()=>{if(r){o(!0),c(null);try{await d(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),I.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},_=async()=>{p(!0),h(null);try{await v(`/api/logout`),u(!1),he(null)}catch(e){h(e)}finally{p(!1)}},y=e.data,b=y?.passkeyAvailability,x=Ie(),S=y?b?.available?x?null:`This browser does not support passkeys.`:b?.reason??`Passkeys are not available on this server.`:null;return(0,B.jsxs)(H,{testId:`settings-signin`,title:`Sign-in`,description:`How you sign in to Switchyard on new devices. Each signed-in device keeps its own revocable credential.`,children:[(0,B.jsx)(G,{}),e.loading&&!y?(0,B.jsx)(A,{label:`Loading sign-in methods…`}):e.error&&!y?(0,B.jsx)(k,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):y?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{title:`Passkeys`,description:`Sign in on any device with its fingerprint, face or screen lock. Passkeys are stored on this server only as public keys.`,actions:(0,B.jsx)(D,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,B.jsx)(P,{className:`size-4`}),disabled:S!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[S&&(0,B.jsxs)(`p`,{role:`status`,className:`mb-3 flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-sm`,children:[(0,B.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,S]})]}),y.passkeys.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one so your other devices can sign in without a link.`}):(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:y.passkeys.map(e=>(0,B.jsxs)(`li`,{"data-testid":`passkey-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2 last:border-b-0`,children:[(0,B.jsx)(de,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,B.jsxs)(`span`,{children:[`Added `,j(e.createdAt)]}),(0,B.jsxs)(`span`,{children:[`Last used `,j(e.lastUsedAt)]})]})]}),(0,B.jsx)(D,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,B.jsx)(pe,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,B.jsx)(U,{title:`Single sign-on`,description:`Configured on the server`,children:y.oidc?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(W,{items:[[`Button label`,y.oidc.label],[`Provider`,(0,B.jsx)(`span`,{className:`break-all`,children:y.oidc.issuer},`i`)],[`Allowed account`,y.oidc.ownerMatch],[`Status`,y.oidc.status===`ready`?(0,B.jsx)(q,{icon:F,tone:`success`,label:`Ready`},`s`):(0,B.jsx)(q,{icon:w,tone:`danger`,label:`Error`},`s`)]]}),y.oidc.status===`error`&&y.oidc.error&&(0,B.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:y.oidc.error})]}):(0,B.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,B.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,B.jsx)(U,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Devices to cut it off.`,children:(0,B.jsx)(D,{icon:(0,B.jsx)(st,{className:`size-4`}),onClick:()=>{h(null),u(!0)},children:`Sign out of this device`})}),(0,B.jsx)(Xn,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,B.jsx)(Ft,{open:r!==null,onClose:()=>i(null),title:r?`Remove passkey ${r.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:a,error:s,onConfirm:g,children:(0,B.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,y&&y.passkeys.length===1&&!y.oidc?` It is your only passkey and no single sign-on is set up: afterwards new devices need a pairing link.`:``]})}),(0,B.jsx)(Ft,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:f,error:m,onConfirm:_,children:(0,B.jsx)(`p`,{className:`text-sm`,children:`You will need a passkey, single sign-on or a pairing link to sign in here again.`})})]})}function Xn({open:e,onClose:t,onAdded:n}){let r=(0,z.useId)(),[i,a]=(0,z.useState)(()=>We()),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null),u=i.trim()?null:`Enter a name for this passkey.`,d=()=>{o||(l(null),t())},f=async e=>{if(e.preventDefault(),!u){s(!0),l(null);try{let{challengeId:e,options:t}=await v(`/api/auth/passkeys/register/options`),r=await Be({optionsJSON:t});await v(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:r}),I.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was cancelled or timed out. Try again.`):e instanceof Error?e:Error(b(e)))}finally{s(!1)}}},p=`${r}-form`;return(0,B.jsx)(R,{open:e,onClose:d,dismissOnBackdrop:!o,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{onClick:d,disabled:o,children:`Cancel`}),(0,B.jsx)(D,{type:`submit`,form:p,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,B.jsxs)(`form`,{id:p,className:`flex min-w-0 flex-col gap-4`,onSubmit:f,noValidate:!0,children:[(0,B.jsx)(J,{id:`${r}-name`,label:`Passkey name`,error:u,children:(0,B.jsx)(L,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...Y(`${r}-name`,{error:u})})}),(0,B.jsx)(Z,{error:c})]})})}function Zn(){let e=Te(),n=e===`mobile`,r=(0,B.jsxs)(i,{children:[(0,B.jsx)(t,{index:!0,element:n?(0,B.jsx)(nr,{}):(0,B.jsx)(tr,{})}),(0,B.jsx)(t,{path:`hosts`,element:(0,B.jsx)(mn,{})}),(0,B.jsx)(t,{path:`hosts/:hostId`,element:(0,B.jsx)(yn,{})}),(0,B.jsx)(t,{path:`devices`,element:(0,B.jsx)(on,{})}),(0,B.jsx)(t,{path:`sign-in`,element:(0,B.jsx)(Yn,{})}),(0,B.jsx)(t,{path:`projects`,element:(0,B.jsx)(Kn,{})}),(0,B.jsx)(t,{path:`projects/new`,element:(0,B.jsx)(Jn,{})}),(0,B.jsx)(t,{path:`projects/:projectId`,element:(0,B.jsx)(Vn,{})}),(0,B.jsx)(t,{path:`profiles`,element:(0,B.jsx)(Mn,{})}),(0,B.jsx)(t,{path:`adapters`,element:(0,B.jsx)(Wt,{})}),(0,B.jsx)(t,{path:`notifications`,element:(0,B.jsx)(Cn,{})}),(0,B.jsx)(t,{path:`backups`,element:(0,B.jsx)(Qt,{})}),(0,B.jsx)(t,{path:`diagnostics`,element:(0,B.jsx)(ln,{})}),(0,B.jsx)(t,{path:`device`,element:(0,B.jsx)(cn,{})}),(0,B.jsx)(t,{path:`*`,element:(0,B.jsx)(rr,{})})]});return n?(0,B.jsx)(`div`,{className:`min-w-0`,children:r}):(0,B.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,B.jsx)($n,{compact:e===`compact`}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:r})]})}function Qn(){let{pathname:e}=l(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function $n({compact:e}){let t=Qn();return(0,B.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,className:T(`sticky top-0 flex max-h-dvh shrink-0 flex-col gap-1 self-start overflow-y-auto border-r border-border px-2 py-4`,e?`w-52`:`w-60`),children:[(0,B.jsx)(r,{to:V(),"aria-current":t===null?`page`:void 0,className:T(`tap mb-2 rounded-md px-3 py-1 text-base font-semibold`,t===null?`bg-accent-soft`:`hover:bg-surface-2`),children:`Settings`}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:St.map(({path:e,label:n,icon:i})=>{let a=t===e;return(0,B.jsx)(`li`,{children:(0,B.jsxs)(r,{to:V(e),"aria-current":a?`page`:void 0,className:T(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,a?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,B.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]})}function er(){let e=h(e=>e.hosts),t=h(e=>e.devices),n=h(e=>e.projects),r=h(e=>e.profiles),i=h(e=>e.adapters),a=h(e=>e.hydrated);return(0,z.useMemo)(()=>{if(!a)return{};let o=Object.values(e).filter(e=>e.revokedAt===null),s=o.filter(e=>e.connectivity===`connected`).length,c=Object.values(i).reduce((e,t)=>e+t.length,0),l=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${l(o.length,`host`)}, ${s} connected`,devices:l(Object.values(t).filter(e=>e.revokedAt===null).length,`device`),projects:l(Object.keys(n).length,`project`),profiles:l(Object.keys(r).length,`profile`),adapters:l(c,`adapter`)}},[e,t,n,r,i,a])}function tr(){let e=er();return(0,B.jsxs)(H,{title:`Settings`,description:`Configure Switchyard and check its health.`,children:[(0,B.jsx)(G,{}),(0,B.jsx)(`ul`,{className:`grid min-w-0 gap-3 lg:grid-cols-2`,children:St.map(({path:t,label:n,description:i,icon:a})=>(0,B.jsx)(`li`,{className:`min-w-0`,children:(0,B.jsxs)(r,{to:V(t),className:`tap flex h-full min-w-0 items-start gap-3 rounded-lg border border-border bg-surface p-4 hover:bg-surface-2`,children:[(0,B.jsx)(a,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),(0,B.jsx)(`span`,{className:`block text-sm text-muted`,children:i}),e[t]&&(0,B.jsx)(`span`,{className:`mt-1 block text-xs text-subtle`,children:e[t]})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-subtle`})]})},t))})]})}function nr(){let e=er();return(0,B.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,B.jsx)(G,{}),(0,B.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,children:(0,B.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:St.map(({path:t,label:n,description:i,icon:a})=>(0,B.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,B.jsxs)(r,{to:V(t),className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,B.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),(0,B.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??i})]}),(0,B.jsx)(se,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})})]})}function rr(){return(0,B.jsx)(N,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:V()}})}export{Zn as default};
|
|
8
|
-
//# sourceMappingURL=settings-Csal1F-W.js.map
|