@openspecui/web 9.0.0 → 9.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/App-CKmWaGbS.css +1 -0
  2. package/dist/assets/{App-pfObbe6n.js → App-Cm5Z3aXu.js} +6 -6
  3. package/dist/assets/{main-Bc_Hy41u.js → main-DbOTQVqN.js} +2 -2
  4. package/dist/assets/{trpc--JMUaLps.js → trpc-DriEPW9x.js} +1 -1
  5. package/dist/index.html +1 -1
  6. package/dist-ssg/client/.vite/ssr-manifest.json +29 -29
  7. package/dist-ssg/client/assets/CanvasRenderer-BhcfZraw.js +1 -0
  8. package/dist-ssg/client/assets/WebGLRenderer-BMU-g2CE.js +1 -0
  9. package/dist-ssg/client/assets/WebGPURenderer-BAsbFOnm.js +1 -0
  10. package/dist-ssg/client/assets/browserAll-DzAH94Dz.js +1 -0
  11. package/dist-ssg/client/assets/{config-guide-presentation-BOR0ydhm.js → config-guide-presentation-Cn3kSpXZ.js} +1 -1
  12. package/dist-ssg/client/assets/{dist-0yxWvQWL.js → dist-BM1aVB3p.js} +1 -1
  13. package/dist-ssg/client/assets/{dist-CcTAgsaD.js → dist-BVC-3Mz_.js} +1 -1
  14. package/dist-ssg/client/assets/dist-CdxtXLZp.js +1 -0
  15. package/dist-ssg/client/assets/{dist-DFrBPW6S.js → dist-CfapX6Lr.js} +1 -1
  16. package/dist-ssg/client/assets/{dist-BXnglWxe.js → dist-DSbjfgtE.js} +1 -1
  17. package/dist-ssg/client/assets/{dist-Cqsy4GXU.js → dist-DTfE1AGY.js} +1 -1
  18. package/dist-ssg/client/assets/{dist-DclbMTMt.js → dist-D_8785UD.js} +1 -1
  19. package/dist-ssg/client/assets/{dist-biv4iN0V.js → dist-Dq7tP1jy.js} +1 -1
  20. package/dist-ssg/client/assets/dist-Dw6bnxbK.js +1 -0
  21. package/dist-ssg/client/assets/{dist-DR4ycVu1.js → dist-URgAfvaG.js} +1 -1
  22. package/dist-ssg/client/assets/{dist-CqBkec9X.js → dist-bIKkmeGM.js} +1 -1
  23. package/dist-ssg/client/assets/dist-nRw76b0P.js +1 -0
  24. package/dist-ssg/client/assets/{ghostty-web-D2QuMH_Q.js → ghostty-web-CepiWfia.js} +1 -1
  25. package/dist-ssg/client/assets/index-CltZALZD.css +1 -0
  26. package/dist-ssg/client/assets/{index.ssg-JS2ceq7d.js → index.ssg-DAtF3E31.js} +22 -22
  27. package/dist-ssg/client/assets/{init-CHYK3_IX.js → init-BOhrbGmd.js} +1 -1
  28. package/dist-ssg/client/assets/{trpc-B-w8tA8C.js → trpc-CfpujRJ8.js} +1 -1
  29. package/dist-ssg/client/assets/webworkerAll-BPYJdLSv.js +1 -0
  30. package/dist-ssg/client/index.ssg.html +2 -2
  31. package/dist-ssg/server/assets/CanvasRenderer-k_tFIFoA.js +3 -0
  32. package/dist-ssg/server/assets/WebGLRenderer-cfN96M_D.js +3 -0
  33. package/dist-ssg/server/assets/WebGPURenderer-moX8CQUm.js +3 -0
  34. package/dist-ssg/server/assets/{browserAll-BNHXRTWn.js → browserAll-BJZwRDaI.js} +2 -2
  35. package/dist-ssg/server/assets/{config-guide-presentation-CmUNOJoP.js → config-guide-presentation-CcpWbzbF.js} +1 -1
  36. package/dist-ssg/server/assets/{dist-CzfcaAEs.js → dist-BZbvCEXY.js} +1 -1
  37. package/dist-ssg/server/assets/{dist-tvIcsOn0.js → dist-BbKu_y6W.js} +1 -1
  38. package/dist-ssg/server/assets/dist-Bosp3yvI.js +3 -0
  39. package/dist-ssg/server/assets/{dist-CkE7XypO.js → dist-C0TNMvo3.js} +1 -1
  40. package/dist-ssg/server/assets/{dist-BZwNiEjE.js → dist-C7cu-Ohs.js} +1 -1
  41. package/dist-ssg/server/assets/{dist-CD_P89TI.js → dist-CTDTyhyq.js} +1 -1
  42. package/dist-ssg/server/assets/dist-CgFGYGuV.js +3 -0
  43. package/dist-ssg/server/assets/{dist-CSnQ9MUZ.js → dist-CmkO24b2.js} +1 -1
  44. package/dist-ssg/server/assets/{dist-Bg6kJ4lE.js → dist-Cxmy4PRF.js} +1 -1
  45. package/dist-ssg/server/assets/dist-DaxZJMDX.js +3 -0
  46. package/dist-ssg/server/assets/{dist-TFBLKdTC.js → dist-FpVzh8vE.js} +1 -1
  47. package/dist-ssg/server/assets/{dist-BTzm9CCH.js → dist-glvfDQXi.js} +1 -1
  48. package/dist-ssg/server/assets/{entry-server-C_EGBt5m.js → entry-server-D-Z6rVrS.js} +86 -89
  49. package/dist-ssg/server/assets/{init-Ds70MQGb.js → init-CCY3tsKc.js} +1 -1
  50. package/dist-ssg/server/assets/trpc-4dLqTVBm.js +3 -0
  51. package/dist-ssg/server/assets/webworkerAll-DVUDp5xO.js +4 -0
  52. package/dist-ssg/server/ssr-entry-manifest.json +24 -24
  53. package/package.json +3 -3
  54. package/dist/assets/App-BvtmL_DV.css +0 -1
  55. package/dist-ssg/client/assets/CanvasRenderer-BFbMT1Ul.js +0 -1
  56. package/dist-ssg/client/assets/WebGLRenderer-C7eR_UnH.js +0 -1
  57. package/dist-ssg/client/assets/WebGPURenderer-BTQYx5S7.js +0 -1
  58. package/dist-ssg/client/assets/browserAll-C88S5YfV.js +0 -1
  59. package/dist-ssg/client/assets/dist-4fNILwqh.js +0 -1
  60. package/dist-ssg/client/assets/dist-Cd3-dF0O.js +0 -1
  61. package/dist-ssg/client/assets/dist-DxTZTTY6.js +0 -1
  62. package/dist-ssg/client/assets/index-CrVhSCmS.css +0 -1
  63. package/dist-ssg/client/assets/webworkerAll-DFRsQGYS.js +0 -1
  64. package/dist-ssg/server/assets/CanvasRenderer-Cud3mH2M.js +0 -3
  65. package/dist-ssg/server/assets/WebGLRenderer-BG7MkvqA.js +0 -3
  66. package/dist-ssg/server/assets/WebGPURenderer--JR4o1Id.js +0 -3
  67. package/dist-ssg/server/assets/dist-CpgxMd46.js +0 -3
  68. package/dist-ssg/server/assets/dist-gfV2B0G7.js +0 -3
  69. package/dist-ssg/server/assets/dist-vPFtDCqy.js +0 -3
  70. package/dist-ssg/server/assets/trpc-DMtttD_4.js +0 -3
  71. package/dist-ssg/server/assets/webworkerAll-6pG_bTSk.js +0 -4
@@ -1,10 +1,10 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/trpc--JMUaLps.js","assets/chunk-VBW0iQ51.js","assets/jsx-runtime-B5X0rzej.js","assets/react-w0ynVMNy.js","assets/main-Bc_Hy41u.js","assets/modulepreload-polyfill-CXK8biUa.js","assets/preload-helper-qlgyTAkD.js","assets/client-pO1cwWkl.js","assets/react-dom-DGmpTSTt.js","assets/browserAll-DpnGZcZ6.js","assets/Geometry-DnX4RiLB.js","assets/FederatedEventTarget-DH40GasF.js","assets/FilterSystem-DGEzd4r7.js","assets/ImageSource-D9b88hVS.js","assets/init-C9T4bNS4.js","assets/webworkerAll-DVvhywpc.js","assets/WebGPURenderer-PzUtbZe0.js","assets/WebGPURenderer-rPgcvLqV.js","assets/RenderTargetSystem-DNBcF83q.js","assets/getTextureBatchBindGroup-BBz5dgEf.js","assets/BufferResource-TFXpqlS4.js","assets/WebGLRenderer-DujEkC4U.js","assets/WebGLRenderer-C7NKu4lr.js","assets/CanvasRenderer-Cquv08SX.js","assets/CanvasRenderer-frZG-e8U.js","assets/ghostty-web-BSS9uGcc.js","assets/config-guide-presentation-DBIlA5BR.js","assets/ToolbarRootContext-DJ7ICfbj.js","assets/dist-DBANUHCV.js","assets/dist-BM1p13VL.js","assets/dist-BjgzTMjG.js","assets/dist-ut4rUQ9T.js","assets/dist-DOslja1j.js","assets/dist-BqFNCcID.js","assets/dist-BElax2Cc.js","assets/dist-B_gB7iV-.js","assets/dist-ChBF8Kxw.js","assets/dist-CdyeiNbL.js","assets/dist-BTEspn1S.js","assets/dist-BTDPzESP.js","assets/dist-DiDQaVUl.js","assets/dist-BPqKJ2jd.js","assets/dist-Cds2ol7_.js","assets/dist-DcxAxgyr.js","assets/dist-DKJ1Q90V.js","assets/dist-H4lUSqHM.js","assets/dist-CUBTZf4H.js","assets/dist-CcJiXGmU.js","assets/dist-B_cOSPGy.js","assets/dockerfile-h2epc4Vl.js","assets/simple-mode-Bhi1lZLR.js","assets/factor-CeOkG9eA.js","assets/nsis-CquHxL-A.js","assets/pug-HlPEUn3L.js","assets/javascript-WdgH9bdJ.js","assets/dist-BfbneuyF.js","assets/dist-CuICAqXS.js","assets/angular-html-EaGg67w-.js","assets/html-B_1hK_C6.js","assets/css-Dc1gxuHE.js","assets/javascript-42uzW-9k.js","assets/angular-ts-Ch5ujYDJ.js","assets/scss-DErQ-q9n.js","assets/apl-BsTI1MgL.js","assets/json-Df6kz_tW.js","assets/xml-CsmvQp5K.js","assets/java-BamxhkWV.js","assets/astro-CW4aHsV1.js","assets/postcss-DFeAuPDm.js","assets/tsx-_a4URhNn.js","assets/typescript-CTlxejIu.js","assets/blade-BMTVXNVa.js","assets/html-derivative-C3wRn33_.js","assets/sql-D3nyyGFw.js","assets/bsl-CT0at82N.js","assets/sdbl-CDtsReAe.js","assets/c-CvFp8_vh.js","assets/cairo-BQK3vvkd.js","assets/python-Bd-SyRCh.js","assets/cobol-DDP5O6At.js","assets/coffee-w-vvbmfR.js","assets/cpp-maXEOUbR.js","assets/glsl-BQ7oP25Y.js","assets/regexp-C_mdE5qh.js","assets/crystal-Daje1etl.js","assets/shellscript-BhoDNWc8.js","assets/edge-Cmw3ms6c.js","assets/elixir-DLLfdAdU.js","assets/elm-qbm_nDoA.js","assets/erb-CXyBVBSU.js","assets/ruby-BwDRzt3-.js","assets/graphql-Cuz3FvD1.js","assets/jsx-DJfNmqFM.js","assets/haml-BYAqN9e2.js","assets/lua-BytP-pXa.js","assets/yaml-CwNn_bUe.js","assets/erlang-C3LeQBYv.js","assets/markdown-C2NdQa1s.js","assets/fortran-fixed-form-CBbbILOk.js","assets/fortran-free-form-CfPabVBP.js","assets/fsharp-D7bpsmxw.js","assets/gdresource-CU-bVyXe.js","assets/gdscript-DlddF44s.js","assets/gdshader-C4SuMVnW.js","assets/git-commit-DDMCszZL.js","assets/diff-Dn6kkMQ8.js","assets/git-rebase-DnBV-Jdd.js","assets/glimmer-js-DZZIz70U.js","assets/glimmer-ts-zjTMyvYA.js","assets/hack-5xlu6a1S.js","assets/handlebars-cvC52nlX.js","assets/http-DEQkV8Xu.js","assets/hurl-C5zNmiJJ.js","assets/csv-DQDSHfxj.js","assets/hxml-k61G-s6T.js","assets/haxe-BX7dHJPc.js","assets/jinja-D77dsJfB.js","assets/jison-frIvnqi7.js","assets/julia-DCwaLw0v.js","assets/r-MgF_uWk3.js","assets/latex-CeNSbJ93.js","assets/tex-B2f-6bPZ.js","assets/liquid-Ds7VUwoG.js","assets/marko-CDjsybka.js","assets/less-B6Q5XzxU.js","assets/mdc-Cp-0xBuf.js","assets/nginx-Zcb-2rM7.js","assets/nim-DX42fVnZ.js","assets/perl-CHTUiVBF.js","assets/php-B4nCmnla.js","assets/pug-Cylx6tZj.js","assets/qml-CyU3AYb_.js","assets/razor-BdKyDmxf.js","assets/csharp-v1IT52Cm.js","assets/rst-B_SeciJo.js","assets/cmake-D9cyu7xI.js","assets/sas-cAgjjTQx.js","assets/shaderlab-Eg2Qf8Qn.js","assets/hlsl-CKs72768.js","assets/shellsession-C6PDany4.js","assets/soy-CnhkrzGt.js","assets/sparql-dvHNG6KX.js","assets/turtle-fIOA9o79.js","assets/stata-BHafLeHQ.js","assets/svelte-Cp1Qqeow.js","assets/templ-DeTZ2yGp.js","assets/go-Dur0j3Bv.js","assets/ts-tags-CiUE0AfB.js","assets/twig-D-r6oRPN.js","assets/vue-BEXq_rm2.js","assets/vue-html-C6ZnjGeH.js","assets/vue-vine-BOrA9MgZ.js","assets/stylus-BPUlgj0k.js","assets/xsl-CpppY2rp.js"])))=>i.map(i=>d[i]);
2
- import{a as e,i as t,n,r,t as i}from"./chunk-VBW0iQ51.js";import{t as a}from"./react-w0ynVMNy.js";import{t as o}from"./react-dom-DGmpTSTt.js";import{t as s}from"./jsx-runtime-B5X0rzej.js";import{t as c}from"./preload-helper-qlgyTAkD.js";import{A as l,B as u,C as d,D as f,E as p,F as m,H as h,I as g,L as _,M as v,N as y,O as b,P as x,R as S,S as C,T as w,V as T,_ as E,b as D,c as O,f as k,g as A,h as j,i as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,r as B,s as V,t as ee,v as te,w as ne,x as re,y as ie,z as ae}from"./main-Bc_Hy41u.js";import{$ as oe,A as se,B as ce,Ct as le,Dt as ue,E as de,Et as fe,F as pe,G as me,H as he,K as ge,M as _e,O as ve,Ot as ye,P as be,Q as xe,R as H,S as Se,St as Ce,T as we,Tt as Te,U as Ee,V as De,W as Oe,X as ke,Y as Ae,Z as je,a as Me,at as Ne,b as Pe,bt as Fe,ct as Ie,dt as Le,et as Re,f as ze,ft as Be,g as Ve,gt as He,it as Ue,jt as We,k as Ge,kt as Ke,l as U,lt as qe,mt as Je,nt as Ye,o as Xe,p as Ze,pt as Qe,q as $e,rt as et,st as tt,u as nt,ut as rt,vt as it,wt as at,xt as ot,z as st}from"./dist-BjgzTMjG.js";import"./dist-BElax2Cc.js";import"./dist-DOslja1j.js";import{n as ct}from"./dist-B_gB7iV-.js";import{i as lt,n as ut,o as dt,r as ft}from"./dist-BM1p13VL.js";import{n as pt}from"./dist-BTEspn1S.js";import{n as mt,r as ht}from"./dist-BPqKJ2jd.js";import{n as gt}from"./dist-B_cOSPGy.js";import{$ as _t,A as vt,H as yt,J as bt,M as xt,Q as St,S as Ct,T as wt,V as Tt,Y as Et,Z as Dt,_ as Ot,b as kt,it as At,nt as jt,q as Mt,rt as Nt,tt as Pt,v as Ft,w as It,x as Lt,y as Rt}from"./Geometry-DnX4RiLB.js";import"./FilterSystem-DGEzd4r7.js";import{a as zt,i as Bt,n as Vt,o as Ht,r as Ut,s as Wt}from"./CanvasRenderer-frZG-e8U.js";import{a as Gt,i as Kt,k as qt,u as Jt}from"./RenderTargetSystem-DNBcF83q.js";import{n as Yt}from"./WebGPURenderer-rPgcvLqV.js";import{$ as Xt,$t as Zt,A as Qt,An as $t,At as en,B as tn,Bt as nn,C as rn,Cn as an,Ct as on,D as sn,Dn as cn,Dt as ln,E as un,En as dn,Et as fn,F as eee,Fn as pn,Ft as tee,G as W,Gt as nee,H as ree,Ht as mn,I as iee,In as G,It as hn,J as gn,Jt as _n,K as aee,Kt as oee,L as vn,Ln as see,Lt as yn,M as cee,Mn as lee,Mt as bn,N as uee,Nn as dee,Nt as fee,O as pee,On as mee,Ot as xn,P as hee,Pn as Sn,Pt as Cn,Q as gee,Qt as wn,R as _ee,Rt as Tn,S as En,Sn as vee,St as yee,T as Dn,Tn as On,Tt as bee,U as kn,Ut as xee,V as An,Vt as See,W as K,Wt as jn,Xt as Cee,Yt as Mn,Zt as Nn,_ as Pn,_n as wee,_t as Tee,a as Fn,an as Eee,b as In,bn as Dee,bt as Oee,c as Ln,cn as Rn,ct as zn,d as kee,dn as Aee,dt as Bn,en as jee,et as Vn,f as Hn,fn as Un,ft as Wn,g as Gn,gn as Kn,gt as qn,h as Jn,hn as Yn,ht as Xn,i as Zn,in as Qn,it as $n,j as Mee,jn as er,jt as tr,k as Nee,kn as nr,l as rr,ln as ir,lt as ar,m as Pee,mn as Fee,mt as or,n as sr,nn as Iee,nt as cr,o as lr,on as ur,ot as dr,p as fr,pn as Lee,pt as pr,q as mr,qt as Ree,r as hr,rn as zee,rt as gr,s as _r,sn as vr,st as Bee,t as Vee,tn as yr,tt as Hee,u as Uee,un as br,ut as xr,v as Wee,vn as Gee,vt as Kee,w as Sr,wn as Cr,wt as wr,x as qee,xn as Jee,xt as Yee,y as Tr,yn as Er,yt as Xee,z as Dr,zt as Or}from"./ToolbarRootContext-DJ7ICfbj.js";import{WS_RETRY_DELAY_MS as kr,_ as Ar,a as Zee,b as jr,c as Qee,d as Mr,f as Nr,g as Pr,getOrCreateWsClientInstance as $ee,h as Fr,i as Ir,l as Lr,m as ete,n as tte,o as Rr,p as zr,queryClient as Br,r as nte,s as Vr,t as rte,trpc as Hr,trpcClient as q,u as Ur,v as Wr,x as Gr,y as ite}from"./trpc--JMUaLps.js";var J=s(),Kr=e(o(),1),Y=e(a(),1),ate=class{constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){let t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=[r,this.get(r)]}return t}evict(e=!1){if(e||this.size>0){let e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){let e=Array(this.size),t=this.first,n=0;for(;t!==null;)e[n++]=t.key,t=t.next;return e}setWithEvicted(e,t,n=this.resetTtl){let r=null;if(this.has(e))this.set(e,t,!0,n);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(e,t,n=!1,r=this.resetTtl){let i=this.items[e];return n||i!==void 0?(i.value=t,n===!1&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(i)):(this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=i:this.last.next=i,this.last=i),this}values(e=this.keys()){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=this.get(e[n]);return t}};function ote(e=1e3,t=0,n=!1){if(isNaN(e)||e<0)throw TypeError(`Invalid max value`);if(isNaN(t)||t<0)throw TypeError(`Invalid ttl value`);if(typeof n!=`boolean`)throw TypeError(`Invalid resetTtl value`);return new ate(e,t,n)}function qr(e){return!!e.tagStyles&&Object.keys(e.tagStyles).length>0}function Jr(e){return e.includes(`<`)}function ste(e,t){return e.clone().assign(t)}function cte(e,t){let n=[],r=t.tagStyles;if(!qr(t)||!Jr(e))return n.push({text:e,style:t}),n;let i=[t],a=[],o=``,s=0;for(;s<e.length;){let t=e[s];if(t===`<`){let c=e.indexOf(`>`,s);if(c===-1){o+=t,s++;continue}let l=e.slice(s+1,c);if(l.startsWith(`/`)){let t=l.slice(1).trim();if(a.length>0&&a[a.length-1]===t){o.length>0&&(n.push({text:o,style:i[i.length-1]}),o=``),i.pop(),a.pop(),s=c+1;continue}else{o+=e.slice(s,c+1),s=c+1;continue}}else{let t=l.trim();if(r[t]){o.length>0&&(n.push({text:o,style:i[i.length-1]}),o=``);let e=i[i.length-1],l=ste(e,r[t]);i.push(l),a.push(t),s=c+1;continue}else{o+=e.slice(s,c+1),s=c+1;continue}}}else o+=t,s++}return o.length>0&&n.push({text:o,style:i[i.length-1]}),n}var lte=new Set([10,13]),ute=new Set([9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]),dte=/(\r\n|\r|\n)/,fte=/(?:\r\n|\r|\n)/;function Yr(e){return typeof e==`string`?lte.has(e.charCodeAt(0)):!1}function Xr(e,t){return typeof e==`string`?ute.has(e.charCodeAt(0)):!1}function Zr(e){return e===`normal`||e===`pre-line`}function Qr(e){return e===`normal`}function $r(e){if(typeof e!=`string`)return``;let t=e.length-1;for(;t>=0&&Xr(e[t]);)t--;return t<e.length-1?e.slice(0,t+1):e}function ei(e){let t=[],n=[];if(typeof e!=`string`)return t;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(Xr(i,a)||Yr(i)){n.length>0&&(t.push(n.join(``)),n.length=0),i===`\r`&&a===`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/trpc-DriEPW9x.js","assets/chunk-VBW0iQ51.js","assets/jsx-runtime-B5X0rzej.js","assets/react-w0ynVMNy.js","assets/main-DbOTQVqN.js","assets/modulepreload-polyfill-CXK8biUa.js","assets/preload-helper-qlgyTAkD.js","assets/client-pO1cwWkl.js","assets/react-dom-DGmpTSTt.js","assets/browserAll-DpnGZcZ6.js","assets/Geometry-DnX4RiLB.js","assets/FederatedEventTarget-DH40GasF.js","assets/FilterSystem-DGEzd4r7.js","assets/ImageSource-D9b88hVS.js","assets/init-C9T4bNS4.js","assets/webworkerAll-DVvhywpc.js","assets/WebGPURenderer-PzUtbZe0.js","assets/WebGPURenderer-rPgcvLqV.js","assets/RenderTargetSystem-DNBcF83q.js","assets/getTextureBatchBindGroup-BBz5dgEf.js","assets/BufferResource-TFXpqlS4.js","assets/WebGLRenderer-DujEkC4U.js","assets/WebGLRenderer-C7NKu4lr.js","assets/CanvasRenderer-Cquv08SX.js","assets/CanvasRenderer-frZG-e8U.js","assets/ghostty-web-BSS9uGcc.js","assets/config-guide-presentation-DBIlA5BR.js","assets/ToolbarRootContext-DJ7ICfbj.js","assets/dist-DBANUHCV.js","assets/dist-BM1p13VL.js","assets/dist-BjgzTMjG.js","assets/dist-ut4rUQ9T.js","assets/dist-DOslja1j.js","assets/dist-BqFNCcID.js","assets/dist-BElax2Cc.js","assets/dist-B_gB7iV-.js","assets/dist-ChBF8Kxw.js","assets/dist-CdyeiNbL.js","assets/dist-BTEspn1S.js","assets/dist-BTDPzESP.js","assets/dist-DiDQaVUl.js","assets/dist-BPqKJ2jd.js","assets/dist-Cds2ol7_.js","assets/dist-DcxAxgyr.js","assets/dist-DKJ1Q90V.js","assets/dist-H4lUSqHM.js","assets/dist-CUBTZf4H.js","assets/dist-CcJiXGmU.js","assets/dist-B_cOSPGy.js","assets/dockerfile-h2epc4Vl.js","assets/simple-mode-Bhi1lZLR.js","assets/factor-CeOkG9eA.js","assets/nsis-CquHxL-A.js","assets/pug-HlPEUn3L.js","assets/javascript-WdgH9bdJ.js","assets/dist-BfbneuyF.js","assets/dist-CuICAqXS.js","assets/angular-html-EaGg67w-.js","assets/html-B_1hK_C6.js","assets/css-Dc1gxuHE.js","assets/javascript-42uzW-9k.js","assets/angular-ts-Ch5ujYDJ.js","assets/scss-DErQ-q9n.js","assets/apl-BsTI1MgL.js","assets/json-Df6kz_tW.js","assets/xml-CsmvQp5K.js","assets/java-BamxhkWV.js","assets/astro-CW4aHsV1.js","assets/postcss-DFeAuPDm.js","assets/tsx-_a4URhNn.js","assets/typescript-CTlxejIu.js","assets/blade-BMTVXNVa.js","assets/html-derivative-C3wRn33_.js","assets/sql-D3nyyGFw.js","assets/bsl-CT0at82N.js","assets/sdbl-CDtsReAe.js","assets/c-CvFp8_vh.js","assets/cairo-BQK3vvkd.js","assets/python-Bd-SyRCh.js","assets/cobol-DDP5O6At.js","assets/coffee-w-vvbmfR.js","assets/cpp-maXEOUbR.js","assets/glsl-BQ7oP25Y.js","assets/regexp-C_mdE5qh.js","assets/crystal-Daje1etl.js","assets/shellscript-BhoDNWc8.js","assets/edge-Cmw3ms6c.js","assets/elixir-DLLfdAdU.js","assets/elm-qbm_nDoA.js","assets/erb-CXyBVBSU.js","assets/ruby-BwDRzt3-.js","assets/graphql-Cuz3FvD1.js","assets/jsx-DJfNmqFM.js","assets/haml-BYAqN9e2.js","assets/lua-BytP-pXa.js","assets/yaml-CwNn_bUe.js","assets/erlang-C3LeQBYv.js","assets/markdown-C2NdQa1s.js","assets/fortran-fixed-form-CBbbILOk.js","assets/fortran-free-form-CfPabVBP.js","assets/fsharp-D7bpsmxw.js","assets/gdresource-CU-bVyXe.js","assets/gdscript-DlddF44s.js","assets/gdshader-C4SuMVnW.js","assets/git-commit-DDMCszZL.js","assets/diff-Dn6kkMQ8.js","assets/git-rebase-DnBV-Jdd.js","assets/glimmer-js-DZZIz70U.js","assets/glimmer-ts-zjTMyvYA.js","assets/hack-5xlu6a1S.js","assets/handlebars-cvC52nlX.js","assets/http-DEQkV8Xu.js","assets/hurl-C5zNmiJJ.js","assets/csv-DQDSHfxj.js","assets/hxml-k61G-s6T.js","assets/haxe-BX7dHJPc.js","assets/jinja-D77dsJfB.js","assets/jison-frIvnqi7.js","assets/julia-DCwaLw0v.js","assets/r-MgF_uWk3.js","assets/latex-CeNSbJ93.js","assets/tex-B2f-6bPZ.js","assets/liquid-Ds7VUwoG.js","assets/marko-CDjsybka.js","assets/less-B6Q5XzxU.js","assets/mdc-Cp-0xBuf.js","assets/nginx-Zcb-2rM7.js","assets/nim-DX42fVnZ.js","assets/perl-CHTUiVBF.js","assets/php-B4nCmnla.js","assets/pug-Cylx6tZj.js","assets/qml-CyU3AYb_.js","assets/razor-BdKyDmxf.js","assets/csharp-v1IT52Cm.js","assets/rst-B_SeciJo.js","assets/cmake-D9cyu7xI.js","assets/sas-cAgjjTQx.js","assets/shaderlab-Eg2Qf8Qn.js","assets/hlsl-CKs72768.js","assets/shellsession-C6PDany4.js","assets/soy-CnhkrzGt.js","assets/sparql-dvHNG6KX.js","assets/turtle-fIOA9o79.js","assets/stata-BHafLeHQ.js","assets/svelte-Cp1Qqeow.js","assets/templ-DeTZ2yGp.js","assets/go-Dur0j3Bv.js","assets/ts-tags-CiUE0AfB.js","assets/twig-D-r6oRPN.js","assets/vue-BEXq_rm2.js","assets/vue-html-C6ZnjGeH.js","assets/vue-vine-BOrA9MgZ.js","assets/stylus-BPUlgj0k.js","assets/xsl-CpppY2rp.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,i as t,n,r,t as i}from"./chunk-VBW0iQ51.js";import{t as a}from"./react-w0ynVMNy.js";import{t as o}from"./react-dom-DGmpTSTt.js";import{t as s}from"./jsx-runtime-B5X0rzej.js";import{t as c}from"./preload-helper-qlgyTAkD.js";import{A as l,B as u,C as d,D as f,E as p,F as m,H as h,I as g,L as _,M as v,N as y,O as b,P as x,R as S,S as C,T as w,V as T,_ as E,b as D,c as O,f as k,g as A,h as j,i as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,r as B,s as V,t as ee,v as te,w as ne,x as re,y as ie,z as ae}from"./main-DbOTQVqN.js";import{$ as oe,A as se,B as ce,Ct as le,Dt as ue,E as de,Et as fe,F as pe,G as me,H as he,K as ge,M as _e,O as ve,Ot as ye,P as be,Q as xe,R as H,S as Se,St as Ce,T as we,Tt as Te,U as Ee,V as De,W as Oe,X as ke,Y as Ae,Z as je,a as Me,at as Ne,b as Pe,bt as Fe,ct as Ie,dt as Le,et as Re,f as ze,ft as Be,g as Ve,gt as He,it as Ue,jt as We,k as Ge,kt as Ke,l as U,lt as qe,mt as Je,nt as Ye,o as Xe,p as Ze,pt as Qe,q as $e,rt as et,st as tt,u as nt,ut as rt,vt as it,wt as at,xt as ot,z as st}from"./dist-BjgzTMjG.js";import"./dist-BElax2Cc.js";import"./dist-DOslja1j.js";import{n as ct}from"./dist-B_gB7iV-.js";import{i as lt,n as ut,o as dt,r as ft}from"./dist-BM1p13VL.js";import{n as pt}from"./dist-BTEspn1S.js";import{n as mt,r as ht}from"./dist-BPqKJ2jd.js";import{n as gt}from"./dist-B_cOSPGy.js";import{$ as _t,A as vt,H as yt,J as bt,M as xt,Q as St,S as Ct,T as wt,V as Tt,Y as Et,Z as Dt,_ as Ot,b as kt,it as At,nt as jt,q as Mt,rt as Nt,tt as Pt,v as Ft,w as It,x as Lt,y as Rt}from"./Geometry-DnX4RiLB.js";import"./FilterSystem-DGEzd4r7.js";import{a as zt,i as Bt,n as Vt,o as Ht,r as Ut,s as Wt}from"./CanvasRenderer-frZG-e8U.js";import{a as Gt,i as Kt,k as qt,u as Jt}from"./RenderTargetSystem-DNBcF83q.js";import{n as Yt}from"./WebGPURenderer-rPgcvLqV.js";import{$ as Xt,$t as Zt,A as Qt,An as $t,At as en,B as tn,Bt as nn,C as rn,Cn as an,Ct as on,D as sn,Dn as cn,Dt as ln,E as un,En as dn,Et as fn,F as eee,Fn as pn,Ft as tee,G as W,Gt as nee,H as ree,Ht as mn,I as iee,In as G,It as hn,J as gn,Jt as _n,K as aee,Kt as oee,L as vn,Ln as see,Lt as yn,M as cee,Mn as lee,Mt as bn,N as uee,Nn as dee,Nt as fee,O as pee,On as mee,Ot as xn,P as hee,Pn as Sn,Pt as Cn,Q as gee,Qt as wn,R as _ee,Rt as Tn,S as En,Sn as vee,St as yee,T as Dn,Tn as On,Tt as bee,U as kn,Ut as xee,V as An,Vt as See,W as K,Wt as jn,Xt as Cee,Yt as Mn,Zt as Nn,_ as Pn,_n as wee,_t as Tee,a as Fn,an as Eee,b as In,bn as Dee,bt as Oee,c as Ln,cn as Rn,ct as zn,d as kee,dn as Aee,dt as Bn,en as jee,et as Vn,f as Hn,fn as Un,ft as Wn,g as Gn,gn as Kn,gt as qn,h as Jn,hn as Yn,ht as Xn,i as Zn,in as Qn,it as $n,j as Mee,jn as er,jt as tr,k as Nee,kn as nr,l as rr,ln as ir,lt as ar,m as Pee,mn as Fee,mt as or,n as sr,nn as Iee,nt as cr,o as lr,on as ur,ot as dr,p as fr,pn as Lee,pt as pr,q as mr,qt as Ree,r as hr,rn as zee,rt as gr,s as _r,sn as vr,st as Bee,t as Vee,tn as yr,tt as Hee,u as Uee,un as br,ut as xr,v as Wee,vn as Gee,vt as Kee,w as Sr,wn as Cr,wt as wr,x as qee,xn as Jee,xt as Yee,y as Tr,yn as Er,yt as Xee,z as Dr,zt as Or}from"./ToolbarRootContext-DJ7ICfbj.js";import{WS_RETRY_DELAY_MS as kr,_ as Ar,a as Zee,b as jr,c as Qee,d as Mr,f as Nr,g as Pr,getOrCreateWsClientInstance as $ee,h as Fr,i as Ir,l as Lr,m as ete,n as tte,o as Rr,p as zr,queryClient as Br,r as nte,s as Vr,t as rte,trpc as Hr,trpcClient as q,u as Ur,v as Wr,x as Gr,y as ite}from"./trpc-DriEPW9x.js";var J=s(),Kr=e(o(),1),Y=e(a(),1),ate=class{constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){let t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=[r,this.get(r)]}return t}evict(e=!1){if(e||this.size>0){let e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){let e=Array(this.size),t=this.first,n=0;for(;t!==null;)e[n++]=t.key,t=t.next;return e}setWithEvicted(e,t,n=this.resetTtl){let r=null;if(this.has(e))this.set(e,t,!0,n);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(e,t,n=!1,r=this.resetTtl){let i=this.items[e];return n||i!==void 0?(i.value=t,n===!1&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(i)):(this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=i:this.last.next=i,this.last=i),this}values(e=this.keys()){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=this.get(e[n]);return t}};function ote(e=1e3,t=0,n=!1){if(isNaN(e)||e<0)throw TypeError(`Invalid max value`);if(isNaN(t)||t<0)throw TypeError(`Invalid ttl value`);if(typeof n!=`boolean`)throw TypeError(`Invalid resetTtl value`);return new ate(e,t,n)}function qr(e){return!!e.tagStyles&&Object.keys(e.tagStyles).length>0}function Jr(e){return e.includes(`<`)}function ste(e,t){return e.clone().assign(t)}function cte(e,t){let n=[],r=t.tagStyles;if(!qr(t)||!Jr(e))return n.push({text:e,style:t}),n;let i=[t],a=[],o=``,s=0;for(;s<e.length;){let t=e[s];if(t===`<`){let c=e.indexOf(`>`,s);if(c===-1){o+=t,s++;continue}let l=e.slice(s+1,c);if(l.startsWith(`/`)){let t=l.slice(1).trim();if(a.length>0&&a[a.length-1]===t){o.length>0&&(n.push({text:o,style:i[i.length-1]}),o=``),i.pop(),a.pop(),s=c+1;continue}else{o+=e.slice(s,c+1),s=c+1;continue}}else{let t=l.trim();if(r[t]){o.length>0&&(n.push({text:o,style:i[i.length-1]}),o=``);let e=i[i.length-1],l=ste(e,r[t]);i.push(l),a.push(t),s=c+1;continue}else{o+=e.slice(s,c+1),s=c+1;continue}}}else o+=t,s++}return o.length>0&&n.push({text:o,style:i[i.length-1]}),n}var lte=new Set([10,13]),ute=new Set([9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]),dte=/(\r\n|\r|\n)/,fte=/(?:\r\n|\r|\n)/;function Yr(e){return typeof e==`string`?lte.has(e.charCodeAt(0)):!1}function Xr(e,t){return typeof e==`string`?ute.has(e.charCodeAt(0)):!1}function Zr(e){return e===`normal`||e===`pre-line`}function Qr(e){return e===`normal`}function $r(e){if(typeof e!=`string`)return``;let t=e.length-1;for(;t>=0&&Xr(e[t]);)t--;return t<e.length-1?e.slice(0,t+1):e}function ei(e){let t=[],n=[];if(typeof e!=`string`)return t;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(Xr(i,a)||Yr(i)){n.length>0&&(t.push(n.join(``)),n.length=0),i===`\r`&&a===`
3
3
  `?(t.push(`\r
4
4
  `),r++):t.push(i);continue}n.push(i)}return n.length>0&&t.push(n.join(``)),t}function ti(e,t,n,r){let i=n(e),a=[];for(let n=0;n<i.length;n++){let o=i[n],s=o,c=1;for(;i[n+c];){let a=i[n+c];if(!r(s,a,e,n,t))o+=a,s=a,c++;else break}n+=c-1,a.push(o)}return a}var pte=/\r\n|\r|\n/g;function mte(e,t,n,r,i,a,o,s){let c=cte(e,t);if(Qr(t.whiteSpace))for(let e=0;e<c.length;e++){let t=c[e];c[e]={text:t.text.replace(pte,` `),style:t.style}}let l=[],u=[];for(let e of c){let t=e.text.split(dte);for(let n=0;n<t.length;n++){let r=t[n];r===`\r
5
5
  `||r===`\r`||r===`
6
6
  `?(l.push(u),u=[]):r.length>0&&u.push({text:r,style:e.style})}}(u.length>0||l.length===0)&&l.push(u);let d=n?hte(l,t,r,i,o,s):l,f=[],p=[],m=[],h=[],g=[],_=0,v=t._fontString,y=a(v);y.fontSize===0&&(y.fontSize=t.fontSize,y.ascent=t.fontSize);let b=``,x=!!t.dropShadow;for(let e of d){let n=0,o=y.ascent,s=y.descent,c=``;for(let t of e){let e=t.style._fontString,l=a(e);e!==b&&(r.font=e,b=e);let u=i(t.text,t.style.letterSpacing,r);n+=u,o=Math.max(o,l.ascent),s=Math.max(s,l.descent),c+=t.text,!x&&t.style.dropShadow&&(x=!0)}e.length===0&&(o=y.ascent,s=y.descent),f.push(n),p.push(o),m.push(s),g.push(c);let l=t.lineHeight||o+s;h.push(l+t.leading),_=Math.max(_,n)}let S=t._stroke?.width||0,C=(n&&t.align!==`left`&&t.align!==`justify`?Math.max(_,t.wordWrapWidth):_)+S+(t.dropShadow?t.dropShadow.distance:0),w=0;for(let e=0;e<h.length;e++)w+=h[e];return w=Math.max(w,h[0]+S),{width:C,height:w+(t.dropShadow?t.dropShadow.distance:0),lines:g,lineWidths:f,lineHeight:(t.lineHeight||y.fontSize)+t.leading,maxLineWidth:_,fontProperties:y,runsByLine:d,lineAscents:p,lineDescents:m,lineHeights:h,hasDropShadow:x}}function hte(e,t,n,r,i,a){let{letterSpacing:o,whiteSpace:s,wordWrapWidth:c,breakWords:l}=t,u=Zr(s),d=c+o,f={},p=``,m=(e,t)=>{let i=`${e}|${t.styleKey}`,a=f[i];if(a===void 0){let o=t._fontString;o!==p&&(n.font=o,p=o),a=r(e,t.letterSpacing,n)+t.letterSpacing,f[i]=a}return a},h=[];for(let t of e){let e=gte(t),n=h.length,r=t=>{let n=0,r=t;do{let{token:t,style:i}=e[r];n+=m(t,i),r++}while(r<e.length&&e[r].continuesFromPrevious);return n},o=t=>{let n=[],r=t;do n.push({token:e[r].token,style:e[r].style}),r++;while(r<e.length&&e[r].continuesFromPrevious);return n},s=[],c=0,f=!u,p=null,g=()=>{p&&p.text.length>0&&s.push(p),p=null},_=()=>{if(g(),s.length>0){let e=s[s.length-1];e.text=$r(e.text),e.text.length===0&&s.pop()}h.push(s),s=[],c=0,f=!1};for(let t=0;t<e.length;t++){let{token:n,style:v,continuesFromPrevious:y}=e[t],b=m(n,v);if(u){let e=Xr(n),t=p?.text[p.text.length-1]??s[s.length-1]?.text.slice(-1)??``,r=t?Xr(t):!1;if(e&&r)continue}let x=!y,S=x?r(t):b;if(S>d&&x)if(c>0&&_(),l){let e=o(t);for(let t=0;t<e.length;t++){let n=e[t].token,r=e[t].style,o=ti(n,l,a,i);for(let e of o){let t=m(e,r);t+c>d&&_(),!p||p.style!==r?(g(),p={text:e,style:r}):p.text+=e,c+=t}}t+=e.length-1}else{let e=o(t);g(),h.push(e.map(e=>({text:e.token,style:e.style}))),f=!1,t+=e.length-1}else if(S+c>d&&x){if(Xr(n)){f=!1;continue}_(),p={text:n,style:v},c=b}else if(y&&!l)!p||p.style!==v?(g(),p={text:n,style:v}):p.text+=n,c+=b;else{let e=Xr(n);if(c===0&&e&&!f)continue;!p||p.style!==v?(g(),p={text:n,style:v}):p.text+=n,c+=b}}if(g(),s.length>0){let e=s[s.length-1];e.text=$r(e.text),e.text.length===0&&s.pop()}(s.length>0||h.length===n)&&h.push(s)}return h}function gte(e){let t=[],n=!1;for(let r of e){let e=ei(r.text),i=!0;for(let a of e){let e=Xr(a)||Yr(a),o=i&&n&&!e;t.push({token:a,style:r.style,continuesFromPrevious:o}),n=!e,i=!1}}return t}var _te={willReadFrequently:!0};function ni(e,t,n,r,i){let a=n[e];return typeof a!=`number`&&(a=i(e,t,r)+t,n[e]=a),a}function vte(e,t,n,r,i,a,o){let s=n.getContext(`2d`,_te);s.font=t._fontString;let c=0,l=``,u=[],d=Object.create(null),{letterSpacing:f,whiteSpace:p}=t,m=Zr(p),h=Qr(p),g=!m,_=t.wordWrapWidth+f,v=ei(e);for(let e=0;e<v.length;e++){let n=v[e];if(Yr(n)){if(!h){u.push($r(l)),g=!m,l=``,c=0;continue}n=` `}if(m){let e=Xr(n),t=Xr(l[l.length-1]);if(e&&t)continue}let p=ni(n,f,d,s,r);if(p>_)if(l!==``&&(u.push($r(l)),l=``,c=0),i(n,t.breakWords)){let e=ti(n,t.breakWords,o,a);for(let t of e){let e=ni(t,f,d,s,r);e+c>_&&(u.push($r(l)),g=!1,l=``,c=0),l+=t,c+=e}}else l.length>0&&(u.push($r(l)),l=``,c=0),u.push($r(n)),g=!1,l=``,c=0;else p+c>_&&(g=!1,u.push($r(l)),l=``,c=0),(l.length>0||!Xr(n)||g)&&(l+=n,c+=p)}let y=$r(l);return y.length>0&&u.push(y),u.join(`
7
- `)}var ri={willReadFrequently:!0},ii=class e{static get experimentalLetterSpacingSupported(){let t=e._experimentalLetterSpacingSupported;if(t===void 0){let n=Rt.get().getCanvasRenderingContext2D().prototype;t=e._experimentalLetterSpacingSupported=`letterSpacing`in n||`textLetterSpacing`in n}return t}constructor(e,t,n,r,i,a,o,s,c,l){this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c,l&&(this.runsByLine=l.runsByLine,this.lineAscents=l.lineAscents,this.lineDescents=l.lineDescents,this.lineHeights=l.lineHeights,this.hasDropShadow=l.hasDropShadow)}static measureText(t=` `,n,r=e._canvas,i=n.wordWrap){let a=`${t}-${n.styleKey}-wordWrap-${i}`;if(e._measurementCache.has(a))return e._measurementCache.get(a);if(qr(n)&&Jr(t)){let r=mte(t,n,i,e._context,e._measureText,e.measureFont,e.canBreakChars,e.wordWrapSplit),o=new e(t,n,r.width,r.height,r.lines,r.lineWidths,r.lineHeight,r.maxLineWidth,r.fontProperties,{runsByLine:r.runsByLine,lineAscents:r.lineAscents,lineDescents:r.lineDescents,lineHeights:r.lineHeights,hasDropShadow:r.hasDropShadow});return e._measurementCache.set(a,o),o}let o=n._fontString,s=e.measureFont(o);s.fontSize===0&&(s.fontSize=n.fontSize,s.ascent=n.fontSize,s.descent=0);let c=e._context;c.font=o;let l=(i?e._wordWrap(t,n,r):t).split(fte),u=Array(l.length),d=0;for(let t=0;t<l.length;t++){let r=e._measureText(l[t],n.letterSpacing,c);u[t]=r,d=Math.max(d,r)}let f=n._stroke?.width??0,p=n.lineHeight||s.fontSize,m=e._getAlignWidth(d,n,i),h=e._adjustWidthForStyle(m,n),g=Math.max(p,s.fontSize+f)+(l.length-1)*(p+n.leading),_=new e(t,n,h,e._adjustHeightForStyle(g,n),l,u,p+n.leading,d,s);return e._measurementCache.set(a,_),_}static _adjustWidthForStyle(e,t){let n=e+(t._stroke?.width||0);return t.dropShadow&&(n+=t.dropShadow.distance),n}static _adjustHeightForStyle(e,t){let n=e;return t.dropShadow&&(n+=t.dropShadow.distance),n}static _getAlignWidth(e,t,n){return n&&t.align!==`left`&&t.align!==`justify`?Math.max(e,t.wordWrapWidth):e}static _measureText(t,n,r){let i=!1;e.experimentalLetterSpacingSupported&&(e.experimentalLetterSpacing?(r.letterSpacing=`${n}px`,r.textLetterSpacing=`${n}px`,i=!0):(r.letterSpacing=`0px`,r.textLetterSpacing=`0px`));let a=r.measureText(t),o=a.width,s=-(a.actualBoundingBoxLeft??0),c=(a.actualBoundingBoxRight??0)-s;if(o>0)if(i)o-=n,c-=n;else{let r=(e.graphemeSegmenter(t).length-1)*n;o+=r,c+=r}return Math.max(o,c)}static _wordWrap(t,n,r=e._canvas){return vte(t,n,r,e._measureText,e.canBreakWords,e.canBreakChars,e.wordWrapSplit)}static isBreakingSpace(e,t){return Xr(e,t)}static canBreakWords(e,t){return t}static canBreakChars(e,t,n,r,i){return!0}static wordWrapSplit(t){return e.graphemeSegmenter(t)}static measureFont(t){if(e._fonts[t])return e._fonts[t];let n=e._context;n.font=t;let r=n.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),i=r.actualBoundingBoxAscent??0,a=r.actualBoundingBoxDescent??0,o={ascent:i,descent:a,fontSize:i+a};return e._fonts[t]=o,o}static clearMetrics(t=``){t?delete e._fonts[t]:e._fonts={}}static get _canvas(){if(!e.__canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,ri)?.measureText)return e.__canvas=n,n;t=Rt.get().createCanvas()}catch{t=Rt.get().createCanvas()}t.width=t.height=10,e.__canvas=t}return e.__canvas}static get _context(){return e.__context||=e._canvas.getContext(`2d`,ri),e.__context}};ii.METRICS_STRING=`|ÉqÅ`,ii.BASELINE_SYMBOL=`M`,ii.BASELINE_MULTIPLIER=1.4,ii.HEIGHT_MULTIPLIER=2,ii.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter==`function`){let e=new Intl.Segmenter;return t=>{let n=e.segment(t),r=[],i=0;for(let e of n)r[i++]=e.segment;return r}}return e=>[...e]})(),ii.experimentalLetterSpacing=!1,ii._fonts={},ii._measurementCache=ote(1e3);var ai=ii,yte=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`];function oi(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!yte.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var si=class e extends jt{constructor(t={}){super(),this.uid=Dt(`textStyle`),this._tick=0,this._cachedFontString=null,bte(t),t instanceof e&&(t=t._toObject());let n={...e.defaultTextStyle,...t};for(let e in n){let t=e;this[t]=n[e]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(typeof t==`object`&&t?this._dropShadow=this._createProxy({...e.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...e.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e==`string`?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Ut.defaultFillStyle,...e},()=>{this._fill=Bt({...this._originalFill},Ut.defaultFillStyle)})),this._fill=Bt(e===0?`black`:e,Ut.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ut.defaultStrokeStyle,...e},()=>{this._stroke=zt({...this._originalStroke},Ut.defaultStrokeStyle)})),this._stroke=zt(e,Ut.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit(`update`,this)}reset(){let t=e.defaultTextStyle;for(let e in t)this[e]=t[e]}assign(e){for(let t in e){let n=t;this[n]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=oi(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new e(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){if(this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(t),this._originalFill?.texture&&this._originalFill.texture.destroy(t),this._stroke?.texture&&this._stroke.texture.destroy(t),this._originalStroke?.texture&&this._originalStroke.texture.destroy(t)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(e,n,r)=>e[n]===r?!0:(e[n]=r,t?.(n,r),this.update(),!0)})}_isFillStyle(e){return(e??null)!==null&&!(Pt.isColorLike(e)||e instanceof Wt||e instanceof Ht)}};si.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:`black`,distance:5},si.defaultTextStyle={align:`left`,breakWords:!1,dropShadow:null,fill:`black`,fontFamily:`Arial`,fontSize:26,fontStyle:`normal`,fontVariant:`normal`,fontWeight:`normal`,leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:`alphabetic`,trim:!1,whiteSpace:`pre`,wordWrap:!1,wordWrapWidth:100};var ci=si;function bte(e){let t=e;if(typeof t.dropShadow==`boolean`&&t.dropShadow){let n=ci.defaultDropShadow;e.dropShadow={alpha:t.dropShadowAlpha??n.alpha,angle:t.dropShadowAngle??n.angle,blur:t.dropShadowBlur??n.blur,color:t.dropShadowColor??n.color,distance:t.dropShadowDistance??n.distance}}if(t.strokeThickness!==void 0){bt(Et,`strokeThickness is now a part of stroke`);let n=t.stroke,r={};if(Pt.isColorLike(n))r.color=n;else if(n instanceof Wt||n instanceof Ht)r.fill=n;else if(Object.hasOwnProperty.call(n,`color`)||Object.hasOwnProperty.call(n,`fill`))r=n;else throw Error(`Invalid stroke value.`);e.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(bt(Et,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw Error(`Invalid fill value. Expected an array of colors for gradient fill.`);t.fill.length!==t.fillGradientStops.length&&Mt(`The number of fill colors must match the number of fill gradient stops.`);let n=new Wt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:`local`}),r=t.fillGradientStops.slice(),i=t.fill.map(e=>Pt.shared.setValue(e).toNumber());r.forEach((e,t)=>{n.addColorStop(e,i[t])}),e.fill={fill:n}}}var li=1e5;function ui(e,t,n,r=0,i=0,a=0){if(e.texture===wt.WHITE&&!e.fill)return Pt.shared.setValue(e.color).setAlpha(e.alpha??1).toHexa();if(!e.fill){let n=t.createPattern(e.texture.source.resource,`repeat`),r=e.matrix.copyTo(_t.shared);return r.scale(e.texture.source.pixelWidth,e.texture.source.pixelHeight),n.setTransform(r),n}else if(e.fill instanceof Ht){let n=e.fill,r=t.createPattern(n.texture.source.resource,`repeat`),i=n.transform.copyTo(_t.shared);return i.scale(n.texture.source.pixelWidth,n.texture.source.pixelHeight),r.setTransform(i),r}else if(e.fill instanceof Wt){let o=e.fill,s=o.type===`linear`,c=o.textureSpace===`local`,l=1,u=1;c&&n&&(l=n.width+r,u=n.height+r);let d,f=!1;if(s){let{start:e,end:n}=o;d=t.createLinearGradient(e.x*l+i,e.y*u+a,n.x*l+i,n.y*u+a),f=Math.abs(n.x-e.x)<Math.abs((n.y-e.y)*.1)}else{let{center:e,innerRadius:n,outerCenter:r,outerRadius:s}=o;d=t.createRadialGradient(e.x*l+i,e.y*u+a,n*l,r.x*l+i,r.y*u+a,s*l)}if(f&&c&&n){let e=n.lineHeight/u;for(let t=0;t<n.lines.length;t++){let i=(t*n.lineHeight+r/2)/u;o.colorStops.forEach(t=>{let n=i+t.offset*e;n=Math.max(0,Math.min(1,n)),d.addColorStop(Math.floor(n*li)/li,Pt.shared.setValue(t.color).toHex())})}}else o.colorStops.forEach(e=>{d.addColorStop(e.offset,Pt.shared.setValue(e.color).toHex())});return d}return Mt(`FillStyle not recognised`,e),`red`}var di=class extends Gr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Vr(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),fi(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pi(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Fr(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ar(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&mi(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Fr(this.options.enabled,this.#t)!==Fr(t.enabled,this.#t)||Pr(this.options.staleTime,this.#t)!==Pr(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Fr(this.options.enabled,this.#t)!==Fr(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Ste(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Nr)),t}#g(){this.#b();let e=Pr(this.options.staleTime,this.#t);if(Ur||this.#r.isStale||!Mr(e))return;let t=ite(this.#r.dataUpdatedAt,e)+1;this.#d=jr.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Ur||Fr(this.options.enabled,this.#t)===!1||!Mr(this.#p)||this.#p===0)&&(this.#f=jr.setInterval(()=>{(this.options.refetchIntervalInBackground||Qee.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(jr.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(jr.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&fi(e,t),o=i&&mi(e,n,t,r);(a||o)&&(l={...l,...Zee(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=zr(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=zr(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:hi(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Fr(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{t(this.#o=x.promise=Vr())},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Ar(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){Rr.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function xte(e,t){return Fr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function fi(e,t){return xte(e,t)||e.state.data!==void 0&&pi(e,t,t.refetchOnMount)}function pi(e,t,n){if(Fr(t.enabled,e)!==!1&&Pr(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&hi(e,t)}return!1}function mi(e,t,n,r){return(e!==t||Fr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&hi(e,n)}function hi(e,t){return Fr(t.enabled,e)!==!1&&e.isStaleByTime(Pr(t.staleTime,e))}function Ste(e,t){return!Ar(e.getCurrentResult(),t)}var Cte=class extends di{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Ir()})}getOptimisticResult(e){return e.behavior=Ir(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:tte(t,n.data),hasPreviousPage:nte(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},wte=class extends Gr{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Ar(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Lr(t.mutationKey)!==Lr(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??rte();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Rr.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n,r),this.#r.onSettled?.(e.data,null,t,n,r)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n,r),this.#r.onSettled?.(void 0,e.error,t,n,r))}this.listeners.forEach(e=>{e(this.#t)})})}};function gi(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Tte(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ete=class extends Gr{#e;#t;#n;#r;#i;#a;#o;#s;#c=[];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.#f(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,Rr.batch(()=>{let e=this.#i,t=this.#d(this.#n);this.#c=t,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||!Ar(e,n)});!o&&!s||(o&&(this.#i=n),this.#t=r,this.hasListeners()&&(o&&(gi(e,n).forEach(e=>{e.destroy()}),gi(n,e).forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})),this.#p()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#d(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions));return[r,e=>this.#u(e??r,t),()=>this.#l(r,n)]}#l(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)})})})}#u(e,t){return t?((!this.#a||this.#t!==this.#s||t!==this.#o)&&(this.#o=t,this.#s=this.#t,this.#a=ete(this.#a,t(e))),this.#a):e}#d(e){let t=new Map(this.#i.map(e=>[e.options.queryHash,e])),n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new di(this.#e,r)})}),n}#f(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Tte(this.#t,n,t),this.#p())}#p(){if(this.hasListeners()){let e=this.#a,t=this.#l(this.#t,this.#c);e!==this.#u(t,this.#r?.combine)&&Rr.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},_i=Y.createContext(void 0),vi=e=>{let t=Y.useContext(_i);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Dte=({client:e,children:t})=>(Y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,J.jsx)(_i.Provider,{value:e,children:t})),yi=Y.createContext(!1),bi=()=>Y.useContext(yi);yi.Provider;function Ote(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kte=Y.createContext(Ote()),xi=()=>Y.useContext(kte),Si=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ci=e=>{Y.useEffect(()=>{e.clearReset()},[e])},wi=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Wr(n,[e.error,r])),Ti=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ei=(e,t)=>e.isLoading&&e.isFetching&&!t,Di=(e,t)=>e?.suspense&&t.isPending,Oi=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ate({queries:e,...t},n){let r=vi(n),i=bi(),a=xi(),o=Y.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ti(e),Si(e,a)}),Ci(a);let[s]=Y.useState(()=>new Ete(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;Y.useSyncExternalStore(Y.useCallback(e=>d?s.subscribe(Rr.batchCalls(e)):Nr,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),Y.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Di(o[t],e))?c.flatMap((e,t)=>{let n=o[t];if(n){let t=new di(r,n);if(Di(n,e))return Oi(n,t,a);Ei(e,i)&&Oi(n,t,a)}return[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&wi({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())}function ki(e,t,n){let r=bi(),i=xi(),a=vi(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Ti(o),Si(o,i),Ci(i);let s=!a.getQueryCache().get(o.queryHash),[c]=Y.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(Y.useSyncExternalStore(Y.useCallback(e=>{let t=u?c.subscribe(Rr.batchCalls(e)):Nr;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Y.useEffect(()=>{c.setOptions(o)},[o,c]),Di(o,l))throw Oi(o,c,i);if(wi({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!Ur&&Ei(l,r)&&(s?Oi(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Nr).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function Ai(e,t){return ki(e,di,t)}function ji(e,t){let n=vi(t),[r]=Y.useState(()=>new wte(n,e));Y.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(Rr.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=Y.useCallback((e,t)=>{r.mutate(e,t).catch(Nr)},[r]);if(i.error&&Wr(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function jte(e,t){return ki(e,Cte,t)}var Mi=new WeakMap,Mte=new WeakMap,Ni={current:[]},Pi=!1,Fi=0,Ii=new Set,Li=new Map;function Ri(e){for(let t of e){if(Ni.current.includes(t))continue;Ni.current.push(t),t.recompute();let e=Mte.get(t);if(e)for(let t of e){let e=Mi.get(t);e?.length&&Ri(e)}}}function Nte(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function Pte(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function zi(e){if(Fi>0&&!Li.has(e)&&Li.set(e,e.prevState),Ii.add(e),!(Fi>0)&&!Pi)try{for(Pi=!0;Ii.size>0;){let e=Array.from(Ii);Ii.clear();for(let t of e)t.prevState=Li.get(t)??t.prevState,Nte(t);for(let t of e){let e=Mi.get(t);e&&(Ni.current.push(t),Ri(e))}for(let t of e){let e=Mi.get(t);if(e)for(let t of e)Pte(t)}}}finally{Pi=!1,Ni.current=[],Li.clear()}}function Bi(e){Fi++;try{e()}finally{if(Fi--,Fi===0){let e=Ii.values().next().value;e&&zi(e)}}}function Fte(e){return typeof e==`function`}var Ite=class{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t;this.listeners.add(e);let n=((t=this.options)?.onSubscribe)?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.prevState=e,this.state=e,this.options=t}setState(e){var t,n;this.prevState=this.state,this.options?.updateFn?this.state=this.options.updateFn(this.prevState)(e):Fte(e)?this.state=e(this.prevState):this.state=e,(n=(t=this.options)?.onUpdate)==null||n.call(t),zi(this)}},Vi=`__TSR_index`,Hi=`popstate`,Ui=`beforeunload`;function Wi(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=Ki(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Vi];i=Gi(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Vi];i=Gi(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Vi]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function Gi(e,t){t||={};let n=qi();return{...t,key:n,__TSR_key:n,[Vi]:e}}function Lte(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>Ki(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=qi();t.history.replaceState({[Vi]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=Ki(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[Vi]-l.state[Vi],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=Wi({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Ui,S,{capture:!0}),t.removeEventListener(Hi,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(Ui,S,{capture:!0}),t.addEventListener(Hi,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function Ki(e,t){let n=e.indexOf(`#`),r=e.indexOf(`?`),i=qi();return{href:e,pathname:e.substring(0,n>0?r>0?Math.min(n,r):n:r>0?r:e.length),hash:n>-1?e.substring(n):``,search:r>-1?e.slice(r,n===-1?void 0:n):``,state:t||{[Vi]:0,key:i,__TSR_key:i}}}function qi(){return(Math.random()+1).toString(36).substring(7)}function Ji(e){return e[e.length-1]}function Rte(e){return typeof e==`function`}function Yi(e,t){return Rte(e)?e(t):e}var zte=Object.prototype.hasOwnProperty;function Xi(e,t){if(e===t)return e;let n=t,r=ea(e)&&ea(n);if(!r&&!(Qi(e)&&Qi(n)))return n;let i=r?e:Zi(e);if(!i)return n;let a=r?n:Zi(n);if(!a)return n;let o=i.length,s=a.length,c=r?Array(s):{},l=0;for(let t=0;t<s;t++){let i=r?t:a[t],s=e[i],u=n[i];if(s===u){c[i]=s,(r?t<o:zte.call(e,i))&&l++;continue}if(s===null||u===null||typeof s!=`object`||typeof u!=`object`){c[i]=u;continue}let d=Xi(s,u);c[i]=d,d===s&&l++}return o===s&&l===o?e:c}function Zi(e){let t=[],n=Object.getOwnPropertyNames(e);for(let r of n){if(!Object.prototype.propertyIsEnumerable.call(e,r))return!1;t.push(r)}let r=Object.getOwnPropertySymbols(e);for(let n of r){if(!Object.prototype.propertyIsEnumerable.call(e,n))return!1;t.push(n)}return t}function Qi(e){if(!$i(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!$i(n)||!n.hasOwnProperty(`isPrototypeOf`))}function $i(e){return Object.prototype.toString.call(e)===`[object Object]`}function ea(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ta(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!ta(e[r],t[r],n))return!1;return!0}if(Qi(e)&&Qi(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!ta(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!ta(e[o],t[o],n)))return!1;return i===a}return!1}function na(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function ra(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function ia(e){try{return decodeURI(e)}catch{return e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}}function aa(e,t){if(!e)return e;let n=t?RegExp(`${t.join(`|`)}`,`gi`):/%25|%5C/gi,r=0,i=``,a;for(;(a=n.exec(e))!==null;)i+=ia(e.slice(r,a.index))+a[0],r=n.lastIndex;return i+ia(r?e.slice(r):e)}var Bte=!0,oa=`Invariant failed`;function sa(e,t){if(!e){if(Bte)throw Error(oa);var n=typeof t==`function`?t():t,r=n?`${oa}: ${n}`:oa;throw Error(r)}}function ca(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var Vte=/^([^{]*)\{\$([a-zA-Z_$][a-zA-Z0-9_$]*)\}([^}]*)$/,Hte=/^([^{]*)\{-\$([a-zA-Z_$][a-zA-Z0-9_$]*)\}([^}]*)$/,Ute=/^([^{]*)\{\$\}([^}]*)$/;function la(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=a.match(Ute);if(o){let r=o[1].length;return n[0]=2,n[1]=t+r,n[2]=t+r+1,n[3]=t+r+2,n[4]=t+r+3,n[5]=e.length,n}let s=a.match(Hte);if(s){let e=s[1],r=s[2],a=s[3],o=e.length;return n[0]=3,n[1]=t+o,n[2]=t+o+3,n[3]=t+o+3+r.length,n[4]=i-a.length,n[5]=i,n}let c=a.match(Vte);if(c){let e=c[1],r=c[2],a=c[3],o=e.length;return n[0]=1,n[1]=t+o,n[2]=t+o+2,n[3]=t+o+2+r.length,n[4]=i-a.length,n[5]=i,n}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function ua(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e;for(;s<o;){let e=la(r,s,t),o,l=s,u=e[5];switch(s=u+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=pa(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=pa(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(l,e[1]),s=r.substring(e[4],u),d=c&&!!(t||s),f=t?d?t:t.toLowerCase():void 0,p=s?d?s:s.toLowerCase():void 0,m=i.dynamic?.find(e=>e.caseSensitive===d&&e.prefix===f&&e.suffix===p);if(m)o=m;else{let e=ma(1,n.fullPath??n.from,d,f,p);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(l,e[1]),s=r.substring(e[4],u),d=c&&!!(t||s),f=t?d?t:t.toLowerCase():void 0,p=s?d?s:s.toLowerCase():void 0,m=i.optional?.find(e=>e.caseSensitive===d&&e.prefix===f&&e.suffix===p);if(m)o=m;else{let e=ma(3,n.fullPath??n.from,d,f,p);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(l,e[1]),s=r.substring(e[4],u),d=c&&!!(t||s),f=t?d?t:t.toLowerCase():void 0,p=s?d?s:s.toLowerCase():void 0,m=ma(2,n.fullPath??n.from,d,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if((n.path||!n.children)&&!n.isRoot){let e=r.endsWith(`/`);e||(i.notFound=n),(!i.route||!i.isIndex&&e)&&(i.route=n),i.isIndex||=e}}if(n.children)for(let r of n.children)ua(e,t,r,s,i,a,o)}function da(e,t){if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function fa(e){if(e.static)for(let t of e.static.values())fa(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())fa(t);if(e.dynamic?.length){e.dynamic.sort(da);for(let t of e.dynamic)fa(t)}if(e.optional?.length){e.optional.sort(da);for(let t of e.optional)fa(t)}if(e.wildcard?.length){e.wildcard.sort(da);for(let t of e.wildcard)fa(t)}}function pa(e){return{kind:0,depth:0,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,isIndex:!1,notFound:null}}function ma(e,t,n,r,i){return{kind:e,depth:0,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,isIndex:!1,notFound:null,caseSensitive:n,prefix:r,suffix:i}}function Wte(e,t){let n=pa(`/`),r=new Uint16Array(6);for(let t of e)ua(!1,r,t,1,n,0);fa(n),t.masksTree=n,t.flatCache=ca(1e3)}function Gte(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=ha(e,t.masksTree);return t.flatCache.set(e,r),r}function Kte(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=pa(`/`),ua(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),ha(r,o,n)}function qte(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a=ha(e,t.segmentTree,n);return a&&(a.branch=Zte(a.route)),t.matchCache.set(r,a),a}function Jte(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function Yte(e,t=!1,n){let r=pa(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return ua(t,i,e,1,r,0,e=>{if(n?.(e,s),sa(!(e.id in a),`Duplicate routes found with id: ${String(e.id)}`),a[e.id]=e,s!==0&&e.path){let t=Jte(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),fa(r),{processedTree:{segmentTree:r,singleCache:ca(1e3),matchCache:ca(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function ha(e,t,n=!1){let r=e.split(`/`),i=$te(e,r,t,n);if(!i)return null;let a=Xte(e,r,i),o=`**`in i;return o&&(a[`**`]=i[`**`]),{route:o?i.node.notFound??i.node.route:i.node.route,params:a}}function Xte(e,t,n){let r=Qte(n.node),i=null,a={};for(let o=0,s=0,c=0;s<r.length;o++,s++,c++){let l=r[s],u=t[o],d=c;if(u&&(c+=u.length),l.kind===1){i??=n.node.fullPath.split(`/`);let e=i[s],t=l.prefix?.length??0;if(e.charCodeAt(t)===123){let n=l.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=u.substring(t,u.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(u)}}else if(l.kind===3){if(n.skipped&1<<s){o--;continue}i??=n.node.fullPath.split(`/`);let e=i[s],t=l.prefix?.length??0,r=l.suffix?.length??0,c=e.substring(t+3,e.length-r-1),d=l.suffix||l.prefix?u.substring(t,u.length-r):u;d&&(a[c]=decodeURIComponent(d))}else if(l.kind===2){let t=l,n=e.substring(d+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return a}function Zte(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Qte(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function $te(e,t,n,r){let i=!Ji(t),a=i&&e!==`/`,o=t.length-(i?1:0),s=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}],c=null,l=null,u=null;for(;s.length;){let e=s.pop(),{node:n,index:i,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=e;r&&n.notFound&&ga(l,e)&&(l=e);let g=i===o;if(g){if(n.route&&(!a||n.isIndex)&&(ga(u,e)&&(u=e),p===o&&n.isIndex))return u;if(!n.optional&&!n.wildcard)continue}let _=g?void 0:t[i],v;if(n.wildcard&&ga(c,e))for(let e of n.wildcard){let{prefix:n,suffix:r}=e;if(!(n&&(g||!(e.caseSensitive?_:v??=_.toLowerCase()).startsWith(n)))){if(r){if(g)continue;let n=t.slice(i).join(`/`).slice(-r.length);if((e.caseSensitive?n:n.toLowerCase())!==r)continue}c={node:e,index:i,skipped:d,depth:f,statics:p,dynamics:m,optionals:h};break}}if(n.optional){let e=d|1<<f,t=f+1;for(let r=n.optional.length-1;r>=0;r--){let a=n.optional[r];s.push({node:a,index:i,skipped:e,depth:t,statics:p,dynamics:m,optionals:h})}if(!g)for(let e=n.optional.length-1;e>=0;e--){let r=n.optional[e],{prefix:a,suffix:o}=r;if(a||o){let e=r.caseSensitive?_:v??=_.toLowerCase();if(a&&!e.startsWith(a)||o&&!e.endsWith(o))continue}s.push({node:r,index:i+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+1})}}if(!g&&n.dynamic&&_)for(let e=n.dynamic.length-1;e>=0;e--){let t=n.dynamic[e],{prefix:r,suffix:a}=t;if(r||a){let e=t.caseSensitive?_:v??=_.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:t,index:i+1,skipped:d,depth:f+1,statics:p,dynamics:m+1,optionals:h})}if(!g&&n.staticInsensitive){let e=n.staticInsensitive.get(v??=_.toLowerCase());e&&s.push({node:e,index:i+1,skipped:d,depth:f+1,statics:p+1,dynamics:m,optionals:h})}if(!g&&n.static){let e=n.static.get(_);e&&s.push({node:e,index:i+1,skipped:d,depth:f+1,statics:p+1,dynamics:m,optionals:h})}}if(u)return u;if(c)return c;if(r&&l){let n=l.index;for(let e=0;e<l.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return{node:l.node,skipped:l.skipped,"**":decodeURIComponent(r)}}return null}function ga(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&(t.node.isIndex>e.node.isIndex||t.node.isIndex===e.node.isIndex&&t.depth>e.depth))):!0}function _a(e){return va(e.filter(e=>e!==void 0).join(`/`))}function va(e){return e.replace(/\/{2,}/g,`/`)}function ya(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function ba(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function xa(e){return ba(ya(e))}function Sa(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function ene(e,t,n){return Sa(e,n)===Sa(t,n)}function tne({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&Ji(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(Ji(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c,l=``;for(let e=0;e<s.length;e++){e>0&&(l+=`/`);let t=s[e];if(!t)continue;c=la(t,0,c);let n=c[0];if(n===0){l+=t;continue}let r=c[5],i=t.substring(0,c[1]),a=t.substring(c[4],r),o=t.substring(c[2],c[3]);n===1?l+=i||a?`${i}{$${o}}${a}`:`$${o}`:n===2?l+=i||a?`${i}{$}${a}`:`$`:l+=`${i}{-$${o}}${a}`}l=va(l);let u=l||`/`;return o&&r&&r.set(o,u),u}function Ca(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?encodeURI(r):nne(r,n):r}function wa({path:e,params:t,decodeCharMap:n}){let r=!1,i={};if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:i,isMissingParams:r};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:i,isMissingParams:r};let a=e.length,o=0,s,c=``;for(;o<a;){let a=o;s=la(e,a,s);let l=s[5];if(o=l+1,a===l)continue;let u=s[0];if(u===0){c+=`/`+e.substring(a,l);continue}if(u===2){let o=t._splat;i._splat=o,i[`*`]=o;let u=e.substring(a,s[1]),d=e.substring(s[4],l);if(!o){r=!0,(u||d)&&(c+=`/`+u+d);continue}let f=Ca(`_splat`,t,n);c+=`/`+u+f+d;continue}if(u===1){let o=e.substring(s[2],s[3]);!r&&!(o in t)&&(r=!0),i[o]=t[o];let u=e.substring(a,s[1]),d=e.substring(s[4],l),f=Ca(o,t,n)??`undefined`;c+=`/`+u+f+d;continue}if(u===3){let r=e.substring(s[2],s[3]),o=t[r];if(o==null)continue;i[r]=o;let u=e.substring(a,s[1]),d=e.substring(s[4],l),f=Ca(r,t,n)??``;c+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(c+=`/`),{usedParams:i,interpolatedPath:c||`/`,isMissingParams:r}}function nne(e,t){let n=encodeURIComponent(e);if(t)for(let[e,r]of t)n=n.replaceAll(e,r);return n}function Ta(e={}){if(e.isNotFound=!0,e.throw)throw e;return e}function Ea(e){return!!e?.isNotFound}function rne(){try{if(typeof window<`u`&&typeof window.sessionStorage==`object`)return window.sessionStorage}catch{}}var Da=`tsr-scroll-restoration-v1_3`,ine=(e,t)=>{let n;return(...r)=>{n||=setTimeout(()=>{e(...r),n=null},t)}};function ane(){let e=rne();if(!e)return null;let t=e.getItem(Da),n=t?JSON.parse(t):{};return{state:n,set:t=>(n=Yi(t,n)||n,e.setItem(Da,JSON.stringify(n)))}}var Oa=ane(),ka=e=>e.state.__TSR_key||e.href;function one(e){let t=[],n;for(;n=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,e)+1})`),e=n;return`${t.reverse().join(` > `)}`.toLowerCase()}var Aa=!1;function ja({storageKey:e,key:t,behavior:n,shouldScrollRestoration:r,scrollToTopSelectors:i,location:a}){let o;try{o=JSON.parse(sessionStorage.getItem(e)||`{}`)}catch(e){console.error(e);return}let s=t||window.history.state?.__TSR_key,c=o[s];Aa=!0;scroll:{if(r&&c&&Object.keys(c).length>0){for(let e in c){let t=c[e];if(e===`window`)window.scrollTo({top:t.scrollY,left:t.scrollX,behavior:n});else if(e){let n=document.querySelector(e);n&&(n.scrollLeft=t.scrollX,n.scrollTop=t.scrollY)}}break scroll}let e=(a??window.location).hash.split(`#`,2)[1];if(e){let t=window.history.state?.__hashScrollIntoViewOptions??!0;if(t){let n=document.getElementById(e);n&&n.scrollIntoView(t)}break scroll}let t={top:0,left:0,behavior:n};if(window.scrollTo(t),i)for(let e of i){if(e===`window`)continue;let n=typeof e==`function`?e():document.querySelector(e);n&&n.scrollTo(t)}}Aa=!1}function sne(e,t){if(!Oa&&!e.isServer||((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isServer||e.isScrollRestorationSetup||!Oa))return;e.isScrollRestorationSetup=!0,Aa=!1;let n=e.options.getScrollRestorationKey||ka;window.history.scrollRestoration=`manual`,typeof document<`u`&&document.addEventListener(`scroll`,ine(t=>{if(Aa||!e.isScrollRestoring)return;let r=``;if(t.target===document||t.target===window)r=`window`;else{let e=t.target.getAttribute(`data-scroll-restoration-id`);r=e?`[data-scroll-restoration-id="${e}"]`:one(t.target)}let i=n(e.state.location);Oa.set(e=>{let t=e[i]||={},n=t[r]||={};if(r===`window`)n.scrollX=window.scrollX||0,n.scrollY=window.scrollY||0;else if(r){let e=document.querySelector(r);e&&(n.scrollX=e.scrollLeft||0,n.scrollY=e.scrollTop||0)}return e})},100),!0),e.subscribe(`onRendered`,t=>{let r=n(t.toLocation);if(!e.resetNextScroll){e.resetNextScroll=!0;return}typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation})||(ja({storageKey:Da,key:r,behavior:e.options.scrollRestorationBehavior,shouldScrollRestoration:e.isScrollRestoring,scrollToTopSelectors:e.options.scrollToTopSelectors,location:e.history.location}),e.isScrollRestoring&&Oa.set(e=>(e[r]||={},e)))})}function cne(e){if(typeof document<`u`&&document.querySelector){let t=e.state.location.state.__hashScrollIntoViewOptions??!0;if(t&&e.state.location.hash!==``){let n=document.getElementById(e.state.location.hash);n&&n.scrollIntoView(t)}}}function lne(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function Ma(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function une(e){let t=new URLSearchParams(e),n={};for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Ma(r):Array.isArray(t)?t.push(Ma(r)):n[e]=[t,Ma(r)]}return n}var dne=pne(JSON.parse),fne=mne(JSON.stringify,JSON.parse);function pne(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=une(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function mne(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=lne(e,r);return t?`?${t}`:``}}var Na=`__root__`;function hne(e){if(e.statusCode=e.statusCode||e.code||307,!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Pa(e){return e instanceof Response&&!!e.options}var Fa=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Ia=(e,t)=>!!(e.preload&&!e.router.state.matches.some(e=>e.id===t)),La=(e,t)=>{let n=e.router.routesById[t.routeId??``]??e.router.routeTree;!n.options.notFoundComponent&&e.router.options?.defaultNotFoundComponent&&(n.options.notFoundComponent=e.router.options.defaultNotFoundComponent),sa(n.options.notFoundComponent,`No notFoundComponent found. Please set a notFoundComponent on your route or provide a defaultNotFoundComponent to the router.`);let r=e.matches.find(e=>e.routeId===n.id);sa(r,`Could not find match for route: `+n.id),e.updateMatch(r.id,e=>({...e,status:`notFound`,error:t,isFetching:!1})),t.routerCode===`BEFORE_LOAD`&&n.parentRoute&&(t.routeId=n.parentRoute.id,La(e,t))},Ra=(e,t,n)=>{if(!(!Pa(n)&&!Ea(n))){if(Pa(n)&&n.redirectHandled&&!n.options.reloadDocument)throw n;if(t){t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0;let r=Pa(n)?`redirected`:`notFound`;t._nonReactive.error=n,e.updateMatch(t.id,e=>({...e,status:r,isFetching:!1,error:n})),Ea(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()}throw Pa(n)?(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n),n):(La(e,n),n)}},za=(e,t)=>{let n=e.router.getMatch(t);return!!(!e.router.isServer&&n._nonReactive.dehydrated||e.router.isServer&&n.ssr===!1)},Ba=(e,t,n,r)=>{let{id:i,routeId:a}=e.matches[t],o=e.router.looseRoutesById[a];if(n instanceof Promise)throw n;n.routerCode=r,e.firstBadMatchIndex??=t,Ra(e,e.router.getMatch(i),n);try{o.options.onError?.(n)}catch(t){n=t,Ra(e,e.router.getMatch(i),n)}e.updateMatch(i,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController}))},gne=(e,t,n,r)=>{let i=e.router.getMatch(t),a=e.matches[n-1]?.id,o=a?e.router.getMatch(a):void 0;if(e.router.isShell()){i.ssr=r.id===Na;return}if(o?.ssr===!1){i.ssr=!1;return}let s=e=>e===!0&&o?.ssr===`data-only`?`data-only`:e,c=e.router.options.defaultSsr??!0;if(r.options.ssr===void 0){i.ssr=s(c);return}if(typeof r.options.ssr!=`function`){i.ssr=s(r.options.ssr);return}let{search:l,params:u}=i,d={search:qa(l,i.searchError),params:qa(u,i.paramsError),location:e.location,matches:e.matches.map(e=>({index:e.index,pathname:e.pathname,fullPath:e.fullPath,staticData:e.staticData,id:e.id,routeId:e.routeId,search:qa(e.search,e.searchError),params:qa(e.params,e.paramsError),ssr:e.ssr}))},f=r.options.ssr(d);if(ra(f))return f.then(e=>{i.ssr=s(e??c)});i.ssr=s(f??c)},Va=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!e.router.isServer&&!Ia(e,t)&&(n.options.loader||n.options.beforeLoad||Ja(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{Fa(e)},i);r._nonReactive.pendingTimeout=t}},_ne=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Va(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Ra(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},vne=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=na(()=>{a?.resolve()});let{paramsError:o,searchError:s}=i;o&&Ba(e,n,o,`PARSE_PARAMS`),s&&Ba(e,n,s,`VALIDATE_SEARCH`),Va(e,t,r,i);let c=new AbortController,l=e.matches[n-1]?.id,u={...(l?e.router.getMatch(l):void 0)?.context??e.router.options.context??void 0,...i.__routeContext},d=!1,f=()=>{d||(d=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c,context:u})))},p=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){Bi(()=>{f(),p()});return}i._nonReactive.beforeLoadPromise=na();let{search:m,params:h,cause:g}=i,_=Ia(e,t),v={search:m,abortController:c,params:h,preload:_,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:_?`preload`:g,matches:e.matches,...e.router.options.additionalContext},y=r=>{if(r===void 0){Bi(()=>{f(),p()});return}(Pa(r)||Ea(r))&&(f(),Ba(e,n,r,`BEFORE_LOAD`)),Bi(()=>{f(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r,context:{...e.context,...r}})),p()})},b;try{if(b=r.options.beforeLoad(v),ra(b))return f(),b.catch(t=>{Ba(e,n,t,`BEFORE_LOAD`)}).then(y)}catch(t){f(),Ba(e,n,t,`BEFORE_LOAD`)}y(b)},yne=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>{if(e.router.isServer){let r=gne(e,n,t,i);if(ra(r))return r.then(s)}return s()},o=()=>vne(e,n,t,i),s=()=>{if(za(e,n))return;let t=_ne(e,n,i);return ra(t)?t.then(o):o()};return a()},Ha=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},Ua=(e,t,n,r)=>{let i=e.matchPromises[n-1],{params:a,loaderDeps:o,abortController:s,cause:c}=e.router.getMatch(t),l=e.router.options.context??{};for(let t=0;t<=n;t++){let n=e.matches[t];if(!n)continue;let r=e.router.getMatch(n.id);r&&(l={...l,...r.__routeContext??{},...r.__beforeLoadContext??{}})}let u=Ia(e,t);return{params:a,deps:o,preload:!!u,parentMatchPromise:i,abortController:s,context:l,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:u?`preload`:c,route:r,...e.router.options.additionalContext}},Wa=async(e,t,n,r)=>{try{let i=e.router.getMatch(t);try{(!e.router.isServer||i.ssr===!0)&&Ka(r);let a=r.options.loader?.(Ua(e,t,n,r)),o=r.options.loader&&ra(a);if((o||r._lazyPromise||r._componentsPromise||r.options.head||r.options.scripts||r.options.headers||i._nonReactive.minPendingPromise)&&e.updateMatch(t,e=>({...e,isFetching:`loader`})),r.options.loader){let n=o?await a:a;Ra(e,e.router.getMatch(t),n),n!==void 0&&e.updateMatch(t,e=>({...e,loaderData:n}))}r._lazyPromise&&await r._lazyPromise;let s=Ha(e,t,r),c=s?await s:void 0,l=i._nonReactive.minPendingPromise;l&&await l,r._componentsPromise&&await r._componentsPromise,e.updateMatch(t,e=>({...e,error:void 0,status:`success`,isFetching:!1,updatedAt:Date.now(),...c}))}catch(n){let a=n,o=i._nonReactive.minPendingPromise;o&&await o,Ea(n)&&await r.options.notFoundComponent?.preload?.(),Ra(e,e.router.getMatch(t),n);try{r.options.onError?.(n)}catch(n){a=n,Ra(e,e.router.getMatch(t),n)}let s=Ha(e,t,r),c=s?await s:void 0;e.updateMatch(t,e=>({...e,error:a,status:`error`,isFetching:!1,...c}))}}catch(n){let i=e.router.getMatch(t);if(i){let n=Ha(e,t,r);if(n){let r=await n;e.updateMatch(t,e=>({...e,...r}))}i._nonReactive.loaderPromise=void 0}Ra(e,i,n)}},bne=async(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=!1,a=!1,o=e.router.looseRoutesById[r];if(za(e,n)){if(e.router.isServer){let t=Ha(e,n,o);if(t){let r=await t;e.updateMatch(n,e=>({...e,...r}))}return e.router.getMatch(n)}}else{let r=e.router.getMatch(n);if(r._nonReactive.loaderPromise){if(r.status===`success`&&!e.sync&&!r.preload)return r;await r._nonReactive.loaderPromise;let t=e.router.getMatch(n),i=t._nonReactive.error||t.error;i&&Ra(e,t,i)}else{let s=Date.now()-r.updatedAt,c=Ia(e,n),l=c?o.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:o.options.staleTime??e.router.options.defaultStaleTime??0,u=o.options.shouldReload,d=typeof u==`function`?u(Ua(e,n,t,o)):u,f=!!c&&!e.router.state.matches.some(e=>e.id===n),p=e.router.getMatch(n);p._nonReactive.loaderPromise=na(),f!==p.preload&&e.updateMatch(n,e=>({...e,preload:f}));let{status:m,invalid:h}=p;if(i=m===`success`&&(h||(d??s>l)),!(c&&o.options.preload===!1))if(i&&!e.sync)a=!0,(async()=>{try{await Wa(e,n,t,o);let r=e.router.getMatch(n);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0}catch(t){Pa(t)&&await e.router.navigate(t.options)}})();else if(m!==`success`||i&&e.sync)await Wa(e,n,t,o);else{let t=Ha(e,n,o);if(t){let r=await t;e.updateMatch(n,e=>({...e,...r}))}}}}let s=e.router.getMatch(n);a||(s._nonReactive.loaderPromise?.resolve(),s._nonReactive.loadPromise?.resolve()),clearTimeout(s._nonReactive.pendingTimeout),s._nonReactive.pendingTimeout=void 0,a||(s._nonReactive.loaderPromise=void 0),s._nonReactive.dehydrated=void 0;let c=a?s.isFetching:!1;return c!==s.isFetching||s.invalid!==!1?(e.updateMatch(n,e=>({...e,isFetching:c,invalid:!1})),e.router.getMatch(n)):s};async function Ga(e){let t=Object.assign(e,{matchPromises:[]});!t.router.isServer&&t.router.state.matches.some(e=>e._forcePending)&&Fa(t);try{for(let e=0;e<t.matches.length;e++){let n=yne(t,e);ra(n)&&await n}let e=t.firstBadMatchIndex??t.matches.length;for(let n=0;n<e;n++)t.matchPromises.push(bne(t,n));await Promise.all(t.matchPromises);let n=Fa(t);ra(n)&&await n}catch(e){if(Ea(e)&&!t.preload){let n=Fa(t);throw ra(n)&&await n,e}if(Pa(e))throw e}return t.matches}async function Ka(e){if(!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0),!e._componentsLoaded&&e._componentsPromise===void 0){let t=()=>{let t=[];for(let n of Ya){let r=e.options[n]?.preload;r&&t.push(r())}if(t.length)return Promise.all(t).then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0});e._componentsLoaded=!0,e._componentsPromise=void 0};e._componentsPromise=e._lazyPromise?e._lazyPromise.then(t):t()}return e._componentsPromise}function qa(e,t){return t?{status:`error`,error:t}:{status:`success`,value:e}}function Ja(e){for(let t of Ya)if(e.options[t]?.preload)return!0;return!1}var Ya=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`];function xne(e){return{input:({url:t})=>{for(let n of e)t=Xa(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=Za(e[n],t);return t}}}function Sne(e){let t=xa(e.basepath),n=`/${t}`,r=`${n}/`,i=e.caseSensitive?n:n.toLowerCase(),a=e.caseSensitive?r:r.toLowerCase();return{input:({url:t})=>{let r=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return r===i?t.pathname=`/`:r.startsWith(a)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=_a([`/`,t,e.pathname]),e)}}function Xa(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Za(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Qa(e){let t=e.resolvedLocation,n=e.location;return{fromLocation:t,toLocation:n,pathChanged:t?.pathname!==n.pathname,hrefChanged:t?.href!==n.href,hashChanged:t?.hash!==n.hash}}var Cne=class{constructor(e){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{e.notFoundRoute&&console.warn(`The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.`);let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.pathParamsDecodeCharMap=this.options.pathParamsAllowedCharacters?new Map(this.options.pathParamsAllowedCharacters.map(e=>[encodeURIComponent(e),e])):void 0,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.isServer||(this.history=Lte())),this.origin=this.options.origin,this.origin||(!this.isServer&&window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),!this.__store&&this.latestLocation&&(this.__store=new Ite(Tne(this.latestLocation),{onUpdate:()=>{this.__store.state={...this.state,cachedMatches:this.state.cachedMatches.filter(e=>![`redirected`].includes(e.status))}}}),sne(this));let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[];xa(o)!==``&&e.push(Sne({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:xne(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.__store&&(this.__store.state={...this.state,location:this.latestLocation}),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a)`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let{routesById:e,routesByPath:t,processedTree:n}=Yte(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});this.options.routeMasks&&Wte(this.options.routeMasks,n),this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({href:e,state:n})=>{let r=new URL(e,this.origin),i=Xa(this.rewrite,r),a=this.options.parseSearch(i.search),o=this.options.stringifySearch(a);i.search=o;let s=i.href.replace(i.origin,``),{pathname:c,hash:l}=i;return{href:s,publicHref:e,url:i.href,pathname:aa(c),searchStr:o,search:Xi(t?.search,a),hash:l.split(`#`).reverse()[0]??``,state:Xi(t?.state,n)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathCache=ca(1e3),this.resolvePathWithBase=(e,t)=>tne({base:e,to:va(t),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>Ene({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{let e=this.state.matches.filter(e=>e.status===`pending`),t=this.state.matches.filter(e=>e.isFetching===`loader`);new Set([...this.state.pendingMatches??[],...e,...t]).forEach(e=>{this.cancelMatch(e.id)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=Ji(this.matchRoutes(n,{_buildLocation:!0}));t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=this.resolvePathWithBase(i,`.`),o=r.search,s={...r.params},c=t.to?this.resolvePathWithBase(a,`${t.to}`):this.resolvePathWithBase(a,`.`),l=t.params===!1||t.params===null?{}:(t.params??!0)===!0?s:Object.assign(s,Yi(t.params,s)),u=wa({path:c,params:l}).interpolatedPath,d=this.matchRoutes(u,void 0,{_buildLocation:!0}).map(e=>this.looseRoutesById[e.routeId]);if(Object.keys(l).length>0)for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;t&&Object.assign(l,t(l))}let f=e.leaveParams?c:aa(wa({path:c,params:l,decodeCharMap:this.pathParamsDecodeCharMap}).interpolatedPath),p=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,eo(t.options.validateSearch,{...e,...p}))}catch{}}),p=e}p=Dne({search:p,dest:t,destRoutes:d,_includeValidateSearch:e._includeValidateSearch}),p=Xi(o,p);let m=this.options.stringifySearch(p),h=t.hash===!0?n.hash:t.hash?Yi(t.hash,n.hash):void 0,g=h?`#${h}`:``,_=t.state===!0?n.state:t.state?Yi(t.state,n.state):{};_=Xi(n.state,_);let v=`${f}${m}${g}`,y=new URL(v,this.origin),b=Za(this.rewrite,y);return{publicHref:b.pathname+b.search+b.hash,href:v,url:b.href,pathname:f,search:p,searchStr:m,state:_,hash:h??``,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n={};if(this.options.routeMasks){let o=Gte(i.pathname,this.processedTree);if(o){Object.assign(n,o.params);let{from:i,...s}=o.route;r={from:e.from,...s,params:n},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=ta(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=ba(this.latestLocation.href)===ba(n.href),a=this.commitLocationPromise;if(this.commitLocationPromise=na(()=>{a?.resolve()}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.publicHref,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=Ki(a,{__TSR_index:e?t:t+1});o.to=n.pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,...r})=>{if(!t&&n)try{new URL(`${n}`),t=!0}catch{}if(t){if(n||=this.buildLocation({to:e,...r}).url,!r.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return r.replace?window.location.replace(n):window.location.href=n,Promise.resolve()}return this.buildAndCommitLocation({...r,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{if(this.cancelMatches(),this.updateLatestLocation(),this.isServer){let e=this.buildLocation({to:this.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0}),t=e=>{try{return encodeURI(decodeURI(e))}catch{return e}};if(xa(t(this.latestLocation.href))!==xa(t(e.href))){let t=e.url;throw this.origin&&t.startsWith(this.origin)&&(t=t.replace(this.origin,``)||`/`),hne({href:t})}}let e=this.matchRoutes(this.latestLocation);this.__store.setState(t=>({...t,status:`pending`,statusCode:200,isLoading:!0,location:this.latestLocation,pendingMatches:e,cachedMatches:t.cachedMatches.filter(t=>!e.some(e=>e.id===t.id))}))},this.load=async e=>{let t,n,r;for(r=new Promise(i=>{this.startTransition(async()=>{try{this.beforeLoad();let t=this.latestLocation,n=this.state.resolvedLocation;this.state.redirect||this.emit({type:`onBeforeNavigate`,...Qa({resolvedLocation:n,location:t})}),this.emit({type:`onBeforeLoad`,...Qa({resolvedLocation:n,location:t})}),await Ga({router:this,sync:e?.sync,matches:this.state.pendingMatches,location:t,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=[],t=[],n=[];Bi(()=>{this.__store.setState(r=>{let i=r.matches,a=r.pendingMatches||r.matches;return e=i.filter(e=>!a.some(t=>t.id===e.id)),t=a.filter(e=>!i.some(t=>t.id===e.id)),n=a.filter(e=>i.some(t=>t.id===e.id)),{...r,isLoading:!1,loadedAt:Date.now(),matches:a,pendingMatches:void 0,cachedMatches:[...r.cachedMatches,...e.filter(e=>e.status!==`error`&&e.status!==`notFound`)]}}),this.clearExpiredCache()}),[[e,`onLeave`],[t,`onEnter`],[n,`onStay`]].forEach(([e,t])=>{e.forEach(e=>{this.looseRoutesById[e.routeId].options[t]?.(e)})})})})}})}catch(e){Pa(e)?(t=e,this.isServer||this.navigate({...t.options,replace:!0,ignoreBlocker:!0})):Ea(e)&&(n=e),this.__store.setState(e=>({...e,statusCode:t?t.status:n?404:e.matches.some(e=>e.status===`error`)?500:200,redirect:t}))}this.latestLoadPromise===r&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),i()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;let i;this.hasNotFoundMatch()?i=404:this.__store.state.matches.some(e=>e.status===`error`)&&(i=500),i!==void 0&&this.__store.setState(e=>({...e,statusCode:i}))},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(delete this.shouldViewTransition,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.state.resolvedLocation,a=typeof t.types==`function`?t.types(Qa({resolvedLocation:i,location:r})):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.state.pendingMatches?.some(t=>t.id===e)?`pendingMatches`:this.state.matches.some(t=>t.id===e)?`matches`:this.state.cachedMatches.some(t=>t.id===e)?`cachedMatches`:``;n&&this.__store.setState(r=>({...r,[n]:r[n]?.map(n=>n.id===e?t(n):n)}))})},this.getMatch=e=>{let t=t=>t.id===e;return this.state.cachedMatches.find(t)??this.state.pendingMatches?.find(t)??this.state.matches.find(t)},this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.__store.setState(e=>({...e,matches:e.matches.map(t),cachedMatches:e.cachedMatches.map(t),pendingMatches:e.pendingMatches?.map(t)})),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{if(!e.options.href){let t=this.buildLocation(e.options),n=t.url;this.origin&&n.startsWith(this.origin)&&(n=n.replace(this.origin,``)||`/`),e.options.href=t.href,e.headers.set(`Location`,n)}return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.__store.setState(e=>({...e,cachedMatches:[]})):this.__store.setState(e=>({...e,cachedMatches:e.cachedMatches.filter(e=>!t(e))}))},this.clearExpiredCache=()=>{this.clearCache({filter:e=>{let t=this.looseRoutesById[e.routeId];if(!t.options.loader)return!0;let n=(e.preload?t.options.preloadGcTime??this.options.defaultPreloadGcTime:t.options.gcTime??this.options.defaultGcTime)??300*1e3;return e.status===`error`?!0:Date.now()-e.updatedAt>=n}})},this.loadRouteChunk=Ka,this.preloadRoute=async e=>{let t=this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(e=>e.id)),i=new Set([...r,...this.state.cachedMatches.map(e=>e.id)]);Bi(()=>{n.forEach(e=>{i.has(e.id)||this.__store.setState(t=>({...t,cachedMatches:[...t.cachedMatches,e]}))})});try{return n=await Ga({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Pa(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});Ea(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.state.status!==`pending`)return!1;let i=(t?.pending===void 0?!this.state.isLoading:t.pending)?this.latestLocation:this.state.resolvedLocation||this.state.location,a=Kte(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!ta(a.params,e.params,{partial:!0})?!1:t?.includeSearch??!0?ta(i.search,r.search,{partial:!0})?a.params:!1:a.params},this.hasNotFoundMatch=()=>this.__store.state.matches.some(e=>e.status===`notFound`||e.globalNotFound),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??fne,parseSearch:e.parseSearch??dne}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.__store.state}get looseRoutesById(){return this.routesById}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i}=n,{matchedRoutes:a}=n,o=!1;(r?r.path!==`/`&&i[`**`]:ba(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=(()=>{if(o){if(this.options.notFoundMode!==`root`)for(let e=a.length-1;e>=0;e--){let t=a[e];if(t.children)return t.id}return Na}})(),c=[],l=e=>e?.id?e.context??this.options.context??void 0:this.options.context??void 0;return a.forEach((n,r)=>{let a=c[r-1],[o,u,d]=(()=>{let r=a?.search??e.search,i=a?._strictSearch??void 0;try{let e=eo(n.options.validateSearch,{...r})??void 0;return[{...r,...e},{...i,...e},void 0]}catch(e){let n=e;if(e instanceof $a||(n=new $a(e.message,{cause:e})),t?.throwOnError)throw n;return[r,{},n]}})(),f=n.options.loaderDeps?.({search:o})??``,p=f?JSON.stringify(f):``,{interpolatedPath:m,usedParams:h}=wa({path:n.fullPath,params:i,decodeCharMap:this.pathParamsDecodeCharMap}),g=n.id+m+p,_=this.getMatch(g),v=this.state.matches.find(e=>e.routeId===n.id),y=_?._strictParams??h,b;if(!_){let e=n.options.params?.parse??n.options.parseParams;if(e)try{Object.assign(y,e(y))}catch(e){if(b=Ea(e)||Pa(e)?e:new wne(e.message,{cause:e}),t?.throwOnError)throw b}}Object.assign(i,y);let x=v?`stay`:`enter`,S;if(_)S={..._,cause:x,params:v?Xi(v.params,i):i,_strictParams:y,search:Xi(v?v.search:_.search,o),_strictSearch:u};else{let e=n.options.loader||n.options.beforeLoad||n.lazyFn||Ja(n)?`pending`:`success`;S={id:g,index:r,routeId:n.id,params:v?Xi(v.params,i):i,_strictParams:y,pathname:m,updatedAt:Date.now(),search:v?Xi(v.search,o):o,_strictSearch:u,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:b,__routeContext:void 0,_nonReactive:{loadPromise:na()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:x,loaderDeps:v?Xi(v.loaderDeps,f):f,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:n.options.staticData||{},fullPath:n.fullPath}}t?.preload||(S.globalNotFound=s===n.id),S.searchError=d;let C=l(a);S.context={...C,...S.__routeContext,...S.__beforeLoadContext},c.push(S)}),c.forEach((n,r)=>{let i=this.looseRoutesById[n.routeId];if(!this.getMatch(n.id)&&t?._buildLocation!==!0){let t=c[r-1],a=l(t);if(i.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c};n.__routeContext=i.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}),c}},$a=class extends Error{},wne=class extends Error{};function Tne(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],pendingMatches:[],cachedMatches:[],statusCode:200}}function eo(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new $a(`Async validation not supported`);if(n.issues)throw new $a(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Ene({pathname:e,routesById:t,processedTree:n}){let r={},i=ba(e),a,o=qte(i,n,!0);return o&&(a=o.route,Object.assign(r,o.params)),{matchedRoutes:o?.branch||[t.__root__],routeParams:r,foundRoute:a}}function Dne({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){let i=n.reduce((e,t)=>{let n=[];return`search`in t.options?t.options.search?.middlewares&&n.push(...t.options.search.middlewares):(t.options.preSearchFilters||t.options.postSearchFilters)&&n.push(({search:e,next:n})=>{let r=e;`preSearchFilters`in t.options&&t.options.preSearchFilters&&(r=t.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=n(r);return`postSearchFilters`in t.options&&t.options.postSearchFilters?t.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),r&&t.options.validateSearch&&n.push(({search:e,next:n})=>{let r=n(e);try{return{...r,...eo(t.options.validateSearch,r)??void 0}}catch{return r}}),e.concat(n)},[])??[];i.push(({search:e})=>t.search?t.search===!0?e:Yi(t.search,e):{});let a=(e,t)=>{if(e>=i.length)return t;let n=i[e];return n({search:t,next:t=>a(e+1,t)})};return a(0,e)}var One=`Error preloading route! ☝️`,to=class{constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=Na:this.parentRoute||sa(!1,`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);let r=n?Na:t?.path;r&&r!==`/`&&(r=ya(r));let i=t?.id||r,a=n?Na:_a([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=_a([`/`,a]));let o=a===`__root__`?`/`:_a([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=o},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}},kne=class{constructor({id:e}){this.notFound=e=>Ta({routeId:this.id,...e}),this.id=e}},Ane=class extends to{constructor(e){super(e)}};function no(e){let t=e.errorComponent??ro;return(0,J.jsx)(jne,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?Y.createElement(t,{error:n,reset:r}):e.children})}var jne=class extends Y.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromProps(e){return{resetKey:e.getResetKey()}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidUpdate(e,t){t.error&&t.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.resetKey===this.props.getResetKey()?this.state.error:null,reset:()=>{this.reset()}})}};function ro({error:e}){let[t,n]=Y.useState(!1);return(0,J.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,J.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,J.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,J.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,J.jsx)(`div`,{children:(0,J.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,J.jsx)(`code`,{children:e.message}):null})}):null]})}function Mne({children:e,fallback:t=null}){return Nne()?(0,J.jsx)(Y.Fragment,{children:e}):(0,J.jsx)(Y.Fragment,{children:t})}function Nne(){return Y.useSyncExternalStore(Pne,()=>!0,()=>!1)}function Pne(){return()=>{}}var Fne=!0;function io(e,t){if(!Fne){if(e)return;var n=`Warning: `+t;typeof console<`u`&&console.warn(n);try{throw Error(n)}catch{}}}var Ine=see();function Lne(e,t=e=>e,n={}){let r=n.equal??Rne;return(0,Ine.useSyncExternalStoreWithSelector)(e.subscribe,()=>e.state,()=>e.state,t,r)}function Rne(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=ao(e);if(n.length!==ao(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function ao(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var oo=Y.createContext(null);function so(){return typeof document>`u`?oo:window.__TSR_ROUTER_CONTEXT__?window.__TSR_ROUTER_CONTEXT__:(window.__TSR_ROUTER_CONTEXT__=oo,oo)}function co(e){let t=Y.useContext(so());return io(!((e?.warn??!0)&&!t),`useRouter must be used inside a <RouterProvider> component!`),t}function lo(e){let t=co({warn:e?.router===void 0}),n=e?.router||t,r=(0,Y.useRef)(void 0);return Lne(n.__store,t=>{if(e?.select){if(e.structuralSharing??n.options.defaultStructuralSharing){let n=Xi(r.current,e.select(t));return r.current=n,n}return e.select(t)}return t})}var uo=Y.createContext(void 0),zne=Y.createContext(void 0);function fo(e){let t=Y.useContext(e.from?zne:uo);return lo({select:n=>{let r=n.matches.find(n=>e.from?e.from===n.routeId:n.id===t);if(sa(!((e.shouldThrow??!0)&&!r),`Could not find ${e.from?`an active match from "${e.from}"`:`a nearest match!`}`),r!==void 0)return e.select?e.select(r):r},structuralSharing:e.structuralSharing})}function po(e){return fo({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function mo(e){let{select:t,...n}=e;return fo({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function ho(e){return fo({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function go(e){return fo({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}var _o=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function vo(e){let t=Y.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function Bne(e,t,n={},r={}){Y.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function Vne(e){let t=Y.useRef(null);return Y.useImperativeHandle(e,()=>t.current,[]),t}function yo(e){let t=co();return Y.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Hne(e,t){let n=co(),[r,i]=Y.useState(!1),a=Y.useRef(!1),o=Vne(t),{activeProps:s,inactiveProps:c,activeOptions:l,to:u,preload:d,preloadDelay:f,hashScrollIntoView:p,replace:m,startTransition:h,resetScroll:g,viewTransition:_,children:v,target:y,disabled:b,style:x,className:S,onClick:C,onFocus:w,onMouseEnter:T,onMouseLeave:E,onTouchStart:D,ignoreBlocker:O,params:k,search:A,hash:j,state:M,mask:N,reloadDocument:P,unsafeRelative:F,from:I,_fromLocation:L,...R}=e,z=lo({select:e=>e.location.search,structuralSharing:!0}),B=e.from,V=Y.useMemo(()=>({...e,from:B}),[n,z,B,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),ee=Y.useMemo(()=>n.buildLocation({...V}),[n,V]),te=Y.useMemo(()=>{if(b)return;let e=ee.maskedLocation?ee.maskedLocation.url:ee.url,t=!1;return n.origin&&(e.startsWith(n.origin)?e=n.history.createHref(e.replace(n.origin,``))||`/`:t=!0),{href:e,external:t}},[b,ee.maskedLocation,ee.url,n.origin,n.history]),ne=Y.useMemo(()=>{if(te?.external)return te.href;try{return new URL(u),u}catch{}},[u,te]),re=e.reloadDocument||ne?!1:d??n.options.defaultPreload,ie=f??n.options.defaultPreloadDelay??0,ae=lo({select:e=>{if(ne)return!1;if(l?.exact){if(!ene(e.location.pathname,ee.pathname,n.basepath))return!1}else{let t=Sa(e.location.pathname,n.basepath),r=Sa(ee.pathname,n.basepath);if(!(t.startsWith(r)&&(t.length===r.length||t[r.length]===`/`)))return!1}return(l?.includeSearch??!0)&&!ta(e.location.search,ee.search,{partial:!l?.exact,ignoreUndefined:!l?.explicitUndefined})?!1:l?.includeHash?e.location.hash===ee.hash:!0}}),oe=Y.useCallback(()=>{n.preloadRoute({...V}).catch(e=>{console.warn(e),console.warn(One)})},[n,V]);Bne(o,Y.useCallback(e=>{e?.isIntersecting&&oe()},[oe]),qne,{disabled:!!b||re!==`viewport`}),Y.useEffect(()=>{a.current||!b&&re===`render`&&(oe(),a.current=!0)},[b,oe,re]);let se=e=>{let t=e.currentTarget.getAttribute(`target`),r=y===void 0?t:y;if(!b&&!Jne(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Kr.flushSync)(()=>{i(!0)});let t=n.subscribe(`onResolved`,()=>{t(),i(!1)});n.navigate({...V,replace:m,resetScroll:g,hashScrollIntoView:p,startTransition:h,viewTransition:_,ignoreBlocker:O})}};if(ne)return{...R,ref:o,href:ne,...v&&{children:v},...y&&{target:y},...b&&{disabled:b},...x&&{style:x},...S&&{className:S},...C&&{onClick:C},...w&&{onFocus:w},...T&&{onMouseEnter:T},...E&&{onMouseLeave:E},...D&&{onTouchStart:D}};let ce=e=>{b||re&&oe()},le=ce,ue=e=>{if(!(b||!re))if(!ie)oe();else{let t=e.target;if(xo.has(t))return;let n=setTimeout(()=>{xo.delete(t),oe()},ie);xo.set(t,n)}},de=e=>{if(b||!re||!ie)return;let t=e.target,n=xo.get(t);n&&(clearTimeout(n),xo.delete(t))},fe=ae?Yi(s,{})??Une:bo,pe=ae?bo:Yi(c,{})??bo,me=[S,fe.className,pe.className].filter(Boolean).join(` `),he=(x||fe.style||pe.style)&&{...x,...fe.style,...pe.style};return{...R,...fe,...pe,href:te?.href,ref:o,onClick:So([C,se]),onFocus:So([w,ce]),onMouseEnter:So([T,ue]),onMouseLeave:So([E,de]),onTouchStart:So([D,le]),disabled:!!b,target:y,...he&&{style:he},...me&&{className:me},...b&&Wne,...ae&&Gne,...r&&Kne}}var bo={},Une={className:`active`},Wne={role:`link`,"aria-disabled":!0},Gne={"data-status":`active`,"aria-current":`page`},Kne={"data-transitioning":`transitioning`},xo=new WeakMap,qne={rootMargin:`100px`},So=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}},Co=Y.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,ref:a,...o}=Hne(r,t),s=typeof r.children==`function`?r.children({isActive:o[`data-status`]===`active`}):r.children;return n===void 0&&delete o.disabled,Y.createElement(n||`a`,{...o,ref:a},s)});function Jne(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Yne(e){return new Xne({id:e})}var Xne=class extends kne{constructor({id:e}){super({id:e}),this.useMatch=e=>fo({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>mo({...e,from:this.id,strict:!1}),this.useLoaderData=e=>po({...e,from:this.id,strict:!1}),this.useNavigate=()=>yo({from:co().routesById[this.id].fullPath}),this.notFound=e=>Ta({routeId:this.id,...e}),this.Link=Y.forwardRef((e,t)=>{let n=co().routesById[this.id].fullPath;return(0,J.jsx)(Co,{ref:t,from:n,...e})})}},Zne=class extends to{constructor(e){super(e),this.useMatch=e=>fo({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>mo({...e,from:this.id}),this.useLoaderData=e=>po({...e,from:this.id}),this.useNavigate=()=>yo({from:this.fullPath}),this.Link=Y.forwardRef((e,t)=>(0,J.jsx)(Co,{ref:t,from:this.fullPath,...e})),this.$$typeof=Symbol.for(`react.memo`)}};function wo(e){return new Zne(e)}var Qne=class extends Ane{constructor(e){super(e),this.useMatch=e=>fo({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>mo({...e,from:this.id}),this.useLoaderData=e=>po({...e,from:this.id}),this.useNavigate=()=>yo({from:this.fullPath}),this.Link=Y.forwardRef((e,t)=>(0,J.jsx)(Co,{ref:t,from:this.fullPath,...e})),this.$$typeof=Symbol.for(`react.memo`)}};function To(e){return new Qne(e)}function Eo(e){return typeof e==`object`?new Do(e,{silent:!0}).createRoute(e):new Do(e,{silent:!0}).createRoute}var Do=class{constructor(e,t){this.path=e,this.createRoute=e=>{io(this.silent,`FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.`);let t=wo(e);return t.isRoot=!1,t},this.silent=t?.silent}},Oo=class{constructor(e){this.useMatch=e=>fo({select:e?.select,from:this.options.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({from:this.options.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.options.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.options.id}),this.useLoaderDeps=e=>mo({...e,from:this.options.id}),this.useLoaderData=e=>po({...e,from:this.options.id}),this.useNavigate=()=>yo({from:co().routesById[this.options.id].fullPath}),this.options=e,this.$$typeof=Symbol.for(`react.memo`)}};function ko(e){return typeof e==`object`?new Oo(e):t=>new Oo({id:e,...t})}function $ne(){let e=co(),t=Y.useRef({router:e,mounted:!1}),[n,r]=Y.useState(!1),{hasPendingMatches:i,isLoading:a}=lo({select:e=>({isLoading:e.isLoading,hasPendingMatches:e.matches.some(e=>e.status===`pending`)}),structuralSharing:!0}),o=vo(a),s=a||n||i,c=vo(s),l=a||i,u=vo(l);return e.startTransition=e=>{r(!0),Y.startTransition(()=>{e(),r(!1)})},Y.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return ba(e.latestLocation.href)!==ba(n.href)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),_o(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),_o(()=>{o&&!a&&e.emit({type:`onLoad`,...Qa(e.state)})},[o,e,a]),_o(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...Qa(e.state)})},[l,u,e]),_o(()=>{if(c&&!s){let t=Qa(e.state);e.emit({type:`onResolved`,...t}),e.__store.setState(e=>({...e,status:`idle`,resolvedLocation:e.location})),t.hrefChanged&&cne(e)}},[s,c,e]),null}function ere(e){let t=lo({select:e=>`not-found-${e.location.pathname}-${e.status}`});return(0,J.jsx)(no,{getResetKey:()=>t,onCatch:(t,n)=>{if(Ea(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(Ea(t))return e.fallback?.(t);throw t},children:e.children})}function tre(){return(0,J.jsx)(`p`,{children:`Not Found`})}function Ao(e){return(0,J.jsx)(J.Fragment,{children:e.children})}function jo(e,t,n){return t.options.notFoundComponent?(0,J.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,J.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,J.jsx)(tre,{})}function nre({children:e}){let t=co();return t.isServer?(0,J.jsx)(`script`,{nonce:t.options.ssr?.nonce,className:`$tsr`,dangerouslySetInnerHTML:{__html:e+`;typeof $_TSR !== "undefined" && $_TSR.c()`}}):null}function rre(){let e=co();if(!e.isScrollRestoring||!e.isServer||typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return null;let t=(e.options.getScrollRestorationKey||ka)(e.latestLocation),n=t===ka(e.latestLocation)?void 0:t,r={storageKey:Da,shouldScrollRestoration:!0};return n&&(r.key=n),(0,J.jsx)(nre,{children:`(${ja.toString()})(${JSON.stringify(r)})`})}var Mo=Y.memo(function({matchId:e}){let t=co(),n=lo({select:t=>{let n=t.matches.find(t=>t.id===e);return sa(n,`Could not find match for matchId "${e}". Please file an issue!`),{routeId:n.routeId,ssr:n.ssr,_displayPending:n._displayPending}},structuralSharing:!0}),r=t.routesById[n.routeId],i=r.options.pendingComponent??t.options.defaultPendingComponent,a=i?(0,J.jsx)(i,{}):null,o=r.options.errorComponent??t.options.defaultErrorComponent,s=r.options.onCatch??t.options.defaultOnCatch,c=r.isRoot?r.options.notFoundComponent??t.options.notFoundRoute?.options.component:r.options.notFoundComponent,l=n.ssr===!1||n.ssr===`data-only`,u=(!r.isRoot||r.options.wrapInSuspense||l)&&(r.options.wrapInSuspense??i??(r.options.errorComponent?.preload||l))?Y.Suspense:Ao,d=o?no:Ao,f=c?ere:Ao,p=lo({select:e=>e.loadedAt}),m=lo({select:t=>{let n=t.matches.findIndex(t=>t.id===e);return t.matches[n-1]?.routeId}});return(0,J.jsxs)(r.isRoot?r.options.shellComponent??Ao:Ao,{children:[(0,J.jsx)(uo.Provider,{value:e,children:(0,J.jsx)(u,{fallback:a,children:(0,J.jsx)(d,{getResetKey:()=>p,errorComponent:o||ro,onCatch:(t,n)=>{if(Ea(t))throw t;io(!1,`Error in route match: ${e}`),s?.(t,n)},children:(0,J.jsx)(f,{fallback:e=>{if(!c||e.routeId&&e.routeId!==n.routeId||!e.routeId&&!r.isRoot)throw e;return Y.createElement(c,e)},children:l||n._displayPending?(0,J.jsx)(Mne,{fallback:a,children:(0,J.jsx)(No,{matchId:e})}):(0,J.jsx)(No,{matchId:e})})})})}),m===`__root__`&&t.options.scrollRestoration?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ire,{}),(0,J.jsx)(rre,{})]}):null]})});function ire(){let e=co(),t=Y.useRef(void 0);return(0,J.jsx)(`script`,{suppressHydrationWarning:!0,ref:n=>{n&&(t.current===void 0||t.current.href!==e.latestLocation.href)&&(e.emit({type:`onRendered`,...Qa(e.state)}),t.current=e.latestLocation)}},e.latestLocation.state.__TSR_key)}var No=Y.memo(function({matchId:e}){let t=co(),{match:n,key:r,routeId:i}=lo({select:n=>{let r=n.matches.find(t=>t.id===e),i=r.routeId,a=(t.routesById[i].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:i,loaderDeps:r.loaderDeps,params:r._strictParams,search:r._strictSearch});return{key:a?JSON.stringify(a):void 0,routeId:i,match:{id:r.id,status:r.status,error:r.error,_forcePending:r._forcePending,_displayPending:r._displayPending}}},structuralSharing:!0}),a=t.routesById[i],o=Y.useMemo(()=>{let e=a.options.component??t.options.defaultComponent;return e?(0,J.jsx)(e,{},r):(0,J.jsx)(Po,{})},[r,a.options.component,t.options.defaultComponent]);if(n._displayPending)throw t.getMatch(n.id)?._nonReactive.displayPendingPromise;if(n._forcePending)throw t.getMatch(n.id)?._nonReactive.minPendingPromise;if(n.status===`pending`){let e=a.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let r=t.getMatch(n.id);if(r&&!r._nonReactive.minPendingPromise&&!t.isServer){let t=na();r._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),r._nonReactive.minPendingPromise=void 0},e)}}throw t.getMatch(n.id)?._nonReactive.loadPromise}if(n.status===`notFound`)return sa(Ea(n.error),`Expected a notFound error`),jo(t,a,n.error);if(n.status===`redirected`)throw sa(Pa(n.error),`Expected a redirect error`),t.getMatch(n.id)?._nonReactive.loadPromise;if(n.status===`error`){if(t.isServer)return(0,J.jsx)((a.options.errorComponent??t.options.defaultErrorComponent)||ro,{error:n.error,reset:void 0,info:{componentStack:``}});throw n.error}return o}),Po=Y.memo(function(){let e=co(),t=Y.useContext(uo),n=lo({select:e=>e.matches.find(e=>e.id===t)?.routeId}),r=e.routesById[n],i=lo({select:e=>{let n=e.matches.find(e=>e.id===t);return sa(n,`Could not find parent match for matchId "${t}"`),n.globalNotFound}}),a=lo({select:e=>{let n=e.matches;return n[n.findIndex(e=>e.id===t)+1]?.id}}),o=e.options.defaultPendingComponent?(0,J.jsx)(e.options.defaultPendingComponent,{}):null;if(i)return jo(e,r,void 0);if(!a)return null;let s=(0,J.jsx)(Mo,{matchId:a});return n===`__root__`?(0,J.jsx)(Y.Suspense,{fallback:o,children:s}):s});function are(){let e=co(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,J.jsx)(t,{}):null,r=(0,J.jsxs)(e.isServer||typeof document<`u`&&e.ssr?Ao:Y.Suspense,{fallback:n,children:[!e.isServer&&(0,J.jsx)($ne,{}),(0,J.jsx)(ore,{})]});return e.options.InnerWrap?(0,J.jsx)(e.options.InnerWrap,{children:r}):r}function ore(){let e=co(),t=lo({select:e=>e.matches[0]?.id}),n=lo({select:e=>e.loadedAt}),r=t?(0,J.jsx)(Mo,{matchId:t}):null;return(0,J.jsx)(uo.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,J.jsx)(no,{getResetKey:()=>n,errorComponent:ro,onCatch:e=>{io(!1,`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`),io(!1,e.message||e.toString())},children:r})})}var Fo=e=>new sre(e),sre=class extends Cne{constructor(e){super(e)}};typeof globalThis<`u`?(globalThis.createFileRoute=Eo,globalThis.createLazyFileRoute=ko):typeof window<`u`&&(window.createFileRoute=Eo,window.createLazyFileRoute=ko);function cre({router:e,children:t,...n}){Object.keys(n).length>0&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,J.jsx)(so().Provider,{value:e,children:t});return e.options.Wrap?(0,J.jsx)(e.options.Wrap,{children:r}):r}function Io({router:e,...t}){return(0,J.jsx)(cre,{router:e,...t,children:(0,J.jsx)(are,{})})}function Lo(e){return lo({select:t=>e?.select?e.select(t.location):t.location})}function lre(e){let t=new MutationObserver(t=>{for(let n of t)n.attributeName===`class`&&e()});return t.observe(document.documentElement,{attributes:!0}),()=>t.disconnect()}function ure(){return document.documentElement.classList.contains(`dark`)}function dre(){return!1}function Ro(){return(0,Y.useSyncExternalStore)(lre,ure,dre)}var zo=[`/dashboard`,`/config`,`/git`,`/specs`,`/changes`,`/board`,`/archive`,`/settings`,`/terminal`],fre=[`/dashboard`,`/config`,`/specs`,`/changes`,`/board`,`/archive`,`/settings`],Bo=B()?[]:[`/git`,`/terminal`],pre=[`/search`,`/notifications`,`/opsx-new`,`/opsx-propose`,`/opsx-verify`,`/opsx-compose`];function Vo(){return z(`nav-layout`,window.location)}function mre(e){return z(`nav-layout:${encodeURIComponent(e)}`,window.location)}var hre=300;function gre(e){return zo.includes(e)}function _re(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&gre(e)):[]}function Ho(e){if(typeof e!=`object`||!e)return null;let t=e;return!Array.isArray(t.mainTabs)||!Array.isArray(t.bottomTabs)?null:{mainTabs:_re(t.mainTabs),bottomTabs:_re(t.bottomTabs),updatedAt:typeof t.updatedAt==`number`?t.updatedAt:0}}function vre(e,t){if(typeof e!=`object`||!e)return{__TSR_index:0,key:t,__TSR_key:t};let n=e,r=typeof n.key==`string`?n.key:t,i=typeof n.__TSR_key==`string`?n.__TSR_key:r,a=typeof n.__TSR_index==`number`?n.__TSR_index:0;return{...n,key:r,__TSR_key:i,__TSR_index:a}}function Uo(e,t){let n=new URL(e,`http://nav.local`),r=`${n.pathname}${n.search}${n.hash}`,i=Math.random().toString(36).slice(2);return{href:r,pathname:n.pathname||`/`,search:n.search,hash:n.hash,state:vre(t,i)}}function Wo(e){let t=e.trim();if(!t||t===`./`||t===`.`)return`/`;let n=t.startsWith(`/`)?t:`/${t}`;return(n.endsWith(`/`)?n:`${n}/`).replace(/\/+/g,`/`)}function Go(e,t){return t===`/`?e||`/`:e===t.slice(0,-1)?`/`:e.startsWith(t)?e.slice(t.length-1)||`/`:e||`/`}function yre(e,t){if(t===`/`)return e||`/`;let n=e.startsWith(`/`)?e:`/${e}`;return n===`/`?t.slice(0,-1)||`/`:`${t.slice(0,-1)}${n}`}function Ko(e){if(typeof window>`u`)return e;let t=new URL(e,window.location.origin),n=Wo(ee());return t.pathname=Go(t.pathname,n),`${t.pathname}${t.search}${t.hash}`}function bre(e,t){for(let n of[`api`,`session`]){let r=t.searchParams.get(n);r&&!e.searchParams.has(n)&&e.searchParams.set(n,r)}}function qo(e){for(let t of zo)if(e===t||e.startsWith(t+`/`))return t;return null}function Jo(e,t){if(t===`pop`)return null;let n=t===`main`?e.mainLocation:e.bottomLocation,r=t===`main`?e.mainTabs:e.bottomTabs,i=qo(n.pathname);return i&&r.includes(i)?i:null}function Yo(e){return pre.some(t=>e===t||e.startsWith(t+`/`))}function Xo(e,t){if(Yo(t))return`pop`;let n=qo(t);return n&&e.bottomTabs.includes(n)?`bottom`:`main`}function Zo(e){let t=new Set,n=[],r=[];for(let r of e.mainTabs)t.has(r)||(n.push(r),t.add(r));for(let n of e.bottomTabs)t.has(n)||(r.push(n),t.add(n));for(let e of zo)t.has(e)||(Bo.includes(e)?r.push(e):n.push(e));return{mainTabs:n,bottomTabs:r}}function Qo(e,t){if(t.length===0)return Uo(`/`);let n=qo(e.pathname);return n&&!t.includes(n)?Uo(`/`):e}function $o(e,t){if(t.length===0)return Uo(`/`);if(e.pathname===`/`)return Uo(`/`,e.state);let n=qo(e.pathname);return!n||!t.includes(n)?Uo(`/`):e}function es(e){return e.pathname===`/`?Uo(`/`,e.state):Yo(e.pathname)?e:Uo(`/`)}function ts(e){let t=Zo({mainTabs:e.mainTabs,bottomTabs:e.bottomTabs});return{...e,mainTabs:t.mainTabs,bottomTabs:t.bottomTabs,mainLocation:Qo(e.mainLocation,t.mainTabs),bottomLocation:$o(e.bottomLocation,t.bottomTabs),popLocation:es(e.popLocation)}}function ns(e,t){let n=new URL(e.href),r=Wo(ee());n.pathname=Go(n.pathname,r);let i=n.searchParams.get(`_b`),a=n.searchParams.get(`_p`);n.searchParams.delete(`_b`),n.searchParams.delete(`_p`);let o=window.history.state,s=Uo(`${n.pathname}${n.search}${n.hash}`,o?.main),c=Uo(i??`/`,o?.bottom),l=Uo(a??`/`,o?.pop);if(!i&&!a){let e=Xo(t,s.pathname);e===`bottom`?(c=s,s=Uo(`/`,o?.main)):e===`pop`&&(l=s,s=Uo(`/`,o?.main))}return{main:Qo(s,t.mainTabs),bottom:$o(c,t.bottomTabs),pop:es(l)}}function rs(e){let t=new URL(window.location.href),n=new URL(e.mainLocation.href,window.location.origin),r=Wo(ee());return n.pathname=yre(n.pathname,r),bre(n,t),n.searchParams.delete(`_b`),n.searchParams.delete(`_p`),e.bottomTabs.length>0&&n.searchParams.set(`_b`,e.bottomLocation.href),e.popLocation.pathname!==`/`&&n.searchParams.set(`_p`,e.popLocation.href),`${n.pathname}${n.search}${n.hash}`}function is(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function xre(){return{mainTabs:[...fre],bottomTabs:[...Bo],updatedAt:0,mainLocation:Uo(`/dashboard`),bottomLocation:Uo(`/`),popLocation:Uo(`/`)}}function Sre(){try{let e=localStorage.getItem(Vo());return e?Ho(JSON.parse(e)):null}catch{return null}}function Cre(e){try{let t=localStorage.getItem(e);return t?Ho(JSON.parse(t)):null}catch{return null}}function as(e,t=Vo()){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}var wre=[({prevState:e,nextState:t,event:n})=>{if(n.type!==`MOVE_TAB`)return t;let r=e.bottomTabs.includes(n.tabId)?`bottom`:`main`;if(Jo(e,r)!==n.tabId)return t;let i=r===`main`?e.mainLocation:e.bottomLocation,a=Uo(i.href,i.state);return n.targetArea===`main`?{...t,mainLocation:a}:{...t,bottomLocation:a}},({nextState:e})=>e.mainTabs.length===0||Jo(e,`main`)!=null?e:{...e,mainLocation:Uo(e.mainTabs[0])}];function os(e,t,n){let r=t;for(let t of wre)r=t({prevState:e,nextState:r,event:n});return r}function ss(e,t){switch(t.type){case`NAVIGATE`:{let n=t.sourceArea===`pop`?`pop`:Xo(e,t.location.pathname);return{nextState:n===`main`?{...e,mainLocation:t.location}:n===`bottom`?{...e,bottomLocation:t.location}:{...e,popLocation:t.location},changed:!0,urlAction:t.action,notify:n===t.sourceArea?[]:[{area:n,type:t.action}],persist:`none`}}case`POPSTATE`:return{nextState:{...e,mainLocation:t.mainLocation,bottomLocation:t.bottomLocation,popLocation:t.popLocation},changed:!0,notify:[{area:`main`,type:`BACK`},{area:`bottom`,type:`BACK`},{area:`pop`,type:`BACK`}],persist:`none`};case`MOVE_TAB`:{let n=e.bottomTabs.includes(t.tabId)?`bottom`:`main`;if(n===t.targetArea)return{nextState:e,changed:!1,notify:[],persist:`none`};let r=e.mainTabs.filter(e=>e!==t.tabId),i=e.bottomTabs.filter(e=>e!==t.tabId),a=t.targetArea===`main`?[...r,t.tabId]:r,o=t.targetArea===`bottom`?[...i,t.tabId]:i,s=e.mainLocation,c=e.bottomLocation;return qo((n===`main`?e.mainLocation:e.bottomLocation).pathname)===t.tabId&&(n===`main`?s=Uo(`/`):c=Uo(`/`)),{nextState:{...e,mainTabs:a,bottomTabs:o,mainLocation:s,bottomLocation:c},changed:!0,urlAction:`REPLACE`,notify:[{area:`main`,type:`REPLACE`},{area:`bottom`,type:`REPLACE`}],persist:`local_and_remote`}}case`REORDER`:{let n=t.area===`main`?e.mainTabs:e.bottomTabs,r=new Set(n),i=t.tabIds.filter(e=>r.has(e));for(let e of n)i.includes(e)||i.push(e);return is(n,i)?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:t.area===`main`?{...e,mainTabs:i}:{...e,bottomTabs:i},changed:!0,notify:[],persist:`local_and_remote`}}case`CLOSE_TAB`:{let n=e.bottomTabs.includes(t.tabId),r=e.mainTabs.includes(t.tabId);return!n&&!r?{nextState:e,changed:!1,notify:[],persist:`none`}:n?qo(e.bottomLocation.pathname)===t.tabId?{nextState:{...e,bottomLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`}:qo(e.mainLocation.pathname)===t.tabId?{nextState:{...e,mainLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`}}case`ACTIVATE_BOTTOM`:return Xo(e,t.location.pathname)===`bottom`?{nextState:{...e,bottomLocation:t.location},changed:!0,urlAction:`PUSH`,notify:[{area:`bottom`,type:`PUSH`}],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`};case`DEACTIVATE_BOTTOM`:return e.bottomLocation.pathname===`/`?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:{...e,bottomLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`};case`ACTIVATE_POP`:return Xo(e,t.location.pathname)===`pop`?{nextState:{...e,popLocation:t.location},changed:!0,urlAction:`PUSH`,notify:[{area:`pop`,type:`PUSH`}],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`};case`DEACTIVATE_POP`:return e.popLocation.pathname===`/`?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:{...e,popLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`};case`APPLY_LAYOUT`:{let n=Zo(t.layout);return!(t.layout.updatedAt!==e.updatedAt||!is(e.mainTabs,n.mainTabs)||!is(e.bottomTabs,n.bottomTabs))||!t.force&&t.layout.updatedAt<=e.updatedAt?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:{...e,mainTabs:n.mainTabs,bottomTabs:n.bottomTabs,updatedAt:t.layout.updatedAt},changed:!0,urlAction:`REPLACE`,notify:[{area:`main`,type:`REPLACE`},{area:`bottom`,type:`REPLACE`}],persist:`local_only`}}}}function cs(e,t,n){return n===`main`?e.mainLocation.href!==t.mainLocation.href:n===`bottom`?e.bottomLocation.href!==t.bottomLocation.href:e.popLocation.href!==t.popLocation.href}function Tre(e,t,n){let r=[...e];for(let e of[`main`,`bottom`,`pop`])cs(t,n,e)&&(r.some(t=>t.area===e)||r.push({area:e,type:`REPLACE`}));return r}var ls=new class{mainHistory=null;bottomHistory=null;popHistory=null;state=xre();listeners=new Set;snapshotCache=null;persistTimer=null;kvUnsubscribe=null;initialized=!1;storageKey=typeof window>`u`?`nav-layout`:z(`nav-layout`,window.location);constructor(){if(typeof window>`u`)return;let e=B()?null:Sre();if(e!=null){let t=Zo(e);this.state={...this.state,mainTabs:t.mainTabs,bottomTabs:t.bottomTabs,updatedAt:e.updatedAt}}let t=ns(window.location,this.state),n=ts({...this.state,mainLocation:t.main,bottomLocation:t.bottom,popLocation:t.pop});n=ts(os(n,n,{type:`BOOTSTRAP`})),this.state=n,this.normalizeUrl(),window.addEventListener(`popstate`,this.handlePopState)}setHistoryRef(e,t){e===`main`?this.mainHistory=t:e===`bottom`?this.bottomHistory=t:this.popHistory=t}getLocation(e){return e===`main`?this.state.mainLocation:e===`bottom`?this.state.bottomLocation:this.state.popLocation}push(e,t,n){this.dispatch({type:`NAVIGATE`,sourceArea:e,action:`PUSH`,location:Uo(Ko(t),n)})}replace(e,t,n){this.dispatch({type:`NAVIGATE`,sourceArea:e,action:`REPLACE`,location:Uo(Ko(t),n)})}createHref(e,t,n){if(typeof window>`u`)return t;let{nextState:r}=this.computeTransition({type:`NAVIGATE`,sourceArea:e,action:`PUSH`,location:Uo(Ko(t),n)});return rs(r)}get mainTabs(){return this.state.mainTabs}get bottomTabs(){return this.state.bottomTabs}getAreaForPath(e){return Xo(this.state,e)}moveTab(e,t){this.dispatch({type:`MOVE_TAB`,tabId:e,targetArea:t})}reorder(e,t){this.dispatch({type:`REORDER`,area:e,tabIds:t})}closeTab(e){this.dispatch({type:`CLOSE_TAB`,tabId:e})}activateBottom(e){this.dispatch({type:`ACTIVATE_BOTTOM`,location:Uo(e)})}deactivateBottom(){this.dispatch({type:`DEACTIVATE_BOTTOM`})}activatePop(e){this.dispatch({type:`ACTIVATE_POP`,location:Uo(e)})}deactivatePop(){this.dispatch({type:`DEACTIVATE_POP`})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getSnapshot(){if(this.snapshotCache)return this.snapshotCache;let e=qo(this.state.bottomLocation.pathname);return this.snapshotCache={mainTabs:[...this.state.mainTabs],bottomTabs:[...this.state.bottomTabs],mainLocation:this.state.mainLocation,bottomLocation:this.state.bottomLocation,popLocation:this.state.popLocation,bottomActive:e!=null&&this.state.bottomTabs.includes(e),popActive:this.state.popLocation.pathname!==`/`},this.snapshotCache}async init(){if(!(this.initialized||B())){this.initialized=!0;try{let e=await this.resolveProjectScopedStorageKey();e&&e!==this.storageKey&&(this.storageKey=e,this.rebindProjectScopedLayout(e));let{trpcClient:t}=await c(async()=>{let{trpcClient:e}=await import(`./trpc--JMUaLps.js`);return{trpcClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])),n=Ho(await t.kv.get.query({key:this.storageKey}));n?n.updatedAt>this.state.updatedAt?this.dispatch({type:`APPLY_LAYOUT`,layout:n}):this.state.updatedAt>n.updatedAt&&t.kv.set.mutate({key:this.storageKey,value:{mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:this.state.updatedAt}}).catch(()=>{}):this.state.updatedAt>0&&t.kv.set.mutate({key:this.storageKey,value:{mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:this.state.updatedAt}}).catch(()=>{});let r=t.kv.subscribe.subscribe({key:this.storageKey},{onData:e=>{let t=Ho(e);t&&this.dispatch({type:`APPLY_LAYOUT`,layout:t})}});this.kvUnsubscribe=()=>r.unsubscribe()}catch{}}}destroy(){typeof window<`u`&&window.removeEventListener(`popstate`,this.handlePopState),this.cancelPersistTimer(),this.kvUnsubscribe&&=(this.kvUnsubscribe(),null)}handlePopState=()=>{let e=ns(window.location,this.state);this.dispatch({type:`POPSTATE`,mainLocation:e.main,bottomLocation:e.bottom,popLocation:e.pop})};computeTransition(e){let t=ss(this.state,e);if(!t.changed)return{transition:t,nextState:this.state};let n=os(this.state,t.nextState,e);return n=ts(n),{transition:t,nextState:n}}dispatch(e){if(typeof window<`u`&&e.type!==`POPSTATE`&&this.mainHistory==null){let e=ns(window.location,this.state);this.state=ts({...this.state,mainLocation:e.main,bottomLocation:e.bottom,popLocation:e.pop})}let t=ss(this.state,e);if(!t.changed)return;let n=this.state,r=os(n,t.nextState,e);r=ts(r),this.state=r,t.persist===`local_and_remote`?this.persistLayout():t.persist===`local_only`&&(this.cancelPersistTimer(),as({mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:this.state.updatedAt},this.storageKey));let i=t.urlAction??(cs(n,this.state,`main`)||cs(n,this.state,`bottom`)||cs(n,this.state,`pop`)?`REPLACE`:void 0);i&&this.syncToUrl(i);let a=Tre(t.notify,n,this.state);this.notifyRouters(a),this.notifyListeners()}notifyRouters(e){for(let t of e)(t.area===`main`?this.mainHistory:t.area===`bottom`?this.bottomHistory:this.popHistory)?.notify({type:t.type})}notifyListeners(){this.snapshotCache=null;for(let e of this.listeners)e()}syncToUrl(e){let t=rs(this.state),n=`${window.location.pathname}${window.location.search}${window.location.hash}`;if(e===`REPLACE`&&t===n)return;let r={main:this.state.mainLocation.state,bottom:this.state.bottomLocation.state,pop:this.state.popLocation.state};e===`PUSH`?window.history.pushState(r,``,t):window.history.replaceState(r,``,t)}normalizeUrl(){let e=rs(this.state);if(e===`${window.location.pathname}${window.location.search}${window.location.hash}`)return;let t={main:this.state.mainLocation.state,bottom:this.state.bottomLocation.state,pop:this.state.popLocation.state};window.history.replaceState(t,``,e)}cancelPersistTimer(){this.persistTimer&&=(clearTimeout(this.persistTimer),null)}persistLayout(){let e=Date.now();this.state={...this.state,updatedAt:e},as({mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:e},this.storageKey),this.cancelPersistTimer(),this.persistTimer=setTimeout(()=>{this.persistTimer=null,c(async()=>{let{trpcClient:e}=await import(`./trpc--JMUaLps.js`);return{trpcClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({trpcClient:t})=>t.kv.set.mutate({key:this.storageKey,value:{mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:e}})).catch(()=>{})},hre)}async resolveProjectScopedStorageKey(){try{let e=await M(O());if(!e.ok)return null;let t=await e.json();return typeof t.projectDir!=`string`||t.projectDir.length===0?null:mre(t.projectDir)}catch{return null}}rebindProjectScopedLayout(e){let t=Cre(e);if(t){this.dispatch({type:`APPLY_LAYOUT`,layout:t,force:!0});return}this.state=ts({...this.state,updatedAt:0}),this.normalizeUrl(),this.notifyListeners()}};typeof window<`u`&&!B()&&ls.init();function us(){return(0,Y.useSyncExternalStore)(e=>ls.subscribe(e),()=>ls.getSnapshot(),()=>ls.getSnapshot())}function ds(e){let t=R();if(!t)return;let n=new URLSearchParams(e.hash.slice(1));n.set(I,t),e.hash=n.toString()}function Ere(e){let{handoff:t,location:n}=e,r=new URL(n.href),i=new URL(t.serverUrl);return k({search:n.search}).hosted?(i.pathname=r.pathname,i.search=r.search,i.hash=r.hash,i.searchParams.set(`api`,t.serverUrl),ds(i),i.toString()):(i.pathname=r.pathname,i.search=r.search,i.hash=r.hash,ds(i),i.toString())}function fs(e){window.location.assign(Ere(e))}var ps=`gitScope`;function ms(e){return new URLSearchParams(e).get(`gitScope`)===`planning`?`planning`:`code`}function hs(e){return e.type===`commit`?e.hash:`uncommitted`}function gs(e,t,n=``){let r=new URLSearchParams(n);t===`planning`?r.set(ps,t):r.delete(ps);let i=r.toString();return`${e}${i?`?${i}`:``}`}function _s(e,t,n){return n.type===`commit`?[`git`,e,t,`meta`,`commit`,n.hash]:[`git`,e,t,`meta`,`uncommitted`]}function Dre(e,t,n){return n.type===`commit`?[`git`,e,t,`files`,`commit`,n.hash]:[`git`,e,t,`files`,`uncommitted`]}function Ore(e,t,n,r){return[`git`,e,t,`patch`,n.type===`commit`?`commit:${n.hash}`:`uncommitted`,r]}function kre(e){return e.type===`commit`?{type:`commit`,hash:e.hash}:{type:`uncommitted`}}function Are(e,t=`code`,n=``){return gs(e.type===`commit`?`/git/commit/${e.hash}`:`/git/uncommitted`,t,n)}function vs(e,t=`code`,n=``){return Are(kre(e),t,n)}var jre={"7d":7,"30d":30,"90d":90,all:null},Mre=/^(\d{4})-(\d{2})-(\d{2})(?:-|$)/;function ys(e){let t=Mre.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=Date.UTC(n,r-1,i),o=new Date(a);return!Number.isFinite(a)||o.getUTCFullYear()!==n||o.getUTCMonth()!==r-1||o.getUTCDate()!==i?null:a}function bs(e){return ys(e.id)??e.updatedAt}function Nre(e,t,n=Date.now()){let r=jre[t];return r===null?!0:bs(e)>=n-r*24*60*60*1e3}function Pre(e,t){return t.updatedAt-e.updatedAt||e.id.localeCompare(t.id)}function Fre(e){return[...e].sort(Pre)}function xs(e,t=10){return Fre(e).slice(0,Math.max(0,Math.trunc(t)))}function Ire(e,t=10){return[...e].sort((e,t)=>bs(t)-bs(e)||e.id.localeCompare(t.id)).slice(0,Math.max(0,Math.trunc(t)))}var Ss=[`timeout`,`memory-limit`,`runtime`,`abort`];async function Lre(e,t={}){let n=new AbortController,r=[],i=t.signal,a=Rre(t.timeoutMs);if(i)if(i.aborted)n.abort(i.reason);else{let e=()=>n.abort(i.reason);i.addEventListener(`abort`,e,{once:!0}),r.push(()=>i.removeEventListener(`abort`,e))}if(n.signal.aborted)return r.forEach(e=>e()),{ok:!1,error:Cs(n.signal.reason,i)};let o,s,c=Promise.resolve().then(()=>e(n.signal));c.catch(()=>void 0);let l=[c];n.signal.aborted||l.push(new Promise((e,t)=>{let i=()=>t(new DOMException(`Translation cancelled.`,`AbortError`));n.signal.addEventListener(`abort`,i,{once:!0}),r.push(()=>n.signal.removeEventListener(`abort`,i))})),a!==void 0&&l.push(new Promise((e,t)=>{o=setTimeout(()=>{s=Error(`Translation task timed out after ${a}ms.`),n.abort(s),t(s)},a)}));try{return{ok:!0,value:await Promise.race(l)}}catch(e){return n.abort(e),s&&n.signal.reason===s?{ok:!1,error:{kind:`timeout`,message:s.message}}:{ok:!1,error:Cs(e,i)}}finally{o&&clearTimeout(o),r.forEach(e=>e())}}function Cs(e,t){if(Hre(e))return e;if(t?.aborted)return{kind:`abort`,message:ws(t.reason)??`Translation cancelled.`};if(e instanceof DOMException&&e.name===`AbortError`)return{kind:`abort`,message:ws(e)??`Translation cancelled.`};let n=zre(e);return Bre(n)?{kind:`timeout`,message:n}:Vre(n)?{kind:`memory-limit`,message:n}:{kind:`runtime`,message:n}}function Rre(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}function zre(e){return e instanceof Error&&e.message.trim().length>0?e.message:typeof e==`string`&&e.trim().length>0?e:`Translation failed.`}function ws(e){if(e instanceof Error&&e.message.trim().length>0)return e.message;if(typeof e==`string`&&e.trim().length>0)return e}function Bre(e){return/\btime(?:d)?\s*out\b/i.test(e)}function Vre(e){return/out of memory/i.test(e)||/memory limit/i.test(e)||/insufficient memory/i.test(e)||/ERR_WORKER_OUT_OF_MEMORY/i.test(e)}function Hre(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`kind`),n=Reflect.get(e,`message`);return typeof t==`string`&&Ss.includes(t)&&typeof n==`string`&&n.length>0}var Ts=[`browser`,`local`,`local-ct2`,`local-llama`,`openai`],Es=l(Ts),Ds=`browser`;function Os(e){return e===`local`||e===`local-ct2`||e===`local-llama`}function ks(e){return e===`local`||e===`local-ct2`}l([`local`,`local-ct2`,`local-llama`,`openai`]);var As=15e3,js=l([`not-downloaded`,`queued`,`downloading`,`paused`,`downloaded`,`error`,`deleting`]),Ms=m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),required:f(),etag:S().min(1).optional(),revision:S().min(1).optional(),sourceUrl:S().min(1).optional(),raw:T().optional()}),Ure=m({id:S().min(1),label:S().min(1),description:S().optional(),profile:S().min(1).optional(),dtype:S().min(1).optional(),estimatedTotalBytes:x().int().nonnegative().optional(),baseGroupId:S().min(1).optional(),commitHash:S().min(1).optional(),shortCommitHash:S().min(1).optional(),rootDir:S().min(1).optional(),status:js.optional(),progress:x().min(0).max(1).optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),resumable:f().optional(),error:S().optional(),selectable:f(),selected:f(),files:p(Ms)}),Wre=l([`idle`,`loading`,`ready`,`error`]),Gre=m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),required:f(),etag:S().min(1).optional(),revision:S().min(1).optional(),sourceUrl:S().min(1).optional(),raw:T().optional()}),Kre=m({id:S().min(1),baseGroupId:S().min(1),label:S().min(1),displayLabel:S().min(1),description:S().optional(),profile:S().min(1).optional(),dtype:S().min(1).optional(),commitHash:S().min(1),shortCommitHash:S().min(1),rootDir:S().min(1),estimatedTotalBytes:x().int().nonnegative().optional(),selectable:f(),files:p(Gre)}),qre=m({modelId:S().min(1),source:v(`huggingface`),endpoint:S().default(``),revision:S().min(1),commitHash:S().min(1),shortCommitHash:S().min(1),fetchedAt:x().int().nonnegative(),updatedAt:x().int().nonnegative(),raw:T().optional(),groups:_(S(),Kre).default({}),groupOrder:p(S().min(1)).default([])}),Jre=m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),downloadedBytes:x().int().nonnegative().optional(),required:f().default(!0),status:js.default(`not-downloaded`),updatedAt:x().int().nonnegative().optional(),error:S().optional()}),Yre=m({groupId:S().min(1),baseGroupId:S().min(1).optional(),status:js.default(`not-downloaded`),rootDir:S().min(1).optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),progress:x().min(0).max(1).optional(),resumable:f().default(!1),error:S().optional(),installedAt:x().int().nonnegative().optional(),updatedAt:x().int().nonnegative().optional(),files:p(Jre).default([])}),Ns=m({status:Wre.default(`idle`),message:S().optional(),error:S().optional(),updatedAt:x().int().nonnegative().optional()});m({engineId:l([`local`,`local-ct2`,`local-llama`]),modelId:S().min(1),selectedGroupId:S().min(1).optional(),groupId:S().min(1).optional(),status:js,message:S(),progress:x().min(0).max(1).optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),sessionId:S().optional(),resumable:f().optional(),files:p(m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),downloadedBytes:x().int().nonnegative().optional()})).optional(),updatedAt:x().int().nonnegative()});var Xre=m({modelId:S().min(1),estimatedTotalBytes:x().int().nonnegative().optional(),files:p(Ms),profile:S().min(1).optional(),selectedGroupId:S().min(1).optional(),groups:p(Ure).optional()});m({modelId:S().min(1),version:v(2).default(2),status:js.default(`not-downloaded`),selected:f().default(!1),selectedGroupId:S().min(1).optional(),installedAt:x().int().nonnegative().optional(),updatedAt:x().int().nonnegative().optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),progress:x().min(0).max(1).optional(),resumable:f().default(!1),error:S().optional(),profileLoad:Ns.default(Ns.parse({})),profileManifest:qre.optional(),groupsState:_(S(),Yre).default({}),plan:Xre.optional(),files:p(m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),downloadedBytes:x().int().nonnegative().optional()})).default([])}),l([`local`,`network`,`recommended`]);var Zre=l([`installed`,`installing`,`missing`,`error`,`not-applicable`]),Qre=l([`ready`,`probing`,`failed`,`error`,`not-applicable`]),$re=l([`ready`,`missing`,`downloading`,`error`,`not-applicable`]),Ps=m({message:S().optional(),progress:x().min(0).max(1).optional(),error:S().optional()}),Fs=m({dependency:Ps.extend({state:Zre}),runtime:Ps.extend({state:Qre}),assets:Ps.extend({state:$re}),summary:S().optional()});function Is(e={}){return{dependency:{state:`not-applicable`,...e.dependency},runtime:{state:`not-applicable`,...e.runtime},assets:{state:`not-applicable`,...e.assets},...e.summary?{summary:e.summary}:{}}}function eie(e){return e.dependency.state===`installed`||e.dependency.state===`not-applicable`}function tie(e){return e.runtime.state===`ready`||e.runtime.state===`not-applicable`}function Ls(e){return e?!eie(e)||!tie(e):!1}function Rs(e){if(e)return e.summary??e.runtime.error??e.runtime.message??e.dependency.error??e.dependency.message??e.assets.error??e.assets.message}var zs=l([`stdout`,`stderr`]);m({stream:zs,text:S()}),P(`type`,[m({type:v(`status`),lifecycle:Fs}),m({type:v(`log`),stream:zs,text:S()}),m({type:v(`exit`),lifecycle:Fs})]);var nie=[{id:`browser`,label:`Browser`,description:`Uses the browser Translator API and future browser-side providers.`,technicalSummary:`Browser-native Web Translator adapter. Package payload is about 5 KB; browser language packs are managed by the browser.`,runtime:`browser`,kind:`browser`,installDescription:`Browser translation support is built into the browser runtime.`,moduleName:`@openspecui/browser-translator`,factoryExport:`createBrowserTranslatorFactory`},{id:`local`,label:`Local-Transformers`,description:`Runs an ONNX Runtime-backed local translation adapter through Transformers.js with managed ONNX model files.`,technicalSummary:`Server-side ONNX Runtime adapter via Transformers.js. Runtime package is installed on demand; selected ONNX model groups are downloaded separately and can range from tens to hundreds of MB.`,runtime:`server`,kind:`managed-local`,settingsKey:`local`,defaultModel:`Xenova/nllb-200-distilled-600M`,runtimePackageName:`@huggingface/transformers`,installDescription:`Install the Local-Transformers runtime package to enable server-side translation.`,modelLabel:`Local Model`,downloadGroupsLabel:`Local download profiles`,refreshTooltip:`Refresh local model profiles`,moduleName:`@openspecui/local-translator`,factoryExport:`createLocalTranslatorFactory`},{id:`local-ct2`,label:`Local-CT2`,description:`Runs a bundled local CTranslate2 translation runtime with managed model files.`,technicalSummary:`Server-side native CTranslate2 adapter. Runtime package is installed on demand; selected model artifacts are downloaded separately and can range from tens to hundreds of MB.`,runtime:`server`,kind:`managed-local`,settingsKey:`localCt2`,defaultModel:`ooeoeo/opus-mt-en-zh-ct2-float16`,runtimePackageName:`ctranslate2`,installDescription:`Install the Local-CT2 runtime package to enable server-side translation.`,modelLabel:`CT2 Model`,downloadGroupsLabel:`Local CT2 download groups`,refreshTooltip:`Refresh local model artifacts`,moduleName:`@openspecui/local-ct2-translator`,factoryExport:`createLocalCt2TranslatorFactory`},{id:`local-llama`,label:`Local-Llama`,description:`Runs a local GGUF translation-capable LLM through node-llama-cpp with managed GGUF model files.`,technicalSummary:`Server-side llama.cpp adapter via node-llama-cpp. Runtime package is installed on demand; selected GGUF model files are downloaded separately and can range from hundreds of MB to multiple GB.`,runtime:`server`,kind:`managed-local`,settingsKey:`localLlama`,defaultModel:`bartowski/Qwen2.5-0.5B-Instruct-GGUF`,runtimePackageName:`node-llama-cpp`,installDescription:`Install the Local-Llama runtime package to enable server-side GGUF translation.`,modelLabel:`Llama Model`,downloadGroupsLabel:`Local GGUF files`,refreshTooltip:`Refresh local GGUF artifacts`,moduleName:`@openspecui/local-llama-translator`,factoryExport:`createLocalLlamaTranslatorFactory`},{id:`openai`,label:`OpenAI-Completion`,description:`Uses an OpenAI-compatible TanStack AI completion provider for context-aware translation.`,technicalSummary:`Server-side TanStack AI adapter for OpenAI-compatible APIs. Package payload is about 5 KB; model size stays with the remote provider.`,runtime:`server`,kind:`remote-provider`,settingsKey:`openai`,defaultModel:`gpt-4.1-mini`,installDescription:`OpenAI completion translation is bundled with the server runtime.`,moduleName:`@openspecui/openai-completion-translator`,factoryExport:`createOpenAICompletionTranslatorFactory`}];function Bs(e){let t=nie.find(t=>t.id===e);if(!t)throw Error(`Unknown translation engine: ${e}`);return t}function rie(e){let t=Bs(e);if(t.kind!==`managed-local`)throw Error(`Translation engine ${e} is not a managed-local engine.`);return t}var Vs=m({baseUrl:S().default(``),token:S().default(``),model:S().default(`gpt-4.1-mini`)}),iie=m({baseUrl:S().optional(),token:S().optional(),model:S().optional()}),Hs=m({model:S().default(`Xenova/nllb-200-distilled-600M`),selectedGroupId:S().optional(),hfEndpoint:S().default(``),memoryBudgetPercent:x().min(0).max(100).default(25)}),aie=m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional(),hfEndpoint:S().optional(),memoryBudgetPercent:x().min(0).max(100).optional()}),Us=m({model:S().default(`ooeoeo/opus-mt-en-zh-ct2-float16`),selectedGroupId:S().optional(),hfEndpoint:S().default(``),memoryBudgetPercent:x().min(0).max(100).default(25)}),oie=m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional(),hfEndpoint:S().optional(),memoryBudgetPercent:x().min(0).max(100).optional()}),Ws=m({model:S().default(`bartowski/Qwen2.5-0.5B-Instruct-GGUF`),selectedGroupId:S().optional(),hfEndpoint:S().default(``),memoryBudgetPercent:x().min(0).max(100).default(25)}),sie=m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional(),hfEndpoint:S().optional(),memoryBudgetPercent:x().min(0).max(100).optional()});m({engineId:Es.default(Ds),openai:Vs.default(Vs.parse({})),local:Hs.default(Hs.parse({})),localCt2:Us.default(Us.parse({})),localLlama:Ws.default(Ws.parse({}))}),m({engineId:Es.optional(),openai:iie.optional(),local:aie.optional(),localCt2:oie.optional(),localLlama:sie.optional()}),m({engineId:Es,sourceLanguage:S().min(1),targetLanguage:S().min(1),model:S().min(1).optional(),selectedGroupId:S().min(1).optional(),inputs:p(S()).min(1),instructions:S().optional(),context:S().optional(),timeoutMs:x().int().positive().default(As)}),m({index:x().int().nonnegative(),output:S().optional(),error:m({kind:l(Ss),message:S().min(1)}).optional()});var Gs=l([`direct`,`bilingual`]),cie=m({local:m({model:S().min(1).optional(),selectedGroupId:S().min(1).optional()}).default({}),localCt2:m({model:S().min(1).optional(),selectedGroupId:S().min(1).optional()}).default({}),localLlama:m({model:S().min(1).optional(),selectedGroupId:S().min(1).optional()}).default({}),openai:m({model:S().min(1).optional()}).default({})}).default({}),lie=m({local:m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional()}).optional(),localCt2:m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional()}).optional(),localLlama:m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional()}).optional(),openai:m({model:S().min(1).optional()}).optional()}),Ks=m({enabled:f().default(!1),targetLanguage:S().min(1).default(`zh`),displayMode:Gs.default(`direct`),cacheEnabled:f().default(!1),engineId:Es.default(Ds),engines:cie});m({enabled:f().optional(),targetLanguage:S().min(1).optional(),displayMode:Gs.optional(),cacheEnabled:f().optional(),engineId:Es.optional(),engines:lie.optional()});var qs=1e4,Js=2e5;m({entryLimit:x().int().min(100).max(Js).default(qs)}),m({entryLimit:x().int().min(100).max(Js).optional()}),m({key:S().min(1),keyHash:S().min(1),sourceText:S(),translatedText:S(),targetNodesJson:S().optional(),sourceLanguage:S().min(1),targetLanguage:S().min(1),placeholderTopologyHash:S().min(1),attributeTopologyHash:S().min(1),displayPolicyVersion:x().int().positive(),engineId:Es.default(Ds),engineVersion:S().optional(),model:S().optional(),translatorContractVersion:x().int().positive().default(1),createdAt:x().int().nonnegative(),lastAccessedAt:x().int().nonnegative()}).omit({createdAt:!0,lastAccessedAt:!0}),m({keyHash:S().min(1)}),m({enabled:f(),entryLimit:x().int().positive(),entries:x().int().nonnegative(),databasePath:S().optional()});var uie=`project`,die=/^[A-Za-z]:\//;function Ys(e){return e.replace(/\\/g,`/`).replace(/\/+$/g,``)}function fie(e){return e.startsWith(`/`)||die.test(e)}function pie(e){return e.replace(/^\.?\//,``)}function Xs(e){return Ys(e).split(`/`).filter(Boolean)}function mie(e){let t=Ys(e),n=/(?:^|\/)node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(@[^/]+\/[^/]+|[^/]+)(\/.*)?/.exec(t),r=n?.[1];return r?`npm:${r}${n[2]??``}`:null}function Zs(e){return`${uie}:${pie(e)}`}function hie(e,t){let n=Ys(e),r=Ys(t),i=n.toLowerCase(),a=r.toLowerCase();return a===i||a.startsWith(`${i}/`)}function gie(e,t){let n=Xs(e),r=Xs(t),i=0;for(;i<n.length&&i<r.length&&n[i]?.toLowerCase()===r[i]?.toLowerCase();)i+=1;return r.slice(i).join(`/`)}function _ie(e){let t=Xs(e),n=t.lastIndexOf(`openspec`);return n<0?null:t.slice(n).join(`/`)}function Qs(e,t){let n=Ys(e),r=mie(n);return(t?.source===`package`||r)&&r?r:fie(n)?t?.projectDir&&hie(t.projectDir,n)?Zs(gie(t.projectDir,n)):Zs(_ie(n)||Xs(n).slice(-4).join(`/`)):Zs(n)}var $s=Symbol.for(`yaml.alias`),ec=Symbol.for(`yaml.document`),tc=Symbol.for(`yaml.map`),nc=Symbol.for(`yaml.pair`),rc=Symbol.for(`yaml.scalar`),ic=Symbol.for(`yaml.seq`),ac=Symbol.for(`yaml.node.type`),oc=e=>!!e&&typeof e==`object`&&e[ac]===$s,sc=e=>!!e&&typeof e==`object`&&e[ac]===ec,cc=e=>!!e&&typeof e==`object`&&e[ac]===tc,lc=e=>!!e&&typeof e==`object`&&e[ac]===nc,uc=e=>!!e&&typeof e==`object`&&e[ac]===rc,dc=e=>!!e&&typeof e==`object`&&e[ac]===ic;function fc(e){if(e&&typeof e==`object`)switch(e[ac]){case tc:case ic:return!0}return!1}function pc(e){if(e&&typeof e==`object`)switch(e[ac]){case $s:case tc:case rc:case ic:return!0}return!1}var mc=e=>(uc(e)||fc(e))&&!!e.anchor,hc=Symbol(`break visit`),gc=Symbol(`skip children`),_c=Symbol(`remove node`);function vc(e,t){let n=Sc(t);sc(e)?yc(null,e.contents,n,Object.freeze([e]))===_c&&(e.contents=null):yc(null,e,n,Object.freeze([]))}vc.BREAK=hc,vc.SKIP=gc,vc.REMOVE=_c;function yc(e,t,n,r){let i=Cc(e,t,n,r);if(pc(i)||lc(i))return wc(e,r,i),yc(e,i,n,r);if(typeof i!=`symbol`){if(fc(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=yc(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===hc)return hc;else i===_c&&(t.items.splice(e,1),--e)}}else if(lc(t)){r=Object.freeze(r.concat(t));let e=yc(`key`,t.key,n,r);if(e===hc)return hc;e===_c&&(t.key=null);let i=yc(`value`,t.value,n,r);if(i===hc)return hc;i===_c&&(t.value=null)}}return i}async function bc(e,t){let n=Sc(t);sc(e)?await xc(null,e.contents,n,Object.freeze([e]))===_c&&(e.contents=null):await xc(null,e,n,Object.freeze([]))}bc.BREAK=hc,bc.SKIP=gc,bc.REMOVE=_c;async function xc(e,t,n,r){let i=await Cc(e,t,n,r);if(pc(i)||lc(i))return wc(e,r,i),xc(e,i,n,r);if(typeof i!=`symbol`){if(fc(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await xc(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===hc)return hc;else i===_c&&(t.items.splice(e,1),--e)}}else if(lc(t)){r=Object.freeze(r.concat(t));let e=await xc(`key`,t.key,n,r);if(e===hc)return hc;e===_c&&(t.key=null);let i=await xc(`value`,t.value,n,r);if(i===hc)return hc;i===_c&&(t.value=null)}}return i}function Sc(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Cc(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(cc(t))return n.Map?.(e,t,r);if(dc(t))return n.Seq?.(e,t,r);if(lc(t))return n.Pair?.(e,t,r);if(uc(t))return n.Scalar?.(e,t,r);if(oc(t))return n.Alias?.(e,t,r)}function wc(e,t,n){let r=t[t.length-1];if(fc(r))r.items[e]=n;else if(lc(r))e===`key`?r.key=n:r.value=n;else if(sc(r))r.contents=n;else{let e=oc(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var vie={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},yie=e=>e.replace(/[!,[\]{}]/g,e=>vie[e]),Tc=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+yie(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&pc(e.contents)){let t={};vc(e.contents,(e,n)=>{pc(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
7
+ `)}var ri={willReadFrequently:!0},ii=class e{static get experimentalLetterSpacingSupported(){let t=e._experimentalLetterSpacingSupported;if(t===void 0){let n=Rt.get().getCanvasRenderingContext2D().prototype;t=e._experimentalLetterSpacingSupported=`letterSpacing`in n||`textLetterSpacing`in n}return t}constructor(e,t,n,r,i,a,o,s,c,l){this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c,l&&(this.runsByLine=l.runsByLine,this.lineAscents=l.lineAscents,this.lineDescents=l.lineDescents,this.lineHeights=l.lineHeights,this.hasDropShadow=l.hasDropShadow)}static measureText(t=` `,n,r=e._canvas,i=n.wordWrap){let a=`${t}-${n.styleKey}-wordWrap-${i}`;if(e._measurementCache.has(a))return e._measurementCache.get(a);if(qr(n)&&Jr(t)){let r=mte(t,n,i,e._context,e._measureText,e.measureFont,e.canBreakChars,e.wordWrapSplit),o=new e(t,n,r.width,r.height,r.lines,r.lineWidths,r.lineHeight,r.maxLineWidth,r.fontProperties,{runsByLine:r.runsByLine,lineAscents:r.lineAscents,lineDescents:r.lineDescents,lineHeights:r.lineHeights,hasDropShadow:r.hasDropShadow});return e._measurementCache.set(a,o),o}let o=n._fontString,s=e.measureFont(o);s.fontSize===0&&(s.fontSize=n.fontSize,s.ascent=n.fontSize,s.descent=0);let c=e._context;c.font=o;let l=(i?e._wordWrap(t,n,r):t).split(fte),u=Array(l.length),d=0;for(let t=0;t<l.length;t++){let r=e._measureText(l[t],n.letterSpacing,c);u[t]=r,d=Math.max(d,r)}let f=n._stroke?.width??0,p=n.lineHeight||s.fontSize,m=e._getAlignWidth(d,n,i),h=e._adjustWidthForStyle(m,n),g=Math.max(p,s.fontSize+f)+(l.length-1)*(p+n.leading),_=new e(t,n,h,e._adjustHeightForStyle(g,n),l,u,p+n.leading,d,s);return e._measurementCache.set(a,_),_}static _adjustWidthForStyle(e,t){let n=e+(t._stroke?.width||0);return t.dropShadow&&(n+=t.dropShadow.distance),n}static _adjustHeightForStyle(e,t){let n=e;return t.dropShadow&&(n+=t.dropShadow.distance),n}static _getAlignWidth(e,t,n){return n&&t.align!==`left`&&t.align!==`justify`?Math.max(e,t.wordWrapWidth):e}static _measureText(t,n,r){let i=!1;e.experimentalLetterSpacingSupported&&(e.experimentalLetterSpacing?(r.letterSpacing=`${n}px`,r.textLetterSpacing=`${n}px`,i=!0):(r.letterSpacing=`0px`,r.textLetterSpacing=`0px`));let a=r.measureText(t),o=a.width,s=-(a.actualBoundingBoxLeft??0),c=(a.actualBoundingBoxRight??0)-s;if(o>0)if(i)o-=n,c-=n;else{let r=(e.graphemeSegmenter(t).length-1)*n;o+=r,c+=r}return Math.max(o,c)}static _wordWrap(t,n,r=e._canvas){return vte(t,n,r,e._measureText,e.canBreakWords,e.canBreakChars,e.wordWrapSplit)}static isBreakingSpace(e,t){return Xr(e,t)}static canBreakWords(e,t){return t}static canBreakChars(e,t,n,r,i){return!0}static wordWrapSplit(t){return e.graphemeSegmenter(t)}static measureFont(t){if(e._fonts[t])return e._fonts[t];let n=e._context;n.font=t;let r=n.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),i=r.actualBoundingBoxAscent??0,a=r.actualBoundingBoxDescent??0,o={ascent:i,descent:a,fontSize:i+a};return e._fonts[t]=o,o}static clearMetrics(t=``){t?delete e._fonts[t]:e._fonts={}}static get _canvas(){if(!e.__canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,ri)?.measureText)return e.__canvas=n,n;t=Rt.get().createCanvas()}catch{t=Rt.get().createCanvas()}t.width=t.height=10,e.__canvas=t}return e.__canvas}static get _context(){return e.__context||=e._canvas.getContext(`2d`,ri),e.__context}};ii.METRICS_STRING=`|ÉqÅ`,ii.BASELINE_SYMBOL=`M`,ii.BASELINE_MULTIPLIER=1.4,ii.HEIGHT_MULTIPLIER=2,ii.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter==`function`){let e=new Intl.Segmenter;return t=>{let n=e.segment(t),r=[],i=0;for(let e of n)r[i++]=e.segment;return r}}return e=>[...e]})(),ii.experimentalLetterSpacing=!1,ii._fonts={},ii._measurementCache=ote(1e3);var ai=ii,yte=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`];function oi(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!yte.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var si=class e extends jt{constructor(t={}){super(),this.uid=Dt(`textStyle`),this._tick=0,this._cachedFontString=null,bte(t),t instanceof e&&(t=t._toObject());let n={...e.defaultTextStyle,...t};for(let e in n){let t=e;this[t]=n[e]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(typeof t==`object`&&t?this._dropShadow=this._createProxy({...e.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...e.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e==`string`?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Ut.defaultFillStyle,...e},()=>{this._fill=Bt({...this._originalFill},Ut.defaultFillStyle)})),this._fill=Bt(e===0?`black`:e,Ut.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ut.defaultStrokeStyle,...e},()=>{this._stroke=zt({...this._originalStroke},Ut.defaultStrokeStyle)})),this._stroke=zt(e,Ut.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit(`update`,this)}reset(){let t=e.defaultTextStyle;for(let e in t)this[e]=t[e]}assign(e){for(let t in e){let n=t;this[n]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=oi(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new e(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){if(this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(t),this._originalFill?.texture&&this._originalFill.texture.destroy(t),this._stroke?.texture&&this._stroke.texture.destroy(t),this._originalStroke?.texture&&this._originalStroke.texture.destroy(t)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(e,n,r)=>e[n]===r?!0:(e[n]=r,t?.(n,r),this.update(),!0)})}_isFillStyle(e){return(e??null)!==null&&!(Pt.isColorLike(e)||e instanceof Wt||e instanceof Ht)}};si.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:`black`,distance:5},si.defaultTextStyle={align:`left`,breakWords:!1,dropShadow:null,fill:`black`,fontFamily:`Arial`,fontSize:26,fontStyle:`normal`,fontVariant:`normal`,fontWeight:`normal`,leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:`alphabetic`,trim:!1,whiteSpace:`pre`,wordWrap:!1,wordWrapWidth:100};var ci=si;function bte(e){let t=e;if(typeof t.dropShadow==`boolean`&&t.dropShadow){let n=ci.defaultDropShadow;e.dropShadow={alpha:t.dropShadowAlpha??n.alpha,angle:t.dropShadowAngle??n.angle,blur:t.dropShadowBlur??n.blur,color:t.dropShadowColor??n.color,distance:t.dropShadowDistance??n.distance}}if(t.strokeThickness!==void 0){bt(Et,`strokeThickness is now a part of stroke`);let n=t.stroke,r={};if(Pt.isColorLike(n))r.color=n;else if(n instanceof Wt||n instanceof Ht)r.fill=n;else if(Object.hasOwnProperty.call(n,`color`)||Object.hasOwnProperty.call(n,`fill`))r=n;else throw Error(`Invalid stroke value.`);e.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(bt(Et,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw Error(`Invalid fill value. Expected an array of colors for gradient fill.`);t.fill.length!==t.fillGradientStops.length&&Mt(`The number of fill colors must match the number of fill gradient stops.`);let n=new Wt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:`local`}),r=t.fillGradientStops.slice(),i=t.fill.map(e=>Pt.shared.setValue(e).toNumber());r.forEach((e,t)=>{n.addColorStop(e,i[t])}),e.fill={fill:n}}}var li=1e5;function ui(e,t,n,r=0,i=0,a=0){if(e.texture===wt.WHITE&&!e.fill)return Pt.shared.setValue(e.color).setAlpha(e.alpha??1).toHexa();if(!e.fill){let n=t.createPattern(e.texture.source.resource,`repeat`),r=e.matrix.copyTo(_t.shared);return r.scale(e.texture.source.pixelWidth,e.texture.source.pixelHeight),n.setTransform(r),n}else if(e.fill instanceof Ht){let n=e.fill,r=t.createPattern(n.texture.source.resource,`repeat`),i=n.transform.copyTo(_t.shared);return i.scale(n.texture.source.pixelWidth,n.texture.source.pixelHeight),r.setTransform(i),r}else if(e.fill instanceof Wt){let o=e.fill,s=o.type===`linear`,c=o.textureSpace===`local`,l=1,u=1;c&&n&&(l=n.width+r,u=n.height+r);let d,f=!1;if(s){let{start:e,end:n}=o;d=t.createLinearGradient(e.x*l+i,e.y*u+a,n.x*l+i,n.y*u+a),f=Math.abs(n.x-e.x)<Math.abs((n.y-e.y)*.1)}else{let{center:e,innerRadius:n,outerCenter:r,outerRadius:s}=o;d=t.createRadialGradient(e.x*l+i,e.y*u+a,n*l,r.x*l+i,r.y*u+a,s*l)}if(f&&c&&n){let e=n.lineHeight/u;for(let t=0;t<n.lines.length;t++){let i=(t*n.lineHeight+r/2)/u;o.colorStops.forEach(t=>{let n=i+t.offset*e;n=Math.max(0,Math.min(1,n)),d.addColorStop(Math.floor(n*li)/li,Pt.shared.setValue(t.color).toHex())})}}else o.colorStops.forEach(e=>{d.addColorStop(e.offset,Pt.shared.setValue(e.color).toHex())});return d}return Mt(`FillStyle not recognised`,e),`red`}var di=class extends Gr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Vr(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),fi(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pi(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Fr(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ar(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&mi(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Fr(this.options.enabled,this.#t)!==Fr(t.enabled,this.#t)||Pr(this.options.staleTime,this.#t)!==Pr(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Fr(this.options.enabled,this.#t)!==Fr(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Ste(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Nr)),t}#g(){this.#b();let e=Pr(this.options.staleTime,this.#t);if(Ur||this.#r.isStale||!Mr(e))return;let t=ite(this.#r.dataUpdatedAt,e)+1;this.#d=jr.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Ur||Fr(this.options.enabled,this.#t)===!1||!Mr(this.#p)||this.#p===0)&&(this.#f=jr.setInterval(()=>{(this.options.refetchIntervalInBackground||Qee.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(jr.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(jr.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&fi(e,t),o=i&&mi(e,n,t,r);(a||o)&&(l={...l,...Zee(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=zr(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=zr(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:hi(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Fr(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{t(this.#o=x.promise=Vr())},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Ar(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){Rr.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function xte(e,t){return Fr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function fi(e,t){return xte(e,t)||e.state.data!==void 0&&pi(e,t,t.refetchOnMount)}function pi(e,t,n){if(Fr(t.enabled,e)!==!1&&Pr(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&hi(e,t)}return!1}function mi(e,t,n,r){return(e!==t||Fr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&hi(e,n)}function hi(e,t){return Fr(t.enabled,e)!==!1&&e.isStaleByTime(Pr(t.staleTime,e))}function Ste(e,t){return!Ar(e.getCurrentResult(),t)}var Cte=class extends di{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Ir()})}getOptimisticResult(e){return e.behavior=Ir(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:tte(t,n.data),hasPreviousPage:nte(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},wte=class extends Gr{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Ar(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Lr(t.mutationKey)!==Lr(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??rte();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Rr.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n,r),this.#r.onSettled?.(e.data,null,t,n,r)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n,r),this.#r.onSettled?.(void 0,e.error,t,n,r))}this.listeners.forEach(e=>{e(this.#t)})})}};function gi(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Tte(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ete=class extends Gr{#e;#t;#n;#r;#i;#a;#o;#s;#c=[];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.#f(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,Rr.batch(()=>{let e=this.#i,t=this.#d(this.#n);this.#c=t,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||!Ar(e,n)});!o&&!s||(o&&(this.#i=n),this.#t=r,this.hasListeners()&&(o&&(gi(e,n).forEach(e=>{e.destroy()}),gi(n,e).forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})),this.#p()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#d(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions));return[r,e=>this.#u(e??r,t),()=>this.#l(r,n)]}#l(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)})})})}#u(e,t){return t?((!this.#a||this.#t!==this.#s||t!==this.#o)&&(this.#o=t,this.#s=this.#t,this.#a=ete(this.#a,t(e))),this.#a):e}#d(e){let t=new Map(this.#i.map(e=>[e.options.queryHash,e])),n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new di(this.#e,r)})}),n}#f(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Tte(this.#t,n,t),this.#p())}#p(){if(this.hasListeners()){let e=this.#a,t=this.#l(this.#t,this.#c);e!==this.#u(t,this.#r?.combine)&&Rr.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},_i=Y.createContext(void 0),vi=e=>{let t=Y.useContext(_i);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Dte=({client:e,children:t})=>(Y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,J.jsx)(_i.Provider,{value:e,children:t})),yi=Y.createContext(!1),bi=()=>Y.useContext(yi);yi.Provider;function Ote(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kte=Y.createContext(Ote()),xi=()=>Y.useContext(kte),Si=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ci=e=>{Y.useEffect(()=>{e.clearReset()},[e])},wi=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Wr(n,[e.error,r])),Ti=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ei=(e,t)=>e.isLoading&&e.isFetching&&!t,Di=(e,t)=>e?.suspense&&t.isPending,Oi=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ate({queries:e,...t},n){let r=vi(n),i=bi(),a=xi(),o=Y.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ti(e),Si(e,a)}),Ci(a);let[s]=Y.useState(()=>new Ete(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;Y.useSyncExternalStore(Y.useCallback(e=>d?s.subscribe(Rr.batchCalls(e)):Nr,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),Y.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Di(o[t],e))?c.flatMap((e,t)=>{let n=o[t];if(n){let t=new di(r,n);if(Di(n,e))return Oi(n,t,a);Ei(e,i)&&Oi(n,t,a)}return[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&wi({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())}function ki(e,t,n){let r=bi(),i=xi(),a=vi(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Ti(o),Si(o,i),Ci(i);let s=!a.getQueryCache().get(o.queryHash),[c]=Y.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(Y.useSyncExternalStore(Y.useCallback(e=>{let t=u?c.subscribe(Rr.batchCalls(e)):Nr;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Y.useEffect(()=>{c.setOptions(o)},[o,c]),Di(o,l))throw Oi(o,c,i);if(wi({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!Ur&&Ei(l,r)&&(s?Oi(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Nr).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function Ai(e,t){return ki(e,di,t)}function ji(e,t){let n=vi(t),[r]=Y.useState(()=>new wte(n,e));Y.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(Rr.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=Y.useCallback((e,t)=>{r.mutate(e,t).catch(Nr)},[r]);if(i.error&&Wr(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function jte(e,t){return ki(e,Cte,t)}var Mi=new WeakMap,Mte=new WeakMap,Ni={current:[]},Pi=!1,Fi=0,Ii=new Set,Li=new Map;function Ri(e){for(let t of e){if(Ni.current.includes(t))continue;Ni.current.push(t),t.recompute();let e=Mte.get(t);if(e)for(let t of e){let e=Mi.get(t);e?.length&&Ri(e)}}}function Nte(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function Pte(e){let t={prevVal:e.prevState,currentVal:e.state};for(let n of e.listeners)n(t)}function zi(e){if(Fi>0&&!Li.has(e)&&Li.set(e,e.prevState),Ii.add(e),!(Fi>0)&&!Pi)try{for(Pi=!0;Ii.size>0;){let e=Array.from(Ii);Ii.clear();for(let t of e)t.prevState=Li.get(t)??t.prevState,Nte(t);for(let t of e){let e=Mi.get(t);e&&(Ni.current.push(t),Ri(e))}for(let t of e){let e=Mi.get(t);if(e)for(let t of e)Pte(t)}}}finally{Pi=!1,Ni.current=[],Li.clear()}}function Bi(e){Fi++;try{e()}finally{if(Fi--,Fi===0){let e=Ii.values().next().value;e&&zi(e)}}}function Fte(e){return typeof e==`function`}var Ite=class{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t;this.listeners.add(e);let n=((t=this.options)?.onSubscribe)?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.prevState=e,this.state=e,this.options=t}setState(e){var t,n;this.prevState=this.state,this.options?.updateFn?this.state=this.options.updateFn(this.prevState)(e):Fte(e)?this.state=e(this.prevState):this.state=e,(n=(t=this.options)?.onUpdate)==null||n.call(t),zi(this)}},Vi=`__TSR_index`,Hi=`popstate`,Ui=`beforeunload`;function Wi(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=Ki(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Vi];i=Gi(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Vi];i=Gi(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Vi]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function Gi(e,t){t||={};let n=qi();return{...t,key:n,__TSR_key:n,[Vi]:e}}function Lte(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>Ki(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=qi();t.history.replaceState({[Vi]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=Ki(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[Vi]-l.state[Vi],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=Wi({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Ui,S,{capture:!0}),t.removeEventListener(Hi,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(Ui,S,{capture:!0}),t.addEventListener(Hi,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function Ki(e,t){let n=e.indexOf(`#`),r=e.indexOf(`?`),i=qi();return{href:e,pathname:e.substring(0,n>0?r>0?Math.min(n,r):n:r>0?r:e.length),hash:n>-1?e.substring(n):``,search:r>-1?e.slice(r,n===-1?void 0:n):``,state:t||{[Vi]:0,key:i,__TSR_key:i}}}function qi(){return(Math.random()+1).toString(36).substring(7)}function Ji(e){return e[e.length-1]}function Rte(e){return typeof e==`function`}function Yi(e,t){return Rte(e)?e(t):e}var zte=Object.prototype.hasOwnProperty;function Xi(e,t){if(e===t)return e;let n=t,r=ea(e)&&ea(n);if(!r&&!(Qi(e)&&Qi(n)))return n;let i=r?e:Zi(e);if(!i)return n;let a=r?n:Zi(n);if(!a)return n;let o=i.length,s=a.length,c=r?Array(s):{},l=0;for(let t=0;t<s;t++){let i=r?t:a[t],s=e[i],u=n[i];if(s===u){c[i]=s,(r?t<o:zte.call(e,i))&&l++;continue}if(s===null||u===null||typeof s!=`object`||typeof u!=`object`){c[i]=u;continue}let d=Xi(s,u);c[i]=d,d===s&&l++}return o===s&&l===o?e:c}function Zi(e){let t=[],n=Object.getOwnPropertyNames(e);for(let r of n){if(!Object.prototype.propertyIsEnumerable.call(e,r))return!1;t.push(r)}let r=Object.getOwnPropertySymbols(e);for(let n of r){if(!Object.prototype.propertyIsEnumerable.call(e,n))return!1;t.push(n)}return t}function Qi(e){if(!$i(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!$i(n)||!n.hasOwnProperty(`isPrototypeOf`))}function $i(e){return Object.prototype.toString.call(e)===`[object Object]`}function ea(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ta(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!ta(e[r],t[r],n))return!1;return!0}if(Qi(e)&&Qi(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!ta(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!ta(e[o],t[o],n)))return!1;return i===a}return!1}function na(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function ra(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function ia(e){try{return decodeURI(e)}catch{return e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}}function aa(e,t){if(!e)return e;let n=t?RegExp(`${t.join(`|`)}`,`gi`):/%25|%5C/gi,r=0,i=``,a;for(;(a=n.exec(e))!==null;)i+=ia(e.slice(r,a.index))+a[0],r=n.lastIndex;return i+ia(r?e.slice(r):e)}var Bte=!0,oa=`Invariant failed`;function sa(e,t){if(!e){if(Bte)throw Error(oa);var n=typeof t==`function`?t():t,r=n?`${oa}: ${n}`:oa;throw Error(r)}}function ca(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var Vte=/^([^{]*)\{\$([a-zA-Z_$][a-zA-Z0-9_$]*)\}([^}]*)$/,Hte=/^([^{]*)\{-\$([a-zA-Z_$][a-zA-Z0-9_$]*)\}([^}]*)$/,Ute=/^([^{]*)\{\$\}([^}]*)$/;function la(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=a.match(Ute);if(o){let r=o[1].length;return n[0]=2,n[1]=t+r,n[2]=t+r+1,n[3]=t+r+2,n[4]=t+r+3,n[5]=e.length,n}let s=a.match(Hte);if(s){let e=s[1],r=s[2],a=s[3],o=e.length;return n[0]=3,n[1]=t+o,n[2]=t+o+3,n[3]=t+o+3+r.length,n[4]=i-a.length,n[5]=i,n}let c=a.match(Vte);if(c){let e=c[1],r=c[2],a=c[3],o=e.length;return n[0]=1,n[1]=t+o,n[2]=t+o+2,n[3]=t+o+2+r.length,n[4]=i-a.length,n[5]=i,n}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function ua(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e;for(;s<o;){let e=la(r,s,t),o,l=s,u=e[5];switch(s=u+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=pa(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=pa(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(l,e[1]),s=r.substring(e[4],u),d=c&&!!(t||s),f=t?d?t:t.toLowerCase():void 0,p=s?d?s:s.toLowerCase():void 0,m=i.dynamic?.find(e=>e.caseSensitive===d&&e.prefix===f&&e.suffix===p);if(m)o=m;else{let e=ma(1,n.fullPath??n.from,d,f,p);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(l,e[1]),s=r.substring(e[4],u),d=c&&!!(t||s),f=t?d?t:t.toLowerCase():void 0,p=s?d?s:s.toLowerCase():void 0,m=i.optional?.find(e=>e.caseSensitive===d&&e.prefix===f&&e.suffix===p);if(m)o=m;else{let e=ma(3,n.fullPath??n.from,d,f,p);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(l,e[1]),s=r.substring(e[4],u),d=c&&!!(t||s),f=t?d?t:t.toLowerCase():void 0,p=s?d?s:s.toLowerCase():void 0,m=ma(2,n.fullPath??n.from,d,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if((n.path||!n.children)&&!n.isRoot){let e=r.endsWith(`/`);e||(i.notFound=n),(!i.route||!i.isIndex&&e)&&(i.route=n),i.isIndex||=e}}if(n.children)for(let r of n.children)ua(e,t,r,s,i,a,o)}function da(e,t){if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function fa(e){if(e.static)for(let t of e.static.values())fa(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())fa(t);if(e.dynamic?.length){e.dynamic.sort(da);for(let t of e.dynamic)fa(t)}if(e.optional?.length){e.optional.sort(da);for(let t of e.optional)fa(t)}if(e.wildcard?.length){e.wildcard.sort(da);for(let t of e.wildcard)fa(t)}}function pa(e){return{kind:0,depth:0,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,isIndex:!1,notFound:null}}function ma(e,t,n,r,i){return{kind:e,depth:0,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,isIndex:!1,notFound:null,caseSensitive:n,prefix:r,suffix:i}}function Wte(e,t){let n=pa(`/`),r=new Uint16Array(6);for(let t of e)ua(!1,r,t,1,n,0);fa(n),t.masksTree=n,t.flatCache=ca(1e3)}function Gte(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=ha(e,t.masksTree);return t.flatCache.set(e,r),r}function Kte(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=pa(`/`),ua(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),ha(r,o,n)}function qte(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a=ha(e,t.segmentTree,n);return a&&(a.branch=Zte(a.route)),t.matchCache.set(r,a),a}function Jte(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function Yte(e,t=!1,n){let r=pa(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return ua(t,i,e,1,r,0,e=>{if(n?.(e,s),sa(!(e.id in a),`Duplicate routes found with id: ${String(e.id)}`),a[e.id]=e,s!==0&&e.path){let t=Jte(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),fa(r),{processedTree:{segmentTree:r,singleCache:ca(1e3),matchCache:ca(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function ha(e,t,n=!1){let r=e.split(`/`),i=$te(e,r,t,n);if(!i)return null;let a=Xte(e,r,i),o=`**`in i;return o&&(a[`**`]=i[`**`]),{route:o?i.node.notFound??i.node.route:i.node.route,params:a}}function Xte(e,t,n){let r=Qte(n.node),i=null,a={};for(let o=0,s=0,c=0;s<r.length;o++,s++,c++){let l=r[s],u=t[o],d=c;if(u&&(c+=u.length),l.kind===1){i??=n.node.fullPath.split(`/`);let e=i[s],t=l.prefix?.length??0;if(e.charCodeAt(t)===123){let n=l.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=u.substring(t,u.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(u)}}else if(l.kind===3){if(n.skipped&1<<s){o--;continue}i??=n.node.fullPath.split(`/`);let e=i[s],t=l.prefix?.length??0,r=l.suffix?.length??0,c=e.substring(t+3,e.length-r-1),d=l.suffix||l.prefix?u.substring(t,u.length-r):u;d&&(a[c]=decodeURIComponent(d))}else if(l.kind===2){let t=l,n=e.substring(d+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return a}function Zte(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Qte(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function $te(e,t,n,r){let i=!Ji(t),a=i&&e!==`/`,o=t.length-(i?1:0),s=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}],c=null,l=null,u=null;for(;s.length;){let e=s.pop(),{node:n,index:i,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=e;r&&n.notFound&&ga(l,e)&&(l=e);let g=i===o;if(g){if(n.route&&(!a||n.isIndex)&&(ga(u,e)&&(u=e),p===o&&n.isIndex))return u;if(!n.optional&&!n.wildcard)continue}let _=g?void 0:t[i],v;if(n.wildcard&&ga(c,e))for(let e of n.wildcard){let{prefix:n,suffix:r}=e;if(!(n&&(g||!(e.caseSensitive?_:v??=_.toLowerCase()).startsWith(n)))){if(r){if(g)continue;let n=t.slice(i).join(`/`).slice(-r.length);if((e.caseSensitive?n:n.toLowerCase())!==r)continue}c={node:e,index:i,skipped:d,depth:f,statics:p,dynamics:m,optionals:h};break}}if(n.optional){let e=d|1<<f,t=f+1;for(let r=n.optional.length-1;r>=0;r--){let a=n.optional[r];s.push({node:a,index:i,skipped:e,depth:t,statics:p,dynamics:m,optionals:h})}if(!g)for(let e=n.optional.length-1;e>=0;e--){let r=n.optional[e],{prefix:a,suffix:o}=r;if(a||o){let e=r.caseSensitive?_:v??=_.toLowerCase();if(a&&!e.startsWith(a)||o&&!e.endsWith(o))continue}s.push({node:r,index:i+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+1})}}if(!g&&n.dynamic&&_)for(let e=n.dynamic.length-1;e>=0;e--){let t=n.dynamic[e],{prefix:r,suffix:a}=t;if(r||a){let e=t.caseSensitive?_:v??=_.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:t,index:i+1,skipped:d,depth:f+1,statics:p,dynamics:m+1,optionals:h})}if(!g&&n.staticInsensitive){let e=n.staticInsensitive.get(v??=_.toLowerCase());e&&s.push({node:e,index:i+1,skipped:d,depth:f+1,statics:p+1,dynamics:m,optionals:h})}if(!g&&n.static){let e=n.static.get(_);e&&s.push({node:e,index:i+1,skipped:d,depth:f+1,statics:p+1,dynamics:m,optionals:h})}}if(u)return u;if(c)return c;if(r&&l){let n=l.index;for(let e=0;e<l.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return{node:l.node,skipped:l.skipped,"**":decodeURIComponent(r)}}return null}function ga(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&(t.node.isIndex>e.node.isIndex||t.node.isIndex===e.node.isIndex&&t.depth>e.depth))):!0}function _a(e){return va(e.filter(e=>e!==void 0).join(`/`))}function va(e){return e.replace(/\/{2,}/g,`/`)}function ya(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function ba(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function xa(e){return ba(ya(e))}function Sa(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function ene(e,t,n){return Sa(e,n)===Sa(t,n)}function tne({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&Ji(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(Ji(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c,l=``;for(let e=0;e<s.length;e++){e>0&&(l+=`/`);let t=s[e];if(!t)continue;c=la(t,0,c);let n=c[0];if(n===0){l+=t;continue}let r=c[5],i=t.substring(0,c[1]),a=t.substring(c[4],r),o=t.substring(c[2],c[3]);n===1?l+=i||a?`${i}{$${o}}${a}`:`$${o}`:n===2?l+=i||a?`${i}{$}${a}`:`$`:l+=`${i}{-$${o}}${a}`}l=va(l);let u=l||`/`;return o&&r&&r.set(o,u),u}function Ca(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?encodeURI(r):nne(r,n):r}function wa({path:e,params:t,decodeCharMap:n}){let r=!1,i={};if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:i,isMissingParams:r};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:i,isMissingParams:r};let a=e.length,o=0,s,c=``;for(;o<a;){let a=o;s=la(e,a,s);let l=s[5];if(o=l+1,a===l)continue;let u=s[0];if(u===0){c+=`/`+e.substring(a,l);continue}if(u===2){let o=t._splat;i._splat=o,i[`*`]=o;let u=e.substring(a,s[1]),d=e.substring(s[4],l);if(!o){r=!0,(u||d)&&(c+=`/`+u+d);continue}let f=Ca(`_splat`,t,n);c+=`/`+u+f+d;continue}if(u===1){let o=e.substring(s[2],s[3]);!r&&!(o in t)&&(r=!0),i[o]=t[o];let u=e.substring(a,s[1]),d=e.substring(s[4],l),f=Ca(o,t,n)??`undefined`;c+=`/`+u+f+d;continue}if(u===3){let r=e.substring(s[2],s[3]),o=t[r];if(o==null)continue;i[r]=o;let u=e.substring(a,s[1]),d=e.substring(s[4],l),f=Ca(r,t,n)??``;c+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(c+=`/`),{usedParams:i,interpolatedPath:c||`/`,isMissingParams:r}}function nne(e,t){let n=encodeURIComponent(e);if(t)for(let[e,r]of t)n=n.replaceAll(e,r);return n}function Ta(e={}){if(e.isNotFound=!0,e.throw)throw e;return e}function Ea(e){return!!e?.isNotFound}function rne(){try{if(typeof window<`u`&&typeof window.sessionStorage==`object`)return window.sessionStorage}catch{}}var Da=`tsr-scroll-restoration-v1_3`,ine=(e,t)=>{let n;return(...r)=>{n||=setTimeout(()=>{e(...r),n=null},t)}};function ane(){let e=rne();if(!e)return null;let t=e.getItem(Da),n=t?JSON.parse(t):{};return{state:n,set:t=>(n=Yi(t,n)||n,e.setItem(Da,JSON.stringify(n)))}}var Oa=ane(),ka=e=>e.state.__TSR_key||e.href;function one(e){let t=[],n;for(;n=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,e)+1})`),e=n;return`${t.reverse().join(` > `)}`.toLowerCase()}var Aa=!1;function ja({storageKey:e,key:t,behavior:n,shouldScrollRestoration:r,scrollToTopSelectors:i,location:a}){let o;try{o=JSON.parse(sessionStorage.getItem(e)||`{}`)}catch(e){console.error(e);return}let s=t||window.history.state?.__TSR_key,c=o[s];Aa=!0;scroll:{if(r&&c&&Object.keys(c).length>0){for(let e in c){let t=c[e];if(e===`window`)window.scrollTo({top:t.scrollY,left:t.scrollX,behavior:n});else if(e){let n=document.querySelector(e);n&&(n.scrollLeft=t.scrollX,n.scrollTop=t.scrollY)}}break scroll}let e=(a??window.location).hash.split(`#`,2)[1];if(e){let t=window.history.state?.__hashScrollIntoViewOptions??!0;if(t){let n=document.getElementById(e);n&&n.scrollIntoView(t)}break scroll}let t={top:0,left:0,behavior:n};if(window.scrollTo(t),i)for(let e of i){if(e===`window`)continue;let n=typeof e==`function`?e():document.querySelector(e);n&&n.scrollTo(t)}}Aa=!1}function sne(e,t){if(!Oa&&!e.isServer||((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isServer||e.isScrollRestorationSetup||!Oa))return;e.isScrollRestorationSetup=!0,Aa=!1;let n=e.options.getScrollRestorationKey||ka;window.history.scrollRestoration=`manual`,typeof document<`u`&&document.addEventListener(`scroll`,ine(t=>{if(Aa||!e.isScrollRestoring)return;let r=``;if(t.target===document||t.target===window)r=`window`;else{let e=t.target.getAttribute(`data-scroll-restoration-id`);r=e?`[data-scroll-restoration-id="${e}"]`:one(t.target)}let i=n(e.state.location);Oa.set(e=>{let t=e[i]||={},n=t[r]||={};if(r===`window`)n.scrollX=window.scrollX||0,n.scrollY=window.scrollY||0;else if(r){let e=document.querySelector(r);e&&(n.scrollX=e.scrollLeft||0,n.scrollY=e.scrollTop||0)}return e})},100),!0),e.subscribe(`onRendered`,t=>{let r=n(t.toLocation);if(!e.resetNextScroll){e.resetNextScroll=!0;return}typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation})||(ja({storageKey:Da,key:r,behavior:e.options.scrollRestorationBehavior,shouldScrollRestoration:e.isScrollRestoring,scrollToTopSelectors:e.options.scrollToTopSelectors,location:e.history.location}),e.isScrollRestoring&&Oa.set(e=>(e[r]||={},e)))})}function cne(e){if(typeof document<`u`&&document.querySelector){let t=e.state.location.state.__hashScrollIntoViewOptions??!0;if(t&&e.state.location.hash!==``){let n=document.getElementById(e.state.location.hash);n&&n.scrollIntoView(t)}}}function lne(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function Ma(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function une(e){let t=new URLSearchParams(e),n={};for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Ma(r):Array.isArray(t)?t.push(Ma(r)):n[e]=[t,Ma(r)]}return n}var dne=pne(JSON.parse),fne=mne(JSON.stringify,JSON.parse);function pne(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=une(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function mne(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=lne(e,r);return t?`?${t}`:``}}var Na=`__root__`;function hne(e){if(e.statusCode=e.statusCode||e.code||307,!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Pa(e){return e instanceof Response&&!!e.options}var Fa=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Ia=(e,t)=>!!(e.preload&&!e.router.state.matches.some(e=>e.id===t)),La=(e,t)=>{let n=e.router.routesById[t.routeId??``]??e.router.routeTree;!n.options.notFoundComponent&&e.router.options?.defaultNotFoundComponent&&(n.options.notFoundComponent=e.router.options.defaultNotFoundComponent),sa(n.options.notFoundComponent,`No notFoundComponent found. Please set a notFoundComponent on your route or provide a defaultNotFoundComponent to the router.`);let r=e.matches.find(e=>e.routeId===n.id);sa(r,`Could not find match for route: `+n.id),e.updateMatch(r.id,e=>({...e,status:`notFound`,error:t,isFetching:!1})),t.routerCode===`BEFORE_LOAD`&&n.parentRoute&&(t.routeId=n.parentRoute.id,La(e,t))},Ra=(e,t,n)=>{if(!(!Pa(n)&&!Ea(n))){if(Pa(n)&&n.redirectHandled&&!n.options.reloadDocument)throw n;if(t){t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0;let r=Pa(n)?`redirected`:`notFound`;t._nonReactive.error=n,e.updateMatch(t.id,e=>({...e,status:r,isFetching:!1,error:n})),Ea(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()}throw Pa(n)?(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n),n):(La(e,n),n)}},za=(e,t)=>{let n=e.router.getMatch(t);return!!(!e.router.isServer&&n._nonReactive.dehydrated||e.router.isServer&&n.ssr===!1)},Ba=(e,t,n,r)=>{let{id:i,routeId:a}=e.matches[t],o=e.router.looseRoutesById[a];if(n instanceof Promise)throw n;n.routerCode=r,e.firstBadMatchIndex??=t,Ra(e,e.router.getMatch(i),n);try{o.options.onError?.(n)}catch(t){n=t,Ra(e,e.router.getMatch(i),n)}e.updateMatch(i,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController}))},gne=(e,t,n,r)=>{let i=e.router.getMatch(t),a=e.matches[n-1]?.id,o=a?e.router.getMatch(a):void 0;if(e.router.isShell()){i.ssr=r.id===Na;return}if(o?.ssr===!1){i.ssr=!1;return}let s=e=>e===!0&&o?.ssr===`data-only`?`data-only`:e,c=e.router.options.defaultSsr??!0;if(r.options.ssr===void 0){i.ssr=s(c);return}if(typeof r.options.ssr!=`function`){i.ssr=s(r.options.ssr);return}let{search:l,params:u}=i,d={search:qa(l,i.searchError),params:qa(u,i.paramsError),location:e.location,matches:e.matches.map(e=>({index:e.index,pathname:e.pathname,fullPath:e.fullPath,staticData:e.staticData,id:e.id,routeId:e.routeId,search:qa(e.search,e.searchError),params:qa(e.params,e.paramsError),ssr:e.ssr}))},f=r.options.ssr(d);if(ra(f))return f.then(e=>{i.ssr=s(e??c)});i.ssr=s(f??c)},Va=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!e.router.isServer&&!Ia(e,t)&&(n.options.loader||n.options.beforeLoad||Ja(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{Fa(e)},i);r._nonReactive.pendingTimeout=t}},_ne=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Va(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Ra(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},vne=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=na(()=>{a?.resolve()});let{paramsError:o,searchError:s}=i;o&&Ba(e,n,o,`PARSE_PARAMS`),s&&Ba(e,n,s,`VALIDATE_SEARCH`),Va(e,t,r,i);let c=new AbortController,l=e.matches[n-1]?.id,u={...(l?e.router.getMatch(l):void 0)?.context??e.router.options.context??void 0,...i.__routeContext},d=!1,f=()=>{d||(d=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c,context:u})))},p=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){Bi(()=>{f(),p()});return}i._nonReactive.beforeLoadPromise=na();let{search:m,params:h,cause:g}=i,_=Ia(e,t),v={search:m,abortController:c,params:h,preload:_,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:_?`preload`:g,matches:e.matches,...e.router.options.additionalContext},y=r=>{if(r===void 0){Bi(()=>{f(),p()});return}(Pa(r)||Ea(r))&&(f(),Ba(e,n,r,`BEFORE_LOAD`)),Bi(()=>{f(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r,context:{...e.context,...r}})),p()})},b;try{if(b=r.options.beforeLoad(v),ra(b))return f(),b.catch(t=>{Ba(e,n,t,`BEFORE_LOAD`)}).then(y)}catch(t){f(),Ba(e,n,t,`BEFORE_LOAD`)}y(b)},yne=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>{if(e.router.isServer){let r=gne(e,n,t,i);if(ra(r))return r.then(s)}return s()},o=()=>vne(e,n,t,i),s=()=>{if(za(e,n))return;let t=_ne(e,n,i);return ra(t)?t.then(o):o()};return a()},Ha=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},Ua=(e,t,n,r)=>{let i=e.matchPromises[n-1],{params:a,loaderDeps:o,abortController:s,cause:c}=e.router.getMatch(t),l=e.router.options.context??{};for(let t=0;t<=n;t++){let n=e.matches[t];if(!n)continue;let r=e.router.getMatch(n.id);r&&(l={...l,...r.__routeContext??{},...r.__beforeLoadContext??{}})}let u=Ia(e,t);return{params:a,deps:o,preload:!!u,parentMatchPromise:i,abortController:s,context:l,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:u?`preload`:c,route:r,...e.router.options.additionalContext}},Wa=async(e,t,n,r)=>{try{let i=e.router.getMatch(t);try{(!e.router.isServer||i.ssr===!0)&&Ka(r);let a=r.options.loader?.(Ua(e,t,n,r)),o=r.options.loader&&ra(a);if((o||r._lazyPromise||r._componentsPromise||r.options.head||r.options.scripts||r.options.headers||i._nonReactive.minPendingPromise)&&e.updateMatch(t,e=>({...e,isFetching:`loader`})),r.options.loader){let n=o?await a:a;Ra(e,e.router.getMatch(t),n),n!==void 0&&e.updateMatch(t,e=>({...e,loaderData:n}))}r._lazyPromise&&await r._lazyPromise;let s=Ha(e,t,r),c=s?await s:void 0,l=i._nonReactive.minPendingPromise;l&&await l,r._componentsPromise&&await r._componentsPromise,e.updateMatch(t,e=>({...e,error:void 0,status:`success`,isFetching:!1,updatedAt:Date.now(),...c}))}catch(n){let a=n,o=i._nonReactive.minPendingPromise;o&&await o,Ea(n)&&await r.options.notFoundComponent?.preload?.(),Ra(e,e.router.getMatch(t),n);try{r.options.onError?.(n)}catch(n){a=n,Ra(e,e.router.getMatch(t),n)}let s=Ha(e,t,r),c=s?await s:void 0;e.updateMatch(t,e=>({...e,error:a,status:`error`,isFetching:!1,...c}))}}catch(n){let i=e.router.getMatch(t);if(i){let n=Ha(e,t,r);if(n){let r=await n;e.updateMatch(t,e=>({...e,...r}))}i._nonReactive.loaderPromise=void 0}Ra(e,i,n)}},bne=async(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=!1,a=!1,o=e.router.looseRoutesById[r];if(za(e,n)){if(e.router.isServer){let t=Ha(e,n,o);if(t){let r=await t;e.updateMatch(n,e=>({...e,...r}))}return e.router.getMatch(n)}}else{let r=e.router.getMatch(n);if(r._nonReactive.loaderPromise){if(r.status===`success`&&!e.sync&&!r.preload)return r;await r._nonReactive.loaderPromise;let t=e.router.getMatch(n),i=t._nonReactive.error||t.error;i&&Ra(e,t,i)}else{let s=Date.now()-r.updatedAt,c=Ia(e,n),l=c?o.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:o.options.staleTime??e.router.options.defaultStaleTime??0,u=o.options.shouldReload,d=typeof u==`function`?u(Ua(e,n,t,o)):u,f=!!c&&!e.router.state.matches.some(e=>e.id===n),p=e.router.getMatch(n);p._nonReactive.loaderPromise=na(),f!==p.preload&&e.updateMatch(n,e=>({...e,preload:f}));let{status:m,invalid:h}=p;if(i=m===`success`&&(h||(d??s>l)),!(c&&o.options.preload===!1))if(i&&!e.sync)a=!0,(async()=>{try{await Wa(e,n,t,o);let r=e.router.getMatch(n);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0}catch(t){Pa(t)&&await e.router.navigate(t.options)}})();else if(m!==`success`||i&&e.sync)await Wa(e,n,t,o);else{let t=Ha(e,n,o);if(t){let r=await t;e.updateMatch(n,e=>({...e,...r}))}}}}let s=e.router.getMatch(n);a||(s._nonReactive.loaderPromise?.resolve(),s._nonReactive.loadPromise?.resolve()),clearTimeout(s._nonReactive.pendingTimeout),s._nonReactive.pendingTimeout=void 0,a||(s._nonReactive.loaderPromise=void 0),s._nonReactive.dehydrated=void 0;let c=a?s.isFetching:!1;return c!==s.isFetching||s.invalid!==!1?(e.updateMatch(n,e=>({...e,isFetching:c,invalid:!1})),e.router.getMatch(n)):s};async function Ga(e){let t=Object.assign(e,{matchPromises:[]});!t.router.isServer&&t.router.state.matches.some(e=>e._forcePending)&&Fa(t);try{for(let e=0;e<t.matches.length;e++){let n=yne(t,e);ra(n)&&await n}let e=t.firstBadMatchIndex??t.matches.length;for(let n=0;n<e;n++)t.matchPromises.push(bne(t,n));await Promise.all(t.matchPromises);let n=Fa(t);ra(n)&&await n}catch(e){if(Ea(e)&&!t.preload){let n=Fa(t);throw ra(n)&&await n,e}if(Pa(e))throw e}return t.matches}async function Ka(e){if(!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0),!e._componentsLoaded&&e._componentsPromise===void 0){let t=()=>{let t=[];for(let n of Ya){let r=e.options[n]?.preload;r&&t.push(r())}if(t.length)return Promise.all(t).then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0});e._componentsLoaded=!0,e._componentsPromise=void 0};e._componentsPromise=e._lazyPromise?e._lazyPromise.then(t):t()}return e._componentsPromise}function qa(e,t){return t?{status:`error`,error:t}:{status:`success`,value:e}}function Ja(e){for(let t of Ya)if(e.options[t]?.preload)return!0;return!1}var Ya=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`];function xne(e){return{input:({url:t})=>{for(let n of e)t=Xa(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=Za(e[n],t);return t}}}function Sne(e){let t=xa(e.basepath),n=`/${t}`,r=`${n}/`,i=e.caseSensitive?n:n.toLowerCase(),a=e.caseSensitive?r:r.toLowerCase();return{input:({url:t})=>{let r=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return r===i?t.pathname=`/`:r.startsWith(a)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=_a([`/`,t,e.pathname]),e)}}function Xa(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Za(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Qa(e){let t=e.resolvedLocation,n=e.location;return{fromLocation:t,toLocation:n,pathChanged:t?.pathname!==n.pathname,hrefChanged:t?.href!==n.href,hashChanged:t?.hash!==n.hash}}var Cne=class{constructor(e){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{e.notFoundRoute&&console.warn(`The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.`);let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.pathParamsDecodeCharMap=this.options.pathParamsAllowedCharacters?new Map(this.options.pathParamsAllowedCharacters.map(e=>[encodeURIComponent(e),e])):void 0,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.isServer||(this.history=Lte())),this.origin=this.options.origin,this.origin||(!this.isServer&&window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),!this.__store&&this.latestLocation&&(this.__store=new Ite(Tne(this.latestLocation),{onUpdate:()=>{this.__store.state={...this.state,cachedMatches:this.state.cachedMatches.filter(e=>![`redirected`].includes(e.status))}}}),sne(this));let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[];xa(o)!==``&&e.push(Sne({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:xne(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.__store&&(this.__store.state={...this.state,location:this.latestLocation}),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a)`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let{routesById:e,routesByPath:t,processedTree:n}=Yte(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});this.options.routeMasks&&Wte(this.options.routeMasks,n),this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({href:e,state:n})=>{let r=new URL(e,this.origin),i=Xa(this.rewrite,r),a=this.options.parseSearch(i.search),o=this.options.stringifySearch(a);i.search=o;let s=i.href.replace(i.origin,``),{pathname:c,hash:l}=i;return{href:s,publicHref:e,url:i.href,pathname:aa(c),searchStr:o,search:Xi(t?.search,a),hash:l.split(`#`).reverse()[0]??``,state:Xi(t?.state,n)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathCache=ca(1e3),this.resolvePathWithBase=(e,t)=>tne({base:e,to:va(t),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>Ene({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{let e=this.state.matches.filter(e=>e.status===`pending`),t=this.state.matches.filter(e=>e.isFetching===`loader`);new Set([...this.state.pendingMatches??[],...e,...t]).forEach(e=>{this.cancelMatch(e.id)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=Ji(this.matchRoutes(n,{_buildLocation:!0}));t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=this.resolvePathWithBase(i,`.`),o=r.search,s={...r.params},c=t.to?this.resolvePathWithBase(a,`${t.to}`):this.resolvePathWithBase(a,`.`),l=t.params===!1||t.params===null?{}:(t.params??!0)===!0?s:Object.assign(s,Yi(t.params,s)),u=wa({path:c,params:l}).interpolatedPath,d=this.matchRoutes(u,void 0,{_buildLocation:!0}).map(e=>this.looseRoutesById[e.routeId]);if(Object.keys(l).length>0)for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;t&&Object.assign(l,t(l))}let f=e.leaveParams?c:aa(wa({path:c,params:l,decodeCharMap:this.pathParamsDecodeCharMap}).interpolatedPath),p=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,eo(t.options.validateSearch,{...e,...p}))}catch{}}),p=e}p=Dne({search:p,dest:t,destRoutes:d,_includeValidateSearch:e._includeValidateSearch}),p=Xi(o,p);let m=this.options.stringifySearch(p),h=t.hash===!0?n.hash:t.hash?Yi(t.hash,n.hash):void 0,g=h?`#${h}`:``,_=t.state===!0?n.state:t.state?Yi(t.state,n.state):{};_=Xi(n.state,_);let v=`${f}${m}${g}`,y=new URL(v,this.origin),b=Za(this.rewrite,y);return{publicHref:b.pathname+b.search+b.hash,href:v,url:b.href,pathname:f,search:p,searchStr:m,state:_,hash:h??``,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n={};if(this.options.routeMasks){let o=Gte(i.pathname,this.processedTree);if(o){Object.assign(n,o.params);let{from:i,...s}=o.route;r={from:e.from,...s,params:n},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=ta(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=ba(this.latestLocation.href)===ba(n.href),a=this.commitLocationPromise;if(this.commitLocationPromise=na(()=>{a?.resolve()}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.publicHref,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=Ki(a,{__TSR_index:e?t:t+1});o.to=n.pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,...r})=>{if(!t&&n)try{new URL(`${n}`),t=!0}catch{}if(t){if(n||=this.buildLocation({to:e,...r}).url,!r.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return r.replace?window.location.replace(n):window.location.href=n,Promise.resolve()}return this.buildAndCommitLocation({...r,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{if(this.cancelMatches(),this.updateLatestLocation(),this.isServer){let e=this.buildLocation({to:this.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0}),t=e=>{try{return encodeURI(decodeURI(e))}catch{return e}};if(xa(t(this.latestLocation.href))!==xa(t(e.href))){let t=e.url;throw this.origin&&t.startsWith(this.origin)&&(t=t.replace(this.origin,``)||`/`),hne({href:t})}}let e=this.matchRoutes(this.latestLocation);this.__store.setState(t=>({...t,status:`pending`,statusCode:200,isLoading:!0,location:this.latestLocation,pendingMatches:e,cachedMatches:t.cachedMatches.filter(t=>!e.some(e=>e.id===t.id))}))},this.load=async e=>{let t,n,r;for(r=new Promise(i=>{this.startTransition(async()=>{try{this.beforeLoad();let t=this.latestLocation,n=this.state.resolvedLocation;this.state.redirect||this.emit({type:`onBeforeNavigate`,...Qa({resolvedLocation:n,location:t})}),this.emit({type:`onBeforeLoad`,...Qa({resolvedLocation:n,location:t})}),await Ga({router:this,sync:e?.sync,matches:this.state.pendingMatches,location:t,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=[],t=[],n=[];Bi(()=>{this.__store.setState(r=>{let i=r.matches,a=r.pendingMatches||r.matches;return e=i.filter(e=>!a.some(t=>t.id===e.id)),t=a.filter(e=>!i.some(t=>t.id===e.id)),n=a.filter(e=>i.some(t=>t.id===e.id)),{...r,isLoading:!1,loadedAt:Date.now(),matches:a,pendingMatches:void 0,cachedMatches:[...r.cachedMatches,...e.filter(e=>e.status!==`error`&&e.status!==`notFound`)]}}),this.clearExpiredCache()}),[[e,`onLeave`],[t,`onEnter`],[n,`onStay`]].forEach(([e,t])=>{e.forEach(e=>{this.looseRoutesById[e.routeId].options[t]?.(e)})})})})}})}catch(e){Pa(e)?(t=e,this.isServer||this.navigate({...t.options,replace:!0,ignoreBlocker:!0})):Ea(e)&&(n=e),this.__store.setState(e=>({...e,statusCode:t?t.status:n?404:e.matches.some(e=>e.status===`error`)?500:200,redirect:t}))}this.latestLoadPromise===r&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),i()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;let i;this.hasNotFoundMatch()?i=404:this.__store.state.matches.some(e=>e.status===`error`)&&(i=500),i!==void 0&&this.__store.setState(e=>({...e,statusCode:i}))},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(delete this.shouldViewTransition,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.state.resolvedLocation,a=typeof t.types==`function`?t.types(Qa({resolvedLocation:i,location:r})):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.state.pendingMatches?.some(t=>t.id===e)?`pendingMatches`:this.state.matches.some(t=>t.id===e)?`matches`:this.state.cachedMatches.some(t=>t.id===e)?`cachedMatches`:``;n&&this.__store.setState(r=>({...r,[n]:r[n]?.map(n=>n.id===e?t(n):n)}))})},this.getMatch=e=>{let t=t=>t.id===e;return this.state.cachedMatches.find(t)??this.state.pendingMatches?.find(t)??this.state.matches.find(t)},this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.__store.setState(e=>({...e,matches:e.matches.map(t),cachedMatches:e.cachedMatches.map(t),pendingMatches:e.pendingMatches?.map(t)})),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{if(!e.options.href){let t=this.buildLocation(e.options),n=t.url;this.origin&&n.startsWith(this.origin)&&(n=n.replace(this.origin,``)||`/`),e.options.href=t.href,e.headers.set(`Location`,n)}return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.__store.setState(e=>({...e,cachedMatches:[]})):this.__store.setState(e=>({...e,cachedMatches:e.cachedMatches.filter(e=>!t(e))}))},this.clearExpiredCache=()=>{this.clearCache({filter:e=>{let t=this.looseRoutesById[e.routeId];if(!t.options.loader)return!0;let n=(e.preload?t.options.preloadGcTime??this.options.defaultPreloadGcTime:t.options.gcTime??this.options.defaultGcTime)??300*1e3;return e.status===`error`?!0:Date.now()-e.updatedAt>=n}})},this.loadRouteChunk=Ka,this.preloadRoute=async e=>{let t=this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(e=>e.id)),i=new Set([...r,...this.state.cachedMatches.map(e=>e.id)]);Bi(()=>{n.forEach(e=>{i.has(e.id)||this.__store.setState(t=>({...t,cachedMatches:[...t.cachedMatches,e]}))})});try{return n=await Ga({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Pa(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});Ea(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.state.status!==`pending`)return!1;let i=(t?.pending===void 0?!this.state.isLoading:t.pending)?this.latestLocation:this.state.resolvedLocation||this.state.location,a=Kte(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!ta(a.params,e.params,{partial:!0})?!1:t?.includeSearch??!0?ta(i.search,r.search,{partial:!0})?a.params:!1:a.params},this.hasNotFoundMatch=()=>this.__store.state.matches.some(e=>e.status===`notFound`||e.globalNotFound),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??fne,parseSearch:e.parseSearch??dne}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.__store.state}get looseRoutesById(){return this.routesById}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i}=n,{matchedRoutes:a}=n,o=!1;(r?r.path!==`/`&&i[`**`]:ba(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=(()=>{if(o){if(this.options.notFoundMode!==`root`)for(let e=a.length-1;e>=0;e--){let t=a[e];if(t.children)return t.id}return Na}})(),c=[],l=e=>e?.id?e.context??this.options.context??void 0:this.options.context??void 0;return a.forEach((n,r)=>{let a=c[r-1],[o,u,d]=(()=>{let r=a?.search??e.search,i=a?._strictSearch??void 0;try{let e=eo(n.options.validateSearch,{...r})??void 0;return[{...r,...e},{...i,...e},void 0]}catch(e){let n=e;if(e instanceof $a||(n=new $a(e.message,{cause:e})),t?.throwOnError)throw n;return[r,{},n]}})(),f=n.options.loaderDeps?.({search:o})??``,p=f?JSON.stringify(f):``,{interpolatedPath:m,usedParams:h}=wa({path:n.fullPath,params:i,decodeCharMap:this.pathParamsDecodeCharMap}),g=n.id+m+p,_=this.getMatch(g),v=this.state.matches.find(e=>e.routeId===n.id),y=_?._strictParams??h,b;if(!_){let e=n.options.params?.parse??n.options.parseParams;if(e)try{Object.assign(y,e(y))}catch(e){if(b=Ea(e)||Pa(e)?e:new wne(e.message,{cause:e}),t?.throwOnError)throw b}}Object.assign(i,y);let x=v?`stay`:`enter`,S;if(_)S={..._,cause:x,params:v?Xi(v.params,i):i,_strictParams:y,search:Xi(v?v.search:_.search,o),_strictSearch:u};else{let e=n.options.loader||n.options.beforeLoad||n.lazyFn||Ja(n)?`pending`:`success`;S={id:g,index:r,routeId:n.id,params:v?Xi(v.params,i):i,_strictParams:y,pathname:m,updatedAt:Date.now(),search:v?Xi(v.search,o):o,_strictSearch:u,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:b,__routeContext:void 0,_nonReactive:{loadPromise:na()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:x,loaderDeps:v?Xi(v.loaderDeps,f):f,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:n.options.staticData||{},fullPath:n.fullPath}}t?.preload||(S.globalNotFound=s===n.id),S.searchError=d;let C=l(a);S.context={...C,...S.__routeContext,...S.__beforeLoadContext},c.push(S)}),c.forEach((n,r)=>{let i=this.looseRoutesById[n.routeId];if(!this.getMatch(n.id)&&t?._buildLocation!==!0){let t=c[r-1],a=l(t);if(i.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c};n.__routeContext=i.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}),c}},$a=class extends Error{},wne=class extends Error{};function Tne(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],pendingMatches:[],cachedMatches:[],statusCode:200}}function eo(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new $a(`Async validation not supported`);if(n.issues)throw new $a(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Ene({pathname:e,routesById:t,processedTree:n}){let r={},i=ba(e),a,o=qte(i,n,!0);return o&&(a=o.route,Object.assign(r,o.params)),{matchedRoutes:o?.branch||[t.__root__],routeParams:r,foundRoute:a}}function Dne({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){let i=n.reduce((e,t)=>{let n=[];return`search`in t.options?t.options.search?.middlewares&&n.push(...t.options.search.middlewares):(t.options.preSearchFilters||t.options.postSearchFilters)&&n.push(({search:e,next:n})=>{let r=e;`preSearchFilters`in t.options&&t.options.preSearchFilters&&(r=t.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=n(r);return`postSearchFilters`in t.options&&t.options.postSearchFilters?t.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),r&&t.options.validateSearch&&n.push(({search:e,next:n})=>{let r=n(e);try{return{...r,...eo(t.options.validateSearch,r)??void 0}}catch{return r}}),e.concat(n)},[])??[];i.push(({search:e})=>t.search?t.search===!0?e:Yi(t.search,e):{});let a=(e,t)=>{if(e>=i.length)return t;let n=i[e];return n({search:t,next:t=>a(e+1,t)})};return a(0,e)}var One=`Error preloading route! ☝️`,to=class{constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=Na:this.parentRoute||sa(!1,`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);let r=n?Na:t?.path;r&&r!==`/`&&(r=ya(r));let i=t?.id||r,a=n?Na:_a([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=_a([`/`,a]));let o=a===`__root__`?`/`:_a([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=o},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}},kne=class{constructor({id:e}){this.notFound=e=>Ta({routeId:this.id,...e}),this.id=e}},Ane=class extends to{constructor(e){super(e)}};function no(e){let t=e.errorComponent??ro;return(0,J.jsx)(jne,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?Y.createElement(t,{error:n,reset:r}):e.children})}var jne=class extends Y.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromProps(e){return{resetKey:e.getResetKey()}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidUpdate(e,t){t.error&&t.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.resetKey===this.props.getResetKey()?this.state.error:null,reset:()=>{this.reset()}})}};function ro({error:e}){let[t,n]=Y.useState(!1);return(0,J.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,J.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,J.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,J.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,J.jsx)(`div`,{children:(0,J.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,J.jsx)(`code`,{children:e.message}):null})}):null]})}function Mne({children:e,fallback:t=null}){return Nne()?(0,J.jsx)(Y.Fragment,{children:e}):(0,J.jsx)(Y.Fragment,{children:t})}function Nne(){return Y.useSyncExternalStore(Pne,()=>!0,()=>!1)}function Pne(){return()=>{}}var Fne=!0;function io(e,t){if(!Fne){if(e)return;var n=`Warning: `+t;typeof console<`u`&&console.warn(n);try{throw Error(n)}catch{}}}var Ine=see();function Lne(e,t=e=>e,n={}){let r=n.equal??Rne;return(0,Ine.useSyncExternalStoreWithSelector)(e.subscribe,()=>e.state,()=>e.state,t,r)}function Rne(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=ao(e);if(n.length!==ao(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function ao(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var oo=Y.createContext(null);function so(){return typeof document>`u`?oo:window.__TSR_ROUTER_CONTEXT__?window.__TSR_ROUTER_CONTEXT__:(window.__TSR_ROUTER_CONTEXT__=oo,oo)}function co(e){let t=Y.useContext(so());return io(!((e?.warn??!0)&&!t),`useRouter must be used inside a <RouterProvider> component!`),t}function lo(e){let t=co({warn:e?.router===void 0}),n=e?.router||t,r=(0,Y.useRef)(void 0);return Lne(n.__store,t=>{if(e?.select){if(e.structuralSharing??n.options.defaultStructuralSharing){let n=Xi(r.current,e.select(t));return r.current=n,n}return e.select(t)}return t})}var uo=Y.createContext(void 0),zne=Y.createContext(void 0);function fo(e){let t=Y.useContext(e.from?zne:uo);return lo({select:n=>{let r=n.matches.find(n=>e.from?e.from===n.routeId:n.id===t);if(sa(!((e.shouldThrow??!0)&&!r),`Could not find ${e.from?`an active match from "${e.from}"`:`a nearest match!`}`),r!==void 0)return e.select?e.select(r):r},structuralSharing:e.structuralSharing})}function po(e){return fo({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function mo(e){let{select:t,...n}=e;return fo({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function ho(e){return fo({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function go(e){return fo({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}var _o=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function vo(e){let t=Y.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function Bne(e,t,n={},r={}){Y.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function Vne(e){let t=Y.useRef(null);return Y.useImperativeHandle(e,()=>t.current,[]),t}function yo(e){let t=co();return Y.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Hne(e,t){let n=co(),[r,i]=Y.useState(!1),a=Y.useRef(!1),o=Vne(t),{activeProps:s,inactiveProps:c,activeOptions:l,to:u,preload:d,preloadDelay:f,hashScrollIntoView:p,replace:m,startTransition:h,resetScroll:g,viewTransition:_,children:v,target:y,disabled:b,style:x,className:S,onClick:C,onFocus:w,onMouseEnter:T,onMouseLeave:E,onTouchStart:D,ignoreBlocker:O,params:k,search:A,hash:j,state:M,mask:N,reloadDocument:P,unsafeRelative:F,from:I,_fromLocation:L,...R}=e,z=lo({select:e=>e.location.search,structuralSharing:!0}),B=e.from,V=Y.useMemo(()=>({...e,from:B}),[n,z,B,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),ee=Y.useMemo(()=>n.buildLocation({...V}),[n,V]),te=Y.useMemo(()=>{if(b)return;let e=ee.maskedLocation?ee.maskedLocation.url:ee.url,t=!1;return n.origin&&(e.startsWith(n.origin)?e=n.history.createHref(e.replace(n.origin,``))||`/`:t=!0),{href:e,external:t}},[b,ee.maskedLocation,ee.url,n.origin,n.history]),ne=Y.useMemo(()=>{if(te?.external)return te.href;try{return new URL(u),u}catch{}},[u,te]),re=e.reloadDocument||ne?!1:d??n.options.defaultPreload,ie=f??n.options.defaultPreloadDelay??0,ae=lo({select:e=>{if(ne)return!1;if(l?.exact){if(!ene(e.location.pathname,ee.pathname,n.basepath))return!1}else{let t=Sa(e.location.pathname,n.basepath),r=Sa(ee.pathname,n.basepath);if(!(t.startsWith(r)&&(t.length===r.length||t[r.length]===`/`)))return!1}return(l?.includeSearch??!0)&&!ta(e.location.search,ee.search,{partial:!l?.exact,ignoreUndefined:!l?.explicitUndefined})?!1:l?.includeHash?e.location.hash===ee.hash:!0}}),oe=Y.useCallback(()=>{n.preloadRoute({...V}).catch(e=>{console.warn(e),console.warn(One)})},[n,V]);Bne(o,Y.useCallback(e=>{e?.isIntersecting&&oe()},[oe]),qne,{disabled:!!b||re!==`viewport`}),Y.useEffect(()=>{a.current||!b&&re===`render`&&(oe(),a.current=!0)},[b,oe,re]);let se=e=>{let t=e.currentTarget.getAttribute(`target`),r=y===void 0?t:y;if(!b&&!Jne(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Kr.flushSync)(()=>{i(!0)});let t=n.subscribe(`onResolved`,()=>{t(),i(!1)});n.navigate({...V,replace:m,resetScroll:g,hashScrollIntoView:p,startTransition:h,viewTransition:_,ignoreBlocker:O})}};if(ne)return{...R,ref:o,href:ne,...v&&{children:v},...y&&{target:y},...b&&{disabled:b},...x&&{style:x},...S&&{className:S},...C&&{onClick:C},...w&&{onFocus:w},...T&&{onMouseEnter:T},...E&&{onMouseLeave:E},...D&&{onTouchStart:D}};let ce=e=>{b||re&&oe()},le=ce,ue=e=>{if(!(b||!re))if(!ie)oe();else{let t=e.target;if(xo.has(t))return;let n=setTimeout(()=>{xo.delete(t),oe()},ie);xo.set(t,n)}},de=e=>{if(b||!re||!ie)return;let t=e.target,n=xo.get(t);n&&(clearTimeout(n),xo.delete(t))},fe=ae?Yi(s,{})??Une:bo,pe=ae?bo:Yi(c,{})??bo,me=[S,fe.className,pe.className].filter(Boolean).join(` `),he=(x||fe.style||pe.style)&&{...x,...fe.style,...pe.style};return{...R,...fe,...pe,href:te?.href,ref:o,onClick:So([C,se]),onFocus:So([w,ce]),onMouseEnter:So([T,ue]),onMouseLeave:So([E,de]),onTouchStart:So([D,le]),disabled:!!b,target:y,...he&&{style:he},...me&&{className:me},...b&&Wne,...ae&&Gne,...r&&Kne}}var bo={},Une={className:`active`},Wne={role:`link`,"aria-disabled":!0},Gne={"data-status":`active`,"aria-current":`page`},Kne={"data-transitioning":`transitioning`},xo=new WeakMap,qne={rootMargin:`100px`},So=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}},Co=Y.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,ref:a,...o}=Hne(r,t),s=typeof r.children==`function`?r.children({isActive:o[`data-status`]===`active`}):r.children;return n===void 0&&delete o.disabled,Y.createElement(n||`a`,{...o,ref:a},s)});function Jne(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Yne(e){return new Xne({id:e})}var Xne=class extends kne{constructor({id:e}){super({id:e}),this.useMatch=e=>fo({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>mo({...e,from:this.id,strict:!1}),this.useLoaderData=e=>po({...e,from:this.id,strict:!1}),this.useNavigate=()=>yo({from:co().routesById[this.id].fullPath}),this.notFound=e=>Ta({routeId:this.id,...e}),this.Link=Y.forwardRef((e,t)=>{let n=co().routesById[this.id].fullPath;return(0,J.jsx)(Co,{ref:t,from:n,...e})})}},Zne=class extends to{constructor(e){super(e),this.useMatch=e=>fo({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>mo({...e,from:this.id}),this.useLoaderData=e=>po({...e,from:this.id}),this.useNavigate=()=>yo({from:this.fullPath}),this.Link=Y.forwardRef((e,t)=>(0,J.jsx)(Co,{ref:t,from:this.fullPath,...e})),this.$$typeof=Symbol.for(`react.memo`)}};function wo(e){return new Zne(e)}var Qne=class extends Ane{constructor(e){super(e),this.useMatch=e=>fo({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>mo({...e,from:this.id}),this.useLoaderData=e=>po({...e,from:this.id}),this.useNavigate=()=>yo({from:this.fullPath}),this.Link=Y.forwardRef((e,t)=>(0,J.jsx)(Co,{ref:t,from:this.fullPath,...e})),this.$$typeof=Symbol.for(`react.memo`)}};function To(e){return new Qne(e)}function Eo(e){return typeof e==`object`?new Do(e,{silent:!0}).createRoute(e):new Do(e,{silent:!0}).createRoute}var Do=class{constructor(e,t){this.path=e,this.createRoute=e=>{io(this.silent,`FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.`);let t=wo(e);return t.isRoot=!1,t},this.silent=t?.silent}},Oo=class{constructor(e){this.useMatch=e=>fo({select:e?.select,from:this.options.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>fo({from:this.options.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>go({select:e?.select,structuralSharing:e?.structuralSharing,from:this.options.id}),this.useParams=e=>ho({select:e?.select,structuralSharing:e?.structuralSharing,from:this.options.id}),this.useLoaderDeps=e=>mo({...e,from:this.options.id}),this.useLoaderData=e=>po({...e,from:this.options.id}),this.useNavigate=()=>yo({from:co().routesById[this.options.id].fullPath}),this.options=e,this.$$typeof=Symbol.for(`react.memo`)}};function ko(e){return typeof e==`object`?new Oo(e):t=>new Oo({id:e,...t})}function $ne(){let e=co(),t=Y.useRef({router:e,mounted:!1}),[n,r]=Y.useState(!1),{hasPendingMatches:i,isLoading:a}=lo({select:e=>({isLoading:e.isLoading,hasPendingMatches:e.matches.some(e=>e.status===`pending`)}),structuralSharing:!0}),o=vo(a),s=a||n||i,c=vo(s),l=a||i,u=vo(l);return e.startTransition=e=>{r(!0),Y.startTransition(()=>{e(),r(!1)})},Y.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return ba(e.latestLocation.href)!==ba(n.href)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),_o(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),_o(()=>{o&&!a&&e.emit({type:`onLoad`,...Qa(e.state)})},[o,e,a]),_o(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...Qa(e.state)})},[l,u,e]),_o(()=>{if(c&&!s){let t=Qa(e.state);e.emit({type:`onResolved`,...t}),e.__store.setState(e=>({...e,status:`idle`,resolvedLocation:e.location})),t.hrefChanged&&cne(e)}},[s,c,e]),null}function ere(e){let t=lo({select:e=>`not-found-${e.location.pathname}-${e.status}`});return(0,J.jsx)(no,{getResetKey:()=>t,onCatch:(t,n)=>{if(Ea(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(Ea(t))return e.fallback?.(t);throw t},children:e.children})}function tre(){return(0,J.jsx)(`p`,{children:`Not Found`})}function Ao(e){return(0,J.jsx)(J.Fragment,{children:e.children})}function jo(e,t,n){return t.options.notFoundComponent?(0,J.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,J.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,J.jsx)(tre,{})}function nre({children:e}){let t=co();return t.isServer?(0,J.jsx)(`script`,{nonce:t.options.ssr?.nonce,className:`$tsr`,dangerouslySetInnerHTML:{__html:e+`;typeof $_TSR !== "undefined" && $_TSR.c()`}}):null}function rre(){let e=co();if(!e.isScrollRestoring||!e.isServer||typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return null;let t=(e.options.getScrollRestorationKey||ka)(e.latestLocation),n=t===ka(e.latestLocation)?void 0:t,r={storageKey:Da,shouldScrollRestoration:!0};return n&&(r.key=n),(0,J.jsx)(nre,{children:`(${ja.toString()})(${JSON.stringify(r)})`})}var Mo=Y.memo(function({matchId:e}){let t=co(),n=lo({select:t=>{let n=t.matches.find(t=>t.id===e);return sa(n,`Could not find match for matchId "${e}". Please file an issue!`),{routeId:n.routeId,ssr:n.ssr,_displayPending:n._displayPending}},structuralSharing:!0}),r=t.routesById[n.routeId],i=r.options.pendingComponent??t.options.defaultPendingComponent,a=i?(0,J.jsx)(i,{}):null,o=r.options.errorComponent??t.options.defaultErrorComponent,s=r.options.onCatch??t.options.defaultOnCatch,c=r.isRoot?r.options.notFoundComponent??t.options.notFoundRoute?.options.component:r.options.notFoundComponent,l=n.ssr===!1||n.ssr===`data-only`,u=(!r.isRoot||r.options.wrapInSuspense||l)&&(r.options.wrapInSuspense??i??(r.options.errorComponent?.preload||l))?Y.Suspense:Ao,d=o?no:Ao,f=c?ere:Ao,p=lo({select:e=>e.loadedAt}),m=lo({select:t=>{let n=t.matches.findIndex(t=>t.id===e);return t.matches[n-1]?.routeId}});return(0,J.jsxs)(r.isRoot?r.options.shellComponent??Ao:Ao,{children:[(0,J.jsx)(uo.Provider,{value:e,children:(0,J.jsx)(u,{fallback:a,children:(0,J.jsx)(d,{getResetKey:()=>p,errorComponent:o||ro,onCatch:(t,n)=>{if(Ea(t))throw t;io(!1,`Error in route match: ${e}`),s?.(t,n)},children:(0,J.jsx)(f,{fallback:e=>{if(!c||e.routeId&&e.routeId!==n.routeId||!e.routeId&&!r.isRoot)throw e;return Y.createElement(c,e)},children:l||n._displayPending?(0,J.jsx)(Mne,{fallback:a,children:(0,J.jsx)(No,{matchId:e})}):(0,J.jsx)(No,{matchId:e})})})})}),m===`__root__`&&t.options.scrollRestoration?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ire,{}),(0,J.jsx)(rre,{})]}):null]})});function ire(){let e=co(),t=Y.useRef(void 0);return(0,J.jsx)(`script`,{suppressHydrationWarning:!0,ref:n=>{n&&(t.current===void 0||t.current.href!==e.latestLocation.href)&&(e.emit({type:`onRendered`,...Qa(e.state)}),t.current=e.latestLocation)}},e.latestLocation.state.__TSR_key)}var No=Y.memo(function({matchId:e}){let t=co(),{match:n,key:r,routeId:i}=lo({select:n=>{let r=n.matches.find(t=>t.id===e),i=r.routeId,a=(t.routesById[i].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:i,loaderDeps:r.loaderDeps,params:r._strictParams,search:r._strictSearch});return{key:a?JSON.stringify(a):void 0,routeId:i,match:{id:r.id,status:r.status,error:r.error,_forcePending:r._forcePending,_displayPending:r._displayPending}}},structuralSharing:!0}),a=t.routesById[i],o=Y.useMemo(()=>{let e=a.options.component??t.options.defaultComponent;return e?(0,J.jsx)(e,{},r):(0,J.jsx)(Po,{})},[r,a.options.component,t.options.defaultComponent]);if(n._displayPending)throw t.getMatch(n.id)?._nonReactive.displayPendingPromise;if(n._forcePending)throw t.getMatch(n.id)?._nonReactive.minPendingPromise;if(n.status===`pending`){let e=a.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let r=t.getMatch(n.id);if(r&&!r._nonReactive.minPendingPromise&&!t.isServer){let t=na();r._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),r._nonReactive.minPendingPromise=void 0},e)}}throw t.getMatch(n.id)?._nonReactive.loadPromise}if(n.status===`notFound`)return sa(Ea(n.error),`Expected a notFound error`),jo(t,a,n.error);if(n.status===`redirected`)throw sa(Pa(n.error),`Expected a redirect error`),t.getMatch(n.id)?._nonReactive.loadPromise;if(n.status===`error`){if(t.isServer)return(0,J.jsx)((a.options.errorComponent??t.options.defaultErrorComponent)||ro,{error:n.error,reset:void 0,info:{componentStack:``}});throw n.error}return o}),Po=Y.memo(function(){let e=co(),t=Y.useContext(uo),n=lo({select:e=>e.matches.find(e=>e.id===t)?.routeId}),r=e.routesById[n],i=lo({select:e=>{let n=e.matches.find(e=>e.id===t);return sa(n,`Could not find parent match for matchId "${t}"`),n.globalNotFound}}),a=lo({select:e=>{let n=e.matches;return n[n.findIndex(e=>e.id===t)+1]?.id}}),o=e.options.defaultPendingComponent?(0,J.jsx)(e.options.defaultPendingComponent,{}):null;if(i)return jo(e,r,void 0);if(!a)return null;let s=(0,J.jsx)(Mo,{matchId:a});return n===`__root__`?(0,J.jsx)(Y.Suspense,{fallback:o,children:s}):s});function are(){let e=co(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,J.jsx)(t,{}):null,r=(0,J.jsxs)(e.isServer||typeof document<`u`&&e.ssr?Ao:Y.Suspense,{fallback:n,children:[!e.isServer&&(0,J.jsx)($ne,{}),(0,J.jsx)(ore,{})]});return e.options.InnerWrap?(0,J.jsx)(e.options.InnerWrap,{children:r}):r}function ore(){let e=co(),t=lo({select:e=>e.matches[0]?.id}),n=lo({select:e=>e.loadedAt}),r=t?(0,J.jsx)(Mo,{matchId:t}):null;return(0,J.jsx)(uo.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,J.jsx)(no,{getResetKey:()=>n,errorComponent:ro,onCatch:e=>{io(!1,`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`),io(!1,e.message||e.toString())},children:r})})}var Fo=e=>new sre(e),sre=class extends Cne{constructor(e){super(e)}};typeof globalThis<`u`?(globalThis.createFileRoute=Eo,globalThis.createLazyFileRoute=ko):typeof window<`u`&&(window.createFileRoute=Eo,window.createLazyFileRoute=ko);function cre({router:e,children:t,...n}){Object.keys(n).length>0&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,J.jsx)(so().Provider,{value:e,children:t});return e.options.Wrap?(0,J.jsx)(e.options.Wrap,{children:r}):r}function Io({router:e,...t}){return(0,J.jsx)(cre,{router:e,...t,children:(0,J.jsx)(are,{})})}function Lo(e){return lo({select:t=>e?.select?e.select(t.location):t.location})}function lre(e){let t=new MutationObserver(t=>{for(let n of t)n.attributeName===`class`&&e()});return t.observe(document.documentElement,{attributes:!0}),()=>t.disconnect()}function ure(){return document.documentElement.classList.contains(`dark`)}function dre(){return!1}function Ro(){return(0,Y.useSyncExternalStore)(lre,ure,dre)}var zo=[`/dashboard`,`/config`,`/git`,`/specs`,`/changes`,`/board`,`/archive`,`/settings`,`/terminal`],fre=[`/dashboard`,`/config`,`/specs`,`/changes`,`/board`,`/archive`,`/settings`],Bo=B()?[]:[`/git`,`/terminal`],pre=[`/search`,`/notifications`,`/opsx-new`,`/opsx-propose`,`/opsx-verify`,`/opsx-compose`];function Vo(){return z(`nav-layout`,window.location)}function mre(e){return z(`nav-layout:${encodeURIComponent(e)}`,window.location)}var hre=300;function gre(e){return zo.includes(e)}function _re(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&gre(e)):[]}function Ho(e){if(typeof e!=`object`||!e)return null;let t=e;return!Array.isArray(t.mainTabs)||!Array.isArray(t.bottomTabs)?null:{mainTabs:_re(t.mainTabs),bottomTabs:_re(t.bottomTabs),updatedAt:typeof t.updatedAt==`number`?t.updatedAt:0}}function vre(e,t){if(typeof e!=`object`||!e)return{__TSR_index:0,key:t,__TSR_key:t};let n=e,r=typeof n.key==`string`?n.key:t,i=typeof n.__TSR_key==`string`?n.__TSR_key:r,a=typeof n.__TSR_index==`number`?n.__TSR_index:0;return{...n,key:r,__TSR_key:i,__TSR_index:a}}function Uo(e,t){let n=new URL(e,`http://nav.local`),r=`${n.pathname}${n.search}${n.hash}`,i=Math.random().toString(36).slice(2);return{href:r,pathname:n.pathname||`/`,search:n.search,hash:n.hash,state:vre(t,i)}}function Wo(e){let t=e.trim();if(!t||t===`./`||t===`.`)return`/`;let n=t.startsWith(`/`)?t:`/${t}`;return(n.endsWith(`/`)?n:`${n}/`).replace(/\/+/g,`/`)}function Go(e,t){return t===`/`?e||`/`:e===t.slice(0,-1)?`/`:e.startsWith(t)?e.slice(t.length-1)||`/`:e||`/`}function yre(e,t){if(t===`/`)return e||`/`;let n=e.startsWith(`/`)?e:`/${e}`;return n===`/`?t.slice(0,-1)||`/`:`${t.slice(0,-1)}${n}`}function Ko(e){if(typeof window>`u`)return e;let t=new URL(e,window.location.origin),n=Wo(ee());return t.pathname=Go(t.pathname,n),`${t.pathname}${t.search}${t.hash}`}function bre(e,t){for(let n of[`api`,`session`]){let r=t.searchParams.get(n);r&&!e.searchParams.has(n)&&e.searchParams.set(n,r)}}function qo(e){for(let t of zo)if(e===t||e.startsWith(t+`/`))return t;return null}function Jo(e,t){if(t===`pop`)return null;let n=t===`main`?e.mainLocation:e.bottomLocation,r=t===`main`?e.mainTabs:e.bottomTabs,i=qo(n.pathname);return i&&r.includes(i)?i:null}function Yo(e){return pre.some(t=>e===t||e.startsWith(t+`/`))}function Xo(e,t){if(Yo(t))return`pop`;let n=qo(t);return n&&e.bottomTabs.includes(n)?`bottom`:`main`}function Zo(e){let t=new Set,n=[],r=[];for(let r of e.mainTabs)t.has(r)||(n.push(r),t.add(r));for(let n of e.bottomTabs)t.has(n)||(r.push(n),t.add(n));for(let e of zo)t.has(e)||(Bo.includes(e)?r.push(e):n.push(e));return{mainTabs:n,bottomTabs:r}}function Qo(e,t){if(t.length===0)return Uo(`/`);let n=qo(e.pathname);return n&&!t.includes(n)?Uo(`/`):e}function $o(e,t){if(t.length===0)return Uo(`/`);if(e.pathname===`/`)return Uo(`/`,e.state);let n=qo(e.pathname);return!n||!t.includes(n)?Uo(`/`):e}function es(e){return e.pathname===`/`?Uo(`/`,e.state):Yo(e.pathname)?e:Uo(`/`)}function ts(e){let t=Zo({mainTabs:e.mainTabs,bottomTabs:e.bottomTabs});return{...e,mainTabs:t.mainTabs,bottomTabs:t.bottomTabs,mainLocation:Qo(e.mainLocation,t.mainTabs),bottomLocation:$o(e.bottomLocation,t.bottomTabs),popLocation:es(e.popLocation)}}function ns(e,t){let n=new URL(e.href),r=Wo(ee());n.pathname=Go(n.pathname,r);let i=n.searchParams.get(`_b`),a=n.searchParams.get(`_p`);n.searchParams.delete(`_b`),n.searchParams.delete(`_p`);let o=window.history.state,s=Uo(`${n.pathname}${n.search}${n.hash}`,o?.main),c=Uo(i??`/`,o?.bottom),l=Uo(a??`/`,o?.pop);if(!i&&!a){let e=Xo(t,s.pathname);e===`bottom`?(c=s,s=Uo(`/`,o?.main)):e===`pop`&&(l=s,s=Uo(`/`,o?.main))}return{main:Qo(s,t.mainTabs),bottom:$o(c,t.bottomTabs),pop:es(l)}}function rs(e){let t=new URL(window.location.href),n=new URL(e.mainLocation.href,window.location.origin),r=Wo(ee());return n.pathname=yre(n.pathname,r),bre(n,t),n.searchParams.delete(`_b`),n.searchParams.delete(`_p`),e.bottomTabs.length>0&&n.searchParams.set(`_b`,e.bottomLocation.href),e.popLocation.pathname!==`/`&&n.searchParams.set(`_p`,e.popLocation.href),`${n.pathname}${n.search}${n.hash}`}function is(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function xre(){return{mainTabs:[...fre],bottomTabs:[...Bo],updatedAt:0,mainLocation:Uo(`/dashboard`),bottomLocation:Uo(`/`),popLocation:Uo(`/`)}}function Sre(){try{let e=localStorage.getItem(Vo());return e?Ho(JSON.parse(e)):null}catch{return null}}function Cre(e){try{let t=localStorage.getItem(e);return t?Ho(JSON.parse(t)):null}catch{return null}}function as(e,t=Vo()){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}var wre=[({prevState:e,nextState:t,event:n})=>{if(n.type!==`MOVE_TAB`)return t;let r=e.bottomTabs.includes(n.tabId)?`bottom`:`main`;if(Jo(e,r)!==n.tabId)return t;let i=r===`main`?e.mainLocation:e.bottomLocation,a=Uo(i.href,i.state);return n.targetArea===`main`?{...t,mainLocation:a}:{...t,bottomLocation:a}},({nextState:e})=>e.mainTabs.length===0||Jo(e,`main`)!=null?e:{...e,mainLocation:Uo(e.mainTabs[0])}];function os(e,t,n){let r=t;for(let t of wre)r=t({prevState:e,nextState:r,event:n});return r}function ss(e,t){switch(t.type){case`NAVIGATE`:{let n=t.sourceArea===`pop`?`pop`:Xo(e,t.location.pathname);return{nextState:n===`main`?{...e,mainLocation:t.location}:n===`bottom`?{...e,bottomLocation:t.location}:{...e,popLocation:t.location},changed:!0,urlAction:t.action,notify:n===t.sourceArea?[]:[{area:n,type:t.action}],persist:`none`}}case`POPSTATE`:return{nextState:{...e,mainLocation:t.mainLocation,bottomLocation:t.bottomLocation,popLocation:t.popLocation},changed:!0,notify:[{area:`main`,type:`BACK`},{area:`bottom`,type:`BACK`},{area:`pop`,type:`BACK`}],persist:`none`};case`MOVE_TAB`:{let n=e.bottomTabs.includes(t.tabId)?`bottom`:`main`;if(n===t.targetArea)return{nextState:e,changed:!1,notify:[],persist:`none`};let r=e.mainTabs.filter(e=>e!==t.tabId),i=e.bottomTabs.filter(e=>e!==t.tabId),a=t.targetArea===`main`?[...r,t.tabId]:r,o=t.targetArea===`bottom`?[...i,t.tabId]:i,s=e.mainLocation,c=e.bottomLocation;return qo((n===`main`?e.mainLocation:e.bottomLocation).pathname)===t.tabId&&(n===`main`?s=Uo(`/`):c=Uo(`/`)),{nextState:{...e,mainTabs:a,bottomTabs:o,mainLocation:s,bottomLocation:c},changed:!0,urlAction:`REPLACE`,notify:[{area:`main`,type:`REPLACE`},{area:`bottom`,type:`REPLACE`}],persist:`local_and_remote`}}case`REORDER`:{let n=t.area===`main`?e.mainTabs:e.bottomTabs,r=new Set(n),i=t.tabIds.filter(e=>r.has(e));for(let e of n)i.includes(e)||i.push(e);return is(n,i)?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:t.area===`main`?{...e,mainTabs:i}:{...e,bottomTabs:i},changed:!0,notify:[],persist:`local_and_remote`}}case`CLOSE_TAB`:{let n=e.bottomTabs.includes(t.tabId),r=e.mainTabs.includes(t.tabId);return!n&&!r?{nextState:e,changed:!1,notify:[],persist:`none`}:n?qo(e.bottomLocation.pathname)===t.tabId?{nextState:{...e,bottomLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`}:qo(e.mainLocation.pathname)===t.tabId?{nextState:{...e,mainLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`}}case`ACTIVATE_BOTTOM`:return Xo(e,t.location.pathname)===`bottom`?{nextState:{...e,bottomLocation:t.location},changed:!0,urlAction:`PUSH`,notify:[{area:`bottom`,type:`PUSH`}],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`};case`DEACTIVATE_BOTTOM`:return e.bottomLocation.pathname===`/`?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:{...e,bottomLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`};case`ACTIVATE_POP`:return Xo(e,t.location.pathname)===`pop`?{nextState:{...e,popLocation:t.location},changed:!0,urlAction:`PUSH`,notify:[{area:`pop`,type:`PUSH`}],persist:`none`}:{nextState:e,changed:!1,notify:[],persist:`none`};case`DEACTIVATE_POP`:return e.popLocation.pathname===`/`?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:{...e,popLocation:Uo(`/`)},changed:!0,urlAction:`REPLACE`,notify:[],persist:`none`};case`APPLY_LAYOUT`:{let n=Zo(t.layout);return!(t.layout.updatedAt!==e.updatedAt||!is(e.mainTabs,n.mainTabs)||!is(e.bottomTabs,n.bottomTabs))||!t.force&&t.layout.updatedAt<=e.updatedAt?{nextState:e,changed:!1,notify:[],persist:`none`}:{nextState:{...e,mainTabs:n.mainTabs,bottomTabs:n.bottomTabs,updatedAt:t.layout.updatedAt},changed:!0,urlAction:`REPLACE`,notify:[{area:`main`,type:`REPLACE`},{area:`bottom`,type:`REPLACE`}],persist:`local_only`}}}}function cs(e,t,n){return n===`main`?e.mainLocation.href!==t.mainLocation.href:n===`bottom`?e.bottomLocation.href!==t.bottomLocation.href:e.popLocation.href!==t.popLocation.href}function Tre(e,t,n){let r=[...e];for(let e of[`main`,`bottom`,`pop`])cs(t,n,e)&&(r.some(t=>t.area===e)||r.push({area:e,type:`REPLACE`}));return r}var ls=new class{mainHistory=null;bottomHistory=null;popHistory=null;state=xre();listeners=new Set;snapshotCache=null;persistTimer=null;kvUnsubscribe=null;initialized=!1;storageKey=typeof window>`u`?`nav-layout`:z(`nav-layout`,window.location);constructor(){if(typeof window>`u`)return;let e=B()?null:Sre();if(e!=null){let t=Zo(e);this.state={...this.state,mainTabs:t.mainTabs,bottomTabs:t.bottomTabs,updatedAt:e.updatedAt}}let t=ns(window.location,this.state),n=ts({...this.state,mainLocation:t.main,bottomLocation:t.bottom,popLocation:t.pop});n=ts(os(n,n,{type:`BOOTSTRAP`})),this.state=n,this.normalizeUrl(),window.addEventListener(`popstate`,this.handlePopState)}setHistoryRef(e,t){e===`main`?this.mainHistory=t:e===`bottom`?this.bottomHistory=t:this.popHistory=t}getLocation(e){return e===`main`?this.state.mainLocation:e===`bottom`?this.state.bottomLocation:this.state.popLocation}push(e,t,n){this.dispatch({type:`NAVIGATE`,sourceArea:e,action:`PUSH`,location:Uo(Ko(t),n)})}replace(e,t,n){this.dispatch({type:`NAVIGATE`,sourceArea:e,action:`REPLACE`,location:Uo(Ko(t),n)})}createHref(e,t,n){if(typeof window>`u`)return t;let{nextState:r}=this.computeTransition({type:`NAVIGATE`,sourceArea:e,action:`PUSH`,location:Uo(Ko(t),n)});return rs(r)}get mainTabs(){return this.state.mainTabs}get bottomTabs(){return this.state.bottomTabs}getAreaForPath(e){return Xo(this.state,e)}moveTab(e,t){this.dispatch({type:`MOVE_TAB`,tabId:e,targetArea:t})}reorder(e,t){this.dispatch({type:`REORDER`,area:e,tabIds:t})}closeTab(e){this.dispatch({type:`CLOSE_TAB`,tabId:e})}activateBottom(e){this.dispatch({type:`ACTIVATE_BOTTOM`,location:Uo(e)})}deactivateBottom(){this.dispatch({type:`DEACTIVATE_BOTTOM`})}activatePop(e){this.dispatch({type:`ACTIVATE_POP`,location:Uo(e)})}deactivatePop(){this.dispatch({type:`DEACTIVATE_POP`})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getSnapshot(){if(this.snapshotCache)return this.snapshotCache;let e=qo(this.state.bottomLocation.pathname);return this.snapshotCache={mainTabs:[...this.state.mainTabs],bottomTabs:[...this.state.bottomTabs],mainLocation:this.state.mainLocation,bottomLocation:this.state.bottomLocation,popLocation:this.state.popLocation,bottomActive:e!=null&&this.state.bottomTabs.includes(e),popActive:this.state.popLocation.pathname!==`/`},this.snapshotCache}async init(){if(!(this.initialized||B())){this.initialized=!0;try{let e=await this.resolveProjectScopedStorageKey();e&&e!==this.storageKey&&(this.storageKey=e,this.rebindProjectScopedLayout(e));let{trpcClient:t}=await c(async()=>{let{trpcClient:e}=await import(`./trpc-DriEPW9x.js`);return{trpcClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])),n=Ho(await t.kv.get.query({key:this.storageKey}));n?n.updatedAt>this.state.updatedAt?this.dispatch({type:`APPLY_LAYOUT`,layout:n}):this.state.updatedAt>n.updatedAt&&t.kv.set.mutate({key:this.storageKey,value:{mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:this.state.updatedAt}}).catch(()=>{}):this.state.updatedAt>0&&t.kv.set.mutate({key:this.storageKey,value:{mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:this.state.updatedAt}}).catch(()=>{});let r=t.kv.subscribe.subscribe({key:this.storageKey},{onData:e=>{let t=Ho(e);t&&this.dispatch({type:`APPLY_LAYOUT`,layout:t})}});this.kvUnsubscribe=()=>r.unsubscribe()}catch{}}}destroy(){typeof window<`u`&&window.removeEventListener(`popstate`,this.handlePopState),this.cancelPersistTimer(),this.kvUnsubscribe&&=(this.kvUnsubscribe(),null)}handlePopState=()=>{let e=ns(window.location,this.state);this.dispatch({type:`POPSTATE`,mainLocation:e.main,bottomLocation:e.bottom,popLocation:e.pop})};computeTransition(e){let t=ss(this.state,e);if(!t.changed)return{transition:t,nextState:this.state};let n=os(this.state,t.nextState,e);return n=ts(n),{transition:t,nextState:n}}dispatch(e){if(typeof window<`u`&&e.type!==`POPSTATE`&&this.mainHistory==null){let e=ns(window.location,this.state);this.state=ts({...this.state,mainLocation:e.main,bottomLocation:e.bottom,popLocation:e.pop})}let t=ss(this.state,e);if(!t.changed)return;let n=this.state,r=os(n,t.nextState,e);r=ts(r),this.state=r,t.persist===`local_and_remote`?this.persistLayout():t.persist===`local_only`&&(this.cancelPersistTimer(),as({mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:this.state.updatedAt},this.storageKey));let i=t.urlAction??(cs(n,this.state,`main`)||cs(n,this.state,`bottom`)||cs(n,this.state,`pop`)?`REPLACE`:void 0);i&&this.syncToUrl(i);let a=Tre(t.notify,n,this.state);this.notifyRouters(a),this.notifyListeners()}notifyRouters(e){for(let t of e)(t.area===`main`?this.mainHistory:t.area===`bottom`?this.bottomHistory:this.popHistory)?.notify({type:t.type})}notifyListeners(){this.snapshotCache=null;for(let e of this.listeners)e()}syncToUrl(e){let t=rs(this.state),n=`${window.location.pathname}${window.location.search}${window.location.hash}`;if(e===`REPLACE`&&t===n)return;let r={main:this.state.mainLocation.state,bottom:this.state.bottomLocation.state,pop:this.state.popLocation.state};e===`PUSH`?window.history.pushState(r,``,t):window.history.replaceState(r,``,t)}normalizeUrl(){let e=rs(this.state);if(e===`${window.location.pathname}${window.location.search}${window.location.hash}`)return;let t={main:this.state.mainLocation.state,bottom:this.state.bottomLocation.state,pop:this.state.popLocation.state};window.history.replaceState(t,``,e)}cancelPersistTimer(){this.persistTimer&&=(clearTimeout(this.persistTimer),null)}persistLayout(){let e=Date.now();this.state={...this.state,updatedAt:e},as({mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:e},this.storageKey),this.cancelPersistTimer(),this.persistTimer=setTimeout(()=>{this.persistTimer=null,c(async()=>{let{trpcClient:e}=await import(`./trpc-DriEPW9x.js`);return{trpcClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({trpcClient:t})=>t.kv.set.mutate({key:this.storageKey,value:{mainTabs:this.state.mainTabs,bottomTabs:this.state.bottomTabs,updatedAt:e}})).catch(()=>{})},hre)}async resolveProjectScopedStorageKey(){try{let e=await M(O());if(!e.ok)return null;let t=await e.json();return typeof t.projectDir!=`string`||t.projectDir.length===0?null:mre(t.projectDir)}catch{return null}}rebindProjectScopedLayout(e){let t=Cre(e);if(t){this.dispatch({type:`APPLY_LAYOUT`,layout:t,force:!0});return}this.state=ts({...this.state,updatedAt:0}),this.normalizeUrl(),this.notifyListeners()}};typeof window<`u`&&!B()&&ls.init();function us(){return(0,Y.useSyncExternalStore)(e=>ls.subscribe(e),()=>ls.getSnapshot(),()=>ls.getSnapshot())}function ds(e){let t=R();if(!t)return;let n=new URLSearchParams(e.hash.slice(1));n.set(I,t),e.hash=n.toString()}function Ere(e){let{handoff:t,location:n}=e,r=new URL(n.href),i=new URL(t.serverUrl);return k({search:n.search}).hosted?(i.pathname=r.pathname,i.search=r.search,i.hash=r.hash,i.searchParams.set(`api`,t.serverUrl),ds(i),i.toString()):(i.pathname=r.pathname,i.search=r.search,i.hash=r.hash,ds(i),i.toString())}function fs(e){window.location.assign(Ere(e))}var ps=`gitScope`;function ms(e){return new URLSearchParams(e).get(`gitScope`)===`planning`?`planning`:`code`}function hs(e){return e.type===`commit`?e.hash:`uncommitted`}function gs(e,t,n=``){let r=new URLSearchParams(n);t===`planning`?r.set(ps,t):r.delete(ps);let i=r.toString();return`${e}${i?`?${i}`:``}`}function _s(e,t,n){return n.type===`commit`?[`git`,e,t,`meta`,`commit`,n.hash]:[`git`,e,t,`meta`,`uncommitted`]}function Dre(e,t,n){return n.type===`commit`?[`git`,e,t,`files`,`commit`,n.hash]:[`git`,e,t,`files`,`uncommitted`]}function Ore(e,t,n,r){return[`git`,e,t,`patch`,n.type===`commit`?`commit:${n.hash}`:`uncommitted`,r]}function kre(e){return e.type===`commit`?{type:`commit`,hash:e.hash}:{type:`uncommitted`}}function Are(e,t=`code`,n=``){return gs(e.type===`commit`?`/git/commit/${e.hash}`:`/git/uncommitted`,t,n)}function vs(e,t=`code`,n=``){return Are(kre(e),t,n)}var jre={"7d":7,"30d":30,"90d":90,all:null},Mre=/^(\d{4})-(\d{2})-(\d{2})(?:-|$)/;function ys(e){let t=Mre.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=Date.UTC(n,r-1,i),o=new Date(a);return!Number.isFinite(a)||o.getUTCFullYear()!==n||o.getUTCMonth()!==r-1||o.getUTCDate()!==i?null:a}function bs(e){return ys(e.id)??e.updatedAt}function Nre(e,t,n=Date.now()){let r=jre[t];return r===null?!0:bs(e)>=n-r*24*60*60*1e3}function Pre(e,t){return t.updatedAt-e.updatedAt||e.id.localeCompare(t.id)}function Fre(e){return[...e].sort(Pre)}function xs(e,t=10){return Fre(e).slice(0,Math.max(0,Math.trunc(t)))}function Ire(e,t=10){return[...e].sort((e,t)=>bs(t)-bs(e)||e.id.localeCompare(t.id)).slice(0,Math.max(0,Math.trunc(t)))}var Ss=[`timeout`,`memory-limit`,`runtime`,`abort`];async function Lre(e,t={}){let n=new AbortController,r=[],i=t.signal,a=Rre(t.timeoutMs);if(i)if(i.aborted)n.abort(i.reason);else{let e=()=>n.abort(i.reason);i.addEventListener(`abort`,e,{once:!0}),r.push(()=>i.removeEventListener(`abort`,e))}if(n.signal.aborted)return r.forEach(e=>e()),{ok:!1,error:Cs(n.signal.reason,i)};let o,s,c=Promise.resolve().then(()=>e(n.signal));c.catch(()=>void 0);let l=[c];n.signal.aborted||l.push(new Promise((e,t)=>{let i=()=>t(new DOMException(`Translation cancelled.`,`AbortError`));n.signal.addEventListener(`abort`,i,{once:!0}),r.push(()=>n.signal.removeEventListener(`abort`,i))})),a!==void 0&&l.push(new Promise((e,t)=>{o=setTimeout(()=>{s=Error(`Translation task timed out after ${a}ms.`),n.abort(s),t(s)},a)}));try{return{ok:!0,value:await Promise.race(l)}}catch(e){return n.abort(e),s&&n.signal.reason===s?{ok:!1,error:{kind:`timeout`,message:s.message}}:{ok:!1,error:Cs(e,i)}}finally{o&&clearTimeout(o),r.forEach(e=>e())}}function Cs(e,t){if(Hre(e))return e;if(t?.aborted)return{kind:`abort`,message:ws(t.reason)??`Translation cancelled.`};if(e instanceof DOMException&&e.name===`AbortError`)return{kind:`abort`,message:ws(e)??`Translation cancelled.`};let n=zre(e);return Bre(n)?{kind:`timeout`,message:n}:Vre(n)?{kind:`memory-limit`,message:n}:{kind:`runtime`,message:n}}function Rre(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}function zre(e){return e instanceof Error&&e.message.trim().length>0?e.message:typeof e==`string`&&e.trim().length>0?e:`Translation failed.`}function ws(e){if(e instanceof Error&&e.message.trim().length>0)return e.message;if(typeof e==`string`&&e.trim().length>0)return e}function Bre(e){return/\btime(?:d)?\s*out\b/i.test(e)}function Vre(e){return/out of memory/i.test(e)||/memory limit/i.test(e)||/insufficient memory/i.test(e)||/ERR_WORKER_OUT_OF_MEMORY/i.test(e)}function Hre(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`kind`),n=Reflect.get(e,`message`);return typeof t==`string`&&Ss.includes(t)&&typeof n==`string`&&n.length>0}var Ts=[`browser`,`local`,`local-ct2`,`local-llama`,`openai`],Es=l(Ts),Ds=`browser`;function Os(e){return e===`local`||e===`local-ct2`||e===`local-llama`}function ks(e){return e===`local`||e===`local-ct2`}l([`local`,`local-ct2`,`local-llama`,`openai`]);var As=15e3,js=l([`not-downloaded`,`queued`,`downloading`,`paused`,`downloaded`,`error`,`deleting`]),Ms=m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),required:f(),etag:S().min(1).optional(),revision:S().min(1).optional(),sourceUrl:S().min(1).optional(),raw:T().optional()}),Ure=m({id:S().min(1),label:S().min(1),description:S().optional(),profile:S().min(1).optional(),dtype:S().min(1).optional(),estimatedTotalBytes:x().int().nonnegative().optional(),baseGroupId:S().min(1).optional(),commitHash:S().min(1).optional(),shortCommitHash:S().min(1).optional(),rootDir:S().min(1).optional(),status:js.optional(),progress:x().min(0).max(1).optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),resumable:f().optional(),error:S().optional(),selectable:f(),selected:f(),files:p(Ms)}),Wre=l([`idle`,`loading`,`ready`,`error`]),Gre=m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),required:f(),etag:S().min(1).optional(),revision:S().min(1).optional(),sourceUrl:S().min(1).optional(),raw:T().optional()}),Kre=m({id:S().min(1),baseGroupId:S().min(1),label:S().min(1),displayLabel:S().min(1),description:S().optional(),profile:S().min(1).optional(),dtype:S().min(1).optional(),commitHash:S().min(1),shortCommitHash:S().min(1),rootDir:S().min(1),estimatedTotalBytes:x().int().nonnegative().optional(),selectable:f(),files:p(Gre)}),qre=m({modelId:S().min(1),source:v(`huggingface`),endpoint:S().default(``),revision:S().min(1),commitHash:S().min(1),shortCommitHash:S().min(1),fetchedAt:x().int().nonnegative(),updatedAt:x().int().nonnegative(),raw:T().optional(),groups:_(S(),Kre).default({}),groupOrder:p(S().min(1)).default([])}),Jre=m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),downloadedBytes:x().int().nonnegative().optional(),required:f().default(!0),status:js.default(`not-downloaded`),updatedAt:x().int().nonnegative().optional(),error:S().optional()}),Yre=m({groupId:S().min(1),baseGroupId:S().min(1).optional(),status:js.default(`not-downloaded`),rootDir:S().min(1).optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),progress:x().min(0).max(1).optional(),resumable:f().default(!1),error:S().optional(),installedAt:x().int().nonnegative().optional(),updatedAt:x().int().nonnegative().optional(),files:p(Jre).default([])}),Ns=m({status:Wre.default(`idle`),message:S().optional(),error:S().optional(),updatedAt:x().int().nonnegative().optional()});m({engineId:l([`local`,`local-ct2`,`local-llama`]),modelId:S().min(1),selectedGroupId:S().min(1).optional(),groupId:S().min(1).optional(),status:js,message:S(),progress:x().min(0).max(1).optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),sessionId:S().optional(),resumable:f().optional(),files:p(m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),downloadedBytes:x().int().nonnegative().optional()})).optional(),updatedAt:x().int().nonnegative()});var Xre=m({modelId:S().min(1),estimatedTotalBytes:x().int().nonnegative().optional(),files:p(Ms),profile:S().min(1).optional(),selectedGroupId:S().min(1).optional(),groups:p(Ure).optional()});m({modelId:S().min(1),version:v(2).default(2),status:js.default(`not-downloaded`),selected:f().default(!1),selectedGroupId:S().min(1).optional(),installedAt:x().int().nonnegative().optional(),updatedAt:x().int().nonnegative().optional(),bytesDownloaded:x().int().nonnegative().optional(),totalBytes:x().int().nonnegative().optional(),progress:x().min(0).max(1).optional(),resumable:f().default(!1),error:S().optional(),profileLoad:Ns.default(Ns.parse({})),profileManifest:qre.optional(),groupsState:_(S(),Yre).default({}),plan:Xre.optional(),files:p(m({path:S().min(1),sizeBytes:x().int().nonnegative().optional(),downloadedBytes:x().int().nonnegative().optional()})).default([])}),l([`local`,`network`,`recommended`]);var Zre=l([`installed`,`installing`,`missing`,`error`,`not-applicable`]),Qre=l([`ready`,`probing`,`failed`,`error`,`not-applicable`]),$re=l([`ready`,`missing`,`downloading`,`error`,`not-applicable`]),Ps=m({message:S().optional(),progress:x().min(0).max(1).optional(),error:S().optional()}),Fs=m({dependency:Ps.extend({state:Zre}),runtime:Ps.extend({state:Qre}),assets:Ps.extend({state:$re}),summary:S().optional()});function Is(e={}){return{dependency:{state:`not-applicable`,...e.dependency},runtime:{state:`not-applicable`,...e.runtime},assets:{state:`not-applicable`,...e.assets},...e.summary?{summary:e.summary}:{}}}function eie(e){return e.dependency.state===`installed`||e.dependency.state===`not-applicable`}function tie(e){return e.runtime.state===`ready`||e.runtime.state===`not-applicable`}function Ls(e){return e?!eie(e)||!tie(e):!1}function Rs(e){if(e)return e.summary??e.runtime.error??e.runtime.message??e.dependency.error??e.dependency.message??e.assets.error??e.assets.message}var zs=l([`stdout`,`stderr`]);m({stream:zs,text:S()}),P(`type`,[m({type:v(`status`),lifecycle:Fs}),m({type:v(`log`),stream:zs,text:S()}),m({type:v(`exit`),lifecycle:Fs})]);var nie=[{id:`browser`,label:`Browser`,description:`Uses the browser Translator API and future browser-side providers.`,technicalSummary:`Browser-native Web Translator adapter. Package payload is about 5 KB; browser language packs are managed by the browser.`,runtime:`browser`,kind:`browser`,installDescription:`Browser translation support is built into the browser runtime.`,moduleName:`@openspecui/browser-translator`,factoryExport:`createBrowserTranslatorFactory`},{id:`local`,label:`Local-Transformers`,description:`Runs an ONNX Runtime-backed local translation adapter through Transformers.js with managed ONNX model files.`,technicalSummary:`Server-side ONNX Runtime adapter via Transformers.js. Runtime package is installed on demand; selected ONNX model groups are downloaded separately and can range from tens to hundreds of MB.`,runtime:`server`,kind:`managed-local`,settingsKey:`local`,defaultModel:`Xenova/nllb-200-distilled-600M`,runtimePackageName:`@huggingface/transformers`,installDescription:`Install the Local-Transformers runtime package to enable server-side translation.`,modelLabel:`Local Model`,downloadGroupsLabel:`Local download profiles`,refreshTooltip:`Refresh local model profiles`,moduleName:`@openspecui/local-translator`,factoryExport:`createLocalTranslatorFactory`},{id:`local-ct2`,label:`Local-CT2`,description:`Runs a bundled local CTranslate2 translation runtime with managed model files.`,technicalSummary:`Server-side native CTranslate2 adapter. Runtime package is installed on demand; selected model artifacts are downloaded separately and can range from tens to hundreds of MB.`,runtime:`server`,kind:`managed-local`,settingsKey:`localCt2`,defaultModel:`ooeoeo/opus-mt-en-zh-ct2-float16`,runtimePackageName:`ctranslate2`,installDescription:`Install the Local-CT2 runtime package to enable server-side translation.`,modelLabel:`CT2 Model`,downloadGroupsLabel:`Local CT2 download groups`,refreshTooltip:`Refresh local model artifacts`,moduleName:`@openspecui/local-ct2-translator`,factoryExport:`createLocalCt2TranslatorFactory`},{id:`local-llama`,label:`Local-Llama`,description:`Runs a local GGUF translation-capable LLM through node-llama-cpp with managed GGUF model files.`,technicalSummary:`Server-side llama.cpp adapter via node-llama-cpp. Runtime package is installed on demand; selected GGUF model files are downloaded separately and can range from hundreds of MB to multiple GB.`,runtime:`server`,kind:`managed-local`,settingsKey:`localLlama`,defaultModel:`bartowski/Qwen2.5-0.5B-Instruct-GGUF`,runtimePackageName:`node-llama-cpp`,installDescription:`Install the Local-Llama runtime package to enable server-side GGUF translation.`,modelLabel:`Llama Model`,downloadGroupsLabel:`Local GGUF files`,refreshTooltip:`Refresh local GGUF artifacts`,moduleName:`@openspecui/local-llama-translator`,factoryExport:`createLocalLlamaTranslatorFactory`},{id:`openai`,label:`OpenAI-Completion`,description:`Uses an OpenAI-compatible TanStack AI completion provider for context-aware translation.`,technicalSummary:`Server-side TanStack AI adapter for OpenAI-compatible APIs. Package payload is about 5 KB; model size stays with the remote provider.`,runtime:`server`,kind:`remote-provider`,settingsKey:`openai`,defaultModel:`gpt-4.1-mini`,installDescription:`OpenAI completion translation is bundled with the server runtime.`,moduleName:`@openspecui/openai-completion-translator`,factoryExport:`createOpenAICompletionTranslatorFactory`}];function Bs(e){let t=nie.find(t=>t.id===e);if(!t)throw Error(`Unknown translation engine: ${e}`);return t}function rie(e){let t=Bs(e);if(t.kind!==`managed-local`)throw Error(`Translation engine ${e} is not a managed-local engine.`);return t}var Vs=m({baseUrl:S().default(``),token:S().default(``),model:S().default(`gpt-4.1-mini`)}),iie=m({baseUrl:S().optional(),token:S().optional(),model:S().optional()}),Hs=m({model:S().default(`Xenova/nllb-200-distilled-600M`),selectedGroupId:S().optional(),hfEndpoint:S().default(``),memoryBudgetPercent:x().min(0).max(100).default(25)}),aie=m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional(),hfEndpoint:S().optional(),memoryBudgetPercent:x().min(0).max(100).optional()}),Us=m({model:S().default(`ooeoeo/opus-mt-en-zh-ct2-float16`),selectedGroupId:S().optional(),hfEndpoint:S().default(``),memoryBudgetPercent:x().min(0).max(100).default(25)}),oie=m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional(),hfEndpoint:S().optional(),memoryBudgetPercent:x().min(0).max(100).optional()}),Ws=m({model:S().default(`bartowski/Qwen2.5-0.5B-Instruct-GGUF`),selectedGroupId:S().optional(),hfEndpoint:S().default(``),memoryBudgetPercent:x().min(0).max(100).default(25)}),sie=m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional(),hfEndpoint:S().optional(),memoryBudgetPercent:x().min(0).max(100).optional()});m({engineId:Es.default(Ds),openai:Vs.default(Vs.parse({})),local:Hs.default(Hs.parse({})),localCt2:Us.default(Us.parse({})),localLlama:Ws.default(Ws.parse({}))}),m({engineId:Es.optional(),openai:iie.optional(),local:aie.optional(),localCt2:oie.optional(),localLlama:sie.optional()}),m({engineId:Es,sourceLanguage:S().min(1),targetLanguage:S().min(1),model:S().min(1).optional(),selectedGroupId:S().min(1).optional(),inputs:p(S()).min(1),instructions:S().optional(),context:S().optional(),timeoutMs:x().int().positive().default(As)}),m({index:x().int().nonnegative(),output:S().optional(),error:m({kind:l(Ss),message:S().min(1)}).optional()});var Gs=l([`direct`,`bilingual`]),cie=m({local:m({model:S().min(1).optional(),selectedGroupId:S().min(1).optional()}).default({}),localCt2:m({model:S().min(1).optional(),selectedGroupId:S().min(1).optional()}).default({}),localLlama:m({model:S().min(1).optional(),selectedGroupId:S().min(1).optional()}).default({}),openai:m({model:S().min(1).optional()}).default({})}).default({}),lie=m({local:m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional()}).optional(),localCt2:m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional()}).optional(),localLlama:m({model:S().min(1).optional(),selectedGroupId:S().min(1).nullable().optional()}).optional(),openai:m({model:S().min(1).optional()}).optional()}),Ks=m({enabled:f().default(!1),targetLanguage:S().min(1).default(`zh`),displayMode:Gs.default(`direct`),cacheEnabled:f().default(!1),engineId:Es.default(Ds),engines:cie});m({enabled:f().optional(),targetLanguage:S().min(1).optional(),displayMode:Gs.optional(),cacheEnabled:f().optional(),engineId:Es.optional(),engines:lie.optional()});var qs=1e4,Js=2e5;m({entryLimit:x().int().min(100).max(Js).default(qs)}),m({entryLimit:x().int().min(100).max(Js).optional()}),m({key:S().min(1),keyHash:S().min(1),sourceText:S(),translatedText:S(),targetNodesJson:S().optional(),sourceLanguage:S().min(1),targetLanguage:S().min(1),placeholderTopologyHash:S().min(1),attributeTopologyHash:S().min(1),displayPolicyVersion:x().int().positive(),engineId:Es.default(Ds),engineVersion:S().optional(),model:S().optional(),translatorContractVersion:x().int().positive().default(1),createdAt:x().int().nonnegative(),lastAccessedAt:x().int().nonnegative()}).omit({createdAt:!0,lastAccessedAt:!0}),m({keyHash:S().min(1)}),m({enabled:f(),entryLimit:x().int().positive(),entries:x().int().nonnegative(),databasePath:S().optional()});var uie=`project`,die=/^[A-Za-z]:\//;function Ys(e){return e.replace(/\\/g,`/`).replace(/\/+$/g,``)}function fie(e){return e.startsWith(`/`)||die.test(e)}function pie(e){return e.replace(/^\.?\//,``)}function Xs(e){return Ys(e).split(`/`).filter(Boolean)}function mie(e){let t=Ys(e),n=/(?:^|\/)node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(@[^/]+\/[^/]+|[^/]+)(\/.*)?/.exec(t),r=n?.[1];return r?`npm:${r}${n[2]??``}`:null}function Zs(e){return`${uie}:${pie(e)}`}function hie(e,t){let n=Ys(e),r=Ys(t),i=n.toLowerCase(),a=r.toLowerCase();return a===i||a.startsWith(`${i}/`)}function gie(e,t){let n=Xs(e),r=Xs(t),i=0;for(;i<n.length&&i<r.length&&n[i]?.toLowerCase()===r[i]?.toLowerCase();)i+=1;return r.slice(i).join(`/`)}function _ie(e){let t=Xs(e),n=t.lastIndexOf(`openspec`);return n<0?null:t.slice(n).join(`/`)}function Qs(e,t){let n=Ys(e),r=mie(n);return(t?.source===`package`||r)&&r?r:fie(n)?t?.projectDir&&hie(t.projectDir,n)?Zs(gie(t.projectDir,n)):Zs(_ie(n)||Xs(n).slice(-4).join(`/`)):Zs(n)}var $s=Symbol.for(`yaml.alias`),ec=Symbol.for(`yaml.document`),tc=Symbol.for(`yaml.map`),nc=Symbol.for(`yaml.pair`),rc=Symbol.for(`yaml.scalar`),ic=Symbol.for(`yaml.seq`),ac=Symbol.for(`yaml.node.type`),oc=e=>!!e&&typeof e==`object`&&e[ac]===$s,sc=e=>!!e&&typeof e==`object`&&e[ac]===ec,cc=e=>!!e&&typeof e==`object`&&e[ac]===tc,lc=e=>!!e&&typeof e==`object`&&e[ac]===nc,uc=e=>!!e&&typeof e==`object`&&e[ac]===rc,dc=e=>!!e&&typeof e==`object`&&e[ac]===ic;function fc(e){if(e&&typeof e==`object`)switch(e[ac]){case tc:case ic:return!0}return!1}function pc(e){if(e&&typeof e==`object`)switch(e[ac]){case $s:case tc:case rc:case ic:return!0}return!1}var mc=e=>(uc(e)||fc(e))&&!!e.anchor,hc=Symbol(`break visit`),gc=Symbol(`skip children`),_c=Symbol(`remove node`);function vc(e,t){let n=Sc(t);sc(e)?yc(null,e.contents,n,Object.freeze([e]))===_c&&(e.contents=null):yc(null,e,n,Object.freeze([]))}vc.BREAK=hc,vc.SKIP=gc,vc.REMOVE=_c;function yc(e,t,n,r){let i=Cc(e,t,n,r);if(pc(i)||lc(i))return wc(e,r,i),yc(e,i,n,r);if(typeof i!=`symbol`){if(fc(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=yc(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===hc)return hc;else i===_c&&(t.items.splice(e,1),--e)}}else if(lc(t)){r=Object.freeze(r.concat(t));let e=yc(`key`,t.key,n,r);if(e===hc)return hc;e===_c&&(t.key=null);let i=yc(`value`,t.value,n,r);if(i===hc)return hc;i===_c&&(t.value=null)}}return i}async function bc(e,t){let n=Sc(t);sc(e)?await xc(null,e.contents,n,Object.freeze([e]))===_c&&(e.contents=null):await xc(null,e,n,Object.freeze([]))}bc.BREAK=hc,bc.SKIP=gc,bc.REMOVE=_c;async function xc(e,t,n,r){let i=await Cc(e,t,n,r);if(pc(i)||lc(i))return wc(e,r,i),xc(e,i,n,r);if(typeof i!=`symbol`){if(fc(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await xc(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===hc)return hc;else i===_c&&(t.items.splice(e,1),--e)}}else if(lc(t)){r=Object.freeze(r.concat(t));let e=await xc(`key`,t.key,n,r);if(e===hc)return hc;e===_c&&(t.key=null);let i=await xc(`value`,t.value,n,r);if(i===hc)return hc;i===_c&&(t.value=null)}}return i}function Sc(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Cc(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(cc(t))return n.Map?.(e,t,r);if(dc(t))return n.Seq?.(e,t,r);if(lc(t))return n.Pair?.(e,t,r);if(uc(t))return n.Scalar?.(e,t,r);if(oc(t))return n.Alias?.(e,t,r)}function wc(e,t,n){let r=t[t.length-1];if(fc(r))r.items[e]=n;else if(lc(r))e===`key`?r.key=n:r.value=n;else if(sc(r))r.contents=n;else{let e=oc(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var vie={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},yie=e=>e.replace(/[!,[\]{}]/g,e=>vie[e]),Tc=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+yie(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&pc(e.contents)){let t={};vc(e.contents,(e,n)=>{pc(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
8
8
  `)}};Tc.defaultYaml={explicit:!1,version:`1.2`},Tc.defaultTags={"!!":`tag:yaml.org,2002:`};function Ec(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Dc(e){let t=new Set;return vc(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function Oc(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function bie(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Dc(e);let a=Oc(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(uc(t.node)||fc(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function kc(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=kc(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=kc(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=kc(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=kc(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function Ac(e,t,n){if(Array.isArray(e))return e.map((e,t)=>Ac(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!mc(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var jc=class{constructor(e){Object.defineProperty(this,ac,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!sc(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=Ac(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?kc(i,{"":o},``,o):o}},Mc=class extends jc{constructor(e){super($s),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],vc(e,{Node:(e,t)=>{(oc(t)||mc(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(Ac(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Nc(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Ec(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Nc(e,t,n){if(oc(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(fc(t)){let r=0;for(let i of t.items){let t=Nc(e,i,n);t>r&&(r=t)}return r}else if(lc(t)){let r=Nc(e,t.key,n),i=Nc(e,t.value,n);return Math.max(r,i)}return 1}var Pc=e=>!e||typeof e!=`function`&&typeof e!=`object`,Fc=class extends jc{constructor(e){super(rc),this.value=e}toJSON(e,t){return t?.keep?this.value:Ac(this.value,e,t)}toString(){return String(this.value)}};Fc.BLOCK_FOLDED=`BLOCK_FOLDED`,Fc.BLOCK_LITERAL=`BLOCK_LITERAL`,Fc.PLAIN=`PLAIN`,Fc.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Fc.QUOTE_SINGLE=`QUOTE_SINGLE`;var xie=`tag:yaml.org,2002:`;function Sie(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Ic(e,t,n){if(sc(e)&&(e=e.contents),pc(e))return e;if(lc(e)){let t=n.schema[tc].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new Mc(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=xie+t.slice(2));let l=Sie(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Fc(e);return c&&(c.node=t),t}l=e instanceof Map?o[tc]:Symbol.iterator in Object(e)?o[ic]:o[tc]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Fc(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Lc(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Ic(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Rc=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,zc=class extends jc{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>pc(t)||lc(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Rc(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(fc(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Lc(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(fc(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&uc(i)?i.value:i:fc(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!lc(t))return!1;let n=t.value;return n==null||e&&uc(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return fc(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(fc(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Lc(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Cie=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Bc(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Vc=(e,t,n)=>e.endsWith(`
9
9
  `)?Bc(n,t):n.includes(`
10
10
  `)?`
@@ -880,7 +880,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
880
880
  <div class="pixi-host">
881
881
  <div class="edge-glow"></div>
882
882
  </div>
883
- `}};customElements.define(`virtual-trackpad-tab`,Lme);function Rme(e){return new URLSearchParams(e.search).get(`session`)?.trim()||null}function jx(e,t=window.location){let n=Rme(t);return n?`hosted-session:${n}:${e}`:e}var Mx=1.5,Nx=30,zme=50,Px=15;function Fx(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Ix(e){return e instanceof HTMLElement&&e.classList.contains(`terminal-touch-mouse-overlay`)}function Bme(e,t,n){let r=document.elementFromPoint(t,n);if(r&&Ix(r)){let e=r,i=e.style.pointerEvents;e.style.pointerEvents=`none`,r=document.elementFromPoint(t,n),e.style.pointerEvents=i}return r&&e.contains(r)&&!Ix(r)?r:e.querySelector(`.xterm-screen`)??e}function Lx(e){return e===`input`||e===`keys`||e===`shortcuts`||e===`trackpad`||e===`settings`}function Vme(e){return e===`copy`||e===`paste`||e===`select-all`}function Rx(e){return typeof e==`object`&&!!e}function zx(){try{let e=localStorage.getItem(jx(`xtermInputPanelState`));if(!e)return{};let t=JSON.parse(e);return Rx(t)?t:{}}catch{return{}}}function Hme(e){try{localStorage.setItem(jx(`xtermInputPanelState`),JSON.stringify(e))}catch{}}function Ume(e){let t=zx().sessions;if(!t)return null;let n=t[e];if(!Rx(n))return null;let r={activeTab:`input`,inputDraft:``};return Lx(n.activeTab)&&(r.activeTab=n.activeTab),typeof n.inputDraft==`string`&&(r.inputDraft=n.inputDraft),r}function Bx(){let e=zx();return Lx(e.lastActiveTab)?e.lastActiveTab:`input`}var Vx=class e{static _lastActiveTab=`input`;static _active=null;static _lastFocused=null;static _instances=new Set;static _onActiveChangeFn=null;static _mountTarget=null;static get activeInstance(){return e._active}static set onActiveChange(t){e._onActiveChangeFn=t}static set mountTarget(t){e._mountTarget=t,e._fabEl&&t&&t.appendChild(e._fabEl)}static get mountTarget(){return e._mountTarget}static _fabEl=null;static _fabSubscriberCount=0;static _ensureFab(t){if(e._fabEl){e._fabEl.parentElement!==t&&t.appendChild(e._fabEl);return}let n=document.createElement(`button`);n.type=`button`,n.title=`Open InputPanel`,n.replaceChildren(Ob(24)),Object.assign(n.style,{position:`fixed`,zIndex:`50`,width:`56px`,height:`56px`,borderRadius:`50%`,border:`2px solid currentColor`,display:`flex`,alignItems:`center`,justifyContent:`center`,touchAction:`none`,userSelect:`none`,webkitUserSelect:`none`,webkitTouchCallout:`none`,cursor:`pointer`,boxShadow:`0 4px 12px rgba(0,0,0,0.3)`,background:`var(--primary, #e04a2f)`,color:`var(--primary-foreground, #fff)`,padding:`0`,margin:`0`,outline:`none`});let r=window.innerWidth-72,i=window.innerHeight-140;try{let e=localStorage.getItem(`input-panel-fab-pos`);if(e){let t=JSON.parse(e);r=t.x??r,i=t.y??i}}catch{}r=Math.max(0,Math.min(window.innerWidth-56,r)),i=Math.max(0,Math.min(window.innerHeight-56,i)),n.style.left=`${r}px`,n.style.top=`${i}px`;let a=!1,o=!1,s=0,c=0,l=0,u=0,d=()=>{let t=e._lastFocused,n=(t&&e._instances.has(t)?t:null)??[...e._instances].find(e=>e._terminal!=null)??null;n&&(e._lastFocused=n,n.open())};n.addEventListener(`pointerdown`,e=>{a=!0,o=!1,s=e.clientX,c=e.clientY,l=parseInt(n.style.left)||0,u=parseInt(n.style.top)||0,n.setPointerCapture(e.pointerId),e.preventDefault()}),n.addEventListener(`pointermove`,e=>{if(!a)return;let t=e.clientX-s,r=e.clientY-c;(Math.abs(t)>4||Math.abs(r)>4)&&(o=!0);let i=Math.max(0,Math.min(window.innerWidth-56,l+t)),d=Math.max(0,Math.min(window.innerHeight-56,u+r));n.style.left=`${i}px`,n.style.top=`${d}px`}),n.addEventListener(`pointerup`,()=>{if(a){a=!1;try{localStorage.setItem(`input-panel-fab-pos`,JSON.stringify({x:parseInt(n.style.left),y:parseInt(n.style.top)}))}catch{}o||d()}}),n.addEventListener(`pointercancel`,()=>{a=!1});let f=!1;n.addEventListener(`pointerdown`,()=>{f=!0},{capture:!0}),n.addEventListener(`click`,()=>{if(f){f=!1;return}d()}),n.addEventListener(`contextmenu`,e=>{e.preventDefault(),e.stopPropagation()}),n.addEventListener(`dragstart`,e=>{e.preventDefault()}),window.addEventListener(`resize`,()=>{let e=Math.min(parseInt(n.style.left)||0,window.innerWidth-56),t=Math.min(parseInt(n.style.top)||0,window.innerHeight-56);n.style.left=`${Math.max(0,e)}px`,n.style.top=`${Math.max(0,t)}px`}),t.appendChild(n),e._fabEl=n}static _setFabVisible(t){e._fabEl&&(e._fabEl.style.display=t&&e._fabSubscriberCount>0?`flex`:`none`)}_terminal=null;_panel=null;_cursorEl=null;_cursorPos={x:0,y:0};_isDragging=!1;_isOpen=!1;_edgeScrollTimer=null;_cleanups=[];_persistentCleanups=[];_listenersAttached=!1;_onInput;_onCommand;_onOpenCb;_onCloseCb;_getHistory;_addHistory;_subscribeHistory;_onSettingsChange;_platform;_defaultLayout;_showFab;_fabSubscribed;_panelSessionState;_stateKey;_hasOwnPersistedState;constructor(t){this._onInput=t?.onInput??(()=>{}),this._onCommand=t?.onCommand??null,this._onOpenCb=t?.onOpen??null,this._onCloseCb=t?.onClose??null,this._getHistory=t?.getHistory??null,this._addHistory=t?.addHistory??null,this._subscribeHistory=t?.subscribeHistory??null,this._onSettingsChange=t?.onSettingsChange??null,this._platform=t?.platform??`common`,this._defaultLayout=t?.defaultLayout??`floating`,this._showFab=t?.showFab??!0,this._fabSubscribed=!1,this._stateKey=t?.stateKey?.trim()?t.stateKey:`default`,this._hasOwnPersistedState=!1,this._panelSessionState={activeTab:`input`,inputDraft:``};let n=Ume(this._stateKey);n?(this._panelSessionState=n,this._hasOwnPersistedState=!0):this._panelSessionState.activeTab=e._lastActiveTab||Bx()}get isOpen(){return this._isOpen}set onOpen(e){this._onOpenCb=e}set onClose(e){this._onCloseCb=e}set onInput(e){this._onInput=e}set onCommand(e){this._onCommand=e}setPlatform(e){this._platform=e,this._applyPlatformToPanel()}setDefaultLayout(e){this._defaultLayout=e}_persistPanelState(){e._lastActiveTab=this._panelSessionState.activeTab;let t=zx(),n={...t.sessions,[this._stateKey]:{activeTab:this._panelSessionState.activeTab,inputDraft:this._panelSessionState.inputDraft}};Hme({...t,lastActiveTab:this._panelSessionState.activeTab,sessions:n})}_getMountTarget(){return e._mountTarget??this._getTerminalHostElement()??document.body}_getTerminalHostElement(){let e=this._terminal?.element;return e instanceof HTMLElement?e.classList.contains(`xterm`)&&e.parentElement instanceof HTMLElement?e.parentElement:e:null}_detectTerminalEngine(){let e=this._terminal?.element;return e instanceof HTMLElement&&e.classList.contains(`xterm`)?`xterm`:`non-xterm`}activate(t){this._terminal=t,e._instances.add(this)}dispose(){this.close();for(let e of this._persistentCleanups)e();this._persistentCleanups=[],this._listenersAttached=!1,this._fabSubscribed&&(e._fabSubscriberCount=Math.max(0,e._fabSubscriberCount-1),this._fabSubscribed=!1,e._setFabVisible(e._active===null)),e._instances.delete(this),e._lastFocused===this&&(e._lastFocused=null),this._terminal=null}attachListeners(){if(this._listenersAttached||!this._terminal)return;let t=this._terminal.textarea;if(!t)return;this._listenersAttached=!0,this._showFab?(e._ensureFab(this._getMountTarget()),this._fabSubscribed||=(e._fabSubscriberCount+=1,!0),e._setFabVisible(!0)):e._fabSubscriberCount===0&&e._setFabVisible(!1),e._lastFocused||=this;let n=()=>{e._lastFocused=this,Fx()&&!this._isOpen&&this.open()};t.addEventListener(`focus`,n),this._persistentCleanups.push(()=>t.removeEventListener(`focus`,n)),Fx()&&t.setAttribute(`inputmode`,`none`)}open(){if(!this._terminal)return;if(this._isOpen){if(this._panel?.isConnected)return;this.close()}if(e._active&&e._active!==this&&e._active.close(),this._isOpen=!0,e._active=this,e._lastFocused=this,this._showFab&&e._setFabVisible(!1),this._suppressKeyboard(),!this._hasOwnPersistedState){let t=Bx();this._panelSessionState.activeTab=t,e._lastActiveTab=t}let t=document.createElement(`input-panel`);t.setAttribute(`layout`,this._defaultLayout),this._applyPanelThemeBindings(t),t.activeTab=this._panelSessionState.activeTab;let n=document.createElement(`input-method-tab`);n.setAttribute(`slot`,`input`),n.value=this._panelSessionState.inputDraft,t.appendChild(n);let r=document.createElement(`virtual-keyboard-tab`);r.setAttribute(`slot`,`keys`),r.setAttribute(`floating`,``),r.setAttribute(`platform`,this._platform),t.appendChild(r);let i=document.createElement(`shortcut-tab`);i.setAttribute(`slot`,`shortcuts`),i.setAttribute(`platform`,this._platform),t.appendChild(i);let a=document.createElement(`virtual-trackpad-tab`);a.setAttribute(`slot`,`trackpad`),a.setAttribute(`floating`,``),t.appendChild(a),this._panel=t;let o=e=>{this._renderHistory(n,e)};if(this._getHistory&&this._getHistory().then(e=>o(e)).catch(()=>{}),this._subscribeHistory)try{let e=this._subscribeHistory(e=>{o(e)});this._cleanups.push(e)}catch{}this._on(t,`input-panel:close`,()=>this.close()),this._on(t,`input-panel:send`,e=>{let t=e.detail?.data;if(t&&this._onInput(t),e.composedPath()[0]===n&&this._addHistory&&t){let e=this._normalizeHistoryText(t);e&&Promise.resolve(this._addHistory(e)).then(()=>this._getHistory?.()).then(e=>{e&&o(e)}).catch(()=>{})}}),this._on(t,`input-panel:command`,e=>{let t=e.detail;if(!Rx(t))return;let n=t.command;if(!Vme(n))return;let r=typeof t.fallbackData==`string`?t.fallbackData:void 0;Promise.resolve(this._onCommand?.(n,{fallbackData:r})??!1).then(e=>{!e&&r&&this._onInput(r)}).catch(()=>{r&&this._onInput(r)})}),this._on(n,`input-panel:input-change`,e=>{let t=e.detail?.value;typeof t==`string`&&(this._panelSessionState.inputDraft=t,this._hasOwnPersistedState=!0,this._persistPanelState())}),this._on(t,`input-panel:tab-change`,e=>{let t=e.detail?.tab;Lx(t)&&(this._panelSessionState.activeTab=t,this._hasOwnPersistedState=!0,this._persistPanelState()),t===`trackpad`?this._showCursor():this._hideCursor()}),this._on(t,`input-panel:settings-change`,e=>{if(!this._onSettingsChange)return;let t=e.detail;if(typeof t!=`object`||!t)return;let n=t;typeof n.fixedHeight!=`number`||typeof n.floatingWidth!=`number`||typeof n.floatingHeight!=`number`||typeof n.vibrationIntensity!=`number`||typeof n.historyLimit!=`number`||this._onSettingsChange({fixedHeight:n.fixedHeight,floatingWidth:n.floatingWidth,floatingHeight:n.floatingHeight,vibrationIntensity:n.vibrationIntensity,historyLimit:n.historyLimit})}),this._on(t,`trackpad:move`,e=>{let{dx:t,dy:n}=e.detail;this._moveCursor(t,n)}),this._on(t,`trackpad:tap`,()=>this._dispatchClick(1)),this._on(t,`trackpad:double-tap`,()=>this._dispatchDblClick()),this._on(t,`trackpad:long-press`,()=>this._dispatchRightClick()),this._on(t,`trackpad:two-finger-tap`,()=>this._dispatchRightClick()),this._on(t,`trackpad:drag-start`,()=>{this._isDragging=!0,this._dispatchMouse(`mousedown`,{detail:1})}),this._on(t,`trackpad:drag-move`,e=>{let{dx:t,dy:n}=e.detail;this._moveCursor(t,n),this._dispatchMouse(`mousemove`,{buttons:1}),this._updateEdgeScroll()}),this._on(t,`trackpad:drag-end`,()=>{this._isDragging=!1,this._stopEdgeScroll(),this._dispatchMouse(`mouseup`,{detail:1})}),this._on(t,`trackpad:scroll`,e=>{let{deltaY:t}=e.detail;this._dispatchWheel(t)}),this._getMountTarget().appendChild(t),this._createCursor(),this._focusTerminal(),this._onOpenCb?.(),e._onActiveChangeFn?.(this)}_applyPlatformToPanel(){if(!this._panel)return;let e=this._panel.querySelector(`virtual-keyboard-tab`),t=this._panel.querySelector(`shortcut-tab`);e?.setAttribute(`platform`,this._platform),t?.setAttribute(`platform`,this._platform)}_readThemeVar(e,t,n){for(let n of t){let t=e.getPropertyValue(n).trim();if(t)return t}return n}_applyPanelThemeBindings(e){let t=this._getTerminalHostElement()??this._getMountTarget(),n=getComputedStyle(t),r=this._readThemeVar(n,[`--input-panel-background`,`--terminal`,`--background`],`#1a1a1a`),i=this._readThemeVar(n,[`--input-panel-foreground`,`--terminal-foreground`,`--foreground`],`#ffffff`),a=this._readThemeVar(n,[`--input-panel-primary`,`--primary`],`#e04a2f`),o=this._readThemeVar(n,[`--input-panel-primary-foreground`,`--primary-foreground`],`#ffffff`),s=this._readThemeVar(n,[`--input-panel-border`,`--border`],`color-mix(in srgb, ${i} 24%, transparent)`),c=this._readThemeVar(n,[`--input-panel-muted`,`--muted`],`color-mix(in srgb, ${r} 86%, ${i} 14%)`),l=this._readThemeVar(n,[`--input-panel-muted-foreground`,`--muted-foreground`],`color-mix(in srgb, ${i} 62%, transparent)`);e.style.setProperty(`--input-panel-background`,r),e.style.setProperty(`--input-panel-foreground`,i),e.style.setProperty(`--input-panel-primary`,a),e.style.setProperty(`--input-panel-primary-foreground`,o),e.style.setProperty(`--input-panel-border`,s),e.style.setProperty(`--input-panel-muted`,c),e.style.setProperty(`--input-panel-muted-foreground`,l)}close(){if(this._isOpen){this._isOpen=!1,e._active===this&&(e._active=null),this._stopEdgeScroll();for(let e of this._cleanups)e();this._cleanups=[],this._panel?.remove(),this._panel=null,this._cursorEl?.remove(),this._cursorEl=null,Fx()||this._restoreKeyboard(),this._showFab&&e._setFabVisible(!0),this._onCloseCb?.(),e._onActiveChangeFn?.(null)}}toggle(){if(this._isOpen){this.close();return}this.open()}syncFocusLifecycle(){if(e._lastFocused=this,this._isOpen&&!this._panel?.isConnected){this.open();return}if(e._active&&e._active!==this){this.open();return}this._isOpen&&this._focusTerminal()}_focusTerminal(){let e=this._terminal?.textarea;e&&(Fx()&&e.setAttribute(`inputmode`,`none`),e.focus())}_createCursor(){let e=this._getTerminalHostElement();if(!e)return;let t=document.createElement(`div`);t.setAttribute(`data-input-panel-cursor`,`virtual-mouse`),t.setAttribute(`data-terminal-engine`,this._detectTerminalEngine()),t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;z-index:10;pointer-events:none;opacity:0;transition:opacity 0.15s;color:#fff;`;let n=Ope(20);n.style.filter=`drop-shadow(0 0 1px rgba(0,0,0,0.9))`,t.replaceChildren(n),e.appendChild(t),this._cursorEl=t;let r=e.getBoundingClientRect();this._cursorPos={x:r.width/2,y:r.height/2},this._positionCursor()}_positionCursor(){this._cursorEl&&(this._cursorEl.style.left=`${this._cursorPos.x-4}px`,this._cursorEl.style.top=`${this._cursorPos.y-2}px`)}_showCursor(){if(this._cursorEl||this._createCursor(),this._cursorEl){let e=this._getTerminalHostElement();if(e){let t=e.getBoundingClientRect();this._cursorPos={x:t.width/2,y:t.height/2},this._positionCursor()}this._cursorEl.style.opacity=`1`}}_hideCursor(){this._cursorEl&&(this._cursorEl.style.opacity=`0.3`)}_moveCursor(e,t){let n=this._getTerminalHostElement();if(!n)return;let r=n.getBoundingClientRect();this._cursorPos.x=Math.max(0,Math.min(r.width,this._cursorPos.x+e*Mx)),this._cursorPos.y=Math.max(0,Math.min(r.height,this._cursorPos.y+t*Mx)),this._positionCursor()}_getClientCoords(){let e=this._getTerminalHostElement();if(!e)return null;let t=e.getBoundingClientRect();return{clientX:t.left+this._cursorPos.x,clientY:t.top+this._cursorPos.y}}_resolveTarget(e,t){let n=this._getTerminalHostElement();return n?Bme(n,e,t):document.body}_dispatchMouse(e,t={}){let n=this._getClientCoords();if(!n)return;let r=t.button??0,i=t.detail??1,a=t.buttons??(e===`mousedown`?r===0?1:r===2?2:4:0);this._resolveTarget(n.clientX,n.clientY).dispatchEvent(new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,detail:i,clientX:n.clientX,clientY:n.clientY,button:r,buttons:a}))}_dispatchClick(e){this._dispatchMouse(`mousedown`,{detail:e}),this._dispatchMouse(`mouseup`,{detail:e}),this._dispatchMouse(`click`,{detail:e})}_dispatchDblClick(){this._dispatchMouse(`mousedown`,{detail:2}),this._dispatchMouse(`mouseup`,{detail:2}),this._dispatchMouse(`click`,{detail:2}),this._dispatchMouse(`dblclick`,{detail:2})}_dispatchRightClick(){this._dispatchMouse(`mousedown`,{button:2}),this._dispatchMouse(`mouseup`,{button:2}),this._dispatchMouse(`contextmenu`,{button:2})}_dispatchWheel(e){let t=this._getClientCoords();t&&this._resolveTarget(t.clientX,t.clientY).dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,view:window,clientX:t.clientX,clientY:t.clientY,deltaY:e,deltaMode:WheelEvent.DOM_DELTA_PIXEL}))}_updateEdgeScroll(){let e=this._getTerminalHostElement();if(!e||!this._isDragging){this._stopEdgeScroll();return}let t=e.getBoundingClientRect(),n=this._cursorPos.y<Nx,r=this._cursorPos.y>t.height-Nx;if(!n&&!r){this._stopEdgeScroll();return}this._stopEdgeScroll(),this._edgeScrollTimer=setInterval(()=>{let e=this._getTerminalHostElement();if(!e||!this._isDragging){this._stopEdgeScroll();return}let t=e.getBoundingClientRect(),n=t.left+this._cursorPos.x,r=this._cursorPos.y<Nx?t.top-Px:t.bottom+Px;this._resolveTarget(t.left+this._cursorPos.x,t.top+this._cursorPos.y).dispatchEvent(new MouseEvent(`mousemove`,{bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:r,button:0,buttons:1}))},zme)}_stopEdgeScroll(){this._edgeScrollTimer&&=(clearInterval(this._edgeScrollTimer),null)}_suppressKeyboard(){if(!Fx())return;let e=this._terminal?.textarea;e&&e.setAttribute(`inputmode`,`none`)}_restoreKeyboard(){let e=this._terminal?.textarea;e&&e.removeAttribute(`inputmode`)}_on(e,t,n){e.addEventListener(t,n),this._cleanups.push(()=>e.removeEventListener(t,n))}_normalizeHistoryText(e){return e.replace(/[\r\n]+$/u,``).trim()||null}_renderHistory(e,t){if(e.querySelectorAll(`[data-input-history-root="true"]`).forEach(e=>e.remove()),t.length===0)return;let n=document.createElement(`div`);n.dataset.inputHistoryRoot=`true`,n.setAttribute(`slot`,`history`),n.style.display=`flex`,n.style.flexDirection=`column`,n.style.gap=`4px`,n.style.padding=`4px 0`;for(let e of t){let t=document.createElement(`button`);t.type=`button`,t.title=e.text,t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`8px`,t.style.width=`100%`,t.style.padding=`4px 6px`,t.style.border=`1px solid transparent`,t.style.borderRadius=`4px`,t.style.background=`transparent`,t.style.color=`var(--foreground, #fff)`,t.style.fontFamily=`inherit`,t.style.fontSize=`12px`,t.style.textAlign=`left`;let r=document.createElement(`span`);r.textContent=new Date(e.time).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r.style.opacity=`0.65`,r.style.fontSize=`10px`,r.style.flexShrink=`0`;let i=document.createElement(`span`);i.textContent=e.text,i.style.overflow=`hidden`,i.style.textOverflow=`ellipsis`,i.style.whiteSpace=`nowrap`,t.appendChild(r),t.appendChild(i),t.addEventListener(`click`,()=>{this._onInput(`${e.text}\n`)}),n.appendChild(t)}e.appendChild(n)}};function Hx(e){let t=/^zh\b/i.test(e);return{apiHost:t?`https://fonts.googleapis.cn`:`https://fonts.googleapis.com`,staticHost:t?`https://fonts.gstatic.cn`:`https://fonts.gstatic.com`}}function Wme(e){return e.trim().replace(/ /g,`+`)}function Gme(e){let t=e.families.map(Wme).filter(Boolean),{apiHost:n}=Hx(e.lang??``),r=t.map(e=>`family=${e}`),i=`display=${e.display??`swap`}`;return`${n}/css2?${[...r,i].join(`&`)}`}function Kme(e){let t=e.documentRef??(typeof document>`u`?null:document);if(!t||e.families.length===0)return null;let n=e.lang??(typeof navigator>`u`?``:navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage||``),r=Hx(n),i=Gme({...e,lang:n});if(t.head.querySelector(`link[href="${i}"]`))return null;let a=t.createElement(`link`);a.rel=`preconnect`,a.href=r.apiHost,a.dataset.openspecGoogleFonts=`preconnect-api`;let o=t.createElement(`link`);o.rel=`preconnect`,o.href=r.staticHost,o.crossOrigin=`anonymous`,o.dataset.openspecGoogleFonts=`preconnect-static`;let s=t.createElement(`link`);return s.rel=`stylesheet`,s.href=i,s.dataset.openspecGoogleFonts=`stylesheet`,t.head.append(a,o,s),s}var Ux=null,Wx=null,Gx=null,Kx=null,qx=!1,Jx=!1;function Yx(){return typeof window>`u`?null:window.AudioContext??window.webkitAudioContext??null}function Xx(){return qx?!0:typeof navigator>`u`?!1:navigator.userActivation?.hasBeenActive===!0||navigator.userActivation?.isActive===!0}function qme(){typeof window>`u`||!Jx||(window.removeEventListener(`pointerdown`,Zx,!0),window.removeEventListener(`keydown`,Zx,!0),Jx=!1)}function Zx(){qx=!0,qme(),Kx?.(),Kx=null,Gx=null}function Qx(){typeof window>`u`||Jx||Xx()||(window.addEventListener(`pointerdown`,Zx,{capture:!0,once:!0,passive:!0}),window.addEventListener(`keydown`,Zx,{capture:!0,once:!0}),Jx=!0)}function Jme(){Qx()}function Yme(){return typeof window>`u`||Xx()?Promise.resolve():Gx||(Gx=new Promise(e=>{Kx=e,Qx()}),Gx)}async function Xme(){return Ux||Wx||(Yx()?(Wx=Yme().then(async()=>{let e=Yx();if(!e)return null;let t=Ux??new e;return Ux=t,t.state===`suspended`&&await t.resume(),t}).finally(()=>{Wx=null}),Wx):null)}var $x=class{fallbackSound;unlocked=!1;unlockPromise=null;silentAudio=null;activeAudios=new Set;constructor(e){this.fallbackSound=e===`bell`?Bu:Vu}init(){Jme()}async unlock(){if(!this.unlocked)return this.unlockPromise||=this.unlockAudioContext().finally(()=>{this.unlockPromise=null}),this.unlockPromise}async play(e,t=1){e!==`silent`&&(await this.unlock().catch(()=>{}),await this.playAudio(e,t))}async unlockAudioContext(){if(!await Xme()){this.unlocked=!0;return}this.silentAudio??=new Audio(`data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=`),this.silentAudio.volume=0,await this.silentAudio.play().catch(()=>{}),this.unlocked=!0}async playAudio(e,t){let n=this.getSoundUrl(e)??this.getSoundUrl(this.fallbackSound);n&&await this.createManagedAudio(n,t).play().catch(async r=>{if(e!==this.fallbackSound){if(await this.isMissingSound(n)){let e=this.getSoundUrl(this.fallbackSound);e&&await this.createManagedAudio(e,t).play().catch(()=>{});return}throw r}})}getSoundUrl(e){let t=Pae(e);if(t)return t;let n=qu(e);if(!n)return null;let r=V(),i=`/api/sounds/custom/${n}`;return r?`${r}${i}`:i}async isMissingSound(e){try{return(await M(e,{method:`HEAD`})).status===404}catch{return!1}}createManagedAudio(e,t){let n=new Audio(e);n.volume=Zme(t),this.activeAudios.add(n);let r=()=>{n.removeEventListener(`ended`,r),n.removeEventListener(`error`,r),this.activeAudios.delete(n)};return n.addEventListener(`ended`,r,{once:!0}),n.addEventListener(`error`,r,{once:!0}),n}};function Zme(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):1}var eS=class extends $x{constructor(){super(`bell`)}},tS=`xtermInputPanelSettings`,Qme=50,$me=1e3,ehe=1,the=1,nS=`terminal-meta`;function rS(){return z(`terminal-input-history`,window.location)}function nhe(){return z(`openspecui-terminal`,window.location)}function iS(){return z(`input-history`,window.location)}function aS(){return z(`terminal-input-history-fallback`,window.location)}function oS(e){return Math.max(ehe,Math.min($me,Math.round(e)))}function sS(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(typeof e.text!=`string`||typeof e.time!=`number`||!Number.isFinite(e.time))continue;let r=e.text.trim();r&&t.push({text:r,time:e.time})}return t}function cS(e,t){let n=new Map;for(let t of e){let e=`${t.time}::${t.text}`;n.has(e)||n.set(e,t)}return[...n.values()].sort((e,t)=>t.time-e.time).slice(0,oS(t))}function lS(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.text!==t[n]?.text||e[n]?.time!==t[n]?.time)return!1;return!0}function uS(){try{let e=localStorage.getItem(tS);if(!e)return{};let t=JSON.parse(e);return typeof t!=`object`||!t?{}:t}catch{return{}}}function rhe(e){let t=uS();try{localStorage.setItem(tS,JSON.stringify({...t,...e}))}catch{}}async function dS(){return typeof window>`u`||!(`indexedDB`in window)?null:await new Promise(e=>{let t=window.indexedDB.open(nhe(),the);t.onupgradeneeded=()=>{let e=t.result;e.objectStoreNames.contains(nS)||e.createObjectStore(nS)},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)})}async function ihe(){let e=await dS();return e?await new Promise(t=>{let n=e.transaction(nS,`readonly`),r=n.objectStore(nS).get(iS());r.onsuccess=()=>{t(sS(r.result))},r.onerror=()=>t([]),n.oncomplete=()=>e.close(),n.onerror=()=>e.close(),n.onabort=()=>e.close()}):null}async function ahe(e){let t=await dS();return t?await new Promise(n=>{let r=t.transaction(nS,`readwrite`);r.objectStore(nS).put(e,iS()),r.oncomplete=()=>{t.close(),n(!0)},r.onerror=()=>{t.close(),n(!1)},r.onabort=()=>{t.close(),n(!1)}}):!1}function ohe(){try{let e=localStorage.getItem(aS());return e?sS(JSON.parse(e)):[]}catch{return[]}}function she(e){try{localStorage.setItem(aS(),JSON.stringify(e))}catch{}}async function che(){return await ihe()||ohe()}async function fS(e){await ahe(e)||she(e)}var lhe=class{records=[];listeners=new Set;kvUnsubscribe=null;initPromise=null;subscribe(e){return this.listeners.add(e),this.ensureInitialized(),e(this.records),()=>{this.listeners.delete(e)}}async list(){return await this.ensureInitialized(),[...this.records]}getLimit(){let e=uS().historyLimit;return typeof e==`number`&&Number.isFinite(e)?oS(e):Qme}async setLimit(e){let t=oS(e);rhe({historyLimit:t}),await this.ensureInitialized();let n=cS(this.records,t);await this.commit(n,{persistRemote:!0})}async add(e){let t=e.trim();if(!t)return;await this.ensureInitialized();let n=cS([{text:t,time:Date.now()},...this.records],this.getLimit());await this.commit(n,{persistRemote:!0})}destroy(){this.kvUnsubscribe&&=(this.kvUnsubscribe(),null)}async ensureInitialized(){if(this.initPromise){await this.initPromise;return}this.initPromise=this.initialize(),await this.initPromise}async initialize(){if(this.records=cS(await che(),this.getLimit()),this.emit(),!B())try{let e=sS(await q.kv.get.query({key:rS()})),t=cS([...this.records,...e],this.getLimit());lS(this.records,t)||(this.records=t,await fS(this.records),this.emit()),lS(e,this.records)||this.persistRemote(this.records);let n=q.kv.subscribe.subscribe({key:rS()},{onData:e=>{this.onRemoteData(e)}});this.kvUnsubscribe=()=>n.unsubscribe()}catch{}}async onRemoteData(e){let t=sS(e),n=cS([...this.records,...t],this.getLimit());await this.commit(n,{persistRemote:!1})}async commit(e,t){lS(this.records,e)||(this.records=e,await fS(this.records),this.emit(),t.persistRemote&&!B()&&this.persistRemote(this.records))}async persistRemote(e){try{await q.kv.set.mutate({key:rS(),value:e})}catch{}}emit(){for(let e of this.listeners)e(this.records)}};function pS(e){return e.type===`keydown`}function mS(e,t){return e.key.toLowerCase()===t}function hS(e){return e.metaKey||e.ctrlKey}function gS(e){return hS(e)&&!e.altKey}function _S(e){return e.clipboard?e.clipboard:typeof navigator>`u`?null:navigator.clipboard??null}function vS(e,t){e.catch(e=>{t.onAsyncError?.(e)})}async function uhe(e,t){let n=_S(e);n?.writeText&&await n.writeText(t)}async function dhe(e){let t=_S(e);if(!t?.readText)return;let n=await t.readText();if(n){try{if(e.terminal.paste?.(n),e.terminal.paste)return}catch{}e.writeInput(n)}}var fhe=[{id:`terminal.copy-selection`,handle:(e,t)=>!pS(e)||!gS(e)||!mS(e,`c`)?null:t.terminal.hasSelection?.()?yS(t):`allow`},{id:`terminal.paste-clipboard`,handle:(e,t)=>!pS(e)||!gS(e)||!mS(e,`v`)?null:bS(t)},{id:`terminal.select-all`,handle:(e,t)=>!pS(e)||!e.metaKey||e.ctrlKey||e.altKey||!mS(e,`a`)?null:xS(t)},{id:`terminal.zoom-in`,handle:(e,t)=>!pS(e)||!hS(e)||e.key!==`=`&&e.key!==`+`?null:(t.zoomFont(1),`block`)},{id:`terminal.zoom-out`,handle:(e,t)=>!pS(e)||!hS(e)||e.key!==`-`?null:(t.zoomFont(-1),`block`)},{id:`terminal.zoom-reset`,handle:(e,t)=>!pS(e)||!hS(e)||e.key!==`0`?null:(t.resetFontSize(),`block`)}];function yS(e){if(!e.terminal.hasSelection?.())return`allow`;let t=e.terminal.getSelection?.()??``;return t?(vS(uhe(e,t),e),`block`):`allow`}function bS(e){return _S(e)?.readText?(vS(dhe(e),e),`block`):`allow`}function xS(e){return e.terminal.selectAll?(e.terminal.selectAll(),`block`):`allow`}var phe=[{id:`terminal.command.copy-selection`,command:`copy`,run:yS},{id:`terminal.command.paste-clipboard`,command:`paste`,run:bS},{id:`terminal.command.select-all`,command:`select-all`,run:xS}],mhe=class{constructor(e=fhe,t=phe){this.bindings=e,this.commandBindings=t}handleKeyEvent(e,t){for(let n of this.bindings){let r=n.handle(e,t);if(r)return r}return`allow`}runCommand(e,t){return this.commandBindings.find(t=>t.command===e)?.run(t)??`allow`}},hhe=[`app`,`light`,`dark`,`system`],ghe=[{value:`default-light`,label:`Default Light`},{value:`default-dark`,label:`Default Dark`},{value:`monokai`,label:`Monokai`},{value:`nord`,label:`Nord`},{value:`solarized-light`,label:`Solarized Light`},{value:`solarized-dark`,label:`Solarized Dark`}],_he={"default-light":{id:`default-light`,label:`Default Light`,modeHint:`light`,palette:{background:`#f6f5f2`,foreground:`#1b1b1b`,cursor:`#ea580c`,cursorAccent:`#f6f5f2`,selectionBackground:`rgba(234, 88, 12, 0.22)`,black:`#111111`,red:`#b91c1c`,green:`#15803d`,yellow:`#a16207`,blue:`#1d4ed8`,magenta:`#a21caf`,cyan:`#0f766e`,white:`#f6f5f2`,brightBlack:`#4b5563`,brightRed:`#dc2626`,brightGreen:`#16a34a`,brightYellow:`#ca8a04`,brightBlue:`#2563eb`,brightMagenta:`#c026d3`,brightCyan:`#0891b2`,brightWhite:`#ffffff`}},"default-dark":{id:`default-dark`,label:`Default Dark`,modeHint:`dark`,palette:{background:`#141414`,foreground:`#e5dfd2`,cursor:`#f97316`,cursorAccent:`#141414`,selectionBackground:`rgba(249, 115, 22, 0.28)`,black:`#151515`,red:`#f87171`,green:`#4ade80`,yellow:`#facc15`,blue:`#60a5fa`,magenta:`#e879f9`,cyan:`#67e8f9`,white:`#f4f1ea`,brightBlack:`#6b7280`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#f0abfc`,brightCyan:`#a5f3fc`,brightWhite:`#fffdf8`}},monokai:{id:`monokai`,label:`Monokai`,modeHint:`either`,palette:{background:`#272822`,foreground:`#f8f8f2`,cursor:`#f8f8f0`,cursorAccent:`#272822`,selectionBackground:`rgba(73, 72, 62, 0.9)`,black:`#272822`,red:`#f92672`,green:`#a6e22e`,yellow:`#f4bf75`,blue:`#66d9ef`,magenta:`#ae81ff`,cyan:`#a1efe4`,white:`#f8f8f2`,brightBlack:`#75715e`,brightRed:`#f92672`,brightGreen:`#a6e22e`,brightYellow:`#f4bf75`,brightBlue:`#66d9ef`,brightMagenta:`#ae81ff`,brightCyan:`#a1efe4`,brightWhite:`#f9f8f5`}},nord:{id:`nord`,label:`Nord`,modeHint:`either`,palette:{background:`#2e3440`,foreground:`#d8dee9`,cursor:`#88c0d0`,cursorAccent:`#2e3440`,selectionBackground:`rgba(94, 129, 172, 0.38)`,black:`#3b4252`,red:`#bf616a`,green:`#a3be8c`,yellow:`#ebcb8b`,blue:`#81a1c1`,magenta:`#b48ead`,cyan:`#88c0d0`,white:`#e5e9f0`,brightBlack:`#4c566a`,brightRed:`#d08770`,brightGreen:`#8fbcbb`,brightYellow:`#eceff4`,brightBlue:`#5e81ac`,brightMagenta:`#b48ead`,brightCyan:`#8fbcbb`,brightWhite:`#eceff4`}},"solarized-light":{id:`solarized-light`,label:`Solarized Light`,modeHint:`light`,palette:{background:`#fdf6e3`,foreground:`#586e75`,cursor:`#cb4b16`,cursorAccent:`#fdf6e3`,selectionBackground:`rgba(147, 161, 161, 0.32)`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#657b83`,brightRed:`#cb4b16`,brightGreen:`#93a1a1`,brightYellow:`#839496`,brightBlue:`#6c71c4`,brightMagenta:`#d33682`,brightCyan:`#2aa198`,brightWhite:`#fdf6e3`}},"solarized-dark":{id:`solarized-dark`,label:`Solarized Dark`,modeHint:`dark`,palette:{background:`#002b36`,foreground:`#93a1a1`,cursor:`#cb4b16`,cursorAccent:`#002b36`,selectionBackground:`rgba(88, 110, 117, 0.5)`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#657b83`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`}}};function vhe(e){let t=e.useTheme??`app`;return t===`light`?`light`:t===`dark`?`dark`:t===`system`?e.systemDarkMode?`dark`:`light`:e.appDarkMode?`dark`:`light`}function SS(e){let t=vhe(e),n=t===`dark`?e.darkTheme??`default-dark`:e.lightTheme??`default-light`;return{id:n,mode:t,definition:_he[n]}}var CS=[`xterm`,`ghostty`];function wS(e){return CS.includes(e)}var TS=`"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,ES={fontSize:13,fontFamily:``,cursorBlink:!0,cursorStyle:`block`,scrollback:1e3,useTheme:`app`,lightTheme:`default-light`,darkTheme:`default-dark`,rendererEngine:`xterm`,bellSound:Bu,bellVolume:1},DS=1500,OS=1e3,yhe=1e4,kS=`common`,bhe=512*1024,xhe=8,She=32,AS=13,Che=800,whe={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`},The={ArrowLeft:`\x1Bb`,ArrowRight:`\x1Bf`,ArrowUp:`\x1B[1;3A`,ArrowDown:`\x1B[1;3B`},Ehe={ArrowLeft:``,ArrowUp:``,ArrowRight:``,ArrowDown:``},jS=[`JetBrains Mono`,`Fira Code`,`Source Code Pro`,`IBM Plex Mono`,`Inconsolata`,`Roboto Mono`,`Ubuntu Mono`,`Space Mono`],Dhe={"JetBrains Mono":`"JetBrains Mono Variable"`,"Share Tech Mono":`"Share Tech Mono"`},MS=new Set;function NS(e){try{return(new URL(e).pathname.split(`/`).pop()??``).replace(/\.[^.]+$/,``).replace(/[-_]/g,` `)||`CustomFont`}catch{return`CustomFont`}}async function Ohe(e){let t=e.trim();if(!t)return``;if(!/^https?:\/\//i.test(t))return t;if(MS.has(t))return NS(t);try{let e=(await M(t,{method:`HEAD`})).headers.get(`content-type`)??``;if(e.includes(`text/css`)){let e=document.createElement(`link`);return e.rel=`stylesheet`,e.href=t,e.dataset.fontSrc=t,document.head.appendChild(e),MS.add(t),``}if(e.startsWith(`font/`)){let e=NS(t),n=document.createElement(`style`);return n.dataset.fontSrc=t,n.textContent=`@font-face { font-family: '${e}'; src: url('${t}'); }`,document.head.appendChild(n),MS.add(t),e}}catch{}return t}function khe(e){let t=`google:${e}`;if(MS.has(t))return;let n=Kme({families:[e]});n&&(n.dataset.fontSrc=t),MS.add(t)}var Ahe=class{instances=new Map;listeners=new Set;activationListeners=new Set;idCounter=0;config={...ES};snapshotCache=null;inputHistoryStore=new lhe;bellSoundEngine=new eS;keybindings=new mhe;ghosttyModule=null;ghosttyInitPromise=null;appDarkMode=!1;systemDarkMode=!1;resolvedTheme=SS({useTheme:ES.useTheme,lightTheme:ES.lightTheme,darkTheme:ES.darkTheme,appDarkMode:!1,systemDarkMode:!1});ws=null;wsConnected=!1;reconnectTimer=null;reconnectDelay=OS;pendingCreates=[];pendingCloseSessionIds=new Set;pendingWorkflowInputs=new Map;workflowInputRequestCounter=0;serverToLocalSessionId=new Map;hasDiscoveredSessions=!1;inputPanelDefaultLayout=`floating`;activeSessionId=null;constructor(){this.bellSoundEngine.init()}createSession(e){let t=`term-${++this.idCounter}`,n=e.label??`Shell ${this.idCounter}`,r=this.createTerminalInstance(t,{label:n,command:e.command,args:e.args,isDedicated:e.isDedicated??!1,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl,initialInput:e.initialInput,customTitle:e.customTitle??null,restored:!1,serverSessionId:null,platform:kS,cwdTarget:e.cwdTarget,initialCwd:null,rootGeneration:null});return this.instances.set(t,r),this._applyFonts(),this.bindTerminalInput(r),this.wsConnected&&this.ws?this.wsSend({type:`create`,requestId:t,cwdTarget:e.cwdTarget,expectedRootGeneration:e.expectedRootGeneration,cols:r.terminal.cols||80,rows:r.terminal.rows||24,command:e.command,args:e.args,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl}):(this.pendingCreates.push({requestId:t,cwdTarget:e.cwdTarget,expectedRootGeneration:e.expectedRootGeneration,command:e.command,args:e.args,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl,cols:r.terminal.cols||80,rows:r.terminal.rows||24}),this.ensureWsConnected()),e.initialInput&&this.scheduleInitialInput(t,e.initialInput),this.notify(),t}scheduleInitialInput(e,t){let n=0,r=()=>{this.writeToSession(e,t)||(n+=1,!(n>75)&&globalThis.setTimeout(r,80))};globalThis.setTimeout(r,80)}createTerminalInstance(e,t){let{terminal:n,fitAddon:r,afterOpenHook:i,engine:a}=this.createRendererTerminal(),o=this.createInputPanelAddon(e,t.platform);return n.loadAddon(o),this.attachTerminalShortcuts(n,a,t=>this.writeToSession(e,t)),{id:e,serverSessionId:t.serverSessionId,terminal:n,fitAddon:r,inputPanelAddon:o,isConnected:!1,label:t.label,customTitle:t.customTitle,processTitle:null,oscTitle:null,cwd:null,cwdTarget:t.cwdTarget,initialCwd:t.initialCwd,rootGeneration:t.rootGeneration,progress:null,promptState:null,isDedicated:t.isDedicated,isExited:!1,exitCode:null,command:t.command,args:t.args,closeTip:t.closeTip,closeCallbackUrl:t.closeCallbackUrl,mountedContainer:null,resizeObserver:null,hasOpened:!1,afterOpenHook:i,pendingOutput:[],pendingOutputBytes:0,lastOutputTime:0,lastBellAt:null,outputIdleTimer:null,restored:t.restored,platform:t.platform,rendererEngine:a}}getTerminalOptions(){let e=SS({useTheme:this.config.useTheme,lightTheme:this.config.lightTheme,darkTheme:this.config.darkTheme,appDarkMode:this.appDarkMode,systemDarkMode:this.systemDarkMode});return{cursorBlink:this.config.cursorBlink,cursorStyle:this.config.cursorStyle,fontSize:this.config.fontSize,fontFamily:TS,theme:e.definition.palette,allowTransparency:!1,convertEol:!0,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,scrollback:this.config.scrollback}}createRendererTerminal(){let e=this.getTerminalOptions();if(this.config.rendererEngine===`xterm`){let t=new Wfe(e),n=new vue;return t.loadAddon(n),t.loadAddon(new wue),{terminal:t,fitAddon:n,afterOpenHook:null,engine:`xterm`}}let t=this.ghosttyModule;if(!t)throw Error(`ghostty-web is not initialized. Open Settings and switch engine again.`);let n=new t.Terminal(e),r=new t.FitAddon;return n.loadAddon(r),{terminal:n,fitAddon:r,afterOpenHook:()=>{let e=n;e.registerLinkProvider&&e.registerLinkProvider(new t.UrlRegexProvider(n))},engine:`ghostty`}}createInputPanelAddon(e,t){return new Vx({onInput:t=>this.writeToSession(e,t),onCommand:t=>this.runInputPanelCommand(e,t),getHistory:async()=>this.inputHistoryStore.list(),addHistory:async e=>this.inputHistoryStore.add(e),subscribeHistory:e=>this.inputHistoryStore.subscribe(e),platform:t,defaultLayout:this.inputPanelDefaultLayout,showFab:!1,stateKey:e,onSettingsChange:async e=>{await this.inputHistoryStore.setLimit(e.historyLimit)}})}runInputPanelCommand(e,t){let n=this.instances.get(e);return n?this.keybindings.runCommand(t,{terminal:n.terminal,writeInput:t=>this.writeToSession(e,t),zoomFont:e=>this.zoomFont(e),resetFontSize:()=>this.resetFontSize(),onAsyncError:e=>console.error(`[terminal] input panel command failed:`,e)})===`block`:!1}applyGhosttyBackground(e,t){if(e.rendererEngine!==`ghostty`)return;let n=e.terminal.options.theme??{},r=typeof n.background==`string`&&n.background.trim().length>0?n.background:this.resolveNearestOpaqueBackground(t);e.terminal.options.allowTransparency=!1,e.terminal.options.theme={...n,background:r}}isTransparentColor(e){let t=e.trim().toLowerCase();return t.length===0||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0,0,0,0)`}resolveNearestOpaqueBackground(e){let t=e;for(;t;){let e=window.getComputedStyle(t).backgroundColor;if(!this.isTransparentColor(e))return e;t=t.parentElement}return`rgb(26, 26, 26)`}resolveTerminalKeyInput(e){return e.type===`keydown`?e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey?The[e.key]??null:e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey?Ehe[e.key]??null:!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey?whe[e.key]??null:null:null}getKeyEventResult(e,t){return e===`xterm`?t===`allow`:t===`block`}attachTerminalShortcuts(e,t,n){e.attachCustomKeyEventHandler(r=>{let i=this.resolveTerminalKeyInput(r);if(i&&n(i))return r.preventDefault(),r.stopPropagation(),this.getKeyEventResult(t,`block`);let a=r.metaKey||r.ctrlKey;if(r.type!==`keydown`||!a)return this.getKeyEventResult(t,`allow`);let o=this.keybindings.handleKeyEvent(r,{terminal:e,writeInput:n,zoomFont:e=>this.zoomFont(e),resetFontSize:()=>this.resetFontSize(),onAsyncError:e=>console.error(`[terminal] keybinding failed:`,e)});return o===`block`&&(r.preventDefault(),r.stopPropagation()),this.getKeyEventResult(t,o)})}bindTerminalInput(e){e.terminal.onData(t=>{if(e.isExited){this.closeSession(e.id);return}let n=this.resolveServerSessionId(e.id);n&&this.wsSend({type:`input`,sessionId:n,data:t})})}isTerminalNotOpenedError(e){if(!(e instanceof Error))return!1;let t=e.message;return t.includes(`Terminal must be opened before use`)||t.includes(`Call terminal.open(parent) first`)}enqueuePendingOutput(e,t){if(t)for(e.pendingOutput.push(t),e.pendingOutputBytes+=t.length;e.pendingOutputBytes>bhe&&e.pendingOutput.length;){let t=e.pendingOutput.shift();if(!t)break;e.pendingOutputBytes-=t.length}}writeTerminalOutput(e,t){if(t){if(!e.hasOpened){this.enqueuePendingOutput(e,t);return}try{e.terminal.write(t)}catch(n){if(this.isTerminalNotOpenedError(n)){this.enqueuePendingOutput(e,t);return}console.error(`[terminal] failed to write output:`,n)}}}flushPendingOutput(e){if(!e.hasOpened||e.pendingOutput.length===0)return;let t=e.pendingOutput.join(``);e.pendingOutput=[],e.pendingOutputBytes=0,this.writeTerminalOutput(e,t)}replaceInstanceRenderer(e){let t=e.mountedContainer,n=e.serverSessionId;e.mountedContainer&&this.unmount(e.id),e.terminal.dispose();let{terminal:r,fitAddon:i,afterOpenHook:a,engine:o}=this.createRendererTerminal(),s=this.createInputPanelAddon(e.id,e.platform);r.loadAddon(s),this.attachTerminalShortcuts(r,o,t=>this.writeToSession(e.id,t)),e.terminal=r,e.fitAddon=i,e.inputPanelAddon=s,e.hasOpened=!1,e.afterOpenHook=a,e.mountedContainer=null,e.resizeObserver=null,e.rendererEngine=o,this.bindTerminalInput(e),t&&this.mount(e.id,t),n&&this.wsSend({type:`attach`,sessionId:n,cols:e.terminal.cols||80,rows:e.terminal.rows||24})}async ensureGhosttyModule(){return this.ghosttyModule?this.ghosttyModule:(this.ghosttyInitPromise||=c(()=>import(`./ghostty-web-BSS9uGcc.js`).then(async e=>(await e.init(),this.ghosttyModule=e,e)),__vite__mapDeps([25,6])).finally(()=>{this.ghosttyInitPromise=null}),this.ghosttyInitPromise)}async setRendererEngine(e){if(e!==this.config.rendererEngine){e===`ghostty`&&await this.ensureGhosttyModule(),this.config.rendererEngine=e;for(let e of this.instances.values())this.replaceInstanceRenderer(e);this._applyFonts(),this.notify()}}closeSession(e,t){let n=this.instances.get(e);if(!n)return;let r=t?.triggerCloseCallback!==!1;if(n.mountedContainer&&this.unmount(e),n.outputIdleTimer&&=(clearTimeout(n.outputIdleTimer),null),this.pendingCreates=this.pendingCreates.filter(t=>t.requestId!==e),n.serverSessionId){let e=n.serverSessionId;this.serverToLocalSessionId.delete(e),this.wsConnected&&this.ws?.readyState===WebSocket.OPEN?this.wsSend({type:`close`,sessionId:e}):this.pendingCloseSessionIds.add(e)}n.terminal.dispose(),r&&this.runCloseCallback(n),this.instances.delete(e),this.activeSessionId===e&&(this.activeSessionId=null),this.notify()}closeAll(){for(let e of this.instances.keys())this.closeSession(e,{triggerCloseCallback:!1});this.activeSessionId=null}mount(e,t){let n=this.instances.get(e);if(!n)return;if(n.mountedContainer===t){requestAnimationFrame(()=>{try{n.fitAddon.fit()}catch{}});return}if(n.mountedContainer&&this.unmount(e),!n.hasOpened)this.applyGhosttyBackground(n,t),n.terminal.open(t),n.hasOpened=!0,n.afterOpenHook?.(),n.afterOpenHook=null,this.flushPendingOutput(n),n.inputPanelAddon.attachListeners();else{let e=n.terminal.element;e&&!e.contains(t)&&e.parentNode!==t&&t.appendChild(e),this.flushPendingOutput(n),this.applyGhosttyBackground(n,t),n.inputPanelAddon.attachListeners()}n.mountedContainer=t,requestAnimationFrame(()=>{try{n.fitAddon.fit()}catch{}});let r=new ResizeObserver(()=>{try{if(n.fitAddon.fit(),n.terminal.cols&&n.terminal.rows){let t=this.resolveServerSessionId(e);if(!t)return;this.wsSend({type:`resize`,sessionId:t,cols:n.terminal.cols,rows:n.terminal.rows})}}catch{}});r.observe(t),n.resizeObserver=r,requestAnimationFrame(()=>{this.focusSession(e)})}unmount(e){let t=this.instances.get(e);!t||!t.mountedContainer||(t.resizeObserver&&=(t.resizeObserver.disconnect(),null),t.mountedContainer=null)}focusSession(e){let t=this.instances.get(e);if(!t||!t.hasOpened)return;let n=!1;try{t.terminal.focus?.(),n=!0}catch{}if(!n){let e=t.terminal.element;if(e instanceof HTMLElement)try{e.focus()}catch{}}t.inputPanelAddon.syncFocusLifecycle()}setActiveSessionId(e){e&&!this.instances.has(e)||(this.activeSessionId=e)}setCustomTitle(e,t){let n=this.instances.get(e);n&&(n.customTitle=t,this.notify())}getDisplayTitle(e){let t=this.instances.get(e);return t?t.customTitle??t.oscTitle??t.processTitle??t.label:``}getConfig(){return{...this.config}}getResolvedTheme(){return this.resolvedTheme}setThemeContext(e){(this.appDarkMode!==e.appDarkMode||this.systemDarkMode!==e.systemDarkMode)&&(this.appDarkMode=e.appDarkMode,this.systemDarkMode=e.systemDarkMode,this.refreshResolvedTheme())}applyConfig(e){let{rendererEngine:t,...n}=e;Object.assign(this.config,n);for(let e of this.instances.values()){let t=e.terminal;t.options.fontSize=this.config.fontSize,t.options.cursorBlink=this.config.cursorBlink,t.options.cursorStyle=this.config.cursorStyle,t.options.scrollback=this.config.scrollback}this.refreshResolvedTheme(),this._applyFonts(),t&&t!==this.config.rendererEngine&&this.setRendererEngine(t).catch(e=>{console.error(`[terminal] failed to switch renderer engine:`,e)}),this.notify()}refreshResolvedTheme(){let e=SS({useTheme:this.config.useTheme,lightTheme:this.config.lightTheme,darkTheme:this.config.darkTheme,appDarkMode:this.appDarkMode,systemDarkMode:this.systemDarkMode});this.resolvedTheme=e;for(let t of this.instances.values())t.terminal.options.theme=e.definition.palette,t.terminal.options.allowTransparency=!1,t.mountedContainer&&this.applyGhosttyBackground(t,t.mountedContainer)}async _applyFonts(){let e=this.config.fontFamily;if(!e){this._setFontFamily(TS);return}let t=e.split(/[,]+/).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=Dhe[e];if(t)n.push(t);else if(jS.includes(e))khe(e),n.push(e);else{let t=await Ohe(e);t&&n.push(t)}}n.push(TS),this._setFontFamily(n.join(`, `))}_setFontFamily(e){for(let t of this.instances.values())if(t.terminal.options.fontFamily=e,t.mountedContainer)try{t.fitAddon.fit()}catch{}}configPersistTimer=null;persistFontSize(){this.configPersistTimer&&clearTimeout(this.configPersistTimer),this.configPersistTimer=setTimeout(()=>{this.configPersistTimer=null,c(async()=>{let{trpcClient:e}=await import(`./trpc--JMUaLps.js`);return{trpcClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({trpcClient:e})=>{e.config.update.mutate({terminal:{fontSize:this.config.fontSize}})}).catch(()=>{})},Che)}zoomFont(e){let t=Math.min(She,Math.max(xhe,this.config.fontSize+e));t!==this.config.fontSize&&(this.applyConfig({fontSize:t}),this.persistFontSize())}resetFontSize(){this.config.fontSize!==AS&&(this.applyConfig({fontSize:AS}),this.persistFontSize())}writeToSession(e,t){let n=this.resolveServerSessionId(e);return n?this.wsSend({type:`input`,sessionId:n,data:t}):!1}writeWorkflowToSession(e,t,n){let r=this.resolveServerSessionId(e);if(!r)return Promise.reject(Error(`Terminal session is not ready.`));let i=`workflow-input-${++this.workflowInputRequestCounter}`;return new Promise((e,a)=>{this.pendingWorkflowInputs.set(i,{resolve:e,reject:a}),this.wsSend({type:`workflow-input`,requestId:i,sessionId:r,expectedRootGeneration:n,data:t})||(this.pendingWorkflowInputs.delete(i),a(Error(`Terminal connection is unavailable.`)))})}openInputPanel(e){let t=[e?this.instances.get(e):void 0,...this.instances.values()],n=t.find(e=>e&&e.mountedContainer)?.id??t.find(e=>e)?.id;if(!n)return!1;this.focusSession(n);let r=this.instances.get(n);return r?(r.inputPanelAddon.open(),!0):!1}hasServerSession(e){let t=this.getInstanceByServerSessionId(e);return!!t&&!t.isExited}focusServerSession(e){let t=this.getInstanceByServerSessionId(e);return!t||t.isExited?!1:(this.focusSession(t.id),!0)}subscribeActivation(e){return this.activationListeners.add(e),()=>{this.activationListeners.delete(e)}}requestActivateSession(e){let t=this.instances.get(e);return!t||t.isExited?!1:(this.emitActivationRequest(t.id),!0)}requestActivateServerSession(e){let t=this.getInstanceByServerSessionId(e);return!t||t.isExited?!1:(this.emitActivationRequest(t.id),!0)}getLocalSessionIdForServerSession(e){return this.getInstanceByServerSessionId(e)?.id??null}isSessionActive(e){return this.activeSessionId===e}async addInputHistory(e){await this.inputHistoryStore.add(e)}resolveServerSessionId(e){let t=this.instances.get(e);return t?t.serverSessionId:null}getInstanceByServerSessionId(e){let t=this.serverToLocalSessionId.get(e)??e;return this.instances.get(t)}getLocalSessionIdByServerSessionId(e){return this.serverToLocalSessionId.get(e)??e}handleCreatedResponse(e){let t=this.instances.get(e.requestId);if(!t){this.wsSend({type:`close`,sessionId:e.sessionId});return}t.serverSessionId=e.sessionId,t.platform=e.platform,t.cwdTarget=e.cwdTarget,t.initialCwd=e.initialCwd,t.rootGeneration=e.rootGeneration,t.inputPanelAddon.setPlatform(e.platform),t.isConnected=!0,this.serverToLocalSessionId.set(e.sessionId,e.requestId),this.notify()}handleOutputResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);if(!t)return;this.writeTerminalOutput(t,e.data);let n=t.lastOutputTime>0&&Date.now()-t.lastOutputTime<DS;t.lastOutputTime=Date.now(),n||this.notify(),t.outputIdleTimer&&clearTimeout(t.outputIdleTimer),t.outputIdleTimer=setTimeout(()=>{t.outputIdleTimer=null,this.notify()},DS)}handleExitResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);if(t){if(t.isExited=!0,t.exitCode=e.exitCode,t.closeTip||t.isDedicated){let n=t.closeTip??`Press any key to close (equivalent to close action).`;this.writeTerminalOutput(t,`\r\n\x1b[90m[Process exited with code ${e.exitCode}. ${n}]\x1b[0m`)}this.notify()}}handleTitleResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.oscTitle=e.title,this.notify())}handleProcessTitleResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.processTitle=e.title,this.notify())}handleCwdResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.cwd=e.cwd,this.notify())}handleProgressResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.progress=e.state===`clear`?null:{state:e.state,value:e.value},this.notify())}handlePromptStateResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.promptState=e.state,this.notify())}handleBellResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);!t||t.isExited||(t.lastBellAt=e.createdAt??Date.now(),this.bellSoundEngine.play(this.config.bellSound,this.config.bellVolume).catch(()=>{}),this.notify())}handleBufferResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);!t||!e.data||this.writeTerminalOutput(t,e.data)}handleErrorResponse(e){if(e.code===`PTY_CREATE_FAILED`&&e.sessionId){let t=this.instances.get(e.sessionId);t&&!t.serverSessionId&&(t.isExited=!0,t.exitCode=-1,this.writeTerminalOutput(t,`\r\n\x1b[31m[Failed to start PTY: ${e.message}]\x1b[0m`),this.notify())}console.warn(`[pty] ${e.code}: ${e.message}`,e)}setInputPanelMountTarget(e){Vx.mountTarget=e}setInputPanelDefaultLayout(e){this.inputPanelDefaultLayout=e;for(let t of this.instances.values())t.inputPanelAddon.setDefaultLayout(e)}getTerminalDimensions(e){let t=this.instances.get(e);return t?{cols:t.terminal.cols||80,rows:t.terminal.rows||24}:null}subscribe(e){return this.listeners.add(e),this.ensureWsConnected(),()=>{this.listeners.delete(e)}}getSnapshot(){if(this.snapshotCache)return this.snapshotCache;let e=[];for(let t of this.instances.values())e.push({id:t.id,serverSessionId:t.serverSessionId,label:t.label,customTitle:t.customTitle,processTitle:t.processTitle,oscTitle:t.oscTitle,cwd:t.cwd,cwdTarget:t.cwdTarget,initialCwd:t.initialCwd,rootGeneration:t.rootGeneration,progress:t.progress,promptState:t.promptState,displayTitle:t.customTitle??t.oscTitle??t.processTitle??t.label,isDedicated:t.isDedicated,isExited:t.isExited,exitCode:t.exitCode,outputActive:t.lastOutputTime>0&&Date.now()-t.lastOutputTime<DS,lastBellAt:t.lastBellAt,command:t.command,args:t.args,closeTip:t.closeTip,closeCallbackUrl:t.closeCallbackUrl,platform:t.platform});return this.snapshotCache={sessions:e},this.snapshotCache}notify(){this.snapshotCache=null;for(let e of this.listeners)e()}emitActivationRequest(e){this.setActiveSessionId(e);for(let t of this.activationListeners)t(e);this.scheduleSessionFocus(e)}scheduleSessionFocus(e){(typeof globalThis.requestAnimationFrame==`function`?globalThis.requestAnimationFrame.bind(globalThis):e=>globalThis.setTimeout(()=>e(Date.now()),0))(()=>{this.focusSession(e)})}ensureWsConnected(){this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN)||this.connectSharedWebSocket()}connectSharedWebSocket(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null);let e=new WebSocket(F());this.ws=e,e.onopen=()=>{this.wsConnected=!0,this.reconnectDelay=OS;let t=R();t&&e.send(JSON.stringify({type:`auth`,credential:t}));for(let e of this.pendingCloseSessionIds)this.wsSend({type:`close`,sessionId:e});this.pendingCloseSessionIds.clear(),this.wsSend({type:`list`});for(let e of this.pendingCreates)this.wsSend({type:`create`,requestId:e.requestId,cwdTarget:e.cwdTarget,expectedRootGeneration:e.expectedRootGeneration,cols:e.cols,rows:e.rows,command:e.command,args:e.args,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl});this.pendingCreates=[];for(let e of this.instances.values())if(!e.restored)continue;this.notify()},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let n=mue.safeParse(t);n.success&&this.handleServerMessage(n.data)},e.onclose=()=>{this.wsConnected=!1,this.ws=null;for(let e of this.pendingWorkflowInputs.values())e.reject(Error(`Terminal connection closed before workflow input was accepted.`));this.pendingWorkflowInputs.clear(),this.notify(),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,(this.listeners.size>0||this.instances.size>0)&&this.connectSharedWebSocket()},this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*1.5,yhe)},e.onerror=()=>{}}handleServerMessage(e){switch(e.type){case`list`:this.handleListResponse(e);break;case`created`:this.handleCreatedResponse(e);break;case`workflow-input-accepted`:{let t=this.pendingWorkflowInputs.get(e.requestId);if(!t)break;this.pendingWorkflowInputs.delete(e.requestId),t.resolve();break}case`workflow-input-rejected`:{let t=this.pendingWorkflowInputs.get(e.requestId);if(!t)break;this.pendingWorkflowInputs.delete(e.requestId),t.reject(Error(e.message));break}case`buffer`:this.handleBufferResponse(e);break;case`output`:this.handleOutputResponse(e);break;case`exit`:this.handleExitResponse(e);break;case`title`:this.handleTitleResponse(e);break;case`process-title`:this.handleProcessTitleResponse(e);break;case`cwd`:this.handleCwdResponse(e);break;case`progress`:this.handleProgressResponse(e);break;case`prompt-state`:this.handlePromptStateResponse(e);break;case`bell`:this.handleBellResponse(e);break;case`error`:this.handleErrorResponse(e);break}}handleListResponse(e){let t=new Set(e.sessions.map(e=>e.id));for(let t of e.sessions){let e=this.getLocalSessionIdByServerSessionId(t.id),n=this.instances.get(e);if(n)n.serverSessionId||=t.id;else{let e=t.title||`${t.command} ${t.args.join(` `)}`.trim();n=this.createTerminalInstance(t.id,{label:e.length>40?`${e.slice(0,37)}...`:e,command:t.command,args:t.args,isDedicated:!1,closeTip:t.closeTip,closeCallbackUrl:t.closeCallbackUrl,initialInput:void 0,customTitle:null,restored:!0,serverSessionId:t.id,platform:t.platform??kS,cwdTarget:t.cwdTarget,initialCwd:t.initialCwd,rootGeneration:t.rootGeneration}),t.isExited&&(n.isExited=!0,n.exitCode=t.exitCode),this.bindTerminalInput(n),this.instances.set(n.id,n),this._applyFonts()}n.closeTip=t.closeTip,n.closeCallbackUrl=t.closeCallbackUrl,n.cwdTarget=t.cwdTarget,n.initialCwd=t.initialCwd,n.rootGeneration=t.rootGeneration,n.platform=t.platform??kS,n.inputPanelAddon.setPlatform(n.platform),this.serverToLocalSessionId.set(t.id,n.id),this.wsSend({type:`attach`,sessionId:t.id,cols:n.terminal.cols||80,rows:n.terminal.rows||24})}for(let e of this.instances.values())e.restored&&e.serverSessionId&&!t.has(e.serverSessionId)&&!e.isExited&&(e.isExited=!0,e.exitCode=-1);this.hasDiscoveredSessions=!0,this.notify()}get discoveredSessions(){return this.hasDiscoveredSessions}runCloseCallback(e){if(!e.isExited)return;let t=jhe(e.closeCallbackUrl,e.exitCode);t&&Mhe(t)}wsSend(e){return this.ws?.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(e)),!0):!1}};function jhe(e,t){if(!e)return null;if(typeof e==`string`){let t=e.trim();return t.length>0?t:null}let n=e[t==null?`null`:String(t)];if(typeof n==`string`&&n.trim().length>0)return n.trim();let r=e[`*`];return typeof r==`string`&&r.trim().length>0?r.trim():null}function Mhe(e){let t;try{t=new URL(e,window.location.origin)}catch{return}if(t.origin===window.location.origin){let e=`${t.pathname}${t.search}${t.hash}`,n=ls.getAreaForPath(t.pathname);ls.push(n,e,null);return}window.open(t.toString(),`_blank`,`noopener,noreferrer`)}var PS=new Ahe;e(i(((e,t)=>{t.exports={}}))(),1);var FS=Mae;m({sound:FS.default(Vu),volume:Nae,systemNotificationsEnabled:f().default(!1)});var Nhe=P(`type`,[m({type:v(`terminal`),sessionId:S().min(1),title:S().optional()}),m({type:v(`openspec-change`),changeId:S().min(1),title:S().optional()}),m({type:v(`hooks-plugin`),pluginId:S().min(1),title:S().optional()}),m({type:v(`root-context`)}),m({type:v(`custom`),groupId:S().min(1),title:S().optional()})]),Phe=P(`type`,[m({type:v(`terminal.focus`),label:S().default(`Focus terminal`),target:m({sessionId:S().min(1)})}),m({type:v(`href.open`),label:S().default(`Open`),target:m({href:S().min(1)})})]),Fhe=S().min(1);m({title:S().min(1).max(160),body:S().max(2e3).default(``),source:Nhe,actions:p(Phe).default([]),level:l([`info`,`success`,`warning`,`error`]).default(`info`),createdAt:x().int().positive().optional()}).extend({id:S().min(1),createdAt:x().int().positive(),groupKey:Fhe});function Ihe(e){return e.type===`terminal`?e.title?.trim()||`Terminal ${e.sessionId}`:e.type===`openspec-change`?e.title?.trim()||`Change ${e.changeId}`:e.type===`hooks-plugin`?e.title?.trim()||`Plugin ${e.pluginId}`:e.type===`root-context`?`Root Context`:e.title?.trim()||e.groupId}function IS(e){return Array.isArray(e)?`[${e.map(e=>IS(e)).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${IS(t)}`).join(`,`)}}`:JSON.stringify(e)}function Lhe(e){return IS({groupKey:e.groupKey,title:e.title,body:e.body,source:e.source,actions:e.actions,level:e.level})}function Rhe(e){let t=new Map;for(let n of e){let e=Lhe(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort((e,t)=>t.createdAt-e.createdAt);return{key:e,notifications:n,latest:n[0],count:n.length}}).sort((e,t)=>t.latest.createdAt-e.latest.createdAt)}function zhe(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?e.push(n):t.set(n.groupKey,[n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort((e,t)=>t.createdAt-e.createdAt),r=n[0];return{key:e,label:Ihe(r.source),source:r.source,notifications:n,aggregates:Rhe(n),latest:r,unreadCount:n.length}}).sort((e,t)=>t.latest.createdAt-e.latest.createdAt)}function LS(){if(typeof window>`u`)return;let e=ee(),t=e.endsWith(`/`)?e:`${e}/`;return new URL(`${t}icon.rounded.svg`,window.location.href).href}var Bhe=class extends $x{constructor(){super(`notification`)}},RS=(0,Y.createContext)(null);function Vhe({value:e,children:t}){return(0,J.jsx)(RS,{value:e,children:t})}var Hhe={notifications:[],latestNotification:null,groups:[],unreadCount:0,highlightedId:null,browserSupported:!1,browserPermission:`unsupported`,panelOpen:!1,openPanel:()=>void 0,requestBrowserPermission:async()=>`unsupported`,previewSound:async()=>void 0,resolveAction:(e,t)=>({action:t,disabled:!0,reason:`Notifications are not available in this render tree.`,run:async()=>void 0}),markRead:async()=>void 0,markManyRead:async()=>void 0,clearGroup:async()=>void 0,clearAll:async()=>void 0,clearTerminalSession:async()=>void 0};function zS(){return typeof window<`u`&&`Notification`in window}function Uhe(){return zS()?Notification.permission:`unsupported`}function Whe(e){if(!e)return`/notifications`;let t=new URLSearchParams;return t.set(`highlight`,e),`/notifications?${t.toString()}`}function Ghe(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Khe(e){return e.body.trim()||e.title}function qhe(e){let t=e[0];if(!t)return``;let n=Ghe(t.createdAt);return e.length<=1?`${n} - 1 unread`:`${n} - ${e.length} unread notifications`}async function Jhe(){if(ls.getAreaForPath(`/terminal`)===`bottom`){await Vp.activateBottom(`/terminal`);return}await Vp.push(`main`,`/terminal`,null)}function Yhe({children:e}){let{data:t}=Ise(),{data:n}=Xf(),r=us(),i=t??[],a=(0,Y.useMemo)(()=>zhe(i),[i]),o=i[0]??null,[s,c]=(0,Y.useState)(()=>Uhe()),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=r.popActive&&r.popLocation.pathname===`/notifications`,h=n?.notifications?.systemNotificationsEnabled??!1,g=n?.notifications?.sound??`builtin:Blow`,_=n?.notifications?.volume??1;(0,Y.useEffect)(()=>{let e=new Bhe;e.init(),d.current=e},[]);let v=(0,Y.useCallback)(e=>{typeof window<`u`&&window.focus(),u(e??null),Vp.activatePop(Whe(e))},[]),y=(0,Y.useCallback)(async e=>{await q.notifications.markRead.mutate({id:e})},[]),b=(0,Y.useCallback)(async e=>{await q.notifications.markManyRead.mutate({ids:[...e]})},[]),x=(0,Y.useCallback)(async e=>{await q.notifications.clearGroup.mutate({groupKey:e})},[]),S=(0,Y.useCallback)(async()=>{await q.notifications.clearAll.mutate()},[]),C=(0,Y.useCallback)(async e=>{await q.notifications.clearTerminalSession.mutate({sessionId:e})},[]),w=(0,Y.useCallback)(async()=>{if(!zS())return c(`unsupported`),`unsupported`;let e=await Notification.requestPermission();return c(e),e===`granted`&&await q.config.update.mutate({notifications:{systemNotificationsEnabled:!0}}),e},[]),T=(0,Y.useCallback)(async(e,t)=>{await d.current?.play(e??g,t??_)},[g,_]),E=(0,Y.useCallback)((e,t,n)=>{let r=n?.markReadOnRun??!0;if(t.type===`terminal.focus`){let n=PS.hasServerSession(t.target.sessionId);return{action:t,disabled:!n,reason:n?void 0:`Target terminal is no longer available.`,run:async()=>{PS.hasServerSession(t.target.sessionId)&&(await Vp.deactivatePop(),await Jhe(),PS.requestActivateServerSession(t.target.sessionId)&&r&&await y(e.id))}}}return{action:t,disabled:!1,run:async()=>{let n=ls.getAreaForPath(t.target.href);m&&await Vp.deactivatePop(),await Vp.push(n,t.target.href,null),r&&await y(e.id)}}},[y,m]);return(0,Y.useEffect)(()=>{let e=o?.id??null;if(!e||f.current===e){f.current=e;return}if(f.current=e,d.current?.play(g,_).catch(()=>{}),!h||m||!zS()||Notification.permission!==`granted`)return;p.current?.close();let t=new Notification(Khe(o),{body:qhe(i),icon:LS(),tag:`openspecui-notifications`});t.onclick=()=>{v(o.id),t.close()},p.current=t},[o,i,v,m,g,h,_]),(0,Y.useEffect)(()=>{m&&(p.current?.close(),p.current=null)},[m]),(0,Y.useEffect)(()=>{r.popLocation.pathname===`/notifications`&&u(new URLSearchParams(r.popLocation.search).get(`highlight`))},[r.popLocation.pathname,r.popLocation.search]),(0,J.jsx)(Vhe,{value:(0,Y.useMemo)(()=>({notifications:i,latestNotification:o,groups:a,unreadCount:i.length,highlightedId:l,browserSupported:zS(),browserPermission:s,panelOpen:m,openPanel:v,requestBrowserPermission:w,previewSound:T,resolveAction:E,markRead:y,markManyRead:b,clearGroup:x,clearAll:S,clearTerminalSession:C}),[s,S,x,C,a,l,o,b,y,i,v,m,T,w,E]),children:e})}function BS(){return(0,Y.useContext)(RS)||Hhe}function VS({className:e,badgeClassName:t,iconClassName:n,size:r=`mobile`}){let{unreadCount:i,openPanel:a}=BS();return(0,J.jsx)(Eh,{label:i>0?`Open notifications, ${i} unread`:`Open notifications`,icon:(0,J.jsx)(qp,{className:fr(`h-4 w-4`,n)}),badge:i>0?(0,J.jsx)(vh,{count:i,className:fr(`ring-background absolute -right-1.5 -top-1.5 ring-2`,t),"aria-hidden":`true`}):void 0,size:r,className:e,onClick:()=>a(),"data-notification-entry-button":`true`})}function HS({children:e,maxWidth:t=300,duration:n=10,gap:r=20,className:i=``}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=()=>{if(l.current&&u.current){let e=l.current.offsetWidth,t=u.current.scrollWidth;c(t>e)}};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[e]);let d=(0,Y.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error(`Failed to copy path:`,e)}},[e]),f=typeof t==`number`?`${t}px`:t;return(0,J.jsxs)(`button`,{onClick:d,className:`hover:bg-muted/50 group flex cursor-pointer items-center gap-1.5 rounded transition-colors ${i}`,title:`${e}\n\nClick to copy`,children:[(0,J.jsx)(`div`,{ref:l,className:`relative overflow-hidden whitespace-nowrap`,style:{maxWidth:f},children:(0,J.jsx)(`div`,{ref:u,"data-content":e,className:`relative inline-block ${s?`animate-marquee group-hover:[animation-play-state:paused]!`:``}`,style:s?{"--marquee-duration":`${n}s`,"--marquee-gap":`${r}px`}:void 0,children:e})}),(0,J.jsx)(`span`,{className:`text-muted-foreground group-hover:text-foreground shrink-0 transition-colors`,children:a?(0,J.jsx)(Xp,{className:`h-3.5 w-3.5 text-green-500`}):(0,J.jsx)(rm,{className:`h-3.5 w-3.5`})})]})}function US({compact:e=!1}){if(B())return(0,J.jsxs)(`div`,{className:`status-indicator flex items-center gap-1.5 text-xs`,title:`Live features disabled (no file watching, task toggling, or AI integration)`,children:[(0,J.jsx)(Tce,{className:`h-3.5 w-3.5 text-blue-500`}),!e&&(0,J.jsx)(`span`,{className:`status-text text-blue-600`,children:`Static`})]});let t=kh(),n=Qle();if(t.connected){let n=t.watcherEnabled?`Watching for changes`:`File watcher disabled`;return(0,J.jsxs)(`div`,{className:`status-indicator flex items-center gap-1.5 text-xs`,children:[(0,J.jsx)(Em,{className:`h-3.5 w-3.5 text-green-500`}),!e&&(0,J.jsx)(gh,{content:n,children:(0,J.jsx)(`span`,{className:`status-text cursor-default text-green-600`,children:`Live`})})]})}return(0,J.jsxs)(`div`,{className:`status-indicator flex items-center gap-1.5 text-xs`,children:[(0,J.jsx)(Zm,{className:`h-3.5 w-3.5 text-red-500`}),!e&&(0,J.jsx)(`span`,{className:`status-text text-red-600`,children:`Offline`}),t.reconnectCountdown!==null&&(0,J.jsxs)(`button`,{onClick:n,className:`text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1 transition-colors`,title:`Click to reconnect now`,children:[(0,J.jsxs)(`span`,{className:`text-xs`,children:[`(`,t.reconnectCountdown,`s)`]}),(0,J.jsx)(Fm,{className:`h-3 w-3`})]})]})}function Xhe(){let e=B(),[t,n]=(0,Y.useState)(`Unknown`),[r,i]=(0,Y.useState)(null);if((0,Y.useEffect)(()=>{e&&hf().then(e=>{e?.meta?.timestamp?n(new Date(e.meta.timestamp).toLocaleString()):n(`Unknown`),i(e?.git?.repositoryUrl??null)}).catch(()=>{n(`Unknown`),i(null)})},[e]),e)return(0,J.jsx)(`div`,{className:`desktop-status border-border bg-muted/30 text-muted-foreground flex h-8 items-center justify-between gap-4 border-t px-2 text-xs`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-4`,children:[(0,J.jsx)(US,{}),(0,J.jsxs)(`span`,{className:`truncate`,children:[`Generated: `,t]}),r&&(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(Wce,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(HS,{children:r,maxWidth:280,duration:12,className:`text-xs`})]})]})});let a=kh();return(0,J.jsxs)(`div`,{className:`desktop-status border-border bg-muted/30 text-muted-foreground flex h-8 items-center justify-between gap-4 border-t px-2 text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsx)(US,{}),a.projectDir&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(gm,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(HS,{children:a.projectDir,maxWidth:300,duration:12,className:`text-xs`})]})]}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(VS,{})})]})}function Zhe(){let[e,t]=(0,Y.useState)(!1),n=Ro(),r=kh(),i=us(),a=r.dirName??`OpenSpec`,o=ee(),s=B(),c=()=>t(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`header`,{className:`mobile-header border-border bg-background flex h-12 items-center justify-between border-b px-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`button`,{onClick:()=>t(!0),className:`hover:bg-muted -ml-1.5 rounded-md p-1.5`,"aria-label":`Open menu`,children:(0,J.jsx)(qce,{className:`h-5 w-5`})}),(0,J.jsx)(`span`,{className:`font-nav max-w-[min(52vw,18rem)] truncate text-[12px] tracking-[0.04em]`,children:a})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Eh,{label:`Open search`,icon:(0,J.jsx)(zm,{className:`h-4 w-4`}),onClick:()=>Vp.activatePop(`/search`)}),!s&&(0,J.jsx)(VS,{}),(0,J.jsx)(US,{compact:!0})]})]}),e&&(0,J.jsxs)(`div`,{className:`fixed inset-0 z-50 flex`,children:[(0,J.jsx)(`div`,{className:`animate-in fade-in absolute inset-0 bg-black/50 duration-200`,onClick:c}),(0,J.jsxs)(`nav`,{className:`bg-background border-border animate-in slide-in-from-left relative flex h-full w-64 max-w-[80vw] flex-col border-r p-4 duration-200`,children:[(0,J.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,J.jsx)(`img`,{src:n?`${o}openspec_pixel_dark.svg`:`${o}openspec_pixel_light.svg`,alt:`OpenSpec`,className:`h-5`}),(0,J.jsx)(`button`,{onClick:c,className:`hover:bg-muted rounded-md p-1.5`,"aria-label":`Close menu`,children:(0,J.jsx)(pn,{className:`h-5 w-5`})})]}),s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`ul`,{className:`flex-1 space-y-1`,children:Sh.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(Rp,{to:e.to,onClick:c,className:`hover:bg-muted [&.active]:bg-primary [&.active]:text-primary-foreground flex items-center gap-2 rounded-md px-3 py-2`,children:[(0,J.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`font-nav text-base tracking-[0.04em]`,children:e.label})]})},e.to))}),(0,J.jsx)(`div`,{className:`border-border space-y-1 border-t pt-4`,children:(0,J.jsxs)(Rp,{to:Ch.to,onClick:c,className:`hover:bg-muted [&.active]:bg-primary [&.active]:text-primary-foreground flex items-center gap-2 rounded-md px-3 py-2`,children:[(0,J.jsx)(Ch.icon,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`font-nav text-base tracking-[0.04em]`,children:Ch.label})]})})]}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(Th,{area:`main`,tabs:i.mainTabs,className:`scrollbar-thin scrollbar-track-transparent h-full overflow-auto`,useLinks:!0,onNavigate:c})}),(0,J.jsx)(`div`,{className:`text-muted-foreground text-[10px] font-medium uppercase tracking-wider`,children:`Bottom`}),(0,J.jsx)(`div`,{className:`border-border border-t pt-2`,children:(0,J.jsx)(Th,{area:`bottom`,tabs:i.bottomTabs,onNavigate:c})})]})]})]})]})}function Qhe(){let e=us();return(0,J.jsx)(`nav`,{className:`mobile-tabbar border-border bg-background flex h-14 items-stretch border-t`,children:(B()?qle:e.mainTabs.map(e=>xh.find(t=>t.to===e)).filter(e=>e!=null)).map(e=>(0,J.jsxs)(Rp,{to:e.to,className:`text-muted-foreground hover:text-foreground [&.active]:text-primary flex flex-1 flex-col items-center justify-center gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`relative`,children:[(0,J.jsx)(e.icon,{className:`h-5 w-5 shrink-0`}),e.beta?(0,J.jsx)(bh,{}):null]}),(0,J.jsx)(`span`,{className:`font-nav text-[10px] tracking-[0.03em]`,children:e.label})]},e.to))})}function WS(e,t){(0,Y.useInsertionEffect)(()=>{if(typeof document>`u`)return;let n=[...document.head.querySelectorAll(`style[data-head-style]`)].find(t=>t.dataset.headStyle===e);if(n){let e=Number(n.dataset.refCount??`1`);return n.dataset.refCount=String(e+1),n.textContent!==t&&(n.textContent=t),()=>{let e=Number(n.dataset.refCount??`1`)-1;if(e<=0){n.remove();return}n.dataset.refCount=String(e)}}let r=document.createElement(`style`);return r.setAttribute(`data-head-style`,e),r.dataset.refCount=`1`,r.textContent=t,document.head.appendChild(r),()=>{let e=Number(r.dataset.refCount??`1`)-1;if(e>0){r.dataset.refCount=String(e);return}r.remove()}},[t,e])}function GS({open:e,title:t,headerActions:n,onClose:r,onDismissRequest:i,onClosed:a,children:o,footer:s,dialogClassName:c=``,contentClassName:l=``,contentShellClassName:u=``,className:d=``,bodyClassName:f=``,maxHeight:p=`86vh`,borderVariant:m=`default`}){let h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),_=(0,Y.useId)(),v=i===void 0?r:i;(0,Y.useEffect)(()=>{let e=h.current;if(!e||!a)return;let t=()=>{a()};return e.addEventListener(`close`,t),()=>{e.removeEventListener(`close`,t)}},[a]),(0,Y.useLayoutEffect)(()=>{let t=h.current;t&&(e&&!t.open?typeof t.showModal==`function`?t.showModal():t.setAttribute(`open`,``):!e&&t.open&&(typeof t.close==`function`?t.close():t.removeAttribute(`open`)))},[e]),(0,Y.useEffect)(()=>{let e=h.current;if(!e)return;let t=e=>{e.preventDefault(),v?.()},n=e=>{let t=g.current;if(!t||e.target instanceof Node&&t.contains(e.target))return;let n=t.getBoundingClientRect();e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top&&e.clientY<=n.bottom||v?.()};return e.addEventListener(`cancel`,t),e.addEventListener(`click`,n),()=>{e.removeEventListener(`cancel`,t),e.removeEventListener(`click`,n)}},[v]);let y=m===`error`?`border-red-500/60`:m===`success`?`border-green-500/50`:`border-border`;return WS(`dialog:openspec-dialog`,(0,Y.useMemo)(()=>String.raw`
883
+ `}};customElements.define(`virtual-trackpad-tab`,Lme);function Rme(e){return new URLSearchParams(e.search).get(`session`)?.trim()||null}function jx(e,t=window.location){let n=Rme(t);return n?`hosted-session:${n}:${e}`:e}var Mx=1.5,Nx=30,zme=50,Px=15;function Fx(){return`ontouchstart`in window||navigator.maxTouchPoints>0}function Ix(e){return e instanceof HTMLElement&&e.classList.contains(`terminal-touch-mouse-overlay`)}function Bme(e,t,n){let r=document.elementFromPoint(t,n);if(r&&Ix(r)){let e=r,i=e.style.pointerEvents;e.style.pointerEvents=`none`,r=document.elementFromPoint(t,n),e.style.pointerEvents=i}return r&&e.contains(r)&&!Ix(r)?r:e.querySelector(`.xterm-screen`)??e}function Lx(e){return e===`input`||e===`keys`||e===`shortcuts`||e===`trackpad`||e===`settings`}function Vme(e){return e===`copy`||e===`paste`||e===`select-all`}function Rx(e){return typeof e==`object`&&!!e}function zx(){try{let e=localStorage.getItem(jx(`xtermInputPanelState`));if(!e)return{};let t=JSON.parse(e);return Rx(t)?t:{}}catch{return{}}}function Hme(e){try{localStorage.setItem(jx(`xtermInputPanelState`),JSON.stringify(e))}catch{}}function Ume(e){let t=zx().sessions;if(!t)return null;let n=t[e];if(!Rx(n))return null;let r={activeTab:`input`,inputDraft:``};return Lx(n.activeTab)&&(r.activeTab=n.activeTab),typeof n.inputDraft==`string`&&(r.inputDraft=n.inputDraft),r}function Bx(){let e=zx();return Lx(e.lastActiveTab)?e.lastActiveTab:`input`}var Vx=class e{static _lastActiveTab=`input`;static _active=null;static _lastFocused=null;static _instances=new Set;static _onActiveChangeFn=null;static _mountTarget=null;static get activeInstance(){return e._active}static set onActiveChange(t){e._onActiveChangeFn=t}static set mountTarget(t){e._mountTarget=t,e._fabEl&&t&&t.appendChild(e._fabEl)}static get mountTarget(){return e._mountTarget}static _fabEl=null;static _fabSubscriberCount=0;static _ensureFab(t){if(e._fabEl){e._fabEl.parentElement!==t&&t.appendChild(e._fabEl);return}let n=document.createElement(`button`);n.type=`button`,n.title=`Open InputPanel`,n.replaceChildren(Ob(24)),Object.assign(n.style,{position:`fixed`,zIndex:`50`,width:`56px`,height:`56px`,borderRadius:`50%`,border:`2px solid currentColor`,display:`flex`,alignItems:`center`,justifyContent:`center`,touchAction:`none`,userSelect:`none`,webkitUserSelect:`none`,webkitTouchCallout:`none`,cursor:`pointer`,boxShadow:`0 4px 12px rgba(0,0,0,0.3)`,background:`var(--primary, #e04a2f)`,color:`var(--primary-foreground, #fff)`,padding:`0`,margin:`0`,outline:`none`});let r=window.innerWidth-72,i=window.innerHeight-140;try{let e=localStorage.getItem(`input-panel-fab-pos`);if(e){let t=JSON.parse(e);r=t.x??r,i=t.y??i}}catch{}r=Math.max(0,Math.min(window.innerWidth-56,r)),i=Math.max(0,Math.min(window.innerHeight-56,i)),n.style.left=`${r}px`,n.style.top=`${i}px`;let a=!1,o=!1,s=0,c=0,l=0,u=0,d=()=>{let t=e._lastFocused,n=(t&&e._instances.has(t)?t:null)??[...e._instances].find(e=>e._terminal!=null)??null;n&&(e._lastFocused=n,n.open())};n.addEventListener(`pointerdown`,e=>{a=!0,o=!1,s=e.clientX,c=e.clientY,l=parseInt(n.style.left)||0,u=parseInt(n.style.top)||0,n.setPointerCapture(e.pointerId),e.preventDefault()}),n.addEventListener(`pointermove`,e=>{if(!a)return;let t=e.clientX-s,r=e.clientY-c;(Math.abs(t)>4||Math.abs(r)>4)&&(o=!0);let i=Math.max(0,Math.min(window.innerWidth-56,l+t)),d=Math.max(0,Math.min(window.innerHeight-56,u+r));n.style.left=`${i}px`,n.style.top=`${d}px`}),n.addEventListener(`pointerup`,()=>{if(a){a=!1;try{localStorage.setItem(`input-panel-fab-pos`,JSON.stringify({x:parseInt(n.style.left),y:parseInt(n.style.top)}))}catch{}o||d()}}),n.addEventListener(`pointercancel`,()=>{a=!1});let f=!1;n.addEventListener(`pointerdown`,()=>{f=!0},{capture:!0}),n.addEventListener(`click`,()=>{if(f){f=!1;return}d()}),n.addEventListener(`contextmenu`,e=>{e.preventDefault(),e.stopPropagation()}),n.addEventListener(`dragstart`,e=>{e.preventDefault()}),window.addEventListener(`resize`,()=>{let e=Math.min(parseInt(n.style.left)||0,window.innerWidth-56),t=Math.min(parseInt(n.style.top)||0,window.innerHeight-56);n.style.left=`${Math.max(0,e)}px`,n.style.top=`${Math.max(0,t)}px`}),t.appendChild(n),e._fabEl=n}static _setFabVisible(t){e._fabEl&&(e._fabEl.style.display=t&&e._fabSubscriberCount>0?`flex`:`none`)}_terminal=null;_panel=null;_cursorEl=null;_cursorPos={x:0,y:0};_isDragging=!1;_isOpen=!1;_edgeScrollTimer=null;_cleanups=[];_persistentCleanups=[];_listenersAttached=!1;_onInput;_onCommand;_onOpenCb;_onCloseCb;_getHistory;_addHistory;_subscribeHistory;_onSettingsChange;_platform;_defaultLayout;_showFab;_fabSubscribed;_panelSessionState;_stateKey;_hasOwnPersistedState;constructor(t){this._onInput=t?.onInput??(()=>{}),this._onCommand=t?.onCommand??null,this._onOpenCb=t?.onOpen??null,this._onCloseCb=t?.onClose??null,this._getHistory=t?.getHistory??null,this._addHistory=t?.addHistory??null,this._subscribeHistory=t?.subscribeHistory??null,this._onSettingsChange=t?.onSettingsChange??null,this._platform=t?.platform??`common`,this._defaultLayout=t?.defaultLayout??`floating`,this._showFab=t?.showFab??!0,this._fabSubscribed=!1,this._stateKey=t?.stateKey?.trim()?t.stateKey:`default`,this._hasOwnPersistedState=!1,this._panelSessionState={activeTab:`input`,inputDraft:``};let n=Ume(this._stateKey);n?(this._panelSessionState=n,this._hasOwnPersistedState=!0):this._panelSessionState.activeTab=e._lastActiveTab||Bx()}get isOpen(){return this._isOpen}set onOpen(e){this._onOpenCb=e}set onClose(e){this._onCloseCb=e}set onInput(e){this._onInput=e}set onCommand(e){this._onCommand=e}setPlatform(e){this._platform=e,this._applyPlatformToPanel()}setDefaultLayout(e){this._defaultLayout=e}_persistPanelState(){e._lastActiveTab=this._panelSessionState.activeTab;let t=zx(),n={...t.sessions,[this._stateKey]:{activeTab:this._panelSessionState.activeTab,inputDraft:this._panelSessionState.inputDraft}};Hme({...t,lastActiveTab:this._panelSessionState.activeTab,sessions:n})}_getMountTarget(){return e._mountTarget??this._getTerminalHostElement()??document.body}_getTerminalHostElement(){let e=this._terminal?.element;return e instanceof HTMLElement?e.classList.contains(`xterm`)&&e.parentElement instanceof HTMLElement?e.parentElement:e:null}_detectTerminalEngine(){let e=this._terminal?.element;return e instanceof HTMLElement&&e.classList.contains(`xterm`)?`xterm`:`non-xterm`}activate(t){this._terminal=t,e._instances.add(this)}dispose(){this.close();for(let e of this._persistentCleanups)e();this._persistentCleanups=[],this._listenersAttached=!1,this._fabSubscribed&&(e._fabSubscriberCount=Math.max(0,e._fabSubscriberCount-1),this._fabSubscribed=!1,e._setFabVisible(e._active===null)),e._instances.delete(this),e._lastFocused===this&&(e._lastFocused=null),this._terminal=null}attachListeners(){if(this._listenersAttached||!this._terminal)return;let t=this._terminal.textarea;if(!t)return;this._listenersAttached=!0,this._showFab?(e._ensureFab(this._getMountTarget()),this._fabSubscribed||=(e._fabSubscriberCount+=1,!0),e._setFabVisible(!0)):e._fabSubscriberCount===0&&e._setFabVisible(!1),e._lastFocused||=this;let n=()=>{e._lastFocused=this,Fx()&&!this._isOpen&&this.open()};t.addEventListener(`focus`,n),this._persistentCleanups.push(()=>t.removeEventListener(`focus`,n)),Fx()&&t.setAttribute(`inputmode`,`none`)}open(){if(!this._terminal)return;if(this._isOpen){if(this._panel?.isConnected)return;this.close()}if(e._active&&e._active!==this&&e._active.close(),this._isOpen=!0,e._active=this,e._lastFocused=this,this._showFab&&e._setFabVisible(!1),this._suppressKeyboard(),!this._hasOwnPersistedState){let t=Bx();this._panelSessionState.activeTab=t,e._lastActiveTab=t}let t=document.createElement(`input-panel`);t.setAttribute(`layout`,this._defaultLayout),this._applyPanelThemeBindings(t),t.activeTab=this._panelSessionState.activeTab;let n=document.createElement(`input-method-tab`);n.setAttribute(`slot`,`input`),n.value=this._panelSessionState.inputDraft,t.appendChild(n);let r=document.createElement(`virtual-keyboard-tab`);r.setAttribute(`slot`,`keys`),r.setAttribute(`floating`,``),r.setAttribute(`platform`,this._platform),t.appendChild(r);let i=document.createElement(`shortcut-tab`);i.setAttribute(`slot`,`shortcuts`),i.setAttribute(`platform`,this._platform),t.appendChild(i);let a=document.createElement(`virtual-trackpad-tab`);a.setAttribute(`slot`,`trackpad`),a.setAttribute(`floating`,``),t.appendChild(a),this._panel=t;let o=e=>{this._renderHistory(n,e)};if(this._getHistory&&this._getHistory().then(e=>o(e)).catch(()=>{}),this._subscribeHistory)try{let e=this._subscribeHistory(e=>{o(e)});this._cleanups.push(e)}catch{}this._on(t,`input-panel:close`,()=>this.close()),this._on(t,`input-panel:send`,e=>{let t=e.detail?.data;if(t&&this._onInput(t),e.composedPath()[0]===n&&this._addHistory&&t){let e=this._normalizeHistoryText(t);e&&Promise.resolve(this._addHistory(e)).then(()=>this._getHistory?.()).then(e=>{e&&o(e)}).catch(()=>{})}}),this._on(t,`input-panel:command`,e=>{let t=e.detail;if(!Rx(t))return;let n=t.command;if(!Vme(n))return;let r=typeof t.fallbackData==`string`?t.fallbackData:void 0;Promise.resolve(this._onCommand?.(n,{fallbackData:r})??!1).then(e=>{!e&&r&&this._onInput(r)}).catch(()=>{r&&this._onInput(r)})}),this._on(n,`input-panel:input-change`,e=>{let t=e.detail?.value;typeof t==`string`&&(this._panelSessionState.inputDraft=t,this._hasOwnPersistedState=!0,this._persistPanelState())}),this._on(t,`input-panel:tab-change`,e=>{let t=e.detail?.tab;Lx(t)&&(this._panelSessionState.activeTab=t,this._hasOwnPersistedState=!0,this._persistPanelState()),t===`trackpad`?this._showCursor():this._hideCursor()}),this._on(t,`input-panel:settings-change`,e=>{if(!this._onSettingsChange)return;let t=e.detail;if(typeof t!=`object`||!t)return;let n=t;typeof n.fixedHeight!=`number`||typeof n.floatingWidth!=`number`||typeof n.floatingHeight!=`number`||typeof n.vibrationIntensity!=`number`||typeof n.historyLimit!=`number`||this._onSettingsChange({fixedHeight:n.fixedHeight,floatingWidth:n.floatingWidth,floatingHeight:n.floatingHeight,vibrationIntensity:n.vibrationIntensity,historyLimit:n.historyLimit})}),this._on(t,`trackpad:move`,e=>{let{dx:t,dy:n}=e.detail;this._moveCursor(t,n)}),this._on(t,`trackpad:tap`,()=>this._dispatchClick(1)),this._on(t,`trackpad:double-tap`,()=>this._dispatchDblClick()),this._on(t,`trackpad:long-press`,()=>this._dispatchRightClick()),this._on(t,`trackpad:two-finger-tap`,()=>this._dispatchRightClick()),this._on(t,`trackpad:drag-start`,()=>{this._isDragging=!0,this._dispatchMouse(`mousedown`,{detail:1})}),this._on(t,`trackpad:drag-move`,e=>{let{dx:t,dy:n}=e.detail;this._moveCursor(t,n),this._dispatchMouse(`mousemove`,{buttons:1}),this._updateEdgeScroll()}),this._on(t,`trackpad:drag-end`,()=>{this._isDragging=!1,this._stopEdgeScroll(),this._dispatchMouse(`mouseup`,{detail:1})}),this._on(t,`trackpad:scroll`,e=>{let{deltaY:t}=e.detail;this._dispatchWheel(t)}),this._getMountTarget().appendChild(t),this._createCursor(),this._focusTerminal(),this._onOpenCb?.(),e._onActiveChangeFn?.(this)}_applyPlatformToPanel(){if(!this._panel)return;let e=this._panel.querySelector(`virtual-keyboard-tab`),t=this._panel.querySelector(`shortcut-tab`);e?.setAttribute(`platform`,this._platform),t?.setAttribute(`platform`,this._platform)}_readThemeVar(e,t,n){for(let n of t){let t=e.getPropertyValue(n).trim();if(t)return t}return n}_applyPanelThemeBindings(e){let t=this._getTerminalHostElement()??this._getMountTarget(),n=getComputedStyle(t),r=this._readThemeVar(n,[`--input-panel-background`,`--terminal`,`--background`],`#1a1a1a`),i=this._readThemeVar(n,[`--input-panel-foreground`,`--terminal-foreground`,`--foreground`],`#ffffff`),a=this._readThemeVar(n,[`--input-panel-primary`,`--primary`],`#e04a2f`),o=this._readThemeVar(n,[`--input-panel-primary-foreground`,`--primary-foreground`],`#ffffff`),s=this._readThemeVar(n,[`--input-panel-border`,`--border`],`color-mix(in srgb, ${i} 24%, transparent)`),c=this._readThemeVar(n,[`--input-panel-muted`,`--muted`],`color-mix(in srgb, ${r} 86%, ${i} 14%)`),l=this._readThemeVar(n,[`--input-panel-muted-foreground`,`--muted-foreground`],`color-mix(in srgb, ${i} 62%, transparent)`);e.style.setProperty(`--input-panel-background`,r),e.style.setProperty(`--input-panel-foreground`,i),e.style.setProperty(`--input-panel-primary`,a),e.style.setProperty(`--input-panel-primary-foreground`,o),e.style.setProperty(`--input-panel-border`,s),e.style.setProperty(`--input-panel-muted`,c),e.style.setProperty(`--input-panel-muted-foreground`,l)}close(){if(this._isOpen){this._isOpen=!1,e._active===this&&(e._active=null),this._stopEdgeScroll();for(let e of this._cleanups)e();this._cleanups=[],this._panel?.remove(),this._panel=null,this._cursorEl?.remove(),this._cursorEl=null,Fx()||this._restoreKeyboard(),this._showFab&&e._setFabVisible(!0),this._onCloseCb?.(),e._onActiveChangeFn?.(null)}}toggle(){if(this._isOpen){this.close();return}this.open()}syncFocusLifecycle(){if(e._lastFocused=this,this._isOpen&&!this._panel?.isConnected){this.open();return}if(e._active&&e._active!==this){this.open();return}this._isOpen&&this._focusTerminal()}_focusTerminal(){let e=this._terminal?.textarea;e&&(Fx()&&e.setAttribute(`inputmode`,`none`),e.focus())}_createCursor(){let e=this._getTerminalHostElement();if(!e)return;let t=document.createElement(`div`);t.setAttribute(`data-input-panel-cursor`,`virtual-mouse`),t.setAttribute(`data-terminal-engine`,this._detectTerminalEngine()),t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;z-index:10;pointer-events:none;opacity:0;transition:opacity 0.15s;color:#fff;`;let n=Ope(20);n.style.filter=`drop-shadow(0 0 1px rgba(0,0,0,0.9))`,t.replaceChildren(n),e.appendChild(t),this._cursorEl=t;let r=e.getBoundingClientRect();this._cursorPos={x:r.width/2,y:r.height/2},this._positionCursor()}_positionCursor(){this._cursorEl&&(this._cursorEl.style.left=`${this._cursorPos.x-4}px`,this._cursorEl.style.top=`${this._cursorPos.y-2}px`)}_showCursor(){if(this._cursorEl||this._createCursor(),this._cursorEl){let e=this._getTerminalHostElement();if(e){let t=e.getBoundingClientRect();this._cursorPos={x:t.width/2,y:t.height/2},this._positionCursor()}this._cursorEl.style.opacity=`1`}}_hideCursor(){this._cursorEl&&(this._cursorEl.style.opacity=`0.3`)}_moveCursor(e,t){let n=this._getTerminalHostElement();if(!n)return;let r=n.getBoundingClientRect();this._cursorPos.x=Math.max(0,Math.min(r.width,this._cursorPos.x+e*Mx)),this._cursorPos.y=Math.max(0,Math.min(r.height,this._cursorPos.y+t*Mx)),this._positionCursor()}_getClientCoords(){let e=this._getTerminalHostElement();if(!e)return null;let t=e.getBoundingClientRect();return{clientX:t.left+this._cursorPos.x,clientY:t.top+this._cursorPos.y}}_resolveTarget(e,t){let n=this._getTerminalHostElement();return n?Bme(n,e,t):document.body}_dispatchMouse(e,t={}){let n=this._getClientCoords();if(!n)return;let r=t.button??0,i=t.detail??1,a=t.buttons??(e===`mousedown`?r===0?1:r===2?2:4:0);this._resolveTarget(n.clientX,n.clientY).dispatchEvent(new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,detail:i,clientX:n.clientX,clientY:n.clientY,button:r,buttons:a}))}_dispatchClick(e){this._dispatchMouse(`mousedown`,{detail:e}),this._dispatchMouse(`mouseup`,{detail:e}),this._dispatchMouse(`click`,{detail:e})}_dispatchDblClick(){this._dispatchMouse(`mousedown`,{detail:2}),this._dispatchMouse(`mouseup`,{detail:2}),this._dispatchMouse(`click`,{detail:2}),this._dispatchMouse(`dblclick`,{detail:2})}_dispatchRightClick(){this._dispatchMouse(`mousedown`,{button:2}),this._dispatchMouse(`mouseup`,{button:2}),this._dispatchMouse(`contextmenu`,{button:2})}_dispatchWheel(e){let t=this._getClientCoords();t&&this._resolveTarget(t.clientX,t.clientY).dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,view:window,clientX:t.clientX,clientY:t.clientY,deltaY:e,deltaMode:WheelEvent.DOM_DELTA_PIXEL}))}_updateEdgeScroll(){let e=this._getTerminalHostElement();if(!e||!this._isDragging){this._stopEdgeScroll();return}let t=e.getBoundingClientRect(),n=this._cursorPos.y<Nx,r=this._cursorPos.y>t.height-Nx;if(!n&&!r){this._stopEdgeScroll();return}this._stopEdgeScroll(),this._edgeScrollTimer=setInterval(()=>{let e=this._getTerminalHostElement();if(!e||!this._isDragging){this._stopEdgeScroll();return}let t=e.getBoundingClientRect(),n=t.left+this._cursorPos.x,r=this._cursorPos.y<Nx?t.top-Px:t.bottom+Px;this._resolveTarget(t.left+this._cursorPos.x,t.top+this._cursorPos.y).dispatchEvent(new MouseEvent(`mousemove`,{bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:r,button:0,buttons:1}))},zme)}_stopEdgeScroll(){this._edgeScrollTimer&&=(clearInterval(this._edgeScrollTimer),null)}_suppressKeyboard(){if(!Fx())return;let e=this._terminal?.textarea;e&&e.setAttribute(`inputmode`,`none`)}_restoreKeyboard(){let e=this._terminal?.textarea;e&&e.removeAttribute(`inputmode`)}_on(e,t,n){e.addEventListener(t,n),this._cleanups.push(()=>e.removeEventListener(t,n))}_normalizeHistoryText(e){return e.replace(/[\r\n]+$/u,``).trim()||null}_renderHistory(e,t){if(e.querySelectorAll(`[data-input-history-root="true"]`).forEach(e=>e.remove()),t.length===0)return;let n=document.createElement(`div`);n.dataset.inputHistoryRoot=`true`,n.setAttribute(`slot`,`history`),n.style.display=`flex`,n.style.flexDirection=`column`,n.style.gap=`4px`,n.style.padding=`4px 0`;for(let e of t){let t=document.createElement(`button`);t.type=`button`,t.title=e.text,t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`8px`,t.style.width=`100%`,t.style.padding=`4px 6px`,t.style.border=`1px solid transparent`,t.style.borderRadius=`4px`,t.style.background=`transparent`,t.style.color=`var(--foreground, #fff)`,t.style.fontFamily=`inherit`,t.style.fontSize=`12px`,t.style.textAlign=`left`;let r=document.createElement(`span`);r.textContent=new Date(e.time).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r.style.opacity=`0.65`,r.style.fontSize=`10px`,r.style.flexShrink=`0`;let i=document.createElement(`span`);i.textContent=e.text,i.style.overflow=`hidden`,i.style.textOverflow=`ellipsis`,i.style.whiteSpace=`nowrap`,t.appendChild(r),t.appendChild(i),t.addEventListener(`click`,()=>{this._onInput(`${e.text}\n`)}),n.appendChild(t)}e.appendChild(n)}};function Hx(e){let t=/^zh\b/i.test(e);return{apiHost:t?`https://fonts.googleapis.cn`:`https://fonts.googleapis.com`,staticHost:t?`https://fonts.gstatic.cn`:`https://fonts.gstatic.com`}}function Wme(e){return e.trim().replace(/ /g,`+`)}function Gme(e){let t=e.families.map(Wme).filter(Boolean),{apiHost:n}=Hx(e.lang??``),r=t.map(e=>`family=${e}`),i=`display=${e.display??`swap`}`;return`${n}/css2?${[...r,i].join(`&`)}`}function Kme(e){let t=e.documentRef??(typeof document>`u`?null:document);if(!t||e.families.length===0)return null;let n=e.lang??(typeof navigator>`u`?``:navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage||``),r=Hx(n),i=Gme({...e,lang:n});if(t.head.querySelector(`link[href="${i}"]`))return null;let a=t.createElement(`link`);a.rel=`preconnect`,a.href=r.apiHost,a.dataset.openspecGoogleFonts=`preconnect-api`;let o=t.createElement(`link`);o.rel=`preconnect`,o.href=r.staticHost,o.crossOrigin=`anonymous`,o.dataset.openspecGoogleFonts=`preconnect-static`;let s=t.createElement(`link`);return s.rel=`stylesheet`,s.href=i,s.dataset.openspecGoogleFonts=`stylesheet`,t.head.append(a,o,s),s}var Ux=null,Wx=null,Gx=null,Kx=null,qx=!1,Jx=!1;function Yx(){return typeof window>`u`?null:window.AudioContext??window.webkitAudioContext??null}function Xx(){return qx?!0:typeof navigator>`u`?!1:navigator.userActivation?.hasBeenActive===!0||navigator.userActivation?.isActive===!0}function qme(){typeof window>`u`||!Jx||(window.removeEventListener(`pointerdown`,Zx,!0),window.removeEventListener(`keydown`,Zx,!0),Jx=!1)}function Zx(){qx=!0,qme(),Kx?.(),Kx=null,Gx=null}function Qx(){typeof window>`u`||Jx||Xx()||(window.addEventListener(`pointerdown`,Zx,{capture:!0,once:!0,passive:!0}),window.addEventListener(`keydown`,Zx,{capture:!0,once:!0}),Jx=!0)}function Jme(){Qx()}function Yme(){return typeof window>`u`||Xx()?Promise.resolve():Gx||(Gx=new Promise(e=>{Kx=e,Qx()}),Gx)}async function Xme(){return Ux||Wx||(Yx()?(Wx=Yme().then(async()=>{let e=Yx();if(!e)return null;let t=Ux??new e;return Ux=t,t.state===`suspended`&&await t.resume(),t}).finally(()=>{Wx=null}),Wx):null)}var $x=class{fallbackSound;unlocked=!1;unlockPromise=null;silentAudio=null;activeAudios=new Set;constructor(e){this.fallbackSound=e===`bell`?Bu:Vu}init(){Jme()}async unlock(){if(!this.unlocked)return this.unlockPromise||=this.unlockAudioContext().finally(()=>{this.unlockPromise=null}),this.unlockPromise}async play(e,t=1){e!==`silent`&&(await this.unlock().catch(()=>{}),await this.playAudio(e,t))}async unlockAudioContext(){if(!await Xme()){this.unlocked=!0;return}this.silentAudio??=new Audio(`data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=`),this.silentAudio.volume=0,await this.silentAudio.play().catch(()=>{}),this.unlocked=!0}async playAudio(e,t){let n=this.getSoundUrl(e)??this.getSoundUrl(this.fallbackSound);n&&await this.createManagedAudio(n,t).play().catch(async r=>{if(e!==this.fallbackSound){if(await this.isMissingSound(n)){let e=this.getSoundUrl(this.fallbackSound);e&&await this.createManagedAudio(e,t).play().catch(()=>{});return}throw r}})}getSoundUrl(e){let t=Pae(e);if(t)return t;let n=qu(e);if(!n)return null;let r=V(),i=`/api/sounds/custom/${n}`;return r?`${r}${i}`:i}async isMissingSound(e){try{return(await M(e,{method:`HEAD`})).status===404}catch{return!1}}createManagedAudio(e,t){let n=new Audio(e);n.volume=Zme(t),this.activeAudios.add(n);let r=()=>{n.removeEventListener(`ended`,r),n.removeEventListener(`error`,r),this.activeAudios.delete(n)};return n.addEventListener(`ended`,r,{once:!0}),n.addEventListener(`error`,r,{once:!0}),n}};function Zme(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):1}var eS=class extends $x{constructor(){super(`bell`)}},tS=`xtermInputPanelSettings`,Qme=50,$me=1e3,ehe=1,the=1,nS=`terminal-meta`;function rS(){return z(`terminal-input-history`,window.location)}function nhe(){return z(`openspecui-terminal`,window.location)}function iS(){return z(`input-history`,window.location)}function aS(){return z(`terminal-input-history-fallback`,window.location)}function oS(e){return Math.max(ehe,Math.min($me,Math.round(e)))}function sS(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(typeof e.text!=`string`||typeof e.time!=`number`||!Number.isFinite(e.time))continue;let r=e.text.trim();r&&t.push({text:r,time:e.time})}return t}function cS(e,t){let n=new Map;for(let t of e){let e=`${t.time}::${t.text}`;n.has(e)||n.set(e,t)}return[...n.values()].sort((e,t)=>t.time-e.time).slice(0,oS(t))}function lS(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.text!==t[n]?.text||e[n]?.time!==t[n]?.time)return!1;return!0}function uS(){try{let e=localStorage.getItem(tS);if(!e)return{};let t=JSON.parse(e);return typeof t!=`object`||!t?{}:t}catch{return{}}}function rhe(e){let t=uS();try{localStorage.setItem(tS,JSON.stringify({...t,...e}))}catch{}}async function dS(){return typeof window>`u`||!(`indexedDB`in window)?null:await new Promise(e=>{let t=window.indexedDB.open(nhe(),the);t.onupgradeneeded=()=>{let e=t.result;e.objectStoreNames.contains(nS)||e.createObjectStore(nS)},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)})}async function ihe(){let e=await dS();return e?await new Promise(t=>{let n=e.transaction(nS,`readonly`),r=n.objectStore(nS).get(iS());r.onsuccess=()=>{t(sS(r.result))},r.onerror=()=>t([]),n.oncomplete=()=>e.close(),n.onerror=()=>e.close(),n.onabort=()=>e.close()}):null}async function ahe(e){let t=await dS();return t?await new Promise(n=>{let r=t.transaction(nS,`readwrite`);r.objectStore(nS).put(e,iS()),r.oncomplete=()=>{t.close(),n(!0)},r.onerror=()=>{t.close(),n(!1)},r.onabort=()=>{t.close(),n(!1)}}):!1}function ohe(){try{let e=localStorage.getItem(aS());return e?sS(JSON.parse(e)):[]}catch{return[]}}function she(e){try{localStorage.setItem(aS(),JSON.stringify(e))}catch{}}async function che(){return await ihe()||ohe()}async function fS(e){await ahe(e)||she(e)}var lhe=class{records=[];listeners=new Set;kvUnsubscribe=null;initPromise=null;subscribe(e){return this.listeners.add(e),this.ensureInitialized(),e(this.records),()=>{this.listeners.delete(e)}}async list(){return await this.ensureInitialized(),[...this.records]}getLimit(){let e=uS().historyLimit;return typeof e==`number`&&Number.isFinite(e)?oS(e):Qme}async setLimit(e){let t=oS(e);rhe({historyLimit:t}),await this.ensureInitialized();let n=cS(this.records,t);await this.commit(n,{persistRemote:!0})}async add(e){let t=e.trim();if(!t)return;await this.ensureInitialized();let n=cS([{text:t,time:Date.now()},...this.records],this.getLimit());await this.commit(n,{persistRemote:!0})}destroy(){this.kvUnsubscribe&&=(this.kvUnsubscribe(),null)}async ensureInitialized(){if(this.initPromise){await this.initPromise;return}this.initPromise=this.initialize(),await this.initPromise}async initialize(){if(this.records=cS(await che(),this.getLimit()),this.emit(),!B())try{let e=sS(await q.kv.get.query({key:rS()})),t=cS([...this.records,...e],this.getLimit());lS(this.records,t)||(this.records=t,await fS(this.records),this.emit()),lS(e,this.records)||this.persistRemote(this.records);let n=q.kv.subscribe.subscribe({key:rS()},{onData:e=>{this.onRemoteData(e)}});this.kvUnsubscribe=()=>n.unsubscribe()}catch{}}async onRemoteData(e){let t=sS(e),n=cS([...this.records,...t],this.getLimit());await this.commit(n,{persistRemote:!1})}async commit(e,t){lS(this.records,e)||(this.records=e,await fS(this.records),this.emit(),t.persistRemote&&!B()&&this.persistRemote(this.records))}async persistRemote(e){try{await q.kv.set.mutate({key:rS(),value:e})}catch{}}emit(){for(let e of this.listeners)e(this.records)}};function pS(e){return e.type===`keydown`}function mS(e,t){return e.key.toLowerCase()===t}function hS(e){return e.metaKey||e.ctrlKey}function gS(e){return hS(e)&&!e.altKey}function _S(e){return e.clipboard?e.clipboard:typeof navigator>`u`?null:navigator.clipboard??null}function vS(e,t){e.catch(e=>{t.onAsyncError?.(e)})}async function uhe(e,t){let n=_S(e);n?.writeText&&await n.writeText(t)}async function dhe(e){let t=_S(e);if(!t?.readText)return;let n=await t.readText();if(n){try{if(e.terminal.paste?.(n),e.terminal.paste)return}catch{}e.writeInput(n)}}var fhe=[{id:`terminal.copy-selection`,handle:(e,t)=>!pS(e)||!gS(e)||!mS(e,`c`)?null:t.terminal.hasSelection?.()?yS(t):`allow`},{id:`terminal.paste-clipboard`,handle:(e,t)=>!pS(e)||!gS(e)||!mS(e,`v`)?null:bS(t)},{id:`terminal.select-all`,handle:(e,t)=>!pS(e)||!e.metaKey||e.ctrlKey||e.altKey||!mS(e,`a`)?null:xS(t)},{id:`terminal.zoom-in`,handle:(e,t)=>!pS(e)||!hS(e)||e.key!==`=`&&e.key!==`+`?null:(t.zoomFont(1),`block`)},{id:`terminal.zoom-out`,handle:(e,t)=>!pS(e)||!hS(e)||e.key!==`-`?null:(t.zoomFont(-1),`block`)},{id:`terminal.zoom-reset`,handle:(e,t)=>!pS(e)||!hS(e)||e.key!==`0`?null:(t.resetFontSize(),`block`)}];function yS(e){if(!e.terminal.hasSelection?.())return`allow`;let t=e.terminal.getSelection?.()??``;return t?(vS(uhe(e,t),e),`block`):`allow`}function bS(e){return _S(e)?.readText?(vS(dhe(e),e),`block`):`allow`}function xS(e){return e.terminal.selectAll?(e.terminal.selectAll(),`block`):`allow`}var phe=[{id:`terminal.command.copy-selection`,command:`copy`,run:yS},{id:`terminal.command.paste-clipboard`,command:`paste`,run:bS},{id:`terminal.command.select-all`,command:`select-all`,run:xS}],mhe=class{constructor(e=fhe,t=phe){this.bindings=e,this.commandBindings=t}handleKeyEvent(e,t){for(let n of this.bindings){let r=n.handle(e,t);if(r)return r}return`allow`}runCommand(e,t){return this.commandBindings.find(t=>t.command===e)?.run(t)??`allow`}},hhe=[`app`,`light`,`dark`,`system`],ghe=[{value:`default-light`,label:`Default Light`},{value:`default-dark`,label:`Default Dark`},{value:`monokai`,label:`Monokai`},{value:`nord`,label:`Nord`},{value:`solarized-light`,label:`Solarized Light`},{value:`solarized-dark`,label:`Solarized Dark`}],_he={"default-light":{id:`default-light`,label:`Default Light`,modeHint:`light`,palette:{background:`#f6f5f2`,foreground:`#1b1b1b`,cursor:`#ea580c`,cursorAccent:`#f6f5f2`,selectionBackground:`rgba(234, 88, 12, 0.22)`,black:`#111111`,red:`#b91c1c`,green:`#15803d`,yellow:`#a16207`,blue:`#1d4ed8`,magenta:`#a21caf`,cyan:`#0f766e`,white:`#f6f5f2`,brightBlack:`#4b5563`,brightRed:`#dc2626`,brightGreen:`#16a34a`,brightYellow:`#ca8a04`,brightBlue:`#2563eb`,brightMagenta:`#c026d3`,brightCyan:`#0891b2`,brightWhite:`#ffffff`}},"default-dark":{id:`default-dark`,label:`Default Dark`,modeHint:`dark`,palette:{background:`#141414`,foreground:`#e5dfd2`,cursor:`#f97316`,cursorAccent:`#141414`,selectionBackground:`rgba(249, 115, 22, 0.28)`,black:`#151515`,red:`#f87171`,green:`#4ade80`,yellow:`#facc15`,blue:`#60a5fa`,magenta:`#e879f9`,cyan:`#67e8f9`,white:`#f4f1ea`,brightBlack:`#6b7280`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#f0abfc`,brightCyan:`#a5f3fc`,brightWhite:`#fffdf8`}},monokai:{id:`monokai`,label:`Monokai`,modeHint:`either`,palette:{background:`#272822`,foreground:`#f8f8f2`,cursor:`#f8f8f0`,cursorAccent:`#272822`,selectionBackground:`rgba(73, 72, 62, 0.9)`,black:`#272822`,red:`#f92672`,green:`#a6e22e`,yellow:`#f4bf75`,blue:`#66d9ef`,magenta:`#ae81ff`,cyan:`#a1efe4`,white:`#f8f8f2`,brightBlack:`#75715e`,brightRed:`#f92672`,brightGreen:`#a6e22e`,brightYellow:`#f4bf75`,brightBlue:`#66d9ef`,brightMagenta:`#ae81ff`,brightCyan:`#a1efe4`,brightWhite:`#f9f8f5`}},nord:{id:`nord`,label:`Nord`,modeHint:`either`,palette:{background:`#2e3440`,foreground:`#d8dee9`,cursor:`#88c0d0`,cursorAccent:`#2e3440`,selectionBackground:`rgba(94, 129, 172, 0.38)`,black:`#3b4252`,red:`#bf616a`,green:`#a3be8c`,yellow:`#ebcb8b`,blue:`#81a1c1`,magenta:`#b48ead`,cyan:`#88c0d0`,white:`#e5e9f0`,brightBlack:`#4c566a`,brightRed:`#d08770`,brightGreen:`#8fbcbb`,brightYellow:`#eceff4`,brightBlue:`#5e81ac`,brightMagenta:`#b48ead`,brightCyan:`#8fbcbb`,brightWhite:`#eceff4`}},"solarized-light":{id:`solarized-light`,label:`Solarized Light`,modeHint:`light`,palette:{background:`#fdf6e3`,foreground:`#586e75`,cursor:`#cb4b16`,cursorAccent:`#fdf6e3`,selectionBackground:`rgba(147, 161, 161, 0.32)`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#657b83`,brightRed:`#cb4b16`,brightGreen:`#93a1a1`,brightYellow:`#839496`,brightBlue:`#6c71c4`,brightMagenta:`#d33682`,brightCyan:`#2aa198`,brightWhite:`#fdf6e3`}},"solarized-dark":{id:`solarized-dark`,label:`Solarized Dark`,modeHint:`dark`,palette:{background:`#002b36`,foreground:`#93a1a1`,cursor:`#cb4b16`,cursorAccent:`#002b36`,selectionBackground:`rgba(88, 110, 117, 0.5)`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#657b83`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`}}};function vhe(e){let t=e.useTheme??`app`;return t===`light`?`light`:t===`dark`?`dark`:t===`system`?e.systemDarkMode?`dark`:`light`:e.appDarkMode?`dark`:`light`}function SS(e){let t=vhe(e),n=t===`dark`?e.darkTheme??`default-dark`:e.lightTheme??`default-light`;return{id:n,mode:t,definition:_he[n]}}var CS=[`xterm`,`ghostty`];function wS(e){return CS.includes(e)}var TS=`"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,ES={fontSize:13,fontFamily:``,cursorBlink:!0,cursorStyle:`block`,scrollback:1e3,useTheme:`app`,lightTheme:`default-light`,darkTheme:`default-dark`,rendererEngine:`xterm`,bellSound:Bu,bellVolume:1},DS=1500,OS=1e3,yhe=1e4,kS=`common`,bhe=512*1024,xhe=8,She=32,AS=13,Che=800,whe={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`},The={ArrowLeft:`\x1Bb`,ArrowRight:`\x1Bf`,ArrowUp:`\x1B[1;3A`,ArrowDown:`\x1B[1;3B`},Ehe={ArrowLeft:``,ArrowUp:``,ArrowRight:``,ArrowDown:``},jS=[`JetBrains Mono`,`Fira Code`,`Source Code Pro`,`IBM Plex Mono`,`Inconsolata`,`Roboto Mono`,`Ubuntu Mono`,`Space Mono`],Dhe={"JetBrains Mono":`"JetBrains Mono Variable"`,"Share Tech Mono":`"Share Tech Mono"`},MS=new Set;function NS(e){try{return(new URL(e).pathname.split(`/`).pop()??``).replace(/\.[^.]+$/,``).replace(/[-_]/g,` `)||`CustomFont`}catch{return`CustomFont`}}async function Ohe(e){let t=e.trim();if(!t)return``;if(!/^https?:\/\//i.test(t))return t;if(MS.has(t))return NS(t);try{let e=(await M(t,{method:`HEAD`})).headers.get(`content-type`)??``;if(e.includes(`text/css`)){let e=document.createElement(`link`);return e.rel=`stylesheet`,e.href=t,e.dataset.fontSrc=t,document.head.appendChild(e),MS.add(t),``}if(e.startsWith(`font/`)){let e=NS(t),n=document.createElement(`style`);return n.dataset.fontSrc=t,n.textContent=`@font-face { font-family: '${e}'; src: url('${t}'); }`,document.head.appendChild(n),MS.add(t),e}}catch{}return t}function khe(e){let t=`google:${e}`;if(MS.has(t))return;let n=Kme({families:[e]});n&&(n.dataset.fontSrc=t),MS.add(t)}var Ahe=class{instances=new Map;listeners=new Set;activationListeners=new Set;idCounter=0;config={...ES};snapshotCache=null;inputHistoryStore=new lhe;bellSoundEngine=new eS;keybindings=new mhe;ghosttyModule=null;ghosttyInitPromise=null;appDarkMode=!1;systemDarkMode=!1;resolvedTheme=SS({useTheme:ES.useTheme,lightTheme:ES.lightTheme,darkTheme:ES.darkTheme,appDarkMode:!1,systemDarkMode:!1});ws=null;wsConnected=!1;reconnectTimer=null;reconnectDelay=OS;pendingCreates=[];pendingCloseSessionIds=new Set;pendingWorkflowInputs=new Map;workflowInputRequestCounter=0;serverToLocalSessionId=new Map;hasDiscoveredSessions=!1;inputPanelDefaultLayout=`floating`;activeSessionId=null;constructor(){this.bellSoundEngine.init()}createSession(e){let t=`term-${++this.idCounter}`,n=e.label??`Shell ${this.idCounter}`,r=this.createTerminalInstance(t,{label:n,command:e.command,args:e.args,isDedicated:e.isDedicated??!1,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl,initialInput:e.initialInput,customTitle:e.customTitle??null,restored:!1,serverSessionId:null,platform:kS,cwdTarget:e.cwdTarget,initialCwd:null,rootGeneration:null});return this.instances.set(t,r),this._applyFonts(),this.bindTerminalInput(r),this.wsConnected&&this.ws?this.wsSend({type:`create`,requestId:t,cwdTarget:e.cwdTarget,expectedRootGeneration:e.expectedRootGeneration,cols:r.terminal.cols||80,rows:r.terminal.rows||24,command:e.command,args:e.args,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl}):(this.pendingCreates.push({requestId:t,cwdTarget:e.cwdTarget,expectedRootGeneration:e.expectedRootGeneration,command:e.command,args:e.args,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl,cols:r.terminal.cols||80,rows:r.terminal.rows||24}),this.ensureWsConnected()),e.initialInput&&this.scheduleInitialInput(t,e.initialInput),this.notify(),t}scheduleInitialInput(e,t){let n=0,r=()=>{this.writeToSession(e,t)||(n+=1,!(n>75)&&globalThis.setTimeout(r,80))};globalThis.setTimeout(r,80)}createTerminalInstance(e,t){let{terminal:n,fitAddon:r,afterOpenHook:i,engine:a}=this.createRendererTerminal(),o=this.createInputPanelAddon(e,t.platform);return n.loadAddon(o),this.attachTerminalShortcuts(n,a,t=>this.writeToSession(e,t)),{id:e,serverSessionId:t.serverSessionId,terminal:n,fitAddon:r,inputPanelAddon:o,isConnected:!1,label:t.label,customTitle:t.customTitle,processTitle:null,oscTitle:null,cwd:null,cwdTarget:t.cwdTarget,initialCwd:t.initialCwd,rootGeneration:t.rootGeneration,progress:null,promptState:null,isDedicated:t.isDedicated,isExited:!1,exitCode:null,command:t.command,args:t.args,closeTip:t.closeTip,closeCallbackUrl:t.closeCallbackUrl,mountedContainer:null,resizeObserver:null,hasOpened:!1,afterOpenHook:i,pendingOutput:[],pendingOutputBytes:0,lastOutputTime:0,lastBellAt:null,outputIdleTimer:null,restored:t.restored,platform:t.platform,rendererEngine:a}}getTerminalOptions(){let e=SS({useTheme:this.config.useTheme,lightTheme:this.config.lightTheme,darkTheme:this.config.darkTheme,appDarkMode:this.appDarkMode,systemDarkMode:this.systemDarkMode});return{cursorBlink:this.config.cursorBlink,cursorStyle:this.config.cursorStyle,fontSize:this.config.fontSize,fontFamily:TS,theme:e.definition.palette,allowTransparency:!1,convertEol:!0,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,scrollback:this.config.scrollback}}createRendererTerminal(){let e=this.getTerminalOptions();if(this.config.rendererEngine===`xterm`){let t=new Wfe(e),n=new vue;return t.loadAddon(n),t.loadAddon(new wue),{terminal:t,fitAddon:n,afterOpenHook:null,engine:`xterm`}}let t=this.ghosttyModule;if(!t)throw Error(`ghostty-web is not initialized. Open Settings and switch engine again.`);let n=new t.Terminal(e),r=new t.FitAddon;return n.loadAddon(r),{terminal:n,fitAddon:r,afterOpenHook:()=>{let e=n;e.registerLinkProvider&&e.registerLinkProvider(new t.UrlRegexProvider(n))},engine:`ghostty`}}createInputPanelAddon(e,t){return new Vx({onInput:t=>this.writeToSession(e,t),onCommand:t=>this.runInputPanelCommand(e,t),getHistory:async()=>this.inputHistoryStore.list(),addHistory:async e=>this.inputHistoryStore.add(e),subscribeHistory:e=>this.inputHistoryStore.subscribe(e),platform:t,defaultLayout:this.inputPanelDefaultLayout,showFab:!1,stateKey:e,onSettingsChange:async e=>{await this.inputHistoryStore.setLimit(e.historyLimit)}})}runInputPanelCommand(e,t){let n=this.instances.get(e);return n?this.keybindings.runCommand(t,{terminal:n.terminal,writeInput:t=>this.writeToSession(e,t),zoomFont:e=>this.zoomFont(e),resetFontSize:()=>this.resetFontSize(),onAsyncError:e=>console.error(`[terminal] input panel command failed:`,e)})===`block`:!1}applyGhosttyBackground(e,t){if(e.rendererEngine!==`ghostty`)return;let n=e.terminal.options.theme??{},r=typeof n.background==`string`&&n.background.trim().length>0?n.background:this.resolveNearestOpaqueBackground(t);e.terminal.options.allowTransparency=!1,e.terminal.options.theme={...n,background:r}}isTransparentColor(e){let t=e.trim().toLowerCase();return t.length===0||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0,0,0,0)`}resolveNearestOpaqueBackground(e){let t=e;for(;t;){let e=window.getComputedStyle(t).backgroundColor;if(!this.isTransparentColor(e))return e;t=t.parentElement}return`rgb(26, 26, 26)`}resolveTerminalKeyInput(e){return e.type===`keydown`?e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey?The[e.key]??null:e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey?Ehe[e.key]??null:!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey?whe[e.key]??null:null:null}getKeyEventResult(e,t){return e===`xterm`?t===`allow`:t===`block`}attachTerminalShortcuts(e,t,n){e.attachCustomKeyEventHandler(r=>{let i=this.resolveTerminalKeyInput(r);if(i&&n(i))return r.preventDefault(),r.stopPropagation(),this.getKeyEventResult(t,`block`);let a=r.metaKey||r.ctrlKey;if(r.type!==`keydown`||!a)return this.getKeyEventResult(t,`allow`);let o=this.keybindings.handleKeyEvent(r,{terminal:e,writeInput:n,zoomFont:e=>this.zoomFont(e),resetFontSize:()=>this.resetFontSize(),onAsyncError:e=>console.error(`[terminal] keybinding failed:`,e)});return o===`block`&&(r.preventDefault(),r.stopPropagation()),this.getKeyEventResult(t,o)})}bindTerminalInput(e){e.terminal.onData(t=>{if(e.isExited){this.closeSession(e.id);return}let n=this.resolveServerSessionId(e.id);n&&this.wsSend({type:`input`,sessionId:n,data:t})})}isTerminalNotOpenedError(e){if(!(e instanceof Error))return!1;let t=e.message;return t.includes(`Terminal must be opened before use`)||t.includes(`Call terminal.open(parent) first`)}enqueuePendingOutput(e,t){if(t)for(e.pendingOutput.push(t),e.pendingOutputBytes+=t.length;e.pendingOutputBytes>bhe&&e.pendingOutput.length;){let t=e.pendingOutput.shift();if(!t)break;e.pendingOutputBytes-=t.length}}writeTerminalOutput(e,t){if(t){if(!e.hasOpened){this.enqueuePendingOutput(e,t);return}try{e.terminal.write(t)}catch(n){if(this.isTerminalNotOpenedError(n)){this.enqueuePendingOutput(e,t);return}console.error(`[terminal] failed to write output:`,n)}}}flushPendingOutput(e){if(!e.hasOpened||e.pendingOutput.length===0)return;let t=e.pendingOutput.join(``);e.pendingOutput=[],e.pendingOutputBytes=0,this.writeTerminalOutput(e,t)}replaceInstanceRenderer(e){let t=e.mountedContainer,n=e.serverSessionId;e.mountedContainer&&this.unmount(e.id),e.terminal.dispose();let{terminal:r,fitAddon:i,afterOpenHook:a,engine:o}=this.createRendererTerminal(),s=this.createInputPanelAddon(e.id,e.platform);r.loadAddon(s),this.attachTerminalShortcuts(r,o,t=>this.writeToSession(e.id,t)),e.terminal=r,e.fitAddon=i,e.inputPanelAddon=s,e.hasOpened=!1,e.afterOpenHook=a,e.mountedContainer=null,e.resizeObserver=null,e.rendererEngine=o,this.bindTerminalInput(e),t&&this.mount(e.id,t),n&&this.wsSend({type:`attach`,sessionId:n,cols:e.terminal.cols||80,rows:e.terminal.rows||24})}async ensureGhosttyModule(){return this.ghosttyModule?this.ghosttyModule:(this.ghosttyInitPromise||=c(()=>import(`./ghostty-web-BSS9uGcc.js`).then(async e=>(await e.init(),this.ghosttyModule=e,e)),__vite__mapDeps([25,6])).finally(()=>{this.ghosttyInitPromise=null}),this.ghosttyInitPromise)}async setRendererEngine(e){if(e!==this.config.rendererEngine){e===`ghostty`&&await this.ensureGhosttyModule(),this.config.rendererEngine=e;for(let e of this.instances.values())this.replaceInstanceRenderer(e);this._applyFonts(),this.notify()}}closeSession(e,t){let n=this.instances.get(e);if(!n)return;let r=t?.triggerCloseCallback!==!1;if(n.mountedContainer&&this.unmount(e),n.outputIdleTimer&&=(clearTimeout(n.outputIdleTimer),null),this.pendingCreates=this.pendingCreates.filter(t=>t.requestId!==e),n.serverSessionId){let e=n.serverSessionId;this.serverToLocalSessionId.delete(e),this.wsConnected&&this.ws?.readyState===WebSocket.OPEN?this.wsSend({type:`close`,sessionId:e}):this.pendingCloseSessionIds.add(e)}n.terminal.dispose(),r&&this.runCloseCallback(n),this.instances.delete(e),this.activeSessionId===e&&(this.activeSessionId=null),this.notify()}closeAll(){for(let e of this.instances.keys())this.closeSession(e,{triggerCloseCallback:!1});this.activeSessionId=null}mount(e,t){let n=this.instances.get(e);if(!n)return;if(n.mountedContainer===t){requestAnimationFrame(()=>{try{n.fitAddon.fit()}catch{}});return}if(n.mountedContainer&&this.unmount(e),!n.hasOpened)this.applyGhosttyBackground(n,t),n.terminal.open(t),n.hasOpened=!0,n.afterOpenHook?.(),n.afterOpenHook=null,this.flushPendingOutput(n),n.inputPanelAddon.attachListeners();else{let e=n.terminal.element;e&&!e.contains(t)&&e.parentNode!==t&&t.appendChild(e),this.flushPendingOutput(n),this.applyGhosttyBackground(n,t),n.inputPanelAddon.attachListeners()}n.mountedContainer=t,requestAnimationFrame(()=>{try{n.fitAddon.fit()}catch{}});let r=new ResizeObserver(()=>{try{if(n.fitAddon.fit(),n.terminal.cols&&n.terminal.rows){let t=this.resolveServerSessionId(e);if(!t)return;this.wsSend({type:`resize`,sessionId:t,cols:n.terminal.cols,rows:n.terminal.rows})}}catch{}});r.observe(t),n.resizeObserver=r,requestAnimationFrame(()=>{this.focusSession(e)})}unmount(e){let t=this.instances.get(e);!t||!t.mountedContainer||(t.resizeObserver&&=(t.resizeObserver.disconnect(),null),t.mountedContainer=null)}focusSession(e){let t=this.instances.get(e);if(!t||!t.hasOpened)return;let n=!1;try{t.terminal.focus?.(),n=!0}catch{}if(!n){let e=t.terminal.element;if(e instanceof HTMLElement)try{e.focus()}catch{}}t.inputPanelAddon.syncFocusLifecycle()}setActiveSessionId(e){e&&!this.instances.has(e)||(this.activeSessionId=e)}setCustomTitle(e,t){let n=this.instances.get(e);n&&(n.customTitle=t,this.notify())}getDisplayTitle(e){let t=this.instances.get(e);return t?t.customTitle??t.oscTitle??t.processTitle??t.label:``}getConfig(){return{...this.config}}getResolvedTheme(){return this.resolvedTheme}setThemeContext(e){(this.appDarkMode!==e.appDarkMode||this.systemDarkMode!==e.systemDarkMode)&&(this.appDarkMode=e.appDarkMode,this.systemDarkMode=e.systemDarkMode,this.refreshResolvedTheme())}applyConfig(e){let{rendererEngine:t,...n}=e;Object.assign(this.config,n);for(let e of this.instances.values()){let t=e.terminal;t.options.fontSize=this.config.fontSize,t.options.cursorBlink=this.config.cursorBlink,t.options.cursorStyle=this.config.cursorStyle,t.options.scrollback=this.config.scrollback}this.refreshResolvedTheme(),this._applyFonts(),t&&t!==this.config.rendererEngine&&this.setRendererEngine(t).catch(e=>{console.error(`[terminal] failed to switch renderer engine:`,e)}),this.notify()}refreshResolvedTheme(){let e=SS({useTheme:this.config.useTheme,lightTheme:this.config.lightTheme,darkTheme:this.config.darkTheme,appDarkMode:this.appDarkMode,systemDarkMode:this.systemDarkMode});this.resolvedTheme=e;for(let t of this.instances.values())t.terminal.options.theme=e.definition.palette,t.terminal.options.allowTransparency=!1,t.mountedContainer&&this.applyGhosttyBackground(t,t.mountedContainer)}async _applyFonts(){let e=this.config.fontFamily;if(!e){this._setFontFamily(TS);return}let t=e.split(/[,]+/).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t){let t=Dhe[e];if(t)n.push(t);else if(jS.includes(e))khe(e),n.push(e);else{let t=await Ohe(e);t&&n.push(t)}}n.push(TS),this._setFontFamily(n.join(`, `))}_setFontFamily(e){for(let t of this.instances.values())if(t.terminal.options.fontFamily=e,t.mountedContainer)try{t.fitAddon.fit()}catch{}}configPersistTimer=null;persistFontSize(){this.configPersistTimer&&clearTimeout(this.configPersistTimer),this.configPersistTimer=setTimeout(()=>{this.configPersistTimer=null,c(async()=>{let{trpcClient:e}=await import(`./trpc-DriEPW9x.js`);return{trpcClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({trpcClient:e})=>{e.config.update.mutate({terminal:{fontSize:this.config.fontSize}})}).catch(()=>{})},Che)}zoomFont(e){let t=Math.min(She,Math.max(xhe,this.config.fontSize+e));t!==this.config.fontSize&&(this.applyConfig({fontSize:t}),this.persistFontSize())}resetFontSize(){this.config.fontSize!==AS&&(this.applyConfig({fontSize:AS}),this.persistFontSize())}writeToSession(e,t){let n=this.resolveServerSessionId(e);return n?this.wsSend({type:`input`,sessionId:n,data:t}):!1}writeWorkflowToSession(e,t,n){let r=this.resolveServerSessionId(e);if(!r)return Promise.reject(Error(`Terminal session is not ready.`));let i=`workflow-input-${++this.workflowInputRequestCounter}`;return new Promise((e,a)=>{this.pendingWorkflowInputs.set(i,{resolve:e,reject:a}),this.wsSend({type:`workflow-input`,requestId:i,sessionId:r,expectedRootGeneration:n,data:t})||(this.pendingWorkflowInputs.delete(i),a(Error(`Terminal connection is unavailable.`)))})}openInputPanel(e){let t=[e?this.instances.get(e):void 0,...this.instances.values()],n=t.find(e=>e&&e.mountedContainer)?.id??t.find(e=>e)?.id;if(!n)return!1;this.focusSession(n);let r=this.instances.get(n);return r?(r.inputPanelAddon.open(),!0):!1}hasServerSession(e){let t=this.getInstanceByServerSessionId(e);return!!t&&!t.isExited}focusServerSession(e){let t=this.getInstanceByServerSessionId(e);return!t||t.isExited?!1:(this.focusSession(t.id),!0)}subscribeActivation(e){return this.activationListeners.add(e),()=>{this.activationListeners.delete(e)}}requestActivateSession(e){let t=this.instances.get(e);return!t||t.isExited?!1:(this.emitActivationRequest(t.id),!0)}requestActivateServerSession(e){let t=this.getInstanceByServerSessionId(e);return!t||t.isExited?!1:(this.emitActivationRequest(t.id),!0)}getLocalSessionIdForServerSession(e){return this.getInstanceByServerSessionId(e)?.id??null}isSessionActive(e){return this.activeSessionId===e}async addInputHistory(e){await this.inputHistoryStore.add(e)}resolveServerSessionId(e){let t=this.instances.get(e);return t?t.serverSessionId:null}getInstanceByServerSessionId(e){let t=this.serverToLocalSessionId.get(e)??e;return this.instances.get(t)}getLocalSessionIdByServerSessionId(e){return this.serverToLocalSessionId.get(e)??e}handleCreatedResponse(e){let t=this.instances.get(e.requestId);if(!t){this.wsSend({type:`close`,sessionId:e.sessionId});return}t.serverSessionId=e.sessionId,t.platform=e.platform,t.cwdTarget=e.cwdTarget,t.initialCwd=e.initialCwd,t.rootGeneration=e.rootGeneration,t.inputPanelAddon.setPlatform(e.platform),t.isConnected=!0,this.serverToLocalSessionId.set(e.sessionId,e.requestId),this.notify()}handleOutputResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);if(!t)return;this.writeTerminalOutput(t,e.data);let n=t.lastOutputTime>0&&Date.now()-t.lastOutputTime<DS;t.lastOutputTime=Date.now(),n||this.notify(),t.outputIdleTimer&&clearTimeout(t.outputIdleTimer),t.outputIdleTimer=setTimeout(()=>{t.outputIdleTimer=null,this.notify()},DS)}handleExitResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);if(t){if(t.isExited=!0,t.exitCode=e.exitCode,t.closeTip||t.isDedicated){let n=t.closeTip??`Press any key to close (equivalent to close action).`;this.writeTerminalOutput(t,`\r\n\x1b[90m[Process exited with code ${e.exitCode}. ${n}]\x1b[0m`)}this.notify()}}handleTitleResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.oscTitle=e.title,this.notify())}handleProcessTitleResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.processTitle=e.title,this.notify())}handleCwdResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.cwd=e.cwd,this.notify())}handleProgressResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.progress=e.state===`clear`?null:{state:e.state,value:e.value},this.notify())}handlePromptStateResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);t&&(t.promptState=e.state,this.notify())}handleBellResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);!t||t.isExited||(t.lastBellAt=e.createdAt??Date.now(),this.bellSoundEngine.play(this.config.bellSound,this.config.bellVolume).catch(()=>{}),this.notify())}handleBufferResponse(e){let t=this.getInstanceByServerSessionId(e.sessionId);!t||!e.data||this.writeTerminalOutput(t,e.data)}handleErrorResponse(e){if(e.code===`PTY_CREATE_FAILED`&&e.sessionId){let t=this.instances.get(e.sessionId);t&&!t.serverSessionId&&(t.isExited=!0,t.exitCode=-1,this.writeTerminalOutput(t,`\r\n\x1b[31m[Failed to start PTY: ${e.message}]\x1b[0m`),this.notify())}console.warn(`[pty] ${e.code}: ${e.message}`,e)}setInputPanelMountTarget(e){Vx.mountTarget=e}setInputPanelDefaultLayout(e){this.inputPanelDefaultLayout=e;for(let t of this.instances.values())t.inputPanelAddon.setDefaultLayout(e)}getTerminalDimensions(e){let t=this.instances.get(e);return t?{cols:t.terminal.cols||80,rows:t.terminal.rows||24}:null}subscribe(e){return this.listeners.add(e),this.ensureWsConnected(),()=>{this.listeners.delete(e)}}getSnapshot(){if(this.snapshotCache)return this.snapshotCache;let e=[];for(let t of this.instances.values())e.push({id:t.id,serverSessionId:t.serverSessionId,label:t.label,customTitle:t.customTitle,processTitle:t.processTitle,oscTitle:t.oscTitle,cwd:t.cwd,cwdTarget:t.cwdTarget,initialCwd:t.initialCwd,rootGeneration:t.rootGeneration,progress:t.progress,promptState:t.promptState,displayTitle:t.customTitle??t.oscTitle??t.processTitle??t.label,isDedicated:t.isDedicated,isExited:t.isExited,exitCode:t.exitCode,outputActive:t.lastOutputTime>0&&Date.now()-t.lastOutputTime<DS,lastBellAt:t.lastBellAt,command:t.command,args:t.args,closeTip:t.closeTip,closeCallbackUrl:t.closeCallbackUrl,platform:t.platform});return this.snapshotCache={sessions:e},this.snapshotCache}notify(){this.snapshotCache=null;for(let e of this.listeners)e()}emitActivationRequest(e){this.setActiveSessionId(e);for(let t of this.activationListeners)t(e);this.scheduleSessionFocus(e)}scheduleSessionFocus(e){(typeof globalThis.requestAnimationFrame==`function`?globalThis.requestAnimationFrame.bind(globalThis):e=>globalThis.setTimeout(()=>e(Date.now()),0))(()=>{this.focusSession(e)})}ensureWsConnected(){this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN)||this.connectSharedWebSocket()}connectSharedWebSocket(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null);let e=new WebSocket(F());this.ws=e,e.onopen=()=>{this.wsConnected=!0,this.reconnectDelay=OS;let t=R();t&&e.send(JSON.stringify({type:`auth`,credential:t}));for(let e of this.pendingCloseSessionIds)this.wsSend({type:`close`,sessionId:e});this.pendingCloseSessionIds.clear(),this.wsSend({type:`list`});for(let e of this.pendingCreates)this.wsSend({type:`create`,requestId:e.requestId,cwdTarget:e.cwdTarget,expectedRootGeneration:e.expectedRootGeneration,cols:e.cols,rows:e.rows,command:e.command,args:e.args,closeTip:e.closeTip,closeCallbackUrl:e.closeCallbackUrl});this.pendingCreates=[];for(let e of this.instances.values())if(!e.restored)continue;this.notify()},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let n=mue.safeParse(t);n.success&&this.handleServerMessage(n.data)},e.onclose=()=>{this.wsConnected=!1,this.ws=null;for(let e of this.pendingWorkflowInputs.values())e.reject(Error(`Terminal connection closed before workflow input was accepted.`));this.pendingWorkflowInputs.clear(),this.notify(),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,(this.listeners.size>0||this.instances.size>0)&&this.connectSharedWebSocket()},this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*1.5,yhe)},e.onerror=()=>{}}handleServerMessage(e){switch(e.type){case`list`:this.handleListResponse(e);break;case`created`:this.handleCreatedResponse(e);break;case`workflow-input-accepted`:{let t=this.pendingWorkflowInputs.get(e.requestId);if(!t)break;this.pendingWorkflowInputs.delete(e.requestId),t.resolve();break}case`workflow-input-rejected`:{let t=this.pendingWorkflowInputs.get(e.requestId);if(!t)break;this.pendingWorkflowInputs.delete(e.requestId),t.reject(Error(e.message));break}case`buffer`:this.handleBufferResponse(e);break;case`output`:this.handleOutputResponse(e);break;case`exit`:this.handleExitResponse(e);break;case`title`:this.handleTitleResponse(e);break;case`process-title`:this.handleProcessTitleResponse(e);break;case`cwd`:this.handleCwdResponse(e);break;case`progress`:this.handleProgressResponse(e);break;case`prompt-state`:this.handlePromptStateResponse(e);break;case`bell`:this.handleBellResponse(e);break;case`error`:this.handleErrorResponse(e);break}}handleListResponse(e){let t=new Set(e.sessions.map(e=>e.id));for(let t of e.sessions){let e=this.getLocalSessionIdByServerSessionId(t.id),n=this.instances.get(e);if(n)n.serverSessionId||=t.id;else{let e=t.title||`${t.command} ${t.args.join(` `)}`.trim();n=this.createTerminalInstance(t.id,{label:e.length>40?`${e.slice(0,37)}...`:e,command:t.command,args:t.args,isDedicated:!1,closeTip:t.closeTip,closeCallbackUrl:t.closeCallbackUrl,initialInput:void 0,customTitle:null,restored:!0,serverSessionId:t.id,platform:t.platform??kS,cwdTarget:t.cwdTarget,initialCwd:t.initialCwd,rootGeneration:t.rootGeneration}),t.isExited&&(n.isExited=!0,n.exitCode=t.exitCode),this.bindTerminalInput(n),this.instances.set(n.id,n),this._applyFonts()}n.closeTip=t.closeTip,n.closeCallbackUrl=t.closeCallbackUrl,n.cwdTarget=t.cwdTarget,n.initialCwd=t.initialCwd,n.rootGeneration=t.rootGeneration,n.platform=t.platform??kS,n.inputPanelAddon.setPlatform(n.platform),this.serverToLocalSessionId.set(t.id,n.id),this.wsSend({type:`attach`,sessionId:t.id,cols:n.terminal.cols||80,rows:n.terminal.rows||24})}for(let e of this.instances.values())e.restored&&e.serverSessionId&&!t.has(e.serverSessionId)&&!e.isExited&&(e.isExited=!0,e.exitCode=-1);this.hasDiscoveredSessions=!0,this.notify()}get discoveredSessions(){return this.hasDiscoveredSessions}runCloseCallback(e){if(!e.isExited)return;let t=jhe(e.closeCallbackUrl,e.exitCode);t&&Mhe(t)}wsSend(e){return this.ws?.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(e)),!0):!1}};function jhe(e,t){if(!e)return null;if(typeof e==`string`){let t=e.trim();return t.length>0?t:null}let n=e[t==null?`null`:String(t)];if(typeof n==`string`&&n.trim().length>0)return n.trim();let r=e[`*`];return typeof r==`string`&&r.trim().length>0?r.trim():null}function Mhe(e){let t;try{t=new URL(e,window.location.origin)}catch{return}if(t.origin===window.location.origin){let e=`${t.pathname}${t.search}${t.hash}`,n=ls.getAreaForPath(t.pathname);ls.push(n,e,null);return}window.open(t.toString(),`_blank`,`noopener,noreferrer`)}var PS=new Ahe;e(i(((e,t)=>{t.exports={}}))(),1);var FS=Mae;m({sound:FS.default(Vu),volume:Nae,systemNotificationsEnabled:f().default(!1)});var Nhe=P(`type`,[m({type:v(`terminal`),sessionId:S().min(1),title:S().optional()}),m({type:v(`openspec-change`),changeId:S().min(1),title:S().optional()}),m({type:v(`hooks-plugin`),pluginId:S().min(1),title:S().optional()}),m({type:v(`root-context`)}),m({type:v(`custom`),groupId:S().min(1),title:S().optional()})]),Phe=P(`type`,[m({type:v(`terminal.focus`),label:S().default(`Focus terminal`),target:m({sessionId:S().min(1)})}),m({type:v(`href.open`),label:S().default(`Open`),target:m({href:S().min(1)})})]),Fhe=S().min(1);m({title:S().min(1).max(160),body:S().max(2e3).default(``),source:Nhe,actions:p(Phe).default([]),level:l([`info`,`success`,`warning`,`error`]).default(`info`),createdAt:x().int().positive().optional()}).extend({id:S().min(1),createdAt:x().int().positive(),groupKey:Fhe});function Ihe(e){return e.type===`terminal`?e.title?.trim()||`Terminal ${e.sessionId}`:e.type===`openspec-change`?e.title?.trim()||`Change ${e.changeId}`:e.type===`hooks-plugin`?e.title?.trim()||`Plugin ${e.pluginId}`:e.type===`root-context`?`Root Context`:e.title?.trim()||e.groupId}function IS(e){return Array.isArray(e)?`[${e.map(e=>IS(e)).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${IS(t)}`).join(`,`)}}`:JSON.stringify(e)}function Lhe(e){return IS({groupKey:e.groupKey,title:e.title,body:e.body,source:e.source,actions:e.actions,level:e.level})}function Rhe(e){let t=new Map;for(let n of e){let e=Lhe(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort((e,t)=>t.createdAt-e.createdAt);return{key:e,notifications:n,latest:n[0],count:n.length}}).sort((e,t)=>t.latest.createdAt-e.latest.createdAt)}function zhe(e){let t=new Map;for(let n of e){let e=t.get(n.groupKey);e?e.push(n):t.set(n.groupKey,[n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort((e,t)=>t.createdAt-e.createdAt),r=n[0];return{key:e,label:Ihe(r.source),source:r.source,notifications:n,aggregates:Rhe(n),latest:r,unreadCount:n.length}}).sort((e,t)=>t.latest.createdAt-e.latest.createdAt)}function LS(){if(typeof window>`u`)return;let e=ee(),t=e.endsWith(`/`)?e:`${e}/`;return new URL(`${t}icon.rounded.svg`,window.location.href).href}var Bhe=class extends $x{constructor(){super(`notification`)}},RS=(0,Y.createContext)(null);function Vhe({value:e,children:t}){return(0,J.jsx)(RS,{value:e,children:t})}var Hhe={notifications:[],latestNotification:null,groups:[],unreadCount:0,highlightedId:null,browserSupported:!1,browserPermission:`unsupported`,panelOpen:!1,openPanel:()=>void 0,requestBrowserPermission:async()=>`unsupported`,previewSound:async()=>void 0,resolveAction:(e,t)=>({action:t,disabled:!0,reason:`Notifications are not available in this render tree.`,run:async()=>void 0}),markRead:async()=>void 0,markManyRead:async()=>void 0,clearGroup:async()=>void 0,clearAll:async()=>void 0,clearTerminalSession:async()=>void 0};function zS(){return typeof window<`u`&&`Notification`in window}function Uhe(){return zS()?Notification.permission:`unsupported`}function Whe(e){if(!e)return`/notifications`;let t=new URLSearchParams;return t.set(`highlight`,e),`/notifications?${t.toString()}`}function Ghe(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Khe(e){return e.body.trim()||e.title}function qhe(e){let t=e[0];if(!t)return``;let n=Ghe(t.createdAt);return e.length<=1?`${n} - 1 unread`:`${n} - ${e.length} unread notifications`}async function Jhe(){if(ls.getAreaForPath(`/terminal`)===`bottom`){await Vp.activateBottom(`/terminal`);return}await Vp.push(`main`,`/terminal`,null)}function Yhe({children:e}){let{data:t}=Ise(),{data:n}=Xf(),r=us(),i=t??[],a=(0,Y.useMemo)(()=>zhe(i),[i]),o=i[0]??null,[s,c]=(0,Y.useState)(()=>Uhe()),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=r.popActive&&r.popLocation.pathname===`/notifications`,h=n?.notifications?.systemNotificationsEnabled??!1,g=n?.notifications?.sound??`builtin:Blow`,_=n?.notifications?.volume??1;(0,Y.useEffect)(()=>{let e=new Bhe;e.init(),d.current=e},[]);let v=(0,Y.useCallback)(e=>{typeof window<`u`&&window.focus(),u(e??null),Vp.activatePop(Whe(e))},[]),y=(0,Y.useCallback)(async e=>{await q.notifications.markRead.mutate({id:e})},[]),b=(0,Y.useCallback)(async e=>{await q.notifications.markManyRead.mutate({ids:[...e]})},[]),x=(0,Y.useCallback)(async e=>{await q.notifications.clearGroup.mutate({groupKey:e})},[]),S=(0,Y.useCallback)(async()=>{await q.notifications.clearAll.mutate()},[]),C=(0,Y.useCallback)(async e=>{await q.notifications.clearTerminalSession.mutate({sessionId:e})},[]),w=(0,Y.useCallback)(async()=>{if(!zS())return c(`unsupported`),`unsupported`;let e=await Notification.requestPermission();return c(e),e===`granted`&&await q.config.update.mutate({notifications:{systemNotificationsEnabled:!0}}),e},[]),T=(0,Y.useCallback)(async(e,t)=>{await d.current?.play(e??g,t??_)},[g,_]),E=(0,Y.useCallback)((e,t,n)=>{let r=n?.markReadOnRun??!0;if(t.type===`terminal.focus`){let n=PS.hasServerSession(t.target.sessionId);return{action:t,disabled:!n,reason:n?void 0:`Target terminal is no longer available.`,run:async()=>{PS.hasServerSession(t.target.sessionId)&&(await Vp.deactivatePop(),await Jhe(),PS.requestActivateServerSession(t.target.sessionId)&&r&&await y(e.id))}}}return{action:t,disabled:!1,run:async()=>{let n=ls.getAreaForPath(t.target.href);m&&await Vp.deactivatePop(),await Vp.push(n,t.target.href,null),r&&await y(e.id)}}},[y,m]);return(0,Y.useEffect)(()=>{let e=o?.id??null;if(!e||f.current===e){f.current=e;return}if(f.current=e,d.current?.play(g,_).catch(()=>{}),!h||m||!zS()||Notification.permission!==`granted`)return;p.current?.close();let t=new Notification(Khe(o),{body:qhe(i),icon:LS(),tag:`openspecui-notifications`});t.onclick=()=>{v(o.id),t.close()},p.current=t},[o,i,v,m,g,h,_]),(0,Y.useEffect)(()=>{m&&(p.current?.close(),p.current=null)},[m]),(0,Y.useEffect)(()=>{r.popLocation.pathname===`/notifications`&&u(new URLSearchParams(r.popLocation.search).get(`highlight`))},[r.popLocation.pathname,r.popLocation.search]),(0,J.jsx)(Vhe,{value:(0,Y.useMemo)(()=>({notifications:i,latestNotification:o,groups:a,unreadCount:i.length,highlightedId:l,browserSupported:zS(),browserPermission:s,panelOpen:m,openPanel:v,requestBrowserPermission:w,previewSound:T,resolveAction:E,markRead:y,markManyRead:b,clearGroup:x,clearAll:S,clearTerminalSession:C}),[s,S,x,C,a,l,o,b,y,i,v,m,T,w,E]),children:e})}function BS(){return(0,Y.useContext)(RS)||Hhe}function VS({className:e,badgeClassName:t,iconClassName:n,size:r=`mobile`}){let{unreadCount:i,openPanel:a}=BS();return(0,J.jsx)(Eh,{label:i>0?`Open notifications, ${i} unread`:`Open notifications`,icon:(0,J.jsx)(qp,{className:fr(`h-4 w-4`,n)}),badge:i>0?(0,J.jsx)(vh,{count:i,className:fr(`ring-background absolute -right-1.5 -top-1.5 ring-2`,t),"aria-hidden":`true`}):void 0,size:r,className:e,onClick:()=>a(),"data-notification-entry-button":`true`})}function HS({children:e,maxWidth:t=300,duration:n=10,gap:r=20,className:i=``}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=()=>{if(l.current&&u.current){let e=l.current.offsetWidth,t=u.current.scrollWidth;c(t>e)}};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[e]);let d=(0,Y.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error(`Failed to copy path:`,e)}},[e]),f=typeof t==`number`?`${t}px`:t;return(0,J.jsxs)(`button`,{onClick:d,className:`hover:bg-muted/50 group flex cursor-pointer items-center gap-1.5 rounded transition-colors ${i}`,title:`${e}\n\nClick to copy`,children:[(0,J.jsx)(`div`,{ref:l,className:`relative overflow-hidden whitespace-nowrap`,style:{maxWidth:f},children:(0,J.jsx)(`div`,{ref:u,"data-content":e,className:`relative inline-block ${s?`animate-marquee group-hover:[animation-play-state:paused]!`:``}`,style:s?{"--marquee-duration":`${n}s`,"--marquee-gap":`${r}px`}:void 0,children:e})}),(0,J.jsx)(`span`,{className:`text-muted-foreground group-hover:text-foreground shrink-0 transition-colors`,children:a?(0,J.jsx)(Xp,{className:`h-3.5 w-3.5 text-green-500`}):(0,J.jsx)(rm,{className:`h-3.5 w-3.5`})})]})}function US({compact:e=!1}){if(B())return(0,J.jsxs)(`div`,{className:`status-indicator flex items-center gap-1.5 text-xs`,title:`Live features disabled (no file watching, task toggling, or AI integration)`,children:[(0,J.jsx)(Tce,{className:`h-3.5 w-3.5 text-blue-500`}),!e&&(0,J.jsx)(`span`,{className:`status-text text-blue-600`,children:`Static`})]});let t=kh(),n=Qle();if(t.connected){let n=t.watcherEnabled?`Watching for changes`:`File watcher disabled`;return(0,J.jsxs)(`div`,{className:`status-indicator flex items-center gap-1.5 text-xs`,children:[(0,J.jsx)(Em,{className:`h-3.5 w-3.5 text-green-500`}),!e&&(0,J.jsx)(gh,{content:n,children:(0,J.jsx)(`span`,{className:`status-text cursor-default text-green-600`,children:`Live`})})]})}return(0,J.jsxs)(`div`,{className:`status-indicator flex items-center gap-1.5 text-xs`,children:[(0,J.jsx)(Zm,{className:`h-3.5 w-3.5 text-red-500`}),!e&&(0,J.jsx)(`span`,{className:`status-text text-red-600`,children:`Offline`}),t.reconnectCountdown!==null&&(0,J.jsxs)(`button`,{onClick:n,className:`text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1 transition-colors`,title:`Click to reconnect now`,children:[(0,J.jsxs)(`span`,{className:`text-xs`,children:[`(`,t.reconnectCountdown,`s)`]}),(0,J.jsx)(Fm,{className:`h-3 w-3`})]})]})}function Xhe(){let e=B(),[t,n]=(0,Y.useState)(`Unknown`),[r,i]=(0,Y.useState)(null);if((0,Y.useEffect)(()=>{e&&hf().then(e=>{e?.meta?.timestamp?n(new Date(e.meta.timestamp).toLocaleString()):n(`Unknown`),i(e?.git?.repositoryUrl??null)}).catch(()=>{n(`Unknown`),i(null)})},[e]),e)return(0,J.jsx)(`div`,{className:`desktop-status border-border bg-muted/30 text-muted-foreground flex h-8 items-center justify-between gap-4 border-t px-2 text-xs`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-4`,children:[(0,J.jsx)(US,{}),(0,J.jsxs)(`span`,{className:`truncate`,children:[`Generated: `,t]}),r&&(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(Wce,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(HS,{children:r,maxWidth:280,duration:12,className:`text-xs`})]})]})});let a=kh();return(0,J.jsxs)(`div`,{className:`desktop-status border-border bg-muted/30 text-muted-foreground flex h-8 items-center justify-between gap-4 border-t px-2 text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsx)(US,{}),a.projectDir&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(gm,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(HS,{children:a.projectDir,maxWidth:300,duration:12,className:`text-xs`})]})]}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(VS,{})})]})}function Zhe(){let[e,t]=(0,Y.useState)(!1),n=Ro(),r=kh(),i=us(),a=r.dirName??`OpenSpec`,o=ee(),s=B(),c=()=>t(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`header`,{className:`mobile-header border-border bg-background flex h-12 items-center justify-between border-b px-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`button`,{onClick:()=>t(!0),className:`hover:bg-muted -ml-1.5 rounded-md p-1.5`,"aria-label":`Open menu`,children:(0,J.jsx)(qce,{className:`h-5 w-5`})}),(0,J.jsx)(`span`,{className:`font-nav max-w-[min(52vw,18rem)] truncate text-[12px] tracking-[0.04em]`,children:a})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Eh,{label:`Open search`,icon:(0,J.jsx)(zm,{className:`h-4 w-4`}),onClick:()=>Vp.activatePop(`/search`)}),!s&&(0,J.jsx)(VS,{}),(0,J.jsx)(US,{compact:!0})]})]}),e&&(0,J.jsxs)(`div`,{className:`fixed inset-0 z-50 flex`,children:[(0,J.jsx)(`div`,{className:`animate-in fade-in absolute inset-0 bg-black/50 duration-200`,onClick:c}),(0,J.jsxs)(`nav`,{className:`bg-background border-border animate-in slide-in-from-left relative flex h-full w-64 max-w-[80vw] flex-col border-r p-4 duration-200`,children:[(0,J.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,J.jsx)(`img`,{src:n?`${o}openspec_pixel_dark.svg`:`${o}openspec_pixel_light.svg`,alt:`OpenSpec`,className:`h-5`}),(0,J.jsx)(`button`,{onClick:c,className:`hover:bg-muted rounded-md p-1.5`,"aria-label":`Close menu`,children:(0,J.jsx)(pn,{className:`h-5 w-5`})})]}),s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`ul`,{className:`flex-1 space-y-1`,children:Sh.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(Rp,{to:e.to,onClick:c,className:`hover:bg-muted [&.active]:bg-primary [&.active]:text-primary-foreground flex items-center gap-2 rounded-md px-3 py-2`,children:[(0,J.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`font-nav text-base tracking-[0.04em]`,children:e.label})]})},e.to))}),(0,J.jsx)(`div`,{className:`border-border space-y-1 border-t pt-4`,children:(0,J.jsxs)(Rp,{to:Ch.to,onClick:c,className:`hover:bg-muted [&.active]:bg-primary [&.active]:text-primary-foreground flex items-center gap-2 rounded-md px-3 py-2`,children:[(0,J.jsx)(Ch.icon,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`font-nav text-base tracking-[0.04em]`,children:Ch.label})]})})]}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(Th,{area:`main`,tabs:i.mainTabs,className:`scrollbar-thin scrollbar-track-transparent h-full overflow-auto`,useLinks:!0,onNavigate:c})}),(0,J.jsx)(`div`,{className:`text-muted-foreground text-[10px] font-medium uppercase tracking-wider`,children:`Bottom`}),(0,J.jsx)(`div`,{className:`border-border border-t pt-2`,children:(0,J.jsx)(Th,{area:`bottom`,tabs:i.bottomTabs,onNavigate:c})})]})]})]})]})}function Qhe(){let e=us();return(0,J.jsx)(`nav`,{className:`mobile-tabbar border-border bg-background flex h-14 items-stretch border-t`,children:(B()?qle:e.mainTabs.map(e=>xh.find(t=>t.to===e)).filter(e=>e!=null)).map(e=>(0,J.jsxs)(Rp,{to:e.to,className:`text-muted-foreground hover:text-foreground [&.active]:text-primary flex flex-1 flex-col items-center justify-center gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`relative`,children:[(0,J.jsx)(e.icon,{className:`h-5 w-5 shrink-0`}),e.beta?(0,J.jsx)(bh,{}):null]}),(0,J.jsx)(`span`,{className:`font-nav text-[10px] tracking-[0.03em]`,children:e.label})]},e.to))})}function WS(e,t){(0,Y.useInsertionEffect)(()=>{if(typeof document>`u`)return;let n=[...document.head.querySelectorAll(`style[data-head-style]`)].find(t=>t.dataset.headStyle===e);if(n){let e=Number(n.dataset.refCount??`1`);return n.dataset.refCount=String(e+1),n.textContent!==t&&(n.textContent=t),()=>{let e=Number(n.dataset.refCount??`1`)-1;if(e<=0){n.remove();return}n.dataset.refCount=String(e)}}let r=document.createElement(`style`);return r.setAttribute(`data-head-style`,e),r.dataset.refCount=`1`,r.textContent=t,document.head.appendChild(r),()=>{let e=Number(r.dataset.refCount??`1`)-1;if(e>0){r.dataset.refCount=String(e);return}r.remove()}},[t,e])}function GS({open:e,title:t,headerActions:n,onClose:r,onDismissRequest:i,onClosed:a,children:o,footer:s,dialogClassName:c=``,contentClassName:l=``,contentShellClassName:u=``,className:d=``,bodyClassName:f=``,maxHeight:p=`86vh`,borderVariant:m=`default`}){let h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),_=(0,Y.useId)(),v=i===void 0?r:i;(0,Y.useEffect)(()=>{let e=h.current;if(!e||!a)return;let t=()=>{a()};return e.addEventListener(`close`,t),()=>{e.removeEventListener(`close`,t)}},[a]),(0,Y.useLayoutEffect)(()=>{let t=h.current;t&&(e&&!t.open?typeof t.showModal==`function`?t.showModal():t.setAttribute(`open`,``):!e&&t.open&&(typeof t.close==`function`?t.close():t.removeAttribute(`open`)))},[e]),(0,Y.useEffect)(()=>{let e=h.current;if(!e)return;let t=e=>{e.preventDefault(),v?.()},n=e=>{let t=g.current;if(!t||e.target instanceof Node&&t.contains(e.target))return;let n=t.getBoundingClientRect();e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top&&e.clientY<=n.bottom||v?.()};return e.addEventListener(`cancel`,t),e.addEventListener(`click`,n),()=>{e.removeEventListener(`cancel`,t),e.removeEventListener(`click`,n)}},[v]);let y=m===`error`?`border-red-500/60`:m===`success`?`border-green-500/50`:`border-border`;return WS(`dialog:openspec-dialog`,(0,Y.useMemo)(()=>String.raw`
884
884
  dialog.openspec-dialog {
885
885
  opacity: 0;
886
886
  transform: translateY(8px);
@@ -1324,7 +1324,7 @@ function handleMessage(payload) {
1324
1324
  ${_}px !important;
1325
1325
  ${v}px !important;
1326
1326
  }
1327
- `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,J.jsx)(iHe,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:Y.cloneElement(e,{ref:u})})}var oHe=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=QW(sHe),d=(0,Y.useId)(),f=(0,Y.useRef)(n),p=(0,Y.useRef)(r);$W(()=>{f.current=n,p.current=r});let m=!0,h=(0,Y.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,Y.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),Y.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,J.jsx)(aHe,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,J.jsx)(eG.Provider,{value:h,children:e})};function sHe(){return new Map}function tX(e=!0){let t=(0,Y.useContext)(eG);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,Y.useId)();(0,Y.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,Y.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var nX=e=>e.key||``;function rX(e){let t=[];return Y.Children.forEach(e,e=>{(0,Y.isValidElement)(e)&&t.push(e)}),t}var iX=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=tX(o),f=(0,Y.useMemo)(()=>rX(e),[e]),p=o&&!u?[]:f.map(nX),m=(0,Y.useRef)(!0),h=(0,Y.useRef)(f),g=QW(()=>new Map),_=(0,Y.useRef)(new Set),[v,y]=(0,Y.useState)(f),[b,x]=(0,Y.useState)(f);$W(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=nX(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=nX(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(rX(e)),y(f),null}let{forceRender:C}=(0,Y.useContext)(ZW);return(0,J.jsx)(J.Fragment,{children:b.map(e=>{let v=nX(e),y=o&&!u?!1:f===b||p.includes(v);return(0,J.jsx)(oHe,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},aX=(0,Y.createContext)({strict:!1}),oX={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},sX=!1;function cHe(){if(sX)return;let e={};for(let t in oX)e[t]={isEnabled:e=>oX[t].some(t=>!!e[t])};DJ(e),sX=!0}function cX(){return cHe(),KBe()}function lHe(e){let t=cX();for(let n in e)t[n]={...t[n],...e[n]};DJ(t)}var uHe=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function lX(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||uHe.has(e)}var dHe=r({default:()=>uX}),uX,fHe=n((()=>{throw uX={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),dX=e=>!lX(e);function pHe(e){typeof e==`function`&&(dX=t=>t.startsWith(`on`)?!lX(t):e(t))}try{pHe((fHe(),t(dHe)).default)}catch{}function mHe(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Oq(e[i])||(dX(i)||n===!0&&lX(i)||!t&&!lX(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var fX=(0,Y.createContext)({});function hHe(e,t){if(xJ(e)){let{initial:t,animate:n}=e;return{initial:t===!1||vJ(t)?t:void 0,animate:vJ(n)?n:void 0}}return e.inherit===!1?{}:t}function gHe(e){let{initial:t,animate:n}=hHe(e,(0,Y.useContext)(fX));return(0,Y.useMemo)(()=>({initial:t,animate:n}),[pX(t),pX(n)])}function pX(e){return Array.isArray(e)?e.join(` `):e}var mX=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hX(e,t,n){for(let r in t)!Oq(t[r])&&!QJ(r,n)&&(e[r]=t[r])}function _He({transformTemplate:e},t){return(0,Y.useMemo)(()=>{let n=mX();return qJ(n,t,e),Object.assign({},n.vars,n.style)},[t])}function vHe(e,t){let n=e.style||{},r={};return hX(r,n,e),Object.assign(r,_He(e,t)),r}function yHe(e,t){let n={},r=vHe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var gX=()=>({...mX(),attrs:{}});function bHe(e,t,n,r){let i=(0,Y.useMemo)(()=>{let n=gX();return eY(n,t,nY(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};hX(t,e.style,e),i.style={...t,...i.style}}return i}var xHe=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function _X(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(xHe.indexOf(e)>-1||/[A-Z]/u.test(e))}function SHe(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??_X(e)?bHe:yHe)(t,r,i,e),c=mHe(t,typeof e==`string`,a),l=e===Y.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,Y.useMemo)(()=>Oq(u)?u.get():u,[u]);return(0,Y.createElement)(e,{...l,children:d})}function CHe({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:wHe(n,r,i,e),renderState:t()}}function wHe(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=FY(a[e]);let{initial:o,animate:s}=e,c=xJ(e),l=SJ(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!_J(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=wq(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var vX=e=>(t,n)=>{let r=(0,Y.useContext)(fX),i=(0,Y.useContext)(eG),a=()=>CHe(e,t,r,i);return n?a():QW(a)},THe=vX({scrapeMotionValuesFromProps:$J,createRenderState:mX}),EHe=vX({scrapeMotionValuesFromProps:rY,createRenderState:gX}),DHe=Symbol.for(`motionComponentSymbol`);function OHe(e,t,n){let r=(0,Y.useRef)(n);(0,Y.useInsertionEffect)(()=>{r.current=n});let i=(0,Y.useRef)(null);return(0,Y.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var yX=(0,Y.createContext)({});function bX(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function kHe(e,t,n,r,i,a){let{visualElement:o}=(0,Y.useContext)(fX),s=(0,Y.useContext)(aX),c=(0,Y.useContext)(eG),l=(0,Y.useContext)($Y),u=l.reducedMotion,d=l.skipAnimations,f=(0,Y.useRef)(null),p=(0,Y.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,Y.useContext)(yX);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&AHe(f.current,n,i,h);let g=(0,Y.useRef)(!1);(0,Y.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[jq],v=(0,Y.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return $W(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,Y.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function AHe(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:xX(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&bX(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function xX(e){if(e)return e.options.allowProjection===!1?xX(e.parent):e.projection}function SX(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&lHe(r);let a=n?n===`svg`:_X(e),o=a?EHe:THe;function s(n,s){let c,l={...(0,Y.useContext)($Y),...n,layoutId:jHe(n)},{isStatic:u}=l,d=gHe(n),f=o(n,u);if(!u&&typeof window<`u`){MHe(l,r);let t=NHe(l);c=t.MeasureLayout,d.visualElement=kHe(e,f,l,i,t.ProjectionNode,a)}return(0,J.jsxs)(fX.Provider,{value:d,children:[c&&d.visualElement?(0,J.jsx)(c,{visualElement:d.visualElement,...l}):null,SHe(e,n,OHe(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,Y.forwardRef)(s);return c[DHe]=e,c}function jHe({layoutId:e}){let t=(0,Y.useContext)(ZW).id;return t&&e!==void 0?t+`-`+e:e}function MHe(e,t){(0,Y.useContext)(aX).strict}function NHe(e){let{drag:t,layout:n}=cX();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function CX(e,t){if(typeof Proxy>`u`)return SX;let n=new Map,r=(n,r)=>SX(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,SX(a,void 0,e,t)),n.get(a))})}CX();var PHe=(e,t)=>t.isSVG??_X(e)?new lVe(t):new rVe(t,{allowProjection:e!==Y.Fragment}),FHe=class extends kJ{constructor(e){super(e),e.animationState||=mVe(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();_J(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},IHe=0,LHe={animation:{Feature:FHe},exit:{Feature:class extends kJ{constructor(){super(...arguments),this.id=IHe++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Tq(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function wX(e){return{point:{x:e.pageX,y:e.pageY}}}var RHe=e=>t=>$q(t)&&e(t,wX(t));function TX(e,t,n,r){return PY(e,t,RHe(n),r)}var EX=({current:e})=>e?e.ownerDocument.defaultView:null,DX=(e,t)=>Math.abs(e-t);function zHe(e,t){let n=DX(e.x,t.x),r=DX(e.y,t.y);return Math.sqrt(n**2+r**2)}var OX=new Set([`auto`,`scroll`]),kX=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=AX(this.lastRawMoveEventInfo,this.transformPagePoint));let e=MX(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=zHe(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=FG;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=AX(t,this.transformPagePoint),NG.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=MX(e.type===`pointercancel`?this.lastMoveEventInfo:AX(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!$q(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=AX(wX(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=FG;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,MX(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=uG(TX(this.contextWindow,`pointermove`,this.handlePointerMove,d),TX(this.contextWindow,`pointerup`,this.handlePointerUp,d),TX(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(OX.has(e.overflowX)||OX.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),NG.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),PG(this.updatePoint)}};function AX(e,t){return t?{point:t(e.point)}:e}function jX(e,t){return{x:e.x-t.x,y:e.y-t.y}}function MX({point:e},t){return{point:e,delta:jX(e,NX(t)),offset:jX(e,BHe(t)),velocity:VHe(t,.1)}}function BHe(e){return e[0]}function NX(e){return e[e.length-1]}function VHe(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=NX(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>pG(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>pG(t)*2&&(r=e[1]);let a=mG(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function HHe(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?mK(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?mK(n,e,r.max):Math.min(e,n)),e}function PX(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function UHe(e,{top:t,left:n,bottom:r,right:i}){return{x:PX(e.x,n,i),y:PX(e.y,t,r)}}function FX(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function WHe(e,t){return{x:FX(e.x,t.x),y:FX(e.y,t.y)}}function GHe(e,t){let n=.5,r=pY(e),i=pY(t);return i>r?n=dG(t.min,t.max-r,e.min):r>i&&(n=dG(e.min,e.max-i,t.min)),rG(0,1,n)}function KHe(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var IX=.35;function qHe(e=IX){return e===!1?e=0:e===!0&&(e=IX),{x:LX(e,`left`,`right`),y:LX(e,`top`,`bottom`)}}function LX(e,t,n){return{min:RX(e,t),max:RX(e,n)}}function RX(e,t){return typeof e==`number`?e:e[t]||0}var JHe=new WeakMap,YHe=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=gJ(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(wX(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=SBe(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kY(e=>{let t=this.getAxisMotionValue(e).get()||0;if(tK.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=pY(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&NG.update(()=>i(e,t),!1,!0),kq(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=ZHe(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&NG.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new kX(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:EX(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&NG.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!BX(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=HHe(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&bX(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=UHe(n.layoutBox,e):this.constraints=!1,this.elastic=qHe(t),r!==this.constraints&&!bX(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&kY(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=KHe(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!bX(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=ZBe(n,r.root,this.visualElement.getTransformPagePoint()),a=WHe(r.layout.layoutBox,i);if(t){let e=t(JBe(a));this.hasMutatedConstraints=!!e,e&&(a=AJ(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=kY(o=>{if(!BX(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return kq(this.visualElement,e),n.start(xq(e,n,0,t,this.visualElement,!1))}stopAnimation(){kY(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){kY(t=>{let{drag:n}=this.getProps();if(!BX(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-mK(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!bX(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};kY(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=GHe({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),kY(t=>{if(!BX(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(mK(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;JHe.set(this.visualElement,this);let e=this.visualElement.current,t=TX(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&OBe(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();bX(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=XHe(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),NG.read(r);let o=PY(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(kY(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=IX,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function zX(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function XHe(e,t,n){let r=dJ(e,zX(n)),i=dJ(t,zX(n));return()=>{r(),i()}}function BX(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function ZHe(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var QHe=class extends kJ{constructor(e){super(e),this.removeGroupControls=lG,this.removeListeners=lG,this.controls=new YHe(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||lG}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},VX=e=>(t,n)=>{e&&NG.update(()=>e(t,n),!1,!0)},$He=class extends kJ{constructor(){super(...arguments),this.removePointerDownListener=lG}onPointerDown(e){this.session=new kX(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:EX(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:VX(e),onStart:VX(t),onMove:VX(n),onEnd:(e,t)=>{delete this.session,r&&NG.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=TX(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},HX=!1,eUe=class extends Y.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),HX&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),IY.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),HX=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||NG.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Jq.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;HX=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function UX(e){let[t,n]=tX(),r=(0,Y.useContext)(ZW);return(0,J.jsx)(eUe,{...e,layoutGroup:r,switchLayoutGroup:(0,Y.useContext)(yX),isPresent:t,safeToRemove:n})}var tUe={pan:{Feature:$He},drag:{Feature:QHe,ProjectionNode:QY,MeasureLayout:UX}};function WX(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&NG.postRender(()=>i(t,wX(t)))}var nUe=class extends kJ{mount(){let{current:e}=this.node;e&&(this.unmount=wBe(e,(e,t)=>(WX(this.node,t,`Start`),e=>WX(this.node,e,`End`))))}unmount(){}},rUe=class extends kJ{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=uG(PY(this.node.current,`focus`,()=>this.onFocus()),PY(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function GX(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&NG.postRender(()=>i(t,wX(t)))}var iUe=class extends kJ{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=ABe(e,(e,t)=>(GX(this.node,t,`Start`),(e,{success:t})=>GX(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},KX=new WeakMap,qX=new WeakMap,aUe=e=>{let t=KX.get(e.target);t&&t(e)},oUe=e=>{e.forEach(aUe)};function sUe({root:e,...t}){let n=e||document;qX.has(n)||qX.set(n,{});let r=qX.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(oUe,{root:e,...t})),r[i]}function cUe(e,t,n){let r=sUe(t);return KX.set(e,n),r.observe(e),()=>{KX.delete(e),r.unobserve(e)}}var lUe={some:0,all:1},uUe=class extends kJ{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:lUe[r]};this.stopObserver=cUe(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(dUe(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function dUe({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var fUe={inView:{Feature:uUe},tap:{Feature:iUe},focus:{Feature:rUe},hover:{Feature:nUe}},pUe={layout:{ProjectionNode:QY,MeasureLayout:UX}},JX=CX({...LHe,...fUe,...tUe,...pUe},PHe),mUe=[.5,2,6];function YX(e){return Number(e.toFixed(4)).toString()}function hUe(e,t,n){let r=n===`bottom`?`to bottom`:`to top`,i=100/t;if(e===t-1)return`linear-gradient(${r}, transparent ${YX(100-i)}%, black 100%)`;let a=e*i,o=(e+1)*i,s=(e+2)*i,c=(e+3)*i;return`linear-gradient(${r}, transparent ${YX(a)}%, black ${YX(o)}%, black ${YX(s)}%, transparent ${YX(c)}%)`}function XX({position:e,blurLevels:t=mUe,surfaceClassName:n,className:r,...i}){return(0,J.jsxs)(`div`,{...i,"aria-hidden":`true`,"data-progressive-blur":e,"data-progressive-blur-levels":t.length,className:fr(`progressive-blur grid`,r),children:[t.map((n,r)=>{let i=hUe(r,t.length,e);return(0,J.jsx)(`div`,{"data-progressive-blur-layer":r,className:`progressive-blur__layer`,style:{zIndex:r+1,backdropFilter:`blur(${n}px)`,WebkitBackdropFilter:`blur(${n}px)`,maskImage:i,WebkitMaskImage:i}},`${n}:${r}`)}),(0,J.jsx)(`div`,{"data-progressive-blur-surface":``,className:fr(`progressive-blur__surface`,n),style:{zIndex:t.length+1}})]})}var ZX=[.5,2,6];function QX({laneId:e,density:t,header:n,children:r,className:i,...a}){return(0,J.jsxs)(`section`,{...a,"data-kanban-lane":e,"data-kanban-lane-density":t,className:fr(`kanban-lane-viewport border-border/70 grid min-h-0 min-w-0 overflow-hidden border-t`,i),children:[(0,J.jsx)(`div`,{"data-kanban-lane-scroll":e,className:`kanban-lane-viewport__scroll scrollbar-thin scrollbar-track-transparent scrollbar-thumb-[color-mix(in_srgb,currentColor,transparent_78%)] min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain pr-1`,children:r}),(0,J.jsx)(XX,{position:`top`,blurLevels:ZX,"data-kanban-lane-veil":`top`,className:`kanban-lane-viewport__veil kanban-lane-viewport__veil--top`,surfaceClassName:`kanban-lane-viewport__veil-surface kanban-lane-viewport__veil-surface--top`}),(0,J.jsx)(`header`,{"data-kanban-lane-header":e,className:`kanban-lane-viewport__header`,children:n}),(0,J.jsx)(XX,{position:`bottom`,blurLevels:ZX,"data-kanban-lane-veil":`bottom`,className:`kanban-lane-viewport__veil kanban-lane-viewport__veil--bottom`,surfaceClassName:`kanban-lane-viewport__veil-surface kanban-lane-viewport__veil-surface--bottom`})]})}var $X=[{id:`no-tasks`,label:`No tracked tasks`,shortLabel:`No tasks`,accentClass:`bg-muted-foreground/55`},{id:`in-progress`,label:`Tasks remaining`,shortLabel:`Remaining`,accentClass:`bg-primary`},{id:`complete`,label:`Tasks complete`,shortLabel:`Complete`,accentClass:`bg-emerald-500`},{id:`archived`,label:`Archived`,shortLabel:`Archived`,accentClass:`bg-accent`}];function eZ(e){let t={"no-tasks":[],"in-progress":[],complete:[]};for(let n of e)t[n.trackedTaskProgress.phase].push(n);return t}function gUe(e){let t=eZ(e);return{"no-tasks":t[`no-tasks`].length,"in-progress":t[`in-progress`].length,complete:t.complete.length}}function _Ue(e,t,n=Date.now()){return e.filter(e=>Nre(e,t,n)).sort((e,t)=>bs(t)-bs(e)||e.id.localeCompare(t.id))}function tZ(e){return e.archivedAt??bs(e)}var nZ=`application/x-openspecui-change-id`,vUe=[{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}];function yUe({activeItems:e,archivedItems:t,statuses:n,range:r,onRangeChange:i,activeState:a,archiveState:o,rootReady:s,rootBlockedReason:c,applyStatusCurrent:l,applyStatusError:u,onApply:d,onArchive:f}){let[p,m]=(0,Y.useState)(!1),h=(0,Y.useMemo)(()=>eZ(e),[e]),g=(0,Y.useMemo)(()=>new Map(e.map(e=>[e.id,e])),[e]),_=(0,Y.useMemo)(()=>new Map(n.map(e=>[e.changeName,e])),[n]),v=s&&a.current,y=v&&o.current,b=e=>{if(e.preventDefault(),m(!1),!y)return;let t=e.dataTransfer.getData(nZ);if(!t)return;let n=g.get(t);n&&f(n)};return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:(0,J.jsx)(SUe,{activeError:a.error,archiveError:o.error,applyStatusError:u,rowErrors:a.rowErrors,progress:a.progress})}),(0,J.jsx)(`div`,{"data-kanban-grid":!0,className:`scrollbar-thin scrollbar-track-transparent scrollbar-thumb-[color-mix(in_srgb,currentColor,transparent_78%)] grid min-h-0 min-w-0 flex-1 auto-cols-[minmax(16rem,1fr)] grid-flow-col gap-3 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2`,children:$X.map(e=>{let n=e.id===`archived`,s=e.id===`archived`?[]:h[e.id],u=n?t:[],g=n?u.length:s.length,x=n?o.initialLoading:a.initialLoading,S=n?o.updating:a.updating;return(0,J.jsx)(QX,{laneId:e.id,density:`full`,"data-lane":e.id,onDragOver:n?e=>{!y||!e.dataTransfer.types.includes(nZ)||(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m(!0))}:void 0,onDragLeave:n?e=>{e.currentTarget.contains(e.relatedTarget)||m(!1)}:void 0,onDrop:n?b:void 0,className:fr(`transition-colors`,n&&p&&`border-primary bg-primary/5`),header:(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 items-center justify-between gap-2 px-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:fr(`h-2 w-2 shrink-0 rounded-full`,e.accentClass)}),(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:e.label}),(0,J.jsx)(vh,{count:g,tone:`muted`,size:`xs`,shape:`pill`})]}),n?(0,J.jsx)(YW,{value:r,options:vUe,onValueChange:i,ariaLabel:`Archived time range`,className:`pointer-events-auto h-7 min-w-0 gap-1 px-2 text-xs`}):null]}),children:(0,J.jsx)(PC,{active:S&&g>0,children:(0,J.jsxs)(JX.div,{layout:!0,className:`min-h-24 space-y-2`,children:[x&&g===0?(0,J.jsx)(zC,{count:2}):null,(0,J.jsxs)(iX,{initial:!1,mode:`popLayout`,children:[u.map(e=>(0,J.jsx)(JX.div,{layout:!0,layoutId:`live-kanban:${e.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,scale:.98},children:(0,J.jsx)(xUe,{item:e})},`archived:${e.id}`)),s.map(e=>(0,J.jsx)(JX.div,{layout:!0,layoutId:`live-kanban:${e.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,scale:.98},children:(0,J.jsx)(bUe,{item:e,status:_.get(e.id),canApply:v&&l,canArchive:v,canDragArchive:y,applyBlockedReason:c??(l?null:`Apply availability is not current.`),archiveBlockedReason:c,onApply:d,onArchive:f})},`active:${e.id}`))]}),!x&&g===0?(0,J.jsx)(`div`,{className:`border-border/60 text-muted-foreground flex h-20 items-center justify-center rounded-md border border-dashed`,children:e.id===`no-tasks`?(0,J.jsx)(lm,{className:`h-4 w-4`,"aria-label":`No entries`}):(0,J.jsx)(Dm,{className:`h-4 w-4`,"aria-label":`No entries`})}):null]})})},e.id)})})]})}function bUe({item:e,status:t,canApply:n,canArchive:r,canDragArchive:i,applyBlockedReason:a,archiveBlockedReason:o,onApply:s,onArchive:c}){let l=XW(t),u=e.trackedTaskProgress,d=u.total>0?Math.round(u.completed/u.total*100):0,f={family:`changes`,entityId:e.id},p=!n||!l.available;return(0,J.jsxs)(`article`,{draggable:i,onDragStart:i?t=>{t.dataTransfer.setData(nZ,e.id),t.dataTransfer.effectAllowed=`move`}:void 0,className:fr(`border-border/70 bg-card min-w-0 rounded-md border p-2.5`,i&&`cursor-grab active:cursor-grabbing`),children:[(0,J.jsxs)(Rp,{to:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{...f,title:e.name,subtitle:e.id}}),vt:{sharedElements:f},...op(f,`container`),draggable:!1,className:`block min-w-0`,children:[(0,J.jsx)(`div`,{...op(f,`title`),className:`truncate text-sm font-medium`,children:e.name}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:e.updatedAt>0?vw(e.updatedAt):e.id}),(0,J.jsx)(`div`,{className:`bg-muted mt-2 h-1.5 rounded-full`,children:(0,J.jsx)(JX.div,{className:`bg-primary h-full rounded-full`,initial:!1,animate:{width:`${d}%`}})})]}),(0,J.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground font-mono text-[11px]`,children:[u.completed,`/`,u.total]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>s(e),"aria-label":`Apply ${e.name}`,title:a??(l.missingArtifactIds.length>0?`Missing: ${l.missingArtifactIds.join(`, `)}`:`Apply`),className:`hover:bg-muted inline-flex h-7 w-7 items-center justify-center rounded-md disabled:cursor-not-allowed disabled:opacity-40`,children:(0,J.jsx)(Nm,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>c(e),"aria-label":`Archive ${e.name}`,title:o??`Archive`,className:`hover:bg-muted inline-flex h-7 w-7 items-center justify-center rounded-md disabled:cursor-not-allowed disabled:opacity-40`,children:(0,J.jsx)(Hp,{className:`h-3.5 w-3.5`})})]})]})]})}function xUe({item:e}){let t={family:`archive`,entityId:e.id};return(0,J.jsx)(Rp,{to:`/archive/$changeId`,params:{changeId:e.id},state:n=>({...n,__vtHandoff:{...t,title:e.name,subtitle:e.id}}),vt:{sharedElements:t},...op(t,`container`),className:`border-border/70 bg-card hover:bg-muted/50 block min-w-0 rounded-md border p-2.5`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,J.jsx)(Hp,{className:`text-muted-foreground mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{...op(t,`title`),className:`truncate text-sm font-medium`,children:e.name}),(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:yw(tZ(e))})]})]})})}function SUe({activeError:e,archiveError:t,applyStatusError:n,rowErrors:r,progress:i}){let a=[e?`Changes: ${e.message}`:null,t?`Archives: ${t.message}`:null,n?`Apply status: ${n.message}`:null,...r.map(e=>`${e.changeId}: ${e.message}`)].filter(e=>e!==null);return(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsxs)(`div`,{className:`text-muted-foreground font-mono text-xs`,"aria-live":`polite`,children:[i.completed,`/`,i.total]}):null,a.length>0?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`div`,{className:`min-w-0 space-y-1`,children:a.map(e=>(0,J.jsx)(`div`,{className:`break-words`,children:e},e))})]}):null]})}function rZ({activeItems:e,archivedItems:t,activeCounts:n,archivedCount:r,variant:i=`full`,pending:a=!1,className:o}){let s=eZ(e),c=i===`compact`;return(0,J.jsx)(`div`,{"data-testid":`readonly-kanban`,"aria-busy":a,className:fr(`@container min-w-0 max-w-full overflow-x-clip`,c&&`@[32rem]:h-[32rem] @[64rem]:h-72 h-[46rem]`,o),children:(0,J.jsx)(`div`,{"data-testid":`readonly-kanban-grid`,className:fr(`@[32rem]:grid-cols-2 @[64rem]:grid-cols-4 grid w-full min-w-0 max-w-full grid-cols-1 gap-3 overflow-x-clip`,c&&`@[32rem]:grid-rows-2 @[64rem]:grid-rows-1 h-full min-h-0 grid-rows-4`),children:$X.map(e=>{let i=e.id===`archived`?t:s[e.id],o=e.id===`archived`?r:n[e.id];return(0,J.jsx)(QX,{laneId:e.id,density:c?`compact`:`full`,header:(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 items-center justify-between gap-2 px-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:fr(`h-2 w-2 shrink-0 rounded-full`,e.accentClass)}),(0,J.jsx)(`h3`,{className:`truncate text-xs font-semibold`,children:c?e.shortLabel:e.label})]}),a?(0,J.jsx)(FC,{className:`h-5 w-8 rounded-full`}):(0,J.jsx)(vh,{count:o,tone:`muted`,size:`xs`,shape:`pill`})]}),children:a?(0,J.jsx)(`div`,{className:`space-y-2`,"aria-hidden":`true`,children:Array.from({length:3},(e,t)=>(0,J.jsxs)(`div`,{className:`border-border/70 bg-card space-y-2 rounded-md border px-2.5 py-2`,children:[(0,J.jsx)(FC,{className:`h-3 w-3/4`}),(0,J.jsx)(FC,{className:`h-2.5 w-1/2`})]},t))}):(0,J.jsxs)(JX.div,{layout:!0,className:`space-y-2`,"data-lane":e.id,children:[(0,J.jsx)(iX,{initial:!1,mode:`popLayout`,children:i.map(t=>(0,J.jsx)(JX.div,{layout:!0,layoutId:`readonly-kanban:${t.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,scale:.98},transition:{duration:.16},children:(0,J.jsx)(CUe,{item:t,laneId:e.id,compact:c})},`${e.id}:${t.id}`))}),i.length===0&&o===0?(0,J.jsx)(`div`,{className:`border-border/60 text-muted-foreground flex h-16 items-center justify-center rounded-md border border-dashed`,children:e.id===`no-tasks`?(0,J.jsx)(lm,{className:`h-4 w-4`,"aria-label":`No entries`}):(0,J.jsx)(Dm,{className:`h-4 w-4`,"aria-label":`No entries`})}):null]})},e.id)})})})}function CUe({item:e,laneId:t,compact:n}){let r=t===`archived`,i={family:r?`archive`:`changes`,entityId:e.id},a=e.cliTaskSummary??null,o=a?{completed:a.completedTasks,total:a.totalTasks}:{completed:e.trackedTaskProgress.completed,total:e.trackedTaskProgress.total},s=o.total>0?Math.round(o.completed/o.total*100):0;return(0,J.jsxs)(Rp,{to:r?`/archive/$changeId`:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{...i,title:e.name,subtitle:e.id}}),vt:{sharedElements:i},...op(i,`container`),className:`border-border/70 bg-card hover:bg-muted/50 block min-w-0 rounded-md border px-2.5 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[r?(0,J.jsx)(Hp,{className:`text-muted-foreground mt-0.5 h-3.5 w-3.5 shrink-0`}):null,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{...op(i,`title`),className:`truncate text-xs font-medium`,children:e.name}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-[11px]`,children:r?yw(tZ(e)):e.updatedAt>0?vw(e.updatedAt):e.id})]}),r?null:(0,J.jsxs)(`span`,{className:`text-muted-foreground shrink-0 font-mono text-[10px]`,children:[o.completed,`/`,o.total]})]}),!r&&!n?(0,J.jsx)(`div`,{className:`bg-muted mt-2 h-1 rounded-full`,children:(0,J.jsx)(JX.div,{className:`bg-primary h-full rounded-full`,initial:!1,animate:{width:`${s}%`}})}):null]})}var iZ=`action`,aZ=`change`,oZ=`artifact`,wUe=new Set([`continue`,`ff`,`apply`,`update`,`sync`,`archive`]);function TUe(e){return wUe.has(e)}function sZ(e){let t=new URLSearchParams;return t.set(iZ,e.action),t.set(aZ,e.changeId),e.artifactId&&t.set(oZ,e.artifactId),`/opsx-compose?${t.toString()}`}function EUe(e){let t=new URLSearchParams(e),n=t.get(iZ),r=t.get(aZ)?.trim()??``,i=t.get(oZ)?.trim()||void 0;return!n||!TUe(n)||r.length===0?null:{action:n,changeId:r,artifactId:i}}function cZ(e){switch(e.action){case`continue`:return`Continue artifact ${e.artifactId??`<missing-artifact>`} for change ${e.changeId}.`;case`ff`:return`Fast-forward artifact ${e.artifactId??`<missing-artifact>`} for change ${e.changeId}.`;case`apply`:return`Apply change ${e.changeId} based on current completed artifacts.`;case`update`:return`Update the existing planning artifacts for change ${e.changeId}.`;case`sync`:return`Sync specs for change ${e.changeId}.`;case`archive`:return`Archive change ${e.changeId} after verifying completion and risks.`}}function lZ({applyCurrent:e=!0,archiveCurrent:t=!0}={}){let n=uC(),r=(0,Y.useRef)({rootAction:n,applyCurrent:e,archiveCurrent:t});r.current={rootAction:n,applyCurrent:e,archiveCurrent:t};let{openArchiveModal:i}=TC(),a=(0,Y.useCallback)(e=>{let t=r.current;return t.rootAction.status!==`ready`||!t.applyCurrent?!1:(Vp.activatePop(sZ({action:`apply`,changeId:e.changeId})),!0)},[]),o=(0,Y.useCallback)(e=>{let t=r.current;return t.rootAction.status!==`ready`||!t.archiveCurrent?!1:(i(e.changeId,e.changeName),!0)},[i]);return{rootAction:n,disabled:n.disabled,launchApply:a,launchArchive:o}}var DUe=[{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}];function OUe(){let e=B(),t=qf(),n=Yf(),r=ep(!e),[i,a]=(0,Y.useState)(`30d`),o=t.data??[],s=(0,Y.useMemo)(()=>_Ue(n.data??[],i),[n.data,i]),c=t.data!==void 0&&!t.isLoading&&!t.isUpdating&&t.error===null,l=n.data!==void 0&&!n.isLoading&&!n.isUpdating&&n.error===null,u=r.data!==void 0&&r.authority.state===`current`,{rootAction:d,launchApply:f,launchArchive:p}=lZ({applyCurrent:c&&u,archiveCurrent:c}),m=(0,J.jsxs)(`div`,{className:`flex min-w-0 shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Km,{className:`h-6 w-6 shrink-0`}),`Kanban`]}),e?(0,J.jsx)(YW,{value:i,options:DUe,onValueChange:a,ariaLabel:`Archived time range`,className:`h-8`}):null]});if(e){let e=t.error??n.error,r=t.isLoading&&t.data===void 0||n.isLoading&&n.data===void 0;return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-4 p-4`,children:[m,e?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:e.message})]}):null,r?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,J.jsx)(zC,{count:2},t))}):(0,J.jsx)(rZ,{activeItems:o,archivedItems:s,activeCounts:gUe(o),archivedCount:s.length})]})}return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-4 overflow-hidden p-4`,children:[m,(0,J.jsx)(yUe,{activeItems:o,archivedItems:s,statuses:r.data??[],range:i,onRangeChange:a,activeState:{initialLoading:t.isLoading&&t.data===void 0,updating:t.isUpdating,current:c,error:t.error,rowErrors:t.rowErrors,progress:t.progress},archiveState:{initialLoading:n.isLoading&&n.data===void 0,updating:n.isUpdating,current:l,error:n.error},rootReady:d.status===`ready`,rootBlockedReason:d.message,applyStatusCurrent:u,applyStatusError:r.error,onApply:e=>f({changeId:e.id,changeName:e.name}),onArchive:e=>p({changeId:e.id,changeName:e.name})})]})}function kUe({ratio:e}){if(!Number.isFinite(e)||e<=0)return null;let t=Math.min(100,Math.max(0,e*100));return(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`bg-primary/50 pointer-events-none absolute inset-y-0 left-0 rounded-[inherit]`,style:{width:`${t}%`}})}function uZ({changeId:e,name:t,subtitle:n,phase:r,updatedAt:i,formatTime:a,sharedFamily:o=`changes`,className:s=``,progressRatio:c=null,containerProps:l,titleProps:u,iconProps:d}){let f={family:o,entityId:e};return(0,J.jsxs)(`div`,{...l,...op(f,`container`),className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-stretch gap-x-3 ${s}`,children:[(0,J.jsx)(`div`,{className:`flex items-center`,children:(0,J.jsx)(ym,{...d,...op(f,`icon`),className:`text-muted-foreground h-5 w-5 shrink-0`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.5 py-0.5`,children:[(0,J.jsx)(`div`,{...u,...op(f,`title`),className:`truncate font-medium`,children:t}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:n})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-end justify-between gap-1 text-right`,children:[(0,J.jsx)(`div`,{className:`flex flex-1 items-center`,children:(0,J.jsxs)(_h,{tone:`custom`,size:`sm`,shape:`box`,className:`relative overflow-hidden border ${r.toneClass}`,children:[(0,J.jsx)(kUe,{ratio:c??NaN}),(0,J.jsx)(`span`,{className:`relative`,children:r.label})]})}),i>0?(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:a(i)}):null]})]})}function dZ(){return(0,J.jsx)(Qp,{className:`text-muted-foreground h-4 w-4 shrink-0`,"aria-hidden":!0})}function fZ(e){if(!e.hasStatus)return{label:`Unknown`,toneClass:`border-border text-muted-foreground`};if(e.isPlanningComplete&&e.trackedTaskPhase===`complete`)return{label:`Workflow Complete`,toneClass:`border-emerald-500/40 text-emerald-700 dark:text-emerald-300`};if(e.trackedArtifactStatus===`blocked`)return{label:`Draft`,toneClass:`border-amber-500/40 text-amber-700 dark:text-amber-300`};if(e.trackedTaskPhase===`no-tasks`)return{label:`No Tracked Tasks`,toneClass:`border-border text-muted-foreground`};let t=e.cliCompletedTasks??null;return t!==null&&t>0?{label:`Applying`,toneClass:`border-primary/40 text-primary`}:e.isPlanningComplete?{label:`Planning Complete`,toneClass:`border-sky-500/40 text-sky-700 dark:text-sky-300`}:{label:`In Execution`,toneClass:`border-primary/40 text-primary`}}function pZ(e){return e.includes(`blocked`)?`blocked`:e.includes(`ready`)?`ready`:e.includes(`done`)?`done`:e.includes(`skipped`)?`skipped`:null}function AUe(e,t){return e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id)}function jUe(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function MUe(e,t){return!!(t&&!jUe()&&typeof e.startViewTransition==`function`&&!e.activeViewTransition)}function NUe(e){if(typeof document>`u`){e.update();return}let t=e.container,n=document;if(!MUe(n,t)){e.update();return}t.style.viewTransitionName=e.transitionName;try{n.startViewTransition(()=>(0,Kr.flushSync)(e.update)).finished.catch(()=>{}).finally(()=>{t.style.viewTransitionName===e.transitionName&&(t.style.viewTransitionName=``)})}catch{t.style.viewTransitionName=``,e.update()}}function PUe(e,t){let[n,r]=(0,Y.useState)(e),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(e),o=(0,Y.useRef)(0),s=`vt-change-list-${(0,Y.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`;return(0,Y.useEffect)(()=>{if(!i.current){i.current=!0,a.current=e,r(e);return}let n=a.current;a.current=e;let c=o.current+1;if(o.current=c,e===void 0||n===void 0||AUe(n,e)){r(e);return}queueMicrotask(()=>{o.current===c&&NUe({container:t.current,transitionName:s,update:()=>{o.current===c&&r(e)}})})},[t,e,s]),n}function FUe(e){return new Map((e??[]).map(e=>[e.changeName,e]))}function IUe(){let{data:e,isLoading:t,isUpdating:n,error:r,rowErrors:i=[],progress:a=null}=qf(),o=(0,Y.useRef)(null),{data:s,isLoading:c,error:l}=ep((e?.length??0)>0),u=PUe(e,o),d=FUe(s),f=e?.length===0&&!r&&!n,p=(e?.length??0)>0||f;return t&&!e&&!r?(0,J.jsxs)(`div`,{className:`space-y-6 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(ym,{className:`h-6 w-6 shrink-0`}),`Changes`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-new`),className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium hover:opacity-90`,title:`Create a new OPSX change`,children:[(0,J.jsx)(Pm,{className:`h-4 w-4`}),`New`]})]}),a&&!r?(0,J.jsx)(Oge,{progress:a,className:`max-w-sm`}):null,(0,J.jsx)(zC,{count:5})]}):(0,J.jsxs)(`div`,{className:`space-y-6 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(ym,{className:`h-6 w-6 shrink-0`}),`Changes`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-new`),className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium hover:opacity-90`,title:`Create a new OPSX change`,children:[(0,J.jsx)(Pm,{className:`h-4 w-4`}),`New`]})]}),(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Active OPSX changes in the current writable Planning root. Completed changes are moved to`,` `,(0,J.jsx)(Rp,{to:`/archive`,className:`text-primary hover:underline`,children:`Archive`}),`.`]}),r?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-center gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`break-words`,children:r.message})]}):null,i.length>0?(0,J.jsx)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive rounded-md border px-3 py-2 text-sm`,children:i.map(e=>(0,J.jsxs)(`div`,{className:`break-words`,children:[e.changeId,`: `,e.message]},e.changeId))}):null,a&&!r?(0,J.jsxs)(`div`,{className:`text-muted-foreground text-sm`,"data-change-progress":!0,children:[`Loaded `,a.completed,`/`,a.total===`unknown`?`unknown`:a.total,` `,`changes`]}):null,l?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-center gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`break-words`,children:l.message})]}):null,p?(0,J.jsx)(PC,{active:n&&!!e,children:(0,J.jsxs)(`div`,{ref:o,"data-change-list-continuity":!0,className:`border-border divide-border divide-y rounded-lg border`,children:[u?.map(e=>{let t=d.get(e.id),n=t?.artifacts.filter(e=>e.status===`done`).length??0,r=t?.artifacts.length??0,i=fZ({hasStatus:!!t,isPlanningComplete:t?.isPlanningComplete??!1,trackedTaskPhase:e.trackedTaskProgress.phase,trackedArtifactStatus:pZ(t?.artifacts.map(e=>e.status)??[]),cliCompletedTasks:e.cliTaskSummary?.completedTasks??null}),a={family:`changes`,entityId:e.id};return(0,J.jsx)(Rp,{to:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{family:`changes`,entityId:e.id,title:e.name,subtitle:e.id}}),vt:{sharedElements:a},...op(a,`container`),className:`hover:bg-muted/50 block px-4 py-3`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(uZ,{changeId:e.id,name:e.name,phase:i,updatedAt:e.updatedAt,formatTime:vw,progressRatio:e.cliTaskSummary&&e.cliTaskSummary.totalTasks>0?e.cliTaskSummary.completedTasks/e.cliTaskSummary.totalTasks:null,className:`min-w-0 flex-1`,titleProps:{...e.id===e.name?null:{}},subtitle:!l&&t?(0,J.jsxs)(`span`,{title:`Task counts reported by the OpenSpec CLI for this Change.`,children:[n,`/`,r,` artifacts · `,t.schemaName,e.cliTaskSummary?` · Tasks ${e.cliTaskSummary.completedTasks}/${e.cliTaskSummary.totalTasks}`:``]}):!l&&s===void 0&&c?(0,J.jsx)(IC,{className:`w-28`}):`Workflow status unavailable`}),(0,J.jsx)(dZ,{})]})},e.id)}),f&&(0,J.jsxs)(`div`,{className:`text-muted-foreground p-4 text-center`,children:[(0,J.jsx)(`div`,{children:`No active changes.`}),(0,J.jsx)(`div`,{className:`mt-1 text-xs`,children:`Recommended workflow start: Quick Propose`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-propose`),className:`text-primary m-2 inline-flex items-center gap-1 hover:underline`,title:`Open Quick Propose`,children:[(0,J.jsx)(Gm,{className:`h-3.5 w-3.5`}),`Start Propose`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-new`),className:`text-primary m-2 inline-flex items-center gap-1 hover:underline`,title:`Open the advanced /opsx:new form`,children:[(0,J.jsx)(Gm,{className:`h-3.5 w-3.5`}),`Open advanced /opsx:new form`]})]})]})}):null]})}function LUe({applyInstructionProgress:e}){let{complete:t,total:n,remaining:r}=e;return(0,J.jsxs)(cw,{ariaLabel:`Apply instructions progress ${t} of ${n}`,tooltip:`Progress reported by openspec instructions apply — ${t} of ${n} tasks applied, ${r} remaining.`,children:[`Apply `,t,`/`,n]})}function RUe({applyInstructionProgress:e}){let t=e.divergence;return t?(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Task progress source divergence`,className:`flex min-w-0 items-start gap-2 border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100`,children:[(0,J.jsx)(Xm,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:`Upstream task progress divergence`}),(0,J.jsx)(`p`,{children:t.message}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsxs)(cw,{ariaLabel:`Apply instructions progress ${e.complete} of ${e.total}`,tooltip:`Progress reported by openspec instructions apply.`,children:[`Apply `,e.complete,`/`,e.total]}),(0,J.jsxs)(cw,{ariaLabel:`Tracked artifact glob progress ${t.tracked.completed} of ${t.tracked.total}`,tooltip:`Progress computed from the workflow's tracked task artifact glob.`,children:[`Tracked `,t.tracked.completed,`/`,t.tracked.total]})]})]})]}):null}function zUe(e){let t=Nd.safeParse(e);return t.success?{report:t.data,schemaIssues:[]}:{report:null,schemaIssues:t.error.issues.map(e=>`${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`)}}function BUe({issues:e}){return e.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No CLI issue reported.`}):(0,J.jsx)(`ul`,{className:`text-muted-foreground space-y-0.5`,children:e.map((e,t)=>(0,J.jsxs)(`li`,{className:`break-words`,children:[e.level,` · `,e.path,` · `,e.message]},t))})}function mZ({pending:e,label:t,onRun:n}){return(0,J.jsxs)(`button`,{type:`button`,onClick:n,disabled:e,"aria-busy":e||void 0,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:[e?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(Fm,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t]})}function VUe(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),o=uC().context?.cli,s=lge(o?.available?rC(o.version):null);if(B())return(0,J.jsx)(lw,{title:`Archived validation`,summary:`Unavailable in static snapshot`,children:(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Archived-task validation is live CLI evidence and is not captured in this static snapshot.`})});if(o?.available===!0&&!s.archivedValidation)return(0,J.jsx)(lw,{title:`Archived validation`,summary:`Unavailable on this CLI line`,children:(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Archived-task validation requires the OpenSpec 1.9 line`,o.version?` (detected ${o.version.trim()})`:``,`. This session's CLI does not declare the capability, so no command is offered.`]})});let c=async()=>{a(!0),r(null),t(null);try{let e=await q.cli.validate.mutate({kind:`archived`}),n=Gae.safeParse(e);n.success?t({...n.data,data:n.data.data??null,payload:n.data.payload??null}):r(`The archived validation transport returned an unrecognized result shape.`)}catch(e){r(e instanceof Error?e.message:String(e))}finally{a(!1)}};if(!e&&!n)return(0,J.jsx)(lw,{title:`Archived validation`,summary:`OpenSpec 1.9 archived-task validation`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Run the official CLI's archived-task validation and keep its typed report as evidence. OpenSpecUI never repairs or archives from here.`}),(0,J.jsx)(mZ,{pending:i,label:`Validate archived tasks`,onRun:()=>void c()})]})});let l=e?zUe(e.data):{report:null,schemaIssues:[]},u=l.report;if(n||!u){let t=l.schemaIssues.length>0?l.schemaIssues.join(`; `):null;return(0,J.jsx)(lw,{title:`Archived validation`,summary:`CLI failure evidence`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 break-words`,role:`alert`,children:[(0,J.jsx)(Xm,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 break-all`,children:n??e?.contractError??t??e?.stderr.trim()??`The archived validation command failed.`})]}),(0,J.jsx)(mZ,{pending:i,label:`Rerun`,onRun:()=>void c()})]})})}let d=u,f=d.summary.totals.failed;return(0,J.jsx)(lw,{title:`Archived validation`,summary:`${d.summary.totals.passed} passed · ${f} failed`,children:(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Root`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:d.root.path}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Exit`}),(0,J.jsx)(`dd`,{children:e?.exitCode??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Totals`}),(0,J.jsxs)(`dd`,{children:[d.summary.totals.passed,` passed · `,f,` failed ·`,` `,d.summary.totals.items,` archived changes`]})]}),(0,J.jsx)(`div`,{className:`space-y-2`,children:d.items.map(e=>(0,J.jsxs)(`div`,{className:`border-border/60 rounded border p-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.valid?(0,J.jsx)(tm,{className:`h-3.5 w-3.5 shrink-0 text-emerald-600`,"aria-hidden":!0}):(0,J.jsx)(Xm,{className:`h-3.5 w-3.5 shrink-0 text-amber-600`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[11px]`,children:e.id})]}),(0,J.jsx)(`div`,{className:`mt-1`,children:(0,J.jsx)(BUe,{issues:e.issues})})]},e.id))}),(0,J.jsx)(mZ,{pending:i,label:`Rerun`,onRun:()=>void c()})]})})}function HUe(e){return e.reduce((e,t)=>(e.total+=t.status.length,e.errors+=t.status.filter(e=>e.severity===`error`).length,e.warnings+=t.status.filter(e=>e.severity===`warning`).length,e),{errors:0,warnings:0,total:0})}function UUe(e){return e.flatMap(e=>{let t=e.status.filter(e=>e.severity===`error`).length;return t>0?[`${e.store_id} (${t})`]:[]})}function WUe({status:e,referenceEvidence:t,applyInstructionProgress:n,statusRefreshing:r=null,rootChecking:i=null}){let a=e.provenance,o=t.state===`unavailable`?null:t.references,s=o?HUe(o):null,c=e.artifacts.filter(e=>e.status===`done`).length,l=e.artifacts.length;return(0,J.jsxs)(`div`,{"data-change-context-summary":``,"aria-label":`Change context summary`,className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,J.jsxs)(cw,{ariaLabel:`Workflow schema ${e.schemaName}`,tooltip:`OpenSpec workflow schema: ${e.schemaName}`,children:[`Schema: `,e.schemaName]}),(0,J.jsxs)(cw,{ariaLabel:`Artifact progress ${c} of ${l}`,tooltip:`${c} completed of ${l} total artifacts.`,children:[c,`/`,l,` artifacts`]}),n?(0,J.jsx)(LUe,{applyInstructionProgress:n}):null,a.kind===`static`?(0,J.jsx)(cw,{ariaLabel:`Static Change context has no live backend provenance`,tooltip:`CLI Change context is unavailable in this static snapshot.`,children:`Static snapshot`}):(0,J.jsx)(cw,{ariaLabel:`Change Root source ${a.root.source}${a.root.store_id?`, Store ${a.root.store_id}`:``}`,className:`max-w-full truncate`,tooltip:(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Change root: `,a.changeRoot]}),(0,J.jsxs)(`div`,{children:[`Planning home: `,a.planningHome.root]}),(0,J.jsxs)(`div`,{children:[`Root source: `,a.root.source]}),(0,J.jsxs)(`div`,{children:[`Store: `,a.root.store_id??`none`]})]}),children:a.root.store_id?`Store ${a.root.store_id}`:a.root.source}),o&&s?(0,J.jsxs)(cw,{ariaLabel:`${t.state===`retained`?`Retained `:``}${o.length} observed References, ${s.errors} errors, ${s.warnings} warnings`,tooltip:`${t.state===`retained`?`Retained · `:``}${o.length} References · ${s.errors} errors · ${s.warnings} warnings · ${s.total} diagnostics`,tone:s.errors>0?`custom`:`muted`,className:s.errors>0?`border-destructive/40 bg-destructive/10 text-destructive`:void 0,children:[t.state===`retained`?`Retained `:``,`References `,o.length]}):(0,J.jsx)(cw,{ariaLabel:`Reference evidence unavailable`,tooltip:t.state===`unavailable`&&t.reason===`static`?`Reference evidence is not published in this static snapshot.`:`Reference evidence is unavailable until Root Context is observed.`,children:`References unavailable`}),i?(0,J.jsx)(WC,{label:i.label,message:i.message}):null,r?(0,J.jsx)(WC,{label:r.label,message:r.message}):null]})}function GUe({referenceEvidence:e}){let t=e.state===`unavailable`?[]:UUe(e.references);return t.length===0?null:(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Reference errors: `,t.join(`, `)]})]})}function KUe({status:e,referenceEvidence:t}){let n=e.provenance;if(n.kind===`static`){let t=e.artifacts.length;return(0,J.jsx)(`section`,{"data-change-evidence-scroll-owner":``,"aria-label":`Change Evidence`,className:`scrollbar-thin scrollbar-track-transparent flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto overflow-x-hidden overscroll-contain p-4`,children:(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3 p-4 text-xs`,children:[(0,J.jsx)(`div`,{className:`border-border bg-muted/20 text-muted-foreground rounded-md border p-4 text-sm`,children:`CLI Change context and Reference evidence are unavailable in this static snapshot.`}),(0,J.jsx)(lw,{title:`Artifact outputs`,summary:`${t} ${t===1?`output`:`outputs`}`,children:(0,J.jsx)(qUe,{artifacts:e.artifacts})})]})})}let r=Object.keys(n.artifactPaths).length;return(0,J.jsx)(`section`,{"data-change-evidence-scroll-owner":``,"aria-label":`Change Evidence`,className:`scrollbar-thin scrollbar-track-transparent flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto overflow-x-hidden overscroll-contain`,children:(0,J.jsxs)(`div`,{className:`@container min-w-0 space-y-3 p-4 text-xs`,children:[(0,J.jsx)(JUe,{provenance:n}),(0,J.jsx)(lw,{title:`Artifact outputs`,summary:`${r} ${r===1?`output`:`outputs`}`,children:(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,J.jsx)(YUe,{artifactPaths:n.artifactPaths}),(0,J.jsx)(hZ,{label:`Allowed edit roots`,values:n.actionContext.allowedEditRoots}),(0,J.jsx)(hZ,{label:`Planning artifacts`,values:n.actionContext.planningArtifacts}),(0,J.jsx)(hZ,{label:`Linked context`,values:n.actionContext.linkedContext.map(e=>e.name)}),(0,J.jsx)(hZ,{label:`Constraints`,values:n.actionContext.constraints}),(0,J.jsx)(hZ,{label:`Next steps`,values:n.nextSteps})]})}),(0,J.jsx)(lw,{title:`References`,summary:XUe(t),children:(0,J.jsx)(ZUe,{evidence:t})}),(0,J.jsx)(lw,{title:`CLI result`,summary:`${n.evidence.command} · exit ${n.evidence.exitCode??`unknown`}`,children:(0,J.jsx)($Ue,{evidence:n.evidence})})]})})}function qUe({artifacts:e}){return e.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No artifact output currently published.`}):(0,J.jsx)(`dl`,{className:`min-w-0 space-y-3`,children:e.map(e=>(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium`,children:e.id}),(0,J.jsx)(`dd`,{className:`text-muted-foreground min-w-0 break-all font-mono`,children:e.outputPath})]},e.id))})}function JUe({provenance:e}){return(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Change root`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:e.changeRoot}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Planning home`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:e.planningHome.root}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Root source`}),(0,J.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[e.root.source,e.root.store_id?` · ${e.root.store_id}`:``]}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Action context`}),(0,J.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[e.actionContext.mode,` · `,e.actionContext.sourceOfTruth]})]})}function YUe({artifactPaths:e}){return(0,J.jsx)(`dl`,{className:`min-w-0 space-y-3`,children:Object.entries(e).map(([e,t])=>(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium`,children:e}),(0,J.jsxs)(`dd`,{className:`text-muted-foreground min-w-0 break-all font-mono`,children:[t.outputPath,` `,`->`,` `,t.resolvedOutputPath]}),(0,J.jsxs)(`dd`,{className:`text-muted-foreground min-w-0 break-all`,children:[`Existing:`,` `,t.existingOutputPaths.length>0?t.existingOutputPaths.join(`, `):`none observed`]})]},e))})}function XUe(e){return e.state===`unavailable`?`Unavailable`:`${e.references.length} observed · ${e.state}`}function ZUe({evidence:e}){if(e.state===`unavailable`)return(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e.reason===`static`?`Reference evidence is not published in this static snapshot.`:`Reference evidence is unavailable until Root Context is observed.`});let t=e.references;return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-medium`,children:e.state===`retained`?`Retained References`:`Observed References`}),t.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:`No reference currently observed.`}):(0,J.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,J.jsx)(QUe,{reference:e},e.store_id))})]})}function QUe({reference:e}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`min-w-0 break-all font-mono`,children:e.store_id}),e.status.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:`No CLI diagnostic.`}):(0,J.jsx)(`ul`,{className:`text-muted-foreground space-y-0.5`,children:e.status.map(e=>(0,J.jsxs)(`li`,{className:`break-words`,children:[e.severity,` · `,e.code,` · `,e.message]},`${e.severity}:${e.code}:${e.message}`))})]})}function $Ue({evidence:e}){return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Command`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:e.command}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Exit`}),(0,J.jsx)(`dd`,{children:e.exitCode??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Selector`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.selector.store??`none`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Contract`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.contractError??`compatible`})]}),(0,J.jsx)(lw,{title:`Raw CLI payload`,summary:`stdout · stderr · diagnostics`,children:(0,J.jsx)(`pre`,{className:`bg-muted/40 max-h-48 max-w-full overflow-auto whitespace-pre-wrap break-all rounded p-2 font-mono`,children:JSON.stringify({stdout:e.stdout,stderr:e.stderr,diagnostics:e.diagnostics,payload:e.payload},null,2)})})]})}function hZ({label:e,values:t}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:e}),(0,J.jsx)(`div`,{className:`text-muted-foreground min-w-0 break-all`,children:t.length>0?t.join(`, `):`none observed`})]})}function eWe({status:e,selectedArtifactId:t,actionDisabled:n=!1,actionDisabledReason:r,applyInputsAction:i,onComposeAction:a,onArchive:o,onVerify:s}){let c=e.artifacts.find(e=>e.status===`ready`),l=e.artifacts.find(e=>e.id===t),u=XW(e);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[[{id:`continue`,label:`Continue`,icon:Nm,artifactId:t,disabled:!t||!l||[`blocked`,`skipped`].includes(l.status),hint:t?l?l.status===`blocked`?`selected artifact is blocked`:l.status===`skipped`?`selected artifact is intentionally skipped`:void 0:`selected artifact is unavailable`:`select an artifact`},{id:`ff`,label:`Fast-forward`,icon:Im,artifactId:c?.id,disabled:!c,hint:c?void 0:`no ready artifacts`},{id:`apply`,label:`Apply`,icon:em,disabled:!u.available,hint:u.missingArtifactIds.length>0?`missing: ${u.missingArtifactIds.join(`, `)}`:void 0},{id:`update`,label:`Update`,icon:Fm,disabled:!1},{id:`sync`,label:`Sync`,icon:Uce,disabled:!1},{id:`archive`,label:`Archive`,icon:Hp,disabled:!1}].map(e=>{let t=e.icon,s=n?r:e.disabled?e.hint:void 0;return(0,J.jsxs)(Y.Fragment,{children:[(0,J.jsx)(gh,{content:s?`${e.label}: ${s}`:e.label,children:(0,J.jsxs)(`button`,{type:`button`,disabled:n||e.disabled,onClick:()=>e.id===`archive`?o():a(e.id,e.artifactId),"aria-label":e.label,className:`border-border hover:bg-muted inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(t,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`@min-[40rem]:inline hidden`,children:e.label})]})}),e.id===`apply`?i:null]},e.id)}),(0,J.jsx)(gh,{content:n&&r?`Verify: ${r}`:`Verify`,children:(0,J.jsxs)(`button`,{type:`button`,onClick:s,disabled:n,"aria-label":`Verify`,className:`border-border hover:bg-muted inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Um,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`@min-[40rem]:inline hidden`,children:`Verify`})]})})]})}function tWe(){let{changeId:e}=ho({from:`/changes/$changeId`}),t=lp(Lo().state),n=Lse({change:e}),r=n.authority.state===`current`,{rootAction:i,launchApply:a,launchArchive:o}=lZ({applyCurrent:r}),{data:s,isLoading:c,error:l}=n,{data:u}=Vse({change:e}),{data:d}=Jf(e),f=(0,Y.useCallback)((t,n)=>{if(t===`apply`){a({changeId:e,changeName:s?.changeName??e});return}let r=sZ({action:t,changeId:e,artifactId:n});Vp.activatePop(r)},[e,a,s?.changeName]),p=(0,Y.useCallback)(()=>{Vp.activatePop(`/opsx-verify?change=${encodeURIComponent(e)}`)},[e]),m=(0,Y.useCallback)(()=>{o({changeId:e,changeName:s?.changeName??e})},[e,o,s?.changeName]),h=(0,Y.useMemo)(()=>{if(s)return s.artifacts.find(e=>e.status===`ready`)?.id??s.artifacts[0]?.id},[s]),g=l?.message.includes(`Change '${e}' not found`)||l?.message.includes(`Change "${e}" not found`),_=i.status===`blocked`?[i.message,...i.evidence].join(`
1327
+ `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,J.jsx)(iHe,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:Y.cloneElement(e,{ref:u})})}var oHe=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=QW(sHe),d=(0,Y.useId)(),f=(0,Y.useRef)(n),p=(0,Y.useRef)(r);$W(()=>{f.current=n,p.current=r});let m=!0,h=(0,Y.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,Y.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),Y.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,J.jsx)(aHe,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,J.jsx)(eG.Provider,{value:h,children:e})};function sHe(){return new Map}function tX(e=!0){let t=(0,Y.useContext)(eG);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,Y.useId)();(0,Y.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,Y.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var nX=e=>e.key||``;function rX(e){let t=[];return Y.Children.forEach(e,e=>{(0,Y.isValidElement)(e)&&t.push(e)}),t}var iX=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=tX(o),f=(0,Y.useMemo)(()=>rX(e),[e]),p=o&&!u?[]:f.map(nX),m=(0,Y.useRef)(!0),h=(0,Y.useRef)(f),g=QW(()=>new Map),_=(0,Y.useRef)(new Set),[v,y]=(0,Y.useState)(f),[b,x]=(0,Y.useState)(f);$W(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=nX(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=nX(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(rX(e)),y(f),null}let{forceRender:C}=(0,Y.useContext)(ZW);return(0,J.jsx)(J.Fragment,{children:b.map(e=>{let v=nX(e),y=o&&!u?!1:f===b||p.includes(v);return(0,J.jsx)(oHe,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},aX=(0,Y.createContext)({strict:!1}),oX={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},sX=!1;function cHe(){if(sX)return;let e={};for(let t in oX)e[t]={isEnabled:e=>oX[t].some(t=>!!e[t])};DJ(e),sX=!0}function cX(){return cHe(),KBe()}function lHe(e){let t=cX();for(let n in e)t[n]={...t[n],...e[n]};DJ(t)}var uHe=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function lX(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||uHe.has(e)}var dHe=r({default:()=>uX}),uX,fHe=n((()=>{throw uX={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),dX=e=>!lX(e);function pHe(e){typeof e==`function`&&(dX=t=>t.startsWith(`on`)?!lX(t):e(t))}try{pHe((fHe(),t(dHe)).default)}catch{}function mHe(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Oq(e[i])||(dX(i)||n===!0&&lX(i)||!t&&!lX(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var fX=(0,Y.createContext)({});function hHe(e,t){if(xJ(e)){let{initial:t,animate:n}=e;return{initial:t===!1||vJ(t)?t:void 0,animate:vJ(n)?n:void 0}}return e.inherit===!1?{}:t}function gHe(e){let{initial:t,animate:n}=hHe(e,(0,Y.useContext)(fX));return(0,Y.useMemo)(()=>({initial:t,animate:n}),[pX(t),pX(n)])}function pX(e){return Array.isArray(e)?e.join(` `):e}var mX=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hX(e,t,n){for(let r in t)!Oq(t[r])&&!QJ(r,n)&&(e[r]=t[r])}function _He({transformTemplate:e},t){return(0,Y.useMemo)(()=>{let n=mX();return qJ(n,t,e),Object.assign({},n.vars,n.style)},[t])}function vHe(e,t){let n=e.style||{},r={};return hX(r,n,e),Object.assign(r,_He(e,t)),r}function yHe(e,t){let n={},r=vHe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var gX=()=>({...mX(),attrs:{}});function bHe(e,t,n,r){let i=(0,Y.useMemo)(()=>{let n=gX();return eY(n,t,nY(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};hX(t,e.style,e),i.style={...t,...i.style}}return i}var xHe=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function _X(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(xHe.indexOf(e)>-1||/[A-Z]/u.test(e))}function SHe(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??_X(e)?bHe:yHe)(t,r,i,e),c=mHe(t,typeof e==`string`,a),l=e===Y.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,Y.useMemo)(()=>Oq(u)?u.get():u,[u]);return(0,Y.createElement)(e,{...l,children:d})}function CHe({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:wHe(n,r,i,e),renderState:t()}}function wHe(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=FY(a[e]);let{initial:o,animate:s}=e,c=xJ(e),l=SJ(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!_J(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=wq(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var vX=e=>(t,n)=>{let r=(0,Y.useContext)(fX),i=(0,Y.useContext)(eG),a=()=>CHe(e,t,r,i);return n?a():QW(a)},THe=vX({scrapeMotionValuesFromProps:$J,createRenderState:mX}),EHe=vX({scrapeMotionValuesFromProps:rY,createRenderState:gX}),DHe=Symbol.for(`motionComponentSymbol`);function OHe(e,t,n){let r=(0,Y.useRef)(n);(0,Y.useInsertionEffect)(()=>{r.current=n});let i=(0,Y.useRef)(null);return(0,Y.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var yX=(0,Y.createContext)({});function bX(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function kHe(e,t,n,r,i,a){let{visualElement:o}=(0,Y.useContext)(fX),s=(0,Y.useContext)(aX),c=(0,Y.useContext)(eG),l=(0,Y.useContext)($Y),u=l.reducedMotion,d=l.skipAnimations,f=(0,Y.useRef)(null),p=(0,Y.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,Y.useContext)(yX);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&AHe(f.current,n,i,h);let g=(0,Y.useRef)(!1);(0,Y.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[jq],v=(0,Y.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return $W(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,Y.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function AHe(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:xX(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&bX(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function xX(e){if(e)return e.options.allowProjection===!1?xX(e.parent):e.projection}function SX(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&lHe(r);let a=n?n===`svg`:_X(e),o=a?EHe:THe;function s(n,s){let c,l={...(0,Y.useContext)($Y),...n,layoutId:jHe(n)},{isStatic:u}=l,d=gHe(n),f=o(n,u);if(!u&&typeof window<`u`){MHe(l,r);let t=NHe(l);c=t.MeasureLayout,d.visualElement=kHe(e,f,l,i,t.ProjectionNode,a)}return(0,J.jsxs)(fX.Provider,{value:d,children:[c&&d.visualElement?(0,J.jsx)(c,{visualElement:d.visualElement,...l}):null,SHe(e,n,OHe(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,Y.forwardRef)(s);return c[DHe]=e,c}function jHe({layoutId:e}){let t=(0,Y.useContext)(ZW).id;return t&&e!==void 0?t+`-`+e:e}function MHe(e,t){(0,Y.useContext)(aX).strict}function NHe(e){let{drag:t,layout:n}=cX();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function CX(e,t){if(typeof Proxy>`u`)return SX;let n=new Map,r=(n,r)=>SX(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,SX(a,void 0,e,t)),n.get(a))})}CX();var PHe=(e,t)=>t.isSVG??_X(e)?new lVe(t):new rVe(t,{allowProjection:e!==Y.Fragment}),FHe=class extends kJ{constructor(e){super(e),e.animationState||=mVe(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();_J(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},IHe=0,LHe={animation:{Feature:FHe},exit:{Feature:class extends kJ{constructor(){super(...arguments),this.id=IHe++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Tq(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function wX(e){return{point:{x:e.pageX,y:e.pageY}}}var RHe=e=>t=>$q(t)&&e(t,wX(t));function TX(e,t,n,r){return PY(e,t,RHe(n),r)}var EX=({current:e})=>e?e.ownerDocument.defaultView:null,DX=(e,t)=>Math.abs(e-t);function zHe(e,t){let n=DX(e.x,t.x),r=DX(e.y,t.y);return Math.sqrt(n**2+r**2)}var OX=new Set([`auto`,`scroll`]),kX=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=AX(this.lastRawMoveEventInfo,this.transformPagePoint));let e=MX(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=zHe(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=FG;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=AX(t,this.transformPagePoint),NG.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=MX(e.type===`pointercancel`?this.lastMoveEventInfo:AX(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!$q(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=AX(wX(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=FG;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,MX(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=uG(TX(this.contextWindow,`pointermove`,this.handlePointerMove,d),TX(this.contextWindow,`pointerup`,this.handlePointerUp,d),TX(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(OX.has(e.overflowX)||OX.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),NG.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),PG(this.updatePoint)}};function AX(e,t){return t?{point:t(e.point)}:e}function jX(e,t){return{x:e.x-t.x,y:e.y-t.y}}function MX({point:e},t){return{point:e,delta:jX(e,NX(t)),offset:jX(e,BHe(t)),velocity:VHe(t,.1)}}function BHe(e){return e[0]}function NX(e){return e[e.length-1]}function VHe(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=NX(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>pG(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>pG(t)*2&&(r=e[1]);let a=mG(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function HHe(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?mK(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?mK(n,e,r.max):Math.min(e,n)),e}function PX(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function UHe(e,{top:t,left:n,bottom:r,right:i}){return{x:PX(e.x,n,i),y:PX(e.y,t,r)}}function FX(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function WHe(e,t){return{x:FX(e.x,t.x),y:FX(e.y,t.y)}}function GHe(e,t){let n=.5,r=pY(e),i=pY(t);return i>r?n=dG(t.min,t.max-r,e.min):r>i&&(n=dG(e.min,e.max-i,t.min)),rG(0,1,n)}function KHe(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var IX=.35;function qHe(e=IX){return e===!1?e=0:e===!0&&(e=IX),{x:LX(e,`left`,`right`),y:LX(e,`top`,`bottom`)}}function LX(e,t,n){return{min:RX(e,t),max:RX(e,n)}}function RX(e,t){return typeof e==`number`?e:e[t]||0}var JHe=new WeakMap,YHe=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=gJ(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(wX(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=SBe(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kY(e=>{let t=this.getAxisMotionValue(e).get()||0;if(tK.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=pY(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&NG.update(()=>i(e,t),!1,!0),kq(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=ZHe(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&NG.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new kX(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:EX(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&NG.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!BX(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=HHe(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&bX(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=UHe(n.layoutBox,e):this.constraints=!1,this.elastic=qHe(t),r!==this.constraints&&!bX(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&kY(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=KHe(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!bX(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=ZBe(n,r.root,this.visualElement.getTransformPagePoint()),a=WHe(r.layout.layoutBox,i);if(t){let e=t(JBe(a));this.hasMutatedConstraints=!!e,e&&(a=AJ(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=kY(o=>{if(!BX(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return kq(this.visualElement,e),n.start(xq(e,n,0,t,this.visualElement,!1))}stopAnimation(){kY(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){kY(t=>{let{drag:n}=this.getProps();if(!BX(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-mK(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!bX(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};kY(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=GHe({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),kY(t=>{if(!BX(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(mK(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;JHe.set(this.visualElement,this);let e=this.visualElement.current,t=TX(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&OBe(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();bX(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=XHe(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),NG.read(r);let o=PY(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(kY(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=IX,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function zX(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function XHe(e,t,n){let r=dJ(e,zX(n)),i=dJ(t,zX(n));return()=>{r(),i()}}function BX(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function ZHe(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var QHe=class extends kJ{constructor(e){super(e),this.removeGroupControls=lG,this.removeListeners=lG,this.controls=new YHe(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||lG}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},VX=e=>(t,n)=>{e&&NG.update(()=>e(t,n),!1,!0)},$He=class extends kJ{constructor(){super(...arguments),this.removePointerDownListener=lG}onPointerDown(e){this.session=new kX(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:EX(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:VX(e),onStart:VX(t),onMove:VX(n),onEnd:(e,t)=>{delete this.session,r&&NG.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=TX(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},HX=!1,eUe=class extends Y.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),HX&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),IY.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),HX=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||NG.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Jq.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;HX=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function UX(e){let[t,n]=tX(),r=(0,Y.useContext)(ZW);return(0,J.jsx)(eUe,{...e,layoutGroup:r,switchLayoutGroup:(0,Y.useContext)(yX),isPresent:t,safeToRemove:n})}var tUe={pan:{Feature:$He},drag:{Feature:QHe,ProjectionNode:QY,MeasureLayout:UX}};function WX(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&NG.postRender(()=>i(t,wX(t)))}var nUe=class extends kJ{mount(){let{current:e}=this.node;e&&(this.unmount=wBe(e,(e,t)=>(WX(this.node,t,`Start`),e=>WX(this.node,e,`End`))))}unmount(){}},rUe=class extends kJ{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=uG(PY(this.node.current,`focus`,()=>this.onFocus()),PY(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function GX(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&NG.postRender(()=>i(t,wX(t)))}var iUe=class extends kJ{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=ABe(e,(e,t)=>(GX(this.node,t,`Start`),(e,{success:t})=>GX(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},KX=new WeakMap,qX=new WeakMap,aUe=e=>{let t=KX.get(e.target);t&&t(e)},oUe=e=>{e.forEach(aUe)};function sUe({root:e,...t}){let n=e||document;qX.has(n)||qX.set(n,{});let r=qX.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(oUe,{root:e,...t})),r[i]}function cUe(e,t,n){let r=sUe(t);return KX.set(e,n),r.observe(e),()=>{KX.delete(e),r.unobserve(e)}}var lUe={some:0,all:1},uUe=class extends kJ{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:lUe[r]};this.stopObserver=cUe(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(dUe(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function dUe({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var fUe={inView:{Feature:uUe},tap:{Feature:iUe},focus:{Feature:rUe},hover:{Feature:nUe}},pUe={layout:{ProjectionNode:QY,MeasureLayout:UX}},JX=CX({...LHe,...fUe,...tUe,...pUe},PHe),mUe=[.5,2,6];function YX(e){return Number(e.toFixed(4)).toString()}function hUe(e,t,n){let r=n===`bottom`?`to bottom`:`to top`,i=100/t;if(e===t-1)return`linear-gradient(${r}, transparent ${YX(100-i)}%, black 100%)`;let a=e*i,o=(e+1)*i,s=(e+2)*i,c=(e+3)*i;return`linear-gradient(${r}, transparent ${YX(a)}%, black ${YX(o)}%, black ${YX(s)}%, transparent ${YX(c)}%)`}function XX({position:e,blurLevels:t=mUe,surfaceClassName:n,className:r,...i}){return(0,J.jsxs)(`div`,{...i,"aria-hidden":`true`,"data-progressive-blur":e,"data-progressive-blur-levels":t.length,className:fr(`progressive-blur grid`,r),children:[t.map((n,r)=>{let i=hUe(r,t.length,e);return(0,J.jsx)(`div`,{"data-progressive-blur-layer":r,className:`progressive-blur__layer`,style:{zIndex:r+1,backdropFilter:`blur(${n}px)`,WebkitBackdropFilter:`blur(${n}px)`,maskImage:i,WebkitMaskImage:i}},`${n}:${r}`)}),(0,J.jsx)(`div`,{"data-progressive-blur-surface":``,className:fr(`progressive-blur__surface`,n),style:{zIndex:t.length+1}})]})}var ZX=[.5,2,6];function QX({laneId:e,density:t,header:n,children:r,className:i,...a}){return(0,J.jsxs)(`section`,{...a,"data-kanban-lane":e,"data-kanban-lane-density":t,className:fr(`kanban-lane-viewport border-border/70 grid min-h-0 min-w-0 overflow-hidden border-t`,i),children:[(0,J.jsx)(`div`,{"data-kanban-lane-scroll":e,className:`kanban-lane-viewport__scroll scrollbar-thin scrollbar-track-transparent scrollbar-thumb-[color-mix(in_srgb,currentColor,transparent_78%)] min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain pr-1`,children:r}),(0,J.jsx)(XX,{position:`top`,blurLevels:ZX,"data-kanban-lane-veil":`top`,className:`kanban-lane-viewport__veil kanban-lane-viewport__veil--top`,surfaceClassName:`kanban-lane-viewport__veil-surface kanban-lane-viewport__veil-surface--top`}),(0,J.jsx)(`header`,{"data-kanban-lane-header":e,className:`kanban-lane-viewport__header`,children:n}),(0,J.jsx)(XX,{position:`bottom`,blurLevels:ZX,"data-kanban-lane-veil":`bottom`,className:`kanban-lane-viewport__veil kanban-lane-viewport__veil--bottom`,surfaceClassName:`kanban-lane-viewport__veil-surface kanban-lane-viewport__veil-surface--bottom`})]})}var $X=[{id:`no-tasks`,label:`No tracked tasks`,shortLabel:`No tasks`,accentClass:`bg-muted-foreground/55`},{id:`in-progress`,label:`Tasks remaining`,shortLabel:`Remaining`,accentClass:`bg-primary`},{id:`complete`,label:`Tasks complete`,shortLabel:`Complete`,accentClass:`bg-emerald-500`},{id:`archived`,label:`Archived`,shortLabel:`Archived`,accentClass:`bg-accent`}];function eZ(e){let t={"no-tasks":[],"in-progress":[],complete:[]};for(let n of e)t[n.trackedTaskProgress.phase].push(n);return t}function gUe(e){let t=eZ(e);return{"no-tasks":t[`no-tasks`].length,"in-progress":t[`in-progress`].length,complete:t.complete.length}}function _Ue(e,t,n=Date.now()){return e.filter(e=>Nre(e,t,n)).sort((e,t)=>bs(t)-bs(e)||e.id.localeCompare(t.id))}function tZ(e){return e.archivedAt??bs(e)}var nZ=`application/x-openspecui-change-id`,vUe=[{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}];function yUe({activeItems:e,archivedItems:t,statuses:n,range:r,onRangeChange:i,activeState:a,archiveState:o,rootReady:s,rootBlockedReason:c,applyStatusCurrent:l,applyStatusError:u,onApply:d,onArchive:f}){let[p,m]=(0,Y.useState)(!1),h=(0,Y.useMemo)(()=>eZ(e),[e]),g=(0,Y.useMemo)(()=>new Map(e.map(e=>[e.id,e])),[e]),_=(0,Y.useMemo)(()=>new Map(n.map(e=>[e.changeName,e])),[n]),v=s&&a.current,y=v&&o.current,b=e=>{if(e.preventDefault(),m(!1),!y)return;let t=e.dataTransfer.getData(nZ);if(!t)return;let n=g.get(t);n&&f(n)};return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:(0,J.jsx)(SUe,{activeError:a.error,archiveError:o.error,applyStatusError:u,rowErrors:a.rowErrors,progress:a.progress})}),(0,J.jsx)(`div`,{"data-kanban-grid":!0,className:`scrollbar-thin scrollbar-track-transparent scrollbar-thumb-[color-mix(in_srgb,currentColor,transparent_78%)] grid min-h-0 min-w-0 flex-1 auto-cols-[minmax(16rem,1fr)] grid-flow-col gap-3 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2`,children:$X.map(e=>{let n=e.id===`archived`,s=e.id===`archived`?[]:h[e.id],u=n?t:[],g=n?u.length:s.length,x=n?o.initialLoading:a.initialLoading,S=n?o.updating:a.updating;return(0,J.jsx)(QX,{laneId:e.id,density:`full`,"data-lane":e.id,onDragOver:n?e=>{!y||!e.dataTransfer.types.includes(nZ)||(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m(!0))}:void 0,onDragLeave:n?e=>{e.currentTarget.contains(e.relatedTarget)||m(!1)}:void 0,onDrop:n?b:void 0,className:fr(`transition-colors`,n&&p&&`border-primary bg-primary/5`),header:(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 items-center justify-between gap-2 px-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:fr(`h-2 w-2 shrink-0 rounded-full`,e.accentClass)}),(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:e.label}),(0,J.jsx)(vh,{count:g,tone:`muted`,size:`xs`,shape:`pill`})]}),n?(0,J.jsx)(YW,{value:r,options:vUe,onValueChange:i,ariaLabel:`Archived time range`,className:`pointer-events-auto h-7 min-w-0 gap-1 px-2 text-xs`}):null]}),children:(0,J.jsx)(PC,{active:S&&g>0,children:(0,J.jsxs)(JX.div,{layout:!0,className:`min-h-24 space-y-2`,children:[x&&g===0?(0,J.jsx)(zC,{count:2}):null,(0,J.jsxs)(iX,{initial:!1,mode:`popLayout`,children:[u.map(e=>(0,J.jsx)(JX.div,{layout:!0,layoutId:`live-kanban:${e.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,scale:.98},children:(0,J.jsx)(xUe,{item:e})},`archived:${e.id}`)),s.map(e=>(0,J.jsx)(JX.div,{layout:!0,layoutId:`live-kanban:${e.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,scale:.98},children:(0,J.jsx)(bUe,{item:e,status:_.get(e.id),canApply:v&&l,canArchive:v,canDragArchive:y,applyBlockedReason:c??(l?null:`Apply availability is not current.`),archiveBlockedReason:c,onApply:d,onArchive:f})},`active:${e.id}`))]}),!x&&g===0?(0,J.jsx)(`div`,{className:`border-border/60 text-muted-foreground flex h-20 items-center justify-center rounded-md border border-dashed`,children:e.id===`no-tasks`?(0,J.jsx)(lm,{className:`h-4 w-4`,"aria-label":`No entries`}):(0,J.jsx)(Dm,{className:`h-4 w-4`,"aria-label":`No entries`})}):null]})})},e.id)})})]})}function bUe({item:e,status:t,canApply:n,canArchive:r,canDragArchive:i,applyBlockedReason:a,archiveBlockedReason:o,onApply:s,onArchive:c}){let l=XW(t),u=e.trackedTaskProgress,d=u.total>0?Math.round(u.completed/u.total*100):0,f={family:`changes`,entityId:e.id},p=!n||!l.available;return(0,J.jsxs)(`article`,{draggable:i,onDragStart:i?t=>{t.dataTransfer.setData(nZ,e.id),t.dataTransfer.effectAllowed=`move`}:void 0,className:fr(`border-border/70 bg-card min-w-0 rounded-md border p-2.5`,i&&`cursor-grab active:cursor-grabbing`),children:[(0,J.jsxs)(Rp,{to:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{...f,title:e.name,subtitle:e.id}}),vt:{sharedElements:f},...op(f,`container`),draggable:!1,className:`block min-w-0`,children:[(0,J.jsx)(`div`,{...op(f,`title`),className:`truncate text-sm font-medium`,children:e.name}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:e.updatedAt>0?vw(e.updatedAt):e.id}),(0,J.jsx)(`div`,{className:`bg-muted mt-2 h-1.5 rounded-full`,children:(0,J.jsx)(JX.div,{className:`bg-primary h-full rounded-full`,initial:!1,animate:{width:`${d}%`}})})]}),(0,J.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground font-mono text-[11px]`,children:[u.completed,`/`,u.total]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>s(e),"aria-label":`Apply ${e.name}`,title:a??(l.missingArtifactIds.length>0?`Missing: ${l.missingArtifactIds.join(`, `)}`:`Apply`),className:`hover:bg-muted inline-flex h-7 w-7 items-center justify-center rounded-md disabled:cursor-not-allowed disabled:opacity-40`,children:(0,J.jsx)(Nm,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>c(e),"aria-label":`Archive ${e.name}`,title:o??`Archive`,className:`hover:bg-muted inline-flex h-7 w-7 items-center justify-center rounded-md disabled:cursor-not-allowed disabled:opacity-40`,children:(0,J.jsx)(Hp,{className:`h-3.5 w-3.5`})})]})]})]})}function xUe({item:e}){let t={family:`archive`,entityId:e.id};return(0,J.jsx)(Rp,{to:`/archive/$changeId`,params:{changeId:e.id},state:n=>({...n,__vtHandoff:{...t,title:e.name,subtitle:e.id}}),vt:{sharedElements:t},...op(t,`container`),className:`border-border/70 bg-card hover:bg-muted/50 block min-w-0 rounded-md border p-2.5`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,J.jsx)(Hp,{className:`text-muted-foreground mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{...op(t,`title`),className:`truncate text-sm font-medium`,children:e.name}),(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:yw(tZ(e))})]})]})})}function SUe({activeError:e,archiveError:t,applyStatusError:n,rowErrors:r,progress:i}){let a=[e?`Changes: ${e.message}`:null,t?`Archives: ${t.message}`:null,n?`Apply status: ${n.message}`:null,...r.map(e=>`${e.changeId}: ${e.message}`)].filter(e=>e!==null);return(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsxs)(`div`,{className:`text-muted-foreground font-mono text-xs`,"aria-live":`polite`,children:[i.completed,`/`,i.total]}):null,a.length>0?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`div`,{className:`min-w-0 space-y-1`,children:a.map(e=>(0,J.jsx)(`div`,{className:`break-words`,children:e},e))})]}):null]})}function rZ({activeItems:e,archivedItems:t,activeCounts:n,archivedCount:r,variant:i=`full`,pending:a=!1,className:o}){let s=eZ(e),c=i===`compact`;return(0,J.jsx)(`div`,{"data-testid":`readonly-kanban`,"aria-busy":a,className:fr(`@container min-w-0 max-w-full overflow-x-clip`,c&&`@[32rem]:h-[32rem] @[64rem]:h-72 h-[46rem]`,o),children:(0,J.jsx)(`div`,{"data-testid":`readonly-kanban-grid`,className:fr(`@[32rem]:grid-cols-2 @[64rem]:grid-cols-4 grid w-full min-w-0 max-w-full grid-cols-1 gap-3 overflow-x-clip`,c&&`@[32rem]:grid-rows-2 @[64rem]:grid-rows-1 h-full min-h-0 grid-rows-4`),children:$X.map(e=>{let i=e.id===`archived`?t:s[e.id],o=e.id===`archived`?r:n[e.id];return(0,J.jsx)(QX,{laneId:e.id,density:c?`compact`:`full`,header:(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 items-center justify-between gap-2 px-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:fr(`h-2 w-2 shrink-0 rounded-full`,e.accentClass)}),(0,J.jsx)(`h3`,{className:`truncate text-xs font-semibold`,children:c?e.shortLabel:e.label})]}),a?(0,J.jsx)(FC,{className:`h-5 w-8 rounded-full`}):(0,J.jsx)(vh,{count:o,tone:`muted`,size:`xs`,shape:`pill`})]}),children:a?(0,J.jsx)(`div`,{className:`space-y-2`,"aria-hidden":`true`,children:Array.from({length:3},(e,t)=>(0,J.jsxs)(`div`,{className:`border-border/70 bg-card space-y-2 rounded-md border px-2.5 py-2`,children:[(0,J.jsx)(FC,{className:`h-3 w-3/4`}),(0,J.jsx)(FC,{className:`h-2.5 w-1/2`})]},t))}):(0,J.jsxs)(JX.div,{layout:!0,className:`space-y-2`,"data-lane":e.id,children:[(0,J.jsx)(iX,{initial:!1,mode:`popLayout`,children:i.map(t=>(0,J.jsx)(JX.div,{layout:!0,layoutId:`readonly-kanban:${t.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,scale:.98},transition:{duration:.16},children:(0,J.jsx)(CUe,{item:t,laneId:e.id,compact:c})},`${e.id}:${t.id}`))}),i.length===0&&o===0?(0,J.jsx)(`div`,{className:`border-border/60 text-muted-foreground flex h-16 items-center justify-center rounded-md border border-dashed`,children:e.id===`no-tasks`?(0,J.jsx)(lm,{className:`h-4 w-4`,"aria-label":`No entries`}):(0,J.jsx)(Dm,{className:`h-4 w-4`,"aria-label":`No entries`})}):null]})},e.id)})})})}function CUe({item:e,laneId:t,compact:n}){let r=t===`archived`,i={family:r?`archive`:`changes`,entityId:e.id},a=e.cliTaskSummary,o=a?{completed:a.completedTasks,total:a.totalTasks}:null,s=o&&o.total>0?Math.min(100,Math.max(0,o.completed/o.total*100)):0;return(0,J.jsxs)(Rp,{to:r?`/archive/$changeId`:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{...i,title:e.name,subtitle:e.id}}),vt:{sharedElements:i},...op(i,`container`),className:`border-border/70 bg-card hover:bg-muted/50 block min-w-0 rounded-md border px-2.5 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[r?(0,J.jsx)(Hp,{className:`text-muted-foreground mt-0.5 h-3.5 w-3.5 shrink-0`}):null,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{...op(i,`title`),className:`truncate text-xs font-medium`,children:e.name}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-[11px]`,children:r?yw(tZ(e)):e.updatedAt>0?vw(e.updatedAt):e.id})]}),!r&&o?(0,J.jsxs)(`span`,{className:`text-muted-foreground shrink-0 font-mono text-[10px]`,children:[o.completed,`/`,o.total]}):null]}),!r&&!n&&o?(0,J.jsx)(`div`,{className:`bg-muted mt-2 h-1 rounded-full`,children:(0,J.jsx)(JX.div,{className:`bg-primary h-full rounded-full`,initial:!1,animate:{width:`${s}%`}})}):null]})}var iZ=`action`,aZ=`change`,oZ=`artifact`,wUe=new Set([`continue`,`ff`,`apply`,`update`,`sync`,`archive`]);function TUe(e){return wUe.has(e)}function sZ(e){let t=new URLSearchParams;return t.set(iZ,e.action),t.set(aZ,e.changeId),e.artifactId&&t.set(oZ,e.artifactId),`/opsx-compose?${t.toString()}`}function EUe(e){let t=new URLSearchParams(e),n=t.get(iZ),r=t.get(aZ)?.trim()??``,i=t.get(oZ)?.trim()||void 0;return!n||!TUe(n)||r.length===0?null:{action:n,changeId:r,artifactId:i}}function cZ(e){switch(e.action){case`continue`:return`Continue artifact ${e.artifactId??`<missing-artifact>`} for change ${e.changeId}.`;case`ff`:return`Fast-forward artifact ${e.artifactId??`<missing-artifact>`} for change ${e.changeId}.`;case`apply`:return`Apply change ${e.changeId} based on current completed artifacts.`;case`update`:return`Update the existing planning artifacts for change ${e.changeId}.`;case`sync`:return`Sync specs for change ${e.changeId}.`;case`archive`:return`Archive change ${e.changeId} after verifying completion and risks.`}}function lZ({applyCurrent:e=!0,archiveCurrent:t=!0}={}){let n=uC(),r=(0,Y.useRef)({rootAction:n,applyCurrent:e,archiveCurrent:t});r.current={rootAction:n,applyCurrent:e,archiveCurrent:t};let{openArchiveModal:i}=TC(),a=(0,Y.useCallback)(e=>{let t=r.current;return t.rootAction.status!==`ready`||!t.applyCurrent?!1:(Vp.activatePop(sZ({action:`apply`,changeId:e.changeId})),!0)},[]),o=(0,Y.useCallback)(e=>{let t=r.current;return t.rootAction.status!==`ready`||!t.archiveCurrent?!1:(i(e.changeId,e.changeName),!0)},[i]);return{rootAction:n,disabled:n.disabled,launchApply:a,launchArchive:o}}var DUe=[{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}];function OUe(){let e=B(),t=qf(),n=Yf(),r=ep(!e),[i,a]=(0,Y.useState)(`30d`),o=t.data??[],s=(0,Y.useMemo)(()=>_Ue(n.data??[],i),[n.data,i]),c=t.data!==void 0&&!t.isLoading&&!t.isUpdating&&t.error===null,l=n.data!==void 0&&!n.isLoading&&!n.isUpdating&&n.error===null,u=r.data!==void 0&&r.authority.state===`current`,{rootAction:d,launchApply:f,launchArchive:p}=lZ({applyCurrent:c&&u,archiveCurrent:c}),m=(0,J.jsxs)(`div`,{className:`flex min-w-0 shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Km,{className:`h-6 w-6 shrink-0`}),`Kanban`]}),e?(0,J.jsx)(YW,{value:i,options:DUe,onValueChange:a,ariaLabel:`Archived time range`,className:`h-8`}):null]});if(e){let e=t.error??n.error,r=t.isLoading&&t.data===void 0||n.isLoading&&n.data===void 0;return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-4 p-4`,children:[m,e?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:e.message})]}):null,r?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,J.jsx)(zC,{count:2},t))}):(0,J.jsx)(rZ,{activeItems:o,archivedItems:s,activeCounts:gUe(o),archivedCount:s.length})]})}return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-4 overflow-hidden p-4`,children:[m,(0,J.jsx)(yUe,{activeItems:o,archivedItems:s,statuses:r.data??[],range:i,onRangeChange:a,activeState:{initialLoading:t.isLoading&&t.data===void 0,updating:t.isUpdating,current:c,error:t.error,rowErrors:t.rowErrors,progress:t.progress},archiveState:{initialLoading:n.isLoading&&n.data===void 0,updating:n.isUpdating,current:l,error:n.error},rootReady:d.status===`ready`,rootBlockedReason:d.message,applyStatusCurrent:u,applyStatusError:r.error,onApply:e=>f({changeId:e.id,changeName:e.name}),onArchive:e=>p({changeId:e.id,changeName:e.name})})]})}function kUe({ratio:e}){if(!Number.isFinite(e)||e<=0)return null;let t=Math.min(100,Math.max(0,e*100));return(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`bg-primary/50 pointer-events-none absolute inset-y-0 left-0`,style:{width:`${t}%`}})}function uZ({changeId:e,name:t,subtitle:n,phase:r,updatedAt:i,formatTime:a,sharedFamily:o=`changes`,className:s=``,progressRatio:c=null,containerProps:l,titleProps:u,iconProps:d}){let f={family:o,entityId:e};return(0,J.jsxs)(`div`,{...l,...op(f,`container`),className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-stretch gap-x-3 ${s}`,children:[(0,J.jsx)(`div`,{className:`flex items-center`,children:(0,J.jsx)(ym,{...d,...op(f,`icon`),className:`text-muted-foreground h-5 w-5 shrink-0`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.5 py-0.5`,children:[(0,J.jsx)(`div`,{...u,...op(f,`title`),className:`truncate font-medium`,children:t}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:n})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-end justify-between gap-1 text-right`,children:[(0,J.jsx)(`div`,{className:`flex flex-1 items-center`,children:(0,J.jsxs)(_h,{tone:`custom`,size:`sm`,shape:`box`,className:`relative overflow-hidden border ${r.toneClass}`,children:[(0,J.jsx)(kUe,{ratio:c??NaN}),(0,J.jsx)(`span`,{className:`relative`,children:r.label})]})}),i>0?(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:a(i)}):null]})]})}function dZ(){return(0,J.jsx)(Qp,{className:`text-muted-foreground h-4 w-4 shrink-0`,"aria-hidden":!0})}function fZ(e){return e.hasStatus&&e.trackedArtifactStatus===`blocked`?{label:`Draft`,toneClass:`border-amber-500/40 text-amber-700 dark:text-amber-300`}:typeof e.cliCompletedTasks==`number`&&e.cliCompletedTasks>0?{label:`Applying`,toneClass:`border-primary/40 text-primary`}:e.hasStatus?e.isPlanningComplete?{label:`Planning Complete`,toneClass:`border-sky-500/40 text-sky-700 dark:text-sky-300`}:{label:`Planning`,toneClass:`border-border text-muted-foreground`}:{label:`Unknown`,toneClass:`border-border text-muted-foreground`}}function pZ(e){return e.includes(`blocked`)?`blocked`:e.includes(`ready`)?`ready`:e.includes(`done`)?`done`:e.includes(`skipped`)?`skipped`:null}function AUe(e,t){return e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id)}function jUe(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function MUe(e,t){return!!(t&&!jUe()&&typeof e.startViewTransition==`function`&&!e.activeViewTransition)}function NUe(e){if(typeof document>`u`){e.update();return}let t=e.container,n=document;if(!MUe(n,t)){e.update();return}t.style.viewTransitionName=e.transitionName;try{n.startViewTransition(()=>(0,Kr.flushSync)(e.update)).finished.catch(()=>{}).finally(()=>{t.style.viewTransitionName===e.transitionName&&(t.style.viewTransitionName=``)})}catch{t.style.viewTransitionName=``,e.update()}}function PUe(e,t){let[n,r]=(0,Y.useState)(e),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(e),o=(0,Y.useRef)(0),s=`vt-change-list-${(0,Y.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`;return(0,Y.useEffect)(()=>{if(!i.current){i.current=!0,a.current=e,r(e);return}let n=a.current;a.current=e;let c=o.current+1;if(o.current=c,e===void 0||n===void 0||AUe(n,e)){r(e);return}queueMicrotask(()=>{o.current===c&&NUe({container:t.current,transitionName:s,update:()=>{o.current===c&&r(e)}})})},[t,e,s]),n}function FUe(e){return new Map((e??[]).map(e=>[e.changeName,e]))}function IUe(){let{data:e,isLoading:t,isUpdating:n,error:r,rowErrors:i=[],progress:a=null}=qf(),o=(0,Y.useRef)(null),{data:s,isLoading:c,error:l}=ep((e?.length??0)>0),u=PUe(e,o),d=FUe(s),f=e?.length===0&&!r&&!n,p=(e?.length??0)>0||f;return t&&!e&&!r?(0,J.jsxs)(`div`,{className:`space-y-6 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(ym,{className:`h-6 w-6 shrink-0`}),`Changes`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-new`),className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium hover:opacity-90`,title:`Create a new OPSX change`,children:[(0,J.jsx)(Pm,{className:`h-4 w-4`}),`New`]})]}),a&&!r?(0,J.jsx)(Oge,{progress:a,className:`max-w-sm`}):null,(0,J.jsx)(zC,{count:5})]}):(0,J.jsxs)(`div`,{className:`space-y-6 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(ym,{className:`h-6 w-6 shrink-0`}),`Changes`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-new`),className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium hover:opacity-90`,title:`Create a new OPSX change`,children:[(0,J.jsx)(Pm,{className:`h-4 w-4`}),`New`]})]}),(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Active OPSX changes in the current writable Planning root. Completed changes are moved to`,` `,(0,J.jsx)(Rp,{to:`/archive`,className:`text-primary hover:underline`,children:`Archive`}),`.`]}),r?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-center gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`break-words`,children:r.message})]}):null,i.length>0?(0,J.jsx)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive rounded-md border px-3 py-2 text-sm`,children:i.map(e=>(0,J.jsxs)(`div`,{className:`break-words`,children:[e.changeId,`: `,e.message]},e.changeId))}):null,a&&!r?(0,J.jsxs)(`div`,{className:`text-muted-foreground text-sm`,"data-change-progress":!0,children:[`Loaded `,a.completed,`/`,a.total===`unknown`?`unknown`:a.total,` `,`changes`]}):null,l?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-center gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`break-words`,children:l.message})]}):null,p?(0,J.jsx)(PC,{active:n&&!!e,children:(0,J.jsxs)(`div`,{ref:o,"data-change-list-continuity":!0,className:`border-border divide-border divide-y rounded-lg border`,children:[u?.map(e=>{let t=d.get(e.id),n=t?.artifacts.filter(e=>e.status===`done`).length??0,r=t?.artifacts.length??0,i=fZ({hasStatus:!!t,isPlanningComplete:t?.isPlanningComplete??!1,trackedArtifactStatus:pZ(t?.artifacts.map(e=>e.status)??[]),cliCompletedTasks:e.cliTaskSummary?.completedTasks??null}),a=e.cliTaskSummary,o=a&&a.totalTasks>0?a.completedTasks/a.totalTasks:null,u=a?(0,J.jsxs)(`span`,{title:`Task counts reported by the OpenSpec CLI for this Change.`,children:[`Tasks `,a.completedTasks,`/`,a.totalTasks]}):null,f={family:`changes`,entityId:e.id};return(0,J.jsx)(Rp,{to:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{family:`changes`,entityId:e.id,title:e.name,subtitle:e.id}}),vt:{sharedElements:f},...op(f,`container`),className:`hover:bg-muted/50 block px-4 py-3`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(uZ,{changeId:e.id,name:e.name,phase:i,updatedAt:e.updatedAt,formatTime:vw,progressRatio:o,className:`min-w-0 flex-1`,titleProps:{...e.id===e.name?null:{}},subtitle:!l&&t?(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`span`,{children:[n,`/`,r,` artifacts · `,t.schemaName]}),u?(0,J.jsxs)(J.Fragment,{children:[` · `,u]}):null]}):!l&&s===void 0&&c?u?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[u,(0,J.jsx)(IC,{className:`w-12`})]}):(0,J.jsx)(IC,{className:`w-28`}):u??`Workflow status unavailable`}),(0,J.jsx)(dZ,{})]})},e.id)}),f&&(0,J.jsxs)(`div`,{className:`text-muted-foreground p-4 text-center`,children:[(0,J.jsx)(`div`,{children:`No active changes.`}),(0,J.jsx)(`div`,{className:`mt-1 text-xs`,children:`Recommended workflow start: Quick Propose`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-propose`),className:`text-primary m-2 inline-flex items-center gap-1 hover:underline`,title:`Open Quick Propose`,children:[(0,J.jsx)(Gm,{className:`h-3.5 w-3.5`}),`Start Propose`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Vp.activatePop(`/opsx-new`),className:`text-primary m-2 inline-flex items-center gap-1 hover:underline`,title:`Open the advanced /opsx:new form`,children:[(0,J.jsx)(Gm,{className:`h-3.5 w-3.5`}),`Open advanced /opsx:new form`]})]})]})}):null]})}function LUe({applyInstructionProgress:e}){let{complete:t,total:n,remaining:r}=e;return(0,J.jsxs)(cw,{ariaLabel:`Apply instructions progress ${t} of ${n}`,tooltip:`Progress reported by openspec instructions apply — ${t} of ${n} tasks applied, ${r} remaining.`,children:[`Apply `,t,`/`,n]})}function RUe({applyInstructionProgress:e}){let t=e.divergence;return t?(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Task progress source divergence`,className:`flex min-w-0 items-start gap-2 border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100`,children:[(0,J.jsx)(Xm,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:`Upstream task progress divergence`}),(0,J.jsx)(`p`,{children:t.message}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsxs)(cw,{ariaLabel:`Apply instructions progress ${e.complete} of ${e.total}`,tooltip:`Progress reported by openspec instructions apply.`,children:[`Apply `,e.complete,`/`,e.total]}),(0,J.jsxs)(cw,{ariaLabel:`Tracked artifact glob progress ${t.tracked.completed} of ${t.tracked.total}`,tooltip:`Progress computed from the workflow's tracked task artifact glob.`,children:[`Tracked `,t.tracked.completed,`/`,t.tracked.total]})]})]})]}):null}function zUe(e){let t=Nd.safeParse(e);return t.success?{report:t.data,schemaIssues:[]}:{report:null,schemaIssues:t.error.issues.map(e=>`${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`)}}function BUe({issues:e}){return e.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No CLI issue reported.`}):(0,J.jsx)(`ul`,{className:`text-muted-foreground space-y-0.5`,children:e.map((e,t)=>(0,J.jsxs)(`li`,{className:`break-words`,children:[e.level,` · `,e.path,` · `,e.message]},t))})}function mZ({pending:e,label:t,onRun:n}){return(0,J.jsxs)(`button`,{type:`button`,onClick:n,disabled:e,"aria-busy":e||void 0,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:[e?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(Fm,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t]})}function VUe(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),o=uC().context?.cli,s=lge(o?.available?rC(o.version):null);if(B())return(0,J.jsx)(lw,{title:`Archived validation`,summary:`Unavailable in static snapshot`,children:(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Archived-task validation is live CLI evidence and is not captured in this static snapshot.`})});if(o?.available===!0&&!s.archivedValidation)return(0,J.jsx)(lw,{title:`Archived validation`,summary:`Unavailable on this CLI line`,children:(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Archived-task validation requires the OpenSpec 1.9 line`,o.version?` (detected ${o.version.trim()})`:``,`. This session's CLI does not declare the capability, so no command is offered.`]})});let c=async()=>{a(!0),r(null),t(null);try{let e=await q.cli.validate.mutate({kind:`archived`}),n=Gae.safeParse(e);n.success?t({...n.data,data:n.data.data??null,payload:n.data.payload??null}):r(`The archived validation transport returned an unrecognized result shape.`)}catch(e){r(e instanceof Error?e.message:String(e))}finally{a(!1)}};if(!e&&!n)return(0,J.jsx)(lw,{title:`Archived validation`,summary:`OpenSpec 1.9 archived-task validation`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Run the official CLI's archived-task validation and keep its typed report as evidence. OpenSpecUI never repairs or archives from here.`}),(0,J.jsx)(mZ,{pending:i,label:`Validate archived tasks`,onRun:()=>void c()})]})});let l=e?zUe(e.data):{report:null,schemaIssues:[]},u=l.report;if(n||!u){let t=l.schemaIssues.length>0?l.schemaIssues.join(`; `):null;return(0,J.jsx)(lw,{title:`Archived validation`,summary:`CLI failure evidence`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 break-words`,role:`alert`,children:[(0,J.jsx)(Xm,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 break-all`,children:n??e?.contractError??t??e?.stderr.trim()??`The archived validation command failed.`})]}),(0,J.jsx)(mZ,{pending:i,label:`Rerun`,onRun:()=>void c()})]})})}let d=u,f=d.summary.totals.failed;return(0,J.jsx)(lw,{title:`Archived validation`,summary:`${d.summary.totals.passed} passed · ${f} failed`,children:(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Root`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:d.root.path}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Exit`}),(0,J.jsx)(`dd`,{children:e?.exitCode??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Totals`}),(0,J.jsxs)(`dd`,{children:[d.summary.totals.passed,` passed · `,f,` failed ·`,` `,d.summary.totals.items,` archived changes`]})]}),(0,J.jsx)(`div`,{className:`space-y-2`,children:d.items.map(e=>(0,J.jsxs)(`div`,{className:`border-border/60 rounded border p-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.valid?(0,J.jsx)(tm,{className:`h-3.5 w-3.5 shrink-0 text-emerald-600`,"aria-hidden":!0}):(0,J.jsx)(Xm,{className:`h-3.5 w-3.5 shrink-0 text-amber-600`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[11px]`,children:e.id})]}),(0,J.jsx)(`div`,{className:`mt-1`,children:(0,J.jsx)(BUe,{issues:e.issues})})]},e.id))}),(0,J.jsx)(mZ,{pending:i,label:`Rerun`,onRun:()=>void c()})]})})}function HUe(e){return e.reduce((e,t)=>(e.total+=t.status.length,e.errors+=t.status.filter(e=>e.severity===`error`).length,e.warnings+=t.status.filter(e=>e.severity===`warning`).length,e),{errors:0,warnings:0,total:0})}function UUe(e){return e.flatMap(e=>{let t=e.status.filter(e=>e.severity===`error`).length;return t>0?[`${e.store_id} (${t})`]:[]})}function WUe({status:e,referenceEvidence:t,applyInstructionProgress:n,statusRefreshing:r=null,rootChecking:i=null}){let a=e.provenance,o=t.state===`unavailable`?null:t.references,s=o?HUe(o):null,c=e.artifacts.filter(e=>e.status===`done`).length,l=e.artifacts.length;return(0,J.jsxs)(`div`,{"data-change-context-summary":``,"aria-label":`Change context summary`,className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,J.jsxs)(cw,{ariaLabel:`Workflow schema ${e.schemaName}`,tooltip:`OpenSpec workflow schema: ${e.schemaName}`,children:[`Schema: `,e.schemaName]}),(0,J.jsxs)(cw,{ariaLabel:`Artifact progress ${c} of ${l}`,tooltip:`${c} completed of ${l} total artifacts.`,children:[c,`/`,l,` artifacts`]}),n?(0,J.jsx)(LUe,{applyInstructionProgress:n}):null,a.kind===`static`?(0,J.jsx)(cw,{ariaLabel:`Static Change context has no live backend provenance`,tooltip:`CLI Change context is unavailable in this static snapshot.`,children:`Static snapshot`}):(0,J.jsx)(cw,{ariaLabel:`Change Root source ${a.root.source}${a.root.store_id?`, Store ${a.root.store_id}`:``}`,className:`max-w-full truncate`,tooltip:(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Change root: `,a.changeRoot]}),(0,J.jsxs)(`div`,{children:[`Planning home: `,a.planningHome.root]}),(0,J.jsxs)(`div`,{children:[`Root source: `,a.root.source]}),(0,J.jsxs)(`div`,{children:[`Store: `,a.root.store_id??`none`]})]}),children:a.root.store_id?`Store ${a.root.store_id}`:a.root.source}),o&&s?(0,J.jsxs)(cw,{ariaLabel:`${t.state===`retained`?`Retained `:``}${o.length} observed References, ${s.errors} errors, ${s.warnings} warnings`,tooltip:`${t.state===`retained`?`Retained · `:``}${o.length} References · ${s.errors} errors · ${s.warnings} warnings · ${s.total} diagnostics`,tone:s.errors>0?`custom`:`muted`,className:s.errors>0?`border-destructive/40 bg-destructive/10 text-destructive`:void 0,children:[t.state===`retained`?`Retained `:``,`References `,o.length]}):(0,J.jsx)(cw,{ariaLabel:`Reference evidence unavailable`,tooltip:t.state===`unavailable`&&t.reason===`static`?`Reference evidence is not published in this static snapshot.`:`Reference evidence is unavailable until Root Context is observed.`,children:`References unavailable`}),i?(0,J.jsx)(WC,{label:i.label,message:i.message}):null,r?(0,J.jsx)(WC,{label:r.label,message:r.message}):null]})}function GUe({referenceEvidence:e}){let t=e.state===`unavailable`?[]:UUe(e.references);return t.length===0?null:(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Reference errors: `,t.join(`, `)]})]})}function KUe({status:e,referenceEvidence:t}){let n=e.provenance;if(n.kind===`static`){let t=e.artifacts.length;return(0,J.jsx)(`section`,{"data-change-evidence-scroll-owner":``,"aria-label":`Change Evidence`,className:`scrollbar-thin scrollbar-track-transparent flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto overflow-x-hidden overscroll-contain p-4`,children:(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3 p-4 text-xs`,children:[(0,J.jsx)(`div`,{className:`border-border bg-muted/20 text-muted-foreground rounded-md border p-4 text-sm`,children:`CLI Change context and Reference evidence are unavailable in this static snapshot.`}),(0,J.jsx)(lw,{title:`Artifact outputs`,summary:`${t} ${t===1?`output`:`outputs`}`,children:(0,J.jsx)(qUe,{artifacts:e.artifacts})})]})})}let r=Object.keys(n.artifactPaths).length;return(0,J.jsx)(`section`,{"data-change-evidence-scroll-owner":``,"aria-label":`Change Evidence`,className:`scrollbar-thin scrollbar-track-transparent flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto overflow-x-hidden overscroll-contain`,children:(0,J.jsxs)(`div`,{className:`@container min-w-0 space-y-3 p-4 text-xs`,children:[(0,J.jsx)(JUe,{provenance:n}),(0,J.jsx)(lw,{title:`Artifact outputs`,summary:`${r} ${r===1?`output`:`outputs`}`,children:(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,J.jsx)(YUe,{artifactPaths:n.artifactPaths}),(0,J.jsx)(hZ,{label:`Allowed edit roots`,values:n.actionContext.allowedEditRoots}),(0,J.jsx)(hZ,{label:`Planning artifacts`,values:n.actionContext.planningArtifacts}),(0,J.jsx)(hZ,{label:`Linked context`,values:n.actionContext.linkedContext.map(e=>e.name)}),(0,J.jsx)(hZ,{label:`Constraints`,values:n.actionContext.constraints}),(0,J.jsx)(hZ,{label:`Next steps`,values:n.nextSteps})]})}),(0,J.jsx)(lw,{title:`References`,summary:XUe(t),children:(0,J.jsx)(ZUe,{evidence:t})}),(0,J.jsx)(lw,{title:`CLI result`,summary:`${n.evidence.command} · exit ${n.evidence.exitCode??`unknown`}`,children:(0,J.jsx)($Ue,{evidence:n.evidence})})]})})}function qUe({artifacts:e}){return e.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No artifact output currently published.`}):(0,J.jsx)(`dl`,{className:`min-w-0 space-y-3`,children:e.map(e=>(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium`,children:e.id}),(0,J.jsx)(`dd`,{className:`text-muted-foreground min-w-0 break-all font-mono`,children:e.outputPath})]},e.id))})}function JUe({provenance:e}){return(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Change root`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:e.changeRoot}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Planning home`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:e.planningHome.root}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Root source`}),(0,J.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[e.root.source,e.root.store_id?` · ${e.root.store_id}`:``]}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Action context`}),(0,J.jsxs)(`dd`,{className:`min-w-0 break-words`,children:[e.actionContext.mode,` · `,e.actionContext.sourceOfTruth]})]})}function YUe({artifactPaths:e}){return(0,J.jsx)(`dl`,{className:`min-w-0 space-y-3`,children:Object.entries(e).map(([e,t])=>(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium`,children:e}),(0,J.jsxs)(`dd`,{className:`text-muted-foreground min-w-0 break-all font-mono`,children:[t.outputPath,` `,`->`,` `,t.resolvedOutputPath]}),(0,J.jsxs)(`dd`,{className:`text-muted-foreground min-w-0 break-all`,children:[`Existing:`,` `,t.existingOutputPaths.length>0?t.existingOutputPaths.join(`, `):`none observed`]})]},e))})}function XUe(e){return e.state===`unavailable`?`Unavailable`:`${e.references.length} observed · ${e.state}`}function ZUe({evidence:e}){if(e.state===`unavailable`)return(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e.reason===`static`?`Reference evidence is not published in this static snapshot.`:`Reference evidence is unavailable until Root Context is observed.`});let t=e.references;return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-medium`,children:e.state===`retained`?`Retained References`:`Observed References`}),t.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:`No reference currently observed.`}):(0,J.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,J.jsx)(QUe,{reference:e},e.store_id))})]})}function QUe({reference:e}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`min-w-0 break-all font-mono`,children:e.store_id}),e.status.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:`No CLI diagnostic.`}):(0,J.jsx)(`ul`,{className:`text-muted-foreground space-y-0.5`,children:e.status.map(e=>(0,J.jsxs)(`li`,{className:`break-words`,children:[e.severity,` · `,e.code,` · `,e.message]},`${e.severity}:${e.code}:${e.message}`))})]})}function $Ue({evidence:e}){return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Command`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:e.command}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Exit`}),(0,J.jsx)(`dd`,{children:e.exitCode??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Selector`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.selector.store??`none`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Contract`}),(0,J.jsx)(`dd`,{className:`min-w-0 break-words`,children:e.contractError??`compatible`})]}),(0,J.jsx)(lw,{title:`Raw CLI payload`,summary:`stdout · stderr · diagnostics`,children:(0,J.jsx)(`pre`,{className:`bg-muted/40 max-h-48 max-w-full overflow-auto whitespace-pre-wrap break-all rounded p-2 font-mono`,children:JSON.stringify({stdout:e.stdout,stderr:e.stderr,diagnostics:e.diagnostics,payload:e.payload},null,2)})})]})}function hZ({label:e,values:t}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:e}),(0,J.jsx)(`div`,{className:`text-muted-foreground min-w-0 break-all`,children:t.length>0?t.join(`, `):`none observed`})]})}function eWe({status:e,selectedArtifactId:t,actionDisabled:n=!1,actionDisabledReason:r,applyInputsAction:i,onComposeAction:a,onArchive:o,onVerify:s}){let c=e.artifacts.find(e=>e.status===`ready`),l=e.artifacts.find(e=>e.id===t),u=XW(e);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[[{id:`continue`,label:`Continue`,icon:Nm,artifactId:t,disabled:!t||!l||[`blocked`,`skipped`].includes(l.status),hint:t?l?l.status===`blocked`?`selected artifact is blocked`:l.status===`skipped`?`selected artifact is intentionally skipped`:void 0:`selected artifact is unavailable`:`select an artifact`},{id:`ff`,label:`Fast-forward`,icon:Im,artifactId:c?.id,disabled:!c,hint:c?void 0:`no ready artifacts`},{id:`apply`,label:`Apply`,icon:em,disabled:!u.available,hint:u.missingArtifactIds.length>0?`missing: ${u.missingArtifactIds.join(`, `)}`:void 0},{id:`update`,label:`Update`,icon:Fm,disabled:!1},{id:`sync`,label:`Sync`,icon:Uce,disabled:!1},{id:`archive`,label:`Archive`,icon:Hp,disabled:!1}].map(e=>{let t=e.icon,s=n?r:e.disabled?e.hint:void 0;return(0,J.jsxs)(Y.Fragment,{children:[(0,J.jsx)(gh,{content:s?`${e.label}: ${s}`:e.label,children:(0,J.jsxs)(`button`,{type:`button`,disabled:n||e.disabled,onClick:()=>e.id===`archive`?o():a(e.id,e.artifactId),"aria-label":e.label,className:`border-border hover:bg-muted inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(t,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`@min-[40rem]:inline hidden`,children:e.label})]})}),e.id===`apply`?i:null]},e.id)}),(0,J.jsx)(gh,{content:n&&r?`Verify: ${r}`:`Verify`,children:(0,J.jsxs)(`button`,{type:`button`,onClick:s,disabled:n,"aria-label":`Verify`,className:`border-border hover:bg-muted inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Um,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`@min-[40rem]:inline hidden`,children:`Verify`})]})})]})}function tWe(){let{changeId:e}=ho({from:`/changes/$changeId`}),t=lp(Lo().state),n=Lse({change:e}),r=n.authority.state===`current`,{rootAction:i,launchApply:a,launchArchive:o}=lZ({applyCurrent:r}),{data:s,isLoading:c,error:l}=n,{data:u}=Vse({change:e}),{data:d}=Jf(e),f=(0,Y.useCallback)((t,n)=>{if(t===`apply`){a({changeId:e,changeName:s?.changeName??e});return}let r=sZ({action:t,changeId:e,artifactId:n});Vp.activatePop(r)},[e,a,s?.changeName]),p=(0,Y.useCallback)(()=>{Vp.activatePop(`/opsx-verify?change=${encodeURIComponent(e)}`)},[e]),m=(0,Y.useCallback)(()=>{o({changeId:e,changeName:s?.changeName??e})},[e,o,s?.changeName]),h=(0,Y.useMemo)(()=>{if(s)return s.artifacts.find(e=>e.status===`ready`)?.id??s.artifacts[0]?.id},[s]),g=l?.message.includes(`Change '${e}' not found`)||l?.message.includes(`Change "${e}" not found`),_=i.status===`blocked`?[i.message,...i.evidence].join(`
1328
1328
  `):void 0,v=i.disabled||!r,y=r?void 0:`Change status is refreshing; actions remain read-only.`,b=i.message??y,x=(0,Y.useMemo)(()=>s?.provenance.kind===`static`?{state:`unavailable`,reason:`static`}:i.context?{state:i.status===`ready`?`current`:`retained`,references:i.context.references}:{state:`unavailable`,reason:`root-context`},[i.context,i.status,s?.provenance.kind]),S=(0,Y.useMemo)(()=>s?[{id:`evidence`,label:`Evidence`,icon:(0,J.jsx)(Lce,{className:`h-4 w-4`}),content:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(KUe,{status:s,referenceEvidence:x}),(0,J.jsx)(VUe,{})]})}]:[],[x,s]),C=x.state!==`unavailable`&&x.references.some(e=>e.status.some(e=>e.severity===`error`)),w=!!l||i.status===`blocked`||C||!!u?.applyInstructionProgress.divergence;return(0,J.jsx)(nW,{entityId:e,sharedFamily:`changes`,backTo:`/changes`,backTitle:`Back to Changes`,icon:ym,title:s?.changeName,subtitle:s?(0,J.jsx)(WUe,{status:s,referenceEvidence:x,applyInstructionProgress:u?.applyInstructionProgress??null,statusRefreshing:r?null:{label:`Status refreshing`,message:y??``},rootChecking:i.status===`checking`?{label:i.title,message:i.message}:null}):void 0,headerActions:s?(0,J.jsx)(eWe,{status:s,selectedArtifactId:h,actionDisabled:v,actionDisabledReason:b,applyInputsAction:(0,J.jsx)(Ege,{title:`Apply inputs`,context:u?.context,operationGuidance:u?.operationGuidance}),onComposeAction:f,onArchive:m,onVerify:p}):void 0,handoff:t,isLoading:(c||i.status===`checking`)&&!s,loadingMessage:`Loading change status...`,errorMessage:_&&!s?_:l&&!g&&!s?`Error loading change: ${l.message}`:void 0,notFoundMessage:!i.disabled&&g&&!s?`Change not found in the current project.`:!i.disabled&&!s&&!c&&!l?`Change not found.`:void 0,notFoundBackLabel:`Back to Changes`,artifacts:s?.artifacts,contentFallback:d?{id:`content`,label:`Content`,outputPath:`openspec/changes/**/*.md`,relativePath:`changes/${e}`,files:d,emptyMessage:`No Markdown files found. Open the folder view to inspect change files.`}:void 0,folder:{changeId:e},tabsQueryKey:`artifact`,initialTab:h,supplementaryTabs:S,statusRegion:s&&w?(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[l?(0,J.jsx)(`div`,{role:`alert`,"aria-live":`assertive`,className:`border-destructive/40 bg-destructive/10 text-destructive rounded-md border p-3 text-sm`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,J.jsx)($p,{className:`h-4 w-4`,"aria-hidden":!0}),`Error loading change: `,l.message]})}):null,(0,J.jsx)(dw,{state:i}),(0,J.jsx)(GUe,{referenceEvidence:x}),u?(0,J.jsx)(RUe,{applyInstructionProgress:u.applyInstructionProgress}):null]}):null})}var gZ=[{id:`overview`,label:`Overview`,href:`/config`,icon:(0,J.jsx)(Tm,{className:`h-4 w-4`,"aria-hidden":!0})},{id:`project`,label:`Project Binding`,href:`/config/project`,icon:(0,J.jsx)(Em,{className:`h-4 w-4`,"aria-hidden":!0}),liveOnly:!0},{id:`root`,label:`Active Root`,href:`/config/root`,icon:(0,J.jsx)(um,{className:`h-4 w-4`,"aria-hidden":!0})},{id:`environment`,label:`Environment`,href:`/config/environment`,icon:(0,J.jsx)(Bm,{className:`h-4 w-4`,"aria-hidden":!0}),liveOnly:!0},{id:`agents`,label:`Agents`,href:`/config/agents`,icon:(0,J.jsx)(Jp,{className:`h-4 w-4`,"aria-hidden":!0}),liveOnly:!0},{id:`schemas`,label:`Schemas`,href:`/config/schemas`,icon:(0,J.jsx)(Yp,{className:`h-4 w-4`,"aria-hidden":!0})},{id:`context`,label:`Context`,href:`/config/context`,icon:(0,J.jsx)(Qm,{className:`h-4 w-4`,"aria-hidden":!0})}];function _Z({children:e,current:t,header:n}){let r=B(),i=r?gZ.filter(e=>e.liveOnly!==!0):gZ;return(0,J.jsxs)(`div`,{"data-testid":`config-workbench`,"data-config-section":t,className:`@container/config flex min-h-full w-full min-w-0 flex-col overflow-x-clip`,children:[(0,J.jsx)(`nav`,{"aria-label":`Config sections`,"data-config-workbench-navbar":!0,className:`bg-background/95 border-border divide-border/20 sticky top-0 z-20 grid min-w-0 shrink-0 gap-0 divide-x border-b p-0 backdrop-blur ${r?`grid-cols-4`:`grid-cols-7`}`,children:i.map(e=>{let n=t===e.id;return(0,J.jsx)(gh,{content:e.label,children:(0,J.jsxs)(Rp,{to:e.href,"aria-label":e.label,"aria-current":n?`page`:void 0,className:`focus-visible:ring-primary @[64rem]:gap-2 flex min-h-10 min-w-0 items-center justify-center gap-0 px-2 text-xs font-bold outline-none transition-colors focus-visible:ring-2 ${n?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`}`,children:[e.icon,(0,J.jsx)(`span`,{"data-testid":`config-nav-label-${e.id}`,className:`config-workbench-nav-label min-w-0 truncate`,"aria-hidden":!0,children:e.label})]})},e.id)})}),(0,J.jsxs)(`div`,{className:`vt-detail-content min-w-0`,children:[(0,J.jsx)(`div`,{className:`shrink-0 px-4 pt-4`,children:n}),(0,J.jsx)(`div`,{className:`min-w-0 p-4`,children:e})]})]})}function vZ({backHref:e,backLabel:t=`Config`,description:n,icon:r,title:i,trailing:a}){return(0,J.jsxs)(`header`,{className:`space-y-3`,children:[e?(0,J.jsxs)(Rp,{to:e,"aria-label":`Back to ${t}`,className:`text-muted-foreground hover:text-foreground focus-visible:ring-primary inline-flex min-h-8 items-center gap-1.5 rounded-md px-1 text-xs outline-none focus-visible:ring-2`,children:[(0,J.jsx)(Up,{className:`h-4 w-4`,"aria-hidden":!0}),t]}):null,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex min-w-0 items-center gap-2 text-2xl font-bold`,children:[r,(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:i})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 max-w-3xl text-sm`,children:n})]}),a?(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:a}):null]})]})}var nWe={ready:{label:`Ready`,tooltip:`The current Root Context can authorize root-dependent operations.`,className:`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`},refreshing:{label:`Refreshing`,tooltip:`Retained facts remain readable while root-dependent operations stay locked.`,className:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`},resolving:{label:`Resolving`,tooltip:`OpenSpec is resolving the effective Root Context.`,className:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`},blocked:{label:`Blocked`,tooltip:`The current observation cannot authorize root-dependent operations.`,className:`border-destructive/40 bg-destructive/10 text-destructive`},static:{label:`Static snapshot`,tooltip:`Published facts are read-only and carry no live mutation authority.`}};function rWe(){return(0,J.jsxs)(Rp,{to:`/config/context`,"aria-label":`Open Resolved Context`,className:`border-border hover:bg-muted focus-visible:ring-primary inline-flex h-9 shrink-0 items-center gap-2 rounded-md border px-3 text-xs font-medium outline-none focus-visible:ring-2`,children:[(0,J.jsx)(Qm,{className:`h-4 w-4`,"aria-hidden":!0}),`Context`]})}function yZ({status:e,trailing:t}){let n=nWe[e];return(0,J.jsxs)(`header`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsxs)(Rp,{to:`/config`,className:`text-muted-foreground hover:text-foreground focus-visible:ring-primary inline-flex min-h-8 items-center gap-1.5 rounded-md px-1 text-xs outline-none focus-visible:ring-2`,children:[(0,J.jsx)(Up,{className:`h-4 w-4`,"aria-hidden":!0}),`Config`]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t,(0,J.jsx)(cw,{ariaLabel:`Resolved Context status ${n.label.toLowerCase()}`,tooltip:n.tooltip,tone:n.className?`custom`:`muted`,className:n.className,children:n.label})]})]}),(0,J.jsxs)(`h1`,{className:`font-nav flex min-w-0 items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Qm,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0}),`Resolved Context`]})]})}function bZ(e){return e instanceof Error?e:Error(String(e))}function xZ(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(!1),l=(0,Y.useRef)(null),u=(0,Y.useCallback)(e=>{c.current&&(t(e),r(l.current),a(!1))},[]);return(0,Y.useEffect)(()=>{c.current=!0;let e=!1;l.current=null;let n=q.agentIntegrations.subscribe.subscribe(void 0,{onData(t){e=!0,l.current=null,u(t)},onError(e){c.current&&(l.current=bZ(e),r(l.current),a(!1))}});return q.agentIntegrations.get.query().then(n=>{!c.current||e||(t(n),r(l.current),a(!1))}).catch(t=>{!c.current||e||(r(bZ(t)),a(!1))}),()=>{c.current=!1,n.unsubscribe()}},[u]),{data:e,error:n,isLoading:i,isRefreshing:o,refresh:(0,Y.useCallback)(async()=>{s(!0);try{let e=await q.agentIntegrations.refresh.query();return u(e),e}catch(e){let t=bZ(e);throw c.current&&r(t),t}finally{c.current&&s(!1)}},[u]),accept:u}}var SZ=50*1024,CZ=S().min(1),wZ=p(CZ),TZ=_(CZ,wZ),EZ=m({guidance:wZ}).strict(),iWe=m({apply:EZ.optional(),archive:EZ.optional()}).strict();function aWe(e){return new TextEncoder().encode(e).byteLength<=SZ}var DZ=S().refine(aWe,`Context must not exceed ${SZ} UTF-8 bytes.`);m({schema:CZ.nullable(),context:DZ.nullable(),rules:TZ.nullable(),operations:iWe.nullable()}).strict();var oWe=m({schema:CZ,context:DZ.nullable(),rules:TZ.nullable(),operations:m({apply:EZ.nullable(),archive:EZ.nullable()}).strict().nullable()}).strict(),sWe=S().regex(/^sha256:[a-f0-9]{64}$/),OZ={ownerPath:S().min(1),filePath:S().min(1),revision:sWe};P(`mode`,[m({...OZ,mode:v(`structured`),update:oWe}).strict(),m({...OZ,mode:v(`raw`),content:S()}).strict()]);var kZ={schema:null,context:null,rules:null,operations:null};function AZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cWe(e){return new TextEncoder().encode(e).byteLength}function lWe(e){let t=Fu(e);return t.errors.length===0?[]:[{code:`config-unparseable`,severity:`error`,path:`$`,message:t.errors.map(e=>e.message).join(`
1329
1329
  `)}]}function uWe(e,t){if(e===void 0)return null;if(!AZ(e))return t.push({code:`rules-invalid`,severity:`error`,path:`rules`,message:`The rules field must be a mapping of artifact ids to string arrays.`}),null;let n={};for(let[r,i]of Object.entries(e)){if(!Array.isArray(i)||i.some(e=>typeof e!=`string`)){t.push({code:`rules-entry-invalid`,severity:`error`,path:`rules.${r}`,message:`Rules for '${r}' must be an array of strings.`});continue}let e=i.filter(e=>e.length>0);e.length<i.length&&t.push({code:`rules-entry-empty`,severity:`warning`,path:`rules.${r}`,message:`Empty rules for '${r}' are ignored by OpenSpec.`}),e.length>0&&(n[r]=e)}return Object.keys(n).length>0?n:null}function dWe(e,t){if(e===void 0)return null;if(!AZ(e))return t.push({code:`operations-invalid`,severity:`error`,path:`operations`,message:`The operations field must be a mapping.`}),null;let n={};for(let r of[`apply`,`archive`]){let i=e[r];if(i===void 0)continue;if(!AZ(i)){t.push({code:`operation-invalid`,severity:`error`,path:`operations.${r}`,message:`Operation '${r}' must be a mapping.`});continue}if(i.guidance===void 0)continue;if(!Array.isArray(i.guidance)||i.guidance.some(e=>typeof e!=`string`)){t.push({code:`operation-guidance-invalid`,severity:`error`,path:`operations.${r}.guidance`,message:`Guidance for '${r}' must be an array of strings.`});continue}let a=i.guidance.filter(e=>e.length>0);a.length<i.guidance.length&&t.push({code:`operation-guidance-empty`,severity:`warning`,path:`operations.${r}.guidance`,message:`Empty '${r}' guidance entries are ignored by OpenSpec.`}),a.length>0&&(n[r]={guidance:a})}return Object.keys(n).length>0?n:null}function fWe(e){if(e===null||e.trim().length===0)return{official:{...kZ},diagnostics:[{code:`schema-missing`,severity:`error`,path:`schema`,message:`The active OpenSpec config does not declare a schema.`}]};let t=Fu(e);if(t.errors.length>0)return{official:{...kZ},diagnostics:lWe(e)};let n=t.toJS();if(!AZ(n))return{official:{...kZ},diagnostics:[{code:`config-not-mapping`,severity:`error`,path:`$`,message:`OpenSpec config must be a YAML mapping for Structured mode.`}]};let r=[],i=null;n.schema===void 0?r.push({code:`schema-missing`,severity:`error`,path:`schema`,message:`The active OpenSpec config does not declare a schema.`}):typeof n.schema!=`string`||n.schema.length===0?r.push({code:`schema-invalid`,severity:`error`,path:`schema`,message:`The schema field must be a non-empty string.`}):i=n.schema;let a=null;return n.context!==void 0&&(typeof n.context==`string`?cWe(n.context)>51200?r.push({code:`context-too-large`,severity:`error`,path:`context`,message:`The context field exceeds ${SZ} UTF-8 bytes.`}):a=n.context:r.push({code:`context-invalid`,severity:`error`,path:`context`,message:`The context field must be a string.`})),{official:{schema:i,context:a,rules:uWe(n.rules,r),operations:dWe(n.operations,r)},diagnostics:r}}function jZ(e){return{content:e.file.content,exists:e.file.exists,filePath:e.file.path,owner:e.owner,revision:e.revision,official:e.official,diagnostics:e.diagnostics}}function MZ(){return Gf((0,Y.useCallback)(e=>q.planningConfig.subscribeProjectBinding.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),async()=>null,[],`planningConfig.subscribeProjectBinding`)}function NZ(){return Kf((0,Y.useCallback)(e=>q.planningConfig.subscribeActiveRoot.subscribe(void 0,{onData:t=>{if(t.type===`recompute-started`){e.onEvent(t);return}e.onEvent({type:`data`,data:jZ(t.data)})},onError:e.onError}),[]),async()=>{let e=await Xoe(),t=fWe(e);return{content:e,exists:e!==null,filePath:null,owner:null,revision:null,...t}},[],`planningConfig.subscribeActiveRootView`)}function PZ(){let e=(0,Y.useMemo)(()=>({read:()=>q.planningConfig.readEnvironmentGlobalProjection.query(),refresh:()=>q.planningConfig.refreshEnvironmentGlobalProjection.query(),parseState:e=>kse.parse(e),subscribe(e){return q.planningConfig.subscribeEnvironmentGlobalProjection.subscribe(void 0,{onData(t){let n=ie.safeParse(t);if(!n.success){e.onError(Error(`Malformed Environment Global notice: ${n.error.message}`));return}e.onNotice()},onError:e.onError,onConnectionStateChange(t){if(t.error){e.onError(t.error);return}(t.state===`connecting`||t.state===`pending`)&&e.onConnectionState(t.state)},onStopped:e.onStopped,onComplete:e.onComplete})}}),[]),t=(0,Y.useMemo)(()=>({read:()=>q.planningConfig.readEnvironmentGlobalFileProjection.query(),refresh:()=>q.planningConfig.refreshEnvironmentGlobalFileProjection.query(),parseState:e=>Ose.parse(e),subscribe(e){return q.planningConfig.subscribeEnvironmentGlobalFileProjection.subscribe(void 0,{onData(t){let n=ie.safeParse(t);if(!n.success){e.onError(Error(`Malformed Environment Global file notice: ${n.error.message}`));return}e.onNotice()},onError:e.onError,onConnectionStateChange(t){if(t.error){e.onError(t.error);return}(t.state===`connecting`||t.state===`pending`)&&e.onConnectionState(t.state)},onStopped:e.onStopped,onComplete:e.onComplete})}}),[]),n=Bf({source:e,sourceKey:`environment-global-cli`,selectData:e=>e,staticLoader:async()=>null,cacheKey:`planningConfig.environmentGlobalCliProjection`}),r=Bf({source:t,sourceKey:`environment-global-file`,selectData:e=>e,staticLoader:async()=>null,cacheKey:`planningConfig.environmentGlobalFileProjection`}),i=n.data!==void 0&&n.data!==null&&r.data!==void 0&&r.data!==null?{...n.data,kind:`environment-global`,file:r.data.file}:void 0,a=n.error??r.error;return{data:i,isLoading:n.isLoading||r.isLoading,isUpdating:n.isUpdating||r.isUpdating,refreshPending:n.refreshPending||r.refreshPending,error:a,authority:n.authority.state===`failed`?n.authority:r.authority.state===`failed`?r.authority:n.authority.state===`current`&&r.authority.state===`current`?{state:`current`}:{state:`waiting`,reason:`pending`},refresh:async()=>{await n.refresh()}}}var pWe={ready:`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`,attention:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`,blocked:`border-destructive/40 bg-destructive/10 text-destructive`,loading:`border-border bg-muted text-muted-foreground`,static:`border-border bg-muted text-muted-foreground`};function mWe(){let e=pC(),t=SC(),n=B();return(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex min-w-0 items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Wm,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0}),`Config`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 max-w-3xl text-sm`,children:`Configure declarations by owner, then verify the CLI-selected result through Resolved Context.`})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e?.projection&&!e.projection.initialized?(0,J.jsxs)(`button`,{type:`button`,onClick:e.open,className:`border-border bg-background text-foreground hover:bg-muted inline-flex h-9 items-center gap-2 rounded-md border px-3 text-xs font-medium`,children:[(0,J.jsx)(fle,{className:`h-4 w-4`,"aria-hidden":!0}),`Init`]}):null,n?null:(0,J.jsxs)(`button`,{id:`config-guide-overview-action`,"data-config-guide-overview":`true`,type:`button`,disabled:!t?.canStart,onClick:t?.active?t.restart:t?.start,title:t?.canStart?`Guide Project Binding, Active Root, Agent Delivery, and Resolved Context.`:`Initialize the local OpenSpec project before starting the Guide.`,className:`border-border bg-background text-foreground hover:bg-muted inline-flex h-9 items-center gap-2 rounded-md border px-3 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-60`,children:[(0,J.jsx)(Mce,{className:`h-4 w-4`,"aria-hidden":!0}),t?.active?`Restart Guide`:`Guide`]}),(0,J.jsx)(rWe,{})]})]})}function hWe({model:e}){let t=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e.icon}),(0,J.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold`,children:e.title})]}),(0,J.jsx)(`span`,{className:`shrink-0 rounded border px-2 py-0.5 text-[10px] font-medium ${pWe[e.status]}`,children:e.statusLabel})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.description}),(0,J.jsx)(`p`,{className:`text-sm`,children:e.summary}),e.error?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive flex items-start gap-1.5 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e.error})]}):null]}),n=`border-border bg-card flex min-h-40 min-w-0 flex-col gap-3 rounded-lg border p-4`;return e.href?(0,J.jsx)(Rp,{to:e.href,"aria-label":e.title,className:`${n} hover:border-primary/40 hover:bg-muted/30 focus-visible:ring-primary outline-none focus-visible:ring-2`,children:t}):(0,J.jsx)(`section`,{"aria-label":e.title,className:n,children:t})}function FZ({models:e}){return(0,J.jsx)(`div`,{className:`@[42rem]:grid-cols-2 @[72rem]:grid-cols-3 grid min-w-0 gap-3`,children:e.map(e=>(0,J.jsx)(hWe,{model:e},e.id))})}function gWe(){let e=MZ(),t=NZ(),n=PZ(),r=xZ(),i=$f(),a=uC(),o=r.data?.states.reduce((e,t)=>e+(t.issues.length>0?1:0),0)??0,s=e.data?.binding.references.entries.length??0,c=i.data?.schemas.length??0;return(0,J.jsx)(FZ,{models:[{id:`project`,title:`Project Binding`,description:`Launch-project Store and read-only Reference declarations.`,href:`/config/project`,icon:(0,J.jsx)(Em,{className:`h-4 w-4`,"aria-hidden":!0}),status:e.error?`blocked`:e.isLoading&&!e.data?`loading`:`ready`,statusLabel:e.error?`Blocked`:e.isLoading&&!e.data?`Loading`:`Observed`,summary:e.data?`${e.data.binding.store.state} Store · ${s} References`:`Waiting for launch-project declarations.`,error:e.error?.message},{id:`root`,title:`Active Root`,description:`Physical config selected by the current Planning Root.`,href:`/config/root`,icon:(0,J.jsx)(um,{className:`h-4 w-4`,"aria-hidden":!0}),status:t.error?`blocked`:t.isLoading&&!t.data?`loading`:t.data?.exists?`ready`:`attention`,statusLabel:t.error?`Blocked`:t.isLoading&&!t.data?`Loading`:t.data?.exists?`Available`:`Missing`,summary:t.data?.exists?t.data.filePath||`Published config document`:`No config file exists in the selected Root.`,error:t.error?.message},{id:`environment`,title:`Environment`,description:`Machine defaultStore, feature flags, and global source evidence.`,href:`/config/environment`,icon:(0,J.jsx)(Bm,{className:`h-4 w-4`,"aria-hidden":!0}),status:n.error?`blocked`:n.isLoading&&!n.data?`loading`:n.authority.state===`current`?`ready`:`attention`,statusLabel:n.error?`Blocked`:n.isLoading&&!n.data?`Loading`:n.authority.state===`current`?`Current`:`Refreshing`,summary:n.data?n.data.configPath??`Global config path is unavailable.`:`Waiting for the CLI-owned environment projection.`,error:n.error?.message},{id:`agents`,title:`Agent Delivery`,description:`Official delivery policy, physical inventory, migration, and repair.`,href:`/config/agents`,icon:(0,J.jsx)(Jp,{className:`h-4 w-4`,"aria-hidden":!0}),status:r.error?`blocked`:r.isLoading&&!r.data?`loading`:o>0?`attention`:`ready`,statusLabel:r.error?`Blocked`:r.isLoading&&!r.data?`Loading`:o>0?`Attention`:`Current`,summary:r.data?`${r.data.registry.length} Agents · ${o} with issues`:`Waiting for the Server-owned Agent projection.`,error:r.error?.message},{id:`schemas`,title:`Schemas`,description:`Resolved workflow Schema catalog and physical detail workspaces.`,href:`/config/schemas`,icon:(0,J.jsx)(Yp,{className:`h-4 w-4`,"aria-hidden":!0}),status:i.error?`blocked`:i.isLoading&&!i.data?`loading`:c>0?`ready`:`attention`,statusLabel:i.error?`Blocked`:i.isLoading&&!i.data?`Loading`:c>0?`Available`:`Empty`,summary:i.data?`${c} resolved Schemas`:`Waiting for the Schema catalog.`,error:i.error?.message},{id:`context`,title:`Resolved Context`,description:`Effective Root, Store, References, and current action authority.`,href:`/config/context`,icon:(0,J.jsx)(Qm,{className:`h-4 w-4`,"aria-hidden":!0}),status:a.status===`ready`?`ready`:a.status===`blocked`?`blocked`:`loading`,statusLabel:a.status===`ready`?`Ready`:a.status===`blocked`?`Blocked`:`Resolving`,summary:a.context?.planningRoot?.path??(a.status===`ready`?`Root Context is current.`:`Waiting for CLI-selected Root Context.`),error:a.status===`blocked`?a.message:void 0}]})}function _We(){let e=NZ(),t=$f(),n=t.data?.schemas.length??0;return(0,J.jsx)(FZ,{models:[{id:`project`,title:`Project Binding`,description:`Launch-project declarations are intentionally excluded from publication.`,icon:(0,J.jsx)(Em,{className:`h-4 w-4`,"aria-hidden":!0}),status:`static`,statusLabel:`Not published`,summary:`Open this project live to inspect or edit Project Binding.`},{id:`root`,title:`Active Root`,description:`Read-only configuration content included in this snapshot.`,href:`/config/root`,icon:(0,J.jsx)(um,{className:`h-4 w-4`,"aria-hidden":!0}),status:e.error?`blocked`:e.isLoading&&!e.data?`loading`:`static`,statusLabel:e.error?`Blocked`:e.isLoading&&!e.data?`Loading`:`Snapshot`,summary:e.data?.exists?`Published config document is available.`:`No config document published.`,error:e.error?.message},{id:`environment`,title:`Environment`,description:`Machine paths and global configuration are private runtime facts.`,icon:(0,J.jsx)(Bm,{className:`h-4 w-4`,"aria-hidden":!0}),status:`static`,statusLabel:`Not published`,summary:`Static output carries no Environment mutation or machine-path authority.`},{id:`agents`,title:`Agent Delivery`,description:`Agent inventory and mutation authority remain live-only.`,icon:(0,J.jsx)(Jp,{className:`h-4 w-4`,"aria-hidden":!0}),status:`static`,statusLabel:`Not published`,summary:`Static output contains no Agent policy or physical inventory.`},{id:`schemas`,title:`Schemas`,description:`Read-only Schema catalog and published physical documents.`,href:`/config/schemas`,icon:(0,J.jsx)(Yp,{className:`h-4 w-4`,"aria-hidden":!0}),status:t.error?`blocked`:t.isLoading&&!t.data?`loading`:`static`,statusLabel:t.error?`Blocked`:t.isLoading&&!t.data?`Loading`:`Snapshot`,summary:t.data?`${n} published Schemas`:`Waiting for published Schema data.`,error:t.error?.message},{id:`context`,title:`Resolved Context`,description:`Publication-redacted Root and Reference provenance.`,href:`/config/context`,icon:(0,J.jsx)(Qm,{className:`h-4 w-4`,"aria-hidden":!0}),status:`static`,statusLabel:`Snapshot`,summary:`Inspect the publication-safe Context evidence boundary.`}]})}function vWe(){let e=B();return(0,J.jsx)(_Z,{current:`overview`,header:(0,J.jsx)(mWe,{}),children:e?(0,J.jsx)(_We,{}):(0,J.jsx)(gWe,{})})}var yWe={init:`Initialize selected Agents`,repair:`Repair Agent delivery`,update:`Update Agent delivery`};function bWe({kind:e,status:t,hasStarted:n,lines:r,onRun:i,onCancel:a,onClose:o}){let s=t===`running`;return(0,J.jsxs)(GS,{open:e!==null,onClose:o,onDismissRequest:s?null:o,title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(qm,{className:`h-4 w-4`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:e?yWe[e]:``})]}),bodyClassName:`space-y-3`,borderVariant:t===`success`?`success`:t===`error`?`error`:`default`,footer:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s?(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`border-destructive/50 text-destructive hover:bg-destructive/10 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}):(0,J.jsx)(`button`,{type:`button`,onClick:o,className:`border-border hover:bg-muted rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Close`}),n?null:(0,J.jsxs)(`button`,{type:`button`,onClick:i,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium`,children:[(0,J.jsx)(qm,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Run command`]})]}),children:[e===`repair`?(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-800 dark:text-amber-200`,children:[(0,J.jsx)(Xm,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Repair runs `,(0,J.jsx)(`span`,{className:`font-mono`,children:`openspec update --force`}),`. Review migration and cleanup evidence before continuing.`]})]}):null,(0,J.jsx)(kC,{lines:r,maxHeight:`52vh`})]})}function xWe(){return(0,J.jsxs)(`header`,{className:`space-y-3`,children:[(0,J.jsxs)(Rp,{to:`/config`,className:`text-muted-foreground hover:text-foreground focus-visible:ring-primary inline-flex min-h-8 items-center gap-1.5 rounded-md px-1 text-xs outline-none focus-visible:ring-2`,children:[(0,J.jsx)(Up,{className:`h-4 w-4`,"aria-hidden":!0}),`Config`]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h1`,{className:`font-nav flex min-w-0 items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Jp,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0}),`Agent Integrations`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 max-w-3xl text-sm`,children:`Configure official OpenSpec delivery policy, inspect physical artifacts, and reconcile Agent integrations from one Server-owned surface.`})]})]})}function SWe(e){if(e.transportError)return{status:`failed`,title:`Project Binding unavailable`,detail:e.transportError};if(e.loading&&!e.available)return{status:`blocked`,title:`Loading Project Binding`,detail:`Wait for the launch-project binding projection.`};if(!e.available)return{status:`failed`,title:`Project Binding unavailable`,detail:`The launch-project binding projection did not return a current value.`};if(e.mutationPending||e.dirty||e.convergencePending)return{status:`active-edit`,title:`Finish Project Binding changes`,detail:e.convergencePending?`Wait for the Root Context projection to replace the saved binding preview.`:`Save or discard the current Project Binding edits.`};let t=e.formError??e.convergenceError;return t?{status:`failed`,title:`Project Binding needs repair`,detail:t}:e.failureDiagnostic?{status:`failed`,title:`Project Binding needs repair`,detail:e.failureDiagnostic}:e.warningDiagnostic?{status:`warning`,title:`Review Project Binding diagnostics`,detail:e.warningDiagnostic}:{status:`ready`,title:`Project Binding ready`,detail:`The current launch-project Store and Reference declarations are settled.`}}function CWe(e){return e.transportError?{status:`failed`,title:`Active Root unavailable`,detail:e.transportError}:e.loading&&!e.available?{status:`blocked`,title:`Loading Active Root`,detail:`Wait for the CLI-selected Active Root projection.`}:e.available?e.mutationPending||e.editing||e.dirty||e.conflict?{status:`active-edit`,title:`Finish Active Root changes`,detail:`Save, resolve, or discard the current Structured or Raw YAML draft.`}:e.authority===`blocked`?{status:`failed`,title:e.authorityTitle??`Active Root authority failed`,detail:e.authorityMessage??`Repair Root Context authority before continuing.`}:e.refreshing||e.authority===`checking`?{status:`stale`,title:`Active Root is refreshing`,detail:e.authorityMessage??`Wait for current Root authority before continuing.`}:e.exists?e.errorDiagnostic?{status:`failed`,title:`Active Root config is invalid`,detail:e.errorDiagnostic}:e.warningDiagnostic?{status:`warning`,title:`Review Active Root diagnostics`,detail:e.warningDiagnostic}:{status:`ready`,title:`Active Root ready`,detail:`The CLI-selected Root has a current valid configuration.`}:{status:`required`,title:`Create the Active Root config`,detail:`Create and save an official or custom YAML configuration for this Root.`}:{status:`failed`,title:`Active Root unavailable`,detail:`No Active Root configuration projection is available.`}}function wWe(e){return e.transportError?{status:`failed`,title:`Agent Delivery unavailable`,detail:e.transportError}:e.loading&&!e.available?{status:`blocked`,title:`Loading Agent Delivery`,detail:`Wait for the current Agent registry and artifact inventory.`}:e.available?e.activeEdit||e.conflict?{status:`active-edit`,title:`Finish Agent Delivery changes`,detail:e.conflict?`Resolve the changed upstream policy before continuing.`:`Save the policy or finish the active Agent delivery command.`}:e.policyError?{status:`failed`,title:`Agent Delivery change failed`,detail:e.policyError}:e.refreshing?{status:`stale`,title:`Agent Delivery is refreshing`,detail:`Wait for replacement registry and artifact inventory data.`}:e.repairRequired?{status:`warning`,title:`Agent Delivery needs attention`,detail:`Review partial, stale, cleanup, or migration work before continuing.`}:{status:`ready`,title:`Agent Delivery ready`,detail:`The current policy and Agent artifact inventory are settled.`}:{status:`failed`,title:`Agent Delivery unavailable`,detail:`The Agent delivery projection did not return current data.`}}function TWe(e){return e.transportError||e.authorityFailed?{status:`failed`,title:`Resolved Context unavailable`,detail:e.transportError??`Current Root authority failed.`}:e.loading?{status:`blocked`,title:`Resolving Context`,detail:`Wait for the current CLI-selected Root Context.`}:e.refreshing||!e.authorityCurrent?{status:`stale`,title:`Resolved Context is refreshing`,detail:`Retained Context is visible, but current Root authority has not settled.`}:!e.available||!e.hasPlanningRoot?{status:`required`,title:`Select a usable Root`,detail:`Project Binding or Environment Global must resolve a current Planning Root.`}:!e.cliAvailable||e.cliError?{status:`failed`,title:`Selected Root is not usable`,detail:e.cliError??`OpenSpec CLI is unavailable for the selected Root.`}:e.errorDiagnostic?{status:`failed`,title:`Resolved Context has errors`,detail:e.errorDiagnostic}:e.warningDiagnostic?{status:`warning`,title:`Review Resolved Context warnings`,detail:e.warningDiagnostic}:{status:`ready`,title:`Resolved Context ready`,detail:`Root authority is current and the selected Planning Root is usable.`}}var IZ=[`propose`,`explore`,`new`,`continue`,`apply`,`update`,`ff`,`sync`,`archive`,`bulk-archive`,`verify`,`onboard`],LZ={propose:`Propose change`,explore:`Explore ideas`,new:`New change`,continue:`Continue change`,apply:`Apply tasks`,update:`Update change`,ff:`Fast-forward`,sync:`Sync specs`,archive:`Archive change`,"bulk-archive":`Bulk archive`,verify:`Verify change`,onboard:`Onboard`},EWe=[{value:`core`,label:`Core workflows`},{value:`custom`,label:`Custom workflows`}],DWe=[{value:`both`,label:`Skills and commands`},{value:`skills`,label:`Skills only`},{value:`commands`,label:`Commands only`}],OWe={unavailable:`border-zinc-500/30 bg-zinc-500/10 text-zinc-600 dark:text-zinc-300`,uninitialized:`border-border bg-muted/50 text-muted-foreground`,partial:`border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200`,initialized:`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`},kWe={"cleanup-needed":`Cleanup needed`,"migration-required":`Migration required`,"stale-version":`Stale version`};function AWe(e){return e===`uninitialized`?`Not initialized`:e.charAt(0).toUpperCase()+e.slice(1)}function jWe({state:e}){return(0,J.jsx)(`span`,{className:`inline-flex min-h-6 items-center rounded border px-2 py-0.5 text-[11px] font-medium ${OWe[e.readiness]}`,children:AWe(e.readiness)})}function RZ({label:e,workflows:t}){return(0,J.jsxs)(`p`,{className:`grid min-w-0 grid-cols-[minmax(0,8rem)_minmax(0,1fr)] gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),(0,J.jsx)(`span`,{className:`min-w-0 break-words font-mono`,children:t.length>0?t.join(`, `):`None`})]})}function MWe({tool:e,state:t}){let n=[e.skillsDir?`Skills: ${e.skillsDir}`:null,e.globalSkillsDir?`Global skills: ~/${e.globalSkillsDir}/skills`:null,e.command?`Commands: ${e.command.pathTemplate}`:null].filter(e=>e!==null);return(0,J.jsxs)(`details`,{className:`border-border/70 bg-muted/20 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)(`summary`,{className:`text-muted-foreground cursor-pointer select-none font-medium`,children:`Registry and artifact evidence`}),(0,J.jsxs)(`div`,{className:`@[42rem]:grid-cols-2 mt-2 grid min-w-0 gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Capability:`}),` `,e.capability]}),n.map(e=>(0,J.jsx)(`p`,{className:`break-all font-mono`,children:e},e)),e.legacySkillsDirs?.length?(0,J.jsxs)(`p`,{className:`break-all font-mono`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground font-sans`,children:`Legacy skills:`}),` `,e.legacySkillsDirs.join(`, `)]}):null,t.commandSurfaceUnavailableReason?(0,J.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`command-surface-unavailable`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Command surface:`}),` `,t.commandSurfaceUnavailableReason]}):null,t.requiresIdeRestart?(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`IDE restart:`}),` required to load regenerated artifacts`]}):null,e.command?(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Invocation:`}),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.command.invocation.prefix,e.command.invocation.style===`namespaced`?`opsx:{workflow}`:`opsx-{workflow}`]})]}):null,e.aliases?.length?(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Aliases:`}),` `,e.aliases.join(`, `)]}):null,e.setupNote?(0,J.jsx)(`p`,{children:e.setupNote}):null]}),(0,J.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Skills scope:`}),` `,t.skillsScope.kind===`user-global`?`user-global ~/${t.skillsScope.globalSkillsDir}/skills`:t.skillsScope.kind===`project`?`project ${t.skillsScope.skillsDir}/skills`:`none`]}),(0,J.jsxs)(`p`,{children:[`Skills `,t.presentExpectedSkillCount,`/`,t.expectedSkillCount,` · Commands`,` `,t.presentExpectedCommandCount,`/`,t.expectedCommandCount]}),t.generatedByVersion?(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Generated by:`}),` `,t.generatedByVersion]}):null,t.cleanup?(0,J.jsxs)(`p`,{className:`break-all`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Cleanup:`}),` `,t.cleanup.paths.join(`, `)]}):null,t.migration?(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Migration:`}),` `,t.migration.from,` →`,` `,t.migration.to,t.migration.needsConsent?` (consent required)`:``]}):null]}),(0,J.jsxs)(`div`,{className:`border-border/60 @[42rem]:col-span-2 @[42rem]:grid-cols-2 grid min-w-0 gap-x-4 gap-y-2 border-t pt-2`,children:[(0,J.jsx)(RZ,{label:`Installed skills`,workflows:t.installedSkillWorkflows}),(0,J.jsx)(RZ,{label:`Missing skills`,workflows:t.missingSkillWorkflows}),(0,J.jsx)(RZ,{label:`Unexpected skills`,workflows:t.unexpectedSkillWorkflows}),(0,J.jsx)(RZ,{label:`Installed commands`,workflows:t.installedCommandWorkflows}),(0,J.jsx)(RZ,{label:`Missing commands`,workflows:t.missingCommandWorkflows}),(0,J.jsx)(RZ,{label:`Unexpected commands`,workflows:t.unexpectedCommandWorkflows}),(0,J.jsx)(RZ,{label:`Legacy commands`,workflows:t.legacyCommandWorkflows})]})]})]})}function NWe({tool:e,state:t,selected:n,disabled:r,onToggle:i}){return(0,J.jsxs)(`li`,{className:`border-border @container min-w-0 space-y-3 rounded-lg border p-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":n,"aria-label":`Select ${e.name}`,disabled:r||!e.available,onClick:i,className:`focus-visible:ring-primary mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded border outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-40 ${n?`border-primary bg-primary text-primary-foreground`:`border-border bg-background`}`,children:n?(0,J.jsx)(Xp,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):null}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,J.jsx)(`p`,{className:`text-muted-foreground font-mono text-[11px]`,children:e.value})]}),(0,J.jsx)(jWe,{state:t})]}),t.issues.length>0?(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:t.issues.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] text-amber-800 dark:text-amber-200`,children:[(0,J.jsx)(Xm,{className:`h-3 w-3`,"aria-hidden":!0}),kWe[e]]},e))}):null]})]}),(0,J.jsx)(MWe,{tool:e,state:t})]})}function PWe(e,t){return e===`init`?{type:`agent-init`,input:{tools:[...t]}}:e===`repair`?{type:`agent-repair`}:{type:`agent-update`}}function zZ(e){return{...e,workflows:[...e.workflows]}}function BZ(e,t){return e!==null&&e.profile===t.profile&&e.delivery===t.delivery&&e.workflows.length===t.workflows.length&&e.workflows.every(e=>t.workflows.includes(e))}function FWe(){let e=xZ(),t=OC(),[n,r]=(0,Y.useState)(`core`),[i,a]=(0,Y.useState)(`both`),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)([]),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),S=(0,Y.useRef)(t.status),C=(0,Y.useMemo)(()=>({profile:n,delivery:i,workflows:o}),[i,n,o]),w=c!==null&&!BZ(c,C),T=(0,Y.useCallback)(e=>{r(e.profile),a(e.delivery),s([...e.workflows])},[]);(0,Y.useEffect)(()=>{if(!e.data||g)return;let t=e.data.policy;if(!c){let e=zZ(t);l(e),T(e),d(!1);return}let n=!BZ(c,t),r=!BZ(c,C);if(!n){r||d(!1);return}let i=zZ(t);if(l(i),!r||BZ(C,t)){T(i),d(!1);return}d(!0)},[C,c,g,e.data,T]),(0,Y.useEffect)(()=>{let n=S.current;S.current=t.status,!(t.status!==`success`||n===`success`)&&e.refresh().catch(()=>void 0)},[e,t.status]);let E=(0,Y.useMemo)(()=>new Map(e.data?.states.map(e=>[e.toolId,e])??[]),[e.data]),D=(0,Y.useMemo)(()=>{let t=m.trim().toLowerCase();return e.data?t?e.data.registry.filter(e=>e.name.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)||e.aliases?.some(e=>e.toLowerCase().includes(t))):e.data.registry:[]},[e.data,m]),O=(0,Y.useMemo)(()=>{let t=e.data?.states??[];return{initialized:t.filter(e=>e.readiness===`initialized`).length,partial:t.filter(e=>e.readiness===`partial`).length,issues:t.filter(e=>e.issues.length>0).length,unavailable:t.filter(e=>e.readiness===`unavailable`).length}},[e.data]),k=g||e.isRefreshing||t.status===`running`,A=(e.data?.states??[]).some(e=>e.readiness===`partial`||e.issues.length>0),j=CC(`agent-delivery`,wWe({available:e.data!==null&&e.data!==void 0,loading:e.isLoading,transportError:e.error?.message??null,activeEdit:g||w||t.status===`running`||b!==null,conflict:u,policyError:v,refreshing:e.isRefreshing,repairRequired:A})),M=(0,Y.useCallback)(e=>{s(t=>t.includes(e)?t.filter(t=>t!==e):IZ.filter(n=>n===e||t.includes(n)))},[]),N=(0,Y.useCallback)(async()=>{_(!0),y(null);try{let t=await q.agentIntegrations.updatePolicy.mutate({profile:n,delivery:i,workflows:o}),r=zZ(t.policy);l(r),T(r),d(!1),e.accept(t)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}},[i,n,e,T,o]),P=(0,Y.useCallback)(()=>{c&&(T(c),d(!1),y(null))},[c,T]),F=(0,Y.useCallback)(e=>{t.reset(),t.commands.replaceAll([PWe(e,f)]),S.current=`idle`,x(e)},[t,f]),I=(0,Y.useCallback)(()=>{t.status!==`running`&&x(null)},[t.status]);return(0,J.jsx)(_Z,{current:`agents`,header:(0,J.jsx)(xWe,{}),children:(0,J.jsxs)(`div`,{...j,className:`space-y-6`,children:[e.error?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 flex items-start gap-2 rounded-lg border p-4 text-sm`,children:[(0,J.jsx)(Hm,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Agent Integrations authority is unavailable.`}),(0,J.jsx)(`p`,{children:e.error.message})]})]}):null,e.isLoading&&!e.data?(0,J.jsxs)(`div`,{className:`border-border bg-card grid gap-3 rounded-lg border p-4`,"aria-label":`Loading Agent Integrations`,children:[(0,J.jsx)(`div`,{className:`bg-muted h-5 w-44 animate-pulse rounded`}),(0,J.jsx)(`div`,{className:`bg-muted h-20 animate-pulse rounded`}),(0,J.jsx)(`div`,{className:`bg-muted h-40 animate-pulse rounded`})]}):null,e.data?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{className:`border-border bg-card space-y-4 rounded-lg border p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Delivery Policy`}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Writes only official profile, delivery, and workflow fields. Raw Environment JSON remains the escape hatch for team extensions.`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void e.refresh(),disabled:k,className:`border-border hover:bg-muted inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs disabled:cursor-not-allowed disabled:opacity-50`,children:[e.isRefreshing?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(Fm,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`@[42rem]:grid-cols-2 grid gap-3`,children:[(0,J.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium`,children:[(0,J.jsx)(`span`,{children:`Profile`}),(0,J.jsx)(YW,{value:n,options:EWe,onValueChange:r,ariaLabel:`Agent delivery profile`,disabled:k,className:`w-full`})]}),(0,J.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium`,children:[(0,J.jsx)(`span`,{children:`Delivery`}),(0,J.jsx)(YW,{value:i,options:DWe,onValueChange:a,ariaLabel:`Agent delivery mode`,disabled:k,className:`w-full`})]})]}),(0,J.jsxs)(`div`,{className:n===`custom`?`space-y-2`:`space-y-2 opacity-60`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium`,children:`Workflows`}),(0,J.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:n===`core`?`Core profile is CLI-defined`:`${o.length} selected`})]}),(0,J.jsx)(`div`,{className:`@[36rem]:grid-cols-2 @[64rem]:grid-cols-3 grid gap-2`,children:IZ.map(e=>{let t=o.includes(e);return(0,J.jsx)(`button`,{type:`button`,"aria-pressed":t,disabled:k||n!==`custom`,onClick:()=>M(e),className:`min-w-0 rounded-md border px-3 py-2 text-left text-xs disabled:cursor-not-allowed ${t?`border-primary/50 bg-primary/10 text-foreground`:`border-border hover:bg-muted text-muted-foreground`}`,children:LZ[e]},e)})})]}),u?(0,J.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,J.jsx)(`span`,{children:`Agent delivery policy changed outside this page. Your unsaved draft is preserved.`}),(0,J.jsx)(`button`,{type:`button`,onClick:P,disabled:k,className:`border-current/30 rounded-md border px-2.5 py-1 font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:`Use current policy`})]}):null,v?(0,J.jsx)(`p`,{role:`alert`,className:`text-destructive text-xs`,children:v}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void N(),disabled:k||n===`custom`&&o.length===0,className:`bg-primary text-primary-foreground inline-flex h-9 items-center gap-2 rounded-md px-3 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[g?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(Xp,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Save policy`]}),w?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Unsaved policy changes`}):null]})]}),(0,J.jsxs)(`section`,{className:`border-border bg-card space-y-4 rounded-lg border p-4`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Agent Inventory`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:[e.data.registry.length,` official entries · `,O.initialized,` `,`initialized · `,O.partial,` partial · `,O.issues,` with issues ·`,` `,O.unavailable,` unavailable`]})]}),(0,J.jsxs)(`label`,{className:`border-border bg-background flex h-9 min-w-48 items-center gap-2 rounded-md border px-3`,children:[(0,J.jsx)(zm,{className:`text-muted-foreground h-3.5 w-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Search Agent inventory`}),(0,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search Agents`,className:`min-w-0 flex-1 bg-transparent text-xs outline-none`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>p((e.data?.registry??[]).filter(e=>e.available).map(e=>e.value)),className:`border-border hover:bg-muted rounded-md border px-2.5 py-1.5 text-xs disabled:cursor-not-allowed disabled:opacity-50`,children:`Select available`}),(0,J.jsx)(`button`,{type:`button`,disabled:k||f.length===0,onClick:()=>p([]),className:`border-border hover:bg-muted rounded-md border px-2.5 py-1.5 text-xs disabled:cursor-not-allowed disabled:opacity-50`,children:`Clear selection`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[f.length,` selected`]})]}),(0,J.jsx)(`ul`,{className:`@[64rem]:grid-cols-2 grid gap-3`,children:D.map(e=>{let t=E.get(e.value);return t?(0,J.jsx)(NWe,{tool:e,state:t,selected:f.includes(e.value),disabled:k,onToggle:()=>p(t=>t.includes(e.value)?t.filter(t=>t!==e.value):[...t,e.value])},e.value):null})}),(0,J.jsxs)(`div`,{className:`border-border flex flex-wrap gap-2 border-t pt-4`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>F(`init`),disabled:k||f.length===0,className:`bg-primary text-primary-foreground inline-flex h-9 items-center gap-2 rounded-md px-3 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(qm,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Init selected`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>F(`update`),disabled:k,className:`border-border hover:bg-muted inline-flex h-9 items-center gap-2 rounded-md border px-3 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Fm,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Update`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>F(`repair`),disabled:k||!A,title:A?void 0:`No partial, stale, cleanup, or migration work detected.`,className:`inline-flex h-9 items-center gap-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-3 text-xs font-medium text-amber-800 hover:bg-amber-500/15 disabled:cursor-not-allowed disabled:opacity-50 dark:text-amber-200`,children:[(0,J.jsx)(ple,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Repair`]})]})]})]}):null,(0,J.jsx)(bWe,{kind:b,status:t.status,hasStarted:t.hasStarted,lines:t.lines,onRun:()=>void t.commands.runAll(),onCancel:t.cancel,onClose:I})]})})}function VZ(e=!0){return Bf({source:(0,Y.useMemo)(()=>({read:()=>q.stores.readListProjection.query(),refresh:()=>q.stores.refreshProjection.query({kind:`list`}),parseState:e=>E.parse(e),subscribe(e){return q.stores.subscribeProjection.subscribe({kind:`list`},{onData(t){let n=j.safeParse(t);if(!n.success){e.onError(Error(`Malformed Store list notice: ${n.error.message}`));return}e.onNotice()},onError:e.onError,onConnectionStateChange(t){t.error?e.onError(t.error):(t.state===`connecting`||t.state===`pending`)&&e.onConnectionState(t.state)},onStopped:e.onStopped,onComplete:e.onComplete})}}),[]),sourceKey:`stores.list`,selectData:e=>e,staticLoader:async()=>({available:!1,stores:[]}),cacheKey:`stores.list.projection`,enabled:e})}var HZ=Y.createContext(void 0),UZ=Y.createContext(void 0),WZ=Y.createContext(void 0),GZ=Y.createContext(``);function KZ(){let e=Y.useContext(HZ);if(!e)throw Error(nr(22));return e}function qZ(){let e=Y.useContext(UZ);if(!e)throw Error(nr(23));return e}function JZ(){let e=Y.useContext(WZ);if(!e)throw Error(nr(24));return e}function YZ(){return Y.useContext(GZ)}var Q={id:W(e=>e.id),labelId:W(e=>e.labelId),query:W(e=>e.query),items:W(e=>e.items),selectedValue:W(e=>e.selectedValue),hasSelectionChips:W(e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:W(e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:W((e,t)=>t?bW(e.items):!1),open:W(e=>e.open),mounted:W(e=>e.mounted),forceMounted:W(e=>e.forceMounted),inline:W(e=>e.inline),activeIndex:W(e=>e.activeIndex),selectedIndex:W(e=>e.selectedIndex),isActive:W((e,t)=>e.activeIndex===t),isSelected:W((e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>mW(t,e,n)):mW(t,r,n)}),transitionStatus:W(e=>e.transitionStatus),popupProps:W(e=>e.popupProps),inputProps:W(e=>e.inputProps),triggerProps:W(e=>e.triggerProps),getItemProps:W(e=>e.getItemProps),positionerElement:W(e=>e.positionerElement),listElement:W(e=>e.listElement),triggerElement:W(e=>e.triggerElement),inputElement:W(e=>e.inputElement),inputGroupElement:W(e=>e.inputGroupElement),popupSide:W(e=>e.popupSide),openMethod:W(e=>e.openMethod),inputInsidePopup:W(e=>e.inputInsidePopup),selectionMode:W(e=>e.selectionMode),listRef:W(e=>e.listRef),labelsRef:W(e=>e.labelsRef),popupRef:W(e=>e.popupRef),emptyRef:W(e=>e.emptyRef),inputRef:W(e=>e.inputRef),keyboardActiveRef:W(e=>e.keyboardActiveRef),chipsContainerRef:W(e=>e.chipsContainerRef),clearRef:W(e=>e.clearRef),valuesRef:W(e=>e.valuesRef),allValuesRef:W(e=>e.allValuesRef),name:W(e=>e.name),disabled:W(e=>e.disabled),readOnly:W(e=>e.readOnly),required:W(e=>e.required),grid:W(e=>e.grid),isGrouped:W(e=>e.isGrouped),virtualized:W(e=>e.virtualized),onOpenChangeComplete:W(e=>e.onOpenChangeComplete),openOnInputClick:W(e=>e.openOnInputClick),itemToStringLabel:W(e=>e.itemToStringLabel),isItemEqualToValue:W(e=>e.isItemEqualToValue),modal:W(e=>e.modal),autoHighlight:W(e=>e.autoHighlight),submitOnItemClick:W(e=>e.submitOnItemClick)};function IWe(e,t){return(n,r)=>{if(n==null)return!1;let i=xW(n,t);return e.contains(i,r)}}function LWe(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;let a=xW(r,t),o=n==null?``:xW(n,t);return o&&e.contains(o,i)&&o.length===i.length?!0:e.contains(a,i)}}var XZ=new Map;function ZZ(e){return Array.isArray(e)?e.map(e=>ZZ(e)).join(`,`):e==null?``:String(e)}function RWe(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${ZZ(e.locale)}|${JSON.stringify(t)}`,r=XZ.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=xW(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=xW(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=xW(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return XZ.set(n,a),a}var zWe=RWe,QZ=Symbol(`none`),$Z={value:QZ,index:-1};function BWe(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,selectionMode:c=`none`,onItemHighlighted:l,name:u,disabled:d=!1,readOnly:f=!1,required:p=!1,inputRef:m,grid:h=!1,items:g,filteredItems:_,filter:v,openOnInputClick:y=!0,autoHighlight:b=!1,keepHighlight:x=!1,highlightItemOnHover:S=!0,loopFocus:C=!0,itemToStringLabel:w,itemToStringValue:T,isItemEqualToValue:E=pW,virtualized:D=!1,inline:O=!1,fillInputOnItemPress:k=!0,modal:A=!1,limit:j=-1,autoComplete:M=`list`,formAutoComplete:N,locale:P,submitOnItemClick:F=!1}=e,{clearErrors:I}=TW(),{setDirty:L,validityData:R,shouldValidateOnChange:z,setFilled:B,name:V,disabled:ee,setTouched:te,setFocused:ne,validationMode:re,validation:ie}=uW(),ae=fW({id:t}),oe=zWe({locale:P}),[se,ce]=Y.useState(!1),[le,ue]=Y.useState(null),de=Y.useRef([]),fe=Y.useRef([]),pe=Y.useRef(null),me=Y.useRef(null),he=Y.useRef(null),ge=Y.useRef(null),_e=Y.useRef(null),ve=Y.useRef(!0),ye=Y.useRef(!1),be=Y.useRef(null),xe=Y.useRef(null),H=Y.useRef(null),Se=Y.useRef($Z),Ce=Y.useRef(null),we=Y.useRef([]),Te=Y.useRef([]),Ee=ee||d,De=V??u,Oe=c===`multiple`,ke=c===`single`,Ae=s!==void 0||o!==void 0,je=g!==void 0,Me=_!==void 0,Ne;Ne=b===`always`?`always`:b?`input-change`:!1;let[Pe,Fe]=GC({controlled:i,default:Oe?r??hn:r,name:`Combobox`,state:`selectedValue`}),Ie=Y.useMemo(()=>v===null?()=>!0:v===void 0?ke&&!se?LWe(oe,w,Pe):IWe(oe,w):v,[v,ke,Pe,se,oe,w]),Le=Sn(()=>Ae?o??``:ke?xW(Pe,w):``).current,[Re,ze]=GC({controlled:s,default:Le,name:`Combobox`,state:`inputValue`}),[Be,Ve]=GC({controlled:e.open,default:e.defaultOpen,name:`Combobox`,state:`open`}),He=yW(g),Ue=le??(Re===``?``:String(Re).trim()),We=ke?xW(Pe,w):``,Ge=ke&&!se&&Ue!==``&&We!==``&&We.length===Ue.length&&oe.contains(We,Ue),Ke=Ge?``:Ue,U=je&&Me&&Ge,qe=Y.useMemo(()=>g?He?g.flatMap(e=>e.items):g:hn,[g,He]),Je=Y.useMemo(()=>{if(_&&!U)return _;if(!g)return hn;if(He){let e=g,t=[],n=0;for(let r of e){if(j>-1&&n>=j)break;let e=Ke===``?r.items:r.items.filter(e=>Ie(e,Ke,w));if(e.length===0)continue;let i=j>-1?j-n:1/0,a=e.slice(0,i);if(a.length>0){let e={...r,items:a};t.push(e),n+=a.length}}return t}if(Ke===``)return j>-1?qe.slice(0,j):qe;let e=[];for(let t of qe){if(j>-1&&e.length>=j)break;Ie(t,Ke,w)&&e.push(t)}return e},[_,U,g,He,Ke,j,Ie,w,qe]),Ye=Y.useMemo(()=>He?Je.flatMap(e=>e.items):Je,[Je,He]),Xe=Sn(()=>new kn({id:ae,labelId:void 0,selectedValue:Pe,open:Be,filter:Ie,query:Ue,items:g,selectionMode:c,listRef:de,labelsRef:fe,popupRef:pe,emptyRef:_e,inputRef:me,startDismissRef:he,endDismissRef:ge,keyboardActiveRef:ve,chipsContainerRef:be,clearRef:xe,valuesRef:we,allValuesRef:Te,selectionEventRef:H,name:De,disabled:Ee,readOnly:f,required:p,grid:h,isGrouped:He,virtualized:D,openOnInputClick:y,itemToStringLabel:w,isItemEqualToValue:E,modal:A,autoHighlight:Ne,submitOnItemClick:F,hasInputValue:Ae,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:O,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,onOpenChangeComplete:n||Tn,setOpen:Tn,setInputValue:Tn,setSelectedValue:Tn,setIndices:Tn,onItemHighlighted:Tn,handleSelection:Tn,getItemProps:()=>yn,forceMount:Tn,requestSubmit:Tn})).current,Ze=c===`none`?Re:Pe,Qe=Y.useMemo(()=>c===`none`?Ze:Array.isArray(Pe)?Pe.map(e=>SW(e,T)):SW(Pe,T),[Ze,T,c,Pe]),$e=Wn(l),et=Wn(n),tt=K(Xe,Q.activeIndex),nt=K(Xe,Q.selectedIndex),rt=K(Xe,Q.positionerElement),it=K(Xe,Q.listElement),at=K(Xe,Q.triggerElement),ot=K(Xe,Q.inputElement),st=K(Xe,Q.inputGroupElement),ct=K(Xe,Q.inline),lt=K(Xe,Q.inputInsidePopup),ut=pr(at),{mounted:dt,setMounted:ft,transitionStatus:pt}=An(Be),{openMethod:mt,triggerProps:ht}=Zn(Be);EW({id:ae,name:De,commit:ie.commit,value:Ze,controlRef:lt?ut:me,getValue:()=>Qe});let gt=Wn(()=>{g?fe.current=Ye.map(e=>xW(e,w)):Xe.set(`forceMounted`,!0)}),_t=Y.useRef(Pe);$t(()=>{Pe!==_t.current&&gt()},[gt,Pe]);let vt=Wn(e=>{Xe.update(e);let t=e.type||`none`;if(e.activeIndex!==void 0)if(e.activeIndex===null)Se.current!==$Z&&(Se.current=$Z,$e(void 0,qn(t,void 0,{index:-1})));else{let n=we.current[e.activeIndex];Se.current={value:n,index:e.activeIndex},$e(n,qn(t,void 0,{index:e.activeIndex}))}}),yt=Wn((t,n)=>{if(ye.current=n.reason===wr,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===`input-change`){let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&ce(!0),Ce.current={hasQuery:e},e&&Ne&&Xe.state.activeIndex==null&&Xe.set(`activeIndex`,0)}}ze(t)}}),bt=Wn((t,n)=>{if(Be!==t&&(n.reason===`escape-key`&&je&&Ye.length===0&&!Xe.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(!t&&se&&(ke?(ct||ue(Ue),Ue===``&&ce(!1)):Oe&&(ct||lt?vt({activeIndex:null}):ue(Ue),yt(``,Xn(wr,n.event)))),Ve(t),!t&&lt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(te(!0),ne(!1),re===`onBlur`)))){let e=c===`none`?Re:Pe;ie.commit(e)}}),xt=Wn((e,t)=>{a?.(e,t),!t.isCanceled&&(Fe(e),(c===`none`&&pe.current&&k||ke&&!Xe.state.inputInsidePopup)&&yt(xW(e,w),Xn(t.reason,t.event)),ke&&e!=null&&t.reason!==`input-change`&&se&&!ct&&ue(Ue))}),St=Wn((e,t)=>{let n=t;if(n===void 0){if(tt===null)return;n=we.current[tt]}let r=ir(e),i=H.current??e;H.current=null;let a=Xn(fn,i),o=r?.closest(`a`)?.getAttribute(`href`);if(o){o.startsWith(`#`)&&bt(!1,a);return}if(Oe){let e=Array.isArray(Pe)?Pe:[];if(xt(hW(e,n,Xe.state.isItemEqualToValue)?_W(e,n,Xe.state.isItemEqualToValue):[...e,n],a),!(me.current&&me.current.value.trim()!==``))return;Xe.state.inputInsidePopup?yt(``,Xn(wr,a.event)):bt(!1,a)}else xt(n,a),bt(!1,a)}),Ct=Wn(()=>{if(!Xe.state.submitOnItemClick)return;let e=Xe.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),wt=Wn(()=>{if(ft(!1),et?.(!1),ce(!1),ue(null),vt(c===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Oe&&me.current&&me.current.value!==``&&!ye.current&&yt(``,Xn(wr)),ke)if(Xe.state.inputInsidePopup)me.current&&me.current.value!==``&&yt(``,Xn(wr));else{let e=xW(Pe,w);me.current&&me.current.value!==e&&yt(e,Xn(e===``?wr:xn))}}),Tt=Y.useMemo(()=>ct&&rt?{current:rt.closest(`[role="dialog"]`)}:pe,[ct,rt]);vn({enabled:!e.actionsRef,open:Be,ref:Tt,onComplete(){Be||wt()}}),Y.useImperativeHandle(e.actionsRef,()=>({unmount:wt}),[wt]),$t(function(){if(Be||c===`none`)return;let e=g?qe:Te.current;if(Oe){let t=Array.isArray(Pe)?Pe:[],n=t[t.length-1],r=gW(e,n,E);vt({selectedIndex:r===-1?null:r})}else{let t=gW(e,Pe,E);vt({selectedIndex:t===-1?null:t})}},[Be,Pe,g,c,qe,Oe,E,vt]),$t(()=>{g&&(we.current=Ye,de.current.length=Ye.length)},[g,Ye]),$t(()=>{let e=Ce.current;if(e&&(e.hasQuery?Ne&&Xe.set(`activeIndex`,0):Ne===`always`&&Xe.set(`activeIndex`,0),Ce.current=null),!Be&&!ct)return;let t=je||Me?Ye:we.current,n=Xe.state.activeIndex;if(n==null){if(Ne===`always`&&t.length>0){Xe.set(`activeIndex`,0);return}Se.current!==$Z&&(Se.current=$Z,Xe.state.onItemHighlighted(void 0,qn(xn,void 0,{index:-1})));return}if(n>=t.length){Se.current!==$Z&&(Se.current=$Z,Xe.state.onItemHighlighted(void 0,qn(xn,void 0,{index:-1}))),Xe.set(`activeIndex`,null);return}let r=t[n],i=Se.current.value,a=i!==QZ&&mW(r,i,Xe.state.isItemEqualToValue);(Se.current.index!==n||!a)&&(Se.current={value:r,index:n},Xe.state.onItemHighlighted(r,qn(xn,void 0,{index:n})))},[tt,Ne,Me,je,Ye,ct,Be,Xe]),$t(()=>{if(c===`none`){B(String(Re)!==``);return}B(Oe?Array.isArray(Pe)&&Pe.length>0:Pe!=null)},[B,c,Re,Pe,Oe]),Y.useEffect(()=>{je&&Ne&&Ye.length===0&&vt({activeIndex:null})},[je,Ne,Ye.length,vt]),Fn(Ue,()=>{!Be||Ue===``||Ue===String(Le)||ce(!0)}),Fn(Pe,()=>{if(c!==`none`&&(I(De),L(Pe!==R.initialValue),z()?ie.commit(Pe):ie.commit(Pe,!0),ke&&!Ae&&!lt)){let e=xW(Pe,w);Re!==e&&yt(e,Xn(xn))}}),Fn(Re,()=>{c===`none`&&(I(De),L(Re!==R.initialValue),z()?ie.commit(Re):ie.commit(Re,!0))}),Fn(g,()=>{if(!ke||Ae||lt||se)return;let e=xW(Pe,w);Re!==e&&yt(e,Xn(xn))});let Et=Qt({open:ct?!0:Be,onOpenChange:bt,elements:{reference:lt?at:ot,floating:rt}}),Dt,Ot;ct||(Dt=h?`grid`:`listbox`,Ot=Be?`true`:`false`);let{getReferenceProps:kt,getFloatingProps:At,getItemProps:jt}=Dn([Y.useMemo(()=>{let e=ot?.tagName===`INPUT`,t=ot==null||e,n=t||Be,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Ot,r[`aria-haspopup`]=Dt,r[`aria-controls`]=Be?it?.id:void 0,r[`aria-autocomplete`]=M),{reference:r,floating:{role:`presentation`}}},[ot,Be,Ot,Dt,it?.id,M]),th(Et,{enabled:!f&&!Ee&&y,event:`mousedown-only`,toggle:!1,touchOpenDelay:lt?0:50,reason:bee}),mr(Et,{enabled:!f&&!Ee&&!ct,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:ct?!0:void 0,outsidePress(e){let t=ir(e);return!vr(at,t)&&!vr(xe.current,t)&&!vr(be.current,t)&&!vr(st,t)}}),sh(Et,{enabled:!f&&!Ee,id:ae,listRef:de,activeIndex:tt,selectedIndex:nt,virtual:!0,loopFocus:C,allowEscape:C&&!Ne,focusItemOnOpen:se||c===`none`&&!Ne?!1:`auto`,focusItemOnHover:S,resetOnPointerLeave:!x,cols:h?2:1,orientation:h?`horizontal`:void 0,disabledIndices:hn,onNavigate(e,t){!t&&!Be||pt===`ending`||vt(t?{activeIndex:e,type:ve.current?`keyboard`:`pointer`}:{activeIndex:e})}})]);er(()=>{Xe.update({inline:O,popupProps:At(),inputProps:kt(),triggerProps:ht,getItemProps:jt,setOpen:bt,setInputValue:yt,setSelectedValue:xt,setIndices:vt,onItemHighlighted:$e,handleSelection:St,forceMount:gt,requestSubmit:Ct})}),$t(()=>{Xe.update({id:ae,selectedValue:Pe,open:Be,mounted:dt,transitionStatus:pt,items:g,inline:O,popupProps:At(),inputProps:kt(),triggerProps:ht,openMethod:mt,getItemProps:jt,selectionMode:c,name:De,disabled:Ee,readOnly:f,required:p,grid:h,isGrouped:He,virtualized:D,onOpenChangeComplete:et,openOnInputClick:y,itemToStringLabel:w,modal:A,autoHighlight:Ne,isItemEqualToValue:E,submitOnItemClick:F,hasInputValue:Ae,requestSubmit:Ct})},[Xe,ae,Pe,Be,dt,pt,g,At,kt,jt,mt,ht,c,De,Ee,f,p,ie,h,He,D,et,y,w,A,E,F,Ae,O,Ct,Ne]);let Mt=or(m,ie.inputRef),Nt=Y.useMemo(()=>({query:Ue,hasItems:je,filteredItems:Je,flatFilteredItems:Ye}),[Ue,je,Je,Ye]),Pt=Y.useMemo(()=>Array.isArray(Ze)?``:SW(Ze,T),[Ze,T]),Ft=Oe&&Array.isArray(Pe)&&Pe.length>0,It=Oe||c===`none`?void 0:De,Lt=Y.useMemo(()=>!Oe||!Array.isArray(Pe)||!De?null:Pe.map(e=>{let t=SW(e,T);return(0,J.jsx)(`input`,{type:`hidden`,name:De,value:t},t)}),[Oe,Pe,De,T]),Rt=(0,J.jsxs)(Y.Fragment,{children:[e.children,(0,J.jsx)(`input`,{...ie.getInputValidationProps({onFocus(){if(lt){at?.focus();return}(me.current||at)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.value,n=Xn(xn,e.nativeEvent);function r(){if(Oe)return;if(c===`none`){L(t!==R.initialValue),yt(t,n),z()&&ie.commit(t);return}let e=we.current.find(e=>SW(e,T).toLowerCase()===t.toLowerCase());e!=null&&(L(e!==R.initialValue),xt?.(e,n),z()&&ie.commit(e))}g?r():(gt(),queueMicrotask(r))}}),id:ae&&It==null?`${ae}-hidden-input`:void 0,name:It,autoComplete:N,disabled:Ee,required:p&&!Ft,readOnly:f,value:Pt,ref:Mt,style:It?ar:zn,tabIndex:-1,"aria-hidden":!0}),Lt]});return(0,J.jsx)(HZ.Provider,{value:Xe,children:(0,J.jsx)(UZ.Provider,{value:Et,children:(0,J.jsx)(WZ.Provider,{value:Nt,children:(0,J.jsx)(GZ.Provider,{value:Re,children:Rt})})})})}function VWe(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,J.jsx)(BWe,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var eQ={...rn,...lW,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null},HWe=Y.createContext(void 0);function UWe(){return Y.useContext(HWe)}var tQ=Y.createContext(void 0);function nQ(e){let t=Y.useContext(tQ);if(t===void 0&&!e)throw Error(nr(21));return t}var rQ=Y.forwardRef(function(e,t){let n=KZ(),{buttonRef:r,getButtonProps:i}=aw({native:!1});return(0,J.jsx)(`span`,{ref:or(t,r),...i({onClick:Wn(e=>{n.state.setOpen(!1,Xn(Kee,e.nativeEvent,e.currentTarget))})}),"aria-label":`Dismiss`,tabIndex:void 0,style:ar})}),WWe=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,...o}=e,{state:s,disabled:c,setTouched:l,setFocused:u,validationMode:d,validation:f}=uW(),{labelId:p}=dW(),m=UWe(),h=!!nQ(!0),g=KZ(),{filteredItems:_}=JZ(),v=YZ(),y=Tr(),b=K(g,Q.required),x=K(g,Q.disabled),S=K(g,Q.readOnly),C=K(g,Q.name),w=K(g,Q.selectionMode),T=K(g,Q.autoHighlight),E=K(g,Q.inputProps),D=K(g,Q.triggerProps),O=K(g,Q.open),k=K(g,Q.mounted),A=K(g,Q.selectedValue),j=K(g,Q.popupSide),M=K(g,Q.positionerElement),N=K(g,Q.id),P=K(g,Q.inline),F=K(g,Q.modal),I=!!T,L=k&&M?j:null,R=c||x||i,z=_.length===0,B=h||P,V=!B||F,ee=In(a??(B?void 0:N)),te=DW(p,void 0),ne=h?cW:s,[re,ie]=Y.useState(null),ae=Y.useRef(!1),oe=Y.useRef(null),se=Y.useRef(!1),ce=Wn(e=>{let t=h||g.state.inline;t&&!g.state.hasInputValue&&g.state.setInputValue(``,Xn(xn)),g.update({inputElement:e,inputInsidePopup:t})}),le=h||!f?o:f.getValidationProps(o),ue={...ne,open:O,disabled:R,readOnly:S,popupSide:L,listEmpty:z};function de(e){if(!m)return;let t,{highlightedChipIndex:n}=m;if(n!==void 0){if(e.key===`ArrowLeft`)e.preventDefault(),t=n>0?n-1:void 0;else if(e.key===`ArrowRight`)e.preventDefault(),t=n<A.length-1?n+1:void 0;else if(e.key===`Backspace`||e.key===`Delete`){e.preventDefault();let r=n>=A.length-1?A.length-2:n;t=r>=0?r:void 0,g.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`})}return t}return e.key===`ArrowLeft`&&(e.currentTarget.selectionStart??0)===0&&A.length>0?(e.preventDefault(),t=Math.max(A.length-1,0)):e.key===`Backspace`&&e.currentTarget.value===``&&A.length>0&&(g.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`}),e.preventDefault()),t}let fe=cr(`input`,e,{state:ue,ref:[t,g.state.inputRef,ce],props:[E,D,{type:`text`,value:e.value??re??v,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":te,disabled:R,readOnly:S,required:w===`none`?b:void 0,...w===`none`&&C&&{name:C},id:ee,onFocus(){if(u(!0),!P||!se.current)return;se.current=!1;let e=oe.current;e==null||!Object.hasOwn(g.state.valuesRef.current,e)||g.state.setIndices({activeIndex:e})},onBlur(){l(!0),u(!1);let e=g.state.activeIndex;if(P&&e!==null&&T!==`always`&&(oe.current=e,se.current=!0,g.state.setIndices({activeIndex:null})),d===`onBlur`){let e=w===`none`?v:A;f.commit(e)}},onCompositionStart(e){Gee||(ae.current=!0,ie(e.currentTarget.value))},onCompositionEnd(e){ae.current=!1;let t=e.currentTarget.value;ie(null),g.state.setInputValue(t,Xn(on,e.nativeEvent))},onChange(e){let t=e.nativeEvent.inputType,n=!t||t===`insertReplacementText`,r=ae.current||!n;if(ae.current){let t=e.currentTarget.value;ie(t),t===``&&!g.state.openOnInputClick&&!g.state.inputInsidePopup&&g.state.setOpen(!1,Xn(wr,e.nativeEvent));let n=t.trim(),i=I&&n!==``;!S&&!R&&n&&r&&(g.state.setOpen(!0,Xn(on,e.nativeEvent)),I||g.state.setIndices({activeIndex:null,selectedIndex:null,type:g.state.keyboardActiveRef.current?`keyboard`:`pointer`})),O&&g.state.activeIndex!==null&&!i&&g.state.setIndices({activeIndex:null,selectedIndex:null,type:g.state.keyboardActiveRef.current?`keyboard`:`pointer`});return}g.state.setInputValue(e.currentTarget.value,Xn(on,e.nativeEvent));let i=e.currentTarget.value===``,a=Xn(wr,e.nativeEvent);i&&!g.state.inputInsidePopup&&(w===`single`&&g.state.setSelectedValue(null,a),g.state.openOnInputClick||g.state.setOpen(!1,a));let o=e.currentTarget.value.trim();!S&&!R&&o&&r&&(g.state.setOpen(!0,Xn(on,e.nativeEvent)),I||g.state.setIndices({activeIndex:null,selectedIndex:null,type:g.state.keyboardActiveRef.current?`keyboard`:`pointer`})),O&&g.state.activeIndex!==null&&!I&&g.state.setIndices({activeIndex:null,selectedIndex:null,type:g.state.keyboardActiveRef.current?`keyboard`:`pointer`})},onKeyDown(e){if(R||S||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;g.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=y===`rtl`;if(e.key===`Home`){Qn(e);let n=Er&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){Qn(e);let i=Er&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!k&&e.key===`Escape`){let t=w===`multiple`&&Array.isArray(A)?A.length===0:A===null,n=Xn(Oee,e.nativeEvent),r=w===`multiple`?[]:null;g.state.setInputValue(``,n),g.state.setSelectedValue(r,n),!t&&!g.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(m&&e.key===`Backspace`&&t.value===``&&m.highlightedChipIndex===void 0&&Array.isArray(A)&&A.length>0){let t=A.slice(0,-1);g.state.setIndices({activeIndex:null,selectedIndex:null,type:g.state.keyboardActiveRef.current?`keyboard`:`pointer`}),g.state.setSelectedValue(t,Xn(xn,e.nativeEvent));return}let i=m?.highlightedChipIndex!==void 0,a=de(e);if(m?.setHighlightedChipIndex(a),a===void 0?i&&g.state.inputRef.current?.focus():m?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&O){let t=g.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;g.state.setOpen(!1,Xn(xn,n));return}Qn(e);let r=g.state.listRef.current[t];r&&(g.state.selectionEventRef.current=n,r.click(),g.state.selectionEventRef.current=null)}},onPointerMove(){g.state.keyboardActiveRef.current=!1},onPointerDown(){g.state.keyboardActiveRef.current=!1}},le],stateAttributesMapping:eQ});return(0,J.jsxs)(Y.Fragment,{children:[O&&V&&(0,J.jsx)(rQ,{ref:g.state.startDismissRef}),fe]})}),GWe=Y.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a,disabled:o}=uW(),s=KZ(),{filteredItems:c}=JZ(),l=K(s,Q.open),u=K(s,Q.mounted),d=K(s,Q.popupSide),f=K(s,Q.positionerElement),p=K(s,Q.disabled),m=K(s,Q.readOnly),h=K(s,Q.hasSelectedValue),g=K(s,Q.selectionMode),_=u&&f?d:null,v=o||p,y=c.length===0,b=g===`none`?!1:!h,x={...a,open:l,disabled:v,readOnly:m,popupSide:_,listEmpty:y,placeholder:b};return cr(`div`,e,{ref:[t,Wn(e=>{s.set(`inputGroupElement`,e)})],props:[{role:`group`},i],state:x,stateAttributesMapping:eQ})}),iQ=2,KWe=Y.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,...s}=e,{state:c,disabled:l,setTouched:u,setFocused:d,validationMode:f,validation:p}=uW(),{labelId:m}=dW(),h=KZ(),{filteredItems:g}=JZ(),_=K(h,Q.selectionMode),v=K(h,Q.disabled),y=K(h,Q.readOnly),b=K(h,Q.required),x=K(h,Q.mounted),S=K(h,Q.popupSide),C=K(h,Q.positionerElement),w=K(h,Q.listElement),T=K(h,Q.triggerProps),E=K(h,Q.triggerElement),D=K(h,Q.inputInsidePopup),O=K(h,Q.id),k=K(h,Q.labelId),A=K(h,Q.open),j=K(h,Q.selectedValue),M=K(h,Q.activeIndex),N=K(h,Q.selectedIndex),P=K(h,Q.hasSelectedValue),F=qZ(),I=YZ(),L=cn(),R=l||v||a,z=g.length===0,B=x&&C?S:null;fW({id:D?o:void 0});let V=D?o??O:o,ee=DW(m,k),te=Y.useRef(``);function ne(e){te.current=e.pointerType}let re=F.useState(`domReferenceElement`);Y.useEffect(()=>{D&&E&&E!==re&&F.set(`domReferenceElement`,E)},[E,re,F,D]);let{reference:ie}=ch(F,{enabled:!A&&!y&&!v&&_===`single`,listRef:h.state.labelsRef,activeIndex:M,selectedIndex:N,onMatch(e){let t=h.state.valuesRef.current[e];t!==void 0&&h.state.setSelectedValue(t,Xn(`none`))}}),{reference:ae}=th(F,{enabled:!y&&!v,event:`mousedown`}),{buttonRef:oe,getButtonProps:se}=aw({native:i,disabled:R}),ce={...c,open:A,disabled:R,popupSide:B,listEmpty:z,placeholder:!P};return cr(`button`,e,{ref:[t,oe,Wn(e=>{h.set(`triggerElement`,e)})],state:ce,props:[T,ae,ie,{id:V,tabIndex:D?0:-1,role:D?`combobox`:void 0,"aria-expanded":A?`true`:`false`,"aria-haspopup":D?`dialog`:`listbox`,"aria-controls":A?w?.id:void 0,"aria-required":D&&b||void 0,"aria-labelledby":ee,onPointerDown:ne,onPointerEnter:ne,onFocus(){d(!0),!(R||y)&&L.start(0,h.state.forceMount)},onBlur(e){if(!vr(C,e.relatedTarget)&&(u(!0),d(!1),f===`onBlur`)){let e=_===`none`?I:j;p.commit(e)}},onMouseDown(e){if(R||y||(D||F.set(`domReferenceElement`,e.currentTarget),h.state.forceMount(),te.current!==`touch`&&(h.state.inputRef.current?.focus(),D||e.preventDefault()),A))return;let t=mn(e.currentTarget);function n(e){if(!E)return;let t=ir(e),n=h.state.positionerElement,r=h.state.listElement;if(vr(E,t)||vr(n,t)||vr(r,t)||t===E)return;let i=OW(E),a=e.clientX>=i.left-iQ&&e.clientX<=i.right+iQ,o=e.clientY>=i.top-iQ&&e.clientY<=i.bottom+iQ;a&&o||h.state.setOpen(!1,Xn(`cancel-open`,e))}D&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){R||y||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(Qn(e),h.state.setOpen(!0,Xn(ln,e.nativeEvent)),h.state.inputRef.current?.focus())}},p?p.getValidationProps(s):s,se],stateAttributesMapping:eQ})}),qWe=Y.createContext(null);function JWe(){return Y.useContext(qWe)}function YWe(e){let{children:t}=e,{filteredItems:n}=JZ(),r=JWe(),i=r?r.items:n;return i?(0,J.jsx)(Y.Fragment,{children:i.map(t)}):null}var XWe=Y.forwardRef(function(e,t){var n;let{render:r,className:i,children:a,...o}=e,s=KZ(),c=qZ(),l=!!nQ(!0),{filteredItems:u}=JZ(),d=K(s,Q.items),f=K(s,Q.labelsRef),p=K(s,Q.listRef),m=K(s,Q.selectionMode),h=K(s,Q.grid),g=K(s,Q.popupProps),_=K(s,Q.disabled),v=K(s,Q.readOnly),y=K(s,Q.virtualized),b=m===`multiple`,x=u.length===0,S=Wn(e=>{s.set(`positionerElement`,e)}),C=Wn(e=>{s.set(`listElement`,e)}),w=Y.useMemo(()=>typeof a==`function`?n||=(0,J.jsx)(YWe,{children:a}):a,[a]),T={empty:x},E=c.useState(`floatingId`),D=cr(`div`,e,{state:T,ref:[t,C,l?null:S],props:[g,{children:w,tabIndex:-1,id:E,role:h?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,onKeyDown(e){if(!(_||v)&&e.key===`Enter`){let t=s.state.activeIndex;if(t==null)return;Qn(e);let n=e.nativeEvent,r=s.state.listRef.current[t];r&&(s.state.selectionEventRef.current=n,r.click(),s.state.selectionEventRef.current=null)}},onKeyDownCapture(){s.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){s.state.keyboardActiveRef.current=!1}},o]});return y?D:(0,J.jsx)(qC,{elementsRef:p,labelsRef:d?void 0:f,children:D})}),aQ=Y.createContext(void 0);function ZWe(){let e=Y.useContext(aQ);if(e===void 0)throw Error(nr(20));return e}var QWe=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=KZ(),a=K(i,Q.mounted),o=K(i,Q.forceMounted);return a||n||o?(0,J.jsx)(aQ.Provider,{value:n,children:(0,J.jsx)(Vn,{ref:t,...r})}):null}),$We=Y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Cn,...g}=e,_=KZ(),{filteredItems:v}=JZ(),y=qZ(),b=ZWe(),x=K(_,Q.modal),S=K(_,Q.open),C=K(_,Q.mounted),w=K(_,Q.openMethod),T=K(_,Q.triggerElement),E=K(_,Q.inputElement),D=K(_,Q.inputGroupElement),O=K(_,Q.inputInsidePopup),k=K(_,Q.transitionStatus),A=v.length===0,j=Pn({anchor:i??(O?T:D??E),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});hr(S&&x&&w!==`touch`,T);let M=Y.useMemo(()=>{let e={...j.positionerStyles};return S||(e.pointerEvents=`none`),{role:`presentation`,hidden:!C,style:e}},[S,C,j.positionerStyles]),N={open:S,side:j.side,align:j.align,anchorHidden:j.anchorHidden,empty:A};$t(()=>{_.set(`popupSide`,j.side)},[_,j.side]);let P=Y.useMemo(()=>({side:j.side,align:j.align,arrowRef:j.arrowRef,arrowUncentered:j.arrowUncentered,arrowStyles:j.arrowStyles,anchorHidden:j.anchorHidden,isPositioned:j.isPositioned}),[j.side,j.align,j.arrowRef,j.arrowUncentered,j.arrowStyles,j.anchorHidden,j.isPositioned]),F=cr(`div`,e,{state:N,ref:[t,Wn(e=>{_.set(`positionerElement`,e)})],props:[M,Gn(k),g],stateAttributesMapping:En});return(0,J.jsxs)(tQ.Provider,{value:P,children:[C&&x&&(0,J.jsx)(sr,{inert:Jn(!S),cutout:D??E??T}),F]})}),eGe={...En,...tn},tGe=Y.forwardRef(function(e,t){let{render:n,className:r,initialFocus:i,finalFocus:a,...o}=e,s=KZ(),c=nQ(),l=qZ(),{filteredItems:u}=JZ(),d=K(s,Q.mounted),f=K(s,Q.open),p=K(s,Q.openMethod),m=K(s,Q.transitionStatus),h=K(s,Q.inputInsidePopup),g=K(s,Q.inputElement),_=K(s,Q.modal),v=u.length===0;vn({open:f,ref:s.state.popupRef,onComplete(){f&&s.state.onOpenChangeComplete(!0)}});let y=cr(`div`,e,{state:{open:f,side:c.side,align:c.align,anchorHidden:c.anchorHidden,transitionStatus:m,empty:v},ref:[t,s.state.popupRef],props:[{role:h?`dialog`:`presentation`,tabIndex:-1,onFocus(e){let t=ir(e.nativeEvent);p!==`touch`&&(vr(s.state.listElement,t)||t===e.currentTarget)&&s.state.inputRef.current?.focus()}},Gn(m),o],stateAttributesMapping:eGe}),b=i===void 0?h?e=>e===`touch`?s.state.popupRef.current:g:!1:i,x;x=a??(h?void 0:!1);let S=!h||_;return(0,J.jsx)(gn,{context:l,disabled:!d,modal:S,openInteractionType:p,initialFocus:b,returnFocus:x,getInsideElements:()=>[s.state.startDismissRef.current,s.state.endDismissRef.current],children:(0,J.jsxs)(Y.Fragment,{children:[y,S&&(0,J.jsx)(rQ,{ref:s.state.endDismissRef})]})})}),oQ=Y.createContext(void 0);function sQ(){let e=Y.useContext(oQ);if(!e)throw Error(nr(19));return e}var nGe=Y.createContext(!1);function rGe(){return Y.useContext(nGe)}var iGe=Y.memo(Y.forwardRef(function(e,t){let{render:n,className:r,value:i=null,index:a,disabled:o=!1,nativeButton:s=!1,...c}=e,l=Y.useRef(!1),u=Y.useRef(null),d=$C({index:a,textRef:u,indexGuessBehavior:QC.GuessFromOrder}),f=KZ(),p=rGe(),{flatFilteredItems:m,hasItems:h}=JZ(),g=K(f,Q.open),_=K(f,Q.selectionMode),v=K(f,Q.readOnly),y=K(f,Q.virtualized),b=K(f,Q.isItemEqualToValue),x=_!==`none`,S=a??(y?gW(m,i,b):d.index),C=d.index!==-1,w=K(f,Q.id),T=K(f,Q.isActive,S),E=K(f,Q.isSelected,i),D=K(f,Q.getItemProps),O=Y.useRef(null),k=w!=null&&C?`${w}-${S}`:void 0,A=E&&x;$t(()=>{if(!(C&&(y||a!=null)))return;let e=f.state.listRef.current;return e[S]=O.current,()=>{delete e[S]}},[C,y,S,a,f]),$t(()=>{if(!C||h)return;let e=f.state.valuesRef.current;return e[S]=i,_!==`none`&&f.state.allValuesRef.current.push(i),()=>{delete e[S]}},[C,h,S,i,f,_]),$t(()=>{if(!g){l.current=!1;return}if(!C||h)return;let e=f.state.selectedValue;mW(i,Array.isArray(e)?e[e.length-1]:e,b)&&f.set(`selectedIndex`,S)},[C,h,g,f,S,i,b]);let j={disabled:o,selected:A,highlighted:T},M=D({active:T,selected:A});M.id=void 0,M.onFocus=void 0;let{getButtonProps:N,buttonRef:P}=aw({disabled:o,focusableWhenDisabled:!0,native:s,composite:!0});function F(e){function t(){f.state.handleSelection(e,i)}f.state.submitOnItemClick?(Kr.flushSync(t),f.state.requestSubmit()):t()}let I={id:k,role:p?`gridcell`:`option`,"aria-selected":x?A:void 0,tabIndex:void 0,onPointerDownCapture(e){l.current=!0,e.preventDefault()},onClick(e){o||v||F(e.nativeEvent)},onMouseUp(e){let t=l.current;l.current=!1,!(o||v||e.button!==0||t||!T)&&F(e.nativeEvent)}},L=cr(`div`,e,{ref:[P,t,d.ref,O],state:j,props:[M,I,c,N]}),R=Y.useMemo(()=>({selected:A,textRef:u}),[A,u]);return(0,J.jsx)(oQ.Provider,{value:R,children:L})})),aGe=Y.forwardRef(function(e,t){let n=e.keepMounted??!1,{selected:r}=sQ();return n||r?(0,J.jsx)(oGe,{...e,ref:t}):null}),oGe=Y.memo(Y.forwardRef((e,t)=>{let{render:n,className:r,keepMounted:i,...a}=e,{selected:o}=sQ(),s=Y.useRef(null),{transitionStatus:c,setMounted:l}=An(o),u=cr(`span`,e,{ref:[t,s],state:{selected:o,transitionStatus:c},props:[{"aria-hidden":!0,children:`✔️`},a],stateAttributesMapping:tn});return vn({open:o,ref:s,onComplete(){o||l(!1)}}),u}));function cQ({id:e,value:t,stores:n,disabled:r,ariaLabel:i=`Store`,placeholder:a=`No Store selected`,onChange:o}){return(0,J.jsxs)(VWe,{items:n,filter:null,inputValue:t,itemToStringLabel:e=>e.id,itemToStringValue:e=>e.id,onInputValueChange:o,onValueChange:e=>{e&&o(e.id)},autoHighlight:!0,children:[(0,J.jsxs)(GWe,{className:fr(`border-border bg-background focus-within:ring-primary flex h-10 min-w-0 items-center rounded-md border focus-within:ring-1`,r&&`cursor-not-allowed opacity-50`),children:[(0,J.jsx)(WWe,{id:e,"aria-label":i,placeholder:a,disabled:r,className:`min-w-0 flex-1 bg-transparent px-3 text-sm outline-none`}),(0,J.jsx)(KWe,{"aria-label":`Show registered ${i} suggestions`,disabled:r,className:`text-muted-foreground hover:text-foreground inline-flex h-full w-9 shrink-0 items-center justify-center outline-none`,children:(0,J.jsx)(Zp,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,J.jsx)(QWe,{children:(0,J.jsx)($We,{sideOffset:4,className:`z-50 outline-none`,children:(0,J.jsx)(tGe,{className:`bg-popover text-popover-foreground border-border min-w-(--anchor-width) max-w-[calc(100vw-1rem)] overflow-hidden rounded-md border p-1 shadow-lg`,children:(0,J.jsxs)(XWe,{className:`scrollbar-thin scrollbar-track-transparent scrollbar-thumb-[color-mix(in_srgb,currentColor,transparent_78%)] max-h-56 overflow-y-auto overflow-x-hidden`,children:[n.map(e=>(0,J.jsxs)(iGe,{value:e,className:e=>fr(`grid min-w-0 cursor-default grid-cols-[1rem_minmax(0,1fr)] items-start gap-2 rounded-sm px-2 py-2 text-sm outline-none`,e.highlighted&&`bg-muted`,e.selected&&`text-foreground`),children:[(0,J.jsx)(aGe,{className:`text-primary col-start-1 flex h-4 w-4 items-center justify-center`,children:(0,J.jsx)(Xp,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,J.jsxs)(`span`,{className:`col-start-2 min-w-0`,children:[(0,J.jsx)(`span`,{className:`block break-all font-mono text-xs`,children:e.id}),(0,J.jsx)(`span`,{className:`text-muted-foreground block break-all text-[11px]`,children:e.root})]})]},e.id)),n.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground px-2 py-2 text-xs`,children:`No registered Stores available. You can still enter an exact Store id.`}):null]})})})})]})}function lQ(e){return e?.defaultStore.state===`configured`?e.defaultStore.id:``}function sGe({config:e,projectionLocked:t,refresh:n}){let r=uC(),i=VZ(e!==null),[a,o]=(0,Y.useState)(()=>lQ(e)),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(void 0),[d,f]=(0,Y.useState)(null),p=e?.defaultStore??null;(0,Y.useEffect)(()=>{if(e){if(l!==void 0){if(l===null&&p?.state===`absent`||l!==null&&p?.state===`configured`&&p.id===l){u(void 0),o(l??``),c(!1);return}if(t)return;u(void 0),o(lQ(e)),c(!1),f(`The configuration command completed, but the replacement projection settled with a different value. Review the current config and retry.`);return}s||o(lQ(e))}},[p,e,s,l,t]);let m=ji({mutationFn:async e=>{let t=await q.planningConfig.writeEnvironmentDefaultStore.mutate({value:e});return await n(),t},onSuccess:(e,t)=>{u(t),c(!1),f(null)},onError:e=>{f(e instanceof Error?e.message:String(e))}}),h=a.trim(),g=p?.state===`configured`?p.id:null,_=h.length>0&&h!==g&&!t&&!m.isPending&&l===void 0,v=p?.state!==`absent`&&!t&&!m.isPending&&l===void 0,y=r.context,b=y?.planningRoot?.source??null,x=y?.storeId??null,S=(0,Y.useMemo)(()=>l===void 0?r.status===`checking`?`Checking the effective Root Context.`:r.status===`blocked`?r.message:b===`global_default`&&x===g?`Effective fallback: ${x}`:g?b?`Configured fallback is not selected; current Root source is ${b}.`:`Configured fallback is not currently selected.`:b?`No machine fallback configured; current Root source is ${b}.`:`No machine fallback configured.`:`Configuration saved; waiting for replacement projections.`,[g,b,x,l,r]),C=i.data?.stores??[],w=i.error!==null||i.data?.available===!1,T=t||m.isPending||l!==void 0;return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Nce,{className:`text-muted-foreground h-4 w-4`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Default Store`}),(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:"Used only when no explicit Store, local root, or project `store:` pointer resolves."})]})]}),(0,J.jsx)(cQ,{id:`environment-default-store`,ariaLabel:`Default Store`,placeholder:`No machine default Store`,value:a,stores:C,disabled:T,onChange:e=>{T||(o(e),c(e!==(g??``)),f(null))}}),(0,J.jsxs)(`div`,{className:`text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[C.length>0?(0,J.jsxs)(`span`,{children:[C.length,` registered suggestions available`]}):null,w?(0,J.jsx)(`span`,{role:`status`,title:i.error?.message??i.data?.error?.message,children:`Suggestions unavailable; exact ids remain editable.`}):null]})]}),p?.state===`invalid`?(0,J.jsx)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive rounded-md border px-3 py-2 text-xs`,children:"The authored `defaultStore` value is invalid. Set an exact Store id or clear the field; the original value remains available in Raw JSON."}):null,(0,J.jsxs)(`div`,{role:r.status===`blocked`&&g?`alert`:`status`,className:`border-border bg-muted/30 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)(`div`,{className:`font-medium`,children:`Effective Root evidence`}),(0,J.jsx)(`div`,{className:`text-muted-foreground mt-1 break-words`,children:S})]}),d?(0,J.jsx)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive rounded-md border px-3 py-2 text-xs`,children:d}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,J.jsxs)(MC,{size:`sm`,pending:m.isPending&&m.variables!==null,settled:!s&&l===void 0,disabled:!_,onClick:()=>m.mutate(h),children:[(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),`Set default`]}),(0,J.jsxs)(MC,{size:`sm`,variant:`secondary`,pending:m.isPending&&m.variables===null,settled:p?.state===`absent`&&l===void 0,disabled:!v,onClick:()=>m.mutate(null),children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Clear`]})]})]})}function uQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dQ(e){return e===null||[`string`,`number`,`boolean`].includes(typeof e)?!0:Array.isArray(e)?e.every(dQ):uQ(e)&&Object.values(e).every(dQ)}function cGe(e){return uQ(e)&&Object.values(e).every(dQ)}function fQ({value:e}){if(e===null)return(0,J.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:`null`});if(typeof e==`string`)return(0,J.jsx)(`code`,{className:`bg-muted rounded px-1.5 py-0.5 text-xs`,children:e});if(typeof e==`number`||typeof e==`boolean`)return(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:String(e)});if(Array.isArray(e))return e.length===0?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`[]`}):(0,J.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>(0,J.jsxs)(`div`,{className:`border-border/60 rounded-md border px-2 py-1`,children:[(0,J.jsxs)(`div`,{className:`text-muted-foreground mb-1 font-mono text-[10px]`,children:[`[`,t,`]`]}),(0,J.jsx)(fQ,{value:e})]},`json-array-${t}`))});if(uQ(e)){let t=Object.entries(e);return t.length===0?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`{}`}):(0,J.jsx)(`div`,{className:`space-y-1.5`,children:t.map(([e,t])=>(0,J.jsxs)(`div`,{className:`border-border/60 rounded-md border px-2 py-1`,children:[(0,J.jsx)(`div`,{className:`mb-1 font-mono text-[10px] font-semibold`,children:e}),(0,J.jsx)(fQ,{value:t})]},`json-object-${e}`))})}return(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:String(e)})}function lGe({isStatic:e}){let[t,n]=(0,Y.useState)(`default-store`),[r,i]=(0,Y.useState)(`{}`),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),{data:d,isLoading:f,error:p,authority:m,refresh:h,refreshPending:g}=PZ(),_=d?.config,v=d?.evidence.path.success===!1||d?.evidence.config.success===!1||d?.evidence.config.contractError!==void 0,y=(0,Y.useRef)({hasProjection:d!=null&&d.config!==null,isLoading:f,subscriptionError:p,refreshPending:g,authorityCurrent:m.state===`current`,projectionHasCliError:v});y.current={hasProjection:d!=null&&d.config!==null,isLoading:f,subscriptionError:p,refreshPending:g,authorityCurrent:m.state===`current`,projectionHasCliError:v};let b=!y.current.hasProjection||y.current.isLoading||y.current.subscriptionError!==null||y.current.refreshPending||!y.current.authorityCurrent||y.current.projectionHasCliError;(0,Y.useEffect)(()=>{!uQ(_)||a||i(JSON.stringify(_,null,2))},[_,a]);let x=(0,Y.useCallback)(()=>{e||l||g||f||(u(!0),h())},[f,l,e,h,g]);(0,Y.useEffect)(()=>{g||u(!1)},[g]);let S=ji({mutationFn:e=>{let t=y.current;if(!t.hasProjection||t.isLoading||t.subscriptionError!==null||t.refreshPending||!t.authorityCurrent||t.projectionHasCliError)throw Error(`Environment Global projection is stale or unavailable.`);return q.planningConfig.writeEnvironmentGlobal.mutate({config:e})},onSuccess:()=>{o(!1),c(null)},onError:e=>{c(e instanceof Error?e.message:String(e))}}),C=(0,Y.useCallback)(async e=>{await S.mutateAsync(e),await h()},[h,S]),w=(0,Y.useCallback)(()=>{let e=y.current;if(!e.hasProjection||e.isLoading||e.subscriptionError!==null||e.refreshPending||!e.authorityCurrent||e.projectionHasCliError||S.isPending){c(`Environment Global projection is stale or unavailable.`);return}let t;try{t=JSON.parse(r)}catch(e){c(e instanceof Error?e.message:String(e));return}if(!cGe(t)){c(`Global config must be a JSON object.`);return}c(null),C(t).then(()=>n(`preview`)).catch(()=>void 0)},[r,C,S.isPending]),T=(0,Y.useMemo)(()=>{if(!d)return null;let e=d.evidence.path;if(!e.success)return e.stderr||`openspec config path failed with exit status ${e.exitCode??`unknown`}.`;let t=d.evidence.config;return t.success?t.contractError?`OpenSpec global config contract drift: ${t.contractError}`:null:t.stderr||`openspec config list failed with exit status ${t.exitCode??`unknown`}.`},[d]),E=(0,Y.useMemo)(()=>uQ(_)?Object.fromEntries(Object.entries(_).filter(([e])=>![`defaultStore`,`profile`,`delivery`,`workflows`,`featureFlags`].includes(e))):{},[_]);if(e)return(0,J.jsxs)(`section`,{className:`border-border bg-card flex min-h-0 flex-1 flex-col gap-4 overflow-hidden rounded-lg border p-4`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Environment Global Config`}),(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed p-4 text-sm`,children:`Environment Global Config is unavailable in static export mode.`})]});let D=p?.message??s??T,O=[{value:`default-store`,label:`Default Store`,disabled:S.isPending},{value:`preview`,label:`Preview`,disabled:S.isPending},{value:`editor`,label:`Raw JSON`,disabled:S.isPending}];return(0,J.jsxs)(`section`,{className:`border-border bg-card flex min-h-0 flex-1 flex-col gap-4 overflow-hidden rounded-lg border p-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-none flex-wrap items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Environment Global Config`}),d?(0,J.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[(0,J.jsx)(cw,{ariaLabel:`Environment Global config file path`,tooltip:d.file.path,children:`Config file`}),(0,J.jsx)(cw,{ariaLabel:`OpenSpec data scope source ${d.owner.dataScope.source}`,tooltip:d.owner.dataScope.path,children:d.owner.dataScope.source})]}):null]}),(0,J.jsxs)(`button`,{type:`button`,onClick:x,disabled:l||g||f||S.isPending,className:`border-border hover:bg-muted inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50`,children:[l?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(Fm,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`text-muted-foreground flex-none text-xs`,children:[`Reads from `,(0,J.jsx)(`code`,{children:`openspec config list --json`}),` and writes to the global config file.`]}),(0,J.jsx)(Yw,{value:t,onChange:n,options:O}),D?(0,J.jsx)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 rounded-md border px-3 py-2 text-xs`,children:D}):null,d?(0,J.jsx)(lw,{title:`CLI evidence`,summary:`config path + list + drift`,children:(0,J.jsxs)(`dl`,{className:`grid gap-x-3 gap-y-1 sm:grid-cols-[auto_minmax(0,1fr)]`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`config path exit`}),(0,J.jsx)(`dd`,{children:d.evidence.path.exitCode??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`config path stdout`}),(0,J.jsx)(`dd`,{className:`whitespace-pre-wrap break-all font-mono`,children:d.evidence.path.stdout||`(empty)`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`config path stderr`}),(0,J.jsx)(`dd`,{className:`whitespace-pre-wrap break-all font-mono`,children:d.evidence.path.stderr||`(empty)`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`config list exit`}),(0,J.jsx)(`dd`,{children:d.evidence.config.exitCode??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`config list stdout`}),(0,J.jsx)(`dd`,{className:`whitespace-pre-wrap break-all font-mono`,children:d.evidence.config.stdout||`(empty)`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`config list stderr`}),(0,J.jsx)(`dd`,{className:`whitespace-pre-wrap break-all font-mono`,children:d.evidence.config.stderr||`(empty)`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`drift stdout`}),(0,J.jsx)(`dd`,{className:`whitespace-pre-wrap break-all font-mono`,children:d.evidence.drift?.stdout||`(empty)`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`drift stderr`}),(0,J.jsx)(`dd`,{className:`whitespace-pre-wrap break-all font-mono`,children:d.evidence.drift?.stderr||`(empty)`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`contract`}),(0,J.jsx)(`dd`,{className:`break-all`,children:d.evidence.config.contractError??`compatible`})]})}):null,t===`default-store`?(0,J.jsx)(sGe,{config:d??null,projectionLocked:b,refresh:h}):t===`preview`?f&&!d?(0,J.jsx)(`div`,{className:`space-y-3 p-4`,"aria-busy":`true`,children:(0,J.jsx)(HC,{count:6})}):uQ(_)?(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-auto pr-1`,children:[(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`featureFlags`}),(0,J.jsx)(fQ,{value:_.featureFlags??{}})]}),Object.keys(E).length>0?(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`other fields`}),(0,J.jsx)(fQ,{value:E})]}):null]}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`Global config unavailable.`}):t===`editor`?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:[(0,J.jsx)(qP,{value:r,onChange:e=>{b||S.isPending||(i(e),o(!0),c(null))},onSaveShortcut:()=>{a&&!b&&!S.isPending&&w()},readOnly:b||S.isPending,filename:`openspec.global.config.json`,language:`json`,className:`min-h-0 flex-1`,editorMinHeight:`0px`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,disabled:b||S.isPending,onClick:()=>{b||!uQ(_)||(i(JSON.stringify(_,null,2)),o(!1),c(null))},className:`border-border hover:bg-muted rounded-md border px-3 py-1.5 text-xs disabled:cursor-not-allowed disabled:opacity-50`,children:`Revert`}),(0,J.jsxs)(MC,{size:`sm`,pending:S.isPending,settled:!a,disabled:b||S.isPending||!a||!uQ(_),onClick:w,children:[(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),`Save`]})]})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`Global config unavailable.`})]})}function uGe(){return(0,J.jsx)(_Z,{current:`environment`,header:(0,J.jsx)(vZ,{title:`Environment`,description:`Manage machine defaults and inspect the CLI-owned global configuration source.`,icon:(0,J.jsx)(Bm,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0})}),children:(0,J.jsx)(lGe,{isStatic:!1})})}var dGe=1;function pQ(e){return{...e,key:dGe++}}function mQ(e){return{storeId:e.store.state===`declared`?e.store.id:``,references:e.references.entries.map(pQ)}}function fGe(e,t){return JSON.stringify(e)===JSON.stringify(t)}function pGe(e,t){if(e.state!==`ready`)return!1;let n=e.data.planningRoot,r=t.data.planningRoot;return(n?.path??null)===(r?.path??null)&&(n?.source??null)===(r?.source??null)&&(n?.store_id??null)===(r?.store_id??null)&&e.data.storeId===t.data.storeId&&e.data.dataScope.path===t.data.dataScope.path&&e.data.dataScope.source===t.data.dataScope.source&&e.data.dataScope.environmentVariable===t.data.dataScope.environmentVariable}function mGe(e){return e.transition.state===`preview-error`}function hQ(e){return{...e,dirty:!0,generation:e.generation+1,formError:null,mutationEvidence:null,pending:null,convergenceError:null}}function hGe(e,t){if(t.type===`projection-observed`){let n=t.config;return e.pending?t.subscriptionError?{...e,formError:t.subscriptionError.message,pending:null,convergenceError:t.subscriptionError.message}:n?.rootPreview.state===`error`?{...e,formError:n.rootPreview.error.message,pending:null,convergenceError:n.rootPreview.error.message}:n&&e.pending.generation===e.generation&&fGe(n.binding,e.pending.result.launchWrite.binding)&&pGe(n.rootPreview,e.pending.result.rootPreview)?{...e,...mQ(n.binding),dirty:!1,formError:null,pending:null,convergenceError:null}:e:!n||e.dirty?e:{...e,...mQ(n.binding),formError:t.subscriptionError?e.formError:null}}return t.type===`store-edited`?{...hQ(e),storeId:t.value}:t.type===`reference-edited`?{...hQ(e),references:e.references.map(e=>e.key===t.key?{...e,...t.update}:e)}:t.type===`reference-added`?{...hQ(e),references:[...e.references,pQ({id:``,remote:void 0})]}:t.type===`reference-removed`?{...hQ(e),references:e.references.filter(e=>e.key!==t.key)}:t.type===`mutation-failed`?{...e,formError:t.error}:mGe(t.result)?{...e,mutationEvidence:t.result,pending:null,convergenceError:null,formError:t.result.transition.error.message}:{...e,mutationEvidence:t.result,pending:{generation:e.generation,result:t.result},convergenceError:null,formError:null}}var gGe={storeId:``,references:[],dirty:!1,generation:0,formError:null,mutationEvidence:null,pending:null,convergenceError:null};function _Ge(e){let[t,n]=(0,Y.useReducer)(hGe,gGe);return(0,Y.useEffect)(()=>{n({type:`projection-observed`,config:e.config,subscriptionError:e.subscriptionError})},[e.config,e.subscriptionError,t.pending]),{...t,pendingConvergence:t.pending?.result??null,editStore(e){n({type:`store-edited`,value:e})},editReference(e,t){n({type:`reference-edited`,key:e,update:t})},addReference(){n({type:`reference-added`})},removeReference(e){n({type:`reference-removed`,key:e})},mutationSucceeded(e){n({type:`mutation-succeeded`,result:e})},mutationFailed(e){n({type:`mutation-failed`,error:e instanceof Error?e.message:String(e)})}}}function gQ(e){return e.rootPreview.state===`ready`?{context:e.rootPreview.data,error:null}:{context:e.rootPreview.attempt,error:e.rootPreview.error}}function _Q({label:e,content:t}){return(0,J.jsx)(gh,{content:t,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":e,className:`text-muted-foreground hover:text-foreground focus-visible:ring-primary inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-offset-1`,children:(0,J.jsx)(Sm,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})})}function vGe({isStatic:e}){let{data:t,isLoading:n,error:r}=MZ(),i=VZ(!e&&t!=null),a=_Ge({config:t,subscriptionError:r}),{convergenceError:o,dirty:s,formError:c,mutationEvidence:l,pendingConvergence:u,references:d,storeId:f}=a,p=ji({mutationFn:async()=>{let e=[];for(let t of d){let n=t.id.trim(),r=t.remote?.trim();if(!n)throw Error(`Every Reference needs a Store id.`);e.push(r?{id:n,remote:r}:{id:n})}return q.planningConfig.updateProjectBinding.mutate({store:f.trim()||null,references:e.length>0?e:null})},onSuccess:a.mutationSucceeded,onError:a.mutationFailed}),m=t?gQ(t):null,h=m?[...m.context.diagnostics.root,...m.context.diagnostics.doctor,...m.context.diagnostics.context,...m.context.references.flatMap(e=>e.status)]:[],g=CC(`project-binding`,SWe({available:t!=null,loading:n,transportError:r?.message??null,mutationPending:p.isPending,dirty:s,convergencePending:u!==null,formError:c,convergenceError:o,failureDiagnostic:m?.error?.message??t?.binding.diagnostics[0]?.message??h.find(e=>e.severity===`error`)?.message??null,warningDiagnostic:h.find(e=>e.severity===`warning`)?.message??null}));if(e)return(0,J.jsx)(`div`,{...g,className:`text-muted-foreground rounded-md border border-dashed p-4 text-sm`,children:`Project Binding is not included in this static export.`});if(n&&!t)return(0,J.jsx)(`div`,{...g,className:`space-y-4`,"aria-busy":`true`,children:(0,J.jsx)(UC,{fields:4})});if(!t)return(0,J.jsx)(`div`,{...g,role:`alert`,className:`text-destructive rounded-md border p-4 text-sm`,children:r?.message??`Project Binding is unavailable.`});let _=gQ(t),v=r?.message??c,y=_.context.references.flatMap(e=>e.status),b=_.context.references.flatMap(e=>e.status.filter(e=>e.severity===`error`).map(t=>({storeId:e.store_id,diagnostic:t}))),x=l?.transition.state===`preview-error`?l.transition.error.message:o,S=x!==null&&x!==v&&x!==_.error?.message,C=i.data?.stores??[],w=i.error!==null||i.data?.available===!1,T=_.context.diagnostics.doctor.find(e=>e.severity===`warning`&&e.code===`root_pointer_ignored`),E=T!==void 0&&f.trim()===``;return(0,J.jsxs)(`div`,{...g,className:`@container min-w-0 space-y-5`,children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Project Binding`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground mt-1 break-all text-xs`,children:[`Launch project: `,t.owner.path]})]}),(0,J.jsxs)(MC,{size:`sm`,pending:p.isPending,settled:!s,onClick:()=>p.mutate(),disabled:!s||p.isPending,children:[(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),`Save binding`]})]}),(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsxs)(`section`,{className:`space-y-2`,"aria-labelledby":`project-binding-store-label`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`label`,{id:`project-binding-store-label`,htmlFor:`project-binding-store`,className:`text-xs font-medium`,children:`Planning Store`}),(0,J.jsx)(_Q,{label:`About Planning Store`,content:`Select a registered Store suggestion or enter an exact Store id. An empty value keeps the launch project's nearest OpenSpec root.`})]}),(0,J.jsx)(cQ,{id:`project-binding-store`,value:f,stores:C,disabled:p.isPending,placeholder:`No declared Store`,onChange:a.editStore}),(0,J.jsxs)(`div`,{className:`text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[C.length>0?(0,J.jsxs)(`span`,{children:[C.length,` registered suggestions available`]}):null,w?(0,J.jsx)(`span`,{role:`status`,title:i.error?.message??i.data?.error?.message,children:`Suggestions unavailable; exact ids remain editable.`}):null]}),T?(0,J.jsxs)(`div`,{role:`status`,className:`flex min-w-0 flex-wrap items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Store declaration ignored`}),(0,J.jsxs)(`p`,{className:`mt-0.5 font-mono opacity-75`,children:[T.severity,` · `,T.code,T.target?` · ${T.target}`:``]}),(0,J.jsx)(`p`,{className:`mt-0.5 break-words`,children:T.message}),T.fix?(0,J.jsx)(`p`,{className:`mt-1 break-words opacity-80`,children:T.fix}):null]}),E?(0,J.jsx)(`span`,{className:`shrink-0 font-medium`,children:`Removed in draft; save to apply.`}):(0,J.jsxs)(`button`,{type:`button`,disabled:p.isPending,onClick:()=>a.editStore(``),className:`border-current/30 inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-2 font-medium hover:bg-amber-500/10 disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Clear declaration`]})]}):null]}),(0,J.jsxs)(`section`,{className:`space-y-2`,"aria-labelledby":`project-binding-references`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`h3`,{id:`project-binding-references`,className:`text-xs font-medium`,children:`Read-only References`}),(0,J.jsx)(_Q,{label:`About References`,content:`References add Specs from registered Stores to this project's OpenSpec context without changing the writable Planning root.`})]}),(0,J.jsxs)(`button`,{type:`button`,disabled:p.isPending,onClick:a.addReference,className:`border-border hover:bg-muted inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs`,children:[(0,J.jsx)(Pm,{className:`h-3.5 w-3.5`}),`Add`]})]}),d.length>0?(0,J.jsx)(`div`,{className:`space-y-2`,children:d.map(e=>(0,J.jsxs)(`div`,{className:`@[36rem]:grid-cols-[minmax(8rem,0.75fr)_minmax(12rem,1.25fr)_2.5rem] grid min-w-0 gap-2`,children:[(0,J.jsx)(`input`,{value:e.id,disabled:p.isPending,onChange:t=>a.editReference(e.key,{id:t.target.value}),"aria-label":`Reference Store id`,placeholder:`Store id`,className:`border-border bg-background focus-visible:ring-primary h-10 min-w-0 rounded-md border px-3 text-sm outline-none focus-visible:ring-1`}),(0,J.jsx)(`input`,{value:e.remote??``,disabled:p.isPending,onChange:t=>a.editReference(e.key,{remote:t.target.value||void 0}),"aria-label":`Remote for ${e.id||`Reference`}`,placeholder:`Optional remote`,className:`border-border bg-background focus-visible:ring-primary h-10 min-w-0 rounded-md border px-3 text-sm outline-none focus-visible:ring-1`}),(0,J.jsx)(`button`,{type:`button`,disabled:p.isPending,onClick:()=>a.removeReference(e.key),"aria-label":`Remove Reference ${e.id||`row`}`,title:`Remove Reference`,className:`border-border text-muted-foreground hover:bg-muted hover:text-foreground inline-flex h-10 w-10 items-center justify-center rounded-md border`,children:(0,J.jsx)(Ym,{className:`h-4 w-4`})})]},e.key))}):(0,J.jsxs)(`div`,{className:`text-muted-foreground flex min-h-10 items-center gap-2 rounded-md border border-dashed px-3 text-xs`,children:[(0,J.jsx)(Em,{className:`h-3.5 w-3.5`}),`No read-only References declared.`]})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Current preview`}),(0,J.jsx)(cw,{ariaLabel:`Root preview source ${_.context.planningRoot?.source??`unknown`}`,tooltip:`Planning root: ${_.context.planningRoot?.path??`Not resolved`}`,children:_.context.planningRoot?.source??`unknown`}),_.context.storeId?(0,J.jsxs)(cw,{ariaLabel:`Root preview Store ${_.context.storeId}`,tooltip:`The current Root Context preview selected Store ${_.context.storeId}.`,children:[`Store `,_.context.storeId]}):null,(0,J.jsxs)(cw,{ariaLabel:`${_.context.references.length} observed References, ${b.length} errors, ${y.length} diagnostics`,tooltip:`${_.context.references.length} observed References · ${b.length} errors · ${y.length} diagnostics`,tone:b.length>0?`custom`:`muted`,className:b.length>0?`border-destructive/40 bg-destructive/10 text-destructive`:void 0,children:[`References `,_.context.references.length]})]}),_.error?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{children:_.error.message})]}):null,b.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{children:b.map(({storeId:e,diagnostic:t})=>`${e}: ${t.message}`).join(` `)})]}):null,t.binding.diagnostics.length>0?(0,J.jsx)(`div`,{className:`space-y-1`,role:`alert`,children:t.binding.diagnostics.map(e=>(0,J.jsx)(`div`,{className:`text-destructive border-destructive/40 bg-destructive/10 rounded-md border px-3 py-2 text-xs`,children:e.message},`${e.code}:${e.message}`))}):null,v?(0,J.jsx)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 rounded-md border px-3 py-2 text-xs`,children:v}):null,u?(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,role:`status`,children:`Binding saved; waiting for the Root Context subscription to converge.`}):null,S?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{children:x})]}):null,(0,J.jsx)(lw,{title:`Root preview and binding evidence`,summary:`${_.context.references.length} References${l?` · latest write`:``}`,children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h3`,{className:`font-medium`,children:`Root Context preview`}),(0,J.jsxs)(`dl`,{className:`@[32rem]:grid-cols-[auto_minmax(0,1fr)] grid min-w-0 gap-x-3 gap-y-1`,children:[(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Planning root`}),(0,J.jsx)(`dd`,{className:`break-all font-mono`,children:_.context.planningRoot?.path??`Not resolved`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Source`}),(0,J.jsx)(`dd`,{children:_.context.planningRoot?.source??`unknown`}),(0,J.jsx)(`dt`,{className:`text-muted-foreground`,children:`Store`}),(0,J.jsx)(`dd`,{children:_.context.storeId??`none`})]})]}),(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h3`,{className:`font-medium`,children:`Observed References`}),_.context.references.length>0?(0,J.jsx)(`div`,{className:`space-y-2`,children:_.context.references.map(e=>(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`font-medium`,children:[`Store: `,e.store_id]}),e.root?(0,J.jsxs)(`div`,{children:[`Root: `,e.root]}):null,e.status.length>0?(0,J.jsx)(`div`,{className:`text-muted-foreground mt-1 space-y-0.5`,children:e.status.map(e=>(0,J.jsxs)(`div`,{children:[e.severity,` · `,e.code,` · `,e.message]},`${e.code}:${e.message}`))}):(0,J.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:`No direct Doctor diagnostics observed.`})]},e.store_id))}):(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:`No Referenced Stores currently observed.`})]}),l?(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h3`,{className:`font-medium`,children:`Latest binding write`}),(0,J.jsxs)(`div`,{children:[`Launch write complete: `,l.launchWrite.file.path??`config file`]}),(0,J.jsxs)(`div`,{children:[`Root preview from this mutation:`,` `,l.rootPreview.state===`ready`?l.rootPreview.data.planningRoot?.path??`Not resolved`:l.rootPreview.attempt.planningRoot?.path??`Not resolved`]}),(0,J.jsxs)(`div`,{children:[`Transition: `,l.transition.state,l.transition.state===`preview-error`?` · ${l.transition.error.message}`:u?` · waiting for Root Context subscription`:o?` · Root Context subscription error: ${o}`:` · Root Context subscription matched the launch write`]})]}):null]})})]})}function yGe(){return(0,J.jsx)(_Z,{current:`project`,header:(0,J.jsx)(vZ,{title:`Project Binding`,description:`Declare the Store and read-only References owned by this launch project.`,icon:(0,J.jsx)(Em,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0})}),children:(0,J.jsx)(vGe,{isStatic:!1})})}function bGe({latest:e,mode:t,pending:n,retryDisabled:r,onReload:i,onRetry:a}){return(0,J.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-md border border-amber-500/40 bg-amber-500/10 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(Hm,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:`Active Root changed after this draft was loaded.`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:[`The physical file was not overwritten. Review revision`,` `,e.revision?.slice(0,15)??`latest`,`before reloading or retrying.`]}),t===`raw`?(0,J.jsx)(`p`,{className:`mt-1 text-xs text-amber-800 dark:text-amber-300`,children:`Retrying Raw YAML replaces the complete latest document, including external changes.`}):null]})]}),(0,J.jsxs)(`details`,{className:`border-border bg-background/70 rounded-md border p-2`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium`,children:`Review latest physical YAML`}),(0,J.jsx)(`pre`,{className:`text-muted-foreground mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap break-words text-xs`,children:e.content??``})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,J.jsxs)(Hn,{variant:`secondary`,size:`sm`,disabled:n,onClick:i,children:[(0,J.jsx)(Lm,{className:`h-3.5 w-3.5`}),`Reload latest`]}),(0,J.jsx)(Hn,{size:`sm`,disabled:n||r,onClick:a,children:`Retry against latest`})]})]})}function xGe({value:e,readOnly:t,onChange:n,onSaveShortcut:r}){return(0,J.jsx)(qP,{value:e,onChange:n,onSaveShortcut:r,readOnly:t,filename:`config.yaml`,className:`min-w-0`,editorMinHeight:`clamp(24rem, 60vh, 48rem)`})}function vQ(e){return e?.join(`
1330
1330
  `)??``}function yQ(e){return e.split(`
@@ -1332,7 +1332,7 @@ function handleMessage(payload) {
1332
1332
  `;function CQ(e,t){return e?.owner?.path===t?.owner?.path&&e?.filePath===t?.filePath&&e?.revision===t?.revision}function TGe(e){return e!==null&&e.owner!==null&&e.filePath!==null&&e.revision!==null}function wQ(e){return{ownerPath:e.owner.path,filePath:e.filePath,revision:e.revision}}function EGe({isStatic:e}){let{data:t,isLoading:n,isUpdating:r,error:i}=NZ(),a=uC(),[o,s]=(0,Y.useState)(`structured`),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(()=>bQ({schema:null,context:null,rules:null,operations:null})),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),w=(0,Y.useRef)(null),T=(0,Y.useRef)(a);T.current=a;let E=(0,Y.useRef)(i);E.current=i;let D=(0,Y.useRef)(n);D.current=n;let O=(0,Y.useRef)(r);O.current=r;let k=(0,Y.useRef)({structured:g,raw:v});k.current={structured:g,raw:v};let A=(0,Y.useCallback)(e=>{p(bQ(e.official)),h(e.exists?e.content??``:wGe),_(!1),y(!1)},[]);(0,Y.useEffect)(()=>{if(!t)return;let e=w.current;if(!(e&&t.revision!==e)){if(e===t.revision&&(w.current=null),!c){if(CQ(u,t))return;d(t),A(t),x(null),C(null);return}if(!u){d(t),A(t);return}CQ(u,t)||x(t)}},[u,t,c,A]);let j=ji({mutationFn:e=>{let t=T.current,n=E.current;if(t.disabled||n!==null||D.current||O.current)throw Error(t.message??n?.message??`Active Root is stale.`);return q.planningConfig.writeActiveRoot.mutate(e)},onSuccess:(e,t)=>{if(e.state===`conflict`){x(jZ(e.latest)),C(`The physical Active Root changed before this save could commit.`);return}if(e.state===`invalid`){C(e.diagnostics.map(({message:e})=>e).join(`
1333
1333
  `));return}let n=jZ(e.config);if(w.current=n.revision,d(n),x(null),C(null),t.mode===`structured`?(p(bQ(n.official)),_(!1)):(h(n.content??``),y(!1)),t.mode===`structured`?k.current.raw:k.current.structured){x(n),C(`The other mode retains an unsaved draft based on the previous revision.`);return}A(n),l(!1)}}),M=a.disabled||i!==null||n||r,N=c&&u!==null&&t!==void 0&&!CQ(u,t),P=M||N||b!==null,F=o===`structured`?g:v,I=CC(`active-root`,CWe({available:t!=null,loading:n,transportError:i?.message??null,mutationPending:j.isPending,editing:c,dirty:F,conflict:b!==null,authority:a.status,authorityTitle:a.title,authorityMessage:a.message,refreshing:r,exists:t?.exists??!1,errorDiagnostic:t?.diagnostics.find(e=>e.severity===`error`)?.message??null,warningDiagnostic:t?.diagnostics.find(e=>e.severity===`warning`)?.message??null})),L=(0,Y.useCallback)(()=>{!t||M||e||(d(t),A(t),t.exists||(o===`structured`?_(!0):y(!0)),x(null),C(null),j.reset(),l(!0))},[t,e,o,A,j,M]),R=(0,Y.useCallback)(()=>{t&&(d(t),A(t)),x(null),C(null),j.reset(),l(!1)},[t,A,j]),z=(0,Y.useCallback)(e=>{if(!TGe(e)){C(`Active Root owner, file, or revision evidence is unavailable.`);return}if(C(null),o===`raw`){j.mutate({mode:`raw`,...wQ(e),content:m});return}let t=SGe(f);if(!t.valid){C(t.errors.join(`
1334
1334
  `));return}j.mutate({mode:`structured`,...wQ(e),update:t.update})},[o,m,j,f]);if(n&&!t)return(0,J.jsx)(`div`,{...I,className:`space-y-4`,"aria-busy":`true`,children:(0,J.jsx)(UC,{fields:4})});if(!t)return(0,J.jsx)(`div`,{...I,role:`alert`,className:`text-destructive rounded-md border p-4 text-sm`,children:i?.message??`Active Root Config is unavailable.`});let B=i?.message??j.error?.message??S;return(0,J.jsxs)(`section`,{...I,"data-testid":`active-root-config-surface`,className:`@container min-w-0 space-y-4`,"aria-busy":n||r||j.isPending,children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Active Root Config`}),t.owner?(0,J.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-1.5 text-xs`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground break-all`,children:[`Planning root: `,t.owner.path]}),(0,J.jsx)(cw,{ariaLabel:`Active Root source ${t.owner.source}`,tooltip:`The CLI selected this root from source ${t.owner.source}.`,children:t.owner.source}),t.owner.storeId?(0,J.jsxs)(cw,{ariaLabel:`Active Root Store ${t.owner.storeId}`,tooltip:`Writes target Store ${t.owner.storeId}.`,children:[`Store `,t.owner.storeId]}):null,t.filePath?(0,J.jsx)(cw,{ariaLabel:`Active Root config file path`,tooltip:t.filePath,children:`Config file`}):null,t.revision?(0,J.jsxs)(cw,{ariaLabel:`Active Root config revision`,tooltip:t.revision,children:[`Revision `,t.revision.slice(7,15)]}):null]}):(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Static Active Root snapshot`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,J.jsx)(uw,{state:a}),(t.exists||c)&&(0,J.jsx)(`div`,{role:`tablist`,"aria-label":`Active Root editor mode`,className:`bg-muted flex rounded-md p-0.5`,children:[`structured`,`raw`].map(e=>(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e,disabled:j.isPending,onClick:()=>s(e),className:`inline-flex items-center gap-1.5 rounded px-2.5 py-1 text-xs font-medium ${o===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground`}`,children:[e===`structured`?(0,J.jsx)(wce,{className:`h-3.5 w-3.5`}):(0,J.jsx)(sm,{className:`h-3.5 w-3.5`}),e===`structured`?`Structured`:`Raw YAML`]},e))}),!e&&!M&&t.exists&&!c?(0,J.jsxs)(Hn,{variant:`secondary`,size:`sm`,onClick:L,children:[(0,J.jsx)(ile,{className:`h-3.5 w-3.5`}),`Edit`]}):null,c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Hn,{variant:`secondary`,size:`sm`,onClick:R,disabled:j.isPending,children:[(0,J.jsx)(pn,{className:`h-3.5 w-3.5`}),`Cancel`]}),(0,J.jsxs)(MC,{size:`sm`,pending:j.isPending,settled:!F,onClick:()=>z(u),disabled:j.isPending||P||!F,children:[(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),`Save `,o===`structured`?`Structured`:`Raw YAML`]})]}):null]})]}),t.owner?.externalToLaunchProject&&t.owner.storeId?(0,J.jsxs)(`div`,{role:`note`,"aria-label":`Shared Store write impact`,className:`rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs`,children:[`This Active Root belongs to shared Store `,(0,J.jsx)(`strong`,{children:t.owner.storeId}),`. Saves affect every project currently resolving this Store.`]}):null,t.diagnostics.length>0?(0,J.jsx)(`div`,{role:t.diagnostics.some(({severity:e})=>e===`error`)?`alert`:`note`,className:`border-border space-y-1 rounded-md border p-3 text-xs`,children:t.diagnostics.map(e=>(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`strong`,{children:e.path}),`: `,e.message]},`${e.code}:${e.path}`))}):null,B?(0,J.jsx)(`div`,{role:`alert`,className:`text-destructive whitespace-pre-wrap rounded-md border p-3 text-sm`,children:B}):null,!e&&a.disabled?(0,J.jsx)(dw,{state:a}):null,b?(0,J.jsx)(bGe,{latest:b,mode:o,pending:j.isPending,retryDisabled:M||!F,onReload:()=>{w.current=null,d(b),A(b),x(null),C(null),j.reset()},onRetry:()=>z(b)}):null,t.exists||c?(0,J.jsx)(`div`,{role:`tabpanel`,"aria-label":o===`structured`?`Structured Active Root editor`:`Raw YAML Active Root editor`,className:`min-w-0`,children:o===`structured`?(0,J.jsx)(CGe,{draft:f,readOnly:!c||j.isPending||P,onChange:e=>{p(e),_(!0),C(null),j.reset()}}):(0,J.jsx)(xGe,{value:m,readOnly:!c||j.isPending||P,onChange:e=>{h(e),y(!0),C(null),j.reset()},onSaveShortcut:()=>{c&&v&&!j.isPending&&!P&&z(u)}})}):(0,J.jsxs)(`div`,{className:`text-muted-foreground rounded-md border border-dashed p-4 text-sm`,children:[(0,J.jsx)(`p`,{className:`mb-3`,children:`No config file exists in the active Planning root.`}),!e&&!M?(0,J.jsx)(Hn,{size:`sm`,onClick:L,children:`Create Active Root config`}):null]})]})}function DGe(){let e=B();return(0,J.jsx)(_Z,{current:`root`,header:(0,J.jsx)(vZ,{title:`Active Root`,description:`Inspect and edit the configuration owned by the CLI-selected Planning Root.`,icon:(0,J.jsx)(um,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0})}),children:(0,J.jsx)(EGe,{isStatic:e})})}function OGe(){let{data:e,isLoading:t,error:n}=$f(),r=e?.schemas,i=r===void 0&&t&&n===null,a=r?.length===0&&n===null;return(0,J.jsx)(_Z,{current:`schemas`,header:(0,J.jsx)(vZ,{title:`Schemas`,description:`Browse resolved OpenSpec workflow schemas, then open one focused detail workspace.`,icon:(0,J.jsx)(Yp,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0})}),children:(0,J.jsxs)(`div`,{className:`space-y-4`,"data-schema-catalog":`true`,children:[n?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 flex items-start gap-2 rounded-lg border p-4 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Schema catalog refresh failed.`}),(0,J.jsx)(`p`,{children:n.message}),r===void 0?null:(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Retaining the last successful catalog while the replacement observation is unavailable.`})]})]}):null,i?(0,J.jsx)(`section`,{"aria-label":`Loading Schema catalog`,className:`border-border bg-card rounded-lg border p-4`,children:(0,J.jsx)(HC,{count:5})}):null,r&&r.length>0?(0,J.jsx)(PC,{active:t,children:(0,J.jsx)(`ul`,{className:`@[48rem]:grid-cols-2 grid gap-3`,children:r.map(e=>(0,J.jsx)(`li`,{className:`min-w-0`,children:(0,J.jsxs)(Rp,{to:`/config/schemas/${encodeURIComponent(e.name)}`,className:`border-border bg-card hover:border-primary/40 hover:bg-muted/40 focus-visible:ring-primary flex min-h-32 min-w-0 flex-col justify-between gap-4 rounded-lg border p-4 outline-none focus-visible:ring-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold`,children:e.name}),(0,J.jsx)(`span`,{className:`bg-muted text-muted-foreground shrink-0 rounded px-2 py-0.5 text-[10px]`,children:e.source})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-2 line-clamp-2 text-xs`,children:e.description||`No schema description provided.`})]}),(0,J.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-3 text-xs`,children:[(0,J.jsxs)(`span`,{children:[e.artifacts.length,` artifacts`]}),(0,J.jsxs)(`span`,{className:`text-foreground inline-flex items-center gap-1 font-medium`,children:[`Open`,(0,J.jsx)(Gp,{className:`h-3.5 w-3.5`,"aria-hidden":!0})]})]})]})},e.name))})}):null,a?(0,J.jsxs)(`section`,{className:`border-border bg-card text-muted-foreground flex min-h-40 flex-col items-center justify-center gap-2 rounded-lg border border-dashed p-6 text-center text-sm`,children:[(0,J.jsx)(Qce,{className:`h-6 w-6`,"aria-hidden":!0}),(0,J.jsx)(`p`,{children:`No schemas available.`})]}):null]})})}function kGe(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e.entries())if(t.get(n)!==r)return!1;return!0}function AGe(e){return Array.from({length:e+1},(t,n)=>n/e)}function TQ(e){return e===`ArrowDown`||e===`ArrowUp`||e===`PageDown`||e===`PageUp`||e===`Home`||e===`End`||e===` `}function jGe(e){return e===`auto`||e===`scroll`||e===`overlay`}function EQ(e,t={}){let{allowNonScrollable:n=!1}=t,r=e?.parentElement??null;for(;r;){if(jGe(window.getComputedStyle(r).overflowY)&&(n||r.scrollHeight>r.clientHeight))return r;r=r.parentElement}return null}function MGe(e){let{container:t,element:n,behavior:r=`auto`,margin:i=8}=e,a=n.getBoundingClientRect(),o=t.getBoundingClientRect(),s=a.top-o.top,c=a.bottom-o.top;if(s<i){t.scrollTo({top:Math.max(t.scrollTop+s-i,0),behavior:r});return}c>o.height-i&&t.scrollTo({top:t.scrollTop+c-o.height+i,behavior:r})}function NGe(e){if(e){let t=e.getBoundingClientRect();return{top:t.top,bottom:t.bottom}}return{top:0,bottom:window.innerHeight}}function PGe(e,t=EQ(e,{allowNonScrollable:!0})){if(typeof window>`u`||!e)return null;let n=e.getBoundingClientRect(),r=NGe(t);return Math.max(Math.floor(r.bottom-Math.max(n.top,r.top)),0)}function DQ({target:e,enabled:t=!0}){let[n,r]=(0,Y.useState)(null);return(0,Y.useLayoutEffect)(()=>{if(!t||typeof window>`u`){r(null);return}if(!e){r(null);return}let n=null,i=null,a=window,o=e=>{r(t=>t===e?t:e)},s=e=>{i!==e&&(a.removeEventListener(`scroll`,c),n&&i&&n.unobserve(i),i=e,a=e??window,a.addEventListener(`scroll`,c,{passive:!0}),n&&i&&n.observe(i))},c=()=>{let t=EQ(e,{allowNonScrollable:!0});s(t),o(PGe(e,t))};return typeof ResizeObserver<`u`&&(n=new ResizeObserver(()=>{c()}),n.observe(e),e.parentElement&&n.observe(e.parentElement)),c(),window.addEventListener(`resize`,c),()=>{window.removeEventListener(`resize`,c),a.removeEventListener(`scroll`,c),n?.disconnect()}},[t,e]),n}function FGe(e){if(e.length===0)return null;let t=[...e].sort((e,t)=>e.entry.boundingClientRect.top-t.entry.boundingClientRect.top);return(t.some(({entry:e})=>{let t=e.rootBounds?.top??0;return e.boundingClientRect.top<=t+1})?t[0]:t.at(-1))?.id??null}function IGe({ids:e,root:t=null,rootMargin:n,threshold:r,onBecomeVisible:i}){let a=(0,Y.useRef)(new Map),o=(0,Y.useRef)(new Map),s=(0,Y.useRef)(null),c=(0,Y.useRef)(new Map),[l,u]=(0,Y.useState)(()=>new Map),d=(0,Y.useRef)(i);d.current=i;let f=(0,Y.useMemo)(()=>JSON.stringify(r??[0]),[r]),p=(0,Y.useCallback)(e=>{kGe(c.current,e)||(c.current=e,u(new Map(e)))},[]);return(0,Y.useEffect)(()=>{if(!e)return;let t=new Set(e),n=!1;for(let[e,r]of a.current.entries())t.has(e)||(s.current?.unobserve(r),a.current.delete(e),o.current.delete(r),n=!0);let r=new Map(c.current);for(let e of r.keys())t.has(e)||(r.delete(e),n=!0);n&&p(r)},[e,p]),(0,Y.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{let t=new Map(c.current),n=[];for(let r of e){let e=r.target,i=o.current.get(e);if(!i)continue;let a=r.isIntersecting?r.intersectionRatio:0,s=c.current.get(i)??0;a>0?t.set(i,a):t.delete(i),s<=0&&a>0&&n.push({id:i,entry:r})}p(t),n.length>0&&d.current?.(n)},{root:t,rootMargin:n,threshold:r?[...r]:void 0});s.current=e;for(let t of a.current.values())e.observe(t);return()=>{e.disconnect(),s.current===e&&(s.current=null)}},[t,n,p,f,r]),{ratioById:l,setObservedNode:(0,Y.useCallback)((e,t)=>{let n=a.current.get(e);if(n!==t){if(n){s.current?.unobserve(n),a.current.delete(e),o.current.delete(n);let t=new Map(c.current);t.delete(e)&&p(t)}t&&(a.current.set(e,t),o.current.set(t,e),s.current?.observe(t))}},[p])}}var LGe=new Set([`generates`,`template`,`path`,`outputPath`]),RGe=new Set([`requires`,`tags`]),zGe=new Set([`id`,`generates`,`description`,`template`,`instruction`,`requires`]);function OQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function BGe(e){if(!e)return{data:null};try{let t=Iu(e);return OQ(t)?{data:t}:{data:null}}catch(e){return{data:null,error:e instanceof Error?e.message:String(e)}}}function VGe(e){let t=e.split(`/`);if(t.length<=1)return null;t.pop();let n=t.join(`/`);return n.length>0?n:null}function HGe(){let[e,t]=(0,Y.useState)(null);return{viewportHeight:DQ({target:e,enabled:e!==null}),setViewportNode:t}}function UGe(){let{schemaId:e}=ho({strict:!1}),t=Lp();return(0,J.jsx)(WGe,{schemaId:e,onNavigate:e=>void t({href:e})})}function WGe({onNavigate:e,schemaId:t}){let n=B(),{viewportHeight:r,setViewportNode:i}=HGe(),[a,o]=(0,Y.useState)(`read`),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(`file`),[C,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(null),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(null),F=(0,Y.useRef)(null),[I,L]=(0,Y.useState)(!0),[R,z]=(0,Y.useState)(``),[V,ee]=(0,Y.useState)(`init`),[te,ne]=(0,Y.useState)(`spec-driven`),re=uC(),ie=(0,Y.useRef)(re);ie.current=re;let{data:ae,isLoading:oe,error:se,authority:ce}=$f(),le=(0,Y.useRef)(ce);le.current=ce;let ue=ae?.schemas,de=ue===void 0&&oe&&se===null,fe=ue?.length===0&&se===null,pe=t,me=pe?ae?.schemaDetails[pe]??null:null,he=pe?ae?.schemaResolutions[pe]??null:null,{data:ge,isLoading:_e,error:ve}=zse(pe),{data:ye}=Rse(pe),{data:be}=Bse(pe),[xe,H]=(0,Y.useState)(null),[Se,Ce]=(0,Y.useState)({}),[we,Te]=(0,Y.useState)({}),Ee=!n&&!re.disabled&&ce.state===`current`&&he?.source!==void 0&&he.source!==`package`,De=Ee&&!n,Oe=(0,Y.useCallback)(()=>{let e=ie.current;if(e.disabled)throw Error(e.message??`Planning root is unavailable.`);if(le.current.state!==`current`)throw Error(`Schema configuration is refreshing; mutations remain read-only.`)},[]);(0,Y.useEffect)(()=>{a===`edit`&&!Ee&&o(`read`)},[Ee,a]),(0,Y.useEffect)(()=>{o(`read`),H(null),Ce({}),Te({}),u(null),O(null),A(null),M(null),P(null)},[pe]),(0,Y.useEffect)(()=>{if(!ge||ge.length===0){H(null);return}let e=ge.filter(e=>e.type===`file`);if(e.length===0){H(null);return}(!xe||!e.some(e=>e.path===xe))&&H(e.find(e=>e.path===`schema.yaml`)?.path??e[0].path)},[ge,xe]);let ke=(0,Y.useMemo)(()=>ge??[],[ge]),Ae=ge===void 0&&_e&&ve===null,je=!Ae&&(!ve||ke.length>0),Me=(0,Y.useMemo)(()=>!ke.length||!xe?null:ke.find(e=>e.path===xe&&e.type===`file`)??null,[ke,xe]),Ne=Me?Se[Me.path]:void 0,Pe=Me?!!we[Me.path]:!1;(0,Y.useEffect)(()=>{if(!Me||we[Me.path])return;let e=Me.content??``;Ce(t=>t[Me.path]===e?t:{...t,[Me.path]:e})},[Me,we]);let Fe=(0,Y.useMemo)(()=>ue?.find(e=>e.name===pe),[ue,pe]),Ie=(0,Y.useMemo)(()=>ue?.map(e=>({value:e.name,label:e.name}))??[],[ue]),Le=(0,Y.useMemo)(()=>{let e=`schema.yaml`,t=ke.find(t=>t.path===e),n=Se[e];return we[e]&&n!==void 0?n:t?.content??``},[we,Se,ke]),Re=(0,Y.useMemo)(()=>BGe(Le),[Le]),ze=Re.data,Be=(0,Y.useMemo)(()=>{if(!ze)return[];let e=ze.artifacts;return Array.isArray(e)?e.filter(OQ):[]},[ze]),Ve=(0,Y.useMemo)(()=>{let e=new Map;for(let t of Be){let n=typeof t.id==`string`?t.id:void 0;n&&e.set(n,t)}return e},[Be]),He=(0,Y.useMemo)(()=>me?.artifacts?.length?me.artifacts:Be.map((e,t)=>({id:typeof e.id==`string`?e.id:`artifact-${t+1}`,outputPath:typeof e.generates==`string`?e.generates:``,description:typeof e.description==`string`?e.description:void 0,requires:Array.isArray(e.requires)?e.requires.filter(e=>typeof e==`string`):[]})),[Be,me?.artifacts]),Ue=(0,Y.useMemo)(()=>{let e=new Map;for(let[t,n]of Object.entries(we)){if(!n)continue;let r=Se[t];r!==void 0&&e.set(t,r)}return e},[we,Se]),We=(0,Y.useMemo)(()=>Object.values(we).some(Boolean),[we]),Ge=(0,Y.useMemo)(()=>{if(!D)return null;let e=D.type===`file`,t=new TextEncoder,n=e?t.encode(D.content??``).length:void 0,r=D.path===`/`,i=D.type===`directory`?r?ke.length:ke.filter(e=>e.path.startsWith(D.path+`/`)).length:void 0;return{path:r?he?.displayPath??he?.path??`/`:D.path,type:D.type,source:he?.source??`unknown`,sizeBytes:n,childCount:i}},[D,ke,he]),Ke=(0,Y.useMemo)(()=>he?.displayPath?he.displayPath:he?.path?Qs(he.path,{source:he.source}):`project:openspec/schemas`,[he]),U=(0,Y.useMemo)(()=>({path:`/`,type:`directory`}),[]),qe=ji({mutationFn:async e=>{Oe(),pe&&await q.opsx.writeSchemaFile.mutate({schema:pe,path:e.path,content:e.content})},onSuccess:(e,t)=>{Te(e=>({...e,[t.path]:!1})),u(null)},onError:e=>{u(e instanceof Error?e.message:String(e))}}),Je=ji({mutationFn:async e=>{Oe(),pe&&await q.opsx.createSchemaFile.mutate({schema:pe,path:e.path,content:e.content})},onSuccess:(e,t)=>{u(null),g(!1),E(``),H(t.path)},onError:e=>{u(e instanceof Error?e.message:String(e))}}),Ye=ji({mutationFn:async e=>{Oe(),pe&&await q.opsx.createSchemaDirectory.mutate({schema:pe,path:e.path})},onSuccess:()=>{u(null),g(!1),E(``)},onError:e=>{u(e instanceof Error?e.message:String(e))}}),Xe=ji({mutationFn:async e=>{Oe(),pe&&await q.opsx.deleteSchemaEntry.mutate({schema:pe,path:e.path})},onSuccess:(e,t)=>{u(null),v(!1),O(null),Te(e=>{let n={...e};return delete n[t.path],n}),Ce(e=>{let n={...e};return delete n[t.path],n})},onError:e=>{u(e instanceof Error?e.message:String(e))}}),Ze=ji({mutationFn:async e=>{Oe();let t=e.mode===`init`?await q.opsx.initSchema.mutate({name:e.name}):await q.opsx.forkSchema.mutate({source:e.source,name:e.name});if(!t.success)throw Error(t.stderr||`Schema ${e.mode} failed.`);return t},onSuccess:()=>{c(null)},onError:e=>{c(e instanceof Error?e.message:String(e))}}),Qe=ji({mutationFn:async()=>{Oe(),pe&&await q.opsx.deleteSchema.mutate({name:pe})},onSuccess:()=>{c(null)},onError:e=>{c(e instanceof Error?e.message:String(e))}}),$e=(0,Y.useCallback)(e=>{e===`edit`&&!Ee||o(e)},[Ee]),et=(0,Y.useCallback)(e=>{Me&&(Ce(t=>({...t,[Me.path]:e})),Te(e=>({...e,[Me.path]:!0})))},[Me]),tt=(0,Y.useCallback)(()=>{Me&&(Ce(e=>({...e,[Me.path]:Me.content??``})),Te(e=>({...e,[Me.path]:!1})))},[Me]),nt=(0,Y.useCallback)(()=>{if(!Me||!Ee)return;let e=Ne??Me.content??``;qe.mutate({path:Me.path,content:e})},[Ne,Me,qe,Ee]),rt=(0,Y.useCallback)((e,t)=>{let n=t.trim().replace(/^\/+/,``),r=e?e.replace(/\/+$/,``):``;return r?`${r}/${n}`:n},[]),it=(0,Y.useCallback)((e,t)=>{!Ee||n||(u(null),S(e),w(t),E(``),g(!0))},[n,Ee]),at=(0,Y.useCallback)(()=>{if(!De)return;let e=T.trim();if(!e){u(`Name is required.`);return}if(e.includes(`..`)){u(`Name cannot include "..".`);return}let t=rt(C,e);if(!t){u(`Invalid path.`);return}if(x===`file`){Je.mutate({path:t,content:``});return}Ye.mutate({path:t})},[T,C,x,Ye,Je,rt,De]),ot=(0,Y.useCallback)(e=>{u(null),O(e),v(!0)},[]),st=(0,Y.useCallback)(()=>{!D||!De||Xe.mutate({path:D.path})},[D,De,Xe]),ct=(0,Y.useCallback)(e=>{O(e),b(!0)},[]),lt=(0,Y.useMemo)(()=>{let e=[];return De&&e.push({id:`new-file-root`,label:`New file`,icon:(0,J.jsx)(cm,{className:`h-3.5 w-3.5`}),onSelect:()=>it(`file`,null)},{id:`new-folder-root`,label:`New folder`,icon:(0,J.jsx)(_m,{className:`h-3.5 w-3.5`}),onSelect:()=>it(`directory`,null)}),e.push({id:`root-properties`,label:`Properties`,icon:(0,J.jsx)(Sm,{className:`h-3.5 w-3.5`}),onSelect:()=>ct(U)}),e},[De,it,ct,U]),ut=(0,Y.useMemo)(()=>[{id:`file-save`,label:`Save`,icon:(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),disabled:!Ee||!Pe,onSelect:()=>nt()},{id:`file-revert`,label:`Revert`,icon:(0,J.jsx)(pn,{className:`h-3.5 w-3.5`}),disabled:!Ee||!Pe,onSelect:()=>tt()}],[Pe,tt,nt,Ee]),dt=(0,Y.useMemo)(()=>[{id:`view-wrap`,label:I?`Disable line wrap`:`Enable line wrap`,onSelect:()=>L(e=>!e)}],[I]),ft=(0,Y.useCallback)(()=>{Ee&&(c(null),z(``),ee(`init`),ne(pe??`spec-driven`),f(!0))},[Ee,pe]),pt=(0,Y.useCallback)(()=>{!pe||!Ee||(c(null),m(!0))},[Ee,pe]),mt=(0,Y.useCallback)(()=>{if(!Ee)return;let t=R.trim();if(!t){c(`Schema name is required.`);return}let n=V===`fork`?{mode:`fork`,source:te.trim()||`spec-driven`,name:t}:{mode:`init`,name:t};Ze.mutate(n,{onSuccess:()=>{f(!1),e(`/config/schemas/${encodeURIComponent(t)}`)}})},[Ze,V,R,te,e,Ee]),ht=(0,Y.useCallback)(()=>{Ee&&Qe.mutate(void 0,{onSuccess:()=>{m(!1),e(`/config/schemas`)}})},[Qe,e,Ee]),gt=(0,Y.useCallback)((e,t)=>{if(t==null)return(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(Array.isArray(t)){if(t.length===0)return(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let n=t.filter(e=>typeof e==`string`);return RGe.has(e)&&n.length>0||n.length===t.length?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.map(e=>(0,J.jsx)(`span`,{className:`bg-muted rounded px-2 py-0.5 text-[10px]`,children:e},e))}):(0,J.jsx)(qP,{value:JSON.stringify(t,null,2),readOnly:!0,language:`json`,lineWrapping:!0})}return OQ(t)?(0,J.jsx)(qP,{value:JSON.stringify(t,null,2),readOnly:!0,language:`json`,lineWrapping:!0}):typeof t==`string`?e===`instruction`?(0,J.jsx)(`div`,{className:`bg-muted/30 rounded-lg p-4 [zoom:0.92]`,children:(0,J.jsx)(RU,{markdown:t,collectToc:!1})}):t.includes(`
1335
- `)?(0,J.jsx)(qP,{value:t,readOnly:!0,filename:`${e}.md`,lineWrapping:!0}):LGe.has(e)||t.includes(`/`)||t.endsWith(`.md`)||t.endsWith(`.yaml`)?(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:t}):(0,J.jsx)(`span`,{children:t}):(0,J.jsx)(`span`,{children:String(t)})},[]),_t=(0,J.jsx)(`section`,{"data-schema-detail-content":`true`,className:`min-w-0`,children:(0,J.jsxs)(`div`,{className:`space-y-4 pr-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(Yw,{value:a,onChange:$e,options:[{value:`read`,label:`Read`},{value:`preview`,label:`Preview`},{value:`edit`,label:`Edit`,disabled:!Ee}]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(uw,{state:re}),(0,J.jsxs)(`button`,{type:`button`,onClick:ft,disabled:!Ee||Ze.isPending,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Pm,{className:`h-3.5 w-3.5`}),`Add`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:pt,disabled:!Ee||Qe.isPending,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Delete`]})]})]}),!n&&re.disabled?(0,J.jsx)(dw,{state:re}):null,s&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:s}),l&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:l}),(0,J.jsx)(`div`,{ref:i,className:`flex min-h-0 flex-col`,style:r==null?void 0:{height:`${r}px`},children:Fe?a===`preview`?(0,J.jsx)(RU,{className:`min-h-0 flex-1`,markdown:({H1:e,H2:t,H3:n,Section:r})=>{let i=`schema-${Fe.name}`,a=e=>`${i}-${e}`;return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(e,{id:i,children:Fe.name}),Fe.description&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Fe.description})]}),he&&(0,J.jsxs)(r,{children:[(0,J.jsx)(t,{id:a(`resolution`),children:`Resolution`}),(0,J.jsxs)(`div`,{className:`text-muted-foreground mt-2 space-y-1 pl-4 text-sm`,children:[(0,J.jsxs)(`div`,{children:[`Source: `,he.source]}),(0,J.jsxs)(`div`,{className:`truncate`,children:[`Path: `,he.displayPath??he.path]}),he.shadows.length>0&&(0,J.jsxs)(`div`,{children:[`Shadows:`,` `,he.shadows.map(e=>`${e.source}(${e.displayPath??e.path})`).join(`, `)]})]})]}),Re.error&&(0,J.jsxs)(r,{children:[(0,J.jsx)(t,{id:a(`schema-errors`),children:`Schema errors`}),(0,J.jsxs)(`div`,{className:`border-destructive/40 bg-destructive/10 text-destructive mt-2 rounded-md border px-3 py-2 text-sm`,children:[`schema.yaml parse error: `,Re.error]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(t,{id:a(`artifacts`),children:`Artifacts`}),He.length>0?(0,J.jsx)(`div`,{className:`mt-3 space-y-6`,children:He.map(e=>{let t=Ve.get(e.id),i=be?.[e.id]??(ye?.[e.id]?{...ye[e.id],content:null}:null),o=i?.path??(typeof t?.template==`string`?t.template:void 0),s=i?.displayPath??o??null,c=o===void 0?void 0:Ue.get(o),l=c===void 0?i?i.content:null:c,u=[[`id`,t?.id??e.id],[`generates`,t?.generates??e.outputPath],[`description`,t?.description??e.description],[`instruction`,t?.instruction],[`requires`,t?.requires??e.requires]].filter(e=>e[1]!==void 0),d=t?Object.entries(t).filter(([e])=>!zGe.has(e)):[];return(0,J.jsxs)(r,{className:`space-y-3`,children:[(0,J.jsx)(n,{id:a(`artifact-${e.id}`),children:e.id}),(0,J.jsxs)(`div`,{className:`border-border space-y-4 rounded-lg border px-4 py-4 text-sm`,children:[(0,J.jsx)(`div`,{className:`space-y-3`,children:u.map(([e,t])=>{let n=e===`requires`,r=n&&Array.isArray(t)?t.filter(e=>typeof e==`string`):[];return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs font-semibold uppercase tracking-wide`,children:e}),(0,J.jsx)(`div`,{className:`pl-4 text-sm leading-6`,children:n?r.length>0?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>He.some(t=>t.id===e)?(0,J.jsx)(`a`,{href:`#${a(`artifact-${e}`)}`,className:`bg-primary hover:bg-primary/80 text-primary-foreground rounded-md px-2 py-0.5 text-xs transition-colors`,children:e},e):(0,J.jsx)(`span`,{className:`bg-muted text-muted-foreground rounded-md px-2 py-0.5 text-xs`,children:e},e))}):(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):gt(e,t)})]},e)})}),o&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs font-semibold uppercase tracking-wide`,children:`Template`}),(0,J.jsxs)(`div`,{className:`text-muted-foreground pl-4 text-xs`,children:[(0,J.jsx)(`span`,{className:`mr-1`,children:`Template:`}),(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:s}),i?.source?` (${i.source})`:null]}),l==null?(0,J.jsx)(`div`,{className:`text-muted-foreground pl-4 text-sm`,children:`Template content unavailable.`}):(0,J.jsx)(`div`,{className:`pl-4`,children:(0,J.jsx)(`div`,{className:`bg-muted/30 rounded-lg p-4 [zoom:0.86]`,children:(0,J.jsx)(RU,{markdown:l,collectToc:!1})})})]}),d.length>0&&(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs font-semibold uppercase tracking-wide`,children:`Extra fields`}),d.map(([e,t])=>(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e}),(0,J.jsx)(`div`,{className:`pl-4 text-sm leading-6`,children:gt(e,t)})]},e))]})]})]},e.id)})}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`Select a schema to view details.`}),me?.applyRequires?.length?(0,J.jsxs)(`div`,{className:`text-muted-foreground mt-3 text-xs`,children:[`Apply requires: `,me.applyRequires.join(`, `)]}):null]}),We&&(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Preview is rendering draft content. Save to persist changes.`})]})}}):(0,J.jsxs)(XP,{ref:F,className:`flex min-h-0 flex-1 flex-col gap-4`,children:[ve&&(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive text-xs`,children:[`Failed to load schema files: `,ve.message]}),Ae?(0,J.jsx)(HC,{count:6}):je?(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(eF,{entries:ke,selectedPath:xe,onSelect:H,breadcrumbRoot:Ke,headerLabel:(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Files`}),(0,J.jsx)(`span`,{className:`text-muted-foreground/80 truncate text-[10px] normal-case`,title:Ke,children:Ke})]}),headerActions:lt.length>0?(0,J.jsx)(ZP,{children:(0,J.jsx)(`button`,{type:`button`,onClick:e=>{M(null),P(null),A({type:`target`,element:e.currentTarget,placement:`bottom-end`})},className:`hover:bg-muted rounded-md p-1`,"aria-label":`Schema menu`,children:(0,J.jsx)(am,{className:`h-4 w-4`})})}):void 0,entryActions:e=>{let t={id:`properties`,label:`Properties`,icon:(0,J.jsx)(Sm,{className:`h-3.5 w-3.5`}),onSelect:()=>ct(e)};if(a!==`edit`||!De)return[t];let n=e.type===`directory`?e.path:VGe(e.path),r=e.type===`directory`;return[{id:`new-file`,label:r?`New file inside`:`New sibling file`,icon:(0,J.jsx)(cm,{className:`h-3.5 w-3.5`}),onSelect:()=>it(`file`,n)},{id:`new-folder`,label:r?`New folder inside`:`New sibling folder`,icon:(0,J.jsx)(_m,{className:`h-3.5 w-3.5`}),onSelect:()=>it(`directory`,n)},t,{id:`delete`,label:`Delete`,icon:(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),tone:`destructive`,onSelect:()=>ot(e)}]},emptyState:(0,J.jsx)(`span`,{children:`No files found for this schema.`}),renderEditor:e=>e?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[a===`edit`&&(0,J.jsxs)(`div`,{className:`border-border/50 flex items-center justify-between border-b px-3 py-2 text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(ZP,{children:(0,J.jsx)(`button`,{type:`button`,onClick:e=>{A(null),P(null),M({type:`target`,element:e.currentTarget,placement:`bottom-start`})},className:`hover:bg-muted rounded-md px-2 py-1 text-xs font-semibold`,children:`File`})}),(0,J.jsx)(ZP,{children:(0,J.jsx)(`button`,{type:`button`,onClick:e=>{A(null),M(null),P({type:`target`,element:e.currentTarget,placement:`bottom-start`})},className:`hover:bg-muted rounded-md px-2 py-1 text-xs font-semibold`,children:`View`})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:tt,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:[(0,J.jsx)(pn,{className:`h-3.5 w-3.5`}),`Cancel`]}),(0,J.jsxs)(Hn,{size:`sm`,onClick:nt,disabled:qe.isPending||!Ee,activity:qe.isPending,children:[(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),`Save`]})]})]}),(0,J.jsx)(tF,{file:e,value:a===`edit`?Ne??e.content??``:e.content??``,readOnly:a!==`edit`||!Ee,onChange:a===`edit`?et:void 0,lineWrapping:I,editorMinHeight:`0px`}),he?.source===`package`&&(0,J.jsx)(`div`,{className:`text-muted-foreground border-border/50 border-t px-3 py-2 text-xs`,children:`Package-provided schemas are read-only.`})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground flex h-full items-center justify-center`,children:`Select a file to view`})})}):null,(0,J.jsx)(YP,{open:!!k,items:lt,anchor:k,boundaryElement:F.current,onClose:()=>A(null)}),(0,J.jsx)(YP,{open:!!j,items:ut,anchor:j,boundaryElement:F.current,onClose:()=>M(null)}),(0,J.jsx)(YP,{open:!!N,items:dt,anchor:N,boundaryElement:F.current,onClose:()=>P(null)})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`Select a schema to view details.`})})]})});return(0,J.jsx)(_Z,{current:`schemas`,header:(0,J.jsx)(vZ,{backHref:`/config/schemas`,backLabel:`Schemas`,title:pe?`Schema: ${pe}`:`Schema`,description:`Inspect resolved schema facts, preview artifacts, and edit writable physical files.`,icon:(0,J.jsx)(wm,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0})}),children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(GS,{open:d,onClose:()=>f(!1),title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(wm,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Add schema`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:mt,disabled:!Ee||!R.trim()||Ze.isPending,"aria-busy":Ze.isPending||void 0,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Pm,{className:`h-3.5 w-3.5`}),`Create`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:`Schema name`}),(0,J.jsx)(`input`,{value:R,disabled:!Ee||Ze.isPending,onChange:e=>{z(e.target.value),c(null)},placeholder:`schema-name`,className:`border-border bg-card w-full rounded-md border px-3 py-2 text-sm`})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:`Create mode`}),(0,J.jsx)(Yw,{value:V,onChange:ee,options:[{value:`init`,label:`Init`,disabled:!Ee},{value:`fork`,label:`Fork`,disabled:!Ee}]})]}),V===`fork`&&(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:`Fork from`}),(0,J.jsx)(YW,{value:te,options:Ie,onValueChange:ne,ariaLabel:`Fork from`,disabled:!Ee,className:`w-full`})]}),s&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:s})]})}),(0,J.jsx)(GS,{open:p,onClose:()=>m(!1),borderVariant:`error`,title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ym,{className:`text-destructive h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Delete schema`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:ht,disabled:!Ee||Qe.isPending,"aria-busy":Qe.isPending||void 0,className:`bg-destructive text-destructive-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Delete`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,J.jsxs)(`p`,{children:[`This will permanently delete`,` `,(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:pe}),` and all of its template files.`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`This action cannot be undone.`}),s&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:s})]})}),(0,J.jsx)(GS,{open:h,onClose:()=>{g(!1),u(null)},title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x===`file`?(0,J.jsx)(cm,{className:`h-4 w-4`}):(0,J.jsx)(_m,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:x===`file`?`New file`:`New folder`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:at,disabled:!De||!T.trim()||Je.isPending||Ye.isPending,"aria-busy":Je.isPending||Ye.isPending||void 0,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[x===`file`?(0,J.jsx)(cm,{className:`h-3.5 w-3.5`}):(0,J.jsx)(_m,{className:`h-3.5 w-3.5`}),`Create`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,J.jsxs)(`div`,{className:`text-muted-foreground text-xs`,children:[`Parent: `,(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:C??`/`})]}),(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:x===`file`?`File name`:`Folder name`}),(0,J.jsx)(`input`,{value:T,disabled:!De||Je.isPending||Ye.isPending,onChange:e=>{E(e.target.value),u(null)},placeholder:x===`file`?`new-file.md`:`new-folder`,className:`border-border bg-card w-full rounded-md border px-3 py-2 text-sm`})]}),l&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:l})]})}),(0,J.jsx)(GS,{open:_,onClose:()=>{v(!1),O(null)},borderVariant:`error`,title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ym,{className:`text-destructive h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Delete entry`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:st,disabled:!De||!D||Xe.isPending,"aria-busy":Xe.isPending||void 0,className:`bg-destructive text-destructive-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Delete`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,J.jsxs)(`p`,{children:[`This will permanently delete`,` `,(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:D?.path??`selected entry`}),`.`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`This action cannot be undone.`}),l&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:l})]})}),(0,J.jsx)(GS,{open:y,onClose:()=>{b(!1),O(null)},title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Sm,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Entry properties`})]}),footer:(0,J.jsx)(`button`,{type:`button`,onClick:()=>b(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Close`}),children:(0,J.jsx)(`div`,{className:`space-y-2 text-sm`,children:Ge?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Path`}),(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:Ge.path})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Type`}),(0,J.jsx)(`span`,{children:Ge.type})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,J.jsx)(`span`,{children:Ge.source})]}),Ge.sizeBytes!==void 0&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Size`}),(0,J.jsxs)(`span`,{children:[Ge.sizeBytes,` bytes`]})]}),Ge.childCount!==void 0&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Items`}),(0,J.jsx)(`span`,{children:Ge.childCount})]})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`No entry selected.`})})}),(0,J.jsxs)(`div`,{"data-schema-workspace-status":`true`,className:`space-y-4`,children:[se?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 flex items-start gap-2 rounded-lg border p-4 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Schema catalog refresh failed.`}),(0,J.jsx)(`p`,{children:se.message})]})]}):null,de?(0,J.jsx)(`section`,{"aria-label":`Loading Schema detail`,className:`border-border bg-card rounded-lg border p-4`,children:(0,J.jsx)(HC,{count:6})}):null,fe?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-lg border border-dashed p-4 text-sm`,children:`No schemas available.`}):null,ue!==void 0&&ue.length>0&&!Fe?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive rounded-lg border p-4 text-sm`,children:[`Schema `,pe||`(missing id)`,` was not found.`]}):null,Fe?_t:null]})]})})}function kQ(e){let t=e.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`);return t===`/`?t:t.replace(/\/$/,``)}function AQ(e){let t=e?.planningRoot?.path;if(!e||!t)return`unresolved`;let n=e.launchProject.physicalPath;return n?kQ(n)===kQ(t)?`collapsed`:`distinct`:`unresolved`}function GGe(e){if(Number.isFinite(e.observedAt)&&e.observedAt>0)return e.observedAt;let t=Date.parse(e.timestamp);return Number.isFinite(t)?t:null}function KGe(e){if(!e)return null;let t=e.meta.referencePolicy,n=t?t.kind===`include`?{kind:`include`,sources:t.referenceSources}:t.kind===`omit`?{kind:`omit`,sourceCount:t.referenceSourceCount}:{kind:`none`}:{kind:`unrecorded`};return{observedAt:GGe(e.meta),projectName:e.meta.projectName,referencePolicy:n,root:e.meta.root??null,version:e.meta.version}}var qGe=(0,Y.createContext)({snapshot:null,basePath:`/`,isStatic:!1});function JGe(){return(0,Y.useContext)(qGe).snapshot}function YGe(){let e=KGe(JGe()??L());return(0,J.jsx)(_Z,{current:`context`,header:(0,J.jsx)(yZ,{status:`static`}),children:e?(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`section`,{className:`border-border min-w-0 border-y py-3`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Published effective root`}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 break-all font-mono text-sm font-medium`,children:e.root?.planningRootPath??`No planning root path was published.`})]}),e.root?(0,J.jsx)(cw,{ariaLabel:`Published root source ${e.root.rootSource}`,tooltip:`OpenSpec reported root source ${e.root.rootSource} at export time.`,children:e.root.rootSource}):null,e.root?.storeId?(0,J.jsxs)(cw,{ariaLabel:`Published Store ${e.root.storeId}`,tooltip:`The exported Planning root used Store ${e.root.storeId}.`,children:[`Store `,e.root.storeId]}):null,(0,J.jsx)(cw,{ariaLabel:`Static Context evidence boundary`,tooltip:`Only publication-safe facts are available; this snapshot has no live authority.`,children:`Published facts`})]})}),(0,J.jsx)(XGe,{policy:e.referencePolicy}),(0,J.jsxs)(lw,{title:`Publication details`,summary:`${e.projectName} · OpenSpecUI ${e.version}`,children:[(0,J.jsxs)(`dl`,{className:`text-muted-foreground grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:[(0,J.jsx)(`dt`,{children:`project`}),(0,J.jsx)(`dd`,{className:`break-words`,children:e.projectName}),(0,J.jsx)(`dt`,{children:`OpenSpecUI version`}),(0,J.jsx)(`dd`,{children:e.version}),(0,J.jsx)(`dt`,{children:`observed at`}),(0,J.jsx)(`dd`,{children:e.observedAt===null?`unavailable`:new Date(e.observedAt).toISOString()})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-3 break-words`,children:`Runtime CLI evidence, registry, and data scope are not published. This snapshot claims no live connection, mutation authority, or current Reference health.`})]})]}):(0,J.jsxs)(`section`,{className:`border-border rounded-lg border p-4`,role:`status`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Static Context unavailable`}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-sm`,children:`This export does not contain a readable snapshot.`})]})})}function XGe({policy:e}){return(0,J.jsx)(lw,{title:`Published Reference policy`,summary:e.kind===`none`?`None recorded`:e.kind===`omit`?`${e.sourceCount} omitted`:e.kind===`unrecorded`?`Legacy unrecorded`:`${e.sources.length} included`,children:e.kind===`none`?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No effective References were recorded when this snapshot was exported.`}):e.kind===`omit`?(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[e.sourceCount,` Reference sources were observed and omitted from this export. Their identities and content were not published.`]}):e.kind===`unrecorded`?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`This snapshot predates the explicit Reference export policy.`}):(0,J.jsx)(`ul`,{className:`divide-border divide-y`,children:e.sources.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center justify-between gap-3 py-2 first:pt-0 last:pb-0`,children:[(0,J.jsx)(`span`,{className:`min-w-0 break-all font-mono text-sm`,children:e.storeId}),(0,J.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[e.specCount,` published Specs · export state `,e.state]})]},e.storeId))})})}function ZGe(){return B()?(0,J.jsx)(YGe,{}):(0,J.jsx)(QGe,{})}function QGe(){let{data:e,isLoading:t,error:n,authority:r}=eC(),i=QS(e),a=e?.state===`error`?e.error:null,o=!n&&!a&&(t||e?.state===`loading`)&&i===null,s=e?.state===`error`?e.data:null,c=e?.state===`error`?e.attempt:null,l=n||a||r.state===`failed`?`blocked`:o?`resolving`:e?.state===`refreshing`||r.state!==`current`?`refreshing`:`ready`,u=i?[...i.diagnostics.root,...i.diagnostics.doctor,...i.diagnostics.context,...i.references.flatMap(e=>e.status)]:[],d=CC(`resolved-context`,TWe({available:i!==null,loading:o,transportError:n?.message??a?.message??null,authorityFailed:r.state===`failed`,refreshing:e?.state===`refreshing`,authorityCurrent:r.state===`current`,hasPlanningRoot:i?.planningRoot!==null&&i?.planningRoot!==void 0,cliAvailable:i?.cli.available??!1,cliError:i?.cli.error??null,errorDiagnostic:u.find(e=>e.severity===`error`)?.message??null,warningDiagnostic:u.find(e=>e.severity===`warning`)?.message??null}));return(0,J.jsx)(_Z,{current:`context`,header:(0,J.jsx)(yZ,{status:l}),children:(0,J.jsxs)(`div`,{...d,className:`space-y-6`,children:[o?(0,J.jsx)(HC,{count:4}):null,n||a?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 flex items-start gap-2 rounded-lg border p-4 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Root Context is not ready.`}),(0,J.jsx)(`p`,{children:n?.message??a?.message}),e?.state===`error`&&e.data?(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Showing the last successful observation while retaining the failed CLI attempt.`}):null]})]}):null,!o&&s&&c?(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsx)(jQ,{label:`Last successful Context (stale)`,context:s}),(0,J.jsx)(jQ,{label:`Current failed attempt`,context:c,rootHeading:`Attempted planning root`})]}):!o&&c?(0,J.jsx)(jQ,{label:`Current failed attempt`,context:c,rootHeading:`Attempted planning root`}):!o&&i?(0,J.jsx)(PC,{active:e?.state===`refreshing`,children:(0,J.jsx)(MQ,{context:i,actionStatus:e?.state===`ready`&&r.state===`current`?`ready`:r.state===`failed`?`blocked`:`checking`})}):null]})})}function jQ({context:e,label:t,rootHeading:n}){return(0,J.jsxs)(`section`,{"aria-label":t,className:`space-y-3`,children:[(0,J.jsx)(`h2`,{className:`text-muted-foreground text-xs font-semibold uppercase`,children:t}),(0,J.jsx)(MQ,{context:e,rootHeading:n})]})}function MQ({actionStatus:e=`blocked`,context:t,rootHeading:n=`Active planning root`}){let r=t.planningRoot,i=[...t.diagnostics.root,...t.diagnostics.doctor,...t.diagnostics.context],a=t.references.flatMap(e=>e.status.filter(e=>e.severity===`error`).map(t=>`${e.store_id}: ${t.message}`)),o=[t.evidence.doctor?.contractError?`Doctor contract drift: ${t.evidence.doctor.contractError}`:null,t.evidence.context?.contractError?`Context contract drift: ${t.evidence.context.contractError}`:null].filter(e=>e!==null),s=t.references.reduce((e,t)=>e+t.status.length,0),c=AQ(t),l=i.filter(e=>e.severity===`warning`&&e.code===`root_pointer_ignored`),u=i.filter(e=>e.severity===`error`),d=i.filter(e=>e.severity!==`error`),f=c===`collapsed`?{label:`Single project root`,tooltip:`Launch and Planning resolve to the same physical project root.`}:c===`distinct`?{label:`Separate roots`,tooltip:`Launch and Planning resolve to different physical roots.`}:{label:`Relationship unresolved`,tooltip:`The server has not observed enough physical identity evidence to compare the roots.`};return(0,J.jsxs)(`div`,{className:`@container min-w-0 space-y-4`,children:[(0,J.jsxs)(`section`,{"aria-label":`Operational Context`,className:`border-border min-w-0 divide-y border-y`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:c===`collapsed`?`Project root`:n}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 break-all font-mono text-sm font-medium`,children:r?.path??`No planning root resolved.`})]}),r?(0,J.jsx)(cw,{ariaLabel:`Planning root source ${r.source}`,tooltip:`OpenSpec selected this root from source: ${r.source}.`,children:r.source}):null,t.storeId?(0,J.jsxs)(cw,{ariaLabel:`Planning Store ${t.storeId}`,tooltip:`The CLI-selected Planning root uses Store ${t.storeId}.`,children:[`Store `,t.storeId]}):null,(0,J.jsx)(cw,{ariaLabel:`Root relationship ${f.label.toLowerCase()}`,tooltip:f.tooltip,children:f.label}),l.length>0?(0,J.jsx)(cw,{ariaLabel:`Ignored Store declaration warning`,tooltip:`OpenSpec ignored the Store declaration because a real project root takes precedence. See CLI diagnostics for the reported fix.`,tone:`custom`,className:`border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200`,children:`Store declaration ignored`}):null]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-4 py-3 ${c===`collapsed`?``:`@[36rem]:grid-cols-2`}`,children:[c===`collapsed`?null:(0,J.jsx)(NQ,{label:`Launch project`,value:t.launchProject.path,mono:!0}),(0,J.jsx)(NQ,{label:`References`,value:`${t.references.length} observed`,detail:`${s} CLI diagnostics`})]})]}),t.cli.error?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),t.cli.error]}):null,a.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),a.join(` `)]}):null,o.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),o.join(` `)]}):null,u.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:u.map(e=>`${e.code}: ${e.message}`).join(` `)})]}):null,(0,J.jsx)(lw,{title:`Referenced context`,summary:`${t.references.length} References · ${t.contextMembers.length} members`,children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[t.references.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No reference currently observed.`}):(0,J.jsx)(`ul`,{className:`divide-border divide-y`,children:t.references.map(e=>(0,J.jsxs)(`li`,{className:`space-y-1 py-2 first:pt-0 last:pb-0`,children:[(0,J.jsx)(`p`,{className:`break-all font-mono`,children:e.store_id}),e.status.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No CLI diagnostic reported.`}):e.status.map(e=>(0,J.jsxs)(`p`,{className:`break-words`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.code}),`: `,e.message]},`${e.code}:${e.message}`))]},e.store_id))}),(0,J.jsx)(PQ,{label:`Context members`,value:t.contextMembers})]})}),(0,J.jsx)($Ge,{context:t,actionStatus:e}),(0,J.jsx)(lw,{title:`CLI diagnostics`,summary:d.length===0?`No supporting diagnostics`:`${d.length} supporting`,children:d.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No supporting CLI diagnostics were reported.`}):(0,J.jsx)(`ul`,{className:`space-y-3`,children:d.map(e=>(0,J.jsxs)(`li`,{className:`space-y-1 break-words`,children:[(0,J.jsxs)(`p`,{className:`font-medium`,children:[e.severity,` · `,e.code,e.target?` · ${e.target}`:``]}),(0,J.jsx)(`p`,{children:e.message}),e.fix?(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Fix: `,e.fix]}):null]},`${e.code}:${e.message}`))})}),(0,J.jsx)(lw,{title:`CLI evidence`,summary:`doctor + context · CLI ${t.cli.version??`unavailable`}`,children:(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsx)(FQ,{label:`Doctor command`,evidence:t.evidence.doctor}),(0,J.jsx)(FQ,{label:`Context command`,evidence:t.evidence.context})]})})]})}function NQ({label:e,value:t,detail:n,mono:r=!1}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 break-all text-sm ${r?`font-mono`:`font-medium`}`,children:t}),n?(0,J.jsx)(`div`,{className:`text-muted-foreground mt-0.5 text-[11px]`,children:n}):null]})}function $Ge({actionStatus:e,context:t}){return(0,J.jsx)(lw,{title:`Resolution details`,summary:`Authority ${e}`,children:(0,J.jsxs)(`dl`,{className:`text-muted-foreground grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:[(0,J.jsx)(`dt`,{children:`root authority`}),(0,J.jsx)(`dd`,{children:e}),(0,J.jsx)(`dt`,{children:`observed at`}),(0,J.jsx)(`dd`,{children:new Date(t.observedAt).toISOString()}),(0,J.jsx)(`dt`,{children:`CLI available`}),(0,J.jsx)(`dd`,{children:String(t.cli.available)}),(0,J.jsx)(`dt`,{children:`CLI version`}),(0,J.jsx)(`dd`,{children:t.cli.version??`unavailable`}),(0,J.jsx)(`dt`,{children:`effective command`}),(0,J.jsx)(`dd`,{className:`break-all`,children:t.cli.effectiveCommand??`unavailable`}),(0,J.jsx)(`dt`,{children:`data scope`}),(0,J.jsx)(`dd`,{className:`break-all`,children:t.dataScope.path}),(0,J.jsx)(`dt`,{children:`data source`}),(0,J.jsxs)(`dd`,{children:[t.dataScope.source,t.dataScope.environmentVariable?` · ${t.dataScope.environmentVariable}`:``]}),(0,J.jsx)(`dt`,{children:`Store registry`}),(0,J.jsx)(`dd`,{children:`Read-only from this project workspace`})]})})}function PQ({label:e,value:t}){let n=typeof t==`string`?t:JSON.stringify(t,null,2);return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold`,children:e}),(0,J.jsx)(`pre`,{className:`bg-muted scrollbar-thin scrollbar-track-transparent max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md p-3 text-xs`,children:n})]})}function FQ({label:e,evidence:t}){return t?(0,J.jsxs)(`section`,{className:`border-border border-t pt-3`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold`,children:e}),(0,J.jsxs)(`dl`,{className:`text-muted-foreground mt-3 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,J.jsx)(`dt`,{children:`process success`}),(0,J.jsx)(`dd`,{children:String(t.success)}),(0,J.jsx)(`dt`,{children:`exit status`}),(0,J.jsx)(`dd`,{children:t.exitCode??`unknown`}),t.contractError?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:`contract drift`}),(0,J.jsx)(`dd`,{className:`text-destructive break-words`,children:t.contractError})]}):null]}),t.stderr?(0,J.jsx)(PQ,{label:`stderr`,value:t.stderr}):null,(0,J.jsx)(PQ,{label:`diagnostics`,value:t.diagnostics}),(0,J.jsx)(PQ,{label:`stdout`,value:t.stdout})]}):(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold`,children:e}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No command evidence observed.`})]})}var eKe={defaultScope:`code`,code:{scope:`code`,bindingToken:null,rootPath:``,repository:null},planningState:`settled`,planning:null};function IQ(e=!0){return Ff(t=>e?q.git.subscribeScopes.subscribe(void 0,{onData:t.onData,onError:t.onError,onConnectionStateChange:e=>t.onConnectionStateChange({state:e.state,error:e.error}),onStopped:t.onStopped,onComplete:t.onComplete}):{unsubscribe(){}},async()=>eKe,[e],`git.subscribeScopes`)}function LQ(e=!0){let t=Lo().searchStr,n=ms(t),r=IQ(e),i=eC(),a=r.data??null,o=a?.planning??null,s=i.data,c=s?.state===`ready`?s.data.planningRoot?.path:null,l=o!==null&&a?.planningState===`settled`&&r.authority.state===`current`&&i.authority.state===`current`&&!i.isLoading&&i.error===null&&c===o.rootPath,u=n===`planning`&&l?`planning`:`code`;return{requestedScope:n,scope:u,descriptor:u===`planning`?o:a?.code??null,scopes:a,locationSearch:t,planningReady:l,planningMessage:n!==`planning`||l?null:r.error?`Git repository scope projection failed: ${r.error.message}`:r.authority.state===`current`?i.error?`Planning Root Context failed: ${i.error.message}`:s?.state===`error`?`Planning Root Context failed: ${s.error.message}`:i.authority.state===`waiting`||s?.state===`refreshing`||s?.state===`loading`?`Planning repository is locked while Root Context refreshes.`:a?.planningState===`resolving`?`Planning repository binding is resolving.`:a?.planningState===`failed`?`Planning Git repository binding failed: ${a.planningError.message}`:o===null?`Planning root is not a distinct Git repository; using Code repository.`:`Planning repository binding is waiting for the current Root Context.`:r.authority.state===`failed`?`Git repository scope projection failed: ${r.authority.error.message}`:`Git repository scope projection is waiting for ${r.authority.reason}.`,query:r}}function tKe({staticMode:e}){return e?null:(0,J.jsx)(nKe,{})}function nKe(){let{data:e,isLoading:t,error:n}=eC(),r=QS(e),i=IQ(),a=e?.state===`error`?e.error:null,o=r?RQ(r.references):null,s=r?.references.map(e=>({storeId:e.store_id,errors:e.status.filter(e=>e.severity===`error`).length})).filter(e=>e.errors>0)??[],c=i.authority.state===`failed`?i.authority.error.message:i.authority.state===`current`&&i.data?.planningState===`failed`?i.data.planningError.message:null;return e?.state===`ready`&&AQ(r)===`collapsed`&&r?.references.length===0&&!n&&!a&&i.authority.state===`current`&&i.data?.planningState===`settled`&&i.data.planning===null&&!c?null:(0,J.jsxs)(`section`,{"aria-label":`Dashboard data scopes`,className:`border-border border-y py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`sr-only`,children:`Data scopes`}),t&&!r?(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-busy":`true`,children:(0,J.jsx)(IC,{className:`w-52`})}):r?(0,J.jsx)(PC,{active:e?.state===`refreshing`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,J.jsx)(Rce,{className:`text-muted-foreground h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm`,title:r.planningRoot?.path,children:r.planningRoot?.path??`No planning root resolved.`}),(0,J.jsx)(cw,{ariaLabel:`Planning root source ${r.planningRoot?.source??`unresolved`}${r.storeId?`, Store ${r.storeId}`:``}`,tooltip:(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Planning root: `,r.planningRoot?.path??`Not resolved`]}),(0,J.jsxs)(`div`,{children:[`Source: `,r.planningRoot?.source??`unresolved`]}),(0,J.jsxs)(`div`,{children:[`Store: `,r.storeId??`none`]})]}),children:r.storeId?`Store ${r.storeId}`:r.planningRoot?.source??`unresolved`}),(0,J.jsxs)(cw,{ariaLabel:`${r.references.length} direct References, ${o?.errors??0} errors, ${o?.warnings??0} warnings`,tooltip:(0,J.jsx)(rKe,{references:r.references}),tone:o?.errors?`custom`:`muted`,className:o?.errors?`border-destructive/40 bg-destructive/10 text-destructive`:void 0,children:[`References `,r.references.length]}),i.authority.state===`current`&&i.data?(0,J.jsx)(cw,{ariaLabel:iKe(i.data),tooltip:(0,J.jsx)(aKe,{scopes:i.data}),children:i.data.planningState===`resolving`?`Git resolving`:`Git ${i.data.planning?`2 repos`:`1 repo`}`}):i.authority.state===`waiting`?(0,J.jsx)(IC,{className:`w-16`}):null]})}):null,(0,J.jsx)(Rp,{to:`/config/context`,className:`text-primary text-xs hover:underline`,children:`Resolved Context`})]}),n||a?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n?.message??a?.message})]}):null,s.length>0?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Reference errors:`,` `,s.map(({storeId:e,errors:t})=>`${e} (${t})`).join(`, `)]})]}):null,c?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Git scope binding failed: `,c]})]}):null]})}function RQ(e){return e.reduce((e,t)=>(e.total+=t.status.length,e.errors+=t.status.filter(e=>e.severity===`error`).length,e.warnings+=t.status.filter(e=>e.severity===`warning`).length,e),{errors:0,warnings:0,total:0})}function rKe({references:e}){return e.length===0?(0,J.jsx)(`span`,{children:`No direct References observed.`}):(0,J.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let t=RQ([e]);return(0,J.jsxs)(`li`,{children:[e.store_id,`: `,t.errors,` error · `,t.warnings,` warning · `,t.total,` `,`total`]},e.store_id)})})}function iKe(e){return e.planningState===`resolving`?`Code Git current, Planning Git resolving`:e.planning?`Code and distinct Planning Git repositories`:`Code Git repository`}function aKe({scopes:e}){return(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Code repository: `,e.code.repository?.topLevel??e.code.rootPath]}),e.planningState===`resolving`?(0,J.jsx)(`div`,{children:`Resolving Planning Git repository.`}):e.planningState===`failed`?(0,J.jsxs)(`div`,{children:[`Planning Git repository binding failed: `,e.planningError.message]}):e.planning?(0,J.jsxs)(`div`,{children:[`Distinct Planning repository:`,` `,e.planning.repository?.topLevel??e.planning.rootPath]}):(0,J.jsx)(`div`,{children:`No distinct Planning Git repository.`})]})}var zQ=`openspecui:dashboard:git-auto-refresh`,oKe={"30s":3e4,"5min":5*6e4,"30min":30*6e4,none:null};function sKe(e){return e===`30s`||e===`5min`||e===`30min`||e===`none`}function BQ(){if(typeof window>`u`)return`none`;try{let e=window.localStorage.getItem(zQ);return sKe(e)?e:`none`}catch{return`none`}}function VQ(e){if(!(typeof window>`u`))try{window.localStorage.setItem(zQ,e)}catch{}}function HQ(e){return oKe[e]}function UQ(e){return`auto-refresh:${e}`}function WQ(e){return e.type===`commit`?Number.isFinite(e.committedAt)&&e.committedAt>0?e.committedAt:null:Number.isFinite(e.updatedAt)&&(e.updatedAt??0)>0?e.updatedAt:null}function cKe(e){return[...e].sort((e,t)=>e.type===t.type?(WQ(t)??0)-(WQ(e)??0):e.type===`uncommitted`?-1:1)}function GQ(e,t,n=Date.now()){if(!e||!t||t<=0)return 0;let r=Math.max(0,n-e);return Math.min(1,r/t)}var KQ=`border-zinc-400/50`,qQ=`bg-zinc-500/8`,lKe=`border-zinc-400/50`;function JQ(e){return!(`state`in e)||e.state===`ready`}function uKe(e){return JQ(e)&&(e.insertions>0||e.deletions>0)}function YQ(e){return e.length===0?`linked openspec changes: none`:e.length===1?`linked openspec changes: ${e[0]}`:`linked openspec changes: ${e.join(`, `)}`}function XQ(e){return/^https?:\/\//.test(e)}async function ZQ(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`absolute`,t.style.left=`-9999px`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}function QQ({preset:e}){return e===`30s`?(0,J.jsx)(kce,{className:`h-3.5 w-3.5`}):e===`5min`?(0,J.jsx)(Ace,{className:`h-3.5 w-3.5`}):e===`30min`?(0,J.jsx)(jce,{className:`h-3.5 w-3.5`}):(0,J.jsx)(Zp,{className:`h-3.5 w-3.5`})}function $Q(e){return{family:`git`,entityId:hs(e)}}function e$(e,t){if(t.trim().length===0)throw Error(`Git handoff requires a non-empty binding token.`);let n=hs(e);if(n.trim().length===0)throw Error(`Git entity id must be non-empty.`);return{family:`git`,entityId:n,bindingToken:t,title:e.title,subtitle:e.type===`commit`?`${e.hash.slice(0,8)} · ${YQ(e.relatedChanges)}`:`working tree · ${YQ(e.relatedChanges)}`}}function t$({entry:e,selected:t=!1,onSelect:n}){let r=e.type===`commit`,i=WQ(e),a=i?vw(i):r?`unknown time`:`working tree`,o=i?j_e(i):void 0,s=$Q(e);return(0,J.jsx)(`button`,{type:`button`,onClick:t=>n?.(e,t.currentTarget),...op(s,`container`),className:`block w-full min-w-0 rounded-md border px-2 py-1.5 text-left ${r?`bg-sky-500/7 border-sky-500/30`:`bg-amber-500/7 border-amber-500/30`} ${t?`ring-primary ring-1`:``}`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[r?(0,J.jsx)(bm,{...op(s,`icon`),className:`h-3.5 w-3.5 text-sky-600 dark:text-sky-300`}):(0,J.jsx)(Am,{...op(s,`icon`),className:`h-3.5 w-3.5 text-amber-600 dark:text-amber-300`}),(0,J.jsx)(`span`,{...op(s,`title`),className:`truncate`,children:e.title})]}),(0,J.jsxs)(`div`,{className:`text-muted-foreground truncate text-[11px]`,children:[r?e.hash.slice(0,8):`working tree`,` ·`,` `,YQ(e.relatedChanges)]})]}),(0,J.jsxs)(`div`,{className:`shrink-0 text-right`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,J.jsx)(i$,{files:e.diff.files}),(0,J.jsx)(r$,{diff:e.diff,className:`justify-end`})]}),(0,J.jsx)(gh,{content:o,delay:0,children:(0,J.jsx)(`span`,{className:`text-muted-foreground hover:text-foreground mt-0.5 inline-flex min-h-5 items-center rounded-sm bg-transparent px-1 py-0 text-[10px]`,title:o,children:a})})]})]})})}function n$({worktree:e,emphasize:t,removing:n=!1,onRemoveDetachedWorktree:r}){let i=XQ(e.path),a=!i,o=!i&&e.detached&&!e.isCurrent,[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=i?e.path:s?e.relativePath:e.path,f=(0,Y.useCallback)(async()=>{try{await ZQ(d),u(!0),window.setTimeout(()=>u(!1),1200)}catch(e){console.error(`[Git] Failed to copy worktree path:`,e)}},[d]);return(0,J.jsx)(`div`,{className:`min-w-0 rounded-e-md rounded-t-md border px-2.5 py-2 ${t?`${KQ} ${qQ}`:`border-border/70 bg-muted/15`}`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,J.jsx)(ym,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.branchName})]}),(0,J.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-1`,children:[a?(0,J.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`text-muted-foreground hover:text-foreground inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-transparent`,title:s?`Show absolute path`:`Show relative path`,"aria-label":s?`Show absolute path`:`Show relative path`,children:s?(0,J.jsx)(hm,{className:`h-3.5 w-3.5`}):(0,J.jsx)(gm,{className:`h-3.5 w-3.5`})}):null,(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{f()},onDoubleClick:()=>{a&&c(e=>!e)},className:`text-muted-foreground hover:text-foreground inline-flex min-w-0 flex-1 items-center gap-1 truncate text-left text-xs`,title:d,"aria-label":`Copy ${s&&a?`relative`:`absolute`} path for ${e.branchName}`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:d}),l?(0,J.jsx)(Xp,{className:`h-3 w-3 shrink-0`}):(0,J.jsx)(rm,{className:`h-3 w-3 shrink-0`})]})]})]}),(0,J.jsx)(`div`,{className:`shrink-0 text-right`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[o?(0,J.jsx)(`button`,{type:`button`,onClick:()=>{r?.(e)},disabled:n,className:`text-muted-foreground hover:text-destructive inline-flex h-5 w-5 items-center justify-center rounded border border-transparent disabled:cursor-not-allowed disabled:opacity-60`,title:`Remove detached worktree`,"aria-label":`Remove detached worktree`,children:n?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`})}):null,(0,J.jsx)(a$,{ahead:e.ahead,behind:e.behind}),(0,J.jsx)(i$,{files:e.diff.files}),(0,J.jsx)(r$,{diff:e.diff,className:`justify-end`})]})})]})})}function r$({diff:e,className:t=``}){return JQ(e)&&!uKe(e)?null:JQ(e)?(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] ${t}`,children:[(0,J.jsxs)(`span`,{className:`bg-emerald-500/12 inline-flex items-center gap-0.5 rounded border border-emerald-500/40 px-[0.15rem] py-0 font-mono text-[10px] text-emerald-700 dark:border-emerald-300/45 dark:bg-emerald-400/20 dark:text-emerald-100`,children:[(0,J.jsx)(Pm,{className:`h-2.5 w-2.5`}),(0,J.jsx)(`span`,{children:e.insertions})]}),(0,J.jsxs)(`span`,{className:`bg-rose-500/12 inline-flex items-center gap-0.5 rounded border border-rose-500/40 px-[0.15rem] py-0 font-mono text-[10px] text-rose-700 dark:border-rose-300/45 dark:bg-rose-400/20 dark:text-rose-100`,children:[(0,J.jsx)(Yce,{className:`h-2.5 w-2.5`}),(0,J.jsx)(`span`,{children:e.deletions})]})]}):(0,J.jsx)(`span`,{className:`inline-flex items-center rounded border border-zinc-500/35 bg-zinc-500/10 px-[0.15rem] py-0 font-mono text-[10px] text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100 ${t}`,children:e.state===`loading`?`loading`:`n/a`})}function i$({files:e}){return e<=0?null:(0,J.jsxs)(_h,{tone:`custom`,size:`xs`,shape:`box`,className:`h-auto min-w-0 border border-zinc-500/35 bg-zinc-500/10 px-[0.15rem] py-0 font-mono text-[10px] font-normal text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100`,children:[e,`f`]})}function a$({ahead:e,behind:t}){return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-zinc-500/35 bg-zinc-500/10 px-[0.15rem] py-0 font-mono text-[10px] text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100`,children:[(0,J.jsxs)(`span`,{children:[`↑`,e]}),(0,J.jsxs)(`span`,{children:[`↓`,t]})]})}function dKe({options:e,value:t,onValueChange:n,progress:r,showProgress:i,disabled:a,animated:o,onRefresh:s}){return(0,J.jsxs)(`div`,{className:`border-border bg-card inline-flex overflow-hidden rounded-md border`,children:[(0,J.jsx)(YW,{value:t,options:e,onValueChange:n,ariaLabel:`Git auto refresh`,className:`text-foreground/75 hover:text-foreground border-r-current/10 bg-muted/20 relative isolate h-7 w-9 shrink-0 justify-center rounded-none border-0 border-r px-0`,positionerClassName:`z-50`,popupClassName:`min-w-[7rem]`,renderTrigger:({selectedOption:e})=>(0,J.jsxs)(`span`,{className:`relative inline-flex h-full w-full items-center justify-center overflow-hidden`,children:[(0,J.jsx)(`span`,{className:`bg-muted/20 pointer-events-none absolute inset-0`}),i?(0,J.jsx)(`span`,{className:`bg-primary/30 dark:bg-primary/35 pointer-events-none absolute inset-y-0 left-0 transition-[width]`,style:{width:`${r*100}%`}}):null,(0,J.jsx)(`span`,{className:`relative z-10 inline-flex items-center justify-center`,children:(0,J.jsx)(QQ,{preset:e?.value??t})})]})}),(0,J.jsxs)(`button`,{type:`button`,onClick:s,disabled:a,className:`inline-flex h-7 items-center gap-1 px-2 py-1 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-70 ${o?`text-primary bg-primary/10`:`text-foreground/75 hover:text-foreground`}`,children:[(0,J.jsx)(Fm,{className:`h-3.5 w-3.5 ${o?`animate-spin`:``}`}),`Refresh`]})]})}var o$=32,s$=.08,c$=.95;function fKe(e,t){if(e.length<=t)return e;let n=[],r=e.length/t;for(let i=0;i<t;i+=1){let t=Math.floor(i*r),a=Math.floor((i+1)*r),o=e.slice(t,Math.max(a,t+1)),s=o.reduce((e,t)=>e+t,0)/o.length;n.push(s)}return n}function pKe(e,t){if(e.length===0)return[];if(t===`monotonic`){let t=Math.max(...e);return t<=0?e.map(()=>s$):e.map(e=>Math.max(0,e)/t*(c$-s$)+s$)}let n=Math.min(...e),r=Math.max(...e);return n===r?e.map(()=>.55):e.map(e=>(e-n)/(r-n)*.8+.15)}function mKe(e){return e.length===0?[]:e.map((t,n)=>n===0?`flat`:t>e[n-1]?`up`:t<e[n-1]?`down`:`flat`)}function hKe({bars:e,directions:t,trendKind:n}){if(e.length===0)return null;let r=e.length===1?Array.from({length:12},()=>e[0]):e,i=t.length===1?Array.from({length:r.length},()=>t[0]??`flat`):t;return(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-end gap-px px-2 py-2 opacity-50`,"data-testid":`dashboard-mini-trend-bars`,children:r.map((e,t)=>{let r=i[t]??`flat`;return(0,J.jsx)(`span`,{className:`${n===`bidirectional`?r===`up`?`bg-emerald-500/30`:r===`down`?`bg-rose-500/30`:`bg-primary/25`:`bg-primary/25`} block flex-1 rounded-sm`,"data-testid":`dashboard-mini-trend-bar`,"data-direction":r,style:{height:`${Math.max(8,Math.round(e*100))}%`}},t)})})}function gKe(e,t){if(e.length<=t)return e;let n=[],r=e.length/t;for(let i=0;i<t;i+=1){let t=Math.floor(i*r),a=Math.floor((i+1)*r),o=e.slice(t,Math.max(a,t+1)),s=o[o.length-1]?.ts??e[e.length-1].ts;n.push({ts:s,add:o.reduce((e,t)=>e+t.add,0),modify:o.reduce((e,t)=>e+t.modify,0),delete:o.reduce((e,t)=>e+t.delete,0)})}return n}function _Ke(e){if(e.length===0)return[];let t=e.map(e=>e.add+e.modify+e.delete),n=Math.max(...t);return n<=0?e.map(()=>({height:0,addRatio:0,modifyRatio:0,deleteRatio:0})):e.map(e=>{let t=e.add+e.modify+e.delete;return t<=0?{height:0,addRatio:0,modifyRatio:0,deleteRatio:0}:{height:t/n*(c$-s$)+s$,addRatio:e.add/t,modifyRatio:e.modify/t,deleteRatio:e.delete/t}})}function vKe({bars:e}){if(e.length===0)return null;let t=e.length===1?Array.from({length:12},()=>e[0]):e;return(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-end gap-px px-2 py-2 opacity-55`,"data-testid":`dashboard-mini-tricolor-bars`,children:t.map((e,t)=>{let n=Math.max(0,Math.round(e.height*100));return n<=0?(0,J.jsx)(`span`,{className:`bg-border/45 block min-h-px flex-1 rounded-sm`,"data-testid":`dashboard-mini-tricolor-bar`},t):(0,J.jsxs)(`span`,{className:`flex flex-1 flex-col-reverse overflow-hidden rounded-sm`,"data-testid":`dashboard-mini-tricolor-bar`,style:{height:`${n}%`,minHeight:`1px`},children:[e.addRatio>0&&(0,J.jsx)(`span`,{className:`bg-primary/40 block w-full`,style:{flexGrow:e.addRatio}}),e.modifyRatio>0&&(0,J.jsx)(`span`,{className:`bg-secondary/55 block w-full`,style:{flexGrow:e.modifyRatio}}),e.deleteRatio>0&&(0,J.jsx)(`span`,{className:`bg-foreground/35 block w-full`,style:{flexGrow:e.deleteRatio}})]},t)})})}function l$({label:e,value:t,icon:n,availability:r,trendKind:i,points:a,triColorPoints:o=[],pending:s=!1,className:c}){let l=gKe(o,o$),u=_Ke(l),d=l.some(e=>e.add+e.modify+e.delete>0),f=fKe(a.map(e=>e.value),o$),p=pKe(f,i),m=mKe(f),h=r.state===`invalid`,g=d||f.length>=2,_=r.state===`invalid`&&r.reason===`objective-history-unavailable`?`No objective historical source`:`Insufficient computable data`;return(0,J.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border p-4 ${h?`border-border from-muted/35 to-muted/5 border-dashed bg-gradient-to-br`:`border-border bg-card`} ${c??``}`,"data-testid":`dashboard-metric-card`,"aria-busy":s,children:[!s&&!h&&(d?(0,J.jsx)(vKe,{bars:u}):(0,J.jsx)(hKe,{bars:p,directions:m,trendKind:i})),s?(0,J.jsxs)(`div`,{className:`relative z-10 flex h-full flex-col`,"aria-hidden":`true`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,J.jsx)(FC,{className:`size-3.5 shrink-0 rounded-full`}),(0,J.jsx)(FC,{className:`h-4 w-2/3 max-w-56`})]}),(0,J.jsx)(FC,{className:`h-8 w-24`}),(0,J.jsx)(`div`,{className:`mt-auto flex h-1/2 items-end gap-1 pt-4`,children:Array.from({length:12},(e,t)=>(0,J.jsx)(FC,{className:`min-h-3 flex-1 rounded-sm`,style:{height:`${28+t*17%64}%`}},t))})]}):(0,J.jsxs)(`div`,{className:`relative z-10`,children:[(0,J.jsxs)(`div`,{className:`text-muted-foreground mb-1 flex items-center gap-2 text-sm`,children:[(0,J.jsx)(n,{className:`h-3.5 w-3.5`}),e]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),h&&(0,J.jsx)(`div`,{className:`text-muted-foreground mt-2 text-xs`,"data-testid":`dashboard-card-invalid-note`,children:_}),!h&&!g&&(0,J.jsx)(`div`,{className:`text-muted-foreground mt-2 text-xs`,"data-testid":`dashboard-card-trend-note`,children:`No trend yet`})]})]})}function u$(e){if(e instanceof Error)return e;if(typeof e==`object`&&e&&`message`in e){let t=e.message;if(typeof t==`string`)return Error(t)}return Error(String(e))}function d$(e,t,n,r=!0){return Kf((0,Y.useCallback)(t=>{if(!r)return{unsubscribe(){}};let n=!1;return e({onData(e){if(e.type===`snapshot`||e.type===`complete`){n=!0,e.snapshot.freshness===`current`?t.onEvent({type:`data`,data:e.snapshot.data}):t.onEvent({type:`display-stale`,data:e.snapshot.data});return}if(e.type===`stage`){e.phase===`start`&&n&&t.onEvent({type:`recompute-started`});return}e.type===`failed`&&t.onError(u$(e.error))},onError:t.onError})},[r,e]),t,[r],n)}function yKe(e,t){return t.identity===e.identity&&t.workGeneration===e.workGeneration}function bKe(e,t){return Kf((0,Y.useCallback)((t,n)=>{let r=!0,i=0,a=n.hasCached,o=null,s=!1,c=e=>r&&o!==null&&o.identity===e.identity&&o.workGeneration===e.workGeneration&&o.snapshotGeneration===e.snapshotGeneration&&o.state===e.state,l=async e=>{let n=++i;try{let o=await q.dashboard.getSummary.query();if(!r||n!==i||e&&(!c(e)||!yKe(e,o)))return;o.data&&(a=!0,t.onEvent({type:o.freshness===`current`?`data`:`display-stale`,data:o.data})),o.error&&t.onError(u$(o.error))}catch(a){if(!r||n!==i||e&&!c(e))return;t.onError(u$(a))}},u=e({onData(e){s=!0;let n=a;o=e,n&&e.state!==`ready`&&t.onEvent({type:`recompute-started`}),l(e)},onError:t.onError});return s||l(),{unsubscribe(){r=!1,i+=1,u.unsubscribe()}}},[e]),t,[],`dashboard.subscribeSummary.v2`)}async function xKe(){let e=await _f();return{summary:e.summary,specifications:e.specifications,activeChanges:e.activeChanges,trackedTaskPhaseCounts:e.trackedTaskPhaseCounts,recentArchives:e.recentArchives}}async function SKe(){let e=await _f();return{trends:e.trends,triColorTrends:e.triColorTrends,trendKinds:e.trendKinds,cardAvailability:e.cardAvailability,trendMeta:e.trendMeta}}async function CKe(){return(await _f()).git}function wKe(){let e=(0,Y.useCallback)(e=>q.dashboard.subscribeSummary.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),t=(0,Y.useCallback)(e=>q.dashboard.subscribeTrends.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),n=(0,Y.useCallback)(e=>q.dashboard.subscribeGit.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),r=bKe(e,xKe),i=r.data!==void 0,a=d$(t,SKe,`dashboard.subscribeTrends`,i),o=d$(n,CKe,`dashboard.subscribeGit`,i);return{data:(0,Y.useMemo)(()=>{if(!(!r.data||!a.data||!o.data))return{...r.data,...a.data,git:o.data}},[o.data,r.data,a.data]),isLoading:r.isLoading,error:r.error,regions:{summary:r,trends:a,git:o}}}async function TKe(e,t){B()||await q.dashboard.refreshGitSnapshot.query({scope:`code`,expectedBindingToken:t,reason:e})}var EKe=[{value:`30s`,label:`30s`},{value:`5min`,label:`5min`},{value:`30min`,label:`30min`},{value:`none`,label:`none`}];function DKe(e){return e===`manual-button`||e?.startsWith(`auto-refresh:`)===!0}function OKe(e){let t=e instanceof Error?e.message:String(e);if(typeof e==`object`&&e&&`data`in e){let n=e.data;if(typeof n==`object`&&n&&`code`in n){let e=n.code;if(typeof e==`string`&&e.length>0)return`${e}: ${t}`}}return t}function kKe(e){return{specifications:{state:`ok`},requirements:{state:`ok`},activeChanges:{state:`invalid`,reason:`objective-history-unavailable`},inProgressChanges:{state:`invalid`,reason:`objective-history-unavailable`},completedChanges:{state:`ok`},taskCompletionPercent:{state:`invalid`,reason:e===null?`semantic-uncomputable`:`objective-history-unavailable`}}}function AKe(){return{specifications:`monotonic`,requirements:`monotonic`,activeChanges:`bidirectional`,inProgressChanges:`bidirectional`,completedChanges:`monotonic`,taskCompletionPercent:`bidirectional`}}function jKe(e){return e.type===`uncommitted`&&(e.diff.files>0||e.diff.insertions>0||e.diff.deletions>0)}function MKe(e){let t=cKe(e),n=t.find(e=>e.type===`uncommitted`),r=t.filter(e=>e.type===`commit`);return n&&jKe(n)?[n,...r.slice(0,4)]:r.slice(0,5)}function NKe(){let e=B(),t=wKe(),{data:n,isLoading:r,error:i}=t,a=t.regions?.summary,o=t.regions?.trends,s=t.regions?.git,c=a?.data??(n?{summary:n.summary,specifications:n.specifications,activeChanges:n.activeChanges,trackedTaskPhaseCounts:n.trackedTaskPhaseCounts,recentArchives:n.recentArchives}:void 0),l=o?.data??(n?{trends:n.trends,triColorTrends:n.triColorTrends,trendKinds:n.trendKinds,cardAvailability:n.cardAvailability,trendMeta:n.trendMeta}:void 0),u=s?.data??n?.git??null,d=a?.isLoading??r,f=a?.isUpdating??!1,p=a?.error??i,m=o?.isLoading??(r&&!n),h=o?.isUpdating??!1,g=o?.error??null,_=s?.isLoading??(r&&!n),v=s?.isUpdating??!1,y=s?.error??null,b=d&&c===void 0,x=b||m&&l===void 0,S=b||_&&u===null,C=c!==void 0,{data:w,authority:T}=IQ(!e&&C),{data:E}=ep(C),{data:D}=$f(C),[O,k]=(0,Y.useState)(()=>BQ()),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(()=>Date.now()),[P,F]=(0,Y.useState)(()=>typeof document>`u`?!0:document.visibilityState===`visible`),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)(null),V=!e&&T.state===`current`&&u?.bindingToken!==null&&u?.bindingToken===w?.code.bindingToken?u?.bindingToken??null:null,ee=(0,Y.useCallback)(()=>{Vp.activatePop(`/opsx-propose`)},[]),te=(0,Y.useCallback)(()=>{Vp.activatePop(`/opsx-new`)},[]),ne=(0,Y.useCallback)(async e=>{V&&(z(null),await TKe(e,V))},[V]),re=(0,Y.useRef)(null),ie=(0,Y.useRef)(O),ae=I?.reason??null,oe=(0,Y.useCallback)(()=>{re.current!==null&&(window.clearTimeout(re.current),re.current=null)},[]),se=(0,Y.useCallback)(e=>{let t=Date.now(),n=HQ(O);j(n===null?null:t+n),L({reason:e,requestedAt:t}),ne(e).then(()=>{L(n=>n?.reason===e&&n.requestedAt===t?null:n)}).catch(n=>{console.error(`[Dashboard] Failed to refresh git snapshot:`,n),z(OKe(n)),L(n=>n?.reason===e&&n.requestedAt===t?null:n)})},[O,ne]),ce=(0,Y.useCallback)(()=>{oe();let t=HQ(O),n=O===`none`?null:UQ(O);if(e||V===null||t===null||n===null||I!==null||v||!P)return;let r=Date.now(),i=A??r+t;if(A===null&&j(i),N(r),r>=i){se(n);return}re.current=window.setTimeout(()=>{re.current=null,N(Date.now()),se(n)},i-r)},[oe,V,A,O,I,v,P,se,e]),le=(0,Y.useCallback)(()=>{V!==null&&(oe(),N(Date.now()),se(`manual-button`))},[oe,V,se]);(0,Y.useEffect)(()=>{if(e)return;let t=()=>{let e=document.visibilityState===`visible`;F(e),e||oe()};return document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t)}},[oe,e]),(0,Y.useEffect)(()=>{if(!e&&(VQ(O),ie.current!==O)){ie.current=O;let e=HQ(O);j(e===null?null:Date.now()+e)}},[O,e]),(0,Y.useEffect)(()=>{if(!e)return ce(),()=>{oe()}},[oe,ce,e]),(0,Y.useEffect)(()=>{let t=HQ(O);if(e||t===null||A===null)return;let n=()=>{N(Date.now())};n();let r=window.setInterval(n,250);return()=>{window.clearInterval(r)}},[A,O,e]);let ue=c?.activeChanges??[],de=(0,Y.useMemo)(()=>new Set(ue.map(e=>e.id)),[ue]),fe=(0,Y.useMemo)(()=>(E??[]).filter(e=>de.has(e.changeName)),[E,de]),pe=(0,Y.useMemo)(()=>{let e=D?.schemaDetails??{},t=new Map;for(let[n,r]of Object.entries(e)){if(!r?.applyTracks)continue;let e=r.artifacts.find(e=>e.outputPath===r.applyTracks);e?.id&&t.set(n,e.id)}return t},[D]),me=c?.summary??{specifications:0,requirements:0,activeChanges:0,inProgressChanges:0,completedChanges:0,archivedTasksCompleted:0,tasksTotal:0,tasksCompleted:0,taskCompletionPercent:null},he=l?.cardAvailability??kKe(me.taskCompletionPercent),ge=l?.trendKinds??AKe(),_e=e||T.state===`current`&&w!==void 0&&u?.bindingToken!==null&&u?.bindingToken===w?.code.bindingToken,ve=_e&&u?u:{bindingToken:null,defaultBranch:`main`,worktrees:[]},ye=e?ve.worktrees.some(e=>e.entries.length>0):_e,be=e?ye:!0,xe=ue.length>0,H=ve.worktrees.find(e=>e.isCurrent)??null,Se=ve.worktrees.filter(e=>!e.isCurrent).filter(e=>!e.detached),Ce=H?MKe(H.entries):[],we=HQ(O),Te=A!==null&&we!==null?A-we:null,Ee=I===null?GQ(Te,we,M):0,De=we!==null&&I===null,Oe=I!==null&&DKe(ae),ke=I!==null||v||V===null,Ae=()=>(0,J.jsxs)(`div`,{className:`space-y-2`,children:[g?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Dashboard trends failed: `,g.message]})]}):null,(0,J.jsx)(PC,{active:h&&!!l,children:(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,J.jsx)(l$,{label:`Specifications / Requirements`,value:`${me.specifications} / ${me.requirements}`,icon:um,availability:he.specifications,trendKind:ge.specifications,points:l?.trends.specifications??[],triColorPoints:[],pending:x,className:`h-44 sm:h-48 lg:h-52 xl:h-56`}),(0,J.jsx)(l$,{label:`Archived Changes / Completed Tasks`,value:`${me.completedChanges} / ${me.archivedTasksCompleted}`,icon:Hp,availability:he.completedChanges,trendKind:ge.completedChanges,points:l?.trends.completedChanges??[],triColorPoints:[],pending:x,className:`h-44 sm:h-48 lg:h-52 xl:h-56`})]})})]}),je=()=>(0,J.jsxs)(`section`,{"data-testid":`dashboard-kanban-row`,className:`border-border @container min-w-0 space-y-2 border-b`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Kanban`}),(0,J.jsx)(Rp,{to:`/board`,"aria-label":`Open Kanban`,title:`Open Kanban`,className:`text-muted-foreground hover:text-foreground inline-flex h-8 w-8 items-center justify-center rounded-md`,children:(0,J.jsx)(Km,{className:`h-4 w-4`})})]}),(0,J.jsx)(rZ,{variant:`compact`,pending:b,activeItems:ue,archivedItems:c?.recentArchives??[],activeCounts:c?.trackedTaskPhaseCounts??{"no-tasks":0,"in-progress":0,complete:0},archivedCount:me.completedChanges})]}),Me=()=>be?(0,J.jsxs)(`section`,{"data-testid":`dashboard-git-snapshot`,className:`min-w-0 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Code Git Snapshot`}),(0,J.jsx)(`p`,{className:`text-muted-foreground truncate text-xs`,children:ye?`Default branch: ${ve.defaultBranch}`:`Waiting for the current Code Git projection.`})]}),e?null:(0,J.jsx)(dKe,{options:EKe,value:O,onValueChange:k,progress:Ee,showProgress:De,disabled:ke,animated:Oe,onRefresh:le})]}),y?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Code Git snapshot failed: `,y.message]})]}):null,S?(0,J.jsxs)(`div`,{"aria-busy":`true`,className:`border-border/80 bg-card min-w-0 space-y-3 rounded-lg border p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:[(0,J.jsx)(FC,{className:`size-4 shrink-0 rounded-full`}),(0,J.jsx)(FC,{className:`h-3 w-36`})]}),(0,J.jsx)(VC,{count:3})]}):null,!ye&&u&&!S&&!y?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`Waiting for the current Code Git binding.`}):null,ye?(0,J.jsx)(PC,{active:v&&!!u,children:(0,J.jsxs)(`div`,{className:`border-border/80 bg-card min-w-0 rounded-lg border p-3`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,J.jsx)(ym,{className:`text-muted-foreground h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[`Default branch: `,ve.defaultBranch]})]}),H?(0,J.jsxs)(`div`,{className:`space-y-0`,children:[(0,J.jsx)(n$,{worktree:H,emphasize:!0}),(0,J.jsx)(`div`,{className:`-mt-px space-y-1 border-l pl-3 pt-2 ${lKe}`,children:Ce.map(t=>(0,J.jsx)(t$,{entry:t,onSelect:e?void 0:(e,t)=>{ve.bindingToken!==null&&Vp.push(`bottom`,vs(e),cp(void 0,e$(e,ve.bindingToken)),{source:t,sharedElements:$Q(e)})}},t.type===`commit`?t.hash:`${t.type}:${t.updatedAt??`none`}`))})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-2.5 py-2 text-xs`,children:`No worktree snapshot available.`}),Se.length>0&&(0,J.jsxs)(`div`,{className:`border-border/70 mt-3 space-y-1 border-t pt-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs uppercase tracking-wide`,children:`Other Worktrees`}),Se.map(e=>(0,J.jsx)(n$,{worktree:e,emphasize:!1},e.path))]})]})}):null]}):null,Ne=()=>(0,J.jsxs)(`section`,{"data-testid":`dashboard-active-changes`,className:`border-border flex min-w-0 flex-col rounded-t-lg border`,children:[(0,J.jsxs)(`div`,{className:`border-border flex min-w-0 flex-wrap items-center justify-between gap-1.5 border-b px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Active Changes`}),b?(0,J.jsx)(FC,{className:`h-4 w-16`}):(0,J.jsxs)(`span`,{className:`text-muted-foreground text-xs sm:text-sm`,children:[me.activeChanges,` active`]})]}),(0,J.jsxs)(`div`,{className:`bg-card divide-border flex min-w-0 flex-1 flex-col divide-y`,children:[b?(0,J.jsx)(zC,{count:3}):null,!b&&ue.map(e=>{let t=fe.find(t=>t.changeName===e.id),n=t?.artifacts.filter(e=>e.status===`done`).length??0,r=t?.artifacts.length??0,i=t?pe.get(t.schemaName):void 0,a=i&&t?t.artifacts.find(e=>e.id===i)?.status??pZ(t.artifacts.map(e=>e.status)):pZ(t?.artifacts.map(e=>e.status)??[]),o=fZ({hasStatus:!!t,isPlanningComplete:t?.isPlanningComplete??!1,trackedTaskPhase:e.trackedTaskProgress.phase,trackedArtifactStatus:a,cliCompletedTasks:e.cliTaskSummary?.completedTasks??null});return(0,J.jsx)(Rp,{to:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{family:`changes`,entityId:e.id,title:e.name,subtitle:e.id}}),vt:{sharedElements:{family:`changes`,entityId:e.id}},...op({family:`changes`,entityId:e.id},`container`),className:`hover:bg-muted/50 block min-w-0 px-4 py-3`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,J.jsx)(uZ,{changeId:e.id,name:e.name,phase:o,updatedAt:e.updatedAt,formatTime:vw,progressRatio:e.cliTaskSummary&&e.cliTaskSummary.totalTasks>0?e.cliTaskSummary.completedTasks/e.cliTaskSummary.totalTasks:null,className:`min-w-0 flex-1`,subtitle:t?(0,J.jsxs)(`span`,{title:`Task counts reported by the OpenSpec CLI for this Change.`,children:[n,`/`,r,` artifacts · `,t.schemaName,e.cliTaskSummary?` · Tasks ${e.cliTaskSummary.completedTasks}/${e.cliTaskSummary.totalTasks}`:``]}):`Artifacts status unavailable`}),(0,J.jsx)(dZ,{})]})},e.id)}),!b&&!xe&&(0,J.jsxs)(`div`,{className:`text-muted-foreground px-4 py-6 text-center text-sm`,children:[(0,J.jsx)(`div`,{children:`No active changes.`}),(0,J.jsx)(`div`,{className:`mt-1 text-xs`,children:`Recommended workflow start: Quick Propose`}),(0,J.jsxs)(`button`,{type:`button`,onClick:te,className:`text-primary mt-2 inline-flex items-center gap-1 hover:underline`,title:`Open the advanced /opsx:new form`,children:[(0,J.jsx)(Gm,{className:`h-3.5 w-3.5`}),`Open /opsx:new form`]})]})]})]});return(0,J.jsxs)(`div`,{className:`@container min-w-0 space-y-6 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Tm,{className:`h-6 w-6 shrink-0`}),`Dashboard`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:ee,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm hover:opacity-90`,title:`Open Quick Propose.`,children:[(0,J.jsx)(Gm,{className:`h-4 w-4`}),`Start Propose`]})]}),(0,J.jsx)(PC,{active:f&&!!c,children:(0,J.jsx)(tKe,{staticMode:e})}),p?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Error loading dashboard: `,p.message]})]}):null,R?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Git action failed: `,R]})]}):null,(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-medium`,children:`Historical Trends`}),Ae()]}),je(),(0,J.jsxs)(`div`,{"data-testid":`dashboard-secondary-grid`,className:`@[64rem]:grid-cols-2 grid min-w-0 gap-3`,children:[Ne(),Me()]})]})}function PKe({worktree:e,emphasize:t,removing:n=!1,action:r,onRemoveDetachedWorktree:i}){let a=XQ(e.path),o=!a,s=!a&&e.detached&&!e.isCurrent,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=a?e.path:c?e.relativePath:e.path,p=(0,Y.useCallback)(async()=>{try{await ZQ(f),d(!0),window.setTimeout(()=>d(!1),1200)}catch(e){console.error(`[Git] Failed to copy worktree path:`,e)}},[f]);return(0,J.jsxs)(`article`,{className:`min-w-0 rounded-md border p-3 ${t?`${KQ} ${qQ}`:`border-border/70 bg-muted/15`}`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5 text-sm font-medium`,children:[(0,J.jsx)(ym,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 break-words leading-snug`,children:e.branchName})]})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[s?(0,J.jsx)(`button`,{type:`button`,onClick:()=>{i?.(e)},disabled:n,className:`text-muted-foreground hover:text-destructive inline-flex h-7 w-7 items-center justify-center rounded border border-transparent disabled:cursor-not-allowed disabled:opacity-60`,title:`Remove detached worktree`,"aria-label":`Remove detached worktree`,children:n?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`})}):null,(0,J.jsx)(a$,{ahead:e.ahead,behind:e.behind}),(0,J.jsx)(i$,{files:e.diff.files}),(0,J.jsx)(r$,{diff:e.diff,className:`justify-end`}),r]})]}),(0,J.jsxs)(`div`,{className:`bg-muted/25 mt-3 flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5`,children:[o?(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`text-muted-foreground hover:text-foreground mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-transparent`,title:c?`Show absolute path`:`Show relative path`,"aria-label":c?`Show absolute path`:`Show relative path`,children:c?(0,J.jsx)(hm,{className:`h-3.5 w-3.5`}):(0,J.jsx)(gm,{className:`h-3.5 w-3.5`})}):null,(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{p()},onDoubleClick:()=>{o&&l(e=>!e)},className:`text-muted-foreground hover:text-foreground flex min-w-0 flex-1 items-start gap-1 text-left text-xs leading-snug`,title:f,"aria-label":`Copy ${c&&o?`relative`:`absolute`} path for ${e.branchName}`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-all`,children:f}),u?(0,J.jsx)(Xp,{className:`mt-0.5 h-3 w-3 shrink-0`}):(0,J.jsx)(rm,{className:`mt-0.5 h-3 w-3 shrink-0`})]})]})]})}function f$(e,t){return e.scope===t.scope&&e.bindingToken===t.bindingToken}function FKe(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return r!==void 0&&hs(e)===hs(r)}):!1}function IKe(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function LKe(e){if(typeof document>`u`){e.update();return}let t=document;if(!e.container||IKe()||typeof t.startViewTransition!=`function`||t.activeViewTransition){e.update();return}e.container.style.viewTransitionName=e.transitionName;try{t.startViewTransition(()=>(0,Kr.flushSync)(e.update)).finished.catch(()=>{}).finally(()=>{e.container?.style.viewTransitionName===e.transitionName&&(e.container.style.viewTransitionName=``)})}catch{e.container.style.viewTransitionName=``,e.update()}}function RKe(e,t,n){let[r,i]=(0,Y.useState)(e),a=(0,Y.useRef)(e),o=(0,Y.useRef)(t),s=(0,Y.useRef)(0),c=(0,Y.useRef)(!1),l=`vt-git-list-${(0,Y.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,u=!f$(o.current,t)||!c.current||e===void 0;return(0,Y.useLayoutEffect)(()=>{if(!c.current){c.current=!0,o.current=t,a.current=e,i(e);return}if(!f$(o.current,t)){o.current=t,a.current=e,s.current+=1,i(e);return}let r=a.current;if(a.current=e,r===e)return;let u=s.current+1;if(s.current=u,e===void 0||r===void 0||FKe(r,e)){i(e);return}queueMicrotask(()=>{s.current===u&&LKe({container:n.current,transitionName:l,update:()=>{s.current===u&&i(e)}})})},[n,e,t.scope,t.bindingToken,l]),u?e:r}var zKe=[{value:`30s`,label:`30s`},{value:`5min`,label:`5min`},{value:`30min`,label:`30min`},{value:`none`,label:`none`}];function BKe(e){return e===`manual-button`||e?.startsWith(`auto-refresh:`)===!0}function VKe(){let e=B(),t=vi(),{requestedScope:n,scope:r,descriptor:i,scopes:a,locationSearch:o,planningReady:s,planningMessage:c,query:l}=LQ(!e),u=i?.bindingToken??null,d=l.authority.state!==`current`,f=(0,Y.useRef)(d);f.current=d;let p=Ai({queryKey:[`git`,r,u,`overview`],queryFn:()=>{if(!u)throw Error(`Git repository binding is unavailable.`);return q.git.overview.query({scope:r,expectedBindingToken:u})},enabled:!e&&!d&&u!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}),m=jte({queryKey:[`git`,r,u,`entries`],initialPageParam:void 0,queryFn:({pageParam:e})=>u?q.git.listEntries.query({scope:r,expectedBindingToken:u,cursor:e,limit:50}):Promise.reject(Error(`Git repository binding is unavailable.`)),getNextPageParam:e=>e.nextCursor??void 0,enabled:!e&&!d&&u!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}),[h,g]=(0,Y.useState)(()=>BQ()),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(()=>Date.now()),[x,S]=(0,Y.useState)(()=>typeof document>`u`?!0:document.visibilityState===`visible`),[C,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),k=ji({mutationFn:e=>q.git.switchWorktree.mutate(e)}),A=(0,Y.useMemo)(()=>m.data?.pages.flatMap(e=>e.items)??[],[m.data]),j=(0,Y.useRef)(null),M=RKe(A,{scope:r,bindingToken:u},j),N=(0,Y.useRef)(0),P=(0,Y.useRef)(null),F=(0,Y.useRef)(C),I=(0,Y.useRef)(!1),L=d||C!==null||k.isPending||T!==null,R=C?.reason??null,z=(0,Y.useCallback)(()=>{P.current!==null&&(window.clearTimeout(P.current),P.current=null)},[]),V=(0,Y.useCallback)(e=>{if(!u||f.current)return;let n=Date.now();w({reason:e,requestedAt:n}),(async()=>{try{await q.git.refresh.query({scope:r,expectedBindingToken:u,reason:e}),await t.invalidateQueries({queryKey:[`git`,r,u],refetchType:`active`})}catch(e){console.error(`[GitRoute] Failed to refresh git data:`,e)}finally{w(t=>t?.reason===e&&t.requestedAt===n?null:t)}})()},[u,t,r]),ee=(0,Y.useCallback)(()=>{z();let t=HQ(h),n=h===`none`?null:UQ(h);if(e||t===null||n===null||L||!x){v(null);return}let r=Date.now();v(r),b(r),P.current=window.setTimeout(()=>{P.current=null,v(null),b(Date.now()),V(n)},t)},[z,h,x,L,V,e]),te=(0,Y.useCallback)(()=>{L||(z(),v(null),b(Date.now()),V(`manual-button`))},[z,L,V]),ne=(0,Y.useCallback)(async n=>{if(!(!u||f.current||e||n.isCurrent||!n.detached)&&window.confirm([`Remove detached worktree?`,``,n.path,``,`This runs git worktree remove --force.`].join(`
1335
+ `)?(0,J.jsx)(qP,{value:t,readOnly:!0,filename:`${e}.md`,lineWrapping:!0}):LGe.has(e)||t.includes(`/`)||t.endsWith(`.md`)||t.endsWith(`.yaml`)?(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:t}):(0,J.jsx)(`span`,{children:t}):(0,J.jsx)(`span`,{children:String(t)})},[]),_t=(0,J.jsx)(`section`,{"data-schema-detail-content":`true`,className:`min-w-0`,children:(0,J.jsxs)(`div`,{className:`space-y-4 pr-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(Yw,{value:a,onChange:$e,options:[{value:`read`,label:`Read`},{value:`preview`,label:`Preview`},{value:`edit`,label:`Edit`,disabled:!Ee}]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(uw,{state:re}),(0,J.jsxs)(`button`,{type:`button`,onClick:ft,disabled:!Ee||Ze.isPending,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Pm,{className:`h-3.5 w-3.5`}),`Add`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:pt,disabled:!Ee||Qe.isPending,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Delete`]})]})]}),!n&&re.disabled?(0,J.jsx)(dw,{state:re}):null,s&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:s}),l&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:l}),(0,J.jsx)(`div`,{ref:i,className:`flex min-h-0 flex-col`,style:r==null?void 0:{height:`${r}px`},children:Fe?a===`preview`?(0,J.jsx)(RU,{className:`min-h-0 flex-1`,markdown:({H1:e,H2:t,H3:n,Section:r})=>{let i=`schema-${Fe.name}`,a=e=>`${i}-${e}`;return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(e,{id:i,children:Fe.name}),Fe.description&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Fe.description})]}),he&&(0,J.jsxs)(r,{children:[(0,J.jsx)(t,{id:a(`resolution`),children:`Resolution`}),(0,J.jsxs)(`div`,{className:`text-muted-foreground mt-2 space-y-1 pl-4 text-sm`,children:[(0,J.jsxs)(`div`,{children:[`Source: `,he.source]}),(0,J.jsxs)(`div`,{className:`truncate`,children:[`Path: `,he.displayPath??he.path]}),he.shadows.length>0&&(0,J.jsxs)(`div`,{children:[`Shadows:`,` `,he.shadows.map(e=>`${e.source}(${e.displayPath??e.path})`).join(`, `)]})]})]}),Re.error&&(0,J.jsxs)(r,{children:[(0,J.jsx)(t,{id:a(`schema-errors`),children:`Schema errors`}),(0,J.jsxs)(`div`,{className:`border-destructive/40 bg-destructive/10 text-destructive mt-2 rounded-md border px-3 py-2 text-sm`,children:[`schema.yaml parse error: `,Re.error]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(t,{id:a(`artifacts`),children:`Artifacts`}),He.length>0?(0,J.jsx)(`div`,{className:`mt-3 space-y-6`,children:He.map(e=>{let t=Ve.get(e.id),i=be?.[e.id]??(ye?.[e.id]?{...ye[e.id],content:null}:null),o=i?.path??(typeof t?.template==`string`?t.template:void 0),s=i?.displayPath??o??null,c=o===void 0?void 0:Ue.get(o),l=c===void 0?i?i.content:null:c,u=[[`id`,t?.id??e.id],[`generates`,t?.generates??e.outputPath],[`description`,t?.description??e.description],[`instruction`,t?.instruction],[`requires`,t?.requires??e.requires]].filter(e=>e[1]!==void 0),d=t?Object.entries(t).filter(([e])=>!zGe.has(e)):[];return(0,J.jsxs)(r,{className:`space-y-3`,children:[(0,J.jsx)(n,{id:a(`artifact-${e.id}`),children:e.id}),(0,J.jsxs)(`div`,{className:`border-border space-y-4 rounded-lg border px-4 py-4 text-sm`,children:[(0,J.jsx)(`div`,{className:`space-y-3`,children:u.map(([e,t])=>{let n=e===`requires`,r=n&&Array.isArray(t)?t.filter(e=>typeof e==`string`):[];return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs font-semibold uppercase tracking-wide`,children:e}),(0,J.jsx)(`div`,{className:`pl-4 text-sm leading-6`,children:n?r.length>0?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>He.some(t=>t.id===e)?(0,J.jsx)(`a`,{href:`#${a(`artifact-${e}`)}`,className:`bg-primary hover:bg-primary/80 text-primary-foreground rounded-md px-2 py-0.5 text-xs transition-colors`,children:e},e):(0,J.jsx)(`span`,{className:`bg-muted text-muted-foreground rounded-md px-2 py-0.5 text-xs`,children:e},e))}):(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):gt(e,t)})]},e)})}),o&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs font-semibold uppercase tracking-wide`,children:`Template`}),(0,J.jsxs)(`div`,{className:`text-muted-foreground pl-4 text-xs`,children:[(0,J.jsx)(`span`,{className:`mr-1`,children:`Template:`}),(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:s}),i?.source?` (${i.source})`:null]}),l==null?(0,J.jsx)(`div`,{className:`text-muted-foreground pl-4 text-sm`,children:`Template content unavailable.`}):(0,J.jsx)(`div`,{className:`pl-4`,children:(0,J.jsx)(`div`,{className:`bg-muted/30 rounded-lg p-4 [zoom:0.86]`,children:(0,J.jsx)(RU,{markdown:l,collectToc:!1})})})]}),d.length>0&&(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs font-semibold uppercase tracking-wide`,children:`Extra fields`}),d.map(([e,t])=>(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e}),(0,J.jsx)(`div`,{className:`pl-4 text-sm leading-6`,children:gt(e,t)})]},e))]})]})]},e.id)})}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`Select a schema to view details.`}),me?.applyRequires?.length?(0,J.jsxs)(`div`,{className:`text-muted-foreground mt-3 text-xs`,children:[`Apply requires: `,me.applyRequires.join(`, `)]}):null]}),We&&(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Preview is rendering draft content. Save to persist changes.`})]})}}):(0,J.jsxs)(XP,{ref:F,className:`flex min-h-0 flex-1 flex-col gap-4`,children:[ve&&(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive text-xs`,children:[`Failed to load schema files: `,ve.message]}),Ae?(0,J.jsx)(HC,{count:6}):je?(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(eF,{entries:ke,selectedPath:xe,onSelect:H,breadcrumbRoot:Ke,headerLabel:(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Files`}),(0,J.jsx)(`span`,{className:`text-muted-foreground/80 truncate text-[10px] normal-case`,title:Ke,children:Ke})]}),headerActions:lt.length>0?(0,J.jsx)(ZP,{children:(0,J.jsx)(`button`,{type:`button`,onClick:e=>{M(null),P(null),A({type:`target`,element:e.currentTarget,placement:`bottom-end`})},className:`hover:bg-muted rounded-md p-1`,"aria-label":`Schema menu`,children:(0,J.jsx)(am,{className:`h-4 w-4`})})}):void 0,entryActions:e=>{let t={id:`properties`,label:`Properties`,icon:(0,J.jsx)(Sm,{className:`h-3.5 w-3.5`}),onSelect:()=>ct(e)};if(a!==`edit`||!De)return[t];let n=e.type===`directory`?e.path:VGe(e.path),r=e.type===`directory`;return[{id:`new-file`,label:r?`New file inside`:`New sibling file`,icon:(0,J.jsx)(cm,{className:`h-3.5 w-3.5`}),onSelect:()=>it(`file`,n)},{id:`new-folder`,label:r?`New folder inside`:`New sibling folder`,icon:(0,J.jsx)(_m,{className:`h-3.5 w-3.5`}),onSelect:()=>it(`directory`,n)},t,{id:`delete`,label:`Delete`,icon:(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),tone:`destructive`,onSelect:()=>ot(e)}]},emptyState:(0,J.jsx)(`span`,{children:`No files found for this schema.`}),renderEditor:e=>e?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[a===`edit`&&(0,J.jsxs)(`div`,{className:`border-border/50 flex items-center justify-between border-b px-3 py-2 text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(ZP,{children:(0,J.jsx)(`button`,{type:`button`,onClick:e=>{A(null),P(null),M({type:`target`,element:e.currentTarget,placement:`bottom-start`})},className:`hover:bg-muted rounded-md px-2 py-1 text-xs font-semibold`,children:`File`})}),(0,J.jsx)(ZP,{children:(0,J.jsx)(`button`,{type:`button`,onClick:e=>{A(null),M(null),P({type:`target`,element:e.currentTarget,placement:`bottom-start`})},className:`hover:bg-muted rounded-md px-2 py-1 text-xs font-semibold`,children:`View`})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:tt,className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:[(0,J.jsx)(pn,{className:`h-3.5 w-3.5`}),`Cancel`]}),(0,J.jsxs)(Hn,{size:`sm`,onClick:nt,disabled:qe.isPending||!Ee,activity:qe.isPending,children:[(0,J.jsx)(Rm,{className:`h-3.5 w-3.5`}),`Save`]})]})]}),(0,J.jsx)(tF,{file:e,value:a===`edit`?Ne??e.content??``:e.content??``,readOnly:a!==`edit`||!Ee,onChange:a===`edit`?et:void 0,lineWrapping:I,editorMinHeight:`0px`}),he?.source===`package`&&(0,J.jsx)(`div`,{className:`text-muted-foreground border-border/50 border-t px-3 py-2 text-xs`,children:`Package-provided schemas are read-only.`})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground flex h-full items-center justify-center`,children:`Select a file to view`})})}):null,(0,J.jsx)(YP,{open:!!k,items:lt,anchor:k,boundaryElement:F.current,onClose:()=>A(null)}),(0,J.jsx)(YP,{open:!!j,items:ut,anchor:j,boundaryElement:F.current,onClose:()=>M(null)}),(0,J.jsx)(YP,{open:!!N,items:dt,anchor:N,boundaryElement:F.current,onClose:()=>P(null)})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`Select a schema to view details.`})})]})});return(0,J.jsx)(_Z,{current:`schemas`,header:(0,J.jsx)(vZ,{backHref:`/config/schemas`,backLabel:`Schemas`,title:pe?`Schema: ${pe}`:`Schema`,description:`Inspect resolved schema facts, preview artifacts, and edit writable physical files.`,icon:(0,J.jsx)(wm,{className:`h-6 w-6 shrink-0`,"aria-hidden":!0})}),children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(GS,{open:d,onClose:()=>f(!1),title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(wm,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Add schema`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:mt,disabled:!Ee||!R.trim()||Ze.isPending,"aria-busy":Ze.isPending||void 0,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Pm,{className:`h-3.5 w-3.5`}),`Create`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:`Schema name`}),(0,J.jsx)(`input`,{value:R,disabled:!Ee||Ze.isPending,onChange:e=>{z(e.target.value),c(null)},placeholder:`schema-name`,className:`border-border bg-card w-full rounded-md border px-3 py-2 text-sm`})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:`Create mode`}),(0,J.jsx)(Yw,{value:V,onChange:ee,options:[{value:`init`,label:`Init`,disabled:!Ee},{value:`fork`,label:`Fork`,disabled:!Ee}]})]}),V===`fork`&&(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:`Fork from`}),(0,J.jsx)(YW,{value:te,options:Ie,onValueChange:ne,ariaLabel:`Fork from`,disabled:!Ee,className:`w-full`})]}),s&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:s})]})}),(0,J.jsx)(GS,{open:p,onClose:()=>m(!1),borderVariant:`error`,title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ym,{className:`text-destructive h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Delete schema`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:ht,disabled:!Ee||Qe.isPending,"aria-busy":Qe.isPending||void 0,className:`bg-destructive text-destructive-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Delete`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,J.jsxs)(`p`,{children:[`This will permanently delete`,` `,(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:pe}),` and all of its template files.`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`This action cannot be undone.`}),s&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:s})]})}),(0,J.jsx)(GS,{open:h,onClose:()=>{g(!1),u(null)},title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x===`file`?(0,J.jsx)(cm,{className:`h-4 w-4`}):(0,J.jsx)(_m,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:x===`file`?`New file`:`New folder`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:at,disabled:!De||!T.trim()||Je.isPending||Ye.isPending,"aria-busy":Je.isPending||Ye.isPending||void 0,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[x===`file`?(0,J.jsx)(cm,{className:`h-3.5 w-3.5`}):(0,J.jsx)(_m,{className:`h-3.5 w-3.5`}),`Create`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,J.jsxs)(`div`,{className:`text-muted-foreground text-xs`,children:[`Parent: `,(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:C??`/`})]}),(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium`,children:x===`file`?`File name`:`Folder name`}),(0,J.jsx)(`input`,{value:T,disabled:!De||Je.isPending||Ye.isPending,onChange:e=>{E(e.target.value),u(null)},placeholder:x===`file`?`new-file.md`:`new-folder`,className:`border-border bg-card w-full rounded-md border px-3 py-2 text-sm`})]}),l&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:l})]})}),(0,J.jsx)(GS,{open:_,onClose:()=>{v(!1),O(null)},borderVariant:`error`,title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ym,{className:`text-destructive h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Delete entry`})]}),footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Cancel`}),(0,J.jsxs)(`button`,{type:`button`,onClick:st,disabled:!De||!D||Xe.isPending,"aria-busy":Xe.isPending||void 0,className:`bg-destructive text-destructive-foreground inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Delete`]})]}),children:(0,J.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,J.jsxs)(`p`,{children:[`This will permanently delete`,` `,(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:D?.path??`selected entry`}),`.`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`This action cannot be undone.`}),l&&(0,J.jsx)(`div`,{className:`text-destructive text-xs`,children:l})]})}),(0,J.jsx)(GS,{open:y,onClose:()=>{b(!1),O(null)},title:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Sm,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Entry properties`})]}),footer:(0,J.jsx)(`button`,{type:`button`,onClick:()=>b(!1),className:`border-border hover:bg-muted inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium`,children:`Close`}),children:(0,J.jsx)(`div`,{className:`space-y-2 text-sm`,children:Ge?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Path`}),(0,J.jsx)(`code`,{className:`bg-muted rounded px-1`,children:Ge.path})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Type`}),(0,J.jsx)(`span`,{children:Ge.type})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Source`}),(0,J.jsx)(`span`,{children:Ge.source})]}),Ge.sizeBytes!==void 0&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Size`}),(0,J.jsxs)(`span`,{children:[Ge.sizeBytes,` bytes`]})]}),Ge.childCount!==void 0&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Items`}),(0,J.jsx)(`span`,{children:Ge.childCount})]})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground text-sm`,children:`No entry selected.`})})}),(0,J.jsxs)(`div`,{"data-schema-workspace-status":`true`,className:`space-y-4`,children:[se?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 flex items-start gap-2 rounded-lg border p-4 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Schema catalog refresh failed.`}),(0,J.jsx)(`p`,{children:se.message})]})]}):null,de?(0,J.jsx)(`section`,{"aria-label":`Loading Schema detail`,className:`border-border bg-card rounded-lg border p-4`,children:(0,J.jsx)(HC,{count:6})}):null,fe?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-lg border border-dashed p-4 text-sm`,children:`No schemas available.`}):null,ue!==void 0&&ue.length>0&&!Fe?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive rounded-lg border p-4 text-sm`,children:[`Schema `,pe||`(missing id)`,` was not found.`]}):null,Fe?_t:null]})]})})}function kQ(e){let t=e.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`);return t===`/`?t:t.replace(/\/$/,``)}function AQ(e){let t=e?.planningRoot?.path;if(!e||!t)return`unresolved`;let n=e.launchProject.physicalPath;return n?kQ(n)===kQ(t)?`collapsed`:`distinct`:`unresolved`}function GGe(e){if(Number.isFinite(e.observedAt)&&e.observedAt>0)return e.observedAt;let t=Date.parse(e.timestamp);return Number.isFinite(t)?t:null}function KGe(e){if(!e)return null;let t=e.meta.referencePolicy,n=t?t.kind===`include`?{kind:`include`,sources:t.referenceSources}:t.kind===`omit`?{kind:`omit`,sourceCount:t.referenceSourceCount}:{kind:`none`}:{kind:`unrecorded`};return{observedAt:GGe(e.meta),projectName:e.meta.projectName,referencePolicy:n,root:e.meta.root??null,version:e.meta.version}}var qGe=(0,Y.createContext)({snapshot:null,basePath:`/`,isStatic:!1});function JGe(){return(0,Y.useContext)(qGe).snapshot}function YGe(){let e=KGe(JGe()??L());return(0,J.jsx)(_Z,{current:`context`,header:(0,J.jsx)(yZ,{status:`static`}),children:e?(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`section`,{className:`border-border min-w-0 border-y py-3`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Published effective root`}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 break-all font-mono text-sm font-medium`,children:e.root?.planningRootPath??`No planning root path was published.`})]}),e.root?(0,J.jsx)(cw,{ariaLabel:`Published root source ${e.root.rootSource}`,tooltip:`OpenSpec reported root source ${e.root.rootSource} at export time.`,children:e.root.rootSource}):null,e.root?.storeId?(0,J.jsxs)(cw,{ariaLabel:`Published Store ${e.root.storeId}`,tooltip:`The exported Planning root used Store ${e.root.storeId}.`,children:[`Store `,e.root.storeId]}):null,(0,J.jsx)(cw,{ariaLabel:`Static Context evidence boundary`,tooltip:`Only publication-safe facts are available; this snapshot has no live authority.`,children:`Published facts`})]})}),(0,J.jsx)(XGe,{policy:e.referencePolicy}),(0,J.jsxs)(lw,{title:`Publication details`,summary:`${e.projectName} · OpenSpecUI ${e.version}`,children:[(0,J.jsxs)(`dl`,{className:`text-muted-foreground grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:[(0,J.jsx)(`dt`,{children:`project`}),(0,J.jsx)(`dd`,{className:`break-words`,children:e.projectName}),(0,J.jsx)(`dt`,{children:`OpenSpecUI version`}),(0,J.jsx)(`dd`,{children:e.version}),(0,J.jsx)(`dt`,{children:`observed at`}),(0,J.jsx)(`dd`,{children:e.observedAt===null?`unavailable`:new Date(e.observedAt).toISOString()})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-3 break-words`,children:`Runtime CLI evidence, registry, and data scope are not published. This snapshot claims no live connection, mutation authority, or current Reference health.`})]})]}):(0,J.jsxs)(`section`,{className:`border-border rounded-lg border p-4`,role:`status`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Static Context unavailable`}),(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-sm`,children:`This export does not contain a readable snapshot.`})]})})}function XGe({policy:e}){return(0,J.jsx)(lw,{title:`Published Reference policy`,summary:e.kind===`none`?`None recorded`:e.kind===`omit`?`${e.sourceCount} omitted`:e.kind===`unrecorded`?`Legacy unrecorded`:`${e.sources.length} included`,children:e.kind===`none`?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No effective References were recorded when this snapshot was exported.`}):e.kind===`omit`?(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[e.sourceCount,` Reference sources were observed and omitted from this export. Their identities and content were not published.`]}):e.kind===`unrecorded`?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`This snapshot predates the explicit Reference export policy.`}):(0,J.jsx)(`ul`,{className:`divide-border divide-y`,children:e.sources.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center justify-between gap-3 py-2 first:pt-0 last:pb-0`,children:[(0,J.jsx)(`span`,{className:`min-w-0 break-all font-mono text-sm`,children:e.storeId}),(0,J.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[e.specCount,` published Specs · export state `,e.state]})]},e.storeId))})})}function ZGe(){return B()?(0,J.jsx)(YGe,{}):(0,J.jsx)(QGe,{})}function QGe(){let{data:e,isLoading:t,error:n,authority:r}=eC(),i=QS(e),a=e?.state===`error`?e.error:null,o=!n&&!a&&(t||e?.state===`loading`)&&i===null,s=e?.state===`error`?e.data:null,c=e?.state===`error`?e.attempt:null,l=n||a||r.state===`failed`?`blocked`:o?`resolving`:e?.state===`refreshing`||r.state!==`current`?`refreshing`:`ready`,u=i?[...i.diagnostics.root,...i.diagnostics.doctor,...i.diagnostics.context,...i.references.flatMap(e=>e.status)]:[],d=CC(`resolved-context`,TWe({available:i!==null,loading:o,transportError:n?.message??a?.message??null,authorityFailed:r.state===`failed`,refreshing:e?.state===`refreshing`,authorityCurrent:r.state===`current`,hasPlanningRoot:i?.planningRoot!==null&&i?.planningRoot!==void 0,cliAvailable:i?.cli.available??!1,cliError:i?.cli.error??null,errorDiagnostic:u.find(e=>e.severity===`error`)?.message??null,warningDiagnostic:u.find(e=>e.severity===`warning`)?.message??null}));return(0,J.jsx)(_Z,{current:`context`,header:(0,J.jsx)(yZ,{status:l}),children:(0,J.jsxs)(`div`,{...d,className:`space-y-6`,children:[o?(0,J.jsx)(HC,{count:4}):null,n||a?(0,J.jsxs)(`div`,{role:`alert`,className:`text-destructive border-destructive/40 bg-destructive/10 flex items-start gap-2 rounded-lg border p-4 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`Root Context is not ready.`}),(0,J.jsx)(`p`,{children:n?.message??a?.message}),e?.state===`error`&&e.data?(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Showing the last successful observation while retaining the failed CLI attempt.`}):null]})]}):null,!o&&s&&c?(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsx)(jQ,{label:`Last successful Context (stale)`,context:s}),(0,J.jsx)(jQ,{label:`Current failed attempt`,context:c,rootHeading:`Attempted planning root`})]}):!o&&c?(0,J.jsx)(jQ,{label:`Current failed attempt`,context:c,rootHeading:`Attempted planning root`}):!o&&i?(0,J.jsx)(PC,{active:e?.state===`refreshing`,children:(0,J.jsx)(MQ,{context:i,actionStatus:e?.state===`ready`&&r.state===`current`?`ready`:r.state===`failed`?`blocked`:`checking`})}):null]})})}function jQ({context:e,label:t,rootHeading:n}){return(0,J.jsxs)(`section`,{"aria-label":t,className:`space-y-3`,children:[(0,J.jsx)(`h2`,{className:`text-muted-foreground text-xs font-semibold uppercase`,children:t}),(0,J.jsx)(MQ,{context:e,rootHeading:n})]})}function MQ({actionStatus:e=`blocked`,context:t,rootHeading:n=`Active planning root`}){let r=t.planningRoot,i=[...t.diagnostics.root,...t.diagnostics.doctor,...t.diagnostics.context],a=t.references.flatMap(e=>e.status.filter(e=>e.severity===`error`).map(t=>`${e.store_id}: ${t.message}`)),o=[t.evidence.doctor?.contractError?`Doctor contract drift: ${t.evidence.doctor.contractError}`:null,t.evidence.context?.contractError?`Context contract drift: ${t.evidence.context.contractError}`:null].filter(e=>e!==null),s=t.references.reduce((e,t)=>e+t.status.length,0),c=AQ(t),l=i.filter(e=>e.severity===`warning`&&e.code===`root_pointer_ignored`),u=i.filter(e=>e.severity===`error`),d=i.filter(e=>e.severity!==`error`),f=c===`collapsed`?{label:`Single project root`,tooltip:`Launch and Planning resolve to the same physical project root.`}:c===`distinct`?{label:`Separate roots`,tooltip:`Launch and Planning resolve to different physical roots.`}:{label:`Relationship unresolved`,tooltip:`The server has not observed enough physical identity evidence to compare the roots.`};return(0,J.jsxs)(`div`,{className:`@container min-w-0 space-y-4`,children:[(0,J.jsxs)(`section`,{"aria-label":`Operational Context`,className:`border-border min-w-0 divide-y border-y`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:c===`collapsed`?`Project root`:n}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 break-all font-mono text-sm font-medium`,children:r?.path??`No planning root resolved.`})]}),r?(0,J.jsx)(cw,{ariaLabel:`Planning root source ${r.source}`,tooltip:`OpenSpec selected this root from source: ${r.source}.`,children:r.source}):null,t.storeId?(0,J.jsxs)(cw,{ariaLabel:`Planning Store ${t.storeId}`,tooltip:`The CLI-selected Planning root uses Store ${t.storeId}.`,children:[`Store `,t.storeId]}):null,(0,J.jsx)(cw,{ariaLabel:`Root relationship ${f.label.toLowerCase()}`,tooltip:f.tooltip,children:f.label}),l.length>0?(0,J.jsx)(cw,{ariaLabel:`Ignored Store declaration warning`,tooltip:`OpenSpec ignored the Store declaration because a real project root takes precedence. See CLI diagnostics for the reported fix.`,tone:`custom`,className:`border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200`,children:`Store declaration ignored`}):null]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-4 py-3 ${c===`collapsed`?``:`@[36rem]:grid-cols-2`}`,children:[c===`collapsed`?null:(0,J.jsx)(NQ,{label:`Launch project`,value:t.launchProject.path,mono:!0}),(0,J.jsx)(NQ,{label:`References`,value:`${t.references.length} observed`,detail:`${s} CLI diagnostics`})]})]}),t.cli.error?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),t.cli.error]}):null,a.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),a.join(` `)]}):null,o.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),o.join(` `)]}):null,u.length>0?(0,J.jsxs)(`div`,{className:`text-destructive flex items-start gap-2 text-sm`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:u.map(e=>`${e.code}: ${e.message}`).join(` `)})]}):null,(0,J.jsx)(lw,{title:`Referenced context`,summary:`${t.references.length} References · ${t.contextMembers.length} members`,children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[t.references.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No reference currently observed.`}):(0,J.jsx)(`ul`,{className:`divide-border divide-y`,children:t.references.map(e=>(0,J.jsxs)(`li`,{className:`space-y-1 py-2 first:pt-0 last:pb-0`,children:[(0,J.jsx)(`p`,{className:`break-all font-mono`,children:e.store_id}),e.status.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No CLI diagnostic reported.`}):e.status.map(e=>(0,J.jsxs)(`p`,{className:`break-words`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.code}),`: `,e.message]},`${e.code}:${e.message}`))]},e.store_id))}),(0,J.jsx)(PQ,{label:`Context members`,value:t.contextMembers})]})}),(0,J.jsx)($Ge,{context:t,actionStatus:e}),(0,J.jsx)(lw,{title:`CLI diagnostics`,summary:d.length===0?`No supporting diagnostics`:`${d.length} supporting`,children:d.length===0?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No supporting CLI diagnostics were reported.`}):(0,J.jsx)(`ul`,{className:`space-y-3`,children:d.map(e=>(0,J.jsxs)(`li`,{className:`space-y-1 break-words`,children:[(0,J.jsxs)(`p`,{className:`font-medium`,children:[e.severity,` · `,e.code,e.target?` · ${e.target}`:``]}),(0,J.jsx)(`p`,{children:e.message}),e.fix?(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Fix: `,e.fix]}):null]},`${e.code}:${e.message}`))})}),(0,J.jsx)(lw,{title:`CLI evidence`,summary:`doctor + context · CLI ${t.cli.version??`unavailable`}`,children:(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsx)(FQ,{label:`Doctor command`,evidence:t.evidence.doctor}),(0,J.jsx)(FQ,{label:`Context command`,evidence:t.evidence.context})]})})]})}function NQ({label:e,value:t,detail:n,mono:r=!1}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e}),(0,J.jsx)(`div`,{className:`mt-1 min-w-0 break-all text-sm ${r?`font-mono`:`font-medium`}`,children:t}),n?(0,J.jsx)(`div`,{className:`text-muted-foreground mt-0.5 text-[11px]`,children:n}):null]})}function $Ge({actionStatus:e,context:t}){return(0,J.jsx)(lw,{title:`Resolution details`,summary:`Authority ${e}`,children:(0,J.jsxs)(`dl`,{className:`text-muted-foreground grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:[(0,J.jsx)(`dt`,{children:`root authority`}),(0,J.jsx)(`dd`,{children:e}),(0,J.jsx)(`dt`,{children:`observed at`}),(0,J.jsx)(`dd`,{children:new Date(t.observedAt).toISOString()}),(0,J.jsx)(`dt`,{children:`CLI available`}),(0,J.jsx)(`dd`,{children:String(t.cli.available)}),(0,J.jsx)(`dt`,{children:`CLI version`}),(0,J.jsx)(`dd`,{children:t.cli.version??`unavailable`}),(0,J.jsx)(`dt`,{children:`effective command`}),(0,J.jsx)(`dd`,{className:`break-all`,children:t.cli.effectiveCommand??`unavailable`}),(0,J.jsx)(`dt`,{children:`data scope`}),(0,J.jsx)(`dd`,{className:`break-all`,children:t.dataScope.path}),(0,J.jsx)(`dt`,{children:`data source`}),(0,J.jsxs)(`dd`,{children:[t.dataScope.source,t.dataScope.environmentVariable?` · ${t.dataScope.environmentVariable}`:``]}),(0,J.jsx)(`dt`,{children:`Store registry`}),(0,J.jsx)(`dd`,{children:`Read-only from this project workspace`})]})})}function PQ({label:e,value:t}){let n=typeof t==`string`?t:JSON.stringify(t,null,2);return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold`,children:e}),(0,J.jsx)(`pre`,{className:`bg-muted scrollbar-thin scrollbar-track-transparent max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md p-3 text-xs`,children:n})]})}function FQ({label:e,evidence:t}){return t?(0,J.jsxs)(`section`,{className:`border-border border-t pt-3`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold`,children:e}),(0,J.jsxs)(`dl`,{className:`text-muted-foreground mt-3 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,J.jsx)(`dt`,{children:`process success`}),(0,J.jsx)(`dd`,{children:String(t.success)}),(0,J.jsx)(`dt`,{children:`exit status`}),(0,J.jsx)(`dd`,{children:t.exitCode??`unknown`}),t.contractError?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:`contract drift`}),(0,J.jsx)(`dd`,{className:`text-destructive break-words`,children:t.contractError})]}):null]}),t.stderr?(0,J.jsx)(PQ,{label:`stderr`,value:t.stderr}):null,(0,J.jsx)(PQ,{label:`diagnostics`,value:t.diagnostics}),(0,J.jsx)(PQ,{label:`stdout`,value:t.stdout})]}):(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-semibold`,children:e}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No command evidence observed.`})]})}var eKe={defaultScope:`code`,code:{scope:`code`,bindingToken:null,rootPath:``,repository:null},planningState:`settled`,planning:null};function IQ(e=!0){return Ff(t=>e?q.git.subscribeScopes.subscribe(void 0,{onData:t.onData,onError:t.onError,onConnectionStateChange:e=>t.onConnectionStateChange({state:e.state,error:e.error}),onStopped:t.onStopped,onComplete:t.onComplete}):{unsubscribe(){}},async()=>eKe,[e],`git.subscribeScopes`)}function LQ(e=!0){let t=Lo().searchStr,n=ms(t),r=IQ(e),i=eC(),a=r.data??null,o=a?.planning??null,s=i.data,c=s?.state===`ready`?s.data.planningRoot?.path:null,l=o!==null&&a?.planningState===`settled`&&r.authority.state===`current`&&i.authority.state===`current`&&!i.isLoading&&i.error===null&&c===o.rootPath,u=n===`planning`&&l?`planning`:`code`;return{requestedScope:n,scope:u,descriptor:u===`planning`?o:a?.code??null,scopes:a,locationSearch:t,planningReady:l,planningMessage:n!==`planning`||l?null:r.error?`Git repository scope projection failed: ${r.error.message}`:r.authority.state===`current`?i.error?`Planning Root Context failed: ${i.error.message}`:s?.state===`error`?`Planning Root Context failed: ${s.error.message}`:i.authority.state===`waiting`||s?.state===`refreshing`||s?.state===`loading`?`Planning repository is locked while Root Context refreshes.`:a?.planningState===`resolving`?`Planning repository binding is resolving.`:a?.planningState===`failed`?`Planning Git repository binding failed: ${a.planningError.message}`:o===null?`Planning root is not a distinct Git repository; using Code repository.`:`Planning repository binding is waiting for the current Root Context.`:r.authority.state===`failed`?`Git repository scope projection failed: ${r.authority.error.message}`:`Git repository scope projection is waiting for ${r.authority.reason}.`,query:r}}function tKe({staticMode:e}){return e?null:(0,J.jsx)(nKe,{})}function nKe(){let{data:e,isLoading:t,error:n}=eC(),r=QS(e),i=IQ(),a=e?.state===`error`?e.error:null,o=r?RQ(r.references):null,s=r?.references.map(e=>({storeId:e.store_id,errors:e.status.filter(e=>e.severity===`error`).length})).filter(e=>e.errors>0)??[],c=i.authority.state===`failed`?i.authority.error.message:i.authority.state===`current`&&i.data?.planningState===`failed`?i.data.planningError.message:null;return e?.state===`ready`&&AQ(r)===`collapsed`&&r?.references.length===0&&!n&&!a&&i.authority.state===`current`&&i.data?.planningState===`settled`&&i.data.planning===null&&!c?null:(0,J.jsxs)(`section`,{"aria-label":`Dashboard data scopes`,className:`border-border border-y py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`sr-only`,children:`Data scopes`}),t&&!r?(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-busy":`true`,children:(0,J.jsx)(IC,{className:`w-52`})}):r?(0,J.jsx)(PC,{active:e?.state===`refreshing`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,J.jsx)(Rce,{className:`text-muted-foreground h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm`,title:r.planningRoot?.path,children:r.planningRoot?.path??`No planning root resolved.`}),(0,J.jsx)(cw,{ariaLabel:`Planning root source ${r.planningRoot?.source??`unresolved`}${r.storeId?`, Store ${r.storeId}`:``}`,tooltip:(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Planning root: `,r.planningRoot?.path??`Not resolved`]}),(0,J.jsxs)(`div`,{children:[`Source: `,r.planningRoot?.source??`unresolved`]}),(0,J.jsxs)(`div`,{children:[`Store: `,r.storeId??`none`]})]}),children:r.storeId?`Store ${r.storeId}`:r.planningRoot?.source??`unresolved`}),(0,J.jsxs)(cw,{ariaLabel:`${r.references.length} direct References, ${o?.errors??0} errors, ${o?.warnings??0} warnings`,tooltip:(0,J.jsx)(rKe,{references:r.references}),tone:o?.errors?`custom`:`muted`,className:o?.errors?`border-destructive/40 bg-destructive/10 text-destructive`:void 0,children:[`References `,r.references.length]}),i.authority.state===`current`&&i.data?(0,J.jsx)(cw,{ariaLabel:iKe(i.data),tooltip:(0,J.jsx)(aKe,{scopes:i.data}),children:i.data.planningState===`resolving`?`Git resolving`:`Git ${i.data.planning?`2 repos`:`1 repo`}`}):i.authority.state===`waiting`?(0,J.jsx)(IC,{className:`w-16`}):null]})}):null,(0,J.jsx)(Rp,{to:`/config/context`,className:`text-primary text-xs hover:underline`,children:`Resolved Context`})]}),n||a?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n?.message??a?.message})]}):null,s.length>0?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Reference errors:`,` `,s.map(({storeId:e,errors:t})=>`${e} (${t})`).join(`, `)]})]}):null,c?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2 text-xs`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Git scope binding failed: `,c]})]}):null]})}function RQ(e){return e.reduce((e,t)=>(e.total+=t.status.length,e.errors+=t.status.filter(e=>e.severity===`error`).length,e.warnings+=t.status.filter(e=>e.severity===`warning`).length,e),{errors:0,warnings:0,total:0})}function rKe({references:e}){return e.length===0?(0,J.jsx)(`span`,{children:`No direct References observed.`}):(0,J.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let t=RQ([e]);return(0,J.jsxs)(`li`,{children:[e.store_id,`: `,t.errors,` error · `,t.warnings,` warning · `,t.total,` `,`total`]},e.store_id)})})}function iKe(e){return e.planningState===`resolving`?`Code Git current, Planning Git resolving`:e.planning?`Code and distinct Planning Git repositories`:`Code Git repository`}function aKe({scopes:e}){return(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Code repository: `,e.code.repository?.topLevel??e.code.rootPath]}),e.planningState===`resolving`?(0,J.jsx)(`div`,{children:`Resolving Planning Git repository.`}):e.planningState===`failed`?(0,J.jsxs)(`div`,{children:[`Planning Git repository binding failed: `,e.planningError.message]}):e.planning?(0,J.jsxs)(`div`,{children:[`Distinct Planning repository:`,` `,e.planning.repository?.topLevel??e.planning.rootPath]}):(0,J.jsx)(`div`,{children:`No distinct Planning Git repository.`})]})}var zQ=`openspecui:dashboard:git-auto-refresh`,oKe={"30s":3e4,"5min":5*6e4,"30min":30*6e4,none:null};function sKe(e){return e===`30s`||e===`5min`||e===`30min`||e===`none`}function BQ(){if(typeof window>`u`)return`none`;try{let e=window.localStorage.getItem(zQ);return sKe(e)?e:`none`}catch{return`none`}}function VQ(e){if(!(typeof window>`u`))try{window.localStorage.setItem(zQ,e)}catch{}}function HQ(e){return oKe[e]}function UQ(e){return`auto-refresh:${e}`}function WQ(e){return e.type===`commit`?Number.isFinite(e.committedAt)&&e.committedAt>0?e.committedAt:null:Number.isFinite(e.updatedAt)&&(e.updatedAt??0)>0?e.updatedAt:null}function cKe(e){return[...e].sort((e,t)=>e.type===t.type?(WQ(t)??0)-(WQ(e)??0):e.type===`uncommitted`?-1:1)}function GQ(e,t,n=Date.now()){if(!e||!t||t<=0)return 0;let r=Math.max(0,n-e);return Math.min(1,r/t)}var KQ=`border-zinc-400/50`,qQ=`bg-zinc-500/8`,lKe=`border-zinc-400/50`;function JQ(e){return!(`state`in e)||e.state===`ready`}function uKe(e){return JQ(e)&&(e.insertions>0||e.deletions>0)}function YQ(e){return e.length===0?`linked openspec changes: none`:e.length===1?`linked openspec changes: ${e[0]}`:`linked openspec changes: ${e.join(`, `)}`}function XQ(e){return/^https?:\/\//.test(e)}async function ZQ(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`absolute`,t.style.left=`-9999px`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}function QQ({preset:e}){return e===`30s`?(0,J.jsx)(kce,{className:`h-3.5 w-3.5`}):e===`5min`?(0,J.jsx)(Ace,{className:`h-3.5 w-3.5`}):e===`30min`?(0,J.jsx)(jce,{className:`h-3.5 w-3.5`}):(0,J.jsx)(Zp,{className:`h-3.5 w-3.5`})}function $Q(e){return{family:`git`,entityId:hs(e)}}function e$(e,t){if(t.trim().length===0)throw Error(`Git handoff requires a non-empty binding token.`);let n=hs(e);if(n.trim().length===0)throw Error(`Git entity id must be non-empty.`);return{family:`git`,entityId:n,bindingToken:t,title:e.title,subtitle:e.type===`commit`?`${e.hash.slice(0,8)} · ${YQ(e.relatedChanges)}`:`working tree · ${YQ(e.relatedChanges)}`}}function t$({entry:e,selected:t=!1,onSelect:n}){let r=e.type===`commit`,i=WQ(e),a=i?vw(i):r?`unknown time`:`working tree`,o=i?j_e(i):void 0,s=$Q(e);return(0,J.jsx)(`button`,{type:`button`,onClick:t=>n?.(e,t.currentTarget),...op(s,`container`),className:`block w-full min-w-0 rounded-md border px-2 py-1.5 text-left ${r?`bg-sky-500/7 border-sky-500/30`:`bg-amber-500/7 border-amber-500/30`} ${t?`ring-primary ring-1`:``}`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[r?(0,J.jsx)(bm,{...op(s,`icon`),className:`h-3.5 w-3.5 text-sky-600 dark:text-sky-300`}):(0,J.jsx)(Am,{...op(s,`icon`),className:`h-3.5 w-3.5 text-amber-600 dark:text-amber-300`}),(0,J.jsx)(`span`,{...op(s,`title`),className:`truncate`,children:e.title})]}),(0,J.jsxs)(`div`,{className:`text-muted-foreground truncate text-[11px]`,children:[r?e.hash.slice(0,8):`working tree`,` ·`,` `,YQ(e.relatedChanges)]})]}),(0,J.jsxs)(`div`,{className:`shrink-0 text-right`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,J.jsx)(i$,{files:e.diff.files}),(0,J.jsx)(r$,{diff:e.diff,className:`justify-end`})]}),(0,J.jsx)(gh,{content:o,delay:0,children:(0,J.jsx)(`span`,{className:`text-muted-foreground hover:text-foreground mt-0.5 inline-flex min-h-5 items-center rounded-sm bg-transparent px-1 py-0 text-[10px]`,title:o,children:a})})]})]})})}function n$({worktree:e,emphasize:t,removing:n=!1,onRemoveDetachedWorktree:r}){let i=XQ(e.path),a=!i,o=!i&&e.detached&&!e.isCurrent,[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=i?e.path:s?e.relativePath:e.path,f=(0,Y.useCallback)(async()=>{try{await ZQ(d),u(!0),window.setTimeout(()=>u(!1),1200)}catch(e){console.error(`[Git] Failed to copy worktree path:`,e)}},[d]);return(0,J.jsx)(`div`,{className:`min-w-0 rounded-e-md rounded-t-md border px-2.5 py-2 ${t?`${KQ} ${qQ}`:`border-border/70 bg-muted/15`}`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,J.jsx)(ym,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.branchName})]}),(0,J.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-1`,children:[a?(0,J.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`text-muted-foreground hover:text-foreground inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-transparent`,title:s?`Show absolute path`:`Show relative path`,"aria-label":s?`Show absolute path`:`Show relative path`,children:s?(0,J.jsx)(hm,{className:`h-3.5 w-3.5`}):(0,J.jsx)(gm,{className:`h-3.5 w-3.5`})}):null,(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{f()},onDoubleClick:()=>{a&&c(e=>!e)},className:`text-muted-foreground hover:text-foreground inline-flex min-w-0 flex-1 items-center gap-1 truncate text-left text-xs`,title:d,"aria-label":`Copy ${s&&a?`relative`:`absolute`} path for ${e.branchName}`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:d}),l?(0,J.jsx)(Xp,{className:`h-3 w-3 shrink-0`}):(0,J.jsx)(rm,{className:`h-3 w-3 shrink-0`})]})]})]}),(0,J.jsx)(`div`,{className:`shrink-0 text-right`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[o?(0,J.jsx)(`button`,{type:`button`,onClick:()=>{r?.(e)},disabled:n,className:`text-muted-foreground hover:text-destructive inline-flex h-5 w-5 items-center justify-center rounded border border-transparent disabled:cursor-not-allowed disabled:opacity-60`,title:`Remove detached worktree`,"aria-label":`Remove detached worktree`,children:n?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`})}):null,(0,J.jsx)(a$,{ahead:e.ahead,behind:e.behind}),(0,J.jsx)(i$,{files:e.diff.files}),(0,J.jsx)(r$,{diff:e.diff,className:`justify-end`})]})})]})})}function r$({diff:e,className:t=``}){return JQ(e)&&!uKe(e)?null:JQ(e)?(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] ${t}`,children:[(0,J.jsxs)(`span`,{className:`bg-emerald-500/12 inline-flex items-center gap-0.5 rounded border border-emerald-500/40 px-[0.15rem] py-0 font-mono text-[10px] text-emerald-700 dark:border-emerald-300/45 dark:bg-emerald-400/20 dark:text-emerald-100`,children:[(0,J.jsx)(Pm,{className:`h-2.5 w-2.5`}),(0,J.jsx)(`span`,{children:e.insertions})]}),(0,J.jsxs)(`span`,{className:`bg-rose-500/12 inline-flex items-center gap-0.5 rounded border border-rose-500/40 px-[0.15rem] py-0 font-mono text-[10px] text-rose-700 dark:border-rose-300/45 dark:bg-rose-400/20 dark:text-rose-100`,children:[(0,J.jsx)(Yce,{className:`h-2.5 w-2.5`}),(0,J.jsx)(`span`,{children:e.deletions})]})]}):(0,J.jsx)(`span`,{className:`inline-flex items-center rounded border border-zinc-500/35 bg-zinc-500/10 px-[0.15rem] py-0 font-mono text-[10px] text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100 ${t}`,children:e.state===`loading`?`loading`:`n/a`})}function i$({files:e}){return e<=0?null:(0,J.jsxs)(_h,{tone:`custom`,size:`xs`,shape:`box`,className:`h-auto min-w-0 border border-zinc-500/35 bg-zinc-500/10 px-[0.15rem] py-0 font-mono text-[10px] font-normal text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100`,children:[e,`f`]})}function a$({ahead:e,behind:t}){return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-zinc-500/35 bg-zinc-500/10 px-[0.15rem] py-0 font-mono text-[10px] text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100`,children:[(0,J.jsxs)(`span`,{children:[`↑`,e]}),(0,J.jsxs)(`span`,{children:[`↓`,t]})]})}function dKe({options:e,value:t,onValueChange:n,progress:r,showProgress:i,disabled:a,animated:o,onRefresh:s}){return(0,J.jsxs)(`div`,{className:`border-border bg-card inline-flex overflow-hidden rounded-md border`,children:[(0,J.jsx)(YW,{value:t,options:e,onValueChange:n,ariaLabel:`Git auto refresh`,className:`text-foreground/75 hover:text-foreground border-r-current/10 bg-muted/20 relative isolate h-7 w-9 shrink-0 justify-center rounded-none border-0 border-r px-0`,positionerClassName:`z-50`,popupClassName:`min-w-[7rem]`,renderTrigger:({selectedOption:e})=>(0,J.jsxs)(`span`,{className:`relative inline-flex h-full w-full items-center justify-center overflow-hidden`,children:[(0,J.jsx)(`span`,{className:`bg-muted/20 pointer-events-none absolute inset-0`}),i?(0,J.jsx)(`span`,{className:`bg-primary/30 dark:bg-primary/35 pointer-events-none absolute inset-y-0 left-0 transition-[width]`,style:{width:`${r*100}%`}}):null,(0,J.jsx)(`span`,{className:`relative z-10 inline-flex items-center justify-center`,children:(0,J.jsx)(QQ,{preset:e?.value??t})})]})}),(0,J.jsxs)(`button`,{type:`button`,onClick:s,disabled:a,className:`inline-flex h-7 items-center gap-1 px-2 py-1 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-70 ${o?`text-primary bg-primary/10`:`text-foreground/75 hover:text-foreground`}`,children:[(0,J.jsx)(Fm,{className:`h-3.5 w-3.5 ${o?`animate-spin`:``}`}),`Refresh`]})]})}var o$=32,s$=.08,c$=.95;function fKe(e,t){if(e.length<=t)return e;let n=[],r=e.length/t;for(let i=0;i<t;i+=1){let t=Math.floor(i*r),a=Math.floor((i+1)*r),o=e.slice(t,Math.max(a,t+1)),s=o.reduce((e,t)=>e+t,0)/o.length;n.push(s)}return n}function pKe(e,t){if(e.length===0)return[];if(t===`monotonic`){let t=Math.max(...e);return t<=0?e.map(()=>s$):e.map(e=>Math.max(0,e)/t*(c$-s$)+s$)}let n=Math.min(...e),r=Math.max(...e);return n===r?e.map(()=>.55):e.map(e=>(e-n)/(r-n)*.8+.15)}function mKe(e){return e.length===0?[]:e.map((t,n)=>n===0?`flat`:t>e[n-1]?`up`:t<e[n-1]?`down`:`flat`)}function hKe({bars:e,directions:t,trendKind:n}){if(e.length===0)return null;let r=e.length===1?Array.from({length:12},()=>e[0]):e,i=t.length===1?Array.from({length:r.length},()=>t[0]??`flat`):t;return(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-end gap-px px-2 py-2 opacity-50`,"data-testid":`dashboard-mini-trend-bars`,children:r.map((e,t)=>{let r=i[t]??`flat`;return(0,J.jsx)(`span`,{className:`${n===`bidirectional`?r===`up`?`bg-emerald-500/30`:r===`down`?`bg-rose-500/30`:`bg-primary/25`:`bg-primary/25`} block flex-1 rounded-sm`,"data-testid":`dashboard-mini-trend-bar`,"data-direction":r,style:{height:`${Math.max(8,Math.round(e*100))}%`}},t)})})}function gKe(e,t){if(e.length<=t)return e;let n=[],r=e.length/t;for(let i=0;i<t;i+=1){let t=Math.floor(i*r),a=Math.floor((i+1)*r),o=e.slice(t,Math.max(a,t+1)),s=o[o.length-1]?.ts??e[e.length-1].ts;n.push({ts:s,add:o.reduce((e,t)=>e+t.add,0),modify:o.reduce((e,t)=>e+t.modify,0),delete:o.reduce((e,t)=>e+t.delete,0)})}return n}function _Ke(e){if(e.length===0)return[];let t=e.map(e=>e.add+e.modify+e.delete),n=Math.max(...t);return n<=0?e.map(()=>({height:0,addRatio:0,modifyRatio:0,deleteRatio:0})):e.map(e=>{let t=e.add+e.modify+e.delete;return t<=0?{height:0,addRatio:0,modifyRatio:0,deleteRatio:0}:{height:t/n*(c$-s$)+s$,addRatio:e.add/t,modifyRatio:e.modify/t,deleteRatio:e.delete/t}})}function vKe({bars:e}){if(e.length===0)return null;let t=e.length===1?Array.from({length:12},()=>e[0]):e;return(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-end gap-px px-2 py-2 opacity-55`,"data-testid":`dashboard-mini-tricolor-bars`,children:t.map((e,t)=>{let n=Math.max(0,Math.round(e.height*100));return n<=0?(0,J.jsx)(`span`,{className:`bg-border/45 block min-h-px flex-1 rounded-sm`,"data-testid":`dashboard-mini-tricolor-bar`},t):(0,J.jsxs)(`span`,{className:`flex flex-1 flex-col-reverse overflow-hidden rounded-sm`,"data-testid":`dashboard-mini-tricolor-bar`,style:{height:`${n}%`,minHeight:`1px`},children:[e.addRatio>0&&(0,J.jsx)(`span`,{className:`bg-primary/40 block w-full`,style:{flexGrow:e.addRatio}}),e.modifyRatio>0&&(0,J.jsx)(`span`,{className:`bg-secondary/55 block w-full`,style:{flexGrow:e.modifyRatio}}),e.deleteRatio>0&&(0,J.jsx)(`span`,{className:`bg-foreground/35 block w-full`,style:{flexGrow:e.deleteRatio}})]},t)})})}function l$({label:e,value:t,icon:n,availability:r,trendKind:i,points:a,triColorPoints:o=[],pending:s=!1,className:c}){let l=gKe(o,o$),u=_Ke(l),d=l.some(e=>e.add+e.modify+e.delete>0),f=fKe(a.map(e=>e.value),o$),p=pKe(f,i),m=mKe(f),h=r.state===`invalid`,g=d||f.length>=2,_=r.state===`invalid`&&r.reason===`objective-history-unavailable`?`No objective historical source`:`Insufficient computable data`;return(0,J.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border p-4 ${h?`border-border from-muted/35 to-muted/5 border-dashed bg-gradient-to-br`:`border-border bg-card`} ${c??``}`,"data-testid":`dashboard-metric-card`,"aria-busy":s,children:[!s&&!h&&(d?(0,J.jsx)(vKe,{bars:u}):(0,J.jsx)(hKe,{bars:p,directions:m,trendKind:i})),s?(0,J.jsxs)(`div`,{className:`relative z-10 flex h-full flex-col`,"aria-hidden":`true`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,J.jsx)(FC,{className:`size-3.5 shrink-0 rounded-full`}),(0,J.jsx)(FC,{className:`h-4 w-2/3 max-w-56`})]}),(0,J.jsx)(FC,{className:`h-8 w-24`}),(0,J.jsx)(`div`,{className:`mt-auto flex h-1/2 items-end gap-1 pt-4`,children:Array.from({length:12},(e,t)=>(0,J.jsx)(FC,{className:`min-h-3 flex-1 rounded-sm`,style:{height:`${28+t*17%64}%`}},t))})]}):(0,J.jsxs)(`div`,{className:`relative z-10`,children:[(0,J.jsxs)(`div`,{className:`text-muted-foreground mb-1 flex items-center gap-2 text-sm`,children:[(0,J.jsx)(n,{className:`h-3.5 w-3.5`}),e]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),h&&(0,J.jsx)(`div`,{className:`text-muted-foreground mt-2 text-xs`,"data-testid":`dashboard-card-invalid-note`,children:_}),!h&&!g&&(0,J.jsx)(`div`,{className:`text-muted-foreground mt-2 text-xs`,"data-testid":`dashboard-card-trend-note`,children:`No trend yet`})]})]})}function u$(e){if(e instanceof Error)return e;if(typeof e==`object`&&e&&`message`in e){let t=e.message;if(typeof t==`string`)return Error(t)}return Error(String(e))}function d$(e,t,n,r=!0){return Kf((0,Y.useCallback)(t=>{if(!r)return{unsubscribe(){}};let n=!1;return e({onData(e){if(e.type===`snapshot`||e.type===`complete`){n=!0,e.snapshot.freshness===`current`?t.onEvent({type:`data`,data:e.snapshot.data}):t.onEvent({type:`display-stale`,data:e.snapshot.data});return}if(e.type===`stage`){e.phase===`start`&&n&&t.onEvent({type:`recompute-started`});return}e.type===`failed`&&t.onError(u$(e.error))},onError:t.onError})},[r,e]),t,[r],n)}function yKe(e,t){return t.identity===e.identity&&t.workGeneration===e.workGeneration}function bKe(e,t){return Kf((0,Y.useCallback)((t,n)=>{let r=!0,i=0,a=n.hasCached,o=null,s=!1,c=e=>r&&o!==null&&o.identity===e.identity&&o.workGeneration===e.workGeneration&&o.snapshotGeneration===e.snapshotGeneration&&o.state===e.state,l=async e=>{let n=++i;try{let o=await q.dashboard.getSummary.query();if(!r||n!==i||e&&(!c(e)||!yKe(e,o)))return;o.data&&(a=!0,t.onEvent({type:o.freshness===`current`?`data`:`display-stale`,data:o.data})),o.error&&t.onError(u$(o.error))}catch(a){if(!r||n!==i||e&&!c(e))return;t.onError(u$(a))}},u=e({onData(e){s=!0;let n=a;o=e,n&&e.state!==`ready`&&t.onEvent({type:`recompute-started`}),l(e)},onError:t.onError});return s||l(),{unsubscribe(){r=!1,i+=1,u.unsubscribe()}}},[e]),t,[],`dashboard.subscribeSummary.v2`)}async function xKe(){let e=await _f();return{summary:e.summary,specifications:e.specifications,activeChanges:e.activeChanges,trackedTaskPhaseCounts:e.trackedTaskPhaseCounts,recentArchives:e.recentArchives}}async function SKe(){let e=await _f();return{trends:e.trends,triColorTrends:e.triColorTrends,trendKinds:e.trendKinds,cardAvailability:e.cardAvailability,trendMeta:e.trendMeta}}async function CKe(){return(await _f()).git}function wKe(){let e=(0,Y.useCallback)(e=>q.dashboard.subscribeSummary.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),t=(0,Y.useCallback)(e=>q.dashboard.subscribeTrends.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),n=(0,Y.useCallback)(e=>q.dashboard.subscribeGit.subscribe(void 0,{onData:e.onData,onError:e.onError}),[]),r=bKe(e,xKe),i=r.data!==void 0,a=d$(t,SKe,`dashboard.subscribeTrends`,i),o=d$(n,CKe,`dashboard.subscribeGit`,i);return{data:(0,Y.useMemo)(()=>{if(!(!r.data||!a.data||!o.data))return{...r.data,...a.data,git:o.data}},[o.data,r.data,a.data]),isLoading:r.isLoading,error:r.error,regions:{summary:r,trends:a,git:o}}}async function TKe(e,t){B()||await q.dashboard.refreshGitSnapshot.query({scope:`code`,expectedBindingToken:t,reason:e})}var EKe=[{value:`30s`,label:`30s`},{value:`5min`,label:`5min`},{value:`30min`,label:`30min`},{value:`none`,label:`none`}];function DKe(e){return e===`manual-button`||e?.startsWith(`auto-refresh:`)===!0}function OKe(e){let t=e instanceof Error?e.message:String(e);if(typeof e==`object`&&e&&`data`in e){let n=e.data;if(typeof n==`object`&&n&&`code`in n){let e=n.code;if(typeof e==`string`&&e.length>0)return`${e}: ${t}`}}return t}function kKe(e){return{specifications:{state:`ok`},requirements:{state:`ok`},activeChanges:{state:`invalid`,reason:`objective-history-unavailable`},inProgressChanges:{state:`invalid`,reason:`objective-history-unavailable`},completedChanges:{state:`ok`},taskCompletionPercent:{state:`invalid`,reason:e===null?`semantic-uncomputable`:`objective-history-unavailable`}}}function AKe(){return{specifications:`monotonic`,requirements:`monotonic`,activeChanges:`bidirectional`,inProgressChanges:`bidirectional`,completedChanges:`monotonic`,taskCompletionPercent:`bidirectional`}}function jKe(e){return e.type===`uncommitted`&&(e.diff.files>0||e.diff.insertions>0||e.diff.deletions>0)}function MKe(e){let t=cKe(e),n=t.find(e=>e.type===`uncommitted`),r=t.filter(e=>e.type===`commit`);return n&&jKe(n)?[n,...r.slice(0,4)]:r.slice(0,5)}function NKe(){let e=B(),t=wKe(),{data:n,isLoading:r,error:i}=t,a=t.regions?.summary,o=t.regions?.trends,s=t.regions?.git,c=a?.data??(n?{summary:n.summary,specifications:n.specifications,activeChanges:n.activeChanges,trackedTaskPhaseCounts:n.trackedTaskPhaseCounts,recentArchives:n.recentArchives}:void 0),l=o?.data??(n?{trends:n.trends,triColorTrends:n.triColorTrends,trendKinds:n.trendKinds,cardAvailability:n.cardAvailability,trendMeta:n.trendMeta}:void 0),u=s?.data??n?.git??null,d=a?.isLoading??r,f=a?.isUpdating??!1,p=a?.error??i,m=o?.isLoading??(r&&!n),h=o?.isUpdating??!1,g=o?.error??null,_=s?.isLoading??(r&&!n),v=s?.isUpdating??!1,y=s?.error??null,b=d&&c===void 0,x=b||m&&l===void 0,S=b||_&&u===null,C=c!==void 0,{data:w,authority:T}=IQ(!e&&C),{data:E}=ep(C),{data:D}=$f(C),[O,k]=(0,Y.useState)(()=>BQ()),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(()=>Date.now()),[P,F]=(0,Y.useState)(()=>typeof document>`u`?!0:document.visibilityState===`visible`),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)(null),V=!e&&T.state===`current`&&u?.bindingToken!==null&&u?.bindingToken===w?.code.bindingToken?u?.bindingToken??null:null,ee=(0,Y.useCallback)(()=>{Vp.activatePop(`/opsx-propose`)},[]),te=(0,Y.useCallback)(()=>{Vp.activatePop(`/opsx-new`)},[]),ne=(0,Y.useCallback)(async e=>{V&&(z(null),await TKe(e,V))},[V]),re=(0,Y.useRef)(null),ie=(0,Y.useRef)(O),ae=I?.reason??null,oe=(0,Y.useCallback)(()=>{re.current!==null&&(window.clearTimeout(re.current),re.current=null)},[]),se=(0,Y.useCallback)(e=>{let t=Date.now(),n=HQ(O);j(n===null?null:t+n),L({reason:e,requestedAt:t}),ne(e).then(()=>{L(n=>n?.reason===e&&n.requestedAt===t?null:n)}).catch(n=>{console.error(`[Dashboard] Failed to refresh git snapshot:`,n),z(OKe(n)),L(n=>n?.reason===e&&n.requestedAt===t?null:n)})},[O,ne]),ce=(0,Y.useCallback)(()=>{oe();let t=HQ(O),n=O===`none`?null:UQ(O);if(e||V===null||t===null||n===null||I!==null||v||!P)return;let r=Date.now(),i=A??r+t;if(A===null&&j(i),N(r),r>=i){se(n);return}re.current=window.setTimeout(()=>{re.current=null,N(Date.now()),se(n)},i-r)},[oe,V,A,O,I,v,P,se,e]),le=(0,Y.useCallback)(()=>{V!==null&&(oe(),N(Date.now()),se(`manual-button`))},[oe,V,se]);(0,Y.useEffect)(()=>{if(e)return;let t=()=>{let e=document.visibilityState===`visible`;F(e),e||oe()};return document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t)}},[oe,e]),(0,Y.useEffect)(()=>{if(!e&&(VQ(O),ie.current!==O)){ie.current=O;let e=HQ(O);j(e===null?null:Date.now()+e)}},[O,e]),(0,Y.useEffect)(()=>{if(!e)return ce(),()=>{oe()}},[oe,ce,e]),(0,Y.useEffect)(()=>{let t=HQ(O);if(e||t===null||A===null)return;let n=()=>{N(Date.now())};n();let r=window.setInterval(n,250);return()=>{window.clearInterval(r)}},[A,O,e]);let ue=c?.activeChanges??[],de=(0,Y.useMemo)(()=>new Set(ue.map(e=>e.id)),[ue]),fe=(0,Y.useMemo)(()=>(E??[]).filter(e=>de.has(e.changeName)),[E,de]),pe=(0,Y.useMemo)(()=>{let e=D?.schemaDetails??{},t=new Map;for(let[n,r]of Object.entries(e)){if(!r?.applyTracks)continue;let e=r.artifacts.find(e=>e.outputPath===r.applyTracks);e?.id&&t.set(n,e.id)}return t},[D]),me=c?.summary??{specifications:0,requirements:0,activeChanges:0,inProgressChanges:0,completedChanges:0,archivedTasksCompleted:0,tasksTotal:0,tasksCompleted:0,taskCompletionPercent:null},he=l?.cardAvailability??kKe(me.taskCompletionPercent),ge=l?.trendKinds??AKe(),_e=e||T.state===`current`&&w!==void 0&&u?.bindingToken!==null&&u?.bindingToken===w?.code.bindingToken,ve=_e&&u?u:{bindingToken:null,defaultBranch:`main`,worktrees:[]},ye=e?ve.worktrees.some(e=>e.entries.length>0):_e,be=e?ye:!0,xe=ue.length>0,H=ve.worktrees.find(e=>e.isCurrent)??null,Se=ve.worktrees.filter(e=>!e.isCurrent).filter(e=>!e.detached),Ce=H?MKe(H.entries):[],we=HQ(O),Te=A!==null&&we!==null?A-we:null,Ee=I===null?GQ(Te,we,M):0,De=we!==null&&I===null,Oe=I!==null&&DKe(ae),ke=I!==null||v||V===null,Ae=()=>(0,J.jsxs)(`div`,{className:`space-y-2`,children:[g?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Dashboard trends failed: `,g.message]})]}):null,(0,J.jsx)(PC,{active:h&&!!l,children:(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,J.jsx)(l$,{label:`Specifications / Requirements`,value:`${me.specifications} / ${me.requirements}`,icon:um,availability:he.specifications,trendKind:ge.specifications,points:l?.trends.specifications??[],triColorPoints:[],pending:x,className:`h-44 sm:h-48 lg:h-52 xl:h-56`}),(0,J.jsx)(l$,{label:`Archived Changes / Completed Tasks`,value:`${me.completedChanges} / ${me.archivedTasksCompleted}`,icon:Hp,availability:he.completedChanges,trendKind:ge.completedChanges,points:l?.trends.completedChanges??[],triColorPoints:[],pending:x,className:`h-44 sm:h-48 lg:h-52 xl:h-56`})]})})]}),je=()=>(0,J.jsxs)(`section`,{"data-testid":`dashboard-kanban-row`,className:`border-border @container min-w-0 space-y-2 border-b`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Kanban`}),(0,J.jsx)(Rp,{to:`/board`,"aria-label":`Open Kanban`,title:`Open Kanban`,className:`text-muted-foreground hover:text-foreground inline-flex h-8 w-8 items-center justify-center rounded-md`,children:(0,J.jsx)(Km,{className:`h-4 w-4`})})]}),(0,J.jsx)(rZ,{variant:`compact`,pending:b,activeItems:ue,archivedItems:c?.recentArchives??[],activeCounts:c?.trackedTaskPhaseCounts??{"no-tasks":0,"in-progress":0,complete:0},archivedCount:me.completedChanges})]}),Me=()=>be?(0,J.jsxs)(`section`,{"data-testid":`dashboard-git-snapshot`,className:`min-w-0 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Code Git Snapshot`}),(0,J.jsx)(`p`,{className:`text-muted-foreground truncate text-xs`,children:ye?`Default branch: ${ve.defaultBranch}`:`Waiting for the current Code Git projection.`})]}),e?null:(0,J.jsx)(dKe,{options:EKe,value:O,onValueChange:k,progress:Ee,showProgress:De,disabled:ke,animated:Oe,onRefresh:le})]}),y?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-xs`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Code Git snapshot failed: `,y.message]})]}):null,S?(0,J.jsxs)(`div`,{"aria-busy":`true`,className:`border-border/80 bg-card min-w-0 space-y-3 rounded-lg border p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:[(0,J.jsx)(FC,{className:`size-4 shrink-0 rounded-full`}),(0,J.jsx)(FC,{className:`h-3 w-36`})]}),(0,J.jsx)(VC,{count:3})]}):null,!ye&&u&&!S&&!y?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`Waiting for the current Code Git binding.`}):null,ye?(0,J.jsx)(PC,{active:v&&!!u,children:(0,J.jsxs)(`div`,{className:`border-border/80 bg-card min-w-0 rounded-lg border p-3`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,J.jsx)(ym,{className:`text-muted-foreground h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[`Default branch: `,ve.defaultBranch]})]}),H?(0,J.jsxs)(`div`,{className:`space-y-0`,children:[(0,J.jsx)(n$,{worktree:H,emphasize:!0}),(0,J.jsx)(`div`,{className:`-mt-px space-y-1 border-l pl-3 pt-2 ${lKe}`,children:Ce.map(t=>(0,J.jsx)(t$,{entry:t,onSelect:e?void 0:(e,t)=>{ve.bindingToken!==null&&Vp.push(`bottom`,vs(e),cp(void 0,e$(e,ve.bindingToken)),{source:t,sharedElements:$Q(e)})}},t.type===`commit`?t.hash:`${t.type}:${t.updatedAt??`none`}`))})]}):(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-2.5 py-2 text-xs`,children:`No worktree snapshot available.`}),Se.length>0&&(0,J.jsxs)(`div`,{className:`border-border/70 mt-3 space-y-1 border-t pt-2`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground text-xs uppercase tracking-wide`,children:`Other Worktrees`}),Se.map(e=>(0,J.jsx)(n$,{worktree:e,emphasize:!1},e.path))]})]})}):null]}):null,Ne=()=>(0,J.jsxs)(`section`,{"data-testid":`dashboard-active-changes`,className:`border-border flex min-w-0 flex-col rounded-t-lg border`,children:[(0,J.jsxs)(`div`,{className:`border-border flex min-w-0 flex-wrap items-center justify-between gap-1.5 border-b px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Active Changes`}),b?(0,J.jsx)(FC,{className:`h-4 w-16`}):(0,J.jsxs)(`span`,{className:`text-muted-foreground text-xs sm:text-sm`,children:[me.activeChanges,` active`]})]}),(0,J.jsxs)(`div`,{className:`bg-card divide-border flex min-w-0 flex-1 flex-col divide-y`,children:[b?(0,J.jsx)(zC,{count:3}):null,!b&&ue.map(e=>{let t=fe.find(t=>t.changeName===e.id),n=t?.artifacts.filter(e=>e.status===`done`).length??0,r=t?.artifacts.length??0,i=t?pe.get(t.schemaName):void 0,a=i&&t?t.artifacts.find(e=>e.id===i)?.status??pZ(t.artifacts.map(e=>e.status)):pZ(t?.artifacts.map(e=>e.status)??[]),o=fZ({hasStatus:!!t,isPlanningComplete:t?.isPlanningComplete??!1,trackedArtifactStatus:a,cliCompletedTasks:e.cliTaskSummary?.completedTasks??null}),s=e.cliTaskSummary,c=s&&s.totalTasks>0?s.completedTasks/s.totalTasks:null,l=s?(0,J.jsxs)(`span`,{title:`Task counts reported by the OpenSpec CLI for this Change.`,children:[`Tasks `,s.completedTasks,`/`,s.totalTasks]}):null;return(0,J.jsx)(Rp,{to:`/changes/$changeId`,params:{changeId:e.id},state:t=>({...t,__vtHandoff:{family:`changes`,entityId:e.id,title:e.name,subtitle:e.id}}),vt:{sharedElements:{family:`changes`,entityId:e.id}},...op({family:`changes`,entityId:e.id},`container`),className:`hover:bg-muted/50 block min-w-0 px-4 py-3`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,J.jsx)(uZ,{changeId:e.id,name:e.name,phase:o,updatedAt:e.updatedAt,formatTime:vw,progressRatio:c,className:`min-w-0 flex-1`,subtitle:t?(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`span`,{children:[n,`/`,r,` artifacts · `,t.schemaName]}),l?(0,J.jsxs)(J.Fragment,{children:[` · `,l]}):null]}):l??`Artifacts status unavailable`}),(0,J.jsx)(dZ,{})]})},e.id)}),!b&&!xe&&(0,J.jsxs)(`div`,{className:`text-muted-foreground px-4 py-6 text-center text-sm`,children:[(0,J.jsx)(`div`,{children:`No active changes.`}),(0,J.jsx)(`div`,{className:`mt-1 text-xs`,children:`Recommended workflow start: Quick Propose`}),(0,J.jsxs)(`button`,{type:`button`,onClick:te,className:`text-primary mt-2 inline-flex items-center gap-1 hover:underline`,title:`Open the advanced /opsx:new form`,children:[(0,J.jsx)(Gm,{className:`h-3.5 w-3.5`}),`Open /opsx:new form`]})]})]})]});return(0,J.jsxs)(`div`,{className:`@container min-w-0 space-y-6 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(Tm,{className:`h-6 w-6 shrink-0`}),`Dashboard`]}),(0,J.jsxs)(`button`,{type:`button`,onClick:ee,className:`bg-primary text-primary-foreground inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm hover:opacity-90`,title:`Open Quick Propose.`,children:[(0,J.jsx)(Gm,{className:`h-4 w-4`}),`Start Propose`]})]}),(0,J.jsx)(PC,{active:f&&!!c,children:(0,J.jsx)(tKe,{staticMode:e})}),p?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Error loading dashboard: `,p.message]})]}):null,R?(0,J.jsxs)(`div`,{role:`alert`,className:`border-destructive/40 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{children:[`Git action failed: `,R]})]}):null,(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-medium`,children:`Historical Trends`}),Ae()]}),je(),(0,J.jsxs)(`div`,{"data-testid":`dashboard-secondary-grid`,className:`@[64rem]:grid-cols-2 grid min-w-0 gap-3`,children:[Ne(),Me()]})]})}function PKe({worktree:e,emphasize:t,removing:n=!1,action:r,onRemoveDetachedWorktree:i}){let a=XQ(e.path),o=!a,s=!a&&e.detached&&!e.isCurrent,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=a?e.path:c?e.relativePath:e.path,p=(0,Y.useCallback)(async()=>{try{await ZQ(f),d(!0),window.setTimeout(()=>d(!1),1200)}catch(e){console.error(`[Git] Failed to copy worktree path:`,e)}},[f]);return(0,J.jsxs)(`article`,{className:`min-w-0 rounded-md border p-3 ${t?`${KQ} ${qQ}`:`border-border/70 bg-muted/15`}`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5 text-sm font-medium`,children:[(0,J.jsx)(ym,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 break-words leading-snug`,children:e.branchName})]})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[s?(0,J.jsx)(`button`,{type:`button`,onClick:()=>{i?.(e)},disabled:n,className:`text-muted-foreground hover:text-destructive inline-flex h-7 w-7 items-center justify-center rounded border border-transparent disabled:cursor-not-allowed disabled:opacity-60`,title:`Remove detached worktree`,"aria-label":`Remove detached worktree`,children:n?(0,J.jsx)(Am,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`})}):null,(0,J.jsx)(a$,{ahead:e.ahead,behind:e.behind}),(0,J.jsx)(i$,{files:e.diff.files}),(0,J.jsx)(r$,{diff:e.diff,className:`justify-end`}),r]})]}),(0,J.jsxs)(`div`,{className:`bg-muted/25 mt-3 flex min-w-0 items-start gap-2 rounded-md px-2 py-1.5`,children:[o?(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`text-muted-foreground hover:text-foreground mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-transparent`,title:c?`Show absolute path`:`Show relative path`,"aria-label":c?`Show absolute path`:`Show relative path`,children:c?(0,J.jsx)(hm,{className:`h-3.5 w-3.5`}):(0,J.jsx)(gm,{className:`h-3.5 w-3.5`})}):null,(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{p()},onDoubleClick:()=>{o&&l(e=>!e)},className:`text-muted-foreground hover:text-foreground flex min-w-0 flex-1 items-start gap-1 text-left text-xs leading-snug`,title:f,"aria-label":`Copy ${c&&o?`relative`:`absolute`} path for ${e.branchName}`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-all`,children:f}),u?(0,J.jsx)(Xp,{className:`mt-0.5 h-3 w-3 shrink-0`}):(0,J.jsx)(rm,{className:`mt-0.5 h-3 w-3 shrink-0`})]})]})]})}function f$(e,t){return e.scope===t.scope&&e.bindingToken===t.bindingToken}function FKe(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return r!==void 0&&hs(e)===hs(r)}):!1}function IKe(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function LKe(e){if(typeof document>`u`){e.update();return}let t=document;if(!e.container||IKe()||typeof t.startViewTransition!=`function`||t.activeViewTransition){e.update();return}e.container.style.viewTransitionName=e.transitionName;try{t.startViewTransition(()=>(0,Kr.flushSync)(e.update)).finished.catch(()=>{}).finally(()=>{e.container?.style.viewTransitionName===e.transitionName&&(e.container.style.viewTransitionName=``)})}catch{e.container.style.viewTransitionName=``,e.update()}}function RKe(e,t,n){let[r,i]=(0,Y.useState)(e),a=(0,Y.useRef)(e),o=(0,Y.useRef)(t),s=(0,Y.useRef)(0),c=(0,Y.useRef)(!1),l=`vt-git-list-${(0,Y.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,u=!f$(o.current,t)||!c.current||e===void 0;return(0,Y.useLayoutEffect)(()=>{if(!c.current){c.current=!0,o.current=t,a.current=e,i(e);return}if(!f$(o.current,t)){o.current=t,a.current=e,s.current+=1,i(e);return}let r=a.current;if(a.current=e,r===e)return;let u=s.current+1;if(s.current=u,e===void 0||r===void 0||FKe(r,e)){i(e);return}queueMicrotask(()=>{s.current===u&&LKe({container:n.current,transitionName:l,update:()=>{s.current===u&&i(e)}})})},[n,e,t.scope,t.bindingToken,l]),u?e:r}var zKe=[{value:`30s`,label:`30s`},{value:`5min`,label:`5min`},{value:`30min`,label:`30min`},{value:`none`,label:`none`}];function BKe(e){return e===`manual-button`||e?.startsWith(`auto-refresh:`)===!0}function VKe(){let e=B(),t=vi(),{requestedScope:n,scope:r,descriptor:i,scopes:a,locationSearch:o,planningReady:s,planningMessage:c,query:l}=LQ(!e),u=i?.bindingToken??null,d=l.authority.state!==`current`,f=(0,Y.useRef)(d);f.current=d;let p=Ai({queryKey:[`git`,r,u,`overview`],queryFn:()=>{if(!u)throw Error(`Git repository binding is unavailable.`);return q.git.overview.query({scope:r,expectedBindingToken:u})},enabled:!e&&!d&&u!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}),m=jte({queryKey:[`git`,r,u,`entries`],initialPageParam:void 0,queryFn:({pageParam:e})=>u?q.git.listEntries.query({scope:r,expectedBindingToken:u,cursor:e,limit:50}):Promise.reject(Error(`Git repository binding is unavailable.`)),getNextPageParam:e=>e.nextCursor??void 0,enabled:!e&&!d&&u!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}),[h,g]=(0,Y.useState)(()=>BQ()),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(()=>Date.now()),[x,S]=(0,Y.useState)(()=>typeof document>`u`?!0:document.visibilityState===`visible`),[C,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),k=ji({mutationFn:e=>q.git.switchWorktree.mutate(e)}),A=(0,Y.useMemo)(()=>m.data?.pages.flatMap(e=>e.items)??[],[m.data]),j=(0,Y.useRef)(null),M=RKe(A,{scope:r,bindingToken:u},j),N=(0,Y.useRef)(0),P=(0,Y.useRef)(null),F=(0,Y.useRef)(C),I=(0,Y.useRef)(!1),L=d||C!==null||k.isPending||T!==null,R=C?.reason??null,z=(0,Y.useCallback)(()=>{P.current!==null&&(window.clearTimeout(P.current),P.current=null)},[]),V=(0,Y.useCallback)(e=>{if(!u||f.current)return;let n=Date.now();w({reason:e,requestedAt:n}),(async()=>{try{await q.git.refresh.query({scope:r,expectedBindingToken:u,reason:e}),await t.invalidateQueries({queryKey:[`git`,r,u],refetchType:`active`})}catch(e){console.error(`[GitRoute] Failed to refresh git data:`,e)}finally{w(t=>t?.reason===e&&t.requestedAt===n?null:t)}})()},[u,t,r]),ee=(0,Y.useCallback)(()=>{z();let t=HQ(h),n=h===`none`?null:UQ(h);if(e||t===null||n===null||L||!x){v(null);return}let r=Date.now();v(r),b(r),P.current=window.setTimeout(()=>{P.current=null,v(null),b(Date.now()),V(n)},t)},[z,h,x,L,V,e]),te=(0,Y.useCallback)(()=>{L||(z(),v(null),b(Date.now()),V(`manual-button`))},[z,L,V]),ne=(0,Y.useCallback)(async n=>{if(!(!u||f.current||e||n.isCurrent||!n.detached)&&window.confirm([`Remove detached worktree?`,``,n.path,``,`This runs git worktree remove --force.`].join(`
1336
1336
  `))){E(n.path);try{await q.git.removeDetachedWorktree.mutate({scope:r,expectedBindingToken:u,path:n.path}),await t.invalidateQueries({queryKey:[`git`,r,u],refetchType:`active`})}catch(e){console.error(`[GitRoute] Failed to remove detached worktree:`,e),window.alert(e instanceof Error?e.message:`Failed to remove detached worktree.`)}finally{E(e=>e===n.path?null:e)}}},[u,t,r,e]),re=(0,Y.useCallback)(async e=>{if(!(!u||f.current)){O(e.path);try{fs({handoff:await k.mutateAsync({scope:r,expectedBindingToken:u,path:e.path}),location:window.location})}catch(e){console.error(`[GitRoute] Failed to switch worktree:`,e),window.alert(e instanceof Error?e.message:`Failed to switch worktree.`)}finally{O(t=>t===e.path?null:t)}}},[u,r,k]);(0,Y.useEffect)(()=>{F.current=C},[C]),(0,Y.useEffect)(()=>{I.current=L},[L]),(0,Y.useEffect)(()=>{if(e)return;let t=e=>{if(F.current!==null||I.current)return;let t=Date.now();t-N.current<700||(N.current=t,z(),v(null),b(Date.now()),V(e))},n=()=>t(`window-focus`),r=()=>{let e=document.visibilityState===`visible`;S(e),e&&t(`document-visible`)};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,r),()=>{window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,r)}},[z,V,e]),(0,Y.useEffect)(()=>{e||VQ(h)},[h,e]),(0,Y.useEffect)(()=>{if(!e)return ee(),()=>{z()}},[z,ee,e]),(0,Y.useEffect)(()=>{let t=HQ(h);if(e||t===null||_===null||L)return;let n=()=>{b(Date.now())};n();let r=window.setInterval(n,250);return()=>{window.clearInterval(r)}},[_,h,L,e]);let ie=p.data,ae=ie?.currentWorktree??null,oe=ie?.otherWorktrees??[],se=HQ(h),ce=L||se===null?0:GQ(_,se,y),le=L&&BKe(R);return e?(0,J.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 p-4 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`}),`Git panel is only available in live mode.`]}):l.authority.state===`failed`?(0,J.jsxs)(`div`,{className:`text-destructive flex items-center gap-2 p-4`,children:[(0,J.jsx)($p,{className:`h-5 w-5 shrink-0`}),`Git repository scope projection failed: `,l.authority.error.message]}):d?(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,"aria-busy":`true`,"data-git-loading":`scopes`,"data-testid":`git-loading-region`,children:[(0,J.jsx)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:`Git`}),(0,J.jsx)(VC,{count:4})]}):p.isLoading&&!ie?(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,"aria-busy":`true`,"data-git-loading":`overview`,"data-testid":`git-loading-region`,children:[(0,J.jsx)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:`Git`}),(0,J.jsx)(VC,{count:4})]}):p.error&&!ie?(0,J.jsxs)(`div`,{className:`text-destructive flex items-center gap-2 p-4`,children:[(0,J.jsx)($p,{className:`h-5 w-5 shrink-0`}),`Error loading git panel: `,p.error.message]}):(0,J.jsxs)(`div`,{className:`min-w-0 space-y-4 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:[(0,J.jsx)(sm,{className:`h-6 w-6 shrink-0`}),`Git`]}),(0,J.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Commit history for the current worktree plus live handoff to sibling worktrees.`})]}),(0,J.jsxs)(`div`,{className:`border-border bg-card inline-flex overflow-hidden rounded-md border`,children:[(0,J.jsx)(YW,{value:h,options:zKe,onValueChange:g,ariaLabel:`Git auto refresh`,className:`text-foreground/75 hover:text-foreground border-r-current/10 bg-muted/20 relative isolate h-8 w-10 shrink-0 justify-center rounded-none border-0 border-r px-0`,positionerClassName:`z-50`,popupClassName:`min-w-[7rem]`,renderTrigger:({selectedOption:e})=>(0,J.jsxs)(`span`,{className:`relative inline-flex h-full w-full items-center justify-center overflow-hidden`,children:[(0,J.jsx)(`span`,{className:`bg-muted/20 pointer-events-none absolute inset-0`}),se!==null&&!L?(0,J.jsx)(`span`,{className:`bg-primary/30 dark:bg-primary/35 pointer-events-none absolute inset-y-0 left-0 transition-[width]`,style:{width:`${ce*100}%`}}):null,(0,J.jsx)(`span`,{className:`relative z-10 inline-flex items-center justify-center`,children:(0,J.jsx)(QQ,{preset:e?.value??h})})]})}),(0,J.jsxs)(`button`,{type:`button`,onClick:te,disabled:L,className:`inline-flex h-8 items-center gap-1 px-2 py-1 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-70 ${le?`bg-primary/10 text-primary`:`text-foreground/75 hover:text-foreground`}`,children:[(0,J.jsx)(Fm,{className:`h-3.5 w-3.5 ${le?`animate-spin`:``}`}),`Refresh`]})]})]}),(0,J.jsxs)(`section`,{className:`border-border bg-card flex flex-wrap items-center justify-between gap-3 rounded-md border p-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:r===`code`?`Code repository`:`Planning repository`}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,title:i?.rootPath,children:i?.repository?.topLevel??i?.rootPath}),n===`planning`&&r===`code`?(0,J.jsx)(`div`,{className:`text-muted-foreground mt-1 text-xs`,children:c}):null]}),a?.planning?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Git repository scope`,className:`border-border bg-muted/30 inline-flex overflow-hidden rounded-md border`,children:[`code`,`planning`].map(e=>(0,J.jsx)(`button`,{type:`button`,"aria-pressed":r===e,disabled:L||e===`planning`&&!s,onClick:()=>{if(r===e)return;let t=gs(`/git`,e,o);Vp.replace(Vp.getAreaForPath(`/git`),t)},className:`h-8 px-3 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${r===e?`bg-background text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e===`code`?`Code repository`:`Planning repository`},e))}):null]}),(0,J.jsxs)(`section`,{className:`bg-card space-y-3 rounded-lg border border-zinc-500/20 p-3`,children:[(0,J.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,J.jsx)(ym,{className:`h-4 w-4 shrink-0`}),(0,J.jsxs)(`span`,{className:`truncate`,children:[ae?.branchName??`(no worktree)`,` against`,` `,ie?.defaultBranch??`main`]})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground truncate text-xs`,children:`Current worktree summary and branch delta.`})]})}),ae?(0,J.jsx)(n$,{worktree:ae,emphasize:!0,removing:T===ae.path,onRemoveDetachedWorktree:ne}):(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`No Git worktree information is available for this project.`})]}),(0,J.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`font-medium`,children:`Commits`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[A.length,` loaded`]})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,ref:j,children:[(M??[]).map(e=>(0,J.jsx)(t$,{entry:e,onSelect:(e,t)=>{!u||f.current||Vp.push(`bottom`,vs(e,n,o),cp(void 0,e$(e,u)),{source:t,sharedElements:$Q(e)})}},`${u??`none`}:${hs(e)}`)),m.error?(0,J.jsx)(`div`,{className:`text-destructive border-current/20 rounded-md border px-3 py-3 text-sm`,children:m.error.message}):null,m.hasNextPage?(0,J.jsx)(`button`,{type:`button`,onClick:()=>{f.current||m.fetchNextPage()},disabled:d||m.isFetchingNextPage,"aria-busy":m.isFetchingNextPage||void 0,className:`hover:bg-muted w-full rounded-md border px-3 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-70`,children:`Load older commits`}):A.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`No uncommitted files or commits ahead of the default branch.`}):null]})]}),oe.length>0?(0,J.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Wp,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`h2`,{className:`font-medium`,children:`Other Worktrees`})]}),(0,J.jsx)(`div`,{className:`grid min-w-0 gap-3 [grid-template-columns:repeat(auto-fit,minmax(min(100%,22rem),1fr))]`,children:oe.map(e=>(0,J.jsx)(PKe,{worktree:e,emphasize:!1,removing:T===e.path,onRemoveDetachedWorktree:ne,action:e.pathAvailable?(0,J.jsx)(gh,{content:`Switch to ${e.branchName}`,sideOffset:8,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>{re(e)},disabled:D===e.path,className:`bg-primary text-primary-foreground inline-flex h-8 w-8 items-center justify-center rounded-md transition-colors disabled:cursor-not-allowed disabled:opacity-70`,title:`Switch to ${e.branchName}`,"aria-label":`Switch to ${e.branchName}`,children:D===e.path?(0,J.jsx)(Am,{className:`h-4 w-4 animate-spin`}):(0,J.jsx)(Wp,{className:`h-4 w-4`})})}):(0,J.jsx)(`span`,{className:`text-muted-foreground rounded-md border border-dashed px-2.5 py-1 text-[11px]`,children:`Path missing`})},e.path))})]}):null]})}var p$=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(!this.state.error)return this.props.children;let{fallback:e}=this.props;return typeof e==`function`?e(this.state.error):e}},HKe=/^[A-Za-z]:\/$/;function m$(e){let t=e.replace(/\\/g,`/`);return t===`/`||HKe.test(t)?t:t.replace(/\/+$/g,``)}function h$(e){return m$(e).split(`/`).filter(Boolean)}function UKe(e){let[t,...n]=e.map(e=>h$(e.path).slice(0,-1)).filter(e=>e.length>0);if(!t)return[];let r=t.length;for(let e of n){r=Math.min(r,e.length);let n=0;for(;n<r&&t[n]===e[n];)n+=1;if(r=n,r===0)return[]}return t.slice(0,r)}function g$(e){return[...e].sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`directory`?-1:1)}function _$(e){let t=e.reduce((e,t)=>e+t.files,0);return e.some(e=>e.state===`loading`)?{state:`loading`,files:t}:e.every(e=>e.state===`ready`)?{state:`ready`,files:t,insertions:e.reduce((e,t)=>e+t.insertions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}:{state:`unavailable`,files:t}}function WKe(e,t){return{kind:`file`,key:e.fileId,name:t,diff:e.diff,file:e}}function GKe(e,t){return{kind:`directory`,key:e,name:t,diff:{state:`unavailable`,files:0},children:[]}}function v$(e,t,n,r,i){let a=n[r];if(!a)return;let o=i?`${i}/${a}`:a;if(r===n.length-1){e.set(o,WKe(t,a));return}let s=e.get(o),c=s?.kind===`directory`?s:GKe(o,a);e.set(o,c);let l=new Map(c.children.map(e=>[e.key,e]));v$(l,t,n,r+1,o),c.children=[...l.values()]}function y$(e){let t=e,n=[e.name];for(;t.children.length===1&&t.children[0]?.kind===`directory`;)t=t.children[0],n.push(t.name);let r=g$(t.children.map(e=>e.kind===`directory`?y$(e):e));return{...t,name:n.join(`/`),diff:_$(r.map(e=>e.diff)),children:r}}function KKe(e,t={}){let n=t.projectDir?m$(t.projectDir):null,r=n?[]:UKe(e),i=r.join(`/`),a=new Map;for(let t of e){let e=h$(t.path).slice(r.length);e.length!==0&&v$(a,t,e,0,``)}let o=g$([...a.values()].map(e=>e.kind===`directory`?y$(e):e));return n?[{kind:`directory`,key:n,name:n,diff:_$(o.map(e=>e.diff)),children:o}]:i.length===0?o:[{kind:`directory`,key:i,name:i,diff:_$(o.map(e=>e.diff)),children:o}]}function qKe(e){let{currentKey:t,visibleKeySet:n,parentByKey:r,firstItemKey:i}=e;if(t&&n.has(t))return t;let a=t?r.get(t)??null:null;for(;a;){if(n.has(a))return a;a=r.get(a)??null}return i}function JKe({items:e,itemsByKey:t,parentByKey:n,treeRef:r,onToggleDirectory:i,onSelectFile:a}){let o=(0,Y.useRef)(new Map),[s,c]=(0,Y.useState)(null),l=(0,Y.useMemo)(()=>new Set(e.map(e=>e.key)),[e]),u=(0,Y.useMemo)(()=>new Map(e.map((e,t)=>[e.key,t])),[e]),d=qKe({currentKey:s,visibleKeySet:l,parentByKey:n,firstItemKey:e[0]?.key??null}),f=(0,Y.useCallback)(e=>{e&&(c(e),o.current.get(e)?.focus())},[]),p=(0,Y.useCallback)(e=>{c(e)},[]);return{focusedKey:d,handleItemClick:(0,Y.useCallback)(e=>{let n=t.get(e);if(n){if(c(e),n.kind===`directory`){i(e);return}a(n.node.file.fileId)}},[t,a,i]),handleItemFocus:p,handleItemKeyDown:(0,Y.useCallback)((r,o)=>{let s=t.get(o);if(!s)return;let c=u.get(o);if(c!=null)switch(r.key){case`ArrowDown`:r.preventDefault(),f(e[c+1]?.key??null);return;case`ArrowUp`:r.preventDefault(),f(e[c-1]?.key??null);return;case`Home`:r.preventDefault(),f(e[0]?.key??null);return;case`End`:r.preventDefault(),f(e.at(-1)?.key??null);return;case`ArrowRight`:if(s.kind!==`directory`)return;if(!s.expanded&&s.firstChildKey){r.preventDefault(),i(s.key);return}s.expanded&&s.firstChildKey&&(r.preventDefault(),f(s.firstChildKey));return;case`ArrowLeft`:{if(s.kind===`directory`&&s.expanded&&s.firstChildKey){r.preventDefault(),i(s.key);return}let e=n.get(s.key)??null;e&&(r.preventDefault(),f(e));return}case`Enter`:case` `:if(r.preventDefault(),s.kind===`directory`){i(s.key);return}a(s.node.file.fileId);return;default:return}},[e,t,f,a,i,n,u]),registerItemRef:(0,Y.useCallback)(e=>t=>{if(!t){o.current.delete(e);return}o.current.set(e,t)},[])}}function b$(e,t,n,r,i){for(let a of e){if(n.set(a.key,t),a.kind===`directory`){r.add(a.key),b$(a.children,a.key,n,r,i);continue}i.set(a.file.fileId,a.key)}}function x$(e,t,n){let r=0;for(let i of e){if(i.kind===`directory`){let e=x$(i.children,t,n);n.set(i.key,e),r=Math.max(r,e);continue}let e=t.get(i.file.fileId)??0;n.set(i.key,e),r=Math.max(r,e)}return r}function S$(e,t,n,r,i,a,o){let s=e.length;e.forEach((e,c)=>{let l=c===s-1;if(e.kind===`directory`){let u=!t.has(e.key);o.push({key:e.key,kind:`directory`,node:e,level:r,parentKey:i,posInSet:c+1,setSize:s,isLastSibling:l,guideMask:a,expanded:u,firstChildKey:e.children[0]?.key??null,visibilityRatio:n.get(e.key)??0}),u&&e.children.length>0&&S$(e.children,t,n,r+1,e.key,[...a,!l],o);return}o.push({key:e.key,kind:`file`,node:e,level:r,parentKey:i,posInSet:c+1,setSize:s,isLastSibling:l,guideMask:a,visibilityRatio:n.get(e.key)??0})})}function YKe(e,t,n=new Map){let r=new Map,i=new Set,a=new Map,o=[],s=new Map;return b$(e,null,r,i,a),x$(e,n,s),S$(e,t,s,1,null,[],o),{items:o,itemsByKey:new Map(o.map(e=>[e.key,e])),directoryKeys:i,parentByKey:r,keyByFileId:a}}var C$=14,XKe=new Map;function ZKe(e){switch(e){case`added`:return`text-emerald-700 dark:text-emerald-100`;case`deleted`:return`text-rose-700 dark:text-rose-100`;case`renamed`:case`copied`:return`text-sky-700 dark:text-sky-100`;case`modified`:return`text-amber-700 dark:text-amber-100`;default:return`text-zinc-700 dark:text-zinc-100`}}function QKe(e,t){if(!e.previousPath)return t;let n=e.previousPath.split(`/`).filter(Boolean).at(-1)??e.previousPath;return n===t?t:`${n} -> ${t}`}function $Ke({guideMask:e}){let t=e.length*C$;return(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none shrink-0 self-stretch`,style:{width:`${t}px`}})}function eqe({item:e,focused:t,onItemClick:n,onItemFocus:r,onItemKeyDown:i,registerItemRef:a,registerOverlayItemRef:o}){let s=e.kind===`directory`?e.node.name:QKe(e.node.file,e.node.name),c=e.guideMask.length*C$,l=e.visibilityRatio,u=l<=0?0:Math.min(.88,.22+l*.66);return(0,J.jsxs)(`div`,{id:`git-file-tree-item-${encodeURIComponent(e.key)}`,"data-file-id":e.kind===`file`?e.node.file.fileId:void 0,"data-visibility-ratio":l.toFixed(3),ref:t=>{a(e.key)(t),o(e.key)(t)},role:`treeitem`,tabIndex:t?0:-1,"aria-label":e.kind===`directory`?e.node.name:e.node.file.displayPath,"aria-level":e.level,"aria-setsize":e.setSize,"aria-posinset":e.posInSet,"aria-expanded":e.kind===`directory`?e.expanded:void 0,onClick:()=>n(e.key),onFocus:()=>r(e.key),onKeyDown:t=>i(t,e.key),className:fr(`relative grid min-w-0 cursor-default grid-cols-[auto_minmax(0,1fr)_auto] items-stretch gap-1.5 rounded-md py-0.5 text-left outline-none transition-colors`,`focus-visible:ring-ring/60 focus-visible:ring-2`,e.kind===`directory`?`text-foreground hover:bg-muted/35`:`text-foreground/90 hover:bg-muted/35`),title:e.kind===`directory`?e.node.name:e.node.file.displayPath,children:[u>0?(0,J.jsx)(`span`,{"aria-hidden":`true`,className:fr(`pointer-events-none absolute inset-y-0 rounded-md`,e.kind===`directory`?`bg-primary/10 ring-primary/10 ring-1`:`bg-primary/16 ring-primary/15 ring-1`),style:{left:`${Math.max(0,c-1)}px`,right:0,opacity:u}}):null,(0,J.jsx)($Ke,{guideMask:e.guideMask}),e.kind===`directory`?(0,J.jsxs)(`div`,{className:fr(`relative z-10 flex min-w-0 items-start gap-1.5 text-[11px] font-medium transition-colors`,l>0?`text-foreground`:`text-muted-foreground`),children:[e.expanded?(0,J.jsx)(gm,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 transition-opacity`,style:{opacity:Math.min(1,.65+l*.35)}}):(0,J.jsx)(Bce,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 transition-opacity`,style:{opacity:Math.min(1,.65+l*.35)}}),(0,J.jsx)(`span`,{className:`min-w-0 leading-4 [overflow-wrap:anywhere]`,children:s})]}):(0,J.jsxs)(`div`,{className:`relative z-10 flex min-w-0 items-start gap-1.5`,children:[(0,J.jsx)(sm,{className:fr(`mt-0.5 h-3.5 w-3.5 shrink-0 transition-colors`,l>0?`text-primary`:ZKe(e.node.file.changeType)),style:{opacity:Math.min(1,.7+l*.3)}}),(0,J.jsx)(`span`,{className:fr(`min-w-0 text-[11px] leading-4 transition-colors [overflow-wrap:anywhere]`,l>0?`text-foreground font-medium`:``),children:s})]}),(0,J.jsx)(`div`,{className:fr(`relative z-10 flex min-h-4 shrink-0 items-center gap-1 transition-opacity`,l>0?`text-foreground/80`:`text-muted-foreground`),style:{opacity:Math.min(1,.68+l*.32)},children:(0,J.jsx)(r$,{diff:e.node.diff})})]})}function w$({nodes:e,itemsByKey:t,focusedKey:n,onItemClick:r,onItemFocus:i,onItemKeyDown:a,registerItemRef:o,registerOverlayItemRef:s}){return(0,J.jsx)(`div`,{children:e.map(e=>{let c=t.get(e.key);return c?(0,J.jsxs)(`div`,{children:[(0,J.jsx)(eqe,{item:c,focused:n===c.key,onItemClick:r,onItemFocus:i,onItemKeyDown:a,registerItemRef:o,registerOverlayItemRef:s}),e.kind===`directory`&&c.kind===`directory`&&c.expanded&&e.children.length>0?(0,J.jsx)(`div`,{role:`group`,children:(0,J.jsx)(w$,{nodes:e.children,itemsByKey:t,focusedKey:n,onItemClick:r,onItemFocus:i,onItemKeyDown:a,registerItemRef:o,registerOverlayItemRef:s})}):null]},e.key):null})})}function T$({files:e,projectDir:t,visibilityRatioByFileId:n=XKe,onSelectFile:r,revealRequest:i=null,className:a,onUserScrollIntent:o}){let[s,c]=(0,Y.useState)(new Set),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(new Map),f=(0,Y.useRef)(null),p=(0,Y.useMemo)(()=>KKe(e,{projectDir:t}),[e,t]),m=(0,Y.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,Y.useMemo)(()=>YKe(p,s,n),[s,p,n]),{focusedKey:g,handleItemClick:_,handleItemFocus:v,handleItemKeyDown:y,registerItemRef:b}=JKe({items:h.items,itemsByKey:h.itemsByKey,parentByKey:h.parentByKey,treeRef:l,onToggleDirectory:m,onSelectFile:r}),x=(0,Y.useCallback)(e=>t=>{if(!t){d.current.delete(e);return}d.current.set(e,t)},[]);return(0,Y.useEffect)(()=>{if(!i||f.current===i.nonce)return;let e=u.current;if(!e)return;let t=h.keyByFileId.get(i.fileId)??null;for(;t&&!h.itemsByKey.has(t);)t=h.parentByKey.get(t)??null;if(!t)return;let n=d.current.get(t);n&&(MGe({container:e,element:n,behavior:`auto`,margin:12}),f.current=i.nonce)},[i,h.itemsByKey,h.keyByFileId,h.parentByKey]),e.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`No changed files found for this entry.`}):(0,J.jsx)(`div`,{ref:l,className:fr(`flex min-h-0 flex-col overflow-hidden rounded-md border border-zinc-500/15 bg-zinc-500/5`,a),children:(0,J.jsx)(`div`,{ref:u,role:`tree`,"data-tab-scroll-root":`true`,"aria-label":`Changed files`,onKeyDownCapture:e=>{TQ(e.key)&&o?.()},onPointerDownCapture:()=>{o?.()},onTouchMoveCapture:()=>{o?.()},onWheelCapture:()=>{o?.()},className:`scrollbar-thin scrollbar-track-transparent min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-2`,children:(0,J.jsx)(`div`,{className:`relative`,children:(0,J.jsx)(w$,{nodes:p,itemsByKey:h.itemsByKey,focusedKey:g,onItemClick:_,onItemFocus:v,onItemKeyDown:y,registerItemRef:b,registerOverlayItemRef:x})})})})}function tqe(e){switch(e){case`added`:return`border-emerald-500/40 bg-emerald-500/12 text-emerald-700 dark:border-emerald-300/45 dark:bg-emerald-400/20 dark:text-emerald-100`;case`deleted`:return`border-rose-500/40 bg-rose-500/12 text-rose-700 dark:border-rose-300/45 dark:bg-rose-400/20 dark:text-rose-100`;case`renamed`:case`copied`:return`border-sky-500/40 bg-sky-500/12 text-sky-700 dark:border-sky-300/45 dark:bg-sky-400/20 dark:text-sky-100`;case`modified`:return`border-amber-500/40 bg-amber-500/12 text-amber-700 dark:border-amber-300/45 dark:bg-amber-400/20 dark:text-amber-100`;default:return`border-zinc-500/35 bg-zinc-500/10 text-zinc-700 dark:border-zinc-300/40 dark:bg-zinc-300/15 dark:text-zinc-100`}}function nqe(e){if(!e)return`Patch preview is unavailable for this file.`;switch(e.state){case`binary`:return`Binary file. Patch preview is unavailable.`;case`too-large`:return`Patch is too large to preview in the panel.`;case`unavailable`:return`Patch preview is unavailable for this file.`;default:return``}}function rqe(e){return e.previousPath&&(e.changeType===`renamed`||e.changeType===`copied`)?e.path:e.displayPath}function iqe(e,t){let n=`readonly-diff-line`;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`@@`)?n=`readonly-diff-line readonly-diff-line-meta`:e.startsWith(`+`)&&!e.startsWith(`+++`)?n=`readonly-diff-line readonly-diff-line-add`:e.startsWith(`-`)&&!e.startsWith(`---`)?n=`readonly-diff-line readonly-diff-line-del`:(e.startsWith(`+++`)||e.startsWith(`---`))&&(n=`readonly-diff-line readonly-diff-line-file`),(0,J.jsx)(`div`,{className:n,children:e||` `},`${t}:${e.slice(0,16)}`)}function E$({file:e,patch:t,status:n,error:r,onRegisterCard:i,scrollMarginTop:a}){let o=nqe(t),s=(0,Y.useCallback)(t=>{i?.(e.fileId,t)},[e.fileId,i]);return(0,J.jsxs)(`section`,{"data-file-id":e.fileId,ref:s,style:a?{scrollMarginTop:`${a}px`}:void 0,className:`overflow-hidden rounded-md border border-zinc-500/20`,children:[(0,J.jsxs)(`header`,{className:`bg-card flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(sm,{className:`text-muted-foreground h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 text-sm font-medium leading-5 [overflow-wrap:anywhere]`,children:rqe(e)})]}),e.previousPath?(0,J.jsxs)(`div`,{className:`text-muted-foreground pl-6 text-[11px] leading-4 [overflow-wrap:anywhere]`,children:[`from `,e.previousPath]}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(`span`,{className:fr(`inline-flex items-center rounded border px-[0.35rem] py-0 text-[10px] font-medium uppercase tracking-wide`,tqe(e.changeType)),children:e.changeType}),(0,J.jsx)(r$,{diff:t?.diff??e.diff})]})]}),n===`loading`||n===`idle`?(0,J.jsxs)(`div`,{className:`readonly-code-surface space-y-2 px-3 py-3`,"aria-busy":n===`loading`,"data-testid":`git-patch-loading`,children:[(0,J.jsx)(NC,{children:n===`loading`?`Loading patch preview`:`Patch preview queued`}),(0,J.jsx)(IC,{className:`w-11/12`}),(0,J.jsx)(IC,{className:`w-4/5`}),(0,J.jsx)(IC,{className:`w-2/3`})]}):r?(0,J.jsxs)(`div`,{className:`readonly-code-surface text-destructive flex items-start gap-2 px-3 py-3 text-sm`,children:[(0,J.jsx)(dm,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:r.message})]}):t?.patch?(0,J.jsx)(`pre`,{className:`readonly-code-surface scrollbar-thin scrollbar-track-transparent overflow-x-auto py-2 font-mono text-[11px] leading-5`,children:t.patch.split(`
1337
1337
  `).map((e,t)=>iqe(e,t))}):(0,J.jsxs)(`div`,{className:`readonly-code-surface text-muted-foreground flex items-start gap-2 px-3 py-3 text-sm`,children:[(0,J.jsx)(dm,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:o})]})]})}E$.displayName=`GitPatchCard`;var aqe=(0,Y.memo)(E$),oqe=960,D$=12,O$=16,sqe=4e3,cqe=12,lqe=`180px 0px`,uqe=AGe(20);function dqe(){let e=(0,Y.useRef)(null),[t,n]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(([e])=>{n((e?.contentRect.width??0)>=oqe)});return r.observe(t),()=>{r.disconnect()}},[]),{ref:e,wide:t}}function fqe(e){return e?e.type===`commit`?`commit:${e.hash}`:`uncommitted`:`none`}function pqe(e,t){return e.state!==t.state||e.files!==t.files?!1:e.state!==`ready`||t.state!==`ready`?!0:e.insertions===t.insertions&&e.deletions===t.deletions}function mqe(e){return TQ(e.key)}function hqe(e){for(let t of e){let e=EQ(t,{allowNonScrollable:!0});if(e)return e}return null}function gqe(e,t,n){let r=EQ(e,{allowNonScrollable:!0})??EQ(t,{allowNonScrollable:!0});if(!r)return e.scrollIntoView({block:`start`,behavior:`auto`}),null;let i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=Math.max(r.scrollTop+i.top-a.top-n,0);typeof r.scrollTo==`function`?r.scrollTo({top:o,behavior:`auto`}):r.scrollTop=o;let s=r.scrollTop;return{appliedTop:s,requestedTop:o,wasClamped:s+1<o}}function _qe(e,t,n){let r=EQ(e,{allowNonScrollable:!0})??EQ(t,{allowNonScrollable:!0}),i=e.getBoundingClientRect();if(!r)return{aligned:Math.abs(i.top-n)<=O$,containerScrollTop:null};let a=r.getBoundingClientRect().top+n;return{aligned:Math.abs(i.top-a)<=O$,containerScrollTop:r.scrollTop}}function vqe(e){return e.type===`commit`?(0,J.jsx)(bm,{className:`h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300`}):(0,J.jsx)(Am,{className:`h-4 w-4 shrink-0 text-amber-600 dark:text-amber-300`})}function k$({files:e,onSelectFile:t}){return(0,J.jsxs)(`div`,{className:`rounded-md border border-dashed border-zinc-500/25 p-3`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground mb-2 text-xs`,children:`File tree is temporarily unavailable. Use the file list below.`}),(0,J.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(e.fileId),className:`hover:bg-muted/40 block w-full rounded-md px-2 py-1.5 text-left text-sm`,children:e.displayPath},e.fileId))})]})}function yqe({selector:e,entry:t,files:n,eagerFiles:r=[],projectDir:i,repositoryScope:a=`code`,repositoryBindingToken:o=`unbound-preview`,isLoading:s,error:c,showEntrySummary:l=!0,patchLoader:u}){let{ref:d,wide:f}=dqe(),p=fqe(e),{tabsRef:m,selectedTab:h,setSelectedTab:g,onTabChange:_}=Ww({queryKey:`gitPane`,tabs:(0,Y.useMemo)(()=>[{id:`diff`},{id:`files`}],[]),initialTab:`diff`,viewportSelector:[`.main-content`,`.bottom-area`]}),v=(0,Y.useMemo)(()=>new Set(r.map(e=>e.fileId)),[r]),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(D$),[C,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),k=(0,Y.useRef)(new Map),A=(0,Y.useRef)(null),j=(0,Y.useRef)(0),M=(0,Y.useRef)(null),N=(0,Y.useRef)(()=>{}),P=(0,Y.useRef)(null),F=(0,Y.useRef)(0),I=(0,Y.useRef)(null),L=(0,Y.useRef)(!1),[R,z]=(0,Y.useState)(null),B=DQ({target:R,enabled:f}),V=(0,Y.useCallback)(()=>{I.current=`tree`},[]),ee=(0,Y.useCallback)(()=>{I.current=`diff`},[]),te=(0,Y.useCallback)(e=>{let t=A.current;t&&(e!=null&&t.token!==e||(A.current=null))},[]),ne=(0,Y.useCallback)(()=>{te()},[te]),re=(0,Y.useCallback)(()=>{ee(),ne()},[ne,ee]),ie=(0,Y.useCallback)(e=>{mqe(e)&&re()},[re]),ae=(0,Y.useCallback)(e=>{v.has(e)||b(t=>t.includes(e)?t:[...t,e])},[v]),oe=(0,Y.useMemo)(()=>n.map(e=>e.fileId),[n]),se=(0,Y.useCallback)(async t=>e?u?u({selector:e,fileId:t}):q.git.getEntryPatch.query({scope:a,expectedBindingToken:o,selector:e,fileId:t}):null,[u,o,a,e]);(0,Y.useEffect)(()=>{L.current?queueMicrotask(()=>{g(`diff`)}):L.current=!0,b([]),O(null),I.current=null,A.current=null,M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null)},[p,g]),(0,Y.useEffect)(()=>{b(e=>{let t=e.filter(e=>!v.has(e)&&n.some(t=>t.fileId===e));return t.length===e.length&&t.every((t,n)=>t===e[n])?e:t})},[v,n]);let ce=(0,Y.useMemo)(()=>n.map(e=>e.fileId).filter(e=>!v.has(e)&&y.includes(e)),[v,n,y]),le=Ate({queries:ce.map(t=>({queryKey:e?Ore(a,o,e,t):[`git`,a,o,`patch`,`none`,t],queryFn:()=>se(t),enabled:e!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}))}),ue=(0,Y.useMemo)(()=>{let e=new Map;for(let t of r)e.set(t.fileId,{status:`ready`,file:t,error:null});return ce.forEach((t,n)=>{let r=le[n];if(!r)return;let i=r.isPending||r.isFetching&&!r.data?`loading`:r.error?`error`:`ready`;e.set(t,{status:i,file:r.data?.file??null,error:r.error instanceof Error?r.error:null})}),e},[r,le,ce]),de=(0,Y.useMemo)(()=>[r.map(e=>`${e.fileId}:${e.state}:${e.patch?.length??0}`).join(`|`),le.map(e=>`${e.status}:${e.fetchStatus}:${e.dataUpdatedAt}:${e.errorUpdatedAt}`).join(`|`)].join(`|`),[r,le]),fe=(0,Y.useMemo)(()=>[n.map(e=>e.fileId).join(`|`),de].join(`::`),[n,de]),pe=(0,Y.useMemo)(()=>n.map(e=>{let t=ue.get(e.fileId)?.file;return!t||pqe(e.diff,t.diff)?e:{...e,diff:t.diff}}),[n,ue]);(0,Y.useLayoutEffect)(()=>{let e=EQ(T,{allowNonScrollable:!0});w(t=>t===e?t:e)},[h,T,f]);let me=(0,Y.useCallback)(e=>{for(let{id:t}of e)ae(t)},[ae]),{ratioById:he,setObservedNode:ge}=IGe({ids:oe,root:C,threshold:uqe,onBecomeVisible:(0,Y.useCallback)(e=>{if(I.current!==`diff`)return;let t=FGe(e);t&&(F.current+=1,O({fileId:t,nonce:F.current}))},[])}),_e=(0,Y.useMemo)(()=>he.size>0||!D?he:new Map([[D.fileId,1]]),[D,he]),{setObservedNode:ve}=IGe({ids:oe,root:C,rootMargin:lqe,threshold:[0],onBecomeVisible:me}),ye=(0,Y.useCallback)(()=>{let e=f?D$:(()=>{let e=P.current?.querySelector(`.tabs-strip`),t=e?Math.ceil(e.getBoundingClientRect().height):0;return t>0?t+D$:D$})();S(t=>t===e?t:e)},[f]);(0,Y.useEffect)(()=>{if(ye(),f||typeof ResizeObserver>`u`)return;let e=P.current?.querySelector(`.tabs-strip`);if(!e)return;let t=new ResizeObserver(()=>{ye()}),n=()=>{ye()};return t.observe(e),window.addEventListener(`resize`,n),()=>{t.disconnect(),window.removeEventListener(`resize`,n)}},[ye,f]);let be=(0,Y.useCallback)(()=>{if(!f&&h!==`diff`)return;let e=A.current;if(!e)return;if(window.performance.now()>e.deadline){te(e.token);return}let t=ue.get(e.fileId)?.status??`idle`;if(!f&&t!==`ready`){A.current={...e,lastAttemptVersion:fe,phase:`await-layout`};return}let n=k.current.get(e.fileId);if(!n){A.current={...e,lastAttemptVersion:fe,phase:`await-layout`};return}let r=_qe(n,T,x),i=r.containerScrollTop!=null&&e.lastAppliedContainerScrollTop!=null&&Math.abs(r.containerScrollTop-e.lastAppliedContainerScrollTop)>1;if(r.aligned){if(e.phase===`verifying`){A.current={...e,lastAttemptVersion:fe,phase:`settling`},N.current();return}te(e.token);return}if(e.phase===`verifying`||e.phase===`settling`){if(i){A.current={...e,lastAppliedContainerScrollTop:null,lastAttemptVersion:fe,phase:`queued`},N.current();return}A.current={...e,lastAppliedContainerScrollTop:null,lastAttemptVersion:fe,phase:`await-layout`};return}let a=gqe(n,T,x);if(A.current?.token===e.token){if(a?.wasClamped){A.current={...e,lastAppliedContainerScrollTop:a.appliedTop,lastAttemptVersion:fe,phase:`await-layout`};return}A.current={...e,lastAppliedContainerScrollTop:a?.appliedTop??null,lastAttemptVersion:fe,phase:`verifying`},N.current()}},[h,te,fe,x,T,ue,f]),xe=(0,Y.useCallback)(()=>{M.current===null&&(M.current=window.requestAnimationFrame(()=>{M.current=null,be()}))},[be]);N.current=xe;let H=(0,Y.useCallback)(e=>{A.current={deadline:window.performance.now()+sqe,fileId:e,lastAppliedContainerScrollTop:null,lastAttemptVersion:null,phase:`queued`,token:++j.current},!(!f&&h!==`diff`)&&xe()},[h,xe,f]);(0,Y.useEffect)(()=>{let e=A.current;if(!(!f&&h!==`diff`||!e)){if(e.phase===`queued`){xe();return}e.phase===`await-layout`&&e.lastAttemptVersion!==fe&&(A.current={...e,phase:`queued`},xe())}},[h,fe,xe,f]),(0,Y.useEffect)(()=>{let e=A.current;!e||e.phase!==`verifying`||xe()},[fe,xe]),(0,Y.useEffect)(()=>()=>{M.current!==null&&window.cancelAnimationFrame(M.current)},[]);let Se=(0,Y.useCallback)(e=>{ae(e),H(e),f||g(`diff`,{transferScroll:!1})},[H,ae,g,f]),Ce=(0,Y.useCallback)((e,t)=>{if(ge(e,t),ve(e,t),!t){k.current.delete(e);return}k.current.set(e,t),w(e=>e??EQ(t,{allowNonScrollable:!0})),A.current?.fileId===e&&N.current()},[ve,ge]);if((0,Y.useEffect)(()=>{if(!C)return;let e=()=>{I.current!==`tree`&&(I.current=`diff`)};return C.addEventListener(`scroll`,e,{passive:!0}),()=>{C.removeEventListener(`scroll`,e)}},[C]),(0,Y.useEffect)(()=>{if(C||k.current.size===0)return;let e=()=>{let e=hqe(k.current.values());e&&w(e)};e();let t=window.requestAnimationFrame(e);return()=>{window.cancelAnimationFrame(t)}},[C,de]),c)return(0,J.jsxs)(`div`,{className:`text-destructive border-current/20 flex items-center gap-2 rounded-md border px-3 py-3 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`}),c.message]});if(s&&!t)return(0,J.jsx)(`div`,{className:`p-3`,"aria-busy":`true`,children:(0,J.jsx)(HC,{count:5})});if(!t)return(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`Select an entry to inspect changed files.`});let we=s&&n.length===0?(0,J.jsx)(`div`,{className:`p-3`,"aria-busy":`true`,children:(0,J.jsx)(HC,{count:4})}):(0,J.jsx)(`div`,{ref:z,"data-testid":`git-file-tree-viewport`,className:`min-h-0 shrink-0 pb-1`,style:B==null?void 0:{height:`${B}px`},children:(0,J.jsx)(p$,{fallback:(0,J.jsx)(k$,{files:pe,onSelectFile:Se}),children:(0,J.jsx)(T$,{files:pe,projectDir:i,visibilityRatioByFileId:_e,onSelectFile:Se,revealRequest:D,className:`h-full min-h-0`,onUserScrollIntent:V})})}),Te=s&&n.length===0?(0,J.jsx)(`div`,{className:`p-3`,"aria-busy":`true`,children:(0,J.jsx)(HC,{count:4})}):(0,J.jsx)(`div`,{className:`py-3`,style:{marginBlock:`${cqe}px`},children:(0,J.jsx)(p$,{fallback:(0,J.jsx)(k$,{files:pe,onSelectFile:Se}),children:(0,J.jsx)(T$,{files:pe,projectDir:i,visibilityRatioByFileId:_e,onSelectFile:Se,revealRequest:D,onUserScrollIntent:V})})}),Ee={scrollPaddingTop:`${x}px`},De=e=>{let t=ue.get(e.fileId);return(0,J.jsx)(aqe,{file:t?.file??e,patch:t?.file??null,status:t?.status??`idle`,error:t?.error??null,onRegisterCard:Ce,scrollMarginTop:x},e.fileId)},Oe=s&&n.length===0?(0,J.jsx)(`div`,{className:`p-3`,"aria-busy":`true`,children:(0,J.jsx)(HC,{count:6})}):n.length===0?(0,J.jsx)(`div`,{className:`text-muted-foreground rounded-md border border-dashed px-3 py-4 text-sm`,children:`No changed files found for this entry.`}):(0,J.jsx)(`div`,{className:`space-y-3`,children:n.map(e=>De(e))});return(0,J.jsxs)(`div`,{ref:d,className:`@container min-w-0 space-y-3`,children:[l?(0,J.jsx)(`section`,{className:`bg-card rounded-md border border-zinc-500/20 px-3 py-3`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[vqe(t),(0,J.jsx)(`span`,{className:`truncate`,children:t.title})]}),(0,J.jsxs)(`div`,{className:`text-muted-foreground mt-1 text-xs`,children:[t.type===`commit`?t.hash:`working tree`,` ·`,` `,YQ(t.relatedChanges)]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(i$,{files:t.diff.files}),(0,J.jsx)(r$,{diff:t.diff})]})]})}):null,f?(0,J.jsxs)(`div`,{className:`grid min-w-0 gap-3 [grid-template-columns:minmax(18rem,20rem)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{className:`sticky top-0 flex min-h-0 self-start`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,J.jsx)(Om,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:`File Tree`})]}),we]})}),(0,J.jsxs)(`section`,{className:`min-w-0 space-y-2`,onKeyDownCapture:ie,onPointerDownCapture:re,onTouchMoveCapture:re,onWheelCapture:re,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,J.jsx)(pm,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:`Diff Stream`})]}),(0,J.jsx)(`div`,{ref:E,"data-testid":`git-diff-viewport`,style:Ee,children:Oe})]})]}):(0,J.jsx)(`div`,{ref:P,children:(0,J.jsx)(Kw,{ref:m,selectedTab:h,onTabChange:_,tabs:[{id:`diff`,label:`Diff Stream`,icon:(0,J.jsx)(pm,{className:`h-4 w-4`}),content:(0,J.jsx)(`div`,{ref:E,"data-testid":`git-diff-viewport`,className:`pt-3`,style:Ee,onKeyDownCapture:ie,onPointerDownCapture:re,onTouchMoveCapture:re,onWheelCapture:re,children:Oe})},{id:`files`,label:`File Tree`,icon:(0,J.jsx)(Om,{className:`h-4 w-4`}),content:Te}]})})]})}function bqe(e,t){return e.type===`commit`?`${e.hash} · ${YQ(t)}`:`working tree · ${YQ(t)}`}function A$({selector:e}){let t=B(),n=Lo(),{requestedScope:r,scope:i,descriptor:a,locationSearch:o,query:s}=LQ(!t),c=s.authority.state!==`current`,l=(0,Y.useRef)(null),u=(0,Y.useMemo)(()=>$Q(e),[e]),d=gs(`/git`,r,o),f=a?.bindingToken??null,p=up(n.state,e,f),m=Ai({queryKey:_s(i,f??`unavailable`,e),queryFn:()=>{if(!f)throw Error(`Git repository binding is unavailable.`);return q.git.getEntryMeta.query({scope:i,expectedBindingToken:f,selector:e})},enabled:!t&&!c&&f!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}),h=Ai({queryKey:Dre(i,f??`unavailable`,e),queryFn:()=>{if(!f)throw Error(`Git repository binding is unavailable.`);return q.git.getEntryFiles.query({scope:i,expectedBindingToken:f,selector:e})},enabled:!t&&!c&&f!==null,staleTime:300*1e3,gcTime:900*1e3,refetchOnWindowFocus:!1}),g=m.data??null,_=h.data?.files??[],v=h.data?.eagerFiles??[],y=e.type===`commit`?bm:Am;return t?(0,J.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 p-4 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`}),`Git detail is only available in live mode.`]}):s.authority.state===`failed`?(0,J.jsxs)(`div`,{className:`text-destructive flex items-center gap-2 p-4 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`}),`Git repository scope projection failed: `,s.authority.error.message]}):c?(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,"aria-busy":`true`,"data-testid":`git-detail-loading`,children:[(0,J.jsx)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:`Git`}),(0,J.jsx)(VC,{count:4})]}):m.isLoading&&!g?p?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,J.jsx)(Rp,{to:d,vt:{source:l,sharedElements:u},className:`hover:bg-muted rounded-md p-2`,"aria-label":`Back to commits`,children:(0,J.jsx)(Up,{className:`h-5 w-5`})}),(0,J.jsxs)(`div`,{ref:l,...op(u,`container`),className:`min-w-0 space-y-1`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex flex-wrap items-start gap-2 text-2xl font-bold`,children:[(0,J.jsx)(y,{...op(u,`icon`),className:`h-5 w-5 shrink-0 ${e.type===`commit`?`text-sky-600 dark:text-sky-300`:`text-amber-600 dark:text-amber-300`}`}),(0,J.jsx)(`span`,{...op(u,`title`),className:`min-w-0 whitespace-normal [overflow-wrap:anywhere]`,children:p.title??(e.type===`commit`?e.hash:`working tree`)})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground whitespace-normal text-sm [overflow-wrap:anywhere]`,children:p.subtitle??(0,J.jsx)(IC,{className:`w-48`})})]})]}),(0,J.jsx)(`div`,{className:`vt-detail-content rounded-lg border p-4`,"aria-busy":`true`,children:(0,J.jsx)(HC,{count:6})})]}):(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,"aria-busy":`true`,"data-testid":`git-detail-loading`,children:[(0,J.jsx)(`h1`,{className:`font-nav flex items-center gap-2 text-2xl font-bold`,children:`Git`}),(0,J.jsx)(VC,{count:4})]}):m.error&&!g?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`text-destructive flex items-center gap-2 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`}),`Error loading commit detail: `,m.error.message]}),(0,J.jsx)(`div`,{children:(0,J.jsx)(Rp,{to:d,className:`text-primary hover:underline`,children:`Back to Commits`})})]}):g?(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-4`,children:[(0,J.jsx)(Rp,{to:d,vt:{source:l,sharedElements:u},className:`hover:bg-muted rounded-md p-2`,"aria-label":`Back to commits`,children:(0,J.jsx)(Up,{className:`h-5 w-5`})}),(0,J.jsxs)(`div`,{ref:l,...op(u,`container`),className:`min-w-0 space-y-1`,children:[(0,J.jsxs)(`h1`,{className:`font-nav flex flex-wrap items-start gap-2 text-2xl font-bold`,children:[(0,J.jsx)(y,{...op(u,`icon`),className:`h-5 w-5 shrink-0 ${e.type===`commit`?`text-sky-600 dark:text-sky-300`:`text-amber-600 dark:text-amber-300`}`}),(0,J.jsx)(`span`,{...op(u,`title`),className:`min-w-0 whitespace-normal [overflow-wrap:anywhere]`,children:g.title})]}),(0,J.jsx)(`p`,{className:`text-muted-foreground whitespace-normal text-sm [overflow-wrap:anywhere]`,children:bqe(e,g.relatedChanges)}),(0,J.jsxs)(`p`,{className:`text-muted-foreground whitespace-normal text-xs [overflow-wrap:anywhere]`,children:[i===`code`?`Code repository`:`Planning repository`,` ·`,` `,a?.repository?.topLevel??a?.rootPath]})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(i$,{files:h.data?_.length:g.diff.files}),(0,J.jsx)(r$,{diff:g.diff})]})]}),(0,J.jsx)(`div`,{className:`vt-detail-content`,children:(0,J.jsx)(yqe,{selector:e,entry:g,files:_,eagerFiles:v,projectDir:a?.repository?.topLevel??a?.rootPath,repositoryScope:i,repositoryBindingToken:f??`unavailable`,isLoading:h.isLoading||h.isFetching,error:(h.error instanceof Error?h.error:null)??(m.error instanceof Error?m.error:null),showEntrySummary:!1})})]}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-sm`,children:[(0,J.jsx)($p,{className:`h-4 w-4 shrink-0`}),`Commit detail is unavailable in the current project.`]}),(0,J.jsx)(`div`,{children:(0,J.jsx)(Rp,{to:d,className:`text-primary hover:underline`,children:`Back to Commits`})})]})}function xqe(){return(0,J.jsx)(A$,{selector:{type:`uncommitted`}})}function Sqe(){let{hash:e}=ho({from:`/git/commit/$hash`});return(0,J.jsx)(A$,{selector:{type:`commit`,hash:e}})}function Cqe(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}var j$=`border-primary bg-primary text-primary-foreground hover:bg-primary/90 inline-flex h-7 items-center gap-1.5 rounded-md border px-2 text-xs transition disabled:cursor-not-allowed disabled:border-border disabled:bg-muted disabled:text-muted-foreground disabled:opacity-50`,wqe=`border-primary bg-primary text-primary-foreground hover:bg-primary/90 inline-flex h-7 w-7 items-center justify-center rounded-md border transition disabled:cursor-not-allowed disabled:border-border disabled:bg-muted disabled:text-muted-foreground disabled:opacity-50`;function M$({aggregate:e}){let{highlightedId:t,markManyRead:n,resolveAction:r}=BS(),i=e.latest,a=(0,Y.useMemo)(()=>e.notifications.map(e=>e.id),[e.notifications]),o=(0,Y.useMemo)(()=>i.actions.map(e=>r(i,e,{markReadOnRun:!1})),[i,r]),s=t!=null&&e.notifications.some(e=>e.id===t);return(0,J.jsx)(`li`,{className:[`notification-list-item grid transition-[grid-template-rows,opacity] duration-200 ease-out`,`grid-rows-[1fr] opacity-100`].join(` `),"data-notification-id":i.id,children:(0,J.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,J.jsxs)(`div`,{className:[`border-border/70 bg-background/80 rounded-md border p-3 transition-[background-color,border-color,box-shadow] duration-200`,s?`border-primary bg-primary/5 shadow-[inset_3px_0_0_var(--primary)]`:`hover:bg-muted/30`].join(` `),children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`border-border/60 bg-muted/40 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border`,children:(0,J.jsx)(qp,{className:`text-muted-foreground h-3.5 w-3.5`})}),(0,J.jsxs)(`h4`,{className:`truncate text-sm font-medium`,children:[i.title,e.count>1&&(0,J.jsx)(vh,{count:e.count,tone:`subtle`,size:`sm`,shape:`box`,className:`ml-1 align-baseline`,"aria-label":`${e.count} identical notifications`})]})]}),i.body&&(0,J.jsx)(`p`,{className:`text-muted-foreground mt-1 line-clamp-3 break-words text-xs`,children:i.body})]}),(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Cqe(i.createdAt)})]}),(0,J.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.map((e,t)=>(0,J.jsx)(gh,{content:e.disabled?e.reason:void 0,children:(0,J.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:()=>{e.run().then(()=>n(a))},className:j$,children:[(0,J.jsx)(om,{className:`h-3.5 w-3.5`}),e.action.label]})},t)),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void n(a),className:`${j$} ml-auto`,children:[(0,J.jsx)(Xp,{className:`h-3.5 w-3.5`}),`Read`]})]})]})})})}function Tqe({group:e}){let[t,n]=(0,Y.useState)(e.aggregates.length<=3),{clearGroup:r}=BS(),i=e.aggregates[0]??null,a=e.aggregates.slice(1),o=a.length>0;return(0,J.jsx)(`section`,{className:`notification-list-item grid grid-rows-[1fr] transition-[grid-template-rows] duration-200 ease-out`,children:(0,J.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`border-border bg-background overflow-hidden rounded-md border`,children:[(0,J.jsxs)(`header`,{className:`border-border bg-muted/25 flex items-center gap-3 border-b px-3 py-2`,children:[(0,J.jsx)(`button`,{type:`button`,disabled:!o,onClick:()=>n(e=>!e),className:`hover:bg-muted inline-flex h-7 w-7 items-center justify-center rounded-md border border-transparent transition disabled:cursor-default disabled:opacity-40`,"aria-label":t?`Collapse group`:`Expand group`,children:(0,J.jsx)(Zp,{className:`h-4 w-4 transition-transform duration-200 ${t?`rotate-180`:``}`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-medium`,children:e.label}),(0,J.jsxs)(`p`,{className:`text-muted-foreground text-xs`,children:[e.unreadCount,` notification`,e.unreadCount===1?``:`s`]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void r(e.key),className:wqe,"aria-label":`Clear group`,children:(0,J.jsx)(Ym,{className:`h-4 w-4`})})]}),(0,J.jsxs)(`ul`,{className:`space-y-2 p-2`,children:[i&&(0,J.jsx)(M$,{aggregate:i},i.key),o&&(0,J.jsx)(`li`,{className:[`duration-220 grid transition-[grid-template-rows,opacity] ease-out`,t?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`].join(` `),children:(0,J.jsx)(`ul`,{className:`min-h-0 space-y-2 overflow-hidden`,children:a.map(e=>(0,J.jsx)(M$,{aggregate:e},e.key))})})]})]})})})}function Eqe(){let{setConfig:e}=YS(),{groups:t,unreadCount:n,clearAll:r}=BS();return(0,Y.useEffect)(()=>{e({layout:{alignY:`start`,width:`normal`,topGap:`comfortable`},panelClassName:`w-full`,bodyClassName:`p-0`,maxHeight:`min(88dvh,860px)`,title:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`font-nav block truncate tracking-[0.04em]`,children:`Notifications`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground block text-xs tracking-normal`,children:[n,` unread`]})]}),headerActions:(0,J.jsxs)(`button`,{type:`button`,disabled:n===0,onClick:()=>void r(),className:j$,children:[(0,J.jsx)(Ym,{className:`h-3.5 w-3.5`}),`Clear all`]}),onDismissRequest:void 0})},[r,e,n]),(0,J.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:(0,J.jsx)(`div`,{className:`scrollbar-thin scrollbar-track-transparent min-h-0 flex-1 overflow-y-auto p-3 sm:p-4`,children:t.length===0?(0,J.jsxs)(`div`,{className:`text-muted-foreground flex min-h-[14rem] flex-col items-center justify-center gap-2 rounded-md border border-dashed text-sm`,children:[(0,J.jsx)(`div`,{className:`border-border bg-muted/30 flex h-10 w-10 items-center justify-center rounded-md border`,children:(0,J.jsx)(qp,{className:`h-5 w-5`})}),`No notifications`]}):(0,J.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,J.jsx)(Tqe,{group:e},e.key))})})})}function Dqe(){return(0,J.jsx)(Eqe,{})}function N$({evidence:e}){return e?(0,J.jsx)(lw,{title:`CLI evidence`,summary:e.kind,children:(0,J.jsx)(`pre`,{className:`text-muted-foreground max-h-40 overflow-auto whitespace-pre-wrap break-all font-mono`,children:JSON.stringify(e,null,2)})}):null}function Oqe(e){let t={references:e.length,errors:0,warnings:0,infos:0,total:0};for(let n of e)for(let e of n.status)t.total+=1,e.severity===`error`&&(t.errors+=1),e.severity===`warning`&&(t.warnings+=1),e.severity===`info`&&(t.infos+=1);return t}function P$(e){let t=e.references===1?`direct Reference`:`direct References`,n=e.errors===1?`error`:`errors`,r=e.warnings===1?`warning`:`warnings`,i=e.infos===1?`info`:`infos`;return`${e.references} ${t} · ${e.errors} ${n} · ${e.warnings} ${r} · ${e.infos} ${i} · ${e.total} total`}function F$({target:e,stale:t=!1}){if(!e)return null;let n=Oqe(e.references),r=e.references.map(e=>({storeId:e.store_id,errors:e.status.filter(e=>e.severity===`error`).length})).filter(e=>e.errors>0);return(0,J.jsxs)(`div`,{role:`region`,"aria-label":`Workflow target`,className:`border-border min-w-0 border-y py-2 text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(ym,{className:`text-muted-foreground h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Planning`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 break-all font-mono`,children:e.planningRoot.path}),(0,J.jsx)(cw,{ariaLabel:`Planning root source ${e.planningRoot.source}`,tooltip:`Root source: ${e.planningRoot.source}`,children:e.planningRoot.source}),e.storeId?(0,J.jsxs)(cw,{ariaLabel:`Planning Store ${e.storeId}`,tooltip:`The prepared workflow target selected Store ${e.storeId}.`,children:[`Store `,e.storeId]}):null,(0,J.jsxs)(cw,{ariaLabel:P$(n),tooltip:P$(n),tone:n.errors>0?`custom`:`muted`,className:n.errors>0?`border-destructive/40 bg-destructive/10 text-destructive`:void 0,children:[`References `,n.references]}),t?(0,J.jsx)(cw,{ariaLabel:`Planning target is stale; dispatch is locked.`,tooltip:`The prepared planning target is stale. Re-prepare the workflow before dispatch.`,tone:`custom`,className:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`,children:`Stale target`}):null]}),r.length>0?(0,J.jsxs)(`div`,{className:`text-destructive mt-2 flex items-start gap-2`,role:`alert`,children:[(0,J.jsx)($p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{children:[`Reference errors:`,` `,r.map(({storeId:e,errors:t})=>`${e} (${t})`).join(`, `)]})]}):null]})}function I$(e){if(!e)return;let t=ls.getAreaForPath(`/terminal`);if(t===`bottom`){Vp.activateBottom(`/terminal`);return}ls.getLocation(t).pathname!==`/terminal`&&Vp.push(t,`/terminal`,null)}var L$=(0,Y.createContext)(null);function kqe({children:e}){let t=B(),n=(0,Y.useSyncExternalStore)(e=>PS.subscribe(e),()=>PS.getSnapshot(),()=>PS.getSnapshot()),[r,i]=(0,Y.useState)(null),a=(0,Y.useCallback)(e=>{if(t)return``;let n=PS.createSession(e);return i(n),PS.setActiveSessionId(n),n},[t]),o=(0,Y.useCallback)((e,n)=>{if(t)return``;let r=n.label??e.label,a=PS.createSession({cwdTarget:n.cwdTarget,label:r,command:e.command,args:e.args,initialInput:n.initialInput,expectedRootGeneration:n.expectedRootGeneration});return i(a),PS.setActiveSessionId(a),a},[t]),s=(0,Y.useCallback)((e,n,r)=>{if(t)return``;let a=`${e} ${n.join(` `)}`.trim(),o=r.label?.trim()||a,s=PS.createSession({cwdTarget:r.cwdTarget,label:o.length>40?`${o.slice(0,37)}...`:o,command:e,args:n,expectedRootGeneration:r.expectedRootGeneration,isDedicated:!0,closeTip:r.closeTip,closeCallbackUrl:r.closeCallbackUrl,initialInput:r.initialInput});return i(s),PS.setActiveSessionId(s),s},[t]),c=(0,Y.useCallback)(e=>{PS.closeSession(e),i(t=>t===e?null:t)},[]),l=(0,Y.useCallback)(e=>{i(e),PS.setActiveSessionId(e),PS.focusSession(e)},[]);(0,Y.useEffect)(()=>PS.subscribeActivation(e=>{i(e),(typeof requestAnimationFrame==`function`?requestAnimationFrame:e=>window.setTimeout(()=>e(Date.now()),0))(()=>{PS.focusSession(e)})}),[]);let u=(0,Y.useCallback)((e,t)=>{},[]),d=(0,Y.useCallback)((e,t)=>{PS.setCustomTitle(e,t)},[]),f=n.sessions,p=(0,Y.useMemo)(()=>r&&f.some(e=>e.id===r)?r:f[f.length-1]?.id??null,[r,f]);(0,Y.useEffect)(()=>{p&&(PS.setActiveSessionId(p),PS.focusSession(p))},[p]);let m=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{m.current||f.length!==0&&PS.discoveredSessions&&(m.current=!0,i(e=>e??f[0].id))},[f]);let{data:h}=Xf(),g=Ro();return(0,Y.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{PS.setThemeContext({appDarkMode:g,systemDarkMode:e.matches})};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[g]),(0,Y.useEffect)(()=>{if(!h?.terminal)return;let{rendererEngine:e,...t}=h.terminal;e&&wS(e)?PS.setRendererEngine(e).catch(e=>{console.error(`[terminal] failed to apply renderer engine from config:`,e)}):e&&console.error(`[terminal] invalid renderer engine in config:`,e),PS.applyConfig(t)},[h?.terminal]),(0,J.jsx)(L$,{value:(0,Y.useMemo)(()=>({sessions:f,activeSessionId:p,createSession:a,createShellSession:o,createDedicatedSession:s,closeSession:c,setActiveSession:l,markExited:u,setCustomTitle:d}),[f,p,a,o,s,c,l,u,d]),children:e})}function R$(){let e=(0,Y.useContext)(L$);if(!e)throw Error(`useTerminalContext must be used within a TerminalProvider`);return e}var z$=`terminal:`,B$=`create:`,Aqe=new Set([`bash`,`zsh`,`fish`,`sh`,`dash`,`ksh`,`cmd.exe`,`cmd`,`powershell.exe`,`powershell`,`pwsh.exe`,`pwsh`,`nu`,`nushell`]);function V$(e){return e instanceof Error?e.message:String(e)}function H$(e){return e?.startsWith(z$)?e.slice(9):null}function U$(e){return e?.startsWith(B$)?e.slice(7):null}function W$(e){return`${z$}${e}`}function G$(e){return`${B$}${e}`}function jqe(e){if(!e)return null;let t=e.trim().toLowerCase();return t?t.split(/[\\/]/).pop()??t:null}function Mqe(e){let t=jqe(e);return t?Aqe.has(t):!1}function Nqe(e){return e.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,``).replace(/\x1B\][^\u0007]*(\u0007|\x1B\\)/g,``).replace(/\x1B[@-Z\\-_]/g,``)}function Pqe(e){let t=``;for(let n of e){let e=n.charCodeAt(0);(!(e>=0&&e<=31||e===127)||e===9||e===10||e===13)&&(t+=n)}return t}function K$(e){let t=Pqe(Nqe(e.trim().replace(/\r\n?/g,`
1338
1338
  `)));return{text:t,modified:t!==e}}function Fqe(e,t){return t?`\x1b[200~${e}\x1b[201~\n`:`${e}\n`}var q$=[`posix`,`cmd`,`powershell`],Iqe=[`text`,`textarea`,`boolean`,`select`],Lqe=l(q$),Rqe=m({id:S().min(1),label:S().min(1),command:S().min(1),args:p(S()).default([]),source:l([`builtin`,`custom`]).default(`custom`),quoteStyle:Lqe.default(`posix`)}),zqe=m({id:S().min(1),label:S().min(1),type:l(Iqe),description:S().optional(),placeholder:S().optional(),defaultValue:u([S(),f()]).optional(),options:p(S()).default([]),required:f().default(!1),advanced:f().default(!1)});function J$(e){return{...e,options:e.options??[],required:e.required??!1,advanced:e.advanced??!1}}function Y$(e){return{...e,parameters:Q$(e.fields),source:e.source??`builtin`}}var Bqe=P(`kind`,[m({kind:v(`literal`),value:S()}),m({kind:v(`field`),fieldId:S().min(1),prefix:S().default(``),omitWhenEmpty:f().default(!0)}),m({kind:v(`booleanFlag`),fieldId:S().min(1),flag:S().min(1)})]),Vqe=m({type:l([`string`,`boolean`]).default(`string`),title:S().optional(),description:S().optional(),default:u([S(),f()]).optional(),enum:p(S()).optional()}),Hqe=m({schema:m({type:v(`object`),properties:_(Vqe).default({}),required:p(S()).default([])}),uiSchema:_(T()).default({})}),Uqe=P(`kind`,[m({kind:v(`literal`),value:S()}),m({kind:v(`field`),fieldId:S().min(1),prefix:S().default(``),omitWhenEmpty:f().default(!0)}),m({kind:v(`booleanFlag`),fieldId:S().min(1),flag:S().min(1)})]),Wqe=P(`kind`,[m({kind:v(`argv`),parts:p(Uqe).default([])}),m({kind:v(`shellLine`),template:S().default(``)})]),Gqe=m({id:S().min(1),label:S().min(1),description:S().optional(),command:S().min(1),args:p(Bqe).default([]),fields:p(zqe).default([]),parameters:Hqe.optional(),builder:Wqe.optional(),shellProfileId:S().optional(),source:l([`builtin`,`custom`]).default(`custom`)}),X$=m({defaultShellProfileId:S().optional(),customShellProfiles:p(Rqe).default([]),customSpawnCommands:p(Gqe).default([])});function Kqe(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function Z$(e){return e?.trim()||``}function qqe(){return typeof process>`u`?{}:{SHELL:{}.SHELL,ComSpec:{}.ComSpec}}function Jqe(e){let t=e.env??qqe();if(e.platform===`windows`){let n=[{id:`builtin:cmd`,label:`Command Prompt`,command:Z$(t.ComSpec)||`cmd.exe`,args:[],source:`builtin`,quoteStyle:`cmd`},{id:`builtin:powershell`,label:`PowerShell`,command:`powershell.exe`,args:[],source:`builtin`,quoteStyle:`powershell`},{id:`builtin:wsl-bash`,label:`WSL Bash`,command:`wsl.exe`,args:[`bash`],source:`builtin`,quoteStyle:`posix`}];return{platform:e.platform,effectiveDefaultShell:n[0],builtinShellProfiles:n}}let n=Z$(t.SHELL),r={id:`builtin:sh`,label:`/bin/sh`,command:`/bin/sh`,args:[],source:`builtin`,quoteStyle:`posix`},i=Kqe([r,...n&&n!==r.command?[{id:`builtin:env-shell`,label:`SHELL (${n})`,command:n,args:[],source:`builtin`,quoteStyle:`posix`}]:[]]);return{platform:e.platform,effectiveDefaultShell:i.find(e=>e.id===`builtin:env-shell`)??r,builtinShellProfiles:i}}var Yqe=[J$({id:`prompt`,label:`Prompt`,type:`textarea`,description:`Initial prompt to send to Claude.`,defaultValue:``,required:!1}),J$({id:`model`,label:`Model`,type:`text`,description:`Claude model alias or full model name.`,defaultValue:``,required:!1}),J$({id:`permissionMode`,label:`Permission mode`,type:`select`,description:`Permission mode for this session.`,defaultValue:``,options:[``,`default`,`acceptEdits`,`auto`,`dontAsk`,`plan`,`bypassPermissions`],required:!1}),J$({id:`effort`,label:`Effort`,type:`select`,description:`Reasoning effort for the current session.`,defaultValue:``,options:[``,`low`,`medium`,`high`,`xhigh`,`max`],required:!1}),J$({id:`continueLatest`,label:`Continue latest`,type:`boolean`,description:`Continue the most recent conversation in the current directory.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`resumeSession`,label:`Resume session`,type:`text`,description:`Resume a conversation by session ID or picker search term.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`name`,label:`Session name`,type:`text`,description:`Display name for the Claude session.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`addDir`,label:`Additional dirs`,type:`text`,description:`Additional directories to allow tool access to.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`appendSystemPrompt`,label:`Append system prompt`,type:`textarea`,description:`Text appended to the default system prompt.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`allowedTools`,label:`Allowed tools`,type:`text`,description:`Comma or space-separated tool allowlist.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`disallowedTools`,label:`Disallowed tools`,type:`text`,description:`Comma or space-separated tool denylist.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`print`,label:`Print and exit`,type:`boolean`,description:`Run in non-interactive print mode.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`outputFormat`,label:`Output format`,type:`select`,description:`Output format for print mode.`,defaultValue:``,options:[``,`text`,`json`,`stream-json`],required:!1,advanced:!0}),J$({id:`dangerouslySkipPermissions`,label:`Skip permissions`,type:`boolean`,description:`Bypass all permission checks. Use only in externally sandboxed workspaces.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`allowDangerouslySkipPermissions`,label:`Allow skip permissions`,type:`boolean`,description:`Expose the skip-permissions option without enabling it by default.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`bare`,label:`Bare mode`,type:`boolean`,description:`Minimal mode that skips hooks, plugin sync, memory, and auto-discovery.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`verbose`,label:`Verbose`,type:`boolean`,description:`Override verbose mode setting from config.`,defaultValue:!1,required:!1,advanced:!0})],Xqe=[J$({id:`prompt`,label:`Prompt`,type:`textarea`,description:`Initial prompt to send to Codex.`,defaultValue:``,required:!1}),J$({id:`model`,label:`Model`,type:`text`,description:`Model the agent should use.`,defaultValue:``,required:!1}),J$({id:`profile`,label:`Profile`,type:`text`,description:`Configuration profile from config.toml.`,defaultValue:``,required:!1}),J$({id:`sandbox`,label:`Sandbox`,type:`select`,description:`Sandbox policy for model-generated commands.`,defaultValue:``,options:[``,`read-only`,`workspace-write`,`danger-full-access`],required:!1}),J$({id:`approvalPolicy`,label:`Approval policy`,type:`select`,description:`When Codex should ask for human approval.`,defaultValue:``,options:[``,`untrusted`,`on-request`,`never`],required:!1}),J$({id:`search`,label:`Web search`,type:`boolean`,description:`Enable live web search for the session.`,defaultValue:!1,required:!1}),J$({id:`cd`,label:`Working root`,type:`text`,description:`Directory Codex should use as its working root.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`addDir`,label:`Additional dir`,type:`text`,description:`Additional writable directory alongside the primary workspace.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`config`,label:`Config override`,type:`text`,description:`Configuration override in key=value form.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`enableFeature`,label:`Enable feature`,type:`text`,description:`Feature flag to enable.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`disableFeature`,label:`Disable feature`,type:`text`,description:`Feature flag to disable.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`image`,label:`Image file`,type:`text`,description:`Image file to attach to the initial prompt.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`oss`,label:`OSS provider`,type:`boolean`,description:`Use an open-source provider.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`localProvider`,label:`Local provider`,type:`select`,description:`Local provider to use with OSS mode.`,defaultValue:``,options:[``,`lmstudio`,`ollama`],required:!1,advanced:!0}),J$({id:`noAltScreen`,label:`No alt screen`,type:`boolean`,description:`Disable alternate screen mode.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`dangerouslyBypassApprovalsAndSandbox`,label:`Bypass approvals and sandbox`,type:`boolean`,description:`Skip all confirmation prompts and execute without sandboxing.`,defaultValue:!1,required:!1,advanced:!0})],Zqe=[J$({id:`prompt`,label:`Prompt`,type:`textarea`,description:`Initial prompt to send to Gemini.`,defaultValue:``,required:!1}),J$({id:`model`,label:`Model`,type:`text`,description:`Model Gemini CLI should use.`,defaultValue:``,required:!1}),J$({id:`approvalMode`,label:`Approval mode`,type:`select`,description:`Approval mode for tool execution.`,defaultValue:``,options:[``,`default`,`auto_edit`,`yolo`,`plan`],required:!1}),J$({id:`sandbox`,label:`Sandbox`,type:`boolean`,description:`Run Gemini in sandbox mode.`,defaultValue:!1,required:!1}),J$({id:`debug`,label:`Debug`,type:`boolean`,description:`Run in debug mode.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`worktree`,label:`Worktree`,type:`text`,description:`Start Gemini in a named new git worktree.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`yolo`,label:`YOLO mode`,type:`boolean`,description:`Automatically accept all actions.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`policy`,label:`Policy`,type:`text`,description:`Additional policy files or directories.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`adminPolicy`,label:`Admin policy`,type:`text`,description:`Additional admin policy files or directories.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`extensions`,label:`Extensions`,type:`text`,description:`Extensions to use.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`includeDirectories`,label:`Include directories`,type:`text`,description:`Additional directories to include in the workspace.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`allowedMcpServerNames`,label:`Allowed MCP servers`,type:`text`,description:`Allowed MCP server names.`,defaultValue:``,required:!1,advanced:!0}),J$({id:`outputFormat`,label:`Output format`,type:`select`,description:`Gemini CLI output format.`,defaultValue:``,options:[``,`text`,`json`,`stream-json`],required:!1,advanced:!0}),J$({id:`screenReader`,label:`Screen reader`,type:`boolean`,description:`Enable screen reader mode.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`rawOutput`,label:`Raw output`,type:`boolean`,description:`Disable output sanitization.`,defaultValue:!1,required:!1,advanced:!0}),J$({id:`acceptRawOutputRisk`,label:`Accept raw output risk`,type:`boolean`,description:`Suppress the raw-output security warning.`,defaultValue:!1,required:!1,advanced:!0})],Qqe=[Y$({id:`builtin:claude`,label:`Claude`,description:`Create a terminal and invoke Claude with an optional prompt.`,command:`claude`,args:[{kind:`booleanFlag`,fieldId:`dangerouslySkipPermissions`,flag:`--dangerously-skip-permissions`},{kind:`booleanFlag`,fieldId:`allowDangerouslySkipPermissions`,flag:`--allow-dangerously-skip-permissions`},{kind:`field`,fieldId:`prompt`,prefix:``,omitWhenEmpty:!0}],fields:Yqe,builder:{kind:`argv`,parts:[{kind:`literal`,value:`claude`},{kind:`field`,fieldId:`model`,prefix:`--model=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`permissionMode`,prefix:`--permission-mode=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`effort`,prefix:`--effort=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`continueLatest`,flag:`--continue`},{kind:`field`,fieldId:`resumeSession`,prefix:`--resume=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`name`,prefix:`--name=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`addDir`,prefix:`--add-dir=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`appendSystemPrompt`,prefix:`--append-system-prompt=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`allowedTools`,prefix:`--allowed-tools=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`disallowedTools`,prefix:`--disallowed-tools=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`print`,flag:`--print`},{kind:`field`,fieldId:`outputFormat`,prefix:`--output-format=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`dangerouslySkipPermissions`,flag:`--dangerously-skip-permissions`},{kind:`booleanFlag`,fieldId:`allowDangerouslySkipPermissions`,flag:`--allow-dangerously-skip-permissions`},{kind:`booleanFlag`,fieldId:`bare`,flag:`--bare`},{kind:`booleanFlag`,fieldId:`verbose`,flag:`--verbose`},{kind:`field`,fieldId:`prompt`,prefix:``,omitWhenEmpty:!0}]}}),Y$({id:`builtin:codex`,label:`Codex`,description:`Create a terminal and invoke Codex with an optional prompt.`,command:`codex`,args:[{kind:`booleanFlag`,fieldId:`dangerouslyBypassApprovalsAndSandbox`,flag:`--dangerously-bypass-approvals-and-sandbox`},{kind:`field`,fieldId:`prompt`,prefix:``,omitWhenEmpty:!0}],fields:Xqe,builder:{kind:`argv`,parts:[{kind:`literal`,value:`codex`},{kind:`field`,fieldId:`model`,prefix:`--model=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`profile`,prefix:`--profile=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`sandbox`,prefix:`--sandbox=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`approvalPolicy`,prefix:`--ask-for-approval=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`search`,flag:`--search`},{kind:`field`,fieldId:`cd`,prefix:`--cd=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`addDir`,prefix:`--add-dir=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`config`,prefix:`--config=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`enableFeature`,prefix:`--enable=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`disableFeature`,prefix:`--disable=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`image`,prefix:`--image=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`oss`,flag:`--oss`},{kind:`field`,fieldId:`localProvider`,prefix:`--local-provider=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`noAltScreen`,flag:`--no-alt-screen`},{kind:`booleanFlag`,fieldId:`dangerouslyBypassApprovalsAndSandbox`,flag:`--dangerously-bypass-approvals-and-sandbox`},{kind:`field`,fieldId:`prompt`,prefix:``,omitWhenEmpty:!0}]}}),Y$({id:`builtin:gemini`,label:`Gemini`,description:`Create a terminal and invoke Gemini with an optional prompt.`,command:`gemini`,args:[{kind:`booleanFlag`,fieldId:`yolo`,flag:`--yolo`},{kind:`field`,fieldId:`prompt`,prefix:``,omitWhenEmpty:!0}],fields:Zqe,builder:{kind:`argv`,parts:[{kind:`literal`,value:`gemini`},{kind:`booleanFlag`,fieldId:`debug`,flag:`--debug`},{kind:`field`,fieldId:`model`,prefix:`--model=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`approvalMode`,prefix:`--approval-mode=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`sandbox`,flag:`--sandbox`},{kind:`field`,fieldId:`worktree`,prefix:`--worktree=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`yolo`,flag:`--yolo`},{kind:`field`,fieldId:`policy`,prefix:`--policy=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`adminPolicy`,prefix:`--admin-policy=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`extensions`,prefix:`--extensions=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`includeDirectories`,prefix:`--include-directories=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`allowedMcpServerNames`,prefix:`--allowed-mcp-server-names=`,omitWhenEmpty:!0},{kind:`field`,fieldId:`outputFormat`,prefix:`--output-format=`,omitWhenEmpty:!0},{kind:`booleanFlag`,fieldId:`screenReader`,flag:`--screen-reader`},{kind:`booleanFlag`,fieldId:`rawOutput`,flag:`--raw-output`},{kind:`booleanFlag`,fieldId:`acceptRawOutputRisk`,flag:`--accept-raw-output-risk`},{kind:`field`,fieldId:`prompt`,prefix:``,omitWhenEmpty:!0}]}})];function $qe(e){let t={title:e.label},n=e.description??e.placeholder;return n&&(t.description=n),e.type===`boolean`?{...t,type:`boolean`,default:typeof e.defaultValue==`boolean`?e.defaultValue:!1}:e.type===`select`?{...t,type:`string`,enum:e.options,default:typeof e.defaultValue==`string`?e.defaultValue:e.options[0]}:{...t,type:`string`,default:typeof e.defaultValue==`string`?e.defaultValue:``}}function Q$(e){let t={},n={},r=[];for(let i of e)if(t[i.id]=$qe(i),i.required&&r.push(i.id),i.type===`textarea`&&(n[i.id]={"ui:widget":`textarea`}),i.advanced){let e=n[i.id]??{};n[i.id]={...e,"ui:advanced":!0}}return{schema:{type:`object`,properties:t,required:r},uiSchema:n}}function $$(e){return e.parameters??Q$(e.fields)}function e1(e,t={}){let n={},r=$$(e);for(let[e,i]of Object.entries(r.schema.properties)){let r=t[e];if(typeof r==`string`||typeof r==`boolean`){n[e]=r;continue}let a=eJe(i);if(a!==void 0){n[e]=a;continue}n[e]=tJe(i)===`boolean`?!1:``}return n}function t1(e){return typeof e==`boolean`?e?`true`:`false`:e??``}function n1(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function eJe(e){if(!n1(e))return;let t=e.default;if(typeof t==`string`||typeof t==`boolean`)return t}function tJe(e){if(n1(e))return typeof e.type==`string`?e.type:void 0}function nJe(e,t){let n=[];for(let r of e.args){if(r.kind===`literal`){n.push(r.value);continue}if(r.kind===`booleanFlag`){t[r.fieldId]===!0&&n.push(r.flag);continue}let e=t1(t[r.fieldId]).trim();!e&&r.omitWhenEmpty||n.push(`${r.prefix}${e}`)}return n}function rJe(e,t){let n=[];for(let r of e){if(r.kind===`literal`){r.value.trim().length>0&&n.push(r.value);continue}if(r.kind===`booleanFlag`){t[r.fieldId]===!0&&n.push(r.flag);continue}let e=t1(t[r.fieldId]).trim();!e&&r.omitWhenEmpty||n.push(`${r.prefix}${e}`)}return n}function iJe(e,t){return e.replace(/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g,(e,n)=>t1(t[n]))}function r1(e){let t=e.command.builder;return t?t.kind===`shellLine`?{kind:`shellLine`,commandLine:iJe(t.template,e.values).trim()}:{kind:`argv`,argv:rJe(t.parts,e.values)}:{kind:`argv`,argv:[e.command.command,...nJe(e.command,e.values)]}}function aJe(e){return e.length===0?`''`:/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function oJe(e){return e.length===0?`""`:/[\s"&|<>^()%!]/.test(e)?`"${e.replace(/(["^&|<>])/g,`^$1`)}"`:e}function sJe(e){return e.length===0?`''`:/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replace(/'/g,`''`)}'`}function cJe(e,t){return t===`cmd`?oJe(e):t===`powershell`?sJe(e):aJe(e)}function i1(e){let t=r1(e);return t.kind===`shellLine`?t.commandLine:t.argv.map(t=>cJe(t,e.quoteStyle)).join(` `)}var lJe=`terminal-invocation-settings`;function a1(){return X$.parse({})}function o1(){return z(lJe,window.location)}function uJe(){if(typeof window>`u`)return a1();try{let e=localStorage.getItem(o1());return e?X$.parse(JSON.parse(e)):a1()}catch{return a1()}}function dJe(e){typeof window>`u`||localStorage.setItem(o1(),JSON.stringify(e))}function s1(e){let t=new Map,n=[];for(let r of e){let e=t.get(r.id);if(e!==void 0){n[e]=r;continue}t.set(r.id,n.length),n.push(r)}return n}function c1(){return Jqe({platform:typeof navigator>`u`?`common`:navigator.platform.toLowerCase().includes(`win`)?`windows`:`common`})}var l1=new class{listeners=new Set;settings=a1();shellDefaults=null;loadingDefaults=null;snapshot=null;constructor(){typeof window<`u`&&(this.settings=uJe())}subscribe(e){return this.listeners.add(e),this.ensureShellDefaults(),()=>{this.listeners.delete(e)}}getSnapshot(){if(this.snapshot)return this.snapshot;let e=this.shellDefaults??c1(),t=s1([...e.builtinShellProfiles,...this.settings.customShellProfiles]),n=t.find(e=>e.id===this.settings.defaultShellProfileId)??e.effectiveDefaultShell,r={settings:this.settings,shellDefaults:e,shellProfiles:t,spawnCommands:s1([...Qqe,...this.settings.customSpawnCommands]),defaultShellProfile:n};return this.snapshot=r,r}updateSettings(e){let t=X$.parse(e(this.settings));this.settings=t,this.snapshot=null,dJe(t),this.notify()}setDefaultShellProfileId(e){this.updateSettings(t=>({...t,defaultShellProfileId:e}))}upsertCustomShellProfile(e){let t={...e,source:`custom`};this.updateSettings(e=>({...e,customShellProfiles:[...e.customShellProfiles.filter(e=>e.id!==t.id),t]}))}removeCustomShellProfile(e){this.updateSettings(t=>({...t,defaultShellProfileId:t.defaultShellProfileId===e?void 0:t.defaultShellProfileId,customShellProfiles:t.customShellProfiles.filter(t=>t.id!==e),customSpawnCommands:t.customSpawnCommands.map(t=>t.shellProfileId===e?{...t,shellProfileId:void 0}:t)}))}upsertCustomSpawnCommand(e){let t={...e,source:`custom`};this.updateSettings(e=>({...e,customSpawnCommands:[...e.customSpawnCommands.filter(e=>e.id!==t.id),t]}))}removeCustomSpawnCommand(e){this.updateSettings(t=>({...t,customSpawnCommands:t.customSpawnCommands.filter(t=>t.id!==e)}))}async ensureShellDefaults(){return this.shellDefaults||this.loadingDefaults?this.loadingDefaults??Promise.resolve():(this.loadingDefaults=q.config.getTerminalShellDefaults.query().then(e=>{this.shellDefaults=e,this.snapshot=null,this.notify()}).catch(()=>{this.shellDefaults=c1(),this.snapshot=null,this.notify()}).finally(()=>{this.loadingDefaults=null}),this.loadingDefaults)}notify(){for(let e of this.listeners)e()}};function u1(){return(0,Y.useSyncExternalStore)(e=>l1.subscribe(e),()=>l1.getSnapshot(),()=>l1.getSnapshot())}function fJe(e){return!e||e.state===`loading`?null:e.state===`error`?e.attempt.launchProject.path:e.data.launchProject.path}function pJe(e){return e.transportError?`Root Context transport failed: ${e.transportError.message}`:e.isLoading||!e.projection||e.projection.state===`loading`?`Planning root is still being resolved.`:e.projection.state===`refreshing`?`Planning root is refreshing; wait for a current CLI observation.`:e.projection.state===`error`?`Planning root is unavailable: ${e.projection.error.message}`:`OpenSpec did not resolve a planning root.`}function mJe(e){let t=!e.isLoading&&!e.transportError&&e.projection?.state===`ready`&&e.projection.data.planningRoot?e.projection.data.planningRoot:null;return{topology:AQ(e.projection?.state===`ready`||e.projection?.state===`refreshing`?e.projection.data:null),launchProject:{target:`launch-project`,label:`Launch project`,path:fJe(e.projection),available:!0,unavailableReason:null},planningRoot:{target:`planning-root`,label:`Planning root`,path:t?.path??null,available:t!==null,unavailableReason:t?null:pJe(e)}}}function d1(){let e=eC();return mJe({projection:e.data,isLoading:e.isLoading,transportError:e.error})}function f1(e,t){return t===`planning-root`?e.planningRoot:e.launchProject}function p1(e){return typeof e!=`object`||!e||typeof e.lastModified==`number`&&typeof File<`u`&&e instanceof File||typeof e.getMonth==`function`&&typeof Date<`u`&&e instanceof Date?!1:!Array.isArray(e)}function hJe(e){return e.additionalItems===!0&&console.warn(`additionalItems=true is currently not supported`),p1(e.additionalItems)}function m1(e){if(e===``)return;if(e===null)return null;if(/\.$/.test(e)||/\.0$/.test(e)||/\.\d*0$/.test(e))return e;let t=Number(e);return typeof t==`number`&&!Number.isNaN(t)?t:e}var h1=`__additional_property`,gJe=`additionalProperties`,g1=`allOf`,_1=`anyOf`,v1=`const`,y1=`default`,b1=`__errors`,x1=`items`,_Je=`_$junk_option_schema_id$_`,S1=`$name`,C1=`oneOf`,w1=`properties`,T1=`readonly`,vJe=`required`,E1=`submitButtonOptions`,D1=`$ref`,O1=`__rjsf_ref`,k1=`root`,yJe=[`discriminator`,`propertyName`],bJe=`formContext`,xJe=`layoutGridLookupMap`,A1=`__rjsf_additionalProperties`,j1=`__rjsf_rootSchema`,M1=`ui:options`,N1=`ui:globalOptions`;function P1(e={},t={}){return e?Object.keys(e).filter(e=>e.indexOf(`ui:`)===0).reduce((t,n)=>{let r=e[n];return n===`ui:widget`&&p1(r)?(console.error(`Setting options via ui:widget object is no longer supported, use ui:options instead`),t):n===`ui:options`&&p1(r)?{...t,...r}:{...t,[n.substring(3)]:r}},{...t}):{...t}}function SJe(e,t={},n){if(!(e.additionalProperties||e.patternProperties))return!1;let{expandable:r=!0}=P1(t);return r===!1?r:e.maxProperties!==void 0&&n?Object.keys(n).length<e.maxProperties:!0}var F1=typeof global==`object`&&global&&global.Object===Object&&global,CJe=typeof self==`object`&&self&&self.Object===Object&&self,I1=F1||CJe||Function(`return this`)(),L1=I1.Symbol,R1=Object.prototype,wJe=R1.hasOwnProperty,TJe=R1.toString,z1=L1?L1.toStringTag:void 0;function EJe(e){var t=wJe.call(e,z1),n=e[z1];try{e[z1]=void 0;var r=!0}catch{}var i=TJe.call(e);return r&&(t?e[z1]=n:delete e[z1]),i}var DJe=Object.prototype.toString;function OJe(e){return DJe.call(e)}var kJe=`[object Null]`,AJe=`[object Undefined]`,B1=L1?L1.toStringTag:void 0;function V1(e){return e==null?e===void 0?AJe:kJe:B1&&B1 in Object(e)?EJe(e):OJe(e)}function H1(e,t){return function(n){return e(t(n))}}var U1=H1(Object.getPrototypeOf,Object);function W1(e){return typeof e==`object`&&!!e}var jJe=`[object Object]`,MJe=Function.prototype,NJe=Object.prototype,G1=MJe.toString,PJe=NJe.hasOwnProperty,FJe=G1.call(Object);function K1(e){if(!W1(e)||V1(e)!=jJe)return!1;var t=U1(e);if(t===null)return!0;var n=PJe.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&G1.call(n)==FJe}function q1(e){let t={[b1]:[],addError(e){this[b1].push(e)}};if(Array.isArray(e))return e.reduce((e,t,n)=>({...e,[n]:q1(t)}),t);if(K1(e)){let n=e;return Object.keys(n).reduce((e,t)=>({...e,[t]:q1(n[t])}),t)}return t}var{getOwnPropertyNames:IJe,getOwnPropertySymbols:LJe}=Object,{hasOwnProperty:RJe}=Object.prototype;function J1(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Y1(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function X1(e){return IJe(e).concat(LJe(e))}var zJe=Object.hasOwn||((e,t)=>RJe.call(e,t)),BJe=`__v`,VJe=`__o`,HJe=`_owner`,{getOwnPropertyDescriptor:Z1,keys:Q1}=Object,$1=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t};function UJe(e,t){return e===t}function WJe(e,t){return e.byteLength===t.byteLength&&r0(new Uint8Array(e),new Uint8Array(t))}function GJe(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function KJe(e,t){return e.byteLength===t.byteLength&&r0(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function qJe(e,t){return $1(e.getTime(),t.getTime())}function JJe(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function e0(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}function YJe(e,t,n){let r=Q1(e),i=r.length;if(Q1(t).length!==i)return!1;for(;i-- >0;)if(!i0(e,t,n,r[i]))return!1;return!0}function t0(e,t,n){let r=X1(e),i=r.length;if(X1(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!i0(e,t,n,a)||(o=Z1(e,a),s=Z1(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function XJe(e,t){return $1(e.valueOf(),t.valueOf())}function ZJe(e,t){return e.source===t.source&&e.flags===t.flags}function n0(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function r0(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function QJe(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function i0(e,t,n,r){return(r===HJe||r===VJe||r===BJe)&&(e.$$typeof||t.$$typeof)?!0:zJe(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var $Je=Object.prototype.toString;function eYe(e){let t=iYe(e),{areArraysEqual:n,areDatesEqual:r,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:s,areRegExpsEqual:c,areSetsEqual:l,getUnsupportedCustomComparator:u}=e;return function(e,d,f){if(e===d)return!0;if(e==null||d==null)return!1;let p=typeof e;if(p!==typeof d)return!1;if(p!==`object`)return p===`number`||p===`bigint`?o(e,d,f):p===`function`?i(e,d,f):!1;let m=e.constructor;if(m!==d.constructor)return!1;if(m===Object)return s(e,d,f);if(m===Array)return n(e,d,f);if(m===Date)return r(e,d,f);if(m===RegExp)return c(e,d,f);if(m===Map)return a(e,d,f);if(m===Set)return l(e,d,f);if(m===Promise)return!1;if(Array.isArray(e))return n(e,d,f);let h=$Je.call(e),g=t[h];if(g)return g(e,d,f);let _=u&&u(e,d,f,h);return _?_(e,d,f):!1}}function tYe({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:WJe,areArraysEqual:n?t0:GJe,areDataViewsEqual:KJe,areDatesEqual:qJe,areErrorsEqual:JJe,areFunctionsEqual:UJe,areMapsEqual:n?J1(e0,t0):e0,areNumbersEqual:$1,areObjectsEqual:n?t0:YJe,arePrimitiveWrappersEqual:XJe,areRegExpsEqual:ZJe,areSetsEqual:n?J1(n0,t0):n0,areTypedArraysEqual:n?J1(r0,t0):r0,areUrlsEqual:QJe,getUnsupportedCustomComparator:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Y1(r.areArraysEqual),t=Y1(r.areMapsEqual),n=Y1(r.areObjectsEqual),i=Y1(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function nYe(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function rYe({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}function iYe({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p}){return{"[object Arguments]":c,"[object Array]":t,"[object ArrayBuffer]":e,"[object AsyncGeneratorFunction]":a,"[object BigInt]":s,"[object BigInt64Array]":f,"[object BigUint64Array]":f,"[object Boolean]":l,"[object DataView]":n,"[object Date]":r,"[object Error]":i,"[object Float16Array]":f,"[object Float32Array]":f,"[object Float64Array]":f,"[object Function]":a,"[object GeneratorFunction]":a,"[object Int8Array]":f,"[object Int16Array]":f,"[object Int32Array]":f,"[object Map]":o,"[object Number]":l,"[object Object]":(e,t,n)=>typeof e.then!=`function`&&typeof t.then!=`function`&&c(e,t,n),"[object RegExp]":u,"[object Set]":d,"[object String]":l,"[object URL]":p,"[object Uint8Array]":f,"[object Uint8ClampedArray]":f,"[object Uint16Array]":f,"[object Uint32Array]":f}}a0(),a0({strict:!0}),a0({circular:!0}),a0({circular:!0,strict:!0}),a0({createInternalComparator:()=>$1}),a0({strict:!0,createInternalComparator:()=>$1}),a0({circular:!0,createInternalComparator:()=>$1}),a0({circular:!0,createInternalComparator:()=>$1,strict:!0});function a0(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=eYe(tYe(e));return rYe({circular:t,comparator:a,createState:r,equals:n?n(a):nYe(a),strict:i})}var o0=a0({circular:!0,createCustomConfig:()=>({areFunctionsEqual(e,t){return typeof t==`function`}})}),s0=Array.isArray,aYe=`[object Symbol]`;function c0(e){return typeof e==`symbol`||W1(e)&&V1(e)==aYe}var oYe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,sYe=/^\w*$/;function l0(e,t){if(s0(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||c0(e)?!0:sYe.test(e)||!oYe.test(e)||t!=null&&e in Object(t)}function u0(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var cYe=`[object AsyncFunction]`,lYe=`[object Function]`,uYe=`[object GeneratorFunction]`,dYe=`[object Proxy]`;function d0(e){if(!u0(e))return!1;var t=V1(e);return t==lYe||t==uYe||t==cYe||t==dYe}var f0=I1[`__core-js_shared__`],p0=function(){var e=/[^.]+$/.exec(f0&&f0.keys&&f0.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function fYe(e){return!!p0&&p0 in e}var pYe=Function.prototype.toString;function m0(e){if(e!=null){try{return pYe.call(e)}catch{}try{return e+``}catch{}}return``}var mYe=/[\\^$.*+?()[\]{}|]/g,hYe=/^\[object .+?Constructor\]$/,gYe=Function.prototype,_Ye=Object.prototype,vYe=gYe.toString,yYe=_Ye.hasOwnProperty,bYe=RegExp(`^`+vYe.call(yYe).replace(mYe,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function xYe(e){return!u0(e)||fYe(e)?!1:(d0(e)?bYe:hYe).test(m0(e))}function SYe(e,t){return e?.[t]}function h0(e,t){var n=SYe(e,t);return xYe(n)?n:void 0}var g0=h0(Object,`create`);function CYe(){this.__data__=g0?g0(null):{},this.size=0}function wYe(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var TYe=`__lodash_hash_undefined__`,EYe=Object.prototype.hasOwnProperty;function DYe(e){var t=this.__data__;if(g0){var n=t[e];return n===TYe?void 0:n}return EYe.call(t,e)?t[e]:void 0}var OYe=Object.prototype.hasOwnProperty;function kYe(e){var t=this.__data__;return g0?t[e]!==void 0:OYe.call(t,e)}var AYe=`__lodash_hash_undefined__`;function jYe(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=g0&&t===void 0?AYe:t,this}function _0(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}_0.prototype.clear=CYe,_0.prototype.delete=wYe,_0.prototype.get=DYe,_0.prototype.has=kYe,_0.prototype.set=jYe;function MYe(){this.__data__=[],this.size=0}function v0(e,t){return e===t||e!==e&&t!==t}function y0(e,t){for(var n=e.length;n--;)if(v0(e[n][0],t))return n;return-1}var NYe=Array.prototype.splice;function PYe(e){var t=this.__data__,n=y0(t,e);return n<0?!1:(n==t.length-1?t.pop():NYe.call(t,n,1),--this.size,!0)}function FYe(e){var t=this.__data__,n=y0(t,e);return n<0?void 0:t[n][1]}function IYe(e){return y0(this.__data__,e)>-1}function LYe(e,t){var n=this.__data__,r=y0(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function b0(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}b0.prototype.clear=MYe,b0.prototype.delete=PYe,b0.prototype.get=FYe,b0.prototype.has=IYe,b0.prototype.set=LYe;var x0=h0(I1,`Map`);function RYe(){this.size=0,this.__data__={hash:new _0,map:new(x0||b0),string:new _0}}function zYe(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function S0(e,t){var n=e.__data__;return zYe(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function BYe(e){var t=S0(this,e).delete(e);return this.size-=t?1:0,t}function VYe(e){return S0(this,e).get(e)}function HYe(e){return S0(this,e).has(e)}function UYe(e,t){var n=S0(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function C0(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}C0.prototype.clear=RYe,C0.prototype.delete=BYe,C0.prototype.get=VYe,C0.prototype.has=HYe,C0.prototype.set=UYe;var WYe=`Expected a function`;function w0(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(WYe);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(w0.Cache||C0),n}w0.Cache=C0;var GYe=500;function KYe(e){var t=w0(e,function(e){return n.size===GYe&&n.clear(),e}),n=t.cache;return t}var qYe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,JYe=/\\(\\)?/g,T0=KYe(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(qYe,function(e,n,r,i){t.push(r?i.replace(JYe,`$1`):n||e)}),t});function E0(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var YYe=1/0,D0=L1?L1.prototype:void 0,O0=D0?D0.toString:void 0;function k0(e){if(typeof e==`string`)return e;if(s0(e))return E0(e,k0)+``;if(c0(e))return O0?O0.call(e):``;var t=e+``;return t==`0`&&1/e==-YYe?`-0`:t}function A0(e){return e==null?``:k0(e)}function j0(e,t){return s0(e)?e:l0(e,t)?[e]:T0(A0(e))}var XYe=1/0;function M0(e){if(typeof e==`string`||c0(e))return e;var t=e+``;return t==`0`&&1/e==-XYe?`-0`:t}function N0(e,t){t=j0(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[M0(t[n++])];return n&&n==r?e:void 0}function $(e,t,n){var r=e==null?void 0:N0(e,t);return r===void 0?n:r}var ZYe=Object.prototype.hasOwnProperty;function QYe(e,t){return e!=null&&ZYe.call(e,t)}var $Ye=`[object Arguments]`;function P0(e){return W1(e)&&V1(e)==$Ye}var F0=Object.prototype,eXe=F0.hasOwnProperty,tXe=F0.propertyIsEnumerable,I0=P0(function(){return arguments}())?P0:function(e){return W1(e)&&eXe.call(e,`callee`)&&!tXe.call(e,`callee`)},nXe=9007199254740991,rXe=/^(?:0|[1-9]\d*)$/;function L0(e,t){var n=typeof e;return t??=nXe,!!t&&(n==`number`||n!=`symbol`&&rXe.test(e))&&e>-1&&e%1==0&&e<t}var iXe=9007199254740991;function R0(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=iXe}function z0(e,t,n){t=j0(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=M0(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&R0(i)&&L0(o,i)&&(s0(e)||I0(e)))}function B0(e,t){return e!=null&&z0(e,t,QYe)}var V0=function(){try{var e=h0(Object,`defineProperty`);return e({},``,{}),e}catch{}}();function H0(e,t,n){t==`__proto__`&&V0?V0(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var aXe=Object.prototype.hasOwnProperty;function U0(e,t,n){var r=e[t];(!(aXe.call(e,t)&&v0(r,n))||n===void 0&&!(t in e))&&H0(e,t,n)}function W0(e,t,n,r){if(!u0(e))return e;t=j0(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=M0(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=u0(u)?u:L0(t[i+1])?[]:{})}U0(s,c,l),s=s[c]}return e}function G0(e,t,n){return e==null?e:W0(e,t,n)}function K0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function q0(e){return e}function J0(e){return typeof e==`function`?e:q0}var oXe=/\s/;function sXe(e){for(var t=e.length;t--&&oXe.test(e.charAt(t)););return t}var cXe=/^\s+/;function lXe(e){return e&&e.slice(0,sXe(e)+1).replace(cXe,``)}var Y0=NaN,uXe=/^[-+]0x[0-9a-f]+$/i,dXe=/^0b[01]+$/i,fXe=/^0o[0-7]+$/i,pXe=parseInt;function mXe(e){if(typeof e==`number`)return e;if(c0(e))return Y0;if(u0(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=u0(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=lXe(e);var n=dXe.test(e);return n||fXe.test(e)?pXe(e.slice(2),n?2:8):uXe.test(e)?Y0:+e}var X0=1/0,hXe=17976931348623157e292;function gXe(e){return e?(e=mXe(e),e===X0||e===-X0?(e<0?-1:1)*hXe:e===e?e:0):e===0?e:0}function Z0(e){var t=gXe(e),n=t%1;return t===t?n?t-n:t:0}var _Xe=9007199254740991,Q0=4294967295,vXe=Math.min;function $0(e,t){if(e=Z0(e),e<1||e>_Xe)return[];var n=Q0,r=vXe(e,Q0);t=J0(t),e-=Q0;for(var i=K0(r,t);++n<e;)t(n);return i}function e2(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var t2=Object.create,n2=function(){function e(){}return function(t){if(!u0(t))return{};if(t2)return t2(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function yXe(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var r2=yXe();function bXe(){return!1}var i2=typeof exports==`object`&&exports&&!exports.nodeType&&exports,a2=i2&&typeof module==`object`&&module&&!module.nodeType&&module,o2=a2&&a2.exports===i2?I1.Buffer:void 0,s2=(o2?o2.isBuffer:void 0)||bXe,xXe=`[object Arguments]`,SXe=`[object Array]`,CXe=`[object Boolean]`,wXe=`[object Date]`,TXe=`[object Error]`,EXe=`[object Function]`,DXe=`[object Map]`,OXe=`[object Number]`,kXe=`[object Object]`,AXe=`[object RegExp]`,jXe=`[object Set]`,MXe=`[object String]`,NXe=`[object WeakMap]`,PXe=`[object ArrayBuffer]`,FXe=`[object DataView]`,IXe=`[object Float32Array]`,LXe=`[object Float64Array]`,RXe=`[object Int8Array]`,zXe=`[object Int16Array]`,BXe=`[object Int32Array]`,VXe=`[object Uint8Array]`,HXe=`[object Uint8ClampedArray]`,UXe=`[object Uint16Array]`,WXe=`[object Uint32Array]`,c2={};c2[IXe]=c2[LXe]=c2[RXe]=c2[zXe]=c2[BXe]=c2[VXe]=c2[HXe]=c2[UXe]=c2[WXe]=!0,c2[xXe]=c2[SXe]=c2[PXe]=c2[CXe]=c2[FXe]=c2[wXe]=c2[TXe]=c2[EXe]=c2[DXe]=c2[OXe]=c2[kXe]=c2[AXe]=c2[jXe]=c2[MXe]=c2[NXe]=!1;function GXe(e){return W1(e)&&R0(e.length)&&!!c2[V1(e)]}function l2(e){return function(t){return e(t)}}var u2=typeof exports==`object`&&exports&&!exports.nodeType&&exports,d2=u2&&typeof module==`object`&&module&&!module.nodeType&&module,f2=d2&&d2.exports===u2&&F1.process,p2=function(){try{return d2&&d2.require&&d2.require(`util`).types||f2&&f2.binding&&f2.binding(`util`)}catch{}}(),m2=p2&&p2.isTypedArray,h2=m2?l2(m2):GXe,KXe=Object.prototype.hasOwnProperty;function g2(e,t){var n=s0(e),r=!n&&I0(e),i=!n&&!r&&s2(e),a=!n&&!r&&!i&&h2(e),o=n||r||i||a,s=o?K0(e.length,String):[],c=s.length;for(var l in e)(t||KXe.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||L0(l,c)))&&s.push(l);return s}var qXe=Object.prototype;function _2(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||qXe)}var JXe=H1(Object.keys,Object),YXe=Object.prototype.hasOwnProperty;function v2(e){if(!_2(e))return JXe(e);var t=[];for(var n in Object(e))YXe.call(e,n)&&n!=`constructor`&&t.push(n);return t}function y2(e){return e!=null&&R0(e.length)&&!d0(e)}function b2(e){return y2(e)?g2(e):v2(e)}function x2(e,t){return e&&r2(e,t,b2)}function XXe(){this.__data__=new b0,this.size=0}function ZXe(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function QXe(e){return this.__data__.get(e)}function $Xe(e){return this.__data__.has(e)}var eZe=200;function tZe(e,t){var n=this.__data__;if(n instanceof b0){var r=n.__data__;if(!x0||r.length<eZe-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new C0(r)}return n.set(e,t),this.size=n.size,this}function S2(e){this.size=(this.__data__=new b0(e)).size}S2.prototype.clear=XXe,S2.prototype.delete=ZXe,S2.prototype.get=QXe,S2.prototype.has=$Xe,S2.prototype.set=tZe;var nZe=`__lodash_hash_undefined__`;function rZe(e){return this.__data__.set(e,nZe),this}function iZe(e){return this.__data__.has(e)}function C2(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new C0;++t<n;)this.add(e[t])}C2.prototype.add=C2.prototype.push=rZe,C2.prototype.has=iZe;function aZe(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function w2(e,t){return e.has(t)}var oZe=1,sZe=2;function T2(e,t,n,r,i,a){var o=n&oZe,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&sZe?new C2:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!aZe(t,function(e,t){if(!w2(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}var E2=I1.Uint8Array;function cZe(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function D2(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var lZe=1,uZe=2,dZe=`[object Boolean]`,fZe=`[object Date]`,pZe=`[object Error]`,mZe=`[object Map]`,hZe=`[object Number]`,gZe=`[object RegExp]`,_Ze=`[object Set]`,vZe=`[object String]`,yZe=`[object Symbol]`,bZe=`[object ArrayBuffer]`,xZe=`[object DataView]`,O2=L1?L1.prototype:void 0,k2=O2?O2.valueOf:void 0;function SZe(e,t,n,r,i,a,o){switch(n){case xZe:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case bZe:return!(e.byteLength!=t.byteLength||!a(new E2(e),new E2(t)));case dZe:case fZe:case hZe:return v0(+e,+t);case pZe:return e.name==t.name&&e.message==t.message;case gZe:case vZe:return e==t+``;case mZe:var s=cZe;case _Ze:var c=r&lZe;if(s||=D2,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=uZe,o.set(e,t);var u=T2(s(e),s(t),r,i,a,o);return o.delete(e),u;case yZe:if(k2)return k2.call(e)==k2.call(t)}return!1}function A2(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function j2(e,t,n){var r=t(e);return s0(e)?r:A2(r,n(e))}function CZe(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function M2(){return[]}var wZe=Object.prototype.propertyIsEnumerable,N2=Object.getOwnPropertySymbols,P2=N2?function(e){return e==null?[]:(e=Object(e),CZe(N2(e),function(t){return wZe.call(e,t)}))}:M2;function F2(e){return j2(e,b2,P2)}var TZe=1,EZe=Object.prototype.hasOwnProperty;function DZe(e,t,n,r,i,a){var o=n&TZe,s=F2(e),c=s.length;if(c!=F2(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:EZe.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var I2=h0(I1,`DataView`),L2=h0(I1,`Promise`),R2=h0(I1,`Set`),z2=h0(I1,`WeakMap`),B2=`[object Map]`,OZe=`[object Object]`,V2=`[object Promise]`,H2=`[object Set]`,U2=`[object WeakMap]`,W2=`[object DataView]`,kZe=m0(I2),AZe=m0(x0),jZe=m0(L2),MZe=m0(R2),NZe=m0(z2),G2=V1;(I2&&G2(new I2(new ArrayBuffer(1)))!=W2||x0&&G2(new x0)!=B2||L2&&G2(L2.resolve())!=V2||R2&&G2(new R2)!=H2||z2&&G2(new z2)!=U2)&&(G2=function(e){var t=V1(e),n=t==OZe?e.constructor:void 0,r=n?m0(n):``;if(r)switch(r){case kZe:return W2;case AZe:return B2;case jZe:return V2;case MZe:return H2;case NZe:return U2}return t});var K2=G2,PZe=1,q2=`[object Arguments]`,J2=`[object Array]`,Y2=`[object Object]`,X2=Object.prototype.hasOwnProperty;function FZe(e,t,n,r,i,a){var o=s0(e),s=s0(t),c=o?J2:K2(e),l=s?J2:K2(t);c=c==q2?Y2:c,l=l==q2?Y2:l;var u=c==Y2,d=l==Y2,f=c==l;if(f&&s2(e)){if(!s2(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new S2,o||h2(e)?T2(e,t,n,r,i,a):SZe(e,t,c,n,r,i,a);if(!(n&PZe)){var p=u&&X2.call(e,`__wrapped__`),m=d&&X2.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new S2,i(h,g,n,r,a)}}return f?(a||=new S2,DZe(e,t,n,r,i,a)):!1}function Z2(e,t,n,r,i){return e===t?!0:e==null||t==null||!W1(e)&&!W1(t)?e!==e&&t!==t:FZe(e,t,n,r,Z2,i)}var IZe=1,LZe=2;function RZe(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new S2;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?Z2(u,l,IZe|LZe,r,d):f))return!1}}return!0}function Q2(e){return e===e&&!u0(e)}function zZe(e){for(var t=b2(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Q2(i)]}return t}function $2(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}function BZe(e){var t=zZe(e);return t.length==1&&t[0][2]?$2(t[0][0],t[0][1]):function(n){return n===e||RZe(n,e,t)}}function VZe(e,t){return e!=null&&t in Object(e)}function e4(e,t){return e!=null&&z0(e,t,VZe)}var HZe=1,UZe=2;function WZe(e,t){return l0(e)&&Q2(t)?$2(M0(e),t):function(n){var r=$(n,e);return r===void 0&&r===t?e4(n,e):Z2(t,r,HZe|UZe)}}function GZe(e){return function(t){return t?.[e]}}function KZe(e){return function(t){return N0(t,e)}}function qZe(e){return l0(e)?GZe(M0(e)):KZe(e)}function t4(e){return typeof e==`function`?e:e==null?q0:typeof e==`object`?s0(e)?WZe(e[0],e[1]):BZe(e):qZe(e)}function JZe(e,t,n){var r=s0(e),i=r||s2(e)||h2(e);if(t=t4(t,4),n==null){var a=e&&e.constructor;n=i?r?new a:[]:u0(e)&&d0(a)?n2(U1(e)):{}}return(i?e2:x2)(e,function(e,r,i){return t(n,e,r,i)}),n}function n4(e,t,n){(n!==void 0&&!v0(e[t],n)||n===void 0&&!(t in e))&&H0(e,t,n)}var r4=typeof exports==`object`&&exports&&!exports.nodeType&&exports,i4=r4&&typeof module==`object`&&module&&!module.nodeType&&module,a4=i4&&i4.exports===r4?I1.Buffer:void 0,o4=a4?a4.allocUnsafe:void 0;function s4(e,t){if(t)return e.slice();var n=e.length,r=o4?o4(n):new e.constructor(n);return e.copy(r),r}function c4(e){var t=new e.constructor(e.byteLength);return new E2(t).set(new E2(e)),t}function l4(e,t){var n=t?c4(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function u4(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function d4(e){return typeof e.constructor==`function`&&!_2(e)?n2(U1(e)):{}}function f4(e){return W1(e)&&y2(e)}function p4(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}function m4(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?H0(n,s,c):U0(n,s,c)}return n}function YZe(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var XZe=Object.prototype.hasOwnProperty;function ZZe(e){if(!u0(e))return YZe(e);var t=_2(e),n=[];for(var r in e)r==`constructor`&&(t||!XZe.call(e,r))||n.push(r);return n}function h4(e){return y2(e)?g2(e,!0):ZZe(e)}function QZe(e){return m4(e,h4(e))}function $Ze(e,t,n,r,i,a,o){var s=p4(e,n),c=p4(t,n),l=o.get(c);if(l){n4(e,n,l);return}var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=s0(c),p=!f&&s2(c),m=!f&&!p&&h2(c);u=c,f||p||m?s0(s)?u=s:f4(s)?u=u4(s):p?(d=!1,u=s4(c,!0)):m?(d=!1,u=l4(c,!0)):u=[]:K1(c)||I0(c)?(u=s,I0(s)?u=QZe(s):(!u0(s)||d0(s))&&(u=d4(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),n4(e,n,u)}function g4(e,t,n,r,i){e!==t&&r2(t,function(a,o){if(i||=new S2,u0(a))$Ze(e,t,o,n,g4,r,i);else{var s=r?r(p4(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),n4(e,o,s)}},h4)}function eQe(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var _4=Math.max;function v4(e,t,n){return t=_4(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=_4(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),eQe(e,this,s)}}function tQe(e){return function(){return e}}var nQe=V0?function(e,t){return V0(e,`toString`,{configurable:!0,enumerable:!1,value:tQe(t),writable:!0})}:q0,rQe=800,iQe=16,aQe=Date.now;function oQe(e){var t=0,n=0;return function(){var r=aQe(),i=iQe-(r-n);if(n=r,i>0){if(++t>=rQe)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var y4=oQe(nQe);function b4(e,t){return y4(v4(e,t,q0),e+``)}function sQe(e,t,n){if(!u0(n))return!1;var r=typeof t;return(r==`number`?y2(n)&&L0(t,n.length):r==`string`&&t in n)?v0(n[t],e):!1}function cQe(e){return b4(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&sQe(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var lQe=cQe(function(e,t,n){g4(e,t,n)}),x4=L1?L1.isConcatSpreadable:void 0;function uQe(e){return s0(e)||I0(e)||!!(x4&&e&&e[x4])}function S4(e,t,n,r,i){var a=-1,o=e.length;for(n||=uQe,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?S4(s,t-1,n,r,i):A2(i,s):r||(i[i.length]=s)}return i}var dQe=1/0;function fQe(e){return e!=null&&e.length?S4(e,dQe):[]}function pQe(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function mQe(e){return e!==e}function hQe(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function C4(e,t,n){return t===t?hQe(e,t,n):pQe(e,mQe,n)}function w4(e,t){return!!(e!=null&&e.length)&&C4(e,t,0)>-1}function T4(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function E4(){}var gQe=R2&&1/D2(new R2([,-0]))[1]==1/0?function(e){return new R2(e)}:E4,_Qe=200;function D4(e,t,n){var r=-1,i=w4,a=e.length,o=!0,s=[],c=s;if(n)o=!1,i=T4;else if(a>=_Qe){var l=t?null:gQe(e);if(l)return D2(l);o=!1,i=w2,c=new C2}else c=t?[]:s;outer:for(;++r<a;){var u=e[r],d=t?t(u):u;if(u=n||u!==0?u:0,o&&d===d){for(var f=c.length;f--;)if(c[f]===d)continue outer;t&&c.push(d),s.push(u)}else i(c,d,n)||(c!==s&&c.push(d),s.push(u))}return s}function O4(e){return e&&e.length?D4(e):[]}var vQe=`[object Map]`,yQe=`[object Set]`,bQe=Object.prototype.hasOwnProperty;function k4(e){if(e==null)return!0;if(y2(e)&&(s0(e)||typeof e==`string`||typeof e.splice==`function`||s2(e)||h2(e)||I0(e)))return!e.length;var t=K2(e);if(t==vQe||t==yQe)return!e.size;if(_2(e))return!v2(e).length;for(var n in e)if(bQe.call(e,n))return!1;return!0}var xQe=Object.prototype;function A4(e){for(let t in e)if(xQe.hasOwnProperty.call(e,t))return!1;return!0}var SQe=[`$defs`,`definitions`,`properties`,`patternProperties`,`dependencies`],CQe=[`items`,`allOf`,`oneOf`,`anyOf`],wQe=[`items`,`additionalItems`,`additionalProperties`,`propertyNames`,`contains`,`if`,`then`,`else`,`not`];[...SQe,...CQe,...wQe];function j4(e){return typeof e==`object`}function M4(e){return j4(e)?A4(e):e===!0}function N4(e,t){return e<t?-1:e>t?1:0}function P4(e,t){let n=e.length;if(n===0)return t;let r=t.length;if(r===0)return e;if(n<r){let i=e;e=t,t=i,r=n}let i=new Set(e);for(let e=0;e<r;e++)i.add(t[e]);return Array.from(i)}function TQe(e,t){let n=[];if(e.length===0||t.length===0)return n;if(e.length>t.length){let n=e;e=t,t=n}let r=new Set(t);for(let t=0;t<e.length&&r.size>0;t++){let i=e[t];r.delete(i)&&n.push(i)}return n}function F4(e){return e.length===0}function I4(e){return(t,n)=>{let r=t.length-n.length;if(r!==0)return r;for(let r=0;r<t.length;r++)if(t[r]!==n[r]){let i=e(t[r],n[r]);if(i!==0)return i}return 0}}function L4(e,{threshold:t=12}={}){return n=>{let r=n.length;if(r===0)return n;if(r<=t){let t=[],i=0;outer:for(let a=0;a<r;a++){let r=n[a];for(let n=0;n<i;n++)if(e(r,t[n])===0)continue outer;i=t.push(r)}return t}let i=n.slice().sort(e),a=0;for(let t=1;t<r;t++)e(i[a],i[t])!==0&&++a!==t&&(i[a]=i[t]);return i.length=a+1,i}}function EQe(e){return(t,n)=>{let r=[],i=t.length,a=n.length;if(i===0||a===0)return r;if(i>a){let e=t;t=n,n=e;let r=i;i=a,a=r}let o=[...t].sort(e),s=[...n].sort(e),c=0,l=0;for(;c<i&&l<a;){let t=e(o[c],s[l]);t===0?((r.length===0||e(r[r.length-1],o[c])!==0)&&r.push(o[c]),c++,l++):t<0?c++:l++}return r}}function DQe(e,t){return n=>{if(e.has(n))return e.get(n);let r=t(n);return e.set(n,r),r}}var R4=DQe,z4=()=>0,OQe=e=>e===void 0,kQe=e=>typeof e!=`object`,B4={boolean:0,number:1,string:2};function AQe(e,t){let n=typeof e,r=typeof t;return n===r?N4(e,t):B4[n]-B4[r]}function jQe(e,t){let n=e.length;if(n===0)return t;let r=t.length;if(r===0)return e;if(r>n){let n=e;e=t,t=n}let i=new Set(e),a=t.length;for(let n=0;n<a;n++){let r=t[n];i.has(r)||e.push(r)}return e}function V4(e,t,n=z4){return(r,i)=>e(r)?e(i)?n(r,i):-1:e(i)?1:t(r,i)}function H4(e){return V4(OQe,e)}function U4(e,t){return V4(t=>t===void 0||e(t),t)}function W4(e,t){return V4(Array.isArray,e,t)}var G4=H4(N4),K4=U4(e=>e===0,(e,t)=>e-t);function MQe({deduplicationCache:e=new WeakMap,sortedKeysCache:t=new WeakMap}={}){let n=R4(t,e=>Object.keys(e).sort());function r(e){return(t,r)=>{let i=n(t),a=n(r),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=N4(i[e],a[e]);if(t!==0)return t}if(i.length!==a.length)return i.length-a.length;for(let n=0;n<o;n++){let a=i[n],o=e(t[a],r[a]);if(o!==0)return o}return 0}}function i(t){let n=I4(t),r=R4(e,L4(t,{threshold:0}));return(e,t)=>n(r(e),r(t))}let a=i(N4);function o(e,t){if(j4(e)){if(j4(t)){let n=jQe(Object.keys(e),Object.keys(t)),r=n.length;for(let i=0;i<r;i++){let r=n[i];if(e[r]===t[r])continue;let a=(m[r]??s)(e[r],t[r]);if(a!==0)return a}return 0}return t===!0&&A4(e)?0:1}return j4(t)?e===!0&&A4(t)?0:-1:N4(e,t)}let s=H4(l),c=V4(kQe,W4(r(s),I4(l)),AQe);function l(e,t){return e===null?-1:t===null?1:c(e,t)}let u=H4(o),d=U4(A4,r(u)),f=H4(i(o)),p=U4(M4,o),m={$id:G4,$comment:G4,$defs:d,$ref:G4,$schema:G4,const:s,contains:u,contentEncoding:G4,contentMediaType:G4,default:s,definitions:d,description:G4,else:u,examples:s,exclusiveMaximum:G4,exclusiveMinimum:G4,format:G4,if:u,maximum:G4,maxItems:G4,maxLength:G4,maxProperties:G4,minimum:G4,multipleOf:G4,not:u,pattern:G4,propertyNames:u,readOnly:G4,then:u,title:G4,writeOnly:G4,uniqueItems:U4(e=>e===!1,z4),minLength:K4,minItems:K4,minProperties:K4,required:U4(F4,a),enum:U4(F4,i(l)),type:H4((e,t)=>{let n=Array.isArray(e),r=Array.isArray(t);return!n&&!r?N4(e,t):a(n?e:[e],r?t:[t])}),items:U4(e=>!Array.isArray(e)&&M4(e),W4(o,I4(o))),anyOf:f,allOf:f,oneOf:f,properties:d,patternProperties:d,additionalProperties:p,additionalItems:p,dependencies:U4(A4,r(H4(W4(o,a))))};return{compareSchemaValues:l,compareSchemaDefinitions:o}}function q4(e){return e}var J4=(e,t)=>e?J4(t%e,e):t,NQe=(e,t)=>Math.abs(e*t)/J4(e,t);function PQe(e,t){return e===t?e:`^(?=.*(?:${e}))(?=.*(?:${t})).*$`}function Y4(e,t,n){let r=e.length,i=t.length;if(r>0&&i>0)for(let a=0;a<r;a++){let r=e[a];for(let e=0;e<i;e++)n(r,t[e])}}function X4(e,t){return e||t}function Z4(e){return(t,n)=>{let r={...t},i=Object.keys(n),a=i.length;for(let o=0;o<a;o++){let a=i[o];r[a]=t[a]===void 0?n[a]:e(t[a],n[a])}return r}}function FQe(e){let t=new Map;for(let n of e)for(let e of n[0])t.set(e,n[1]);return t}function Q4(e,t,n){n===void 0||M4(n)?delete e[t]:e[t]=n}var IQe=[`properties`,`patternProperties`,`additionalProperties`];function $4(e){let t=Object.keys(e),n=t.length,r=[];for(let i=0;i<n;i++){let n=t[i];r.push({regExp:new RegExp(n),schema:e[n]})}return[r,t]}var e3=[[],[]];function t3(e,t,n){let r=n.length;for(let i=0;i<r;i++){let r=n[i];if(!r.regExp.test(t))continue;let a=r.schema;if(a===!1)return!0;e.push(a)}return!1}var LQe=[`items`,`additionalItems`],RQe=[`if`,`then`,`else`];function n3(e,t){return t.if!==void 0&&(e.if=t.if),t.then!==void 0&&(e.then=t.then),t.else!==void 0&&(e.else=t.else),e}function r3(e,t){if(e===t)return e;switch(e){case`number`:if(t===`integer`)return`integer`;case`integer`:if(t===`number`)return`integer`;default:return}}function i3(e,t,n){return[e,t,n]}function zQe(e){let t=new Map;for(let[n,r,i]of e){let e=e=>{if(!i(e))throw Error(`Schema keys '${n}' and '${r}' are conflicting (${n}: ${JSON.stringify(e[n])}, ${r}: ${JSON.stringify(e[r])})`)};for(let i of[[n,r],[r,n]]){let n=t.get(i[0]);n===void 0&&(n=[],t.set(i[0],n)),n.push({oppositeKey:i[1],check:e})}}return t}var BQe=[i3(`minimum`,`maximum`,e=>e.maximum>=e.minimum),i3(`exclusiveMinimum`,`maximum`,e=>e.maximum>e.exclusiveMinimum),i3(`minimum`,`exclusiveMaximum`,e=>e.exclusiveMaximum>e.minimum),i3(`exclusiveMinimum`,`exclusiveMaximum`,e=>e.exclusiveMaximum>e.exclusiveMinimum),i3(`minLength`,`maxLength`,e=>e.maxLength>=e.minLength),i3(`minItems`,`maxItems`,e=>e.maxItems>=e.minItems),i3(`minProperties`,`maxProperties`,e=>e.maxProperties>=e.minProperties)];function VQe({mergePatterns:e=PQe,isSubRegExp:t=Object.is,intersectJson:n=TQe,deduplicateJsonSchemaDef:r=q4,defaultMerger:i=q4,assigners:a=[],checks:o=BQe,mergers:s}={}){function c(e){let t=e.length,n=e[0];for(let r=1;r<t;r++){let t=_(n,e[r]);if(t===!1)return!1;M4(t)||(n=t)}return n}function l(e,t,n,r,i,a,o){if(e.length=0,n===!1)return!1;if(e.push(n),i!==void 0){if(i===!1)return!1;e.push(i)}if(t3(e,t,a))return!1;let s=e.length<2;if(o===!1){if(s)return;if(t3(e,t,r))return!1}else s&&o!==void 0&&e.push(o);return e.length===1?e[0]:c(e)}function u(e,t,n,r,i,a){let o=n.length;if(o>0&&i!==!1)if(a)Object.assign(e,t);else for(let a=0;a<o;a++){let o=n[a];r.has(o)||(e[o]=_(t[o],i))}return e}let d=(n,{properties:r={},patternProperties:i,additionalProperties:a=!0},{properties:o={},patternProperties:s,additionalProperties:c=!0})=>{let d=M4(a),f=M4(c);if(d&&f)return Q4(n,`properties`,v(r,o)),Q4(n,`patternProperties`,i&&s?v(i,s):i??s),delete n.additionalProperties,n;Q4(n,`additionalProperties`,_(a,c));let p={},m=Object.keys(r),h=m.length,[g,y]=i?$4(i):e3,[b,x]=s?$4(s):e3,S=[],C=new Set,w=f?void 0:c;for(let e=0;e<h;e++){let t=m[e];C.add(t);let n=l(S,t,r[t],g,o[t],b,w);n!==void 0&&(p[t]=n)}let T=Object.keys(o),E=T.length,D=d?void 0:a;for(let e=0;e<E;e++){let t=T[e];if(C.has(t))continue;let n=l(S,t,o[t],b,void 0,g,D);n!==void 0&&(p[t]=n)}Q4(n,`properties`,p);let O={},k=new Set;return y.length>0&&x.length>0&&Y4(y,x,(n,r)=>{t(n,r)&&k.add(n),t(r,n)&&k.add(r),O[e(n,r)]=_(i[n],s[r])}),O=u(O,i,y,k,c,f),O=u(O,s,x,k,a,d),Q4(n,`patternProperties`,O),n},f=(e,{items:t=[],additionalItems:n},{items:r=[],additionalItems:i})=>{let a=Array.isArray(t),o=Array.isArray(r),s=[];if(e.items=s,a&&o){let[a,o,c]=t.length<r.length?[t.length,n,r]:[r.length,i,t],l=0;for(;l<a;l++)s.push(_(t[l],r[l]));if(o===!1)e.additionalItems=!1;else{let t=o===void 0||M4(o);for(;l<c.length;l++)s.push(t?c[l]:_(c[l],o));Q4(e,`additionalItems`,n!==void 0&&i!==void 0?_(n,i):n??i)}}else if(a||o){let[o,c,l]=a?[t,r,n]:[r,t,i];Q4(e,`additionalItems`,l&&_(l,c));for(let e=0;e<o.length;e++)s.push(_(o[e],c))}else delete e.additionalItems,e.items=_(t,r);return e},p=(e,t,n)=>{n3(e,t);let r=n3({},n);return e.allOf===void 0?e.allOf=[r]:e.allOf=e.allOf.concat(r),e};function m(e,t){let n=[];if(Y4(e,t,(e,t)=>{try{n.push(_(e,t))}catch{}}),n.length===0)throw Error(`No valid schema combinations could be produced for "${JSON.stringify(e)}" and "${JSON.stringify(t)}"; the merged result is empty`);return r(n)}let h=FQe([[IQe,d],[LQe,f],[RQe,p],...a]),g=zQe(o);function _(e,t){if(e===!1||t===!1)return!1;if(M4(e))return M4(t)?!0:t;if(M4(t))return e;let n={...e},r=new Set,a=new Set,o=Object.keys(t),s=o.length;for(let c=0;c<s;c++){let s=o[c],l=t[s];if(l===void 0)continue;let u=g.get(s);if(u!==void 0){let t=u.length;for(let n=0;n<t;n++){let t=u[n];e[t.oppositeKey]!==void 0&&a.add(t.check)}}let d=e[s];if(d===void 0){n[s]=l;continue}let f=h.get(s);if(f){r.add(f);continue}let p=y[s]??i;n[s]=p(d,l)}for(let i of r)n=i(n,e,t);for(let e of a)e(n);return n}let v=Z4(_),y={$id:i,$ref:i,$schema:i,$comment:i,$defs:v,definitions:v,type:(e,t)=>{if(e===t)return e;let n=Array.isArray(e),r=Array.isArray(t);if(!n&&!r){let n=r3(e,t);if(n!==void 0)return n}else if(n||r){let i=new Set;if(n&&r)Y4(e,t,(e,t)=>{let n=r3(e,t);n!==void 0&&i.add(n)});else{let r=n?e:t,a=n?t:e,o=r.length;for(let e=0;e<o;e++){let t=r3(a,r[e]);t!==void 0&&i.add(t)}}let a=i.size;if(a===1)return i.values().next().value;if(a>1)return Array.from(i)}throw Error(`It is not possible to create an intersection of the following incompatible types: ${e.toString()}, ${t.toString()}`)},default:i,description:i,title:i,const:i,format:i,contentEncoding:i,contentMediaType:i,not:(e,t)=>{let n=r([e,t]);return n.length===1?n[0]:{anyOf:n}},pattern:e,readOnly:X4,writeOnly:X4,enum:(e,t)=>{let r=n(e,t);if(r.length===0)throw Error(`Intersection of the following enums is empty: "${JSON.stringify(e)}", "${JSON.stringify(t)}"`);return r},anyOf:m,oneOf:m,allOf:(e,t)=>r(e.concat(t)),propertyNames:_,contains:_,dependencies:Z4((e,t)=>Array.isArray(e)?Array.isArray(t)?P4(e,t):_(t,{required:e}):Array.isArray(t)?_(e,{required:t}):_(e,t)),examples:(e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))throw Error(`Value of the 'examples' field should be an array, but got "${JSON.stringify(e)}" and "${JSON.stringify(t)}"`);return P4(e,t)},multipleOf:(e,t)=>{let n=1;for(;!Number.isInteger(e)||!Number.isInteger(t);)n*=10,e*=10,t*=10;return NQe(e,t)/n},exclusiveMaximum:Math.min,maximum:Math.min,maxItems:Math.min,maxLength:Math.min,maxProperties:Math.min,exclusiveMinimum:Math.max,minimum:Math.max,minItems:Math.max,minLength:Math.max,minProperties:Math.max,uniqueItems:X4,required:P4,...s};return{mergeSchemaDefinitions:_,mergeArrayOfSchemaDefinitions:c}}function HQe(e){let t=[],n=[e];for(;n.length>0;){let e=n.pop();if(typeof e==`boolean`||e.allOf===void 0){t.push(e);continue}let{allOf:r,...i}=e;t.push(i);for(let e=r.length-1;e>=0;e--)n.push(r[e])}return t}function UQe(e){return t=>e(HQe(t))}var a3=e(i((e=>{var t=/~/,n=/~[01]/g;function r(e){switch(e){case`~1`:return`/`;case`~0`:return`~`}throw Error(`Invalid tilde escape: `+e)}function i(e){return t.test(e)?e.replace(n,r):e}function a(e){if(typeof e==`string`){if(e=e.split(`/`),e[0]===``)return e;throw Error(`Invalid JSON pointer.`)}else if(Array.isArray(e)){for(let t of e)if(typeof t!=`string`&&typeof t!=`number`)throw Error(`Invalid JSON pointer. Must be of type string or number.`);return e}throw Error(`Invalid JSON pointer.`)}function o(e,t){if(typeof e!=`object`)throw Error(`Invalid input object.`);t=a(t);var n=t.length;if(n===1)return e;for(var r=1;r<n;){if(e=e[i(t[r++])],n===r)return e;if(typeof e!=`object`||!e)return}}e.get=o}))(),1);function WQe(e,t){return e&&m4(t,b2(t),e)}function GQe(e,t){return e&&m4(t,h4(t),e)}function KQe(e,t){return m4(e,P2(e),t)}var o3=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)A2(t,P2(e)),e=U1(e);return t}:M2;function qQe(e,t){return m4(e,o3(e),t)}function s3(e){return j2(e,h4,o3)}var JQe=Object.prototype.hasOwnProperty;function YQe(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&JQe.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function XQe(e,t){var n=t?c4(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var ZQe=/\w*$/;function QQe(e){var t=new e.constructor(e.source,ZQe.exec(e));return t.lastIndex=e.lastIndex,t}var c3=L1?L1.prototype:void 0,l3=c3?c3.valueOf:void 0;function $Qe(e){return l3?Object(l3.call(e)):{}}var e$e=`[object Boolean]`,t$e=`[object Date]`,n$e=`[object Map]`,r$e=`[object Number]`,i$e=`[object RegExp]`,a$e=`[object Set]`,o$e=`[object String]`,s$e=`[object Symbol]`,c$e=`[object ArrayBuffer]`,l$e=`[object DataView]`,u$e=`[object Float32Array]`,d$e=`[object Float64Array]`,f$e=`[object Int8Array]`,p$e=`[object Int16Array]`,m$e=`[object Int32Array]`,h$e=`[object Uint8Array]`,g$e=`[object Uint8ClampedArray]`,_$e=`[object Uint16Array]`,v$e=`[object Uint32Array]`;function y$e(e,t,n){var r=e.constructor;switch(t){case c$e:return c4(e);case e$e:case t$e:return new r(+e);case l$e:return XQe(e,n);case u$e:case d$e:case f$e:case p$e:case m$e:case h$e:case g$e:case _$e:case v$e:return l4(e,n);case n$e:return new r;case r$e:case o$e:return new r(e);case i$e:return QQe(e);case a$e:return new r;case s$e:return $Qe(e)}}var b$e=`[object Map]`;function x$e(e){return W1(e)&&K2(e)==b$e}var u3=p2&&p2.isMap,S$e=u3?l2(u3):x$e,C$e=`[object Set]`;function w$e(e){return W1(e)&&K2(e)==C$e}var d3=p2&&p2.isSet,T$e=d3?l2(d3):w$e,E$e=1,D$e=2,O$e=4,f3=`[object Arguments]`,k$e=`[object Array]`,A$e=`[object Boolean]`,j$e=`[object Date]`,M$e=`[object Error]`,p3=`[object Function]`,N$e=`[object GeneratorFunction]`,P$e=`[object Map]`,F$e=`[object Number]`,m3=`[object Object]`,I$e=`[object RegExp]`,L$e=`[object Set]`,R$e=`[object String]`,z$e=`[object Symbol]`,B$e=`[object WeakMap]`,V$e=`[object ArrayBuffer]`,H$e=`[object DataView]`,U$e=`[object Float32Array]`,W$e=`[object Float64Array]`,G$e=`[object Int8Array]`,K$e=`[object Int16Array]`,q$e=`[object Int32Array]`,J$e=`[object Uint8Array]`,Y$e=`[object Uint8ClampedArray]`,X$e=`[object Uint16Array]`,Z$e=`[object Uint32Array]`,h3={};h3[f3]=h3[k$e]=h3[V$e]=h3[H$e]=h3[A$e]=h3[j$e]=h3[U$e]=h3[W$e]=h3[G$e]=h3[K$e]=h3[q$e]=h3[P$e]=h3[F$e]=h3[m3]=h3[I$e]=h3[L$e]=h3[R$e]=h3[z$e]=h3[J$e]=h3[Y$e]=h3[X$e]=h3[Z$e]=!0,h3[M$e]=h3[p3]=h3[B$e]=!1;function g3(e,t,n,r,i,a){var o,s=t&E$e,c=t&D$e,l=t&O$e;if(n&&(o=i?n(e,r,i,a):n(e)),o!==void 0)return o;if(!u0(e))return e;var u=s0(e);if(u){if(o=YQe(e),!s)return u4(e,o)}else{var d=K2(e),f=d==p3||d==N$e;if(s2(e))return s4(e,s);if(d==m3||d==f3||f&&!i){if(o=c||f?{}:d4(e),!s)return c?qQe(e,GQe(o,e)):KQe(e,WQe(o,e))}else{if(!h3[d])return i?e:{};o=y$e(e,d,s)}}a||=new S2;var p=a.get(e);if(p)return p;a.set(e,o),T$e(e)?e.forEach(function(r){o.add(g3(r,t,n,r,e,a))}):S$e(e)&&e.forEach(function(r,i){o.set(i,g3(r,t,n,i,e,a))});var m=u?void 0:(l?c?s3:F2:c?h4:b2)(e);return e2(m||e,function(r,i){m&&(i=r,r=e[i]),U0(o,i,g3(r,t,n,i,e,a))}),o}function _3(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function Q$e(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function $$e(e,t){return t.length<2?e:N0(e,Q$e(t,0,-1))}var e1e=Object.prototype.hasOwnProperty;function v3(e,t){t=j0(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=M0(t[n]);if(i===`__proto__`&&!e1e.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=$$e(e,t);return a==null||delete a[M0(_3(t))]}function t1e(e){return K1(e)?void 0:e}function y3(e){return e!=null&&e.length?S4(e,1):[]}function b3(e){return y4(v4(e,void 0,y3),e+``)}var n1e=1,r1e=2,i1e=4,x3=b3(function(e,t){var n={};if(e==null)return n;var r=!1;t=E0(t,function(t){return t=j0(t,e),r||=t.length>1,t}),m4(e,s3(e),n),r&&(n=g3(n,n1e|r1e|i1e,t1e));for(var i=t.length;i--;)v3(n,t[i]);return n}),S3=i(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function i(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var a=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(e){return e.length=0,!0}function s(e,t,n){if(e.length){let r=i(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function c(e){let t=0,n={error:!1,address:``,zone:``},r=[],a=[],c=!1,l=!1,u=s;for(let i=0;i<e.length;i++){let s=e[i];if(!(s===`[`||s===`]`))if(s===`:`){if(c===!0&&(l=!0),!u(a,r,n))break;if(++t>7){n.error=!0;break}i>0&&e[i-1]===`:`&&(c=!0),r.push(`:`);continue}else if(s===`%`){if(!u(a,r,n))break;u=o}else{a.push(s);continue}}return a.length&&(u===o?n.zone=a.join(``):l?r.push(a.join(``)):r.push(i(a))),n.address=r.join(``),n}function l(e){if(u(e,`:`)<2)return{host:e,isIPV6:!1};let t=c(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function u(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function d(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}function f(e,t){let n=t===!0?unescape:escape;return e.scheme!==void 0&&(e.scheme=n(e.scheme)),e.userinfo!==void 0&&(e.userinfo=n(e.userinfo)),e.host!==void 0&&(e.host=n(e.host)),e.path!==void 0&&(e.path=n(e.path)),e.query!==void 0&&(e.query=n(e.query)),e.fragment!==void 0&&(e.fragment=n(e.fragment)),e}function p(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let t=l(n);n=t.isIPV6===!0?`[${t.escapedHost}]`:e.host}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:a,recomposeAuthority:p,normalizeComponentEncoding:f,removeDotSegments:d,isIPv4:r,isUUID:n,normalizeIPv6:l,stringArrayToHexStripped:i}})),a1e=i(((e,t)=>{var{isUUID:n}=S3(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=S(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=S(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},y={scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},b={scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0},x={http:h,https:g,ws:_,wss:v,urn:y,"urn:uuid":b};Object.setPrototypeOf(x,null);function S(e){return e&&(x[e]||x[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:x,isValidSchemeName:a,getSchemeHandler:S}})),C3=i(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:o,nonSimpleDomain:s}=S3(),{SCHEMES:c,getSchemeHandler:l}=a1e();function u(e,t){return typeof e==`string`?e=m(g(e,t),t):typeof e==`object`&&(e=g(m(e,t),t)),e}function d(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=f(g(e,r),g(t,r),r,!0);return r.skipEscape=!0,m(i,r)}function f(e,t,n,i){let a={};return i||(e=g(m(e,n),n),t=g(m(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function p(e,t,n){return typeof e==`string`?(e=unescape(e),e=m(a(g(e,n),!0),{...n,skipEscape:!0})):typeof e==`object`&&(e=m(a(e,!0),{...n,skipEscape:!0})),typeof t==`string`?(t=unescape(t),t=m(a(g(t,n),!0),{...n,skipEscape:!0})):typeof t==`object`&&(t=m(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function m(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},a=Object.assign({},t),o=[],s=l(a.scheme||n.scheme);s&&s.serialize&&s.serialize(n,a),n.path!==void 0&&(a.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),a.reference!==`suffix`&&n.scheme&&o.push(n.scheme,`:`);let c=i(n);if(c!==void 0&&(a.reference!==`suffix`&&o.push(`//`),o.push(c),n.path&&n.path[0]!==`/`&&o.push(`/`)),n.path!==void 0){let e=n.path;!a.absolutePath&&(!s||!s.absolutePath)&&(e=r(e)),c===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),o.push(e)}return n.query!==void 0&&o.push(`?`,n.query),n.fragment!==void 0&&o.push(`#`,n.fragment),o.join(``)}var h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function g(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let c=e.match(h);if(c){if(i.scheme=c[1],i.userinfo=c[3],i.host=c[4],i.port=parseInt(c[5],10),i.path=c[6]||``,i.query=c[7],i.fragment=c[8],isNaN(i.port)&&(i.port=c[5]),i.host)if(o(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),a=e.isIPV6}else a=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let t=l(r.scheme||i.scheme);if(!r.unicodeSupport&&(!t||!t.unicodeSupport)&&i.host&&(r.domainHost||t&&t.domainHost)&&a===!1&&s(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}(!t||t&&!t.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=unescape(i.host))),i.path&&=escape(unescape(i.path)),i.fragment&&=encodeURI(decodeURIComponent(i.fragment))),t&&t.parse&&t.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return i}var _={SCHEMES:c,normalize:u,resolve:d,resolveComponent:f,equal:p,serialize:m,parse:g};t.exports=_,t.exports.default=_,t.exports.fastUri=_})),w3=e(C3(),1);function T3(e,t){if(`$id`in e&&w3.default.equal(e.$id,t))return e;for(let n of Object.values(e))if(Array.isArray(n)){for(let e of n)if(u0(e)){let n=T3(e,t);if(n!==void 0)return n}}else if(u0(n)){let e=T3(n,t);if(e!==void 0)return e}}function E3(e,t){let n=$(e,`$id`,t);`$ref`in e&&(e={...e,[D1]:w3.default.resolve(n,e[D1])});for(let[t,r]of Object.entries(e))Array.isArray(r)?e={...e,[t]:r.map(e=>u0(e)?E3(e,n):e)}:u0(r)&&(e={...e,[t]:E3(r,n)});return e}function D3(e,t){let n=t[e];return[x3(t,[e]),n]}function O3(e,t={},n=[],r=$(t,[`$id`])){let i=e||``,a;if(i.startsWith(`#`)){let e=decodeURIComponent(i.substring(1));r===void 0||`$id`in t&&t.$id===r?a=a3.get(t,e):t.$schema===`https://json-schema.org/draft/2020-12/schema`&&(a=T3(t,r.replace(/\/$/,``)),a!==void 0&&(a=a3.get(a,e)))}else if(t.$schema===`https://json-schema.org/draft/2020-12/schema`){let[e,...n]=(r?w3.default.resolve(r,i):i).replace(/#\/?$/,``).split(`#`);a=T3(t,e.replace(/\/$/,``)),a!==void 0&&(r=a.$id,k4(n)||(a=a3.get(a,decodeURIComponent(n.join(`#`)))))}if(a===void 0)throw Error(`Could not find a definition for ${e}.`);let o=a[D1];if(o){if(n.includes(o)){if(n.length===1)throw Error(`Definition for ${e} is a circular reference`);let[t,...r]=n,a=[...r,i,t].join(` -> `);throw Error(`Definition for ${t} contains a circular reference through ${a}`)}let[s,c]=D3(D1,a),l=O3(c,t,[...n,i],r);return Object.keys(s).length>0?t.$schema===`https://json-schema.org/draft/2019-09/schema`||t.$schema===`https://json-schema.org/draft/2020-12/schema`?{[g1]:[s,l]}:{...s,...l}:l}return a}function k3(e,t={},n=$(t,[`$id`])){return O3(e,t,[],n)}var o1e=`[object String]`;function A3(e){return typeof e==`string`||!s0(e)&&W1(e)&&V1(e)==o1e}function j3(e){let t,n=$(e,yJe);return A3(n)?t=n:n!==void 0&&console.warn(`Expecting discriminator to be a string, got "${typeof n}" instead`),t}function M3(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:e==null?`null`:typeof e==`boolean`?`boolean`:isNaN(e)?typeof e==`object`?`object`:`string`:`number`}var s1e=b4(function(e){return D4(S4(e,1,f4,!0))});function N3(e){let{type:t}=e;return!t&&e.const?M3(e.const):!t&&e.enum?`string`:!t&&(e.properties||e.additionalProperties||e.patternProperties)?`object`:(Array.isArray(t)&&(t=t.length===2&&t.includes(`null`)?t.find(e=>e!==`null`):t[0]),t)}function P3(e,t){let n=Object.assign({},e);return Object.keys(t).reduce((n,r)=>{let i=e?e[r]:{},a=t[r];return e&&r in e&&p1(a)?n[r]=P3(i,a):e&&t&&(N3(e)===`object`||N3(t)===`object`)&&r===`required`&&Array.isArray(i)&&Array.isArray(a)?n[r]=s1e(i,a):n[r]=a,n},n)}var c1e=`[object Number]`;function F3(e){return typeof e==`number`||W1(e)&&V1(e)==c1e}function I3(e,t,n){if(e&&n){let r=$(e,n);if(r===void 0)return;for(let e=0;e<t.length;e++){let i=t[e],a=$(i,[w1,n],{});if(!(a.type===`object`||a.type===`array`)&&(a.const===r||a.enum?.includes(r)))return e}}}function L3(e,t,n,r,i){if(t===void 0)return 0;let a=I3(t,n,i);if(F3(a))return a;for(let a=0;a<n.length;a++){let o=n[a];if(i&&B0(o,[`properties`,i])){let n=$(t,i),s=$(o,[w1,i],{});if(e.isValid(s,n,r))return a}else if(o.properties){let n={anyOf:Object.keys(o[w1]).map(e=>({required:[e]}))},i;if(o.anyOf){let{...e}=o;e.allOf?e.allOf=e.allOf.slice():e.allOf=[],e.allOf.push(n),i=e}else i=Object.assign({},o,n);if(delete i.required,e.isValid(i,t,r))return a}else if(e.isValid(o,t,r))return a}return 0}function R3(e,t,n={},r,i,a=!1){return U3(e,t,n,r,void 0,void 0,i,a)[0]}function l1e(e,t,n,r,i,a,o){let{if:s,then:c,else:l,...u}=t,d=e.isValid(s,a||{},n),f=[u],p=[];if(r)c&&typeof c!=`boolean`&&(p=p.concat(U3(e,c,n,a,r,i,o))),l&&typeof l!=`boolean`&&(p=p.concat(U3(e,l,n,a,r,i,o)));else{let t=d?c:l;t&&typeof t!=`boolean`&&(p=p.concat(U3(e,t,n,a,r,i,o)))}return p.length&&(f=p.map(e=>P3(u,e))),f.flatMap(t=>U3(e,t,n,a,r,i,o))}function z3(e){return e.reduce((e,t)=>t.length>1?t.flatMap(t=>$0(e.length,n=>[...e[n]].concat(t))):(e.forEach(e=>e.push(t[0])),e),[[]])}function B3(e,t){return Object.keys(e.patternProperties).filter(e=>RegExp(e).test(t)).reduce((t,n)=>(G0(t,[n],e.patternProperties[n]),t),{})}function u1e(e,t,n,r,i,a,o,s){let c=V3(e,t,n,r,i,a,o,s);return c.length>1||c[0]!==t?c:`dependencies`in t?W3(e,t,n,r,i,a,o).flatMap(t=>U3(e,t,n,a,r,i,o)):`allOf`in t&&Array.isArray(t.allOf)?z3(t.allOf.map(t=>U3(e,t,n,a,r,i,o))).map(e=>({...t,allOf:e})):[t]}function V3(e,t,n,r,i,a,o,s){let c=H3(t,n,i,void 0,s);return c===t?[t]:U3(e,c,n,a,r,i,o,s)}function H3(e,t,n,r,i){if(!p1(e))return e;let a=e;if(`$ref`in a){let{$ref:e,...i}=a;if(n.includes(e))return a;n.push(e),a={...k3(e,t,r),...i,[O1]:e},`$id`in a&&(r=a.$id)}if(`properties`in a){let e=[],o=JZe(a[w1],(a,o,s)=>{let c=[...n];a[s]=H3(o,t,c,r,i),e.push(c)},{});lQe(n,O4(fQe(e))),a={...a,[w1]:o}}if(`items`in a&&!Array.isArray(a.items)&&typeof a.items!=`boolean`&&(a={...a,items:H3(a.items,t,n,r,i)}),i){let o,s;`anyOf`in e&&Array.isArray(e.anyOf)?(o=_1,s=a[_1]):`oneOf`in e&&Array.isArray(e.oneOf)&&(o=C1,s=a[C1]),o&&s&&(a={...a,[o]:s.map(e=>H3(e,t,n,r,i))})}return o0(e,a)?e:a}function d1e(e,t,n,r,i){let a={...t,properties:{...t.properties}},o=r&&p1(r)?r:{};return Object.keys(o).forEach(t=>{if(!(t in a.properties)){if(`patternProperties`in a){let r=B3(a,t);if(!k4(r)){a.properties[t]=R3(e,{[g1]:Object.values(r)},n,$(o,[t]),i),G0(a.properties,[t,h1],!0);return}}if(`additionalProperties`in a&&a.additionalProperties!==!1){let r;r=typeof a.additionalProperties==`boolean`?{type:M3($(o,[t]))}:`$ref`in a.additionalProperties?R3(e,{[D1]:$(a.additionalProperties,[D1])},n,o,i):`type`in a.additionalProperties?{...a.additionalProperties}:`anyOf`in a.additionalProperties||`oneOf`in a.additionalProperties?{type:`object`,...a.additionalProperties}:{type:M3($(o,[t]))},a.properties[t]=r,G0(a.properties,[t,h1],!0)}else a.properties[t]={type:`null`},G0(a.properties,[t,h1],!0)}}),a}var{compareSchemaDefinitions:f1e,compareSchemaValues:p1e}=MQe(),{mergeArrayOfSchemaDefinitions:m1e}=VQe({intersectJson:EQe(p1e),deduplicateJsonSchemaDef:L4(f1e)}),h1e=UQe(m1e);function g1e(e){return h1e(e)}function U3(e,t,n,r,i=!1,a=[],o,s){return p1(t)?u1e(e,t,n,i,a,r,o,s).flatMap(t=>{var s;let c=t;if(`if`in c)return l1e(e,c,n,i,a,r,o);if(`allOf`in c){if(i){let{allOf:e,...t}=c;return[...e,t]}try{let e=[],t=[];(s=c.allOf)==null||s.forEach(n=>{typeof n==`object`&&n.contains?e.push(n):t.push(n)}),e.length&&(c={...c,allOf:t}),c=o?o(c):g1e(c),e.length&&(c.allOf=e)}catch(e){console.warn(`could not merge subschemas in allOf: