nextclaw 0.20.1 → 0.20.2

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 (54) hide show
  1. package/package.json +16 -16
  2. package/ui-dist/assets/app-presenter-provider-DIcnNB9s.js +3 -0
  3. package/ui-dist/assets/{wrench-qVIwShTF.js → boxes-BvA-I63l.js} +1 -1
  4. package/ui-dist/assets/channels-list-page-wK3l7p5R.js +8 -0
  5. package/ui-dist/assets/chat-page-DgehvdJT.js +105 -0
  6. package/ui-dist/assets/{confirm-dialog-B0TP-vPd.js → confirm-dialog-CGrKHbAW.js} +1 -1
  7. package/ui-dist/assets/desktop-update-config-CehWxSSg.js +1 -0
  8. package/ui-dist/assets/doc-browser-BgxmVsTx.js +1 -0
  9. package/ui-dist/assets/doc-browser-CZn5-Qbu.js +1 -0
  10. package/ui-dist/assets/doc-browser-context-B8gk7HMr.js +1 -0
  11. package/ui-dist/assets/index-DORmh0Cy.css +1 -0
  12. package/ui-dist/assets/index-DcFpvnge.js +101 -0
  13. package/ui-dist/assets/key-round-D41Oe35x.js +1 -0
  14. package/ui-dist/assets/mcp-marketplace-page-DBLhJWOJ.js +1 -0
  15. package/ui-dist/assets/{mcp-marketplace-page-DDjeHd1I.js → mcp-marketplace-page-Dvi8mCBd.js} +2 -2
  16. package/ui-dist/assets/model-config-B-EJXGtO.js +1 -0
  17. package/ui-dist/assets/popover-YieElO8c.js +1 -0
  18. package/ui-dist/assets/{provider-scoped-model-input-t1tCP5y5.js → provider-scoped-model-input-BPRNGqYn.js} +1 -1
  19. package/ui-dist/assets/providers-list-CtBpL1ZY.js +1 -0
  20. package/ui-dist/assets/remote-BGHbHoHf.js +1 -0
  21. package/ui-dist/assets/rotate-cw-jueVCNJQ.js +1 -0
  22. package/ui-dist/assets/runtime-config-page-C1Hv7mad.js +1 -0
  23. package/ui-dist/assets/search-config-G2O1fcRb.js +1 -0
  24. package/ui-dist/assets/{secrets-config-D1AUSEXX.js → secrets-config-TenzxYbE.js} +2 -2
  25. package/ui-dist/assets/status-dot-BSMG7ZaC.js +1 -0
  26. package/ui-dist/assets/tabs-D1CjpWNX.js +1 -0
  27. package/ui-dist/assets/trash-2-DSWTsARW.js +1 -0
  28. package/ui-dist/index.html +19 -13
  29. package/ui-dist/assets/channels-list-page-DXH1qYLs.js +0 -8
  30. package/ui-dist/assets/chat-page-Cpo0AFHb.js +0 -105
  31. package/ui-dist/assets/desktop-update-config-Be8x1jNy.js +0 -1
  32. package/ui-dist/assets/doc-browser-BI7HSaMK.js +0 -3
  33. package/ui-dist/assets/doc-browser-context-DB6TTHeE.js +0 -1
  34. package/ui-dist/assets/doc-browser-route-registry.utils-x5ijvk0u.js +0 -1
  35. package/ui-dist/assets/doc-browser-yTfN7UBH.js +0 -1
  36. package/ui-dist/assets/index-GVTiCf1s.js +0 -101
  37. package/ui-dist/assets/index-v0fAGXQW.css +0 -1
  38. package/ui-dist/assets/mcp-marketplace-page-WUkc7n94.js +0 -1
  39. package/ui-dist/assets/model-config-BjXMpU9U.js +0 -1
  40. package/ui-dist/assets/providers-list-C1D5p9kK.js +0 -1
  41. package/ui-dist/assets/remote-BHeENKxL.js +0 -1
  42. package/ui-dist/assets/runtime-config-page--O0Wq01S.js +0 -1
  43. package/ui-dist/assets/search-config-Dzpizo-_.js +0 -1
  44. /package/ui-dist/assets/{book-open-cPX0Za7Z.js → book-open-CRotBOF2.js} +0 -0
  45. /package/ui-dist/assets/{config-hints-CY1lg9IE.js → config-hints-A7G_jMTU.js} +0 -0
  46. /package/ui-dist/assets/{config-split-page-BFh_Qixx.js → config-split-page-BnTO1mAM.js} +0 -0
  47. /package/ui-dist/assets/{external-link-C3usm3se.js → external-link-DHjFdCpy.js} +0 -0
  48. /package/ui-dist/assets/{play-CqNi0u02.js → play-C-0vo7hi.js} +0 -0
  49. /package/ui-dist/assets/{plus-BcIC8dG1.js → plus-Cr_akLp2.js} +0 -0
  50. /package/ui-dist/assets/{save-D10M5vQg.js → save-aYdSdK97.js} +0 -0
  51. /package/ui-dist/assets/{setting-row-8VkukJoH.js → setting-row-BNu0qhOM.js} +0 -0
  52. /package/ui-dist/assets/{tabs-custom-BBXu1OGs.js → tabs-custom-CRSN1ekg.js} +0 -0
  53. /package/ui-dist/assets/{tag-chip-ix15P-r4.js → tag-chip-DEashiw6.js} +0 -0
  54. /package/ui-dist/assets/{x-Chb07O-Y.js → x-D1v_vb54.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "Powerful AI assistant for coordinating agents, skills, CLI tools, automations, and messaging apps.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -41,20 +41,20 @@
41
41
  "commander": "^12.1.0",
42
42
  "jszip": "^3.10.1",
43
43
  "yaml": "^2.8.1",
44
- "@nextclaw/core": "0.13.1",
45
- "@nextclaw/kernel": "0.2.1",
46
- "@nextclaw/ncp": "0.5.21",
47
- "@nextclaw/ncp-agent-runtime": "0.3.32",
48
- "@nextclaw/mcp": "0.2.1",
49
- "@nextclaw/ncp-mcp": "0.1.96",
50
- "@nextclaw/ncp-toolkit": "0.5.26",
51
- "@nextclaw/nextclaw-hermes-acp-bridge": "0.2.1",
52
- "@nextclaw/nextclaw-ncp-runtime-http-client": "0.2.1",
53
- "@nextclaw/remote": "0.2.1",
54
- "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.2.1",
55
- "@nextclaw/runtime": "0.3.1",
56
- "@nextclaw/service": "0.2.1",
57
- "@nextclaw/server": "0.13.1"
44
+ "@nextclaw/mcp": "0.2.2",
45
+ "@nextclaw/kernel": "0.2.2",
46
+ "@nextclaw/ncp": "0.5.22",
47
+ "@nextclaw/ncp-agent-runtime": "0.3.33",
48
+ "@nextclaw/nextclaw-hermes-acp-bridge": "0.2.2",
49
+ "@nextclaw/ncp-toolkit": "0.5.27",
50
+ "@nextclaw/core": "0.13.2",
51
+ "@nextclaw/nextclaw-ncp-runtime-http-client": "0.2.2",
52
+ "@nextclaw/remote": "0.2.2",
53
+ "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.2.2",
54
+ "@nextclaw/runtime": "0.3.2",
55
+ "@nextclaw/server": "0.13.2",
56
+ "@nextclaw/service": "0.2.2",
57
+ "@nextclaw/ncp-mcp": "0.1.97"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/node": "^20.17.6",
@@ -62,7 +62,7 @@
62
62
  "tsx": "^4.19.2",
63
63
  "typescript": "^5.6.3",
64
64
  "vitest": "^4.1.2",
65
- "@nextclaw/ui": "0.13.1"
65
+ "@nextclaw/ui": "0.13.2"
66
66
  },
