nextclaw 0.20.5 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/cli/app/index.js +812 -3
  2. package/dist/cli/app/index.js.map +1 -1
  3. package/package.json +16 -16
  4. package/ui-dist/assets/api-BCDb13Uv.js +8 -0
  5. package/ui-dist/assets/app-presenter-provider-C-QMjK7m.js +3 -0
  6. package/ui-dist/assets/arrow-left-rIXFA2Zy.js +1 -0
  7. package/ui-dist/assets/{channels-list-page-BnGxv6ma.js → channels-list-page-DnqwsKGe.js} +6 -6
  8. package/ui-dist/assets/chat-page-CsQx20xL.js +105 -0
  9. package/ui-dist/assets/{config-split-page-CWN2YG9U.js → config-split-page-BwhGqmUS.js} +1 -1
  10. package/ui-dist/assets/confirm-dialog-DBkKcQ1q.js +5 -0
  11. package/ui-dist/assets/{desktop-update-config-abmYzHSy.js → desktop-update-config-BE9KjiXi.js} +1 -1
  12. package/ui-dist/assets/dist-BI0bX8jv.js +1 -0
  13. package/ui-dist/assets/dist-C8JRt-tf.js +1 -0
  14. package/ui-dist/assets/{doc-browser-context-Cb1sEUT0.js → doc-browser-context-VHUOIUXL.js} +1 -1
  15. package/ui-dist/assets/doc-browser-eqdNEerh.js +1 -0
  16. package/ui-dist/assets/doc-browser-lpF_pyx4.js +1 -0
  17. package/ui-dist/assets/ellipsis-C9VB2CxT.js +1 -0
  18. package/ui-dist/assets/es2015-BCw3Q7nY.js +41 -0
  19. package/ui-dist/assets/external-link-Bp7_4s9t.js +1 -0
  20. package/ui-dist/assets/index-BCq7kbC8.css +1 -0
  21. package/ui-dist/assets/{index-Ccbswzt9.js → index-DTdPDqto.js} +12 -12
  22. package/ui-dist/assets/key-round-Ccy6oND3.js +1 -0
  23. package/ui-dist/assets/loader-circle-OpH4EErP.js +1 -0
  24. package/ui-dist/assets/{mcp-marketplace-page-CmUKUeno.js → mcp-marketplace-page-B-GxKOqS.js} +2 -2
  25. package/ui-dist/assets/mcp-marketplace-page-Dm-0-w51.js +1 -0
  26. package/ui-dist/assets/{model-config-Dbo3zWDl.js → model-config-BXPnV_7n.js} +1 -1
  27. package/ui-dist/assets/{notice-card-CFTFtJky.js → notice-card-Dsbkl7u7.js} +1 -1
  28. package/ui-dist/assets/play-CvgYhNbo.js +1 -0
  29. package/ui-dist/assets/plus-DHcP-K1U.js +1 -0
  30. package/ui-dist/assets/popover-BTLZE5Iz.js +1 -0
  31. package/ui-dist/assets/provider-scoped-model-input-DKI9KN7N.js +1 -0
  32. package/ui-dist/assets/providers-list-Bko6B7dE.js +1 -0
  33. package/ui-dist/assets/react-BqS8oMyM.js +8 -0
  34. package/ui-dist/assets/refresh-cw-BIaj7txb.js +1 -0
  35. package/ui-dist/assets/remote-DHn_b8QU.js +1 -0
  36. package/ui-dist/assets/rotate-cw-DMqSkRJQ.js +1 -0
  37. package/ui-dist/assets/{runtime-config-page-Dg8aEgWx.js → runtime-config-page-DX_wSK1J.js} +1 -1
  38. package/ui-dist/assets/save-BEoORten.js +1 -0
  39. package/ui-dist/assets/search-COFh_SFI.js +1 -0
  40. package/ui-dist/assets/{search-config-DAibVFGR.js → search-config-DA5By-tE.js} +1 -1
  41. package/ui-dist/assets/{secrets-config-CoJzy13_.js → secrets-config-eDxG7iN4.js} +1 -1
  42. package/ui-dist/assets/{status-dot-D8xx5ZR8.js → status-dot-oWBjTovo.js} +1 -1
  43. package/ui-dist/assets/{tabs-DxmND60Q.js → tabs-CGaY0BVO.js} +1 -1
  44. package/ui-dist/assets/{tabs-custom-Cjo0bHw8.js → tabs-custom-D2fPYb4G.js} +1 -1
  45. package/ui-dist/assets/{tag-chip-DnNWFRMu.js → tag-chip-TVkgofS1.js} +1 -1
  46. package/ui-dist/assets/tooltip-BwHPKBv9.js +1 -0
  47. package/ui-dist/assets/trash-2-D3psAGrz.js +1 -0
  48. package/ui-dist/assets/x-CHAxzyp2.js +1 -0
  49. package/ui-dist/index.html +25 -24
  50. package/ui-dist/assets/api-BAyyGaoz.js +0 -15
  51. package/ui-dist/assets/app-presenter-provider-DqHHfC1K.js +0 -3
  52. package/ui-dist/assets/arrow-left-Bn-3Pj3p.js +0 -1
  53. package/ui-dist/assets/boxes-ClVuotcz.js +0 -1
  54. package/ui-dist/assets/chat-page-DInyWLb4.js +0 -105
  55. package/ui-dist/assets/confirm-dialog-CVbgKuHp.js +0 -5
  56. package/ui-dist/assets/createLucideIcon-CjPUPAAK.js +0 -1
  57. package/ui-dist/assets/dist-hkrb6Ynt.js +0 -41
  58. package/ui-dist/assets/doc-browser-BlrpUKVJ.js +0 -1
  59. package/ui-dist/assets/doc-browser-kJ2ClG0H.js +0 -1
  60. package/ui-dist/assets/ellipsis-CdkxFkVZ.js +0 -1
  61. package/ui-dist/assets/external-link-CT9_qFwN.js +0 -1
  62. package/ui-dist/assets/index-BGXTR0F_.css +0 -1
  63. package/ui-dist/assets/key-round-xJfR4iRe.js +0 -1
  64. package/ui-dist/assets/loader-circle-BI6HJDg5.js +0 -1
  65. package/ui-dist/assets/mcp-marketplace-page-DH11bSVx.js +0 -1
  66. package/ui-dist/assets/play-DyBWW2j4.js +0 -1
  67. package/ui-dist/assets/plus-BlnBmcKE.js +0 -1
  68. package/ui-dist/assets/popover-DPqa_Mfb.js +0 -1
  69. package/ui-dist/assets/provider-scoped-model-input-C6xL7zSJ.js +0 -1
  70. package/ui-dist/assets/providers-list-DOj_7GL8.js +0 -1
  71. package/ui-dist/assets/react-oAHNoVya.js +0 -1
  72. package/ui-dist/assets/refresh-cw-o8NSmIYV.js +0 -1
  73. package/ui-dist/assets/remote-fCE5fLsj.js +0 -1
  74. package/ui-dist/assets/rotate-cw-DA8EqNAH.js +0 -1
  75. package/ui-dist/assets/save-D4-g0EAq.js +0 -1
  76. package/ui-dist/assets/search-G2cMn3M5.js +0 -1
  77. package/ui-dist/assets/trash-2-C9tc-9sQ.js +0 -1
  78. package/ui-dist/assets/x-DmLl2yG6.js +0 -1
  79. /package/ui-dist/assets/{config-hints-TmNgpFHv.js → config-hints-Ceiol9x4.js} +0 -0
  80. /package/ui-dist/assets/{provider-models-CXUgDxGR.js → provider-models-C_yOh6DE.js} +0 -0
