nextclaw 0.19.24 → 0.19.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +19 -19
  2. package/ui-dist/assets/{api-CKKNxbsy.js → api-rASx2-N4.js} +1 -1
  3. package/ui-dist/assets/{app-manager-provider-BM1hziPv.js → app-manager-provider-CUkcbdWk.js} +1 -1
  4. package/ui-dist/assets/{channels-list-page-GD_IBCbY.js → channels-list-page-CE_9jne_.js} +1 -1
  5. package/ui-dist/assets/{chat-page-Ty6QH2Tc.js → chat-page-BMJLtk3O.js} +1 -1
  6. package/ui-dist/assets/cpu-DKc3bQic.js +3 -0
  7. package/ui-dist/assets/desktop-DJpQzxsz.js +3 -0
  8. package/ui-dist/assets/{desktop-update-config-jWt63bXG.js → desktop-update-config-DAD9JN9Q.js} +1 -1
  9. package/ui-dist/assets/{dialog-DWZeMf9V.js → dialog-CR80q3Rm.js} +1 -1
  10. package/ui-dist/assets/{dist-DN-YM_0Y.js → dist-NBjcwlsw.js} +1 -1
  11. package/ui-dist/assets/doc-browser-B19cYGxa.js +1 -0
  12. package/ui-dist/assets/{doc-browser-CAhfnm0D.js → doc-browser-CDBYvb8A.js} +1 -1
  13. package/ui-dist/assets/doc-browser-IRh6LCzu.js +1 -0
  14. package/ui-dist/assets/{doc-browser-context-FukQHvyo.js → doc-browser-context-BPeeiNJ_.js} +1 -1
  15. package/ui-dist/assets/{es2015-ZJ-nWL4L.js → es2015-CVAuMqlM.js} +1 -1
  16. package/ui-dist/assets/index-BEn7o-oH.js +100 -0
  17. package/ui-dist/assets/index-DV57tBmg.css +1 -0
  18. package/ui-dist/assets/{marketplace-page-DzwJTbAg.js → marketplace-page-B3Q_uKOZ.js} +2 -2
  19. package/ui-dist/assets/marketplace-page-CCq1bFb1.js +1 -0
  20. package/ui-dist/assets/{mcp-marketplace-page-BUMkGb6q.js → mcp-marketplace-page-D9maE_Sf.js} +1 -1
  21. package/ui-dist/assets/mcp-marketplace-page-O5AQzBYl.js +1 -0
  22. package/ui-dist/assets/{model-config-Cgiw7ejv.js → model-config-BsEQYJvz.js} +1 -1
  23. package/ui-dist/assets/{notice-card-BM2_YNoc.js → notice-card-CF4AJPM3.js} +1 -1
  24. package/ui-dist/assets/{popover-2H9DS7Cv.js → popover-DeAliE_4.js} +1 -1
  25. package/ui-dist/assets/{provider-scoped-model-input-DsZJ44ZV.js → provider-scoped-model-input-B8LJ6RCt.js} +1 -1
  26. package/ui-dist/assets/{providers-list-BrViWRyR.js → providers-list-5mA-2zno.js} +1 -1
  27. package/ui-dist/assets/remote-DiPWGRZc.js +1 -0
  28. package/ui-dist/assets/runtime-config-page-BSoKMvCh.js +1 -0
  29. package/ui-dist/assets/{search-config-Deb56TtE.js → search-config-DxWm2GrK.js} +1 -1
  30. package/ui-dist/assets/{secrets-config-JJkgNCnO.js → secrets-config-qutTAlFx.js} +1 -1
  31. package/ui-dist/assets/{select-C2c10F3e.js → select-HI5kiwX_.js} +1 -1
  32. package/ui-dist/assets/{setting-row-CB_ZFbIZ.js → setting-row-B4QnghjV.js} +1 -1
  33. package/ui-dist/assets/{tag-chip-CrQfVN3A.js → tag-chip-BPgMfp9l.js} +1 -1
  34. package/ui-dist/assets/{use-config-jAYudJxy.js → use-config-BFqzVF8Y.js} +1 -1
  35. package/ui-dist/assets/{use-infinite-scroll-loader-B97V1Ywd.js → use-infinite-scroll-loader-CyNa4Vj6.js} +1 -1
  36. package/ui-dist/index.html +18 -18
  37. package/ui-dist/assets/cpu-DPPwMzoC.js +0 -3
  38. package/ui-dist/assets/desktop-BwONApN9.js +0 -3
  39. package/ui-dist/assets/doc-browser-p9DDNPWB.js +0 -1
  40. package/ui-dist/assets/doc-browser-rZIQIjuw.js +0 -1
  41. package/ui-dist/assets/index-B7CVI2ys.css +0 -1
  42. package/ui-dist/assets/index-SS1xPoWD.js +0 -100
  43. package/ui-dist/assets/marketplace-page-DZEljaFz.js +0 -1
  44. package/ui-dist/assets/mcp-marketplace-page-NfOsALIL.js +0 -1
  45. package/ui-dist/assets/remote-Dm6hKGew.js +0 -1
  46. package/ui-dist/assets/runtime-config-page-CvvW9VBj.js +0 -1
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,r,t as i}from"./i18n-D1144VAA.js";import{At as a,Dt as o,Et as s,Ft as c,Lt as l,Mt as u,Nt as d,Ot as f,Tt as p,a as m,bt as h,c as g,dt as _,i as ee,jt as te,kt as v,l as y,o as ne,r as b,s as re,u as x,wt as S,zt as C}from"./api-CKKNxbsy.js";import{a as w,n as T,o as ie,r as E,t as ae}from"./dialog-DWZeMf9V.js";import{t as D}from"./createLucideIcon-DzY6wN61.js";import{t as O}from"./key-round-DUq47t0P.js";import{t as k}from"./notice-card-BM2_YNoc.js";import{t as A}from"./status-dot-l3kPFdq_.js";var oe=D(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),se=D(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),j=D(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),M=D(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]);function N(){return C({queryKey:L,queryFn:m,staleTime:5e3,refetchOnWindowFocus:!0})}var P=e(t(),1),F=n();function I(e){let{label:t,muted:n,value:r}=e;return(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,F.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,F.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function ce(){let e=$(),t=N(),n=t.data,c=W(e=>e.actionLabel),l=(0,P.useMemo)(()=>J(n),[n]),u=!!c,m=n?.runtime?.deviceName?.trim()||n?.settings.deviceName?.trim()||r(`remoteDeviceNameAuto`),h=!!(n?.account.loggedIn&&U(n)),{hero:g,issueHint:_}=l;return(0,P.useEffect)(()=>{e.remoteAccessManager.syncStatus(n)},[e,n]),t.isLoading&&!n?(0,F.jsx)(`div`,{className:`p-8 text-gray-400`,children:r(`remoteLoading`)}):(0,F.jsxs)(a,{className:`space-y-6`,children:[(0,F.jsx)(v,{title:r(`remotePageTitle`),description:r(`remotePageDescription`)}),(0,F.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,F.jsxs)(S,{children:[(0,F.jsxs)(o,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsx)(f,{children:g.title}),(0,F.jsx)(A,{status:g.badgeStatus,label:g.badgeLabel})]}),(0,F.jsx)(s,{children:g.description})]}),(0,F.jsxs)(p,{className:`space-y-5`,children:[(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(I,{label:r(`remoteSignedInAccount`),value:n?.account.email}),(0,F.jsx)(I,{label:r(`remoteDeviceName`),value:m}),(0,F.jsx)(I,{label:r(`remoteConnectionStatus`),value:g.badgeLabel}),(0,F.jsx)(I,{label:r(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?i(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[l.primaryAction?(0,F.jsxs)(d,{onClick:()=>{if(l.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(n);return}if(l.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(n);return}e.remoteAccessManager.enableRemoteAccess(n)},disabled:u,children:[l.primaryAction.showRefreshIcon?(0,F.jsx)(j,{className:`mr-2 h-4 w-4`}):null,c||l.primaryAction.label]}):null,(0,F.jsxs)(d,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:u||!h,children:[(0,F.jsx)(M,{className:`mr-2 h-4 w-4`}),r(`remoteOpenDeviceList`)]}),n?.settings.enabled?(0,F.jsx)(d,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(n),disabled:u,children:r(`remoteDisable`)}):null]}),l.shouldShowIssueHint&&_?(0,F.jsx)(k,{tone:`warning`,title:_.title,description:_.body}):null,(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`remoteOpenWebHint`)})]})]}),(0,F.jsxs)(S,{children:[(0,F.jsxs)(o,{children:[(0,F.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,F.jsx)(oe,{className:`h-4 w-4 text-primary`}),r(`remoteDeviceSectionTitle`)]}),(0,F.jsx)(s,{children:r(`remoteDeviceSectionDescription`)})]}),(0,F.jsxs)(p,{className:`space-y-5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(A,{status:n?.account.loggedIn?`ready`:`inactive`,label:n?.account.loggedIn?r(`remoteAccountConnected`):r(`remoteAccountNotConnected`)}),(0,F.jsx)(A,{status:n?.settings.enabled?`active`:`inactive`,label:n?.settings.enabled?r(`remoteEnabled`):r(`remoteStateDisabled`)}),(0,F.jsx)(A,{status:n?.service.running?`active`:`inactive`,label:n?.service.running?r(`remoteServiceRunning`):r(`remoteServiceStopped`)})]}),(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(I,{label:r(`remoteDeviceName`),value:m}),(0,F.jsx)(I,{label:r(`remoteConnectionStatus`),value:g.badgeLabel}),(0,F.jsx)(I,{label:r(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?i(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,F.jsx)(k,{tone:`neutral`,borderStyle:`dashed`,description:n?.account.loggedIn?r(`remoteOpenWebHint`):r(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var L=[`remote-status`],le=`https://platform.nextclaw.io`,R=`https://nextclaw-platform-console.pages.dev`,z=async()=>await c.fetchQuery({queryKey:L,queryFn:m,staleTime:5e3}),B=async()=>(await c.invalidateQueries({queryKey:L}),await z()),V=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function H(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return le;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return R}var U=e=>H(e?.account.apiBase)||H(e?.settings.platformApiBase)||H(e?.platformBase)||H(e?.account.platformBase)||void 0,W=h(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),G=class{constructor(){this.accountManager=null,this.bindAccountManager=e=>{this.accountManager=e},this.syncStatus=e=>{if(!e)return;let t=W.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{W.getState().setEnabled(e)},this.setDeviceName=e=>{W.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{W.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{W.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await B(),n=W.getState();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`},apiBase:n.platformApiBase});return}await this.applyEnabledState(!0,t)},this.disableRemoteAccess=async e=>{let t=e??await B();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await B();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`}});return}let n=t.service.running?`restart`:`start`;await this.runManagedAction({actionLabel:r(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await b(n);let e=await B();this.hydrateDraftFromStatus(e)},successMessage:r(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await B();await this.accountManager?.startBrowserSignIn({status:t,apiBase:W.getState().platformApiBase,pendingAction:{type:`repair-remote`}})},this.saveAdvancedSettings=async e=>{let t=e??await B(),n=W.getState();await this.runManagedAction({actionLabel:r(`remoteActionSavingAdvanced`),job:async()=>{await x({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await B();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?r(`remoteSettingsSaved`):r(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:r(`remoteDoctorRunning`),job:async()=>{let e=await ee();W.getState().setDoctor(e)},successMessage:r(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,r(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,r(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,r(`remoteActionStopping`))},this.resumePendingActionAfterSignIn=async(e,t)=>{if(e){if(e.type===`enable-remote`){await this.applyEnabledState(!0,t);return}e.type===`repair-remote`&&await this.repairRemoteAccess(t)}},this.applyEnabledState=async(e,t)=>{let n=W.getState();await this.runManagedAction({actionLabel:r(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await x({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await B();this.hydrateDraftFromStatus(r),e?await b(r.service.running?`restart`:`start`):t.service.running&&await b(`restart`);let i=await B();this.hydrateDraftFromStatus(i)},successMessage:r(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await b(e),n=await B();this.hydrateDraftFromStatus(n),l.success(t.message)}})},this.hydrateDraftFromStatus=e=>{W.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{W.getState().beginAction(e.actionLabel);try{await e.job(),e.successMessage&&l.success(e.successMessage)}catch(e){let t=e instanceof Error?e.message:r(`error`);throw l.error(t),e}finally{W.getState().finishAction()}}}},ue=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function K(e){return e?.runtime?.lastError?.trim()||``}function de(e){let t=r(`remoteStatusIssueDetailGeneric`),n=K(e);return n?`${t} (${n})`:t}function q(e){if(!e?.settings.enabled)return!1;let t=K(e);return ue.some(e=>e.test(t))}function J(e){return q(e)?{hero:{badgeStatus:`warning`,badgeLabel:r(`remoteStateReauthorizationRequired`),title:r(`remoteStatusReauthorizationTitle`),description:r(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:r(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:r(`remoteStatusRecoveryTitle`),body:r(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:r(`statusReady`),title:r(`remoteStatusReadyTitle`),description:r(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:r(`connecting`),title:r(`remoteStatusConnectingTitle`),description:r(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:r(`remoteStateDisconnected`),title:r(`remoteStatusIssueTitle`),description:r(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:r(`remoteStatusRecoveryTitle`),body:de(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:r(`remoteServiceStopped`),title:r(`remoteStatusNeedsServiceTitle`),description:r(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:r(`remoteStatusRecoveryTitle`),body:r(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:r(`statusInactive`),title:r(`remoteStatusNeedsEnable`),description:r(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:r(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:r(`statusSetup`),title:r(`remoteStatusNeedsSignIn`),description:r(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:r(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var Y=h(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,pendingAction:null,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),setPendingAction:t=>e({pendingAction:t}),clearPendingAction:()=>e({pendingAction:null}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function X({label:e,value:t}){return(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,F.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,F.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function fe(e){let{email:t,username:n,role:i,canSubmitUsername:a,savingUsername:o,usernameDraft:s,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:f,onLogout:p}=e;return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(k,{tone:`success`,title:r(`accountPanelSignedInTitle`),description:r(`accountPanelSignedInDescription`)}),(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(X,{label:r(`remoteAccountEmail`),value:t}),(0,F.jsx)(X,{label:r(`remoteAccountUsername`),value:n}),(0,F.jsx)(X,{label:r(`remoteAccountRole`),value:i})]}),n?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`remoteAccountUsernameLockedHelp`)}):(0,F.jsxs)(k,{tone:`warning`,title:r(`remoteAccountUsernameRequiredTitle`),description:r(`remoteAccountUsernameRequiredDescription`),children:[(0,F.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,F.jsx)(te,{htmlFor:`account-panel-username`,children:r(`remoteAccountUsername`)}),(0,F.jsx)(u,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:r(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,F.jsx)(d,{disabled:!a,onClick:()=>void l(),children:r(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsxs)(d,{onClick:()=>void f(),children:[(0,F.jsx)(M,{className:`mr-2 h-4 w-4`}),r(`remoteOpenDeviceList`)]}),(0,F.jsxs)(d,{variant:`outline`,onClick:()=>void p(),children:[(0,F.jsx)(se,{className:`mr-2 h-4 w-4`}),r(`remoteLogout`)]})]})]})}function pe(e){let{authSessionId:t,authExpiresAt:n,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(k,{tone:`neutral`,title:r(`accountPanelSignedOutTitle`),description:r(`accountPanelSignedOutDescription`),children:t?(0,F.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,F.jsx)(X,{label:r(`remoteBrowserAuthSession`),value:t}),(0,F.jsx)(X,{label:r(`remoteBrowserAuthExpiresAt`),value:n?i(n):`-`})]}):null}),a?(0,F.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsx)(d,{onClick:()=>void s(),children:r(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,F.jsx)(d,{variant:`outline`,onClick:c,children:r(`remoteBrowserAuthResume`)}):null]})]})}function me(){let e=$(),t=N(),n=Y(e=>e.panelOpen),i=Y(e=>e.authSessionId),a=Y(e=>e.authVerificationUri),o=Y(e=>e.authExpiresAt),s=Y(e=>e.authStatusMessage),c=t.data,[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(!1);(0,P.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,F.jsx)(ae,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,F.jsxs)(T,{className:`max-w-xl`,children:[(0,F.jsxs)(w,{children:[(0,F.jsxs)(ie,{className:`flex items-center gap-2`,children:[(0,F.jsx)(O,{className:`h-5 w-5 text-primary`}),r(`accountPanelTitle`)]}),(0,F.jsx)(E,{children:r(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,F.jsx)(fe,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,F.jsx)(pe,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function he({username:e}){let t=_(),[n,i]=(0,P.useState)(e??``),[a,c]=(0,P.useState)(``),l=n.trim().length>0&&a.length>0&&!t.isPending;return(0,F.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,F.jsxs)(S,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,F.jsxs)(o,{children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:r(`authBrand`)}),(0,F.jsx)(f,{className:`text-2xl`,children:r(`authLoginTitle`)}),(0,F.jsx)(s,{children:r(`authLoginDescription`)})]}),(0,F.jsx)(p,{children:(0,F.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),l&&t.mutate({username:n.trim(),password:a})},children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`authUsername`)}),(0,F.jsx)(u,{value:n,onChange:e=>i(e.target.value),placeholder:r(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`authPassword`)}),(0,F.jsx)(u,{type:`password`,value:a,onChange:e=>c(e.target.value),placeholder:r(`authPasswordPlaceholder`)})]}),(0,F.jsx)(d,{type:`submit`,className:`w-full`,disabled:!l,children:t.isPending?r(`authLoggingIn`):r(`authLoginAction`)})]})})]})})}var ge=class{constructor(){this.authPollTimerId=null,this.afterSignedIn=null,this.bindSignedInContinuation=e=>{this.afterSignedIn=e},this.openAccountPanel=()=>{Y.getState().openPanel()},this.closeAccountPanel=()=>{Y.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),Y.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=await z();return t.account.loggedIn?!0:(e?.pendingAction&&Y.getState().setPendingAction(e.pendingAction),this.openAccountPanel(),await this.startBrowserSignIn({apiBase:e?.apiBase,status:t}),!1)},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,n=e?.pendingAction,i=e?.status??await z();n&&Y.getState().setPendingAction(n);let a=await g({apiBase:V(i,t)});Y.getState().beginBrowserAuth({sessionId:a.sessionId,verificationUri:a.verificationUri,expiresAt:a.expiresAt,intervalMs:a.intervalMs,statusMessage:r(`remoteBrowserAuthWaiting`)}),window.open(a.verificationUri,`_blank`,`noopener,noreferrer`)||Y.getState().setAuthStatusMessage(r(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:r(`remoteBrowserAuthStartFailed`);l.error(`${r(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=Y.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await ne(),Y.getState().clearPendingAction(),Y.getState().clearBrowserAuth(),await B(),l.success(r(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:r(`remoteLogoutFailed`);l.error(`${r(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await y({username:e.trim()}),await B(),l.success(r(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:r(`remoteAccountUsernameSetFailed`);l.error(`${r(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=U(await z());if(!t){l.error(r(`remoteOpenWebUnavailable`));return}let n=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(n,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=Y.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Y.getState();if(e.authSessionId)try{let t=await z(),n=await re({sessionId:e.authSessionId,apiBase:V(t)});if(n.status===`pending`){Y.getState().updateBrowserAuth({statusMessage:r(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),Y.getState().clearBrowserAuth(),l.error(n.message||r(`remoteBrowserAuthExpired`));return}Y.getState().setAuthStatusMessage(r(`remoteBrowserAuthCompleted`));let i=await B(),{pendingAction:a}=Y.getState();this.clearPollTimer(),Y.getState().clearBrowserAuth(),l.success(r(`remoteLoginSuccess`)),a&&this.afterSignedIn&&await this.afterSignedIn(a,i),Y.getState().clearPendingAction()}catch(e){this.clearPollTimer(),Y.getState().clearBrowserAuth();let t=e instanceof Error?e.message:r(`remoteBrowserAuthPollFailed`);l.error(`${r(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.getBrowserAuthSummary=()=>{let e=Y.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}},Z=new class{constructor(){this.accountManager=new ge,this.remoteAccessManager=new G}};Z.accountManager.bindSignedInContinuation(Z.remoteAccessManager.resumePendingActionAfterSignIn),Z.remoteAccessManager.bindAccountManager(Z.accountManager);var Q=(0,P.createContext)(null);function _e({children:e}){return(0,F.jsx)(Q.Provider,{value:Z,children:e})}function $(){let e=(0,P.useContext)(Q);if(!e)throw Error(`useAppManager must be used inside AppManagerProvider`);return e}export{J as a,W as c,B as d,V as f,j as g,N as h,me as i,L as l,ce as m,$ as n,q as o,U as p,he as r,G as s,_e as t,z as u};
1
+ import{_ as e,m as t,p as n,r,t as i}from"./i18n-D1144VAA.js";import{At as a,Dt as o,Et as s,Ft as c,Lt as l,Mt as u,Nt as d,Ot as f,Tt as p,a as m,bt as h,c as g,dt as _,i as ee,jt as te,kt as v,l as y,o as ne,r as b,s as re,u as x,wt as S,zt as C}from"./api-rASx2-N4.js";import{a as w,n as T,o as ie,r as E,t as ae}from"./dialog-CR80q3Rm.js";import{t as D}from"./createLucideIcon-DzY6wN61.js";import{t as O}from"./key-round-DUq47t0P.js";import{t as k}from"./notice-card-CF4AJPM3.js";import{t as A}from"./status-dot-l3kPFdq_.js";var oe=D(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),se=D(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),j=D(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),M=D(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]);function N(){return C({queryKey:L,queryFn:m,staleTime:5e3,refetchOnWindowFocus:!0})}var P=e(t(),1),F=n();function I(e){let{label:t,muted:n,value:r}=e;return(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,F.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,F.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function ce(){let e=$(),t=N(),n=t.data,c=W(e=>e.actionLabel),l=(0,P.useMemo)(()=>J(n),[n]),u=!!c,m=n?.runtime?.deviceName?.trim()||n?.settings.deviceName?.trim()||r(`remoteDeviceNameAuto`),h=!!(n?.account.loggedIn&&U(n)),{hero:g,issueHint:_}=l;return(0,P.useEffect)(()=>{e.remoteAccessManager.syncStatus(n)},[e,n]),t.isLoading&&!n?(0,F.jsx)(`div`,{className:`p-8 text-gray-400`,children:r(`remoteLoading`)}):(0,F.jsxs)(a,{className:`space-y-6`,children:[(0,F.jsx)(v,{title:r(`remotePageTitle`),description:r(`remotePageDescription`)}),(0,F.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,F.jsxs)(S,{children:[(0,F.jsxs)(o,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsx)(f,{children:g.title}),(0,F.jsx)(A,{status:g.badgeStatus,label:g.badgeLabel})]}),(0,F.jsx)(s,{children:g.description})]}),(0,F.jsxs)(p,{className:`space-y-5`,children:[(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(I,{label:r(`remoteSignedInAccount`),value:n?.account.email}),(0,F.jsx)(I,{label:r(`remoteDeviceName`),value:m}),(0,F.jsx)(I,{label:r(`remoteConnectionStatus`),value:g.badgeLabel}),(0,F.jsx)(I,{label:r(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?i(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[l.primaryAction?(0,F.jsxs)(d,{onClick:()=>{if(l.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(n);return}if(l.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(n);return}e.remoteAccessManager.enableRemoteAccess(n)},disabled:u,children:[l.primaryAction.showRefreshIcon?(0,F.jsx)(j,{className:`mr-2 h-4 w-4`}):null,c||l.primaryAction.label]}):null,(0,F.jsxs)(d,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:u||!h,children:[(0,F.jsx)(M,{className:`mr-2 h-4 w-4`}),r(`remoteOpenDeviceList`)]}),n?.settings.enabled?(0,F.jsx)(d,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(n),disabled:u,children:r(`remoteDisable`)}):null]}),l.shouldShowIssueHint&&_?(0,F.jsx)(k,{tone:`warning`,title:_.title,description:_.body}):null,(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`remoteOpenWebHint`)})]})]}),(0,F.jsxs)(S,{children:[(0,F.jsxs)(o,{children:[(0,F.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,F.jsx)(oe,{className:`h-4 w-4 text-primary`}),r(`remoteDeviceSectionTitle`)]}),(0,F.jsx)(s,{children:r(`remoteDeviceSectionDescription`)})]}),(0,F.jsxs)(p,{className:`space-y-5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(A,{status:n?.account.loggedIn?`ready`:`inactive`,label:n?.account.loggedIn?r(`remoteAccountConnected`):r(`remoteAccountNotConnected`)}),(0,F.jsx)(A,{status:n?.settings.enabled?`active`:`inactive`,label:n?.settings.enabled?r(`remoteEnabled`):r(`remoteStateDisabled`)}),(0,F.jsx)(A,{status:n?.service.running?`active`:`inactive`,label:n?.service.running?r(`remoteServiceRunning`):r(`remoteServiceStopped`)})]}),(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(I,{label:r(`remoteDeviceName`),value:m}),(0,F.jsx)(I,{label:r(`remoteConnectionStatus`),value:g.badgeLabel}),(0,F.jsx)(I,{label:r(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?i(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,F.jsx)(k,{tone:`neutral`,borderStyle:`dashed`,description:n?.account.loggedIn?r(`remoteOpenWebHint`):r(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var L=[`remote-status`],le=`https://platform.nextclaw.io`,R=`https://nextclaw-platform-console.pages.dev`,z=async()=>await c.fetchQuery({queryKey:L,queryFn:m,staleTime:5e3}),B=async()=>(await c.invalidateQueries({queryKey:L}),await z()),V=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function H(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return le;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return R}var U=e=>H(e?.account.apiBase)||H(e?.settings.platformApiBase)||H(e?.platformBase)||H(e?.account.platformBase)||void 0,W=h(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),G=class{constructor(){this.accountManager=null,this.bindAccountManager=e=>{this.accountManager=e},this.syncStatus=e=>{if(!e)return;let t=W.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{W.getState().setEnabled(e)},this.setDeviceName=e=>{W.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{W.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{W.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await B(),n=W.getState();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`},apiBase:n.platformApiBase});return}await this.applyEnabledState(!0,t)},this.disableRemoteAccess=async e=>{let t=e??await B();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await B();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`}});return}let n=t.service.running?`restart`:`start`;await this.runManagedAction({actionLabel:r(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await b(n);let e=await B();this.hydrateDraftFromStatus(e)},successMessage:r(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await B();await this.accountManager?.startBrowserSignIn({status:t,apiBase:W.getState().platformApiBase,pendingAction:{type:`repair-remote`}})},this.saveAdvancedSettings=async e=>{let t=e??await B(),n=W.getState();await this.runManagedAction({actionLabel:r(`remoteActionSavingAdvanced`),job:async()=>{await x({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await B();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?r(`remoteSettingsSaved`):r(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:r(`remoteDoctorRunning`),job:async()=>{let e=await ee();W.getState().setDoctor(e)},successMessage:r(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,r(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,r(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,r(`remoteActionStopping`))},this.resumePendingActionAfterSignIn=async(e,t)=>{if(e){if(e.type===`enable-remote`){await this.applyEnabledState(!0,t);return}e.type===`repair-remote`&&await this.repairRemoteAccess(t)}},this.applyEnabledState=async(e,t)=>{let n=W.getState();await this.runManagedAction({actionLabel:r(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await x({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await B();this.hydrateDraftFromStatus(r),e?await b(r.service.running?`restart`:`start`):t.service.running&&await b(`restart`);let i=await B();this.hydrateDraftFromStatus(i)},successMessage:r(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await b(e),n=await B();this.hydrateDraftFromStatus(n),l.success(t.message)}})},this.hydrateDraftFromStatus=e=>{W.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{W.getState().beginAction(e.actionLabel);try{await e.job(),e.successMessage&&l.success(e.successMessage)}catch(e){let t=e instanceof Error?e.message:r(`error`);throw l.error(t),e}finally{W.getState().finishAction()}}}},ue=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function K(e){return e?.runtime?.lastError?.trim()||``}function de(e){let t=r(`remoteStatusIssueDetailGeneric`),n=K(e);return n?`${t} (${n})`:t}function q(e){if(!e?.settings.enabled)return!1;let t=K(e);return ue.some(e=>e.test(t))}function J(e){return q(e)?{hero:{badgeStatus:`warning`,badgeLabel:r(`remoteStateReauthorizationRequired`),title:r(`remoteStatusReauthorizationTitle`),description:r(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:r(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:r(`remoteStatusRecoveryTitle`),body:r(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:r(`statusReady`),title:r(`remoteStatusReadyTitle`),description:r(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:r(`connecting`),title:r(`remoteStatusConnectingTitle`),description:r(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:r(`remoteStateDisconnected`),title:r(`remoteStatusIssueTitle`),description:r(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:r(`remoteStatusRecoveryTitle`),body:de(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:r(`remoteServiceStopped`),title:r(`remoteStatusNeedsServiceTitle`),description:r(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:r(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:r(`remoteStatusRecoveryTitle`),body:r(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:r(`statusInactive`),title:r(`remoteStatusNeedsEnable`),description:r(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:r(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:r(`statusSetup`),title:r(`remoteStatusNeedsSignIn`),description:r(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:r(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var Y=h(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,pendingAction:null,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),setPendingAction:t=>e({pendingAction:t}),clearPendingAction:()=>e({pendingAction:null}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function X({label:e,value:t}){return(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,F.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,F.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function fe(e){let{email:t,username:n,role:i,canSubmitUsername:a,savingUsername:o,usernameDraft:s,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:f,onLogout:p}=e;return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(k,{tone:`success`,title:r(`accountPanelSignedInTitle`),description:r(`accountPanelSignedInDescription`)}),(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(X,{label:r(`remoteAccountEmail`),value:t}),(0,F.jsx)(X,{label:r(`remoteAccountUsername`),value:n}),(0,F.jsx)(X,{label:r(`remoteAccountRole`),value:i})]}),n?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`remoteAccountUsernameLockedHelp`)}):(0,F.jsxs)(k,{tone:`warning`,title:r(`remoteAccountUsernameRequiredTitle`),description:r(`remoteAccountUsernameRequiredDescription`),children:[(0,F.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,F.jsx)(te,{htmlFor:`account-panel-username`,children:r(`remoteAccountUsername`)}),(0,F.jsx)(u,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:r(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,F.jsx)(d,{disabled:!a,onClick:()=>void l(),children:r(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsxs)(d,{onClick:()=>void f(),children:[(0,F.jsx)(M,{className:`mr-2 h-4 w-4`}),r(`remoteOpenDeviceList`)]}),(0,F.jsxs)(d,{variant:`outline`,onClick:()=>void p(),children:[(0,F.jsx)(se,{className:`mr-2 h-4 w-4`}),r(`remoteLogout`)]})]})]})}function pe(e){let{authSessionId:t,authExpiresAt:n,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(k,{tone:`neutral`,title:r(`accountPanelSignedOutTitle`),description:r(`accountPanelSignedOutDescription`),children:t?(0,F.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,F.jsx)(X,{label:r(`remoteBrowserAuthSession`),value:t}),(0,F.jsx)(X,{label:r(`remoteBrowserAuthExpiresAt`),value:n?i(n):`-`})]}):null}),a?(0,F.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsx)(d,{onClick:()=>void s(),children:r(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,F.jsx)(d,{variant:`outline`,onClick:c,children:r(`remoteBrowserAuthResume`)}):null]})]})}function me(){let e=$(),t=N(),n=Y(e=>e.panelOpen),i=Y(e=>e.authSessionId),a=Y(e=>e.authVerificationUri),o=Y(e=>e.authExpiresAt),s=Y(e=>e.authStatusMessage),c=t.data,[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(!1);(0,P.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,F.jsx)(ae,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,F.jsxs)(T,{className:`max-w-xl`,children:[(0,F.jsxs)(w,{children:[(0,F.jsxs)(ie,{className:`flex items-center gap-2`,children:[(0,F.jsx)(O,{className:`h-5 w-5 text-primary`}),r(`accountPanelTitle`)]}),(0,F.jsx)(E,{children:r(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,F.jsx)(fe,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,F.jsx)(pe,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function he({username:e}){let t=_(),[n,i]=(0,P.useState)(e??``),[a,c]=(0,P.useState)(``),l=n.trim().length>0&&a.length>0&&!t.isPending;return(0,F.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,F.jsxs)(S,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,F.jsxs)(o,{children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:r(`authBrand`)}),(0,F.jsx)(f,{className:`text-2xl`,children:r(`authLoginTitle`)}),(0,F.jsx)(s,{children:r(`authLoginDescription`)})]}),(0,F.jsx)(p,{children:(0,F.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),l&&t.mutate({username:n.trim(),password:a})},children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`authUsername`)}),(0,F.jsx)(u,{value:n,onChange:e=>i(e.target.value),placeholder:r(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`authPassword`)}),(0,F.jsx)(u,{type:`password`,value:a,onChange:e=>c(e.target.value),placeholder:r(`authPasswordPlaceholder`)})]}),(0,F.jsx)(d,{type:`submit`,className:`w-full`,disabled:!l,children:t.isPending?r(`authLoggingIn`):r(`authLoginAction`)})]})})]})})}var ge=class{constructor(){this.authPollTimerId=null,this.afterSignedIn=null,this.bindSignedInContinuation=e=>{this.afterSignedIn=e},this.openAccountPanel=()=>{Y.getState().openPanel()},this.closeAccountPanel=()=>{Y.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),Y.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=await z();return t.account.loggedIn?!0:(e?.pendingAction&&Y.getState().setPendingAction(e.pendingAction),this.openAccountPanel(),await this.startBrowserSignIn({apiBase:e?.apiBase,status:t}),!1)},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,n=e?.pendingAction,i=e?.status??await z();n&&Y.getState().setPendingAction(n);let a=await g({apiBase:V(i,t)});Y.getState().beginBrowserAuth({sessionId:a.sessionId,verificationUri:a.verificationUri,expiresAt:a.expiresAt,intervalMs:a.intervalMs,statusMessage:r(`remoteBrowserAuthWaiting`)}),window.open(a.verificationUri,`_blank`,`noopener,noreferrer`)||Y.getState().setAuthStatusMessage(r(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:r(`remoteBrowserAuthStartFailed`);l.error(`${r(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=Y.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await ne(),Y.getState().clearPendingAction(),Y.getState().clearBrowserAuth(),await B(),l.success(r(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:r(`remoteLogoutFailed`);l.error(`${r(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await y({username:e.trim()}),await B(),l.success(r(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:r(`remoteAccountUsernameSetFailed`);l.error(`${r(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=U(await z());if(!t){l.error(r(`remoteOpenWebUnavailable`));return}let n=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(n,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=Y.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Y.getState();if(e.authSessionId)try{let t=await z(),n=await re({sessionId:e.authSessionId,apiBase:V(t)});if(n.status===`pending`){Y.getState().updateBrowserAuth({statusMessage:r(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),Y.getState().clearBrowserAuth(),l.error(n.message||r(`remoteBrowserAuthExpired`));return}Y.getState().setAuthStatusMessage(r(`remoteBrowserAuthCompleted`));let i=await B(),{pendingAction:a}=Y.getState();this.clearPollTimer(),Y.getState().clearBrowserAuth(),l.success(r(`remoteLoginSuccess`)),a&&this.afterSignedIn&&await this.afterSignedIn(a,i),Y.getState().clearPendingAction()}catch(e){this.clearPollTimer(),Y.getState().clearBrowserAuth();let t=e instanceof Error?e.message:r(`remoteBrowserAuthPollFailed`);l.error(`${r(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.getBrowserAuthSummary=()=>{let e=Y.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}},Z=new class{constructor(){this.accountManager=new ge,this.remoteAccessManager=new G}};Z.accountManager.bindSignedInContinuation(Z.remoteAccessManager.resumePendingActionAfterSignIn),Z.remoteAccessManager.bindAccountManager(Z.accountManager);var Q=(0,P.createContext)(null);function _e({children:e}){return(0,F.jsx)(Q.Provider,{value:Z,children:e})}function $(){let e=(0,P.useContext)(Q);if(!e)throw Error(`useAppManager must be used inside AppManagerProvider`);return e}export{J as a,W as c,B as d,V as f,j as g,N as h,me as i,L as l,ce as m,$ as n,q as o,U as p,he as r,G as s,_e as t,z as u};
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,h as n,m as r,p as i,r as a,t as o,u as s}from"./i18n-D1144VAA.js";import{At as c,Ct as l,Lt as u,Mt as d,Nt as f,Rt as p,Xt as m,ft as h,jt as g,kt as _,nt as v,ot as y,tt as b,zt as x}from"./api-CKKNxbsy.js";import{t as S}from"./createLucideIcon-DzY6wN61.js";import{t as C}from"./search-CRtQwr-h.js";import{t as w}from"./book-open-BcnAiKde.js";import{O as ee,a as T,i as E,n as D,r as te,t as ne}from"./select-C2c10F3e.js";import{t as O}from"./external-link-CpEvG65F.js";import{t as re}from"./key-round-DUq47t0P.js";import{n as ie,t as ae}from"./settings-MWL2SMyk.js";import{t as oe}from"./x-BeyYA_h6.js";import{t as k}from"./status-dot-l3kPFdq_.js";import{i as A,l as se,n as j,r as M,v as ce}from"./use-config-jAYudJxy.js";import{J as le,Q as ue,Y as de,et as fe,q as pe}from"./index-SS1xPoWD.js";import{t as me}from"./tabs-custom-D48zdZoc.js";import{t as he}from"./tag-chip-CrQfVN3A.js";import{t as N}from"./config-hints-BNfpOL4J.js";import{a as P,c as F,i as ge,n as _e,o as I,r as ve,s as ye,t as be}from"./config-split-page-CcrEUtwu.js";var xe=S(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Se=S(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),Ce=S(`MessageCircleMore`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),L=S(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),we=S(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),R=e(r(),1),z=i();function Te({value:e,onChange:t,className:n,placeholder:r=``}){let[i,o]=(0,R.useState)(``),c=n=>{n.key===`Enter`&&i.trim()?(n.preventDefault(),t([...e,i.trim()]),o(``)):n.key===`Backspace`&&!i&&e.length>0&&t(e.slice(0,-1))},l=n=>{t(e.filter((e,t)=>t!==n))};return(0,z.jsxs)(`div`,{className:s(`flex min-h-[42px] flex-wrap gap-2 rounded-xl border border-gray-200/80 bg-white p-2`,n),children:[e.map((e,t)=>(0,z.jsxs)(he,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,z.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,z.jsx)(oe,{className:`h-3 w-3`})})]},t)),(0,z.jsx)(`input`,{type:`text`,value:i,onChange:e=>o(e.target.value),onKeyDown:c,className:`flex-1 outline-none min-w-[100px] bg-transparent text-sm`,placeholder:r||a(`enterTag`)})]})}function Ee(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,z.jsx)(re,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,z.jsx)(fe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,z.jsx)(Se,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,z.jsx)(xe,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,z.jsx)(we,{className:`h-3.5 w-3.5 text-gray-500`}):(0,z.jsx)(ae,{className:`h-3.5 w-3.5 text-gray-500`})}function De({channelName:e,fields:t,formData:n,jsonDrafts:r,setJsonDrafts:i,updateField:o,uiHints:s}){return(0,z.jsx)(z.Fragment,{children:t.map(t=>{let c=N(`channels.${e}.${t.name}`,s),l=c?.label??t.label,u=c?.placeholder;return(0,z.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,z.jsxs)(g,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[Ee(t.name),l]}),t.type===`boolean`&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,z.jsx)(`span`,{className:`text-sm text-gray-500`,children:n[t.name]?a(`enabled`):a(`disabled`)}),(0,z.jsx)(h,{id:t.name,checked:n[t.name]||!1,onCheckedChange:e=>o(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,z.jsx)(d,{id:t.name,type:t.type,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:u,className:`rounded-xl`}),t.type===`password`&&(0,z.jsx)(d,{id:t.name,type:`password`,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:u??a(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,z.jsx)(d,{id:t.name,type:`number`,value:n[t.name]||0,onChange:e=>o(t.name,parseInt(e.target.value,10)||0),placeholder:u,className:`rounded-xl`}),t.type===`tags`&&(0,z.jsx)(Te,{value:n[t.name]||[],onChange:e=>o(t.name,e)}),t.type===`select`&&(0,z.jsxs)(ne,{value:n[t.name]||``,onValueChange:e=>o(t.name,e),children:[(0,z.jsx)(E,{className:`rounded-xl`,children:(0,z.jsx)(T,{})}),(0,z.jsx)(D,{children:(t.options??[]).map(e=>(0,z.jsx)(te,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,z.jsx)(`textarea`,{id:t.name,value:r[t.name]??`{}`,onChange:e=>i(n=>({...n,[t.name]:e.target.value})),className:`min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`})]},t.name)})})}var Oe=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),B=n((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),V=n((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),ke=n(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ae=n(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),je=n((e=>{var t=B().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Me=n((e=>{var t=B().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Ne=n((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),H=n((e=>{var t=V(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Pe=n((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Fe=n((e=>{var t=Pe();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Ie=n(((e,t)=>{var n=Fe();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),U=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),W=n((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{_ as e,a as t,h as n,m as r,p as i,r as a,t as o,u as s}from"./i18n-D1144VAA.js";import{At as c,Ct as l,Lt as u,Mt as d,Nt as f,Rt as p,Xt as m,ft as h,jt as g,kt as _,nt as v,ot as y,tt as b,zt as x}from"./api-rASx2-N4.js";import{t as S}from"./createLucideIcon-DzY6wN61.js";import{t as C}from"./search-CRtQwr-h.js";import{t as w}from"./book-open-BcnAiKde.js";import{O as ee,a as T,i as E,n as D,r as te,t as ne}from"./select-HI5kiwX_.js";import{t as O}from"./external-link-CpEvG65F.js";import{t as re}from"./key-round-DUq47t0P.js";import{n as ie,t as ae}from"./settings-MWL2SMyk.js";import{t as oe}from"./x-BeyYA_h6.js";import{t as k}from"./status-dot-l3kPFdq_.js";import{i as A,l as se,n as j,r as M,v as ce}from"./use-config-BFqzVF8Y.js";import{J as le,Q as ue,Y as de,et as fe,q as pe}from"./index-BEn7o-oH.js";import{t as me}from"./tabs-custom-D48zdZoc.js";import{t as he}from"./tag-chip-BPgMfp9l.js";import{t as N}from"./config-hints-BNfpOL4J.js";import{a as P,c as F,i as ge,n as _e,o as I,r as ve,s as ye,t as be}from"./config-split-page-CcrEUtwu.js";var xe=S(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Se=S(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),Ce=S(`MessageCircleMore`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),L=S(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),we=S(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),R=e(r(),1),z=i();function Te({value:e,onChange:t,className:n,placeholder:r=``}){let[i,o]=(0,R.useState)(``),c=n=>{n.key===`Enter`&&i.trim()?(n.preventDefault(),t([...e,i.trim()]),o(``)):n.key===`Backspace`&&!i&&e.length>0&&t(e.slice(0,-1))},l=n=>{t(e.filter((e,t)=>t!==n))};return(0,z.jsxs)(`div`,{className:s(`flex min-h-[42px] flex-wrap gap-2 rounded-xl border border-gray-200/80 bg-white p-2`,n),children:[e.map((e,t)=>(0,z.jsxs)(he,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,z.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,z.jsx)(oe,{className:`h-3 w-3`})})]},t)),(0,z.jsx)(`input`,{type:`text`,value:i,onChange:e=>o(e.target.value),onKeyDown:c,className:`flex-1 outline-none min-w-[100px] bg-transparent text-sm`,placeholder:r||a(`enterTag`)})]})}function Ee(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,z.jsx)(re,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,z.jsx)(fe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,z.jsx)(Se,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,z.jsx)(xe,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,z.jsx)(we,{className:`h-3.5 w-3.5 text-gray-500`}):(0,z.jsx)(ae,{className:`h-3.5 w-3.5 text-gray-500`})}function De({channelName:e,fields:t,formData:n,jsonDrafts:r,setJsonDrafts:i,updateField:o,uiHints:s}){return(0,z.jsx)(z.Fragment,{children:t.map(t=>{let c=N(`channels.${e}.${t.name}`,s),l=c?.label??t.label,u=c?.placeholder;return(0,z.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,z.jsxs)(g,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[Ee(t.name),l]}),t.type===`boolean`&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,z.jsx)(`span`,{className:`text-sm text-gray-500`,children:n[t.name]?a(`enabled`):a(`disabled`)}),(0,z.jsx)(h,{id:t.name,checked:n[t.name]||!1,onCheckedChange:e=>o(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,z.jsx)(d,{id:t.name,type:t.type,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:u,className:`rounded-xl`}),t.type===`password`&&(0,z.jsx)(d,{id:t.name,type:`password`,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:u??a(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,z.jsx)(d,{id:t.name,type:`number`,value:n[t.name]||0,onChange:e=>o(t.name,parseInt(e.target.value,10)||0),placeholder:u,className:`rounded-xl`}),t.type===`tags`&&(0,z.jsx)(Te,{value:n[t.name]||[],onChange:e=>o(t.name,e)}),t.type===`select`&&(0,z.jsxs)(ne,{value:n[t.name]||``,onValueChange:e=>o(t.name,e),children:[(0,z.jsx)(E,{className:`rounded-xl`,children:(0,z.jsx)(T,{})}),(0,z.jsx)(D,{children:(t.options??[]).map(e=>(0,z.jsx)(te,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,z.jsx)(`textarea`,{id:t.name,value:r[t.name]??`{}`,onChange:e=>i(n=>({...n,[t.name]:e.target.value})),className:`min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`})]},t.name)})})}var Oe=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),B=n((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),V=n((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),ke=n(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ae=n(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),je=n((e=>{var t=B().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Me=n((e=>{var t=B().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Ne=n((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),H=n((e=>{var t=V(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Pe=n((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Fe=n((e=>{var t=Pe();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Ie=n(((e,t)=>{var n=Fe();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),U=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),W=n((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),G=n((e=>{var t=U(),n=W();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Le=n((e=>{var t=B(),n=H(),r=V(),i=G(),a=U(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Re=n((e=>{var t=B(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ze=n(((e,t)=>{var n=G();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Be=n(((e,t)=>{var n=G(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Ve=n(((e,t)=>{var n=G();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),He=n(((e,t)=>{var n=G(),r=B();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Ue=n(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),We=n((e=>{var t=G(),n=ze(),r=Be(),i=Ve(),a=He(),o=W(),s=B(),c=Ue();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Ge=n((e=>{var t=B(),n=V(),r=ke(),i=Ae(),a=je(),o=Me(),s=Ne(),c=H(),l=Ie(),u=Le(),d=Re(),f=G(),p=We();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{At as a,Mt as o,Nt as s,Tt as c,_t as l,kt as u,wt as d}from"./api-CKKNxbsy.js";import{c as f,l as p,u as m}from"./cpu-DPPwMzoC.js";import{n as h,t as g}from"./marketplace-page-DzwJTbAg.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./dialog-DWZeMf9V.js";import{t as C}from"./createLucideIcon-DzY6wN61.js";import{D as w,O as T,w as E}from"./desktop-BwONApN9.js";import{a as D,i as O,n as k,r as A,t as j}from"./select-C2c10F3e.js";import{i as ee,n as M,r as te,t as ne}from"./provider-scoped-model-input-DsZJ44ZV.js";import"./mcp-marketplace-page-BUMkGb6q.js";import{t as re}from"./play-AqrNslHI.js";import{t as N}from"./plus-B-YHtTNC.js";import{t as ie}from"./refresh-cw-CrbD8EkT.js";import{t as ae}from"./sparkles-BmgOD4nY.js";import{t as oe}from"./notice-card-BM2_YNoc.js";import{_ as se,d as ce,f as le,m as ue,n as P,o as de,r as F,s as fe}from"./use-config-jAYudJxy.js";import{n as pe,r as me,t as he}from"./popover-2H9DS7Cv.js";import{$ as ge,A as _e,B as I,C as L,D as R,E as ve,F as ye,G as be,H as xe,I as Se,K as Ce,L as we,M as z,N as B,O as Te,P as Ee,R as De,S as Oe,T as V,U as ke,V as Ae,W as H,X as U,Y as je,Z as W,a as Me,b as Ne,c as Pe,d as Fe,f as Ie,h as G,i as Le,j as Re,k as ze,l as Be,m as K,n as q,o as Ve,p as He,r as Ue,s as J,t as We,w as Ge,x as Ke,z as Y}from"./index-SS1xPoWD.js";import{t as qe}from"./tag-chip-CrQfVN3A.js";var Je=C(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ye=C(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),X=e(t(),1),Z=n(),Q=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(`textarea`,{className:i(`flex min-h-28 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));Q.displayName=`Textarea`;function Xe(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function Ze(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=L(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:V(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function Qe({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:i,onChange:a}){let o=e.trim()?L(e):``,s=Ze({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?r(`agentsRuntimeUnavailableHelp`):``);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(j,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,Z.jsx)(O,{"aria-label":r(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,Z.jsx)(D,{placeholder:r(`agentsRuntimeSelectPlaceholder`)})}),(0,Z.jsx)(k,{className:`rounded-xl`,children:s.map(e=>(0,Z.jsx)(A,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,Z.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function $e({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,Z.jsx)(S,{open:e!==null,onOpenChange:a,children:e?(0,Z.jsx)(et,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function et(e){let{agent:t,pending:n,providerCatalog:i,runtimeOptions:a,defaultRuntime:c,onOpenChange:l,onSubmit:u}=e,[d,f]=(0,X.useState)(Xe(t));return(0,Z.jsxs)(y,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,Z.jsxs)(_,{className:`text-left`,children:[(0,Z.jsx)(b,{children:r(`agentsEditDialogTitle`)}),(0,Z.jsx)(x,{children:r(`agentsEditDialogDescription`)})]})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(oe,{tone:`warning`,title:r(`agentsEditHomeReadonly`),description:r(`agentsEditHomeReadonlyHint`),children:(0,Z.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsx)(o,{value:d.displayName,onChange:e=>f(t=>({...t,displayName:e.target.value})),placeholder:r(`agentsFormNamePlaceholder`)}),(0,Z.jsx)(Q,{value:d.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:r(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,Z.jsx)(o,{value:d.avatar,onChange:e=>f(t=>({...t,avatar:e.target.value})),placeholder:r(`agentsFormAvatarPlaceholder`)}),(0,Z.jsx)(ne,{value:d.model,onChange:e=>f(t=>({...t,model:e})),providerCatalog:i,disabled:n,className:`md:col-span-2`}),(0,Z.jsx)(Qe,{value:d.runtime,onChange:e=>f(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:c,disabled:n})]})]})}),(0,Z.jsxs)(v,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,Z.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>l(!1),disabled:n,children:r(`cancel`)}),(0,Z.jsxs)(s,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>u(t.id,d),disabled:n,children:[(0,Z.jsx)(W,{className:`mr-2 h-4 w-4`}),r(`agentsEditSaveAction`)]})]})]})}var tt=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function nt(e){let{agentCount:t,onCreate:n}=e;return(0,Z.jsxs)(`section`,{className:`flex flex-col gap-3 border-b border-gray-200 pb-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:r(`agentsHeroEyebrow`)}),(0,Z.jsx)(`span`,{className:`rounded-full border border-gray-200 bg-white px-2 py-0.5 text-xs font-medium text-gray-500`,children:t})]}),(0,Z.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:r(`agentsHeroDescription`)})]}),(0,Z.jsxs)(s,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:n,children:[(0,Z.jsx)(N,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}function $(e){let{icon:t,label:n,disabled:r=!1,destructive:a=!1,onClick:o}=e;return(0,Z.jsxs)(`button`,{type:`button`,className:i(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:o,disabled:r,children:[(0,Z.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:n})]})}function rt(e){let{agent:t,runtimeOptions:n,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:l,onEdit:u,onDelete:f}=e,p=t.runtime?.trim()||t.engine?.trim()||``,m=p?n.find(e=>e.value===L(p))?.label??V(p):i;return(0,Z.jsx)(d,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,Z.jsxs)(c,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,Z.jsx)(Ce,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,Z.jsxs)(qe,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,Z.jsx)(Ye,{className:`h-3 w-3`}),r(`agentsCardBuiltInTag`)]}):null]}),(0,Z.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,Z.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,Z.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`agentsCardStartChat`),title:r(`agentsCardStartChat`),onClick:l,children:(0,Z.jsx)(E,{className:`h-4 w-4`})}),(0,Z.jsxs)(he,{children:[(0,Z.jsx)(me,{asChild:!0,children:(0,Z.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`chatSessionMoreActions`),title:r(`chatSessionMoreActions`),children:(0,Z.jsx)(Je,{className:`h-4 w-4`})})}),(0,Z.jsxs)(pe,{align:`end`,className:`w-44 p-1.5`,children:[(0,Z.jsx)($,{icon:W,label:r(`agentsEditAction`),onClick:u,disabled:a}),t.builtIn?null:(0,Z.jsx)($,{icon:U,label:r(`agentsRemoveAction`),onClick:f,disabled:o,destructive:!0})]})]})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-gray-600`,children:t.description?.trim()||(t.builtIn?r(`agentsCardBuiltInSummary`):r(`agentsCardCustomSummary`))}),(0,Z.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,Z.jsx)(`span`,{className:`truncate`,children:m})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ge,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,Z.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function it(){let e=ke(),t=R(),n=P(),i=F(),o=J(),l=ze(),u=Te(),[f,p]=(0,X.useState)(null),m=(0,X.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),h=(0,X.useMemo)(()=>[...m].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[m]),g=(0,X.useMemo)(()=>M({config:n.data,meta:i.data,onlyConfigured:!0}),[i.data,n.data]),_=(0,X.useMemo)(()=>Oe(o.data?.options??[]),[o.data?.options]),v=(0,X.useMemo)(()=>L(o.data?.defaultType??`native`),[o.data?.defaultType]),y=(0,X.useMemo)(()=>_.find(e=>e.value===v)?.label??V(v),[v,_]),b=e=>{p(e)},x=async(e,t)=>{await l.mutateAsync({agentId:e,data:{displayName:t.displayName,description:t.description,avatar:t.avatar,model:t.model,...t.runtime.trim()?{runtime:t.runtime.trim()}:{runtime:``}}}),p(null)},S=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,Ge(t,v))};return(0,Z.jsxs)(a,{className:`space-y-5`,children:[(0,Z.jsx)(nt,{agentCount:m.length,onCreate:()=>e.startAgentCreationDraft(tt)}),(0,Z.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,Z.jsx)(d,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,Z.jsx)(c,{className:`py-14 text-center text-sm text-gray-500`,children:r(`agentsLoading`)})}):h.length===0?(0,Z.jsx)(d,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,Z.jsxs)(c,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,Z.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,Z.jsx)(w,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,Z.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:r(`agentsEmpty`)}),(0,Z.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:r(`agentsEmptyDescription`)}),(0,Z.jsxs)(s,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:()=>e.startAgentCreationDraft(tt),children:[(0,Z.jsx)(N,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}):h.map(e=>(0,Z.jsx)(rt,{agent:e,runtimeOptions:_,defaultRuntimeLabel:y,updatePending:l.isPending,deletePending:u.isPending,onStartChat:()=>S(e),onEdit:()=>b(e),onDelete:()=>u.mutate({agentId:e.id})},e.id))}),(0,Z.jsx)($e,{agent:f,pending:l.isPending,providerCatalog:g,runtimeOptions:_,defaultRuntime:v,onOpenChange:e=>{!e&&!l.isPending&&p(null)},onSubmit:x})]})}function at(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.sessionId??``,e.payload.channel??``,e.payload.to??``].join(` `).toLowerCase().includes(n):!0}function ot(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function st(e){let{job:t,onDelete:n,onRun:a,onToggle:o}=e;return(0,Z.jsx)(d,{className:`border border-gray-200`,children:(0,Z.jsx)(c,{className:`pt-5 pb-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:t.name||t.id}),(0,Z.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-semibold text-gray-500`,children:t.id}),(0,Z.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-[10px] font-semibold`,t.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:t.enabled?r(`enabled`):r(`disabled`)}),t.deleteAfterRun?(0,Z.jsx)(`span`,{className:`rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-semibold text-amber-700`,children:r(`cronOneShot`)}):null]}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[r(`cronScheduleLabel`),`: `,Ie(t)]}),(0,Z.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-gray-700`,children:t.payload.message}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[r(`cronSessionLabel`),`: `,He(t)]}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[r(`cronDeliverTo`),`: `,Fe(t)]})]}),(0,Z.jsxs)(`div`,{className:`min-w-[220px] space-y-2 text-xs text-gray-500`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[r(`cronNextRun`),`:`]}),` `,K(t.state.nextRunAt)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[r(`cronLastRun`),`:`]}),` `,K(t.state.lastRunAt)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[r(`cronLastStatus`),`:`]}),` `,t.state.lastStatus??`-`]}),t.state.lastError?(0,Z.jsx)(`div`,{className:`break-words text-[11px] text-red-500`,children:t.state.lastError}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-end gap-2`,children:[(0,Z.jsxs)(s,{variant:`subtle`,size:`sm`,onClick:()=>a(t),className:`gap-1`,children:[(0,Z.jsx)(re,{className:`h-3.5 w-3.5`}),r(`cronRunNow`)]}),(0,Z.jsxs)(s,{variant:t.enabled?`outline`:`primary`,size:`sm`,onClick:()=>o(t),className:`gap-1`,children:[(0,Z.jsx)(h,{className:`h-3.5 w-3.5`}),t.enabled?r(`cronDisable`):r(`cronEnable`)]}),(0,Z.jsxs)(s,{variant:`destructive`,size:`sm`,onClick:()=>n(t),className:`gap-1`,children:[(0,Z.jsx)(U,{className:`h-3.5 w-3.5`}),r(`delete`)]})]})]})})})}function ct(){let[e,t]=(0,X.useState)(``),[n,c]=(0,X.useState)(`all`),l=de({all:!0}),d=fe(),f=se(),p=ue(),{confirm:m,ConfirmDialog:h}=G(),g=(0,X.useMemo)(()=>(l.data?.jobs??[]).filter(t=>at(t,e)).filter(e=>ot(e,n)),[l.data,e,n]),_=async e=>{await m({title:`${r(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:r(`delete`)})&&d.mutate({id:e.id})},v=async e=>{let t=!e.enabled;await m({title:t?`${r(`cronEnableConfirm`)}?`:`${r(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:r(t?`cronEnable`:`cronDisable`)})&&f.mutate({id:e.id,enabled:t})},y=async e=>{let t=!e.enabled;await m({title:t?`${r(`cronRunForceConfirm`)}?`:`${r(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:r(`cronRunNow`)})&&p.mutate({id:e.id,force:t})};return(0,Z.jsxs)(a,{fullHeight:!0,children:[(0,Z.jsx)(u,{title:r(`cronPageTitle`),description:r(`cronPageDescription`),actions:(0,Z.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>l.refetch(),children:(0,Z.jsx)(ie,{className:i(`h-4 w-4`,l.isFetching&&`animate-spin`)})})}),(0,Z.jsx)(`div`,{className:`mb-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,Z.jsx)(o,{value:e,onChange:e=>t(e.target.value),placeholder:r(`cronSearchPlaceholder`),className:`pl-9`}),(0,Z.jsx)(T,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,Z.jsx)(`div`,{className:`min-w-[180px]`,children:(0,Z.jsxs)(j,{value:n,onValueChange:e=>c(e),children:[(0,Z.jsx)(O,{className:`w-full`,children:(0,Z.jsx)(D,{placeholder:r(`cronStatusLabel`)})}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(A,{value:`all`,children:r(`cronStatusAll`)}),(0,Z.jsx)(A,{value:`enabled`,children:r(`cronStatusEnabled`)}),(0,Z.jsx)(A,{value:`disabled`,children:r(`cronStatusDisabled`)})]})]})}),(0,Z.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[r(`cronTotalLabel`),`: `,l.data?.total??0,` / `,g.length]})]})}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:l.isLoading?(0,Z.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:r(`cronLoading`)}):g.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:r(`cronEmpty`)}):(0,Z.jsx)(`div`,{className:`space-y-4`,children:g.map(e=>(0,Z.jsx)(st,{job:e,onDelete:_,onRun:y,onToggle:v},e.id))})}),(0,Z.jsx)(h,{})]})}function lt(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,setSelectedSessionKey:i,selectedSessionKeyRef:a,resetStreamState:o}=e;(0,X.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&i(n);return}r!==null&&(i(null),o())}},[o,n,r,i,t]),(0,X.useEffect)(()=>{a.current=r},[r,a])}function ut({view:e,confirmDialog:t}){let{isMobile:n}=je();return(0,Z.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,Z.jsx)(Pe,{}),e===`chat`?n?(0,Z.jsx)(We,{}):(0,Z.jsx)(Be,{}):(0,Z.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Z.jsx)(ct,{})})}):e===`agents`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Z.jsx)(it,{})})}):(0,Z.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-4 py-4 sm:px-6 sm:py-5`,children:(0,Z.jsx)(g,{forcedType:`skills`})})})}),t]})}function dt(e,t){return e.filter(e=>be(e,t))}function ft(e){let{config:t,meta:n}=e;return(0,X.useMemo)(()=>{let e=M({meta:n,config:t,onlyConfigured:!0}),r=new Set,i=[];for(let t of e)for(let e of t.models){let n=te(t.prefix,e);!n||r.has(n)||(r.add(n),i.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:ee(t.modelThinking,e,t.aliases)}))}return i.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[t,n])}function pt(e){let{sessions:t,sessionKey:n,sessionType:r}=e;return{recentSessionPreferredModel:(0,X.useMemo)(()=>q({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredModel?.trim()||void 0}),[n,r,t]),recentSessionPreferredThinking:(0,X.useMemo)(()=>q({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredThinking??void 0}),[n,r,t])}}function mt(e){let{currentSelectedModel:t,modelOptions:n}=e,r=(0,X.useMemo)(()=>n.find(e=>e.value===t),[t,n]);return{supportedThinkingLevels:(0,X.useMemo)(()=>r?.thinkingCapability?.supported??[],[r?.thinkingCapability?.supported]),defaultThinkingLevel:(0,X.useMemo)(()=>r?.thinkingCapability?.default??null,[r?.thinkingCapability?.default])}}function ht(e){let{modelOptions:t,supportedModels:n}=e;if(!n||n.length===0)return t;let r=new Set(n),i=t.filter(e=>r.has(e.value));return i.length>0?i:t}function gt(e){let{currentSelectedModel:t,pendingSessionType:n,projectRootOverride:r,query:i,sessionKey:a,setPendingSessionType:o,setSelectedModel:s,setSelectedThinkingLevel:c}=e,l=P(),u=F(),d=le({limit:200}),f=J(),p=ce({sessionId:a?.trim()||`draft-session`,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:r??null}:{}}),m=(l.isFetched||l.isSuccess)&&(u.isFetched||u.isSuccess),h=ft({config:l.data,meta:u.data}),g=(0,X.useMemo)(()=>d.data?.sessions??[],[d.data?.sessions]),_=(0,X.useMemo)(()=>Re(g),[g]),v=(0,X.useMemo)(()=>dt(_,i),[_,i]),y=(0,X.useMemo)(()=>_.find(e=>e.key===a)??null,[_,a]),b=(0,X.useMemo)(()=>p.data?.records??[],[p.data?.records]),x=ve({selectedSession:y,pendingSessionType:n,setPendingSessionType:o,sessionTypesData:f.data}),S=(0,X.useMemo)(()=>ht({modelOptions:h,supportedModels:x.selectedSessionTypeOption?.supportedModels}),[h,x.selectedSessionTypeOption?.supportedModels]),{recentSessionPreferredModel:C,recentSessionPreferredThinking:w}=pt({sessions:_,sessionKey:a,sessionType:x.selectedSessionType}),{supportedThinkingLevels:T,defaultThinkingLevel:E}=mt({currentSelectedModel:t,modelOptions:S});return Ue({modelOptions:S,selectedSessionKey:a??``,selectedSessionExists:!!y,selectedSessionPreferredModel:y?.preferredModel,fallbackPreferredModel:x.selectedSessionTypeOption?.recommendedModel??C,defaultModel:x.selectedSessionTypeOption?.recommendedModel??l.data?.agents.defaults.model,setSelectedModel:s}),Le({supportedThinkingLevels:T,selectedSessionKey:a??``,selectedSessionExists:!!y,selectedSessionPreferredThinking:y?.preferredThinking??null,fallbackPreferredThinking:w??null,defaultThinkingLevel:E,setSelectedThinkingLevel:c}),{configQuery:l,configMetaQuery:u,sessionsQuery:d,sessionTypesQuery:f,sessionSkillsQuery:p,isProviderStateResolved:m,modelOptions:S,sessionSummaries:g,sessions:v,skillRecords:b,selectedSession:y,...x}}function _t(e){return e.parentSessionKey?e.sessionSummaries.map(z).filter(t=>t.parentSessionId===e.parentSessionKey).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>({sessionKey:e.key,parentSessionKey:e.parentSessionId??null,label:e.label??null,agentId:e.agentId??null})):[]}function vt(e){let{availableAgents:t,parentSessionId:n,selectedAgentId:r,selectedSession:i,selectedSessionType:a,sessionKey:o,sessionSummaries:s,sessionTypeOptions:c}=e,l=i?H(i):void 0,u=i?.agentId??r,d=t.find(e=>e.id===u)??null,f=(0,X.useMemo)(()=>{if(!n)return null;let e=s.find(e=>e.sessionId===n)??null;return e?z(e):null},[n,s]),p=c.find(e=>e.value===a)??null;return{currentSessionDisplayName:l,currentAgentId:u,currentAgent:d,parentSession:f,currentSessionTypeLabel:p?.label??V(a),currentSessionTypeIcon:p?.icon??null,currentChildSessionTabs:(0,X.useMemo)(()=>_t({parentSessionKey:o,sessionSummaries:s}),[o,s])}}function yt(e){(0,X.useEffect)(()=>{e.presenter.chatInputManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,defaultSessionType:e.defaultSessionType,canStopGeneration:e.canStopCurrentRun,stopDisabledReason:e.stopDisabledReason,stopSupported:!0,stopReason:void 0,sendError:e.lastSendError,isSending:e.isSending,modelOptions:e.modelOptions,sessionTypeOptions:e.sessionTypeOptions,selectedSessionType:e.selectedSessionType,canEditSessionType:e.canEditSessionType,sessionTypeUnavailable:e.sessionTypeUnavailable,skillRecords:e.skillRecords,isSkillsLoading:e.isSkillsLoading}),e.presenter.chatThreadManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,modelOptions:e.modelOptions,sessionTypeUnavailable:e.sessionTypeUnavailable,sessionTypeUnavailableMessage:e.sessionTypeUnavailableMessage,sessionTypeLabel:e.currentSessionTypeLabel,sessionTypeIcon:e.currentSessionTypeIcon,sessionKey:e.sessionKey??null,agentId:e.currentAgentId,agentDisplayName:e.currentAgent?.displayName??null,agentAvatarUrl:e.currentAgent?.avatarUrl??null,availableAgents:e.availableAgents,sessionDisplayName:e.currentSessionDisplayName,sessionProjectRoot:e.effectiveSessionProjectRoot,sessionProjectName:e.effectiveSessionProjectName,canDeleteSession:!!e.selectedSession,threadRef:e.threadRef,isHistoryLoading:e.agent.isHydrating,messages:e.agent.visibleMessages,isSending:e.isSending,isAwaitingAssistantOutput:e.isAwaitingAssistantOutput,contextWindow:_e(e.agent.snapshot.contextWindow),parentSessionKey:e.parentSession?.key??null,parentSessionLabel:e.parentSession?H(e.parentSession):null,childSessionTabs:e.childSessionTabs})},[e])}function bt(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function xt(e){let t={};e.model?.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),e.thinkingLevel?.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),e.sessionType?.trim()&&(t.session_type=e.sessionType.trim(),t.runtime=e.sessionType.trim()),e.agentId?.trim()&&(t.agent_id=e.agentId.trim());let n=Ee(e.projectRoot);n&&(t.project_root=n);let r=bt(e.requestedSkills);r.length>0&&(t.requested_skill_refs=r);let i=e.composerNodes?Se(e.composerNodes):[];return i.length>0&&(t[ye]=i),t}function St(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r,selectedSessionProjectRoot:i}=e;return t!==null&&n!==null&&r===n&&(i??null)===t}function Ct(e){let t=Y(e=>e.snapshot.query),n=Y(e=>e.snapshot.selectedSessionKey),r=Y(e=>e.snapshot.selectedAgentId),i=I(e=>e.snapshot.pendingSessionType),a=I(e=>e.snapshot.pendingProjectRoot),o=I(e=>e.snapshot.pendingProjectRootSessionKey),s=I(e=>e.snapshot.selectedModel),c=l(),u=we(c),d=R(),{confirm:h,ConfirmDialog:g}=G(),_=f(),v=p(),{sessionId:y}=m(),b=(0,X.useRef)(null),x=(0,X.useRef)(n),S=(0,X.useMemo)(()=>Ve(y),[y]),C=S??void 0,w=a!==null&&(!C||o===C),T=gt({query:t,sessionKey:C??null,projectRootOverride:w?a:void 0,currentSelectedModel:s,pendingSessionType:i,setPendingSessionType:e.chatInputManager.setPendingSessionType,setSelectedModel:e.chatInputManager.setSelectedModel,setSelectedThinkingLevel:e.chatInputManager.setSelectedThinkingLevel});return{presenter:e,selectedSessionKey:n,selectedAgentId:r,pendingProjectRoot:a,pendingProjectRootSessionKey:o,systemStatus:c,isRuntimeBlocked:u,agentsQuery:d,confirm:h,ConfirmDialog:g,location:_,navigate:v,threadRef:b,selectedSessionKeyRef:x,routeSessionKey:S,sessionKey:C,hasSessionProjectRootOverride:w,agent:Ke(C),...T}}function wt(e){let t=Ct(e),{agent:n,agentsQuery:r,hasSessionProjectRootOverride:i,pendingProjectRoot:a,isRuntimeBlocked:o,systemStatus:s,selectedAgentId:c,selectedSession:l,selectedSessionType:u,sessionKey:d,sessionSummaries:f,sessionTypeOptions:p}=t,m=i?a:l?.projectRoot??null,h=i?B(m):l?.projectName??B(m),g=n.hydrateError?.message??n.snapshot.error?.message??null,_=s.phase===`ready`&&Ne(g)?null:g,v=(r.data?.agents?.length??0)>0?r.data?.agents??[]:[{id:l?.agentId??c}],y=vt({sessionKey:d??null,selectedSession:l,selectedAgentId:c,availableAgents:v,parentSessionId:l?.parentSessionId??null,sessionSummaries:f,selectedSessionType:u,sessionTypeOptions:p}),b=n.isRunning||l?.status===`running`;return{...t,availableAgents:v,effectiveSessionProjectRoot:m,effectiveSessionProjectName:h,isSending:n.isSending||b,isAwaitingAssistantOutput:b,canStopCurrentRun:b,stopDisabledReason:b?null:`__preparing__`,lastSendError:o?null:s.phase===`ready`?_:De({message:_,status:s}),...y}}function Tt(e){let{agent:t,pendingProjectRoot:n,pendingProjectRootSessionKey:r,presenter:i,selectedSession:a,selectedSessionKeyRef:o,sessionKey:s}=e;(0,X.useEffect)(()=>{i.chatStreamActionsManager.bind({sendMessage:async e=>{if((e.sessionKey??null)!==(s??null))return;let o=xt({agentId:e.agentId,model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,projectRoot:!e.sessionKey||e.sessionKey===r?n:a?.projectRoot??null,requestedSkills:e.requestedSkills,composerNodes:e.composerNodes}),c=Ae({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:o});if(c)try{let n=await t.send(c);!e.sessionKey&&n?.sessionId&&i.chatSessionListManager.materializeRootSessionRoute(n.sessionId)}catch(t){throw e.restoreDraftOnError&&(e.composerNodes&&e.composerNodes.length>0?i.chatInputManager.restoreComposerState?.(e.composerNodes,e.attachments??[]):i.chatInputManager.setDraft(t=>t.trim().length===0?e.message:t)),t}},stopCurrentRun:async()=>{await t.abort()},resumeRun:async e=>{e.sessionKey===s&&await t.streamRun()},resetStreamState:()=>{o.current=null},applyHistoryMessages:()=>{}})},[t,n,r,i,a?.projectRoot,o,s])}function Et(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,selectedSession:r}=e;(0,X.useEffect)(()=>{!r||!St({pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r.key,selectedSessionProjectRoot:r.projectRoot??null})||I.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[t,n,r])}function Dt(e){let{confirm:t,location:n,navigate:r,presenter:i}=e;(0,X.useEffect)(()=>{i.chatUiManager.syncState({pathname:n.pathname}),i.chatUiManager.bindActions({navigate:r,confirm:t})},[t,n.pathname,r,i])}function Ot(e){let{presenter:t,selectedAgentId:n,selectedSession:r}=e;(0,X.useEffect)(()=>{!r?.agentId||n===r.agentId||t.chatSessionListManager.setSelectedAgentId(r.agentId)},[t,n,r?.agentId])}function kt(e){let{agent:t,presenter:n,routeSessionKey:r}=e,i=t.snapshot.activeRun?.sessionId??t.visibleMessages.find(e=>e.sessionId.trim())?.sessionId??null;(0,X.useEffect)(()=>{r||!i||n.chatSessionListManager.materializeRootSessionRoute(i)},[i,n,r])}function At({view:e}){let[t]=(0,X.useState)(()=>new Me),n=wt(t);return Tt(n),Et(n),Dt(n),Ot(n),kt(n),lt({view:e,routeSessionKey:n.routeSessionKey,selectedSessionKey:n.selectedSessionKey,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,selectedSessionKeyRef:n.selectedSessionKeyRef,resetStreamState:t.chatStreamActionsManager.resetStreamState}),yt({presenter:t,isProviderStateResolved:n.isProviderStateResolved,defaultSessionType:n.defaultSessionType,canStopCurrentRun:n.canStopCurrentRun,stopDisabledReason:n.stopDisabledReason,lastSendError:n.lastSendError,isSending:n.isSending,modelOptions:n.modelOptions,sessionTypeOptions:n.sessionTypeOptions,selectedSessionType:n.selectedSessionType,canEditSessionType:n.canEditSessionType,sessionTypeUnavailable:n.sessionTypeUnavailable,skillRecords:n.skillRecords,isSkillsLoading:n.sessionSkillsQuery.isLoading,sessionTypeUnavailableMessage:n.sessionTypeUnavailableMessage,currentSessionTypeLabel:n.currentSessionTypeLabel,currentSessionTypeIcon:n.currentSessionTypeIcon,sessionKey:n.sessionKey,currentAgentId:n.currentAgentId,currentAgent:n.currentAgent,availableAgents:n.availableAgents,currentSessionDisplayName:n.currentSessionDisplayName,effectiveSessionProjectRoot:n.effectiveSessionProjectRoot,effectiveSessionProjectName:n.effectiveSessionProjectName,selectedSession:n.selectedSession,threadRef:n.threadRef,agent:n.agent,isAwaitingAssistantOutput:n.isAwaitingAssistantOutput,parentSession:n.parentSession,childSessionTabs:n.currentChildSessionTabs}),(0,Z.jsx)(xe,{presenter:t,children:(0,Z.jsx)(ut,{view:e,confirmDialog:(0,Z.jsx)(n.ConfirmDialog,{})})})}function jt({view:e}){return(0,Z.jsx)(At,{view:e})}export{jt as ChatPage};
1
+ import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{At as a,Mt as o,Nt as s,Tt as c,_t as l,kt as u,wt as d}from"./api-rASx2-N4.js";import{d as f,l as p,u as m}from"./cpu-DKc3bQic.js";import{n as h,t as g}from"./marketplace-page-B3Q_uKOZ.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./dialog-CR80q3Rm.js";import{t as C}from"./createLucideIcon-DzY6wN61.js";import{A as w,E as T,k as E}from"./desktop-DJpQzxsz.js";import{a as D,i as O,n as k,r as A,t as j}from"./select-HI5kiwX_.js";import{i as ee,n as M,r as te,t as ne}from"./provider-scoped-model-input-B8LJ6RCt.js";import"./mcp-marketplace-page-D9maE_Sf.js";import{t as re}from"./play-AqrNslHI.js";import{t as N}from"./plus-B-YHtTNC.js";import{t as ie}from"./refresh-cw-CrbD8EkT.js";import{t as ae}from"./sparkles-BmgOD4nY.js";import{t as oe}from"./notice-card-CF4AJPM3.js";import{_ as se,d as ce,f as le,m as ue,n as P,o as de,r as F,s as fe}from"./use-config-BFqzVF8Y.js";import{n as pe,r as me,t as he}from"./popover-DeAliE_4.js";import{$ as ge,A as _e,B as I,C as L,D as R,E as ve,F as ye,G as be,H as xe,I as Se,K as Ce,L as we,M as z,N as B,O as Te,P as Ee,R as De,S as Oe,T as V,U as ke,V as Ae,W as H,X as U,Y as je,Z as W,a as Me,b as Ne,c as Pe,d as Fe,f as Ie,h as G,i as Le,j as Re,k as ze,l as Be,m as K,n as q,o as Ve,p as He,r as Ue,s as J,t as We,w as Ge,x as Ke,z as Y}from"./index-BEn7o-oH.js";import{t as qe}from"./tag-chip-BPgMfp9l.js";var Je=C(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ye=C(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),X=e(t(),1),Z=n(),Q=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(`textarea`,{className:i(`flex min-h-28 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));Q.displayName=`Textarea`;function Xe(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function Ze(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=L(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:V(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function Qe({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:i,onChange:a}){let o=e.trim()?L(e):``,s=Ze({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?r(`agentsRuntimeUnavailableHelp`):``);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(j,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,Z.jsx)(O,{"aria-label":r(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,Z.jsx)(D,{placeholder:r(`agentsRuntimeSelectPlaceholder`)})}),(0,Z.jsx)(k,{className:`rounded-xl`,children:s.map(e=>(0,Z.jsx)(A,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,Z.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function $e({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,Z.jsx)(S,{open:e!==null,onOpenChange:a,children:e?(0,Z.jsx)(et,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function et(e){let{agent:t,pending:n,providerCatalog:i,runtimeOptions:a,defaultRuntime:c,onOpenChange:l,onSubmit:u}=e,[d,f]=(0,X.useState)(Xe(t));return(0,Z.jsxs)(y,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,Z.jsxs)(_,{className:`text-left`,children:[(0,Z.jsx)(b,{children:r(`agentsEditDialogTitle`)}),(0,Z.jsx)(x,{children:r(`agentsEditDialogDescription`)})]})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(oe,{tone:`warning`,title:r(`agentsEditHomeReadonly`),description:r(`agentsEditHomeReadonlyHint`),children:(0,Z.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsx)(o,{value:d.displayName,onChange:e=>f(t=>({...t,displayName:e.target.value})),placeholder:r(`agentsFormNamePlaceholder`)}),(0,Z.jsx)(Q,{value:d.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:r(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,Z.jsx)(o,{value:d.avatar,onChange:e=>f(t=>({...t,avatar:e.target.value})),placeholder:r(`agentsFormAvatarPlaceholder`)}),(0,Z.jsx)(ne,{value:d.model,onChange:e=>f(t=>({...t,model:e})),providerCatalog:i,disabled:n,className:`md:col-span-2`}),(0,Z.jsx)(Qe,{value:d.runtime,onChange:e=>f(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:c,disabled:n})]})]})}),(0,Z.jsxs)(v,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,Z.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>l(!1),disabled:n,children:r(`cancel`)}),(0,Z.jsxs)(s,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>u(t.id,d),disabled:n,children:[(0,Z.jsx)(W,{className:`mr-2 h-4 w-4`}),r(`agentsEditSaveAction`)]})]})]})}var tt=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function nt(e){let{agentCount:t,onCreate:n}=e;return(0,Z.jsxs)(`section`,{className:`flex flex-col gap-3 border-b border-gray-200 pb-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:r(`agentsHeroEyebrow`)}),(0,Z.jsx)(`span`,{className:`rounded-full border border-gray-200 bg-white px-2 py-0.5 text-xs font-medium text-gray-500`,children:t})]}),(0,Z.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:r(`agentsHeroDescription`)})]}),(0,Z.jsxs)(s,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:n,children:[(0,Z.jsx)(N,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}function $(e){let{icon:t,label:n,disabled:r=!1,destructive:a=!1,onClick:o}=e;return(0,Z.jsxs)(`button`,{type:`button`,className:i(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:o,disabled:r,children:[(0,Z.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:n})]})}function rt(e){let{agent:t,runtimeOptions:n,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:l,onEdit:u,onDelete:f}=e,p=t.runtime?.trim()||t.engine?.trim()||``,m=p?n.find(e=>e.value===L(p))?.label??V(p):i;return(0,Z.jsx)(d,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,Z.jsxs)(c,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,Z.jsx)(Ce,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,Z.jsxs)(qe,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,Z.jsx)(Ye,{className:`h-3 w-3`}),r(`agentsCardBuiltInTag`)]}):null]}),(0,Z.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,Z.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,Z.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`agentsCardStartChat`),title:r(`agentsCardStartChat`),onClick:l,children:(0,Z.jsx)(T,{className:`h-4 w-4`})}),(0,Z.jsxs)(he,{children:[(0,Z.jsx)(me,{asChild:!0,children:(0,Z.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`chatSessionMoreActions`),title:r(`chatSessionMoreActions`),children:(0,Z.jsx)(Je,{className:`h-4 w-4`})})}),(0,Z.jsxs)(pe,{align:`end`,className:`w-44 p-1.5`,children:[(0,Z.jsx)($,{icon:W,label:r(`agentsEditAction`),onClick:u,disabled:a}),t.builtIn?null:(0,Z.jsx)($,{icon:U,label:r(`agentsRemoveAction`),onClick:f,disabled:o,destructive:!0})]})]})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-gray-600`,children:t.description?.trim()||(t.builtIn?r(`agentsCardBuiltInSummary`):r(`agentsCardCustomSummary`))}),(0,Z.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,Z.jsx)(`span`,{className:`truncate`,children:m})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ge,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,Z.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function it(){let e=ke(),t=R(),n=P(),i=F(),o=J(),l=ze(),u=Te(),[f,p]=(0,X.useState)(null),m=(0,X.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),h=(0,X.useMemo)(()=>[...m].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[m]),g=(0,X.useMemo)(()=>M({config:n.data,meta:i.data,onlyConfigured:!0}),[i.data,n.data]),_=(0,X.useMemo)(()=>Oe(o.data?.options??[]),[o.data?.options]),v=(0,X.useMemo)(()=>L(o.data?.defaultType??`native`),[o.data?.defaultType]),y=(0,X.useMemo)(()=>_.find(e=>e.value===v)?.label??V(v),[v,_]),b=e=>{p(e)},x=async(e,t)=>{await l.mutateAsync({agentId:e,data:{displayName:t.displayName,description:t.description,avatar:t.avatar,model:t.model,...t.runtime.trim()?{runtime:t.runtime.trim()}:{runtime:``}}}),p(null)},S=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,Ge(t,v))};return(0,Z.jsxs)(a,{className:`space-y-5`,children:[(0,Z.jsx)(nt,{agentCount:m.length,onCreate:()=>e.startAgentCreationDraft(tt)}),(0,Z.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,Z.jsx)(d,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,Z.jsx)(c,{className:`py-14 text-center text-sm text-gray-500`,children:r(`agentsLoading`)})}):h.length===0?(0,Z.jsx)(d,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,Z.jsxs)(c,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,Z.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,Z.jsx)(E,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,Z.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:r(`agentsEmpty`)}),(0,Z.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:r(`agentsEmptyDescription`)}),(0,Z.jsxs)(s,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:()=>e.startAgentCreationDraft(tt),children:[(0,Z.jsx)(N,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}):h.map(e=>(0,Z.jsx)(rt,{agent:e,runtimeOptions:_,defaultRuntimeLabel:y,updatePending:l.isPending,deletePending:u.isPending,onStartChat:()=>S(e),onEdit:()=>b(e),onDelete:()=>u.mutate({agentId:e.id})},e.id))}),(0,Z.jsx)($e,{agent:f,pending:l.isPending,providerCatalog:g,runtimeOptions:_,defaultRuntime:v,onOpenChange:e=>{!e&&!l.isPending&&p(null)},onSubmit:x})]})}function at(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.sessionId??``,e.payload.channel??``,e.payload.to??``].join(` `).toLowerCase().includes(n):!0}function ot(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function st(e){let{job:t,onDelete:n,onRun:a,onToggle:o}=e;return(0,Z.jsx)(d,{className:`border border-gray-200`,children:(0,Z.jsx)(c,{className:`pt-5 pb-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:t.name||t.id}),(0,Z.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-semibold text-gray-500`,children:t.id}),(0,Z.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-[10px] font-semibold`,t.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:t.enabled?r(`enabled`):r(`disabled`)}),t.deleteAfterRun?(0,Z.jsx)(`span`,{className:`rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-semibold text-amber-700`,children:r(`cronOneShot`)}):null]}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[r(`cronScheduleLabel`),`: `,Ie(t)]}),(0,Z.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-gray-700`,children:t.payload.message}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[r(`cronSessionLabel`),`: `,He(t)]}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[r(`cronDeliverTo`),`: `,Fe(t)]})]}),(0,Z.jsxs)(`div`,{className:`min-w-[220px] space-y-2 text-xs text-gray-500`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[r(`cronNextRun`),`:`]}),` `,K(t.state.nextRunAt)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[r(`cronLastRun`),`:`]}),` `,K(t.state.lastRunAt)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[r(`cronLastStatus`),`:`]}),` `,t.state.lastStatus??`-`]}),t.state.lastError?(0,Z.jsx)(`div`,{className:`break-words text-[11px] text-red-500`,children:t.state.lastError}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-end gap-2`,children:[(0,Z.jsxs)(s,{variant:`subtle`,size:`sm`,onClick:()=>a(t),className:`gap-1`,children:[(0,Z.jsx)(re,{className:`h-3.5 w-3.5`}),r(`cronRunNow`)]}),(0,Z.jsxs)(s,{variant:t.enabled?`outline`:`primary`,size:`sm`,onClick:()=>o(t),className:`gap-1`,children:[(0,Z.jsx)(h,{className:`h-3.5 w-3.5`}),t.enabled?r(`cronDisable`):r(`cronEnable`)]}),(0,Z.jsxs)(s,{variant:`destructive`,size:`sm`,onClick:()=>n(t),className:`gap-1`,children:[(0,Z.jsx)(U,{className:`h-3.5 w-3.5`}),r(`delete`)]})]})]})})})}function ct(){let[e,t]=(0,X.useState)(``),[n,c]=(0,X.useState)(`all`),l=de({all:!0}),d=fe(),f=se(),p=ue(),{confirm:m,ConfirmDialog:h}=G(),g=(0,X.useMemo)(()=>(l.data?.jobs??[]).filter(t=>at(t,e)).filter(e=>ot(e,n)),[l.data,e,n]),_=async e=>{await m({title:`${r(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:r(`delete`)})&&d.mutate({id:e.id})},v=async e=>{let t=!e.enabled;await m({title:t?`${r(`cronEnableConfirm`)}?`:`${r(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:r(t?`cronEnable`:`cronDisable`)})&&f.mutate({id:e.id,enabled:t})},y=async e=>{let t=!e.enabled;await m({title:t?`${r(`cronRunForceConfirm`)}?`:`${r(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:r(`cronRunNow`)})&&p.mutate({id:e.id,force:t})};return(0,Z.jsxs)(a,{fullHeight:!0,children:[(0,Z.jsx)(u,{title:r(`cronPageTitle`),description:r(`cronPageDescription`),actions:(0,Z.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>l.refetch(),children:(0,Z.jsx)(ie,{className:i(`h-4 w-4`,l.isFetching&&`animate-spin`)})})}),(0,Z.jsx)(`div`,{className:`mb-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,Z.jsx)(o,{value:e,onChange:e=>t(e.target.value),placeholder:r(`cronSearchPlaceholder`),className:`pl-9`}),(0,Z.jsx)(w,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,Z.jsx)(`div`,{className:`min-w-[180px]`,children:(0,Z.jsxs)(j,{value:n,onValueChange:e=>c(e),children:[(0,Z.jsx)(O,{className:`w-full`,children:(0,Z.jsx)(D,{placeholder:r(`cronStatusLabel`)})}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(A,{value:`all`,children:r(`cronStatusAll`)}),(0,Z.jsx)(A,{value:`enabled`,children:r(`cronStatusEnabled`)}),(0,Z.jsx)(A,{value:`disabled`,children:r(`cronStatusDisabled`)})]})]})}),(0,Z.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[r(`cronTotalLabel`),`: `,l.data?.total??0,` / `,g.length]})]})}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:l.isLoading?(0,Z.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:r(`cronLoading`)}):g.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:r(`cronEmpty`)}):(0,Z.jsx)(`div`,{className:`space-y-4`,children:g.map(e=>(0,Z.jsx)(st,{job:e,onDelete:_,onRun:y,onToggle:v},e.id))})}),(0,Z.jsx)(h,{})]})}function lt(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,setSelectedSessionKey:i,selectedSessionKeyRef:a,resetStreamState:o}=e;(0,X.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&i(n);return}r!==null&&(i(null),o())}},[o,n,r,i,t]),(0,X.useEffect)(()=>{a.current=r},[r,a])}function ut({view:e,confirmDialog:t}){let{isMobile:n}=je();return(0,Z.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,Z.jsx)(Pe,{}),e===`chat`?n?(0,Z.jsx)(We,{}):(0,Z.jsx)(Be,{}):(0,Z.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Z.jsx)(ct,{})})}):e===`agents`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Z.jsx)(it,{})})}):(0,Z.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-4 py-4 sm:px-6 sm:py-5`,children:(0,Z.jsx)(g,{forcedType:`skills`})})})}),t]})}function dt(e,t){return e.filter(e=>be(e,t))}function ft(e){let{config:t,meta:n}=e;return(0,X.useMemo)(()=>{let e=M({meta:n,config:t,onlyConfigured:!0}),r=new Set,i=[];for(let t of e)for(let e of t.models){let n=te(t.prefix,e);!n||r.has(n)||(r.add(n),i.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:ee(t.modelThinking,e,t.aliases)}))}return i.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[t,n])}function pt(e){let{sessions:t,sessionKey:n,sessionType:r}=e;return{recentSessionPreferredModel:(0,X.useMemo)(()=>q({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredModel?.trim()||void 0}),[n,r,t]),recentSessionPreferredThinking:(0,X.useMemo)(()=>q({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredThinking??void 0}),[n,r,t])}}function mt(e){let{currentSelectedModel:t,modelOptions:n}=e,r=(0,X.useMemo)(()=>n.find(e=>e.value===t),[t,n]);return{supportedThinkingLevels:(0,X.useMemo)(()=>r?.thinkingCapability?.supported??[],[r?.thinkingCapability?.supported]),defaultThinkingLevel:(0,X.useMemo)(()=>r?.thinkingCapability?.default??null,[r?.thinkingCapability?.default])}}function ht(e){let{modelOptions:t,supportedModels:n}=e;if(!n||n.length===0)return t;let r=new Set(n),i=t.filter(e=>r.has(e.value));return i.length>0?i:t}function gt(e){let{currentSelectedModel:t,pendingSessionType:n,projectRootOverride:r,query:i,sessionKey:a,setPendingSessionType:o,setSelectedModel:s,setSelectedThinkingLevel:c}=e,l=P(),u=F(),d=le({limit:200}),f=J(),p=ce({sessionId:a?.trim()||`draft-session`,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:r??null}:{}}),m=(l.isFetched||l.isSuccess)&&(u.isFetched||u.isSuccess),h=ft({config:l.data,meta:u.data}),g=(0,X.useMemo)(()=>d.data?.sessions??[],[d.data?.sessions]),_=(0,X.useMemo)(()=>Re(g),[g]),v=(0,X.useMemo)(()=>dt(_,i),[_,i]),y=(0,X.useMemo)(()=>_.find(e=>e.key===a)??null,[_,a]),b=(0,X.useMemo)(()=>p.data?.records??[],[p.data?.records]),x=ve({selectedSession:y,pendingSessionType:n,setPendingSessionType:o,sessionTypesData:f.data}),S=(0,X.useMemo)(()=>ht({modelOptions:h,supportedModels:x.selectedSessionTypeOption?.supportedModels}),[h,x.selectedSessionTypeOption?.supportedModels]),{recentSessionPreferredModel:C,recentSessionPreferredThinking:w}=pt({sessions:_,sessionKey:a,sessionType:x.selectedSessionType}),{supportedThinkingLevels:T,defaultThinkingLevel:E}=mt({currentSelectedModel:t,modelOptions:S});return Ue({modelOptions:S,selectedSessionKey:a??``,selectedSessionExists:!!y,selectedSessionPreferredModel:y?.preferredModel,fallbackPreferredModel:x.selectedSessionTypeOption?.recommendedModel??C,defaultModel:x.selectedSessionTypeOption?.recommendedModel??l.data?.agents.defaults.model,setSelectedModel:s}),Le({supportedThinkingLevels:T,selectedSessionKey:a??``,selectedSessionExists:!!y,selectedSessionPreferredThinking:y?.preferredThinking??null,fallbackPreferredThinking:w??null,defaultThinkingLevel:E,setSelectedThinkingLevel:c}),{configQuery:l,configMetaQuery:u,sessionsQuery:d,sessionTypesQuery:f,sessionSkillsQuery:p,isProviderStateResolved:m,modelOptions:S,sessionSummaries:g,sessions:v,skillRecords:b,selectedSession:y,...x}}function _t(e){return e.parentSessionKey?e.sessionSummaries.map(z).filter(t=>t.parentSessionId===e.parentSessionKey).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>({sessionKey:e.key,parentSessionKey:e.parentSessionId??null,label:e.label??null,agentId:e.agentId??null})):[]}function vt(e){let{availableAgents:t,parentSessionId:n,selectedAgentId:r,selectedSession:i,selectedSessionType:a,sessionKey:o,sessionSummaries:s,sessionTypeOptions:c}=e,l=i?H(i):void 0,u=i?.agentId??r,d=t.find(e=>e.id===u)??null,f=(0,X.useMemo)(()=>{if(!n)return null;let e=s.find(e=>e.sessionId===n)??null;return e?z(e):null},[n,s]),p=c.find(e=>e.value===a)??null;return{currentSessionDisplayName:l,currentAgentId:u,currentAgent:d,parentSession:f,currentSessionTypeLabel:p?.label??V(a),currentSessionTypeIcon:p?.icon??null,currentChildSessionTabs:(0,X.useMemo)(()=>_t({parentSessionKey:o,sessionSummaries:s}),[o,s])}}function yt(e){(0,X.useEffect)(()=>{e.presenter.chatInputManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,defaultSessionType:e.defaultSessionType,canStopGeneration:e.canStopCurrentRun,stopDisabledReason:e.stopDisabledReason,stopSupported:!0,stopReason:void 0,sendError:e.lastSendError,isSending:e.isSending,modelOptions:e.modelOptions,sessionTypeOptions:e.sessionTypeOptions,selectedSessionType:e.selectedSessionType,canEditSessionType:e.canEditSessionType,sessionTypeUnavailable:e.sessionTypeUnavailable,skillRecords:e.skillRecords,isSkillsLoading:e.isSkillsLoading}),e.presenter.chatThreadManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,modelOptions:e.modelOptions,sessionTypeUnavailable:e.sessionTypeUnavailable,sessionTypeUnavailableMessage:e.sessionTypeUnavailableMessage,sessionTypeLabel:e.currentSessionTypeLabel,sessionTypeIcon:e.currentSessionTypeIcon,sessionKey:e.sessionKey??null,agentId:e.currentAgentId,agentDisplayName:e.currentAgent?.displayName??null,agentAvatarUrl:e.currentAgent?.avatarUrl??null,availableAgents:e.availableAgents,sessionDisplayName:e.currentSessionDisplayName,sessionProjectRoot:e.effectiveSessionProjectRoot,sessionProjectName:e.effectiveSessionProjectName,canDeleteSession:!!e.selectedSession,threadRef:e.threadRef,isHistoryLoading:e.agent.isHydrating,messages:e.agent.visibleMessages,isSending:e.isSending,isAwaitingAssistantOutput:e.isAwaitingAssistantOutput,contextWindow:_e(e.agent.snapshot.contextWindow),parentSessionKey:e.parentSession?.key??null,parentSessionLabel:e.parentSession?H(e.parentSession):null,childSessionTabs:e.childSessionTabs})},[e])}function bt(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function xt(e){let t={};e.model?.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),e.thinkingLevel?.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),e.sessionType?.trim()&&(t.session_type=e.sessionType.trim(),t.runtime=e.sessionType.trim()),e.agentId?.trim()&&(t.agent_id=e.agentId.trim());let n=Ee(e.projectRoot);n&&(t.project_root=n);let r=bt(e.requestedSkills);r.length>0&&(t.requested_skill_refs=r);let i=e.composerNodes?Se(e.composerNodes):[];return i.length>0&&(t[ye]=i),t}function St(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r,selectedSessionProjectRoot:i}=e;return t!==null&&n!==null&&r===n&&(i??null)===t}function Ct(e){let t=Y(e=>e.snapshot.query),n=Y(e=>e.snapshot.selectedSessionKey),r=Y(e=>e.snapshot.selectedAgentId),i=I(e=>e.snapshot.pendingSessionType),a=I(e=>e.snapshot.pendingProjectRoot),o=I(e=>e.snapshot.pendingProjectRootSessionKey),s=I(e=>e.snapshot.selectedModel),c=l(),u=we(c),d=R(),{confirm:h,ConfirmDialog:g}=G(),_=p(),v=m(),{sessionId:y}=f(),b=(0,X.useRef)(null),x=(0,X.useRef)(n),S=(0,X.useMemo)(()=>Ve(y),[y]),C=S??void 0,w=a!==null&&(!C||o===C),T=gt({query:t,sessionKey:C??null,projectRootOverride:w?a:void 0,currentSelectedModel:s,pendingSessionType:i,setPendingSessionType:e.chatInputManager.setPendingSessionType,setSelectedModel:e.chatInputManager.setSelectedModel,setSelectedThinkingLevel:e.chatInputManager.setSelectedThinkingLevel});return{presenter:e,selectedSessionKey:n,selectedAgentId:r,pendingProjectRoot:a,pendingProjectRootSessionKey:o,systemStatus:c,isRuntimeBlocked:u,agentsQuery:d,confirm:h,ConfirmDialog:g,location:_,navigate:v,threadRef:b,selectedSessionKeyRef:x,routeSessionKey:S,sessionKey:C,hasSessionProjectRootOverride:w,agent:Ke(C),...T}}function wt(e){let t=Ct(e),{agent:n,agentsQuery:r,hasSessionProjectRootOverride:i,pendingProjectRoot:a,isRuntimeBlocked:o,systemStatus:s,selectedAgentId:c,selectedSession:l,selectedSessionType:u,sessionKey:d,sessionSummaries:f,sessionTypeOptions:p}=t,m=i?a:l?.projectRoot??null,h=i?B(m):l?.projectName??B(m),g=n.hydrateError?.message??n.snapshot.error?.message??null,_=s.phase===`ready`&&Ne(g)?null:g,v=(r.data?.agents?.length??0)>0?r.data?.agents??[]:[{id:l?.agentId??c}],y=vt({sessionKey:d??null,selectedSession:l,selectedAgentId:c,availableAgents:v,parentSessionId:l?.parentSessionId??null,sessionSummaries:f,selectedSessionType:u,sessionTypeOptions:p}),b=n.isRunning||l?.status===`running`;return{...t,availableAgents:v,effectiveSessionProjectRoot:m,effectiveSessionProjectName:h,isSending:n.isSending||b,isAwaitingAssistantOutput:b,canStopCurrentRun:b,stopDisabledReason:b?null:`__preparing__`,lastSendError:o?null:s.phase===`ready`?_:De({message:_,status:s}),...y}}function Tt(e){let{agent:t,pendingProjectRoot:n,pendingProjectRootSessionKey:r,presenter:i,selectedSession:a,selectedSessionKeyRef:o,sessionKey:s}=e;(0,X.useEffect)(()=>{i.chatStreamActionsManager.bind({sendMessage:async e=>{if((e.sessionKey??null)!==(s??null))return;let o=xt({agentId:e.agentId,model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,projectRoot:!e.sessionKey||e.sessionKey===r?n:a?.projectRoot??null,requestedSkills:e.requestedSkills,composerNodes:e.composerNodes}),c=Ae({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:o});if(c)try{let n=await t.send(c);!e.sessionKey&&n?.sessionId&&i.chatSessionListManager.materializeRootSessionRoute(n.sessionId)}catch(t){throw e.restoreDraftOnError&&(e.composerNodes&&e.composerNodes.length>0?i.chatInputManager.restoreComposerState?.(e.composerNodes,e.attachments??[]):i.chatInputManager.setDraft(t=>t.trim().length===0?e.message:t)),t}},stopCurrentRun:async()=>{await t.abort()},resumeRun:async e=>{e.sessionKey===s&&await t.streamRun()},resetStreamState:()=>{o.current=null},applyHistoryMessages:()=>{}})},[t,n,r,i,a?.projectRoot,o,s])}function Et(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,selectedSession:r}=e;(0,X.useEffect)(()=>{!r||!St({pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r.key,selectedSessionProjectRoot:r.projectRoot??null})||I.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[t,n,r])}function Dt(e){let{confirm:t,location:n,navigate:r,presenter:i}=e;(0,X.useEffect)(()=>{i.chatUiManager.syncState({pathname:n.pathname}),i.chatUiManager.bindActions({navigate:r,confirm:t})},[t,n.pathname,r,i])}function Ot(e){let{presenter:t,selectedAgentId:n,selectedSession:r}=e;(0,X.useEffect)(()=>{!r?.agentId||n===r.agentId||t.chatSessionListManager.setSelectedAgentId(r.agentId)},[t,n,r?.agentId])}function kt(e){let{agent:t,presenter:n,routeSessionKey:r}=e,i=t.snapshot.activeRun?.sessionId??t.visibleMessages.find(e=>e.sessionId.trim())?.sessionId??null;(0,X.useEffect)(()=>{r||!i||n.chatSessionListManager.materializeRootSessionRoute(i)},[i,n,r])}function At({view:e}){let[t]=(0,X.useState)(()=>new Me),n=wt(t);return Tt(n),Et(n),Dt(n),Ot(n),kt(n),lt({view:e,routeSessionKey:n.routeSessionKey,selectedSessionKey:n.selectedSessionKey,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,selectedSessionKeyRef:n.selectedSessionKeyRef,resetStreamState:t.chatStreamActionsManager.resetStreamState}),yt({presenter:t,isProviderStateResolved:n.isProviderStateResolved,defaultSessionType:n.defaultSessionType,canStopCurrentRun:n.canStopCurrentRun,stopDisabledReason:n.stopDisabledReason,lastSendError:n.lastSendError,isSending:n.isSending,modelOptions:n.modelOptions,sessionTypeOptions:n.sessionTypeOptions,selectedSessionType:n.selectedSessionType,canEditSessionType:n.canEditSessionType,sessionTypeUnavailable:n.sessionTypeUnavailable,skillRecords:n.skillRecords,isSkillsLoading:n.sessionSkillsQuery.isLoading,sessionTypeUnavailableMessage:n.sessionTypeUnavailableMessage,currentSessionTypeLabel:n.currentSessionTypeLabel,currentSessionTypeIcon:n.currentSessionTypeIcon,sessionKey:n.sessionKey,currentAgentId:n.currentAgentId,currentAgent:n.currentAgent,availableAgents:n.availableAgents,currentSessionDisplayName:n.currentSessionDisplayName,effectiveSessionProjectRoot:n.effectiveSessionProjectRoot,effectiveSessionProjectName:n.effectiveSessionProjectName,selectedSession:n.selectedSession,threadRef:n.threadRef,agent:n.agent,isAwaitingAssistantOutput:n.isAwaitingAssistantOutput,parentSession:n.parentSession,childSessionTabs:n.currentChildSessionTabs}),(0,Z.jsx)(xe,{presenter:t,children:(0,Z.jsx)(ut,{view:e,confirmDialog:(0,Z.jsx)(n.ConfirmDialog,{})})})}function jt({view:e}){return(0,Z.jsx)(At,{view:e})}export{jt as ChatPage};
@@ -0,0 +1,3 @@
1
+ import{_ as e,m as t}from"./i18n-D1144VAA.js";import{t as n}from"./createLucideIcon-DzY6wN61.js";var r=`modulepreload`,i=function(e){return`/`+e},a={},o=function(e,t,n){let o=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),s=document.querySelector(`meta[property=csp-nonce]`),c=s?.nonce||s?.getAttribute(`nonce`);function l(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}o=l(t.map(t=>{if(t=i(t,n),t in a)return;a[t]=!0;let o=t.endsWith(`.css`),s=o?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.href===t&&(!o||r.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${s}`))return;let l=document.createElement(`link`);if(l.rel=o?`stylesheet`:r,o||(l.as=`script`),l.crossOrigin=``,l.href=t,c&&l.setAttribute(`nonce`,c),document.head.appendChild(l),o)return new Promise((e,n)=>{l.addEventListener(`load`,e),l.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function s(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return o.then(t=>{for(let e of t||[])e.status===`rejected`&&s(e.reason);return e().catch(s)})},s=e(t(),1),c=`popstate`;function l(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=h(i?l().pathname:`/`,e,t,n);return f(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:g(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?_(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function u(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return h(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:g(t)}return v(t,n,null,e)}function d(e,t){if(e===!1||e==null)throw Error(t)}function f(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function p(){return Math.random().toString(36).substring(2,10)}function m(e,t){return{usr:e.state,key:e.key,idx:t}}function h(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?_(t):t,state:n,key:t&&t.key||r||p()}}function g({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function _(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function v(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,l=null,u=d();u??(u=0,o.replaceState({...o.state,idx:u},``));function d(){return(o.state||{idx:null}).idx}function f(){s=`POP`;let e=d(),t=e==null?null:e-u;u=e,l&&l({action:s,location:v.location,delta:t})}function p(e,t){s=`PUSH`;let r=h(v.location,e,t);n&&n(r,e),u=d()+1;let c=m(r,u),f=v.createHref(r);try{o.pushState(c,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&l&&l({action:s,location:v.location,delta:1})}function g(e,t){s=`REPLACE`;let r=h(v.location,e,t);n&&n(r,e),u=d();let i=m(r,u),c=v.createHref(r);o.replaceState(i,``,c),a&&l&&l({action:s,location:v.location,delta:0})}function _(e){return y(e)}let v={get action(){return s},get location(){return e(i,o)},listen(e){if(l)throw Error(`A history only accepts one active listener`);return i.addEventListener(c,f),l=e,()=>{i.removeEventListener(c,f),l=null}},createHref(e){return t(i,e)},createURL:_,encodeLocation(e){let t=_(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:p,replace:g,go(e){return o.go(e)}};return v}function y(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),d(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:g(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function b(e,t,n=`/`){return x(e,t,n,!1)}function x(e,t,n,r){let i=D((typeof t==`string`?_(t):t).pathname||`/`,n);if(i==null)return null;let a=C(e);T(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=de(i);o=le(a[e],t,r)}return o}function S(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function C(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;d(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=j([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(d(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),C(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:se(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of w(e.path))a(e,t,!0,n)}),t}function w(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=w(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function T(e){e.sort((e,t)=>e.score===t.score?ce(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ee=/^:[\w-]+$/,te=3,ne=2,re=1,ie=10,ae=-2,oe=e=>e===`*`;function se(e,t){let n=e.split(`/`),r=n.length;return n.some(oe)&&(r+=ae),t&&(r+=ne),n.filter(e=>!oe(e)).reduce((e,t)=>e+(ee.test(t)?te:t===``?re:ie),r)}function ce(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function le(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:j([a,u.pathname]),pathnameBase:ge(j([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=j([a,u.pathnameBase]))}return o}function E(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ue(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ue(e,t=!1,n=!0){f(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function de(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return f(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function D(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var fe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function pe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?_(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?me(n.substring(1),`/`):me(n,t)):a=t,{pathname:a,search:_e(r),hash:ve(i)}}function me(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function O(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function he(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function k(e){let t=he(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function A(e,t,n,r=!1){let i;typeof e==`string`?i=_(e):(i={...e},d(!i.pathname||!i.pathname.includes(`?`),O(`?`,`pathname`,`search`,i)),d(!i.pathname||!i.pathname.includes(`#`),O(`#`,`pathname`,`hash`,i)),d(!i.search||!i.search.includes(`#`),O(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=pe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var j=e=>e.join(`/`).replace(/\/\/+/g,`/`),ge=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),_e=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,ve=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,ye=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function be(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function xe(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Se=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ce(e,t){let n=e;if(typeof n!=`string`||!fe.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Se)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=D(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{f(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var we=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(we);var Te=[`GET`,...we];new Set(Te);var M=s.createContext(null);M.displayName=`DataRouter`;var N=s.createContext(null);N.displayName=`DataRouterState`;var Ee=s.createContext(!1),De=s.createContext({isTransitioning:!1});De.displayName=`ViewTransition`;var Oe=s.createContext(new Map);Oe.displayName=`Fetchers`;var ke=s.createContext(null);ke.displayName=`Await`;var P=s.createContext(null);P.displayName=`Navigation`;var F=s.createContext(null);F.displayName=`Location`;var I=s.createContext({outlet:null,matches:[],isDataRoute:!1});I.displayName=`Route`;var Ae=s.createContext(null);Ae.displayName=`RouteError`;var je=`REACT_ROUTER_ERROR`,Me=`REDIRECT`,Ne=`ROUTE_ERROR_RESPONSE`;function Pe(e){if(e.startsWith(`${je}:${Me}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Fe(e){if(e.startsWith(`${je}:${Ne}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new ye(t.status,t.statusText,t.data)}catch{}}function Ie(e,{relative:t}={}){d(L(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=s.useContext(P),{hash:i,pathname:a,search:o}=B(e,{relative:t}),c=a;return n!==`/`&&(c=a===`/`?n:j([n,a])),r.createHref({pathname:c,search:o,hash:i})}function L(){return s.useContext(F)!=null}function R(){return d(L(),`useLocation() may be used only in the context of a <Router> component.`),s.useContext(F).location}var Le=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Re(e){s.useContext(P).static||s.useLayoutEffect(e)}function z(){let{isDataRoute:e}=s.useContext(I);return e?tt():ze()}function ze(){d(L(),`useNavigate() may be used only in the context of a <Router> component.`);let e=s.useContext(M),{basename:t,navigator:n}=s.useContext(P),{matches:r}=s.useContext(I),{pathname:i}=R(),a=JSON.stringify(k(r)),o=s.useRef(!1);return Re(()=>{o.current=!0}),s.useCallback((r,s={})=>{if(f(o.current,Le),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=A(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:j([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}s.createContext(null);function Be(){let{matches:e}=s.useContext(I),t=e[e.length-1];return t?t.params:{}}function B(e,{relative:t}={}){let{matches:n}=s.useContext(I),{pathname:r}=R(),i=JSON.stringify(k(n));return s.useMemo(()=>A(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ve(e,t){return He(e,t)}function He(e,t,n,r,i){d(L(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=s.useContext(P),{matches:o}=s.useContext(I),c=o[o.length-1],l=c?c.params:{},u=c?c.pathname:`/`,p=c?c.pathnameBase:`/`,m=c&&c.route;{let e=m&&m.path||``;rt(u,!m||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
+
3
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let h=R(),g;if(t){let e=typeof t==`string`?_(t):t;d(p===`/`||e.pathname?.startsWith(p),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${e.pathname}" was given in the \`location\` prop.`),g=e}else g=h;let v=g.pathname||`/`,y=v;if(p!==`/`){let e=p.replace(/^\//,``).split(`/`);y=`/`+v.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let x=b(e,{pathname:y});f(m||x!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),f(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=Je(x&&x.map(e=>Object.assign({},e,{params:Object.assign({},l,e.params),pathname:j([p,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?p:j([p,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&S?s.createElement(F.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...g},navigationType:`POP`}},S):S}function Ue(){let e=et(),t=be(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=s.createElement(s.Fragment,null,s.createElement(`p`,null,`💿 Hey developer 👋`),s.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,s.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,s.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),s.createElement(s.Fragment,null,s.createElement(`h2`,null,`Unexpected Application Error!`),s.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?s.createElement(`pre`,{style:i},n):null,o)}var We=s.createElement(Ue,null),Ge=class extends s.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Fe(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:s.createElement(I.Provider,{value:this.props.routeContext},s.createElement(Ae.Provider,{value:e,children:this.props.component}));return this.context?s.createElement(Ke,{error:e},t):t}};Ge.contextType=Ee;var V=new WeakMap;function Ke({children:e,error:t}){let{basename:n}=s.useContext(P);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Pe(t.digest);if(e){let r=V.get(t);if(r)throw r;let i=Ce(e.location,n);if(Se&&!V.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw V.set(t,n),n}return s.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function qe({routeContext:e,match:t,children:n}){let r=s.useContext(M);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),s.createElement(I.Provider,{value:e},n)}function Je(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);d(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let c=!1,l=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(l=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){c=!0,a=l>=0?a.slice(0,l+1):[a[0]];break}}}let u=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:xe(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let d,f=!1,p=null,m=null;n&&(d=o&&r.route.id?o[r.route.id]:void 0,p=r.route.errorElement||We,c&&(l<0&&i===0?(rt(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):l===i&&(f=!0,m=r.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,i+1)),g=()=>{let t;return t=d?p:f?m:r.route.Component?s.createElement(r.route.Component,null):r.route.element?r.route.element:e,s.createElement(qe,{match:r,routeContext:{outlet:e,matches:h,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?s.createElement(Ge,{location:n.location,revalidation:n.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function H(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ye(e){let t=s.useContext(M);return d(t,H(e)),t}function U(e){let t=s.useContext(N);return d(t,H(e)),t}function Xe(e){let t=s.useContext(I);return d(t,H(e)),t}function W(e){let t=Xe(e),n=t.matches[t.matches.length-1];return d(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ze(){return W(`useRouteId`)}function Qe(){return U(`useNavigation`).navigation}function $e(){let{matches:e,loaderData:t}=U(`useMatches`);return s.useMemo(()=>e.map(e=>S(e,t)),[e,t])}function et(){let e=s.useContext(Ae),t=U(`useRouteError`),n=W(`useRouteError`);return e===void 0?t.errors?.[n]:e}function tt(){let{router:e}=Ye(`useNavigate`),t=W(`useNavigate`),n=s.useRef(!1);return Re(()=>{n.current=!0}),s.useCallback(async(r,i={})=>{f(n.current,Le),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var nt={};function rt(e,t,n){!t&&!nt[e]&&(nt[e]=!0,f(!1,n))}s.useOptimistic,s.memo(it);function it({routes:e,future:t,state:n,onError:r}){return He(e,void 0,n,r,t)}function at({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=s.useRef();a.current??=l({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[c,u]=s.useState({action:o.action,location:o.location}),d=s.useCallback(e=>{i===!1?u(e):s.startTransition(()=>u(e))},[i]);return s.useLayoutEffect(()=>o.listen(d),[o,d]),s.createElement(G,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:o,unstable_useTransitions:i})}function ot({to:e,replace:t,state:n,relative:r}){d(L(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=s.useContext(P);f(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=s.useContext(I),{pathname:o}=R(),c=z(),l=A(e,k(a),o,r===`path`),u=JSON.stringify(l);return s.useEffect(()=>{c(JSON.parse(u),{replace:t,state:n,relative:r})},[c,u,r,t,n]),null}function st(e){d(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function G({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){d(!L(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=s.useMemo(()=>({basename:c,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[c,i,a,o]);typeof n==`string`&&(n=_(n));let{pathname:u=`/`,search:p=``,hash:m=``,state:h=null,key:g=`default`}=n,v=s.useMemo(()=>{let e=D(u,c);return e==null?null:{location:{pathname:e,search:p,hash:m,state:h,key:g},navigationType:r}},[c,u,p,m,h,g,r]);return f(v!=null,`<Router basename="${c}"> is not able to match the URL "${u}${p}${m}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:s.createElement(P.Provider,{value:l},s.createElement(F.Provider,{children:t,value:v}))}function ct({children:e,location:t}){return Ve(K(e),t)}s.Component;function K(e,t=[]){let n=[];return s.Children.forEach(e,(e,r)=>{if(!s.isValidElement(e))return;let i=[...t,r];if(e.type===s.Fragment){n.push.apply(n,K(e.props.children,i));return}d(e.type===st,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),d(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=K(e.props.children,i)),n.push(a)}),n}var q=`get`,J=`application/x-www-form-urlencoded`;function Y(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function lt(e){return Y(e)&&e.tagName.toLowerCase()===`button`}function ut(e){return Y(e)&&e.tagName.toLowerCase()===`form`}function dt(e){return Y(e)&&e.tagName.toLowerCase()===`input`}function ft(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function pt(e,t){return e.button===0&&(!t||t===`_self`)&&!ft(e)}var X=null;function mt(){if(X===null)try{new FormData(document.createElement(`form`),0),X=!1}catch{X=!0}return X}var ht=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function gt(e){return e!=null&&!ht.has(e)?(f(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${J}"`),null):e}function _t(e,t){let n,r,i,a,o;if(ut(e)){let o=e.getAttribute(`action`);r=o?D(o,t):null,n=e.getAttribute(`method`)||q,i=gt(e.getAttribute(`enctype`))||J,a=new FormData(e)}else if(lt(e)||dt(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?D(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||q,i=gt(e.getAttribute(`formenctype`))||gt(o.getAttribute(`enctype`))||J,a=new FormData(o,e),!mt()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Y(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=q,r=null,i=J,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var vt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},yt=/[&><\u2028\u2029]/g;function bt(e){return e.replace(yt,e=>vt[e])}function xt(e,t){if(e===!1||e==null)throw Error(t)}function St(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&D(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function Ct(e,t){if(e.id in t)return t[e.id];try{let n=await o(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function wt(e){return e!=null&&typeof e.page==`string`}function Tt(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Et(e,t,n){return jt((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Ct(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Tt).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Dt(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Ot(e,t,{includeHydrateFallback:n}={}){return kt(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function kt(e){return[...new Set(e)]}function At(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function jt(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!wt(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(At(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Mt(){let e=s.useContext(M);return xt(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Nt(){let e=s.useContext(N);return xt(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Z=s.createContext(void 0);Z.displayName=`FrameworkContext`;function Pt(){let e=s.useContext(Z);return xt(e,`You must render this element inside a <HydratedRouter> element`),e}function Ft(e,t){let n=s.useContext(Z),[r,i]=s.useState(!1),[a,o]=s.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=t,p=s.useRef(null);s.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),s.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,p,{onFocus:Q(c,m),onBlur:Q(l,h),onMouseEnter:Q(u,m),onMouseLeave:Q(d,h),onTouchStart:Q(f,m)}]:[a,p,{}]:[!1,p,{}]}function Q(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function It({page:e,...t}){let{router:n}=Mt(),r=s.useMemo(()=>b(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?s.createElement(Rt,{page:e,matches:r,...t}):null}function Lt(e){let{manifest:t,routeModules:n}=Pt(),[r,i]=s.useState([]);return s.useEffect(()=>{let r=!1;return Et(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Rt({page:e,matches:t,...n}){let r=R(),{future:i,manifest:a,routeModules:o}=Pt(),{basename:c}=Mt(),{loaderData:l,matches:u}=Nt(),d=s.useMemo(()=>Dt(e,t,u,a,r,`data`),[e,t,u,a,r]),f=s.useMemo(()=>Dt(e,t,u,a,r,`assets`),[e,t,u,a,r]),p=s.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,s=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!d.some(t=>t.route.id===e.route.id)&&e.route.id in l&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?s=!0:n.add(e.route.id))}),n.size===0)return[];let u=St(e,c,i.unstable_trailingSlashAwareDataRequests,`data`);return s&&n.size>0&&u.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[u.pathname+u.search]},[c,i.unstable_trailingSlashAwareDataRequests,l,r,a,d,t,e,o]),m=s.useMemo(()=>Ot(f,a),[f,a]),h=Lt(f);return s.createElement(s.Fragment,null,p.map(e=>s.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),m.map(e=>s.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),h.map(({key:e,link:t})=>s.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function zt(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}s.Component;var Bt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Bt&&(window.__reactRouterVersion=`7.13.0`)}catch{}function Vt({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=s.useRef();i.current??=u({window:r,v5Compat:!0});let a=i.current,[o,c]=s.useState({action:a.action,location:a.location}),l=s.useCallback(e=>{n===!1?c(e):s.startTransition(()=>c(e))},[n]);return s.useLayoutEffect(()=>a.listen(l),[a,l]),s.createElement(G,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Ht({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=s.useState({action:n.action,location:n.location}),o=s.useCallback(e=>{r===!1?a(e):s.startTransition(()=>a(e))},[r]);return s.useLayoutEffect(()=>n.listen(o),[n,o]),s.createElement(G,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Ht.displayName=`unstable_HistoryRouter`;var Ut=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Wt=s.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,unstable_useTransitions:g}=s.useContext(P),_=typeof l==`string`&&Ut.test(l),v=Ce(l,h);l=v.to;let y=Ie(l,{relative:r}),[b,x,S]=Ft(n,p),C=Zt(l,{replace:a,state:o,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:g});function w(t){e&&e(t),t.defaultPrevented||C(t)}let T=s.createElement(`a`,{...p,...S,href:v.absoluteURL||y,onClick:v.isExternal||i?e:w,ref:zt(m,x),target:c,"data-discover":!_&&t===`render`?`true`:void 0});return b&&!_?s.createElement(s.Fragment,null,T,s.createElement(It,{page:y})):T});Wt.displayName=`Link`;var Gt=s.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:c,...l},u){let d=B(a,{relative:l.relative}),f=R(),p=s.useContext(N),{navigator:m,basename:h}=s.useContext(P),g=p!=null&&sn(d)&&o===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=D(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let ee=typeof i==`function`?i(C):i;return s.createElement(Wt,{...l,"aria-current":w,className:T,ref:u,style:ee,to:a,viewTransition:o},typeof c==`function`?c(C):c)});Gt.displayName=`NavLink`;var Kt=s.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=q,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},h)=>{let{unstable_useTransitions:g}=s.useContext(P),_=en(),v=tn(c,{relative:u}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof c==`string`&&Ut.test(c);return s.createElement(`form`,{ref:h,method:y,action:v,onSubmit:r?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,c=r?.getAttribute(`formmethod`)||o,m=()=>_(r||e.currentTarget,{fetcherKey:t,method:c,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p});g&&n!==!1?s.startTransition(()=>m()):m()},...m,"data-discover":!b&&e===`render`?`true`:void 0})});Kt.displayName=`Form`;function qt({getKey:e,storageKey:t,...n}){let r=s.useContext(Z),{basename:i}=s.useContext(P),a=R(),o=$e();an({getKey:e,storageKey:t});let c=s.useMemo(()=>{if(!r||!e)return null;let t=rn(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return s.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${bt(JSON.stringify(t||nn))}, ${bt(JSON.stringify(c))})`}})}qt.displayName=`ScrollRestoration`;function Jt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yt(e){let t=s.useContext(M);return d(t,Jt(e)),t}function Xt(e){let t=s.useContext(N);return d(t,Jt(e)),t}function Zt(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=z(),d=R(),f=B(e,{relative:a});return s.useCallback(p=>{if(pt(p,t)){p.preventDefault();let t=n===void 0?g(d)===g(f):n,m=()=>u(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:c});l?s.startTransition(()=>m()):m()}},[d,u,f,n,r,t,e,i,a,o,c,l])}var Qt=0,$t=()=>`__${String(++Qt)}__`;function en(){let{router:e}=Yt(`useSubmit`),{basename:t}=s.useContext(P),n=Ze(),r=e.fetch,i=e.navigate;return s.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=_t(e,t);a.navigate===!1?await r(a.fetcherKey||$t(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function tn(e,{relative:t}={}){let{basename:n}=s.useContext(P),r=s.useContext(I);d(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...B(e||`.`,{relative:t})},o=R();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:j([n,a.pathname])),g(a)}var nn=`react-router-scroll-positions`,$={};function rn(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:D(e.pathname,n)||e.pathname},t)),i??=e.key,i}function an({getKey:e,storageKey:t}={}){let{router:n}=Yt(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Xt(`useScrollRestoration`),{basename:a}=s.useContext(P),o=R(),c=$e(),l=Qe();s.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),on(s.useCallback(()=>{if(l.state===`idle`){let t=rn(o,c,a,e);$[t]=window.scrollY}try{sessionStorage.setItem(t||nn,JSON.stringify($))}catch(e){f(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[l.state,e,a,o,c,t])),typeof document<`u`&&(s.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||nn);e&&($=JSON.parse(e))}catch{}},[t]),s.useLayoutEffect(()=>{let t=n?.enableScrollRestoration($,()=>window.scrollY,e?(t,n)=>rn(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),s.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{f(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function on(e,t){let{capture:n}=t||{};s.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function sn(e,{relative:t}={}){let n=s.useContext(De);d(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Yt(`useViewTransitionState`),i=B(e,{relative:t});if(!n.isTransitioning)return!1;let a=D(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=D(n.nextLocation.pathname,r)||n.nextLocation.pathname;return E(i.pathname,o)!=null||E(i.pathname,a)!=null}var cn=n(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]);export{Gt as a,ct as c,Be as d,o as f,at as i,R as l,Vt as n,ot as o,Wt as r,st as s,cn as t,z as u};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-IRh6LCzu.js","assets/doc-browser-B19cYGxa.js","assets/i18n-D1144VAA.js","assets/createLucideIcon-DzY6wN61.js","assets/search-CRtQwr-h.js","assets/book-open-BcnAiKde.js","assets/external-link-CpEvG65F.js","assets/plus-B-YHtTNC.js","assets/x-BeyYA_h6.js","assets/doc-browser-context-BPeeiNJ_.js"])))=>i.map(i=>d[i]);
2
+ import{_ as e,i as t,m as n,p as r,r as i,u as a}from"./i18n-D1144VAA.js";import{Dt as o,Et as s,Lt as c,Nt as l,Ot as u,Tt as d,bt as f,gt as ee,mt as p,pt as m,wt as h,yt as te}from"./api-rASx2-N4.js";import{a as g,f as _,t as v}from"./cpu-DKc3bQic.js";import{t as y}from"./createLucideIcon-DzY6wN61.js";import{n as ne,t as re}from"./search-CRtQwr-h.js";import{r as ie}from"./doc-browser-B19cYGxa.js";import{t as ae}from"./book-open-BcnAiKde.js";import{i as oe,k as se,n as ce,r as le,t as ue}from"./select-HI5kiwX_.js";import{t as b}from"./download-CMM8po31.js";import{t as de}from"./key-round-DUq47t0P.js";import{h as fe,n as pe}from"./app-manager-provider-CUkcbdWk.js";import{n as me,t as x}from"./settings-MWL2SMyk.js";import{t as he}from"./refresh-cw-CrbD8EkT.js";import{t as ge}from"./sparkles-BmgOD4nY.js";import{t as S}from"./x-BeyYA_h6.js";import{i as _e}from"./doc-browser-context-BPeeiNJ_.js";import{n as ve}from"./doc-browser-CDBYvb8A.js";import{t as ye}from"./use-config-BFqzVF8Y.js";import{n as be,r as xe,t as Se}from"./popover-DeAliE_4.js";var C=y(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),w=y(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),T=y(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),E=y(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),D=y(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Ce=y(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),we=y(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),Te=y(`Plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M9 8V2`,key:`14iosj`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z`,key:`osxo6l`}]]),Ee=y(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),De=y(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Oe=y(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),O=y(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),k=f(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),ke=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}k.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();k.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){k.setState({supported:!0,initialized:!0,busyAction:null}),c.error(`${i(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{k.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(i(`runtimePresenceLaunchAtLoginUnavailable`));k.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return k.setState({supported:!0,initialized:!0,snapshot:n}),c.success(i(`runtimePresenceSaved`)),n}catch(e){throw c.error(`${i(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{k.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:i(`error`)}},A=f(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){A.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{A.setState({supported:!0,initialized:!0,snapshot:e})}),A.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();A.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){A.setState({supported:!0,initialized:!0}),c.error(`${i(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,i(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){c.success(i(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){c.success(i(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??i(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){c.success(i(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&c.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,i(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&c.success(i(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,i(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,i(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(A.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,i(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){c.success(i(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}c.success(i(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(i(`desktopUpdatesDesktopOnlyDescription`));A.setState({busyAction:e});try{let e=await n(r);return A.setState({snapshot:e}),e}catch(e){throw c.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{A.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:i(`error`),this.getChannelLabel=e=>i(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function j(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function M(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)||t===`/agents`||t.startsWith(`/agents/`)}function Ae(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function je(e){return[{target:`/chat`,label:e(`chat`),icon:D},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:T},{target:`/agents`,label:e(`agentsPageTitle`),icon:w},{target:`/settings`,label:e(`settings`),icon:x}]}function Me(e){return[{target:`/model`,label:e(`model`),icon:v},{target:`/providers`,label:e(`providers`),icon:ge},{target:`/channels`,label:e(`channels`),icon:me},{target:`/search`,label:e(`searchChannels`),icon:re},{target:`/runtime`,label:e(`runtime`),icon:v},{target:`/updates`,label:e(`updates`),icon:b},{target:`/remote`,label:e(`remote`),icon:Oe},{target:`/security`,label:e(`security`),icon:Ee},{target:`/secrets`,label:e(`secrets`),icon:de},{target:`/cron`,label:e(`cron`),icon:C},{target:`/marketplace/plugins`,label:e(`marketplaceFilterPlugins`),icon:Te},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:O}]}function N(e){return[{target:`/language`,label:e(`language`),icon:E},...Me(e)]}function Ne(e){let t=e.toLowerCase();return t===`/settings`?!0:N(e=>e).some(e=>j(t,e.target))}function Pe(e,t){let n=e.toLowerCase(),r=N(t);if(Ae(n))return{title:t(`chat`),backTarget:`/chat`,backLabel:t(`chat`)};if(n===`/chat`)return{title:t(`chat`),backTarget:null,backLabel:null};if(n===`/skills`||n.startsWith(`/skills/`))return{title:t(`marketplaceFilterSkills`),backTarget:null,backLabel:null};if(n===`/agents`||n.startsWith(`/agents/`))return{title:t(`agentsPageTitle`),backTarget:null,backLabel:null};if(n===`/settings`)return{title:t(`settings`),backTarget:null,backLabel:null};for(let e of r)if(j(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var Fe=`nextclaw.ui.theme`,P=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],F=`warm`,I=!1,L=new Set;function Ie(e){return e===`warm`||e===`cool`}function R(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function Le(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(Fe);if(Ie(e))return e}catch{}return`warm`}function z(){return I||=(F=Le(),R(F),!0),F}function Re(){return I?F:z()}function ze(e){if(z(),e!==F){if(F=e,R(F),typeof window<`u`)try{window.localStorage.setItem(Fe,F)}catch{}L.forEach(e=>e(F))}}function Be(e){return L.add(e),()=>{L.delete(e)}}var B=r(),Ve={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function He(){let e=ee(),t=e.actionLabel===i(`runtimeStatusRestartAction`),n=async()=>{if(t)try{let e=await te.runRuntimeControlAction(`restart-service`);c.success(e.message)}catch(e){let t=e instanceof Error?e.message:i(`runtimeControlActionFailed`);c.error(`${i(`runtimeControlActionFailed`)}: ${t}`)}};return(0,B.jsxs)(Se,{children:[(0,B.jsx)(xe,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,children:(0,B.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-full`,Ve[e.tone])})})}),(0,B.jsxs)(be,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,B.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,B.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,B.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,B.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:i(`runtimeStatusActionHint`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?i(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}var V=e(n(),1);function H({className:e,density:t=`sidebar`,suffix:n}){let{data:r}=ye(),i=r?.name??`NextClaw`,o=r?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,B.jsx)(He,{}),l=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,u=t===`chrome`;return(0,B.jsxs)(`div`,{className:a(e??`flex min-w-0 items-center gap-2`,l&&`pl-[58px]`),children:[(0,B.jsx)(`div`,{className:a(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,B.jsx)(`img`,{src:`/logo.svg`,alt:i,className:`h-full w-full object-contain`})}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,B.jsx)(`span`,{className:a(`shrink-0 font-semibold text-gray-800`,u?`text-[15px]`:`text-[14px]`),children:i}),s?(0,B.jsx)(Ue,{versionLabel:s,density:t}):null]}),(0,B.jsx)(We,{}),c?(0,B.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Ue({versionLabel:e,density:t}){let[n,r]=(0,V.useState)(!1);return(0,B.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[(0,B.jsx)(`span`,{tabIndex:0,"aria-label":e,className:a(`block min-w-0 truncate font-medium text-gray-500 outline-none`,`text-[12px]`),children:e}),n?(0,B.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function We(){let{supported:e,busyAction:t,snapshot:n}=p();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,B.jsx)(Ge,{snapshot:n}):n.status===`downloaded`?(0,B.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void m.applyDownloadedUpdate(),children:i(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,B.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void m.downloadUpdate(),children:i(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Ge({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,B.jsx)(Ke,{snapshot:e});let t=e.status===`downloading`?qe(e):null;return t?(0,B.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,title:i(`updates`),children:t}):null}function Ke({snapshot:e}){let t=e.status===`failed`?i(`desktopUpdatesStatusFailed`):i(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,a=[t,e.status===`blocked`&&e.blockReason?i(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
3
+ `);return(0,B.jsx)(`span`,{role:`img`,"aria-label":t,title:a,tabIndex:0,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-50 text-[13px] font-bold leading-none text-amber-700 ring-1 ring-amber-100`,children:`!`})}function qe(e){let t=e.progress?.percent;return t==null?i(`desktopUpdatesInlineDownloading`):i(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Je={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function U(e){return Je[e]}function W({to:e,label:t,icon:n,density:r=`default`,className:i}){let o=U(r);return(0,B.jsx)(g,{to:e,className:({isActive:e})=>a(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,i),children:({isActive:e})=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(n,{className:a(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function G({label:e,icon:t,onClick:n,density:r=`default`,className:i,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=U(r);return(0,B.jsxs)(`button`,{type:`button`,onClick:n,className:a(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,i),"data-testid":l,children:[(0,B.jsx)(t,{className:a(d.icon,`shrink-0 text-gray-400`)}),(0,B.jsx)(`span`,{className:a(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,B.jsx)(`span`,{className:a(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function Ye({label:e,icon:t,value:n,valueLabel:r,onValueChange:i,density:o=`default`,children:s}){let c=U(o);return(0,B.jsxs)(ue,{value:n,onValueChange:i,children:[(0,B.jsxs)(oe,{className:a(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,B.jsxs)(`div`,{className:a(`flex min-w-0 items-center`,c.gap),children:[(0,B.jsx)(t,{className:a(c.icon,`text-gray-400`)}),(0,B.jsx)(`span`,{className:`text-left`,children:e})]}),(0,B.jsx)(`span`,{className:a(`ml-auto text-gray-500`,c.value),children:r})]}),(0,B.jsx)(ce,{children:s})]})}var K=`nextclaw-pwa-install-banner-dismissed`,q=`nextclaw-pwa-install-banner-dismissed-until`;function Xe(){let e=J();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:$e(e):!1}function Ze(){let e=J();e?.setItem(K,`1`),e?.removeItem(q)}function Qe(){let e=J();e?.removeItem(K),e?.removeItem(q)}function J(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function $e(e){let t=e.getItem(q);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(q),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(K,`1`),!0)}function et(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Xe(),updateAvailable:!1,registrationFailed:!1}}var Y=f(()=>et()),X=`nextclaw-pwa-dev-sw-reset`,Z=new class{constructor(){this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{let e=await navigator.serviceWorker.register(`/sw.js`);this.registration=e,this.bindRegistration(e),navigator.serviceWorker.addEventListener(`controllerchange`,this.handleControllerChange),await this.syncUpdateAvailability()}catch{Y.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){Y.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;Y.setState({updateAvailable:this.shouldSurfaceUpdate(e)})},this.applyUpdate=async()=>{let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;if(!e){window.location.reload();return}e.waiting||await e.update();let t=e.waiting;if(!t){window.location.reload();return}this.reloadWhenControllerChanges=!0,t.postMessage({type:`SKIP_WAIT`})},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(navigator.serviceWorker.removeEventListener(`controllerchange`,this.handleControllerChange),this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1)},this.bindRegistration=e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&this.syncUpdateAvailability()})})},this.handleControllerChange=()=>{this.reloadWhenControllerChanges&&(this.reloadWhenControllerChanges=!1,window.location.reload())},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.shouldSurfaceUpdate=e=>!e?.waiting||!navigator.serviceWorker.controller?!1:Y.getState().installability===`installed`,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));if(e.length===0){this.clearDevResetMarker();return}if(await Promise.all(e.map(async e=>await e.unregister())),await this.clearNextClawCaches(),navigator.serviceWorker.controller&&!this.hasDevResetMarker()){this.setDevResetMarker(),window.location.reload();return}this.clearDevResetMarker()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))},this.hasDevResetMarker=()=>{try{return window.sessionStorage.getItem(X)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(X,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(X)}catch{}}}},Q=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),Y.setState(et())},this.refreshState=()=>{let e=this.resolveInstallability();Y.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Xe()})),Z.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Ze(),Y.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(Qe(),this.refreshState(),c.success(i(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Qe(),Y.setState({dismissedInstallPrompt:!0}),c.success(i(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function tt(){let e=Y(e=>e.installability);return(0,B.jsx)(`span`,{className:a(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:nt(e)})}function nt(e){return i(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function rt(e,t,n){return i(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function it(){let e=Y(e=>e.installability),t=Y(e=>e.installMethod),n=Y(e=>e.blockedReason);return(0,B.jsxs)(h,{children:[(0,B.jsxs)(o,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(u,{children:i(`pwaInstallTitle`)}),(0,B.jsx)(s,{children:i(`pwaInstallDescription`)})]}),(0,B.jsx)(tt,{})]}),(0,B.jsxs)(d,{className:`space-y-4`,children:[(0,B.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,B.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:rt(e,t,n)})}),e===`available`&&t===`prompt`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsxs)(l,{type:`button`,className:`gap-2`,onClick:()=>{Q.promptInstall()},children:[(0,B.jsx)(b,{className:`h-4 w-4`}),i(`pwaInstallAction`)]}),(0,B.jsx)(`p`,{className:`text-sm text-gray-500`,children:i(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,B.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,B.jsx)(De,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,B.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:i(`pwaInstallManualHint`)})]}):null]})]})}function at(){let e=Y(e=>e.installability),t=Y(e=>e.installMethod),n=Y(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,B.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:i(`pwaInstallBannerTitle`)}),(0,B.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:i(`pwaInstallBannerDescription`)})]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":i(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{Q.dismissInstallPrompt()},children:(0,B.jsx)(S,{className:`h-4 w-4`})})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,B.jsxs)(l,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Q.promptInstall()},children:[(0,B.jsx)(b,{className:`h-4 w-4`}),i(`pwaInstallAction`)]}),(0,B.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Q.dismissInstallPrompt()},children:i(`pwaInstallDismiss`)})]})]})}function ot(){let e=Y(e=>e.updateAvailable),t=Y(e=>e.installability);return!e||t!==`installed`?null:(0,B.jsxs)(`div`,{className:`fixed top-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,B.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:i(`pwaUpdateBannerTitle`)}),(0,B.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:i(`pwaUpdateBannerDescription`)})]})}),(0,B.jsx)(`div`,{className:`mt-4`,children:(0,B.jsxs)(l,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Z.applyUpdate()},children:[(0,B.jsx)(he,{className:`h-4 w-4`}),i(`pwaUpdateAction`)]})})]})}var st=!1;function ct(){st||typeof window>`u`||(st=!0,Q.start(),Z.start())}var lt={warm:`#F9F8F5`,cool:`#F8FAFB`},ut=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=lt[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},dt=(0,V.createContext)(null);function ft({children:e}){let[t,n]=(0,V.useState)(()=>z());(0,V.useEffect)(()=>{ut.syncTheme(t)},[t]),(0,V.useEffect)(()=>Be(e=>{n(e)}),[]);let r=(0,V.useCallback)(e=>{ze(e),n(Re())},[]),i=(0,V.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,B.jsx)(dt.Provider,{value:i,children:e})}function pt(){let e=(0,V.useContext)(dt);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function mt(){let{language:e,setLanguage:n}=ve();return{currentLanguage:e,currentLanguageLabel:t.find(t=>t.value===e)?.label??e,languageOptions:t,selectLanguage:(0,V.useCallback)(t=>{e!==t&&(n(t),window.location.reload())},[e,n])}}function ht(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:r}=mt();return(0,B.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,B.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,B.jsx)(E,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:i(`language`)}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,B.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(t.value),className:a(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,B.jsx)(se,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function gt({mode:e}){let t=pe(),n=_e(),r=fe(),{currentLanguage:o,currentLanguageLabel:s,languageOptions:c,selectLanguage:l}=mt(),{theme:u,setTheme:d}=pt(),f=e===`settings`,ee=i(P.find(e=>e.value===u)?.labelKey??`themeWarm`),p=r.data?.account.email?.trim(),m=!!r.data?.account.loggedIn,h=e=>{u!==e&&d(e)},te=[{target:`/chat`,label:i(`chat`),icon:D},{target:`/chat/cron`,label:i(`cron`),icon:C},{target:`/chat/skills`,label:i(`marketplaceFilterSkills`),icon:T},{target:`/agents`,label:i(`agentsPageTitle`),icon:w}],_=Me(i),v=f?_:te,y=f?`compact`:`default`;return(0,B.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 py-6`,children:[f?(0,B.jsx)(`div`,{className:`shrink-0 px-2 pb-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,B.jsxs)(g,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,B.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,B.jsx)(`span`,{className:`truncate`,children:i(`backToMain`)})]}),(0,B.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,B.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:i(`settings`)})]})}):(0,B.jsx)(`div`,{className:`shrink-0 px-2 pb-8`,children:(0,B.jsx)(H,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,B.jsx)(`ul`,{className:a(f?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:v.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(W,{to:e.target,label:e.label,icon:e.icon,density:y})},e.target))})}),(0,B.jsxs)(`div`,{className:a(`shrink-0 border-t border-[#dde0ea] bg-secondary`,f?`mt-2 pt-3`:`mt-3 pt-3`),children:[f?(0,B.jsx)(G,{onClick:()=>t.accountManager.openAccountPanel(),icon:de,label:i(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:m?p||i(`remoteAccountEntryConnected`):i(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,B.jsx)(`div`,{className:`mb-2`,children:(0,B.jsx)(W,{to:`/settings`,label:i(`settings`),icon:x})}),(0,B.jsx)(`div`,{className:`mb-2`,children:(0,B.jsx)(Ye,{value:u,onValueChange:e=>h(e),icon:we,label:i(`theme`),valueLabel:ee,density:y,children:P.map(e=>(0,B.jsx)(le,{value:e.value,className:`text-xs`,children:i(e.labelKey)},e.value))})}),(0,B.jsx)(`div`,{className:`mb-2`,children:(0,B.jsx)(Ye,{value:o,onValueChange:e=>l(e),icon:E,label:i(`language`),valueLabel:s,density:y,children:c.map(e=>(0,B.jsx)(le,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,B.jsx)(G,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:ae,label:i(`docBrowserHelp`),density:y})]})]})]})}var _t=[{action:`minimize`,label:`Minimize`,icon:Ce},{action:`toggle-maximize`,label:`Maximize`,icon:ie},{action:`close`,label:`Close`,icon:S,variant:`danger`}];function vt(){return(0,B.jsxs)(`header`,{className:`desktop-window-drag relative flex h-[var(--desktop-titlebar-height)] shrink-0 border-b border-[#ebe7dc]/80 bg-secondary`,"data-testid":`desktop-window-chrome`,children:[(0,B.jsx)(`div`,{className:`desktop-window-no-drag absolute left-0 right-0 top-0 h-1`,"data-testid":`desktop-window-chrome-resize-strip`}),(0,B.jsx)(`div`,{className:`desktop-window-no-drag relative z-10 flex h-full w-[var(--desktop-sidebar-width)] shrink-0 items-center bg-secondary pl-4 pr-3 text-secondary-foreground`,"data-testid":`desktop-window-chrome-sidebar`,children:(0,B.jsx)(H,{className:`flex min-w-0 shrink-0 items-center gap-2.5`,density:`chrome`})}),(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`desktop-window-drag h-full min-w-0 flex-1`,"data-testid":`desktop-window-chrome-main-drag-region`}),(0,B.jsx)(`div`,{className:`desktop-window-no-drag absolute right-0 top-0 z-20 flex h-full w-[var(--desktop-caption-safe-right)] items-start justify-end`,"data-testid":`desktop-window-controls`,children:_t.map(e=>(0,B.jsx)(yt,{control:e},e.action))})]})}function yt({control:e}){let t=e.icon;return(0,B.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,className:e.variant===`danger`?`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-red-500 hover:text-white`:`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-black/10`,onClick:()=>{window.nextclawDesktop?.controlWindow?.(e.action)},children:(0,B.jsx)(t,{className:`h-3.5 w-3.5`})})}function $(){return typeof window>`u`?null:St()??window.nextclawDesktop?.platform??null}function bt(){return $()===`darwin`}function xt(){return $()===`win32`}function St(){return null}var Ct=(0,V.lazy)(async()=>({default:(await _(async()=>{let{DocBrowser:e}=await import(`./doc-browser-IRh6LCzu.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function wt(e){return{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":e?`280px`:`240px`}}function Tt({pathname:e,isDocBrowserOpen:t,docBrowserMode:n,children:r}){let i=M(e),o=xt();return(0,B.jsxs)(`div`,{className:a(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,o?`rounded-[10px]`:null),style:o?wt(i):void 0,children:[o?(0,B.jsx)(vt,{}):null,(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!i&&(0,B.jsx)(gt,{mode:`settings`}),(0,B.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,B.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:i?(0,B.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:r}):(0,B.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,B.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:r})})}),t&&n===`docked`?(0,B.jsx)(V.Suspense,{fallback:null,children:(0,B.jsx)(Ct,{})}):null]})]}),t&&n===`floating`?(0,B.jsx)(V.Suspense,{fallback:null,children:(0,B.jsx)(Ct,{})}):null]})}export{C as A,O as C,E as D,D as E,T as O,k as S,Ce as T,Ae as _,ht as a,Pe as b,ct as c,ot as d,W as f,N as g,je as h,xt as i,w as k,at as l,P as m,$ as n,ft as o,H as p,bt as r,pt as s,Tt as t,it as u,M as v,we as w,ke as x,Ne as y};