67
67
  "scripts": {
68
68
  "dev": "tsx watch --tsconfig ../../scripts/dev/dev-runtime.tsconfig.json src/cli/app/index.ts",
@@ -0,0 +1,3 @@
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-B2X_ph0a.js";import{At as l,Dt as u,Et as d,Ft as f,Lt as p,Mt as m,Nt as h,Ot as g,Rt as _,St as v,Tt as y,Xt as b,a as x,c as S,dt as ee,i as te,jt as ne,kt as re,l as ie,o as ae,ot as C,r as oe,s as se,u as ce,wt as le,zt as ue}from"./api-DruAcori.js";import{C as de,S as fe,_ as pe,a as me,d as he,h as ge,i as _e,o as ve,p as ye,r as be,s as xe,t as Se,v as Ce,w,y as we}from"./dist-rzakR_bu.js";import{t as Te}from"./dist-CpwDZDtv.js";import{a as Ee,c as De,i as Oe,n as T,o as ke,r as Ae,s as je,t as Me}from"./confirm-dialog-CGrKHbAW.js";import{t as E}from"./createLucideIcon-Br1EFMEr.js";import{n as Ne,t as Pe}from"./search-CdhgFNwf.js";import{t as Fe}from"./book-open-CRotBOF2.js";import{t as Ie}from"./boxes-BvA-I63l.js";import{t as Le}from"./key-round-D41Oe35x.js";import{t as Re}from"./plus-Cr_akLp2.js";import{n as ze,t as Be}from"./rotate-cw-jueVCNJQ.js";import{t as Ve}from"./trash-2-DSWTsARW.js";import{t as He}from"./status-dot-BSMG7ZaC.js";import{n as Ue,r as We,t as Ge}from"./popover-YieElO8c.js";import{i as D,r as Ke,t as qe}from"./tabs-D1CjpWNX.js";import{a as O,c as Je,f as k,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-B8gk7HMr.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:P(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`?F(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:P(t)}return ht(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`?F(t):t,state:n,key:t&&t.key||r||ft()}}function P({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 F(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 ht(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 gt(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 gt(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:P(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function _t(e,t,n=`/`){return vt(e,t,n,!1)}function vt(e,t,n,r){let i=I((typeof t==`string`?F(t):t).pathname||`/`,n);if(i==null)return null;let a=bt(e);St(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=Ft(i);o=Mt(a[e],t,r)}return o}function yt(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 bt(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=L([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}".`),bt(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:At(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of xt(e.path))a(e,t,!0,n)}),t}function xt(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=xt(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 St(e){e.sort((e,t)=>e.score===t.score?jt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Ct=/^:[\w-]+$/,wt=3,Tt=2,Et=1,Dt=10,Ot=-2,kt=e=>e===`*`;function At(e,t){let n=e.split(`/`),r=n.length;return n.some(kt)&&(r+=Ot),t&&(r+=Tt),n.filter(e=>!kt(e)).reduce((e,t)=>e+(Ct.test(t)?wt:t===``?Et:Dt),r)}function jt(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 Mt(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=Nt({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=Nt({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:L([a,u.pathname]),pathnameBase:Ut(L([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=L([a,u.pathnameBase]))}return o}function Nt(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Pt(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 Pt(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 Ft(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 I(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 It=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Lt(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?F(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Rt(n.substring(1),`/`):Rt(n,t)):a=t,{pathname:a,search:Wt(r),hash:Gt(i)}}function Rt(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 zt(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 Bt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Vt(e){let t=Bt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Ht(e,t,n,r=!1){let i;typeof e==`string`?i=F(e):(i={...e},M(!i.pathname||!i.pathname.includes(`?`),zt(`?`,`pathname`,`search`,i)),M(!i.pathname||!i.pathname.includes(`#`),zt(`#`,`pathname`,`hash`,i)),M(!i.search||!i.search.includes(`#`),zt(`#`,`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=Lt(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var L=e=>e.join(`/`).replace(/\/\/+/g,`/`),Ut=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Wt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Gt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Kt=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 qt(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Jt(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Yt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Xt(e,t){let n=e;if(typeof n!=`string`||!It.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Yt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=I(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 Zt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Zt);var Qt=[`GET`,...Zt];new Set(Qt);var R=j.createContext(null);R.displayName=`DataRouter`;var $t=j.createContext(null);$t.displayName=`DataRouterState`;var en=j.createContext(!1),tn=j.createContext({isTransitioning:!1});tn.displayName=`ViewTransition`;var nn=j.createContext(new Map);nn.displayName=`Fetchers`;var rn=j.createContext(null);rn.displayName=`Await`;var z=j.createContext(null);z.displayName=`Navigation`;var an=j.createContext(null);an.displayName=`Location`;var B=j.createContext({outlet:null,matches:[],isDataRoute:!1});B.displayName=`Route`;var on=j.createContext(null);on.displayName=`RouteError`;var sn=`REACT_ROUTER_ERROR`,cn=`REDIRECT`,ln=`ROUTE_ERROR_RESPONSE`;function un(e){if(e.startsWith(`${sn}:${cn}:{`))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 dn(e){if(e.startsWith(`${sn}:${ln}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Kt(t.status,t.statusText,t.data)}catch{}}function fn(e,{relative:t}={}){M(V(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=j.useContext(z),{hash:i,pathname:a,search:o}=U(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:L([n,a])),r.createHref({pathname:s,search:o,hash:i})}function V(){return j.useContext(an)!=null}function H(){return M(V(),`useLocation() may be used only in the context of a <Router> component.`),j.useContext(an).location}var pn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function mn(e){j.useContext(z).static||j.useLayoutEffect(e)}function hn(){let{isDataRoute:e}=j.useContext(B);return e?In():gn()}function gn(){M(V(),`useNavigate() may be used only in the context of a <Router> component.`);let e=j.useContext(R),{basename:t,navigator:n}=j.useContext(z),{matches:r}=j.useContext(B),{pathname:i}=H(),a=JSON.stringify(Vt(r)),o=j.useRef(!1);return mn(()=>{o.current=!0}),j.useCallback((r,s={})=>{if(N(o.current,pn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Ht(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:L([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}j.createContext(null);function _n(){let{matches:e}=j.useContext(B),t=e[e.length-1];return t?t.params:{}}function U(e,{relative:t}={}){let{matches:n}=j.useContext(B),{pathname:r}=H(),i=JSON.stringify(Vt(n));return j.useMemo(()=>Ht(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function vn(e,t){return yn(e,t)}function yn(e,t,n,r,i){M(V(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=j.useContext(z),{matches:o}=j.useContext(B),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||``;Rn(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=H(),p;if(t){let e=typeof t==`string`?F(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=_t(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 _=En(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:L([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:L([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?j.createElement(an.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function bn(){let e=Fn(),t=qt(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 xn=j.createElement(bn,null),Sn=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=dn(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:j.createElement(B.Provider,{value:this.props.routeContext},j.createElement(on.Provider,{value:e,children:this.props.component}));return this.context?j.createElement(wn,{error:e},t):t}};Sn.contextType=en;var Cn=new WeakMap;function wn({children:e,error:t}){let{basename:n}=j.useContext(z);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=un(t.digest);if(e){let r=Cn.get(t);if(r)throw r;let i=Xt(e.location,n);if(Yt&&!Cn.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 Cn.set(t,n),n}return j.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function Tn({routeContext:e,match:t,children:n}){let r=j.useContext(R);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),j.createElement(B.Provider,{value:e},n)}function En(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:Jt(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||xn,s&&(c<0&&i===0?(Rn(`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(Tn,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?j.createElement(Sn,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function Dn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function On(e){let t=j.useContext(R);return M(t,Dn(e)),t}function kn(e){let t=j.useContext($t);return M(t,Dn(e)),t}function An(e){let t=j.useContext(B);return M(t,Dn(e)),t}function jn(e){let t=An(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 Mn(){return jn(`useRouteId`)}function Nn(){return kn(`useNavigation`).navigation}function Pn(){let{matches:e,loaderData:t}=kn(`useMatches`);return j.useMemo(()=>e.map(e=>yt(e,t)),[e,t])}function Fn(){let e=j.useContext(on),t=kn(`useRouteError`),n=jn(`useRouteError`);return e===void 0?t.errors?.[n]:e}function In(){let{router:e}=On(`useNavigate`),t=jn(`useNavigate`),n=j.useRef(!1);return mn(()=>{n.current=!0}),j.useCallback(async(r,i={})=>{N(n.current,pn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Ln={};function Rn(e,t,n){!t&&!Ln[e]&&(Ln[e]=!0,N(!1,n))}j.useOptimistic,j.memo(zn);function zn({routes:e,future:t,state:n,onError:r}){return yn(e,void 0,n,r,t)}function Bn({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(Un,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,unstable_useTransitions:i})}function Vn({to:e,replace:t,state:n,relative:r}){M(V(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=j.useContext(z);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(B),{pathname:o}=H(),s=hn(),c=Ht(e,Vt(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 Hn(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 Un({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){M(!V(),`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=F(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=j.useMemo(()=>{let e=I(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(z.Provider,{value:c},j.createElement(an.Provider,{children:t,value:m}))}function Wn({children:e,location:t}){return vn(Gn(e),t)}j.Component;function Gn(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,Gn(e.props.children,i));return}M(e.type===Hn,`[${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=Gn(e.props.children,i)),n.push(a)}),n}var Kn=`get`,qn=`application/x-www-form-urlencoded`;function Jn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Yn(e){return Jn(e)&&e.tagName.toLowerCase()===`button`}function Xn(e){return Jn(e)&&e.tagName.toLowerCase()===`form`}function Zn(e){return Jn(e)&&e.tagName.toLowerCase()===`input`}function Qn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function $n(e,t){return e.button===0&&(!t||t===`_self`)&&!Qn(e)}var er=null;function tr(){if(er===null)try{new FormData(document.createElement(`form`),0),er=!1}catch{er=!0}return er}var nr=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function rr(e){return e!=null&&!nr.has(e)?(N(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${qn}"`),null):e}function ir(e,t){let n,r,i,a,o;if(Xn(e)){let o=e.getAttribute(`action`);r=o?I(o,t):null,n=e.getAttribute(`method`)||Kn,i=rr(e.getAttribute(`enctype`))||qn,a=new FormData(e)}else if(Yn(e)||Zn(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?I(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Kn,i=rr(e.getAttribute(`formenctype`))||rr(o.getAttribute(`enctype`))||qn,a=new FormData(o,e),!tr()){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(Jn(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Kn,r=null,i=qn,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 ar={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},or=/[&><\u2028\u2029]/g;function sr(e){return e.replace(or,e=>ar[e])}function cr(e,t){if(e===!1||e==null)throw Error(t)}function lr(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&&I(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function ur(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 dr(e){return e!=null&&typeof e.page==`string`}function fr(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 pr(e,t,n){return vr((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await ur(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(fr).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function mr(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 hr(e,t,{includeHydrateFallback:n}={}){return gr(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 gr(e){return[...new Set(e)]}function _r(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function vr(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!dr(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(_r(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function yr(){let e=j.useContext(R);return cr(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function br(){let e=j.useContext($t);return cr(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var xr=j.createContext(void 0);xr.displayName=`FrameworkContext`;function Sr(){let e=j.useContext(xr);return cr(e,`You must render this element inside a <HydratedRouter> element`),e}function Cr(e,t){let n=j.useContext(xr),[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:wr(s,p),onBlur:wr(c,m),onMouseEnter:wr(l,p),onMouseLeave:wr(u,m),onTouchStart:wr(d,p)}]:[a,f,{}]:[!1,f,{}]}function wr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Tr({page:e,...t}){let{router:n}=yr(),r=j.useMemo(()=>_t(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?j.createElement(Dr,{page:e,matches:r,...t}):null}function Er(e){let{manifest:t,routeModules:n}=Sr(),[r,i]=j.useState([]);return j.useEffect(()=>{let r=!1;return pr(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Dr({page:e,matches:t,...n}){let r=H(),{future:i,manifest:a,routeModules:o}=Sr(),{basename:s}=yr(),{loaderData:c,matches:l}=br(),u=j.useMemo(()=>mr(e,t,l,a,r,`data`),[e,t,l,a,r]),d=j.useMemo(()=>mr(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=lr(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(()=>hr(d,a),[d,a]),m=Er(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 Or(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}j.Component;var kr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{kr&&(window.__reactRouterVersion=`7.13.0`)}catch{}function Ar({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(Un,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function jr({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(Un,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}jr.displayName=`unstable_HistoryRouter`;var Mr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Nr=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(z),g=typeof c==`string`&&Mr.test(c),_=Xt(c,m);c=_.to;let v=fn(c,{relative:r}),[y,b,x]=Cr(n,f),S=Br(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function ee(t){e&&e(t),t.defaultPrevented||S(t)}let te=j.createElement(`a`,{...f,...x,href:_.absoluteURL||v,onClick:_.isExternal||i?e:ee,ref:Or(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?j.createElement(j.Fragment,null,te,j.createElement(Tr,{page:v})):te});Nr.displayName=`Link`;var Pr=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=U(a,{relative:c.relative}),d=H(),f=j.useContext($t),{navigator:p,basename:m}=j.useContext(z),h=f!=null&&Xr(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=I(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},ee=b?e:void 0,te;te=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let ne=typeof i==`function`?i(S):i;return j.createElement(Nr,{...c,"aria-current":ee,className:te,ref:l,style:ne,to:a,viewTransition:o},typeof s==`function`?s(S):s)});Pr.displayName=`NavLink`;var Fr=j.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Kn,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=j.useContext(z),g=Ur(),_=Wr(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Mr.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})});Fr.displayName=`Form`;function Ir({getKey:e,storageKey:t,...n}){let r=j.useContext(xr),{basename:i}=j.useContext(z),a=H(),o=Pn();Jr({getKey:e,storageKey:t});let s=j.useMemo(()=>{if(!r||!e)return null;let t=qr(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})(${sr(JSON.stringify(t||Gr))}, ${sr(JSON.stringify(s))})`}})}Ir.displayName=`ScrollRestoration`;function Lr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Rr(e){let t=j.useContext(R);return M(t,Lr(e)),t}function zr(e){let t=j.useContext($t);return M(t,Lr(e)),t}function Br(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=hn(),u=H(),d=U(e,{relative:a});return j.useCallback(f=>{if($n(f,t)){f.preventDefault();let t=n===void 0?P(u)===P(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 Vr=0,Hr=()=>`__${String(++Vr)}__`;function Ur(){let{router:e}=Rr(`useSubmit`),{basename:t}=j.useContext(z),n=Mn(),r=e.fetch,i=e.navigate;return j.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=ir(e,t);a.navigate===!1?await r(a.fetcherKey||Hr(),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 Wr(e,{relative:t}={}){let{basename:n}=j.useContext(z),r=j.useContext(B);M(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...U(e||`.`,{relative:t})},o=H();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:L([n,a.pathname])),P(a)}var Gr=`react-router-scroll-positions`,Kr={};function qr(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:I(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Jr({getKey:e,storageKey:t}={}){let{router:n}=Rr(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=zr(`useScrollRestoration`),{basename:a}=j.useContext(z),o=H(),s=Pn(),c=Nn();j.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Yr(j.useCallback(()=>{if(c.state===`idle`){let t=qr(o,s,a,e);Kr[t]=window.scrollY}try{sessionStorage.setItem(t||Gr,JSON.stringify(Kr))}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||Gr);e&&(Kr=JSON.parse(e))}catch{}},[t]),j.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Kr,()=>window.scrollY,e?(t,n)=>qr(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 Yr(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 Xr(e,{relative:t}={}){let n=j.useContext(tn);M(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Rr(`useViewTransitionState`),i=U(e,{relative:t});if(!n.isTransitioning)return!1;let a=I(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=I(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Nt(i.pathname,o)!=null||Nt(i.pathname,a)!=null}var Zr=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`}]]),Qr=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`}]]),$r=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`}]]),ei=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`}]]),ti=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`}]]),ni=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`}]]),ri=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`}]]),ii=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`}]]),ai=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`}]]),oi=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`}]]),si=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`}]]),ci=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`}]]),li=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`}]]),ui=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 di(){return ue({queryKey:pi,queryFn:x,staleTime:5e3,refetchOnWindowFocus:!0})}var W=r();function G(e){let{label:t,muted:n,value:r}=e;return(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,W.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function fi(){let e=Cs(),t=di(),r=t.data,a=J(e=>e.actionLabel),o=(0,j.useMemo)(()=>wi(r),[r]),s=!!a,c=r?.runtime?.deviceName?.trim()||r?.settings.deviceName?.trim()||n(`remoteDeviceNameAuto`),f=!!(r?.account.loggedIn&&vi(r)),{hero:p,issueHint:m}=o;return(0,j.useEffect)(()=>{e.remoteAccessManager.syncStatus(r)},[e,r]),t.isLoading&&!r?(0,W.jsx)(`div`,{className:`p-8 text-gray-400`,children:n(`remoteLoading`)}):(0,W.jsxs)(l,{className:`space-y-6`,children:[(0,W.jsx)(re,{title:n(`remotePageTitle`),description:n(`remotePageDescription`)}),(0,W.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,W.jsxs)(le,{children:[(0,W.jsxs)(u,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(g,{children:p.title}),(0,W.jsx)(He,{status:p.badgeStatus,label:p.badgeLabel})]}),(0,W.jsx)(d,{children:p.description})]}),(0,W.jsxs)(y,{className:`space-y-5`,children:[(0,W.jsxs)(T,{tone:`neutral`,children:[(0,W.jsx)(G,{label:n(`remoteSignedInAccount`),value:r?.account.email}),(0,W.jsx)(G,{label:n(`remoteDeviceName`),value:c}),(0,W.jsx)(G,{label:n(`remoteConnectionStatus`),value:p.badgeLabel}),(0,W.jsx)(G,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[o.primaryAction?(0,W.jsxs)(h,{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,W.jsx)(ii,{className:`mr-2 h-4 w-4`}):null,a||o.primaryAction.label]}):null,(0,W.jsxs)(h,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:s||!f,children:[(0,W.jsx)(ci,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),r?.settings.enabled?(0,W.jsx)(h,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(r),disabled:s,children:n(`remoteDisable`)}):null]}),o.shouldShowIssueHint&&m?(0,W.jsx)(T,{tone:`warning`,title:m.title,description:m.body}):null,(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteOpenWebHint`)})]})]}),(0,W.jsxs)(le,{children:[(0,W.jsxs)(u,{children:[(0,W.jsxs)(g,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 text-primary`}),n(`remoteDeviceSectionTitle`)]}),(0,W.jsx)(d,{children:n(`remoteDeviceSectionDescription`)})]}),(0,W.jsxs)(y,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(He,{status:r?.account.loggedIn?`ready`:`inactive`,label:r?.account.loggedIn?n(`remoteAccountConnected`):n(`remoteAccountNotConnected`)}),(0,W.jsx)(He,{status:r?.settings.enabled?`active`:`inactive`,label:r?.settings.enabled?n(`remoteEnabled`):n(`remoteStateDisabled`)}),(0,W.jsx)(He,{status:r?.service.running?`active`:`inactive`,label:r?.service.running?n(`remoteServiceRunning`):n(`remoteServiceStopped`)})]}),(0,W.jsxs)(T,{tone:`neutral`,children:[(0,W.jsx)(G,{label:n(`remoteDeviceName`),value:c}),(0,W.jsx)(G,{label:n(`remoteConnectionStatus`),value:p.badgeLabel}),(0,W.jsx)(G,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,W.jsx)(T,{tone:`neutral`,borderStyle:`dashed`,description:r?.account.loggedIn?n(`remoteOpenWebHint`):n(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var pi=[`remote-status`],mi=`https://platform.nextclaw.io`,hi=`https://nextclaw-platform-console.pages.dev`,K=async()=>await f.fetchQuery({queryKey:pi,queryFn:x,staleTime:5e3}),q=async()=>(await f.invalidateQueries({queryKey:pi}),await K()),gi=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function _i(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 mi;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return hi}var vi=e=>_i(e?.account.apiBase)||_i(e?.settings.platformApiBase)||_i(e?.platformBase)||_i(e?.account.platformBase)||void 0,J=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})})),yi=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=J.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{J.getState().setEnabled(e)},this.setDeviceName=e=>{J.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{J.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{J.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await q(),n=J.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await q();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await q(),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 q();this.hydrateDraftFromStatus(e)},successMessage:n(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await q(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:J.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await q(),r=J.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 q();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 te();J.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=J.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 q();this.hydrateDraftFromStatus(n),e?await oe(n.service.running?`restart`:`start`):t.service.running&&await oe(`restart`);let i=await q();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 q();this.hydrateDraftFromStatus(n),p.success(t.message)}})},this.hydrateDraftFromStatus=e=>{J.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;J.getState().beginAction(t);try{await r(),i&&p.success(i)}catch(e){let t=e instanceof Error?e.message:n(`error`);throw p.error(t),e}finally{J.getState().finishAction()}}}},bi=[/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 xi(e){return e?.runtime?.lastError?.trim()||``}function Si(e){let t=n(`remoteStatusIssueDetailGeneric`),r=xi(e);return r?`${t} (${r})`:t}function Ci(e){if(!e?.settings.enabled)return!1;let t=xi(e);return bi.some(e=>e.test(t))}function wi(e){return Ci(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:Si(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 Y=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 Ti({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,W.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Ei(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,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(T,{tone:`success`,title:n(`accountPanelSignedInTitle`),description:n(`accountPanelSignedInDescription`)}),(0,W.jsxs)(T,{tone:`neutral`,children:[(0,W.jsx)(Ti,{label:n(`remoteAccountEmail`),value:t}),(0,W.jsx)(Ti,{label:n(`remoteAccountUsername`),value:r}),(0,W.jsx)(Ti,{label:n(`remoteAccountRole`),value:i})]}),r?(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteAccountUsernameLockedHelp`)}):(0,W.jsxs)(T,{tone:`warning`,title:n(`remoteAccountUsernameRequiredTitle`),description:n(`remoteAccountUsernameRequiredDescription`),children:[(0,W.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,W.jsx)(ne,{htmlFor:`account-panel-username`,children:n(`remoteAccountUsername`)}),(0,W.jsx)(m,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:n(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,W.jsx)(h,{disabled:!a,onClick:()=>void l(),children:n(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,W.jsxs)(h,{onClick:()=>void u(),children:[(0,W.jsx)(ci,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),(0,W.jsxs)(h,{variant:`outline`,onClick:()=>void d(),children:[(0,W.jsx)(ri,{className:`mr-2 h-4 w-4`}),n(`remoteLogout`)]})]})]})}function Di(e){let{authSessionId:t,authExpiresAt:r,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(T,{tone:`neutral`,title:n(`accountPanelSignedOutTitle`),description:n(`accountPanelSignedOutDescription`),children:t?(0,W.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,W.jsx)(Ti,{label:n(`remoteBrowserAuthSession`),value:t}),(0,W.jsx)(Ti,{label:n(`remoteBrowserAuthExpiresAt`),value:r?i(r):`-`})]}):null}),a?(0,W.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,W.jsx)(h,{onClick:()=>void s(),children:n(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,W.jsx)(h,{variant:`outline`,onClick:c,children:n(`remoteBrowserAuthResume`)}):null]})]})}function Oi(){let e=Cs(),t=di(),r=Y(e=>e.panelOpen),i=Y(e=>e.authSessionId),a=Y(e=>e.authVerificationUri),o=Y(e=>e.authExpiresAt),s=Y(e=>e.authStatusMessage),c=t.data,[l,u]=(0,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,W.jsx)(Ae,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,W.jsxs)(Oe,{className:`max-w-xl`,children:[(0,W.jsxs)(je,{children:[(0,W.jsxs)(De,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Le,{className:`h-5 w-5 text-primary`}),n(`accountPanelTitle`)]}),(0,W.jsx)(Ee,{children:n(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,W.jsx)(Ei,{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,W.jsx)(Di,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function ki({username:e}){let t=ee(),[r,i]=(0,j.useState)(e??``),[a,o]=(0,j.useState)(``),s=r.trim().length>0&&a.length>0&&!t.isPending;return(0,W.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,W.jsxs)(le,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,W.jsxs)(u,{children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:n(`authBrand`)}),(0,W.jsx)(g,{className:`text-2xl`,children:n(`authLoginTitle`)}),(0,W.jsx)(d,{children:n(`authLoginDescription`)})]}),(0,W.jsx)(y,{children:(0,W.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),s&&t.mutate({username:r.trim(),password:a})},children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authUsername`)}),(0,W.jsx)(m,{value:r,onChange:e=>i(e.target.value),placeholder:n(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authPassword`)}),(0,W.jsx)(m,{type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:n(`authPasswordPlaceholder`)})]}),(0,W.jsx)(h,{type:`submit`,className:`w-full`,disabled:!s,children:t.isPending?n(`authLoggingIn`):n(`authLoginAction`)})]})})]})})}var Ai=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{Y.getState().openPanel()},this.closeAccountPanel=()=>{Y.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),Y.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await K();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:gi(e?.status??await K(),t)});Y.getState().beginBrowserAuth({sessionId:r.sessionId,verificationUri:r.verificationUri,expiresAt:r.expiresAt,intervalMs:r.intervalMs,statusMessage:n(`remoteBrowserAuthWaiting`)}),window.open(r.verificationUri,`_blank`,`noopener,noreferrer`)||Y.getState().setAuthStatusMessage(n(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:n(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),p.error(`${n(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=Y.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await ae(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),Y.getState().clearBrowserAuth(),await q(),p.success(n(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteLogoutFailed`);p.error(`${n(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await ie({username:e.trim()}),await q(),p.success(n(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteAccountUsernameSetFailed`);p.error(`${n(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=vi(await K());if(!t){p.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}=Y.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Y.getState();if(e.authSessionId)try{let t=await K(),r=await se({sessionId:e.authSessionId,apiBase:gi(t)});if(r.status===`pending`){Y.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`))),Y.getState().clearBrowserAuth(),p.error(r.message||n(`remoteBrowserAuthExpired`));return}Y.getState().setAuthStatusMessage(n(`remoteBrowserAuthCompleted`));let i=await q();this.clearPollTimer(),this.resolveBrowserSignIn(i),Y.getState().clearBrowserAuth(),p.success(n(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),Y.getState().clearBrowserAuth();let t=e instanceof Error?e.message:n(`remoteBrowserAuthPollFailed`);p.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=Y.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}};function ji({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`)} ${Ni(t.lastOpenedAt)}`:`${n(`panelAppsUpdated`)} ${Ni(t.updatedAt)}`,p=e=>{e.stopPropagation(),o()},m=()=>{c(!1),u(!0)};return(0,W.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,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 text-left`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.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,W.jsx)(Pi,{icon:t.icon,title:t.title})}),(0,W.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,W.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,W.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.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,W.jsx)(li,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,W.jsxs)(Ge,{open:s,onOpenChange:c,children:[(0,W.jsx)(We,{asChild:!0,children:(0,W.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,W.jsx)(ei,{className:`h-4 w-4`})})}),(0,W.jsx)(Ue,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,W.jsx)(Mi,{destructive:!0,disabled:e,icon:Ve,label:n(`panelAppsDelete`),onClick:m})})]})]})]}),(0,W.jsx)(Me,{open:l,onOpenChange:u,title:n(`panelAppsDeleteConfirmTitle`),description:`${n(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:i,onCancel:()=>void 0})]})}function Mi({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,W.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,W.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:i})]})}function Ni(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 Pi({icon:e,title:t}){return e?Fi(e)?(0,W.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,W.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,W.jsx)(Zr,{className:`h-4 w-4`})}function Fi(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Ii=[`panel-apps`];function Li(){return ue({queryKey:Ii,queryFn:()=>C.panelApps.listPanelApps(),staleTime:0})}function Ri(){let e=b();return _({mutationFn:({id:e,preferences:t})=>C.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Ii})}})}function zi(){let e=b();return _({mutationFn:e=>C.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ii})}})}function Bi(){let e=b();return _({mutationFn:e=>C.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ii})}})}function Vi(e,t){return t===`favorites`?Hi(e.filter(e=>e.favorite),`smart`):Hi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function Hi(e,t){return[...e].sort((e,n)=>Ui(e,n,t))}function Ui(e,t,n){return n===`recent-open`?qi(e.lastOpenedAt,t.lastOpenedAt)||Wi(e,t):n===`updated`?qi(e.updatedAt,t.updatedAt)||Wi(e,t):n===`name`?Wi(e,t):Gi(e,t)||Number(t.favorite)-Number(e.favorite)||Wi(e,t)}function Wi(e,t){return e.title.localeCompare(t.title)}function Gi(e,t){return Ki(t)-Ki(e)}function Ki(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function qi(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var[Ji,Yi]=fe(`Tooltip`,[xe]),Xi=xe(),Zi=`TooltipProvider`,Qi=700,$i=`tooltip.open`,[ea,ta]=Ji(Zi),na=e=>{let{__scopeTooltip:t,delayDuration:n=Qi,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,W.jsx)(ea,{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})};na.displayName=Zi;var ra=`Tooltip`,[ia,aa]=Ji(ra),oa=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ta(ra,e.__scopeTooltip),l=Xi(t),[u,d]=j.useState(null),f=we(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=Ce({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent($i))):c.onClose(),a?.(e)},caller:ra}),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,W.jsx)(ve,{...l,children:(0,W.jsx)(ia,{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})})};oa.displayName=ra;var sa=`TooltipTrigger`,ca=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=aa(sa,n),a=ta(sa,n),o=Xi(n),s=de(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,W.jsx)(be,{asChild:!0,...o,children:(0,W.jsx)(ge.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:w(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:w(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:w(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:w(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:w(e.onBlur,i.onClose),onClick:w(e.onClick,i.onClose)})})});ca.displayName=sa;var la=`TooltipPortal`,[ua,da]=Ji(la,{forceMount:void 0}),fa=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=aa(la,t);return(0,W.jsx)(ua,{scope:t,forceMount:n,children:(0,W.jsx)(Te,{present:n||a.open,children:(0,W.jsx)(he,{asChild:!0,container:i,children:r})})})};fa.displayName=la;var X=`TooltipContent`,pa=j.forwardRef((e,t)=>{let n=da(X,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=aa(X,e.__scopeTooltip);return(0,W.jsx)(Te,{present:r||o.open,children:o.disableHoverableContent?(0,W.jsx)(va,{side:i,...a,ref:t}):(0,W.jsx)(ma,{side:i,...a,ref:t})})}),ma=j.forwardRef((e,t)=>{let n=aa(X,e.__scopeTooltip),r=ta(X,e.__scopeTooltip),i=j.useRef(null),a=de(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=Sa(r,xa(r,n.getBoundingClientRect())),a=Ca(t.getBoundingClientRect());s(Ta([...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=!wa(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,W.jsx)(va,{...e,ref:a})}),[ha,ga]=Ji(ra,{isInside:!1}),_a=pe(`TooltipContent`),va=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=aa(X,n),l=Xi(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener($i,u),()=>document.removeEventListener($i,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,W.jsx)(ye,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,W.jsxs)(me,{"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,W.jsx)(_a,{children:r}),(0,W.jsx)(ha,{scope:n,isInside:!0,children:(0,W.jsx)(Se,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});pa.displayName=X;var ya=`TooltipArrow`,ba=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Xi(n);return ga(ya,n).isInside?null:(0,W.jsx)(_e,{...i,...r,ref:t})});ba.displayName=ya;function xa(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 Sa(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 Ca(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 wa(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 Ta(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),Ea(t)}function Ea(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 Da=na,Oa=oa,ka=ca,Aa=fa,ja=pa,Ma=Da,Na=Oa,Pa=ka,Fa=j.forwardRef(({className:t,sideOffset:n=4,...r},i)=>(0,W.jsx)(Aa,{children:(0,W.jsx)(ja,{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})}));Fa.displayName=ja.displayName;function Ia({headerContent:e,onOpenPanelApp:t}){let r=Li(),i=Bi(),a=Ri(),o=zi(),[s,c]=(0,j.useState)(`smart`),l=(0,j.useMemo)(()=>Vi(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,W.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`panelAppsLoading`)}):r.isError?(0,W.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:r.error instanceof Error?r.error.message:n(`panelAppsLoadFailed`)}):(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`panelAppsTitle`)}),r.data?.panelsPath?(0,W.jsx)(Ma,{delayDuration:250,children:(0,W.jsxs)(Na,{children:[(0,W.jsx)(Pa,{asChild:!0,children:(0,W.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,W.jsx)($r,{className:`h-3.5 w-3.5`})})}),(0,W.jsx)(Fa,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:r.data.panelsPath})]})}):null]}),(0,W.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,W.jsx)(ze,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,W.jsx)(qe,{value:s,onValueChange:e=>c(e),children:(0,W.jsxs)(Ke,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,W.jsx)(D,{value:`smart`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortSmart`)}),(0,W.jsx)(D,{value:`favorites`,className:`px-2 py-1 text-xs`,children:n(`panelAppsFavorites`)}),(0,W.jsx)(D,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortRecentOpen`)}),(0,W.jsx)(D,{value:`updated`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortUpdated`)}),(0,W.jsx)(D,{value:`name`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortName`)})]})})}),l.length===0?(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`panelAppsEmpty`)}):(0,W.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,W.jsx)(`div`,{className:`space-y-1.5`,children:l.map(e=>(0,W.jsx)(ji,{entry:e,deletePending:i.isPending,favoritePending:a.isPending,onDelete:()=>f(e),onOpen:()=>void u(e),onToggleFavorite:()=>d(e)},e.id))})})]})}var La=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 v)||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 v)||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 v)||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 v({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 v({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 v?{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 Ra(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var za=s((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:Ra(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function Ba(){let e=za(e=>e.pending),t=za(e=>e.resolveAuthorization);return(0,W.jsx)(Ae,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,W.jsxs)(Oe,{className:`[&>:last-child]:hidden`,children:[(0,W.jsxs)(je,{children:[(0,W.jsxs)(De,{className:`flex items-center gap-2`,children:[(0,W.jsx)(oi,{className:`h-4 w-4 text-amber-600`}),n(`serviceActionAuthorizationTitle`)]}),(0,W.jsx)(Ee,{children:n(`serviceActionAuthorizationDescription`)})]}),e?(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,W.jsx)(Va,{label:n(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,W.jsx)(Va,{label:n(`serviceActionAuthorizationAction`),value:e.actionTitle??e.actionId}),e.actionDescription?(0,W.jsx)(Va,{label:n(`serviceActionAuthorizationPurpose`),value:e.actionDescription}):null,(0,W.jsx)(Va,{label:n(`serviceActionAuthorizationRisk`),value:e.risk??`dangerous`}),e.inputPreview?(0,W.jsx)(Va,{label:n(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,W.jsxs)(ke,{className:`gap-2 sm:gap-0`,children:[(0,W.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:n(`serviceActionAuthorizationReject`)}),(0,W.jsx)(h,{type:`button`,onClick:()=>t(!0),children:n(`serviceActionAuthorizationAllow`)})]})]})})}function Va({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,W.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Ha=class{constructor(){this.requestAuthorization=async e=>await za.getState().requestAuthorization(e)}},Ua=[`service-apps`],Wa=[`service-actions`],Ga=[`service-action-grants`];function Ka(){return ue({queryKey:Ua,queryFn:()=>C.serviceApps.listServiceApps()})}function qa(){return ue({queryKey:Wa,queryFn:()=>C.serviceApps.listServiceActions()})}function Ja(){return ue({queryKey:Ga,queryFn:()=>C.serviceApps.listServiceActionGrants()})}function Ya(){let e=b();return _({mutationFn:e=>C.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Ua}),e.invalidateQueries({queryKey:Wa})])}})}function Xa(){let e=b();return _({mutationFn:e=>C.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Ua})}})}function Za(){let e=b();return _({mutationFn:e=>C.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Wa}),e.invalidateQueries({queryKey:Ga})])}})}function Qa({headerContent:e}){let t=Ka(),r=qa(),i=Ja(),a=Ya(),o=Xa(),s=Za(),[c,l]=(0,j.useState)({}),u=()=>{t.refetch(),r.refetch(),i.refetch()};if(t.isLoading||r.isLoading||i.isLoading)return(0,W.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,W.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:n(`serviceAppsLoadFailed`)})}let d=t.data?.entries??[],f=r.data?.actions??[],p=i.data?.grants??[],m=e=>{o.mutateAsync(e).then(t=>{l(n=>({...n,[e]:t.actions}))})};return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,W.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ai,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`serviceAppsTitle`)})]})}),(0,W.jsx)(`button`,{type:`button`,onClick:u,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`serviceAppsRefresh`),"aria-label":n(`serviceAppsRefresh`),children:(0,W.jsx)(ze,{className:`h-3.5 w-3.5`})})]}),d.length===0?(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`serviceAppsEmpty`)}):(0,W.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,W.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,W.jsx)($a,{app:e,actions:c[e.id]??f.filter(t=>t.appId===e.id),grants:p,isDiscovering:o.isPending,onDiscover:m,onRestart:e=>void a.mutate(e),onRevoke:e=>void s.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function $a({app:e,actions:t,grants:r,isDiscovering:i,onDiscover:a,onRestart:o,onRevoke:s}){return(0,W.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,W.jsx)(`span`,{className:`rounded bg-gray-100 px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.status})]}),e.description?(0,W.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,W.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),disabled:i,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,title:n(`serviceAppsDiscoverActions`),"aria-label":n(`serviceAppsDiscoverActions`),children:(0,W.jsx)(Pe,{className:`h-3.5 w-3.5`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`serviceAppsRestart`),"aria-label":n(`serviceAppsRestart`),children:(0,W.jsx)(Be,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)(eo,{app:e}),(0,W.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,W.jsx)(no,{action:e,grants:r.filter(t=>t.actionId===e.id),onRevoke:s},e.id))})]})}function eo({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,W.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,W.jsx)(to,{label:e.label,value:e.value},e.label))})}function to({label:e,value:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,W.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function no({action:e,grants:t,onRevoke:r}){return(0,W.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(ui,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,W.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,W.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:n(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,W.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,W.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,W.jsx)(si,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,W.jsxs)(`span`,{className:`truncate`,children:[n(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,W.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,W.jsx)(Ve,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function ro({activeTab:e,onActiveTabChange:t,onOpenPanelApp:r}){let i=(0,W.jsx)(qe,{value:e,onValueChange:e=>t(e),children:(0,W.jsxs)(Ke,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,W.jsxs)(D,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,W.jsx)(Zr,{className:`h-3.5 w-3.5`}),n(`panelAppsTitle`)]}),(0,W.jsxs)(D,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,W.jsx)(ai,{className:`h-3.5 w-3.5`}),n(`serviceAppsTitle`)]})]})});return(0,W.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,W.jsx)(Ia,{headerContent:i,onOpenPanelApp:r}):(0,W.jsx)(Qa,{headerContent:i})})}function io({onOpenApps:e,onRefresh:t}){return(0,W.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,W.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,W.jsx)(Ne,{className:`h-3.5 w-3.5`}),n(`appsTitle`)]}),(0,W.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,W.jsx)(ze,{className:`h-3.5 w-3.5`})})]})}var ao=`home`,oo=`nextclaw://new-tab`,so=`apps`,Z=`nextclaw://apps`,co=`${Z}?tab=service-apps`,lo=`panel-app`,uo=`panel-apps`;function fo(e){return e===`panel-apps`||e===`service-apps`}function po(e=uo){return e===uo?Z:co}function mo(e){try{let t=new URL(e).searchParams.get(`tab`);return fo(t)?t:uo}catch{return uo}}function ho(e){return po(mo(e))}function go(e){return{dedupeKey:`panel-app:${e.id}`,historyPolicy:`managed`,kind:lo,title:e.title,url:e.contentPath}}function _o(e,t){return e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`)}function vo(e){let t=e.pathSegments.join(`/`);return Ye(t?`/${t}`:`/`,`docs`)}function yo(e){let t=e.pathSegments[0]??``;return t?`nextclaw://panel-app/${encodeURIComponent(t)}`:`nextclaw://panel-app`}var Q=[{defaultUrl:()=>oo,id:`home`,kind:ao,match:e=>e.raw===oo,resolve:()=>({historyPolicy:`managed`,kind:ao,title:n(`docBrowserHomeTitle`),url:oo}),areEquivalent:(e,t)=>e===t},{defaultUrl:k,id:`docs-url`,kind:`docs`,match:e=>Qe(e.raw),resolve:e=>{let t=Ye(e.raw,`docs`);return{historyPolicy:`managed`,kind:`docs`,title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>A(e)===A(t)},{defaultUrl:k,id:`nextclaw-docs`,kind:`docs`,match:e=>e.scheme===`nextclaw`&&e.authority===`docs`,resolve:e=>{let t=vo(e);return{historyPolicy:`managed`,kind:`docs`,title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>A(e)===A(t)},{defaultUrl:()=>Z,id:`apps`,kind:so,match:e=>_o(e.raw,Z),resolve:e=>{let t=ho(e.raw);return{dedupeKey:`apps`,historyPolicy:`managed`,kind:so,title:n(t===`nextclaw://apps`?`appsTitle`:`serviceAppsTitle`),url:t}},areEquivalent:(e,t)=>ho(e)===ho(t)},{defaultUrl:()=>`nextclaw://panel-app`,id:`panel-app`,kind:lo,match:e=>e.scheme===`nextclaw`&&e.authority===`panel-app`,resolve:e=>{let t=yo(e),r=e.pathSegments[0]??``;return{dedupeKey:r?`panel-app:${decodeURIComponent(r)}`:void 0,historyPolicy:`managed`,kind:lo,title:n(`panelAppsTitle`),url:t}},areEquivalent:(e,t)=>e===t},{defaultUrl:()=>`about:blank`,id:`content`,kind:`content`,match:()=>!0,resolve:e=>({historyPolicy:`managed`,kind:`content`,title:tt(e.raw,`content`,`Detail`),url:e.raw||`about:blank`}),areEquivalent:(e,t)=>e===t}],bo=Q.map(e=>({areEquivalent:e.areEquivalent,id:e.id,match:e.match,resolve:e.resolve}));function xo(){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:k()}},{id:`skill-marketplace`,label:n(`marketplaceSkillsPageTitle`),target:{path:`/marketplace/skills`,type:`app-route`}}]}var So={apps:{accentClassName:`bg-emerald-50 text-emerald-700`,hoverAccentClassName:`group-hover:bg-emerald-100`,icon:(0,W.jsx)(Ie,{className:`h-5 w-5`})},"service-apps":{accentClassName:`bg-sky-50 text-sky-700`,hoverAccentClassName:`group-hover:bg-sky-100`,icon:(0,W.jsx)(ti,{className:`h-5 w-5`})},docs:{accentClassName:`bg-amber-50 text-amber-700`,hoverAccentClassName:`group-hover:bg-amber-100`,icon:(0,W.jsx)(Fe,{className:`h-5 w-5`})},"skill-marketplace":{accentClassName:`bg-rose-50 text-rose-700`,hoverAccentClassName:`group-hover:bg-rose-100`,icon:(0,W.jsx)(Qr,{className:`h-5 w-5`})}};function Co(e){return So[e.id]??{accentClassName:`bg-gray-50 text-gray-700`,hoverAccentClassName:`group-hover:bg-gray-100`,icon:(0,W.jsx)(Ie,{className:`h-5 w-5`})}}function wo({open:t}){let n=hn(),r=xo(),i=e=>{if(e.type===`app-route`){n(e.path);return}t(e.uri,e.options)};return(0,W.jsx)(`div`,{className:`h-full overflow-auto bg-background px-4 py-5`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-[520px]`,children:(0,W.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(76px,1fr))] gap-x-2 gap-y-4`,children:r.map(t=>{let n=Co(t);return(0,W.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,W.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,W.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 To(e){return e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0)}function Eo(e){let t=e.trim();try{let e=new URL(t);return{authority:e.hostname,pathSegments:To(e.pathname),pathname:e.pathname,raw:t,scheme:e.protocol.replace(/:$/,``).toLowerCase(),searchParams:e.searchParams}}catch{return{authority:``,pathSegments:To(t),pathname:t,raw:t,scheme:``,searchParams:new URLSearchParams}}}var Do=class{constructor(e,t){this.routeDefinitions=e,this.options=t,this.resolve=e=>{let t=Eo(e);return this.findDefinition(t).resolve(t)},this.normalize=e=>this.options.getNormalizedUri(this.resolve(e)),this.areEquivalent=(e,t)=>this.findDefinition(Eo(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}}};function Oo(e){return e&&Qe(e)?`docs`:`content`}var ko=class{constructor(){this.resourceUriResolver=new Do(bo,{getNormalizedUri:e=>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(Eo(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(Eo(e.currentUrl)).historyPolicy===`managed`,this.resolveRouteDefinition=(e,t,n)=>{let r=t??(e?void 0:n?.kind),i=r?Q.find(e=>e.kind===r):void 0;if(i)return i;let a=e?Eo(e):null,o=a?Q.find(e=>e.match(a)):void 0;if(o)return o;let s=t??n?.kind??Oo(e);return Q.find(e=>e.kind===s)??Q[Q.length-1]}}},Ao=so,jo=lo,Mo=`panel-apps`,No=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function Po(e){return e===`panel-apps`||e===`service-apps`}function Fo(e=Mo){return e===Mo?Z:co}function Io(e){try{let t=new URL(e).searchParams.get(`tab`);return Po(t)?t:Mo}catch{return Mo}}function Lo(e){e.open(Fo(),{kind:Ao,title:n(`appsTitle`),dedupeKey:`apps`})}var Ro={[ao]:{getTitle:()=>n(`docBrowserHomeTitle`),renderContent:({open:e})=>(0,W.jsx)(wo,{open:e})},[Ao]:{getTitle:()=>n(`appsTitle`),renderIcon:()=>(0,W.jsx)(Ie,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t,openTarget:r})=>(0,W.jsx)(ro,{activeTab:Io(e),onActiveTabChange:e=>t(Fo(e),{activate:!1,kind:Ao,title:n(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>r(go(e))})},[jo]:{getIframeSandbox:()=>No,getTitle:e=>e.title||n(`panelAppsTitle`),onIframeMessage:e=>bs().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,W.jsx)(Zr,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,W.jsx)(io,{onOpenApps:()=>Lo({open:e}),onRefresh:t})}},zo=[{builtIn:!0,icon:{type:`builtin`,name:`apps`},id:`apps`,labelKey:`appsTitle`,removable:!1,target:{type:`right-panel-resource`,uri:Z}},{builtIn:!0,icon:{type:`builtin`,name:`service-apps`},id:`service-apps`,labelKey:`serviceAppsTitle`,removable:!1,target:{type:`right-panel-resource`,uri:co}},{builtIn:!0,icon:{type:`builtin`,name:`docs`},id:`docs`,labelKey:`docBrowserHelp`,removable:!1,target:{type:`right-panel-resource`,uri:`nextclaw://docs`}},{builtIn:!0,icon:{type:`builtin`,name:`new-tab`},id:`new-tab`,labelKey:`docBrowserHomeTitle`,removable:!1,target:{type:`right-panel-resource`,uri:oo}}],Bo=[`apps`,`docs`,`new-tab`,`service-apps`];function Vo(e){return!!e&&typeof e==`object`}function Ho(e){return Bo.includes(e)}function Uo(e){return!Vo(e)||typeof e.type!=`string`?null:e.type===`builtin`&&Ho(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()}:null}function Wo(e){if(!Vo(e)||typeof e.id!=`string`||e.id.trim().length===0||typeof e.labelKey!=`string`||e.labelKey.trim().length===0||typeof e.createdAt!=`string`||e.createdAt.trim().length===0||!Vo(e.target)||e.target.type!==`right-panel-resource`||typeof e.target.uri!=`string`||e.target.uri.trim().length===0)return null;let t=Uo(e.icon);return t?{createdAt:e.createdAt,icon:t,id:e.id.trim(),labelKey:e.labelKey.trim(),target:{type:`right-panel-resource`,uri:e.target.uri.trim()}}:null}function Go(e){if(!Array.isArray(e))return[];let t=new Map;return e.forEach(e=>{let n=Wo(e);n&&t.set(n.id,n)}),Array.from(t.values())}function Ko(e,t){return{createdAt:t,icon:e.icon,id:e.id,labelKey:e.labelKey,target:e.target}}function qo(e){return{builtIn:!1,icon:e.icon,id:e.id,labelKey:e.labelKey,removable:!0,target:e.target}}function Jo(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(qo);return[...e,...i]}var Yo=`nextclaw.side-dock.state`,Xo=1;function Zo(e){return!!e&&typeof e==`object`}var Qo=s()(Je(e=>({pinnedItems:[],setPinnedItems:t=>e({pinnedItems:Go(t)})}),{name:Yo,version:Xo,storage:rt(()=>window.localStorage),partialize:e=>({pinnedItems:e.pinnedItems}),merge:(e,t)=>{let n=Zo(e)?Go(e.pinnedItems):[];return{...t,pinnedItems:n}}})),$o={apps:Ie,docs:Fe,"new-tab":Re,"service-apps":Zr};function es({icon:e}){if(e.type===`url`)return(0,W.jsx)(`img`,{src:e.url,alt:``,className:`h-5 w-5 rounded object-cover`});let t=$o[e.name];return(0,W.jsx)(t,{className:`h-5 w-5`,"aria-hidden":`true`})}function ts({active:t,item:r,onOpen:i}){let a=n(r.labelKey);return(0,W.jsxs)(Na,{children:[(0,W.jsx)(Pa,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":a,title:a,"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,W.jsx)(es,{icon:r.icon})})}),(0,W.jsx)(Fa,{side:`left`,children:a})]})}function ns(e,t,n){return!t||!n?!1:n.currentUrl===e.target.uri?!0:e.id===`docs`&&n.kind===`docs`}function rs({manager:e}){let t=Qo(e=>e.pinnedItems),{currentTab:n,isOpen:r}=$e(),i=Jo(zo,t);return(0,W.jsx)(Ma,{delayDuration:250,children:(0,W.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,W.jsx)(ts,{active:ns(t,r,n),item:t,onOpen:e.openItem},t.id))})})}var is=class{constructor(e){this.docBrowserManager=e,this.getItems=()=>Jo(zo,Qo.getState().pinnedItems),this.openItem=e=>{e.target.type===`right-panel-resource`&&this.docBrowserManager.open(e.target.uri)},this.pinItem=(e,t=new Date().toISOString())=>{e.removable&&this.setPinnedItems(n=>n.some(t=>t.id===e.id||t.target.uri===e.target.uri)?n:[...n,Ko(e,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}=Qo.getState();n(e(t))}}},as=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`?k():`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 os(e,t,n){return{...e,tabs:e.tabs.map(e=>e.id===t?n(e):e)}}function ss(e,t){return os(e,e.activeTabId,t)}function cs(e,t){let n=[...e.history.slice(0,e.historyIndex+1),t];return{history:n,historyIndex:n.length-1}}function ls(e,t,n){return t.tabId===n.tabId&&t.kind===n.kind&&e.areUrlsEquivalent(t.url,n.url,t.kind,n.kind)}function $(e,t,n){let r=t.activeHistory[t.activeHistoryIndex];if(r&&ls(e,r,n))return t;let i=[...t.activeHistory.slice(0,t.activeHistoryIndex+1),n];return{...t,activeHistory:i,activeHistoryIndex:i.length-1}}function us(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 ds(e,t,n){let r=t.tabs.find(e=>e.id===n.tabId);if(!r)return t;let i=e.resolveOpenTarget({activeTab:r,kind:n.kind,url:n.url}),a=us(e,r,i.url);return os({...t,activeTabId:r.id,isOpen:!0},r.id,e=>({...e,currentUrl:i.url,dedupeKey:i.dedupeKey,historyIndex:a>=0?a:e.historyIndex,kind:i.kind,title:i.title}))}function fs(e,t,n,r,i){let a={...t,title:r?.title||n.title||t.title,kind:n.kind,dedupeKey:i};return e.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?a:{...a,currentUrl:n.url,...cs(t,n.url),navVersion:t.navVersion+1}}function ps(e,t){return!e.isOpen&&e.tabs.length===1&&t?.kind===`home`&&t.currentUrl===`nextclaw://new-tab`}function ms(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=os(t,u.id,t=>fs(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,{kind:n.kind,tabId:u.id,url:n.url}):l}if(o||c||!l||l.kind!==n.kind){let r=et(n.url,n.kind,s??n.title,c);return ps(t,l)?{...t,isOpen:!0,tabs:[r],activeTabId:r.id,activeHistory:[O(r)],activeHistoryIndex:0}:$(e,{...t,isOpen:!0,tabs:[...t.tabs,r],activeTabId:r.id},O(r))}return $(e,{...ss(t,t=>fs(e,t,n,r,c)),isOpen:!0},{kind:n.kind,tabId:t.activeTabId,url:n.url})}function hs(e,t,n,r){let i=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0];return ms(e,t,e.resolveOpenTarget({activeTab:i,kind:r?.kind,url:n}),r)}var gs=class{constructor(e=as){this.routeResolver=e,this.setSnapshot=e=>{nt.getState().setSnapshot(e)},this.open=(e,t)=>{this.setSnapshot(n=>hs(this.routeResolver,n,e,t))},this.openTarget=(e,t)=>{this.setSnapshot(n=>ms(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(k(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}let n=ss(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,...cs(t,n.url),kind:n.kind,navVersion:t.navVersion+1,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,O(r)):n})},this.syncUrl=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=et(k(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}let n=ss(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,...cs(t,n.url),kind:n.kind,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,O(r)):n})},this.goBack=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex<=0)return e;let t=e.activeHistoryIndex-1,n=e.activeHistory[t];return n?ds(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?ds(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:[O(c)],activeHistoryIndex:Math.min(Math.max(0,s.length-1),Math.max(0,o.length-1))};return t.activeTabId===e?$(this.routeResolver,l,O(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},O(n)):t})}}},_s=class{constructor(){this.accountManager=new Ai,this.rightPanelResourceRouteResolver=new ko,this.docBrowserManager=new gs(this.rightPanelResourceRouteResolver),this.sideDockManager=new is(this.docBrowserManager),this.serviceActionAuthorizationManager=new Ha,this.panelAppBridgeManager=new La(this.serviceActionAuthorizationManager),this.remoteAccessManager=new yi({accountManager:this.accountManager})}},vs=null;function ys(){return vs??=new _s,vs}function bs(){return ys()}var xs=(0,j.createContext)(null);function Ss({children:e}){let t=(0,j.useMemo)(()=>ys(),[]);return(0,W.jsx)(xs.Provider,{value:t,children:e})}function Cs(){let e=(0,j.useContext)(xs);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}export{ui as A,Hn as B,pi as C,vi as D,gi as E,Ar as F,ct as G,H,Nr as I,Bn as L,ii as M,ei as N,fi as O,Qr as P,Pr as R,J as S,q as T,hn as U,Wn as V,_n as W,ki as _,Ro as a,Ci as b,Na as c,Pa as d,ja as f,ka as g,Oa as h,rs as i,si as j,di as k,Fa as l,Da as m,Cs as n,Lo as o,Aa as p,bs as r,Ba as s,Ss as t,Ma as u,Oi as v,K as w,yi as x,wi as y,Vn as z};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-Br1EFMEr.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`}]]),n=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`}]]);export{t as n,n as t};
1
+ import{t as e}from"./createLucideIcon-Br1EFMEr.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};
@@ -0,0 +1,8 @@
1
+ import{d as e,g as t,h as n,i as r,m as i,n as a,o,v as s}from"./react-B2X_ph0a.js";import{At as c,Ct as l,Lt as u,Mt as d,Nt as f,Rt as p,Xt as m,et as h,ft as g,jt as _,kt as v,nt as y,ot as b,tt as x,zt as S}from"./api-DruAcori.js";import{t as C}from"./createLucideIcon-Br1EFMEr.js";import{t as w}from"./search-CdhgFNwf.js";import{t as T}from"./book-open-CRotBOF2.js";import{t as E}from"./external-link-DHjFdCpy.js";import{t as D}from"./key-round-D41Oe35x.js";import{t as O}from"./x-D1v_vb54.js";import{t as ee}from"./status-dot-BSMG7ZaC.js";import{i as te,n as ne,r as re,t as ie}from"./tabs-D1CjpWNX.js";import{$ as ae,Dt as oe,Ft as se,J as k,K as ce,Q as A,Tt as le,U as j,W as M,X as N,Y as P,Z as ue,it as de,jt as fe,kt as pe,pt as me,q as F,xt as he}from"./index-DcFpvnge.js";import{t as ge}from"./tabs-custom-CRSN1ekg.js";import{t as _e}from"./tag-chip-DEashiw6.js";import{t as I}from"./config-hints-A7G_jMTU.js";import{a as L,c as R,i as ve,n as ye,o as z,r as be,s as xe,t as Se}from"./config-split-page-BnTO1mAM.js";var Ce=C(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),we=C(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),B=C(`MessageCircleMore`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),V=C(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),Te=C(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),H=s(n(),1),U=i();function Ee({value:t,onChange:n,className:i,placeholder:a=``}){let[o,s]=(0,H.useState)(``),c=e=>{e.key===`Enter`&&o.trim()?(e.preventDefault(),n([...t,o.trim()]),s(``)):e.key===`Backspace`&&!o&&t.length>0&&n(t.slice(0,-1))},l=e=>{n(t.filter((t,n)=>n!==e))};return(0,U.jsxs)(`div`,{className:e(`flex min-h-[42px] flex-wrap gap-2 rounded-xl border border-gray-200/80 bg-white p-2`,i),children:[t.map((e,t)=>(0,U.jsxs)(_e,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,U.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,U.jsx)(O,{className:`h-3 w-3`})})]},t)),(0,U.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:c,className:`flex-1 outline-none min-w-[100px] bg-transparent text-sm`,placeholder:a||r(`enterTag`)})]})}function De(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,U.jsx)(D,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,U.jsx)(fe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,U.jsx)(we,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,U.jsx)(Ce,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,U.jsx)(Te,{className:`h-3.5 w-3.5 text-gray-500`}):(0,U.jsx)(le,{className:`h-3.5 w-3.5 text-gray-500`})}function Oe({channelName:e,fields:t,formData:n,jsonDrafts:i,setJsonDrafts:a,updateField:o,uiHints:s}){return(0,U.jsx)(U.Fragment,{children:t.map(t=>{let c=I(`channels.${e}.${t.name}`,s),l=c?.label??t.label,u=c?.placeholder;return(0,U.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,U.jsxs)(_,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[De(t.name),l]}),t.type===`boolean`&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,U.jsx)(`span`,{className:`text-sm text-gray-500`,children:n[t.name]?r(`enabled`):r(`disabled`)}),(0,U.jsx)(g,{id:t.name,checked:n[t.name]||!1,onCheckedChange:e=>o(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,U.jsx)(d,{id:t.name,type:t.type,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:u,className:`rounded-xl`}),t.type===`password`&&(0,U.jsx)(d,{id:t.name,type:`password`,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:u??r(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,U.jsx)(d,{id:t.name,type:`number`,value:n[t.name]||0,onChange:e=>o(t.name,parseInt(e.target.value,10)||0),placeholder:u,className:`rounded-xl`}),t.type===`tags`&&(0,U.jsx)(Ee,{value:n[t.name]||[],onChange:e=>o(t.name,e)}),t.type===`select`&&(0,U.jsxs)(ce,{value:n[t.name]||``,onValueChange:e=>o(t.name,e),children:[(0,U.jsx)(P,{className:`rounded-xl`,children:(0,U.jsx)(N,{})}),(0,U.jsx)(F,{children:(t.options??[]).map(e=>(0,U.jsx)(k,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,U.jsx)(`textarea`,{id:t.name,value:i[t.name]??`{}`,onChange:e=>a(n=>({...n,[t.name]:e.target.value})),className:`min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`})]},t.name)})})}var ke=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),W=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),G=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Ae=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),je=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Me=t((e=>{var t=W().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Ne=t((e=>{var t=W().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Pe=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),K=t((e=>{var t=G(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Fe=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ie=t((e=>{var t=Fe();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Le=t(((e,t)=>{var n=Ie();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),q=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Re=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
+ ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),J=t((e=>{var t=q(),n=Re();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),ze=t((e=>{var t=W(),n=K(),r=G(),i=J(),a=q(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Be=t((e=>{var t=W(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Ve=t(((e,t)=>{var n=J();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),He=t(((e,t)=>{var n=J(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Ue=t(((e,t)=>{var n=J();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),We=t(((e,t)=>{var n=J(),r=W();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Ge=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Ke=t((e=>{var t=J(),n=Ve(),r=He(),i=Ue(),a=We(),o=Re(),s=W(),c=Ge();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
+ Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),qe=t((e=>{var t=W(),n=G(),r=Ae(),i=je(),a=Me(),o=Ne(),s=Pe(),c=K(),l=Le(),u=ze(),d=Be(),f=J(),p=Ke();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+c+`.
7
+ `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Je=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[a[t*i+r]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Ye=t((e=>{var t=Je();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Xe=t((e=>{var t=Je();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
+ `;return typeof a==`function`&&a(null,p),p}})),Ze=t((e=>{var t=ke(),n=qe(),r=Ye(),i=Xe();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))();function Qe(){return p({mutationFn:({channel:e,data:t})=>y(e,t)})}function $e(){return p({mutationFn:({channel:e,data:t})=>x(e,t)})}function et(){return p({mutationFn:({channel:e,data:t})=>h(e,t)})}var tt={weixin:{title:`weixinAuthTitle`,description:`weixinAuthDescription`,hint:`weixinAuthHint`,capabilityHint:`weixinAuthCapabilityHint`,disabledHint:`weixinAuthDisabledHint`,connect:`weixinAuthConnect`,qrAlt:`weixinAuthQrAlt`,scanPrompt:`weixinAuthScanPrompt`,readyTitle:`weixinAuthReadyTitle`,readyDescription:`weixinAuthReadyDescription`,advancedTitle:`weixinAuthAdvancedTitle`,advancedDescription:`weixinAuthAdvancedDescription`},feishu:{title:`feishuAuthTitle`,description:`feishuAuthDescription`,hint:`feishuAuthHint`,capabilityHint:`feishuAuthCapabilityHint`,disabledHint:`feishuAuthDisabledHint`,connect:`feishuAuthConnect`,qrAlt:`feishuAuthQrAlt`,scanPrompt:`feishuAuthScanPrompt`,readyTitle:`feishuAuthReadyTitle`,readyDescription:`feishuAuthReadyDescription`,advancedTitle:`feishuAuthAdvancedTitle`,advancedDescription:`feishuAuthAdvancedDescription`,domainLabel:`feishuAuthDomain`}};function nt(e){let{accounts:t}=e,n=new Set;if(typeof e.defaultAccountId==`string`&&e.defaultAccountId.trim()&&n.add(e.defaultAccountId.trim()),t&&typeof t==`object`&&!Array.isArray(t))for(let e of Object.keys(t)){let t=e.trim();t&&n.add(t)}return[...n]}function rt(e,t){if(typeof e.baseUrl==`string`&&e.baseUrl.trim())return e.baseUrl.trim();if(typeof t.baseUrl==`string`&&t.baseUrl.trim())return t.baseUrl.trim()}function it(e,t){return(typeof e.domain==`string`?e.domain.trim():``)||(typeof t.domain==`string`?t.domain.trim():``)||void 0}function at(e,t){return it(e,t)===`lark`?`lark`:`feishu`}function ot(e){return e===`lark`?`https://open.larksuite.com/app`:`https://open.feishu.cn/app`}function st(e,t){return S({queryKey:[`channel-qr`,e,t],enabled:!!t,queryFn:()=>(0,Ze.toDataURL)(t,{errorCorrectionLevel:`M`,margin:1,width:480})}).data??null}function ct({activeSession:t,baseUrl:n,channelEnabled:i,copy:a,connectButtonLabel:o,connectedAccountIds:s,disabled:c,domain:l,handleStartAuth:u,hasConnectedAccount:d,primaryAccountId:p,statusLabel:m}){return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full bg-white/90 px-3 py-1 text-xs font-medium text-primary shadow-sm`,children:[(0,U.jsx)(V,{className:`h-3.5 w-3.5`}),r(a.title)]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h4`,{className:`text-base font-semibold text-gray-900`,children:r(a.description)}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-gray-600`,children:r(a.hint)})]}),(0,U.jsxs)(`div`,{className:e(`inline-flex w-fit items-center gap-2 rounded-full px-3 py-1 text-xs font-medium`,t?`bg-amber-50 text-amber-700`:d?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-600`),children:[t?(0,U.jsx)(pe,{className:`h-3.5 w-3.5 animate-spin`}):(0,U.jsx)(B,{className:`h-3.5 w-3.5`}),m]}),(0,U.jsxs)(`div`,{className:`space-y-1 text-sm text-gray-600`,children:[(0,U.jsx)(`p`,{children:r(i||!d?a.capabilityHint:a.disabledHint)}),p?(0,U.jsxs)(`p`,{children:[r(`weixinAuthPrimaryAccount`),`: `,(0,U.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:p})]}):null,s.length>1?(0,U.jsxs)(`p`,{children:[r(`weixinAuthConnectedAccounts`),`: `,(0,U.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:s.join(`, `)})]}):null,n?(0,U.jsxs)(`p`,{children:[r(`weixinAuthBaseUrl`),`: `,(0,U.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:n})]}):null,l&&a.domainLabel?(0,U.jsxs)(`p`,{children:[r(a.domainLabel),`: `,(0,U.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:l})]}):null]}),(0,U.jsx)(f,{type:`button`,onClick:()=>void u(),disabled:c,className:`rounded-xl`,children:o})]})}function lt({activeSession:e,authMessage:t,copy:n,qrDataUrl:i}){return(0,U.jsx)(`div`,{className:`w-full max-w-sm rounded-2xl border border-dashed border-primary/25 bg-white/85 p-4 shadow-sm`,children:e?(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-100 bg-white p-3`,children:i?(0,U.jsx)(`img`,{src:i,alt:r(n.qrAlt),className:`mx-auto aspect-square w-full max-w-[240px] object-contain`}):(0,U.jsx)(`div`,{className:`flex aspect-square w-full items-center justify-center rounded-xl bg-gray-50 text-gray-500`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[(0,U.jsx)(pe,{className:`h-5 w-5 animate-spin`}),(0,U.jsx)(`p`,{className:`text-xs`,children:r(`weixinAuthStarting`)})]})})}),(0,U.jsxs)(`div`,{className:`space-y-1 text-xs text-gray-500`,children:[(0,U.jsx)(`p`,{children:t||e.note||r(n.scanPrompt)}),(0,U.jsxs)(`p`,{children:[r(`weixinAuthExpiresAt`),`: `,a(e.expiresAt)]})]}),(0,U.jsxs)(`a`,{href:e.qrCodeUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,U.jsx)(E,{className:`h-3.5 w-3.5`}),r(`weixinAuthOpenQr`)]})]}):(0,U.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center rounded-2xl bg-gray-50/80 px-6 text-center`,children:[(0,U.jsx)(V,{className:`h-9 w-9 text-gray-300`}),(0,U.jsx)(`p`,{className:`mt-3 text-sm font-medium text-gray-700`,children:r(n.readyTitle)}),(0,U.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500`,children:r(n.readyDescription)})]})})}function ut({channelConfig:e,channelEnabled:t,channelName:n,disabled:i,formData:a}){let o=m(),s=Qe(),c=$e(),[l,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(null),[h,g]=(0,H.useState)(!1),_=(0,H.useMemo)(()=>nt(e),[e]),v=_[0],y=rt(a,e),b=n===`feishu`?it(a,e):void 0,x=_.length>0,S=x&&!h?null:l,C=st(n,S?.qrCodeUrl),w=tt[n];(0,H.useEffect)(()=>{if(!S)return;let e=!1,t=null,i=async()=>{try{let a=await c.mutateAsync({channel:n,data:{sessionId:S.sessionId}});if(e)return;if(p(a),a.status===`authorized`){await o.invalidateQueries({queryKey:[`config`]}),await o.invalidateQueries({queryKey:[`config-meta`]}),u.success(a.message||r(`weixinAuthAuthorized`)),d(null);return}if(a.status===`expired`||a.status===`error`){u.error(a.message||r(`weixinAuthRetryRequired`)),d(null);return}t=setTimeout(i,a.nextPollMs??S.intervalMs)}catch(t){e||(u.error(`${r(`error`)}: ${t instanceof Error?t.message:String(t)}`),d(null))}};return t=setTimeout(i,S.intervalMs),()=>{e=!0,t&&clearTimeout(t)}},[n,S,c,o]);let T=async()=>{try{let e=await s.mutateAsync({channel:n,data:{baseUrl:y,domain:b,accountId:typeof a.defaultAccountId==`string`&&a.defaultAccountId.trim()?a.defaultAccountId.trim():void 0}});g(x),d(e),p({channel:n,status:`pending`,message:e.note,nextPollMs:e.intervalMs})}catch(e){u.error(`${r(`error`)}: ${e instanceof Error?e.message:String(e)}`)}},E=S?f?.status===`scanned`?r(`weixinAuthScanned`):r(`weixinAuthWaiting`):r(x?t?`weixinAuthAuthorized`:`weixinAuthConnectedDisabled`:`weixinAuthNotConnected`),D=s.isPending?r(`weixinAuthStarting`):r(S?`weixinAuthWaiting`:x?`weixinAuthReconnect`:w.connect),O=x?r(`weixinAuthAuthorized`):f?.message;return(0,U.jsx)(`section`,{className:`rounded-2xl border border-primary/20 bg-gradient-to-br from-primary-50/70 via-white to-emerald-50/60 p-5`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,U.jsx)(ct,{activeSession:S,baseUrl:y,channelEnabled:t,copy:w,connectButtonLabel:D,connectedAccountIds:_,disabled:i||s.isPending||!!S,domain:b,handleStartAuth:T,hasConnectedAccount:x,primaryAccountId:v,statusLabel:E}),(0,U.jsx)(lt,{activeSession:S,authMessage:O,copy:w,qrDataUrl:C})]})})}function dt({channelConfig:e,disabled:t,formData:n}){let i=m(),a=et(),[o,s]=(0,H.useState)(()=>at(n,e)),[c,l]=(0,H.useState)(``),[p,h]=(0,H.useState)(``),g=ot(o),v=!!(c.trim()&&p.trim())&&!t&&!a.isPending,y=async()=>{try{let e=await a.mutateAsync({channel:`feishu`,data:{domain:o,fields:{appId:c.trim(),appSecret:p.trim()}}});await i.invalidateQueries({queryKey:[`config`]}),await i.invalidateQueries({queryKey:[`config-meta`]}),u.success(e.message||r(`feishuExistingAgentConnectSuccess`)),h(``)}catch(e){u.error(`${r(`error`)}: ${e instanceof Error?e.message:String(e)}`)}};return(0,U.jsx)(`section`,{className:`rounded-2xl border border-primary/20 bg-white p-5`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,U.jsxs)(`div`,{className:`max-w-xl space-y-3`,children:[(0,U.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full bg-gray-100 px-3 py-1 text-xs font-medium text-gray-700`,children:[(0,U.jsx)(B,{className:`h-3.5 w-3.5`}),r(`feishuExistingAgentTitle`)]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h4`,{className:`text-base font-semibold text-gray-900`,children:r(`feishuExistingAgentDescription`)}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-gray-600`,children:r(`feishuExistingAgentHint`)})]}),(0,U.jsxs)(`a`,{href:g,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-primary transition-colors hover:text-primary-hover`,children:[(0,U.jsx)(E,{className:`h-4 w-4`}),r(o===`lark`?`feishuExistingAgentOpenLarkList`:`feishuExistingAgentOpenFeishuList`)]})]}),(0,U.jsxs)(`div`,{className:`w-full max-w-sm space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(_,{htmlFor:`feishu-existing-platform`,children:r(`feishuPlatform`)}),(0,U.jsxs)(ce,{value:o,onValueChange:e=>s(e===`lark`?`lark`:`feishu`),children:[(0,U.jsx)(P,{id:`feishu-existing-platform`,className:`rounded-xl`,children:(0,U.jsx)(N,{})}),(0,U.jsxs)(F,{children:[(0,U.jsx)(k,{value:`feishu`,children:`Feishu`}),(0,U.jsx)(k,{value:`lark`,children:`Lark`})]})]})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(_,{htmlFor:`feishu-existing-app-id`,children:`App ID`}),(0,U.jsx)(d,{id:`feishu-existing-app-id`,value:c,onChange:e=>l(e.target.value),className:`rounded-xl`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(_,{htmlFor:`feishu-existing-app-secret`,children:`App Secret`}),(0,U.jsx)(d,{id:`feishu-existing-app-secret`,type:`password`,value:p,onChange:e=>h(e.target.value),className:`rounded-xl`})]}),(0,U.jsx)(f,{type:`button`,onClick:()=>void y(),disabled:!v,className:`w-full rounded-xl`,children:a.isPending?r(`feishuExistingAgentConnecting`):r(`feishuExistingAgentConnect`)})]})]})})}function ft(e){let[t,n]=(0,H.useState)(`create`);return(0,U.jsxs)(ie,{value:t,onValueChange:e=>n(e===`existing`?`existing`:`create`),children:[(0,U.jsxs)(re,{children:[(0,U.jsx)(te,{value:`create`,children:r(`feishuAuthCreateNew`)}),(0,U.jsx)(te,{value:`existing`,children:r(`feishuAuthConnectExisting`)})]}),(0,U.jsx)(ne,{value:`create`,className:`mt-4`,children:(0,U.jsx)(ut,{...e,channelName:`feishu`})}),(0,U.jsx)(ne,{value:`existing`,className:`mt-4`,children:(0,U.jsx)(dt,{...e})})]})}var pt=[{value:`pairing`,label:`pairing`},{value:`allowlist`,label:`allowlist`},{value:`open`,label:`open`},{value:`disabled`,label:`disabled`}],Y=[{value:`open`,label:`open`},{value:`allowlist`,label:`allowlist`},{value:`disabled`,label:`disabled`}],mt=[{value:`feishu`,label:`feishu`},{value:`lark`,label:`lark`}],ht=[{value:`off`,label:`off`},{value:`partial`,label:`partial`},{value:`block`,label:`block`},{value:`progress`,label:`progress`}];function gt(){return{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`),section:`primary`},{name:`defaultAccountId`,type:`text`,label:r(`defaultAccountId`)},{name:`domain`,type:`select`,label:r(`feishuAuthDomain`),options:mt},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)},{name:`groupPolicy`,type:`select`,label:r(`groupPolicy`),options:Y},{name:`requireMention`,type:`boolean`,label:r(`requireMention`)},{name:`accounts`,type:`json`,label:r(`accountsJson`)}],layout:[{type:`fields`,section:`primary`},{type:`custom`,sectionId:`feishu-auth`},{type:`fields`,section:`advanced`,collapsible:{title:r(`feishuAuthAdvancedTitle`),description:r(`feishuAuthAdvancedDescription`)}}]}}function _t(){return{telegram:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`token`,type:`password`,label:r(`botToken`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)},{name:`proxy`,type:`text`,label:r(`proxy`)},{name:`accountId`,type:`text`,label:r(`accountId`)},{name:`dmPolicy`,type:`select`,label:r(`dmPolicy`),options:pt},{name:`groupPolicy`,type:`select`,label:r(`groupPolicy`),options:Y},{name:`groupAllowFrom`,type:`tags`,label:r(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:r(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:r(`mentionPatterns`)},{name:`groups`,type:`json`,label:r(`groupRulesJson`)}]},discord:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`token`,type:`password`,label:r(`botToken`)},{name:`allowBots`,type:`boolean`,label:r(`allowBotMessages`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)},{name:`gatewayUrl`,type:`text`,label:r(`gatewayUrl`)},{name:`intents`,type:`number`,label:r(`intents`)},{name:`proxy`,type:`text`,label:r(`proxy`)},{name:`mediaMaxMb`,type:`number`,label:r(`attachmentMaxSizeMb`)},{name:`streaming`,type:`select`,label:r(`streamingMode`),options:ht},{name:`draftChunk`,type:`json`,label:r(`draftChunkingJson`)},{name:`textChunkLimit`,type:`number`,label:r(`textChunkLimit`)},{name:`accountId`,type:`text`,label:r(`accountId`)},{name:`dmPolicy`,type:`select`,label:r(`dmPolicy`),options:pt},{name:`groupPolicy`,type:`select`,label:r(`groupPolicy`),options:Y},{name:`groupAllowFrom`,type:`tags`,label:r(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:r(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:r(`mentionPatterns`)},{name:`groups`,type:`json`,label:r(`groupRulesJson`)}]},whatsapp:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`bridgeUrl`,type:`text`,label:r(`bridgeUrl`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)}]},feishu:gt(),dingtalk:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`clientId`,type:`text`,label:r(`clientId`)},{name:`clientSecret`,type:`password`,label:r(`clientSecret`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)}]},wecom:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`corpId`,type:`text`,label:r(`corpId`)},{name:`agentId`,type:`text`,label:r(`agentId`)},{name:`secret`,type:`password`,label:r(`secret`)},{name:`token`,type:`password`,label:r(`token`)},{name:`callbackPort`,type:`number`,label:r(`callbackPort`)},{name:`callbackPath`,type:`text`,label:r(`callbackPath`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)}]},weixin:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`),section:`primary`},{name:`defaultAccountId`,type:`text`,label:r(`defaultAccountId`)},{name:`baseUrl`,type:`text`,label:r(`baseUrl`)},{name:`pollTimeoutMs`,type:`number`,label:r(`pollTimeoutMs`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)},{name:`accounts`,type:`json`,label:r(`accountsJson`)}],layout:[{type:`fields`,section:`primary`},{type:`custom`,sectionId:`weixin-auth`},{type:`fields`,section:`advanced`,collapsible:{title:r(`weixinAuthAdvancedTitle`),description:r(`weixinAuthAdvancedDescription`)}}]},slack:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`mode`,type:`text`,label:r(`mode`)},{name:`webhookPath`,type:`text`,label:r(`webhookPath`)},{name:`allowBots`,type:`boolean`,label:r(`allowBotMessages`)},{name:`botToken`,type:`password`,label:r(`botToken`)},{name:`appToken`,type:`password`,label:r(`appToken`)}]},email:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`consentGranted`,type:`boolean`,label:r(`consentGranted`)},{name:`imapHost`,type:`text`,label:r(`imapHost`)},{name:`imapPort`,type:`number`,label:r(`imapPort`)},{name:`imapUsername`,type:`text`,label:r(`imapUsername`)},{name:`imapPassword`,type:`password`,label:r(`imapPassword`)},{name:`fromAddress`,type:`email`,label:r(`fromAddress`)}]},qq:{fields:[{name:`enabled`,type:`boolean`,label:r(`enabled`)},{name:`appId`,type:`text`,label:r(`appId`)},{name:`secret`,type:`password`,label:r(`appSecret`)},{name:`markdownSupport`,type:`boolean`,label:r(`markdownSupport`)},{name:`allowFrom`,type:`tags`,label:r(`allowFrom`)}]}}}function vt(e){let t=o();return e.tutorialUrls?.[t]||e.tutorialUrls?.default||e.tutorialUrl}var yt=[],bt=[{type:`fields`,section:`all`}],X=new Set,Z=new Map,Q=null;function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xt(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]=$(n[e])&&$(r)?xt(n[e],r):r;return n}function St(e,t){let n={},r=n,i=e.split(`.`);for(let e=0;e<i.length-1;e+=1)r[i[e]]={},r=r[i[e]];return r[i[i.length-1]]=t,n}function Ct(e,t){return t===`all`?e:e.filter(e=>t===`primary`?e.section===`primary`:e.section!==`primary`)}function wt(e,t){let n={};return t.filter(e=>e.type===`json`).forEach(t=>{n[t.name]=JSON.stringify(e[t.name]??{},null,2)}),n}function Tt(){Q||=b.eventBus.on(l.channelConfigApplyStatus,e=>{Z.set(e.channel,e.status===`started`?{status:`applying`}:e.status===`succeeded`?{status:`applied`}:{status:`failed`,message:e.message}),X.forEach(e=>e())})}function Et(e){return X.add(e),Tt(),()=>{X.delete(e),!X.size&&Q&&(Q(),Q=null,Z.clear())}}function Dt(e){return(0,H.useSyncExternalStore)(Et,()=>e?Z.get(e)??null:null,()=>null)}function Ot(e){return e?e.status===`applying`?{className:`text-amber-600`,label:r(`channelConfigApplying`)}:e.status===`applied`?{className:`text-emerald-600`,label:r(`channelConfigApplied`)}:{className:`text-red-600`,label:`${r(`channelConfigApplyFailed`)}${e.message?`: ${e.message}`:``}`}:null}function kt({channelApplyStatus:t,channelLabel:n,channelName:i,enabled:a,tutorialUrl:o}){return(0,U.jsx)(R,{className:`px-6 py-5`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(j,{name:i,src:M(i),className:e(`h-9 w-9 rounded-lg border`,a?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,U.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:i[0]})}),(0,U.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900 capitalize`,children:n})]}),(0,U.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:r(`channelsFormDescription`)}),t?(0,U.jsx)(`p`,{className:e(`mt-2 text-xs font-medium`,t.className),children:t.label}):null,o?(0,U.jsxs)(`a`,{href:o,className:`mt-2 inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,U.jsx)(T,{className:`h-3.5 w-3.5`}),r(`channelsGuideTitle`)]}):null]}),(0,U.jsx)(ee,{status:a?`active`:`inactive`,label:r(a?`statusActive`:`statusInactive`)})]})})}function At({channelConfig:e,channelName:t,disabled:n,enabled:r,fields:i,formData:a,jsonDrafts:o,layoutBlocks:s,setJsonDrafts:c,uiHints:l,updateField:u}){return(0,U.jsx)(U.Fragment,{children:s.map((s,d)=>{if(s.type===`fields`){let e=Ct(i,s.section);if(e.length===0)return null;let n=(0,U.jsx)(Oe,{channelName:t,fields:e,formData:a,jsonDrafts:o,setJsonDrafts:c,updateField:u,uiHints:l});return s.collapsible?(0,U.jsxs)(`details`,{className:`group rounded-2xl border border-gray-200/80 bg-white`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-5 py-4 text-sm font-medium text-gray-900`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{children:s.collapsible.title}),s.collapsible.description?(0,U.jsx)(`p`,{className:`mt-1 text-xs font-normal text-gray-500`,children:s.collapsible.description}):null]}),(0,U.jsx)(se,{className:`h-4 w-4 text-gray-400 transition-transform group-open:rotate-180`})]}),(0,U.jsx)(`div`,{className:`space-y-6 border-t border-gray-100 px-5 py-5`,children:n})]},`${s.type}-${s.section}-${d}`):(0,U.jsx)(`div`,{children:n},`${s.type}-${s.section}-${d}`)}return s.sectionId===`feishu-auth`?(0,U.jsx)(ft,{channelConfig:e,formData:a,channelEnabled:r,disabled:n},`${s.type}-${s.sectionId}-${d}`):s.sectionId===`weixin-auth`?(0,U.jsx)(ut,{channelConfig:e,formData:a,channelName:`weixin`,channelEnabled:r,disabled:n},`${s.type}-${s.sectionId}-${d}`):null})})}function jt({actions:e,channelConfig:t,channelLabel:n,channelName:i,fields:a,layoutBlocks:o,tutorialUrl:s,uiHints:c}){let l=me(),d=de(),[p,m]=(0,H.useState)(()=>({...t})),[h,g]=(0,H.useState)(()=>wt(t,a)),[_,v]=(0,H.useState)(null),y=Ot(Dt(i)),b=typeof p.enabled==`boolean`?p.enabled:!!t.enabled,x=l.isPending||!!_,S=(e,t)=>m(n=>({...n,[e]:t})),C=e=>{e.preventDefault();let t={...p};for(let e of a){if(e.type===`password`){let n=t[e.name];(typeof n!=`string`||n.length===0)&&delete t[e.name]}if(e.type===`json`)try{t[e.name]=(h[e.name]??``).trim()?JSON.parse(h[e.name]):{}}catch{u.error(`${r(`invalidJson`)}: ${e.name}`);return}}l.mutate({channel:i,data:t})},w=e=>{if(!$(e?.channels)||!$(e.channels[i]))return;let t=e.channels[i];m(e=>xt(e,t)),g(e=>{let n={...e},r=!1;for(let e of a)e.type!==`json`||!Object.prototype.hasOwnProperty.call(t,e.name)||(n[e.name]=JSON.stringify(t[e.name]??{},null,2),r=!0);return r?n:e})},T=async e=>{v(e.id);try{let t=`channels.${i}`,n={...p};e.saveBeforeRun&&(n={...n,...e.savePatch??{}},m(n),await l.mutateAsync({channel:i,data:n}));let a=await d.mutateAsync({actionId:e.id,data:{scope:t,draftConfig:St(t,n)}});w(a.patch),a.ok?u.success(a.message||r(`success`)):u.error(a.message||r(`error`))}catch(e){u.error(`${r(`error`)}: ${e instanceof Error?e.message:String(e)}`)}finally{v(null)}};return(0,U.jsxs)(L,{children:[(0,U.jsx)(kt,{channelName:i,channelLabel:n,enabled:b,tutorialUrl:s,channelApplyStatus:y}),(0,U.jsxs)(`form`,{onSubmit:C,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(z,{className:`space-y-6 px-6 py-5`,children:(0,U.jsx)(At,{channelConfig:t,channelName:i,enabled:b,fields:a,formData:p,jsonDrafts:h,layoutBlocks:o,setJsonDrafts:g,uiHints:c,updateField:S,disabled:x})}),(0,U.jsxs)(xe,{className:`flex flex-wrap items-center justify-between gap-3 px-6 py-4`,children:[(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.filter(e=>e.trigger===`manual`).map(e=>(0,U.jsx)(f,{type:`button`,onClick:()=>void T(e),disabled:x,variant:`secondary`,children:_===e.id?r(`connecting`):e.title},e.id))}),(0,U.jsx)(f,{type:`submit`,disabled:x,children:l.isPending?r(`saving`):r(`save`)})]})]})]})}function Mt({channelName:e}){let{data:t}=ue(),{data:n}=A(),{data:i}=ae(),a=e?t?.channels[e]??null:null,o=n?.channels.find(t=>t.name===e),s=(0,H.useMemo)(()=>_t()[e||``],[e]);if(!e||!o||!a)return(0,U.jsx)(ye,{children:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:r(`channelsSelectTitle`)}),(0,U.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:r(`channelsSelectDescription`)})]})});let c=s?.fields??yt,l=s?.layout??bt,u=i?.uiHints,d=I(`channels.${e}`,u)?.label??e,f=vt(o),p=JSON.stringify({channelName:e,channelConfig:a,jsonFields:c.filter(e=>e.type===`json`).map(e=>e.name)});return(0,U.jsx)(jt,{actions:i?.actions?.filter(t=>t.scope===`channels.${e}`)??[],channelConfig:a,channelLabel:d,channelName:e,fields:c,layoutBlocks:l,tutorialUrl:f,uiHints:u},p)}var Nt={telegram:`channelDescTelegram`,slack:`channelDescSlack`,email:`channelDescEmail`,webhook:`channelDescWebhook`,discord:`channelDescDiscord`,feishu:`channelDescFeishu`,weixin:`channelDescWeixin`},Pt=[`weixin`,`feishu`,`discord`,`qq`];function Ft(e){let t=new Map(Pt.map((e,t)=>[e,t]));return e.map((e,t)=>({channel:e,index:t})).sort((e,n)=>{let r=t.get(e.channel.name)??1/0,i=t.get(n.channel.name)??1/0;return r===i?e.index-n.index:r-i}).map(({channel:e})=>e)}function It(){let{isMobile:t}=he(),{data:n}=ue(),{data:i}=A(),{data:a}=ae(),[o,s]=(0,H.useState)(`enabled`),[l,u]=(0,H.useState)(null),[f,p]=(0,H.useState)(``),m=(0,H.useMemo)(()=>Ft(i?.channels??[]),[i?.channels]),h=n?.channels,g=(0,H.useMemo)(()=>{let e=f.trim().toLowerCase();return m.filter(e=>o!==`enabled`||!!h?.[e.name]?.enabled).filter(t=>e?(t.displayName||t.name).toLowerCase().includes(e)||t.name.toLowerCase().includes(e):!0)},[o,h,m,f]),_=l&&g.some(e=>e.name===l)?l:t?null:g[0]?.name??null;return!n||!i?(0,U.jsx)(`div`,{className:`p-8 text-gray-400`,children:r(`channelsLoading`)}):(0,U.jsxs)(c,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,U.jsx)(v,{title:r(`channelsPageTitle`),description:r(`channelsPageDescription`)}),(0,U.jsxs)(ve,{className:`xl:min-h-0`,mobileView:t?_?`detail`:`list`:void 0,onMobileBack:()=>u(null),mobileListLabel:r(`channelsPageTitle`),children:[(0,U.jsxs)(L,{children:[(0,U.jsx)(R,{className:`px-4 pt-4`,children:(0,U.jsx)(ge,{tabs:[{id:`enabled`,label:r(`channelsTabEnabled`),count:m.filter(e=>h?.[e.name]?.enabled).length},{id:`all`,label:r(`channelsTabAll`),count:m.length}],activeTab:o,onChange:s,className:`mb-0`})}),(0,U.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(w,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,U.jsx)(d,{value:f,onChange:e=>p(e.target.value),placeholder:r(`channelsFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,U.jsxs)(z,{className:`space-y-2 p-3`,children:[g.map(t=>{let i=!!n.channels[t.name]?.enabled,o=vt(t),s=I(`channels.${t.name}`,a?.uiHints)?.help||r(Nt[t.name]||`channelDescriptionDefault`);return(0,U.jsx)(Se,{onClick:()=>u(t.name),active:_===t.name,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(j,{name:t.name,src:M(t.name),className:e(`h-10 w-10 rounded-lg border`,i?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,U.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:t.name[0]})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:t.displayName||t.name}),(0,U.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:s})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,U.jsx)(`a`,{href:o,onClick:e=>e.stopPropagation(),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100/70 hover:text-gray-500`,title:r(`channelsGuideTitle`),children:(0,U.jsx)(E,{className:`h-3.5 w-3.5`})}):null,(0,U.jsx)(ee,{status:i?`active`:`inactive`,label:r(i?`statusActive`:`statusInactive`),className:`min-w-[56px] justify-center`})]})]})},t.name)}),g.length===0?(0,U.jsx)(be,{icon:oe,title:r(`channelsNoMatch`)}):null]})]}),(0,U.jsx)(Mt,{channelName:_??void 0})]})]})}export{It as ChannelsList};