@@ -1,3 +0,0 @@
1
- import{d as e,h as t,i as n,m as r,n as i,o as a,s as o,t as s,v as c}from"./react-oAHNoVya.js";import{At as l,Bt as u,Dt as d,Et as f,Ft as p,Lt as m,Mt as h,Nt as g,Ot as _,Pt as v,Qt as y,Vt as b,a as x,c as S,ct as C,i as ee,jt as te,kt as ne,l as re,o as ie,pt as ae,r as oe,s as se,u as ce,wt as le,zt as w}from"./api-BAyyGaoz.js";import{C as ue,S as de,_ as fe,a as pe,d as me,h as he,i as ge,o as _e,p as ve,r as ye,s as be,t as xe,v as Se,w as T,y as Ce}from"./dist-hkrb6Ynt.js";import{a as we,c as Te,i as Ee,n as De,o as Oe,r as ke,s as Ae,t as je}from"./confirm-dialog-CVbgKuHp.js";import{t as E}from"./createLucideIcon-CjPUPAAK.js";import{t as Me}from"./arrow-left-Bn-3Pj3p.js";import{n as Ne,t as Pe}from"./loader-circle-BI6HJDg5.js";import{t as Fe}from"./boxes-ClVuotcz.js";import{t as Ie}from"./key-round-xJfR4iRe.js";import{t as Le}from"./plus-BlnBmcKE.js";import{t as Re}from"./refresh-cw-o8NSmIYV.js";import{t as ze}from"./trash-2-C9tc-9sQ.js";import{t as Be}from"./x-DmLl2yG6.js";import{t as D}from"./notice-card-CFTFtJky.js";import{t as Ve}from"./status-dot-D8xx5ZR8.js";import{n as He,r as Ue,t as We}from"./popover-DPqa_Mfb.js";import{i as O,r as Ge,t as Ke}from"./tabs-DxmND60Q.js";import{a as k,c as qe,f as Je,g as Ye,h as A,i as Xe,l as Ze,m as Qe,n as $e,o as et,p as tt,r as nt,s as rt,u as it}from"./doc-browser-context-Cb1sEUT0.js";var at=`modulepreload`,ot=function(e){return`/`+e},st={},ct=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ot(t,n),t in st)return;st[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:at,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},j=c(t(),1),lt=`popstate`;function ut(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=mt(i?l().pathname:`/`,e,t,n);return N(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:ht(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`?P(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 dt(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return mt(``,{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:ht(t)}return gt(t,n,null,e)}function M(e,t){if(e===!1||e==null)throw Error(t)}function N(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function ft(){return Math.random().toString(36).substring(2,10)}function pt(e,t){return{usr:e.state,key:e.key,idx:t}}function mt(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?P(t):t,state:n,key:t&&t.key||r||ft()}}function ht({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 P(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 gt(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=mt(h.location,e,t);n&&n(r,e),l=u()+1;let d=pt(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=mt(h.location,e,t);n&&n(r,e),l=u();let i=pt(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return _t(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(lt,d),c=e,()=>{i.removeEventListener(lt,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function _t(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),M(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:ht(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function vt(e,t,n=`/`){return yt(e,t,n,!1)}function yt(e,t,n,r){let i=F((typeof t==`string`?P(t):t).pathname||`/`,n);if(i==null)return null;let a=xt(e);Ct(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=It(i);o=Nt(a[e],t,r)}return o}function bt(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 xt(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;M(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=I([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(M(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),xt(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:jt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of St(e.path))a(e,t,!0,n)}),t}function St(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=St(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 Ct(e){e.sort((e,t)=>e.score===t.score?Mt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var wt=/^:[\w-]+$/,Tt=3,Et=2,Dt=1,Ot=10,kt=-2,At=e=>e===`*`;function jt(e,t){let n=e.split(`/`),r=n.length;return n.some(At)&&(r+=kt),t&&(r+=Et),n.filter(e=>!At(e)).reduce((e,t)=>e+(wt.test(t)?Tt:t===``?Dt:Ot),r)}function Mt(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 Nt(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=Pt({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=Pt({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:I([a,u.pathname]),pathnameBase:Wt(I([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=I([a,u.pathnameBase]))}return o}function Pt(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Ft(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 Ft(e,t=!1,n=!0){N(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 It(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return N(!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 F(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 Lt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Rt(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?P(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?zt(n.substring(1),`/`):zt(n,t)):a=t,{pathname:a,search:Gt(r),hash:Kt(i)}}function zt(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 Bt(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 Vt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Ht(e){let t=Vt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Ut(e,t,n,r=!1){let i;typeof e==`string`?i=P(e):(i={...e},M(!i.pathname||!i.pathname.includes(`?`),Bt(`?`,`pathname`,`search`,i)),M(!i.pathname||!i.pathname.includes(`#`),Bt(`#`,`pathname`,`hash`,i)),M(!i.search||!i.search.includes(`#`),Bt(`#`,`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=Rt(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var I=e=>e.join(`/`).replace(/\/\/+/g,`/`),Wt=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Gt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Kt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,qt=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 Jt(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Yt(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Xt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Zt(e,t){let n=e;if(typeof n!=`string`||!Lt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Xt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=F(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{N(!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 Qt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Qt);var $t=[`GET`,...Qt];new Set($t);var en=j.createContext(null);en.displayName=`DataRouter`;var tn=j.createContext(null);tn.displayName=`DataRouterState`;var nn=j.createContext(!1),rn=j.createContext({isTransitioning:!1});rn.displayName=`ViewTransition`;var an=j.createContext(new Map);an.displayName=`Fetchers`;var on=j.createContext(null);on.displayName=`Await`;var L=j.createContext(null);L.displayName=`Navigation`;var sn=j.createContext(null);sn.displayName=`Location`;var R=j.createContext({outlet:null,matches:[],isDataRoute:!1});R.displayName=`Route`;var cn=j.createContext(null);cn.displayName=`RouteError`;var ln=`REACT_ROUTER_ERROR`,un=`REDIRECT`,dn=`ROUTE_ERROR_RESPONSE`;function fn(e){if(e.startsWith(`${ln}:${un}:{`))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 pn(e){if(e.startsWith(`${ln}:${dn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new qt(t.status,t.statusText,t.data)}catch{}}function mn(e,{relative:t}={}){M(z(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=j.useContext(L),{hash:i,pathname:a,search:o}=bn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:I([n,a])),r.createHref({pathname:s,search:o,hash:i})}function z(){return j.useContext(sn)!=null}function B(){return M(z(),`useLocation() may be used only in the context of a <Router> component.`),j.useContext(sn).location}var hn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function gn(e){j.useContext(L).static||j.useLayoutEffect(e)}function _n(){let{isDataRoute:e}=j.useContext(R);return e?zn():vn()}function vn(){M(z(),`useNavigate() may be used only in the context of a <Router> component.`);let e=j.useContext(en),{basename:t,navigator:n}=j.useContext(L),{matches:r}=j.useContext(R),{pathname:i}=B(),a=JSON.stringify(Ht(r)),o=j.useRef(!1);return gn(()=>{o.current=!0}),j.useCallback((r,s={})=>{if(N(o.current,hn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Ut(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:I([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}j.createContext(null);function yn(){let{matches:e}=j.useContext(R),t=e[e.length-1];return t?t.params:{}}function bn(e,{relative:t}={}){let{matches:n}=j.useContext(R),{pathname:r}=B(),i=JSON.stringify(Ht(n));return j.useMemo(()=>Ut(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function xn(e,t){return Sn(e,t)}function Sn(e,t,n,r,i){M(z(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=j.useContext(L),{matches:o}=j.useContext(R),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;Vn(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (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 f=B(),p;if(t){let e=typeof t==`string`?P(t):t;M(u===`/`||e.pathname?.startsWith(u),`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 "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),p=e}else p=f;let m=p.pathname||`/`,h=m;if(u!==`/`){let e=u.replace(/^\//,``).split(`/`);h=`/`+m.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let g=vt(e,{pathname:h});N(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),N(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.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 _=kn(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:I([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:I([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?j.createElement(sn.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function Cn(){let e=Rn(),t=Jt(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=j.createElement(j.Fragment,null,j.createElement(`p`,null,`💿 Hey developer 👋`),j.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,j.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,j.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),j.createElement(j.Fragment,null,j.createElement(`h2`,null,`Unexpected Application Error!`),j.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?j.createElement(`pre`,{style:i},n):null,o)}var wn=j.createElement(Cn,null),Tn=class extends j.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=pn(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:j.createElement(R.Provider,{value:this.props.routeContext},j.createElement(cn.Provider,{value:e,children:this.props.component}));return this.context?j.createElement(Dn,{error:e},t):t}};Tn.contextType=nn;var En=new WeakMap;function Dn({children:e,error:t}){let{basename:n}=j.useContext(L);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=fn(t.digest);if(e){let r=En.get(t);if(r)throw r;let i=Zt(e.location,n);if(Xt&&!En.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 En.set(t,n),n}return j.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function On({routeContext:e,match:t,children:n}){let r=j.useContext(en);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),j.createElement(R.Provider,{value:e},n)}function kn(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);M(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 s=!1,c=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=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){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}let l=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Yt(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let u,d=!1,f=null,p=null;n&&(u=o&&r.route.id?o[r.route.id]:void 0,f=r.route.errorElement||wn,s&&(c<0&&i===0?(Vn(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):c===i&&(d=!0,p=r.route.hydrateFallbackElement||null)));let m=t.concat(a.slice(0,i+1)),h=()=>{let t;return t=u?f:d?p:r.route.Component?j.createElement(r.route.Component,null):r.route.element?r.route.element:e,j.createElement(On,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?j.createElement(Tn,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function An(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function jn(e){let t=j.useContext(en);return M(t,An(e)),t}function Mn(e){let t=j.useContext(tn);return M(t,An(e)),t}function Nn(e){let t=j.useContext(R);return M(t,An(e)),t}function Pn(e){let t=Nn(e),n=t.matches[t.matches.length-1];return M(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Fn(){return Pn(`useRouteId`)}function In(){return Mn(`useNavigation`).navigation}function Ln(){let{matches:e,loaderData:t}=Mn(`useMatches`);return j.useMemo(()=>e.map(e=>bt(e,t)),[e,t])}function Rn(){let e=j.useContext(cn),t=Mn(`useRouteError`),n=Pn(`useRouteError`);return e===void 0?t.errors?.[n]:e}function zn(){let{router:e}=jn(`useNavigate`),t=Pn(`useNavigate`),n=j.useRef(!1);return gn(()=>{n.current=!0}),j.useCallback(async(r,i={})=>{N(n.current,hn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Bn={};function Vn(e,t,n){!t&&!Bn[e]&&(Bn[e]=!0,N(!1,n))}j.useOptimistic,j.memo(Hn);function Hn({routes:e,future:t,state:n,onError:r}){return Sn(e,void 0,n,r,t)}function Un({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=j.useRef();a.current??=ut({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[s,c]=j.useState({action:o.action,location:o.location}),l=j.useCallback(e=>{i===!1?c(e):j.startTransition(()=>c(e))},[i]);return j.useLayoutEffect(()=>o.listen(l),[o,l]),j.createElement(Kn,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,unstable_useTransitions:i})}function Wn({to:e,replace:t,state:n,relative:r}){M(z(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=j.useContext(L);N(!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}=j.useContext(R),{pathname:o}=B(),s=_n(),c=Ut(e,Ht(a),o,r===`path`),l=JSON.stringify(c);return j.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Gn(e){M(!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 Kn({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){M(!z(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=j.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=P(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=j.useMemo(()=>{let e=F(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p},navigationType:r}},[s,l,u,d,f,p,r]);return N(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:j.createElement(L.Provider,{value:c},j.createElement(sn.Provider,{children:t,value:m}))}function qn({children:e,location:t}){return xn(Jn(e),t)}j.Component;function Jn(e,t=[]){let n=[];return j.Children.forEach(e,(e,r)=>{if(!j.isValidElement(e))return;let i=[...t,r];if(e.type===j.Fragment){n.push.apply(n,Jn(e.props.children,i));return}M(e.type===Gn,`[${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>`),M(!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=Jn(e.props.children,i)),n.push(a)}),n}var Yn=`get`,Xn=`application/x-www-form-urlencoded`;function Zn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Qn(e){return Zn(e)&&e.tagName.toLowerCase()===`button`}function $n(e){return Zn(e)&&e.tagName.toLowerCase()===`form`}function er(e){return Zn(e)&&e.tagName.toLowerCase()===`input`}function tr(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function nr(e,t){return e.button===0&&(!t||t===`_self`)&&!tr(e)}var rr=null;function ir(){if(rr===null)try{new FormData(document.createElement(`form`),0),rr=!1}catch{rr=!0}return rr}var ar=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function or(e){return e!=null&&!ar.has(e)?(N(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Xn}"`),null):e}function sr(e,t){let n,r,i,a,o;if($n(e)){let o=e.getAttribute(`action`);r=o?F(o,t):null,n=e.getAttribute(`method`)||Yn,i=or(e.getAttribute(`enctype`))||Xn,a=new FormData(e)}else if(Qn(e)||er(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?F(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Yn,i=or(e.getAttribute(`formenctype`))||or(o.getAttribute(`enctype`))||Xn,a=new FormData(o,e),!ir()){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(Zn(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Yn,r=null,i=Xn,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 cr={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},lr=/[&><\u2028\u2029]/g;function ur(e){return e.replace(lr,e=>cr[e])}function dr(e,t){if(e===!1||e==null)throw Error(t)}function fr(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&&F(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function pr(e,t){if(e.id in t)return t[e.id];try{let n=await ct(()=>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 mr(e){return e!=null&&typeof e.page==`string`}function hr(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 gr(e,t,n){return xr((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await pr(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(hr).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function _r(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 vr(e,t,{includeHydrateFallback:n}={}){return yr(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 yr(e){return[...new Set(e)]}function br(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function xr(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!mr(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(br(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Sr(){let e=j.useContext(en);return dr(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Cr(){let e=j.useContext(tn);return dr(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var wr=j.createContext(void 0);wr.displayName=`FrameworkContext`;function Tr(){let e=j.useContext(wr);return dr(e,`You must render this element inside a <HydratedRouter> element`),e}function Er(e,t){let n=j.useContext(wr),[r,i]=j.useState(!1),[a,o]=j.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=j.useRef(null);j.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),j.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Dr(s,p),onBlur:Dr(c,m),onMouseEnter:Dr(l,p),onMouseLeave:Dr(u,m),onTouchStart:Dr(d,p)}]:[a,f,{}]:[!1,f,{}]}function Dr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Or({page:e,...t}){let{router:n}=Sr(),r=j.useMemo(()=>vt(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?j.createElement(Ar,{page:e,matches:r,...t}):null}function kr(e){let{manifest:t,routeModules:n}=Tr(),[r,i]=j.useState([]);return j.useEffect(()=>{let r=!1;return gr(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Ar({page:e,matches:t,...n}){let r=B(),{future:i,manifest:a,routeModules:o}=Tr(),{basename:s}=Sr(),{loaderData:c,matches:l}=Cr(),u=j.useMemo(()=>_r(e,t,l,a,r,`data`),[e,t,l,a,r]),d=j.useMemo(()=>_r(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=j.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=fr(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=j.useMemo(()=>vr(d,a),[d,a]),m=kr(d);return j.createElement(j.Fragment,null,f.map(e=>j.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>j.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>j.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function jr(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}j.Component;var Mr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Mr&&(window.__reactRouterVersion=`7.13.0`)}catch{}function Nr({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=j.useRef();i.current??=dt({window:r,v5Compat:!0});let a=i.current,[o,s]=j.useState({action:a.action,location:a.location}),c=j.useCallback(e=>{n===!1?s(e):j.startTransition(()=>s(e))},[n]);return j.useLayoutEffect(()=>a.listen(c),[a,c]),j.createElement(Kn,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Pr({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=j.useState({action:n.action,location:n.location}),o=j.useCallback(e=>{r===!1?a(e):j.startTransition(()=>a(e))},[r]);return j.useLayoutEffect(()=>n.listen(o),[n,o]),j.createElement(Kn,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Pr.displayName=`unstable_HistoryRouter`;var Fr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ir=j.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u,unstable_defaultShouldRevalidate:d,...f},p){let{basename:m,unstable_useTransitions:h}=j.useContext(L),g=typeof c==`string`&&Fr.test(c),_=Zt(c,m);c=_.to;let v=mn(c,{relative:r}),[y,b,x]=Er(n,f),S=Ur(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function C(t){e&&e(t),t.defaultPrevented||S(t)}let ee=j.createElement(`a`,{...f,...x,href:_.absoluteURL||v,onClick:_.isExternal||i?e:C,ref:jr(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?j.createElement(j.Fragment,null,ee,j.createElement(Or,{page:v})):ee});Ir.displayName=`Link`;var Lr=j.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=bn(a,{relative:c.relative}),d=B(),f=j.useContext(tn),{navigator:p,basename:m}=j.useContext(L),h=f!=null&&$r(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=F(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,ee;ee=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let te=typeof i==`function`?i(S):i;return j.createElement(Ir,{...c,"aria-current":C,className:ee,ref:l,style:te,to:a,viewTransition:o},typeof s==`function`?s(S):s)});Lr.displayName=`NavLink`;var Rr=j.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Yn,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=j.useContext(L),g=Kr(),_=qr(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Fr.test(s);return j.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?j.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Rr.displayName=`Form`;function zr({getKey:e,storageKey:t,...n}){let r=j.useContext(wr),{basename:i}=j.useContext(L),a=B(),o=Ln();Zr({getKey:e,storageKey:t});let s=j.useMemo(()=>{if(!r||!e)return null;let t=Xr(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((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 j.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${ur(JSON.stringify(t||Jr))}, ${ur(JSON.stringify(s))})`}})}zr.displayName=`ScrollRestoration`;function Br(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Vr(e){let t=j.useContext(en);return M(t,Br(e)),t}function Hr(e){let t=j.useContext(tn);return M(t,Br(e)),t}function Ur(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=_n(),u=B(),d=bn(e,{relative:a});return j.useCallback(f=>{if(nr(f,t)){f.preventDefault();let t=n===void 0?ht(u)===ht(d):n,p=()=>l(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s});c?j.startTransition(()=>p()):p()}},[u,l,d,n,r,t,e,i,a,o,s,c])}var Wr=0,Gr=()=>`__${String(++Wr)}__`;function Kr(){let{router:e}=Vr(`useSubmit`),{basename:t}=j.useContext(L),n=Fn(),r=e.fetch,i=e.navigate;return j.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=sr(e,t);a.navigate===!1?await r(a.fetcherKey||Gr(),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 qr(e,{relative:t}={}){let{basename:n}=j.useContext(L),r=j.useContext(R);M(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...bn(e||`.`,{relative:t})},o=B();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:I([n,a.pathname])),ht(a)}var Jr=`react-router-scroll-positions`,Yr={};function Xr(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:F(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Zr({getKey:e,storageKey:t}={}){let{router:n}=Vr(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Hr(`useScrollRestoration`),{basename:a}=j.useContext(L),o=B(),s=Ln(),c=In();j.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Qr(j.useCallback(()=>{if(c.state===`idle`){let t=Xr(o,s,a,e);Yr[t]=window.scrollY}try{sessionStorage.setItem(t||Jr,JSON.stringify(Yr))}catch(e){N(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(j.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Jr);e&&(Yr=JSON.parse(e))}catch{}},[t]),j.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Yr,()=>window.scrollY,e?(t,n)=>Xr(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),j.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{N(!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 Qr(e,t){let{capture:n}=t||{};j.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function $r(e,{relative:t}={}){let n=j.useContext(rn);M(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Vr(`useViewTransitionState`),i=bn(e,{relative:t});if(!n.isTransitioning)return!1;let a=F(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=F(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Pt(i.pathname,o)!=null||Pt(i.pathname,a)!=null}var ei=E(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),ti=E(`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`}]]),ni=E(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ri=E(`CircleDashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),ii=E(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ai=E(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),oi=E(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),si=E(`Grid3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ci=E(`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`}]]),li=E(`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`}]]),ui=E(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),di=E(`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`}]]),fi=E(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),pi=E(`ShieldAlert`,[[`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:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),mi=E(`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`}]]),hi=E(`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`}]]),gi=E(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),_i=E(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),vi=E(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),yi=E(`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`}]]);function bi(){return b({queryKey:Si,queryFn:x,staleTime:5e3,refetchOnWindowFocus:!0})}var V=r();function H(e){let{label:t,muted:n,value:r}=e;return(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,V.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function xi(){let e=$s(),t=bi(),r=t.data,a=W(e=>e.actionLabel),o=(0,j.useMemo)(()=>Pi(r),[r]),s=!!a,c=r?.runtime?.deviceName?.trim()||r?.settings.deviceName?.trim()||n(`remoteDeviceNameAuto`),u=!!(r?.account.loggedIn&&Oi(r)),{hero:m,issueHint:g}=o;return(0,j.useEffect)(()=>{e.remoteAccessManager.syncStatus(r)},[e,r]),t.isLoading&&!r?(0,V.jsx)(`div`,{className:`p-8 text-gray-400`,children:n(`remoteLoading`)}):(0,V.jsxs)(h,{className:`space-y-6`,children:[(0,V.jsx)(te,{title:n(`remotePageTitle`),description:n(`remotePageDescription`)}),(0,V.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,V.jsxs)(f,{children:[(0,V.jsxs)(ne,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,V.jsx)(l,{children:m.title}),(0,V.jsx)(Ve,{status:m.badgeStatus,label:m.badgeLabel})]}),(0,V.jsx)(_,{children:m.description})]}),(0,V.jsxs)(d,{className:`space-y-5`,children:[(0,V.jsxs)(D,{tone:`neutral`,children:[(0,V.jsx)(H,{label:n(`remoteSignedInAccount`),value:r?.account.email}),(0,V.jsx)(H,{label:n(`remoteDeviceName`),value:c}),(0,V.jsx)(H,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,V.jsx)(H,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[o.primaryAction?(0,V.jsxs)(p,{onClick:()=>{if(o.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(r);return}if(o.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(r);return}e.remoteAccessManager.enableRemoteAccess(r)},disabled:s,children:[o.primaryAction.showRefreshIcon?(0,V.jsx)(di,{className:`mr-2 h-4 w-4`}):null,a||o.primaryAction.label]}):null,(0,V.jsxs)(p,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:s||!u,children:[(0,V.jsx)(hi,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),r?.settings.enabled?(0,V.jsx)(p,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(r),disabled:s,children:n(`remoteDisable`)}):null]}),o.shouldShowIssueHint&&g?(0,V.jsx)(D,{tone:`warning`,title:g.title,description:g.body}):null,(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteOpenWebHint`)})]})]}),(0,V.jsxs)(f,{children:[(0,V.jsxs)(ne,{children:[(0,V.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,V.jsx)(ci,{className:`h-4 w-4 text-primary`}),n(`remoteDeviceSectionTitle`)]}),(0,V.jsx)(_,{children:n(`remoteDeviceSectionDescription`)})]}),(0,V.jsxs)(d,{className:`space-y-5`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(Ve,{status:r?.account.loggedIn?`ready`:`inactive`,label:r?.account.loggedIn?n(`remoteAccountConnected`):n(`remoteAccountNotConnected`)}),(0,V.jsx)(Ve,{status:r?.settings.enabled?`active`:`inactive`,label:r?.settings.enabled?n(`remoteEnabled`):n(`remoteStateDisabled`)}),(0,V.jsx)(Ve,{status:r?.service.running?`active`:`inactive`,label:r?.service.running?n(`remoteServiceRunning`):n(`remoteServiceStopped`)})]}),(0,V.jsxs)(D,{tone:`neutral`,children:[(0,V.jsx)(H,{label:n(`remoteDeviceName`),value:c}),(0,V.jsx)(H,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,V.jsx)(H,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,V.jsx)(D,{tone:`neutral`,borderStyle:`dashed`,description:r?.account.loggedIn?n(`remoteOpenWebHint`):n(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var Si=[`remote-status`],Ci=`https://platform.nextclaw.io`,wi=`https://nextclaw-platform-console.pages.dev`,Ti=async()=>await m.fetchQuery({queryKey:Si,queryFn:x,staleTime:5e3}),U=async()=>(await m.invalidateQueries({queryKey:Si}),await Ti()),Ei=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function Di(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 Ci;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return wi}var Oi=e=>Di(e?.account.apiBase)||Di(e?.settings.platformApiBase)||Di(e?.platformBase)||Di(e?.account.platformBase)||void 0,W=s(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})})),ki=class{constructor(e){this.params=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 U(),n=W.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await U();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await U(),r=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:n(r===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await oe(r);let e=await U();this.hydrateDraftFromStatus(e)},successMessage:n(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await U(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:W.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await U(),r=W.getState();await this.runManagedAction({actionLabel:n(`remoteActionSavingAdvanced`),job:async()=>{await ce({enabled:r.enabled,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let e=await U();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===r.enabled?n(`remoteSettingsSaved`):n(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:n(`remoteDoctorRunning`),job:async()=>{let e=await ee();W.getState().setDoctor(e)},successMessage:n(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,n(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,n(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,n(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let r=W.getState();await this.runManagedAction({actionLabel:n(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await ce({enabled:e,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let n=await U();this.hydrateDraftFromStatus(n),e?await oe(n.service.running?`restart`:`start`):t.service.running&&await oe(`restart`);let i=await U();this.hydrateDraftFromStatus(i)},successMessage:n(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.ensureRemoteAccount=async(e,t)=>e.account.loggedIn?e:await this.params.accountManager.ensureSignedIn({apiBase:t,status:e}),this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await oe(e),n=await U();this.hydrateDraftFromStatus(n),w.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=>{let{actionLabel:t,job:r,successMessage:i}=e;W.getState().beginAction(t);try{await r(),i&&w.success(i)}catch(e){let t=e instanceof Error?e.message:n(`error`);throw w.error(t),e}finally{W.getState().finishAction()}}}},Ai=[/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 ji(e){return e?.runtime?.lastError?.trim()||``}function Mi(e){let t=n(`remoteStatusIssueDetailGeneric`),r=ji(e);return r?`${t} (${r})`:t}function Ni(e){if(!e?.settings.enabled)return!1;let t=ji(e);return Ai.some(e=>e.test(t))}function Pi(e){return Ni(e)?{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateReauthorizationRequired`),title:n(`remoteStatusReauthorizationTitle`),description:n(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:n(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:n(`statusReady`),title:n(`remoteStatusReadyTitle`),description:n(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:n(`connecting`),title:n(`remoteStatusConnectingTitle`),description:n(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateDisconnected`),title:n(`remoteStatusIssueTitle`),description:n(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:Mi(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteServiceStopped`),title:n(`remoteStatusNeedsServiceTitle`),description:n(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:n(`statusInactive`),title:n(`remoteStatusNeedsEnable`),description:n(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:n(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:n(`statusSetup`),title:n(`remoteStatusNeedsSignIn`),description:n(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:n(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var G=s(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),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 Fi({label:e,value:t}){return(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,V.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Ii(e){let{email:t,username:r,role:i,canSubmitUsername:a,savingUsername:o,usernameDraft:s,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:u,onLogout:d}=e;return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(D,{tone:`success`,title:n(`accountPanelSignedInTitle`),description:n(`accountPanelSignedInDescription`)}),(0,V.jsxs)(D,{tone:`neutral`,children:[(0,V.jsx)(Fi,{label:n(`remoteAccountEmail`),value:t}),(0,V.jsx)(Fi,{label:n(`remoteAccountUsername`),value:r}),(0,V.jsx)(Fi,{label:n(`remoteAccountRole`),value:i})]}),r?(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteAccountUsernameLockedHelp`)}):(0,V.jsxs)(D,{tone:`warning`,title:n(`remoteAccountUsernameRequiredTitle`),description:n(`remoteAccountUsernameRequiredDescription`),children:[(0,V.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,V.jsx)(g,{htmlFor:`account-panel-username`,children:n(`remoteAccountUsername`)}),(0,V.jsx)(v,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:n(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,V.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,V.jsx)(p,{disabled:!a,onClick:()=>void l(),children:n(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,V.jsxs)(p,{onClick:()=>void u(),children:[(0,V.jsx)(hi,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),(0,V.jsxs)(p,{variant:`outline`,onClick:()=>void d(),children:[(0,V.jsx)(li,{className:`mr-2 h-4 w-4`}),n(`remoteLogout`)]})]})]})}function Li(e){let{authSessionId:t,authExpiresAt:r,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(D,{tone:`neutral`,title:n(`accountPanelSignedOutTitle`),description:n(`accountPanelSignedOutDescription`),children:t?(0,V.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,V.jsx)(Fi,{label:n(`remoteBrowserAuthSession`),value:t}),(0,V.jsx)(Fi,{label:n(`remoteBrowserAuthExpiresAt`),value:r?i(r):`-`})]}):null}),a?(0,V.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,V.jsx)(p,{onClick:()=>void s(),children:n(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,V.jsx)(p,{variant:`outline`,onClick:c,children:n(`remoteBrowserAuthResume`)}):null]})]})}function Ri(){let e=$s(),t=bi(),r=G(e=>e.panelOpen),i=G(e=>e.authSessionId),a=G(e=>e.authVerificationUri),o=G(e=>e.authExpiresAt),s=G(e=>e.authStatusMessage),c=t.data,[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(!1);(0,j.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,V.jsx)(De,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,V.jsxs)(ke,{className:`max-w-xl`,children:[(0,V.jsxs)(Oe,{children:[(0,V.jsxs)(Ae,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Ie,{className:`h-5 w-5 text-primary`}),n(`accountPanelTitle`)]}),(0,V.jsx)(Ee,{children:n(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,V.jsx)(Ii,{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,V.jsx)(Li,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function zi({username:e}){let t=ae(),[r,i]=(0,j.useState)(e??``),[a,o]=(0,j.useState)(``),s=r.trim().length>0&&a.length>0&&!t.isPending;return(0,V.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,V.jsxs)(f,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,V.jsxs)(ne,{children:[(0,V.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:n(`authBrand`)}),(0,V.jsx)(l,{className:`text-2xl`,children:n(`authLoginTitle`)}),(0,V.jsx)(_,{children:n(`authLoginDescription`)})]}),(0,V.jsx)(d,{children:(0,V.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),s&&t.mutate({username:r.trim(),password:a})},children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authUsername`)}),(0,V.jsx)(v,{value:r,onChange:e=>i(e.target.value),placeholder:n(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authPassword`)}),(0,V.jsx)(v,{type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:n(`authPasswordPlaceholder`)})]}),(0,V.jsx)(p,{type:`submit`,className:`w-full`,disabled:!s,children:t.isPending?n(`authLoggingIn`):n(`authLoginAction`)})]})})]})})}var Bi=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{G.getState().openPanel()},this.closeAccountPanel=()=>{G.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),G.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await Ti();return t.account.loggedIn?t:(this.openAccountPanel(),await this.startBrowserSignInAndWait({apiBase:e?.apiBase,status:t}))},this.startBrowserSignInAndWait=async e=>{let t=this.createBrowserSignInCompletion();return await this.startBrowserSignIn(e),await t},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,r=await S({apiBase:Ei(e?.status??await Ti(),t)});G.getState().beginBrowserAuth({sessionId:r.sessionId,verificationUri:r.verificationUri,expiresAt:r.expiresAt,intervalMs:r.intervalMs,statusMessage:n(`remoteBrowserAuthWaiting`)}),window.open(r.verificationUri,`_blank`,`noopener,noreferrer`)||G.getState().setAuthStatusMessage(n(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:n(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),w.error(`${n(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=G.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await ie(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),G.getState().clearBrowserAuth(),await U(),w.success(n(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteLogoutFailed`);w.error(`${n(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await re({username:e.trim()}),await U(),w.success(n(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteAccountUsernameSetFailed`);w.error(`${n(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=Oi(await Ti());if(!t){w.error(n(`remoteOpenWebUnavailable`));return}let r=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(r,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=G.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=G.getState();if(e.authSessionId)try{let t=await Ti(),r=await se({sessionId:e.authSessionId,apiBase:Ei(t)});if(r.status===`pending`){G.getState().updateBrowserAuth({statusMessage:n(`remoteBrowserAuthWaiting`),intervalMs:r.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(r.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(r.message||n(`remoteBrowserAuthExpired`))),G.getState().clearBrowserAuth(),w.error(r.message||n(`remoteBrowserAuthExpired`));return}G.getState().setAuthStatusMessage(n(`remoteBrowserAuthCompleted`));let i=await U();this.clearPollTimer(),this.resolveBrowserSignIn(i),G.getState().clearBrowserAuth(),w.success(n(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),G.getState().clearBrowserAuth();let t=e instanceof Error?e.message:n(`remoteBrowserAuthPollFailed`);w.error(`${n(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.createBrowserSignInCompletion=()=>(this.rejectBrowserSignIn(Error(`Browser sign-in was replaced by a newer request.`)),new Promise((e,t)=>{this.browserSignInCompletion={resolve:e,reject:t}})),this.resolveBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.resolve(e))},this.rejectBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.reject(e instanceof Error?e:Error(String(e))))},this.getBrowserAuthSummary=()=>{let e=G.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}};function Vi({deletePending:e,entry:t,favoritePending:r,onDelete:i,onOpen:a,onToggleFavorite:o}){let[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),d=t.favorite?n(`panelAppsUnfavorite`):n(`panelAppsFavorite`),f=t.lastOpenedAt?`${n(`panelAppsLastOpened`)} ${Ui(t.lastOpenedAt)}`:`${n(`panelAppsUpdated`)} ${Ui(t.updatedAt)}`,p=e=>{e.stopPropagation(),o()},m=()=>{c(!1),u(!0)};return(0,V.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 text-left`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,V.jsx)(Wi,{icon:t.icon,title:t.title})}),(0,V.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,V.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,V.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:p,disabled:r,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:d,"aria-label":d,children:(0,V.jsx)(gi,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,V.jsxs)(We,{open:s,onOpenChange:c,children:[(0,V.jsx)(Ue,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-gray-700`,"aria-label":n(`panelAppsMoreActions`),disabled:e,children:(0,V.jsx)(oi,{className:`h-4 w-4`})})}),(0,V.jsx)(He,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,V.jsx)(Hi,{destructive:!0,disabled:e,icon:ze,label:n(`panelAppsDelete`),onClick:m})})]})]})]}),(0,V.jsx)(je,{open:l,onOpenChange:u,title:n(`panelAppsDeleteConfirmTitle`),description:`${n(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:i,onCancel:()=>void 0})]})}function Hi({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,V.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,V.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,V.jsx)(`span`,{children:i})]})}function Ui(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=o(a()),r=new Date;return t.toDateString()===r.toDateString()?new Intl.DateTimeFormat(n,{hour:`2-digit`,minute:`2-digit`}).format(t):t.getFullYear()===r.getFullYear()?new Intl.DateTimeFormat(n,{month:`numeric`,day:`numeric`}).format(t):new Intl.DateTimeFormat(n,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(t)}function Wi({icon:e,title:t}){return e?Gi(e)?(0,V.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,V.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,V.jsx)(ei,{className:`h-4 w-4`})}function Gi(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Ki=[`panel-apps`];function qi(){return b({queryKey:Ki,queryFn:()=>C.panelApps.listPanelApps(),staleTime:0})}function Ji(){let e=y();return u({mutationFn:({id:e,preferences:t})=>C.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Ki})}})}function Yi(){let e=y();return u({mutationFn:e=>C.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ki})}})}function Xi(){let e=y();return u({mutationFn:e=>C.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ki})}})}function Zi(e,t){return t===`favorites`?Qi(e.filter(e=>e.favorite),`smart`):Qi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function Qi(e,t){return[...e].sort((e,n)=>$i(e,n,t))}function $i(e,t,n){return n===`recent-open`?ra(e.lastOpenedAt,t.lastOpenedAt)||ea(e,t):n===`updated`?ra(e.updatedAt,t.updatedAt)||ea(e,t):n===`name`?ea(e,t):ta(e,t)||Number(t.favorite)-Number(e.favorite)||ea(e,t)}function ea(e,t){return e.title.localeCompare(t.title)}function ta(e,t){return na(t)-na(e)}function na(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function ra(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var[ia,aa]=de(`Tooltip`,[be]),oa=be(),sa=`TooltipProvider`,ca=700,la=`tooltip.open`,[ua,da]=ia(sa),fa=e=>{let{__scopeTooltip:t,delayDuration:n=ca,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=j.useRef(!0),s=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,V.jsx)(ua,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:j.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};fa.displayName=sa;var pa=`Tooltip`,[ma,ha]=ia(pa),ga=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=da(pa,e.__scopeTooltip),l=oa(t),[u,d]=j.useState(null),f=Ce(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=Se({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(la))):c.onClose(),a?.(e)},caller:pa}),y=j.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return j.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,V.jsx)(_e,{...l,children:(0,V.jsx)(ma,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:j.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};ga.displayName=pa;var _a=`TooltipTrigger`,va=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ha(_a,n),a=da(_a,n),o=oa(n),s=ue(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,V.jsx)(ye,{asChild:!0,...o,children:(0,V.jsx)(he.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:T(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:T(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:T(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:T(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:T(e.onBlur,i.onClose),onClick:T(e.onClick,i.onClose)})})});va.displayName=_a;var ya=`TooltipPortal`,[ba,xa]=ia(ya,{forceMount:void 0}),Sa=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=ha(ya,t);return(0,V.jsx)(ba,{scope:t,forceMount:n,children:(0,V.jsx)(Te,{present:n||a.open,children:(0,V.jsx)(me,{asChild:!0,container:i,children:r})})})};Sa.displayName=ya;var K=`TooltipContent`,Ca=j.forwardRef((e,t)=>{let n=xa(K,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=ha(K,e.__scopeTooltip);return(0,V.jsx)(Te,{present:r||o.open,children:o.disableHoverableContent?(0,V.jsx)(Oa,{side:i,...a,ref:t}):(0,V.jsx)(wa,{side:i,...a,ref:t})})}),wa=j.forwardRef((e,t)=>{let n=ha(K,e.__scopeTooltip),r=da(K,e.__scopeTooltip),i=j.useRef(null),a=ue(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Ma(r,ja(r,n.getBoundingClientRect())),a=Na(t.getBoundingClientRect());s(Fa([...i,...a])),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Pa(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,V.jsx)(Oa,{...e,ref:a})}),[Ta,Ea]=ia(pa,{isInside:!1}),Da=fe(`TooltipContent`),Oa=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=ha(K,n),l=oa(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(la,u),()=>document.removeEventListener(la,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,V.jsx)(ve,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,V.jsxs)(pe,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,V.jsx)(Da,{children:r}),(0,V.jsx)(Ta,{scope:n,isInside:!0,children:(0,V.jsx)(xe,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Ca.displayName=K;var ka=`TooltipArrow`,Aa=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=oa(n);return Ea(ka,n).isInside?null:(0,V.jsx)(ge,{...i,...r,ref:t})});Aa.displayName=ka;function ja(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Ma(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Na(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Pa(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Fa(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Ia(t)}function Ia(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var La=fa,Ra=ga,za=va,Ba=Sa,Va=Ca,Ha=La,q=Ra,J=za,Y=j.forwardRef(({className:t,sideOffset:n=4,...r},i)=>(0,V.jsx)(Ba,{children:(0,V.jsx)(Va,{ref:i,sideOffset:n,className:e(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,t),...r})}));Y.displayName=Va.displayName;function Ua({headerContent:e,onOpenPanelApp:t}){let r=qi(),i=Xi(),a=Ji(),o=Yi(),[s,c]=(0,j.useState)(`smart`),l=(0,j.useMemo)(()=>Zi(r.data?.entries??[],s),[r.data?.entries,s]),u=async e=>{try{t(await o.mutateAsync(e.id))}catch{t(e)}},d=e=>{a.mutate({id:e.id,preferences:{favorite:!e.favorite}})},f=e=>{i.mutate(e.id)};return r.isLoading?(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`panelAppsLoading`)}):r.isError?(0,V.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:r.error instanceof Error?r.error.message:n(`panelAppsLoadFailed`)}):(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`panelAppsTitle`)}),r.data?.panelsPath?(0,V.jsx)(Ha,{delayDuration:250,children:(0,V.jsxs)(q,{children:[(0,V.jsx)(J,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":n(`panelAppsTitle`),children:(0,V.jsx)(ii,{className:`h-3.5 w-3.5`})})}),(0,V.jsx)(Y,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:r.data.panelsPath})]})}):null]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void r.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefresh`),"aria-label":n(`panelAppsRefresh`),children:(0,V.jsx)(Re,{className:`h-3.5 w-3.5`})})]}),(0,V.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,V.jsx)(Ke,{value:s,onValueChange:e=>c(e),children:(0,V.jsxs)(Ge,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,V.jsx)(O,{value:`smart`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortSmart`)}),(0,V.jsx)(O,{value:`favorites`,className:`px-2 py-1 text-xs`,children:n(`panelAppsFavorites`)}),(0,V.jsx)(O,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortRecentOpen`)}),(0,V.jsx)(O,{value:`updated`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortUpdated`)}),(0,V.jsx)(O,{value:`name`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortName`)})]})})}),l.length===0?(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`panelAppsEmpty`)}):(0,V.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,V.jsx)(`div`,{className:`space-y-1.5`,children:l.map(e=>(0,V.jsx)(Vi,{entry:e,deletePending:i.isPending,favoritePending:a.isPending,onDelete:()=>f(e),onOpen:()=>void u(e),onToggleFavorite:()=>d(e)},e.id))})})]})}var Wa=class{constructor(e){this.authorizationManager=e,this.sessions=new Map,this.handleIframeMessage=({event:e,iframe:t,iframeInstanceId:n,tab:r})=>{this.isBridgeRequest(e.data)&&(!t?.contentWindow||e.source!==t.contentWindow||this.handleBridgeRequest({event:e,iframe:t,iframeInstanceId:n,tab:r},e.data))},this.handleBridgeRequest=async(e,t)=>{try{let n=await this.getSession(e),r=await this.dispatchRequest(n,t);this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!0,data:r})}catch(n){this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!1,error:this.toBridgeError(n)})}},this.dispatchRequest=async(e,t)=>{switch(t.method){case`list`:return await C.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await C.serviceApps.revokeServiceAction(this.requireActionId(t),{bridgeSessionToken:e.token});case`invoke`:return await this.invokeWithAuthorization(e,t);case`agent.send`:return await this.sendAgentMessageWithAuthorization(e,t);case`agent.generateObject`:return await this.generateAgentObjectWithAuthorization(e,t);default:throw Error(`Unsupported panel bridge method: ${String(t.method)}`)}},this.invokeWithAuthorization=async(e,t)=>{let n=this.requireActionId(t);try{return await C.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof le)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await C.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await C.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof le)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await C.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await C.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof le)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await C.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actionId:t,actionTitle:t===`agent:send`?`Send agent message`:`Generate object`,actionDescription:t===`agent:send`?`Send a message to a NextClaw Agent session.`:`Send context to a NextClaw Agent session and receive a structured object.`,risk:`write`}))throw new le({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await C.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.findAction(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actionId:t,actionTitle:r?.title,actionDescription:r?.description,risk:r?.risk,inputPreview:this.createInputPreview(n)}))throw new le({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await C.serviceApps.grantServiceAction(t,{bridgeSessionToken:e.token})},this.findAction=async(e,t)=>(await C.serviceApps.listServiceActions({bridgeSessionToken:e.token})).actions.find(e=>e.id===t),this.createInputPreview=e=>{if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e,null,2);return t.length>500?`${t.slice(0,500)}...`:t}catch{return`[unserializable input]`}},this.getSession=async e=>{let t=this.readPanelAppId(e.tab.currentUrl),n=`${e.iframeInstanceId}:${t}`,r=this.sessions.get(n);return r||(r=C.panelApps.createBridgeSession({panelAppId:t,tabId:e.tab.id}),this.sessions.set(n,r)),await r},this.readPanelAppId=e=>{let t=new URL(e,window.location.origin),n=/^\/api\/panel-apps\/([^/]+)\/content$/.exec(t.pathname);if(!n?.[1])throw Error(`Current tab is not a Panel App.`);return decodeURIComponent(n[1])},this.requireActionId=e=>{let t=e.payload?.actionId?.trim();if(!t)throw Error(`Panel bridge actionId is required.`);return t},this.readOptionalRecord=e=>{if(e!==void 0)return this.requireRecord(e,`input`)},this.readAgentSendRequest=e=>({payload:this.requireRecord(e.payload?.request,`agent.send request`)}),this.readGenerateObjectRequest=e=>({input:this.requireRecord(e.payload?.input,`generateObject input`)}),this.requireRecord=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} is required.`);return e},this.postResponse=(e,t)=>{e.iframe?.contentWindow?.postMessage(t,`*`)},this.toBridgeError=e=>e instanceof le?{code:e.code,message:e.message,details:e.details}:{message:e instanceof Error?e.message:String(e)},this.isBridgeRequest=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`nextclaw:panel-app-service-actions:request`&&typeof t.requestId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function Ga(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var Ka=s((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:Ga(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function qa(){let e=Ka(e=>e.pending),t=Ka(e=>e.resolveAuthorization);return(0,V.jsx)(De,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,V.jsxs)(ke,{className:`[&>:last-child]:hidden`,children:[(0,V.jsxs)(Oe,{children:[(0,V.jsxs)(Ae,{className:`flex items-center gap-2`,children:[(0,V.jsx)(pi,{className:`h-4 w-4 text-amber-600`}),n(`serviceActionAuthorizationTitle`)]}),(0,V.jsx)(Ee,{children:n(`serviceActionAuthorizationDescription`)})]}),e?(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,V.jsx)(Ja,{label:n(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,V.jsx)(Ja,{label:n(`serviceActionAuthorizationAction`),value:e.actionTitle??e.actionId}),e.actionDescription?(0,V.jsx)(Ja,{label:n(`serviceActionAuthorizationPurpose`),value:e.actionDescription}):null,(0,V.jsx)(Ja,{label:n(`serviceActionAuthorizationRisk`),value:e.risk??`dangerous`}),e.inputPreview?(0,V.jsx)(Ja,{label:n(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,V.jsxs)(we,{className:`gap-2 sm:gap-0`,children:[(0,V.jsx)(p,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:n(`serviceActionAuthorizationReject`)}),(0,V.jsx)(p,{type:`button`,onClick:()=>t(!0),children:n(`serviceActionAuthorizationAllow`)})]})]})})}function Ja({label:e,value:t}){return(0,V.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,V.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Ya=class{constructor(){this.requestAuthorization=async e=>await Ka.getState().requestAuthorization(e)}},Xa=[`service-apps`],Za=[`service-actions`],Qa=[`service-action-grants`];function $a(){return b({queryKey:Xa,queryFn:()=>C.serviceApps.listServiceApps()})}function eo(){return b({queryKey:Za,queryFn:()=>C.serviceApps.listServiceActions()})}function to(){return b({queryKey:Qa,queryFn:()=>C.serviceApps.listServiceActionGrants()})}function no(){let e=y();return u({mutationFn:e=>C.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Xa}),e.invalidateQueries({queryKey:Za})])}})}function ro(){let e=y();return u({mutationFn:e=>C.serviceApps.deleteServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Xa}),e.invalidateQueries({queryKey:Za}),e.invalidateQueries({queryKey:Qa})])}})}function io(){let e=y();return u({mutationFn:e=>C.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Xa})}})}function ao(){let e=y();return u({mutationFn:e=>C.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Za}),e.invalidateQueries({queryKey:Qa})])}})}function oo({headerContent:e}){let t=$a(),r=eo(),i=to(),a=ro(),o=no(),s=io(),c=ao(),[l,u]=(0,j.useState)({}),d=()=>{t.refetch(),r.refetch(),i.refetch()};if(t.isLoading||r.isLoading||i.isLoading)return(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`serviceAppsLoading`)});if(t.isError||r.isError||i.isError){let e=t.error??r.error??i.error;return(0,V.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:n(`serviceAppsLoadFailed`)})}let f=t.data?.entries??[],p=r.data?.actions??[],m=i.data?.grants??[],h=e=>{s.mutateAsync(e).then(t=>{u(n=>({...n,[e]:t.actions}))})};return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,V.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(fi,{className:`h-4 w-4 text-primary`}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`serviceAppsTitle`)})]})}),(0,V.jsx)(Ha,{delayDuration:250,children:(0,V.jsx)(uo,{icon:Re,label:n(`serviceAppsRefresh`),onClick:d})})]}),f.length===0?(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`serviceAppsEmpty`)}):(0,V.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,V.jsx)(`div`,{className:`space-y-3`,children:f.map(e=>(0,V.jsx)(so,{app:e,actions:l[e.id]??p.filter(t=>t.appId===e.id),grants:m,deletePending:a.isPending,isDiscovering:s.isPending,onDiscover:h,onDelete:e=>void a.mutate(e),onRestart:e=>void o.mutate(e),onRevoke:e=>void c.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function so({app:e,actions:t,grants:r,deletePending:i,isDiscovering:a,onDiscover:o,onDelete:s,onRestart:c,onRevoke:l}){let[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=e.status!==`starting`&&e.status!==`stopped`,h=e.status===`running`||e.status===`failed`,g=()=>{d(!1),p(!0)};return(0,V.jsx)(Ha,{delayDuration:250,children:(0,V.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,V.jsx)(co,{status:e.status})]}),e.description?(0,V.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,V.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(uo,{disabled:a||!m,icon:ui,label:n(`serviceAppsDiscoverActions`),tooltip:n(`serviceAppsDiscoverActionsHint`),onClick:()=>o(e.id)}),(0,V.jsx)(uo,{disabled:!h,icon:vi,label:n(`serviceAppsDisconnectRuntime`),tooltip:n(`serviceAppsDisconnectRuntimeHint`),onClick:()=>c(e.id)}),(0,V.jsxs)(We,{open:u,onOpenChange:d,children:[(0,V.jsxs)(q,{children:[(0,V.jsx)(J,{asChild:!0,children:(0,V.jsx)(Ue,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,"aria-label":n(`serviceAppsMoreActions`),disabled:i,children:(0,V.jsx)(oi,{className:`h-3.5 w-3.5`})})})}),(0,V.jsx)(Y,{side:`bottom`,className:`text-xs`,children:n(`serviceAppsMoreActions`)})]}),(0,V.jsx)(He,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,V.jsx)(fo,{destructive:!0,disabled:i,icon:ze,label:n(`serviceAppsDelete`),onClick:g})})]})]})]}),(0,V.jsx)(po,{app:e}),(0,V.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,V.jsx)(ho,{action:e,grants:r.filter(t=>t.actionId===e.id),onRevoke:l},e.id))}),(0,V.jsx)(je,{open:f,onOpenChange:p,title:n(`serviceAppsDeleteConfirmTitle`),description:`${n(`serviceAppsDeleteConfirmDescription`)} ${e.title}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:()=>s(e.id),onCancel:()=>void 0})]})})}function co({status:t}){let n=lo(t),r=n.icon;return(0,V.jsxs)(q,{children:[(0,V.jsx)(J,{asChild:!0,children:(0,V.jsxs)(`span`,{className:e(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium`,n.className),"aria-label":n.label,children:[(0,V.jsx)(r,{className:e(`h-3 w-3`,n.iconClassName)}),(0,V.jsx)(`span`,{children:n.label})]})}),(0,V.jsx)(Y,{side:`bottom`,className:`text-xs`,children:n.tooltip})]})}function lo(e){switch(e){case`running`:return{className:`bg-emerald-50 text-emerald-700`,icon:ni,label:n(`serviceAppsStatus_running`),tooltip:n(`serviceAppsStatusHint_running`)};case`starting`:return{className:`bg-blue-50 text-blue-700`,icon:Pe,iconClassName:`animate-spin`,label:n(`serviceAppsStatus_starting`),tooltip:n(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`bg-rose-50 text-rose-700`,icon:_i,label:n(`serviceAppsStatus_failed`),tooltip:n(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`bg-gray-100 text-gray-600`,icon:ai,label:n(`serviceAppsStatus_stopped`),tooltip:n(`serviceAppsStatusHint_stopped`)};default:return{className:`bg-slate-100 text-slate-600`,icon:ri,label:n(`serviceAppsStatus_idle`),tooltip:n(`serviceAppsStatusHint_idle`)}}}function uo({disabled:e=!1,icon:t,label:n,tooltip:r=n,onClick:i}){return(0,V.jsxs)(q,{children:[(0,V.jsx)(J,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,onClick:i,disabled:e,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:text-gray-300 disabled:opacity-60 disabled:hover:bg-transparent`,"aria-label":n,children:(0,V.jsx)(t,{className:`h-3.5 w-3.5`})})}),(0,V.jsx)(Y,{side:`bottom`,className:`max-w-56 text-xs`,children:r})]})}function fo({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,V.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,V.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,V.jsx)(`span`,{children:i})]})}function po({app:e}){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),r=[{label:n(`serviceAppsCommand`),value:t},{label:n(`serviceAppsCwd`),value:e.cwd},{label:n(`serviceAppsManifest`),value:e.manifestPath},{label:n(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:n(`serviceAppsLastReady`),value:e.lastReadyAt},{label:n(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return r.length===0?null:(0,V.jsx)(`dl`,{className:`mt-3 grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-gray-100 pt-2 text-[11px]`,children:r.map(e=>(0,V.jsx)(mo,{label:e.label,value:e.value},e.label))})}function mo({label:e,value:t}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,V.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function ho({action:e,grants:t,onRevoke:r}){return(0,V.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(yi,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,V.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,V.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:n(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,V.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,V.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,V.jsx)(mi,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,V.jsxs)(`span`,{className:`truncate`,children:[n(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`rounded-md p-1 text-gray-400 transition-colors hover:bg-white hover:text-rose-600`,title:n(`serviceAppsRevokeGrant`),"aria-label":n(`serviceAppsRevokeGrant`),children:(0,V.jsx)(ze,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function go({activeTab:e,onActiveTabChange:t,onOpenPanelApp:r}){let i=(0,V.jsx)(Ke,{value:e,onValueChange:e=>t(e),children:(0,V.jsxs)(Ge,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,V.jsxs)(O,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,V.jsx)(ei,{className:`h-3.5 w-3.5`}),n(`panelAppsTitle`)]}),(0,V.jsxs)(O,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,V.jsx)(fi,{className:`h-3.5 w-3.5`}),n(`serviceAppsTitle`)]})]})});return(0,V.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,V.jsx)(Ua,{headerContent:i,onOpenPanelApp:r}):(0,V.jsx)(oo,{headerContent:i})})}function _o({onOpenApps:e,onRefresh:t}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,V.jsx)(Me,{className:`h-3.5 w-3.5`}),n(`appsTitle`)]}),(0,V.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefreshCurrent`),"aria-label":n(`panelAppsRefreshCurrent`),children:(0,V.jsx)(Re,{className:`h-3.5 w-3.5`})})]})}function vo(e){return e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0)}function X(e){let t=e.trim();try{let e=new URL(t);return{authority:e.hostname,pathSegments:vo(e.pathname),pathname:e.pathname,raw:t,scheme:e.protocol.replace(/:$/,``).toLowerCase(),searchParams:e.searchParams}}catch{return{authority:``,pathSegments:vo(t),pathname:t,raw:t,scheme:``,searchParams:new URLSearchParams}}}var yo=class{constructor(e,t){this.routeDefinitions=e,this.options=t,this.resolve=e=>{let t=X(e);return this.findDefinition(t).resolve(t)},this.normalize=e=>this.options.getNormalizedUri(this.resolve(e)),this.areEquivalent=(e,t)=>this.findDefinition(X(e)).areEquivalent?.(e,t)??this.normalize(e)===this.normalize(t),this.findDefinition=e=>{let t=this.routeDefinitions.find(t=>t.match(e));if(!t)throw Error(`Unsupported resource URI: ${e.raw}`);return t}}},bo=`home`,xo=`nextclaw://new-tab`,So=`apps`,Z=`nextclaw://apps`,Co=`${Z}?tab=service-apps`,wo=`panel-app`,To=`panel-apps`;function Eo(e){return e===`panel-apps`||e===`service-apps`}function Do(e=To){return e===To?Z:Co}function Oo(e){try{let t=new URL(e).searchParams.get(`tab`);return Eo(t)?t:To}catch{return To}}function ko(e){return Do(Oo(e))}function Ao(e){return`nextclaw://panel-app/${encodeURIComponent(e)}`}function jo(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}function Mo(e){let t=e.icon?.trim();if(t)return jo(t)?{type:`url`,url:t}:{type:`text`,value:t}}function No(e){return{dedupeKey:`panel-app:${e.id}`,dockIcon:Mo(e),historyPolicy:`managed`,kind:wo,resourceUri:Ao(e.id),title:e.title,url:e.contentPath}}function Po(e,t){return e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`)}function Fo(e){let t=e.pathSegments.join(`/`);return Ye(t?`/${t}`:`/`,`docs`)}function Io(e){let t=e.filter(e=>e.trim().length>0).map(e=>encodeURIComponent(decodeURIComponent(e))).join(`/`);return t?`nextclaw://docs/${t}`:`nextclaw://docs`}function Lo(e){let t=A(e),n=t.startsWith(`/`)?t:(()=>{try{return new URL(e).pathname}catch{return``}})();return n?Io(n.split(`/`)):`nextclaw://docs`}function Ro(e){if(e.scheme===`nextclaw`&&e.authority===`panel-app`)return e.pathSegments[0]??``;let[t,n,r,i]=e.pathSegments;return t===`api`&&n===`panel-apps`&&r!==void 0&&r.length>0&&i===`content`?r:``}function zo(e){return Ro(e).length>0}function Bo(e){let t=Ro(e);return t?`/api/panel-apps/${encodeURIComponent(decodeURIComponent(t))}/content`:`nextclaw://panel-app`}function Vo(e){let t=Ro(e);return t?`nextclaw://panel-app/${encodeURIComponent(decodeURIComponent(t))}`:`nextclaw://panel-app`}function Ho(e,t){let n=X(e),r=X(t),i=Ro(n),a=Ro(r);return i.length>0&&a.length>0?decodeURIComponent(i)===decodeURIComponent(a):e===t}var Uo=[{defaultUrl:()=>xo,id:`home`,kind:bo,match:e=>e.raw===xo,resolve:()=>({historyPolicy:`managed`,kind:bo,resourceUri:xo,title:n(`docBrowserHomeTitle`),url:xo}),areEquivalent:(e,t)=>e===t},{defaultUrl:Je,id:`docs-url`,kind:`docs`,match:e=>Qe(e.raw),resolve:e=>{let t=Ye(e.raw,`docs`);return{historyPolicy:`managed`,kind:`docs`,resourceUri:Lo(t),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>A(e)===A(t)},{defaultUrl:Je,id:`nextclaw-docs`,kind:`docs`,match:e=>e.scheme===`nextclaw`&&e.authority===`docs`,resolve:e=>{let t=Fo(e);return{historyPolicy:`managed`,kind:`docs`,resourceUri:Io(e.pathSegments),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>A(e)===A(t)},{defaultUrl:()=>Z,id:`apps`,kind:So,match:e=>Po(e.raw,Z),resolve:e=>{let t=ko(e.raw);return{dedupeKey:`apps`,historyPolicy:`managed`,kind:So,resourceUri:t,title:n(t===`nextclaw://apps`?`appsTitle`:`serviceAppsTitle`),url:t}},areEquivalent:(e,t)=>ko(e)===ko(t)},{defaultUrl:()=>`nextclaw://panel-app`,id:`panel-app`,kind:wo,match:e=>e.scheme===`nextclaw`&&e.authority===`panel-app`||zo(e),resolve:e=>{let t=Bo(e),r=Ro(e);return{dedupeKey:r?`panel-app:${decodeURIComponent(r)}`:void 0,historyPolicy:`managed`,kind:wo,resourceUri:Vo(e),title:n(`panelAppsTitle`),url:t}},areEquivalent:Ho},{defaultUrl:()=>`about:blank`,id:`content`,kind:`content`,match:()=>!0,resolve:e=>({historyPolicy:`managed`,kind:`content`,resourceUri:e.raw||`about:blank`,title:tt(e.raw,`content`,`Detail`),url:e.raw||`about:blank`}),areEquivalent:(e,t)=>e===t}],Wo=Uo.map(e=>({areEquivalent:e.areEquivalent,id:e.id,match:e.match,resolve:e.resolve}));function Go(){return[{id:`apps`,label:n(`appsTitle`),target:{type:`right-panel-resource`,uri:Z}},{id:`service-apps`,label:n(`serviceAppsTitle`),target:{type:`right-panel-resource`,uri:Co}},{id:`docs`,label:n(`docBrowserHelp`),target:{options:{newTab:!0},type:`right-panel-resource`,uri:Je()}},{id:`skill-marketplace`,label:n(`marketplaceSkillsPageTitle`),target:{path:`/marketplace/skills`,type:`app-route`}}]}var Ko={apps:{accentClassName:`bg-emerald-50 text-emerald-700`,hoverAccentClassName:`group-hover:bg-emerald-100`,icon:(0,V.jsx)(Fe,{className:`h-5 w-5`})},"service-apps":{accentClassName:`bg-sky-50 text-sky-700`,hoverAccentClassName:`group-hover:bg-sky-100`,icon:(0,V.jsx)(si,{className:`h-5 w-5`})},docs:{accentClassName:`bg-amber-50 text-amber-700`,hoverAccentClassName:`group-hover:bg-amber-100`,icon:(0,V.jsx)(Ne,{className:`h-5 w-5`})},"skill-marketplace":{accentClassName:`bg-rose-50 text-rose-700`,hoverAccentClassName:`group-hover:bg-rose-100`,icon:(0,V.jsx)(ti,{className:`h-5 w-5`})}};function qo(e){return Ko[e.id]??{accentClassName:`bg-gray-50 text-gray-700`,hoverAccentClassName:`group-hover:bg-gray-100`,icon:(0,V.jsx)(Fe,{className:`h-5 w-5`})}}function Jo({open:t}){let n=_n(),r=Go(),i=e=>{if(e.type===`app-route`){n(e.path);return}t(e.uri,e.options)};return(0,V.jsx)(`div`,{className:`h-full overflow-auto bg-background px-4 py-5`,children:(0,V.jsx)(`div`,{className:`mx-auto w-full max-w-[520px]`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(76px,1fr))] gap-x-2 gap-y-4`,children:r.map(t=>{let n=qo(t);return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(t.target),className:`group flex min-h-[68px] flex-col items-center gap-1.5 rounded-md px-1.5 py-1.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,V.jsx)(`span`,{className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-md transition-colors`,n.accentClassName,n.hoverAccentClassName),children:n.icon}),(0,V.jsx)(`span`,{className:`line-clamp-2 min-w-0 max-w-full text-xs font-medium leading-snug text-gray-700 transition-colors group-hover:text-gray-900`,children:t.label})]},t.id)})})})})}function Yo(e){return e&&Qe(e)?`docs`:`content`}var Xo=class{constructor(){this.resourceUriResolver=new yo(Wo,{getNormalizedUri:e=>e.resourceUri??e.url}),this.resolve=e=>this.resourceUriResolver.resolve(e),this.normalize=e=>this.resourceUriResolver.normalize(e),this.areEquivalent=(e,t)=>this.resourceUriResolver.areEquivalent(e,t),this.resolveOpenTarget=e=>{let{activeTab:t,kind:n,url:r}=e,i=this.resolveRouteDefinition(r,n,t),a=r?.trim()||(!n&&t&&t.kind!==`docs`?t.currentUrl:i.defaultUrl());return i.resolve(X(a))},this.areUrlsEquivalent=(e,t,n,r)=>n===r?this.resolveRouteDefinition(e,n).areEquivalent?.(e,t)??this.areEquivalent(e,t):!1,this.usesManagedHistory=e=>this.resolveRouteDefinition(e.currentUrl,e.kind).resolve(X(e.currentUrl)).historyPolicy===`managed`,this.resolveRouteDefinition=(e,t,n)=>{let r=t??(e?void 0:n?.kind),i=r?Uo.find(e=>e.kind===r):void 0;if(i)return i;let a=e?X(e):null,o=a?Uo.find(e=>e.match(a)):void 0;if(o)return o;let s=t??n?.kind??Yo(e);return Uo.find(e=>e.kind===s)??Uo[Uo.length-1]}}},Zo=So,Qo=wo,$o=`panel-apps`,es=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function ts(e){return e===`panel-apps`||e===`service-apps`}function ns(e=$o){return e===$o?Z:Co}function rs(e){try{let t=new URL(e).searchParams.get(`tab`);return ts(t)?t:$o}catch{return $o}}function is(e){e.open(ns(),{kind:Zo,title:n(`appsTitle`),dedupeKey:`apps`})}var as={[bo]:{getTitle:()=>n(`docBrowserHomeTitle`),renderContent:({open:e})=>(0,V.jsx)(Jo,{open:e})},[Zo]:{getTitle:()=>n(`appsTitle`),renderIcon:()=>(0,V.jsx)(Fe,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t,openTarget:r})=>(0,V.jsx)(go,{activeTab:rs(e),onActiveTabChange:e=>t(ns(e),{activate:!1,kind:Zo,title:n(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>r(No(e))})},[Qo]:{getIframeSandbox:()=>es,getTitle:e=>e.title||n(`panelAppsTitle`),onIframeMessage:e=>Xs().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,V.jsx)(ei,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,V.jsx)(_o,{onOpenApps:()=>is({open:e}),onRefresh:t})}},os=`nextclaw://docs`;function ss(){return[{builtIn:!0,icon:{type:`builtin`,name:`apps`},id:`apps`,label:n(`appsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Z}},{builtIn:!0,icon:{type:`builtin`,name:`service-apps`},id:`service-apps`,label:n(`serviceAppsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Co}},{builtIn:!0,icon:{type:`builtin`,name:`docs`},id:`docs`,label:n(`docBrowserHelp`),removable:!1,target:{type:`right-panel-resource`,uri:os}},{builtIn:!0,icon:{type:`builtin`,name:`new-tab`},id:`new-tab`,label:n(`docBrowserHomeTitle`),removable:!1,target:{type:`right-panel-resource`,uri:xo}}]}var cs=[`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`];function ls(e){return!!e&&typeof e==`object`}function us(e){return cs.includes(e)}function ds(e){return!ls(e)||typeof e.type!=`string`?null:e.type===`builtin`&&us(e.name)?{type:`builtin`,name:e.name}:e.type===`url`&&typeof e.url==`string`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e.type===`text`&&typeof e.value==`string`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function fs(e){if(!ls(e)||typeof e.id!=`string`||e.id.trim().length===0||typeof e.label!=`string`||e.label.trim().length===0||typeof e.createdAt!=`string`||e.createdAt.trim().length===0||!ls(e.target)||e.target.type!==`right-panel-resource`||typeof e.target.uri!=`string`||e.target.uri.trim().length===0)return null;let t=ds(e.icon);return t?{createdAt:e.createdAt,icon:t,id:e.id.trim(),label:e.label.trim(),target:{type:`right-panel-resource`,uri:e.target.uri.trim()}}:null}function ps(e){if(!Array.isArray(e))return[];let t=new Map;return e.forEach(e=>{let n=fs(e);n&&t.set(n.id,n)}),Array.from(t.values())}function ms(e,t){return{createdAt:t,icon:e.icon,id:e.id,label:e.label,target:e.target}}function hs(e){return{builtIn:!1,icon:e.icon,id:e.id,label:e.label,removable:!0,target:e.target}}function gs(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(e.map(e=>e.target.uri)),i=t.filter(e=>!n.has(e.id)&&!r.has(e.target.uri)).map(hs);return[...e,...i]}var _s=`nextclaw.side-dock.state`,vs=1;function ys(e){return!!e&&typeof e==`object`}var bs=s()(qe(e=>({pinnedItems:[],setPinnedItems:t=>e({pinnedItems:ps(t)})}),{name:_s,version:vs,storage:rt(()=>window.localStorage),partialize:e=>({pinnedItems:e.pinnedItems}),merge:(e,t)=>{let n=ys(e)?ps(e.pinnedItems):[];return{...t,pinnedItems:n}}})),xs={apps:Fe,docs:Ne,"new-tab":Le,"panel-app":ei,"service-apps":ei};function Ss({icon:e}){if(e.type===`url`)return(0,V.jsx)(`img`,{src:e.url,alt:``,className:`h-5 w-5 rounded object-cover`});if(e.type===`text`)return(0,V.jsx)(`span`,{className:`max-w-7 truncate text-center text-[13px] font-semibold leading-none`,"aria-hidden":`true`,children:e.value});let t=xs[e.name];return(0,V.jsx)(t,{className:`h-5 w-5`,"aria-hidden":`true`})}function Cs({active:t,item:r,onOpen:i,onUnpin:a}){let{label:o}=r;return(0,V.jsxs)(q,{children:[(0,V.jsxs)(`div`,{className:`group relative`,children:[(0,V.jsx)(J,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":o,title:o,"data-side-dock-item-id":r.id,onClick:()=>i(r),className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors`,`hover:bg-primary/10 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?`bg-primary/10 text-primary`:`bg-transparent`),children:(0,V.jsx)(Ss,{icon:r.icon})})}),r.removable?(0,V.jsx)(`button`,{type:`button`,"aria-label":n(`sideDockUnpinItem`),title:n(`sideDockUnpinItem`),onClick:e=>{e.stopPropagation(),a(r)},className:`absolute -right-1 -top-1 hidden h-4 w-4 items-center justify-center rounded-full bg-background text-muted-foreground shadow-sm ring-1 ring-border/70 transition-colors hover:bg-muted hover:text-foreground group-hover:flex focus-visible:flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,V.jsx)(Be,{className:`h-3 w-3`,"aria-hidden":`true`})}):null]}),(0,V.jsx)(Y,{side:`left`,children:o})]})}function ws(e){return e?.trim()??``}function Ts(e,t,n,r=!1){if(!t||!n)return!1;let i=ws(e.target.uri),a=ws(n.resourceUri);return a&&a===i||ws(n.currentUrl)===i?!0:r?!1:e.id===`docs`&&n.kind===`docs`}function Es(e,t){if(!t)return!1;let n=ws(t.resourceUri),r=ws(t.currentUrl);return e.some(e=>{let t=ws(e.target.uri);return t===n||t===r})}function Ds({manager:e}){let t=bs(e=>e.pinnedItems),{currentTab:n,isOpen:r}=$e(),i=gs(ss(),t),a=Es(i,n);return(0,V.jsx)(Ha,{delayDuration:250,children:(0,V.jsx)(`aside`,{"data-testid":`side-dock`,className:`z-30 flex h-full w-14 shrink-0 flex-col items-center gap-1 border-l border-border/60 bg-background/95 px-2 py-3`,children:i.map(t=>(0,V.jsx)(Cs,{active:Ts(t,r,n,a),item:t,onOpen:e.openItem,onUnpin:t=>e.unpinItem(t.id)},t.id))})})}var Os=`pinned`,ks=new Set([`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`]);function Q(e){return e.trim()}function As(e){let t=0;return Array.from(Q(e)).forEach(e=>{t=t*31+e.charCodeAt(0)>>>0}),`${Os}-${Q(e).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()||`resource`}-${t.toString(36)}`}function js(e){return e?.type===`builtin`&&ks.has(e.name)?{type:`builtin`,name:e.name}:e?.type===`url`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e?.type===`text`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function Ms(e){return e.kind===`docs`?`docs`:e.kind===`home`?`new-tab`:e.kind===`apps`?e.resourceUri?.includes(`service-apps`)?`service-apps`:`apps`:e.kind===`panel-app`?`panel-app`:`apps`}var Ns=class{constructor(e){this.docBrowserManager=e,this.getItems=()=>gs(ss(),bs.getState().pinnedItems),this.openItem=e=>{e.target.type===`right-panel-resource`&&this.docBrowserManager.open(e.target.uri,{dockIcon:e.icon,title:e.label})},this.getDockState=e=>{let t=this.getTabResourceUri(e);if(!t)return{canDock:!1,isDocked:!1,removable:!1};let n=this.findItemByUri(t);return{canDock:!0,isDocked:!!n,removable:n?.removable===!0}},this.pinTab=(e,t=new Date().toISOString())=>{let n=this.getTabResourceUri(e);!e||!n||this.findItemByUri(n)||this.pinItem({builtIn:!1,icon:js(e.dockIcon)??{type:`builtin`,name:Ms(e)},id:As(n),label:e.title.trim()||n,removable:!0,target:{type:`right-panel-resource`,uri:n}},t)},this.unpinTab=e=>{let t=this.getTabResourceUri(e),n=t?this.findItemByUri(t):void 0;n?.removable&&this.unpinItem(n.id)},this.pinItem=(e,t=new Date().toISOString())=>{if(!e.removable)return;let n=Q(e.target.uri);this.setPinnedItems(r=>r.some(t=>t.id===e.id||Q(t.target.uri)===n)?r:[...r,ms({...e,target:{...e.target,uri:n}},t)])},this.unpinItem=e=>{this.setPinnedItems(t=>t.filter(t=>t.id!==e))},this.reorderPinnedItems=e=>{this.setPinnedItems(t=>{let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e)).filter(e=>e!==void 0),i=new Set(r.map(e=>e.id)),a=t.filter(e=>!i.has(e.id));return[...r,...a]})},this.setPinnedItems=e=>{let{pinnedItems:t,setPinnedItems:n}=bs.getState();n(e(t))},this.getTabResourceUri=e=>{let t=e?.resourceUri??e?.currentUrl,n=t?Q(t):``;return n.length>0?n:null},this.findItemByUri=e=>{let t=Q(e);return this.getItems().find(e=>Q(e.target.uri)===t)}}},Ps=new class{constructor(){this.resolveOpenTarget=e=>{let{activeTab:t,kind:r,url:i}=e,a=r??(i?void 0:t?.kind)??(i&&Qe(i)?`docs`:`home`),o=i?.trim()||(!r&&t&&t.kind!==`docs`?t.currentUrl:a===`home`?`nextclaw://new-tab`:a===`docs`?Je():`about:blank`),s=a===`docs`?Ye(o,`docs`):o;return{historyPolicy:`managed`,kind:a,title:a===`home`?n(`docBrowserHomeTitle`):tt(s,a,a===`docs`?n(`docBrowserHelp`):`Detail`),url:s}},this.areUrlsEquivalent=(e,t,n,r)=>n===r?n===`docs`?A(e)===A(t):e===t:!1,this.usesManagedHistory=e=>e.currentUrl!==Ze}};function Fs(e,t,n){return{...e,tabs:e.tabs.map(e=>e.id===t?n(e):e)}}function Is(e,t){return Fs(e,e.activeTabId,t)}function Ls(e,t){let n=[...e.history.slice(0,e.historyIndex+1),t];return{history:n,historyIndex:n.length-1}}function Rs(e,t,n){let r=t.resourceUri??t.url,i=n.resourceUri??n.url;return t.tabId===n.tabId&&t.kind===n.kind&&e.areUrlsEquivalent(r,i,t.kind,n.kind)}function zs(e,t){return{kind:t.kind,resourceUri:t.resourceUri??t.url,tabId:e,url:t.url}}function $(e,t,n){let r=t.activeHistory[t.activeHistoryIndex];if(r&&Rs(e,r,n))return t;let i=[...t.activeHistory.slice(0,t.activeHistoryIndex+1),n];return{...t,activeHistory:i,activeHistoryIndex:i.length-1}}function Bs(e,t,n){for(let r=t.history.length-1;r>=0;--r)if(e.areUrlsEquivalent(t.history[r],n,t.kind,t.kind))return r;return-1}function Vs(e,t,n){let r=t.tabs.find(e=>e.id===n.tabId);if(!r)return t;let i=n.resourceUri??n.url,a=e.resolveOpenTarget({activeTab:r,kind:n.kind,url:i}),o=Bs(e,r,a.url),s=n.resourceUri!==void 0&&n.resourceUri===r.resourceUri;return Fs({...t,activeTabId:r.id,isOpen:!0},r.id,e=>({...e,currentUrl:a.url,dedupeKey:a.dedupeKey,dockIcon:a.dockIcon??e.dockIcon,historyIndex:o>=0?o:e.historyIndex,kind:a.kind,resourceUri:a.resourceUri??a.url,title:s?e.title:a.title}))}function Hs(e,t,n,r,i){let a={...t,title:r?.title||n.title||t.title,kind:n.kind,resourceUri:n.resourceUri??n.url,dockIcon:r?.dockIcon??n.dockIcon,dedupeKey:i};return e.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?a:{...a,currentUrl:n.url,...Ls(t,n.url),navVersion:t.navVersion+1}}function Us(e,t){return!e.isOpen&&e.tabs.length===1&&t?.kind===`home`&&t.currentUrl===`nextclaw://new-tab`}function Ws(e,t,n,r){let{activate:i,dedupeKey:a,newTab:o,title:s}=r??{},c=a?.trim()||n.dedupeKey,l=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0],u=c?t.tabs.find(e=>e.dedupeKey===c):void 0;if(u){let a=Fs(t,u.id,t=>Hs(e,t,n,r,c)),o=i!==!1,s=o?u.id:t.activeTabId,l={...a,activeTabId:s,isOpen:!0};return o||u.id===t.activeTabId?$(e,l,zs(u.id,n)):l}if(o||c||!l||l.kind!==n.kind){let i=et(n.url,n.kind,s??n.title,c,n.resourceUri??n.url,r?.dockIcon??n.dockIcon);return Us(t,l)?{...t,isOpen:!0,tabs:[i],activeTabId:i.id,activeHistory:[k(i)],activeHistoryIndex:0}:$(e,{...t,isOpen:!0,tabs:[...t.tabs,i],activeTabId:i.id},k(i))}return $(e,{...Is(t,t=>Hs(e,t,n,r,c)),isOpen:!0},zs(t.activeTabId,n))}function Gs(e,t,n,r){let i=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0];return Ws(e,t,e.resolveOpenTarget({activeTab:i,kind:r?.kind,url:n}),r)}var Ks=class{constructor(e=Ps){this.routeResolver=e,this.setSnapshot=e=>{nt.getState().setSnapshot(e)},this.open=(e,t)=>{this.setSnapshot(n=>Gs(this.routeResolver,n,e,t))},this.openTarget=(e,t)=>{this.setSnapshot(n=>Ws(this.routeResolver,n,e,{...t,dedupeKey:t?.dedupeKey??e.dedupeKey,kind:t?.kind??e.kind,title:t?.title??e.title}))},this.openNewTab=()=>{this.open(void 0,{kind:it,newTab:!0})},this.close=()=>{this.setSnapshot(e=>({...e,isOpen:!1}))},this.toggleMode=()=>{this.setSnapshot(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`}))},this.navigate=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=et(Je(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}let n=Is(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Ls(t,n.url),kind:n.kind,navVersion:t.navVersion+1,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,k(r)):n})},this.syncUrl=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=et(Je(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}let n=Is(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,kind:t.kind,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Ls(t,n.url),kind:n.kind,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,k(r)):n})},this.goBack=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex<=0)return e;let t=e.activeHistoryIndex-1,n=e.activeHistory[t];return n?Vs(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.goForward=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex>=e.activeHistory.length-1)return e;let t=e.activeHistoryIndex+1,n=e.activeHistory[t];return n?Vs(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.closeTab=e=>{this.setSnapshot(t=>{if(t.tabs.length<=1)return{...Xe(),isOpen:!1};let n=t.tabs.findIndex(t=>t.id===e);if(n<0)return t;let r=t.tabs.filter(t=>t.id!==e),i=t.activeTabId===e?r[Math.max(0,n-1)]?.id??r[0].id:t.activeTabId,a={...t,tabs:r,activeTabId:i},o=a.activeHistory.filter(t=>t.tabId!==e),s=a.activeHistory.slice(0,a.activeHistoryIndex+1).filter(t=>t.tabId!==e),c=r.find(e=>e.id===i)??r[0],l={...a,activeHistory:o.length>0?o:[k(c)],activeHistoryIndex:Math.min(Math.max(0,s.length-1),Math.max(0,o.length-1))};return t.activeTabId===e?$(this.routeResolver,l,k(c)):l})},this.setActiveTab=e=>{this.setSnapshot(t=>{if(!t.tabs.some(t=>t.id===e))return t;let n=t.tabs.find(t=>t.id===e);return n?$(this.routeResolver,{...t,activeTabId:e,isOpen:!0},k(n)):t})}}},qs=class{constructor(){this.accountManager=new Bi,this.rightPanelResourceRouteResolver=new Xo,this.docBrowserManager=new Ks(this.rightPanelResourceRouteResolver),this.sideDockManager=new Ns(this.docBrowserManager),this.serviceActionAuthorizationManager=new Ya,this.panelAppBridgeManager=new Wa(this.serviceActionAuthorizationManager),this.remoteAccessManager=new ki({accountManager:this.accountManager})}},Js=null;function Ys(){return Js??=new qs,Js}function Xs(){return Ys()}var Zs=(0,j.createContext)(null);function Qs({children:e}){let t=(0,j.useMemo)(()=>Ys(),[]);return(0,V.jsx)(Zs.Provider,{value:t,children:e})}function $s(){let e=(0,j.useContext)(Zs);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}export{bi as A,Un as B,W as C,Ei as D,U as E,oi as F,B as G,Wn as H,ni as I,ct as J,_n as K,ti as L,_i as M,mi as N,Oi as O,di as P,Nr as R,ki as S,Ti as T,Gn as U,Lr as V,qn as W,za as _,bs as a,Pi as b,qa as c,Ha as d,J as f,Ra as g,La as h,Ds as i,yi as j,xi as k,q as l,Ba as m,$s as n,as as o,Va as p,yn as q,Xs as r,is as s,Qs as t,Y as u,zi as v,Si as w,Ni as x,Ri as y,Ir as z};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CjPUPAAK.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CjPUPAAK.js";var t=e(`Boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]);export{t};
@@ -1,105 +0,0 @@
1
- import{d as e,h as t,i as n,m as r,v as i}from"./react-oAHNoVya.js";import{A as a,Bt as o,D as s,Dt as c,E as l,Et as u,Ft as d,Gt as f,Jt as p,Kt as m,Mt as h,O as g,Pt as _,Qt as v,Ut as y,Vt as b,Wt as x,Xt as S,Yt as C,an as w,in as T,j as E,jt as D,k as O,nn as ee,on as te,qt as ne,rn as k,sn as A,yt as j,zt as M}from"./api-BAyyGaoz.js";import{G as re,I as N,K as ie,N as ae,d as P,f as F,l as I,q as oe,u as L}from"./app-presenter-provider-DqHHfC1K.js";import{a as se,c as ce,i as R,l as z,n as le,o as ue,r as de,s as B}from"./mcp-marketplace-page-CmUKUeno.js";import{a as fe,i as V,n as pe,o as me,r as he,s as ge}from"./confirm-dialog-CVbgKuHp.js";import{t as H}from"./createLucideIcon-CjPUPAAK.js";import{t as _e}from"./arrow-left-Bn-3Pj3p.js";import{t as ve}from"./provider-scoped-model-input-C6xL7zSJ.js";import{t as ye}from"./ellipsis-CdkxFkVZ.js";import{t as be}from"./play-DyBWW2j4.js";import{t as xe}from"./plus-BlnBmcKE.js";import{t as Se}from"./refresh-cw-o8NSmIYV.js";import{t as Ce}from"./trash-2-C9tc-9sQ.js";import{t as we}from"./notice-card-CFTFtJky.js";import{n as Te,r as Ee,t as De}from"./popover-DPqa_Mfb.js";import{n as Oe}from"./doc-browser-context-Cb1sEUT0.js";import{A as ke,At as Ae,B as je,C as Me,Ct as Ne,D as Pe,E as Fe,Et as Ie,F as Le,Ft as Re,H as ze,I as U,J as W,K as Be,L as Ve,M as He,N as Ue,O as We,Ot as Ge,P as Ke,Pt as qe,R as Je,Rt as Ye,S as Xe,T as Ze,V as Qe,X as $e,Y as et,Z as tt,_ as nt,a as rt,b as it,c as at,d as ot,dt as st,f as ct,g as lt,h as ut,i as dt,j as ft,jt as pt,k as mt,l as ht,lt as gt,m as _t,mt as vt,n as yt,nt as bt,o as xt,ot as St,p as Ct,q as wt,r as Tt,s as Et,st as Dt,t as Ot,tt as kt,u as G,ut as At,v as jt,w as Mt,wt as Nt,x as K,y as q,z as Pt,zt as Ft}from"./index-Ccbswzt9.js";import{t as It}from"./tabs-custom-Cjo0bHw8.js";import{t as Lt}from"./tag-chip-DnNWFRMu.js";import{c as Rt,n as zt,r as Bt}from"./provider-models-CXUgDxGR.js";function Vt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ht(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ut=class extends A{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,k.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!te(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Vt(e,n).forEach(e=>{e.destroy()}),Vt(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=w(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new ee(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ht(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},J=i(t(),1);function Wt({queries:e,...t},n){let r=v(n),i=S(),a=C(),o=J.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{y(e),m(e,a,r.getQueryCache().get(e.queryHash))}),p(a);let[s]=J.useState(()=>new Ut(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;J.useSyncExternalStore(J.useCallback(e=>d?s.subscribe(k.batchCalls(e)):T,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),J.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let h=c.some((e,t)=>f(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&f(n,e)?x(n,new ee(r,n),a):[]}):[];if(h.length>0)throw Promise.all(h);let g=c.find((e,t)=>{let n=o[t];return n&&ne({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(g?.error)throw g.error;return l(u())}var Gt=H(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),Kt=H(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),qt=H(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Jt=H(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Yt=H(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Xt=H(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),Zt=H(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Qt=H(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Y=r(),$t=J.forwardRef(({className:t,...n},r)=>(0,Y.jsx)(`textarea`,{className:e(`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`,t),ref:r,...n}));$t.displayName=`Textarea`;function en(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function tn(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=q(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:K(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 nn({value:e,disabled:t=!1,runtimeOptions:r,defaultRuntime:i,onChange:a}){let o=e.trim()?q(e):``,s=tn({runtimeOptions:r,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?n(`agentsRuntimeUnavailableHelp`):``);return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(Be,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,Y.jsx)(et,{"aria-label":n(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,Y.jsx)($e,{placeholder:n(`agentsRuntimeSelectPlaceholder`)})}),(0,Y.jsx)(wt,{className:`rounded-xl`,children:s.map(e=>(0,Y.jsx)(W,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,Y.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function rn({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,Y.jsx)(pe,{open:e!==null,onOpenChange:a,children:e?(0,Y.jsx)(an,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function an(e){let{agent:t,pending:r,providerCatalog:i,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:c}=e,[l,u]=(0,J.useState)(en(t));return(0,Y.jsxs)(he,{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,Y.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,Y.jsxs)(me,{className:`text-left`,children:[(0,Y.jsx)(ge,{children:n(`agentsEditDialogTitle`)}),(0,Y.jsx)(V,{children:n(`agentsEditDialogDescription`)})]})}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(we,{tone:`warning`,title:n(`agentsEditHomeReadonly`),description:n(`agentsEditHomeReadonlyHint`),children:(0,Y.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(_,{value:l.displayName,onChange:e=>u(t=>({...t,displayName:e.target.value})),placeholder:n(`agentsFormNamePlaceholder`)}),(0,Y.jsx)($t,{value:l.description,onChange:e=>u(t=>({...t,description:e.target.value})),placeholder:n(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,Y.jsx)(_,{value:l.avatar,onChange:e=>u(t=>({...t,avatar:e.target.value})),placeholder:n(`agentsFormAvatarPlaceholder`)}),(0,Y.jsx)(ve,{value:l.model,onChange:e=>u(t=>({...t,model:e})),providerCatalog:i,disabled:r,className:`md:col-span-2`}),(0,Y.jsx)(nn,{value:l.runtime,onChange:e=>u(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:r})]})]})}),(0,Y.jsxs)(fe,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,Y.jsx)(d,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:r,children:n(`cancel`)}),(0,Y.jsxs)(d,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>c(t.id,l),disabled:r,children:[(0,Y.jsx)(Ge,{className:`mr-2 h-4 w-4`}),n(`agentsEditSaveAction`)]})]})]})}var on=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function sn(e){let{agentCount:t,onCreate:r}=e;return(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:n(`agentsHeroEyebrow`)}),(0,Y.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,Y.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:n(`agentsHeroDescription`)})]}),(0,Y.jsxs)(d,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:r,children:[(0,Y.jsx)(xe,{className:`mr-2 h-4 w-4`}),n(`agentsCreateButton`)]})]})}function cn(t){let{icon:n,label:r,disabled:i=!1,destructive:a=!1,onClick:o}=t;return(0,Y.jsxs)(`button`,{type:`button`,className:e(`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:i,children:[(0,Y.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{children:r})]})}function ln(e){let{agent:t,runtimeOptions:r,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:s,onEdit:l,onDelete:f}=e,p=t.runtime?.trim()||t.engine?.trim()||``,m=p?r.find(e=>e.value===q(p))?.label??K(p):i;return(0,Y.jsx)(u,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,Y.jsxs)(c,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,Y.jsx)(ze,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,Y.jsxs)(Lt,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,Y.jsx)(ae,{className:`h-3 w-3`}),n(`agentsCardBuiltInTag`)]}):null]}),(0,Y.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,Y.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,Y.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":n(`agentsCardStartChat`),title:n(`agentsCardStartChat`),onClick:s,children:(0,Y.jsx)(Ae,{className:`h-4 w-4`})}),(0,Y.jsxs)(De,{children:[(0,Y.jsx)(Ee,{asChild:!0,children:(0,Y.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":n(`chatSessionMoreActions`),title:n(`chatSessionMoreActions`),children:(0,Y.jsx)(ye,{className:`h-4 w-4`})})}),(0,Y.jsxs)(Te,{align:`end`,className:`w-44 p-1.5`,children:[(0,Y.jsx)(cn,{icon:Ge,label:n(`agentsEditAction`),onClick:l,disabled:a}),t.builtIn?null:(0,Y.jsx)(cn,{icon:Ce,label:n(`agentsRemoveAction`),onClick:f,disabled:o,destructive:!0})]})]})]}),(0,Y.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-gray-600`,children:t.description?.trim()||(t.builtIn?n(`agentsCardBuiltInSummary`):n(`agentsCardCustomSummary`))}),(0,Y.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(Ie,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,Y.jsx)(`span`,{className:`truncate`,children:m})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(pt,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function un(){let e=Pt(),t=Me(),r=tt(),i=At(),a=gt(),o=Et(),s=Ze(),l=Mt(),[f,p]=(0,J.useState)(null),m=(0,J.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),g=(0,J.useMemo)(()=>[...m].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[m]),_=(0,J.useMemo)(()=>zt({config:r.data,providersView:i.data,templatesView:a.data,onlyConfigured:!0}),[r.data,i.data,a.data]),v=(0,J.useMemo)(()=>jt(o.data?.options??[]),[o.data?.options]),y=(0,J.useMemo)(()=>q(o.data?.defaultType??`native`),[o.data?.defaultType]),b=(0,J.useMemo)(()=>v.find(e=>e.value===y)?.label??K(y),[y,v]),x=e=>{p(e)},S=async(e,t)=>{await s.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)},C=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,it(t,y))};return(0,Y.jsxs)(h,{className:`space-y-5`,children:[(0,Y.jsx)(sn,{agentCount:m.length,onCreate:()=>e.startAgentCreationDraft(on)}),(0,Y.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,Y.jsx)(u,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,Y.jsx)(c,{className:`py-14 text-center text-sm text-gray-500`,children:n(`agentsLoading`)})}):g.length===0?(0,Y.jsx)(u,{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,Y.jsxs)(c,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,Y.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,Y.jsx)(Ye,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,Y.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:n(`agentsEmpty`)}),(0,Y.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:n(`agentsEmptyDescription`)}),(0,Y.jsxs)(d,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:()=>e.startAgentCreationDraft(on),children:[(0,Y.jsx)(xe,{className:`mr-2 h-4 w-4`}),n(`agentsCreateButton`)]})]})}):g.map(e=>(0,Y.jsx)(ln,{agent:e,runtimeOptions:v,defaultRuntimeLabel:b,updatePending:s.isPending,deletePending:l.isPending,onStartChat:()=>C(e),onEdit:()=>x(e),onDelete:()=>l.mutate({agentId:e.id})},e.id))}),(0,Y.jsx)(rn,{agent:f,pending:s.isPending,providerCatalog:_,runtimeOptions:v,defaultRuntime:y,onOpenChange:e=>{!e&&!s.isPending&&p(null)},onSubmit:S})]})}function dn(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 fn(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function pn(t){let{job:r,onDelete:i,onRun:a,onToggle:o}=t;return(0,Y.jsx)(u,{className:`border border-gray-200`,children:(0,Y.jsx)(c,{className:`pt-5 pb-5`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:r.name||r.id}),(0,Y.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-semibold text-gray-500`,children:r.id}),(0,Y.jsx)(`span`,{className:e(`rounded-full px-2 py-0.5 text-[10px] font-semibold`,r.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:r.enabled?n(`enabled`):n(`disabled`)}),r.deleteAfterRun?(0,Y.jsx)(`span`,{className:`rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-semibold text-amber-700`,children:n(`cronOneShot`)}):null]}),(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[n(`cronScheduleLabel`),`: `,ct(r)]}),(0,Y.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-gray-700`,children:r.payload.message}),(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[n(`cronSessionLabel`),`: `,Ct(r)]}),(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[n(`cronDeliverTo`),`: `,ot(r)]})]}),(0,Y.jsxs)(`div`,{className:`min-w-[220px] space-y-2 text-xs text-gray-500`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[n(`cronNextRun`),`:`]}),` `,_t(r.state.nextRunAt)]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[n(`cronLastRun`),`:`]}),` `,_t(r.state.lastRunAt)]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[n(`cronLastStatus`),`:`]}),` `,r.state.lastStatus??`-`]}),r.state.lastError?(0,Y.jsx)(`div`,{className:`break-words text-[11px] text-red-500`,children:r.state.lastError}):null]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-end gap-2`,children:[(0,Y.jsxs)(d,{variant:`subtle`,size:`sm`,onClick:()=>a(r),className:`gap-1`,children:[(0,Y.jsx)(be,{className:`h-3.5 w-3.5`}),n(`cronRunNow`)]}),(0,Y.jsxs)(d,{variant:r.enabled?`outline`:`primary`,size:`sm`,onClick:()=>o(r),className:`gap-1`,children:[(0,Y.jsx)(Zt,{className:`h-3.5 w-3.5`}),r.enabled?n(`cronDisable`):n(`cronEnable`)]}),(0,Y.jsxs)(d,{variant:`destructive`,size:`sm`,onClick:()=>i(r),className:`gap-1`,children:[(0,Y.jsx)(Ce,{className:`h-3.5 w-3.5`}),n(`delete`)]})]})]})})})}function mn(){let[t,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(`all`),o=kt({all:!0}),s=bt(),c=vt(),l=st(),{confirm:u,ConfirmDialog:f}=ut(),p=(0,J.useMemo)(()=>(o.data?.jobs??[]).filter(e=>dn(e,t)).filter(e=>fn(e,i)),[o.data,t,i]),m=async e=>{await u({title:`${n(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:n(`delete`)})&&s.mutate({id:e.id})},g=async e=>{let t=!e.enabled;await u({title:t?`${n(`cronEnableConfirm`)}?`:`${n(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:n(t?`cronEnable`:`cronDisable`)})&&c.mutate({id:e.id,enabled:t})},v=async e=>{let t=!e.enabled;await u({title:t?`${n(`cronRunForceConfirm`)}?`:`${n(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:n(`cronRunNow`)})&&l.mutate({id:e.id,force:t})};return(0,Y.jsxs)(h,{fullHeight:!0,children:[(0,Y.jsx)(D,{title:n(`cronPageTitle`),description:n(`cronPageDescription`),actions:(0,Y.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>o.refetch(),children:(0,Y.jsx)(Se,{className:e(`h-4 w-4`,o.isFetching&&`animate-spin`)})})}),(0,Y.jsx)(`div`,{className:`mb-6`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,Y.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,Y.jsx)(_,{value:t,onChange:e=>r(e.target.value),placeholder:n(`cronSearchPlaceholder`),className:`pl-9`}),(0,Y.jsx)(Ft,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,Y.jsx)(`div`,{className:`min-w-[180px]`,children:(0,Y.jsxs)(Be,{value:i,onValueChange:e=>a(e),children:[(0,Y.jsx)(et,{className:`w-full`,children:(0,Y.jsx)($e,{placeholder:n(`cronStatusLabel`)})}),(0,Y.jsxs)(wt,{children:[(0,Y.jsx)(W,{value:`all`,children:n(`cronStatusAll`)}),(0,Y.jsx)(W,{value:`enabled`,children:n(`cronStatusEnabled`)}),(0,Y.jsx)(W,{value:`disabled`,children:n(`cronStatusDisabled`)})]})]})}),(0,Y.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[n(`cronTotalLabel`),`: `,o.data?.total??0,` / `,p.length]})]})}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:o.isLoading?(0,Y.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:n(`cronLoading`)}):p.length===0?(0,Y.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:n(`cronEmpty`)}):(0,Y.jsx)(`div`,{className:`space-y-4`,children:p.map(e=>(0,Y.jsx)(pn,{job:e,onDelete:m,onRun:v,onToggle:g},e.id))})}),(0,Y.jsx)(f,{})]})}function hn(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function gn(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function _n(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function vn(e,t){return t??{type:e,total:0,specs:[],records:[]}}function yn(e){let t=vn(e.result.type,e.view),n=gn(e),r=t.records.findIndex(e=>_n(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:hn(i),total:i.length}}function bn(e){let t=vn(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!_n(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:hn(n),total:n.length}}let n=t.records.map(t=>_n(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:e.result.action===`update`?{...t,installedAt:new Date().toISOString(),origin:t.origin??`marketplace`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:hn(n),total:n.length}}function xn(e){let t=z({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&Sn(r,e)?t:void 0},staleTime:15e3}),n=(0,J.useMemo)(()=>ce(t.data),[t.data]);return{...t,data:n}}function Sn(e,t){return e.q===t.q&&e.tag===t.tag&&e.scene===t.scene&&e.sort===t.sort&&e.pageSize===t.pageSize}function Cn(e=!0){return b({queryKey:[`marketplace-skill-scenes`],queryFn:O,enabled:e,staleTime:6e4})}function wn(e,t=!0){let n=Wt({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>s({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,J.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function Tn(e){return b({queryKey:[`marketplace-installed`,e],queryFn:()=>l(e),staleTime:1e4})}function En(){let e=v();return o({mutationFn:e=>a(e),onSuccess:(t,r)=>{e.setQueryData([`marketplace-installed`,t.type],e=>yn({view:e,request:r,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),M.success(t.message||n(`marketplaceInstallSuccessSkill`))},onError:e=>{M.error(e.message||n(`marketplaceInstallFailed`))}})}function Dn(){let e=v();return o({mutationFn:e=>E(e),onSuccess:(t,r)=>{e.setQueryData([`marketplace-installed`,t.type],e=>bn({view:e,request:r,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`});let i=t.action===`enable`?n(`marketplaceEnableSuccess`):t.action===`disable`?n(`marketplaceDisableSuccess`):t.action===`update`?n(`marketplaceUpdateSuccess`):n(`marketplaceUninstallSuccess`);M.success(t.message||i)},onError:e=>{M.error(e.message||n(`marketplaceOperationFailed`))}})}function On(e){return(e??``).trim().toLowerCase()}function X(e,t){let n=On(t);return n.length>0?`${e}:${n}`:``}function kn(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=X(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function An(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=X(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function jn(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=X(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function Mn(e,t){return t.get(X(e.type,e.spec))||t.get(X(e.type,e.id))||t.get(X(e.type,e.label))}function Nn(e,t,n,r){let i=On(n);if(!i)return!0;let a=R(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>On(e)).filter(Boolean).some(e=>e.includes(i))}function Z(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Pn(e){let t=e.replace(/\r\n/g,`
2
- `).split(`
3
- `);if(t[0]?.trim()!==`---`)return e;let n=t.findIndex((e,t)=>t>0&&e.trim()===`---`);return n>0?t.slice(n+1).join(`
4
- `).trim():e}function Fn(e){return Z(e).replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`)}function In(e){return/^(#{1,4})\s+/.test(e)||/^([-*])\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)}function Ln(e,t,n){let r=[],i=t+1;for(;i<e.length&&!e[i]?.trim().startsWith("```");)r.push(e[i]??``),i+=1;return{html:`<div class="code-block">${n[1]?`<span class="code-language">${Z(n[1])}</span>`:``}<pre><code>${Z(r.join(`
5
- `))}</code></pre></div>`,nextIndex:i+1}}function Rn(e,t){let n=Math.min(4,e[1]?.length??2);return{html:`<h${n}>${Fn(e[2]??``)}</h${n}>`,nextIndex:t+1}}function zn(e,t,n){let r=[],i=t,a=n?/^\d+\.\s+/:/^[-*]\s+/;for(;i<e.length&&a.test(e[i]?.trim()??``);)r.push(`<li>${Fn((e[i]??``).trim().replace(a,``))}</li>`),i+=1;return{html:n?`<ol>${r.join(``)}</ol>`:`<ul>${r.join(``)}</ul>`,nextIndex:i}}function Bn(e,t){let n=[],r=t;for(;r<e.length&&/^>\s?/.test(e[r]?.trim()??``);)n.push((e[r]??``).trim().replace(/^>\s?/,``)),r+=1;return{html:`<blockquote>${Fn(n.join(` `))}</blockquote>`,nextIndex:r}}function Vn(e,t){let n=[],r=t;for(;r<e.length;){let t=e[r]?.trim()??``;if(!t||In(t))break;n.push(t),r+=1}return{html:`<p>${Fn(n.join(` `))}</p>`,nextIndex:r}}function Hn(e,t){let n=e[t]?.trim()??``,r=n.match(/^```(\S*)/);if(r)return Ln(e,t,r);let i=n.match(/^(#{1,4})\s+(.+)$/);return i?Rn(i,t):/^[-*]\s+/.test(n)?zn(e,t,!1):/^\d+\.\s+/.test(n)?zn(e,t,!0):/^>\s?/.test(n)?Bn(e,t):Vn(e,t)}function Un(e){let t=Pn(e).replace(/\r\n/g,`
6
- `).split(`
7
- `),n=[],r=0;for(;r<t.length;){if(!(t[r]??``).trim()){r+=1;continue}let e=Hn(t,r);n.push(e.html),r=e.nextIndex}return n.join(``)}function Wn(e){return Array.isArray(e)?e.map(e=>Wn(e)).join(`, `):e&&typeof e==`object`?JSON.stringify(e):String(e??``)}function Gn(e){try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?[]:Object.entries(t).map(([e,t])=>({key:e,value:Wn(t)})).filter(e=>e.value.trim().length>0)}catch{return[]}}function Kn(e){return e.replace(/\r\n/g,`
8
- `).split(`
9
- `).map(e=>e.match(/^([A-Za-z0-9_.-]+):\s*(.+)$/)).filter(e=>!!e).map(e=>({key:e[1]??``,value:e[2]?.replace(/^["']|["']$/g,``)??``})).filter(e=>e.key&&e.value.trim().length>0)}function qn(e){let t=Gn(e),n=t.length>0?t:Kn(e);return n.length===0?`<pre class="code">${Z(e)}</pre>`:`<dl class="metadata-list">${n.map(e=>`<div><dt>${Z(e.key)}</dt><dd>${Z(e.value)}</dd></div>`).join(``)}</dl>`}function Jn(e){let{title:t,typeLabel:n,spec:r,summary:i,description:a,metadataRaw:o,contentRaw:s,sourceUrl:c,sourceLabel:l,tags:u,author:d,loading:f}=e,p=o?.trim()||`-`,m=s?.trim()||`-`,h=i?.trim(),g=a?.trim(),_=!!g&&g!==h,v=qn(p),y=Un(m),b=`<!doctype html>
10
- <html>
11
- <head>
12
- <meta charset="utf-8" />
13
- <meta name="viewport" content="width=device-width, initial-scale=1" />
14
- <title>${Z(t)}</title>
15
- <style>
16
- :root { color-scheme: light; }
17
- body { margin: 0; background: #f9f8f5; color: #2f2212; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
18
- .wrap { max-width: 940px; margin: 0 auto; padding: 24px 20px 36px; }
19
- .hero { border: 1px solid #f0e2c8; border-radius: 14px; background: linear-gradient(180deg, #fff9f1 0%, #ffffff 28%); padding: 18px; box-shadow: 0 1px 3px rgba(30, 20, 10, 0.05); }
20
- .hero h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: 0; }
21
- .meta { margin-top: 7px; color: #78644d; font-size: 12px; overflow-wrap: anywhere; word-break: break-word; }
22
- .summary { margin: 12px 0 0; font-size: 13px; line-height: 1.65; color: #5f5142; }
23
- .grid { display: grid; grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
24
- .card { border: 1px solid #eee3d1; background: #fffdf9; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(30, 20, 10, 0.035); }
25
- .card h2 { margin: 0; padding: 11px 13px; font-size: 12px; font-weight: 650; color: #3f472f; border-bottom: 1px solid #f1e7d4; background: #fffaf2; }
26
- .card .body { padding: 12px 13px; font-size: 12px; color: #4e463d; line-height: 1.65; }
27
- .code { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.55; margin: 0; }
28
- .metadata-list { margin: 0; }
29
- .metadata-list div { display: grid; grid-template-columns: minmax(72px, 0.36fr) minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid #f2eadc; }
30
- .metadata-list div:last-child { border-bottom: 0; }
31
- .metadata-list dt { color: #7a5a24; font-weight: 650; overflow-wrap: anywhere; }
32
- .metadata-list dd { margin: 0; color: #4e463d; overflow-wrap: anywhere; }
33
- .markdown { font-size: 13px; line-height: 1.68; }
34
- .markdown > *:first-child { margin-top: 0; }
35
- .markdown > *:last-child { margin-bottom: 0; }
36
- .markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 18px 0 8px; color: #2f2212; line-height: 1.25; letter-spacing: 0; }
37
- .markdown h1 { font-size: 20px; }
38
- .markdown h2 { font-size: 17px; }
39
- .markdown h3 { font-size: 15px; }
40
- .markdown h4 { font-size: 13px; }
41
- .markdown p { margin: 10px 0; }
42
- .markdown ul, .markdown ol { margin: 10px 0; padding-left: 20px; }
43
- .markdown li { margin: 5px 0; }
44
- .markdown blockquote { margin: 12px 0; padding: 8px 12px; border-left: 3px solid #d9b56f; border-radius: 8px; background: #fff7ea; color: #6d5841; }
45
- .markdown code { border: 1px solid #eadcc6; border-radius: 5px; background: #fff7ea; padding: 1px 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: #6b4b16; }
46
- .markdown a { color: #5f6b45; text-decoration: none; font-weight: 600; }
47
- .markdown a:hover { text-decoration: underline; }
48
- .code-block { position: relative; margin: 12px 0; overflow: hidden; border: 1px solid #eadcc6; border-radius: 10px; background: #2f2a24; }
49
- .code-block pre { margin: 0; overflow-x: auto; padding: 13px; }
50
- .code-block code { border: 0; border-radius: 0; background: transparent; padding: 0; color: #f7efe3; }
51
- .code-language { position: absolute; right: 10px; top: 8px; color: #d8c3a0; font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
52
- .tags { margin-top: 10px; }
53
- .tag { display: inline-block; margin: 0 6px 6px 0; padding: 4px 8px; border: 1px solid #ecd9b5; border-radius: 999px; background: #fff7ea; color: #7a5a24; font-size: 11px; }
54
- .source { color: #5f6b45; text-decoration: none; overflow-wrap: anywhere; word-break: break-all; }
55
- .source:hover { text-decoration: underline; }
56
- .skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, #f0e6d6 0%, #fffaf2 42%, #f0e6d6 78%); background-size: 220% 100%; animation: shimmer 1.35s ease-in-out infinite; }
57
- .detail-skeleton .hero { padding: 18px; }
58
- .sk-title { width: 52%; height: 24px; }
59
- .sk-meta { width: 78%; height: 12px; margin-top: 12px; }
60
- .sk-line { height: 12px; margin-top: 12px; }
61
- .sk-line.short { width: 62%; }
62
- .sk-line.mid { width: 82%; }
63
- .sk-body { height: 220px; margin: 13px; }
64
- @keyframes shimmer { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
65
- @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
66
- </style>
67
- </head>
68
- <body>
69
- <main class="wrap${f?` detail-skeleton`:``}"${f?` aria-busy="true"`:``}>
70
- ${f?`
71
- <section class="hero">
72
- <span class="skeleton sk-title"></span>
73
- <span class="skeleton sk-meta"></span>
74
- <span class="skeleton sk-line mid"></span>
75
- <span class="skeleton sk-line"></span>
76
- <span class="skeleton sk-line short"></span>
77
- </section>
78
- <section class="grid">
79
- <article class="card"><span class="skeleton sk-body"></span></article>
80
- <article class="card"><span class="skeleton sk-body"></span></article>
81
- </section>
82
- `:`
83
- <section class="hero">
84
- <h1>${Z(t)}</h1>
85
- <div class="meta">${Z(n)} · ${Z(r)}${d?` · ${Z(d)}`:``}</div>
86
- ${h?`<p class="summary">${Z(h)}</p>`:``}
87
- ${_?`<p class="summary">${Z(g)}</p>`:``}
88
- ${u&&u.length>0?`<div class="tags">${u.map(e=>`<span class="tag">${Z(e)}</span>`).join(``)}</div>`:``}
89
- ${c?`<p class="meta" style="margin-top:12px;">${Z(l??`Source`)}: <a class="source" href="${Z(c)}" target="_blank" rel="noopener noreferrer">${Z(c)}</a></p>`:``}
90
- </section>
91
-
92
- <section class="grid">
93
- <article class="card">
94
- <h2>Metadata</h2>
95
- <div class="body">${v}</div>
96
- </article>
97
- <article class="card">
98
- <h2>Content</h2>
99
- <div class="body markdown">${y}</div>
100
- </article>
101
- </section>
102
- `}
103
- </main>
104
- </body>
105
- </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(b)}`}var Yn=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`];function Xn(t){let{name:n,fallback:r,className:i}=t,a=n||r,o=a.substring(0,2).toUpperCase();return(0,Y.jsx)(`div`,{className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-sm font-semibold text-white`,Zn(a),i),children:o})}function Zn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Yn[Math.abs(t)%Yn.length]}function Qn({title:e,spec:t,summary:n}){return(0,Y.jsxs)(P,{delayDuration:400,children:[(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`truncate text-[14px] font-semibold leading-tight text-gray-900`,children:e})}),(0,Y.jsx)(L,{className:`max-w-[300px] text-xs`,children:e})]}),(0,Y.jsx)(`div`,{className:`mb-1.5 mt-0.5 flex min-w-0 items-center gap-1.5`,children:t?(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(`span`,{className:`max-w-full truncate text-[11px] font-mono text-gray-400`,children:t})}),(0,Y.jsx)(L,{className:`max-w-[300px] break-all font-mono text-xs`,children:t})]}):null}),(0,Y.jsx)(`p`,{className:`line-clamp-2 text-left text-[12px] leading-relaxed text-gray-500/90`,children:n})]})}function $n(t){let{item:r,record:i,isInstalling:a,isDisabled:o,canUpdate:s,canUninstall:c,busyAction:l,busyForRecord:u,language:d,onInstall:f,onManage:p}=t,m=!!(r&&!i||i&&(s||c));return(0,Y.jsxs)(`div`,{className:e(`relative flex h-8 shrink-0 items-center justify-end`,i?`md:w-5`:`md:w-0`),children:[(0,Y.jsx)(`div`,{className:e(`hidden items-center justify-end transition-opacity duration-150 md:flex`,m&&`group-hover:opacity-0 group-focus-within:opacity-0`),children:i?(0,Y.jsx)(er,{disabled:o,language:d}):null}),(0,Y.jsxs)(`div`,{className:e(`flex w-max items-center justify-end gap-2 transition-opacity duration-150`,`opacity-100 md:pointer-events-none md:absolute md:right-0 md:opacity-0`,`md:group-hover:pointer-events-auto md:group-hover:opacity-100`,`md:group-focus-within:pointer-events-auto md:group-focus-within:opacity-100`),children:[r&&!i&&(0,Y.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f(r)},disabled:a,className:`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-xl bg-primary px-3 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50`,children:[(0,Y.jsx)(qe,{className:`h-3.5 w-3.5`}),n(a?`marketplaceInstalling`:`marketplaceInstall`)]}),i&&s&&(0,Y.jsxs)(`button`,{disabled:u,onClick:e=>{e.stopPropagation(),p(`update`,i)},className:`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-xl border border-blue-200/80 bg-white px-3 text-xs font-medium text-blue-600 transition-colors hover:border-blue-300 hover:bg-blue-50 disabled:opacity-50`,children:[(0,Y.jsx)(Se,{className:`h-3.5 w-3.5`}),n(l===`update`?`marketplaceUpdating`:`marketplaceUpdate`)]}),i&&c&&(0,Y.jsxs)(`button`,{disabled:u,onClick:e=>{e.stopPropagation(),p(`uninstall`,i)},className:`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 text-xs font-medium text-gray-500 transition-colors hover:border-rose-200 hover:bg-rose-50 hover:text-rose-600 disabled:opacity-50`,children:[(0,Y.jsx)(Ce,{className:`h-3.5 w-3.5`}),n(l===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)]})]})]})}function er(t){let{disabled:n,language:r}=t,i=nr(n?{zh:`已禁用`,en:`Disabled`}:{zh:`已安装`,en:`Installed`},r);return(0,Y.jsx)(P,{delayDuration:300,children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(`span`,{"aria-label":i,className:e(`inline-flex h-5 w-5 items-center justify-center`,n?`text-gray-400`:`text-emerald-700`),children:n?(0,Y.jsx)(N,{className:`h-4 w-4 opacity-40`}):(0,Y.jsx)(N,{className:`h-4 w-4`})})}),(0,Y.jsx)(L,{className:`text-xs`,children:i})]})})}function tr(e){let{item:t,record:r,language:i,installState:a,manageState:o,onOpen:s,onInstall:c,onManage:l}=e,u=de(i),d=t?.name??r?.label??r?.id??r?.spec??n(`marketplaceUnknownItem`),f=R(t?.summaryI18n,t?.summary,u)||(r?n(`marketplaceInstalledLocalSummary`):``),p=t?.install.spec??r?.spec??``,m=r?.id||r?.spec,h=m?o.actionsByTarget.get(m):void 0,g=!!h,_=r?.type===`skill`&&r.source===`workspace`,v=r?.type===`skill`&&r.origin===`marketplace`,y=r?r.enabled===!1||r.runtimeStatus===`disabled`:!1,b=t?.install.spec,x=typeof b==`string`&&a.installingSpecs.has(b);return(0,Y.jsxs)(`article`,{onClick:s,className:`group flex cursor-pointer items-start justify-between gap-3.5 rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm transition-all hover:border-blue-300/80 hover:shadow-md`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,Y.jsx)(Xn,{name:d,fallback:p||n(`marketplaceTypeSkill`)}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center`,children:(0,Y.jsx)(Qn,{title:d,spec:p,summary:f})})]}),(0,Y.jsx)($n,{item:t,record:r,isInstalling:x,isDisabled:y,canUpdate:v,canUninstall:_,busyAction:h,busyForRecord:g,language:i,onInstall:c,onManage:l})]})}function nr(e,t){return t.startsWith(`zh`)?e.zh:e.en}function rr(t){let{scope:n,title:r,summary:i,showTitle:a,showListSkeleton:o,skeletonCardCount:s,allItems:c,installedEntries:l,installedRecordLookup:u,language:d,installState:f,manageState:p,onOpen:m,onInstall:h,onManage:g}=t;return(0,Y.jsxs)(`section`,{className:e(`flex min-h-full flex-col`,a&&`gap-3`),children:[a&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-950`,children:r}),(0,Y.jsx)(`span`,{className:`text-[12px] text-gray-500`,children:i})]}),(0,Y.jsxs)(`div`,{"data-testid":o?`marketplace-list-skeleton`:void 0,className:e(`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`,o&&`min-h-0 flex-1 auto-rows-[104px] content-start`),children:[o&&(0,Y.jsx)(B,{count:s}),!o&&n===`all`&&c.map(e=>(0,Y.jsx)(tr,{item:e,record:jn(e,u),language:d,installState:f,manageState:p,onOpen:()=>m(e,jn(e,u)),onInstall:h,onManage:g},e.id)),!o&&n===`installed`&&l.map(e=>(0,Y.jsx)(tr,{item:e.item,record:e.record,language:d,installState:f,manageState:p,onOpen:()=>m(e.item,e.record),onInstall:h,onManage:g},e.key))]})]})}function ir(t){let{entry:r,language:i,localeFallbacks:a,installState:o,layout:s=`rail`,onOpen:c,onInstall:l}=t,{item:u,record:d}=r,f=R(u.summaryI18n,u.summary,a),p=u.install.spec,m=o.installingSpecs.has(p),h=!!d;return(0,Y.jsxs)(`article`,{onClick:()=>c(r),className:e(`group flex min-h-[166px] cursor-pointer flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,s===`rail`?`w-[260px] shrink-0`:`w-full min-w-0`),children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(Xn,{name:u.name,fallback:u.install.spec}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[13px] font-semibold leading-tight text-gray-950`,children:u.name}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] font-mono leading-tight text-gray-400`,children:ar(u)})]})]}),(0,Y.jsx)(`p`,{className:`line-clamp-2 text-[12px] leading-relaxed text-gray-500`,children:f}),(0,Y.jsx)(or,{tags:u.tags})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-gray-400`,children:sr(u.updatedAt)}),h?(0,Y.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 text-[11px] font-semibold text-emerald-700`,children:[(0,Y.jsx)(N,{className:`h-3.5 w-3.5`}),cr({zh:`已安装`,en:`Installed`},i)]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:m,onClick:e=>{e.stopPropagation(),l(u)},className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-gray-200 bg-white px-2 text-[11px] font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 disabled:opacity-50`,children:[(0,Y.jsx)(qe,{className:`h-3.5 w-3.5`}),n(m?`marketplaceInstalling`:`marketplaceInstall`)]})]})]})}function ar(e){return e.slug||e.install.spec}function or({tags:e}){let t=e.slice(0,2);return t.length===0?null:(0,Y.jsx)(`div`,{className:`mt-2 truncate text-[11px] font-medium text-gray-400`,children:t.join(` / `)})}function sr(e){return e.slice(0,10)||e}function cr(e,t){return t.startsWith(`zh`)?e.zh:e.en}var lr=[{scene:`development-debugging`,title:{zh:`开发与调试`,en:`Development`},summary:{zh:`代码审查、错误定位、架构分析与交付验证。`,en:`Review, debug, analyze, and verify delivery work.`},icon:Qt,tone:`dark`,span:`md:col-span-2`},{scene:`office-collaboration`,title:{zh:`办公协作`,en:`Office Work`},summary:{zh:`连接文档、日历、会议、邮件和团队通信。`,en:`Connect docs, calendars, meetings, mail, and teams.`},icon:Gt,tone:`green`,span:`md:col-span-2`},{scene:`writing-content`,title:{zh:`写作与内容`,en:`Writing`},summary:{zh:`把调研、写作、润色和发布组织成连续工作流。`,en:`Turn research, writing, polishing, and publishing into one flow.`},icon:Xt,tone:`amber`,span:`md:col-span-2`},{scene:`browser-automation`,title:{zh:`浏览器自动化`,en:`Browser`},summary:{zh:`操作网页、捕获动态内容并验证真实用户路径。`,en:`Operate pages, capture dynamic content, and verify user paths.`},icon:Jt,tone:`blue`,span:`md:col-span-2`},{scene:`local-environment`,title:{zh:`本地环境`,en:`Local`},summary:{zh:`管理终端、文件、运行时和本地服务。`,en:`Manage shells, files, runtimes, and local services.`},icon:Re,tone:`violet`,span:`md:col-span-1`},{scene:`social-platforms`,title:{zh:`社交平台`,en:`Social`},summary:{zh:`处理发布、互动、检索和内容分发。`,en:`Handle posting, interaction, search, and distribution.`},icon:Yt,tone:`sky`,span:`md:col-span-1`},{scene:`nextclaw-official`,title:{zh:`NextClaw 官方`,en:`NextClaw Official`},summary:{zh:`优先查看由 NextClaw 维护的原生能力。`,en:`Browse native capabilities maintained by NextClaw.`},icon:Ie,tone:`teal`,span:`md:col-span-2`}],ur={icon:Ie,tone:`dark`,span:`md:col-span-2`},dr={dark:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-stone-600 bg-stone-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},blue:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-cyan-600 bg-cyan-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},green:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-emerald-600 bg-emerald-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},amber:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-amber-600 bg-amber-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},violet:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-violet-500 bg-violet-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},sky:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-sky-500 bg-sky-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},teal:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-teal-600 bg-teal-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`}},fr=`grid grid-cols-[repeat(auto-fill,minmax(240px,320px))] justify-start gap-3`,pr=24;function mr(e){let{entries:t,scenes:n,isScenesLoading:r,isItemsLoading:i,language:a,installState:o,onOpen:s,onInstall:c,onOpenScene:l}=e,u=de(a),d=[...t].sort((e,t)=>xr(e.item,t.item)).slice(0,6);return(0,Y.jsxs)(`div`,{className:`mb-4 space-y-5`,children:[(0,Y.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,Y.jsx)(br,{icon:qt,title:Q({zh:`场景`,en:`Scenes`},a),description:Q({zh:`按使用场景浏览适合的技能组合。`,en:`Browse skills by how you plan to use them.`},a)}),r?(0,Y.jsx)(hr,{}):(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:n.map(e=>(0,Y.jsx)(gr,{scene:e,language:a,onSelect:l},e.scene))})]}),(i||d.length>0)&&(0,Y.jsx)(vr,{icon:Kt,title:Q({zh:`最近更新`,en:`Recently updated`},a),description:Q({zh:`看看生态最近在补齐哪些能力。`,en:`See what the ecosystem has been improving lately.`},a),entries:d,language:a,localeFallbacks:u,isLoading:i,installState:o,onOpen:s,onInstall:c})]})}function hr(){return(0,Y.jsx)(`div`,{"data-testid":`marketplace-scenes-skeleton`,className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:lr.map(e=>(0,Y.jsxs)(`div`,{className:`flex min-h-[74px] flex-col justify-center rounded-lg border border-gray-200/70 bg-white px-3 py-2.5 shadow-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(G,{className:`h-7 w-7 shrink-0 rounded-md`}),(0,Y.jsx)(G,{className:`h-3.5 min-w-0 flex-1`}),(0,Y.jsx)(G,{className:`h-3 w-8 shrink-0`})]}),(0,Y.jsx)(G,{className:`mt-2 h-3 w-4/5`})]},e.scene))})}function gr(t){let{scene:n,language:r,onSelect:i}=t,a=Sr(n.scene),o=a.icon,s=dr[a.tone];return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(n.scene),className:e(`group flex min-h-[74px] flex-col justify-center rounded-lg border px-3 py-2.5 text-left shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/70`,s.card),children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:e(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,s.icon),children:(0,Y.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-gray-950`,children:Cr(n,a,r)}),typeof n.count==`number`&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:Tr(n.count,r)})]}),(0,Y.jsx)(`p`,{className:e(`mt-1 line-clamp-1 text-[11px] leading-relaxed`,s.text),children:wr(n,a,r)})]})})}function _r(t){let{scene:n,entries:r,isLoading:i,language:a,localeFallbacks:o,installState:s,onBack:c,onOpen:l,onInstall:u}=t,d=Sr(n.scene),f=d.icon,p=dr[d.tone];return(0,Y.jsxs)(`section`,{className:`flex min-h-full flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-4 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":Q({zh:`返回`,en:`Back`},a),children:(0,Y.jsx)(_e,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:e(`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border`,p.icon),children:(0,Y.jsx)(f,{className:`h-4 w-4`})}),(0,Y.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-gray-950`,children:Cr(n,d,a)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:Q(i?{zh:`加载中`,en:`Loading`}:{zh:`${r.length} 个技能`,en:`${r.length} skills`},a)})]}),(0,Y.jsx)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2`,children:(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[12px] leading-relaxed text-gray-500`,children:wr(n,d,a)})})]})]}),i?(0,Y.jsx)(`div`,{"data-testid":`marketplace-scene-skeleton`,className:e(fr,`min-h-0 flex-1 auto-rows-[166px] content-start`),children:(0,Y.jsx)(B,{count:pr})}):r.length>0?(0,Y.jsx)(`div`,{className:fr,children:r.map(e=>(0,Y.jsx)(ir,{entry:e,language:a,localeFallbacks:o,installState:s,layout:`grid`,onOpen:l,onInstall:u},e.item.id))}):(0,Y.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-200 py-8 text-center text-[12px] text-gray-500`,children:Q({zh:`这个模块暂无技能。`,en:`No skills in this module yet.`},a)})]})}function vr(e){let{icon:t,title:n,description:r,entries:i,language:a,localeFallbacks:o,isLoading:s,installState:c,onOpen:l,onInstall:u}=e;return(0,Y.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,Y.jsx)(br,{icon:t,title:n,description:r}),s?(0,Y.jsx)(yr,{}):(0,Y.jsx)(`div`,{className:`-mx-1 flex gap-2.5 overflow-x-auto px-1 pb-1.5 custom-scrollbar`,children:i.map(e=>(0,Y.jsx)(ir,{entry:e,language:a,localeFallbacks:o,installState:c,onOpen:l,onInstall:u},e.item.id))})]})}function yr(){return(0,Y.jsx)(`div`,{"data-testid":`marketplace-recent-skeleton`,className:`-mx-1 flex gap-2.5 overflow-hidden px-1 pb-1.5`,children:Array.from({length:4},(e,t)=>(0,Y.jsxs)(`article`,{className:`flex min-h-[166px] w-[260px] shrink-0 flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(G,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5 pt-0.5`,children:[(0,Y.jsx)(G,{className:`h-3.5 w-32 max-w-full`}),(0,Y.jsx)(G,{className:`h-3 w-24 max-w-full`})]})]}),(0,Y.jsx)(G,{className:`h-3 w-full`}),(0,Y.jsx)(G,{className:`mt-1.5 h-3 w-4/5`}),(0,Y.jsx)(G,{className:`mt-2 h-3 w-24`})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,Y.jsx)(G,{className:`h-3 w-20`}),(0,Y.jsx)(G,{className:`h-7 w-16 rounded-md`})]})]},`marketplace-recent-skeleton-${t}`))})}function br({icon:e,title:t,description:n}){return(0,Y.jsx)(`div`,{className:`flex items-end justify-between gap-4`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 text-[14px] font-semibold text-gray-950`,children:[(0,Y.jsx)(e,{className:`h-4 w-4 text-primary`}),t]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[12px] leading-relaxed text-gray-500`,children:n})]})})}function xr(e,t){let n=Date.parse(e.updatedAt),r=Date.parse(t.updatedAt);return Number.isNaN(n)||Number.isNaN(r)?t.updatedAt.localeCompare(e.updatedAt):r-n}function Q(e,t){return t.startsWith(`zh`)?e.zh:e.en}function Sr(e){return lr.find(t=>t.scene===e)??{scene:e,...ur}}function Cr(e,t,n){return t.title?Q(t.title,n):e.title}function wr(e,t,n){return t.summary?Q(t.summary,n):e.description??e.scene}function Tr(e,t){return t.startsWith(`zh`)?`${e} 个技能`:`${e} skills`}function Er(e){let{items:t,installedRecordLookup:n,scene:r,forcedType:i,typeFilter:a,scope:o,searchText:s,query:c,showListSkeleton:l,hasCatalogError:u}=e,d=Cn(a===`skill`),f=(0,J.useMemo)(()=>d.data?.scenes??[],[d.data?.scenes]),p=wn(f,a===`skill`),m=(0,J.useMemo)(()=>f.map(e=>({...e,count:typeof e.count==`number`?e.count:p.get(e.scene)})),[p,f]),h=(0,J.useMemo)(()=>t.map(e=>({item:e,record:jn(e,n)})),[t,n]),g=(0,J.useMemo)(()=>{let e=r?.trim();if(e)return m.find(t=>t.scene===e)??{scene:e,title:e}},[r,m]),_=a===`skill`&&!!r?.trim(),v=a===`skill`&&o===`all`&&!s.trim()&&!c&&!_,y=l||t.length>=4,b=v&&!u&&y&&m.length===0&&d.isLoading;return{entries:h,scenes:m,selectedScene:g,sceneEntries:h,isSceneRoute:_,isScenesLoading:b,showShelves:v&&!u&&y&&(l||m.length>0||b),backPath:i?`/skills`:`/marketplace/skills`,pathPrefix:i?`/skills/scenes`:`/marketplace/skills/scenes`}}var Dr=20,Or=36;function kr(){return{pageTitle:`marketplaceSkillsPageTitle`,pageDescription:`marketplaceSkillsPageDescription`,tabMarketplace:`marketplaceTabMarketplaceSkills`,tabInstalled:`marketplaceTabInstalledSkills`,searchPlaceholder:`marketplaceSearchPlaceholderSkills`,sectionCatalog:`marketplaceSectionSkills`,sectionInstalled:`marketplaceSectionInstalledSkills`,errorLoadData:`marketplaceErrorLoadingSkillsData`,errorLoadInstalled:`marketplaceErrorLoadingInstalledSkills`,emptyData:`marketplaceNoSkills`,emptyInstalled:`marketplaceNoInstalledSkills`,installedCountSuffix:`marketplaceInstalledSkillsCountSuffix`}}function Ar(e={}){let{forcedType:t}=e,r=ie(),i=oe(),{language:a}=Nt(),o=Oe(),s=`skill`,c=(0,J.useMemo)(()=>de(a),[a]),l=kr(),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,_]=(0,J.useState)(`all`),[v,y]=(0,J.useState)(`relevance`),[b,x]=(0,J.useState)(new Set),[S,C]=(0,J.useState)(new Map),w=(0,J.useRef)({byKey:new Map,seq:0});(0,J.useEffect)(()=>{let e=setTimeout(()=>{p(u.trim())},250);return()=>clearTimeout(e)},[u]);let T=Tn(s),E=s===`skill`?i.scene?.trim():void 0,D=xn({q:E?void 0:f||void 0,scene:E,type:s,sort:v,pageSize:Dr}),O=le({disabled:m!==`all`||D.isError||!D.hasNextPage||D.isFetchingNextPage,onLoadMore:()=>D.fetchNextPage(),watchValue:`${s}:${m}:${f}:${E??``}:${v}:${D.data?.loadedItems??0}:${D.data?.loadedPages??0}`});(0,J.useEffect)(()=>{let e=O.containerRef.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[O.containerRef,f,E,m,v,s]);let ee=En(),te=Dn(),{confirm:ne,ConfirmDialog:k}=ut(),A=(0,J.useMemo)(()=>T.data?.records??[],[T.data?.records]),j=(0,J.useMemo)(()=>D.data?.items??[],[D.data?.items]),M=(0,J.useMemo)(()=>kn(j),[j]),re=(0,J.useMemo)(()=>An(A),[A]),N=(0,J.useMemo)(()=>{let e=A.filter(e=>e.type===s).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:Mn(e,M)})).filter(e=>Nn(e.record,e.item,f,c));return e.sort((e,t)=>{let n=e.record.installedAt?Date.parse(e.record.installedAt):NaN,r=t.record.installedAt?Date.parse(t.record.installedAt):NaN;return!Number.isNaN(n)&&!Number.isNaN(r)&&n!==r?r-n:e.record.spec.localeCompare(t.record.spec)}),e},[A,s,M,f,c]),ae=m===`installed`?N.length:D.data?.total??0,P={showCatalog:m===`all`&&D.isLoading&&!D.data,showInstalled:m===`installed`&&T.isLoading&&!T.data},F=P.showCatalog||P.showInstalled,I=(0,J.useMemo)(()=>m===`installed`?T.isLoading&&!T.data?n(`loading`):`${N.length} ${n(l.installedCountSuffix)}`:D.data?`${j.length} / ${ae}`:n(`loading`),[m,T.data,T.isLoading,N.length,D.data,j.length,ae,l.installedCountSuffix]),L={installingSpecs:b},ce={actionsByTarget:S},z=Er({items:j,installedRecordLookup:re,scene:E,forcedType:t,typeFilter:s,scope:m,searchText:u,query:f,showListSkeleton:F,hasCatalogError:D.isError}),B=async e=>{let t=e.install.spec;if(!b.has(t)){x(e=>{let n=new Set(e);return n.add(t),n});try{await ee.mutateAsync({type:e.type,spec:t,kind:e.install.kind,skill:e.slug,installPath:`skills/${e.slug}`})}catch{}finally{x(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n})}}},fe=async(e,t)=>{let r=e===`update`?t.catalogSlug||t.id||t.spec:t.id||t.spec;if(r&&!S.has(r)&&!(e===`uninstall`&&!await ne({title:`${n(`marketplaceUninstallTitle`)} ${r}?`,description:n(`marketplaceUninstallDescription`),confirmLabel:n(`marketplaceUninstall`),variant:`destructive`}))){C(t=>{let n=new Map(t);return n.set(r,e),n});try{await te.mutateAsync({type:t.type,action:e,id:r,spec:t.spec})}finally{C(e=>{if(!e.has(r))return e;let t=new Map(e);return t.delete(r),t})}}},V=async(e,t)=>{let r=e?.name??t?.label??t?.id??t?.spec??n(`marketplaceUnknownItem`),i=e?`marketplace:${e.type}:${e.slug}`:`marketplace:${t?.type??`unknown`}:${t?.id??t?.spec??r}`,a={title:r,kind:`content`,dedupeKey:i},s={...a,activate:!1};if(!e){let e=Jn({title:r,typeLabel:n(`marketplaceTypeSkill`),spec:t?.spec??`-`,summary:n(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(t??{},null,2),contentRaw:`-`});o.open(e,a);return}let l=w.current.seq+1;w.current.seq=l,w.current.byKey.set(i,l);let u=R(e.summaryI18n,e.summary,c),d={typeLabel:n(`marketplaceTypeSkill`),loadContent:()=>g(e.slug),fallbackContent:n(`marketplaceOperationFailed`),defaultContent:void 0};o.open(Jn({title:r,typeLabel:d.typeLabel,spec:e.install.spec,loading:!0}),a);try{let t=await d.loadContent();if(w.current.byKey.get(i)!==l)return;let n=Jn({title:r,typeLabel:d.typeLabel,spec:e.install.spec,summary:u,metadataRaw:t.metadataRaw,contentRaw:t.bodyRaw||t.raw||d.defaultContent,sourceUrl:t.sourceUrl,sourceLabel:`Source (${t.source})`,tags:e.tags,author:e.author});o.open(n,s)}catch(t){if(w.current.byKey.get(i)!==l)return;let n=Jn({title:r,typeLabel:d.typeLabel,spec:e.install.spec,summary:u,metadataRaw:JSON.stringify({error:t instanceof Error?t.message:String(t)},null,2),contentRaw:d.fallbackContent});o.open(n,s)}};return(0,Y.jsxs)(h,{className:`flex h-full min-h-0 flex-col pb-0`,children:[!z.isSceneRoute&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(It,{tabs:[{id:`all`,label:n(l.tabMarketplace)},{id:`installed`,label:n(l.tabInstalled),count:T.data?.total??0}],activeTab:m,onChange:e=>_(e),className:`mb-3`}),(0,Y.jsx)(se,{scope:m,searchText:u,searchPlaceholder:n(l.searchPlaceholder),sort:v,onSearchTextChange:d,onSortChange:y})]}),(0,Y.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[!z.isSceneRoute&&!z.showShelves&&!F&&(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Y.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-900`,children:m===`installed`?n(l.sectionInstalled):a.startsWith(`zh`)?`全部技能`:`All Skills`}),(0,Y.jsx)(`span`,{className:`text-[12px] text-gray-500`,children:I})]}),m===`all`&&D.isError&&(0,Y.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[n(l.errorLoadData),`: `,D.error.message]}),m===`installed`&&T.isError&&(0,Y.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[n(l.errorLoadInstalled),`: `,T.error.message]}),(0,Y.jsxs)(`div`,{ref:O.containerRef,className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":F||D.isFetchingNextPage,children:[z.isSceneRoute&&z.selectedScene&&(0,Y.jsx)(_r,{scene:z.selectedScene,entries:z.sceneEntries,isLoading:F,language:a,localeFallbacks:c,installState:L,onBack:()=>r(z.backPath),onOpen:e=>void V(e.item,e.record),onInstall:B}),z.showShelves&&(0,Y.jsx)(mr,{entries:z.entries,scenes:z.scenes,isScenesLoading:z.isScenesLoading,isItemsLoading:F,language:a,installState:L,onOpen:e=>void V(e.item,e.record),onInstall:B,onOpenScene:e=>r(`${z.pathPrefix}/${e}`)}),!z.isSceneRoute&&(0,Y.jsx)(rr,{scope:m,title:m===`installed`?n(l.sectionInstalled):a.startsWith(`zh`)?`全部技能`:`All Skills`,summary:I,showTitle:z.showShelves,showListSkeleton:F,skeletonCardCount:Or,allItems:j,installedEntries:N,installedRecordLookup:re,language:a,installState:L,manageState:ce,onOpen:(e,t)=>void V(e,t),onInstall:B,onManage:fe}),m===`all`&&!z.isSceneRoute&&!F&&!D.isError&&j.length===0&&(0,Y.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:n(l.emptyData)}),m===`installed`&&!z.isSceneRoute&&!F&&!T.isError&&N.length===0&&(0,Y.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:n(l.emptyInstalled)}),m===`all`&&!F&&!D.isError&&(0,Y.jsx)(ue,{hasMore:!!D.hasNextPage,loading:D.isFetchingNextPage,sentinelRef:O.sentinelRef})]})]}),(0,Y.jsx)(k,{})]})}function jr(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,setSelectedSessionKey:i,selectedSessionKeyRef:a,resetStreamState:o}=e;(0,J.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&i(n);return}r!==null&&(i(null),o())}},[o,n,r,i,t]),(0,J.useEffect)(()=>{a.current=r},[r,a])}function Mr({view:e,confirmDialog:t}){let{isMobile:n}=Ne();return(0,Y.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,Y.jsx)(at,{}),e===`chat`?n?(0,Y.jsx)(Ot,{}):(0,Y.jsx)(ht,{}):(0,Y.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,Y.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Y.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Y.jsx)(mn,{})})}):e===`agents`?(0,Y.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Y.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Y.jsx)(un,{})})}):(0,Y.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,Y.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,Y.jsx)(Ar,{forcedType:`skills`})})})}),t]})}function Nr(e,t){return e.filter(e=>Qe(e,t))}function Pr(e){let{config:t,providersView:n,templatesView:r}=e;return(0,J.useMemo)(()=>{let e=zt({providersView:n,templatesView:r,config:t,onlyConfigured:!0}),i=new Set,a=[];for(let t of e)for(let e of t.models){let n=Bt(t.prefix,e);!n||i.has(n)||(i.add(n),a.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:Rt(t.modelThinking,e,t.aliases)}))}return a.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[t,n,r])}function Fr(e){let{sessions:t,sessionKey:n,sessionType:r}=e;return{recentSessionPreferredModel:(0,J.useMemo)(()=>yt({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredModel?.trim()||void 0}),[n,r,t]),recentSessionPreferredThinking:(0,J.useMemo)(()=>yt({sessions:t,selectedSessionKey:n??``,sessionType:r,readPreference:e=>e.preferredThinking??void 0}),[n,r,t])}}function Ir(e){let{currentSelectedModel:t,modelOptions:n}=e,r=(0,J.useMemo)(()=>n.find(e=>e.value===t),[t,n]);return{supportedThinkingLevels:(0,J.useMemo)(()=>r?.thinkingCapability?.supported??[],[r?.thinkingCapability?.supported]),defaultThinkingLevel:(0,J.useMemo)(()=>r?.thinkingCapability?.default??null,[r?.thinkingCapability?.default])}}function Lr(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 Rr(e){let{currentSelectedModel:t,pendingSessionType:n,projectRootOverride:r,query:i,sessionKey:a,setPendingSessionType:o,setSelectedModel:s,setSelectedThinkingLevel:c}=e,l=tt(),u=At(),d=gt(),f=Dt({limit:200}),p=Et(),m=St({sessionId:a?.trim()||`draft-session`,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:r??null}:{}}),h=(l.isFetched||l.isSuccess)&&(u.isFetched||u.isSuccess)&&(d.isFetched||d.isSuccess),g=Pr({config:l.data,providersView:u.data,templatesView:d.data}),_=(0,J.useMemo)(()=>f.data?.sessions??[],[f.data?.sessions]),v=(0,J.useMemo)(()=>Pe(_),[_]),y=(0,J.useMemo)(()=>Nr(v,i),[v,i]),b=(0,J.useMemo)(()=>v.find(e=>e.key===a)??null,[v,a]),x=(0,J.useMemo)(()=>m.data?.records??[],[m.data?.records]),S=Xe({selectedSession:b,pendingSessionType:n,setPendingSessionType:o,sessionTypesData:p.data}),C=(0,J.useMemo)(()=>Lr({modelOptions:g,supportedModels:S.selectedSessionTypeOption?.supportedModels}),[g,S.selectedSessionTypeOption?.supportedModels]),{recentSessionPreferredModel:w,recentSessionPreferredThinking:T}=Fr({sessions:v,sessionKey:a,sessionType:S.selectedSessionType}),{supportedThinkingLevels:E,defaultThinkingLevel:D}=Ir({currentSelectedModel:t,modelOptions:C});return Tt({modelOptions:C,selectedSessionKey:a??``,selectedSessionExists:!!b,selectedSessionPreferredModel:b?.preferredModel,fallbackPreferredModel:S.selectedSessionTypeOption?.recommendedModel??w,defaultModel:S.selectedSessionTypeOption?.recommendedModel??l.data?.agents.defaults.model,setSelectedModel:s}),dt({supportedThinkingLevels:E,selectedSessionKey:a??``,selectedSessionExists:!!b,selectedSessionPreferredThinking:b?.preferredThinking??null,fallbackPreferredThinking:T??null,defaultThinkingLevel:D,setSelectedThinkingLevel:c}),{configQuery:l,providersQuery:u,templatesQuery:d,sessionsQuery:f,sessionTypesQuery:p,sessionSkillsQuery:m,isProviderStateResolved:h,modelOptions:C,sessionSummaries:_,sessions:y,skillRecords:x,selectedSession:b,...S}}function zr(e){return e.parentSessionKey?e.sessionSummaries.map(We).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 Br(e){let{availableAgents:t,parentSessionId:n,selectedAgentId:r,selectedSession:i,selectedSessionType:a,sessionKey:o,sessionSummaries:s,sessionTypeOptions:c}=e,l=i?je(i):void 0,u=i?.agentId??r,d=t.find(e=>e.id===u)??null,f=(0,J.useMemo)(()=>{if(!n)return null;let e=s.find(e=>e.sessionId===n)??null;return e?We(e):null},[n,s]),p=c.find(e=>e.value===a)??null;return{currentSessionDisplayName:l,currentAgentId:u,currentAgent:d,parentSession:f,currentSessionTypeLabel:p?.label??K(a),currentSessionTypeIcon:p?.icon??null,currentChildSessionTabs:(0,J.useMemo)(()=>zr({parentSessionKey:o,sessionSummaries:s}),[o,s])}}function Vr(e){(0,J.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:Fe(e.agent.snapshot.contextWindow),parentSessionKey:e.parentSession?.key??null,parentSessionLabel:e.parentSession?je(e.parentSession):null,childSessionTabs:e.childSessionTabs})},[e])}function Hr(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 $(e,t){return e?Object.fromEntries(t.map(t=>[t,e])):{}}function Ur(e){let t=ke(e.projectRoot),n={...$(e.model?.trim(),[`model`,`preferred_model`]),...$(e.thinkingLevel?.trim(),[`thinkingEffort`,`thinking`,`preferred_thinking`]),...$(e.sessionType?.trim(),[`agentRuntimeId`,`session_type`,`runtime`]),...$(e.agentId?.trim(),[`agentId`,`agent_id`]),...$(t??void 0,[`projectRoot`,`project_root`])},r=Hr(e.requestedSkills);r.length>0&&(n.requested_skill_refs=r);let i=e.composerNodes?He(e.composerNodes):[];return i.length>0&&(n[ft]=i),n}function Wr(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r,selectedSessionProjectRoot:i}=e;return t!==null&&n!==null&&r===n&&(i??null)===t}function Gr(e){let t=Le(e=>e.snapshot.query),n=Le(e=>e.snapshot.selectedSessionKey),r=Le(e=>e.snapshot.selectedAgentId),i=U(e=>e.snapshot.pendingSessionType),a=U(e=>e.snapshot.pendingProjectRoot),o=U(e=>e.snapshot.pendingProjectRootSessionKey),s=U(e=>e.snapshot.selectedModel),c=j(),l=Ue(c),u=Me(),{confirm:d,ConfirmDialog:f}=ut(),p=re(),m=ie(),{sessionId:h}=oe(),g=(0,J.useRef)(null),_=(0,J.useRef)(n),v=(0,J.useMemo)(()=>xt(h),[h]),y=v??void 0,b=a!==null&&(!y||o===y),x=Rr({query:t,sessionKey:y??null,projectRootOverride:b?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:l,agentsQuery:u,confirm:d,ConfirmDialog:f,location:p,navigate:m,threadRef:g,selectedSessionKeyRef:_,routeSessionKey:v,sessionKey:y,hasSessionProjectRootOverride:b,agent:nt(y),...x}}function Kr(e){let t=Gr(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?mt(m):l?.projectName??mt(m),g=n.hydrateError?.message??n.snapshot.error?.message??null,_=s.phase===`ready`&&lt(g)?null:g,v=(r.data?.agents?.length??0)>0?r.data?.agents??[]:[{id:l?.agentId??c}],y=Br({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`?_:Ke({message:_,status:s}),...y}}function qr(e){let{agent:t,pendingProjectRoot:n,pendingProjectRootSessionKey:r,presenter:i,selectedSession:a,selectedSessionKeyRef:o,sessionKey:s}=e;(0,J.useEffect)(()=>{i.chatStreamActionsManager.bind({sendMessage:async e=>{if((e.sessionKey??null)!==(s??null))return;let o=Ur({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=Ve({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 Jr(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,selectedSession:r}=e;(0,J.useEffect)(()=>{!r||!Wr({pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r.key,selectedSessionProjectRoot:r.projectRoot??null})||U.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[t,n,r])}function Yr(e){let{confirm:t,location:n,navigate:r,presenter:i}=e;(0,J.useEffect)(()=>{i.chatUiManager.syncState({pathname:n.pathname}),i.chatUiManager.bindActions({navigate:r,confirm:t})},[t,n.pathname,r,i])}function Xr(e){let{presenter:t,selectedAgentId:n,selectedSession:r}=e;(0,J.useEffect)(()=>{!r?.agentId||n===r.agentId||t.chatSessionListManager.setSelectedAgentId(r.agentId)},[t,n,r?.agentId])}function Zr(e){let{agent:t,presenter:n,routeSessionKey:r}=e,i=t.snapshot.activeRun?.sessionId??t.visibleMessages.find(e=>e.sessionId.trim())?.sessionId??null;(0,J.useEffect)(()=>{r||!i||n.chatSessionListManager.materializeRootSessionRoute(i)},[i,n,r])}function Qr({view:e}){let[t]=(0,J.useState)(()=>new rt),n=Kr(t);return qr(n),Jr(n),Yr(n),Xr(n),Zr(n),jr({view:e,routeSessionKey:n.routeSessionKey,selectedSessionKey:n.selectedSessionKey,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,selectedSessionKeyRef:n.selectedSessionKeyRef,resetStreamState:t.chatStreamActionsManager.resetStreamState}),Vr({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,Y.jsx)(Je,{presenter:t,children:(0,Y.jsx)(Mr,{view:e,confirmDialog:(0,Y.jsx)(n.ConfirmDialog,{})})})}function $r({view:e}){return(0,Y.jsx)(Qr,{view:e})}export{$r as ChatPage};