@nextclaw/ui 0.15.2 → 0.15.3

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 (109) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/assets/{api-B7Qigvtm.js → api-iNBpppzj.js} +2 -2
  3. package/dist/assets/{appearance-settings-page-CuE0Iiqj.js → appearance-settings-page-DMffQFR3.js} +1 -1
  4. package/dist/assets/{book-open-Ba2f7YiG.js → book-open-C3mJGwiy.js} +1 -1
  5. package/dist/assets/{channels-list-page-CTsM6TcP.js → channels-list-page-CCtp0BRS.js} +1 -1
  6. package/dist/assets/chat-page-H5a0dWvO.js +1 -0
  7. package/dist/assets/{config-split-page-Fbb4PtTf.js → config-split-page-CrOJgB-Y.js} +1 -1
  8. package/dist/assets/{confirm-dialog-D2EG3nqE.js → confirm-dialog-Chv50USy.js} +2 -2
  9. package/dist/assets/{desktop-update-config-BGR3HUi1.js → desktop-update-config-KzTuXRf_.js} +1 -1
  10. package/dist/assets/{dist-7JTjycxE.js → dist-BunzmC4B.js} +1 -1
  11. package/dist/assets/{dist-wXLhk4hl.js → dist-ChmGwvtK.js} +1 -1
  12. package/dist/assets/doc-browser-DNRL4Zvd.js +1 -0
  13. package/dist/assets/doc-browser-Dg0pmkOg.js +1 -0
  14. package/dist/assets/{doc-browser-context-CYAGm5d5.js → doc-browser-context-BHY-0FSD.js} +1 -1
  15. package/dist/assets/{es2015-j1SRCIX5.js → es2015-DQZ5JWwK.js} +1 -1
  16. package/dist/assets/{external-link-DxuPaDoK.js → external-link-CU0kzzIP.js} +1 -1
  17. package/dist/assets/{form-actions-BztL7P_T.js → form-actions-BvCp_0lS.js} +1 -1
  18. package/dist/assets/{i18n-provider-B4oMxOFx.js → i18n-provider-Cu8XyZb_.js} +1 -1
  19. package/dist/assets/index-CzfBdvK1.css +1 -0
  20. package/dist/assets/index-DGqHne1Q.js +104 -0
  21. package/dist/assets/loader-circle-CDSFuzmk.js +1 -0
  22. package/dist/assets/mcp-marketplace-page-BeEQK0DL.js +9 -0
  23. package/dist/assets/mcp-marketplace-page-D6idOTLp.js +1 -0
  24. package/dist/assets/{model-config-page-DeKk9gvE.js → model-config-page-bNNo-XyG.js} +1 -1
  25. package/dist/assets/plus-D4DsdLN-.js +1 -0
  26. package/dist/assets/{provider-scoped-model-input-DsH2LF1q.js → provider-scoped-model-input-IlgQCsoT.js} +1 -1
  27. package/dist/assets/{providers-config-page-BFnGp68F.js → providers-config-page-wLo6CAJw.js} +1 -1
  28. package/dist/assets/{react-UirzUuST.js → react-BPIsQIlO.js} +1 -1
  29. package/dist/assets/{refresh-cw-eT8BF-8B.js → refresh-cw-CILd1vAP.js} +1 -1
  30. package/dist/assets/remote-uKEYp7AR.js +1 -0
  31. package/dist/assets/rotate-cw-wPFPg1kH.js +1 -0
  32. package/dist/assets/{runtime-config-page-BelAqiNG.js → runtime-config-page-DDn1sP4G.js} +1 -1
  33. package/dist/assets/{save-Cb2g0BOi.js → save-ByJqcPTP.js} +1 -1
  34. package/dist/assets/{search-BcHjwdsb.js → search-DVIV6pfD.js} +1 -1
  35. package/dist/assets/{search-config-page-zPm6--Ig.js → search-config-page-B-Cf4iiB.js} +1 -1
  36. package/dist/assets/{secrets-config-page-Cxyp-KuQ.js → secrets-config-page-DPKsY8Iw.js} +1 -1
  37. package/dist/assets/security-config-e9SSBlKr.js +1 -0
  38. package/dist/assets/{select-CdSEOwVM.js → select-BdgczSNw.js} +1 -1
  39. package/dist/assets/{setting-row-CTAtGexr.js → setting-row-BkTVUTKx.js} +1 -1
  40. package/dist/assets/{settings-2-2DWauOjY.js → settings-2-CH5shGg_.js} +1 -1
  41. package/dist/assets/{side-dock-DPvakJ0a.js → side-dock-BsBvcJ9i.js} +2 -2
  42. package/dist/assets/{skeleton-P5oM14E1.js → skeleton-DeX1FKw7.js} +1 -1
  43. package/dist/assets/switch-Cv8Ekb3x.js +1 -0
  44. package/dist/assets/{tag-chip-D-WsKoT1.js → tag-chip-RB9uKcoC.js} +1 -1
  45. package/dist/assets/{tooltip-CjkOaHW7.js → tooltip-oQlEN-l6.js} +1 -1
  46. package/dist/assets/{use-config--hx5oxQn.js → use-config-l3W7y8Qz.js} +1 -1
  47. package/dist/assets/{use-confirm-dialog-CD9a_SK1.js → use-confirm-dialog-BAxaVOJI.js} +1 -1
  48. package/dist/assets/x-BBMffEN0.js +1 -0
  49. package/dist/index.html +26 -26
  50. package/package.json +9 -9
  51. package/src/app/components/layout/sidebar-items.tsx +3 -3
  52. package/src/app/components/layout/sidebar-rail.styles.ts +2 -2
  53. package/src/app/components/layout/sidebar.tsx +1 -1
  54. package/src/app/styles/design-system.css +17 -4
  55. package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +1 -1
  56. package/src/features/chat/features/conversation/components/session-queued-input-rows.tsx +1 -1
  57. package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +62 -1
  58. package/src/features/chat/features/message/components/chat-message-list.container.tsx +47 -1
  59. package/src/features/chat/features/message/utils/__tests__/chat-message-process-summary.utils.test.ts +11 -1
  60. package/src/features/chat/features/message/utils/__tests__/chat-message-texts.utils.test.ts +23 -0
  61. package/src/features/chat/features/message/utils/chat-message-process-summary.utils.ts +5 -0
  62. package/src/features/chat/features/message/utils/chat-message-texts.utils.ts +138 -0
  63. package/src/features/chat/features/session/components/chat-sidebar-project-groups.tsx +1 -1
  64. package/src/features/chat/features/session/components/session-header/chat-session-title-switcher.tsx +2 -2
  65. package/src/features/chat/features/welcome/components/chat-welcome-project-picker.tsx +1 -1
  66. package/src/features/chat/features/welcome/components/chat-welcome-session-type-picker.tsx +1 -1
  67. package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-file-preview.test.tsx +67 -0
  68. package/src/features/chat/features/workspace/components/chat-session-workspace-directory-browser.tsx +1 -1
  69. package/src/features/chat/features/workspace/components/chat-session-workspace-file-breadcrumb-browser.tsx +2 -2
  70. package/src/features/chat/features/workspace/components/chat-session-workspace-file-breadcrumbs.tsx +1 -1
  71. package/src/features/chat/features/workspace/components/chat-session-workspace-file-preview.tsx +174 -22
  72. package/src/features/chat/features/workspace/utils/chat-workspace-file-tab-persistence.utils.ts +4 -0
  73. package/src/features/chat/managers/chat-thread.manager.ts +2 -0
  74. package/src/features/chat/stores/chat-thread.store.ts +3 -0
  75. package/src/features/cron/components/cron-config.tsx +63 -80
  76. package/src/features/marketplace/components/detail-doc/__tests__/marketplace-detail-doc.test.tsx +44 -6
  77. package/src/features/marketplace/components/marketplace-detail-doc.tsx +8 -4
  78. package/src/features/marketplace/components/marketplace-page-parts.tsx +1 -1
  79. package/src/features/marketplace/hooks/use-marketplace-detail-doc-entry.ts +84 -0
  80. package/src/features/panel-apps/components/panel-apps-list.tsx +2 -2
  81. package/src/features/right-panel-resources/components/right-panel-resource-home-page.tsx +1 -1
  82. package/src/features/side-dock/components/side-dock.tsx +3 -3
  83. package/src/index.css +239 -13
  84. package/src/shared/components/actions/action-link.tsx +1 -1
  85. package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +1 -1
  86. package/src/shared/components/ui/actions/icon-action-button.tsx +1 -1
  87. package/src/shared/components/ui/button.tsx +1 -1
  88. package/src/shared/components/ui/dialog.tsx +1 -1
  89. package/src/shared/components/ui/input.tsx +1 -1
  90. package/src/shared/components/ui/select.tsx +1 -1
  91. package/src/shared/components/ui/switch.tsx +1 -1
  92. package/src/shared/components/ui/tabs.tsx +1 -1
  93. package/src/shared/components/ui/textarea.tsx +1 -1
  94. package/src/shared/lib/i18n/locales/en-US/chat.json +83 -0
  95. package/src/shared/lib/i18n/locales/zh-CN/chat.json +83 -0
  96. package/dist/assets/chat-page-C_5dcuE3.js +0 -1
  97. package/dist/assets/doc-browser-bHyXnxlj.js +0 -1
  98. package/dist/assets/doc-browser-gTrQ3jCF.js +0 -1
  99. package/dist/assets/index-CvrvblgX.css +0 -1
  100. package/dist/assets/index-Obd4JYU2.js +0 -104
  101. package/dist/assets/loader-circle-CdzgK4eH.js +0 -1
  102. package/dist/assets/mcp-marketplace-page-Bt7CuOoq.js +0 -9
  103. package/dist/assets/mcp-marketplace-page-Ck3t78_n.js +0 -1
  104. package/dist/assets/plus-Bx7wQbhG.js +0 -1
  105. package/dist/assets/remote-CDkHZtA8.js +0 -1
  106. package/dist/assets/rotate-cw-1JqxHTuw.js +0 -1
  107. package/dist/assets/security-config-B_gCq9fn.js +0 -1
  108. package/dist/assets/switch-BU_UEULb.js +0 -1
  109. package/dist/assets/x-DT5x45JU.js +0 -1
@@ -0,0 +1,104 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-DNRL4Zvd.js","assets/doc-browser-Dg0pmkOg.js","assets/react-BPIsQIlO.js","assets/dist-BunzmC4B.js","assets/tooltip-oQlEN-l6.js","assets/dist-ChmGwvtK.js","assets/search-DVIV6pfD.js","assets/external-link-CU0kzzIP.js","assets/plus-D4DsdLN-.js","assets/refresh-cw-CILd1vAP.js","assets/x-BBMffEN0.js","assets/doc-browser-context-BHY-0FSD.js","assets/middleware-BILWbJE4.js","assets/model-config-page-bNNo-XyG.js","assets/api-iNBpppzj.js","assets/switch-Cv8Ekb3x.js","assets/book-open-C3mJGwiy.js","assets/provider-scoped-model-input-IlgQCsoT.js","assets/select-BdgczSNw.js","assets/es2015-DQZ5JWwK.js","assets/loader-circle-CDSFuzmk.js","assets/skeleton-DeX1FKw7.js","assets/form-actions-BvCp_0lS.js","assets/use-config-l3W7y8Qz.js","assets/config-hints-C_iP1zl_.js","assets/appearance-settings-page-DMffQFR3.js","assets/side-dock-BsBvcJ9i.js","assets/use-confirm-dialog-BAxaVOJI.js","assets/confirm-dialog-Chv50USy.js","assets/host-capabilities-9bB_998Z.js","assets/setting-row-BkTVUTKx.js","assets/chat-page-H5a0dWvO.js","assets/i18n-provider-Cu8XyZb_.js","assets/settings-2-CH5shGg_.js","assets/tag-chip-RB9uKcoC.js","assets/search-config-page-B-Cf4iiB.js","assets/config-split-page-CrOJgB-Y.js","assets/providers-config-page-wLo6CAJw.js","assets/channels-list-page-CCtp0BRS.js","assets/runtime-config-page-DDn1sP4G.js","assets/rotate-cw-wPFPg1kH.js","assets/save-ByJqcPTP.js","assets/desktop-update-config-KzTuXRf_.js","assets/security-config-e9SSBlKr.js","assets/secrets-config-page-DPKsY8Iw.js","assets/mcp-marketplace-page-D6idOTLp.js","assets/mcp-marketplace-page-BeEQK0DL.js"])))=>i.map(i=>d[i]);
2
+ import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,o as l,p as u,r as d,t as f,u as p,v as m}from"./react-BPIsQIlO.js";import{C as h,E as g,S as _,T as v,_ as y,a as b,b as x,c as S,d as C,f as w,g as T,h as E,i as D,l as O,m as k,n as A,o as ee,p as j,r as M,s as N,t as te,u as ne,v as re,w as ie,x as ae,y as oe}from"./side-dock-BsBvcJ9i.js";import{$t as se,A as ce,At as le,B as ue,Bt as de,C as fe,Ct as pe,Dt as me,Et as he,F as ge,Ft as _e,G as ve,Gt as ye,Ht as be,It as P,Jt as xe,Kt as Se,L as Ce,Lt as we,M as Te,Mt as Ee,N as De,Nt as Oe,Ot as ke,P as Ae,Pt as je,Rt as Me,S as Ne,St as Pe,Ut as Fe,Vt as Ie,W as Le,Wt as Re,X as ze,Yt as Be,Z as Ve,_ as He,_t as Ue,a as We,b as Ge,c as Ke,d as qe,dt as Je,en as Ye,f as Xe,ft as F,g as Ze,gt as Qe,h as $e,ht as et,i as tt,in as nt,j as rt,jt as it,kt as at,l as ot,lt as st,m as ct,n as lt,nn as ut,o as dt,p as ft,pt,qt as mt,r as ht,rn as gt,s as _t,t as vt,tn as yt,u as bt,ut as xt,v as St,vt as Ct,wt,x as Tt,xt as Et,y as Dt,yt as Ot}from"./api-iNBpppzj.js";import{a as kt,c as At,d as jt,f as Mt,i as Nt,l as Pt,n as Ft,o as It,r as Lt,s as Rt,u as zt}from"./mcp-marketplace-page-BeEQK0DL.js";import{a as Bt,c as Vt,i as Ht,l as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt,u as Yt}from"./switch-Cv8Ekb3x.js";import{a as Xt,b as Zt,c as I,f as Qt,g as $t,h as en,i as tn,l as nn,o as rn,p as an,r as on,s as sn,u as cn,x as ln,y as un}from"./dist-BunzmC4B.js";import{i as dn,n as fn,r as pn,t as mn}from"./es2015-DQZ5JWwK.js";import{t as hn}from"./dist-ChmGwvtK.js";import{a as gn,i as _n,n as vn,o as yn,r as bn,s as xn,t as Sn}from"./confirm-dialog-Chv50USy.js";import{n as Cn,t as wn}from"./search-DVIV6pfD.js";import{a as Tn,i as En,n as Dn,o as On,r as kn}from"./doc-browser-Dg0pmkOg.js";import{t as An}from"./book-open-C3mJGwiy.js";import{a as jn,c as Mn,i as Nn,l as Pn,n as Fn,o as In,r as Ln,s as Rn,t as zn,u as Bn}from"./tooltip-oQlEN-l6.js";import{C as Vn,S as Hn,_ as Un,a as Wn,b as Gn,c as Kn,d as qn,f as Jn,g as Yn,h as Xn,i as Zn,l as Qn,m as $n,n as er,o as tr,p as nr,r as rr,s as ir,t as ar,u as or,v as sr,w as cr,x as lr,y as ur}from"./select-BdgczSNw.js";import{a as dr,i as fr,n as pr,o as mr,r as hr,t as gr}from"./i18n-provider-Cu8XyZb_.js";import{t as _r}from"./external-link-CU0kzzIP.js";import{t as vr}from"./loader-circle-CDSFuzmk.js";import{t as yr}from"./plus-D4DsdLN-.js";import{t as br}from"./refresh-cw-CILd1vAP.js";import{n as xr,t as Sr}from"./skeleton-DeX1FKw7.js";import{t as Cr}from"./x-BBMffEN0.js";import{t as wr}from"./host-capabilities-9bB_998Z.js";import{n as Tr,t as Er}from"./middleware-BILWbJE4.js";import{t as Dr}from"./use-confirm-dialog-BAxaVOJI.js";import{a as Or,c as kr,f as Ar,h as jr,i as Mr,m as Nr,n as Pr,o as Fr,p as Ir,r as Lr,s as Rr,t as zr,u as Br}from"./doc-browser-context-BHY-0FSD.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Vr=i((e=>{var t=s();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}));function Hr(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ur(e,t,n){let r=e.slice(0);return r[t]=n,r}var Wr=class extends nt{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Ye.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!gt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Hr(e,n).forEach(e=>{e.destroy()}),Hr(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=ut(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new se(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ur(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&Ye.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},L=m(a(),1);function Gr({queries:e,...t},n){let r=Be(n),i=mt(),a=Se(),o=L.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{de(e),Fe(e,a,r.getQueryCache().get(e.queryHash))}),ye(a);let[s]=L.useState(()=>new Wr(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;L.useSyncExternalStore(L.useCallback(e=>d?s.subscribe(Ye.batchCalls(e)):yt,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),L.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>be(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&be(n,e)?Ie(n,new se(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Re({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var Kr=I(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),qr=I(`ArrowDown`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Jr=I(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Yr=I(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Xr=I(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Zr=I(`Braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Qr=I(`Brain`,[[`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:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`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:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),$r=I(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),ei=I(`CalendarClock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),ti=I(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ni=I(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ri=I(`CircleDashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),ii=I(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ai=I(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),oi=I(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),si=I(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),ci=I(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),li=I(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ui=I(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),di=I(`CornerDownRight`,[[`polyline`,{points:`15 10 20 15 15 20`,key:`1q7qjw`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),fi=I(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),pi=I(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),mi=I(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),hi=I(`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`}]]),gi=I(`Expand`,[[`path`,{d:`m21 21-6-6m6 6v-4.8m0 4.8h-4.8`,key:`1c15vz`}],[`path`,{d:`M3 16.2V21m0 0h4.8M3 21l6-6`,key:`1fsnz2`}],[`path`,{d:`M21 7.8V3m0 0h-4.8M21 3l-6 6`,key:`hawz9i`}],[`path`,{d:`M3 7.8V3m0 0h4.8M3 3l6 6`,key:`u9ee12`}]]),_i=I(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),vi=I(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),yi=I(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),bi=I(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),xi=I(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Si=I(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),Ci=I(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),wi=I(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Ti=I(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Ei=I(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Di=I(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Oi=I(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),ki=I(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Ai=I(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ji=I(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Mi=I(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Ni=I(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),Pi=I(`Image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Fi=I(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ii=I(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Li=I(`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=I(`ListTodo`,[[`rect`,{x:`3`,y:`5`,width:`6`,height:`6`,rx:`1`,key:`1defrl`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),zi=I(`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`}]]),Bi=I(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),Vi=I(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Hi=I(`MessageSquarePlus`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}]]),Ui=I(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),Wi=I(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),Gi=I(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Ki=I(`Minimize2`,[[`polyline`,{points:`4 14 10 14 10 20`,key:`11kfnr`}],[`polyline`,{points:`20 10 14 10 14 4`,key:`rlmsce`}],[`line`,{x1:`14`,x2:`21`,y1:`10`,y2:`3`,key:`o5lafz`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),qi=I(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Ji=I(`PanelLeftClose`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Yi=I(`PanelLeftOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Xi=I(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),Zi=I(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),Qi=I(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),$i=I(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),ea=I(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),ta=I(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),na=I(`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`}]]),ra=I(`Send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),ia=I(`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`}]]),aa=I(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),oa=I(`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`}]]),sa=I(`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`}]]),ca=I(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),la=I(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),ua=I(`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`}]]),da=I(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),fa=I(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),pa=I(`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`}]]),ma=I(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),ha=I(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),ga=I(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),_a=I(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),va=I(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),ya=I(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),ba=I(`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`}]]),xa=Vr(),R=u(),Sa={active:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},ready:{dot:`bg-emerald-500`,text:`text-emerald-600`,bg:`bg-emerald-50`},inactive:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},setup:{dot:`bg-gray-300`,text:`text-gray-400`,bg:`bg-gray-100/80`},warning:{dot:`bg-amber-400`,text:`text-amber-600`,bg:`bg-amber-50`}};function Ca({status:e,label:t,className:n}){let r=Sa[e];return(0,R.jsxs)(`div`,{className:p(`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5`,r.bg,n),children:[(0,R.jsx)(`span`,{className:p(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,R.jsx)(`span`,{className:p(`text-[11px] font-medium`,r.text),children:t})]})}function wa(){return Me({queryKey:Da,queryFn:dt,staleTime:5e3,refetchOnWindowFocus:!0})}function Ta(e){let{label:t,muted:n,value:r}=e;return(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,R.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function Ea(){let e=sY(),t=wa(),n=t.data,r=Fa(e=>e.actionLabel),i=(0,L.useMemo)(()=>Va(n),[n]),a=!!r,o=n?.runtime?.deviceName?.trim()||n?.settings.deviceName?.trim()||d(`remoteDeviceNameAuto`),s=!!(n?.account.loggedIn&&Pa(n)),{hero:l,issueHint:u}=i;return(0,L.useEffect)(()=>{e.remoteAccessManager.syncStatus(n)},[e,n]),t.isLoading&&!n?(0,R.jsx)(`div`,{className:`p-8 text-gray-400`,children:d(`remoteLoading`)}):(0,R.jsxs)(Vt,{className:`space-y-6`,children:[(0,R.jsx)(qt,{title:d(`remotePageTitle`),description:d(`remotePageDescription`)}),(0,R.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,R.jsxs)(Wt,{children:[(0,R.jsxs)(Bt,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(Gt,{children:l.title}),(0,R.jsx)(Ca,{status:l.badgeStatus,label:l.badgeLabel})]}),(0,R.jsx)(Ht,{children:l.description})]}),(0,R.jsxs)(Kt,{className:`space-y-5`,children:[(0,R.jsxs)(fr,{tone:`neutral`,children:[(0,R.jsx)(Ta,{label:d(`remoteSignedInAccount`),value:n?.account.email}),(0,R.jsx)(Ta,{label:d(`remoteDeviceName`),value:o}),(0,R.jsx)(Ta,{label:d(`remoteConnectionStatus`),value:l.badgeLabel}),(0,R.jsx)(Ta,{label:d(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?c(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i.primaryAction?(0,R.jsxs)(Ut,{onClick:()=>{if(i.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(n);return}if(i.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(n);return}e.remoteAccessManager.enableRemoteAccess(n)},disabled:a,children:[i.primaryAction.showRefreshIcon?(0,R.jsx)(na,{className:`mr-2 h-4 w-4`}):null,r||i.primaryAction.label]}):null,(0,R.jsxs)(Ut,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:a||!s,children:[(0,R.jsx)(ua,{className:`mr-2 h-4 w-4`}),d(`remoteOpenDeviceList`)]}),n?.settings.enabled?(0,R.jsx)(Ut,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(n),disabled:a,children:d(`remoteDisable`)}):null]}),i.shouldShowIssueHint&&u?(0,R.jsx)(fr,{tone:`warning`,title:u.title,description:u.body}):null,(0,R.jsx)(`p`,{className:`text-xs text-gray-500`,children:d(`remoteOpenWebHint`)})]})]}),(0,R.jsxs)(Wt,{children:[(0,R.jsxs)(Bt,{children:[(0,R.jsxs)(Gt,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Li,{className:`h-4 w-4 text-primary`}),d(`remoteDeviceSectionTitle`)]}),(0,R.jsx)(Ht,{children:d(`remoteDeviceSectionDescription`)})]}),(0,R.jsxs)(Kt,{className:`space-y-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(Ca,{status:n?.account.loggedIn?`ready`:`inactive`,label:n?.account.loggedIn?d(`remoteAccountConnected`):d(`remoteAccountNotConnected`)}),(0,R.jsx)(Ca,{status:n?.settings.enabled?`active`:`inactive`,label:n?.settings.enabled?d(`remoteEnabled`):d(`remoteStateDisabled`)}),(0,R.jsx)(Ca,{status:n?.service.running?`active`:`inactive`,label:n?.service.running?d(`remoteServiceRunning`):d(`remoteServiceStopped`)})]}),(0,R.jsxs)(fr,{tone:`neutral`,children:[(0,R.jsx)(Ta,{label:d(`remoteDeviceName`),value:o}),(0,R.jsx)(Ta,{label:d(`remoteConnectionStatus`),value:l.badgeLabel}),(0,R.jsx)(Ta,{label:d(`remoteLastConnectedAt`),value:n?.runtime?.lastConnectedAt?c(n.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,R.jsx)(fr,{tone:`neutral`,borderStyle:`dashed`,description:n?.account.loggedIn?d(`remoteOpenWebHint`):d(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var Da=[`remote-status`],Oa=`https://platform.nextclaw.io`,ka=`https://nextclaw-platform-console.pages.dev`,Aa=async()=>await je.fetchQuery({queryKey:Da,queryFn:dt,staleTime:5e3}),ja=async()=>(await je.invalidateQueries({queryKey:Da}),await Aa()),Ma=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function Na(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 Oa;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return ka}var Pa=e=>Na(e?.account.apiBase)||Na(e?.settings.platformApiBase)||Na(e?.platformBase)||Na(e?.account.platformBase)||void 0,Fa=f(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})})),Ia=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=Fa.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{Fa.getState().setEnabled(e)},this.setDeviceName=e=>{Fa.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{Fa.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{Fa.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await ja(),n=Fa.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await ja();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await ja(),n=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:d(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await tt(n);let e=await ja();this.hydrateDraftFromStatus(e)},successMessage:d(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await ja(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:Fa.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await ja(),n=Fa.getState();await this.runManagedAction({actionLabel:d(`remoteActionSavingAdvanced`),job:async()=>{await qe({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await ja();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?d(`remoteSettingsSaved`):d(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:d(`remoteDoctorRunning`),job:async()=>{let e=await We();Fa.getState().setDoctor(e)},successMessage:d(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,d(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,d(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,d(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let n=Fa.getState();await this.runManagedAction({actionLabel:d(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await qe({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await ja();this.hydrateDraftFromStatus(r),e?await tt(r.service.running?`restart`:`start`):t.service.running&&await tt(`restart`);let i=await ja();this.hydrateDraftFromStatus(i)},successMessage:d(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 tt(e),n=await ja();this.hydrateDraftFromStatus(n),P.success(t.message)}})},this.hydrateDraftFromStatus=e=>{Fa.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{let{actionLabel:t,job:n,successMessage:r}=e;Fa.getState().beginAction(t);try{await n(),r&&P.success(r)}catch(e){let t=e instanceof Error?e.message:d(`error`);throw P.error(t),e}finally{Fa.getState().finishAction()}}}},La=[/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 Ra(e){return e?.runtime?.lastError?.trim()||``}function za(e){let t=d(`remoteStatusIssueDetailGeneric`),n=Ra(e);return n?`${t} (${n})`:t}function Ba(e){if(!e?.settings.enabled)return!1;let t=Ra(e);return La.some(e=>e.test(t))}function Va(e){return Ba(e)?{hero:{badgeStatus:`warning`,badgeLabel:d(`remoteStateReauthorizationRequired`),title:d(`remoteStatusReauthorizationTitle`),description:d(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:d(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:d(`remoteStatusRecoveryTitle`),body:d(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:d(`statusReady`),title:d(`remoteStatusReadyTitle`),description:d(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:d(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:d(`connecting`),title:d(`remoteStatusConnectingTitle`),description:d(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:d(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:d(`remoteStateDisconnected`),title:d(`remoteStatusIssueTitle`),description:d(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:d(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:d(`remoteStatusRecoveryTitle`),body:za(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:d(`remoteServiceStopped`),title:d(`remoteStatusNeedsServiceTitle`),description:d(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:d(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:d(`remoteStatusRecoveryTitle`),body:d(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:d(`statusInactive`),title:d(`remoteStatusNeedsEnable`),description:d(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:d(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:d(`statusSetup`),title:d(`remoteStatusNeedsSignIn`),description:d(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:d(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var Ha=f(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 Ua({label:e,value:t}){return(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,R.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Wa(e){let{email:t,username:n,role:r,canSubmitUsername:i,savingUsername:a,usernameDraft:o,onUsernameDraftChange:s,onSubmitUsername:c,onOpenDeviceList:l,onLogout:u}=e;return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(fr,{tone:`success`,title:d(`accountPanelSignedInTitle`),description:d(`accountPanelSignedInDescription`)}),(0,R.jsxs)(fr,{tone:`neutral`,children:[(0,R.jsx)(Ua,{label:d(`remoteAccountEmail`),value:t}),(0,R.jsx)(Ua,{label:d(`remoteAccountUsername`),value:n}),(0,R.jsx)(Ua,{label:d(`remoteAccountRole`),value:r})]}),n?(0,R.jsx)(`p`,{className:`text-xs text-gray-500`,children:d(`remoteAccountUsernameLockedHelp`)}):(0,R.jsxs)(fr,{tone:`warning`,title:d(`remoteAccountUsernameRequiredTitle`),description:d(`remoteAccountUsernameRequiredDescription`),children:[(0,R.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,R.jsx)(Ee,{htmlFor:`account-panel-username`,children:d(`remoteAccountUsername`)}),(0,R.jsx)(Oe,{id:`account-panel-username`,value:o,onChange:e=>s(e.target.value),placeholder:d(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,R.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,R.jsx)(Ut,{disabled:!i,onClick:()=>void c(),children:d(a?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,R.jsxs)(Ut,{onClick:()=>void l(),children:[(0,R.jsx)(ua,{className:`mr-2 h-4 w-4`}),d(`remoteOpenDeviceList`)]}),(0,R.jsxs)(Ut,{variant:`outline`,onClick:()=>void u(),children:[(0,R.jsx)(zi,{className:`mr-2 h-4 w-4`}),d(`remoteLogout`)]})]})]})}function Ga(e){let{authSessionId:t,authExpiresAt:n,authStatusMessage:r,authVerificationUri:i,onStartBrowserSignIn:a,onResumeBrowserSignIn:o}=e;return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(fr,{tone:`neutral`,title:d(`accountPanelSignedOutTitle`),description:d(`accountPanelSignedOutDescription`),children:t?(0,R.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,R.jsx)(Ua,{label:d(`remoteBrowserAuthSession`),value:t}),(0,R.jsx)(Ua,{label:d(`remoteBrowserAuthExpiresAt`),value:n?c(n):`-`})]}):null}),r?(0,R.jsx)(`p`,{className:`text-sm text-gray-600`,children:r}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,R.jsx)(Ut,{onClick:()=>void a(),children:d(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),i?(0,R.jsx)(Ut,{variant:`outline`,onClick:()=>void o(),children:d(`remoteBrowserAuthResume`)}):null]})]})}function Ka(){let e=nY(),t=wa(),n=Ha(e=>e.panelOpen),r=Ha(e=>e.authSessionId),i=Ha(e=>e.authVerificationUri),a=Ha(e=>e.authExpiresAt),o=Ha(e=>e.authStatusMessage),s=t.data,[c,l]=(0,L.useState)(``),[u,f]=(0,L.useState)(!1);(0,L.useEffect)(()=>{e.accountManager.syncRemoteStatus(s)},[e,s]);let p=!u&&c.trim().length>0&&!s?.account.username;return(0,R.jsx)(vn,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,R.jsxs)(bn,{className:`max-w-xl`,children:[(0,R.jsxs)(yn,{children:[(0,R.jsxs)(xn,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Fi,{className:`h-5 w-5 text-primary`}),d(`accountPanelTitle`)]}),(0,R.jsx)(_n,{children:d(`accountPanelDescription`)})]}),s?.account.loggedIn?(0,R.jsx)(Wa,{email:s.account.email,username:s.account.username,role:s.account.role,canSubmitUsername:p,savingUsername:u,usernameDraft:c,onUsernameDraftChange:l,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(c)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,R.jsx)(Ga,{authSessionId:r,authExpiresAt:a,authStatusMessage:o,authVerificationUri:i,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function qa({username:e}){let t=Ue(),[n,r]=(0,L.useState)(e??``),[i,a]=(0,L.useState)(``),o=n.trim().length>0&&i.length>0&&!t.isPending;return(0,R.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,R.jsxs)(Wt,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,R.jsxs)(Bt,{children:[(0,R.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:d(`authBrand`)}),(0,R.jsx)(Gt,{className:`text-2xl`,children:d(`authLoginTitle`)}),(0,R.jsx)(Ht,{children:d(`authLoginDescription`)})]}),(0,R.jsx)(Kt,{children:(0,R.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),o&&t.mutate({username:n.trim(),password:i})},children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:d(`authUsername`)}),(0,R.jsx)(Oe,{value:n,onChange:e=>r(e.target.value),placeholder:d(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:d(`authPassword`)}),(0,R.jsx)(Oe,{type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:d(`authPasswordPlaceholder`)})]}),(0,R.jsx)(Ut,{type:`submit`,className:`w-full`,disabled:!o,children:t.isPending?d(`authLoggingIn`):d(`authLoginAction`)})]})})]})})}var Ja=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{Ha.getState().openPanel()},this.closeAccountPanel=()=>{Ha.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),Ha.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await Aa();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,n=await ot({apiBase:Ma(e?.status??await Aa(),t)});Ha.getState().beginBrowserAuth({sessionId:n.sessionId,verificationUri:n.verificationUri,expiresAt:n.expiresAt,intervalMs:n.intervalMs,statusMessage:d(`remoteBrowserAuthWaiting`)}),(await wr.openExternalUrl(n.verificationUri)).opened||Ha.getState().setAuthStatusMessage(d(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:d(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),P.error(`${d(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=async()=>{let e=Ha.getState().authVerificationUri;e&&await wr.openExternalUrl(e)},this.logout=async()=>{try{await _t(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),Ha.getState().clearBrowserAuth(),await ja(),P.success(d(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:d(`remoteLogoutFailed`);P.error(`${d(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await bt({username:e.trim()}),await ja(),P.success(d(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:d(`remoteAccountUsernameSetFailed`);P.error(`${d(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=Pa(await Aa());if(!t){P.error(d(`remoteOpenWebUnavailable`));return}let n=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();await wr.openExternalUrl(n)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=Ha.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Ha.getState();if(e.authSessionId)try{let t=await Aa(),n=await Ke({sessionId:e.authSessionId,apiBase:Ma(t)});if(n.status===`pending`){Ha.getState().updateBrowserAuth({statusMessage:d(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(n.message||d(`remoteBrowserAuthExpired`))),Ha.getState().clearBrowserAuth(),P.error(n.message||d(`remoteBrowserAuthExpired`));return}Ha.getState().setAuthStatusMessage(d(`remoteBrowserAuthCompleted`));let r=await ja();this.clearPollTimer(),this.resolveBrowserSignIn(r),Ha.getState().clearBrowserAuth(),P.success(d(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),Ha.getState().clearBrowserAuth();let t=e instanceof Error?e.message:d(`remoteBrowserAuthPollFailed`);P.error(`${d(`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=Ha.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?c(e.authExpiresAt):`-`}}}},Ya=`nextclaw.app.viewport-layout`,Xa=1;function Za(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function Qa(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:Za(e),width:e,isSidebarCollapsed:!1}}function $a(e){if(!e||typeof e!=`object`)return null;let{isSidebarCollapsed:t}=e;return typeof t==`boolean`?t:null}var eo=f()(Tr(()=>Qa(),{name:Ya,version:Xa,storage:Er(()=>window.localStorage),partialize:e=>({isSidebarCollapsed:e.isSidebarCollapsed}),merge:(e,t)=>{let n=$a(e);return n===null?t:{...t,isSidebarCollapsed:n}}})),to=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>eo.getState(),this.setSidebarCollapsed=e=>{eo.setState({isSidebarCollapsed:e})},this.collapseSidebarForDenseRightPanels=e=>{if(!e.isDocBrowserOpen||!e.isDocBrowserDocked||!e.isWorkspacePanelOpen)return;let t=this.getSnapshot();if(t.mode!==`desktop`||t.isSidebarCollapsed)return;let n=typeof t.width==`number`?t.width:typeof window>`u`?null:window.innerWidth;typeof n!=`number`||!Number.isFinite(n)||n>1800||this.setSidebarCollapsed(!0)},this.toggleSidebarCollapsed=()=>{eo.setState(e=>({isSidebarCollapsed:!e.isSidebarCollapsed}))},this.resetForTests=()=>{this.consumerCount=0,this.stop(),eo.setState(Qa())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;eo.setState({width:e,mode:Za(e)})}}};function no({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,R.jsx)(`div`,{className:`bg-background/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[(0,R.jsx)(Cn,{className:`h-3.5 w-3.5`}),(0,R.jsxs)(`span`,{children:[d(`chatBackToParent`),n?` · ${n}`:``]})]})})}function ro({layoutMode:e,actions:t,leading:n,onBackToList:r,projectBadge:i,sessionTypeBadge:a,shouldShow:o,title:s,titleContent:c}){let l=e===`mobile`;return(0,R.jsxs)(`div`,{"data-testid":`chat-conversation-header`,className:p(`bg-background/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-colors duration-200`,l?`px-3 sm:px-3`:`px-4 sm:px-5`,o?`opacity-100`:`h-0 py-0 opacity-0`,o&&(l?`min-h-12 pb-2 pt-2`:`h-[52px]`)),style:l&&o?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[l&&r?(0,R.jsx)(En,{icon:(0,R.jsx)(Cn,{className:`h-4 w-4`}),label:d(`chat`),onClick:r,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`}):null,n,c??(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:s}),a,i]}),t]})}var io=`Popover`,[ao,oo]=un(io,[sn]),so=sn(),[co,lo]=ao(io),uo=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=so(t),c=L.useRef(null),[l,u]=L.useState(!1),[d,f]=en({prop:r,defaultProp:i??!1,onChange:a,caller:io});return(0,R.jsx)(rn,{...s,children:(0,R.jsx)(co,{scope:t,contentId:$t(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:L.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:L.useCallback(()=>u(!0),[]),onCustomAnchorRemove:L.useCallback(()=>u(!1),[]),modal:o,children:n})})};uo.displayName=io;var fo=`PopoverAnchor`,po=L.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(fo,n),a=so(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return L.useEffect(()=>(o(),()=>s()),[o,s]),(0,R.jsx)(on,{...a,...r,ref:t})});po.displayName=fo;var mo=`PopoverTrigger`,ho=L.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(mo,n),a=so(n),o=Zt(t,i.triggerRef),s=(0,R.jsx)(Qt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ao(i.open),...r,ref:o,onClick:ln(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,R.jsx)(on,{asChild:!0,...a,children:s})});ho.displayName=mo;var go=`PopoverPortal`,[_o,vo]=ao(go,{forceMount:void 0}),yo=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=lo(go,t);return(0,R.jsx)(_o,{scope:t,forceMount:n,children:(0,R.jsx)(hn,{present:n||a.open,children:(0,R.jsx)(nn,{asChild:!0,container:i,children:r})})})};yo.displayName=go;var bo=`PopoverContent`,xo=L.forwardRef((e,t)=>{let n=vo(bo,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=lo(bo,e.__scopePopover);return(0,R.jsx)(hn,{present:r||a.open,children:a.modal?(0,R.jsx)(Co,{...i,ref:t}):(0,R.jsx)(wo,{...i,ref:t})})});xo.displayName=bo;var So=an(`PopoverContent.RemoveScroll`),Co=L.forwardRef((e,t)=>{let n=lo(bo,e.__scopePopover),r=L.useRef(null),i=Zt(t,r),a=L.useRef(!1);return L.useEffect(()=>{let e=r.current;if(e)return mn(e)},[]),(0,R.jsx)(fn,{as:So,allowPinchZoom:!0,children:(0,R.jsx)(To,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ln(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:ln(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:ln(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),wo=L.forwardRef((e,t)=>{let n=lo(bo,e.__scopePopover),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(To,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),To=L.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=lo(bo,n),p=so(n);return pn(),(0,R.jsx)(dn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(cn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,R.jsx)(Xt,{"data-state":Ao(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),Eo=`PopoverClose`,Do=L.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(Eo,n);return(0,R.jsx)(Qt.button,{type:`button`,...r,ref:t,onClick:ln(e.onClick,()=>i.onOpenChange(!1))})});Do.displayName=Eo;var Oo=`PopoverArrow`,ko=L.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=so(n);return(0,R.jsx)(tn,{...i,...r,ref:t})});ko.displayName=Oo;function Ao(e){return e?`open`:`closed`}var jo=uo,Mo=po,No=ho,Po=yo,Fo=xo,Io=`2rem`;function Lo(e){return`min(${e}, max(0px, calc(var(--radix-popover-content-available-height, 100vh) - ${Io})))`}var Ro=Lo(`24rem`),zo=jo,Bo=No,Vo=Mo,Ho=L.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,collisionPadding:r=12,style:i,...a},o)=>(0,R.jsx)(Po,{children:(0,R.jsx)(Fo,{ref:o,sideOffset:t,align:n,collisionPadding:r,className:p(`z-[var(--z-popover,10100)] w-72 overflow-x-hidden overflow-y-auto rounded-2xl border border-border bg-popover p-4 text-popover-foreground shadow-lg 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`,e),style:{maxHeight:Ro,...i},...a})}));Ho.displayName=Fo.displayName;function Uo(){let e=Be();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{ct(e,await Ne(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),P.success(i??d(`configSavedApplied`))}catch(e){throw P.error(d(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function Wo(){let e=Uo();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:d(`configSavedApplied`)})}}function Go(){let e=Uo();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=d(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){P.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function Ko({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,R.jsxs)(`button`,{type:`button`,className:p(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`),onClick:n,disabled:r,children:[(0,R.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{children:t})]})}function qo(e){try{return JSON.stringify(e??{},null,2)}catch{return`{}`}}function Jo({open:e,metadata:t,onOpenChange:n}){return(0,R.jsx)(vn,{open:e,onOpenChange:n,children:(0,R.jsxs)(bn,{className:`max-w-2xl gap-0 overflow-hidden p-0`,children:[(0,R.jsxs)(yn,{className:`border-b border-border px-5 py-4 pr-12`,children:[(0,R.jsx)(xn,{className:`text-base`,children:d(`chatSessionMetadataDialogTitle`)}),(0,R.jsx)(_n,{className:`sr-only`,children:d(`chatSessionMetadataDialogDescription`)})]}),(0,R.jsx)(`div`,{className:`px-5 pb-5 pt-4`,children:(0,R.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted/60 p-4 font-mono text-xs leading-6 text-foreground shadow-inner custom-scrollbar`,children:qo(t)})})]})})}function Yo(e){return[`server-path-browse`,e.path?.trim()??``,e.basePath?.trim()??``,e.includeFiles??!1]}function Xo(e){let{basePath:t,enabled:n,includeFiles:r,path:i}=e,a=i?.trim()??``,o=t?.trim()??``;return Me({queryKey:Yo({path:a,basePath:o,includeFiles:r}),queryFn:()=>lt({path:a,basePath:o,includeFiles:r}),enabled:n??!0,staleTime:0})}var Zo=L.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsx)(`div`,{ref:r,className:p(`overflow-auto`,e),...n,children:t}));Zo.displayName=`ScrollArea`;function Qo({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:o,pathLabel:s,pathPlaceholder:c,confirmLabel:l,hint:u}){let[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(``);(0,L.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),h(n),_(``)},[t,e]);let v=Xo({path:m,enabled:e});(0,L.useEffect)(()=>{!e||!v.data||f.trim().length===0&&p(v.data.currentPath)},[v.data,f,e]);let y=f.trim(),b=y.length===0||n,x=(0,L.useMemo)(()=>v.error?v.error instanceof Error?v.error.message:String(v.error):null,[v.error]),S=g.trim().toLowerCase(),C=(0,L.useMemo)(()=>{let e=v.data?.entries??[];return S.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(S)||n.includes(S)})},[v.data?.entries,S]),w=e=>{h(e),_(``),e&&p(e)};return(0,R.jsx)(vn,{open:e,onOpenChange:e=>{n||r(e)},children:(0,R.jsxs)(bn,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,R.jsxs)(yn,{children:[(0,R.jsx)(xn,{children:a}),o?(0,R.jsx)(_n,{children:o}):null]}),(0,R.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!b&&i(y)},children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(Ee,{htmlFor:`server-path-picker-input`,children:s}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(Oe,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:c,autoFocus:!0,disabled:n}),(0,R.jsx)(Ut,{type:`button`,variant:`outline`,onClick:()=>w(y||null),disabled:n,children:d(`openPath`)})]})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,R.jsxs)(Ut,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.homePath??null),disabled:n||v.isLoading,children:[(0,R.jsx)(Ni,{className:`mr-1 h-4 w-4`}),d(`homeDirectory`)]}),(0,R.jsxs)(Ut,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.parentPath??null),disabled:!v.data?.parentPath||n||v.isLoading,children:[(0,R.jsx)(Oi,{className:`mr-1 h-4 w-4`}),d(`parentDirectory`)]}),(0,R.jsxs)(Ut,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{v.refetch()},disabled:n||v.isLoading,children:[(0,R.jsx)(na,{className:`mr-1 h-4 w-4`}),d(`chatRefresh`)]})]}),(0,R.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:d(`currentDirectory`)}),(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:v.data?.breadcrumbs.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>w(e.path),disabled:n,children:e.label}),t<v.data.breadcrumbs.length-1?(0,R.jsx)(ti,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,R.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,R.jsx)(Oe,{value:g,onChange:e=>_(e.target.value),placeholder:d(`pathPickerSearchPlaceholder`),disabled:n||v.isLoading,className:`pl-9`})]})}),(0,R.jsx)(Zo,{className:`min-h-0 flex-1 px-2 py-2`,children:v.isLoading?(0,R.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:d(`loading`)}):x?(0,R.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[d(`pathBrowseFailed`),`: `,x]}):v.data&&C.length>0?(0,R.jsx)(`div`,{className:`space-y-1`,children:C.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>w(e.path),disabled:n,children:[(0,R.jsx)(Ai,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):v.data&&v.data.entries.length>0?(0,R.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:d(`pathPickerSearchEmpty`)}):(0,R.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:d(`emptyDirectory`)})})]}),u?(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:u}):null,(0,R.jsxs)(gn,{children:[(0,R.jsx)(Ut,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:d(`cancel`)}),(0,R.jsx)(Ut,{type:`submit`,disabled:b,children:n?d(`saving`):l})]})]})]})})}function $o({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,R.jsx)(Qo,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:d(`chatSessionProjectDialogTitle`),description:d(`chatSessionProjectDialogDescription`),pathLabel:d(`chatSessionProjectPathLabel`),pathPlaceholder:d(`chatSessionProjectPathPlaceholder`),confirmLabel:d(`chatSessionSetProject`),hint:d(`chatSessionProjectUpdateHint`)})}var es=`flex shrink-0 items-center gap-1.5`;function ts({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,metadata:i,childSessionCount:a=0,sessionCronJobCount:o=0,onOpenChildSessions:s,onOpenSessionCronJobs:c,onDeleteSession:l}){let u=Go(),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(!1),b=n||v;return(0,R.jsxs)(`div`,{className:es,children:[a>0&&s?(0,R.jsx)(En,{icon:(0,R.jsx)(ji,{className:`h-4 w-4`}),label:d(`chatSessionOpenChildSessions`),onClick:s,disabled:b}):null,o>0&&c?(0,R.jsx)(En,{icon:(0,R.jsx)(Kr,{className:`h-4 w-4`}),label:d(`chatSessionOpenCronJobs`),onClick:c,disabled:b}):null,(0,R.jsxs)(zo,{open:f,onOpenChange:p,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(En,{icon:(0,R.jsx)(hi,{className:`h-4 w-4`}),label:d(`chatSessionMoreActions`),tooltip:!1,disabled:b})}),(0,R.jsx)(Ho,{align:`end`,className:`w-56 p-2`,children:(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(Ko,{icon:Ei,label:d(`chatSessionSetProject`),onClick:()=>{p(!1),h(!0)},disabled:b}),(0,R.jsx)(Ko,{icon:Zr,label:d(`chatSessionViewMetadata`),onClick:()=>{p(!1),_(!0)},disabled:b}),(0,R.jsx)(Ko,{icon:ha,label:d(`chatDeleteSession`),onClick:()=>{p(!1),l()},disabled:!t||b,destructive:!0})]})})]}),(0,R.jsx)($o,{open:m,currentProjectRoot:r,isSaving:v,onOpenChange:h,onSave:async n=>{let r=t;y(!0);try{await u({sessionKey:e,projectRoot:n,persistToServer:r}),h(!1),p(!1)}finally{y(!1)}}}),(0,R.jsx)(Jo,{open:g,metadata:i,onOpenChange:_})]})}var ns={maxHeight:Lo(`18rem`)};function rs({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=Go(),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),f=async t=>{u(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),c(!1),o(!1)}finally{u(!1)}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(zo,{open:a,onOpenChange:o,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-border bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:border-primary/35 hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":d(`chatSessionSetProject`),disabled:l,children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(Ei,{className:`h-3.5 w-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:t}),(0,R.jsx)(Vn,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,R.jsxs)(Ho,{align:`start`,className:`w-72 p-2`,style:ns,children:[(0,R.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:t}),n?(0,R.jsx)(`div`,{className:`mt-1 break-all text-xs text-muted-foreground`,children:n}):null]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(Ko,{icon:Qi,label:d(`chatSessionSetProject`),onClick:()=>{o(!1),c(!0)},disabled:l}),(0,R.jsx)(Ko,{icon:ki,label:d(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:l})]})]})]}),(0,R.jsx)($o,{open:s,currentProjectRoot:n,isSaving:l,onOpenChange:c,onSave:f})]})}var is=(0,L.createContext)(null);function as({presenter:e,children:t}){return(0,R.jsx)(is.Provider,{value:e,children:t})}function os(){let e=(0,L.useContext)(is);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}function ss(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function cs(e){let t=e.activityPreview;return!t||t.state===`cancelled`?null:t.state===`failed`||t.state===`running`?t.statusText??t.replyText??null:t.state===`completed`?t.replyText??t.statusText??null:t.statusText??t.replyText??null}function ls(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function us(e,t){return e.getFullYear()===t.getFullYear()}function ds(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return us(e,t)?n:`${e.getFullYear()}年${n}`}function fs(e,n=t(),r=new Date){if(!e)return`-`;let i=e instanceof Date?e:new Date(e);if(Number.isNaN(i.getTime()))return typeof e==`string`?e:`-`;let a=l(n),o=ls(i),s=ls(r),c=Math.floor((s-o)/864e5);if(c===0)return new Intl.DateTimeFormat(a,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(i);if(c===1)return d(`chatSidebarYesterday`,n);if(c>1&&c<7)return new Intl.DateTimeFormat(a,{weekday:`long`}).format(i);if(n===`zh`)return ds(i,r);let u=us(i,r)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(a,u).format(i)}function ps(e){return e.trim().toLowerCase()}function ms(e,t){let n=ps(t);return n?[e.key,ss(e),e.projectRoot??``,e.projectName??``].map(ps).some(e=>e.includes(n)):!0}var hs=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function gs(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function _s(e){return gs(e)}function vs(e){let t=gs(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function ys(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function bs(e){let t=ys(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function xs(e,t){if(!e)return t.join(`/`);let n=ys(e.trim().replace(/\\/g,`/`));return t.length===0?n:n===`/`?`/${t.join(`/`)}`:`${n}/${t.join(`/`)}`}function Ss(e){let t=ys(e.trim().replace(/\\/g,`/`));if(!t||t===`/`||/^[A-Za-z]:[\\/]?$/.test(t))return null;let n=t.lastIndexOf(`/`);if(n<0)return null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r}function Cs(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function ws(e){let t=bs(e.path),n=bs(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function Ts(e){let{basePath:t=null,currentKind:n=`file`,labels:r,leading:i=null}=e,a=r.map((e,i)=>{let a=i===r.length-1?n:`directory`,o=xs(t,r.slice(0,i+1));return{key:`${i}:${e}`,label:e,kind:a,path:o,browsePath:a===`file`?Ss(o):o,isCurrent:i===r.length-1}});return i?[i,...a]:a}function Es(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function Ds(e){let{column:t,kind:n=`file`,line:r,path:i,sessionProjectRoot:a,truncated:o}=e,s=i.trim(),c=a?.trim()&&s?ws({path:s,sessionProjectRoot:a}):null,l;if(a?.trim()&&c){let e=a.trim(),t=vs(e)??e;l=Ts({labels:c,basePath:e,currentKind:n,leading:{key:`workspace:${t}`,label:t,kind:`workspace`,path:e,browsePath:e,isCurrent:c.length===0}})}else{let{prefix:e,segments:t}=Cs(s),r=e===`/`?`/`:e?`${e}/`:null;l=Ts({labels:t,basePath:r,currentKind:n,leading:e?{key:`root:${e}`,label:e,kind:`root`,path:r??e,browsePath:r??e,isCurrent:t.length===0}:null})}return l.length===0&&(l=[{key:`file:unknown`,label:s||`file`,kind:n,path:s,browsePath:n===`directory`?s:Ss(s),isCurrent:!0}]),{fullPath:s,locationLabel:Es({line:r,column:t}),truncated:o,segments:l}}var Os=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),ks=new Set([`running`,`completed`,`failed`,`cancelled`,`idle`]);function As(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function js(e){return`${he}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function Ms(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Ns(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function Ps(e){let t=Ns(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=Ms(n.timestamp);if(!ks.has(r)||!i)return null;let a=Ms(n.statusText),o=Ms(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function Fs(e){let t=Ns(e);return t?Ms(t.preferred_model)??Ms(t.preferredModel)??Ms(t.model):null}function Is(e){let t=Ns(e);if(!t)return null;let n=Ms(t.preferred_thinking)??Ms(t.thinking)??Ms(t.thinking_level)??Ms(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return Os.has(r)?r:null}function Ls(e){let t=Ns(e);return t?Ms(t.label):null}function Rs(e){let t=Ns(e);return t?_s(t.project_root??t.projectRoot):null}function zs(e){return Ms(e.workingDir)}function Bs(e){let t=Ns(e);return t?Ms(t.ui_last_read_at):null}function Vs(e){let t=Ns(e);return t?Ms(t.runtime)??Ms(t.session_type)??Ms(t.sessionType)??`native`:`native`}function Hs(e){let t=Ns(e);return t?Ms(t.parent_session_id)??Ms(t.parentSessionId):null}function Us(e){let t=Ns(e);return t?Ms(t.spawned_by_request_id)??Ms(t.spawnedByRequestId):null}function Ws(e){let t=Ns(e);return t?t.child_session_promoted===!0:!1}function Gs(e){if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function Ks(e){return e.state===`cancelled`?hs.CANCELLED:e.state===`result`?hs.RESULT:e.state===`partial-call`?hs.PARTIAL_CALL:hs.CALL}function qs(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:js(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:Ks(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:As(n.args),result:n.result}})}return t}function Js(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function Ys(e){return{id:e.id,role:Js(e.role),parts:qs(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function Xs(e){let t=Ns(e),n=Ls(e),r=Fs(e),i=Is(e),a=Rs(e),o=zs(e)??a,s=Bs(e),c=Ms(e.lastMessageAt),l=vs(a),u=Gs(e.sessionId),d=Hs(e),f=Us(e),p=Ws(e),m=Ps(e);return{key:e.sessionId,createdAt:e.createdAt??e.updatedAt,updatedAt:e.updatedAt,...c?{lastMessageAt:c}:{},...s?{readAt:s}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...n?{label:n}:{},...u,...r?{preferredModel:r}:{},...i?{preferredThinking:i}:{},...a?{projectRoot:a}:{},...o?{workingDir:o}:{},...l?{projectName:l}:{},...t?{metadata:t}:{},sessionType:Vs(e),sessionTypeMutable:!1,status:e.status??`idle`,isChildSession:!!d,...p?{isPromotedChildSession:p}:{},...d?{parentSessionId:d}:{},...f?{spawnedByRequestId:f}:{},...m?{activityPreview:m}:{},messageCount:e.messageCount}}function Zs(e){return e.map(Xs)}var Qs=`nextclaw.chat.session-list.mode`,$s=`time-first`;function ec(e){return e===`time-first`||e===`project-first`}function tc(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))]:[]}function nc(e){if(!e||typeof e!=`object`)return null;let{snapshot:t}=e;return!t||typeof t!=`object`?null:ec(t.listMode)?t.listMode:null}function rc(e,t){let n=e?.trim();if(!n)return!1;let r=t?.trim();return r?n.localeCompare(r)>0:!1}function ic(e){let{active:t,readAt:n,runStatus:r,lastMessageAt:i}=e;return t||r===`running`?!1:rc(i,n)}var ac={selectedSessionKey:null,selectedAgentId:`main`,query:``,listMode:$s,pinnedSessionKeys:[],pinnedProjectRoots:[],collapsedProjectRoots:[]};function oc(e){return t=>e(e=>({snapshot:{...e.snapshot,...t}}))}function sc(e){return(t,n)=>e(e=>{let r=t.trim(),i=n?.trim();if(!r||!i)return e;let a=e.optimisticReadAtBySessionKey[r];return a&&a.localeCompare(i)>=0?e:{...e,optimisticReadAtBySessionKey:{...e.optimisticReadAtBySessionKey,[r]:i}}})}var z=f()(Tr(e=>({snapshot:ac,optimisticReadAtBySessionKey:{},setSnapshot:oc(e),markSessionRead:sc(e)}),{name:Qs,storage:Er(()=>window.localStorage),partialize:e=>({snapshot:{listMode:e.snapshot.listMode,pinnedSessionKeys:e.snapshot.pinnedSessionKeys,pinnedProjectRoots:e.snapshot.pinnedProjectRoots,collapsedProjectRoots:e.snapshot.collapsedProjectRoots}}),merge:(e,t)=>{if(!e||typeof e!=`object`)return t;let{snapshot:n}=e,r=nc(e);return{...t,snapshot:{...t.snapshot,...r?{listMode:r}:{},pinnedSessionKeys:tc(n?.pinnedSessionKeys),pinnedProjectRoots:tc(n?.pinnedProjectRoots),collapsedProjectRoots:tc(n?.collapsedProjectRoots)}}}})),cc={staleTime:5e3,retry:!1};function lc(e){return Me({queryKey:[`ncp-sessions`,e?.limit??null,e?.peerId?.trim()||null],queryFn:()=>Tt(e),...cc})}function uc(e){return Me({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>Ge(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,...cc})}function dc(e,t){return e.filter(e=>ms(e,t))}function fc(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function pc(e={}){let t=z(e=>e.snapshot.query),n=e.query??t,r=lc({limit:e.limit??200}),i=(0,L.useMemo)(()=>dc(Zs(r.data?.sessions??[]).filter(fc),n).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[n,r.data?.sessions]);return{isLoading:r.isLoading,items:i}}var mc={telegram:`telegram.svg`,slack:`slack.svg`,discord:`discord.svg`,whatsapp:`whatsapp.svg`,qq:`qq.svg`,feishu:`feishu.svg`,dingtalk:`dingtalk.svg`,wecom:`wecom.svg`,weixin:`weixin.svg`,email:`email.svg`};function hc(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function gc(e){return hc(mc,e)}var _c={wx:`weixin`,lark:`feishu`},vc={cron:{icon:`cron`}},yc={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function bc(e){return e?.trim().toLowerCase()??``}function xc(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Sc(e,t){let n=bc(e);if(!n||n===`native`)return null;let r=t.find(e=>bc(e.value)===n);return r?.label.trim()?r.label.trim():xc(n)}function Cc(e,t){let n=bc(e);return!n||n===`native`?null:t.find(e=>bc(e.value)===n)??null}function wc(e){let t=bc(e);if(!t)return null;let n=_c[t]??t;return gc(n)?n:null}function Tc(e,t){let n=wc(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=vc[bc(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=bc(e.sessionType),a=Cc(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let o=yc[i];return o?{icon:null,label:d(o)}:{icon:null,label:a?.label?.trim()||Sc(e.sessionType,t)}}var Ec=`app://`;function Dc(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Oc(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Ec))return t;let n=Dc(t.slice(6));return n?`/${n}`:null}function kc({name:e,src:t,className:n,imgClassName:r,fallback:i}){let[a,o]=(0,L.useState)(!1),s=!!t&&!a;return(0,R.jsx)(`div`,{className:p(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:s?(0,R.jsx)(`img`,{src:t,alt:`${e} logo`,className:p(`block h-6 w-6 object-contain`,r),onError:()=>o(!0),draggable:!1}):i??(0,R.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function Ac({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,R.jsx)(jc,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Oc(e.src);return(0,R.jsx)(kc,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:p(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,R.jsx)(Xr,{className:p(`h-3 w-3 text-muted-foreground`,t)})})}return(0,R.jsx)(Kr,{className:p(`h-3.5 w-3.5`,t)})}function jc({channel:e,className:t}){return(0,R.jsx)(kc,{name:e,src:gc(e),className:p(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,R.jsx)(Xr,{className:`h-3 w-3 text-muted-foreground`})})}function Mc({status:e,className:t}){let n=d(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,R.jsxs)(`span`,{className:p(`inline-flex h-3.5 w-3.5 items-center justify-center text-muted-foreground/70`,t),title:n,"aria-label":n,children:[(0,R.jsx)(vr,{className:`h-3 w-3 animate-spin`}),(0,R.jsx)(`span`,{className:`sr-only`,children:n})]})}function Nc(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function Pc(e){return[...e].sort((e,t)=>Nc(t)-Nc(e))}function Fc(e,t){return[...e].sort((e,n)=>Number(t.has(n.session.key))-Number(t.has(e.session.key))||Nc(n)-Nc(e))}function Ic(e,t=new Set){let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=r-864e5,a=r-7*864e5,o=[],s=[],c=[],l=[],u=e.filter(e=>!t.has(e.session.key)),f=Fc(e.filter(e=>t.has(e.session.key)),t);for(let e of u){let t=Nc(e);t>=r?o.push(e):t>=i?s.push(e):t>=a?c.push(e):l.push(e)}let p=[];return f.length>0&&p.push({label:d(`chatSidebarPinned`),items:f}),o.length>0&&p.push({label:d(`chatSidebarToday`),items:o}),s.length>0&&p.push({label:d(`chatSidebarYesterday`),items:s}),c.length>0&&p.push({label:d(`chatSidebarPrevious7Days`),items:c}),l.length>0&&p.push({label:d(`chatSidebarOlder`),items:l}),p}function Lc(e,t=new Set,n=new Set){let r=new Map;for(let t of e){let e=t.session.projectRoot?.trim();if(!e)continue;let i=r.get(e),a=Nc(t);if(i){i.items.push(t),i.latestUpdatedAt=Math.max(i.latestUpdatedAt,a);continue}r.set(e,{projectRoot:e,projectName:t.session.projectName?.trim()||vs(e)||e,items:[t],latestUpdatedAt:a,isPinned:n.has(e)})}return[...r.values()].map(e=>({...e,items:Fc(e.items,t)})).sort((e,t)=>Number(t.isPinned)-Number(e.isPinned)||t.latestUpdatedAt-e.latestUpdatedAt)}function Rc(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>Nc(t)-Nc(e));return t}function zc(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Bc=`native`;function Vc(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:Bc}function Hc(e,t=Bc){return Vc(e?.runtime?.trim()||e?.engine?.trim()||t)}function Uc(e,t){return e===`native`?d(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function Wc(e){let t=new Map;for(let n of e){let e=Vc(n.value);t.set(e,{value:e,label:n.label?.trim()||Uc(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,modelSelectionMode:n.modelSelectionMode??`nextclaw`,runtimeDefaultThinking:n.runtimeDefaultThinking??null,cta:n.cta??null})}return t.has(`native`)||t.set(Bc,{value:Bc,label:Uc(Bc),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,modelSelectionMode:`nextclaw`,runtimeDefaultThinking:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}var Gc=f(e=>({snapshot:{},setSnapshot:t=>e(({snapshot:e})=>({snapshot:{...e,...t}}))})),Kc=`group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`;function qc({title:e}){return(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e})}function Jc({label:e}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-4 text-xs text-muted-foreground`,children:[(0,R.jsx)(Ui,{className:`h-4 w-4 shrink-0 text-muted-foreground/55`}),(0,R.jsx)(`span`,{children:e})]})}function Yc(){return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-4 text-xs text-muted-foreground`,children:[(0,R.jsx)(vr,{className:`h-4 w-4 shrink-0 animate-spin`}),(0,R.jsx)(`span`,{children:d(`sessionsLoading`)})]})}function Xc({item:e,selectedSessionKey:t,optimisticReadAtBySessionKey:n,sessionTypeOptions:r,onSelect:i}){let{session:a,runStatus:o}=e,s=t===a.key,c=n[a.key],l=c&&a.readAt?c.localeCompare(a.readAt)>0?c:a.readAt:c??a.readAt,u=ic({active:s,lastMessageAt:a.lastMessageAt,readAt:l,runStatus:o}),f=cs(a)??a.projectName??a.projectRoot??`${a.messageCount}`,m=fs(a.lastMessageAt??a.createdAt),h=Tc(a,r);return(0,R.jsxs)(`button`,{type:`button`,"aria-current":s?`page`:void 0,className:p(`flex w-full min-w-0 items-start gap-2 rounded-lg px-2.5 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,s?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/70`),onClick:()=>i(a.key),children:[(0,R.jsx)(`span`,{className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center`,children:s?(0,R.jsx)(cr,{className:`h-3.5 w-3.5`}):u?(0,R.jsx)(`span`,{"aria-label":d(`chatSessionUnread`),className:`h-2 w-2 rounded-full bg-primary`}):null}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,children:ss(a)}),h.label?(0,R.jsx)(`span`,{className:`shrink-0 rounded-full border border-border/70 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-muted-foreground`,children:h.label}):null,h.icon?(0,R.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center text-muted-foreground`,children:(0,R.jsx)(Ac,{icon:h.icon})}):null]}),(0,R.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),(0,R.jsx)(`span`,{className:`shrink-0`,children:m})]})]}),o?(0,R.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,R.jsx)(Mc,{status:o})}):null]})}function Zc({selectedSessionKey:e,title:t}){let n=os(),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(``),s=z(e=>e.optimisticReadAtBySessionKey),c=Gc(e=>e.snapshot.sessionTypesQuery?.data??null),{isLoading:l,items:u}=pc({query:a}),f=(0,L.useMemo)(()=>Pc(u),[u]),m=(0,L.useMemo)(()=>Wc(c?.options??[]),[c?.options]),h=t=>{i(!1),o(``),t!==e&&n.chatSessionListManager.selectSession(t)};return(0,R.jsxs)(zo,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":`${d(`chatSessionSwitch`)}: ${t}`,"aria-expanded":r,className:Kc,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,R.jsx)(Vn,{className:p(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:text-accent-foreground`,r?`rotate-180`:null)})]})}),(0,R.jsxs)(Ho,{align:`start`,className:`w-[22rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,R.jsxs)(`div`,{className:`space-y-2 border-b border-border px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground/75`,children:d(`chatSessionSwitcherTitle`)}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/65`}),(0,R.jsx)(Oe,{value:a,onChange:e=>o(e.target.value),placeholder:d(`chatSearchSessionPlaceholder`),"aria-label":d(`chatSearchSessionPlaceholder`),className:`h-8 rounded-lg bg-background pl-8 pr-2 text-xs`,autoFocus:!0})]})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-y-auto p-1.5`,children:l?(0,R.jsx)(Yc,{}):f.length>0?(0,R.jsx)(`div`,{className:`space-y-1`,children:f.map(t=>(0,R.jsx)(Xc,{item:t,selectedSessionKey:e,optimisticReadAtBySessionKey:s,sessionTypeOptions:m,onSelect:h},t.session.key))}):(0,R.jsx)(Jc,{label:a.trim()?d(`chatSessionSwitcherNoResults`):d(`sessionsEmpty`)})})]})]})}function Qc({layoutMode:e,selectedSessionKey:t,title:n}){let r=eo(e=>e.isSidebarCollapsed);return e!==`desktop`||!r?(0,R.jsx)(qc,{title:n}):(0,R.jsx)(Zc,{selectedSessionKey:t,title:n})}function $c(e={all:!0}){return Me({queryKey:[`cron`,e],queryFn:()=>Le(e),staleTime:1e4})}function el(){let e=Be();return{onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),P.success(d(`configSavedApplied`))},onError:e=>{P.error(d(`configSaveFailed`)+`: `+e.message)}}}function tl(){return we({mutationFn:({id:e})=>Ce(e),...el()})}function nl(){return we({mutationFn:({id:e,enabled:t})=>Ve(e,{enabled:t}),...el()})}function rl(){return we({mutationFn:({id:e,force:t})=>ze(e,{force:t}),...el()})}function il(e){return c(e??void 0)}function al(e){if(!e)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=Date.now(),i=n.getTime()-r,a=t(),o=Math.abs(i);if(o<6e4)return a===`zh`?`刚刚`:`just now`;if(o<36e5){let e=Math.round(o/6e4);return i>0?a===`zh`?`${e}分钟后`:`in ${e}m`:a===`zh`?`${e}分钟前`:`${e}m ago`}if(o<864e5){let e=Math.round(o/36e5);return i>0?a===`zh`?`${e}小时后`:`in ${e}h`:a===`zh`?`${e}小时前`:`${e}h ago`}let s=Math.round(o/864e5);return i>0?a===`zh`?`${s}天后`:`in ${s}d`:a===`zh`?`${s}天前`:`${s}d ago`}function ol(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:c(new Date(e))}function sl(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}var cl=[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`],ll=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function ul(e){return e.padStart(2,`0`)}function dl(e,t){let n=e.trim().split(/\s+/);if(n.length!==5)return null;let[r,i,a,o,s]=n,c=t===`zh`;if(r===`*`&&i===`*`&&a===`*`&&o===`*`&&s===`*`)return c?`每分钟`:`every minute`;if(r.startsWith(`*/`)&&i===`*`&&a===`*`&&o===`*`&&s===`*`){let e=parseInt(r.slice(2),10);if(Number.isFinite(e)&&e>0)return c?`每 ${e} 分钟`:`every ${e}m`}if(r===`0`&&i===`*`&&a===`*`&&o===`*`&&s===`*`)return c?`每小时`:`every hour`;let l=`${ul(i)}:${ul(r)}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&s===`*`)return c?`每天 ${l}`:`daily ${l}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&s===`1-5`)return c?`工作日 ${l}`:`weekdays ${l}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&(s===`0,6`||s===`6,0`))return c?`周末 ${l}`:`weekends ${l}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&/^\d$/.test(s)){let e=parseInt(s,10),t=c?cl[e]:ll[e];return t?`${t} ${l}`:null}return r!==`*`&&i!==`*`&&a!==`*`&&o===`*`&&s===`*`?c?`每月 ${a} 日 ${l}`:`monthly ${a} ${l}`:null}function fl(e){let n=t(),r=n===`zh`,{schedule:i}=e;if(i.kind===`cron`)return i.expr?dl(i.expr,n)??`cron ${i.expr}`:`cron`;if(i.kind===`every`){let e=sl(i.everyMs);return r?`每 ${e}`:`every ${e}`}return i.kind===`at`?`${r?`定时`:`at`} ${ol(i.atMs)}`:`-`}function pl(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function ml(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function hl(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.sessionId??``].join(` `).toLowerCase().includes(n):!0}function gl(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function _l({job:e}){return(0,R.jsxs)(`span`,{className:p(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium`,e.enabled?`bg-emerald-50 text-emerald-700`:`bg-muted text-muted-foreground`),children:[(0,R.jsx)(`span`,{className:p(`h-1.5 w-1.5 rounded-full`,e.enabled?`bg-emerald-500`:`bg-muted-foreground/50`)}),e.enabled?d(`enabled`):d(`disabled`)]})}function vl(e){let{job:t,onDelete:n,onRun:r,onToggle:i}=e,[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(!1);return(0,R.jsx)(`div`,{className:p(`group overflow-hidden rounded-xl border border-border/70 bg-card transition-colors cursor-pointer`,a?`bg-muted/20`:`hover:bg-muted/30`),onClick:e=>{e.target.closest(`[data-no-expand]`)||o(!a)},children:(0,R.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a?(0,R.jsx)(Vn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,R.jsx)(ti,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 group-hover:text-muted-foreground transition-colors`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:t.name||t.id}),(0,R.jsx)(_l,{job:t}),t.deleteAfterRun?(0,R.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:d(`cronOneShot`)}):null]})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,"data-no-expand":!0,children:[(0,R.jsx)(Jt,{checked:t.enabled,onCheckedChange:e=>i(t,e)}),(0,R.jsxs)(zo,{open:s,onOpenChange:c,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(Ut,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted`,"aria-label":d(`cronMoreActions`),children:(0,R.jsx)(hi,{className:`h-4 w-4`})})}),(0,R.jsxs)(Ho,{align:`end`,sideOffset:4,className:`w-40 p-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{c(!1),r(t)},className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted`,children:[(0,R.jsx)($i,{className:`h-3.5 w-3.5 text-muted-foreground`}),d(`cronRunNow`)]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{c(!1),n(t)},className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-600 transition-colors hover:bg-red-50`,children:[(0,R.jsx)(ha,{className:`h-3.5 w-3.5`}),d(`delete`)]})]})]})]})]}),(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground pl-6`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(ei,{className:`h-3 w-3 text-muted-foreground/70`}),(0,R.jsx)(`span`,{className:`font-mono text-foreground/80`,children:fl(t)})]}),t.state.nextRunAt?(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(si,{className:`h-3 w-3 text-muted-foreground/70`}),(0,R.jsx)(`span`,{children:al(t.state.nextRunAt)})]}):null,t.state.lastRunAt?(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,"data-no-expand":!0,children:[(0,R.jsx)(`span`,{className:`text-border`,children:`•`}),t.state.lastStatus===`error`&&t.state.lastError?(0,R.jsx)(Ln,{delayDuration:200,children:(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`span`,{className:`inline-flex items-center gap-0.5 text-orange-500 cursor-help`,children:(0,R.jsx)(mr,{className:`h-3 w-3`})})}),(0,R.jsx)(Fn,{side:`top`,align:`start`,className:`max-w-xs text-xs bg-red-50 text-red-700 border-red-200`,children:t.state.lastError})]})}):(0,R.jsx)(`span`,{className:p(t.state.lastStatus===`ok`?`text-emerald-500`:`text-muted-foreground/70`),children:t.state.lastStatus===`ok`?`✓`:``}),(0,R.jsx)(`span`,{children:al(t.state.lastRunAt)})]}):null]}),(0,R.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,R.jsx)(`div`,{className:p(`text-sm text-muted-foreground break-words`,!a&&`line-clamp-2`),children:t.payload.message})}),a?(0,R.jsxs)(`div`,{className:`mt-3 ml-6 space-y-3 border-t border-border/60 pt-3`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-2 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mb-0.5`,children:d(`cronSessionLabel`)}),(0,R.jsx)(`div`,{className:`text-foreground/80 font-mono text-[11px] truncate`,title:pl(t),children:pl(t)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mb-0.5`,children:d(`cronNextRun`)}),(0,R.jsx)(`div`,{className:`text-foreground/80`,children:il(t.state.nextRunAt)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mb-0.5`,children:d(`cronLastRun`)}),(0,R.jsx)(`div`,{className:`text-foreground/80`,children:il(t.state.lastRunAt)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mb-0.5`,children:d(`cronLastStatus`)}),(0,R.jsx)(`div`,{className:p(`inline-flex items-center gap-1 font-medium`,t.state.lastStatus===`ok`?`text-emerald-600`:t.state.lastStatus===`error`?`text-red-600`:t.state.lastStatus===`skipped`?`text-amber-600`:`text-muted-foreground`),children:t.state.lastStatus??`-`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mb-0.5`,children:d(`cronCreatedAt`)}),(0,R.jsx)(`div`,{className:`text-foreground/80`,children:il(t.createdAt)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mb-0.5`,children:d(`cronId`)}),(0,R.jsx)(`div`,{className:`text-foreground/80 font-mono text-[11px] truncate`,title:t.id,children:t.id})]})]}),t.state.lastError?(0,R.jsx)(`div`,{className:`rounded-lg bg-red-50/80 border border-red-100 px-3 py-2 text-xs text-red-600 break-words`,children:t.state.lastError}):null]}):null]})})}function yl(){let[e,t]=(0,L.useState)(``),[n,r]=(0,L.useState)(`all`),i=$c({all:!0}),a=tl(),o=nl(),s=rl(),{confirm:c,ConfirmDialog:l}=Dr(),u=(0,L.useMemo)(()=>(i.data?.jobs??[]).filter(t=>hl(t,e)).filter(e=>gl(e,n)),[i.data,e,n]),f=async e=>{await c({title:`${d(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:d(`delete`)})&&a.mutate({id:e.id})},m=(e,t)=>{o.mutate({id:e.id,enabled:t})},h=async e=>{let t=!e.enabled;t&&!await c({title:`${d(`cronRunForceConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:d(`cronRunNow`)})||s.mutate({id:e.id,force:t})};return(0,R.jsxs)(Vt,{fullHeight:!0,children:[(0,R.jsx)(qt,{title:d(`cronPageTitle`),description:d(`cronPageDescription`),actions:(0,R.jsx)(Ut,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted`,onClick:()=>i.refetch(),children:(0,R.jsx)(br,{className:p(`h-4 w-4`,i.isFetching&&`animate-spin`)})})}),(0,R.jsx)(`div`,{className:`mb-4`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2.5 items-center`,children:[(0,R.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/70`}),(0,R.jsx)(Oe,{value:e,onChange:e=>t(e.target.value),placeholder:d(`cronSearchPlaceholder`),className:`pl-9`})]}),(0,R.jsx)(`div`,{className:`min-w-[140px]`,children:(0,R.jsxs)(ar,{value:n,onValueChange:e=>r(e),children:[(0,R.jsx)(Zn,{className:`w-full`,children:(0,R.jsx)(Wn,{placeholder:d(`cronStatusLabel`)})}),(0,R.jsxs)(er,{children:[(0,R.jsx)(rr,{value:`all`,children:d(`cronStatusAll`)}),(0,R.jsx)(rr,{value:`enabled`,children:d(`cronStatusEnabled`)}),(0,R.jsx)(rr,{value:`disabled`,children:d(`cronStatusDisabled`)})]})]})}),(0,R.jsxs)(`div`,{className:`text-xs text-muted-foreground ml-auto tabular-nums`,children:[u.length,` / `,i.data?.total??0]})]})}),(0,R.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:i.isLoading?(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-muted-foreground`,children:[(0,R.jsx)(br,{className:`h-5 w-5 animate-spin mb-3`}),(0,R.jsx)(`span`,{className:`text-sm`,children:d(`cronLoading`)})]}):u.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-muted-foreground`,children:[(0,R.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-xl bg-muted`,children:(0,R.jsx)(Ri,{className:`h-5 w-5 text-muted-foreground/70`})}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:d(`cronEmpty`)}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground mt-1`,children:d(`cronEmptyGuide`)})]}):(0,R.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>(0,R.jsx)(vl,{job:e,onDelete:f,onRun:h,onToggle:m},e.id))})}),(0,R.jsx)(l,{})]})}var bl=[];function xl(e,t){let n=Gc(e=>e.snapshot.sessionsQuery?.data?.sessions??bl),r=(0,L.useMemo)(()=>{let r=e.childSessionTabs.filter(e=>e.parentSessionKey===t),i=new Set(r.map(e=>e.sessionKey));return[...r,...Zs(n).filter(e=>e.parentSessionId===t&&!i.has(e.key)).map(e=>({sessionKey:e.key,parentSessionKey:t}))]},[t,n,e.childSessionTabs]),i=(0,L.useMemo)(()=>e.workspaceFileTabs.filter(e=>e.parentSessionKey===t),[t,e.workspaceFileTabs]),a=e.activeSideChatDraft?.parentSessionKey===t?e.activeSideChatDraft:null,o=$c({all:!0}),s=(0,L.useMemo)(()=>(o.data?.jobs??[]).filter(e=>ml(e,t)),[o.data?.jobs,t]);return{childSessionTabs:r,activeSideChatDraft:a,workspaceFileTabs:i,sessionCronJobs:s,showWorkspacePanel:e.workspacePanelParentKey===t&&(a!==null||r.length>0||i.length>0||s.length>0)}}var Sl=[];function Cl(){let e=Gc(e=>!!(e.snapshot.configQuery?.isFetched||e.snapshot.configQuery?.isSuccess)),t=Gc(e=>!!(e.snapshot.providersQuery?.isFetched||e.snapshot.providersQuery?.isSuccess)),n=Gc(e=>!!(e.snapshot.providerTemplatesQuery?.isFetched||e.snapshot.providerTemplatesQuery?.isSuccess));return e&&t&&n}function wl(e){let t=Gc(e=>e.snapshot.sessionsQuery?.data?.sessions??Sl),n=(0,L.useMemo)(()=>Zs(t),[t]);return(0,L.useMemo)(()=>n.find(t=>t.key===e)??null,[n,e])}function Tl(e){return!!e&&typeof e==`object`}function El(e){return typeof e==`string`&&e.trim().length>0?e.trim():null}function Dl(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Ol(e){return typeof e==`string`?e:null}function kl(e){return e===`auto`||e===`source`||e===`rendered`?e:null}function Al(e){if(!Tl(e)||typeof e.key!=`string`||typeof e.path!=`string`||e.viewMode!==`preview`&&e.viewMode!==`diff`)return null;let t=e.key.trim(),n=e.path.trim();return!t||!n?null:{key:t,parentSessionKey:El(e.parentSessionKey),path:n,label:El(e.label),viewMode:e.viewMode,previewViewer:kl(e.previewViewer),line:Dl(e.line),column:Dl(e.column),rawText:Ol(e.rawText),contentUrl:El(e.contentUrl),mimeType:El(e.mimeType),beforeText:Ol(e.beforeText),afterText:Ol(e.afterText),patchText:Ol(e.patchText),oldStartLine:Dl(e.oldStartLine),newStartLine:Dl(e.newStartLine)}}function jl(e){return{key:e.key,parentSessionKey:e.parentSessionKey,path:e.path,label:e.label,viewMode:e.viewMode,previewViewer:e.previewViewer,line:e.line,column:e.column,rawText:e.rawText,contentUrl:e.contentUrl,mimeType:e.mimeType,beforeText:e.beforeText,afterText:e.afterText,patchText:e.patchText,oldStartLine:e.oldStartLine,newStartLine:e.newStartLine}}var Ml=`nextclaw.chat.workspace-panel.state`,Nl=2,Pl=8,Fl={sessionTypeLabel:null,sessionTypeIcon:null,sessionKey:null,agentId:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionWorkingDir:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeSideChatDraft:null,workspaceFileTabs:[],activeWorkspaceFileKey:null,workspaceNavigationHistory:[],workspaceNavigationHistoryIndex:0,contextWindow:null};function Il(e){return!!e&&typeof e==`object`}function Ll(e){return typeof e==`string`&&e.trim().length>0?e.trim():null}function Rl(e,t){return typeof e==`number`&&Number.isInteger(e)?Math.min(Math.max(0,e),t):t}function zl(e){return e===`child-session`||e===`file`||e===`cron`}function Bl(e){if(!Il(e))return null;if(e.kind===`cron`)return{kind:`cron`};let t=Ll(e.key);return!t||e.kind!==`child-session`&&e.kind!==`file`?null:{kind:e.kind,key:t}}function Vl({activeChildSessionKey:e,activeWorkspaceFileKey:t,activeWorkspacePanelKind:n}){return n===`cron`?{kind:`cron`}:n===`child-session`&&e?{kind:`child-session`,key:e}:n===`file`&&t?{kind:`file`,key:t}:null}function Hl(e){if(!Il(e))return null;let t=Array.isArray(e.workspaceFileTabs)?e.workspaceFileTabs.map(Al).filter(e=>e!==null).slice(-Pl):[],n=Ll(e.activeWorkspaceFileKey),r=n&&t.some(e=>e.key===n)?n:t[0]?.key??null,i=zl(e.activeWorkspacePanelKind)?e.activeWorkspacePanelKind:null,a=i===`file`&&!r?null:i,o=Ll(e.activeChildSessionKey),s=Vl({activeWorkspacePanelKind:a,activeChildSessionKey:o,activeWorkspaceFileKey:r}),c=Array.isArray(e.workspaceNavigationHistory)?e.workspaceNavigationHistory.map(Bl).filter(e=>e!==null).filter(e=>e.kind!==`file`||t.some(t=>t.key===e.key)):[],l=c.length>0?c:s?[s]:[],u=l.length>0?Rl(e.workspaceNavigationHistoryIndex,l.length-1):0;return{workspacePanelParentKey:Ll(e.workspacePanelParentKey),activeWorkspacePanelKind:a,activeChildSessionKey:o,workspaceFileTabs:t,activeWorkspaceFileKey:r,workspaceNavigationHistory:l,workspaceNavigationHistoryIndex:u}}var Ul=f()(Tr(e=>({snapshot:Fl,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}),{name:Ml,version:Nl,storage:Er(()=>window.localStorage),partialize:e=>{let t=e.snapshot.workspaceNavigationHistory.filter(e=>e.kind!==`side-chat-draft`),n=t.length>0?Math.min(e.snapshot.workspaceNavigationHistoryIndex,t.length-1):0;return{snapshot:{workspacePanelParentKey:e.snapshot.workspacePanelParentKey,activeWorkspacePanelKind:e.snapshot.activeWorkspacePanelKind===`side-chat-draft`?null:e.snapshot.activeWorkspacePanelKind,activeChildSessionKey:e.snapshot.activeChildSessionKey,workspaceFileTabs:e.snapshot.workspaceFileTabs.slice(-Pl).map(jl),activeWorkspaceFileKey:e.snapshot.activeWorkspaceFileKey,workspaceNavigationHistory:t,workspaceNavigationHistoryIndex:n}}},merge:(e,t)=>{let n=Hl(Il(e)?e.snapshot:null);return n?{...t,snapshot:{...t.snapshot,...n}}:t}})),Wl=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Gl(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Kl({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,a=e.trim().toLowerCase()===`main`,[o,s]=Wl[Gl(e)%Wl.length]??Wl[0],c=a?`bg-primary`:o,l=a?`text-primary-foreground`:s;return n?.trim()?(0,R.jsx)(`img`,{src:n,alt:t?.trim()||e,className:p(`rounded-full object-cover`,r)}):(0,R.jsx)(`div`,{className:p(`rounded-full flex items-center justify-center font-semibold`,c,l,r),"aria-label":t?.trim()||e,children:a?(0,R.jsx)(Xr,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(i.trim()||`A`).slice(0,1).toUpperCase()})}function ql(){return Me({queryKey:[`agents`],queryFn:xt,staleTime:3e4})}function Jl(){let e=Be();return we({mutationFn:({agentId:e,data:t})=>Je(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),P.success(d(`configSavedApplied`))},onError:e=>{P.error(d(`configSaveFailed`)+`: `+e.message)}})}function Yl(){let e=Be();return we({mutationFn:({agentId:e})=>st(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),P.success(d(`configSavedApplied`))},onError:e=>{P.error(d(`configSaveFailed`)+`: `+e.message)}})}function Xl(e){return new Map(e.filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function Zl(e){let t=e?.trim()??``,n=ql(),r=(0,L.useMemo)(()=>Xl(n.data?.agents??[]),[n.data?.agents]);return(0,L.useMemo)(()=>{if(!t)return null;let e=r.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[r,t])}function Ql({agentId:e,className:t}){let n=Zl(e);return n?(0,R.jsx)(Kl,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}function $l({layoutMode:e,onBackToList:t}){let n=os(),r=Ul(e=>e.snapshot),i=z(e=>e.snapshot.selectedSessionKey),a=z(e=>e.snapshot.selectedAgentId),o=Gc(e=>e.snapshot.sessionTypesQuery?.data??null),s=wl(i),c=(0,L.useMemo)(()=>Wc(o?.options??[]),[o?.options]),l=Vc(s?.sessionType??o?.defaultType??`native`),u=c.find(e=>e.value===l)??null,f=u?.label??Uc(l),p=l!==`native`&&!!f,m=s?.projectRoot??null,h=s?.projectName??vs(m),g=!!s,{childSessionTabs:_,sessionCronJobs:v}=xl(r,i),y=!!(i||f),b=(s?ss(s):void 0)||(g&&i?i:null)||d(`chatSidebarNewTask`),x=s?.agentId?.trim()??a?.trim()??``,S=x.length>0&&x.toLowerCase()!==`main`;return(0,R.jsx)(ro,{layoutMode:e,title:b,titleContent:(0,R.jsx)(Qc,{layoutMode:e,selectedSessionKey:i,title:b}),shouldShow:y,onBackToList:t,leading:S?(0,R.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,R.jsx)(Ql,{agentId:x,className:`h-5 w-5`})}):null,sessionTypeBadge:p?(0,R.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:[u?.icon?.src?(0,R.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,R.jsx)(Ac,{icon:{kind:`runtime-image`,src:u.icon.src,alt:u.icon.alt??null,name:f}})}):null,f]}):null,projectBadge:h?(0,R.jsx)(rs,{sessionKey:i??`draft`,projectName:h,projectRoot:m,persistToServer:g}):null,actions:i?(0,R.jsx)(ts,{sessionKey:i,canDeleteSession:g,isDeletePending:r.isDeletePending,projectRoot:m,metadata:s?.metadata??null,childSessionCount:_.length,sessionCronJobCount:v.length,onOpenChildSessions:()=>{i&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:i,activeChildSessionKey:_[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!i||v.length===0||n.chatThreadManager.openSessionCronPanel(i)},onDeleteSession:n.chatThreadManager.deleteSession}):null})}function eu(){let e=os(),t=Ul(e=>e.snapshot);return(0,R.jsx)(no,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}var tu=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function nu(){return(0,R.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-background`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,R.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,R.jsxs)(`div`,{className:`space-y-6`,children:[(0,R.jsx)(Sr,{className:`h-6 w-52 rounded-lg bg-muted`}),(0,R.jsx)(`div`,{className:`space-y-5`,children:tu.map(e=>(0,R.jsx)(`div`,{className:p(`flex w-full`,e.alignmentClassName),children:(0,R.jsx)(Sr,{"data-testid":`chat-conversation-skeleton-bubble`,className:p(`w-full bg-muted`,e.bubbleClassName)})},e.key))})]}),(0,R.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(Sr,{className:`h-4 w-40 rounded-full bg-muted`}),(0,R.jsx)(Sr,{className:`h-[112px] w-full rounded-[30px] bg-muted`})]}),(0,R.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,R.jsx)(Sr,{className:`h-10 w-36 rounded-full bg-muted`})})]})]})})}),(0,R.jsx)(`div`,{className:`bg-background p-4`,children:(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border bg-card shadow-card`,children:[(0,R.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,R.jsx)(Sr,{className:`h-[84px] w-full rounded-[28px] bg-muted`})}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Sr,{className:`h-8 w-20 rounded-full bg-muted`}),(0,R.jsx)(Sr,{className:`h-8 w-28 rounded-full bg-muted`}),(0,R.jsx)(Sr,{className:`hidden h-8 w-24 rounded-full bg-muted sm:block`})]}),(0,R.jsx)(Sr,{className:`h-8 w-8 rounded-full bg-muted`})]})]})})})]})}function ru(e,t){return e.label?.trim()?e.label.trim():t?ss(t):e.sessionKey}function iu(e){let t=lc({limit:200}),n=(0,L.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,L.useMemo)(()=>{let e=Zs(n);return new Map(e.map(e=>[e.key,e]))},[n]);return(0,L.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:ru(e,t),agentId:n,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:t?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?Uc(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function au(e){let t=e.path.split(`/`).filter(Boolean).pop();return e.label?.trim()||t||e.path}function ou(e){let{activePanelKind:t,activeChildSessionKey:n,activeSideChatDraft:r,activeWorkspaceFileKey:i,childSessionTabs:a,workspaceFileTabs:o,sessionCronJobCount:s}=e;if(t===`cron`&&s>0)return{kind:`cron`};if(t===`side-chat-draft`&&r)return{kind:`side-chat-draft`,draft:r};if(t!==`child-session`&&i){let e=o.find(e=>e.key===i);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=a.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return a[0]?{kind:`child-session`,tab:a[0]}:r?{kind:`side-chat-draft`,draft:r}:o[0]?{kind:`file`,file:o[0]}:s>0?{kind:`cron`}:null}function su(e){let{activeSideChatDraft:t,resolvedChildTabs:n,workspaceFileTabs:r,sessionCronJobCount:i,activeSelection:a,optimisticReadAtBySessionKey:o,onSelectSession:s,onSelectFile:c,onCloseFile:l,onSelectCronJobs:u}=e,f=t?[{key:`side-chat-draft:${t.draftKey}`,kind:`side-chat-draft`,title:d(`chatWorkspaceSideChatDraftTitle`),tooltip:d(`chatWorkspaceSideChatDraftSubtitle`),active:a?.kind===`side-chat-draft`&&a.draft.draftKey===t.draftKey,onSelect:()=>void 0}]:[],p=n.map(e=>{let t=o[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:a?.kind===`child-session`&&a.tab.sessionKey===e.sessionKey,showUnreadDot:ic({active:a?.kind===`child-session`&&a.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>s(e.sessionKey)}}),m=r.map(e=>({key:`file:${e.key}`,kind:`file`,title:au(e),tooltip:e.path,viewMode:e.viewMode,active:a?.kind===`file`&&a.file.key===e.key,onSelect:()=>c(e.key),onClose:()=>l(e.key)})),h=i>0?[{key:`cron:session`,kind:`cron`,title:d(`chatWorkspaceSessionCronJobs`),tooltip:d(`chatWorkspaceSessionCronJobs`),active:a?.kind===`cron`,onSelect:u}]:[];return[...f,...p,...m,...h]}function cu({agentId:e,kind:t}){return t===`cron`?(0,R.jsx)(Kr,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,R.jsx)(bi,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`side-chat-draft`?(0,R.jsx)(Hi,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e?(0,R.jsx)(Ql,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,R.jsx)(Ui,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function lu(e){return e.map(e=>({key:e.key,label:e.title,active:e.active,tooltip:e.tooltip,leadingIcon:(0,R.jsx)(cu,{kind:e.kind,agentId:e.agentId}),badge:e.kind===`file`&&e.viewMode===`diff`?(0,R.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:d(`chatWorkspaceDiff`)}):null,unreadIndicator:e.showUnreadDot?(0,R.jsx)(`span`,{"aria-label":d(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null,closeLabel:d(`chatWorkspaceCloseFile`),closePlacement:`leading-hover`,onSelect:e.onSelect,onClose:e.onClose}))}function uu({canGoBack:e,canGoForward:t,isMaximized:n=!1,onClose:r,onGoBack:i,onGoForward:a,onRefreshFile:o,onToggleMaximize:s,tabs:c}){return(0,R.jsx)(kn,{testId:`workspace-tabs-bar`,scrollTestId:`workspace-tabs-scroll`,tabs:lu(c),actions:[{key:`back`,icon:(0,R.jsx)(Cn,{className:`h-4 w-4`}),label:d(`chatWorkspaceBack`),disabled:!e,onClick:i},{key:`forward`,icon:(0,R.jsx)(On,{className:`h-4 w-4`}),label:d(`chatWorkspaceForward`),disabled:!t,onClick:a},...o?[{key:`refresh-file`,icon:(0,R.jsx)(br,{className:`h-4 w-4`}),label:d(`chatWorkspaceRefreshFile`),onClick:o}]:[],...s?[{key:`maximize`,icon:n?(0,R.jsx)(Ki,{className:`h-4 w-4`}):(0,R.jsx)(Bi,{className:`h-4 w-4`}),label:d(n?`chatWorkspaceRestorePanel`:`chatWorkspaceMaximizePanel`),onClick:s}]:[],{key:`close`,icon:(0,R.jsx)(Cr,{className:`h-4 w-4`}),label:d(`chatWorkspaceClosePanel`),onClick:r}],scrollClassName:`workspace-horizontal-scrollbar`,actionsClassName:`ml-1 mr-1 self-stretch`})}var du={key:`slash`,marker:`/`};function fu(){return`composer-${Math.random().toString(36).slice(2,10)}`}function pu(e=``){return{id:fu(),type:`text`,text:e}}function mu(e){return{id:fu(),type:`token`,tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function hu(e){return e.type===`text`?e.text.length:1}function gu(){return[pu(``)]}function _u(e){return[pu(e)]}function vu(e){let t=[];for(let n of e){if(n.type===`text`){if(n.text.length===0)continue;let e=t[t.length-1];if(e?.type===`text`){t[t.length-1]={...e,text:e.text+n.text};continue}}t.push(n)}return t.length===0?gu():t}function yu(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}function bu(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function xu(e,t){let n=[],r=new Set;for(let i of e)i.type!==`token`||i.tokenKind!==t||r.has(i.tokenKey)||(r.add(i.tokenKey),n.push(i.tokenKey));return n}function Su(e,t,n,r){let i=Math.max(0,n-t),a=Math.max(0,t+e.text.length-r),o=[];return i>0&&o.push({...e,text:e.text.slice(0,i)}),a>0&&o.push({...e,text:e.text.slice(e.text.length-a)}),o}function Cu(e,t,n,r){return t<=n||e>=r}function wu(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function Tu(e,t,n,r,i,a,o){let s=Su(t,n,r,i);s[0]&&e.push(s[0]);let c=o;return c||=(e.push(...a),!0),s[1]&&e.push(s[1]),c}function Eu(e,t,n,r,i,a){return!r&&i<=a?(e.push(...n),!0):(e.push(t),r)}function Du(e,t,n,r){let i=Math.max(0,t),a=Math.max(i,n),o=[],s=0,c=!1;for(let t of e){let e=hu(t),n=s,l=s+e;if(Cu(n,l,i,a)){c=wu(o,r,c,n,a),o.push(t),s=l;continue}c=t.type===`text`?Tu(o,t,n,i,a,r,c):Eu(o,t,r,c,i,n),s=l}return c||o.push(...r),vu(o)}function Ou(e,t){return vu(e.filter(e=>e.type!==`token`||!t(e)))}function ku(e,t){return t===0||/\s/.test(e[t-1]??``)}function Au(e,t,n){if(!t||t.start!==t.end)return null;let r=yu(e),i=t.end,a=r.slice(0,i),o=a.lastIndexOf(n.marker);if(o<0||!ku(a,o))return null;let s=a.slice(o+n.marker.length);return/[\s\uFFFC]/.test(s)?null:{key:n.key,marker:n.marker,query:s.trim().toLowerCase(),start:o,end:i}}function ju(e,t,n=[du]){let r=null;for(let i of n){let n=Au(e,t,i);n&&(!r||n.start>r.start)&&(r=n)}return r}function Mu(e,t){let n=Au(e,t,du);return n?{query:n.query,start:n.start,end:n.end}:null}var Nu=e=>`[data-item-index="${e}"]`;function Pu(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??Nu;(0,L.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function Fu(){let e=(0,L.useRef)(null),[t,n]=(0,L.useState)(null);return(0,L.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function B(...e){return n(r(e))}var Iu=L.forwardRef(({className:e,type:t,...n},r)=>(0,R.jsx)(`input`,{type:t,className:B(`flex h-9 w-full rounded-xl border border-border bg-card px-3.5 py-2 text-sm text-foreground file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground/55 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Iu.displayName=`ChatInput`;var Lu=`2rem`;function Ru(e){return`min(${e}, max(0px, calc(var(--radix-popover-content-available-height, 100vh) - ${Lu})))`}var zu=Ru(`24rem`),Bu=jo,Vu=No,Hu=Mo,Uu=L.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,collisionPadding:r=12,style:i,...a},o)=>(0,R.jsx)(Po,{children:(0,R.jsx)(Fo,{ref:o,sideOffset:t,align:n,collisionPadding:r,className:B(`z-[var(--z-popover,50)] w-72 overflow-x-hidden overflow-y-auto rounded-2xl border border-border bg-popover p-4 text-popover-foreground shadow-lg 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=top]:slide-in-from-bottom-2 data-[side=right]:slide-in-from-left-2`,e),style:{maxHeight:zu,...i},...a})}));Uu.displayName=Fo.displayName;var Wu=Xn,Gu=Kn,Ku=Gn,qu=`2rem`;function Ju(e){return`min(${e}, max(0px, calc(var(--radix-select-content-available-height, 100vh) - ${qu})))`}var Yu=Ju(`24rem`),Xu=L.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(ur,{ref:r,className:B(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-border bg-card px-3 py-2 text-sm text-foreground shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,R.jsx)(Qn,{asChild:!0,children:(0,R.jsx)(Vn,{className:`h-4 w-4 opacity-50`})})]}));Xu.displayName=ur.displayName;var Zu=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Un,{ref:n,className:B(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(Hn,{className:`h-4 w-4`})}));Zu.displayName=Un.displayName;var Qu=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Yn,{ref:n,className:B(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(Vn,{className:`h-4 w-4`})}));Qu.displayName=Yn.displayName;var $u=L.forwardRef(({className:e,children:t,collisionPadding:n=12,position:r=`popper`,style:i,viewportClassName:a,...o},s)=>(0,R.jsx)($n,{children:(0,R.jsxs)(ir,{ref:s,className:B(`relative z-50 flex max-h-96 min-w-[8rem] flex-col overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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`,r===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),collisionPadding:n,position:r,style:{maxHeight:Yu,...i},...o,children:[(0,R.jsx)(Zu,{}),(0,R.jsx)(lr,{className:B(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-1`,r===`popper`&&`w-full min-w-[var(--radix-select-trigger-width)]`,a),children:t}),(0,R.jsx)(Qu,{})]})}));$u.displayName=ir.displayName;var ed=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(nr,{ref:n,className:B(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground`,e),...t}));ed.displayName=nr.displayName;var td=L.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(or,{ref:r,className:B(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-accent hover:text-accent-foreground`,e),...n,children:[(0,R.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,R.jsx)(qn,{children:(0,R.jsx)(cr,{className:`h-4 w-4`})})}),(0,R.jsx)(Jn,{children:t})]}));td.displayName=or.displayName;var nd=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(sr,{ref:n,className:B(`-mx-1 my-1 h-px bg-border`,e),...t}));nd.displayName=sr.displayName;var rd=Rn,id=Mn,ad=Pn,od=L.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,R.jsx)(In,{children:(0,R.jsx)(jn,{ref:r,sideOffset:t,className:B(`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`,e),...n})}));od.displayName=jn.displayName;var sd={Popover:Bu,PopoverAnchor:Hu,PopoverContent:Uu,PopoverTrigger:Vu,Input:Iu,Select:Wu,SelectContent:$u,SelectGroup:Gu,SelectItem:td,SelectLabel:ed,SelectSeparator:nd,SelectTrigger:Xu,SelectValue:Ku,Tooltip:id,TooltipContent:od,TooltipProvider:rd,TooltipTrigger:ad},cd=680,ld=.82,ud=560,dd=Ru(`24rem`),fd=Ru(`240px`);function pd(e,t){return!t.sectionKeys||t.sectionKeys.length===0?!0:!!(e.sectionKey&&t.sectionKeys.includes(e.sectionKey))}var md=(0,L.forwardRef)(function(e,t){let{Popover:n,PopoverAnchor:r,PopoverContent:i}=sd,{elementRef:a,width:o}=Fu(),s=(0,L.useRef)(null),[c,l]=(0,L.useState)({index:0,itemsSignature:``}),{isOpen:u,isLoading:d,filterOptions:f,items:p,texts:m,onSelectItem:h,onOpenChange:g,onDetailsPointerDown:_}=e,[v,y]=(0,L.useState)(f?.[0]?.key??null),b=(0,L.useMemo)(()=>f?.length?f.some(e=>e.key===v)?v:f[0].key:null,[v,f]),x=(0,L.useMemo)(()=>f?.find(e=>e.key===b)??null,[f,b]),S=(0,L.useMemo)(()=>f?.map(e=>({...e,count:p.filter(t=>pd(t,e)).length}))??[],[f,p]),C=(0,L.useMemo)(()=>x?p.filter(e=>pd(e,x)):p,[x,p]),w=(0,L.useMemo)(()=>C.map(e=>e.key).join(``),[C]),T=(0,L.useMemo)(()=>C.some(e=>!!e.sectionLabel?.trim()),[C]),E=c.itemsSignature===w?c.index:0,D=C.length===0?0:Math.min(E,C.length-1),O=C[D]??null,k=(0,L.useCallback)(e=>{y(e),l({index:0,itemsSignature:``})},[]),A=(0,L.useCallback)(e=>{l(t=>{let n=t.itemsSignature===w?t.index:0;return{index:typeof e==`function`?e(n):e,itemsSignature:w}})},[w]),ee=(0,L.useMemo)(()=>{if(o)return Math.min(o>ud?o*ld:o,cd)},[o]);return(0,L.useImperativeHandle)(t,()=>({handleKeyDown:e=>u?e.key===`Escape`?(e.preventDefault(),g(!1),!0):C.length===0?!1:e.key===`ArrowDown`?(e.preventDefault(),A(e=>(e+1)%C.length),!0):e.key===`ArrowUp`?(e.preventDefault(),A(e=>(e-1+C.length)%C.length),!0):e.key===`Enter`&&!e.shiftKey||e.key===`Tab`?(e.preventDefault(),h(C[D]),!0):!1:!1}),[D,u,g,h,A,C]),Pu({containerRef:s,activeIndex:D,itemCount:C.length,isEnabled:u&&!d,getItemSelector:e=>`[data-input-surface-index="${e}"]`}),(0,R.jsxs)(n,{open:u,onOpenChange:g,children:[(0,R.jsx)(r,{asChild:!0,children:(0,R.jsx)(`div`,{ref:a,className:`pointer-events-none absolute bottom-0 left-3 right-3 top-0`})}),(0,R.jsx)(i,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] flex max-w-[calc(100vw-1.5rem)] flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:{maxHeight:dd,width:ee?`${ee}px`:void 0},children:(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,style:{minHeight:fd},children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col border-r border-gray-200`,children:[!d&&S.length>0?(0,R.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto px-2.5 pb-2 pt-2.5`,children:S.map(({count:e,key:t,label:n})=>{let r=t===b;return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":r,onPointerDown:e=>e.preventDefault(),onClick:()=>k(t),className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-1 text-[11px] font-semibold transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${r?`border-primary/30 bg-primary/10 text-primary`:`border-gray-200 bg-white text-gray-600 hover:border-gray-300 hover:bg-gray-50`}`,children:[(0,R.jsx)(`span`,{children:n}),(0,R.jsx)(`span`,{className:r?`text-primary/70`:`text-gray-400`,children:e})]},t)})}):null,(0,R.jsx)(`div`,{ref:s,role:`listbox`,"aria-label":m.sectionLabel,className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain ${!d&&S.length>0?`px-2.5 pb-2.5`:`p-2.5`}`,children:d?(0,R.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:m.loadingLabel}):(0,R.jsxs)(R.Fragment,{children:[T?null:(0,R.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:m.sectionLabel}),C.length===0?(0,R.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:m.emptyLabel}):(0,R.jsx)(`div`,{className:`space-y-1`,children:C.map((e,t)=>{let{key:n,sectionKey:r,sectionLabel:i,title:a,subtitle:o}=e,s=t===D,c=C[t-1];return(0,R.jsxs)(`div`,{className:`space-y-1`,children:[T&&i?.trim()&&c?.sectionKey!==r?(0,R.jsx)(`div`,{className:`px-2 pb-0.5 pt-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:i}):null,(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":s,"data-input-surface-index":t,onPointerMove:e=>{e.pointerType!==`touch`&&A(t)},onPointerDown:t=>{t.button>0||(t.preventDefault(),h(e))},onClick:t=>{t.detail===0&&h(e)},className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${s?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:a}),(0,R.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:o})]})]},n)})})]})})]}),(0,R.jsx)(`div`,{className:`custom-scrollbar min-h-0 min-w-0 overflow-y-auto overscroll-contain p-2.5`,onPointerDown:_,children:O?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:O.subtitle}),(0,R.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:O.title})]}),(0,R.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:O.description}),(0,R.jsx)(`div`,{className:`space-y-1`,children:O.detailLines.map(e=>(0,R.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,R.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:O.hintLabel??m.itemHintLabel})]}):(0,R.jsx)(`div`,{className:`text-xs text-gray-500`,children:m.hintLabel})})]})})]})});function hd(e){return`${e.key}:${e.marker}:${e.start}`}function gd(e,t){return t.type===`insert-text`&&t.text===e.marker&&e.query===``&&e.end===e.start+e.marker.length}function _d(e,t,n){if(!t)return null;let r=hd(t);return e===r?e:gd(t,n)?r:null}function vd(e){let{children:t,inputSurface:n,onInputSurfaceTriggerChange:r,onSelectItem:i,triggerSpecs:a=[du]}=e,o=(0,L.useRef)(null),[s,c]=(0,L.useState)(null),l=!!n&&s!==null,u=(0,L.useCallback)((e,t)=>{c(e),r?.(e?t:null)},[r]),d=(0,L.useCallback)(()=>{u(null,null)},[u]),f=(0,L.useCallback)((e,t,n)=>{let r=ju(e,t,a),i=_d(s,r,n);u(i,i?r:null)},[s,u,a]),p=(0,L.useCallback)(e=>o.current?.handleKeyDown(e)??!1,[]),m=(0,L.useCallback)(e=>{e||d()},[d]);return(0,R.jsxs)(R.Fragment,{children:[t((0,L.useMemo)(()=>({onInputSurfaceKeyDown:p,onInputSurfaceOpenChange:m,onInputSurfaceSnapshotChange:f}),[p,m,f])),n&&l?(0,R.jsx)(md,{ref:o,isOpen:l,isLoading:n.isLoading,filterOptions:n.filterOptions,items:n.items,texts:n.texts,onSelectItem:e=>{d(),i(e)},onOpenChange:m,onDetailsPointerDown:e=>e.preventDefault()},s):null]})}var yd=Yt(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium transition-all duration-fast focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-border bg-card text-muted-foreground hover:bg-accent hover:text-accent-foreground`,secondary:`bg-muted text-foreground hover:bg-accent hover:text-accent-foreground`,ghost:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),bd=L.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,R.jsx)(`button`,{className:B(yd({variant:t,size:n,className:e})),ref:i,...r}));bd.displayName=`ChatButton`;var xd=120;function Sd(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=xd?t:`${t.slice(0,xd-1)}…`}function Cd(){return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-foreground shadow-[inset_0_0_0_1px_hsl(var(--border))]`})}function wd({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=sd,a=Math.max(0,Math.min(1,e.ratio)),o=Math.round(a*360);return(0,R.jsx)(r,{delayDuration:0,children:(0,R.jsxs)(t,{children:[(0,R.jsx)(i,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,"aria-label":e.label,title:e.label,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[7px] rounded-full`,style:{background:`conic-gradient(hsl(var(--muted-foreground)) ${o}deg, hsl(var(--border)) 0deg)`}}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[10px] rounded-full bg-card`})]})}),(0,R.jsx)(n,{side:`top`,className:`max-w-[18rem]`,children:(0,R.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-5 font-semibold text-foreground`,children:[(0,R.jsx)(`span`,{children:e.label}),(0,R.jsx)(`span`,{children:e.percentLabel})]}),e.details.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-5 text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:e.label}),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.value})]},e.label))]})})]})})}function Td({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,contextWindow:l,onSend:u,onStop:d}){let{Popover:f,PopoverContent:p,PopoverTrigger:m,Tooltip:h,TooltipContent:g,TooltipProvider:_,TooltipTrigger:v}=sd,y=e?.trim()??``,b=y?Sd(y):``,x=t?.trim()||`Details`;return(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[y?(0,R.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,R.jsx)(`span`,{className:`block truncate`,title:y,children:b})}),(0,R.jsxs)(f,{children:[(0,R.jsx)(m,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:x})}),(0,R.jsxs)(p,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,R.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:x}),(0,R.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:y})]})]})]}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,R.jsx)(wd,{contextWindow:l}):null,!n||!i?(0,R.jsx)(bd,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,R.jsx)(Yr,{className:`h-5 w-5`})}):r?(0,R.jsx)(bd,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,R.jsx)(Cd,{})}):(0,R.jsx)(_,{children:(0,R.jsxs)(h,{children:[(0,R.jsx)(v,{asChild:!0,children:(0,R.jsx)(`span`,{children:(0,R.jsx)(bd,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,R.jsx)(Cd,{})})})}),(0,R.jsx)(g,{side:`top`,children:(0,R.jsx)(`p`,{className:`text-xs`,children:o})})]})})]})]})}function Ed(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}var Dd=Ru(`24rem`);function Od(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=sd,{picker:a}=e,o=(0,L.useRef)(null),s=(0,L.useId)(),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(0),f=(0,L.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,L.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,L.useMemo)(()=>h?h.flatMap(e=>e.options):Ed(a.options,c),[h,a.options,c]);(0,L.useEffect)(()=>{d(0)},[c]),(0,L.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),Pu({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,R.jsxs)(n,{children:[(0,R.jsx)(i,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-label":a.title,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground sm:w-auto sm:gap-1.5 sm:px-3`,children:[(0,R.jsx)(k,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`nextclaw-chat-skill-picker-label hidden sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:a.title}),p>0?(0,R.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,R.jsxs)(r,{side:`top`,align:`start`,className:`flex w-[min(360px,calc(100vw-1rem))] flex-col overflow-hidden p-0`,style:{maxHeight:Dd},children:[(0,R.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:a.title}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground/70`}),(0,R.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,R.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:a.isLoading?(0,R.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:a.loadingLabel}):g.length===0?(0,R.jsx)(`div`,{className:`p-4 text-center text-xs text-muted-foreground`,children:a.emptyLabel}):(0,R.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,R.jsxs)(`div`,{children:[e.label?(0,R.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,R.jsxs)(`div`,{id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-accent`:`hover:bg-accent`}`,children:[(0,R.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,R.jsx)(ea,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 select-text`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm text-foreground`,children:e.label}),e.badgeLabel?(0,R.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,R.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:e.description||e.key})]}),(0,R.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`${r?`Remove`:`Add`} ${e.label}`,onClick:()=>_(e.key),className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-border bg-card`,children:r?(0,R.jsx)(cr,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,R.jsx)(`div`,{className:`shrink-0 border-t border-border px-4 py-2.5`,children:(0,R.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,R.jsx)(_r,{className:`h-3 w-3`})]})}):null]})]})}function kd({icon:e}){return e===`sparkles`?(0,R.jsx)(xr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,R.jsx)(Qr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):null}function Ad({icon:e}){return e===`paperclip`?(0,R.jsx)(Xi,{className:`h-4 w-4`}):(0,R.jsx)(kd,{icon:e})}var jd={model:`min-w-0 max-w-[18rem]`,"session-type":`shrink-0`,thinking:`shrink-0`},Md={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`},Nd=Ru(`18rem`),Pd=Ju(`18rem`);function Fd(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Id(e){return e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[])}function Ld({item:e}){let t=Fd(e);return e.selectedLabel?(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,R.jsx)(kd,{icon:e.icon}),(0,R.jsx)(`span`,{className:`nextclaw-chat-toolbar-mobile-label truncate sm:hidden [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:t}),(0,R.jsx)(`span`,{className:`nextclaw-chat-toolbar-label hidden truncate sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:e.selectedLabel})]}):e.loading?(0,R.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-muted`}):(0,R.jsx)(`span`,{className:`truncate`,children:e.placeholder})}function Rd({option:e}){return e.description?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.label}),(0,R.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:e.description})]}):(0,R.jsx)(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.label})}function zd({item:e}){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i,Tooltip:a,TooltipContent:o,TooltipProvider:s,TooltipTrigger:c}=sd,[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(``),p=Id(e),m=(0,L.useMemo)(()=>{let e=d.trim().toLowerCase();return e?p.map(t=>({...t,options:t.options.filter(t=>[t.label,t.value,t.description].filter(e=>!!e).some(t=>t.toLowerCase().includes(e)))})).filter(e=>e.options.length>0):p},[p,d]),h=p.some(e=>e.options.length>0),g=m.some(e=>e.options.length>0),_=e.optionAction,v=new Set(_?.activeValues??[]);return(0,R.jsxs)(n,{open:l,onOpenChange:u,children:[(0,R.jsx)(i,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":e.selectedLabel?`${e.placeholder}: ${e.selectedLabel}`:e.placeholder,disabled:e.disabled,className:`nextclaw-chat-toolbar-select-trigger inline-flex h-8 w-auto items-center justify-between rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-muted-foreground shadow-none hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-0 disabled:cursor-not-allowed disabled:opacity-50 sm:px-3 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!basis-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!justify-center [@container_nextclaw-chat-input-bar_(max-width:440px)]:!max-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!min-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!px-0 ${jd[e.key]??``}`,children:[(0,R.jsx)(Ld,{item:e}),(0,R.jsx)(Vn,{className:`ml-1 h-3.5 w-3.5 shrink-0 text-muted-foreground/70 [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`})]})}),(0,R.jsxs)(r,{className:`flex flex-col overflow-hidden p-2 ${Md[e.key]??``}`,style:{maxHeight:Nd},children:[(0,R.jsxs)(`div`,{className:`relative mb-2 shrink-0`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/70`}),(0,R.jsx)(t,{value:d,onChange:e=>f(e.currentTarget.value),placeholder:e.search?.placeholder??e.placeholder,className:`h-8 rounded-lg pl-8 text-xs`})]}),h?null:e.loading?(0,R.jsxs)(`div`,{className:`space-y-2 px-2 py-1`,children:[(0,R.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-muted`}),(0,R.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-muted`}),(0,R.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-muted`})]}):e.emptyLabel?(0,R.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:e.emptyLabel}):null,h&&!g?(0,R.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:e.search?.emptyLabel??e.emptyLabel}):null,(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:m.map((t,n)=>(0,R.jsxs)(`div`,{className:n>0?`border-t border-border pt-1`:void 0,children:[t.label?(0,R.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:t.label}):null,t.options.map(t=>{let n=e.value===t.value,r=v.has(t.value),i=r?_?.activeLabel:_?.inactiveLabel;return(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 rounded-md hover:bg-accent`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-2 text-left`,onClick:()=>{e.onValueChange(t.value),u(!1),f(``)},children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(Rd,{option:t})}),n?(0,R.jsx)(cr,{className:`h-4 w-4 shrink-0 text-primary`}):null]}),_&&i?(0,R.jsx)(s,{children:(0,R.jsxs)(a,{children:[(0,R.jsx)(c,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":i,"aria-pressed":r,className:`mr-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-card hover:text-foreground focus:outline-none focus:ring-1 focus:ring-primary/40`,onClick:e=>{e.stopPropagation(),_.onToggle(t.value,!r)},children:(0,R.jsx)(pa,{className:`h-3.5 w-3.5 ${r?`fill-current text-foreground`:``}`})})}),(0,R.jsx)(o,{side:`left`,children:(0,R.jsx)(`p`,{className:`text-xs`,children:i})})]})}):null]},t.value)})]},t.key))})]})]})}function Bd({item:e}){if(e.search)return(0,R.jsx)(zd,{item:e});let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=sd,l=Id(e),u=l.some(e=>e.options.length>0);return(0,R.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,R.jsx)(s,{"aria-label":e.selectedLabel?`${e.placeholder}: ${e.selectedLabel}`:e.placeholder,title:e.selectedLabel,className:`nextclaw-chat-toolbar-select-trigger h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-muted-foreground shadow-none hover:bg-accent hover:text-accent-foreground focus:ring-0 sm:px-3 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!basis-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!justify-center [@container_nextclaw-chat-input-bar_(max-width:440px)]:!max-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!min-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!px-0 ${jd[e.key]??``}`,children:e.selectedLabel||e.loading?(0,R.jsx)(Ld,{item:e}):(0,R.jsx)(c,{placeholder:e.placeholder})}),(0,R.jsxs)(n,{className:Md[e.key]??``,style:{maxHeight:Pd},children:[u?null:e.loading?(0,R.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-muted`}),(0,R.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-muted`}),(0,R.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-muted`})]}):e.emptyLabel?(0,R.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:e.emptyLabel}):null,l.map((e,t)=>(0,R.jsxs)(`div`,{children:[t>0?(0,R.jsx)(o,{}):null,(0,R.jsxs)(r,{children:[e.label?(0,R.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,R.jsx)(i,{value:e.value,className:`py-2`,children:(0,R.jsx)(Rd,{option:e})},e.value))]})]},e.key))]})]})}function Vd({actions:e,accessories:t,selects:n,skillPicker:r,trailingSelects:i=[]}){let{Tooltip:a,TooltipContent:o,TooltipProvider:s,TooltipTrigger:c}=sd;return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-3 pb-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-[12rem] flex-1 flex-wrap items-center gap-1 overflow-hidden`,children:[r?(0,R.jsx)(Od,{picker:r}):null,n.map(e=>(0,R.jsx)(Bd,{item:e},e.key)),t?.map(e=>{let t=(0,R.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/50 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,R.jsx)(Ad,{icon:e.icon}),e.iconOnly?null:(0,R.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,R.jsx)(s,{children:(0,R.jsxs)(a,{children:[(0,R.jsx)(c,{asChild:!0,children:e.disabled?(0,R.jsx)(`span`,{className:`inline-flex`,children:t}):t}),(0,R.jsx)(o,{side:`top`,children:(0,R.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,R.jsx)(`div`,{children:t},e.key)})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-end gap-1`,children:[i.length>0?(0,R.jsx)(`div`,{className:`nextclaw-chat-toolbar-trailing-selects flex min-w-0 items-center gap-1`,children:i.map(e=>(0,R.jsx)(Bd,{item:e},e.key))}):null,(0,R.jsx)(Td,{...e})]})]})}var Hd=(0,L.createContext)(null);function Ud(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Wd(){let e=(0,L.useContext)(Hd);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function V(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Gd(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Kd=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,qd=Kd&&`documentMode`in document?document.documentMode:null,Jd=Kd&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Yd=Kd&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Xd=!(!Kd||!(`InputEvent`in window)||qd)&&`getTargetRanges`in new window.InputEvent(`input`),Zd=Kd&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Qd=Kd&&/Android/.test(navigator.userAgent),$d=Kd&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Qd,ef=Kd&&/^(?=.*Chrome).*/i.test(navigator.userAgent),tf=Kd&&Qd&&ef,nf=Kd&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Jd&&!ef,rf=0,af=1,of=2,sf=1,cf=2,lf=3,uf=4,df=5,ff=6,pf=$d||Zd||nf?`\xA0`:`​`,mf=`
3
+
4
+ `,hf=Yd?`\xA0`:pf,gf={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},_f={directionless:1,unmergeable:2},vf={center:2,end:6,justify:4,left:1,right:3,start:5},yf={[cf]:`center`,[ff]:`end`,[uf]:`justify`,[sf]:`left`,[lf]:`right`,[df]:`start`},bf={normal:0,segmented:2,token:1},xf={[rf]:`normal`,[of]:`segmented`,[af]:`token`},Sf=`$config`;function Cf(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(K(o)&&Cf(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var wf=!1,Tf=0;function Ef(e){Tf=e.timeStamp}function Df(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&w_(e,n)!==void 0}function Of(e,t,n){let r=pv(av(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&L_(t,o,i,a,!1)}function kf(e,t,n){if(W(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return p_(t)&&n.isAttached()}function Af(e,t,n,r){for(let i=e;i&&!Ov(i);i=$_(i)){let e=w_(i,t);if(e!==void 0){let t=S_(e,n);if(t)return Pg(t)||!hv(i)?void 0:[i,t]}else if(i===r)return[r,k_(n)]}}function jf(e,t,n){wf=!0;let r=performance.now()-Tf>100;try{Og(e,()=>{let i=G()||function(e){return e.getEditorState().read(()=>{let e=G();return e===null?null:e.clone()})}(e),a=new Map,o=e.getRootElement(),s=e._editorState,c=e._blockCursorElement,l=!1,u=``;for(let n=0;n<t.length;n++){let d=t[n],f=d.type,p=d.target,m=Af(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&U(g)&&p_(p)&&kf(i,p,g)&&Of(p,g,e);else if(f===`childList`){l=!0;let t=d.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=C_(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!Df(r,a,e)){if(Yd){let e=(hv(r)?r.innerText:null)||r.nodeValue;e&&(u+=e)}a.removeChild(r)}}let n=d.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(Df(r,p,e)||c===r)&&(p.appendChild(r),t++)}r!==t&&a.set(h,g)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let d=n.takeRecords();if(d.length>0){for(let t=0;t<d.length;t++){let n=d[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||Df(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&A_(i),Yd&&Z_(e)&&i.insertRawText(u))})}finally{wf=!1}}function Mf(e){let t=e._observer;t!==null&&jf(e,t.takeRecords(),t)}function Nf(e){(function(e){Tf===0&&av(e).addEventListener(`textInput`,Ef,!0)})(e),e._observer=new MutationObserver((t,n)=>{jf(e,t,n)})}var Pf=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Vf).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Ff(e,t){return new Pf(e,t)}function If(e){let t=new Map,n=new Set;for(let r=typeof e==`function`?e:e.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){let{ownNodeConfig:e}=Av(r);if(e&&e.stateConfigs)for(let r of e.stateConfigs){let e;`stateConfig`in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}var Lf=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState;this.size=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return Bf(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=Bf(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function Rf(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Lf(t,zf(t));return t.__state=n,n}function zf(e){return e.__state?e.__state.sharedNodeState:n_(xv(),e.getType()).sharedNodeState}function Bf(e){if(e)for(let t in e)return e}function Vf(e){return e}function Hf(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function Uf(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function Wf(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Gf(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&Hf(n,e,t)||t&&Hf(n,t,e)||e&&Uf(n,e,t)||t&&Uf(n,t,e))}(c,l))}function Kf(e,t){let n=e.mergeWithSibling(t),r=hg()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function qf(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&U(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Gf(t,r)){r=Kf(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&U(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Gf(r,n)){r=Kf(r,n);break}break}n.remove()}}else r.remove()}function Jf(e){return Yf(e.anchor),Yf(e.focus),e}function Yf(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),U(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!K(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var Xf,Zf,Qf,$f,ep,tp,np,rp,ip,ap,op=``,sp=null,cp=null,lp=!1,up=!1;function dp(e,t){let n=np.get(e);if(t!==null){let n=kp(e);n.parentNode===t&&t.removeChild(n)}if(rp.has(e)||Zf._keyToDOMMap.delete(e),K(n)){let e=Cp(n,np);fp(e,0,e.length-1,null)}n!==void 0&&J_(ap,Qf,$f,n,`destroyed`)}function fp(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&dp(t,r)}}function pp(e,t){e.setProperty(`text-align`,t)}var mp=`40px`;function hp(e,t){let n=Xf.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}if(t===0)return void e.style.setProperty(`padding-inline-start`,``);let r=getComputedStyle(Zf._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||mp;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function gp(e,t){let n=e.style;t===0?pp(n,``):t===1?pp(n,`left`):t===2?pp(n,`center`):t===3?pp(n,`right`):t===4?pp(n,`justify`):t===5?pp(n,`start`):t===6&&pp(n,`end`)}function _p(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Ig(e))return null;let n=e.getParentOrThrow();return Ig(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function vp(e,t){let n=rp.get(e);n===void 0&&V(60);let r=n.createDOM(Xf,Zf);if(function(e,t,n){let r=n._keyToDOMMap;(function(e,t,n){let r=`__lexicalKey_${t._key}`;e[r]=n})(t,n,e),r.set(e,t)}(e,r,Zf),U(n)?r.setAttribute(`data-lexical-text`,`true`):Pg(n)&&r.setAttribute(`data-lexical-decorator`,`true`),K(n)){let e=n.__indent,t=n.__size;if(_p(r,n),e!==0&&hp(r,e),t!==0){let e=t-1;yp(Cp(n,rp),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&gp(r,i),n.isInline()||xp(null,n,r)}else{let t=n.getTextContent();if(Pg(n)){let t=n.decorate(Zf,Xf);t!==null&&Tp(e,t),r.contentEditable=`false`}op+=t}return t!==null&&t.insertChild(r),J_(ap,Qf,$f,n,`created`),r}function yp(e,t,n,r,i){let a=op;op=``;let o=n;for(;o<=r;++o){vp(e[o],i);let t=rp.get(e[o]);t!==null&&U(t)?sp===null&&(sp=t.getFormat(),cp=t.getStyle()):K(t)&&o<r&&!t.isInline()&&(op+=mf)}i.element.__lexicalTextContent=op,op=a+op}function bp(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return oh(e)?`line-break`:Pg(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function xp(e,t,n){let r=bp(e,np),i=bp(t,rp);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function Sp(e,t,n){var r;sp=null,cp=null,function(e,t,n){let r=op,i=e.__size,a=t.__size;op=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)wp(n,o);else{let e=kp(n),t=vp(r,null);try{o.replaceChild(t,e)}catch(i){if(typeof i==`object`&&i){let a=`${i.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw Error(a)}throw i}dp(n,null)}let i=rp.get(r);U(i)&&sp===null&&(sp=i.getFormat(),cp=i.getStyle())}else{let r=Cp(e,np),s=Cp(t,rp);if(r.length!==i&&V(227),s.length!==a&&V(228),i===0)a!==0&&yp(s,0,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&n.element.__lexicalLineBreak==null;fp(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else (function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f];if(e===r)u=Ep(wp(r,a.element)),d++,f++;else{if(l===void 0&&(l=Dp(n,f)),c===void 0)c=Dp(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=Ep(kp(e)),dp(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=Q_(Zf,r);e!==u&&a.withBefore(u).insertChild(e),u=Ep(wp(r,a.element)),d++,f++}else vp(r,a.withBefore(u)),f++}let i=rp.get(r);i!==null&&U(i)?sp===null&&(sp=i.getFormat(),cp=i.getStyle()):K(i)&&f<=s&&!i.isInline()&&(op+=mf)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:Zf.getElementByKey(e);yp(n,0,f,s,a.withBefore(t))}else m&&!p&&fp(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=op,op=r+op}(e,t,t.getDOMSlot(n)),r=t,sp==null||sp===r.__textFormat||up||r.setTextFormat(sp),function(e){cp==null||cp===e.__textStyle||up||e.setTextStyle(cp)}(t)}function Cp(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t.get(r);e===void 0&&V(101),n.push(r),r=e.__next}return n}function wp(e,t){let n=np.get(e),r=rp.get(e);n!==void 0&&r!==void 0||V(61);let i=lp||tp.has(e)||ep.has(e),a=Q_(Zf,e);if(n===r&&!i){let e;if(K(n)){let t=a.__lexicalTextContent;typeof t==`string`?e=t:(e=n.getTextContent(),a.__lexicalTextContent=e)}else e=n.getTextContent();return op+=e,a}if(n!==r&&i&&J_(ap,Qf,$f,r,`updated`),r.updateDOM(n,a,Xf)){let n=vp(e,null);return t===null&&V(62),t.replaceChild(n,a),dp(e,null),n}if(K(n)){K(r)||V(334,e);let t=r.__indent;(lp||t!==n.__indent)&&hp(a,t);let o=r.__format;if((lp||o!==n.__format)&&gp(a,o),i)Sp(n,r,a),Ig(r)||r.isInline()||xp(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),op+=t}if((lp||r.__dir!==n.__dir)&&(_p(a,r),Ig(r)&&!lp))for(let e of r.getChildren())K(e)&&_p(Q_(Zf,e.getKey()),e)}else{let t=r.getTextContent();if(Pg(r)){let t=r.decorate(Zf,Xf);t!==null&&Tp(e,t)}op+=t}if(!up&&Ig(r)&&r.__cachedText!==op){let e=r.getWritable();e.__cachedText=op,r=e}return a}function Tp(e,t){let n=Zf._pendingDecorators,r=Zf._decorators;if(n===null){if(r[e]===t)return;n=E_(Zf)}n[e]=t}function Ep(e){let t=e.nextSibling;return t!==null&&t===Zf._blockCursorElement&&(t=t.nextSibling),t}function Dp(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Op(e,t,n,r,i,a){op=``,lp=r===2,Zf=n,Xf=n._config,Qf=n._nodes,$f=Zf._listeners.mutation,ep=i,tp=a,np=e._nodeMap,rp=t._nodeMap,up=t._readOnly,ip=new Map(n._keyToDOMMap);let o=new Map;return ap=o,wp(`root`,null),Zf=void 0,Qf=void 0,ep=void 0,tp=void 0,np=void 0,rp=void 0,Xf=void 0,ip=void 0,ap=void 0,o}function kp(e){let t=ip.get(e);return t===void 0&&V(75,e),t}function H(e){return{type:e}}var Ap=H(`SELECTION_CHANGE_COMMAND`),jp=H(`CLICK_COMMAND`),Mp=H(`BEFORE_INPUT_COMMAND`),Np=H(`INPUT_COMMAND`),Pp=H(`COMPOSITION_START_COMMAND`),Fp=H(`COMPOSITION_END_COMMAND`),Ip=H(`DELETE_CHARACTER_COMMAND`),Lp=H(`INSERT_LINE_BREAK_COMMAND`),Rp=H(`INSERT_PARAGRAPH_COMMAND`),zp=H(`CONTROLLED_TEXT_INSERTION_COMMAND`),Bp=H(`PASTE_COMMAND`),Vp=H(`REMOVE_TEXT_COMMAND`),Hp=H(`DELETE_WORD_COMMAND`),Up=H(`DELETE_LINE_COMMAND`),Wp=H(`FORMAT_TEXT_COMMAND`),Gp=H(`UNDO_COMMAND`),Kp=H(`REDO_COMMAND`),qp=H(`KEYDOWN_COMMAND`),Jp=H(`KEY_ARROW_RIGHT_COMMAND`),Yp=H(`MOVE_TO_END`),Xp=H(`KEY_ARROW_LEFT_COMMAND`),Zp=H(`MOVE_TO_START`),Qp=H(`KEY_ARROW_UP_COMMAND`),$p=H(`KEY_ARROW_DOWN_COMMAND`),em=H(`KEY_ENTER_COMMAND`),tm=H(`KEY_SPACE_COMMAND`),nm=H(`KEY_BACKSPACE_COMMAND`),rm=H(`KEY_ESCAPE_COMMAND`),im=H(`KEY_DELETE_COMMAND`),am=H(`KEY_TAB_COMMAND`),om=H(`DROP_COMMAND`),sm=H(`DRAGSTART_COMMAND`),cm=H(`DRAGOVER_COMMAND`),lm=H(`DRAGEND_COMMAND`),um=H(`COPY_COMMAND`),dm=H(`CUT_COMMAND`),fm=H(`SELECT_ALL_COMMAND`),pm=H(`FOCUS_COMMAND`),mm=H(`BLUR_COMMAND`),hm=H(`KEY_MODIFIER_COMMAND`),gm=Object.freeze({}),_m=[[`keydown`,function(e,t){vm=e.timeStamp,ym=e.key,!t.isComposing()&&q(t,qp,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;gv(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Og(t,()=>{a_(n)||(Tm=!0)})}],[`compositionstart`,function(e,t){q(t,Pp,e)}],[`compositionend`,function(e,t){Yd?Dm=!0:Zd||!$d&&!nf?q(t,Fp,e):(Om=!0,km=e.data)}],[`input`,function(e,t){e.stopPropagation(),Og(t,()=>{t.dispatchCommand(Np,e)},{event:e}),xm=null}],[`click`,function(e,t){Og(t,()=>{let n=G(),r=pv(av(t)),i=Jh();if(r){if(W(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!Ig(a)&&O_().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(e.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){let e=Mv(a,e=>K(e)&&!e.isInline());K(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(hv(n)||p_(n))&&A_(qh(i,r,t,e))}}q(t,jp,e)})}],[`cut`,gm],[`copy`,gm],[`dragstart`,gm],[`dragover`,gm],[`dragend`,gm],[`paste`,gm],[`focus`,gm],[`blur`,gm],[`drop`,gm]];Xd&&_m.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||Yd&&Z_(t)||n!==`insertCompositionText`&&q(t,Mp,e)}(e,t)]);var vm=0,ym=null,bm=0,xm=null,Sm=new WeakMap,Cm=new WeakMap,wm=!1,Tm=!1,Em=!1,Dm=!1,Om=!1,km=``,Am=null,jm=[0,``,0,`root`,0];function Mm(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=hg(),l=pv(av(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!U(s)||(!i&&(!Xd||bm<r+50)||s.isDirty()&&p<2||M_(n))&&a.offset!==o.offset&&!s.isComposing()||f_(s)||s.isDirty()&&p>1||(i||!Xd)&&f!==null&&!s.isComposing()&&u!==h_(f)||l!==null&&t!==null&&(!t.collapsed||t.startContainer!==l.anchorNode||t.startOffset!==l.anchorOffset)||!s.isComposing()&&(s.getFormat()!==e.format||s.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=d_(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(U(t)||K(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,s)}function Nm(e,t){return p_(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function Pm(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;wm&&(wm=!1,Nm(r,i)&&Nm(a,o)&&!Am)||Og(t,()=>{if(!n)return void A_(null);if(!s_(t,r,a))return;let s=G();if(Am&&W(s)&&s.isCollapsed()){let e=s.anchor,t=Am.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=Am.clone(),A_(s))}if(Am=null,W(s)){let n=s.anchor,r=n.getNode();if(s.isCollapsed()){e.type===`Range`&&e.anchorNode===e.focusNode&&(s.dirty=!0);let i=av(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=jm,f=O_(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)Fm(s,o,c);else if(n.type===`text`)U(r)||V(141),Im(s,r);else if(n.type===`element`&&!p){K(r)||V(259);let e=n.getNode();e.isEmpty()?function(e,t){Fm(e,t.getTextFormat(),t.getTextStyle())}(s,e):Fm(s,s.format,``)}}else{let e=n.key,t=s.focus.key,r=s.getNodes(),a=r.length,c=s.isBackward(),l=c?o:i,u=c?i:o,d=c?t:e,f=c?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(U(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}s.format=m?p:0}}q(t,Ap,void 0)})}function Fm(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Im(e,t){Fm(e,t.getFormat(),t.getStyle())}function Lm(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Rm(e){let t=e.inputType,n=Lm(e),r=hg(),i=G();if(t===`deleteContentBackward`){if(i===null){let e=Jh();if(!W(e))return!0;A_(e.clone())}if(W(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,ym===`MediaLast`&&a<vm+30&&r.isComposing()&&t){if(b_(null),vm=0,setTimeout(()=>{Og(r,()=>{b_(null)})},30),W(i)){let e=i.anchor.getNode();e.markDirty(),U(e)||V(142),Im(i,e)}}else{b_(null),e.preventDefault();let n=i.anchor.getNode(),a=n.getTextContent(),o=n.canInsertTextAfter(),s=i.anchor.offset===0&&i.focus.offset===a.length,c=tf&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!Pg(X_(i.anchor,!0))),!c){q(r,Ip,!0);let e=G();tf&&W(e)&&e.isCollapsed()&&(Am=e,setTimeout(()=>Am=null))}}return!0}}var a;if(!W(i))return!0;let o=e.data;xm!==null&&I_(!1,r,xm),i.dirty&&xm===null||!i.isCollapsed()||Ig(i.anchor.getNode())||n===null||i.applyDOMRange(n),xm=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
5
+ `)e.preventDefault(),q(r,Lp,!1);else if(o===mf)e.preventDefault(),q(r,Rp,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&Mm(i,n,o,e.timeStamp,!0)?(e.preventDefault(),q(r,zp,o)):xm=o;return bm=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:q(r,zp,e);break;case`insertFromComposition`:b_(null),q(r,zp,e);break;case`insertLineBreak`:b_(null),q(r,Lp,!1);break;case`insertParagraph`:b_(null),Em&&!Zd?(Em=!1,q(r,Lp,!1)):q(r,Rp,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:q(r,Bp,e);break;case`deleteByComposition`:(function(e,t){return e!==t||K(e)||K(t)||!d_(e)||!d_(t)})(l,u)&&q(r,Vp,e);break;case`deleteByDrag`:case`deleteByCut`:q(r,Vp,e);break;case`deleteContent`:q(r,Ip,!1);break;case`deleteWordBackward`:q(r,Hp,!0);break;case`deleteWordForward`:q(r,Hp,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:q(r,Up,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:q(r,Up,!1);break;case`formatStrikeThrough`:q(r,Wp,`strikethrough`);break;case`formatBold`:q(r,Wp,`bold`);break;case`formatItalic`:q(r,Wp,`italic`);break;case`formatUnderline`:q(r,Wp,`underline`);break;case`historyUndo`:q(r,Gp,void 0);break;case`historyRedo`:q(r,Kp,void 0)}return!0}function zm(e){if(hv(e.target)&&a_(e.target))return!0;let t=hg(),n=G(),r=e.data,i=Lm(e);if(r!=null&&W(n)&&Mm(n,i,r,e.timeStamp,!1)){Dm&&=(Hm(t,r),!1);let i=n.anchor.getNode(),a=pv(av(t));if(a===null)return!0;let o=n.isBackward(),s=o?n.anchor.offset:n.focus.offset,c=o?n.focus.offset:n.anchor.offset;Xd&&!n.isCollapsed()&&U(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===F_(a.anchorNode)||q(t,zp,r);let l=r.length;Yd&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),tf&&t.isComposing()&&(vm=0,b_(null))}else I_(!1,t,r===null?void 0:r),Dm&&=(Hm(t,r||void 0),!1);return function(){fg(),Mf(hg())}(),!0}function Bm(e){let t=hg(),n=G();if(W(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();b_(r.key),tv(th),(e.timeStamp<vm+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||U(i)&&i.getStyle()!==n.style)&&q(t,zp,hf)}return!0}function Vm(e){return Hm(hg(),e.data),tv(nh),!0}function Hm(e,t){let n=e._compositionKey;if(b_(null),n!==null&&t!=null){if(t===``){let t=S_(n),r=h_(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&U(t)){let n=pv(av(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),L_(t,r.nodeValue,i,a,!0)}return}if(t[t.length-1]===`
6
+ `){let t=G();if(W(t)||Ph(t)){if(W(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}q(e,em,null);return}}}I_(!0,e,t)}function Um(e){let t=hg();if(e.key==null)return!0;if(Om){if(W_(e))return Og(t,()=>{Hm(t,km)}),Om=!1,km=``,!0;Om=!1,km=``}if(function(e){return V_(e,`ArrowRight`,{shiftKey:`any`})}(e))q(t,Jp,e);else if(function(e){return V_(e,`ArrowRight`,H_)}(e))q(t,Yp,e);else if(function(e){return V_(e,`ArrowLeft`,{shiftKey:`any`})}(e))q(t,Xp,e);else if(function(e){return V_(e,`ArrowLeft`,H_)}(e))q(t,Zp,e);else if(function(e){return V_(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))q(t,Qp,e);else if(function(e){return V_(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))q(t,$p,e);else if(function(e){return V_(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))Em=!0,q(t,em,e);else if(function(e){return e.key===` `}(e))q(t,tm,e);else if(function(e){return Jd&&V_(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),Em=!0,q(t,Lp,!0);else if(function(e){return V_(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))Em=!1,q(t,em,e);else if(function(e){return V_(e,`Backspace`,{shiftKey:`any`})||Jd&&V_(e,`h`,{ctrlKey:!0})}(e))W_(e)?q(t,nm,e):(e.preventDefault(),q(t,Ip,!0));else if(function(e){return e.key===`Escape`}(e))q(t,rm,e);else if(function(e){return V_(e,`Delete`,{})||Jd&&V_(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?q(t,im,e):(e.preventDefault(),q(t,Ip,!1));else if(function(e){return V_(e,`Backspace`,U_)}(e))e.preventDefault(),q(t,Hp,!0);else if(function(e){return V_(e,`Delete`,U_)}(e))e.preventDefault(),q(t,Hp,!1);else if(function(e){return Jd&&V_(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),q(t,Up,!0);else if(function(e){return Jd&&(V_(e,`Delete`,{metaKey:!0})||V_(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),q(t,Up,!1);else if(function(e){return V_(e,`b`,H_)}(e))e.preventDefault(),q(t,Wp,`bold`);else if(function(e){return V_(e,`u`,H_)}(e))e.preventDefault(),q(t,Wp,`underline`);else if(function(e){return V_(e,`i`,H_)}(e))e.preventDefault(),q(t,Wp,`italic`);else if(function(e){return V_(e,`Tab`,{shiftKey:`any`})}(e))q(t,am,e);else if(function(e){return V_(e,`z`,H_)}(e))e.preventDefault(),q(t,Gp,void 0);else if(function(e){return Jd?V_(e,`z`,{metaKey:!0,shiftKey:!0}):V_(e,`y`,{ctrlKey:!0})||V_(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),q(t,Kp,void 0);else{let n=t._editorState._selection;n===null||W(n)?G_(e)&&(e.preventDefault(),q(t,fm,e)):function(e){return V_(e,`c`,H_)}(e)?(e.preventDefault(),q(t,um,e)):function(e){return V_(e,`x`,H_)}(e)?(e.preventDefault(),q(t,dm,e)):G_(e)&&(e.preventDefault(),q(t,fm,e))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(hm,e),!0}function Wm(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}var Gm=new Map;function Km(e){let t=mv(e.target);if(t===null)return;let n=l_(t.anchorNode);if(n===null)return;Tm&&(Tm=!1,Og(n,()=>{let r=Jh(),i=t.anchorNode;(hv(i)||p_(i))&&A_(qh(r,t,n,e))}));let r=N_(n),i=r[r.length-1],a=i._key,o=Gm.get(a),s=o||i;s!==n&&Pm(t,s,!1),Pm(t,n,!0),n===i?o&&Gm.delete(a):Gm.set(a,n)}function qm(e){e._lexicalHandled=!0}function Jm(e){return!0===e._lexicalHandled}function Ym(e){let t=Sm.get(e);if(t===void 0)return;let n=Cm.get(t);if(n===void 0)return;let r=n-1;r>=0||V(164),Sm.delete(e),Cm.set(t,r),r===0&&t.removeEventListener(`selectionchange`,Km);let i=u_(e);c_(i)?(function(e){if(e._parentEditor!==null){let t=N_(e),n=t[t.length-1]._key;Gm.get(n)===e&&Gm.delete(n)}else Gm.delete(e._key)}(i),e.__lexicalEditor=null):i&&V(198);let a=Wm(e);for(let e=0;e<a.length;e++)a[e]();e.__lexicalEventHandles=[]}function Xm(e,t,n){fg();let r=e.__key,i=e.getParent();if(i===null)return;let a=function(e){let t=G();if(!W(t)||!K(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return rv(i,e)&&n.set(e.__key,0,`element`),rv(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(W(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Zh(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Zh(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else Ph(a)&&t&&e.isSelected()&&e.selectPrevious();if(W(a)&&t&&!o){let t=e.getIndexWithinParent();v_(e),Yh(a,i,t,-1)}else v_(e);n||sv(i)||i.canBeEmpty()||!i.isEmpty()||Xm(i,t),t&&a&&Ig(i)&&i.isEmpty()&&i.selectEnd()}var Zm=Symbol.for(`ephemeral`);function Qm(e){return e[Zm]||!1}var $m=class{__type;__key;__parent;__prev;__next;__state;static getType(){let{ownNodeType:e}=Av(this);return e===void 0&&V(64,this.name),e}static clone(e){V(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||Object.getPrototypeOf(this.constructor);return Object.assign(t,{extends:n,type:e}),{[e]:t}}afterCloneFrom(e){this.__key===e.__key?(this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev,this.__state=e.__state):e.__state&&(this.__state=e.__state.getWritable(this))}resetOnCopyNodeFrom(e){this.__state&&=this.__state.getWritable(this).resetOnCopyNode()}static importDOM;constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,`__state`,{configurable:!0,enumerable:!1,value:void 0,writable:!0}),__(this,e)}getType(){return this.__type}isInline(){V(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=S_(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){let t=e||G();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(U(this))return n;if(W(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(Pg(this)&&this.isInline()&&e){let n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:S_(e)}getParentOrThrow(){let e=this.getParent();return e===null&&V(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(sv(t))return K(e)||e===this&&Pg(e)||V(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&V(67,this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:S_(e)}getPreviousSiblings(){let e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){let e=this.getLatest().__next;return e===null?null:S_(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=K(this)?this:this.getParent(),n=K(e)?e:e.getParent(),r=t&&n?uy(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=uy(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?sy(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&V(279),!1)))}isParentOf(e){let t=uy(this,e);return t!==null&&t.type===`ancestor`}getNodesBetween(e){let t=this.isBefore(e),n=[],r=new Set,i=this;for(;i!==null;){let a=i.__key;if(r.has(a)||(r.add(a),n.push(i)),i===e)break;let o=K(i)?t?i.getFirstChild():i.getLastChild():null;if(o!==null){i=o;continue}let s=t?i.getNextSibling():i.getPreviousSibling();if(s!==null){i=s;continue}let c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===e)break;let l=null,u=c;do{if(u===null&&V(68),l=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),u===null)break;l!==null||r.has(u.__key)||n.push(u)}while(l===null);i=l}return t||n.reverse(),n}isDirty(){let e=hg()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(Qm(this))return this;let e=S_(this.__key);return e===null&&V(113),e}getWritable(){if(Qm(this))return this;fg();let e=mg(),t=hg(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=G();if(o!==null&&o.setCachedNodes(null),a.has(r))return y_(i),i;let s=Tv(i);return a.add(r),y_(s),n.set(r,s),s}getTextContent(){return``}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){V(70)}updateDOM(e,t,n){V(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){let e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){V(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of zf(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&Rf(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){Xm(this,!0,e)}replace(e,t){fg();let n=G();n!==null&&(n=n.clone()),lv(this,e);let r=this.getLatest(),i=this.__key,a=e.__key,o=e.getWritable(),s=this.getParentOrThrow().getWritable(),c=s.__size;v_(o);let l=r.getPreviousSibling(),u=r.getNextSibling(),d=r.__prev,f=r.__next,p=r.__parent;if(Xm(r,!1,!0),l===null?s.__first=a:l.getWritable().__next=a,o.__prev=d,u===null?s.__last=a:u.getWritable().__prev=a,o.__next=f,o.__parent=p,s.__size=c,t&&(K(this)&&K(o)||V(139),this.getChildren().forEach(e=>{o.append(e)})),W(n)){A_(n);let e=n.anchor,t=n.focus;e.key===i&&jh(e,o),t.key===i&&jh(t,o)}return x_()===i&&b_(a),o}insertAfter(e,t=!0){fg(),lv(this,e);let n=this.getWritable(),r=e.getWritable(),i=r.getParent(),a=G(),o=!1,s=!1;if(i!==null){let t=e.getIndexWithinParent();if(v_(r),W(a)){let e=i.__key,n=a.anchor,r=a.focus;o=n.type===`element`&&n.key===e&&n.offset===t+1,s=r.type===`element`&&r.key===e&&r.offset===t+1}}let c=this.getNextSibling(),l=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(c===null?l.__last=u:c.getWritable().__prev=u,l.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&W(a)){let e=this.getIndexWithinParent();Yh(a,l,e+1);let t=l.__key;o&&a.anchor.set(t,e+2,`element`),s&&a.focus.set(t,e+2,`element`)}return e}insertBefore(e,t=!0){fg(),lv(this,e);let n=this.getWritable(),r=e.getWritable(),i=r.__key;v_(r);let a=this.getPreviousSibling(),o=this.getParentOrThrow().getWritable(),s=n.__prev,c=this.getIndexWithinParent();a===null?o.__first=i:a.getWritable().__next=i,o.__size++,n.__prev=i,r.__prev=s,r.__next=n.__key,r.__parent=n.__parent;let l=G();return t&&W(l)&&Yh(l,this.getParentOrThrow(),c),e}isParentRequired(){return!1}createParentElementNode(){return Gg()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){fg();let n=this.getPreviousSibling(),r=this.getParentOrThrow();if(n===null)return r.select(0,0);if(K(n))return n.select();if(!U(n)){let e=n.getIndexWithinParent()+1;return r.select(e,e)}return n.select(e,t)}selectNext(e,t){fg();let n=this.getNextSibling(),r=this.getParentOrThrow();if(n===null)return r.select();if(K(n))return n.select(0,0);if(!U(n)){let e=n.getIndexWithinParent();return r.select(e,e)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}},eh=`history-merge`,th=`composition-start`,nh=`composition-end`,rh=class e extends $m{static getType(){return`linebreak`}static clone(t){return new e(t.__key)}constructor(e){super(e)}getTextContent(){return`
7
+ `}createDOM(){return document.createElement(`br`)}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:e=>function(e){let t=e.parentElement;if(t!==null&&yv(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&sh(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&sh(n))return!0}}return!1}(e)||function(e){let t=e.parentElement;if(t!==null&&yv(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&sh(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&sh(r))return!0}return!1}(e)?null:{conversion:ih,priority:0}}}static importJSON(e){return ah().updateFromJSON(e)}};function ih(e){return{node:ah()}}function ah(){return cv(new rh)}function oh(e){return e instanceof rh}function sh(e){return p_(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}function ch(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function lh(e,t){return 1&t?`strong`:2&t?`em`:`span`}function uh(e,t,n,r,i){let a=r.classList,o=q_(i,`base`);o!==void 0&&a.add(...o),o=q_(i,`underlineStrikethrough`);let s=!1,c=8&t&&4&t;o!==void 0&&(8&n&&4&n?(s=!0,c||a.add(...o)):c&&a.remove(...o));for(let e in gf){let r=gf[e];if(o=q_(i,e),o!==void 0)if(n&r){if(s&&(e===`underline`||e===`strikethrough`)){t&r&&a.remove(...o);continue}((t&r)===0||c&&e===`underline`||e===`strikethrough`)&&a.add(...o)}else t&r&&a.remove(...o)}}function dh(e,t,n){let r=t.firstChild,i=n.isComposing(),a=e+(i?pf:``);if(r==null)t.textContent=a;else{let e=r.nodeValue;if(e!==a)if(i||Yd){let[t,n,i]=function(e,t){let n=e.length,r=t.length,i=0,a=0;for(;i<n&&i<r&&e[i]===t[i];)i++;for(;a+i<n&&a+i<r&&e[n-a-1]===t[r-a-1];)a++;return[i,n-i-a,t.slice(i,r-a)]}(e,a);n!==0&&r.deleteData(t,n),r.insertData(t,i)}else r.nodeValue=a}}function fh(e,t,n,r,i,a){dh(i,e,t);let o=a.theme.text;o!==void 0&&uh(0,0,r,e,o)}function ph(e,t){let n=document.createElement(t);return n.appendChild(e),n}var mh=class e extends $m{__text;__format;__style;__mode;__detail;static getType(){return`text`}static clone(t){return new e(t.__text,t.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text,this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e=``,t){super(t),this.__text=e,this.__format=0,this.__style=``,this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){return xf[this.getLatest().__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===x_()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=gf[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return g_(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=ch(0,n),i=lh(0,n),a=r===null?i:r,o=document.createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=document.createElement(i),o.appendChild(s)),fh(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&(o.style.cssText=c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=ch(0,i),s=ch(0,a),c=lh(0,i),l=lh(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??V(48);let i=document.createElement(l);return fh(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??V(49)),dh(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&uh(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&(t.style.cssText=p),!1}static importDOM(){return{"#text":()=>({conversion:yh,priority:0}),b:()=>({conversion:gh,priority:0}),code:()=>({conversion:Sh,priority:0}),em:()=>({conversion:Sh,priority:0}),i:()=>({conversion:Sh,priority:0}),mark:()=>({conversion:Sh,priority:0}),s:()=>({conversion:Sh,priority:0}),span:()=>({conversion:hh,priority:0}),strong:()=>({conversion:Sh,priority:0}),sub:()=>({conversion:Sh,priority:0}),sup:()=>({conversion:Sh,priority:0}),u:()=>({conversion:Sh,priority:0})}}static importJSON(e){return Ch().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return hv(t)||V(132),t.style.whiteSpace=`pre-wrap`,this.hasFormat(`lowercase`)?t.style.textTransform=`lowercase`:this.hasFormat(`uppercase`)?t.style.textTransform=`uppercase`:this.hasFormat(`capitalize`)&&(t.style.textTransform=`capitalize`),this.hasFormat(`bold`)&&(t=ph(t,`b`)),this.hasFormat(`italic`)&&(t=ph(t,`i`)),this.hasFormat(`strikethrough`)&&(t=ph(t,`s`)),this.hasFormat(`underline`)&&(t=ph(t,`u`)),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,t){}setFormat(e){let t=this.getWritable();return t.__format=typeof e==`string`?gf[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?_f[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=g_(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=2,e}setMode(e){let t=bf[e];if(this.__mode===t)return this;let n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;let t=this.getWritable();return t.__text=e,t}select(e,t){fg();let n=e,r=t,i=G(),a=this.getTextContent(),o=this.__key;if(typeof a==`string`){let e=a.length;n===void 0&&(n=e),r===void 0&&(r=e)}else n=0,r=0;if(!W(i))return Wh(o,n,o,r,`text`,`text`);{let e=x_();e!==i.anchor.key&&e!==i.focus.key||b_(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),a=i.__text,o=n.length,s=e;s<0&&(s=o+s,s<0&&(s=0));let c=G();if(r&&W(c)){let t=e+o;c.setTextNodeRange(i,t,i,t)}return i.__text=a.slice(0,s)+n+a.slice(s+t),i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){fg();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=x_(),a=n.length;e.sort((e,t)=>e-t),e.push(a);let o=[],s=e.length;for(let t=0,r=0;t<a&&r<=s;r++){let i=e[r];i>t&&(o.push(n.slice(t,i)),t=i)}let c=o.length;if(c===1)return[t];let l=o[0],u=t.getParent(),d,f=t.getFormat(),p=t.getStyle(),m=t.__detail,h=!1,g=null,_=null,v=G();if(W(v)){let[e,t]=v.isBackward()?[v.focus,v.anchor]:[v.anchor,v.focus];e.type===`text`&&e.key===r&&(g=e),t.type===`text`&&t.key===r&&(_=t)}t.isSegmented()?(d=Ch(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=Wf(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=Ch(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=Wf(t,n);let a=n.__key;i===r&&b_(a),y.push(n)}let b=g?g.offset:null,x=_?_.offset:null,S=0;for(let e of y){if(!g&&!_)break;let t=S+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=S&&(g.set(e.getKey(),b-S,`text`),b<t&&(g=null)),_!==null&&x!==null&&x<=t&&x>=S){_.set(e.getKey(),x-S,`text`);break}S=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&y_(t),n!==null&&y_(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),W(v)&&Yh(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||V(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;x_()===r&&b_(n);let o=G();if(W(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&Qh(i,t,n,e,a),s!==null&&s.key===r&&Qh(s,t,n,e,a)}let s=e.__text,c=t?s+i:i+s;this.setTextContent(c);let l=this.getWritable();return e.remove(),l}isTextEntity(){return!1}};function hh(e){return{forChild:wh(e.style),node:null}}function gh(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:wh(t.style,n?void 0:`bold`),node:null}}var _h=new WeakMap;function vh(e){if(!hv(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function yh(e){let t=e;e.parentElement===null&&V(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=_h.get(n))===void 0&&!vh(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)_h.set(r[e],i);return i}(t)!==null){let e=n.split(/(\r?\n|\t)/),t=[],r=e.length;for(let n=0;n<r;n++){let r=e[n];r===`
8
+ `||r===`\r
9
+ `?t.push(ah()):r===` `?t.push(Eh()):r!==``&&t.push(Ch(r))}return{node:t}}if(n=n.replace(/\r/g,``).replace(/[ \t\n]+/g,` `),n===``)return{node:null};if(n[0]===` `){let e=t,r=!0;for(;e!==null&&(e=bh(e,!1))!==null;){let t=e.textContent||``;if(t.length>0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(n[n.length-1]===` `){let e=t,r=!0;for(;e!==null&&(e=bh(e,!0))!==null;)if((e.textContent||``).replace(/^( |\t|\r?\n)+/,``).length>0){r=!1;break}r&&(n=n.slice(0,n.length-1))}return n===``?{node:null}:{node:Ch(n)}}function bh(e,t){let n=e;for(;;){let e;for(;(e=t?n.nextSibling:n.previousSibling)===null;){let e=n.parentElement;if(e===null)return null;n=e}if(n=e,hv(n)){let e=n.style.display;if(e===``&&!vv(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(p_(n))return n;if(n.nodeName===`BR`)return null}}var xh={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function Sh(e){let t=xh[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:wh(e.style,t),node:null}}function Ch(e=``){return cv(new mh(e))}function U(e){return e instanceof mh}function wh(e,t){let n=e.fontWeight,r=e.textDecoration.split(` `),i=n===`700`||n===`bold`,a=r.includes(`line-through`),o=e.fontStyle===`italic`,s=r.includes(`underline`),c=e.verticalAlign;return e=>U(e)?(i&&!e.hasFormat(`bold`)&&e.toggleFormat(`bold`),a&&!e.hasFormat(`strikethrough`)&&e.toggleFormat(`strikethrough`),o&&!e.hasFormat(`italic`)&&e.toggleFormat(`italic`),s&&!e.hasFormat(`underline`)&&e.toggleFormat(`underline`),c!==`sub`||e.hasFormat(`subscript`)||e.toggleFormat(`subscript`),c!==`super`||e.hasFormat(`superscript`)||e.toggleFormat(`superscript`),t&&!e.hasFormat(t)&&e.toggleFormat(t),e):e}var Th=class e extends mh{static getType(){return`tab`}static clone(t){return new e(t.__key)}constructor(e){super(` `,e),this.__detail=2}static importDOM(){return null}createDOM(e){let t=super.createDOM(e),n=q_(e.theme,`tab`);return n!==void 0&&t.classList.add(...n),t}static importJSON(e){return Eh().updateFromJSON(e)}setTextContent(e){return e!==` `&&e!==``&&Gd(126),super.setTextContent(` `)}spliceText(e,t,n,r){return n===``&&t===0||n===` `&&t===1||V(286),this}setDetail(e){return e!==2&&V(127),this}setMode(e){return e!==`normal`&&V(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function Eh(){return cv(new Th)}function Dh(e){return e instanceof Th}var Oh=class{key;offset;type;_selection;constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){return this.key===e.key?this.offset<e.offset:oy(by(dy(this,`next`)),by(dy(e,`next`)))<0}getNode(){let e=S_(this.key);return e===null&&V(20),e}set(e,t,n,r){let i=this._selection,a=this.key;r&&this.key===e&&this.offset===t&&this.type===n||(this.key=e,this.offset=t,this.type=n,dg()||(x_()===a&&b_(e),i!==null&&(i.setCachedNodes(null),i.dirty=!0)))}};function kh(e,t,n){return new Oh(e,t,n)}function Ah(e,t){let n=t.__key,r=e.offset,i=`element`;if(U(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!K(t)){let e=t.getNextSibling();if(U(e))n=e.__key,r=0,i=`text`;else{let e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function jh(e,t){if(K(t)){let n=t.getLastDescendant();K(n)||U(n)?Ah(e,n):Ah(e,t)}else Ah(e,t)}var Mh=class e{_nodes;_cachedNodes;dirty;constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ph(e))return!1;let t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(e=>n.has(e))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new e(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.getNodes(),n=t.length,r=t[n-1],i;if(U(r))i=r.select();else{let e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e<n;e++)t[e].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let e of t){let t=S_(e);t!==null&&n.push(t)}return dg()||(this._cachedNodes=n),n}getTextContent(){let e=this.getNodes(),t=``;for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}deleteNodes(){let e=this.getNodes();if((G()||Jh())===this&&e[0]){let t=qv(e[0],`next`);py(iy(t,t))}for(let t of e)t.remove()}};function W(e){return e instanceof Nh}var Nh=class e{format;style;anchor;focus;_cachedNodes;dirty;constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!W(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=function(e){let t=[],[n,r]=e.getTextSlices();n&&t.push(n.caret.origin);let i=new Set,a=new Set;for(let n of e)if(Uv(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;K(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),Hv(e.focus)&&K(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=Zv(e.focus.origin,`previous`);Uv(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=$v(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!K(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=by(e.anchor),r=by(e.anchor.getFlipped()),i=e=>Vv(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(Cy(hy(this),`next`));return dg()||(this._cachedNodes=t),t}setTextNodeRange(e,t,n,r){this.anchor.set(e.__key,t,`text`),this.focus.set(n.__key,r,`text`)}getTextContent(){let e=this.getNodes();if(e.length===0)return``;let t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,a=r.isBefore(i),[o,s]=Ih(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if(K(d)&&!d.isInline())l||(c+=`
10
+ `),l=!d.isEmpty();else if(l=!1,U(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else !Pg(d)&&!oh(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=hg(),n=t.getEditorState()._selection,r=Uh(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(r===null)return;let[i,a]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(a.key,a.offset,a.type,!0),Jf(this)}clone(){let t=this.anchor,n=this.focus;return new e(kh(t.key,t.offset,t.type),kh(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=g_(this.format,e,null),this.dirty=!0}setFormat(e){this.format=e,this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=gf[e];return(this.format&t)!==0}insertRawText(e){let t=e.split(/(\r?\n|\t)/),n=[],r=t.length;for(let e=0;e<r;e++){let r=t[e];r===`
11
+ `||r===`\r
12
+ `?n.push(ah()):r===` `?n.push(Eh()):n.push(Ch(r))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,a=t,o=n;!this.isCollapsed()&&n.isBefore(t)&&(a=n,o=t),a.type===`element`&&function(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=Ch();if(o.setFormat(n),o.setStyle(r),Kg(a))a.splice(0,0,[o]);else{let e=Ig(i)?Gg().append(o):o;a===null?i.append(e):a.insertBefore(e)}e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}(a,o,r,i),o.type===`element`&&fy(o,by(dy(o,`next`)));let s=a.offset,c=o.offset,l=this.getNodes(),u=l.length,d=l[0];U(d)||V(26);let f=d.getTextContent().length,p=d.getParentOrThrow(),m=l[u-1];if(u===1&&o.type===`element`&&(c=f,o.set(a.key,c,`text`)),this.isCollapsed()&&s===f&&(f_(d)||!d.canInsertTextAfter()||!p.canInsertTextAfter()&&d.getNextSibling()===null)){let t=d.getNextSibling();if(U(t)&&t.canInsertTextBefore()&&!f_(t)||(t=Ch(),t.setFormat(r),t.setStyle(i),p.canInsertTextAfter()?d.insertAfter(t):p.insertAfter(t)),t.select(0,0),d=t,e!==``)return void this.insertText(e)}else if(this.isCollapsed()&&s===0&&(f_(d)||!d.canInsertTextBefore()||!p.canInsertTextBefore()&&d.getPreviousSibling()===null)){let t=d.getPreviousSibling();if(U(t)&&!f_(t)||(t=Ch(),t.setFormat(r),p.canInsertTextBefore()?d.insertBefore(t):p.insertBefore(t)),t.select(),d=t,e!==``)return void this.insertText(e)}else if(d.isSegmented()&&s!==f){let e=Ch(d.getTextContent());e.setFormat(r),d.replace(e),d=e}else if(!this.isCollapsed()&&e!==``){let t=m.getParent();if(!p.canInsertTextBefore()||!p.canInsertTextAfter()||K(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(``),Hh(this.anchor,this.focus),void this.insertText(e)}if(u===1){if(d_(d)){let t=Ch(e);t.select(),d.replace(t);return}let t=d.getFormat(),n=d.getStyle();if(s!==c||t===r&&n===i){if(Dh(d)){let t=Ch(e);t.setFormat(r),t.setStyle(i),t.select(),d.replace(t);return}}else{if(d.getTextContent()!==``){let t=Ch(e);if(t.setFormat(r),t.setStyle(i),t.select(),s===0)d.insertBefore(t,!1);else{let[e]=d.splitText(s);e.insertAfter(t,!1)}t.isComposing()&&this.anchor.type===`text`&&(this.anchor.offset-=e.length);return}d.setFormat(r),d.setStyle(i)}let a=c-s;d=d.spliceText(s,a,e,!0),d.getTextContent()===``?d.remove():this.anchor.type===`text`&&(this.format=t,this.style=n,d.isComposing()&&(this.anchor.offset-=e.length))}else{let t=new Set([...d.getParentKeys(),...m.getParentKeys()]),n=K(d)?d:d.getParentOrThrow(),r=K(m)?m:m.getParentOrThrow(),i=m;if(!n.is(r)&&r.isInline())do i=r,r=r.getParentOrThrow();while(r.isInline());if(o.type===`text`&&(c!==0||m.getTextContent()===``)||o.type===`element`&&m.getIndexWithinParent()<c)if(U(m)&&!d_(m)&&c!==m.getTextContentSize()){if(m.isSegmented()){let e=Ch(m.getTextContent());m.replace(e),m=e}Ig(o.getNode())||o.type!==`text`||(m=m.spliceText(0,c,``)),t.add(m.__key)}else{let e=m.getParentOrThrow();e.canBeEmpty()||e.getChildrenSize()!==1?m.remove():e.remove()}else t.add(m.__key);let a=r.getChildren(),p=new Set(l),h=n.is(r),g=n.isInline()&&d.getNextSibling()===null?n:d;for(let e=a.length-1;e>=0;e--){let t=a[e];if(t.is(d)||K(t)&&t.isParentOf(d))break;t.isAttached()&&(!p.has(t)||t.is(i)?h||g.insertAfter(t,!1):t.remove())}if(!h){let e=r,n=null;for(;e!==null;){let r=e.getChildren(),i=r.length;(i===0||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(d_(d))if(s===f)d.select();else{let t=Ch(e);t.select(),d.replace(t)}else d=d.spliceText(s,f-s,e,!0),d.getTextContent()===``?d.remove():this.anchor.type===`text`&&(this.format=d.getFormat(),this.style=d.getStyle(),d.isComposing()&&(this.anchor.offset-=e.length));for(let e=1;e<u;e++){let n=l[e],r=n.__key;t.has(r)||n.remove()}}}removeText(){let e=G()===this;my(this,yy(hy(this))),e&&G()!==this&&A_(this)}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void b_(null);let n=this.getNodes(),r=[];for(let e of n)U(e)&&r.push(e);let i=t=>{n.forEach(n=>{if(K(n)){let r=n.getFormatFlags(e,t);n.setTextFormat(r)}})},a=r.length;if(a===0)return this.toggleFormat(e),b_(null),void i(t);let o=this.anchor,s=this.focus,c=this.isBackward(),l=c?s:o,u=c?o:s,d=0,f=r[0],p=l.type===`element`?0:l.offset;if(l.type===`text`&&p===f.getTextContentSize()&&(d=1,f=r[1],p=0),f==null)return;let m=f.getFormatFlags(e,t);i(m);let h=a-1,g=r[h],_=u.type===`text`?u.offset:g.getTextContentSize();if(f.is(g)){if(p===_)return;if(f_(f)||p===0&&_===f.getTextContentSize())f.setFormat(m);else{let e=f.splitText(p,_),t=p===0?e[0]:e[1];t.setFormat(m),l.type===`text`&&l.set(t.__key,0,`text`),u.type===`text`&&u.set(t.__key,_-p,`text`)}this.format=m;return}p===0||f_(f)||([,f]=f.splitText(p),p=0),f.setFormat(m);let v=g.getFormatFlags(e,m);_>0&&(_===g.getTextContentSize()||f_(g)||([g]=g.splitText(_)),g.setFormat(v));for(let t=d+1;t<h;t++){let n=r[t],i=n.getFormatFlags(e,v);n.setFormat(i)}l.type===`text`&&l.set(f.__key,p,`text`),u.type===`text`&&u.set(g.__key,_,`text`),this.format=m|v}insertNodes(e){if(e.length===0)return;if(this.isCollapsed()||this.removeText(),this.anchor.key===`root`){this.insertParagraph();let t=G();return W(t)||V(134),t.insertNodes(e)}let t=(this.isBackward()?this.focus:this.anchor).getNode(),n=Mv(t,bv),r=e[e.length-1];if(K(n)&&`__language`in n){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=ng(this);n.splice(t,0,e),r.selectEnd()}return}if(!e.some(e=>(K(e)||Pg(e))&&!e.isInline())){K(n)||V(211,t.constructor.name,t.getType());let i=ng(this);n.splice(i,0,e),r.selectEnd();return}let i=function(e){let t=Gg(),n=null;for(let r=0;r<e.length;r++){let i=e[r],a=oh(i);if(a||Pg(i)&&i.isInline()||K(i)&&i.isInline()||U(i)||i.isParentRequired()){if(n===null&&(n=i.createParentElementNode(),t.append(n),a))continue;n!==null&&n.append(i)}else t.append(i),n=null}return t}(e),a=i.getLastDescendant(),o=i.getChildren(),s=!K(n)||!n.isEmpty()?this.insertParagraph():null,c=o[o.length-1],l=o[0];var u;K(u=l)&&bv(u)&&!u.isEmpty()&&K(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(K(n)||V(211,t.constructor.name,t.getType()),n.append(...l.getChildren()),l=o[1]),l&&(n===null&&V(212,t.constructor.name,t.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||V(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(n,l));let d=Mv(a,bv);s&&K(d)&&(s.canMergeWhenEmpty()||bv(c))&&(d.append(...s.getChildren()),s.remove()),K(n)&&n.isEmpty()&&n.remove(),a.selectEnd();let f=K(n)?n.getLastChild():null;oh(f)&&d!==n&&f.remove()}insertParagraph(){if(this.anchor.key===`root`){let e=Gg();return O_().splice(this.anchor.offset,0,[e]),e.select(),e}let e=ng(this),t=Mv(this.anchor.getNode(),bv);K(t)||V(213);let n=t.getChildAtIndex(e),r=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(e){let t=ah();if(this.insertNodes([t]),e){let e=t.getParentOrThrow(),n=t.getIndexWithinParent();e.select(n,n)}}extract(){let e=[...this.getNodes()],t=e.length,n=e[0],r=e[t-1],[i,a]=Ih(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(U(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(U(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),U(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(ig(this,e,t,n))return;let r=e===`move`,i=hg(),a=pv(av(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();if(s===null||o===null||!K(c)||c.isInline()||c.canBeEmpty()||fv(o,i,s),this.dirty){let e=Q_(i,this.anchor.key),t=Q_(i,this.focus.key);this.anchor.type===`text`&&(e=h_(e)),this.focus.type===`text`&&(t=h_(t)),e&&t&&$h(a,e,this.anchor.offset,t,this.focus.offset)}if(function(e,t,n,r){e.modify(t,n,r)}(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=a.getRangeAt(0),n=this.anchor.getNode(),i=Ig(n)?n:ov(n);if(this.applyDOMRange(e),this.dirty=!0,!r){let n=this.getNodes(),r=[],o=!1;for(let e=0;e<n.length;e++){let t=n[e];rv(t,i)?r.push(t):o=!0}if(o&&r.length>0)if(t){let e=r[0];K(e)?e.selectStart():e.getParentOrThrow().selectStart()}else{let e=r[r.length-1];K(e)?e.selectEnd():e.getParentOrThrow().selectEnd()}a.anchorNode===e.startContainer&&a.anchorOffset===e.startOffset||function(e){let t=e.focus,n=e.anchor,r=n.key,i=n.offset,a=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,a,!0)}(this)}}n===`lineboundary`&&ig(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&K(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(K(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=ny(dy(t,e?`previous`:`next`));if(r.getTextSlices().every(e=>e===null||e.distance===0)){let e={type:`initial`};for(let t of r.iterNodeCarets(`shadowRoot`))if(Uv(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(K(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=by(t);my(this,iy(e,e)),r.anchor.origin.remove()}return}e.type!==`merge-next-block`&&e.type!==`merge-block`||(e={block:e.block,caret:t,type:`merge-block`})}}else{if(e.type===`merge-block`)break;if(Hv(t)){if(K(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(Pg(t.origin)){if(!t.origin.isIsolated())if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&K(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=Kh();e.add(t.origin.getKey()),A_(e)}else t.origin.remove();return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return my(this,iy(!t.origin.isEmpty()&&n.isEmpty()?gy(qv(n,t.direction)):r.anchor,t)),this.removeText()}}let i=this.focus;if(this.modify(`extend`,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&Lh(this,t.getNode()))return}else{let r=i.type===`text`?i.getNode():null;if(n=t.type===`text`?t.getNode():null,r!==null&&r.isSegmented()){let t=i.offset,a=r.getTextContentSize();if(r.is(n)||e&&t!==a||!e&&t!==0)return void zh(r,e,t)}else if(n!==null&&n.isSegmented()){let i=t.offset,a=n.getTextContentSize();if(n.is(r)||e&&i!==0||!e&&i!==a)return void zh(n,e,i)}(function(e,t){let n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&n.type===`text`&&r.type===`text`){let e=n.offset,a=r.offset,o=e<a,s=o?e:a,c=o?a:e,l=c-1;s!==l&&(function(e){return!(M_(e)||Rh(e))})(i.getTextContent().slice(s,c))&&(t?r.set(r.key,l,r.type):n.set(n.key,l,n.type))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type===`element`&&this.anchor.offset===0){let e=this.anchor.getNode();e.isEmpty()&&Ig(e.getParent())&&e.getPreviousSibling()===null&&Lh(this,e)}}deleteLine(e){this.isCollapsed()&&this.modify(`extend`,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):this.removeText()}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify(`extend`,e,`word`)}this.isCollapsed()?this.deleteCharacter(e):this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function Ph(e){return e instanceof Mh}function Fh(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function Ih(e){let t=e.getStartEndPoints();if(t===null)return[0,0];let[n,r]=t;return n.type===`element`&&r.type===`element`&&n.key===r.key&&n.offset===r.offset?[0,0]:[Fh(n),Fh(r)]}function Lh(e,t){for(let n=t;n;n=n.getParent()){if(K(n)){if(n.collapseAtStart(e))return!0;if(sv(n))break}if(n.getPreviousSibling())break}return!1}var Rh=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function zh(e,t,n){let r=e,i=r.getTextContent().split(/(?=\s)/g),a=i.length,o=0,s=0;for(let e=0;e<a;e++){let r=e===a-1;if(s=o,o+=i[e].length,t&&o===n||o>n||r){i.splice(e,1),r&&(s=void 0);break}}let c=i.join(``).trim();c===``?r.remove():(r.setTextContent(c),r.select(s,s))}function Bh(e,t,n,r){let i,a=t;if(hv(e)){let o=!1,s=e.childNodes,c=s.length,l=r._blockCursorElement;a===c&&(o=!0,a=c-1);let u=s[a],d=!1;if(u===l)u=s[a+1],d=!0;else if(l!==null){let n=l.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,l)&&a--}if(i=j_(u),U(i))a=Yv(i,o?`next`:`previous`);else{let s=j_(e);if(s===null)return null;if(K(s)){let c=r.getElementByKey(s.getKey());c===null&&V(214);let l=s.getDOMSlot(c);[s,a]=l.resolveChildIndex(s,c,e,t),K(s)||V(215),o&&a>=s.getChildrenSize()&&(a=Math.max(0,s.getChildrenSize()-1));let u=s.getChildAtIndex(a);if(K(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=o?u.getLastDescendant():u.getFirstDescendant();e===null?s=u:(u=e,s=K(u)?u:u.getParentOrThrow()),a=0}U(u)?(i=u,s=null,a=Yv(u,o?`next`:`previous`)):u!==s&&o&&!d&&(K(s)||V(216),a=Math.min(s.getChildrenSize(),a+1))}else{let n=s.getIndexWithinParent();a=t===0&&Pg(s)&&j_(e)===s?n:n+1,s=s.getParentOrThrow()}if(K(s))return kh(s.__key,a,`element`)}}else i=j_(e);return U(i)?kh(i.__key,Yv(i,a,`clamp`),`text`):null}function Vh(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&K(a)&&a.isInline()){let t=a.getPreviousSibling();U(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else K(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):U(r)&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&K(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&K(a)&&a.isInline()&&!a.canInsertTextAfter()){let t=a.getNextSibling();U(t)&&e.set(t.__key,0,`text`)}}}function Hh(e,t,n){if(e.type===`text`&&t.type===`text`){let n=e.isBefore(t),r=e.is(t);Vh(e,n,r),Vh(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}function Uh(e,t,n,r,i,a){if(e===null||n===null||!s_(i,e,n))return null;let o=Bh(e,t,W(a)?a.anchor:null,i);if(o===null)return null;let s=Bh(n,r,W(a)?a.focus:null,i);if(s===null)return null;if(o.type===`element`&&s.type===`element`){let t=j_(e),r=j_(n);if(Pg(t)&&Pg(r))return null}return Hh(o,s),[o,s]}function Wh(e,t,n,r,i,a){let o=mg(),s=new Nh(kh(e,t,i),kh(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function Gh(){return new Nh(kh(`root`,0,`element`),kh(`root`,0,`element`),0,``)}function Kh(){return new Mh(new Set)}function qh(e,t,n,r){let i=n._window;if(i===null)return null;let a=r||i.event,o=a?a.type:void 0,s=o===`selectionchange`,c=!wf&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(W(e)&&!c)return e.clone();if(t===null)return null;if(l=t.anchorNode,u=t.focusNode,d=t.anchorOffset,f=t.focusOffset,(s||o===void 0)&&W(e)&&!s_(n,l,u))return e.clone();let p=Uh(l,d,u,f,n,e);if(p===null)return null;let[m,h]=p,g=0,_=``;if(W(e)){let t=e.anchor;if(m.key===t.key)g=e.format,_=e.style;else{let e=m.getNode();U(e)?(g=e.getFormat(),_=e.getStyle()):K(e)&&(g=e.getTextFormat(),_=e.getTextStyle())}}return new Nh(m,h,g,_)}function G(){return mg()._selection}function Jh(){return hg()._editorState._selection}function Yh(e,t,n,r=1){let i=e.anchor,a=e.focus,o=i.getNode(),s=a.getNode();if(!t.is(o)&&!t.is(s))return;let c=t.__key;if(e.isCollapsed()){let t=i.offset;if(n<=t&&r>0||n<t&&r<0){let n=Math.max(0,t+r);i.set(c,n,`element`),a.set(c,n,`element`),Xh(e)}}else{let o=e.isBackward(),s=o?a:i,l=s.getNode(),u=o?i:a,d=u.getNode();if(t.is(l)){let e=s.offset;(n<=e&&r>0||n<e&&r<0)&&s.set(c,Math.max(0,e+r),`element`)}if(t.is(d)){let e=u.offset;(n<=e&&r>0||n<e&&r<0)&&u.set(c,Math.max(0,e+r),`element`)}}Xh(e)}function Xh(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!K(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(U(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}return}if(K(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(U(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(K(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(U(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}function Zh(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,U(i)?s=`text`:K(i)&&(s=`element`)):(a=r.__key,U(r)?(o=r.getTextContentSize(),s=`text`):K(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function Qh(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function $h(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function eg(e,t,n){let r=Q_(e,t.getKey());if(K(t)){let e=t.getDOMSlot(r);return[e.element,n+e.getFirstChildOffset()]}return[r,n]}function tg(e,t,n,r,i,a,o){let s=r.anchorNode,c=r.focusNode,l=r.anchorOffset,u=r.focusOffset,d=document.activeElement;if(i.has(`collaboration`)&&d!==a||d!==null&&o_(d))return;if(!W(t))return void(e!==null&&s_(n,s,c)&&r.removeAllRanges());let f=t.anchor,p=t.focus,m=f.getNode(),h=p.getNode(),[g,_]=eg(n,m,f.offset),[v,y]=eg(n,h,p.offset),b=t.format,x=t.style,S=t.isCollapsed(),C=g,w=v,T=!1;var E,D,O,k,A;if((f.type===`text`?(C=h_(g),T=m.getFormat()!==b||m.getStyle()!==x):W(e)&&e.anchor.type===`text`&&(T=!0),p.type===`text`&&(w=h_(v)),C!==null&&w!==null)&&(S&&(e===null||T||W(e)&&(e.format!==b||e.style!==x))&&(E=b,D=x,O=_,k=f.key,A=performance.now(),jm=[E,D,O,k,A]),l!==_||u!==y||s!==C||c!==w||r.type===`Range`&&S||(d!==null&&a.contains(d)||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0}),f.type===`element`))){if($h(r,C,_,w,y),!Yd||!t.isCollapsed()||a===null||i.has(`skip-selection-focus`)||document.activeElement!==null&&a.contains(document.activeElement)||a.focus({preventScroll:!0}),!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===document.activeElement){let e=W(t)&&t.anchor.type===`element`?C.childNodes[_]||null:r.rangeCount>0?r.getRangeAt(0):null;if(e!==null){let t;if(e instanceof Text){let n=document.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=ev(n),i=iv(r);if(r===null||i===null)return;let{top:a,bottom:o}=t,s=0,c=0,l=n;for(;l!==null;){let t=l===r.body;if(t){s=0,c=av(e).innerHeight;let t=i.getComputedStyle(r.documentElement),n=parseFloat(t.scrollPaddingTop),a=parseFloat(t.scrollPaddingBottom);isFinite(n)&&(s+=n),isFinite(a)&&(c-=a)}else{let e=l.getBoundingClientRect();s=e.top,c=e.bottom}let n=0;if(a<s?n=-(s-a):o>c&&(n=o-c),n!==0)if(t)i.scrollBy(0,n);else{let e=l.scrollTop;l.scrollTop+=n;let t=l.scrollTop-e;a-=t,o-=t}if(t)break;l=$_(l)}})(n,t,a)}}wm=!0}}function ng(e){let t=e;e.isCollapsed()||t.removeText();let n=G();W(n)&&(t=n),W(t)||V(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!bv(i);){let e=i;if([i,a]=rg(i,a),e.is(i))break}return a}function rg(e,t){let n=e.getParent();if(!n){let e=Gg();return O_().append(e),e.select(),[O_(),0]}if(U(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!K(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new Nh(kh(e.__key,t,`element`),kh(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function ig(e,t,n,r,i=`decorators-and-blocks`){if(t===`move`&&r===`character`&&!e.isCollapsed()){let[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}let a=dy(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!xy(c)){for(let e of c){l=!1;let{origin:t}=e;if(!Pg(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of ny(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(Uv(e))e.origin.isInline()||(c=e);else{if(K(e.origin))continue;Pg(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&Pg(c.origin)&&c.origin.isKeyboardSelectable()){let e=Kh();return e.add(c.origin.getKey()),A_(e),!0}return c=by(c),s&&fy(e.anchor,c),fy(e.focus,c),l||!o}var ag=null,og=null,sg=!1,cg=!1,lg=0,ug={characterData:!0,childList:!0,subtree:!0};function dg(){return sg||ag!==null&&ag._readOnly}function fg(){sg&&V(13)}function pg(){lg>99&&V(14)}function mg(){return ag===null&&V(195,gg()),ag}function hg(){return og===null&&V(196,gg()),og}function gg(){let e=0,t=new Set,n=Qg.version;if(typeof window<`u`)for(let r of document.querySelectorAll(`[contenteditable]`)){let i=u_(r);if(c_(i))e++;else if(i){let e=String(i.constructor.version||`<0.17.1`);e===n&&(e+=` (separately built, likely a bundler configuration issue)`),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(`, `)}`),r}function _g(){return og}function vg(e,t,n){let r=t.__type,i=n_(e,r),a=n.get(r);a===void 0&&(a=Array.from(i.transforms),n.set(r,a));let o=a.length;for(let e=0;e<o&&(a[e](t),t.isAttached());e++);}function yg(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function bg(e,t){if(!t)return;let n=e._updateTags,r=t;Array.isArray(t)||(r=[t]);for(let e of r)n.add(e)}function xg(e,t){let n=e.type,r=t.get(n);r===void 0&&V(17,n);let i=r.klass;e.type!==i.getType()&&V(18,i.name);let a=i.importJSON(e),o=e.children;if(K(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=xg(o[e],t);a.append(n)}return a}function Sg(e,t,n){let r=ag,i=sg,a=og;ag=t,sg=!0,og=e;try{return n()}finally{ag=r,sg=i,og=a}}function Cg(e,t){let n=e._pendingEditorState,r=e._rootElement,i=e._headless||r===null;if(n===null)return;let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=ag,u=sg,d=og,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){og=e,ag=n,sg=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=Op(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),cg)throw t;qg(e,null,r,n),Nf(e),e._dirtyType=2,cg=!0,Cg(e,a),cg=!1;return}finally{p.observe(r,ug),e._updating=f,ag=l,sg=u,og=d}}n._readOnly||=!0;let h=e._dirtyLeaves,g=e._dirtyElements,_=e._normalizedNodes,v=e._updateTags,y=e._deferred;c&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements=new Map,e._normalizedNodes=new Set,e._updateTags=new Set),function(e,t){let n=e._decorators,r=e._pendingDecorators||n,i=t._nodeMap,a;for(a in r)i.has(a)||(r===n&&(r=E_(e)),delete r[a])}(e,n);let b=i?null:pv(av(e));if(e._editable&&b!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){og=e,ag=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&fv(t,e,r),tg(o,s,e,b,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(W(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(document.activeElement)){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())dv(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&dv(t)){let n=t.getPreviousSibling();(n===null||dv(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=e.getElementByKey(a.__key);r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=document.createElement(`div`);n.contentEditable=`false`,n.setAttribute(`data-lexical-cursor`,`true`);let r=t.blockCursor;return r!==void 0&&(typeof r==`string`&&(r=t.blockCursor=Oy(r)),r!==void 0&&n.classList.add(...r)),n}(e._config)),t.style.caretColor=`transparent`,c===null?n.appendChild(r):n.insertBefore(r,c);return}}r!==null&&fv(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,ug),og=d,ag=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),W(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(Ap,void 0);let x=e._pendingDecorators;x!==null&&(e._decorators=x,e._pendingDecorators=null,wg(`decorator`,e,!0,x)),function(e,t,n){let r=D_(t),i=D_(n);r!==i&&wg(`textcontent`,e,!0,i)}(e,t||a,n),wg(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),function(e,t){if(e._deferred=[],t.length!==0){let n=e._updating;e._updating=!0;try{for(let e=0;e<t.length;e++)t[e]()}finally{e._updating=n}}}(e,y),function(e){let t=e._updates;if(t.length!==0){let n=t.shift();if(n){let[t,r]=n;Dg(e,t,r)}}}(e)}function wg(e,t,n,...r){let i=t._updating;t._updating=n;try{let n=t._listeners[e],i=Array.from(n);for(let[e,t]of i){t&&t();let i=e(...r);n.has(e)?n.set(e,i):i&&i()}}finally{t._updating=i}}function Tg(e,t,n,r){let i=N_(e),a;for(let e=4;e>=0;e--)for(let o=0;o<i.length;o++){let s=i[o];if(o>0&&s._updating){a=s;break}let c=s._commands.get(t);if(c!==void 0){let t=c[e];if(t!==void 0){let e=Array.from(t),i=e.length,a=!1;if(Og(s,()=>{for(let t=0;t<i;t++)if(e[t](n,r))return void(a=!0)}),a)return a}}}return a&&a.update(()=>{Tg(a,t,n,r)}),!1}function Eg(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&V(191),a._flushSync=!0),o&&e._deferred.push(o),bg(e,i.tag)),a==null?Dg(e,n,i):n()}}return r}function Dg(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,bg(e,n.tag),a=n.skipTransforms||!1,o=n.discrete||!1),i&&e._deferred.push(i);let s=e._editorState,c=e._pendingEditorState,l=!1;(c===null||c._readOnly)&&(c=e._pendingEditorState=Lg(c||s),l=!0),c._flushSync=o;let u=ag,d=sg,f=og,p=e._updating;ag=c,sg=!1,e._updating=!0,og=e;let m=e._headless||e.getRootElement()===null;e_(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=pv(av(e));return W(n)||n==null?qh(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=Eg(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(W(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);U(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&qf(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=x_(),o=new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=new Set;for(let e of s){let r=i.get(e);U(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&qf(r),r!==void 0&&yg(r,a)&&vg(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){lg++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map,l.delete(`root`)&&l.set(`root`,!0);for(let e of l){let n=e[0],s=e[1];if(r.set(n,s),!s)continue;let c=i.get(n);c!==void 0&&yg(c,a)&&vg(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,lg++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),Eg(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(K(t)&&Cf(t,e,i,a,o,r),i.has(e)||r.delete(e),o.push(e)))}for(let e of o)a.delete(e);for(let e of n){let t=a.get(e);t===void 0||t.isAttached()||(i.has(e)||n.delete(e),a.delete(e))}}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(W(i)){let e=c._nodeMap,t=i.anchor.key,n=i.focus.key;e.get(t)!==void 0&&e.get(n)!==void 0||V(19)}else Ph(i)&&i._nodes.size===0&&(c._selection=null)}catch(t){t instanceof Error&&e._onError(t),e._pendingEditorState=s,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),Cg(e);return}finally{ag=u,sg=d,og=f,e._updating=p,lg=0}e._dirtyType!==0||e._deferred.length>0||function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(r!==null){if(r.dirty||!r.is(n))return!0}else if(n!==null)return!0;return!1}(c,e)?c._flushSync?(c._flushSync=!1,Cg(e)):l&&i_(()=>{Cg(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Og(e,t,n){og===e&&n===void 0?t():Dg(e,t,n)}var kg=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&V(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&V(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&V(224),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(nf||Zd||$d);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before,i=document.createElement(`br`);if(n.insertBefore(i,r),e){let e=document.createElement(`img`);e.setAttribute(`data-lexical-linebreak`,`true`),e.style.cssText=`display: inline !important; border: 0px !important; margin: 0px !important;`,e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset();return[e,Math.min(t+e.getChildrenSize(),Math.max(t,r))]}let i=Ag(t,n);i.push(r);let a=Ag(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function Ag(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&V(225),n.reverse()}var jg=class extends $m{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){return yf[this.getFormat()]||``}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let e=hg()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[],t=this.getFirstChild();for(;t!==null;){if(U(t)&&e.push(t),K(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;K(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;K(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return K(e)&&e.getLastDescendant()||e||null}let r=t[e];return K(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:S_(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&V(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:S_(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&V(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=``,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),K(i)&&r!==n-1&&!i.isInline()&&(e+=mf)}return e}getTextContentSize(){let e=0,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),K(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=vf[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=gf[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return g_(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){fg();let n=G(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(U(e)||K(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(U(e)||K(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return W(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):Wh(o,r,o,i,`element`,`element`)}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(e=>e.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e===``?0:vf[e],this}setStyle(e){return this.getWritable().__style=e||``,this}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){Qm(this)&&V(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||V(226,String(e),String(t),String(r));let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0)if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&V(100);let t=e.getNextSibling(),n=e.__key;v_(e.getWritable()),s.push(n),e=t}}let d=l;for(let e of n){d!==null&&e.is(d)&&(l=d=d.getPreviousSibling());let t=e.getWritable();t.__parent===a&&u--,v_(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&V(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=G();if(W(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;Mg(r,t,n)&&Zh(r,r.getNode(),this,l,c),Mg(i,t,n)&&Zh(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||sv(this)||this.remove()}}return i}getDOMSlot(e){return new kg(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(hv(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`);let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||sv(this)||this.getChildren().some(U)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=this.getDOMSlot(e),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function K(e){return e instanceof jg}function Mg(e,t,n){let r=e.getNode();for(;r;){let e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}var Ng=class extends $m{decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function Pg(e){return e instanceof Ng}var Fg=class e extends jg{__cachedText;static getType(){return`root`}static clone(){return new e}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){V(51)}getTextContent(){let e=this.__cachedText;return!dg()&&hg()._dirtyType!==0||e===null?super.getTextContent():e}remove(){V(52)}replace(e){V(53)}insertBefore(e){V(54)}insertAfter(e){V(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)K(e)||Pg(e)||V(282);return super.splice(e,t,n)}static importJSON(e){return O_().updateFromJSON(e)}collapseAtStart(){return!0}};function Ig(e){return e instanceof Fg}function Lg(e){return new Vg(new Map(e._nodeMap))}function Rg(){return new Vg(new Map([[`root`,new Fg]]))}function zg(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&V(130,n.name),K(e)){let r=t.children;Array.isArray(r)||V(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=zg(i[e]);r.push(t)}}return t}function Bg(e){return e instanceof Vg}var Vg=class e{_nodeMap;_selection;_flushSync;_readOnly;constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Sg(t&&t.editor||null,this,e)}clone(t){let n=new e(this._nodeMap,t===void 0?this._selection:t);return n._readOnly=!0,n}toJSON(){return Sg(null,this,()=>({root:zg(O_())}))}},Hg=class extends jg{static getType(){return`artificial`}createDOM(e){return document.createElement(`div`)}},Ug=class e extends jg{static getType(){return`paragraph`}static clone(t){return new e(t.__key)}createDOM(e){let t=document.createElement(`p`),n=q_(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Wg,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);if(hv(t)){this.isEmpty()&&t.append(document.createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}static importJSON(e){return Gg().updateFromJSON(e)}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(U);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=Gg();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||U(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function Wg(e){let t=Gg();if(e.style&&(t.setFormat(e.style.textAlign),Dv(e,t)),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in vf&&t.setFormat(n)}return{node:t}}function Gg(){return cv(new Ug)}function Kg(e){return e instanceof Ug}function qg(e,t,n,r){let i=e._keyToDOMMap;i.clear(),e._editorState=Rg(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,e._updateTags=new Set,e._updates=[],e._blockCursorElement=null;let a=e._observer;a!==null&&(a.disconnect(),e._observer=null),t!==null&&(t.textContent=``),n!==null&&(n.textContent=``,i.set(`root`,n))}function Jg(e){let t=new Set,n=new Set,r=e;for(;r;){let{ownNodeConfig:e}=Av(r),i=r.transform;if(!n.has(i)){n.add(i);let e=r.transform();e&&t.add(e)}if(e){let n=e.$transform;n&&t.add(n),r=e.extends}else{let e=Object.getPrototypeOf(r);r=e.prototype instanceof $m&&e!==$m?e:void 0}}return t}function Yg(e){let t=e||{},n=_g(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=Rg(),s=t.namespace||(i===null?P_():i._config.namespace),c=t.editorState,l=[Fg,mh,rh,Th,Ug,Hg,...t.nodes||[]],{onError:u,html:d}=t,f=t.editable===void 0||t.editable,p;if(e===void 0&&n!==null)p=n._nodes;else{p=new Map;for(let e=0;e<l.length;e++){let t=l[e],n=null,r=null;if(typeof t!=`function`){let e=t;t=e.replace,n=e.with,r=e.withKlass||null}Av(t);let i=t.getType(),a=Jg(t);p.set(i,{exportDOM:d&&d.export?d.export.get(t):void 0,klass:t,replace:n,replaceWithKlass:r,sharedNodeState:If(l[e]),transforms:a})}}let m=new Qg(o,i,p,{disableEvents:a,namespace:s,theme:r},u||console.error,function(e,t){let n=new Map,r=new Set,i=e=>{Object.keys(e).forEach(t=>{let r=n.get(t);r===void 0&&(r=[],n.set(t,r)),r.push(e[t])})};return e.forEach(e=>{let t=e.klass.importDOM;if(t==null||r.has(t))return;r.add(t);let n=t.call(e.klass);n!==null&&i(n)}),t&&i(t),n}(p,d?d.import:void 0),f,e);return c!==void 0&&(m._pendingEditorState=c,m._dirtyType=2),function(e){e.registerCommand(Mp,Rm,0),e.registerCommand(Np,zm,0),e.registerCommand(Pp,Bm,0),e.registerCommand(Fp,Vm,0),e.registerCommand(qp,Um,0)}(m),m}function Xg(e,t){let n=e.get(t);e.delete(t),n&&n()}function Zg(e,t,n){return e.set(t,n),Xg.bind(null,e,t)}var Qg=class{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(e,t,n,r,i,a,o,s){this._createEditorArgs=s,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=P_(),this._onError=i,this._htmlConversions=a,this._editable=o,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){return Zg(this._listeners.update,e)}registerEditableListener(e){return Zg(this._listeners.editable,e)}registerDecoratorListener(e){return Zg(this._listeners.decorator,e)}registerTextContentListener(e){return Zg(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return Ay(Zg(t,e,e(this._rootElement,null)||void 0),()=>function(e,t,n){let r=e.get(t);r&&r(),e.set(t,t(...n)||void 0)}(t,e,[null,this._rootElement]))}registerCommand(e,t,n){n===void 0&&V(35);let r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(e);i===void 0&&V(36,String(e));let a=i[n];return a.add(t),()=>{a.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&V(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=wv(n).get(t.getType());if(!r)return;let i=new Map;for(let e of r.keys())i.set(e,`created`);i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set([`registerMutationListener`])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){let n=wv(e.getEditorState()),r=[];for(let e of t){let t=n.get(e);t&&r.push(t)}r.length!==0&&e.update(()=>{for(let e of r)for(let t of e.keys()){let e=S_(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:eh}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return q(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=q_(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,qg(this,t,e,r),t!==null&&(this._config.disableEvents||Ym(t),n!=null&&t.classList.remove(...n)),e!==null){let t=iv(e),r=e.style;r.userSelect=`text`,r.whiteSpace=`pre-wrap`,r.wordBreak=`break-word`,e.setAttribute(`data-lexical-editor`,`true`),this._window=t,this._dirtyType=2,Nf(this),this._updateTags.add(eh),Cg(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Sm.set(e,n);let r=Cm.get(n)??0;r<1&&n.addEventListener(`selectionchange`,Km),Cm.set(n,r+1),e.__lexicalEditor=t;let i=Wm(e);for(let n=0;n<_m.length;n++){let[r,a]=_m[n],o=typeof a==`function`?e=>{Jm(e)||(qm(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(Jm(e))return;qm(e);let n=t.isEditable();switch(r){case`cut`:return n&&q(t,dm,e);case`copy`:return q(t,um,e);case`paste`:return n&&q(t,Bp,e);case`dragstart`:return n&&q(t,sm,e);case`dragover`:return n&&q(t,cm,e);case`dragend`:return n&&q(t,lm,e);case`focus`:return n&&q(t,pm,e);case`blur`:return n&&q(t,mm,e);case`drop`:return n&&q(t,om,e)}};e.addEventListener(r,o),i.push(()=>{e.removeEventListener(r,o)})}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(eh),Cg(this);wg(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&V(38);let n=e;n._readOnly&&(n=Lg(e),n._selection=e._selection?e._selection.clone():null),Mf(this);let r=this._pendingEditorState,i=this._updateTags,a=t===void 0?null:t.tag;r===null||r.isEmpty()||(a!=null&&i.add(a),Cg(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,a!=null&&i.add(a),this._updating||Cg(this)}parseEditorState(e,t){return function(e,t,n){let r=Rg(),i=ag,a=sg,o=og,s=t._dirtyElements,c=t._dirtyLeaves,l=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=new Map,t._dirtyLeaves=new Set,t._cloneNotNeeded=new Set,t._dirtyType=0,ag=r,sg=!1,og=t,e_(null);try{let i=t._nodes;xg(e.root,i),n&&n(),r._readOnly=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=s,t._dirtyLeaves=c,t._cloneNotNeeded=l,t._dirtyType=u,ag=i,sg=a,og=o}return r}(typeof e==`string`?JSON.parse(e):e,this,t)}read(e){return Cg(this),this.getEditorState().read(e,{editor:this})}update(e,t){(function(e,t,n){e._updating?e._updates.push([t,n]):Dg(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),Og(this,()=>{let r=G(),i=O_();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||A_(r.clone()),tv(`focus`),nv(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=pv(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,wg(`editable`,this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};Qg.version=`0.43.0+prod.esm`;var $g=null;function e_(e){$g=e}var t_=1;function n_(e,t){let n=r_(e,t);return n===void 0&&V(30,t),n}function r_(e,t){return e._nodes.get(t)}var i_=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function a_(e){return Pg(T_(e))}function o_(e){let t=document.activeElement;if(!hv(t))return!1;let n=t.nodeName;return Pg(T_(e))&&(n===`INPUT`||n===`TEXTAREA`||t.contentEditable===`true`&&u_(t)==null)}function s_(e,t,n){let r=e.getRootElement();try{return r!==null&&r.contains(t)&&r.contains(n)&&t!==null&&!o_(t)&&l_(t)===e}catch{return!1}}function c_(e){return e instanceof Qg}function l_(e){let t=e;for(;t!=null;){let e=u_(t);if(c_(e))return e;t=$_(t)}return null}function u_(e){return e?e.__lexicalEditor:null}function d_(e){return Dh(e)||e.isToken()}function f_(e){return d_(e)||e.isSegmented()}function p_(e){return gv(e)&&e.nodeType===3}function m_(e){return gv(e)&&e.nodeType===9}function h_(e){let t=e;for(;t!=null;){if(p_(t))return t;t=t.firstChild}return null}function g_(e,t,n){let r=gf[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~gf.superscript:t===`superscript`?i&=~gf.subscript:t===`lowercase`?(i&=~gf.uppercase,i&=~gf.capitalize):t===`uppercase`?(i&=~gf.lowercase,i&=~gf.capitalize):t===`capitalize`&&(i&=~gf.lowercase,i&=~gf.uppercase),i}function __(e,t){let n=function(){let e=$g;return $g=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);fg(),pg();let r=hg(),i=mg(),a=``+ t_++;i._nodeMap.set(a,e),K(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType=1,e.__key=a}function v_(e){let t=e.getParent();if(t!==null){let n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),a=e.getNextSibling(),o=a===null?null:a.__key,s=i===null?null:i.__key,c=i===null?null:i.getWritable(),l=a===null?null:a.getWritable();i===null&&(r.__first=o),a===null&&(r.__last=s),c!==null&&(c.__next=o),l!==null&&(l.__prev=s),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function y_(e){pg(),Qm(e)&&V(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent,r=mg(),i=hg(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent}}(n,a,o);let s=t.__key;i._dirtyType=1,K(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function b_(e){fg();let t=hg(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=S_(n);e!==null&&e.getWritable()}if(e!==null){let t=S_(e);t!==null&&t.getWritable()}}}function x_(){return dg()?null:hg()._compositionKey}function S_(e,t){let n=(t||mg())._nodeMap.get(e);return n===void 0?null:n}function C_(e,t){let n=w_(e,hg());return n===void 0?null:S_(n,t)}function w_(e,t){return e[`__lexicalKey_${t._key}`]}function T_(e,t){let n=e;for(;n!=null;){let e=C_(n,t);if(e!==null)return e;n=$_(n)}return null}function E_(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function D_(e){return e.read(()=>O_().getTextContent())}function O_(){return k_(mg())}function k_(e){return e._nodeMap.get(`root`)}function A_(e){fg();let t=mg();e!==null&&(e.dirty=!0,e.setCachedNodes(null)),t._selection=e}function j_(e){let t=hg(),n=function(e,t){let n=e;for(;n!=null;){let e=w_(n,t);if(e!==void 0)return e;n=$_(n)}return null}(e,t);return n===null?e===t.getRootElement()?S_(`root`):null:S_(n)}function M_(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function N_(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function P_(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function F_(e){return p_(e)?e.nodeValue:null}function I_(e,t,n){let r=pv(av(t));if(r===null)return;let i=r.anchorNode,{anchorOffset:a,focusOffset:o}=r;if(i!==null){let t=F_(i),r=T_(i);if(t!==null&&U(r)){if((t===pf||t===hf)&&n){let e=n.length;t=n,a=e,o=e}t!==null&&L_(r,t,a,o,e)}}}function L_(e,t,n,r,i){let a=e;if(a.isAttached()&&(i||!a.isDirty())){let o=a.isComposing(),s=t;if((o||i)&&(t.endsWith(pf)&&(s=t.slice(0,-pf.length)),i)){let e=hf,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){if(s===``){if(b_(null),$d||Zd||nf)a.remove();else{let e=hg();setTimeout(()=>{e.update(()=>{a.isAttached()&&a.remove()})},20)}return}let t=a.getParent(),i=Jh(),c=a.getTextContentSize(),l=x_(),u=a.getKey();if(a.isToken()||l!==null&&u===l&&!o||W(i)&&(t!==null&&!t.canInsertTextBefore()&&i.anchor.offset===0||i.anchor.key===e.__key&&i.anchor.offset===0&&!a.canInsertTextBefore()&&!o||i.focus.key===e.__key&&i.focus.offset===c&&!a.canInsertTextAfter()&&!o))return void a.markDirty();let d=G();if(!W(d)||n===null||r===null)return void R_(a,s,d);if(d.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=Ch(a.getTextContent());a.replace(e),a=e}R_(a,s,d)}}}function R_(e,t,n){if(e.setTextContent(t),W(n)){let t=e.getKey();for(let r of[`anchor`,`focus`]){let i=n[r];i.type===`text`&&i.key===t&&(i.offset=Yv(e,i.offset,`clamp`))}}}function z_(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function B_(e,t){return z_(e,t,`altKey`)&&z_(e,t,`ctrlKey`)&&z_(e,t,`shiftKey`)&&z_(e,t,`metaKey`)}function V_(e,t,n){if(!B_(e,n))return!1;if(e.key.toLowerCase()===t.toLowerCase())return!0;if(t.length>1||e.key.length===1&&e.key.charCodeAt(0)<=127)return!1;let r=`Key`+t.toUpperCase();return e.code===r}var H_={ctrlKey:!Jd,metaKey:Jd},U_={altKey:Jd,ctrlKey:!Jd};function W_(e){return e.key===`Backspace`}function G_(e){return V_(e,`a`,H_)}function K_(e){let t=O_();if(W(e)){let t=e.anchor,n=e.focus,r=t.getNode().getTopLevelElementOrThrow().getParentOrThrow();return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),Jf(e),e}{let e=t.select(0,t.getChildrenSize());return A_(Jf(e)),e}}function q_(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});let n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;let i=e[t];if(typeof i==`string`){let e=Oy(i);return n[t]=e,e}return i}function J_(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&V(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function Y_(e,t,n){let r=e.getParent(),i=n,a=e;return r!==null&&(t&&n===0?(i=a.getIndexWithinParent(),a=r):t||n!==a.getChildrenSize()||(i=a.getIndexWithinParent()+1,a=r)),a.getChildAtIndex(t?i-1:i)}function X_(e,t){let n=e.offset;if(e.type===`element`)return Y_(e.getNode(),t,n);{let r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){let e=t?r.getPreviousSibling():r.getNextSibling();return e===null?Y_(r.getParentOrThrow(),t,r.getIndexWithinParent()+(t?0:1)):e}}return null}function Z_(e){let t=av(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function q(e,t,n){return Tg(e,t,n,e)}function Q_(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&V(75,t),n}function $_(e){let t=e.assignedSlot||e.parentElement;return _v(t)?t.host:t}function ev(e){return m_(e)?e:hv(e)?e.ownerDocument:null}function tv(e){fg(),hg()._updateTags.add(e)}function nv(e){fg(),hg()._deferred.push(e)}function rv(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function iv(e){let t=ev(e);return t?t.defaultView:null}function av(e){let t=e._window;return t===null&&V(78),t}function ov(e){let t=e.getParentOrThrow();for(;t!==null;){if(sv(t))return t;t=t.getParentOrThrow()}return t}function sv(e){return Ig(e)||K(e)&&e.isShadowRoot()}function cv(e){let t=hg(),n=e.getType(),r=r_(t,n);r===void 0&&V(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||V(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||V(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&V(203,e.constructor.name,n,r.name,r.getType()),t}return e}function lv(e,t){!Ig(e.getParent())||K(t)||Pg(t)||V(99)}function uv(e){let t=S_(e);return t===null&&V(63,e),t}function dv(e){return(Pg(e)||K(e)&&!e.canBeEmpty())&&!e.isInline()}function fv(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function pv(e){return Kd?(e||window).getSelection():null}function mv(e){let t=iv(e);return t?t.getSelection():null}function hv(e){return gv(e)&&e.nodeType===1}function gv(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function _v(e){return gv(e)&&e.nodeType===11}function vv(e){let t=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,`i`);return e.nodeName.match(t)!==null}function yv(e){let t=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,`i`);return e.nodeName.match(t)!==null}function bv(e){if(Pg(e)&&!e.isInline())return!0;if(!K(e)||sv(e))return!1;let t=e.getFirstChild(),n=t===null||oh(t)||U(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function xv(){return hg()}var Sv=new WeakMap,Cv=new Map;function wv(e){if(!e._readOnly&&e.isEmpty())return Cv;e._readOnly||V(192);let t=Sv.get(e);return t||(t=function(e){let t=new Map;for(let[n,r]of e._nodeMap){let e=r.__type,i=t.get(e);i||(i=new Map,t.set(e,i)),i.set(n,r)}return t}(e),Sv.set(e,t)),t}function Tv(e){let t=e.constructor.clone(e);return t.afterCloneFrom(e),t}function Ev(e){return(t=Tv(e))[Zm]=!0,t;var t}function Dv(e,t){let n=parseInt(e.style.paddingInlineStart,10)||0,r=Math.round(n/40);t.setIndent(r)}function Ov(e){return!0===e.__lexicalUnmanaged}function kv(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==$m[t]}function Av(e){let t=Sf in e.prototype?e.prototype[Sf]():void 0,n=function(e){if(!(e===$m||e.prototype instanceof $m)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{Qg.version&&(n=JSON.parse(Qg.version))}catch{}V(290,e.name,t,n)}return e===Ng||e===jg||e===$m}(e),r=!n&&kv(e,`getType`)?e.getType():void 0,i,a=r;if(t)if(r)i=t[r];else for(let[e,n]of Object.entries(t))a=e,i=n;if(!n&&a&&(kv(e,`getType`)||(e.getType=()=>a),kv(e,`clone`)||(e.clone=t=>(e_(t),new e)),kv(e,`importJSON`)||(e.importJSON=i&&i.$importJSON||(t=>new e().updateFromJSON(t))),!kv(e,`importDOM`)&&i)){let{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:a}}function jv(e){let t=xv();return fg(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}var Mv=(e,t)=>{let n=e;for(;n!=null&&!Ig(n);){if(t(n))return n;n=n.getParent()}return null},Nv={next:`previous`,previous:`next`},Pv=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return ay({hasNext:Hv,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return qv(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return qv(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&V(263,Array.from(o).join(` `))}else i.insert(e);i=qv(e,this.direction)}for(let e of o.values())e.remove();return this}},Fv=class e extends Pv{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Zv(e,this.direction)}getParentCaret(e=`root`){return qv(Rv(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=Lv(this.direction);return qv(this.getNodeAtCaret(),e)||Zv(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}},Iv={root:Ig,shadowRoot:sv};function Lv(e){return Nv[e]}function Rv(e,t=`root`){return Iv[t](e)?null:e}var zv=class e extends Pv{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:qv(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return K(this.origin)?Zv(this.origin,this.direction):null}getParentCaret(e=`root`){return qv(Rv(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=Lv(this.direction);return qv(this.getNodeAtCaret(),e)||Zv(this.origin.getParentOrThrow(),e)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof e||t instanceof Bv)&&this.direction===t.direction&&this.origin.is(t.origin)}},Bv=class e extends Pv{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:Jv(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return qv(Rv(this.getParentAtCaret(),e),this.direction)}getFlipped(){return Jv(this.origin,Lv(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof zv||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return qv(this.origin,this.direction)}};function Vv(e){return e instanceof Bv}function Hv(e){return e instanceof zv}function Uv(e){return e instanceof Fv}var Wv={next:class extends Bv{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends Bv{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},Gv={next:class extends zv{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends zv{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},Kv={next:class extends Fv{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends Fv{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function qv(e,t){return e?new Gv[t](e):null}function Jv(e,t,n){return e?new Wv[t](e,Yv(e,n)):null}function Yv(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&Gd(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function Xv(e,t){return new ty(e,t)}function Zv(e,t){return K(e)?new Kv[t](e):null}function Qv(e){return e&&e.getChildCaret()||e}function $v(e){return e&&Qv(e.getAdjacentCaret())}var ey=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return Vv(t)?function(e,t){let{direction:n,origin:r}=e;return Xv(e,Yv(r,t===`focus`?Lv(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[Xv(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=Vv(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=Vv(n),i=t=>t.isSameNodeCaret(n)?null:$v(t)||t.getParentCaret(e);return ay({hasNext:e=>e!==null&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets(`root`)}},ty=class{type=`slice`;caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){let{distance:e,caret:{offset:t}}=this,n=t+e;return n<t?[n,t]:[t,n]}getTextContent(){let[e,t]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(e,t)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){let{caret:{origin:e,direction:t}}=this,[n,r]=this.getSliceIndices(),i=e.getTextContent();return Jv(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function ny(e){return iy(e,qv(O_(),e.direction))}function ry(e){return iy(e,e)}function iy(e,t){return e.direction!==t.direction&&V(265),new ey(e,t,e.direction)}function ay(e){let{initial:t,hasNext:n,step:r,map:i}=e,a=t;return{[Symbol.iterator](){return this},next(){if(!n(a))return{done:!0,value:void 0};let e={done:!1,value:i(a)};return a=r(a),e}}}function oy(e,t){let n=uy(e.origin,t.origin);switch(n===null&&V(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return sy(n)}}function sy(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function cy(e,t){return t.is(e)}function ly(e){return K(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function uy(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=new Map;for(let[t,r]=ly(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=ly(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(cy(e,r)||V(276),{commonAncestor:r,type:`ancestor`}):i===null?(cy(t,r)||V(277),{commonAncestor:r,type:`descendant`}):((K(a)||cy(e,a))&&(K(i)||cy(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||V(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function dy(e,t){let{type:n,key:r,offset:i}=e,a=uv(e.key);return n===`text`?(U(a)||V(266,a.getType(),r),Jv(a,t,i)):(K(a)||V(267,a.getType(),r),wy(a,e.offset,t))}function fy(e,t){let{origin:n,direction:r}=t,i=r===`next`;Vv(t)?e.set(n.getKey(),t.offset,`text`):Hv(t)?U(n)?e.set(n.getKey(),Yv(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+(i?1:0),`element`):(Uv(t)&&K(n)||V(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function py(e){let t=G(),n=W(t)?t:Gh();return my(n,e),A_(n),n}function my(e,t){fy(e.anchor,t.anchor),fy(e.focus,t.focus)}function hy(e){let{anchor:t,focus:n}=e,r=dy(t,`next`),i=dy(n,`next`),a=oy(r,i)<=0?`next`:`previous`;return iy(Sy(r,a),Sy(i,a))}function gy(e){let{direction:t,origin:n}=e,r=qv(n,Lv(t)).getNodeAtCaret();return r?qv(r,t):Zv(n.getParentOrThrow(),t)}function _y(e,t=`root`){let n=[e];for(let r=Uv(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(gy(r));return n}function vy(e){return!!e&&e.origin.isAttached()}function yy(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=Cy(e,r),o=_y(a.anchor,n),s=_y(a.focus.getFlipped(),n),c=new Set,l=[];for(let e of a.iterNodeCarets(n))if(Uv(e))c.add(e.origin.getKey());else if(Hv(e)){let{origin:t}=e;K(t)&&!c.has(t.getKey())||l.push(t)}for(let e of l)e.remove();for(let e of a.getTextSlices()){if(!e)continue;let{origin:t}=e.caret,n=t.getTextContentSize(),a=gy(qv(t,r)),c=t.getMode();if(Math.abs(e.distance)===n&&i===`removeEmptySlices`||c===`token`&&e.distance!==0)a.remove();else if(e.distance!==0){i=`removeEmptySlices`;let t=e.removeTextSlice(),n=e.caret.origin;if(c===`segmented`){let e=t.origin,n=Ch(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=Jv(n,r,t.offset)}n.is(o[0].origin)&&(o[0]=t),n.is(s[0].origin)&&(s[0]=t.getFlipped())}}let u,d;for(let e of o)if(vy(e)){u=by(e);break}for(let e of s)if(vy(e)){d=by(e);break}let f=function(e,t,n){if(!e||!t)return null;let r=e.getParentAtCaret(),i=t.getParentAtCaret();if(!r||!i)return null;let a=r.getParents().reverse();a.push(r);let o=i.getParents().reverse();o.push(i);let s=Math.min(a.length,o.length),c;for(c=0;c<s&&a[c]===o[c];c++);let l=(e,t)=>{let n;for(let r=c;r<e.length;r++){let i=e[r];if(sv(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,bv),d=u&&l(o,e=>n.has(e.getKey())&&bv(e));return u&&d?[u,d]:null}(u,d,c);if(f){let[e,t]=f;Zv(e,`previous`).splice(0,t.getChildren());let n=t.getParent();for(t.remove(!0);n&&n.isEmpty();){let e=n;n=n.getParent(),e.remove(!0)}}let p=[u,d,...o,...s].find(vy);if(p)return ry(Sy(by(p),e.direction));V(269,JSON.stringify(o.map(e=>e.origin.__key)))}function by(e){let t=function(e){let t=e;for(;Uv(t);){let e=$v(t);if(!Uv(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(U(t.origin))return Vv(t)?t:Jv(t.origin,n,n);let r=t.getAdjacentCaret();return Hv(r)&&U(r.origin)?Jv(r.origin,n,Lv(n)):t}function xy(e){return Vv(e)&&e.offset!==Yv(e.origin,e.direction)}function Sy(e,t){return e.direction===t?e:e.getFlipped()}function Cy(e,t){return e.direction===t?e:iy(Sy(e.focus,t),Sy(e.anchor,t))}function wy(e,t,n){let r=Zv(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return Sy(r,n)}function Ty(e){return e}function Ey(e){return e}function Dy(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function Oy(...e){let t=[];for(let n of e)if(n&&typeof n==`string`)for(let[e]of n.matchAll(/\S+/g))t.push(e);return t}function ky(e,...t){let n=Oy(...t);n.length>0&&e.classList.add(...n)}function Ay(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function jy(){return O_().getTextContent()}function My(e,t=!0){if(e)return!1;let n=jy();return t&&(n=n.trim()),n===``}function Ny(e){if(!My(e,!1))return!1;let t=O_().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(Pg(n))return!1;if(K(n)){if(!Kg(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!U(n))return!1}}}return!0}function Py(e){return()=>Ny(e)}function Fy(e){let t=xv().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function Iy(e){return Fy(Ig(e)?e:e.getParentOrThrow())}function Ly(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!f_(t)&&r!==null){let[i,a]=r,o=e.isBackward(),s=i.getNode(),c=a.getNode(),l=t.is(s),u=t.is(c);if(l||u){let[r,i]=Ih(e),a=s.is(c),l=t.is(o?c:s),u=t.is(o?s:c),d,f=0;a?(f=r>i?i:r,d=r>i?r:i):l?(f=o?i:r,d=void 0):u&&(f=0,d=o?r:i);let p=t.__text.slice(f,d);p!==t.__text&&(n===`clone`&&(t=Ev(t)),t.__text=p)}}return t}function Ry(e){let t=zy(e);return t!==null&&t.writingMode===`vertical-rl`}function zy(e){let t=e.anchor.getNode();return K(t)?Fy(t):Iy(t)}function By(e,t){let n=Ry(e)?!t:t;Hy(e)&&(n=!n);let r=dy(e.focus,n?`previous`:`next`);if(xy(r))return!1;for(let e of ny(r)){if(Uv(e))return!e.origin.isInline();if(!K(e.origin)){if(Pg(e.origin))return!0;break}}return!1}function Vy(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function Hy(e){let t=zy(e);return t!==null&&t.direction===`rtl`}function Uy(e,t,n){let r=Hy(e),i;i=Ry(e)||r?!n:n,Vy(e,t,i,`character`)}var Wy=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Gy=Wy&&`documentMode`in document?document.documentMode:null;Wy&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Wy&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),!(!Wy||!(`InputEvent`in window)||Gy)&&`getTargetRanges`in new window.InputEvent(`input`),Wy&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&window.MSStream,Wy&&/Android/.test(navigator.userAgent),Wy&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Wy&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Wy&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent);function Ky(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}var qy=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?L.useLayoutEffect:L.useEffect;function Jy({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,L.useState)(e.isEditable()),T=(0,L.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,L.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return qy(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,R.jsx)(`div`,{"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":C&&g===`combobox`?!!o:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y,...x})}var Yy=(0,L.forwardRef)(Jy);function Xy(e){return e.getEditorState().read(Py(e.isComposing()))}var Zy=(0,L.forwardRef)(Qy);function Qy(e,t){let{placeholder:n,...r}=e,[i]=Wd();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Yy,{editor:i,...r,ref:t}),n!=null&&(0,R.jsx)($y,{editor:i,content:n})]})}function $y({content:e,editor:t}){let n=function(e){let[t,n]=(0,L.useState)(()=>Xy(e));return qy(()=>{function t(){n(Xy(e))}return t(),Ay(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,L.useState)(t.isEditable());if((0,L.useLayoutEffect)(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,R.jsx)(`div`,{"aria-hidden":!0,children:a})}var eb=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,tb=eb?L.useLayoutEffect:L.useEffect,nb={tag:eh};function rb({initialConfig:e,children:t}){let n=(0,L.useMemo)(()=>{let{theme:t,namespace:n,nodes:r,onError:i,editorState:a,html:o}=e,s=Ud(null,t),c=Yg({editable:e.editable,html:o,namespace:n,nodes:r,onError:e=>i(e,c),theme:t});return function(e,t){if(t!==null){if(t===void 0)e.update(()=>{let t=O_();if(t.isEmpty()){let n=Gg();t.append(n);let r=eb?document.activeElement:null;(G()!==null||r!==null&&r===e.getRootElement())&&n.select()}},nb);else if(t!==null)switch(typeof t){case`string`:{let n=e.parseEditorState(t);e.setEditorState(n,nb);break}case`object`:e.setEditorState(t,nb);break;case`function`:e.update(()=>{O_().isEmpty()&&t(e)},nb)}}}(c,a),[c,s]},[]);return tb(()=>{let t=e.editable,[r]=n;r.setEditable(t===void 0||t)},[]),(0,R.jsx)(Hd.Provider,{value:n,children:t})}var ib=(0,L.createContext)(null),ab={didCatch:!1,error:null},ob=class extends L.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=ab}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(ab))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&sb(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(ab))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,L.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,L.createElement)(ib.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function sb(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function cb({children:e,onError:t}){return(0,R.jsx)(ob,{fallback:(0,R.jsx)(`div`,{style:{border:`1px solid #f00`,color:`#f00`,padding:`8px`},children:`An error was thrown.`}),onError:t,children:e})}var lb=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?L.useLayoutEffect:L.useEffect;function ub(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function db(){return function(e){let[t]=Wd(),n=(0,L.useMemo)(()=>e(t),[t,e]),[r,i]=(0,L.useState)(()=>n.initialValueFn()),a=(0,L.useRef)(r);return lb(()=>{let{initialValueFn:e,subscribe:t}=n,r=e();return a.current!==r&&(a.current=r,i(r)),t(e=>{a.current=e,i(e)})},[n,e]),r}(ub)}var fb=Symbol.for(`preact-signals`);function pb(){if(vb>1)return void vb--;let e,t=!1;for(function(){let e=_b;for(_b=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();hb!==void 0;){let n=hb;for(hb=void 0,yb++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&wb(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(yb=0,vb--,t)throw e}var mb,hb;function gb(e){let t=mb;mb=void 0;try{return e()}finally{mb=t}}var _b,vb=0,yb=0,bb=0,xb=0;function Sb(e){if(mb===void 0)return;let t=e.n;return t===void 0||t.t!==mb?(t={i:0,S:e,p:mb.s,n:void 0,t:mb,e:void 0,x:void 0,r:t},mb.s!==void 0&&(mb.s.n=t),mb.s=t,e.n=t,32&mb.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=mb.s,t.n=void 0,mb.s.n=t,mb.s=t),t):void 0}function Cb(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function wb(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Tb(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Eb(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function Db(e,t){Cb.call(this,void 0),this.x=e,this.s=void 0,this.g=xb-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function Ob(e){let t=e.m;if(e.m=void 0,typeof t==`function`){vb++;let n=mb;mb=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,kb(e),t}finally{mb=n,pb()}}}function kb(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ob(e)}function Ab(e){if(mb!==this)throw Error(`Out-of-order effect`);Eb(this),mb=e,this.f&=-2,8&this.f&&kb(this),pb()}function jb(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name}function Mb(e,t){let n=new jb(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}Cb.prototype.brand=fb,Cb.prototype.h=function(){return!0},Cb.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?gb(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},Cb.prototype.U=function(e){if(this.t!==void 0){let t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&gb(()=>{var e;(e=this.Z)==null||e.call(this)}))}},Cb.prototype.subscribe=function(e){return Mb(()=>{let t=this.value,n=mb;mb=void 0;try{e(t)}finally{mb=n}},{name:`sub`})},Cb.prototype.valueOf=function(){return this.value},Cb.prototype.toString=function(){return this.value+``},Cb.prototype.toJSON=function(){return this.value},Cb.prototype.peek=function(){let e=mb;mb=void 0;try{return this.value}finally{mb=e}},Object.defineProperty(Cb.prototype,`value`,{get(){let e=Sb(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(yb>100)throw Error(`Cycle detected`);(function(e){vb!==0&&yb===0&&e.l!==bb&&(e.l=bb,_b={S:e,v:e.v,i:e.i,o:_b})})(this),this.v=e,this.i++,xb++,vb++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{pb()}}}}),Db.prototype=new Cb,Db.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===xb))return!0;if(this.g=xb,this.f|=1,this.i>0&&!wb(this))return this.f&=-2,!0;let e=mb;try{Tb(this),mb=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return mb=e,Eb(this),this.f&=-2,!0},Db.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Cb.prototype.S.call(this,e)},Db.prototype.U=function(e){if(this.t!==void 0&&(Cb.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}},Db.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Db.prototype,`value`,{get(){if(1&this.f)throw Error(`Cycle detected`);let e=Sb(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),jb.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e==`function`&&(this.m=e)}finally{e()}},jb.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Ob(this),Tb(this),vb++;let e=mb;return mb=this,Ab.bind(this,e)},jb.prototype.N=function(){2&this.f||(this.f|=2,this.u=hb,hb=this)},jb.prototype.d=function(){this.f|=8,1&this.f||kb(this)},jb.prototype.dispose=function(){this.d()};function Nb(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}Ff(`format`,{parse:e=>typeof e==`number`?e:0});function Pb(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Fb(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)n[e]=Fb(n[e],r[e]);return e}return t}var Ib=0,Lb=1,Rb=2,zb=3,Bb=4,Vb=5,Hb=6,Ub=7;function Wb(e){return e.id===Ib}function Gb(e){return e.id===Rb}function Kb(e){return function(e){return e.id===Lb}(e)||Pb(305,String(e.id),String(Lb)),Object.assign(e,{id:Rb})}var qb=new Set,Jb=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:Ib}}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):Dy;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Gb(t)||Pb(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=function(e,t,n){return Object.assign(e,{config:t,id:zb,registerState:n})}(t,this.mergeConfigs(),n),a;this.state=i,this.extension.init&&(a=this.extension.init(e,i.config,n)),this.state=function(e,t,n){return Object.assign(e,{id:Bb,initResult:t,registerState:n})}(i,a,r)}build(e){let t=this.state,n;t.id!==Bb&&Pb(307,String(t.id),String(Vb)),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(e,t,n){return Object.assign(e,{id:Vb,output:t,registerState:n})}(t,n,r)}register(e,t){this._signal=t;let n=this.state;n.id!==Vb&&Pb(308,String(n.id),String(Vb));let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=function(e){return Object.assign(e,{id:Hb})}(n),()=>{let e=this.state;e.id!==Ub&&Pb(309,String(n.id),String(Ub)),this.state=function(e){return Object.assign(e,{id:Vb})}(e),r&&r()}}afterRegistration(e){let t=this.state,n;return t.id!==Hb&&Pb(310,String(t.id),String(Hb)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=function(e){return Object.assign(e,{id:Ub})}(t),n}getSignal(){return this._signal===void 0&&Pb(311),this._signal}getInitResult(){this.extension.init===void 0&&Pb(312,this.extension.name);let e=this.state;return function(e){return e.id>=Bb}(e)||Pb(313,String(e.id),String(Bb)),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return function(e){return e.id>=zb}(e)||Pb(314,String(e.id),String(zb)),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Pb(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Pb(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=Ub}(e)||Pb(316,String(e.id),String(Ub)),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||qb}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;(function(e){return e.id>=Vb})(e)||Pb(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}},Yb={tag:eh};function Xb(){let e=O_();e.isEmpty()&&e.append(Gg())}var Zb=Ty({config:Ey({setOptions:Yb,updateOptions:Yb}),init:({$initialEditorState:e=Xb})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){let i=r.getInitResult();if(!i.initialized){i.initialized=!0;let{$initialEditorState:r}=i;if(Bg(r))e.setEditorState(r,n);else if(typeof r==`function`)e.update(()=>{r(e)},t);else if(r&&(typeof r==`string`||typeof r==`object`)){let t=e.parseEditorState(r);e.setEditorState(t,n)}}return()=>{}},name:`@lexical/extension/InitialState`,nodes:[Fg,mh,rh,Th,Ug]}),Qb=Symbol.for(`@lexical/extension/LexicalBuilder`);function $b(){}function ex(e){throw e}function tx(e){return Array.isArray(e)?e:[e]}var nx=`0.43.0+prod.esm`,rx=class e{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=nx,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[tx(Zb)];for(let e of t)n.push(tx(e));return new e(n)}static maybeFromEditor(t){let n=t[Qb];return n&&(n.PACKAGE_VERSION!==nx&&Pb(292,n.PACKAGE_VERSION,nx),n instanceof e||Pb(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&Pb(294),n}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(Yg({...n,...t?{onError:e=>{t(e,r)}}:{}}),{[Qb]:this});for(let e of this.sortedExtensionReps())e.build(r);return r}buildEditor(){let e=$b;function t(){try{e()}finally{e=$b}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=Ay(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&Pb(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]))}addExtension(e){this._sortedExtensionReps!==void 0&&Pb(296);let[t]=tx(e);typeof t.name!=`string`&&Pb(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&Pb(298,t.name),!n){n=new Jb(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&Pb(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&Pb(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=tx(e);this.addEdge(t.name,n[0].name,n.slice(1)),this.addExtension(n)}for(let[e,n]of t.peerDependencies||[])this.addEdge(t.name,e,n?[n]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Gb(i))return;let a=n.extension.name;var o;Wb(i)||Pb(300,a,r||`[unknown]`),Wb(o=i)||Pb(304,String(o.id),String(Ib)),i=Object.assign(o,{id:Lb}),n.state=i;let s=this.outgoingConfigEdges.get(a);if(s)for(let e of s.keys()){let n=this.extensionNameMap.get(e);n&&t(n,a)}i=Kb(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Wb(e.state)&&t(e);for(let t of e)for(let[e,n]of this.outgoingConfigEdges.get(t.extension.name)||[])if(n.length>0){let t=this.extensionNameMap.get(e);if(t)for(let e of n)t.configs.add(e)}for(let[e,...t]of this.roots)if(t.length>0){let n=this.extensionNameMap.get(e.name);n===void 0&&Pb(301,e.name);for(let e of t)n.configs.add(e)}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let n of t){let t=n.register(e,i);t&&r.push(t)}for(let n of t){let t=n.afterRegistration(e);t&&r.push(t)}return Ay(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},a={},o=this.sortedExtensionReps();for(let s of o){let{extension:o}=s;if(o.onError!==void 0&&(e.onError=o.onError),o.disableEvents!==void 0&&(e.disableEvents=o.disableEvents),o.parentEditor!==void 0&&(e.parentEditor=o.parentEditor),o.editable!==void 0&&(e.editable=o.editable),o.namespace!==void 0&&(e.namespace=o.namespace),o.$initialEditorState!==void 0&&(e.$initialEditorState=o.$initialEditorState),o.nodes)for(let e of Nb(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&Pb(302,o.name,e.replace.name,t.extension.name),n.set(e.replace,s)}t.add(e)}if(o.html){if(o.html.export)for(let[e,t]of o.html.export.entries())r.set(e,t);o.html.import&&Object.assign(i,o.html.import)}o.theme&&Fb(a,o.theme)}Object.keys(a).length>0&&(e.theme=a),t.size&&(e.nodes=[...t]);let s=Object.keys(i).length>0,c=r.size>0;(s||c)&&(e.html={},s&&(e.html.import=i),c&&(e.html.export=r));for(let t of o)t.init(e);return e.onError||=ex,e}},ix=class e extends Ng{static getType(){return`horizontalrule`}static clone(t){return new e(t.__key)}static importJSON(e){return ox().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:ax,priority:0})}}exportDOM(){return{element:document.createElement(`hr`)}}createDOM(e){let t=document.createElement(`hr`);return ky(t,e.theme.hr),t}getTextContent(){return`
13
+ `}isInline(){return!1}updateDOM(){return!1}};function ax(){return{node:ox()}}function ox(){return jv(ix)}var sx=Ty({name:`@lexical/react/ReactProvider`}),cx=m(s(),1);function lx(e){let t=window.location.origin,n=n=>{if(n.origin!==t)return;let r=e.getRootElement();if(document.activeElement!==r)return;let i=n.data;if(typeof i==`string`){let t;try{t=JSON.parse(i)}catch{return}if(t&&t.protocol===`nuanria_messaging`&&t.type===`request`){let r=t.payload;if(r&&r.functionId===`makeChanges`){let t=r.args;if(t){let[r,i,a,o,s]=t;e.update(()=>{let e=G();if(W(e)){let t=e.anchor,c=t.getNode(),l=0,u=0;if(U(c)&&r>=0&&i>=0&&(l=r,u=r+i,e.setTextNodeRange(c,l,c,u)),l===u&&a===``||(e.insertRawText(a),c=t.getNode()),U(c)){l=o,u=o+s;let t=c.getTextContentSize();l=l>t?t:l,u=u>t?t:u,e.setTextNodeRange(c,l,c,u)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener(`message`,n,!0),()=>{window.removeEventListener(`message`,n,!0)}}function ux(e,t){if(typeof document>`u`||typeof window>`u`&&global.window===void 0)throw Error(`To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.`);let n=document.createElement(`div`),r=O_().getChildren();for(let i=0;i<r.length;i++)dx(e,r[i],n,t);return n.innerHTML}function dx(e,t,n,r=null){let i=r===null||t.isSelected(r),a=K(t)&&t.excludeFromCopy(`html`),o=t;r!==null&&U(t)&&(o=Ly(r,t,`clone`));let s=K(o)?o.getChildren():[],c=r_(e,o.getType()),l;l=c&&c.exportDOM!==void 0?c.exportDOM(e,o):o.exportDOM(e);let{element:u,after:d}=l;if(!u)return!1;let f=document.createDocumentFragment();for(let n=0;n<s.length;n++){let a=s[n],o=dx(e,a,f,r);!i&&K(t)&&o&&t.extractWithChild(a,r,`html`)&&(i=!0)}if(i&&!a){if((hv(u)||_v(u))&&u.append(f),n.append(u),d){let e=d.call(o,u);e&&(_v(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(f);return i}function fx(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function px(e,t=G()){return t??fx(166),W(t)&&t.isCollapsed()||t.getNodes().length===0?``:ux(e,t)}function mx(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var hx=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,gx=hx&&`documentMode`in document?document.documentMode:null,_x=hx&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),vx=!(!hx||!(`InputEvent`in window)||gx)&&`getTargetRanges`in new window.InputEvent(`input`),yx=hx&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,bx=hx&&/Android/.test(navigator.userAgent),xx=hx&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!bx,Sx=hx&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Cx=hx&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&_x&&!Sx;function wx(e,t){t.update(()=>{if(e!==null){let n=Ky(e,KeyboardEvent)?null:e.clipboardData,r=G();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=px(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function Tx(e){return Ay(e.registerCommand(Ip,e=>{let t=G();return!!W(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(Hp,e=>{let t=G();return!!W(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(Up,e=>{let t=G();return!!W(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(zp,e=>{let t=G();if(!W(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)mx(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(Vp,()=>{let e=G();return!!W(e)&&(e.removeText(),!0)},0),e.registerCommand(Lp,e=>{let t=G();return!!W(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(Rp,()=>{let e=G();return!!W(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(Xp,e=>{let t=G();if(!W(t))return!1;let n=e,r=n.shiftKey;return!!By(t,!0)&&(n.preventDefault(),Uy(t,r,!0),!0)},0),e.registerCommand(Jp,e=>{let t=G();if(!W(t))return!1;let n=e,r=n.shiftKey;return!!By(t,!1)&&(n.preventDefault(),Uy(t,r,!1),!0)},0),e.registerCommand(nm,t=>!!W(G())&&(!yx||navigator.language!==`ko-KR`)&&(t.preventDefault(),e.dispatchCommand(Ip,!0)),0),e.registerCommand(im,t=>!!W(G())&&(t.preventDefault(),e.dispatchCommand(Ip,!1)),0),e.registerCommand(em,t=>{if(!W(G()))return!1;if(t!==null){if((yx||xx||Cx)&&vx)return!1;t.preventDefault()}return e.dispatchCommand(Lp,!1)},0),e.registerCommand(fm,()=>(K_(),!0),0),e.registerCommand(um,t=>!!W(G())&&(wx(t,e),!0),0),e.registerCommand(dm,t=>!!W(G())&&(function(e,t){wx(e,t),t.update(()=>{let e=G();W(e)&&e.removeText()})}(t,e),!0),0),e.registerCommand(Bp,t=>!!W(G())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=G(),n=Ky(e,ClipboardEvent)?e.clipboardData:null;n!=null&&W(t)&&mx(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(om,e=>!!W(G())&&(e.preventDefault(),!0),0),e.registerCommand(sm,e=>!!W(G())&&(e.preventDefault(),!0),0))}function Ex(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Dx=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?L.useLayoutEffect:L.useEffect;function Ox({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,L.useState)(()=>e.getDecorators());return Dx(()=>e.registerDecoratorListener(e=>{(0,cx.flushSync)(()=>{r(e)})}),[e]),(0,L.useEffect)(()=>{r(e.getDecorators())},[e]),(0,L.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,R.jsx)(t,{onError:t=>e._onError(t),children:(0,R.jsx)(L.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,cx.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function kx({editor:e,ErrorBoundary:t}){return function(e){let t=rx.maybeFromEditor(e);if(t&&t.hasExtensionByName(sx.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&Ex(320,e);return!0}return!1}(e)?null:(0,R.jsx)(Ox,{editor:e,ErrorBoundary:t})}function Ax(e){return e.getEditorState().read(Py(e.isComposing()))}function jx({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=Wd();return function(e){Dx(()=>Ay(Tx(e),lx(e)),[e])}(r),(0,R.jsxs)(R.Fragment,{children:[e,(0,R.jsx)(Mx,{content:t}),(0,R.jsx)(kx,{editor:r,ErrorBoundary:n})]})}function Mx({content:e}){let[t]=Wd(),n=function(e){let[t,n]=(0,L.useState)(()=>Ax(e));return Dx(()=>{function t(){n(Ax(e))}return t(),Ay(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=db();return n?typeof e==`function`?e(r):e:null}function Nx(e){return e===`file`?[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-[min(100%,17rem)]`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`border-border`,`bg-muted`,`px-2`,`align-baseline`,`text-foreground`,`transition-[border-color,background-color,box-shadow,color]`,`duration-150`].join(` `):[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-full`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`border-primary/12`,`bg-primary/8`,`px-2`,`align-baseline`,`text-[11px]`,`font-medium`,`text-primary`,`transition`].join(` `)}function Px({label:e,tokenKind:t}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:t===`file`?`inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-card text-muted-foreground ring-1 ring-border`:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary/70`,children:t===`file`?(0,R.jsx)(Pi,{"aria-hidden":`true`,className:`h-3 w-3`}):t===`panel_app`?(0,R.jsx)(E,{"aria-hidden":`true`,className:`h-3 w-3`}):(0,R.jsx)(ea,{"aria-hidden":`true`,className:`h-3 w-3`})}),(0,R.jsx)(`span`,{className:t===`file`?`min-w-0 flex-1 truncate text-[12px] font-medium text-foreground`:`truncate`,children:e})]})}var Fx=class e extends Ng{static getType(){return`chat-composer-token`}static clone(t){return new e(t.__composerId,t.__tokenKind,t.__tokenKey,t.__label,t.__key)}static importJSON(e){return Ix({composerId:e.composerId,label:e.label,tokenKey:e.tokenKey,tokenKind:e.tokenKind})}constructor(e,t,n,r,i){super(i),this.applyTokenDom=e=>{e.contentEditable=`false`,e.dataset.composerNodeId=this.__composerId,e.dataset.composerNodeType=`token`,e.dataset.composerTokenKind=this.__tokenKind,e.dataset.composerTokenKey=this.__tokenKey,e.dataset.composerLabel=this.__label,e.title=this.__label,e.className=Nx(this.__tokenKind)},this.createDOM=(e,t)=>{let n=document.createElement(`span`);return this.applyTokenDom(n),n},this.updateDOM=(e,t)=>(this.applyTokenDom(t),!1),this.decorate=()=>(0,R.jsx)(Px,{label:this.__label,tokenKind:this.__tokenKind}),this.exportJSON=()=>({composerId:this.__composerId,label:this.__label,tokenKey:this.__tokenKey,tokenKind:this.__tokenKind,type:`chat-composer-token`,version:1}),this.getComposerId=()=>this.getLatest().__composerId,this.getTokenKind=()=>this.getLatest().__tokenKind,this.getTokenKey=()=>this.getLatest().__tokenKey,this.getLabel=()=>this.getLatest().__label,this.getTextContent=()=>``,this.isInline=()=>!0,this.isIsolated=()=>!0,this.isKeyboardSelectable=()=>!1,this.__composerId=e,this.__tokenKind=t,this.__tokenKey=n,this.__label=r}};function Ix(e){let{composerId:t,label:n,tokenKey:r,tokenKind:i}=e;return cv(new Fx(t,i,r,n))}function Lx(e){return e instanceof Fx}function Rx(){let e=O_(),t=e.getFirstChild();if(!K(t))return{descriptors:[],paragraphKey:e.getKey(),paragraphSize:0,totalLength:0};let n=t.getChildren(),r=[],i=0;for(let[e,t]of n.entries()){if(U(t)){let n=t.getTextContent();r.push({index:e,key:t.getKey(),length:n.length,node:t,start:i,text:n,type:`text`}),i+=n.length;continue}if(Lx(t)){r.push({index:e,key:t.getKey(),length:1,node:t,start:i,type:`token`}),i+=1;continue}r.push({index:e,key:t.getKey(),length:t.getTextContent().length,node:t,start:i,type:`linebreak`}),i+=t.getTextContent().length}return{descriptors:r,paragraphKey:t.getKey(),paragraphSize:n.length,totalLength:i}}function zx(e){let{descriptors:t,paragraphKey:n,paragraphSize:r,totalLength:i}=Rx(),a=Math.max(0,Math.min(e,i));if(t.length===0)return{key:n,offset:0,type:`element`};for(let e of t){let r=e.start+e.length;if(e.type===`text`&&a>=e.start&&a<=r)return{key:e.key,offset:a-e.start,type:`text`};if(e.type!==`text`){if(a===e.start)return{key:n,offset:e.index,type:`element`};if(a===r){let r=t[e.index+1];return r?.type===`text`&&r.length===0?{key:r.key,offset:0,type:`text`}:{key:n,offset:e.index+1,type:`element`}}}}return{key:n,offset:r,type:`element`}}function Bx(e){let{descriptors:t,paragraphKey:n,totalLength:r}=Rx();if(e.key===n){let n=t[e.offset-1];return n?n.start+n.length:0}let i=t.find(t=>t.key===e.key);return i?i.start+Math.min(e.offset,i.length):r}function Vx(e){if(e.type===`element`)return Bx(e);let{descriptors:t,totalLength:n}=Rx(),r=t.find(t=>t.key===e.key);return r?r.start+Math.min(e.offset,r.length):n}function Hx(){let{descriptors:e}=Rx(),t=[],n=``,r=``,i=()=>{n.length!==0&&(t.push({id:r,type:`text`,text:n}),n=``,r=``)};for(let a of e){if(a.type===`text`){n.length===0&&(r=a.key),n+=a.text;continue}if(a.type===`linebreak`){n.length===0&&(r=a.key),n+=`
14
+ `;continue}i();let e=a.node;t.push({id:e.getComposerId(),label:e.getLabel(),tokenKey:e.getTokenKey(),tokenKind:e.getTokenKind(),type:`token`})}return i(),vu(t)}function Ux(e){return e.read(()=>{let e=G(),t=Hx();return W(e)?{nodes:t,selection:{start:Math.min(Vx(e.anchor),Vx(e.focus)),end:Math.max(Vx(e.anchor),Vx(e.focus))}}:{nodes:t,selection:null}})}function Wx(e,t){let n=O_();n.clear();let r=Gg();n.append(r);for(let t of vu(e)){if(t.type===`token`){r.append(Ix({composerId:t.id,label:t.label,tokenKey:t.tokenKey,tokenKind:t.tokenKind}));continue}let e=t.text.split(`
15
+ `);for(let[t,n]of e.entries())n.length>0&&r.append(Ch(n)),t<e.length-1&&r.append(ah())}if(Lx(r.getLastChild())&&r.append(Ch(``)),!t)return;let i=Gh(),a=zx(t.start),o=zx(t.end);i.anchor.set(a.key,a.offset,a.type),i.focus.set(o.key,o.offset,o.type),A_(i)}function Gx(e,t,n){e.update(()=>{Wx(t,n)})}function Kx(e,t){e.update(()=>{let e=Gh(),n=zx(t.start),r=zx(t.end);e.anchor.set(n.key,n.offset,n.type),e.focus.set(r.key,r.offset,r.type),A_(e)})}function qx(e){return e.reduce((e,t)=>e+hu(t),0)}function Jx(e){let{label:t,nodes:n,selection:r,tokenKey:i,tokenKind:a,trigger:o}=e,s=qx(n),[c,l]=r?[Math.min(r.start,r.end),Math.max(r.start,r.end)]:[s,s],u=o?.start??c;return{nodes:Du(n,u,o?.end??l,[mu({label:t,tokenKey:i,tokenKind:a})]),selection:{start:u+1,end:u+1}}}function Yx(e){let{label:t,nodes:n,selection:r,tokenKey:i,tokenKind:a,triggerSpecs:o}=e;return xu(n,a).includes(i)?{nodes:vu(n),selection:r}:Jx({label:t,nodes:n,selection:r,tokenKey:i,tokenKind:a,trigger:ju(n,r,o??[du])})}function Xx(e){let{item:t,nodes:n,selection:r,triggerSpecs:i}=e,a=t.tokenKind??(t.value?`skill`:void 0),o=t.tokenKey??t.value;if(!a||!o){let e=ju(n,r,i??[du]);return e?{nodes:vu(Du(n,e.start,e.end,[])),selection:{start:e.start,end:e.start}}:{nodes:vu(n),selection:r}}return Yx({label:t.title,nodes:n,selection:r,tokenKey:o,tokenKind:a,triggerSpecs:i})}function Zx(e){return e.map(e=>e.type===`text`?`text:${e.text}`:`token:${e.tokenKind}:${e.tokenKey}:${e.label}`).join(``)}function Qx(e){let{nodes:t,selection:n,text:r}=e,i=qx(t),[a,o]=n?[Math.min(n.start,n.end),Math.max(n.start,n.end)]:[i,i],s=a+r.length;return{nodes:Du(t,a,o,[pu(r)]),selection:{start:s,end:s}}}function $x(e){let{label:t,nodes:n,selection:r,tokenKey:i}=e;return Jx({label:t,nodes:n,selection:r,tokenKey:i,tokenKind:`file`})}function eS(e){let{label:t,nodes:n,selection:r,tokenKey:i}=e;return xu(n,`skill`).includes(i)?{nodes:vu(n),selection:r}:Jx({label:t,nodes:n,selection:r,tokenKey:i,tokenKind:`skill`,trigger:Mu(n,r)})}function tS(e){let{nextKeys:t,nodes:n,options:r,selection:i}=e,a=xu(n,`skill`),o=new Map(r.map(e=>[e.key,e])),s=t.find(e=>!a.includes(e));if(s)return eS({label:o.get(s)?.label??s,nodes:n,selection:i,tokenKey:s});let c=a.find(e=>!t.includes(e));return c?{nodes:Ou(n,e=>e.tokenKind===`skill`&&e.tokenKey===c),selection:i}:{nodes:vu(n),selection:i}}function nS(e){let{direction:t,nodes:n,selection:r}=e,i=qx(n),[a,o]=r?[Math.min(r.start,r.end),Math.max(r.start,r.end)]:[i,i],s=a,c=o;if(s===c)if(t===`backward`&&s>0)--s;else if(t===`forward`&&c<i)c+=1;else return{nodes:vu(n),selection:{start:s,end:c}};return{nodes:Du(n,s,c,[]),selection:{start:s,end:s}}}function rS(e){let{canStopGeneration:t,isComposing:n,isSending:r,key:i,shiftKey:a}=e;return i===`Escape`?r&&t?{type:`stop-generation`}:{type:`noop`}:i===`Enter`&&a?{type:`insert-line-break`}:i===`Enter`?{type:`send-message`}:!n&&(i===`Backspace`||i===`Delete`)?{type:`delete-content`,direction:i===`Backspace`?`backward`:`forward`}:{type:`noop`}}function iS(e){return JSON.stringify(e.map(e=>e.type===`text`?{text:e.text,type:e.type}:{label:e.label,tokenKey:e.tokenKey,tokenKind:e.tokenKind,type:e.type}))}function aS(e){let{disabled:t,event:n,isComposing:r,publishSnapshot:i,snapshotReader:a}=e,o=n.nativeEvent,s=o.inputType===`insertText`||o.inputType===`insertReplacementText`;t||r||o.isComposing||!s||!o.data||(n.preventDefault(),i(Qx({nodes:a().nodes,selection:a().selection,text:o.data}),{inputSurfaceReason:{type:`insert-text`,text:o.data}}))}function oS(e){let{compositionStartSnapshot:t,data:n,fallbackSnapshot:r,publishSnapshot:i,snapshotReader:a}=e,o=a(),s=r(),c=t??o;i(iS(s.nodes)===iS(c.nodes)&&n.length>0?Qx({nodes:c.nodes,selection:c.selection,text:n}):s,{forcePublish:!0,inputSurfaceReason:{type:`insert-text`,text:n}})}function sS(e){let{actions:t,nativeEvent:n,publishSnapshot:r,snapshot:i}=e,a=rS({canStopGeneration:t.canStopGeneration,isComposing:n.isComposing,isSending:t.isSending,key:n.key,shiftKey:n.shiftKey});switch(a.type!==`noop`&&n.preventDefault(),a.type){case`stop-generation`:return t.onStop(),!0;case`insert-line-break`:return r(Qx({nodes:i.nodes,selection:i.selection,text:`
16
+ `}),{inputSurfaceReason:{type:`insert-text`,text:`
17
+ `}}),!0;case`send-message`:return t.onSend(),!0;case`delete-content`:return r(nS({direction:a.direction,nodes:i.nodes,selection:i.selection}),{inputSurfaceReason:{type:`delete-content`}}),!0;case`noop`:return!1}}function cS(e){return{current:e}}function lS(e){return e.reduce((e,t)=>e+(t.type===`text`?t.text.length:1),0)}var uS=class{constructor(){this.isApplyingExternalUpdateRef=cS(!1),this.isComposingRef=cS(!1),this.pendingOwnerSignatureRef=cS(null),this.pendingSelectionRef=cS(null),this.selectionRef=cS(null),this.shouldFocusAfterSyncRef=cS(!1),this.compositionStartSnapshotRef=cS(null),this.editorSignatureRef=cS(``),this.lastPublishedSignatureRef=cS(``),this.pendingInputSurfaceReasonRef=cS(null),this.editor=null,this.runtime=null,this.configureRuntime=e=>{this.runtime=e},this.bindEditor=e=>(this.editor=e,()=>{this.editor===e&&(this.editor=null)}),this.registerEditorListeners=e=>Ay(e.registerUpdateListener(({editorState:e})=>{let t=this.getRuntime();this.handleEditorUpdate(e,t.callbacks)}),e.registerCommand(Ap,()=>{let t=this.getRuntime();return this.handleSelectionChange(e,t.callbacks),!1},0),e.registerCommand(mm,()=>(this.getRuntime().callbacks.onInputSurfaceOpenChange?.(!1),!1),0),e.registerCommand(qp,e=>{let t=this.getRuntime();return this.handleKeyDown({actions:t.actions,callbacks:t.callbacks,event:e,fallbackNodes:t.fallbackNodes})},3)),this.syncExternalState=(e,t)=>{if(this.isComposingRef.current)return;let n=Zx(t),r=this.pendingSelectionRef.current,i=this.pendingOwnerSignatureRef.current;if(i){if(n===i)this.pendingOwnerSignatureRef.current=null;else if(n!==this.editorSignatureRef.current)return}let a=n!==this.editorSignatureRef.current;if(!(!a&&!r)&&(this.startApplyingExternalUpdate(),a?(Gx(e,t,r),this.editorSignatureRef.current=n,this.lastPublishedSignatureRef.current=n):r&&Kx(e,r),r&&(this.selectionRef.current=r,this.pendingSelectionRef.current=null),this.shouldFocusAfterSyncRef.current)){this.shouldFocusAfterSyncRef.current=!1;let t=this.selectionRef.current;e.focus(()=>{t&&Kx(e,t)})}},this.publishSnapshot=(e,t,n)=>{this.selectionRef.current=e.selection,this.pendingSelectionRef.current=e.selection,n?.focusAfterSync&&(this.shouldFocusAfterSyncRef.current=!0);let r=Zx(e.nodes),{editor:i}=this;this.pendingOwnerSignatureRef.current=r,i&&(this.startApplyingExternalUpdate(),Gx(i,e.nodes,e.selection),this.editorSignatureRef.current=r),t.onInputSurfaceSnapshotChange?.(e.nodes,e.selection,n?.inputSurfaceReason??{type:`programmatic`}),(n?.forcePublish||r!==this.lastPublishedSignatureRef.current)&&(this.lastPublishedSignatureRef.current=r,t.onNodesChange(e.nodes))},this.focusComposer=()=>{let{editor:e}=this;if(!e)return;e.getRootElement()?.focus({preventScroll:!0});let t=this.selectionRef.current;t&&Kx(e,t),e.focus()},this.focusComposerAtEnd=e=>{let{editor:t}=this;if(!t)return;let n=lS(e??Ux(t.getEditorState()).nodes),r={start:n,end:n};if(this.selectionRef.current=r,this.pendingSelectionRef.current=r,t.getRootElement()?.focus({preventScroll:!0}),e){this.startApplyingExternalUpdate();let n=Zx(e);Gx(t,e,r),this.editorSignatureRef.current=n,this.lastPublishedSignatureRef.current=n}else Kx(t,r);t.focus(()=>{Kx(t,r)})},this.readComposerSnapshot=e=>{let{editor:t}=this;if(!t)return{nodes:e,selection:this.selectionRef.current};let n=Ux(t.getEditorState());return this.selectionRef.current=n.selection,n},this.createHandle=()=>{let e=(e,t=[du])=>{let{callbacks:n}=this.getRuntime();n.onInputSurfaceItemSelect?.(e),this.publishRuntimeSnapshot(n=>Xx({item:e,nodes:n.nodes,selection:n.selection,triggerSpecs:t}),{focusAfterSync:!0})};return{insertInputSurfaceItem:e,insertSlashItem:t=>{e(t)},insertFileToken:(e,t)=>{this.publishRuntimeSnapshot(n=>$x({label:t,nodes:n.nodes,selection:n.selection,tokenKey:e}),{focusAfterSync:!0})},insertFileTokens:e=>{this.publishRuntimeSnapshot(t=>e.reduce((e,t)=>$x({label:t.label,nodes:e.nodes,selection:e.selection,tokenKey:t.tokenKey}),t),{focusAfterSync:!0})},focusComposer:this.focusComposer,focusComposerAtEnd:this.focusComposerAtEnd,syncSelectedSkills:(e,t)=>{this.publishRuntimeSnapshot(n=>tS({nextKeys:e,nodes:n.nodes,options:t,selection:n.selection}),{focusAfterSync:!0})}}},this.handleBeforeInput=e=>{let{disabled:t,event:n}=e,{callbacks:r,fallbackNodes:i}=this.getRuntime();aS({disabled:t,event:n,isComposing:this.isComposingRef.current,publishSnapshot:(e,t)=>this.publishSnapshot(e,r,t),snapshotReader:()=>this.readComposerSnapshot(i)})},this.handleCompositionStart=()=>{let{fallbackNodes:e}=this.getRuntime();this.compositionStartSnapshotRef.current=this.readComposerSnapshot(e),this.isComposingRef.current=!0},this.handleCompositionEnd=e=>{let{data:t}=e,{callbacks:n,fallbackNodes:r}=this.getRuntime();this.isComposingRef.current=!1,oS({compositionStartSnapshot:this.compositionStartSnapshotRef.current,data:t,fallbackSnapshot:()=>this.readComposerSnapshot(r),publishSnapshot:(e,t)=>this.publishSnapshot(e,n,t),snapshotReader:()=>this.readComposerSnapshot(r)}),this.compositionStartSnapshotRef.current=null},this.handleKeyDown=e=>{let{actions:t,callbacks:n,event:r,fallbackNodes:i}=e;r.key.length===1&&!r.isComposing&&!r.altKey&&!r.ctrlKey&&!r.metaKey&&(this.pendingInputSurfaceReasonRef.current={type:`insert-text`,text:r.key});let a=this.readComposerSnapshot(i);return n.onInputSurfaceKeyDown?.(r)?!0:sS({actions:t,nativeEvent:r,publishSnapshot:(e,t)=>this.publishSnapshot(e,n,t),snapshot:a})},this.handleEditorUpdate=(e,t)=>{let n=Ux(e),r=Zx(n.nodes);this.editorSignatureRef.current=r,!(this.isApplyingExternalUpdateRef.current||this.isComposingRef.current)&&(this.selectionRef.current=n.selection,t.onInputSurfaceSnapshotChange?.(n.nodes,n.selection,this.consumeInputSurfaceReason()??{type:`sync`}),r!==this.lastPublishedSignatureRef.current&&(this.lastPublishedSignatureRef.current=r,t.onNodesChange(n.nodes)))},this.handleSelectionChange=(e,t)=>{let n=Ux(e.getEditorState());this.isComposingRef.current||(this.selectionRef.current=n.selection,t.onInputSurfaceSnapshotChange?.(n.nodes,n.selection,{type:`selection`}))},this.consumeInputSurfaceReason=()=>{let e=this.pendingInputSurfaceReasonRef.current;return this.pendingInputSurfaceReasonRef.current=null,e},this.publishRuntimeSnapshot=(e,t)=>{let{callbacks:n,fallbackNodes:r}=this.getRuntime();this.publishSnapshot(e(this.readComposerSnapshot(r)),n,t)},this.startApplyingExternalUpdate=()=>{this.isApplyingExternalUpdateRef.current=!0,requestAnimationFrame(()=>{this.isApplyingExternalUpdateRef.current=!1})},this.getRuntime=()=>{if(!this.runtime)throw Error(`ChatComposerLexicalOwner runtime has not been configured.`);return this.runtime}}};function dS({disabled:e,nodes:t,owner:n}){let[r]=Wd();return(0,L.useLayoutEffect)(()=>n.bindEditor(r),[r,n]),(0,L.useLayoutEffect)(()=>{r.setEditable(!e),n.syncExternalState(r,t)},[e,r,t,n]),(0,L.useEffect)(()=>n.registerEditorListeners(r),[r,n]),null}var fS=(0,L.forwardRef)(function({actions:e,disabled:t,nodes:n,onFilesAdd:r,onInputSurfaceItemSelect:i,onInputSurfaceKeyDown:a,onInputSurfaceOpenChange:o,onInputSurfaceSnapshotChange:s,onNodesChange:c,placeholder:l},u){let[d]=(0,L.useState)(()=>new uS),f=(0,L.useMemo)(()=>({onInputSurfaceItemSelect:i,onInputSurfaceKeyDown:a,onInputSurfaceOpenChange:o,onInputSurfaceSnapshotChange:s,onNodesChange:c}),[i,a,o,s,c]);return d.configureRuntime({actions:e,callbacks:f,fallbackNodes:n}),(0,L.useImperativeHandle)(u,()=>d.createHandle(),[d]),(0,R.jsxs)(rb,{initialConfig:(0,L.useMemo)(()=>({editable:!t,editorState:()=>{Wx(n,null)},namespace:`NextClawChatComposerLexical`,nodes:[Fx],onError:e=>{throw e},theme:{}}),[t,n]),children:[(0,R.jsx)(`div`,{className:`px-3 py-2 sm:px-4 sm:py-2.5`,children:(0,R.jsx)(`div`,{className:`min-h-11 sm:min-h-[60px]`,children:(0,R.jsx)(jx,{contentEditable:(0,R.jsx)(Zy,{className:`min-h-7 max-h-[188px] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent py-0.5 text-sm leading-6 text-foreground outline-none`,onBeforeInput:e=>{d.handleBeforeInput({disabled:t,event:e})},onCompositionEnd:e=>{let t=e.nativeEvent;d.handleCompositionEnd({data:typeof t.data==`string`?t.data:``})},onCompositionStart:()=>{d.handleCompositionStart()},onPaste:e=>{let t=Array.from(e.clipboardData.files??[]);t.length>0&&r&&(e.preventDefault(),r(t))}}),placeholder:(0,R.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-2 select-none text-sm leading-6 text-muted-foreground/60 sm:left-4 sm:top-2.5`,children:l}),ErrorBoundary:cb})})}),(0,R.jsx)(dS,{disabled:t,nodes:n,owner:d})]})});fS.displayName=`LexicalChatInputBarTokenizedComposer`;function pS({hint:e}){return e?e.loading?(0,R.jsx)(`div`,{className:`px-4 pb-2`,children:(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-border bg-muted px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`h-3 w-28 animate-pulse rounded bg-muted-foreground/20`}),(0,R.jsx)(`span`,{className:`h-3 w-16 animate-pulse rounded bg-muted-foreground/20`})]})}):(0,R.jsx)(`div`,{className:`px-4 pb-2`,children:(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${e.tone===`warning`?`border-amber-200 bg-amber-50 text-amber-800`:`border-border bg-muted text-muted-foreground`}`,children:[e.text?(0,R.jsx)(`span`,{children:e.text}):null,e.actionLabel&&e.onAction?(0,R.jsx)(`button`,{type:`button`,onClick:e.onAction,className:`font-semibold underline-offset-2 hover:underline`,children:e.actionLabel}):null]})}):null}var mS=(0,L.forwardRef)(function({composer:e,hint:t,inputSurface:n,slashMenu:r,surface:i,toolbar:a,topSlot:o},s){let c=(0,L.useRef)(null),l=n??(r?{isLoading:r.isLoading,filterOptions:r.filterOptions,items:r.items,onSelectItem:r.onSelectItem,texts:{loadingLabel:r.texts.slashLoadingLabel,sectionLabel:r.texts.slashSectionLabel,emptyLabel:r.texts.slashEmptyLabel,hintLabel:r.texts.slashHintLabel,itemHintLabel:r.texts.slashSkillHintLabel}}:null),u=(0,L.useMemo)(()=>a.skillPicker?{...a,skillPicker:{...a.skillPicker,onSelectedKeysChange:e=>{c.current?.syncSelectedSkills(e,a.skillPicker?.options??[]),a.skillPicker?.onSelectedKeysChange(e)}}}:a,[a]);return(0,L.useImperativeHandle)(s,()=>({insertFileToken:(e,t)=>c.current?.insertFileToken(e,t),insertFileTokens:e=>c.current?.insertFileTokens(e),focusComposer:()=>c.current?.focusComposer(),focusComposerAtEnd:e=>c.current?.focusComposerAtEnd(e)}),[]),(0,R.jsx)(`div`,{className:i===`embedded`?`bg-transparent px-0 py-0`:`bg-background px-3 pb-3 pt-2 sm:px-4 sm:pb-4 sm:pt-2`,children:(0,R.jsx)(`div`,{className:`nextclaw-chat-input-bar-shell mx-auto w-full max-w-[min(1120px,100%)] [container:nextclaw-chat-input-bar/inline-size]`,children:(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-border bg-card shadow-card`,children:[o?(0,R.jsx)(`div`,{className:`px-3 pb-0 pt-2 sm:px-4 sm:pt-2.5`,children:o}):null,(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsx)(vd,{inputSurface:l,onInputSurfaceTriggerChange:e.onInputSurfaceTriggerChange,onSelectItem:t=>c.current?.insertInputSurfaceItem(t,e.inputSurfaceTriggerSpecs),triggerSpecs:e.inputSurfaceTriggerSpecs,children:({onInputSurfaceKeyDown:t,onInputSurfaceOpenChange:n,onInputSurfaceSnapshotChange:r})=>(0,R.jsx)(fS,{ref:c,nodes:e.nodes,placeholder:e.placeholder,disabled:e.disabled,onInputSurfaceItemSelect:l?.onSelectItem,actions:a.actions,onNodesChange:e.onNodesChange,onFilesAdd:e.onFilesAdd,onInputSurfaceSnapshotChange:r,onInputSurfaceOpenChange:n,onInputSurfaceKeyDown:t})})}),(0,R.jsx)(pS,{hint:t}),(0,R.jsx)(Vd,{...u})]})})})});mS.displayName=`ChatInputBar`;function hS({role:e}){return e===`user`?(0,R.jsx)(`div`,{"data-testid":`chat-message-avatar-user`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-sm`,children:(0,R.jsx)(va,{className:`h-4 w-4`})}):e===`tool`?(0,R.jsx)(`div`,{"data-testid":`chat-message-avatar-tool`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-accent text-accent-foreground shadow-sm ring-1 ring-border`,children:(0,R.jsx)(ba,{className:`h-4 w-4`})}):(0,R.jsx)(`div`,{"data-testid":`chat-message-avatar-assistant`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-foreground shadow-sm ring-1 ring-border`,children:(0,R.jsx)(Xr,{className:`h-[18px] w-[18px] text-current`,strokeWidth:2.5})})}function gS(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var _S=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vS=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yS={};function bS(e,t){return((t||yS).jsx?vS:_S).test(e)}var xS=/[ \t\n\f\r]/g;function SS(e){return typeof e==`object`?e.type===`text`?CS(e.value):!1:CS(e)}function CS(e){return e.replace(xS,``)===``}var wS=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};wS.prototype.normal={},wS.prototype.property={},wS.prototype.space=void 0;function TS(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new wS(n,r,t)}function ES(e){return e.toLowerCase()}var DS=class{constructor(e,t){this.attribute=t,this.property=e}};DS.prototype.attribute=``,DS.prototype.booleanish=!1,DS.prototype.boolean=!1,DS.prototype.commaOrSpaceSeparated=!1,DS.prototype.commaSeparated=!1,DS.prototype.defined=!1,DS.prototype.mustUseProperty=!1,DS.prototype.number=!1,DS.prototype.overloadedBoolean=!1,DS.prototype.property=``,DS.prototype.spaceSeparated=!1,DS.prototype.space=void 0;var OS=e({boolean:()=>J,booleanish:()=>AS,commaOrSpaceSeparated:()=>PS,commaSeparated:()=>NS,number:()=>Y,overloadedBoolean:()=>jS,spaceSeparated:()=>MS}),kS=0,J=FS(),AS=FS(),jS=FS(),Y=FS(),MS=FS(),NS=FS(),PS=FS();function FS(){return 2**++kS}var IS=Object.keys(OS),LS=class extends DS{constructor(e,t,n,r){let i=-1;if(super(e,t),RS(this,`space`,r),typeof n==`number`)for(;++i<IS.length;){let e=IS[i];RS(this,IS[i],(n&OS[e])===OS[e])}}};LS.prototype.defined=!0;function RS(e,t,n){n&&(e[t]=n)}function zS(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new LS(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ES(r)]=r,n[ES(a.attribute)]=r}return new wS(t,n,e.space)}var BS=zS({properties:{ariaActiveDescendant:null,ariaAtomic:AS,ariaAutoComplete:null,ariaBusy:AS,ariaChecked:AS,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:MS,ariaCurrent:null,ariaDescribedBy:MS,ariaDetails:null,ariaDisabled:AS,ariaDropEffect:MS,ariaErrorMessage:null,ariaExpanded:AS,ariaFlowTo:MS,ariaGrabbed:AS,ariaHasPopup:null,ariaHidden:AS,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MS,ariaLevel:Y,ariaLive:null,ariaModal:AS,ariaMultiLine:AS,ariaMultiSelectable:AS,ariaOrientation:null,ariaOwns:MS,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:AS,ariaReadOnly:AS,ariaRelevant:null,ariaRequired:AS,ariaRoleDescription:MS,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:AS,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function VS(e,t){return t in e?e[t]:t}function HS(e,t){return VS(e,t.toLowerCase())}var US=zS({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:NS,acceptCharset:MS,accessKey:MS,action:null,allow:null,allowFullScreen:J,allowPaymentRequest:J,allowUserMedia:J,alt:null,as:null,async:J,autoCapitalize:null,autoComplete:MS,autoFocus:J,autoPlay:J,blocking:MS,capture:null,charSet:null,checked:J,cite:null,className:MS,cols:Y,colSpan:null,content:null,contentEditable:AS,controls:J,controlsList:MS,coords:Y|NS,crossOrigin:null,data:null,dateTime:null,decoding:null,default:J,defer:J,dir:null,dirName:null,disabled:J,download:jS,draggable:AS,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:J,formTarget:null,headers:MS,height:Y,hidden:jS,high:Y,href:null,hrefLang:null,htmlFor:MS,httpEquiv:MS,id:null,imageSizes:null,imageSrcSet:null,inert:J,inputMode:null,integrity:null,is:null,isMap:J,itemId:null,itemProp:MS,itemRef:MS,itemScope:J,itemType:MS,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:J,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:J,muted:J,name:null,nonce:null,noModule:J,noValidate:J,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:J,optimum:Y,pattern:null,ping:MS,placeholder:null,playsInline:J,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:J,referrerPolicy:null,rel:MS,required:J,reversed:J,rows:Y,rowSpan:Y,sandbox:MS,scope:null,scoped:J,seamless:J,selected:J,shadowRootClonable:J,shadowRootDelegatesFocus:J,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:AS,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:J,useMap:null,value:AS,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MS,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:J,declare:J,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:J,noHref:J,noShade:J,noWrap:J,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:AS,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:J,disableRemotePlayback:J,prefix:null,property:null,results:Y,security:null,unselectable:null},space:`html`,transform:HS}),WS=zS({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:PS,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:MS,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:J,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:NS,g2:NS,glyphName:NS,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:PS,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MS,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:PS,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:PS,rev:PS,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:PS,requiredFeatures:PS,requiredFonts:PS,requiredFormats:PS,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:PS,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:PS,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:PS,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:VS}),GS=zS({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),KS=zS({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:HS}),qS=zS({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),JS={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},YS=/[A-Z]/g,XS=/-[a-z]/g,ZS=/^data[-\w.:]+$/i;function QS(e,t){let n=ES(t),r=t,i=DS;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ZS.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(XS,eC);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!XS.test(e)){let n=e.replace(YS,$S);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=LS}return new i(r,t)}function $S(e){return`-`+e.toLowerCase()}function eC(e){return e.charAt(1).toUpperCase()}var tC=TS([BS,US,GS,KS,qS],`html`),nC=TS([BS,WS,GS,KS,qS],`svg`);function rC(e){return e.join(` `).trim()}var iC=i(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
18
+ `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),aC=i((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(iC());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),oC=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),sC=i(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(aC()),r=oC();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),cC=uC(`end`),lC=uC(`start`);function uC(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function dC(e){let t=lC(e),n=cC(e);if(t&&n)return{start:t,end:n}}function fC(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?mC(e.position):`start`in e||`end`in e?mC(e):`line`in e||`column`in e?pC(e):``}function pC(e){return hC(e&&e.line)+`:`+hC(e&&e.column)}function mC(e){return pC(e&&e.start)+`-`+pC(e&&e.end)}function hC(e){return e&&typeof e==`number`?e:1}var gC=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=fC(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};gC.prototype.file=``,gC.prototype.name=``,gC.prototype.reason=``,gC.prototype.message=``,gC.prototype.stack=``,gC.prototype.column=void 0,gC.prototype.line=void 0,gC.prototype.ancestors=void 0,gC.prototype.cause=void 0,gC.prototype.fatal=void 0,gC.prototype.place=void 0,gC.prototype.ruleId=void 0,gC.prototype.source=void 0;var _C=m(sC(),1),vC={}.hasOwnProperty,yC=new Map,bC=/[A-Z]/g,xC=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),SC=new Set([`td`,`th`]),CC=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function wC(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=FC(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=PC(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?nC:tC,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=TC(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function TC(e,t,n){if(t.type===`element`)return EC(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return DC(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return kC(e,t,n);if(t.type===`mdxjsEsm`)return OC(e,t);if(t.type===`root`)return AC(e,t,n);if(t.type===`text`)return jC(e,t)}function EC(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=nC,e.schema=i),e.ancestors.push(t);let a=VC(e,t.tagName,!1),o=IC(e,t),s=RC(e,t);return xC.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!SS(e):!0})),MC(e,o,a,t),NC(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function DC(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}HC(e,t.position)}function OC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);HC(e,t.position)}function kC(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=nC,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:VC(e,t.name,!0),o=LC(e,t),s=RC(e,t);return MC(e,o,a,t),NC(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function AC(e,t,n){let r={};return NC(r,RC(e,t)),e.create(t,e.Fragment,r,n)}function jC(e,t){return t.value}function MC(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function NC(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function PC(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function FC(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=lC(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function IC(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&vC.call(t.properties,i)){let a=zC(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&SC.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function LC(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else HC(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else HC(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function RC(e,t){let n=[],r=-1,i=e.passKeys?new Map:yC;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=TC(e,a,o);s!==void 0&&n.push(s)}return n}function zC(e,t,n){let r=QS(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?gS(n):rC(n)),r.property===`style`){let t=typeof n==`object`?n:BC(e,String(n));return e.stylePropertyNameCase===`css`&&(t=UC(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?JS[r.property]||r.property:r.attribute,n]}}function BC(e,t){try{return(0,_C.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new gC("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=CC+`#cannot-parse-style-attribute`,r}}function VC(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=bS(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=bS(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return vC.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);HC(e)}function HC(e,t){let n=new gC("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=CC+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function UC(e){let t={},n;for(n in e)vC.call(e,n)&&(t[WC(n)]=e[n]);return t}function WC(e){let t=e.replace(bC,GC);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function GC(e){return`-`+e.toLowerCase()}var KC={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},qC={};function JC(e,t){let n=t||qC;return YC(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function YC(e,t,n){if(ZC(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return XC(e.children,t,n)}return Array.isArray(e)?XC(e,t,n):``}function XC(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=YC(e[i],t,n);return r.join(``)}function ZC(e){return!!(e&&typeof e==`object`)}var QC=document.createElement(`i`);function $C(e){let t=`&`+e+`;`;QC.innerHTML=t;let n=QC.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function ew(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function tw(e,t){return e.length>0?(ew(e,e.length,0,t),e):t}var nw={}.hasOwnProperty;function rw(e){let t={},n=-1;for(;++n<e.length;)iw(t,e[n]);return t}function iw(e,t){let n;for(n in t){let r=(nw.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){nw.call(r,a)||(r[a]=[]);let e=i[a];aw(r[a],Array.isArray(e)?e:e?[e]:[])}}}function aw(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);ew(e,0,0,r)}function ow(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function sw(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var cw=vw(/[A-Za-z]/),lw=vw(/[\dA-Za-z]/),uw=vw(/[#-'*+\--9=?A-Z^-~]/);function dw(e){return e!==null&&(e<32||e===127)}var fw=vw(/\d/),pw=vw(/[\dA-Fa-f]/),mw=vw(/[!-/:-@[-`{-~]/);function X(e){return e!==null&&e<-2}function hw(e){return e!==null&&(e<0||e===32)}function Z(e){return e===-2||e===-1||e===32}var gw=vw(/\p{P}|\p{S}/u),_w=vw(/\s/);function vw(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function yw(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&lw(e.charCodeAt(n+1))&&lw(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Q(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Z(r)?(e.enter(n),s(r)):t(r)}function s(r){return Z(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var bw={tokenize:xw};function xw(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Q(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return X(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Sw={tokenize:ww},Cw={tokenize:Tw};function ww(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return ew(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Cw,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Cw,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return X(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;ew(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Tw(e,t,n){return Q(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Ew(e){if(e===null||hw(e)||_w(e))return 1;if(gw(e))return 2}function Dw(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Ow={name:`attention`,resolveAll:kw,tokenize:Aw};function kw(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};jw(d,-c),jw(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=tw(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=tw(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=tw(l,Dw(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=tw(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=tw(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ew(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Aw(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ew(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Ew(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function jw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Mw={name:`autolink`,tokenize:Nw};function Nw(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return cw(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||lw(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||lw(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||dw(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):uw(t)?(e.consume(t),l):n(t)}function u(e){return lw(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||lw(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Pw={partial:!0,tokenize:Fw};function Fw(e,t,n){return r;function r(t){return Z(t)?Q(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||X(e)?t(e):n(e)}}var Iw={continuation:{tokenize:Rw},exit:zw,name:`blockQuote`,tokenize:Lw};function Lw(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Z(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Rw(e,t,n){let r=this;return i;function i(t){return Z(t)?Q(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Iw,t,n)(r)}}function zw(e){e.exit(`blockQuote`)}var Bw={name:`characterEscape`,tokenize:Vw};function Vw(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return mw(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Hw={name:`characterReference`,tokenize:Uw};function Uw(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=lw,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=pw,u):(e.enter(`characterReferenceValue`),a=7,o=fw,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===lw&&!$C(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Ww={partial:!0,tokenize:qw},Gw={concrete:!0,name:`codeFenced`,tokenize:Kw};function Kw(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Z(t)?Q(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||X(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Ww,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Z(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Q(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||X(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Z(t)?Q(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||X(t)?e.check(Ww,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||X(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Z(t)?Q(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Z(t)?Q(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||X(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function qw(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Jw={name:`codeIndented`,tokenize:Xw},Yw={partial:!0,tokenize:Zw};function Xw(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Q(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):X(t)?e.attempt(Yw,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||X(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Zw(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Q(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):X(e)?i(e):n(e)}}var Qw={name:`codeText`,previous:eT,resolve:$w,tokenize:tT};function $w(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function eT(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function tT(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||X(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var nT=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&rT(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),rT(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),rT(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);rT(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);rT(this.left,t.reverse())}}};function rT(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function iT(e){let t={},n=-1,r,i,a,o,s,c,l,u=new nT(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,aT(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return ew(e,0,1/0,u.slice(0)),!l}function aT(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var oT={resolve:cT,tokenize:lT},sT={partial:!0,tokenize:uT};function cT(e){return iT(e),e}function lT(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):X(t)?e.check(sT,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function uT(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Q(e,a,`linePrefix`)}function a(i){if(i===null||X(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function dT(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||dw(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||X(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||hw(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||dw(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function fT(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):X(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||X(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Z(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function pT(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Q(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||X(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function mT(e,t){let n;return r;function r(i){return X(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Z(i)?Q(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var hT={name:`definition`,tokenize:_T},gT={partial:!0,tokenize:vT};function _T(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return fT.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=sw(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return hw(t)?mT(e,l)(t):l(t)}function l(t){return dT(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(gT,d,d)(t)}function d(t){return Z(t)?Q(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||X(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function vT(e,t,n){return r;function r(t){return hw(t)?mT(e,i)(t):n(t)}function i(t){return pT(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Z(t)?Q(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||X(e)?t(e):n(e)}}var yT={name:`hardBreakEscape`,tokenize:bT};function bT(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return X(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var xT={name:`headingAtx`,resolve:ST,tokenize:CT};function ST(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},ew(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function CT(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||hw(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||X(n)?(e.exit(`atxHeading`),t(n)):Z(n)?Q(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||hw(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var wT=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),TT=[`pre`,`script`,`style`,`textarea`],ET={concrete:!0,name:`htmlFlow`,resolveTo:kT,tokenize:AT},DT={partial:!0,tokenize:MT},OT={partial:!0,tokenize:jT};function kT(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function AT(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ne):cw(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):cw(a)?(e.consume(a),i=4,r.interrupt?t:ne):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ne):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return cw(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||hw(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&TT.includes(l)?(i=1,r.interrupt?t(s):O(s)):wT.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||lw(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Z(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||cw(t)?(e.consume(t),b):Z(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||lw(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Z(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Z(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||X(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||hw(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Z(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||X(t)?O(t):Z(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),re):t===63&&i===3?(e.consume(t),ne):t===93&&i===5?(e.consume(t),te):X(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(DT,ie,k)(t)):t===null||X(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(OT,A,ie)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return t===null||X(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),ne):O(t)}function M(t){return t===47?(e.consume(t),o=``,N):O(t)}function N(t){if(t===62){let n=o.toLowerCase();return TT.includes(n)?(e.consume(t),re):O(t)}return cw(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),N):O(t)}function te(t){return t===93?(e.consume(t),ne):O(t)}function ne(t){return t===62?(e.consume(t),re):t===45&&i===2?(e.consume(t),ne):O(t)}function re(t){return t===null||X(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),re)}function ie(n){return e.exit(`htmlFlow`),t(n)}}function jT(e,t,n){let r=this;return i;function i(t){return X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function MT(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Pw,t,n)}}var NT={name:`htmlText`,tokenize:PT};function PT(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):cw(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):cw(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):X(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):X(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):X(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):X(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return cw(t)?(e.consume(t),S):n(t)}function S(t){return t===45||lw(t)?(e.consume(t),S):C(t)}function C(t){return X(t)?(o=C,M(t)):Z(t)?(e.consume(t),C):j(t)}function w(t){return t===45||lw(t)?(e.consume(t),w):t===47||t===62||hw(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||cw(t)?(e.consume(t),E):X(t)?(o=T,M(t)):Z(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||lw(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):X(t)?(o=D,M(t)):Z(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):X(t)?(o=O,M(t)):Z(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,ee):t===null?n(t):X(t)?(o=k,M(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||hw(t)?T(t):(e.consume(t),A)}function ee(e){return e===47||e===62||hw(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N}function N(t){return Z(t)?Q(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var FT={name:`labelEnd`,resolveAll:zT,resolveTo:BT,tokenize:VT},IT={tokenize:HT},LT={tokenize:UT},RT={tokenize:WT};function zT(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&ew(e,0,e.length,n),e}function BT(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=tw(s,e.slice(a+1,a+r+3)),s=tw(s,[[`enter`,u,t]]),s=tw(s,Dw(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=tw(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=tw(s,e.slice(o+1)),s=tw(s,[[`exit`,c,t]]),ew(e,a,e.length,s),e}function VT(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(sw(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(IT,u,o?u:d)(t):t===91?e.attempt(LT,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(RT,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function HT(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return hw(t)?mT(e,a)(t):a(t)}function a(t){return t===41?u(t):dT(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return hw(t)?mT(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?pT(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return hw(t)?mT(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function UT(e,t,n){let r=this;return i;function i(t){return fT.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(sw(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function WT(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var GT={name:`labelStartImage`,resolveAll:FT.resolveAll,tokenize:KT};function KT(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var qT={name:`labelStartLink`,resolveAll:FT.resolveAll,tokenize:JT};function JT(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var YT={name:`lineEnding`,tokenize:XT};function XT(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Q(e,t,`linePrefix`)}}var ZT={name:`thematicBreak`,tokenize:QT};function QT(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||X(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Z(t)?Q(e,s,`whitespace`)(t):s(t))}}var $T={continuation:{tokenize:rE},exit:aE,name:`list`,tokenize:nE},eE={partial:!0,tokenize:oE},tE={partial:!0,tokenize:iE};function nE(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:fw(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(ZT,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return fw(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Pw,r.interrupt?n:u,e.attempt(eE,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Z(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function rE(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Pw,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Q(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Z(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tE,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Q(e,e.attempt($T,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function iE(e,t,n){let r=this;return Q(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function aE(e){e.exit(this.containerState.type)}function oE(e,t,n){let r=this;return Q(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Z(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var sE={name:`setextUnderline`,resolveTo:cE,tokenize:lE};function cE(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function lE(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Z(t)?Q(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||X(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var uE={tokenize:dE};function dE(e){let t=this,n=e.attempt(Pw,r,e.attempt(this.parser.constructs.flowInitial,i,Q(e,e.attempt(this.parser.constructs.flow,i,e.attempt(oT,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var fE={resolveAll:gE()},pE=hE(`string`),mE=hE(`text`);function hE(e){return{resolveAll:gE(e===`text`?_E:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function gE(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function _E(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var vE=e({attentionMarkers:()=>EE,contentInitial:()=>bE,disable:()=>DE,document:()=>yE,flow:()=>SE,flowInitial:()=>xE,insideSpan:()=>TE,string:()=>CE,text:()=>wE}),yE={42:$T,43:$T,45:$T,48:$T,49:$T,50:$T,51:$T,52:$T,53:$T,54:$T,55:$T,56:$T,57:$T,62:Iw},bE={91:hT},xE={[-2]:Jw,[-1]:Jw,32:Jw},SE={35:xT,42:ZT,45:[sE,ZT],60:ET,61:sE,95:ZT,96:Gw,126:Gw},CE={38:Hw,92:Bw},wE={[-5]:YT,[-4]:YT,[-3]:YT,33:GT,38:Hw,42:Ow,60:[Mw,NT],91:qT,92:[yT,Bw],93:FT,95:Ow,96:Qw},TE={null:[Ow,fE]},EE={null:[42,95]},DE={null:[]};function OE(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=tw(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Dw(a,l.events,l),l.events):[]}function f(e,t){return AE(p(e),t)}function p(e){return kE(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){X(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&ew(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function kE(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function AE(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
19
+ `;break;case-3:o=`\r
20
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function jE(e){let t={constructs:rw([vE,...(e||{}).extensions||[]]),content:n(bw),defined:[],document:n(Sw),flow:n(uE),lazy:{},string:n(pE),text:n(mE)};return t;function n(e){return n;function n(n){return OE(t,e,n)}}}function ME(e){for(;!iT(e););return e}var NE=/[\0\t\n\r]/g;function PE(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(NE.lastIndex=u,c=NE.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var FE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function IE(e){return e.replace(FE,LE)}function LE(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return ow(n.slice(t?2:1),t?16:10)}return $C(n)||e}var RE={}.hasOwnProperty;function zE(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),BE(n)(ME(jE(n).document().write(PE()(e,t,!0))))}function BE(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(P),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(_e),blockQuote:a(fe),characterEscape:T,characterReference:T,codeFenced:a(pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(pe,o),codeText:a(me,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(he),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ge),hardBreakEscape:a(ve),hardBreakTrailing:a(ve),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(P),listItem:a(Se),listItemValue:f,listOrdered:a(xe,d),listUnordered:a(xe),paragraph:a(Ce),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(_e),strong:a(we),thematicBreak:a(Ee)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(ee),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(M),label:te,labelText:N,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:oe,resourceDestinationString:ne,resourceTitleString:re,resource:ie,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};HE(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];RE.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||WE).call(a,void 0,e[0])}for(r.position={start:VE(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:VE(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:VE(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||WE).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+fC({start:e.start,end:e.end})+`): it’s not open`);n.position.end=VE(e.end)}function u(){return JC(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=sw(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Te(),n.position={start:VE(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=VE(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=VE(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=IE(t),n.identifier=sw(t).toLowerCase()}function te(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ie(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function oe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=sw(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function se(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=ow(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=$C(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=VE(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function fe(){return{type:`blockquote`,children:[]}}function pe(){return{type:`code`,lang:null,meta:null,value:``}}function me(){return{type:`inlineCode`,value:``}}function he(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ge(){return{type:`emphasis`,children:[]}}function _e(){return{type:`heading`,depth:0,children:[]}}function ve(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function P(){return{type:`link`,title:null,url:``,children:[]}}function xe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Se(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ce(){return{type:`paragraph`,children:[]}}function we(){return{type:`strong`,children:[]}}function Te(){return{type:`text`,value:``}}function Ee(){return{type:`thematicBreak`}}}function VE(e){return{line:e.line,column:e.column,offset:e.offset}}function HE(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?HE(e,r):UE(e,r)}}function UE(e,t){let n;for(n in t)if(RE.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function WE(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+fC({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+fC({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+fC({start:t.start,end:t.end})+`) is still open`)}function GE(e){let t=this;t.parser=n;function n(n){return zE(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function KE(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function qE(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
21
+ `}]}function JE(e,t){let n=t.value?t.value+`
22
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function YE(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XE(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZE(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=yw(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function QE(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $E(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function eD(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function tD(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return eD(e,t);let i={src:yw(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function nD(e,t){let n={src:yw(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function rD(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function iD(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return eD(e,t);let i={href:yw(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function aD(e,t){let n={href:yw(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function oD(e,t,n){let r=e.all(t),i=n?sD(n):cD(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
23
+ `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
24
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function sD(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=cD(n[r])}return t}function cD(e){return e.spread??e.children.length>1}function lD(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function uD(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dD(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function fD(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pD(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=lC(t.children[1]),o=cC(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function mD(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function hD(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var gD=9,_D=32;function vD(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(yD(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(yD(t.slice(i),i>0,!1)),a.join(``)}function yD(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===gD||t===_D;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===gD||t===_D;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function bD(e,t){let n={type:`text`,value:vD(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xD(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var SD={blockquote:KE,break:qE,code:JE,delete:YE,emphasis:XE,footnoteReference:ZE,heading:QE,html:$E,imageReference:tD,image:nD,inlineCode:rD,linkReference:iD,link:aD,listItem:oD,list:lD,paragraph:uD,root:dD,strong:fD,table:pD,tableCell:hD,tableRow:mD,text:bD,thematicBreak:xD,toml:CD,yaml:CD,definition:CD,footnoteDefinition:CD};function CD(){}var wD=typeof self==`object`?self:globalThis,TD=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new wD[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new wD[a](o),i)};return r},ED=e=>TD(new Map,e)(0),DD=``,{toString:OD}={},{keys:kD}=Object,AD=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=OD.call(e).slice(8,-1);switch(n){case`Array`:return[1,DD];case`Object`:return[2,DD];case`Date`:return[3,DD];case`RegExp`:return[4,DD];case`Map`:return[5,DD];case`Set`:return[6,DD];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},jD=([e,t])=>e===0&&(t===`function`||t===`symbol`),MD=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=AD(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of kD(r))(e||!jD(AD(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(jD(AD(n))||jD(AD(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!jD(AD(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},ND=(e,{json:t,lossy:n}={})=>{let r=[];return MD(!(t||n),!!t,new Map,r)(e),r},PD=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?ED(ND(e,t)):structuredClone(e):(e,t)=>ED(ND(e,t));function FD(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function ID(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function LD(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||FD,r=e.options.footnoteBackLabel||ID,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=yw(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...PD(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
25
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
26
+ `}]}}var RD=(function(e){if(e==null)return UD;if(typeof e==`function`)return HD(e);if(typeof e==`object`)return Array.isArray(e)?zD(e):BD(e);if(typeof e==`string`)return VD(e);throw Error(`Expected function, string, or object as test`)});function zD(e){let t=[],n=-1;for(;++n<e.length;)t[n]=RD(e[n]);return HD(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function BD(e){let t=e;return HD(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function VD(e){return HD(t);function t(t){return t&&t.type===e}}function HD(e){return t;function t(t,n,r){return!!(WD(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function UD(){return!0}function WD(e){return typeof e==`object`&&!!e&&`type`in e}function GD(e){return e}var KD=[];function qD(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=RD(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+GD(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=KD,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=JD(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function JD(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?KD:[e]}function YD(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),qD(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var XD={}.hasOwnProperty,ZD={};function QD(e,t){let n=t||ZD,r=new Map,i=new Map,a={all:s,applyData:eO,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...SD,...n.handlers},one:o,options:n,patch:$D,wrap:nO};return YD(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(XD.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=PD(n);return r.children=a.all(e),r}return PD(e)}return(a.options.unknownHandler||tO)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=rO(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=rO(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function $D(e,t){e.position&&(t.position=dC(e))}function eO(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,PD(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function tO(e,t){let n=t.data||{},r=`value`in t&&!(XD.call(n,`hProperties`)||XD.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function nO(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
27
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
28
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
29
+ `}),n}function rO(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function iO(e,t){let n=QD(e,t),r=n.one(e,void 0),i=LD(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
30
+ `},i)),a}function aO(e,t){return e&&`run`in e?async function(n,r){let i=iO(n,{file:r,...t});await e.run(i,r)}:function(n,r){return iO(n,{file:r,...e||t})}}function oO(e){if(e)throw e}var sO=i(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function cO(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function lO(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?uO(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function uO(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var dO={basename:fO,dirname:pO,extname:mO,join:hO,sep:`/`};function fO(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);vO(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function pO(e){if(vO(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function mO(e){vO(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function hO(...e){let t=-1,n;for(;++t<e.length;)vO(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:gO(n)}function gO(e){vO(e);let t=e.codePointAt(0)===47,n=_O(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function _O(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function vO(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var yO={cwd:bO};function bO(){return`/`}function xO(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function SO(e){if(typeof e==`string`)e=new URL(e);else if(!xO(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return CO(e)}function CO(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var wO=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],TO=class{constructor(e){let t;t=e?xO(e)?{path:e}:typeof e==`string`||kO(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:yO.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<wO.length;){let e=wO[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)wO.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?dO.basename(this.path):void 0}set basename(e){DO(e,`basename`),EO(e,`basename`),this.path=dO.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?dO.dirname(this.path):void 0}set dirname(e){OO(this.basename,`dirname`),this.path=dO.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?dO.extname(this.path):void 0}set extname(e){if(EO(e,`extname`),OO(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=dO.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){xO(e)&&(e=SO(e)),DO(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?dO.basename(this.path,this.extname):void 0}set stem(e){DO(e,`stem`),EO(e,`stem`),this.path=dO.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new gC(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function EO(e,t){if(e&&e.includes(dO.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+dO.sep+"`")}function DO(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function OO(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function kO(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var AO=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),jO=m(sO(),1),MO={}.hasOwnProperty,NO=new class e extends AO{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lO()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,jO.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(IO(`data`,this.frozen),this.namespace[e]=t,this):MO.call(this.namespace,e)&&this.namespace[e]||void 0:e?(IO(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=zO(e),n=this.parser||this.Parser;return PO(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),PO(`process`,this.parser||this.Parser),FO(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=zO(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);VO(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),PO(`processSync`,this.parser||this.Parser),FO(`processSync`,this.compiler||this.Compiler),this.process(e,r),RO(`processSync`,`process`,t),n;function r(e,r){t=!0,oO(e),n=r}}run(e,t,n){LO(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=zO(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),RO(`runSync`,`run`,n),r;function i(e,t){oO(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=zO(t),r=this.compiler||this.Compiler;return FO(`stringify`,r),LO(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(IO(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,jO.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];cO(o)&&cO(r)&&(r=(0,jO.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function PO(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function FO(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function IO(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function LO(e){if(!cO(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function RO(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function zO(e){return BO(e)?e:new TO(e)}function BO(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function VO(e){return typeof e==`string`||HO(e)}function HO(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var UO=[],WO={allowDangerousHtml:!0},GO=/^(https?|ircs?|mailto|xmpp)$/i,KO=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function qO(e){let t=JO(e),n=YO(e);return XO(t.runSync(t.parse(n),n),e)}function JO(e){let t=e.rehypePlugins||UO,n=e.remarkPlugins||UO,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...WO}:WO;return NO().use(GE).use(n).use(aO,r).use(t)}function YO(e){let t=e.children||``,n=new TO;return typeof t==`string`?n.value=t:``+t,n}function XO(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ZO;for(let e of KO)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return YD(e,l),wC(e,{Fragment:R.Fragment,components:i,ignoreInvalidStyle:!0,jsx:R.jsx,jsxs:R.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in KC)if(Object.hasOwn(KC,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=KC[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ZO(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||GO.test(e.slice(0,t))?e:``}function QO(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function $O(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function ek(e,t,n){let r=RD((n||{}).ignore||[]),i=tk(t),a=-1;for(;++a<i.length;)qD(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function tk(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([nk(e[0]),rk(e[1])])}return t}function nk(e){return typeof e==`string`?new RegExp($O(e),`g`):e}function rk(e){return typeof e==`function`?e:function(){return e}}var ik=`phrasing`,ak=[`autolink`,`link`,`image`,`label`];function ok(){return{transforms:[mk],enter:{literalAutolink:ck,literalAutolinkEmail:lk,literalAutolinkHttp:lk,literalAutolinkWww:lk},exit:{literalAutolink:pk,literalAutolinkEmail:fk,literalAutolinkHttp:uk,literalAutolinkWww:dk}}}function sk(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:ik,notInConstruct:ak},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:ik,notInConstruct:ak},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:ik,notInConstruct:ak}]}}function ck(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function lk(e){this.config.enter.autolinkProtocol.call(this,e)}function uk(e){this.config.exit.autolinkProtocol.call(this,e)}function dk(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function fk(e){this.config.exit.autolinkEmail.call(this,e)}function pk(e){this.exit(e)}function mk(e){ek(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,hk],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,gk]],{ignore:[`link`,`linkReference`]})}function hk(e,t,n,r,i){let a=``;if(!yk(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!_k(n)))return!1;let o=vk(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function gk(e,t,n,r){return!yk(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function _k(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function vk(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=QO(e,`(`),a=QO(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function yk(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||_w(n)||gw(n))&&(!t||n!==47)}kk.peek=Ok;function bk(){this.buffer()}function xk(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Sk(){this.buffer()}function Ck(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function wk(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=sw(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Tk(e){this.exit(e)}function Ek(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=sw(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Dk(e){this.exit(e)}function Ok(){return`[`}function kk(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Ak(){return{enter:{gfmFootnoteCallString:bk,gfmFootnoteCall:xk,gfmFootnoteDefinitionLabelString:Sk,gfmFootnoteDefinition:Ck},exit:{gfmFootnoteCallString:wk,gfmFootnoteCall:Tk,gfmFootnoteDefinitionLabelString:Ek,gfmFootnoteDefinition:Dk}}}function jk(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:kk},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
31
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Nk:Mk))),s(),o}}function Mk(e,t,n){return t===0?e:Nk(e,t,n)}function Nk(e,t,n){return(n?``:` `)+e}var Pk=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];zk.peek=Bk;function Fk(){return{canContainEols:[`delete`],enter:{strikethrough:Lk},exit:{strikethrough:Rk}}}function Ik(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Pk}],handlers:{delete:zk}}}function Lk(e){this.enter({type:`delete`,children:[]},e)}function Rk(e){this.exit(e)}function zk(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Bk(){return`~`}function Vk(e){return e.length}function Hk(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Vk,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=Uk(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=Wk(r[d]);else{let e=Wk(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
32
+ `)}function Uk(e){return e==null?``:String(e)}function Wk(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Gk(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Kk);return i(),o}function Kk(e,t,n){return`>`+(n?``:` `)+e}function qk(e,t){return Jk(e,t.inConstruct,!0)&&!Jk(e,t.notInConstruct,!1)}function Jk(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Yk(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
33
+ `&&qk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
34
+ `}function Xk(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Zk(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Qk(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function $k(e,t,n,r){let i=Qk(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Zk(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,eA);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Xk(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
35
+ `,encode:["`"],...s.current()})),t()}return u+=s.move(`
36
+ `),a&&(u+=s.move(a+`
37
+ `)),u+=s.move(c),l(),u}function eA(e,t,n){return(n?``:` `)+e}function tA(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function nA(e,t,n,r){let i=tA(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
38
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function rA(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function iA(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function aA(e,t,n){let r=Ew(e),i=Ew(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}oA.peek=sA;function oA(e,t,n,r){let i=rA(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=aA(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=iA(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=aA(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+iA(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function sA(e,t,n){return n.options.emphasis||`*`}function cA(e,t){let n=!1;return YD(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&JC(e)&&(t.options.setext||n))}function lA(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(cA(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
39
+ `,after:`
40
+ `});return r(),t(),o+`
41
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
42
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
43
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=iA(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}uA.peek=dA;function uA(e){return e.value||``}function dA(){return`<`}fA.peek=pA;function fA(e,t,n,r){let i=tA(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function pA(){return`!`}mA.peek=hA;function mA(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function hA(){return`!`}gA.peek=_A;function gA(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function _A(){return"`"}function vA(e,t){let n=JC(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}yA.peek=bA;function yA(e,t,n,r){let i=tA(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(vA(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function bA(e,t,n){return vA(e,n)?`<`:`[`}xA.peek=SA;function xA(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function SA(){return`[`}function CA(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function wA(e){let t=CA(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function TA(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function EA(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function DA(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?TA(n):CA(n),s=e.ordered?o===`.`?`)`:`.`:wA(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),EA(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function OA(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function kA(e,t,n,r){let i=OA(n),a=n.bulletCurrent||CA(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function AA(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var jA=RD([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function MA(e,t,n,r){return(e.children.some(function(e){return jA(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function NA(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}PA.peek=FA;function PA(e,t,n,r){let i=NA(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=aA(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=iA(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=aA(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+iA(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function FA(e,t,n){return n.options.strong||`*`}function IA(e,t,n,r){return n.safe(e.value,r)}function LA(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function RA(e,t,n){let r=(EA(n)+(n.options.ruleSpaces?` `:``)).repeat(LA(n));return n.options.ruleSpaces?r.slice(0,-1):r}var zA={blockquote:Gk,break:Yk,code:$k,definition:nA,emphasis:oA,hardBreak:Yk,heading:lA,html:uA,image:fA,imageReference:mA,inlineCode:gA,link:yA,linkReference:xA,list:DA,listItem:kA,paragraph:AA,root:MA,strong:PA,text:IA,thematicBreak:RA};function BA(){return{enter:{table:VA,tableData:GA,tableHeader:GA,tableRow:UA},exit:{codeText:KA,table:HA,tableData:WA,tableHeader:WA,tableRow:WA}}}function VA(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function HA(e){this.exit(e),this.data.inTable=void 0}function UA(e){this.enter({type:`tableRow`,children:[]},e)}function WA(e){this.exit(e)}function GA(e){this.enter({type:`tableCell`,children:[]},e)}function KA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,qA));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function qA(e,t){return t===`|`?t:e}function JA(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
44
+ `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
45
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Hk(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=zA.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function YA(){return{exit:{taskListCheckValueChecked:ZA,taskListCheckValueUnchecked:ZA,paragraph:QA}}}function XA(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:$A}}}function ZA(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function QA(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function $A(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=zA.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function ej(){return[ok(),Ak(),Fk(),BA(),YA()]}function tj(e){return{extensions:[sk(),jk(e),Ik(),JA(e),XA()]}}var nj={tokenize:gj,partial:!0},rj={tokenize:_j,partial:!0},ij={tokenize:vj,partial:!0},aj={tokenize:yj,partial:!0},oj={tokenize:bj,partial:!0},sj={name:`wwwAutolink`,tokenize:mj,previous:xj},cj={name:`protocolAutolink`,tokenize:hj,previous:Sj},lj={name:`emailAutolink`,tokenize:pj,previous:Cj},uj={};function dj(){return{text:uj}}for(var fj=48;fj<123;)uj[fj]=lj,fj++,fj===58?fj=65:fj===91&&(fj=97);uj[43]=lj,uj[45]=lj,uj[46]=lj,uj[95]=lj,uj[72]=[lj,cj],uj[104]=[lj,cj],uj[87]=[lj,sj],uj[119]=[lj,sj];function pj(e,t,n){let r=this,i,a;return o;function o(t){return!wj(t)||!Cj.call(r,r.previous)||Tj(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return wj(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(oj,u,l)(t):t===45||t===95||lw(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&cw(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function mj(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!xj.call(r,r.previous)||Tj(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(nj,e.attempt(rj,e.attempt(ij,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function hj(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Sj.call(r,r.previous)&&!Tj(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(cw(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||dw(t)||hw(t)||_w(t)||gw(t)?n(t):e.attempt(rj,e.attempt(ij,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function gj(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function _j(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(aj,c,s)(t):t===null||hw(t)||_w(t)||t!==45&&gw(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function vj(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(aj,t,a)(o):o===null||hw(o)||_w(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function yj(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||hw(o)||_w(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||hw(e)||_w(e)?t(e):r(e)}function a(e){return cw(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):cw(t)?(e.consume(t),o):n(t)}}function bj(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return lw(e)?n(e):t(e)}}function xj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||hw(e)}function Sj(e){return!cw(e)}function Cj(e){return!(e===47||wj(e))}function wj(e){return e===43||e===45||e===46||e===95||lw(e)}function Tj(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Ej={tokenize:Pj,partial:!0};function Dj(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:jj,continuation:{tokenize:Mj},exit:Nj}},text:{91:{name:`gfmFootnoteCall`,tokenize:Aj},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Oj,resolveTo:kj}}}}function Oj(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=sw(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function kj(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Aj(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||hw(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(sw(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return hw(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function jj(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||hw(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=sw(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return hw(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Q(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Mj(e,t,n){return e.check(Pw,t,e.attempt(Ej,t,n))}function Nj(e){e.exit(`gfmFootnoteDefinition`)}function Pj(e,t,n){let r=this;return Q(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Fj(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&ew(o,o.length,0,Dw(s,e.slice(r+1,n),t)),ew(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ew(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Ew(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Ew(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Ij=class{constructor(){this.map=[]}add(e,t,n){Lj(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Lj(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Rj(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function zj(){return{flow:{null:{name:`table`,tokenize:Bj,resolveAll:Vj}}}}function Bj(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):X(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Z(t)?Q(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||hw(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Z(t)?Q(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Z(t)?Q(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||X(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Z(t)?Q(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||X(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||X(n)?(e.exit(`tableRow`),t(n)):Z(n)?Q(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||hw(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Vj(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Ij;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Uj(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Hj(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Hj(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Hj(f,t,o,i,n,d)):(o[0]=o[1],d=Hj(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Uj(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Rj(t.events,n))}return e}function Hj(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Wj(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Wj(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Wj(t.events,n[2]),a=Wj(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Wj(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Uj(e,t,n,r,i){let a=[],o=Wj(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Wj(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Gj={name:`tasklistCheck`,tokenize:qj};function Kj(){return{text:{91:Gj}}}function qj(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return hw(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return X(r)?t(r):Z(r)?e.check({tokenize:Jj},t,n)(r):n(r)}}function Jj(e,t,n){return Q(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Yj(e){return rw([dj(),Dj(),Fj(e),zj(),Kj()])}var Xj={};function Zj(e){let t=this,n=e||Xj,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Yj(n)),a.push(ej()),o.push(tj(n))}function Qj(e){return e===`skill`?`skill`:e===`panel_app`?`panel_app`:`default`}function $j(e,t,n){return e===`skill`?B(`border-transparent bg-transparent text-[color:var(--md-link)]`,n&&`cursor-pointer underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--md-link)]/30`,!n&&`cursor-default`):e===`panel_app`?t?`border-primary-foreground/40 bg-primary-foreground/22 text-primary-foreground`:`border-border bg-muted text-foreground`:t?`border-primary-foreground/40 bg-primary-foreground/22 text-primary-foreground`:`border-border bg-muted text-muted-foreground`}function eM(e,t){return e===`skill`?`text-current opacity-80`:t?`text-primary-foreground/80`:`text-muted-foreground`}function tM(e){return e===`panel_app`?(0,R.jsx)(E,{"aria-hidden":`true`,className:`h-3 w-3`}):(0,R.jsx)(ea,{"aria-hidden":`true`,className:`h-3 w-3`})}function nM({kind:e,label:t,isUser:n,onClick:r}){let i=Qj(e),a=!!r,o=B(`nextclaw-chat-inline-token mx-[2px] inline-flex max-w-full items-center gap-1 align-baseline text-[11px] font-medium`,i===`skill`?`h-auto rounded-none px-0 py-0`:`h-7 rounded-xl border px-2.5`,$j(i,n,a)),s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:B(`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,eM(i,n)),children:tM(i)}),(0,R.jsx)(`span`,{className:`truncate`,children:t})]});return a?(0,R.jsx)(`button`,{type:`button`,className:o,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),r?.()},children:s}):(0,R.jsx)(`span`,{className:o,title:t,children:s})}function rM(){return typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`}function iM(e){if(typeof document>`u`)return;let t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(e=>t.addRange(e)))}function aM(){let e=document.activeElement instanceof HTMLElement?document.activeElement:null,t=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:null,n=t?{input:t,start:t.selectionStart,end:t.selectionEnd}:null,r=document.getSelection();return{activeElement:e,activeInputSelection:n,ranges:r?Array.from({length:r.rangeCount},(e,t)=>r.getRangeAt(t).cloneRange()):[]}}function oM(e){let t=document.createElement(`textarea`);return t.value=e,t.setAttribute(`readonly`,``),t.setAttribute(`aria-hidden`,`true`),Object.assign(t.style,{fontSize:`12pt`,left:`-9999px`,opacity:`0`,pointerEvents:`none`,position:`fixed`,top:`0`}),t}function sM(e){try{e.focus({preventScroll:!0})}catch{e.focus()}}function cM(e){sM(e),e.select(),e.setSelectionRange(0,e.value.length)}function lM(){try{return typeof document.execCommand==`function`&&document.execCommand(`copy`)}catch{return!1}}function uM(e){if(!e.activeInputSelection)return!1;let{input:t,start:n,end:r}=e.activeInputSelection;return n===null||r===null?!1:(t.setSelectionRange(n,r),!0)}function dM(e){e.activeElement&&sM(e.activeElement),uM(e)||iM(e.ranges)}function fM(e){if(typeof document>`u`||!document.body)return!1;let t=aM(),n=oM(e);document.body.appendChild(n),cM(n);let r=lM();return n.remove(),dM(t),r}async function pM(e){if(!e)return!1;if(rM())try{return await navigator.clipboard.writeText(e),!0}catch{return fM(e)}return fM(e)}var mM=1300;function hM(e){let[t,n]=(0,L.useState)(!1),r=(0,L.useCallback)(async()=>{e.text&&(await pM(e.text)?n(!0):n(!1))},[e.text]);return(0,L.useEffect)(()=>{if(!t||typeof window>`u`)return;let r=window.setTimeout(()=>n(!1),e.resetDelayMs??mM);return()=>window.clearTimeout(r)},[t,e.resetDelayMs]),{copied:t,copy:r}}var gM=m(i(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,ee=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},j={begin:`\\\\[\\s\\S]`,relevance:0},M={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[j]},N={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[j]},te={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},ne=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},re=ne(`//`,`$`),ie=ne(`/\\*`,`\\*/`),ae=ne(`#`,`$`),oe={scope:`number`,begin:D,relevance:0},se={scope:`number`,begin:O,relevance:0},ce={scope:`number`,begin:k,relevance:0},le={scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[j,{begin:/\[/,end:/\]/,relevance:0,contains:[j]}]},ue={scope:`title`,begin:T,relevance:0},de={scope:`title`,begin:E,relevance:0},fe={begin:`\\.\\s*`+E,relevance:0},pe=Object.freeze({__proto__:null,APOS_STRING_MODE:M,BACKSLASH_ESCAPE:j,BINARY_NUMBER_MODE:ce,BINARY_NUMBER_RE:k,COMMENT:ne,C_BLOCK_COMMENT_MODE:ie,C_LINE_COMMENT_MODE:re,C_NUMBER_MODE:se,C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:ae,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:fe,NUMBER_MODE:oe,NUMBER_RE:D,PHRASAL_WORDS_MODE:te,QUOTE_STRING_MODE:N,REGEXP_MODE:le,RE_STARTERS_RE:A,SHEBANG:ee,TITLE_MODE:ue,UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:de});function me(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function he(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function ge(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=me,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function _e(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function ve(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function ye(e,t){e.relevance===void 0&&(e.relevance=1)}var be=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},P=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],xe=`keyword`;function Se(e,t,n=xe){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,Se(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,Ce(n[0],n[1])]})}}function Ce(e,t){return t?Number(t):we(e)?0:1}function we(e){return P.includes(e.toLowerCase())}var Te={},Ee=e=>{console.error(e)},De=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Oe=(e,t)=>{Te[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Te[`${e}/${t}`]=!0)},ke=Error();function Ae(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function je(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw Ee(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),ke;if(typeof e.beginScope!=`object`||e.beginScope===null)throw Ee(`beginScope must be object`),ke;Ae(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function Me(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw Ee(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),ke;if(typeof e.endScope!=`object`||e.endScope===null)throw Ee(`endScope must be object`),ke;Ae(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function Ne(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Pe(e){Ne(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),je(e),Me(e)}function Fe(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null),this.matcherRe=t(C(this.regexes.map(e=>e[1]),{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[he,ve,Pe,be].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[ge,_e,ye].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=Se(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return Le(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function Ie(e){return e?e.endsWithParent||Ie(e.starts):!1}function Le(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Ie(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var Re=`11.11.1`,ze=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},Be=i,Ve=a,He=Symbol(`nomatch`),Ue=7,We=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=M(n[1]);return t||(De(s.replace(`{}`,n[1])),De(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||M(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(Oe(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),Oe(`10.7.0`,`Please use highlight(code, options) instead.
46
+ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};ae(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,ae(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){j.addText(N);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(N),n=``;for(;t;){n+=N.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(j.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=Ue&&(te+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(N)}n+=N.substring(e),j.addText(n)}function f(){if(N===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){j.addText(N);return}e=v(A.subLanguage,N,!0,ee[A.subLanguage]),ee[A.subLanguage]=e._top}else e=S(N,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(te+=e.relevance),j.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),N=``}function m(e,t){e!==``&&(j.startScope(t),j.addText(e),j.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(N=i,d(),N=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&j.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(N,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),N=``):e.beginScope._multi&&(h(e.beginScope,t),N=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(N+=e[0],1):(ie=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?N+=t:(n.excludeBegin&&(N+=t),p(),!n.returnBegin&&!n.excludeBegin&&(N=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return He;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?N+=t:(a.returnEnd||a.excludeEnd||(N+=t),p(),a.excludeEnd&&(N=t));do A.scope&&j.closeNode(),!A.skip&&!A.subLanguage&&(te+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>j.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(N+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(N+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==He)return e}if(r.type===`illegal`&&a===``)return N+=`
47
+ `,1;if(re>1e5&&re>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return N+=a,a.length}let D=M(e);if(!D)throw Ee(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=Fe(D),k=``,A=a||O,ee={},j=new l.__emitter(l);w();let N=``,te=0,ne=0,re=0,ie=!1;try{if(D.__emitTokens)D.__emitTokens(n,j);else{for(A.matcher.considerAll();;){re++,ie?ie=!1:A.matcher.considerAll(),A.matcher.lastIndex=ne;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(ne,e.index),e);ne=e.index+t}E(n.substring(ne))}return j.finalize(),k=j.toHTML(),{language:e,value:k,relevance:te,illegal:!1,_emitter:j,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:Be(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:ne,context:n.slice(ne-100,ne+100),mode:t.mode,resultSoFar:k},_emitter:j};if(o)return{language:e,value:Be(n),illegal:!1,relevance:0,errorRaised:t,_emitter:j,_top:A};throw t}}function b(e){let t={value:Be(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(M).filter(te).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(M(e.language).supersetOf===t.language)return 1;if(M(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(ae(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new ze(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),ae(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=Ve(l,e)}let E=()=>{k(),Oe(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),Oe(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(Ee(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)Ee(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&N(i.aliases,{languageName:n})}function ee(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function j(){return Object.keys(t)}function M(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function N(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function te(e){let t=M(e);return t&&!t.disableAutodetect}function ne(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function re(e){ne(e),a.push(e)}function ie(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function ae(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function oe(e){return Oe(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),Oe(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:oe,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:ee,listLanguages:j,getLanguage:M,registerAliases:N,autoDetection:te,inherit:Ve,addPlugin:re,removePlugin:ie}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=Re,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in pe)typeof pe[e]==`object`&&n(pe[e]);return Object.assign(e,pe),e},Ge=We({});Ge.newInstance=()=>We({}),t.exports=Ge,Ge.HighlightJS=Ge,Ge.default=Ge}))()).default;function _M(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var vM=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),yM=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),bM=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),xM=[...yM,...bM],SM=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),CM=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),wM=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),TM=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function EM(e){let t=e.regex,n=vM(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+CM.join(`|`)+`)`},{begin:`:(:)?(`+wM.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+TM.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:SM.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+xM.join(`|`)+`)\\b`}]}}function DM(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}var OM=`[A-Za-z$_][0-9A-Za-z$_]*`,kM=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),AM=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],jM=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),MM=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],NM=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],PM=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],FM=[].concat(NM,jM,MM);function IM(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=OM,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:OM,keyword:kM,literal:AM,built_in:FM,"variable.language":PM},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...jM,...MM]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...NM,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},ee=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,j={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},j,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ee,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function LM(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function RM(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function zM(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=`and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield`.split(`.`),i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:`__import__.abs.all.any.ascii.bin.bool.breakpoint.bytearray.bytes.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.exec.filter.float.format.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.print.property.range.repr.reversed.round.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip`.split(`.`),literal:[`__debug__`,`Ellipsis`,`False`,`None`,`NotImplemented`,`True`],type:[`Any`,`Callable`,`Coroutine`,`Dict`,`List`,`Literal`,`Generic`,`Optional`,`Sequence`,`Set`,`Tuple`,`Type`,`Union`]},a={className:`meta`,begin:/^(>>>|\.\.\.) /},o={className:`subst`,begin:/\{/,end:/\}/,keywords:i,illegal:/#/},s={begin:/\{\{/,relevance:0},c={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l=`[0-9](_?[0-9])*`,u=`(\\b(${l}))?\\.(${l})|\\b(${l})\\.`,d=`\\b|${r.join(`|`)}`,f={className:`number`,relevance:0,variants:[{begin:`(\\b(${l})|(${u}))[eE][+-]?(${l})[jJ]?(?=${d})`},{begin:`(${u})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${l})[jJ](?=${d})`}]},p={className:`comment`,begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:`params`,variants:[{className:``,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:[`self`,a,f,c,e.HASH_COMMENT_MODE]}]};return o.contains=[c,f,a],{name:`Python`,aliases:[`py`,`gyp`,`ipython`],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,f,{scope:`variable.language`,match:/\bself\b/},{beginKeywords:`if`,relevance:0},{match:/\bor\b/,scope:`keyword`},c,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:`keyword`,3:`title.class`,6:`title.class.inherited`}},{className:`meta`,begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[f,m,c]}]}}function BM(e){return{name:`Shell Session`,aliases:[`console`,`shellsession`],contains:[{className:`meta.prompt`,begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:`bash`}}]}}function VM(e){let t=e.regex,n=e.COMMENT(`--`,`$`),r={scope:`string`,variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=[`true`,`false`,`unknown`],o=[`double precision`,`large object`,`with timezone`,`without timezone`],s=`bigint.binary.blob.boolean.char.character.clob.date.dec.decfloat.decimal.float.int.integer.interval.nchar.nclob.national.numeric.real.row.smallint.time.timestamp.varchar.varying.varbinary`.split(`.`),c=[`add`,`asc`,`collation`,`desc`,`final`,`first`,`last`,`view`],l=`abs.acos.all.allocate.alter.and.any.are.array.array_agg.array_max_cardinality.as.asensitive.asin.asymmetric.at.atan.atomic.authorization.avg.begin.begin_frame.begin_partition.between.bigint.binary.blob.boolean.both.by.call.called.cardinality.cascaded.case.cast.ceil.ceiling.char.char_length.character.character_length.check.classifier.clob.close.coalesce.collate.collect.column.commit.condition.connect.constraint.contains.convert.copy.corr.corresponding.cos.cosh.count.covar_pop.covar_samp.create.cross.cube.cume_dist.current.current_catalog.current_date.current_default_transform_group.current_path.current_role.current_row.current_schema.current_time.current_timestamp.current_path.current_role.current_transform_group_for_type.current_user.cursor.cycle.date.day.deallocate.dec.decimal.decfloat.declare.default.define.delete.dense_rank.deref.describe.deterministic.disconnect.distinct.double.drop.dynamic.each.element.else.empty.end.end_frame.end_partition.end-exec.equals.escape.every.except.exec.execute.exists.exp.external.extract.false.fetch.filter.first_value.float.floor.for.foreign.frame_row.free.from.full.function.fusion.get.global.grant.group.grouping.groups.having.hold.hour.identity.in.indicator.initial.inner.inout.insensitive.insert.int.integer.intersect.intersection.interval.into.is.join.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.language.large.last_value.lateral.lead.leading.left.like.like_regex.listagg.ln.local.localtime.localtimestamp.log.log10.lower.match.match_number.match_recognize.matches.max.member.merge.method.min.minute.mod.modifies.module.month.multiset.national.natural.nchar.nclob.new.no.none.normalize.not.nth_value.ntile.null.nullif.numeric.octet_length.occurrences_regex.of.offset.old.omit.on.one.only.open.or.order.out.outer.over.overlaps.overlay.parameter.partition.pattern.per.percent.percent_rank.percentile_cont.percentile_disc.period.portion.position.position_regex.power.precedes.precision.prepare.primary.procedure.ptf.range.rank.reads.real.recursive.ref.references.referencing.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.release.result.return.returns.revoke.right.rollback.rollup.row.row_number.rows.running.savepoint.scope.scroll.search.second.seek.select.sensitive.session_user.set.show.similar.sin.sinh.skip.smallint.some.specific.specifictype.sql.sqlexception.sqlstate.sqlwarning.sqrt.start.static.stddev_pop.stddev_samp.submultiset.subset.substring.substring_regex.succeeds.sum.symmetric.system.system_time.system_user.table.tablesample.tan.tanh.then.time.timestamp.timezone_hour.timezone_minute.to.trailing.translate.translate_regex.translation.treat.trigger.trim.trim_array.true.truncate.uescape.union.unique.unknown.unnest.update.upper.user.using.value.values.value_of.var_pop.var_samp.varbinary.varchar.varying.versioning.when.whenever.where.width_bucket.window.with.within.without.year`.split(`.`),u=`abs.acos.array_agg.asin.atan.avg.cast.ceil.ceiling.coalesce.corr.cos.cosh.count.covar_pop.covar_samp.cume_dist.dense_rank.deref.element.exp.extract.first_value.floor.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.last_value.lead.listagg.ln.log.log10.lower.max.min.mod.nth_value.ntile.nullif.percent_rank.percentile_cont.percentile_disc.position.position_regex.power.rank.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.row_number.sin.sinh.sqrt.stddev_pop.stddev_samp.substring.substring_regex.sum.tan.tanh.translate.translate_regex.treat.trim.trim_array.unnest.upper.value_of.var_pop.var_samp.width_bucket`.split(`.`),d=[`current_catalog`,`current_date`,`current_default_transform_group`,`current_path`,`current_role`,`current_schema`,`current_transform_group_for_type`,`current_user`,`session_user`,`system_time`,`system_user`,`current_time`,`localtime`,`current_timestamp`,`localtimestamp`],f=[`create table`,`insert into`,`primary key`,`foreign key`,`not null`,`alter table`,`add constraint`,`grouping sets`,`on overflow`,`character set`,`respect nulls`,`ignore nulls`,`nulls first`,`nulls last`,`depth first`,`breadth first`],p=u,m=[...l,...c].filter(e=>!u.includes(e)),h={scope:`variable`,match:/@[a-z0-9][a-z0-9_]*/},g={scope:`operator`,match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,`\\s+`))),/\b/)}let y={scope:`keyword`,match:v(f),relevance:0};function b(e,{exceptions:t,when:n}={}){let r=n;return t||=[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}return{name:`SQL`,case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:b(m,{when:e=>e.length<3}),literal:a,type:s,built_in:d},contains:[{scope:`type`,match:v(o)},y,_,h,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}var HM=`[A-Za-z$_][0-9A-Za-z$_]*`,UM=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),WM=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],GM=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),KM=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],qM=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],JM=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],YM=[].concat(qM,GM,KM);function XM(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=HM,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:HM,keyword:UM,literal:WM,built_in:YM,"variable.language":JM},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...GM,...KM]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...qM,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},ee=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,j={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},j,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ee,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function ZM(e){let t=e.regex,n=XM(e),r=HM,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:HM,keyword:UM.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:WM,built_in:YM.concat(i),"variable.language":JM},l={className:`meta`,begin:`@`+r},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function QM(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function $M(e){let t=`true false yes no null`,n=`[\\w#;/?:@&=+$,.~*'()[\\]]+`,r={className:`attr`,variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:`template-variable`,variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={className:`string`,relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:`char.escape`,relevance:0}]},o={className:`string`,relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},s=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),c={className:`number`,begin:`\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b`},l={end:`,`,endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},u={begin:/\{/,end:/\}/,contains:[l],illegal:`\\n`,relevance:0},d={begin:`\\[`,end:`\\]`,contains:[l],illegal:`\\n`,relevance:0},f=[r,{className:`meta`,begin:`^---\\s*$`,relevance:10},{className:`string`,begin:`[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*`},{begin:`<%[%=-]?`,end:`[%-]?%>`,subLanguage:`ruby`,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:`!\\w+!`+n},{className:`type`,begin:`!<`+n+`>`},{className:`type`,begin:`!`+n},{className:`type`,begin:`!!`+n},{className:`meta`,begin:`&`+e.UNDERSCORE_IDENT_RE+`$`},{className:`meta`,begin:`\\*`+e.UNDERSCORE_IDENT_RE+`$`},{className:`bullet`,begin:`-(?=[ ]|$)`,relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},c,{className:`number`,begin:e.C_NUMBER_RE+`\\b`,relevance:0},u,d,a,o],p=[...f];return p.pop(),p.push(s),l.contains=p,{name:`YAML`,case_insensitive:!0,aliases:[`yml`],contains:f}}var eN=new Set([`text`,`txt`,`plain`,`plaintext`,`none`,`output`]),tN=[`typescript`,`javascript`,`json`,`bash`,`shell`,`python`,`css`,`xml`,`markdown`,`yaml`,`sql`,`diff`],nN=4,rN=[{name:`typescript`,language:ZM,aliases:[`ts`,`tsx`]},{name:`javascript`,language:IM,aliases:[`js`,`jsx`,`mjs`,`cjs`]},{name:`json`,language:LM,aliases:[`jsonc`]},{name:`bash`,language:_M,aliases:[`sh`,`zsh`]},{name:`shell`,language:BM,aliases:[`console`,`terminal`]},{name:`python`,language:zM,aliases:[`py`]},{name:`css`,language:EM},{name:`xml`,language:QM,aliases:[`html`,`svg`]},{name:`markdown`,language:RM,aliases:[`md`,`mdx`]},{name:`yaml`,language:$M,aliases:[`yml`]},{name:`sql`,language:VM},{name:`diff`,language:DM,aliases:[`patch`]}];function iN(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function aN(e){return e.trim().toLowerCase()}var oN=new class{constructor(){this.highlight=(e,t)=>{let n=aN(t);if(!e||eN.has(n))return this.createPlainTextResult(e,n||`text`);if(this.engine.getLanguage(n)){let t=this.engine.highlight(e,{language:n,ignoreIllegals:!0});return{html:t.value,language:t.language??n,highlighted:!0}}let r=this.engine.highlightAuto(e,tN);return r.language&&r.relevance>=nN?{html:r.value,language:r.language,highlighted:!0}:this.createPlainTextResult(e,n||`text`)},this.createPlainTextResult=(e,t)=>({html:iN(e),language:t,highlighted:!1}),this.engine=gM.newInstance(),rN.forEach(e=>{this.engine.registerLanguage(e.name,e.language),e.aliases&&this.engine.registerAliases(e.aliases,{languageName:e.name})})}},sN=/language-([a-z0-9-]+)/i;function cN(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(cN).join(``):``}function lN(e){let t=cN(e);return t.endsWith(`
48
+ `)?t.slice(0,-1):t}function uN(e){return(e?sN.exec(e):null)?.[1]?.toLowerCase()||`text`}function dN({className:e,children:t,texts:n}){let r=(0,L.useMemo)(()=>uN(e),[e]),i=(0,L.useMemo)(()=>lN(t),[t]),a=(0,L.useMemo)(()=>oN.highlight(i,r),[i,r]),o=(0,L.useMemo)(()=>{let t=`language-${a.language}`;return B(`hljs`,e,e?.includes(`language-`)?void 0:t)},[e,a.language]),{copied:s,copy:c}=hM({text:i});return(0,R.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,R.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,R.jsx)(`span`,{className:`chat-codeblock-language`,children:r}),(0,R.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void c(),"aria-label":s?n.copiedCodeLabel:n.copyCodeLabel,children:[s?(0,R.jsx)(cr,{className:`h-3.5 w-3.5`}):(0,R.jsx)(ui,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{children:s?n.copiedCodeLabel:n.copyCodeLabel})]})]}),(0,R.jsx)(`pre`,{children:(0,R.jsx)(`code`,{className:o,"data-highlighted":a.highlighted?`true`:`false`,dangerouslySetInnerHTML:{__html:a.html}})})]})}var fN=`nextclaw-inline`,pN=/language-([a-z0-9-]+)/i,mN=new Set([`auto`,`source`,`rendered`]);function hN(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gN(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function _N(e){return Number.isInteger(e)&&Number(e)>0?Number(e):void 0}function vN(e){let t=gN(e);return t&&mN.has(t)?t:void 0}function yN(e){let{payload:t}=e;return hN(t)?t:null}function bN(e){let t=yN(e);if(!t)return null;let n=gN(t.path);return n?{type:`file`,payload:{path:n,line:_N(t.line),column:_N(t.column),viewer:vN(t.viewer)}}:null}function xN(e){let t=yN(e);if(!t)return null;let n=gN(t.url);return n?{type:`url`,payload:{url:n}}:null}function SN(e){let t=yN(e);if(!t)return null;let n=gN(t.appId);return n?{type:`panel_app`,payload:{appId:n}}:null}function CN(e){let t=yN(e);return!t||!(`value`in t)?null:{type:`json`,payload:{value:t.value}}}function wN(e){if(!hN(e))return null;let t=gN(e.type);return t===`file`?bN(e):t===`url`?xN(e):t===`panel_app`?SN(e):t===`json`?CN(e):null}function TN(e){return(e?pN.exec(e):null)?.[1]?.toLowerCase()===fN}function EN(e){let t=e.endsWith(`
49
+ `)?e.slice(0,-1):e,n;try{n=JSON.parse(t)}catch{return null}if(!hN(n))return null;let r=wN(n.target);return r?{target:r,title:gN(n.title),description:gN(n.description)}:null}function DN(e){if(e.title)return e.title;if(e.target.type===`file`){let t=e.target.payload.path.split(`/`).filter(Boolean);return t[t.length-1]??e.target.payload.path}return e.target.type===`url`?e.target.payload.url:e.target.type===`panel_app`?e.target.payload.appId:`JSON`}function ON(e){return e.target.type===`file`?e.target.payload.path:e.target.type===`url`?e.target.payload.url:e.target.type===`panel_app`?e.target.payload.appId:JSON.stringify(e.target.payload.value,null,2)}function kN({display:e}){let t=`h-3.5 w-3.5 shrink-0 text-muted-foreground`;return e.target.type===`file`?(0,R.jsx)(dr,{className:t,"aria-hidden":!0}):e.target.type===`url`?(0,R.jsx)(Mi,{className:t,"aria-hidden":!0}):e.target.type===`panel_app`?(0,R.jsx)(E,{className:t,"aria-hidden":!0}):(0,R.jsx)(ci,{className:t,"aria-hidden":!0})}function AN(e){return e.length>1200?`${e.slice(0,1200)}\n...`:e}function jN({display:e}){let t=DN(e),n=ON(e),r=e.target.type===`json`?AN(n):n;return(0,R.jsxs)(`section`,{className:B(`my-2 max-w-full border-l-2 border-border bg-muted/30 px-3 py-2`,`text-xs leading-relaxed text-foreground`),"data-nextclaw-inline-display":`true`,"data-nextclaw-inline-display-type":e.target.type,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(kN,{display:e}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]}),e.description?(0,R.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[12px] text-muted-foreground`,children:e.description}):null,(0,R.jsx)(`pre`,{className:B(`mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words`,`font-mono text-[11px] leading-relaxed text-muted-foreground`),children:r})]})}function MN({display:e,renderInlineDisplay:t}){let n=t?.(e);return n==null?(0,R.jsx)(jN,{display:e}):(0,R.jsx)(R.Fragment,{children:n})}var NN=14e4,PN=new Set([`http:`,`https:`,`mailto:`,`tel:`]),FN=`data-chat-inline-token-kind`,IN=`data-chat-inline-token-key`,LN=`data-chat-inline-token-label`,RN=`data-chat-inline-token-raw-text`,zN=RegExp(`^(?![a-zA-Z][a-zA-Z\\d+.-]*:)(?!//)(?:(?:[^/\\s?#]+/)+[^?#\\s]+\\.[A-Za-z0-9_-]+|[^/\\s?#]+\\.(?:cjs|css|cts|html?|js|json|jsx|mdx?|mjs|mts|tsx?|txt|ya?ml))(?::\\d+(?::\\d+)?)?(?:[?#].*)?$`,`i`);function BN(e){return e.length<=NN?e:`${e.slice(0,NN)}\n\n...`}function VN(e){if(!e)return null;if(e.startsWith(`#`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||zN.test(e))return e;try{let t=new URL(e);return PN.has(t.protocol)?e:null}catch{return null}}function HN(e){return/^https?:\/\//i.test(e)}function UN(e){return e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/Users/`)||e.startsWith(`/home/`)||e.startsWith(`/tmp/`)||e.startsWith(`/var/`)||zN.test(e)||/^\/.+\.[A-Za-z0-9_-]+(?::\d+(?::\d+)?)?$/.test(e)}function WN(e){let t=new URLSearchParams(e.split(`#`)[0]?.split(`?`)[1]??``).get(`viewer`),n=e.split(`#`)[0]?.split(`?`)[0]??e,r=decodeURIComponent(n);if(!UN(r))return null;let i=/^(.*?)(?::(\d+)(?::(\d+))?)$/.exec(r),a=i?.[1]??r,o=i?.[2]?Number(i[2]):void 0,s=i?.[3]?Number(i[3]):void 0;return{path:a,label:a.split(`/`).filter(Boolean).pop()??a,viewMode:`preview`,...t===`source`||t===`rendered`?{previewViewer:t}:{},...typeof o==`number`?{line:o}:{},...typeof s==`number`?{column:s}:{}}}function GN(e){if(!e||e.length===0)return[];let t=new Set,n=[];for(let r of e)!r.rawText||t.has(r.rawText)||(t.add(r.rawText),n.push(r));return n.sort((e,t)=>t.rawText.length-e.rawText.length)}function KN(e){return{type:`chatInlineToken`,data:{hName:`span`,hProperties:{[FN]:e.kind,[IN]:e.key,[LN]:e.label,[RN]:e.rawText},hChildren:[{type:`text`,value:e.label}]}}}function qN(e,t,n){let r=null;for(let i of n){let n=e.indexOf(i.rawText,t);n<0||(!r||n<r.index||n===r.index&&i.rawText.length>r.token.rawText.length)&&(r={index:n,token:i})}return r}function JN(e,t){let n=[],r=0;for(;r<e.length;){let i=qN(e,r,t);if(!i){n.push({type:`text`,value:e.slice(r)});break}i.index>r&&n.push({type:`text`,value:e.slice(r,i.index)}),n.push(KN(i.token)),r=i.index+i.token.rawText.length}return n.length>0?n:[{type:`text`,value:e}]}function YN(e,t){if(e.type===`code`||e.type===`inlineCode`||!e.children)return;let n=[];for(let r of e.children){if(r.type===`text`&&typeof r.value==`string`){n.push(...JN(r.value,t));continue}YN(r,t),n.push(r)}e.children=n}function XN(e){let t=GN(e);return()=>e=>{t.length!==0&&YN(e,t)}}function ZN(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function QN({text:e,role:t,texts:n,inline:r=!1,inlineTokens:i,onFileOpen:a,onInlineTokenClick:o,renderInlineDisplay:s}){let c=t===`user`,l=(0,L.useMemo)(()=>i&&i.length>0?[Zj,XN(i)]:[Zj],[i]),u=(0,L.useMemo)(()=>({p:({children:e})=>r?(0,R.jsx)(R.Fragment,{children:e}):(0,R.jsx)(`p`,{children:e}),span:({node:e,children:t,...n})=>{let r=n,i=ZN(r,FN),a=ZN(r,IN),s=ZN(r,LN),l=ZN(r,RN);return i&&a&&s&&l?(0,R.jsx)(nM,{kind:i,label:s,isUser:c,onClick:o?()=>o({kind:i,key:a,label:s,rawText:l}):void 0}):(0,R.jsx)(`span`,{...n,children:t})},a:({node:e,href:t,children:n,...r})=>{let i=VN(t);if(!i)return(0,R.jsx)(`span`,{className:`chat-link-invalid`,children:n});let o=HN(i),s=o?null:WN(i),c=e=>{!a||!s||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),a(s))};return(0,R.jsx)(`a`,{...r,href:i,onClick:c,target:o?`_blank`:void 0,rel:o?`noreferrer noopener`:void 0,children:n})},table:({node:e,children:t,...n})=>(0,R.jsx)(`div`,{className:`chat-table-wrap`,children:(0,R.jsx)(`table`,{...n,children:t})}),input:({node:e,type:t,checked:n,...r})=>t===`checkbox`?(0,R.jsx)(`input`,{...r,type:`checkbox`,checked:n,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,R.jsx)(`input`,{...r,type:t}),img:({node:e,src:t,alt:n,...r})=>{let i=VN(t);return i?(0,R.jsx)(`img`,{...r,src:i,alt:n||``,loading:`lazy`,decoding:`async`}):null},code:({node:e,className:t,children:r,...i})=>{let a=String(r??``);if(!t&&!a.includes(`
50
+ `))return(0,R.jsx)(`code`,{...i,className:B(`chat-inline-code`,t),children:r});let o=TN(t)?EN(a):null;return o?(0,R.jsx)(MN,{display:o,renderInlineDisplay:s}):(0,R.jsx)(dN,{className:t,texts:n,children:r})}}),[r,c,a,o,s,n]);return(0,R.jsx)(r?`span`:`div`,{className:B(`chat-markdown`,c?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,R.jsx)(qO,{skipHtml:!0,remarkPlugins:l,components:u,children:BN(e)})})}var $N={archive:`bg-muted text-muted-foreground`,audio:`bg-muted text-muted-foreground`,code:`bg-muted text-muted-foreground`,data:`bg-muted text-muted-foreground`,document:`bg-muted text-muted-foreground`,generic:`bg-muted text-muted-foreground`,image:`bg-muted text-muted-foreground`,pdf:`bg-muted text-muted-foreground`,sheet:`bg-muted text-muted-foreground`,video:`bg-muted text-muted-foreground`},eP=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),tP=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),nP=new Set([`avif`,`bmp`,`gif`,`heic`,`heif`,`ico`,`jpeg`,`jpg`,`png`,`svg`,`tif`,`tiff`,`webp`]),rP=new Set([`aac`,`flac`,`m4a`,`mp3`,`ogg`,`opus`,`wav`,`weba`]),iP=new Set([`avi`,`m4v`,`mov`,`mp4`,`mkv`,`webm`,`wmv`]),aP=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),oP=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),sP=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function cP(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function lP(e,t){let n=uP(e);if(n)return n.toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function uP(e){return/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``}function dP(e){return typeof e==`string`&&/^data:image\//i.test(e.trim())}function fP(e){return nP.has(e)?e===`jpg`||e===`jpeg`?`image/jpeg`:e===`svg`?`image/svg+xml`:`image/${e}`:rP.has(e)?e===`mp3`?`audio/mpeg`:e===`m4a`?`audio/mp4`:e===`weba`?`audio/webm`:`audio/${e}`:iP.has(e)?e===`mov`?`video/quicktime`:e===`m4v`?`video/mp4`:`video/${e}`:e===`pdf`?`application/pdf`:null}function pP(e){let t=uP(e);return t?fP(t):null}function mP(e){let t=e.mimeType.trim().toLowerCase();return t.length>0&&t!==`application/octet-stream`?t:pP(e.label)}function hP(e){let t=e.mimeType.trim().toLowerCase(),n=uP(e.label);return e.isImage||t.startsWith(`image/`)||nP.has(n)||dP(e.dataUrl)}function gP(e,t){let n=uP(e),r=t.toLowerCase();return r.startsWith(`image/`)||nP.has(n)?`image`:r.startsWith(`audio/`)||rP.has(n)?`audio`:r.startsWith(`video/`)||iP.has(n)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:sP.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:oP.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:tP.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:eP.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:aP.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function _P(e){let t=gP(e.label,e.mimeType),n=cP(e.sizeBytes);return{category:t,extension:lP(e.label,e.mimeType),sizeLabel:n}}var vP={archive:`Archive`,audio:`Audio`,code:`Code file`,data:`Data file`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF document`,sheet:`Spreadsheet`,video:`Video`},yP={archive:vi,audio:yi,code:bi,data:Si,document:dr,generic:Ti,image:xi,pdf:dr,sheet:Ci,video:wi};function bP(e,t){return t?.attachmentCategoryLabels?.[e]??vP[e]}function xP(e,t,n){return(0,R.jsx)(`div`,{className:B(`mt-0.5 text-[11px] leading-4`,n?`text-foreground/55`:`text-muted-foreground`),children:t?`${e} · ${t}`:e})}function SP(e,t,n){return(0,R.jsx)(`span`,{className:B(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-medium`,n?t?`bg-black/5 text-foreground/75`:`bg-muted text-muted-foreground`:t?`bg-black/[0.03] text-foreground/45`:`bg-muted/70 text-muted-foreground/70`),children:e})}function CP(e){let{label:t,href:n,isUser:r,onOpen:i}=e,a=B(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors`,r?`bg-black/5 text-foreground/75 hover:bg-black/10 hover:text-foreground`:`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`);return i?(0,R.jsx)(`button`,{type:`button`,className:a,onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},children:t}):n?(0,R.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:a,children:t}):SP(t,r,!1)}function wP({category:e,isUser:t}){let n=yP[e];return(0,R.jsx)(`div`,{className:B(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,t?`bg-black/5 text-foreground/70`:$N[e]),children:(0,R.jsx)(n,{className:B(`h-4 w-4`,t?`text-foreground/70`:`text-current`),strokeWidth:2})})}function TP({alt:e,closeLabel:t,onClose:n,src:r}){let i=(0,L.useId)();return(0,L.useEffect)(()=>{let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t)}},[n]),(0,cx.createPortal)((0,R.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":i,className:`fixed inset-0 z-[var(--z-modal,10050)] flex items-center justify-center bg-black/80 p-4 backdrop-blur-[2px]`,"data-testid":`chat-message-image-lightbox`,onClick:n,children:[(0,R.jsx)(`span`,{id:i,className:`sr-only`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":t,className:`absolute right-4 top-4 inline-flex h-9 w-9 items-center justify-center rounded-full bg-black/55 text-white transition-colors hover:bg-black/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/70`,onClick:e=>{e.stopPropagation(),n()},children:(0,R.jsx)(Cr,{className:`h-4 w-4`,strokeWidth:2})}),(0,R.jsx)(`img`,{src:r,alt:e,className:`max-h-[min(92vh,100%)] max-w-[min(96vw,100%)] object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]}),document.body)}function EP({expandLabel:e,closeLabel:t,file:n,sizeLabel:r}){let[i,a]=(0,L.useState)(!1);if(!n.dataUrl)return null;let o=()=>a(!0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`group/image relative w-fit max-w-full overflow-hidden rounded-xl`,children:[(0,R.jsx)(`button`,{type:`button`,className:`block w-fit max-w-full text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,onClick:o,onDoubleClick:e=>{e.preventDefault(),o()},"aria-label":e,children:(0,R.jsx)(`img`,{src:n.dataUrl,alt:n.label,className:`block h-auto max-h-[26rem] max-w-full rounded-xl bg-transparent object-contain`})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":e,className:`absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md bg-black/45 text-white opacity-0 transition-opacity duration-150 hover:bg-black/60 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/70 group-hover/image:opacity-100`,onClick:e=>{e.preventDefault(),e.stopPropagation(),o()},children:(0,R.jsx)(gi,{className:`h-3.5 w-3.5`,strokeWidth:2})}),r?(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-end justify-start bg-gradient-to-t from-black/50 via-black/15 to-transparent px-2.5 pb-2 pt-8 opacity-0 transition-opacity duration-150 group-hover/image:opacity-100 group-focus-within/image:opacity-100`,children:(0,R.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-black/40 px-1.5 py-0.5 text-[10px] font-medium text-white/95 backdrop-blur-sm`,children:r})}):null]}),i?(0,R.jsx)(TP,{alt:n.label,closeLabel:t,onClose:()=>a(!1),src:n.dataUrl}):null]})}function DP(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:o}=e;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-2`,children:[(0,R.jsx)(wP,{category:t,isUser:a}),(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.label}),xP(r,i,a)]}),o]})})]})}function OP(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,shellClasses:o,actionLabel:s,onOpen:c}=e;if(!n.dataUrl||t!==`audio`&&t!==`video`)return null;let l=mP(n);return(0,R.jsxs)(`div`,{className:o,children:[DP({category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:CP({label:s,href:n.dataUrl,isUser:a,onOpen:c?()=>c(n):void 0})}),(0,R.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:t===`audio`?(0,R.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":n.label,className:`block w-full`,children:(0,R.jsx)(`source`,{src:n.dataUrl,...l?{type:l}:{}})}):(0,R.jsx)(`div`,{className:B(`overflow-hidden rounded-lg`,a?`bg-black/10`:`bg-muted ring-1 ring-border/70`),children:(0,R.jsx)(`video`,{controls:!0,preload:`metadata`,playsInline:!0,"aria-label":n.label,className:`block max-h-[28rem] w-full bg-black`,children:(0,R.jsx)(`source`,{src:n.dataUrl,...l?{type:l}:{}})})})})]})}function kP({file:e,isUser:t=!1,texts:n,onOpen:r}){let{category:i,sizeLabel:a}=_P(e),o=hP(e)&&!!e.dataUrl,s=i===`audio`&&!!e.dataUrl,c=i===`video`&&!!e.dataUrl,l=!!e.dataUrl,u=l?n?.attachmentOpenLabel??`Open`:n?.attachmentAttachedLabel??`Attached`,d=n?.attachmentExpandLabel??`Expand image`,f=n?.attachmentCloseLabel??`Close preview`,p=bP(i,n),m=B(`block overflow-hidden rounded-xl border transition-colors`,t?`border-black/8 bg-black/[0.03] text-foreground`:`border-border/70 bg-card text-card-foreground`,l&&(t?`hover:bg-black/[0.05]`:`hover:bg-muted/50`));if(o)return(0,R.jsx)(EP,{expandLabel:d,closeLabel:f,file:e,sizeLabel:a});if(s||c)return OP({category:i,file:e,categoryLabel:p,sizeLabel:a,isUser:t,shellClasses:m,actionLabel:u,onOpen:r});let h=DP({category:i,file:e,categoryLabel:p,sizeLabel:a,isUser:t,action:SP(u,t,l)});return!l||!e.dataUrl?(0,R.jsx)(`div`,{className:m,children:h}):r?(0,R.jsx)(`button`,{type:`button`,className:B(m,`group w-full text-left`),onClick:()=>r(e),children:h}):(0,R.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,className:B(m,`group`),children:h})}function AP(e){let{isInProgress:t}=e,[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(t);(0,L.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}var jP=10;function MP({contentVersion:e,hasContent:t,isLoading:n,resetKey:r,scrollRef:i,stickyThresholdPx:a}){let[o,s]=(0,L.useState)(!0),c=(0,L.useRef)(!0),l=(0,L.useRef)(!1),u=(0,L.useRef)(null),d=(0,L.useRef)(!1),f=(0,L.useRef)(null),p=(0,L.useCallback)(e=>{c.current=e,s(e)},[]),m=(0,L.useCallback)(e=>e.scrollHeight-e.scrollTop-e.clientHeight<=(a??jP),[a]),h=(0,L.useCallback)((e=`auto`)=>{i.current&&(f.current!==null&&cancelAnimationFrame(f.current),f.current=requestAnimationFrame(()=>{f.current=null;let t=i.current;t&&(l.current=!0,typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)}))},[i]),g=(0,L.useCallback)(()=>{p(!0),h()},[h,p]),_=(0,L.useCallback)(()=>{if(l.current){l.current=!1;return}let e=i.current;e&&p(m(e))},[m,i,p]);return(0,L.useEffect)(()=>{u.current!==r&&(u.current=r,p(!0),d.current=!0)},[r,p]),(0,L.useEffect)(()=>()=>{let e=f.current;e!==null&&(cancelAnimationFrame(e),f.current=null)},[]),(0,L.useLayoutEffect)(()=>{!d.current||n||!t||i.current&&(d.current=!1,h())},[t,n,h,i]),(0,L.useLayoutEffect)(()=>{!c.current||!t||i.current&&h()},[e,t,h,i]),{isAtBottom:o,onScroll:_,scrollToBottom:g}}var NP=`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-current`,PP=`group/process-row flex w-full min-w-0 items-center gap-1.5 py-0 text-[0.925rem] font-normal leading-[1.72] text-muted-foreground`;function FP({children:e,className:t}){return(0,R.jsx)(`span`,{className:B(NP,t),children:e})}function IP({children:e,className:t,interactive:n=!1,onClick:r,role:i,tabIndex:a,onKeyDown:o}){return(0,R.jsx)(`div`,{className:B(PP,n?`cursor-pointer transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`:null,t),onClick:r,role:i,tabIndex:a,onKeyDown:o,children:e})}function LP({label:e,openGroup:t,open:n=!1,className:r,labelClassName:i,onClick:a}){return(0,R.jsxs)(`button`,{type:`button`,className:B(PP,`m-0 w-full border-0 bg-transparent p-0 text-left shadow-none transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`,r),"aria-expanded":n,onClick:a,children:[(0,R.jsx)(`span`,{className:B(`min-w-0 shrink truncate`,i),children:e}),(0,R.jsx)(`span`,{className:B(`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-muted-foreground/80 transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/process-row:opacity-100 focus-visible:opacity-100`),children:(0,R.jsx)(ti,{className:B(`h-[1.05em] w-[1.05em] transition-transform`,n&&`rotate-90`),strokeWidth:2.25})})]})}function RP(e,t,n){let r=Array.from(t).length;return(n??`${e} · {count}`).split(`{count}`).join(String(r))}function zP({label:e,text:t,characterCountTemplates:n,isUser:r,isInProgress:i}){let{isOpen:a,onSummaryClick:o}=AP({isInProgress:i}),s=(0,L.useRef)(null),c=RP(e,t,i?n?.inProgress:n?.completed),{onScroll:l}=MP({scrollRef:s,resetKey:`${c}:${i?`streaming`:`idle`}`,isLoading:!1,hasContent:t.length>0,contentVersion:t,stickyThresholdPx:20});return(0,R.jsxs)(`div`,{className:`group/reasoning`,children:[(0,R.jsx)(LP,{openGroup:`reasoning`,open:a,label:c,labelClassName:r?`text-primary-100`:void 0,onClick:o}),a?(0,R.jsx)(`div`,{ref:s,onScroll:l,"data-reasoning-scroll":`true`,className:B(`mt-1 w-fit max-w-[500px] max-h-56 overflow-y-auto rounded-lg custom-scrollbar`,r?`bg-primary/70`:`bg-muted`),children:(0,R.jsx)(`pre`,{className:`min-w-0 whitespace-pre-wrap break-all p-2 text-[11px]`,children:t})}):null]})}function BP({children:e,className:t}){return(0,R.jsx)(`div`,{className:B(`relative my-0 flex w-full min-w-0 max-w-full flex-col text-[0.925rem] leading-[1.72] text-muted-foreground`,t),children:e})}function VP({children:e,className:t}){return(0,R.jsx)(`div`,{className:B(`mt-0.5 w-full max-w-full min-w-0 overflow-hidden pl-[calc(1.15em+0.375rem)] text-[0.925rem] leading-[1.72] text-muted-foreground`,t),children:e})}var HP={running:{text:`text-muted-foreground`,icon:vr,spin:!0},success:{text:`text-muted-foreground/75`,icon:cr,spin:!1},error:{text:`text-destructive`,icon:ga,spin:!1},cancelled:{text:`text-muted-foreground/70`,icon:qi,spin:!1}};function UP({card:e,iconOnly:t=!1}){let n=HP[e.statusTone]||HP.cancelled,r=n.icon,i=!t&&(e.statusTone===`running`||e.statusTone===`error`);return(0,R.jsxs)(`span`,{className:B(`inline-flex shrink-0 items-center gap-1 text-[0.925rem] font-normal leading-[1.72]`,n.text),"aria-label":t?e.statusLabel:void 0,children:[(0,R.jsx)(r,{"aria-hidden":`true`,className:B(`h-[1.05em] w-[1.05em]`,n.spin&&`animate-spin`),strokeWidth:2.25}),i?e.statusLabel:null]})}function WP(e){return e.kind===`show-content`?{icon:_i,label:e.label,toneClassName:`border-border/70 bg-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-primary/35`}:{icon:Jr,label:e.label??(e.sessionKind===`child`?`Open child session`:`Open session`),toneClassName:`border-border/70 bg-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-primary/35`}}function GP({action:e,onAction:t}){let{Tooltip:n,TooltipContent:r,TooltipProvider:i,TooltipTrigger:a}=sd,o=WP(e),s=o.icon;return(0,R.jsx)(i,{delayDuration:250,children:(0,R.jsxs)(n,{children:[(0,R.jsx)(a,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:B(`inline-flex h-6 w-6 items-center justify-center rounded-md border transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1`,o.toneClassName),"aria-label":o.label,title:o.label,children:(0,R.jsx)(s,{className:`h-3.5 w-3.5`,strokeWidth:2.25})})}),(0,R.jsx)(r,{side:`top`,className:`text-xs`,children:o.label})]})})}function KP(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim()}function qP(e,t){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),t())}function JP({label:e,summary:t}){return(0,R.jsxs)(`span`,{className:`min-w-0 shrink truncate`,children:[e,t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`mx-1.5 select-none text-muted-foreground/45`,children:`·`}),(0,R.jsx)(`span`,{title:t,children:t})]}):null]})}function YP({expanded:e}){return(0,R.jsx)(`span`,{className:B(`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-muted-foreground/80 transition-opacity`,e?`opacity-100`:`opacity-0 group-hover/process-row:opacity-100 group-focus-within/process-row:opacity-100`),children:(0,R.jsx)(ti,{className:B(`h-[1.05em] w-[1.05em] transition-transform`,e&&`rotate-90`),strokeWidth:2.25})})}function XP({additions:e,deletions:t}){if(e===0&&t===0)return null;let n=[e>0?`+${e}`:null,t>0?`-${t}`:null].filter(Boolean).join(` `);return(0,R.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground/75`,"aria-label":n,children:[e>0?(0,R.jsxs)(`span`,{className:`transition-colors group-hover/process-row:text-emerald-600`,children:[`+`,e]}):null,t>0?(0,R.jsxs)(`span`,{className:`transition-colors group-hover/process-row:text-rose-600`,children:[`-`,t]}):null]})}function ZP({card:e,toolLabel:t,changeSummary:n,icon:r,expanded:i,canExpand:a,hideSummary:o=!1,actionSlot:s,onToggle:c}){let l=o?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``,u=t??KP(e.toolName);return(0,R.jsxs)(IP,{interactive:a,onClick:a?()=>c():void 0,role:a?`button`:void 0,tabIndex:a?0:void 0,onKeyDown:a?e=>qP(e,c):void 0,children:[(0,R.jsx)(FP,{className:`relative z-[1] rounded-sm bg-card`,children:(0,R.jsx)(r,{className:`h-[1.05em] w-[1.05em]`,strokeWidth:2.25})}),(0,R.jsx)(JP,{label:u,summary:l}),n?(0,R.jsx)(XP,{...n}):null,(0,R.jsx)(UP,{card:e,iconOnly:!!t}),a?(0,R.jsx)(YP,{expanded:i}):null,s?(0,R.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/process-row:opacity-100 group-focus-within/process-row:opacity-100`,children:s}):null]})}function QP({action:e,onAction:t}){return(0,R.jsx)(GP,{action:e,onAction:t})}var $P=`font-mono text-[11px] leading-5`,eF=`flex h-5 w-full ${$P}`,tF=`flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function nF(e){let t=e.newLineNumber??e.oldLineNumber;return typeof t==`number`?String(t):``}function rF(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function iF(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function aF(e){return e.lines.some(iF)}function oF(e){let t=e.lines.reduce((e,t)=>iF(t)?Math.max(e,nF(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function sF(e){return`calc(${e.lines.reduce((e,t)=>Math.max(e,Math.max(1,t.text.length)),1)}ch + 1.25rem)`}function cF(e){let t=e.split(/[\\/]/).filter(Boolean).pop()??e,n=t.split(/[?#]/)[0]??t,r=n.lastIndexOf(`.`);return r<=0||r===n.length-1?null:n.slice(r+1).toLowerCase()}function lF(e){return e.languageHint?.trim()||cF(e.path)||`text`}function uF(e){let t=e.toLowerCase().replace(/[^a-z0-9-]/g,`-`);return t?`language-${t}`:`language-text`}function dF(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-border bg-muted text-muted-foreground`}function fF(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-card text-foreground`}function pF({layout:e,line:t,lineNumberColumnWidth:n}){return(0,R.jsx)(`span`,{"data-file-line-number-cell":`true`,style:e===`compact`?{width:n,minWidth:n}:void 0,className:B(tF,e===`compact`?`sticky left-0 z-[1]`:`w-full shrink-0`,dF(t)),children:nF(t)})}function mF({language:e,line:t}){let n=(0,L.useMemo)(()=>oN.highlight(t.text||` `,e),[e,t.text]);return(0,R.jsx)(`span`,{"data-file-code-row":`true`,"data-file-code-language":n.language,"data-highlighted":n.highlighted?`true`:`false`,className:B(`chat-file-code-syntax hljs block min-w-0 flex-1 whitespace-pre px-2.5`,uF(n.language),fF(t)),dangerouslySetInnerHTML:{__html:n.html}})}function hF({language:e,line:t,showLineNumbers:n,lineNumberColumnWidth:r}){return(0,R.jsxs)(`div`,{"data-file-line-row":`true`,className:eF,children:[n?(0,R.jsx)(pF,{layout:`compact`,line:t,lineNumberColumnWidth:r}):null,(0,R.jsx)(mF,{language:e,line:t})]})}function gF({block:e}){let t=aF(e),n=oF(e),r=sF(e),i=lF(e);return(0,R.jsxs)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`workspace`,className:`flex h-full min-h-full min-w-full bg-card`,children:[t?(0,R.jsxs)(`div`,{"data-file-code-gutter":`true`,style:{width:n,minWidth:n},className:B(`flex h-full min-h-full shrink-0 flex-col`,$P),children:[e.lines.map((e,t)=>(0,R.jsx)(pF,{layout:`workspace`,line:e,lineNumberColumnWidth:n},rF(`gutter`,e,t))),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 border-r border-border bg-muted`})]}):null,(0,R.jsxs)(`div`,{"data-file-code-canvas":`true`,className:`flex h-full min-h-full min-w-0 flex-1 flex-col bg-card`,children:[(0,R.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:r},children:e.lines.map((e,t)=>(0,R.jsx)(`div`,{"data-file-code-canvas-row":`true`,className:eF,children:(0,R.jsx)(mF,{language:i,line:e})},rF(`code`,e,t)))}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 bg-card`})]})]})}function _F({block:e,layout:t=`compact`}){if(t===`workspace`)return(0,R.jsx)(gF,{block:e});let n=aF(e),r=oF(e),i=sF(e),a=n?`calc(${r} + ${i})`:i,o=lF(e);return(0,R.jsx)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`compact`,className:`overflow-x-auto custom-scrollbar bg-card`,children:(0,R.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:a},children:e.lines.map((e,t)=>(0,R.jsx)(hF,{language:o,line:e,showLineNumbers:n,lineNumberColumnWidth:r},rF(`row`,e,t)))})})}function vF({block:e}){return(0,R.jsx)(_F,{block:e,layout:`compact`})}function yF(e){return e.display===`preview`}function bF(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
51
+ `)}function xF(e){return/^\+\d+$/.test(e)?`text-emerald-700`:/^-\d+$/.test(e)?`text-rose-700`:`text-muted-foreground`}function SF(e){let t=e.split(`·`).map(e=>e.trim()).filter(e=>/^\+\d+$/.test(e)||/^-\d+$/.test(e));return t.length===0?null:(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-x-1 whitespace-nowrap text-[10px] font-medium uppercase tracking-[0.08em]`,children:t.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[t>0?(0,R.jsx)(`span`,{className:`text-muted-foreground/45`,children:`·`}):null,(0,R.jsx)(`span`,{className:B(xF(e)),children:e})]},`${e}-${t}`))})}function CF(e){return{path:e.path,label:e.path.split(`/`).filter(Boolean).pop()??e.path,viewMode:e.display===`diff`?`diff`:`preview`,...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},fullLines:e.fullLines??e.lines}}function wF({children:e,contentVersion:t,resetKey:n,className:r,scrollKind:i}){let a=(0,L.useRef)(null),{onScroll:o}=MP({scrollRef:a,resetKey:n,isLoading:!1,hasContent:!0,contentVersion:t,stickyThresholdPx:20});return(0,R.jsx)(`div`,{ref:a,onScroll:o,"data-file-scroll-kind":i,className:B(`overflow-y-auto bg-card custom-scrollbar`,r),children:e})}function TF({block:e,showPathRow:t,isFirst:n,onFileOpen:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=sd,c=yF(e),l=t||!!e.caption;return(0,R.jsxs)(`section`,{className:B(`overflow-hidden bg-card`,!n&&`border-t border-border`),children:[l?(0,R.jsxs)(`div`,{className:B(`flex min-h-9 items-center justify-between gap-4 border-b border-border px-3 text-muted-foreground`,t?`py-2`:`py-1.5`),children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,R.jsx)(o,{delayDuration:250,children:(0,R.jsxs)(i,{children:[(0,R.jsx)(s,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>{r&&r(CF(e))},className:B(`w-full truncate whitespace-nowrap text-left font-mono text-[12px] font-medium leading-5 text-foreground`,r&&`transition-colors hover:text-primary hover:underline`),title:e.path,children:e.path})}),(0,R.jsx)(a,{side:`top`,className:`max-w-[420px] text-xs font-mono break-all`,children:e.path})]})}):null}),e.caption?SF(e.caption):null]}):null,e.lines.length>0?(0,R.jsx)(wF,{resetKey:`block:${e.key}`,contentVersion:bF(e),className:`max-h-72`,scrollKind:`block`,children:(0,R.jsx)(vF,{block:e})}):e.rawText?(0,R.jsx)(wF,{resetKey:`raw:${e.key}`,contentVersion:e.rawText,className:`max-h-72`,scrollKind:`raw`,children:(0,R.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar`,children:(0,R.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-card px-3 py-2 font-mono text-[11px] leading-5 text-foreground`,children:e.rawText})})}):null,e.truncated&&!c?(0,R.jsx)(`div`,{className:`border-t border-border bg-muted px-3 py-2 text-[10px] text-muted-foreground`,children:`Showing a shortened diff preview.`}):null]})}function EF({card:e,className:t,onFileOpen:n,showPathRow:r=!0}){let i=e.fileOperation?.blocks??[],a=e.output?.trim()??``;return i.length===0&&!a?null:(0,R.jsxs)(`div`,{className:B(`overflow-hidden rounded-md border border-border/70 bg-card`,t),children:[i.map((e,t)=>(0,R.jsx)(TF,{block:e,showPathRow:r,isFirst:t===0,onFileOpen:n},e.key)),a?(0,R.jsx)(wF,{resetKey:`output:${e.toolName}:${e.summary??`none`}`,contentVersion:a,className:B(`max-h-56`,i.length>0&&`border-t border-border`),scrollKind:`output`,children:(0,R.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar`,children:(0,R.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-card px-3 py-2 font-mono text-[11px] leading-5 text-foreground`,children:a})})}):null]})}var DF=`\x1B`,OF=RegExp(`${DF}\\[(.*?)([ -/]*[@-~])`,`g`);function kF(e){return e.includes(`${DF}[`)}function AF(e){return e.replace(RegExp(`${DF}\\[[0-?]*[ -/]*[@-~]`,`g`),``)}function jF(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}var MF={bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1},NF={1:{bold:!0},2:{dim:!0},3:{italic:!0},4:{underline:!0},7:{inverse:!0},22:{bold:!1,dim:!1},23:{italic:!1},24:{underline:!1},27:{inverse:!1},39:{fg:void 0},49:{bg:void 0}},PF={30:`black`,31:`red`,32:`green`,33:`yellow`,34:`blue`,35:`magenta`,36:`cyan`,37:`white`,90:`bright-black`,91:`bright-red`,92:`bright-green`,93:`bright-yellow`,94:`bright-blue`,95:`bright-magenta`,96:`bright-cyan`,97:`bright-white`},FF={40:`black`,41:`red`,42:`green`,43:`yellow`,44:`blue`,45:`magenta`,46:`cyan`,47:`white`,100:`bright-black`,101:`bright-red`,102:`bright-green`,103:`bright-yellow`,104:`bright-blue`,105:`bright-magenta`,106:`bright-cyan`,107:`bright-white`};function IF(e,t){let n=e[t+1];return n===5&&typeof e[t+2]==`number`?{color:`ansi-256-${e[t+2]}`,consumed:2}:n===2&&typeof e[t+2]==`number`&&typeof e[t+3]==`number`&&typeof e[t+4]==`number`?{color:`rgb(${e[t+2]},${e[t+3]},${e[t+4]})`,consumed:4}:null}function LF(e,t){let n={...e};for(let e=0;e<t.length;e+=1){let r=t[e];if(r===0)return{...MF};let i=NF[r];if(i){n={...n,...i};continue}if(r===38||r===48){let i=IF(t,e);i&&(n=r===38?{...n,fg:i.color}:{...n,bg:i.color},e+=i.consumed);continue}if(PF[r]){n={...n,fg:PF[r]};continue}FF[r]&&(n={...n,bg:FF[r]})}return n}function RF(e){let t=[`ansi`];return e.bold&&t.push(`ansi-bold`),e.dim&&t.push(`ansi-dim`),e.italic&&t.push(`ansi-italic`),e.underline&&t.push(`ansi-underline`),e.inverse&&t.push(`ansi-inverse`),e.fg&&(e.fg.startsWith(`rgb(`)?t.push(`ansi-fg-custom`):e.fg.startsWith(`ansi-256-`)?(t.push(`ansi-fg-256`),t.push(e.fg)):t.push(`ansi-fg-${e.fg}`)),e.bg&&(e.bg.startsWith(`rgb(`)?t.push(`ansi-bg-custom`):e.bg.startsWith(`ansi-256-`)?(t.push(`ansi-bg-256`),t.push(e.bg)):t.push(`ansi-bg-${e.bg}`)),t.join(` `)}function zF(e){let t=[];return e.fg?.startsWith(`rgb(`)&&t.push(`color:${e.fg}`),e.bg?.startsWith(`rgb(`)&&t.push(`background-color:${e.bg}`),t.length>0?t.join(`;`):void 0}function BF(e){let t=RF(e),n=zF(e);return n?`<span class="${t}" style="${n}">`:`<span class="${t}">`}function VF(e){if(!e)return``;if(!kF(e))return jF(e);let t=``,n=0,r={...MF},i=!1,a=e=>{e&&(i||=(t+=BF(r),!0),t+=jF(e))},o=()=>{i&&=(t+=`</span>`,!1)};return e.replace(OF,(t,i,s,c)=>{if(a(e.slice(n,c)),n=c+t.length,s!==`m`)return t;let l=i.trim().length===0?[0]:i.split(`;`).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e));return o(),r=LF(r,l.length>0?l:[0]),t}),a(e.slice(n)),o(),t}var HF=12e4;function UF(e){return e.length<=HF?e:`${e.slice(0,HF)}\n…`}function WF({code:e,language:t,preferAnsi:n=!1,className:r}){let i=UF(e),a=(0,L.useMemo)(()=>{if(n&&kF(i))return{html:VF(i),language:`ansi`,highlighted:!0};let e=AF(i);return oN.highlight(e,t)},[t,n,i]);return(0,R.jsx)(`code`,{className:B(`hljs chat-terminal-code`,`language-${a.language}`,r),"data-highlighted":a.highlighted?`true`:`false`,dangerouslySetInnerHTML:{__html:a.html}})}function GF({command:e,output:t,emptyLabel:n,isRunning:r,hasOutput:i,isError:a=!1}){return(0,R.jsx)(`div`,{className:B(`chat-terminal-surface`,a?`chat-terminal-surface-error`:void 0),"data-testid":`chat-terminal-surface`,children:(0,R.jsxs)(`div`,{className:`chat-terminal-body custom-scrollbar`,children:[(0,R.jsxs)(`div`,{className:`chat-terminal-line chat-terminal-line-command`,children:[(0,R.jsx)(`span`,{className:`chat-terminal-gutter`,"aria-hidden":`true`,children:`$`}),(0,R.jsx)(`div`,{className:`chat-terminal-line-content`,children:e?(0,R.jsxs)(`pre`,{className:`chat-terminal-pre`,children:[(0,R.jsx)(WF,{code:e,language:`bash`}),r&&!i?(0,R.jsx)(`span`,{className:`chat-terminal-caret`,"aria-hidden":`true`}):null]}):(0,R.jsx)(`div`,{className:`chat-terminal-skeleton`})})]}),(i||!r)&&(0,R.jsx)(`div`,{className:`chat-terminal-output-block`,children:i?(0,R.jsxs)(`pre`,{className:B(`chat-terminal-pre chat-terminal-output`,a?`chat-terminal-pre-error`:void 0),children:[(0,R.jsx)(WF,{code:t,language:a?`text`:`shell`,preferAnsi:!0,className:a?`chat-terminal-code-error`:void 0}),r?(0,R.jsx)(`span`,{className:`chat-terminal-caret`,"aria-hidden":`true`}):null]}):(0,R.jsx)(`div`,{className:`chat-terminal-empty`,children:n})})]})})}var KF=200;function qF(e){return typeof e==`string`&&e.length>0?e:null}function JF(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function YF(e){return`command`in e||`workingDir`in e||`exitCode`in e||`durationMs`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e}function XF(e){let t=qF(e.aggregated_output)??qF(e.combinedOutput)??qF(e.output);if(t)return t;let n=qF(e.stdout),r=qF(e.stderr);return!n&&!r?null:[n,r].filter(e=>!!e).join(`
52
+ `)}function ZF(e,t){if(JF(t)){let e=XF(t);if(e)return e;if(YF(t))return``}if(!e)return``;let n=e.trim();if(!n.startsWith(`{`))return e;try{let t=JSON.parse(n);return JF(t)?XF(t)||(YF(t)?``:e):e}catch{return e}}function QF(e){return e===`write_file`||e===`edit_file`}function $F(e){return e.reduce((e,t)=>({additions:e.additions+t.lines.filter(e=>e.kind===`add`).length,deletions:e.deletions+t.lines.filter(e=>e.kind===`remove`).length}),{additions:0,deletions:0})}function eI({canExpand:e,isRunning:t,autoExpandWhileRunning:n=!0,expandOnError:r=!1,statusTone:i}){let[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(!1),l=(0,L.useRef)(null),u=(0,L.useRef)(t),d=(0,L.useRef)(!0);return(0,L.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,L.useEffect)(()=>{if(r&&i===`error`&&e&&!s){l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(!0),u.current=t,d.current=!1;return}n&&t&&e&&!s&&!a&&(d.current||!u.current)&&(l.current=window.setTimeout(()=>{o(!0),l.current=null},KF)),t||(l.current!==null&&(window.clearTimeout(l.current),l.current=null),u.current&&!s&&o(!1)),u.current=t,d.current=!1},[n,e,r,a,s,t,i]),{expanded:a,onToggle:()=>{e&&(l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(e=>!e),c(!0))}}}function tI(e){return JF(e)?{exitCode:typeof e.exitCode==`number`?e.exitCode:typeof e.exit_code==`number`?e.exit_code:null,workingDir:qF(e.workingDir)??qF(e.cwd)??qF(e.working_directory)}:{}}function nI({card:e,toolLabel:t}){let n=ZF(e.output,e.outputData),r=e.statusTone===`running`,i=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``),a=n.trim().length>0,o=r||a||!!i?.trim(),s=tI(e.outputData),{expanded:c,onToggle:l}=eI({canExpand:o,isRunning:r,autoExpandWhileRunning:!1,expandOnError:o,statusTone:e.statusTone});return(0,R.jsxs)(BP,{children:[(0,R.jsx)(ZP,{card:e,toolLabel:t,icon:ma,expanded:c,canExpand:o,onToggle:l}),c&&(0,R.jsx)(VP,{className:`bg-transparent py-0`,children:(0,R.jsx)(GF,{command:i,output:n,emptyLabel:e.emptyLabel,isRunning:r,hasOutput:a,isError:e.statusTone===`error`,exitCode:s.exitCode,workingDir:s.workingDir})})]})}function rI({card:e,toolLabel:t,onFileOpen:n}){let r=e.output?.trim()??``,i=e.statusTone===`running`,a=!!e.fileOperation?.blocks.length||!!r,o=e.fileOperation?.blocks??[],s=o.reduce((e,t)=>e+t.lines.length,0),c=o.reduce((e,t)=>t.rawText?e+t.rawText.length:e+t.lines.reduce((e,t)=>e+t.text.length+1,0),0),l=QF(e.toolName)&&!(i&&e.toolName===`write_file`&&(s>24||c>1200)),{expanded:u,onToggle:d}=eI({canExpand:a||i,isRunning:i,autoExpandWhileRunning:l,expandOnError:a,statusTone:e.statusTone}),f=e.toolName===`edit_file`||e.toolName===`write_file`||e.toolName===`apply_patch`||e.toolName===`file_change`;return(0,R.jsxs)(BP,{children:[(0,R.jsx)(ZP,{card:e,toolLabel:t,changeSummary:f?$F(o):void 0,icon:f?ci:dr,expanded:u,canExpand:a||i,hideSummary:!1,onToggle:d}),u&&a?(0,R.jsx)(VP,{className:`bg-transparent py-0`,children:(0,R.jsx)(EF,{card:e,onFileOpen:n,showPathRow:!0})}):null]})}function iI({card:e,toolLabel:t,icon:n=wn}){let r=e.statusTone===`running`,i=e.output?.trim()??``,{expanded:a,onToggle:o}=eI({canExpand:!!i||r,isRunning:r,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,R.jsxs)(BP,{children:[(0,R.jsx)(ZP,{card:e,toolLabel:t,icon:n,expanded:a,canExpand:!!i||r,onToggle:o}),a&&i&&(0,R.jsx)(VP,{className:`py-0`,children:(0,R.jsx)(`pre`,{className:`font-mono text-[12px] text-muted-foreground whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar leading-relaxed`,children:i})})]})}function aI({label:e,tone:t,children:n}){let r={input:{dot:`bg-muted-foreground/60`,body:`text-foreground`},output:{dot:`bg-primary/70`,body:`text-foreground`},error:{dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-md border border-border/70 bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-1.5 text-[10px] font-medium tracking-wide text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:B(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,R.jsx)(`span`,{className:`normal-case tracking-normal`,children:e})]}),(0,R.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,R.jsx)(`pre`,{className:B(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-2.5 py-2 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar`,r.body),children:n})})]})}function oI(e,t,n){let r=e.agentId&&n?n(e.agentId):null,i=e.action&&t?(0,R.jsx)(QP,{action:e.action,onAction:t}):null;return r||i?(0,R.jsxs)(R.Fragment,{children:[r,i]}):void 0}function sI({card:e,toolLabel:t,icon:n=ba,onToolAction:r,renderToolAgent:i}){let a=e.input?.trim()??``,o=e.output?.trim()??``,s=e.statusTone===`running`,c=a.length>0,l=o.length>0,u=c||l,d=oI(e,r,i),{expanded:f,onToggle:p}=eI({canExpand:u||s,isRunning:s,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,R.jsxs)(BP,{children:[(0,R.jsx)(ZP,{card:e,toolLabel:t,icon:n,expanded:f,canExpand:u||s,actionSlot:d,onToggle:p}),f&&u?(0,R.jsxs)(VP,{className:`bg-transparent py-0`,children:[c?(0,R.jsx)(aI,{label:e.inputLabel?.trim()||`Input`,tone:`input`,children:a}):null,c&&l?(0,R.jsx)(`div`,{className:`h-2`}):null,l?(0,R.jsx)(aI,{label:e.outputLabel?.trim()||`Output`,tone:e.statusTone===`error`?`error`:`output`,children:o}):null]}):null]})}function cI({card:e,onToolAction:t,renderPanelAppCard:n}){let{panelApp:r}=e;return r&&n?n(r):(0,R.jsx)(sI,{card:e,onToolAction:t})}function lI(e){let t=e.toLowerCase();return t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t.includes(`run_`)}function uI(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function dI(e){let t=e.toLowerCase();return t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function fI(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}var pI={list_dir:{statusKind:`directory`,icon:Di},web_fetch:{statusKind:`web`,icon:mi},message:{statusKind:`message`,icon:ra},sessions_list:{statusKind:`session`,icon:Wi},sessions_history:{statusKind:`session`,icon:Wi},sessions_request:{statusKind:`session`,icon:Wi},spawn:{statusKind:`agent`,icon:Xr},sessions_spawn:{statusKind:`agent`,icon:Xr},subagents:{statusKind:`agent`,icon:Xr},memory_search:{statusKind:`memory`,icon:Qr},memory_get:{statusKind:`memory`,icon:Qr},cron:{statusKind:`schedule`,icon:ei},gateway:{statusKind:`system`,icon:aa},view_image:{statusKind:`image`,icon:Pi},show_file:{statusKind:`display`,icon:_i},show_url:{statusKind:`display`,icon:_i},show_panel_app:{statusKind:`display`,icon:_i},show_content:{statusKind:`display`,icon:_i}};function mI(e){return pI[e.toLowerCase()]??null}function hI({card:e,toolStatusLabels:t,onToolAction:n,onFileOpen:r,renderToolAgent:i,renderPanelAppCard:a}){if(e.panelApp)return(0,R.jsx)(cI,{card:e,onToolAction:n,renderPanelAppCard:a});let o=mI(e.toolName),s=o?t?.builtIn?.[o.statusKind]?.[e.statusTone]:void 0;return lI(e.toolName)?(0,R.jsx)(nI,{card:e,toolLabel:t?.terminal[e.statusTone]}):uI(e.toolName)?(0,R.jsx)(rI,{card:e,toolLabel:dI(e.toolName)?t?.fileEdit[e.statusTone]:t?.fileRead[e.statusTone],onFileOpen:r}):fI(e.toolName)?(0,R.jsx)(iI,{card:e,toolLabel:s??t?.search[e.statusTone],icon:o?.icon}):(0,R.jsx)(sI,{card:e,toolLabel:s,icon:o?.icon,onToolAction:n,renderToolAgent:i})}function gI({group:e,isUser:t,reasoningCharacterCountTemplates:n,toolStatusLabels:r,onToolAction:i,onFileOpen:a,renderToolAgent:o,renderPanelAppCard:s}){let[c,l]=(0,L.useState)(!1),u=e.parts.filter(e=>e.type===`tool-card`).length,d=c&&u>1;return(0,R.jsxs)(`div`,{className:`group/tool-activity`,children:[(0,R.jsx)(LP,{openGroup:`tool-activity`,open:c,label:e.label,onClick:()=>l(e=>!e)}),c?(0,R.jsx)(`div`,{className:`text-[0.925rem] leading-[1.72]`,children:e.parts.map((c,l)=>{let u=l===e.parts.length-1;return(0,R.jsxs)(`div`,{className:`relative min-w-0`,children:[d?(0,R.jsx)(`div`,{"aria-hidden":`true`,"data-tool-workflow-rail":`true`,className:B(`pointer-events-none absolute left-[0.575em] w-px -translate-x-1/2 bg-border/70`,l===0?`bottom-0 top-[0.86em]`:u?`top-0 h-[0.86em]`:`inset-y-0`)}):null,c.type===`tool-card`?(0,R.jsx)(hI,{card:c.card,toolStatusLabels:r,onToolAction:i,onFileOpen:a,renderToolAgent:o,renderPanelAppCard:s}):(0,R.jsx)(`div`,{className:`pl-[calc(1.15em+0.375rem)]`,children:(0,R.jsx)(zP,{label:c.label,text:c.text,characterCountTemplates:n,isUser:t,isInProgress:!1})})]},`tool-group-item-${e.startIndex+l}`)})}):null]})}var _I=3;function vI(e){return e.type===`tool-card`}function yI(e){let t=e.toLowerCase();return t===`list_dir`?`directory`:t.includes(`show_content`)||t.includes(`panel_app`)||t.includes(`panel`)?`panel`:t===`spawn`||t.includes(`subagent`)||t.includes(`session_request`)||t.includes(`agent`)&&!t.includes(`read`)?`agent`:t.includes(`web_`)||t.includes(`_web`)||t.includes(`url`)||t.includes(`fetch`)||t.includes(`http`)?`web`:t===`grep_search`||t===`find_files`||t===`search_files`||t.includes(`search`)||t.includes(`grep`)?`search`:t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t===`terminal`||t.includes(`run_`)?`bash`:t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`||t===`multi_replace`||t.includes(`write_file`)||t.includes(`edit_file`)||t.includes(`apply_patch`)?`edit`:t===`read_file`||t===`read`||t===`view_file`||t.includes(`read_file`)||t.startsWith(`read_`)?`read`:`other`}function bI(e){return e===`error`?0:e===`cancelled`?1:e===`running`?2:3}function xI(e,t,n){if(t!==`read`&&t!==`edit`&&t!==`directory`)return[`call:${n}`];let r=e.fileOperation?.blocks.map(({path:e})=>e.trim()).filter(Boolean),i=e.summary?.replace(/^(path|file):\s*/i,``).trim();return r?.length?r:[i||`call:${n}`]}function SI(e,t){let n=t.segmentTemplates[e.family],r=e.count===1?n.one:n.other.split(`{count}`).join(String(e.count));return e.tone===`error`?`${r} ${t.failedLabel}`:e.tone===`cancelled`?`${r} ${t.cancelledLabel}`:r}function CI(e){let t=[],n=new Map;for(let[r,i]of e.entries()){let e=yI(i.toolName),a=xI(i,e,r),o=n.get(e);if(!o){t.push(e),n.set(e,{units:new Set(a),tone:i.statusTone});continue}a.forEach(e=>o.units.add(e)),bI(i.statusTone)<bI(o.tone)&&(o.tone=i.statusTone)}let r=t.map(e=>{let t=n.get(e);return{family:e,count:t.units.size,tone:t.tone}});return r.sort((e,n)=>{let r=bI(e.tone)-bI(n.tone);return r===0?t.indexOf(e.family)-t.indexOf(n.family):r}),r}function wI(e){let{labels:t,segments:n}=e;if(n.length===0)return``;let r=n.slice(0,_I),i=n.length-r.length,a=r.map(e=>SI(e,t));return i>0&&a.push(`+${i}`),a.join(` · `)}function TI(e,t){let n=[],r=0;for(;r<e.length;){let i=e[r];if(i.type!==`tool-card`){n.push({kind:`part`,key:`part-${r}`,index:r,part:i}),r+=1;continue}let a=r,o=[],s=-1;for(;r<e.length&&(e[r]?.type===`tool-card`||e[r]?.type===`reasoning`);){let t=e[r];o.push(t),t.type===`tool-card`&&(s=o.length-1),r+=1}let c=o.filter(vI);if(c.length===1){n.push({kind:`part`,key:`part-${a}`,index:a,part:i}),r=a+1;continue}let l=o.slice(0,s+1);r=a+l.length;let u=CI(c.map(e=>e.card)),d=wI({segments:u,labels:t});n.push({kind:`tool-group`,key:`tool-group-${a}-${r-1}`,group:{key:`tool-group-${a}-${r-1}`,startIndex:a,endIndex:r-1,parts:l,segments:u,label:d}})}return n}var EI={segmentTemplates:{read:{one:`Read 1 file`,other:`Read {count} files`},edit:{one:`Edit 1 file`,other:`Edit {count} files`},directory:{one:`View 1 directory`,other:`View {count} directories`},search:{one:`Search 1 time`,other:`Search {count} times`},bash:{one:`Run 1 command`,other:`Run {count} commands`},web:{one:`Open 1 page`,other:`Open {count} pages`},agent:{one:`Start 1 subtask`,other:`Start {count} subtasks`},panel:{one:`Show 1 result`,other:`Show {count} results`},other:{one:`Use 1 tool`,other:`Use {count} tools`}},failedLabel:`failed`,cancelledLabel:`cancelled`};function DI(e){return{segmentTemplates:{...EI.segmentTemplates,...e.toolActivitySegmentTemplates??{}},failedLabel:e.toolActivityFailedLabel??EI.failedLabel,cancelledLabel:e.toolActivityCancelledLabel??EI.cancelledLabel}}function OI(e){return e===`pending`||e===`streaming`}function kI(e){return e.type===`reasoning`||e.type===`tool-card`}function AI(e){if(e.role!==`assistant`||!e.processSummary||OI(e.status))return null;let t=-1;for(let n=e.parts.length-1;n>=0;--n)if(kI(e.parts[n])){t=n;break}return t<0||t>=e.parts.length-1?null:{processParts:e.parts.slice(0,t+1),finalParts:e.parts.slice(t+1)}}function jI({index:e,isInProgress:t,isLastPart:n,isUser:r,onAttachmentOpen:i,onFileOpen:a,onInlineTokenClick:o,onToolAction:s,part:c,renderInlineDisplay:l,renderPanelAppCard:u,renderToolAgent:d,role:f,texts:p}){let{type:m}=c;if(m===`markdown`){let{inlineTokens:t,text:n}=c;return(0,R.jsx)(QN,{text:n,role:f,texts:p,inlineTokens:t,onFileOpen:a,onInlineTokenClick:o,renderInlineDisplay:l},`markdown-${e}`)}if(m===`reasoning`){let{label:i,text:a}=c;return(0,R.jsx)(zP,{label:i,text:a,characterCountTemplates:p.reasoningCharacterCountTemplates,isUser:r,isInProgress:t&&n},`reasoning-${e}`)}if(m===`tool-card`){let{card:t}=c;return(0,R.jsx)(`div`,{children:(0,R.jsx)(hI,{card:t,toolStatusLabels:p.toolStatusLabels,onToolAction:s,onFileOpen:a,renderToolAgent:d,renderPanelAppCard:u})},`tool-${e}`)}if(m===`file`){let{file:t}=c;return(0,R.jsx)(kP,{file:t,isUser:r,texts:p,onOpen:i},`file-${e}`)}if(m===`unknown`){let{label:t,rawType:n,text:r}=c;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/60 px-2.5 py-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`div`,{className:`font-semibold text-foreground`,children:[t,`: `,n]}),r?(0,R.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground`,children:r}):null]},`unknown-${e}`)}return null}function MI(e){let{isInProgress:t,isUser:n,onAttachmentOpen:r,onFileOpen:i,onInlineTokenClick:a,onToolAction:o,parts:s,renderInlineDisplay:c,renderPanelAppCard:l,renderToolAgent:u,role:d,texts:f,indexOffset:p=0}=e;return TI(s,DI(f)).map(e=>e.kind===`tool-group`?(0,R.jsx)(gI,{group:e.group,isUser:n,reasoningCharacterCountTemplates:f.reasoningCharacterCountTemplates,toolStatusLabels:f.toolStatusLabels,onToolAction:o,onFileOpen:i,renderToolAgent:u,renderPanelAppCard:l},e.key):jI({part:e.part,index:p+e.index,role:d,isUser:n,isInProgress:t,isLastPart:p+e.index===p+s.length-1,texts:f,onToolAction:o,onFileOpen:i,onAttachmentOpen:r,onInlineTokenClick:a,renderInlineDisplay:c,renderToolAgent:u,renderPanelAppCard:l}))}var NI=(0,L.memo)(function({message:e,texts:t,onToolAction:n,onFileOpen:r,onAttachmentOpen:i,onInlineTokenClick:a,renderInlineDisplay:o,renderToolAgent:s,renderPanelAppCard:c}){let{role:l}=e,u=l===`user`,d=OI(e.status),f=AI(e),[p,m]=(0,L.useState)(!1);return(0,R.jsx)(`div`,{className:B(`inline-block w-fit max-w-full rounded-2xl border px-4 shadow-sm has-[[data-chat-message-wide-content=true]]:w-full`,u?`nextclaw-chat-message-user rounded-[1.45rem] border-primary bg-primary py-2.5 text-primary-foreground shadow-none`:l===`assistant`?`border-border bg-card pb-3 pt-4 text-card-foreground`:`border-border bg-muted/45 py-3 text-foreground`),children:(0,R.jsx)(`div`,{className:`space-y-0`,children:f?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`group/process`,children:[(0,R.jsx)(`div`,{className:`mb-2 border-b border-border/60 pb-2`,children:(0,R.jsx)(LP,{openGroup:`process`,open:p,label:e.processSummary?.label,onClick:()=>m(e=>!e)})}),p?(0,R.jsx)(`div`,{className:`space-y-0`,children:MI({parts:f.processParts,role:l,isUser:u,isInProgress:d,texts:t,onToolAction:n,onFileOpen:r,onAttachmentOpen:i,onInlineTokenClick:a,renderInlineDisplay:o,renderToolAgent:s,renderPanelAppCard:c})}):null]}),MI({parts:f.finalParts,role:l,isUser:u,isInProgress:d,texts:t,onToolAction:n,onFileOpen:r,onAttachmentOpen:i,onInlineTokenClick:a,renderInlineDisplay:o,renderToolAgent:s,renderPanelAppCard:c,indexOffset:f.processParts.length})]}):MI({parts:e.parts,role:l,isUser:u,isInProgress:d,texts:t,onToolAction:n,onFileOpen:r,onAttachmentOpen:i,onInlineTokenClick:a,renderInlineDisplay:o,renderToolAgent:s,renderPanelAppCard:c})})})});function PI({message:e,texts:t}){let n=(0,L.useMemo)(()=>e.parts.map(e=>e.type===`markdown`||e.type===`unknown`?e.text:``).filter(e=>!!e&&e.trim().length>0).join(`
53
+
54
+ `),[e.parts]),{copied:r,copy:i}=hM({text:n});return n?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void i(),className:`text-muted-foreground hover:text-foreground transition-colors p-1 rounded-md hover:bg-accent flex items-center justify-center`,"aria-label":r?t.copiedMessageLabel:t.copyMessageLabel,title:r?t.copiedMessageLabel:t.copyMessageLabel,children:r?(0,R.jsx)(cr,{className:`h-3.5 w-3.5`}):(0,R.jsx)(ui,{className:`h-3.5 w-3.5`})}):null}var FI=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g,II=`
55
+ @keyframes nextclaw-chat-typing-text-sheen {
56
+ 0% {
57
+ background-position: 160% 0;
58
+ }
59
+ 100% {
60
+ background-position: -60% 0;
61
+ }
62
+ }
63
+
64
+ .nextclaw-chat-typing-indicator__text {
65
+ background-image: linear-gradient(
66
+ 100deg,
67
+ hsl(var(--muted-foreground)) 0%,
68
+ hsl(var(--muted-foreground)) 34%,
69
+ hsl(var(--foreground-tertiary)) 43%,
70
+ hsl(var(--foreground-muted)) 50%,
71
+ hsl(var(--foreground-tertiary)) 57%,
72
+ hsl(var(--muted-foreground)) 66%,
73
+ hsl(var(--muted-foreground)) 100%
74
+ );
75
+ background-size: 240% 100%;
76
+ background-position: 160% 0;
77
+ -webkit-background-clip: text;
78
+ background-clip: text;
79
+ color: transparent;
80
+ -webkit-text-fill-color: transparent;
81
+ animation: nextclaw-chat-typing-text-sheen 2.5s linear infinite;
82
+ }
83
+
84
+ @media (prefers-reduced-motion: reduce) {
85
+ .nextclaw-chat-typing-indicator__text {
86
+ animation: none;
87
+ background-image: none;
88
+ color: hsl(var(--muted-foreground));
89
+ -webkit-text-fill-color: currentColor;
90
+ }
91
+ }
92
+ `;function LI(e){let t=e.trim();return t?t.replace(FI,``).trim().length>0:!1}function RI(e){return e.parts.some(e=>e.type===`markdown`||e.type===`reasoning`?LI(e.text):!0)}function zI(){return(0,R.jsx)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-[11px] text-muted-foreground`,children:(0,R.jsxs)(`div`,{className:`flex space-x-1 items-center h-full`,children:[(0,R.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground animate-pulse`}),(0,R.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground animate-pulse [animation-delay:200ms]`}),(0,R.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground animate-pulse [animation-delay:400ms]`})]})})}function BI({label:e}){return(0,R.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card px-4 py-3 text-sm text-muted-foreground shadow-sm`,children:[(0,R.jsx)(`style`,{children:II}),(0,R.jsx)(`span`,{className:`nextclaw-chat-typing-indicator__text`,children:e})]})}function VI({className:e,isSending:t,messages:n,onAttachmentOpen:r,onFileOpen:i,onInlineTokenClick:a,onToolAction:o,renderInlineDisplay:s,renderPanelAppCard:c,renderToolAgent:l,texts:u}){let d=n.filter(RI),f=d.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`));return(0,R.jsxs)(`div`,{className:B(`space-y-5`,e),children:[d.map(e=>{let t=e.role===`user`,n=!t&&(e.status===`streaming`||e.status===`pending`);return(0,R.jsxs)(`div`,{className:B(`flex gap-3`,t?`justify-end`:`justify-start`),children:[t?null:(0,R.jsx)(hS,{role:e.role}),(0,R.jsxs)(`div`,{className:B(`w-fit max-w-[92%] space-y-2 has-[[data-chat-message-wide-content=true]]:w-full`,t&&`flex flex-col items-end`),children:[(0,R.jsx)(NI,{message:e,texts:u,onToolAction:o,onFileOpen:i,onAttachmentOpen:r,onInlineTokenClick:a,renderInlineDisplay:s,renderToolAgent:l,renderPanelAppCard:c}),(0,R.jsx)(`div`,{className:B(`flex items-center gap-2`,t&&`justify-end`),children:n?(0,R.jsx)(zI,{}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:B(`px-1 text-[11px] leading-4 text-muted-foreground`,t?`text-right`:`text-left`),children:[e.roleLabel,` · `,e.timestampLabel]}),t?null:(0,R.jsx)(PI,{message:e,texts:u})]})})]}),t?(0,R.jsx)(hS,{role:e.role}):null]},e.id)}),t&&!f?(0,R.jsxs)(`div`,{className:`flex justify-start gap-3`,children:[(0,R.jsx)(hS,{role:`assistant`}),(0,R.jsx)(BI,{label:u.typingLabel})]}):null]})}function HI(e){return{key:e.key,triggerSpecs:[e.trigger],resolvePanel:t=>t.trigger.key===e.trigger.key?e.resolvePanel(t):null}}function UI(e){return HI({key:e.key,trigger:e.trigger,resolvePanel:t=>({isLoading:e.getIsLoading?.(t)??!1,items:e.getItems({context:t,records:e.getRecords(t),query:t.trigger.query,tokenKind:e.tokenKind}),onSelectItem:e.onSelectItem,texts:e.texts})})}function WI(e){let{data:t,plugins:n,trigger:r}=e,i=n.flatMap(e=>[...e.triggerSpecs]);if(!r)return{triggerSpecs:i,panel:null};for(let e of n){let n=e.resolvePanel({data:t,trigger:r});if(n)return{triggerSpecs:i,panel:n}}return{triggerSpecs:i,panel:null}}var GI=[`cmd`,`command`,`query`,`q`,`path`,`url`,`to`,`channel`,`agentId`,`sessionKey`];function KI(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qI(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}\n…`}function JI(e,t=120){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1)}…`}function YI(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;try{return qI(JSON.stringify(e,null,2))}catch{return String(e)}}function XI(e){if(KI(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{let e=JSON.parse(t);return KI(e)?e:null}catch{return null}}function ZI(e){let t=XI(e);if(!t){let t=YI(e).trim();return t?JI(t,120):void 0}let n=[];for(let e of GI){let r=t[e];if(typeof r==`string`&&r.trim()?n.push(`${e}: ${r.trim()}`):(typeof r==`number`||typeof r==`boolean`)&&n.push(`${e}: ${String(r)}`),n.length>=2)break}return n.length>0?JI(n.join(` · `),120):JI(YI(t),140)}var QI=`ui_inline_tokens`,$I=`$`,eL=`@panel-app:`,tL=/@panel-app:([A-Za-z0-9_-]+)/g;function nL(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rL(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function iL(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind}:${r.key}:${r.rawText}`;t.has(e)||(t.add(e),n.push(r))}return n}function aL(e){let t=[];for(let n of e)n.type!==`token`||n.tokenKind!==`skill`||t.push({kind:`skill`,key:n.tokenKey,label:n.label,rawText:`${$I}${n.tokenKey}`});return iL(t)}function oL(e){let t=[];for(let n of e.matchAll(tL)){let e=n[1];e&&t.push({kind:`panel_app`,key:e,label:e,rawText:`${eL}${e}`})}return iL(t)}function sL(e,t){return iL([...t,...oL(e)])}function cL(e){let t=e?.[QI];if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!nL(e))continue;let t=rL(e.kind),r=rL(e.key),i=rL(e.rawText);!t||!r||!i||n.push({kind:t,key:r,rawText:i,label:rL(e.label)??r})}return iL(n)}var lL=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function uL(e){let t=e.trim();return t&&t.replace(lL,``).trim()?t:null}function dL(e,t){let n=uL(e.text);if(!n)return null;let r=sL(e.text,t);return{type:`markdown`,text:n,inlineTokens:r.length>0?r:void 0}}function fL(e){return uL(e)}function pL(e){return typeof e==`object`&&!!e}function mL(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function hL(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function gL(e){return pL(e)?`command`in e||`workingDir`in e||`exitCode`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e:!1}function _L(e,t){if(!pL(e))return null;let n=pL(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&pL(e.assets[0])?e.assets[0]:null;if(!n)return null;let r=mL(n.url),i=mL(n.mimeType)??`application/octet-stream`,a=hL(n.sizeBytes);return r?{type:`file`,file:{label:mL(n.name)??(i.startsWith(`image/`)?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...a==null?{}:{sizeBytes:a},isImage:i.startsWith(`image/`)}}:null}function vL(e,t){return{kind:e.kind,toolName:e.name,...`agentId`in e&&e.agentId?{agentId:e.agentId}:{},summary:e.detail,inputLabel:t.toolInputLabel,input:`input`in e&&typeof e.input==`string`?e.input:void 0,output:e.text,outputData:e.outputData,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind===`call`?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel,...`action`in e&&e.action?{action:e.action}:{},...`fileOperation`in e&&e.fileOperation?{fileOperation:e.fileOperation}:{},...`panelApp`in e&&e.panelApp?{panelApp:e.panelApp}:{}}}function yL(e){let{cancelled:t,error:n,result:r,status:i,texts:a}=e,o=typeof i==`string`?i.trim().toLowerCase():``,s=typeof n==`string`&&n.trim().length>0;return t===!0||o===`cancelled`?{kind:`result`,hasResult:!0,statusTone:`cancelled`,statusLabel:a.toolStatusCancelledLabel}:s||o===`error`?{kind:`result`,hasResult:!0,statusTone:`error`,statusLabel:a.toolStatusFailedLabel}:o===`result`||r!=null?{kind:`result`,hasResult:!0,statusTone:`success`,statusLabel:a.toolStatusCompletedLabel}:{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:a.toolStatusRunningLabel}}function bL(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function xL(e,t){return YI(t??bL(e)).trim()||void 0}function SL(e){return typeof e==`object`&&!!e}function CL(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function wL(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function TL(e){let t=CL(e);return SL(t)?wL(t.agentId):null}function EL(e){return TL(e.parsedArgs)??TL(e.args)??TL(e.result)}var DL=12e3,OL=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function kL(e){let t=e.replace(/\r\n/g,`
93
+ `).replace(/\r/g,`
94
+ `);return t===``?[]:t.split(`
95
+ `)}function AL(e){return typeof e==`number`?e+1:void 0}function jL(e){let{kind:t,newLineNumber:n,oldLineNumber:r,text:i}=e;return{kind:t,text:i,...typeof r==`number`?{oldLineNumber:r}:{},...typeof n==`number`?{newLineNumber:n}:{}}}function ML(e){let t=OL.exec(e);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function NL(e){let{kind:t,newStartLine:n,oldStartLine:r,text:i}=e;return kL(i).map((e,i)=>jL(t===`add`?{kind:`add`,text:e,newLineNumber:n+i}:{kind:`context`,text:e,oldLineNumber:r+i,newLineNumber:n+i}))}function PL(e){let{afterLines:t,beforeLines:n,newStartLine:r,oldStartLine:i}=e,a=i,o=r;return[...n.map(e=>{let t=jL({kind:`remove`,text:e,oldLineNumber:a});return a=AL(a),t}),...t.map(e=>{let t=jL({kind:`add`,text:e,newLineNumber:o});return o=AL(o),t})]}function FL(e){let{afterLines:t,beforeLines:n}=e,r=Array.from({length:n.length+1},()=>Array.from({length:t.length+1},()=>0));for(let e=n.length-1;e>=0;--e)for(let i=t.length-1;i>=0;--i)r[e][i]=n[e]===t[i]?(r[e+1][i+1]??0)+1:Math.max(r[e+1][i]??0,r[e][i+1]??0);return r}function IL(e){let{afterIndex:t,afterLines:n,beforeIndex:r,beforeLines:i,lines:a,newLineNumber:o,oldLineNumber:s}=e,c=s,l=o;for(let e=r;e<i.length;e+=1)a.push(jL({kind:`remove`,text:i[e]??``,oldLineNumber:c})),c=AL(c);for(let e=t;e<n.length;e+=1)a.push(jL({kind:`add`,text:n[e]??``,newLineNumber:l})),l=AL(l)}function LL(e){let{afterText:t,beforeText:n,newStartLine:r,oldStartLine:i}=e,a=kL(n),o=kL(t);if(a.length*o.length>DL)return PL({beforeLines:a,afterLines:o,oldStartLine:i,newStartLine:r});let s=FL({beforeLines:a,afterLines:o}),c=[],l=0,u=0,d=i,f=r;for(;l<a.length&&u<o.length;){if(a[l]===o[u]){c.push(jL({kind:`context`,text:a[l]??``,oldLineNumber:d,newLineNumber:f})),l+=1,u+=1,d=AL(d),f=AL(f);continue}if((s[l+1][u]??0)>=(s[l][u+1]??0)){c.push(jL({kind:`remove`,text:a[l]??``,oldLineNumber:d})),l+=1,d=AL(d);continue}c.push(jL({kind:`add`,text:o[u]??``,newLineNumber:f})),u+=1,f=AL(f)}return IL({lines:c,beforeLines:a,afterLines:o,beforeIndex:l,afterIndex:u,oldLineNumber:d,newLineNumber:f}),c}var RL=120;function zL(e){let{lines:t,operation:n}=e,r=t.filter(e=>e.kind===`add`).length,i=t.filter(e=>e.kind===`remove`).length,a=[],o=n?.trim().toLowerCase()??``;return o&&o!==`update`&&a.push(o),r>0&&a.push(`+${r}`),i>0&&a.push(`-${i}`),a.length>0?a.join(` · `):void 0}function BL(e){let{afterText:t,beforeText:n,newStartLine:r,oldStartLine:i,operation:a}=e,o=a?.trim().toLowerCase()??``;return{oldStartLine:typeof i==`number`?i:(o===`delete`||o===`remove`)&&n!=null?1:void 0,newStartLine:typeof r==`number`?r:(o===`write`||o===`add`)&&t!=null?1:void 0}}function VL(e){return e.length<=RL?{lines:e,truncated:!1}:{lines:e.slice(0,RL),truncated:!0}}function HL(e){let{lines:t,operation:n,path:r}=e,i=VL(t);return{path:r,display:`diff`,caption:zL({operation:n,lines:t}),lines:i.lines,...i.truncated?{fullLines:t}:{},truncated:i.truncated}}function UL(e){let{newStartLine:t,oldStartLine:n,operation:r,path:i,text:a}=e,o=a.trim();if(!o)return null;let s=r?.trim().toLowerCase()===`write`?`add`:`context`,c=typeof n==`number`?n:1,l=typeof t==`number`?t:1,u=NL({text:o,kind:s,oldStartLine:c,newStartLine:l});return{path:i,display:`preview`,caption:zL({operation:r,lines:u}),lines:u,rawText:o,oldStartLine:c,newStartLine:l}}function WL(e){let{afterText:t,beforeText:n,operation:r,path:i}=e,{oldStartLine:a,newStartLine:o}=BL(e),s=LL({beforeText:n??``,afterText:t??``,oldStartLine:a,newStartLine:o}),c=VL(s);return c.lines.length===0?null:{path:i,display:`diff`,caption:zL({operation:r,lines:s}),lines:c.lines,...c.truncated?{fullLines:s}:{},...n==null?{}:{beforeText:n},...t==null?{}:{afterText:t},...typeof a==`number`?{oldStartLine:a}:{},...typeof o==`number`?{newStartLine:o}:{},truncated:c.truncated}}function GL(e){let{flushCurrent:t,line:n,setCurrent:r}=e;return n.startsWith(`*** Update File: `)?(t(),r(n.slice(17).trim(),`update`),!0):n.startsWith(`*** Add File: `)?(t(),r(n.slice(14).trim(),`add`),!0):n.startsWith(`*** Delete File: `)?(t(),r(n.slice(17).trim(),`delete`),!0):!1}function KL(e){let{currentLines:t,line:n,newLineNumber:r,oldLineNumber:i}=e;return n.startsWith(`+`)?(t.push(jL({kind:`add`,text:n.slice(1),newLineNumber:r})),{oldLineNumber:i,newLineNumber:AL(r)}):n.startsWith(`-`)?(t.push(jL({kind:`remove`,text:n.slice(1),oldLineNumber:i})),{oldLineNumber:AL(i),newLineNumber:r}):n.startsWith(` `)?(t.push(jL({kind:`context`,text:n.slice(1),oldLineNumber:i,newLineNumber:r})),{oldLineNumber:AL(i),newLineNumber:AL(r)}):{oldLineNumber:i,newLineNumber:r}}function qL(e){let t=[],n=null,r=null,i=[],a,o,s=()=>{if(!n){i=[],r=null,a=void 0,o=void 0;return}t.push(HL({path:n,operation:r,lines:i})),n=null,r=null,i=[],a=void 0,o=void 0};for(let t of kL(e)){if(GL({line:t,flushCurrent:s,setCurrent:(e,t)=>{n=e,r=t}})||t.startsWith(`*** Move to: `)||t.startsWith(`*** Begin Patch`)||t.startsWith(`*** End Patch`))continue;if(t.startsWith(`@@`)){let e=ML(t);a=e?.oldLineNumber,o=e?.newLineNumber;continue}if(!n)continue;let e=KL({currentLines:i,line:t,oldLineNumber:a,newLineNumber:o});a=e.oldLineNumber,o=e.newLineNumber}return s(),t}function JL(e){let t=[],n=null,r=[],i,a,o=()=>{if(!n){r=[],i=void 0,a=void 0;return}t.push(HL({path:n,operation:`update`,lines:r})),n=null,r=[],i=void 0,a=void 0};for(let t of kL(e)){if(t.startsWith(`+++ `)){o(),n=t.slice(4).trim().replace(/^b\//,``).replace(/^a\//,``);continue}if(t.startsWith(`--- `))continue;if(t.startsWith(`@@`)){let e=ML(t);i=e?.oldLineNumber,a=e?.newLineNumber;continue}if(!n)continue;let e=KL({currentLines:r,line:t,oldLineNumber:i,newLineNumber:a});i=e.oldLineNumber,a=e.newLineNumber}return o(),t}function YL(e){return e.includes(`*** Begin Patch`)?qL(e):e.includes(`--- `)&&e.includes(`+++ `)?JL(e):[]}function XL(e){switch(e){case`"`:case`\\`:case`/`:return e;case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
96
+ `;case`r`:return`\r`;case`t`:return` `;default:return e}}function ZL(e,t){let n=`"${t}"`,r=e.indexOf(n);if(r<0)return null;let i=e.indexOf(`:`,r+n.length);if(i<0)return null;let a=i+1;for(;a<e.length&&/\s/.test(e[a]??``);)a+=1;return e[a]===`"`?a+1:null}function QL(e,t,n=1/0){let r=``,i=!1;for(let a=t;a<e.length;a+=1){let t=e[a];if(t==null)break;if(i){r+=XL(t),i=!1;continue}if(t===`\\`){i=!0;continue}if(t===`"`)return{value:r,truncated:!1};if(r+=t,r.length>=n)return{value:r,truncated:!0}}return r.length>0?{value:r,truncated:!1}:null}function $L(e,t,n=1/0){for(let r of t){let t=ZL(e,r);if(t!=null)return QL(e,t,n)}return null}function eR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function tR(e){return typeof e==`string`&&e.trim()?e.trim():null}function nR(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:typeof e==`string`&&/^\d+$/.test(e.trim())?Number(e.trim()):null}function rR(e){if(eR(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);return eR(e)?e:null}catch{return null}}function iR(e){if(eR(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;let n=$L(t,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`])?.value??null,r=$L(t,[`content`,`text`,`afterText`,`after_text`])?.value??null,i=$L(t,[`oldText`,`beforeText`,`before_text`])?.value??null,a=$L(t,[`newText`,`afterText`,`after_text`])?.value??null,o=$L(t,[`patch`,`diff`,`unifiedDiff`,`unified_diff`])?.value??null,s={};return n&&(s.path=n),r&&(s.content=r),i&&(s.oldText=i),a&&(s.newText=a),o&&(s.patch=o),Object.keys(s).length>0?s:null}function aR(e){return tR(e.path)??tR(e.filePath)??tR(e.file_path)??tR(e.targetPath)??tR(e.target_path)??tR(e.filename)??tR(e.name)}function oR(e){return $(e.operation)??$(e.op)??$(e.action)??$(e.kind)??$(e.type)??$(e.status)}function sR(e,t){for(let n of t){let t=nR(e[n]);if(t!==null)return t}return null}function cR(e){return sR(e,[`oldStartLine`,`old_start_line`,`startOldLine`,`start_old_line`,`oldLineStart`,`old_line_start`,`oldLineNumber`,`old_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function lR(e){return sR(e,[`newStartLine`,`new_start_line`,`startNewLine`,`start_new_line`,`newLineStart`,`new_line_start`,`newLineNumber`,`new_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function uR(e){return $(e.patch)??$(e.diff)??$(e.unifiedDiff)??$(e.unified_diff)}function dR(e){return $(e.beforeText)??$(e.before_text)??$(e.oldText)??$(e.old_text)??$(e.oldContent)??$(e.old_content)??$(e.before)??$(e.previous)}function fR(e){return $(e.afterText)??$(e.after_text)??$(e.newText)??$(e.new_text)??$(e.newContent)??$(e.new_content)??$(e.content)??$(e.text)??$(e.after)??$(e.updated)}var pR=new Set([`file_change`,`read_file`,`write_file`,`edit_file`,`apply_patch`]);function mR(e){let t=e.map((e,t)=>({key:`${e.path}-${t+1}`,path:e.path,display:e.display,...e.caption?{caption:e.caption}:{},lines:e.lines,...e.fullLines?{fullLines:e.fullLines}:{},...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},...e.truncated?{truncated:!0}:{}})).filter(e=>e.lines.length>0||!!e.rawText);if(t.length===0)return null;let n=t.map(e=>e.path);return{summary:n.length===1?n[0]:`${n.length} files · ${n.slice(0,2).join(` · `)}${n.length>2?` …`:``}`,fileOperation:{blocks:t}}}function hR(e,t){let n=aR(e)??t,r=oR(e),i=cR(e),a=lR(e),o=uR(e);if(o){let e=YL(o);if(e.length>0)return e[0]??null}let s=dR(e),c=fR(e);if(s!=null||c!=null)return WL({path:n,beforeText:s,afterText:c,operation:r,oldStartLine:i,newStartLine:a});let l=$(e.preview);return l?UL({path:n,text:l,operation:r,oldStartLine:i,newStartLine:a}):null}function gR(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e==`string`){let n=YL(e);n.length>0&&t.push(...n);return}if(!eR(e))return;let r=hR(e,aR(e)??`file-${n+1}`);if(r){t.push(r);return}let i=Array.isArray(e.changes)?gR(e.changes):[];i.length>0&&t.push(...i)}),t}function _R(e){let t=rR(e.result)??rR(e.parsedArgs)??rR(e.args);return t?mR(gR(t.changes)):null}function vR(e){let t=rR(e.parsedArgs)??rR(e.args)??iR(e.args),n=t&&aR(t),r=$(e.result);return!n||!r?null:mR([UL({path:n,text:r,operation:`read`})].filter(e=>!!e))}function yR(e){if(e.status===`partial-call`&&typeof e.args==`string`){let t=$L(e.args,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`]),n=$L(e.args,[`content`,`text`,`afterText`,`after_text`]);if(t?.value&&n?.value){let e=UL({path:t.value,text:n.value,operation:`write`});if(e)return mR([e])}}let t=rR(e.parsedArgs)??rR(e.args)??iR(e.args);if(!t)return null;let n=aR(t),r=$(t.content);return!n||!r?null:mR([UL({path:n,text:r,operation:`write`})].filter(e=>!!e))}function bR(e){let t=rR(e.result),n=rR(e.parsedArgs)??rR(e.args)??iR(e.args);if(!t&&!n)return null;let r=(t?aR(t):null)??(n?aR(n):null),i=(t?dR(t):null)??(n?dR(n):null),a=(t?fR(t):null)??(n?fR(n):null),o=(t?cR(t):null)??(n?cR(n):null),s=(t?lR(t):null)??(n?lR(n):null);return!r||i==null&&a==null?null:mR([WL({path:r,beforeText:i,afterText:a,operation:`edit`,oldStartLine:o,newStartLine:s})].filter(e=>!!e))}function xR(e){let t=rR(e.parsedArgs),n=rR(e.args)??iR(e.args),r=$(e.args)??(t?$(t.patch):null)??(n?$(n.patch):null);return r?mR(YL(r)):null}function SR(e){return pR.has(e.toolName)?e.toolName===`file_change`?_R(e):e.toolName===`read_file`?vR(e):e.toolName===`write_file`?yR(e):e.toolName===`edit_file`?bR(e):e.toolName===`apply_patch`?xR(e):null:null}var CR=[`show_content`,`show_file`,`show_url`,`show_panel_app`];function wR(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function TR(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function ER(e){return Number.isInteger(e)&&typeof e==`number`&&e>0?e:void 0}function DR(e){return e===`file`||e===`url`||e===`panel_app`?e:null}function OR(e){return e===`read`||e===`preview`||e===`edit`||e===`interact`?e:void 0}function kR(e){return e===`inline`||e===`side_panel`?e:void 0}function AR(e){return e===`auto`||e===`source`||e===`rendered`?e:void 0}function jR(e){if(!wR(e)||!wR(e.target))return null;let{target:t}=e,{payload:n,type:r}=t,i=DR(r);if(!i||!wR(n))return null;let a=TR(e.title),o=OR(e.purpose),s=kR(e.placement);if(i===`file`){let e=TR(n.path);return e?{target:{type:`file`,payload:{path:e,line:ER(n.line),column:ER(n.column),viewer:AR(n.viewer)}},title:a,purpose:o,placement:s}:null}if(i===`url`){let e=TR(n.url);return e?{target:{type:`url`,payload:{url:e}},title:a,purpose:o,placement:s}:null}let c=TR(n.appId);return c?{target:{type:`panel_app`,payload:{appId:c}},title:a,purpose:o,placement:s}:null}function MR(e){return!wR(e)||e.action!==`showContent`?null:jR(e.request)}function NR(e){return e.title?e.title:e.target.type===`file`?e.target.payload.path:e.target.type===`url`?e.target.payload.url:e.target.payload.appId}function PR(e){let{actionLabel:t,invocation:n,statusLabel:r}=e;if(!CR.includes(n.toolName))return null;let i=MR(n.result);if(!i)return null;let a={kind:`show-content`,label:t,request:{...i,placement:`side_panel`}},o=i.target.type===`panel_app`&&i.placement===`inline`?{appId:i.target.payload.appId,title:i.title,action:a}:void 0;return{kind:`result`,name:n.toolName,detail:NR(i),text:void 0,outputData:n.result,hasResult:!0,statusTone:`success`,statusLabel:r,action:a,...o?{panelApp:o}:{}}}function FR(e){return typeof e==`object`&&!!e}function IR(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function LR(e){return!FR(e)||e.kind!==`nextclaw.session_request`?null:e}function RR(e){return!FR(e)||e.kind!==`nextclaw.session`?null:e}function zR(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function BR(e){return YI(zR(e)).trim()||void 0}function VR(e,t){return[IR(e.title)?`title: ${e.title?.trim()}`:null,IR(e.sessionId)?`session: ${e.sessionId?.trim()}`:null,IR(e.task)?`task: ${e.task?.trim()}`:null].filter(e=>!!e).join(` · `)||ZI(t)}function HR(e,t){return[IR(e.title)?`title: ${e.title?.trim()}`:null,IR(e.sessionId)?`session: ${e.sessionId?.trim()}`:null].filter(e=>!!e).join(` · `)||ZI(t)}function UR(e){let t=IR(e.requestId),n=IR(e.sessionId),r=IR(e.title),i=IR(e.task),a=IR(e.status),o=IR(e.notify),s=IR(e.lifecycle),c=IR(e.parentSessionId),l=IR(e.spawnedByRequestId),u=e.message===void 0?``:YI(e.message).trim(),d=e.finalResponseText===void 0?``:YI(e.finalResponseText).trim(),f=e.error===void 0?``:YI(e.error).trim(),p=[t?`Request ID: ${t}`:null,n?`Session ID: ${n}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,a?`Status: ${a}`:null,o?`Notify: ${o}`:null,s?`Lifecycle: ${s}`:null,c?`Parent Session ID: ${c}`:null,l?`Spawned By Request ID: ${l}`:null,r?`Title: ${r}`:null,i?`Task:\n${i}`:null,d?`Final Response:\n${d}`:f?`Error:\n${f}`:u?`Status:\n${u}`:null].filter(e=>!!e);return p.length>0?p.join(`
97
+
98
+ `):void 0}function WR(e){let t=IR(e.sessionId),n=IR(e.title),r=IR(e.sessionType),i=IR(e.lifecycle),a=IR(e.parentSessionId),o=IR(e.createdAt),s=[t?`Session ID: ${t}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,n?`Title: ${n}`:null,r?`Session Type: ${r}`:null,i?`Lifecycle: ${i}`:null,a?`Parent Session ID: ${a}`:null,o?`Created At: ${o}`:null].filter(e=>!!e);return s.length>0?s.join(`
99
+
100
+ `):void 0}function GR(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=LR(o);if(s){let e=IR(s.status)?.toLowerCase(),t=VR(s,a),o=UR(s),c=IR(s.sessionId),l=EL({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...IR(s.title)?{label:s.title.trim()}:{},...IR(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:BR(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:BR(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:BR(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=RR(o);if(!c)return null;let l=HR(c,a),u=WR(c),d=IR(c.sessionId),f=EL({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...IR(c.title)?{label:c.title.trim()}:{},...IR(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:BR(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function KR(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e.error:null;return typeof t==`object`&&t&&!Array.isArray(t)&&t.code===`invalid_tool_arguments`?t:null}function qR(e,t){let n=fL(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function JR(e,t){let n=e.mimeType.startsWith(`image/`),r=hL(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function YR(e,t){let n=e.toolInvocation,r=_L(n.result,t);if(r)return r;let i=GR({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:vL(i,t)};let a=PR({invocation:n,actionLabel:t.showContentActionLabel??`Show content`,statusLabel:t.toolStatusCompletedLabel});if(a)return{type:`tool-card`,card:vL(a,t)};let o=yL({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),s=KR(n.result),c=Array.isArray(s?.issues)?s.issues.find(e=>typeof e==`string`&&e.trim().length>0):void 0,l=SR({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),u=c?`Invalid arguments: ${c}`:l?.summary??ZI(n.parsedArgs??n.args),d=l?void 0:xL(n.args,n.parsedArgs),f=c||(typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:YI(n.result).trim()),p=!n.error&&gL(n.result),m=(!l?.fileOperation||!!n.error)&&!p,h=EL(n);return{type:`tool-card`,card:vL({kind:o.kind,name:n.toolName,...h?{agentId:h}:{},detail:u,...d?{input:d}:{},text:m&&f?f:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:o.hasResult,statusTone:s?`error`:o.statusTone,statusLabel:s?t.toolStatusFailedLabel:o.statusLabel,...l?.fileOperation?{fileOperation:l.fileOperation}:{}},t)}}function XR(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:YI(e)}}function ZR(e){return e.type===`text`&&typeof e.text==`string`}function QR(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function $R(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function ez(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function tz(e){let{inlineTokens:t,part:n,texts:r}=e;return ZR(n)?dL(n,t):QR(n)?qR(n,r):$R(n)?JR(n,r):ez(n)?YR(n,r):XR(n,r)}function nz(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function rz(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function iz(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function az(e,t){return{id:e.id,role:iz(e.role),roleLabel:rz(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(nz(e)),status:e.meta?.status,processSummary:e.meta?.processSummary,parts:e.parts.map(n=>tz({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}function oz(e){return e.type===`reasoning`||e.type===`tool-invocation`}function sz(e){return e.type===`text`||e.type===`rich-text`?e.text.trim().length>0:e.type===`file`||e.type===`source`||e.type===`card`}function cz(e){if(e.role!==`assistant`||e.status===`pending`||e.status===`streaming`)return!1;let t=-1;for(let n=e.parts.length-1;n>=0;--n){let r=e.parts[n];if(r&&oz(r)){t=n;break}}return t>=0&&t<e.parts.length-1&&e.parts.slice(t+1).some(sz)}function lz(e){let t=e.lifecycle?.startedAt,n=e.lifecycle?.endedAt;if(!t||!n)return null;let r=Date.parse(t),i=Date.parse(n);if(!Number.isFinite(r)||!Number.isFinite(i)||i<r)return null;let a=Math.round((i-r)/1e3),o=Math.floor(a/3600),s=Math.floor(a%3600/60),c=a%60;return o>0?s>0?`${o}h ${s}m`:`${o}h`:s>0?`${s}m ${c}s`:`${c}s`}function uz({message:e,processedLabel:t}){if(!cz(e))return;let n=lz(e);return{label:n?`${t} ${n}`:t}}function dz(e){return{roleLabels:{user:d(`chatRoleUser`),assistant:d(`chatRoleAssistant`),tool:d(`chatRoleTool`),system:d(`chatRoleSystem`),fallback:d(`chatRoleMessage`)},reasoningLabel:d(`chatReasoning`),toolCallLabel:d(`chatToolCall`),toolResultLabel:d(`chatToolResult`),toolInputLabel:d(`chatToolInput`),toolNoOutputLabel:d(`chatToolNoOutput`),toolOutputLabel:d(`chatToolOutput`),toolStatusPreparingLabel:d(`chatToolStatusPreparing`),toolStatusRunningLabel:d(`chatToolStatusRunning`),toolStatusCompletedLabel:d(`chatToolStatusCompleted`),toolStatusFailedLabel:d(`chatToolStatusFailed`),toolStatusCancelledLabel:d(`chatToolStatusCancelled`),showContentActionLabel:d(`chatShowContentAction`),imageAttachmentLabel:d(`chatImageAttachment`),fileAttachmentLabel:d(`chatFileAttachment`),unknownPartLabel:d(`chatUnknownPart`)}}function fz(){return{directory:{running:d(`chatToolDirectoryRunning`),success:d(`chatToolDirectorySuccess`),error:d(`chatToolDirectoryError`),cancelled:d(`chatToolDirectoryCancelled`)},web:{running:d(`chatToolWebRunning`),success:d(`chatToolWebSuccess`),error:d(`chatToolWebError`),cancelled:d(`chatToolWebCancelled`)},message:{running:d(`chatToolMessageRunning`),success:d(`chatToolMessageSuccess`),error:d(`chatToolMessageError`),cancelled:d(`chatToolMessageCancelled`)},session:{running:d(`chatToolSessionRunning`),success:d(`chatToolSessionSuccess`),error:d(`chatToolSessionError`),cancelled:d(`chatToolSessionCancelled`)},agent:{running:d(`chatToolAgentRunning`),success:d(`chatToolAgentSuccess`),error:d(`chatToolAgentError`),cancelled:d(`chatToolAgentCancelled`)},memory:{running:d(`chatToolMemoryRunning`),success:d(`chatToolMemorySuccess`),error:d(`chatToolMemoryError`),cancelled:d(`chatToolMemoryCancelled`)},schedule:{running:d(`chatToolScheduleRunning`),success:d(`chatToolScheduleSuccess`),error:d(`chatToolScheduleError`),cancelled:d(`chatToolScheduleCancelled`)},system:{running:d(`chatToolSystemRunning`),success:d(`chatToolSystemSuccess`),error:d(`chatToolSystemError`),cancelled:d(`chatToolSystemCancelled`)},image:{running:d(`chatToolImageRunning`),success:d(`chatToolImageSuccess`),error:d(`chatToolImageError`),cancelled:d(`chatToolImageCancelled`)},display:{running:d(`chatToolDisplayRunning`),success:d(`chatToolDisplaySuccess`),error:d(`chatToolDisplayError`),cancelled:d(`chatToolDisplayCancelled`)}}}function pz(e){return{copyCodeLabel:d(`chatCodeCopy`),copiedCodeLabel:d(`chatCodeCopied`),copyMessageLabel:d(`chatMessageCopy`),copiedMessageLabel:d(`chatMessageCopied`),typingLabel:d(`chatTyping`),reasoningCharacterCountTemplates:{inProgress:d(`chatReasoningInProgressCharacterCount`),completed:d(`chatReasoningCompletedCharacterCount`)},toolStatusLabels:{terminal:{running:d(`chatToolTerminalRunning`),success:d(`chatToolTerminalSuccess`),error:d(`chatToolTerminalError`),cancelled:d(`chatToolTerminalCancelled`)},fileRead:{running:d(`chatToolFileReadRunning`),success:d(`chatToolFileReadSuccess`),error:d(`chatToolFileReadError`),cancelled:d(`chatToolFileReadCancelled`)},fileEdit:{running:d(`chatToolFileEditRunning`),success:d(`chatToolFileEditSuccess`),error:d(`chatToolFileEditError`),cancelled:d(`chatToolFileEditCancelled`)},search:{running:d(`chatToolSearchRunning`),success:d(`chatToolSearchSuccess`),error:d(`chatToolSearchError`),cancelled:d(`chatToolSearchCancelled`)},builtIn:fz()},attachmentOpenLabel:d(`chatAttachmentOpen`),attachmentAttachedLabel:d(`chatAttachmentAttached`),attachmentExpandLabel:d(`chatAttachmentExpand`),attachmentCloseLabel:d(`chatAttachmentClosePreview`),attachmentCategoryLabels:{archive:d(`chatAttachmentCategoryArchive`),audio:d(`chatAttachmentCategoryAudio`),code:d(`chatAttachmentCategoryCode`),data:d(`chatAttachmentCategoryData`),document:d(`chatAttachmentCategoryDocument`),generic:d(`chatAttachmentCategoryGeneric`),image:d(`chatAttachmentCategoryImage`),pdf:d(`chatAttachmentCategoryPdf`),sheet:d(`chatAttachmentCategorySheet`),video:d(`chatAttachmentCategoryVideo`)},toolActivitySegmentTemplates:{read:{one:d(`chatToolActivityReadOne`),other:d(`chatToolActivityReadOther`)},edit:{one:d(`chatToolActivityEditOne`),other:d(`chatToolActivityEditOther`)},directory:{one:d(`chatToolActivityDirectoryOne`),other:d(`chatToolActivityDirectoryOther`)},search:{one:d(`chatToolActivitySearchOne`),other:d(`chatToolActivitySearchOther`)},bash:{one:d(`chatToolActivityBashOne`),other:d(`chatToolActivityBashOther`)},web:{one:d(`chatToolActivityWebOne`),other:d(`chatToolActivityWebOther`)},agent:{one:d(`chatToolActivityAgentOne`),other:d(`chatToolActivityAgentOther`)},panel:{one:d(`chatToolActivityPanelOne`),other:d(`chatToolActivityPanelOther`)},other:{one:d(`chatToolActivityOtherOne`),other:d(`chatToolActivityOtherOther`)}},toolActivityFailedLabel:d(`chatProcessSummaryFailed`),toolActivityCancelledLabel:d(`chatProcessSummaryCancelled`)}}function mz(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function hz(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function gz(e){return e===!0}function _z(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=hz(n.usedContextTokens),i=hz(n.totalContextTokens),a=hz(n.prunedUsedContextTokens),o=mz(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=hz(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:hz(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:hz(n.droppedHistoryCount)??0,truncatedToolResultCount:hz(n.truncatedToolResultCount)??0,truncatedSystemPrompt:gz(n.truncatedSystemPrompt),truncatedUserMessage:gz(n.truncatedUserMessage),compacted:gz(n.compacted),...mz(n.checkpointId)?{checkpointId:mz(n.checkpointId)??void 0}:{},compactedMessageCount:hz(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function vz(e){let{metadata:t}=e;if(!t||t.nextclaw_timeline_kind!==`context_compaction`)return null;let n=t.checkpoint&&typeof t.checkpoint==`object`&&!Array.isArray(t.checkpoint)?t.checkpoint:null;if(!n)return null;let r=mz(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=mz(n.summary),o=hz(n.coveredMessageCount),s=hz(n.coveredSessionMessageCount),c=hz(n.originalEstimatedTokens),l=hz(n.projectedEstimatedTokens),u=mz(n.createdAt),d=mz(n.updatedAt);return!r||!i||!a||o===null||s===null||c===null||l===null||!u||!d?null:{id:r,status:i,summary:a,coveredMessageCount:o,coveredSessionMessageCount:s,originalEstimatedTokens:c,projectedEstimatedTokens:l,createdAt:u,updatedAt:d}}function yz({deletePending:e,entry:t,favoritePending:n,onDelete:r,onOpen:i,onToggleFavorite:a}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),u=t.favorite?d(`panelAppsUnfavorite`):d(`panelAppsFavorite`),f=t.lastOpenedAt?`${d(`panelAppsLastOpened`)} ${xz(t.lastOpenedAt)}`:`${d(`panelAppsUpdated`)} ${xz(t.updatedAt)}`,p=e=>{e.stopPropagation(),a()},m=()=>{s(!1),l(!0)};return(0,R.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-border/60 bg-card px-2.5 py-2.5 transition-colors hover:bg-muted/40`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted text-base text-muted-foreground`,children:(0,R.jsx)(Sz,{icon:t.icon,title:t.title})}),(0,R.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:t.title})]}),t.description?(0,R.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-muted-foreground`,children:t.description}):null,(0,R.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-muted-foreground/70`,children:f})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:p,disabled:n,className:`rounded-md p-1.5 text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,title:u,"aria-label":u,children:(0,R.jsx)(pa,{className:t.favorite?`h-4 w-4 fill-current text-foreground`:`h-4 w-4`})}),(0,R.jsxs)(zo,{open:o,onOpenChange:s,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground`,"aria-label":d(`panelAppsMoreActions`),disabled:e,children:(0,R.jsx)(hi,{className:`h-4 w-4`})})}),(0,R.jsx)(Ho,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,R.jsx)(bz,{destructive:!0,disabled:e,icon:ha,label:d(`panelAppsDelete`),onClick:m})})]})]})]}),(0,R.jsx)(Sn,{open:c,onOpenChange:l,title:d(`panelAppsDeleteConfirmTitle`),description:`${d(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:d(`delete`),variant:`destructive`,onConfirm:r,onCancel:()=>void 0})]})}function bz({destructive:e=!1,disabled:t=!1,icon:n,label:r,onClick:i}){return(0,R.jsxs)(`button`,{type:`button`,className:p(`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`,e?`text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`),disabled:t,onClick:i,children:[(0,R.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{children:r})]})}function xz(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let r=l(t()),i=new Date;return n.toDateString()===i.toDateString()?new Intl.DateTimeFormat(r,{hour:`2-digit`,minute:`2-digit`}).format(n):n.getFullYear()===i.getFullYear()?new Intl.DateTimeFormat(r,{month:`numeric`,day:`numeric`}).format(n):new Intl.DateTimeFormat(r,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(n)}function Sz({icon:e,title:t}){return e?Cz(e)?(0,R.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,R.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,R.jsx)(E,{className:`h-4 w-4`})}function Cz(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var wz=[`panel-apps`];function Tz(e={}){return Me({queryKey:wz,queryFn:()=>F.panelApps.listPanelApps(),enabled:e.enabled??!0,staleTime:0})}function Ez(){let e=Be();return we({mutationFn:({id:e,preferences:t})=>F.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:wz})}})}function Dz(){let e=Be();return we({mutationFn:e=>F.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:wz})}})}function Oz(){let e=Be();return we({mutationFn:e=>F.panelApps.grantClient(e),onSuccess:()=>{e.invalidateQueries({queryKey:wz})}})}function kz(){let e=Be();return we({mutationFn:e=>F.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:wz})}})}function Az(e,t){return t===`favorites`?jz(e.filter(e=>e.favorite),`smart`):jz(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function jz(e,t){return[...e].sort((e,n)=>Mz(e,n,t))}function Mz(e,t,n){return n===`recent-open`?Iz(e.lastOpenedAt,t.lastOpenedAt)||Nz(e,t):n===`updated`?Iz(e.updatedAt,t.updatedAt)||Nz(e,t):n===`name`?Nz(e,t):Pz(e,t)||Number(t.favorite)-Number(e.favorite)||Nz(e,t)}function Nz(e,t){return e.title.localeCompare(t.title)}function Pz(e,t){return Fz(t)-Fz(e)}function Fz(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function Iz(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}var Lz=L.createContext(null);function Rz({defaultValue:e,value:t,onValueChange:n,children:r}){return(0,R.jsx)(Lz.Provider,{value:{value:t,onValueChange:n},children:r})}function zz({children:e,className:t}){return(0,R.jsx)(`div`,{className:p(`inline-flex h-9 items-center justify-center rounded-xl bg-muted p-1 text-muted-foreground`,t),children:e})}function Bz({value:e,children:t,className:n}){let r=L.useContext(Lz);if(!r)throw Error(`TabsTrigger must be used within Tabs`);let i=r.value===e;return(0,R.jsx)(`button`,{type:`button`,onClick:()=>r.onValueChange(e),"aria-pressed":i,"data-state":i?`active`:`inactive`,className:p(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-[13px] font-medium transition-all duration-fast focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:pointer-events-none disabled:opacity-50`,i?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`,n),children:t})}function Vz({value:e,children:t,className:n}){let r=L.useContext(Lz);if(!r)throw Error(`TabsContent must be used within Tabs`);return r.value===e?(0,R.jsx)(`div`,{className:p(`mt-2 animate-fade-in`,n),children:t}):null}var Hz=[];function Uz({headerContent:e,onOpenPanelApp:t}){let n=Tz(),r=kz(),i=Ez(),a=Dz(),o=Oz(),s=sY(),c=ie(),[l,u]=(0,L.useState)(`smart`),f=n.data?.entries??Hz,p=(0,L.useMemo)(()=>Az(f,l),[f,l]),m=async e=>{if(await h(e))try{t(await a.mutateAsync(e.id))}catch{t(e)}},h=async e=>!e.clientDeclared||e.clientGranted?!0:await s.serviceActionAuthorizationManager.requestAuthorization({panelAppId:e.appId,actions:[{actionId:`nextclaw.client`,actionTitle:d(`panelAppsClientGrantTitle`),actionDescription:d(`panelAppsClientGrantDescription`),risk:`dangerous`}]})?(await o.mutateAsync(e.appId),!0):!1,g=e=>{i.mutate({id:e.id,preferences:{favorite:!e.favorite}})},_=e=>{r.mutate(e.id)},v=()=>{c(`/chat`),s.chatDraftIntentManager.requestDraft(d(`panelAppsExamplePrompt`))};return n.isLoading?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:d(`panelAppsLoading`)}):n.isError?(0,R.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:n.error instanceof Error?n.error.message:d(`panelAppsLoadFailed`)}):(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card text-card-foreground`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/70 px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:d(`panelAppsTitle`)}),n.data?.panelsPath?(0,R.jsx)(Ln,{delayDuration:250,children:(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-muted-foreground/70 transition-colors hover:bg-accent hover:text-accent-foreground`,"aria-label":d(`panelAppsTitle`),children:(0,R.jsx)(ii,{className:`h-3.5 w-3.5`})})}),(0,R.jsx)(Fn,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:n.data.panelsPath})]})}):null]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void n.refetch(),className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,title:d(`panelAppsRefresh`),"aria-label":d(`panelAppsRefresh`),children:(0,R.jsx)(br,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`border-b border-border/70 px-3 py-2`,children:(0,R.jsx)(Rz,{value:l,onValueChange:e=>u(e),children:(0,R.jsxs)(zz,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-muted/70 p-0.5`,children:[(0,R.jsx)(Bz,{value:`smart`,className:`px-2 py-1 text-xs`,children:d(`panelAppsSortSmart`)}),(0,R.jsx)(Bz,{value:`favorites`,className:`px-2 py-1 text-xs`,children:d(`panelAppsFavorites`)}),(0,R.jsx)(Bz,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:d(`panelAppsSortRecentOpen`)}),(0,R.jsx)(Bz,{value:`updated`,className:`px-2 py-1 text-xs`,children:d(`panelAppsSortUpdated`)}),(0,R.jsx)(Bz,{value:`name`,className:`px-2 py-1 text-xs`,children:d(`panelAppsSortName`)})]})})}),f.length===0?(0,R.jsx)(Wz,{panelsPath:n.data?.panelsPath,onCreateExample:v,onRefresh:()=>void n.refetch()}):p.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:d(`panelAppsEmptyFiltered`)}):(0,R.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,R.jsx)(`div`,{className:`space-y-1.5`,children:p.map(e=>(0,R.jsx)(yz,{entry:e,deletePending:r.isPending,favoritePending:i.isPending,onDelete:()=>_(e),onOpen:()=>void m(e),onToggleFavorite:()=>g(e)},e.id))})})]})}function Wz({onCreateExample:e,panelsPath:t,onRefresh:n}){return(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center overflow-y-auto px-5 py-6 text-center`,children:(0,R.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,R.jsx)(`div`,{className:`mx-auto flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(E,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-foreground`,children:d(`panelAppsEmptyTitle`)}),(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:d(`panelAppsEmptyDescription`)}),(0,R.jsxs)(`div`,{className:`mt-4 space-y-2 text-left`,children:[(0,R.jsx)(Gz,{icon:(0,R.jsx)(Hi,{className:`h-4 w-4`}),title:d(`panelAppsEmptyAskTitle`),description:d(`panelAppsEmptyAskDescription`),actionLabel:d(`panelAppsEmptyAskAction`),onAction:e}),(0,R.jsx)(Gz,{icon:(0,R.jsx)(bi,{className:`h-4 w-4`}),title:d(`panelAppsEmptyFileTitle`),description:d(`panelAppsEmptyFileDescription`)})]}),t?(0,R.jsxs)(`div`,{className:`mt-4 rounded-md bg-muted/60 px-3 py-2 text-left`,children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium uppercase text-muted-foreground/70`,children:d(`panelAppsPanelsPath`)}),(0,R.jsx)(`code`,{className:`mt-1 block break-all text-xs text-muted-foreground`,children:t})]}):null,(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:`mt-4 inline-flex items-center justify-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,children:[(0,R.jsx)(br,{className:`h-3.5 w-3.5`}),d(`panelAppsRefresh`)]})]})})}function Gz({actionLabel:e,description:t,icon:n,onAction:r,title:i}){let a=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:n}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:i}),(0,R.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-muted-foreground`,children:t}),e?(0,R.jsx)(`div`,{className:`mt-2 text-xs font-medium text-primary`,children:e}):null]})]});return r?(0,R.jsx)(`button`,{type:`button`,onClick:r,className:`flex w-full gap-2 rounded-md bg-muted/60 px-3 py-2.5 text-left transition-colors hover:bg-accent/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,children:a}):(0,R.jsx)(`div`,{className:`flex gap-2 rounded-md bg-muted/60 px-3 py-2.5`,children:a})}var Kz=class{constructor(e){this.authorizationManager=e,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=this.getBridgeContext(t),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 F.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await F.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 F.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof me)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await F.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await F.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof me)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await F.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await F.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof me)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await F.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.appId,actions:[{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 me({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await F.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.listGrantCandidateActions(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.appId,actions:r.map(e=>({actionId:e.id,actionTitle:e.title,actionDescription:e.description,risk:e.risk})),inputPreview:this.createInputPreview(n)}))throw new me({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});let i=await F.serviceApps.grantServiceActions(r.map(e=>e.id),{bridgeSessionToken:e.token}),a=i.grants.find(e=>e.actionId===t)??i.grants[0];if(!a)throw Error(`No permission grant returned for ${t}.`);return a},this.listGrantCandidateActions=async(e,t)=>{let n=await F.serviceApps.listServiceActions({bridgeSessionToken:e.token}),r=n.actions.find(e=>e.id===t);if(r&&r.grantState!==`not-granted`)return[r];let i=n.actions.filter(e=>e.grantState===`not-granted`),a=[...i.filter(e=>e.id===t),...i.filter(e=>e.id!==t)];return a.length>0?a:[{appId:r?.appId??t.split(`.`)[0]??t,description:r?.description,id:t,name:r?.name??t,risk:r?.risk??`dangerous`,title:r?.title}]},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.getBridgeContext=e=>({appId:e.appId,token:e.runtimeToken}),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 me?{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`&&typeof t.runtimeToken==`string`&&typeof t.appId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function qz(e,t){let n=t.trim();return[e.id,e.appId,e.fileName,e.title].some(e=>e.trim()===n)}function Jz(e,t){let n=t.trim();return n?e.find(e=>qz(e,n))??null:null}var Yz=`allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads allow-pointer-lock allow-presentation`;function Xz(e){e?.focus({preventScroll:!0}),e?.contentWindow?.focus()}function Zz(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var Qz=f((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:Zz(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function $z(){let e=Qz(e=>e.pending),t=Qz(e=>e.resolveAuthorization);return(0,R.jsx)(vn,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,R.jsxs)(bn,{className:`[&>:last-child]:hidden`,children:[(0,R.jsxs)(yn,{children:[(0,R.jsxs)(xn,{className:`flex items-center gap-2`,children:[(0,R.jsx)(oa,{className:`h-4 w-4 text-amber-600`}),d(`serviceActionAuthorizationTitle`)]}),(0,R.jsx)(_n,{children:d(`serviceActionAuthorizationDescription`)})]}),e?(0,R.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border bg-muted/60 p-3 text-sm`,children:[(0,R.jsx)(tB,{label:d(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:d(`serviceActionAuthorizationActions`)}),(0,R.jsx)(`div`,{className:`max-h-64 space-y-2 overflow-auto`,children:e.actions.map(e=>(0,R.jsx)(eB,{action:e},e.actionId))})]}),e.inputPreview?(0,R.jsx)(tB,{label:d(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,R.jsxs)(gn,{className:`gap-2 sm:gap-0`,children:[(0,R.jsx)(Ut,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:d(`serviceActionAuthorizationReject`)}),(0,R.jsx)(Ut,{type:`button`,onClick:()=>t(!0),children:d(`serviceActionAuthorizationAllow`)})]})]})})}function eB({action:e}){return(0,R.jsxs)(`div`,{className:`space-y-1 rounded border border-border bg-card px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsx)(`div`,{className:`min-w-0 break-words text-xs font-medium text-foreground`,children:e.actionTitle??e.actionId}),(0,R.jsx)(`div`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700`,children:e.risk??`dangerous`})]}),(0,R.jsx)(`div`,{className:`break-words text-[11px] text-muted-foreground`,children:e.actionId}),e.actionDescription?(0,R.jsx)(`div`,{className:`break-words text-xs text-muted-foreground`,children:e.actionDescription}):null]})}function tB({label:e,value:t}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,R.jsx)(`div`,{className:`min-w-0 break-words text-xs text-foreground`,children:t})]})}var nB=class{constructor(){this.requestAuthorization=async e=>await Qz.getState().requestAuthorization(e)}},rB=[`service-apps`],iB=[`service-actions`],aB=[`service-action-grants`];function oB(){return Me({queryKey:rB,queryFn:()=>F.serviceApps.listServiceApps()})}function sB(){return Me({queryKey:iB,queryFn:()=>F.serviceApps.listServiceActions()})}function cB(){return Me({queryKey:aB,queryFn:()=>F.serviceApps.listServiceActionGrants()})}function lB(){let e=Be();return we({mutationFn:e=>F.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:rB}),e.invalidateQueries({queryKey:iB})])}})}function uB(){let e=Be();return we({mutationFn:e=>F.serviceApps.deleteServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:rB}),e.invalidateQueries({queryKey:iB}),e.invalidateQueries({queryKey:aB})])}})}function dB(){let e=Be();return we({mutationFn:e=>F.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:rB})}})}function fB(){let e=Be();return we({mutationFn:e=>F.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:iB}),e.invalidateQueries({queryKey:aB})])}})}function pB({headerContent:e}){let t=oB(),n=sB(),r=cB(),i=uB(),a=lB(),o=dB(),s=fB(),[c,l]=(0,L.useState)({}),[u,f]=(0,L.useState)({}),p=()=>{t.refetch(),n.refetch(),r.refetch()};if(t.isLoading||n.isLoading||r.isLoading)return(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:d(`serviceAppsLoading`)});if(t.isError||n.isError||r.isError){let e=t.error??n.error??r.error;return(0,R.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:d(`serviceAppsLoadFailed`)})}let m=t.data?.entries??[],h=n.data?.actions??[],g=r.data?.grants??[],_=e=>{o.mutateAsync(e).then(t=>{l(n=>({...n,[e]:t.actions})),f(t=>({...t,[e]:!0}))})};return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card text-card-foreground`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/60 px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ia,{className:`h-4 w-4 text-primary`}),(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:d(`serviceAppsTitle`)})]})}),(0,R.jsx)(Ln,{delayDuration:250,children:(0,R.jsx)(_B,{icon:br,label:d(`serviceAppsRefresh`),onClick:p})})]}),m.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 py-8 text-center`,children:(0,R.jsxs)(`div`,{className:`w-full max-w-xs`,children:[(0,R.jsx)(`div`,{className:`mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,R.jsx)(ia,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-foreground`,children:d(`serviceAppsEmptyTitle`)}),(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:d(`serviceAppsEmptyDescription`)})]})}):(0,R.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto bg-muted/25 p-3`,children:(0,R.jsx)(`div`,{className:`space-y-2.5`,children:m.map(e=>(0,R.jsx)(mB,{app:e,actions:c[e.id]??h.filter(t=>t.appId===e.id),actionsOpen:!!u[e.id],grants:g,deletePending:i.isPending,isDiscovering:o.isPending,onActionsOpenChange:t=>f(n=>({...n,[e.id]:t})),onDiscover:_,onDelete:e=>void i.mutate(e),onRestart:e=>void a.mutate(e),onRevoke:e=>void s.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function mB({app:e,actions:t,actionsOpen:n,grants:r,deletePending:i,isDiscovering:a,onActionsOpenChange:o,onDiscover:s,onDelete:c,onRestart:l,onRevoke:u}){let[f,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(!1),_=e.status!==`starting`&&e.status!==`stopped`,v=e.status===`running`||e.status===`failed`,y=()=>{m(!1),g(!0)};return(0,R.jsx)(Ln,{delayDuration:250,children:(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border/70 bg-card shadow-[0_1px_2px_rgba(30,20,10,0.03)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3 px-3 pt-3`,children:[(0,R.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(ia,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,R.jsx)(hB,{status:e.status})]}),e.description?(0,R.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground`,children:e.description}):null]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(_B,{disabled:a||!_,icon:ta,label:d(`serviceAppsDiscoverActions`),tooltip:d(`serviceAppsDiscoverActionsHint`),onClick:()=>s(e.id)}),(0,R.jsx)(_B,{disabled:!v,icon:_a,label:d(`serviceAppsDisconnectRuntime`),tooltip:d(`serviceAppsDisconnectRuntimeHint`),onClick:()=>l(e.id)}),(0,R.jsxs)(zo,{open:f,onOpenChange:m,children:[(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,"aria-label":d(`serviceAppsMoreActions`),disabled:i,children:(0,R.jsx)(hi,{className:`h-3.5 w-3.5`})})})}),(0,R.jsx)(Fn,{side:`bottom`,className:`text-xs`,children:d(`serviceAppsMoreActions`)})]}),(0,R.jsx)(Ho,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,R.jsx)(vB,{destructive:!0,disabled:i,icon:ha,label:d(`serviceAppsDelete`),onClick:y})})]})]})]}),e.lastError?(0,R.jsx)(`div`,{className:`mx-3 mt-3 rounded-lg border border-rose-200/70 bg-rose-50 px-2.5 py-1.5 text-xs text-rose-700`,children:e.lastError}):null,(0,R.jsx)(yB,{app:e}),(0,R.jsxs)(`div`,{className:`mt-3 border-t border-border/50 bg-muted/30`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(!n),className:`flex w-full items-start justify-between gap-2 px-3 py-2 text-left transition-colors hover:bg-muted/40`,"aria-expanded":n,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground/80`,children:d(`serviceAppsActionsSection`)}),(0,R.jsx)(`span`,{className:`rounded-full bg-card px-1.5 py-0.5 text-[11px] tabular-nums text-muted-foreground/70`,children:t.length})]}),n?null:t.length===0?(0,R.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:d(`serviceAppsActionsEmpty`)}):(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[t.slice(0,4).map(e=>(0,R.jsx)(`span`,{className:`max-w-[9.5rem] truncate rounded-md border border-border/50 bg-card px-1.5 py-0.5 text-[11px] text-muted-foreground`,title:e.title??e.name,children:e.title??e.name},e.id)),t.length>4?(0,R.jsxs)(`span`,{className:`rounded-md bg-card px-1.5 py-0.5 text-[11px] text-muted-foreground/70`,children:[`+`,t.length-4]}):null]})]}),(0,R.jsx)(Vn,{className:p(`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground/70 transition-transform`,n&&`rotate-180`)})]}),n?(0,R.jsx)(`div`,{className:`px-3 pb-2.5`,children:t.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 bg-card/70 px-2.5 py-2 text-[11px] text-muted-foreground`,children:d(`serviceAppsActionsEmpty`)}):(0,R.jsx)(`div`,{className:`space-y-1.5`,children:t.map(e=>(0,R.jsx)(xB,{action:e,grants:r.filter(t=>t.actionId===e.id),onRevoke:u},e.id))})}):null]}),(0,R.jsx)(Sn,{open:h,onOpenChange:g,title:d(`serviceAppsDeleteConfirmTitle`),description:`${d(`serviceAppsDeleteConfirmDescription`)} ${e.title}`,confirmLabel:d(`delete`),variant:`destructive`,onConfirm:()=>c(e.id),onCancel:()=>void 0})]})})}function hB({status:e}){let t=gB(e),n=t.icon;return(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsxs)(`span`,{className:p(`inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] font-medium`,t.className),"aria-label":t.label,children:[(0,R.jsx)(n,{className:p(`h-3 w-3`,t.iconClassName)}),(0,R.jsx)(`span`,{children:t.label})]})}),(0,R.jsx)(Fn,{side:`bottom`,className:`text-xs`,children:t.tooltip})]})}function gB(e){switch(e){case`running`:return{className:`bg-emerald-50 text-emerald-700`,icon:ni,label:d(`serviceAppsStatus_running`),tooltip:d(`serviceAppsStatusHint_running`)};case`starting`:return{className:`bg-blue-50 text-blue-700`,icon:vr,iconClassName:`animate-spin`,label:d(`serviceAppsStatus_starting`),tooltip:d(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`bg-rose-50 text-rose-700`,icon:ga,label:d(`serviceAppsStatus_failed`),tooltip:d(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`bg-muted text-muted-foreground`,icon:ai,label:d(`serviceAppsStatus_stopped`),tooltip:d(`serviceAppsStatusHint_stopped`)};default:return{className:`bg-muted text-muted-foreground`,icon:ri,label:d(`serviceAppsStatus_idle`),tooltip:d(`serviceAppsStatusHint_idle`)}}}function _B({disabled:e=!1,icon:t,label:n,tooltip:r=n,onClick:i}){return(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:i,disabled:e,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/40 disabled:opacity-60 disabled:hover:bg-transparent`,"aria-label":n,children:(0,R.jsx)(t,{className:`h-3.5 w-3.5`})})}),(0,R.jsx)(Fn,{side:`bottom`,className:`max-w-56 text-xs`,children:r})]})}function vB({destructive:e=!1,disabled:t=!1,icon:n,label:r,onClick:i}){return(0,R.jsxs)(`button`,{type:`button`,className:p(`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`,e?`text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`),disabled:t,onClick:i,children:[(0,R.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{children:r})]})}function yB({app:e}){let[t,n]=(0,L.useState)(!1),r=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),i=[{label:d(`serviceAppsCommand`),value:r},{label:d(`serviceAppsCwd`),value:e.cwd},{label:d(`serviceAppsManifest`),value:e.manifestPath},{label:d(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:d(`serviceAppsLastReady`),value:e.lastReadyAt},{label:d(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return i.length===0?null:(0,R.jsxs)(`div`,{className:`mx-3 mt-3 overflow-hidden rounded-lg border border-border/50 bg-muted/35`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/50`,"aria-expanded":t,children:[(0,R.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:d(`serviceAppsDetails`)}),(0,R.jsx)(Vn,{className:p(`h-3.5 w-3.5 shrink-0 text-muted-foreground/70 transition-transform`,t&&`rotate-180`)})]}),t?(0,R.jsx)(`dl`,{className:`grid grid-cols-[4.75rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-border/50 px-2.5 py-2 text-[11px]`,children:i.map(e=>(0,R.jsx)(bB,{label:e.label,value:e.value},e.label))}):null]})}function bB({label:e,value:t}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground/70`,children:e}),(0,R.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-muted-foreground`,title:t,children:t})]})}function xB({action:e,grants:t,onRevoke:n}){return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-card px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,R.jsx)(ba,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`truncate text-xs font-medium text-foreground`,children:e.title??e.name}),e.description?(0,R.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:e.description}):null]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,R.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:d(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,R.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:e.risk})]})]}),t.map(e=>(0,R.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2 pl-8`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(sa,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,R.jsxs)(`span`,{className:`truncate`,children:[d(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-muted hover:text-rose-600`,title:d(`serviceAppsRevokeGrant`),"aria-label":d(`serviceAppsRevokeGrant`),children:(0,R.jsx)(ha,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function SB({activeTab:e,onActiveTabChange:t,onOpenPanelApp:n}){let r=(0,R.jsx)(Rz,{value:e,onValueChange:e=>t(e),children:(0,R.jsxs)(zz,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,R.jsxs)(Bz,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,R.jsx)(E,{className:`h-3.5 w-3.5`}),d(`panelAppsTitle`)]}),(0,R.jsxs)(Bz,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,R.jsx)(ia,{className:`h-3.5 w-3.5`}),d(`serviceAppsTitle`)]})]})});return(0,R.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,R.jsx)(Uz,{headerContent:r,onOpenPanelApp:n}):(0,R.jsx)(pB,{headerContent:r})})}function CB({appTitle:e,onOpenApps:t,onRefresh:n}){return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/70 bg-card px-3.5 py-2 shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`inline-flex shrink-0 items-center rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,title:d(`appsTitle`),"aria-label":d(`appsTitle`),children:(0,R.jsx)(Cn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-muted-foreground`,title:e,children:e}),(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,title:d(`panelAppsRefreshCurrent`),"aria-label":d(`panelAppsRefreshCurrent`),children:(0,R.jsx)(br,{className:`h-3.5 w-3.5`})})]})}var wB=ee,TB=O,EB=`panel-apps`;function DB(e){return e===`panel-apps`||e===`service-apps`}function OB(e=EB){return e===EB?N:ne}function kB(e){try{let t=new URL(e).searchParams.get(`tab`);return DB(t)?t:EB}catch{return EB}}function AB(e){e.open(OB(),{kind:wB,title:d(`appsTitle`),dedupeKey:`apps`})}var jB={[S]:{getTitle:()=>d(`docBrowserHomeTitle`),renderContent:({open:e})=>(0,R.jsx)(b,{open:e})},[wB]:{getTitle:()=>d(`appsTitle`),renderIcon:()=>(0,R.jsx)(Bn,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t,openTarget:n})=>(0,R.jsx)(SB,{activeTab:kB(e),onActiveTabChange:e=>t(OB(e),{activate:!1,kind:wB,title:d(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>n(w(e))})},[TB]:{getIframeSandbox:()=>Yz,getTitle:e=>e.title||d(`panelAppsTitle`),onIframeMessage:e=>rY().panelAppBridgeManager.handleIframeMessage(e),onIframePointerOver:e=>Xz(e.currentTarget),renderIcon:()=>(0,R.jsx)(E,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t,tab:n})=>(0,R.jsx)(CB,{appTitle:n.title||d(`panelAppsTitle`),onOpenApps:()=>AB({open:e}),onRefresh:t})}},MB={nextclawDisplayMode:`card`,nextclawPlacement:`inline`};function NB(e){return`/api/panel-apps/${encodeURIComponent(e)}/content`}function PB(e){return`${e}${e.includes(`?`)?`&`:`?`}${new URLSearchParams(MB).toString()}`}function FB(e){let{appId:t,title:n,url:r}=e;return{currentUrl:r,dedupeKey:`panel-app:${t}`,history:[r],historyIndex:0,id:`inline-panel-app:${t}`,kind:O,navVersion:0,resourceUri:C(t),title:n}}function IB({panelApp:e,showExpandAction:t=!0}){let n=Pr(),r=(0,L.useRef)(null),i=(0,L.useId)(),a=Tz(),o=(0,L.useMemo)(()=>Jz(a.data?.entries??[],e.appId),[e.appId,a.data?.entries]),s=o?w(o):null,c=e.title??s?.title??e.appId,l=a.isLoading?``:s?.url??NB(e.appId),u=(0,L.useMemo)(()=>l?PB(l):``,[l]),f=(0,L.useMemo)(()=>FB({appId:o?.id??e.appId,title:c,url:l}),[o?.id,e.appId,c,l]),p=`${f.id}:${f.navVersion}:${i}`,m=()=>{if(s){n.openTarget(s);return}n.open(l,{dedupeKey:f.dedupeKey,kind:f.kind,title:c})};return(0,L.useEffect)(()=>{if(!l)return;let e=e=>{rY().panelAppBridgeManager.handleIframeMessage({event:e,iframe:r.current,iframeInstanceId:p,tab:f})};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[p,f,l]),l?(0,R.jsxs)(`div`,{className:`w-full max-w-[48rem] overflow-hidden rounded-lg border border-border bg-card shadow-sm`,"data-chat-message-wide-content":`true`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center justify-between gap-2 border-b border-border bg-muted/45 px-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium text-foreground`,children:[(0,R.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`truncate`,children:c})]}),t?(0,R.jsx)(En,{size:`md`,icon:(0,R.jsx)(Bi,{className:`h-3.5 w-3.5`}),label:d(`chatPanelCardExpand`),onClick:m}):null]}),(0,R.jsx)(`div`,{className:`relative h-[420px] min-h-[220px] max-h-[min(60vh,420px)] overflow-hidden bg-card`,children:(0,R.jsx)(`iframe`,{ref:r,src:u,title:c,sandbox:Yz,tabIndex:0,onPointerOver:()=>Xz(r.current),className:`h-full w-full border-0 bg-card`},p)})]}):(0,R.jsx)(`div`,{className:`h-[320px] min-h-[220px] w-full max-w-[48rem] animate-pulse rounded-lg border border-border bg-muted/45`,"data-chat-message-wide-content":`true`})}var LB=`inherited_from_session_id`,RB=new WeakMap;function zB(e){if(e.target.type===`panel_app`)return(0,R.jsx)(IB,{panelApp:{appId:e.target.payload.appId,title:e.title}})}function BB({checkpoint:e}){return(0,R.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-muted-foreground`,title:[`${d(`chatContextCompactionCoveredMessages`)}: ${e.coveredSessionMessageCount}`,`${d(`chatContextCompactionOriginalTokens`)}: ${e.originalEstimatedTokens}`,`${d(`chatContextCompactionProjectedTokens`)}: ${e.projectedEstimatedTokens}`].join(`
101
+ `),children:[(0,R.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-border bg-muted px-3 py-1`,children:[e.status===`compressing`?(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-muted-foreground`}):(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/45`}),(0,R.jsx)(`span`,{children:e.status===`compressing`?d(`chatContextCompactionCompressing`):d(`chatContextCompactionCompressed`)})]}),(0,R.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function VB({inheritance:e}){return(0,R.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-emerald-700`,title:[`${d(`chatContextInheritanceSourceSession`)}: ${e.sourceSessionId}`,`${d(`chatContextInheritanceMessages`)}: ${e.inheritedMessageCount}`].join(`
102
+ `),children:[(0,R.jsx)(`div`,{className:`h-px flex-1 bg-emerald-100`}),(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1`,children:[(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-400`}),(0,R.jsx)(`span`,{children:d(`chatContextInheritanceInherited`)})]}),(0,R.jsx)(`div`,{className:`h-px flex-1 bg-emerald-100`})]})}function HB(e){let{rawMessageId:t,rawMessages:n,visibleRawMessages:r}=e,i=n.findIndex(e=>e.id===t);return i<0?r.length-1:n.slice(0,i).filter(WB).length-1}function UB(e){let t=e.metadata?.[LB];return typeof t==`string`&&t.trim()?t.trim():null}function WB(e){return!vz(e)&&!UB(e)}function GB(e){let t=e.findIndex(e=>UB(e));if(t<0)return null;let n=UB(e[t]);return n?{boundaryIndex:e.slice(0,t).filter(WB).length,sourceSessionId:n,inheritedMessageCount:e.filter(e=>UB(e)===n).length}:null}function KB(e){let t=e.rawMessages.filter(WB),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:vz(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:HB({rawMessages:e.rawMessages,visibleRawMessages:t,rawMessageId:n.rawMessageId})})).sort((e,t)=>e.boundaryIndex-t.boundaryIndex),r=GB(e.rawMessages),i=[],a=[],o=0,s=e=>{a.length!==0&&(i.push({kind:`messages`,key:e,messages:a}),a=[])};for(t.forEach((t,c)=>{r?.boundaryIndex===c&&(s(`messages-before-context-inheritance`),i.push({kind:`context-inheritance`,key:`context-inheritance`,inheritance:r}));let l=e.messages[c];for(l&&a.push(l);o<n.length&&n[o]?.boundaryIndex<=c;){let e=n[o];s(`messages-before-${e.key}`),i.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),o+=1}}),r?.boundaryIndex===t.length&&(s(`messages-before-context-inheritance`),i.push({kind:`context-inheritance`,key:`context-inheritance`,inheritance:r}));o<n.length;){let e=n[o];s(`messages-before-${e.key}`),i.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),o+=1}return s(`messages-final`),i.length===0&&i.push({kind:`messages`,key:`messages-empty`,messages:[]}),i}function qB({messages:e,isSending:t,className:n}){let r=os(),{language:i}=pr(),a=(0,L.useMemo)(()=>dz(i),[i]),o=(0,L.useMemo)(()=>{let t=e.filter(WB),n=d(`chatProcessSummaryProcessed`);return t.flatMap(e=>{let t=uz({message:e,processedLabel:n}),r=t?.label??null,o=RB.get(e);if(o&&o.language===i&&o.processSummaryLabel===r)return[o.viewModel];let s=Ys(e),l=az({id:s.id,role:s.role,meta:{timestamp:s.meta?.timestamp,status:s.meta?.status,inlineTokens:cL(e.metadata),processSummary:t},parts:s.parts},{formatTimestamp:e=>c(e,i),texts:a});return RB.set(e,{language:i,processSummaryLabel:r,viewModel:l}),[l]})},[i,e,a]),s=(0,L.useMemo)(()=>o.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[o]),l=(0,L.useMemo)(()=>pz(i),[i]),u=(0,L.useMemo)(()=>KB({rawMessages:e,messages:o}),[o,e]),f=Gc(e=>e.snapshot.sessionSkillsQuery),p=(0,L.useCallback)(e=>{if(e.kind!==`skill`)return;let t=e.key.trim();if(!t)return;let n=(f?.data?.records??[]).find(e=>e.ref===t||e.name===t),i=n?.path?.trim();i&&r.chatThreadManager.openFilePreview({path:i,label:e.label||n?.name||t,viewMode:`preview`,previewViewer:`rendered`})},[r.chatThreadManager,f]),m=(0,L.useCallback)(e=>{let t=e.dataUrl?.trim();if(!t)return;let n=e.label.trim()||`attachment`;r.chatThreadManager.openFilePreview({path:n,label:n,viewMode:`preview`,contentUrl:t,mimeType:e.mimeType})},[r.chatThreadManager]);return(0,R.jsx)(`div`,{className:n,children:u.map((e,n)=>e.kind===`compaction`?(0,R.jsx)(BB,{checkpoint:e.checkpoint},e.key):e.kind===`context-inheritance`?(0,R.jsx)(VB,{inheritance:e.inheritance},e.key):(0,R.jsx)(VI,{messages:e.messages,isSending:n===u.length-1?t:!1,hasAssistantDraft:s,texts:l,onToolAction:r.chatThreadManager.handleToolAction,onFileOpen:r.chatThreadManager.openFilePreview,onAttachmentOpen:m,onInlineTokenClick:p,renderInlineDisplay:zB,renderToolAgent:e=>(0,R.jsx)(Ql,{agentId:e,className:`h-4 w-4 shrink-0`}),renderPanelAppCard:e=>(0,R.jsx)(IB,{panelApp:e})},e.key))})}function JB({bottomSlot:e,isAwaitingAssistantOutput:t,isHistoryLoading:n,isSending:r,messages:i,sessionKey:a,showWelcome:o,welcomeSlot:s}){let c=(0,L.useRef)(null),l=n&&i.length===0&&!r&&!t,{isAtBottom:u,onScroll:f,scrollToBottom:p}=MP({scrollRef:c,resetKey:a,isLoading:n,hasContent:i.length>0,contentVersion:i[i.length-1]??null}),m=i.length>0,h=m&&!o&&!u;return(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{ref:c,onScroll:f,"data-chat-scroll-container":`true`,className:`h-full overflow-y-auto custom-scrollbar`,children:o?s??null:(0,R.jsxs)(R.Fragment,{children:[l||!m?null:(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,R.jsx)(qB,{messages:i,isSending:m&&r&&t})}),e?(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 pb-4 sm:px-6 sm:pb-5`,children:e}):null]})}),h?(0,R.jsx)(En,{icon:(0,R.jsx)(qr,{className:`h-4 w-4`}),label:d(`chatScrollToBottom`),onClick:p,tooltipSide:`top`,className:`absolute bottom-4 left-1/2 z-10 h-9 w-9 -translate-x-1/2 rounded-full border border-border bg-background/90 text-foreground shadow-lg backdrop-blur hover:bg-accent hover:text-accent-foreground`}):null]})}var YB=function(e){return e.EndpointReady=`endpoint.ready`,e.EndpointError=`endpoint.error`,e.MessageRequest=`message.request`,e.MessageStreamRequest=`message.stream-request`,e.MessageSent=`message.sent`,e.MessageAccepted=`message.accepted`,e.MessageIncoming=`message.incoming`,e.MessageCompleted=`message.completed`,e.MessageFailed=`message.failed`,e.MessageAbort=`message.abort`,e.MessageTextStart=`message.text-start`,e.MessageTextDelta=`message.text-delta`,e.MessageTextEnd=`message.text-end`,e.MessageReasoningStart=`message.reasoning-start`,e.MessageReasoningDelta=`message.reasoning-delta`,e.MessageReasoningEnd=`message.reasoning-end`,e.MessageToolCallStart=`message.tool-call-start`,e.MessageToolCallArgs=`message.tool-call-args`,e.MessageToolCallArgsDelta=`message.tool-call-args-delta`,e.MessageToolCallEnd=`message.tool-call-end`,e.MessageToolCallResult=`message.tool-call-result`,e.MessageRead=`message.read`,e.MessageDelivered=`message.delivered`,e.MessageRecalled=`message.recalled`,e.MessageReaction=`message.reaction`,e.RunStarted=`run.started`,e.RunFinished=`run.finished`,e.RunError=`run.error`,e.RunMetadata=`run.metadata`,e.ContextWindowUpdated=`context-window.updated`,e.TypingStart=`typing.start`,e.TypingEnd=`typing.end`,e.PresenceUpdated=`presence.updated`,e}({});function XB(e,t=e.occurredAt??new Date().toISOString()){return{...e,occurredAt:t}}var ZB=/\[\[\s*reply_to_current\s*\]\]/gi,QB=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function $B(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function eV(e,t){let n=e,r;ZB.test(n)&&(r=$B(t),n=n.replace(ZB,``).trim());let i=n.match(QB)?.[1];return i&&(r=$B(i),n=n.replace(QB,``).trim()),r?{content:n,replyTo:r}:{content:n}}function tV(e,t=e.id){if(e.role!==`assistant`)return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};let n=e.parts.findIndex(e=>e.type===`text`),r=e.metadata?{...e.metadata}:void 0,i=$B(r?.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};let a=e.parts[n];if(!a||a.type!==`text`)return{...e,parts:[...e.parts],metadata:r};let{content:o,replyTo:s}=eV(a.text,t),c=s??i,l=e.parts.flatMap((e,t)=>t!==n||e.type!==`text`?[e]:o.length===0?[]:[{...e,text:o}]);return c?{...e,parts:l,metadata:{...r,reply_to:c}}:{...e,parts:l,metadata:r}}function nV(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
103
+ `)}}async function*rV(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=iV(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=iV(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function iV(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=nV(e);t&&i.push(t)}if(t&&r.trim()){let e=nV(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var aV=`/ncp/agent`,oV=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function sV(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function cV(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function lV(e){let t=(e??`/ncp/agent`).trim();if(!t)return aV;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function uV(e){try{return(await e.text()).trim()}catch{return``}}function dV(e){if(hV(e))return e.ncpError;if(pV(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:_V(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function fV(e,t={}){return new oV(e,t.alreadyPublished??!1)}function pV(e){return mV(e)&&typeof e.code==`string`&&typeof e.message==`string`}function mV(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function hV(e){return e instanceof oV}var gV={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function _V(e){if(!e)return`runtime-error`;let t=gV[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function vV(e){let t=bV(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function yV(e){let t=bV(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=_V(n),i=mV(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function bV(e){try{let t=JSON.parse(e);return mV(t)?t:null}catch{return null}}var xV=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],SV=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=sV(e.baseUrl),this.basePath=lV(e.basePath),this.fetchImpl=cV(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:xV,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish(XB({type:YB.EndpointReady})))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await uV(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(hV(e))throw e;let n=dV(e);throw this.publish(XB({type:YB.EndpointError,payload:n})),fV(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await uV(n)}`)}catch(e){if(t.signal.aborted)return;let n=dV(e);throw this.publish(XB({type:YB.EndpointError,payload:n})),fV(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await uV(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of rV(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(hV(e))throw e;let n=dV(e);throw this.publish(XB({type:YB.EndpointError,payload:n})),fV(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=vV(e.data);if(!t){this.publish(XB({type:YB.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}}));return}this.publish(t);return}if(e.event===`error`){let t=yV(e.data);throw this.publish(XB({type:YB.EndpointError,payload:t})),fV(t,{alreadyPublished:!0})}}};function CV(e){return{...e,parts:[...e.parts],lifecycle:e.lifecycle?{...e.lifecycle}:void 0,metadata:e.metadata?{...e.metadata}:void 0}}function wV(e){return CV(tV(e))}var TV=`__nextclaw_aborted_tool_call__`;function EV(e){let t=e.error?.trim();return{code:`runtime-error`,message:t&&t.length>0?t:`Agent run failed.`,details:{sessionId:e.sessionId,messageId:e.messageId,threadId:e.threadId,runId:e.runId}}}function DV(e){if(!(!e.startedAt&&!e.endedAt))return{startedAt:e.startedAt,endedAt:e.endedAt}}function OV(e,t,n){return n?{...e,status:t,lifecycle:n}:{...e,status:t}}function kV(e,t){let n=Date.parse(t.timestamp);if(!Number.isFinite(n))return e.length;let r=e.findIndex(e=>{let t=Date.parse(e.timestamp);return Number.isFinite(t)&&t>n});return r<0?e.length:r}function AV(e,t){let n=[...e];return n.splice(kV(e,t),0,t),n}function jV(e,t){return t.trim()?e.id.startsWith(`tool-`)?!0:e.parts.some(e=>e.type===`tool-invocation`):!1}function MV(e,t,n){for(let[r,i]of e)i===t&&e.set(r,n)}function NV(e,t,n){for(let[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function PV(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`tool-invocation`&&r.toolCallId===t)return r}return null}function FV(e,t){return PV(e,t)?.toolName??null}function IV(e,t){let n=[...e];for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.type===`tool-invocation`&&r.toolCallId===t.toolCallId)return n[e]={...r,...t},n}return n.push(t),n}function LV(e){let t=[];return{parts:e.map(e=>e.type!==`tool-invocation`||!e.toolCallId||e.state===`result`||e.state===`cancelled`?e:(t.push(e.toolCallId),{...e,state:`cancelled`})),toolCallIds:t}}var RV=class{messageIdByCallId=new Map;argsRawByCallId=new Map;constructor(e){this.port=e}isEmpty=()=>this.messageIdByCallId.size===0&&this.argsRawByCallId.size===0;clear=()=>{this.messageIdByCallId.clear(),this.argsRawByCallId.clear()};clearByMessageId=e=>{NV(this.messageIdByCallId,this.argsRawByCallId,e)};markAborted=e=>{e.forEach(e=>this.argsRawByCallId.set(e,TV))};remapMessageId=(e,t)=>{MV(this.messageIdByCallId,e,t)};handleToolCallStart=e=>{if(this.argsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.argsRawByCallId.set(e.toolCallId,``),this.port.replaceStreamingMessage({...t,parts:IV(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:e.toolName,state:`partial-call`,args:``}),status:`streaming`})};handleToolCallArgs=e=>{this.argsRawByCallId.get(e.toolCallId)!==`__nextclaw_aborted_tool_call__`&&(this.argsRawByCallId.set(e.toolCallId,e.args),this.applyToolCallArgs(e.sessionId,e.toolCallId,e.args))};handleToolCallArgsDelta=e=>{if(this.argsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=`${this.argsRawByCallId.get(e.toolCallId)??``}${e.delta}`;this.argsRawByCallId.set(e.toolCallId,t),this.applyToolCallArgs(e.sessionId,e.toolCallId,t,e.messageId)};handleToolCallEnd=e=>{if(this.argsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.argsRawByCallId.get(e.toolCallId)??``;this.port.replaceStreamingMessage({...t,parts:IV(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:FV(t.parts,e.toolCallId)??`unknown`,state:`call`,args:n}),status:`streaming`})};handleToolCallResult=e=>{if(this.argsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`||this.port.updateMessageContainingToolCall(e.toolCallId,(t,n)=>IV(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:n.toolName,state:`result`,args:n.args,result:e.content,resultContentItems:e.contentItems})))return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId);this.port.replaceStreamingMessage({...t,parts:IV(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:`unknown`,state:`result`,result:e.content,resultContentItems:e.contentItems}),status:`streaming`})};applyToolCallArgs=(e,t,n,r)=>{let i=this.resolveToolCallTargetMessage(e,t,r),a=FV(i.parts,t)??`unknown`;this.port.replaceStreamingMessage({...i,parts:IV(i.parts,{type:`tool-invocation`,toolCallId:t,toolName:a,state:`partial-call`,args:n}),status:`streaming`})};resolveToolCallTargetMessage=(e,t,n)=>{let r=n?.trim()||this.messageIdByCallId.get(t)||this.port.readStreamingMessageId()||`tool-${t}`;return this.messageIdByCallId.set(t,r),this.port.ensureStreamingMessage(e,r,`streaming`)}},zV=`assistant`,BV=class{messages=[];streamingMessage=null;error=null;activeRun=null;contextWindow=null;listeners=new Set;toolCalls;lastSettledRunId=null;snapshotCache=null;snapshotVersion=-1;stateVersion=0;constructor(){this.toolCalls=new RV({ensureStreamingMessage:this.ensureStreamingMessage,readStreamingMessageId:()=>this.streamingMessage?.id??null,replaceStreamingMessage:this.replaceStreamingMessage,updateMessageContainingToolCall:this.updateMessageContainingToolCall})}getSnapshot=()=>{if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;let e={messages:this.messages,streamingMessage:this.streamingMessage,error:this.error?{...this.error,details:this.error.details?{...this.error.details}:void 0}:null,activeRun:this.activeRun?{...this.activeRun}:null,contextWindow:this.contextWindow?{...this.contextWindow}:null};return this.snapshotCache=e,this.snapshotVersion=this.stateVersion,e};subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));reset=()=>{this.messages.length===0&&!this.streamingMessage&&!this.error&&!this.activeRun&&!this.contextWindow&&this.toolCalls.isEmpty()||(this.messages=[],this.streamingMessage=null,this.error=null,this.activeRun=null,this.contextWindow=null,this.toolCalls.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners())};hydrate=e=>{this.messages=e.messages.map(e=>wV(e)),this.streamingMessage=null,this.error=null,this.contextWindow=e.contextWindow?{...e.contextWindow}:null,this.activeRun=e.activeRun?{...e.activeRun,sessionId:e.activeRun.sessionId??e.sessionId,abortDisabledReason:e.activeRun.abortDisabledReason??null}:null,this.toolCalls.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners()};dispatch=e=>this.dispatchBatch([e]);dispatchBatch=async e=>{if(!e.length)return;let t=this.stateVersion;e.forEach(this.applyEvent),this.stateVersion!==t&&this.notifyListeners()};applyEvent=e=>{switch(e.type){case YB.MessageSent:this.handleMessageSent(e.payload);break;case YB.MessageAbort:this.handleMessageAbort(e.payload);break;case YB.MessageTextStart:this.handleMessageTextStart(e.payload);break;case YB.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case YB.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case YB.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case YB.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case YB.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case YB.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case YB.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case YB.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case YB.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case YB.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case YB.RunStarted:this.handleRunStarted(e.payload);break;case YB.RunFinished:this.handleRunFinished(e.payload);break;case YB.RunError:this.handleRunError(e.payload);break;case YB.RunMetadata:this.handleRunMetadata(e.payload);break;case YB.ContextWindowUpdated:this.handleContextWindowUpdated(e.payload);break;case YB.EndpointError:this.handleEndpointError(e.payload);break;default:break}};handleMessageSent=e=>{this.upsertMessage(e.message),this.setError(null)};handleMessageAbort=e=>{let t=e.messageId?.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){let e=this.streamingMessage.id,{parts:n,toolCallIds:r}=LV(this.streamingMessage.parts);this.upsertMessage({...this.streamingMessage,status:`final`,parts:n}),this.replaceStreamingMessage(null),t?this.toolCalls.clearByMessageId(t):this.toolCalls.clearByMessageId(e),this.toolCalls.markAborted(r)}};handleMessageTextStart=e=>{let t=this.streamingMessage?.id===e.messageId,n=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),r=n.parts[n.parts.length-1];t&&r?.type===`text`&&r.text.length>0&&this.replaceStreamingMessage({...n,parts:[...n.parts,{type:`text`,text:``}],status:`streaming`}),this.setError(null)};handleMessageTextDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`text`?n[n.length-1]={type:`text`,text:`${r.text}${e.delta}`}:n.push({type:`text`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageTextEnd=e=>{this.streamingMessage?.id===e.messageId&&this.streamingMessage.status===`streaming`&&this.replaceStreamingMessage({...this.streamingMessage,status:`pending`})};handleMessageReasoningStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`)};handleMessageReasoningDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`reasoning`?n[n.length-1]={type:`reasoning`,text:`${r.text}${e.delta}`}:n.push({type:`reasoning`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageReasoningEnd=e=>{this.streamingMessage?.id,e.messageId};handleMessageToolCallStart=e=>{this.toolCalls.handleToolCallStart(e),this.setError(null)};handleMessageToolCallArgs=e=>{this.toolCalls.handleToolCallArgs(e)};handleMessageToolCallArgsDelta=e=>{this.toolCalls.handleToolCallArgsDelta(e)};handleMessageToolCallEnd=e=>{this.toolCalls.handleToolCallEnd(e)};handleMessageToolCallResult=e=>{this.toolCalls.handleToolCallResult(e)};handleRunStarted=e=>{this.isSettledRunId(e.runId)||(this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1)};handleRunFinished=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`final`,DV(e)),this.setError(null),this.clearActiveRun()};handleRunError=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`error`,DV(e)),this.setError(EV(e)),this.clearActiveRun()};handleRunMetadata=e=>{let t=e.metadata;if(t?.kind===`ready`){let e=t;if(this.isSettledRunId(e.runId))return;this.activeRun={runId:e.runId??this.activeRun?.runId??null,sessionId:e.sessionId??this.activeRun?.sessionId,abortDisabledReason:e.supportsAbort===!1?e.abortDisabledReason??`Unsupported`:null},this.stateVersion+=1}else t?.kind===`final`&&(this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.clearActiveRun())};handleContextWindowUpdated=e=>{this.contextWindow={...e.contextWindow},this.stateVersion+=1};handleEndpointError=e=>{if(e.code===`abort-error`){this.handleMessageAbort({sessionId:this.activeRun?.sessionId??this.streamingMessage?.sessionId??``,...this.streamingMessage?.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage(`error`),this.clearActiveRun(),this.setError(e)};ensureStreamingMessage=(e,t,n)=>{if(this.streamingMessage?.id===t){if(this.streamingMessage.status===n)return this.streamingMessage;let e={...this.streamingMessage,status:n};return this.replaceStreamingMessage(e),e}let r=this.messages.findIndex(e=>e.id===t);if(r>=0){let t=CV(this.messages[r]),i=[...this.messages];i.splice(r,1),this.messages=i,this.stateVersion+=1;let a={...t,sessionId:e,status:n};return this.replaceStreamingMessage(a),a}let i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&jV(i,t)){let r={...i,id:t,sessionId:e,status:n};return this.toolCalls.remapMessageId(i.id,t),this.replaceStreamingMessage(r),r}let a={id:t,sessionId:e,role:zV,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(a),a};updateMessageContainingToolCall=(e,t)=>{if(this.streamingMessage){let n=PV(this.streamingMessage.parts,e);if(n){let e=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:e}),!0}}for(let n=this.messages.length-1;n>=0;--n){let r=this.messages[n],i=PV(r.parts,e);if(!i)continue;let a=[...this.messages];return a[n]={...r,parts:t(r,i)},this.messages=a,this.stateVersion+=1,!0}return!1};upsertMessage=e=>{let t=wV(e);this.streamingMessage?.id===t.id&&(this.streamingMessage=null);let n=this.messages.findIndex(e=>e.id===t.id);if(n<0){this.messages=AV(this.messages,t),this.stateVersion+=1;return}let r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1};replaceStreamingMessage=e=>{!e&&!this.streamingMessage||(this.streamingMessage=e?wV(e):null,this.stateVersion+=1)};setError=e=>{this.error?.code===e?.code&&this.error?.message===e?.message&&this.error?.details===e?.details&&this.error?.cause===e?.cause||(this.error=e?{...e,details:e.details?{...e.details}:void 0}:null,this.stateVersion+=1)};clearActiveRun=()=>{this.activeRun&&(this.activeRun=null,this.stateVersion+=1)};isSettledRunId=e=>!!e?.trim()&&e===this.lastSettledRunId;markRunAsSettled=e=>{this.lastSettledRunId=e?.trim()||null};settleStreamingMessage=(e,t)=>{if(!this.streamingMessage)return;let n=OV(this.streamingMessage,e,t);this.upsertMessage(n),this.replaceStreamingMessage(null),this.toolCalls.clearByMessageId(n.id)};notifyListeners=()=>{let e=this.getSnapshot();for(let t of this.listeners)t(e)}},VV=16,HV={code:`abort-error`,message:`User stopped the current run.`,details:{source:`chat-ui`}},UV=class{constructor(e){this.dispatchBatch=e,this.queue=[],this.flushTimerId=null,this.isFlushing=!1,this.isDisposed=!1,this.enqueue=e=>{this.isDisposed||(this.queue.push(e),this.scheduleFlush())},this.dispose=()=>{this.isDisposed=!0,this.flushTimerId!==null&&(window.clearTimeout(this.flushTimerId),this.flushTimerId=null),this.queue.length=0},this.scheduleFlush=()=>{this.flushTimerId!==null||this.isFlushing||this.queue.length===0||(this.flushTimerId=window.setTimeout(()=>{this.flushTimerId=null,this.flush()},VV))},this.flush=async()=>{if(!(this.isDisposed||this.isFlushing||this.queue.length===0)){this.isFlushing=!0;try{for(;this.queue.length>0;){let e=this.queue.splice(0);await this.dispatchBatch(e)}}finally{this.isFlushing=!1,this.scheduleFlush()}}}}};function WV(e,t){let n=e.dispatchBatch;return typeof n==`function`?n.call(e,t):t.reduce((t,n)=>t.then(()=>e.dispatch(n)),Promise.resolve())}function GV(e,t){if(!t)return!0;let n=`payload`in e?e.payload:null;return!n||typeof n!=`object`||!(`sessionId`in n)||typeof n.sessionId!=`string`?!0:n.sessionId===t}function KV(e){return e.parts.some(e=>e.type===`text`||e.type===`rich-text`||e.type===`reasoning`?e.text.trim().length>0:!0)}function qV(e,t){if(typeof e==`string`){let n=e.trim();return n?{...t?{sessionId:t}:{},message:{id:`user-${Date.now().toString(36)}`,...t?{sessionId:t}:{},role:`user`,status:`final`,parts:[{type:`text`,text:n}],timestamp:new Date().toISOString()}}:null}if(!KV(e.message))return null;let n=e.sessionId||e.message.sessionId||t;return{...e,...n?{sessionId:n}:{},message:{...e.message,...n?{sessionId:n}:{}}}}function JV(e){let t=(0,L.useRef)();return t.current?e&&t.current.sessionId===null?t.current.sessionId=e:t.current.sessionId!==(e??null)&&(t.current={sessionId:e??null,manager:new BV}):t.current={sessionId:e??null,manager:new BV},t.current.manager}function YV({sessionId:e,client:t,manager:n}){let r=(0,L.useRef)(e),i=(0,L.useSyncExternalStore)(e=>n.subscribe(()=>e()),()=>n.getSnapshot(),()=>n.getSnapshot()),[a,o]=(0,L.useState)(!1);(0,L.useEffect)(()=>{r.current=e},[e]),(0,L.useEffect)(()=>{o(!1)},[e]),(0,L.useEffect)(()=>{let e=new UV(e=>WV(n,e)),i=t.subscribe(t=>{GV(t,r.current)&&e.enqueue(t)});return()=>{i(),e.dispose(),t.stop()}},[t,n]);let s=i.streamingMessage?[...i.messages,i.streamingMessage]:i.messages,c=i.activeRun?.runId??null,l=!!i.activeRun;return{snapshot:i,visibleMessages:s,activeRunId:c,isRunning:l,isSending:a,send:async r=>{if(a||l)return null;let i=qV(r,e);if(!i)return null;o(!0),e&&await n.dispatch({occurredAt:new Date().toISOString(),type:YB.MessageSent,payload:{sessionId:e,message:{...i.message,sessionId:e},metadata:i.metadata}});try{return await t.send(i)}finally{o(!1)}},abort:async()=>{e&&await t.abort({sessionId:e,runId:c??void 0,reason:HV})},streamRun:async()=>{e&&(await t.stop(),await t.stream({sessionId:e}))}}}function XV(e){return e instanceof Error?e:Error(String(e))}function ZV(e){let{hydratedSessionId:t,isHydrating:n,sessionId:r}=e;return r?n||t!==r:!1}function QV(e,t){let n=e.getSnapshot();return n.activeRun?.sessionId===t||n.streamingMessage?.sessionId===t||n.messages.some(e=>e.sessionId===t)}function $V(e,t){return e.status===`running`?{runId:null,sessionId:t,abortDisabledReason:null}:null}function eH(e,t,n){return n.signal.aborted||e.requestId!==t}function tH({sessionId:e,client:t,loadSeed:n}){let r=JV(e),i=YV({sessionId:e,client:t,manager:r}),[a,o]=(0,L.useState)(!0),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(null),d=(0,L.useRef)({requestId:0,controller:null}),f=(0,L.useCallback)(async()=>{await t.stop(),r.reset(),c(null),u(null),o(!1),d.current={requestId:d.current.requestId+1,controller:null}},[t,r]),p=(0,L.useCallback)(e=>{c(null),u(e),o(!1)},[]),m=(0,L.useCallback)(async()=>{if(d.current.controller?.abort(),!e){await f();return}let i=new AbortController,a=d.current.requestId+1;if(d.current={requestId:a,controller:i},QV(r,e)){p(e),d.current.controller===i&&(d.current.controller=null);return}await t.stop(),r.reset(),c(null),o(!0);try{let o=await n(e,i.signal);if(eH(d.current,a,i))return;r.hydrate({sessionId:e,messages:o.messages,activeRun:$V(o,e)}),p(e),t.stream({sessionId:e}).catch(e=>{d.current.requestId===a&&c(XV(e))})}catch(t){if(eH(d.current,a,i))return;c(XV(t)),u(e),o(!1)}finally{d.current.controller===i&&(d.current.controller=null)}},[t,n,r,p,f,e]);return(0,L.useEffect)(()=>(m(),()=>{d.current.controller?.abort(),d.current.controller=null}),[m]),{...i,isHydrating:ZV({sessionId:e,hydratedSessionId:l,isHydrating:a}),hydrateError:s}}var nH=200*1024*1024,rH=`application/octet-stream`;function iH(e){let t=e.type.trim().toLowerCase();return t.length>0?t:rH}function aH(e,t){let n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(e=>e.trim().toLowerCase())):null,r=t.maxBytes??209715200,i=iH(e);return n&&!n.has(i)?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`unsupported-type`}}:e.size>r?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`too-large`}}:{ok:!0,mimeType:i}}function oH(e){let t=e.parts&&e.parts.length>0?e.parts.map(e=>structuredClone(e)):[...e.text?.trim()??``?[{type:`text`,text:e.text.trim()}]:[],...(e.attachments??[]).map(e=>({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?.trim()?{assetUri:e.assetUri.trim()}:{},...e.url?.trim()?{url:e.url.trim()}:{},...e.contentBase64?.trim()?{contentBase64:e.contentBase64.trim()}:{},sizeBytes:e.sizeBytes}))];if(t.length===0)return null;let n=e.timestamp??new Date().toISOString(),r=e.messageId??`user-${Date.now().toString(36)}`;return{...e.sessionId?{sessionId:e.sessionId}:{},message:{id:r,...e.sessionId?{sessionId:e.sessionId}:{},role:`user`,status:`final`,parts:t,timestamp:n,...e.metadata?{metadata:e.metadata}:{}},...e.metadata?{metadata:e.metadata}:{}}}async function sH(e,t){let n=[],r=[];for(let i of e){let e=aH(i,t);if(!e.ok){r.push(e.rejected);continue}n.push(i)}if(n.length===0)return{attachments:[],rejected:r};try{return{attachments:await t.uploadBatch(n),rejected:r}}catch{return r.push(...n.map(e=>({fileName:e.name,mimeType:iH(e),sizeBytes:e.size,reason:`read-failed`}))),{attachments:[],rejected:r}}}function cH(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function lH(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function uH(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function dH(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw wt.reportTransportFailure(lH(n)),uH(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${cH(e)}: ${lH(n)}`,n)}}}var fH=300,pH=`ncp agent unavailable during startup`;function mH(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function hH(e){return e?.trim().toLowerCase().includes(pH)??!1}function gH(){return new SV({baseUrl:he,basePath:`/api/ncp/agent`,fetchImpl:dH()})}async function _H(e,t,n=fH){t.throwIfAborted();try{let r=await Dt(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!mH(e))throw e;return{messages:[],status:`idle`}}}function vH(e,t){let n=(0,L.useRef)(null),r=(0,L.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,L.useEffect)(()=>{r(e)},[e,r])}function yH(e,t={}){let[n]=(0,L.useState)(()=>gH()),r=Pe(),[i,a]=(0,L.useState)(0),[o,s]=(0,L.useState)(null),c=t.messageLimit??fH;(0,L.useEffect)(()=>{s(null)},[e]);let l=tH({sessionId:e,client:n,loadSeed:(0,L.useCallback)(async(e,t)=>{let n=await _H(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return vH(e&&r.phase===`ready`&&hH(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,L.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}function bH(e){return e.bootstrapStatus?.ncpAgent.state!==`ready`}function xH(e){return e.activeSystemAction?.message?.trim()||(e.lifecyclePhase===`cold-starting`?d(`chatRuntimeInitializing`):e.lifecyclePhase===`startup-failed`?e.bootstrapStatus?.ncpAgent.error?.trim()||e.bootstrapStatus?.lastError?.trim()||e.lastError?.trim()||d(`chatRuntimeInitializationFailed`):null)}function SH(e){let{message:t,status:n}=e,r=t?.trim();if(!r)return xH(n);let i=n.activeSystemAction?.message?.trim();if(n.phase===`service-transitioning`&&i)return i;let a=pt(r);return n.phase===`recovering`&&a?d(`runtimeControlRecoveringHelp`):n.phase===`stalled`&&a?null:r}function CH(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function wH(e){if(!e||e.totalContextTokens<=0)return null;let t=e.usedContextTokens/e.totalContextTokens,n=Math.max(0,Math.min(1,t)),r=`${Math.round(n*100)}%`,i=n>=.9?`danger`:n>=.75?`warning`:`neutral`,a=[{label:d(`chatContextWindowUsed`),value:CH(e.usedContextTokens)},{label:d(`chatContextWindowTotal`),value:CH(e.totalContextTokens)},{label:d(`chatContextWindowAvailable`),value:CH(e.availableContextTokens)}];return e.prunedUsedContextTokens!==e.usedContextTokens&&a.push({label:d(`chatContextWindowPruned`),value:CH(e.prunedUsedContextTokens)}),e.droppedHistoryCount>0&&a.push({label:d(`chatContextWindowDroppedHistory`),value:String(e.droppedHistoryCount)}),e.truncatedToolResultCount>0&&a.push({label:d(`chatContextWindowTruncatedTools`),value:String(e.truncatedToolResultCount)}),{label:d(`chatContextWindow`),percentLabel:r,ratio:n,tone:i,details:a}}var TH=tr(`18rem`);function EH({agents:e,selectedAgent:t,selectedAgentId:n,onSelectAgent:r}){return(0,R.jsxs)(ar,{value:n,onValueChange:r,children:[(0,R.jsxs)(Zn,{"aria-label":d(`chatDraftAgentTitle`),className:`h-auto w-auto min-w-0 gap-1 rounded-lg border-0 bg-transparent px-2 py-1.5 text-muted-foreground shadow-none hover:bg-accent hover:text-accent-foreground focus:ring-0`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:d(`chatDraftAgentTitle`)}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Kl,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,R.jsx)(`span`,{className:`max-w-28 truncate text-sm font-medium`,children:t.displayName?.trim()||t.id})]}):null})]}),(0,R.jsx)(er,{className:`rounded-xl border-border shadow-lg`,style:{maxHeight:TH},children:e.map(e=>(0,R.jsx)(rr,{value:e.id,className:`rounded-lg pr-10`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(Kl,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.displayName?.trim()||e.id})]})},e.id))})]})}var DH=[{icon:Vi,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`,promptKey:`chatWelcomeCapability1Prompt`},{icon:k,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`,promptKey:`chatWelcomeCapability2Prompt`},{icon:Kr,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`,promptKey:`chatWelcomeCapability3Prompt`}];function OH({onSelectPrompt:e}){return(0,R.jsx)(`div`,{className:`mt-8 grid grid-cols-[repeat(auto-fit,minmax(min(100%,9.5rem),1fr))] gap-3`,children:DH.map(t=>{let n=t.icon;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>e(d(t.promptKey)),className:p(`min-w-0 rounded-xl border border-border/75 bg-card p-3 text-left text-card-foreground shadow-none transition-colors sm:p-3.5`,`hover:bg-muted/40`),children:[(0,R.jsx)(`div`,{className:`mb-2.5 flex h-8 w-8 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,R.jsx)(n,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`mb-1 text-sm font-medium text-foreground`,children:d(t.titleKey)}),(0,R.jsx)(`div`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:d(t.descKey)})]},t.titleKey)})})}var kH=Lo(`20rem`);function AH({defaultProjectRoot:e,isSaving:t,projectOptions:n,projectRoot:r,selectable:i,onOpenProjectDialog:a,onSelectProjectRoot:o}){let[s,c]=(0,L.useState)(!1),l=vs(r)??d(`chatWelcomeProjectPickerPlaceholder`),u=e!=null&&r===e,f=async e=>{c(!1),await o(e)};return(0,R.jsxs)(zo,{open:s,onOpenChange:c,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-left font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,title:r??void 0,"aria-label":d(`chatWelcomeProjectPickerLabel`),disabled:!i||t,children:[(0,R.jsx)(Ei,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:l}),u?(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground/70`,children:d(`chatWelcomeProjectDefaultBadge`)}):null,(0,R.jsx)(Vn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`})]})}),(0,R.jsxs)(Ho,{align:`start`,className:`flex w-[min(20rem,calc(100vw-1rem))] flex-col overflow-hidden rounded-2xl border border-border bg-popover p-0 text-popover-foreground shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,style:{maxHeight:kH},children:[(0,R.jsx)(`div`,{className:`shrink-0 px-3 pb-2 pt-3 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:d(`chatWelcomeProjectRecentTitle`)}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1.5 pb-1.5`,children:n.length>0?n.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-start gap-2 rounded-xl px-2 py-2 text-left transition-colors hover:bg-accent`,title:e.projectRoot,onClick:()=>{f(e.projectRoot)},children:[(0,R.jsx)(Ei,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground/70`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,R.jsx)(`span`,{className:`truncate text-[13px] font-semibold text-foreground`,children:e.projectName})}),(0,R.jsx)(`span`,{className:`block truncate text-[11px] leading-4 text-muted-foreground`,children:e.projectRoot})]}),e.sessionCount>0?(0,R.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:e.sessionCount}):null]},e.projectRoot)):(0,R.jsx)(`div`,{className:`px-2 py-5 text-center text-xs text-muted-foreground`,children:d(`chatWelcomeProjectNoRecent`)})}),(0,R.jsx)(`div`,{className:`shrink-0 border-t border-border p-1.5`,children:(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] font-semibold text-foreground transition-colors hover:bg-accent`,onClick:()=>{c(!1),a()},children:[(0,R.jsx)(Ei,{className:`h-4 w-4 shrink-0 text-muted-foreground/70`}),(0,R.jsx)(`span`,{children:d(`chatWelcomeProjectOpenFolder`)})]})})]})]})}function jH(e){let{disabled:t=!1,option:n,onSelect:r,selected:i=!1}=e,a=n.ready===!1?n.reasonMessage?.trim()||d(`statusSetup`):null;return(0,R.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:t,onClick:r,className:p(`w-full rounded-2xl px-3 py-2.5 text-left transition-colors`,i?`bg-gray-50`:`hover:bg-gray-50`,t?`cursor-not-allowed opacity-70`:null),children:(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[n.icon?.src?(0,R.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,R.jsx)(Ac,{icon:{kind:`runtime-image`,src:n.icon.src,alt:n.icon.alt??null,name:n.label}})}):(0,R.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,R.jsx)(Xr,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:n.label}),(0,R.jsx)(Ca,{status:n.ready===!1?`warning`:`ready`,label:n.ready===!1?d(`statusSetup`):d(`statusReady`),className:`bg-transparent px-0`})]}),a?(0,R.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:a}):null]})]}),i?(0,R.jsx)(cr,{className:`mt-1 h-3.5 w-3.5 shrink-0 text-primary`}):null]})})}var MH=Lo(`18rem`);function NH({options:e,selectedSessionType:t,onSelectSessionType:n}){let[r,i]=(0,L.useState)(!1),a=e.find(e=>e.value===t)??e[0]??null;return a?(0,R.jsxs)(zo,{open:r,onOpenChange:i,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-left font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,"aria-label":d(`chatWelcomeSessionTypePickerLabel`),children:[a.icon?.src?(0,R.jsx)(Ac,{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},className:`h-4 w-4`}):(0,R.jsx)(Xr,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:a.label}),(0,R.jsx)(Vn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`})]})}),(0,R.jsx)(Ho,{align:`start`,className:`flex w-[min(16rem,calc(100vw-1rem))] flex-col overflow-hidden rounded-2xl border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,style:{maxHeight:MH},children:(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.map(e=>(0,R.jsx)(jH,{option:e,onSelect:()=>{n(e.value),i(!1)}},e.value))})})]}):null}function PH({agents:e,defaultProjectRoot:t,inputSlot:n,projectOptions:r,selectedAgentId:i,selectedProjectRoot:a,selectedSessionType:o,sessionTypeOptions:s,onSelectAgent:c,onSelectPrompt:l,onSelectProjectRoot:u,onSelectSessionType:f}){let p=e.find(e=>e.id===i)??null,[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(!1),v=a??t??null,y=async e=>{if(u){_(!0);try{await u(e),h(!1)}finally{_(!1)}}},b=!!u;return(0,R.jsxs)(`div`,{className:`flex min-h-full items-center justify-center px-4 py-8 sm:p-8`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 w-full max-w-[min(760px,100%)]`,children:[(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground sm:text-3xl`,children:d(`chatWelcomeTitle`)}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-muted-foreground sm:text-base`,children:d(`chatWelcomeSubtitle`)})]}),n?(0,R.jsx)(`div`,{className:`mt-8`,children:n}):null,(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 px-1 text-sm text-muted-foreground`,children:[u?(0,R.jsx)(AH,{defaultProjectRoot:t,isSaving:g,projectOptions:r,projectRoot:v,selectable:b,onOpenProjectDialog:()=>h(!0),onSelectProjectRoot:y}):null,(0,R.jsx)(EH,{agents:e,selectedAgent:p,selectedAgentId:i,onSelectAgent:c}),(0,R.jsx)(NH,{options:s,selectedSessionType:o,onSelectSessionType:f})]}),(0,R.jsx)(OH,{onSelectPrompt:l})]}),u?(0,R.jsx)($o,{open:m,currentProjectRoot:v,isSaving:g,onOpenChange:h,onSave:y}):null]})}function FH(e){let{agents:t,fallbackAgentId:n}=e;return(t?.length??0)>0?t??[]:[{id:n}]}function IH(e){return e.agents.find(t=>t.id===e.agentId)??null}function LH(e,t){if(typeof e!=`string`||e.trim().length===0)return null;let n=Vc(e);return t.some(e=>e.value===n)?n:null}function RH(e){let{agentId:t,agents:n,defaultSessionType:r,pendingSessionType:i,selectedSessionType:a,sessionTypeOptions:o}=e;return(LH(a,o)??LH(i,o))||((n&&t?LH(Hc(IH({agents:n,agentId:t}),r),o):null)??LH(r,o)??o[0]?.value??Vc(r))}function zH(e){return new Date(e.lastMessageAt??e.createdAt).getTime()}function BH(e){let{defaultProjectRoot:t,sessionSummaries:n}=e,r=new Map;for(let e of Zs([...n])){let n=e.projectRoot?.trim();if(!n||n===t)continue;let i=r.get(n),a=zH(e);if(i){i.sessionCount+=1,i.latestUpdatedAt=Math.max(i.latestUpdatedAt,a);continue}r.set(n,{projectRoot:n,projectName:e.projectName?.trim()||vs(n)||n,sessionCount:1,latestUpdatedAt:a})}return[...r.values()].sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt).map(({latestUpdatedAt:e,...t})=>t)}var VH=[];function HH({inputSlot:e,pendingProjectRoot:t,pendingSessionType:n,selectedSessionTypeValue:r,onSelectProjectRoot:i,onSelectPrompt:a,onSelectSessionType:o}){let s=os(),c=z(e=>e.snapshot.selectedAgentId),l=Ul(e=>e.snapshot),u=Gc(e=>e.snapshot.configQuery?.data??null),d=Gc(e=>e.snapshot.sessionsQuery?.data?.sessions??VH),f=Gc(e=>e.snapshot.sessionTypesQuery?.data??null),p=ql(),m=l.agentId??c,h=FH({agents:p.data?.agents,fallbackAgentId:m}),g=_s(u?.agents.defaults.workspace),_=_s(t),v=Wc(f?.options??[]),y=Vc(f?.defaultType??`native`),b=RH({defaultSessionType:y,pendingSessionType:n,selectedSessionType:r,sessionTypeOptions:v}),x=BH({defaultProjectRoot:g,sessionSummaries:d});return(0,R.jsx)(PH,{agents:h,defaultProjectRoot:g,inputSlot:e,projectOptions:x,selectedAgentId:m,selectedProjectRoot:_,selectedSessionType:b,sessionTypeOptions:v,onSelectAgent:e=>{s.chatSessionListManager.setSelectedAgentId(e),o(RH({agents:h,agentId:e,defaultSessionType:y,pendingSessionType:null,selectedSessionType:null,sessionTypeOptions:v}))},onSelectPrompt:a,onSelectProjectRoot:i,onSelectSessionType:o})}var UH=`$`,WH=`@panel-app:`;function GH(e,t){if(t.length===0)return e;let n=e[e.length-1];return n?.type===`text`?[...e.slice(0,-1),{...n,text:n.text+t}]:[...e,{type:`text`,text:t}]}function KH(e){return _u(e)}function qH(e){return bu(e)}function JH(e){return xu(e,`skill`)}function YH(e){return xu(e,`file`)}function XH(e,t,n){let r=new Set(t),i=Ou(e,e=>e.tokenKind===`skill`&&!r.has(e.tokenKey)),a=xu(i,`skill`),o=new Map(n.map(e=>[e.ref,e])),s=t.filter(e=>!a.includes(e)).map(e=>mu({tokenKind:`skill`,tokenKey:e,label:o.get(e)?.name||e}));return s.length===0?i:vu([...i,...s])}function ZH(e,t){let n=new Set(YH(e));return t.filter(e=>n.has(e.id))}function QH(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){if(t.type===`text`){r=GH(r,t.text);continue}if(t.tokenKind===`skill`){r=GH(r,`${UH}${t.tokenKey}`);continue}if(t.tokenKind===`panel_app`){r=GH(r,`${WH}${t.tokenKey}`);continue}if(t.tokenKind!==`file`)continue;let e=n.get(t.tokenKey);e&&r.push({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?{assetUri:e.assetUri}:{},...e.url?{url:e.url}:{},...e.contentBase64?{contentBase64:e.contentBase64}:{},sizeBytes:e.sizeBytes})}return r}function $H(e){return e.modelOptions.length>0}function eU(e){return!e.isProviderStateResolved&&!$H(e)}function tU(e){return e.isProviderStateResolved&&!$H(e)}function nU(e){return!1}function rU(e){let{hasSendableDraft:t,isRuntimeBlocked:n}=e;return n||!t}function iU(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function aU(e,t){return e?Object.fromEntries(t.map(t=>[t,e])):{}}function oU(e){let t=_s(e.projectRoot),n={...aU(e.model?.trim(),[`model`,`preferred_model`]),...aU(e.thinkingLevel?.trim(),[`thinkingEffort`,`thinking`,`preferred_thinking`]),...aU(e.sessionType?.trim(),[`agentRuntimeId`,`session_type`,`runtime`]),...aU(e.agentId?.trim(),[`agentId`,`agent_id`]),...aU(t??void 0,[`projectRoot`,`project_root`])},r=iU(e.requestedSkills);r.length>0&&(n.requested_skill_refs=r);let i=e.composerNodes?aL(e.composerNodes):[];return i.length>0&&(n[QI]=i),e.sessionMaterialization&&(n[le]=e.sessionMaterialization),n}var sU=e=>e.some(e=>e.type!==`text`||e.text.trim().length>0),cU=e=>e?.trim()||void 0;function lU(e){return e.text.replace(/\s+/g,` `).trim()||e.attachments.map(e=>e.name).filter(Boolean).join(`, `)}function uU(e){return{isProviderStateResolved:e.isProviderStateResolved,modelOptions:e.modelOptions,sessionTypeUnavailable:e.sessionTypeState.sessionTypeUnavailable}}function dU(e){let{agentIsSending:t,inputQuery:n,inputSnapshot:r,isRuntimeBlocked:i,materializationContext:a,selectedAgentId:o,sessionKey:s}=e,c=QH([...r.nodes],r.attachments);if(rU({snapshot:uU(n),hasSendableDraft:sU(c),isRuntimeBlocked:i})||t)return null;let l={text:r.text,nodes:[...r.nodes],selectedSkills:[...r.selectedSkills],skillRecords:[...r.skillRecords],attachments:[...r.attachments]},u=oU({agentId:a?void 0:o,model:cU(a?r.selectedModel:r.selectedModel??n.fallbackPreferredModel??n.defaultModel),thinkingLevel:a?r.selectedThinkingLevel??void 0:r.selectedThinkingLevel??n.fallbackPreferredThinking??void 0,sessionType:a?void 0:n.sessionTypeState.selectedSessionType,projectRoot:a?r.pendingProjectRoot:s?n.selectedSession?.projectRoot??null:r.pendingProjectRoot,requestedSkills:[...r.selectedSkills],composerNodes:[...r.nodes],sessionMaterialization:a?{kind:a.kind,parentSessionId:a.parentSessionKey,inheritContext:a.inheritContext}:null});return{composerSnapshot:l,id:`queued-input-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,metadata:u,preview:lU(l)}}function fU(e,t){return oH({sessionId:t??void 0,text:e.composerSnapshot.text.trim(),attachments:[...e.composerSnapshot.attachments],parts:QH([...e.composerSnapshot.nodes],e.composerSnapshot.attachments),metadata:e.metadata})}function pU(e){let{autoSendingQueuedDraftIdRef:t,draft:n,sendQueuedDraft:r,setQueuedDrafts:i,setSendError:a}=e;t.current=n.id,i(e=>e[0]?.id===n.id?e.slice(1):e),a(null),r(n).catch(e=>{i(e=>[n,...e]),a(e instanceof Error?e.message:String(e))}).finally(()=>{t.current=null})}function mU(e){let{agentIsRunning:t,agentIsSending:n,queuedDrafts:r,sendQueuedDraft:i,setQueuedDrafts:a,setSendError:o}=e,s=(0,L.useRef)(null);(0,L.useEffect)(()=>{t||n||s.current||r.length===0||pU({autoSendingQueuedDraftIdRef:s,draft:r[0],sendQueuedDraft:i,setQueuedDrafts:a,setSendError:o})},[t,n,r,i,a,o])}function hU(e){let{queuedDrafts:t,restoreComposer:n,setQueuedDrafts:r,setSendError:i}=e,a=(0,L.useCallback)(e=>{let a=t.find(t=>t.id===e);a&&(r(t=>t.filter(t=>t.id!==e)),n(a.composerSnapshot),i(null))},[t,n,r,i]);return{deleteQueuedInput:(0,L.useCallback)(e=>{r(t=>t.filter(t=>t.id!==e)),i(null)},[r,i]),editQueuedInput:a}}function gU(e){let{agent:t,inputSnapshot:n,inputQuery:r,isRuntimeBlocked:i,materializationContext:a,selectedAgentId:o,sessionKey:s,onSessionMaterialized:c,resetComposer:l,restoreComposer:u,setSendError:d}=e,f=sU((0,L.useMemo)(()=>QH([...n.nodes],n.attachments),[n.attachments,n.nodes])),p=t.isSending||t.isRunning,m=rU({snapshot:uU(r),hasSendableDraft:f,isRuntimeBlocked:i})||t.isSending,[h,g]=(0,L.useState)([]),_=(0,L.useCallback)(()=>dU({agentIsSending:t.isSending,inputSnapshot:n,inputQuery:r,isRuntimeBlocked:i,materializationContext:a,selectedAgentId:o,sessionKey:s}),[t.isSending,r,n,i,a,o,s]),v=(0,L.useCallback)(async e=>{let n=await t.send(e),r=n?.sessionId?.trim()||t.snapshot.activeRun?.sessionId?.trim()||null;return!s&&r&&c?.(r),n},[t,c,s]),y=(0,L.useCallback)(async e=>{let t=fU(e,s);return t?v(t):null},[v,s]),b=(0,L.useCallback)(async()=>{let e=_();if(e){if(l(),d(null),t.isRunning){g(t=>[...t,e]);return}try{await y(e)}catch(t){throw u(e.composerSnapshot),d(t instanceof Error?t.message:String(t)),t}}},[t.isRunning,_,l,u,y,d]),x=hU({queuedDrafts:h,restoreComposer:u,setQueuedDrafts:g,setSendError:d});mU({agentIsRunning:t.isRunning,agentIsSending:t.isSending,queuedDrafts:h,sendQueuedDraft:y,setQueuedDrafts:g,setSendError:d});let S=(0,L.useCallback)(async()=>{await t.abort()},[t]);return{canStopGeneration:t.isRunning,...x,hasSendableDraft:f,isSending:p,queuedInputs:h.map(({id:e,preview:t})=>({id:e,preview:t})),send:b,sendDisabled:m,stop:S,stopDisabled:!t.isRunning}}var _U=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],vU=new Set(_U);function yU(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function bU(e,t){let n=e.trim(),r=t.trim();if(!n||!r)return n;let i=`${r}/`;return n.startsWith(i)?n.slice(i.length):n}function xU(e,t){let n=e.trim();if(!n)return``;for(let e of t)n=bU(n,e);return n.trim()}function SU(e,t){let n=t.trim(),r=e.trim();return n?r?`${r}/${n}`:n:``}function CU(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&vU.has(t)?t:null}function wU(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=CU(n);!e||t.includes(e)||t.push(e)}return t}function TU(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=xU(r,t);if(!e)continue;let a={},o=wU(i?.thinking?.supported);if(o.length>0){let e=CU(i?.thinking?.default);a.thinking=e&&o.includes(e)?{supported:o,default:e}:{supported:o}}i?.vision===!0&&(a.vision=!0),(a.thinking||a.vision===!0)&&(n[e]=a)}return n}function EU(e){return Object.fromEntries(Object.entries(e).filter(e=>!!e[1].thinking).map(([e,t])=>[e,t.thinking]))}function DU(e,t,n){let r=xU(t,n);return r?e[r]??null:null}function OU(e,t){let n=e.trim();if(!n)return null;let r=null;for(let e of t)for(let t of e.aliases){let i=t.trim();i&&(n===i||n.startsWith(`${i}/`))&&(!r||i.length>r.score)&&(r={name:e.name,score:i.length})}if(r)return r.name;for(let e of t){let t=xU(n,e.aliases);if(t&&yU(e.models??[]).some(e=>e===t))return e.name}return null}function kU(e){return e?e.enabled!==!1&&e.apiKeySet===!0:!1}function AU(e){let{providersView:t,templatesView:n,config:r,onlyConfigured:i=!1}=e,a=new Map((n?.providerTemplates??[]).map(e=>[e.providerType,e])),o=Object.values(t?.providers??r?.providers??{}).map(e=>{let{providerId:t}=e,n=e.providerType?a.get(e.providerType):void 0,r=t.trim(),i=yU([t,n?.modelPrefix||``,n?.providerType||``]),o=yU((e?.models??[]).map(e=>xU(e,i))),s={...TU(n?.modelConfig,i),...TU(e?.modelConfig,i)},c=EU(s),l=e?.displayName?.trim(),u=kU(e);return{name:t,displayName:l||n?.displayName||t,prefix:r,aliases:i,models:o,modelConfig:s,modelThinking:c,configured:u}});return i?o.filter(e=>e.configured&&e.models.length>0):o}function jU(e,t){return{value:ke,modelLabel:e,providerLabel:``,isRuntimeDefault:!0,thinkingCapability:t??null}}function MU(e){let t=new Set;return AU({providersView:e.providersView??void 0,templatesView:e.templatesView??void 0,config:e.config??void 0,onlyConfigured:!0}).flatMap(e=>e.models.map(n=>{let r=SU(e.prefix,n);return!r||t.has(r)?null:(t.add(r),{value:r,modelLabel:n,providerLabel:e.displayName,thinkingCapability:DU(e.modelThinking,n,e.aliases)})})).filter(e=>e!==null).sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})}function NU(e){let{modelOptions:t,modelSelectionMode:n,runtimeDefaultThinkingCapability:r,runtimeDefaultModelLabel:i=`Runtime default`,supportedModels:a}=e,o=jU(i,r);if(n===`runtime-default`)return[o];if(!a||a.length===0)return n===`optional`?[o,...t]:t;let s=new Set(a),c=t.filter(e=>s.has(e.value)),l=c.length>0?c:t;return n===`optional`?[o,...l]:l}function PU(e){return e?.trim().toLowerCase()||`native`}function FU(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=PU(r),o,s=-1/0;for(let e of t){if(e.key===n||PU(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function IU(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,L.useMemo)(()=>Wc(i?.options??[]),[i?.options]),o=(0,L.useMemo)(()=>{let e=[...a],n=Vc(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:Uc(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,modelSelectionMode:`nextclaw`,runtimeDefaultThinking:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),s=(0,L.useMemo)(()=>Vc(i?.defaultType??`native`),[i?.defaultType]),c=(0,L.useRef)(null),l=typeof n==`string`&&n.trim().length>0?n:void 0,u=(0,L.useMemo)(()=>Vc(t?.sessionType??l??s),[s,l,t?.sessionType]),f=(0,L.useMemo)(()=>o.find(e=>e.value===u)??null,[u,o]);(0,L.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=Vc(n);(e.length===0||c.current===i||c.current===null&&i===`native`)&&(c.current=s,i!==s&&r(s))},[s,n,t,r]);let p=!t||!!t.sessionTypeMutable,m=(0,L.useMemo)(()=>new Set(a.map(e=>e.value)),[a]),h=(0,L.useMemo)(()=>t&&!m.has(Vc(t.sessionType))?!0:f?.ready===!1,[m,t,f?.ready]),g=(0,L.useMemo)(()=>t&&!m.has(Vc(t.sessionType))?`${Uc(u)} ${d(`chatSessionTypeUnavailableSuffix`)}`:f?.ready===!1?f.reasonMessage?.trim()||`${f.label} setup required`:null,[m,t,u,f]);return(0,L.useMemo)(()=>({sessionTypeOptions:o,selectedSessionTypeOption:f,defaultSessionType:s,selectedSessionType:u,canEditSessionType:p,sessionTypeUnavailable:h,sessionTypeUnavailableMessage:g}),[p,s,u,f,o,h,g])}var LU=`nextclaw.chat.recent-selection.store`;function RU(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function zU(e,t){return Array.isArray(e)?Array.from(new Set(e.map(RU).filter(e=>!!e))).slice(0,t):[]}function BU(e,t){let n=RU(t?.namespace);return n?`${e.storageKey}.${encodeURIComponent(n.toLowerCase())}`:e.storageKey}function VU(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){let e=RU(n);if(!e)continue;let i=zU(r,1/0);i.length>0&&(t[e]=i)}return t}var HU=f()(Tr(e=>({entriesByKey:{},setEntries:(t,n)=>e(e=>({entriesByKey:{...e.entriesByKey,[t]:zU(n,1/0)}}))}),{name:LU,storage:Er(()=>window.localStorage),partialize:e=>({entriesByKey:e.entriesByKey}),merge:(e,t)=>({...t,entriesByKey:VU(e?.entriesByKey)})})),UU=class{constructor(e){this.options=e,this.read=(e={})=>{let t=BU(this.options,e);return zU(HU.getState().entriesByKey[t],this.options.limit)},this.remember=(e,t={})=>{let n=RU(e);if(!n)return this.read(t);let r=BU(this.options,t),i=[n,...this.read(t).filter(e=>e!==n)].slice(0,this.options.limit);return HU.getState().setEntries(r,i),i},this.resolveVisible=e=>{let t=zU(e.availableValues,1/0);if(t.length<=e.minAvailableCount)return[];let n=new Set(t),r=[],i=Math.max(1,e.limit??this.options.limit);for(let t of this.read(e))if(!(!n.has(t)||r.includes(t))&&(r.push(t),r.length>=i))break;return r}}},WU=new UU({storageKey:`nextclaw.chat.recent-models`,limit:3}),GU=[],KU=[];function qU(e){let{sessionKey:t,inputSnapshot:n,setPendingSessionType:r}=e,i=t??null,a=Cl(),o=Gc(e=>e.snapshot),s=o.configQuery?.data??null,c=o.sessionsQuery?.data?.sessions??KU,l=uc({sessionId:i?.trim()||`draft-session`,projectRoot:_s(n.pendingProjectRoot)}),u=l.data?.records??GU,f=!!(l.isLoading||l.isFetching),p=(0,L.useMemo)(()=>Zs(c),[c]),m=(0,L.useMemo)(()=>p.find(e=>e.key===i)??null,[i,p]),h=IU({selectedSession:m,pendingSessionType:n.pendingSessionType,setPendingSessionType:r,sessionTypesData:o.sessionTypesQuery?.data??null}),g=(0,L.useMemo)(()=>MU({config:s,providersView:o.providersQuery?.data??null,templatesView:o.providerTemplatesQuery?.data??null}),[s,o.providerTemplatesQuery?.data,o.providersQuery?.data]),_=(0,L.useMemo)(()=>NU({modelOptions:g,modelSelectionMode:h.selectedSessionTypeOption?.modelSelectionMode,runtimeDefaultThinkingCapability:h.selectedSessionTypeOption?.runtimeDefaultThinking??null,runtimeDefaultModelLabel:d(`chatRuntimeDefaultModel`),supportedModels:h.selectedSessionTypeOption?.supportedModels}),[g,h.selectedSessionTypeOption?.modelSelectionMode,h.selectedSessionTypeOption?.runtimeDefaultThinking,h.selectedSessionTypeOption?.supportedModels]),v=(0,L.useMemo)(()=>new Set(_.map(e=>e.value)),[_]),y=WU.read({namespace:h.selectedSessionType}).find(e=>v.has(e)),b=(0,L.useMemo)(()=>y??FU({sessions:p,selectedSessionKey:i,sessionType:h.selectedSessionType,readPreference:e=>e.preferredModel?.trim()||void 0}),[y,i,h.selectedSessionType,p]),x=(0,L.useMemo)(()=>FU({sessions:p,selectedSessionKey:i,sessionType:h.selectedSessionType,readPreference:e=>e.preferredThinking??void 0}),[i,h.selectedSessionType,p]),S=_s(s?.agents.defaults.workspace);return(0,L.useMemo)(()=>({defaultModel:s?.agents.defaults.model,defaultProjectRoot:S,fallbackPreferredModel:b,fallbackPreferredThinking:x,isProviderStateResolved:a,isSkillsLoading:f,modelOptions:_,selectedSession:m,selectedSessionKey:i,sessionTypeState:h,skillRecords:u}),[s?.agents.defaults.model,S,b,x,a,f,_,m,i,h,u])}var JU={text:``,nodes:[],selectedSkills:[],skillRecords:[]},YU=()=>({...JU,attachments:[],selectedModel:void 0,selectedThinkingLevel:null,pendingSessionType:Bc,selectedSessionType:Bc,pendingProjectRoot:null,composerFocusRequestId:0,sendError:null}),XU=e=>e?.trim()||Bc,ZU=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),QU=(e,t)=>{let n=new Set(e.map(ZU)),r=[...e];return t.forEach(e=>{let t=ZU(e);n.has(t)||(n.add(t),r.push(e))}),r},$U=()=>{let[e,t]=(0,L.useState)(YU),n=(0,L.useCallback)(e=>{t(t=>{let n=typeof e==`function`?e(t):e;return{...t,...n}})},[]),r=(0,L.useCallback)(e=>{n({text:e.text,nodes:e.nodes,selectedSkills:e.selectedSkills,skillRecords:e.skillRecords,sendError:null})},[n]),i=(0,L.useCallback)(()=>{n({...JU,attachments:[],sendError:null})},[n]),a=(0,L.useCallback)(e=>{n({...e})},[n]),o=(0,L.useCallback)(e=>{n({text:e,nodes:KH(e),selectedSkills:[],skillRecords:[],sendError:null,composerFocusRequestId:Date.now()})},[n]),s=(0,L.useCallback)(()=>{n(e=>({composerFocusRequestId:e.composerFocusRequestId+1}))},[n]),c=(0,L.useCallback)(()=>{n({composerFocusRequestId:0})},[n]),l=(0,L.useCallback)(e=>{n({attachments:e})},[n]),u=(0,L.useCallback)(t=>{if(t.length===0)return[];let r=new Set(e.attachments.map(ZU)),i=QU(e.attachments,t),a=i.filter(e=>!r.has(ZU(e)));return a.length>0&&n({attachments:i}),a},[e.attachments,n]),d=(0,L.useCallback)(e=>{n(t=>({attachments:t.attachments.filter(t=>t.id!==e)}))},[n]),f=(0,L.useCallback)(e=>{n({selectedModel:e})},[n]),p=(0,L.useCallback)(e=>{n({selectedThinkingLevel:e})},[n]),m=(0,L.useCallback)(e=>{n(t=>{let n=XU(typeof e==`function`?e(t.pendingSessionType):e);return{pendingSessionType:n,selectedSessionType:n}})},[n]),h=(0,L.useCallback)(e=>{n({pendingProjectRoot:e})},[n]),g=(0,L.useCallback)((e,t)=>{n({selectedSkills:e,skillRecords:t,sendError:null})},[n]),_=(0,L.useCallback)(e=>{n({sendError:e})},[n]);return{inputSnapshot:e,inputActions:(0,L.useMemo)(()=>({update:n,syncComposer:r,resetComposer:i,restoreComposer:a,applyPromptSuggestion:o,requestComposerFocusAtEnd:s,consumeComposerFocusRequest:c,setAttachments:l,addAttachments:u,removeAttachment:d,setSelectedModel:f,setSelectedThinkingLevel:p,setPendingSessionType:m,setPendingProjectRoot:h,setSelectedSkills:g,setSendError:_}),[n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_])}};function eW(){return(0,L.useEffect)(()=>to.attach(),[]),{isMobile:eo(e=>e.mode)===`mobile`}}var tW={exactId:1200,exactLabel:1150,prefixId:1e3,prefixLabel:950,prefixToken:900,containsId:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function nW(e){return(e??``).trim().toLowerCase()}function rW(e,t){if(!e||!t)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function iW(e,t){let n=nW(t);if(!n)return tW.fallback;let r=nW(e.id),i=nW(e.label||e.id),a=nW(e.description),o=(e.aliases??[]).map(nW).filter(Boolean),s=i.split(/[\s/_-]+/).filter(Boolean),c=[r,...o];return c.some(e=>e===n)?tW.exactId:i===n?tW.exactLabel:c.some(e=>e.startsWith(n))?tW.prefixId:i.startsWith(n)?tW.prefixLabel:s.some(e=>e.startsWith(n))?tW.prefixToken:c.some(e=>e.includes(n))?tW.containsId:i.includes(n)?tW.containsLabel:a.includes(n)?tW.containsDescription:rW(n,i)||c.some(e=>rW(n,e))?tW.subsequence:0}function aW(e){return e>=tW.exactLabel?4:e>=tW.prefixToken?3:e>=tW.containsLabel?2:e>0?1:0}var oW={key:`panel-app-reference`,marker:`@`};function sW(e){return Date.parse(e.lastOpenedAt??e.updatedAt)||0}function cW(e){let t=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0});return e.entries.map((t,n)=>({entry:t,order:n,score:iW({id:t.appId,label:t.title||t.appId,description:t.description,aliases:[t.id,t.fileName]},e.query)})).filter(e=>e.score>0).sort((e,n)=>{let r=aW(e.score),i=aW(n.score);if(i!==r)return i-r;if(e.entry.favorite!==n.entry.favorite)return e.entry.favorite?-1:1;let a=sW(n.entry),o=sW(e.entry);return a===o?n.score===e.score?t.compare(e.entry.title||e.entry.appId,n.entry.title||n.entry.appId)||e.order-n.order:n.score-e.score:a-o}).map(({entry:e})=>e)}function lW(e){let t=e.keyPrefix??`panel-app`;return cW({entries:e.entries,query:e.query}).map(n=>({entry:n,item:{key:`${t}:${n.appId}`,title:n.title||n.appId,subtitle:e.texts.subtitle,description:(n.description??``).trim()||e.texts.noDescriptionLabel,detailLines:[`${e.texts.appIdLabel}: ${n.appId}`,`${e.texts.fileLabel}: ${n.fileName}`]}}))}function uW(e){return lW(e).map(({item:e})=>e)}function dW(e){return lW(e).map(({entry:e,item:t})=>({...t,tokenKind:`panel_app`,tokenKey:e.appId,value:e.appId}))}function fW(e){return UI({key:`panel-app-reference`,trigger:oW,tokenKind:`panel_app`,texts:e.menuTexts,getIsLoading:({data:e})=>e.isPanelAppsLoading,getRecords:({data:e})=>e.panelApps,getItems:({records:t,query:n})=>dW({entries:t,query:n,texts:e.itemTexts})})}function pW(e){let t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function mW(e){let t=[];for(let n of[`off`,...e])t.includes(n)||t.push(n);return t}function hW(e){let{isModelOptionsEmpty:t,isModelOptionsLoading:n,onGoToProviders:r,texts:i}=e;return!n&&!t?null:n?{tone:`neutral`,loading:!0}:{tone:`warning`,text:i.noModelOptionsLabel,actionLabel:i.configureProviderLabel,onAction:r}}function gW({modelOptions:e,favoriteModelValues:t,recentModelValues:n,selectedModel:r,isModelOptionsLoading:i,hasModelOptions:a,onFavoriteToggle:o,onValueChange:s,texts:c}){let l=e.find(e=>e.value===r)??e[0],u=a?l?.value:void 0,d=new Map(e.map(e=>[e.value,e])),f=(t??[]).map(e=>d.get(e)).filter(e=>!!e),p=new Set(f.map(e=>e.value)),m=(n??[]).map(e=>d.get(e)).filter(e=>e!==void 0&&!p.has(e.value)),h=new Set(m.map(e=>e.value)),g=e.filter(e=>!p.has(e.value)&&!h.has(e.value)),_=f.length>0||m.length>0?[{key:`favorite-models`,label:c.favoriteModelsLabel,options:f.map(e=>({value:e.value,label:pW(e)}))},{key:`recent-models`,label:c.recentModelsLabel,options:m.map(e=>({value:e.value,label:pW(e)}))},{key:`all-models`,label:c.allModelsLabel,options:g.map(e=>({value:e.value,label:pW(e)}))}].filter(e=>e.options.length>0):void 0;return{key:`model`,value:u,placeholder:c.modelSelectPlaceholder,selectedLabel:l?pW(l):void 0,icon:`sparkles`,options:e.map(e=>({value:e.value,label:pW(e)})),groups:_,disabled:!a,loading:i,emptyLabel:c.modelNoOptionsLabel,search:{placeholder:c.modelSearchPlaceholder,emptyLabel:c.modelSearchEmptyLabel},optionAction:o?{kind:`favorite`,activeValues:f.map(e=>e.value),activeLabel:c.unfavoriteModelLabel,inactiveLabel:c.favoriteModelLabel,onToggle:o}:void 0,onValueChange:s}}function _W(e){let{defaultThinkingLevel:t,onValueChange:n,selectedThinkingLevel:r,supportedLevels:i,texts:a}=e;if(i.length===0)return null;let o=mW(i),s=o.includes(`off`)?`off`:o[0],c=r&&o.includes(r)&&r||t&&o.includes(t)&&t||s;return{key:`thinking`,value:c,placeholder:a.thinkingLabels[c],selectedLabel:a.thinkingLabels[c],icon:`brain`,options:o.map(e=>({value:e,label:a.thinkingLabels[e]})),onValueChange:e=>n(e)}}var vW={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function yW(e){return(e??``).trim().toLowerCase()}function bW(e,t){if(!e||!t)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function xW(e,t){let n=yW(t);if(!n)return vW.fallback;let r=yW(e.key),i=yW(e.label||e.key),a=yW(`${e.descriptionZh??``} ${e.description??``}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?vW.exactSpec:i===n?vW.exactLabel:r.startsWith(n)?vW.prefixSpec:i.startsWith(n)?vW.prefixLabel:o.some(e=>e.startsWith(n))?vW.prefixToken:r.includes(n)?vW.containsSpec:i.includes(n)?vW.containsLabel:a.includes(n)?vW.containsDescription:bW(n,i)||bW(n,r)?vW.subsequence:0}function SW(e){return e>=vW.exactLabel?4:e>=vW.prefixToken?3:e>=vW.containsLabel?2:e>0?1:0}function CW(e){return new Map(e.map((e,t)=>[e,t]))}function wW(e,t){let n=CW(t),r=[],i=[];for(let t of e){if(n.has(t.key)){r.push(t);continue}i.push(t)}return r.sort((e,t)=>(n.get(e.key)??1/0)-(n.get(t.key)??1/0)),[...r,...i]}function TW(e,t,n,r=[]){let i=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),a=CW(r);return e.map((e,n)=>({record:e,order:n,score:xW(e,t)})).filter(e=>e.score>0).sort((e,t)=>{let n=SW(e.score),r=SW(t.score);if(r!==n)return r-n;let o=a.get(e.record.key)??1/0,s=a.get(t.record.key)??1/0;if(o!==s)return o-s;if(t.score!==e.score)return t.score-e.score;let c=(e.record.label||e.record.key).trim(),l=(t.record.label||t.record.key).trim(),u=i.compare(c,l);return u===0?e.order-t.order:u}).map(({record:e})=>({key:`skill:${e.key}`,title:e.label||e.key,subtitle:n.slashSkillSubtitle,description:(e.descriptionZh??e.description??``).trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${e.key}`,...e.scopeLabel?[`${n.slashSkillScopeLabel}: ${e.scopeLabel}`]:[]],tokenKind:`skill`,tokenKey:e.key,value:e.key}))}function EW(e){return e.map(e=>({key:e.key,label:e.label,description:e.descriptionZh||e.description||``,badgeLabel:e.badgeLabel}))}function DW(e){let{groupedRecentSkillValues:t,isLoading:n,onSelectedKeysChange:r,recentSkillValues:i,selectedSkills:a,skillRecords:o,texts:s}=e,c=wW(o,i??[]),l=new Set(t??[]),u=EW(c.filter(e=>l.has(e.key))),d=EW(c.filter(e=>!l.has(e.key)));return{title:s.title,searchPlaceholder:s.searchPlaceholder,emptyLabel:s.emptyLabel,loadingLabel:s.loadingLabel,isLoading:n,manageLabel:s.manageLabel,manageHref:`/marketplace/skills`,options:EW(c),groups:u.length>0?[{key:`recent-skills`,label:s.recentSkillsLabel,options:u},{key:`all-skills`,label:s.allSkillsLabel,options:d}].filter(e=>e.options.length>0):void 0,selectedKeys:a,onSelectedKeysChange:r}}var OW=`commands`,kW=`panel-app-action`,AW=`panel-apps`,jW=`skills`;function MW(e){let t=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0});return e.commands.map((t,n)=>({command:t,order:n,score:iW({id:t.key,label:t.title,description:t.description,aliases:t.keywords},e.query)})).filter(e=>e.score>0).sort((e,n)=>{let r=aW(e.score),i=aW(n.score);return i===r?n.score===e.score?t.compare(e.command.title,n.command.title)||e.order-n.order:n.score-e.score:i-r}).map(({command:t})=>({key:`command:${t.key}`,title:t.title,subtitle:e.texts.commandSubtitle,description:t.description,detailLines:[...t.detailLines??[]],hintLabel:e.texts.commandHintLabel,sectionKey:OW,sectionLabel:e.texts.commandSectionLabel}))}function NW(e){let{data:t,itemTexts:n,query:r,skillHintLabel:i,skillSectionLabel:a}=e;return TW([...t.skillRecords],r,n,[...t.recentSkillValues]).map(e=>({...e,hintLabel:i,sectionKey:jW,sectionLabel:a}))}function PW(e){return uW({entries:e.data.panelApps,keyPrefix:kW,query:e.query,texts:e.itemTexts}).map(t=>({...t,hintLabel:e.panelAppHintLabel,sectionKey:AW,sectionLabel:e.panelAppSectionLabel}))}function FW(e){let t=`${kW}:`;return e.key.startsWith(t)?e.key.slice(t.length):null}function IW(e){return HI({key:`slash-command`,trigger:du,resolvePanel:t=>{let{data:n,trigger:r}=t;return{filterOptions:[{key:`all`,label:e.labels.filterAllLabel},{key:OW,label:e.labels.filterCommandsLabel,sectionKeys:[OW]},{key:jW,label:e.labels.filterSkillsLabel,sectionKeys:[jW]},{key:AW,label:e.labels.filterPanelAppsLabel,sectionKeys:[AW]}],isLoading:n.isPanelAppsLoading||n.isSkillsLoading,items:[...MW({commands:e.commands,query:r.query,texts:{commandHintLabel:e.labels.commandHintLabel,commandSectionLabel:e.labels.commandSectionLabel,commandSubtitle:e.labels.commandSubtitle}}),...NW({data:n,itemTexts:e.itemTexts.skillTexts,query:r.query,skillHintLabel:e.labels.skillHintLabel,skillSectionLabel:e.labels.skillSectionLabel}),...PW({data:n,itemTexts:e.itemTexts.panelAppTexts,panelAppHintLabel:e.labels.panelAppHintLabel,panelAppSectionLabel:e.labels.panelAppSectionLabel,query:r.query})],onSelectItem:t=>{if(t.key.startsWith(`command:`)){e.commands.find(e=>t.key===`command:${e.key}`)?.onSelect();return}let n=FW(t);if(n){e.onSelectPanelApp(n);return}let r=t.tokenKey??t.value;r&&e.onSelectSkill?.(r)},texts:e.menuTexts}}})}function LW(e){let{isSkillsLoading:t,itemTexts:n,language:r,onSelectPanelApp:i,onSelectSkill:a,recentSkillValues:o,skillRecords:s,commands:c}=e,[l,u]=(0,L.useState)(null),f=(0,L.useRef)(`null`),p=(0,L.useCallback)(e=>{let t=JSON.stringify(e?[e.key,e.marker,e.query,e.start,e.end]:null);f.current!==t&&(f.current=t,u(e))},[]),m=Tz({enabled:l?.key===oW.key||l?.key===du.key}),h=(0,L.useMemo)(()=>[IW({commands:c,itemTexts:{panelAppTexts:{appIdLabel:d(`chatPanelAppReferenceAppId`,r),fileLabel:d(`chatPanelAppReferenceFile`,r),noDescriptionLabel:d(`chatPanelAppReferenceNoDescription`,r),subtitle:d(`chatPanelAppReferenceType`,r)},skillTexts:n.slashTexts},menuTexts:{loadingLabel:d(`chatSlashLoading`,r),sectionLabel:d(`chatSlashSection`,r),emptyLabel:d(`chatSlashNoResult`,r),hintLabel:d(`chatSlashHint`,r),itemHintLabel:d(`chatSlashSkillHint`,r)},labels:{commandHintLabel:d(`chatSlashCommandHint`,r),commandSectionLabel:d(`chatSlashSectionCommands`,r),commandSubtitle:d(`chatSlashTypeCommand`,r),filterAllLabel:d(`chatSlashFilterAll`,r),filterCommandsLabel:d(`chatSlashFilterCommands`,r),filterPanelAppsLabel:d(`chatSlashFilterPanelApps`,r),filterSkillsLabel:d(`chatSlashFilterSkills`,r),panelAppHintLabel:d(`chatSlashPanelAppHint`,r),panelAppSectionLabel:d(`chatPanelAppReferenceSection`,r),skillHintLabel:d(`chatSlashSkillHint`,r),skillSectionLabel:d(`chatSlashSectionSkills`,r)},onSelectPanelApp:i,onSelectSkill:a}),fW({itemTexts:{appIdLabel:d(`chatPanelAppReferenceAppId`,r),fileLabel:d(`chatPanelAppReferenceFile`,r),noDescriptionLabel:d(`chatPanelAppReferenceNoDescription`,r),subtitle:d(`chatPanelAppReferenceType`,r)},menuTexts:{loadingLabel:d(`chatPanelAppReferenceLoading`,r),sectionLabel:d(`chatPanelAppReferenceSection`,r),emptyLabel:d(`chatPanelAppReferenceNoResult`,r),hintLabel:d(`chatPanelAppReferenceHint`,r),itemHintLabel:d(`chatPanelAppReferenceItemHint`,r)}})],[c,n.slashTexts,r,i,a]);return{inputSurfaceState:(0,L.useMemo)(()=>WI({data:{isPanelAppsLoading:m.isLoading||m.isFetching,isSkillsLoading:t,panelApps:m.data?.entries??[],recentSkillValues:o,skillRecords:s},plugins:h,trigger:l}),[h,l,m.data?.entries,m.isFetching,m.isLoading,t,o,s]),setInputSurfaceTrigger:p}}var RW=$e.chat.modelFavorites,zW=[`preference`,RW];function BW(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function VW(e){let t=Be(),n=(0,L.useMemo)(()=>new Set(e),[e]),r=Me({queryKey:zW,queryFn:()=>Ze(RW),staleTime:3e4}),i=(0,L.useMemo)(()=>BW(r.data?.value),[r.data?.value]),a=(0,L.useMemo)(()=>i.filter(e=>n.has(e)),[n,i]),o=we({mutationFn:async e=>await He(RW,e),onMutate:async e=>{await t.cancelQueries({queryKey:zW});let n=t.getQueryData(zW);return t.setQueryData(zW,{key:RW,value:e,updatedAt:new Date().toISOString()}),{previous:n}},onError:(e,n,r)=>{r?.previous&&t.setQueryData(zW,r.previous)},onSuccess:e=>{t.setQueryData(zW,e)}}),s=(0,L.useCallback)((e,t)=>{let n=e.trim();if(!n)return;let r=t?[n,...i.filter(e=>e!==n)]:i.filter(e=>e!==n);o.mutate(r)},[i,o]);return{favoriteModelValues:a,isLoading:r.isLoading,setModelFavorite:s}}var HW=new UU({storageKey:`nextclaw.chat.recent-skills`,limit:5});function UW(e){let{addAttachments:t,attachmentSupported:n,inputBarRef:r}=e,i=(0,L.useCallback)(e=>{if(e===`unsupported-type`){P.error(d(`chatInputAttachmentUnsupported`));return}if(e===`too-large`){P.error(d(`chatInputAttachmentTooLarge`).replace(`{maxMb}`,String(nH/(1024*1024))));return}P.error(d(`chatInputAttachmentReadFailed`))},[]),a=(0,L.useCallback)(async e=>{if(!n||e.length===0)return;let a=await sH(e,{uploadBatch:fe});if(a.attachments.length>0){let e=t(a.attachments);e.length>0&&r.current?.insertFileTokens(e.map(e=>({tokenKey:e.id,label:e.name})))}a.rejected.length>0&&i(a.rejected[0].reason)},[t,n,r,i]);return{handleFilesAdd:a,handleFileInputChange:(0,L.useCallback)(async e=>{let t=Array.from(e.target.files??[]);e.currentTarget.value=``,await a(t)},[a])}}function WW(){return{off:d(`chatThinkingLevelOff`),minimal:d(`chatThinkingLevelMinimal`),low:d(`chatThinkingLevelLow`),medium:d(`chatThinkingLevelMedium`),high:d(`chatThinkingLevelHigh`),adaptive:d(`chatThinkingLevelAdaptive`),xhigh:d(`chatThinkingLevelXhigh`)}}function GW(e){let{allModelsLabel:t,favoriteModelLabel:n,favoriteModelValues:r,favoriteModelsLabel:i,hasModelOptions:a,isModelOptionsLoading:o,modelRecords:s,modelSearchEmptyLabel:c,modelSearchPlaceholder:l,onFavoriteModelToggle:u,onModelChange:f,onThinkingChange:p,recentModelValues:m,recentModelsLabel:h,selectedModel:g,selectedThinkingLevel:_,thinkingDefaultLevel:v,thinkingSupportedLevels:y,unfavoriteModelLabel:b}=e;return[gW({modelOptions:s,favoriteModelValues:r,recentModelValues:m,selectedModel:g,isModelOptionsLoading:o,hasModelOptions:a,onFavoriteToggle:u,onValueChange:f,texts:{modelSelectPlaceholder:d(`chatSelectModel`),modelNoOptionsLabel:d(`chatModelNoOptions`),modelSearchPlaceholder:l,modelSearchEmptyLabel:c,favoriteModelsLabel:i,favoriteModelLabel:n,unfavoriteModelLabel:b,recentModelsLabel:h,allModelsLabel:t}}),_W({supportedLevels:y,selectedThinkingLevel:_,defaultThinkingLevel:v,onValueChange:p,texts:{thinkingLabels:WW()}})].filter(e=>e!==null)}function KW(e){let{allSkillsLabel:t,isSkillsLoading:n,onSelectedKeysChange:r,recentSkillGroupValues:i,recentSkillValues:a,recentSkillsLabel:o,selectedSkills:s,skillRecords:c}=e;return DW({skillRecords:c,recentSkillValues:a,groupedRecentSkillValues:i,selectedSkills:[...s],isLoading:n,onSelectedKeysChange:r,texts:{title:d(`chatSkillsPickerTitle`),searchPlaceholder:d(`chatSkillsPickerSearchPlaceholder`),emptyLabel:d(`chatSkillsPickerEmpty`),loadingLabel:d(`sessionsLoading`),manageLabel:d(`chatSkillsPickerManage`),recentSkillsLabel:o,allSkillsLabel:t}})}function qW(e,t){let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`}function JW({children:e,disabled:t=!1,label:n,onClick:r}){return(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`span`,{className:`inline-flex`,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":n,disabled:t,onClick:r,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:cursor-not-allowed disabled:text-muted-foreground/50`,children:e})})}),(0,R.jsx)(Fn,{side:`top`,children:n})]})}function YW({controller:e}){return e.queuedInputs.length===0?null:(0,R.jsx)(Ln,{delayDuration:120,children:(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.queuedInputs.map(t=>(0,R.jsxs)(`div`,{className:`flex min-h-8 min-w-0 items-center gap-2 text-sm`,children:[(0,R.jsx)(di,{className:`h-4 w-4 shrink-0 text-muted-foreground/70`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground/80`,children:t.preview||d(`chatQueuedBannerAttachmentFallback`)}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,R.jsx)(JW,{label:d(`chatQueuedEdit`),onClick:()=>e.editQueuedInput(t.id),children:(0,R.jsx)(Qi,{className:`h-4 w-4`})}),(0,R.jsx)(JW,{label:d(`chatQueuedDelete`),onClick:()=>e.deleteQueuedInput(t.id),children:(0,R.jsx)(ha,{className:`h-4 w-4`})})]})]},t.id))})})}function XW(e,t){return e.map(e=>({key:e.ref,label:e.name,scopeLabel:t[e.scope],description:e.description,descriptionZh:e.descriptionZh,badgeLabel:t[e.scope]}))}function ZW(e){return e.map(e=>({value:e.value,modelLabel:e.modelLabel,providerLabel:e.providerLabel,thinkingCapability:e.thinkingCapability?{supported:e.thinkingCapability.supported,default:e.thinkingCapability.default??null}:null}))}function QW(e){return{skillScopeLabels:(0,L.useMemo)(()=>({builtin:d(`chatSkillScopeBuiltin`),project:d(`chatSkillScopeProject`),workspace:d(`chatSkillScopeWorkspace`)}),[e]),slashTexts:(0,L.useMemo)(()=>({slashSkillSubtitle:d(`chatSlashTypeSkill`),slashSkillSpecLabel:d(`chatSlashSkillSpec`),slashSkillScopeLabel:d(`chatSlashSkillScope`),noSkillDescription:d(`chatSkillsPickerNoDescription`)}),[e]),recentModelsLabel:d(`chatPickerRecentModels`),allModelsLabel:d(`chatPickerAllModels`),favoriteModelsLabel:d(`chatPickerFavoriteModels`),modelSearchPlaceholder:d(`chatModelSearchPlaceholder`),modelSearchEmptyLabel:d(`chatModelSearchEmpty`),favoriteModelLabel:d(`chatFavoriteModel`),unfavoriteModelLabel:d(`chatUnfavoriteModel`),recentSkillsLabel:d(`chatPickerRecent`),allSkillsLabel:d(`chatPickerAllSkills`)}}function $W(e){let t=(0,L.useMemo)(()=>XW(e.skillRecords,e.skillScopeLabels),[e.skillRecords,e.skillScopeLabels]),n=(0,L.useMemo)(()=>ZW(e.modelOptions),[e.modelOptions]);return{skillRecords:t,modelRecords:n,recentModelValues:WU.resolveVisible({availableValues:n.map(e=>e.value),minAvailableCount:5}),recentSkillValues:HW.resolveVisible({availableValues:t.map(e=>e.key),minAvailableCount:0}),recentSkillGroupValues:HW.resolveVisible({availableValues:t.map(e=>e.key),minAvailableCount:4})}}var eG=(0,L.memo)(function(e){let{contextWindow:t,controller:n,inputActions:r,inputQuery:i,inputSnapshot:a,surface:o=`default`}=e,s=os(),{language:c}=pr(),{isMobile:l}=eW(),u=(0,L.useRef)(null),f=(0,L.useRef)(null),p=QW(c),{skillRecords:m,modelRecords:h,recentModelValues:g,recentSkillValues:_,recentSkillGroupValues:v}=$W({modelOptions:i.modelOptions,skillRecords:i.skillRecords,skillScopeLabels:p.skillScopeLabels}),y=(0,L.useMemo)(()=>{let e=i.selectedSessionKey?.trim();return e?[{key:`side-chat`,title:d(`chatSlashCommandSideChatTitle`,c),description:d(`chatSlashCommandSideChatDescription`,c),detailLines:[d(`chatSlashCommandSideChatDetail`,c)],keywords:[`side`,`chat`,`child`,`branch`,`new`],onSelect:()=>s.chatThreadManager.openSideChatDraft(e)}]:[]},[i.selectedSessionKey,c,s.chatThreadManager]),b=(0,L.useCallback)(e=>void s.chatUiManager.showContent({target:{type:`panel_app`,payload:{appId:e}}}),[s.chatUiManager]),{inputSurfaceState:x,setInputSurfaceTrigger:S}=LW({commands:y,isSkillsLoading:i.isSkillsLoading,itemTexts:{slashTexts:p.slashTexts},language:c,onSelectPanelApp:b,onSelectSkill:HW.remember,recentSkillValues:_,skillRecords:m}),{favoriteModelValues:C,setModelFavorite:w}=VW((0,L.useMemo)(()=>h.map(e=>e.value),[h])),T=a.selectedModel??i.fallbackPreferredModel??i.defaultModel??``,E=a.selectedThinkingLevel??i.fallbackPreferredThinking??null,D={isProviderStateResolved:i.isProviderStateResolved,modelOptions:i.modelOptions,sessionTypeUnavailable:i.sessionTypeState.sessionTypeUnavailable},O=$H(D),k=eU(D),A=tU(D),ee=nU(D),j=d(A?`chatModelNoOptions`:l?`chatInputPlaceholderCompact`:`chatInputPlaceholder`),M=h.find(e=>e.value===T),N=M?.thinkingCapability?.supported??[],{handleFilesAdd:te,handleFileInputChange:ne}=UW({attachmentSupported:!0,inputBarRef:u,addAttachments:r.addAttachments}),re=(0,L.useCallback)(e=>{!i.selectedSessionKey||!i.selectedSession||Ne(i.selectedSessionKey,e).catch(()=>void 0)},[i.selectedSession,i.selectedSessionKey]),ie=(0,L.useCallback)(e=>{let t=[...e];r.update(e=>({nodes:t,attachments:ZH(t,e.attachments),text:qH(t),selectedSkills:JH(t),sendError:null}))},[r]),ae=(0,L.useCallback)(e=>{let t=qW(h.find(t=>t.value===e),E);r.update({selectedModel:e,selectedThinkingLevel:t,sendError:null}),WU.remember(e,{namespace:i.sessionTypeState.selectedSessionType}),at(e)||WU.remember(e),re({preferredModel:at(e)?null:e,preferredThinking:t})},[r,i.sessionTypeState.selectedSessionType,h,E,re]),oe=(0,L.useCallback)(e=>{r.setSelectedThinkingLevel(e),re({preferredThinking:e})},[r,re]),se=(0,L.useCallback)(e=>{let t=a.selectedSkills;e.filter(e=>!t.includes(e)).forEach(e=>HW.remember(e)),ie(XH([...a.nodes],e,i.skillRecords.map(e=>({ref:e.ref,name:e.name}))))},[ie,i.skillRecords,a.nodes,a.selectedSkills]);(0,L.useEffect)(()=>{a.composerFocusRequestId&&(u.current?.focusComposerAtEnd([...a.nodes]),r.consumeComposerFocusRequest())},[r,a.composerFocusRequestId,a.nodes]);let ce=GW({allModelsLabel:p.allModelsLabel,favoriteModelLabel:p.favoriteModelLabel,favoriteModelValues:C,favoriteModelsLabel:p.favoriteModelsLabel,hasModelOptions:O,isModelOptionsLoading:k,modelRecords:h,modelSearchEmptyLabel:p.modelSearchEmptyLabel,modelSearchPlaceholder:p.modelSearchPlaceholder,onFavoriteModelToggle:w,onModelChange:ae,onThinkingChange:oe,recentModelValues:g,recentModelsLabel:p.recentModelsLabel,selectedModel:T,selectedThinkingLevel:E,thinkingSupportedLevels:N,thinkingDefaultLevel:M?.thinkingCapability?.default??null,unfavoriteModelLabel:p.unfavoriteModelLabel}),le=KW({allSkillsLabel:p.allSkillsLabel,onSelectedKeysChange:se,recentSkillGroupValues:v,recentSkillValues:_,recentSkillsLabel:p.recentSkillsLabel,isSkillsLoading:i.isSkillsLoading,skillRecords:m,selectedSkills:a.selectedSkills});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(mS,{ref:u,surface:o,topSlot:n.queuedInputs.length>0?(0,R.jsx)(YW,{controller:n}):null,composer:{nodes:[...a.nodes],placeholder:j,disabled:ee,onNodesChange:ie,onFilesAdd:te,inputSurfaceTriggerSpecs:x.triggerSpecs,onInputSurfaceTriggerChange:S},inputSurface:x.panel??void 0,hint:hW({isModelOptionsLoading:k,isModelOptionsEmpty:A,onGoToProviders:s.chatUiManager.goToProviders,texts:{noModelOptionsLabel:d(`chatModelNoOptions`),configureProviderLabel:d(`chatGoConfigureProvider`)}}),toolbar:{selects:[],trailingSelects:ce,accessories:[{key:`attach`,label:d(`chatInputAttach`),icon:`paperclip`,iconOnly:!0,disabled:ee,onClick:()=>f.current?.click()}],skillPicker:le,actions:{sendError:a.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:n.sendDisabled,stopDisabled:n.stopDisabled,stopHint:d(`chatStopUnavailable`),sendButtonLabel:n.isSending?d(`chatQueueSend`):d(`chatSend`),stopButtonLabel:d(`chatStop`),contextWindow:t,onSend:n.send,onStop:n.stop}}}),(0,R.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:ne})]})});function tG(e){let{applyPromptSuggestion:t,consumeDraftIntent:n}=e,r=sY(),i=os();(0,L.useEffect)(()=>{if(!n)return;let e=e=>{i.chatSessionListManager.createSession(),i.chatSessionListManager.setSelectedAgentId(`main`),t(e.prompt),r.chatDraftIntentManager.markConsumed(e.id)},a=r.chatDraftIntentManager.subscribe(e),o=r.chatDraftIntentManager.consumePending();return o&&e(o),a},[r,t,n,i])}function nG(e){if(!e||typeof e!=`object`)return null;let t=e.chatDraft;return!t||typeof t!=`object`?null:t}function rG(e){let{sessionKey:t,setPendingProjectRoot:n,setPendingSessionType:r}=e,i=h(),a=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(t)return;let e=nG(i.state);if(!e)return;let o=[i.key,typeof e.sessionType==`string`?e.sessionType:``,typeof e.projectRoot==`string`?e.projectRoot:``].join(`:`);a.current!==o&&(a.current=o,typeof e.sessionType==`string`&&e.sessionType.trim()&&r(e.sessionType),n(typeof e.projectRoot==`string`&&e.projectRoot.trim()?e.projectRoot:null))},[i.key,i.state,t,n,r])}function iG({inputQuery:e}){let t=os(),n=e.isProviderStateResolved&&e.modelOptions.length===0,r=e.sessionTypeState.sessionTypeUnavailableMessage?.trim()||null;return(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-amber-800`,children:d(`chatModelNoOptions`)}),(0,R.jsx)(`button`,{type:`button`,onClick:t.chatUiManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:d(`chatGoConfigureProvider`)})]}):null,e.sessionTypeState.sessionTypeUnavailable&&r?(0,R.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,R.jsx)(`span`,{className:`text-xs text-amber-800`,children:r})}):null]})}function aG(e){let{consumeDraftIntent:t=!1,materializationContext:n=null,onSessionMaterialized:r,sessionKey:i,showWelcomeForDraft:a=!0}=e,o=Pe(),s=z(e=>e.snapshot.selectedAgentId),c=yH(i??void 0),{inputActions:l,inputSnapshot:u}=$U(),f=qU({sessionKey:i,inputSnapshot:u,setPendingSessionType:l.setPendingSessionType});rG({sessionKey:i,setPendingProjectRoot:l.setPendingProjectRoot,setPendingSessionType:l.setPendingSessionType});let p=bH(o),m=c.isRunning||f.selectedSession?.status===`running`,h=c.hydrateError?.message??c.snapshot.error?.message??null,g=o.phase===`ready`&&hH(h)?null:h,_=p?null:o.phase===`ready`?g:SH({message:g,status:o}),v=gU({agent:(0,L.useMemo)(()=>({...c,isRunning:m,isSending:c.isSending}),[c,m]),inputSnapshot:u,inputQuery:f,isRuntimeBlocked:p,materializationContext:n,selectedAgentId:s,sessionKey:i,onSessionMaterialized:r,resetComposer:l.resetComposer,restoreComposer:l.restoreComposer,setSendError:l.setSendError}),y=(0,L.useRef)(v);(0,L.useEffect)(()=>{y.current=v},[v]);let b=(0,L.useMemo)(()=>({canStopGeneration:v.canStopGeneration,deleteQueuedInput:e=>y.current.deleteQueuedInput(e),editQueuedInput:e=>y.current.editQueuedInput(e),isSending:v.isSending,queuedInputs:v.queuedInputs,send:()=>y.current.send(),sendDisabled:v.sendDisabled,stop:()=>y.current.stop(),stopDisabled:v.stopDisabled}),[v.canStopGeneration,v.isSending,v.queuedInputs,v.sendDisabled,v.stopDisabled]),x=(0,L.useMemo)(()=>wH(_z(c.snapshot.contextWindow)),[c.snapshot.contextWindow]),S=(0,L.useMemo)(()=>({...u,sendError:_??u.sendError}),[u,_]),C=f.selectedSession?.activityPreview,w=C?.state===`failed`&&(C.statusText?.trim()||C.replyText?.trim())||null,T=w?(0,R.jsxs)(`div`,{className:`rounded-lg border border-red-200/80 bg-red-50/80 px-3 py-2.5 shadow-sm`,children:[(0,R.jsx)(`div`,{className:`text-xs font-semibold text-red-800`,children:d(`chatSessionErrorTitle`)}),(0,R.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-5 text-red-700`,children:w})]}):null;tG({consumeDraftIntent:t,applyPromptSuggestion:l.applyPromptSuggestion});let E=(0,L.useCallback)(e=>(0,R.jsx)(eG,{contextWindow:x,controller:b,inputActions:l,inputQuery:f,inputSnapshot:S,surface:e}),[x,S,b,l,f]),D=a&&!i&&c.visibleMessages.length===0&&!c.isHydrating;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(iG,{inputQuery:f}),(0,R.jsx)(JB,{isAwaitingAssistantOutput:v.isSending&&m,isHistoryLoading:c.isHydrating,isSending:v.isSending,bottomSlot:T,messages:c.visibleMessages,sessionKey:i,showWelcome:D,welcomeSlot:(0,R.jsx)(HH,{inputSlot:E(`embedded`),pendingProjectRoot:u.pendingProjectRoot,pendingSessionType:u.pendingSessionType,selectedSessionTypeValue:u.selectedSessionType,onSelectProjectRoot:l.setPendingProjectRoot,onSelectPrompt:l.applyPromptSuggestion,onSelectSessionType:l.setPendingSessionType})}),D?null:E(`default`)]})}function oG({kind:e}){return e===`directory`?(0,R.jsx)(Ai,{className:`h-4 w-4 shrink-0 text-emerald-600`}):(0,R.jsx)(bi,{className:`h-4 w-4 shrink-0 text-sky-600`})}function sG(e){return`${e.kind===`directory`?d(`chatWorkspaceOpenDirectory`):d(`chatWorkspaceOpenFile`)}: ${e.name}`}function cG({browseQuery:e,onFileOpen:t,renderStatus:n}){let r=e.data?.entries??[],i=e.error?e.error instanceof Error?e.error.message:String(e.error):null,a=e=>{t({path:e.path,label:e.name,viewMode:`preview`})};return e.isLoading&&!e.data?n({text:d(`chatWorkspaceLoadingDirectory`)}):i&&!e.data?n({tone:`error`,text:`${d(`chatWorkspaceDirectoryLoadFailed`)}: ${i}`}):r.length===0?n({text:d(`chatWorkspaceDirectoryEmpty`)}):(0,R.jsx)(`div`,{"data-testid":`workspace-directory-browser`,className:`h-full overflow-auto bg-white px-2 py-2 custom-scrollbar`,children:(0,R.jsx)(`div`,{className:`space-y-0.5`,children:r.map(e=>(0,R.jsxs)(`button`,{type:`button`,"aria-label":sG(e),className:p(`flex h-8 w-full min-w-0 items-center gap-2 rounded-sm px-2 text-left text-sm text-gray-700 transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,e.hidden?`opacity-65`:null),onClick:()=>a(e),children:[(0,R.jsx)(oG,{kind:e.kind}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.kind===`directory`?(0,R.jsx)(ti,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}):null]},e.path))})})}function lG({kind:e}){return e===`directory`?(0,R.jsx)(Ai,{className:`h-3.5 w-3.5 shrink-0 text-emerald-600`}):(0,R.jsx)(Ti,{className:`h-3.5 w-3.5 shrink-0 text-sky-600`})}function uG({browsePath:e,onBrowsePathChange:t,onClose:n,onFileOpen:r}){let i=Xo({path:e,includeFiles:!0,enabled:!!e}),a=i.error?i.error instanceof Error?i.error.message:String(i.error):null,o=i.data?.entries??[],s=e=>{if(e.kind===`directory`){t(e.path);return}r({path:e.path,label:e.name,viewMode:`preview`}),n()};return(0,R.jsxs)(`div`,{"data-testid":`workspace-breadcrumb-browser`,className:`flex max-h-72 flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`border-b border-gray-200 px-2 py-1`,children:(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-0.5 text-[11px] leading-none text-gray-600`,children:i.data?.breadcrumbs.map((e,n)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`h-5 rounded-sm px-1 text-left hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,onClick:()=>t(e.path),children:e.label}),n<i.data.breadcrumbs.length-1?(0,R.jsx)(ti,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},e.path))})}),(0,R.jsx)(Zo,{className:`min-h-0 flex-1 px-1 py-1`,children:i.isLoading?(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-4 text-[11px] text-gray-500`,children:[(0,R.jsx)(vr,{className:`h-3.5 w-3.5 animate-spin`}),d(`loading`)]}):a?(0,R.jsxs)(`div`,{className:`px-2 py-3 text-[11px] text-rose-600`,children:[d(`pathBrowseFailed`),`: `,a]}):o.length>0?(0,R.jsx)(`div`,{className:`space-y-0.5`,children:o.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:p(`flex h-6 w-full items-center gap-1.5 rounded-sm px-1.5 text-left text-[11px] text-gray-700 transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,e.hidden?`opacity-65`:null),onClick:()=>s(e),children:[(0,R.jsx)(lG,{kind:e.kind}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.kind===`directory`?(0,R.jsx)(ti,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},e.path))}):(0,R.jsx)(`div`,{className:`px-2 py-4 text-[11px] text-gray-500`,children:d(`emptyDirectory`)})})]})}function dG({tone:e=`neutral`,value:t}){return(0,R.jsx)(`span`,{className:p(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function fG({onFileOpen:e,segment:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(t.browsePath);return(0,R.jsxs)(zo,{open:n,onOpenChange:e=>{e&&a(t.browsePath),r(e)},children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"aria-current":t.isCurrent?`page`:void 0,className:p(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none transition-colors hover:bg-gray-200/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,t.kind===`workspace`?`bg-primary/8 text-primary hover:bg-primary/12`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),disabled:!t.browsePath,children:[t.kind===`workspace`?(0,R.jsx)(Di,{className:`h-3 w-3 shrink-0`}):t.kind===`directory`&&t.isCurrent?(0,R.jsx)(Ai,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,R.jsx)(bi,{className:`h-3 w-3 shrink-0`}):null,(0,R.jsx)(`span`,{children:t.label})]})}),(0,R.jsx)(Ho,{"data-testid":`workspace-breadcrumb-popover`,className:`w-[22rem] rounded-md p-0`,align:`start`,children:(0,R.jsx)(uG,{browsePath:i,onBrowsePathChange:a,onClose:()=>r(!1),onFileOpen:e})})]})}function pG({breadcrumb:e,onFileOpen:t}){return(0,R.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,R.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((n,r)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(fG,{segment:n,onFileOpen:t}),r<e.segments.length-1?(0,R.jsx)(ti,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},n.key))}),e.locationLabel||e.truncated?(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,R.jsx)(dG,{value:e.locationLabel}):null,e.truncated?(0,R.jsx)(dG,{tone:`warning`,value:d(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function mG(e){return[`server-path-read`,e.path?.trim()??``,e.basePath??null]}function hG(e){let t=e.path?.trim()??``;return Me({queryKey:mG({path:t,basePath:e.basePath}),queryFn:()=>ht({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function gG(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function _G(e){return e.viewer===`rendered`&&/\.html?$/i.test(e.path)?`rendered`:`source`}function vG(e){let t=e.mimeType?.trim().toLowerCase()??``,n=e.path.trim().toLowerCase();return t.startsWith(`image/`)||/\.(avif|bmp|gif|heic|heif|ico|jpe?g|png|svg|tiff?|webp)$/i.test(n)?`image`:t.startsWith(`audio/`)||/\.(aac|flac|m4a|mp3|ogg|opus|wav|weba)$/i.test(n)?`audio`:t.startsWith(`video/`)||/\.(avi|m4v|mkv|mov|mp4|webm|wmv)$/i.test(n)?`video`:t.includes(`pdf`)||n.endsWith(`.pdf`)?`pdf`:t.includes(`html`)||/\.html?$/i.test(n)?`html`:`other`}function yG(e,t){return t<=0?e:`${e}${e.includes(`?`)?`&`:`?`}refresh=${t}`}function bG(e){let{languageHint:t,line:n,path:r,text:i}=e,a=n??1;return{key:`preview:${r}`,path:r,display:`preview`,lines:NL({text:i,kind:`context`,oldStartLine:a,newStartLine:a}),rawText:i,languageHint:t??null,oldStartLine:a,newStartLine:a}}function xG(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=LL({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function SG({text:e,tone:t=`muted`}){return(0,R.jsx)(`div`,{className:p(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function CG({diffBlock:e}){return e?(0,R.jsx)(wG,{block:e}):(0,R.jsx)(SG,{text:d(`chatWorkspaceDiffEmpty`)})}function wG({block:e}){return(0,R.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,R.jsx)(_F,{block:e,layout:`workspace`})})}function TG({src:e}){return(0,R.jsx)(`iframe`,{allowFullScreen:!0,className:`h-full w-full border-0 bg-white`,"data-testid":`workspace-html-preview`,src:e,title:d(`chatWorkspaceHtmlPreviewTitle`)})}function EG({contentUrl:e,kind:t,label:n}){return t===`image`?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto custom-scrollbar bg-white p-4`,children:(0,R.jsx)(`img`,{src:e,alt:n,className:`max-h-full max-w-full object-contain`,"data-testid":`workspace-content-image`})}):t===`audio`?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center bg-white px-6`,children:(0,R.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":n,className:`w-full max-w-xl`,"data-testid":`workspace-content-audio`,src:e})}):t===`video`?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center bg-black`,children:(0,R.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,"aria-label":n,className:`max-h-full max-w-full`,"data-testid":`workspace-content-video`,src:e})}):t===`pdf`||t===`html`?(0,R.jsx)(`iframe`,{allowFullScreen:!0,className:`h-full w-full border-0 bg-white`,"data-testid":t===`pdf`?`workspace-content-pdf`:`workspace-html-preview`,src:e,title:n}):(0,R.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-6 text-center`,"data-testid":`workspace-content-unsupported`,children:[(0,R.jsxs)(`div`,{className:`max-w-sm space-y-1.5`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,title:n,children:n}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(`chatWorkspacePreviewUnsupported`)}),(0,R.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground/80`,children:d(`chatWorkspacePreviewUnsupportedHint`)})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsx)(`a`,{href:e,download:n,className:`inline-flex h-8 items-center rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted`,children:d(`chatWorkspacePreviewDownload`)}),(0,R.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`inline-flex h-8 items-center rounded-lg bg-primary px-3 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90`,children:d(`chatWorkspacePreviewOpenExternally`)})]})]})}function DG({contentUrl:e,contentUrlKind:t,contentLabel:n,directoryQuery:r,onFileOpen:i,previewBlock:a,previewKind:o,previewQuery:s,previewText:c,previewUrl:l,previewViewer:u}){return e&&t?(0,R.jsx)(EG,{contentUrl:e,kind:t,label:n}):r?.data?(0,R.jsx)(cG,{browseQuery:r,onFileOpen:i,renderStatus:e=>(0,R.jsx)(SG,{...e})}):r?.isLoading&&s?.error&&!a?(0,R.jsx)(SG,{text:d(`chatWorkspaceLoadingDirectory`)}):(r?.isLoading||s?.isLoading)&&!a?(0,R.jsx)(SG,{text:d(`chatWorkspaceLoadingPreview`)}):s?.data?.kind===`binary`?(0,R.jsx)(SG,{text:d(`chatWorkspacePreviewUnsupported`)}):s?.error&&!a?(0,R.jsx)(SG,{tone:`error`,text:s.error instanceof Error?s.error.message:String(s.error)}):u===`rendered`&&l?(0,R.jsx)(TG,{src:l}):o===`markdown`&&c?(0,R.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,R.jsx)(QN,{text:c,role:`assistant`,texts:{copyCodeLabel:d(`chatCodeCopy`),copiedCodeLabel:d(`chatCodeCopied`)},onFileOpen:i})}):a?(0,R.jsx)(wG,{block:a}):(0,R.jsx)(SG,{text:d(`chatWorkspacePreviewEmpty`)})}function OG({file:e,refreshVersion:t=0,sessionProjectRoot:n,sessionWorkingDir:r,onFileOpen:i}){let a=e.viewMode===`preview`,o=e.contentUrl?.trim()||null,s=a&&!o,c=hG({path:e.path,basePath:r,enabled:s}),l=Xo({path:e.path,basePath:r,includeFiles:!0,enabled:s}),u=(0,L.useMemo)(()=>e.viewMode===`diff`?xG(e):null,[e]),d=a?c?.data?.text??e.rawText??null:null,f=gG({path:c?.data?.resolvedPath??e.path,serverKind:c?.data?.kind}),p=o?vG({path:e.path,mimeType:e.mimeType}):null,m=l?.data?.currentPath??c?.data?.resolvedPath??e.path,h=l?.data?`directory`:`file`,g=_G({path:m,viewer:e.previewViewer}),_=g===`rendered`&&c?.data?.resolvedPath?yG(vt(c.data.resolvedPath),t):null,v=(0,L.useMemo)(()=>!a||!d||o?null:bG({path:c?.data?.resolvedPath??e.path,text:d,languageHint:c?.data?.languageHint??null,line:e.line}),[o,e.line,e.path,a,c?.data?.languageHint,c?.data?.resolvedPath,d]),y=!!c?.data?.truncated,b=n??r;return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,R.jsx)(pG,{breadcrumb:(0,L.useMemo)(()=>Ds({path:m,kind:h,sessionProjectRoot:b,line:e.line,column:e.column,truncated:y}),[b,e.column,e.line,y,h,m]),onFileOpen:i}),(0,R.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,R.jsx)(CG,{diffBlock:u}):(0,R.jsx)(DG,{contentUrl:o,contentUrlKind:p,contentLabel:e.label?.trim()||m,directoryQuery:l,onFileOpen:i,previewBlock:v,previewKind:f,previewQuery:c,previewText:d,previewUrl:_,previewViewer:g})})]})}function kG({jobs:e}){let t=tl(),{confirm:n,ConfirmDialog:r}=Dr(),i=async e=>{await n({title:`${d(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:d(`delete`)})&&t.mutate({id:e.id})};return(0,R.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,R.jsxs)(`div`,{className:`mb-4`,children:[(0,R.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:d(`chatWorkspaceSessionCronJobs`)}),(0,R.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[d(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,R.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:d(`chatWorkspaceCronJobEmpty`)}):(0,R.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,R.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,R.jsxs)(Ut,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,R.jsx)(ha,{className:`h-3.5 w-3.5`}),d(`delete`)]})]}),(0,R.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[d(`cronScheduleLabel`),`:`]}),` `,fl(e)]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[d(`cronNextRun`),`:`]}),` `,il(e.state.nextRunAt)]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[d(`cronLastRun`),`:`]}),` `,il(e.state.lastRunAt)]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[d(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[d(`cronSessionLabel`),`:`]}),` `,pl(e)]})]}),(0,R.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,R.jsx)(r,{})]})}function AG({value:e}){return(0,R.jsx)(`span`,{className:`inline-flex max-w-full shrink-0 items-center rounded border border-gray-200 bg-gray-50 px-1.5 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,R.jsx)(`span`,{className:`truncate`,children:e})})}function jG({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,R.jsxs)(`div`,{className:`flex min-h-9 min-w-0 items-center gap-1.5 border-b border-gray-200/70 px-3 py-1.5 text-[11px] text-gray-500`,children:[t.map(e=>(0,R.jsx)(AG,{value:e},e)),e.projectRoot?(0,R.jsx)(`span`,{title:e.projectRoot,className:`min-w-0 flex-1 truncate rounded border border-gray-200 bg-gray-50 px-1.5 py-0.5 font-mono text-[10px] text-gray-500`,children:e.projectRoot}):null]})}function MG(){return(0,R.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[(0,R.jsx)(Hi,{className:`h-4 w-4 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`truncate`,children:d(`chatWorkspaceSideChatDraftTitle`)})]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500`,children:d(`chatWorkspaceSideChatDraftSubtitle`)})]})}function NG({activeSelection:e,filePreviewRefreshVersion:t,sessionCronJobs:n,sessionProjectRoot:r,sessionWorkingDir:i}){let a=os();return e.kind===`side-chat-draft`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(MG,{}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(aG,{materializationContext:{kind:`child`,parentSessionKey:e.draft.parentSessionKey,inheritContext:!0},sessionKey:null,showWelcomeForDraft:!1,onSessionMaterialized:t=>a.chatThreadManager.materializeSideChatDraft({draftKey:e.draft.draftKey,sessionKey:t})})})]}):e.kind===`child-session`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(jG,{tab:e.tab}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(aG,{sessionKey:e.tab.sessionKey})})]}):e.kind===`file`?(0,R.jsx)(OG,{file:e.file,refreshVersion:t,sessionProjectRoot:r,sessionWorkingDir:i,onFileOpen:a.chatThreadManager.openFilePreview}):(0,R.jsx)(kG,{jobs:n})}function PG(e){return e.index>0&&e.entries.length>0}function FG(e){return e.index>=0&&e.index<e.entries.length-1}function IG(e,t,n=Object.is){let r=zG(e),i=e.entries[r];if(i&&n(i,t))return{entries:e.entries,index:r};let a=[...e.entries.slice(0,r+1),t];return{entries:a,index:a.length-1}}function LG(e,t){let n=zG(e),r=t===`back`?n-1:n+1,i=e.entries[r];return i?{history:{entries:e.entries,index:r},entry:i}:null}function RG(e,t,n){let r=zG(e),i=e.entries.filter(t);if(i.length===0)return n===void 0?{entries:[],index:0}:{entries:[n],index:0};let a=e.entries.slice(0,r+1).filter(t);return{entries:i,index:Math.min(Math.max(0,a.length-1),i.length-1)}}function zG(e){return e.entries.length===0?0:Number.isInteger(e.index)?Math.min(Math.max(0,e.index),e.entries.length-1):e.entries.length-1}function BG({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,activeSideChatDraft:r,workspaceFileTabs:i,activeWorkspaceFileKey:a,workspaceNavigationHistory:o=[],workspaceNavigationHistoryIndex:s=0,activePanelKind:c,sessionCronJobs:l=[],sessionProjectRoot:u,sessionWorkingDir:d,displayMode:f=`docked`}){let m=os(),h=Be(),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(0),b=iu(t),x=z(e=>e.optimisticReadAtBySessionKey),S=ou({activeChildSessionKey:n,activeSideChatDraft:r,activeWorkspaceFileKey:a,activePanelKind:c,childSessionTabs:b,workspaceFileTabs:i,sessionCronJobCount:l.length}),C={entries:o,index:s};(0,L.useEffect)(()=>{m.chatThreadManager.syncVisibleWorkspaceSelection(S)},[S,m]);let w=(0,L.useMemo)(()=>su({resolvedChildTabs:b,activeSideChatDraft:r,workspaceFileTabs:i,sessionCronJobCount:l.length,activeSelection:S,optimisticReadAtBySessionKey:x,onSelectSession:m.chatThreadManager.selectChildSessionDetail,onSelectFile:m.chatThreadManager.selectWorkspaceFile,onCloseFile:m.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&m.chatThreadManager.openSessionCronPanel(e)}}),[S,r,x,m.chatThreadManager,b,e,i,l.length]);if(!S)return null;let T=f===`docked`&&g,E=f===`overlay`||T,D=S.kind===`file`&&S.file.viewMode===`preview`?S.file:null,O=D?()=>{h.invalidateQueries({queryKey:mG({path:D.path,basePath:d})}),h.invalidateQueries({queryKey:Yo({path:D.path,basePath:d,includeFiles:!0})}),y(e=>e+1)}:void 0;return(0,R.jsxs)(Dn,{"data-testid":`chat-session-workspace-panel`,className:p(E?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`,T?`shadow-xl`:null),defaultWidth:480,minWidth:360,maxWidth:860,overlay:E,overlayScope:T?`container`:`viewport`,children:[(0,R.jsx)(uu,{tabs:w,canGoBack:PG(C),canGoForward:FG(C),isMaximized:T,onGoBack:m.chatThreadManager.goBackWorkspacePanel,onGoForward:m.chatThreadManager.goForwardWorkspacePanel,onRefreshFile:O,onToggleMaximize:f===`docked`?()=>_(e=>!e):void 0,onClose:m.chatThreadManager.closeWorkspacePanel}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:(0,R.jsx)(NG,{activeSelection:S,filePreviewRefreshVersion:v,sessionCronJobs:l,sessionProjectRoot:u,sessionWorkingDir:d})})]})}function VG({layoutMode:e,sessionKey:t}){let n=Ul(e=>e.snapshot),r=wl(t),{childSessionTabs:i,activeSideChatDraft:a,workspaceFileTabs:o,sessionCronJobs:s,showWorkspacePanel:c}=xl(n,t);return c?(0,R.jsx)(BG,{sessionKey:t,childSessionTabs:i,activeChildSessionKey:n.activeChildSessionKey??null,activeSideChatDraft:a,workspaceFileTabs:o,activeWorkspaceFileKey:n.activeWorkspaceFileKey??null,workspaceNavigationHistory:n.workspaceNavigationHistory,workspaceNavigationHistoryIndex:n.workspaceNavigationHistoryIndex,activePanelKind:n.activeWorkspacePanelKind??null,sessionCronJobs:s,sessionProjectRoot:r?.projectRoot??null,sessionWorkingDir:r?.workingDir??r?.projectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function HG({layoutMode:e=`desktop`,onBackToList:t}){let n=os(),r=Cl(),i=z(e=>e.snapshot.selectedSessionKey),a=(0,L.useCallback)(e=>{n.chatUiManager.isAtChatRoot()&&n.chatUiManager.goToSession(e,{replace:!0})},[n]);return r?(0,R.jsxs)(`section`,{className:`relative flex-1 min-h-0 flex overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,R.jsx)(eu,{}),(0,R.jsx)($l,{layoutMode:e,onBackToList:t}),(0,R.jsx)(aG,{consumeDraftIntent:!0,sessionKey:i,onSessionMaterialized:a})]}),(0,R.jsx)(VG,{layoutMode:e,sessionKey:i})]}):(0,R.jsx)(nu,{})}function UG(){let e=Wo(),[t,n]=(0,L.useState)(null),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}var WG=`nextclaw.ui.theme`,GG=`work`,KG=[{value:`work`,labelKey:`themeWork`,appearance:`light`},{value:`night`,labelKey:`themeNight`,appearance:`dark`},{value:`natural`,labelKey:`themeNatural`,appearance:`light`},{value:`minimal`,labelKey:`themeMinimal`,appearance:`light`},{value:`warm`,labelKey:`themeWarm`,appearance:`light`},{value:`cool`,labelKey:`themeCool`,appearance:`light`},{value:`dawn`,labelKey:`themeDawn`,appearance:`light`},{value:`graphite`,labelKey:`themeGraphite`,appearance:`light`},{value:`probe`,labelKey:`themeProbe`,appearance:`light`}],qG=KG.map(({value:e})=>e),JG=KG.map(({value:e,labelKey:t})=>({value:e,labelKey:t}));function YG(e){return typeof e==`string`?qG.includes(e)?e:e===`leaf`?`warm`:null:null}function XG(e){return KG.find(t=>t.value===e)?.appearance??`light`}var ZG=new class{constructor(){this.activeTheme=GG,this.initialized=!1,this.listeners=new Set,this.resolveInitialTheme=()=>{if(typeof window>`u`)return GG;try{let e=YG(window.localStorage.getItem(WG));if(e)return e}catch{}return GG},this.initializeTheme=()=>(this.initialized||=(this.activeTheme=this.resolveInitialTheme(),this.applyThemeAttribute(this.activeTheme),!0),this.activeTheme),this.getTheme=()=>this.initialized?this.activeTheme:this.initializeTheme(),this.setTheme=e=>{this.initializeTheme(),e!==this.activeTheme&&(this.activeTheme=e,this.applyThemeAttribute(this.activeTheme),this.saveTheme(this.activeTheme),this.listeners.forEach(e=>e(this.activeTheme)))},this.subscribeThemeChange=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.applyThemeAttribute=e=>{if(typeof document>`u`)return;let t=XG(e);document.documentElement.setAttribute(`data-theme`,e),document.documentElement.setAttribute(`data-theme-appearance`,t),document.documentElement.style.colorScheme=t},this.saveTheme=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(WG,e)}catch{}}}};function QG(){return ZG.initializeTheme()}function $G(){return ZG.getTheme()}function eK(e){ZG.setTheme(e)}function tK(e){return ZG.subscribeThemeChange(e)}var nK=`nextclaw-pwa-install-banner-dismissed`,rK=`nextclaw-pwa-install-banner-dismissed-until`;function iK(){let e=sK();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:cK(e):!1}function aK(){let e=sK();e?.setItem(nK,`1`),e?.removeItem(rK)}function oK(){let e=sK();e?.removeItem(nK),e?.removeItem(rK)}function sK(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function cK(e){let t=e.getItem(rK);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(rK),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(nK,`1`),!0)}function lK(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:iK()}}var uK=f(()=>lK()),dK=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),uK.setState(lK())},this.refreshState=()=>{let e=this.resolveInstallability();uK.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:iK()}))},this.dismissInstallPrompt=()=>{aK(),uK.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(oK(),this.refreshState(),P.success(d(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,oK(),uK.setState({dismissedInstallPrompt:!0}),P.success(d(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function fK(){let e=uK(e=>e.installability);return(0,R.jsx)(`span`,{className:p(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:pK(e)})}function pK(e){return d(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function mK(e,t,n){return d(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function hK(){let e=uK(e=>e.installability),t=uK(e=>e.installMethod),n=uK(e=>e.blockedReason);return(0,R.jsxs)(Wt,{children:[(0,R.jsxs)(Bt,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(Gt,{children:d(`pwaInstallTitle`)}),(0,R.jsx)(Ht,{children:d(`pwaInstallDescription`)})]}),(0,R.jsx)(fK,{})]}),(0,R.jsxs)(Kt,{className:`space-y-4`,children:[(0,R.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,R.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:mK(e,t,n)})}),e===`available`&&t===`prompt`?(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsxs)(Ut,{type:`button`,className:`gap-2`,onClick:()=>{dK.promptInstall()},children:[(0,R.jsx)(pi,{className:`h-4 w-4`}),d(`pwaInstallAction`)]}),(0,R.jsx)(`p`,{className:`text-sm text-gray-500`,children:d(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,R.jsx)(la,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,R.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:d(`pwaInstallManualHint`)})]}):null]})]})}function gK(){let e=uK(e=>e.installability),t=uK(e=>e.installMethod),n=uK(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,R.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:d(`pwaInstallBannerTitle`)}),(0,R.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:d(`pwaInstallBannerDescription`)})]}),(0,R.jsx)(`button`,{type:`button`,"aria-label":d(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{dK.dismissInstallPrompt()},children:(0,R.jsx)(Cr,{className:`h-4 w-4`})})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,R.jsxs)(Ut,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{dK.promptInstall()},children:[(0,R.jsx)(pi,{className:`h-4 w-4`}),d(`pwaInstallAction`)]}),(0,R.jsx)(Ut,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{dK.dismissInstallPrompt()},children:d(`pwaInstallDismiss`)})]})]})}var _K=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},vK=!1;function yK(){vK||typeof window>`u`||(vK=!0,dK.start(),_K.start())}var bK={natural:`#FAF9F7`,work:`#FFFFFF`,minimal:`#FFFFFF`,warm:`#FAF8F4`,cool:`#F8FAFC`,dawn:`#FAF7F4`,graphite:`#F8F8F7`,night:`#101318`,probe:`#FEFCF6`},xK=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=bK[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=XG(e)},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`);this.syncTheme(YG(e)??`work`)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},SK=(0,L.createContext)(null);function CK({children:e}){let[t,n]=(0,L.useState)(()=>QG());(0,L.useEffect)(()=>{xK.syncTheme(t)},[t]),(0,L.useEffect)(()=>tK(e=>{n(e)}),[]);let r=(0,L.useCallback)(e=>{eK(e),n($G())},[]),i=(0,L.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,R.jsx)(SK.Provider,{value:i,children:e})}function wK(){let e=(0,L.useContext)(SK);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function TK({sessionKey:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(Oe,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:d(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(En,{icon:(0,R.jsx)(cr,{className:`h-3.5 w-3.5`}),label:d(`save`),tooltip:!1,onClick:()=>void i(),disabled:n}),(0,R.jsx)(En,{icon:(0,R.jsx)(Cr,{className:`h-3.5 w-3.5`}),label:d(`cancel`),tooltip:!1,onClick:a,disabled:n})]})]})]})}function EK({active:e,showUnreadDot:t,runStatus:n,context:r,isPinned:i,title:a,previewText:o,trailingText:s,agentId:c,agentLabel:l,agentAvatarUrl:u,childSessionCount:f=0,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onTogglePinned:_}){return(0,R.jsxs)(`div`,{className:`group/session relative`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:m,className:`w-full text-left`,children:[(0,R.jsx)(`div`,{className:p(`flex min-h-6 min-w-0 items-center`,f>0&&h?`pr-20`:`pr-12`),children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c?.trim()&&c.trim().toLowerCase()!==`main`?(0,R.jsx)(Kl,{agentId:c,displayName:l,avatarUrl:u,className:`h-5 w-5 shrink-0`}):null,(0,R.jsx)(`span`,{className:`truncate leading-6 font-medium`,children:a}),r.label?(0,R.jsx)(`span`,{className:p(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,e?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:r.label}):null,r.icon?(0,R.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,R.jsx)(Ac,{icon:r.icon,className:e?`text-gray-700`:`text-gray-500`})}):null]})}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:o}),t?(0,R.jsx)(`span`,{"aria-label":d(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,R.jsx)(`span`,{className:`ml-auto shrink-0`,children:s})]})]}),f>0&&h?(0,R.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h()},className:p(`absolute right-12 top-0 inline-flex h-6 items-center gap-1 rounded-md px-1.5 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-black/10 hover:text-foreground`,e?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":d(`chatSessionOpenChildSessions`),title:d(`chatSessionOpenChildSessions`),children:[(0,R.jsx)(ji,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{children:f})]}):null,n?(0,R.jsx)(`span`,{className:`absolute right-0 top-0 inline-flex h-6 w-6 items-center justify-center transition-opacity group-hover/session:opacity-0 group-focus-within/session:opacity-0`,children:(0,R.jsx)(Mc,{status:n})}):null,(0,R.jsxs)(`div`,{className:`absolute right-0 top-0 flex h-6 items-center gap-0.5 opacity-0 transition-opacity group-hover/session:opacity-100 group-focus-within/session:opacity-100`,children:[(0,R.jsx)(En,{size:`sm`,tone:`strong`,icon:(0,R.jsx)(Tn,{className:p(`h-3.5 w-3.5`,i&&`fill-current text-foreground`)}),label:d(i?`chatSidebarUnpinSession`:`chatSidebarPinSession`),tooltipSide:`right`,onClick:e=>{e.stopPropagation(),_()}}),(0,R.jsx)(En,{size:`sm`,tone:`strong`,icon:(0,R.jsx)(Qi,{className:`h-3.5 w-3.5`}),label:d(`edit`),tooltipSide:`right`,onClick:e=>{e.stopPropagation(),g()}})]})]})}function DK({sessionKey:e,active:t,showUnreadDot:n,runStatus:r,context:i,isPinned:a,title:o,previewText:s,trailingText:c,agentId:l,agentLabel:u,agentAvatarUrl:d,childSessionCount:f,isEditing:m,draftLabel:h,isSaving:g,onSelect:_,onOpenChildSessions:v,onStartEditing:y,onDraftLabelChange:b,onSave:x,onCancel:S,onTogglePinned:C}){return(0,R.jsx)(`div`,{className:p(`w-full rounded-xl px-3 py-2.5 text-left transition-all text-[13px]`,t?`bg-gray-200/80 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:m?(0,R.jsx)(TK,{sessionKey:e,draftLabel:h,isSaving:g,onDraftLabelChange:b,onSave:x,onCancel:S}):(0,R.jsx)(EK,{active:t,showUnreadDot:n,runStatus:r,context:i,isPinned:a,title:o,previewText:s,trailingText:c,agentId:l,agentLabel:u,agentAvatarUrl:d,onSelect:_,childSessionCount:f,onOpenChildSessions:v,onStartEditing:y,onTogglePinned:C})})}function OK(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTypeOptions:l,isPinned:u,sessionTitle:d,onSelectSession:f,onOpenChildSessions:p,onStartEditingSessionLabel:m,onDraftLabelChange:h,onSaveSessionLabel:g,onCancelEditingSessionLabel:_,onTogglePinned:v}=e,{session:y,runStatus:b}=t,x=n===y.key,S=r[y.key],C=S&&y.readAt?S.localeCompare(y.readAt)>0?S:y.readAt:S??y.readAt,w=a.get(y.key)??[],T=y.agentId?i.get(y.agentId)?.displayName??y.agentId:null,E=cs(y)??`${T?.trim()?`${T} · `:``}${y.messageCount}`;return(0,R.jsx)(DK,{sessionKey:y.key,active:x,showUnreadDot:ic({active:x,lastMessageAt:y.lastMessageAt,readAt:C,runStatus:b}),runStatus:b,context:Tc(y,l),isPinned:u,title:d(y),previewText:E,trailingText:fs(y.lastMessageAt??y.createdAt),agentId:y.agentId??null,agentLabel:T,agentAvatarUrl:y.agentId?i.get(y.agentId)?.avatarUrl??null:null,childSessionCount:w.length,isEditing:o===y.key,draftLabel:s,isSaving:c===y.key,onSelect:()=>f(y.key),onOpenChildSessions:()=>p(y.key,w[0]?.session.key??null),onStartEditing:()=>m(y),onDraftLabelChange:h,onSave:()=>g(y),onCancel:_,onTogglePinned:v})}var kK={maxHeight:Lo(`18rem`)};function AK({className:e,onSelect:t,options:n,selectedSessionType:r,title:i=d(`chatSessionTypeLabel`),titleClassName:a}){return(0,R.jsxs)(`div`,{className:p(`space-y-1 overflow-y-auto overscroll-contain`,e),style:kK,children:[(0,R.jsx)(`div`,{className:p(`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,a),children:i}),n.map(e=>(0,R.jsx)(jH,{disabled:e.ready===!1,option:e,selected:e.value===r,onSelect:()=>t(e.value)},e.value))]})}var jK=`w-[56px]`,MK=`px-2`,NK=`h-9 w-9 rounded-xl`,PK=`h-4 w-4`,FK=`space-y-1`,IK=`gap-1`,LK=`[mask-image:linear-gradient(to_bottom,black_calc(100%_-_28px),transparent)] [-webkit-mask-image:linear-gradient(to_bottom,black_calc(100%_-_28px),transparent)]`,RK=`text-muted-foreground transition-colors duration-base hover:bg-gray-200/60 hover:text-gray-900 active:bg-gray-200/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,zK=`bg-gray-200/80 text-gray-900`,BK=`brandSoft`,VK={neutralSurface:{leftVariant:`ghost`,leftClassName:`bg-card text-foreground shadow-none transition-[background-color,color,box-shadow] hover:bg-accent hover:text-accent-foreground hover:shadow-sm active:bg-accent`,rightClassName:`bg-card text-muted-foreground shadow-none transition-[background-color,color,box-shadow] hover:bg-accent hover:text-accent-foreground hover:shadow-sm active:bg-accent`},brandSoft:{leftVariant:`ghost`,leftClassName:`bg-primary/10 text-primary shadow-none ring-1 ring-primary/10 transition-[background-color,color,box-shadow] hover:bg-primary/15 hover:text-primary-700 hover:shadow-sm active:bg-primary/20`,rightClassName:`bg-primary/10 text-primary shadow-none ring-1 ring-primary/10 transition-[background-color,color,box-shadow] hover:bg-primary/15 hover:text-primary-700 hover:shadow-sm active:bg-primary/20`},brandTextSurface:{leftVariant:`ghost`,leftClassName:`bg-card text-primary shadow-none transition-[background-color,color,box-shadow] hover:bg-accent hover:text-primary-700 hover:shadow-sm active:bg-primary/15`,rightClassName:`bg-card text-primary shadow-none transition-[background-color,color,box-shadow] hover:bg-accent hover:text-primary-700 hover:shadow-sm active:bg-primary/15`},brandSolid:{leftVariant:`primary`,leftClassName:``,rightClassName:`bg-primary text-primary-foreground shadow-sm hover:bg-primary-600 hover:text-primary-foreground active:bg-primary-700`}};function HK(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function UK({option:e}){return e?.icon?.src?(0,R.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:(0,R.jsx)(Ac,{icon:{kind:`runtime-image`,src:e.icon.src,alt:e.icon.alt??null,name:e.label},className:`h-4 w-4`})}):(0,R.jsx)(Xr,{className:`h-4 w-4 shrink-0`})}function WK(e){let{query:t,selectedNewSessionType:n,selectedNewSessionTypeOption:r,sessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:s,onSelectNewSessionType:c,onQueryChange:l,collapsed:u=!1}=e,f=i.length>1,m=VK[BK];return u?(0,R.jsx)(`div`,{className:`px-2 pb-2`,children:(0,R.jsxs)(`div`,{className:p(`flex flex-col items-center`,IK),children:[(0,R.jsx)(En,{icon:(0,R.jsx)(yr,{className:PK}),label:d(`chatSidebarNewTask`),className:p(NK,RK),onClick:()=>{o(!1),s(n)}}),f?(0,R.jsxs)(zo,{open:a,onOpenChange:o,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(En,{icon:(0,R.jsx)(UK,{option:r}),label:d(`chatSessionTypeLabel`),className:p(NK,RK)})}),(0,R.jsx)(Ho,{align:`start`,side:`right`,className:`w-56 rounded-2xl border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:(0,R.jsx)(AK,{options:i,selectedSessionType:n,onSelect:e=>{c(e),o(!1)}})})]}):null]})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-4 pb-3`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(Ut,{variant:m.leftVariant,className:p(`min-w-0 rounded-xl`,m.leftClassName,f?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{o(!1),s(n)},children:[(0,R.jsx)(yr,{className:`mr-2 h-4 w-4`}),d(`chatSidebarNewTask`)]}),f?(0,R.jsxs)(zo,{open:a,onOpenChange:o,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(En,{icon:(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(UK,{option:r}),(0,R.jsx)(Vn,{className:`h-3 w-3 opacity-60`})]}),label:d(`chatSessionTypeLabel`),tooltip:d(`chatSessionTypeLabel`),className:p(`h-9 w-12 shrink-0 rounded-xl rounded-l-md`,m.rightClassName)})}),(0,R.jsx)(Ho,{align:`end`,className:`w-56 rounded-2xl border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:(0,R.jsx)(AK,{options:i,selectedSessionType:n,onSelect:e=>{c(e),o(!1)}})})]}):null]})}),(0,R.jsx)(`div`,{className:`px-4 pb-3`,children:(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground/70`}),(0,R.jsx)(Oe,{value:t,onChange:e=>l(e.target.value),placeholder:d(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function GK(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:s,onQueryChange:c}=e,l=HK({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),u=l.length>1;return(0,R.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,R.jsx)(wn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,R.jsx)(Oe,{value:t,onChange:e=>c(e.target.value),placeholder:d(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-muted pl-9 pr-3 text-[13px] shadow-none focus:border-border focus:bg-card`})]}),u?(0,R.jsxs)(zo,{open:a,onOpenChange:o,children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(En,{icon:(0,R.jsx)(yr,{className:`h-4 w-4`}),label:d(`chatSidebarNewTask`),tooltip:!1,className:`h-9 w-9 shrink-0 rounded-full bg-muted text-foreground shadow-none hover:bg-accent hover:text-accent-foreground`})}),(0,R.jsx)(Ho,{align:`end`,className:`w-60 rounded-3xl border border-border bg-popover p-2 text-popover-foreground shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:(0,R.jsx)(AK,{options:l,selectedSessionType:n,title:d(`chatSidebarNewTask`),titleClassName:`pb-1.5 text-[11px] font-medium normal-case tracking-normal`,onSelect:e=>{s(e),o(!1)}})})]}):(0,R.jsx)(En,{icon:(0,R.jsx)(yr,{className:`h-4 w-4`}),label:d(`chatSidebarNewTask`),className:`h-9 w-9 shrink-0 rounded-full bg-muted text-foreground shadow-none hover:bg-accent hover:text-accent-foreground`,onClick:()=>s(n)})]})})}function KK(){return Me({queryKey:[`app-meta`],queryFn:ue,staleTime:1/0})}var qK={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-muted-foreground/45 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function JK(){let e=Et(),t=e.actionLabel===d(`runtimeStatusRestartAction`),n=()=>{e.tone!==`healthy`&&wt.requestRuntimeBootstrapProbeNow()},r=async()=>{if(t)try{let e=await wt.runRuntimeControlAction(`restart-service`);P.success(e.message)}catch(e){let t=e instanceof Error?e.message:d(`runtimeControlActionFailed`);P.error(`${d(`runtimeControlActionFailed`)}: ${t}`)}};return(0,R.jsxs)(zo,{children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,onClick:n,children:(0,R.jsx)(`span`,{className:p(`h-2.5 w-2.5 rounded-full`,qK[e.tone])})})}),(0,R.jsxs)(Ho,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-border bg-popover p-4 text-popover-foreground`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:e.title}),(0,R.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:e.description})]}),e.reasonLines.length>0?(0,R.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,R.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border/70 pt-1`,children:[(0,R.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:d(`runtimeStatusActionHint`)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void r(),disabled:e.isBusy,className:`text-sm font-semibold text-primary transition-colors hover:text-primary-hover disabled:text-muted-foreground/45`,children:e.isBusy?d(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function YK({className:e,density:t=`sidebar`,suffix:n}){let{data:r}=KK(),i=r?.name??`NextClaw`,a=r?.productVersion?.trim(),o=a?`v${a}`:null,s=n??(0,R.jsx)(JK,{}),c=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,l=t===`chrome`;return(0,R.jsxs)(`div`,{className:p(e??`flex min-w-0 items-center gap-2`,c&&`pl-[58px]`),children:[(0,R.jsx)(`div`,{className:p(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,R.jsx)(`img`,{src:`/logo.svg`,alt:i,className:`h-full w-full object-contain`})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{className:p(`shrink-0 font-semibold text-gray-800`,l?`text-[15px]`:`text-[14px]`),children:i}),o?(0,R.jsx)(XK,{versionLabel:o,density:t}):null]}),(0,R.jsx)(ZK,{}),s?(0,R.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:s}):null]})]})}function XK({versionLabel:e,density:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[(0,R.jsx)(`span`,{tabIndex:0,"aria-label":e,className:p(`block min-w-0 truncate font-medium text-gray-500 outline-none`,`text-[12px]`),children:e}),n?(0,R.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function ZK(){let{supported:e,busyAction:t,snapshot:n}=Ot();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,R.jsx)(QK,{snapshot:n}):n.status===`downloaded`?(0,R.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void Ct.applyDownloadedUpdate(),children:d(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,R.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void Ct.downloadUpdate(),children:d(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function QK({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,R.jsx)($K,{snapshot:e});let t=e.status===`downloading`?eq(e):null;return t?(0,R.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,title:d(`updates`),children:t}):null}function $K({snapshot:e}){let t=e.status===`failed`?d(`desktopUpdatesStatusFailed`):d(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,i=[t,e.status===`blocked`&&e.blockReason?d(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
104
+ `);return(0,R.jsx)(`span`,{role:`img`,"aria-label":t,title:i,tabIndex:0,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-50 text-[13px] font-bold leading-none text-amber-700 ring-1 ring-amber-100`,children:`!`})}function eq(e){let t=e.progress?.percent;return t==null?d(`desktopUpdatesInlineDownloading`):d(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var tq={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function nq({status:e,className:t}){let n=tq[e],r=d(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,R.jsx)(Ln,{delayDuration:250,children:(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`span`,{role:`status`,"aria-label":r,className:p(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,R.jsx)(vr,{className:p(`h-3 w-3 animate-spin`,n.dotClass)}):(0,R.jsx)(`span`,{className:p(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,R.jsx)(Fn,{side:`bottom`,className:`text-xs`,children:r})]})})}function rq({isProjectFirstView:e,onSelectMode:t}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:p(`transition-colors`,e?`text-muted-foreground/65 hover:text-muted-foreground`:`font-medium text-foreground`),children:d(`chatSidebarViewTime`)}),(0,R.jsx)(`span`,{className:`text-muted-foreground/35`,children:`/`}),(0,R.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:p(`transition-colors`,e?`font-medium text-foreground`:`text-muted-foreground/65 hover:text-muted-foreground`),children:d(`chatSidebarViewProject`)})]})}var iq={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function aq(e){return iq[e]}function oq(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function sq({children:e,label:t,side:n=`right`}){return(0,R.jsx)(Ln,{delayDuration:250,children:(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:e}),(0,R.jsx)(Fn,{side:n,className:`text-xs`,children:t})]})})}function cq({to:e,label:t,icon:n,density:r=`default`,className:i,collapsed:a=!1}){let o=aq(r),{pathname:s}=h(),c=oq(s,e),l=(0,R.jsxs)(y,{to:e,"aria-label":t,"aria-current":c?`page`:void 0,className:p(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,a?p(NK,`justify-center px-0 py-0`):o.row,c?a?zK:`bg-gray-200/80 text-gray-900 shadow-sm`:a?RK:`text-muted-foreground hover:bg-gray-200/60 hover:text-gray-900`,i),children:[(0,R.jsx)(n,{className:p(a?PK:o.icon,`shrink-0 transition-colors`,c?`text-gray-700`:`text-muted-foreground group-hover:text-gray-700`)}),(0,R.jsx)(`span`,{className:a?`sr-only`:`min-w-0 flex-1 text-left`,children:t})]});return a?(0,R.jsx)(sq,{label:t,children:l}):l}function lq({isCollapsed:e,items:t,density:n,className:r}){return(0,R.jsx)(`ul`,{className:r,children:t.map(t=>(0,R.jsx)(`li`,{className:e?`flex justify-center`:void 0,children:(0,R.jsx)(cq,{to:t.target,label:t.label,icon:t.icon,density:n,collapsed:e})},t.target))})}function uq({label:e,icon:t,onClick:n,density:r=`default`,className:i,labelClassName:a,trailing:o,trailingClassName:s,testId:c,trailingTestId:l,collapsed:u=!1}){let d=aq(r),f=(0,R.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":e,className:p(`group flex w-full items-center rounded-xl font-medium text-muted-foreground transition-colors duration-base hover:bg-gray-200/60 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,u?p(NK,`justify-center px-0 py-0`,RK):d.row,i),"data-testid":c,children:[(0,R.jsx)(t,{className:p(u?PK:d.icon,`shrink-0 text-muted-foreground transition-colors group-hover:text-gray-700`)}),(0,R.jsx)(`span`,{className:p(u?`sr-only`:`min-w-0 flex-1 text-left`,a),children:e}),!u&&o?(0,R.jsx)(`span`,{className:p(`shrink-0 text-muted-foreground`,d.value,s),"data-testid":l,children:o}):null]});return u?(0,R.jsx)(sq,{label:e,children:f}):f}function dq({label:e,icon:t,value:n,valueLabel:r,onValueChange:i,density:a=`default`,children:o,collapsed:s=!1}){let c=aq(a),l=(0,R.jsxs)(Zn,{"aria-label":e,className:p(`group h-auto w-full rounded-xl border-0 bg-transparent font-medium text-muted-foreground shadow-none hover:bg-gray-200/60 hover:text-gray-900 focus:ring-0 focus-visible:ring-1 focus-visible:ring-border`,s?p(NK,`justify-center px-0 py-0`,RK):c.row),children:[(0,R.jsxs)(`div`,{className:p(`flex min-w-0 items-center`,s?`justify-center`:c.gap),children:[(0,R.jsx)(t,{className:p(s?PK:c.icon,`shrink-0 text-muted-foreground/75 transition-colors group-hover:text-gray-700`)}),(0,R.jsx)(`span`,{className:s?`sr-only`:`text-left`,children:e})]}),s?null:(0,R.jsx)(`span`,{className:p(`ml-auto text-muted-foreground`,c.value),children:r})]});return(0,R.jsxs)(ar,{value:n,onValueChange:i,children:[s?(0,R.jsx)(sq,{label:`${e}: ${r}`,children:l}):l,(0,R.jsx)(er,{children:o})]})}function fq(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function pq(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i}=e,a=os(),o=z(e=>e.snapshot.collapsedProjectRoots),[s,c]=(0,L.useState)(null),l=(0,L.useMemo)(()=>fq(n,r),[n,r]),u=r.length>1;return(0,R.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${d(`chatSidebarNewTask`)} · ${e.projectName}`,n=o.includes(e.projectRoot),f=d(e.isPinned?`chatSidebarUnpinProject`:`chatSidebarPinProject`);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`group/project relative h-10 rounded-lg px-2 text-muted-foreground transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":!n,"aria-label":d(n?`chatSidebarExpandProject`:`chatSidebarCollapseProject`),className:`flex h-full w-full min-w-0 items-center gap-1.5 pr-14 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,onClick:()=>a.chatSessionListManager.toggleProjectCollapsed(e.projectRoot),children:[(0,R.jsx)(Ai,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wider`,title:e.projectRoot,children:e.projectName}),n?(0,R.jsx)(ti,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}):(0,R.jsx)(Vn,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:e.items.length})]}),(0,R.jsxs)(`div`,{className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center opacity-0 transition-opacity group-hover/project:pointer-events-auto group-hover/project:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100`,children:[u?(0,R.jsxs)(zo,{open:s===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(En,{icon:(0,R.jsx)(yr,{className:`h-3.5 w-3.5`}),label:t})}),(0,R.jsx)(Ho,{align:`end`,className:`w-56 rounded-2xl border border-border bg-popover p-1.5 text-popover-foreground shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:(0,R.jsx)(AK,{options:r,selectedSessionType:l,onSelect:t=>{a.chatSessionListManager.createSession(t,e.projectRoot),c(null)}})})]}):(0,R.jsx)(En,{icon:(0,R.jsx)(yr,{className:`h-3.5 w-3.5`}),label:t,onClick:()=>a.chatSessionListManager.createSession(l,e.projectRoot)}),(0,R.jsx)(En,{icon:(0,R.jsx)(Tn,{className:e.isPinned?`h-3.5 w-3.5 fill-current text-foreground`:`h-3.5 w-3.5`}),label:f,tooltipSide:`right`,onClick:()=>a.chatSessionListManager.toggleProjectPinned(e.projectRoot)})]})]}),n?null:(0,R.jsx)(`div`,{className:`mt-0.5 space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}function mq({label:e}){return(0,R.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,R.jsx)(Ui,{className:`mx-auto mb-2 h-6 w-6 text-muted-foreground/45`}),(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e})]})}function hq({defaultSessionType:e,groups:t,isLoading:n,isProjectFirstView:r,projectGroups:i,renderSessionItem:a,sessionTypeOptions:o}){return n?(0,R.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:d(`sessionsLoading`)}):r?i.length===0?(0,R.jsx)(mq,{label:d(`chatSidebarProjectViewEmpty`)}):(0,R.jsx)(pq,{groups:i,defaultSessionType:e,sessionTypeOptions:o,renderSessionItem:a}):t.length===0?(0,R.jsx)(mq,{label:d(`sessionsEmpty`)}):(0,R.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-muted-foreground/70`,children:e.label}),(0,R.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(a)})]},e.label))})}function gq(e){return e instanceof HTMLElement&&!!e.closest(`.nextclaw-chat-input-bar-shell [role="textbox"][contenteditable="true"]`)}function _q({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:s,languageOptions:c,onSelectLanguage:l,onOpenDocs:u,onOpenApps:f,collapsed:m=!1}){return(0,R.jsxs)(zo,{open:e,onOpenChange:t,children:[m?(0,R.jsx)(Ln,{delayDuration:250,children:(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":d(`settingsMenu`),className:p(`flex items-center justify-center`,NK,RK),children:(0,R.jsx)(aa,{className:p(PK,`shrink-0 text-muted-foreground`)})})})}),(0,R.jsx)(Fn,{side:`right`,className:`text-xs`,children:d(`settingsMenu`)})]})}):(0,R.jsx)(Bo,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":d(`settingsMenu`),className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-muted-foreground transition-colors duration-base hover:bg-gray-200/60 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,children:[(0,R.jsx)(aa,{className:`h-4 w-4 shrink-0 text-muted-foreground/70`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:d(`settings`)}),(0,R.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-muted-foreground`,children:[r,` / `,s]})]})}),(0,R.jsxs)(Ho,{side:m?`right`:`top`,align:m?`end`:`start`,className:`w-64 p-2`,onFocusOutside:e=>{gq(e.detail.originalEvent.target)&&e.preventDefault()},children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(oe,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-foreground transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,R.jsx)(aa,{className:`h-4 w-4 text-muted-foreground/70`}),(0,R.jsx)(`span`,{className:`flex-1 text-left`,children:d(`settings`)})]}),[{key:`docs`,icon:An,label:d(`docBrowserHelp`),action:u},{key:`apps`,icon:Bn,label:d(`appsTitle`),action:f}].map(({key:e,icon:n,label:r,action:i})=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{i(),t(!1)},className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-foreground transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,R.jsx)(n,{className:`h-4 w-4 text-muted-foreground/70`}),(0,R.jsx)(`span`,{className:`flex-1 text-left`,children:r})]},e))]}),(0,R.jsx)(`div`,{className:`my-2 h-px bg-border`}),(0,R.jsx)(vq,{icon:j,label:d(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,R.jsx)(vq,{icon:Ii,label:d(`language`),options:c,value:o,valueLabel:s,onSelect:l,onCloseMenu:()=>t(!1)})]})]})}function vq({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,R.jsxs)(ar,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,R.jsxs)(Zn,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-foreground shadow-none hover:bg-gray-200/60 hover:text-gray-900 focus:ring-0`,indicator:(0,R.jsx)(ti,{className:`h-4 w-4 text-muted-foreground/70`}),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,R.jsx)(e,{className:`h-4 w-4 shrink-0 text-muted-foreground/70`}),(0,R.jsx)(`span`,{className:`text-left`,children:t})]}),(0,R.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-muted-foreground`,children:i})]}),(0,R.jsx)(er,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,R.jsx)(rr,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}var yq=f(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),bq=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}yq.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();yq.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){yq.setState({supported:!0,initialized:!0,busyAction:null}),P.error(`${d(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{yq.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(d(`runtimePresenceLaunchAtLoginUnavailable`));yq.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return yq.setState({supported:!0,initialized:!0,snapshot:n}),P.success(d(`runtimePresenceSaved`)),n}catch(e){throw P.error(`${d(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{yq.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:d(`error`)}},xq=f(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){xq.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{xq.setState({supported:!0,initialized:!0,snapshot:e})}),xq.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();xq.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){xq.setState({supported:!0,initialized:!0}),P.error(`${d(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,d(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){P.success(d(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){P.success(d(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??d(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){P.success(d(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&P.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,d(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&P.success(d(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,d(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,d(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(xq.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,d(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){P.success(d(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}P.success(d(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(d(`desktopUpdatesDesktopOnlyDescription`));xq.setState({busyAction:e});try{let e=await n(r);return xq.setState({snapshot:e}),e}catch(e){throw P.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{xq.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:d(`error`),this.getChannelLabel=e=>d(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function Sq(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Cq(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)||t===`/agents`||t.startsWith(`/agents/`)}function wq(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Tq(e){return[{target:`/chat`,label:e(`chat`),icon:Vi},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:k},{target:`/agents`,label:e(`agentsPageTitle`),icon:Xr},{target:`/settings`,label:e(`settings`),icon:aa}]}function Eq(e){return[{target:`/chat`,label:e(`chat`),icon:Vi},{target:`/chat/cron`,label:e(`cron`),icon:Kr},{target:`/chat/skills`,label:e(`marketplaceFilterSkills`),icon:k},{target:`/agents`,label:e(`agentsPageTitle`),icon:Xr}]}function Dq(e){return[{target:`/model`,label:e(`model`),icon:fi},{target:`/providers`,label:e(`providers`),icon:xr},{target:`/channels`,label:e(`channels`),icon:Wi},{target:`/search`,label:e(`searchChannels`),icon:wn},{target:`/appearance`,label:e(`appearance`),icon:j},{target:`/security`,label:e(`security`),icon:ca},{target:`/runtime`,label:e(`runtime`),icon:fi},{target:`/updates`,label:e(`updates`),icon:pi},{target:`/remote`,label:e(`remote`),icon:ya},{target:`/secrets`,label:e(`secrets`),icon:Fi},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:ba}]}function Oq(e){let t=Dq(e);return[{label:e(`settingsGroupBasic`),items:t.slice(0,3)},{label:e(`settingsGroupAdvanced`),items:t.slice(3)}]}function kq(e){return[{target:`/language`,label:e(`language`),icon:Ii},...Dq(e)]}function Aq(e){let t=e.toLowerCase();return t===`/settings`?!0:kq(e=>e).some(e=>Sq(t,e.target))}function jq(e,t){let n=e.toLowerCase(),r=kq(t);if(wq(n))return{title:t(`chat`),backTarget:`/chat`,backLabel:t(`chat`)};if(n===`/chat`)return{title:t(`chat`),backTarget:null,backLabel:null};if(n===`/skills`||n.startsWith(`/skills/`))return{title:t(`marketplaceFilterSkills`),backTarget:null,backLabel:null};if(n===`/agents`||n.startsWith(`/agents/`))return{title:t(`agentsPageTitle`),backTarget:null,backLabel:null};if(n===`/settings`)return{title:t(`settings`),backTarget:null,backLabel:null};for(let e of r)if(Sq(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}function Mq(){let{language:e,setLanguage:t}=pr();return{currentLanguage:e,currentLanguageLabel:o.find(t=>t.value===e)?.label??e,languageOptions:o,selectLanguage:(0,L.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}function Nq(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:r}=Mq();return(0,R.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,R.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,R.jsx)(Ii,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:d(`language`)}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,R.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.value),className:p(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,R.jsx)(cr,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function Pq(e,t){if(!e)return{items:Eq(t),density:`default`};let n=Oq(t);return{items:n.flatMap(e=>e.items),sections:n,density:`compact`}}function Fq({isCollapsed:e,onToggle:t}){let n=d(e?`sidebarExpand`:`sidebarCollapse`);return(0,R.jsx)(En,{icon:(0,R.jsx)(e?Yi:Ji,{className:PK}),label:n,className:p(RK,e&&`h-9 w-9 rounded-xl`),onClick:t})}function Iq({isCollapsed:e,onToggle:t}){return(0,R.jsx)(`div`,{className:p(`shrink-0`,e?`px-0 py-1.5`:`px-2 py-2`),children:(0,R.jsxs)(`div`,{className:p(`flex items-center py-1`,e?p(`flex-col px-0`,IK):`gap-2 px-1`),"data-testid":`settings-sidebar-header`,children:[e?(0,R.jsx)(Fq,{isCollapsed:e,onToggle:t}):null,(0,R.jsxs)(oe,{to:`/chat`,"aria-label":d(`backToMain`),className:p(`group inline-flex min-w-0 items-center rounded-lg text-[12px] font-medium text-muted-foreground transition-colors hover:bg-gray-200/60 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,e?p(NK,RK,`justify-center p-0`):`gap-1.5 px-1 py-1`),children:[(0,R.jsx)(Cn,{className:p(e?PK:`h-3.5 w-3.5`,`shrink-0 text-muted-foreground/75 group-hover:text-gray-700`)}),(0,R.jsx)(`span`,{className:e?`sr-only`:`truncate`,children:d(`backToMain`)})]}),e?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-border`,"aria-hidden":`true`}),(0,R.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-foreground`,children:d(`settings`)}),(0,R.jsx)(`div`,{className:`ml-auto`,children:(0,R.jsx)(Fq,{isCollapsed:e,onToggle:t})})]})]})})}function Lq({isCollapsed:e,onToggle:t}){return(0,R.jsx)(`div`,{className:p(`shrink-0`,e?`flex justify-center px-0 py-1.5`:`px-2 py-2`),children:e?(0,R.jsx)(Fq,{isCollapsed:e,onToggle:t}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(YK,{className:`flex min-w-0 flex-1 items-center gap-2.5 cursor-pointer`}),(0,R.jsx)(Fq,{isCollapsed:e,onToggle:t})]})})}function Rq({isSettingsMode:e,isCollapsed:t,onToggle:n}){return e?(0,R.jsx)(Iq,{isCollapsed:t,onToggle:n}):(0,R.jsx)(Lq,{isCollapsed:t,onToggle:n})}function zq({isSettingsMode:e,isCollapsed:t,items:n,sections:r,density:i}){let a=p(t?p(FK,`pb-3`):e?`space-y-0.5 pb-3`:`space-y-1 pb-4`);return(0,R.jsx)(`nav`,{className:p(`custom-scrollbar min-h-0 flex-1 overflow-y-auto`,t?`pr-0`:`pr-1`,LK),children:r&&!t?(0,R.jsx)(`div`,{className:`space-y-3 pb-3`,children:r.map(e=>(0,R.jsxs)(`section`,{"aria-label":e.label,className:`space-y-1`,children:[(0,R.jsx)(`h2`,{className:`px-3 text-[11px] font-semibold text-muted-foreground/70`,children:e.label}),(0,R.jsx)(lq,{isCollapsed:t,items:e.items,density:i,className:`space-y-0.5`})]},e.label))}):(0,R.jsx)(lq,{isCollapsed:t,items:n,density:i,className:a})})}function Bq({mode:e}){let t=sY(),n=Pr(),r=wa(),i=eo(e=>e.isSidebarCollapsed),a=to.toggleSidebarCollapsed,{currentLanguage:o,currentLanguageLabel:s,languageOptions:c,selectLanguage:l}=Mq(),{theme:u,setTheme:f}=wK(),m=e===`settings`,h=d(JG.find(e=>e.value===u)?.labelKey??`themeWork`),g=r.data?.account.email?.trim(),_=!!r.data?.account.loggedIn,v=e=>{u!==e&&f(e)},{items:y,sections:b,density:x}=Pq(m,d);return(0,R.jsxs)(`aside`,{className:p(`shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary pb-6 transition-[width] duration-200 ease-out`,i?p(jK,MK):`w-[240px] px-4`),"data-sidebar-collapsed":i?`true`:`false`,children:[(0,R.jsx)(Rq,{isSettingsMode:m,isCollapsed:i,onToggle:a}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(zq,{isSettingsMode:m,isCollapsed:i,items:y,sections:b,density:x}),(0,R.jsxs)(`div`,{className:p(`shrink-0 bg-secondary`,i?`mt-2 pt-2`:m?`mt-2 pt-3`:`mt-3 pt-3`),children:[m?(0,R.jsx)(uq,{onClick:()=>t.accountManager.openAccountPanel(),icon:Fi,label:d(`remoteAccountEntryManage`),density:`compact`,className:i?`mb-1`:`mb-1.5`,trailing:_?g||d(`remoteAccountEntryConnected`):d(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`,collapsed:i}):null,e===`main`&&(0,R.jsx)(`div`,{className:p(i?`mb-1`:`mb-2`,i?`flex justify-center`:void 0),children:(0,R.jsx)(cq,{to:`/settings`,label:d(`settings`),icon:aa,collapsed:i})}),(0,R.jsx)(`div`,{className:p(i?`mb-1`:`mb-2`,i?`flex justify-center`:void 0),children:(0,R.jsx)(dq,{value:u,onValueChange:e=>v(e),icon:j,label:d(`theme`),valueLabel:h,density:x,collapsed:i,children:JG.map(e=>(0,R.jsx)(rr,{value:e.value,className:`text-xs`,children:d(e.labelKey)},e.value))})}),(0,R.jsx)(`div`,{className:p(i?`mb-1`:`mb-2`,i?`flex justify-center`:void 0),children:(0,R.jsx)(dq,{value:o,onValueChange:e=>l(e),icon:Ii,label:d(`language`),valueLabel:s,density:x,collapsed:i,children:c.map(e=>(0,R.jsx)(rr,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,R.jsx)(uq,{onClick:()=>n.open(void 0,{kind:`docs`,title:d(`docBrowserHelp`)}),icon:An,label:d(`docBrowserHelp`),density:x,collapsed:i})]})]})]})}var Vq=[{action:`minimize`,label:`Minimize`,icon:qi},{action:`close`,label:`Close`,icon:Cr,variant:`danger`}];function Hq({sidebarCollapsed:e=!1}){let t=Wq()?{action:`toggle-maximize`,label:`Restore`,icon:ui}:{action:`toggle-maximize`,label:`Maximize`,icon:fa};return(0,R.jsxs)(`header`,{className:`desktop-window-drag relative flex h-[var(--desktop-titlebar-height)] shrink-0 bg-secondary after:absolute after:bottom-0 after:left-[var(--desktop-sidebar-width)] after:right-0 after:border-b after:border-border/80`,"data-testid":`desktop-window-chrome`,children:[(0,R.jsx)(`div`,{className:`desktop-window-no-drag absolute left-0 right-0 top-0 h-1`,"data-testid":`desktop-window-chrome-resize-strip`}),(0,R.jsx)(`div`,{className:p(`desktop-window-drag relative z-10 flex h-full w-[var(--desktop-sidebar-width)] shrink-0 items-center bg-secondary text-secondary-foreground`,e?`justify-center px-0`:`pl-4 pr-3`),"data-testid":`desktop-window-chrome-sidebar`,children:e?(0,R.jsx)(`img`,{src:`/logo.svg`,alt:`NextClaw`,className:`h-6 w-6 shrink-0 object-contain`}):(0,R.jsx)(YK,{className:`flex min-w-0 shrink-0 items-center gap-2.5`,density:`chrome`})}),(0,R.jsx)(`div`,{className:`desktop-window-no-drag absolute right-0 top-0 z-20 flex h-full w-[var(--desktop-caption-safe-right)] items-start justify-end`,"data-testid":`desktop-window-controls`,children:[Vq[0],t,Vq[1]].map(e=>(0,R.jsx)(Uq,{control:e},e.action))})]})}function Uq({control:e}){let t=e.icon;return(0,R.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,className:e.variant===`danger`?`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-red-500 hover:text-white`:`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-black/10`,onClick:()=>{window.nextclawDesktop?.controlWindow?.(e.action)},children:(0,R.jsx)(t,{className:`h-3.5 w-3.5`})})}function Wq(){let[e,t]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let e=!0,n=window.nextclawDesktop;n?.getWindowState?.().then(n=>{e&&t(n.isMaximized)});let r=n?.onWindowStateChanged?.(e=>{t(e.isMaximized)});return()=>{e=!1,r?.()}},[]),e}function Gq(){return typeof window>`u`?null:qq()??window.nextclawDesktop?.platform??null}function Kq(){return Gq()===`win32`}function qq(){return null}function Jq(e,t){if(t===`/settings`)return Aq(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Yq(){let{pathname:e}=h(),t=Tq(d);return(0,R.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":d(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,R.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=Jq(e,t.target);return(0,R.jsx)(`li`,{children:(0,R.jsx)(y,{to:t.target,"aria-current":n?`page`:void 0,className:p(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,R.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:p(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,R.jsx)(t.icon,{className:p(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,R.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function Xq({leadingInset:e}){let t=ie(),{pathname:n}=h(),r=jq(n,d);return(0,R.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,R.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 py-1.5 pl-3 pr-3`,style:{paddingLeft:e?`calc(${e} + 0.75rem)`:void 0},children:[r.backTarget?(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(r.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":r.backLabel??d(`backToMain`),children:(0,R.jsx)(Cn,{className:`h-4 w-4`})}):null,(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:r.title})}),r.backTarget?(0,R.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var Zq=(0,L.lazy)(async()=>({default:(await g(async()=>{let{DocBrowser:e}=await import(`./doc-browser-DNRL4Zvd.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))).DocBrowser}));function Qq({pathname:e,isDocBrowserOpen:t,docBrowserDockControls:n,docBrowserRenderers:r={},topbarLeadingInset:i,children:a}){let o=Cq(e),s=!wq(e),c=!wq(e);return(0,R.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[s?(0,R.jsx)(Xq,{leadingInset:i}):null,(0,R.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:o?(0,R.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:a}):(0,R.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,R.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:a})})}),c?(0,R.jsx)(Yq,{}):null,t?(0,R.jsx)(L.Suspense,{fallback:null,children:(0,R.jsx)(Zq,{customTabRenderers:r,displayMode:`fullscreen`,dockControls:n})}):null]})}function $q(){let e=kq(d);return(0,R.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,R.jsxs)(oe,{to:e.target,className:({isActive:e})=>p(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,R.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,R.jsx)(e.icon,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`min-w-0`,children:(0,R.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function eJ(){let{pathname:e}=h(),t=ie();return wq(e)?(0,R.jsx)(HG,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,R.jsx)(gJ,{variant:`mobile`})}var tJ=(0,L.lazy)(async()=>({default:(await g(async()=>{let{DocBrowser:e}=await import(`./doc-browser-DNRL4Zvd.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))).DocBrowser}));function nJ({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:i,docBrowserRenderers:a={},sideDock:o,children:s}){let c=Cq(e),l=eo(e=>e.isSidebarCollapsed),u=t&&!wq(e),d=Kq(),f=l?`56px`:c?`280px`:`240px`;return(0,R.jsxs)(`div`,{className:p(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,d?`rounded-[10px]`:null),style:d?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":f}:void 0,children:[d?(0,R.jsx)(Hq,{sidebarCollapsed:l}):null,(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!c&&(0,R.jsx)(Bq,{mode:`settings`}),(0,R.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:c?(0,R.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:s}):(0,R.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,R.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:s})})}),n&&r===`docked`?(0,R.jsx)(L.Suspense,{fallback:null,children:(0,R.jsx)(tJ,{customTabRenderers:a,dockControls:i})}):null,o]})]}),u?(0,R.jsx)(Yq,{}):null,n&&r===`floating`?(0,R.jsx)(L.Suspense,{fallback:null,children:(0,R.jsx)(tJ,{customTabRenderers:a,dockControls:i})}):null]})}var rJ=[{target:`/cron`,label:()=>d(`chatSidebarScheduledTasks`),icon:Kr},{target:`/skills`,label:()=>d(`chatSidebarSkills`),icon:k},{target:`/agents`,label:()=>d(`agentsPageTitle`),icon:Xr}];function iJ({isCollapsed:e}){let t=d(e?`sidebarExpand`:`sidebarCollapse`);return(0,R.jsx)(En,{icon:(0,R.jsx)(e?Yi:Ji,{className:PK}),label:t,className:p(RK,e&&`h-9 w-9 rounded-xl`),onClick:to.toggleSidebarCollapsed})}function aJ({connectionStatus:e,isCollapsed:t}){let n=Kq(),r=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`;return(0,R.jsxs)(`div`,{className:p(`flex items-center`,t?`justify-center px-2 py-1.5`:n?`justify-end px-3 py-1.5`:`gap-2 px-5 py-2`,t&&r?`pt-8`:null),children:[t||n?null:(0,R.jsx)(YK,{className:`flex min-w-0 flex-1 items-center gap-2`,suffix:(0,R.jsx)(nq,{status:e})}),(0,R.jsx)(iJ,{isCollapsed:t})]})}function oJ({isCollapsed:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:p(`pb-2`,e?`px-0`:`px-3`),children:(0,R.jsx)(`ul`,{className:e?FK:`space-y-0.5`,children:rJ.map(t=>(0,R.jsx)(`li`,{className:e?`flex justify-center`:void 0,children:(0,R.jsx)(cq,{to:t.target,label:t.label(),icon:t.icon,density:`compact`,collapsed:e})},t.target))})}),(0,R.jsx)(`div`,{className:p(`border-t border-border/70`,e?`mx-2 my-1.5`:`mx-4`)})]})}function sJ({defaultSessionType:e,groups:t,isCollapsed:n,isLoading:r,isProjectFirstView:i,onSelectMode:a,projectGroups:o,renderSessionItem:s,sessionTypeOptions:c}){return n?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,"aria-hidden":`true`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground/75`,children:d(`chatSidebarTaskRecords`)}),(0,R.jsx)(rq,{isProjectFirstView:i,onSelectMode:a})]}),(0,R.jsx)(`div`,{className:p(`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-3 pb-7 pt-2`,LK),children:(0,R.jsx)(hq,{isLoading:r,isProjectFirstView:i,groups:t,projectGroups:o,defaultSessionType:e,sessionTypeOptions:c,renderSessionItem:s})})]})}function cJ({currentLanguage:e,currentLanguageLabel:t,currentTheme:n,currentThemeLabel:r,isCollapsed:i,isOpen:a,languageOptions:o,onOpenApps:s,onOpenChange:c,onOpenDocs:l,onSelectLanguage:u,onSelectTheme:d,themeOptions:f}){return(0,R.jsx)(`div`,{className:p(`py-3`,i?p(`flex justify-center`,MK):`px-3`),children:(0,R.jsx)(_q,{isOpen:a,onOpenChange:c,currentTheme:n,currentThemeLabel:r,themeOptions:f,onSelectTheme:d,currentLanguage:e,currentLanguageLabel:t,languageOptions:o,onSelectLanguage:u,onOpenDocs:l,onOpenApps:s,collapsed:i})})}var lJ=$e.chat.newSessionType,uJ=[`preference`,lJ];function dJ(e,t){let n=Vc(e);return t.find(e=>e.value===n&&e.ready!==!1)??null}function fJ(e){let{defaultSessionType:t,preferredSessionType:n,sessionTypeOptions:r}=e,i=n?dJ(n,r):null,a=dJ(t,r);return i??a??r.find(e=>e.ready!==!1)??r[0]??{value:Vc(t),label:Vc(t),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,modelSelectionMode:`nextclaw`,runtimeDefaultThinking:null,cta:null}}function pJ(e){return typeof e?.value==`string`?Vc(e.value):null}function mJ({defaultSessionType:e,sessionTypeOptions:t}){let n=Be(),r=Me({queryKey:uJ,queryFn:()=>Ze(lJ),staleTime:3e4,retry:!1}),i=(0,L.useMemo)(()=>pJ(r.data),[r.data]),a=(0,L.useMemo)(()=>fJ({preferredSessionType:i,defaultSessionType:e,sessionTypeOptions:t}),[e,i,t]),o=we({mutationFn:async e=>await He(lJ,Vc(e)),onMutate:async e=>{let t=Vc(e);await n.cancelQueries({queryKey:uJ});let r=n.getQueryData(uJ);return n.setQueryData(uJ,{key:lJ,value:t,updatedAt:new Date().toISOString()}),{previous:r}},onError:(e,t,r)=>{r?.previous&&n.setQueryData(uJ,r.previous)},onSuccess:e=>{n.setQueryData(uJ,e)}}),s=(0,L.useCallback)(e=>{let n=dJ(e,t);n&&o.mutate(n.value)},[t,o]);return{selectedSessionType:a.value,selectedSessionTypeOption:a,isLoading:r.isLoading,setSelectedSessionType:s}}function hJ(e,t,n){let r=z(e=>e.optimisticReadAtBySessionKey);return(0,L.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r||r.runStatus===`running`)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function gJ({variant:e=`desktop`}){let t=e===`mobile`,n=os(),r=Pr(),i=eo(e=>e.isSidebarCollapsed),[a,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),u=z(e=>e.snapshot),f=Gc(e=>e.snapshot.sessionTypesQuery?.data??null),m=Pe(),h=ql(),{isLoading:g,items:_}=pc(),{language:v,setLanguage:y}=pr(),{theme:b,setTheme:x}=wK(),S=d(JG.find(e=>e.value===b)?.labelKey??`themeWork`),C=o.find(e=>e.value===v)?.label??v,w=(0,L.useMemo)(()=>JG.map(e=>({value:e.value,label:d(e.labelKey)})),[]),T=(0,L.useMemo)(()=>o.map(e=>({value:e.value,label:e.label})),[]),E=(0,L.useMemo)(()=>new Map((h.data?.agents??[]).map(e=>[e.id,e])),[h.data?.agents]),D=(0,L.useMemo)(()=>new Set(u.pinnedSessionKeys),[u.pinnedSessionKeys]),O=(0,L.useMemo)(()=>new Set(u.pinnedProjectRoots),[u.pinnedProjectRoots]),k=(0,L.useMemo)(()=>Pc(_),[_]),A=(0,L.useMemo)(()=>Rc(_),[_]),ee=(0,L.useMemo)(()=>Ic(k,D),[D,k]),j=(0,L.useMemo)(()=>Lc(k,D,O),[O,D,k]),M=(0,L.useMemo)(()=>Wc(f?.options??[]),[f?.options]),N=(0,L.useMemo)(()=>Vc(f?.defaultType??`native`),[f?.defaultType]),te=(0,L.useMemo)(()=>M.filter(e=>e.value!==N),[N,M]),ne=mJ({defaultSessionType:N,sessionTypeOptions:M}),re=u.listMode===`project-first`,ie=!t&&i,ae=hJ(_,u.selectedSessionKey,n.chatSessionListManager.markSessionRead),{editingSessionKey:oe,draftLabel:se,savingSessionKey:ce,setDraftLabel:le,startEditingSessionLabel:ue,cancelEditingSessionLabel:de,saveSessionLabel:fe}=UG(),pe=e=>{v!==e&&(y(e),window.location.reload())},me=e=>(0,R.jsx)(OK,{item:e,selectedSessionKey:u.selectedSessionKey,optimisticReadAtBySessionKey:ae,agentsById:E,childSessionsByParentKey:A,editingSessionKey:oe,draftLabel:se,savingSessionKey:ce,sessionTypeOptions:M,isPinned:D.has(e.session.key),sessionTitle:zc,onSelectSession:n.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>n.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ue,onDraftLabelChange:le,onSaveSessionLabel:fe,onCancelEditingSessionLabel:de,onTogglePinned:()=>n.chatSessionListManager.toggleSessionPinned(e.session.key)},e.session.key),he=(e,t)=>{n.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,R.jsxs)(`aside`,{className:p(`flex h-full min-h-0 flex-col bg-secondary transition-[width] duration-200 ease-out`,t?`flex-1 overflow-hidden`:ie?p(jK,`shrink-0`):`w-[280px] shrink-0`),"data-sidebar-collapsed":ie?`true`:`false`,children:[t?null:(0,R.jsx)(aJ,{connectionStatus:m.connectionStatus,isCollapsed:ie}),t?(0,R.jsx)(GK,{query:u.query,defaultSessionType:ne.selectedSessionType,sessionTypeOptions:M,nonDefaultSessionTypeOptions:te,selectedNewSessionType:ne.selectedSessionType,selectedNewSessionTypeOption:ne.selectedSessionTypeOption,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:he,onSelectNewSessionType:ne.setSelectedSessionType,onQueryChange:n.chatSessionListManager.setQuery}):(0,R.jsx)(WK,{query:u.query,defaultSessionType:N,sessionTypeOptions:M,nonDefaultSessionTypeOptions:te,selectedNewSessionType:ne.selectedSessionType,selectedNewSessionTypeOption:ne.selectedSessionTypeOption,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:he,onSelectNewSessionType:ne.setSelectedSessionType,onQueryChange:n.chatSessionListManager.setQuery,collapsed:ie}),t?null:(0,R.jsx)(oJ,{isCollapsed:ie}),(0,R.jsx)(sJ,{defaultSessionType:ne.selectedSessionType,groups:ee,isCollapsed:ie,isLoading:g,isProjectFirstView:re,onSelectMode:n.chatSessionListManager.setListMode,projectGroups:j,renderSessionItem:me,sessionTypeOptions:M}),t?null:(0,R.jsx)(cJ,{currentLanguage:v,currentLanguageLabel:C,currentTheme:b,currentThemeLabel:S,isCollapsed:ie,isOpen:c,languageOptions:T,onOpenApps:()=>AB(r),onOpenChange:l,onOpenDocs:()=>r.open(void 0,{kind:`docs`,title:d(`docBrowserHelp`)}),onSelectLanguage:pe,onSelectTheme:x,themeOptions:w})]})}var _J=`sid_`,vJ=`/chat/draft`,yJ=vJ.slice(6);function bJ(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${_J}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function xJ(e){if(!e.startsWith(_J))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function SJ(e){if(!e||e===yJ)return null;let t=xJ(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function CJ(e){return`/chat/${bJ(e)}`}function wJ(e,t){let n=t.trim();return n?e.includes(n)?e.filter(e=>e!==n):[n,...e]:e}var TJ=class{constructor(e){this.uiManager=e,this.syncDraftThreadState=()=>{Ul.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null,workspaceNavigationHistory:[],workspaceNavigationHistoryIndex:0})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=z.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=z.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&z.getState().setSnapshot({selectedAgentId:n})},this.syncSelectedSessionAgent=()=>{let e=Ul.getState().snapshot.agentId?.trim();e&&this.setSelectedAgentId(e)},this.setSelectedSessionKey=e=>{let t=z.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&z.getState().setSnapshot({selectedSessionKey:n})},this.syncRouteSessionSelection=e=>{let{isChatView:t,routeSessionKey:n}=e;if(!t)return;let{selectedSessionKey:r}=z.getState().snapshot;if(n){r!==n&&this.setSelectedSessionKey(n);return}r!==null&&this.setSelectedSessionKey(null)},this.setListMode=e=>{let t=z.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&z.getState().setSnapshot({listMode:n})},this.toggleSessionPinned=e=>{let{pinnedSessionKeys:t}=z.getState().snapshot;z.getState().setSnapshot({pinnedSessionKeys:wJ(t,e)})},this.toggleProjectPinned=e=>{let{pinnedProjectRoots:t}=z.getState().snapshot;z.getState().setSnapshot({pinnedProjectRoots:wJ(t,e)})},this.toggleProjectCollapsed=e=>{let{collapsedProjectRoots:t}=z.getState().snapshot;z.getState().setSnapshot({collapsedProjectRoots:wJ(t,e)})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(z.getState().markSessionRead(r,i),Ne(r,{uiReadAt:i}).catch(()=>void 0))},this.markVisibleWorkspaceChildRead=e=>{this.markSessionRead(e.sessionKey,e.runStatus===`running`?null:e.lastMessageAt,e.readAt)},this.createSession=(e,t)=>{let n=Vc(e??`native`),r=_s(t);z.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),this.uiManager.navigateTo(vJ,{replace:this.uiManager.isAtChatRoot(),state:{chatDraft:{sessionType:n,projectRoot:r}}})},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=z.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&z.getState().setSnapshot({query:n})}}},EJ=async()=>!1,DJ=class{constructor(e){this.docBrowserManager=e,this.state={pathname:``},this.actions={navigate:null,confirm:EJ},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.isCompactViewport=()=>to.getSnapshot().mode===`mobile`,this.resolvePanelAppEntry=async e=>{let t=e.trim();if(!t)return null;try{return Jz((await F.panelApps.listPanelApps()).entries,t)}catch{return null}},this.showContent=async e=>{let{target:t,title:n}=e;if(t.type===`url`){this.docBrowserManager.open(t.payload.url,{dedupeKey:`browser:${t.payload.url}`,kind:`content`,title:n});return}let{appId:r}=t.payload,i=await this.resolvePanelAppEntry(r);if(i){this.docBrowserManager.openTarget(w(i),{title:n});return}this.docBrowserManager.open(C(r),{title:n})},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`||this.state.pathname===`/chat/draft`,this.goToSession=(e,t)=>{this.navigateTo(CJ(e),t)}}};function OJ(e){let t=e=>{if(!e||typeof e!=`object`)return e;let t=e,n=t.error instanceof Error?{name:t.error.name,message:t.error.message}:t.error;return{data:t.data,error:n,status:t.status,fetchStatus:t.fetchStatus,isLoading:t.isLoading,isFetching:t.isFetching,isFetched:t.isFetched,isSuccess:t.isSuccess}};return{configQuery:t(e.configQuery),providersQuery:t(e.providersQuery),providerTemplatesQuery:t(e.providerTemplatesQuery),sessionsQuery:t(e.sessionsQuery),sessionTypesQuery:t(e.sessionTypesQuery),sessionSkillsSessionId:e.sessionSkillsSessionId,sessionSkillsQuery:t(e.sessionSkillsQuery)}}function kJ(e,t){return JSON.stringify(OJ(e))!==JSON.stringify(OJ({...e,...t}))}var AJ=class{constructor(){this.syncSnapshot=e=>{let t=Gc.getState();kJ(t.snapshot,e)&&t.setSnapshot(e)}}};function jJ(e,t){return e.kind===t.kind?e.kind===`cron`?!0:t.kind!==`cron`&&e.key===t.key:!1}function MJ(e){return{draftKey:`side-chat-draft:${e}:${typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`,parentSessionKey:e}}function NJ(e,t){let n=e.findIndex(e=>e.sessionKey===t.sessionKey);if(n===-1)return[t,...e];let r=e[n],i=[...e];return i[n]={...r,parentSessionKey:r.parentSessionKey??t.parentSessionKey,label:r.label?.trim()?r.label:t.label,agentId:r.agentId?.trim()?r.agentId:t.agentId},i}function PJ(e){let{agentId:t,draftKey:n,label:r,sessionKey:i,snapshot:a}=e,o=i.trim(),s=n.trim(),{activeSideChatDraft:c}=a;if(!o||!s||c?.draftKey!==s)return null;let{parentSessionKey:l}=c,u=IG(RG({entries:a.workspaceNavigationHistory,index:a.workspaceNavigationHistoryIndex},e=>e.kind!==`side-chat-draft`||e.key!==s),{kind:`child-session`,key:o},jJ);return{parentSessionKey:l,patch:{workspacePanelParentKey:l,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:o,activeSideChatDraft:null,activeWorkspaceFileKey:null,childSessionTabs:NJ(a.childSessionTabs,{sessionKey:o,parentSessionKey:l,label:r?.trim()||null,agentId:t?.trim()||null}),workspaceNavigationHistory:[...u.entries],workspaceNavigationHistoryIndex:u.index}}}var FJ=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.onWorkspacePanelOpened=n,this.handledUiShowContentEventIds=new Set,this.hasSnapshotChanges=e=>{let t=Ul.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Ul.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{z.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Ul.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeSideChatDraft:null,workspaceFileTabs:[],activeWorkspaceFileKey:null,workspaceNavigationHistory:[],workspaceNavigationHistoryIndex:0})},this.resolveWorkspaceParentSessionKey=()=>z.getState().snapshot.selectedSessionKey?.trim()||Ul.getState().snapshot.sessionKey?.trim()||(z.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null,i=e.viewMode===`preview`&&e.previewViewer!==`rendered`&&(e.previewViewer===`auto`||e.previewViewer===`source`||/\.html?$/i.test(n))?`source`:e.previewViewer??null,a=e.viewMode===`preview`&&i===`rendered`?`preview:rendered`:e.viewMode;return{key:`${r??`draft`}::${a}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,previewViewer:i,line:e.line??null,column:e.column??null,rawText:e.rawText??null,contentUrl:e.contentUrl?.trim()||null,mimeType:e.mimeType?.trim()||null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Ul.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=z.getState();t!==e&&this.uiManager.goToSession(e)},this.createWorkspaceSelectionPatch=(e,t)=>{if(e.kind===`cron`)return{activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeSideChatDraft:null,activeWorkspaceFileKey:null};if(e.kind===`file`)return t.workspaceFileTabs.some(t=>t.key===e.key)?{activeWorkspacePanelKind:`file`,activeChildSessionKey:null,activeSideChatDraft:null,activeWorkspaceFileKey:e.key}:null;if(e.kind===`side-chat-draft`){let{activeSideChatDraft:n}=t;return n?.draftKey===e.key?{activeWorkspacePanelKind:`side-chat-draft`,activeChildSessionKey:null,activeSideChatDraft:n,activeWorkspaceFileKey:null}:null}return e.key?{activeWorkspacePanelKind:`child-session`,activeChildSessionKey:e.key,activeSideChatDraft:null,activeWorkspaceFileKey:null}:null},this.setWorkspaceSelection=(e,t)=>{let{snapshot:n}=Ul.getState(),r=IG({entries:n.workspaceNavigationHistory,index:n.workspaceNavigationHistoryIndex},t,jJ);Ul.getState().setSnapshot({...e,workspaceNavigationHistory:[...r.entries],workspaceNavigationHistoryIndex:r.index})},this.openChildSessionPanel=e=>{let{activeChildSessionKey:t,childSessionTab:n,parentSessionKey:r}=e,i=r.trim();if(!i)return;let a=t?.trim()||null,o={workspacePanelParentKey:i,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:a,activeSideChatDraft:null,activeWorkspaceFileKey:null};a&&n&&(o.childSessionTabs=NJ(Ul.getState().snapshot.childSessionTabs,{sessionKey:a,parentSessionKey:i,label:n.label?.trim()||null,agentId:n.agentId?.trim()||null})),a?this.setWorkspaceSelection(o,{kind:`child-session`,key:a}):Ul.getState().setSnapshot(o),this.ensureWorkspaceParentRoute(i),this.onWorkspacePanelOpened?.()},this.openSideChatDraft=e=>{let t=e?.trim()||this.resolveWorkspaceParentSessionKey()?.trim();if(!t)return;let n=MJ(t);this.setWorkspaceSelection({workspacePanelParentKey:t,activeWorkspacePanelKind:`side-chat-draft`,activeChildSessionKey:null,activeSideChatDraft:n,activeWorkspaceFileKey:null},{kind:`side-chat-draft`,key:n.draftKey}),this.ensureWorkspaceParentRoute(t),this.onWorkspacePanelOpened?.()},this.materializeSideChatDraft=e=>{let t=PJ({snapshot:Ul.getState().snapshot,...e});t&&(Ul.getState().setSnapshot(t.patch),this.ensureWorkspaceParentRoute(t.parentSessionKey))},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(this.setWorkspaceSelection({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null,activeSideChatDraft:null},{kind:`file`,key:n.key}),this.ensureWorkspaceParentRoute(t),this.onWorkspacePanelOpened?.())},this.openSessionFromToolAction=e=>{if(e.kind!==`open-session`)return;let t=e.sessionId.trim();if(t){if(e.sessionKind===`child`&&!this.uiManager.isCompactViewport()){let n=e.parentSessionId?.trim()||z.getState().snapshot.selectedSessionKey||null;if(n){this.openChildSessionPanel({parentSessionKey:n,activeChildSessionKey:t,childSessionTab:{label:e.label,agentId:e.agentId}});return}}this.closeWorkspacePanel(),this.uiManager.goToSession(t)}},this.handleToolAction=async e=>{if(e.kind===`show-content`){await this.showContent(e.request);return}this.openSessionFromToolAction(e)},this.handleUiShowContentEvent=async e=>{let t=e.id.trim();!t||this.handledUiShowContentEventIds.has(t)||(this.handledUiShowContentEventIds.add(t),await this.showContent({target:e.target,title:e.title,purpose:e.purpose,placement:e.placement}))},this.showContent=async e=>{if(e.placement!==`inline`){if(e.target.type===`file`){this.openFilePreview({path:e.target.payload.path,label:e.title,viewMode:`preview`,previewViewer:e.target.payload.viewer,line:e.target.payload.line,column:e.target.payload.column});return}await this.uiManager.showContent({target:e.target,title:e.title})}},this.syncVisibleWorkspaceSelection=e=>{e?.kind===`child-session`&&this.sessionListManager.markVisibleWorkspaceChildRead(e.tab)},this.selectChildSessionDetail=e=>{let t=e.trim();t&&this.setWorkspaceSelection({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`,activeSideChatDraft:null},{kind:`child-session`,key:t})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Ul.getState().snapshot;n.some(e=>e.key===t)&&this.setWorkspaceSelection({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`,activeSideChatDraft:null},{kind:`file`,key:t})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Ul.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a=i.filter(e=>e.key!==t),o=RG({entries:n.workspaceNavigationHistory,index:n.workspaceNavigationHistoryIndex},e=>e.kind!==`file`||e.key!==t),s={workspaceFileTabs:a,workspaceNavigationHistory:[...o.entries],workspaceNavigationHistoryIndex:o.index};if(r===t){let e={...n,workspaceFileTabs:a},t=o.entries[o.index],r=t?this.createWorkspaceSelectionPatch(t,e):null;Object.assign(s,r??{activeWorkspacePanelKind:null,activeSideChatDraft:null,activeWorkspaceFileKey:null})}Ul.getState().setSnapshot(s)},this.closeWorkspacePanel=()=>{Ul.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeSideChatDraft:null,activeWorkspaceFileKey:null,workspaceNavigationHistory:[],workspaceNavigationHistoryIndex:0})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(this.setWorkspaceSelection({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeSideChatDraft:null,activeWorkspaceFileKey:null},{kind:`cron`}),this.ensureWorkspaceParentRoute(t),this.onWorkspacePanelOpened?.())},this.goBackWorkspacePanel=()=>{this.restoreWorkspaceNavigationStep(`back`)},this.goForwardWorkspacePanel=()=>{this.restoreWorkspaceNavigationStep(`forward`)},this.restoreWorkspaceNavigationStep=e=>{let{snapshot:t}=Ul.getState(),n=LG({entries:t.workspaceNavigationHistory,index:t.workspaceNavigationHistoryIndex},e);if(!n)return;let r=this.createWorkspaceSelectionPatch(n.entry,t);r&&Ul.getState().setSnapshot({...r,workspaceNavigationHistory:[...n.history.entries],workspaceNavigationHistoryIndex:n.history.index})},this.goToParentSession=()=>{let{parentSessionKey:e,activeSideChatDraft:t,childSessionTabs:n,activeChildSessionKey:r}=Ul.getState().snapshot,i=n.find(e=>e.sessionKey===r)?.parentSessionKey??null,a=e??t?.parentSessionKey??i;a&&(this.closeWorkspacePanel(),this.uiManager.goToSession(a))},this.deleteSession=async()=>{let{snapshot:{selectedSessionKey:e}}=z.getState();if(e&&await this.uiManager.confirm({title:d(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:d(`delete`)})){Ul.getState().setSnapshot({isDeletePending:!0});try{await St(e),ft(je,e),je.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Ul.getState().setSnapshot({isDeletePending:!1})}}}}},IJ=class{constructor(e){this.chatUiManager=new DJ(e.docBrowserManager),this.chatSessionListManager=new TJ(this.chatUiManager),this.chatQueryManager=new AJ,this.chatThreadManager=new FJ(this.chatUiManager,this.chatSessionListManager,e.notifyRightPanelOpened)}},LJ=class{constructor(){this.nextId=0,this.pendingIntent=null,this.listeners=new Set,this.requestDraft=e=>{let t=e.trim();if(!t)return;let n={id:this.nextId+1,prompt:t};this.nextId=n.id,this.pendingIntent=n,this.listeners.forEach(e=>e(n))},this.consumePending=()=>{let e=this.pendingIntent;return this.pendingIntent=null,e},this.markConsumed=e=>{this.pendingIntent?.id===e&&(this.pendingIntent=null)},this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})}};function RJ(){return Me({queryKey:[`ncp-session-types`],queryFn:ve,staleTime:1e4,retry:!1})}var zJ=new class{constructor(){this.resolveOpenTarget=e=>{let{activeTab:t,kind:n,url:r}=e,i=n??(r?void 0:t?.kind)??(r&&Ir(r)?`docs`:`home`),a=r?.trim()||(!n&&t&&t.kind!==`docs`?t.currentUrl:i===`home`?`nextclaw://new-tab`:i===`docs`?Br():`about:blank`),o=i===`docs`?jr(a,`docs`):a;return{historyPolicy:`managed`,kind:i,title:i===`home`?d(`docBrowserHomeTitle`):Ar(o,i,i===`docs`?d(`docBrowserHelp`):`Detail`),url:o}},this.areUrlsEquivalent=(e,t,n,r)=>n===r?n===`docs`?Nr(e)===Nr(t):e===t:!1,this.usesManagedHistory=e=>e.currentUrl!==Rr}};function BJ(e,t,n){return{...e,tabs:e.tabs.map(e=>e.id===t?n(e):e)}}function VJ(e,t){return BJ(e,e.activeTabId,t)}function HJ(e,t){let n=[...e.history.slice(0,e.historyIndex+1),t];return{history:n,historyIndex:n.length-1}}function UJ(e,t,n){let r=t.resourceUri??t.url,i=n.resourceUri??n.url;return t.tabId===n.tabId&&t.kind===n.kind&&e.areUrlsEquivalent(r,i,t.kind,n.kind)}function WJ(e,t){return{kind:t.kind,resourceUri:t.resourceUri??t.url,tabId:e,url:t.url}}function GJ(e,t,n){let r=IG({entries:t.activeHistory,index:t.activeHistoryIndex},n,(t,n)=>UJ(e,t,n));return{...t,activeHistory:[...r.entries],activeHistoryIndex:r.index}}function KJ(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 qJ(e,t,n){let r=t.tabs.find(e=>e.id===n.tabId);if(!r)return t;let i=n.resourceUri??n.url,a=e.resolveOpenTarget({activeTab:r,kind:n.kind,url:i}),o=KJ(e,r,a.url),s=n.resourceUri!==void 0&&n.resourceUri===r.resourceUri;return BJ({...t,activeTabId:r.id,isOpen:!0},r.id,e=>({...e,currentUrl:a.url,dedupeKey:a.dedupeKey,dockIcon:a.dockIcon??e.dockIcon,historyIndex:o>=0?o:e.historyIndex,kind:a.kind,resourceUri:a.resourceUri??a.url,title:s?e.title:a.title}))}function JJ(e,t,n,r,i){let a={...t,title:r?.title||n.title||t.title,kind:n.kind,resourceUri:n.resourceUri??n.url,dockIcon:r?.dockIcon??n.dockIcon,dedupeKey:i};return e.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?a:{...a,currentUrl:n.url,...HJ(t,n.url),navVersion:t.navVersion+1}}function YJ(e,t){return!e.isOpen&&e.tabs.length===1&&t?.kind===`home`&&t.currentUrl===`nextclaw://new-tab`}function XJ(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=BJ(t,u.id,t=>JJ(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?GJ(e,l,WJ(u.id,n)):l}if(o||c||!l||l.kind!==n.kind){let i=Fr(n.url,n.kind,s??n.title,c,n.resourceUri??n.url,r?.dockIcon??n.dockIcon);return YJ(t,l)?{...t,isOpen:!0,tabs:[i],activeTabId:i.id,activeHistory:[Or(i)],activeHistoryIndex:0}:GJ(e,{...t,isOpen:!0,tabs:[...t.tabs,i],activeTabId:i.id},Or(i))}return GJ(e,{...VJ(t,t=>JJ(e,t,n,r,c)),isOpen:!0},WJ(t.activeTabId,n))}function ZJ(e,t,n,r){let i=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0];return XJ(e,t,e.resolveOpenTarget({activeTab:i,kind:r?.kind,url:n}),r)}var QJ=class{constructor(e=zJ,t){this.routeResolver=e,this.onRightPanelOpened=t,this.setSnapshot=e=>{Lr.getState().setSnapshot(e)},this.open=(e,t)=>{this.setSnapshot(n=>ZJ(this.routeResolver,n,e,t)),this.onRightPanelOpened?.()},this.openTarget=(e,t)=>{this.setSnapshot(n=>XJ(this.routeResolver,n,e,{...t,dedupeKey:t?.dedupeKey??e.dedupeKey,kind:t?.kind??e.kind,title:t?.title??e.title})),this.onRightPanelOpened?.()},this.openNewTab=()=>{this.open(void 0,{kind:kr,newTab:!0})},this.close=()=>{this.setSnapshot(e=>({...e,isOpen:!1}))},this.toggleMode=()=>{this.setSnapshot(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`})),this.onRightPanelOpened?.()},this.navigate=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=Fr(Br(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}let n=VJ(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...HJ(t,n.url),kind:n.kind,navVersion:t.navVersion+1,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?GJ(this.routeResolver,n,Or(r)):n})},this.syncUrl=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=Fr(Br(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}let n=VJ(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,kind:t.kind,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...HJ(t,n.url),kind:n.kind,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?GJ(this.routeResolver,n,Or(r)):n})},this.goBack=()=>{this.setSnapshot(e=>{let t=LG({entries:e.activeHistory,index:e.activeHistoryIndex},`back`);return t?qJ(this.routeResolver,{...e,activeHistory:[...t.history.entries],activeHistoryIndex:t.history.index},t.entry):e})},this.goForward=()=>{this.setSnapshot(e=>{let t=LG({entries:e.activeHistory,index:e.activeHistoryIndex},`forward`);return t?qJ(this.routeResolver,{...e,activeHistory:[...t.history.entries],activeHistoryIndex:t.history.index},t.entry):e})},this.closeTab=e=>{this.setSnapshot(t=>{if(t.tabs.length<=1)return{...Mr(),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=r.find(e=>e.id===i)??r[0],s=RG({entries:a.activeHistory,index:a.activeHistoryIndex},t=>t.tabId!==e,Or(o)),c={...a,activeHistory:[...s.entries],activeHistoryIndex:s.index};return t.activeTabId===e?GJ(this.routeResolver,c,Or(o)):c})},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?GJ(this.routeResolver,{...t,activeTabId:e,isOpen:!0},Or(n)):t})}}};function $J(e){return e.activeWorkspacePanelKind!=null}var eY=class{constructor(){this.accountManager=new Ja,this.rightPanelResourceRouteResolver=new D,this.notifyRightPanelOpened=()=>{let e=Lr.getState().snapshot,t=Ul.getState().snapshot;to.collapseSidebarForDenseRightPanels({isDocBrowserDocked:e.mode===`docked`,isDocBrowserOpen:e.isOpen,isWorkspacePanelOpen:$J(t)})},this.docBrowserManager=new QJ(this.rightPanelResourceRouteResolver,this.notifyRightPanelOpened),this.sideDockManager=new te(this.docBrowserManager),this.chatDraftIntentManager=new LJ,this.serviceActionAuthorizationManager=new nB,this.panelAppBridgeManager=new Kz(this.serviceActionAuthorizationManager),this.remoteAccessManager=new Ia({accountManager:this.accountManager})}},tY=null;function nY(){return tY??=new eY,tY}function rY(){return nY()}var iY=globalThis,aY=iY.__NEXTCLAW_APP_PRESENTER_CONTEXT__??(0,L.createContext)(null);iY.__NEXTCLAW_APP_PRESENTER_CONTEXT__=aY;function oY({children:e}){let t=(0,L.useMemo)(()=>nY(),[]);return(0,R.jsx)(aY.Provider,{value:t,children:e})}function sY(){let e=(0,L.useContext)(aY);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}function cY(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function lY(e){let{request:t,result:n}=e,r=new Date().toISOString();return n.type===`skill`?{type:`skill`,spec:n.spec,id:t.skill??n.spec,label:t.skill??n.name??n.spec,source:`workspace`,installPath:t.installPath,installedAt:r}:{type:n.type,spec:n.spec,id:n.name??n.spec,label:n.name??n.spec,source:`marketplace`,origin:`marketplace`,enabled:t.enabled??!0,runtimeStatus:t.enabled===!1?`disabled`:`ready`,installedAt:r}}function uY(e,t){let{id:n,spec:r}=t;return!!(r&&e.spec===r||n&&e.id===n)}function dY(e,t){return t??{type:e,total:0,specs:[],records:[]}}function fY(e){let{result:t,view:n}=e,r=dY(t.type,n),i=lY(e),a=r.records.findIndex(e=>uY(e,{id:i.id,spec:i.spec})),o=[...r.records];return a>=0?o[a]={...o[a],...i}:o.unshift(i),{...r,type:t.type,records:o,specs:cY(o),total:o.length}}function pY(e){let{request:t,result:n,view:r}=e,i=dY(n.type,r);if(n.action===`uninstall`||n.action===`remove`){let e=i.records.filter(e=>!uY(e,{id:n.id,spec:t.spec}));return{...i,records:e,specs:cY(e),total:e.length}}let a=i.records.map(e=>uY(e,{id:n.id,spec:t.spec})?n.action===`disable`?{...e,enabled:!1,runtimeStatus:`disabled`}:n.action===`update`?{...e,installedAt:new Date().toISOString(),origin:e.origin??`marketplace`}:{...e,enabled:!0,runtimeStatus:`ready`}:e);return{...i,records:a,specs:cY(a),total:a.length}}function mY(e){let t=Mt({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>rt({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&hY(r,e)?t:void 0},staleTime:15e3}),n=(0,L.useMemo)(()=>jt(t.data),[t.data]);return{...t,data:n}}function hY(e,t){return e.tag===t.tag&&e.scene===t.scene&&e.pageSize===t.pageSize}function gY(e=!0){return Me({queryKey:[`marketplace-skill-scenes`],queryFn:De,enabled:e,staleTime:6e4})}function _Y(e,t=!0){let n=Gr({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>rt({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,L.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function vY(e){return Me({queryKey:[`marketplace-installed`,e],queryFn:()=>ce(e),staleTime:1e4})}function yY(){let e=Be();return we({mutationFn:e=>Ae(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>fY({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),P.success(t.message||d(`marketplaceInstallSuccessSkill`))},onError:e=>{P.error(e.message||d(`marketplaceInstallFailed`))}})}function bY(){let e=Be();return we({mutationFn:e=>ge(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>pY({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`});let r=t.action===`enable`?d(`marketplaceEnableSuccess`):t.action===`disable`?d(`marketplaceDisableSuccess`):t.action===`update`?d(`marketplaceUpdateSuccess`):d(`marketplaceUninstallSuccess`);P.success(t.message||r)},onError:e=>{P.error(e.message||d(`marketplaceOperationFailed`))}})}var xY=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`];function SY(e){let{name:t,fallback:n,className:r}=e,i=t||n,a=i.substring(0,2).toUpperCase();return(0,R.jsx)(`div`,{className:p(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-sm font-semibold text-white`,CY(i),r),children:a})}function CY(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return xY[Math.abs(t)%xY.length]}function wY({title:e,spec:t}){return(0,R.jsxs)(Ln,{delayDuration:400,children:[(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`div`,{className:`truncate text-[14px] font-semibold leading-tight text-gray-950`,children:e})}),(0,R.jsx)(Fn,{className:`max-w-[300px] text-xs`,children:e})]}),(0,R.jsx)(`div`,{className:`mb-2 mt-1 flex min-w-0 items-center gap-1.5`,children:t?(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`span`,{className:`max-w-full truncate text-[11px] font-mono leading-tight text-gray-400`,children:t})}),(0,R.jsx)(Fn,{className:`max-w-[300px] break-all font-mono text-xs`,children:t})]}):null})]})}function TY(e){let{item:t,record:n,state:r,onInstall:i,onManage:a}=e,{isInstalling:o,canUpdate:s,canUninstall:c,busyAction:l}=r,u=!!l;return t&&!n||n&&(s||c)?(0,R.jsxs)(`div`,{className:p(`flex shrink-0 items-center justify-end gap-1.5 opacity-100 transition-opacity duration-150`,`md:pointer-events-none md:opacity-0`,`md:group-hover:pointer-events-auto md:group-hover:opacity-100`,`md:group-focus-within:pointer-events-auto md:group-focus-within:opacity-100`),children:[t&&!n&&(0,R.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),i(t)},disabled:o,className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md bg-primary px-2 text-[11px] font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50`,children:[(0,R.jsx)(pi,{className:`h-3 w-3`}),d(o?`marketplaceInstalling`:`marketplaceInstall`)]}),n&&s&&(0,R.jsxs)(`button`,{disabled:u,onClick:e=>{e.stopPropagation(),a(`update`,n)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-blue-200/80 bg-white px-2 text-[11px] font-medium text-blue-600 transition-colors hover:border-blue-300 hover:bg-blue-50 disabled:opacity-50`,children:[(0,R.jsx)(br,{className:`h-3 w-3`}),d(l===`update`?`marketplaceUpdating`:`marketplaceUpdate`)]}),n&&c&&(0,R.jsxs)(`button`,{disabled:u,onClick:e=>{e.stopPropagation(),a(`uninstall`,n)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-gray-200/80 bg-white px-2 text-[11px] font-medium text-gray-500 transition-colors hover:border-rose-200 hover:bg-rose-50 hover:text-rose-600 disabled:opacity-50`,children:[(0,R.jsx)(ha,{className:`h-3 w-3`}),d(l===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)]})]}):null}function EY(e){let{record:t,disabled:n}=e;return t?(0,R.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-end`,children:(0,R.jsx)(DY,{disabled:n})}):null}function DY(e){let{disabled:t}=e,n=d(t?`marketplaceDisabledStatus`:`marketplaceInstalledStatus`);return(0,R.jsx)(Ln,{delayDuration:300,children:(0,R.jsxs)(zn,{children:[(0,R.jsx)(Nn,{asChild:!0,children:(0,R.jsx)(`span`,{"aria-label":n,className:p(`inline-flex h-5 w-5 items-center justify-center`,t?`text-gray-400`:`text-emerald-700`),children:t?(0,R.jsx)(ni,{className:`h-4 w-4 opacity-40`}):(0,R.jsx)(ni,{className:`h-4 w-4`})})}),(0,R.jsx)(Fn,{className:`text-xs`,children:n})]})})}function OY(e){let{item:t,record:n,installState:r,manageState:i,onOpen:a,onInstall:o,onManage:s}=e,{language:c}=pr(),l=It(c),u=t?.name??n?.label??n?.id??n?.spec??d(`marketplaceUnknownItem`),f=Rt(t?.summaryI18n,t?.summary,l)||(n?d(`marketplaceInstalledLocalSummary`):``),p=t?.install.spec??n?.spec??``,m=t?.tags??[],h=n?.id||n?.spec,g=h?i.actionsByTarget.get(h):void 0,_=n?.type===`skill`&&n.source===`workspace`,v=n?.type===`skill`&&n.origin===`marketplace`,y=n?n.enabled===!1||n.runtimeStatus===`disabled`:!1,b=t?.install.spec,x=typeof b==`string`&&r.installingSpecs.has(b);return(0,R.jsxs)(`article`,{onClick:a,className:`group flex h-full min-h-[156px] cursor-pointer flex-col rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,R.jsx)(SY,{name:u,fallback:p||d(`marketplaceTypeSkill`),className:`h-9 w-9 rounded-lg text-xs`}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,R.jsx)(wY,{title:u,spec:p})}),(0,R.jsx)(EY,{record:n,disabled:y})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`p`,{className:`line-clamp-2 text-left text-[12px] leading-relaxed text-gray-500`,children:f}),(0,R.jsxs)(`div`,{className:`mt-auto flex min-w-0 items-end justify-between gap-2 pt-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(kY,{tags:m})}),(0,R.jsx)(TY,{item:t,record:n,state:{isInstalling:x,canUpdate:v,canUninstall:_,busyAction:g},onInstall:o,onManage:s})]})]})]})}function kY({tags:e}){let t=e.filter(AY).slice(0,3);return t.length===0?null:(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5 overflow-hidden`,children:t.map(e=>(0,R.jsx)(`span`,{className:`max-w-[104px] truncate rounded-md bg-gray-100 px-2 py-0.5 text-[11px] font-medium leading-5 text-gray-500`,children:e},e))})}function AY(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function jY({model:e,showTitle:t,operationState:n,scroll:r,actions:i}){let{scope:a,entries:o,header:s,status:c,emptyLabel:l,errorLabel:u}=e,{showSkeleton:d,isRefreshing:f,error:m}=c,{hasMore:h,loadingMore:g,sentinelRef:_}=r,{installState:v,manageState:y}=n,{onOpen:b,onInstall:x,onManage:S}=i;return(0,R.jsxs)(`section`,{className:p(`flex min-h-full flex-col`,t&&`gap-3`),children:[t&&(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-950`,children:s.title}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-gray-500`,children:[f&&(0,R.jsx)(`span`,{className:`font-medium text-primary`,children:s.refreshingLabel}),(0,R.jsx)(`span`,{children:s.summary})]})]}),m&&(0,R.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[u,`: `,m.message]}),f&&(0,R.jsx)(`div`,{"data-testid":`marketplace-list-refreshing`,className:`h-0.5 overflow-hidden rounded-full bg-primary/10`,children:(0,R.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-primary`})}),(0,R.jsxs)(`div`,{"data-testid":d?`marketplace-list-skeleton`:void 0,className:p(`grid grid-cols-1 gap-2.5 md:grid-cols-2 xl:grid-cols-3`,d&&`min-h-0 flex-1 auto-rows-[156px] content-start`),children:[d&&(0,R.jsx)(zt,{count:36}),!d&&!m&&o.map(e=>(0,R.jsx)(OY,{item:e.item,record:e.record,installState:v,manageState:y,onOpen:()=>b(e.item,e.record),onInstall:x,onManage:S},e.key))]}),!d&&!m&&o.length===0&&(0,R.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:l}),a===`all`&&!d&&!m&&(0,R.jsx)(Pt,{hasMore:h,loading:g,sentinelRef:_})]})}function MY(e){let{entry:t,language:n,localeFallbacks:r,installState:i,layout:a=`rail`,onOpen:o,onInstall:s}=e,{item:c,record:l}=t,u=Rt(c.summaryI18n,c.summary,r),f=c.install.spec,m=i.installingSpecs.has(f),h=!!l;return(0,R.jsxs)(`article`,{onClick:()=>o(t),className:p(`group flex min-h-[166px] cursor-pointer flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,a===`rail`?`w-[260px] shrink-0`:`w-full min-w-0`),children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,R.jsx)(SY,{name:c.name,fallback:c.install.spec}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] font-semibold leading-tight text-gray-950`,children:c.name}),(0,R.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] font-mono leading-tight text-gray-400`,children:NY(c)})]})]}),(0,R.jsx)(`p`,{className:`line-clamp-2 text-[12px] leading-relaxed text-gray-500`,children:u}),(0,R.jsx)(PY,{tags:c.tags})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-gray-400`,children:IY(c.updatedAt)}),h?(0,R.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 text-[11px] font-semibold text-emerald-700`,children:[(0,R.jsx)(ni,{className:`h-3.5 w-3.5`}),LY({zh:`已安装`,en:`Installed`},n)]}):(0,R.jsxs)(`button`,{type:`button`,disabled:m,onClick:e=>{e.stopPropagation(),s(c)},className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-gray-200 bg-white px-2 text-[11px] font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 disabled:opacity-50`,children:[(0,R.jsx)(pi,{className:`h-3.5 w-3.5`}),d(m?`marketplaceInstalling`:`marketplaceInstall`)]})]})]})}function NY(e){return e.slug||e.install.spec}function PY({tags:e}){let t=e.filter(FY).slice(0,2);return t.length===0?null:(0,R.jsx)(`div`,{className:`mt-auto truncate pt-2 text-[11px] font-medium text-gray-400`,children:t.join(` / `)})}function FY(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function IY(e){return e.slice(0,10)||e}function LY(e,t){return t.startsWith(`zh`)?e.zh:e.en}var RY=[{scene:`development-debugging`,title:{zh:`开发与调试`,en:`Development`},summary:{zh:`代码审查、错误定位、架构分析与交付验证。`,en:`Review, debug, analyze, and verify delivery work.`},icon:da,tone:`dark`,span:`md:col-span-2`},{scene:`office-collaboration`,title:{zh:`办公协作`,en:`Office Work`},summary:{zh:`连接文档、日历、会议、邮件和团队通信。`,en:`Connect docs, calendars, meetings, mail, and teams.`},icon:$r,tone:`green`,span:`md:col-span-2`},{scene:`writing-content`,title:{zh:`写作与内容`,en:`Writing`},summary:{zh:`把调研、写作、润色和发布组织成连续工作流。`,en:`Turn research, writing, polishing, and publishing into one flow.`},icon:Zi,tone:`amber`,span:`md:col-span-2`},{scene:`browser-automation`,title:{zh:`浏览器自动化`,en:`Browser`},summary:{zh:`操作网页、捕获动态内容并验证真实用户路径。`,en:`Operate pages, capture dynamic content, and verify user paths.`},icon:mi,tone:`blue`,span:`md:col-span-2`},{scene:`local-environment`,title:{zh:`本地环境`,en:`Local`},summary:{zh:`管理终端、文件、运行时和本地服务。`,en:`Manage shells, files, runtimes, and local services.`},icon:fi,tone:`violet`,span:`md:col-span-1`},{scene:`social-platforms`,title:{zh:`社交平台`,en:`Social`},summary:{zh:`处理发布、互动、检索和内容分发。`,en:`Handle posting, interaction, search, and distribution.`},icon:Gi,tone:`sky`,span:`md:col-span-1`},{scene:`nextclaw-official`,title:{zh:`NextClaw 官方`,en:`NextClaw Official`},summary:{zh:`优先查看由 NextClaw 维护的原生能力。`,en:`Browse native capabilities maintained by NextClaw.`},icon:xr,tone:`teal`,span:`md:col-span-2`}],zY={icon:xr,tone:`dark`,span:`md:col-span-2`},BY={dark:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-stone-600 bg-stone-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},blue:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-cyan-600 bg-cyan-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},green:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-emerald-600 bg-emerald-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},amber:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-amber-600 bg-amber-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},violet:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-violet-500 bg-violet-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},sky:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-sky-500 bg-sky-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},teal:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-teal-600 bg-teal-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`}},VY=`grid grid-cols-[repeat(auto-fill,minmax(240px,320px))] justify-start gap-3`;function HY(e){let{entries:t,scenes:n,isScenesLoading:r,isItemsLoading:i,language:a,installState:o,onOpen:s,onInstall:c,onOpenScene:l}=e,u=It(a),d=[...t].sort((e,t)=>qY(e.item,t.item)).slice(0,6);return(0,R.jsxs)(`div`,{className:`mb-4 space-y-5`,children:[(0,R.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,R.jsx)(KY,{icon:li,title:JY({zh:`场景`,en:`Scenes`},a),description:JY({zh:`按使用场景浏览适合的技能组合。`,en:`Browse skills by how you plan to use them.`},a)}),r?(0,R.jsx)(`div`,{"data-testid":`marketplace-scenes-skeleton`,className:`grid auto-rows-[104px] grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:(0,R.jsx)(zt,{count:RY.length})}):(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:n.map(e=>(0,R.jsx)(UY,{scene:e,language:a,onSelect:l},e.scene))})]}),(i||d.length>0)&&(0,R.jsx)(GY,{icon:oi,title:JY({zh:`最近更新`,en:`Recently updated`},a),description:JY({zh:`看看生态最近在补齐哪些能力。`,en:`See what the ecosystem has been improving lately.`},a),entries:d,language:a,localeFallbacks:u,isLoading:i,installState:o,onOpen:s,onInstall:c})]})}function UY(e){let{scene:t,language:n,onSelect:r}=e,i=YY(t.scene),a=i.icon,o=BY[i.tone];return(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(t.scene),className:p(`group flex min-h-[74px] flex-col justify-center rounded-lg border px-3 py-2.5 text-left shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/70`,o.card),children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:p(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,o.icon),children:(0,R.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-gray-950`,children:XY(t,i,n)}),typeof t.count==`number`&&(0,R.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:QY(t.count,n)})]}),(0,R.jsx)(`p`,{className:p(`mt-1 line-clamp-1 text-[11px] leading-relaxed`,o.text),children:ZY(t,i,n)})]})})}function WY(e){let{scene:t,entries:n,isLoading:r,language:i,localeFallbacks:a,installState:o,onBack:s,onOpen:c,onInstall:l}=e,u=YY(t.scene),d=u.icon,f=BY[u.tone];return(0,R.jsxs)(`section`,{className:`flex min-h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`mb-4 flex min-w-0 items-start gap-2.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":JY({zh:`返回`,en:`Back`},i),children:(0,R.jsx)(Cn,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:p(`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border`,f.icon),children:(0,R.jsx)(d,{className:`h-4 w-4`})}),(0,R.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-gray-950`,children:XY(t,u,i)}),(0,R.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:JY(r?{zh:`加载中`,en:`Loading`}:{zh:`${n.length} 个技能`,en:`${n.length} skills`},i)})]}),(0,R.jsx)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2`,children:(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[12px] leading-relaxed text-gray-500`,children:ZY(t,u,i)})})]})]}),r?(0,R.jsx)(`div`,{"data-testid":`marketplace-scene-skeleton`,className:p(VY,`min-h-0 flex-1 auto-rows-[166px] content-start`),children:(0,R.jsx)(zt,{count:24})}):n.length>0?(0,R.jsx)(`div`,{className:VY,children:n.map(e=>(0,R.jsx)(MY,{entry:e,language:i,localeFallbacks:a,installState:o,layout:`grid`,onOpen:c,onInstall:l},e.item.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-200 py-8 text-center text-[12px] text-gray-500`,children:JY({zh:`这个模块暂无技能。`,en:`No skills in this module yet.`},i)})]})}function GY(e){let{icon:t,title:n,description:r,entries:i,language:a,localeFallbacks:o,isLoading:s,installState:c,onOpen:l,onInstall:u}=e;return(0,R.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,R.jsx)(KY,{icon:t,title:n,description:r}),s?(0,R.jsx)(`div`,{"data-testid":`marketplace-recent-skeleton`,className:`-mx-1 grid auto-rows-[166px] grid-cols-[repeat(4,260px)] gap-2.5 overflow-hidden px-1 pb-1.5`,children:(0,R.jsx)(zt,{count:4})}):(0,R.jsx)(`div`,{className:`-mx-1 flex gap-2.5 overflow-x-auto px-1 pb-1.5 custom-scrollbar`,children:i.map(e=>(0,R.jsx)(MY,{entry:e,language:a,localeFallbacks:o,installState:c,onOpen:l,onInstall:u},e.item.id))})]})}function KY({icon:e,title:t,description:n}){return(0,R.jsx)(`div`,{className:`flex items-end justify-between gap-4`,children:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`h3`,{className:`flex items-center gap-2 text-[14px] font-semibold text-gray-950`,children:[(0,R.jsx)(e,{className:`h-4 w-4 text-primary`}),t]}),(0,R.jsx)(`p`,{className:`mt-0.5 text-[12px] leading-relaxed text-gray-500`,children:n})]})})}function qY(e,t){let n=Date.parse(e.updatedAt),r=Date.parse(t.updatedAt);return Number.isNaN(n)||Number.isNaN(r)?t.updatedAt.localeCompare(e.updatedAt):r-n}function JY(e,t){return t.startsWith(`zh`)?e.zh:e.en}function YY(e){return RY.find(t=>t.scene===e)??{scene:e,...zY}}function XY(e,t,n){return t.title?JY(t.title,n):e.title}function ZY(e,t,n){return t.summary?JY(t.summary,n):e.description??e.scene}function QY(e,t){return t.startsWith(`zh`)?`${e} 个技能`:`${e} skills`}function $Y({label:e,className:t,onClick:n}){return(0,R.jsxs)(`button`,{type:`button`,className:p(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-1.5 text-[13px] font-medium text-primary transition-colors hover:text-primary-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,t),onClick:n,children:[(0,R.jsx)(_r,{className:`h-3.5 w-3.5`}),e]})}var eX=`https://skillhub.cn/`;function tX(){return(0,R.jsx)($Y,{label:d(`marketplaceExternalSkillSourceTitle`),onClick:()=>void wr.openExternalUrl(eX)})}function nX(e){return(e??``).trim().toLowerCase()}function rX(e,t){let n=nX(t);return n.length>0?`${e}:${n}`:``}function iX(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=rX(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function aX(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=rX(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function oX(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=rX(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function sX(e,t){return t.get(rX(e.type,e.spec))||t.get(rX(e.type,e.id))||t.get(rX(e.type,e.label))}function cX(e,t,n,r){let i=nX(n);if(!i)return!0;let a=Rt(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>nX(e)).filter(Boolean).some(e=>e.includes(i))}function lX(e){let{items:t,installedRecordLookup:n,scene:r,forcedType:i,typeFilter:a,scope:o,searchText:s,query:c,showListSkeleton:l,hasCatalogError:u}=e,d=gY(a===`skill`),f=(0,L.useMemo)(()=>d.data?.scenes??[],[d.data?.scenes]),p=_Y(f,a===`skill`),m=(0,L.useMemo)(()=>f.map(e=>({...e,count:typeof e.count==`number`?e.count:p.get(e.scene)})),[p,f]),h=(0,L.useMemo)(()=>t.map(e=>({item:e,record:oX(e,n)})),[t,n]),g=(0,L.useMemo)(()=>{let e=r?.trim();if(e)return m.find(t=>t.scene===e)??{scene:e,title:e}},[r,m]),_=a===`skill`&&!!r?.trim(),v=a===`skill`&&o===`all`&&!s.trim()&&!c&&!_,y=l||t.length>=4,b=v&&!u&&y&&m.length===0&&d.isLoading;return{entries:h,scenes:m,selectedScene:g,sceneEntries:h,isSceneRoute:_,isScenesLoading:b,showShelves:v&&!u&&y&&(l||m.length>0||b),backPath:i?`/skills`:`/marketplace/skills`,pathPrefix:i?`/skills/scenes`:`/marketplace/skills/scenes`}}function uX(){let e=yY(),t=bY(),{confirm:n,ConfirmDialog:r}=Dr(),[i,a]=(0,L.useState)(new Set),[o,s]=(0,L.useState)(new Map);return{installState:{installingSpecs:i},manageState:{actionsByTarget:o},handleInstall:async t=>{let n=t.install.spec;if(!i.has(n)){a(e=>new Set(e).add(n));try{await e.mutateAsync({type:t.type,spec:n,kind:t.install.kind,skill:t.slug,installPath:`skills/${t.slug}`})}catch{}finally{a(e=>{let t=new Set(e);return t.delete(n),t})}}},handleManage:async(e,r)=>{let i=e===`update`?r.catalogSlug||r.id||r.spec:r.id||r.spec;if(!(!i||o.has(i))&&!(e===`uninstall`&&!await n({title:`${d(`marketplaceUninstallTitle`)} ${i}?`,description:d(`marketplaceUninstallDescription`),confirmLabel:d(`marketplaceUninstall`),variant:`destructive`}))){s(t=>new Map(t).set(i,e));try{await t.mutateAsync({type:r.type,action:e,id:i,spec:r.spec})}finally{s(e=>{let t=new Map(e);return t.delete(i),t})}}},ConfirmDialog:r}}function dX(e){let t=Pr(),n=(0,L.useRef)({byKey:new Map,seq:0});return{openItemDetail:async(r,i)=>{let a=r?.name??i?.label??i?.id??i?.spec??d(`marketplaceUnknownItem`),o=Nt(r?`skill`:`skill-local`,r?.slug??i?.id??i?.spec??a),s=r?`marketplace:${r.type}:${r.slug}`:`marketplace:${i?.type??`unknown`}:${i?.id??i?.spec??a}`,c=d(`marketplaceTypeSkill`);if(!r){kt(t,{id:o,title:a,typeLabel:c,spec:i?.spec??`-`,status:`ready`,summary:d(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(i??{},null,2),contentRaw:`-`});return}let l=n.current.seq+1;n.current.seq=l,n.current.byKey.set(s,l);let u=Rt(r.summaryI18n,r.summary,e);kt(t,{id:o,title:a,typeLabel:c,spec:r.install.spec,status:`loading`,summary:u,tags:r.tags,author:r.author});try{let e=await Te(r.slug);if(n.current.byKey.get(s)!==l)return;kt(t,{id:o,title:a,typeLabel:c,spec:r.install.spec,status:`ready`,summary:u,metadataRaw:e.metadataRaw,contentRaw:e.bodyRaw||e.raw,sourceUrl:e.sourceUrl,sourceLabel:`Source (${e.source})`,tags:r.tags,author:r.author},{activate:!1})}catch(e){if(n.current.byKey.get(s)!==l)return;kt(t,{id:o,title:a,typeLabel:c,spec:r.install.spec,status:`error`,summary:u,metadataRaw:JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),contentRaw:d(`marketplaceOperationFailed`)},{activate:!1})}}}}function fX(e){let{scope:t,typeFilter:n,query:r,localeFallbacks:i,catalogView:a,installedView:o,isCatalogLoading:s,isCatalogFetching:c,isCatalogFetchingNextPage:l,catalogError:u,isInstalledLoading:f,installedError:p}=e,m=(0,L.useMemo)(()=>o?.records??[],[o?.records]),h=(0,L.useMemo)(()=>a?.items??[],[a?.items]),g=(0,L.useMemo)(()=>iX(h),[h]),_=(0,L.useMemo)(()=>aX(m),[m]),v=(0,L.useMemo)(()=>m.filter(e=>e.type===n).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:sX(e,g)})).filter(e=>cX(e.record,e.item,r,i)).sort((e,t)=>pX(e.record,t.record)),[m,n,g,r,i]),y=(0,L.useMemo)(()=>t===`installed`?v:h.map(e=>({key:e.id,item:e,record:oX(e,_)})),[h,v,_,t]),b=t===`all`&&s&&!a||t===`installed`&&f&&!o,x=t===`all`&&!b&&!!a&&c&&!l,S=t===`installed`?f&&!o?d(`loading`):`${v.length} ${d(`marketplaceInstalledSkillsCountSuffix`)}`:a?`${h.length} / ${a.total}`:d(`loading`),C=t===`all`&&u?u:t===`installed`&&p?p:void 0,w={scope:t,entries:y,header:{title:d(t===`installed`?`marketplaceSectionInstalledSkills`:`marketplaceAllSkills`),summary:S,refreshingLabel:d(`marketplaceRefreshingResults`)},status:{showSkeleton:b,isRefreshing:x,error:C},emptyLabel:d(t===`installed`?`marketplaceNoInstalledSkills`:`marketplaceNoSkills`),errorLabel:d(t===`installed`?`marketplaceErrorLoadingInstalledSkills`:`marketplaceErrorLoadingSkillsData`)};return{allItems:h,installedRecordLookup:_,installedTotal:o?.total??0,itemListView:w,showListSkeleton:b,isRefreshingList:x}}function pX(e,t){let n=Date.parse(e.installedAt??``),r=Date.parse(t.installedAt??``);return Number.isNaN(n)||Number.isNaN(r)||n===r?e.spec.localeCompare(t.spec):r-n}var mX=20;function hX({forcedType:e}={}){let t=ie(),n=v(),{language:r}=pr(),i=`skill`,a=(0,L.useMemo)(()=>It(r),[r]),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),[u,f]=(0,L.useState)(`all`),[p,m]=(0,L.useState)(`relevance`),{installState:h,manageState:g,handleInstall:_,handleManage:y,ConfirmDialog:b}=uX(),{openItemDetail:x}=dX(a);(0,L.useEffect)(()=>{let e=setTimeout(()=>{l(o.trim())},250);return()=>clearTimeout(e)},[o]);let S=vY(i),C=i===`skill`?n.scene?.trim():void 0,w=mY({q:C?void 0:c||void 0,scene:C,type:i,sort:p,pageSize:mX}),{containerRef:T,sentinelRef:E}=Ft({disabled:u!==`all`||w.isError||!w.hasNextPage||w.isFetchingNextPage,onLoadMore:()=>w.fetchNextPage(),watchValue:`${i}:${u}:${c}:${C??``}:${p}:${w.data?.loadedItems??0}:${w.data?.loadedPages??0}`});(0,L.useEffect)(()=>{let e=T.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[T,c,C,u,p,i]);let D=fX({scope:u,typeFilter:i,query:c,localeFallbacks:a,catalogView:w.data,installedView:S.data,isCatalogLoading:w.isLoading,isCatalogFetching:w.isFetching,isCatalogFetchingNextPage:w.isFetchingNextPage,catalogError:w.isError?w.error:void 0,isInstalledLoading:S.isLoading,installedError:S.isError?S.error:void 0}),O=lX({items:D.allItems,installedRecordLookup:D.installedRecordLookup,scene:C,forcedType:e,typeFilter:i,scope:u,searchText:o,query:c,showListSkeleton:D.showListSkeleton,hasCatalogError:w.isError});return(0,R.jsxs)(Vt,{className:`flex h-full min-h-0 flex-col pb-0`,children:[!O.isSceneRoute&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3 border-b border-gray-200/60`,children:[(0,R.jsx)(Rz,{value:u,onValueChange:e=>f(e),children:(0,R.jsxs)(zz,{className:`mb-0 h-auto flex-1 justify-start gap-6 rounded-none border-b-0 bg-transparent p-0 text-gray-500`,children:[(0,R.jsx)(Bz,{value:`all`,className:`rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:d(`marketplaceTabMarketplaceSkills`)}),(0,R.jsxs)(Bz,{value:`installed`,className:`gap-1.5 rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:[d(`marketplaceTabInstalledSkills`),(0,R.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:D.installedTotal})]})]})}),(0,R.jsx)(tX,{})]}),(0,R.jsx)(At,{scope:u,searchText:o,isRefreshing:D.isRefreshingList,searchPlaceholder:d(`marketplaceSearchPlaceholderSkills`),sort:p,onSearchTextChange:s,onSortChange:m})]}),(0,R.jsx)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsxs)(`div`,{ref:T,className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":D.showListSkeleton||w.isFetchingNextPage,children:[O.isSceneRoute&&O.selectedScene&&(0,R.jsx)(WY,{scene:O.selectedScene,entries:O.sceneEntries,isLoading:D.showListSkeleton,language:r,localeFallbacks:a,installState:h,onBack:()=>t(O.backPath),onOpen:e=>void x(e.item,e.record),onInstall:_}),O.isSceneRoute&&!D.showListSkeleton&&(0,R.jsx)(Pt,{hasMore:!!w.hasNextPage,loading:w.isFetchingNextPage,sentinelRef:E}),O.showShelves&&(0,R.jsx)(HY,{entries:O.entries,scenes:O.scenes,isScenesLoading:O.isScenesLoading,isItemsLoading:D.showListSkeleton,language:r,installState:h,onOpen:e=>void x(e.item,e.record),onInstall:_,onOpenScene:e=>t(`${O.pathPrefix}/${e}`)}),!O.isSceneRoute&&(0,R.jsx)(jY,{model:D.itemListView,showTitle:O.showShelves||!D.showListSkeleton,operationState:{installState:h,manageState:g},scroll:{hasMore:!!w.hasNextPage,loadingMore:w.isFetchingNextPage,sentinelRef:E},actions:{onOpen:(e,t)=>void x(e,t),onInstall:_,onManage:y}})]})}),(0,R.jsx)(b,{})]})}var gX=`NextClaw`,_X=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function vX(e,t){return e===t||e.startsWith(`${t}/`)}function yX(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of _X)if(vX(t,e))return d(n);return d(`settings`)}function bX(e){let t=e.toLowerCase();return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||t===`[::1]`||t.startsWith(`127.`)}function xX(e){let t=e?.host.trim(),n=e?.hostname.trim(),r=e?.port.trim();return!t||!n?null:bX(n)?r||null:t}function SX(e,t){let n=xX(t);return`${gX}${n?` ${n}`:``} - ${yX(e)}`}var CX={...jB,...Lt};function wX({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=Pr();hr();let{pathname:i}=h(),{language:a}=pr(),{isMobile:o}=eW(),s=Gq(),c=M(e=>e.isVisible);M(e=>e.pinnedItems);let l={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,L.useEffect)(()=>{document.title=SX(i,window.location)},[i,a]),o&&s!==`win32`?(0,R.jsx)(Qq,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:l,docBrowserRenderers:CX,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,R.jsx)(nJ,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:l,docBrowserRenderers:CX,sideDock:c?(0,R.jsx)(A,{manager:t}):null,children:e})}function TX({children:e}){let t=rY();return(0,R.jsx)(zr,{manager:t.docBrowserManager,children:(0,R.jsx)(wX,{sideDockManager:t.sideDockManager,children:e})})}function EX(){let{isMobile:e}=eW();return e?(0,R.jsx)($q,{}):(0,R.jsx)(x,{to:`/model`,replace:!0})}function DX(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function OX(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function kX(e,t){e&&DX(t)&&e.invalidateQueries({queryKey:[`config`]}),OX(e,t)}function AX(e){let t=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let n=F.eventBus.on(it.connectionOpen,()=>{wt.handleConnectionRestored(),Ct.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=F.eventBus.on(it.connectionClose,()=>{wt.handleConnectionInterrupted(null),t.current=!0}),i=F.eventBus.on(it.connectionError,e=>{wt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=F.eventBus.on(it.configUpdated,({path:t})=>{kX(e,t)}),o=F.eventBus.on(it.runtimeUpdateSnapshot,e=>{Ct.reportSnapshot(e)}),s=F.eventBus.on(it.sessionRunStatus,t=>{Xe(e,{type:`session.run-status`,payload:t})}),c=F.eventBus.on(it.sessionSummaryUpsert,t=>{Xe(e,{type:`session.summary.upsert`,payload:t})}),l=F.eventBus.on(it.sessionSummaryDelete,t=>{Xe(e,{type:`session.summary.delete`,payload:t})}),u=F.eventBus.on(it.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var jX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{ModelConfigPage:e}=await import(`./model-config-page-bNNo-XyG.js`);return{ModelConfigPage:e}},__vite__mapDeps([13,2,14,15,16,3,17,18,19,20,21,11,12,22,23,24]))).ModelConfigPage})),MX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{AppearanceSettingsPage:e}=await import(`./appearance-settings-page-DMffQFR3.js`);return{AppearanceSettingsPage:e}},__vite__mapDeps([25,2,26,3,4,5,16,8,10,12,11,27,28,19,15,29,30]))).AppearanceSettingsPage})),NX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{ChatPage:e}=await import(`./chat-page-H5a0dWvO.js`);return{ChatPage:e}},__vite__mapDeps([31,2,26,3,4,5,16,8,10,12,11,27,28,19,15,29,18,14,17,32,1,6,7,9,33,21,34,23]))).ChatPage})),PX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{SearchConfigPage:e}=await import(`./search-config-page-B-Cf4iiB.js`);return{SearchConfigPage:e}},__vite__mapDeps([35,2,18,3,19,14,15,6,7,36,22,23]))).SearchConfigPage})),FX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{ProvidersConfigPage:e}=await import(`./providers-config-page-wLo6CAJw.js`);return{ProvidersConfigPage:e}},__vite__mapDeps([37,2,3,18,19,28,5,15,10,14,6,33,8,36,22,23,24,29]))).ProvidersConfigPage})),IX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-CCtp0BRS.js`);return{ChannelsList:e}},__vite__mapDeps([38,2,3,18,19,14,15,6,16,7,20,10,36,34,22,23,24]))).ChannelsList})),LX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-DDn1sP4G.js`);return{RuntimeConfig:e}},__vite__mapDeps([39,2,18,3,19,14,15,32,1,4,5,6,7,8,9,10,11,12,20,40,41,30,22,23]))).RuntimeConfig})),RX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-KzTuXRf_.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([42,2,18,3,19,14,15,7,9,40,29]))).DesktopUpdateConfig})),zX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{SecurityConfig:e}=await import(`./security-config-e9SSBlKr.js`);return{SecurityConfig:e}},__vite__mapDeps([43,14,2,15]))).SecurityConfig})),BX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{SecretsConfigPage:e}=await import(`./secrets-config-page-DPKsY8Iw.js`);return{SecretsConfigPage:e}},__vite__mapDeps([44,2,18,3,19,14,15,8,41,22,23]))).SecretsConfigPage})),VX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{RemoteAccessPage:e}=await import(`./remote-uKEYp7AR.js`);return{RemoteAccessPage:e}},[])).RemoteAccessPage})),HX=(0,L.lazy)(async()=>({default:(await g(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-D6idOTLp.js`);return{McpMarketplacePage:e}},__vite__mapDeps([45,46,2,3,18,19,28,5,15,10,14,32,1,4,6,7,8,9,11,12,20,21,34,27]))).McpMarketplacePage}));function UX(){return(0,R.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function WX({children:e}){return(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(UX,{}),children:e})}function GX(e){return(0,R.jsx)(WX,{children:e})}var KX=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:GX((0,R.jsx)(NX,{view:`chat`}))},{path:`/agents`,element:GX((0,R.jsx)(NX,{view:`agents`}))},{path:`/skills`,element:GX((0,R.jsx)(NX,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:GX((0,R.jsx)(NX,{view:`skills`}))},{path:`/cron`,element:GX((0,R.jsx)(NX,{view:`cron`}))},{path:`/appearance`,element:GX((0,R.jsx)(MX,{}))},{path:`/model`,element:GX((0,R.jsx)(jX,{}))},{path:`/search`,element:GX((0,R.jsx)(PX,{}))},{path:`/providers`,element:GX((0,R.jsx)(FX,{}))},{path:`/channels`,element:GX((0,R.jsx)(IX,{}))},{path:`/runtime`,element:GX((0,R.jsx)(LX,{}))},{path:`/updates`,element:GX((0,R.jsx)(RX,{}))},{path:`/remote`,element:GX((0,R.jsx)(VX,{}))},{path:`/security`,element:GX((0,R.jsx)(zX,{}))},{path:`/secrets`,element:GX((0,R.jsx)(BX,{}))},{path:`/language`,element:(0,R.jsx)(Nq,{})},{path:`/settings`,element:(0,R.jsx)(EX,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:GX((0,R.jsx)(HX,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function qX(e){return`redirectTo`in e?(0,R.jsx)(ae,{path:e.path,element:(0,R.jsx)(x,{to:e.redirectTo,replace:!0})},e.path):(0,R.jsx)(ae,{path:e.path,element:e.element},e.path)}function JX(){return(0,R.jsx)(_,{children:KX.map(qX)})}function YX(){return AX(je),pe(),(0,L.useEffect)(()=>(Ct.start(),()=>{Ct.stop()}),[]),(0,R.jsxs)(oY,{children:[(0,R.jsx)(TX,{children:(0,R.jsx)(JX,{})}),(0,R.jsx)(Ka,{}),(0,R.jsx)($z,{})]})}function XX(){let e=Qe(),t=e.isError&&et(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,R.jsx)(YX,{}):e.data?.enabled&&!e.data.authenticated?(0,R.jsx)(qa,{username:e.data.username}):(0,R.jsx)(YX,{})}function ZX(){return(0,L.useEffect)(()=>{yK()},[]),(0,R.jsxs)(xe,{client:je,children:[(0,R.jsx)(XX,{}),(0,R.jsx)(gK,{}),(0,R.jsx)(_e,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var QX=window.nextclawDesktop?.platform===`win32`?re:T;(0,xa.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(L.StrictMode,{children:(0,R.jsx)(CK,{children:(0,R.jsx)(gr,{children:(0,R.jsx)(QX,{children:(0,R.jsx)(ZX,{})})})})}));export{Pa as $,Wc as A,zo as B,zz as C,Jl as D,Yl as E,gc as F,Va as G,Ho as H,uc as I,Fa as J,Ba as K,lc as L,Hc as M,Uc as N,Kl as O,kc as P,Ma as Q,as as R,Vz as S,ql as T,Bo as U,Vo as V,Lo as W,Aa as X,Da as Y,ja as Z,TU as _,Qr as _t,SJ as a,sa as at,xU as b,bq as c,Qi as ct,HG as d,Fi as dt,Ea as et,eW as f,Ni as ft,OU as g,pi as gt,SU as h,_i as ht,IJ as i,fa as it,Vc as j,yl as k,yq as l,Wi as lt,AU as m,Ai as mt,sY as n,Ca as nt,gJ as o,aa as ot,_U as p,Mi as pt,Ia as q,RJ as r,ha as rt,eJ as s,$i as st,hX as t,wa as tt,hK as u,Vi as ut,wU as v,Xr as vt,Bz as w,Rz as x,CU as y,os as z};