specrails-desktop 2.43.0 → 2.43.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 (43) hide show
  1. package/client/dist/assets/{ActivityFeedPage-DoEMumQS.js → ActivityFeedPage-C7XJ5-bJ.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-DIh4K0gh.js → AgentBrowserCapture-C_WpXceT.js} +1 -1
  3. package/client/dist/assets/{AgentModeAnalyticsPane-mbq4WEoO.js → AgentModeAnalyticsPane-PEZKjyZS.js} +2 -2
  4. package/client/dist/assets/{AgentModeCodePane-CKh7zuA4.js → AgentModeCodePane-D_Xcq5t5.js} +2 -2
  5. package/client/dist/assets/{AgentModeJobsPane-BDokPiLJ.js → AgentModeJobsPane-CDSkOuNP.js} +1 -1
  6. package/client/dist/assets/{AgentsPage-BFVAZbBj.js → AgentsPage-D577NzIM.js} +1 -1
  7. package/client/dist/assets/{AnalyticsPage-3Y9LuWwz.js → AnalyticsPage-C6ZZI_zg.js} +1 -1
  8. package/client/dist/assets/{CodePage-C9KyuV_C.js → CodePage-B5z5oLnP.js} +1 -1
  9. package/client/dist/assets/{DesktopAnalyticsPage-Bhi54bXQ.js → DesktopAnalyticsPage-D_V9RuGg.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-Dj6mt4ga.js → DocsDialog-Beg82MEe.js} +1 -1
  11. package/client/dist/assets/{DocsPage-24yWglNI.js → DocsPage-BkE4m4wp.js} +1 -1
  12. package/client/dist/assets/{InteractiveJobComposer-C1ucmxQh.js → InteractiveJobComposer-wBBBNaJn.js} +1 -1
  13. package/client/dist/assets/JobDetailModal-BCxue_Do.js +1 -0
  14. package/client/dist/assets/{JobDetailPage-BcajZyuu.js → JobDetailPage-_rIDpNfo.js} +1 -1
  15. package/client/dist/assets/{JobsPage-B9nTZw6e.js → JobsPage-C6xcijbs.js} +1 -1
  16. package/client/dist/assets/{LoopBuilderPage-Oc48iOFW.js → LoopBuilderPage-A-Mt6EjT.js} +1 -1
  17. package/client/dist/assets/{LoopPreviewModal-ae0Fr6SU.js → LoopPreviewModal-DqHiG4Dt.js} +1 -1
  18. package/client/dist/assets/{LoopsPage-CUEqzUBI.js → LoopsPage-B-ketPET.js} +1 -1
  19. package/client/dist/assets/{PluginsPage-C1xtARIx.js → PluginsPage-Dn2jPvJL.js} +1 -1
  20. package/client/dist/assets/{ProjectSettingsDialog-JZzrXFBN.js → ProjectSettingsDialog-CVTj4VLt.js} +1 -1
  21. package/client/dist/assets/{RepositoryDeliveries-CSDsiVUz.js → RepositoryDeliveries-IiQCcndQ.js} +1 -1
  22. package/client/dist/assets/{ReviewPacketPage-x5EfGTiL.js → ReviewPacketPage-BBd617OM.js} +1 -1
  23. package/client/dist/assets/{TemplatePreviewModal-BSyuZxGq.js → TemplatePreviewModal-COHFkUS4.js} +1 -1
  24. package/client/dist/assets/{TicketDetailModalContext-DqyF0so-.js → TicketDetailModalContext-BNa1mdXq.js} +3 -3
  25. package/client/dist/assets/{button-DCBqEaZl.js → button-Ccc9Dc-D.js} +1 -1
  26. package/client/dist/assets/dialog-xXB2q5HJ.js +45 -0
  27. package/client/dist/assets/index-D5n_jg_I.css +2 -0
  28. package/client/dist/assets/index-m5pKr1T6.js +76 -0
  29. package/client/dist/index.html +6 -6
  30. package/docs/guide/en/pipeline/3-batch-implement-and-multi-feature.md +11 -0
  31. package/docs/internals/core-runtime-updates.md +7 -0
  32. package/docs/internals/interactive-jobs.md +53 -0
  33. package/package.json +1 -1
  34. package/server/dist/loop-executors.js +14 -1
  35. package/server/dist/loop-factory.js +24 -5
  36. package/server/dist/loop-run-manager.js +12 -0
  37. package/server/dist/loop-templates.js +14 -33
  38. package/server/dist/rails-router.js +2 -2
  39. package/server/dist/workspace-manager.js +54 -3
  40. package/client/dist/assets/JobDetailModal-DNWmgVHD.js +0 -1
  41. package/client/dist/assets/dialog-SRw01_QU.js +0 -45
  42. package/client/dist/assets/index-DwAmL7m5.css +0 -2
  43. package/client/dist/assets/index-EzrkUb8B.js +0 -76
@@ -0,0 +1,76 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-B3mKBIh5.js","assets/rolldown-runtime-CNC7AqOf.js","assets/event-Bt7f3wXe.js","assets/addon-image-BRmmRHgQ.js","assets/addon-ligatures-qIZUPvRV.js","assets/addon-webgl-C2d7lriQ.js","assets/JobDetailModal-BCxue_Do.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/TicketDetailModalContext-BNa1mdXq.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-DEKu087k.js","assets/useSharedWebSocket-BOdS5_Iz.js","assets/activity-DiyjsgQV.js","assets/addspec-D2YIQ0GU.js","assets/agent-Bh9K7iEt.js","assets/agents-ms7TwG16.js","assets/agentstudio-CN2pokQu.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BMzCvrCU.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-BTiGnPT0.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-BrlwEnL7.js","assets/dashboard-BfBir_6o.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CKJg3HZd.js","assets/jobs-DzMjUcaN.js","assets/loops-B7YpGizO.js","assets/mcp-CUAN6ORK.js","assets/narration-B-ynWTpn.js","assets/nav-Ch-zHBG5.js","assets/packet-Cx-zRuWn.js","assets/settings-BJB9RKJj.js","assets/setup-Ba11l2JA.js","assets/specs-DII0C8gw.js","assets/terminal-BAzpHtpY.js","assets/tickets-W6pBmbrX.js","assets/createLucideIcon-Bjbbp_KS.js","assets/Trans-SnMX4MhW.js","assets/useDesktop-RSMTyy7V.js","assets/save-B6wGWwBR.js","assets/spending-BqbdPm_4.js","assets/MinimizedChatsContext-Deg39peL.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/file-text-BcLCfcWZ.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/git-branch-BRM0F5GN.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/square-Ci-PFcFe.js","assets/plus-CsnjfkmX.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/jira-api-CSCqGr-Q.js","assets/zap-CHo3aCD1.js","assets/dialog-xXB2q5HJ.js","assets/utils-BC4DHlz2.js","assets/clsx-CjueKrWZ.js","assets/lib-CGdyxIWg.js","assets/formatDistanceToNow-DSj5DprF.js","assets/getTimezoneOffsetInMilliseconds-YhD8rIEs.js","assets/button-Ccc9Dc-D.js","assets/RepositoryScopeSelector-D-RCaknl.js","assets/project-repositories-DYhTvwQ1.js","assets/provider-capabilities-B-wOHfLP.js","assets/InteractiveJobComposer-wBBBNaJn.js","assets/brain-DI9lHkKY.js","assets/lib-C7Mhm-gT.js","assets/job-time-BCL7wee9.js","assets/LoopPreviewModal-DqHiG4Dt.js","assets/TemplatePreviewModal-COHFkUS4.js","assets/AgentModeCodePane-D_Xcq5t5.js","assets/AgentModeJobsPane-CDSkOuNP.js","assets/format-command-C0D9IPmV.js","assets/AgentModeAnalyticsPane-PEZKjyZS.js","assets/dist-js-CJ_2XX1Y.js","assets/ProjectSettingsDialog-CVTj4VLt.js","assets/AgentBrowserCapture-C_WpXceT.js","assets/JobDetailPage-_rIDpNfo.js","assets/ReviewPacketPage-BBd617OM.js","assets/RepositoryDeliveries-IiQCcndQ.js","assets/JobsPage-C6xcijbs.js","assets/ExportDropdown-ophapHrT.js","assets/AnalyticsPage-C6ZZI_zg.js","assets/BarChart-nBOMNfiy.js","assets/value-s-gzBeyF.js","assets/ActivityFeedPage-C7XJ5-bJ.js","assets/AgentsPage-D577NzIM.js","assets/CodePage-B5z5oLnP.js","assets/IntegrationsPage-Bhy58lnQ.js","assets/PluginsPage-Dn2jPvJL.js","assets/DesktopAnalyticsPage-D_V9RuGg.js","assets/DocsPage-BkE4m4wp.js","assets/atom-one-dark-qiGhVQxg.js","assets/atom-one-dark-B-oHczHB.css","assets/DocsDialog-Beg82MEe.js","assets/LoopsPage-B-ketPET.js","assets/upload-DYMjAQ6M.js","assets/LoopBuilderPage-A-Mt6EjT.js","assets/LoopBuilderPage-DtxX27Jz.css"])))=>i.map(i=>d[i]);
2
+ import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-CNC7AqOf.js";import{n as a,t as o}from"./jsx-runtime-zu2_FqZY.js";import{t as s}from"./react-dom-DiWzBDP9.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{a as l,c as u,f as d,i as f,l as p,o as m,r as h,s as g,t as _,u as v}from"./chunk-KS7C4IRE-DEKu087k.js";import{$ as y,A as b,B as x,C as S,D as C,E as w,F as T,H as E,I as D,J as O,L as k,M as A,N as j,O as M,P as N,Q as P,R as F,S as I,T as L,U as R,V as z,X as B,Y as ee,Z as V,_ as H,a as te,at as ne,b as re,c as ie,ct as ae,dt as oe,et as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,lt as me,n as he,nt as ge,o as _e,ot as ve,p as ye,q as U,r as be,rt as xe,s as Se,st as Ce,t as W,tt as we,ut as Te,v as Ee,w as De,x as Oe,y as ke,z as Ae}from"./TicketDetailModalContext-BNa1mdXq.js";import{C as je,O as Me,S as Ne,T as Pe,_ as Fe,a as Ie,b as Le,d as Re,f as ze,g as Be,h as G,i as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,t as Ye,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./useSharedWebSocket-BOdS5_Iz.js";import{t as tt}from"./Trans-SnMX4MhW.js";import{n as K,t as q}from"./createLucideIcon-Bjbbp_KS.js";import{a as nt,n as rt,o as it,r as at,s as J,t as ot}from"./useDesktop-RSMTyy7V.js";import{a as Y,n as st,r as ct,t as lt}from"./core-B3mKBIh5.js";import{C as ut,D as dt,E as ft,O as pt,S as mt,T as ht,_ as gt,a as _t,b as vt,c as yt,d as bt,f as xt,g as St,h as Ct,i as wt,l as Tt,m as Et,n as Dt,o as Ot,p as kt,r as At,s as jt,t as Mt,u as Nt,v as Pt,w as Ft,x as It,y as Lt}from"./RepositoryDeliveries-IiQCcndQ.js";import{n as Rt,t as zt}from"./save-B6wGWwBR.js";import{a as Bt,c as Vt,d as Ht,f as Ut,i as Wt,l as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./MinimizedChatsContext-Deg39peL.js";import{n as Qt,t as $t}from"./file-text-BcLCfcWZ.js";import{t as en}from"./circle-x-CMYsN4ZH.js";import{t as tn}from"./download-CFHyyHcw.js";import{t as nn}from"./git-branch-BRM0F5GN.js";import{t as rn}from"./loader-circle-DcygOQpC.js";import{t as an}from"./pencil-C9RkrIPZ.js";import{n as on,t as sn}from"./square-Ci-PFcFe.js";import{t as cn}from"./plus-CsnjfkmX.js";import{t as ln}from"./search-Cq_gE3Ik.js";import{t as un}from"./sparkles-DrY8hb0X.js";import{t as dn}from"./trash-2-BOU3WdZZ.js";import{t as fn}from"./triangle-alert-H9T4jAmh.js";import{n as pn}from"./jira-api-CSCqGr-Q.js";import{t as mn}from"./x-CBMI9ejn.js";import{t as hn}from"./zap-CHo3aCD1.js";import{A as gn,C as _n,D as vn,E as yn,M as bn,O as xn,S as Sn,T as Cn,_ as wn,a as Tn,b as En,c as Dn,d as On,f as kn,g as An,h as jn,i as Mn,j as Nn,k as Pn,l as Fn,m as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un,v as Wn,w as Gn,x as Kn,y as qn}from"./dialog-xXB2q5HJ.js";import{t as X}from"./utils-BC4DHlz2.js";import{n as Jn,t as Yn}from"./lib-CGdyxIWg.js";import{t as Xn}from"./getTimezoneOffsetInMilliseconds-YhD8rIEs.js";import{t as Zn}from"./formatDistanceToNow-DSj5DprF.js";import{n as Qn,t as Z}from"./button-Ccc9Dc-D.js";import{n as $n,t as er}from"./project-repositories-DYhTvwQ1.js";import{t as tr}from"./RepositoryScopeSelector-D-RCaknl.js";import{a as nr,c as rr,d as ir,f as ar,l as or,n as sr,o as cr,p as lr,r as ur,s as dr,t as fr,u as pr}from"./provider-capabilities-B-wOHfLP.js";import{a as mr,n as hr,o as gr,r as _r,t as vr}from"./event-Bt7f3wXe.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var yr=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),br=i(((e,t)=>{t.exports=yr()})),xr=i((e=>{var t=br(),n=a(),r=s();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var s=!1,l=a.child;l;){if(l===n){s=!0,n=a,r=o;break}if(l===r){s=!0,r=a,n=o;break}l=l.sibling}if(!s){for(l=o.child;l;){if(l===n){s=!0,n=o,r=a;break}if(l===r){s=!0,r=o,n=a;break}l=l.sibling}if(!s)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},R=[],z=-1;function B(e){return{current:e}}function ee(e){0>z||(e.current=R[z],R[z]=null,z--)}function V(e,t){z++,R[z]=e.current,e.current=t}var H=B(null),te=B(null),ne=B(null),re=B(null);function ie(e,t){switch(V(ne,t),V(te,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ee(H),V(H,e)}function ae(){ee(H),ee(te),ee(ne)}function oe(e){e.memoizedState!==null&&V(re,e);var t=H.current,n=Hd(t,e.type);t!==n&&(V(te,e),V(H,n))}function se(e){te.current===e&&(ee(H),ee(te)),re.current===e&&(ee(re),Qf._currentValue=L)}var ce,le;function ue(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,le=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+ce+e+le}var de=!1;function fe(e,t){if(!e||de)return``;de=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{de=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ue(n):``}function pe(e,t){switch(e.tag){case 26:case 27:case 5:return ue(e.type);case 16:return ue(`Lazy`);case 13:return e.child!==t&&t!==null?ue(`Suspense Fallback`):ue(`Suspense`);case 19:return ue(`SuspenseList`);case 0:case 15:return fe(e.type,!1);case 11:return fe(e.type.render,!1);case 1:return fe(e.type,!0);case 31:return ue(`Activity`);default:return``}}function me(e){try{var t=``,n=null;do t+=pe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var he=Object.prototype.hasOwnProperty,ge=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,ve=t.unstable_shouldYield,ye=t.unstable_requestPaint,U=t.unstable_now,be=t.unstable_getCurrentPriorityLevel,xe=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,Ce=t.unstable_NormalPriority,W=t.unstable_LowPriority,we=t.unstable_IdlePriority,Te=t.log,Ee=t.unstable_setDisableYieldValue,De=null,Oe=null;function ke(e){if(typeof Te==`function`&&Ee(e),Oe&&typeof Oe.setStrictMode==`function`)try{Oe.setStrictMode(De,e)}catch{}}var Ae=Math.clz32?Math.clz32:Ne,je=Math.log,Me=Math.LN2;function Ne(e){return e>>>=0,e===0?32:31-(je(e)/Me|0)|0}var Pe=256,Fe=262144,Ie=4194304;function Le(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Re(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Le(n))):i=Le(o):i=Le(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Le(n))):i=Le(o)):i=Le(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Be(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function G(){var e=Ie;return Ie<<=1,!(Ie&62914560)&&(Ie=4194304),e}function Ve(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function He(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ue(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ae(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&We(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function We(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ae(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ae(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ke(e,t){var n=t&-t;return n=n&42?1:qe(n),(n&(e.suspendedLanes|t))===0?n:0}function qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=I.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function Xe(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,K=`__reactListeners$`+Ze,q=`__reactHandles$`+Ze,nt=`__reactResources$`+Ze,rt=`__reactMarker$`+Ze;function it(e){delete e[Qe],delete e[$e],delete e[tt],delete e[K],delete e[q]}function at(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[Qe])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function J(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ot(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Y(e){var t=e[nt];return t||=e[nt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function st(e){e[rt]=!0}var ct=new Set,lt={};function ut(e,t){dt(e,t),dt(e+`Capture`,t)}function dt(e,t){for(lt[e]=t,e=0;e<t.length;e++)ct.add(t[e])}var ft=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),pt={},mt={};function ht(e){return he.call(mt,e)?!0:he.call(pt,e)?!1:ft.test(e)?mt[e]=!0:(pt[e]=!0,!1)}function gt(e,t,n){if(ht(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function _t(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function vt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function yt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function bt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function xt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function St(e){if(!e._valueTracker){var t=bt(e)?`checked`:`value`;e._valueTracker=xt(e,t,``+e[t])}}function Ct(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=bt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function wt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Tt=/[\n"\\]/g;function Et(e){return e.replace(Tt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Dt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+yt(t)):e.value!==``+yt(t)&&(e.value=``+yt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):kt(e,o,yt(n)):kt(e,o,yt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+yt(s):e.removeAttribute(`name`)}function Ot(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){St(e);return}n=n==null?``:``+yt(n),t=t==null?n:``+yt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),St(e)}function kt(e,t,n){t===`number`&&wt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function At(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+yt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function jt(e,t,n){if(t!=null&&(t=``+yt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+yt(n)}function Mt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(P(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=yt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),St(e)}function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Ft(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Pt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function It(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Ft(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Ft(e,o,t[o])}function Lt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Rt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),zt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Bt(e){return zt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Vt(){}var Ht=null;function Ut(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wt=null,Gt=null;function Kt(e){var t=J(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Dt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Et(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));Dt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ct(r)}break a;case`textarea`:jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&At(e,!!n.multiple,t,!1)}}}var qt=!1;function Jt(e,t,n){if(qt)return e(t,n);qt=!0;try{return e(t)}finally{if(qt=!1,(Wt!==null||Gt!==null)&&(_u(),Wt&&(t=Wt,e=Gt,Gt=Wt=null,Kt(t),e)))for(t=0;t<e.length;t++)Kt(e[t])}}function Yt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Xt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Zt=!1;if(Xt)try{var Qt={};Object.defineProperty(Qt,"passive",{get:function(){Zt=!0}}),window.addEventListener(`test`,Qt,Qt),window.removeEventListener(`test`,Qt,Qt)}catch{Zt=!1}var $t=null,en=null,tn=null;function nn(){if(tn)return tn;var e,t=en,n=t.length,r,i=`value`in $t?$t.value:$t.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return tn=i.slice(e,1<r?1-r:void 0)}function rn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function an(){return!0}function on(){return!1}function sn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?an:on,this.isPropagationStopped=on,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=an)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=an)},persist:function(){},isPersistent:an}),t}var cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ln=sn(cn),un=m({},cn,{view:0,detail:0}),dn=sn(un),fn,pn,mn,hn=m({},un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:En,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==mn&&(mn&&e.type===`mousemove`?(fn=e.screenX-mn.screenX,pn=e.screenY-mn.screenY):pn=fn=0,mn=e),fn)},movementY:function(e){return`movementY`in e?e.movementY:pn}}),gn=sn(hn),_n=sn(m({},hn,{dataTransfer:0})),vn=sn(m({},un,{relatedTarget:0})),yn=sn(m({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=sn(m({},cn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),xn=sn(m({},cn,{data:0})),Sn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Cn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},wn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Tn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=wn[e])?!!t[e]:!1}function En(){return Tn}var Dn=sn(m({},un,{key:function(e){if(e.key){var t=Sn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=rn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Cn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:En,charCode:function(e){return e.type===`keypress`?rn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?rn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),On=sn(m({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),kn=sn(m({},un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:En})),An=sn(m({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),jn=sn(m({},hn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Mn=sn(m({},cn,{newState:0,oldState:0})),Nn=[9,13,27,32],Pn=Xt&&`CompositionEvent`in window,Fn=null;Xt&&`documentMode`in document&&(Fn=document.documentMode);var In=Xt&&`TextEvent`in window&&!Fn,Ln=Xt&&(!Pn||Fn&&8<Fn&&11>=Fn),Rn=` `,zn=!1;function Bn(e,t){switch(e){case`keyup`:return Nn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Vn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Hn=!1;function Un(e,t){switch(e){case`compositionend`:return Vn(t);case`keypress`:return t.which===32?(zn=!0,Rn):null;case`textInput`:return e=t.data,e===Rn&&zn?null:e;default:return null}}function Wn(e,t){if(Hn)return e===`compositionend`||!Pn&&Bn(e,t)?(e=nn(),tn=en=$t=null,Hn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Ln&&t.locale!==`ko`?null:t.data;default:return null}}var Gn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Gn[e.type]:t===`textarea`}function qn(e,t,n,r){Wt?Gt?Gt.push(r):Gt=[r]:Wt=r,t=Td(t,`onChange`),0<t.length&&(n=new ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var X=null,Jn=null;function Yn(e){_d(e,0)}function Xn(e){if(Ct(ot(e)))return e}function Zn(e,t){if(e===`change`)return t}var Qn=!1;if(Xt){var Z;if(Xt){var $n=`oninput`in document;if(!$n){var er=document.createElement(`div`);er.setAttribute(`oninput`,`return;`),$n=typeof er.oninput==`function`}Z=$n}else Z=!1;Qn=Z&&(!document.documentMode||9<document.documentMode)}function tr(){X&&(X.detachEvent(`onpropertychange`,nr),Jn=X=null)}function nr(e){if(e.propertyName===`value`&&Xn(Jn)){var t=[];qn(t,Jn,e,Ut(e)),Jt(Yn,t)}}function rr(e,t,n){e===`focusin`?(tr(),X=t,Jn=n,X.attachEvent(`onpropertychange`,nr)):e===`focusout`&&tr()}function ir(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Xn(Jn)}function ar(e,t){if(e===`click`)return Xn(t)}function or(e,t){if(e===`input`||e===`change`)return Xn(t)}function sr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var cr=typeof Object.is==`function`?Object.is:sr;function lr(e,t){if(cr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!he.call(t,i)||!cr(e[i],t[i]))return!1}return!0}function ur(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function dr(e,t){var n=ur(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=ur(n)}}function fr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?fr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function pr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=wt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=wt(e.document)}return t}function mr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var hr=Xt&&`documentMode`in document&&11>=document.documentMode,gr=null,_r=null,vr=null,yr=!1;function xr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;yr||gr==null||gr!==wt(r)||(r=gr,`selectionStart`in r&&mr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),vr&&lr(vr,r)||(vr=r,r=Td(_r,`onSelect`),0<r.length&&(t=new ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=gr)))}function Sr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Q={animationend:Sr(`Animation`,`AnimationEnd`),animationiteration:Sr(`Animation`,`AnimationIteration`),animationstart:Sr(`Animation`,`AnimationStart`),transitionrun:Sr(`Transition`,`TransitionRun`),transitionstart:Sr(`Transition`,`TransitionStart`),transitioncancel:Sr(`Transition`,`TransitionCancel`),transitionend:Sr(`Transition`,`TransitionEnd`)},Cr={},wr={};Xt&&(wr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Q.animationend.animation,delete Q.animationiteration.animation,delete Q.animationstart.animation),`TransitionEvent`in window||delete Q.transitionend.transition);function Tr(e){if(Cr[e])return Cr[e];if(!Q[e])return e;var t=Q[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in wr)return Cr[e]=t[n];return e}var Er=Tr(`animationend`),Dr=Tr(`animationiteration`),Or=Tr(`animationstart`),kr=Tr(`transitionrun`),Ar=Tr(`transitionstart`),jr=Tr(`transitioncancel`),Mr=Tr(`transitionend`),Nr=new Map,Pr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Pr.push(`scrollEnd`);function Fr(e,t){Nr.set(e,t),ut(t,[e])}var Ir=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Lr=[],Rr=0,zr=0;function Br(){for(var e=Rr,t=zr=Rr=0;t<e;){var n=Lr[t];Lr[t++]=null;var r=Lr[t];Lr[t++]=null;var i=Lr[t];Lr[t++]=null;var a=Lr[t];if(Lr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Wr(n,i,a)}}function Vr(e,t,n,r){Lr[Rr++]=e,Lr[Rr++]=t,Lr[Rr++]=n,Lr[Rr++]=r,zr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Hr(e,t,n,r){return Vr(e,t,n,r),Gr(e)}function Ur(e,t){return Vr(e,null,null,t),Gr(e)}function Wr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ae(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Gr(e){if(50<cu)throw cu=0,lu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Kr={};function qr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jr(e,t,n,r){return new qr(e,t,n,r)}function Yr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Xr(e,t){var n=e.alternate;return n===null?(n=Jr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Zr(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Qr(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Yr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,H.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case O:return e=Jr(31,n,t,a),e.elementType=O,e.lanes=o,e;case v:return $r(n.children,a,o,t);case y:s=8,a|=24;break;case b:return e=Jr(12,n,t,a|2),e.elementType=b,e.lanes=o,e;case w:return e=Jr(13,n,t,a),e.elementType=w,e.lanes=o,e;case T:return e=Jr(19,n,t,a),e.elementType=T,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case S:s=10;break a;case x:s=9;break a;case C:s=11;break a;case E:s=14;break a;case D:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Jr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function $r(e,t,n,r){return e=Jr(7,e,r,t),e.lanes=n,e}function ei(e,t,n){return e=Jr(6,e,null,t),e.lanes=n,e}function ti(e){var t=Jr(18,null,null,0);return t.stateNode=e,t}function ni(e,t,n){return t=Jr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ri=new WeakMap;function $(e,t){if(typeof e==`object`&&e){var n=ri.get(e);return n===void 0?(t={value:e,source:t,stack:me(t)},ri.set(e,t),t):n}return{value:e,source:t,stack:me(t)}}var ii=[],ai=0,oi=null,si=0,ci=[],li=0,ui=null,di=1,fi=``;function pi(e,t){ii[ai++]=si,ii[ai++]=oi,oi=e,si=t}function mi(e,t,n){ci[li++]=di,ci[li++]=fi,ci[li++]=ui,ui=e;var r=di;e=fi;var i=32-Ae(r)-1;r&=~(1<<i),n+=1;var a=32-Ae(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,di=1<<32-Ae(t)+i|n<<i|r,fi=a+e}else di=1<<a|n<<i|r,fi=e}function hi(e){e.return!==null&&(pi(e,1),mi(e,1,0))}function gi(e){for(;e===oi;)oi=ii[--ai],ii[ai]=null,si=ii[--ai],ii[ai]=null;for(;e===ui;)ui=ci[--li],ci[li]=null,fi=ci[--li],ci[li]=null,di=ci[--li],ci[li]=null}function _i(e,t){ci[li++]=di,ci[li++]=fi,ci[li++]=ui,di=t.id,fi=t.overflow,ui=e}var vi=null,yi=null,bi=!1,xi=null,Si=!1,Ci=Error(i(519));function wi(e){throw Ai($(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ci}function Ti(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:vd(`cancel`,t),vd(`close`,t);break;case`iframe`:case`object`:case`embed`:vd(`load`,t);break;case`video`:case`audio`:for(n=0;n<hd.length;n++)vd(hd[n],t);break;case`source`:vd(`error`,t);break;case`img`:case`image`:case`link`:vd(`error`,t),vd(`load`,t);break;case`details`:vd(`toggle`,t);break;case`input`:vd(`invalid`,t),Ot(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:vd(`invalid`,t);break;case`textarea`:vd(`invalid`,t),Mt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||jd(t.textContent,n)?(r.popover!=null&&(vd(`beforetoggle`,t),vd(`toggle`,t)),r.onScroll!=null&&vd(`scroll`,t),r.onScrollEnd!=null&&vd(`scrollend`,t),r.onClick!=null&&(t.onclick=Vt),t=!0):t=!1,t||wi(e,!0)}function Ei(e){for(vi=e.return;vi;)switch(vi.tag){case 5:case 31:case 13:Si=!1;return;case 27:case 3:Si=!0;return;default:vi=vi.return}}function Di(e){if(e!==vi)return!1;if(!bi)return Ei(e),bi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&yi&&wi(e),Ei(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));yi=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));yi=uf(e)}else t===27?(t=yi,Zd(e.type)?(e=lf,lf=null,yi=e):yi=t):yi=vi?cf(e.stateNode.nextSibling):null;return!0}function Oi(){yi=vi=null,bi=!1}function ki(){var e=xi;return e!==null&&(Jl===null?Jl=e:Jl.push.apply(Jl,e),xi=null),e}function Ai(e){xi===null?xi=[e]:xi.push(e)}var ji=B(null),Mi=null,Ni=null;function Pi(e,t,n){V(ji,t._currentValue),t._currentValue=n}function Fi(e){e._currentValue=ji.current,ee(ji)}function Ii(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Li(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ii(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ii(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Ri(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;cr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===re.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&Li(t,e,n,r),t.flags|=262144}function zi(e){for(e=e.firstContext;e!==null;){if(!cr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Bi(e){Mi=e,Ni=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Vi(e){return Ui(Mi,e)}function Hi(e,t){return Mi===null&&Bi(e),Ui(e,t)}function Ui(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ni===null){if(e===null)throw Error(i(308));Ni=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ni=Ni.next=t;return n}var Wi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Gi=t.unstable_scheduleCallback,Ki=t.unstable_NormalPriority,qi={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ji(){return{controller:new Wi,data:new Map,refCount:0}}function Yi(e){e.refCount--,e.refCount===0&&Gi(Ki,function(){e.controller.abort()})}var Xi=null,Zi=0,Qi=0,$i=null;function ea(e,t){if(Xi===null){var n=Xi=[];Zi=0,Qi=ld(),$i={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Zi++,t.then(ta,ta),t}function ta(){if(--Zi===0&&Xi!==null){$i!==null&&($i.status=`fulfilled`);var e=Xi;Xi=null,Qi=0,$i=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function na(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ra=F.S;F.S=function(e,t){Zl=U(),typeof t==`object`&&t&&typeof t.then==`function`&&ea(e,t),ra!==null&&ra(e,t)};var ia=B(null);function aa(){var e=ia.current;return e===null?Ml.pooledCache:e}function oa(e,t){t===null?V(ia,ia.current):V(ia,t.pool)}function sa(){var e=aa();return e===null?null:{parent:qi._currentValue,pool:e}}var ca=Error(i(460)),la=Error(i(474)),ua=Error(i(542)),da={then:function(){}};function fa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function pa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Vt,Vt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,_a(e),e;default:if(typeof t.status==`string`)t.then(Vt,Vt);else{if(e=Ml,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,_a(e),e}throw ha=t,ca}}function ma(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ha=e,ca):e}}var ha=null;function ga(){if(ha===null)throw Error(i(459));var e=ha;return ha=null,e}function _a(e){if(e===ca||e===ua)throw Error(i(483))}var va=null,ya=0;function ba(e){var t=ya;return ya+=1,va===null&&(va=[]),pa(va,e,t)}function xa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Sa(e,t){throw t.$$typeof===h?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ca(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Xr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ei(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===v?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===D&&ma(i)===t.type)?(t=a(t,n.props),xa(t,n),t.return=e,t):(t=Qr(n.type,n.key,n.props,null,e.mode,r),xa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ni(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=$r(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ei(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=Qr(t.type,t.key,t.props,null,e.mode,n),xa(n,t),n.return=e,n;case _:return t=ni(t,e.mode,n),t.return=e,t;case D:return t=ma(t),f(e,t,n)}if(P(t)||j(t))return t=$r(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,ba(t),n);if(t.$$typeof===S)return f(e,Hi(e,t),n);Sa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case g:return n.key===i?l(e,t,n,r):null;case _:return n.key===i?u(e,t,n,r):null;case D:return n=ma(n),p(e,t,n,r)}if(P(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,ba(n),r);if(n.$$typeof===S)return p(e,t,Hi(e,n),r);Sa(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case _:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case D:return r=ma(r),m(e,t,n,r,i)}if(P(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,ba(r),i);if(r.$$typeof===S)return m(e,t,n,Hi(t,r),i);Sa(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),bi&&pi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return bi&&pi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),bi&&pi(i,h),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),bi&&pi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return bi&&pi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),bi&&pi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===v&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case g:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===v){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===D&&ma(l)===r.type){n(e,r.sibling),c=a(r,o.props),xa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===v?(c=$r(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=Qr(o.type,o.key,o.props,null,e.mode,c),xa(c,o),c.return=e,e=c)}return s(e);case _:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ni(o,e.mode,c),c.return=e,e=c}return s(e);case D:return o=ma(o),b(e,r,o,c)}if(P(o))return h(e,r,o,c);if(j(o)){if(l=j(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,ba(o),c);if(o.$$typeof===S)return b(e,r,Hi(e,o),c);Sa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ei(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ya=0;var i=b(e,t,n,r);return va=null,i}catch(t){if(t===ca||t===ua)throw t;var a=Jr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var wa=Ca(!0),Ta=Ca(!1),Ea=!1;function Da(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Oa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Aa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,jl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Gr(e),Wr(e,null,n),t}return Vr(e,r,t,n),Gr(e)}function ja(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}function Ma(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Na=!1;function Pa(){if(Na){var e=$i;if(e!==null)throw e}}function Fa(e,t,n,r){Na=!1;var i=e.updateQueue;Ea=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Pl&f)===f:(r&f)===f){f!==0&&f===Qi&&(Na=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Ea=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Hl|=o,e.lanes=o,e.memoizedState=d}}function Ia(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function La(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ia(n[e],t)}var Ra=B(null),za=B(0);function Ba(e,t){e=Bl,V(za,e),V(Ra,t),Bl=e|t.baseLanes}function Va(){V(za,Bl),V(Ra,Ra.current)}function Ha(){Bl=za.current,ee(Ra),ee(za)}var Ua=B(null),Wa=null;function Ga(e){var t=e.alternate;V(Xa,Xa.current&1),V(Ua,e),Wa===null&&(t===null||Ra.current!==null||t.memoizedState!==null)&&(Wa=e)}function Ka(e){V(Xa,Xa.current),V(Ua,e),Wa===null&&(Wa=e)}function qa(e){e.tag===22?(V(Xa,Xa.current),V(Ua,e),Wa===null&&(Wa=e)):Ja(e)}function Ja(){V(Xa,Xa.current),V(Ua,Ua.current)}function Ya(e){ee(Ua),Wa===e&&(Wa=null),ee(Xa)}var Xa=B(0);function Za(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Qa=0,$a=null,eo=null,to=null,no=!1,ro=!1,io=!1,ao=0,oo=0,so=null,co=0;function lo(){throw Error(i(321))}function uo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!cr(e[n],t[n]))return!1;return!0}function fo(e,t,n,r,i,a){return Qa=a,$a=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,F.H=e===null||e.memoizedState===null?ks:As,io=!1,a=n(r,i),io=!1,ro&&(a=mo(t,n,r,i)),po(e),a}function po(e){F.H=Os;var t=eo!==null&&eo.next!==null;if(Qa=0,to=eo=$a=null,no=!1,oo=0,so=null,t)throw Error(i(300));e===null||qs||(e=e.dependencies,e!==null&&zi(e)&&(qs=!0))}function mo(e,t,n,r){$a=e;var a=0;do{if(ro&&(so=null),oo=0,ro=!1,25<=a)throw Error(i(301));if(a+=1,to=eo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}F.H=js,o=t(n,r)}while(ro);return o}function ho(){var e=F.H,t=e.useState()[0];return t=typeof t.then==`function`?So(t):t,e=e.useState()[0],(eo===null?null:eo.memoizedState)!==e&&($a.flags|=1024),t}function go(){var e=ao!==0;return ao=0,e}function _o(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function vo(e){if(no){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}no=!1}Qa=0,to=eo=$a=null,ro=!1,oo=ao=0,so=null}function yo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return to===null?$a.memoizedState=to=e:to=to.next=e,to}function bo(){if(eo===null){var e=$a.alternate;e=e===null?null:e.memoizedState}else e=eo.next;var t=to===null?$a.memoizedState:to.next;if(t!==null)to=t,eo=e;else{if(e===null)throw $a.alternate===null?Error(i(467)):Error(i(310));eo=e,e={memoizedState:eo.memoizedState,baseState:eo.baseState,baseQueue:eo.baseQueue,queue:eo.queue,next:null},to===null?$a.memoizedState=to=e:to=to.next=e}return to}function xo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function So(e){var t=oo;return oo+=1,so===null&&(so=[]),e=pa(so,e,t),t=$a,(to===null?t.memoizedState:to.next)===null&&(t=t.alternate,F.H=t===null||t.memoizedState===null?ks:As),e}function Co(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return So(e);if(e.$$typeof===S)return Vi(e)}throw Error(i(438,String(e)))}function wo(e){var t=null,n=$a.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=$a.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=xo(),$a.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=k;return t.index++,n}function To(e,t){return typeof t==`function`?t(e):t}function Eo(e){return Do(bo(),eo,e)}function Do(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Qa&f)===f:(Pl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Qi&&(d=!0);else if((Qa&p)===p){u=u.next,p===Qi&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,$a.lanes|=p,Hl|=p;f=u.action,io&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,$a.lanes|=f,Hl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!cr(o,e.memoizedState)&&(qs=!0,d&&(n=$i,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Oo(e){var t=bo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);cr(o,t.memoizedState)||(qs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function ko(e,t,n){var r=$a,a=bo(),o=bi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!cr((eo||a).memoizedState,n);if(s&&(a.memoizedState=n,qs=!0),a=a.queue,es(Mo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||to!==null&&to.memoizedState.tag&1){if(r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,a,n,t),null),Ml===null)throw Error(i(349));o||Qa&127||Ao(r,t,n)}return n}function Ao(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=$a.updateQueue,t===null?(t=xo(),$a.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function jo(e,t,n,r){t.value=n,t.getSnapshot=r,No(t)&&Po(e)}function Mo(e,t,n){return n(function(){No(t)&&Po(e)})}function No(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!cr(e,n)}catch{return!0}}function Po(e){var t=Ur(e,2);t!==null&&fu(t,e,2)}function Fo(e){var t=yo();if(typeof e==`function`){var n=e;if(e=n(),io){ke(!0);try{n()}finally{ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:e},t}function Io(e,t,n,r){return e.baseState=n,Do(e,eo,typeof r==`function`?r:To)}function Lo(e,t,n,r,a){if(Ts(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};F.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ro(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ro(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=F.T,o={};F.T=o;try{var s=n(i,r),c=F.S;c!==null&&c(o,s),zo(e,t,s)}catch(n){Vo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),F.T=a}}else try{a=n(i,r),zo(e,t,a)}catch(n){Vo(e,t,n)}}function zo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Bo(e,t,n)},function(n){return Vo(e,t,n)}):Bo(e,t,n)}function Bo(e,t,n){t.status=`fulfilled`,t.value=n,Ho(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ro(e,n)))}function Vo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ho(t),t=t.next;while(t!==r)}e.action=null}function Ho(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Uo(e,t){return t}function Wo(e,t){if(bi){var n=Ml.formState;if(n!==null){a:{var r=$a;if(bi){if(yi){b:{for(var i=yi,a=Si;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){yi=cf(i.nextSibling),r=i.data===`F!`;break a}}wi(r)}r=!1}r&&(t=n[0])}}return n=yo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:t},n.queue=r,n=Ss.bind(null,$a,r),r.dispatch=n,r=Fo(!1),a=ws.bind(null,$a,!1,r.queue),r=yo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Lo.bind(null,$a,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Go(e){return Ko(bo(),eo,e)}function Ko(e,t,n){if(t=Do(e,t,Uo)[0],e=Eo(To)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=So(t)}catch(e){throw e===ca?ua:e}else r=t;t=bo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&($a.flags|=2048,Yo(9,{destroy:void 0},qo.bind(null,i,n),null)),[r,a,e]}function qo(e,t){e.action=t}function Jo(e){var t=bo(),n=eo;if(n!==null)return Ko(t,n,e);bo(),t=t.memoizedState,n=bo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Yo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=$a.updateQueue,t===null&&(t=xo(),$a.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Xo(){return bo().memoizedState}function Zo(e,t,n,r){var i=yo();$a.flags|=e,i.memoizedState=Yo(1|t,{destroy:void 0},n,r===void 0?null:r)}function Qo(e,t,n,r){var i=bo();r=r===void 0?null:r;var a=i.memoizedState.inst;eo!==null&&r!==null&&uo(r,eo.memoizedState.deps)?i.memoizedState=Yo(t,a,n,r):($a.flags|=e,i.memoizedState=Yo(1|t,a,n,r))}function $o(e,t){Zo(8390656,8,e,t)}function es(e,t){Qo(2048,8,e,t)}function ts(e){$a.flags|=4;var t=$a.updateQueue;if(t===null)t=xo(),$a.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ns(e){var t=bo().memoizedState;return ts({ref:t,nextImpl:e}),function(){if(jl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function rs(e,t){return Qo(4,2,e,t)}function is(e,t){return Qo(4,4,e,t)}function as(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function os(e,t,n){n=n==null?null:n.concat([e]),Qo(4,4,as.bind(null,t,e),n)}function ss(){}function cs(e,t){var n=bo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&uo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ls(e,t){var n=bo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&uo(t,r[1]))return r[0];if(r=e(),io){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r}function us(e,t,n){return n===void 0||Qa&1073741824&&!(Pl&261930)?e.memoizedState=t:(e.memoizedState=n,e=du(),$a.lanes|=e,Hl|=e,n)}function ds(e,t,n,r){return cr(n,t)?n:Ra.current===null?!(Qa&42)||Qa&1073741824&&!(Pl&261930)?(qs=!0,e.memoizedState=n):(e=du(),$a.lanes|=e,Hl|=e,t):(e=us(e,n,r),cr(e,t)||(qs=!0),e)}function fs(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,ws(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Cs(e,t,na(c,r),uu(e)):Cs(e,t,r,uu(e))}catch(n){Cs(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function ps(){}function ms(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=hs(e).queue;fs(e,a,t,L,n===null?ps:function(){return gs(e),n(r)})}function hs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:L},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function gs(e){var t=hs(e);t.next===null&&(t=e.alternate.memoizedState),Cs(e,t.next.queue,{},uu())}function _s(){return Vi(Qf)}function vs(){return bo().memoizedState}function ys(){return bo().memoizedState}function bs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=ka(n);var r=Aa(t,e,n);r!==null&&(fu(r,t,n),ja(r,t,n)),t={cache:Ji()},e.payload=t;return}t=t.return}}function xs(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ts(e)?Es(t,n):(n=Hr(e,t,n,r),n!==null&&(fu(n,e,r),Ds(n,t,r)))}function Ss(e,t,n){Cs(e,t,n,uu())}function Cs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ts(e))Es(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,cr(s,o))return Vr(e,t,i,0),Ml===null&&Br(),!1}catch{}if(n=Hr(e,t,i,r),n!==null)return fu(n,e,r),Ds(n,t,r),!0}return!1}function ws(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ts(e)){if(t)throw Error(i(479))}else t=Hr(e,n,r,2),t!==null&&fu(t,e,2)}function Ts(e){var t=e.alternate;return e===$a||t!==null&&t===$a}function Es(e,t){ro=no=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ds(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}var Os={readContext:Vi,use:Co,useCallback:lo,useContext:lo,useEffect:lo,useImperativeHandle:lo,useLayoutEffect:lo,useInsertionEffect:lo,useMemo:lo,useReducer:lo,useRef:lo,useState:lo,useDebugValue:lo,useDeferredValue:lo,useTransition:lo,useSyncExternalStore:lo,useId:lo,useHostTransitionStatus:lo,useFormState:lo,useActionState:lo,useOptimistic:lo,useMemoCache:lo,useCacheRefresh:lo};Os.useEffectEvent=lo;var ks={readContext:Vi,use:Co,useCallback:function(e,t){return yo().memoizedState=[e,t===void 0?null:t],e},useContext:Vi,useEffect:$o,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Zo(4194308,4,as.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){Zo(4,2,e,t)},useMemo:function(e,t){var n=yo();t=t===void 0?null:t;var r=e();if(io){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=yo();if(n!==void 0){var i=n(t);if(io){ke(!0);try{n(t)}finally{ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=xs.bind(null,$a,e),[r.memoizedState,e]},useRef:function(e){var t=yo();return e={current:e},t.memoizedState=e},useState:function(e){e=Fo(e);var t=e.queue,n=Ss.bind(null,$a,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ss,useDeferredValue:function(e,t){return us(yo(),e,t)},useTransition:function(){var e=Fo(!1);return e=fs.bind(null,$a,e.queue,!0,!1),yo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=$a,a=yo();if(bi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ml===null)throw Error(i(349));Pl&127||Ao(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,$o(Mo.bind(null,r,o,e),[e]),r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,o,n,t),null),n},useId:function(){var e=yo(),t=Ml.identifierPrefix;if(bi){var n=fi,r=di;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ao++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=co++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:_s,useFormState:Wo,useActionState:Wo,useOptimistic:function(e){var t=yo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ws.bind(null,$a,!0,n),n.dispatch=t,[e,t]},useMemoCache:wo,useCacheRefresh:function(){return yo().memoizedState=bs.bind(null,$a)},useEffectEvent:function(e){var t=yo(),n={impl:e};return t.memoizedState=n,function(){if(jl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},As={readContext:Vi,use:Co,useCallback:cs,useContext:Vi,useEffect:es,useImperativeHandle:os,useInsertionEffect:rs,useLayoutEffect:is,useMemo:ls,useReducer:Eo,useRef:Xo,useState:function(){return Eo(To)},useDebugValue:ss,useDeferredValue:function(e,t){return ds(bo(),eo.memoizedState,e,t)},useTransition:function(){var e=Eo(To)[0],t=bo().memoizedState;return[typeof e==`boolean`?e:So(e),t]},useSyncExternalStore:ko,useId:vs,useHostTransitionStatus:_s,useFormState:Go,useActionState:Go,useOptimistic:function(e,t){return Io(bo(),eo,e,t)},useMemoCache:wo,useCacheRefresh:ys};As.useEffectEvent=ns;var js={readContext:Vi,use:Co,useCallback:cs,useContext:Vi,useEffect:es,useImperativeHandle:os,useInsertionEffect:rs,useLayoutEffect:is,useMemo:ls,useReducer:Oo,useRef:Xo,useState:function(){return Oo(To)},useDebugValue:ss,useDeferredValue:function(e,t){var n=bo();return eo===null?us(n,e,t):ds(n,eo.memoizedState,e,t)},useTransition:function(){var e=Oo(To)[0],t=bo().memoizedState;return[typeof e==`boolean`?e:So(e),t]},useSyncExternalStore:ko,useId:vs,useHostTransitionStatus:_s,useFormState:Jo,useActionState:Jo,useOptimistic:function(e,t){var n=bo();return eo===null?(n.baseState=e,[e,n.queue.dispatch]):Io(n,eo,e,t)},useMemoCache:wo,useCacheRefresh:ys};js.useEffectEvent=ns;function Ms(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ns={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=uu(),i=ka(r);i.payload=t,n!=null&&(i.callback=n),t=Aa(e,i,r),t!==null&&(fu(t,e,r),ja(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=uu(),i=ka(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Aa(e,i,r),t!==null&&(fu(t,e,r),ja(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=uu(),r=ka(n);r.tag=2,t!=null&&(r.callback=t),t=Aa(e,r,n),t!==null&&(fu(t,e,n),ja(t,e,n))}};function Ps(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!lr(n,r)||!lr(i,a):!0}function Fs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ns.enqueueReplaceState(t,t.state,null)}function Is(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ls(e){Ir(e)}function Rs(e){console.error(e)}function zs(e){Ir(e)}function Bs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Vs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Hs(e,t,n){return n=ka(n),n.tag=3,n.payload={element:null},n.callback=function(){Bs(e,t)},n}function Us(e){return e=ka(e),e.tag=3,e}function Ws(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Vs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Vs(t,n,r),typeof i!=`function`&&(eu===null?eu=new Set([this]):eu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Gs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ri(t,n,a,!0),n=Ua.current,n!==null){switch(n.tag){case 31:case 13:return Wa===null?wu():n.alternate===null&&Vl===0&&(Vl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===da?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Uu(e,r,a)),!1;case 22:return n.flags|=65536,r===da?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Uu(e,r,a)),!1}throw Error(i(435,n.tag))}return Uu(e,r,a),wu(),!1}if(bi)return t=Ua.current,t===null?(r!==Ci&&(t=Error(i(423),{cause:r}),Ai($(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=$(r,n),a=Hs(e.stateNode,r,a),Ma(e,a),Vl!==4&&(Vl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ci&&(e=Error(i(422),{cause:r}),Ai($(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=$(o,n),ql===null?ql=[o]:ql.push(o),Vl!==4&&(Vl=2),t===null)return!0;r=$(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Hs(n.stateNode,r,e),Ma(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(eu===null||!eu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Us(a),Ws(a,e,n,r),Ma(n,a),!1}n=n.return}while(n!==null);return!1}var Ks=Error(i(461)),qs=!1;function Js(e,t,n,r){t.child=e===null?Ta(t,null,n,r):wa(t,e.child,n,r)}function Ys(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Bi(t),r=fo(e,t,n,o,a,i),s=go(),e!==null&&!qs?(_o(e,t,i),yc(e,t,i)):(bi&&s&&hi(t),t.flags|=1,Js(e,t,r,i),t.child)}function Xs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Yr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Zs(e,t,a,r,i)):(e=Qr(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!bc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?lr:n,n(o,r)&&e.ref===t.ref)return yc(e,t,i)}return t.flags|=1,e=Xr(a,r),e.ref=t.ref,e.return=t,t.child=e}function Zs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(lr(a,r)&&e.ref===t.ref)if(qs=!1,t.pendingProps=r=a,bc(e,i))e.flags&131072&&(qs=!0);else return t.lanes=e.lanes,yc(e,t,i)}return ac(e,t,n,r,i)}function Qs(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return ec(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&oa(t,a===null?null:a.cachePool),a===null?Va():Ba(t,a),qa(t);else return r=t.lanes=536870912,ec(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&oa(t,null),Va(),Ja(t)):(oa(t,a.cachePool),Ba(t,a),Ja(t),t.memoizedState=null);return Js(e,t,i,n),t.child}function $s(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function ec(e,t,n,r,i){var a=aa();return a=a===null?null:{parent:qi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&oa(t,null),Va(),qa(t),e!==null&&Ri(e,t,r,!0),t.childLanes=i,null}function tc(e,t){return t=mc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function nc(e,t,n){return wa(t,e.child,null,n),e=tc(t,t.pendingProps),e.flags|=2,Ya(t),t.memoizedState=null,e}function rc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(bi){if(r.mode===`hidden`)return e=tc(t,r),t.lanes=536870912,$s(null,e);if(Ka(t),(e=yi)?(e=rf(e,Si),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ui===null?null:{id:di,overflow:fi},retryLane:536870912,hydrationErrors:null},n=ti(e),n.return=t,t.child=n,vi=t,yi=null)):e=null,e===null)throw wi(t);return t.lanes=536870912,null}return tc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ka(t),a)if(t.flags&256)t.flags&=-257,t=nc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(qs||Ri(e,t,n,!1),a=(n&e.childLanes)!==0,qs||a){if(r=Ml,r!==null&&(s=Ke(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Ur(e,s),fu(r,e,s),Ks;wu(),t=nc(e,t,n)}else e=o.treeContext,yi=cf(s.nextSibling),vi=t,bi=!0,xi=null,Si=!1,e!==null&&_i(t,e),t=tc(t,r),t.flags|=4096;return t}return e=Xr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ic(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function ac(e,t,n,r,i){return Bi(t),n=fo(e,t,n,r,void 0,i),r=go(),e!==null&&!qs?(_o(e,t,i),yc(e,t,i)):(bi&&r&&hi(t),t.flags|=1,Js(e,t,n,i),t.child)}function oc(e,t,n,r,i,a){return Bi(t),t.updateQueue=null,n=mo(t,r,n,i),po(e),r=go(),e!==null&&!qs?(_o(e,t,a),yc(e,t,a)):(bi&&r&&hi(t),t.flags|=1,Js(e,t,n,a),t.child)}function sc(e,t,n,r,i){if(Bi(t),t.stateNode===null){var a=Kr,o=n.contextType;typeof o==`object`&&o&&(a=Vi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ns,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Da(t),o=n.contextType,a.context=typeof o==`object`&&o?Vi(o):Kr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ms(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ns.enqueueReplaceState(a,a.state,null),Fa(t,r,a,i),Pa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Is(n,s);a.props=c;var l=a.context,u=n.contextType;o=Kr,typeof u==`object`&&u&&(o=Vi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Fs(t,a,r,o),Ea=!1;var f=t.memoizedState;a.state=f,Fa(t,r,a,i),Pa(),l=t.memoizedState,s||f!==l||Ea?(typeof d==`function`&&(Ms(t,n,d,r),l=t.memoizedState),(c=Ea||Ps(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Oa(e,t),o=t.memoizedProps,u=Is(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Kr,typeof l==`object`&&l&&(c=Vi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Fs(t,a,r,c),Ea=!1,f=t.memoizedState,a.state=f,Fa(t,r,a,i),Pa();var p=t.memoizedState;o!==d||f!==p||Ea||e!==null&&e.dependencies!==null&&zi(e.dependencies)?(typeof s==`function`&&(Ms(t,n,s,r),p=t.memoizedState),(u=Ea||Ps(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&zi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,ic(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=wa(t,e.child,null,i),t.child=wa(t,null,n,i)):Js(e,t,n,i),t.memoizedState=a.state,e=t.child):e=yc(e,t,i),e}function cc(e,t,n,r){return Oi(),t.flags|=256,Js(e,t,n,r),t.child}var lc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function uc(e){return{baseLanes:e,cachePool:sa()}}function dc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Gl),e}function fc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Xa.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(bi){if(a?Ga(t):Ja(t),(e=yi)?(e=rf(e,Si),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ui===null?null:{id:di,overflow:fi},retryLane:536870912,hydrationErrors:null},n=ti(e),n.return=t,t.child=n,vi=t,yi=null)):e=null,e===null)throw wi(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Ja(t),a=t.mode,c=mc({mode:`hidden`,children:c},a),r=$r(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=uc(n),r.childLanes=dc(e,s,n),t.memoizedState=lc,$s(null,r)):(Ga(t),pc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ga(t),t.flags&=-257,t=hc(e,t,n)):t.memoizedState===null?(Ja(t),c=r.fallback,a=t.mode,r=mc({mode:`visible`,children:r.children},a),c=$r(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,wa(t,e.child,null,n),r=t.child,r.memoizedState=uc(n),r.childLanes=dc(e,s,n),t.memoizedState=lc,t=$s(null,r)):(Ja(t),t.child=e.child,t.flags|=128,t=null);else if(Ga(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ai({value:r,source:null,stack:null}),t=hc(e,t,n)}else if(qs||Ri(e,t,n,!1),s=(n&e.childLanes)!==0,qs||s){if(s=Ml,s!==null&&(r=Ke(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Ur(e,r),fu(s,e,r),Ks;af(c)||wu(),t=hc(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,yi=cf(c.nextSibling),vi=t,bi=!0,xi=null,Si=!1,e!==null&&_i(t,e),t=pc(t,r.children),t.flags|=4096);return t}return a?(Ja(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Xr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=$r(c,a,n,null),c.flags|=2):c=Xr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,$s(null,r),r=t.child,c=e.child.memoizedState,c===null?c=uc(n):(a=c.cachePool,a===null?a=sa():(l=qi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=dc(e,s,n),t.memoizedState=lc,$s(e.child,r)):(Ga(t),n=e.child,e=n.sibling,n=Xr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function pc(e,t){return t=mc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function mc(e,t){return e=Jr(22,e,null,t),e.lanes=0,e}function hc(e,t,n){return wa(t,e.child,null,n),e=pc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function gc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ii(e.return,t,n)}function _c(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function vc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Xa.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(Xa,o),Js(e,t,r,n),r=bi?si:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&gc(e,n,t);else if(e.tag===19)gc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Za(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),_c(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Za(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}_c(t,!0,n,null,a,r);break;case`together`:_c(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function yc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Hl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Ri(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Xr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Xr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function bc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&zi(e))):!0}function xc(e,t,n){switch(t.tag){case 3:ie(t,t.stateNode.containerInfo),Pi(t,qi,e.memoizedState.cache),Oi();break;case 27:case 5:oe(t);break;case 4:ie(t,t.stateNode.containerInfo);break;case 10:Pi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ka(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ga(t),e=yc(e,t,n),e===null?null:e.sibling):fc(e,t,n):(Ga(t),t.flags|=128,null);Ga(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Ri(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return vc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(Xa,Xa.current),r)break;return null;case 22:return t.lanes=0,Qs(e,t,n,t.pendingProps);case 24:Pi(t,qi,e.memoizedState.cache)}return yc(e,t,n)}function Sc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)qs=!0;else{if(!bc(e,n)&&!(t.flags&128))return qs=!1,xc(e,t,n);qs=!!(e.flags&131072)}else qs=!1,bi&&t.flags&1048576&&mi(t,si,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ma(t.elementType),t.type=e,typeof e==`function`)Yr(e)?(r=Is(e,r),t.tag=1,t=sc(null,t,e,r,n)):(t.tag=0,t=ac(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===C){t.tag=11,t=Ys(null,t,e,r,n);break a}else if(a===E){t.tag=14,t=Xs(null,t,e,r,n);break a}}throw t=N(e)||e,Error(i(306,t,``))}}return t;case 0:return ac(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Is(r,t.pendingProps),sc(e,t,r,a,n);case 3:a:{if(ie(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Oa(e,t),Fa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Pi(t,qi,r),r!==o.cache&&Li(t,[qi],n,!0),Pa(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=cc(e,t,r,n);break a}else if(r!==a){a=$(Error(i(424)),t),Ai(a),t=cc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(yi=cf(e.firstChild),vi=t,bi=!0,xi=null,Si=!0,n=Ta(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Oi(),r===a){t=yc(e,t,n);break a}Js(e,t,r,n)}t=t.child}return t;case 26:return ic(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:bi||(n=t.type,e=t.pendingProps,r=Bd(ne.current).createElement(n),r[Qe]=t,r[$e]=e,Pd(r,n,e),st(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return oe(t),e===null&&bi&&(r=t.stateNode=ff(t.type,t.pendingProps,ne.current),vi=t,Si=!0,a=yi,Zd(t.type)?(lf=a,yi=cf(r.firstChild)):yi=a),Js(e,t,t.pendingProps.children,n),ic(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&bi&&((a=r=yi)&&(r=tf(r,t.type,t.pendingProps,Si),r===null?a=!1:(t.stateNode=r,vi=t,yi=cf(r.firstChild),Si=!1,a=!0)),a||wi(t)),oe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=fo(e,t,ho,null,null,n),Qf._currentValue=a),ic(e,t),Js(e,t,r,n),t.child;case 6:return e===null&&bi&&((e=n=yi)&&(n=nf(n,t.pendingProps,Si),n===null?e=!1:(t.stateNode=n,vi=t,yi=null,e=!0)),e||wi(t)),null;case 13:return fc(e,t,n);case 4:return ie(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wa(t,null,r,n):Js(e,t,r,n),t.child;case 11:return Ys(e,t,t.type,t.pendingProps,n);case 7:return Js(e,t,t.pendingProps,n),t.child;case 8:return Js(e,t,t.pendingProps.children,n),t.child;case 12:return Js(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Pi(t,t.type,r.value),Js(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Bi(t),a=Vi(a),r=r(a),t.flags|=1,Js(e,t,r,n),t.child;case 14:return Xs(e,t,t.type,t.pendingProps,n);case 15:return Zs(e,t,t.type,t.pendingProps,n);case 19:return vc(e,t,n);case 31:return rc(e,t,n);case 22:return Qs(e,t,n,t.pendingProps);case 24:return Bi(t),r=Vi(qi),e===null?(a=aa(),a===null&&(a=Ml,o=Ji(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Da(t),Pi(t,qi,a)):((e.lanes&n)!==0&&(Oa(e,t),Fa(t,null,null,n),Pa()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Pi(t,qi,r),r!==a.cache&&Li(t,[qi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Pi(t,qi,r))),Js(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Cc(e){e.flags|=4}function wc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(xu())e.flags|=8192;else throw ha=da,la}else e.flags&=-16777217}function Tc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(xu())e.flags|=8192;else throw ha=da,la}function Ec(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:G(),e.lanes|=t,Kl|=t)}function Dc(e,t){if(!bi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Oc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function kc(e,t,n){var r=t.pendingProps;switch(gi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Oc(t),null;case 1:return Oc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Fi(qi),ae(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Di(t)?Cc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ki())),Oc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Cc(t),o===null?(Oc(t),wc(t,a,null,r,n)):(Oc(t),Tc(t,o))):o?o===e.memoizedState?(Oc(t),t.flags&=-16777217):(Cc(t),Oc(t),Tc(t,o)):(e=e.memoizedProps,e!==r&&Cc(t),Oc(t),wc(t,a,e,r,n)),null;case 27:if(se(t),n=ne.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Oc(t),null}e=H.current,Di(t)?Ti(t,e):(e=ff(a,r,n),t.stateNode=e,Cc(t))}return Oc(t),null;case 5:if(se(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Oc(t),null}if(o=H.current,Di(t))Ti(t,o);else{var s=Bd(ne.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Qe]=t,o[$e]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Cc(t)}}return Oc(t),wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ne.current,Di(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=vi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||wi(t,!0)}else e=Bd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return Oc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Di(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Qe]=t}else Oi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),e=!1}else n=ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ya(t),t):(Ya(t),null);if(t.flags&128)throw Error(i(558))}return Oc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Di(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Qe]=t}else Oi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),a=!1}else a=ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Ya(t),t):(Ya(t),null)}return Ya(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ec(t,t.updateQueue),Oc(t),null);case 4:return ae(),e===null&&xd(t.stateNode.containerInfo),Oc(t),null;case 10:return Fi(t.type),Oc(t),null;case 19:if(ee(Xa),r=t.memoizedState,r===null)return Oc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Dc(r,!1);else{if(Vl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Za(e),o!==null){for(t.flags|=128,Dc(r,!1),e=o.updateQueue,t.updateQueue=e,Ec(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Zr(n,e),n=n.sibling;return V(Xa,Xa.current&1|2),bi&&pi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&U()>Ql&&(t.flags|=128,a=!0,Dc(r,!1),t.lanes=4194304)}else{if(!a)if(e=Za(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ec(t,e),Dc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!bi)return Oc(t),null}else 2*U()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,a=!0,Dc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Oc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=U(),e.sibling=null,n=Xa.current,V(Xa,a?n&1|2:n&1),bi&&pi(t,r.treeForkCount),e);case 22:case 23:return Ya(t),Ha(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Oc(t),t.subtreeFlags&6&&(t.flags|=8192)):Oc(t),n=t.updateQueue,n!==null&&Ec(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ee(ia),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Fi(qi),Oc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Ac(e,t){switch(gi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fi(qi),ae(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return se(t),null;case 31:if(t.memoizedState!==null){if(Ya(t),t.alternate===null)throw Error(i(340));Oi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ya(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Oi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ee(Xa),null;case 4:return ae(),null;case 10:return Fi(t.type),null;case 22:case 23:return Ya(t),Ha(),e!==null&&ee(ia),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Fi(qi),null;case 25:return null;default:return null}}function jc(e,t){switch(gi(t),t.tag){case 3:Fi(qi),ae();break;case 26:case 27:case 5:se(t);break;case 4:ae();break;case 31:t.memoizedState!==null&&Ya(t);break;case 13:Ya(t);break;case 19:ee(Xa);break;case 10:Fi(t.type);break;case 22:case 23:Ya(t),Ha(),e!==null&&ee(ia);break;case 24:Fi(qi)}}function Mc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Hu(t,t.return,e)}}function Nc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Pc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{La(t,n)}catch(t){Hu(e,e.return,t)}}}function Fc(e,t,n){n.props=Is(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Ic(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Hu(e,t,n)}}function Lc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Hu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Hu(e,t,n)}else n.current=null}function Rc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Hu(e,e.return,t)}}function zc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[$e]=t}catch(t){Hu(e,e.return,t)}}function Bc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Vc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Bc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Hc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Vt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Hc(e,t,n),e=e.sibling;e!==null;)Hc(e,t,n),e=e.sibling}function Uc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Hu(e,e.return,t)}}var Gc=!1,Kc=!1,qc=!1,Jc=typeof WeakSet==`function`?WeakSet:Set,Yc=null;function Xc(e,t){if(e=e.containerInfo,Rd=sp,e=pr(e),mr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Yc=t;Yc!==null;)if(t=Yc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Yc=e;else for(;Yc!==null;){switch(t=Yc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Is(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Hu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Yc=e;break}Yc=t.return}}function Zc(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:fl(e,n),r&4&&Mc(5,n);break;case 1:if(fl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Hu(n,n.return,e)}else{var i=Is(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Hu(n,n.return,e)}}r&64&&Pc(n),r&512&&Ic(n,n.return);break;case 3:if(fl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{La(e,t)}catch(e){Hu(n,n.return,e)}}break;case 27:t===null&&r&4&&Wc(n);case 26:case 5:fl(e,n),t===null&&r&4&&Rc(n),r&512&&Ic(n,n.return);break;case 12:fl(e,n);break;case 31:fl(e,n),r&4&&rl(e,n);break;case 13:fl(e,n),r&4&&il(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ku.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||Gc,!r){t=t!==null&&t.memoizedState!==null||Kc,i=Gc;var a=Kc;Gc=r,(Kc=t)&&!a?ml(e,n,(n.subtreeFlags&8772)!=0):fl(e,n),Gc=i,Kc=a}break;case 30:break;default:fl(e,n)}}function Qc(e){var t=e.alternate;t!==null&&(e.alternate=null,Qc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&it(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var $c=null,el=!1;function tl(e,t,n){for(n=n.child;n!==null;)nl(e,t,n),n=n.sibling}function nl(e,t,n){if(Oe&&typeof Oe.onCommitFiberUnmount==`function`)try{Oe.onCommitFiberUnmount(De,n)}catch{}switch(n.tag){case 26:Kc||Lc(n,t),tl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Kc||Lc(n,t);var r=$c,i=el;Zd(n.type)&&($c=n.stateNode,el=!1),tl(e,t,n),pf(n.stateNode),$c=r,el=i;break;case 5:Kc||Lc(n,t);case 6:if(r=$c,i=el,$c=null,tl(e,t,n),$c=r,el=i,$c!==null)if(el)try{($c.nodeType===9?$c.body:$c.nodeName===`HTML`?$c.ownerDocument.body:$c).removeChild(n.stateNode)}catch(e){Hu(n,t,e)}else try{$c.removeChild(n.stateNode)}catch(e){Hu(n,t,e)}break;case 18:$c!==null&&(el?(e=$c,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd($c,n.stateNode));break;case 4:r=$c,i=el,$c=n.stateNode.containerInfo,el=!0,tl(e,t,n),$c=r,el=i;break;case 0:case 11:case 14:case 15:Nc(2,n,t),Kc||Nc(4,n,t),tl(e,t,n);break;case 1:Kc||(Lc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Fc(n,t,r)),tl(e,t,n);break;case 21:tl(e,t,n);break;case 22:Kc=(r=Kc)||n.memoizedState!==null,tl(e,t,n),Kc=r;break;default:tl(e,t,n)}}function rl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Hu(t,t.return,e)}}}function il(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Hu(t,t.return,e)}}function al(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Jc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Jc),t;default:throw Error(i(435,e.tag))}}function ol(e,t){var n=al(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=qu.bind(null,e,t);t.then(r,r)}})}function sl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){$c=c.stateNode,el=!1;break a}break;case 5:$c=c.stateNode,el=!1;break a;case 3:case 4:$c=c.stateNode.containerInfo,el=!0;break a}c=c.return}if($c===null)throw Error(i(160));nl(o,s,a),$c=null,el=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ll(t,e),t=t.sibling}var cl=null;function ll(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:sl(t,e),ul(e),r&4&&(Nc(3,e,e.return),Mc(3,e),Nc(5,e,e.return));break;case 1:sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),r&64&&Gc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=cl;if(sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[rt]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[Qe]=e,st(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,st(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode);else e.stateNode=If(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&zc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),n!==null&&r&4&&zc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),e.flags&32){a=e.stateNode;try{Nt(a,``)}catch(t){Hu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,zc(e,a,n===null?a:n.memoizedProps)),r&1024&&(qc=!0);break;case 6:if(sl(t,e),ul(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Hu(e,e.return,t)}}break;case 3:if(Bf=null,a=cl,cl=gf(t.containerInfo),sl(t,e),cl=a,ul(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Hu(e,e.return,t)}qc&&(qc=!1,dl(e));break;case 4:r=cl,cl=gf(e.stateNode.containerInfo),sl(t,e),ul(e),cl=r;break;case 12:sl(t,e),ul(e);break;case 31:sl(t,e),ul(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 13:sl(t,e),ul(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Xl=U()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Gc,d=Kc;if(Gc=u||a,Kc=d||l,sl(t,e),Kc=d,Gc=u,ul(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Gc||Kc||pl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Hu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Hu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Hu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,ol(e,n))));break;case 19:sl(t,e),ul(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 30:break;case 21:break;default:sl(t,e),ul(e)}}function ul(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Bc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Uc(e,Vc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Nt(o,``),n.flags&=-33),Uc(e,Vc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Hc(e,Vc(e),s);break;default:throw Error(i(161))}}catch(t){Hu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function dl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;dl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function fl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Zc(e,t.alternate,t),t=t.sibling}function pl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Nc(4,t,t.return),pl(t);break;case 1:Lc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Fc(t,t.return,n),pl(t);break;case 27:pf(t.stateNode);case 26:case 5:Lc(t,t.return),pl(t);break;case 22:t.memoizedState===null&&pl(t);break;case 30:pl(t);break;default:pl(t)}e=e.sibling}}function ml(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:ml(i,a,n),Mc(4,a);break;case 1:if(ml(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Hu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ia(c[i],s)}catch(e){Hu(r,r.return,e)}}n&&o&64&&Pc(a),Ic(a,a.return);break;case 27:Wc(a);case 26:case 5:ml(i,a,n),n&&r===null&&o&4&&Rc(a),Ic(a,a.return);break;case 12:ml(i,a,n);break;case 31:ml(i,a,n),n&&o&4&&rl(i,a);break;case 13:ml(i,a,n),n&&o&4&&il(i,a);break;case 22:a.memoizedState===null&&ml(i,a,n),Ic(a,a.return);break;case 30:break;default:ml(i,a,n)}t=t.sibling}}function hl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Yi(n))}function gl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Yi(e))}function _l(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)vl(e,t,n,r),t=t.sibling}function vl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:_l(e,t,n,r),i&2048&&Mc(9,t);break;case 1:_l(e,t,n,r);break;case 3:_l(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Yi(e)));break;case 12:if(i&2048){_l(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Hu(t,t.return,e)}}else _l(e,t,n,r);break;case 31:_l(e,t,n,r);break;case 13:_l(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?_l(e,t,n,r):(a._visibility|=2,yl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?_l(e,t,n,r):bl(e,t),i&2048&&hl(o,t);break;case 24:_l(e,t,n,r),i&2048&&gl(t.alternate,t);break;default:_l(e,t,n,r)}}function yl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:yl(a,o,s,c,i),Mc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,yl(a,o,s,c,i)):u._visibility&2?yl(a,o,s,c,i):bl(a,o),i&&l&2048&&hl(o.alternate,o);break;case 24:yl(a,o,s,c,i),i&&l&2048&&gl(o.alternate,o);break;default:yl(a,o,s,c,i)}t=t.sibling}}function bl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:bl(n,r),i&2048&&hl(r.alternate,r);break;case 24:bl(n,r),i&2048&&gl(r.alternate,r);break;default:bl(n,r)}t=t.sibling}}var xl=8192;function Sl(e,t,n){if(e.subtreeFlags&xl)for(e=e.child;e!==null;)Cl(e,t,n),e=e.sibling}function Cl(e,t,n){switch(e.tag){case 26:Sl(e,t,n),e.flags&xl&&e.memoizedState!==null&&Gf(n,cl,e.memoizedState,e.memoizedProps);break;case 5:Sl(e,t,n);break;case 3:case 4:var r=cl;cl=gf(e.stateNode.containerInfo),Sl(e,t,n),cl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=xl,xl=16777216,Sl(e,t,n),xl=r):Sl(e,t,n));break;default:Sl(e,t,n)}}function wl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Tl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Yc=r,Ol(r,e)}wl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)El(e),e=e.sibling}function El(e){switch(e.tag){case 0:case 11:case 15:Tl(e),e.flags&2048&&Nc(9,e,e.return);break;case 3:Tl(e);break;case 12:Tl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Dl(e)):Tl(e);break;default:Tl(e)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Yc=r,Ol(r,e)}wl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Nc(8,t,t.return),Dl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Dl(t));break;default:Dl(t)}e=e.sibling}}function Ol(e,t){for(;Yc!==null;){var n=Yc;switch(n.tag){case 0:case 11:case 15:Nc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Yi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Yc=r;else a:for(n=e;Yc!==null;){r=Yc;var i=r.sibling,a=r.return;if(Qc(r),r===n){Yc=null;break a}if(i!==null){i.return=a,Yc=i;break a}Yc=a}}}var kl={getCacheForType:function(e){var t=Vi(qi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Vi(qi).controller.signal}},Al=typeof WeakMap==`function`?WeakMap:Map,jl=0,Ml=null,Nl=null,Pl=0,Fl=0,Il=null,Ll=!1,Rl=!1,zl=!1,Bl=0,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=null,Jl=null,Yl=!1,Xl=0,Zl=0,Ql=1/0,$l=null,eu=null,tu=0,nu=null,ru=null,iu=0,au=0,ou=null,su=null,cu=0,lu=null;function uu(){return jl&2&&Pl!==0?Pl&-Pl:F.T===null?Ye():ld()}function du(){if(Gl===0)if(!(Pl&536870912)||bi){var e=Fe;Fe<<=1,!(Fe&3932160)&&(Fe=262144),Gl=e}else Gl=536870912;return e=Ua.current,e!==null&&(e.flags|=32),Gl}function fu(e,t,n){(e===Ml&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)&&(yu(e,0),gu(e,Pl,Gl,!1)),He(e,n),(!(jl&2)||e!==Ml)&&(e===Ml&&(!(jl&2)&&(Ul|=n),Vl===4&&gu(e,Pl,Gl,!1)),td(e))}function pu(e,t,n){if(jl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||ze(e,t),a=r?Du(e,t):Tu(e,t,!0),o=r;do{if(a===0){Rl&&!r&&gu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!hu(n)){a=Tu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ql;var l=c.current.memoizedState.isDehydrated;if(l&&(yu(c,s).flags|=256),s=Tu(c,s,!1),s!==2){if(zl&&!l){c.errorRecoveryDisabledLanes|=o,Ul|=o,a=4;break a}o=Jl,Jl=a,o!==null&&(Jl===null?Jl=o:Jl.push.apply(Jl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){yu(e,0),gu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:gu(r,t,Gl,!Ll);break a;case 2:Jl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Xl+300-U(),10<a)){if(gu(r,t,Gl,!Ll),Re(r,0,!0)!==0)break a;iu=t,r.timeoutHandle=Kd(mu.bind(null,r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,`Throttled`,-0,0),a);break a}mu(r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,null,-0,0)}}break}while(1);td(e)}function mu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vt},Cl(t,a,d);var m=(a&62914560)===a?Xl-U():(a&4194048)===a?Zl-U():0;if(m=qf(d,m),m!==null){iu=a,e.cancelPendingCommit=m(Pu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),gu(e,a,o,!l);return}}Pu(e,t,a,n,r,i,o,s,c)}function hu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!cr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function gu(e,t,n,r){t&=~Wl,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ae(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&We(e,n,t)}function _u(){return jl&6?!0:(nd(0,!1),!1)}function vu(){if(Nl!==null){if(Fl===0)var e=Nl.return;else e=Nl,Ni=Mi=null,vo(e),va=null,ya=0,e=Nl;for(;e!==null;)jc(e.alternate,e),e=e.return;Nl=null}}function yu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),iu=0,vu(),Ml=e,Nl=n=Xr(e.current,null),Pl=t,Fl=0,Il=null,Ll=!1,Rl=ze(e,t),zl=!1,Kl=Gl=Wl=Ul=Hl=Vl=0,Jl=ql=null,Yl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ae(r),a=1<<i;t|=e[i],r&=~a}return Bl=t,Br(),n}function bu(e,t){$a=null,F.H=Os,t===ca||t===ua?(t=ga(),Fl=3):t===la?(t=ga(),Fl=4):Fl=t===Ks?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Il=t,Nl===null&&(Vl=1,Bs(e,$(t,e.current)))}function xu(){var e=Ua.current;return e===null?!0:(Pl&4194048)===Pl?Wa===null:(Pl&62914560)===Pl||Pl&536870912?e===Wa:!1}function Su(){var e=F.H;return F.H=Os,e===null?Os:e}function Cu(){var e=F.A;return F.A=kl,e}function wu(){Vl=4,Ll||(Pl&4194048)!==Pl&&Ua.current!==null||(Rl=!0),!(Hl&134217727)&&!(Ul&134217727)||Ml===null||gu(Ml,Pl,Gl,!1)}function Tu(e,t,n){var r=jl;jl|=2;var i=Su(),a=Cu();(Ml!==e||Pl!==t)&&($l=null,yu(e,t)),t=!1;var o=Vl;a:do try{if(Fl!==0&&Nl!==null){var s=Nl,c=Il;switch(Fl){case 8:vu(),o=6;break a;case 3:case 2:case 9:case 6:Ua.current===null&&(t=!0);var l=Fl;if(Fl=0,Il=null,ju(e,s,c,l),n&&Rl){o=0;break a}break;default:l=Fl,Fl=0,Il=null,ju(e,s,c,l)}}Eu(),o=Vl;break}catch(t){bu(e,t)}while(1);return t&&e.shellSuspendCounter++,Ni=Mi=null,jl=r,F.H=i,F.A=a,Nl===null&&(Ml=null,Pl=0,Br()),o}function Eu(){for(;Nl!==null;)ku(Nl)}function Du(e,t){var n=jl;jl|=2;var r=Su(),a=Cu();Ml!==e||Pl!==t?($l=null,Ql=U()+500,yu(e,t)):Rl=ze(e,t);a:do try{if(Fl!==0&&Nl!==null){t=Nl;var o=Il;b:switch(Fl){case 1:Fl=0,Il=null,ju(e,t,o,1);break;case 2:case 9:if(fa(o)){Fl=0,Il=null,Au(t);break}t=function(){Fl!==2&&Fl!==9||Ml!==e||(Fl=7),td(e)},o.then(t,t);break a;case 3:Fl=7;break a;case 4:Fl=5;break a;case 7:fa(o)?(Fl=0,Il=null,Au(t)):(Fl=0,Il=null,ju(e,t,o,7));break;case 5:var s=null;switch(Nl.tag){case 26:s=Nl.memoizedState;case 5:case 27:var c=Nl;if(s?Wf(s):c.stateNode.complete){Fl=0,Il=null;var l=c.sibling;if(l!==null)Nl=l;else{var u=c.return;u===null?Nl=null:(Nl=u,Mu(u))}break b}}Fl=0,Il=null,ju(e,t,o,5);break;case 6:Fl=0,Il=null,ju(e,t,o,6);break;case 8:vu(),Vl=6;break a;default:throw Error(i(462))}}Ou();break}catch(t){bu(e,t)}while(1);return Ni=Mi=null,F.H=r,F.A=a,jl=n,Nl===null?(Ml=null,Pl=0,Br(),Vl):0}function Ou(){for(;Nl!==null&&!ve();)ku(Nl)}function ku(e){var t=Sc(e.alternate,e,Bl);e.memoizedProps=e.pendingProps,t===null?Mu(e):Nl=t}function Au(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=oc(n,t,t.pendingProps,t.type,void 0,Pl);break;case 11:t=oc(n,t,t.pendingProps,t.type.render,t.ref,Pl);break;case 5:vo(t);default:jc(n,t),t=Nl=Zr(t,Bl),t=Sc(n,t,Bl)}e.memoizedProps=e.pendingProps,t===null?Mu(e):Nl=t}function ju(e,t,n,r){Ni=Mi=null,vo(t),va=null,ya=0;var i=t.return;try{if(Gs(e,i,t,n,Pl)){Vl=1,Bs(e,$(n,e.current)),Nl=null;return}}catch(t){if(i!==null)throw Nl=i,t;Vl=1,Bs(e,$(n,e.current)),Nl=null;return}t.flags&32768?(bi||r===1?e=!0:Rl||Pl&536870912?e=!1:(Ll=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ua.current,r!==null&&r.tag===13&&(r.flags|=16384))),Nu(t,e)):Mu(t)}function Mu(e){var t=e;do{if(t.flags&32768){Nu(t,Ll);return}e=t.return;var n=kc(t.alternate,t,Bl);if(n!==null){Nl=n;return}if(t=t.sibling,t!==null){Nl=t;return}Nl=t=e}while(t!==null);Vl===0&&(Vl=5)}function Nu(e,t){do{var n=Ac(e.alternate,e);if(n!==null){n.flags&=32767,Nl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Nl=e;return}Nl=e=n}while(e!==null);Vl=6,Nl=null}function Pu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do zu();while(tu!==0);if(jl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=zr,Ue(e,n,o,s,c,l),e===Ml&&(Nl=Ml=null,Pl=0),ru=t,nu=e,iu=n,au=o,ou=a,su=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Ju(Ce,function(){return Bu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,a=I.p,I.p=2,s=jl,jl|=4;try{Xc(e,t,n)}finally{jl=s,I.p=a,F.T=r}}tu=1,Fu(),Iu(),Lu()}}function Fu(){if(tu===1){tu=0;var e=nu,t=ru,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=jl;jl|=4;try{ll(t,e);var a=zd,o=pr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&fr(s.ownerDocument.documentElement,s)){if(c!==null&&mr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=dr(s,h),v=dr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{jl=i,I.p=r,F.T=n}}e.current=t,tu=2}}function Iu(){if(tu===2){tu=0;var e=nu,t=ru,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=jl;jl|=4;try{Zc(e,t.alternate,t)}finally{jl=i,I.p=r,F.T=n}}tu=3}}function Lu(){if(tu===4||tu===3){tu=0,ye();var e=nu,t=ru,n=iu,r=su;t.subtreeFlags&10256||t.flags&10256?tu=5:(tu=0,ru=nu=null,Ru(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(eu=null),Je(n),t=t.stateNode,Oe&&typeof Oe.onCommitFiberRoot==`function`)try{Oe.onCommitFiberRoot(De,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{F.T=t,I.p=i}}iu&3&&zu(),td(e),i=e.pendingLanes,n&261930&&i&42?e===lu?cu++:(cu=0,lu=e):cu=0,nd(0,!1)}}function Ru(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Yi(t)))}function zu(){return Fu(),Iu(),Lu(),Bu()}function Bu(){if(tu!==5)return!1;var e=nu,t=au;au=0;var n=Je(iu),r=F.T,a=I.p;try{I.p=32>n?32:n,F.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,jl&6)throw Error(i(331));var c=jl;if(jl|=4,El(o.current),vl(o,o.current,s,n),jl=c,nd(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot==`function`)try{Oe.onPostCommitFiberRoot(De,o)}catch{}return!0}finally{I.p=a,F.T=r,Ru(e,t)}}function Vu(e,t,n){t=$(n,t),t=Hs(e.stateNode,t,2),e=Aa(e,t,2),e!==null&&(He(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=$(n,e),n=Us(2),r=Aa(t,n,2),r!==null&&(Ws(n,r,t,e),He(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Al;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ml===e&&(Pl&n)===n&&(Vl===4||Vl===3&&(Pl&62914560)===Pl&&300>U()-Xl?!(jl&2)&&yu(e,0):Wl|=n,Kl===Pl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=G()),e=Ur(e,t),e!==null&&(He(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return ge(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ae(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Pl,a=Re(r,r===Ml?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ze(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=U(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ae(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Be(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ml,n=Pl,n=Re(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&_e(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&_e(r),Je(n)){case 2:case 8:n=Se;break;case 32:n=Ce;break;case 268435456:n=we;break;default:n=Ce}return r=od.bind(null,e),n=ge(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&_e(r),e.callbackPriority=2,e.callbackNode=null,2}function od(e,t){if(tu!==0&&tu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(zu()&&e.callbackNode!==n)return null;var r=Pl;return r=Re(e,e===Ml?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(pu(e,r,t),ad(e,U()),e.callbackNode!=null&&e.callbackNode===n?od.bind(null,e):null)}function sd(e,t){if(zu())return null;pu(e,t,!0)}function cd(){Yd(function(){jl&6?ge(xe,rd):id()})}function ld(){if(ed===0){var e=Qi;e===0&&(e=Pe,Pe<<=1,!(Pe&261888)&&(Pe=256)),ed=e}return ed}function ud(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Bt(``+e)}function dd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function fd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=ud((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?ud(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ed!==0){var e=o?dd(i,o):new FormData(i);ms(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?dd(i,o):new FormData(i),ms(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var pd=0;pd<Pr.length;pd++){var md=Pr[pd];Fr(md.toLowerCase(),`on`+(md[0].toUpperCase()+md.slice(1)))}Fr(Er,`onAnimationEnd`),Fr(Dr,`onAnimationIteration`),Fr(Or,`onAnimationStart`),Fr(`dblclick`,`onDoubleClick`),Fr(`focusin`,`onFocus`),Fr(`focusout`,`onBlur`),Fr(kr,`onTransitionRun`),Fr(Ar,`onTransitionStart`),Fr(jr,`onTransitionCancel`),Fr(Mr,`onTransitionEnd`),dt(`onMouseEnter`,[`mouseout`,`mouseover`]),dt(`onMouseLeave`,[`mouseout`,`mouseover`]),dt(`onPointerEnter`,[`pointerout`,`pointerover`]),dt(`onPointerLeave`,[`pointerout`,`pointerover`]),ut(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ut(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ut(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ut(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var hd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),gd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(hd));function _d(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Ir(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Ir(e)}i.currentTarget=null,a=c}}}}function vd(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,ct.forEach(function(t){t!==`selectionchange`&&(gd.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!Zt||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=at(s),o===null)return;if(l=o.tag,l===5||l===6||l===26||l===27){r=a=o;continue a}s=s.parentNode}}r=r.return}Jt(function(){var r=a,i=Ut(n),o=[];a:{var s=Nr.get(e);if(s!==void 0){var l=ln,u=e;switch(e){case`keypress`:if(rn(n)===0)break a;case`keydown`:case`keyup`:l=Dn;break;case`focusin`:u=`focus`,l=vn;break;case`focusout`:u=`blur`,l=vn;break;case`beforeblur`:case`afterblur`:l=vn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=gn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=_n;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=kn;break;case Er:case Dr:case Or:l=yn;break;case Mr:l=An;break;case`scroll`:case`scrollend`:l=dn;break;case`wheel`:l=jn;break;case`copy`:case`cut`:case`paste`:l=bn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=On;break;case`toggle`:case`beforetoggle`:l=Mn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Yt(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(s=new l(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,s&&n!==Ht&&(u=n.relatedTarget||n.fromElement)&&(at(u)||u[et]))break a;if((l||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?at(u):null,u!==null&&(f=c(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=gn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=On,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?s:ot(l),h=u==null?s:ot(u),s=new d(g,m+`leave`,l,n,i),s.target=f,s.relatedTarget=h,g=null,at(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ed,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Dd(o,s,l,d,!1),u!==null&&f!==null&&Dd(o,f,u,d,!0)}}a:{if(s=r?ot(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var v=Zn;else if(Kn(s))if(Qn)v=or;else{v=ir;var y=rr}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Lt(r.elementType)&&(v=Zn):v=ar;if(v&&=v(e,r)){qn(o,v,n,i);break a}y&&y(e,s,r),e===`focusout`&&r&&s.type===`number`&&r.memoizedProps.value!=null&&kt(s,`number`,s.value)}switch(y=r?ot(r):window,e){case`focusin`:(Kn(y)||y.contentEditable===`true`)&&(gr=y,_r=r,vr=null);break;case`focusout`:vr=_r=gr=null;break;case`mousedown`:yr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:yr=!1,xr(o,n,i);break;case`selectionchange`:if(hr)break;case`keydown`:case`keyup`:xr(o,n,i)}var b;if(Pn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Hn?Bn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Ln&&n.locale!==`ko`&&(Hn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Hn&&(b=nn()):($t=i,en=`value`in $t?$t.value:$t.textContent,Hn=!0)),y=Td(r,x),0<y.length&&(x=new xn(x,e,null,n,i),o.push({event:x,listeners:y}),b?x.data=b:(b=Vn(n),b!==null&&(x.data=b)))),(b=In?Un(e,n):Wn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new xn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:y,listeners:x}),y.data=b)),fd(o,e,r,n,i)}_d(o,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Yt(e,n),i!=null&&r.unshift(wd(e,i,a)),i=Yt(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Yt(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=Yt(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
10
+ `).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Nt(e,``+r);break;case`className`:_t(e,`class`,r);break;case`tabIndex`:_t(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:_t(e,n,r);break;case`style`:It(e,r,o);break;case`data`:if(t!==`object`){_t(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Bt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:vd(`beforetoggle`,e),vd(`toggle`,e),gt(e,`popover`,r);break;case`xlinkActuate`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:gt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Rt.get(n)||n,gt(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:It(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Nt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):gt(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}Ot(e,o,c,l,u,s,a,!1);return;case`select`:for(a in vd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&At(e,!!r,n,!0):At(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}Mt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}Dt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?At(e,!!n,n?[]:``,!1):At(e,!!n,t,!0)):At(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(Lt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[rt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),it(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[rt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);it(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=I.d;I.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=J(e);t!==null&&t.tag===5&&t.type===`form`?gs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Et(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Et(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Et(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Et(n.imageSizes)+`"]`)):i+=`[href="`+Et(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Et(r)+`"][href="`+Et(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),st(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=Y(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);st(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=Y(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),st(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=Y(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),st(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ne.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=Y(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=Y(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=Y(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Et(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),st(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Et(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Et(n.href)+`"]`);if(r)return t.instance=r,st(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),st(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,st(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),st(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,st(a),a):(r=n,(a=mf.get(o))&&(r=m({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),st(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[rt]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,st(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),st(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:S,Provider:null,Consumer:null,_currentValue:L,_currentValue2:L,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ve(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ve(0),this.hiddenUpdates=Ve(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Jr(3,null,null,t),e.current=a,a.stateNode=e,t=Ji(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Da(a),e}function tp(e){return e?(e=Kr,e):Kr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=ka(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Aa(e,r,t),n!==null&&(fu(n,e,t),ja(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Ur(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=qe(t);var n=Ur(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,up(e,t,n,r)}finally{I.p=a,F.T=i}}function lp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,up(e,t,n,r)}finally{I.p=a,F.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=J(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Le(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ae(o);s.entanglements[1]|=c,o&=~c}td(a),!(jl&6)&&(Ql=U()+500,nd(0,!1))}}break;case 31:case 13:s=Ur(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Ut(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=at(e),e!==null){var t=c(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=l(t),e!==null)return e;e=null}else if(n===31){if(e=u(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(be()){case xe:return 2;case Se:return 8;case Ce:case W:return 32;case we:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=J(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=at(e.target);if(t!==null){var n=c(t);if(n!==null){if(t=n.tag,t===13){if(t=l(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===31){if(t=u(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ht=r,n.target.dispatchEvent(r),Ht=null}else return t=J(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=J(n);a!==null&&(e.splice(t,3),t-=3,ms(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[et]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.4`)throw Error(i(527,Lp,`19.2.4`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=f(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.4`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.2.4`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{De=zp.inject(Rp),Oe=zp}catch{}}e.createRoot=function(e,t){if(!o(e))throw Error(i(299));var n=!1,r=``,a=Ls,s=Rs,c=zs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,a,s,c,Pp),e[et]=t.current,xd(e),new Fp(t)}})),Sr=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=xr()})),Q=e(a(),1),Cr=Sr(),wr=`__new-mission__`,Tr=new Map,Er=new Map,Dr=new Map,Or=new Map,kr=new Set,Ar=new Map;function jr(e){Ar.set(e,(Ar.get(e)??0)+1),kr.forEach(e=>e())}function Mr(e){return kr.add(e),()=>{kr.delete(e)}}function Nr(e){return Ar.get(e)??0}function Pr(e){return(0,Q.useSyncExternalStore)(Mr,()=>Nr(e),()=>Nr(e))}function Fr(e,t,n){t?Tr.set(e,t):Tr.delete(e),t&&n.length?Dr.set(e,n):Dr.delete(e),Jr(e),jr(e)}function Ir(e,t){t.length>0?Er.set(e,t):Er.delete(e),Jr(e),jr(e)}function Lr(e,t){t?Or.set(e,t):Or.delete(e),Jr(e)}function Rr(e,t){return(Tr.get(e)??``)===t.text&&JSON.stringify(Dr.get(e)??[])===JSON.stringify(t.references)&&JSON.stringify((Er.get(e)??[]).map(e=>e.id))===JSON.stringify(t.attachments.map(e=>e.id))}function zr(e){return!Tr.get(e)&&!(Dr.get(e)??[]).length&&!(Er.get(e)??[]).length}function Br(e,t){return Rr(e,t)?(Tr.delete(e),Dr.delete(e),Er.delete(e),Xr(e),jr(e),!0):!1}function Vr(e,t){return!zr(e)&&!Rr(e,t)?!1:(qr(e,t),!0)}var Hr=`specrails:mission-draft:v1:`,Ur=2*1024*1024;function Wr(e){return JSON.parse(JSON.stringify(e))}function Gr(e){return Wr({text:Tr.get(e)??``,references:Dr.get(e)??[],attachments:Er.get(e)??[],...Or.has(e)?{submission:Or.get(e)}:{}})}function Kr(e){return Tr.has(e)||Dr.has(e)||Er.has(e)||Or.has(e)}function qr(e,t){let n=Wr(t);Tr.set(e,n.text),Dr.set(e,n.references),Er.set(e,n.attachments),n.submission?Or.set(e,n.submission):Or.delete(e),Jr(e),jr(e)}function Jr(e){try{let t=JSON.stringify({version:1,...Gr(e)});return new TextEncoder().encode(t).length>Ur?!1:(sessionStorage.setItem(Hr+encodeURIComponent(e),t),!0)}catch{return!1}}function Yr(e){if(Kr(e))return!0;try{let t=sessionStorage.getItem(Hr+encodeURIComponent(e));if(!t||t.length>Ur)return!1;let n=JSON.parse(t);return n.version!==1||typeof n.text!=`string`||!Array.isArray(n.references)||!Array.isArray(n.attachments)||!n.references.every(e=>typeof e?.key==`string`&&Number.isInteger(e.start)&&Number.isInteger(e.end)&&e.start>=0&&e.end>=e.start&&e.end<=n.text.length&&typeof e.chip?.id==`string`)||!n.attachments.every(e=>typeof e?.id==`string`&&typeof e.filename==`string`)||n.submission!==void 0&&(!n.submission||typeof n.submission.signature!=`string`||typeof n.submission.queueId!=`string`||!n.submission.queueId)?!1:(qr(e,n),!0)}catch{return!1}}function Xr(e){try{sessionStorage.removeItem(Hr+encodeURIComponent(e))}catch{}}function Zr(e){let t=Tr.get(wr),n=Dr.get(wr),r=Or.get(wr);if(t!==void 0){let i=Tr.get(e);r&&!Or.has(e)&&(i===void 0||i===t)&&Or.set(e,{...r}),i===void 0?(Tr.set(e,t),n===void 0?Dr.delete(e):Dr.set(e,n)):i===t&&!Dr.has(e)&&n!==void 0&&Dr.set(e,n),Tr.delete(wr)}Dr.delete(wr),Or.delete(wr);let i=Er.get(wr);if(i!==void 0){if(i.length){let t=Er.get(e)??[];Er.set(e,[...t,...i])}Er.delete(wr)}Xr(wr),Kr(e)&&Jr(e),jr(wr),jr(e)}var Qr=`mission-window:event`;function $r(){return me()&&new URLSearchParams(window.location.search).get(`missionWindow`)===`1`}function ei(e,t){let n=JSON.stringify(e);if(!n||new TextEncoder().encode(n).length>2097152)throw Error(`The mission state exceeds the transfer limit. Your draft remains in this window.`);let r=JSON.parse(n);if(!r||r.version!==1||r.projectId!==t.projectId||r.conversationId!==t.conversationId)throw Error(`The mission window snapshot does not match this conversation.`);if(!Number.isFinite(r.capturedAt)||typeof r.composer?.text!=`string`||!Array.isArray(r.composer.references)||!Array.isArray(r.composer.attachments))throw Error(`The mission draft snapshot is incomplete.`);let{text:i,references:a,attachments:o}=r.composer;if(!a.every(e=>typeof e?.key==`string`&&Number.isInteger(e.start)&&Number.isInteger(e.end)&&e.start>=0&&e.end>=e.start&&e.end<=i.length&&typeof e.chip?.id==`string`&&typeof e.chip.token==`string`))throw Error(`The mission draft contains invalid reference positions.`);if(!o.every(e=>typeof e?.id==`string`&&typeof e.filename==`string`))throw Error(`The mission draft contains invalid attachments.`);let s=r.composer.submission;if(s!==void 0&&(!s||typeof s.signature!=`string`||typeof s.queueId!=`string`||!s.queueId))throw Error(`The mission draft contains an invalid retry identity.`);if(r.scroll!==null&&(!r.scroll||!Number.isFinite(r.scroll.top)||r.scroll.top<0))throw Error(`The mission scroll snapshot is invalid.`);if(!r.workspace||![`codePaneOpen`,`jobsPaneOpen`,`analyticsPaneOpen`,`browserOpen`].every(e=>typeof r.workspace[e]==`boolean`)||!Array.isArray(r.workspace.pendingCaptures))throw Error(`The mission workspace snapshot is incomplete.`);return r}async function ti(e,t){if(!me())throw Error(`Native mission windows are unavailable in this browser.`);return(await c(()=>import(`./core-B3mKBIh5.js`).then(e=>e.i),__vite__mapDeps([0,1]))).invoke(e,t)}var ni={async supported(){if(!me())return!1;try{return await ti(`mission_windows_supported`)===!0}catch{return!1}},async list(){return me()?ti(`mission_windows_list`):[]},async current(e){return me()?ti(`mission_window_current`,e?{windowLabel:e}:void 0):null},detach(e,t){return ti(`mission_window_detach`,{...e,snapshot:t})},ready(e){return ti(`mission_window_ready`,{revision:e})},attach(e){return ti(`mission_window_attach`,{snapshot:e})},ack(e,t){return ti(`mission_window_ack`,{windowLabel:e,revision:t})},async cancel(e,t){me()&&await ti(`mission_window_cancel`,{windowLabel:e,revision:t})},async focus(e){return me()?ti(`mission_window_focus`,{conversationId:e}):!1},async discard(e){me()&&await ti(`mission_window_discard`,{conversationId:e})},async listen(e){if(!me())return()=>{};let{listen:t}=await c(async()=>{let{listen:e}=await import(`./event-Bt7f3wXe.js`).then(e=>e.i);return{listen:e}},__vite__mapDeps([2,1,0]));return t(Qr,t=>e(t.payload))}},ri=class{bridge;secondary;native;state={available:!1,initialized:!1,current:null,transfers:[],pending:[],error:null};listeners=new Set;handlers;unlisten;startPromise;stopped=!1;generation=0;revisions=new Map;changes=new Map;closedRevisions=new Map;restores=new Set;restored=new Set;failedRestores=new Set;mainRestoreActive;restoreAbort=new Map;operations=new Map;discarded=new Set;ownLabel;ownershipKnown=!1;constructor(e,t=!1,n=!0){this.bridge=e,this.secondary=t,this.native=n}getSnapshot=()=>this.state;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));update(e){if(!this.stopped){this.state={...this.state,...e};for(let e of this.listeners)e()}}error(e){this.update({error:e instanceof Error?e.message:String(e)})}clearError=()=>this.update({error:null});pending(e,t){this.update({pending:t?[...new Set([...this.state.pending,e])]:this.state.pending.filter(t=>t!==e)})}isPending=e=>this.state.pending.includes(e)||this.state.transfers.some(t=>t.conversationId===e&&t.state!==`detached`);isEditable=e=>!this.state.initialized&&this.native?!1:this.state.available?!this.ownershipKnown||this.isPending(e)?!1:this.secondary?this.state.current?.conversationId===e&&this.state.current.state===`detached`:!this.state.transfers.some(t=>t.conversationId===e):!this.secondary;registerHandlers=e=>(this.handlers=e,this.failedRestores.clear(),this.restorePending(),()=>{this.handlers===e&&(this.handlers=void 0)});start=()=>{if(this.startPromise)return this.startPromise;this.stopped=!1;let e=++this.generation;return this.startPromise=(async()=>{let t=await this.bridge.supported();if(!(this.stopped||e!==this.generation)){if(this.update({available:t}),t){let t=await this.bridge.listen(this.onEvent);if(this.stopped||e!==this.generation){t();return}this.unlisten=t,await this.refresh()}e===this.generation&&this.update({initialized:!0})}})().catch(t=>{e===this.generation&&(this.error(t),this.update({initialized:!0}))}),this.startPromise};stop=()=>{this.stopped=!0,this.generation++,this.unlisten?.(),this.unlisten=void 0,this.startPromise=void 0;for(let e of this.restoreAbort.values())e.controller.abort()};refresh=async()=>{if(!this.state.available||this.stopped)return;let e=this.generation,t=new Map(this.changes);try{let[n,r]=await Promise.all([this.bridge.list(),this.bridge.current()]);if(this.stopped||e!==this.generation)return;this.ownershipKnown=!0,r&&(this.secondary=!0,this.ownLabel=r.windowLabel);for(let e of n)this.merge(e);r&&this.merge(r);let i=new Set(n.map(e=>e.windowLabel));r&&i.add(r.windowLabel),this.update({transfers:this.state.transfers.filter(e=>i.has(e.windowLabel)||this.changes.get(e.windowLabel)!==t.get(e.windowLabel))}),this.ownLabel&&this.update({current:this.state.transfers.find(e=>e.windowLabel===this.ownLabel)??null});for(let t of this.state.transfers)if(!this.secondary&&t.state===`attaching`&&!t.snapshot){let n=await this.bridge.current(t.windowLabel);if(this.stopped||e!==this.generation)return;n&&this.merge(n)}this.failedRestores.clear(),this.restorePending()}catch(e){this.error(e)}};merge(e){if(this.stopped||!Number.isSafeInteger(e.revision)||e.revision<(this.revisions.get(e.windowLabel)??-1)||e.revision<=(this.closedRevisions.get(e.windowLabel)??-1))return!1;let t=this.state.transfers.find(t=>t.windowLabel===e.windowLabel),n={opening:0,detached:1,attaching:2};if(t?.revision===e.revision&&n[t.state]>n[e.state])return!1;let r=this.restoreAbort.get(e.windowLabel);r&&r.revision!==e.revision&&r.controller.abort(),this.revisions.set(e.windowLabel,e.revision),this.changes.set(e.windowLabel,(this.changes.get(e.windowLabel)??0)+1);let i={...e,snapshot:e.snapshot??(t?.revision===e.revision?t.snapshot:void 0)};return this.update({transfers:[...this.state.transfers.filter(t=>t.windowLabel!==e.windowLabel),i],...this.ownLabel===e.windowLabel?{current:i}:{}}),!0}remove(e){e.revision<(this.revisions.get(e.windowLabel)??-1)||(this.revisions.set(e.windowLabel,e.revision),this.changes.set(e.windowLabel,(this.changes.get(e.windowLabel)??0)+1),this.closedRevisions.set(e.windowLabel,e.revision),this.restoreAbort.get(e.windowLabel)?.controller.abort(),this.update({transfers:this.state.transfers.filter(t=>t.windowLabel!==e.windowLabel),...this.ownLabel===e.windowLabel?{current:null}:{}}))}onEvent=e=>{if(this.stopped)return;let t=e.transfer;if(!(t.revision<(this.revisions.get(t.windowLabel)??-1)||t.revision<=(this.closedRevisions.get(t.windowLabel)??-1))){if(e.kind===`failed`&&e.registered===!1&&!this.secondary&&t.snapshot)try{let e=ei(t.snapshot,t);qr(t.conversationId,e.composer),this.handlers?.recover?.(e,t)}catch{}e.kind===`attached`||e.kind===`discarded`||e.kind===`failed`&&e.registered===!1?this.remove(t):e.kind!==`attach-requested`&&this.merge(t),e.kind===`failed`&&(this.pending(t.conversationId,!1),this.error(e.error??`The mission window transfer failed. Your draft is preserved.`),e.registered===void 0&&this.refresh()),e.kind===`discarded`&&(this.discarded.add(t.conversationId),this.clearDraft(t.conversationId)),e.kind===`attach-requested`&&this.ownLabel===t.windowLabel&&this.attach(),this.restorePending()}};restorePending(){if(!(!this.handlers||this.stopped))if(this.secondary){let e=this.state.current;e&&(e.state===`opening`||e.state===`detached`)&&this.restore(e,e.state===`opening`?`ready`:`reload`)}else{if(this.mainRestoreActive)return;let e=this.state.transfers.find(e=>{let t=`${e.windowLabel}:${e.revision}:ack`;return e.state===`attaching`&&e.snapshot&&!this.restored.has(t)&&!this.failedRestores.has(t)});e&&this.restore(e,`ack`)}}async restore(e,t){let n=`${e.windowLabel}:${e.revision}:${t}`;if(!this.handlers||this.restores.has(n)||this.restored.has(n)||this.failedRestores.has(n)||t===`reload`&&this.restores.has(`${e.windowLabel}:${e.revision}:ready`))return;this.restores.add(n),t===`ack`&&(this.mainRestoreActive=n),this.pending(e.conversationId,!0);let r=this.handlers,i=new AbortController;this.restoreAbort.set(e.windowLabel,{revision:e.revision,controller:i});try{let a=ei(e.snapshot,e);if(t===`reload`&&(Yr(e.conversationId),Kr(e.conversationId)&&(a.composer=Gr(e.conversationId))),qr(e.conversationId,a.composer),await r.restore(a,e,i.signal),i.signal.aborted||this.stopped||this.revisions.get(e.windowLabel)!==e.revision||this.closedRevisions.get(e.windowLabel)===e.revision)return;t===`ready`?this.merge(await this.bridge.ready(e.revision)):t===`ack`&&this.remove(await this.bridge.ack(e.windowLabel,e.revision)),this.restored.add(n),t===`ready`&&this.restored.add(`${e.windowLabel}:${e.revision}:reload`)}catch(r){if(i.signal.aborted)return;if(this.failedRestores.add(n),this.error(r),t!==`reload`)try{await this.bridge.cancel(e.windowLabel,e.revision)}catch{}}finally{this.restores.delete(n),this.restoreAbort.get(e.windowLabel)?.controller===i&&(this.restoreAbort.delete(e.windowLabel),this.pending(e.conversationId,!1)),this.mainRestoreActive===n&&(this.mainRestoreActive=void 0,this.restorePending())}}detach=(e,t)=>this.operate(t,async()=>{if(!this.state.available||this.secondary)return!1;if(this.state.transfers.find(e=>e.conversationId===t))return this.bridge.focus(t);if(!this.handlers)throw Error(`The mission view is not ready to move yet.`);let n={projectId:e,conversationId:t},r=ei(await this.handlers.capture(n),n);return this.discarded.has(t)||this.stopped?!1:(qr(t,r.composer),this.merge(await this.bridge.detach(n,r)),!0)});attach=()=>{let e=this.state.current;return!this.state.available||!this.secondary||!e?Promise.resolve(!1):this.operate(e.conversationId,async()=>{if(e.state===`attaching`)return!0;if(e.state!==`detached`||!this.handlers)throw Error(`The mission view is not ready to move yet.`);let t=ei(await this.handlers.capture(e),e);return this.discarded.has(e.conversationId)||this.stopped?!1:(qr(e.conversationId,t.composer),this.merge(await this.bridge.attach(t)),!0)})};operate(e,t){let n=this.operations.get(e);if(n)return n;this.pending(e,!0),this.clearError();let r=Promise.resolve().then(t).catch(t=>(this.discarded.has(e)||Jr(e),this.error(t),!1)).finally(()=>{this.operations.get(e)===r&&this.operations.delete(e),this.pending(e,!1)});return this.operations.set(e,r),r}focus=e=>this.state.available?this.bridge.focus(e).catch(e=>(this.error(e),!1)):Promise.resolve(!1);clearDraft(e){Tr.delete(e),Er.delete(e),Dr.delete(e),Or.delete(e),Xr(e),this.pending(e,!1)}discard=async e=>{try{this.state.available&&await this.bridge.discard(e),this.discarded.add(e);let t=this.state.transfers.find(t=>t.conversationId===e);return t&&this.remove(t),this.clearDraft(e),!0}catch(e){return this.error(e),!1}}},$=o(),ii=()=>{},ai=(0,Q.createContext)({available:!1,initialized:!0,current:null,transfers:[],pending:[],error:null,registerHandlers:()=>ii,detach:async()=>!1,attach:async()=>!1,focus:async()=>!1,discard:async()=>!1,isEditable:()=>!0,isPending:()=>!1,clearError:ii,refresh:async()=>{}});function oi({children:e,bridge:t=ni,secondary:n=$r()}){let[r]=(0,Q.useState)(()=>new ri(t,n,me()||t!==ni)),i=(0,Q.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot);(0,Q.useEffect)(()=>{r.start();let e=()=>{r.refresh()};return window.addEventListener(`focus`,e),()=>{window.removeEventListener(`focus`,e),r.stop()}},[r]);let a=(0,Q.useMemo)(()=>({...i,registerHandlers:r.registerHandlers,detach:r.detach,attach:r.attach,focus:r.focus,isEditable:r.isEditable,isPending:r.isPending,discard:r.discard,clearError:r.clearError,refresh:r.refresh}),[i,r]);return(0,$.jsx)(ai.Provider,{value:a,children:e})}function si(){return(0,Q.useContext)(ai)}var ci=i(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this.register(this._terminal.onResize((e=>this._handleResize(e.rows)))),this.register(this._terminal.onRender((e=>this._refreshRows(e.start,e.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((e=>this._handleChar(e)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
11
+ `)))),this.register(this._terminal.onA11yTab((e=>this._handleTab(e)))),this.register(this._terminal.onKey((e=>this._handleKey(e.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,u.addDisposableDomListener)(document,`selectionchange`,(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,s.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
12
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.innerText=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error(`anchorNode and/or focusNode are null`);let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};t.AccessibilityManager=d=r([i(1,l.IInstantiationService),i(2,c.ICoreBrowserService),i(3,c.IRenderService)],d)},3614:(e,t)=>{function n(e){return e.replace(/\r?\n/g,`\r`)}function r(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function i(e,t,i,a){e=r(e=n(e),i.decPrivateModes.bracketedPasteMode&&!0!==a.rawOptions.ignoreBracketedPasteMode),i.triggerDataEvent(e,!0),t.value=``}function a(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}Object.defineProperty(t,"__esModule",{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=n,t.bracketTextForPaste=r,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,n,r){e.stopPropagation(),e.clipboardData&&i(e.clipboardData.getData(`text/plain`),t,n,r)},t.paste=i,t.moveTextAreaUnderMouseCursor=a,t.rightClickHandler=function(e,t,n,r,i){a(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}},7239:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;let r=n(1505);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},3656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,n,r){e.addEventListener(t,n,r);let i=!1;return{dispose:()=>{i||(i=!0,e.removeEventListener(t,n,r))}}}},3551:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Linkifier=void 0;let a=n(3656),o=n(8460),s=n(844),c=n(2585),l=n(4725),u=t.Linkifier=class extends s.Disposable{get currentLink(){return this._currentLink}constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new o.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new o.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,s.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,s.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,a.addDisposableDomListener)(this._element,`mouseleave`,(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,`mousemove`,this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mousedown`,this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mouseup`,this._handleMouseUp.bind(this)))}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(e,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach((e=>{e?.forEach((e=>{e.link.dispose&&e.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,(t=>{if(this._isMouseOut)return;let i=t?.map((e=>({link:e})));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)}))}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)this._activeProviderReplies.has(t)&&!this._activeProviderReplies.get(t)||(i=!0);if(!i&&r){let e=r.find((e=>this._linkAtPosition(e.link,t)));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find((e=>this._linkAtPosition(e.link,t)));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,s.disposeArray)(this._linkCacheDisposables))}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}}))))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};t.Linkifier=u=r([i(1,l.IMouseService),i(2,l.IRenderService),i(3,c.IBufferService),i(4,l.ILinkProviderService)],u)},9042:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel=`Terminal input`,t.tooMuchOutput=`Too much output to announce, navigate to rows manually to read`},3730:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkProvider=void 0;let a=n(511),o=n(2585),s=t.OscLinkProvider=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n)return void t(void 0);let r=[],i=this._optionsService.rawOptions.linkHandler,o=new a.CellData,s=n.getTrimmedLength(),l=-1,u=-1,d=!1;for(let t=0;t<s;t++)if(u!==-1||n.hasContent(t)){if(n.loadCell(t,o),o.hasExtendedAttrs()&&o.extended.urlId){if(u===-1){u=t,l=o.extended.urlId;continue}d=o.extended.urlId!==l}else u!==-1&&(d=!0);if(d||u!==-1&&t===s-1){let n=this._oscLinkService.getLinkData(l)?.uri;if(n){let a={start:{x:u+1,y:e},end:{x:t+(d||t!==s-1?0:1),y:e}},o=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(o=!0)}catch{o=!0}o||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):c(0,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(u=t,l=o.extended.urlId):(u=-1,l=-1)}}t(r)}};function c(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}t.OscLinkProvider=s=r([i(0,o.IBufferService),i(1,o.IOptionsService),i(2,o.IOscLinkService)],s)},6193:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RenderDebouncer=void 0,t.RenderDebouncer=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}}},3236:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;let r=n(3614),i=n(3656),a=n(3551),o=n(9042),s=n(3730),c=n(1680),l=n(3107),u=n(5744),d=n(2950),f=n(1296),p=n(428),m=n(4269),h=n(5114),g=n(8934),_=n(3230),v=n(9312),y=n(4725),b=n(6731),x=n(8055),S=n(8969),C=n(8460),w=n(844),T=n(6114),E=n(8437),D=n(2584),O=n(7399),k=n(5941),A=n(9074),j=n(2585),M=n(5435),N=n(4567),P=n(779);class F extends S.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(e={}){super(e),this.browser=T,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new w.MutableDisposable),this._onCursorMove=this.register(new C.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new C.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new C.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new C.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new C.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new C.EventEmitter),this._onBlur=this.register(new C.EventEmitter),this._onA11yCharEmitter=this.register(new C.EventEmitter),this._onA11yTabEmitter=this.register(new C.EventEmitter),this._onWillOpen=this.register(new C.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(A.DecorationService),this._instantiationService.setService(j.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(P.LinkProviderService),this._instantiationService.setService(y.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(s.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((e,t)=>this.refresh(e,t)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((e=>this._reportWindowsOptions(e)))),this.register(this._inputHandler.onColor((e=>this._handleColorEvent(e)))),this.register((0,C.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,C.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((e=>this._afterResize(e.cols,e.rows)))),this.register((0,w.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=x.color.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${D.C0.ESC}]${n};${(0,k.toRgbString)(r)}${D.C1_ESCAPED.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors((e=>e.ansi[t.index]=x.channels.toColor(...t.color)));else{let n=e;this._themeService.modifyColors((e=>e[n]=x.channels.toColor(...t.color)))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(N.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this.register((0,i.addDisposableDomListener)(this.element,`copy`,(e=>{this.hasSelection()&&(0,r.copyHandler)(e,this._selectionService)})));let e=e=>(0,r.handlePasteEvent)(e,this.textarea,this.coreService,this.optionsService);this.register((0,i.addDisposableDomListener)(this.textarea,`paste`,e)),this.register((0,i.addDisposableDomListener)(this.element,`paste`,e)),T.isFirefox?this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>{e.button===2&&(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,i.addDisposableDomListener)(this.element,`contextmenu`,(e=>{(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),T.isLinux&&this.register((0,i.addDisposableDomListener)(this.element,`auxclick`,(e=>{e.button===1&&(0,r.moveTextAreaUnderMouseCursor)(e,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,i.addDisposableDomListener)(this.textarea,`keyup`,(e=>this._keyUp(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keydown`,(e=>this._keyDown(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keypress`,(e=>this._keyPress(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionstart`,(()=>this._compositionHelper.compositionstart()))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionupdate`,(e=>this._compositionHelper.compositionupdate(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionend`,(()=>this._compositionHelper.compositionend()))),this.register((0,i.addDisposableDomListener)(this.textarea,`input`,(e=>this._inputEvent(e)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement(`div`),this._viewportScrollArea.classList.add(`xterm-scroll-area`),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this.register((0,i.addDisposableDomListener)(this.screenElement,`mousemove`,(e=>this.updateCursorStyle(e)))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement),this.textarea=this._document.createElement(`textarea`),this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,o.promptLabel),T.isChromeOS||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(h.CoreBrowserService,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(y.ICoreBrowserService,this._coreBrowserService),this.register((0,i.addDisposableDomListener)(this.textarea,`focus`,(e=>this._handleTextAreaFocus(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`blur`,(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(p.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(y.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(b.ThemeService),this._instantiationService.setService(y.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(m.CharacterJoinerService),this._instantiationService.setService(y.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(_.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(y.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((e=>this._onRender.fire(e)))),this.onResize((e=>this._renderService.resize(e.cols,e.rows))),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(g.MouseService),this._instantiationService.setService(y.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(a.Linkifier,this.screenElement)),this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(c.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(v.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(y.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((e=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,i.addDisposableDomListener)(this._viewportElement,`scroll`,(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>this._selectionService.handleMouseDown(e)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(N.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,(e=>this._handleScreenReaderModeOptionChange(e)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRulerWidth`,(e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(f.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=1&t.buttons?0:4&t.buttons?1:2&t.buttons?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(t)||e.viewport.getLinesScrolled(t)===0)return!1;i=t.deltaY<0?0:1,r=4;break;default:return!1}return!(i===void 0||r===void 0||r>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this.register(this.coreMouseService.onProtocolChange((e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),8&e?r.mousemove||=(t.addEventListener(`mousemove`,a.mousemove),a.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),16&e?r.wheel||=(t.addEventListener(`wheel`,a.wheel,{passive:!1}),a.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),2&e?r.mouseup||=a.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),4&e?r.mousedrag||=a.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,i.addDisposableDomListener)(t,`mousedown`,(e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)}))),this.register((0,i.addDisposableDomListener)(t,`wheel`,(e=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(e))return!1;if(!this.buffer.hasScrollback){let t=this.viewport.getLinesScrolled(e);if(t===0)return;let n=D.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(e.deltaY<0?`A`:`B`),r=``;for(let e=0;e<Math.abs(t);e++)r+=n;return this.coreService.triggerDataEvent(r,!0),this.cancel(e,!0)}return this.viewport.handleWheel(e)?this.cancel(e):void 0}}),{passive:!1})),this.register((0,i.addDisposableDomListener)(t,`touchstart`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(e),this.cancel(e)}),{passive:!0})),this.register((0,i.addDisposableDomListener)(t,`touchmove`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(e)?void 0:this.cancel(e)}),{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t,n=0){n===1?(super.scrollLines(e,t,n),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(e)}paste(e){(0,r.paste)(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=(0,O.evaluateKeyboardEvent)(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}return n.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key||!!(e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(n.key!==D.C0.ETX&&n.key!==D.C0.CR||(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey?this.cancel(e,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else{if(e.which===0||e.charCode===0)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(E.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(D.C0.ESC+`[I`):this.coreService.triggerDataEvent(D.C0.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case M.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[4;${t};${e}t`);break;case M.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}}t.Terminal=F},9924:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeBasedDebouncer=void 0,t.TimeBasedDebouncer=class{constructor(e,t=1e3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=Date.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}}},1680:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Viewport=void 0;let a=n(3656),o=n(4725),s=n(8460),c=n(844),l=n(2585),u=t.Viewport=class extends c.Disposable{constructor(e,t,n,r,i,o,c,l){super(),this._viewportElement=e,this._scrollArea=t,this._bufferService=n,this._optionsService=r,this._charSizeService=i,this._renderService=o,this._coreBrowserService=c,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new s.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,`scroll`,this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((e=>this._renderDimensions=e))),this._handleThemeChange(l.colors),this.register(l.onChangeColors((e=>this._handleThemeChange(e)))),this.register(this._optionsService.onSpecificOptionChange(`scrollback`,(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(e){this._viewportElement.style.backgroundColor=e.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(e){if(e)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;let e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+`px`)}let e=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==e&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=e),this._refreshAnimationFrame=null}syncScrollArea(e=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(e)}_handleScroll(e){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});let t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;let e=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(e*(this._smoothScrollState.target-this._smoothScrollState.origin)),e<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(e,t){let n=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&this._viewportElement.scrollTop!==0||t>0&&n<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)}handleWheel(e){let t=this._getPixelsScrolled(e);return t!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+t:this._smoothScrollState.target+=t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}scrollLines(e){if(e!==0)if(this._optionsService.rawOptions.smoothScrollDuration){let t=e*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!1})}_getPixelsScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t}getBufferElements(e,t){let n,r=``,i=[],a=t??this._bufferService.buffer.lines.length,o=this._bufferService.buffer.lines;for(let t=e;t<a;t++){let e=o.get(t);if(!e)continue;let a=o.get(t+1)?.isWrapped;if(r+=e.translateToString(!a),!a||t===o.length-1){let e=document.createElement(`div`);e.textContent=r,i.push(e),r.length>0&&(n=e),r=``}}return{bufferElements:i,cursorElement:n}}getLinesScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t}_applyScrollModifier(e,t){let n=this._optionsService.rawOptions.fastScrollModifier;return n===`alt`&&t.altKey||n===`ctrl`&&t.ctrlKey||n===`shift`&&t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(e){this._lastTouchY=e.touches[0].pageY}handleTouchMove(e){let t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,t!==0&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}};t.Viewport=u=r([i(2,l.IBufferService),i(3,l.IOptionsService),i(4,o.ICharSizeService),i(5,o.IRenderService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],u)},3107:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferDecorationRenderer=void 0;let a=n(4725),o=n(844),s=n(2585),c=t.BufferDecorationRenderer=class extends o.Disposable{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((e=>this._removeDecoration(e)))),this.register((0,o.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+`px`,t.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+`px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose((()=>{this._decorationElements.delete(e),n.remove()}))),n.style.top=t*this._renderService.dimensions.css.cell.height+`px`,n.style.display=this._altBufferIsActive?`none`:`block`,e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?n*this._renderService.dimensions.css.cell.width+`px`:``:t.style.left=n?n*this._renderService.dimensions.css.cell.width+`px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};t.BufferDecorationRenderer=c=r([i(1,s.IBufferService),i(2,a.ICoreBrowserService),i(3,s.IDecorationService),i(4,a.IRenderService)],c)},5871:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorZoneStore=void 0,t.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}}},5744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OverviewRulerRenderer=void 0;let a=n(5871),o=n(4725),s=n(844),c=n(2585),l={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},f=t.OverviewRulerRenderer=class extends s.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(e,t,n,r,i,o,c){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=o,this._coreBrowserService=c,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);let l=this._canvas.getContext(`2d`);if(!l)throw Error(`Ctx cannot be null`);this._ctx=l,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,s.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange(`overviewRulerWidth`,(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){let e=Math.floor(this._canvas.width/3),t=Math.ceil(this._canvas.width/3);u.full=this._canvas.width,u.left=e,u.center=t,u.right=e,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);l.left=t,l.center=t,l.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1;let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(d[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-l[e.position||`full`]/2),u[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};t.OverviewRulerRenderer=f=r([i(2,c.IBufferService),i(3,c.IDecorationService),i(4,o.IRenderService),i(5,c.IOptionsService),i(6,o.ICoreBrowserService)],f)},2950:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompositionHelper=void 0;let a=n(4725),o=n(2585),s=n(2584),c=t.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,e.end):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${s.C0.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}}),0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};t.CompositionHelper=c=r([i(2,o.IBufferService),i(3,o.IOptionsService),i(4,o.ICoreService),i(5,a.IRenderService)],c)},9806:(e,t)=>{function n(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}Object.defineProperty(t,"__esModule",{value:!0}),t.getCoords=t.getCoordsRelativeToElement=void 0,t.getCoordsRelativeToElement=n,t.getCoords=function(e,t,r,i,a,o,s,c,l){if(!o)return;let u=n(e,t,r);return u?(u[0]=Math.ceil((u[0]+(l?s/2:0))/s),u[1]=Math.ceil(u[1]/c),u[0]=Math.min(Math.max(u[0],1),i+ +!!l),u[1]=Math.min(Math.max(u[1],1),a),u):void 0}},9504:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.moveToCellSequence=void 0;let r=n(2584);function i(e,t,n,r){let i=e-a(e,n),s=t-a(t,n);return l(Math.abs(i-s)-function(e,t,n){let r=0,i=e-a(e,n),s=t-a(t,n);for(let a=0;a<Math.abs(i-s);a++){let s=o(e,t)===`A`?-1:1;n.buffer.lines.get(i+s*a)?.isWrapped&&r++}return r}(e,t,n),c(o(e,t),r))}function a(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function o(e,t){return e>t?`A`:`B`}function s(e,t,n,r,i,a){let o=e,s=t,c=``;for(;o!==n||s!==r;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function c(e,t){let n=t?`O`:`[`;return r.C0.ESC+n+e}function l(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}t.moveToCellSequence=function(e,t,n,r){let o=n.buffer.x,u=n.buffer.y;if(!n.buffer.hasScrollback)return function(e,t,n,r,o,u){return i(t,r,o,u).length===0?``:l(s(e,t,e,t-a(t,o),!1,o).length,c(`D`,u))}(o,u,0,t,n,r)+i(u,t,n,r)+function(e,t,n,r,o,u){let d;d=i(t,r,o,u).length>0?r-a(r,o):t;let f=r,p=function(e,t,n,r,o,s){let c;return c=i(n,r,o,s).length>0?r-a(r,o):t,e<n&&c<=r||e>=n&&c<r?`C`:`D`}(e,t,n,r,o,u);return l(s(e,d,n,f,p===`C`,o).length,c(p,u))}(o,u,e,t,n,r);let d;if(u===t)return d=o>e?`D`:`C`,l(Math.abs(o-e),c(d,r));d=u>t?`D`:`C`;let f=Math.abs(u-t);return l(function(e,t){return t.cols-e}(u>t?e:o,n)+(f-1)*n.cols+1+((u>t?o:e)-1),c(d,r))}},1296:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRenderer=void 0;let a=n(3787),o=n(2550),s=n(2223),c=n(6171),l=n(6052),u=n(4725),d=n(8055),f=n(8460),p=n(844),m=n(2585),h=`xterm-dom-renderer-owner-`,g=`xterm-rows`,_=`xterm-fg-`,v=`xterm-bg-`,y=`xterm-focus`,b=`xterm-selection`,x=1,S=t.DomRenderer=class extends p.Disposable{constructor(e,t,n,r,i,s,u,d,m,_,v,y,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=s,this._linkifier2=u,this._charSizeService=m,this._optionsService=_,this._bufferService=v,this._coreBrowserService=y,this._themeService=S,this._terminalClass=x++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(g),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(b),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=(0,c.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((e=>this._injectCss(e)))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(h+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((e=>this._handleLinkHover(e)))),this.register(this._linkifier2.onHideLinkUnderline((e=>this._handleLinkLeave(e)))),this.register((0,p.toDisposable)((()=>{this._element.classList.remove(h+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new o.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${g} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${g} { color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${g} .xterm-dim { color: ${d.color.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${b} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${b} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${b} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${_}${n} { color: ${r.css}; }${this._terminalSelector} .${_}${n}.xterm-dim { color: ${d.color.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${v}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR} { color: ${d.color.opaque(e.background).css}; }${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${d.color.multiplyOpacity(d.color.opaque(e.background),.5).css}; }${this._terminalSelector} .${v}${s.INVERTED_DEFAULT_COLOR} { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t)return;this._selectionRenderModel.update(this._terminal,e,t,n);let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow;if(a>=this._bufferService.rows||o<0)return;let s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=r*this.dimensions.css.cell.height+`px`,i.style.top=e*this.dimensions.css.cell.height+`px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._optionsService.rawOptions.cursorBlink,o=this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${h}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};t.DomRenderer=S=r([i(7,m.IInstantiationService),i(8,u.ICharSizeService),i(9,m.IOptionsService),i(10,m.IBufferService),i(11,u.ICoreBrowserService),i(12,u.IThemeService)],S)},3787:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRendererRowFactory=void 0;let a=n(2223),o=n(643),s=n(511),c=n(2585),l=n(8055),u=n(4725),d=n(4269),f=n(6171),p=n(3734),m=t.DomRendererRowFactory=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new s.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,s,c,u,f,m,g){let _=[],v=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,b,x=e.getNoBgTrimmedLength();n&&x<s+1&&(x=s+1);let S=0,C=``,w=0,T=0,E=0,D=!1,O=0,k=!1,A=0,j=[],M=m!==-1&&g!==-1;for(let N=0;N<x;N++){e.loadCell(N,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let P=!1,F=N,I=this._workCell;if(v.length>0&&N===v[0][0]){P=!0;let t=v.shift();I=new d.JoinedCellData(this._workCell,e.translateToString(!0,t[0],t[1]),t[1]-t[0]),F=t[1]-1,x=I.getWidth()}let L=this._isCellInSelection(N,t),R=n&&N===s,z=M&&N>=m&&N<=g,B=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,(e=>{B=!0}));let ee=I.getChars()||o.WHITESPACE_CELL_CHAR;if(ee===` `&&(I.isUnderline()||I.isOverline())&&(ee=`\xA0`),A=x*u-f.get(ee,I.isBold(),I.isItalic()),b){if(S&&(L&&k||!L&&!k&&I.bg===w)&&(L&&k&&y.selectionForeground||I.fg===T)&&I.extended.ext===E&&z===D&&A===O&&!R&&!P&&!B){I.isInvisible()?C+=o.WHITESPACE_CELL_CHAR:C+=ee,S++;continue}S&&(b.textContent=C),b=this._document.createElement(`span`),S=0,C=``}else b=this._document.createElement(`span`);if(w=I.bg,T=I.fg,E=I.extended.ext,D=z,O=A,k=L,P&&s>=N&&s<=F&&(s=N),!this._coreService.isCursorHidden&&R&&this._coreService.isCursorInitialized){if(j.push(`xterm-cursor`),this._coreBrowserService.isFocused)c&&j.push(`xterm-cursor-blink`),j.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:j.push(`xterm-cursor-outline`);break;case`block`:j.push(`xterm-cursor-block`);break;case`bar`:j.push(`xterm-cursor-bar`);break;case`underline`:j.push(`xterm-cursor-underline`)}}if(I.isBold()&&j.push(`xterm-bold`),I.isItalic()&&j.push(`xterm-italic`),I.isDim()&&j.push(`xterm-dim`),C=I.isInvisible()?o.WHITESPACE_CELL_CHAR:I.getChars()||o.WHITESPACE_CELL_CHAR,I.isUnderline()&&(j.push(`xterm-underline-${I.extended.underlineStyle}`),C===` `&&(C=`\xA0`),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${p.AttributeData.toColorRGB(I.getUnderlineColor()).join(`,`)})`;else{let e=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&e<8&&(e+=8),b.style.textDecorationColor=y.ansi[e].css}I.isOverline()&&(j.push(`xterm-overline`),C===` `&&(C=`\xA0`)),I.isStrikethrough()&&j.push(`xterm-strikethrough`),z&&(b.style.textDecoration=`underline`);let V=I.getFgColor(),H=I.getFgColorMode(),te=I.getBgColor(),ne=I.getBgColorMode(),re=!!I.isInverse();if(re){let e=V;V=te,te=e;let t=H;H=ne,ne=t}let ie,ae,oe,se=!1;switch(this._decorationService.forEachDecorationAtCell(N,t,void 0,(e=>{e.options.layer!==`top`&&se||(e.backgroundColorRGB&&(ne=50331648,te=e.backgroundColorRGB.rgba>>8&16777215,ie=e.backgroundColorRGB),e.foregroundColorRGB&&(H=50331648,V=e.foregroundColorRGB.rgba>>8&16777215,ae=e.foregroundColorRGB),se=e.options.layer===`top`)})),!se&&L&&(ie=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,te=ie.rgba>>8&16777215,ne=50331648,se=!0,y.selectionForeground&&(H=50331648,V=y.selectionForeground.rgba>>8&16777215,ae=y.selectionForeground)),se&&j.push(`xterm-decoration-top`),ne){case 16777216:case 33554432:oe=y.ansi[te],j.push(`xterm-bg-${te}`);break;case 50331648:oe=l.channels.toColor(te>>16,te>>8&255,255&te),this._addStyle(b,`background-color:#${h((te>>>0).toString(16),`0`,6)}`);break;default:re?(oe=y.foreground,j.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):oe=y.background}switch(ie||I.isDim()&&(ie=l.color.multiplyOpacity(oe,.5)),H){case 16777216:case 33554432:I.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(b,oe,y.ansi[V],I,ie,void 0)||j.push(`xterm-fg-${V}`);break;case 50331648:let e=l.channels.toColor(V>>16&255,V>>8&255,255&V);this._applyMinimumContrast(b,oe,e,I,ie,ae)||this._addStyle(b,`color:#${h(V.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(b,oe,y.foreground,I,ie,ae)||re&&j.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}j.length&&=(b.className=j.join(` `),0),R||P||B?b.textContent=C:S++,A!==this.defaultSpacing&&(b.style.letterSpacing=`${A}px`),_.push(b),N=F}return b&&S&&(b.textContent=C),_}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,f.treatGlyphAsBackgroundColor)(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(i||a||(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=l.color.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return!!s&&(this._addStyle(e,`color:${s.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!(!n||!r)&&(this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0])}};function h(e,t,n){for(;e.length<n;)e=t+e;return e}t.DomRendererRowFactory=m=r([i(1,u.ICharacterJoinerService),i(2,c.IOptionsService),i(3,u.ICoreBrowserService),i(4,c.ICoreService),i(5,c.IDecorationService),i(6,u.IThemeService)],m)},2550:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WidthCache=void 0,t.WidthCache=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}}},2223:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;let r=n(6114);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=r.isFirefox||r.isLegacyEdge?`bottom`:`ideographic`},6171:(e,t)=>{function n(e){return 57508<=e&&e<=57558}function r(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}Object.defineProperty(t,"__esModule",{value:!0}),t.computeNextVariantOffset=t.createRenderDimensions=t.treatGlyphAsBackgroundColor=t.allowRescaling=t.isEmoji=t.isRestrictedPowerlineGlyph=t.isPowerlineGlyph=t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw Error(`value must not be falsy`);return e},t.isPowerlineGlyph=n,t.isRestrictedPowerlineGlyph=function(e){return 57520<=e&&e<=57527},t.isEmoji=r,t.allowRescaling=function(e,t,i,a){return t===1&&i>Math.ceil(1.5*a)&&e!==void 0&&e>255&&!r(e)&&!n(e)&&!function(e){return 57344<=e&&e<=63743}(e)},t.treatGlyphAsBackgroundColor=function(e){return n(e)||function(e){return 9472<=e&&e<=9631}(e)},t.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},t.computeNextVariantOffset=function(e,t,n=0){return(e-(2*Math.round(t)-n))%(2*Math.round(t))}},6052:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createSelectionRenderModel=void 0;class n{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1])return void this.clear();let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return!!this.hasSelection&&(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol)}}t.createSelectionRenderModel=function(){return new n}},456:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionModel=void 0,t.SelectionModel=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharSizeService=void 0;let a=n(2585),o=n(8460),s=n(844),c=t.CharSizeService=class extends s.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this.register(new o.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new d(this._optionsService))}catch{this._measureStrategy=this.register(new u(e,t,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],(()=>this.measure())))}measure(){let e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};t.CharSizeService=c=r([i(2,a.IOptionsService)],c);class l extends s.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}}class u extends l{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class d extends l{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}}},4269:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharacterJoinerService=t.JoinedCellData=void 0;let a=n(3734),o=n(643),s=n(511),c=n(2585);class l extends a.AttributeData{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.JoinedCellData=l;let u=t.CharacterJoinerService=class e{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new s.CellData}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,s=0,c=t.getFg(0),l=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==l){if(e-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,s=a,c=this._workCell.fg,l=this._workCell.bg}a+=this._workCell.getChars().length||o.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(t,n,r,i,a){let o=t.substring(n,r),s=[];try{s=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let t=1;t<this._characterJoiners.length;t++)try{let n=this._characterJoiners[t].handler(o);for(let t=0;t<n.length;t++)e._mergeRanges(s,n[t])}catch(e){console.error(e)}return this._stringRangesToCellRanges(s,i,a),s}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,s=e[r];if(s){for(let c=n;c<this._bufferService.cols;c++){let n=t.getWidth(c),l=t.getString(c).length||o.WHITESPACE_CELL_CHAR.length;if(n!==0){if(!i&&s[0]<=a&&(s[0]=c,i=!0),s[1]<=a){if(s[1]=c,s=e[++r],!s)break;s[0]<=a?(s[0]=c,i=!0):i=!1}a+=l}}s&&(s[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0)}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};t.CharacterJoinerService=u=r([i(0,c.IBufferService)],u)},5114:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreBrowserService=void 0;let r=n(844),i=n(8460),a=n(3656);class o extends r.Disposable{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new s(this._window),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new i.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,i.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener(`focus`,(()=>this._isFocused=!0)),this._textarea.addEventListener(`blur`,(()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}t.CoreBrowserService=o;class s extends r.Disposable{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this.register(new r.MutableDisposable),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,r.toDisposable)((()=>this.clearListener())))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,a.addDisposableDomListener)(this._parentWindow,`resize`,(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkProviderService=void 0;let r=n(844);class i extends r.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,r.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}}t.LinkProviderService=i},8934:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseService=void 0;let a=n(4725),o=n(9806),s=t.MouseService=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return(0,o.getCoords)(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=(0,o.getCoordsRelativeToElement)(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};t.MouseService=s=r([i(0,a.IRenderService),i(1,a.ICharSizeService)],s)},3230:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.RenderService=void 0;let a=n(6193),o=n(4725),s=n(8460),c=n(844),l=n(7226),u=n(2585),d=t.RenderService=class extends c.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,t,n,r,i,o,u,d){super(),this._rowCount=e,this._charSizeService=r,this._renderer=this.register(new c.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new c.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new s.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new s.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new s.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new s.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new a.RenderDebouncer(((e,t)=>this._renderRows(e,t)),u),this.register(this._renderDebouncer),this.register(u.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(o.onResize((()=>this._fullRefresh()))),this.register(o.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(n.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(i.onDecorationRegistered((()=>this._fullRefresh()))),this.register(i.onDecorationRemoved((()=>this._fullRefresh()))),this.register(n.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],(()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()}))),this.register(n.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],(()=>this.refreshRows(o.buffer.y,o.buffer.y,!0)))),this.register(d.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(u.window,t),this.register(u.onWindowChange((e=>this._registerIntersectionObserver(e,t))))}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver((e=>this._handleIntersectionChange(e[e.length-1])),{threshold:0});n.observe(t),this._observerDisposable.value=(0,c.toDisposable)((()=>n.disconnect()))}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){this._isPaused?this._needsFullRefresh=!0:(n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount))}_renderRows(e,t){this._renderer.value&&(e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0)}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw((e=>this.refreshRows(e.start,e.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,t))):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};t.RenderService=d=r([i(2,u.IOptionsService),i(3,o.ICharSizeService),i(4,u.IDecorationService),i(5,u.IBufferService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],d)},9312:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionService=void 0;let a=n(9806),o=n(9504),s=n(456),c=n(4725),l=n(8460),u=n(844),d=n(6114),f=n(4841),p=n(511),m=n(2585),h=RegExp(`\xA0`,`g`),g=t.SelectionService=class extends u.Disposable{constructor(e,t,n,r,i,a,o,c,d){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=c,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new p.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((e=>this._handleTrim(e))),this.register(this._bufferService.buffers.onBufferActivate((e=>this._handleBufferActivate(e)))),this.enable(),this._model=new s.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,u.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t||e[0]===t[0]&&e[1]===t[1])}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map((e=>e.replace(h,` `))).join(d.isWindows?`\r
13
+ `:`
14
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh())),d.isLinux&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!(n&&r&&t)&&this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!(!n||!r)&&this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=(0,f.getRangeLength)(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return!!r&&(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=(0,a.getCoordsRelativeToElement)(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-50),50),t/=50,t/Math.abs(t)+Math.round(14*t))}shouldForceSelection(e){return d.isMac?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,(e.button!==2||!this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=(0,o.moveToCellSequence)(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);n?e&&t&&(this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n)):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim((e=>this._handleTrim(e)))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,f.getRangeLength)(n,this._bufferService.cols)}};t.SelectionService=g=r([i(3,m.IBufferService),i(4,m.ICoreService),i(5,c.IMouseService),i(6,m.IOptionsService),i(7,c.IRenderService),i(8,c.ICoreBrowserService)],g)},4725:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ILinkProviderService=t.IThemeService=t.ICharacterJoinerService=t.ISelectionService=t.IRenderService=t.IMouseService=t.ICoreBrowserService=t.ICharSizeService=void 0;let r=n(8343);t.ICharSizeService=(0,r.createDecorator)(`CharSizeService`),t.ICoreBrowserService=(0,r.createDecorator)(`CoreBrowserService`),t.IMouseService=(0,r.createDecorator)(`MouseService`),t.IRenderService=(0,r.createDecorator)(`RenderService`),t.ISelectionService=(0,r.createDecorator)(`SelectionService`),t.ICharacterJoinerService=(0,r.createDecorator)(`CharacterJoinerService`),t.IThemeService=(0,r.createDecorator)(`ThemeService`),t.ILinkProviderService=(0,r.createDecorator)(`LinkProviderService`)},6731:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.ThemeService=t.DEFAULT_ANSI_COLORS=void 0;let a=n(7239),o=n(8055),s=n(8460),c=n(844),l=n(2585),u=o.css.toColor(`#ffffff`),d=o.css.toColor(`#000000`),f=o.css.toColor(`#ffffff`),p=o.css.toColor(`#000000`),m={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze((()=>{let e=[o.css.toColor(`#2e3436`),o.css.toColor(`#cc0000`),o.css.toColor(`#4e9a06`),o.css.toColor(`#c4a000`),o.css.toColor(`#3465a4`),o.css.toColor(`#75507b`),o.css.toColor(`#06989a`),o.css.toColor(`#d3d7cf`),o.css.toColor(`#555753`),o.css.toColor(`#ef2929`),o.css.toColor(`#8ae234`),o.css.toColor(`#fce94f`),o.css.toColor(`#729fcf`),o.css.toColor(`#ad7fa8`),o.css.toColor(`#34e2e2`),o.css.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:o.channels.toCss(r,i,a),rgba:o.channels.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+10*t;e.push({css:o.channels.toCss(n,n,n),rgba:o.channels.toRgba(n,n,n)})}return e})());let h=t.ThemeService=class extends c.Disposable{get colors(){return this._colors}constructor(e){super(),this._optionsService=e,this._contrastCache=new a.ColorContrastCache,this._halfContrastCache=new a.ColorContrastCache,this._onChangeColors=this.register(new s.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:u,background:d,cursor:f,cursorAccent:p,selectionForeground:void 0,selectionBackgroundTransparent:m,selectionBackgroundOpaque:o.color.blend(d,m),selectionInactiveBackgroundTransparent:m,selectionInactiveBackgroundOpaque:o.color.blend(d,m),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange(`theme`,(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(e={}){let n=this._colors;if(n.foreground=g(e.foreground,u),n.background=g(e.background,d),n.cursor=g(e.cursor,f),n.cursorAccent=g(e.cursorAccent,p),n.selectionBackgroundTransparent=g(e.selectionBackground,m),n.selectionBackgroundOpaque=o.color.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=g(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=o.color.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?g(e.selectionForeground,o.NULL_COLOR):void 0,n.selectionForeground===o.NULL_COLOR&&(n.selectionForeground=void 0),o.color.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=o.color.opacity(n.selectionBackgroundTransparent,.3)),o.color.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=o.color.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.ansi=t.DEFAULT_ANSI_COLORS.slice(),n.ansi[0]=g(e.black,t.DEFAULT_ANSI_COLORS[0]),n.ansi[1]=g(e.red,t.DEFAULT_ANSI_COLORS[1]),n.ansi[2]=g(e.green,t.DEFAULT_ANSI_COLORS[2]),n.ansi[3]=g(e.yellow,t.DEFAULT_ANSI_COLORS[3]),n.ansi[4]=g(e.blue,t.DEFAULT_ANSI_COLORS[4]),n.ansi[5]=g(e.magenta,t.DEFAULT_ANSI_COLORS[5]),n.ansi[6]=g(e.cyan,t.DEFAULT_ANSI_COLORS[6]),n.ansi[7]=g(e.white,t.DEFAULT_ANSI_COLORS[7]),n.ansi[8]=g(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),n.ansi[9]=g(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),n.ansi[10]=g(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),n.ansi[11]=g(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),n.ansi[12]=g(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),n.ansi[13]=g(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),n.ansi[14]=g(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),n.ansi[15]=g(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),e.extendedAnsi){let r=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<r;i++)n.ansi[i+16]=g(e.extendedAnsi[i],t.DEFAULT_ANSI_COLORS[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e!==void 0)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function g(e,t){if(e!==void 0)try{return o.css.toColor(e)}catch{}return t}t.ThemeService=h=r([i(0,l.IOptionsService)],h)},6349:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this.register(new r.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new r.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new r.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}}t.CircularList=a},1439:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=void 0,t.clone=function e(t,n=5){if(typeof t!=`object`)return t;let r=Array.isArray(t)?[]:{};for(let i in t)r[i]=n<=1?t[i]:t[i]&&e(t[i],n-1);return r}},8055:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0;let n=0,r=0,i=0,a=0;var o,s,c,l,u;function d(e){let t=e.toString(16);return t.length<2?`0`+t:t}function f(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:`#00000000`,rgba:0},function(e){e.toCss=function(e,t,n,r){return r===void 0?`#${d(e)}${d(t)}${d(n)}`:`#${d(e)}${d(t)}${d(n)}${d(r)}`},e.toRgba=function(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0},e.toColor=function(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}}(o||(t.channels=o={})),function(e){function t(e,t){return a=Math.round(255*t),[n,r,i]=u.toChannels(e.rgba),{css:o.toCss(n,r,i,a),rgba:o.toRgba(n,r,i,a)}}e.blend=function(e,t){if(a=(255&t.rgba)/255,a===1)return{css:t.css,rgba:t.rgba};let s=t.rgba>>24&255,c=t.rgba>>16&255,l=t.rgba>>8&255,u=e.rgba>>24&255,d=e.rgba>>16&255,f=e.rgba>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),{css:o.toCss(n,r,i),rgba:o.toRgba(n,r,i)}},e.isOpaque=function(e){return(255&e.rgba)==255},e.ensureContrastRatio=function(e,t,n){let r=u.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return o.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[n,r,i]=u.toChannels(t),{css:o.toCss(n,r,i),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,n){return a=255&e.rgba,t(e,a*n/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(s||(t.color=s={})),function(e){let t,s;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let n=e.getContext(`2d`,{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation=`copy`,s=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),o.toColor(n,r,i);case 5:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),a=parseInt(e.slice(4,5).repeat(2),16),o.toColor(n,r,i,a);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let c=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return n=parseInt(c[1]),r=parseInt(c[2]),i=parseInt(c[3]),a=Math.round(255*(c[5]===void 0?1:parseFloat(c[5]))),o.toColor(n,r,i,a);if(!t||!s||(t.fillStyle=s,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[n,r,i,a]=t.getImageData(0,0,1,1).data,a!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:o.toRgba(n,r,i,a),css:e}}}(c||(t.css=c={})),function(e){function t(e,t,n){let r=e/255,i=t/255,a=n/255;return .2126*(r<=.03928?r/12.92:((r+.055)/1.055)**2.4)+.7152*(i<=.03928?i/12.92:((i+.055)/1.055)**2.4)+.0722*(a<=.03928?a/12.92:((a+.055)/1.055)**2.4)}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(l||(t.rgb=l={})),function(e){function t(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(.1*o)),s-=Math.max(0,Math.ceil(.1*s)),c-=Math.max(0,Math.ceil(.1*c)),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}function s(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),s=Math.min(255,s+Math.ceil(.1*(255-s))),c=Math.min(255,c+Math.ceil(.1*(255-c))),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.blend=function(e,t){if(a=(255&t)/255,a===1)return t;let s=t>>24&255,c=t>>16&255,l=t>>8&255,u=e>>24&255,d=e>>16&255,f=e>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),o.toRgba(n,r,i)},e.ensureContrastRatio=function(e,n,r){let i=l.relativeLuminance(e>>8),a=l.relativeLuminance(n>>8);if(f(i,a)<r){if(a<i){let a=t(e,n,r),o=f(i,l.relativeLuminance(a>>8));if(o<r){let t=s(e,n,r);return o>f(i,l.relativeLuminance(t>>8))?a:t}return a}let o=s(e,n,r),c=f(i,l.relativeLuminance(o>>8));if(c<r){let a=t(e,n,r);return c>f(i,l.relativeLuminance(a>>8))?o:a}return o}},e.reduceLuminance=t,e.increaseLuminance=s,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(u||(t.rgba=u={})),t.toPaddedHex=d,t.contrastRatio=f},8969:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;let r=n(844),i=n(2585),a=n(4348),o=n(7866),s=n(744),c=n(7302),l=n(6975),u=n(8460),d=n(1753),f=n(1480),p=n(7994),m=n(9282),h=n(5435),g=n(5981),_=n(2660),v=!1;class y extends r.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new u.EventEmitter),this._onScroll.event((e=>{this._onScrollApi?.fire(e.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}constructor(e){super(),this._windowsWrappingHeuristics=this.register(new r.MutableDisposable),this._onBinary=this.register(new u.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new u.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new u.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new u.EventEmitter),this._instantiationService=new a.InstantiationService,this.optionsService=this.register(new c.OptionsService(e)),this._instantiationService.setService(i.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(s.BufferService)),this._instantiationService.setService(i.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(o.LogService)),this._instantiationService.setService(i.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(l.CoreService)),this._instantiationService.setService(i.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(i.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(f.UnicodeService)),this._instantiationService.setService(i.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p.CharsetService),this._instantiationService.setService(i.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_.OscLinkService),this._instantiationService.setService(i.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new h.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,u.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,u.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,u.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,u.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new g.WriteBuffer(((e,t)=>this._inputHandler.parse(e,t)))),this.register((0,u.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=i.LogLevelEnum.WARN&&!v&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),v=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,s.MINIMUM_COLS),t=Math.max(t,s.MINIMUM_ROWS),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t,n){this._bufferService.scrollLines(e,t,n)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(m.updateWindowsModeWrappedState.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},(()=>((0,m.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,r.toDisposable)((()=>{for(let t of e)t.dispose()}))}}}t.CoreTerminal=y},8460:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},5435:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0;let a=n(2584),o=n(7116),s=n(2015),c=n(844),l=n(482),u=n(8437),d=n(8460),f=n(643),p=n(511),m=n(3734),h=n(2585),g=n(1480),_=n(6242),v=n(6351),y=n(5941),b={"(":0,")":1,"*":2,"+":3,"-":1,".":2},x=131072;function S(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var C;(function(e){e[e.GET_WIN_SIZE_PIXELS=0]=`GET_WIN_SIZE_PIXELS`,e[e.GET_CELL_SIZE_PIXELS=1]=`GET_CELL_SIZE_PIXELS`})(C||(t.WindowsOptionsReportType=C={}));let w=0;class T extends c.Disposable{getAttrData(){return this._curAttrData}constructor(e,t,n,r,i,c,f,m,h=new s.EscapeSequenceParser){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=c,this._coreMouseService=f,this._unicodeService=m,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new l.StringToUtf32,this._utf8Decoder=new l.Utf8ToUtf32,this._workCell=new p.CellData,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new E(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._parser.setCsiHandlerFallback(((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})})),this._parser.setEscHandlerFallback((e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})})),this._parser.setExecuteHandlerFallback((e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})})),this._parser.setOscHandlerFallback(((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})})),this._parser.setDcsHandlerFallback(((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})})),this._parser.setPrintHandler(((e,t,n)=>this.print(e,t,n))),this._parser.registerCsiHandler({final:`@`},(e=>this.insertChars(e))),this._parser.registerCsiHandler({intermediates:` `,final:`@`},(e=>this.scrollLeft(e))),this._parser.registerCsiHandler({final:`A`},(e=>this.cursorUp(e))),this._parser.registerCsiHandler({intermediates:` `,final:`A`},(e=>this.scrollRight(e))),this._parser.registerCsiHandler({final:`B`},(e=>this.cursorDown(e))),this._parser.registerCsiHandler({final:`C`},(e=>this.cursorForward(e))),this._parser.registerCsiHandler({final:`D`},(e=>this.cursorBackward(e))),this._parser.registerCsiHandler({final:`E`},(e=>this.cursorNextLine(e))),this._parser.registerCsiHandler({final:`F`},(e=>this.cursorPrecedingLine(e))),this._parser.registerCsiHandler({final:`G`},(e=>this.cursorCharAbsolute(e))),this._parser.registerCsiHandler({final:`H`},(e=>this.cursorPosition(e))),this._parser.registerCsiHandler({final:`I`},(e=>this.cursorForwardTab(e))),this._parser.registerCsiHandler({final:`J`},(e=>this.eraseInDisplay(e,!1))),this._parser.registerCsiHandler({prefix:`?`,final:`J`},(e=>this.eraseInDisplay(e,!0))),this._parser.registerCsiHandler({final:`K`},(e=>this.eraseInLine(e,!1))),this._parser.registerCsiHandler({prefix:`?`,final:`K`},(e=>this.eraseInLine(e,!0))),this._parser.registerCsiHandler({final:`L`},(e=>this.insertLines(e))),this._parser.registerCsiHandler({final:`M`},(e=>this.deleteLines(e))),this._parser.registerCsiHandler({final:`P`},(e=>this.deleteChars(e))),this._parser.registerCsiHandler({final:`S`},(e=>this.scrollUp(e))),this._parser.registerCsiHandler({final:`T`},(e=>this.scrollDown(e))),this._parser.registerCsiHandler({final:`X`},(e=>this.eraseChars(e))),this._parser.registerCsiHandler({final:`Z`},(e=>this.cursorBackwardTab(e))),this._parser.registerCsiHandler({final:"`"},(e=>this.charPosAbsolute(e))),this._parser.registerCsiHandler({final:`a`},(e=>this.hPositionRelative(e))),this._parser.registerCsiHandler({final:`b`},(e=>this.repeatPrecedingCharacter(e))),this._parser.registerCsiHandler({final:`c`},(e=>this.sendDeviceAttributesPrimary(e))),this._parser.registerCsiHandler({prefix:`>`,final:`c`},(e=>this.sendDeviceAttributesSecondary(e))),this._parser.registerCsiHandler({final:`d`},(e=>this.linePosAbsolute(e))),this._parser.registerCsiHandler({final:`e`},(e=>this.vPositionRelative(e))),this._parser.registerCsiHandler({final:`f`},(e=>this.hVPosition(e))),this._parser.registerCsiHandler({final:`g`},(e=>this.tabClear(e))),this._parser.registerCsiHandler({final:`h`},(e=>this.setMode(e))),this._parser.registerCsiHandler({prefix:`?`,final:`h`},(e=>this.setModePrivate(e))),this._parser.registerCsiHandler({final:`l`},(e=>this.resetMode(e))),this._parser.registerCsiHandler({prefix:`?`,final:`l`},(e=>this.resetModePrivate(e))),this._parser.registerCsiHandler({final:`m`},(e=>this.charAttributes(e))),this._parser.registerCsiHandler({final:`n`},(e=>this.deviceStatus(e))),this._parser.registerCsiHandler({prefix:`?`,final:`n`},(e=>this.deviceStatusPrivate(e))),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},(e=>this.softReset(e))),this._parser.registerCsiHandler({intermediates:` `,final:`q`},(e=>this.setCursorStyle(e))),this._parser.registerCsiHandler({final:`r`},(e=>this.setScrollRegion(e))),this._parser.registerCsiHandler({final:`s`},(e=>this.saveCursor(e))),this._parser.registerCsiHandler({final:`t`},(e=>this.windowOptions(e))),this._parser.registerCsiHandler({final:`u`},(e=>this.restoreCursor(e))),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},(e=>this.insertColumns(e))),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},(e=>this.deleteColumns(e))),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},(e=>this.selectProtected(e))),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},(e=>this.requestMode(e,!0))),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},(e=>this.requestMode(e,!1))),this._parser.setExecuteHandler(a.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(a.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(a.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(a.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(a.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(a.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(a.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(a.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(a.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new _.OscHandler((e=>(this.setTitle(e),this.setIconName(e),!0)))),this._parser.registerOscHandler(1,new _.OscHandler((e=>this.setIconName(e)))),this._parser.registerOscHandler(2,new _.OscHandler((e=>this.setTitle(e)))),this._parser.registerOscHandler(4,new _.OscHandler((e=>this.setOrReportIndexedColor(e)))),this._parser.registerOscHandler(8,new _.OscHandler((e=>this.setHyperlink(e)))),this._parser.registerOscHandler(10,new _.OscHandler((e=>this.setOrReportFgColor(e)))),this._parser.registerOscHandler(11,new _.OscHandler((e=>this.setOrReportBgColor(e)))),this._parser.registerOscHandler(12,new _.OscHandler((e=>this.setOrReportCursorColor(e)))),this._parser.registerOscHandler(104,new _.OscHandler((e=>this.restoreIndexedColor(e)))),this._parser.registerOscHandler(110,new _.OscHandler((e=>this.restoreFgColor(e)))),this._parser.registerOscHandler(111,new _.OscHandler((e=>this.restoreBgColor(e)))),this._parser.registerOscHandler(112,new _.OscHandler((e=>this.restoreCursorColor(e)))),this._parser.registerEscHandler({final:`7`},(()=>this.saveCursor())),this._parser.registerEscHandler({final:`8`},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:`D`},(()=>this.index())),this._parser.registerEscHandler({final:`E`},(()=>this.nextLine())),this._parser.registerEscHandler({final:`H`},(()=>this.tabSet())),this._parser.registerEscHandler({final:`M`},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:`=`},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:`>`},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:`c`},(()=>this.fullReset())),this._parser.registerEscHandler({final:`n`},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:`o`},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:`|`},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:`}`},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:`~`},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:`%`,final:`@`},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:`%`,final:`G`},(()=>this.selectDefaultCharset()));for(let e in o.CHARSETS)this._parser.registerEscHandler({intermediates:`(`,final:e},(()=>this.selectCharset(`(`+e))),this._parser.registerEscHandler({intermediates:`)`,final:e},(()=>this.selectCharset(`)`+e))),this._parser.registerEscHandler({intermediates:`*`,final:e},(()=>this.selectCharset(`*`+e))),this._parser.registerEscHandler({intermediates:`+`,final:e},(()=>this.selectCharset(`+`+e))),this._parser.registerEscHandler({intermediates:`-`,final:e},(()=>this.selectCharset(`-`+e))),this._parser.registerEscHandler({intermediates:`.`,final:e},(()=>this.selectCharset(`.`+e))),this._parser.registerEscHandler({intermediates:`/`,final:e},(()=>this.selectCharset(`/`+e)));this._parser.registerEscHandler({intermediates:`#`,final:`8`},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((e=>(this._logService.error(`Parsing error: `,e),e))),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new v.DcsHandler(((e,t)=>this.requestStatusString(e,t))))}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=h.LogLevelEnum.WARN&&Promise.race([e,new Promise(((e,t)=>setTimeout((()=>t(`#SLOW_TIMEOUT`)),5e3)))]).catch((e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than 5000 ms`)}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>x&&(a=this._parseStack.position+x)}if(this._logService.logLevel<=h.LogLevelEnum.DEBUG&&this._logService.debug(`parsing data`+(typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,(e=>String.fromCharCode(e))).join(``)}"`),typeof e==`string`?e.split(``).map((e=>e.charCodeAt(0))):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<x&&(this._parseBuffer=new Uint32Array(Math.min(e.length,x))),o||this._dirtyRowTracker.clearRange(),e.length>x)for(let t=a;t<e.length;t+=x){let a=t+x<e.length?t+x:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}this._activeBuffer.x===r&&this._activeBuffer.y===i||this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(c,this._bufferService.rows-1),Math.min(s,this._bufferService.rows-1))}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,p=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,p);let h=this._parser.precedingJoinState;for(let _=t;_<n;++_){if(r=e[_],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,h);i=g.UnicodeService.extractWidth(t);let n=g.UnicodeService.extractShouldJoin(t),v=n?g.UnicodeService.extractWidth(h):0;if(h=t,o&&this._onA11yChar.fire((0,l.stringFromCodePoint)(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-v>s){if(c){let e=m,t=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof u.BufferLine&&m.copyCellsFrom(e,t,0,v,!1);t<s;)e.setCellFromCodepoint(t++,0,1,p)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-v;--e>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}else if(d&&(m.insertCells(this._activeBuffer.x,i-v,this._activeBuffer.getNullCell(p)),m.getWidth(s-1)===2&&m.setCellFromCodepoint(s-1,f.NULL_CELL_CODE,f.NULL_CELL_WIDTH,p)),m.setCellFromCodepoint(this._activeBuffer.x++,r,i,p),i>0)for(;--i;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}this._parser.precedingJoinState=h,this._activeBuffer.x<s&&n-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,p),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final!==`t`||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,(e=>!S(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)))}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new v.DcsHandler(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new _.OscHandler(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),t!==2&&t!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){let n;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(u.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=g.UnicodeService.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(a.C0.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(a.C0.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(a.C0.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(a.C0.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(a.C0.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,o.DEFAULT_CHARSET),this._charsetService.setgCharset(1,o.DEFAULT_CHARSET),this._charsetService.setgCharset(2,o.DEFAULT_CHARSET),this._charsetService.setgCharset(3,o.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(e,t){let n=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:i}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=e=>e?1:2,p=e.params[0];return m=p,h=t?p===2?4:p===4?f(o.modes.insertMode):p===12?3:p===20?f(d.convertEol):0:p===1?f(n.applicationCursorKeys):p===3?d.windowOptions.setWinLines?c===80?2:+(c===132):0:p===6?f(n.origin):p===7?f(n.wraparound):p===8?3:p===9?f(r===`X10`):p===12?f(d.cursorBlink):p===25?f(!o.isCursorHidden):p===45?f(n.reverseWraparound):p===66?f(n.applicationKeypad):p===67?4:p===1e3?f(r===`VT200`):p===1002?f(r===`DRAG`):p===1003?f(r===`ANY`):p===1004?f(n.sendFocus):p===1005?4:p===1006?f(i===`SGR`):p===1015?4:p===1016?f(i===`SGR_PIXELS`):p===1048?1:p===47||p===1047||p===1049?f(l===u):p===2004?f(n.bracketedPasteMode):0,o.triggerDataEvent(`${a.C0.ESC}[${t?``:`?`}${m};${h}$y`),!0;var m,h}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=m.AttributeData.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|255&n),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=u.DEFAULT_ATTR_DATA.fg,e.bg=u.DEFAULT_ATTR_DATA.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777224|n-90):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777224|n-100):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=16777215&u.DEFAULT_ATTR_DATA.fg):n===49?(r.bg&=-67108864,r.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=16777215&u.DEFAULT_ATTR_DATA.fg,r.bg&=-67108864,r.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${a.C0.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle=`block`;break;case 3:case 4:this._optionsService.options.cursorStyle=`underline`;break;case 5:case 6:this._optionsService.options.cursorStyle=`bar`}let n=t%2==1;return this._optionsService.options.cursorBlink=n,!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!S(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(C.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(C.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${a.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:t!==0&&t!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),t!==0&&t!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:t!==0&&t!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),t!==0&&t!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(D(n))if(r===`?`)t.push({type:0,index:n});else{let e=(0,y.parseColor)(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.split(`;`);return!(t.length<2)&&(t[1]?this._createHyperlink(t[0],t[1]):!t[0]&&this._finishHyperlink())}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex((e=>e.startsWith(`id=`)));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=(0,y.parseColor)(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);D(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,o.DEFAULT_CHARSET),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(b[e[0]],o.CHARSETS[e[1]]||o.DEFAULT_CHARSET),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new p.CellData;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=this._bufferService.buffer,r=this._optionsService.rawOptions;return(e=>(this._coreService.triggerDataEvent(`${a.C0.ESC}${e}${a.C0.ESC}\\`),!0))(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-+!!r.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}}t.InputHandler=T;let E=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(w=e,e=t,t=w),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function D(e){return 0<=e&&e<256}E=r([i(0,h.IBufferService)],E)},844:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}},1505:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}}t.TwoKeyMap=n,t.FourKeyMap=class{constructor(){this._data=new n}set(e,t,r,i,a){this._data.get(e,t)||this._data.set(e,t,new n),this._data.get(e,t).set(r,i,a)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}}},6114:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.getSafariVersion=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.isNode=typeof process<`u`&&`title`in process;let n=t.isNode?`node`:navigator.userAgent,r=t.isNode?`node`:navigator.platform;t.isFirefox=n.includes(`Firefox`),t.isLegacyEdge=n.includes(`Edge`),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.getSafariVersion=function(){if(!t.isSafari)return 0;let e=n.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])},t.isMac=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(r),t.isIpad=r===`iPad`,t.isIphone=r===`iPhone`,t.isWindows=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(r),t.isLinux=r.indexOf(`Linux`)>=0,t.isChromeOS=/\bCrOS\b/.test(n)},6106:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SortedList=void 0;let n=0;t.SortedList=class{constructor(e){this._getKey=e,this._array=[]}clear(){this._array.length=0}insert(e){this._array.length===0?this._array.push(e):(n=this._search(this._getKey(e)),this._array.splice(n,0,e))}delete(e){if(this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(n=this._search(t),n===-1)||this._getKey(this._array[n])!==t)return!1;do if(this._array[n]===e)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===t);return!1}*getKeyIterator(e){if(this._array.length!==0&&(n=this._search(e),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===e))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===e)}forEachByKey(e,t){if(this._array.length!==0&&(n=this._search(e),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===e))do t(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===e)}values(){return[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else{if(!(i<e)){for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}t=r+1}}return t}}},7226:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;let r=n(6114);class i{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=Date.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,Date.now()-t),n=Math.max(t,n),i=e.timeRemaining(),1.5*n>i)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=i}this.clear()}}class a extends i{_requestCallback(e){return setTimeout((()=>e(this._createDeadline(16))))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=Date.now()+e;return{timeRemaining:()=>Math.max(0,t-Date.now())}}}t.PriorityTaskQueue=a,t.IdleTaskQueue=!r.isNode&&`requestIdleCallback`in window?class extends i{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:a,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}}},9282:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=void 0;let r=n(643);t.updateWindowsModeWrappedState=function(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[r.CHAR_DATA_CODE_INDEX]!==r.NULL_CELL_CODE&&t[r.CHAR_DATA_CODE_INDEX]!==r.WHITESPACE_CELL_CODE)}},3734:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new r}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let e=new n;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t.AttributeData=n;class r{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}clone(){return new r(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t.ExtendedAttrs=r},9092:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Buffer=t.MAX_BUFFER_SIZE=void 0;let r=n(6349),i=n(7226),a=n(3734),o=n(8437),s=n(4634),c=n(511),l=n(643),u=n(4863),d=n(7116);t.MAX_BUFFER_SIZE=4294967295,t.Buffer=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=o.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=c.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]),this._whitespaceCell=c.CellData.fromCharData([0,l.WHITESPACE_CELL_CHAR,l.WHITESPACE_CELL_WIDTH,l.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new i.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new r.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new a.ExtendedAttrs),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new a.ExtendedAttrs),this._whitespaceCell}getBlankLine(e,t){return new o.BufferLine(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let n=e+this._optionsService.rawOptions.scrollback;return n>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:n}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=o.DEFAULT_ATTR_DATA);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new r.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(o.DEFAULT_ATTR_DATA),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new o.BufferLine(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new o.BufferLine(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=(0,s.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(o.DEFAULT_ATTR_DATA));if(n.length>0){let r=(0,s.reflowLargerCreateNewLayout)(this.lines,n);(0,s.reflowLargerApplyNewLayout)(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(o.DEFAULT_ATTR_DATA),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new o.BufferLine(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this.getNullCell(o.DEFAULT_ATTR_DATA),r=[],i=0;for(let a=this.lines.length-1;a>=0;a--){let c=this.lines.get(a);if(!c||!c.isWrapped&&c.getTrimmedLength()<=e)continue;let l=[c];for(;c.isWrapped&&a>0;)c=this.lines.get(--a),l.unshift(c);let u=this.ybase+this.y;if(u>=a&&u<a+l.length)continue;let d=l[l.length-1].getTrimmedLength(),f=(0,s.reflowSmallerGetNewLineLengths)(l,this._cols,e),p=f.length-l.length,m;m=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+p):Math.max(0,this.lines.length-this.lines.maxLength+p);let h=[];for(let e=0;e<p;e++){let e=this.getBlankLine(o.DEFAULT_ATTR_DATA,!0);h.push(e)}h.length>0&&(r.push({start:a+l.length+i,newLines:h}),i+=h.length),l.push(...h);let g=f.length-1,_=f[g];_===0&&(g--,_=f[g]);let v=l.length-p-1,y=d;for(;v>=0;){let e=Math.min(y,_);if(l[g]===void 0)break;if(l[g].copyCellsFrom(l[v],y-e,_-e,e,!0),_-=e,_===0&&(g--,_=f[g]),y-=e,y===0){v--;let e=Math.max(v,0);y=(0,s.getWrappedLineTrimmedLength)(l,e,this._cols)}}for(let t=0;t<l.length;t++)f[t]<e&&l[t].setCell(f[t],n);let b=p-m;for(;b-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+i)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+t-1)}if(r.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,a=n-1,o=0,s=r[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+i);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+i-1);l>=0;l--)if(s&&s.start>a+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:a+1,amount:s.newLines.length}),c+=s.newLines.length,s=r[++o]}else this.lines.set(l,t[a--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+i-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose(),this.markers.splice(e--,1);this._isClearing=!1}addMarker(e){let t=new u.Marker(e);return this.markers.push(t),t.register(this.lines.onTrim((e=>{t.line-=e,t.line<0&&t.dispose()}))),t.register(this.lines.onInsert((e=>{t.line>=e.index&&(t.line+=e.amount)}))),t.register(this.lines.onDelete((e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)}))),t.register(t.onDispose((()=>this._removeMarker(t)))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}}},8437:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;let r=n(3734),i=n(511),a=n(643),o=n(482);t.DEFAULT_ATTR_DATA=Object.freeze(new r.AttributeData);let s=0;class c{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let r=t||i.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[3*e+0],n=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:n?(0,o.stringFromCodePoint)(n):``,t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[3*e+1]=t[a.CHAR_DATA_ATTR_INDEX],t[a.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[a.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[a.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 12582912&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?(0,o.stringFromCodePoint)(2097151&t):``}isProtected(e){return 536870912&this._data[3*e+2]}loadCell(e,t){return s=3*e,t.content=this._data[s+0],t.fg=this._data[s+1],t.bg=this._data[s+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg}setCellFromCodepoint(e,t,n,r){268435456&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=t|n<<22,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[3*e+0];2097152&r?this._combined[e]+=(0,o.stringFromCodePoint)(t):2097151&r?(this._combined[e]=(0,o.stringFromCodePoint)(2097151&r)+(0,o.stringFromCodePoint)(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[3*e+0]=r}insertCells(e,t,n){if((e%=this.length)&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new i.CellData;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new i.CellData;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)!==0||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let n=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*n)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,4*n*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let e=new c(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let t in this._combined)e._combined[t]=this._combined[t];for(let t in this._extendedAttrs)e._extendedAttrs[t]=this._extendedAttrs[t];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||50331648&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<3;e++)this._data[3*(n+i)+e]=a[3*(t+i)+e];268435456&a[3*(t+i)+2]&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<3;e++)this._data[3*(n+i)+e]=a[3*(t+i)+e];268435456&a[3*(t+i)+2]&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[3*t+0],n=2097151&e,s=2097152&e?this._combined[t]:n?(0,o.stringFromCodePoint)(n):a.WHITESPACE_CELL_CHAR;if(i+=s,r)for(let e=0;e<s.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}}t.BufferLine=c},4841:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRangeLength=void 0,t.getRangeLength=function(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}},4634:(e,t)=>{function n(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}Object.defineProperty(t,"__esModule",{value:!0}),t.getWrappedLineTrimmedLength=t.reflowSmallerGetNewLineLengths=t.reflowLargerApplyNewLayout=t.reflowLargerCreateNewLayout=t.reflowLargerGetLinesToRemove=void 0,t.reflowLargerGetLinesToRemove=function(e,t,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(i>=s&&i<c){s+=u.length-1;continue}let d=0,f=n(u,d,t),p=1,m=0;for(;p<u.length;){let e=n(u,p,t),i=e-m,o=r-f,s=Math.min(i,o);u[d].copyCellsFrom(u[p],m,f,s,!1),f+=s,f===r&&(d++,f=0),m+=s,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(r-1)===2&&(u[d].copyCellsFrom(u[d-1],r-1,f++,1,!1),u[d-1].setCell(r-1,a))}u[d].replaceCells(f,r,a);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o},t.reflowLargerCreateNewLayout=function(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}},t.reflowLargerApplyNewLayout=function(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length},t.reflowSmallerGetNewLineLengths=function(e,t,r){let i=[],a=e.map(((r,i)=>n(e,i,t))).reduce(((e,t)=>e+t)),o=0,s=0,c=0;for(;c<a;){if(a-c<r){i.push(a-c);break}o+=r;let l=n(e,s,t);o>l&&(o-=l,s++);let u=e[s].getWidth(o-1)===2;u&&o--;let d=u?r-1:r;i.push(d),c+=d}return i},t.getWrappedLineTrimmedLength=n},5295:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;let r=n(8460),i=n(844),a=n(9092);class o extends i.Disposable{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this.register(new r.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange(`scrollback`,(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,(()=>this.setupTabStops())))}reset(){this._normal=new a.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}}t.BufferSet=o},511:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;let r=n(482),i=n(643),a=n(3734);class o extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=``}static fromCharData(e){let t=new o;return t.setFromCharData(e),t}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,r.stringFromCodePoint)(2097151&this.content):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[i.CHAR_DATA_ATTR_INDEX],this.bg=0;let t=!1;if(e[i.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(e[i.CHAR_DATA_CHAR_INDEX].length===2){let n=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(n-55296)+r-56320+65536|e[i.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[i.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[i.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[i.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=o},643:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR=``,t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=` `,t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},4863:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;let r=n(8460),i=n(844);class a{get id(){return this._id}constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new r.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,i.disposeArray)(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}}t.Marker=a,a._nextId=1},7116:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},t.CHARSETS.A={"#":`£`},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},t.CHARSETS.C=t.CHARSETS[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},t.CHARSETS.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},t.CHARSETS.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},t.CHARSETS.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},t.CHARSETS.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},t.CHARSETS.E=t.CHARSETS[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},t.CHARSETS.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},t.CHARSETS.H=t.CHARSETS[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},t.CHARSETS[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`}},2584:(e,t)=>{var n,r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.C1_ESCAPED=t.C1=t.C0=void 0,function(e){e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
15
+ `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``}(n||(t.C0=n={})),function(e){e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`}(r||(t.C1=r={})),function(e){e.ST=`${n.ESC}\\`}(i||(t.C1_ESCAPED=i={}))},7399:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateKeyboardEvent=void 0;let r=n(2584),i={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};t.evaluateKeyboardEvent=function(e,t,n,a){let o={type:0,cancel:!1,key:void 0},s=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`:e.key===`UIKeyInputRightArrow`?o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`);break;case 8:o.key=e.ctrlKey?`\b`:r.C0.DEL,e.altKey&&(o.key=r.C0.ESC+o.key);break;case 9:if(e.shiftKey){o.key=r.C0.ESC+`[Z`;break}o.key=r.C0.HT,o.cancel=!0;break;case 13:o.key=e.altKey?r.C0.ESC+r.C0.CR:r.C0.CR,o.cancel=!0;break;case 27:o.key=r.C0.ESC,e.altKey&&(o.key=r.C0.ESC+r.C0.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`D`,o.key===r.C0.ESC+`[1;3D`&&(o.key=r.C0.ESC+(n?`b`:`[1;5D`))):o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`;break;case 39:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`C`,o.key===r.C0.ESC+`[1;3C`&&(o.key=r.C0.ESC+(n?`f`:`[1;5C`))):o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`;break;case 38:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`A`,n||o.key!==r.C0.ESC+`[1;3A`||(o.key=r.C0.ESC+`[1;5A`)):o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`;break;case 40:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`B`,n||o.key!==r.C0.ESC+`[1;3B`||(o.key=r.C0.ESC+`[1;5B`)):o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`;break;case 45:e.shiftKey||e.ctrlKey||(o.key=r.C0.ESC+`[2~`);break;case 46:o.key=s?r.C0.ESC+`[3;`+(s+1)+`~`:r.C0.ESC+`[3~`;break;case 36:o.key=s?r.C0.ESC+`[1;`+(s+1)+`H`:t?r.C0.ESC+`OH`:r.C0.ESC+`[H`;break;case 35:o.key=s?r.C0.ESC+`[1;`+(s+1)+`F`:t?r.C0.ESC+`OF`:r.C0.ESC+`[F`;break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=r.C0.ESC+`[5;`+(s+1)+`~`:o.key=r.C0.ESC+`[5~`;break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=r.C0.ESC+`[6;`+(s+1)+`~`:o.key=r.C0.ESC+`[6~`;break;case 112:o.key=s?r.C0.ESC+`[1;`+(s+1)+`P`:r.C0.ESC+`OP`;break;case 113:o.key=s?r.C0.ESC+`[1;`+(s+1)+`Q`:r.C0.ESC+`OQ`;break;case 114:o.key=s?r.C0.ESC+`[1;`+(s+1)+`R`:r.C0.ESC+`OR`;break;case 115:o.key=s?r.C0.ESC+`[1;`+(s+1)+`S`:r.C0.ESC+`OS`;break;case 116:o.key=s?r.C0.ESC+`[15;`+(s+1)+`~`:r.C0.ESC+`[15~`;break;case 117:o.key=s?r.C0.ESC+`[17;`+(s+1)+`~`:r.C0.ESC+`[17~`;break;case 118:o.key=s?r.C0.ESC+`[18;`+(s+1)+`~`:r.C0.ESC+`[18~`;break;case 119:o.key=s?r.C0.ESC+`[19;`+(s+1)+`~`:r.C0.ESC+`[19~`;break;case 120:o.key=s?r.C0.ESC+`[20;`+(s+1)+`~`:r.C0.ESC+`[20~`;break;case 121:o.key=s?r.C0.ESC+`[21;`+(s+1)+`~`:r.C0.ESC+`[21~`;break;case 122:o.key=s?r.C0.ESC+`[23;`+(s+1)+`~`:r.C0.ESC+`[23~`;break;case 123:o.key=s?r.C0.ESC+`[24;`+(s+1)+`~`:r.C0.ESC+`[24~`;break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(n&&!a||!e.altKey||e.metaKey)!n||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(o.key=r.C0.US),e.key===`@`&&(o.key=r.C0.NUL)):e.keyCode===65&&(o.type=1);else{let t=i[e.keyCode]?.[+!!e.shiftKey];if(t)o.key=r.C0.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),o.key=r.C0.ESC+n}else if(e.keyCode===32)o.key=r.C0.ESC+(e.ctrlKey?r.C0.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),o.key=r.C0.ESC+t,o.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=r.C0.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=r.C0.DEL:e.keyCode===219?o.key=r.C0.ESC:e.keyCode===220?o.key=r.C0.FS:e.keyCode===221&&(o.key=r.C0.GS)}return o}},482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=1024*(this._interim-55296)+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=1024*(i-55296)+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r,i,a,o,s=0,c=0,l=0;if(this.interim[0]){let r=!1,i=this.interim[0];i&=(224&i)==192?31:(240&i)==224?15:7;let a,o=0;for(;(a=63&this.interim[++o])&&o<4;)i<<=6,i|=a;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(a=e[l++],(192&a)!=128){l--,r=!0;break}this.interim[o++]=a,i<<=6,i|=63&a}r||(c===2?i<128?l--:t[s++]=i:c===3?i<2048||i>=55296&&i<=57343||i===65279||(t[s++]=i):i<65536||i>1114111||(t[s++]=i)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;!(!(d<u)||128&(r=e[d])||128&(i=e[d+1])||128&(a=e[d+2])||128&(o=e[d+3]));)t[s++]=r,t[s++]=i,t[s++]=a,t[s++]=o,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((224&r)==192){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(c=(31&r)<<6|63&i,c<128){d--;continue}t[s++]=c}else if((240&r)==224){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(c=(15&r)<<12|(63&i)<<6|63&a,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((248&r)==240){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,this.interim[2]=a,s;if(o=e[d++],(192&o)!=128){d--;continue}if(c=(7&r)<<18|(63&i)<<12|(63&a)<<6|63&o,c<65536||c>1114111)continue;t[s++]=c}}return s}}},225:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;let r=n(1480),i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],o;t.UnicodeV6=class{constructor(){if(this.version=`6`,!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<i.length;++e)o.fill(0,i[e][0],i[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},5981:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new r.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let n;for(this._isSyncWriting=!0;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>5e7)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch((e=>(queueMicrotask((()=>{throw e})),Promise.resolve(!1)))).then(e=>Date.now()-n>=12?setTimeout((()=>this._innerWrite(0,e))):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,Date.now()-n>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t.WriteBuffer=a},5941:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toRgbString=t.parseColor=void 0;let n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,r=/^[\da-f]+$/;function i(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}t.parseColor=function(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=n.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),r.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}},t.toRgbString=function(e,t=16){let[n,r,a]=e;return`rgb:${i(n,t)}/${i(r,t)}/${i(a,t)}`}},5770:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},6351:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;let r=n(482),i=n(8742),a=n(5770),o=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=o,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=o,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||o,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t);else this._handlerFb(this._ident,`HOOK`,t)}put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._ident,`PUT`,(0,r.utf32ToString)(e,t,n))}unhook(e,t=!0){if(this._active.length){let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===n){for(;r>=0&&(n=this._active[r].unhook(e),!0!==n);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,`UNHOOK`,e);this._active=o,this._ident=0}};let s=new i.Params;s.addParam(0),t.DcsHandler=class{constructor(e){this._handler=e,this._data=``,this._params=s,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():s,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,r.utf32ToString)(e,t,n),this._data.length>a.PAYLOAD_LIMIT&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then((e=>(this._params=s,this._data=``,this._hitLimit=!1,e)));return this._params=s,this._data=``,this._hitLimit=!1,t}}},2015:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;let r=n(844),i=n(8742),a=n(6242),o=n(6351);class s{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}}t.TransitionTable=s,t.VT500_TRANSITION_TABLE=function(){let e=new s(4095),t=Array.apply(null,Array(256)).map(((e,t)=>t)),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}();class c extends r.Disposable{constructor(e=t.VT500_TRANSITION_TABLE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new i.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,r.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new a.OscParser),this._dcsParser=this.register(new o.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},(()=>!0))}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r,i=0,a=0,o=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](this._params),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 4:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],r=this._dcsParser.unhook(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],r=this._oscParser.end(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let n=o;n<t;++n){switch(i=e[n],a=this._transitions.table[this.currentState<<8|(i<160?i:160)],a>>4){case 2:for(let r=n+1;;++r){if(r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|i],s=o?o.length-1:-1;for(;s>=0&&(r=o[s](this._params),!0!==r);s--)if(r instanceof Promise)return this._preserveStack(3,o,s,a,n),r;s<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++n<t&&(i=e[n])>47&&i<60);n--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(r=c[l](),!0!==r);l--)if(r instanceof Promise)return this._preserveStack(4,c,l,a,n),r;l<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let r=n+1;;++r)if(r>=t||(i=e[r])===24||i===26||i===27||i>127&&i<160){this._dcsParser.put(e,n,r),n=r-1;break}break;case 14:if(r=this._dcsParser.unhook(i!==24&&i!==26),r)return this._preserveStack(6,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let r=n+1;;r++)if(r>=t||(i=e[r])<32||i>127&&i<160){this._oscParser.put(e,n,r),n=r-1;break}break;case 6:if(r=this._oscParser.end(i!==24&&i!==26),r)return this._preserveStack(5,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&a}}}t.EscapeSequenceParser=c},6242:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;let r=n(5770),i=n(482),a=[];t.OscParser=class{constructor(){this._state=0,this._active=a,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,`START`)}_put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._id,`PUT`,(0,i.utf32ToString)(e,t,n))}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&!1===n){for(;r>=0&&(n=this._active[r].end(e),!0!==n);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._id,`END`,e);this._active=a,this._id=-1,this._state=0}}},t.OscHandler=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,i.utf32ToString)(e,t,n),this._data.length>r.PAYLOAD_LIMIT&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then((e=>(this._data=``,this._hitLimit=!1,e)));return this._data=``,this._hitLimit=!1,t}}},8742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;let n=2147483647;class r{static fromArray(e){let t=new r;if(!e.length)return t;for(let n=+!!Array.isArray(e[0]);n<e.length;++n){let r=e[n];if(Array.isArray(r))for(let e=0;e<r.length;++e)t.addSubParam(r[e]);else t.addParam(r)}return t}constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let e=new r(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>n?n:e}}addSubParam(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>n?n:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=255&this._subParamsIdx[e];return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[t-1];r[t-1]=~i?Math.min(10*i+e,n):e}}t.Params=r},5741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0,t.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}}},8771:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;let r=n(3785),i=n(511);t.BufferApiView=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new r.BufferLineApiView(t)}getNullCell(){return new i.CellData}}},3785:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;let r=n(511);t.BufferLineApiView=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new r.CellData)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}}},8285:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;let r=n(8771),i=n(8460),a=n(844);class o extends a.Disposable{constructor(e){super(),this._core=e,this._onBufferChange=this.register(new i.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new r.BufferApiView(this._core.buffers.normal,`normal`),this._alternate=new r.BufferApiView(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t.BufferNamespaceApi=o},7975:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0,t.ParserApi=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,(e=>t(e.toArray())))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,((e,n)=>t(e,n.toArray())))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}}},7090:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}}},744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;let a=n(8460),o=n(844),s=n(5295),c=n(2585);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let l=t.BufferService=class extends o.Disposable{get buffer(){return this.buffers.active}constructor(e){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(e.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this.register(new s.BufferSet(e,this))}resize(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t,n){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let i=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),i!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};t.BufferService=l=r([i(0,c.IOptionsService)],l)},7994:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0,t.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}}},1753:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;let a=n(2585),o=n(8460),s=n(844),c={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button!==4&&e.action===1&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function l(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=3&e.button,4&e.button&&(n|=64),8&e.button&&(n|=128),e.action===32?n|=32:e.action!==0||t||(n|=3)),n}let u=String.fromCharCode,d={DEFAULT:e=>{let t=[l(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`${u(t[0])}${u(t[1])}${u(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.x};${e.y}${t}`}},f=t.CoreMouseService=class extends s.Disposable{constructor(e,t){super(),this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._onProtocolChange=this.register(new o.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(c))this.addProtocol(e,c[e]);for(let e of Object.keys(d))this.addEncoding(e,d[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};t.CoreMouseService=f=r([i(0,a.IBufferService),i(1,a.ICoreService)],f)},6975:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;let a=n(1439),o=n(8460),s=n(844),c=n(2585),l=Object.freeze({insertMode:!1}),u=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),d=t.CoreService=class extends s.Disposable{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new o.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new o.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}reset(){this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onBinary.fire(e))}};t.CoreService=d=r([i(0,c.IBufferService),i(1,c.ILogService),i(2,c.IOptionsService)],d)},9074:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DecorationService=void 0;let r=n(8055),i=n(8460),a=n(844),o=n(6106),s=0,c=0;class l extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new o.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new i.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new i.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,a.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;let t=new u(e);if(t){let e=t.marker.onDispose((()=>t.dispose()));t.onDispose((()=>{t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())})),this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,(t=>{s=t.options.x??0,c=s+(t.options.width??1),e>=s&&e<c&&(!n||(t.options.layer??`bottom`)===n)&&r(t)}))}}t.DecorationService=l;class u extends a.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=r.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=r.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new i.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new i.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;let r=n(2585),i=n(8343);class a{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}}t.ServiceCollection=a,t.InstantiationService=class{constructor(){this._services=new a,this._services.set(r.IInstantiationService,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=(0,i.getServiceDependencies)(e).sort(((e,t)=>e.index-t.index)),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id}.`);r.push(n)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}}},7866:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.traceCall=t.setTraceLogger=t.LogService=void 0;let a=n(844),o=n(2585),s={trace:o.LogLevelEnum.TRACE,debug:o.LogLevelEnum.DEBUG,info:o.LogLevelEnum.INFO,warn:o.LogLevelEnum.WARN,error:o.LogLevelEnum.ERROR,off:o.LogLevelEnum.OFF},c,l=t.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(e){super(),this._optionsService=e,this._logLevel=o.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange(`logLevel`,(()=>this._updateLogLevel()))),c=this}_updateLogLevel(){this._logLevel=s[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:`xterm.js: `)+t,...n)}trace(e,...t){this._logLevel<=o.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=o.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=o.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=o.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=o.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};t.LogService=l=r([i(0,o.IOptionsService)],l),t.setTraceLogger=function(e){c=e},t.traceCall=function(e,t,n){if(typeof n.value!=`function`)throw Error(`not supported`);let r=n.value;n.value=function(...e){if(c.logLevel!==o.LogLevelEnum.TRACE)return r.apply(this,e);c.trace(`GlyphRenderer#${r.name}(${e.map((e=>JSON.stringify(e))).join(`, `)})`);let t=r.apply(this,e);return c.trace(`GlyphRenderer#${r.name} return`,t),t}}},7302:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;let r=n(8460),i=n(844);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`courier-new, courier, monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:n(6114).isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRulerWidth:0};let a=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`];class o extends i.Disposable{constructor(e){super(),this._onOptionChange=this.register(new r.EventEmitter),this.onOptionChange=this._onOptionChange.event;let n={...t.DEFAULT_OPTIONS};for(let t in e)if(t in n)try{let r=e[t];n[t]=this._sanitizeAndValidateOption(t,r)}catch(e){console.error(e)}this.rawOptions=n,this.options={...n},this._setupOptions(),this.register((0,i.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(e,t){return this.onOptionChange((n=>{n===e&&t(this.rawOptions[e])}))}onMultipleOptionChange(e,t){return this.onOptionChange((n=>{e.indexOf(n)!==-1&&t()}))}_setupOptions(){let e=e=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},n=(e,n)=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);n=this._sanitizeAndValidateOption(e,n),this.rawOptions[e]!==n&&(this.rawOptions[e]=n,this._onOptionChange.fire(e))};for(let t in this.rawOptions){let r={get:e.bind(this,t),set:n.bind(this,t)};Object.defineProperty(this.options,t,r)}}_sanitizeAndValidateOption(e,n){switch(e){case`cursorStyle`:if(n||=t.DEFAULT_OPTIONS[e],!function(e){return e===`block`||e===`underline`||e===`bar`}(n))throw Error(`"${n}" is not a valid value for ${e}`);break;case`wordSeparator`:n||=t.DEFAULT_OPTIONS[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof n==`number`&&1<=n&&n<=1e3)break;n=a.includes(n)?n:t.DEFAULT_OPTIONS[e];break;case`cursorWidth`:n=Math.floor(n);case`lineHeight`:case`tabStopWidth`:if(n<1)throw Error(`${e} cannot be less than 1, value: ${n}`);break;case`minimumContrastRatio`:n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case`scrollback`:if((n=Math.min(n,4294967295))<0)throw Error(`${e} cannot be less than 0, value: ${n}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(n<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case`rows`:case`cols`:if(!n&&n!==0)throw Error(`${e} must be numeric, value: ${n}`);break;case`windowsPty`:n??={}}return n}}t.OptionsService=o},2660:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkService=void 0;let a=n(2585),o=t.OscLinkService=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose((()=>this._removeMarkerFromLink(r,n))),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose((()=>this._removeMarkerFromLink(o,a))),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every((e=>e.line!==t))){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose((()=>this._removeMarkerFromLink(n,e)))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};t.OscLinkService=o=r([i(0,a.IBufferService)],o)},8343:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;let n=`di$target`,r=`di$dependencies`;t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);let i=function(e,t,a){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);(function(e,t,i){t[n]===t?t[r].push({id:e,index:i}):(t[r]=[{id:e,index:i}],t[n]=t)})(i,e,a)};return i.toString=()=>e,t.serviceRegistry.set(e,i),i}},2585:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let r=n(8343);var i;t.IBufferService=(0,r.createDecorator)(`BufferService`),t.ICoreMouseService=(0,r.createDecorator)(`CoreMouseService`),t.ICoreService=(0,r.createDecorator)(`CoreService`),t.ICharsetService=(0,r.createDecorator)(`CharsetService`),t.IInstantiationService=(0,r.createDecorator)(`InstantiationService`),function(e){e[e.TRACE=0]=`TRACE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARN=3]=`WARN`,e[e.ERROR=4]=`ERROR`,e[e.OFF=5]=`OFF`}(i||(t.LogLevelEnum=i={})),t.ILogService=(0,r.createDecorator)(`LogService`),t.IOptionsService=(0,r.createDecorator)(`OptionsService`),t.IOscLinkService=(0,r.createDecorator)(`OscLinkService`),t.IUnicodeService=(0,r.createDecorator)(`UnicodeService`),t.IDecorationService=(0,r.createDecorator)(`DecorationService`)},1480:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;let r=n(8460),i=n(225);class a{static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(16777215&e)<<3|(3&t)<<1|!!n}constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,n=0,r=e.length;for(let i=0;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return t+this.wcwidth(o);let n=e.charCodeAt(i);56320<=n&&n<=57343?o=1024*(o-55296)+n-56320+65536:t+=this.wcwidth(n)}let s=this.charProperties(o,n),c=a.extractWidth(s);a.extractShouldJoin(s)&&(c-=a.extractWidth(n)),t+=c,n=s}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=a}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.Terminal=void 0;let t=n(9042),i=n(3236),a=n(844),o=n(5741),s=n(8285),c=n(7975),l=n(7090),u=[`cols`,`rows`];class d extends a.Disposable{constructor(e){super(),this._core=this.register(new i.Terminal(e)),this._addonManager=this.register(new o.AddonManager),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(u.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new c.ParserApi(this._core),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this.register(new s.BufferNamespaceApi(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
16
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return t}_verifyIntegers(...e){for(let t of e)if(t===1/0||isNaN(t)||t%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(let t of e)if(t&&(t===1/0||isNaN(t)||t%1!=0||t<0))throw Error(`This API only accepts positive integers`)}}e.Terminal=d})(),r})()))})),li=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.FitAddon=r():n.FitAddon=r()})(self,(()=>(()=>{var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core,t=e._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(r.getPropertyValue(`height`)),a=Math.max(0,parseInt(r.getPropertyValue(`width`))),o=window.getComputedStyle(this._terminal.element),s=i-(parseInt(o.getPropertyValue(`padding-top`))+parseInt(o.getPropertyValue(`padding-bottom`))),c=a-(parseInt(o.getPropertyValue(`padding-right`))+parseInt(o.getPropertyValue(`padding-left`)))-n;return{cols:Math.max(2,Math.floor(c/t.css.cell.width)),rows:Math.max(1,Math.floor(s/t.css.cell.height))}}}})(),e})()))})),ui=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.WebLinksAddon=r():n.WebLinksAddon=r()})(self,(()=>(()=>{var e={6:(e,t)=>{function n(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=r.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map((e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e)))}};class r{static computeLink(e,t,i,a){let o=new RegExp(t.source,(t.flags||``)+`g`),[s,c]=r._getWindowedLineStrings(e-1,i),l=s.join(``),u,d=[];for(;u=o.exec(l);){let e=u[0];if(!n(e))continue;let[t,o]=r._mapStrIdx(i,c,0,u.index),[s,l]=r._mapStrIdx(i,t,o,e.length);if(t===-1||o===-1||s===-1||l===-1)continue;let f={start:{x:o+1,y:t+1},end:{x:l,y:s+1}};d.push({range:f,text:e,activate:a})}return d}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}}t.LinkComputer=r}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;let t=n(6),i=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function a(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}e.WebLinksAddon=class{constructor(e=a,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let n=this._options,r=n.urlRegex||i;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,r,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),r})()))})),di=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.SearchAddon=r():n.SearchAddon=r()})(self,(()=>(()=>{var e={345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.SearchAddon=void 0;let t=n(345),i=n(859),a=` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`;class o extends i.Disposable{constructor(e){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new i.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new i.MutableDisposable,this._onDidChangeResults=this.register(new t.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=e?.highlightLimit??1e3}activate(e){this._terminal=e,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,i.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{let e=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(e,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(e){this._selectedDecoration.clear(),(0,i.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),e||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!e||e.length===0)return void this.clearDecorations();t||={},this.clearDecorations(!0);let n=[],r,i=this._find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);for(let e of n){let n=this._createResultDecoration(e,t.decorations);n&&(this._highlightedLines.add(n.marker.line),this._highlightDecorations.push({decoration:n,match:e,dispose(){n.dispose()}}))}}_find(e,t,n,r){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);let i;this._initLinesCache();let a={startRow:t,startCol:n};if(i=this._findInLine(e,a,r),!i)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,i=this._findInLine(e,a,r),!i);n++);return i}_findNextAndSelect(e,t){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,i=0;n&&(this._cachedSearchTerm===e?(r=n.end.x,i=n.end.y):(r=n.start.x,i=n.start.y)),this._initLinesCache();let a={startRow:i,startCol:r},o=this._findInLine(e,a,t);if(!o)for(let n=i+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);if(!o&&i!==0)for(let n=0;n<i&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);return!o&&n&&(a.startRow=n.start.y,a.startCol=0,o=this._findInLine(e,a,t)),this._selectResult(o,t?.decorations,t?.noScroll)}findPrevious(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_didOptionsChange(e,t){return!!t&&(e.caseSensitive!==t.caseSensitive||e.regex!==t.regex||e.wholeWord!==t.wholeWord)}_fireResults(e){if(e?.decorations){let e=-1;if(this._selectedDecoration.value){let t=this._selectedDecoration.value.match;for(let n=0;n<this._highlightDecorations.length;n++){let r=this._highlightDecorations[n].match;if(r.row===t.row&&r.col===t.col&&r.size===t.size){e=n;break}}}this._onDidChangeResults.fire({resultIndex:e,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,i=this._terminal.cols;this._initLinesCache();let a={startRow:r,startCol:i},o;if(n&&(a.startRow=r=n.start.y,a.startCol=i=n.start.x,this._cachedSearchTerm!==e&&(o=this._findInLine(e,a,t,!1),o||(a.startRow=r=n.end.y,a.startCol=i=n.end.x))),o||=this._findInLine(e,a,t,!0),!o){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let n=r-1;n>=0&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);}if(!o&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=r&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);return this._selectResult(o,t?.decorations,t?.noScroll)}_initLinesCache(){let e=this._terminal;this._linesCache||(this._linesCache=Array(e.buffer.active.length),this._linesCacheDisposables.value=(0,i.getDisposeArrayDisposable)([e.onLineFeed((()=>this._destroyLinesCache())),e.onCursorMove((()=>this._destroyLinesCache())),e.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&=(window.clearTimeout(this._linesCacheTimeoutId),0)}_isWholeWord(e,t,n){return(e===0||a.includes(t[e-1]))&&(e+n.length===t.length||a.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=this._terminal,a=t.startRow,o=t.startCol;if(i.buffer.active.getLine(a)?.isWrapped)return r?void(t.startCol+=i.cols):(t.startRow--,t.startCol+=i.cols,this._findInLine(e,t,n));let s=this._linesCache?.[a];s||(s=this._translateBufferLineToStringWithWrap(a,!0),this._linesCache&&(this._linesCache[a]=s));let[c,l]=s,u=this._bufferColsToStringOffset(a,o),d=n.caseSensitive?e:e.toLowerCase(),f=n.caseSensitive?c:c.toLowerCase(),p=-1;if(n.regex){let t=RegExp(d,`g`),n;if(r)for(;n=t.exec(f.slice(0,u));)p=t.lastIndex-n[0].length,e=n[0],t.lastIndex-=e.length-1;else n=t.exec(f.slice(u)),n&&n[0].length>0&&(p=u+(t.lastIndex-n[0].length),e=n[0])}else r?u-d.length>=0&&(p=f.lastIndexOf(d,u-d.length)):p=f.indexOf(d,u);if(p>=0){if(n.wholeWord&&!this._isWholeWord(p,f,e))return;let t=0;for(;t<l.length-1&&p>=l[t+1];)t++;let r=t;for(;r<l.length-1&&p+e.length>=l[r+1];)r++;let o=p-l[t],s=p+e.length-l[r],c=this._stringLengthToBufferSize(a+t,o);return{term:e,col:c,row:a+t,size:this._stringLengthToBufferSize(a+r,s)-c+i.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=this._terminal,r=e,i=0,a=n.buffer.active.getLine(r);for(;t>0&&a;){for(let e=0;e<t&&e<n.cols;e++){let t=a.getCell(e);if(!t)break;t.getWidth()&&(i+=t.getCode()===0?1:t.getChars().length)}if(r++,a=n.buffer.active.getLine(r),a&&!a.isWrapped)break;t-=n.cols}return i}_translateBufferLineToStringWithWrap(e,t){let n=this._terminal,r=[],i=[0],a=n.buffer.active.getLine(e);for(;a;){let o=n.buffer.active.getLine(e+1),s=!!o&&o.isWrapped,c=a.translateToString(!s&&t);if(s&&o){let e=a.getCell(a.length-1);e&&e.getCode()===0&&e.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(c=c.slice(0,-1))}if(r.push(c),!s)break;i.push(i[i.length-1]+c.length),e++,a=o}return[r.join(``),i]}_selectResult(e,t,n){let r=this._terminal;if(this._selectedDecoration.clear(),!e)return r.clearSelection(),!1;if(r.select(e.col,e.row,e.size),t){let n=r.registerMarker(-r.buffer.active.baseY-r.buffer.active.cursorY+e.row);if(n){let a=r.registerDecoration({marker:n,x:e.col,width:e.size,backgroundColor:t.activeMatchBackground,layer:`top`,overviewRulerOptions:{color:t.activeMatchColorOverviewRuler}});if(a){let r=[];r.push(n),r.push(a.onRender((e=>this._applyStyles(e,t.activeMatchBorder,!0)))),r.push(a.onDispose((()=>(0,i.disposeArray)(r)))),this._selectedDecoration.value={decoration:a,match:e,dispose(){a.dispose()}}}}}if(!n&&(e.row>=r.buffer.active.viewportY+r.rows||e.row<r.buffer.active.viewportY)){let t=e.row-r.buffer.active.viewportY;t-=Math.floor(r.rows/2),r.scrollLines(t)}return!0}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecoration(e,t){let n=this._terminal,r=n.registerMarker(-n.buffer.active.baseY-n.buffer.active.cursorY+e.row);if(!r)return;let a=n.registerDecoration({marker:r,x:e.col,width:e.size,backgroundColor:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:t.matchOverviewRuler,position:`center`}});if(a){let e=[];e.push(r),e.push(a.onRender((e=>this._applyStyles(e,t.matchBorder,!1)))),e.push(a.onDispose((()=>(0,i.disposeArray)(e))))}return a}}e.SearchAddon=o})(),r})()))})),fi=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.Unicode11Addon=r():n.Unicode11Addon=r()})(e,(()=>(()=>{var e={433:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV11=void 0;let r=n(938),i=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],a=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],o=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],s=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],c;function l(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}t.UnicodeV11=class{constructor(){if(this.version=`11`,!c){c=new Uint8Array(65536),c.fill(1),c[0]=0,c.fill(0,1,32),c.fill(0,127,160);for(let e=0;e<i.length;++e)c.fill(0,i[e][0],i[e][1]+1);for(let e=0;e<o.length;++e)c.fill(2,o[e][0],o[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?c[e]:l(e,a)?0:l(e,s)?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},490:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;let r=n(938),i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],o;t.UnicodeV6=class{constructor(){if(this.version=`6`,!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<i.length;++e)o.fill(0,i[e][0],i[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},938:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;let r=n(345),i=n(490);class a{static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(16777215&e)<<3|(3&t)<<1|!!n}constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,n=0,r=e.length;for(let i=0;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return t+this.wcwidth(o);let n=e.charCodeAt(i);56320<=n&&n<=57343?o=1024*(o-55296)+n-56320+65536:t+=this.wcwidth(n)}let s=this.charProperties(o,n),c=a.extractWidth(s);a.extractShouldJoin(s)&&(c-=a.extractWidth(n)),t+=c,n=s}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=a}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.Unicode11Addon=void 0;let t=n(433);e.Unicode11Addon=class{activate(e){e.unicode.register(new t.UnicodeV11)}dispose(){}}})(),r})()))})),pi=ci(),mi=li(),hi=ui(),gi=di(),_i=fi(),vi={fontFamily:`'DM Mono', 'JetBrains Mono', ui-monospace, Menlo, monospace`,fontSize:12,renderMode:`auto`,copyOnSelect:!1,shellIntegrationEnabled:!0,notifyOnCompletion:!0,imageRendering:!0,longCommandThresholdMs:6e4,browserShortcutUrl:`https://specrails.dev`,quickScript:`echo "Hello World!"`};function yi(e){return Number.isFinite(e)?Math.min(32,Math.max(8,Math.round(e))):vi.fontSize}var bi=new Map,xi=new Map;function Si(e){let t=bi.get(e);return t||(t={openPreExec:null,completed:[],cwd:null,promptRows:[]},bi.set(e,t)),t}function Ci(e){let t=xi.get(e);if(!t)return;let n=Si(e);for(let e of t)try{e(n)}catch{}}function wi(e,t,n){let r=Si(e);switch(t.kind){case`prompt-start`:r.promptRows.push({ts:t.ts,row:n?.row??null,exitCode:null}),r.promptRows.length>1e3&&r.promptRows.shift();break;case`pre-exec`:r.openPreExec={startedAt:t.ts};break;case`post-exec`:{let e=t.payload?.exitCode??null,n=r.openPreExec?.startedAt??t.ts;r.completed.push({startedAt:n,finishedAt:t.ts,exitCode:e});let i=r.promptRows[r.promptRows.length-1];i&&(i.exitCode=e),r.openPreExec=null,r.completed.length>1e3&&r.completed.shift();break}case`cwd`:r.cwd=t.payload?.path??null;break}Ci(e)}function Ti(e,t){let n=xi.get(e);return n||(n=new Set,xi.set(e,n)),n.add(t),()=>{n.delete(t)}}function Ei(e){return Si(e)}function Di(e){bi.delete(e),xi.delete(e)}var Oi=new Map,ki=5e3;function Ai(){return typeof document<`u`&&!document.hasFocus()}async function ji(e,t){let n=`${e}:${t.command??``}`,r=Date.now();if(r-(Oi.get(n)??0)<ki)return;Oi.set(n,r);let i=t.command?G.t(`terminal:notifications.commandFinishedNamed`,{command:Mi(t.command,50)}):G.t(`terminal:notifications.commandFinished`),a=G.t(`terminal:notifications.finishedBody`,{code:t.exitCode??`?`,elapsed:Ni(t.elapsedMs)});if(me()){try{let{invoke:e}=await c(async()=>{let{invoke:e}=await import(`./core-B3mKBIh5.js`).then(e=>e.i);return{invoke:e}},__vite__mapDeps([0,1]));await e(`desktop_notify`,{title:i,body:a})}catch{}return}try{if(typeof Notification>`u`||Notification.permission==="default"&&await Notification.requestPermission().catch(()=>`denied`)!==`granted`||Notification.permission!==`granted`)return;new Notification(i,{body:a})}catch{}}function Mi(e,t){return e.length<=t?e:e.slice(0,t-1)+`…`}function Ni(e){if(e<6e4)return G.t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)});let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return G.t(`terminal:duration.minutesSeconds`,{minutes:t,seconds:n})}var Pi=[`dracula`,`aurora-light`,`obsidian-dark`,`code-rain`,`specrails`,`galaxy`],Fi={"star-wars":`galaxy`,matrix:`code-rain`};function Ii(e){return typeof e==`string`&&Pi.includes(e)}var Li=`specrails`,Ri={bg:`hsl(231 15% 18%)`,fg:`hsl(60 30% 96%)`,current:`hsl(232 14% 31%)`,comment:`hsl(225 27% 51%)`,purple:`hsl(265 89% 78%)`,cyan:`hsl(191 97% 77%)`,green:`hsl(135 94% 65%)`,pink:`hsl(326 100% 74%)`,orange:`hsl(31 100% 71%)`,red:`hsl(0 100% 67%)`,yellow:`hsl(65 92% 76%)`},zi={id:`dracula`,displayName:`Dracula`,tagline:`The original — dark purple-tinted with vivid neon accents`,scheme:`dark`,previewSwatches:{background:Ri.bg,foreground:Ri.fg,accents:[Ri.purple,Ri.pink,Ri.cyan,Ri.green]},xterm:{background:Ri.bg,foreground:Ri.fg,cursor:Ri.purple,cursorAccent:Ri.bg,selectionBackground:`hsl(232 14% 36%)`,black:`hsl(232 14% 24%)`,red:Ri.red,green:Ri.green,yellow:Ri.yellow,blue:Ri.purple,magenta:Ri.pink,cyan:Ri.cyan,white:Ri.fg,brightBlack:Ri.comment,brightRed:`hsl(0 100% 78%)`,brightGreen:`hsl(135 94% 78%)`,brightYellow:`hsl(65 92% 86%)`,brightBlue:`hsl(265 89% 88%)`,brightMagenta:`hsl(326 100% 84%)`,brightCyan:`hsl(191 97% 87%)`,brightWhite:`hsl(60 30% 100%)`},chart:[Ri.purple,Ri.cyan,Ri.green,Ri.pink,Ri.orange],status:{completed:Ri.purple,failed:Ri.pink,canceled:Ri.orange,running:Ri.cyan,queued:Ri.comment}},Bi={bg:`hsl(220 25% 99%)`,fg:`hsl(230 28% 14%)`,surface:`hsl(220 22% 96%)`,muted:`hsl(225 14% 42%)`,primary:`hsl(255 75% 56%)`,info:`hsl(195 80% 42%)`,success:`hsl(150 65% 36%)`,secondary:`hsl(330 75% 52%)`,warning:`hsl(35 90% 48%)`,destructive:`hsl(0 72% 50%)`,highlight:`hsl(45 95% 48%)`},Vi={id:`aurora-light`,displayName:`Aurora Light`,tagline:`Premium light — Linear-inspired indigo on warm off-white`,scheme:`light`,previewSwatches:{background:Bi.bg,foreground:Bi.fg,accents:[Bi.primary,Bi.secondary,Bi.info,Bi.success]},xterm:{background:Bi.bg,foreground:Bi.fg,cursor:Bi.primary,cursorAccent:Bi.bg,selectionBackground:`hsl(255 75% 90%)`,black:`hsl(225 14% 18%)`,red:Bi.destructive,green:Bi.success,yellow:Bi.warning,blue:Bi.primary,magenta:Bi.secondary,cyan:Bi.info,white:Bi.fg,brightBlack:Bi.muted,brightRed:`hsl(0 72% 38%)`,brightGreen:`hsl(150 65% 26%)`,brightYellow:`hsl(35 90% 38%)`,brightBlue:`hsl(255 75% 42%)`,brightMagenta:`hsl(330 75% 38%)`,brightCyan:`hsl(195 80% 32%)`,brightWhite:`hsl(230 28% 8%)`},chart:[Bi.primary,Bi.info,Bi.success,Bi.secondary,Bi.warning],status:{completed:Bi.primary,failed:Bi.secondary,canceled:Bi.warning,running:Bi.info,queued:Bi.muted}},Hi={bg:`hsl(222 18% 8%)`,fg:`hsl(220 18% 92%)`,surface:`hsl(222 16% 12%)`,muted:`hsl(220 12% 60%)`,primary:`hsl(265 80% 72%)`,info:`hsl(192 90% 62%)`,success:`hsl(150 70% 55%)`,secondary:`hsl(330 80% 68%)`,warning:`hsl(35 95% 62%)`,destructive:`hsl(0 78% 62%)`,highlight:`hsl(50 95% 65%)`},Ui={id:`obsidian-dark`,displayName:`Obsidian Dark`,tagline:`Premium dark — near-black blue-tinted with electric accents`,scheme:`dark`,previewSwatches:{background:Hi.bg,foreground:Hi.fg,accents:[Hi.primary,Hi.info,Hi.secondary,Hi.success]},xterm:{background:Hi.bg,foreground:Hi.fg,cursor:Hi.primary,cursorAccent:Hi.bg,selectionBackground:`hsl(222 16% 22%)`,black:`hsl(222 16% 14%)`,red:Hi.destructive,green:Hi.success,yellow:Hi.warning,blue:Hi.primary,magenta:Hi.secondary,cyan:Hi.info,white:Hi.fg,brightBlack:Hi.muted,brightRed:`hsl(0 78% 78%)`,brightGreen:`hsl(150 70% 70%)`,brightYellow:`hsl(35 95% 78%)`,brightBlue:`hsl(265 80% 86%)`,brightMagenta:`hsl(330 80% 80%)`,brightCyan:`hsl(192 90% 78%)`,brightWhite:`hsl(220 18% 100%)`},chart:[Hi.primary,Hi.info,Hi.success,Hi.secondary,Hi.warning],status:{completed:Hi.primary,failed:Hi.secondary,canceled:Hi.warning,running:Hi.info,queued:Hi.muted}},Wi={bg:`hsl(154 30% 5%)`,fg:`hsl(150 100% 86%)`,surface:`hsl(154 28% 9%)`,muted:`hsl(150 40% 55%)`,primary:`hsl(144 100% 50%)`,info:`hsl(174 56% 56%)`,success:`hsl(145 100% 70%)`,secondary:`hsl(153 100% 33%)`,warning:`hsl(35 100% 64%)`,highlight:`hsl(51 100% 50%)`,destructive:`hsl(351 100% 65%)`},Gi={id:`code-rain`,displayName:`Code Rain`,tagline:`Phosphor terminal — soft mint on green-tinted near-black`,scheme:`dark`,previewSwatches:{background:Wi.bg,foreground:Wi.fg,accents:[Wi.primary,Wi.info,Wi.highlight,Wi.destructive]},xterm:{background:Wi.bg,foreground:Wi.fg,cursor:Wi.primary,cursorAccent:Wi.bg,selectionBackground:`hsl(154 40% 22%)`,black:`hsl(154 30% 10%)`,red:Wi.destructive,green:Wi.primary,yellow:Wi.warning,blue:Wi.info,magenta:Wi.highlight,cyan:Wi.info,white:Wi.fg,brightBlack:Wi.muted,brightRed:`hsl(351 100% 78%)`,brightGreen:Wi.success,brightYellow:`hsl(35 100% 78%)`,brightBlue:`hsl(174 56% 72%)`,brightMagenta:`hsl(51 100% 70%)`,brightCyan:`hsl(174 56% 78%)`,brightWhite:`hsl(150 100% 96%)`},chart:[Wi.primary,Wi.info,Wi.warning,Wi.highlight,Wi.destructive],status:{completed:Wi.primary,failed:Wi.destructive,canceled:Wi.warning,running:Wi.info,queued:Wi.muted}},Ki={bg:`hsl(240 33% 4%)`,card:`hsl(240 30% 8%)`,bgDeep:`hsl(240 40% 2%)`,fg:`hsl(240 20% 95%)`,muted:`hsl(240 13% 62%)`,primary:`hsl(187 100% 44%)`,secondary:`hsl(280 45% 62%)`,success:`hsl(152 78% 48%)`,info:`hsl(191 97% 55%)`,warning:`hsl(42 92% 58%)`,highlight:`hsl(248 75% 67%)`,destructive:`hsl(12 80% 55%)`},qi={id:`specrails`,displayName:`SpecRails`,tagline:`Brand theme — deep navy-indigo with saturated cyan accents`,scheme:`dark`,previewSwatches:{background:Ki.bg,foreground:Ki.fg,accents:[Ki.primary,Ki.highlight,Ki.secondary,Ki.success]},xterm:{background:Ki.bg,foreground:Ki.fg,cursor:Ki.primary,cursorAccent:Ki.bg,selectionBackground:`hsl(240 30% 22%)`,black:`hsl(240 35% 8%)`,red:Ki.destructive,green:Ki.success,yellow:Ki.warning,blue:Ki.highlight,magenta:Ki.secondary,cyan:Ki.primary,white:Ki.fg,brightBlack:Ki.muted,brightRed:`hsl(12 78% 66%)`,brightGreen:`hsl(152 80% 58%)`,brightYellow:`hsl(42 90% 70%)`,brightBlue:`hsl(248 70% 76%)`,brightMagenta:`hsl(280 38% 70%)`,brightCyan:`hsl(191 97% 65%)`,brightWhite:`hsl(240 20% 100%)`},chart:[Ki.primary,Ki.info,Ki.success,Ki.secondary,Ki.warning],status:{completed:Ki.primary,failed:Ki.destructive,canceled:Ki.warning,running:Ki.info,queued:Ki.muted}},Ji={bg:`hsl(220 20% 4%)`,card:`hsl(220 18% 8%)`,bgDeep:`hsl(220 24% 2%)`,fg:`hsl(210 30% 94%)`,muted:`hsl(215 15% 60%)`,primary:`hsl(212 100% 62%)`,info:`hsl(212 100% 62%)`,secondary:`hsl(210 12% 65%)`,success:`hsl(140 65% 50%)`,warning:`hsl(28 95% 56%)`,highlight:`hsl(55 90% 56%)`,destructive:`hsl(355 92% 56%)`},Yi={dracula:zi,"aurora-light":Vi,"obsidian-dark":Ui,"code-rain":Gi,specrails:qi,galaxy:{id:`galaxy`,displayName:`Galaxy`,tagline:`Deep-space blue with a glowing blade trail`,scheme:`dark`,previewSwatches:{background:Ji.bg,foreground:Ji.fg,accents:[Ji.primary,Ji.destructive,Ji.highlight,Ji.success]},xterm:{background:Ji.bg,foreground:Ji.fg,cursor:Ji.primary,cursorAccent:Ji.bg,selectionBackground:`hsl(220 18% 18%)`,black:`hsl(220 18% 7%)`,red:Ji.destructive,green:Ji.success,yellow:Ji.warning,blue:Ji.primary,magenta:Ji.secondary,cyan:Ji.primary,white:Ji.fg,brightBlack:Ji.muted,brightRed:`hsl(355 92% 68%)`,brightGreen:`hsl(140 65% 62%)`,brightYellow:`hsl(28 95% 68%)`,brightBlue:`hsl(212 100% 74%)`,brightMagenta:`hsl(210 12% 78%)`,brightCyan:`hsl(212 100% 74%)`,brightWhite:`hsl(210 30% 100%)`},chart:[Ji.primary,Ji.success,Ji.warning,Ji.secondary,Ji.destructive],status:{completed:Ji.primary,failed:Ji.destructive,canceled:Ji.warning,running:Ji.info,queued:Ji.muted}}},Xi=`specrails-desktop:ui-theme`;function Zi(){if(typeof document>`u`)return Li;let e=document.documentElement.dataset.theme;return Ii(e)?e:Li}function Qi(){return Yi[Zi()]}function $i(e={}){let t={...e},n=Ve();return n&&(t[`X-Desktop-Token`]=n),t}var ea=(0,Q.createContext)(null);function ta(e){return Ii(e)?e:typeof e==`string`?Fi[e]??null:null}function na(){if(typeof document>`u`)return Li;let e=document.documentElement.dataset.theme,t=ta(e);if(t)return t!==e&&(ra(t),ia(t)),t;if(typeof localStorage<`u`)try{let e=localStorage.getItem(Xi),t=ta(e);if(t)return t!==e&&(ra(t),ia(t)),t}catch{}return Li}function ra(e){typeof document>`u`||(document.documentElement.dataset.theme=e)}function ia(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Xi,e)}catch{}}function aa({children:e,endpoint:t=`/api/theme`}){let[n,r]=(0,Q.useState)(()=>na()),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(o.current)return;o.current=!0;let e=!1;return(async()=>{try{let i=await fetch(t,{headers:$i()});if(!i.ok)return;let a=await i.json();if(e)return;let o=ta(a.theme);o&&o!==n&&(ra(o),ia(o),r(o))}catch{}})(),()=>{e=!0}},[t]);let s=(0,Q.useCallback)(async e=>{if(e===n)return;let i=n;ra(e),ia(e),r(e),a(!0);try{let n=await fetch(t,{method:`PATCH`,headers:$i({"Content-Type":`application/json`}),body:JSON.stringify({theme:e})});if(!n.ok)throw Error(`server rejected theme: ${n.status}`)}catch(e){throw ra(i),ia(i),r(i),e}finally{a(!1)}},[n,t]),c=(0,Q.useMemo)(()=>({theme:Yi[n],themeId:n,setTheme:s,isUpdating:i}),[n,s,i]);return(0,$.jsx)(ea.Provider,{value:c,children:e})}function oa(){let e=(0,Q.useContext)(ea);if(!e)throw Error(`useTheme must be used within a ThemeProvider`);return e}function sa(){return(0,Q.useContext)(ea)}function ca(){let e=(0,Q.useContext)(ea);return e?e.theme:Qi()}var la=class e extends st{constructor(e){super(e)}static async new(t,n,r){return Y(`plugin:image|new`,{rgba:ua(t),width:n,height:r}).then(t=>new e(t))}static async fromBytes(t){return Y(`plugin:image|from_bytes`,{bytes:ua(t)}).then(t=>new e(t))}static async fromPath(t){return Y(`plugin:image|from_path`,{path:t}).then(t=>new e(t))}async rgba(){return Y(`plugin:image|rgba`,{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return Y(`plugin:image|size`,{rid:this.rid})}};function ua(e){return e==null?null:typeof e==`string`?e:e instanceof la?e.rid:e}async function da(e,t){await Y(`plugin:clipboard-manager|write_text`,{label:t?.label,text:e})}async function fa(){return await Y(`plugin:clipboard-manager|read_text`)}async function pa(){if(me())try{let e=await fa();return typeof e==`string`?e:null}catch{return null}try{if(typeof navigator<`u`&&navigator.clipboard?.readText)return await navigator.clipboard.readText()||null}catch{}return null}async function ma(e){if(me())try{return await da(e),!0}catch{return!1}try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return!1}var ha=(0,Q.createContext)(null);function ga(e){return`specrails-desktop:terminal-panel:${e}`}function _a(e){try{let t=localStorage.getItem(ga(e));if(!t)return null;let n=JSON.parse(t);if(!n)return null;let r=n.visibility,i=n.userHeight;return r!==`hidden`&&r!==`restored`&&r!==`maximized`||typeof i!=`number`||!Number.isFinite(i)?null:{visibility:r,userHeight:i}}catch{return null}}function va(e,t){try{localStorage.setItem(ga(e),JSON.stringify(t))}catch{}}function ya(e){return{visibility:e?.visibility??`hidden`,userHeight:e?.userHeight??320,sessions:[],activeId:null}}function ba(){let e=document.getElementById(`specrails-terminal-host`);return e||(e=document.createElement(`div`),e.id=`specrails-terminal-host`,e.style.position=`fixed`,e.style.left=`0`,e.style.top=`0`,e.style.width=`0`,e.style.height=`0`,e.style.overflow=`hidden`,e.style.visibility=`hidden`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),document.body.appendChild(e),e)}function xa({children:e,activeProjectId:t}){let[n,r]=(0,Q.useState)({}),i=(0,Q.useRef)(n);i.current=n;let a=(0,Q.useRef)(new Map),o=(0,Q.useRef)(new Map),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>(s.current=ba(),()=>{for(let e of a.current.values())Ma(e);a.current.clear(),o.current.clear()}),[]);let c=sa()?.theme??null;(0,Q.useEffect)(()=>{if(c)for(let e of a.current.values())try{e.term.options.theme=c.xterm}catch{}},[c]);let l=(0,Q.useCallback)((e,t)=>{r(n=>{let r=n[e]??ya(_a(e)),i=t(r);return i===r?n:((i.visibility!==r.visibility||i.userHeight!==r.userHeight)&&va(e,{visibility:i.visibility,userHeight:i.userHeight}),{...n,[e]:i})})},[]),u=(0,Q.useCallback)(e=>{r(t=>t[e]?t:{...t,[e]:ya(_a(e))})},[]),d=(0,Q.useCallback)(e=>i.current[e]??ya(_a(e)),[]),f=(0,Q.useCallback)((e,t)=>{l(e,e=>e.visibility===t?e:{...e,visibility:t})},[l]),p=(0,Q.useCallback)(e=>{l(e,e=>({...e,visibility:e.visibility===`hidden`?`restored`:`hidden`}))},[l]),m=(0,Q.useCallback)((e,t)=>{l(e,e=>e.userHeight===t?e:{...e,userHeight:t})},[l]),h=(0,Q.useCallback)((e,t)=>{l(e,e=>e.activeId===t?e:{...e,activeId:t})},[l]),g=(0,Q.useRef)(t);g.current=t,(0,Q.useEffect)(()=>{if(!t)return;u(t);let e=!1;return(async()=>{try{let n=await fetch(`${He}/api/projects/${t}/terminals`);if(!n.ok)return;let r=await n.json();if(e)return;l(t,e=>{let t=new Set(r.sessions.map(e=>e.id));for(let n of e.sessions.map(e=>e.id))if(!t.has(n)){let e=a.current.get(n);e&&(Ma(e),a.current.delete(n),o.current.delete(n),Di(n))}let n=r.sessions.map(t=>{let n=e.sessions.find(e=>e.id===t.id);return n?{...n,...t}:t}),i=n.find(t=>t.id===e.activeId)?.id??n[0]?.id??null;for(let e of n)a.current.has(e.id)||Da(e.projectId,e.id,e.cols,e.rows,a.current,o.current,s.current);return{...e,sessions:n,activeId:i}})}catch{}})(),()=>{e=!0}},[t,u,l]);let _=(0,Q.useCallback)(async(e,t)=>{let n=t?.cols??80,r=t?.rows??24;try{let i=await fetch(`${He}/api/projects/${e}/terminals`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:n,rows:r,name:t?.name})});if(!i.ok){let e=``;try{e=(await i.json())?.error??``}catch{}return J.error(e===`terminal_limit_exceeded`?G.t(`terminal:errors.limitReached`,{max:10}):e===`terminal_spawn_failed`?G.t(`terminal:errors.spawnFailed`):e===`terminal_name_invalid`?G.t(`terminal:errors.invalidName`):G.t(`terminal:errors.openFailed`)),null}let c=(await i.json()).session;return Da(e,c.id,c.cols,c.rows,a.current,o.current,s.current,vi,void 0,void 0,!0),l(e,e=>({...e,sessions:[...e.sessions,c],activeId:c.id})),c}catch{return J.error(G.t(`terminal:errors.serverUnreachable`)),null}},[l]),v=(0,Q.useCallback)(async(e,t,n)=>{let r=await _(e,n);if(!r)return null;let i=a.current.get(r.id);if(!i)return r;let o=()=>{let e=i.ws;if(e)try{e.send(new TextEncoder().encode(t))}catch{}};return i.ws&&i.ws.readyState===WebSocket.OPEN?setTimeout(o,50):i.ws&&i.ws.addEventListener(`open`,()=>setTimeout(o,50),{once:!0}),r},[]),y=(0,Q.useCallback)((e,t)=>{let n=a.current.get(e);if(!n?.ws||n.ws.readyState!==WebSocket.OPEN)return!1;try{n.ws.send(new TextEncoder().encode(t));try{n.term.focus()}catch{}return!0}catch{return!1}},[]),b=(0,Q.useCallback)(async(e,t,n)=>{try{let r=await fetch(`${He}/api/projects/${e}/terminals/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok)return!1;let i=await r.json();return l(e,e=>({...e,sessions:e.sessions.map(e=>e.id===t?{...e,name:i.session.name}:e)})),!0}catch{return!1}},[l]),x=(0,Q.useCallback)(async(e,t)=>{let n=a.current.get(t);n&&(Ma(n),a.current.delete(t),o.current.delete(t),Di(t)),l(e,e=>{let n=e.sessions.filter(e=>e.id!==t),r=e.activeId===t?n[0]?.id??null:e.activeId;return{...e,sessions:n,activeId:r}});try{await fetch(`${He}/api/projects/${e}/terminals/${t}`,{method:`DELETE`})}catch{}},[l]),S=(0,Q.useCallback)(e=>{let t=i.current[e];if(!t?.activeId)return;let n=a.current.get(t.activeId);if(n?.attached)try{n.term.focus()}catch{}},[]),C=(0,Q.useCallback)(e=>{for(let[t,n]of o.current.entries()){if(n!==e)continue;let r=a.current.get(t);r&&(Ma(r),a.current.delete(t)),o.current.delete(t)}r(t=>{if(!t[e])return t;let{[e]:n,...r}=t;return r});try{localStorage.removeItem(ga(e))}catch{}},[]),w=(0,Q.useCallback)(e=>a.current.get(e)?.container??null,[]),T=(0,Q.useCallback)(e=>{let t=a.current.get(e);if(!t)return;let n=!t.term.element||t.term.element.parentElement!==t.container;if(t.attached=!0,n){try{t.term.open(t.container)}catch{}let e=t.settings.renderMode;(e===`webgl`||e===`auto`&&ja())&&!t.webgl&&Aa(t.term).then(e=>{e&&(t.webgl=e)})}try{t.fit.fit()}catch{}try{t.term.focus()}catch{}let r=t.term.cols,i=t.term.rows;if(t.ws&&t.ws.readyState===WebSocket.OPEN)try{t.ws.send(JSON.stringify({type:`resize`,cols:r,rows:i}))}catch{}},[]),E=(0,Q.useCallback)(e=>{let t=a.current.get(e);if(!(!t||!t.attached)){try{t.fit.fit()}catch{}if(t.ws&&t.ws.readyState===WebSocket.OPEN)try{t.ws.send(JSON.stringify({type:`resize`,cols:t.term.cols,rows:t.term.rows}))}catch{}}},[]),D=(0,Q.useCallback)((e,t)=>{let n=a.current.get(e);return n?(n.markListeners.add(t),()=>{n.markListeners.delete(t)}):()=>{}},[]),O=(0,Q.useCallback)(e=>a.current.get(e)?.currentCwd??Object.values(i.current).flatMap(e=>e.sessions).find(t=>t.id===e)?.cwd??null,[]),k=(0,Q.useCallback)(e=>Object.values(i.current).flatMap(e=>e.sessions).find(t=>t.id===e)?.shell??null,[]),A=(0,Q.useCallback)(e=>a.current.get(e)?.search??null,[]),j=(0,Q.useCallback)(e=>a.current.get(e)?.term??null,[]),M=(0,Q.useCallback)((e,t)=>{let n=a.current.get(e);return n?(n.openSearchListeners.add(t),()=>{n.openSearchListeners.delete(t)}):()=>{}},[]),N=(0,Q.useMemo)(()=>({states:n,getState:d,ensureProject:u,setVisibility:f,togglePanel:p,setUserHeight:m,setActive:h,create:_,createAndType:v,writeToSession:y,rename:b,kill:x,focusActive:S,disposeProject:C,getContainer:w,notifyAdopted:T,refitActive:E,subscribeMarks:D,getCwd:O,getShell:k,getSearchAddon:A,subscribeOpenSearch:M,getTerminalInstance:j}),[n,d,u,f,p,m,h,_,v,y,b,x,S,C,w,T,E,D,O,k,A,M,j]);return(0,$.jsx)(ha.Provider,{value:N,children:e})}var Sa={states:{},getState:e=>ya(null),ensureProject:()=>{},setVisibility:()=>{},togglePanel:()=>{},setUserHeight:()=>{},setActive:()=>{},create:async()=>null,createAndType:async()=>null,writeToSession:()=>!1,rename:async()=>!1,kill:async()=>{},focusActive:()=>{},disposeProject:()=>{},getContainer:()=>null,notifyAdopted:()=>{},refitActive:()=>{},subscribeMarks:()=>()=>{},getCwd:()=>null,getShell:()=>null,getSearchAddon:()=>null,subscribeOpenSearch:()=>()=>{},getTerminalInstance:()=>null};function Ca(){return(0,Q.useContext)(ha)??Sa}function wa(e){let t=Ca();return e?t.states[e]??ya(_a(e)):ya(null)}function Ta(e,t,n,r,i){let a=e.get(t);if(!a)return;let o=a.term.options.fontSize??vi.fontSize,s;if(r===`reset`)s=a.settings.fontSize,i&&i(n,{fontSize:null});else{let e=o+r;if(e<8||e>32)return;s=yi(e),i&&i(n,{fontSize:s})}if(s!==o)try{a.term.options.fontSize=s,a.fit.fit()}catch{}}function Ea(e,t,n){let r=e.get(t);if(!r)return;let{promptRows:i}=Ei(t);if(i.length===0)return;let a=r.term.buffer.active.viewportY,o=null;if(n===`prev`)for(let e=i.length-1;e>=0;e--){let t=i[e].row;if(t!=null&&t<a){o=t;break}}else for(let e of i){let t=e.row;if(t!=null&&t>a){o=t;break}}if(o!=null)try{r.term.scrollToLine(o)}catch{}}function Da(e,t,n,r,i,a,o,s=vi,c,l,u=!1){let d=i.get(t);if(d)return d;let f=document.createElement(`div`);f.style.width=`100%`,f.style.height=`100%`,f.className=`specrails-xterm-container`;let p=new pi.Terminal({cols:n,rows:r,fontFamily:s.fontFamily,fontSize:s.fontSize,theme:Qi().xterm,cursorBlink:!0,scrollback:1e4,allowProposedApi:!0}),m=new mi.FitAddon,h=new hi.WebLinksAddon,g=new gi.SearchAddon;p.loadAddon(m),p.loadAddon(h),p.loadAddon(g),p.attachCustomKeyEventHandler(n=>{if(n.type!==`keydown`||!(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?n.metaKey:n.ctrlKey))return!0;let r=n.key;if(r===`c`||r===`C`){let e=p.getSelection();return e.length===0?!0:(ma(e),n.preventDefault(),!1)}if(r===`v`||r===`V`)return pa().then(e=>{if(e)try{p.paste(e)}catch{}}),n.preventDefault(),!1;if(r===`k`||r===`K`){try{p.clear()}catch{}return n.preventDefault(),!1}if(r===`f`||r===`F`){n.preventDefault();let e=i.get(t);if(e)for(let t of e.openSearchListeners)try{t()}catch{}return!1}return r===`=`||r===`+`?(n.preventDefault(),Ta(i,t,e,1,l),!1):r===`-`||r===`_`?(n.preventDefault(),Ta(i,t,e,-1,l),!1):r===`0`?(n.preventDefault(),Ta(i,t,e,`reset`,l),!1):r===`ArrowUp`||r===`ArrowDown`?(n.preventDefault(),Ea(i,t,r===`ArrowUp`?`prev`:`next`),!1):!0});try{let e=new _i.Unicode11Addon;p.loadAddon(e),p.unicode.activeVersion=`11`}catch{}s.imageRendering&&Oa(p),ka(p),o&&o.appendChild(f);let _=`${ae||(typeof window<`u`?`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`:`ws://localhost:4200`)}/ws/terminal/${t}?projectId=${encodeURIComponent(e)}`,v=Ie(),y=v?new WebSocket(_,[`specrails-desktop`,v]):new WebSocket(_);y.binaryType=`arraybuffer`;let b=[];y.onmessage=e=>{if(typeof e.data==`string`){try{let n=JSON.parse(e.data);if(n?.type===`ready`)return;if(n?.type===`exit`){let e=i.get(t);e&&x(e,n.code??null,!!n.early);return}if(n?.type===`mark`&&typeof n.kind==`string`&&typeof n.ts==`number`){let e=i.get(t);if(e){n.kind===`cwd`&&n.payload?.path&&(e.currentCwd=n.payload.path);let r={type:`mark`,kind:n.kind,payload:n.payload,ts:n.ts,sessionId:t},i=e.term.buffer.active,a=n.kind===`prompt-start`?i.cursorY+i.viewportY:null,o=n.kind===`post-exec`?Ei(t).openPreExec?.startedAt??null:null;if(wi(t,n,{row:a}),n.kind===`post-exec`&&o!=null&&Ai()){let r=n.ts-o,i=e.settings.longCommandThresholdMs;e.settings.notifyOnCompletion&&r>=i&&ji(t,{command:null,exitCode:n.payload?.exitCode??null,elapsedMs:r})}for(let t of e.markListeners)try{t(r)}catch{}c&&c(r)}}}catch{}return}let n=i.get(t);n&&(n.gotData=!0);let r=new Uint8Array(e.data);try{p.write(r)}catch{}};let x=(e,t,n)=>{if(!e.exitShown){e.exitShown=!0;try{let n=t===null?G.t(`terminal:session.processExited`):G.t(`terminal:session.processExitedWithCode`,{code:t});e.term.write(`\r\n\x1b[2m${n}\x1b[0m\r\n`)}catch{}n&&!e.gotUserInput&&J.error(G.t(`terminal:errors.exitedImmediately`))}};y.onclose=e=>{let n=i.get(t);if(!n||n.disposing||n.exitShown)return;let r=(typeof e?.reason==`string`?e.reason:``)===`pty_exit_early`,a=n.openedAt>0&&Date.now()-n.openedAt<3e3&&!n.gotData&&!n.gotUserInput;x(n,null,r||a)};let S=p.onData(e=>{let n=i.get(t);if(n&&(n.gotUserInput=!0),y.readyState===WebSocket.OPEN)try{y.send(new TextEncoder().encode(e))}catch{}});b.push(()=>S.dispose());let C=null,w=()=>{if(f.isConnected){try{m.fit()}catch{return}if(y.readyState===WebSocket.OPEN)try{y.send(JSON.stringify({type:`resize`,cols:p.cols,rows:p.rows}))}catch{}}},T=()=>{C&&clearTimeout(C),C=setTimeout(()=>{C=null,w()},120)};y.onopen=()=>{let e=i.get(t);e&&(e.openedAt=Date.now()),w()};let E=new ResizeObserver(T);E.observe(f),b.push(()=>{C&&clearTimeout(C),E.disconnect()});let D={term:p,fit:m,webLinks:h,search:g,webgl:null,settings:s,container:f,ws:y,attached:!1,disposers:b,openedAt:0,gotData:!1,gotUserInput:!1,disposing:!1,exitShown:!1,currentCwd:null,markListeners:new Set,openSearchListeners:new Set};return i.set(t,D),a.set(t,e),D}async function Oa(t){try{let n=(await c(()=>import(`./addon-image-BRmmRHgQ.js`).then(t=>e(t.default,1)),__vite__mapDeps([3,1]))).ImageAddon,r=new n({pixelLimit:8e6});t.loadAddon(r)}catch{}}async function ka(t){try{let n=(await c(()=>import(`./addon-ligatures-qIZUPvRV.js`).then(t=>e(t.default,1)),__vite__mapDeps([4,1]))).LigaturesAddon;t.loadAddon(new n)}catch{}}async function Aa(t){try{let n=(await c(()=>import(`./addon-webgl-C2d7lriQ.js`).then(t=>e(t.default,1)),__vite__mapDeps([5,1]))).WebglAddon,r=new n;return r.onContextLoss(()=>{try{r.dispose()}catch{}}),t.loadAddon(r),r}catch{return null}}function ja(){try{let e=document.createElement(`canvas`);return!!(e.getContext(`webgl2`)||e.getContext(`experimental-webgl2`))}catch{return!1}}function Ma(e){e.disposing=!0;for(let t of e.disposers)try{t()}catch{}e.disposers=[],e.markListeners.clear(),e.openSearchListeners.clear();try{e.ws?.close(1e3,`client_dispose`)}catch{}e.ws=null;try{e.webgl?.dispose()}catch{}e.webgl=null;try{e.term.dispose()}catch{}try{e.container.remove()}catch{}}var Na=class extends Error{code;status;constructor(e,t){super(G.t(`network.${e}`,{ns:`common`,status:t})),this.code=e,this.status=t,this.name=`ApiResponseError`}};async function Pa(e){let t=await e.text(),n=e.headers?.get(`content-type`)??``;if(/\btext\/html\b|\bapplication\/xhtml\+xml\b/i.test(n)||/^\s*</.test(t))throw new Na(`htmlResponse`,e.status);if(!t.trim())return null;try{return JSON.parse(t)}catch{throw new Na(`invalidResponse`,e.status)}}async function Fa(e){let t=await Pa(e);if(!e.ok){let n=t&&typeof t==`object`&&`error`in t?t.error:void 0;throw n===`api_route_not_found`?new Na(`endpointUnavailable`,e.status):Error(typeof n==`string`&&n?n:G.t(`network.httpError`,{ns:`common`,status:e.status}))}return t}var Ia=`${He}/api/agent`;async function La(e){let t=await Fa(await fetch(`${Ia}/models?provider=${encodeURIComponent(e)}`));return{models:t.models,customModelAliases:t.customModelAliases===!0,supportsImageInput:t.supportsImageInput!==!1,efforts:Array.isArray(t.efforts)?t.efforts:[]}}async function Ra(){return(await Fa(await fetch(`${Ia}/conversations`))).conversations}async function za(e,t=20,n){let r=new URLSearchParams({q:e,limit:String(t)});return(await Fa(await fetch(`${Ia}/search?${r.toString()}`,{signal:n}))).results}async function Ba(){return Fa(await fetch(`${Ia}/active-turns`))}async function Va(e){return(await Fa(await fetch(`${Ia}/conversations`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}))).conversation}async function Ha(e){return Fa(await fetch(`${Ia}/conversations/${e}`))}async function Ua(e,t){return(await Fa(await fetch(`${Ia}/conversations/${e}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}))).conversation}async function Wa(e){await Fa(await fetch(`${Ia}/conversations/${e}`,{method:`DELETE`}))}async function Ga(e,t,n={}){let r;try{if(r=await Fa(await fetch(`${Ia}/conversations/${e}/send`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,...n})})),r?.accepted!==!0||typeof r.queued!=`boolean`)throw new Na(`invalidResponse`,200)}catch(e){if(e instanceof Na||e instanceof TypeError){let t=e instanceof Na?e.message:G.t(`network.requestFailed`,{ns:`common`});throw Error(`${t} ${G.t(`network.deliveryUnconfirmed`,{ns:`common`})}`)}throw e}return{queued:r?.queued===!0,...r?.deliveryMode?{deliveryMode:r.deliveryMode}:{},...r?.message?{message:r.message}:{},...r?.duplicate===void 0?{}:{duplicate:r.duplicate},...r?.removed===void 0?{}:{removed:r.removed}}}async function Ka(e,t){let n=new FormData;return n.append(`file`,t),(await Fa(await fetch(`${Ia}/conversations/${e}/attachments`,{method:`POST`,body:n}))).attachment}async function qa(e){return(await Fa(await fetch(`${Ia}/conversations/${e}/attachments`))).attachments}function Ja(e,t){return`${Ia}/conversations/${e}/attachments/${t}`}async function Ya(e,t){let n=await fetch(Ja(e,t));if(!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()}async function Xa(e,t){await Fa(await fetch(`${Ia}/conversations/${e}/attachments/${t}`,{method:`DELETE`}))}async function Za(e){await Fa(await fetch(`${Ia}/conversations/${e}/abort`,{method:`POST`}))}async function Qa(e,t,n){let r=await fetch(`${Ia}/conversations/${e}/queue/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({text:n})});return r.status===409?`conflict`:(await Fa(r),`saved`)}async function $a(e,t){let n=await fetch(`${Ia}/conversations/${encodeURIComponent(e)}/queue/${encodeURIComponent(t)}/steer`,{method:`POST`});return n.status===409?`conflict`:(await Fa(n),`saved`)}async function eo(e,t){let n=await fetch(`${Ia}/conversations/${encodeURIComponent(e)}/queue/${encodeURIComponent(t)}`,{method:`DELETE`});return n.status===409?`conflict`:(await Fa(n),`saved`)}var to=[`building`,`on_review`,`pr_draft`,`pr_ready`,`no_changes`,`completed`,`pr_closed`,`superseded`,`merged`,`discarded`,`implementation_failed`,`pr_failed`],no=[`none`,`local-only`,`pushed`,`pr-created`];function ro(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind!==`pr_decision`||typeof t.prDeliveryId!=`string`||!t.prDeliveryId||typeof t.railIndex!=`number`||!Number.isFinite(t.railIndex)||typeof t.projectId!=`string`||!t.projectId||typeof t.baseBranch!=`string`||typeof t.decision!=`string`||!to.includes(t.decision))return null;let n=ut({...t,prDeliveryId:t.prDeliveryId},t.railIndex);return n?{kind:`pr_decision`,prDeliveryId:t.prDeliveryId,railIndex:t.railIndex,projectId:t.projectId,baseBranch:t.baseBranch,ticketIds:n.ticketIds,decision:t.decision,prUrl:typeof t.prUrl==`string`&&t.prUrl?t.prUrl:null,prNumber:typeof t.prNumber==`number`&&Number.isInteger(t.prNumber)&&t.prNumber>0?t.prNumber:null,prState:typeof t.prState==`string`&&no.includes(t.prState)?t.prState:`none`,branch:typeof t.branch==`string`&&t.branch?t.branch:null,runIds:n.runIds,implementationOutcome:n.implementationOutcome,deliveryOutcome:n.deliveryOutcome,statusCode:n.statusCode,statusDetail:n.statusDetail,deliverySha:n.deliverySha,isContinuation:n.isContinuation,supersedesDeliveryId:n.supersedesDeliveryId,restoredFromDeliveryId:n.restoredFromDeliveryId,operation:n.operation,cleanupWarnings:n.cleanupWarnings,safetyArchives:n.safetyArchives,units:n.units,executionManifest:n.executionManifest,repositoryDeliveries:n.repositoryDeliveries,createdAt:n.createdAt,updatedAt:n.updatedAt}:null}function io(e){try{return ro(JSON.parse(e))}catch{return null}}var ao=[`create-pr`,`publish`,`discard`,`poll-merge`,`merge-local`,`dismiss`,`reopen`,`acknowledge-no-changes`,`recover-and-retry`];async function oo(e,t){let n=await fetch(`${He}/api/projects/${e}/rails/pr-decision`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=null;try{if(r=await Pa(n),n.ok&&(!r||typeof r!=`object`||Array.isArray(r)))throw new Na(`invalidResponse`,n.status)}catch(e){return{kind:`failed`,detail:e instanceof Error?e.message:G.t(`network.invalidResponse`,{ns:`common`}),snapshot:null}}if(n.ok){let e=ut(r?.snapshot);return{kind:`ok`,decision:typeof r?.decision==`string`?r.decision:e?.decision??t.expectedDecision,prUrl:typeof r?.prUrl==`string`?r.prUrl:e?.prUrl??null,prState:typeof r?.prState==`string`&&no.includes(r.prState)?r.prState:e?.prState??`none`,merged:r?.merged===!0,detail:typeof r?.detail==`string`&&r.detail?r.detail:null,deliveryVerified:typeof r?.deliveryVerified==`boolean`?r.deliveryVerified:null,verifiedSha:typeof r?.verifiedSha==`string`?r.verifiedSha:null,remoteHeadSha:typeof r?.remoteHeadSha==`string`?r.remoteHeadSha:null,pushed:typeof r?.pushed==`boolean`?r.pushed:null,recoveryUnavailable:r?.recoveryUnavailable===!0,snapshot:e}}if(n.status===409){if(r?.error===`project_recovery_in_progress`)return{kind:`recovering`,snapshot:ut(r?.snapshot)};if(r?.error===`operation_in_progress`){let e=ut(r?.snapshot),t=e?.operation??r?.operation;return{kind:`busy`,operation:typeof t==`string`&&(t===`checkout`||ao.includes(t))?t:null,snapshot:e}}if(r?.error===`merge_local_blocked`&&(r.reason===`dirty`||r.reason===`wrong_branch`))return{kind:`blocked`,reason:r?.reason===`dirty`?`dirty`:`wrong_branch`,base:String(r?.base??``),current:typeof r?.current==`string`?r.current:null,snapshot:ut(r?.snapshot)};if(r?.error===`stale_decision`)return{kind:`stale`,current:String(r?.current??``),snapshot:ut(r?.snapshot)}}return{kind:`failed`,detail:String(r?.detail??r?.error??`HTTP ${n.status}`),snapshot:ut(r?.snapshot)}}function so(e,t){return{...e,prDeliveryId:t.prDeliveryId,railIndex:t.railIndex,baseBranch:t.baseBranch,ticketIds:t.ticketIds,decision:t.decision,prUrl:t.prUrl,prNumber:t.prNumber,prState:t.prState,branch:t.branch,runIds:t.runIds,implementationOutcome:t.implementationOutcome,deliveryOutcome:t.deliveryOutcome,statusCode:t.statusCode,statusDetail:t.statusDetail,deliverySha:t.deliverySha,isContinuation:t.isContinuation,supersedesDeliveryId:t.supersedesDeliveryId,restoredFromDeliveryId:t.restoredFromDeliveryId,operation:t.operation,cleanupWarnings:t.cleanupWarnings,safetyArchives:t.safetyArchives,units:t.units,executionManifest:t.executionManifest,repositoryDeliveries:t.repositoryDeliveries,createdAt:t.createdAt,updatedAt:t.updatedAt}}async function co(e,t,n){let r=await fetch(`${He}/api/projects/${e}/rails/pr-checkout`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prDeliveryId:t,...n?{repositoryId:n}:{}})}),i=null;try{if(i=await Pa(r),r.ok&&(!i||typeof i!=`object`||Array.isArray(i)))throw new Na(`invalidResponse`,r.status)}catch(e){return{kind:`failed`,error:`invalid_api_response`,detail:e instanceof Error?e.message:G.t(`network.invalidResponse`,{ns:`common`})}}return r.ok?{kind:`ok`,branch:typeof i?.branch==`string`?i.branch:null,cleanupWarnings:Array.isArray(i?.cleanupWarnings)?i.cleanupWarnings.filter(e=>typeof e==`string`&&e.length>0):[]}:r.status===409&&i?.error===`project_recovery_in_progress`?{kind:`recovering`}:{kind:`failed`,error:String(i?.error??`http_${r.status}`),detail:String(i?.detail??i?.error??`HTTP ${r.status}`)}}async function lo(){let e=await Fa(await fetch(`${He}/api/available-providers`)),t=Object.entries(e).filter(([e,t])=>e!==`tiers`&&t===!0).map(([e])=>e);return{any:t.length>0,installed:t}}async function uo(){return Fa(await fetch(`${He}/api/mcp-admin/status`))}async function fo(){await Fa(await fetch(`${He}/api/mcp-admin/enable`,{method:`POST`}))}var po=q(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),mo=q(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),ho=q(`arrow-down-up`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]),go=q(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),_o=q(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),vo=q(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),yo=q(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),bo=q(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),xo=q(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),So=q(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Co=q(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),wo=q(`brain-circuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),To=q(`briefcase-business`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),Eo=q(`briefcase`,[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),Do=q(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Oo=q(`chart-no-axes-column`,[[`path`,{d:`M5 21v-6`,key:`1hz6c0`}],[`path`,{d:`M12 21V3`,key:`1lcnhd`}],[`path`,{d:`M19 21V9`,key:`unv183`}]]),ko=q(`chart-pie`,[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]]),Ao=q(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),jo=q(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Mo=q(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),No=q(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),Po=q(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Fo=q(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),Io=q(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),Lo=q(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ro=q(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),zo=q(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),Bo=q(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),Vo=q(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),Ho=q(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Uo=q(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Wo=q(`corner-up-right`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M4 20v-7a4 4 0 0 1 4-4h12`,key:`1lu4f8`}]]),Go=q(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Ko=q(`crop`,[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]),qo=q(`crown`,[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Jo=q(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Yo=q(`drafting-compass`,[[`path`,{d:`m12.99 6.74 1.93 3.44`,key:`iwagvd`}],[`path`,{d:`M19.136 12a10 10 0 0 1-14.271 0`,key:`ppmlo4`}],[`path`,{d:`m21 21-2.16-3.84`,key:`vylbct`}],[`path`,{d:`m3 21 8.02-14.26`,key:`1ssaw4`}],[`circle`,{cx:`12`,cy:`5`,r:`2`,key:`f1ur92`}]]),Xo=q(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Zo=q(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Qo=q(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),$o=q(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),es=q(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),ts=q(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),ns=q(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),rs=q(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),is=q(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),as=q(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),os=q(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ss=q(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),cs=q(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),ls=q(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),us=q(`github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),ds=q(`graduation-cap`,[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]),fs=q(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ps=q(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),ms=q(`heart`,[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]),hs=q(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),gs=q(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),_s=q(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),vs=q(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ys=q(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),bs=q(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),xs=q(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Ss=q(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Cs=q(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ws=q(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ts=q(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),Es=q(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Ds=q(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Os=q(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),ks=q(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),As=q(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),js=q(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Ms=q(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Ns=q(`package-open`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),Ps=q(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Fs=q(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Is=q(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Ls=q(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Rs=q(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),zs=q(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Bs=q(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Vs=q(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Hs=q(`pipette`,[[`path`,{d:`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`,key:`1y3wsu`}],[`path`,{d:`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`,key:`110lr1`}],[`path`,{d:`m2 22 .414-.414`,key:`jhxm08`}]]),Us=q(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Ws=q(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Gs=q(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),Ks=q(`ratio`,[[`rect`,{width:`12`,height:`20`,x:`6`,y:`2`,rx:`2`,key:`1oxtiu`}],[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}]]),qs=q(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),Js=q(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Ys=q(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),Xs=q(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Zs=q(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qs=q(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),$s=q(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),ec=q(`search-check`,[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),tc=q(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),nc=q(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),rc=q(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ic=q(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ac=q(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),oc=q(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),sc=q(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),cc=q(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),lc=q(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),uc=q(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),dc=q(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),fc=q(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),pc=q(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]),mc=q(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),hc=q(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),gc=q(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]);function _c(){let{t:e}=K(`agent`),{active:t}=lM(),n=si();if(!n.available||!t)return null;let r=n.current?.conversationId===t.id,i=n.isPending(t.id),a=e(r?`window.attach`:`window.detach`);return(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:i,title:a,"aria-label":a,className:`rounded-md p-1.5 text-foreground/60 hover:bg-surface hover:text-foreground disabled:opacity-40`,onClick:()=>{r?n.attach():n.detach(t.pinned_project_id,t.id)},children:i?(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`}):r?(0,$.jsx)(mo,{className:`h-4 w-4`}):(0,$.jsx)(Vt,{className:`h-4 w-4`})})}function vc(){let{t:e}=K(`agent`),{error:t,clearError:n}=si();return t?(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-3 border-b border-border bg-destructive/10 px-4 py-2 text-sm`,children:[(0,$.jsxs)(`span`,{className:`flex-1`,children:[e(`window.failed`),` `,t]}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-2 py-1 hover:bg-muted`,children:e(`window.dismiss`)})]}):null}var yc=(0,Q.createContext)({});function bc(e){let t=(0,Q.useRef)(null);return t.current===null&&(t.current=e()),t.current}var xc=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,Sc=(0,Q.createContext)(null);function Cc(e,t){e.indexOf(t)===-1&&e.push(t)}function wc(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Tc=(e,t,n)=>n>t?t:n<e?e:n,Ec={},Dc=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Oc=e=>typeof e==`object`&&!!e,kc=e=>/^0[^.\s]+$/u.test(e);function Ac(e){let t;return()=>(t===void 0&&(t=e()),t)}var jc=e=>e,Mc=(...e)=>e.reduce((e,t)=>n=>t(e(n))),Nc=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},Pc=class{constructor(){this.subscriptions=[]}add(e){return Cc(this.subscriptions,e),()=>wc(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Fc=e=>e*1e3,Ic=e=>e/1e3,Lc=(e,t)=>t?1e3/t*e:0,Rc=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,zc=1e-7,Bc=12;function Vc(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=Rc(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>zc&&++s<Bc);return o}function Hc(e,t,n,r){if(e===t&&n===r)return jc;let i=t=>Vc(t,0,1,e,n);return e=>e===0||e===1?e:Rc(i(e),t,r)}var Uc=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Wc=e=>t=>1-e(1-t),Gc=Hc(.33,1.53,.69,.99),Kc=Wc(Gc),qc=Uc(Kc),Jc=e=>e>=1?1:(e*=2)<1?.5*Kc(e):.5*(2-2**(-10*(e-1))),Yc=e=>1-Math.sin(Math.acos(e)),Xc=Wc(Yc),Zc=Uc(Yc),Qc=Hc(.42,0,1,1),$c=Hc(0,0,.58,1),el=Hc(.42,0,.58,1),tl=e=>Array.isArray(e)&&typeof e[0]!=`number`,nl=e=>Array.isArray(e)&&typeof e[0]==`number`,rl={linear:jc,easeIn:Qc,easeInOut:el,easeOut:$c,circIn:Yc,circInOut:Zc,circOut:Xc,backIn:Kc,backInOut:qc,backOut:Gc,anticipate:Jc},il=e=>typeof e==`string`,al=e=>{if(nl(e)){e.length;let[t,n,r,i]=e;return Hc(t,n,r,i)}else if(il(e))return rl[e],`${e}`,rl[e];return e},ol=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function sl(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var cl=40;function ll(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=ol.reduce((e,t)=>(e[t]=sl(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Ec.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,cl),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:ol.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<ol.length;t++)o[ol[t]].cancel(e)},state:i,steps:o}}var{schedule:ul,cancel:dl,state:fl,steps:pl}=ll(typeof requestAnimationFrame<`u`?requestAnimationFrame:jc,!0),ml;function hl(){ml=void 0}var gl={now:()=>(ml===void 0&&gl.set(fl.isProcessing||Ec.useManualTiming?fl.timestamp:performance.now()),ml),set:e=>{ml=e,queueMicrotask(hl)}},_l=e=>t=>typeof t==`string`&&t.startsWith(e),vl=_l(`--`),yl=_l(`var(--`),bl=e=>yl(e)?xl.test(e.split(`/*`)[0].trim()):!1,xl=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Sl(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Cl={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},wl={...Cl,transform:e=>Tc(0,1,e)},Tl={...Cl,default:1},El=e=>Math.round(e*1e5)/1e5,Dl=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ol(e){return e==null}var kl=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Al=(e,t)=>n=>!!(typeof n==`string`&&kl.test(n)&&n.startsWith(e)||t&&!Ol(n)&&Object.prototype.hasOwnProperty.call(n,t)),jl=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Dl);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Ml=e=>Tc(0,255,e),Nl={...Cl,transform:e=>Math.round(Ml(e))},Pl={test:Al(`rgb`,`red`),parse:jl(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Nl.transform(e)+`, `+Nl.transform(t)+`, `+Nl.transform(n)+`, `+El(wl.transform(r))+`)`};function Fl(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var Il={test:Al(`#`),parse:Fl,transform:Pl.transform},Ll=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Rl=Ll(`deg`),zl=Ll(`%`),Bl=Ll(`px`),Vl=Ll(`vh`),Hl=Ll(`vw`),Ul={...zl,parse:e=>zl.parse(e)/100,transform:e=>zl.transform(e*100)},Wl={test:Al(`hsl`,`hue`),parse:jl(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+zl.transform(El(t))+`, `+zl.transform(El(n))+`, `+El(wl.transform(r))+`)`},Gl={test:e=>Pl.test(e)||Il.test(e)||Wl.test(e),parse:e=>Pl.test(e)?Pl.parse(e):Wl.test(e)?Wl.parse(e):Il.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Pl.transform(e):Wl.transform(e),getAnimatableNone:e=>{let t=Gl.parse(e);return t.alpha=0,Gl.transform(t)}},Kl=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ql(e){return isNaN(e)&&typeof e==`string`&&(e.match(Dl)?.length||0)+(e.match(Kl)?.length||0)>0}var Jl=`number`,Yl=`color`,Xl=`var`,Zl=`var(`,Ql="${}",$l=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function eu(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace($l,e=>(Gl.test(e)?(r.color.push(a),i.push(Yl),n.push(Gl.parse(e))):e.startsWith(Zl)?(r.var.push(a),i.push(Xl),n.push(e)):(r.number.push(a),i.push(Jl),n.push(parseFloat(e))),++a,Ql)).split(Ql),indexes:r,types:i}}function tu(e){return eu(e).values}function nu({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===Jl?i+=El(r[a]):e===Yl?i+=Gl.transform(r[a]):i+=r[a]}return i}}function ru(e){return nu(eu(e))}var iu=e=>typeof e==`number`?0:Gl.test(e)?Gl.getAnimatableNone(e):e,au=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:iu(e);function ou(e){let t=eu(e);return nu(t)(t.values.map((e,n)=>au(e,t.split[n])))}var su={test:ql,parse:tu,createTransformer:ru,getAnimatableNone:ou};function cu(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function lu({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=cu(s,r,e+1/3),a=cu(s,r,e),o=cu(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function uu(e,t){return n=>n>0?t:e}var du=(e,t,n)=>e+(t-e)*n,fu=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},pu=[Il,Pl,Wl],mu=e=>pu.find(t=>t.test(e));function hu(e){let t=mu(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===Wl&&(n=lu(n)),n}var gu=(e,t)=>{let n=hu(e),r=hu(t);if(!n||!r)return uu(e,t);let i={...n};return e=>(i.red=fu(n.red,r.red,e),i.green=fu(n.green,r.green,e),i.blue=fu(n.blue,r.blue,e),i.alpha=du(n.alpha,r.alpha,e),Pl.transform(i))},_u=new Set([`none`,`hidden`]);function vu(e,t){return _u.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function yu(e,t){return n=>du(e,t,n)}function bu(e){return typeof e==`number`?yu:typeof e==`string`?bl(e)?uu:Gl.test(e)?gu:wu:Array.isArray(e)?xu:typeof e==`object`?Gl.test(e)?gu:Su:uu}function xu(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>bu(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Su(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=bu(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Cu(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var wu=(e,t)=>{let n=su.createTransformer(t),r=eu(e),i=eu(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?_u.has(e)&&!i.values.length||_u.has(t)&&!r.values.length?vu(e,t):Mc(xu(Cu(r,i),i.values),n):(`${e}${t}`,uu(e,t))};function Tu(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?du(e,t,n):bu(e)(e,t)}var Eu=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>ul.update(t,e),stop:()=>dl(t),now:()=>fl.isProcessing?fl.timestamp:gl.now()}},Du=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Ou=2e4;function ku(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Au(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(ku(r),Ou);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Ic(i)}}var ju={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Mu(e,t){return e*Math.sqrt(1-t*t)}var Nu=12;function Pu(e,t,n){let r=n;for(let n=1;n<Nu;n++)r-=e(r)/t(r);return r}var Fu=.001;function Iu({duration:e=ju.duration,bounce:t=ju.bounce,velocity:n=ju.velocity,mass:r=ju.mass}){let i,a;ju.maxDuration;let o=1-t;o=Tc(ju.minDamping,ju.maxDamping,o),e=Tc(ju.minDuration,ju.maxDuration,Ic(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Mu(t,o),c=Math.exp(-i);return Fu-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Mu(t**2,o);return(-i(t)+Fu>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Pu(i,a,s);if(e=Fc(e),isNaN(c))return{stiffness:ju.stiffness,damping:ju.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Lu=[`duration`,`bounce`],Ru=[`stiffness`,`damping`,`mass`];function zu(e,t){return t.some(t=>e[t]!==void 0)}function Bu(e){let t={velocity:ju.velocity,stiffness:ju.stiffness,damping:ju.damping,mass:ju.mass,isResolvedFromDuration:!1,...e};if(!zu(e,Ru)&&zu(e,Lu))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Tc(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:ju.mass,stiffness:i,damping:a}}else{let n=Iu({...e,velocity:0});t={...t,...n,mass:ju.mass},t.isResolvedFromDuration=!0}return t}function Vu(e=ju.visualDuration,t=ju.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=Bu({...n,velocity:-Ic(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Ic(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?ju.restSpeed.granular:ju.restSpeed.default,i||=v?ju.restDelta.granular:ju.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Mu(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>Fc(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=Fc(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=Fc(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(ku(T),Ou),t=Du(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}Vu.applyToOptions=e=>{let t=Au(e,100,Vu);return e.ease=t.ease,e.duration=Fc(t.duration),e.type=`keyframes`,e};var Hu=5;function Uu(e,t,n){let r=Math.max(t-Hu,0);return Lc(n-e(r),t-r)}function Wu({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=Vu({keyframes:[f.value,m(f.value)],velocity:Uu(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function Gu(e,t,n){let r=[],i=n||Ec.mix||Tu,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Mc(Array.isArray(t)?t[n]||jc:t,a)),r.push(a)}return r}function Ku(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=Gu(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=Nc(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Tc(e[0],e[a-1],t)):l}function qu(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Nc(0,t,r);e.push(du(n,1,i))}}function Ju(e){let t=[0];return qu(t,e.length-1),t}function Yu(e,t){return e.map(e=>e*t)}function Xu(e,t){return e.map(()=>t||el).splice(0,e.length-1)}function Zu({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=tl(r)?r.map(al):al(r),a={done:!1,value:t[0]},o=Ku(Yu(n&&n.length===t.length?n:Ju(t),e),t,{ease:Array.isArray(i)?i:Xu(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Qu=e=>e!==null;function $u(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Qu),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var ed={decay:Wu,inertia:Wu,tween:Zu,keyframes:Zu,spring:Vu};function td(e){typeof e.type==`string`&&(e.type=ed[e.type])}var nd=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},rd=e=>e/100,id=class extends nd{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==gl.now()&&this.tick(gl.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;td(e);let{type:t=Zu,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Zu;s!==Zu&&typeof o[0]!=`number`&&(this.mixKeyframes=Mc(rd,Tu(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=ku(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Tc(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==Wu&&(b.value=$u(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return Ic(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Ic(e)}get time(){return Ic(this.currentTime)}set time(e){e=Fc(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return Uu(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(gl.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Ic(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Eu,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(gl.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function ad(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var od=e=>e*180/Math.PI,sd=e=>ld(od(Math.atan2(e[1],e[0]))),cd={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:sd,rotateZ:sd,skewX:e=>od(Math.atan(e[1])),skewY:e=>od(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},ld=e=>(e%=360,e<0&&(e+=360),e),ud=sd,dd=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),fd=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),pd={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:dd,scaleY:fd,scale:e=>(dd(e)+fd(e))/2,rotateX:e=>ld(od(Math.atan2(e[6],e[5]))),rotateY:e=>ld(od(Math.atan2(-e[2],e[0]))),rotateZ:ud,rotate:ud,skewX:e=>od(Math.atan(e[4])),skewY:e=>od(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function md(e){return+!!e.includes(`scale`)}function hd(e,t){if(!e||e===`none`)return md(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=pd,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=cd,i=t}if(!i)return md(t);let a=r[t],o=i[1].split(`,`).map(_d);return typeof a==`function`?a(o):o[a]}var gd=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return hd(n,t)};function _d(e){return parseFloat(e.trim())}var vd=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],yd=new Set([...vd,`pathRotation`]),bd=e=>e===Cl||e===Bl,xd=new Set([`x`,`y`,`z`]),Sd=vd.filter(e=>!xd.has(e));function Cd(e){let t=[];return Sd.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var wd={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>hd(t,`x`),y:(e,{transform:t})=>hd(t,`y`)};wd.translateX=wd.x,wd.translateY=wd.y;var Td=new Set,Ed=!1,Dd=!1,Od=!1;function kd(){if(Dd){let e=Array.from(Td).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Cd(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Dd=!1,Ed=!1,Td.forEach(e=>e.complete(Od)),Td.clear()}function Ad(){Td.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Dd=!0)})}function jd(){Od=!0,Ad(),kd(),Od=!1}var Md=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Td.add(this),Ed||(Ed=!0,ul.read(Ad),ul.resolveKeyframes(kd))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}ad(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Td.delete(this)}cancel(){this.state===`scheduled`&&(Td.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Nd=e=>e.startsWith(`--`);function Pd(e,t,n){Nd(t)?e.style.setProperty(t,n):e.style[t]=n}var Fd={};function Id(e,t){let n=Ac(e);return()=>Fd[t]??n()}var Ld=Id(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Rd=Id(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),zd=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Bd={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:zd([0,.65,.55,1]),circOut:zd([.55,0,1,.45]),backIn:zd([.31,.01,.66,-.59]),backOut:zd([.33,1.53,.69,.99])};function Vd(e,t){if(e)return typeof e==`function`?Rd()?Du(e,t):`ease-out`:nl(e)?zd(e):Array.isArray(e)?e.map(e=>Vd(e,t)||Bd.easeOut):Bd[e]}function Hd(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Vd(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Ud(e){return typeof e==`function`&&`applyToOptions`in e}function Wd({type:e,...t}){return Ud(e)&&Rd()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Gd=class extends nd{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=Wd(e);this.animation=Hd(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=$u(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Pd(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return Ic(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Ic(e)}get time(){return Ic(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Fc(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&Ld()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),jc):r(this)}},Kd={anticipate:Jc,backInOut:qc,circInOut:Zc};function qd(e){return e in Kd}function Jd(e){typeof e.ease==`string`&&qd(e.ease)&&(e.ease=Kd[e.ease])}var Yd=10,Xd=class extends Gd{constructor(e){Jd(e),td(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new id({...a,autoplay:!1}),s=Math.max(Yd,gl.now()-this.startTime),c=Tc(0,Yd,s-Yd),l=o.sample(s).value,{name:u}=this.options;i&&u&&Pd(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},Zd=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(su.test(e)||e===`0`)&&!e.startsWith(`url(`));function Qd(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function $d(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=Zd(i,t),s=Zd(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:Qd(e)||(n===`spring`||Ud(n))&&r}function ef(e){e.duration=0,e.type=`keyframes`}var tf=new Set([`opacity`,`clipPath`,`filter`,`transform`]),nf=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function rf(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&nf.test(e[t]))return!0;return!1}var af=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),of=Ac(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function sf(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return of()&&n&&(tf.has(n)||af.has(n)&&rf(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var cf=40,lf=class extends nd{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=gl.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||Md;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=gl.now();let u=!0;$d(e,i,a,o)||(u=!1,(Ec.instantAnimations||!s)&&l?.($u(e,n,t)),e[0]=e[e.length-1],ef(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>cf?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&sf(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new Xd({...d,element:p})}catch{m=new id(d)}else m=new id(d);m.finished.then(()=>{this.notifyFinished()}).catch(jc),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),jd()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function uf(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var df=30,ff=e=>!isNaN(parseFloat(e)),pf={current:void 0},mf=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=gl.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=gl.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=ff(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new Pc);let n=this.events[e].add(t);return e===`change`?()=>{n(),ul.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return pf.current&&pf.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=gl.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>df)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,df);return Lc(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function hf(e,t){return new mf(e,t)}function gf(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function _f(e,t){let n=e?.[t]??e?.default??e;return n===e?n:gf(n,e)}var vf={type:`spring`,stiffness:500,damping:25,restSpeed:10},yf=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),bf={type:`keyframes`,duration:.8},xf={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Sf=(e,{keyframes:t})=>t.length>2?bf:yd.has(e)?e.startsWith(`scale`)?yf(t[1]):vf:xf,Cf=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function wf(e){for(let t in e)if(!Cf.has(t))return!0;return!1}var Tf=(e,t,n,r={},i,a)=>o=>{let s=_f(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Fc(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};wf(s)||Object.assign(u,Sf(e,u)),u.duration&&=Fc(u.duration),u.repeatDelay&&=Fc(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(ef(u),u.delay===0&&(d=!0)),(Ec.instantAnimations||Ec.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,ef(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=$u(u.keyframes,s);if(e!==void 0){ul.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new id(u):new lf(u)},Ef=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Df(e){let t=Ef.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Of(e,t,n=1){`${e}`;let[r,i]=Df(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Dc(e)?parseFloat(e):e}return bl(i)?Of(i,t,n+1):i}function kf(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Af(e,t,n,r){if(typeof t==`function`){let[i,a]=kf(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=kf(r);t=t(n===void 0?e.custom:n,i,a)}return t}function jf(e,t,n){let r=e.getProps();return Af(r,t,n===void 0?r.custom:n,e)}var Mf=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...vd]),Nf=e=>Array.isArray(e);function Pf(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,hf(n))}function Ff(e){return Nf(e)?e[e.length-1]||0:e}function If(e,t){let{transitionEnd:n={},transition:r={},...i}=jf(e,t)||{};i={...i,...n};for(let t in i)Pf(e,t,Ff(i[t]))}var Lf=e=>!!(e&&e.getVelocity);function Rf(e){return!!(Lf(e)&&e.add)}function zf(e,t){let n=e.getValue(`willChange`);if(Rf(n))return n.add(t);if(!n&&Ec.WillChange){let n=new Ec.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Bf(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Vf=`data-`+Bf(`framerAppearId`);function Hf(e){return e.props[Vf]}function Uf({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Wf(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?gf(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Uf(f,t))continue;let o={delay:n,..._f(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){ul.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=Hf(e);if(n){let e=window.MotionHandoffAnimation(n,t,ul);e!==null&&(o.startTime=e,p=!0)}}zf(e,t);let m=l??e.shouldReduceMotion;r.start(Tf(t,r,i,m&&Mf.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>ul.update(()=>{o&&If(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Gf(e,t,n={}){let r=jf(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(Wf(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return Kf(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function Kf(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(Gf(c,t,{...o,delay:n+(typeof r==`function`?0:r)+uf(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function qf(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>Gf(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=Gf(e,t,n);else{let i=typeof t==`function`?jf(e,t,n.custom):t;r=Promise.all(Wf(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var Jf={test:e=>e===`auto`,parse:e=>e},Yf=e=>t=>t.test(e),Xf=[Cl,Bl,zl,Rl,Hl,Vl,Jf],Zf=e=>Xf.find(Yf(e));function Qf(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||kc(e)}var $f=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function ep(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Dl)||[];if(!r)return e;let i=n.replace(r,``),a=+!!$f.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var tp=/\b([a-z-]*)\(.*?\)/gu,np={...su,getAnimatableNone:e=>{let t=e.match(tp);return t?t.map(ep).join(` `):e}},rp={...su,getAnimatableNone:e=>{let t=su.parse(e);return su.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ip={...Cl,transform:Math.round},ap={borderWidth:Bl,borderTopWidth:Bl,borderRightWidth:Bl,borderBottomWidth:Bl,borderLeftWidth:Bl,borderRadius:Bl,borderTopLeftRadius:Bl,borderTopRightRadius:Bl,borderBottomRightRadius:Bl,borderBottomLeftRadius:Bl,width:Bl,maxWidth:Bl,height:Bl,maxHeight:Bl,top:Bl,right:Bl,bottom:Bl,left:Bl,inset:Bl,insetBlock:Bl,insetBlockStart:Bl,insetBlockEnd:Bl,insetInline:Bl,insetInlineStart:Bl,insetInlineEnd:Bl,padding:Bl,paddingTop:Bl,paddingRight:Bl,paddingBottom:Bl,paddingLeft:Bl,paddingBlock:Bl,paddingBlockStart:Bl,paddingBlockEnd:Bl,paddingInline:Bl,paddingInlineStart:Bl,paddingInlineEnd:Bl,margin:Bl,marginTop:Bl,marginRight:Bl,marginBottom:Bl,marginLeft:Bl,marginBlock:Bl,marginBlockStart:Bl,marginBlockEnd:Bl,marginInline:Bl,marginInlineStart:Bl,marginInlineEnd:Bl,fontSize:Bl,backgroundPositionX:Bl,backgroundPositionY:Bl,rotate:Rl,pathRotation:Rl,rotateX:Rl,rotateY:Rl,rotateZ:Rl,scale:Tl,scaleX:Tl,scaleY:Tl,scaleZ:Tl,skew:Rl,skewX:Rl,skewY:Rl,distance:Bl,translateX:Bl,translateY:Bl,translateZ:Bl,x:Bl,y:Bl,z:Bl,perspective:Bl,transformPerspective:Bl,opacity:wl,originX:Ul,originY:Ul,originZ:Bl,zIndex:ip,fillOpacity:wl,strokeOpacity:wl,numOctaves:ip},op={...ap,color:Gl,backgroundColor:Gl,outlineColor:Gl,fill:Gl,stroke:Gl,borderColor:Gl,borderTopColor:Gl,borderRightColor:Gl,borderBottomColor:Gl,borderLeftColor:Gl,filter:np,WebkitFilter:np,mask:rp,WebkitMask:rp},sp=e=>op[e],cp=new Set([np,rp]);function lp(e,t){let n=sp(e);return cp.has(n)||(n=su),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var up=new Set([`auto`,`none`,`0`]);function dp(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!up.has(t)&&eu(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=lp(n,i)}var fp=class extends Md{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),bl(r))){let i=Of(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Mf.has(n)||e.length!==2)return;let[r,i]=e,a=Zf(r),o=Zf(i);if(Sl(r)!==Sl(i)&&wd[n]){this.needsMeasurement=!0;return}if(a!==o)if(bd(a)&&bd(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else wd[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||Qf(e[t]))&&n.push(t);n.length&&dp(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=wd[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=wd[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},pp=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function mp(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var hp=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function gp(e){return Oc(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:_p,cancel:vp}=ll(queueMicrotask,!1),yp={x:!1,y:!1};function bp(){return yp.x||yp.y}function xp(e){return e===`x`||e===`y`?yp[e]?null:(yp[e]=!0,()=>{yp[e]=!1}):yp.x||yp.y?null:(yp.x=yp.y=!0,()=>{yp.x=yp.y=!1})}function Sp(e,t){let n=mp(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Cp(e){return!(e.pointerType===`touch`||bp())}function wp(e,t,n={}){let[r,i,a]=Sp(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!Cp(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Tp=(e,t)=>t?e===t||Tp(e,t.parentElement):!1,Ep=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Dp=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Op(e){return Dp.has(e.tagName)||e.isContentEditable===!0}var kp=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Ap(e){return kp.has(e.tagName)||e.isContentEditable===!0}var jp=new WeakSet;function Mp(e){return t=>{t.key===`Enter`&&e(t)}}function Np(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Pp=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Mp(()=>{if(jp.has(n))return;Np(n,`down`);let e=Mp(()=>{Np(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Np(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Fp(e){return Ep(e)&&!bp()}var Ip=new WeakSet;function Lp(e,t,n={}){let[r,i,a]=Sp(e,n),o=e=>{let r=e.currentTarget;if(!Fp(e)||Ip.has(e))return;jp.add(r),n.stopPropagation&&Ip.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),jp.has(r)&&jp.delete(r),Fp(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Tp(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),gp(e)&&(e.addEventListener(`focus`,e=>Pp(e,i)),!Op(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function Rp(e){return Oc(e)&&`ownerSVGElement`in e}var zp=new WeakMap,Bp,Vp=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Rp(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Hp=Vp(`inline`,`width`,`offsetWidth`),Up=Vp(`block`,`height`,`offsetHeight`);function Wp({target:e,borderBoxSize:t}){zp.get(e)?.forEach(n=>{n(e,{get width(){return Hp(e,t)},get height(){return Up(e,t)}})})}function Gp(e){e.forEach(Wp)}function Kp(){typeof ResizeObserver>`u`||(Bp=new ResizeObserver(Gp))}function qp(e,t){Bp||Kp();let n=mp(e);return n.forEach(e=>{let n=zp.get(e);n||(n=new Set,zp.set(e,n)),n.add(t),Bp?.observe(e)}),()=>{n.forEach(e=>{let n=zp.get(e);n?.delete(t),n?.size||Bp?.unobserve(e)})}}var Jp=new Set,Yp;function Xp(){Yp=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Jp.forEach(t=>t(e))},window.addEventListener(`resize`,Yp)}function Zp(e){return Jp.add(e),Yp||Xp(),()=>{Jp.delete(e),!Jp.size&&typeof Yp==`function`&&(window.removeEventListener(`resize`,Yp),Yp=void 0)}}function Qp(e,t){return typeof e==`function`?Zp(e):qp(e,t)}var $p={value:null,addProjectionMetrics:null};function em(e){return Rp(e)&&e.tagName===`svg`}var tm=[...Xf,Gl,su],nm=e=>tm.find(Yf(e)),rm=()=>({translate:0,scale:1,origin:0,originPoint:0}),im=()=>({x:rm(),y:rm()}),am=()=>({min:0,max:0}),om=()=>({x:am(),y:am()}),sm=new WeakMap;function cm(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function lm(e){return typeof e==`string`||Array.isArray(e)}var um=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],dm=[`initial`,...um];function fm(e){return cm(e.animate)||dm.some(t=>lm(e[t]))}function pm(e){return!!(fm(e)||e.variants)}function mm(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Lf(i))e.addValue(r,i);else if(Lf(a))e.addValue(r,hf(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,hf(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var hm={current:null},gm={current:!1},_m=typeof window<`u`;function vm(){if(gm.current=!0,_m)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>hm.current=e.matches;e.addEventListener(`change`,t),t()}else hm.current=!1}var ym=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],bm={};function xm(e){bm=e}function Sm(){return bm}var Cm=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Md,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=gl.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,ul.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=fm(t),this.isVariantNode=pm(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Lf(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,sm.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(gm.current||vm(),this.shouldReduceMotion=hm.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),dl(this.notifyUpdate),dl(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&tf.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Gd({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Fc(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=yd.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&ul.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in bm){let t=bm[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):om()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<ym.length;t++){let n=ym[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=mm(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=hf(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Dc(n)||kc(n))?n=parseFloat(n):!nm(n)&&su.test(t)&&(n=lp(e,t)),this.setBaseTarget(e,Lf(n)?n.get():n)),Lf(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Af(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Lf(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new Pc),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){_p.render(this.render)}},wm=class extends Cm{constructor(){super(...arguments),this.KeyframeResolver=fp}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Lf(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Tm=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Em({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Dm({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Om(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function km(e){return e===void 0||e===1}function Am({scale:e,scaleX:t,scaleY:n}){return!km(e)||!km(t)||!km(n)}function jm(e){return Am(e)||Mm(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Mm(e){return Nm(e.x)||Nm(e.y)}function Nm(e){return e&&e!==`0%`}function Pm(e,t,n){return n+t*(e-n)}function Fm(e,t,n,r,i){return i!==void 0&&(e=Pm(e,i,r)),Pm(e,n,r)+t}function Im(e,t=0,n=1,r,i){e.min=Fm(e.min,t,n,r,i),e.max=Fm(e.max,t,n,r,i)}function Lm(e,{x:t,y:n}){Im(e.x,t.translate,t.scale,t.originPoint),Im(e.y,n.translate,n.scale,n.originPoint)}var Rm=.999999999999,zm=1.0000000000001;function Bm(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Vm(e.x,-a.scroll.offset.x),Vm(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Lm(e,o)),r&&jm(a.latestValues)&&Wm(e,a.latestValues,a.layout?.layoutBox))}t.x<zm&&t.x>Rm&&(t.x=1),t.y<zm&&t.y>Rm&&(t.y=1)}function Vm(e,t){e.min+=t,e.max+=t}function Hm(e,t,n,r,i=.5){Im(e,t,n,du(e.min,e.max,i),r)}function Um(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function Wm(e,t,n){let r=n??e;Hm(e.x,Um(t.x,r.x),t.scaleX,t.scale,t.originX),Hm(e.y,Um(t.y,r.y),t.scaleY,t.scale,t.originY)}function Gm(e,t){return Em(Om(e.getBoundingClientRect(),t))}function Km(e,t,n){let r=Gm(e,n),{scroll:i}=t;return i&&(Vm(r.x,i.offset.x),Vm(r.y,i.offset.y)),r}var qm={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Jm=vd.length;function Ym(e,t,n){let r=``,i=!0;for(let a=0;a<Jm;a++){let o=vd[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=hp(s,ap[o]);if(!c){i=!1;let t=qm[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${hp(a,ap.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Xm(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(yd.has(e)){o=!0;continue}else if(vl(e)){i[e]=n;continue}else{let t=hp(n,ap[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Ym(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function Zm(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function Qm(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var $m={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(Bl.test(e))e=parseFloat(e);else return e;return`${Qm(e,t.target.x)}% ${Qm(e,t.target.y)}%`}},eh={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=su.parse(e);if(i.length>5)return r;let a=su.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=du(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},th={borderRadius:{...$m,applyTo:[...pp]},borderTopLeftRadius:$m,borderTopRightRadius:$m,borderBottomLeftRadius:$m,borderBottomRightRadius:$m,boxShadow:eh};function nh(e,{layout:t,layoutId:n}){return yd.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!th[e]||e===`opacity`)}function rh(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Lf(r[t])||i&&Lf(i[t])||nh(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function ih(e){return window.getComputedStyle(e)}var ah=class extends wm{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Zm}readValueFromInstance(e,t){if(yd.has(t))return this.projection?.isProjecting?md(t):gd(e,t);{let n=ih(e),r=(vl(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Gm(e,t)}build(e,t,n){Xm(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return rh(e,t,n)}},oh={offset:`stroke-dashoffset`,array:`stroke-dasharray`},sh={offset:`strokeDashoffset`,array:`strokeDasharray`};function ch(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?oh:sh;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var lh=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function uh(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Xm(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of lh)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&ch(d,i,a,o,!1)}var dh=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),fh=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function ph(e,t,n,r){Zm(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(dh.has(n)?n:Bf(n),t.attrs[n])}function mh(e,t,n){let r=rh(e,t,n);for(let n in e)if(Lf(e[n])||Lf(t[n])){let t=vd.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var hh=class extends wm{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=om}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(yd.has(t)){let e=sp(t);return e&&e.default||0}return t=dh.has(t)?t:Bf(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return mh(e,t,n)}build(e,t,n){uh(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){ph(e,t,n,r)}mount(e){this.isSVGTag=fh(e.tagName),super.mount(e)}},gh=dm.length;function _h(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&_h(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<gh;n++){let r=dm[n],i=e.props[r];(lm(i)||i===!1)&&(t[r]=i)}return t}function vh(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var yh=[...um].reverse(),bh=um.length;function xh(e){return t=>Promise.all(t.map(({animation:t,options:n})=>qf(e,t,n)))}function Sh(e){let t=xh(e),n=Th(),r=!0,i=!1,a=t=>(n,r)=>{let i=jf(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=_h(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<bh;t++){let p=yh[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=lm(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||cm(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Ch(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Nf(t)&&Nf(n)?!vh(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=jf(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=uf(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=jf(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Th(),i=!0}}}function Ch(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!vh(t,e):!1}function wh(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Th(){return{animate:wh(!0),whileInView:wh(),whileHover:wh(),whileTap:wh(),whileDrag:wh(),whileFocus:wh(),exit:wh()}}function Eh(e,t){e.min=t.min,e.max=t.max}function Dh(e,t){Eh(e.x,t.x),Eh(e.y,t.y)}function Oh(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var kh=.9999,Ah=1.0001,jh=-.01,Mh=.01;function Nh(e){return e.max-e.min}function Ph(e,t,n){return Math.abs(e-t)<=n}function Fh(e,t,n,r=.5){e.origin=r,e.originPoint=du(t.min,t.max,e.origin),e.scale=Nh(n)/Nh(t),e.translate=du(n.min,n.max,e.origin)-e.originPoint,(e.scale>=kh&&e.scale<=Ah||isNaN(e.scale))&&(e.scale=1),(e.translate>=jh&&e.translate<=Mh||isNaN(e.translate))&&(e.translate=0)}function Ih(e,t,n,r){Fh(e.x,t.x,n.x,r?r.originX:void 0),Fh(e.y,t.y,n.y,r?r.originY:void 0)}function Lh(e,t,n,r=0){e.min=(r?du(n.min,n.max,r):n.min)+t.min,e.max=e.min+Nh(t)}function Rh(e,t,n,r){Lh(e.x,t.x,n.x,r?.x),Lh(e.y,t.y,n.y,r?.y)}function zh(e,t,n,r=0){let i=r?du(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Nh(t)}function Bh(e,t,n,r){zh(e.x,t.x,n.x,r?.x),zh(e.y,t.y,n.y,r?.y)}function Vh(e,t,n,r,i){return e-=t,e=Pm(e,1/n,r),i!==void 0&&(e=Pm(e,1/i,r)),e}function Hh(e,t=0,n=1,r=.5,i,a=e,o=e){if(zl.test(t)&&(t=parseFloat(t),t=du(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=du(a.min,a.max,r);e===a&&(s-=t),e.min=Vh(e.min,t,n,s,i),e.max=Vh(e.max,t,n,s,i)}function Uh(e,t,[n,r,i],a,o){Hh(e,t[n],t[r],t[i],t.scale,a,o)}var Wh=[`x`,`scaleX`,`originX`],Gh=[`y`,`scaleY`,`originY`];function Kh(e,t,n,r){Uh(e.x,t,Wh,n?n.x:void 0,r?r.x:void 0),Uh(e.y,t,Gh,n?n.y:void 0,r?r.y:void 0)}function qh(e){return e.translate===0&&e.scale===1}function Jh(e){return qh(e.x)&&qh(e.y)}function Yh(e,t){return e.min===t.min&&e.max===t.max}function Xh(e,t){return Yh(e.x,t.x)&&Yh(e.y,t.y)}function Zh(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Qh(e,t){return Zh(e.x,t.x)&&Zh(e.y,t.y)}function $h(e){return Nh(e.x)/Nh(e.y)}function eg(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function tg(e){return[e(`x`),e(`y`)]}function ng(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var rg=pp.length,ig=e=>typeof e==`string`?parseFloat(e):e,ag=e=>typeof e==`number`||Bl.test(e);function og(e,t,n,r,i,a){i?(e.opacity=du(0,n.opacity??1,cg(r)),e.opacityExit=du(t.opacity??1,0,lg(r))):a&&(e.opacity=du(t.opacity??1,n.opacity??1,r));for(let i=0;i<rg;i++){let a=pp[i],o=sg(t,a),s=sg(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||ag(o)===ag(s)?(e[a]=Math.max(du(ig(o),ig(s),r),0),(zl.test(s)||zl.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=du(t.rotate||0,n.rotate||0,r))}function sg(e,t){return e[t]===void 0?e.borderRadius:e[t]}var cg=ug(0,.5,Xc),lg=ug(.5,.95,jc);function ug(e,t,n){return r=>r<e?0:r>t?1:n(Nc(e,t,r))}function dg(e,t,n){let r=Lf(e)?e:hf(e);return r.start(Tf(``,r,t,n)),r.animation}function fg(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var pg=(e,t)=>e.depth-t.depth,mg=class{constructor(){this.children=[],this.isDirty=!1}add(e){Cc(this.children,e),this.isDirty=!0}remove(e){wc(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(pg),this.isDirty=!1,this.children.forEach(e)}};function hg(e,t){let n=gl.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(dl(r),e(a-t))};return ul.setup(r,!0),()=>dl(r)}function gg(e){return Lf(e)?e.get():e}var _g=class{constructor(){this.members=[]}add(e){Cc(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(wc(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(wc(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},vg={hasAnimatedSinceResize:!0,hasEverUpdated:!1},yg={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},bg=[``,`X`,`Y`,`Z`],xg=1e3,Sg=0;function Cg(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function wg(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Hf(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,ul,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&wg(r)}function Tg({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Sg++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,$p.value&&(yg.nodes=yg.calculatedTargetDeltas=yg.calculatedProjections=0),this.nodes.forEach(Og),this.nodes.forEach(Lg),this.nodes.forEach(Rg),this.nodes.forEach(kg),$p.addProjectionMetrics&&$p.addProjectionMetrics(yg)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new mg)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Pc),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=Rp(t)&&!em(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;ul.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=hg(i,250),vg.hasAnimatedSinceResize&&(vg.hasAnimatedSinceResize=!1,this.nodes.forEach(Ig)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||Gg,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Qh(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={..._f(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||Ig(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),dl(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(zg),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&wg(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(Mg),this.nodes.forEach(jg);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ng);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Pg),this.nodes.forEach(Fg),this.nodes.forEach(Eg),this.nodes.forEach(Dg)):this.nodes.forEach(Ng),this.clearAllSnapshots();let e=gl.now();fl.delta=Tc(0,1e3/60,e-fl.timestamp),fl.timestamp=e,fl.isProcessing=!0,pl.update.process(fl),pl.preRender.process(fl),pl.render.process(fl),fl.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,_p.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Ag),this.sharedNodes.forEach(Bg)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ul.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ul.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Nh(this.snapshot.measuredBox.x)&&!Nh(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=om(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Jh(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||jm(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),Yg(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return om();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Zg))){let{scroll:e}=this.root;e&&(Vm(t.x,e.offset.x),Vm(t.y,e.offset.y))}return t}removeElementScroll(e){let t=om();if(Dh(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Dh(t,e),Vm(t.x,i.offset.x),Vm(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||om();Dh(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Vm(r.x,-n.scroll.offset.x),Vm(r.y,-n.scroll.offset.y)),jm(n.latestValues)&&Wm(r,n.latestValues,n.layout?.layoutBox)}return jm(this.latestValues)&&Wm(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=om();Dh(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!jm(n.latestValues))continue;let r;n.instance&&(Am(n.latestValues)&&n.updateSnapshot(),r=om(),Dh(r,n.measurePageBox())),Kh(t,n.latestValues,n.snapshot?.layoutBox,r)}return jm(this.latestValues)&&Kh(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==fl.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=fl.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=om(),this.targetWithTransforms=om()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Rh(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Dh(this.target,this.layout.layoutBox),Lm(this.target,this.targetDelta)):Dh(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),$p.value&&yg.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Am(this.parent.latestValues)||Mm(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=om(),this.relativeTargetOrigin=om(),Bh(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Dh(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===fl.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Dh(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Bm(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=om());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Oh(this.prevProjectionDelta.x,this.projectionDelta.x),Oh(this.prevProjectionDelta.y,this.projectionDelta.y)),Ih(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!eg(this.projectionDelta.x,this.prevProjectionDelta.x)||!eg(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),$p.value&&yg.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=im(),this.projectionDelta=im(),this.projectionDeltaWithTransform=im()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=im();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=om(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(Wg));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=du(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=du(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(Vg(o.x,e.x,n),Vg(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Bh(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Ug(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&Xh(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=om(),Dh(f,this.relativeTarget)),c&&(this.animationValues=a,og(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(dl(this.pendingAnimation),void 0),this.pendingAnimation=ul.update(()=>{vg.hasAnimatedSinceResize=!0,this.motionValue||=hf(0),this.motionValue.jump(0,!1),this.currentAnimation=dg(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(xg),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&Xg(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||om();let t=Nh(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Nh(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Dh(t,n),Wm(t,i),Ih(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new _g),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Cg(`z`,e,r,this.animationValues);for(let t=0;t<bg.length;t++)Cg(`rotate${bg[t]}`,e,r,this.animationValues),Cg(`skew${bg[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=gg(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=gg(t?.pointerEvents)||``),this.hasProjected&&!jm(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=ng(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in th){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=th[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?gg(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(jg),this.root.sharedNodes.clear()}}}function Eg(e){e.updateLayout()}function Dg(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)tg(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Nh(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Eh(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else Xg(i,t.layoutBox,n)&&tg(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Nh(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=im();Ih(o,n,t.layoutBox);let s=im();a?Ih(s,e.applyTransform(r,!0),t.measuredBox):Ih(s,n,t.layoutBox);let c=!Jh(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=om();Bh(s,t.layoutBox,i.layoutBox,o);let c=om();Bh(c,n,a.layoutBox,o),Qh(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Og(e){$p.value&&yg.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function kg(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Ag(e){e.clearSnapshot()}function jg(e){e.clearMeasurements()}function Mg(e){e.isLayoutDirty=!0,e.updateLayout()}function Ng(e){e.isLayoutDirty=!1}function Pg(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Fg(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Ig(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Lg(e){e.resolveTargetDelta()}function Rg(e){e.calcProjection()}function zg(e){e.resetSkewAndRotation()}function Bg(e){e.removeLeadSnapshot()}function Vg(e,t,n){e.translate=du(t.translate,0,n),e.scale=du(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Hg(e,t,n,r){e.min=du(t.min,n.min,r),e.max=du(t.max,n.max,r)}function Ug(e,t,n,r){Hg(e.x,t.x,n.x,r),Hg(e.y,t.y,n.y,r)}function Wg(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var Gg={duration:.45,ease:[.4,0,.1,1]},Kg=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),qg=Kg(`applewebkit/`)&&!Kg(`chrome/`)?Math.round:jc;function Jg(e){e.min=qg(e.min),e.max=qg(e.max)}function Yg(e){Jg(e.x),Jg(e.y)}function Xg(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ph($h(t),$h(n),.2)}function Zg(e){return e!==e.root&&e.scroll?.wasRoot}var Qg=Tg({attachResizeListener:(e,t)=>fg(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),$g={current:void 0},e_=Tg({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!$g.current){let e=new Qg({});e.mount(window),e.setOptions({layoutScroll:!0}),$g.current=e}return $g.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),t_=(0,Q.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function n_(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function r_(...e){return t=>{let n=!1,r=e.map(e=>{let r=n_(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():n_(e[t],null)}}}}function i_(...e){return Q.useCallback(r_(...e),e)}var a_=class extends Q.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(gp(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=gp(e)&&e.offsetWidth||0,r=gp(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function o_({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,Q.useId)(),s=(0,Q.useRef)(null),c=(0,Q.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,Q.useContext)(t_),u=i_(s,e.props?.ref??e?.ref);return(0,Q.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
17
+ [data-motion-pop-id="${o}"] {
18
+ position: absolute !important;
19
+ width: ${e}px !important;
20
+ height: ${u}px !important;
21
+ ${_}px !important;
22
+ ${v}px !important;
23
+ }
24
+ `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,$.jsx)(a_,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:Q.cloneElement(e,{ref:u})})}var s_=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=bc(c_),d=(0,Q.useId)(),f=(0,Q.useRef)(n),p=(0,Q.useRef)(r);xc(()=>{f.current=n,p.current=r});let m=!0,h=(0,Q.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,Q.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),Q.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,$.jsx)(o_,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,$.jsx)(Sc.Provider,{value:h,children:e})};function c_(){return new Map}function l_(e=!0){let t=(0,Q.useContext)(Sc);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,Q.useId)();(0,Q.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,Q.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var u_=e=>e.key||``;function d_(e){let t=[];return Q.Children.forEach(e,e=>{(0,Q.isValidElement)(e)&&t.push(e)}),t}var f_=({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]=l_(o),f=(0,Q.useMemo)(()=>d_(e),[e]),p=o&&!u?[]:f.map(u_),m=(0,Q.useRef)(!0),h=(0,Q.useRef)(f),g=bc(()=>new Map),_=(0,Q.useRef)(new Set),[v,y]=(0,Q.useState)(f),[b,x]=(0,Q.useState)(f);xc(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=u_(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=u_(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(d_(e)),y(f),null}let{forceRender:C}=(0,Q.useContext)(yc);return(0,$.jsx)($.Fragment,{children:b.map(e=>{let v=u_(e),y=o&&!u?!1:f===b||p.includes(v);return(0,$.jsx)(s_,{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)})})},p_=(0,Q.createContext)({strict:!1}),m_={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`]},h_=!1;function g_(){if(h_)return;let e={};for(let t in m_)e[t]={isEnabled:e=>m_[t].some(t=>!!e[t])};xm(e),h_=!0}function __(){return g_(),Sm()}function v_(e){let t=__();for(let n in e)t[n]={...t[n],...e[n]};xm(t)}var y_=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 b_(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||y_.has(e)}var x_=r({default:()=>S_}),S_,C_=n((()=>{throw S_={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),w_=e=>!b_(e);function T_(e){typeof e==`function`&&(w_=t=>t.startsWith(`on`)?!b_(t):e(t))}try{T_((C_(),t(x_)).default)}catch{}function E_(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Lf(e[i])||(w_(i)||n===!0&&b_(i)||!t&&!b_(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}function D_({children:e,isValidProp:t,...n}){t&&T_(t);let r=(0,Q.useContext)(t_);n={...r,...n},n.transition=gf(n.transition,r.transition),n.isStatic=bc(()=>n.isStatic);let i=(0,Q.useMemo)(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion,n.skipAnimations]);return(0,$.jsx)(t_.Provider,{value:i,children:e})}var O_=(0,Q.createContext)({});function k_(e,t){if(fm(e)){let{initial:t,animate:n}=e;return{initial:t===!1||lm(t)?t:void 0,animate:lm(n)?n:void 0}}return e.inherit===!1?{}:t}function A_(e){let{initial:t,animate:n}=k_(e,(0,Q.useContext)(O_));return(0,Q.useMemo)(()=>({initial:t,animate:n}),[j_(t),j_(n)])}function j_(e){return Array.isArray(e)?e.join(` `):e}var M_=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function N_(e,t,n){for(let r in t)!Lf(t[r])&&!nh(r,n)&&(e[r]=t[r])}function P_({transformTemplate:e},t){return(0,Q.useMemo)(()=>{let n=M_();return Xm(n,t,e),Object.assign({},n.vars,n.style)},[t])}function F_(e,t){let n=e.style||{},r={};return N_(r,n,e),Object.assign(r,P_(e,t)),r}function I_(e,t){let n={},r=F_(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 L_=()=>({...M_(),attrs:{}});function R_(e,t,n,r){let i=(0,Q.useMemo)(()=>{let n=L_();return uh(n,t,fh(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};N_(t,e.style,e),i.style={...t,...i.style}}return i}var z_=[`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 B_(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(z_.indexOf(e)>-1||/[A-Z]/u.test(e))}function V_(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??B_(e)?R_:I_)(t,r,i,e),c=E_(t,typeof e==`string`,a),l=e===Q.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,Q.useMemo)(()=>Lf(u)?u.get():u,[u]);return(0,Q.createElement)(e,{...l,children:d})}function H_({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:U_(n,r,i,e),renderState:t()}}function U_(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=gg(a[e]);let{initial:o,animate:s}=e,c=fm(e),l=pm(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`&&!cm(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Af(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 W_=e=>(t,n)=>{let r=(0,Q.useContext)(O_),i=(0,Q.useContext)(Sc),a=()=>H_(e,t,r,i);return n?a():bc(a)},G_=W_({scrapeMotionValuesFromProps:rh,createRenderState:M_}),K_=W_({scrapeMotionValuesFromProps:mh,createRenderState:L_}),q_=Symbol.for(`motionComponentSymbol`);function J_(e,t,n){let r=(0,Q.useRef)(n);(0,Q.useInsertionEffect)(()=>{r.current=n});let i=(0,Q.useRef)(null);return(0,Q.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 Y_=(0,Q.createContext)({});function X_(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Z_(e,t,n,r,i,a){let{visualElement:o}=(0,Q.useContext)(O_),s=(0,Q.useContext)(p_),c=(0,Q.useContext)(Sc),l=(0,Q.useContext)(t_),u=l.reducedMotion,d=l.skipAnimations,f=(0,Q.useRef)(null),p=(0,Q.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,Q.useContext)(Y_);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Q_(f.current,n,i,h);let g=(0,Q.useRef)(!1);(0,Q.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[Vf],v=(0,Q.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return xc(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,Q.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function Q_(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:$_(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&X_(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function $_(e){if(e)return e.options.allowProjection===!1?$_(e.parent):e.projection}function ev(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&v_(r);let a=n?n===`svg`:B_(e),o=a?K_:G_;function s(n,s){let c,l={...(0,Q.useContext)(t_),...n,layoutId:tv(n)},{isStatic:u}=l,d=A_(n),f=o(n,u);if(!u&&typeof window<`u`){nv(l,r);let t=rv(l);c=t.MeasureLayout,d.visualElement=Z_(e,f,l,i,t.ProjectionNode,a)}return(0,$.jsxs)(O_.Provider,{value:d,children:[c&&d.visualElement?(0,$.jsx)(c,{visualElement:d.visualElement,...l}):null,V_(e,n,J_(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,Q.forwardRef)(s);return c[q_]=e,c}function tv({layoutId:e}){let t=(0,Q.useContext)(yc).id;return t&&e!==void 0?t+`-`+e:e}function nv(e,t){(0,Q.useContext)(p_).strict}function rv(e){let{drag:t,layout:n}=__();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function iv(e,t){if(typeof Proxy>`u`)return ev;let n=new Map,r=(n,r)=>ev(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,ev(a,void 0,e,t)),n.get(a))})}var av=(e,t)=>t.isSVG??B_(e)?new hh(t):new ah(t,{allowProjection:e!==Q.Fragment}),ov=class extends Tm{constructor(e){super(e),e.animationState||=Sh(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();cm(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?.()}},sv=0,cv={animation:{Feature:ov},exit:{Feature:class extends Tm{constructor(){super(...arguments),this.id=sv++,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=jf(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 lv(e){return{point:{x:e.pageX,y:e.pageY}}}var uv=e=>t=>Ep(t)&&e(t,lv(t));function dv(e,t,n,r){return fg(e,t,uv(n),r)}var fv=({current:e})=>e?e.ownerDocument.defaultView:null,pv=(e,t)=>Math.abs(e-t);function mv(e,t){let n=pv(e.x,t.x),r=pv(e.y,t.y);return Math.sqrt(n**2+r**2)}var hv=new Set([`auto`,`scroll`]),gv=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=_v(this.lastRawMoveEventInfo,this.transformPagePoint));let e=yv(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=mv(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=fl;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=_v(t,this.transformPagePoint),ul.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=yv(e.type===`pointercancel`?this.lastMoveEventInfo:_v(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Ep(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=_v(lv(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=fl;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,yv(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=Mc(dv(this.contextWindow,`pointermove`,this.handlePointerMove,d),dv(this.contextWindow,`pointerup`,this.handlePointerUp,d),dv(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(hv.has(e.overflowX)||hv.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),ul.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),dl(this.updatePoint)}};function _v(e,t){return t?{point:t(e.point)}:e}function vv(e,t){return{x:e.x-t.x,y:e.y-t.y}}function yv({point:e},t){return{point:e,delta:vv(e,xv(t)),offset:vv(e,bv(t)),velocity:Sv(t,.1)}}function bv(e){return e[0]}function xv(e){return e[e.length-1]}function Sv(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=xv(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Fc(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Fc(t)*2&&(r=e[1]);let a=Ic(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 Cv(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?du(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?du(n,e,r.max):Math.min(e,n)),e}function wv(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 Tv(e,{top:t,left:n,bottom:r,right:i}){return{x:wv(e.x,n,i),y:wv(e.y,t,r)}}function Ev(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 Dv(e,t){return{x:Ev(e.x,t.x),y:Ev(e.y,t.y)}}function Ov(e,t){let n=.5,r=Nh(e),i=Nh(t);return i>r?n=Nc(t.min,t.max-r,e.min):r>i&&(n=Nc(e.min,e.max-i,t.min)),Tc(0,1,n)}function kv(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 Av=.35;function jv(e=Av){return e===!1?e=0:e===!0&&(e=Av),{x:Mv(e,`left`,`right`),y:Mv(e,`top`,`bottom`)}}function Mv(e,t,n){return{min:Nv(e,t),max:Nv(e,n)}}function Nv(e,t){return typeof e==`number`?e:e[t]||0}var Pv=new WeakMap,Fv=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=om(),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(lv(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=xp(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),tg(e=>{let t=this.getAxisMotionValue(e).get()||0;if(zl.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Nh(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&ul.update(()=>i(e,t),!1,!0),zf(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=zv(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&&ul.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 gv(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:fv(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&&ul.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||!Rv(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Cv(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&&X_(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Tv(n.layoutBox,e):this.constraints=!1,this.elastic=jv(t),r!==this.constraints&&!X_(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&tg(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=kv(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!X_(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=Km(n,r.root,this.visualElement.getTransformPagePoint()),a=Dv(r.layout.layoutBox,i);if(t){let e=t(Dm(a));this.hasMutatedConstraints=!!e,e&&(a=Em(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=tg(o=>{if(!Rv(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 zf(this.visualElement,e),n.start(Tf(e,n,0,t,this.visualElement,!1))}stopAnimation(){tg(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){tg(t=>{let{drag:n}=this.getProps();if(!Rv(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]-du(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!X_(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};tg(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Ov({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(),tg(t=>{if(!Rv(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(du(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Pv.set(this.visualElement,this);let e=this.visualElement.current,t=dv(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Ap(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();X_(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Lv(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),ul.read(r);let o=fg(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(tg(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=Av,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Iv(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Lv(e,t,n){let r=Qp(e,Iv(n)),i=Qp(t,Iv(n));return()=>{r(),i()}}function Rv(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function zv(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Bv=class extends Tm{constructor(e){super(e),this.removeGroupControls=jc,this.removeListeners=jc,this.controls=new Fv(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||jc}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()}},Vv=e=>(t,n)=>{e&&ul.update(()=>e(t,n),!1,!0)},Hv=class extends Tm{constructor(){super(...arguments),this.removePointerDownListener=jc}onPointerDown(e){this.session=new gv(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:fv(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Vv(e),onStart:Vv(t),onMove:Vv(n),onEnd:(e,t)=>{delete this.session,r&&ul.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=dv(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Uv=!1,Wv=class extends Q.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),Uv&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),vg.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}),Uv=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||ul.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(),_p.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Uv=!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 Gv(e){let[t,n]=l_(),r=(0,Q.useContext)(yc);return(0,$.jsx)(Wv,{...e,layoutGroup:r,switchLayoutGroup:(0,Q.useContext)(Y_),isPresent:t,safeToRemove:n})}var Kv={pan:{Feature:Hv},drag:{Feature:Bv,ProjectionNode:e_,MeasureLayout:Gv}};function qv(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&ul.postRender(()=>i(t,lv(t)))}var Jv=class extends Tm{mount(){let{current:e}=this.node;e&&(this.unmount=wp(e,(e,t)=>(qv(this.node,t,`Start`),e=>qv(this.node,e,`End`))))}unmount(){}},Yv=class extends Tm{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=Mc(fg(this.node.current,`focus`,()=>this.onFocus()),fg(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Xv(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&&ul.postRender(()=>i(t,lv(t)))}var Zv=class extends Tm{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Lp(e,(e,t)=>(Xv(this.node,t,`Start`),(e,{success:t})=>Xv(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Qv=new WeakMap,$v=new WeakMap,ey=e=>{let t=Qv.get(e.target);t&&t(e)},ty=e=>{e.forEach(ey)};function ny({root:e,...t}){let n=e||document;$v.has(n)||$v.set(n,{});let r=$v.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(ty,{root:e,...t})),r[i]}function ry(e,t,n){let r=ny(t);return Qv.set(e,n),r.observe(e),()=>{Qv.delete(e),r.unobserve(e)}}var iy={some:0,all:1},ay=class extends Tm{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:iy[r]},o=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)};this.stopObserver=ry(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(oy(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function oy({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var sy={inView:{Feature:ay},tap:{Feature:Zv},focus:{Feature:Yv},hover:{Feature:Jv}},cy={layout:{ProjectionNode:e_,MeasureLayout:Gv}},ly=iv({...cv,...sy,...Kv,...cy},av);function uy(e){let t=bc(()=>hf(e)),{isStatic:n}=(0,Q.useContext)(t_);if(n){let[,n]=(0,Q.useState)(e);(0,Q.useEffect)(()=>t.on(`change`,n),[])}return t}function dy(){!gm.current&&vm();let[e]=(0,Q.useState)(hm.current);return e}var fy=ly,py=new Map;function my(e,t){return py.get(`${e}:${t}`)??{path:null,repositoryId:null}}function hy(e,t,n){py.set(`${e}:${t}`,{...my(e,t),...n})}var gy=new Map,_y=new Map,vy=new Map,yy=new Set;function by(e,t){gy.set(e,t)}function xy(e){return gy.get(e)??null}function Sy(e,t){gy.set(e,t),_y.set(e,(_y.get(e)??0)+1),yy.forEach(e=>e())}function Cy(e){return(0,Q.useSyncExternalStore)(e=>(yy.add(e),()=>{yy.delete(e)}),()=>_y.get(e)??0)}function wy(e){let t=Symbol(),n=vy.get(e)??new Set;return n.add(t),vy.set(e,n),()=>{n.delete(t),n.size||vy.delete(e)}}function Ty(e){return!!vy.get(e)?.size}var Ey=4096,Dy=250,Oy=1100,ky=.1,Ay=40;function jy(e,t){let[n,r]=(0,Q.useState)(e),i=(0,Q.useRef)(e),a=(0,Q.useRef)(e),o=(0,Q.useRef)(0),s=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{a.current=e},[e]),(0,Q.useEffect)(()=>{i.current=n},[n]),(0,Q.useEffect)(()=>{if(!e.startsWith(i.current)){i.current=e,o.current=0,n!==e&&r(e);return}if(!t&&e.length<=i.current.length){s.current!=null&&(cancelAnimationFrame(s.current),s.current=null),n!==e&&r(e);return}let c=e=>{let t=i.current,n=a.current,l=n.length-t.length;if(l<=0){s.current=null;return}if(l>Ey){r(n),i.current=n,s.current=null;return}let u=o.current||e,d=Math.min(48,Math.max(0,e-u));o.current=e;let f=Oy*d/1e3,p=Math.min(l*ky,Ay),m=l/Dy*d,h=Math.max(1,Math.min(Math.round(Math.max(f+p,m)),l)),g=n.slice(0,Math.min(n.length,t.length+h));r(g),i.current=g,s.current=requestAnimationFrame(c)};return s.current??=(o.current=0,requestAnimationFrame(c)),()=>{s.current!=null&&(cancelAnimationFrame(s.current),s.current=null)}},[e,t,n]),n}function My(e,t){return Le(e,{...t,weekStartsOn:1})}function Ny(e,t){let n=$e(e,t?.in),r=n.getFullYear(),i=Qe(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=My(i),o=Qe(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=My(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function Py(e,t){let n=$e(e,t?.in);return n.setHours(0,0,0,0),n}function Fy(e,t,n){let[r,i]=je(n?.in,e,t),a=Py(r),o=Py(i),s=+a-Xn(a),c=+o-Xn(o);return Math.round((s-c)/Pe)}function Iy(e,t){let n=Ny(e,t),r=Qe(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),My(r)}function Ly(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Ry(e){return!(!Ly(e)&&typeof e!=`number`||isNaN(+$e(e)))}function zy(e,t){let n=$e(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function By(e,t){let n=$e(e,t?.in);return Fy(n,zy(n))+1}function Vy(e,t){let n=$e(e,t?.in),r=My(n)-+Iy(n);return Math.round(r/Me)+1}function Hy(e,t){let n=$e(e,t?.in),r=n.getFullYear(),i=Ne(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Qe(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Le(o,t),c=Qe(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Le(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function Uy(e,t){let n=Ne(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=Hy(e,t),a=Qe(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Le(a,t)}function Wy(e,t){let n=$e(e,t?.in),r=Le(n,t)-+Uy(n,t);return Math.round(r/Me)+1}function Gy(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var Ky={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return Gy(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):Gy(n+1,2)},d(e,t){return Gy(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return Gy(e.getHours()%12||12,t.length)},H(e,t){return Gy(e.getHours(),t.length)},m(e,t){return Gy(e.getMinutes(),t.length)},s(e,t){return Gy(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return Gy(Math.trunc(r*10**(n-3)),t.length)}},qy={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},Jy={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return Ky.y(e,t)},Y:function(e,t,n,r){let i=Hy(e,r),a=i>0?i:1-i;return t===`YY`?Gy(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):Gy(a,t.length)},R:function(e,t){return Gy(Ny(e),t.length)},u:function(e,t){return Gy(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return Gy(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return Gy(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return Ky.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return Gy(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Wy(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):Gy(i,t.length)},I:function(e,t,n){let r=Vy(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):Gy(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):Ky.d(e,t)},D:function(e,t,n){let r=By(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):Gy(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return Gy(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return Gy(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return Gy(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?qy.noon:r===0?qy.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?qy.evening:r>=12?qy.afternoon:r>=4?qy.morning:qy.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return Ky.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):Ky.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):Gy(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):Gy(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):Ky.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):Ky.s(e,t)},S:function(e,t){return Ky.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Xy(r);case`XXXX`:case`XX`:return Zy(r);default:return Zy(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Xy(r);case`xxxx`:case`xx`:return Zy(r);default:return Zy(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Yy(r,`:`);default:return`GMT`+Zy(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Yy(r,`:`);default:return`GMT`+Zy(r,`:`)}},t:function(e,t,n){return Gy(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return Gy(+e,t.length)}};function Yy(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+Gy(a,2)}function Xy(e,t){return e%60==0?(e>0?`-`:`+`)+Gy(Math.abs(e)/60,2):Zy(e,t)}function Zy(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Gy(Math.trunc(r/60),2),a=Gy(r%60,2);return n+i+t+a}var Qy=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},$y=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},eb={p:$y,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Qy(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Qy(r,t)).replace(`{{time}}`,$y(i,t))}},tb=/^D+$/,nb=/^Y+$/,rb=[`D`,`DD`,`YY`,`YYYY`];function ib(e){return tb.test(e)}function ab(e){return nb.test(e)}function ob(e,t,n){let r=sb(e,t,n);if(console.warn(r),rb.includes(e))throw RangeError(r)}function sb(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var cb=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,lb=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ub=/^'([^]*?)'?$/,db=/''/g,fb=/[a-zA-Z]/;function pb(e,t,n){let r=Ne(),i=n?.locale??r.locale??et,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=$e(e,n?.in);if(!Ry(s))throw RangeError(`Invalid time value`);let c=t.match(lb).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=eb[t];return n(e,i.formatLong)}return e}).join(``).match(cb).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:mb(e)};if(Jy[t])return{isToken:!0,value:e};if(t.match(fb))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&ab(a)||!n?.useAdditionalDayOfYearTokens&&ib(a))&&ob(a,t,String(e));let o=Jy[a[0]];return o(s,a,i.localize,l)}).join(``)}function mb(e){let t=e.match(ub);return t?t[1].replace(db,`'`):e}async function hb(e){if(e.startsWith(`factory:`)){let t=await fetch(`${He}/api/loops/factory`);if(!t.ok)return null;let n=((await t.json()).loops??[]).find(t=>t.id===e);return n?{id:n.id,name:n.name,description:n.description,status:null,graph:n.graph,locked:!0}:null}let t=await fetch(`${He}/api/loops/${encodeURIComponent(e)}`);if(!t.ok)return null;let n=(await t.json()).loop;return n?{id:n.id,name:n.name,description:n.description,status:n.status,graph:n.graph,locked:!1}:null}async function gb(e,t){let n=await fetch(`${He}/api/projects/${e}/git/pull-requests/${t}`);if(!n.ok)return null;let r=await n.json();return typeof r.url==`string`&&r.url?r.url:null}function _b(){let{t:e}=K(`agent`),{openTicketDetailInProject:t}=he(),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),o=(0,Q.useCallback)(()=>r(null),[]),s=(0,Q.useCallback)(()=>a(null),[]);return{openRef:(0,Q.useCallback)(async(n,i)=>{try{if(i.kind===`ticket`){if(!(await fetch(`${He}/api/projects/${n}/tickets/${i.ticketId}`)).ok){J.info(e(`refs.ticketNotFound`,{id:i.ticketId}));return}t(n,i.ticketId)}else if(i.kind===`pull-request`){let t=i.prUrl??await gb(n,i.prNumber);if(!t){J.info(e(`refs.pullRequestNotFound`,{id:i.prNumber}));return}await Te(t)}else if(i.kind===`loop`){let t=await hb(i.loopId);if(!t){J.info(e(`refs.loopNotFound`));return}a(t)}else{if((await fetch(`${He}/api/projects/${n}/jobs/${i.jobId}`)).ok){r({projectId:n,jobId:i.jobId});return}let t=await hb(i.jobId);if(t){a(t);return}J.info(e(`refs.jobNotFound`))}}catch{J.info(e(`refs.lookupFailed`))}},[t,e]),jobRef:n,closeJobRef:o,loopRef:i,closeLoopRef:s}}function vb(e){if(e.startsWith(`mcp__`)){let t=e.split(`__`).pop()?.replace(/^specrails_/,``)??``;return t?`MCP · ${t}`:`MCP Tool`}return{Bash:`Terminal`,Read:`Reading`,Grep:`Searching`,Glob:`Searching`,Write:`Editing`,Edit:`Editing`,NotebookEdit:`Editing`,WebFetch:`Web`,WebSearch:`Web`,Task:`Agent`}[e]??e}var yb=new Set([`<unnamed>`,`<missing>`,``]);function bb({tool:e,onClick:t}){let{t:n}=K(`agent`),r=e&&!yb.has(e)?vb(e):n(`thinking`),i=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin text-accent-info`}),(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:`easeOut`},children:r},r)})]}),a=`inline-flex items-center gap-2 rounded-full border border-border/50 bg-surface/60 px-3 py-1 text-xs font-medium text-foreground/80`;return t?(0,$.jsxs)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity.openLog`),title:n(`activity.openLog`),"data-testid":`agent-activity-chip`,className:`${a} group cursor-pointer transition-colors hover:border-accent-info/50 hover:bg-surface/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/50`,children:[i,(0,$.jsx)($s,{className:`h-3 w-3 text-foreground/40 transition-colors group-hover:text-accent-info`,"aria-hidden":!0})]}):(0,$.jsx)(`div`,{className:a,children:i})}var xb=e(s(),1);function Sb({tools:e,streaming:t,onClose:n}){let{t:r}=K(`agent`),i=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,Q.useEffect)(()=>{if(!t)return;let e=i.current;e&&(e.scrollTop=e.scrollHeight)},[e.length,t]);let a=e=>{let t=[`[${e.at?Cb(e.at):``}] ${e.tool}`];return e.input&&t.push(` input: ${e.input}`),e.output!==void 0&&t.push(` ${e.isError?`error`:`output`}: ${e.output||`∅`}`),t.join(`
25
+ `)},o=async()=>{try{await navigator.clipboard.writeText(e.map(a).join(`
26
+
27
+ `)),J.success(r(`activity.copySuccess`))}catch{J.error(r(`activity.copyFailed`))}};return(0,xb.createPortal)((0,$.jsxs)(`div`,{"data-testid":`agent-activity-log-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:n,"aria-hidden":!0}),(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":r(`activity.title`),className:`relative flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-border/30 bg-popover shadow-xl backdrop-blur-md`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-4 py-3`,children:[(0,$.jsx)($s,{className:`h-4 w-4 text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold`,children:r(`activity.title`)}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/40 px-1.5 py-px text-[10px] leading-4 text-muted-foreground`,children:e.length}),t&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-accent-info`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),r(`activity.live`)]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void o(),disabled:e.length===0,title:r(`activity.copyAll`),"aria-label":r(`activity.copyAll`),"data-testid":`agent-activity-copy-all`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,$.jsx)(Ho,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":r(`activity.close`),className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]})]}),(0,$.jsx)(`div`,{ref:i,className:`min-h-0 flex-1 space-y-2 overflow-y-auto px-4 py-3`,children:e.length===0?(0,$.jsx)(`p`,{className:`py-8 text-center text-xs text-muted-foreground`,children:r(`activity.empty`)}):e.map(e=>(0,$.jsx)(wb,{entry:e,formatted:a(e)},e.id))})]})]}),document.body)}function Cb(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(void 0,{hour12:!1})}function wb({entry:e,formatted:t}){let{t:n}=K(`agent`),[r,i]=(0,Q.useState)(!1),a=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{J.error(n(`activity.copyFailed`))}};return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-surface/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(sc,{className:`h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:vb(e.tool)}),(0,$.jsx)(`span`,{className:`truncate text-[10px] font-mono text-muted-foreground`,children:e.tool}),e.at&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] font-mono text-muted-foreground`,children:Cb(e.at)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void a(),title:n(`activity.copyEntry`),"aria-label":n(`activity.copyEntry`),"data-testid":`agent-activity-copy-${e.id}`,className:X(`shrink-0 rounded p-1 transition-colors`,r?`text-accent-success`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`,!e.at&&`ml-auto`),children:r?(0,$.jsx)(Ht,{className:`h-3 w-3`}):(0,$.jsx)(Ho,{className:`h-3 w-3`})})]}),e.input&&(0,$.jsx)(`pre`,{className:`mt-1.5 max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-background-deep/60 px-2 py-1.5 font-mono text-[11px] leading-relaxed text-foreground/80`,children:e.input}),e.output!==void 0&&(0,$.jsxs)(`div`,{className:`mt-1.5`,children:[(0,$.jsx)(`p`,{className:X(`mb-0.5 text-[10px] uppercase tracking-wider`,e.isError?`text-destructive`:`text-muted-foreground`),children:e.isError?n(`activity.error`):n(`activity.output`)}),(0,$.jsx)(`pre`,{className:X(`max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed`,e.isError?`bg-destructive/10 text-destructive`:`bg-background-deep/60 text-foreground/80`),children:e.output||`∅`})]})]})}function Tb(e){if(!e)return NaN;let t=e.trim();return/[zZ]$/.test(t)||/[+-]\d{2}:?\d{2}$/.test(t)?Date.parse(t):Date.parse(`${t.replace(` `,`T`)}Z`)}function Eb(e){let t=Tb(e);return Number.isNaN(t)?null:new Date(t)}function Db(e,t=Date.now()){let n=Tb(e);if(Number.isNaN(n))return``;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<45)return`now`;let i=Math.floor(r/60);if(i<60)return`${Math.max(1,i)}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);if(o<7)return`${o}d`;let s=Math.floor(o/7);if(o<30)return`${s}w`;let c=Math.floor(o/30);return c<12?`${c}mo`:`${Math.floor(o/365)}y`}function Ob(e){let t=Eb(e);return t?pb(t,`PPpp`,{locale:Ue()}):``}var kb=2,Ab=8,jb=80,Mb="```options";function Nb(e){let t=e.replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``),n;try{n=JSON.parse(t)}catch{return null}if(!Array.isArray(n)||n.length<kb||n.length>Ab)return null;let r=[];for(let e of n){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.length>jb)return null;r.push(t)}return r}function Pb(e){let t=e.indexOf(Mb);for(;t!==-1;){if(t===0||e[t-1]!=="`"){let n=Nb(e.slice(t+10));if(n)return{body:e.slice(0,t).replace(/\s+$/,``),options:n}}t=e.indexOf(Mb,t+1)}return{body:e,options:null}}var Fb=/```spec-draft[^\S\n]*\n([\s\S]*?)\n[^\S\n]*```/g,Ib="```spec-draft",Lb=new Set([`low`,`medium`,`high`,`critical`]);function Rb(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function zb(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r={title:typeof n.title==`string`?n.title:Wt.title,description:typeof n.description==`string`?n.description:Wt.description,labels:Rb(n.labels),priority:typeof n.priority==`string`&&Lb.has(n.priority)?n.priority:Wt.priority,acceptanceCriteria:Rb(n.acceptanceCriteria)};return!r.title.trim()&&!r.description.trim()?null:r}function Bb(e){return e.replace(/\n{3,}/g,`
28
+
29
+ `).trim()}function Vb(e,t=!1){if(!e.includes(Ib))return{body:e,draft:null,pending:!1};let n=null,r=``,i=0;Fb.lastIndex=0;let a;for(;(a=Fb.exec(e))!==null;){r+=e.slice(i,a.index),i=a.index+a[0].length;let t=zb(a[1]);t&&(n=t)}r+=e.slice(i);let o=!1,s=r.indexOf(Ib);if(s!==-1){let e=zb(r.slice(s+13).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``));e?(n=e,r=r.slice(0,s)):t&&(r=r.slice(0,s),o=!0)}return{body:Bb(r),draft:n,pending:o}}var Hb={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`},Ub=X(`text-xs leading-6 text-foreground/85`,`[&_p]:my-2 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-[11px] [&_h2]:font-semibold [&_h2]:uppercase [&_h2]:tracking-wider [&_h2]:text-foreground/60 [&_h2:first-child]:mt-0`,`[&_h3]:mt-2 [&_h3]:mb-1 [&_h3]:text-xs [&_h3]:font-semibold`,`[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-4 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-4 [&_li]:my-0.5`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-2`,`[&_strong]:font-semibold`);function Wb({draft:e}){let{t}=K(`agent`),[n,r]=(0,Q.useState)(!1),i=e.description.trim().length>0,a=e.acceptanceCriteria;return(0,$.jsxs)(`div`,{"data-testid":`agent-spec-draft-card`,className:`my-1 overflow-hidden rounded-xl border border-accent-primary/25 bg-card/80 shadow-lg backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/40 bg-accent-primary/[0.06] px-3.5 py-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest text-accent-primary/90`,children:[(0,$.jsx)(un,{className:`h-3 w-3`}),t(`specDraft.heading`)]}),(0,$.jsx)(`span`,{className:X(`rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,Hb[e.priority]),children:t(`explore:priority.${e.priority}`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.5 py-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold leading-snug text-foreground`,children:e.title.trim()||t(`specDraft.untitled`)}),e.labels.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.labels.map((e,t)=>(0,$.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[10px] text-foreground/70`,children:e},`${t}-${e}`))}),i&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:X(`relative`,!n&&`max-h-28 overflow-hidden`),children:[(0,$.jsx)(`div`,{className:Ub,children:(0,$.jsx)(Jn,{remarkPlugins:[Yn],children:e.description})}),!n&&(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-card to-transparent`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"data-agent-interactive":!0,className:`mt-1 flex items-center gap-1 text-[11px] text-accent-info transition-colors hover:text-foreground`,children:[n?(0,$.jsx)(Gt,{className:`h-3 w-3`}):(0,$.jsx)(Zt,{className:`h-3 w-3`}),t(n?`specDraft.collapse`:`specDraft.expand`)]})]}),a.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-foreground/50`,children:[t(`specDraft.acceptanceCriteria`),` · `,a.length]}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs leading-5 text-foreground/85`,children:[(0,$.jsx)(Mo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success/80`}),(0,$.jsx)(`span`,{children:e})]},`${t}-${e}`))})]})]})]})}function Gb(){let{t:e}=K(`agent`);return(0,$.jsxs)(`span`,{"data-testid":`agent-spec-draft-pending`,className:`inline-flex w-fit items-center gap-1.5 rounded-full border border-accent-primary/25 bg-accent-primary/10 px-2.5 py-1 text-[11px] text-accent-primary/90`,children:[(0,$.jsx)(un,{className:`h-3 w-3 animate-pulse`}),e(`specDraft.drafting`)]})}var Kb=/```problem-frame[^\S\n]*\n([\s\S]*?)\n[^\S\n]*```/g,qb="```problem-frame";function Jb(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yb(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.reading!=`string`||!t.reading.trim()?null:{reading:t.reading,touches:Jb(t.touches)}}function Xb(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=Yb(n.restated),i=Yb(n.alternative);return!r||!i||typeof n.discriminator!=`string`||!n.discriminator.trim()||r.reading.trim()===i.reading.trim()?null:{restated:r,alternative:i,discriminator:n.discriminator,assumptions:Jb(n.assumptions),unknowns:Jb(n.unknowns)}}function Zb(e){return e.replace(/\n{3,}/g,`
30
+
31
+ `).trim()}function Qb(e,t=!1){if(!e.includes(qb))return{body:e,frame:null,pending:!1};let n=null,r=``,i=0;Kb.lastIndex=0;let a;for(;(a=Kb.exec(e))!==null;){r+=e.slice(i,a.index),i=a.index+a[0].length;let t=Xb(a[1]);t&&(n=t)}r+=e.slice(i);let o=!1,s=r.indexOf(qb);if(s!==-1){let e=Xb(r.slice(s+16).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``));e?(n=e,r=r.slice(0,s)):t&&(r=r.slice(0,s),o=!0)}return{body:Zb(r),frame:n,pending:o}}var $b=`flex min-w-0 flex-col gap-1.5 rounded-lg border border-border/50 bg-surface/50 p-2.5 text-left`;function ex({label:e,value:t,testId:n,onSelect:r,disabled:i}){let{t:a}=K(`agent`),o=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground/50`,children:e}),(0,$.jsx)(`div`,{className:`text-xs leading-5 text-foreground/90`,children:t.reading}),t.touches.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 pt-0.5`,children:[(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground/40`,children:a(`problemFrame.touches`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.touches.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded border border-border/50 bg-background-deep/40 px-1.5 py-0.5 font-mono text-[10px] text-foreground/65`,children:[(0,$.jsx)($o,{className:`h-2.5 w-2.5 shrink-0 text-accent-info/70`}),(0,$.jsx)(`span`,{className:`truncate`,children:e})]},`${t}-${e}`))})]})]});return r?(0,$.jsxs)(`button`,{type:`button`,"data-testid":n,"data-agent-interactive":!0,disabled:i,title:a(`problemFrame.pick`),onClick:()=>r(t.reading),className:X($b,`group/reading transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50`,i?`cursor-default`:`cursor-pointer hover:border-accent-primary/45 hover:bg-accent-primary/[0.09]`),children:[o,(0,$.jsxs)(`span`,{"aria-hidden":!0,className:X(`mt-0.5 inline-flex items-center gap-1 text-[10px] font-medium text-accent-primary/80 transition-opacity`,i?`opacity-0`:`opacity-0 group-hover/reading:opacity-100 group-focus-visible/reading:opacity-100`),children:[(0,$.jsx)(Uo,{className:`h-2.5 w-2.5`}),a(`problemFrame.pick`)]})]}):(0,$.jsx)(`div`,{"data-testid":n,className:$b,children:o})}function tx({label:e,items:t}){return t.length===0?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground/45`,children:e}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px] leading-5 text-foreground/70`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-foreground/30`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:e})]},`${t}-${e}`))})]})}function nx({frame:e,isLatest:t,isStreaming:n,onSelect:r}){let{t:i}=K(`agent`),a=e.assumptions.length>0||e.unknowns.length>0,o=r&&t?r:void 0;return(0,$.jsxs)(`div`,{"data-testid":`agent-problem-frame-card`,className:`my-1 overflow-hidden rounded-xl border border-accent-info/25 bg-card/80 shadow-lg backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/40 bg-accent-info/[0.06] px-3.5 py-2 text-[10px] font-semibold uppercase tracking-widest text-accent-info/90`,children:[(0,$.jsx)(Bo,{className:`h-3 w-3`}),i(`problemFrame.heading`)]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.5 py-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,$.jsx)(ex,{label:i(`problemFrame.restated`),value:e.restated,testId:`agent-problem-frame-reading-restated`,onSelect:o,disabled:n}),(0,$.jsx)(ex,{label:i(`problemFrame.alternative`),value:e.alternative,testId:`agent-problem-frame-reading-alternative`,onSelect:o,disabled:n})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-accent-primary/25 bg-accent-primary/[0.07] px-2.5 py-2`,children:[(0,$.jsx)(Po,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary/80`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-accent-primary/80`,children:i(`problemFrame.discriminator`)}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-foreground/90`,children:e.discriminator})]})]}),a&&(0,$.jsxs)(`div`,{className:`grid gap-2 border-t border-border/40 pt-2.5 sm:grid-cols-2`,children:[(0,$.jsx)(tx,{label:i(`problemFrame.assumptions`),items:e.assumptions}),(0,$.jsx)(tx,{label:i(`problemFrame.unknowns`),items:e.unknowns})]})]})]})}function rx(){let{t:e}=K(`agent`);return(0,$.jsxs)(`span`,{"data-testid":`agent-problem-frame-pending`,className:`inline-flex w-fit items-center gap-1.5 rounded-full border border-accent-info/25 bg-accent-info/10 px-2.5 py-1 text-[11px] text-accent-info/90`,children:[(0,$.jsx)(Bo,{className:`h-3 w-3 animate-pulse`}),e(`problemFrame.framing`)]})}var ix=`#agentref:`;function ax(e){return e.kind===`ticket`?`${ix}ticket:${e.ticketId}`:e.kind===`pull-request`?`${ix}pr:${e.prNumber}${e.prUrl?`:${encodeURIComponent(e.prUrl)}`:``}`:e.kind===`loop`?`${ix}loop:${e.loopId}`:`${ix}job:${e.jobId}`}function ox(e){if(!e||!e.startsWith(ix))return null;let t=e.slice(10);if(t.startsWith(`ticket:`)){let e=Number.parseInt(t.slice(7),10);return Number.isInteger(e)&&e>0?{kind:`ticket`,ticketId:e}:null}if(t.startsWith(`pr:`)){let[,e,n]=/^pr:(\d+)(?::(.+))?$/.exec(t)??[],r=Number.parseInt(e??``,10);if(!Number.isInteger(r)||r<=0)return null;let i=n?decodeURIComponent(n):void 0;return i?{kind:`pull-request`,prNumber:r,prUrl:i}:{kind:`pull-request`,prNumber:r}}if(t.startsWith(`job:`)){let e=t.slice(4);return cx.test(e)?{kind:`job`,jobId:e}:null}if(t.startsWith(`loop:`)){let e=t.slice(5);return ux.test(e)||cx.test(e)?{kind:`loop`,loopId:e}:null}return null}var sx=`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`,cx=RegExp(`^${sx}$`),lx=`factory:(?:implement|batch|freestyle)`,ux=RegExp(`^${lx}$`),dx=/\b(jobs?|runs?|loops?|rails?|ejecuci[oó]n(?:es)?|trabajos?|bucles?)\b|(?:loop|job|run)[a-z]*id/i;function fx(e){let t=new Set;for(let n of e.split(`
32
+ `)){if(!dx.test(n))continue;let e=new RegExp(sx,`g`),r;for(;(r=e.exec(n))!==null;)t.add(r[0].toLowerCase())}return t}var px=/[\w#&$-]/,mx=/[\w-]/;function hx(e,t){let n=/\b(?:PR|pull request)\s*#?(\d{1,10})\b/gi,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];if(n!==void 0&&px.test(n)||i!==void 0&&mx.test(i))continue;let a=Number.parseInt(r[1],10);!Number.isInteger(a)||a<=0||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`pull-request`,prNumber:a,label:`PR #${a}`}})}let i=/https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?/gi,a;for(;(a=i.exec(e))!==null;){let e=Number.parseInt(a[1],10);if(!Number.isInteger(e)||e<=0)continue;let n=a[0].replace(/[.,;:!?…]+$/u,``);t.push({start:a.index,end:a.index+n.length,segment:{kind:`pull-request`,prNumber:e,prUrl:n,label:`PR #${e}`}})}}function gx(e){if(!e)return null;let t=/^https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?$/i.exec(e);if(!t)return null;let n=Number.parseInt(t[1],10);return!Number.isInteger(n)||n<=0?null:{prNumber:n,prUrl:e}}function _x(e,t){let n=/#(\d{1,6})/g,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=r.index+r[0].length,a=e[i];if(n!==void 0&&px.test(n)||a!==void 0&&mx.test(a))continue;let o=Number.parseInt(r[1],10);if(!Number.isInteger(o)||o<=0)continue;let s=i,c=`#${o}`,l=/^([ \t]*[—–][ \t]*)([^\n#]{1,80})/.exec(e.slice(s));if(l){let e=l[2].replace(/[\s.,;:!?…]+$/u,``);e.length>0&&(s+=l[1].length+e.length,c=`#${o} — ${e}`)}t.push({start:r.index,end:s,segment:{kind:`ticket`,ticketId:o,label:c}})}}function vx(e,t,n){let r=new RegExp(sx,`g`),i;for(;(i=r.exec(e))!==null;){let r=e[i.index-1],a=e[i.index+i[0].length];if(r!==void 0&&px.test(r)||a!==void 0&&mx.test(a))continue;let o=i[0].toLowerCase();t.has(o)&&n.push({start:i.index,end:i.index+i[0].length,segment:{kind:`job`,jobId:o,label:`${o.slice(0,8)}…`}})}}function yx(e,t){let n=new RegExp(lx,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];n!==void 0&&px.test(n)||i!==void 0&&mx.test(i)||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`loop`,loopId:r[0],label:r[0]}})}}function bx(e,t){let n=[];if(hx(e,n),_x(e,n),vx(e,t,n),yx(e,n),n.length===0)return[{kind:`text`,text:e}];n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let t of n)t.start<i||(t.start>i&&r.push({kind:`text`,text:e.slice(i,t.start)}),r.push(t.segment),i=t.end);return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r}var xx=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function Sx(e){return e.kind===`text`?{type:`text`,value:e.text}:{type:`link`,url:ax(e.kind===`ticket`?{kind:`ticket`,ticketId:e.ticketId}:e.kind===`pull-request`?{kind:`pull-request`,prNumber:e.prNumber,prUrl:e.prUrl}:e.kind===`loop`?{kind:`loop`,loopId:e.loopId}:{kind:`job`,jobId:e.jobId}),children:[{type:`text`,value:e.label}]}}function Cx(e,t){let n=e.children;if(n)for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.type===`inlineCode`&&typeof r.value==`string`){let i=r.value.trim();if(cx.test(i)&&t.has(i.toLowerCase())){let t=i.toLowerCase();n.splice(e,1,Sx({kind:`job`,jobId:t,label:`${t.slice(0,8)}…`}))}else ux.test(i)&&n.splice(e,1,Sx({kind:`loop`,loopId:i,label:i}));continue}if(r.type===`link`&&typeof r.url==`string`){let t=gx(r.url);t&&n.splice(e,1,Sx({kind:`pull-request`,prNumber:t.prNumber,prUrl:t.prUrl,label:`PR #${t.prNumber}`}));continue}if(!xx.has(r.type))if(r.type===`text`&&typeof r.value==`string`){let i=bx(r.value,t);i.some(e=>e.kind!==`text`)&&n.splice(e,1,...i.map(Sx))}else Cx(r,t)}}function wx(){return(e,t)=>{Cx(e,fx(t==null?``:String(t)))}}function Tx({refTarget:e,onOpen:t,children:n}){let{t:r}=K(`agent`),i=e.kind===`ticket`?r(`refs.openTicket`,{id:e.ticketId}):e.kind===`pull-request`?r(`refs.openPullRequest`,{id:e.prNumber}):e.kind===`loop`?r(`refs.openLoop`,{id:e.loopId}):r(`refs.openJob`,{id:e.jobId.slice(0,8)}),a=e.kind===`ticket`?F:e.kind===`pull-request`?R:e.kind===`loop`?Ys:Eo;return(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-ref-chip`,"data-ref-kind":e.kind,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,`hover:-translate-y-px hover:shadow-sm`,e.kind===`ticket`?`border-accent-primary/35 bg-accent-primary/10 text-accent-primary hover:border-accent-primary/60 hover:bg-accent-primary/15`:e.kind===`pull-request`?`border-accent-success/35 bg-accent-success/10 text-accent-success hover:border-accent-success/60 hover:bg-accent-success/15`:e.kind===`loop`?`border-accent-highlight/35 bg-accent-highlight/10 text-accent-highlight hover:border-accent-highlight/60 hover:bg-accent-highlight/15`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:border-accent-info/60 hover:bg-accent-info/15`),children:[(0,$.jsx)(a,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,$.jsx)(`span`,{className:`max-w-[280px] truncate`,children:n})]})}function Ex({receipt:e,status:t}){let{t:n}=K(`agent`),r=t===`interrupted`||t===`cancelled`?t:e??(t===`delivered`?`received`:`sent`),i=n(`receipt.${r}`);return(0,$.jsx)(`span`,{role:`img`,"aria-label":i,title:i,"data-testid":`agent-delivery-receipt`,"data-receipt":r,className:`inline-flex shrink-0 items-center align-middle ${r===`read`?`text-emerald-500`:r===`interrupted`?`text-accent-warning`:`text-foreground/45`}`,children:(0,$.jsx)(r===`interrupted`?fn:r===`cancelled`?en:r===`sent`?Ht:Ao,{className:`h-3.5 w-3.5`,"aria-hidden":`true`,strokeWidth:2})})}var Dx=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-5 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_blockquote]:my-2 [&_blockquote]:border-l-2 [&_blockquote]:border-accent-primary/40 [&_blockquote]:pl-3 [&_blockquote]:text-foreground/80`,`[&_hr]:my-3 [&_hr]:border-border/60`,`[&_table]:my-2 [&_table]:w-full [&_table]:border-collapse [&_table]:overflow-hidden [&_table]:rounded-lg`,`[&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-semibold`,`[&_td]:border [&_td]:border-border [&_td]:px-2.5 [&_td]:py-1.5`,`[&_tr:nth-child(even)]:bg-surface/40`);function Ox({text:e,timestampIso:t}){let{t:n}=K(`agent`),[r,i]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{type:`button`,onClick:async()=>{try{let n=e;if(t){let r=Eb(t);r&&(n=`[${pb(r,`yyyy-MM-dd HH:mm:ss`)}]\n${e}`)}await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)}catch{}},"aria-label":n(`copy`),title:n(`copy`),className:`rounded-md p-1 text-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-foreground group-hover:opacity-100`,"data-agent-interactive":!0,children:r?(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3 w-3`})})}function kx({iso:e}){if(!e)return null;let t=Eb(e);if(!t)return null;let n=Ue();return(0,$.jsx)(`time`,{dateTime:t.toISOString(),title:pb(t,`PPpp`,{locale:n}),className:`shrink-0 select-none font-mono text-[10px] leading-none tabular-nums tracking-tight text-foreground/25 transition-colors duration-200 group-hover:text-foreground/50`,children:pb(t,`yyyy-MM-dd HH:mm:ss`)})}function Ax(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function jx(e){return e.mimeType.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.filename)}function Mx({conversationId:e,attachment:t,onClose:n}){let{t:r}=K(`agent`),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null);if((0,Q.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,Q.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),Ya(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`attachment.loadFailed`))}),()=>{n=!0}},[t,e,r]),(0,Q.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=jx(t),l=r(`attachment.download`),u=i?(0,$.jsxs)(`a`,{href:i,download:t.filename,onClick:e=>e.stopPropagation(),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90`,"data-agent-interactive":!0,children:[(0,$.jsx)(tn,{className:`h-4 w-4`}),l]}):(0,$.jsxs)(`button`,{type:`button`,disabled:!0,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white opacity-45`,children:[o?(0,$.jsx)(tn,{className:`h-4 w-4`}):(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`}),l]});return(0,xb.createPortal)((0,$.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c?r(`attachment.previewTitle`,{name:t.filename}):r(`attachment.downloadTitle`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm animate-in fade-in-0 duration-150`,onClick:n,children:c?(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-white/10 bg-black/30 px-3 py-2 text-white`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`close`),className:`inline-flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm text-white/75 transition-colors hover:bg-white/10 hover:text-white`,"data-agent-interactive":!0,children:[(0,$.jsx)(Rt,{className:`h-4 w-4`}),r(`close`)]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-white/95`,children:t.filename}),(0,$.jsx)(`div`,{className:`text-[11px] text-white/45`,children:Ax(t.size)||t.mimeType})]}),u]}),(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center overflow-auto p-6`,children:o?(0,$.jsx)(`div`,{className:`rounded-xl border border-white/10 bg-white/5 px-8 py-7 text-center text-sm text-white/80`,children:r(`attachment.loadError`,{error:o})}):i?(0,$.jsx)(`img`,{src:i,alt:t.filename,className:`max-h-full max-w-full rounded-xl object-contain shadow-2xl animate-in zoom-in-95 duration-150`}):(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-xl border border-white/10 bg-white/5 px-5 py-3 text-sm text-white/70`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`}),r(`attachment.loading`)]})})]}):(0,$.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-border/70 bg-card p-4 text-foreground shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-surface/70`,children:(0,$.jsx)(ts,{className:`h-5 w-5 text-accent-primary`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`attachment.downloadTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs font-medium text-foreground/70`,children:t.filename}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[11px] text-foreground/45`,children:[Ax(t.size),t.mimeType].filter(Boolean).join(` · `)})]})]}),(0,$.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-foreground/70`,children:r(`attachment.downloadPrompt`)}),o&&(0,$.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:r(`attachment.loadError`,{error:o})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-border/70 bg-surface/70 px-3 py-2 text-sm text-foreground/75 transition-colors hover:bg-surface hover:text-foreground`,"data-agent-interactive":!0,children:r(`attachment.cancelDownload`)}),u]})]})}),document.body)}function Nx({conversationId:e,attachments:t}){let{t:n}=K(`agent`),[r,i]=(0,Q.useState)(null);return!e||!t||t.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 border-t border-border/40 pt-2`,children:t.map(e=>{let t=jx(e),r=t?_s:$t;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e),title:e.filename,"aria-label":n(t?`attachment.openPreview`:`attachment.openDownload`,{name:e.filename}),className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border/60 bg-background/45 px-2 py-1 text-left text-[11px] text-foreground/75 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/10 hover:text-foreground`,"data-agent-interactive":!0,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.filename}),e.size>0&&(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-foreground/35`,children:Ax(e.size)})]},e.id)})}),(0,$.jsx)(Mx,{conversationId:e,attachment:r,onClose:()=>i(null)})]})}function Px(e){return e===`project`||e===`alias`?To:e===`spec`?$t:e===`job`?So:e===`trace`?z:e===`conversation`?So:e===`file`?Rs:e===`pr`?R:e===`action`?un:vo}function Fx(e){return e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function Ix({refItem:e}){let t=Px(e.kind);return(0,$.jsxs)(`span`,{title:[e.label,e.scope?.projectName,e.status].filter(Boolean).join(` · `)||e.token,className:X(`mx-0.5 inline-flex max-w-[16rem] translate-y-[2px] items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium leading-4 shadow-sm shadow-black/5`,Fx(e.kind)),"data-agent-context-token":e.kind,children:[(0,$.jsx)(t,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label||e.token})]})}function Lx({content:e,contextRefs:t}){if(!t||t.length===0)return(0,$.jsx)($.Fragment,{children:e});let n=[],r=0,i=0,a=new Set,o=t.map((t,n)=>({ref:t,originalIndex:n,index:t.token?e.indexOf(t.token):-1})).filter(e=>e.index>=0).sort((e,t)=>e.index-t.index||e.originalIndex-t.originalIndex);for(let t of o){let o=e.indexOf(t.ref.token,r);o<r||o===-1||(o>r&&n.push(e.slice(r,o)),n.push((0,$.jsx)(Ix,{refItem:t.ref},`${t.ref.kind}:${t.ref.id}:${o}:${t.originalIndex}`)),r=o+t.ref.token.length,a.add(t.originalIndex),i++)}r<e.length&&n.push(e.slice(r));let s=t.filter((e,t)=>!a.has(t));return s.length===0?(0,$.jsx)($.Fragment,{children:i?n:e}):(0,$.jsxs)($.Fragment,{children:[s.map((e,t)=>(0,$.jsx)(Ix,{refItem:e},`unmatched:${e.kind}:${e.id}:${t}`)),e.trim()&&(0,$.jsx)(`span`,{className:`mx-0.5`}),i?n:e]})}function Rx({role:e,content:t,createdAt:n,streaming:r,isLast:i,isLatest:a,isStreaming:o,onPickOption:s,refsProjectId:c,onOpenRef:l,contextRefs:u,attachments:d,conversationId:f,deliveryStatus:p,deliveryReceipt:m}){let h=e===`user`,{openWebView:g,canOpenWebView:_}=Se(),v=!h&&!r&&!!c&&!!l,y=(0,Q.useMemo)(()=>v?[Yn,wx]:[Yn],[v]),b=(0,Q.useMemo)(()=>({a:({href:e,children:t})=>{let n=ox(e);return n&&l?(0,$.jsx)(Tx,{refTarget:n,onOpen:l,children:t}):(0,$.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,"data-agent-interactive":!0,onClick:t=>{_&&typeof e==`string`&&/^https?:\/\//i.test(e)&&(t.preventDefault(),t.stopPropagation(),g(e))},children:t})}}),[g,_,l]);if(h)return(0,$.jsxs)(`div`,{className:`group flex flex-col items-end gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-end gap-1`,children:[(0,$.jsx)(Ox,{text:t,timestampIso:n}),(0,$.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-border/50 bg-foreground/[0.06] px-3.5 py-2 text-sm text-foreground`,children:[(0,$.jsx)(Lx,{content:t,contextRefs:u}),(0,$.jsx)(Nx,{conversationId:f,attachments:d}),(p||m)&&(0,$.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,$.jsx)(Ex,{receipt:m,status:p})})]})]}),n&&(0,$.jsx)(`div`,{className:`pr-1.5`,children:(0,$.jsx)(kx,{iso:n})})]});let{body:x,options:S,frame:C,framePending:w,draft:T,pending:E}=(0,Q.useMemo)(()=>{let e=Pb(t),n=Qb(e.body,r),i=Vb(n.body,r);return{body:i.body,options:e.options,frame:n.frame,framePending:n.pending,draft:i.draft,pending:i.pending}},[t,r]),D=!!S&&!!i&&!r&&!!s;return(0,$.jsxs)(`div`,{className:`group flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:X(`max-w-full`,Dx),children:(0,$.jsx)(Jn,{remarkPlugins:y,components:b,children:x})}),C&&(0,$.jsx)(nx,{frame:C,isLatest:!!a,isStreaming:!!o||!!r,onSelect:s}),w&&(0,$.jsx)(rx,{}),T&&(0,$.jsx)(Wb,{draft:T}),E&&(0,$.jsx)(Gb,{}),D&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:S.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s?.(e),className:`rounded-full border border-border/60 bg-surface/70 px-3 py-1 text-xs text-foreground/80 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/15 hover:text-foreground`,"data-agent-interactive":!0,children:e},`${t}-${e}`))}),!r&&(x.trim()||n)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x.trim()&&(0,$.jsx)(Ox,{text:x,timestampIso:n}),n&&(0,$.jsx)(kx,{iso:n})]})]})}function zx({item:e,conversationId:t,attachments:n,onEdit:r}){let{t:i}=K(`agent`),{steerQueuedMessage:a,removeQueuedMessage:o}=lM(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(!1),f=(0,Q.useRef)(null),p=e.deliveryMode===`steer`,m=l||p;(0,Q.useEffect)(()=>{if(!s)return;let e=e=>{f.current?.contains(e.target)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[s]);let h=async t=>{if(!(d.current||p)){d.current=!0,u(!0),c(!1);try{await(t===`steer`?a(e.queueId):o(e.queueId))===`conflict`&&J.info(i(`queue.actionConflict`))}catch{J.error(i(`queue.actionFailed`))}finally{d.current=!1,u(!1)}}};return(0,$.jsx)(`div`,{className:`flex justify-end`,"data-testid":`agent-queued-message`,"data-queue-id":e.queueId,children:(0,$.jsxs)(`div`,{className:`min-w-0 max-w-[85%] rounded-2xl rounded-br-sm border border-dashed border-border/70 bg-foreground/[0.03] text-sm text-foreground/75`,children:[(0,$.jsxs)(`div`,{className:`space-y-1 px-3.5 py-2`,children:[(0,$.jsx)(`div`,{className:`whitespace-pre-wrap`,children:(0,$.jsx)(Lx,{content:e.text,contextRefs:e.contextRefs})}),(0,$.jsx)(Nx,{conversationId:t,attachments:n})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-1 border-t border-border/40 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`mr-auto pl-1.5`,children:(0,$.jsx)(Ex,{receipt:e.deliveryReceipt??`sent`})}),(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>void h(`steer`),title:i(`queue.steerHint`),className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium hover:bg-foreground/5 disabled:opacity-40`,children:[(0,$.jsx)(Wo,{className:`h-3.5 w-3.5`}),i(`queue.steer`)]}),(0,$.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>void h(`remove`),"aria-label":i(`queue.remove`),title:i(`queue.remove`),className:`rounded-md p-1.5 hover:bg-foreground/5 hover:text-destructive disabled:opacity-40`,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`relative`,ref:f,children:[(0,$.jsx)(`button`,{type:`button`,disabled:m,"aria-label":i(`queue.more`),title:i(`queue.more`),"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),className:`rounded-md p-1.5 hover:bg-foreground/5 disabled:opacity-40`,children:(0,$.jsx)(Zo,{className:`h-3.5 w-3.5`})}),s&&!m&&(0,$.jsx)(`div`,{role:`menu`,"aria-label":i(`queue.more`),className:`absolute bottom-full right-0 z-20 mb-1 min-w-28 rounded-lg border border-border bg-card p-1 shadow-xl`,children:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,autoFocus:!0,onClick:()=>{r(e.queueId),c(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-foreground/5`,children:[(0,$.jsx)(an,{className:`h-3.5 w-3.5`}),i(`queue.edit`)]})})]})]})]})})}var Bx=(0,Q.createContext)(null);function Vx({children:e}){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=(0,Q.useCallback)(()=>n(!0),[]),g=(0,Q.useCallback)(()=>n(!1),[]),_=(0,Q.useCallback)(()=>n(e=>!e),[]),v=(0,Q.useCallback)(()=>i(!0),[]),y=(0,Q.useCallback)(()=>i(!1),[]),b=(0,Q.useCallback)(()=>i(e=>!e),[]),x=(0,Q.useCallback)(()=>o(!0),[]),S=(0,Q.useCallback)(()=>o(!1),[]),C=(0,Q.useCallback)(()=>o(e=>!e),[]),w=(0,Q.useCallback)(()=>{u(crypto.randomUUID()),c(!0)},[]),T=(0,Q.useCallback)(()=>c(!1),[]),E=(0,Q.useRef)([]),D=(0,Q.useCallback)(e=>{E.current=[...E.current,e],m(E.current)},[]),O=(0,Q.useCallback)(()=>{let e=E.current;return e.length&&(E.current=[],m([])),e},[]),k=(0,Q.useCallback)(e=>{n(e.codePaneOpen),i(e.jobsPaneOpen),o(e.analyticsPaneOpen),u(e.browserOwnerId??null),f(e.browserUrl??null),c(e.browserOpen),E.current=e.pendingCaptures,m(e.pendingCaptures)},[]),A=(0,Q.useCallback)(()=>({codePaneOpen:t,jobsPaneOpen:r,analyticsPaneOpen:a,browserOpen:s,browserOwnerId:l,browserUrl:d,pendingCaptures:E.current}),[t,r,a,s,l,d]),j=(0,Q.useMemo)(()=>({codePaneOpen:t,openCodePane:h,closeCodePane:g,toggleCodePane:_,jobsPaneOpen:r,openJobsPane:v,closeJobsPane:y,toggleJobsPane:b,analyticsPaneOpen:a,openAnalyticsPane:x,closeAnalyticsPane:S,toggleAnalyticsPane:C,browserOpen:s,openBrowser:w,closeBrowser:T,browserOwnerId:l,browserUrl:d,setBrowserUrl:f,captureWorkspace:A,restoreWorkspace:k,pendingCaptures:p,queueCapture:D,consumePendingCaptures:O}),[l,d,A,k,t,h,g,_,r,v,y,b,a,x,S,C,s,w,T,p,D,O]);return(0,$.jsx)(Bx.Provider,{value:j,children:e})}var Hx={codePaneOpen:!1,openCodePane:()=>{},closeCodePane:()=>{},toggleCodePane:()=>{},jobsPaneOpen:!1,openJobsPane:()=>{},closeJobsPane:()=>{},toggleJobsPane:()=>{},analyticsPaneOpen:!1,openAnalyticsPane:()=>{},closeAnalyticsPane:()=>{},toggleAnalyticsPane:()=>{},browserOwnerId:null,browserUrl:null,setBrowserUrl:()=>{},captureWorkspace:()=>({codePaneOpen:!1,jobsPaneOpen:!1,analyticsPaneOpen:!1,browserOpen:!1,pendingCaptures:[]}),restoreWorkspace:()=>{},browserOpen:!1,openBrowser:()=>{},closeBrowser:()=>{},pendingCaptures:[],queueCapture:()=>{},consumePendingCaptures:()=>[]};function Ux(){return(0,Q.useContext)(Bx)??Hx}var Wx=1e4;function Gx(e){return JSON.stringify([e.projectId,e.chatId,e.processId??[e.pid,e.startedAt]])}var Kx=e=>`${He}/api/projects/${encodeURIComponent(e)}/background-processes`,qx=e=>{let t=new URLSearchParams({chatId:e.chatId});return e.processId&&t.set(`processId`,e.processId),{url:`${Kx(e.projectId)}/${encodeURIComponent(String(e.pid))}`,query:t}};async function Jx(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(typeof t?.error==`string`?t.error:`HTTP ${e.status}`);return t}async function Yx(e,t={}){let n=new AbortController,r=!1,i=()=>n.abort();t.signal?.aborted?i():t.signal?.addEventListener(`abort`,i,{once:!0});let a=window.setTimeout(()=>{r=!0,i()},Wx);try{return await Jx(await fetch(e,{...t,signal:n.signal}))}catch(e){throw r?Error(`The background process request timed out. Check its status and retry.`):e}finally{window.clearTimeout(a),t.signal?.removeEventListener(`abort`,i)}}async function Xx(e,t,n){let r=new URLSearchParams({chatId:t,includeFinished:`true`}),i=await Yx(`${Kx(e)}?${r}`,{signal:n});if(!Array.isArray(i?.processes))throw Error(`Invalid background process snapshot`);return i.processes}async function Zx(e,t){let{url:n,query:r}=qx(e),i=await Yx(`${n}?${r}`,{method:`DELETE`,signal:t});if(!i?.ok)throw Error(`The server did not confirm the stop request`);if(i.process&&Gx(i.process)!==Gx(e))throw Error(`The stop response belongs to another process`);return i}async function Qx(e,t={}){let{url:n,query:r}=qx(e),i=Number.isFinite(t.limit)?t.limit:2e3;r.set(`limit`,String(Math.max(1,Math.min(2e3,Math.trunc(i)))));let a=await Yx(`${n}/logs?${r}`,{signal:t.signal});if(!a?.process||!Array.isArray(a.lines)||Gx(a.process)!==Gx(e))throw Error(`Invalid background process log snapshot`);return a}var $x=(0,Q.createContext)(null),eS=new Set([`exited`,`killed`,`failed`,`interrupted`]),tS=12e4,nS=15e3;function rS({children:e}){let{registerHandler:t,unregisterHandler:n,connectionStatus:r}=qe(),{active:i,draftPinnedProjectId:a}=lM(),{activeProjectId:o}=at(),s=i?.pinned_project_id??a??o,c=i?.id??null,[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=(0,Q.useRef)([]),g=(0,Q.useRef)(!0),_=(0,Q.useRef)(new Map),v=(0,Q.useRef)(0),y=(0,Q.useRef)(new Map),b=(0,Q.useRef)(new Map),x=(0,Q.useRef)(new Map),S=(0,Q.useRef)(new Map),C=(0,Q.useRef)(new Set),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(0),D=(0,Q.useRef)(null),O=(0,Q.useCallback)(e=>{if(!g.current)return;let t=e(h.current);h.current=t,u(t)},[]),k=(0,Q.useCallback)((e,t)=>e&&eS.has(e.status)&&!eS.has(t.status)?e:{...t,...eS.has(t.status)?{completedAt:t.endedAt??t.recoveredAt??e?.completedAt??Date.now()}:e?.stopError?{stopError:e.stopError}:{}},[]),A=(0,Q.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(![`background_process.started`,`background_process.updated`,`background_process.exited`].includes(t.type??``)||!t.process)return;let n=t.process;if(!n.projectId||!n.chatId||!Number.isFinite(n.pid)||t.projectId&&t.projectId!==n.projectId)return;let r=Gx(n),i=h.current.find(e=>Gx(e)===r);b.current.has(r)&&i?.status===`stopping`&&!eS.has(n.status)&&n.status!==`stopping`&&!n.error||(y.current.set(r,++v.current),O(e=>{let t=e.find(e=>Gx(e)===r),i=k(t,n);return t?e.map(e=>Gx(e)===r?i:e):[...e,i]}))},[O,k]);(0,Q.useEffect)(()=>(t(`background-processes`,A),()=>n(`background-processes`)),[A,t,n]);let j=(0,Q.useCallback)(async e=>{if(!s||!c)return;let t=D.current;if(t?.projectId===s&&t.chatId===c&&!t.signal?.aborted)return;let n=++E.current;D.current={projectId:s,chatId:c,signal:e,sequence:n},f(!0),m(null);let r=v.current;try{let t=await Xx(s,c,e);if(e?.aborted||n!==E.current||!g.current)return;let i=new Map(t.filter(e=>e.projectId===s&&e.chatId===c).map(e=>[Gx(e),e]));O(e=>{let t=[];for(let n of e){let e=Gx(n);if(n.projectId!==s||n.chatId!==c||(y.current.get(e)??0)>r){t.push(n),i.delete(e);continue}let a=i.get(e);a?(t.push(b.current.has(e)&&!eS.has(a.status)?n:k(n,a)),i.delete(e)):b.current.has(e)&&t.push(n)}for(let e of i.values())t.push(k(void 0,e));return t})}catch(t){!e?.aborted&&n===E.current&&g.current&&m(t instanceof Error?t.message:`Could not load process history`)}finally{D.current?.sequence===n&&(D.current=null),n===E.current&&g.current&&f(!1)}},[s,c,O,k]);(0,Q.useEffect)(()=>{let e=new AbortController;j(e.signal);let t=()=>{j(e.signal)},n=()=>{document.visibilityState===`visible`&&t()};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,n),()=>{e.abort(),E.current+=1,window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,n)}},[j,r]),(0,Q.useEffect)(()=>{for(let e of l){if(e.completedAt===void 0)continue;let t=Gx(e);if(_.current.has(t))continue;let n=Math.max(0,e.completedAt+tS-Date.now());n&&_.current.set(t,window.setTimeout(()=>{O(e=>[...e])},n))}},[l,O]),(0,Q.useEffect)(()=>(g.current=!0,()=>{g.current=!1;for(let e of _.current.values())window.clearTimeout(e);_.current.clear();for(let e of x.current.values())e.abort();x.current.clear()}),[]);let M=(0,Q.useMemo)(()=>l.filter(e=>e.projectId===s&&e.chatId===c),[l,s,c]),N=(0,Q.useMemo)(()=>M.filter(e=>e.completedAt===void 0||e.completedAt+12e4>Date.now()),[M]),P=JSON.stringify(N.filter(e=>!eS.has(e.status)&&(e.status===`stopping`||e.stopError)).map(Gx));(0,Q.useEffect)(()=>{let e=JSON.parse(P);if(!e.length)return;let t=new AbortController,n;for(let t of e)S.current.has(t)||S.current.set(t,Date.now());let r=()=>{let t=e.filter(e=>!C.current.has(e));if(!t.length)return;let r=Math.min(...t.map(e=>S.current.get(e)+nS-Date.now()));n=window.setTimeout(i,Math.max(0,Math.min(2e3,r)))},i=()=>{let n=e.filter(e=>!C.current.has(e)&&Date.now()>=S.current.get(e)+15e3);for(let e of n)C.current.add(e);n.length&&O(e=>e.map(e=>n.includes(Gx(e))&&!eS.has(e.status)?{...e,stopError:e.stopError??`The process has not confirmed that it stopped. You can retry.`}:e)),e.some(e=>!C.current.has(e))&&j(t.signal),r()};return r(),()=>{t.abort(),n!==void 0&&window.clearTimeout(n)}},[P,w,j,O]);let F=(0,Q.useCallback)(e=>{let t=typeof e==`number`?h.current.filter(t=>t.pid===e&&t.projectId===s&&t.chatId===c&&!eS.has(t.status)):[e];if(t.length!==1)return Promise.reject(Error(`The process is no longer available. Refresh its status before retrying.`));let n=t[0],r=Gx(n),i=h.current.find(e=>Gx(e)===r);if(eS.has(i?.status??n.status))return Promise.resolve();let a=b.current.get(r);if(a)return a;let o=i??n;S.current.set(r,Date.now()),C.current.delete(r),T(e=>e+1);let l=++v.current;y.current.set(r,l),O(e=>e.map(e=>Gx(e)===r?{...e,status:`stopping`,stopError:void 0}:e));let u=new AbortController;x.current.set(r,u);let d=(async()=>{try{let e=await Zx(n,u.signal);if(!g.current||(y.current.get(r)??0)>l)return;y.current.set(r,++v.current),e.process&&O(t=>t.map(t=>Gx(t)===r?k(t,e.process):t))}catch(e){let t=u.signal.aborted?Error(`The stop request could not be confirmed. Check its status and retry.`):e;if(g.current){let e=(y.current.get(r)??0)>l;y.current.set(r,++v.current),O(n=>n.map(n=>Gx(n)!==r||eS.has(n.status)?n:{...n,status:e?n.status:o.status,stopError:t instanceof Error?t.message:`Could not stop the process`}))}throw t}finally{x.current.delete(r),b.current.delete(r)}})();return b.current.set(r,d),d},[s,c,O,k]),I=(0,Q.useMemo)(()=>({processes:N,history:M,historyLoading:!!s&&!!c&&d,historyError:s&&c?p:null,refreshHistory:j,kill:F}),[N,M,d,p,s,c,j,F]);return(0,$.jsx)($x.Provider,{value:I,children:e})}function iS(){return(0,Q.useContext)($x)??{processes:[],history:[],historyLoading:!1,historyError:null,refreshHistory:async()=>void 0,kill:async()=>void 0}}function aS(e){return e.mimeType.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.filename)}function oS({conversationId:e,attachment:t,removeLabel:n,onRemove:r}){let i=aS(t)&&e!==null,[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(!i||!e)return;let n=!1,r=null;return Ya(e,t.id).then(e=>{n||(r=URL.createObjectURL(e),o(r))}).catch(()=>{n||c(!0)}),()=>{n=!0,r&&URL.revokeObjectURL(r)}},[i,e,t.id]),i&&!s?(0,$.jsxs)(`span`,{className:`group relative inline-flex h-14 w-14 shrink-0 overflow-hidden rounded-lg border border-border/60 bg-surface/70`,title:t.filename,"data-testid":`composer-attachment-thumb`,children:[a?(0,$.jsx)(`img`,{src:a,alt:t.filename,className:`h-full w-full object-cover`}):(0,$.jsx)(`span`,{className:`flex h-full w-full items-center justify-center`,children:(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-foreground/40`})}),(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":n,className:`absolute right-0.5 top-0.5 rounded-full bg-black/60 p-0.5 text-white opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100`,children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[11px] text-foreground/80`,"data-testid":`composer-attachment-pill`,children:[(0,$.jsx)(Rs,{className:`h-3 w-3 text-accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:t.filename}),(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":n,className:`rounded-sm hover:bg-muted`,children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]})}function sS(e,t){return t.map(t=>({id:`file:${e.id}:${t.repositoryId}:${t.path}`,mode:`reference`,title:t.path,subtitle:t.repositoryName,group:`Files`,icon:`file`,keywords:[t.path,t.repositoryName],chip:{kind:`file`,id:t.path,label:`${t.repositoryName} · ${t.path}`,token:`@${t.repositoryName}/${t.path}`,projectId:e.id,projectName:e.name,repositoryId:t.repositoryId,repositoryName:t.repositoryName,metadata:{path:t.path}}}))}var cS=new Set([`@`,`#`,`/`]),lS=/[\s()[\]{}<>"']/;function uS(e,t=e.length){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(r===`
33
+ `||r===` `||r===` `)break;if(!cS.has(r))continue;let i=t===0?``:e[t-1];if(i&&!lS.test(i))continue;let a=e.slice(t+1,n);if(/[()[\]{}<>"']/.test(a))return null;let o=r;return{trigger:o,mode:o===`@`?`reference`:o===`#`?`trace`:`action`,query:a,start:t,end:n}}return null}function dS(e){return`${e.kind}:${e.repositoryId?`${e.repositoryId}:`:``}${e.id}`}function fS(e){return{kind:e.kind,id:e.id,label:e.label,token:e.token,scope:{projectId:e.projectId??null,projectName:e.projectName??null,...e.repositoryId?{repositoryId:e.repositoryId,repositoryName:e.repositoryName}:{}},status:e.status??null,metadata:e.metadata}}function pS(e,t){return t?e.find(e=>e.id===t)?.name??null:null}function mS(e){return{kind:`project`,id:e.id,label:e.name,token:`@${e.name}`,detail:e.path,projectId:e.id,projectName:e.name,metadata:{slug:e.slug,path:e.path}}}function hS(e,t,n){return{kind:`spec`,id:String(e.id),label:e.title,token:`@${e.title}`,detail:n?`${n} / #${e.id}`:`#${e.id}`,status:e.status,projectId:t,projectName:n,metadata:{ticketId:e.id,priority:e.priority,labels:e.labels,shortSummary:e.short_summary??null}}}function gS(e,t,n){let r=e.id.slice(0,8);return{kind:`job`,id:e.id,label:r,token:`#${r}`,detail:n?`${n} / ${e.command}`:e.command,status:e.status,projectId:t,projectName:n,metadata:{command:e.command,startedAt:e.started_at,costUsd:e.total_cost_usd??null}}}function _S(e,t){let n=e.title||`Untitled mission`;return{kind:`conversation`,id:e.id,label:n,token:`@${n}`,detail:t?`Mission / ${t}`:`Mission`,projectId:e.pinned_project_id,projectName:t,metadata:{provider:e.provider}}}function vS(e,t){let n=t.trim().toLowerCase();return!n||[e.title,e.subtitle,e.detail,e.group,...e.keywords??[]].filter(Boolean).join(` `).toLowerCase().includes(n)}function yS(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 bS(e,t){let n=yS(e).filter(e=>vS(e,t)),r=`#${t.trim()}`,i=e=>e.mode===`trace`&&e.icon===`spec`&&e.title===r;return n.sort((e,t)=>Number(i(t))-Number(i(e))).slice(0,12)}function xS(e){let t=pS(e.projects,e.pinnedProjectId),n=e.pinnedProjectId?e.projects.find(t=>t.id===e.pinnedProjectId)??null:null,r=[];if(n&&r.push({id:`alias:current-project:${n.id}`,mode:`reference`,title:`@current`,subtitle:n.name,detail:`Pinned project`,group:`Current`,icon:`alias`,chip:{...mS(n),kind:`alias`,id:`current:${n.id}`,token:`@current`},keywords:[`this`,`project`,n.name]}),e.activeConversation){let n=_S(e.activeConversation,t);r.push({id:`conversation:${e.activeConversation.id}`,mode:`reference`,title:n.label,subtitle:n.detail,detail:`Current mission`,group:`Created here`,icon:`conversation`,chip:n,keywords:[`mission`,`conversation`,`last`]})}for(let t of e.chips)r.push({id:`chip:${dS(t)}`,mode:`reference`,title:t.label,subtitle:t.detail,detail:`Already in context`,group:`Current context`,icon:t.kind,chip:t});let i=e.tickets.map(n=>{let r=hS(n,e.pinnedProjectId,t),i=n.status===`on_review`||n.status===`in_progress`||n.status===`draft`;return{id:`spec:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:n.title,subtitle:`Spec #${n.id}${n.status?` · ${n.status}`:``}`,detail:r.detail,group:i?`Active in project`:`Specs`,icon:`spec`,chip:r,keywords:[String(n.id),n.priority??``,...n.labels??[]]}});r.push(...i);let a=e.jobs.slice(0,8).map(n=>{let r=gS(n,e.pinnedProjectId,t);return{id:`job:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:r.label,subtitle:`Job · ${n.status}`,detail:n.command,group:n.status===`running`||n.status===`failed`?`Needs attention`:`Recent jobs`,icon:`job`,chip:r,keywords:[n.id,n.command,n.status]}});r.push(...a);for(let t of e.projects){let n=mS(t);r.push({id:`project:${t.id}`,mode:`reference`,title:t.name,subtitle:`Project`,detail:t.path,group:t.id===e.activeProjectId?`Current app project`:`Projects`,icon:`project`,chip:n,keywords:[t.slug,t.path]})}return r}function SS(e){let t=pS(e.projects,e.pinnedProjectId),n=[];for(let r of[...e.tickets].sort((e,t)=>e.id-t.id)){let i=hS(r,e.pinnedProjectId,t);n.push({id:`trace:spec:${r.id}`,mode:`trace`,title:`#${r.id}`,subtitle:`${r.title} · ${r.status}`,detail:t??void 0,group:`Specs`,icon:`spec`,chip:{...i,kind:`trace`,token:`#${r.id}`},keywords:[String(r.id),r.title,r.status]})}for(let r of e.jobs){let i=gS(r,e.pinnedProjectId,t);n.push({id:`trace:job:${r.id}`,mode:`trace`,title:i.label,subtitle:`${r.status} · ${r.command}`,detail:t??void 0,group:r.status===`failed`||r.status===`running`?`Active traces`:`Recent traces`,icon:`job`,chip:{...i,kind:`trace`},keywords:[r.id,r.command,r.status,`failed`,`running`,`deploy`,`run`]})}return n}var CS=[{id:`action:create-spec`,mode:`action`,title:`Create spec`,subtitle:`Turn this into a structured spec`,group:`Create`,icon:`action`,insertText:`/create spec`,tierLevel:2,risk:`cost`,keywords:[`new ticket quick add`]},{id:`action:explore-spec`,mode:`action`,title:`Explore spec`,subtitle:`Refine a fuzzy idea first`,group:`Refine`,icon:`action`,insertText:`/explore spec`,tierLevel:2,risk:`cost`,keywords:[`discovery draft requirements`]},{id:`action:update-spec`,mode:`action`,title:`Update spec`,subtitle:`Edit the selected spec`,group:`Refine`,icon:`action`,insertText:`/update spec`,tierLevel:1,keywords:[`edit ticket`]},{id:`action:assign-rail`,mode:`action`,title:`Assign to rail`,subtitle:`Put selected specs on a rail`,group:`Execute`,icon:`action`,insertText:`/assign to rail`,tierLevel:1,keywords:[`tickets rail`]},{id:`action:launch-rail`,mode:`action`,title:`Launch rail`,subtitle:`Run the selected rail or spec`,group:`Execute`,icon:`action`,insertText:`/launch rail`,tierLevel:2,risk:`cost`,keywords:[`run implement`]},{id:`action:launch-all`,mode:`action`,title:`Launch all eligible rails`,subtitle:`Start every ready rail in parallel`,group:`Execute`,icon:`action`,insertText:`/launch all eligible rails`,tierLevel:2,risk:`cost`,keywords:[`all rails run`]},{id:`action:status`,mode:`action`,title:`Show status`,subtitle:`Summarize the current workbench`,group:`Review`,icon:`action`,insertText:`/status`,tierLevel:0,keywords:[`state overview`]},{id:`action:diagnose`,mode:`action`,title:`Diagnose`,subtitle:`Inspect git, jobs, setup, Jira, and failures`,group:`Review`,icon:`action`,insertText:`/diagnose`,tierLevel:0,keywords:[`debug health failed`]},{id:`action:compare`,mode:`action`,title:`Compare`,subtitle:`Compare selected specs, jobs, diffs, or costs`,group:`Review`,icon:`action`,insertText:`/compare`,tierLevel:0,keywords:[`diff versus`]},{id:`action:summarize`,mode:`action`,title:`Summarize`,subtitle:`Condense selected context`,group:`Review`,icon:`action`,insertText:`/summarize`,tierLevel:0,keywords:[`recap`]},{id:`action:save-as-spec`,mode:`action`,title:`Save as spec`,subtitle:`Capture the selected context as durable work`,group:`Create`,icon:`action`,insertText:`/save as spec`,tierLevel:1,keywords:[`persist capture`]},{id:`action:generate-report`,mode:`action`,title:`Generate report`,subtitle:`Create a written artifact from selected context`,group:`Create`,icon:`action`,insertText:`/generate report`,tierLevel:1,keywords:[`document export`]},{id:`action:show-spend`,mode:`action`,title:`Show spend`,subtitle:`Review cost and budget impact`,group:`Review`,icon:`action`,insertText:`/show spend`,tierLevel:0,keywords:[`cost budget analytics`]},{id:`action:search`,mode:`action`,title:`Search current project`,subtitle:`Find specs, jobs, files, or context`,group:`Navigate`,icon:`action`,insertText:`/search`,tierLevel:0,keywords:[`find`]},{id:`action:search-all`,mode:`action`,title:`Search all projects`,subtitle:`Fan out across registered projects`,group:`Navigate`,icon:`action`,insertText:`/search all projects`,tierLevel:0,keywords:[`global home`]},{id:`action:open`,mode:`action`,title:`Open item`,subtitle:`Open the selected object in Specrails`,group:`Navigate`,icon:`action`,insertText:`/open`,tierLevel:0,keywords:[`navigate`]},{id:`action:wait`,mode:`action`,title:`Wait for result`,subtitle:`Follow a running job or trace`,group:`Review`,icon:`action`,insertText:`/wait for result`,tierLevel:0,keywords:[`watch running`]},{id:`action:show-diff`,mode:`action`,title:`Show diff`,subtitle:`Inspect changes from the selected job`,group:`Review`,icon:`action`,insertText:`/show diff`,tierLevel:0,keywords:[`files changes`]},{id:`action:diagnostic`,mode:`action`,title:`Export diagnostic`,subtitle:`Collect job telemetry and logs`,group:`Review`,icon:`action`,insertText:`/export diagnostic`,tierLevel:0,keywords:[`zip logs telemetry`]},{id:`action:cancel-job`,mode:`action`,title:`Cancel job`,subtitle:`Stop or delete a selected job`,group:`Clean up`,icon:`action`,insertText:`/cancel job`,tierLevel:3,risk:`destructive`,keywords:[`stop kill`]},{id:`action:refine-contract`,mode:`action`,title:`Refine contract`,subtitle:`Add or refresh the Contract Layer`,group:`Refine`,icon:`action`,insertText:`/refine contract`,tierLevel:2,risk:`cost`,keywords:[`contract`]},{id:`action:split-epic`,mode:`action`,title:`Split epic`,subtitle:`Decompose a large spec into children`,group:`Refine`,icon:`action`,insertText:`/split epic`,tierLevel:2,risk:`cost`,keywords:[`smash children`]},{id:`action:files-touched`,mode:`action`,title:`Show files touched`,subtitle:`Inspect provenance for selected work`,group:`Review`,icon:`action`,insertText:`/show files touched`,tierLevel:0,keywords:[`provenance`]},{id:`action:connect-jira`,mode:`action`,title:`Connect Jira`,subtitle:`Start the Jira connection flow`,group:`Integrate`,icon:`action`,insertText:`/connect Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:sync-jira`,mode:`action`,title:`Sync Jira`,subtitle:`Refresh Jira-backed specs`,group:`Integrate`,icon:`action`,insertText:`/sync Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:install-plugin`,mode:`action`,title:`Install plugin`,subtitle:`Preview and install an integration`,group:`Integrate`,icon:`action`,insertText:`/install plugin`,tierLevel:1,keywords:[`mcp integration`]},{id:`action:set-budget`,mode:`action`,title:`Set budget`,subtitle:`Adjust spend guardrails`,group:`Configure`,icon:`action`,insertText:`/set budget`,tierLevel:1,keywords:[`cost limit`]}];function wS(e,t,n){let r=new Set(t.map(e=>e.kind)),i=0;return t.length===0&&([`action:create-spec`,`action:search`,`action:status`,`action:diagnose`,`action:show-spend`].includes(e.id)&&(i+=40),n.pinnedProjectId&&e.id===`action:launch-all`&&(i+=30)),r.has(`project`)&&[`action:status`,`action:search`,`action:launch-all`,`action:show-spend`,`action:sync-jira`,`action:install-plugin`].includes(e.id)&&(i+=50),r.has(`spec`)&&[`action:update-spec`,`action:assign-rail`,`action:launch-rail`,`action:refine-contract`,`action:split-epic`,`action:files-touched`,`action:show-spend`].includes(e.id)&&(i+=70),(r.has(`job`)||r.has(`trace`))&&[`action:open`,`action:wait`,`action:compare`,`action:show-diff`,`action:diagnostic`,`action:cancel-job`].includes(e.id)&&(i+=80),r.has(`file`)&&[`action:summarize`,`action:show-diff`,`action:files-touched`].includes(e.id)&&(i+=60),i}function TS(e){return[...CS].sort((t,n)=>wS(n,e.chips,e)-wS(t,e.chips,e)).map(e=>({...e,chip:{kind:`action`,id:e.id,label:e.title,token:e.insertText??`/${e.title.toLowerCase()}`,detail:e.subtitle,metadata:{tierLevel:e.tierLevel,risk:e.risk??null}}}))}function ES(e,t){return e===`reference`?xS(t):e===`trace`?SS(t):TS(t)}function DS(e,t){let n=t.trim();if(!n)return[];let r=n.slice(0,80),i=[{id:`fallback:search-all:${e}:${r}`,mode:e,title:`Search all Specrails`,subtitle:`Find "${r}" across every project`,group:`No matches`,icon:`action`,insertText:`/search all projects ${r}`,tierLevel:0,keywords:[`fallback global search all`]},{id:`fallback:ask-agent:${e}:${r}`,mode:e,title:`Ask agent about "${r}"`,subtitle:`Keep the wording and let the agent resolve it`,group:`No matches`,icon:`action`,insertText:r,tierLevel:0,keywords:[`fallback ask agent clarify`]}];return e===`trace`?i.splice(1,0,{id:`fallback:archived:${e}:${r}`,mode:e,title:`Include archived results`,subtitle:`Search completed, canceled, and old traces for "${r}"`,group:`No matches`,icon:`action`,insertText:`/search all projects archived ${r}`,tierLevel:0,keywords:[`fallback archived old completed canceled`]}):i.splice(1,0,{id:`fallback:create-spec:${e}:${r}`,mode:e,title:`Create "${r}"`,subtitle:`Turn this unmatched reference into a spec`,group:`No matches`,icon:`action`,insertText:`/create spec ${r}`,tierLevel:2,risk:`cost`,keywords:[`fallback create new spec`]}),i}function OS(e,t,n){let r=n.insertText??n.chip?.token??n.title,i=t?.start??e.length,a=t?.end??e.length,o=e.slice(0,i),s=e.slice(a),c=o&&!/\s$/.test(o)?` `:``,l=s&&!/^\s/.test(s)?` `:``;return{text:`${o}${c}${r}${l}${s}`,caret:o.length+c.length+r.length+l.length}}function kS(e,[t,n]){return Math.min(n,Math.max(t,e))}function AS(e){let t=jS(e),n=Q.forwardRef((e,n)=>{let{children:r,...i}=e,a=Q.Children.toArray(r),o=a.find(NS);if(o){let e=o.props.children,r=a.map(t=>t===o?Q.Children.count(e)>1?Q.Children.only(null):Q.isValidElement(e)?e.props.children:null:t);return(0,$.jsx)(t,{...i,ref:n,children:Q.isValidElement(e)?Q.cloneElement(e,void 0,r):null})}return(0,$.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function jS(e){let t=Q.forwardRef((e,t)=>{let{children:n,...r}=e;if(Q.isValidElement(n)){let e=FS(n),i=PS(r,n.props);return n.type!==Q.Fragment&&(i.ref=t?Pn(t,e):e),Q.cloneElement(n,i)}return Q.Children.count(n)>1?Q.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var MS=Symbol(`radix.slottable`);function NS(e){return Q.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===MS}function PS(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function FS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function IS(e){let t=e+`CollectionProvider`,[n,r]=vn(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Q.useRef(null),a=Q.useRef(new Map).current;return(0,$.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=AS(s),l=Q.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=gn(t,a(s,n).collectionRef);return(0,$.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=AS(u),p=Q.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Q.useRef(null),s=gn(t,o),c=a(u,n);return Q.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,$.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return Q.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var LS=Q.createContext(void 0);function RS(e){let t=Q.useContext(LS);return e||t||`ltr`}var zS=[`top`,`right`,`bottom`,`left`],BS=Math.min,VS=Math.max,HS=Math.round,US=Math.floor,WS=e=>({x:e,y:e}),GS={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function KS(e,t,n){return VS(e,BS(t,n))}function qS(e,t){return typeof e==`function`?e(t):e}function JS(e){return e.split(`-`)[0]}function YS(e){return e.split(`-`)[1]}function XS(e){return e===`x`?`y`:`x`}function ZS(e){return e===`y`?`height`:`width`}function QS(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function $S(e){return XS(QS(e))}function eC(e,t,n){n===void 0&&(n=!1);let r=YS(e),i=$S(e),a=ZS(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=lC(o)),[o,lC(o)]}function tC(e){let t=lC(e);return[nC(e),t,nC(t)]}function nC(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var rC=[`left`,`right`],iC=[`right`,`left`],aC=[`top`,`bottom`],oC=[`bottom`,`top`];function sC(e,t,n){switch(e){case`top`:case`bottom`:return n?t?iC:rC:t?rC:iC;case`left`:case`right`:return t?aC:oC;default:return[]}}function cC(e,t,n,r){let i=YS(e),a=sC(JS(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(nC)))),a}function lC(e){let t=JS(e);return GS[t]+e.slice(t.length)}function uC(e){return{top:0,right:0,bottom:0,left:0,...e}}function dC(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:uC(e)}function fC(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function pC(e,t,n){let{reference:r,floating:i}=e,a=QS(t),o=$S(t),s=ZS(o),c=JS(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(YS(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function mC(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=qS(t,e),p=dC(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=fC(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=fC(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var hC=50,gC=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:mC},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=pC(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<hC&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=pC(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},_C=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=qS(e,t)||{};if(l==null)return{};let d=dC(u),f={x:n,y:r},p=$S(i),m=ZS(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=BS(d[_],T),D=BS(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=KS(O,A,k),M=!c.arrow&&YS(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),vC=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=qS(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=JS(r),_=QS(o),v=JS(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[lC(o)]:tC(o)),x=p!==`none`;!d&&x&&b.push(...cC(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=eC(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==QS(t))||T.every(e=>QS(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=QS(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function yC(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bC(e){return zS.some(t=>e[t]>=0)}var xC=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=qS(e,t);switch(i){case`referenceHidden`:{let e=yC(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:bC(e)}}}case`escaped`:{let e=yC(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:bC(e)}}}default:return{}}}}},SC=new Set([`left`,`top`]);async function CC(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=JS(n),s=YS(n),c=QS(n)===`y`,l=SC.has(o)?-1:1,u=a&&c?-1:1,d=qS(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var wC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await CC(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},TC=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=qS(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=QS(JS(i)),p=XS(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=KS(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=KS(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},EC=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=qS(e,t),u={x:n,y:r},d=QS(i),f=XS(d),p=u[f],m=u[d],h=qS(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=SC.has(JS(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},DC=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=qS(e,t),u=await o.detectOverflow(t,l),d=JS(i),f=YS(i),p=QS(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=BS(h-u[g],v),x=BS(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=VS(u.left,0),t=VS(u.right,0),n=VS(u.top,0),r=VS(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:VS(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:VS(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function OC(){return typeof window<`u`}function kC(e){return MC(e)?(e.nodeName||``).toLowerCase():`#document`}function AC(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jC(e){return((MC(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function MC(e){return OC()?e instanceof Node||e instanceof AC(e).Node:!1}function NC(e){return OC()?e instanceof Element||e instanceof AC(e).Element:!1}function PC(e){return OC()?e instanceof HTMLElement||e instanceof AC(e).HTMLElement:!1}function FC(e){return!OC()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof AC(e).ShadowRoot}function IC(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=qC(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function LC(e){return/^(table|td|th)$/.test(kC(e))}function RC(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var zC=/transform|translate|scale|rotate|perspective|filter/,BC=/paint|layout|strict|content/,VC=e=>!!e&&e!==`none`,HC;function UC(e){let t=NC(e)?qC(e):e;return VC(t.transform)||VC(t.translate)||VC(t.scale)||VC(t.rotate)||VC(t.perspective)||!GC()&&(VC(t.backdropFilter)||VC(t.filter))||zC.test(t.willChange||``)||BC.test(t.contain||``)}function WC(e){let t=YC(e);for(;PC(t)&&!KC(t);){if(UC(t))return t;if(RC(t))return null;t=YC(t)}return null}function GC(){return HC??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),HC}function KC(e){return/^(html|body|#document)$/.test(kC(e))}function qC(e){return AC(e).getComputedStyle(e)}function JC(e){return NC(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function YC(e){if(kC(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||FC(e)&&e.host||jC(e);return FC(t)?t.host:t}function XC(e){let t=YC(e);return KC(t)?e.ownerDocument?e.ownerDocument.body:e.body:PC(t)&&IC(t)?t:XC(t)}function ZC(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=XC(e),i=r===e.ownerDocument?.body,a=AC(r);if(i){let e=QC(a);return t.concat(a,a.visualViewport||[],IC(r)?r:[],e&&n?ZC(e):[])}else return t.concat(r,ZC(r,[],n))}function QC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $C(e){let t=qC(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=PC(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=HS(n)!==a||HS(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ew(e){return NC(e)?e:e.contextElement}function tw(e){let t=ew(e);if(!PC(t))return WS(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=$C(t),o=(a?HS(n.width):n.width)/r,s=(a?HS(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var nw=WS(0);function rw(e){let t=AC(e);return!GC()||!t.visualViewport?nw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function iw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==AC(e)?!1:t}function aw(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ew(e),o=WS(1);t&&(r?NC(r)&&(o=tw(r)):o=tw(e));let s=iw(a,n,r)?rw(a):WS(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=AC(a),t=r&&NC(r)?AC(r):r,n=e,i=QC(n);for(;i&&r&&t!==n;){let e=tw(i),t=i.getBoundingClientRect(),r=qC(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=AC(i),i=QC(n)}}return fC({width:u,height:d,x:c,y:l})}function ow(e,t){let n=JC(e).scrollLeft;return t?t.left+n:aw(jC(e)).left+n}function sw(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ow(e,n),y:n.top+t.scrollTop}}function cw(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=jC(r),s=t?RC(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=WS(1),u=WS(0),d=PC(r);if((d||!d&&!a)&&((kC(r)!==`body`||IC(o))&&(c=JC(r)),d)){let e=aw(r);l=tw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?sw(o,c):WS(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function lw(e){return Array.from(e.getClientRects())}function uw(e){let t=jC(e),n=JC(e),r=e.ownerDocument.body,i=VS(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=VS(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+ow(e),s=-n.scrollTop;return qC(r).direction===`rtl`&&(o+=VS(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var dw=25;function fw(e,t){let n=AC(e),r=jC(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=GC();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=ow(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=dw&&(a-=o)}else l<=dw&&(a+=l);return{width:a,height:o,x:s,y:c}}function pw(e,t){let n=aw(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=PC(e)?tw(e):WS(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function mw(e,t,n){let r;if(t===`viewport`)r=fw(e,n);else if(t===`document`)r=uw(jC(e));else if(NC(t))r=pw(t,n);else{let n=rw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return fC(r)}function hw(e,t){let n=YC(e);return n===t||!NC(n)||KC(n)?!1:qC(n).position===`fixed`||hw(n,t)}function gw(e,t){let n=t.get(e);if(n)return n;let r=ZC(e,[],!1).filter(e=>NC(e)&&kC(e)!==`body`),i=null,a=qC(e).position===`fixed`,o=a?YC(e):e;for(;NC(o)&&!KC(o);){let t=qC(o),n=UC(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||IC(o)&&!n&&hw(e,o))?r=r.filter(e=>e!==o):i=t,o=YC(o)}return t.set(e,r),r}function _w(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?RC(t)?[]:gw(t,this._c):[].concat(n),r],o=mw(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=mw(t,a[e],i);s=VS(n.top,s),c=BS(n.right,c),l=BS(n.bottom,l),u=VS(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function vw(e){let{width:t,height:n}=$C(e);return{width:t,height:n}}function yw(e,t,n){let r=PC(t),i=jC(t),a=n===`fixed`,o=aw(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=WS(0);function l(){c.x=ow(i)}if(r||!r&&!a)if((kC(t)!==`body`||IC(i))&&(s=JC(t)),r){let e=aw(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?sw(i,s):WS(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function bw(e){return qC(e).position===`static`}function xw(e,t){if(!PC(e)||qC(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return jC(e)===n&&(n=n.ownerDocument.body),n}function Sw(e,t){let n=AC(e);if(RC(e))return n;if(!PC(e)){let t=YC(e);for(;t&&!KC(t);){if(NC(t)&&!bw(t))return t;t=YC(t)}return n}let r=xw(e,t);for(;r&&LC(r)&&bw(r);)r=xw(r,t);return r&&KC(r)&&bw(r)&&!UC(r)?n:r||WC(e)||n}var Cw=async function(e){let t=this.getOffsetParent||Sw,n=this.getDimensions,r=await n(e.floating);return{reference:yw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ww(e){return qC(e).direction===`rtl`}var Tw={convertOffsetParentRelativeRectToViewportRelativeRect:cw,getDocumentElement:jC,getClippingRect:_w,getOffsetParent:Sw,getElementRects:Cw,getClientRects:lw,getDimensions:vw,getScale:tw,isElement:NC,isRTL:ww};function Ew(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dw(e,t){let n=null,r,i=jC(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=US(d),h=US(i.clientWidth-(u+f)),g=US(i.clientHeight-(d+p)),_=US(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:VS(0,BS(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Ew(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Ow(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=ew(e),u=i||a?[...l?ZC(l):[],...t?ZC(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dw(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?aw(e):null;c&&g();function g(){let t=aw(e);h&&!Ew(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var kw=wC,Aw=TC,jw=vC,Mw=DC,Nw=xC,Pw=_C,Fw=EC,Iw=(e,t,n)=>{let r=new Map,i={platform:Tw,...n},a={...i.platform,_c:r};return gC(e,t,{...i,platform:a})},Lw=typeof document<`u`?Q.useLayoutEffect:function(){};function Rw(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Rw(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Rw(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zw(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bw(e,t){let n=zw(e);return Math.round(t*n)/n}function Vw(e){let t=Q.useRef(e);return Lw(()=>{t.current=e}),t}function Hw(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Q.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Q.useState(r);Rw(f,r)||p(r);let[m,h]=Q.useState(null),[g,_]=Q.useState(null),v=Q.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Q.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(u),T=c!=null,E=Vw(c),D=Vw(i),O=Vw(l),k=Q.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Iw(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Rw(w.current,t)&&(w.current=t,xb.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Lw(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Q.useRef(!1);Lw(()=>(A.current=!0,()=>{A.current=!1}),[]),Lw(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Q.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Q.useMemo(()=>({reference:b,floating:x}),[b,x]),N=Q.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Bw(M.floating,u.x),r=Bw(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zw(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Q.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Uw=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Pw({element:r.current,padding:i}).fn(n):r?Pw({element:r,padding:i}).fn(n):{}}}},Ww=(e,t)=>{let n=kw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gw=(e,t)=>{let n=Aw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kw=(e,t)=>({fn:Fw(e).fn,options:[e,t]}),qw=(e,t)=>{let n=jw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jw=(e,t)=>{let n=Mw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yw=(e,t)=>{let n=Nw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xw=(e,t)=>{let n=Uw(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zw=`Arrow`,Qw=Q.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(_n.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Qw.displayName=Zw;var $w=Qw;function eT(e){let[t,n]=Q.useState(void 0);return yn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var tT=`Popper`,[nT,rT]=vn(tT),[iT,aT]=nT(tT),oT=e=>{let{__scopePopper:t,children:n}=e,[r,i]=Q.useState(null);return(0,$.jsx)(iT,{scope:t,anchor:r,onAnchorChange:i,children:n})};oT.displayName=tT;var sT=`PopperAnchor`,cT=Q.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=aT(sT,n),o=Q.useRef(null),s=gn(t,o),c=Q.useRef(null);return Q.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,$.jsx)(_n.div,{...i,ref:s})});cT.displayName=sT;var lT=`PopperContent`,[uT,dT]=nT(lT),fT=Q.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=aT(lT,n),[_,v]=Q.useState(null),y=gn(t,e=>v(e)),[b,x]=Q.useState(null),S=eT(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(gT),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=Hw({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Ow(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Ww({mainAxis:i+w,alignmentAxis:o}),c&&Gw({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Kw():void 0,...k}),c&&qw({...k}),Jw({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&Xw({element:b,padding:s}),_T({arrowWidth:C,arrowHeight:w}),f&&Yw({strategy:`referenceHidden`,...k})]}),[F,I]=vT(M),L=Sn(m);yn(()=>{N&&L?.()},[N,L]);let R=P.arrow?.x,z=P.arrow?.y,B=P.arrow?.centerOffset!==0,[ee,V]=Q.useState();return yn(()=>{_&&V(window.getComputedStyle(_).zIndex)},[_]),(0,$.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ee,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(uT,{scope:n,placedSide:F,onArrowChange:x,arrowX:R,arrowY:z,shouldHideArrow:B,children:(0,$.jsx)(_n.div,{"data-side":F,"data-align":I,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});fT.displayName=lT;var pT=`PopperArrow`,mT={top:`bottom`,right:`left`,bottom:`top`,left:`right`},hT=Q.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=dT(pT,n),a=mT[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)($w,{...r,ref:t,style:{...r.style,display:`block`}})})});hT.displayName=pT;function gT(e){return e!==null}var _T=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=vT(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function vT(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var yT=oT,bT=cT,xT=fT,ST=hT;function CT(e){let t=wT(e),n=Q.forwardRef((e,n)=>{let{children:r,...i}=e,a=Q.Children.toArray(r),o=a.find(ET);if(o){let e=o.props.children,r=a.map(t=>t===o?Q.Children.count(e)>1?Q.Children.only(null):Q.isValidElement(e)?e.props.children:null:t);return(0,$.jsx)(t,{...i,ref:n,children:Q.isValidElement(e)?Q.cloneElement(e,void 0,r):null})}return(0,$.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function wT(e){let t=Q.forwardRef((e,t)=>{let{children:n,...r}=e;if(Q.isValidElement(n)){let e=OT(n),i=DT(r,n.props);return n.type!==Q.Fragment&&(i.ref=t?Pn(t,e):e),Q.cloneElement(n,i)}return Q.Children.count(n)>1?Q.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var TT=Symbol(`radix.slottable`);function ET(e){return Q.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===TT}function DT(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function OT(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function kT(e){let t=Q.useRef({value:e,previous:e});return Q.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var AT=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),jT=`VisuallyHidden`,MT=Q.forwardRef((e,t)=>(0,$.jsx)(_n.span,{...e,ref:t,style:{...AT,...e.style}}));MT.displayName=jT;var NT=MT,PT=[` `,`Enter`,`ArrowUp`,`ArrowDown`],FT=[` `,`Enter`],IT=`Select`,[LT,RT,zT]=IS(IT),[BT,VT]=vn(IT,[zT,rT]),HT=rT(),[UT,WT]=BT(IT),[GT,KT]=BT(IT),qT=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=HT(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=RS(l),[C,w]=Gn({prop:r,defaultProp:i??!1,onChange:a,caller:IT}),[T,E]=Gn({prop:o,defaultProp:s,onChange:c,caller:IT}),D=Q.useRef(null),O=!g||m||!!g.closest(`form`),[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,$.jsx)(yT,{...h,children:(0,$.jsxs)(UT,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Cn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,$.jsx)(LT.Provider,{scope:t,children:(0,$.jsx)(GT,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,$.jsxs)(HE,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,$.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};qT.displayName=IT;var JT=`SelectTrigger`,YT=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=HT(n),o=WT(JT,n),s=o.disabled||r,c=gn(t,o.onTriggerChange),l=RT(n),u=Q.useRef(`touch`),[d,f,p]=WE(e=>{let t=l().filter(e=>!e.disabled),n=GE(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,$.jsx)(bT,{asChild:!0,...a,children:(0,$.jsx)(_n.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":UE(o.value)?``:void 0,...i,ref:c,onClick:xn(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:xn(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:xn(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&PT.includes(e.key)&&(m(),e.preventDefault())})})})});YT.displayName=JT;var XT=`SelectValue`,ZT=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=WT(XT,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=gn(t,c.onValueNodeChange);return yn(()=>{l(u)},[l,u]),(0,$.jsx)(_n.span,{...s,ref:d,style:{pointerEvents:`none`},children:UE(c.value)?(0,$.jsx)($.Fragment,{children:o}):a})});ZT.displayName=XT;var QT=`SelectIcon`,$T=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,$.jsx)(_n.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});$T.displayName=QT;var eE=`SelectPortal`,tE=e=>(0,$.jsx)(qn,{asChild:!0,...e});tE.displayName=eE;var nE=`SelectContent`,rE=Q.forwardRef((e,t)=>{let n=WT(nE,e.__scopeSelect),[r,i]=Q.useState();if(yn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?xb.createPortal((0,$.jsx)(aE,{scope:e.__scopeSelect,children:(0,$.jsx)(LT.Slot,{scope:e.__scopeSelect,children:(0,$.jsx)(`div`,{children:e.children})})}),t):null}return(0,$.jsx)(lE,{...e,ref:t})});rE.displayName=nE;var iE=10,[aE,oE]=BT(nE),sE=`SelectContentImpl`,cE=CT(`SelectContent.RemoveScroll`),lE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=WT(nE,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=gn(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=RT(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return jn(y)},[y]),wn();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=WE(e=>{let t=O().filter(e=>!e.disabled),n=GE(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),z=Q.useCallback(()=>y?.focus(),[y]),B=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ee=r===`popper`?pE:dE,V=ee===pE?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,$.jsx)(aE,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:z,itemTextRefCallback:B,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,$.jsx)(An,{as:cE,allowPinchZoom:!0,children:(0,$.jsx)(En,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:xn(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,$.jsx)(Kn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,$.jsx)(ee,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...V,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:xn(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&L(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});lE.displayName=sE;var uE=`SelectItemAlignedPosition`,dE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=WT(nE,n),o=oE(nE,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=gn(t,e=>u(e)),f=RT(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-iE,d=kS(a,[iE,Math.max(iE,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-iE,d=kS(a,[iE,Math.max(iE,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-iE*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-iE,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${iE}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);yn(()=>y(),[y]);let[b,x]=Q.useState();return yn(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,$.jsx)(mE,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,$.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,$.jsx)(_n.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});dE.displayName=uE;var fE=`SelectPopperPosition`,pE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=iE,...a}=e,o=HT(n);return(0,$.jsx)(xT,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});pE.displayName=fE;var[mE,hE]=BT(nE,{}),gE=`SelectViewport`,_E=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=oE(gE,n),o=hE(gE,n),s=gn(t,a.onViewportChange),c=Q.useRef(0);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,$.jsx)(LT.Slot,{scope:n,children:(0,$.jsx)(_n.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:xn(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-iE*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});_E.displayName=gE;var vE=`SelectGroup`,[yE,bE]=BT(vE),xE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Cn();return(0,$.jsx)(yE,{scope:n,id:i,children:(0,$.jsx)(_n.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});xE.displayName=vE;var SE=`SelectLabel`,CE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=bE(SE,n);return(0,$.jsx)(_n.div,{id:i.id,...r,ref:t})});CE.displayName=SE;var wE=`SelectItem`,[TE,EE]=BT(wE),DE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=WT(wE,n),c=oE(wE,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=gn(t,e=>c.itemRefCallback?.(e,r,i)),h=Cn(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,$.jsx)(TE,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,$.jsx)(LT.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,$.jsx)(_n.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:xn(o.onFocus,()=>p(!0)),onBlur:xn(o.onBlur,()=>p(!1)),onClick:xn(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:xn(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:xn(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:xn(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xn(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:xn(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(FT.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});DE.displayName=wE;var OE=`SelectItemText`,kE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=WT(OE,n),s=oE(OE,n),c=EE(OE,n),l=KT(OE,n),[u,d]=Q.useState(null),f=gn(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.useMemo(()=>(0,$.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return yn(()=>(h(m),()=>g(m)),[h,g,m]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?xb.createPortal(a.children,o.valueNode):null]})});kE.displayName=OE;var AE=`SelectItemIndicator`,jE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return EE(AE,n).isSelected?(0,$.jsx)(_n.span,{"aria-hidden":!0,...r,ref:t}):null});jE.displayName=AE;var ME=`SelectScrollUpButton`,NE=Q.forwardRef((e,t)=>{let n=oE(ME,e.__scopeSelect),r=hE(ME,e.__scopeSelect),[i,a]=Q.useState(!1),o=gn(t,r.onScrollButtonChange);return yn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,$.jsx)(IE,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});NE.displayName=ME;var PE=`SelectScrollDownButton`,FE=Q.forwardRef((e,t)=>{let n=oE(PE,e.__scopeSelect),r=hE(PE,e.__scopeSelect),[i,a]=Q.useState(!1),o=gn(t,r.onScrollButtonChange);return yn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,$.jsx)(IE,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});FE.displayName=PE;var IE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=oE(`SelectScrollButton`,n),o=Q.useRef(null),s=RT(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),yn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,$.jsx)(_n.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:xn(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:xn(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:xn(i.onPointerLeave,()=>{c()})})}),LE=`SelectSeparator`,RE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,$.jsx)(_n.div,{"aria-hidden":!0,...r,ref:t})});RE.displayName=LE;var zE=`SelectArrow`,BE=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=HT(n),a=WT(zE,n),o=oE(zE,n);return a.open&&o.position===`popper`?(0,$.jsx)(ST,{...i,...r,ref:t}):null});BE.displayName=zE;var VE=`SelectBubbleInput`,HE=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=gn(r,i),o=kT(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,$.jsx)(_n.select,{...n,style:{...AT,...n.style},ref:a,defaultValue:t})});HE.displayName=VE;function UE(e){return e===``||e===void 0}function WE(e){let t=Sn(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function GE(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=KE(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function KE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var qE=qT,JE=YT,YE=ZT,XE=$T,ZE=tE,QE=rE,$E=_E,eD=CE,tD=DE,nD=kE,rD=jE,iD=NE,aD=FE,oD=RE,sD=`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground outline-none transition-colors hover:bg-surface/70 focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-50`,cD=`overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,lD=`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground outline-none hover:bg-surface/70 focus-visible:bg-surface/70`;function uD({label:e,value:t,options:n,icon:r,onSelect:i,placeholder:a,disabled:o=!1,testId:s}){return(0,$.jsxs)(qE,{value:t,onValueChange:i,disabled:o||n.length===0,children:[(0,$.jsxs)(JE,{"aria-label":e,title:e,"data-agent-interactive":!0,"data-testid":s,className:sD,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(YE,{placeholder:a??e,className:`max-w-[160px] truncate`}),(0,$.jsx)(XE,{asChild:!0,children:(0,$.jsx)(Zt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})})]}),(0,$.jsx)(ZE,{children:(0,$.jsxs)(QE,{position:`popper`,side:`top`,align:`start`,sideOffset:4,collisionPadding:8,className:`z-[80] min-w-[12rem] max-w-[20rem] ${cD} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1`,children:[(0,$.jsx)(iD,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,$.jsx)(Gt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)($E,{className:`max-h-72 py-1`,children:n.map(e=>{let t=e.icon??r;return(0,$.jsxs)(tD,{value:e.value,className:`${lD} relative cursor-default select-none pr-9 data-[highlighted]:bg-surface/70 data-[state=checked]:font-medium`,children:[(0,$.jsx)(t,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(nD,{children:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})}),(0,$.jsx)(rD,{className:`absolute right-3 flex items-center`,children:(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 text-accent-primary`})})]},e.value)})}),(0,$.jsx)(aD,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,$.jsx)(Zt,{className:`h-3.5 w-3.5`})})]})})]})}function dD({pinnedProjectId:e,onSelect:t}){let{t:n}=K(`agent`),{projects:r}=at(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(0),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useId)(),p=(0,Q.useCallback)((e=!1)=>{a(!1),s(``),l(0),e&&d.current?.focus()},[]);(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{u.current&&!u.current.contains(e.target)&&p()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i,p]);let m=r.find(t=>t.id===e)??null,h=(0,Q.useMemo)(()=>{let e=o.trim().toLowerCase();return e?r.filter(t=>t.name.toLowerCase().includes(e)):r},[r,o]),g=h.length+1;(0,Q.useEffect)(()=>{l(o.trim()?h.length>0?1:-1:0)},[o,h.length]);let _=()=>{let t=e?r.findIndex(t=>t.id===e):-1;l(t>=0?t+1:0),a(!0)},v=e=>{t(e),p(!0)},y=()=>{if(!(c<0))if(c===0)v(null);else{let e=h[c-1];e&&v(e.id)}};return(0,$.jsxs)(`div`,{className:`relative`,ref:u,"data-agent-interactive":!0,onKeyDown:e=>{if(!i){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),_());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;l(e=>(e+t+g)%g)}else e.key===`Enter`?(e.preventDefault(),y()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(!0))},children:[(0,$.jsxs)(`button`,{ref:d,type:`button`,onClick:()=>i?p():_(),"aria-haspopup":`listbox`,"aria-expanded":i,"aria-controls":f,className:sD,children:[m?(0,$.jsx)(os,{className:`h-3.5 w-3.5 text-accent-primary`}):(0,$.jsx)(gs,{className:`h-3.5 w-3.5 text-foreground/70`}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:m?m.name:n(`project.home`)}),(0,$.jsx)(Zt,{className:`h-3.5 w-3.5 text-foreground/50`})]}),(0,$.jsx)(f_,{children:i&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-64 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),role:`combobox`,placeholder:n(`project.searchProjectsPlaceholder`),"aria-label":n(`project.searchProjectsPlaceholder`),"aria-expanded":i,"aria-autocomplete":`list`,"aria-controls":f,"aria-activedescendant":c>=0?`${f}-option-${c}`:void 0,className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,$.jsxs)(`div`,{id:f,role:`listbox`,"aria-label":n(`project.allProjects`),className:`max-h-72 overflow-y-auto py-1`,children:[(0,$.jsx)(`div`,{className:`px-3 py-1 text-[11px] uppercase tracking-wide text-foreground/40`,children:n(`project.recents`)}),(0,$.jsx)(fD,{id:`${f}-option-0`,icon:(0,$.jsx)(gs,{className:`h-4 w-4`}),label:n(`project.home`),active:!e,highlighted:c===0,onMouseEnter:()=>l(0),onClick:()=>v(null),index:0}),h.map((t,n)=>(0,$.jsx)(fD,{id:`${f}-option-${n+1}`,icon:(0,$.jsx)(os,{className:`h-4 w-4 text-accent-primary`}),label:t.name,active:t.id===e,highlighted:c===n+1,onMouseEnter:()=>l(n+1),onClick:()=>v(t.id),index:n+1},t.id))]})]})})]})}function fD({id:e,icon:t,label:n,active:r,highlighted:i,onMouseEnter:a,onClick:o,index:s}){return(0,$.jsxs)(fy.button,{id:e,type:`button`,role:`option`,"aria-selected":r,tabIndex:-1,onMouseEnter:a,onClick:o,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(s*.03,.18)},className:`${lD} ${i?`bg-surface/70`:``}`,children:[t,(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),r&&(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 text-accent-primary`})]})}var pD=[{level:0,key:`observe`,icon:Qo,tone:`text-foreground/70`,bar:`bg-accent-info`},{level:1,key:`edit`,icon:an,tone:`text-accent-info`,bar:`bg-accent-info`},{level:2,key:`operate`,icon:hn,tone:`text-accent-warning`,bar:`bg-accent-warning`},{level:3,key:`autonomous`,icon:rs,tone:`text-destructive`,bar:`bg-destructive`}];function mD({level:e,onCycle:t}){let{t:n}=K(`agent`),r=pD[e],i=r.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:t,title:n(`tier.${r.key}.desc`),"aria-label":`${n(`tier.${r.key}.name`)} — ${n(`tier.cycleHint`)}`,className:`group flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/70 px-2.5 py-1 text-xs font-medium ${r.tone} transition-colors hover:bg-surface`,"data-agent-interactive":!0,children:[(0,$.jsxs)(fy.span,{initial:{scale:.8},animate:{scale:[1,1.18,1]},transition:{duration:.28,ease:`easeOut`},className:`flex items-center gap-1.5`,children:[(0,$.jsx)(i,{className:`h-3.5 w-3.5`}),n(`tier.${r.key}.name`)]},e),(0,$.jsx)(`span`,{className:`ml-1 flex gap-0.5`,"aria-hidden":!0,children:pD.map(t=>(0,$.jsx)(`span`,{className:`h-1 w-2 rounded-full transition-colors duration-200 ${t.level<=e?r.bar:`bg-border/50`}`},t.level))})]})}var hD=/^[A-Za-z0-9][A-Za-z0-9._/:-]*$/;function gD(e){return typeof e==`string`&&e.length>0&&e.length<=128&&hD.test(e)}function _D({value:e,options:t,onCommit:n,disabled:r=!1,ariaLabel:i,testId:a,placeholder:o,className:s}){let[c,l]=(0,Q.useState)(e),u=(0,Q.useId)(),d=(0,Q.useRef)(!1),f=gD(c);return(0,Q.useEffect)(()=>{l(e)},[e]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{type:`text`,list:u,value:c,maxLength:128,disabled:r,"aria-label":i,"aria-invalid":!f,"data-testid":a,placeholder:o,className:X(`rounded border border-border bg-transparent text-foreground outline-none`,`focus:ring-1 focus:ring-accent-primary/40`,!f&&`border-destructive focus:ring-destructive/40`,r&&`pointer-events-none opacity-50`,s),onChange:e=>l(e.target.value),onBlur:()=>{if(d.current){d.current=!1,l(e);return}if(!f){l(e);return}c!==e&&n(c)},onKeyDown:t=>{if(t.key===`Enter`){t.preventDefault(),t.currentTarget.blur();return}t.key===`Escape`&&(t.preventDefault(),d.current=!0,l(e),t.currentTarget.blur())}}),(0,$.jsx)(`datalist`,{id:u,children:t.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function vD({models:e,model:t,onSelect:n,status:r=`ready`,disabled:i=!1,testId:a=`agent-model-selector`,customModelAliases:o=!1}){let{t:s}=K(`agent`),c=t??e.find(e=>e.default)?.value??e[0]?.value??``,l=s(r===`loading`?`model.loading`:r===`error`?`model.unavailable`:`model.label`);return o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1`,children:[(0,$.jsx)(un,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(_D,{value:c,options:e,onCommit:n,disabled:i||r!==`ready`,ariaLabel:s(`model.label`),testId:a,placeholder:l,className:`h-6 w-48 border-border/40 px-1.5 text-xs`})]}):(0,$.jsx)(uD,{label:s(`model.label`),value:c,options:e.map(e=>({value:e.value,label:e.label})),icon:un,onSelect:n,placeholder:l,disabled:i||r!==`ready`,testId:a})}function yD(e){return{provider:e,models:[],efforts:[],customModelAliases:!1,supportsImageInput:!0,status:`loading`}}function bD(e){let[t,n]=(0,Q.useState)(()=>yD(e));return(0,Q.useEffect)(()=>{let t=!0;return n(yD(e)),La(e).then(r=>{t&&n({provider:e,models:r.models,efforts:r.efforts,customModelAliases:r.customModelAliases,supportsImageInput:r.supportsImageInput,status:`ready`})}).catch(()=>{t&&n({...yD(e),status:`error`})}),()=>{t=!1}},[e]),t.provider===e?t:yD(e)}function xD({projectId:e}){let{t}=K(`agent`),{isStreaming:n}=lM(),{projects:r}=at(),i=er(r.find(t=>t.id===e)),[a,o]=(0,Q.useState)(null),s=a?.projectId===e?a.repositoryId:i.find(e=>e.isPrimary)?.id,c=i.find(e=>e.id===s),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(``),x=(0,Q.useRef)(null),S=`${$n(e,s)}/git`,C=`${S}\0${c?.path??``}`,w=(0,Q.useRef)({key:C,epoch:0});w.current.key!==C&&(w.current={key:C,epoch:w.current.epoch+1});let T=w.current.epoch,E=l?.key===C?l.value:null,D=(0,Q.useRef)(null),O=(0,Q.useRef)(0),k=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,Q.useCallback)(async()=>{let e=++O.current;D.current?.abort();let t=new AbortController;D.current=t;try{let n=await fetch(S,{signal:t.signal});if(!n.ok)throw Error(`unavailable`);let r=await n.json();if(typeof r.git!=`boolean`||s&&r.repositoryId&&r.repositoryId!==s)throw Error(`repository mismatch`);k.current&&w.current.epoch===T&&O.current===e&&!t.signal.aborted&&(u({key:C,value:r}),f(!1))}catch{k.current&&w.current.epoch===T&&O.current===e&&!t.signal.aborted&&(u(null),f(!0))}},[S,s,C,T]);(0,Q.useEffect)(()=>(u(null),f(!1),m(!1),g(!1),v(!1),b(``),A(),()=>{++O.current,D.current?.abort()}),[A]);let j=(0,Q.useRef)(n);(0,Q.useEffect)(()=>{j.current&&!n&&A(),j.current=n},[n,A]),(0,Q.useEffect)(()=>It(t=>{t===e&&A()}),[e,A]),(0,Q.useEffect)(()=>{if(!h&&!_)return;let e=e=>{x.current&&!x.current.contains(e.target)&&(g(!1),v(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h,_]);let M=(0,Q.useCallback)(async e=>{if(g(!1),b(``),!(!E?.git||!e||e===E.branch||p||n||w.current.epoch!==T)){++O.current,D.current?.abort(),m(!0);try{let n=await fetch(`${S}/checkout`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({branch:e,...s?{repositoryId:s}:{}})}),r=await n.json().catch(()=>({}));if(!k.current||w.current.epoch!==T)return;if(!n.ok){J.error(t(`git.switchFailed`),{description:r.error}),A();return}if(++O.current,typeof r.git!=`boolean`||s&&r.repositoryId&&r.repositoryId!==s){u(null),f(!0);return}u({key:C,value:r}),J.success(t(`git.switched`,{branch:e}))}catch{if(!k.current||w.current.epoch!==T)return;J.error(t(`git.switchFailed`)),A()}finally{k.current&&w.current.epoch===T&&m(!1)}}},[S,E,s,C,T,p,n,t,A]),N=(0,Q.useMemo)(()=>{if(!E)return[];let e=y.trim().toLowerCase();return e?(E.branches??[]).filter(t=>t.toLowerCase().includes(e)):E.branches??[]},[E,y]),P=i.length>1||!!s&&!c;if(!E?.git&&!P&&!d)return null;let F=p||n,I=E?.detached?t(`git.detached`):E?.branch??t(`git.detached`),L=new Map((E?.worktrees??[]).filter(e=>!e.isMain&&e.branch).map(e=>[e.branch,e])),R=N.filter(e=>!L.has(e)),z=N.filter(e=>L.has(e)),B=async e=>{g(!1),b(``);try{await navigator.clipboard.writeText(e.path),J.success(t(`git.worktreePathCopied`),{description:e.path})}catch{J.info?.(e.path)}};return(0,$.jsxs)(`div`,{ref:x,className:`relative mt-1.5 flex min-w-0 items-center gap-2 px-1 text-[11px] text-foreground/50`,"data-agent-interactive":!0,children:[P&&(0,$.jsxs)(`div`,{className:`relative min-w-0 shrink-0`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":t(`git.repository`),"aria-expanded":_,disabled:p,onClick:()=>{v(e=>!e),g(!1)},className:`flex max-w-[180px] items-center gap-1.5 rounded-md border border-border/50 bg-surface/60 px-1.5 py-0.5 text-foreground hover:bg-surface disabled:opacity-50`,children:[(0,$.jsx)(is,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`truncate`,children:c?.name??t(`git.repositoryUnavailable`)}),(0,$.jsx)(Zt,{className:`h-3 w-3 shrink-0`})]}),_&&(0,$.jsx)(`div`,{role:`listbox`,"aria-label":t(`git.repository`),className:`absolute bottom-full left-0 z-20 mb-1 max-h-56 w-64 overflow-y-auto rounded-xl border border-border/60 bg-card p-1 shadow-2xl`,children:i.map(t=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.id===s,onClick:()=>{o({projectId:e,repositoryId:t.id}),v(!1)},className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-surface`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name}),t.id===s&&(0,$.jsx)(Ht,{className:`h-3 w-3`})]},t.id))})]}),!E?.git&&(0,$.jsx)(`span`,{role:d?`status`:void 0,className:`min-w-0 truncate`,children:d?t(`git.loadFailed`):E?t(`git.notGit`):(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`})}),d&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void A(),className:`shrink-0 text-accent-primary hover:underline`,children:t(`git.retry`)}),E?.git&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{F||(g(e=>!e),v(!1))},disabled:F,"aria-label":t(`git.branch`),"aria-expanded":h,title:t(F&&n?`git.lockedWhileWorking`:`git.branch`),className:`flex max-w-[220px] shrink-0 items-center gap-1.5 rounded-md border border-border/50 bg-surface/60 px-1.5 py-0.5 text-[11px] text-foreground transition-colors hover:bg-surface disabled:opacity-50`,children:[p?(0,$.jsx)(rn,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary/70`}):(0,$.jsx)(nn,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:I}),(0,$.jsx)(Zt,{className:`h-3 w-3 shrink-0 text-foreground/40`})]}),(0,$.jsx)(f_,{children:h&&E?.git&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute bottom-full left-0 z-20 mb-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.jsx)(`input`,{autoFocus:!0,value:y,onChange:e=>b(e.target.value),placeholder:t(`git.searchPlaceholder`),"aria-label":t(`git.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,$.jsxs)(`div`,{className:`max-h-64 overflow-y-auto py-1`,role:`listbox`,"aria-label":t(`git.branch`),children:[N.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:t(`git.noMatches`)}),R.map((e,t)=>(0,$.jsxs)(fy.button,{type:`button`,role:`option`,"aria-selected":e===E.branch,onClick:()=>void M(e),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.02,.16)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),e===E.branch&&(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`})]},e)),z.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-1 border-t border-border/50 px-3 pb-0.5 pt-1.5 text-[10px] uppercase tracking-wide text-foreground/40`,children:t(`git.worktrees`)}),z.map((e,n)=>{let r=L.get(e);return(0,$.jsxs)(fy.button,{type:`button`,role:`option`,"aria-selected":!1,onClick:()=>void B(r),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(n*.02,.16)},title:t(`git.copyWorktreePath`),className:`group flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,$.jsx)(is,{className:`h-3.5 w-3.5 shrink-0 text-accent-secondary/80`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs`,children:e}),(0,$.jsx)(`span`,{className:`block truncate text-[10px] text-foreground/40`,children:r.path})]}),(0,$.jsx)(Ho,{className:`h-3 w-3 shrink-0 text-foreground/30 opacity-0 transition-opacity group-hover:opacity-100`})]},e)})]})]})]})}),E?.dirty&&(0,$.jsx)(`span`,{title:t(`git.dirty`),"aria-label":t(`git.dirty`),className:`h-1.5 w-1.5 shrink-0 rounded-full bg-accent-warning`}),E?.lastCommit&&(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${E.lastCommit.hash} · ${E.lastCommit.subject}`,children:[(0,$.jsx)(`span`,{className:`font-mono text-foreground/40`,children:E.lastCommit.hash}),` · `,E.lastCommit.subject]})]})}var SD={reference:vo,trace:z,action:un},CD={project:To,spec:$t,job:So,trace:z,conversation:So,file:Rs,alias:vo,pr:R,action:un};function wD(e){return e===`reference`?`@`:e===`trace`?`#`:`/`}function TD({items:e,mode:t,query:n,activeIndex:r,onActiveIndexChange:i,onSelect:a}){let{t:o}=K(`agent`),s=SD[t],c=``;return(0,$.jsxs)(`div`,{"data-testid":`agent-context-palette`,className:`absolute bottom-[calc(100%+0.5rem)] left-0 right-0 z-30 overflow-hidden rounded-lg border border-border/70 bg-background/95 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-md bg-surface text-foreground/70`,children:(0,$.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-medium text-foreground`,children:[wD(t),` `,o(`palette.mode.${t}.title`)]}),(0,$.jsx)(`div`,{className:`truncate text-[11px] text-foreground/45`,children:n?o(`palette.filtering`,{query:n}):o(`palette.mode.${t}.hint`)})]}),(0,$.jsx)(`div`,{className:`hidden text-[10px] text-foreground/35 sm:block`,children:o(`palette.keyboard`)})]}),e.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 text-xs text-foreground/55`,children:[(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-foreground/35`}),(0,$.jsx)(`span`,{children:n?o(`palette.noMatchesFor`,{query:n}):o(`palette.noMatches`)})]}):(0,$.jsx)(`div`,{className:`max-h-[19rem] overflow-y-auto py-1`,children:e.map((e,t)=>{let n=CD[e.icon]??un,o=e.group!==c;c=e.group;let s=t===r;return(0,$.jsxs)(`div`,{children:[o&&(0,$.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/35`,children:e.group}),(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":s,onMouseEnter:()=>i(t),onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),className:`flex w-full items-center gap-2 px-2.5 py-2 text-left transition-colors ${s?`bg-accent-primary/10 text-foreground`:`text-foreground/80 hover:bg-surface/70`}`,children:[(0,$.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${s?`bg-background text-accent-primary`:`bg-surface text-foreground/50`}`,children:(0,$.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title}),e.risk&&(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border/60 px-1 py-0.5 text-[10px] uppercase text-foreground/45`,children:e.risk})]}),(e.subtitle||e.detail)&&(0,$.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-foreground/45`,children:[e.subtitle,e.subtitle&&e.detail?` · `:``,e.detail]})]})]})]},e.id)})})]})}function ED({open:e,canAttach:t,uploading:n,onToggle:r,onClose:i,onOpenMode:a,onAttachFile:o,canBrowserCapture:s,onOpenBrowser:c}){let{t:l}=K(`agent`),u=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t instanceof Node&&u.current?.contains(t)||i()},n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n,!0)}},[e,i]),(0,$.jsxs)(`div`,{ref:u,className:`relative mb-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":l(`palette.addContextAction`),title:l(`palette.addContextAction`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/50 hover:bg-surface hover:text-foreground disabled:opacity-50`,children:(0,$.jsx)(cn,{className:`h-4 w-4`})}),e&&(0,$.jsxs)(`div`,{className:`absolute bottom-8 left-0 z-40 w-64 overflow-hidden rounded-lg border border-border/70 bg-background/95 py-1 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,$.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`reference`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,$.jsx)(vo,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:l(`palette.plus.reference`)}),(0,$.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:l(`palette.plus.referenceHint`)})]})]}),(0,$.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`trace`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,$.jsx)(z,{className:`h-4 w-4 text-accent-info`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:l(`palette.plus.trace`)}),(0,$.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:l(`palette.plus.traceHint`)})]})]}),(0,$.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`action`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,$.jsx)(un,{className:`h-4 w-4 text-accent-highlight`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:l(`palette.plus.action`)}),(0,$.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:l(`palette.plus.actionHint`)})]})]}),(0,$.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,$.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:o,disabled:!t||n,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,$.jsx)(Rs,{className:`h-4 w-4 text-foreground/50`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:l(`palette.plus.fileAttachment`)}),(0,$.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:l(`palette.plus.fileAttachmentHint`)})]})]}),(0,$.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{i(),c()},disabled:!s,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface disabled:cursor-not-allowed disabled:opacity-45`,"data-testid":`agent-plus-browser-capture`,children:[(0,$.jsx)(ee,{className:`h-4 w-4 text-foreground/50`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:l(`palette.plus.browserCapture`)}),(0,$.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:l(`palette.plus.browserCaptureHint`)})]})]})]})]})}var DD=new Set([`DIV`,`P`,`LI`]),OD=`​`;function kD(e,t){let n=``,r=[],i=new Map,a=e=>{let o=n.length;if(e.nodeType===Node.TEXT_NODE){let t=[o];for(let r of(e.textContent??``).split(``))r!==OD&&(n+=r===`\xA0`?` `:r),t.push(n.length);i.set(e,{start:o,end:n.length,boundaries:t});return}if(!(e instanceof HTMLElement))return;let s=e.dataset.inlineReference,c=s?t.get(s):void 0;if(s&&c){n+=c.token,r.push({key:s,start:o,end:n.length,chip:c}),i.set(e,{start:o,end:n.length,atomic:!0});return}if(e.tagName===`BR`){e.nextSibling&&(n+=`
34
+ `),i.set(e,{start:o,end:n.length});return}let l=[o];Array.from(e.childNodes).forEach((t,r)=>{let i=e.childNodes[r-1],o=i instanceof HTMLElement&&DD.has(i.tagName);r>0&&t instanceof HTMLElement&&DD.has(t.tagName)&&(o||!n.endsWith(`
35
+ `))&&(n+=`
36
+ `),l[r]=n.length,a(t),l.push(n.length)}),i.set(e,{start:o,end:n.length,boundaries:l})};return a(e),{value:n,references:r,positions:i}}function AD(e,t,n){let r=e.positions.get(t);if(r)return r.boundaries?r.boundaries[Math.min(n,r.boundaries.length-1)]:r.atomic?n===0?r.start:r.end:Math.min(r.end,r.start+n);let i=t.parentNode;for(;i;){let t=e.positions.get(i);if(t?.atomic)return n===0?t.start:t.end;i=i.parentNode}return e.value.length}function jD(e,t){let n=e.ownerDocument.getSelection();if(!n?.anchorNode||!n.focusNode||!e.contains(n.anchorNode)||!e.contains(n.focusNode))return null;let r=AD(t,n.anchorNode,n.anchorOffset),i=AD(t,n.focusNode,n.focusOffset);return[Math.min(r,i),Math.max(r,i)]}function MD(e,t,n){let r=Math.max(0,Math.min(n,t.value.length));for(let[n,i]of t.positions)if(!(r<i.start||r>i.end)){if(n.nodeType===Node.TEXT_NODE)return[n,i.boundaries?.lastIndexOf(r)??r-i.start];if(i.atomic&&n.parentNode){let e=Array.prototype.indexOf.call(n.parentNode.childNodes,n);return r===i.end&&n.nextSibling?.nodeType===Node.TEXT_NODE&&n.nextSibling.textContent?.startsWith(OD)?[n.nextSibling,1]:[n.parentNode,e+ +(r-i.start>(i.end-i.start)/2)]}if(n!==e&&n instanceof HTMLElement&&n.tagName===`BR`&&n.parentNode){let e=Array.prototype.indexOf.call(n.parentNode.childNodes,n);return[n.parentNode,e+ +(r>i.start)]}}return[e,e.childNodes.length]}function ND(e,t,n,r){let[i,a]=MD(e,t,n),[o,s]=MD(e,t,Math.max(n,r)),c=e.ownerDocument.createRange();c.setStart(i,a),c.setEnd(o,s);let l=e.ownerDocument.getSelection();l?.removeAllRanges(),l?.addRange(c)}function PD(e,t){let n=0,r=new Set;return[...t].sort((e,t)=>e.start-t.start).filter(t=>!t.key||!Number.isInteger(t.start)||!Number.isInteger(t.end)||r.has(t.key)||t.start<n||t.end<=t.start||e.slice(t.start,t.end)!==t.chip.token?!1:(n=t.end,r.add(t.key),!0))}function FD(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.key===r.key&&e.start===r.start&&e.end===r.end&&JSON.stringify(e.chip)===JSON.stringify(r.chip)})}function ID(e){return e===`spec`||e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function LD(e,t,n,r,i){let a=e.createDocumentFragment(),o=0;for(let s of n){a.append(e.createTextNode(`${o>0?OD:``}${t.slice(o,s.start)}${OD}`));let n=e.createElement(`span`);n.setAttribute(`contenteditable`,`false`),n.dataset.inlineReference=s.key,n.dataset.token=s.chip.token,n.className=`mx-0.5 inline-flex max-w-[240px] items-center gap-1 align-middle rounded-full border px-2 py-0.5 text-[11px] select-none ${ID(s.chip.kind)}`,n.title=[s.chip.label,s.chip.detail,s.chip.projectName,s.chip.status].filter(Boolean).join(` · `);let c=e.createElement(`span`);c.textContent=/^[#@/]/.test(s.chip.token)?s.chip.token[0]:`@`,c.setAttribute(`aria-hidden`,`true`);let l=e.createElement(`span`);if(l.className=`truncate font-medium`,l.textContent=s.chip.label,n.append(c,l),s.chip.status){let t=e.createElement(`span`);t.className=`text-foreground/40`,t.textContent=s.chip.status,n.append(t)}let u=e.createElement(`button`);u.type=`button`,u.tabIndex=-1,u.disabled=r??!1,u.dataset.removeReference=s.key,u.setAttribute(`aria-label`,i(s.chip.label)),u.className=`rounded-sm px-0.5 text-foreground/45 hover:bg-background/60 hover:text-foreground`,u.textContent=`×`,n.append(u),a.append(n),o=s.end}return a.append(e.createTextNode(`${n.length?OD:``}${t.slice(o)}`)),a}var RD=(0,Q.forwardRef)(function(e,t){let{t:n}=K(`agent`),r=(0,Q.useRef)(null),i=(0,Q.useRef)(e);i.current=e;let a=(0,Q.useRef)(new Map),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)([e.value.length,e.value.length]),l=(0,Q.useRef)([]),u=(0,Q.useRef)(``),d=(0,Q.useRef)(null),f=(0,Q.useRef)({entries:[{value:e.value,references:PD(e.value,e.references),selection:[e.value.length,e.value.length]}],index:0,typing:null}),p=()=>kD(r.current,a.current),m=e=>{c.current=e,f.current.entries[f.current.index].selection=e},h=(e,t)=>{let n=f.current,r=n.entries[n.index];if(r.value===e.value&&FD(r.references,e.references)){r.selection=e.selection;return}r.selection=c.current;let i=Date.now(),a=t===`insertText`&&n.typing!==null&&i-n.typing.at<1e3&&r.selection[0]===r.selection[1]&&r.selection[0]===n.typing.caret&&e.selection[0]===e.selection[1]&&e.selection[0]>=r.selection[0]&&r.references.length===e.references.length&&r.references.every((t,n)=>t.key===e.references[n].key);n.entries.splice(n.index+1),a&&n.index>0?n.entries[n.index]=e:(n.entries.push(e),n.entries.length>64&&n.entries.shift(),n.index=n.entries.length-1),n.typing=t===`insertText`?{at:i,caret:e.selection[0]}:null},g=(e,t,o)=>{let s=r.current;for(let e of t)a.current.set(e.key,e.chip);s.replaceChildren(LD(s.ownerDocument,e,t,i.current.disabled??!1,e=>n(`palette.remove`,{label:e}))),s.dataset.empty=String(e.length===0),l.current=t,u.current=b,o&&(ND(s,p(),...o),m(jD(s,p())??o))},_=e=>{let t=r.current;if(!t||i.current.disabled)return;let n=f.current;n.index=Math.max(0,Math.min(n.entries.length-1,n.index+e)),n.typing=null;let a=n.entries[n.index];t.focus(),g(a.value,a.references,a.selection),i.current.onChange(a.value,a.references,a.selection[0])},v=()=>{let e=r.current;if(!e)return;let t=jD(e,p());t&&(t[0]!==c.current[0]||t[1]!==c.current[1])&&(m(t),i.current.onSelect(...t))},y=(e=`insertText`)=>{let t=r.current;if(!t||o.current)return;if(e===`historyUndo`||e===`historyRedo`){_(e===`historyUndo`?-1:1);return}let n=p(),a=jD(t,n)??[n.value.length,n.value.length];h({value:n.value,references:n.references,selection:a},d.current??e),m(a),l.current=n.references,t.dataset.empty=String(n.value.length===0),i.current.onChange(n.value,n.references,a[0])};(0,Q.useImperativeHandle)(t,()=>({focus:()=>r.current?.focus(),setSelectionRange:(e,t)=>{r.current&&(ND(r.current,p(),e,t),m(jD(r.current,p())??[e,t]))},get selectionStart(){return r.current?(jD(r.current,p())??c.current)[0]:0},get selectionEnd(){return r.current?(jD(r.current,p())??c.current)[1]:0},get value(){return r.current?p().value:i.current.value}}));let b=n(`palette.remove`,{label:`{{label}}`});(0,Q.useLayoutEffect)(()=>{let t=r.current;if(!t||o.current)return;let n=PD(e.value,e.references),i=p();for(let e of n)a.current.set(e.key,e.chip);t.querySelectorAll(`[data-remove-reference]`).forEach(t=>{t.disabled=e.disabled??!1});let s=t.ownerDocument.activeElement===t,d=jD(t,i)??c.current;i.value===e.value&&FD(i.references,n)&&FD(l.current,n)&&u.current===b||(h({value:e.value,references:n,selection:d},`external`),g(e.value,n,s?d:null))}),(0,Q.useEffect)(()=>{let t=r.current;if(!t)return;t.ownerDocument.addEventListener(`selectionchange`,v);let n=e=>{e.inputType!==`historyUndo`&&e.inputType!==`historyRedo`||(e.preventDefault(),e.cancelable&&_(e.inputType===`historyUndo`?-1:1))};return t.addEventListener(`beforeinput`,n),e.autoFocus&&t.focus(),()=>{t.ownerDocument.removeEventListener(`selectionchange`,v),t.removeEventListener(`beforeinput`,n)}},[]);let x=(e,t)=>{let n=r.current,i=n?.ownerDocument.getSelection();if(!n||!i?.rangeCount||!i.anchorNode||!i.focusNode||!n.contains(i.anchorNode)||!n.contains(i.focusNode))return;m(jD(n,p())??c.current),d.current=t;let a=!1;try{a=n.ownerDocument.execCommand?.(e?`insertText`:`delete`,!1,e)??!1}catch{}if(!a){let t=i.getRangeAt(0);if(t.deleteContents(),e){let r=n.ownerDocument.createTextNode(e);t.insertNode(r),t.setStartAfter(r)}t.collapse(!0),i.removeAllRanges(),i.addRange(t)}y(t),d.current=null},S=e=>{let t=r.current;if(!t||i.current.disabled)return;let n=p(),a=n.references.find(t=>t.key===e);a&&(t.focus(),ND(t,n,a.start,a.end),x(``,`deleteAtomic`))},C=(e,t)=>{let n=r.current;if(!n)return;let a=p(),o=jD(n,a);!o||o[0]===o[1]||(e.preventDefault(),e.clipboardData.setData(`text/plain`,a.value.slice(...o)),t&&!i.current.disabled&&x(``,`deleteByCut`))};return(0,$.jsx)(`div`,{ref:r,role:`textbox`,"aria-label":e.ariaLabel??e.placeholder,"aria-multiline":`true`,"aria-disabled":e.disabled||void 0,"data-agent-interactive":!0,contentEditable:!e.disabled,suppressContentEditableWarning:!0,"data-placeholder":e.placeholder,"data-empty":e.value.length===0,title:e.title,className:`whitespace-pre-wrap break-words outline-none data-[empty=true]:before:pointer-events-none data-[empty=true]:before:text-foreground/35 data-[empty=true]:before:content-[attr(data-placeholder)] ${e.className??``}`,onInput:e=>y(e.nativeEvent.inputType||`insertText`),onCompositionStart:()=>{o.current=!0,s.current={value:i.current.value,references:i.current.references}},onCompositionEnd:()=>{o.current=!1;let e=s.current;s.current=null;let t=i.current;if(e&&(e.value!==t.value||!FD(e.references,t.references))){let e=PD(t.value,t.references),n=[t.value.length,t.value.length];h({value:t.value,references:e,selection:n},`external`),g(t.value,e,r.current?.ownerDocument.activeElement===r.current?n:null);return}y(`insertCompositionText`)},onKeyUp:v,onMouseUp:v,onMouseDown:e=>{e.target.closest(`[data-remove-reference]`)&&e.preventDefault()},onClick:e=>{let t=e.target.closest(`[data-remove-reference]`);t?.dataset.removeReference&&S(t.dataset.removeReference)},onKeyDown:e=>{if(!(i.current.disabled||o.current||e.nativeEvent.isComposing||e.keyCode===229)){if((e.metaKey||e.ctrlKey)&&!e.altKey&&(e.key.toLowerCase()===`z`||!e.metaKey&&e.key.toLowerCase()===`y`)){e.preventDefault(),_(e.shiftKey||e.key.toLowerCase()===`y`?1:-1);return}if(m(jD(r.current,p())??c.current),i.current.onKeyDown(e),!(e.defaultPrevented||i.current.disabled)){if(e.key===`Enter`)e.preventDefault(),x(`
37
+ `,`insertLineBreak`);else if(e.key===`Backspace`||e.key===`Delete`){let t=r.current,n=p(),i=jD(t,n);if(!i||i[0]!==i[1])return;let a=n.references.find(t=>e.key===`Backspace`?t.end===i[0]:t.start===i[0]);a&&(e.preventDefault(),S(a.key))}}}},onPaste:e=>{i.current.onPaste(e),!(e.defaultPrevented||i.current.disabled)&&(e.preventDefault(),x(e.clipboardData.getData(`text/plain`).replace(/\r\n?/g,`
38
+ `),`insertFromPaste`))},onCopy:e=>C(e,!1),onCut:e=>C(e,!0)})}),zD=Symbol(`radix.slottable`);function BD(e){let t=({children:e})=>(0,$.jsx)($.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=zD,t}var[VD,HD]=vn(`Tooltip`,[rT]),UD=rT(),WD=`TooltipProvider`,GD=700,KD=`tooltip.open`,[qD,JD]=VD(WD),YD=e=>{let{__scopeTooltip:t,delayDuration:n=GD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Q.useRef(!0),s=Q.useRef(!1),c=Q.useRef(0);return Q.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,$.jsx)(qD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Q.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:Q.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Q.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};YD.displayName=WD;var XD=`Tooltip`,[ZD,QD]=VD(XD),$D=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=JD(XD,e.__scopeTooltip),l=UD(t),[u,d]=Q.useState(null),f=Cn(),p=Q.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Q.useRef(!1),[_,v]=Gn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(KD))):c.onClose(),a?.(e)},caller:XD}),y=Q.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Q.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Q.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Q.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Q.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,$.jsx)(yT,{...l,children:(0,$.jsx)(ZD,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Q.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Q.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};$D.displayName=XD;var eO=`TooltipTrigger`,tO=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=QD(eO,n),a=JD(eO,n),o=UD(n),s=gn(t,Q.useRef(null),i.onTriggerChange),c=Q.useRef(!1),l=Q.useRef(!1),u=Q.useCallback(()=>c.current=!1,[]);return Q.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,$.jsx)(bT,{asChild:!0,...o,children:(0,$.jsx)(_n.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:xn(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:xn(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:xn(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:xn(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:xn(e.onBlur,i.onClose),onClick:xn(e.onClick,i.onClose)})})});tO.displayName=eO;var nO=`TooltipPortal`,[rO,iO]=VD(nO,{forceMount:void 0}),aO=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=QD(nO,t);return(0,$.jsx)(rO,{scope:t,forceMount:n,children:(0,$.jsx)(Wn,{present:n||a.open,children:(0,$.jsx)(qn,{asChild:!0,container:i,children:r})})})};aO.displayName=nO;var oO=`TooltipContent`,sO=Q.forwardRef((e,t)=>{let n=iO(oO,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=QD(oO,e.__scopeTooltip);return(0,$.jsx)(Wn,{present:r||o.open,children:o.disableHoverableContent?(0,$.jsx)(fO,{side:i,...a,ref:t}):(0,$.jsx)(cO,{side:i,...a,ref:t})})}),cO=Q.forwardRef((e,t)=>{let n=QD(oO,e.__scopeTooltip),r=JD(oO,e.__scopeTooltip),i=Q.useRef(null),a=gn(t,i),[o,s]=Q.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=Q.useCallback(()=>{s(null),d(!1)},[d]),p=Q.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=gO(r,hO(r,n.getBoundingClientRect())),a=_O(t.getBoundingClientRect()),o=yO([...i,...a]);s(o),d(!0)},[d]);return Q.useEffect(()=>()=>f(),[f]),Q.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),Q.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!vO(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,$.jsx)(fO,{...e,ref:a})}),[lO,uO]=VD(XD,{isInside:!1}),dO=BD(`TooltipContent`),fO=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=QD(oO,n),l=UD(n),{onClose:u}=c;return Q.useEffect(()=>(document.addEventListener(KD,u),()=>document.removeEventListener(KD,u)),[u]),Q.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,$.jsx)(Kn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,$.jsxs)(xT,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,$.jsx)(dO,{children:r}),(0,$.jsx)(lO,{scope:n,isInside:!0,children:(0,$.jsx)(NT,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});sO.displayName=oO;var pO=`TooltipArrow`,mO=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=UD(n);return uO(pO,n).isInside?null:(0,$.jsx)(ST,{...i,...r,ref:t})});mO.displayName=pO;function hO(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function gO(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _O(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function vO(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function yO(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),bO(t)}function bO(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xO=YD,SO=$D,CO=tO,wO=sO,TO=xO,EO=SO,DO=CO,OO=Q.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,$.jsx)(wO,{ref:r,sideOffset:t,className:X(`z-50 overflow-hidden rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n}));OO.displayName=wO.displayName;function kO(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var AO={"accent-primary":`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,"accent-info":`border-accent-info/40 bg-accent-info/10 text-accent-info`,"accent-highlight":`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`};function jO({process:e,accentVariant:t,onKill:n,onOpen:r}){let{t:i}=K(`agent`),a=NO(e),o=MO(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=s||e.status===`stopping`&&!e.stopError&&!e.error,f=l||!!e.stopError||e.status===`stopping`&&!!e.error,p=async()=>{if(!(d||o)){c(!0),u(!1);try{await n(e)}catch{u(!0)}finally{c(!1)}}};return(0,$.jsx)(TO,{delayDuration:150,children:(0,$.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`inline-flex max-w-full items-center rounded-lg border text-[11px] ${AO[t]}`,children:[(0,$.jsxs)(EO,{children:[(0,$.jsx)(DO,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-label":i(`backgroundProcess.open`,{command:e.command}),className:`inline-flex min-w-0 max-w-[340px] items-center gap-1.5 rounded-l-lg px-2 py-1 transition-colors hover:bg-background/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`shrink-0 ${e.status===`failed`?`text-destructive`:`text-foreground/70`}`,children:i(`backgroundProcess.status.${d?`stopping`:e.status}`)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.command}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground`,children:a})]})}),(0,$.jsxs)(OO,{children:[i(`backgroundProcess.open`,{command:e.command}),` · `,a]})]}),f&&(0,$.jsxs)(`span`,{role:`alert`,title:i(`backgroundProcess.stopFailed`),className:`flex shrink-0 items-center px-1 text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3 w-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i(`backgroundProcess.stopFailed`)})]}),!o&&(0,$.jsx)(`button`,{type:`button`,disabled:d,"aria-label":i(`backgroundProcess.stopCommand`,{command:e.command}),title:i(`backgroundProcess.stopCommand`,{command:e.command}),onClick:e=>{e.preventDefault(),e.stopPropagation(),p()},className:`mr-1 rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive disabled:opacity-50`,children:d?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(mn,{className:`h-3 w-3`,"aria-hidden":!0})})]})})}function MO(e){return e.status===`exited`||e.status===`failed`||e.status===`killed`||e.status===`interrupted`}function NO(e){let[t,n]=(0,Q.useState)(Date.now()),r=MO(e);return(0,Q.useEffect)(()=>{if(n(Date.now()),r)return;let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[r,e.startedAt]),kO(Math.max(0,(e.endedAt??e.recoveredAt??t)-e.startedAt))}var PO=2e3,FO=512*1024,IO=1e3;function LO(e){return e.replace(/\x1b\][\s\S]*?(?:\x07|\x1b\\|$)/g,``).replace(/\x1b[PX^_][\s\S]*?(?:\x1b\\|$)/g,``).replace(/(?:\x1b\[|\x9b)[0-?]*[ -/]*[@-~]/g,``).replace(/\x1b[()][0-2A-Z]/g,``).replace(/\x1b[@-_]/g,``).replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g,``)}function RO(e){let t=[],n=0,r=e.length>PO;for(let i=e.length-1;i>=0&&t.length<PO;i--){let a=e[i],o=LO(a.line),s=o.slice(-4e3);if(o.length>s.length&&(r=!0),n+s.length>FO){r=!0;break}n+=s.length,t.push({...a,line:s})}return{lines:t.reverse(),truncated:r}}function zO(e){let t=new Date(e.at);return`[${Number.isNaN(t.getTime())?`—`:t.toLocaleTimeString(void 0,{hour12:!1})}] [${e.source}] ${e.line}`}function BO({process:e,onClose:t,onKill:n,onBack:r}){return(0,$.jsx)(VO,{process:e,onClose:t,onKill:n,onBack:r},Gx(e))}function VO({process:e,onClose:t,onKill:n,onBack:r}){let{t:i}=K(`agent`),a=Gx(e),o=(0,Q.useRef)(e);o.current=e;let[s,c]=(0,Q.useState)(e),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(`all`),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),N=(0,Q.useRef)(null),P=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(P.current=!0,()=>{P.current=!1}),[]);let F=MO(e)?e:MO(s)?s:e.status===`stopping`&&s.status!==`stopping`?e:s,I=MO(F);(0,Q.useEffect)(()=>{I&&v(!1)},[I]);let L=D||F.status===`stopping`&&!F.error&&!e.stopError,R=NO(F);(0,Q.useEffect)(()=>{if(_){f(!1);return}let e=new AbortController,t,n=async()=>{try{let r=await Qx(o.current,{limit:PO,signal:e.signal});if(e.signal.aborted)return;if(Gx(r.process)!==a)throw Error(`Unexpected process identity`);let i=RO(r.lines);c(e=>JSON.stringify(e)===JSON.stringify(r.process)?e:r.process),u(e=>e.length===i.lines.length&&e.every((e,t)=>{let n=i.lines[t];return e.sequence===n.sequence&&e.line===n.line&&e.source===n.source&&e.at===n.at&&e.partial===n.partial})?e:i.lines),g(r.truncated||i.truncated),m(!1),f(!1),MO(r.process)||(t=setTimeout(()=>{n()},IO))}catch{if(e.signal.aborted)return;f(!1),m(!0)}};return f(!0),m(!1),n(),()=>{e.abort(),clearTimeout(t)}},[a,_,T]),(0,Q.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>M(null),2500);return()=>clearTimeout(e)},[j]);let z=(0,Q.useMemo)(()=>{let e=x.toLocaleLowerCase();return l.filter(t=>(C===`all`||C===t.source)&&(!e||t.line.toLocaleLowerCase().includes(e)))},[l,x,C]),B=(0,Q.useMemo)(()=>z.map(zO).join(`
39
+ `),[z]);(0,Q.useEffect)(()=>{y&&!_&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[z,y,_]);let ee=async()=>{if(!(L||I)){O(!0),A(!1);try{await n(o.current)}catch{P.current&&A(!0)}finally{P.current&&O(!1)}}},V=async()=>{try{await navigator.clipboard.writeText(B),P.current&&M(`copied`)}catch{P.current&&M(`failed`)}},H=()=>{let t;try{t=URL.createObjectURL(new Blob([B],{type:`text/plain;charset=utf-8`}));let n=document.createElement(`a`);n.href=t,n.download=`process-${e.pid}-${e.startedAt}.log`,document.body.appendChild(n),n.click(),n.remove()}catch{M(`failed`)}finally{t&&URL.revokeObjectURL(t)}},te=`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border/60 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:cursor-not-allowed disabled:opacity-40`;return(0,$.jsx)(Hn,{open:!0,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Dn,{children:[(0,$.jsx)(Vn,{className:`z-[80]`}),(0,$.jsxs)(Un,{"data-testid":`background-process-logs-modal`,className:`fixed left-1/2 top-1/2 z-[81] flex h-[min(780px,88vh)] w-[calc(100vw-2rem)] max-w-5xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/50 bg-popover text-foreground shadow-2xl focus:outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex items-start gap-3 border-b border-border/50 px-4 py-3`,children:[r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`backgroundProcess.history.back`),title:i(`backgroundProcess.history.back`),className:`rounded-md p-1 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:(0,$.jsx)(Rt,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsx)(dc,{className:`mt-0.5 h-5 w-5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(Fn,{className:`text-sm font-semibold`,children:i(`backgroundProcess.logsTitle`)}),(0,$.jsx)(`span`,{"data-testid":`background-process-status`,className:`rounded-full px-2 py-0.5 text-[11px] ${F.status===`failed`?`bg-destructive/10 text-destructive`:I?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:i(`backgroundProcess.status.${L?`stopping`:F.status}`)}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:R})]}),(0,$.jsx)(Mn,{className:`mt-1 text-xs text-muted-foreground`,children:i(`backgroundProcess.logsDescription`)})]}),(0,$.jsx)(Ln,{className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,"aria-label":i(`backgroundProcess.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-b border-border/50 px-4 py-3 text-xs`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.command`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono`,children:LO(F.command)}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.directory`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono text-muted-foreground`,children:LO(F.cwd)}),(F.repositoryName||F.repositoryId)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.repository`)}),(0,$.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:LO(F.repositoryName??F.repositoryId??``)})]}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`PID`}),(0,$.jsxs)(`dd`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:F.pid}),F.exitCode!=null&&(0,$.jsx)(`span`,{children:i(`backgroundProcess.exitCode`,{code:F.exitCode})}),F.signal&&(0,$.jsx)(`span`,{children:i(`backgroundProcess.signal`,{signal:F.signal})})]})]}),F.error&&(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:LO(F.error).slice(0,1e3)}),F.status===`interrupted`&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-700 dark:text-amber-300`,children:i(`backgroundProcess.interruptedHint`)}),F.persistenceError&&(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-700 dark:text-amber-300`,children:i(`backgroundProcess.persistenceFailed`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-2.5`,children:[(0,$.jsxs)(`label`,{className:`relative min-w-[150px] flex-1`,children:[(0,$.jsx)(ln,{className:`pointer-events-none absolute left-2.5 top-2 h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),placeholder:i(`backgroundProcess.search`),"aria-label":i(`backgroundProcess.search`),className:`h-8 w-full rounded-md border border-border/60 bg-background/50 pl-8 pr-2 text-xs outline-none focus:border-accent-primary/60`})]}),(0,$.jsxs)(`select`,{"aria-label":i(`backgroundProcess.source`),value:C,onChange:e=>w(e.target.value),className:`h-8 rounded-md border border-border/60 bg-background px-2 text-xs outline-none focus:border-accent-primary/60`,children:[(0,$.jsx)(`option`,{value:`all`,children:i(`backgroundProcess.allSources`)}),(0,$.jsx)(`option`,{value:`stdout`,children:`stdout`}),(0,$.jsx)(`option`,{value:`stderr`,children:`stderr`})]}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:te,"aria-pressed":_,onClick:()=>v(e=>!e),children:[_?(0,$.jsx)(on,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(_?`backgroundProcess.resume`:`backgroundProcess.pause`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`${te} ${y?`border-accent-info/40 text-accent-info`:``}`,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,$.jsx)(go,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`backgroundProcess.follow`)]}),(0,$.jsx)(`button`,{type:`button`,className:te,disabled:!z.length,onClick:()=>void V(),"aria-label":i(`backgroundProcess.copy`),title:i(`backgroundProcess.copy`),children:j===`copied`?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:te,disabled:!z.length,onClick:H,"aria-label":i(`backgroundProcess.download`),title:i(`backgroundProcess.download`),children:(0,$.jsx)(tn,{className:`h-3.5 w-3.5`})}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:`${te} text-destructive`,disabled:L,onClick:()=>void ee(),children:[L?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(sn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(L?`backgroundProcess.status.stopping`:`backgroundProcess.stop`)]})]}),h&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-600 dark:text-amber-400`,children:i(`backgroundProcess.truncated`)}),_&&!I&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-muted/20 px-4 py-2 text-xs text-muted-foreground`,children:i(`backgroundProcess.paused`)}),p&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`backgroundProcess.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,className:te,onClick:()=>{v(!1),E(e=>e+1)},children:i(`backgroundProcess.retry`)})]}),(k||e.stopError)&&(0,$.jsx)(`p`,{role:`alert`,className:`bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:i(`backgroundProcess.stopFailed`)}),j&&(0,$.jsx)(`p`,{role:j===`failed`?`alert`:`status`,className:`px-4 py-1 text-xs text-muted-foreground`,children:i(j===`copied`?`backgroundProcess.copied`:`backgroundProcess.exportFailed`)}),(0,$.jsx)(`div`,{ref:N,"data-testid":`background-process-log-output`,"aria-label":i(`backgroundProcess.output`),role:`region`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.clientHeight-t.scrollTop>40&&b(!1)},className:`min-h-0 flex-1 overflow-auto bg-background/80 px-3 py-3 font-mono text-[11px] leading-5 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent-primary/50`,children:d&&!l.length?(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 py-12 text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),i(`backgroundProcess.loading`)]}):z.length?z.map(e=>(0,$.jsxs)(`div`,{"data-log-source":e.source,className:`grid grid-cols-[auto_auto_minmax(0,1fr)] items-start gap-x-2 hover:bg-muted/20`,children:[(0,$.jsx)(`span`,{className:`select-none whitespace-nowrap text-[10px] text-muted-foreground/70`,children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),(0,$.jsx)(`span`,{className:`select-none text-[10px] ${e.source===`stderr`?`text-amber-600 dark:text-amber-400`:`text-muted-foreground/60`}`,children:e.source}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${e.source===`stderr`?`text-amber-700 dark:text-amber-200`:`text-foreground/90`}`,children:e.line||`\xA0`})]},e.sequence)):!p&&(0,$.jsx)(`p`,{className:`py-12 text-center font-sans text-xs text-muted-foreground`,children:i(l.length?`backgroundProcess.noMatches`:`backgroundProcess.empty`)})}),(0,$.jsxs)(`footer`,{className:`flex flex-wrap justify-between gap-1 border-t border-border/50 px-4 py-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:i(`backgroundProcess.lineCount`,{count:z.length,total:l.length})}),(0,$.jsx)(`span`,{children:i(`backgroundProcess.exportHint`)})]})]})]})})}function HO({processes:e,loading:t,error:n,onRefresh:r,onClose:i,onKill:a}){let{t:o}=K(`agent`),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(100),[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{r()},[r]);let p=(0,Q.useMemo)(()=>{let t=s.trim().toLocaleLowerCase();return e.filter(e=>!t||[e.command,e.cwd,e.repositoryName,e.repositoryId,e.pid,o(`backgroundProcess.status.${e.status}`)].join(` `).toLocaleLowerCase().includes(t)).sort((e,t)=>Number(MO(e))-Number(MO(t))||t.startedAt-e.startedAt)},[e,s,o]);if(d)return(0,$.jsx)(BO,{process:e.find(e=>Gx(e)===Gx(d))??d,onClose:i,onBack:()=>f(null),onKill:a});let m=`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border/60 px-2 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:opacity-40`;return(0,$.jsx)(Hn,{open:!0,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Dn,{children:[(0,$.jsx)(Vn,{className:`z-[80]`}),(0,$.jsxs)(Un,{"data-testid":`background-process-history-modal`,className:`fixed left-1/2 top-1/2 z-[81] flex max-h-[85vh] w-[calc(100vw-2rem)] max-w-3xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/50 bg-popover text-foreground shadow-2xl focus:outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex items-start gap-3 border-b border-border/50 px-4 py-3`,children:[(0,$.jsx)(dc,{className:`mt-0.5 h-5 w-5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(Fn,{className:`text-sm font-semibold`,children:o(`backgroundProcess.history.title`)}),(0,$.jsx)(Mn,{className:`mt-1 text-xs text-muted-foreground`,children:o(`backgroundProcess.history.description`)})]}),(0,$.jsx)(Ln,{className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,"aria-label":o(`backgroundProcess.history.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 border-b border-border/50 px-4 py-3`,children:[(0,$.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(ln,{className:`pointer-events-none absolute left-2.5 top-2 h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:s,onChange:e=>{c(e.target.value),u(100)},placeholder:o(`backgroundProcess.history.search`),"aria-label":o(`backgroundProcess.history.search`),className:`h-8 w-full rounded-md border border-border/60 bg-background/50 pl-8 pr-2 text-xs outline-none focus:border-accent-primary/60`})]}),(0,$.jsx)(`button`,{type:`button`,className:m,disabled:t,onClick:()=>void r(),"aria-label":o(`backgroundProcess.history.refresh`),title:o(`backgroundProcess.history.refresh`),children:(0,$.jsx)(Js,{className:`h-3.5 w-3.5 ${t?`animate-spin`:``}`,"aria-hidden":!0})})]}),n&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`backgroundProcess.history.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,className:m,onClick:()=>void r(),children:o(`backgroundProcess.retry`)})]}),(0,$.jsxs)(`div`,{className:`min-h-[160px] overflow-y-auto p-2`,children:[p.slice(0,l).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":o(`backgroundProcess.open`,{command:e.command}),className:`flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-4 w-4 shrink-0 ${MO(e)?`text-muted-foreground`:`text-accent-info`}`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs text-foreground`,children:LO(e.command)}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:[LO(e.repositoryName??e.cwd),` · `,new Date(e.startedAt).toLocaleString(),` · PID `,e.pid]})]}),(0,$.jsx)(`span`,{className:`max-w-[35%] shrink-0 rounded-full px-2 py-0.5 text-[10px] ${e.status===`failed`?`bg-destructive/10 text-destructive`:MO(e)?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:o(`backgroundProcess.status.${e.status}`)}),(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]},Gx(e))),t&&!e.length?(0,$.jsxs)(`p`,{role:`status`,className:`flex justify-center gap-2 py-12 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),o(`backgroundProcess.history.loading`)]}):!n&&!p.length&&(0,$.jsx)(`p`,{className:`px-4 py-12 text-center text-xs text-muted-foreground`,children:o(s.trim()?`backgroundProcess.history.noMatches`:`backgroundProcess.history.empty`)}),p.length>l&&(0,$.jsx)(`div`,{className:`py-2 text-center`,children:(0,$.jsx)(`button`,{type:`button`,className:m,onClick:()=>u(e=>e+100),children:o(`backgroundProcess.history.showMore`)})})]}),(0,$.jsx)(`footer`,{className:`border-t border-border/50 px-4 py-2 text-[10px] text-muted-foreground`,children:o(`backgroundProcess.history.count`,{count:p.length})})]})]})})}function UO(){let[e,t]=(0,Q.useState)({available:{},availableIds:[],issues:{},launchDescriptors:{},loading:!0});return(0,Q.useEffect)(()=>{let e=!0;return fetch(`${He}/api/available-providers`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!e)return;let r={};for(let[e,t]of Object.entries(n))e===`tiers`||e===`providerIssues`||e===`launchDescriptors`||typeof t==`boolean`&&(r[e]=t);let i=n.providerIssues&&typeof n.providerIssues==`object`?n.providerIssues:{},a=n.launchDescriptors&&typeof n.launchDescriptors==`object`?n.launchDescriptors:{};t({available:r,availableIds:Object.keys(r).filter(e=>r[e]),issues:i,launchDescriptors:a,loading:!1})}).catch(()=>{e&&t(e=>({...e,loading:!1}))}),()=>{e=!1}},[]),e}function WO(e,t,n,r,i){let a=i.length-(r-n);return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,references:t.flatMap(e=>e.end<=n?[e]:e.start>=r?[{...e,start:e.start+a,end:e.end+a}]:[])}}var GO=[],KO=[];function qO({autoFocus:e=!1,hideProjectSelector:t=!1,queueEditRequest:n}){let{t:r}=K(`agent`),{active:i,messages:a,conversations:o,isStreaming:s,providersReady:c,draftPinnedProjectId:l,draftProvider:u,draftModel:d,draftTierLevel:f,draftEffort:p,setEffort:m,send:h,abort:g,cycleTier:_,setProvider:v,setModel:y,setPinnedProject:b,materializeDraftConversation:x,queuedMessages:S,editQueuedMessage:C,wasQueueConsumed:w}=lM(),T=(0,Q.useMemo)(()=>S.filter(e=>e.deliveryMode!==`steer`),[S]),{pendingCaptures:E,consumePendingCaptures:D,openBrowser:O}=Ux(),{processes:k,history:A=k,historyLoading:j=!1,historyError:M=null,refreshHistory:N,kill:P}=iS(),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),z=(0,Q.useMemo)(()=>[...k].sort((e,t)=>Number(MO(e))-Number(MO(t))||t.startedAt-e.startedAt).slice(0,4),[k]),{projects:B,activeProjectId:ee}=at(),V=i?.pinned_project_id??l??ee,H=i?.id??`__new-mission__`,te=si(),ne=(0,Q.useRef)(null);ne.current!==H&&(Yr(H),ne.current=H),Pr(H);let[re,ie]=(0,Q.useState)(null),ae=re&&re.key===H?re:null,oe=ae?ae.text:Tr.get(H)??``,se=ae?GO:Dr.get(H)??GO,ce=Er.get(H)??KO,le=(e,t=[])=>Fr(H,e,t),[ue,de]=(0,Q.useState)(null),fe=(e,t)=>{let n=Er.get(e)??KO;Ir(e,typeof t==`function`?t(n):t)},[pe,me]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(!1),_e=(0,Q.useRef)(!1),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),U=(0,Q.useMemo)(()=>[...new Map(se.map(({chip:e})=>[JSON.stringify([e.projectId,dS(e)]),e])).values()],[se]),[be,xe]=(0,Q.useState)(null),[Se,Ce]=(0,Q.useState)(0),[W,we]=(0,Q.useState)(!1),[Te,Ee]=(0,Q.useState)([]),[De,Oe]=(0,Q.useState)([]),Ae=ue!==null,je=(0,Q.useMemo)(()=>a.filter(e=>e.role===`user`).map(e=>e.content),[a]),Me=ae?.queueId??null,Ne=(0,Q.useRef)(``),Pe=Me===null?-1:T.findIndex(e=>e.queueId===Me),Fe=Pe>=0?T[Pe]:null,Ie=ae!==null;(0,Q.useEffect)(()=>{if(pe||he||Ie)return wy(H)},[H,pe,he,Ie]);let Le=c===!1||(i?!te.isEditable(i.id):!!te.current),Re=!Le&&!Ie,ze=i?.provider??u,{availableIds:Be}=UO(),G=(0,Q.useMemo)(()=>[ze,...Be].filter((e,t,n)=>n.indexOf(e)===t),[ze,Be]),Ve=i?i.pinned_project_id:l,Ue=Ve,We=be?.mode===`reference`?be.query.trim():``,Ge=`${Ue??``}:${We}`,[Ke,qe]=(0,Q.useState)({key:``,items:[]});(0,Q.useEffect)(()=>{let e=B.find(e=>e.id===Ue);if(!e||We.length<2)return;let t=new AbortController,n=setTimeout(()=>{let n=new URLSearchParams({kind:`find`,q:We,limit:`20`});fetch(`${He}/api/projects/${encodeURIComponent(e.id)}/code/discover?${n}`,{signal:t.signal}).then(async n=>{if(!n.ok)return;let r=await n.json();t.signal.aborted||qe({key:Ge,items:sS(e,r.matches??[])})}).catch(()=>{})},180);return()=>{clearTimeout(n),t.abort()}},[Ue,B,We,Ge]);let Je=(0,Q.useMemo)(()=>({projects:B,conversations:o,activeConversation:i,pinnedProjectId:Ue,activeProjectId:ee,tickets:Te,jobs:De,chips:U}),[B,o,i,Ue,ee,Te,De,U]),Ye=(0,Q.useMemo)(()=>be?[...ES(be.mode,Je),...be.mode===`reference`&&We.length>=2&&Ke.key===Ge?Ke.items:[]]:[],[be,Je,Ke,Ge,We]),Xe=(0,Q.useMemo)(()=>{if(!be)return[];let e=bS(Ye,be.query);return e.length>0?e:DS(be.mode,be.query)},[Ye,be]),Ze=be!==null&&!Ie,Qe=oe.trim().length>0||U.length>0,$e=[`accent-primary`,`accent-info`,`accent-highlight`],et=i?.id??null;(0,Q.useEffect)(()=>{I(null),R(null)},[et,V]),(0,Q.useEffect)(()=>{de(null),xe(null),we(!1),ie(null)},[et]),(0,Q.useEffect)(()=>{if(!Ue){Ee([]),Oe([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${He}/api/projects/${encodeURIComponent(Ue)}/tickets`),fetch(`${He}/api/projects/${encodeURIComponent(Ue)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;Ee(Array.isArray(r.tickets)?r.tickets:[]),Oe(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;Ee([]),Oe([])}})(),()=>{e=!1}},[Ue]),(0,Q.useEffect)(()=>{Ce(0)},[be?.mode,be?.query]),(0,Q.useEffect)(()=>{Se>=Xe.length&&Ce(Math.max(0,Xe.length-1))},[Se,Xe.length]),(0,Q.useEffect)(()=>{if(E.length===0)return;let e=D();e.length&&fe(H,t=>[...t,...e])},[E,D,H]);let tt=bD(ze),{models:q,efforts:nt,supportsImageInput:rt,customModelAliases:it}=tt,ot=(i?i.model:d)??q.find(e=>e.default)?.value??q[0]?.value??``,Y=lr(ze,ot),st=nt.filter(e=>Y.includes(e)),ct=i?i.reasoning_effort:p,lt=ct&&st.includes(ct)?ct:fr(ze,ot)??``,ut=e=>{Zr(e)},dt=async e=>{if(e.length===0)return;me(!0);let t=i;if(!t)try{t=await x(),ut(t.id)}catch(e){J.error(e instanceof Error?e.message:r(`workspace.uploadFailed`)),me(!1);return}for(let n of e){if(!rt&&n.type.startsWith(`image/`)){J.error(r(`imagesUnsupported`));continue}try{let e=await Ka(t.id,n);fe(t.id,t=>[...t,e])}catch(e){J.error(e instanceof Error?e.message:r(`workspace.uploadFailed`))}}me(!1)},ft=async e=>{try{i&&await Xa(i.id,e),fe(H,t=>t.filter(t=>t.id!==e))}catch(e){J.error(e instanceof Error?e.message:`Failed to remove attachment.`)}},pt=(e,t,n=se)=>{if(n.some(e=>t>e.start&&t<=e.end)){xe(null);return}let r=uS(e,t);xe(r),r&&we(!1)},ht=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,gt=e=>{requestAnimationFrame(()=>{ye.current?.focus(),ye.current?.setSelectionRange(e,e)})},_t=e=>{if(Ie)return;let t=ht(e),n=ye.current,r=n?.selectionStart??oe.length,i=n?.selectionEnd??r,a=WO(oe,se,r,i,t);le(a.text,a.references),de(null),we(!1),xe({mode:e,trigger:t,query:``,start:r,end:r+1}),gt(r+1)},vt=e=>{ye.current?.focus();let t=OS(oe,be,e),n=be?.start??oe.length,r=be?.end??n,i=t.text.slice(n,t.caret),{references:a}=WO(oe,se,n,r,i);if(e.chip){let t=n+i.indexOf(e.chip.token);a.push({key:crypto.randomUUID(),start:t,end:t+e.chip.token.length,chip:e.chip}),a.sort((e,t)=>e.start-t.start)}le(t.text,a),de(null),xe(null),we(!1),gt(t.caret)},yt=e=>{let t=T[e];t&&(Ne.current=t.text,ie({key:H,queueId:t.queueId,text:t.text}))},bt=e=>{Ae&&le(``),de(null),yt(e)};(0,Q.useEffect)(()=>{if(!n||n.conversationId!==i?.id)return;let e=T.findIndex(e=>e.queueId===n.queueId);e<0||(Ie?yt(e):bt(e),gt(T[e].text.length))},[n]);let xt=(e,t)=>{let n=t??oe;ie(null),e===`keep`&&le(n)},St=async()=>{let e=Fe,t=oe.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?xt(`restore`):(J.info(r(`queueEdit.dispatched`)),xt(`keep`))}catch{J.error(r(`queueEdit.saveFailed`))}};(0,Q.useEffect)(()=>{if(!ae||T.some(e=>e.queueId===ae.queueId))return;let e=oe!==Ne.current;w(ae.queueId)&&J.info(r(`queueEdit.dispatched`)),xt(e?`keep`:`restore`)},[Me,T,Ie]);let Ct=async()=>{if(Le||!Qe||_e.current)return;let e=oe.trim()||U.map(e=>e.token).join(` `),t={...ce.length?{attachmentIds:ce.map(e=>e.id)}:{},...U.length?{contextRefs:U.map(fS)}:{}},n=JSON.stringify([e,t]),i=Or.get(H),a=i?.signature===n?i:{signature:n,queueId:`q-${crypto.randomUUID()}`},o={text:oe,references:se,attachments:ce,submission:a};Lr(H,a),Br(H,o),xe(null),we(!1),de(null),_e.current=!0,ge(!0);try{let n=await h(e,{...t,queueId:a.queueId}),r=n.conversationId??H;if(!n.accepted){Lr(r,a),Vr(r,o);return}Lr(H,null),Lr(r,null)}catch(e){Vr(H,o),J.error(e instanceof Error?e.message:r(`queueEdit.saveFailed`))}finally{_e.current=!1,ge(!1)}},wt=e=>{if(je[e]===void 0){de(null);return}de(e),le(je[e])};return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[i===null&&!t&&(0,$.jsx)(dD,{pinnedProjectId:l,onSelect:e=>void b(e)}),(0,$.jsx)(uD,{label:r(`provider.label`),value:ze,options:G.map(e=>({value:e,label:r(`provider.${e}`,{defaultValue:e})})),icon:So,onSelect:e=>{v(e).catch(()=>J.error(r(`error.generic`)))},testId:`agent-provider-selector`}),(0,$.jsx)(vD,{models:q,model:i?i.model:d,status:tt.status,customModelAliases:it,onSelect:e=>{y(e).catch(()=>J.error(r(`error.generic`)))}}),st.length>0&&(0,$.jsx)(uD,{label:r(`effort.label`),value:lt,options:st.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ss,onSelect:e=>{m(e).catch(()=>J.error(r(`error.generic`)))},testId:`agent-effort-selector`}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(mD,{level:i?.tier_level??f,onCycle:()=>void _()})})]}),Ie&&Fe&&(0,$.jsxs)(`div`,{"data-testid":`queue-edit-chip`,className:`mb-1 flex items-center gap-1.5 rounded-md border border-accent-highlight/30 bg-accent-highlight/10 px-2 py-1 text-[11px] text-accent-highlight`,children:[(0,$.jsx)(an,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:r(`queueEdit.editing`,{n:Pe+1,m:T.length})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/45`,children:r(`queueEdit.hint`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>xt(`restore`),"aria-label":r(`queueEdit.cancel`),title:r(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]}),Ae&&(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,$.jsx)(hs,{className:`h-3 w-3`}),r(`history.hint`)]}),ce.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:ce.map(e=>(0,$.jsx)(oS,{conversationId:et,attachment:e,removeLabel:r(`close`),onRemove:()=>ft(e.id)},e.id))}),(k.length>0||et&&V)&&(0,$.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:[et&&V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>R({chatId:et,projectId:V}),"aria-label":r(`backgroundProcess.history.open`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-3 w-3`,"aria-hidden":!0}),r(`backgroundProcess.history.button`),A.length>0&&(0,$.jsx)(`span`,{className:`font-mono text-[10px]`,children:A.length})]}),z.map((e,t)=>(0,$.jsx)(jO,{process:e,accentVariant:$e[t%$e.length],onKill:P,onOpen:I},Gx(e)))]}),(0,$.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${Ie?`border-accent-highlight/50`:Ae?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{Re&&e.preventDefault()},onDrop:e=>{if(!Re)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&dt(t)},children:[Ze&&(0,$.jsx)(TD,{items:Xe,mode:be.mode,query:be.query,activeIndex:Se,onActiveIndexChange:Ce,onSelect:vt}),Re&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`input`,{ref:ve,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&dt(t),e.target.value=``}})}),!Ie&&(0,$.jsx)(ED,{open:W,canAttach:Re,uploading:pe,onToggle:()=>{we(e=>!e),xe(null)},onClose:()=>we(!1),onOpenMode:_t,onAttachFile:()=>{we(!1),ve.current?.click()},canBrowserCapture:ke()&&!!(Ue??ee),onOpenBrowser:()=>{we(!1),O()}}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(RD,{ref:ye,value:oe,references:Ie?[]:se,autoFocus:e,onChange:(e,t,n)=>{if(Ie){ie(t=>t&&{...t,text:e});return}Ae&&de(null),le(e,t),pt(e,n,t)},onSelect:e=>{Ie||pt(ye.current?.value??oe,e)},onKeyDown:e=>{if(e.nativeEvent.isComposing)return;if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(Ze){if(e.key===`ArrowDown`){e.preventDefault(),Xe.length>0&&Ce(e=>Math.min(Xe.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Xe.length>0&&Ce(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Xe[Se]??Xe[0];t&&vt(t);return}if(e.key===`Escape`){e.preventDefault(),xe(null);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Ie?St():Ct();return}if(e.key===`Escape`&&Ie){e.preventDefault(),e.stopPropagation(),xt(`restore`);return}let t=ye.current,n=t?.selectionStart===0&&t?.selectionEnd===0,r=t?.selectionStart===oe.length&&t?.selectionEnd===oe.length;if(e.key===`ArrowUp`){if(Ie){Fe!==null&&oe===Fe.text&&n&&Pe>0&&(e.preventDefault(),yt(Pe-1));return}if(T.length>0){n&&(e.preventDefault(),bt(T.length-1));return}!Ae&&oe===``&&je.length>0?(e.preventDefault(),wt(je.length-1)):Ae&&(e.preventDefault(),wt(Math.max(0,ue-1)));return}if(e.key===`ArrowDown`){if(Ie){Fe!==null&&oe===Fe.text&&r&&(e.preventDefault(),Pe<T.length-1?yt(Pe+1):xt(`restore`));return}if(T.length>0)return;Ae&&(e.preventDefault(),ue<je.length-1?wt(ue+1):(de(null),le(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Ae&&de(null)},onPaste:e=>{if(!Re)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),dt(t))},disabled:Le,placeholder:r(Le?`noProvider.placeholder`:s?`queue.placeholder`:`composerPlaceholder`),title:Ie?r(`queueEdit.hint`):Ae?r(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-0 w-full resize-y overflow-y-auto bg-transparent text-sm outline-none ${Ae?`italic text-foreground/50`:`text-foreground`}`},H)}),s&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":r(`stop`),title:r(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(sn,{className:`h-4 w-4`,fill:`currentColor`})}),Ie?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void St(),disabled:Le||!oe.trim(),"aria-label":r(`queueEdit.save`),title:r(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,$.jsx)(Ht,{className:`h-4 w-4`})}):s?(0,$.jsx)(`button`,{type:`button`,onClick:Ct,disabled:Le||!Qe||he,"aria-label":r(`queue.send`),title:r(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ct,disabled:Le||!Qe||he,"aria-label":r(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})})]}),Ve&&(0,$.jsx)(xD,{projectId:Ve}),F&&F.chatId===et&&F.projectId===V&&(0,$.jsx)(BO,{process:A.find(e=>Gx(e)===Gx(F))??F,onClose:()=>I(null),onKill:P}),L&&L.chatId===et&&L.projectId===V&&(0,$.jsx)(HO,{processes:A,loading:j,error:M,onRefresh:N,onClose:()=>R(null),onKill:P})]})}function JO({active:e,inset:t=-4,radius:n=`9999px`,className:r,fadeInMs:i=350,fadeOutMs:a=350}){let o=dy();return(0,$.jsx)(f_,{children:e&&(0,$.jsxs)(fy.span,{"aria-hidden":!0,"data-testid":`builder-halo`,"data-reduced-motion":o?`true`:void 0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{duration:i/1e3,ease:`easeOut`}},exit:{opacity:0,scale:1.15,transition:{duration:a/1e3,ease:`easeInOut`}},style:{inset:t},className:`pointer-events-none absolute ${r??``}`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 overflow-hidden`,style:{borderRadius:n,padding:`2px`,WebkitMask:`linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)`,WebkitMaskComposite:`xor`,maskComposite:`exclude`},children:(0,$.jsx)(`span`,{className:`absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2 ${o?``:`animate-[builder-halo-spin_2.6s_linear_infinite]`}`,style:{background:`conic-gradient(from 0deg, transparent 0%, color-mix(in srgb, var(--color-accent-primary) 90%, transparent) 18%, color-mix(in srgb, var(--color-accent-highlight) 85%, transparent) 32%, transparent 55%)`}})}),(0,$.jsx)(`span`,{className:`absolute inset-0 opacity-60`,style:{borderRadius:n,boxShadow:`0 0 12px 2px color-mix(in srgb, var(--color-accent-primary) 45%, transparent), inset 0 0 8px 1px color-mix(in srgb, var(--color-accent-highlight) 30%, transparent)`}})]})})}var YO=`specrails-desktop:effects`,XO=`specrails:effects-changed`,ZO={agentThinkingHalo:!0},QO=null;function $O(){try{let e=localStorage.getItem(YO);if(!e)return ZO;let t=JSON.parse(e);return{...ZO,...typeof t.agentThinkingHalo==`boolean`?{agentThinkingHalo:t.agentThinkingHalo}:{}}}catch{return ZO}}function ek(){return QO||=$O(),QO}function tk(e){let t={...ek(),...e};QO=t;try{localStorage.setItem(YO,JSON.stringify(t))}catch{}try{window.dispatchEvent(new CustomEvent(XO))}catch{}return t}function nk(e){let t=()=>{QO=null,e()};return window.addEventListener(XO,t),window.addEventListener(`storage`,t),()=>{window.removeEventListener(XO,t),window.removeEventListener(`storage`,t)}}function rk(){return(0,Q.useSyncExternalStore)(nk,ek,()=>ZO)}function ik({active:e,radius:t=`0.75rem`,inset:n=-3}){let{agentThinkingHalo:r}=rk();return r?(0,$.jsx)(`span`,{"data-testid":`agent-thinking-halo`,"data-active":e,className:`contents`,children:(0,$.jsx)(JO,{active:e,radius:t,inset:n,fadeInMs:450,fadeOutMs:800})}):null}var ak=e=>e===`running`||e===`queued`;function ok(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${n%60}m`}function sk(){try{return qe()}catch{return null}}var ck=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function lk(e,t,n){let{live:r}=n,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(()=>Date.now());(0,Q.useEffect)(()=>{let n=!1;return fetch(`${He}/api/projects/${e}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{if(n)return;let t=e?.job;t&&(s(typeof t.status==`string`?t.status:null),l(ck(t.started_at)),d(ck(t.finished_at)),typeof t.total_cost_usd==`number`&&p(t.total_cost_usd),typeof t.num_turns==`number`&&h(t.num_turns),_(t.loopPaused===!0),y(typeof t.loopPauseReason==`string`?t.loopPauseReason:null)),a(!0)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t,r]);let S=ak(o)&&u===null,C=sk(),w=(0,Q.useId)();return(0,Q.useEffect)(()=>{if(!C||!r)return;let e=`run-vitals-${t}-${w}`;return C.registerHandler(e,e=>{let n=e;if(n?.type===`loop.run_paused`&&n.loopRunId===t){_(!0),y(typeof n.reason==`string`?n.reason:null),s(`running`),d(null);return}if((n?.type===`loop.run_resumed`||n?.type===`loop.run_completed`)&&n.loopRunId===t){_(!1),y(null);return}n?.jobId===t&&(n.type===`job.turn_done`?(typeof n.totals?.total_cost_usd==`number`&&p(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&h(n.totals.num_turns)):n.type===`job.finalized`&&(typeof n.totals?.total_cost_usd==`number`&&p(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&h(n.totals.num_turns),typeof n.status==`string`&&s(n.status),_(!1),y(null),d(ck(n.timestamp)??Date.now())))}),()=>C.unregisterHandler(e)},[C,r,t,w]),(0,Q.useEffect)(()=>{if(!r||!S||c===null)return;let e=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(e)},[r,S,c]),{status:o,paused:g,pausedReason:v,running:S,elapsedMs:c===null?null:Math.max(0,(u??b)-c),costUsd:f,numTurns:m,loaded:i}}function uk(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var dk=15e3;function fk(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function pk(e){let{projectId:t,jobId:n,timeoutMs:r=dk}=e,i=t?`${He}/api/projects/${t}`:nt(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:fk(r)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(r/1e3)}s`:t?.message||String(e),httpStatus:null}}if(a.ok){let e=`canceled`;try{let t=await a.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let o=typeof a.status==`number`?a.status:null,s=o==null?``:` (HTTP ${o})`,c=``;try{typeof a.text==`function`?c=await a.text():typeof a.json==`function`&&(c=JSON.stringify(await a.json()))}catch{}let l=c.slice(0,200).trim();try{let e=JSON.parse(c);e&&typeof e.error==`string`&&e.error&&(l=e.error)}catch{}let u=typeof a.statusText==`string`?a.statusText:``;return{ok:!1,error:l?`${l}${s}`:`HTTP ${o??`?`}${u?` ${u}`:``}`,httpStatus:o}}var mk=null;function hk(e){mk=e}function gk(e,t){mk?.(e,t)}var _k=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-BCxue_Do.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([6,1,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76]))),vk={building:nn,on_review:nn,pr_draft:R,pr_ready:R,no_changes:Mo,completed:Mo,pr_closed:en,superseded:R,implementation_failed:fn,pr_failed:fn,merged:ls,discarded:en},yk={building:`text-accent-primary/70`,on_review:`text-accent-primary`,pr_draft:`text-accent-info`,pr_ready:`text-accent-info`,no_changes:`text-accent-success`,completed:`text-accent-success`,pr_closed:`text-accent-warning`,superseded:`text-foreground/40`,implementation_failed:`text-destructive`,pr_failed:`text-destructive`,merged:`text-accent-success`,discarded:`text-foreground/40`};function bk({envelope:e}){let{t}=K(`agent`),n=ht(e);return n.units.length===0&&!n.partial?null:(0,$.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`agent-pr-unit-evidence`,children:[n.partial&&(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-accent-warning`,children:t(`prCard.partialSummary`,{succeeded:n.succeededCount,failed:n.failedCount,total:n.totalCount})}),n.units.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.units.map(e=>{let n=e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded,r=e.deliveryOutcome===`no_changes`||e.changed===!1,i=e.deliveryOutcome===`blocked`,a=t(n?`prCard.unit.failed`:i?`prCard.unit.blocked`:r?`prCard.unit.noChanges`:`prCard.unit.succeeded`);return(0,$.jsxs)(`span`,{title:e.failureCode??e.branch,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px]`,n?`border-destructive/35 bg-destructive/10 text-destructive`:i?`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`:`border-accent-success/30 bg-accent-success/10 text-accent-success`),children:[`#`,e.ticketId,` · `,a]},`${e.ticketId}-${e.runId??e.branch}`)})})]})}function xk({prDeliveryId:e,projectId:t}){let{t:n}=K(`agent`),r=v(),{activeProjectId:i,setActiveProjectId:a}=at();return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let n=`/review/${e}`;i!==t&&(gk(t,n),a(t)),r(n)},"data-testid":`agent-pr-open-packet`,"data-agent-interactive":!0,title:n(`prCard.openReviewTooltip`),className:`inline-flex items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-2 py-1 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/20`,children:[(0,$.jsx)(Qo,{className:`h-3 w-3`}),n(`prCard.openReview`)]})}function Sk(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function Ck({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=K(`agent`),s=lk(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:ok(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,Q.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`pr-run-log-chip`,onClick:e=>{e.stopPropagation(),i(t)},title:o(`prCard.viewLog`,{ref:c}),"aria-label":o(`prCard.viewLog`,{ref:c}),className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 py-px align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,s.paused?`border-accent-warning/45 bg-accent-warning/10 text-accent-warning hover:-translate-y-px hover:border-accent-warning/65 hover:bg-accent-warning/15 hover:shadow-sm`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:-translate-y-px hover:border-accent-info/60 hover:bg-accent-info/15 hover:shadow-sm`),children:[(s.paused||s.running&&r)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 shrink-0 animate-pulse rounded-full`,s.paused?`bg-accent-warning`:`bg-accent-info`)}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,$.jsx)($s,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,$.jsxs)($.Fragment,{children:[d,(0,$.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,$.jsxs)($.Fragment,{children:[d,(0,$.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function wk({envelope:e}){let{t}=K(`agent`),n=u(),{projects:r}=at(),{applyPrDecisionSnapshot:i}=lM(),{openWebView:a,canOpenWebView:o}=Se(),{openRef:s}=_b(),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),k=D??e,A=At(k.projectId).has(k.prDeliveryId),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)({}),[I,L]=(0,Q.useState)(null),{decision:z,prUrl:B,prState:ee}=k,V=!!k.repositoryDeliveries?.length,H=ht(k),te=ft(k.statusCode,k.statusDetail),ne=k.operation==null&&te,re=r.find(e=>e.id===k.projectId)?.name??k.projectId,ie=z===`pr_draft`&&!B,ae=z===`building`&&ee===`pr-created`&&!!k.branch,se=k.prNumber?`#${k.prNumber}`:B?Sk(B):null,ce=H.terminal,le=dt(k.statusCode)?t(`common:prDeliveryStatus.${k.statusCode}`):null,ue=H.partial&&H.deliverableCount>0&&(z===`on_review`||z===`pr_draft`&&!B);(0,Q.useEffect)(()=>{O(null)},[e]),(0,Q.useEffect)(()=>{l(null),m(!1),g(!1),v(!1),b(!1),S(!1),w(!1),E(!1)},[z,B,k.prDeliveryId]);let de=(0,Q.useCallback)((e,t)=>{P(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),fe=async e=>{if(!I){L(e);try{let n=await pk({projectId:k.projectId,jobId:e,kind:`loop-run`});n.ok?J.info(t(`prCard.stopExecutionSent`)):J.error(t(`prCard.stopExecutionFailed`),{description:n.error})}finally{L(null)}}},pe=async(e,n)=>{if(d||c||k.operation||V&&!n&&[`create-pr`,`merge-local`,`publish`,`poll-merge`,`reopen`,`acknowledge-no-changes`].includes(e))return;let r=k.repositoryDeliveries?.find(e=>e.repositoryId===n),a=r?.integrationBranch??r?.baseBranch??k.baseBranch;l(e);try{let r=await oo(k.projectId,{prDeliveryId:k.prDeliveryId,action:e,expectedDecision:z,...n?{repositoryId:n}:{}}),o=null;if(r.snapshot){let e=so(k,r.snapshot);o=i(e),o!==`stale`&&O(e)}if(o===`stale`){J.info(t(`prCard.alreadyResolved`));return}if(r.kind===`recovering`)J.info(t(`common:prRecovery.inProgress`));else if(r.kind===`busy`)J.info(t(`prCard.operation.${r.operation??`inProgress`}`));else if(r.kind===`stale`)J.info(t(`prCard.alreadyResolved`));else if(r.kind===`blocked`)J.warning(r.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:r.base||a}):t(`prCard.mergeLocalBlockedBranch`,{base:r.base||a,current:r.current??`?`}));else if(r.kind===`failed`)J.error(t(`prCard.actionFailed`),{description:r.detail});else if(r.kind===`ok`&&e===`recover-and-retry`)if(r.deliveryVerified){let e=(r.verifiedSha??r.snapshot?.deliverySha??``).slice(0,8);J.success(t(`prCard.recoverAndRetryVerified`,{sha:e}))}else r.recoveryUnavailable||r.snapshot?.statusCode===`recovery_unavailable`?J.info(t(`prCard.recoveryUnavailable`),{description:t(`prCard.recoveryUnavailableBody`)}):J.warning(t(`prCard.recoveryStillBlocked`),{description:r.detail??void 0});else if(r.kind===`ok`&&e===`create-pr`&&H.retryablePush&&r.deliveryVerified){let e=(r.verifiedSha??r.snapshot?.deliverySha??k.deliverySha??``).slice(0,8);J.success(t(r.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(r.kind===`ok`&&e===`create-pr`&&r.detail)J.error(t(`prCard.deliveryNeedsAttention`),{description:r.detail});else if(r.kind===`ok`&&e===`poll-merge`&&r.deliveryVerified===!1)J.warning(t(`prCard.commitMissingRetry`));else if(r.kind===`ok`&&e===`poll-merge`&&r.deliveryVerified&&!r.merged){let e=(r.verifiedSha??r.snapshot?.deliverySha??k.deliverySha??``).slice(0,8);J.success(t(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!r.merged&&r.decision!==`pr_closed`?J.info(t(`prCard.notMergedYet`)):e===`merge-local`&&r.kind===`ok`&&r.decision===`merged`&&J.success(t(`prCard.mergedLocally`,{base:a}));r.kind===`ok`&&(e===`create-pr`||e===`discard`||e===`merge-local`||e===`recover-and-retry`)&&vt(k.projectId)}catch(e){J.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{l(null)}},he=async e=>{if(!(V&&!e)&&!(c||d||k.operation)){f(!0);try{let n=await(e?co(k.projectId,k.prDeliveryId,e):co(k.projectId,k.prDeliveryId));n.kind===`ok`?(J.success(t(`prCard.checkoutSuccess`,{branch:n.branch??pt(k)??``})),n.cleanupWarnings.length>0&&J.warning(t(`prCard.cleanupIncomplete`,{count:n.cleanupWarnings.length}),{description:n.cleanupWarnings.join(`
40
+ `)}),vt(k.projectId)):n.kind===`recovering`?J.info(t(`common:prRecovery.inProgress`)):n.error===`checkout_dirty`?J.warning(t(`prCard.checkoutDirtyTitle`),{description:t(`prCard.checkoutDirtyBody`)}):n.error===`checkout_not_deliverable`?J.warning(t(`prCard.checkoutNotDeliverableTitle`),{description:t(`prCard.checkoutNotDeliverableBody`)}):n.error===`checkout_safety_unknown`?J.warning(t(`prCard.checkoutSafetyUnknownTitle`),{description:t(`prCard.checkoutSafetyUnknownBody`)}):J.warning(t(`prCard.checkoutFailed`),{description:n.detail})}catch(e){J.error(t(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{f(!1)}}},ge=async()=>{let e=H.recoveryWorktreePaths;if(e.length===0){J.info(t(`prCard.localResultUnavailableHere`));return}let n=e.join(`
41
+ `),r=!1;try{await navigator.clipboard.writeText(n),r=!0}catch{}try{me()&&await oe(e[0])}catch{}r?J.success(t(`prCard.localResultPathCopied`),{description:n}):J.info(t(`prCard.localResultPath`),{description:n})},_e=(e,t)=>{o&&(e.preventDefault(),e.stopPropagation(),a(t))},ye=k.ticketIds.length>0&&(0,$.jsx)($.Fragment,{children:k.ticketIds.map(e=>(0,$.jsxs)(Tx,{refTarget:{kind:`ticket`,ticketId:e},onOpen:e=>void s(k.projectId,e),children:[`#`,e]},e))}),U=k.runIds??[],be=e=>U.length===1&&k.ticketIds.length>1?k.ticketIds.map(e=>`#${e}`).join(` `):k.ticketIds[e]==null?null:`#${k.ticketIds[e]}`,xe=U.find(e=>N[e]?.paused)??null,Ce=xe?N[xe]?.pausedReason??null:null,W=U.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,"data-testid":`pr-run-log-chips`,children:U.map((e,t)=>(0,$.jsx)(Ck,{projectId:k.projectId,runId:e,ticketLabel:be(t),live:z===`building`,onOpen:M,onVitals:de},e))}),we=z===`building`&&xe!==null,Te=xe?be(U.indexOf(xe))??xe.slice(0,8):null,Ee=j&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(_k,{jobId:j,projectId:k.projectId,onClose:()=>M(null)})});if(z===`building`)return(0,$.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:`rounded-xl border border-border/60 bg-card/80 px-3.5 py-2.5 text-xs text-foreground/60 shadow-lg backdrop-blur-xl`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[we?(0,$.jsx)(fn,{className:`h-3.5 w-3.5 text-accent-warning`}):ae?(0,$.jsx)(R,{className:`h-3.5 w-3.5 text-accent-info`}):(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin text-accent-primary/70`}),(0,$.jsx)(`span`,{className:X(!ae&&!we&&`animate-pulse`,we&&`text-accent-warning`),children:t(we?`prCard.title.paused`:ae?`prCard.title.buildingExistingPr`:`prCard.title.building`)})]}),ye&&(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:ye}),ae&&(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:[B?(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,onClick:e=>_e(e,B),title:B,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/60 hover:bg-accent-info/15`,children:[(0,$.jsx)(R,{className:`h-3 w-3`}),se??t(`prCard.openPr`),(0,$.jsx)(Vt,{className:`h-2.5 w-2.5 opacity-60`})]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info`,children:[(0,$.jsx)(R,{className:`h-3 w-3`}),se??t(`prCard.existingPr`)]}),(0,$.jsxs)(`span`,{title:t(`git.branch`),className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,$.jsx)(nn,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`truncate`,children:k.branch})]})]}),we&&xe&&(0,$.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 px-2 py-1.5 text-[11px] text-accent-warning`,"data-testid":`pr-run-paused-actions`,children:[(0,$.jsx)(fn,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:Ce??void 0,children:[Te?t(`prCard.pausedForRun`,{ref:Te}):t(`prCard.paused`),Ce?`: ${Ce}`:``]}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:e=>{e.stopPropagation(),M(xe)},className:`inline-flex items-center gap-1 rounded-md border border-accent-warning/40 bg-surface/70 px-2 py-0.5 font-medium text-accent-warning transition-colors hover:bg-accent-warning/15`,children:[(0,$.jsx)(on,{className:`h-3 w-3`}),t(`prCard.resume`)]}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:I===xe,onClick:e=>{e.stopPropagation(),fe(xe)},className:`inline-flex items-center gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-0.5 font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-default disabled:opacity-60`,children:[I===xe?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(sn,{className:`h-3 w-3`}),t(`prCard.stopExecution`)]})]}),W&&(0,$.jsx)(`div`,{className:`pl-[22px]`,children:W}),(0,$.jsx)(`p`,{className:`mt-1 pl-[22px] text-[11px] leading-4 text-foreground/40`,children:t(ae?`prCard.buildingExistingPrHint`:`prCard.buildingHint`)}),Ee]});let De=vk[z],Oe=H.superseded?t(`prCard.title.superseded`):H.noChanges?t(`prCard.title.no_changes`):H.deliveryBlocked?t(`prCard.title.delivery_blocked`):H.retryablePush?t(`prCard.title.update_failed`):H.closed?t(`prCard.title.pr_closed`):H.partial?t(`prCard.title.partial`):k.statusCode===`existing_pr_updated`?t(`prCard.title.existing_pr_updated`):t(ie?`prCard.title.pr_draft_degraded`:`prCard.title.${z}`),ke=`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-2.5 py-1 text-xs font-medium text-white transition-colors hover:bg-accent-primary/90 disabled:cursor-default disabled:opacity-60`,Ae=X(`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:cursor-default disabled:opacity-60`,`border-border/60 text-foreground/70 hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),je=c!==null||d||k.operation!=null,Me=!!k.operation||ne||H.partial||H.deliveryBlocked||H.retryablePush||H.retryablePrCreation||H.closed||H.implementationFailed,Ne=(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}),Pe=(e,t)=>!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void pe(e),disabled:je,"data-agent-interactive":!0,className:ke,children:[c===e&&Ne,t]}),Fe=ve&&n&&!H.terminal?(0,$.jsx)(xk,{prDeliveryId:k.prDeliveryId,projectId:k.projectId}):null,Ie=pt(k),Le=Ie&&!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void he(),disabled:je,"data-testid":`agent-pr-checkout`,"data-agent-interactive":!0,title:t(`prCard.checkoutTooltip`,{branch:Ie}),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`,children:[d?Ne:(0,$.jsx)(nn,{className:`h-3 w-3`}),t(`prCard.checkout`)]}),Re=H.recoveryWorktreePaths.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void ge(),disabled:je,"data-testid":`agent-pr-inspect-local-result`,"data-agent-interactive":!0,title:t(`prCard.inspectLocalResultTooltip`),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`,children:[(0,$.jsx)(as,{className:`h-3 w-3`,"aria-hidden":!0}),t(`prCard.inspectLocalResult`)]}),ze=H.recoveryRecheck,Be=(H.manualRecovery||ze)&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!0),disabled:je,"data-testid":ze?`agent-pr-recheck-recovery`:`agent-pr-recover-and-retry`,"data-agent-interactive":!0,className:ze?`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`:ke,children:[c===`recover-and-retry`?Ne:(0,$.jsx)(Zs,{className:`h-3 w-3`,"aria-hidden":!0}),t(ze?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)]}),G=!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),disabled:je,"data-testid":`agent-pr-merge-local`,"data-agent-interactive":!0,title:t(`prCard.mergeLocalTooltip`,{base:k.baseBranch}),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-2 py-1 text-[11px] font-medium text-accent-success transition-colors hover:bg-accent-success/20 disabled:pointer-events-none disabled:opacity-50`,children:[c===`merge-local`&&Ne,t(`prCard.mergeLocal`)]}),Ve=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`discard`&&Ne,t(`prCard.discard`)]}),He=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`dismiss`&&Ne,t(`prCard.dismiss`)]}),Ue=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`discard`&&Ne,t(`prCard.discardLocalResult`)]}),We=!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>S(!0),disabled:je,"data-agent-interactive":!0,className:ke,children:[c===`acknowledge-no-changes`&&Ne,t(`prCard.markDone`)]}),Ge=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`discard`&&Ne,t(`prCard.refine`)]}),Ke=B&&(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,onClick:e=>_e(e,B),title:B,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/50 hover:bg-accent-info/10`,children:[(0,$.jsx)(R,{className:`h-3 w-3`}),se??t(`prCard.openPr`),(0,$.jsx)(Vt,{className:`h-2.5 w-2.5 opacity-60`})]});return(0,$.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:X(`rounded-xl border border-border/60 bg-card/80 px-3.5 py-3 shadow-lg backdrop-blur-xl`,z===`merged`&&`border-accent-success/30`,z===`completed`&&`border-accent-success/30`,z===`discarded`&&`opacity-70`),children:[Me&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-label":k.operation?t(`prCard.operation.${k.operation}`):ne?t(`common:prRecovery.interrupted`):Oe,className:`sr-only`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(De,{className:X(`h-4 w-4 shrink-0`,yk[z])}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:Oe}),(0,$.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:re,children:re}),(0,$.jsx)(`span`,{className:`shrink-0 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-foreground/60`,children:t(`prCard.rail`,{index:k.railIndex+1})})]}),(0,$.jsx)(Mt,{deliveryId:k.prDeliveryId,repositories:k.repositoryDeliveries,busy:!!c||d||!!k.operation,onAct:pe,onCheckout:he}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[!V&&(0,$.jsxs)(`span`,{title:t(`prCard.base`),className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,$.jsx)(nn,{className:`h-3 w-3 text-accent-primary/70`}),`→ `,k.baseBranch]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[11px] text-foreground/70`,children:[(0,$.jsx)(F,{className:`h-3 w-3 text-accent-secondary/80`}),t(`prCard.specCount`,{count:k.ticketIds.length})]}),ye,Ke,k.deliverySha&&(0,$.jsxs)(`span`,{"data-testid":`agent-pr-delivery-sha`,title:k.deliverySha,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,k.deliveryOutcome===`delivered`?`border-accent-success/35 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/65`),children:[(0,$.jsx)(Mo,{className:`h-3 w-3`}),t(`prCard.deliveryCommit`,{sha:k.deliverySha.slice(0,8)})]})]}),W,k.operation&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-[11px] font-medium text-accent-info`,"data-testid":`agent-pr-operation`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`prCard.operation.${k.operation}`)]}),ne&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-info`,"data-testid":`agent-pr-recovery-interrupted`,children:[(0,$.jsx)(Zs,{className:`mt-px h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t(`common:prRecovery.interrupted`)})]}),(0,$.jsx)(bk,{envelope:k}),le&&(0,$.jsx)(`p`,{className:`mt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,"data-testid":`agent-pr-status-code`,children:le}),!ce&&H.deliveryBlocked&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[H.recoveryUnavailable?t(`prCard.recoveryUnavailableBody`):t(H.partial?`prCard.partialDeliveryBlockedNote`:`prCard.deliveryBlockedNote`),k.statusDetail&&!te&&!H.recoveryUnavailable?(0,$.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:k.statusDetail}):null]})]}),!ce&&H.recoveryUnavailable&&k.statusDetail&&!te&&(0,$.jsxs)(`details`,{className:`mt-1.5 text-[10px] leading-4 text-foreground/55`,"data-testid":`agent-pr-recovery-technical-detail`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground/65`,children:t(`prCard.recoveryDetailSummary`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:k.statusDetail})]}),!ce&&H.retryablePush&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[t(`prCard.retryPushNote`),k.statusDetail&&!te?(0,$.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:k.statusDetail}):null]})]}),k.statusDetail&&!te&&!H.deliveryBlocked&&!H.retryablePush&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/45`,"data-testid":`agent-pr-status-detail`,children:k.statusDetail}),!ce&&!B&&(ee===`pushed`||ee===`local-only`)&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),t(ee===`local-only`?`prCard.degraded.localOnly`:`prCard.degraded.pushed`)]}),H.cleanupWarnings.length>0&&(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-accent-warning/35 bg-accent-warning/10 px-2 py-1.5 text-[11px] text-accent-warning`,"data-testid":`agent-pr-cleanup-warning`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:t(`prCard.cleanupIncomplete`,{count:H.cleanupWarnings.length})}),(0,$.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4 text-foreground/60`,children:H.cleanupWarnings.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}-${e}`))})]}),H.safetyArchives.length>0&&(0,$.jsxs)(`details`,{className:`mt-2 rounded-md border border-accent-info/25 bg-accent-info/5 px-2 py-1.5 text-[11px] text-foreground/65`,"data-agent-interactive":!0,"data-testid":`agent-pr-safety-archives`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-accent-info`,children:t(`prCard.safetyArchiveTitle`,{count:H.safetyArchives.length})}),(0,$.jsx)(`p`,{className:`mt-1 leading-4`,children:t(`prCard.safetyArchiveHint`)}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground/50`,children:H.safetyArchives.map(e=>(0,$.jsx)(`li`,{className:`break-all`,children:e},e))})]}),(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5`,children:[H.noChanges&&!ce&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(Mo,{className:`h-3.5 w-3.5`}),H.continuation?t(`prCard.noChangesExisting`):t(`prCard.noChangesNote`)]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:H.continuation?He:(0,$.jsxs)($.Fragment,{children:[We,Ge]})})]}),!ce&&H.deliveryBlocked&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Re,Be,H.continuation?H.hasDiscardableRecoveryResult?Ue:He:Ve]}),!ce&&H.retryablePush&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retryPush`)),H.continuation?He:Ve]}),!ce&&H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retryPr`)),G,H.continuation?He:Ve]}),!ce&&H.closed&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`reopen`,t(`prCard.reopen`)),H.continuation?He:Ve]}),!ce&&ue&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.createPartialPr`,{count:H.deliverableCount})),H.continuation?He:Ve]}),z===`on_review`&&!H.noChanges&&!H.partial&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Fe,Le,Pe(`create-pr`,t(`prCard.createPr`)),G,H.continuation?He:Ve]}),z===`pr_draft`&&!ie&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`publish`,t(`prCard.publish`)),H.continuation?He:Ve]}),ie&&!ue&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retryPr`)),G,H.continuation?He:Ve]}),z===`pr_ready`&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`poll-merge`,t(`prCard.verifyPr`)),H.continuation?He:Ve]}),z===`pr_failed`&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retry`)),!B&&G,H.continuation?He:Ve]}),z===`implementation_failed`&&H.implementationFailed&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] leading-4 text-destructive`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),t(`prCard.implementationFailedNote`)]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:H.continuation?He:Ve})]}),z===`merged`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(Mo,{className:`h-3.5 w-3.5`}),t(`prCard.mergedNote`)]}),z===`discarded`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,$.jsx)(en,{className:`h-3.5 w-3.5`}),t(`prCard.discardedNote`)]}),z===`completed`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(Mo,{className:`h-3.5 w-3.5`}),t(`prCard.completedNote`)]}),z===`superseded`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5`}),t(`prCard.supersededNote`)]})]},`${z}-${B??``}`),(0,$.jsx)(Hn,{open:!V&&y,onOpenChange:b,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-merge-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.mergeLocalTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.mergeLocalBody`,{base:k.baseBranch})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>b(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-merge-local-confirm-btn`,onClick:()=>{b(!1),pe(`merge-local`)},children:t(`prCard.mergeLocal`)})]})]})}),(0,$.jsx)(Hn,{open:T,onOpenChange:E,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-recover-and-retry-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(ze?`prCard.confirm.recheckRecoveryTitle`:`prCard.confirm.recoverAndRetryTitle`)}),(0,$.jsx)(Mn,{children:t(ze?`prCard.confirm.recheckRecoveryBody`:`prCard.confirm.recoverAndRetryBody`,{branch:k.branch??``})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>E(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-recover-and-retry-confirm-btn`,onClick:()=>{E(!1),pe(`recover-and-retry`)},children:t(ze?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)})]})]})}),(0,$.jsx)(Hn,{open:p,onOpenChange:m,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-discard-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(z===`implementation_failed`?`prCard.confirm.implementationFailedDiscardTitle`:`prCard.confirm.freshDiscardTitle`)}),(0,$.jsx)(Mn,{children:t(z===`implementation_failed`?`prCard.confirm.implementationFailedDiscardBody`:`prCard.confirm.freshDiscardBody`)}),A&&(0,$.jsx)(`p`,{className:`mt-2 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-2 py-1.5 text-xs text-accent-warning`,"data-testid":`agent-pr-discard-stacked-note`,children:t(`prCard.discardStackedNote`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>m(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:je,"data-testid":`agent-pr-discard-confirm-btn`,onClick:()=>{m(!1),pe(`discard`)},children:t(`prCard.discard`)})]})]})}),(0,$.jsx)(Hn,{open:h,onOpenChange:g,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-dismiss-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.dismissTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.dismissBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>g(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-dismiss-confirm-btn`,onClick:()=>{g(!1),pe(`dismiss`)},children:t(`prCard.dismiss`)})]})]})}),(0,$.jsx)(Hn,{open:_,onOpenChange:v,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-discard-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.discardLocalTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.discardLocalBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>v(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:je,"data-testid":`agent-pr-discard-local-confirm-btn`,onClick:()=>{v(!1),pe(`discard`)},children:t(`prCard.discardLocalResult`)})]})]})}),(0,$.jsx)(Hn,{open:!V&&x,onOpenChange:S,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-no-changes-done-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.noChangesDoneTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.noChangesDoneBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>S(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-no-changes-done-confirm-btn`,onClick:()=>{S(!1),pe(`acknowledge-no-changes`)},children:t(`prCard.markDone`)})]})]})}),(0,$.jsx)(Hn,{open:C,onOpenChange:w,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-refine-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.refineTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.refineBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>w(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:je,"data-testid":`agent-pr-refine-confirm-btn`,onClick:()=>{w(!1),pe(`discard`)},children:t(`prCard.refine`)})]})]})}),Ee]})}var Tk={building:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,on_review:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,pr_draft:`border-accent-info/40 bg-accent-info/10 text-accent-info`,pr_ready:`border-accent-info/40 bg-accent-info/10 text-accent-info`,no_changes:`border-accent-success/40 bg-accent-success/10 text-accent-success`,completed:`border-accent-success/40 bg-accent-success/10 text-accent-success`,pr_closed:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,superseded:`border-border/60 bg-surface/60 text-foreground/40`,implementation_failed:`border-destructive/40 bg-destructive/10 text-destructive`,pr_failed:`border-destructive/40 bg-destructive/10 text-destructive`,merged:`border-accent-success/40 bg-accent-success/10 text-accent-success`,discarded:`border-border/60 bg-surface/60 text-foreground/50`};function Ek({decision:e}){let{t}=K(`agent`);return(0,$.jsx)(`span`,{"data-testid":`pr-decision-pill`,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,Tk[e]),children:t(`prCard.pinned.state.${e}`)})}var Dk=e=>`specrails-desktop:agent-pr-dock-collapsed:${e}`,Ok=e=>`specrails-desktop:agent-pr-dock-card-collapsed:${e}`;function kk(e){try{return sessionStorage.getItem(Dk(e))===`1`}catch{return!1}}function Ak(e,t){try{t?sessionStorage.setItem(Dk(e),`1`):sessionStorage.removeItem(Dk(e))}catch{}}function jk(e){try{let t=sessionStorage.getItem(Ok(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Mk(e,t){try{t.size===0?sessionStorage.removeItem(Ok(e)):sessionStorage.setItem(Ok(e),JSON.stringify([...t]))}catch{}}function Nk({pinned:e,conversationId:t,inline:n}){let{t:r}=K(`agent`),[i,a]=(0,Q.useState)(()=>kk(t)),[o,s]=(0,Q.useState)(()=>jk(t));if((0,Q.useEffect)(()=>{a(kk(t)),s(jk(t))},[t]),e.length===0)return null;let c=e[e.length-1],l=e=>{Ak(t,e),a(e)},u=e=>{s(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),Mk(t,r),r})},d=e=>{let t=r(`prCard.rail`,{index:e.railIndex+1}),n=e.ticketIds.map(e=>`#${e}`).join(` `);return n?`${t} · ${n}`:t};return(0,$.jsx)(fy.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.2,ease:`easeOut`},"data-testid":`agent-pr-pinned-dock`,className:X(`shrink-0`,n?`px-4 pb-2`:`px-3 pb-2`),children:(0,$.jsx)(`div`,{className:X(n&&`mx-auto w-full max-w-[680px]`),children:i?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-expand`,"data-agent-interactive":!0,onClick:()=>l(!1),"aria-label":r(`prCard.pinned.expand`),title:r(`prCard.pinned.expand`),className:`flex w-full items-center gap-2 rounded-xl border border-border/60 bg-card/80 px-3 py-1.5 text-xs text-foreground/70 shadow-lg backdrop-blur-xl transition-colors hover:border-accent-primary/40 hover:bg-surface/60`,children:[(0,$.jsx)(Vs,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r(`prCard.pinned.collapsed`,{count:e.length})}),(0,$.jsx)(Ek,{decision:c.envelope.decision}),(0,$.jsx)(Gt,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,$.jsx)(Vs,{className:`h-3 w-3 text-accent-primary/60`}),r(`prCard.pinned.label`),e.length>1&&(0,$.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/60 px-1.5 py-px text-[9px] tabular-nums text-foreground/55`,children:e.length})]}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`agent-pr-dock-collapse`,"data-agent-interactive":!0,onClick:()=>l(!0),"aria-label":r(`prCard.pinned.collapse`),title:r(`prCard.pinned.collapse`),className:`rounded p-0.5 text-foreground/45 transition-colors hover:bg-surface hover:text-foreground`,children:(0,$.jsx)(Zt,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{"data-testid":`agent-pr-dock-stack`,className:`max-h-[45vh] space-y-1.5 overflow-y-auto overscroll-contain`,children:e.map(e=>{let t=e.envelope.prDeliveryId,n=o.has(t);return(0,$.jsxs)(`div`,{"data-testid":`agent-pr-dock-card`,className:`space-y-1`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-card-toggle`,"data-agent-interactive":!0,onClick:()=>u(t),"aria-expanded":!n,"aria-label":r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),title:r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),className:X(`flex w-full items-center gap-2 rounded-lg border px-2.5 py-1 text-[11px] text-foreground/70 transition-colors`,n?`border-border/60 bg-card/80 shadow backdrop-blur-xl hover:border-accent-primary/40 hover:bg-surface/70`:`border-transparent bg-transparent hover:bg-surface/50`),children:[(0,$.jsx)(R,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:d(e.envelope)}),(0,$.jsx)(Ek,{decision:e.envelope.decision}),n?(0,$.jsx)(Gt,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,$.jsx)(Zt,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!n&&(0,$.jsx)(wk,{envelope:e.envelope})]},e.messageId)})})]})})})}function Pk(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}function Fk(e,t,n,r){let i=e.title?.trim()||`Untitled mission`,a=r?.exportedAt??new Date().toISOString(),o=[`Mission: ${i}`,`Mission ID: ${e.id}`];return n?.name&&o.push(`Project: ${n.name}`),n?.path&&o.push(`Project path: ${n.path}`),o.push(`Exported at: ${a}`,``,`Messages:`),t.length===0?(o.push(`No messages loaded.`),o.join(`
42
+ `)):(t.forEach((e,t)=>{t>0&&o.push(``),o.push(`[${e.created_at}] ${Pk(e.role)}`,e.content)}),o.join(`
43
+ `))}function Ik(e,t){let n=(e??``).normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),r=t.trim()||`mission`;return`${n||r}.txt`}function Lk(){let{t:e}=K(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=lM(),{projects:c}=at(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),x=t?.pinned_project_id?c.find(e=>e.id===t.pinned_project_id)??null:null,S=t?.title?.trim()||e(`header.untitled`),C=t?o.has(t.id):!1;(0,Q.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&!y.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),(0,Q.useEffect)(()=>{l||v(!1)},[l]),(0,Q.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,Q.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,Q.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{J.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,Q.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{J.error(e(`header.copyFailed`))}},[e]),D=(0,Q.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(Fk(t,n,x)),g(`transcript`),J.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{J.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,Q.useCallback)(()=>{if(t){u(!1);try{let r=Fk(t,n,x),i=new Blob([r],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=Ik(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),J.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{J.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,Q.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{J.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,Q.useCallback)(()=>{t&&(s(t.id),u(!1))},[t,s]);if(!t)return null;let j=[{id:`name`,label:e(`header.copyName`),value:t.title??S},{id:`id`,label:e(`header.copyId`),value:t.id},...x?[{id:`project`,label:e(`header.copyProject`),value:x.name},{id:`path`,label:e(`header.copyProjectPath`),value:x.path}]:[]];return(0,$.jsxs)(`div`,{ref:y,"data-agent-interactive":!0,className:`relative flex h-12 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,$.jsx)(`input`,{ref:b,value:p,onChange:e=>m(e.target.value),onBlur:()=>void T(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&(e.preventDefault(),f(!1))},placeholder:e(`header.renamePlaceholder`),className:`min-w-0 flex-1 rounded-md border border-accent-primary/40 bg-surface/60 px-2 py-0.5 text-sm text-foreground outline-none focus:border-accent-primary/70`,maxLength:200}):(0,$.jsx)(`button`,{type:`button`,onDoubleClick:w,title:e(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:S})]}),(0,$.jsx)(_c,{}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":e(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground/45 transition-colors hover:bg-surface hover:text-foreground/80`,l&&`bg-surface text-foreground/80`),children:(0,$.jsx)(Xo,{className:`h-4 w-4`})}),(0,$.jsx)(f_,{children:l&&(0,$.jsx)(fy.div,{role:`menu`,"data-testid":`agent-conv-menu`,initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.14,ease:`easeOut`},className:`absolute right-3 top-11 z-50 min-w-[220px] overflow-hidden rounded-xl border border-border/50 bg-card/95 p-1 shadow-2xl backdrop-blur-xl`,children:_?(0,$.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,$.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-delete-confirm-btn`,onClick:()=>void k(),className:`flex-1 rounded-lg bg-destructive/90 px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-destructive`,children:e(`header.delete`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs text-foreground/80 transition-colors hover:bg-surface/80`,children:e(`common:actions.cancel`)})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:w,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,$.jsx)(an,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:A,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,$.jsx)(ms,{className:X(`h-3.5 w-3.5 shrink-0`,C?`text-accent-primary`:`text-foreground/50`),fill:C?`currentColor`:`none`}),e(C?`header.removeFavorite`:`header.addFavorite`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>v(!0),className:`group/del flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-destructive/10 hover:text-destructive`,children:[(0,$.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-transcript`,onClick:()=>void D(),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===`transcript`?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:O,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,$.jsx)(tn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),j.map(e=>e===`divider`?null:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void E(e.value,e.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===e.id?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var Rk=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function zk(e){return Rk.has(e)}function Bk(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=io(r.content);e&&t.push({messageId:r.id,envelope:e,position:n})}let n=new Map;for(let e of t){let t=n.get(e.envelope.prDeliveryId);if(!t){n.set(e.envelope.prDeliveryId,e);continue}let r=Ft(t.envelope.updatedAt,e.envelope.updatedAt);(r===1||r===null&&e.position>t.position)&&n.set(e.envelope.prDeliveryId,e)}let r=new Set(t.map(({envelope:e})=>e.supersedesDeliveryId).filter(e=>!!e)),i=new Set,a=[...n.values()];for(let e of a){let t=e.envelope.restoredFromDeliveryId;if(!t)continue;let n=null;for(let t of a){if(t.envelope.supersedesDeliveryId!==e.envelope.prDeliveryId)continue;if(!n){n=t;continue}let r=Ft(n.envelope.createdAt,t.envelope.createdAt);(r===1||(r===0||r===null)&&t.position>n.position)&&(n=t)}n&&n.envelope.prDeliveryId!==t||(r.delete(e.envelope.prDeliveryId),r.add(t),i.add(t))}let o=new Map;for(let e of n.values()){if(r.has(e.envelope.prDeliveryId))continue;let t=o.get(e.envelope.railIndex)??[];t.push(e),o.set(e.envelope.railIndex,t)}for(let e of o.values()){if(e.length<=1)continue;let t=e[0];for(let n of e.slice(1))Ft(t.envelope.createdAt,n.envelope.createdAt)===1&&(t=n);for(let n of e)n.envelope.prDeliveryId!==t.envelope.prDeliveryId&&r.add(n.envelope.prDeliveryId)}let s=t.map(e=>r.has(e.envelope.prDeliveryId)&&(e.envelope.decision!==`superseded`||i.has(e.envelope.prDeliveryId))?{...e,envelope:{...e.envelope,decision:i.has(e.envelope.prDeliveryId)?`discarded`:`superseded`}}:e),c=new Map,l=new Set,u=[];for(let e of s){if(n.get(e.envelope.prDeliveryId)?.messageId!==e.messageId){l.add(e.messageId);continue}c.set(e.messageId,e.envelope),zk(e.envelope.decision)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}var Vk=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-BCxue_Do.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([6,1,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76]))),Hk=(0,Q.lazy)(()=>c(()=>import(`./LoopPreviewModal-DqHiG4Dt.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([77,1,7,8,11,10,42,74,55,56,64,65,69,63,49,78,52,53]))),Uk=new Set,Wk=new Set([`spec-framing.committed`]);function Gk(e){if(!e.startsWith(`{`))return!1;try{let t=JSON.parse(e);return typeof t?.kind==`string`&&Wk.has(t.kind)}catch{return!1}}function Kk({variant:e}){let{t}=K(`agent`),{active:n}=lM(),r=si(),i=Cy(n?.id??`__new-mission__`),a=r.transfers.find(e=>e.conversationId===n?.id);if(n&&!r.current&&a?.state===`detached`)return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[e===`inline`&&(0,$.jsx)(Lk,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,$.jsx)(Vt,{className:`h-8 w-8 text-accent-primary`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`window.detached`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{r.focus(n.id)},className:`rounded-md bg-accent-primary px-4 py-2 text-sm text-white`,children:t(`window.focus`)})]})]});let o=!!n&&!r.isEditable(n.id);return(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 flex-col`,inert:o||void 0,"aria-busy":o||void 0,children:(0,$.jsx)(qk,{variant:e},`${n?.id??`__new-mission__`}:${i}`)})}function qk({variant:e}){let{t}=K(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,turnTools:s,queuedMessages:c,mcpEnabled:l,enablingMcp:u,enableMcpServer:d,providersReady:f,cycleTier:p,send:m}=lM(),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=o.length>0?o:s,b=(0,Q.useRef)(null),x=jy(i,a),{openRef:S,jobRef:C,closeJobRef:w,loopRef:T,closeLoopRef:E}=_b(),D=n?.pinned_project_id??null,[O,k]=(0,Q.useState)(new Map),A=(0,Q.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);for(let t of c)for(let n of t.attachmentIds??[])e.add(n);return[...e].sort()},[r,c]).join(`\0`);(0,Q.useEffect)(()=>{let e=A?A.split(`\0`):[];if(!n?.id||e.length===0){k(new Map);return}let t=!1,r=new Set(e);return qa(n.id).then(e=>{t||k(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||k(new Map)}),()=>{t=!0}},[n?.id,A]);let j=(0,Q.useMemo)(()=>D?e=>{S(D,e)}:void 0,[D,S]),M=ca().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),N=(0,Q.useMemo)(()=>Bk(r),[r]),P=n?xy(n.id):null,F=(0,Q.useRef)(P?.atBottom??!0);(0,Q.useLayoutEffect)(()=>{let e=b.current;return e&&P&&(e.scrollTop=P.atBottom?e.scrollHeight:P.top),()=>{e&&n&&by(n.id,{top:e.scrollTop,atBottom:F.current})}},[n?.id]);let I=()=>{let e=b.current;e&&(F.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,n&&by(n.id,{top:e.scrollTop,atBottom:F.current}))};(0,Q.useEffect)(()=>{F.current&&b.current?.scrollTo?.({top:b.current.scrollHeight,behavior:`auto`})},[r.length,x,o.length,c.length]);let L=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),p())},R=e===`inline`,z=R?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:L,children:[f===!1&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,$.jsx)(Ns,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),f!==!1&&!l&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,$.jsx)(rc,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void d(),disabled:u,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(u?`degraded.enabling`:`degraded.enable`)})]}),R&&n&&(0,$.jsx)(Lk,{}),(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(fy.div,{ref:b,onScroll:I,initial:R?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[r.length===0&&!a&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,$.jsx)(So,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:M}),(0,$.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){if(Gk(e.content))return null;let n=N.byMessageId.get(e.id);return n?zk(n.decision)?(0,$.jsxs)(`div`,{"data-testid":`agent-pr-pinned-marker`,className:`flex items-center gap-2 rounded-lg border border-border/40 bg-surface/30 px-3 py-1.5 text-[11px] text-foreground/45 backdrop-blur-sm`,children:[(0,$.jsx)(Vs,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,$.jsx)(Ek,{decision:n.decision})]},e.id):(0,$.jsx)(wk,{envelope:n},e.id):(N.duplicateMessageIds.has(e.id)||Uk.has(e.id)||(Uk.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,$.jsx)(Rx,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,isLatest:n===r.length-1,isStreaming:a,onPickOption:e=>void m(e),refsProjectId:D,onOpenRef:j,contextRefs:e.context_refs,deliveryStatus:e.delivery_status,deliveryReceipt:e.delivery_receipt,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>O.get(e)).filter(e=>!!e)},e.id)}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[x&&(0,$.jsx)(Rx,{role:`assistant`,content:x,streaming:!0}),(0,$.jsx)(bb,{tool:o.length?o[o.length-1].tool:null,onClick:()=>g(!0)})]}),c.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:c.map(e=>(0,$.jsx)(zx,{item:e,conversationId:n?.id,onEdit:e=>{n&&v(t=>({conversationId:n.id,queueId:e,revision:(t?.revision??0)+1}))},attachments:(e.attachmentIds??[]).map(e=>O.get(e)).filter(e=>!!e)},`${n?.id}:${e.queueId}`))})]}),(0,$.jsx)(f_,{initial:!1,children:n&&N.pinned.length>0&&(0,$.jsx)(Nk,{pinned:N.pinned,conversationId:n.id,inline:R},`agent-pr-pinned-dock`)}),R?(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsxs)(fy.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`relative mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,"data-testid":`agent-composer-dock`,children:[(0,$.jsx)(ik,{active:a,radius:`1rem`,inset:-3}),(0,$.jsx)(qO,{queueEditRequest:_})]})}):(0,$.jsxs)(`div`,{className:`relative shrink-0 border-t border-border/50 bg-surface/30 p-3`,"data-testid":`agent-composer-dock`,children:[(0,$.jsx)(ik,{active:a,radius:`0.75rem`,inset:-2}),(0,$.jsx)(qO,{hideProjectSelector:!0,queueEditRequest:_})]})]}),C&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Vk,{jobId:C.jobId,projectId:C.projectId,onClose:w})}),T&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hk,{loop:T,onClose:E})}),h&&(0,$.jsx)(Sb,{tools:y,streaming:a,onClose:()=>g(!1)})]})}var Jk=8,Yk=3e3;function Xk(){let{t:e}=K(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=lM(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(0),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y=(0,Q.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updated_at);return Number.isNaN(t)?0:t};return[...t].sort((t,n)=>e(n)-e(t))},[t]),b=t.length>Jk,x=(0,Q.useMemo)(()=>{let t=u.trim().toLowerCase();if(!t)return y;let n=e(`mission.untitled`).toLowerCase();return y.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[y,u,e]),S=x.length+1,C=(0,Q.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,Q.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,Q.useEffect)(()=>{if(!c)return;let e=e=>{_.current&&!_.current.contains(e.target)&&T()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let w=()=>{let e=n?y.findIndex(e=>e.id===n.id):-1;p(e>=0?e+1:0),l(!0)},T=()=>{l(!1),d(``),C()},E=e=>{e!==n?.id&&r(e),T()},D=()=>{a(null),T()},O=e=>{g.current&&clearTimeout(g.current),h(e),g.current=setTimeout(()=>{h(null),g.current=null},Yk)},k=async t=>{C();let a=n?.id===t,o=y.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{J.error(e(`mission.deleteFailed`))}},A=()=>{if(f===0)D();else{let e=x[f-1];e&&E(e.id)}},j=e=>{if(!c){e.key===`ArrowDown`&&(e.preventDefault(),w());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p(e=>(e+t+S)%S)}else e.key===`Home`?(e.preventDefault(),p(0)):e.key===`End`?(e.preventDefault(),p(S-1)):e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m?C():(T(),v.current?.focus()))},M=n?.title?.trim()||e(`mission.untitled`);return(0,$.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,$.jsxs)(`button`,{ref:v,type:`button`,"data-testid":`mission-trigger`,onClick:()=>c?T():w(),"aria-haspopup":`listbox`,"aria-expanded":c,"aria-controls":`agent-mission-listbox`,title:e(`mission.label`),className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[(0,$.jsx)(Yt,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,$.jsx)(Zt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,$.jsx)(f_,{children:c&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[b&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>{d(e.target.value),p(0)},placeholder:e(`mission.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,$.jsxs)(`div`,{id:`agent-mission-listbox`,role:`listbox`,"aria-label":e(`mission.label`),"aria-activedescendant":`agent-mission-opt-${f}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,$.jsxs)(fy.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:D,onMouseEnter:()=>p(0),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14},className:`flex w-full cursor-pointer items-center gap-2.5 px-3 py-1.5 text-left text-sm font-medium text-foreground ${f===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,$.jsx)(cn,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,$.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,$.jsx)(Zk,{conversation:e,index:t+1,highlighted:f===t+1,activeId:n?.id??null,streaming:o.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:m===e.id,onHover:()=>p(t+1),onSelect:()=>E(e.id),onArmDelete:()=>O(e.id),onConfirmDelete:()=>void k(e.id),onCancelDelete:C},e.id))]})]})})]})}function Zk({conversation:e,index:t,highlighted:n,activeId:r,streaming:i,queuedCount:a,confirming:o,onHover:s,onSelect:c,onArmDelete:l,onConfirmDelete:u,onCancelDelete:d}){let{t:f}=K(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,$.jsxs)(`div`,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,"data-testid":`mission-row-${e.id}`,className:`flex w-full items-center gap-2 bg-destructive/10 px-3 py-1.5 text-sm`,children:[(0,$.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-yes`,onClick:e=>{e.stopPropagation(),u()},"aria-label":f(`mission.confirmDelete`),className:`rounded-md p-1 text-destructive hover:bg-destructive/20`,children:(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-no`,onClick:e=>{e.stopPropagation(),d()},"aria-label":f(`mission.cancelDelete`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface`,children:(0,$.jsx)(mn,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(fy.div,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,tabIndex:-1,"data-testid":`mission-row-${e.id}`,onClick:c,onMouseEnter:s,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.03,.18)},className:`group flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-sm text-foreground ${n?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:Ob(e.updated_at),children:Db(e.updated_at)}),i&&(0,$.jsxs)(`span`,{"data-testid":`mission-live-${e.id}`,"aria-label":f(`mission.working`),className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,$.jsx)(`span`,{"data-testid":`mission-queued-${e.id}`,"aria-label":f(`mission.queuedBadge`,{n:a}),title:f(`mission.queuedBadge`,{n:a}),className:`shrink-0 rounded-full border border-border/60 bg-surface px-1.5 text-[9px] font-semibold leading-4 text-foreground/60`,children:a}),m&&(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`mission-delete-${e.id}`,onClick:e=>{e.stopPropagation(),l()},"aria-label":f(`mission.delete`,{title:p}),className:`shrink-0 rounded-md p-0.5 text-foreground/50 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`})})]})}var Qk=Q.forwardRef(({className:e,type:t,...n},r)=>(0,$.jsx)(`input`,{type:t,className:X(`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-xs ring-offset-background file:border-0 file:bg-transparent file:text-xs file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Qk.displayName=`Input`;var $k=6e4,eA={data:null,fetchedAt:0,inFlight:null,error:null},tA=new Set;function nA(){tA.forEach(e=>{try{e()}catch{}})}function rA(){return eA.data!==null&&Date.now()-eA.fetchedAt<$k}async function iA(e){if(eA.inFlight)return eA.inFlight;let t=(async()=>{let t=await fetch(`${He}/api/setup-prerequisites`,{signal:e});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(typeof n?.ok!=`boolean`||!Array.isArray(n?.prerequisites)||!Array.isArray(n?.missingRequired))throw Error(`Malformed prerequisites response`);return eA.data=n,eA.fetchedAt=Date.now(),eA.error=null,eA.inFlight=null,nA(),eA.data})().catch(t=>{throw eA.inFlight=null,e?.aborted?t:(eA.error=t instanceof Error?t:Error(String(t)),nA(),eA.error)});return eA.inFlight=t,t}var aA=!1;function oA(){aA||typeof window>`u`||(window.addEventListener(`focus`,()=>{eA.fetchedAt=0,eA.data=null,iA().catch(()=>{})}),aA=!0)}function sA(){let[,e]=(0,Q.useState)(0),[t,n]=(0,Q.useState)(()=>!rA()),[r,i]=(0,Q.useState)(eA.error);(0,Q.useEffect)(()=>{oA();let t=()=>{e(e=>e+1),i(eA.error),n(!1)};tA.add(t);let r=new AbortController;return!rA()&&!eA.inFlight?(n(!0),iA(r.signal).catch(e=>{r.signal.aborted||i(e instanceof Error?e:Error(String(e)))}).finally(()=>{r.signal.aborted||n(!1)})):eA.inFlight&&eA.inFlight.catch(()=>{}).finally(()=>{r.signal.aborted||n(!1)}),()=>{r.abort(),tA.delete(t)}},[]);let a=(0,Q.useCallback)(async()=>{eA.fetchedAt=0,eA.data=null,eA.error=null,n(!0);try{await iA()}catch(e){i(e instanceof Error?e:Error(String(e)))}finally{n(!1)}},[]);return{status:eA.data,isLoading:t,error:r,recheck:a}}var cA={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`},kimi:{icon:`🌙`,label:`Kimi`}};function lA(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function uA({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=K(`builder`),{status:s}=sA(),[c,l]=(0,Q.useState)(e.product.name||``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(new Set([`claude`])),[g,_]=(0,Q.useState)({claude:!0}),[v,y]=(0,Q.useState)(!1),b=(0,Q.useMemo)(()=>`~/projects/${lA(c)}`,[c]),x=u?f:b;(0,Q.useEffect)(()=>{fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n===`tiers`||n===`providerIssues`||n===`launchDescriptors`||typeof r==`boolean`&&(t[n]=r);_(t);let n=new Set;for(let[e,r]of Object.entries(t))r&&n.add(e);n.size>0&&h(n)}).catch(()=>{})},[]);let S=s?.prerequisites.find(e=>e.key===`gh`),C=!!(S?.installed&&S?.executable!==!1),w=C&&!!S?.authenticated,T=[`claude`,`codex`,`gemini`,`kimi`,...Object.keys(g)].filter((e,t,n)=>n.indexOf(e)===t).filter(e=>m.has(e)&&g[e]),E=c.trim()!==``&&x.trim()!==``&&T.length>0&&!r;return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col gap-4 p-6`,"data-testid":`commit-form`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`commit.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`commit.description`)})]}),i&&(0,$.jsxs)(`div`,{className:`rounded-md bg-destructive/10 p-2 text-xs text-destructive`,"data-testid":`commit-error`,children:[(0,$.jsx)(`p`,{children:o(`commit.errors.${i}`,{defaultValue:o(`commit.errors.generic`)})}),a&&(0,$.jsx)(`p`,{className:`mt-1 opacity-80`,children:a})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsx)(Qk,{value:c,onChange:e=>l(e.target.value),"data-testid":`commit-name`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.locationLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsx)(Qk,{value:x,onChange:e=>{d(!0),p(e.target.value)},"data-testid":`commit-location`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:o(`commit.locationHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:o(`commit.providersLabel`)}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:Object.keys(g).map(e=>{let{icon:t,label:n}=cA[e]??{icon:`•`,label:e},r=g[e],i=m.has(e)&&r;return(0,$.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":i,disabled:!r,"data-testid":`commit-provider-${e}`,onClick:()=>{h(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})},className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors`,i?`border-accent-primary/60 bg-accent-primary/10`:`border-border/30 text-muted-foreground`,!r&&`cursor-not-allowed opacity-40`),children:[(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(`span`,{className:`font-medium`,children:n})]},e)})})]}),C&&(0,$.jsxs)(`label`,{className:X(`flex items-center gap-2 rounded-md border border-border/30 px-3 py-2 text-xs`,!w&&`opacity-50`),children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:v&&w,disabled:!w,onChange:e=>y(e.target.checked),"data-testid":`commit-github`}),(0,$.jsx)(us,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:o(`commit.githubLabel`)}),!w&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:o(`commit.githubAuthHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between pt-2`,children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:o(`commit.back`)}),(0,$.jsxs)(Z,{size:`sm`,disabled:!E,"data-testid":`commit-submit`,onClick:()=>t({name:c.trim(),location:x.trim(),providers:T,createGithubRepo:v&&w}),children:[(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}function dA({session:e,autoFocus:t=!1}){let{t:n}=K(`builder`),{t:r}=K(`agent`),{availableIds:i}=UO(),a=rr(e.provider),o=[e.provider,...i].filter((e,t,n)=>n.indexOf(e)===t).filter(rr),s=()=>{!a||!e.draft.trim()||e.busy||!e.conversationReady||(e.send(e.draft),e.setDraft(``))};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:n(`mode.title`)})]}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(uD,{label:r(`provider.label`),value:e.provider,options:o.map(e=>({value:e,label:r(`provider.${e}`,{defaultValue:e})})),icon:So,onSelect:e.setProvider,disabled:!a||e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,$.jsx)(vD,{models:e.models,model:e.model,onSelect:e.setModel,disabled:!a||e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,$.jsx)(uD,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ss,onSelect:e.setEffort,disabled:!a||e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,$.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:!a||e.busy||!e.conversationReady,className:`ml-auto inline-flex items-center gap-1.5 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-3 py-1 text-[11px] text-accent-highlight transition-colors hover:bg-accent-highlight/20 disabled:opacity-40`,"data-testid":`surprise-me`,children:[(0,$.jsx)(un,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),!a&&(0,$.jsx)(`p`,{className:`mb-2 rounded-md border border-accent-warning/30 bg-accent-warning/10 px-2.5 py-2 text-xs text-accent-warning`,"data-testid":`builder-provider-unavailable`,children:n(`shell.providerUnavailable`)}),(0,$.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border border-border/60 bg-background/60 px-3 py-2`,children:[(0,$.jsx)(`textarea`,{value:e.draft,disabled:!a,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),s())},rows:2,placeholder:n(`shell.inputPlaceholder`),"aria-label":n(`shell.inputPlaceholder`),"data-agent-interactive":!0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`,"data-testid":`builder-input`}),(0,$.jsx)(`button`,{type:`button`,onClick:s,disabled:!a||e.busy||!e.draft.trim()||!e.conversationReady,"aria-label":r(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,"data-testid":`builder-send`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})})]})]})}function fA(e){let t=Date.parse(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`);return Number.isFinite(t)?Zn(new Date(t),{addSuffix:!0,locale:Ue()}):``}function pA({items:e,loading:t,disabled:n=!1,onResume:r,onDiscard:i}){let{t:a}=K(`builder`),[o,s]=(0,Q.useState)(null);return!t&&e.length===0?null:(0,$.jsxs)(fy.section,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.24,ease:`easeOut`,delay:.08},className:`mt-4 w-full rounded-2xl border border-border/50 bg-card/70 p-3 shadow-lg backdrop-blur-xl`,"data-testid":`builder-recent`,"aria-label":a(`recent.title`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-1`,children:[(0,$.jsx)(hs,{className:`h-3.5 w-3.5 text-accent-secondary`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:a(`recent.title`)}),t&&(0,$.jsx)(rn,{className:`ml-auto h-3 w-3 animate-spin text-muted-foreground/60`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`space-y-1`,children:(0,$.jsx)(f_,{initial:!1,children:e.map(e=>{let t=e.productName||e.title||a(`recent.untitled`),c=o===e.id;return(0,$.jsxs)(fy.li,{layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,height:0},className:X(`group flex items-center gap-2 rounded-xl border border-transparent px-2.5 py-2 transition-colors`,`hover:border-border/60 hover:bg-surface/60`),"data-testid":`builder-recent-${e.id}`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(e.id),className:`flex min-w-0 flex-1 items-center gap-2.5 text-left disabled:opacity-50`,"data-testid":`builder-recent-resume-${e.id}`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent-primary/10 text-accent-primary`,children:(0,$.jsx)(on,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t}),(0,$.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground`,children:[e.platform&&(0,$.jsx)(`span`,{children:e.platform}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(xs,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),e.specCount>0?e.specsComplete?a(`recent.specsComplete`,{count:e.specCount}):a(`recent.specsInProgress`,{count:e.specCount}):a(`recent.dimensions`,{filled:e.dimensionsFilled,total:5})]}),e.pendingIssue&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-warning`,"data-testid":`builder-recent-pending-issue`,children:[(0,$.jsx)(fn,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),a(`recent.pendingIssue`)]}),e.updatedAt&&(0,$.jsx)(`span`,{className:`opacity-80`,children:fA(e.updatedAt)})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{s(null),i(e.id)},"aria-label":a(`recent.discardConfirm`),title:a(`recent.discardConfirm`),className:`rounded-md p-1 text-destructive hover:bg-destructive/10`,"data-testid":`builder-recent-discard-confirm-${e.id}`,children:(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(null),"aria-label":a(`recent.discardCancel`),title:a(`recent.discardCancel`),className:`rounded-md p-1 text-muted-foreground hover:bg-surface`,"data-testid":`builder-recent-discard-cancel-${e.id}`,children:(0,$.jsx)(mn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),"aria-label":a(`recent.discard`),title:a(`recent.discard`),className:`rounded-md p-1 text-muted-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100`,"data-testid":`builder-recent-discard-${e.id}`,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})})]},e.id)})})})]})}function mA({specsStarted:e,snapshot:t,maxSpecs:n=10}){let{t:r}=K(`builder`),i=t.status===`repairing`,a=t.status===`generating`?t.generation:null,o=(a&&a.total>0?a.phase===`audit`?.95:Math.min(.95,Math.max(.06,Math.max(0,a.from-1)/a.total)):null)??Math.min(.95,Math.max(.06,e/n)),s=i?pn:un,c=i?r(`snapshot.repairing.${t.kind}`):a?r(`generation.phase.${a.phase}`,{from:a.from,to:a.to,total:a.total}):r(`generation.writing`);return(0,$.jsxs)(`div`,{className:`inline-flex max-w-full flex-col gap-1.5 rounded-xl border border-border/50 bg-surface/60 px-3 py-2 text-xs text-foreground/80`,"data-testid":`builder-generation-progress`,"data-phase":i?`repairing`:a?`generation-${a.phase}`:`generating`,role:`status`,"aria-live":`polite`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 shrink-0 animate-spin text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(s,{className:`h-3 w-3 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:`easeOut`},className:`font-medium`,children:c},c)}),a&&a.totalTurns>0&&(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-2 py-px font-mono text-[10px] text-muted-foreground`,"data-testid":`builder-generation-turn`,children:r(`generation.turn`,{turn:a.turn,total:a.totalTurns})}),e>0&&(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.14},className:`rounded-full bg-accent-primary/10 px-2 py-px font-mono text-[10px] text-accent-primary`,"data-testid":`builder-generation-count`,children:r(`generation.specCount`,{n:e})},e)})]}),(0,$.jsx)(`div`,{className:`h-1 w-56 max-w-full overflow-hidden rounded-full bg-border/40`,"aria-hidden":!0,children:(0,$.jsx)(fy.div,{className:`h-full rounded-full bg-gradient-to-r from-accent-primary/70 to-accent-highlight/80`,initial:{width:`6%`},animate:{width:`${Math.round(o*100)}%`},transition:{type:`spring`,stiffness:120,damping:20}})})]})}var hA=`specrails-desktop:milestone-launch-mode`,gA=`specrails-desktop:milestone-sequential-plans`;function _A(){try{return localStorage.getItem(`specrails-desktop:milestone-launch-mode`)===`parallel`?`parallel`:`sequential`}catch{return`sequential`}}function vA(e){try{localStorage.setItem(hA,e)}catch{}}var yA=`specrails-desktop:milestone-auto-advance`;function bA(){try{return localStorage.getItem(yA)===`true`}catch{return!1}}function xA(e){try{localStorage.setItem(yA,e?`true`:`false`)}catch{}}function SA(){try{return localStorage.getItem(`specrails-desktop:milestone-sequential-plans`)===null?!1:(localStorage.removeItem(gA),!0)}catch{return!1}}function CA(e){return`M${e}`}function wA(e,t){return t===`chain_active`?`chain_active`:t===`no_tickets`?`no_tickets`:t===`milestone_not_found`?`milestone_not_found`:e===503?`unavailable`:`launch_rejected`}async function TA(e){try{let t=await e.json();return t&&typeof t==`object`?t:{}}catch{return{}}}async function EA(e,t,n=_A(),r={}){let i=typeof r==`function`?{fetchImpl:r}:r,a=i.fetchImpl??fetch,o=i.autoAdvance??bA(),s;try{s=await a(`/api/projects/${e}/blueprint/milestones/${t}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n,autoAdvance:o})})}catch(e){return{ok:!1,reason:`network`,error:`network`,detail:e instanceof Error?e.message:String(e)}}let c=await TA(s);if(!s.ok){let e=typeof c.error==`string`?c.error:`http_${s.status}`;return{ok:!1,reason:wA(s.status,e),error:e,...typeof c.detail==`string`?{detail:c.detail}:{},...typeof c.chainId==`string`?{chainId:c.chainId}:{}}}let l=Array.isArray(c.launched)?c.launched.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk==`number`):[],u=Array.isArray(c.pending)?c.pending.filter(e=>Array.isArray(e)):[];return{ok:!0,chainId:typeof c.chainId==`string`?c.chainId:null,launched:l,pending:u,ticketCount:l.reduce((e,t)=>e+(Array.isArray(t.ticketIds)?t.ticketIds.length:0),0),skippedCount:u.reduce((e,t)=>e+t.length,0)}}async function DA(e,t,n,r){let i;try{i=await r(`/api/projects/${e}/blueprint/chains/${t}/${n}`,{method:`POST`})}catch(e){return{ok:!1,error:`network`,detail:e instanceof Error?e.message:String(e)}}let a=await TA(i);return i.ok?{ok:!0,chain:yt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}function OA(e,t,n=fetch){return DA(e,t,`resume`,n)}function kA(e,t,n=fetch){return DA(e,t,`cancel`,n)}async function AA(e,t,n,r=fetch){let i;try{i=await r(`/api/projects/${e}/blueprint/chains/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoAdvance:n})})}catch(e){return{ok:!1,error:`network`,detail:e instanceof Error?e.message:String(e)}}let a=await TA(i);return i.ok?{ok:!0,chain:yt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}var jA=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],MA={problemMinChars:200,solutionMinChars:500,outOfScopeMinBullets:3,technicalMinBullets:5,criteriaMin:6,criteriaMax:10,criterionMinChars:20},NA=new Set([`scaffold`,`feature`,`verification`]),PA=new Set([`critical`,`high`,`medium`,`low`]),FA=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function IA(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function LA(e){return e.trim().toLocaleLowerCase(`en-US`)}function RA(e){let t=[...e.matchAll(/^##[ \t]+(.+?)[ \t]*$/gm)],n=t.map(e=>e[1].trim()),r=new Map;return t.forEach((i,a)=>{let o=(i.index??0)+i[0].length,s=a+1<t.length?t[a+1].index??e.length:e.length;r.set(n[a],e.slice(o,s).trim())}),{headings:n,bodies:r}}function zA(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function BA(e,t){let n=[],r=IA(e),i=Array.isArray(r?.m1Specs)?r.m1Specs:[],a=t.milestoneLabel.trim().toUpperCase(),o=(e,t,r,i,a={})=>{n.push({specIndex:e,field:t,code:r,message:i,params:e===null?a:{n:e+1,...a}})};r?.specsComplete!==!0&&o(null,`specsComplete`,`batch_incomplete`,`Generation is not complete yet.`),(i.length<t.minSpecs||i.length>t.maxSpecs)&&o(null,`m1Specs`,`spec_count`,`The batch needs ${t.minSpecs}-${t.maxSpecs} specs.`,{min:t.minSpecs,max:t.maxSpecs,count:i.length});let s=new Map;return i.forEach((e,n)=>{let r=IA(e),i=n+1;if(!r){o(n,`spec`,`invalid_shape`,`Spec ${i} must be an object.`);return}let c=typeof r.kind==`string`?r.kind:``;NA.has(c)||o(n,`kind`,`invalid_kind`,`Spec ${i} needs a valid kind.`),t.requireScaffold&&n===0&&c!==`scaffold`&&o(n,`kind`,`scaffold_first`,`The first spec must be the project scaffold.`),t.requireScaffold&&n>0&&c===`scaffold`&&o(n,`kind`,`duplicate_scaffold`,`Spec ${i} cannot be another scaffold.`);let l=typeof r.title==`string`?r.title.trim():``;if(!l)o(n,`title`,`required`,`Spec ${i} needs a title.`);else{let e=LA(l),t=s.get(e);t===void 0?s.set(e,n):o(n,`title`,`duplicate`,`Spec ${i} duplicates spec ${t+1}.`,{other:t+1})}let u=typeof r.shortSummary==`string`?r.shortSummary.trim():``;(!u||u.length>240||/[\r\n]/.test(u))&&o(n,`shortSummary`,`summary`,`Spec ${i} needs a one-line summary under 240 characters.`);let d=typeof r.priority==`string`?r.priority:``;PA.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=RA(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==jA.length||p.headings.some((e,t)=>e!==jA[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of jA)(p.bodies.get(e)??``).trim()||o(n,`description`,`empty_section`,`Spec ${i} has an empty ${e} section.`,{heading:e});for(let[e,t]of[[`Problem Statement`,MA.problemMinChars],[`Proposed Solution`,MA.solutionMinChars]]){let r=(p.bodies.get(e)??``).trim();r&&r.length<t&&o(n,`description`,`section_depth`,`Spec ${i} ${e} is too thin.`,{heading:e,min:t})}for(let[e,t]of[[`Out of Scope`,MA.outOfScopeMinBullets],[`Technical Considerations`,MA.technicalMinBullets]]){let r=p.bodies.get(e)??``;r&&zA(r)<t&&o(n,`description`,`section_bullets`,`Spec ${i} needs ${t} ${e} bullets.`,{heading:e,min:t})}let m=p.bodies.get(`Estimated Complexity`)??``;m&&!/^(?:Low|Medium|High|Very High)\s*(?:[—\-:]\s*)\S/i.test(m)&&o(n,`description`,`complexity_format`,`Spec ${i} needs a justified complexity.`),t.requireScaffold&&n===0&&f&&!/\bREADME\b/i.test(f)&&o(n,`description`,`scaffold_readme`,`The scaffold spec must mention the existing README.`);let h=Array.isArray(r.acceptanceCriteria)?r.acceptanceCriteria:[];(h.length<MA.criteriaMin||h.length>MA.criteriaMax)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs ${MA.criteriaMin}-${MA.criteriaMax} acceptance criteria.`,{count:h.length,min:MA.criteriaMin,max:MA.criteriaMax});let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<MA.criterionMinChars||FA.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`,{criterion:t+1});return}let a=LA(r);g.has(a)&&o(n,`acceptanceCriteria`,`duplicate_criterion`,`Spec ${i} repeats an acceptance criterion.`,{criterion:t+1}),g.add(a)});let _=Array.isArray(r.labels)?r.labels.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[];new Set(_.map(e=>e.toUpperCase())).has(a)||o(n,`labels`,`milestone_label`,`Spec ${i} needs the ${a} label.`,{label:a}),_.every(e=>e.toUpperCase()===a)&&o(n,`labels`,`domain_label`,`Spec ${i} needs a domain label.`,{label:a});let v=r.dependsOnIndex;v!==void 0&&(!Number.isInteger(v)||v<0||v>=n)&&o(n,`dependsOnIndex`,`invalid_dependency`,`Spec ${i} must depend only on an earlier spec.`),t.requireScaffold&&n===0&&v!==void 0&&o(n,`dependsOnIndex`,`scaffold_dependency`,`The scaffold cannot declare a dependency.`)}),{valid:n.length===0,issues:n}}var VA=new Set([`batch_incomplete`,`spec_count`]);function HA(e,t,n,r,i={}){let a=gt(e),o=Object.values(a).filter(Boolean).length,s=Object.keys(a).length,c=t&&typeof t==`object`&&!Array.isArray(t)?t:null,l=Array.isArray(c?.m1Specs)?c.m1Specs.length:e?.m1Specs.length??0,u=Array.isArray(c?.m1Specs)?c.m1Specs:e?.m1Specs??[],d=new Set;u.forEach((e,t)=>{let n=e&&typeof e==`object`?e:null,r=typeof n?.description==`string`?n.description.trim():``,i=Array.isArray(n?.acceptanceCriteria)?n.acceptanceCriteria:[];(r.length>0||i.length>0)&&d.add(t)});let f=d.size,p=c?c.specsComplete===!0:e?.specsComplete===!0,m=i.generating===!0&&l>0,h=!m&&l>0&&f<l&&!p,g=m?[]:n.issues.filter(e=>!VA.has(e.code)&&(!h||e.specIndex===null||d.has(e.specIndex))),_={key:`blueprint`,state:o===s?`done`:`pending`,params:{filled:o,total:s}},v;v=m?`writing`:l===0?`pending`:l<r.minSpecs||l>r.maxSpecs?`blocked`:p?`done`:`pending`;let y={key:`specs`,state:v,params:{count:l,written:f,min:r.minSpecs,max:r.maxSpecs}},b={key:`audit`,state:m?`writing`:l===0||h&&g.length===0?`pending`:g.length===0?`done`:`blocked`,params:{count:g.length}};return{ready:n.valid,steps:[_,y,b],issues:g}}function UA(e){return e.field===`shortSummary`?`quality.summary`:e.field===`title`&&e.code===`required`?`quality.title_required`:e.field===`title`&&e.code===`duplicate`?`quality.title_duplicate`:`quality.${e.code}`}function WA(e,t){let n={n:t.specIndex===null?``:t.specIndex+1,...t.params??{}};return e(UA(t),{...n,defaultValue:t.message})}var GA=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function KA(e){return`progress.githubErrors.${e&&GA.has(e)?e:`generic`}`}var qA=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`],JA={minSpecs:5,maxSpecs:10};function YA(e){let t=e&&typeof e==`object`?e:null;if(!t)return null;let n=t.phase;if(n!==`outline`&&n!==`details`&&n!==`audit`&&n!==`repair`)return null;let r=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return{phase:n,from:r(t.from),to:r(t.to),total:r(t.total),turn:r(t.turn),totalTurns:r(t.totalTurns)}}function XA(e,t){let n=e&&typeof e==`object`?e:{},r=new Date().toISOString();if(n.continuing){let e=YA(n.generation);return e?{status:`generating`,generation:e}:t}return n.status===`accepted`?{status:`accepted`,repaired:n.repaired===!0,repairAttempted:n.repairAttempted===!0,at:r,...n.generationHalted===!0?{generationHalted:!0}:{}}:n.status===`rejected`?{status:`rejected`,reason:n.reason??`invalid_json`,detail:n.detail??``,repairAttempted:n.repairAttempted===!0,at:r}:t.status===`repairing`||t.status===`generating`?{status:`idle`}:t}function ZA(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`).map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:null,productName:typeof e.productName==`string`?e.productName:null,platform:typeof e.platform==`string`?e.platform:null,provider:typeof e.provider==`string`?e.provider:`claude`,model:typeof e.model==`string`?e.model:null,updatedAt:typeof e.updated_at==`string`?e.updated_at:``,messageCount:typeof e.messageCount==`number`?e.messageCount:0,specCount:typeof e.specCount==`number`?e.specCount:0,specsComplete:e.specsComplete===!0,dimensionsFilled:typeof e.dimensionsFilled==`number`?e.dimensionsFilled:0,hasSnapshot:e.hasSnapshot===!0,pendingIssue:e.pendingIssue===`invalid_json`||e.pendingIssue===`truncated`||e.pendingIssue===`missing_version`?e.pendingIssue:null})):[]}function QA(e,t){let{t:n}=K(`builder`),{registerHandler:r,unregisterHandler:i}=qe(),{setActiveProjectId:a}=at(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(`chat`),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(`claude`),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)([]),[V,H]=(0,Q.useState)(``),[te,ne]=(0,Q.useState)([]),[re,ie]=(0,Q.useState)(`medium`),[ae,oe]=(0,Q.useState)(``),[se,ce]=(0,Q.useState)({status:`idle`}),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(!1),he=R??V,ge=(0,Q.useMemo)(()=>{let e=lr(I,he);return te.filter(t=>e.includes(t))},[he,I,te]),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(I),U=(0,Q.useRef)(null),be=(0,Q.useRef)(!1),xe=(0,Q.useRef)(re),Se=(0,Q.useRef)(ge),Ce=(0,Q.useRef)(R),W=(0,Q.useRef)(!1),we=(0,Q.useRef)(t.onFinished);(0,Q.useEffect)(()=>{_e.current=o},[o]),(0,Q.useEffect)(()=>{ye.current=I},[I]),(0,Q.useEffect)(()=>{U.current=w},[w]),(0,Q.useEffect)(()=>{xe.current=re},[re]),(0,Q.useEffect)(()=>{Se.current=ge},[ge]),(0,Q.useEffect)(()=>{Ce.current=R},[R]),(0,Q.useEffect)(()=>{we.current=t.onFinished},[t.onFinished]);let Te=(0,Q.useCallback)(async()=>{let e=_e.current;if(e)return e;if(ve.current)return ve.current;let t=fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:ye.current,...Ce.current?{model:Ce.current}:{}})}).then(e=>e.json()).then(e=>e.conversation?(_e.current=e.conversation.id,s(e.conversation.id),e.conversation.id):null).catch(()=>null).finally(()=>{ve.current=null});return ve.current=t,t},[]),Ee=(0,Q.useCallback)(async()=>{fe(!0);try{let e=await(await fetch(`/api/blueprint/conversations?resumable=1`)).json();ue(ZA(e.conversations))}catch{ue([])}finally{fe(!1)}},[]);(0,Q.useEffect)(()=>{e&&Ee()},[e,Ee]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return ee([]),H(``),ne([]),ie(``),fetch(`/api/blueprint/models?provider=${encodeURIComponent(I)}`).then(e=>e.json()).then(e=>{if(t)return;ee(e.models??[]);let n=e.defaultModel??e.models?.[0]?.value??``,r=e.efforts??[],i=lr(I,n),a=r.filter(e=>i.includes(e));H(n),ne(r),ie(e=>a.includes(e)?e:fr(I,n)??``)}).catch(()=>{}),()=>{t=!0}},[e,I]);let De=(0,Q.useCallback)(e=>{L(e),z(null);let t=_e.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),Oe=(0,Q.useCallback)(e=>{z(e);let t=lr(I,e),n=te.filter(e=>t.includes(e));ie(t=>n.includes(t)?t:fr(I,e)??``);let r=_e.current;r&&fetch(`/api/blueprint/conversations/${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[I,te]);(0,Q.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=_e.current!==null&&t.conversationId===_e.current,i=U.current!==null&&t.commitId===U.current;if(t.type===`blueprint.stream`&&r)d(e=>(e??``)+String(t.delta??``));else if(t.type===`blueprint.repairing`&&r){let e=t.kind===`truncated`||t.kind===`quality`?t.kind:`invalid_json`;_(!0),ce({status:`repairing`,kind:e,manual:t.manual===!0,attempt:typeof t.attempt==`number`?t.attempt:1})}else if(t.type===`blueprint.generating`&&r){let e=YA(t);d(null),_(!0),e&&ce({status:`generating`,generation:e})}else if(t.type===`blueprint.done`&&r){let e=t.continuing===!0;d(null),_(e);let n=String(t.fullText??``);n.trim()&&!e&&l(e=>[...e,{role:`assistant`,content:n,createdAt:new Date().toISOString()}]);let r=Ct(t.blueprint),i=t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint;if(!r&&t.snapshot===void 0){let e=Lt(n);r=e.blueprint,i=e.rawBlueprint}r&&(p(r),h(i)),ce(e=>t.snapshot===void 0?r?{status:`accepted`,repaired:!1,repairAttempted:!1,at:new Date().toISOString()}:e:XA(t.snapshot,e))}else if(t.type===`blueprint.error`&&r)d(null),_(!1),ce(e=>e.status===`repairing`||e.status===`generating`?{status:`idle`}:e),J.error(n(`errors.turnFailed`),{description:String(t.error??``)});else if(t.type===`blueprint.commit_progress`&&i){let e=String(t.step),r=t.status,i=typeof t.detail==`string`?t.detail:void 0,a=typeof t.code==`string`?t.code:void 0;e===`github`&&r===`warning`&&!be.current&&(be.current=!0,J.warning(n(KA(a)),{description:i})),D(t=>[...t.filter(t=>t.step!==e),{step:e,status:r,detail:i,code:a}])}else t.type===`blueprint.commit_done`&&i?(k(String(t.projectId)),y(`done`)):t.type===`blueprint.commit_failed`&&i&&(W.current=!1,F(!1),J.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let ke=(0,Q.useCallback)((e,t={})=>{let r=e.trim();if(!r||g||pe)return;l(e=>[...e,{role:`user`,content:r,createdAt:new Date().toISOString(),...t.intent?{intent:t.intent}:{}}]),_(!0);let i=xe.current,a=Se.current.includes(i);Te().then(e=>{if(!e){_(!1),J.error(n(`errors.startFailed`));return}return fetch(`/api/blueprint/conversations/${e}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...Ce.current?{model:Ce.current}:{},...a?{reasoning_effort:i}:{},...t.intent?{intent:t.intent}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),J.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),J.error(n(`errors.turnFailed`))})})},[g,pe,Te,n]),Ae=(0,Q.useCallback)(async e=>{if(!g){me(!0);try{let t=await fetch(`/api/blueprint/conversations/${e}`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(!n.conversation)throw Error(`missing conversation`);_e.current=n.conversation.id,s(n.conversation.id),n.conversation.provider&&L(n.conversation.provider),z(n.conversation.model??null),l((n.messages??[]).filter(e=>typeof e.content==`string`&&e.content.trim()!==``).map(e=>({role:e.role,content:e.content,createdAt:e.created_at??new Date().toISOString(),...e.intent===`surprise`||e.intent===`approve`?{intent:e.intent}:{}})));let r=Ct(n.blueprint);p(r),h(r?n.rawBlueprint??n.blueprint:null),ce(XA(n.snapshot,{status:`idle`})),d(null),_(!1),y(`chat`),x(null),C(null),D([]),oe(``)}catch{J.error(n(`recent.resumeFailed`))}finally{me(!1)}}},[g,n]),je=(0,Q.useCallback)(async e=>{try{let t=await fetch(`/api/blueprint/conversations/${e}`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(`HTTP ${t.status}`);ue(t=>t.filter(t=>t.id!==e))}catch{J.error(n(`recent.discardFailed`))}},[n]),Me=(0,Q.useCallback)(async()=>{let e=_e.current;if(!(!e||g)){_(!0);try{let t=await fetch(`/api/blueprint/conversations/${e}/repair-snapshot`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(re?{reasoningEffort:re}:{})});if(t.status===202)return;let r=await t.json().catch(()=>({}));_(!1),r.error===`nothing_to_repair`?J.info(n(`snapshot.nothingToRepair`)):r.error===`no_session`?J.error(n(`snapshot.noSession`)):r.error===`streaming`?J.info(n(`snapshot.alreadyStreaming`)):J.error(n(`errors.turnFailed`))}catch{_(!1),J.error(n(`errors.turnFailed`))}}},[g,re,n]),Ne=(0,Q.useCallback)(()=>ke(n(`prompts.surpriseMe`),{intent:`surprise`}),[ke,n]),Pe=(0,Q.useCallback)(()=>ke(n(`prompts.approve`),{intent:`approve`}),[ke,n]),Fe=(0,Q.useCallback)(e=>{!f||W.current||(W.current=!0,F(!0),x(null),C(null),D([]),be.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e,..._e.current?{conversationId:_e.current}:{}})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),U.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),W.current=!1,F(!1)}).catch(()=>{W.current=!1,F(!1),x(`generic`),C(null)}))},[f,m]),Ie=(0,Q.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=_A(),t=bA(),r=await EA(O,1,e,{autoAdvance:t}),i=CA(1);if(r.ok){let o=r.launched.length+r.pending.length;e===`sequential`&&r.pending.length>0?J.success(n(t?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:i,count:r.ticketCount,n:o})):r.skippedCount>0?J.warning(n(`milestoneProgress.toast.launchedPartial`,{milestone:i,count:r.ticketCount,skipped:r.skippedCount})):J.success(n(`milestoneProgress.toast.launchedAll`,{milestone:i,count:r.ticketCount,n:o})),a(O),N(!0)}else r.reason===`chain_active`?(J.info(n(`milestoneProgress.toast.chainActive`,{milestone:i})),a(O),N(!0)):J.error(n(`done.launchFailed`),{description:r.detail??r.error})}finally{j(!1)}}},[O,A,a,n]),Le=(0,Q.useCallback)(()=>{O&&a(O),we.current()},[O,a]),Re=(0,Q.useCallback)(()=>{let e=_e.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),_e.current=null,ve.current=null,l([]),d(null),p(null),h(null),ce({status:`idle`}),ue([]),me(!1),_(!1),y(`chat`),x(null),C(null),T(null),D([]),be.current=!1,k(null),N(!1),j(!1),W.current=!1,F(!1),L(`claude`),z(null),ee([]),H(``),ne([]),ie(`medium`),oe(``)},[]),ze=gt(f),Be=Object.values(ze).some(Boolean)||c.length>0||ae.trim().length>0,G=(0,Q.useMemo)(()=>BA(m??f,{milestoneLabel:`M1`,minSpecs:JA.minSpecs,maxSpecs:JA.maxSpecs,requireScaffold:!0}),[f,m]),Ve=se.status===`generating`,He=(0,Q.useMemo)(()=>HA(f,m??f,G,JA,{generating:Ve}),[f,m,G,Ve]),Ue=(0,Q.useMemo)(()=>{if(G.valid)return null;let e=G.issues[0];return e?WA(n,e):null},[G,n]),We=(0,Q.useMemo)(()=>Pt(u),[u]);return{phase:v,messages:c,streamBuffer:u,blueprint:f,busy:g,commitError:b,commitErrorDetail:S,commitSteps:E,createdProjectId:O,launching:A,launched:M,submitting:P,conversationReady:e&&!pe,conversationId:o,dirty:Be,canProposeCommit:G.valid,specQualityDetail:Ue,readiness:He,snapshot:se,generation:We,recent:le,recentLoading:de,resume:Ae,discardRecent:je,repairSnapshot:Me,showSurpriseMe:c.length<=1&&v===`chat`,provider:I,model:R,models:B,efforts:ge,effort:re,draft:ae,setDraft:oe,setEffort:ie,setProvider:De,setModel:Oe,send:ke,surpriseMe:Ne,approveBlueprint:Pe,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:Fe,launchM1:Ie,openProject:Le,abortAndReset:Re}}var $A={done:`bg-accent-success`,onReview:`bg-accent-warning`,inProgress:`bg-accent-info animate-pulse`,failed:`bg-destructive`,todo:`bg-muted-foreground/25`},ej={planned:`border-border/60 bg-surface/60 text-foreground/60`,committed:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,running:`border-accent-info/40 bg-accent-info/10 text-accent-info`,delivered:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,done:`border-accent-success/40 bg-accent-success/10 text-accent-success`};function tj({counts:e,className:t}){let{t:n}=K(`builder`),r=kt(e);return(0,$.jsx)(`div`,{className:X(`flex h-1.5 w-full overflow-hidden rounded-full bg-muted`,t),role:`img`,"aria-label":n(`milestoneProgress.counts`,{delivered:Nt(e),total:e.total,done:e.done}),"data-testid":`milestone-progress-bar`,children:r.map(e=>(0,$.jsx)(`div`,{"data-segment":e.key,className:X(`h-full transition-all duration-500`,$A[e.key]),style:{width:`${e.pct}%`},title:`${n(`milestoneProgress.legend.${e.key}`)} · ${e.count}`},e.key))})}function nj({state:e}){let{t}=K(`builder`);return(0,$.jsx)(`span`,{"data-testid":`milestone-state-pill`,"data-state":e,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[9px] font-semibold uppercase tracking-wide`,ej[e]),children:t(`milestoneProgress.state.${e}`)})}function rj(e){let[t,n]=(0,Q.useState)(()=>Date.now());return(0,Q.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function ij({rail:e,now:t,onReview:n,onOpenRail:r}){let{t:i}=K(`builder`),a=e.name??i(`milestoneProgress.rail.fallbackName`,{n:e.railIndex+1}),o=e.active&&e.startedAt?Math.max(0,t-Date.parse(e.startedAt)):null,s=e.delivery?.decision??null,c=s!==null&&wt.has(s)&&e.delivery!==null;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/30 bg-surface/40 px-2 py-1.5`,"data-testid":`milestone-rail-row`,"data-rail-index":e.railIndex,children:[e.chunkIndex!=null&&(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-muted/70 px-1 py-px text-[9px] font-mono tabular-nums text-muted-foreground`,title:i(`milestoneProgress.rail.chunk`,{k:e.chunkIndex}),children:e.chunkIndex}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.railIndex),className:`min-w-0 flex-1 truncate text-left text-[11px] font-medium hover:underline`,title:i(`milestoneProgress.rail.open`),children:a}),e.active?(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-accent-info`,"data-testid":`milestone-rail-running`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),o==null?i(`milestoneProgress.state.running`):i(`milestoneProgress.rail.running`,{elapsed:kO(o)})]}):s?(0,$.jsx)(Ek,{decision:s}):(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`milestoneProgress.rail.noDelivery`)}),c&&e.delivery&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n?.(e.delivery.id),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-primary hover:bg-accent-primary/20`,"data-testid":`milestone-rail-review`,children:[(0,$.jsx)(Qo,{className:`h-3 w-3`,"aria-hidden":!0}),i(`milestoneProgress.rail.review`)]})]})}function aj({checked:e,onChange:t,disabled:n=!1,compact:r=!1,testId:i=`milestone-auto-advance`}){let{t:a}=K(`builder`),o=a(e?`milestoneProgress.chain.autoAdvanceHint`:`milestoneProgress.chain.checkpointHint`);return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a(`milestoneProgress.chain.autoAdvance`),disabled:n,onClick:()=>t(!e),title:o,className:X(`group inline-flex items-center gap-1.5 rounded-md border px-1.5 py-1 text-left text-[10px] transition-colors disabled:opacity-50`,e?`border-accent-success/40 bg-accent-success/10 text-accent-success`:`border-border/50 text-muted-foreground hover:text-foreground`,r?`py-0.5`:`w-full`),"data-testid":i,"data-checked":e,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`relative inline-flex h-3 w-5 shrink-0 items-center rounded-full transition-colors`,e?`bg-accent-success/70`:`bg-muted-foreground/30`),children:(0,$.jsx)(`span`,{className:X(`absolute h-2 w-2 rounded-full bg-background shadow transition-transform`,e?`translate-x-2.5`:`translate-x-0.5`)})}),e?(0,$.jsx)(hn,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(ns,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:a(`milestoneProgress.chain.autoAdvance`)}),!r&&(0,$.jsx)(`span`,{className:`hidden truncate text-[9px] font-normal text-muted-foreground group-hover:inline`,children:o})]})}function oj({chain:e,busy:t=!1,onResume:n,onCancel:r,onSetAutoAdvance:i}){let{t:a}=K(`builder`),o=Ot(e),s=e.status===`paused`,c=_t(e),l=jt(e.pauseReason),u=s?a(`milestoneProgress.chain.reasons.${l.key}`,{detail:l.detail,defaultValue:e.pauseReason??``}):null,d=e.mode===`sequential`&&(o||s||c)&&!!i;return(0,$.jsxs)(`div`,{className:X(`rounded-md border px-2 py-1.5 text-[10px]`,s?`border-accent-warning/40 bg-accent-warning/5`:c?`border-accent-success/40 bg-accent-success/5`:o?`border-accent-info/30 bg-accent-info/5`:`border-border/30 bg-surface/40`),"data-testid":`milestone-chain-row`,"data-status":e.status,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(xs,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.mode===`parallel`?a(`milestoneProgress.chain.parallelTitle`):a(`milestoneProgress.chain.title`)}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a(`milestoneProgress.chain.progress`,{k:Math.min(e.nextChunk,e.totalChunks),n:e.totalChunks})]}),(0,$.jsx)(`span`,{className:`flex-1`}),c&&n&&(0,$.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>n(e.id),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 font-medium text-accent-success hover:bg-accent-success/20 disabled:opacity-50`,"data-testid":`milestone-chain-launch-next`,children:[t?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(on,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.launchNext`)]}),s&&n&&(0,$.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>n(e.id),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 font-medium text-accent-success hover:bg-accent-success/20 disabled:opacity-50`,"data-testid":`milestone-chain-resume`,children:[t?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(on,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.resume`)]}),(o||s||c)&&r&&(0,$.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(e.id),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-muted-foreground hover:text-foreground disabled:opacity-50`,title:a(`milestoneProgress.chain.cancel`),"data-testid":`milestone-chain-cancel`,children:(0,$.jsx)(mn,{className:`h-3 w-3`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1 text-muted-foreground`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zs,{className:`h-3 w-3 shrink-0 text-accent-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-accent-warning`,children:a(`milestoneProgress.chain.paused`,{reason:u})})]}):c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ns,{className:`h-3 w-3 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-accent-success`,"data-testid":`milestone-chain-checkpoint`,children:a(`milestoneProgress.chain.checkpoint`,{k:e.nextChunk,next:e.nextChunk+1,n:e.totalChunks})}),e.headBranch&&(0,$.jsxs)(`span`,{className:`truncate font-mono`,title:e.headBranch,children:[` · `,a(`milestoneProgress.chain.stackedOn`,{branch:e.headBranch})]})]}):e.status===`running`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})}),e.headBranch&&e.mode===`sequential`&&(0,$.jsxs)(`span`,{className:`truncate font-mono`,title:e.headBranch,children:[` · `,a(`milestoneProgress.chain.stackedOn`,{branch:e.headBranch})]}),e.mode===`sequential`&&!e.autoAdvance&&e.nextChunk<e.totalChunks&&(0,$.jsxs)(`span`,{className:`shrink-0`,"data-testid":`milestone-chain-checkpoint-note`,children:[` · `,a(`milestoneProgress.chain.checkpointNote`)]})]}):e.status===`completed`?(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.completed`)}):e.status===`cancelled`?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(yo,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.cancelled`)]}):(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})})}),d&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(aj,{checked:e.autoAdvance,disabled:t,onChange:t=>i(e.id,t),testId:`milestone-chain-auto-advance`})})]})}function sj({progress:e,actions:t,chainBusy:n,onReview:r,onOpenRail:i,onResume:a,onCancel:o,onSetAutoAdvance:s,className:c}){let{t:l}=K(`builder`),u=e.rails.some(e=>e.active),d=rj(u),{counts:f}=e,p=e.chain!==null&&e.chain.status!==`completed`&&e.chain.status!==`cancelled`||e.chain&&e.chain.status===`completed`&&e.rails.length>0&&u?e.chain:null;return(0,$.jsxs)(`div`,{className:X(`rounded-md border border-border/30 px-2 py-1.5`,c),"data-testid":`milestone-card`,"data-milestone":e.n,"data-state":e.state,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] font-semibold text-accent-primary`,children:xt(e.n)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium`,children:e.title}),(0,$.jsx)(nj,{state:e.state})]}),f.total>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tj,{counts:f,className:`mt-1.5`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[10px] tabular-nums text-muted-foreground`,children:[(0,$.jsx)(`span`,{"data-testid":`milestone-counts`,children:l(`milestoneProgress.counts`,{delivered:Nt(f),total:f.total,done:f.done})}),f.inProgress>0&&(0,$.jsxs)(`span`,{className:`text-accent-info`,children:[l(`milestoneProgress.legend.inProgress`),` · `,f.inProgress]})]}),f.failed>0&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-destructive`,"data-testid":`milestone-failed-note`,children:l(`milestoneProgress.failedNote`,{count:f.failed})})]}),t&&(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:t}),p&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(oj,{chain:p,busy:n,onResume:a,onCancel:o,onSetAutoAdvance:s})}),e.rails.length>0&&(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`milestone-rails`,children:e.rails.map(e=>(0,$.jsx)(ij,{rail:e,now:d,onReview:r,onOpenRail:i},e.railIndex))})]})}function cj({projectId:e}){let{t}=K(`builder`),n=v(),{setActiveProjectId:r}=at(),{progress:i,hasBlueprint:a}=Dt(e),[o,s]=(0,Q.useState)(!1),c=i.find(e=>e.n===1)??null,l=(0,Q.useCallback)(t=>{r(e),setTimeout(()=>n(t),50)},[n,e,r]),u=(0,Q.useCallback)(async n=>{s(!0);try{let r=await OA(e,n);r.ok?J.success(t(`milestoneProgress.chain.resumed`)):J.error(t(`milestoneProgress.chain.resumeFailed`),{description:r.detail??r.error})}finally{s(!1)}},[e,t]),d=(0,Q.useCallback)(async(n,r)=>{s(!0);try{let i=await AA(e,n,r);i.ok?(xA(r),J.success(t(r?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):J.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{s(!1)}},[e,t]),f=(0,Q.useCallback)(async n=>{s(!0);try{let r=await kA(e,n);r.ok?J.success(t(`milestoneProgress.chain.cancelledToast`)):J.error(r.detail??r.error)}finally{s(!1)}},[e,t]);return a===null&&!c?(0,$.jsx)(`div`,{className:`mt-4 flex items-center justify-center gap-2 text-xs text-muted-foreground`,"data-testid":`builder-done-milestone-loading`,children:(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0})}):c?(0,$.jsx)(`div`,{className:`mt-4 text-left`,"data-testid":`builder-done-milestone`,children:(0,$.jsx)(sj,{progress:c,chainBusy:o,onReview:e=>l(ve?`/review/${e}`:`/`),onOpenRail:()=>l(`/`),onResume:u,onCancel:f,onSetAutoAdvance:d,className:`bg-card/60`})}):null}var lj={surprise:mc,approve:Xs};function uj({kind:e,mode:t,onAction:n,disabled:r=!1,createdAt:i,className:a}){let{t:o}=K(`builder`),s=dy(),c=t===`settled`,l=c?Ht:lj[e],u=i?dj(i):null,d=X(`group relative my-1 w-full max-w-lg overflow-hidden rounded-xl border text-left shadow-lg backdrop-blur`,c?`border-accent-success/25 bg-card/60`:`border-accent-primary/25 bg-card/80 transition-colors hover:border-accent-primary/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-60`,a),f=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-0 bg-gradient-to-br via-transparent transition-opacity`,c?`from-accent-success/[0.06] to-accent-success/[0.03] opacity-100`:`from-accent-primary/[0.08] to-accent-highlight/[0.08] opacity-70 group-hover:opacity-100`)}),(0,$.jsxs)(`div`,{className:X(`relative flex items-center justify-between gap-2 border-b border-border/40 px-3.5 py-2`,c?`bg-accent-success/[0.05]`:`bg-accent-primary/[0.06]`),children:[(0,$.jsxs)(`span`,{className:X(`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest`,c?`text-accent-success/90`:`text-accent-primary/90`),children:[c?(0,$.jsx)(Ht,{className:`h-3 w-3`,"aria-hidden":!0}):(0,$.jsx)(un,{className:`h-3 w-3`,"aria-hidden":!0}),o(c?`decisionCard.settledLabel`:`decisionCard.${e}.label`)]}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`builder-decision-card-meta`,children:c?u:o(`decisionCard.${e}.hint`)})]}),(0,$.jsxs)(`div`,{className:`relative flex items-center gap-3.5 px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:X(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full shadow-inner`,c?`bg-accent-success/15 text-accent-success`:`bg-gradient-to-br from-accent-primary/25 to-accent-highlight/25 text-accent-primary`),children:(0,$.jsx)(l,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold leading-snug text-foreground`,children:o(c?`decisionCard.${e}.settledTitle`:`decisionCard.${e}.title`)}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-muted-foreground`,children:o(c?`decisionCard.${e}.settledDescription`:`decisionCard.${e}.description`)})]}),!c&&(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-accent-primary/15 px-2.5 py-1 text-[11px] font-medium text-accent-primary transition-colors group-hover:bg-accent-primary/25`,children:[o(`decisionCard.${e}.cta`),(0,$.jsx)(B,{className:`h-3 w-3 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})]});return c?(0,$.jsx)(`div`,{className:d,"data-testid":`builder-decision-card`,"data-kind":e,"data-mode":`settled`,children:f}):(0,$.jsx)(fy.button,{type:`button`,onClick:n,disabled:r,initial:s?{opacity:0}:{opacity:0,y:8},animate:{opacity:1,y:0},exit:s?{opacity:0}:{opacity:0,y:-6},transition:{duration:.22,ease:`easeOut`},whileHover:r||s?void 0:{y:-2},whileTap:r?void 0:{scale:.99},className:d,"data-testid":`builder-decision-card`,"data-kind":e,"data-mode":`offer`,"aria-label":o(`decisionCard.${e}.cta`),children:f})}function dj(e){let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return pb(t,`p`,{locale:Ue()})}catch{return null}}var fj=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function pj({variant:e}){let{t}=K(`builder`),{builderMode:n}=lM(),r=n.session,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(()=>bA()),c=(0,Q.useRef)(null),l=r.messages[r.messages.length-1],u=r.readiness.steps.find(e=>e.key===`blueprint`),d=r.readiness.steps.find(e=>e.key===`specs`),f=r.phase===`chat`&&!r.busy&&r.streamBuffer===null&&l?.role===`assistant`&&r.snapshot.status!==`generating`,p=f&&u?.state!==`done`,m=f&&u?.state===`done`&&(d===void 0||d.state===`pending`&&Number(d.params.count??0)===0)&&(r.blueprint?.m1Specs.length??0)===0;(0,Q.useEffect)(()=>{c.current?.scrollTo?.({top:c.current.scrollHeight})},[r.messages,r.streamBuffer]);let h=(0,Q.useCallback)(()=>{r.dirty&&r.phase!==`done`?a(!0):n.exit()},[r.dirty,r.phase,n]),g=(0,Q.useCallback)(e=>{e.key===`Escape`&&(e.stopPropagation(),i?a(!1):r.phase===`commit`&&!r.submitting?r.backToChat():r.phase===`chat`&&h())},[i,r,h]),_=r.messages.length===0&&r.streamBuffer===null&&!r.busy,v=e===`inline`?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,onKeyDown:g,"data-testid":`builder-conversation`,children:[r.phase===`chat`&&(_?(0,$.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,$.jsxs)(fy.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1]},className:X(`w-full`,e===`inline`?`max-w-[680px]`:`max-w-[560px]`),children:[(0,$.jsxs)(`div`,{className:`mb-4 text-center`,children:[(0,$.jsx)(un,{className:`mx-auto h-7 w-7 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:t(`shell.emptyTitle`)}),(0,$.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-muted-foreground`,children:t(`shell.emptyHint`)})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(JO,{active:!0,inset:-3,radius:`1rem`}),(0,$.jsx)(fy.div,{layoutId:e===`inline`?`builder-composer-dock`:void 0,"data-testid":`builder-composer-card`,"data-composer-position":`hero`,"data-layout-id":e===`inline`?`builder-composer-dock`:void 0,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:fj,children:(0,$.jsx)(dA,{session:r,autoFocus:!0})})]}),(0,$.jsx)(pA,{items:r.recent,loading:r.recentLoading,disabled:!r.conversationReady,onResume:e=>void r.resume(e),onDiscard:e=>void r.discardRecent(e)})]})}):(0,$.jsxs)(`div`,{className:v,children:[(0,$.jsxs)(`div`,{ref:c,className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,"data-testid":`builder-messages`,children:[r.messages.map((e,t)=>e.role===`user`&&e.intent?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(uj,{kind:e.intent,mode:`settled`,createdAt:e.createdAt})},`${t}-${e.createdAt}`):(0,$.jsx)(Rx,{role:e.role,content:e.content,createdAt:e.createdAt,isLast:r.streamBuffer===null&&!r.busy&&t===r.messages.length-1,onPickOption:e=>r.send(e)},`${t}-${e.createdAt}`)),(0,$.jsxs)(f_,{initial:!1,children:[p&&(0,$.jsx)(uj,{kind:`surprise`,mode:`offer`,onAction:r.surpriseMe,disabled:!r.conversationReady},`surprise`),m&&(0,$.jsx)(uj,{kind:`approve`,mode:`offer`,onAction:r.approveBlueprint,disabled:!r.conversationReady},`approve`)]}),(r.busy||r.streamBuffer!==null)&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r.streamBuffer!==null&&St(r.streamBuffer)&&(0,$.jsx)(Rx,{role:`assistant`,content:St(r.streamBuffer),streaming:!0}),r.generation.generating||r.snapshot.status===`repairing`||r.snapshot.status===`generating`?(0,$.jsx)(mA,{specsStarted:r.generation.specsStarted,snapshot:r.snapshot}):(0,$.jsx)(bb,{tool:null})]})]}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(fy.div,{layoutId:e===`inline`?`builder-composer-dock`:void 0,"data-testid":`builder-composer-card`,"data-composer-position":`docked`,"data-layout-id":e===`inline`?`builder-composer-dock`:void 0,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:X(fj,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,$.jsx)(dA,{session:r})})})]})),r.phase===`commit`&&r.blueprint&&(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto`,children:(0,$.jsx)(uA,{blueprint:r.blueprint,onSubmit:r.submitCommit,onBack:r.backToChat,submitting:r.submitting,error:r.commitError,errorDetail:r.commitErrorDetail})}),r.phase===`progress`&&(0,$.jsxs)(`div`,{className:`mx-auto mt-10 w-full max-w-md p-6`,"data-testid":`commit-progress`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:t(`progress.title`)}),(0,$.jsx)(`ul`,{className:`mt-4 space-y-2`,children:qA.map(e=>{let n=r.commitSteps.find(t=>t.step===e);return!n&&e===`github`?null:(0,$.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[!n&&(0,$.jsx)(No,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,$.jsx)(fn,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,$.jsx)(mn,{className:`h-3.5 w-3.5 text-destructive`}),(0,$.jsx)(`span`,{className:X(!n&&`text-muted-foreground/50`),children:t(`progress.steps.${e}`)}),n?.status===`warning`&&e===`github`?(0,$.jsx)(`span`,{className:`truncate text-[10px] text-accent-warning`,title:n.detail,children:t(KA(n.code))}):n?.detail&&(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,title:n.detail,children:n.detail})]},e)})})]}),r.phase===`done`&&(0,$.jsxs)(`div`,{className:`mx-auto mt-12 w-full max-w-md p-6 text-center`,"data-testid":`commit-done`,children:[(0,$.jsx)(Ht,{className:`mx-auto h-10 w-10 rounded-full bg-accent-success/15 p-2 text-accent-success`}),(0,$.jsx)(`h2`,{className:`mt-3 text-sm font-semibold`,children:t(`done.title`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`done.description`)}),r.launched&&r.createdProjectId&&(0,$.jsx)(cj,{projectId:r.createdProjectId}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2`,children:[!r.launched&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{onClick:()=>void r.launchM1(),disabled:r.launching,"data-testid":`launch-m1`,children:[r.launching?(0,$.jsx)(rn,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),_A()===`sequential`&&(0,$.jsx)(aj,{checked:o,onChange:e=>{s(e),xA(e)},disabled:r.launching,testId:`done-auto-advance`})]}),(0,$.jsx)(Z,{variant:`outline`,onClick:r.openProject,"data-testid":`open-project`,children:t(`done.openProject`)})]})]}),i&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/70 backdrop-blur-sm`,"data-testid":`builder-exit-confirm`,children:(0,$.jsxs)(`div`,{className:`w-72 rounded-lg border border-border/60 bg-card p-4 shadow-xl`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`builder-exit-confirm-title`,children:[(0,$.jsx)(`p`,{id:`builder-exit-confirm-title`,className:`text-sm font-medium`,children:t(`mode.exitConfirmTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`mode.exitConfirmBody`)}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>a(!1),"data-testid":`builder-exit-cancel`,children:t(`mode.exitConfirmCancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n.exit()},"data-testid":`builder-exit-confirm-btn`,children:t(`mode.exitConfirmDiscard`)})]})]})})]})}var mj=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-4 [&_h2]:mb-1.5 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-2.5 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-2.5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_hr]:my-3 [&_hr]:border-border/60`),hj={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`};function gj({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=K(`builder`),{t:a}=K(`tickets`),o=`blueprint-spec-summary-${t}`;return(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,xb.createPortal)((0,$.jsxs)(`div`,{"data-testid":`blueprint-spec-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:r,"aria-hidden":!0}),(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e.title,"aria-describedby":e.shortSummary.trim()?o:void 0,className:`relative flex max-h-[82vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-border/40 bg-popover shadow-2xl backdrop-blur-md`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/40 px-5 py-4`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:i(`specModal.eyebrow`,{milestone:n,index:t+1})}),(0,$.jsx)(`h2`,{className:`mt-0.5 text-base font-semibold text-foreground`,children:e.title}),e.shortSummary.trim()&&(0,$.jsxs)(`p`,{id:o,className:`mt-1 text-xs leading-5 text-muted-foreground`,"data-testid":`blueprint-spec-summary`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[i(`specModal.summary`),`: `]}),e.shortSummary]}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,hj[e.priority]),"data-testid":`blueprint-spec-priority`,"aria-label":`${i(`specModal.priority`)}: ${a(`priority.${e.priority}`)}`,children:a(`priority.${e.priority}`)}),e.labels.map(e=>(0,$.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] text-accent-primary`,children:e},e)),e.dependsOnIndex!==void 0&&(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:i(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`specModal.close`),"data-agent-interactive":!0,className:`rounded-md p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground`,"data-testid":`blueprint-spec-modal-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`section`,{"aria-label":i(`specModal.description`),"data-testid":`blueprint-spec-description`,children:e.description.trim()?(0,$.jsx)(`div`,{className:mj,children:(0,$.jsx)(Jn,{remarkPlugins:[Yn],children:e.description})}):(0,$.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.empty`)})}),(0,$.jsxs)(`section`,{"aria-labelledby":`blueprint-spec-criteria-heading`,"data-testid":`blueprint-spec-acceptance-criteria`,children:[(0,$.jsxs)(`h3`,{id:`blueprint-spec-criteria-heading`,className:`mb-2 flex items-center justify-between gap-2 text-xs font-semibold uppercase tracking-wider text-foreground/60`,children:[(0,$.jsx)(`span`,{children:i(`specModal.acceptanceCriteria`)}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:e.acceptanceCriteria.length})]}),e.acceptanceCriteria.length>0?(0,$.jsx)(`ol`,{className:`space-y-2`,children:e.acceptanceCriteria.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 text-sm leading-6 text-foreground/85`,"data-testid":`blueprint-spec-criterion-${t}`,children:[(0,$.jsx)(Mo,{className:`mt-1 h-4 w-4 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:e})]},`${t}-${e}`))}):(0,$.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.criteriaEmpty`)})]})]})]})]}),document.body)}var _j={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`};function vj({blueprint:e,milestoneLabel:t=`M1`,snapshot:n}){let{t:r}=K(`builder`),{t:i}=K(`tickets`),a=gt(e),[o,s]=(0,Q.useState)(null),c=[{key:`product`,label:r(`panel.product`),value:e?.product.name??``},{key:`coreFlow`,label:r(`panel.coreFlow`),value:e?.coreFlow??``},{key:`platform`,label:r(`panel.platform`),value:e?.platform??``},{key:`stack`,label:r(`panel.stack`),value:e?[e.stack.language,e.stack.framework,e.stack.db].filter(Boolean).join(` · `):``},{key:`milestones`,label:r(`panel.milestones`),value:e&&e.milestones.length>0?r(`panel.milestonesValue`,{count:e.milestones.length}):``}];return(0,$.jsxs)(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`blueprint-panel`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[r(`panel.title`),n?.status===`repairing`&&(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin text-accent-info`,"aria-hidden":!0,"data-testid":`panel-repairing`})]}),(0,$.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>(0,$.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs transition-colors`,a[e.key]?`border-accent-success/30 bg-accent-success/5`:`border-border/30`),"data-testid":`dimension-${e.key}`,children:[a[e.key]?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,$.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/40`,"aria-label":`✗`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.value&&(0,$.jsx)(`span`,{className:`ml-auto truncate text-muted-foreground`,title:e.value,children:e.value})]},e.key))})]}),e&&e.assumptions.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`panel.assumptions`)}),(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:e.assumptions.map((e,t)=>(0,$.jsx)(`li`,{className:`text-[11px] text-muted-foreground before:mr-1.5 before:content-['·']`,children:e},t))})]}),e&&e.m1Specs.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`h4`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(xs,{className:`h-3 w-3`}),r(`panel.m1Specs`,{count:e.m1Specs.length}),(0,$.jsx)(`span`,{className:X(`ml-auto rounded-full border px-1.5 py-px text-[9px] font-medium normal-case tracking-normal`,e.specsComplete?`border-accent-success/35 bg-accent-success/10 text-accent-success`:`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`),"data-testid":`m1-specs-completeness`,children:e.specsComplete?r(`panel.specsComplete`):r(`panel.specsInProgress`)})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.m1Specs.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(t),"data-agent-interactive":!0,className:`w-full rounded-lg border border-border/40 bg-surface/50 p-2.5 text-left shadow-sm transition-colors animate-in fade-in slide-in-from-bottom-1 hover:border-accent-primary/50 hover:bg-surface/80 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,"data-testid":`m1-spec-card-${t}`,title:r(`specModal.open`),children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium leading-tight`,children:e.title}),e.shortSummary.trim()&&(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-4 text-muted-foreground`,"data-testid":`m1-spec-summary-${t}`,children:e.shortSummary}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,_j[e.priority]),"data-testid":`m1-spec-priority-${t}`,children:i(`priority.${e.priority}`)}),!e.description.trim()&&e.acceptanceCriteria.length===0?(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 rounded-full border px-1.5 py-px text-[9px]`,n?.status===`generating`?`border-accent-info/35 bg-accent-info/10 text-accent-info`:`border-border/50 bg-surface/70 text-muted-foreground`),"data-testid":`m1-spec-unwritten-${t}`,children:[n?.status===`generating`?(0,$.jsx)(rn,{className:`h-2.5 w-2.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ts,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),r(n?.status===`generating`?`panel.specWriting`:`panel.specPendingBody`)]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/50 bg-surface/70 px-1.5 py-px text-[9px] text-muted-foreground`,"data-testid":`m1-spec-criteria-count-${t}`,children:[(0,$.jsx)(Ts,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),r(`panel.criteriaCount`,{count:e.acceptanceCriteria.length})]}),e.labels.map(e=>(0,$.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] text-accent-primary`,children:e},e)),e.dependsOnIndex!==void 0&&(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:r(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]})]})},`${t}-${e.title}`))})]}),e&&e.milestones.length>1&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`panel.laterMilestones`)}),e.milestones.slice(1).map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/20 px-2.5 py-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:e.title}),e.plannedSpecs.length>0&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.plannedSpecs.join(` · `)})]},e.id||e.title))]}),!e&&(0,$.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground/60`,children:r(`panel.empty`)}),e&&o!==null&&e.m1Specs[o]&&(0,$.jsx)(gj,{spec:e.m1Specs[o],index:o,milestoneLabel:t,onClose:()=>s(null)})]})}var yj={done:Ht,pending:No,blocked:fn,writing:rn},bj={done:`text-accent-success`,pending:`text-muted-foreground/50`,blocked:`text-accent-warning`,writing:`text-accent-info animate-spin`};function xj({readiness:e,snapshot:t,busy:n,primaryLabel:r,onPrimary:i,onRepair:a,primaryTestId:o=`builder-create-specs`,showPrimary:s=!0}){let{t:c}=K(`builder`),[l,u]=(0,Q.useState)(!1),d=t.status===`repairing`,f=t.status===`rejected`,p=t.status===`accepted`&&t.generationHalted===!0&&!n,m=e.steps.find(e=>e.key===`specs`),h=m?.state===`done`,g=!!a&&h&&e.issues.length>0,_=e.steps.find(e=>e.state!==`done`);return(0,$.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/40 p-3`,"data-testid":`blueprint-readiness`,children:[(0,$.jsx)(`ol`,{className:`space-y-1`,"aria-label":c(`readiness.title`),children:e.steps.map(e=>{let t=yj[e.state];return(0,$.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4`,"data-testid":`readiness-step-${e.key}`,"data-state":e.state,children:[(0,$.jsx)(t,{className:X(`mt-px h-3.5 w-3.5 shrink-0`,bj[e.state]),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:X(`font-medium`,e.state===`pending`&&`text-muted-foreground`,e.state===`writing`&&`text-accent-info`),children:c(`readiness.steps.${e.key}`)}),(0,$.jsx)(`span`,{className:`ml-auto max-w-[60%] truncate text-right text-muted-foreground`,title:c(`readiness.details.${e.key}.${e.state}`,e.params),children:c(`readiness.details.${e.key}.${e.state}`,e.params)})]},e.key)})}),(0,$.jsxs)(f_,{initial:!1,mode:`wait`,children:[d&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`flex items-center gap-2 rounded-md border border-accent-info/30 bg-accent-info/10 px-2.5 py-1.5 text-[11px] text-accent-info`,"data-testid":`snapshot-repairing`,children:[(0,$.jsx)(rn,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c(`snapshot.repairing.${t.kind}`),t.manual?``:` · ${c(`snapshot.repairing.automatic`)}`]})]},`repairing`),f&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`space-y-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 p-2.5`,"data-testid":`snapshot-rejected`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:c(`snapshot.rejected.title`)}),(0,$.jsx)(`p`,{className:`text-accent-warning/90`,children:c(`snapshot.rejected.${t.reason}`)}),t.repairAttempted&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-accent-warning/80`,children:c(`snapshot.rejected.autoRepairFailed`)})]})]}),t.detail&&(0,$.jsx)(`p`,{className:`line-clamp-2 break-all font-mono text-[10px] leading-4 text-foreground/60`,title:t.detail,"data-testid":`snapshot-rejected-detail`,children:t.detail}),a&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`snapshot-retry`,children:[(0,$.jsx)(Js,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.rejected.retry`)]})]},`rejected`),p&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`space-y-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 p-2.5`,"data-testid":`snapshot-halted`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:c(`snapshot.halted.title`)}),(0,$.jsx)(`p`,{className:`text-accent-warning/90`,children:c(`snapshot.halted.detail`,{written:m?.params?.written??0,total:m?.params?.count??0})})]})]}),a&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`snapshot-resume`,children:[(0,$.jsx)(un,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.halted.resume`)]})]},`halted`),t.status===`accepted`&&t.repaired&&!p&&(0,$.jsxs)(fy.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,"data-testid":`snapshot-repaired`,children:[(0,$.jsx)(un,{className:`h-3 w-3 text-accent-success`,"aria-hidden":!0}),c(`snapshot.repairedNote`)]},`repaired`)]}),e.issues.length>0&&(0,$.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-surface/40`,"data-testid":`readiness-issues`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-expanded":l,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] font-medium text-foreground/80 hover:bg-surface/70`,"data-testid":`readiness-issues-toggle`,children:[(0,$.jsx)(pn,{className:`h-3 w-3 text-accent-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`readiness.issuesCount`,{count:e.issues.length})}),(0,$.jsx)(Zt,{className:X(`h-3.5 w-3.5 transition-transform`,l&&`rotate-180`),"aria-hidden":!0})]}),l&&(0,$.jsx)(`ul`,{className:`max-h-40 space-y-1 overflow-y-auto border-t border-border/30 px-2.5 py-2`,children:e.issues.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[10px] leading-4 text-muted-foreground`,children:[e.specIndex!==null&&(0,$.jsxs)(`span`,{className:`shrink-0 rounded bg-accent-primary/10 px-1 font-mono text-[9px] text-accent-primary`,children:[`#`,e.specIndex+1]}),(0,$.jsx)(`span`,{children:WA(c,e)})]},`${e.specIndex}-${e.field}-${e.code}-${t}`))}),g&&(0,$.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`readiness-ask-fix`,children:[(0,$.jsx)(pn,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`readiness.askFix`)]})})]}),s&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Z,{className:`w-full`,size:`sm`,disabled:!e.ready||n,onClick:i,"data-testid":o,children:[(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`,"aria-hidden":!0}),r]}),!e.ready&&_&&!d&&!f&&!p&&(0,$.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,"data-testid":`readiness-hint`,children:c(`readiness.hints.${_.key}.${_.state}`,_.params)})]})]})}function Sj(){let{t:e}=K(`agent`),{t}=K(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=lM(),[l,u]=(0,Q.useState)(!1),d=c.active,f=e=>{d||e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),i())},{panelRef:p,panelStyle:m,headerHandleProps:h,resizeHandles:g}=bn({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(fy.div,{ref:p,initial:{opacity:0,scale:.85,y:8},animate:{opacity:1,scale:1,y:0},transition:{duration:.22,ease:[.34,1.56,.64,1]},style:l?{position:`fixed`,inset:12,width:`auto`,height:`auto`,maxWidth:`none`,maxHeight:`none`}:m,role:`dialog`,"aria-label":d?t(`mode.title`):e(`title`),onKeyDown:f,className:`fixed z-[60] flex flex-col overflow-hidden rounded-2xl border border-border/60 bg-card/90 shadow-2xl backdrop-blur-xl ${l?``:`bottom-4 right-4 h-[78vh] max-h-[94vh] max-w-[92vw] ${d?`w-[860px]`:`w-[520px]`}`}`,children:[(0,$.jsxs)(`div`,{...l?{}:h,onDoubleClick:()=>u(e=>!e),className:`flex shrink-0 items-center gap-2 border-b border-border/50 bg-surface/40 px-3 py-2 ${l?``:`cursor-grab`}`,children:[(0,$.jsxs)(`span`,{className:`relative flex h-5 w-5 shrink-0 items-center justify-center`,children:[(0,$.jsx)(JO,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,$.jsx)(So,{className:`h-4 w-4 shrink-0 text-accent-primary`})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:d?t(`mode.title`):e(`title`)}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dD,{pinnedProjectId:a?a.pinned_project_id:o,onSelect:e=>void s(e)}),(0,$.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,$.jsx)(Xk,{})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[!d&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(null),title:e(`newConversation`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,$.jsx)(cn,{className:`h-4 w-4`})}),(0,$.jsx)(_c,{}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-label":e(l?`restore`:`maximize`),title:e(l?`restore`:`maximize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:l?(0,$.jsx)(ks,{className:`h-4 w-4`}):(0,$.jsx)(Os,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":e(`minimize`),title:e(`minimize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]})]}),d?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(pj,{variant:`floating`}),(0,$.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,$.jsx)(vj,{blueprint:c.session.blueprint,snapshot:c.session.snapshot}),c.session.phase===`chat`&&(0,$.jsx)(xj,{readiness:c.session.readiness,snapshot:c.session.snapshot,busy:c.session.busy,primaryLabel:t(`shell.createSpecs`),onPrimary:c.session.goToCommit,onRepair:()=>void c.session.repairSnapshot()})]})]}):(0,$.jsx)(Kk,{variant:`floating`})]}),!l&&(0,$.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,$.jsx)(Nn,{handles:g})})]})}var Cj=`specrails-desktop:agent-bubble-pos`,wj=56,Tj=12;function Ej(){try{let e=localStorage.getItem(Cj);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function Dj(e){let t=Math.max(Tj,window.innerWidth-wj-Tj),n=Math.max(Tj,window.innerHeight-wj-Tj);return{left:Math.min(Math.max(Tj,e.left),t),top:Math.min(Math.max(Tj,e.top),n)}}function Oj(){return{left:Math.round(window.innerWidth/2-wj/2),top:window.innerHeight-wj-20}}function kj(){let{t:e}=K(`agent`),{t}=K(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=lM(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(()=>Dj(Ej()??Oj())),u=uy(0),d=uy(0),f=(0,Q.useRef)(!1),p=a.active?a.session.busy:r;(0,Q.useEffect)(()=>{let e=()=>l(e=>Dj(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Q.useCallback)(e=>{try{localStorage.setItem(Cj,JSON.stringify(e))}catch{}},[]);return(0,$.jsxs)(fy.button,{type:`button`,onClick:()=>{if(f.current){f.current=!1;return}n()},onHoverStart:()=>s(!0),onHoverEnd:()=>s(!1),"aria-label":e(`trigger`),title:`${e(`trigger`)} (⌘⇧A)`,drag:!0,dragMomentum:!1,dragElastic:0,style:{position:`fixed`,left:c.left,top:c.top,x:u,y:d},onDragStart:()=>{f.current=!0},onDragEnd:()=>{let e=Dj({left:c.left+u.get(),top:c.top+d.get()});u.set(0),d.set(0),l(e),m(e),setTimeout(()=>{f.current=!1},0)},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:420,damping:28},whileHover:{scale:1.06},whileTap:{scale:.94},whileDrag:{scale:1.1,cursor:`grabbing`},className:`z-[60] flex h-14 items-center gap-2 rounded-full border border-border/60 bg-card/85 px-3 shadow-2xl backdrop-blur-xl cursor-grab`,children:[(0,$.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,$.jsx)(JO,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,$.jsx)(So,{className:`h-5 w-5 text-accent-primary`}),p&&(0,$.jsx)(fy.span,{className:`absolute inset-0 rounded-full ring-2 ring-accent-success`,animate:{opacity:[.8,.2,.8],scale:[1,1.18,1]},transition:{duration:1.4,repeat:1/0,ease:`easeInOut`}})]}),(0,$.jsx)(f_,{initial:!1,children:(o||p)&&(0,$.jsx)(fy.span,{initial:{opacity:0,width:0,marginRight:0},animate:{opacity:1,width:`auto`,marginRight:4},exit:{opacity:0,width:0,marginRight:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden whitespace-nowrap text-sm font-medium text-foreground`,children:p?e(`thinking`):a.active?t(`mode.title`):i?.title||e(`trigger`)})})]})}var Aj=`specrails-desktop:uiMode`;function jj(){if(!y)return`kanban`;try{return localStorage.getItem(Aj)===`kanban`?`kanban`:`agent`}catch{return`agent`}}function Mj(e){try{localStorage.setItem(Aj,e)}catch{}}var Nj=(0,Q.createContext)(null);function Pj({children:e,initialMode:t,persist:n=!0}){let[r,i]=(0,Q.useState)(()=>t??jj()),a=(0,Q.useCallback)(e=>{y&&(i(e),n&&Mj(e))},[n]),o=(0,Q.useCallback)(()=>{i(e=>{if(!y)return`kanban`;let t=e===`kanban`?`agent`:`kanban`;return n&&Mj(t),t})},[n]),s=(0,Q.useMemo)(()=>({uiMode:r,setUiMode:a,toggleUiMode:o}),[r,a,o]);return(0,$.jsx)(Nj.Provider,{value:s,children:e})}var Fj={uiMode:`kanban`,setUiMode:()=>{},toggleUiMode:()=>{}};function Ij(){return(0,Q.useContext)(Nj)??Fj}var Lj={streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queued:[]},Rj=`specrails-desktop:favorite-agent-conversations`;function zj(){try{let e=localStorage.getItem(Rj);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function Bj(e){try{localStorage.setItem(Rj,JSON.stringify([...e]))}catch{}}function Vj(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var Hj=`specrails-desktop:agent-tier-last`;function Uj(){try{let e=localStorage.getItem(Hj),t=e===null?0:Number.parseInt(e,10);return t===0||t===1||t===2||t===3?t:0}catch{return 0}}function Wj(e){try{localStorage.setItem(Hj,String(e))}catch{}}var Gj=new Set([`completed`,`merged`,`discarded`,`superseded`]);function Kj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qj(e){if(!e.createdAt)return null;let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(e.createdAt)?`${e.createdAt.replace(` `,`T`)}Z`:e.createdAt,n=Date.parse(t);return Number.isFinite(n)?n:null}function Jj(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=qj(e),r=qj(t);return n==null||r==null?null:r<n?-1:+(r>n)}function Yj(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=qj(n),i=qj(r);(e==null||i==null||i>=e)&&(n=r)}return n}function Xj(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=Yj(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function Zj(e,t){let n=e.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=Xj(n,t);if(r){let e=Gj.has(r.decision),n=Gj.has(t.decision),a=Ft(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!Kj(r,t)||e&&!n&&!(i&&r.decision===`superseded`))return!0}let a=new Set(n.map(e=>e.supersedesDeliveryId).filter(e=>!!e));if(i)return!1;if(a.has(t.prDeliveryId)&&t.decision!==`superseded`)return!0;for(let e of n){if(e.railIndex!==t.railIndex||e.prDeliveryId===t.prDeliveryId||a.has(e.prDeliveryId))continue;let n=Jj(e,t);if(n===-1||(n===0||n===null)&&!Gj.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function Qj(e,t){let n=t.restoredFromDeliveryId;if(!n)return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let t=io(e.content);return!t||t.prDeliveryId!==n||Gj.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function $j(e,t){let n=e.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&Xj(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=io(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||Gj.has(n.decision)||Jj(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function eM(e,t,n){if(Zj(e,n))return e;let r=$j(Qj(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&io(e.content)?.prDeliveryId===n.prDeliveryId?[t]:[]);if(a.length>0){let e=a[a.length-1];if(a.length===1&&r[e].content===i)return r;let t=new Set(a.slice(0,-1));return r.flatMap((n,r)=>t.has(r)?[]:[r===e?{...n,content:i}:n])}return[...r,{id:`prd-${n.prDeliveryId}`,conversation_id:t,role:`system`,content:i,created_at:new Date().toISOString()}]}var tM=(0,Q.createContext)(null),nM=0,rM=0,iM={sent:0,received:1,read:2};function aM(e,t){return e&&(!t||iM[e]>=iM[t])?e:t}function oM(e,t){let n=[...e];for(let[e,r]of t.entries()){let i=n.findIndex(e=>e.id===r.id);if(i>=0){let e=aM(n[i].delivery_receipt,r.delivery_receipt);n[i]={...r,...e?{delivery_receipt:e}:{}}}else{let i=new Set(t.slice(e+1).map(e=>e.id)),a=n.findIndex(e=>i.has(e.id));a>=0?n.splice(a,0,r):n.push(r)}}return n}function sM({children:e}){let{registerHandler:t,unregisterHandler:n,connectionStatus:r}=qe(),{uiMode:i}=Ij(),{setActiveProjectId:a,activeProjectId:o}=at(),s=si(),c=(0,Q.useRef)(s);c.current=s;let l=$r(),u=e=>e?c.current.isEditable(e):!l,[d,f]=(0,Q.useState)(`hidden`),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),y=(0,Q.useRef)(new Map),b=(0,Q.useRef)(_);b.current=_;let[x,S]=(0,Q.useState)(zj);(0,Q.useEffect)(()=>{let e=e=>{(e.key===Rj||e.key===null)&&S(zj())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let[C,w]=(0,Q.useState)(new Set),[T,E]=(0,Q.useState)(new Map),[D,O]=(0,Q.useState)(!0),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(null),I=(0,Q.useRef)(null);I.current=N;let[L,R]=(0,Q.useState)(`claude`),[z,B]=(0,Q.useState)(null),[ee,V]=(0,Q.useState)(()=>Uj()),[H,te]=(0,Q.useState)(null),ne=(0,Q.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});ne.current={provider:L,model:z,tierLevel:ee,effort:H};let re=(0,Q.useRef)(null);re.current=h?.id??null;let ie=(0,Q.useRef)(T);ie.current=T;let ae=(0,Q.useRef)(new Set),oe=(0,Q.useRef)(new Set),se=(0,Q.useRef)(new Map),ce=(0,Q.useRef)(new Map),le=e=>{let t=aM(e.delivery_receipt,se.current.get(`${e.conversation_id}:m:${e.id}`));return t?{...e,delivery_receipt:t}:e},ue=(e,t)=>{let n=aM(t.deliveryReceipt,se.current.get(`${e}:q:${t.queueId}`));return n?{...t,deliveryReceipt:n}:t},de=(0,Q.useRef)(new Set),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(new Map),me=(0,Q.useRef)(new Map),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(0),_e=(0,Q.useRef)(0),ve=(0,Q.useRef)(new Map),ye=(0,Q.useCallback)(e=>{let t=re.current;if(!t)return`untracked`;if(Zj(b.current,e))return`stale`;if(!b.current.some(t=>t.role===`system`&&io(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;ge.current++;let n=eM(b.current,t,e);return b.current=n,v(n=>{if(!n.some(t=>t.role===`system`&&io(t.content)?.prDeliveryId===e.prDeliveryId))return b.current=n,n;let r=eM(n,t,e);return b.current=r,r}),`accepted`},[]),U=(0,Q.useCallback)((e,t)=>{E(n=>{let r=t(n.get(e)??Lj),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.turnTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),be=(0,Q.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===re.current&&!t||w(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),xe=(0,Q.useCallback)(e=>{w(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Q.useEffect)(()=>{if(!P||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=re.current;e&&xe(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[xe]);let Se=(h?T.get(h.id):void 0)??Lj,Ce=Se.streamingText,W=Se.isStreaming,we=Se.liveTools,Te=Se.turnTools,Ee=Se.queued,De=(0,Q.useMemo)(()=>{let e=new Set;for(let[t,n]of T)n.isStreaming&&e.add(t);return e},[T]),Oe=(0,Q.useCallback)(async()=>{try{let e=await Ra();m(e),S(t=>{let n=Vj(zj(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(Bj(n),n)})}catch{}},[]),ke=(0,Q.useCallback)(async()=>{try{let e=await uo();O(e.enabled)}catch{O(!1)}},[]),Ae=(0,Q.useCallback)(async()=>{try{M((await lo()).any)}catch{M(!0)}},[]),[je,Me]=(0,Q.useState)(0);(0,Q.useEffect)(()=>P?(t(`agent-chat`,e=>{let t=e;if(!t)return;if(t.type===`desktop.project_recovered`){Me(e=>e+1);return}if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;m(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),g(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;fe.current.set(n,(fe.current.get(n)??0)+1);let r=n===re.current,i=e=>{me.current.set(n,oM(me.current.get(n)??[],e).slice(-500)),r&&(b.current=oM(b.current,e),v(t=>oM(t,e)))};if(t.type===`agent_input_receipt`){if(t.receipt!==`received`&&t.receipt!==`read`)return;let e=`${n}:q:${t.queueId}`,a=t.messageId??ce.current.get(e);if(t.queueId&&se.current.set(e,aM(se.current.get(e),t.receipt)),a){let e=`${n}:m:${a}`;se.current.set(e,aM(se.current.get(e),t.receipt));let o=(r?b.current:me.current.get(n)??[]).find(e=>e.id===a);o&&i([le(o)])}U(n,e=>({...e,queued:e.queued.map(e=>e.queueId===t.queueId?{...e,deliveryReceipt:aM(e.deliveryReceipt,t.receipt)}:e)}))}else if(t.type===`agent_stream`)be(n),U(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)U(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${nM++}`,tool:t.tool??`tool`,...t.input?{input:t.input}:{},...t.toolId?{toolId:t.toolId}:{},...t.timestamp?{at:t.timestamp}:{}}].slice(-200)}));else if(t.type===`agent_tool_result`)U(n,e=>{let n=[...e.liveTools],r=t.toolId?n.findIndex(e=>e.toolId===t.toolId):-1;if(r===-1){for(let e=n.length-1;e>=0;e--)if(n[e].output===void 0){r=e;break}}return r===-1?e:(n[r]={...n[r],output:t.output??``,...t.isError?{isError:!0}:{}},{...e,liveTools:n})});else if(t.type===`agent_partial`){let e=t.fullText??``;e&&i([{id:t.messageId??`partial-${n}-${t.timestamp??Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:t.timestamp??new Date().toISOString()}])}else if(t.type===`agent_done`){ve.current.delete(n),be(n);let e=t.fullText??``;t.messageId&&e?i([{id:t.messageId,conversation_id:n,role:`assistant`,content:e,created_at:t.timestamp??new Date().toISOString()}]):r&&e&&v(t=>{let r=t[t.length-1];return r&&r.role===`assistant`&&r.content===e&&!r.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),U(n,e=>({...Lj,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}))}else if(t.type===`agent_error`){ve.current.delete(n),be(n),U(n,e=>({...Lj,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}));let e=t.error||`The agent turn failed.`;J.error(e),r&&v(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`){if(t.queueId&&ae.current.has(t.queueId))return;U(n,e=>{let r=aM(t.deliveryReceipt??t.delivery_receipt,se.current.get(`${n}:q:${t.queueId}`)),i={queueId:t.queueId??`srv-${rM++}`,text:t.text??``,contextRefs:t.contextRefs,attachmentIds:t.attachmentIds,deliveryMode:t.deliveryMode,...r?{deliveryReceipt:r}:{},timestamp:t.timestamp};return t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?{...e,queued:e.queued.map(e=>e.queueId===t.queueId?{...e,...i,deliveryReceipt:aM(e.deliveryReceipt,i.deliveryReceipt),deliveryMode:e.deliveryMode===`steer`?`steer`:i.deliveryMode??e.deliveryMode,attachmentIds:i.attachmentIds??e.attachmentIds,contextRefs:i.contextRefs??e.contextRefs}:e)}:{...e,queued:[...e.queued,i]}})}else if(t.type===`agent_steered`){if(!t.messageId)return;if(de.current.has(t.messageId)){t.queueId&&ae.current.add(t.queueId),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId)}));return}de.current.add(t.messageId),t.queueId&&ae.current.add(t.queueId),ce.current.set(`${n}:q:${t.queueId}`,t.messageId);let e=aM(t.delivery_receipt??t.deliveryReceipt,se.current.get(`${n}:q:${t.queueId}`)),r=[];t.assistantSegment&&r.push({...t.assistantSegment,conversation_id:n,role:`assistant`}),r.push(le({id:t.messageId,conversation_id:n,role:`user`,content:t.text??``,context_refs:t.contextRefs??[],attachment_ids:t.attachmentIds??[],delivery_status:t.deliveryStatus??`delivered`,...e?{delivery_receipt:e}:{},created_at:t.timestamp??new Date().toISOString()})),i(r),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId),streamingText:t.assistantSegment?``:e.streamingText}))}else if(t.type===`agent_dequeued`){if(t.queueId&&ae.current.has(t.queueId))return;if(t.queueId&&ae.current.add(t.queueId),U(n,e=>({...e,queued:t.queueId?e.queued.filter(e=>e.queueId!==t.queueId):e.queued.slice(1),isStreaming:!0,streamingText:``,liveTools:[]})),t.text){t.messageId&&ce.current.set(`${n}:q:${t.queueId}`,t.messageId);let e=aM(t.delivery_receipt??t.deliveryReceipt,se.current.get(`${n}:q:${t.queueId}`));i([le({id:t.messageId??`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],attachment_ids:t.attachmentIds??[],...t.messageId?{delivery_status:`delivered`}:{},...e?{delivery_receipt:e}:{},created_at:t.timestamp??new Date().toISOString()})])}}else if(t.type===`agent_queue_cleared`)pe.current.set(n,(pe.current.get(n)??0)+1),t.messages?.length&&i(t.messages),U(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_removed`){if(!t.queueId)return;ae.current.add(t.queueId),oe.current.add(t.queueId),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId)}))}else if(t.type===`agent_queue_edited`)U(n,e=>({...e,queued:e.queued.map(e=>t.queueId&&e.queueId===t.queueId?{...e,text:t.text??e.text,contextRefs:t.contextRefs??e.contextRefs,deliveryMode:t.deliveryMode??e.deliveryMode}:e)}));else if(t.type===`agent_pr_decision`&&(be(n),r)){let t=ro(e);if(t){ge.current++;let e=eM(b.current,n,t);b.current=e,v(e=>{let r=eM(e,n,t);return b.current=r,r})}}}),()=>n(`agent-chat`)):void 0,[t,n,U,be]);let Ne=(0,Q.useCallback)(async(e,t)=>{let n=++_e.current,r=fe.current.get(e)??0;ge.current++;let{conversation:i,messages:a,pendingMessages:o,live:s}=await Ha(e);if(t?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);if(n!==_e.current){if(t)throw new DOMException(`The mission changed during restoration`,`AbortError`);return}ge.current++;let c=oM(a,me.current.get(e)??[]).map(le);for(let e of c)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&de.current.add(e.id);g(i),b.current=c,v(c),xe(e),r===(fe.current.get(e)??0)&&(o!==void 0||s)&&U(e,t=>({...t,...s?{isStreaming:s.isStreaming,streamingText:s.streamingText}:{},queued:o?.filter(e=>!ae.current.has(e.queueId)).map(t=>ue(e,t))??t.queued}))},[xe,U]),Pe=(0,Q.useCallback)(async()=>{let e=re.current;if(!e)return;let t=ge.current,n=fe.current.get(e)??0,r=y.current.get(e)??0;try{let i=await Ha(e);if(re.current!==e||ge.current!==t)return;if(r===(y.current.get(e)??0)&&(g(t=>t?.id===e?i.conversation:t),m(t=>t.map(t=>t.id===e?i.conversation:t))),(i.pendingMessages!==void 0||i.live)&&n===(fe.current.get(e)??0)){let t=oM(i.messages,me.current.get(e)??[]).map(le);for(let e of t)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&de.current.add(e.id);v(e=>oM(t,e.filter(e=>e.id.startsWith(`local-u-`)&&!t.some(t=>t.role===`user`&&t.content===e.content)))),U(e,t=>({...t,...i.live?{isStreaming:i.live.isStreaming,streamingText:i.live.streamingText}:{},queued:i.pendingMessages?.filter(e=>!ae.current.has(e.queueId)).map(t=>ue(e,t))??t.queued}))}let a=i.messages.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null);if(a.length===0)return;v(t=>{let n=a.reduce((t,n)=>eM(t,e,n),t);return b.current=n,n})}catch{}},[U]),Fe=(0,Q.useCallback)(async()=>{try{let e=new Map(fe.current),t=await Ba(),n=new Set(t.turns.map(e=>e.conversationId)),r=Date.parse(t.capturedAt),i=[...ie.current].flatMap(([t,i])=>{if(!i.isStreaming||n.has(t)||(e.get(t)??0)!==(fe.current.get(t)??0))return[];let a=ve.current.get(t);return a&&Date.parse(a)>r?[]:[t]});E(i=>{let a=new Map(i);for(let[t,o]of i){if(!o.isStreaming||n.has(t)||(e.get(t)??0)!==(fe.current.get(t)??0))continue;let i=ve.current.get(t);i&&Date.parse(i)>r||a.set(t,{...Lj,queued:o.queued,turnTools:o.liveTools.length?o.liveTools:o.turnTools})}for(let n of t.turns){let t=n.conversationId;if((e.get(t)??0)!==(fe.current.get(t)??0))continue;let r=a.get(t)??Lj;a.set(t,{...r,isStreaming:!0,streamingText:n.streamingText??r.streamingText,queued:n.pendingMessages?.filter(e=>!ae.current.has(e.queueId)).map(e=>ue(t,e))??r.queued})}return a});for(let e of i)ve.current.delete(e);let a=re.current;if(a&&i.includes(a)){let e=`interrupted-${a}-${t.snapshotVersion}`;v(n=>n.some(t=>t.id===e)?n:[...n,{id:e,conversation_id:a,role:`assistant`,content:`⚠️ The agent turn was interrupted when the Specrails server reconnected. It was not retried.`,created_at:t.capturedAt}])}console.info(`[agent-chat] reconciled active turns`,{snapshotVersion:t.snapshotVersion,active:n.size,interrupted:i.length})}catch{}},[]);(0,Q.useEffect)(()=>{let e=()=>{Oe(),Pe()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Pe,Oe]),(0,Q.useEffect)(()=>{je&&(Oe(),Pe())},[je,Oe,Pe]);let Ie=(0,Q.useRef)(r);(0,Q.useEffect)(()=>{let e=Ie.current;Ie.current=r,r===`connected`&&e!==`connected`&&(Oe(),ke(),Ae(),Pe(),Fe())},[r,Oe,ke,Ae,Pe,Fe]);let Le=(0,Q.useCallback)(async()=>{if(h)return h;if(l)throw Error(`This window is reserved for its mission.`);let e=await Ra();if(m(e),S(t=>{let n=Vj(zj(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(Bj(n),n)}),e.length>0)return await Ne(e[0].id),e[0];let t=await Va({});return m(e=>[t,...e]),g(t),v([]),t},[h,Ne]),Re=(0,Q.useCallback)(()=>{f(`open`),Oe(),ke(),Ae(),Le()},[Oe,ke,Ae,Le]),ze=(0,Q.useCallback)(()=>f(`hidden`),[]),Be=(0,Q.useCallback)(()=>f(`minimized`),[]),[G,Ve]=(0,Q.useState)(!1),He=(0,Q.useRef)(null),Ue=(0,Q.useCallback)(()=>{He.current?.abortAndReset(),Ve(!1)},[]),We=QA(G,{onFinished:Ue});He.current=We;let Ge=(0,Q.useCallback)(()=>{l||(Ve(!0),i!==`agent`&&Re())},[i,Re]),Ke=(0,Q.useCallback)(()=>{f(e=>e===`open`?`minimized`:`open`),d!==`open`&&(Oe(),ke(),Ae(),Le())},[d,Oe,ke,Ae,Le]),Je=(0,Q.useCallback)(async()=>{if(!u(h?.id))throw Error(`This mission is active in another window.`);if(h)return h;if(he.current)return he.current;let e=Va({pinnedProjectId:I.current,provider:ne.current.provider,model:ne.current.model,tierLevel:ne.current.tierLevel,reasoningEffort:ne.current.effort}).then(e=>(Zr(e.id),m(t=>[e,...t]),g(e),v([]),e)).finally(()=>{he.current=null});return he.current=e,e},[h]),Ye=(0,Q.useCallback)(async(e,t)=>{if(!u(h?.id))return{accepted:!1};let n=e.trim();if(!n)return{accepted:!1};let r=h??await Je();fe.current.set(r.id,(fe.current.get(r.id)??0)+1);let i=fe.current.get(r.id),a=pe.current.get(r.id)??0,o=t?.queueId??`q-${Date.now()}-${rM++}`,s=new Date().toISOString();ve.current.set(r.id,s),m(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:s},...e.filter(e=>e.id!==r.id)]),g(e=>e&&e.id===r.id?{...e,updated_at:s}:e);let c={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],delivery_receipt:`sent`,created_at:s},l=ie.current.get(r.id)?.isStreaming===!0,d={queueId:o,text:n,contextRefs:t?.contextRefs,attachmentIds:t?.attachmentIds,deliveryMode:`queue`,deliveryReceipt:`sent`,timestamp:s};l?U(r.id,e=>({...e,queued:e.queued.some(e=>e.queueId===o)?e.queued.map(e=>e.queueId===o?{...d,deliveryReceipt:aM(e.deliveryReceipt,d.deliveryReceipt),deliveryMode:e.deliveryMode??d.deliveryMode,timestamp:e.timestamp??d.timestamp}:e):[...e.queued,d]})):(v(e=>[...e,c]),U(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let f=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,s=await Ga(r.id,n,{tierLevel:r.tier_level,attachments:f,queueId:o,contextRefs:e});if(s.removed){ae.current.add(o),oe.current.add(o);let e=!l&&i===fe.current.get(r.id);return re.current===r.id&&v(e=>e.filter(e=>e.id!==c.id)),U(r.id,t=>({...t,queued:t.queued.filter(e=>e.queueId!==o),...e?{isStreaming:!1}:{}})),e&&ve.current.delete(r.id),{accepted:!0,conversationId:r.id}}if(s.message){ce.current.set(`${r.id}:q:${o}`,s.message.id);let e=aM(s.message.delivery_receipt,se.current.get(`${r.id}:q:${o}`)),t=le({...s.message,...e?{delivery_receipt:e}:{}});return ae.current.add(o),me.current.set(r.id,oM(me.current.get(r.id)??[],[t]).slice(-500)),re.current===r.id&&v(e=>oM(e.filter(e=>e.id!==c.id),[t])),U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})),s.duplicate&&Fe(),{accepted:!0,conversationId:r.id}}if(a!==(pe.current.get(r.id)??0))return v(e=>e.filter(e=>e.id!==c.id)),{accepted:!0,conversationId:r.id};let u=s?.queued===!0;return u&&!l?(v(e=>e.filter(e=>e.id!==c.id)),ae.current.has(o)||U(r.id,e=>e.queued.some(e=>e.queueId===o)?e:{...e,queued:[...e.queued,{...d,deliveryMode:s.deliveryMode??d.deliveryMode}]})):!u&&l&&!ae.current.has(o)&&(U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o),isStreaming:!0})),v(e=>[...e,c])),{accepted:!0,conversationId:r.id}}catch(e){return ae.current.has(o)||a!==(pe.current.get(r.id)??0)?{accepted:!0,conversationId:r.id}:(ve.current.delete(r.id),l?U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})):(U(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),v(e=>e.filter(e=>e.id!==c.id))),J.error(e instanceof Error?e.message:`Failed to send message.`),{accepted:!1,conversationId:r.id})}},[h,Je,U,Fe]),Xe=(0,Q.useCallback)(async()=>{if(!(!h||!u(h.id)))try{await Za(h.id),pe.current.set(h.id,(pe.current.get(h.id)??0)+1),fe.current.set(h.id,(fe.current.get(h.id)??0)+1),U(h.id,()=>null)}catch(e){J.error(e instanceof Error?e.message:`Failed to stop the agent.`)}},[h,U]),Ze=(0,Q.useCallback)(async(e,t)=>{let n=h;if(!n||!u(n.id)||ie.current.get(n.id)?.queued.find(t=>t.queueId===e)?.deliveryMode===`steer`)return`conflict`;let r=await Qa(n.id,e,t);return r===`saved`&&U(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[h,U]),Qe=(0,Q.useCallback)(async e=>{let t=h,n=t&&ie.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!u(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await $a(t.id,e);return r===`saved`?(fe.current.set(t.id,(fe.current.get(t.id)??0)+1),U(t.id,t=>({...t,queued:t.queued.map(t=>t.queueId===e?{...t,deliveryMode:`steer`}:t)}))):re.current===t.id&&Pe(),r},[h,U,Pe]),$e=(0,Q.useCallback)(async e=>{let t=h,n=t&&ie.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!u(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await eo(t.id,e);return r===`saved`?(ae.current.add(e),oe.current.add(e),fe.current.set(t.id,(fe.current.get(t.id)??0)+1),U(t.id,t=>({...t,queued:t.queued.filter(t=>t.queueId!==e)}))):re.current===t.id&&Pe(),r},[h,U,Pe]),et=(0,Q.useCallback)(e=>ae.current.has(e)&&!oe.current.has(e),[]),tt=(0,Q.useCallback)(async e=>{if(!h||!u(h.id))return;let t=(y.current.get(h.id)??0)+1;y.current.set(h.id,t);let n=await Ua(h.id,e);y.current.get(h.id)===t&&(g(e=>e?.id===n.id?n:e),m(e=>e.map(e=>e.id===n.id?n:e)))},[h]),K=(0,Q.useCallback)(async e=>{u(h?.id)&&(Wj(e),h?await tt({tierLevel:e}):V(e))},[h,tt]),q=(0,Q.useCallback)(async()=>{let e=((h?.tier_level??ee)+1)%4;await K(e)},[h,ee,K]),nt=(0,Q.useCallback)(async e=>{h?await tt({provider:e}):(R(e),B(null),te(null))},[h,tt]),rt=(0,Q.useCallback)(async e=>{h?await tt({model:e}):(B(e),te(null))},[h,tt]),it=(0,Q.useCallback)(async e=>{h?await tt({reasoningEffort:e}):te(e)},[h,tt]),ot=(0,Q.useCallback)(async e=>{l||!u(h?.id)||(h?await tt({pinnedProjectId:e}):F(e),!h&&e&&i===`agent`&&a(e))},[h,tt,i,a]),Y=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let e=Y.current;if(Y.current=o,!(e===void 0||e===o)&&!(l||i!==`agent`||!o)){if(!h){F(o);return}b.current.length>0||h.pinned_project_id!==o&&tt({pinnedProjectId:o})}},[o,i,h,tt]);let st=(0,Q.useCallback)(e=>{l||(Ue(),g(null),v([]),F(e??null),R(`claude`),B(null),V(Uj()),te(null))},[Ue]),ct=(0,Q.useCallback)(async e=>{if(l)return;Ue();let t=await Va({pinnedProjectId:e===void 0?h?.pinned_project_id??null:e,tierLevel:Uj()});m(e=>[t,...e]),g(t),v([])},[h,Ue]),lt=(0,Q.useCallback)(async(e,t)=>{if(!(l&&!t?.windowRestore&&c.current.current?.conversationId!==e)&&!(!l&&!t?.windowRestore&&await c.current.focus(e))){if(t?.signal?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);Ue(),await Ne(e,t?.signal),t?.windowRestore&&i!==`agent`&&f(`open`)}},[Ne,Ue,l,i]),ut=(0,Q.useCallback)(async e=>{u(e)&&(await Wa(e),await c.current.discard(e),m(t=>t.filter(t=>t.id!==e)),S(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),Bj(n),n}),U(e,()=>null),re.current===e&&(g(null),v([])))},[U]),dt=(0,Q.useCallback)(async(e,t)=>{if(!u(e))return;let n=t.trim()||null;y.current.set(e,(y.current.get(e)??0)+1);let r;m(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),g(t=>t&&t.id===e?{...t,title:n}:t);try{await Ua(e,{title:n})}catch(t){throw m(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),g(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),ft=(0,Q.useCallback)(e=>{S(()=>{let t=new Set(zj());return t.has(e)?t.delete(e):t.add(e),Bj(t),t})},[]),pt=(0,Q.useCallback)(async()=>{A(!0);try{await fo(),await ke()}catch(e){J.error(e instanceof Error?e.message:`Failed to enable MCP.`)}finally{A(!1)}},[ke]),mt=(0,Q.useMemo)(()=>({visibility:d,open:Re,close:ze,minimize:Be,toggle:Ke,conversations:p,active:h,messages:_,streamingText:Ce,isStreaming:W,liveTools:we,turnTools:Te,queuedMessages:Ee,streamingConversationIds:De,liveByConversation:T,unreadConversationIds:C,favoriteConversationIds:x,mcpEnabled:D,enablingMcp:k,enableMcpServer:pt,providersReady:j,send:Ye,abort:Xe,editQueuedMessage:Ze,steerQueuedMessage:Qe,removeQueuedMessage:$e,wasQueueConsumed:et,cycleTier:q,setTier:K,setProvider:nt,setModel:rt,setPinnedProject:ot,newConversation:ct,startNewConversation:st,materializeDraftConversation:Je,draftPinnedProjectId:N,draftProvider:L,draftModel:z,draftTierLevel:ee,draftEffort:H,setEffort:it,selectConversation:lt,deleteConversation:ut,renameConversation:dt,toggleFavoriteConversation:ft,refreshConversations:Oe,applyPrDecisionSnapshot:ye,builderMode:{active:G,enter:Ge,exit:Ue,session:We}}),[d,Re,ze,Be,Ke,G,Ge,Ue,We,p,h,_,Ce,W,we,Te,Ee,De,T,C,x,D,k,pt,j,Ye,Xe,Ze,Qe,$e,et,q,K,nt,rt,ot,ct,st,Je,N,L,z,ee,H,it,lt,ut,dt,ft,Oe,ye]),ht=P&&i!==`agent`;return(0,$.jsxs)(tM.Provider,{value:mt,children:[e,ht&&d===`open`&&(0,$.jsx)(Sj,{}),ht&&d!==`open`&&(0,$.jsx)(kj,{})]})}var cM={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>({accepted:!1}),abort:async()=>{},editQueuedMessage:async()=>`conflict`,steerQueuedMessage:async()=>`conflict`,removeQueuedMessage:async()=>`conflict`,wasQueueConsumed:()=>!1,cycleTier:async()=>{},setTier:async()=>{},setProvider:async()=>{},setModel:async()=>{},setPinnedProject:async()=>{},newConversation:async()=>{},startNewConversation:()=>{},materializeDraftConversation:async()=>{throw Error(`AgentChatProvider is not mounted`)},draftPinnedProjectId:null,draftProvider:`claude`,draftModel:null,draftTierLevel:0,draftEffort:null,setEffort:async()=>{},selectConversation:async()=>{},deleteConversation:async()=>{},renameConversation:async()=>{},toggleFavoriteConversation:()=>{},refreshConversations:async()=>{},applyPrDecisionSnapshot:()=>`untracked`,builderMode:{active:!1,enter:()=>{},exit:()=>{},session:{phase:`chat`,messages:[],streamBuffer:null,blueprint:null,busy:!1,commitError:null,commitErrorDetail:null,commitSteps:[],createdProjectId:null,launching:!1,launched:!1,submitting:!1,conversationReady:!1,conversationId:null,dirty:!1,canProposeCommit:!1,specQualityDetail:null,readiness:{ready:!1,steps:[],issues:[]},snapshot:{status:`idle`},generation:{generating:!1,specsStarted:0},recent:[],recentLoading:!1,resume:async()=>{},discardRecent:async()=>{},repairSnapshot:async()=>{},showSurpriseMe:!0,provider:`claude`,model:null,models:[],efforts:[],effort:`medium`,draft:``,setDraft:()=>{},setEffort:()=>{},setProvider:()=>{},setModel:()=>{},send:()=>{},surpriseMe:()=>{},approveBlueprint:()=>{},goToCommit:()=>{},backToChat:()=>{},submitCommit:()=>{},launchM1:async()=>{},openProject:()=>{},abortAndReset:()=>{}}}};function lM(){return(0,Q.useContext)(tM)??cM}var uM=new Map;function dM(){let e=lM(),t=Ux(),n=at(),r=Ca(),{registerHandlers:i}=si(),{t:a}=K(`agent`),o=(0,Q.useRef)({chat:e,workspace:t,desktop:n,terminals:r,t:a});o.current={chat:e,workspace:t,desktop:n,terminals:r,t:a};let s=(0,Q.useRef)(null),c=(0,Q.useRef)(!1);(0,Q.useLayoutEffect)(()=>{let n=e.active?.id??`__new-mission__`,r=s.current;if(c.current||r===n)return;s.current=n,r&&uM.set(r,t.captureWorkspace());let i=uM.get(n);i?t.restoreWorkspace(i):r&&t.restoreWorkspace({...t.captureWorkspace(),browserOpen:!1,browserOwnerId:null,browserUrl:null,pendingCaptures:[]})},[e.active?.id]);let[l,u]=(0,Q.useState)(null);return(0,Q.useLayoutEffect)(()=>{l&&!l.signal.aborted&&e.active?.id===l.target.conversationId&&n.activeProjectId===l.target.projectId&&(l.resolve(),u(e=>e===l?null:e))},[l,e.active?.id,n.activeProjectId]),(0,Q.useEffect)(()=>i({recover(e,t){Sy(t.conversationId,e.scroll)},capture(e){let{chat:t,workspace:n,terminals:r,t:i}=o.current;if(t.active?.id!==e.conversationId)throw Error(i(`window.wrongMission`));if(Ty(e.conversationId))throw Error(i(`window.finishPending`));return{version:1,...e,capturedAt:Date.now(),composer:Gr(e.conversationId),scroll:xy(e.conversationId),workspace:{...n.captureWorkspace(),...e.projectId?{codeSelection:my(e.projectId,e.conversationId),terminal:(({activeId:e,visibility:t,userHeight:n})=>({activeId:e,visibility:t,userHeight:n}))(r.getState(e.projectId))}:{}}}},async restore(e,t,n){let r=()=>new DOMException(`Window transfer cancelled`,`AbortError`);if(n.aborted)throw r();let i=o.current.chat.active?.id;i&&uM.set(i,o.current.workspace.captureWorkspace()),c.current=!0;try{if(await o.current.chat.selectConversation(t.conversationId,{windowRestore:!0,signal:n}),n.aborted)throw r();if(s.current=t.conversationId,uM.set(t.conversationId,e.workspace),qr(t.conversationId,e.composer),t.projectId&&(e.workspace.codeSelection&&hy(t.projectId,t.conversationId,e.workspace.codeSelection),e.workspace.terminal)){let n=e.workspace.terminal,r=o.current.terminals;r.ensureProject(t.projectId),r.setVisibility(t.projectId,n.visibility),r.setUserHeight(t.projectId,n.userHeight),n.activeId&&r.setActive(t.projectId,n.activeId)}o.current.workspace.restoreWorkspace(e.workspace),o.current.desktop.setActiveProjectId(t.projectId),Sy(t.conversationId,e.scroll),await new Promise((e,i)=>{let a=()=>{u(e=>e?.signal===n?null:e),i(r())};n.addEventListener(`abort`,a,{once:!0}),u({target:t,signal:n,resolve:()=>{n.removeEventListener(`abort`,a),e()}})})}finally{c.current=!1}}}),[i]),null}var fM=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new pM(this.width*e,this.height*e)}[ct](){return{width:this.width,height:this.height}}toJSON(){return this[ct]()}},pM=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new fM(this.width/e,this.height/e)}[ct](){return{width:this.width,height:this.height}}toJSON(){return this[ct]()}},mM=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof fM?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof pM?this.size:this.size.toPhysical(e)}[ct](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[ct]()}},hM=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new gM(this.x*e,this.y*e)}[ct](){return{x:this.x,y:this.y}}toJSON(){return this[ct]()}},gM=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new hM(this.x/e,this.y/e)}[ct](){return{x:this.x,y:this.y}}toJSON(){return this[ct]()}},_M=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof hM?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof gM?this.position:this.position.toPhysical(e)}[ct](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[ct]()}},vM;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(vM||={});var yM=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},bM;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(bM||={});function xM(){return new wM(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function SM(){return Y(`plugin:window|get_all_windows`).then(e=>e.map(e=>new wM(e,{skip:!0})))}var CM=[`tauri://created`,`tauri://error`],wM=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||Y(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await SM()).find(t=>t.label===e)??null}static getCurrent(){return xM()}static async getAll(){return SM()}static async getFocusedWindow(){for(let e of await SM())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:mr(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:gr(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(CM.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return hr(e,t)}async emitTo(e,t,n){if(CM.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return _r(e,t,n)}_handleTauriEvent(e,t){return CM.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return Y(`plugin:window|scale_factor`,{label:this.label})}async innerPosition(){return Y(`plugin:window|inner_position`,{label:this.label}).then(e=>new gM(e))}async outerPosition(){return Y(`plugin:window|outer_position`,{label:this.label}).then(e=>new gM(e))}async innerSize(){return Y(`plugin:window|inner_size`,{label:this.label}).then(e=>new pM(e))}async outerSize(){return Y(`plugin:window|outer_size`,{label:this.label}).then(e=>new pM(e))}async isFullscreen(){return Y(`plugin:window|is_fullscreen`,{label:this.label})}async isMinimized(){return Y(`plugin:window|is_minimized`,{label:this.label})}async isMaximized(){return Y(`plugin:window|is_maximized`,{label:this.label})}async isFocused(){return Y(`plugin:window|is_focused`,{label:this.label})}async isDecorated(){return Y(`plugin:window|is_decorated`,{label:this.label})}async isResizable(){return Y(`plugin:window|is_resizable`,{label:this.label})}async isMaximizable(){return Y(`plugin:window|is_maximizable`,{label:this.label})}async isMinimizable(){return Y(`plugin:window|is_minimizable`,{label:this.label})}async isClosable(){return Y(`plugin:window|is_closable`,{label:this.label})}async isVisible(){return Y(`plugin:window|is_visible`,{label:this.label})}async title(){return Y(`plugin:window|title`,{label:this.label})}async theme(){return Y(`plugin:window|theme`,{label:this.label})}async isAlwaysOnTop(){return Y(`plugin:window|is_always_on_top`,{label:this.label})}async center(){return Y(`plugin:window|center`,{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===vM.Critical?{type:`Critical`}:{type:`Informational`}),Y(`plugin:window|request_user_attention`,{label:this.label,value:t})}async setResizable(e){return Y(`plugin:window|set_resizable`,{label:this.label,value:e})}async setEnabled(e){return Y(`plugin:window|set_enabled`,{label:this.label,value:e})}async isEnabled(){return Y(`plugin:window|is_enabled`,{label:this.label})}async setMaximizable(e){return Y(`plugin:window|set_maximizable`,{label:this.label,value:e})}async setMinimizable(e){return Y(`plugin:window|set_minimizable`,{label:this.label,value:e})}async setClosable(e){return Y(`plugin:window|set_closable`,{label:this.label,value:e})}async setTitle(e){return Y(`plugin:window|set_title`,{label:this.label,value:e})}async maximize(){return Y(`plugin:window|maximize`,{label:this.label})}async unmaximize(){return Y(`plugin:window|unmaximize`,{label:this.label})}async toggleMaximize(){return Y(`plugin:window|toggle_maximize`,{label:this.label})}async minimize(){return Y(`plugin:window|minimize`,{label:this.label})}async unminimize(){return Y(`plugin:window|unminimize`,{label:this.label})}async show(){return Y(`plugin:window|show`,{label:this.label})}async hide(){return Y(`plugin:window|hide`,{label:this.label})}async close(){return Y(`plugin:window|close`,{label:this.label})}async destroy(){return Y(`plugin:window|destroy`,{label:this.label})}async setDecorations(e){return Y(`plugin:window|set_decorations`,{label:this.label,value:e})}async setShadow(e){return Y(`plugin:window|set_shadow`,{label:this.label,value:e})}async setEffects(e){return Y(`plugin:window|set_effects`,{label:this.label,value:e})}async clearEffects(){return Y(`plugin:window|set_effects`,{label:this.label,value:null})}async setAlwaysOnTop(e){return Y(`plugin:window|set_always_on_top`,{label:this.label,value:e})}async setAlwaysOnBottom(e){return Y(`plugin:window|set_always_on_bottom`,{label:this.label,value:e})}async setContentProtected(e){return Y(`plugin:window|set_content_protected`,{label:this.label,value:e})}async setSize(e){return Y(`plugin:window|set_size`,{label:this.label,value:e instanceof mM?e:new mM(e)})}async setMinSize(e){return Y(`plugin:window|set_min_size`,{label:this.label,value:e instanceof mM?e:e?new mM(e):null})}async setMaxSize(e){return Y(`plugin:window|set_max_size`,{label:this.label,value:e instanceof mM?e:e?new mM(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return Y(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return Y(`plugin:window|set_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setFullscreen(e){return Y(`plugin:window|set_fullscreen`,{label:this.label,value:e})}async setSimpleFullscreen(e){return Y(`plugin:window|set_simple_fullscreen`,{label:this.label,value:e})}async setFocus(){return Y(`plugin:window|set_focus`,{label:this.label})}async setFocusable(e){return Y(`plugin:window|set_focusable`,{label:this.label,value:e})}async setIcon(e){return Y(`plugin:window|set_icon`,{label:this.label,value:ua(e)})}async setSkipTaskbar(e){return Y(`plugin:window|set_skip_taskbar`,{label:this.label,value:e})}async setCursorGrab(e){return Y(`plugin:window|set_cursor_grab`,{label:this.label,value:e})}async setCursorVisible(e){return Y(`plugin:window|set_cursor_visible`,{label:this.label,value:e})}async setCursorIcon(e){return Y(`plugin:window|set_cursor_icon`,{label:this.label,value:e})}async setBackgroundColor(e){return Y(`plugin:window|set_background_color`,{color:e})}async setCursorPosition(e){return Y(`plugin:window|set_cursor_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setIgnoreCursorEvents(e){return Y(`plugin:window|set_ignore_cursor_events`,{label:this.label,value:e})}async startDragging(){return Y(`plugin:window|start_dragging`,{label:this.label})}async startResizeDragging(e){return Y(`plugin:window|start_resize_dragging`,{label:this.label,value:e})}async setBadgeCount(e){return Y(`plugin:window|set_badge_count`,{label:this.label,value:e})}async setBadgeLabel(e){return Y(`plugin:window|set_badge_label`,{label:this.label,value:e})}async setOverlayIcon(e){return Y(`plugin:window|set_overlay_icon`,{label:this.label,value:e?ua(e):void 0})}async setProgressBar(e){return Y(`plugin:window|set_progress_bar`,{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return Y(`plugin:window|set_visible_on_all_workspaces`,{label:this.label,value:e})}async setTitleBarStyle(e){return Y(`plugin:window|set_title_bar_style`,{label:this.label,value:e})}async setTheme(e){return Y(`plugin:window|set_theme`,{label:this.label,value:e})}async onResized(e){return this.listen(vr.WINDOW_RESIZED,t=>{t.payload=new pM(t.payload),e(t)})}async onMoved(e){return this.listen(vr.WINDOW_MOVED,t=>{t.payload=new gM(t.payload),e(t)})}async onCloseRequested(e){return this.listen(vr.WINDOW_CLOSE_REQUESTED,async t=>{let n=new yM(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(vr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),n=await this.listen(vr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new gM(t.payload.position)}})}),r=await this.listen(vr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),i=await this.listen(vr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(vr.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(vr.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(vr.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(vr.WINDOW_THEME_CHANGED,e)}},TM;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(TM||={});var EM;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(EM||={});var DM;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(DM||={});var OM;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(OM||={});var kM=12e-5,AM=36,jM=140,MM=1.5,NM=6;function PM(e,t){return{x:Math.random()*e,y:Math.random()*t,radius:.35+Math.random()*1.25,alpha:.22+Math.random()*.5,drift:MM+Math.random()*(NM-MM)}}function FM(e){let t=e.getBoundingClientRect(),n=t.width||e.parentElement?.clientWidth||window.innerWidth,r=t.height||e.parentElement?.clientHeight||window.innerHeight;return{width:Math.max(1,Math.floor(n)),height:Math.max(1,Math.floor(r))}}function IM(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=0,s=0,c=0,l=0,u=0,d=!document.hidden;function f(){let e=FM(r),t=window.devicePixelRatio||1;if(e.width===o&&e.height===s&&t===c)return;let n=e.width!==o||e.height!==s;if(o=e.width,s=e.height,c=t,r.width=Math.max(1,Math.round(o*t)),r.height=Math.max(1,Math.round(s*t)),r.style.width=`100%`,r.style.height=`100%`,i.setTransform(t,0,0,t,0,0),n||a.length===0){let e=Math.min(jM,Math.max(AM,Math.floor(o*s*kM)));a=Array.from({length:e},()=>PM(o,s))}}function p(e){i.clearRect(0,0,o,s);for(let t of a)t.x+=t.drift*e,t.x>o+t.radius&&(t.x=-t.radius,t.y=Math.random()*s),i.globalAlpha=t.alpha,i.fillStyle=`hsl(213 100% 92%)`,i.beginPath(),i.arc(t.x,t.y,t.radius,0,Math.PI*2),i.fill();i.globalAlpha=1}function m(e){if(!d)return;let t=u===0?.016:Math.min(.05,(e-u)/1e3);u=e,p(t),l=requestAnimationFrame(m)}function h(){d=!document.hidden,d?(u=0,l=requestAnimationFrame(m)):cancelAnimationFrame(l)}let g=null;function _(){g&&g.removeEventListener(`change`,_),f(),v()}function v(){let e=window.devicePixelRatio||1;g=window.matchMedia(`(resolution: ${e}dppx)`),g.addEventListener(`change`,_)}f();let y=null,b=r.parentElement;return typeof ResizeObserver<`u`&&b&&(y=new ResizeObserver(()=>f()),y.observe(b)),window.addEventListener(`resize`,f),v(),document.addEventListener(`visibilitychange`,h),d&&(l=requestAnimationFrame(m)),()=>{cancelAnimationFrame(l),y&&y.disconnect(),g&&g.removeEventListener(`change`,_),window.removeEventListener(`resize`,f),document.removeEventListener(`visibilitychange`,h)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`absolute inset-0 pointer-events-none`,style:{zIndex:-1}})}var LM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeCodePane-D_Xcq5t5.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([79,1,7,10,42,49]))),RM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeJobsPane-CDSkOuNP.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([80,1,7,12,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,8,54,49,64,65,67,68,76,6,9,11,43,45,46,47,48,50,51,52,53,55,56,57,58,59,60,61,62,63,66,69,70,71,72,73,74,75,81]))),zM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeAnalyticsPane-PEZKjyZS.js`).then(e=>({default:e.AgentModeAnalyticsPane})),__vite__mapDeps([82,1,7,10,42,54,49,64,65])));function BM(){let{t:e}=K(`agent`),{active:t,refreshConversations:n,builderMode:r}=lM(),{codePaneOpen:i,jobsPaneOpen:a,analyticsPaneOpen:o}=Ux(),{activeProjectId:s}=at(),c=si(),l=Cy(t?.id??`__new-mission__`),u=!c.current&&c.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),d=ca(),f=d.id===`galaxy`,p=d.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,Q.useEffect)(()=>{n()},[n]);let m=i&&!!s&&!u,h=a&&!!s&&!u,g=o&&!!s&&!u;return(0,$.jsx)(D_,{reducedMotion:`user`,children:(0,$.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[f&&(0,$.jsx)(IM,{}),(0,$.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(fy.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(t===null)},transition:{duration:.5,ease:`easeOut`},style:{background:`radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--color-accent-primary) 13%, transparent), transparent 70%)`}}),r.active?(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(pj,{variant:`inline`})}):t===null?(0,$.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,$.jsxs)(fy.div,{layoutId:`agent-composer-dock`,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1],layout:{type:`spring`,stiffness:350,damping:34}},className:`w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-4 shadow-2xl backdrop-blur-xl`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(So,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:p})]}),(0,$.jsx)(qO,{autoFocus:!0})]})}):(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(Kk,{variant:`inline`})})]}),h&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,$.jsx)(RM,{projectId:s})}),m&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,$.jsx)(LM,{projectId:s,conversationId:t?.id??`__home__`},`${t?.id}:${l}`)}),g&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[560px] border-l border-border`}),children:(0,$.jsx)(zM,{})})]})})}var VM=(e,t,n)=>Math.min(n,Math.max(t,e)),HM=e=>`specrails-desktop:sidebar-width:${e}`;function UM(e,t){let n=HM(e),[r,i]=(0,Q.useState)(()=>{try{let e=localStorage.getItem(n),r=e?Number.parseInt(e,10):NaN;if(Number.isFinite(r))return VM(r,t.min,t.max)}catch{}return t.defaultWidth}),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(r);c.current=r;let l=(0,Q.useRef)(!1),u=(0,Q.useRef)(t);return u.current=t,(0,Q.useLayoutEffect)(()=>{let e=s.current;!e||l.current||(e.style.width=`${t.expanded?r:t.collapsedWidth}px`)},[r,t.expanded,t.collapsedWidth]),{width:r,dragging:a,panelRef:s,onGripPointerDown:(0,Q.useCallback)(e=>{if(e.button!==0||!u.current.expanded)return;e.preventDefault();let t=s.current;if(!t)return;let r=e.clientX,a=c.current,d=a;l.current=!0,o(!0),t.style.transition=`none`;let f=document.body.style.cursor,p=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;try{e.target.setPointerCapture?.(e.pointerId)}catch{}let m=e=>{let n=u.current,i=e.clientX-r,o=n.side===`left`?i:-i;d=VM(a+o,n.min,n.max),t.style.width=`${d}px`},h=()=>{window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,h),t.style.transition=``,document.body.style.cursor=f,document.body.style.userSelect=p,l.current=!1,o(!1),i(d);try{localStorage.setItem(n,String(Math.round(d)))}catch{}};window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,h)},[n]),onGripKeyDown:(0,Q.useCallback)(e=>{let t=u.current,r=e.shiftKey?24:8,a=t.side===`left`?`ArrowRight`:`ArrowLeft`,o=t.side===`left`?`ArrowLeft`:`ArrowRight`,s=null;if(e.key===a?s=VM(c.current+r,t.min,t.max):e.key===o?s=VM(c.current-r,t.min,t.max):e.key===`Home`&&(s=t.defaultWidth),s!==null){e.preventDefault(),i(s);try{localStorage.setItem(n,String(Math.round(s)))}catch{}}},[n])}}function WM({side:e,dragging:t,width:n,min:r,max:i,label:a,onPointerDown:o,onKeyDown:s}){return(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":a,"aria-valuenow":Math.round(n),"aria-valuemin":r,"aria-valuemax":i,tabIndex:0,"data-testid":`sidebar-resize-grip-${e}`,onPointerDown:o,onKeyDown:s,className:X(`group absolute inset-y-0 z-20 w-1.5 cursor-col-resize outline-none`,e===`left`?`-right-0.5`:`-left-0.5`),children:(0,$.jsx)(`div`,{className:X(`absolute inset-y-0 w-px transition-colors duration-150`,e===`left`?`right-0`:`left-0`,t?`bg-accent-primary`:`bg-transparent group-hover:bg-accent-primary/50 group-focus-visible:bg-accent-primary/70`)})})}var GM=[`pinned-open`,`pinned-collapsed`,`unpinned`],KM=`specrails-desktop:sidebar-mode:left`,qM=`specrails-desktop:sidebar-mode:right`;function JM(e){return typeof e==`string`&&GM.includes(e)}function YM(e){try{let t=window.localStorage.getItem(e);if(JM(t))return t}catch{}return`unpinned`}function XM(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ZM(e){switch(e){case`pinned-open`:return`pinned-collapsed`;case`pinned-collapsed`:return`unpinned`;case`unpinned`:return`pinned-open`}}var QM=(0,Q.createContext)({leftMode:`unpinned`,rightMode:`unpinned`,setLeftMode:()=>{},setRightMode:()=>{},cycleLeftMode:()=>{},cycleRightMode:()=>{}});function $M({children:e}){let[t,n]=(0,Q.useState)(()=>YM(KM)),[r,i]=(0,Q.useState)(()=>YM(qM));(0,Q.useEffect)(()=>{XM(KM,t)},[t]),(0,Q.useEffect)(()=>{XM(qM,r)},[r]);let a=(0,Q.useCallback)(e=>n(e),[]),o=(0,Q.useCallback)(e=>i(e),[]),s=(0,Q.useCallback)(()=>n(e=>ZM(e)),[]),c=(0,Q.useCallback)(()=>i(e=>ZM(e)),[]),l=(0,Q.useMemo)(()=>({leftMode:t,rightMode:r,setLeftMode:a,setRightMode:o,cycleLeftMode:s,cycleRightMode:c}),[t,r,a,o,s,c]);return(0,$.jsx)(QM.Provider,{value:l,children:e})}function eN(){return(0,Q.useContext)(QM)}function tN({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a,provider:o=`claude`}){let{t:s}=K(`builder`),{registerHandler:c,unregisterHandler:l}=qe(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)({status:`idle`}),O=(0,Q.useRef)(null),k=(0,Q.useRef)(r),A=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{O.current=u},[u]),(0,Q.useEffect)(()=>{k.current=r},[r]);let j=a.milestones.find(e=>e.id===i),M=i.toUpperCase(),N=ir(o,`read-only`),P=(0,Q.useMemo)(()=>BA(v??g,{milestoneLabel:M,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[g,v,M]),F=(0,Q.useMemo)(()=>HA(g,v??g,P,{minSpecs:1,maxSpecs:10}),[g,v,P]),I=(0,Q.useMemo)(()=>Pt(m),[m]);(0,Q.useEffect)(()=>{if(!e||u||!N)return;let t=!1;return fetch(`${nt()}/chat/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`milestone`,milestone:i})}).then(e=>e.json()).then(e=>{if(t||!e.conversation)return;O.current=e.conversation.id,d(e.conversation.id);let n=j?.plannedSpecs??[],r={label:M,title:j?.title??M,planned:n.join(`; `)},i=n.length>0?s(`prompts.milestoneSeedWithPlanned`,r):s(`prompts.milestoneSeed`,r);p([{role:`user`,content:i}]),C(!0),fetch(`${nt()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{C(!1),J.error(s(`errors.turnFailed`))})}).catch(()=>{t||J.error(s(`errors.startFailed`))}),()=>{t=!0}},[e,u,i,j,M,N,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=`milestone-generate-${i}`;return c(t,e=>{let t=e;if(t.conversationId===O.current&&!(t.projectId&&t.projectId!==k.current))if(t.type===`chat_stream`)h(e=>(e??``)+String(t.delta??``));else if(t.type===`chat_done`){h(null),C(!1);let e=String(t.fullText??``),n=Lt(e),r=n.stripped.trim()||(n.hadBlocks?``:e);if(r&&p(e=>[...e,{role:`assistant`,content:r}]),n.blueprint)_(n.blueprint),y(n.rawBlueprint),D({status:`accepted`,repaired:n.repaired,repairAttempted:!1,at:new Date().toISOString()});else if(n.rejected.length>0){let e=n.rejected[n.rejected.length-1];D({status:`rejected`,reason:e.reason,detail:e.detail,repairAttempted:!1,at:new Date().toISOString()})}}else t.type===`chat_error`&&(h(null),C(!1),J.error(s(`errors.turnFailed`),{description:String(t.error??``)}))}),()=>l(t)},[e,i,c,l,s]),(0,Q.useEffect)(()=>{A.current?.scrollTo?.({top:A.current.scrollHeight})},[f,m]);let L=(0,Q.useCallback)(e=>{let t=O.current,n=e.trim();!t||!n||S||(p(e=>[...e,{role:`user`,content:n}]),x(``),C(!0),fetch(`${nt()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{C(!1),J.error(s(`errors.turnFailed`))}))},[S,s]),R=(0,Q.useCallback)(()=>{let e=E.status===`rejected`?s(`snapshot.rejected.${E.reason}`):s(`readiness.issuesCount`,{count:F.issues.length});L(s(`prompts.repairSnapshot`,{reason:e}))},[E,F.issues.length,L,s]),z=(0,Q.useCallback)(()=>{let e=v??g,r=e&&typeof e==`object`&&!Array.isArray(e)?e:null,a=Array.isArray(r?.m1Specs)?r.m1Specs:[];!P.valid||w||(T(!0),fetch(`${nt()}/blueprint/commit-milestone`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({milestoneId:i,specsComplete:r?.specsComplete,specs:a})}).then(async e=>{if(e.status===201){let r=await e.json();J.success(s(`milestone.commitToast`,{count:r.insertedIds.length,label:M})),n?.(),t()}else{let t=await e.json().catch(()=>({}));J.error(s(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>J.error(s(`milestone.commitFailed`))).finally(()=>T(!1)))},[g,v,P.valid,w,i,M,t,n,s]);if(!e)return null;let B=g?.m1Specs.length??0;return N?(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:s(`milestone.title`,{label:M})}),j&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:j.title}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":s(`shell.close`),"data-testid":`milestone-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col border-r border-border/40`,children:[(0,$.jsxs)(`div`,{ref:A,className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[f.map((e,t)=>(0,$.jsx)(`div`,{className:X(`max-w-[85%] whitespace-pre-wrap rounded-lg px-3 py-2 text-xs leading-relaxed`,e.role===`user`?`ml-auto bg-accent-primary/15`:`bg-surface/70`),children:e.content},t)),m!==null&&(0,$.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-surface/70 px-3 py-2 text-xs leading-relaxed`,children:[St(m),(0,$.jsx)(`span`,{className:`ml-0.5 inline-block h-3 w-1.5 animate-pulse bg-accent-primary/70 align-middle`})]}),I.generating&&(0,$.jsx)(mA,{specsStarted:I.specsStarted,snapshot:E})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-border/40 p-3`,children:[(0,$.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L(b))},rows:2,placeholder:s(`milestone.inputPlaceholder`),className:`min-h-[2.5rem] flex-1 resize-none rounded-md border border-border/40 bg-surface/50 px-3 py-2 text-xs focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`}),(0,$.jsx)(Z,{size:`sm`,onClick:()=>L(b),disabled:S||!b.trim()||!u,children:S?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(tc,{className:`h-3.5 w-3.5`})})]})]}),(0,$.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,$.jsx)(vj,{blueprint:g,milestoneLabel:M,snapshot:E}),(0,$.jsx)(xj,{readiness:F,snapshot:E,busy:S||w,primaryLabel:w?s(`commit.creating`):s(`milestone.commit`,{count:B,label:M}),onPrimary:z,onRepair:R,primaryTestId:`milestone-commit`})]})]})]}):(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:s(`milestone.title`,{label:M})}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":s(`shell.close`),"data-testid":`milestone-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`m-4 rounded-md border border-accent-warning/30 bg-accent-warning/10 p-3 text-sm text-accent-warning`,"data-testid":`milestone-provider-unavailable`,children:s(`milestone.providerUnavailable`)})]})}function nN({expanded:e}){let{t}=K(`builder`),n=v(),{activeProjectId:r,projects:i}=at(),{blueprint:a,progress:o,hasBlueprint:s,refresh:c}=Dt(r),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(()=>_A()),[_,y]=(0,Q.useState)(()=>bA()),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{if(!l){T(null);return}let e=()=>{let e=S.current?.getBoundingClientRect();if(!e)return;let t=Math.max(8,e.left-320-8),n=Math.min(Math.max(8,e.top),Math.max(8,window.innerHeight-240));T({top:n,left:t})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[l]),(0,Q.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;S.current?.contains(t)||C.current?.contains(t)||u(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let E=(0,Q.useCallback)(async()=>{if(!(!r||d)){f(!0);try{let e=await EA(r,1,h,{autoAdvance:_}),n=CA(1);if(e.ok){let r=e.launched.length+e.pending.length;h===`sequential`&&e.pending.length>0?J.success(t(_?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:n,count:e.ticketCount,n:r})):e.skippedCount>0?J.warning(t(`milestoneProgress.toast.launchedPartial`,{milestone:n,count:e.ticketCount,skipped:e.skippedCount})):J.success(t(`milestoneProgress.toast.launchedAll`,{milestone:n,count:e.ticketCount,n:r})),u(!1)}else e.reason===`chain_active`?J.info(t(`milestoneProgress.toast.chainActive`,{milestone:n})):J.error(t(`done.launchFailed`),{description:e.detail??e.error})}finally{f(!1)}}},[r,_,d,h,t]),D=(0,Q.useCallback)(async(e,n)=>{if(!(!r||p)){m(!0);try{let i=await AA(r,e,n);i.ok?(y(n),xA(n),J.success(t(n?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):J.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{m(!1)}}},[r,p,t]),O=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await OA(r,e);n.ok?J.success(t(`milestoneProgress.chain.resumed`)):J.error(t(`milestoneProgress.chain.resumeFailed`),{description:n.detail??n.error})}finally{m(!1)}}},[r,p,t]),k=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await kA(r,e);n.ok?J.success(t(`milestoneProgress.chain.cancelledToast`)):J.error(n.detail??n.error)}finally{m(!1)}}},[r,p,t]),A=(0,Q.useCallback)(e=>{u(!1),n(ve?`/review/${e}`:`/`)},[n]),j=(0,Q.useCallback)(()=>{u(!1),n(`/`)},[n]);if(!r||s===!1||!a)return null;let M=o.find(e=>e.n===1)??null,N=M!==null&&bt(M),P=o.find(e=>e.state===`planned`&&e.n>1)??null,F=i.find(e=>e.id===r),I=F?.provider??F?.providers?.[0]??`claude`,L=ir(I,`read-only`),R=N?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex rounded-md border border-border/40 p-0.5 text-[10px]`,role:`radiogroup`,"aria-label":t(`sequential.modeLabel`),title:t(h===`sequential`?`milestoneProgress.sequentialHint`:`milestoneProgress.parallelHint`),"data-testid":`milestone-launch-mode`,children:[`sequential`,`parallel`].map(e=>(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":h===e,onClick:()=>{g(e),vA(e)},className:X(`flex-1 rounded px-1.5 py-1 font-medium transition-colors`,h===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:text-foreground`),children:t(`sequential.mode.${e}`)},e))}),h===`sequential`&&(0,$.jsx)(aj,{checked:_,onChange:e=>{y(e),xA(e)},testId:`sidebar-auto-advance`}),(0,$.jsxs)(`button`,{type:`button`,onClick:E,disabled:d,className:`inline-flex items-center justify-center gap-1.5 rounded-md bg-accent-primary/15 px-2 py-1.5 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/25 disabled:opacity-50`,"data-testid":`sidebar-launch-m1`,children:[d?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Xs,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]})]}):null;return(0,$.jsxs)(`div`,{ref:S,className:`relative`,"data-testid":`builder-sidebar-entry`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,e?`px-2`:`px-0 justify-center`,l?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:e?void 0:t(`sidebar.title`),"data-testid":`builder-sidebar-toggle`,children:[(0,$.jsx)(ps,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),l&&w&&(0,xb.createPortal)((0,$.jsxs)(`div`,{ref:C,className:`fixed z-[72] w-80 max-h-[80vh] overflow-y-auto rounded-lg border border-border/50 bg-background p-3 shadow-xl`,style:{top:w.top,left:w.left},"data-testid":`builder-sidebar-panel`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-semibold`,children:t(`sidebar.title`)}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:o.map(e=>(0,$.jsx)(sj,{progress:e,actions:e.n===1?R:void 0,chainBusy:p,onReview:A,onOpenRail:j,onResume:O,onCancel:k,onSetAutoAdvance:D},e.id||e.n))}),P&&(0,$.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{L&&(x(P.id),u(!1))},disabled:!L,className:`inline-flex items-center justify-center gap-1.5 rounded-md border border-accent-highlight/40 px-2 py-1.5 text-[11px] font-medium text-accent-highlight transition-colors hover:bg-accent-highlight/10`,title:t(L?`sidebar.generateHint`:`sidebar.generateUnavailable`),"data-testid":`sidebar-generate-next`,children:[(0,$.jsx)(un,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:P.n})]})})]}),document.body),b&&(0,$.jsx)(tN,{open:!0,onClose:()=>x(null),onCommitted:()=>{c()},projectId:r,milestoneId:b,blueprint:a,provider:I})]})}var rN={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function iN({missionOnly:e=!1}={}){let{t}=K(`agent`),{t:n}=K(`nav`),{t:r}=K(`builder`),{rightMode:i,cycleRightMode:a}=eN(),{activeProjectId:o}=at(),s=Ca(),c=Ux(),{builderMode:l}=lM(),[u,d]=(0,Q.useState)(!1),f=l.active||i===`pinned-open`||i===`unpinned`&&u,p=UM(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=i!==`unpinned`,h=n(rN[i]),g=!o,_=[{key:`jobs`,icon:Eo,label:t(`workspace.jobs`),onClick:()=>c.toggleJobsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},{key:`analytics`,icon:Do,label:t(`workspace.analytics`),onClick:()=>c.toggleAnalyticsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},...ke()?[{key:`browser`,icon:E,label:t(`workspace.browser`),onClick:()=>c.openBrowser(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...Ce?[{key:`terminal`,icon:sc,label:t(`workspace.terminal`),onClick:()=>o&&s.togglePanel(o),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...se?[{key:`files`,icon:$o,label:t(`workspace.files`),onClick:()=>c.toggleCodePane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[]];return(0,$.jsxs)(`div`,{ref:p.panelRef,className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{i===`unpinned`&&d(!0)},onMouseLeave:()=>{i===`unpinned`&&!p.dragging&&d(!1)},children:[f&&(0,$.jsx)(WM,{side:`right`,dragging:p.dragging,width:p.width,min:180,max:460,label:n(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:p.onGripPointerDown,onKeyDown:p.onGripKeyDown}),(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,f?`px-3 justify-between`:`justify-center`),children:[f&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:t(`workspace.title`)}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,m?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":h,title:n(`sidebarPin.withShortcut`,{label:h,shortcut:`⌘B`}),children:(0,$.jsx)(Ls,{className:`w-4 h-4`})})]}),l.active?(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsxs)(fy.div,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:24},transition:{duration:.22,ease:`easeOut`},className:`flex min-h-0 flex-1 flex-col`,"data-testid":`workspace-blueprint-panel`,children:[(0,$.jsx)(vj,{blueprint:l.session.blueprint,snapshot:l.session.snapshot}),l.session.phase===`chat`&&(0,$.jsx)(xj,{readiness:l.session.readiness,snapshot:l.session.snapshot,busy:l.session.busy,primaryLabel:r(`shell.createSpecs`),onPrimary:l.session.goToCommit,onRepair:()=>void l.session.repairSnapshot()})]},`builder-blueprint`)}):(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[!e&&(0,$.jsx)(nN,{expanded:f}),_.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,$.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,f?`px-2`:`px-0 justify-center`,i?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:i?a:f?void 0:n,children:[(0,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),f&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))]})]})}var aN=`specrails:terminal-settings-updated`;function oN(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(aN,{detail:e}))}function sN(){return new uN(xM(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function cN(){return Y(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new uN(new wM(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var lN=[`tauri://created`,`tauri://error`],uN=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||Y(`plugin:webview|create_webview`,{windowLabel:e.label,options:{...n,label:t}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await cN()).find(t=>t.label===e)??null}static getCurrent(){return sN()}static async getAll(){return cN()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:mr(e,t,{target:{kind:`Webview`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:gr(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(lN.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return hr(e,t)}async emitTo(e,t,n){if(lN.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return _r(e,t,n)}_handleTauriEvent(e,t){return lN.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return Y(`plugin:webview|webview_position`,{label:this.label}).then(e=>new gM(e))}async size(){return Y(`plugin:webview|webview_size`,{label:this.label}).then(e=>new pM(e))}async close(){return Y(`plugin:webview|webview_close`,{label:this.label})}async setSize(e){return Y(`plugin:webview|set_webview_size`,{label:this.label,value:e instanceof mM?e:new mM(e)})}async setPosition(e){return Y(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setFocus(){return Y(`plugin:webview|set_webview_focus`,{label:this.label})}async setAutoResize(e){return Y(`plugin:webview|set_webview_auto_resize`,{label:this.label,value:e})}async hide(){return Y(`plugin:webview|webview_hide`,{label:this.label})}async show(){return Y(`plugin:webview|webview_show`,{label:this.label})}async setZoom(e){return Y(`plugin:webview|set_webview_zoom`,{label:this.label,value:e})}async reparent(e){return Y(`plugin:webview|reparent`,{label:this.label,window:typeof e==`string`?e:e.label})}async clearAllBrowsingData(){return Y(`plugin:webview|clear_all_browsing_data`)}async setBackgroundColor(e){return Y(`plugin:webview|set_webview_background_color`,{color:e})}async onDragDropEvent(e){let t=await this.listen(vr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),n=await this.listen(vr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new gM(t.payload.position)}})}),r=await this.listen(vr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),i=await this.listen(vr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function dN(e){return`'${e.replace(/'/g,`'\\''`)}'`}function fN(e){if(/[\x00-\x1f"%!]/.test(e))throw Error(`unsafe-cmd-path`);return`"`+e+`"`}function pN(e){return`'${e.replace(/'/g,`''`)}'`}function mN(e,t,n=`powershell`){return t?n===`cmd`?fN(e):pN(e):dN(e)}function hN(e,t,n=`powershell`){return e.map(e=>mN(e,t,n)).join(` `)}function gN(e){return/(?:^|[\\/])cmd(?:\.exe)?$/i.test(e??``)?`cmd`:`powershell`}async function _N(e){if(!me())return{dispose:()=>{}};let t=[];try{let n=``,r=0,i=typeof navigator<`u`&&/Win/i.test(navigator.platform||``),a=t=>{let a=t.payload;if(!a||a.type!==`drop`)return;let o=a.paths;if(!o||o.length===0)return;let s=a.position;if(!s)return;let c=`${o.join(`\0`)}@${s.x},${s.y}`,l=Date.now();if(c===n&&l-r<250)return;n=c,r=l;let u=e();if(u&&yN(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))try{u.writeText(hN(o,i,gN(u.shell)))}catch{J.error(G.t(`terminal:errors.pathPasteUnsafe`))}},o=vN((()=>{try{return sN()}catch{return null}})());o&&t.push(await o(a));let s=vN((()=>{try{return xM()}catch{return null}})());return s&&t.push(await s(a)),t.length===0?{dispose:()=>{}}:{dispose:()=>{for(let e of t)try{e()}catch{}}}}catch{for(let e of t)try{e()}catch{}return{dispose:()=>{}}}}function vN(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function yN(e,t,n){let r=Number.isFinite(n)&&n>0?n:1;return bN(e.x/r,e.y/r,t)}function bN(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function xN({x:e,y:t,label:n,onSelect:r,onClose:i}){let a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),(0,$.jsx)(`div`,{ref:a,role:`menu`,"data-shortcut-context-menu":!0,style:{position:`fixed`,left:typeof window<`u`&&e+220>window.innerWidth?e-220:e,top:typeof window<`u`&&t+60>window.innerHeight?t-60:t,minWidth:200},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),i()},className:`w-full text-left px-3 py-1.5 text-[#f8f8f2] hover:bg-[#44475a]`,children:n})})}function SN({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=K(`terminal`),o=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=typeof window<`u`&&e+200>window.innerWidth?e-200:e,c=8+n.length*32;return(0,$.jsx)(`div`,{ref:o,role:`menu`,"data-cli-launch-menu":!0,style:{position:`fixed`,left:s,top:typeof window<`u`&&t+c>window.innerHeight?t-c:t,minWidth:180},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:n.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(e),i()},className:`w-full text-left px-3 py-1.5 text-[#f8f8f2] hover:bg-[#44475a]`,children:a(`cliMenu.open`,{name:ur(e)})},e))})}var CN=(0,Q.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=K(`terminal`);return(0,$.jsx)(`button`,{ref:r,type:`button`,"aria-label":i(e?`panelChevron.collapse`:`panelChevron.expand`),"aria-expanded":e,className:X(`panel-chevron`,`inline-flex items-center justify-center`,`h-5 w-6 mr-1.5`,`rounded text-muted-foreground`,`hover:bg-border/40 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/60`,`transition-colors duration-120`,t),...n,children:(0,$.jsxs)(`svg`,{width:`14`,height:`10`,viewBox:`0 0 14 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,$.jsx)(`rect`,{x:`1`,y:`1`,width:`12`,height:`8`,rx:`1.5`}),e?(0,$.jsx)(`path`,{d:`M5 3.5 L7 5.5 L9 3.5`}):(0,$.jsx)(`path`,{d:`M5 6.5 L7 4.5 L9 6.5`})]})})});function wN({visibility:e,canCreate:t,hasActive:n,provider:r=`claude`,providers:i,onCreate:a,onOpenCli:o,onOpenBrowser:s,onPasteScript:c,pasteScriptDisabled:l,onConfigureBrowser:u,onConfigureScript:d,onKillActive:f,onToggleMaximize:p,onCollapse:m}){let{t:h}=K(`terminal`),g=!!i&&i.length>1,_=ur(r),v=h(`topBar.maxTerminals`,{max:10}),y=t?g?h(`topBar.openCliMulti`):h(`topBar.openCli`,{cli:_}):v;return(0,$.jsxs)(`div`,{className:X(`flex items-center justify-between h-7 px-2 shrink-0`,`bg-background/95 backdrop-blur-sm`,`border-b border-border/40`,`text-[10px] uppercase tracking-wide text-muted-foreground select-none`),children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 pl-1`,children:(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:h(`topBar.title`)})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(TN,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,$.jsx)(un,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(E,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(l?`topBar.pasteScriptNoActive`:`topBar.pasteScript`),disabled:l,onClick:c,onContextMenu:e=>{e.preventDefault(),d({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(Lo,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,$.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,$.jsx)(ks,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Os,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(CN,{isOpen:!0,onClick:m})]})]})}function TN({label:e,disabled:t,onClick:n,onContextMenu:r,children:i}){return(0,$.jsx)(`button`,{type:`button`,onClick:e=>n(e),onContextMenu:r,disabled:t,title:e,"aria-label":e,className:X(`inline-flex items-center justify-center h-5 w-6 rounded`,`text-muted-foreground transition-colors duration-120`,t?`opacity-40 cursor-not-allowed`:`hover:bg-border/40 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/60`),children:i})}function EN({sessions:e,activeId:t,onActivate:n,onRename:r,onKill:i}){return(0,$.jsx)(`aside`,{className:X(`w-44 shrink-0 border-l border-border/40 bg-background/70`,`overflow-y-auto`),children:(0,$.jsx)(`ul`,{className:`py-1`,children:e.map(e=>(0,$.jsx)(DN,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function DN({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=K(`terminal`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(e.name),u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{o&&(l(e.name),queueMicrotask(()=>{u.current?.focus(),u.current?.select()}))},[o,e.name]);function d(){let t=c.trim();t&&t!==e.name&&r(t),s(!1)}function f(){s(!0)}function p(){s(!1),l(e.name)}return(0,$.jsx)(`li`,{className:`relative group px-1`,children:(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{o||n()},onKeyDown:e=>{o||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},onDoubleClick:f,className:X(`flex items-center gap-2 px-2 py-1.5 rounded-md text-xs cursor-pointer select-none`,`transition-colors duration-120`,t?`bg-border/40 text-foreground border-l-2 border-accent-primary/70 pl-[calc(0.5rem-2px)]`:`text-muted-foreground hover:bg-border/20 hover:text-foreground`),children:[(0,$.jsx)(dc,{className:`h-3 w-3 shrink-0`}),o?(0,$.jsx)(`input`,{ref:u,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(e.preventDefault(),p())},onBlur:d,onClick:e=>e.stopPropagation(),maxLength:64,className:X(`flex-1 min-w-0 bg-background/60 border border-border/40 rounded px-1`,`text-xs text-foreground outline-none focus:ring-1 focus:ring-accent-primary/60`)}):(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),!o&&(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`sidebar.rename`,{name:e.name}),title:a(`sidebar.rename`,{name:e.name}),onClick:e=>{e.stopPropagation(),f()},className:X(`inline-flex items-center justify-center h-4 w-4 rounded`,`text-muted-foreground opacity-0 group-hover:opacity-100`,`hover:bg-border/40 hover:text-foreground`,`transition-opacity duration-120`,t&&`opacity-70`),children:(0,$.jsx)(an,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`sidebar.close`,{name:e.name}),title:a(`sidebar.close`,{name:e.name}),onClick:e=>{e.stopPropagation(),i()},className:X(`inline-flex items-center justify-center h-4 w-4 rounded`,`text-muted-foreground opacity-0 group-hover:opacity-100`,`hover:bg-destructive/20 hover:text-destructive`,`transition-opacity duration-120`,t&&`opacity-70`),children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]})})}function ON({search:e,onClose:t}){let{t:n}=K(`terminal`),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(r.current?.focus(),()=>{try{e.clearDecorations()}catch{}}),[e]),(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);function m(){return{caseSensitive:o,regex:c,wholeWord:u,decorations:{matchBackground:`#bd93f9`,matchOverviewRuler:`#bd93f9`,activeMatchBackground:`#ff79c6`,activeMatchColorOverviewRuler:`#ff79c6`}}}function h(){if(i)try{e.findNext(i,m())}catch{}}function g(){if(i)try{e.findPrevious(i,m())}catch{}}return(0,Q.useEffect)(()=>{let t=()=>{};try{let n=e.onDidChangeResults(e=>{if(!e){p(null);return}p({current:e.resultIndex+1,total:e.resultCount})});t=()=>{try{n.dispose()}catch{}}}catch{}return t},[e]),(0,$.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1 bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg px-2 py-1 z-30`,role:`search`,"data-terminal-search-overlay":!0,children:[(0,$.jsx)(`input`,{ref:r,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.shiftKey?g():h())},placeholder:n(`search.placeholder`),className:`bg-transparent text-sm outline-none text-[#f8f8f2] placeholder:text-[#6272a4] w-48`}),f&&(0,$.jsxs)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:[f.current,`/`,f.total]}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.previous`),onClick:g,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(Gt,{size:14})}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(Zt,{size:14})}),(0,$.jsx)(kN,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,$.jsx)(kN,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,$.jsx)(kN,{label:`W`,title:n(`search.wholeWord`),active:u,onToggle:()=>d(e=>!e)}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.close`),onClick:t,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(mn,{size:14})})]})}function kN({label:e,title:t,active:n,onToggle:r}){return(0,$.jsx)(`button`,{type:`button`,title:t,onClick:r,className:`text-xs px-1.5 py-0.5 rounded font-mono ${n?`bg-[#6272a4] text-white`:`text-[#f8f8f2] hover:bg-[#44475a]`}`,children:e})}function AN({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=K(`terminal`),u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&a()},t=e=>{e.key===`Escape`&&a()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let d=typeof window<`u`&&e+220>window.innerWidth?e-220:e,f=typeof window<`u`&&t+260>window.innerHeight?t-260:t,p=/Mac/i.test(navigator.platform||``)?`⌘`:`Ctrl+`,m=n.getSelection(),h=m.length>0;function g(){h&&(ma(m),a())}function _(){pa().then(e=>{if(e)try{n.paste(e)}catch{}}),a()}function v(){try{n.selectAll()}catch{}a()}function y(){try{n.clear()}catch{}a()}function b(){o(),a()}function x(){c(),a()}function S(){r&&s(r),a()}return(0,$.jsxs)(`div`,{ref:u,role:`menu`,"data-terminal-context-menu":!0,style:{position:`fixed`,left:d,top:f,minWidth:200},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:[(0,$.jsx)(jN,{onClick:g,disabled:!h,label:l(`common:actions.copy`),shortcut:p+`C`}),(0,$.jsx)(jN,{onClick:_,label:l(`contextMenu.paste`),shortcut:p+`V`}),(0,$.jsx)(jN,{onClick:v,label:l(`contextMenu.selectAll`),shortcut:p+`A`}),(0,$.jsx)(MN,{}),(0,$.jsx)(jN,{onClick:y,label:l(`contextMenu.clear`),shortcut:p+`K`}),(0,$.jsx)(jN,{onClick:b,label:l(`contextMenu.search`),shortcut:p+`F`}),(0,$.jsx)(jN,{onClick:x,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(MN,{}),(0,$.jsx)(jN,{onClick:S,label:l(`contextMenu.openPath`,{path:NN(r,40)})})]})]})}function jN({onClick:e,label:t,shortcut:n,disabled:r}){return(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r||e()},disabled:r,className:`w-full text-left px-3 py-1.5 flex justify-between items-center ${r?`text-[#6272a4] cursor-not-allowed`:`text-[#f8f8f2] hover:bg-[#44475a]`}`,children:[(0,$.jsx)(`span`,{children:t}),n&&(0,$.jsx)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:n})]})}function MN(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function NN(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function PN(e,t=`terminal-scrollback.txt`){let n=e.buffer.active,r=[];for(let e=0;e<n.length;e++){let t=n.getLine(e);t&&r.push(t.translateToString(!0))}let i=r.join(`
44
+ `);if(me()){let{invoke:e}=await c(async()=>{let{invoke:e}=await import(`./core-B3mKBIh5.js`).then(e=>e.i);return{invoke:e}},__vite__mapDeps([0,1]));await e(`desktop_save_text`,{suggestedName:t,text:i});return}try{let e=new Blob([i],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{}}function FN({sessionId:e}){let[t,n]=(0,Q.useState)(()=>Ei(e));return(0,Q.useEffect)(()=>Ti(e,n),[e]),t.promptRows.length===0?null:(0,$.jsx)(`div`,{"aria-hidden":`true`,"data-prompt-gutter":!0,className:`absolute left-0 top-0 bottom-0 w-1 pointer-events-none z-10`,children:(0,$.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 w-full`,style:{backgroundImage:`linear-gradient(to bottom, rgba(189,147,249,0.2), rgba(189,147,249,0.05))`}})})}function IN({sessionId:e}){let{t}=K(`terminal`),[n,r]=(0,Q.useState)(Ei(e).openPreExec?.startedAt??null),[i,a]=(0,Q.useState)(Date.now());if((0,Q.useEffect)(()=>Ti(e,e=>r(e.openPreExec?.startedAt??null)),[e]),(0,Q.useEffect)(()=>{if(n==null)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[n]),n==null)return null;let o=i-n;return o<500?null:(0,$.jsx)(`div`,{className:`absolute top-2 left-2 px-2 py-0.5 rounded text-xs font-mono bg-[#44475a] text-[#f8f8f2] z-10 pointer-events-none`,children:LN(o,t)})}function LN(e,t){return e<6e4?t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)}):t(`terminal:duration.minutesSeconds`,{minutes:Math.floor(e/6e4),seconds:Math.floor(e%6e4/1e3)})}function RN({activeId:e}){let{t}=K(`terminal`),n=(0,Q.useRef)(null),r=Ca(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=me();(0,Q.useEffect)(()=>{if(e)return r.subscribeOpenSearch(e,()=>a(!0))},[e,r]),(0,Q.useEffect)(()=>{a(!1),s(null)},[e]);let l=e?r.getSearchAddon(e):null,u=e?r.getTerminalInstance(e):null,d=e?r.getCwd(e):null,[f,p]=(0,Q.useState)(!1),m=(0,Q.useCallback)(t=>{if(!t)return!1;if(e&&r.writeToSession(e,t))return!0;if(!u)return!1;try{return u.paste(t),!0}catch{return!1}},[e,r,u]),h=(0,Q.useCallback)(n=>{if(!u||!n||n.length===0)return!1;let i=Array.from(n).map(e=>zN(e)).filter(e=>!!e);if(i.length===0)return!1;let a=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);try{return m(hN(i,a,gN(e?r.getShell?.(e):null)))}catch{return J.error(t(`errors.pathPasteUnsafe`)),!1}},[u,m,e,r,t]),g=(0,Q.useCallback)(e=>{if(e.preventDefault(),!e.shiftKey&&u){let e=u.modes?.mouseTrackingMode;if(e&&e!==`none`)return}s({x:e.clientX,y:e.clientY})},[u]),_=(0,Q.useCallback)(n=>{if(!u)return;if(n.clipboardData.files&&n.clipboardData.files.length>0){let i=Array.from(n.clipboardData.files).map(e=>zN(e)).filter(e=>!!e);if(i.length>0){n.preventDefault(),n.stopPropagation();let a=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);try{m(hN(i,a,gN(e?r.getShell?.(e):null)))}catch{J.error(t(`errors.pathPasteUnsafe`))}return}}let i=n.clipboardData.getData(`text/plain`);i&&(n.preventDefault(),n.stopPropagation(),m(i))},[u,m,e,r,t]),v=(0,Q.useCallback)(e=>{if(!u)return;let t=u.getSelection();t&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault(),e.stopPropagation())},[u]),y=(0,Q.useCallback)(e=>{if(u&&(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?e.metaKey:e.ctrlKey)&&(e.key===`c`||e.key===`C`)){let t=u.getSelection();if(!t)return;e.preventDefault(),e.stopPropagation(),ma(t)}},[u]);return(0,Q.useEffect)(()=>{let t=n.current;if(!t||!e)return;let i=r.getContainer(e);if(i)return t.appendChild(i),r.notifyAdopted(e),()=>{let e=document.getElementById(`specrails-terminal-host`);e&&i.parentElement===t&&e.appendChild(i)}},[e,r]),(0,Q.useEffect)(()=>{let t=n.current;if(!t||!e)return;let i=[],a=t.parentElement;for(;a&&a!==document.body;)(a.tagName.toLowerCase()===`aside`||a.matches(`[data-sidebar]`))&&i.push(a),a=a.parentElement;if(i.length===0)return;let o=t=>{let n=t;n.propertyName!==`width`&&n.propertyName!==`height`||r.refitActive(e)};return i.forEach(e=>e.addEventListener(`transitionend`,o)),()=>{i.forEach(e=>e.removeEventListener(`transitionend`,o))}},[e,r]),(0,$.jsxs)(`div`,{ref:n,className:`flex-1 min-w-0 bg-background px-2 py-1 relative ${f?`outline outline-2 outline-accent-primary outline-offset-[-2px]`:``}`,role:`presentation`,"data-terminal-viewport":!0,onContextMenu:g,onPasteCapture:_,onCopyCapture:v,onKeyDownCapture:y,tabIndex:-1,onDragEnter:e=>{BN(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),p(!0))},onDragOver:e=>{BN(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),p(!0))},onDragLeave:()=>p(!1),onDrop:e=>{BN(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),h(e.dataTransfer.files)),p(!1)},children:[e&&(0,$.jsx)(FN,{sessionId:e}),e&&(0,$.jsx)(IN,{sessionId:e}),i&&l&&(0,$.jsx)(ON,{search:l,onClose:()=>a(!1)}),o&&u&&(0,$.jsx)(AN,{x:o.x,y:o.y,term:u,cwd:d,hasReveal:c,onClose:()=>s(null),onOpenSearch:()=>a(!0),onReveal:e=>{oe(e).catch(()=>J.error(t(`errors.nativeActionFailed`)))},onSaveScrollback:()=>{u&&PN(u).catch(()=>J.error(t(`errors.nativeActionFailed`)))}})]})}function zN(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function BN(e){return e?Array.from(e.types).includes(`Files`):!1}function VN({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=K(`terminal`),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(0),c=(0,Q.useRef)(e),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(e),d=(0,Q.useCallback)(e=>e<i?i:e>t?t:Math.round(e),[i,t]);(0,Q.useEffect)(()=>{function e(e){if(!o.current)return;let t=s.current-e.clientY,n=d(c.current+t);u.current=n,l.current||(l.current=!0,requestAnimationFrame(()=>{l.current=!1,r?.(u.current)}))}function t(){o.current&&(o.current=!1,document.body.style.userSelect=``,document.body.style.cursor=``,n(u.current))}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[d,n,r]);function f(t){o.current=!0,s.current=t.clientY,c.current=e,u.current=e,document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`;let n=t.target;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(t.pointerId)}catch{}}return(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`dragHandle.resize`),onPointerDown:f,className:X(`absolute top-0 left-0 right-0 h-1`,`cursor-row-resize`,`bg-transparent hover:bg-accent-primary/40`,`transition-colors duration-120`,`z-10`)})}function HN({onCreate:e}){let{t}=K(`terminal`);return(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-6 bg-background-deep`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,$.jsx)(dc,{className:`h-8 w-8 opacity-50`}),(0,$.jsx)(`p`,{className:`text-xs`,children:t(`emptyState.noTerminals`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs bg-border/30 hover:bg-border/50 hover:text-foreground transition-colors`,children:[(0,$.jsx)(cn,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var UN=300;function WN({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=Ca(),{t:s}=K(`terminal`),c=v(),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(vi),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),{launchDescriptors:y}=UO(),b=(0,Q.useRef)(a===0&&r.visibility!==`hidden`),[x,S]=(0,Q.useState)(()=>r.visibility===`hidden`?`hidden`:b.current?`opening`:`open`),C=(0,Q.useRef)(!1),w=n&&n.length>0?n:[t],T=w.length>1,E=(0,Q.useCallback)(async(t=()=>!1)=>{try{let n=await fetch(`/api/projects/${e}/terminal-settings`);if(!n.ok)return;let r=await n.json();!t()&&r?.resolved&&p(r.resolved)}catch{}},[e]);(0,Q.useEffect)(()=>{let e=!1;return E(()=>e),()=>{e=!0}},[E]),(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||E()};return window.addEventListener(aN,t),()=>window.removeEventListener(aN,t)},[E,e]);let D=Math.max(120,i-a-40),O=Math.min(Math.max(r.userHeight||320,120),D),k=r.visibility===`maximized`?Math.max(120,i-a):u??O,A=x===`open`,j=A?k:0,M=a===0,N=r.sessions.length<10,P=r.activeId!==null;(0,Q.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{S(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>S(`open`))})};return C.current?(r.visibility===`hidden`?(S(`closing`),e=setTimeout(()=>S(`hidden`),UN)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(C.current=!0,b.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,Q.useEffect)(()=>{let e=!1,t=null;return _N(()=>{let e=l.current,t=r.activeId;return!e||!t||r.visibility===`hidden`?null:{viewportEl:e,shell:o.getShell?.(t),writeText:e=>{if(o.writeToSession(t,e))return!0;let n=o.getTerminalInstance(t);try{return n?.paste(e),!!n}catch{return!1}}}}).then(n=>{e?n.dispose():t=n}),()=>{e=!0,t?.dispose()}},[r.activeId,r.visibility,o]);let F=(0,Q.useCallback)(()=>{N&&o.create(e)},[N,e,o]),I=(0,Q.useCallback)(t=>{if(!N)return;let n=y[t]??{command:t,args:[]},i=[n.command,...n.args].join(` `)+`
45
+ `,a=t||`claude`,s=RegExp(`^${a} \\(\\d+\\)$`),c=r.sessions.filter(e=>e.name===a||s.test(e.name)),l=c.length===0?a:`${a} (${c.length+1})`;o.createAndType(e,i,{name:l})},[N,y,e,r.sessions,o]),L=(0,Q.useCallback)(e=>{if(N){if(T&&e){_(e);return}I(t)}},[N,T,t,I]),R=(0,Q.useCallback)(()=>{Te(f.browserShortcutUrl)},[f.browserShortcutUrl]),z=(0,Q.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),B=(0,Q.useCallback)(e=>{h({...e,kind:`browser`})},[]),ee=(0,Q.useCallback)(e=>{h({...e,kind:`script`})},[]),V=(0,Q.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),H=(0,Q.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),te=(0,Q.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ne=(0,Q.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,Q.useEffect)(()=>{d(null)},[r.visibility]),x===`hidden`?null:(0,$.jsxs)(`div`,{ref:l,className:X(`relative flex flex-col shrink-0 overflow-hidden origin-bottom transform-gpu bg-background/95`,`border-t border-border/40`,`transition-[height,opacity,transform,clip-path] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`),style:{height:j,opacity:+!!A,transform:A?`translateY(0) scaleY(1)`:`translateY(${M?14:8}px) scaleY(${M?.96:.985})`,clipPath:A?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,$.jsx)(VN,{height:O,maxHeight:D,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,$.jsx)(wN,{visibility:r.visibility,canCreate:N,hasActive:P,provider:t,providers:w,onCreate:F,onOpenCli:L,onOpenBrowser:R,onPasteScript:z,pasteScriptDisabled:!P||!f.quickScript,onConfigureBrowser:B,onConfigureScript:ee,onKillActive:H,onToggleMaximize:te,onCollapse:ne}),m&&(0,$.jsx)(xN,{x:m.x,y:m.y,label:m.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>V(m.kind),onClose:()=>h(null)}),g&&(0,$.jsx)(SN,{x:g.x,y:g.y,providers:w,onSelect:e=>I(e),onClose:()=>_(null)}),(0,$.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,$.jsx)(HN,{onCreate:F}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(RN,{activeId:r.activeId}),(0,$.jsx)(EN,{sessions:r.sessions,activeId:r.activeId,onActivate:t=>o.setActive(e,t),onRename:(t,n)=>void o.rename(e,t,n),onKill:t=>void o.kill(e,t)})]})})]})}function GN(){let{t:e}=K(`agent`),{current:t,initialized:n}=si(),{active:r}=lM(),{activeProjectId:i,projects:a}=at(),o=wa(i),s=a.find(e=>e.id===i),[c,l]=(0,Q.useState)(window.innerHeight);return(0,Q.useEffect)(()=>{!me()||!t||r?.id!==t.conversationId||xM().setTitle(`${r.title?.trim()||e(`header.untitled`)} — Specrails`).catch(()=>{})},[t?.conversationId,r?.id,r?.title,e]),(0,Q.useEffect)(()=>{let e=()=>l(window.innerHeight);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),!n||!t||r?.id!==t.conversationId?(0,$.jsx)(`div`,{role:`status`,className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:e(`window.loading`)}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-mission-window":!0,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(BM,{})}),Ce&&s&&i&&(0,$.jsx)(WN,{projectId:i,provider:s.provider,providers:rt(s),state:o,viewportHeight:c-36,statusBarHeight:0})]}),(0,$.jsx)(iN,{missionOnly:!0})]})}function KN(){var e=[...arguments];return(0,Q.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var qN=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function JN(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function YN(e){return`nodeType`in e}function XN(e){return e?JN(e)?e:YN(e)?e.ownerDocument?.defaultView??window:window:window}function ZN(e){let{Document:t}=XN(e);return e instanceof t}function QN(e){return!JN(e)&&e instanceof XN(e).HTMLElement}function $N(e){return e instanceof XN(e).SVGElement}function eP(e){return e?JN(e)?e.document:YN(e)?ZN(e)?e:QN(e)||$N(e)?e.ownerDocument:document:document:document}var tP=qN?Q.useLayoutEffect:Q.useEffect;function nP(e){let t=(0,Q.useRef)(e);return tP(()=>{t.current=e}),(0,Q.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function rP(){let e=(0,Q.useRef)(null);return[(0,Q.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,Q.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function iP(e,t){t===void 0&&(t=[e]);let n=(0,Q.useRef)(e);return tP(()=>{n.current!==e&&(n.current=e)},t),n}function aP(e,t){let n=(0,Q.useRef)();return(0,Q.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function oP(e){let t=nP(e),n=(0,Q.useRef)(null);return[n,(0,Q.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function sP(e){let t=(0,Q.useRef)();return(0,Q.useEffect)(()=>{t.current=e},[e]),t.current}var cP={};function lP(e,t){return(0,Q.useMemo)(()=>{if(t)return t;let n=cP[e]==null?0:cP[e]+1;return cP[e]=n,e+`-`+n},[e,t])}function uP(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var dP=uP(1),fP=uP(-1);function pP(e){return`clientX`in e&&`clientY`in e}function mP(e){if(!e)return!1;let{KeyboardEvent:t}=XN(e.target);return t&&e instanceof t}function hP(e){if(!e)return!1;let{TouchEvent:t}=XN(e.target);return t&&e instanceof t}function gP(e){if(hP(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return pP(e)?{x:e.clientX,y:e.clientY}:null}var _P=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[_P.Translate.toString(e),_P.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),vP=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function yP(e){return e.matches(vP)?e:e.querySelector(vP)}var bP={display:`none`};function xP(e){let{id:t,value:n}=e;return Q.createElement(`div`,{id:t,style:bP},n)}function SP(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return Q.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function CP(){let[e,t]=(0,Q.useState)(``);return{announce:(0,Q.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var wP=(0,Q.createContext)(null);function TP(e){let t=(0,Q.useContext)(wP);(0,Q.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function EP(){let[e]=(0,Q.useState)(()=>new Set),t=(0,Q.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,Q.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var DP={draggable:`
46
+ To pick up a draggable item, press the space bar.
47
+ While dragging, use the arrow keys to move the item.
48
+ Press space again to drop the item in its new position, or press escape to cancel.
49
+ `},OP={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function kP(e){let{announcements:t=OP,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=DP}=e,{announce:a,announcement:o}=CP(),s=lP(`DndLiveRegion`),[c,l]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{l(!0)},[]),TP((0,Q.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=Q.createElement(Q.Fragment,null,Q.createElement(xP,{id:r,value:i.draggable}),Q.createElement(SP,{id:s,announcement:o}));return n?(0,xb.createPortal)(u,n):u}var AP;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(AP||={});function jP(){}function MP(e,t){return(0,Q.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function NP(){var e=[...arguments];return(0,Q.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var PP=Object.freeze({x:0,y:0});function FP(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function IP(e,t){let n=gP(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function LP(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function RP(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function zP(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function BP(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function VP(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var HP=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=VP(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=FP(VP(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(LP)},UP=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=zP(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=zP(r),o=i.reduce((e,t,r)=>e+FP(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(LP)};function WP(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var GP=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=WP(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(RP)};function KP(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var qP=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&KP(r,a)){let n=zP(a).reduce((e,t)=>e+FP(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(LP)};function JP(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function YP(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:PP}function XP(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var ZP=XP(1);function QP(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function $P(e,t,n){let r=QP(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var eF={ignoreTransform:!1};function tF(e,t){t===void 0&&(t=eF);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=XN(e).getComputedStyle(e);t&&(n=$P(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function nF(e){return tF(e,{ignoreTransform:!0})}function rF(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function iF(e,t){return t===void 0&&(t=XN(e).getComputedStyle(e)),t.position===`fixed`}function aF(e,t){t===void 0&&(t=XN(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function oF(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(ZN(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!QN(i)||$N(i)||n.includes(i))return n;let a=XN(e).getComputedStyle(i);return i!==e&&aF(i,a)&&n.push(i),iF(i,a)?n:r(i.parentNode)}return e?r(e):n}function sF(e){let[t]=oF(e,1);return t??null}function cF(e){return!qN||!e?null:JN(e)?e:YN(e)?ZN(e)||e===eP(e).scrollingElement?window:QN(e)?e:null:null}function lF(e){return JN(e)?e.scrollX:e.scrollLeft}function uF(e){return JN(e)?e.scrollY:e.scrollTop}function dF(e){return{x:lF(e),y:uF(e)}}var fF;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(fF||={});function pF(e){return!qN||!e?!1:e===document.scrollingElement}function mF(e){let t={x:0,y:0},n=pF(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var hF={x:.2,y:.2};function gF(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=hF);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=mF(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=fF.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=fF.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=fF.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=fF.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function _F(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function vF(e){return e.reduce((e,t)=>dP(e,dF(t)),PP)}function yF(e){return e.reduce((e,t)=>e+lF(t),0)}function bF(e){return e.reduce((e,t)=>e+uF(t),0)}function xF(e,t){if(t===void 0&&(t=tF),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);sF(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var SF=[[`x`,[`left`,`right`],yF],[`y`,[`top`,`bottom`],bF]],CF=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=oF(t),r=vF(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of SF)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},wF=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function TF(e){let{EventTarget:t}=XN(e);return e instanceof t?e:eP(e)}function EF(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var DF;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(DF||={});function OF(e){e.preventDefault()}function kF(e){e.stopPropagation()}var AF;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(AF||={});var jF={start:[AF.Space,AF.Enter],cancel:[AF.Esc],end:[AF.Space,AF.Enter,AF.Tab]},MF=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case AF.Right:return{...n,x:n.x+25};case AF.Left:return{...n,x:n.x-25};case AF.Down:return{...n,y:n.y+25};case AF.Up:return{...n,y:n.y-25}}},NF=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new wF(eP(t)),this.windowListeners=new wF(XN(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(DF.Resize,this.handleCancel),this.windowListeners.add(DF.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(DF.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&xF(n),t(PP)}handleKeyDown(e){if(mP(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=jF,coordinateGetter:a=MF,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:PP;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=fP(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=mF(n),p=_F(n),m={x:Math.min(i===AF.Right?p.right-p.width/2:p.right,Math.max(i===AF.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===AF.Down?p.bottom-p.height/2:p.bottom,Math.max(i===AF.Down?p.top:p.top+p.height/2,u.y))},h=i===AF.Right&&!s||i===AF.Left&&!c,g=i===AF.Down&&!l||i===AF.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===AF.Right&&e<=d.x||i===AF.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===AF.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===AF.Down&&e<=d.y||i===AF.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===AF.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,dP(fP(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};NF.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=jF,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function PF(e){return!!(e&&`distance`in e)}function FF(e){return!!(e&&`delay`in e)}var IF=class{constructor(e,t,n){n===void 0&&(n=TF(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=eP(i),this.documentListeners=new wF(this.document),this.listeners=new wF(n),this.windowListeners=new wF(XN(i)),this.initialCoordinates=gP(r)??PP,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(DF.Resize,this.handleCancel),this.windowListeners.add(DF.DragStart,OF),this.windowListeners.add(DF.VisibilityChange,this.handleCancel),this.windowListeners.add(DF.ContextMenu,OF),this.documentListeners.add(DF.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(FF(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(PF(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(DF.Click,kF,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(DF.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=gP(e)??PP,s=fP(n,o);if(!t&&a){if(PF(a)){if(a.tolerance!=null&&EF(s,a.tolerance))return this.handleCancel();if(EF(s,a.distance))return this.handleStart()}if(FF(a)&&EF(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===AF.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},LF={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},RF=class extends IF{constructor(e){let{event:t}=e,n=eP(t.target);super(e,LF,n)}};RF.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var zF={move:{name:`mousemove`},end:{name:`mouseup`}},BF;(function(e){e[e.RightClick=2]=`RightClick`})(BF||={});var VF=class extends IF{constructor(e){super(e,zF,eP(e.event.target))}};VF.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===BF.RightClick?!1:(r?.({event:n}),!0)}}];var HF={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},UF=class extends IF{constructor(e){super(e,HF)}static setup(){return window.addEventListener(HF.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(HF.move.name,e)};function e(){}}};UF.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var WF;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(WF||={});var GF;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(GF||={});function KF(e){let{acceleration:t,activator:n=WF.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=GF.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=JF({delta:d,disabled:!a}),[m,h]=rP(),g=(0,Q.useRef)({x:0,y:0}),_=(0,Q.useRef)({x:0,y:0}),v=(0,Q.useMemo)(()=>{switch(n){case WF.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case WF.DraggableRect:return i}},[n,i,c]),y=(0,Q.useRef)(null),b=(0,Q.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,Q.useMemo)(()=>s===GF.TreeOrder?[...l].reverse():l,[s,l]);(0,Q.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=gF(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var qF={x:{[fF.Backward]:!1,[fF.Forward]:!1},y:{[fF.Backward]:!1,[fF.Forward]:!1}};function JF(e){let{delta:t,disabled:n}=e,r=sP(t);return aP(e=>{if(n||!r||!e)return qF;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[fF.Backward]:e.x[fF.Backward]||i.x===-1,[fF.Forward]:e.x[fF.Forward]||i.x===1},y:{[fF.Backward]:e.y[fF.Backward]||i.y===-1,[fF.Forward]:e.y[fF.Forward]||i.y===1}}},[n,t,r])}function YF(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return aP(e=>t==null?null:r??e??null,[r,t])}function XF(e,t){return(0,Q.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var ZF;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(ZF||={});var QF;(function(e){e.Optimized=`optimized`})(QF||={});var $F=new Map;function eI(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Q.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Q.useRef)(e),d=g(),f=iP(d),p=(0,Q.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,Q.useRef)(null),h=aP(t=>{if(d&&!n)return $F;if(!t||t===$F||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new CF(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,Q.useEffect)(()=>{u.current=e},[e]),(0,Q.useEffect)(()=>{d||p()},[n,d]),(0,Q.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Q.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case ZF.Always:return!1;case ZF.BeforeDragging:return n;default:return!n}}}function tI(e,t){return aP(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function nI(e,t){return tI(e,t)}function rI(e){let{callback:t,disabled:n}=e,r=nP(t),i=(0,Q.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Q.useEffect)(()=>()=>i?.disconnect(),[i]),i}function iI(e){let{callback:t,disabled:n}=e,r=nP(t),i=(0,Q.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Q.useEffect)(()=>()=>i?.disconnect(),[i]),i}function aI(e){return new CF(tF(e),e)}function oI(e,t,n){t===void 0&&(t=aI);let[r,i]=(0,Q.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=rI({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=iI({callback:a});return tP(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function sI(e){return YP(e,tI(e))}var cI=[];function lI(e){let t=(0,Q.useRef)(e),n=aP(n=>e?n&&n!==cI&&e&&t.current&&e.parentNode===t.current.parentNode?n:oF(e):cI,[e]);return(0,Q.useEffect)(()=>{t.current=e},[e]),n}function uI(e){let[t,n]=(0,Q.useState)(null),r=(0,Q.useRef)(e),i=(0,Q.useCallback)(e=>{let t=cF(e.target);t&&n(e=>e?(e.set(t,dF(t)),new Map(e)):null)},[]);return(0,Q.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=cF(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,dF(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{cF(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Q.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>dP(e,t),PP):vF(e):PP,[e,t])}function dI(e,t){t===void 0&&(t=[]);let n=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{n.current=null},t),(0,Q.useEffect)(()=>{let t=e!==PP;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?fP(e,n.current):PP}function fI(e){(0,Q.useEffect)(()=>{if(!qN)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function pI(e,t){return(0,Q.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function mI(e){return(0,Q.useMemo)(()=>e?rF(e):null,[e])}var hI=[];function gI(e,t){t===void 0&&(t=tF);let[n]=e,r=mI(n?XN(n):null),[i,a]=(0,Q.useState)(hI);function o(){a(()=>e.length?e.map(e=>pF(e)?r:new CF(t(e),e)):hI)}let s=iI({callback:o});return tP(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function _I(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return QN(t)?t:e}function vI(e){let{measure:t}=e,[n,r]=(0,Q.useState)(null),i=iI({callback:(0,Q.useCallback)(e=>{for(let{target:n}of e)if(QN(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=oP((0,Q.useCallback)(e=>{let n=_I(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Q.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var yI=[{sensor:RF,options:{}},{sensor:NF,options:{}}],bI={current:{}},xI={draggable:{measure:nF},droppable:{measure:nF,strategy:ZF.WhileDragging,frequency:QF.Optimized},dragOverlay:{measure:tF}},SI=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},CI={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new SI,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jP},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:xI,measureDroppableContainers:jP,windowRect:null,measuringScheduled:!1},wI={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:jP,draggableNodes:new Map,over:null,measureDroppableContainers:jP},TI=(0,Q.createContext)(wI),EI=(0,Q.createContext)(CI);function DI(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new SI}}}function OI(e,t){switch(t.type){case AP.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case AP.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case AP.DragEnd:case AP.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case AP.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new SI(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case AP.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new SI(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case AP.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new SI(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function kI(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Q.useContext)(TI),a=sP(r),o=sP(n?.id);return(0,Q.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!mP(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=yP(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function AI(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function jI(e){return(0,Q.useMemo)(()=>({draggable:{...xI.draggable,...e?.draggable},droppable:{...xI.droppable,...e?.droppable},dragOverlay:{...xI.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function MI(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Q.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;tP(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=YP(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=sF(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var NI=(0,Q.createContext)({...PP,scaleX:1,scaleY:1}),PI;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(PI||={});var FI=(0,Q.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=yI,collisionDetection:o=GP,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Q.useReducer)(OI,void 0,DI),[f,p]=EP(),[m,h]=(0,Q.useState)(PI.Uninitialized),g=m===PI.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Q.useRef)({initial:null,translated:null}),C=(0,Q.useMemo)(()=>_==null?null:{id:_,data:x?.data??bI,rect:S},[_,x]),w=(0,Q.useRef)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),k=iP(l,Object.values(l)),A=lP(`DndDescribedBy`,t),j=(0,Q.useMemo)(()=>b.getEnabled(),[b]),M=jI(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=eI(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=YF(v,_),L=(0,Q.useMemo)(()=>D?gP(D):null,[D]),R=we(),z=nI(I,M.draggable.measure);MI({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=oI(I,M.draggable.measure,z),ee=oI(I?I.parentElement:null),V=(0,Q.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),H=b.getNodeFor(V.current.over?.id),te=vI({measure:M.dragOverlay.measure}),ne=te.nodeRef.current??I,re=g?te.rect??B:null,ie=!!(te.nodeRef.current&&te.rect),ae=sI(ie?null:B),oe=mI(ne?XN(ne):null),se=lI(g?H??I:null),ce=gI(se),le=AI(c,{transform:{x:y.x-ae.x,y:y.y-ae.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:B,containerNodeRect:ee,draggingNodeRect:re,over:V.current.over,overlayNodeRect:te.rect,scrollableAncestors:se,scrollableAncestorRects:ce,windowRect:oe}),ue=L?dP(L,y):null,de=uI(se),fe=dI(de),pe=dI(de,[B]),me=dP(le,fe),he=re?ZP(re,le):null,ge=C&&he?o({active:C,collisionRect:he,droppableRects:N,droppableContainers:j,pointerCoordinates:ue}):null,_e=BP(ge,`id`),[ve,ye]=(0,Q.useState)(null),U=JP(ie?le:dP(le,pe),ve?.rect??null,B),be=(0,Q.useRef)(null),xe=(0,Q.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:V,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,xb.unstable_batchedUpdates)(()=>{r?.(i),h(PI.Initializing),d({type:AP.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(be.current),O(a)})},onMove(e){d({type:AP.DragMove,coordinates:e})},onEnd:s(AP.DragEnd),onCancel:s(AP.DragCancel)});be.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=V.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===AP.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=AP.DragCancel)}w.current=null,(0,xb.unstable_batchedUpdates)(()=>{d({type:e}),h(PI.Uninitialized),ye(null),E(null),O(null),be.current=null;let t=e===AP.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Se=XF(a,(0,Q.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,xe(n,t))},[v,xe]));fI(a),tP(()=>{B&&m===PI.Initializing&&h(PI.Initialized)},[B,m]),(0,Q.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=V.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:me.x,y:me.y},over:i};(0,xb.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[me.x,me.y]),(0,Q.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=V.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(_e),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,xb.unstable_batchedUpdates)(()=>{ye(s),a?.(c),f({type:`onDragOver`,event:c})})},[_e]),tP(()=>{V.current={activatorEvent:D,active:C,activeNode:I,collisionRect:he,collisions:ge,droppableRects:N,draggableNodes:v,draggingNode:ne,draggingNodeRect:re,droppableContainers:b,over:ve,scrollableAncestors:se,scrollAdjustedTranslate:me},S.current={initial:re,translated:he}},[C,I,ge,he,v,ne,re,N,b,ve,se,me]),KF({...R,delta:y,draggingRect:he,pointerCoordinates:ue,scrollableAncestors:se,scrollableAncestorRects:ce});let Ce=(0,Q.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:ge,containerNodeRect:ee,dragOverlay:te,draggableNodes:v,droppableContainers:b,droppableRects:N,over:ve,measureDroppableContainers:P,scrollableAncestors:se,scrollableAncestorRects:ce,measuringConfiguration:M,measuringScheduled:F,windowRect:oe}),[C,I,B,D,ge,ee,te,v,b,N,ve,P,se,ce,M,F,oe]),W=(0,Q.useMemo)(()=>({activatorEvent:D,activators:Se,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:ve,measureDroppableContainers:P}),[D,Se,C,B,d,A,v,ve,P]);return Q.createElement(wP.Provider,{value:p},Q.createElement(TI.Provider,{value:W},Q.createElement(EI.Provider,{value:Ce},Q.createElement(NI.Provider,{value:U},i)),Q.createElement(kI,{disabled:n?.restoreFocus===!1})),Q.createElement(kP,{...n,hiddenTextDescribedById:A}));function we(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),II=(0,Q.createContext)(null),LI=`button`,RI=`Draggable`;function zI(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=lP(RI),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Q.useContext)(TI),{role:p=LI,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Q.useContext)(g?NI:II),[v,y]=oP(),[b,x]=oP(),S=pI(o,t),C=iP(n);return tP(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,Q.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===LI?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function BI(){return(0,Q.useContext)(EI)}var VI=`Droppable`,HI={timeout:25};function UI(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=lP(VI),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Q.useContext)(TI),u=(0,Q.useRef)({disabled:n}),d=(0,Q.useRef)(!1),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...HI,...i},_=iP(h??r),v=iI({callback:(0,Q.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=oP((0,Q.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=iP(t);return(0,Q.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Q.useEffect)(()=>(s({type:AP.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:AP.UnregisterDroppable,key:a,id:r})),[r]),(0,Q.useEffect)(()=>{n!==u.current.disabled&&(s({type:AP.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function WI(e){let{animation:t,children:n}=e,[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(null),s=sP(n);return!n&&!r&&s&&i(s),tP(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),Q.createElement(Q.Fragment,null,n,r?(0,Q.cloneElement)(r,{ref:o}):null)}var GI={x:0,y:0,scaleX:1,scaleY:1};function KI(e){let{children:t}=e;return Q.createElement(TI.Provider,{value:wI},Q.createElement(NI.Provider,{value:GI},t))}var qI={position:`fixed`,touchAction:`none`},JI=e=>mP(e)?`transform 250ms ease`:void 0,YI=(0,Q.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=JI}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...qI,width:s.width,height:s.height,top:s.top,left:s.left,transform:_P.Transform.toString(d),transformOrigin:i&&r?IP(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Q.createElement(n,{className:o,style:f,ref:t},a)}),XI={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:_P.Transform.toString(t)},{transform:_P.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function ZI(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return nP((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=_I(a);if(!c)return;let{transform:l}=XN(a).getComputedStyle(a),u=QP(l);if(!u)return;let d=typeof t==`function`?t:QI(t);return xF(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function QI(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...XI,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var $I=0;function eL(e){return(0,Q.useMemo)(()=>{if(e!=null)return $I++,$I},[e])}var tL=Q.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=BI(),S=(0,Q.useContext)(NI),C=eL(d?.id),w=AI(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=tI(f),E=ZI({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Q.createElement(KI,null,Q.createElement(WI,{animation:E},d&&C?Q.createElement(YI,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function nL(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function rL(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function iL(e){return e!==null&&e>=0}function aL(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function oL(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var sL=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=nL(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},cL={scaleX:1,scaleY:1},lL=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...cL}:null}let s=uL(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...cL}:r<t&&r>=a?{x:0,y:o.height+s,...cL}:{x:0,y:0,...cL}};function uL(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var dL=`Sortable`,fL=Q.createContext({activeIndex:-1,containerId:dL,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:sL,disabled:{draggable:!1,droppable:!1}});function pL(e){let{children:t,id:n,items:r,strategy:i=sL,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=BI(),d=lP(dL,n),f=s.rect!==null,p=(0,Q.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,Q.useRef)(p),v=!aL(p,_.current),y=g!==-1&&h===-1||v,b=oL(a);tP(()=>{v&&m&&u(p)},[v,p,m,u]),(0,Q.useEffect)(()=>{_.current=p},[p]);let x=(0,Q.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:rL(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return Q.createElement(fL.Provider,{value:x},t)}var mL=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return nL(n,r,i).indexOf(t)},hL=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},gL={duration:200,easing:`ease`},_L=`transform`,vL=_P.Transition.toString({property:_L,duration:0,easing:`linear`}),yL={roleDescription:`sortable`};function bL(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(n);return tP(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=tF(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,Q.useEffect)(()=>{a&&o(null)},[a]),a}function xL(e){let{animateLayoutChanges:t=hL,attributes:n,disabled:r,data:i,getNewIndex:a=mL,id:o,strategy:s,resizeObserverConfig:c,transition:l=gL}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,Q.useContext)(fL),y=SL(r,p),b=u.indexOf(o),x=(0,Q.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,Q.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=UI({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:A,setNodeRef:j,listeners:M,isDragging:N,over:P,setActivatorNodeRef:F,transform:I}=zI({id:o,data:x,attributes:{...yL,...n},disabled:y.draggable}),L=KN(E,j),R=!!D,z=R&&!m&&iL(f)&&iL(g),B=!_&&N,ee=z?(B&&z?I:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,V=iL(f)&&iL(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,H=D?.id,te=(0,Q.useRef)({activeId:H,items:u,newIndex:V,containerId:d}),ne=u!==te.current.items,re=t({active:D,containerId:d,isDragging:N,isSorting:R,id:o,index:b,items:u,newIndex:te.current.newIndex,previousItems:te.current.items,previousContainerId:te.current.containerId,transition:l,wasDragging:te.current.activeId!=null}),ie=bL({disabled:!re,index:b,node:w,rect:C});return(0,Q.useEffect)(()=>{R&&te.current.newIndex!==V&&(te.current.newIndex=V),d!==te.current.containerId&&(te.current.containerId=d),u!==te.current.items&&(te.current.items=u)},[R,V,d,u]),(0,Q.useEffect)(()=>{if(H===te.current.activeId)return;if(H!=null&&te.current.activeId==null){te.current.activeId=H;return}let e=setTimeout(()=>{te.current.activeId=H},50);return()=>clearTimeout(e)},[H]),{active:D,activeIndex:f,attributes:A,data:x,rect:C,index:b,newIndex:V,items:u,isOver:T,isSorting:R,isDragging:N,listeners:M,node:w,overIndex:g,over:P,setNodeRef:L,setActivatorNodeRef:F,setDroppableNodeRef:E,setDraggableNodeRef:j,transform:ie??ee,transition:ae()};function ae(){if(ie||ne&&te.current.newIndex===b)return vL;if(!(B&&!mP(O)||!l)&&(R||re))return _P.Transition.toString({...l,property:_L})}}function SL(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function CL(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var wL=[AF.Down,AF.Right,AF.Up,AF.Left],TL=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(wL.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case AF.Down:r.top<a.top&&t.push(n);break;case AF.Up:r.top>a.top&&t.push(n);break;case AF.Left:r.left>a.left&&t.push(n);break;case AF.Right:r.left<a.left&&t.push(n);break}});let c=UP({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=BP(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=oF(c).some((e,t)=>s[t]!==e),i=EL(e,t),a=DL(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:fP(u,l)}}}};function EL(e,t){return!CL(e)||!CL(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function DL(e,t){return!CL(e)||!CL(t)||!EL(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var OL=Qn(`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground`,outline:`text-foreground`,success:`border-transparent bg-emerald-500/20 aurora-light:bg-accent-success/10 text-emerald-400 aurora-light:text-accent-success border-emerald-500/30 aurora-light:border-accent-success/30`,warning:`border-transparent bg-amber-500/20 aurora-light:bg-accent-warning/10 text-amber-400 aurora-light:text-accent-warning border-amber-500/30 aurora-light:border-accent-warning/30`,running:`border-transparent bg-blue-500/20 aurora-light:bg-accent-info/10 text-blue-400 aurora-light:text-accent-info border-blue-500/30 aurora-light:border-accent-info/30`,queued:`border-transparent bg-slate-500/20 aurora-light:bg-muted text-slate-400 aurora-light:text-muted-foreground border-slate-500/30 aurora-light:border-border`,failed:`border-transparent bg-red-500/20 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,canceled:`border-transparent bg-slate-600/20 aurora-light:bg-muted text-slate-500 aurora-light:text-muted-foreground border-slate-600/30 aurora-light:border-border`}},defaultVariants:{variant:`default`}});function kL({className:e,variant:t,...n}){return(0,$.jsx)(`div`,{className:X(OL({variant:t}),e),...n})}var AL={critical:`destructive`,high:`default`,medium:`warning`,low:`outline`},jL=700;function ML({ticket:e,onClick:t,dragDisabled:n,allowOnReviewDrag:r=!1,contractRefining:i=!1,epicChildrenCount:a,parentEpicTitle:o,onOpenParentEpic:s,jiggleMode:c=!1,onLongPress:l,onDelete:u}){let{t:d}=K(`specs`),f=n||c||e.status===`on_review`&&!r,{attributes:p,listeners:m,setNodeRef:h,transform:g,transition:_,isDragging:v}=xL({id:e.id,disabled:f}),y=(0,Q.useRef)(null),b=(0,Q.useRef)(!1),x=(0,Q.useCallback)(()=>{y.current&&=(clearTimeout(y.current),null)},[]),S=(0,Q.useCallback)(()=>{l&&(b.current=!1,y.current=setTimeout(()=>{b.current=!0,l(),y.current=null},jL))},[l]),C=(0,Q.useCallback)(e=>{e.target.closest(`button`)||S()},[S]),w=(0,Q.useCallback)(()=>{x()},[x]),T=(0,Q.useCallback)(n=>{if(b.current){n.stopPropagation(),b.current=!1;return}if(c){n.stopPropagation();return}t(e)},[c,t,e]),E=(0,Q.useCallback)(t=>{t.stopPropagation(),u?.(e)},[u,e]),D=c?-(e.id*73%400):void 0,O={transform:_P.Transform.toString(g),transition:_,opacity:v?.4:1,...D===void 0?{}:{animationDelay:`${D}ms`}},k=e.status===`draft`,A=e.status===`on_review`,j=`relative flex items-center gap-2 px-3 py-2.5 rounded-lg border transition-colors group touch-none ${c||A&&!r?``:`cursor-grab active:cursor-grabbing`} ${k?`border-dashed border-accent-secondary/50 bg-accent-secondary/10 hover:bg-accent-secondary/15 hover:border-accent-secondary/70`:A?`border-accent-warning/40 bg-accent-warning/5 hover:bg-accent-warning/10 hover:border-accent-warning/60`:i?`border-accent-highlight/70 bg-card/70 shadow-lg shadow-accent-highlight/20 animate-pulse`:`border-border/40 bg-card/60 hover:bg-card/80 hover:border-border/60`} ${c?`animate-jiggle`:``}`;return(0,$.jsxs)(`div`,{ref:h,"data-ticket-id":e.id,"data-draft":k||void 0,"data-on-review":A||void 0,"data-contract-refining":i||void 0,"data-jiggle":c||void 0,style:O,...f?{}:{...p,...m},className:j,onClick:T,onPointerDownCapture:C,onPointerUp:w,onPointerLeave:w,onPointerCancel:w,role:`button`,tabIndex:0,onKeyDown:n=>n.key===`Enter`&&!c&&t(e),children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-foreground shrink-0`,children:[`#`,e.id]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm truncate text-foreground`,children:e.title}),e.is_epic?(0,$.jsx)(kL,{variant:`outline`,className:`text-[9px] shrink-0 border-accent-highlight/60 text-accent-highlight bg-accent-highlight/10`,"data-testid":`epic-badge-${e.id}`,children:d(`badges.epicWithCount`,{count:a??0})}):null,o&&e.parent_epic_id!=null?(0,$.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s?.(e.parent_epic_id)},onPointerDown:e=>e.stopPropagation(),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.stopPropagation(),t.preventDefault(),s?.(e.parent_epic_id))},className:`inline-flex items-center rounded-md border border-accent-secondary/40 text-accent-secondary bg-accent-secondary/5 hover:bg-accent-secondary/15 hover:border-accent-secondary/60 px-1.5 py-0.5 text-[9px] font-medium shrink-0 max-w-[12rem] truncate transition-colors cursor-pointer`,title:d(`badges.openParentEpicTitle`,{id:e.parent_epic_id,title:o}),"data-testid":`epic-child-pill-${e.id}`,children:[`↑ #`,e.parent_epic_id,` `,o]}):null,e.needs_review?(0,$.jsxs)(kL,{variant:`outline`,className:`text-[9px] shrink-0 gap-1 border-accent-warning/60 text-accent-warning bg-accent-warning/10`,title:d(`badges.needsReviewTitle`),"data-testid":`needs-review-badge-${e.id}`,children:[(0,$.jsx)(fn,{className:`w-2.5 h-2.5`,"aria-hidden":!0}),d(`badges.review`)]}):null,e.source===`free-prompt`?(0,$.jsx)(kL,{variant:`outline`,className:`text-[9px] shrink-0 uppercase border-accent-info/50 text-accent-info`,title:d(`badges.rawTitle`),"data-testid":`raw-badge-${e.id}`,children:d(`badges.raw`)}):null,e.jira_key?(0,$.jsx)(kL,{variant:`outline`,className:`text-[9px] shrink-0 font-mono border-accent-info/50 text-accent-info`,title:e.jira_key,"data-testid":`jira-badge-${e.id}`,children:e.jira_key}):null,k?(0,$.jsx)(kL,{variant:`outline`,className:`text-[9px] shrink-0 border-accent-secondary/60 text-accent-secondary`,children:d(`common:status.draft`)}):A?(0,$.jsx)(kL,{variant:`outline`,className:`text-[9px] shrink-0 border-accent-warning/60 text-accent-warning bg-accent-warning/10`,title:d(`status.onReviewHint`),"data-testid":`on-review-badge-${e.id}`,children:d(`common:status.onReview`)}):i?(0,$.jsx)(kL,{variant:`outline`,className:`text-[9px] shrink-0 border-accent-highlight/70 text-accent-highlight bg-accent-highlight/10`,children:d(`badges.contract`)}):e.priority?(0,$.jsx)(kL,{variant:AL[e.priority],className:`text-[9px] shrink-0`,children:d(`priority.${e.priority}`)}):null,c&&u&&(0,$.jsx)(`button`,{type:`button`,onClick:E,onPointerDown:e=>e.stopPropagation(),className:`absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-red-500 text-white flex items-center justify-center shadow-md hover:bg-red-600 transition-colors z-10`,title:d(`card.deleteSpec`,{id:e.id}),"aria-label":d(`card.deleteSpec`,{id:e.id}),"data-testid":`spec-card-delete-${e.id}`,children:(0,$.jsx)(dn,{className:`w-2.5 h-2.5`})})]})}var NL={critical:`destructive`,high:`default`,medium:`warning`,low:`outline`},PL=700;function FL({ticket:e,rails:t,onClick:n,onMoveToRail:r,epicChildrenCount:i,parentEpicTitle:a,onOpenParentEpic:o,contractRefining:s=!1,allowOnReviewRailMove:c=!1,jiggleMode:l=!1,onLongPress:u,onDelete:d}){let{t:f}=K(`specs`),p=l||e.status===`on_review`&&!c,{attributes:m,listeners:h,setNodeRef:g,transform:_,transition:v,isDragging:y}=xL({id:e.id,disabled:p}),[b,S]=(0,Q.useState)(null),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(!1),O=(0,Q.useCallback)(()=>{E.current&&=(clearTimeout(E.current),null)},[]),k=(0,Q.useCallback)(()=>{u&&(D.current=!1,E.current=setTimeout(()=>{D.current=!0,u(),E.current=null},PL))},[u]),A=(0,Q.useCallback)(e=>{e.target.closest(`button`)||k()},[k]),j=(0,Q.useCallback)(()=>{O()},[O]),M=(0,Q.useCallback)(t=>{if(D.current){t.stopPropagation(),D.current=!1;return}l||n(e)},[l,n,e]),N=(0,Q.useCallback)(e=>{e.stopPropagation(),T.current&&S(T.current.getBoundingClientRect())},[]),P=e.status===`draft`,F=e.status===`on_review`,I=e.is_epic===!0,R=e.parent_epic_id!=null,z=(e.prerequisites?.length??0)>0,ee=e.short_summary&&e.short_summary.trim().length>0?e.short_summary:null,{triggerResume:V}=Kt(),{activeProjectId:H}=at(),te=w(e)&&!!H,ne=(0,Q.useCallback)(t=>{if(t.stopPropagation(),!H)return;let{body:n,criteria:r}=C(e.description??``);V({kind:`explore-spec`,projectId:H,label:e.title||f(`card.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:L(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:e.title,description:n,labels:e.labels??[],priority:e.priority??`medium`,acceptanceCriteria:r,status:e.status}}})},[H,e,V,f]),re=l?-(e.id*73%400):void 0,ie={transform:_P.Translate.toString(_),transition:v,opacity:y?.4:void 0,...re===void 0?{}:{animationDelay:`${re}ms`}},ae=P?`bg-accent-secondary/10 border-accent-secondary/40`:F?`bg-accent-warning/5 border-accent-warning/40`:s?`bg-card/70 border-accent-highlight/70 shadow-lg shadow-accent-highlight/20 animate-pulse`:I?`bg-card/80 border-accent-highlight/40`:`bg-card/80 border-border/40`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:g,...m,...h,style:ie,onClick:M,onPointerDownCapture:A,onPointerUp:j,onPointerLeave:j,onPointerCancel:j,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M(e))},"data-ticket-id":e.id,"data-tier":`postit`,className:`group relative flex flex-col gap-2 rounded-xl border ${ae} backdrop-blur p-3 cursor-pointer transition-[transform,box-shadow,border-color] duration-150 ease-out hover:border-accent-info/40 hover:shadow-md hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/60 min-h-[180px] ${l?`animate-jiggle`:``} ${s?`ring-1 ring-accent-info/30`:``}`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/60 shrink-0`,children:[`#`,e.id]}),R&&a&&e.parent_epic_id!=null&&(0,$.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o?.(e.parent_epic_id)},onPointerDown:e=>e.stopPropagation(),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.stopPropagation(),t.preventDefault(),o?.(e.parent_epic_id))},disabled:!o,title:f(`badges.openParentEpicTitle`,{id:e.parent_epic_id,title:a}),"data-testid":`postit-epic-child-pill-${e.id}`,className:`inline-flex items-center gap-1 rounded-md border border-accent-secondary/40 text-accent-secondary bg-accent-secondary/5 hover:bg-accent-secondary/15 hover:border-accent-secondary/60 disabled:hover:bg-accent-secondary/5 disabled:hover:border-accent-secondary/40 disabled:cursor-default px-1.5 py-0.5 text-[10px] font-medium max-w-[160px] truncate transition-colors`,children:[(0,$.jsx)(qo,{className:`w-2.5 h-2.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`↑ #`,e.parent_epic_id,` `,a]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[e.needs_review&&(0,$.jsxs)(kL,{variant:`outline`,className:`h-4 gap-1 px-1.5 text-[9px] uppercase border-accent-warning/60 text-accent-warning bg-accent-warning/10`,title:f(`badges.needsReviewTitle`),"data-testid":`needs-review-badge-${e.id}`,children:[(0,$.jsx)(fn,{className:`w-2.5 h-2.5`,"aria-hidden":!0}),f(`badges.review`)]}),I&&(0,$.jsxs)(kL,{variant:`outline`,className:`h-4 gap-1 px-1.5 text-[9px] border-accent-highlight/40 text-accent-highlight`,children:[(0,$.jsx)(qo,{className:`w-2.5 h-2.5`,"aria-hidden":!0}),i?f(`badges.epicWithCount`,{count:i}):f(`badges.epic`)]}),e.source===`free-prompt`&&(0,$.jsx)(kL,{variant:`outline`,className:`h-4 px-1.5 text-[9px] uppercase border-accent-info/50 text-accent-info`,title:f(`badges.rawTitle`),"data-testid":`raw-badge-${e.id}`,children:f(`badges.raw`)}),e.jira_key&&(0,$.jsx)(kL,{variant:`outline`,className:`h-4 px-1.5 text-[9px] font-mono border-accent-info/50 text-accent-info`,title:e.jira_key,"data-testid":`jira-badge-${e.id}`,children:e.jira_key}),e.priority&&!P&&!F&&(0,$.jsx)(kL,{variant:NL[e.priority],className:`h-4 px-1.5 text-[9px] uppercase`,children:f(`priority.${e.priority}`)}),P&&(0,$.jsx)(kL,{variant:`outline`,className:`h-4 px-1.5 text-[9px] uppercase border-accent-secondary/50 text-accent-secondary`,children:f(`common:status.draft`)}),F&&(0,$.jsx)(kL,{variant:`outline`,className:`h-4 px-1.5 text-[9px] uppercase border-accent-warning/60 text-accent-warning bg-accent-warning/10`,title:f(`status.onReviewHint`),"data-testid":`on-review-badge-postit-${e.id}`,children:f(`common:status.onReview`)})]})]}),(0,$.jsx)(`h3`,{className:`text-sm font-medium leading-snug line-clamp-2 text-foreground`,children:e.title}),ee&&(0,$.jsx)(`p`,{"data-testid":`postit-short-summary`,className:`text-xs text-muted-foreground/80 leading-relaxed line-clamp-3 italic`,children:ee}),z&&(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground/70`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(ws,{className:`w-2.5 h-2.5`,"aria-hidden":!0}),f(`card.dependsOn`,{count:e.prerequisites.length})]})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-1 border-t border-border/30`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[te&&(0,$.jsxs)(`button`,{type:`button`,onClick:ne,onPointerDown:e=>e.stopPropagation(),"data-testid":`postit-continue-editing`,title:f(`card.continueEditingTitle`),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-medium text-accent-primary/90 hover:bg-accent-primary/10 hover:text-accent-primary transition-colors`,children:[(0,$.jsx)(x,{className:`w-2.5 h-2.5`,"aria-hidden":!0}),f(`card.continueEditing`)]}),(!F||c)&&(0,$.jsxs)(`button`,{ref:T,type:`button`,onClick:N,"data-testid":`move-to-rail-button`,className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-medium text-accent-info/90 hover:bg-accent-info/10 hover:text-accent-info transition-colors`,children:[f(`card.moveToRail`),(0,$.jsx)(B,{className:`w-2.5 h-2.5`,"aria-hidden":!0})]})]}),l&&d&&(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d(e)},className:`p-1 rounded-md text-destructive/70 hover:bg-destructive/10 hover:text-destructive transition-colors`,"aria-label":f(`card.deleteTicket`,{id:e.id}),children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]})]}),b&&(0,$.jsx)(ue,{rails:t,anchorRect:b,onMoveToRail:t=>r(e.id,t),onClose:()=>S(null)})]})}var IL=(0,Q.createContext)({discardStatus:null});function LL({children:e}){let t=fe(),n=t.connected?t.discardStatus:null,r=(0,Q.useMemo)(()=>({discardStatus:n}),[n]);return(0,$.jsx)(IL.Provider,{value:r,children:e})}function RL(){return(0,Q.useContext)(IL)}var zL=[{value:`todo`,labelKey:`ticketStatus.todo`,icon:(0,$.jsx)(O,{className:`w-3.5 h-3.5 text-slate-400 aurora-light:text-muted-foreground`}),className:`text-slate-400 aurora-light:text-muted-foreground`},{value:`done`,labelKey:`ticketStatus.done`,icon:(0,$.jsx)(Mo,{className:`w-3.5 h-3.5 text-emerald-400 aurora-light:text-accent-success`}),className:`text-emerald-400 aurora-light:text-accent-success`}],BL=[{value:`critical`,labelKey:`priority.critical`,icon:(0,$.jsx)(jo,{className:`w-3.5 h-3.5 text-red-400 aurora-light:text-destructive`}),className:`text-red-400 aurora-light:text-destructive`},{value:`high`,labelKey:`priority.high`,icon:(0,$.jsx)(Ut,{className:`w-3.5 h-3.5 text-orange-400 aurora-light:text-accent-warning`}),className:`text-orange-400 aurora-light:text-accent-warning`},{value:`medium`,labelKey:`priority.medium`,icon:(0,$.jsx)(B,{className:`w-3.5 h-3.5 text-yellow-400 aurora-light:text-accent-warning`}),className:`text-yellow-400 aurora-light:text-accent-warning`},{value:`low`,labelKey:`priority.low`,icon:(0,$.jsx)(_o,{className:`w-3.5 h-3.5 text-slate-400 aurora-light:text-muted-foreground`}),className:`text-slate-400 aurora-light:text-muted-foreground`}];function VL({position:e,ticket:t,activeSubmenu:n,onSetSubmenu:r,onStatusChange:i,onPriorityChange:a,onDeleteRequest:o,discardLabel:s,onDiscardRequest:c,onClose:l}){let{t:u}=K(`tickets`),d=(0,Q.useRef)(null),[f,p]=(0,Q.useState)(e);(0,Q.useEffect)(()=>{if(!d.current)return;let t=d.current.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;p({x:t.right>n?Math.max(0,e.x-t.width):e.x,y:t.bottom>r?Math.max(0,e.y-t.height):e.y})},[e]);let m=(0,Q.useCallback)(e=>{e(),l()},[l]);return(0,$.jsxs)(`div`,{ref:d,role:`menu`,"aria-label":u(`contextMenu.ariaLabel`),style:{left:f.x,top:f.y},className:`fixed z-[200] min-w-[180px] rounded-lg border border-border/50 bg-popover shadow-xl text-xs py-1`,children:[s&&c?(0,$.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{c(),l()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-accent-info hover:bg-accent-info/10 transition-colors`,"data-testid":`jira-move-to-menuitem`,children:[(0,$.jsx)(B,{className:`w-3.5 h-3.5 shrink-0`}),s]}):(0,$.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{o(),l()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-red-400 aurora-light:text-destructive hover:bg-red-500/10 transition-colors`,children:[(0,$.jsx)(dn,{className:`w-3.5 h-3.5 shrink-0`}),u(`contextMenu.deleteTicket`)]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/40`,role:`separator`}),(0,$.jsxs)(`div`,{role:`menuitem`,tabIndex:-1,"aria-haspopup":`menu`,"aria-expanded":n===`status`,className:X(`relative flex w-full items-center justify-between gap-2 px-3 py-2 cursor-pointer select-none text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors`,n===`status`&&`bg-accent/50 text-foreground`),onMouseEnter:()=>r(`status`),onClick:e=>{e.stopPropagation(),r(n===`status`?null:`status`)},children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(O,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}),u(`contextMenu.changeStatus`)]}),(0,$.jsx)(Qt,{className:`w-3 h-3 text-muted-foreground`}),n===`status`&&(0,$.jsx)(`div`,{role:`menu`,"aria-label":u(`contextMenu.statusOptions`),className:`absolute left-full top-0 ml-1 min-w-[150px] rounded-lg border border-border/50 bg-popover shadow-xl py-1 z-[201]`,children:zL.map(e=>(0,$.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>m(()=>i(e.value)),className:X(`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors`,e.className,t.status===e.value&&`bg-accent/30 font-semibold`),children:[e.icon,u(e.labelKey)]},e.value))})]}),(0,$.jsxs)(`div`,{role:`menuitem`,tabIndex:-1,"aria-haspopup":`menu`,"aria-expanded":n===`priority`,className:X(`relative flex w-full items-center justify-between gap-2 px-3 py-2 cursor-pointer select-none text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors`,n===`priority`&&`bg-accent/50 text-foreground`),onMouseEnter:()=>r(`priority`),onClick:e=>{e.stopPropagation(),r(n===`priority`?null:`priority`)},children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ns,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground`}),u(`contextMenu.setPriority`)]}),(0,$.jsx)(Qt,{className:`w-3 h-3 text-muted-foreground`}),n===`priority`&&(0,$.jsx)(`div`,{role:`menu`,"aria-label":u(`contextMenu.priorityOptions`),className:`absolute left-full top-0 ml-1 min-w-[140px] rounded-lg border border-border/50 bg-popover shadow-xl py-1 z-[201]`,children:BL.map(e=>(0,$.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>m(()=>a(e.value)),className:X(`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors`,e.className,t.priority===e.value&&`bg-accent/30 font-semibold`),children:[e.icon,u(e.labelKey)]},e.value))})]})]})}function HL({ticket:e,onDelete:t,onStatusChange:n,onPriorityChange:r,children:i,className:a}){let{t:o}=K(`tickets`),{t:s}=K(`jira`),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)({x:0,y:0}),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),{discardStatus:v}=RL(),y=!!v&&e.source===`jira`&&!!e.jira_key,b=(0,Q.useCallback)(()=>{l(!1),p(null)},[]);(0,Q.useEffect)(()=>{if(!c)return;function e(e){e.key===`Escape`&&b()}function t(e){e.target.closest(`[role="menu"]`)||b()}return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[c,b]);function x(e){e.preventDefault(),d({x:e.clientX,y:e.clientY}),p(null),l(!0)}function S(){t(e.id),h(!1)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{onContextMenu:x,className:a,"data-ticket-id":e.id,children:i}),c&&(0,xb.createPortal)((0,$.jsx)(VL,{position:u,ticket:e,activeSubmenu:f,onSetSubmenu:p,onStatusChange:t=>n(e.id,t),onPriorityChange:t=>r(e.id,t),onDeleteRequest:()=>h(!0),discardLabel:y?s(`discard.moveButton`,{status:v}):void 0,onDiscardRequest:y?()=>_(!0):void 0,onClose:b}),document.body),y&&v&&(0,$.jsx)(M,{open:g,onOpenChange:_,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:v}),(0,$.jsx)(Hn,{open:m,onOpenChange:h,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:o(`deleteDialog.title`)}),(0,$.jsx)(Mn,{children:(0,$.jsx)(tt,{t:o,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,$.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>h(!1),children:o(`common:actions.cancel`)}),(0,$.jsxs)(Z,{variant:`destructive`,size:`sm`,onClick:S,children:[(0,$.jsx)(dn,{className:`w-3.5 h-3.5 mr-1.5`}),o(`common:actions.delete`)]})]})]})})]})}var UL=[`accent-primary`,`accent-info`,`accent-success`,`accent-secondary`,`accent-warning`,`accent-highlight`];function WL(e){let t=2166136261,n=e.toLowerCase();for(let e=0;e<n.length;e+=1)t^=n.charCodeAt(e),t=Math.imul(t,16777619)>>>0;return UL[t%UL.length]}var GL={"accent-primary":`bg-accent-primary/20 text-accent-primary`,"accent-info":`bg-accent-info/20 text-accent-info`,"accent-success":`bg-accent-success/20 text-accent-success`,"accent-secondary":`bg-accent-secondary/20 text-accent-secondary`,"accent-warning":`bg-accent-warning/20 text-accent-warning`,"accent-highlight":`bg-accent-highlight/20 text-accent-highlight`};function KL({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e)for(let e of n.labels??[]){let n=e.trim();n&&t.set(n,(t.get(n)??0)+1)}return Array.from(t.entries()).sort((e,t)=>t[1]===e[1]?e[0].localeCompare(t[0]):t[1]-e[1])},[e]);(0,Q.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)}function d(){n(new Set)}let f=t.size===0?i(`labelFilter.all`):t.size===1?Array.from(t)[0]:i(`labelFilter.selected`,{count:t.size});return(0,$.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,$.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`labelFilter.ariaLabel`),"data-testid":`spec-label-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-secondary/10 border border-accent-secondary/30 hover:bg-accent-secondary/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-secondary/50`,children:[(0,$.jsx)(uc,{className:`w-3 h-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[120px]`,children:f}),t.size>0&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/80`,children:[`·\xA0`,t.size]})]}),a&&(0,$.jsxs)(`div`,{ref:c,role:`listbox`,"aria-multiselectable":`true`,"data-testid":`spec-label-filter-panel`,className:`absolute z-40 left-0 mt-1 w-56 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.size===0,onClick:d,"data-testid":`spec-label-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t.size===0&&`bg-accent-info/10 text-accent-info`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t.size===0&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`labelFilter.all`)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length===0&&(0,$.jsx)(`div`,{className:`px-2 py-2 text-[11px] text-muted-foreground/60 italic`,children:i(`labelFilter.empty`)}),l.length>0&&(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(([e,n])=>{let r=t.has(e),i=GL[WL(e)]??`bg-muted/40 text-foreground`;return(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,onClick:()=>u(e),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,r&&`bg-accent-info/5`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:r&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:X(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium`,i),children:e}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:n})]},e)})]})]})}function qL({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e){if(!n.jira_epic_key)continue;let e=t.get(n.jira_epic_key);e?e.count+=1:t.set(n.jira_epic_key,{key:n.jira_epic_key,name:n.jira_epic_name??n.jira_epic_key,count:1})}return Array.from(t.values()).sort((e,t)=>t.count===e.count?e.name.localeCompare(t.name):t.count-e.count)},[e]);(0,Q.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){n(e),o(!1)}let d=t?l.find(e=>e.key===t):null,f=d?d.name:i(`epicFilter.all`);return(0,$.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,$.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`epicFilter.ariaLabel`),"data-testid":`spec-epic-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-highlight/10 border border-accent-highlight/30 hover:bg-accent-highlight/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-highlight/50`,children:[(0,$.jsx)(xs,{className:`w-3 h-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:f})]}),a&&(0,$.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-epic-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>u(null),"data-testid":`spec-epic-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`epicFilter.all`)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length>0&&(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(e=>{let n=t===e.key;return(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>u(e.key),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-accent-highlight shrink-0`,children:e.key}),(0,$.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e.count})]},e.key)})]})]})}function JL({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e){if(!n.jira_sprint_id)continue;let e=n.jira_sprint_state===`active`,r=t.get(n.jira_sprint_id);r?(r.count+=1,e&&(r.active=!0)):t.set(n.jira_sprint_id,{id:n.jira_sprint_id,name:n.jira_sprint_name??n.jira_sprint_id,count:1,active:e})}return Array.from(t.values()).sort((e,t)=>e.active===t.active?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:e.active?-1:1)},[e]);(0,Q.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function u(e){n(e),o(!1)}let d=t?l.find(e=>e.id===t):null,f=d?d.name:i(`sprintFilter.all`);return(0,$.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,$.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`sprintFilter.ariaLabel`),"data-testid":`spec-sprint-filter-dropdown`,onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs bg-accent-success/10 border border-accent-success/30 hover:bg-accent-success/20 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-success/50`,children:[(0,$.jsx)(fc,{className:`w-3 h-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:f})]}),a&&(0,$.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-sprint-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-72 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>u(null),"data-testid":`spec-sprint-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`sprintFilter.all`)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.length})]}),l.length>0&&(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/40`,"aria-hidden":!0}),l.map(e=>{let n=t===e.id;return(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>u(e.id),className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),e.active&&(0,$.jsx)(`span`,{"data-testid":`spec-sprint-current-badge`,className:`shrink-0 rounded-full bg-accent-success/15 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-success`,children:i(`sprintFilter.current`)}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:e.count})]},e.id)})]})]})}var YL=[`draft`,`todo`,`in_progress`,`on_review`,`done`,`cancelled`],XL=new Set([`draft`,`todo`,`in_progress`,`on_review`]),ZL=[`active`,`all`,...YL];function QL(e){return typeof e==`string`&&ZL.includes(e)}function $L(e,t){return t===`all`?!0:t===`active`?XL.has(e):e===t}var eR=e=>`specrails-desktop:spec-status-filter:${e}`,tR=e=>`specrails-desktop:spec-status-tab:${e}`;function nR(e){if(!e)return`active`;try{let t=localStorage.getItem(eR(e));return QL(t)?t:localStorage.getItem(tR(e))===`done`?`done`:`active`}catch{return`active`}}function rR(e,t){if(e)try{localStorage.setItem(eR(e),t)}catch{}}var iR={active:`bg-accent-primary/15 border-accent-primary/40 text-accent-primary`,all:`bg-muted/50 border-border text-foreground`,draft:`bg-accent-secondary/15 border-accent-secondary/40 text-accent-secondary`,todo:`bg-slate-500/15 border-slate-500/40 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,in_progress:`bg-blue-500/15 border-blue-500/40 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,on_review:`bg-accent-warning/15 border-accent-warning/40 text-accent-warning`,done:`bg-emerald-500/15 border-emerald-500/40 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,cancelled:`bg-red-500/10 border-red-500/30 text-red-400/80 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`},aR={active:`statusFilter.active`,all:`statusFilter.all`,draft:`common:status.draft`,todo:`status.todo`,in_progress:`status.inProgress`,on_review:`status.onReview`,done:`status.done`,cancelled:`status.cancelled`};function oR({value:e,selected:t,count:n,onClick:r,label:i}){let a=e!==`active`&&e!==`all`;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:r,"data-testid":`specs-status-chip-${e}`,title:i,className:X(`inline-flex items-center gap-1.5 rounded-full border px-2.5 h-6 text-[11px] font-medium whitespace-nowrap shrink-0 transition-all`,t?iR[e]:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/40`,!t&&n===0&&`opacity-40`),children:[a&&(0,$.jsx)(b,{status:e,className:`w-2 h-2`}),(0,$.jsx)(`span`,{children:i}),(0,$.jsx)(`span`,{className:X(`text-[10px] tabular-nums rounded-full px-1 min-w-[16px] text-center`,t?`bg-background/40`:`bg-muted/30 opacity-70`),"data-testid":`specs-status-count-${e}`,children:n})]})}function sR({value:e,onChange:t,counts:n,className:r}){let{t:i}=K(`specs`),a=YL.filter(e=>XL.has(e)).reduce((e,t)=>e+n[t],0),o=YL.reduce((e,t)=>e+n[t],0),s=e=>e===`active`?a:e===`all`?o:n[e];return(0,$.jsxs)(`div`,{role:`tablist`,"aria-label":i(`statusFilter.ariaLabel`),"data-testid":`specs-status-filter`,className:X(`flex items-center gap-1 min-w-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,r),children:[[`active`,`all`].map(n=>(0,$.jsx)(oR,{value:n,selected:e===n,count:s(n),onClick:()=>t(n),label:i(aR[n])},n)),(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/50 shrink-0 mx-0.5`,"aria-hidden":!0}),YL.map(n=>(0,$.jsx)(oR,{value:n,selected:e===n,count:s(n),onClick:()=>t(n),label:i(aR[n])},n))]})}var cR=[...YL,`other`],lR={draft:`common:status.draft`,todo:`status.todo`,in_progress:`status.inProgress`,on_review:`status.onReview`,done:`status.done`,cancelled:`status.cancelled`};function uR({tickets:e,active:t,onChange:n,className:r}){let{t:i}=K(`specs`),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),{groups:l,total:u}=(0,Q.useMemo)(()=>{let t=new Map,n=0;for(let r of e){if(!r.jira_status)continue;n+=1;let e=t.get(r.jira_status);e||(e=new Map,t.set(r.jira_status,e)),e.set(r.status,(e.get(r.status)??0)+1)}let r=[];for(let[e,n]of t){let t=0,i=`other`,a=0,o=!1;for(let e of YL){let r=n.get(e)??0;t+=r,r>a?(i=e,a=r,o=!1):r===a&&r>0&&(o=!0)}r.push({name:e,count:t,logical:o?`other`:i})}let i=new Map;for(let e of cR){let t=r.filter(t=>t.logical===e).sort((e,t)=>t.count===e.count?e.name.localeCompare(t.name):t.count-e.count);t.length>0&&i.set(e,t)}return{groups:i,total:n}},[e]);(0,Q.useEffect)(()=>{if(!a)return;function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);function d(e){n(e),o(!1)}let f=(0,Q.useMemo)(()=>{if(!t)return null;for(let[e,n]of l)if(n.some(e=>e.name===t))return e;return`other`},[t,l]);return(0,$.jsxs)(`div`,{className:X(`relative shrink-0`,r),children:[(0,$.jsxs)(`button`,{ref:s,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":a,"aria-label":i(`jiraStatusFilter.ariaLabel`),"data-testid":`spec-jira-status-filter-dropdown`,onClick:()=>o(e=>!e),className:X(`flex items-center gap-1.5 h-6 px-2 rounded-full text-[11px] font-medium border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/50`,t?`bg-accent-info/10 border-accent-info/40 text-accent-info hover:bg-accent-info/20`:`bg-transparent border-border/60 text-muted-foreground hover:text-foreground hover:bg-muted/40`),children:[(0,$.jsx)(gc,{className:`w-3 h-3`}),t&&f&&f!==`other`&&(0,$.jsx)(b,{status:f,className:`w-2 h-2`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t??i(`jiraStatusFilter.triggerLabel`)})]}),a&&(0,$.jsxs)(`div`,{ref:c,role:`listbox`,"data-testid":`spec-jira-status-filter-panel`,className:`absolute z-40 left-0 mt-1 w-64 max-h-80 overflow-y-auto rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/30 p-1`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===null,onClick:()=>d(null),"data-testid":`spec-jira-status-filter-all`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-accent-info/10 transition-colors`,t===null&&`bg-accent-info/10 text-accent-info`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:t===null&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`jiraStatusFilter.all`)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 tabular-nums`,children:u})]}),cR.map(e=>{let n=l.get(e);if(!n)return null;let r=e===`other`;return(0,$.jsxs)(`div`,{"data-testid":`spec-jira-status-group-${e}`,children:[(0,$.jsxs)(`div`,{className:X(`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wide`,r?`text-muted-foreground/50`:`text-muted-foreground/80`),"aria-hidden":!0,children:[!r&&(0,$.jsx)(b,{status:e,className:`w-2 h-2`}),(0,$.jsx)(`span`,{children:i(r?`jiraStatusFilter.other`:lR[e])})]}),n.map(e=>{let n=t===e.name;return(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,onClick:()=>d(e.name),"data-testid":`spec-jira-status-option-${e.name}`,className:X(`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-xs hover:bg-muted/30 transition-colors`,n&&`bg-accent-info/5`,r&&`opacity-70`),children:[(0,$.jsx)(`span`,{className:`inline-flex w-4 h-4 items-center justify-center`,children:n&&(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-info`})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.name}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60 tabular-nums`,children:e.count})]},e.name)})]},e)})]})]})}var dR=qE,fR=YE,pR=Q.forwardRef(({className:e,children:t,...n},r)=>(0,$.jsxs)(JE,{ref:r,className:X(`flex h-8 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-1 text-xs ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,$.jsx)(XE,{asChild:!0,children:(0,$.jsx)(Zt,{className:`h-3 w-3 opacity-50`})})]}));pR.displayName=JE.displayName;var mR=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(iD,{ref:n,className:X(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,$.jsx)(Gt,{className:`h-3 w-3`})}));mR.displayName=iD.displayName;var hR=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(aD,{ref:n,className:X(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,$.jsx)(Zt,{className:`h-3 w-3`})}));hR.displayName=aD.displayName;var gR=Q.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,$.jsx)(ZE,{children:(0,$.jsxs)(QE,{ref:i,className:X(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,$.jsx)(mR,{}),(0,$.jsx)($E,{className:X(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,$.jsx)(hR,{})]})}));gR.displayName=QE.displayName;var _R=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(eD,{ref:n,className:X(`py-1.5 pl-8 pr-2 text-xs font-semibold`,e),...t}));_R.displayName=eD.displayName;var vR=Q.forwardRef(({className:e,children:t,...n},r)=>(0,$.jsxs)(tD,{ref:r,className:X(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-xs outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(rD,{children:(0,$.jsx)(Ht,{className:`h-3 w-3`})})}),(0,$.jsx)(nD,{children:t})]}));vR.displayName=tD.displayName;var yR=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(oD,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));yR.displayName=oD.displayName;var bR={default:`sortControl.modes.default`,"ticket-id":`sortControl.modes.ticketId`,priority:`sortControl.modes.priority`,"jira-key":`sortControl.modes.jiraKey`};function xR({mode:e,dir:t,onChange:n,showJiraSort:r=!1,className:i}){let{t:a}=K(`specs`),o=e!=="default";return(0,$.jsx)(TO,{delayDuration:300,children:(0,$.jsxs)(`div`,{className:X(`flex items-center gap-1 shrink-0`,i),children:[(0,$.jsxs)(EO,{children:[(0,$.jsx)(DO,{asChild:!0,children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(dR,{value:e,onValueChange:e=>n(e,t),children:[(0,$.jsxs)(pR,{"aria-label":a(`sortControl.modeAriaLabel`),className:`h-7 w-auto gap-1.5 px-2 text-xs bg-accent-secondary/10 border-accent-secondary/30 hover:bg-accent-secondary/20`,children:[(0,$.jsx)(ho,{className:`w-3 h-3 text-muted-foreground`}),(0,$.jsx)(fR,{children:a(bR[e])})]}),(0,$.jsxs)(gR,{children:[(0,$.jsx)(vR,{value:`default`,children:a(`sortControl.modes.default`)}),(0,$.jsx)(vR,{value:`ticket-id`,children:a(`sortControl.modes.ticketId`)}),(0,$.jsx)(vR,{value:`priority`,children:a(`sortControl.modes.priority`)}),(r||e===`jira-key`)&&(0,$.jsx)(vR,{value:`jira-key`,children:a(`sortControl.modes.jiraKey`)})]})]})})}),(0,$.jsx)(OO,{children:a(`sortControl.tooltip`,{mode:a(bR[e])})})]}),o&&(0,$.jsxs)(EO,{children:[(0,$.jsx)(DO,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":a(`sortControl.toggleDirAriaLabel`),onClick:()=>n(e,t===`asc`?`desc`:`asc`),className:`inline-flex items-center justify-center h-7 w-7 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 hover:bg-accent-secondary/20 text-muted-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,children:t===`asc`?(0,$.jsx)(Ut,{className:`w-3 h-3`}):(0,$.jsx)(_o,{className:`w-3 h-3`})})}),(0,$.jsx)(OO,{children:a(t===`asc`?`sortControl.ascending`:`sortControl.descending`)})]})]})})}var SR=[{value:`row`,Icon:Es,labelKey:`viewTier.listView`},{value:`postit`,Icon:cc,labelKey:`viewTier.postitView`}];function CR({tier:e,onChange:t,className:n}){let{t:r}=K(`specs`);return(0,$.jsx)(TO,{delayDuration:300,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`viewTier.ariaLabel`),className:X(`inline-flex items-center rounded-md border border-accent-secondary/30 bg-accent-secondary/10 p-0.5 shrink-0`,n),children:SR.map(({value:n,Icon:i,labelKey:a})=>{let o=e===n;return(0,$.jsxs)(EO,{children:[(0,$.jsx)(DO,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":o,"aria-label":r(a),onClick:()=>t(n),className:X(`inline-flex items-center justify-center h-6 w-6 rounded transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1`,o?`bg-accent-secondary/40 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent-secondary/20`),"data-testid":`specs-view-tier-${n}`,children:(0,$.jsx)(i,{className:`w-3.5 h-3.5`})})}),(0,$.jsx)(OO,{children:r(a)})]},n)})})})}var wR=`default`,TR=`desc`,ER=e=>`specrails-desktop:spec-sort-mode:${e}`,DR=e=>`specrails-desktop:spec-sort-dir:${e}`;function OR(e){return e==="default"||e===`ticket-id`||e===`priority`||e===`jira-key`}function kR(e){return e===`asc`||e===`desc`}function AR(e){if(!e)return{mode:wR,dir:TR};let t=wR,n=TR;try{let n=localStorage.getItem(ER(e));OR(n)&&(t=n)}catch{}try{let t=localStorage.getItem(DR(e));kR(t)&&(n=t)}catch{}return{mode:t,dir:n}}function jR(e,t,n){if(e)try{localStorage.setItem(ER(e),t),localStorage.setItem(DR(e),n)}catch{}}var MR={critical:4,high:3,medium:2,low:1,null:0};function NR(e){return e===null?MR.null:MR[e]}function PR(e,t,n){return n===`asc`?e.id-t.id:t.id-e.id}function FR(e,t,n){let r=NR(e.priority),i=NR(t.priority),a=n===`asc`?r-i:i-r;return a===0?e.id-t.id:a}function IR(e){let t=e.jira_key;if(!t)return null;let n=/(\d+)\s*$/.exec(t);if(!n)return null;let r=Number.parseInt(n[1],10);return Number.isSafeInteger(r)?r:null}function LR(e,t,n){let r=IR(e),i=IR(t);if(r===null&&i===null)return e.id-t.id;if(r===null)return 1;if(i===null)return-1;let a=n===`asc`?r-i:i-r;return a===0?e.id-t.id:a}function RR(e,t,n){return t===`ticket-id`?[...e].sort((e,t)=>PR(e,t,n)):t===`priority`?[...e].sort((e,t)=>FR(e,t,n)):t===`jira-key`?[...e].sort((e,t)=>LR(e,t,n)):e}var zR=e=>`specrails-desktop:spec-filters:${e}`;function BR(e){return e.labels.size===0&&e.epic===null&&e.sprint===null&&e.jiraStatus===null}function VR(e){return typeof e==`string`&&e.length>0?e:null}function HR(){return{labels:new Set,epic:null,sprint:null,jiraStatus:null}}function UR(e){if(!e)return HR();try{let t=localStorage.getItem(zR(e));if(!t)return HR();let n=JSON.parse(t);if(!n||typeof n!=`object`)return HR();let r=n;return{labels:Array.isArray(r.labels)?new Set(r.labels.filter(e=>typeof e==`string`)):new Set,epic:VR(r.epic),sprint:VR(r.sprint),jiraStatus:VR(r.jiraStatus)}}catch{return HR()}}function WR(e,t){if(e)try{if(BR(t)){localStorage.removeItem(zR(e));return}localStorage.setItem(zR(e),JSON.stringify({labels:[...t.labels],epic:t.epic,sprint:t.sprint,jiraStatus:t.jiraStatus}))}catch{}}function GR(e){let t=Math.floor(e/1e3),n=Math.floor(t/60);return n>0?`${n}:${(t%60).toString().padStart(2,`0`)}`:`${t}s`}var KR=`specrails-desktop:pending-specs`;function qR(){try{return JSON.parse(localStorage.getItem(KR)??`[]`)}catch{return[]}}function JR(e){try{let t=qR().filter(t=>t.id!==e.id);t.push(e),localStorage.setItem(KR,JSON.stringify(t))}catch{}}function YR(e){try{let t=qR().filter(t=>t.id!==e);localStorage.setItem(KR,JSON.stringify(t))}catch{}}var XR=(0,Q.createContext)(null),ZR=40,QR=3e3;function $R({children:e}){let{registerHandler:t,unregisterHandler:n}=qe(),{setActiveProjectId:r}=at(),i=v(),[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Map),c=(0,Q.useRef)(new Map),l=(0,Q.useRef)(new Set),u=(0,Q.useRef)(null),{activeProjectId:d}=at();(0,Q.useEffect)(()=>{u.current=d},[d]);let f=(0,Q.useCallback)(e=>{e.timerId=setInterval(()=>{J.loading(`${e.projectName} · ${e.truncated}`,{id:e.toastId,description:G.t(`activity:specGen.generating`,{elapsed:GR(Date.now()-e.startTime)})})},1e3)},[]),p=(0,Q.useCallback)(e=>{clearInterval(e.timerId),YR(e.persistId),k(e.projectId)},[]),m=(0,Q.useCallback)((e,t)=>{e.projectId===u.current?(o({ticket:t,projectId:e.projectId}),window.location.pathname!==`/`&&i(`/`)):(gk(e.projectId,`/`),o({ticket:t,projectId:e.projectId}),r(e.projectId))},[r,i]),h=(0,Q.useRef)(m);(0,Q.useEffect)(()=>{h.current=m},[m]);let g=(0,Q.useCallback)((e,t)=>{p(e);let n=GR(Date.now()-e.startTime);J.success(`${e.projectName} · ${t.title||G.t(`activity:specGen.specCreated`)}`,{id:e.toastId,duration:1e4,description:G.t(`activity:specGen.generatedIn`,{elapsed:n}),action:{label:G.t(`activity:specGen.view`),onClick:()=>m(e,t)}})},[p,m]),_=(0,Q.useCallback)((e,t)=>{p(e),J.error(`${e.projectName} · ${t??G.t(`activity:specGen.errorGenerating`)}`,{id:e.toastId})},[p]),y=(0,Q.useCallback)((e,t)=>{let n=0;async function r(){try{let n=await fetch(`${He}/api/projects/${e.projectId}/tickets`);if(!n.ok)throw Error(`fetch failed`);let r=await n.json(),i=(Array.isArray(r)?r:r.tickets??[]).find(t=>!e.knownTicketIds.has(t.id));if(i){t&&c.current.delete(t),g(e,i);return}}catch{}n++,n<5?setTimeout(r,1e3):(t&&c.current.delete(t),_(e,G.t(`activity:specGen.couldNotFind`)))}r()},[g,_]),b=(0,Q.useCallback)(e=>{let t={...e,timerId:0};return l.current.add(e.persistId),D(e.projectId),f(t),JR({id:e.persistId,knownTicketIds:[...e.knownTicketIds],projectId:e.projectId,projectName:e.projectName,startTime:e.startTime,truncated:e.truncated}),t},[f]),x=(0,Q.useCallback)((e,t)=>{let n=b(t);s.current.set(e,n)},[b]),S=(0,Q.useCallback)((e,t)=>{let n=b(t);c.current.set(e,n)},[b]),C=(0,Q.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`||t.type!==`spec_gen_done`&&t.type!==`spec_gen_error`)return;let n=t.requestId;if(!n)return;let r=s.current.get(n);r&&(s.current.delete(n),t.type===`spec_gen_done`?g(r,t.ticket):_(r))},[g,_]),w=(0,Q.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`)return;let n=t.conversationId;if(!n)return;let r=c.current.get(n);if(r){if(t.type===`chat_error`){c.current.delete(n),_(r);return}t.type===`chat_done`&&y(r,n)}},[y,_]),T=(0,Q.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`||t.type!==`ticket_created`&&t.type!==`ticket_updated`)return;let n=t.ticket;if(!n)return;let r=t.projectId;for(let[e,t]of c.current.entries())r&&t.projectId!==r||t.knownTicketIds.has(n.id)||y(t,e)},[y]);(0,Q.useLayoutEffect)(()=>(t(`_tracker_spec_gen`,C),t(`_tracker_chat_done`,w),t(`_tracker_tickets`,T),()=>{n(`_tracker_spec_gen`),n(`_tracker_chat_done`),n(`_tracker_tickets`)}),[C,w,T,t,n]),(0,Q.useEffect)(()=>{let e=qR();if(e.length!==0)for(let t of e){if(l.current.has(t.id))continue;l.current.add(t.id);let e=`spec-restore-${t.id}`,n=new Set(t.knownTicketIds),r=()=>{J.loading(`${t.projectName} · ${t.truncated}`,{id:e,description:G.t(`activity:specGen.generating`,{elapsed:GR(Date.now()-t.startTime)})})};r();let i=setInterval(r,1e3);D(t.projectId);let a=0,o={toastId:e,truncated:t.truncated,knownTicketIds:n,projectId:t.projectId,projectName:t.projectName,startTime:t.startTime,persistId:t.id,timerId:i};async function s(){try{let r=await fetch(`${He}/api/projects/${t.projectId}/tickets`);if(!r.ok)throw Error();let a=await r.json(),s=(Array.isArray(a)?a:a.tickets??[]).find(e=>!n.has(e.id));if(s){clearInterval(i),YR(t.id),k(t.projectId);let n=GR(Date.now()-t.startTime);J.success(`${t.projectName} · ${s.title||G.t(`activity:specGen.specCreated`)}`,{id:e,duration:1e4,description:G.t(`activity:specGen.generatedIn`,{elapsed:n}),action:{label:G.t(`activity:specGen.view`),onClick:()=>h.current(o,s)}});return}}catch{}a++,a<ZR?setTimeout(s,QR):(clearInterval(i),YR(t.id),k(t.projectId),J.error(`${t.projectName} · ${G.t(`activity:specGen.couldNotConfirm`)}`,{id:e}))}s()}},[]);let E=(0,Q.useCallback)(()=>o(null),[]),O=(0,Q.useMemo)(()=>({registerFastSpec:x,registerExploreSpec:S,specToOpen:a,clearSpecToOpen:E}),[x,S,a,E]);return(0,$.jsx)(XR.Provider,{value:O,children:e})}var ez={registerFastSpec:()=>{},registerExploreSpec:()=>{},specToOpen:null,clearSpecToOpen:()=>{}};function tz(){return(0,Q.useContext)(XR)??ez}function nz(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function rz(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function iz({attachment:e,uploading:t,onRemove:n,onClick:r,index:i=0,className:a}){let{t:o}=K(`attachments`),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=Math.min(i*50,250),t=setTimeout(()=>c(!0),e);return()=>clearTimeout(t)},[i]);let d=e?.filename??t?.name??o(`chip.genericFile`),f=e?.mimeType??`application/octet-stream`,p=t?o(`chip.uploading`):e?nz(e.size):``;function m(e){e.stopPropagation(),u(!0),setTimeout(()=>n?.(),180)}return(0,$.jsxs)(`div`,{role:r?`button`:void 0,tabIndex:r?0:void 0,onClick:r,onKeyDown:e=>r&&e.key===`Enter`&&r(),className:X(`group/chip relative inline-flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-lg border border-border bg-card/70 backdrop-blur-sm text-xs shadow-sm`,`transition-all duration-200 ease-out origin-left`,s&&!l?`opacity-100 scale-100 translate-y-0`:`opacity-0 scale-[0.85] translate-y-1`,l&&`max-w-0 overflow-hidden pl-0 pr-0 py-0 border-transparent ml-0 mr-0`,r&&`cursor-pointer hover:border-primary/50`,t&&`animate-pulse`,a),style:l?{maxWidth:0}:void 0,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none shrink-0 w-5 text-center`,children:rz(f)}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 mr-1`,children:[(0,$.jsx)(`span`,{className:`font-medium truncate max-w-[160px] text-foreground`,children:d}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground leading-tight`,children:p})]}),n&&!t&&(0,$.jsx)(`button`,{type:`button`,onClick:m,"aria-label":o(`removeFile`,{name:d}),className:`ml-0.5 w-5 h-5 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:`×`})]})}function az(e){let t=[];for(let n=0;n<e.files.length;n++){let r=e.files.item(n);r&&t.push(r)}return t}function oz(e){return`paste-${new Date().toISOString().slice(0,10)}-${e}.png`}function sz(e){let t=document.createElement(`span`);t.setAttribute(`contenteditable`,`false`),t.dataset.attachmentId=e.id,t.dataset.filename=e.filename,t.className=`inline-flex items-center gap-1 px-1.5 py-0.5 mx-0.5 rounded bg-accent/80 hover:bg-accent text-accent-foreground text-xs font-medium align-baseline select-none border border-border shadow-sm transition-all`;let n=document.createElement(`span`);n.textContent=`@${e.filename}`,n.className=`max-w-[180px] truncate`;let r=document.createElement(`button`);return r.type=`button`,r.setAttribute(`aria-label`,G.t(`attachments:removeFile`,{name:e.filename})),r.dataset.role=`pill-remove`,r.className=`text-accent-foreground/60 hover:text-destructive transition-colors leading-none`,r.textContent=`×`,t.appendChild(n),t.appendChild(r),t}function cz(e){return!!e&&e.nodeType===Node.ELEMENT_NODE}function lz(e,t){if(e.nodeType===Node.TEXT_NODE){t.push(e.nodeValue??``);return}if(e.nodeType!==Node.ELEMENT_NODE)return;let n=e;if(n.dataset.attachmentId&&n.dataset.filename){t.push(`@[${n.dataset.filename}](${n.dataset.attachmentId})`);return}if(n.tagName===`BR`){t.push(`
50
+ `);return}if(n.tagName===`DIV`||n.tagName===`P`){t.length&&!t[t.length-1].endsWith(`
51
+ `)&&t.push(`
52
+ `),e.childNodes.forEach(e=>lz(e,t));return}e.childNodes.forEach(e=>lz(e,t))}var uz=(0,Q.forwardRef)(function({ticketKey:e,placeholder:t,minHeight:n=120,maxHeight:r=320,ariaLabel:i,autoFocus:a,className:o,disabled:s,onAttachmentAdded:c,onAttachmentRemoved:l,onUnsupportedFile:u,onUploadError:d,onChange:f,onSubmit:p,footerExtra:m},h){let{t:g}=K(`attachments`),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(0,Q.useRef)(!1),x=(0,Q.useRef)([]),S=(0,Q.useRef)(0),C=(0,Q.useRef)(0),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)([]),[A,M]=(0,Q.useState)(!0),P=(0,Q.useCallback)(()=>{let e=_.current;e&&M(e.textContent?.trim().length===0&&e.querySelectorAll(`[data-attachment-id]`).length===0),f?.()},[f]),F=(0,Q.useCallback)(()=>{let e=window.getSelection();if(!e||e.rangeCount===0)return;let t=_.current;if(!t)return;let n=e.getRangeAt(0);t.contains(n.commonAncestorContainer)&&(y.current=n.cloneRange())},[]),I=(0,Q.useCallback)(()=>{let e=_.current;if(!e)return null;let t=window.getSelection();if(!t)return null;let n;return y.current&&e.contains(y.current.commonAncestorContainer)?n=y.current.cloneRange():(n=document.createRange(),n.selectNodeContents(e),n.collapse(!1)),t.removeAllRanges(),t.addRange(n),n},[]),L=(0,Q.useCallback)(e=>{if(!_.current)return;let t=I();if(!t)return;let n=sz(e),r=document.createTextNode(` `),i=document.createTextNode(` `);t.deleteContents(),t.insertNode(i),t.insertNode(n),t.insertNode(r);let a=document.createRange();a.setStartAfter(i),a.collapse(!0);let o=window.getSelection();o?.removeAllRanges(),o?.addRange(a),y.current=a.cloneRange(),P()},[P,I]),R=(0,Q.useCallback)(e=>{k(t=>t.some(t=>t.id===e.id)?t:[...t,e]),b.current?x.current.push(e):L(e)},[L]),z=(0,Q.useCallback)(e=>{let t=_.current;if(!t)return null;let n=t.querySelector(`[data-attachment-id="${CSS.escape(e)}"]`),r=n?.dataset.filename;return n?.remove(),k(t=>t.find(t=>t.id===e)?t.filter(t=>t.id!==e):t),P(),!n&&!r?O.find(t=>t.id===e)||null:{id:e,filename:r??``}},[O,P]),B=(0,Q.useCallback)(async t=>{if(!j(t)){u?.(t);return}let n=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;D(e=>[...e,{id:n,name:t.name}]);try{let n=await N(e,t);R(n),c?.(n)}catch(e){let n=e instanceof Error?e:Error(String(e));d?.(n,t)}finally{D(e=>e.filter(e=>e.id!==n))}},[c,u,d,R,e]),ee=(0,Q.useCallback)(async e=>{F(),await Promise.all(e.map(B))},[F,B]);(0,Q.useImperativeHandle)(h,()=>({getPlainText:()=>{let e=_.current;if(!e)return``;let t=[];return e.childNodes.forEach(e=>lz(e,t)),t.join(``).replace(/​/g,``).trim()},getAttachmentIds:()=>{let e=_.current;return e?Array.from(e.querySelectorAll(`[data-attachment-id]`)).map(e=>e.dataset.attachmentId):[]},insertPill:L,focus:()=>_.current?.focus(),resetHeight:()=>{let e=_.current;e&&(e.style.height=``)},clear:()=>{let e=_.current;e&&(e.innerHTML=``,y.current=null,k([]),P())},setPlainText:e=>{let t=_.current;t&&(t.textContent=e,y.current=null,P())}}),[L,P]);let V=(0,Q.useCallback)(e=>{if(!_.current)return;if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){e.preventDefault(),p?.();return}if(e.key!==`Backspace`&&e.key!==`Delete`)return;let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0);if(!n.collapsed)return;let r=e.key===`Backspace`?(()=>{let e=n.startContainer;return e.nodeType===Node.TEXT_NODE&&n.startOffset>0?null:cz(e)?e.childNodes[n.startOffset-1]??null:e.previousSibling})():(()=>{let e=n.startContainer;return e.nodeType===Node.TEXT_NODE&&n.startOffset<(e.nodeValue?.length??0)?null:cz(e)?e.childNodes[n.startOffset]??null:e.nextSibling})(),i=cz(r)?r:null;if(i&&i.dataset.attachmentId){e.preventDefault();let t=z(i.dataset.attachmentId);t&&l?.(t)}},[l,p,z]),H=(0,Q.useCallback)(e=>{let t=e.clipboardData;if(!t)return;let n=(t.items?Array.from(t.items):[]).find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(n){let t=n.getAsFile();if(t){e.preventDefault(),S.current+=1;let n=t.name&&t.name!==`image.png`?t:new File([t],oz(S.current),{type:t.type});B(n);return}}e.preventDefault();let r=t.getData(`text/plain`);if(!r)return;let i=window.getSelection();if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0);a.deleteContents(),a.insertNode(document.createTextNode(r)),a.collapse(!1),P()},[P,B]),te=(0,Q.useCallback)(e=>{let t=e.target;if(t.dataset.role===`pill-remove`){e.preventDefault();let n=t.closest(`[data-attachment-id]`);if(n?.dataset.attachmentId){let e=z(n.dataset.attachmentId);e&&l?.(e)}}},[l,z]),ne=(0,Q.useCallback)(()=>P(),[P]),re=(0,Q.useCallback)(()=>F(),[F]),ie=(0,Q.useCallback)(()=>{b.current=!0},[]),ae=(0,Q.useCallback)(()=>{if(b.current=!1,x.current.length>0){let e=x.current;x.current=[],e.forEach(e=>L(e))}},[L]),oe=(0,Q.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),C.current+=1,T(!0))},[]),se=(0,Q.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},[]),ce=(0,Q.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&(--C.current,C.current<=0&&(C.current=0,T(!1)))},[]),le=(0,Q.useCallback)(e=>{if(!e.dataTransfer?.types.includes(`Files`))return;e.preventDefault(),C.current=0,T(!1);let t=az(e.dataTransfer);t.length>0&&ee(t)},[ee]),ue=(0,Q.useCallback)(()=>{v.current?.click()},[]),fe=(0,Q.useCallback)(e=>{let t=e.target.files?Array.from(e.target.files):[];t.length>0&&ee(t),e.target.value=``},[ee]);return(0,Q.useEffect)(()=>{a&&_.current?.focus()},[a]),(0,$.jsxs)(`div`,{className:X(`relative group`,o),onDragEnter:oe,onDragOver:se,onDragLeave:ce,onDrop:le,children:[(0,$.jsx)(`div`,{ref:_,contentEditable:!s,role:`textbox`,"aria-multiline":`true`,"aria-label":i,spellCheck:!0,suppressContentEditableWarning:!0,onInput:ne,onPaste:H,onKeyDown:V,onClick:te,onBlur:re,onCompositionStart:ie,onCompositionEnd:ae,"data-empty":A?`true`:`false`,className:X(`w-full rounded-lg border border-border bg-background px-3 py-2 text-sm leading-relaxed`,`outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/60`,`transition-colors whitespace-pre-wrap break-words`,`data-[empty=true]:before:content-[attr(data-placeholder)]`,`data-[empty=true]:before:text-muted-foreground data-[empty=true]:before:pointer-events-none`,`data-[empty=true]:before:absolute data-[empty=true]:before:top-2 data-[empty=true]:before:left-3`),style:{minHeight:n,maxHeight:r,resize:`vertical`,overflow:`auto`},"data-placeholder":t??``}),(O.length>0||E.length>0)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:[O.map((e,t)=>(0,$.jsx)(iz,{attachment:e,index:t,onRemove:()=>{let t=z(e.id);t&&l?.(t)}},e.id)),E.map((e,t)=>(0,$.jsx)(iz,{uploading:{name:e.name},index:O.length+t},e.id))]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-[11px] text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:ue,disabled:s,className:`inline-flex items-center gap-1 px-2 py-1 rounded-md border border-border hover:bg-accent/40 transition-colors disabled:opacity-50`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`📎`}),(0,$.jsx)(`span`,{children:g(`editor.attachFiles`)})]}),m]}),E.length>0&&(0,$.jsx)(`span`,{className:`animate-pulse`,children:g(`editor.uploadingFiles`,{count:E.length})})]}),(0,$.jsx)(`input`,{ref:v,type:`file`,multiple:!0,accept:de,className:`hidden`,onChange:fe}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-0 rounded-lg border-2 border-dashed transition-all duration-150`,w?`border-primary bg-primary/10 opacity-100 scale-100`:`border-transparent opacity-0 scale-[0.98]`),children:(0,$.jsx)(`div`,{className:X(`absolute inset-0 flex items-center justify-center text-sm font-medium text-primary`,w?`opacity-100`:`opacity-0`,`transition-opacity`),children:g(`editor.dropToAddContext`)})})]})}),dz={claude:[{value:`sonnet`,label:`Claude Sonnet`},{value:`fable`,label:`Claude Fable`},{value:`opus`,label:`Claude Opus`},{value:`haiku`,label:`Claude Haiku`}],codex:[{value:`gpt-5.5`,label:`GPT-5.5`},{value:`gpt-6-astra`,label:`GPT-6 Astra`},{value:`gpt-5.6-sol`,label:`GPT-5.6 Sol`},{value:`gpt-5.6-terra`,label:`GPT-5.6 Terra`},{value:`gpt-5.6-luna`,label:`GPT-5.6 Luna`},{value:`gpt-5.4`,label:`GPT-5.4`},{value:`gpt-5.4-mini`,label:`GPT-5.4 Mini`},{value:`gpt-5.3-codex`,label:`GPT-5.3 Codex`}],gemini:[{value:`gemini-3.5-flash`,label:`Gemini 3.5 Flash`},{value:`gemini-3.1-pro-preview`,label:`Gemini 3.1 Pro (preview)`},{value:`gemini-3.1-flash-lite`,label:`Gemini 3.1 Flash Lite`},{value:`gemini-2.5-flash-lite`,label:`Gemini 2.5 Flash Lite`}],kimi:[{value:`k3`,label:`Kimi K3`},{value:`kimi-for-coding`,label:`Kimi for Coding`},{value:`kimi-for-coding-highspeed`,label:`Kimi for Coding Highspeed`}]};function fz(e){return e&&dz[e]||[]}function pz(e){return fz(e)[0]?.value??``}function mz({value:e,allowed:t,customModelAliases:n=!1,loading:r,onChange:i,ariaLabel:a}){let{t:o}=K(`explore`),s=a??o(`modelPicker.ariaLabel`);return n?(0,$.jsx)(_D,{value:e??``,options:t,onCommit:i,disabled:r,ariaLabel:s,testId:`spec-model-picker`,placeholder:o(r?`common:states.loading`:`modelPicker.placeholder`),className:`h-8 w-[210px] px-2 text-xs`}):(0,$.jsxs)(dR,{value:e??``,onValueChange:i,disabled:r||t.length===0,children:[(0,$.jsx)(pR,{className:`h-8 w-[160px] text-xs gap-1.5`,"aria-label":s,"data-testid":`spec-model-picker`,children:r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`w-3 h-3 animate-spin`}),o(`common:states.loading`)]}):(0,$.jsx)(fR,{placeholder:o(`modelPicker.placeholder`)})}),(0,$.jsx)(gR,{children:t.map(e=>(0,$.jsx)(vR,{value:e.value,children:e.label},e.value))})]})}function hz(e,t,n){let[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(!t||!e)return;let r=!1;m(!0),g(null),i(null),o([]),c(n??null),f(!1);let a=n?`?provider=${encodeURIComponent(n)}`:``;return fetch(`${nt()}/default-spec-model${a}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{if(r)return;let t=e?.provider??n??`claude`,a=fz(t),s=Array.isArray(e?.allowed)&&e.allowed.length>0?e.allowed:a;i(typeof e?.model==`string`?e.model:s[0]?.value??null),o(s),c(t),f(e?.customModelAliases===!0),u(Array.isArray(e?.providers)&&e.providers.length>0?e.providers:[t])}).catch(e=>{if(r)return;g(e.message);let t=n??`claude`,a=fz(t);i(a[0]?.value??null),o(a),c(t),f(nr(t)),u([t])}).finally(()=>{r||m(!1)}),()=>{r=!0}},[t,e,n]),{model:r,setModel:i,allowed:a,customModelAliases:d,provider:s,providers:l,loading:p,error:h}}function gz(){let[e,t]=(0,Q.useState)({detected:[],providers:{},loading:!0}),n=(0,Q.useContext)(Ye);return(0,Q.useEffect)(()=>{let e=!0;return fetch(`${He}/api/providers/detected`).then(e=>e.ok?e.json():null).then(n=>{!e||!n||t({detected:Array.isArray(n.detected)?n.detected:[],providers:n.providers??{},loading:!1})}).catch(()=>{e&&t(e=>({...e,loading:!1}))}),()=>{e=!1}},[]),(0,Q.useEffect)(()=>{let e=e=>{let n=e;n.type===`providers.detected_changed`&&t({detected:Array.isArray(n.detected)?n.detected:[],providers:n.providers??{},loading:!1})};if(n)return n.registerHandler(`provider-detection`,e),()=>n.unregisterHandler(`provider-detection`)},[n]),e}function _z({value:e,providers:t,onChange:n,disabled:r,ariaLabel:i,className:a}){let{t:o}=K(`addspec`),s=gz();return!t||t.length<=1?null:(0,$.jsxs)(dR,{value:e,onValueChange:e=>n(e),disabled:r,children:[(0,$.jsx)(pR,{className:a??`h-8 w-[130px] text-xs gap-1.5`,"aria-label":i??o(`aiEngine.label`),"data-testid":`ai-engine-selector`,children:(0,$.jsx)(fR,{placeholder:o(`aiEngine.label`)})}),(0,$.jsx)(gR,{children:t.map(e=>{let t=s.providers[e]?.authState===`unauthenticated`;return(0,$.jsx)(vR,{value:e,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[ur(e),t&&(0,$.jsx)(`span`,{className:`rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] leading-4 text-accent-warning`,title:o(`aiEngine.notSignedIn`),children:o(`aiEngine.notSignedIn`)})]})},e)})})]})}function vz(e){return{specrails:!0,openspec:!1,full:e===`explore`,mcp:!1,contractRefine:!1,userMcp:!1}}function yz(e){let t=+!!e.specrails+(e.openspec?2:0)+(e.mcp?2:0)+(e.full?4:0)+(e.contractRefine?4:0);return t===0?`Light`:t<=2?`Medium`:t<=5?`Heavy`:`Deep`}function bz(e){switch(e){case`Light`:return`bg-accent-success text-white hover:bg-accent-success/90`;case`Medium`:return`bg-accent-info text-white hover:bg-accent-info/90`;case`Heavy`:return`bg-accent-warning text-white hover:bg-accent-warning/90`;case`Deep`:return`bg-accent-secondary text-white hover:bg-accent-secondary/90`}}var xz={sonnet:.003,opus:.015,haiku:8e-4,"gpt-5.5":.0015,"gpt-5.4-mini":6e-4,"gpt-5.4":.005,"gpt-5.6-sol":.005,"gpt-5.6-terra":.0025,"gpt-5.6-luna":.001};function Sz(e,t){let n=0;return e.specrails&&(n+=t.specrailsTicketsTokens??0),e.openspec&&(n+=t.openspecSpecsTokens??0),e.full&&(n+=Math.min(t.codebaseEstimatedTokens??0,5e4)),n}function Cz(e,t,n){let r=Sz(e,t),i=xz[n]??.003;return r/1e3*i}function wz(e){switch(e){case`Light`:return`~15s`;case`Medium`:return`~30s`;case`Heavy`:return`~60s`;case`Deep`:return`~120s`}}function Tz(e){return e.full?`~45s`:`~15s`}function Ez({id:e,label:t,hint:n,checked:r,disabled:i,tooltip:a,onChange:o}){return(0,$.jsxs)(`div`,{title:a,className:`flex items-center justify-between gap-3 px-3 py-2 rounded-md border border-border/40 ${i?`opacity-50 cursor-not-allowed`:`cursor-pointer hover:bg-card/60`}`,children:[(0,$.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n})]}),(0,$.jsx)(`button`,{id:e,type:`button`,role:`switch`,"aria-label":t,"aria-checked":r,disabled:i,onClick:()=>o(!r),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 ${r?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${r?`translate-x-4`:`translate-x-0.5`}`})})]})}function Dz({scope:e,onChange:t,defaultOpen:n=!1,label:r,showSummary:i=!0,userMcpSupported:a=!0,contractRefineSupported:o=!0,providerLabel:s}){let{t:c}=K(`addspec`),l=r??c(`contextScope.defaultLabel`),u=!a,d=!o,f=s?c(`contextScope.checks.providerUnsupported`,{provider:s}):void 0,[p,m]=(0,Q.useState)(n),h=[e.specrails&&c(`contextScope.tags.specrails`),e.openspec&&c(`contextScope.tags.openspec`),e.full&&c(`contextScope.tags.codebase`),e.mcp&&c(`contextScope.tags.mcp`),e.userMcp&&!u&&c(`contextScope.tags.myMcp`),e.contractRefine&&!d&&c(`contextScope.tags.contract`)].filter(Boolean),g=h.length===0?c(`contextScope.summaryMinimal`):h.join(`, `),_=yz(e);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":p,"aria-controls":`ctx-scope-body`,"data-testid":`context-scope-toggle`,onClick:()=>m(e=>!e),className:`flex items-center justify-between gap-2 text-[11px] uppercase tracking-wider text-muted-foreground font-semibold hover:text-foreground transition-colors`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[p?(0,$.jsx)(Zt,{className:`w-3 h-3`}):(0,$.jsx)(Qt,{className:`w-3 h-3`}),l]}),!p&&i?(0,$.jsxs)(`span`,{className:`text-[10px] normal-case tracking-normal text-muted-foreground/80`,children:[g,` · `,_]}):null]}),p?(0,$.jsxs)(`div`,{id:`ctx-scope-body`,className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,$.jsx)(Ez,{id:`ctx-specrails`,label:c(`contextScope.checks.specrailsLabel`),hint:`.specrails/local-tickets.json`,checked:e.specrails,onChange:n=>t({...e,specrails:n})}),(0,$.jsx)(Ez,{id:`ctx-openspec`,label:c(`contextScope.checks.openspecLabel`),hint:`openspec/specs/*`,checked:e.openspec,onChange:n=>t({...e,openspec:n})}),(0,$.jsx)(Ez,{id:`ctx-full`,label:c(`contextScope.checks.fullLabel`),hint:`Read · Grep · Glob`,checked:e.full,onChange:n=>t({...e,full:n})}),(0,$.jsx)(Ez,{id:`ctx-mcp`,label:c(`contextScope.checks.mcpLabel`),hint:c(`contextScope.checks.mcpHint`),checked:e.mcp&&!0,disabled:!1,tooltip:void 0,onChange:n=>t({...e,mcp:n})}),(0,$.jsx)(Ez,{id:`ctx-user-mcp`,label:c(`contextScope.checks.userMcpLabel`),hint:c(`contextScope.checks.userMcpHint`),checked:!!e.userMcp&&!u,disabled:u,tooltip:u?f:c(`contextScope.checks.userMcpTooltip`),onChange:n=>t({...e,userMcp:n})}),(0,$.jsx)(Ez,{id:`ctx-contract-refine`,label:c(`contextScope.checks.contractLabel`),hint:c(`contextScope.checks.contractHint`),checked:e.contractRefine&&!d,disabled:d,tooltip:d?f:void 0,onChange:n=>t({...e,contractRefine:n})})]}):null]})}var Oz=[{id:`minimal`,scope:{specrails:!1,openspec:!1,full:!1,mcp:!1,contractRefine:!1}},{id:`light`,scope:{specrails:!0,openspec:!1,full:!1,mcp:!1,contractRefine:!1}},{id:`standard`,scope:{specrails:!0,openspec:!0,full:!1,mcp:!1,contractRefine:!1}},{id:`rich`,scope:{specrails:!0,openspec:!0,full:!0,mcp:!1,contractRefine:!1}},{id:`max`,scope:{specrails:!0,openspec:!0,full:!0,mcp:!1,contractRefine:!0}},{id:`desktop`,scope:{specrails:!0,openspec:!0,full:!0,mcp:!0,contractRefine:!0,userMcp:!0}}];function kz(e,t){return e.specrails===t.specrails&&e.openspec===t.openspec&&e.full===t.full&&e.mcp===t.mcp&&e.contractRefine===t.contractRefine&&(e.userMcp??!1)===(t.userMcp??!1)}function Az(e){return Oz.findIndex(t=>kz(t.scope,e))}function jz(e){let t={specrails:1,openspec:1,full:1,contractRefine:1,mcp:1,userMcp:1},n=0;return e.specrails&&(n+=t.specrails),e.openspec&&(n+=t.openspec),e.full&&(n+=t.full),e.contractRefine&&(n+=t.contractRefine),e.mcp&&(n+=t.mcp),e.userMcp&&(n+=t.userMcp),Math.max(0,Math.min(5,n))}function Mz(e){return e>=1e3?`~${(e/1e3).toFixed(e>=1e4?0:1)}k tok`:`~${e} tok`}function Nz(e){return e<.01?`~$${e.toFixed(4)}`:`~$${e.toFixed(2)}`}function Pz({value:e,onChange:t,budget:n=null,budgetError:r=!1,model:i=`sonnet`,maxPresetId:a=`desktop`,onPresetChange:o,smashCapable:s=!0}){let{t:c}=K(`addspec`),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),m=Math.max(0,Oz.findIndex(e=>e.id===a)),h=Oz.slice(0,m+1),g=Az(e),_=g<0,v=g>=0?Oz[g]:null,y=Math.min(_?jz(e):g,m);(0,Q.useEffect)(()=>{o?.(v?.id??`custom`)},[v,o]);let b=(0,Q.useCallback)(e=>{t(Oz[Math.max(0,Math.min(m,e))].scope)},[m,t]),x=(0,Q.useCallback)(e=>{let t=m;e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),b((g<0?Math.round(y):g)+1)):e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),b((g<0?Math.round(y):g)-1)):e.key===`Home`?(e.preventDefault(),b(0)):e.key===`End`&&(e.preventDefault(),b(t))},[g,y,m,b]),S=(0,Q.useCallback)(e=>{let t=l.current;if(!t)return 0;let n=t.getBoundingClientRect(),r=(e-n.left)/Math.max(1,n.width);return Math.max(0,Math.min(1,r))},[]),C=(0,Q.useCallback)(e=>{let t=S(e);return Math.round(t*m)},[m,S]),w=(0,Q.useCallback)(e=>{e.preventDefault(),d(!0),p(S(e.clientX)),e.target.setPointerCapture?.(e.pointerId)},[S]),T=(0,Q.useCallback)(e=>{u&&p(S(e.clientX))},[u,S]),E=(0,Q.useCallback)(e=>{u&&(d(!1),p(null),b(C(e.clientX)))},[u,C,b]),D=(0,Q.useMemo)(()=>u&&f!==null?f:m===0?0:y/m,[u,f,m,y]),O=_?c(`contextScope.customMix`):v?c(`contextScope.presetCost.${v.id}`):``,k=yz(e),A=r||!n?c(`contextScope.estimateUnavailable`,{tier:k}):`${k} · ${Mz(Sz(e,n))} · ${Nz(Cz(e,n,i))} · ${wz(k)}`;return(0,$.jsxs)(`div`,{className:`space-y-2 select-none`,"data-testid":`context-scope-slider`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground font-semibold`,children:c(`contextScope.heading`)}),_?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-warning/15 px-2 py-0.5 text-[10px] font-semibold text-accent-warning`,"data-testid":`scope-custom-pill`,children:c(`contextScope.custom`)}):null]}),(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-foreground`,"data-testid":`context-awareness-tier`,children:k})]}),(0,$.jsx)(`div`,{className:`flex justify-between text-[10px] font-medium text-muted-foreground`,children:h.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(t),className:`px-1 cursor-pointer hover:text-foreground transition-colors ${g===t?`text-foreground font-semibold`:``}`,"data-testid":`scope-stop-${e.id}`,children:c(`contextScope.preset.${e.id}`)},e.id))}),(0,$.jsxs)(`div`,{ref:l,role:`slider`,"aria-valuemin":0,"aria-valuemax":m,"aria-valuenow":g<0?Math.round(y):g,"aria-valuetext":_?c(`contextScope.custom`):v?c(`contextScope.preset.${v.id}`):``,tabIndex:0,onKeyDown:x,onPointerDown:w,onPointerMove:T,onPointerUp:E,className:`relative h-2 rounded-full bg-muted/40 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[h.map((e,t)=>(0,$.jsx)(`span`,{className:`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 h-2 w-2 rounded-full bg-muted-foreground/70 pointer-events-none`,style:{left:`${m===0?0:t/m*100}%`}},t)),(0,$.jsx)(`div`,{className:`absolute left-0 top-0 h-full rounded-full bg-primary/60 pointer-events-none`,style:{width:`${D*100}%`}}),(0,$.jsx)(`div`,{"data-testid":`scope-thumb`,className:`absolute top-1/2 -translate-y-1/2 -translate-x-1/2 h-4 w-4 rounded-full bg-background border-2 ${_?`border-accent-warning`:`border-primary`} shadow-sm pointer-events-none ${u?``:`transition-[left] duration-150`}`,style:{left:`${D*100}%`}})]}),(0,$.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`scope-cost-line`,children:[O,` · `,A]}),e.contractRefine&&s&&(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 px-2 py-1.5 text-[10px] text-foreground/80`,"data-testid":`scope-smash-hint`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-accent-highlight`,children:`⊢→`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{className:`text-accent-highlight`,children:c(`contextScope.smashCapable`)}),` · `,c(`contextScope.smashHint`)]})]})]})}var Fz=`specrails-desktop:last-engine:`;function Iz(e){return`${Fz}${e}`}function Lz(e,t,n){if(!e)return n;try{let n=window.localStorage.getItem(Iz(e));if(n&&t.includes(n))return n}catch{}return n}function Rz(e,t){if(e)try{window.localStorage.setItem(Iz(e),t)}catch{}}function zz(e,t,n){let[r,i]=(0,Q.useState)({scope:vz(t),loaded:!1}),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!n||!e)return;let o=`${e}:${t}`;if(a.current===o&&r.loaded)return;a.current=o;let s=!1;return(async()=>{if(t===`quick`){s||i({scope:vz(`quick`),loaded:!0});return}let n=vz(t);try{let r=await fetch(`${He}/api/projects/${e}/context-scope-last`);if(r.ok){let e=await r.json();e.scope&&(n={...vz(t),...e.scope})}}catch{}s||i({scope:n,loaded:!0})})(),()=>{s=!0}},[e,n,t]);let o=(0,Q.useCallback)(e=>{i(t=>({scope:typeof e==`function`?e(t.scope):e,loaded:t.loaded}))},[]),s=(0,Q.useCallback)(async t=>{if(e)try{await fetch(`${He}/api/projects/${e}/context-scope-last`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}catch{}},[e]);return{scope:r.scope,setScope:o,persist:s,loaded:r.loaded}}function Bz(e,t){let[n,r]=(0,Q.useState)({data:null,isError:!1}),i=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!t||!e||i.current===e&&n.data)return;i.current=e;let a=!1,o=new AbortController,s=setTimeout(()=>o.abort(),5e3);return fetch(`${He}/api/projects/${e}/context-budget`,{signal:o.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{a||r({data:e,isError:!1})}).catch(()=>{a||r({data:null,isError:!0})}).finally(()=>clearTimeout(s)),()=>{a=!0,o.abort(),clearTimeout(s)}},[e,t]),n}function Vz(e,t){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(!t||!e)return;let n=!1;return(async()=>{let t=!1;try{let n=await fetch(`${He}/api/projects/${e}/add-spec-quick-contract-refine-last`);if(n.ok){let e=await n.json();(e.configured===!0||e.configured===void 0)&&(t=e.enabled===!0)}}catch{}n||(r(t),a(!0))})(),()=>{n=!0}},[e,t]),{value:n,setValue:r,loaded:i,persist:(0,Q.useCallback)(async t=>{e&&await fetch(`${He}/api/projects/${e}/add-spec-quick-contract-refine-last`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})})},[e])}}function Hz(){return typeof window>`u`||!(`__TAURI_INTERNALS__`in window)?!1:/mac/i.test(navigator.platform)}var Uz={desktop:{w:1280,h:800},tablet:{w:768,h:1024},mobile:{w:375,h:667}};function Wz({open:e,onClose:t,projectId:n,pendingSpecId:r,onCaptured:i,confirmLabel:a,selectLabel:o}){let{t:s}=K(`browser`),c=pe({projectId:n,open:e}),{canvasRef:l,viewport:u,status:d,errorMsg:f,url:p,title:m,hoverRect:h,hoverSelector:g,hoverPath:_,popup:v,popupError:y}=c,[b,x]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(!1),[T,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(`fit`),[M,N]=(0,Q.useState)(!0),[P,F]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(null),[z,ee]=(0,Q.useState)(null),[V,te]=(0,Q.useState)(null),ne=(0,Q.useRef)(null),ae=(0,Q.useRef)(null),oe=(0,Q.useRef)(null),se=(0,Q.useRef)(c.forwardInput);se.current=c.forwardInput;let ue=(0,Q.useRef)(null),de=(0,Q.useCallback)(()=>(ue.current??=H(e=>se.current(e)),ue.current),[]);(0,Q.useEffect)(()=>()=>{ue.current?.dispose(),ue.current=null},[]);let fe=(0,Q.useRef)(null),me=(0,Q.useRef)(0),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(c.navigateElement);(0,Q.useEffect)(()=>{he.current=V},[V]),(0,Q.useEffect)(()=>{ge.current=g},[g]),_e.current=c.navigateElement;let ve=v?.active?v.url??`about:blank`:p??``;(0,Q.useEffect)(()=>{x(ve)},[ve,v?.active]);let U=(0,Q.useCallback)(()=>{let e=b.trim();e&&c.navigate(`goto`,e)},[b,c]),{setViewport:be}=c,xe=A===`fit`?void 0:{width:Uz[A].w,height:Uz[A].h};ie(ne,be,e&&!L,xe);let Se=(0,Q.useCallback)(e=>{j(e),e!==`fit`&&be(Uz[e].w,Uz[e].h)},[be]);(0,Q.useEffect)(()=>{if(!e||L)return;let n=e=>{e.key===`Escape`&&(C?(w(!1),D(null),te(null)):t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,L,C,t]),(0,Q.useEffect)(()=>{if(!e||!C)return;let t=e=>{if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;let t=he.current?.selector??ge.current;t&&(e.preventDefault(),_e.current(t,e.key===`ArrowUp`?`parent`:`child`).then(e=>{e&&te(e)}))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,C]),(0,Q.useEffect)(()=>{v?.active&&C&&(w(!1),D(null),te(null),c.clearHover())},[v?.active,C]);let Ce=(0,Q.useCallback)(()=>{let e=l.current?.getBoundingClientRect()??null;return e&&(fe.current={left:e.left,top:e.top,width:e.width,height:e.height}),e},[l]),W=(0,Q.useCallback)((e,t)=>{let n=Ce();return n?Oe({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},u):{x:0,y:0}},[Ce,u]),we=(0,Q.useCallback)(e=>{if(C)return;let t=W(e.clientX,e.clientY);de().move(t.x,t.y)},[C,W,de]),Te=e=>e===2?`right`:e===1?`middle`:`left`,Ee=(0,Q.useCallback)(e=>{if(C)return;let t=W(e.clientX,e.clientY),n=de();n.move(t.x,t.y),n.flush(),c.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:Te(e.button),clickCount:e.detail||1})},[C,W,c,de]),ke=(0,Q.useCallback)(e=>{if(C)return;let t=W(e.clientX,e.clientY),n=de();n.move(t.x,t.y),n.flush(),c.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:Te(e.button),clickCount:e.detail||1})},[C,W,c,de]),je=(0,Q.useCallback)(e=>{if(C)return;let t=W(e.clientX,e.clientY);de().wheel(t.x,t.y,e.deltaX,e.deltaY)},[C,W,de]),Me=(0,Q.useCallback)(e=>{if(C||e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await c.clipboard(`paste`,e)}else{let{text:e}=await c.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};c.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[C,c]),Ne=(0,Q.useCallback)(e=>{C||e.key===`Escape`||c.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[C,c]),Pe=(0,Q.useCallback)(async e=>{let t=ce(e,u);k(!0),ee(null);try{if(P){let e={x:t.x+t.width/2,y:t.y+t.height/2},n=await c.captureBreakpoints(t,e,r,le);R(n)}else{let e=await c.capture(t,r,{captureNetwork:M});R(e)}}catch(e){let t=e instanceof Error?e.message:String(e);ee(t),J.error(s(`modal.toast.captureFailed`))}finally{k(!1),w(!1),D(null),te(null),c.clearHover()}},[c,r,M,P,s,u]),Fe=(0,Q.useCallback)(e=>{c.navigateElement(e.selector,`self`).then(e=>{e&&te(e)})},[c]),Ie=(0,Q.useCallback)(e=>{e.target.setPointerCapture?.(e.pointerId),ee(null),D({startX:e.clientX,startY:e.clientY,curX:e.clientX,curY:e.clientY})},[]),Le=(0,Q.useCallback)(e=>{if(T){let t=e.clientX,n=e.clientY;D(e=>e&&{...e,curX:t,curY:n});return}he.current&&te(null);let t=W(e.clientX,e.clientY);ae.current=t,oe.current??=requestAnimationFrame(()=>{oe.current=null;let e=typeof performance<`u`?performance.now():Date.now();if(e-me.current<40)return;me.current=e;let t=ae.current;t&&c.probe(t)})},[T,W,c]),Re=(0,Q.useCallback)(e=>{let t=he.current;if(D(null),!T)return;let n=De(W(T.startX,T.startY),W(e.clientX,e.clientY));re(n)?Pe(n):t?Pe(t.rect):h&&Pe(h)},[T,W,h,Pe]),ze=(0,Q.useCallback)(e=>{e.target===e.currentTarget&&!L&&t()},[t,L]);if(!e||typeof document>`u`)return null;let Be=T?{left:Math.min(T.startX,T.curX),top:Math.min(T.startY,T.curY),width:Math.abs(T.startX-T.curX),height:Math.abs(T.startY-T.curY)}:null,G=fe.current,Ve=V?.rect??h,He=V?.path??_,Ue=C&&Ve&&!T&&G?I(Ve,G,u):null,We=Hz();return(0,xb.createPortal)((0,$.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/60 backdrop-blur-md pointer-events-auto`,onClick:ze,children:(0,$.jsx)(`div`,{className:`absolute inset-x-[4%] inset-y-[3.5%] flex flex-col border border-border/70 rounded-2xl bg-background-deep overflow-hidden shadow-2xl ring-1 ring-black/20`,role:`dialog`,"aria-modal":`true`,"aria-label":s(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:L?(0,$.jsx)(ye,{result:L,pendingSpecId:r,macOverlay:We,confirmLabel:a,onConfirm:async e=>{await i(e),t()},onReselect:()=>{R(null),w(!0)},onCancel:()=>{R(null),t()}}):(0,$.jsxs)($.Fragment,{children:[z&&(0,$.jsxs)(`div`,{role:`alert`,"data-testid":`capture-error-banner`,className:`flex items-center gap-2 px-3 py-2 text-xs bg-destructive/10 text-destructive border-b border-destructive/30 shrink-0`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:s(`modal.toast.captureFailed`)}),(0,$.jsx)(`span`,{className:`opacity-80 font-mono truncate`,children:z})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 border-b border-border/50 bg-surface/80 shrink-0 ${We?`pr-3`:`px-3`}`,children:[We&&(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,className:`w-20 self-stretch shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":s(`common:actions.back`),onClick:()=>c.navigate(`back`),children:(0,$.jsx)(Rt,{className:`w-4 h-4`})}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":s(`modal.nav.forward`),onClick:()=>c.navigate(`forward`),children:(0,$.jsx)(B,{className:`w-4 h-4`})}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":s(`modal.nav.reload`),onClick:()=>c.navigate(`reload`),children:(0,$.jsx)(Ae,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),U()},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,$.jsx)(E,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,$.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),U())},placeholder:s(`modal.address.placeholder`),"aria-label":s(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,$.jsx)(Z,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:d===`error`,children:s(`modal.address.go`)})]}),(0,$.jsx)(`div`,{className:`hidden md:flex items-center gap-0.5 rounded-md border border-border/50 p-0.5 shrink-0`,role:`group`,"aria-label":s(`modal.viewport.groupLabel`),children:[[`fit`,Os],[`desktop`,js],[`tablet`,lc],[`mobile`,oc]].map(([e,t])=>(0,$.jsx)(`button`,{type:`button`,"aria-label":s(`modal.viewport.presetLabel`,{preset:s(`modal.viewport.${e}`)}),"aria-pressed":A===e,title:s(`modal.viewport.presetTitle`,{preset:s(`modal.viewport.${e}`)}),onClick:()=>Se(e),className:`h-7 w-7 inline-flex items-center justify-center rounded transition-colors ${A===e?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:(0,$.jsx)(t,{className:`w-3.5 h-3.5`})},e))}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":s(`modal.network.ariaLabel`),"aria-pressed":M,title:s(M?`modal.network.titleOn`:`modal.network.titleOff`),onClick:()=>N(e=>!e),className:`hidden md:inline-flex items-center gap-1 h-7 px-2 rounded-md border text-[11px] shrink-0 transition-colors ${M?`border-accent-info/40 bg-accent-info/10 text-accent-info`:`border-border/50 text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:[(0,$.jsx)(Ms,{className:`w-3.5 h-3.5`}),s(`modal.network.button`)]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":s(`modal.allSizes.ariaLabel`),"aria-pressed":P,title:s(P?`modal.allSizes.titleOn`:`modal.allSizes.titleOff`),onClick:()=>F(e=>!e),className:`hidden md:inline-flex items-center gap-1 h-7 px-2 rounded-md border text-[11px] shrink-0 transition-colors ${P?`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`:`border-border/50 text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:[(0,$.jsx)(Ks,{className:`w-3.5 h-3.5`}),s(`modal.allSizes.button`)]}),(0,$.jsxs)(Z,{size:`sm`,variant:C?`default`:`secondary`,className:`gap-1.5`,onClick:()=>{w(e=>!e),D(null),te(null),c.clearHover()},disabled:d!==`ready`||O||v?.active===!0,"data-testid":`browser-select-toggle`,children:[(0,$.jsx)(Ko,{className:`w-3.5 h-3.5`}),C?s(`modal.select.active`):o??s(`modal.select.start`)]}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":s(`modal.closeBrowser`),onClick:t,children:(0,$.jsx)(mn,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${d===`ready`?`bg-accent-success`:d===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:d===`connecting`?s(`modal.status.connecting`):d===`error`?f??s(`modal.status.unavailable`):v?.active?s(`popup.loginWindow`,{origin:S(v.url)}):m||``})]}),y&&(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-1.5 text-xs text-destructive border-b border-border/40 shrink-0`,children:y}),v&&(0,$.jsxs)(`div`,{"data-testid":`browser-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${v.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,$.jsx)(Vt,{className:`w-3.5 h-3.5 shrink-0`}),v.active?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:s(`popup.loginWindow`,{origin:S(v.url)})}),v.count>1&&(0,$.jsx)(`span`,{className:`shrink-0 opacity-70`,children:s(`popup.stacked`,{count:v.count-1})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,$.jsx)(Rt,{className:`w-3 h-3`}),s(`popup.backToPage`)]})]}):(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[s(`popup.show`),v.count>1&&(0,$.jsx)(`span`,{className:`opacity-70`,children:s(`popup.stacked`,{count:v.count-1})})]})]}),(0,$.jsxs)(`div`,{ref:ne,className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:Me,onKeyUp:Ne,children:[d===`error`?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,$.jsx)(fn,{className:`w-8 h-8 text-accent-warning`}),(0,$.jsx)(`p`,{className:`text-sm text-foreground/90`,children:f??s(`modal.error.unavailable`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,$.jsx)(tt,{i18nKey:`modal.error.devHint`,t:s,components:{cmd:(0,$.jsx)(`code`,{className:`font-mono`})}})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`canvas`,{ref:l,style:{maxWidth:`min(100%, ${u.width}px)`,maxHeight:`min(100%, ${u.height}px)`},className:`max-w-full max-h-full block shadow-2xl ${C?`cursor-crosshair`:`cursor-default`}`,onPointerMove:we,onPointerDown:Ee,onPointerUp:ke,onContextMenu:e=>e.preventDefault(),onWheel:je}),C&&(0,$.jsx)(`div`,{className:`absolute inset-0 cursor-crosshair`,onPointerDown:Ie,onPointerMove:Le,onPointerUp:Re}),d===`connecting`&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`w-4 h-4 animate-spin`}),` `,s(`modal.status.opening`)]}),O&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 text-sm text-foreground bg-background-deep/40`,children:[(0,$.jsx)(rn,{className:`w-4 h-4 animate-spin`}),` `,s(`modal.status.capturing`)]})]}),Ue&&(0,$.jsx)(`div`,{className:`fixed border-2 border-accent-info bg-accent-info/10 pointer-events-none z-[81]`,style:{left:Ue.left,top:Ue.top,width:Ue.width,height:Ue.height}}),Be&&(0,$.jsx)(`div`,{className:`fixed border-2 border-accent-primary bg-accent-primary/10 pointer-events-none z-[81]`,style:Be})]}),C&&He&&He.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-1.5 border-t border-border/40 bg-surface/70 shrink-0 overflow-x-auto text-[11px]`,children:[V?(0,$.jsx)(Ds,{className:`w-3 h-3 shrink-0 text-accent-info`}):null,He.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(0,$.jsx)(Qt,{className:`w-3 h-3 text-muted-foreground/50 shrink-0`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Fe(e),title:e.selector,className:`shrink-0 font-mono px-1 rounded hover:bg-card/60 transition-colors ${t===He.length-1?`text-accent-info font-medium`:`text-foreground/70`}`,children:e.label})]},`${e.selector}-${t}`)),(0,$.jsx)(`span`,{className:`text-muted-foreground/60 shrink-0 ml-auto pl-2 hidden md:inline`,children:s(`modal.breadcrumb.hint`)})]}),C&&(0,$.jsx)(`div`,{className:`px-3 py-1.5 text-center text-[11px] text-muted-foreground border-t border-border/40 shrink-0`,children:s(`modal.select.hint`)})]})})}),document.body)}function Gz(e,t){t.push({type:`punct`,text:`<`});let n=1;e[n]===`/`&&(t.push({type:`punct`,text:`/`}),n++);let r=/^[a-zA-Z][a-zA-Z0-9-]*/.exec(e.slice(n));r&&(t.push({type:`tag`,text:r[0]}),n+=r[0].length);let i=e.slice(n,e.length-1),a=/(\s+)|([a-zA-Z_:][-a-zA-Z0-9_:.]*)|(=)|("[^"]*"|'[^']*')|(\/)/g,o;for(;(o=a.exec(i))!==null;)o[1]?t.push({type:`text`,text:o[1]}):o[2]?t.push({type:`attr`,text:o[2]}):o[3]?t.push({type:`punct`,text:`=`}):o[4]?t.push({type:`value`,text:o[4]}):o[5]&&t.push({type:`punct`,text:`/`});t.push({type:`punct`,text:`>`})}function Kz(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r===-1){n<e.length&&t.push({type:`text`,text:e.slice(n)});break}r>n&&t.push({type:`text`,text:e.slice(n,r)});let i=e.indexOf(`>`,r);if(i===-1){t.push({type:`text`,text:e.slice(r)});break}Gz(e.slice(r,i+1),t),n=i+1}return t}var qz={tag:`text-accent-info`,attr:`text-accent-secondary`,value:`text-accent-success`,punct:`text-muted-foreground`,text:`text-foreground/80`};function Jz(e){try{let t=new URL(e);return t.host+t.pathname}catch{return e}}var Yz=4e4;function Xz({html:e}){let t=(0,Q.useMemo)(()=>e.length>Yz?null:Kz(e),[e]);return t?(0,$.jsx)($.Fragment,{children:t.map((e,t)=>(0,$.jsx)(`span`,{className:qz[e.type],children:e.text},t))}):(0,$.jsx)($.Fragment,{children:e})}function Zz({dom:e,onRemove:t}){let{t:n}=K(`browser`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=Ee(e),m=e.designTokens,h=m?Object.entries(m.anchor):[],g=!!m&&(m.palette.length>0||h.length>0),_=e.networkRequests??[],v=_.length>0,y=(()=>{try{return new URL(e.url).host}catch{return e.url}})();return(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent-secondary/40 bg-accent-secondary/5 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,className:`flex items-center gap-2 flex-1 min-w-0 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,$.jsx)(Qt,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${r?`rotate-90`:``}`}),(0,$.jsx)(Lo,{className:`w-3.5 h-3.5 shrink-0 text-accent-secondary`}),(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n(`domPanel.header`,{title:e.title||y})})]}),(0,$.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:[n(`domPanel.badge.elements`,{count:p.nodeCount}),e.css?` · CSS`:``,g?` · ${n(`domPanel.badge.tokens`)}`:``,v?` · ${n(`domPanel.badge.requests`,{count:_.length})}`:``,p.truncated?` · ${n(`domPanel.badge.truncated`)}`:``]}),t&&(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`domPanel.removeLabel`),className:`shrink-0 text-muted-foreground/60 hover:text-destructive transition-colors`,children:(0,$.jsx)(mn,{className:`w-3.5 h-3.5`})})]}),r&&(0,$.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,$.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] text-muted-foreground truncate`,title:e.url,children:e.url}),(0,$.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 pb-3 text-[11px] leading-relaxed whitespace-pre-wrap break-words font-mono`,"data-testid":`captured-dom-html`,children:e.html?(0,$.jsx)(Xz,{html:e.html}):n(`domPanel.noMarkup`)}),e.css&&(0,$.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`flex items-center gap-2 w-full px-3 py-2 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,$.jsx)(Qt,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${a?`rotate-90`:``}`}),(0,$.jsx)(Fs,{className:`w-3.5 h-3.5 shrink-0 text-accent-highlight`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.cssTruncated?n(`domPanel.appliedCssTruncated`):n(`domPanel.appliedCss`)})]}),a&&(0,$.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 pb-3 text-[11px] leading-relaxed whitespace-pre-wrap break-words font-mono text-accent-success/90`,"data-testid":`captured-dom-css`,children:e.css})]}),g&&m&&(0,$.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,className:`flex items-center gap-2 w-full px-3 py-2 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,$.jsx)(Qt,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${s?`rotate-90`:``}`}),(0,$.jsx)(Hs,{className:`w-3.5 h-3.5 shrink-0 text-accent-highlight`}),(0,$.jsx)(`span`,{className:`font-medium`,children:n(`domPanel.designTokens`)})]}),s&&(0,$.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,"data-testid":`captured-dom-tokens`,children:[m.palette.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:m.palette.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border/50 px-1.5 py-0.5 font-mono text-[10px] text-foreground/80`,children:[(0,$.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-sm border border-border/40`,style:{background:e},"aria-hidden":!0}),e]},t))}),h.length>0&&(0,$.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 font-mono text-[11px]`,children:h.map(([e,t])=>(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,$.jsx)(`dd`,{className:`text-accent-success/90 break-all`,children:t})]},e))}),m.fonts.length>0&&(0,$.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[n(`domPanel.fonts`),` `,(0,$.jsx)(`span`,{className:`font-mono text-foreground/80 break-all`,children:m.fonts.join(`, `)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{try{navigator.clipboard?.writeText(JSON.stringify(m,null,2)),f(!0),setTimeout(()=>f(!1),1500)}catch{}},className:`text-[10px] text-accent-info hover:underline`,children:n(d?`domPanel.copied`:`domPanel.copyJson`)})]})]}),v&&(0,$.jsxs)(`div`,{className:`border-t border-accent-secondary/30`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-expanded":l,className:`flex items-center gap-2 w-full px-3 py-2 text-left text-foreground/90 hover:text-foreground transition-colors`,children:[(0,$.jsx)(Qt,{className:`w-3.5 h-3.5 shrink-0 transition-transform ${l?`rotate-90`:``}`}),(0,$.jsx)(Ms,{className:`w-3.5 h-3.5 shrink-0 text-accent-info`}),(0,$.jsx)(`span`,{className:`font-medium`,children:n(`domPanel.network`,{count:_.length})})]}),l&&(0,$.jsx)(`div`,{className:`max-h-64 overflow-auto px-3 pb-3 space-y-1.5`,"data-testid":`captured-dom-network`,children:_.map((e,t)=>(0,$.jsxs)(`div`,{className:`font-mono text-[11px] leading-snug`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`text-accent-highlight shrink-0`,children:e.method}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums ${e.failed?`text-destructive`:(e.status??0)>=400?`text-accent-warning`:`text-accent-success/90`}`,children:e.failed?`ERR`:e.status??`…`}),(0,$.jsx)(`span`,{className:`truncate flex-1 text-foreground/80`,title:e.url,children:Jz(e.url)}),e.durationMs!=null&&(0,$.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.durationMs,`ms`]})]}),e.responseShape&&(0,$.jsxs)(`div`,{className:`pl-4 text-accent-info/80 break-all whitespace-pre-wrap`,children:[`→ `,e.responseShape]})]},t))})]})]})]})}var Qz={critical:`bg-destructive/15 text-destructive`,high:`bg-accent-warning/15 text-accent-warning`,medium:`bg-accent-info/15 text-accent-info`,low:`bg-muted text-muted-foreground`},$z=[`critical`,`high`,`medium`,`low`];function eB(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function tB({open:e,onClose:t,tickets:n,onExploreLaunch:r}){let{t:i}=K(`addspec`),{t:a}=K(`jira`),o=fe(),{activeProjectId:s,projects:c}=at(),l=tz(),[u,d]=(0,Q.useState)(`quick`),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(()=>eB()),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)([]),w=ke(),T=(0,Q.useRef)(null),D=(0,Q.useRef)(!1),O=(0,Q.useRef)(!1),[k,j]=(0,Q.useState)(``),M=(0,Q.useRef)(!1),[N,P]=(0,Q.useState)(`medium`),[F,I]=(0,Q.useState)(),[L,R]=(0,Q.useState)([]),[z,B]=(0,Q.useState)(null),{model:ee,setModel:V,allowed:H,customModelAliases:te,loading:ne,provider:re,providers:ie}=hz(s,e,z);(0,Q.useEffect)(()=>{!e||z||ie.length===0||B(Lz(s,ie,re??`claude`))},[e,z,ie,re,s]);let ae=(0,Q.useCallback)(e=>{B(e),Rz(s,e)},[s]),oe=z??re,se=oe==null||rr(oe),ce=oe==null||ar(oe),le=oe==null||pr(oe),{scope:ue,setScope:de,persist:pe}=zz(s,u,e),me=Vz(s,e),{data:he,isError:ge}=Bz(s,e),_e=(0,Q.useCallback)(e=>{let t=ce?e.userMcp:!1,n=le?e.contractRefine:!1;return t===e.userMcp&&n===e.contractRefine?e:{...e,userMcp:t,contractRefine:n}},[ce,le]),ve=(0,Q.useMemo)(()=>_e(ue),[ue,_e]),ye=(0,Q.useMemo)(()=>yz(ve),[ve]),U=sr(oe);(0,Q.useEffect)(()=>{e&&u===`quick`&&!se&&d(`explore`)},[e,u,se]),(0,Q.useEffect)(()=>{u!==`quick`||!me.loaded||O.current||!le||de(e=>({...e,contractRefine:me.value}))},[u,me.loaded,me.value,de,le]),(0,Q.useEffect)(()=>{ue!==ve&&de(ve)},[ue,ve,de]);let be=(0,Q.useCallback)(e=>{O.current=!0,de(t=>_e(typeof e==`function`?e(t):e))},[de,_e]);(0,Q.useEffect)(()=>{O.current=!1},[u]);let xe=(0,Q.useRef)(s);(0,Q.useEffect)(()=>{xe.current=s},[s]);let Se=(0,Q.useRef)(c);(0,Q.useEffect)(()=>{Se.current=c},[c]),(0,Q.useEffect)(()=>{e&&(y(eB()),d(`quick`),p(!1),h(!1),_(0),B(null),x(!1),C([]),j(``),P(`medium`),R([]),I(void 0),D.current=!1,O.current=!1,M.current=!1,setTimeout(()=>{T.current?.resetHeight(),T.current?.focus()},50))},[e]),(0,Q.useEffect)(()=>{!e&&!D.current&&g>0&&A(v).catch(e=>console.warn(`[ProposeSpec] cleanup failed:`,e))},[e]);let Ce=(0,Q.useMemo)(()=>(m||S.length>0)&&!f&&(u===`free`||!ne&&ee!==null)&&(u!==`quick`||se),[m,S.length,f,u,se,ne,ee]),W=(0,Q.useCallback)(e=>{if(e.rawScreenshot&&e.rawScreenshot.id!==e.screenshot.id){let t=xe.current;fetch(`${He}/api/projects/${t}/tickets/${v}/attachments/${e.rawScreenshot.id}`,{method:`DELETE`}).catch(()=>{})}let t=e.breakpoints?Object.entries(e.breakpoints).map(([e,t])=>({key:e,attachmentId:t.attachment.id,dataUrl:t.dataUrl,width:t.viewport.width})):void 0;C(n=>[...n,{screenshotId:e.screenshot.id,screenshotName:e.screenshot.filename,screenshotDataUrl:e.screenshotDataUrl,domAttachmentId:e.domAttachment.id,dom:e.dom,breakpoints:t}]),_(e=>e+1+(t?t.length:1))},[v]),we=(0,Q.useCallback)(e=>{C(t=>t.filter(t=>t.domAttachmentId!==e.domAttachmentId));let t=new Set([e.screenshotId,e.domAttachmentId,...e.breakpoints?.map(e=>e.attachmentId)??[]]);_(e=>Math.max(0,e-t.size));let n=xe.current;for(let e of t)fetch(`${He}/api/projects/${n}/tickets/${v}/attachments/${e}`,{method:`DELETE`}).catch(()=>{})},[v]),Te=(0,Q.useCallback)(async()=>{let e=(T.current?.getPlainText().trim()??``)||(S.length>0?`Create a spec based on the captured browser selection (a screenshot and the page DOM are attached for reference).`:``);if(!e)return;let a=S.find(e=>e.breakpoints&&e.breakpoints.length>1);if(a){let t=a.breakpoints.map(e=>`${e.width}px`).join(`, `);e+=`${e?`
53
+
54
+ `:``}This element must be responsive: reference screenshots are attached at ${t}.`}let o=[...T.current?.getAttachmentIds()??[],...S.flatMap(e=>[...e.breakpoints?e.breakpoints.map(e=>e.attachmentId):[e.screenshotId],e.domAttachmentId])],s=xe.current;if(!s||u!==`free`&&(ne||ee===null))return;if(u===`quick`&&!se){d(`explore`);return}if(u===`free`){let e=T.current?.getPlainText().trim()??``;if(!e)return;let n=T.current?.getAttachmentIds()??[];D.current=!0,p(!0);try{let r=await fetch(`${He}/api/projects/${s}/tickets/from-prompt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({description:e,title:k.trim()||void 0,labels:L.length>0?L:void 0,priority:N,structured:!1,...F?{repositoryIds:F}:{},attachmentIds:n,pendingSpecId:v})});if(!r.ok){D.current=!1,J.error(i(`proposeModal.toast.createFailed`));return}let a=(await r.json().catch(()=>({}))).ticket?.id;J.success(a?i(`proposeModal.toast.rawSavedWithId`,{id:a}):i(`proposeModal.toast.rawCreated`)),t()}catch(e){D.current=!1,console.error(`[ProposeSpec] from-prompt failed:`,e),J.error(i(`proposeModal.toast.createFailed`))}finally{p(!1)}return}if(u===`explore`){if(!r){J.error(i(`proposeModal.toast.exploreNotWired`));return}D.current=!0,pe(ve),r({idea:e,pendingSpecId:v,initialAttachmentIds:o,model:ee,provider:oe??void 0,contextScope:ve,...F?{repositoryIds:F}:{}}),t();return}let c=Se.current.find(e=>e.id===s)?.name??`Project`,f=`spec-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,m=e.length>45?e.slice(0,45)+`…`:e,g=new Set(n.map(e=>e.id)),y=Date.now();J.loading(`${c} · ${m}`,{id:f,description:i(`proposeModal.toast.generating`)}),D.current=!0,me.persist(ve.contractRefine),p(!0),T.current?.clear(),_(0),h(!1),C([]);let b={toastId:f,truncated:m,knownTicketIds:g,projectId:s,projectName:c,startTime:y,persistId:f};try{let t;try{t=await fetch(`${He}/api/projects/${s}/tickets/generate-spec`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({idea:e,attachmentIds:o,pendingSpecId:v,model:ee??void 0,aiEngine:oe??void 0,...F?{repositoryIds:F}:{},contextScope:{specrails:ve.specrails,openspec:ve.openspec,full:ve.full,mcp:ve.mcp,userMcp:ve.userMcp,contractRefine:ve.contractRefine},contractRefine:ve.contractRefine})})}catch(e){console.error(`[ProposeSpec] generate-spec fetch threw:`,e),J.error(i(`proposeModal.toast.failedToStart`,{projectName:c}),{id:f});return}if(!t.ok){J.error(i(`proposeModal.toast.failedToStart`,{projectName:c}),{id:f});return}let n=await t.json();l.registerFastSpec(n.requestId,b)}finally{p(!1)}},[u,n,l,v,t,r,ee,me,ve,oe,se,S,k,N,L,F,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{open:e,modal:!b,onOpenChange:e=>{!e&&!b&&t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-4xl flex flex-col gap-0 p-0 overflow-hidden`,children:[(0,$.jsxs)(Rn,{className:`px-5 py-4 border-b border-border/40 shrink-0`,children:[(0,$.jsxs)(Fn,{className:`text-sm flex items-center gap-2`,children:[(0,$.jsx)(un,{className:`w-4 h-4 text-primary/70`}),i(`proposeModal.title`)]}),(0,$.jsx)(Mn,{className:`sr-only`,children:i(`proposeModal.dialogDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col p-5 gap-4 flex-1 min-h-0 overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(nB,{value:u,onChange:d,fullCodebase:ve.full,quickAvailable:se}),u!==`free`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(_z,{value:oe??`claude`,providers:ie,onChange:ae,disabled:ne,ariaLabel:i(`proposeModal.engineAriaLabel`)}),(0,$.jsx)(mz,{value:ee,allowed:H,customModelAliases:te,loading:ne,onChange:V})]})]}),u!==`free`&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Pz,{value:ve,onChange:be,budget:he,budgetError:ge,model:ee??``,maxPresetId:u===`quick`?`max`:`desktop`,smashCapable:U}),(0,$.jsx)(Dz,{scope:ve,mode:u,onChange:be,label:i(`contextScope.fineTune`),showSummary:!1,userMcpSupported:ce,contractRefineSupported:le,providerLabel:ur(oe)})]}),(0,$.jsx)(tr,{value:F,onChange:I,disabled:f}),u===`free`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`raw-spec-title`,className:`text-xs font-medium text-muted-foreground whitespace-nowrap`,children:i(`proposeModal.raw.titleLabel`)}),(0,$.jsx)(`input`,{id:`raw-spec-title`,type:`text`,value:k,onChange:e=>{M.current=!0,j(e.target.value)},placeholder:i(`proposeModal.raw.titlePlaceholder`),"data-testid":`raw-title-input`,className:`flex-1 h-8 px-2.5 rounded-md bg-card/40 border border-border/40 text-sm text-foreground placeholder-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/40 focus-visible:border-accent-info/60 transition-colors`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:i(`proposeModal.raw.priorityLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":i(`proposeModal.raw.priorityLabel`),"data-testid":`raw-priority-group`,className:`inline-flex items-center gap-1 p-1 rounded-lg border border-border/50 bg-card/40`,children:$z.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":N===e,tabIndex:N===e?0:-1,onClick:()=>P(e),onKeyDown:e=>{let t=$z.indexOf(N);e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),P($z[Math.min(t+1,$z.length-1)])):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(e.preventDefault(),P($z[Math.max(t-1,0)]))},className:`px-2 py-1 rounded-md text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/40 ${N===e?Qz[e]:`text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:i(`proposeModal.priority.${e}`)},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-[12rem]`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:i(`proposeModal.raw.labelsLabel`)}),(0,$.jsxs)(`div`,{className:`flex-1 flex items-center flex-wrap gap-1 px-2 py-1 rounded-md border border-border/40 bg-card/40`,children:[L.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info text-[10px] font-medium`,children:[e,(0,$.jsx)(`button`,{type:`button`,"aria-label":i(`proposeModal.raw.removeLabel`,{label:e}),onClick:()=>R(t=>t.filter(t=>t!==e)),className:`text-accent-info/60 hover:text-accent-info`,children:`×`})]},e)),(0,$.jsx)(`input`,{type:`text`,"aria-label":i(`proposeModal.raw.addLabelAria`),"data-testid":`raw-label-input`,placeholder:L.length?``:i(`proposeModal.raw.labelPlaceholder`),className:`flex-1 min-w-[4rem] bg-transparent text-xs text-foreground placeholder-muted-foreground/50 focus-visible:outline-none`,onKeyDown:e=>{let t=e.target,n=t.value.trim();e.key===`Enter`&&n?(e.preventDefault(),R(e=>e.includes(n)?e:[...e,n]),t.value=``):e.key===`Backspace`&&!n&&L.length&&R(e=>e.slice(0,-1))}})]})]})]})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(u===`quick`?`proposeModal.modeDescription.quick`:u===`explore`?`proposeModal.modeDescription.explore`:`proposeModal.modeDescription.raw`)}),(0,$.jsx)(uz,{ref:T,ticketKey:v,placeholder:i(u===`quick`?`proposeModal.editorPlaceholder.quick`:u===`explore`?`proposeModal.editorPlaceholder.explore`:`proposeModal.editorPlaceholder.raw`),minHeight:u===`free`?220:160,autoFocus:!0,ariaLabel:i(u===`free`?`proposeModal.raw.bodyAriaLabel`:`proposeModal.ideaAriaLabel`),onChange:()=>{let e=T.current?.getPlainText()??``;if(h(e.trim().length>0),u===`free`&&!M.current){let t=e.split(`
55
+ `).find(e=>e.trim().length>0)?.trim().slice(0,120)??``;j(t)}},onAttachmentAdded:()=>_(e=>e+1),onAttachmentRemoved:e=>{_(e=>Math.max(0,e-1)),fetch(`${He}/api/projects/${xe.current}/tickets/${v}/attachments/${e.id}`,{method:`DELETE`}).catch(()=>{})},onUnsupportedFile:e=>J.error(i(`proposeModal.toast.unsupportedFileType`,{name:e.name})),onUploadError:(e,t)=>J.error(i(`proposeModal.toast.uploadFailed`,{name:t.name,message:e.message})),onSubmit:Te,footerExtra:u!==`free`&&w&&s?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>x(!0),"data-testid":`from-browser-btn`,title:i(`proposeModal.fromWebsiteTitle`),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md border border-accent-info/50 text-accent-info hover:bg-accent-info/10 transition-colors font-medium`,children:[(0,$.jsx)(E,{className:`w-3.5 h-3.5`}),(0,$.jsx)(`span`,{children:i(`proposeModal.fromWebsite`)})]}):void 0}),u!==`free`&&S.length>0&&(0,$.jsx)(`div`,{className:`space-y-3`,"data-testid":`captured-dom-list`,children:S.map(e=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent-secondary/40 bg-accent-secondary/5 p-2 space-y-1.5`,children:[e.breakpoints?(0,$.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`capture-breakpoints`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium text-accent-highlight`,children:[(0,$.jsx)(Ks,{className:`w-3 h-3 shrink-0`}),i(`proposeModal.capture.responsiveSizes`,{count:e.breakpoints.length})]}),(0,$.jsx)(`div`,{className:`flex items-end justify-center gap-2 flex-wrap`,children:e.breakpoints.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsx)(`img`,{src:e.dataUrl,alt:`${e.key} (${e.width}px)`,className:`max-h-36 w-auto max-w-[10rem] object-contain rounded border border-border/60 bg-background-deep block`}),(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.key,` · `,e.width,`px`]})]},e.key))})]}):(0,$.jsx)(`img`,{src:e.screenshotDataUrl,alt:e.screenshotName,className:`max-h-44 w-auto max-w-full object-contain rounded border border-border/60 bg-background-deep mx-auto block`}),e.dom.url&&e.dom.url!==`about:blank`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,title:e.dom.url,children:[(0,$.jsx)(E,{className:`w-3 h-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.dom.url})]})]}),(0,$.jsx)(Zz,{dom:e.dom,onRemove:()=>we(e)})]},e.domAttachmentId))}),o.connected&&u===`quick`&&(0,$.jsx)(`div`,{className:`flex items-center justify-end text-[11px]`,"data-testid":`jira-create-indicator`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-info`,children:[(0,$.jsx)(Us,{className:`w-3 h-3`}),a(`addSpec.willCreate`,{key:o.jiraProjectKey??``})]})}),(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsxs)(Z,{size:`sm`,onClick:Te,disabled:!Ce,title:Ce?void 0:i(`proposeModal.submit.disabledTitle`),className:`gap-1.5 ${u===`free`?`bg-accent-info text-white hover:bg-accent-info/90`:bz(ye)}`,"data-testid":`propose-submit`,children:[u===`free`?(0,$.jsx)(Bs,{className:`w-3.5 h-3.5`}):(0,$.jsx)(tc,{className:`w-3.5 h-3.5`}),i(u===`quick`?`proposeModal.submit.quick`:u===`explore`?`proposeModal.submit.explore`:`proposeModal.submit.raw`)]})})]})]})}),w&&b&&s&&(0,$.jsx)(Wz,{open:b,onClose:()=>x(!1),projectId:s,pendingSpecId:v,onCaptured:W})]})}function nB({value:e,onChange:t,fullCodebase:n,quickAvailable:r}){let{t:i}=K(`addspec`),a=i(`proposeModal.mode.quickUnavailable`);return(0,$.jsxs)(`div`,{role:`tablist`,"aria-label":i(`proposeModal.modeTablistLabel`),className:`inline-flex items-center gap-1 p-1 rounded-lg border border-border/50 bg-card/40 self-start`,children:[(0,$.jsx)(rB,{active:e===`quick`,icon:(0,$.jsx)(hn,{className:`w-3.5 h-3.5`}),label:i(`proposeModal.mode.quick`),hint:r?Tz({specrails:!1,openspec:!1,full:n,mcp:!1,contractRefine:!1}):a,onClick:()=>t(`quick`),disabled:!r,disabledReason:a}),(0,$.jsx)(rB,{active:e===`explore`,icon:(0,$.jsx)(Yt,{className:`w-3.5 h-3.5`}),label:i(`proposeModal.mode.explore`),hint:i(`proposeModal.mode.exploreHint`),onClick:()=>t(`explore`)}),(0,$.jsx)(rB,{active:e===`free`,icon:(0,$.jsx)(Bs,{className:`w-3.5 h-3.5`}),label:i(`proposeModal.mode.raw`),hint:i(`proposeModal.mode.rawHint`),onClick:()=>t(`free`)})]})}function rB({active:e,icon:t,label:n,hint:r,onClick:i,disabled:a=!1,disabledReason:o}){return(0,$.jsxs)(`button`,{role:`tab`,type:`button`,"aria-selected":e,disabled:a,title:a?o:r,onClick:i,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${a?`cursor-not-allowed text-muted-foreground/50 opacity-70`:e?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:[t,n,(0,$.jsx)(`span`,{className:`text-[10px] ${e?`text-primary/60`:`text-muted-foreground/60`}`,children:r})]})}var iB=`specrails.chatPanelOpen`,aB=(0,Q.createContext)(null);function oB(){return(0,Q.useContext)(aB)}function sB(){let{activeProjectId:e}=at(),[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(()=>{try{return localStorage.getItem(iB)===`true`}catch{return!1}}),{registerHandler:s,unregisterHandler:c}=qe(),l=(0,Q.useRef)(new Map),u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(u.current&&u.current!==e&&l.current.set(u.current,t),u.current=e,e){let t=l.current.get(e);t?(n(t),i(0)):(n([]),i(0))}async function r(){try{let t=nt(),r=await fetch(`${t}/chat/conversations`);if(!r.ok)return;let i=(await r.json()).conversations.slice(0,3),a=await Promise.all(i.map(async e=>{try{let t=await fetch(`${nt()}/chat/conversations/${e.id}/messages`),n=t.ok?await t.json():{messages:[]};return{id:e.id,title:e.title,model:e.model,provider:e.provider,messages:n.messages,isStreaming:!1,streamingText:``,commandProposals:[]}}catch{return{id:e.id,title:e.title,model:e.model,provider:e.provider,messages:[],isStreaming:!1,streamingText:``,commandProposals:[]}}}));n(a),e&&l.current.set(e,a)}catch{}}r()},[e]);let d=(0,Q.useCallback)(e=>{let t=e;if(typeof t.type!=`string`)return;let r=nt(),i=r.startsWith(`/api/projects/`)?r.split(`/api/projects/`)[1]:null;if(!(i&&t.projectId&&t.projectId!==i)){if(t.type===`chat_stream`){let e=t.conversationId,r=t.delta;n(t=>t.map(t=>t.id===e?{...t,isStreaming:!0,streamingText:t.streamingText+r}:t))}else if(t.type===`chat_done`){let e=t.conversationId,r=t.fullText;n(t=>t.map(t=>{if(t.id!==e)return t;let n={id:Date.now(),conversation_id:e,role:`assistant`,content:r,created_at:new Date().toISOString()};return{...t,isStreaming:!1,streamingText:``,messages:[...t.messages,n]}}))}else if(t.type===`chat_error`){let e=t.conversationId;n(t=>t.map(t=>t.id===e?{...t,isStreaming:!1,streamingText:``}:t))}else if(t.type===`chat_command_proposal`){let e=t.conversationId,r=t.command;n(t=>t.map(t=>t.id===e&&!t.commandProposals.includes(r)?{...t,commandProposals:[...t.commandProposals,r]}:t))}else if(t.type===`chat_title_update`){let e=t.conversationId,r=t.title;n(t=>t.map(t=>t.id===e?{...t,title:r}:t))}}},[]);(0,Q.useLayoutEffect)(()=>(s(`chat`,d),()=>c(`chat`)),[d,s,c]);let f=(0,Q.useCallback)(()=>{o(e=>{let t=!e;try{localStorage.setItem(iB,String(t))}catch{}return t})},[]),p=(0,Q.useCallback)(async(e=`sonnet`)=>{try{let t=await fetch(`${nt()}/chat/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})});if(!t.ok)return;let r=await t.json(),a={id:r.conversation.id,title:r.conversation.title,model:r.conversation.model,provider:r.conversation.provider,messages:[],isStreaming:!1,streamingText:``,commandProposals:[]};n(e=>{let t=[...e,a].slice(0,3);return i(Math.min(e.length,2)),t})}catch{}},[]),m=(0,Q.useCallback)(async e=>{try{await fetch(`${nt()}/chat/conversations/${e}`,{method:`DELETE`})}catch{}n(t=>t.filter(t=>t.id!==e)),i(e=>Math.max(0,e-1))},[]),h=(0,Q.useCallback)(async(e,t,r)=>{let i={id:Date.now(),conversation_id:e,role:`user`,content:t,created_at:new Date().toISOString()};n(t=>t.map(t=>t.id===e?{...t,messages:[...t.messages,i],isStreaming:!0}:t));try{let n={text:t};r?.lightweight&&(n.lightweight=!0),r?.maxTurns!=null&&(n.maxTurns=r.maxTurns),r?.attachments&&r.attachments.ids.length>0&&(n.attachments=r.attachments),await fetch(`${nt()}/chat/conversations/${e}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})}catch{n(t=>t.map(t=>t.id===e?{...t,isStreaming:!1,messages:t.messages.filter(e=>e.id!==i.id)}:t)),J.error(G.t(`chat:errors.sendFailed`))}},[]),g=(0,Q.useCallback)(async e=>{try{await fetch(`${nt()}/chat/conversations/${e}/messages/stream`,{method:`DELETE`})}catch{}},[]),_=(0,Q.useCallback)(async e=>{try{await fetch(`${nt()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:e})})}catch{}},[]),v=(0,Q.useCallback)((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,commandProposals:n.commandProposals.filter(e=>e!==t)}:n))},[]),y=(0,Q.useCallback)(async(e,t)=>{n(n=>n.map(n=>n.id===e?{...n,model:t}:n));try{await fetch(`${nt()}/chat/conversations/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t})})}catch{}},[]);return{conversations:t,activeTabIndex:r,isPanelOpen:a,setActiveTabIndex:i,togglePanel:f,createConversation:p,deleteConversation:m,sendMessage:h,startWithMessage:(0,Q.useCallback)(async(e,t,r,a,o,s)=>{try{let c={model:r??void 0,kind:a??void 0};o&&a===`explore`&&(c.contextScope=o),s&&(c.aiEngine=s);let l=await fetch(`${nt()}/chat/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(c)});if(!l.ok)return null;let u=await l.json(),d={id:u.conversation.id,title:u.conversation.title,model:u.conversation.model,provider:u.conversation.provider??s??null,messages:[],isStreaming:!1,streamingText:``,commandProposals:[]};return n(e=>{let t=[...e,d].slice(-3);return i(t.length-1),t}),h(u.conversation.id,e,t),u.conversation.id}catch{return null}},[h]),hydrateConversation:(0,Q.useCallback)(async e=>{if(!t.some(t=>t.id===e))try{let t=await fetch(`${nt()}/chat/conversations/${e}`);if(!t.ok)return;let r=await t.json(),i={id:r.conversation.id,title:r.conversation.title,model:r.conversation.model,provider:r.conversation.provider,messages:r.messages,isStreaming:!1,streamingText:``,commandProposals:[]};n(t=>t.some(t=>t.id===e)?t:[...t,i])}catch{}},[t]),abortStream:g,confirmCommand:_,dismissCommandProposal:v,changeConversationModel:y}}function cB(e,t){let{registerHandler:n,unregisterHandler:r}=qe(),i=(0,Q.useRef)(t?Object.keys(t).filter(e=>t[e]!==void 0):[]),a=(0,Q.useRef)({...Wt,...t??{}}),[o,s]=(0,Q.useState)(a.current),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)([]),m=(0,Q.useRef)(new Set(i.current)),[h,g]=(0,Q.useState)(i.current.length>0);return(0,Q.useEffect)(()=>{if(s(a.current),l(!1),d([]),p([]),m.current=new Set(i.current),g(i.current.length>0),!e)return;let t=!1;return(async()=>{try{let n=await fetch(`${nt()}/chat/conversations/${e}/spec-draft`);if(!n.ok)return;let r=await n.json();if(t||!r.draft)return;let i=m.current;s(e=>{let t={...e};for(let e of Bt){if(i.has(e))continue;let n=r.draft[e];n!==void 0&&(t[e]=n)}return t}),l(r.ready),d(r.chips.slice(0,3))}catch{}})(),()=>{t=!0}},[e]),(0,Q.useEffect)(()=>{if(!e)return;let t=`spec-draft-stream:${e}`;return n(t,t=>{if(!qt(t)||t.conversationId!==e)return;let n=m.current,r=[];s(e=>{let i={...e};for(let e of Bt){if(n.has(e))continue;let a=t.draft[e];if(a===void 0)continue;let o=!lB(i[e],a);i[e]=a,o&&r.push(e)}return i}),l(t.ready),d(t.chips.slice(0,3)),p(r)}),()=>r(t)},[e,n,r]),{draft:o,ready:c,chips:u,lastChangedFields:f,hasManualOverrides:h,setField:(0,Q.useCallback)((e,t)=>{m.current.add(e),g(!0),s(n=>({...n,[e]:t}))},[]),clearManualOverrides:(0,Q.useCallback)(()=>{m.current.size!==0&&(m.current=new Set,g(!1))},[])}}function lB(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return!1}var uB=[`low`,`medium`,`high`,`critical`];function dB({draft:e,ready:t,flashFields:n,onFieldChange:r,attachments:i=[],onRemoveAttachment:a}){let{t:o}=K(`explore`);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex-shrink-0 px-5 py-3 border-b border-border/40 flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(un,{className:`w-4 h-4 text-primary/70`}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:o(`common:status.draft`)})]}),t&&(0,$.jsxs)(`span`,{role:`status`,"aria-live":`polite`,className:`text-[10px] text-primary/80 bg-primary/10 rounded-full px-2 py-0.5 flex items-center gap-1`,children:[(0,$.jsx)(un,{className:`w-3 h-3`}),o(`draftPanel.ready`)]})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 pb-32 space-y-4`,children:[(0,$.jsx)(fB,{label:o(`draftPanel.titleLabel`),flash:n.includes(`title`),children:(0,$.jsx)(`input`,{type:`text`,value:e.title,onChange:e=>r(`title`,e.target.value),placeholder:o(`draftPanel.titlePlaceholder`),className:`w-full px-3 py-2 text-sm rounded-md border border-border/50 bg-background focus:outline-none focus:ring-2 focus:ring-primary/40`,"aria-label":o(`draftPanel.titleAriaLabel`)})}),(0,$.jsx)(fB,{label:o(`draftPanel.priorityLabel`),flash:n.includes(`priority`),children:(0,$.jsx)(`select`,{value:e.priority,onChange:e=>r(`priority`,e.target.value),className:`w-full px-3 py-2 text-sm rounded-md border border-border/50 bg-background focus:outline-none focus:ring-2 focus:ring-primary/40`,"aria-label":o(`draftPanel.priorityAriaLabel`),children:uB.map(e=>(0,$.jsx)(`option`,{value:e,children:o(`priority.${e}`)},e))})}),(0,$.jsx)(tr,{value:e.repositoryIds,onChange:e=>r(`repositoryIds`,e)}),(0,$.jsx)(fB,{label:o(`draftPanel.labelsLabel`),flash:n.includes(`labels`),children:(0,$.jsx)(pB,{labels:e.labels,onChange:e=>r(`labels`,e)})}),(0,$.jsx)(fB,{label:o(`draftPanel.descriptionLabel`),flash:n.includes(`description`),children:(0,$.jsx)(`textarea`,{value:e.description,onChange:e=>r(`description`,e.target.value),rows:5,placeholder:o(`draftPanel.descriptionPlaceholder`),className:`w-full px-3 py-2 text-sm rounded-md border border-border/50 bg-background focus:outline-none focus:ring-2 focus:ring-primary/40 resize-none`,"aria-label":o(`draftPanel.descriptionAriaLabel`)})}),(0,$.jsx)(fB,{label:o(`draftPanel.acceptanceCriteriaLabel`),flash:n.includes(`acceptanceCriteria`),children:(0,$.jsx)(gB,{items:e.acceptanceCriteria,onChange:e=>r(`acceptanceCriteria`,e)})})]}),i.length>0&&(0,$.jsxs)(`div`,{className:`flex-shrink-0 px-5 py-3 border-t border-border/40 bg-card/40`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground/80 font-medium`,children:o(`draftPanel.attachmentsHeading`,{count:i.length})}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:o(`draftPanel.linkedOnCreate`)})]}),(0,$.jsx)(mB,{items:i,onRemove:a})]})]})}function fB({label:e,flash:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(t)return i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),700),()=>{a.current&&clearTimeout(a.current)}},[t]),(0,$.jsxs)(`div`,{className:`space-y-1.5 transition-colors duration-200 ${r?`bg-primary/[0.06] -mx-2 px-2 py-1 rounded`:``}`,children:[(0,$.jsx)(`label`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground/80 font-medium`,children:e}),n]})}function pB({labels:e,onChange:t}){let{t:n}=K(`explore`),[r,i]=(0,Q.useState)(``);function a(){let n=r.trim();if(!n||e.includes(n)){i(``);return}t([...e,n]),i(``)}function o(n){t(e.filter(e=>e!==n))}return(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 p-1.5 rounded-md border border-border/50 bg-background min-h-[36px]`,children:[e.map(e=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full bg-primary/10 text-primary/90`,children:[e,(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`hover:text-foreground`,"aria-label":n(`draftPanel.removeLabelAriaLabel`,{label:e}),children:(0,$.jsx)(mn,{className:`w-3 h-3`})})]},e)),(0,$.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),a()):n.key===`Backspace`&&!r&&e.length>0&&t(e.slice(0,-1))},onBlur:a,placeholder:e.length===0?n(`draftPanel.addLabelsPlaceholder`):``,className:`flex-1 min-w-[80px] bg-transparent text-xs focus:outline-none`,"aria-label":n(`draftPanel.addLabelAriaLabel`)})]})}function mB({items:e,onRemove:t}){let{t:n}=K(`explore`);return(0,$.jsx)(`ul`,{className:`space-y-1`,"aria-label":n(`draftPanel.attachmentsListAriaLabel`),children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border/40 bg-card/40 text-xs`,children:[(0,$.jsx)(e.mimeType.startsWith(`image/`)?_s:$t,{className:`w-3.5 h-3.5 text-primary/70 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,title:`${e.filename} · ${hB(e.size)}`,children:e.filename}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60 flex-shrink-0`,children:hB(e.size)}),t&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`text-muted-foreground hover:text-destructive flex-shrink-0`,"aria-label":n(`draftPanel.removeAttachmentAriaLabel`,{filename:e.filename}),children:(0,$.jsx)(mn,{className:`w-3 h-3`})})]},e.id))})}function hB(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function gB({items:e,onChange:t}){let{t:n}=K(`explore`);function r(n,r){let i=e.slice();i[n]=r,t(i)}function i(n){t(e.filter((e,t)=>t!==n))}function a(){t([...e,``])}return(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`•`}),(0,$.jsx)(`input`,{value:e,onChange:e=>r(t,e.target.value),placeholder:n(`draftPanel.criterionPlaceholder`),className:`flex-1 px-2 py-1 text-xs rounded border border-border/50 bg-background focus:outline-none focus:ring-1 focus:ring-primary/40`,"aria-label":n(`draftPanel.criterionAriaLabel`,{number:t+1})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(t),className:`text-muted-foreground hover:text-destructive`,"aria-label":n(`draftPanel.removeCriterionAriaLabel`,{number:t+1}),children:(0,$.jsx)(mn,{className:`w-3.5 h-3.5`})})]},t)),(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,"aria-label":n(`draftPanel.addCriterionAriaLabel`),children:[(0,$.jsx)(cn,{className:`w-3 h-3`}),` `,n(`draftPanel.addCriterion`)]})]})}var _B=!0,vB=150,yB={connecting:`statusPills.connecting`,thinking:`statusPills.thinking`,tool:`statusPills.tool`};function bB({active:e,hasSystemEvent:t,hasToolUse:n,hasText:r,minDisplayMs:i=vB}){let{t:a}=K(`explore`),[o,s]=(0,Q.useState)(`connecting`),c=(0,Q.useRef)(Date.now()),l=(0,Q.useRef)(null),u=r?`streaming`:n?`tool`:t?`thinking`:`connecting`;if((0,Q.useEffect)(()=>{if(u===o)return;let e=Date.now()-c.current,t=Math.max(0,i-e);return l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{s(u),c.current=Date.now(),l.current=null},t),()=>{l.current&&clearTimeout(l.current)}},[u,o,i]),!_B||!e||o===`streaming`)return null;let d=a(yB[o]);return(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full bg-accent-info/10 text-accent-info px-3 py-1 text-[11px] font-medium`,role:`status`,"aria-live":`polite`,"data-testid":`explore-status-pill`,"data-stage":o,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:d})]})}var xB=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends xB{};function SB(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function CB(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function wB(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function TB(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function EB(e,t){return wB(e,t,``)}function DB(e,t){return TB(e,t,``)}function OB(e,t){return t.slice(0,kB(e,t))}function kB(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function AB(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function jB(e,t){if(t)return NB(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function MB(e,t){if(t)return NB(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function NB(e,t){if(!t)return[MB(e),jB(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=AB(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var PB=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,FB=RegExp(`[${PB}]+|\\s+|[^${PB}]`,`ug`),IB=new class extends xB{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=AB(e,r)}else n=e.match(FB)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&RB(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&RB(n,i,r,null,t.intlSegmenter),e}};function LB(e,t,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?BB(e,t,n):IB.diff(e,t,n)}function RB(e,t,n,r,i){if(t&&n){let[a,o]=NB(t.value,i),[s,c]=NB(n.value,i);if(e){let r=SB(a,s);e.value=TB(e.value,s,r),t.value=EB(t.value,r),n.value=EB(n.value,r)}if(r){let e=CB(o,c);r.value=wB(r.value,c,e),t.value=DB(t.value,e),n.value=DB(n.value,e)}}else if(n){if(e){let e=MB(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=MB(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=MB(r.value,i),[a,o]=NB(t.value,i),s=SB(n,a);t.value=EB(t.value,s);let c=CB(EB(n,s),o);t.value=DB(t.value,c),r.value=wB(r.value,n,c),e.value=TB(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=MB(r.value,i),n=OB(jB(t.value,i),e);t.value=DB(t.value,n)}else if(e){let n=OB(jB(e.value,i),MB(t.value,i));t.value=EB(t.value,n)}}var zB=new class extends xB{tokenize(e){let t=RegExp(`(\\r?\\n)|[${PB}]+|[^\\S\\n\\r]+|[^${PB}]`,`ug`);return e.match(t)||[]}};function BB(e,t,n){return zB.diff(e,t,n)}new class extends xB{constructor(){super(...arguments),this.tokenize=VB}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
56
+ `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
57
+ `))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
58
+ `)&&(e=e.slice(0,-1)),t.endsWith(`
59
+ `)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function VB(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
60
+ `));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function HB(e){return e==`.`||e==`!`||e==`?`}new class extends xB{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(HB(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends xB{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends xB{constructor(){super(...arguments),this.tokenize=VB}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(UB(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function UB(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=UB(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=UB(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends xB{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function WB(e,t){return LB(e,t).map(e=>({value:e.value,...e.added?{added:!0}:{},...e.removed?{removed:!0}:{}}))}function GB(e,t,n=(e,t)=>e===t){let r=t=>e.some(e=>n(e,t)),i=e=>t.some(t=>n(t,e)),a=[],o=[],s=[];for(let e of t)a.some(t=>n(t.value,e))||(r(e)?(s.push(e),a.push({value:e,status:`unchanged`})):(o.push(e),a.push({value:e,status:`added`})));let c=[];for(let t of e)c.some(e=>n(e,t))||i(t)||(c.push(t),a.push({value:t,status:`removed`}));return{added:o,removed:c,unchanged:s,ordered:a}}var KB={title:``,description:``,labels:[],priority:null,acceptanceCriteria:[]};function qB({baseline:e,proposed:t,isCommitting:n,mode:r=`create`,onBack:i,onCommit:a}){let{t:o}=K(`explore`),{activeProjectId:s,projects:c}=at(),l=er(c.find(e=>e.id===s)),u=l.filter(e=>e.isPrimary).map(e=>e.id),d=e=>e.map(e=>l.find(t=>t.id===e)?.name??e),f=GB(d(e.repositoryIds??u),d(t.repositoryIds??u)),p=(0,Q.useMemo)(()=>WB(e.title,t.title),[e.title,t.title]),m=(0,Q.useMemo)(()=>WB(e.description,t.description),[e.description,t.description]),h=(0,Q.useMemo)(()=>GB(e.labels,t.labels),[e.labels,t.labels]),g=(0,Q.useMemo)(()=>GB(e.acceptanceCriteria,t.acceptanceCriteria),[e.acceptanceCriteria,t.acceptanceCriteria]),_=e.priority!==t.priority;return(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,xb.createPortal)((0,$.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":o(`reviewOverlay.dialogAriaLabel`),"data-testid":`explore-review-overlay`,className:`fixed inset-0 z-[60] flex items-stretch justify-center bg-black/70 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex flex-col w-full max-w-5xl h-full bg-background border-x border-border/30 shadow-2xl`,children:[(0,$.jsx)(`header`,{className:`flex items-center justify-between px-6 py-4 border-b border-border/30`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold`,children:o(`reviewOverlay.eyebrow`)}),(0,$.jsx)(`h2`,{className:`text-base font-semibold mt-0.5`,children:o(`reviewOverlay.heading`)})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,$.jsxs)(`section`,{"data-testid":`review-title`,className:`space-y-2`,children:[(0,$.jsx)(JB,{label:o(`reviewOverlay.titleLabel`)}),(0,$.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words rounded-lg bg-card/40 border border-border/30 px-3 py-2`,children:(0,$.jsx)(YB,{parts:p})})]}),(0,$.jsxs)(`section`,{"data-testid":`review-priority`,className:`space-y-2`,children:[(0,$.jsx)(JB,{label:o(`reviewOverlay.priorityLabel`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(QB,{value:e.priority,removed:!0}),(0,$.jsx)(Qt,{className:`w-3 h-3 text-muted-foreground/60`,"aria-hidden":`true`}),(0,$.jsx)(QB,{value:t.priority,added:!0})]}):(0,$.jsx)(QB,{value:t.priority})})]}),(0,$.jsxs)(`section`,{"data-testid":`review-description`,className:`lg:col-span-2 space-y-2`,children:[(0,$.jsx)(JB,{label:o(`reviewOverlay.descriptionLabel`)}),(0,$.jsx)(`div`,{className:`text-xs font-mono whitespace-pre-wrap break-words rounded-lg bg-card/40 border border-border/30 px-3 py-3 leading-relaxed`,children:(0,$.jsx)(YB,{parts:m})})]}),l.length>1&&(0,$.jsxs)(`section`,{className:`space-y-2`,"data-testid":`review-repositories`,children:[(0,$.jsx)(JB,{label:o(`common:repositories.specScope`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.ordered.map((e,t)=>(0,$.jsx)(XB,{entry:e},t))})]}),(0,$.jsxs)(`section`,{"data-testid":`review-labels`,className:`space-y-2`,children:[(0,$.jsx)(JB,{label:o(`reviewOverlay.labelsLabel`)}),h.ordered.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 italic`,children:o(`reviewOverlay.noLabels`)}):(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.ordered.map((e,t)=>(0,$.jsx)(XB,{entry:e},`${e.status}-${t}`))})]}),(0,$.jsxs)(`section`,{"data-testid":`review-criteria`,className:`space-y-2`,children:[(0,$.jsx)(JB,{label:o(`reviewOverlay.acceptanceCriteriaLabel`)}),g.ordered.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 italic`,children:o(`reviewOverlay.noCriteria`)}):(0,$.jsx)(`ul`,{className:`space-y-1 text-sm`,children:g.ordered.map((e,t)=>(0,$.jsx)(ZB,{entry:e},`${e.status}-${t}`))})]})]})}),(0,$.jsxs)(`footer`,{className:`flex items-center justify-between gap-3 px-6 py-4 border-t border-border/30`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,disabled:n,"data-testid":`review-back`,children:[(0,$.jsx)(Rt,{className:`w-3.5 h-3.5`}),o(`reviewOverlay.backToEdit`)]}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,onClick:a,disabled:n||!t.title.trim(),"data-testid":`review-commit`,className:`gap-1.5`,children:[(0,$.jsx)(Ht,{className:`w-3.5 h-3.5`}),o(r===`edit`?`reviewOverlay.updateSpec`:`reviewOverlay.createSpec`)]})]})]})}),document.body)}function JB({label:e}){return(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold`,children:e})}function YB({parts:e}){let{t}=K(`explore`);return(0,$.jsx)($.Fragment,{children:e.map((e,n)=>e.added?(0,$.jsx)(`span`,{className:`diff-added`,"aria-label":t(`reviewOverlay.inserted`),children:e.value},n):e.removed?e.value.trim()?(0,$.jsx)(`span`,{className:`diff-removed`,"aria-label":t(`reviewOverlay.removed`),children:e.value},n):null:(0,$.jsx)(`span`,{children:e.value},n))})}function XB({entry:e}){let{t}=K(`explore`),n=`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px]`;return e.status===`added`?(0,$.jsxs)(`span`,{className:`${n} diff-chip-added`,"aria-label":t(`reviewOverlay.added`),children:[`+ `,e.value]}):e.status===`removed`?(0,$.jsxs)(`span`,{className:`${n} diff-chip-removed`,"aria-label":t(`reviewOverlay.removed`),children:[`− `,e.value]}):(0,$.jsx)(`span`,{className:`${n} bg-card/60 text-muted-foreground border border-border/40`,"aria-label":t(`reviewOverlay.unchanged`),children:e.value})}function ZB({entry:e}){let{t}=K(`explore`);return e.status===`added`?(0,$.jsxs)(`li`,{className:`diff-bullet-added rounded px-2 py-1 list-none`,"aria-label":t(`reviewOverlay.added`),children:[(0,$.jsx)(`span`,{className:`mr-1 font-mono`,children:`+`}),e.value]}):e.status===`removed`?(0,$.jsxs)(`li`,{className:`diff-bullet-removed rounded px-2 py-1 list-none`,"aria-label":t(`reviewOverlay.removed`),children:[(0,$.jsx)(`span`,{className:`mr-1 font-mono`,children:`−`}),e.value]}):(0,$.jsx)(`li`,{className:`text-foreground/90 list-disc list-inside`,"aria-label":t(`reviewOverlay.unchanged`),children:e.value})}function QB({value:e,added:t,removed:n}){let{t:r}=K(`explore`);if(!e)return(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 italic`,children:r(`reviewOverlay.noPriority`)});let i=`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] capitalize border`;return t?(0,$.jsx)(`span`,{className:`${i} diff-chip-added`,"aria-label":r(`reviewOverlay.added`),children:r(`priority.${e}`)}):n?(0,$.jsx)(`span`,{className:`${i} diff-chip-removed`,"aria-label":r(`reviewOverlay.removed`),children:r(`priority.${e}`)}):(0,$.jsx)(`span`,{className:`${i} bg-card/60 text-muted-foreground border-border/40`,children:r(`priority.${e}`)})}function $B(){return typeof window>`u`||!(`__TAURI_INTERNALS__`in window)?!1:/mac/i.test(navigator.platform)}function eV({initialIdea:e,pendingSpecId:t,initialAttachmentIds:n,initialModel:r,initialProvider:i,resumeConversationId:a,seedDraftTitle:o,seedComposerText:s,seedDraftOverrides:c,onClose:l,onMinimize:u,onStateChange:d,editTicket:f,onTicketCreated:p,contextScope:m}){let{t:h}=K(`explore`),{t:g}=K(`jira`),{panelRef:_,panelStyle:v,headerHandleProps:y,resizeHandles:b,isFloating:x}=bn(),S=fe(),C=oB(),{activeProjectId:w}=at(),[T]=(0,Q.useState)(()=>t&&t.trim()?t:L()),[O,A]=(0,Q.useState)(a??null),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(!1),[B,ee]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)([]),te=ke(),[ne,re]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)([]),oe=(0,Q.useRef)(w);(0,Q.useEffect)(()=>{oe.current=w},[w]);let se=(0,Q.useRef)(null),ce=(0,Q.useRef)(!1),le=(0,Q.useRef)(!1),ue=!!f&&f.status!==`draft`,de=!!f,pe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(!1),_e=(0,Q.useCallback)(()=>{let e=me.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;ge.current=t>100},[]),ve=(0,Q.useCallback)(async()=>{if(w)try{let e=await fetch(`${He}/api/projects/${w}/tickets/${T}/attachments`);if(!e.ok)return;let t=await e.json();H(t.attachments)}catch{}},[w,T]);(0,Q.useEffect)(()=>{ve()},[ve]);let ye=(0,Q.useRef)(null),U=(0,Q.useRef)(!1),be=(0,Q.useCallback)(e=>{if(e.rawScreenshot&&e.rawScreenshot.id!==e.screenshot.id){let t=oe.current;fetch(`${He}/api/projects/${t}/tickets/${T}/attachments/${e.rawScreenshot.id}`,{method:`DELETE`}).catch(()=>{})}let t=e.breakpoints?Object.entries(e.breakpoints).map(([e,t])=>({key:e,attachmentId:t.attachment.id,dataUrl:t.dataUrl,width:t.viewport.width})):void 0;ve();let n=[...t?t.map(e=>e.attachmentId):[e.screenshot.id],e.domAttachment.id];U.current&&ye.current?ye.current(n):ae(n=>[...n,{screenshotId:e.screenshot.id,screenshotName:e.screenshot.filename,screenshotDataUrl:e.screenshotDataUrl,domAttachmentId:e.domAttachment.id,dom:e.dom,breakpoints:t}])},[T,ve]),xe=(0,Q.useCallback)(e=>{ae(t=>t.filter(t=>t.domAttachmentId!==e.domAttachmentId));let t=new Set([e.screenshotId,e.domAttachmentId,...e.breakpoints?.map(e=>e.attachmentId)??[]]),n=oe.current;for(let e of t)fetch(`${He}/api/projects/${n}/tickets/${T}/attachments/${e}`,{method:`DELETE`}).catch(()=>{});H(e=>e.filter(e=>!t.has(e.id)))},[T]),Se=(0,Q.useCallback)(()=>ie.flatMap(e=>[...e.breakpoints?e.breakpoints.map(e=>e.attachmentId):[e.screenshotId],e.domAttachmentId]),[ie]);(0,Q.useEffect)(()=>{O&&ve()},[O,ve]),(0,Q.useEffect)(()=>{if(ce.current)return;if(a){ce.current=!0,C?.hydrateConversation?.(a);return}if(!C||(ce.current=!0,f))return;let t=`/specrails:explore-spec\n\n${e.trim()}`,o=n.length>0?{ticketKey:T,ids:n}:void 0;C.startWithMessage(t,{lightweight:!0,maxTurns:20,attachments:o},r,`explore`,m,i).then(e=>{e&&A(e)})},[C,e,T,n,a,r,i,f,m]),(0,Q.useEffect)(()=>(se.current=document.activeElement,()=>{let e=se.current;e&&e instanceof HTMLElement&&e.focus()}),[]);let Ce=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ce.current||!s)return;let e=setTimeout(()=>{pe.current?.setPlainText(s),P(s.trim().length>0),Ce.current=!0},0);return()=>clearTimeout(e)},[s]);let W=(0,Q.useMemo)(()=>{if(!(!C||!O))return C.conversations.find(e=>e.id===O)},[C,O]),we=W?.messages.length??0,Te=(0,Q.useRef)(we);Te.current=we;let Ee=jy(W?.streamingText??``,!!W?.isStreaming);(0,Q.useEffect)(()=>{if(ge.current)return;let e=me.current;e&&(W?.isStreaming||R?e.scrollTop=e.scrollHeight:he.current?.scrollIntoView({behavior:`smooth`,block:`end`}))},[we,Ee,W?.isStreaming,R]),(0,Q.useEffect)(()=>{ge.current=!1;let e=null,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>{let e=me.current;e&&(e.scrollTop=e.scrollHeight)})});return()=>{cancelAnimationFrame(t),e!=null&&cancelAnimationFrame(e)}},[]);let{draft:De,ready:Oe,chips:Ae,lastChangedFields:je,setField:Me,clearManualOverrides:Ne}=cB(O,f?{title:f.title,description:f.description,labels:f.labels,repositoryIds:f.repositoryIds,priority:f.priority??`medium`,acceptanceCriteria:f.acceptanceCriteria}:void 0),Pe=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Pe.current)return;if(f){Pe.current=!0;return}if(!c)return;Pe.current=!0;let e=c;e.title&&e.title.trim()&&Me(`title`,e.title),e.description&&e.description.trim()&&Me(`description`,e.description),e.priority&&e.priority!==`medium`&&Me(`priority`,e.priority),e.labels&&e.labels.length>0&&Me(`labels`,e.labels),e.repositoryIds?.length&&Me(`repositoryIds`,e.repositoryIds);let t=e.acceptanceCriteria?.filter(e=>e.trim().length>0)??[];t.length>0&&Me(`acceptanceCriteria`,t)},[c,Me,f]);let Fe=(0,Q.useCallback)(()=>{Te.current>1?M(!0):l()},[l]),Ie=(0,Q.useCallback)(async e=>{let t=e.trim();if(!t||!C)return;if(f&&!le.current){le.current=!0;let e=[...pe.current?.getAttachmentIds()??[],...Se()];pe.current?.clear(),P(!1),Ue(``),z(!0),Ne(),ie.length>0&&(ae([]),ve());let n=`/specrails:explore-spec\n\n${[`## Spec context`,`Ticket #${f.id}: ${f.title}`,``,f.description||`(no description)`].join(`
61
+ `)}\n\n---\n\n## Instruction\n\n${t}`,a=e.length>0?{ticketKey:T,ids:e}:void 0;W?await C.sendMessage(W.id,n,{lightweight:!0,maxTurns:20,attachments:a}):C.startWithMessage(n,{lightweight:!0,maxTurns:20,attachments:a},r,`explore`,void 0,i).then(e=>{e&&A(e)});return}if(!W||W.isStreaming)return;let n=[...pe.current?.getAttachmentIds()??[],...Se()];pe.current?.clear(),P(!1),Ue(``),z(!0),Ne(),ie.length>0&&ae([]),n.length>0&&ve(),await C.sendMessage(W.id,t,{lightweight:!0,maxTurns:20,attachments:n.length>0?{ticketKey:T,ids:n}:void 0})},[W,C,Ne,T,ve,f,r,Se,ie.length]),Le=(0,Q.useCallback)(async e=>{if(!C||e.length===0)return;let t=h(`shell.captureFeedbackPrompt`),n={ticketKey:T,ids:e};if(z(!0),Ne(),f&&!le.current){le.current=!0;let e=`/specrails:explore-spec\n\n${[`## Spec context`,`Ticket #${f.id}: ${f.title}`,``,f.description||`(no description)`].join(`
62
+ `)}\n\n---\n\n## Instruction\n\n${t}`;W?await C.sendMessage(W.id,e,{lightweight:!0,maxTurns:20,attachments:n}):C.startWithMessage(e,{lightweight:!0,maxTurns:20,attachments:n},r,`explore`,void 0,i).then(e=>{e&&A(e)});return}!W||W.isStreaming||await C.sendMessage(W.id,t,{lightweight:!0,maxTurns:20,attachments:n})},[C,W,f,T,r,i,Ne,h]);(0,Q.useEffect)(()=>{ye.current=Le},[Le]),(0,Q.useEffect)(()=>{U.current=!!C&&(W?!W.isStreaming:!!f&&!le.current)},[C,W,f]),(0,Q.useEffect)(()=>{W?.isStreaming&&z(!1)},[W?.isStreaming]);let Re=(0,Q.useCallback)(()=>{if(W?.isStreaming){(W.messages?.length??0)>1&&C&&C.abortStream(W.id);return}let e=pe.current?.getPlainText().trim()??``;e&&Ie(e)},[W,C,Ie]),ze=(0,Q.useCallback)(async()=>{if(!O||!w)return!1;try{let e={conversationId:O,title:De.title?.trim()||void 0,description:De.description||void 0,labels:De.labels,...De.repositoryIds?{repositoryIds:De.repositoryIds}:{}};f&&(e.editTicketId=f.id);let t=await fetch(`${nt()}/tickets/save-as-draft`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));return J.error(e.error||h(`shell.toasts.saveDraftFailed`)),!1}let n=await t.json();return J.success(h(`shell.toasts.draftSaved`,{id:n.ticket.id,title:n.ticket.title})),!0}catch{return J.error(h(`shell.toasts.draftNetworkError`)),!1}},[O,w,De.title,De.description,De.labels,De.repositoryIds,f,h]),Be=(0,Q.useCallback)(async()=>{if(!F&&!(!De.title.trim()||!w)){I(!0),D(w);try{if(ue&&f){let e=await fetch(`${nt()}/tickets/${f.id}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:De.title.trim(),description:De.description,labels:De.labels,...De.repositoryIds?{repositoryIds:De.repositoryIds}:{},priority:De.priority,acceptanceCriteria:De.acceptanceCriteria.filter(e=>e.trim().length>0)})});if(!e.ok){let t=await e.json().catch(()=>({}));J.error(t.error||h(`shell.toasts.updateSpecFailed`));return}let t=await e.json();J.success(h(`shell.toasts.specUpdated`,{id:t.ticket.id,title:t.ticket.title})),p?.(t.ticket),l();return}let e=await fetch(`${nt()}/tickets/from-draft`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:De.title.trim(),description:De.description,labels:De.labels,...De.repositoryIds?{repositoryIds:De.repositoryIds}:{},priority:De.priority,acceptanceCriteria:De.acceptanceCriteria.filter(e=>e.trim().length>0),pendingSpecId:T,conversationId:O,...f?{draftTicketId:f.id}:{}})});if(!e.ok){let t=await e.json().catch(()=>({}));J.error(t.error||h(`shell.toasts.createSpecFailed`));return}let t=await e.json();J.success(h(`shell.toasts.specCreated`,{id:t.ticket.id,title:t.ticket.title})),p?.(t.ticket),l()}catch{J.error(h(`shell.toasts.createNetworkError`))}finally{I(!1),k(w)}}},[F,De,w,p,l,T,f,ue,O,h]);(0,Q.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.preventDefault(),Fe())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Fe]);let G=(0,Q.useRef)(d);G.current=d;let[Ve,Ue]=(0,Q.useState)(s??``);(0,Q.useEffect)(()=>{G.current?.({conversationId:O,draftTitle:De.title,composerText:Ve,draftOverrides:{title:De.title,description:De.description,priority:De.priority,labels:De.labels,...De.repositoryIds?{repositoryIds:De.repositoryIds}:{},acceptanceCriteria:De.acceptanceCriteria}})},[O,De.title,De.description,De.priority,De.labels,De.acceptanceCriteria,De.repositoryIds,Ve]);let We=$B()?`pl-[88px]`:`pl-4`;return(0,xb.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex p-3 pt-10 sm:p-6 sm:pt-12 bg-black/40 backdrop-blur-sm animate-in fade-in duration-150`,"data-testid":`explore-spec-backdrop`,children:[(0,$.jsxs)(`div`,{ref:_,role:`dialog`,"aria-modal":`true`,"aria-label":h(`shell.dialogAriaLabel`),className:`m-auto w-full h-full max-w-[1600px] flex flex-col bg-background rounded-xl border border-border/40 shadow-2xl overflow-hidden`,style:v,children:[(0,$.jsxs)(`div`,{...y,className:`flex-shrink-0 flex items-center justify-between ${We} pr-4 h-14 border-b border-border bg-card/60 backdrop-blur-sm${x?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:Fe,className:`flex items-center gap-2 group p-1 -ml-1 rounded hover:bg-accent focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:outline-none`,"aria-label":h(`shell.backAriaLabel`),children:[(0,$.jsx)(Rt,{className:`w-4 h-4 text-muted-foreground group-hover:text-foreground`}),(0,$.jsxs)(`div`,{className:`text-left min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70 leading-none`,children:f?h(`shell.editingEyebrow`,{id:f.id}):h(`shell.exploreEyebrow`)}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate block`,children:De.title||o||h(`shell.newSpecPlaceholder`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m?(0,$.jsx)(`span`,{"data-testid":`explore-context-pill`,title:h(`shell.contextPillTitle`),className:`hidden md:inline-flex items-center gap-1 px-2 py-1 rounded-full border border-border/50 bg-card/60 text-[10px] text-muted-foreground`,children:h(`shell.contextPill`,{scopes:[m.specrails&&`specrails`,m.openspec&&`openspec`,m.full&&h(`shell.contextScopeCodebase`),m.mcp&&`mcp`].filter(Boolean).join(`, `)||h(`shell.contextScopeMinimal`)})}):null,(0,$.jsx)(Z,{size:`sm`,variant:`outline`,onClick:async()=>{await ze()&&l()},disabled:we<2||F,className:`gap-1.5`,"aria-label":h(`shell.saveAsDraftAriaLabel`),"data-testid":`explore-spec-save-draft`,title:we<2?h(`shell.saveAsDraftDisabledTitle`):void 0,children:h(`shell.saveAsDraft`)}),De.title.trim()&&(0,$.jsx)(Z,{size:`sm`,variant:`outline`,onClick:()=>ee(!0),disabled:F,className:`gap-1.5`,"aria-label":h(`shell.reviewAriaLabel`),"data-testid":`explore-spec-review`,children:h(`shell.review`)}),S.connected&&!ue&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] text-accent-info mr-1`,"data-testid":`jira-create-indicator`,title:g(`addSpec.willCreate`,{key:S.jiraProjectKey??``}),children:[(0,$.jsx)(Us,{className:`w-3 h-3 shrink-0`}),(0,$.jsx)(`span`,{className:`hidden lg:inline`,children:g(`addSpec.willCreate`,{key:S.jiraProjectKey??``})})]}),(0,$.jsxs)(Z,{size:`sm`,onClick:Be,disabled:!De.title.trim()||F,className:`gap-1.5`,"aria-label":h(de?`shell.updateSpecAriaLabel`:`shell.createSpecAriaLabel`),"data-testid":`explore-spec-create`,title:De.title.trim()?void 0:h(`shell.createSpecDisabledTitle`),children:[F?(0,$.jsx)(rn,{className:`w-3.5 h-3.5 animate-spin`}):Oe?(0,$.jsx)(un,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Ht,{className:`w-3.5 h-3.5`}),h(de?`shell.updateSpec`:`shell.createSpec`)]}),u&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:()=>u(O,De.title||o||``),"aria-label":h(`common:actions.minimize`),"data-testid":`explore-spec-minimize`,children:(0,$.jsx)(As,{className:`w-4 h-4`})}),(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:Fe,"aria-label":h(`common:actions.close`),children:(0,$.jsx)(mn,{className:`w-4 h-4`})})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-h-0 grid grid-cols-[1fr_360px] divide-x divide-border/40`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-h-0`,children:[(0,$.jsxs)(`div`,{ref:me,onScroll:_e,className:`flex-1 overflow-y-auto px-5 py-4 pb-24 space-y-3`,"data-testid":`explore-conversation`,children:[!W&&f&&(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground/70 italic px-1 py-2`,children:h(`shell.editModeIntro`)}),!W&&!f&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`w-4 h-4 animate-spin`}),h(`shell.startingConversation`)]}),W?.messages.map((e,t)=>(0,$.jsx)(rV,{role:e.role,content:e.content,timestamp:e.created_at,provider:W?.provider},t)),(R||W?.isStreaming)&&(W?.streamingText?(0,$.jsx)(rV,{role:`assistant`,content:Ee,streaming:!0,provider:W?.provider}):(0,$.jsx)(`div`,{className:`px-5 pb-1`,children:(0,$.jsx)(bB,{active:!0,hasSystemEvent:!!W?.isStreaming,hasToolUse:!1,hasText:!1})})),(0,$.jsx)(`div`,{ref:he})]}),Ae.length>0&&W&&!W.isStreaming&&(0,$.jsx)(`div`,{role:`group`,"aria-label":h(`shell.suggestedRepliesAriaLabel`),className:`flex-shrink-0 flex gap-1.5 px-5 pb-2 flex-wrap`,children:Ae.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`text-[11px] px-2.5 py-1 rounded-full border border-border/60 bg-card/40 hover:bg-card/80 hover:border-primary/40 transition-colors`,children:e},e))}),(0,$.jsxs)(`div`,{className:`flex-shrink-0 px-5 py-3 border-t border-border/40 bg-card/30`,children:[(0,$.jsx)(uz,{ref:pe,ticketKey:T,placeholder:W?.isStreaming?``:h(`shell.composerPlaceholder`),minHeight:72,ariaLabel:h(`shell.composerAriaLabel`),onChange:()=>{let e=pe.current?.getPlainText()??``;P(e.length>0),Ue(e)},onUnsupportedFile:e=>J.error(h(`shell.toasts.unsupportedFileType`,{name:e.name})),onUploadError:(e,t)=>J.error(h(`shell.toasts.uploadFailed`,{name:t.name,message:e.message})),onAttachmentRemoved:e=>{fetch(`${He}/api/projects/${w}/tickets/${T}/attachments/${e.id}`,{method:`DELETE`}).catch(()=>{}),H(t=>t.filter(t=>t.id!==e.id))},onAttachmentAdded:()=>{ve()},onSubmit:Re,footerExtra:te&&w?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>re(!0),"data-testid":`explore-from-browser-btn`,title:h(`shell.fromWebsiteTitle`),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md border border-accent-info/50 text-accent-info hover:bg-accent-info/10 transition-colors font-medium`,children:[(0,$.jsx)(E,{className:`w-3.5 h-3.5`}),(0,$.jsx)(`span`,{children:h(`shell.fromWebsite`)})]}):void 0}),ie.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 mt-2`,"data-testid":`explore-captured-dom-list`,children:ie.map(e=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent-secondary/40 bg-accent-secondary/5 p-2 space-y-1.5`,children:[e.breakpoints?(0,$.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`explore-capture-breakpoints`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium text-accent-highlight`,children:[(0,$.jsx)(Ks,{className:`w-3 h-3 shrink-0`}),h(`shell.captureResponsiveSizes`,{count:e.breakpoints.length})]}),(0,$.jsx)(`div`,{className:`flex items-end justify-center gap-2 flex-wrap`,children:e.breakpoints.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsx)(`img`,{src:e.dataUrl,alt:`${e.key} (${e.width}px)`,className:`max-h-28 w-auto max-w-[9rem] object-contain rounded border border-border/60 bg-background-deep block`}),(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.key,` · `,e.width,`px`]})]},e.key))})]}):(0,$.jsx)(`img`,{src:e.screenshotDataUrl,alt:e.screenshotName,className:`max-h-36 w-auto max-w-full object-contain rounded border border-border/60 bg-background-deep mx-auto block`}),e.dom.url&&e.dom.url!==`about:blank`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,title:e.dom.url,children:[(0,$.jsx)(E,{className:`w-3 h-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.dom.url})]})]}),(0,$.jsx)(Zz,{dom:e.dom,onRemove:()=>xe(e)})]},e.domAttachmentId))}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-2 gap-3`,children:[(0,$.jsx)(`span`,{}),W?.isStreaming&&we>1?(0,$.jsxs)(Z,{size:`sm`,variant:`ghost`,onClick:()=>{W&&C&&C.abortStream(W.id)},className:`gap-1.5 text-destructive hover:text-destructive`,"data-testid":`explore-stop-button`,children:[h(`shell.stop`),(0,$.jsx)(`span`,{className:`text-[10px] opacity-70 ml-1`,children:`⌘⏎`})]}):(0,$.jsxs)(Z,{size:`sm`,onClick:Re,disabled:!N||!W&&!f||R,className:`gap-1.5`,children:[(0,$.jsx)(tc,{className:`w-3.5 h-3.5`}),h(`shell.send`),(0,$.jsx)(`span`,{className:`text-[10px] opacity-70 ml-1`,children:`⌘⏎`})]})]})]})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 transition-opacity duration-500 ${W?.isStreaming?`opacity-90`:`opacity-100`}`,children:[W?.isStreaming&&(0,$.jsx)(`div`,{className:`absolute top-0 inset-x-0 h-0.5 overflow-hidden pointer-events-none z-10`,children:(0,$.jsx)(`div`,{className:`h-full bg-primary/40 animate-pulse`})}),(0,$.jsx)(dB,{draft:De,ready:Oe,flashFields:je,onFieldChange:Me,attachments:V,onRemoveAttachment:async e=>{try{await fetch(`${He}/api/projects/${w}/tickets/${T}/attachments/${e}`,{method:`DELETE`})}catch{}H(t=>t.filter(t=>t.id!==e))}})]})]}),(0,$.jsx)(Hn,{open:j,onOpenChange:e=>!e&&M(!1),children:(0,$.jsxs)(Bn,{className:`max-w-sm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:h(`shell.closePrompt.title`)}),(0,$.jsx)(Mn,{children:h(`shell.closePrompt.description`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:()=>M(!1),"data-testid":`close-prompt-cancel`,children:h(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,onClick:l,"data-testid":`close-prompt-discard`,children:h(`common:actions.discard`)}),(0,$.jsx)(Z,{size:`sm`,onClick:async()=>{let e=await ze();M(!1),e&&l()},autoFocus:!0,"data-testid":`close-prompt-save-draft`,children:h(`shell.saveAsDraft`)})]})]})})]}),(0,$.jsx)(Nn,{handles:b}),B&&(0,$.jsx)(qB,{baseline:f?{title:f.title,description:f.description,labels:f.labels,repositoryIds:f.repositoryIds,priority:f.priority,acceptanceCriteria:f.acceptanceCriteria}:KB,proposed:{title:De.title??``,description:De.description??``,labels:De.labels??[],priority:De.priority??null,acceptanceCriteria:De.acceptanceCriteria??[]},mode:de?`edit`:`create`,isCommitting:F,onBack:()=>ee(!1),onCommit:async()=>{await Be(),ee(!1)}}),te&&ne&&w&&(0,$.jsx)(Wz,{open:ne,onClose:()=>re(!1),projectId:w,pendingSpecId:T,onCaptured:be,confirmLabel:h(de?`shell.updateSpec`:`shell.createSpec`)})]}),document.body)}function tV(e){let t=e.trimStart();if(t.startsWith(`/specrails:explore-spec`)){let e=t.indexOf(`
63
+ `);if(e===-1)return``;t=t.slice(e+1).replace(/^\s+/,``)}if(t.startsWith(`## Spec context`)){let e=t.indexOf(`## Instruction
64
+
65
+ `);if(e!==-1)return t.slice(e+16).trimStart()}return t}function nV(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function rV({role:e,content:t,streaming:n,timestamp:r,provider:i}){let{t:a}=K(`explore`);if(e===`system`)return null;let o=e===`user`,s=o?tV(t):t;if(!s.trim()&&!n)return null;let c=nV(r);return(0,$.jsx)(`div`,{className:`flex ${o?`justify-end`:`justify-start`}`,children:(0,$.jsxs)(`div`,{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${o?`bg-primary/10 text-foreground`:`bg-card/60 border border-border/40`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 mb-1`,children:[(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold`,children:o?a(`shell.you`):ur(i)}),c&&(0,$.jsx)(`div`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums`,children:c})]}),o?(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words`,children:[s,n&&(0,$.jsx)(`span`,{className:`inline-block w-1 h-3 bg-primary/60 ml-0.5 animate-pulse align-baseline`})]}):(0,$.jsxs)(`div`,{className:[`prose prose-sm max-w-none break-words`,`text-foreground`,`[&_p]:text-foreground [&_li]:text-foreground`,`[&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5 [&_li]:my-0.5`,`[&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_strong]:text-accent-primary [&_strong]:font-semibold`,`[&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-accent-primary [&_code]:text-[12px]`,`[&_pre]:rounded [&_pre]:bg-background/60 [&_pre]:p-2 [&_pre]:my-2`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0`,`[&_a]:text-accent-primary [&_a]:underline`,`[&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-foreground`,`[&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold`].join(` `),children:[(0,$.jsx)(Jn,{remarkPlugins:[Yn],children:s}),n&&(0,$.jsx)(`span`,{className:`inline-block w-1 h-3 bg-primary/60 ml-0.5 animate-pulse align-baseline`})]})]})})}function iV({errorMessage:e,onRetry:t,onClose:n}){let{t:r}=K(`nav`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-8`,children:[(0,$.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`errorBoundary.title`)}),e&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 font-mono max-w-md break-words`,children:e})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,$.jsx)(Js,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]}),n&&(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium border border-border hover:bg-muted/40 transition-colors`,children:[(0,$.jsx)(mn,{className:`w-3.5 h-3.5`}),r(`common:actions.close`)]})]})]})}var aV=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ShellErrorBoundary]`,e,t.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,$.jsx)(iV,{errorMessage:this.state.error?.message??null,onRetry:this.handleRetry,onClose:this.props.onClose}):this.props.children}},oV=`specrails-desktop:active-explore-spec`;function sV(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(oV);if(!e)return null;let t=JSON.parse(e);return uV(t)?t:null}catch{return null}}function cV(e){if(!(typeof window>`u`))try{window.localStorage.setItem(oV,JSON.stringify(e))}catch{}}function lV(){if(!(typeof window>`u`))try{window.localStorage.removeItem(oV)}catch{}}function uV(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.projectId==`string`&&typeof t.idea==`string`&&typeof t.pendingSpecId==`string`&&Array.isArray(t.initialAttachmentIds)&&t.initialAttachmentIds.every(e=>typeof e==`string`)}function dV(e){return!!(e.title?.trim()||e.description?.trim()||e.priority&&e.priority!==`medium`||e.labels&&e.labels.length>0||e.repositoryIds?.length||e.acceptanceCriteria&&e.acceptanceCriteria.some(e=>e.trim()))}function fV(e,t,n){let r=e?.trim();if(r)return r;let i=t?.trim();if(i)return i;let a=n.trim();return a?a.length>60?a.slice(0,57)+`…`:a:G.t(`specs:board.untitledSpec`)}function pV({tickets:e,allTickets:t,doneTickets:n=[],isLoading:r,error:i,onRetry:a,onTicketClick:o,onTicketCreated:s,onTicketDelete:c,contractRefiningIds:l=new Set,sortMode:u=`default`,sortDir:f=`desc`,onSortChange:p=()=>{},viewTier:m=`postit`,onViewTierChange:h,rails:g=[],onMoveToRail:_,continuableReviewTicketIds:v,onTicketStatusChange:y,onTicketPriorityChange:b}){let{t:x}=K(`specs`),[S,C]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!S)return;let e=e=>{e.key===`Escape`&&C(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S]);let w=(0,Q.useCallback)(()=>{S&&C(!1)},[S]),T=(0,Q.useCallback)(()=>C(!0),[]),E=(0,Q.useCallback)(e=>{c&&c(e.id)},[c]),[D,O]=(0,Q.useState)(!1),[k,j]=(0,Q.useState)(null),{activeProjectId:M}=at(),[N,P]=d(),[F,I]=(0,Q.useState)(()=>UR(M).labels),[L,R]=(0,Q.useState)(()=>UR(M).epic),[z,B]=(0,Q.useState)(()=>UR(M).sprint),[ee,V]=(0,Q.useState)(()=>{let e=N.get(`status`);return QL(e)?e:nR(M)}),[H,te]=(0,Q.useState)(()=>N.get(`jiraStatus`)??UR(M).jiraStatus),ne=(0,Q.useCallback)(e=>{V(e),rR(M,e)},[M]);(0,Q.useEffect)(()=>{P(e=>{let t=new URLSearchParams(e);return ee===`active`?t.delete(`status`):t.set(`status`,ee),H===null?t.delete(`jiraStatus`):t.set(`jiraStatus`,H),t.toString()===e.toString()?e:t},{replace:!0})},[ee,H,P]);let{minimize:re}=Kt(),ie=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t??[])n.parent_epic_id!=null&&e.set(n.parent_epic_id,(e.get(n.parent_epic_id)??0)+1);return e},[t]),ae=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t??[])n.is_epic&&e.set(n.id,n.title);return e},[t]),oe=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t??[])e.set(n.id,n);return e},[t]),se=(0,Q.useCallback)(e=>{let t=oe.get(e);t&&o(t)},[oe,o]),ce=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=UR(M);I(e.labels),R(e.epic),B(e.sprint),ce.current&&(V(nR(M)),te(e.jiraStatus)),ce.current=!0},[M]);let le=(0,Q.useCallback)(e=>{I(e),WR(M,{labels:e,epic:L,sprint:z,jiraStatus:H})},[M,L,z,H]),ue=(0,Q.useCallback)(e=>{R(e),WR(M,{labels:F,epic:e,sprint:z,jiraStatus:H})},[M,F,z,H]),de=(0,Q.useCallback)(e=>{B(e),WR(M,{labels:F,epic:L,sprint:e,jiraStatus:H})},[M,F,L,H]),fe=(0,Q.useCallback)(e=>{te(e),WR(M,{labels:F,epic:L,sprint:z,jiraStatus:e})},[M,F,L,z]),pe=(0,Q.useCallback)(e=>!(L!==null&&e.jira_epic_key!==L||z!==null&&e.jira_sprint_id!==z||F.size>0&&!(e.labels??[]).some(e=>F.has(e))),[F,L,z]),me=F.size===0&&L===null&&z===null,he=(0,Q.useMemo)(()=>me?e:e.filter(pe),[e,me,pe]),ge=(0,Q.useMemo)(()=>me?n:n.filter(pe),[n,me,pe]),_e=(0,Q.useMemo)(()=>e.some(e=>e.jira_epic_key)||n.some(e=>e.jira_epic_key),[e,n]),ve=(0,Q.useMemo)(()=>e.some(e=>e.jira_sprint_id)||n.some(e=>e.jira_sprint_id),[e,n]),ye=(0,Q.useMemo)(()=>e.some(e=>e.jira_key)||n.some(e=>e.jira_key),[e,n]),U=(0,Q.useMemo)(()=>e.some(e=>e.jira_status)||n.some(e=>e.jira_status),[e,n]),be=(0,Q.useMemo)(()=>{let e={draft:0,todo:0,in_progress:0,on_review:0,done:0,cancelled:0};for(let t of he)e[t.status]+=1;for(let t of ge)e[t.status]+=1;return e},[he,ge]),xe=(0,Q.useCallback)(e=>H===null||e.jira_status===H,[H]),Se=(0,Q.useMemo)(()=>he.filter(e=>$L(e.status,ee)&&xe(e)),[he,ee,xe]),Ce=(0,Q.useMemo)(()=>{let e=ge.filter(xe);return u==="default"?e:RR(e,u,f)},[ge,xe,u,f]),[W,we]=(0,Q.useState)({conversationId:null,draftTitle:``,composerText:``,draftOverrides:{}}),Te=(0,Q.useRef)(W);Te.current=W;let Ee=(0,Q.useRef)(k);Ee.current=k;let De=(0,Q.useCallback)(()=>{let e=Ee.current;!e||!e.projectId||(re({kind:`explore-spec`,projectId:e.projectId,label:fV(Te.current.draftTitle,e.seedDraftTitle,e.idea),restoreRoute:`/`,params:{initialIdea:e.idea,pendingSpecId:e.pendingSpecId,initialAttachmentIds:e.initialAttachmentIds,resumeConversationId:Te.current.conversationId??e.resumeConversationId,composerText:Te.current.composerText||void 0,draftOverrides:dV(Te.current.draftOverrides)?Te.current.draftOverrides:void 0,editTicket:e.editTicket}}),lV())},[re]);(0,Q.useEffect)(()=>{if(!M)return;let e=sV();!e||e.projectId!==M||(we({conversationId:e.resumeConversationId??null,draftTitle:e.seedDraftTitle??``,composerText:e.composerText??``,draftOverrides:e.draftOverrides??{}}),j({projectId:e.projectId,idea:e.idea,pendingSpecId:e.pendingSpecId,initialAttachmentIds:e.initialAttachmentIds,resumeConversationId:e.resumeConversationId,seedDraftTitle:e.seedDraftTitle,seedComposerText:e.composerText,seedDraftOverrides:e.draftOverrides}))},[M]),(0,Q.useEffect)(()=>{!k||!M||cV({projectId:M,idea:k.idea,pendingSpecId:k.pendingSpecId,initialAttachmentIds:k.initialAttachmentIds,resumeConversationId:W.conversationId??k.resumeConversationId,seedDraftTitle:W.draftTitle||k.seedDraftTitle,composerText:W.composerText||void 0,draftOverrides:dV(W.draftOverrides)?W.draftOverrides:void 0})},[k,M,W]);let Oe=(0,Q.useCallback)(e=>{De(),we({conversationId:null,draftTitle:``,composerText:``,draftOverrides:{}}),M&&j({projectId:M,idea:e.idea,seedDraftOverrides:e.repositoryIds?{repositoryIds:e.repositoryIds}:void 0,pendingSpecId:e.pendingSpecId,initialAttachmentIds:e.initialAttachmentIds,initialModel:e.model,initialProvider:e.provider,contextScope:e.contextScope})},[De,M]);Jt(`explore-spec`,M,e=>{e.kind===`explore-spec`&&(De(),we({conversationId:e.params.resumeConversationId??null,draftTitle:e.label,composerText:e.params.composerText??``,draftOverrides:e.params.draftOverrides??{}}),j({projectId:e.projectId,idea:e.params.initialIdea,pendingSpecId:e.params.pendingSpecId,initialAttachmentIds:e.params.initialAttachmentIds,resumeConversationId:e.params.resumeConversationId,seedDraftTitle:e.label,seedComposerText:e.params.composerText,seedDraftOverrides:e.params.draftOverrides,editTicket:e.params.editTicket}))}),(0,Q.useEffect)(()=>{function e(e){if(!(e.metaKey||e.ctrlKey)||e.key!==`Enter`)return;let t=e.target?.tagName;t===`INPUT`||t===`TEXTAREA`||e.target?.isContentEditable||(e.preventDefault(),O(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let{isOver:ke,setNodeRef:Ae}=UI({id:`specs`}),{isOver:je,setNodeRef:Me}=UI({id:`done-specs`}),Ne=ee!==`done`,Pe=ee===`all`||ee===`done`,Fe=ee!==`active`||H!==null,Ie=e.length+n.length>0;return(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,onClick:w,children:[(0,$.jsxs)(`div`,{className:`flex items-center px-4 h-12 border-b border-border/40 shrink-0 gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)($t,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-accent-primary`,children:x(`board.title`)}),e.length+n.length>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground bg-muted/30 rounded-full px-1.5 py-0.5`,children:!me||H!==null?`${he.filter(xe).length+ge.filter(xe).length}/${e.length+n.length}`:e.length+n.length})]}),(0,$.jsx)(sR,{value:ee,onChange:ne,counts:be}),U&&(0,$.jsx)(uR,{tickets:[...he,...ge],active:H,onChange:fe}),(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/60 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(KL,{tickets:[...e,...n],active:F,onChange:le}),_e&&(0,$.jsx)(qL,{tickets:[...e,...n],active:L,onChange:ue}),ve&&(0,$.jsx)(JL,{tickets:[...e,...n],active:z,onChange:de}),(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/60 shrink-0 ml-auto`,"aria-hidden":!0}),(0,$.jsx)(xR,{mode:u,dir:f,onChange:p,showJiraSort:ye,className:`shrink-0`}),h&&(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(CR,{tier:m,onChange:h})}),(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/60 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1 shrink-0 border-accent-primary/50 text-accent-primary hover:bg-accent-primary/10 hover:text-accent-primary`,onClick:()=>O(!0),"data-tour":`add-spec-btn`,children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5`}),x(`common:actions.add`)]})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[i&&(0,$.jsxs)(`div`,{role:`alert`,"data-testid":`specs-load-error`,className:`mx-4 mt-3 flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(fn,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:x(`errors.loadFailed`)}),a&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:a,disabled:r,children:x(`common:actions.retry`)})]}),(!i||Ie)&&Ne&&(0,$.jsx)(`div`,{ref:Ae,"data-tour":`specs-list`,className:`px-4 pt-3 pb-2 space-y-1.5 transition-colors duration-150 ${ke?`bg-primary/[0.04]`:``}`,children:r&&!Ie?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>(0,$.jsx)(`div`,{className:`h-10 rounded-lg border border-border/40 bg-card/50 animate-pulse`},e))}):Se.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center transition-colors ${ke?`text-primary/50`:`text-muted-foreground`}`,children:[(0,$.jsx)($t,{className:`w-8 h-8 mb-3 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:ke?x(`board.dropHere`):e.length===0?x(`board.emptyNoSpecs`):he.length===0&&F.size>0?x(`board.emptyNoLabelMatch`):x(Fe?`board.emptyNoStatusMatch`:`board.emptyNoActiveSpecs`)}),!ke&&e.length===0&&(0,$.jsx)(`p`,{className:`text-xs mt-1 opacity-60`,children:x(`board.emptyHint`)})]}):m===`postit`&&_?(0,$.jsx)(pL,{items:Se.map(e=>e.id),strategy:lL,children:(0,$.jsx)(`div`,{"data-testid":`specs-board-postit-grid`,className:`grid gap-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`},children:Se.map(e=>(0,$.jsx)(mV,{ticket:e,onTicketDelete:c,onTicketStatusChange:y,onTicketPriorityChange:b,children:(0,$.jsx)(FL,{ticket:e,rails:g,onClick:o,onMoveToRail:_,contractRefining:l.has(e.id),epicChildrenCount:e.is_epic?ie.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:ae.get(e.parent_epic_id)??null,onOpenParentEpic:se,jiggleMode:S,onLongPress:c?T:void 0,onDelete:c?E:void 0,allowOnReviewRailMove:v?.has(e.id)??!1})},e.id))})}):(0,$.jsx)(pL,{items:Se.map(e=>e.id),strategy:lL,children:(0,$.jsx)(`div`,{"data-testid":`specs-board-list`,"data-tier":`row`,className:`space-y-1.5`,children:Se.map(e=>(0,$.jsx)(mV,{ticket:e,onTicketDelete:c,onTicketStatusChange:y,onTicketPriorityChange:b,children:(0,$.jsx)(ML,{ticket:e,onClick:o,contractRefining:l.has(e.id),epicChildrenCount:e.is_epic?ie.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:ae.get(e.parent_epic_id)??null,onOpenParentEpic:se,jiggleMode:S,onLongPress:c?T:void 0,onDelete:c?E:void 0,allowOnReviewDrag:v?.has(e.id)??!1})},e.id))})})}),(!i||Ie)&&Pe&&(0,$.jsx)(`div`,{ref:Me,"data-testid":`specs-board-done-bucket`,className:`px-4 pt-2 pb-3 space-y-1.5 transition-colors duration-150 ${je?`bg-emerald-500/[0.04] aurora-light:bg-accent-success/10`:``} ${Ne?`border-t border-border/30 mt-1`:``}`,children:Ce.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Mo,{className:`w-6 h-6 mb-2 opacity-15`}),(0,$.jsx)(`p`,{className:`text-xs opacity-60`,children:je?x(`board.dropToMarkDone`):F.size>0&&n.length>0?x(`board.emptyNoDoneLabelMatch`):H!==null&&ge.length>0?x(`board.emptyNoStatusMatch`):x(`board.emptyNoCompleted`)})]}):m===`postit`&&_?(0,$.jsx)(pL,{items:Ce.map(e=>e.id),strategy:lL,children:(0,$.jsx)(`div`,{"data-testid":`specs-board-done-postit-grid`,className:`grid gap-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`},children:Ce.map(e=>(0,$.jsx)(mV,{ticket:e,onTicketDelete:c,onTicketStatusChange:y,onTicketPriorityChange:b,children:(0,$.jsx)(FL,{ticket:e,rails:g,onClick:o,onMoveToRail:_,contractRefining:l.has(e.id),epicChildrenCount:e.is_epic?ie.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:ae.get(e.parent_epic_id)??null,onOpenParentEpic:se,jiggleMode:S,onLongPress:c?T:void 0,onDelete:c?E:void 0})},e.id))})}):(0,$.jsx)(pL,{items:Ce.map(e=>e.id),strategy:lL,children:Ce.map(e=>(0,$.jsx)(mV,{ticket:e,onTicketDelete:c,onTicketStatusChange:y,onTicketPriorityChange:b,children:(0,$.jsx)(ML,{ticket:e,onClick:o,contractRefining:l.has(e.id),epicChildrenCount:e.is_epic?ie.get(e.id)??0:void 0,parentEpicTitle:e.parent_epic_id==null?null:ae.get(e.parent_epic_id)??null,onOpenParentEpic:se,jiggleMode:S,onLongPress:c?T:void 0,onDelete:c?E:void 0})},e.id))})})]}),(0,$.jsx)(tB,{open:D,onClose:()=>O(!1),tickets:t??e,onExploreLaunch:Oe}),k&&M&&(0,$.jsx)(aV,{onClose:()=>j(null),children:(0,$.jsx)(eV,{initialIdea:k.idea,pendingSpecId:k.pendingSpecId,initialAttachmentIds:k.initialAttachmentIds,initialModel:k.initialModel,initialProvider:k.initialProvider,resumeConversationId:k.resumeConversationId,seedDraftTitle:k.seedDraftTitle,seedComposerText:k.seedComposerText,seedDraftOverrides:k.seedDraftOverrides,editTicket:k.editTicket,contextScope:k.contextScope,onStateChange:e=>we(e),onClose:()=>{A(k.pendingSpecId).catch(()=>{}),j(null),lV()},onMinimize:(e,t)=>{let n=Te.current;re({kind:`explore-spec`,projectId:k.projectId,label:fV(t,k.seedDraftTitle,k.idea),restoreRoute:`/`,params:{initialIdea:k.idea,pendingSpecId:k.pendingSpecId,initialAttachmentIds:k.initialAttachmentIds,resumeConversationId:e??void 0,composerText:n.composerText||void 0,draftOverrides:dV(n.draftOverrides)?n.draftOverrides:void 0}}),j(null),lV()},onTicketCreated:e=>{j(null),lV(),s?.(e)}},`${k.pendingSpecId}:${k.resumeConversationId??`fresh`}`)})]})}function mV({ticket:e,onTicketDelete:t,onTicketStatusChange:n,onTicketPriorityChange:r,children:i}){return!t||!n||!r?(0,$.jsx)($.Fragment,{children:i}):(0,$.jsx)(HL,{ticket:e,onDelete:t,onStatusChange:n,onPriorityChange:r,children:i})}function hV({status:e,activeJobId:t,ticketCount:n,onToggle:r}){let{t:i}=K(`dashboard`),a=v(),o=n>0;return(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e===`running`&&t&&(0,$.jsxs)(Z,{size:`sm`,variant:`ghost`,className:`group h-6 px-2 gap-1 rounded-md border border-accent-info/20 bg-accent-info/5 text-[10px] font-semibold text-accent-info transition-all duration-200 hover:-translate-y-px hover:border-accent-info/50 hover:bg-accent-info/15 hover:text-accent-info hover:shadow-[0_0_14px_hsl(191_97%_77%/0.22)] active:translate-y-0 active:scale-[0.98]`,onClick:()=>a(`/jobs/${t}`),title:i(`railControls.viewJobLog`),children:[(0,$.jsx)($s,{className:`w-3 h-3 transition-transform duration-200 group-hover:scale-110`}),(0,$.jsx)(`span`,{children:i(`railControls.log`)})]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 rounded-full transition-all duration-200 ${e===`running`?`text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-400/10 aurora-light:hover:bg-destructive/10`:e===`failed`?`text-amber-400 aurora-light:text-accent-warning hover:text-emerald-300 aurora-light:hover:text-accent-success hover:bg-emerald-400/10 aurora-light:hover:bg-accent-success/10`:o?`text-emerald-400 aurora-light:text-accent-success hover:text-emerald-300 aurora-light:hover:text-accent-success hover:bg-emerald-400/10 aurora-light:hover:bg-accent-success/10`:`text-muted-foreground/30 cursor-not-allowed`}`,onClick:r,disabled:!o&&e!==`running`,title:i(e===`running`?`railControls.stop`:e===`failed`?`railControls.failedRetry`:o?`railControls.play`:`railControls.addSpecsFirst`),children:e===`running`?(0,$.jsx)(sn,{className:`w-2.5 h-2.5 fill-current`}):e===`failed`?(0,$.jsx)(fn,{className:`w-2.5 h-2.5`}):(0,$.jsx)(on,{className:`w-2.5 h-2.5 fill-current`})})]})}var gV={implement:`factory:implement`,"batch-implement":`factory:batch`,freestyle:`factory:freestyle`},_V=[{id:`factory:implement`,labelKey:`railControls.implement`},{id:`factory:batch`,labelKey:`railControls.batch`},{id:`factory:freestyle`,labelKey:`railControls.freestyle`,requiresFreestyle:!0},{id:`factory:sdd-quick-openspec`,labelKey:`railControls.openspec`,requiresLoops:!0}];function vV(e){return e===`loop`?``:gV[e]}function yV(e){return e===`factory:implement`?`implement`:e===`factory:batch`?`batch-implement`:e===`factory:freestyle`?`freestyle`:`loop`}function bV(e,t){return e||vV(t)}var xV=`__legacy__`;function SV({provider:e,value:t,onChange:n}){let{t:r}=K(`agents`),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let r=!1;return fetch(`${nt()}/profiles?provider=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():{profiles:[]}).then(i=>{if(r)return;let o=Array.isArray(i.profiles)?i.profiles.filter(t=>!t.provider||t.provider===e):[];a(o),t&&!o.some(e=>e.name===t)&&n(null)}).catch(()=>{r||a([])}).finally(()=>{r||s(!0)}),()=>{r=!0}},[e]),!o||i.length===0)return null;let c=t??xV;return(0,$.jsxs)(`div`,{className:`inline-flex items-center`,title:r(`railSelectors.profileTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(So,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,$.jsxs)(`select`,{value:c,onChange:e=>{let t=e.target.value;n(t===xV?null:t)},className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:[i.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.name},e.name)),(0,$.jsx)(`option`,{value:xV,children:r(`railSelectors.noProfile`)})]})]})}function CV({value:e,providers:t,onChange:n}){let{t:r}=K(`agents`);if(!t||t.length<=1)return null;let i=e??t[0];return(0,$.jsxs)(`div`,{className:`inline-flex items-center`,title:r(`railSelectors.engineTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(Go,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,$.jsx)(`select`,{value:i,"aria-label":r(`railSelectors.engineTitle`),"data-testid":`rail-engine-selector`,onChange:e=>n(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:t.map(e=>(0,$.jsx)(`option`,{value:e,children:ur(e)},e))})]})}function wV({provider:e=`claude`,value:t,onChange:n,testId:r=`rail-model-selector`,ariaLabel:i}){let{t:a}=K(`agents`),o=fz(e),s=nr(e),c=t&&(o.some(e=>e.value===t)||s&&gD(t))?t:pz(e),l=i??a(`railSelectors.modelTitle`);return(0,$.jsxs)(`div`,{className:`inline-flex items-center`,title:l,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(un,{className:`w-3 h-3 text-accent-highlight mr-1`}),s?(0,$.jsx)(_D,{value:c,options:o,ariaLabel:l,testId:r,className:`h-5 w-48 border-border/50 px-1 text-[10px] text-muted-foreground hover:text-foreground`,onCommit:n}):(0,$.jsx)(`select`,{value:c,"aria-label":l,"data-testid":r,onChange:e=>n(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:o.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}var TV=class extends Error{errors;constructor(e){super(`Loop graph is invalid`),this.name=`LoopPublishError`,this.errors=e}},EV=`/api`;async function DV(e){if(!e.ok){let t;try{t=await e.json()}catch{t=void 0}if(e.status===422&&t&&typeof t==`object`&&`errors`in t)throw new TV(t.errors??[]);let n=t&&typeof t==`object`&&`error`in t?String(t.error):`Request failed (${e.status})`;throw Error(n)}return e.json()}async function OV(e,t,n){return DV(await fetch(`${EV}${t}`,{method:e,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}))}var kV={async list(){return(await OV(`GET`,`/loops`)).loops},async get(e){return(await OV(`GET`,`/loops/${e}`)).loop},async create(e){return(await OV(`POST`,`/loops`,e)).loop},async update(e,t){return(await OV(`PUT`,`/loops/${e}`,t)).loop},async publish(e){return(await OV(`POST`,`/loops/${e}/publish`)).loop},async unpublish(e){return(await OV(`POST`,`/loops/${e}/unpublish`)).loop},async duplicate(e,t){return(await OV(`POST`,`/loops/${e}/duplicate`,t?{name:t}:{})).loop},async remove(e){let t=await fetch(`${EV}/loops/${e}`,{method:`DELETE`});!t.ok&&t.status!==204&&await DV(t)},async templates(){return(await OV(`GET`,`/loop-templates`)).templates},async fromTemplate(e,t){return(await OV(`POST`,`/loops/from-template/${e}`,t?{name:t}:{})).loop},async factoryLoops(){return(await OV(`GET`,`/loops/factory`)).factoryLoops},async loopCommands(){return(await OV(`GET`,`/loops/commands`)).commands},async forkFactory(e,t){return(await OV(`POST`,`/loops/factory/${e}/fork`,t?{name:t}:{})).loop},async loopConstants(){return(await OV(`GET`,`/loops/constants`)).constants},async createConstant(e,t){return(await OV(`POST`,`/loops/constants`,{name:e,value:t})).constant},async updateConstant(e,t){return(await OV(`PUT`,`/loops/constants/${e}`,{value:t})).constant},async deleteConstant(e){await OV(`DELETE`,`/loops/constants/${e}`)},async importLoops(e){return OV(`POST`,`/loops/import`,{loops:e})},async previewLoop(e,t){return OV(`POST`,`/loops/preview`,{graph:e,provider:t})},async runStandalone(e,t,n={}){return DV(await fetch(`/api/projects/${e}/loop-runs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({loopId:t,...n})}))}},AV=/\{\{\s*spec\./,jV=/\{\{\s*cmd:(implement|batch|freestyle)\b/;function MV(e){if(!e)return!1;for(let t of e.nodes){let e=[t.data?.prompt,t.data?.command,t.data?.goal].filter(e=>typeof e==`string`).join(`
66
+ `);if(AV.test(e)||jV.test(e))return!0}return!1}function NV({value:e,onChange:t,freestyleAvailable:n=!0,loopsEnabled:r=!0}){let{t:i}=K(`dashboard`),[a,o]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!r)return;let e=!1;return kV.list().then(t=>{e||o(t.filter(e=>e.status===`published`&&MV(e.graph)))}).catch(()=>{}),()=>{e=!0}},[r]);let s=_V.filter(e=>(n||!e.requiresFreestyle)&&(r||!e.requiresLoops));return(0,$.jsxs)(`div`,{className:`inline-flex items-center`,title:i(`railControls.loopTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(gc,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,$.jsxs)(`select`,{value:e??``,"aria-label":i(`railControls.loop`),"data-testid":`rail-loop-selector`,onChange:e=>t(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40 max-w-[160px]`,children:[(0,$.jsx)(`option`,{value:``,disabled:!0,children:i(`railControls.pickLoop`)}),(0,$.jsx)(`optgroup`,{label:i(`railControls.builtInLoops`),children:s.map(e=>(0,$.jsx)(`option`,{value:e.id,children:i(e.labelKey)},e.id))}),a.length>0&&(0,$.jsx)(`optgroup`,{label:i(`railControls.customLoops`),children:a.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]})}function PV({metric:e}){let{t}=K(`dashboard`),[n,r]=(0,Q.useState)(()=>Date.now());return(0,Q.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 text-[10px] text-muted-foreground tabular-nums`,"data-testid":`rail-exec-info`,children:[(0,$.jsx)(`span`,{children:kO(n-e.startedAt)}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:t(`railControls.execSteps`,{count:e.steps})}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:t(`railControls.execLines`,{count:e.lines})})]})}function FV({value:e,provider:t,model:n,onChange:r}){let{t:i}=K(`dashboard`),a=lr(t,n),o=e&&a.includes(e)?e:fr(t,n)??``;return(0,$.jsxs)(`div`,{className:`inline-flex items-center`,title:i(`railControls.effortTitle`),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(ss,{className:`w-3 h-3 text-muted-foreground mr-1`}),(0,$.jsx)(`select`,{value:o,"aria-label":i(`railControls.effortTitle`),"data-testid":`rail-effort-selector`,onChange:e=>r(e.target.value),className:`h-5 text-[10px] rounded border border-border/50 bg-transparent text-muted-foreground hover:text-foreground pr-4 pl-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,children:a.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]})}function IV({decision:e,density:t,act:n,checkout:r}){let{t:i}=K(`dashboard`),a=v(),{activeProjectId:o}=at(),s=At(o),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),m=(0,Q.useRef)(e.prDeliveryId);m.current=e.prDeliveryId;let h=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]),(0,Q.useEffect)(()=>{p(null),l(null),d(!1)},[e.prDeliveryId]);let g=e.decision,_=!!e.repositoryDeliveries?.length,y=ht(e),b=ft(e.statusCode,e.statusDetail),x=e.operation==null&&b,S=dt(e.statusCode)?i(`common:prDeliveryStatus.${e.statusCode}`):null,C=e.operation?i(`railPr.operation.${e.operation}`):x?i(`common:prRecovery.interrupted`):y.deliveryBlocked?i(`railPr.deliveryBlocked`):y.retryablePush?i(`railPr.updateFailed`):y.retryablePrCreation?y.localOnly?i(`railPr.localOnly`):e.prState===`pushed`?i(`railPr.branchPushed`):i(`railPr.prFailed`):y.closed?i(`railPr.prClosed`):y.partial?i(`railPr.partial`,{succeeded:y.succeededCount,total:y.totalCount}):y.implementationFailed?i(`railPr.implementationFailed`):null,w=g===`building`&&e.prState===`pr-created`&&!!e.branch;if(g===`building`&&!w||g===`merged`||g===`discarded`||g===`completed`||g===`superseded`)return null;let T=t===`compact`,E=t=>!(_&&(t===`merge-local`||t===`no-changes-done`))&&f?.kind===t&&f.prDeliveryId===e.prDeliveryId,D=t=>{p({kind:t,prDeliveryId:e.prDeliveryId,expectedDecision:g})},O=()=>p(null),k=(t,n)=>{let r=f;p(null),!(!h.current||!r||r.kind!==t||r.prDeliveryId!==e.prDeliveryId||r.prDeliveryId!==m.current)&&A(n,r.expectedDecision,r.prDeliveryId)};async function A(t,r,a=e.prDeliveryId,o){if(_&&!o&&[`create-pr`,`merge-local`,`publish`,`poll-merge`,`reopen`,`acknowledge-no-changes`].includes(t)||!h.current||a!==e.prDeliveryId||a!==m.current||c||u||e.operation)return;let s=e.repositoryDeliveries?.find(e=>e.repositoryId===o),d=s?.integrationBranch??s?.baseBranch??e.baseBranch;l(t);try{let s=await(o?n(t,r,a,o):n(t,r,a));if(!h.current||m.current!==a)return;if(s.status===409){if(s.error===`project_recovery_in_progress`){J.info(i(`common:prRecovery.inProgress`));return}if(s.error===`operation_in_progress`||s.busy){J.info(i(`railPr.operation.${s.operation??`inProgress`}`));return}if(s.error===`merge_local_blocked`&&(s.reason===`dirty`||s.reason===`wrong_branch`)){J.warning(s.reason===`dirty`?i(`railPr.mergeLocalBlockedDirty`,{base:s.base??d}):i(`railPr.mergeLocalBlockedBranch`,{base:s.base??d,current:s.current??`?`}));return}s.error===`stale_decision`?J.info(i(`railPr.alreadyResolved`)):J.error(i(`railPr.actionFailed`),{description:s.detail??s.error});return}if(s.status===502){if(s.error===`merge_failed`){J.error(i(`railPr.mergeLocalFailed`,{detail:s.detail??``}));return}J.error(i(`railPr.ghFailed`,{detail:s.detail??s.error??``}));return}if(!s.ok){J.error(i(`railPr.actionFailed`));return}if(s.snapshot&&s.snapshotApplication&&s.snapshotApplication!==`accepted`){J.info(i(`railPr.alreadyResolved`));return}if(t===`poll-merge`&&s.merged===!1&&s.decision!==`pr_closed`&&s.deliveryVerified==null&&J.info(i(`railPr.notMergedYet`)),t===`merge-local`&&s.decision===`merged`&&J.success(i(`railPr.mergedLocally`,{base:d})),t===`recover-and-retry`){if(s.deliveryVerified){let e=(s.verifiedSha??s.snapshot?.deliverySha??``).slice(0,8);J.success(i(`railPr.recoverAndRetryVerified`,{sha:e}))}else s.recoveryUnavailable||s.snapshot?.statusCode===`recovery_unavailable`?J.info(i(`railPr.recoveryUnavailable`),{description:i(`railPr.recoveryUnavailableBody`)}):J.warning(i(`railPr.recoveryStillBlocked`),{description:s.detail??void 0});return}if(t===`create-pr`&&y.retryablePush&&s.deliveryVerified){let t=(s.verifiedSha??s.snapshot?.deliverySha??e.deliverySha??``).slice(0,8);J.success(i(s.pushed?`railPr.retryPushVerified`:`railPr.commitAlreadyVerified`,{sha:t}));return}if(t===`create-pr`&&s.decision===`pr_failed`){J.error(s.detail?i(`railPr.prFailedDetail`,{detail:s.detail}):i(`railPr.prFailed`));return}if(t===`create-pr`&&s.decision===`pr_draft`&&!s.prUrl&&s.detail&&J.error(i(`railPr.createDegraded`,{detail:s.detail})),t===`poll-merge`&&s.deliveryVerified===!1){J.warning(i(`railPr.commitMissingRetry`));return}if(t===`poll-merge`&&s.deliveryVerified&&s.merged===!1){let t=(s.verifiedSha??s.snapshot?.deliverySha??e.deliverySha??``).slice(0,8);J.success(i(`railPr.prVerifiedWaiting`,{sha:t}));return}}finally{h.current&&m.current===a&&l(null)}}async function j(t){if(_&&!t||!h.current||!r||c||u||e.operation)return;let n=e.prDeliveryId;d(!0);try{let a=await(t?r(n,t):r(n));if(!h.current||m.current!==n)return;if(!a.ok){if(a.status===409&&a.error===`project_recovery_in_progress`){J.info(i(`common:prRecovery.inProgress`));return}if(a.error===`checkout_dirty`){J.warning(i(`railPr.checkoutDirtyTitle`),{description:i(`railPr.checkoutDirtyBody`)});return}if(a.error===`checkout_not_deliverable`){J.warning(i(`railPr.checkoutNotDeliverableTitle`),{description:i(`railPr.checkoutNotDeliverableBody`)});return}if(a.error===`checkout_safety_unknown`){J.warning(i(`railPr.checkoutSafetyUnknownTitle`),{description:i(`railPr.checkoutSafetyUnknownBody`)});return}J.warning(i(`railPr.checkoutFailed`),{description:a.detail??a.error});return}J.success(i(`railPr.checkoutSuccess`,{branch:a.branch??pt(e)??``})),a.cleanupWarnings?.length&&J.warning(i(`railPr.cleanupIncomplete`,{count:a.cleanupWarnings.length}),{description:a.cleanupWarnings.join(`
67
+ `)})}finally{h.current&&m.current===n&&d(!1)}}async function M(){let e=y.recoveryWorktreePaths;if(e.length===0){J.info(i(`railPr.localResultUnavailableHere`));return}let t=e.join(`
68
+ `),n=!1;try{await navigator.clipboard.writeText(t),n=!0}catch{}try{me()&&await oe(e[0])}catch{}n?J.success(i(`railPr.localResultPathCopied`),{description:t}):J.info(i(`railPr.localResultPath`),{description:t})}let N=`inline-flex items-center gap-1 rounded-full font-medium border ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,P=`inline-flex items-center gap-1 rounded-md font-medium bg-accent-primary text-white hover:bg-accent-primary/90 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,F=`inline-flex items-center gap-1 rounded-md font-medium border border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,I=`inline-flex items-center gap-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,L=T?`w-2.5 h-2.5`:`w-3 h-3`,z=(0,$.jsx)(rn,{className:`${L} animate-spin`,"aria-hidden":!0}),B=c!==null||u||e.operation!=null,ee=s.has(e.prDeliveryId),V=i(g===`implementation_failed`?`railPr.implementationFailedHint`:`railPr.discardTooltip`),H=e.prUrl?(0,$.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,"data-testid":`rail-pr-link`,title:i(`railPr.openPrTitle`),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 rounded-md font-mono border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors ${T?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[e.prNumber==null?i(`railPr.prLinkFallback`):`#${e.prNumber}`,(0,$.jsx)(Vt,{className:T?`w-2 h-2`:`w-2.5 h-2.5`,"aria-hidden":!0})]}):null,te=e.branch?(0,$.jsx)(`span`,{"data-testid":`rail-pr-branch`,className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-md font-mono border border-border/60 bg-surface/60 text-foreground/70 ${T?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:(0,$.jsx)(`span`,{className:`truncate`,children:e.branch})}):null,ne=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-discard`,disabled:B,title:V,onClick:e=>{e.stopPropagation(),D(`discard`)},className:I,children:[c===`discard`?z:null,i(`railPr.discard`)]}),re=!_&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-merge-local`,disabled:B,title:i(`railPr.mergeLocalTooltip`,{base:e.baseBranch}),onClick:e=>{e.stopPropagation(),D(`merge-local`)},className:`inline-flex items-center gap-1 rounded-md font-medium border border-accent-success/40 bg-accent-success/10 text-accent-success hover:bg-accent-success/20 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[c===`merge-local`?z:(0,$.jsx)(ls,{className:L,"aria-hidden":!0}),i(`railPr.mergeLocal`)]}),ie=(e,t,n,r,i,a)=>!_&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":r,disabled:B,title:i,onClick:n=>{n.stopPropagation(),A(e,t)},className:P,children:[c===e?z:a,n]}),ae=ve?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-open-packet`,title:i(`railPr.openReviewTooltip`),onClick:t=>{t.stopPropagation(),a(`/review/${e.prDeliveryId}`)},className:`inline-flex items-center gap-1 rounded-md font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20 transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[(0,$.jsx)(Qo,{className:L,"aria-hidden":!0}),i(`railPr.openReview`)]}):null,se=pt(e),ce=r&&se&&!_?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-checkout`,disabled:B,title:i(`railPr.checkoutTooltip`,{branch:se}),onClick:e=>{e.stopPropagation(),j()},className:`inline-flex items-center gap-1 rounded-md font-medium border border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[u?z:(0,$.jsx)(nn,{className:L,"aria-hidden":!0}),i(`railPr.checkout`)]}):null,le=y.recoveryWorktreePaths.length>0?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-inspect-local-result`,disabled:B,onClick:e=>{e.stopPropagation(),M()},className:F,title:i(`railPr.inspectLocalResultTooltip`),children:[(0,$.jsx)(as,{className:L,"aria-hidden":!0}),i(`railPr.inspectLocalResult`)]}):null,ue=y.recoveryRecheck,de=y.manualRecovery||ue?(0,$.jsxs)(`button`,{type:`button`,"data-testid":ue?`rail-pr-recheck-recovery`:`rail-pr-recover-and-retry`,disabled:B,onClick:e=>{e.stopPropagation(),D(`recover-and-retry`)},className:ue?F:P,children:[c===`recover-and-retry`?z:(0,$.jsx)(Zs,{className:L,"aria-hidden":!0}),i(ue?`railPr.recheckRecovery`:`railPr.recoverAndRetry`)]}):null,fe=(e.runIds??[]).map((t,n)=>(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-run-log`,title:i(`railPr.viewRunLog`,{ref:e.ticketIds[n]==null?t.slice(0,8):`#${e.ticketIds[n]}`}),"aria-label":i(`railPr.viewRunLog`,{ref:e.ticketIds[n]==null?t.slice(0,8):`#${e.ticketIds[n]}`}),onClick:e=>{e.stopPropagation(),a(`/jobs/${t}`)},className:`inline-flex items-center gap-1 rounded-md border border-accent-info/30 bg-accent-info/10 font-medium text-accent-info transition-colors hover:border-accent-info/55 hover:bg-accent-info/15 ${T?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[(0,$.jsx)($s,{className:L,"aria-hidden":!0}),e.ticketIds[n]==null?t.slice(0,8):`#${e.ticketIds[n]}`]},t)),pe=(e.units??[]).map(e=>{let t=e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded,n=e.deliveryOutcome===`blocked`,r=e.deliveryOutcome===`no_changes`||e.changed===!1;return(0,$.jsxs)(`span`,{"data-testid":`rail-pr-unit-evidence`,title:e.failureCode??e.branch,className:`${N} ${t?`border-destructive/30 bg-destructive/10 text-destructive`:n?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:`border-accent-success/30 bg-accent-success/10 text-accent-success`}`,children:[`#`,e.ticketId,` · `,i(t?`railPr.unit.failed`:n?`railPr.unit.blocked`:r?`railPr.unit.noChanges`:`railPr.unit.succeeded`)]},`${e.ticketId}-${e.runId??e.branch}`)}),he=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-dismiss`,disabled:B,onClick:e=>{e.stopPropagation(),D(`dismiss`)},className:I,children:[c===`dismiss`?z:null,i(`railPr.dismiss`)]}),ge=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-discard-local`,disabled:B,onClick:e=>{e.stopPropagation(),D(`discard-local`)},className:I,children:[c===`discard`?z:null,i(`railPr.discardLocalResult`)]}),_e=!_&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-no-changes-done`,disabled:B,onClick:e=>{e.stopPropagation(),D(`no-changes-done`)},className:P,children:[c===`acknowledge-no-changes`?z:(0,$.jsx)(Mo,{className:L,"aria-hidden":!0}),i(`railPr.markDone`)]}),ye=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-refine`,disabled:B,onClick:e=>{e.stopPropagation(),D(`refine`)},className:I,children:[c===`discard`?z:null,i(`railPr.refine`)]}),U=null,be=null;return w?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,$.jsx)(rn,{className:`${L} animate-spin`,"aria-hidden":!0}),i(`railPr.iteratingPr`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,te]})):y.noChanges?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-success/30 bg-accent-success/10 text-accent-success`,children:[(0,$.jsx)(Mo,{className:L,"aria-hidden":!0}),i(`railPr.noChanges`)]}),be=(0,$.jsxs)($.Fragment,{children:[e.prUrl?H:null,y.continuation?he:(0,$.jsxs)($.Fragment,{children:[_e,ye]})]})):y.partial&&!y.deliveryBlocked&&!y.retryablePush&&!y.retryablePrCreation&&!y.closed?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.partial`,{succeeded:y.succeededCount,total:y.totalCount})]}),be=g===`pr_draft`&&e.prUrl?(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`publish`,`pr_draft`,i(`railPr.publish`),`rail-pr-publish`,i(`railPr.publishTooltip`)),y.continuation?he:ne]}):g===`pr_ready`?(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`poll-merge`,`pr_ready`,i(`railPr.verifyPr`),`rail-pr-poll`,i(`railPr.verifyPrTooltip`)),y.continuation?he:ne]}):g===`on_review`||g===`pr_draft`&&!e.prUrl?(0,$.jsxs)($.Fragment,{children:[ce,ie(`create-pr`,g,i(`railPr.createPartialPr`,{count:y.deliverableCount}),`rail-pr-create-partial`),y.continuation?he:ne]}):(0,$.jsxs)($.Fragment,{children:[H,ce,y.continuation?he:ne]})):y.deliveryBlocked?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:e.statusDetail??void 0,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.deliveryBlocked`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,le,de,y.continuation?y.hasDiscardableRecoveryResult?ge:he:ne]})):y.retryablePush?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:e.statusDetail??void 0,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.updateFailed`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`create-pr`,g,i(`railPr.retryPush`),`rail-pr-retry-push`),y.continuation?he:ne]})):y.retryablePrCreation?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:e.statusDetail??void 0,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),y.localOnly?i(`railPr.localOnly`):e.prState===`pushed`?i(`railPr.branchPushed`):i(`railPr.prFailed`)]}),be=(0,$.jsxs)($.Fragment,{children:[ie(`create-pr`,g,i(`railPr.retryPr`),`rail-pr-create`),ce,re,y.continuation?he:ne]})):y.closed?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.prClosed`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`reopen`,`pr_closed`,i(`railPr.reopen`),`rail-pr-reopen`,void 0,(0,$.jsx)(Zs,{className:L,"aria-hidden":!0})),y.continuation?he:ne]})):g===`on_review`?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,$.jsx)(Qo,{className:L,"aria-hidden":!0}),i(`railPr.readyForReview`)]}),be=(0,$.jsxs)($.Fragment,{children:[ae,ce,ie(`create-pr`,`on_review`,i(`railPr.createPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch}),(0,$.jsx)(R,{className:L,"aria-hidden":!0})),re,y.continuation?he:ne]})):g===`pr_draft`&&e.prUrl?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,$.jsx)(R,{className:L,"aria-hidden":!0}),i(`railPr.draftPr`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`publish`,`pr_draft`,i(`railPr.publish`),`rail-pr-publish`,i(`railPr.publishTooltip`)),y.continuation?he:ne]})):g===`pr_draft`?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:i(`railPr.branchPushedHint`),children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),y.localOnly?i(`railPr.localOnly`):i(`railPr.branchPushed`)]}),be=(0,$.jsxs)($.Fragment,{children:[ie(`create-pr`,`pr_draft`,i(`railPr.retryPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),ce,re,y.continuation?he:ne]})):g===`pr_ready`?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-success/30 bg-accent-success/10 text-accent-success`,children:[(0,$.jsx)(ls,{className:L,"aria-hidden":!0}),i(`railPr.prReady`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`poll-merge`,`pr_ready`,i(`railPr.verifyPr`),`rail-pr-poll`,i(`railPr.verifyPrTooltip`)),y.continuation?he:ne]})):g===`pr_failed`?(U=(0,$.jsxs)(`span`,{className:`${N} border-destructive/30 bg-destructive/10 text-destructive`,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.prFailed`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`create-pr`,`pr_failed`,i(`railPr.retry`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),!e.prUrl&&re,y.continuation?he:ne]})):g===`implementation_failed`&&y.implementationFailed&&(U=(0,$.jsxs)(`span`,{className:`${N} border-destructive/30 bg-destructive/10 text-destructive`,title:i(`railPr.implementationFailedHint`),children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.implementationFailed`)]}),be=(0,$.jsx)($.Fragment,{children:y.continuation?he:ne})),(0,$.jsxs)(`div`,{"data-testid":`rail-pr-strip`,"data-decision":g,className:`flex items-center flex-wrap animate-in fade-in slide-in-from-top-1 duration-200 ${T?`gap-1`:`gap-1.5`}`,onClick:e=>e.stopPropagation(),children:[C&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-label":C,className:`sr-only`}),(0,$.jsx)(Mt,{deliveryId:e.prDeliveryId,repositories:e.repositoryDeliveries,busy:B,onAct:(t,n)=>A(t,e.decision,e.prDeliveryId,n),onCheckout:r?j:void 0}),U,e.operation&&(0,$.jsxs)(`span`,{className:`${N} border-accent-info/30 bg-accent-info/10 text-accent-info`,"data-testid":`rail-pr-operation`,children:[(0,$.jsx)(rn,{className:`${L} animate-spin`,"aria-hidden":!0}),i(`railPr.operation.${e.operation}`)]}),be,e.deliverySha&&(0,$.jsxs)(`span`,{className:`${N} ${e.deliveryOutcome===`delivered`?`border-accent-success/30 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/60`} font-mono`,"data-testid":`rail-pr-delivery-sha`,title:e.deliverySha,children:[(0,$.jsx)(Mo,{className:L,"aria-hidden":!0}),i(`railPr.deliveryCommit`,{sha:e.deliverySha.slice(0,8)})]}),fe,pe,S&&(0,$.jsx)(`span`,{className:`${N} border-border/60 bg-surface/60 text-foreground/55`,"data-testid":`rail-pr-status-code`,children:S}),(x||y.recoveryUnavailable||!b&&e.statusDetail&&!y.recoveryUnavailable||y.cleanupWarnings.length>0)&&(0,$.jsxs)(`div`,{className:`basis-full rounded-md border border-accent-warning/30 bg-accent-warning/10 text-accent-warning ${T?`px-1.5 py-1 text-[9px]`:`px-2 py-1.5 text-[10px]`}`,"data-testid":`rail-pr-delivery-detail`,children:[x&&(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5`,"data-testid":`rail-pr-recovery-interrupted`,children:[(0,$.jsx)(Zs,{className:`${L} mt-px shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i(`common:prRecovery.interrupted`)})]}),y.recoveryUnavailable&&(0,$.jsx)(`p`,{"data-testid":`rail-pr-recovery-unavailable`,children:i(`railPr.recoveryUnavailableBody`)}),y.recoveryUnavailable&&e.statusDetail&&!b&&(0,$.jsxs)(`details`,{className:`mt-1 text-foreground/60`,"data-testid":`rail-pr-recovery-technical-detail`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground/70`,children:i(`railPr.recoveryDetailSummary`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:e.statusDetail})]}),!b&&e.statusDetail&&!y.recoveryUnavailable&&(0,$.jsx)(`p`,{children:e.statusDetail}),y.cleanupWarnings.length>0&&(0,$.jsxs)(`div`,{className:x||!b&&e.statusDetail?`mt-1`:void 0,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:i(`railPr.cleanupIncomplete`,{count:y.cleanupWarnings.length})}),(0,$.jsx)(`ul`,{className:`mt-0.5 list-disc pl-4 text-foreground/60`,children:y.cleanupWarnings.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}-${e}`))})]})]}),y.safetyArchives.length>0&&(0,$.jsxs)(`details`,{className:`basis-full rounded-md border border-accent-info/25 bg-accent-info/5 text-foreground/65 ${T?`px-1.5 py-1 text-[9px]`:`px-2 py-1.5 text-[10px]`}`,"data-testid":`rail-pr-safety-archives`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-accent-info`,children:i(`railPr.safetyArchiveTitle`,{count:y.safetyArchives.length})}),(0,$.jsx)(`p`,{className:`mt-1`,children:i(`railPr.safetyArchiveHint`)}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[0.9em] text-foreground/55`,children:y.safetyArchives.map(e=>(0,$.jsx)(`li`,{className:`break-all`,children:e},e))})]}),(0,$.jsx)(Hn,{open:E(`merge-local`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-merge-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.mergeLocalConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.mergeLocalConfirmBody`,{base:e.baseBranch})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,"data-testid":`rail-pr-merge-local-confirm-btn`,onClick:()=>k(`merge-local`,`merge-local`),children:i(`railPr.mergeLocal`)})]})]})}),(0,$.jsx)(Hn,{open:E(`discard`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-discard-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(g===`implementation_failed`?`railPr.implementationFailedDiscardTitle`:`railPr.discardConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(g===`implementation_failed`?`railPr.implementationFailedDiscardBody`:`railPr.discardConfirmBody`)}),ee&&(0,$.jsx)(`p`,{className:`mt-2 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-2 py-1.5 text-xs text-accent-warning`,"data-testid":`rail-pr-discard-stacked-note`,children:i(`railPr.discardStackedNote`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:B,"data-testid":`rail-pr-discard-confirm-btn`,onClick:()=>k(`discard`,`discard`),children:i(`railPr.discard`)})]})]})}),(0,$.jsx)(Hn,{open:E(`dismiss`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-dismiss-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.dismissConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.dismissConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,"data-testid":`rail-pr-dismiss-confirm-btn`,onClick:()=>k(`dismiss`,`dismiss`),children:i(`railPr.dismiss`)})]})]})}),(0,$.jsx)(Hn,{open:E(`discard-local`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-discard-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.discardLocalConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.discardLocalConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:B,"data-testid":`rail-pr-discard-local-confirm-btn`,onClick:()=>k(`discard-local`,`discard`),children:i(`railPr.discardLocalResult`)})]})]})}),(0,$.jsx)(Hn,{open:E(`no-changes-done`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-no-changes-done-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.markDoneConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.markDoneConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,"data-testid":`rail-pr-no-changes-done-confirm-btn`,onClick:()=>k(`no-changes-done`,`acknowledge-no-changes`),children:i(`railPr.markDone`)})]})]})}),(0,$.jsx)(Hn,{open:E(`refine`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-refine-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.refineConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.refineConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:B,"data-testid":`rail-pr-refine-confirm-btn`,onClick:()=>k(`refine`,`discard`),children:i(`railPr.refine`)})]})]})}),(0,$.jsx)(Hn,{open:E(`recover-and-retry`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-recover-and-retry-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(ue?`railPr.recheckRecoveryConfirmTitle`:`railPr.recoverAndRetryConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(ue?`railPr.recheckRecoveryConfirmBody`:`railPr.recoverAndRetryConfirmBody`,{branch:e.branch??``})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,onClick:()=>k(`recover-and-retry`,`recover-and-retry`),children:i(ue?`railPr.recheckRecovery`:`railPr.recoverAndRetry`)})]})]})})]})}function LV({railIndex:e,value:t,onChange:n}){let{t:r}=K(`dashboard`),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(``),f=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!i)return;let t=!1;return s(!0),fetch(`${nt()}/rails/${e}/pr-candidates`).then(e=>e.ok?e.json():Promise.reject(Error(`${e.status}`))).then(e=>{t||l(Array.isArray(e.candidates)?e.candidates:[])}).catch(()=>{t||l([])}).finally(()=>{t||s(!1)}),()=>{t=!0}},[i,e]),(0,Q.useEffect)(()=>{if(!i)return;function e(e){f.current&&!f.current.contains(e.target)&&a(!1)}function t(e){e.key===`Escape`&&a(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=e=>{n(e),a(!1),d(``)},m=/^\d{1,9}$/.test(u.trim())?parseInt(u.trim(),10):null;return(0,$.jsxs)(`div`,{ref:f,className:`relative inline-flex items-center`,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-target-pr-selector`,title:r(`targetPr.chipTitle`),"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`inline-flex h-5 items-center gap-1 rounded border px-1 text-[10px] transition-colors focus:outline-none focus:ring-1 focus:ring-primary/40 ${t?`border-accent-info/50 text-accent-info hover:text-accent-info`:`border-border/50 bg-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,$.jsx)(R,{className:`h-3 w-3`,"aria-hidden":!0}),t?`#${t.number}`:r(`targetPr.chipNew`)]}),t&&(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`targetPr.clear`),onClick:()=>n(null),className:`ml-0.5 rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-2.5 w-2.5`,"aria-hidden":!0})}),i&&(0,$.jsxs)(`div`,{role:`listbox`,"aria-label":r(`targetPr.chipTitle`),className:`absolute left-0 top-6 z-50 w-72 rounded-lg border border-border bg-popover p-1.5 shadow-xl`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!t,onClick:()=>p(null),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-foreground hover:bg-muted/60`,children:[(0,$.jsx)(R,{className:`h-3 w-3 text-muted-foreground`,"aria-hidden":!0}),r(`targetPr.newPr`)]}),(0,$.jsx)(`div`,{className:`my-1 border-t border-border/60`}),o&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),r(`targetPr.loading`)]}),!o&&c!==null&&c.length===0&&(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:r(`targetPr.none`)}),!o&&(c??[]).map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t?.number===e.number,disabled:e.isCrossRepository,onClick:()=>p({number:e.number,title:e.title,headRefName:e.headRefName}),title:e.isCrossRepository?r(`targetPr.fork`):e.url,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-xs transition-colors ${e.isCrossRepository?`cursor-not-allowed text-muted-foreground/50`:`text-foreground hover:bg-muted/60`}`,children:[e.isCrossRepository?(0,$.jsx)(cs,{className:`mt-0.5 h-3 w-3 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`mt-0.5 h-3 w-3 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`block truncate font-medium`,children:[`#`,e.number,` · `,e.title]}),(0,$.jsxs)(`span`,{className:`block truncate text-[10px] text-muted-foreground`,children:[e.headRefName,e.isCrossRepository&&` — ${r(`targetPr.fork`)}`]})]})]},e.number)),(0,$.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,$.jsxs)(`form`,{className:`flex items-center gap-1.5 px-1 py-1`,onSubmit:e=>{e.preventDefault(),m&&p({number:m})},children:[(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),inputMode:`numeric`,placeholder:r(`targetPr.manualPlaceholder`),"aria-label":r(`targetPr.manualPlaceholder`),className:`h-6 w-full rounded border border-border/60 bg-transparent px-1.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-1 focus:ring-primary/40`}),(0,$.jsx)(`button`,{type:`submit`,disabled:!m,className:`h-6 shrink-0 rounded border border-border/60 px-2 text-[10px] text-muted-foreground enabled:hover:text-foreground disabled:opacity-40`,children:r(`targetPr.manualUse`)})]})]})]})}function RV(e){return`rail-${e+1}`}function zV(e){let t=/^rail-(\d+)$/.exec(e);if(!t)return null;let n=parseInt(t[1],10);return!Number.isInteger(n)||n<1?null:n-1}var BV=800;function VV({id:e,label:t,tickets:n,mode:r,status:i,activeJobId:a,profileName:o,aiEngine:s,freestyleModel:c,loopModel:l,providers:u,loopAvailable:d,selectedLoopId:f,reasoningEffort:p,targetPr:m,worktreeSummary:h,prDecision:g,onPrDecision:_,onPrCheckout:v,executionMetric:y,jiggleMode:b,dragHandleListeners:x,dragHandleAttributes:S,density:C=`normal`,onModeChange:w,onProfileChange:T,onEngineChange:E,onFreestyleModelChange:D,onLoopModelChange:O,onLoopChange:k,onEffortChange:A,onTargetPrChange:j,onToggle:M,onTicketClick:N,onDelete:P,onLongPress:F,onRename:I,onTicketMoveToSpecs:L}){let{t:R}=K(`dashboard`),z=zV(e),B=s??u?.[0]??`claude`,ee=dr(B),V=cr(B),H=!!E&&i!==`running`&&(u?.length??0)>1,te=!!T&&i!==`running`&&ee&&r!==`loop`,ne=!!D&&i!==`running`&&r===`freestyle`&&V,re=!!O&&i!==`running`&&r===`loop`,ie=B,ae=fz(ie),oe=l&&(ae.some(e=>e.value===l)||nr(ie)&&gD(l))?l:pz(ie),se=or(B,oe),ce=re&&O?(0,$.jsx)(wV,{provider:ie,value:oe,onChange:O,testId:`loop-model-selector`,ariaLabel:R(`railSelectors.loopModelTitle`)}):null,le=!!k&&i!==`running`,ue=H||ne||re||le,[de,fe]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!de)return;function e(e){e.target?.closest(`[role="menu"]`)||fe(null)}function t(e){e.key===`Escape`&&fe(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[de]);let{isOver:pe,setNodeRef:me}=UI({id:e}),{active:he}=BI(),ge=typeof he?.id==`number`,[_e,ve]=(0,Q.useState)(0),[ye,U]=(0,Q.useState)(!1),[be,xe]=(0,Q.useState)(!1),[Se,Ce]=(0,Q.useState)(!1),[W,we]=(0,Q.useState)(``),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(null),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(!1),ke=i===`running`,Ae=!ke,je=(0,Q.useCallback)(()=>{De.current&&=(clearTimeout(De.current),null)},[]),Me=(0,Q.useCallback)(()=>{Ae&&(Oe.current=!1,De.current=setTimeout(()=>{Oe.current=!0,F(),De.current=null},BV))},[Ae,F]),Ne=(0,Q.useCallback)(e=>{let t=e.touches[0];Ee.current={x:t.clientX,y:t.clientY},U(!1),xe(!1),Me()},[Me]),Pe=(0,Q.useCallback)(e=>{if(!Ee.current)return;let t=e.touches[0],n=t.clientX-Ee.current.x,r=t.clientY-Ee.current.y;(Math.abs(n)>10||Math.abs(r)>10)&&je(),Ae&&n<-10&&Math.abs(n)>Math.abs(r)*1.5&&(U(!0),ve(Math.max(n,-150)))},[Ae,je]),Fe=(0,Q.useCallback)(()=>{je(),ye&&(_e<-60&&Ae?(xe(!0),ve(-80)):(ve(0),xe(!1)),U(!1)),Ee.current=null},[_e,ye,Ae,je]),Ie=(0,Q.useCallback)(e=>{e.target.closest(`button`)||Me()},[Me]),Le=(0,Q.useCallback)(()=>{je()},[je]),Re=(0,Q.useCallback)(e=>{if(Oe.current){e.stopPropagation(),Oe.current=!1;return}be&&(xe(!1),ve(0))},[be]),ze=(0,Q.useCallback)(e=>{e.stopPropagation(),xe(!1),ve(0),P()},[P]),Be=b&&Ae?-(Array.from(e).reduce((e,t)=>e+t.charCodeAt(0),0)*53%400):void 0,G=Be===void 0?void 0:{animationDelay:`${Be}ms`};return C===`compact`?(0,$.jsxs)(`div`,{ref:me,"data-testid":`rail-row-compact-${e}`,"data-density":`compact`,onMouseDown:Ie,onMouseUp:Le,onMouseLeave:Le,onClick:Re,style:G,className:`group relative flex flex-col gap-1.5 rounded-xl border bg-card p-2.5 transition-all ${pe?`border-accent-info/60 shadow-[0_0_0_1px_hsl(var(--accent-info)/0.35),0_0_14px_hsl(var(--accent-info)/0.18)]`:ge?`border-dashed border-accent-info/35`:ke?`border-accent-success/40 shadow-sm`:`border-border/40 hover:border-accent-info/30 hover:shadow-md`} ${b&&Ae?`animate-jiggle`:``}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/70 transition-colors shrink-0`,...x,...S,children:(0,$.jsx)(fs,{className:`w-3 h-3`})}),(0,$.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${ke?`bg-accent-success shadow-[0_0_4px_hsl(var(--accent-success)/0.8)] animate-pulse`:i===`failed`?`bg-accent-warning shadow-[0_0_4px_hsl(var(--accent-warning)/0.6)]`:`bg-muted-foreground/25`}`,"aria-hidden":!0}),Se?(0,$.jsx)(`form`,{className:`flex items-center gap-0.5 min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let t=W.trim();t&&I(t),Ce(!1)},children:(0,$.jsx)(`input`,{ref:Te,type:`text`,value:W,onChange:e=>we(e.target.value),onBlur:()=>{let e=W.trim();e&&I(e),Ce(!1)},onKeyDown:e=>{e.key===`Escape`&&Ce(!1)},className:`flex-1 min-w-0 text-xs font-medium bg-transparent border-b border-accent-info/60 outline-none text-foreground/90 px-0.5`,autoFocus:!0})}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation();let n=t.startsWith(`Rail `)?t.slice(5):t;we(n),Ce(!0),setTimeout(()=>Te.current?.select(),0)},className:`flex-1 min-w-0 text-left text-xs font-medium text-foreground/90 hover:text-foreground truncate`,title:t,children:t})]}),n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-testid":`rail-row-compact-tickets-${e}`,children:n.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),N(e)},onMouseDown:t=>{t.button===2&&L&&(t.preventDefault(),t.stopPropagation(),fe({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{L&&(e.preventDefault(),e.stopPropagation())},onPointerDown:e=>e.stopPropagation(),title:`#${e.id} ${e.title}`,className:`inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-mono font-medium border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors`,children:[`#`,e.id]},e.id))}),de&&L&&(0,xb.createPortal)((0,$.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-compact-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(de.y,window.innerHeight-60),left:Math.min(de.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),L(de.ticketId),fe(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,$.jsx)(Rt,{className:`w-3 h-3`,"aria-hidden":!0}),R(`railRow.moveToSpecs`)]})}),document.body),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[E&&!ke&&(0,$.jsx)(CV,{value:s??null,providers:u??[],onChange:E}),T&&!ke&&ee&&r!==`loop`&&(0,$.jsx)(SV,{provider:B,value:o??null,onChange:T}),D&&!ke&&r===`freestyle`&&V&&(0,$.jsx)(wV,{provider:B,value:c??null,onChange:D}),ce,k&&!ke&&(0,$.jsx)(NV,{value:bV(f,r),onChange:k,freestyleAvailable:V,loopsEnabled:d}),A&&!ke&&r===`loop`&&se&&(0,$.jsx)(FV,{provider:B,model:oe,value:p??null,onChange:A}),j&&!ke&&z!==null&&(0,$.jsx)(LV,{railIndex:z,value:m??null,onChange:j}),(0,$.jsx)(hV,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:V,loopAvailable:d,onModeChange:w,onToggle:M})]}),ke&&y&&(0,$.jsx)(PV,{metric:y}),h&&(h.merged>0||h.needsReview>0)&&(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px]`,"data-testid":`rail-worktree-summary`,children:[h.merged>0&&(0,$.jsx)(`span`,{className:`text-accent-success`,children:R(`railControls.worktreesMerged`,{count:h.merged})}),h.needsReview>0&&(0,$.jsx)(`span`,{className:`text-accent-warning`,children:R(`railControls.worktreesNeedsReview`,{count:h.needsReview})})]}),g&&_&&(0,$.jsx)(`div`,{className:`mt-1`,children:(0,$.jsx)(IV,{decision:g,density:`compact`,act:_,checkout:v},g.prDeliveryId)}),b&&Ae&&(0,$.jsx)(`button`,{type:`button`,onClick:ze,className:`absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-sm hover:opacity-90 transition-opacity`,"aria-label":R(`railRow.deleteRail`,{label:t}),children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]}):(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl`,onClick:Re,onTouchStart:Ne,onTouchMove:Pe,onTouchEnd:Fe,onMouseDown:Ie,onMouseUp:Le,onMouseLeave:Le,children:[Ae&&(be||_e<0)&&(0,$.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-20 flex items-center justify-center bg-red-500/90 rounded-r-xl z-0`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:ze,className:`flex flex-col items-center gap-1 text-white`,children:[(0,$.jsx)(dn,{className:`w-5 h-5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-medium`,children:R(`common:actions.delete`)})]})}),(0,$.jsxs)(`div`,{className:`relative z-10 flex flex-col rounded-xl border overflow-hidden bg-card ${b&&Ae?`animate-jiggle`:``} ${pe?`border-primary/50 shadow-[0_0_0_1px_hsl(var(--primary)/0.25),0_0_12px_hsl(var(--primary)/0.08)]`:`border-border/40 hover:border-border/60`}`,style:{transform:_e<0?`translateX(${_e}px)`:void 0,transition:ye?`none`:`transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)`,...Be===void 0?{}:{animationDelay:`${Be}ms`}},children:[(0,$.jsxs)(`div`,{className:`flex flex-col border-b border-border/30 bg-gradient-to-r from-muted/30 to-transparent shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors -ml-1`,...x,...S,children:(0,$.jsx)(fs,{className:`w-3.5 h-3.5`})}),(0,$.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${i===`running`?`bg-emerald-400 shadow-[0_0_4px_hsl(142_70%_56%/0.8)] animate-pulse`:i===`failed`?`bg-amber-400 shadow-[0_0_4px_hsl(38_92%_50%/0.6)]`:`bg-muted-foreground/25`}`}),Se?(0,$.jsxs)(`form`,{className:`flex items-center gap-0.5`,onSubmit:e=>{e.preventDefault();let t=W.trim();t&&I(t),Ce(!1)},children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground/50`,children:`Rail `}),(0,$.jsx)(`input`,{ref:Te,type:`text`,value:W,onChange:e=>we(e.target.value),onBlur:()=>{let e=W.trim();e&&I(e),Ce(!1)},onKeyDown:e=>{e.key===`Escape`&&Ce(!1)},className:`w-24 text-xs font-medium bg-transparent border-b border-primary/50 outline-none text-foreground/80 px-0.5`,autoFocus:!0})]}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation();let n=t.startsWith(`Rail `)?t.slice(5):t;we(n),Ce(!0),setTimeout(()=>Te.current?.select(),0)},className:`text-xs font-medium text-foreground/80 hover:text-foreground hover:underline decoration-dotted underline-offset-2 cursor-text transition-colors`,children:t}),n.length>0&&(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground bg-muted/30 rounded-full px-1.5 py-0.5 leading-none`,children:n.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[!ue&&te&&T&&(0,$.jsx)(SV,{provider:B,value:o??null,onChange:T}),(0,$.jsx)(hV,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:V,loopAvailable:d,onModeChange:w,onToggle:M}),b&&Ae&&(0,$.jsx)(`button`,{type:`button`,onClick:ze,className:`w-5 h-5 flex items-center justify-center rounded-full bg-red-500 text-white shadow-sm hover:bg-red-600 transition-colors`,children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]})]}),ke&&y&&(0,$.jsx)(`div`,{className:`px-3 pb-1`,children:(0,$.jsx)(PV,{metric:y})}),h&&(h.merged>0||h.needsReview>0)&&(0,$.jsxs)(`div`,{className:`px-3 pb-1 flex items-center gap-2 text-[10px]`,children:[h.merged>0&&(0,$.jsx)(`span`,{className:`text-accent-success`,children:R(`railControls.worktreesMerged`,{count:h.merged})}),h.needsReview>0&&(0,$.jsx)(`span`,{className:`text-accent-warning`,children:R(`railControls.worktreesNeedsReview`,{count:h.needsReview})})]}),g&&_&&(0,$.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,$.jsx)(IV,{decision:g,density:`normal`,act:_,checkout:v},g.prDeliveryId)}),ue&&(0,$.jsxs)(`div`,{className:`flex items-center flex-wrap gap-x-3 gap-y-1 px-3 py-1.5 border-t border-border/20 bg-background/20`,children:[H&&E&&(0,$.jsx)(CV,{value:s??null,providers:u??[],onChange:E}),ue&&te&&T&&(0,$.jsx)(SV,{provider:B,value:o??null,onChange:T}),ne&&D&&(0,$.jsx)(wV,{provider:B,value:c??null,onChange:D}),ce,le&&k&&(0,$.jsx)(NV,{value:bV(f,r),onChange:k,freestyleAvailable:V,loopsEnabled:d}),r===`loop`&&!ke&&se&&A&&(0,$.jsx)(FV,{provider:B,model:oe,value:p??null,onChange:A}),j&&!ke&&z!==null&&(0,$.jsx)(LV,{railIndex:z,value:m??null,onChange:j})]})]}),(0,$.jsx)(`div`,{ref:me,"data-drop-target":ge?`available`:void 0,className:`min-h-[56px] px-3 py-2 space-y-1.5 transition-colors duration-150 ${pe?`bg-accent-info/[0.06]`:ge?`bg-accent-info/[0.02]`:`bg-card/20`}`,children:n.length===0?(0,$.jsx)(`div`,{className:`h-10 flex items-center justify-center rounded-lg border border-dashed transition-all duration-150 ${pe?`border-accent-info/60 text-accent-info/80 bg-accent-info/[0.06]`:ge?`border-accent-info/35 text-accent-info/60`:`border-border/25 text-muted-foreground/30`}`,children:(0,$.jsx)(`span`,{className:`text-[10px] select-none`,children:R(pe?`railRow.dropHere`:ge?`railRow.dropOnThisRail`:`railRow.dragSpecsHere`)})}):(0,$.jsx)(pL,{items:n.map(e=>e.id),strategy:lL,children:n.map(e=>(0,$.jsx)(`div`,{onMouseDown:t=>{t.button===2&&L&&(t.preventDefault(),t.stopPropagation(),fe({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{L&&(e.preventDefault(),e.stopPropagation())},children:(0,$.jsx)(ML,{ticket:e,onClick:N,dragDisabled:i===`running`})},e.id))})}),de&&L&&C===`normal`&&(0,xb.createPortal)((0,$.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-normal-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(de.y,window.innerHeight-60),left:Math.min(de.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),L(de.ticketId),fe(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,$.jsx)(Rt,{className:`w-3 h-3`,"aria-hidden":!0}),R(`railRow.moveToSpecs`)]})}),document.body)]})]})}function HV(e,t,n,r){return{...e,[t]:{...e[t]??{},[n]:r}}}function UV(e){if(!e)return null;let t=Object.values(e);if(t.length===0)return null;let n=0,r=0,i=0;for(let e of t)e===`merged`?n++:e===`needs-review`?r++:e===`failed`&&i++;return{merged:n,needsReview:r,failed:i,reported:t.length}}var WV=`__rail:`;function GV(e){return`${WV}${e}`}function KV(e){return typeof e==`string`&&e.startsWith(`__rail:`)}function qV(e){return e.slice(7)}function JV(e,t,n){let r=new Set(n),i=RV(t),a=e.some(e=>e.id===i);return e.map((e,n)=>(a?e.id===i:n===t)?{...e,status:`idle`,activeJobId:void 0,ticketIds:r.size>0?e.ticketIds.filter(e=>!r.has(e)):[]}:e)}function YV({railId:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=xL({id:GV(e)});return(0,$.jsx)(`div`,{ref:i,style:{transform:_P.Translate.toString(a),transition:o,opacity:s?.4:void 0,position:`relative`,zIndex:s?50:void 0},children:t({listeners:r??{},attributes:n,isDragging:s})})}function XV({rails:e,ticketMap:t,railWorktrees:n,railMetrics:r,railPrDecisions:i,onPrDecision:a,onPrCheckout:o,providers:s,onModeChange:c,onProfileChange:l,onEngineChange:u,onFreestyleModelChange:d,onLoopModelChange:f,loopAvailable:p,onLoopChange:m,onEffortChange:h,onTargetPrChange:g,onToggle:_,onTicketClick:v,onAddRail:y,onDeleteRail:b,onRenameRail:x,onTicketMoveToSpecs:S,onLaunchAll:C,launchAllCount:w}){let{t:T}=K(`dashboard`),E=e.filter(e=>e.status===`running`).length,[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(null),[A,j]=(0,Q.useState)(`normal`);(0,Q.useEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=k.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width;j(e<320?`compact`:`normal`)}});return t.observe(e),()=>t.disconnect()},[]);let M=(0,Q.useCallback)(()=>{D&&O(!1)},[D]);(0,Q.useEffect)(()=>{if(!D)return;let e=e=>{e.key===`Escape`&&O(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D]);let N=e.map(e=>GV(e.id));return(0,$.jsxs)(`div`,{ref:k,className:`flex flex-col h-full`,"data-density":A,onClick:M,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 border-b border-border/40 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xs,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-accent-secondary`,children:T(`railsBoard.title`)}),E>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-emerald-400 aurora-light:text-accent-success bg-emerald-400/10 aurora-light:bg-accent-success/10 rounded-full px-1.5 py-0.5 font-medium whitespace-nowrap`,children:T(`railsBoard.runningCount`,{count:E})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C&&(0,$.jsxs)(`button`,{type:`button`,disabled:(w??0)===0,onClick:e=>{e.stopPropagation(),C()},title:T(`railsBoard.launchAllTitle`),className:`flex items-center gap-1.5 h-7 px-2.5 text-xs font-semibold rounded-md border border-emerald-400/50 text-emerald-400 aurora-light:text-accent-success aurora-light:border-accent-success/50 bg-gradient-to-r from-emerald-400/10 to-accent-primary/10 hover:from-emerald-400/20 hover:to-accent-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:from-emerald-400/10 disabled:hover:to-accent-primary/10`,children:[(0,$.jsx)(Xs,{className:`w-3.5 h-3.5`}),T(`railsBoard.launchAll`),(w??0)>0&&(0,$.jsx)(`span`,{className:`text-[10px] font-mono rounded-full bg-emerald-400/15 px-1.5 py-0.5 leading-none`,children:w})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y()},className:`flex items-center gap-1 h-7 px-2.5 text-xs font-medium rounded-md border border-accent-primary/50 text-accent-primary hover:bg-accent-primary/10 transition-colors`,children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5`}),T(`common:actions.add`)]})]})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-2.5`,children:(0,$.jsx)(pL,{items:N,strategy:lL,children:e.map((e,y)=>{let C=zV(e.id)??y;return(0,$.jsx)(YV,{railId:e.id,children:({listeners:w,attributes:T})=>(0,$.jsx)(`div`,{"data-tour":y===0?`rail-1`:void 0,children:(0,$.jsx)(VV,{id:e.id,label:e.label,tickets:e.ticketIds.map(e=>t.get(e)).filter(e=>e!==void 0),mode:e.mode,status:e.status,activeJobId:e.activeJobId,profileName:e.profileName??null,aiEngine:e.aiEngine??null,freestyleModel:e.freestyleModel??null,loopModel:e.loopModel??null,worktreeSummary:UV(n?.[C]),prDecision:i?.get(C)??null,onPrDecision:a?(e,t,n,r)=>a(C,e,t,n,r):void 0,onPrCheckout:o?(e,t)=>o(C,e,t):void 0,executionMetric:r?.[C]??null,providers:s,loopAvailable:p,selectedLoopId:e.selectedLoopId??null,reasoningEffort:e.reasoningEffort??null,targetPr:e.targetPr??null,jiggleMode:D,density:A,dragHandleListeners:w,dragHandleAttributes:T,onModeChange:t=>c(e.id,t),onProfileChange:l?t=>l(e.id,t):void 0,onEngineChange:u?t=>u(e.id,t):void 0,onFreestyleModelChange:d?t=>d(e.id,t):void 0,onLoopModelChange:f?t=>f(e.id,t):void 0,onLoopChange:m?t=>m(e.id,t):void 0,onEffortChange:h?t=>h(e.id,t):void 0,onTargetPrChange:g?t=>g(e.id,t):void 0,onToggle:()=>_(e.id),onTicketClick:v,onDelete:()=>b(e.id),onLongPress:()=>O(!0),onRename:t=>x(e.id,t),onTicketMoveToSpecs:S})})},e.id)})})})]})}var ZV=new Set([`editing`,`writing`,`reading`,`searching`,`running`]);function QV(e){return e.length>40?`${e.slice(0,39)}…`:e}function $V(e){return typeof e!=`string`||e.length===0?``:QV(e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??``)}function eH(e){return typeof e!=`string`||e.length===0?``:QV((e.trim().split(/\s+/)[0]??``).replace(/^['"`]+/,``))}var tH=/(^|\/)(ba|z|k|da|fi)?sh$/;function nH(e){if(e.length===0||!tH.test(e[0]))return e;let t=e.slice(1).filter(e=>!e.startsWith(`-`));return t.length>0?t:e}function rH(e){return Array.isArray(e)?eH(nH(e.filter(e=>typeof e==`string`)).join(` `)):typeof e!=`string`||e.length===0?``:eH(nH(e.trim().split(/\s+/)).join(` `))}function iH(e){return Array.isArray(e)?nH(e.filter(e=>typeof e==`string`)).join(` `).trim():typeof e!=`string`||e.length===0?``:nH(e.trim().split(/\s+/)).join(` `).trim()}function aH(e){if(typeof e!=`string`)return``;try{let t=JSON.parse(e)?.command;if(Array.isArray(t)||typeof t==`string`)return rH(t)}catch{}return``}function oH(e,t){let n=t??{},r=$V(n.file_path??n.path);switch(typeof e==`string`?e.toLowerCase():``){case`edit`:case`multiedit`:case`notebookedit`:case`update`:case`editfile`:case`strreplace`:case`searchreplace`:return{step:!0,actionKey:`editing`,actionArg:r};case`write`:case`create`:case`writefile`:return{step:!0,actionKey:`writing`,actionArg:r};case`read`:case`readfile`:case`readmediafile`:return{step:!0,actionKey:`reading`,actionArg:r};case`grep`:case`glob`:case`search`:case`websearch`:return{step:!0,actionKey:`searching`,actionArg:QV(String(n.pattern??n.query??``))};case`bash`:case`shell`:return{step:!0,actionKey:`running`,actionArg:rH(n.command)};case`task`:return{step:!0,actionKey:`delegating`,actionArg:QV(String(n.subagent_type??n.description??``).replace(/^sr-/,``))};default:return{step:!0,actionKey:`working`}}}function sH(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e;if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}catch{return}}function cH(e){let t=e.event_type,n={};try{let t=JSON.parse(e.payload);t&&typeof t==`object`&&!Array.isArray(t)&&(n=t)}catch{}if(t===`assistant`){let e=n.message?.content;if(Array.isArray(e)){let t=e.filter(e=>e?.type===`tool_use`);if(t.length>0){let e=t[t.length-1];return{...oH(e.name,e.input),stepCount:t.length}}if(e.some(e=>e?.type===`text`))return{step:!0,actionKey:`thinking`}}let t=(Array.isArray(n.tool_calls)?n.tool_calls:[]).flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.function;return!t||typeof t!=`object`||Array.isArray(t)?[]:[t]});if(t.length>0){let e=t[t.length-1];return{...oH(e.name,sH(e.arguments)),stepCount:t.length}}return typeof n.content==`string`||Array.isArray(n.content)&&n.content.length>0?{step:!0,actionKey:`thinking`}:{step:!0}}if(t===`tool_use`)return oH(n.name,n.input);if(t===`item.completed`){let e=n.item,t=e?.type;return t===`agent_message`?{step:!0,actionKey:`thinking`}:t===`agent_reasoning`?{step:!0,actionKey:`reasoning`}:t===`function_call`||t===`local_shell_call`||t===`command_execution`?{step:!0,actionKey:`running`,actionArg:rH(e?.command)||aH(e?.arguments)||(typeof e?.name==`string`?QV(e.name):``)||(t===`local_shell_call`?`shell`:``)}:{step:!0}}return{step:!1}}function lH(e){let t={};try{let n=JSON.parse(e.payload);n&&typeof n==`object`&&!Array.isArray(n)&&(t=n)}catch{return``}if(e.event_type===`assistant`){let e=t.message?.content;if(!Array.isArray(e))return``;for(let t of e){if(t?.type!==`tool_use`)continue;let e=t.input?.command;if(e)return iH(e)}return``}if(e.event_type===`item.completed`){let e=t.item;if(!e)return``;if(e.command)return iH(e.command);if(typeof e.arguments==`string`)try{let t=JSON.parse(e.arguments);if(t?.command)return iH(t.command)}catch{return``}}return``}var uH=(0,Q.createContext)({});function dH(){return(0,Q.useContext)(uH)}function fH({activeProjectId:e,children:t}){let[n,r]=(0,Q.useState)(new Map),{registerHandler:i,unregisterHandler:a}=qe(),o=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{o.current=e},[e]),(0,Q.useEffect)(()=>{if(r(new Map),!e)return;let t=!1;return fetch(`/api/projects/${e}/rails`).then(e=>e.ok?e.json():null).then(e=>{if(t||!e?.activeLoopRuns)return;let n=new Map;for(let[t,r]of Object.entries(e.activeLoopRuns))r?.loopRunId&&n.set(r.loopRunId,{railIndex:Number(t),startedAt:r.startedAt?new Date(r.startedAt).getTime():Date.now(),steps:r.steps??0,lines:r.lines??0});n.size!==0&&r(e=>{let t=new Map(e);for(let[e,r]of n)t.has(e)||t.set(e,r);return t})}).catch(()=>{}),()=>{t=!0}},[e]);let s=(0,Q.useCallback)(e=>{let t=e;if(!(!t||typeof t.type!=`string`)){if(t.type===`loop.run_started`){if(t.projectId!==o.current||!t.loopRunId)return;r(e=>{let n=new Map(e);return n.set(t.loopRunId,{railIndex:t.railIndex??0,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`loop.run_completed`){r(e=>{if(!t.loopRunId||!e.has(t.loopRunId))return e;let n=new Map(e);return n.delete(t.loopRunId),n});return}if(t.type===`rail.job_started`){if(t.projectId!==o.current||!t.jobId||t.railIndex==null)return;r(e=>{let n=new Map(e);return n.set(t.jobId,{railIndex:t.railIndex,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`rail.job_completed`||t.type===`rail.job_stopped`){r(e=>{if(!t.jobId||!e.has(t.jobId))return e;let n=new Map(e);return n.delete(t.jobId),n});return}if(t.type===`event`&&t.event_type&&t.jobId){let e=cH({event_type:t.event_type,payload:t.payload??``});if(!e.step)return;r(n=>{let r=n.get(t.jobId);if(!r)return n;let i=new Map(n);return i.set(t.jobId,{...r,steps:r.steps+(e.stepCount??1)}),i});return}t.type===`log`&&t.processId&&r(e=>{let n=e.get(t.processId);if(!n)return e;let r=new Map(e);return r.set(t.processId,{...n,lines:n.lines+1}),r})}},[]);(0,Q.useLayoutEffect)(()=>(i(`rail-exec-metrics`,s),()=>a(`rail-exec-metrics`)),[s,i,a]);let c=(0,Q.useMemo)(()=>{let e={};for(let t of n.values()){let n=e[t.railIndex];n?(n.startedAt=Math.min(n.startedAt,t.startedAt),n.steps+=t.steps,n.lines+=t.lines):e[t.railIndex]={startedAt:t.startedAt,steps:t.steps,lines:t.lines}}return e},[n]);return(0,$.jsx)(uH.Provider,{value:c,children:t})}var pH=(0,Q.createContext)({decisions:new Map,hydrated:!0,act:async()=>({status:0,ok:!1,error:`no_provider`}),checkout:async()=>({status:0,ok:!1,error:`no_provider`})});function mH(){return(0,Q.useContext)(pH)}function hH(e,t){return ut(e,t)}var gH=new Set([`merged`,`discarded`,`completed`,`superseded`]),_H=new Set([`create-pr`,`publish`,`discard`,`poll-merge`,`merge-local`,`dismiss`,`reopen`,`acknowledge-no-changes`,`recover-and-retry`]);function vH(e,t){return JSON.stringify(e)===JSON.stringify(t)}function yH({activeProjectId:e,children:t}){let{t:n}=K(`dashboard`),[r,i]=(0,Q.useState)(new Map),[a,o]=(0,Q.useState)(!1),{registerHandler:s,unregisterHandler:c,connectionStatus:l}=qe(),u=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{u.current=e},[e]);let d=(0,Q.useRef)(r),f=(0,Q.useRef)(new Map),p=(0,Q.useRef)(0),m=(0,Q.useRef)(new Set),h=(0,Q.useRef)(new Map),g=(0,Q.useRef)(new Set),_=(0,Q.useRef)(new Map),v=(0,Q.useCallback)((e,t=!0)=>{let r=d.current,a=r.get(e.railIndex),o=gH.has(e.decision),s=e.restoredFromDeliveryId??null,c=h.current.get(e.prDeliveryId),l=a?.supersedesDeliveryId===e.prDeliveryId?a.prDeliveryId:null,u=!!(s&&_.current.get(e.prDeliveryId)!==s&&(!c||c===s)&&(!l||l===s));if(a?.prDeliveryId===e.prDeliveryId){let t=Ft(a.updatedAt,e.updatedAt);if(t===-1||t===0&&!vH(a,e))return`stale`;if(t===0&&vH(a,e))return`accepted`}if(!o&&(g.current.has(e.prDeliveryId)||m.current.has(e.prDeliveryId))&&!u)return`stale`;let p=!1;if(a&&a.prDeliveryId!==e.prDeliveryId)if(u&&a.prDeliveryId===s)p=!0;else{let t=e.supersedesDeliveryId===a.prDeliveryId,n=a.supersedesDeliveryId===e.prDeliveryId||m.current.has(e.prDeliveryId),r=e.createdAt?Date.parse(e.createdAt):NaN,i=a.createdAt?Date.parse(a.createdAt):NaN;if(n||!t&&!(Number.isFinite(r)&&Number.isFinite(i)&&r>i))return o&&g.current.add(e.prDeliveryId),e.decision===`superseded`&&m.current.add(e.prDeliveryId),o?`untracked`:`stale`;p=!0}if(u&&s&&(g.current.delete(e.prDeliveryId),m.current.delete(e.prDeliveryId),g.current.add(s),_.current.set(e.prDeliveryId,s),h.current.set(e.prDeliveryId,s)),o){if(g.current.add(e.prDeliveryId),e.decision===`superseded`&&m.current.add(e.prDeliveryId),!a||a.prDeliveryId!==e.prDeliveryId)return`untracked`;if(t){if(e.safetyArchives?.length){let t=e.safetyArchives.join(`
69
+ `);J.warning(n(`railPr.safetyArchiveTitle`,{count:e.safetyArchives.length}),{description:`${n(`railPr.safetyArchiveHint`)}\n${t}`,duration:1/0,action:{label:n(`railPr.copySafetyArchive`),onClick:()=>{navigator.clipboard?.writeText(t)}}})}if(e.cleanupWarnings?.length){let t=e.cleanupWarnings.join(`
70
+ `);J.warning(n(`railPr.cleanupIncomplete`,{count:e.cleanupWarnings.length}),{description:`${n(`railPr.cleanupIncompleteHint`)}\n${t}`,duration:1/0,action:{label:n(`railPr.copyCleanupDetails`),onClick:()=>{navigator.clipboard?.writeText(t)}}})}else e.decision===`merged`?J.success(n(`railPr.mergedToast`)):e.decision===`discarded`?J.info(n(`railPr.discardedToast`)):e.decision===`completed`&&J.success(n(`railPr.completedToast`))}}else e.supersedesDeliveryId&&(m.current.add(e.supersedesDeliveryId),h.current.set(e.supersedesDeliveryId,e.prDeliveryId)),p&&a&&m.current.add(a.prDeliveryId);let v=new Map(r);return o?v.delete(e.railIndex):v.set(e.railIndex,e),f.current.set(e.railIndex,(f.current.get(e.railIndex)??0)+1),d.current=v,i(v),`accepted`},[n]),y=(0,Q.useCallback)(async(e,t)=>{let n=++p.current,r=new Map(f.current);try{let t=await fetch(`/api/projects/${e}/rails`);if(!t.ok)return;let a=await t.json();if(n!==p.current||u.current!==e)return;let o=new Map;for(let[e,t]of Object.entries(a.prDeliveries??{})){let n=hH(t,Number(e)),r=d.current.get(n?.railIndex??Number(e)),i=n?.restoredFromDeliveryId??null,a=n?h.current.get(n.prDeliveryId):void 0,s=n&&r?.supersedesDeliveryId===n.prDeliveryId?r.prDeliveryId:null,c=!!(n&&i&&_.current.get(n.prDeliveryId)!==i&&(!a||a===i)&&(!s||s===i));n&&!gH.has(n.decision)&&(c||!g.current.has(n.prDeliveryId)&&!m.current.has(n.prDeliveryId))&&o.set(Number(e),n)}let s=d.current,c=new Map(o);for(let[e,t]of f.current){if(t===(r.get(e)??0))continue;let n=s.get(e);n?c.set(e,n):c.delete(e)}for(let e of c.values()){e.supersedesDeliveryId&&(m.current.add(e.supersedesDeliveryId),h.current.set(e.supersedesDeliveryId,e.prDeliveryId));let t=e.restoredFromDeliveryId;t&&_.current.get(e.prDeliveryId)!==t&&(!h.current.get(e.prDeliveryId)||h.current.get(e.prDeliveryId)===t)&&(g.current.delete(e.prDeliveryId),m.current.delete(e.prDeliveryId),g.current.add(t),_.current.set(e.prDeliveryId,t),h.current.set(e.prDeliveryId,t))}d.current=c,i(c)}catch{}finally{t&&n===p.current&&u.current===e&&o(!0)}},[]);(0,Q.useEffect)(()=>{u.current=e,p.current++;let t=new Map;if(d.current=t,i(t),o(!1),f.current=new Map,m.current=new Set,h.current=new Map,g.current=new Set,_.current=new Map,!e){o(!0);return}y(e,!0)},[e,y]);let b=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`rail.pr_state`||t.projectId!==u.current||typeof t.railIndex!=`number`||typeof t.prDeliveryId!=`string`||!t.decision)return;let n=ut(t,t.railIndex);n&&v(n)},[v]);(0,Q.useLayoutEffect)(()=>(s(`rail-pr-decision`,b),()=>c(`rail-pr-decision`)),[b,s,c]),(0,Q.useEffect)(()=>{let e=()=>{let e=u.current;e&&y(e,!1)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]);let x=(0,Q.useRef)(l);(0,Q.useEffect)(()=>{let e=x.current;x.current=l;let t=u.current;t&&l===`connected`&&e!==`connected`&&y(t,!1)},[l,y]);let S=(0,Q.useCallback)(async(e,t,n,r,i)=>{let a=d.current.get(e),o=u.current;if(!a||!o)return{status:0,ok:!1,error:`no_delivery`};if(a.prDeliveryId!==r)return{status:409,ok:!1,error:`stale_decision`,current:a.decision,snapshotApplication:`stale`};try{let e=await fetch(`/api/projects/${o}/rails/pr-decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:a.prDeliveryId,action:t,expectedDecision:n,...i?{repositoryId:i}:{}})}),r=await e.json().catch(()=>({})),s=ut(r.snapshot),c;return s&&u.current===o&&(c=v(s)),{...r,snapshot:s,snapshotApplication:c,busy:e.status===409&&r.error===`operation_in_progress`,operation:s?.operation??(typeof r.operation==`string`&&_H.has(r.operation)?r.operation:null),status:e.status,ok:e.ok&&r.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[v]),C=(0,Q.useCallback)(async(e,t,n)=>{let r=d.current.get(e),i=u.current;if(!r||!i)return{status:0,ok:!1,error:`no_delivery`};if(r.prDeliveryId!==t)return{status:409,ok:!1,error:`stale_decision`,detail:`The delivery generation changed before checkout.`};try{let e=await fetch(`/api/projects/${i}/rails/pr-checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:r.prDeliveryId,...n?{repositoryId:n}:{}})}),t=await e.json().catch(()=>({}));return{...t,status:e.status,ok:e.ok&&t.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),w=(0,Q.useMemo)(()=>({decisions:r,hydrated:a,act:S,checkout:C}),[r,a,S,C]);return(0,$.jsx)(pH.Provider,{value:w,children:t})}function bH(e){return e?`specrails-desktop:dashboard-split:${e}`:null}function xH(e){let t=bH(e);if(!t)return null;try{let e=localStorage.getItem(t);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function SH(e,t){let n=bH(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function CH(e,t){let n=Math.max(320,t-280);return Math.min(Math.max(e,320),n)}var wH=.7;function TH(e){return CH(Math.round(e*wH),e)}function EH(e,t){let n=TH(t);return Math.abs(e-n)<=48?n:e}function DH(e,t){let[n,r]=(0,Q.useState)(()=>typeof window<`u`?window.innerWidth:1200),i=(0,Q.useRef)(n),[a,o]=(0,Q.useState)(()=>{if(typeof window>`u`)return null;let e=window.innerWidth;return e<900?null:TH(e)}),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let e=t?.current?.clientWidth||window.innerWidth;if(r(e),i.current=e,e<900){o(null);return}o(TH(e))},[e,t]),(0,Q.useEffect)(()=>{function n(t){if(r(t),t<900){i.current=t,o(null);return}let n=t-i.current;i.current=t,o(r=>{let i=r??xH(e)??TH(t),a=CH(r!==null&&Number.isFinite(n)?i+n:i,t);return a!==r&&SH(e,a),a})}let a=t?.current;if(a&&typeof ResizeObserver<`u`){let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});return e.observe(a),n(a.clientWidth||window.innerWidth),()=>e.disconnect()}function s(){n(window.innerWidth)}return window.addEventListener(`resize`,s),()=>window.removeEventListener(`resize`,s)},[e,t]);let u=(0,Q.useCallback)(()=>{if(c.current=null,l.current===null)return;let e=CH(l.current,n);l.current=null,o(e)},[n]),d=(0,Q.useCallback)(e=>{if(!s.current)return;let t=e.clientX-s.current.startClientX;l.current=s.current.startLeftWidth+t,c.current===null&&(c.current=requestAnimationFrame(u))},[u]),f=(0,Q.useCallback)(t=>{if(!s.current)return;let{pointerId:r,element:i}=s.current;try{i.releasePointerCapture(r)}catch{}s.current=null,window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o(t=>{if(t===null)return t;let r=CH(EH(t,n),n);return SH(e,r),r})},[d,e,n]),p=(0,Q.useCallback)(e=>{let t=e.nativeEvent??e,n=e.currentTarget??t.target;try{n.setPointerCapture(t.pointerId)}catch{}s.current={pointerId:t.pointerId,element:n,startClientX:t.clientX,startLeftWidth:a??0},window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[d,f,a]),m=(0,Q.useCallback)(()=>{if(typeof window>`u`)return;let n=t?.current?.clientWidth||window.innerWidth;if(n<900)return;let r=TH(n);o(r),SH(e,r)},[e,t]);return{leftWidth:a,enabled:a!==null&&n>=900,beginDrag:p,resetToDefault:m}}function OH({leftWidth:e,onPointerDown:t,onReset:n,viewport:r}){let i=(0,Q.useCallback)(t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`&&(t.preventDefault(),e-n)},[e]);return(0,$.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":320,"aria-valuemax":Math.max(320,r-280),tabIndex:0,onPointerDown:t,onDoubleClick:n,onKeyDown:i,className:`relative w-1.5 shrink-0 cursor-col-resize group select-none touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/60`,"data-testid":`dashboard-splitter`,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border/40 group-hover:bg-accent-info/40 group-focus-visible:bg-accent-info/60 transition-colors`}),(0,$.jsxs)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 flex flex-col items-center justify-center gap-1 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`})]})]})}function kH({open:e,allLabels:t,onClose:n,onCreate:r}){let{t:i}=K(`tickets`),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(`todo`),[d,f]=(0,Q.useState)(`medium`),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e&&setTimeout(()=>x.current?.focus(),100)},[e]),(0,Q.useEffect)(()=>{e||(o(``),c(``),u(`todo`),f(`medium`),m([]),g(void 0),v(``))},[e]);let C=(0,Q.useMemo)(()=>{if(!_.trim())return[];let e=_.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!p.includes(t)).slice(0,5)},[_,t,p]),w=(0,Q.useCallback)(e=>{let t=e.trim();t&&!p.includes(t)&&m(e=>[...e,t]),v(``)},[p]),T=(0,Q.useCallback)(async()=>{if(!a.trim())return;b(!0);let e=await r({title:a.trim(),description:s.trim()||void 0,status:l,priority:d,labels:p.length>0?p:void 0,...h?{repositoryIds:h}:{}});b(!1),e?(J.success(i(`createModal.toast.created`)),n()):J.error(i(`createModal.toast.createFailed`))},[a,s,l,d,p,h,r,n,i]);return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-lg glass-card`,children:[(0,$.jsx)(Rn,{children:(0,$.jsx)(Fn,{children:i(`createModal.title`)})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:[i(`fields.title`),` `,(0,$.jsx)(`span`,{className:`text-red-400 aurora-light:text-destructive`,children:`*`})]}),(0,$.jsx)(`input`,{ref:x,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&T()},placeholder:i(`createModal.titlePlaceholder`),className:`w-full h-8 rounded border border-border bg-input px-3 text-xs text-foreground placeholder:text-muted-foreground`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.description`)}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:4,placeholder:i(`fields.markdownPlaceholder`),className:`w-full rounded border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-y min-h-[80px]`}),(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground mt-0.5 block`,children:i(`fields.supportsMarkdown`)})]}),(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.status`)}),(0,$.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:[(0,$.jsx)(`option`,{value:`todo`,children:i(`ticketStatus.todo`)}),(0,$.jsx)(`option`,{value:`in_progress`,children:i(`ticketStatus.inProgress`)}),(0,$.jsx)(`option`,{value:`done`,children:i(`ticketStatus.done`)}),(0,$.jsx)(`option`,{value:`cancelled`,children:i(`ticketStatus.cancelled`)})]})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.priority`)}),(0,$.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:[(0,$.jsx)(`option`,{value:`critical`,children:i(`priority.critical`)}),(0,$.jsx)(`option`,{value:`high`,children:i(`priority.high`)}),(0,$.jsx)(`option`,{value:`medium`,children:i(`priority.medium`)}),(0,$.jsx)(`option`,{value:`low`,children:i(`priority.low`)})]})]})]}),(0,$.jsx)(tr,{value:h,onChange:g,disabled:y}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.labels`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:p.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70`,children:[e,(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(t=>t.filter(t=>t!==e)),className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(en,{className:`w-2.5 h-2.5`})})]},e))}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{ref:S,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_.trim()&&(e.preventDefault(),w(_))},placeholder:i(`createModal.labelsPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),C.length>0&&(0,$.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:C.map(e=>(0,$.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),w(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:n,children:i(`common:actions.cancel`)}),(0,$.jsxs)(Z,{size:`sm`,onClick:T,disabled:y||!a.trim(),children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5 mr-1`}),i(y?`createModal.creating`:`createModal.create`)]})]})]})})}function AH({open:e,railLabel:t,specCount:n,provider:r=`claude`,model:i,onConfirm:a,onCancel:o}){let{t:s}=K(`dashboard`),c=(0,Q.useRef)(null),l=ur(r);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),a())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a]),(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30`,children:(0,$.jsx)(un,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:s(`freestyleDialog.title`)}),(0,$.jsxs)(Mn,{children:[s(`freestyleDialog.context`,{rail:t,count:n}),i?` · ${i}`:``]})]})]})}),(0,$.jsxs)(`ul`,{className:`space-y-2.5 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.noPipelineTitle`)}),` `,s(`freestyleDialog.noPipelineBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(So,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.autonomyTitle`,{provider:l})}),` `,s(`freestyleDialog.autonomyBody`,{provider:l})]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(Jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.costTitle`)}),` `,s(`freestyleDialog.costBody`,{provider:l})]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:o,children:s(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:c,className:`h-9 gap-2 bg-emerald-500 text-white hover:bg-emerald-400 focus-visible:ring-emerald-400`,onClick:a,children:[s(`freestyleDialog.continue`),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:`⌘↵`})]})]})]})})}function jH(e,t=typeof navigator>`u`?``:navigator.platform){return/Mac|iPhone|iPad/i.test(t)?e:e.replace(/⌥/g,`Alt+`).replace(/⌘/g,`Ctrl+`).replace(/⇧/g,`Shift+`).replace(/[⏎↵]/g,`Enter`)}function MH({open:e,railCount:t,specCount:n,onConfirm:r,onCancel:i}){let{t:a}=K(`dashboard`),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),r())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-primary/15 text-accent-primary ring-1 ring-accent-primary/30`,children:(0,$.jsx)(Xs,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:a(`launchAllDialog.title`)}),(0,$.jsxs)(Mn,{children:[a(`launchAllDialog.railsCount`,{count:t}),` · `,a(`launchAllDialog.specsCount`,{count:n})]})]})]})}),(0,$.jsxs)(`ul`,{className:`space-y-2.5 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.isolationTitle`)}),` `,a(`launchAllDialog.isolationBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(xs,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-secondary`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.pipelinesTitle`,{count:t})}),` `,a(`launchAllDialog.pipelinesBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(Jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.costTitle`)}),` `,a(`launchAllDialog.costBody`)]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:i,children:a(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:o,className:`h-9 gap-2 bg-emerald-500 text-white hover:bg-emerald-400 focus-visible:ring-emerald-400`,onClick:r,children:[a(`launchAllDialog.launch`,{count:t}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:jH(`⌘↵`)})]})]})]})})}function NH({open:e,target:t,onConfirm:n,onCancel:r}){let{t:i}=K(`dashboard`),a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),n())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n]),t?(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||r()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),a.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-info/15 text-accent-info ring-1 ring-accent-info/30`,children:(0,$.jsx)(R,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:i(`targetPr.confirmTitle`)}),(0,$.jsx)(Mn,{children:i(`targetPr.confirmBody`)})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-muted/30 p-3 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 font-medium text-foreground`,children:[`#`,t.number,t.title?` · ${t.title}`:``]})]}),t.headRefName&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-muted-foreground`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[i(`targetPr.confirmBranch`),`: `,(0,$.jsx)(`span`,{className:`font-mono`,children:t.headRefName})]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:r,children:i(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:a,className:`h-9 gap-2 bg-accent-info text-white hover:bg-accent-info/85 focus-visible:ring-accent-info`,onClick:n,children:[i(`targetPr.confirmLaunch`,{number:t.number}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:jH(`⌘↵`)})]})]})]})}):null}var PH=`postit`,FH=e=>`specrails-desktop:specs-view-tier:${e}`;function IH(e){return e===`row`||e===`postit`}function LH(e){if(!e)return PH;try{let t=localStorage.getItem(FH(e));if(IH(t))return t}catch{}return PH}function RH(e,t){if(e)try{localStorage.setItem(FH(e),t)}catch{}}function zH(e,t,n){if(typeof n==`number`&&n===t)return e;if(typeof n==`number`&&e.includes(n)){let r=e.indexOf(n),i=[...e];return i.splice(r,0,t),i}return[...e,t]}function BH(e,t,n,r,i){if(typeof e==`string`){if(r(e)){let n=i(e);return t.has(n)?n:null}return t.has(e)?e:null}if(typeof e==`number`){let r=n(e);return r&&t.has(r)?r:null}return null}var VH=[{id:`rail-1`,label:`Rail 1`,ticketIds:[],mode:`implement`,status:`idle`},{id:`rail-2`,label:`Rail 2`,ticketIds:[],mode:`implement`,status:`idle`},{id:`rail-3`,label:`Rail 3`,ticketIds:[],mode:`implement`,status:`idle`}],HH=e=>e===`implement`||e===`batch-implement`||e===`freestyle`||e===`loop`;function UH(e,t){if(!e||e.decision!==`pr_draft`&&e.decision!==`pr_ready`||!e.prUrl||!e.branch)return!1;let n=new Set(e.ticketIds);return t.length>0&&t.every(e=>n.has(e))}function WH(e,t){for(let n of t.values())if(UH(n,[e]))return!0;return!1}function GH(e){if(!e)return null;try{let t=localStorage.getItem(`specrails-desktop:spec-order:${e}`);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function KH(e,t){if(e)try{t?localStorage.setItem(`specrails-desktop:spec-order:${e}`,JSON.stringify(t)):localStorage.removeItem(`specrails-desktop:spec-order:${e}`)}catch{}}function qH(e){if(!e)return null;try{let t=localStorage.getItem(`specrails-desktop:rails:${e}`);if(!t)return null;let n=JSON.parse(t);return!Array.isArray(n)||n.length===0?null:n}catch{return null}}function JH(e,t){if(e)try{localStorage.setItem(`specrails-desktop:rails:${e}`,JSON.stringify(t))}catch{}}function YH(){let{t:e}=K(`dashboard`),{activeProjectId:t,projects:n}=at(),r=ca().id===`galaxy`,i=(()=>{let e=n.find(e=>e.id===t);return e?rt(e):[`claude`]})(),{tickets:a,isLoading:o,error:s,updateTicket:c,updateTicketStatus:l,updateTicketPriority:u,deleteTicket:d,createTicket:f,refetch:p,contractRefiningIds:m}=T(),{registerHandler:h,unregisterHandler:g,connectionStatus:_}=qe(),{specToOpen:v,clearSpecToOpen:y}=tz(),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!v||v.projectId!==t||(x(v.ticket),p(),y())},[v,t,p,y]);let[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(()=>GH(t)),[L,R]=(0,Q.useState)(()=>qH(t)??VH),[z,B]=(0,Q.useState)({}),ee=dH(),{decisions:V,hydrated:H,act:te,checkout:ne}=mH(),re=AR(t),[ie,ae]=(0,Q.useState)(re.mode),[oe,se]=(0,Q.useState)(re.dir),[ce,le]=(0,Q.useState)(()=>LH(t));(0,Q.useEffect)(()=>{I(GH(t)),R(qH(t)??VH),B({});let e=AR(t);ae(e.mode),se(e.dir),le(LH(t))},[t]);let ue=(0,Q.useCallback)((e,n)=>{ae(e),se(n),jR(t,e,n)},[t]),de=(0,Q.useCallback)(e=>{le(e),RH(t,e)},[t]);(0,Q.useEffect)(()=>{if(_!==`connected`||!t)return;let e=!1,n=qH(t)??VH,r=new Map(n.map(e=>[e.id,e]));return fetch(`${nt()}/rails`).then(e=>e.ok?e.json():null).then(n=>{if(e||!n)return;let i=n.activeJobs??{},a=n.activeLoopRuns??{},o=new Set([...Object.keys(i).map(Number),...Object.keys(a).map(Number)]),s=n.rails??[],c=new Map;for(let e of s)c.set(e.railIndex,Array.isArray(e.ticketIds)?e.ticketIds:[]);let l=new Set(s.map(e=>e.railIndex));R(e=>{let n=!1,u=new Map,d=e.map((e,t)=>{let s=zV(e.id)??t,l=a[String(s)],d=i[String(s)]?.jobId??l?.loopRunId;if(o.has(s)){if(e.status===`running`)return d&&!e.activeJobId?(n=!0,{...e,activeJobId:d}):e;if(r.get(e.id)?.status===`running`)return e;let t=c.get(s)??[],a=i[String(s)]?.mode,o=HH(a)?a:l?yV(l.loopId):void 0,f=t.length?t:e.ticketIds;return u.set(e.id,f),n=!0,{...e,status:`running`,activeJobId:d,ticketIds:f,mode:o??e.mode,...l?.loopId&&l.loopId.startsWith(`custom:`)?{selectedLoopId:l.loopId}:{}}}return e.status!==`running`||r.get(e.id)?.status!==`running`?e:(n=!0,{...e,status:`idle`,activeJobId:void 0,ticketIds:[]})}),f=new Set(d.map(e=>e.id)),p=[];for(let e of s){let t=RV(e.railIndex);if(f.has(t))continue;let r=a[String(e.railIndex)],s=i[String(e.railIndex)]?.mode,l=HH(s)?s:r?yV(r.loopId):HH(e.mode)?e.mode:`implement`,d=o.has(e.railIndex),m=c.get(e.railIndex)??[];p.push({id:t,label:e.name?`Rail ${e.name}`:`Rail ${e.railIndex+1}`,ticketIds:m,mode:l,status:d?`running`:`idle`,activeJobId:i[String(e.railIndex)]?.jobId??r?.loopRunId,...r?.loopId&&r.loopId.startsWith(`custom:`)?{selectedLoopId:r.loopId}:{}}),m.length>0&&u.set(t,m),n=!0}let m=p.length>0?[...d,...p]:d;if(s.length>0){let e=m.filter(e=>{let t=zV(e.id);return t===null||l.has(t)||!r.has(e.id)?!0:e.status===`running`||e.ticketIds.length>0});e.length!==m.length&&(m=e,n=!0)}if(!n)return e;let h=new Set([...u.values()].flat()),g=h.size?m.map(e=>{if(u.has(e.id))return e;let t=e.ticketIds.filter(e=>!h.has(e));return t.length===e.ticketIds.length?e:{...e,ticketIds:t}}):m;return JH(t,g),g})}).catch(()=>{}),()=>{e=!0}},[t,_]),(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`${nt()}/rails`).then(e=>e.ok?e.json():null).then(n=>{if(e||!n?.rails)return;let r=new Map;for(let e of n.rails)r.set(e.railIndex,e.name??null);R(e=>{let n=!1,i=e.map((e,t)=>{let i=zV(e.id)??t,a=r.get(i)??null;if(!a)return e;let o=`Rail ${a}`;return o===e.label?e:(n=!0,{...e,label:o})});return n?(JH(t,i),i):e})}).catch(()=>{}),()=>{e=!0}},[t]),(0,Q.useEffect)(()=>{let e=new Set(a.filter(e=>e.status===`done`||H&&e.status===`on_review`&&!WH(e.id,V)).map(e=>e.id));e.size!==0&&R(n=>{let r=n.map(t=>{let n=t.ticketIds.filter(t=>!e.has(t));return n.length===t.ticketIds.length?t:{...t,ticketIds:n}});return r.every((e,t)=>e===n[t])?n:(JH(t,r),r)})},[a,t,L,V,H]);let fe=(0,Q.useCallback)(e=>{I(n=>{let r=e(n);return KH(t,r),r})},[t]),pe=(0,Q.useCallback)(e=>{R(n=>{let r=e(n);return JH(t,r),r})},[t]),me=(0,Q.useMemo)(()=>{let e=new Set([`specs`,`done-specs`]);for(let t of L)e.add(t.id);return e},[L]),he=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${nt()}/rails`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(t.ok){let n=(await t.json()).rail?.railIndex;if(typeof n==`number`){let t=RV(n);pe(e=>e.some(e=>e.id===t)?e:[...e,{id:t,label:`Rail ${n+1}`,ticketIds:[],mode:`implement`,status:`idle`}]),J.success(e(`toasts.railAdded`,{n:n+1}));return}}else{let n=await t.json().catch(()=>({error:``}));if(n.error===`rail_limit_reached`){J.error(e(`toasts.railLimitReached`,{max:n.maxRails??12}));return}}}catch{}let t=L.map(e=>zV(e.id)).filter(e=>e!==null),n=t.length>0?Math.max(...t)+2:1,r={id:`rail-${n}`,label:`Rail ${n}`,ticketIds:[],mode:`implement`,status:`idle`};pe(e=>[...e,r]),J.success(e(`toasts.railAdded`,{n}))},[L,pe,e]),_e=(0,Q.useCallback)(async t=>{let n=L.find(e=>e.id===t);if(!n||n.status===`running`)return;let r=()=>{n.ticketIds.length>0&&fe(e=>[...e??[],...n.ticketIds]),pe(e=>e.filter(e=>e.id!==t)),J.info(e(`toasts.railRemoved`,{rail:n.label}))},i=zV(t);if(i===null){r();return}try{let t=await fetch(`${nt()}/rails/${i}`,{method:`DELETE`});if(t.ok||t.status===404){r();return}J.error(e(`toasts.railDeleteFailed`))}catch{J.error(e(`toasts.railDeleteFailed`))}},[L,pe,fe,e]),ve=(0,Q.useCallback)((e,t)=>{pe(n=>n.map(n=>n.id===e?{...n,label:`Rail ${t}`}:n));let n=zV(e);n!==null&&fetch(`${nt()}/rails/${n}/name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})}).catch(()=>{})},[pe]),ye=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{ye.current=t},[t]);let U=(0,Q.useCallback)(t=>{let n=t;if(n.projectId===ye.current){if(n.type===`rail.job_started`||n.type===`loop.run_started`){if(n.railIndex==null)return;let e=RV(n.railIndex),t=n.jobId??n.loopRunId;pe(n=>n.map(n=>n.id===e?{...n,status:`running`,activeJobId:t??n.activeJobId}:n));return}if(n.type===`rail.updated`){let e=n.railIndex??0,t=RV(e),r=n.ticketIds??[],i=n.name?`Rail ${n.name}`:`Rail ${e+1}`;pe(e=>e.some(e=>e.id===t)?e.map(e=>e.id===t?n.changed!==`tickets`||e.status===`running`?{...e,label:i}:{...e,label:i,ticketIds:r}:e):[...e,{id:t,label:i,ticketIds:r,mode:HH(n.mode)?n.mode:`implement`,status:`idle`}]);return}if(n.type===`rail.removed`){if(n.railIndex==null)return;let e=RV(n.railIndex);pe(t=>t.filter(t=>t.id!==e||t.status===`running`));return}if(n.type===`rail.worktree_progress`){let t=n.railIndex??0,r=n.ticketId,i=n.state;typeof r==`number`&&i&&(B(e=>HV(e,t,r,i)),i===`needs-review`&&J.error(e(`toasts.railWorktreeNeedsReview`,{n:t+1,ticket:r})));return}if(n.type===`rail.job_completed`){let t=n.railIndex??0;pe(e=>JV(e,t,n.ticketIds??[])),n.status===`completed`?J.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`zombie_terminated`?J.error(e(`toasts.railFailed`,{n:t+1})):J.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}if(n.type===`loop.run_completed`){let t=n.railIndex??0;pe(e=>JV(e,t,n.ticketIds??[])),n.status===`success`?J.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`max-iterations`?J.error(e(`toasts.railFailed`,{n:t+1})):J.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}}},[pe,e]);(0,Q.useEffect)(()=>(h(`dashboard-rails`,U),()=>g(`dashboard-rails`)),[U,h,g]);let xe=NP(MP(RF,{activationConstraint:{distance:5}}),MP(NF)),Se=(0,Q.useCallback)(e=>{let t=typeof e.active.id==`string`&&KV(e.active.id),n=e.droppableContainers.filter(e=>{let n=e.id;return typeof n==`string`&&KV(n)?t:!t}),r={...e,droppableContainers:n};if(t)return UP(r);let i=qP(r);if(BP(i))return i;let a=GP(r);return BP(a)?a:UP(r)},[]),Ce=(0,Q.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]),W=(0,Q.useMemo)(()=>{let e=[],t=[];return L.forEach((n,r)=>{let i=zV(n.id)??r;if(n.status===`running`){t.push({rail:n,reason:`running`});return}if(n.ticketIds.length===0){t.push({rail:n,reason:`empty`});return}let a=V.get(i);if(a&&!UH(a,n.ticketIds)){t.push({rail:n,reason:`pendingDecision`});return}if(n.ticketIds.some(e=>Ce.get(e)?.status===`on_review`&&(!H||!WH(e,V)))){t.push({rail:n,reason:`onReview`});return}e.push(n)}),{eligible:e,skipped:t}},[L,V,H,Ce]),we=(0,Q.useMemo)(()=>{let e=new Set;for(let t of a)for(let n of t.labels)e.add(n);return Array.from(e).sort()},[a]),Te=(0,Q.useMemo)(()=>{let e=new Set;for(let t of L)for(let n of t.ticketIds)e.add(n);return e},[L]),Ee=(0,Q.useMemo)(()=>a.filter(e=>(e.source===`propose-spec`||e.source===`product-backlog`||e.source===`get-backlog-specs`||e.source===`explore-draft`||e.source===`specs-smash`||e.source===`free-prompt`||e.source===`mcp`||e.source===`project-builder`||e.source===`manual`&&e.created_by===`project-builder`||e.source===`jira`)&&!Te.has(e.id)),[a,Te]);(0,Q.useEffect)(()=>{o||ie===`jira-key`&&!Ee.some(e=>e.jira_key)&&ue(`default`,oe)},[o,ie,oe,Ee,ue]);let De=(0,Q.useMemo)(()=>{let e=Ee.filter(e=>e.status!==`done`);if(ie!=="default")return RR(e,ie,oe);if(!F)return e;let t=new Map(e.map(e=>[e.id,e])),n=[];for(let e of F){let r=t.get(e);r&&n.push(r)}for(let t of e)F.includes(t.id)||n.push(t);return n},[Ee,F,ie,oe]),Oe=(0,Q.useMemo)(()=>Ee.filter(e=>e.status===`done`),[Ee]),ke=(0,Q.useMemo)(()=>{let e=new Set;if(!H)return e;for(let t of a)t.status===`on_review`&&WH(t.id,V)&&e.add(t.id);return e},[a,V,H]),Ae=(0,Q.useCallback)((t,n)=>{let r=L.find(e=>e.id===n);if(r){if(a.find(e=>e.id===t)?.status===`on_review`&&(!H||!WH(t,V))){J.info(e(`toasts.onReviewCannotMoveToRail`));return}if(r.ticketIds.includes(t)){J.info(e(`toasts.alreadyOnRail`,{rail:r.label}));return}fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==t)),pe(e=>e.map(e=>e.id===n?{...e,ticketIds:[...e.ticketIds.filter(e=>e!==t),t]}:e.ticketIds.includes(t)?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),J.success(e(`toasts.movedToRail`,{rail:r.label}))}},[L,a,De,pe,fe,e,V,H]),je=(0,Q.useCallback)(t=>{let n=L.find(e=>e.ticketIds.includes(t));if(n){if(n.status===`running`){J.error(e(`toasts.railRunningStopFirst`,{rail:n.label}));return}pe(e=>e.map(e=>e.id===n.id?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),fe(e=>{let n=e??De.map(e=>e.id);return n.includes(t)?n:[...n,t]}),J.success(e(`toasts.removedFromRail`,{rail:n.label}))}},[L,De,pe,fe,e]),Me=(0,Q.useCallback)(e=>{if(De.some(t=>t.id===e))return`specs`;if(Oe.some(t=>t.id===e))return`done-specs`;for(let t of L)if(t.ticketIds.includes(e))return t.id;return null},[De,Oe,L]);function Ne({active:e}){if(KV(e.id)){let t=qV(e.id),n=L.find(e=>e.id===t);P(n?.label??t);return}M(e.id)}function Pe({active:n,over:r}){if(M(null),P(null),!r)return;if(KV(n.id)){if(!KV(r.id))return;let e=qV(n.id),t=qV(r.id);if(e===t)return;pe(n=>{let r=n.findIndex(t=>t.id===e),i=n.findIndex(e=>e.id===t);return r===-1||i===-1?n:nL(n,r,i)});return}let i=n.id,o=r.id,s=Me(i);if(!s)return;let l=BH(o,me,Me,KV,qV)??s;if(me.has(l))if(s===l)if(l===`specs`){let e=De.map(e=>e.id),n=e.indexOf(i),r=e.indexOf(o);if(n!==-1&&r!==-1&&n!==r){let i=nL(e,n,r);fe(()=>i),ie!=="default"&&(ae(`default`),jR(t,`default`,oe))}}else pe(e=>e.map(e=>{if(e.id!==l)return e;let t=e.ticketIds.indexOf(i),n=e.ticketIds.indexOf(o);return t!==-1&&n!==-1&&t!==n?{...e,ticketIds:nL(e.ticketIds,t,n)}:e}));else if(s===`specs`&&l===`done-specs`){if(a.find(e=>e.id===i)?.status===`on_review`){J.info(e(`toasts.onReviewCannotMoveToRail`));return}fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),c(i,{status:`done`})}else if(s===`done-specs`&&l===`specs`)c(i,{status:`todo`}),fe(e=>zH(e??De.map(e=>e.id),i,o));else if(s===`specs`){if(a.find(e=>e.id===i)?.status===`on_review`&&(!H||!WH(i,V))){J.info(e(`toasts.onReviewCannotMoveToRail`));return}let t=L.find(e=>e.id===l);fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),pe(e=>e.map(e=>e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e)),t&&(t.status===`running`?J.info(e(`toasts.queuedOnRail`,{rail:t.label}),{description:e(`toasts.queuedOnRailDescription`)}):J.success(e(`toasts.movedToRail`,{rail:t.label})))}else if(l===`specs`){let t=L.find(e=>e.id===s);if(t?.status===`running`){J.error(e(`toasts.railRunningStopFirst`,{rail:t.label}));return}pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),fe(e=>zH(e??De.map(e=>e.id),i,o)),t&&J.success(e(`toasts.removedFromRail`,{rail:t.label}))}else s===`done-specs`?(c(i,{status:`todo`}),pe(e=>e.map(e=>e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e))):l===`done-specs`?(pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),c(i,{status:`done`})):pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e))}function Fe(e,t){pe(n=>n.map(n=>n.id===e?{...n,mode:t}:n))}function Ie(e){let t=zV(e);return t===null?L.findIndex(t=>t.id===e):t}async function Le(e,t){pe(n=>n.map(n=>n.id===e?{...n,profileName:t}:n));let n=Ie(e);if(n!==-1)try{await fetch(`${nt()}/rails/${n}/profile`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileName:t})})}catch{}}function Re(e,t){pe(n=>n.map(n=>n.id===e?{...n,freestyleModel:t}:n))}function ze(e,t){let n=yV(t);pe(r=>r.map(r=>r.id===e?{...r,selectedLoopId:t,mode:n}:r))}function Be(e,t){pe(n=>n.map(n=>{if(n.id!==e)return n;let r=n.aiEngine??i[0]??`claude`,a=lr(r,t);return{...n,loopModel:t,reasoningEffort:n.reasoningEffort&&a.includes(n.reasoningEffort)?n.reasoningEffort:fr(r,t)??null}}))}function G(e,t){pe(n=>n.map(n=>n.id===e?{...n,reasoningEffort:t}:n))}async function Ve(e,t){pe(n=>n.map(n=>{if(n.id!==e)return n;let r=n.mode===`freestyle`||n.selectedLoopId===`factory:freestyle`,i=!cr(t)&&r,a=fz(t),o=e=>!!(e&&(a.some(t=>t.value===e)||nr(t)&&gD(e))),s=o(n.loopModel)?n.loopModel:pz(t),c=lr(t,s);return{...n,aiEngine:t,mode:i?`implement`:n.mode,selectedLoopId:i?`factory:implement`:n.selectedLoopId,profileName:null,freestyleModel:o(n.freestyleModel)?n.freestyleModel:pz(t),loopModel:s,reasoningEffort:n.reasoningEffort&&c.includes(n.reasoningEffort)?n.reasoningEffort:fr(t,s)??null}}));let n=Ie(e);if(n!==-1)try{await fetch(`${nt()}/rails/${n}/engine`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({aiEngine:t})})}catch{}}function He(e,t){pe(n=>n.map(n=>n.id===e?{...n,targetPr:t}:n))}async function Ue(t){let n=L.find(e=>e.id===t),r=Ie(t);if(!(!n||r===-1)){if(n.status===`running`){try{await fetch(`${nt()}/rails/${r}/stop`,{method:`POST`}),pe(e=>e.map(e=>e.id===t?{...e,status:`idle`,activeJobId:void 0}:e)),J.info(e(`toasts.railStopped`,{rail:n.label}))}catch{J.error(e(`toasts.stopFailed`))}return}if(n.ticketIds.length!==0){if(n.mode===`freestyle`){E({railId:t});return}if(n.targetPr){O({railId:t});return}await We(t)}}}async function We(t,n){let r=n?.silent??!1,o=L.find(e=>e.id===t),s=Ie(t);if(!o||s===-1)return`failed`;if(o.ticketIds.length===0)return`skipped`;if(o.ticketIds.some(e=>a.find(t=>t.id===e)?.status===`on_review`&&(!H||!WH(e,V))))return r||J.info(e(`toasts.onReviewNotLaunchable`)),`skipped`;let c=bV(o.selectedLoopId,o.mode);if(!c)return r||J.error(e(`railControls.pickLoop`)),`failed`;let l=o.aiEngine??i[0]??`claude`,u=lr(l,o.loopModel??pz(l)),d=o.reasoningEffort&&u.includes(o.reasoningEffort)?o.reasoningEffort:null,f=nt();try{await fetch(`${f}/rails/${s}/tickets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ticketIds:o.ticketIds})})}catch{return r||J.error(e(`toasts.syncTicketsFailed`)),`failed`}try{let n=await fetch(`${f}/rails/${s}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:o.mode,...o.profileName===void 0?{}:{profileName:o.profileName},...o.aiEngine==null?{}:{aiEngine:o.aiEngine},...o.mode===`freestyle`&&o.freestyleModel?{model:o.freestyleModel}:{},...o.mode===`loop`&&o.loopModel?{model:o.loopModel}:{},loopId:c,...o.mode===`loop`&&d?{reasoning_effort:d}:{},...o.targetPr?{targetPrNumber:o.targetPr.number}:{}})});if(!n.ok){let t=await n.json().catch(()=>({error:``}));return n.status===409&&t.error===`pr_decision_pending`?(r||J.info(e(`railPr.decisionPending`)),`pendingDecision`):n.status===409&&t.error===`tickets_in_flight`?(r||J.info(e(`toasts.launchTicketsInFlight`)),`skipped`):n.status===400&&t.error===`rail_ticket_cap_exceeded`?(r||J.error(e(`toasts.launchTicketCap`,{max:t.max??3,count:t.ticketCount??0})),`failed`):typeof t.error==`string`&&[`invalid_target_pr`,`target_pr_requires_pr_mode`,`target_pr_not_found`,`target_pr_not_open`,`target_pr_fork`,`target_pr_invalid`,`target_pr_unfetchable`].includes(t.error)?(r||J.error(e(`targetPr.errors.${t.error}`),{description:t.detail,duration:1e4}),`failed`):(r||J.error(t.error||e(`toasts.launchFailed`)),`failed`)}let i=await n.json();!r&&i.isolationUnavailable===`no-git`?J.info(e(`toasts.railWorktreesNoGit`)):!r&&i.isolationUnavailable===`no-commits`?J.info(e(`toasts.railWorktreesNoCommits`)):!r&&i.isolationUnavailable===`error`&&J.warning(e(`toasts.railWorktreesError`),{description:i.isolationUnavailableDetail,duration:12e3});let a=i.jobId??i.loopRunIds?.[0];return pe(e=>e.map(e=>e.id===t?{...e,status:`running`,activeJobId:a,targetPr:null}:e)),r||J.success(e(`toasts.railLaunched`,{rail:o.label}),{description:e(`toasts.launchDescription`,{mode:o.mode,count:o.ticketIds.length})}),`launched`}catch{return r||J.error(e(`toasts.launchNetworkError`)),`failed`}}function Ge(){if(W.eligible.length===0){J.info(e(`toasts.launchAllNoneEligible`));return}A(!0)}async function Ke(){A(!1);let{eligible:t,skipped:n}=W;if(t.length===0){J.info(e(`toasts.launchAllNoneEligible`));return}let r=await Promise.allSettled(t.map(e=>We(e.id,{silent:!0}))),i=0,a=0,o=0,s=0;for(let e of r){let t=e.status===`fulfilled`?e.value:`failed`;t===`launched`?i++:t===`pendingDecision`?o++:t===`skipped`?s++:a++}let c=new Map;for(let e of n)c.set(e.reason,(c.get(e.reason)??0)+1);o>0&&c.set(`pendingDecision`,(c.get(`pendingDecision`)??0)+o);let l={running:`launchAll.skipRunning`,empty:`launchAll.skipEmpty`,pendingDecision:`launchAll.skipPendingDecision`,onReview:`launchAll.skipOnReview`},u=[];for(let[t,n]of c)n>0&&u.push(e(l[t],{count:n}));s>0&&u.push(e(`launchAll.skipInFlight`,{count:s})),a>0&&u.push(e(`launchAll.failedCount`,{count:a}));let d=u.length>0?u.join(` · `):void 0;i>0?J.success(e(`toasts.launchAllSummary`,{count:i}),d?{description:d}:void 0):J.error(e(`toasts.launchAllFailed`),d?{description:d}:void 0)}let Je=j===null?void 0:Ce.get(j),Ye=(0,Q.useRef)(null),{leftWidth:Xe,enabled:Ze,beginDrag:Qe,resetToDefault:$e}=DH(t,Ye),et=typeof window<`u`?window.innerWidth:1200;return(0,$.jsx)(LL,{children:(0,$.jsxs)(FI,{sensors:xe,collisionDetection:Se,onDragStart:Ne,onDragEnd:Pe,children:[(0,$.jsxs)(`div`,{ref:Ye,className:`relative z-0 flex h-full overflow-hidden`,children:[r&&(0,$.jsx)(IM,{}),(0,$.jsx)(`div`,{className:`relative z-10 min-w-0 flex flex-col overflow-hidden`,style:Ze&&Xe!==null?{width:`${Xe}px`,flex:`0 0 auto`}:{flex:`1 1 0%`},children:(0,$.jsx)(pV,{tickets:De,allTickets:a,doneTickets:Oe,isLoading:o,error:s,onRetry:()=>{p()},onTicketClick:x,onTicketCreated:e=>{x(e),p()},onTicketDelete:e=>d(e),onTicketStatusChange:(e,t)=>{l(e,t)},onTicketPriorityChange:(e,t)=>{u(e,t)},contractRefiningIds:m,sortMode:ie,sortDir:oe,onSortChange:ue,viewTier:ce,onViewTierChange:de,rails:L,onMoveToRail:Ae,continuableReviewTicketIds:ke})}),Ze&&Xe!==null&&(0,$.jsx)(OH,{leftWidth:Xe,viewport:et,onPointerDown:Qe,onReset:$e}),(0,$.jsx)(`div`,{className:`relative z-10 flex-1 min-w-0 flex flex-col overflow-hidden`,children:(0,$.jsx)(XV,{rails:L,ticketMap:Ce,railWorktrees:z,railMetrics:ee,railPrDecisions:V,onPrDecision:te,onPrCheckout:ne,providers:i,onModeChange:Fe,onProfileChange:Le,onEngineChange:Ve,onFreestyleModelChange:Re,onLoopModelChange:Be,loopAvailable:ge,onLoopChange:ze,onEffortChange:G,onToggle:Ue,onTargetPrChange:He,onTicketClick:x,onAddRail:()=>{he()},onDeleteRail:e=>{_e(e)},onRenameRail:ve,onTicketMoveToSpecs:je,onLaunchAll:Ge,launchAllCount:W.eligible.length})})]}),(0,$.jsx)(tL,{dropAnimation:{duration:180,easing:`ease`},children:Je?ce===`postit`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-accent-info/40 bg-card/95 shadow-xl shadow-black/30 backdrop-blur-sm p-3 rotate-1 scale-[1.02] pointer-events-none w-[260px] min-h-[180px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/60`,children:[`#`,Je.id]}),Je.priority&&(0,$.jsx)(`span`,{className:`h-4 px-1.5 rounded-full text-[9px] font-medium uppercase bg-muted/40 text-foreground`,children:Je.priority})]}),(0,$.jsx)(`h3`,{className:`text-sm font-medium leading-snug line-clamp-2 text-foreground`,children:Je.title}),Je.short_summary&&Je.short_summary.trim().length>0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 leading-relaxed line-clamp-3 italic`,children:Je.short_summary})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border border-primary/40 bg-card/95 shadow-xl shadow-black/20 backdrop-blur-sm rotate-1 scale-[1.03] pointer-events-none`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/50 shrink-0`,children:[`#`,Je.id]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm truncate max-w-[240px]`,children:Je.title})]}):N?(0,$.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-xl border border-primary/40 bg-card/95 shadow-xl shadow-black/20 backdrop-blur-sm rotate-[0.5deg] scale-[1.02] pointer-events-none`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:N})}):null}),b&&(()=>{let e=a.find(e=>e.id===b.id)??b;return(0,$.jsx)(be,{ticket:e,allLabels:we,allTickets:a,onClose:()=>x(null),onOpenTicket:e=>{let t=a.find(t=>t.id===e);t&&x(t)},onSave:c,onDelete:d,rails:L,onMoveToRail:Ae,onRemoveFromRail:je},e.id)})(),(0,$.jsx)(kH,{open:S,allLabels:we,onClose:()=>C(!1),onCreate:f}),(0,$.jsx)(MH,{open:k,railCount:W.eligible.length,specCount:W.eligible.reduce((e,t)=>e+t.ticketIds.length,0),onCancel:()=>A(!1),onConfirm:()=>{Ke()}}),(()=>{let e=D?L.find(e=>e.id===D.railId):void 0;return(0,$.jsx)(NH,{open:!!D&&!!e?.targetPr,target:e?.targetPr??null,onCancel:()=>O(null),onConfirm:()=>{let e=D?.railId;O(null),e&&We(e)}})})(),(()=>{let e=w?L.find(e=>e.id===w.railId):void 0,t=e?.aiEngine??i[0]??`claude`;return(0,$.jsx)(AH,{open:!!w&&!!e,railLabel:e?.label??``,specCount:e?.ticketIds.length??0,provider:t,model:e?.freestyleModel??pz(t),onCancel:()=>E(null),onConfirm:()=>{let e=w?.railId;E(null),e&&We(e)}})})()]})})}var XH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`rounded-lg border border-border bg-card text-card-foreground shadow-sm`,e),...t}));XH.displayName=`Card`;var ZH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex flex-col space-y-1 p-4`,e),...t}));ZH.displayName=`CardHeader`;var QH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`h3`,{ref:n,className:X(`text-sm font-semibold leading-none tracking-tight`,e),...t}));QH.displayName=`CardTitle`;var $H=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`p`,{ref:n,className:X(`text-xs text-muted-foreground`,e),...t}));$H.displayName=`CardDescription`;var eU=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`p-4 pt-0`,e),...t}));eU.displayName=`CardContent`;var tU=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex items-center p-4 pt-0`,e),...t}));tU.displayName=`CardFooter`;var nU=[`auto`,`canvas`,`webgl`];function rU({mode:e}){let{t}=K(`settings`),{activeProjectId:n}=at(),[r,i]=(0,Q.useState)(vi),[a,o]=(0,Q.useState)({}),[s,c]=(0,Q.useState)(vi),[l,u]=(0,Q.useState)(vi),[d,f]=(0,Q.useState)(new Set),[p,m]=(0,Q.useState)(!0),[h,g]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=!1;if(e===`project`&&!n){m(!1);return}return(async()=>{try{if(e===`desktop`){let e=await fetch(`/api/terminal-settings`);if(!e.ok)throw Error(`desktop settings fetch failed`);let n=await e.json();!t&&n&&typeof n==`object`&&`fontSize`in n&&(i(n),c(n),u(n),f(new Set)),t||m(!1)}else if(n){let e=await fetch(`/api/projects/${n}/terminal-settings`);if(!e.ok)throw Error(`project fetch failed`);let r=await e.json();!t&&r&&typeof r==`object`&&r.resolved&&r.desktopDefaults&&(i(r.desktopDefaults),o(r.override??{}),c(r.resolved),u(r.resolved),f(new Set)),t||m(!1)}}catch(e){t||(m(!1),console.error(e))}})(),()=>{t=!0}},[e,n]);let _=(0,Q.useMemo)(()=>d.size>0||Object.keys(l).some(e=>l[e]!==s[e]),[l,s,d]);function v(e,t){u(n=>({...n,[e]:t})),d.has(e)&&f(t=>{let n=new Set(t);return n.delete(e),n})}function y(t){e===`project`&&(f(e=>{let n=new Set(e);return n.add(t),n}),u(e=>({...e,[t]:r[t]})))}function b(){u(s),f(new Set)}async function x(){g(!0);try{let r={};for(let e of Object.keys(l)){if(d.has(e)){r[e]=null;continue}l[e]!==s[e]&&(r[e]=l[e])}if(Object.keys(r).length===0){J(t(`terminal.nothingToSave`)),g(!1);return}if(e===`desktop`){let e=await fetch(`/api/terminal-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(await e.text()||`patch failed`);let n=await e.json();i(n),c(n),u(n),f(new Set),oN({mode:`desktop`,projectId:null}),J.success(t(`terminal.saved`))}else if(n){let e=await fetch(`/api/projects/${n}/terminal-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(await e.text()||`patch failed`);let a=await e.json();i(a.desktopDefaults),o(a.override),c(a.resolved),u(a.resolved),f(new Set),oN({mode:`project`,projectId:n}),J.success(t(`terminal.saved`))}}catch(e){J.error(t(`errors.saveFailed`,{message:e.message}))}finally{g(!1)}}function S(t){return e!==`project`||d.has(t)?!1:a[t]!==void 0}return p?(0,$.jsx)(XH,{children:(0,$.jsx)(eU,{children:t(`common:states.loading`)})}):(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:t(`terminal.title`)}),(0,$.jsx)($H,{children:t(e===`desktop`?`terminal.desktopDescription`:`terminal.projectDescription`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsx)(iU,{label:t(`terminal.fontFamily`),overridden:S(`fontFamily`),onClear:()=>y(`fontFamily`),mode:e,children:(0,$.jsx)(Qk,{value:l.fontFamily,onChange:e=>v(`fontFamily`,e.target.value)})}),(0,$.jsx)(iU,{label:t(`terminal.fontSize`,{min:8,max:32}),overridden:S(`fontSize`),onClear:()=>y(`fontSize`),mode:e,children:(0,$.jsx)(Qk,{type:`number`,min:8,max:32,value:l.fontSize,onChange:e=>v(`fontSize`,parseInt(e.target.value,10)||l.fontSize)})}),(0,$.jsx)(iU,{label:t(`terminal.renderMode`),overridden:S(`renderMode`),onClear:()=>y(`renderMode`),mode:e,children:(0,$.jsx)(`select`,{value:l.renderMode,onChange:e=>v(`renderMode`,e.target.value),className:`border rounded px-2 py-1 bg-transparent`,children:nU.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})}),(0,$.jsx)(aU,{label:t(`terminal.copyOnSelect`),checked:l.copyOnSelect,overridden:S(`copyOnSelect`),onClear:()=>y(`copyOnSelect`),onChange:e=>v(`copyOnSelect`,e),mode:e}),(0,$.jsx)(aU,{label:t(`terminal.shellIntegration`),checked:l.shellIntegrationEnabled,overridden:S(`shellIntegrationEnabled`),onClear:()=>y(`shellIntegrationEnabled`),onChange:e=>v(`shellIntegrationEnabled`,e),mode:e}),(0,$.jsx)(aU,{label:t(`terminal.notifyLongRunning`),checked:l.notifyOnCompletion,overridden:S(`notifyOnCompletion`),onClear:()=>y(`notifyOnCompletion`),onChange:e=>v(`notifyOnCompletion`,e),mode:e}),(0,$.jsx)(iU,{label:t(`terminal.longCommandThreshold`),overridden:S(`longCommandThresholdMs`),onClear:()=>y(`longCommandThresholdMs`),mode:e,children:(0,$.jsx)(Qk,{type:`number`,min:1e3,value:l.longCommandThresholdMs,onChange:e=>v(`longCommandThresholdMs`,parseInt(e.target.value,10)||l.longCommandThresholdMs)})}),(0,$.jsx)(aU,{label:t(`terminal.imageRendering`),checked:l.imageRendering,overridden:S(`imageRendering`),onClear:()=>y(`imageRendering`),onChange:e=>v(`imageRendering`,e),mode:e}),(0,$.jsx)(iU,{id:`terminal-browser-shortcut-url`,label:t(`terminal.browserShortcutUrl`),overridden:S(`browserShortcutUrl`),onClear:()=>y(`browserShortcutUrl`),mode:e,children:(0,$.jsx)(Qk,{type:`url`,value:l.browserShortcutUrl,placeholder:`https://specrails.dev`,onChange:e=>v(`browserShortcutUrl`,e.target.value)})}),(0,$.jsx)(iU,{id:`terminal-quick-script`,label:t(`terminal.quickScript`),overridden:S(`quickScript`),onClear:()=>y(`quickScript`),mode:e,children:(0,$.jsx)(`textarea`,{value:l.quickScript,placeholder:`echo "Hello World!"`,onChange:e=>v(`quickScript`,e.target.value),rows:3,className:`w-full border rounded px-2 py-1 bg-transparent font-mono text-xs`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 border-t`,children:[(0,$.jsx)(Z,{onClick:x,disabled:!_||h,children:t(h?`common:states.saving`:`common:actions.save`)}),(0,$.jsx)(Z,{variant:`ghost`,onClick:b,disabled:!_||h,children:t(`terminal.reset`)}),_&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`terminal.unsavedChanges`)})]})]})]})}function iU({id:e,label:t,overridden:n,onClear:r,mode:i,children:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(`div`,{id:e,"data-terminal-settings-anchor":e?``:void 0,className:e?`scroll-mt-4`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:t}),i===`project`&&n&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:r,children:o(`terminal.clearOverride`)})]}),a,i===`project`&&!n&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:o(`terminal.inheritingDefault`)})]})}function aU({label:e,checked:t,overridden:n,onClear:r,onChange:i,mode:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:e}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a===`project`&&n&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:r,children:o(`terminal.clear`)}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e,"aria-checked":t,onClick:()=>i(!t),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${t?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})})]})]})}function oU(){let{activeProjectId:e,projects:t,refreshProjects:n}=at(),r=t.find(t=>t.id===e);return r?(0,$.jsx)(sU,{project:r,refreshProjects:n},r.id):null}function sU({project:e,refreshProjects:t}){let{t:n}=K(`common`),[r,i]=(0,Q.useState)(()=>er(e)),[a,o]=(0,Q.useState)(null),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,Q.useEffect)(()=>{i(er(e))},[e]);let x=`${$n(e.id)}/repositories`;function S(e){y(null),o(e??null),l(!e),d(e?.path??``),p(e?.name??``),h(e?.integrationBranch??``)}async function C(e,n){if(!g){_(!0),y(null);try{let r=await fetch(n?`${x}/${encodeURIComponent(n)}`:x,{method:e,headers:{"Content-Type":`application/json`},...e===`DELETE`?{}:{body:JSON.stringify({...!a||!a.isPrimary&&u.trim()!==a.path?{path:u.trim()}:{},...f.trim()?{name:f.trim()}:{},integrationBranch:m.trim()||null})}});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let s=await fetch(x,{cache:`no-store`});if(!s.ok)throw Error(`HTTP ${s.status}`);let c=await s.json();b.current&&(i(c.repositories),l(!1),o(null)),await t?.()}catch(e){b.current&&y(e instanceof Error?e.message:String(e))}finally{b.current&&_(!1)}}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsxs)(QH,{className:`flex items-center gap-2`,children:[(0,$.jsx)(is,{className:`h-4 w-4`}),n(`repositories.title`)]}),(0,$.jsx)($H,{children:n(`repositories.sharedBacklog`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.isPrimary?n(`repositories.primary`):e.kind===`folder`?n(`repositories.contextOnly`):`Git`}),e.available===!1&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`repositories.unavailable`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>S(e),children:n(`actions.edit`)}),!e.isPrimary&&(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>void C(`DELETE`,e.id),children:n(`repositories.detach`)})]})]}),(0,$.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.path}),e.integrationBranch&&(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[n(`repositories.integrationBranch`),`: `,e.integrationBranch]})]},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`repositories.detachHint`)}),v&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:v}),s||a?(0,$.jsxs)(`form`,{className:`space-y-3 rounded-lg border border-border p-3`,onSubmit:e=>{e.preventDefault(),C(a?`PATCH`:`POST`,a?.id)},children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.name`),(0,$.jsx)(Qk,{value:f,disabled:g,onChange:e=>p(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.path`),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{value:u,required:!0,disabled:g||a?.isPrimary,onChange:e=>d(e.target.value)}),`__TAURI_INTERNALS__`in window&&!a?.isPrimary&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,disabled:g,"aria-label":n(`repositories.browse`),onClick:async()=>{try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!1});typeof t==`string`&&b.current&&d(t)}catch{}},children:(0,$.jsx)(as,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.integrationBranch`),(0,$.jsx)(Qk,{value:m,disabled:g,placeholder:n(`repositories.branchDefault`),onChange:e=>h(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`submit`,size:`sm`,disabled:g||!u.trim(),children:n(g?`actions.saving`:`actions.save`)}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,disabled:g,onClick:()=>{l(!1),o(null),y(null)},children:n(`actions.cancel`)})]})]}):(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,disabled:g,onClick:()=>S(),children:[(0,$.jsx)(cn,{className:`mr-1 h-4 w-4`}),n(`repositories.addFolder`)]})]})]})}function cU(){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-lg bg-muted/30`,"data-testid":`section-skeleton`})}function lU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!t)return;let e=!1;return s(!1),fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&r(t.pipelineTelemetryEnabled??!1)}).catch(()=>{}).finally(()=>{e||s(!0)}),()=>{e=!0}},[t]),!o)return(0,$.jsx)(cU,{});async function c(t){a(!0);let i=n;r(t);try{if(!(await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pipelineTelemetryEnabled:t})})).ok)throw Error(`Failed to save`);J.success(e(t?`telemetry.enabled`:`telemetry.disabled`))}catch(t){r(i),J.error(e(`telemetry.saveFailed`),{description:t.message})}finally{a(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`telemetry.title`)}),(0,$.jsx)($H,{children:e(`telemetry.description`)})]}),(0,$.jsx)(eU,{className:`space-y-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:e(`telemetry.toggleLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`telemetry.toggleDescription`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e(`telemetry.toggleLabel`),"aria-checked":n,disabled:i,onClick:()=>c(!n),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 ${n?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})})]})}function uU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);async function u(e){let t=await fetch(`${nt()}/integration-branch`).then(e=>e.ok?e.json():null).catch(()=>null);e?.current||t&&(r(t.configured??``),t.branch&&a({branch:t.branch,source:t.source??``}))}if((0,Q.useEffect)(()=>{if(!t)return;let e={current:!1};return l(!1),u(e).finally(()=>{e.current||l(!0)}),()=>{e.current=!0}},[t]),!c)return(0,$.jsx)(cU,{});async function d(){s(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({integrationBranch:n.trim()})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}J.success(e(`integrationBranch.saved`)),await u()}catch(t){J.error(e(`integrationBranch.saveFailed`),{description:t.message})}finally{s(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`integrationBranch.title`)}),(0,$.jsx)($H,{children:e(`integrationBranch.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-3`,children:[(0,$.jsx)(Qk,{value:n,onChange:e=>r(e.target.value),placeholder:e(`integrationBranch.placeholder`),"data-testid":`integration-branch-input`}),i&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`integration-branch-resolved`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`integrationBranch.resolved`,values:{branch:i.branch},components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(Z,{size:`sm`,onClick:d,disabled:o,"data-testid":`integration-branch-save`,children:e(`integrationBranch.save`)})]})]})}var dU=/^[A-Za-z_][A-Za-z0-9_]*$/,fU=[`NODE_AUTH_TOKEN`,`NPM_TOKEN`,`AWS_PROFILE`];function pU(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function mU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),s(``),fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&r(Array.isArray(t.worktreeEnvPassthrough)?t.worktreeEnvPassthrough:[])}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]),!u)return(0,$.jsx)(cU,{});function f(t){let i=pU(t);if(i.length===0)return;let o=[...n];for(let t of i){if(t.includes(`=`)){s(e(`worktreeEnv.noValues`));return}if(!dU.test(t)){s(e(`worktreeEnv.invalidName`,{name:t}));return}o.includes(t)||o.push(t)}r(o),a(``),s(``)}async function p(){l(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({worktreeEnvPassthrough:n})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}let i=await t.json();r(i.settings?.worktreeEnvPassthrough??n),J.success(e(`worktreeEnv.saved`))}catch(t){J.error(e(`worktreeEnv.saveFailed`),{description:t.message})}finally{l(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`worktreeEnv.title`)}),(0,$.jsx)($H,{children:e(`worktreeEnv.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`worktree-env-name`,className:`text-xs font-medium`,children:e(`worktreeEnv.label`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{id:`worktree-env-name`,value:i,onChange:e=>{a(e.target.value),s(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f(i))},placeholder:e(`worktreeEnv.placeholder`),"aria-invalid":!!o,"data-testid":`worktree-env-input`}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`secondary`,className:`h-9 shrink-0`,onClick:()=>f(i),disabled:!i.trim(),"data-testid":`worktree-env-add`,children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5`}),e(`worktreeEnv.add`)]})]}),o?(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`worktree-env-error`,children:o}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`worktreeEnv.helper`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:fU.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`rounded-md border border-border bg-muted/30 px-2 py-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e},e))}),n.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`worktree-env-list`,children:n.map(t=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 font-mono text-[11px]`,children:[t,(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e!==t)),className:`rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":e(`worktreeEnv.remove`,{name:t}),children:(0,$.jsx)(mn,{className:`w-3 h-3`})})]},t))}):(0,$.jsx)(`p`,{className:`rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:e(`worktreeEnv.empty`)}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,onClick:p,disabled:c,"data-testid":`worktree-env-save`,children:e(c?`common:states.saving`:`worktreeEnv.save`)})})]})]})}function hU({value:e,onChange:t,onSave:n,isSaving:r,fieldId:i,i18nRoot:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:o(`${a}.title`)}),(0,$.jsx)($H,{children:o(`${a}.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium`,children:o(`${a}.label`)}),(0,$.jsx)(`textarea`,{id:i,value:e,onChange:e=>t(e.target.value),placeholder:o(`${a}.placeholder`),className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`${a}.helper`)})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:r,onClick:n,children:o(r?`common:states.saving`:`${a}.saveButton`)})})]})]})}function gU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)({pre:!1,freestyle:!1});(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),f.current={pre:!1,freestyle:!1},fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{e||!t||(f.current.pre||r(t.prePrompt??``),f.current.freestyle||s(t.freestylePrePrompt??``))}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]);async function p(){a(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prePrompt:n})});if(!t.ok)throw Error(`Failed to save`);let i=(await t.json()).settings?.prePrompt??``;r(i),J.success(i.trim()===``?e(`prePrompt.cleared`):e(`prePrompt.saved`))}catch(t){J.error(e(`prePrompt.saveFailed`),{description:t.message})}finally{a(!1)}}async function m(){l(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({freestylePrePrompt:o})});if(!t.ok)throw Error(`Failed to save`);let n=(await t.json()).settings?.freestylePrePrompt??``;s(n),J.success(n.trim()===``?e(`freestylePrePrompt.resetToDefault`):e(`freestylePrePrompt.saved`))}catch(t){J.error(e(`freestylePrePrompt.saveFailed`),{description:t.message})}finally{l(!1)}}return u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hU,{value:n,onChange:e=>{f.current.pre=!0,r(e)},onSave:p,isSaving:i,fieldId:`project-pre-prompt`,i18nRoot:`prePrompt`}),(0,$.jsx)(hU,{value:o,onChange:e=>{f.current.freestyle=!0,s(e)},onSave:m,isSaving:c,fieldId:`project-freestyle-pre-prompt`,i18nRoot:`freestylePrePrompt`})]}):(0,$.jsx)(cU,{})}function _U(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)({daily:!1,perJob:!1});(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),f.current={daily:!1,perJob:!1},fetch(`${nt()}/budget`).then(e=>e.ok?e.json():null).then(t=>{e||!t||(f.current.daily||r(t.dailyBudgetUsd==null?``:String(t.dailyBudgetUsd)),f.current.perJob||s(t.jobCostThresholdUsd==null?``:String(t.jobCostThresholdUsd)))}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]);async function p(t,n,r,i){i(!0);try{if(!(await fetch(`${nt()}/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`Failed to save`);J.success(n)}catch(t){J.error(e(r),{description:t.message})}finally{i(!1)}}function m(t){let n=t.trim()===``?null:parseFloat(t);if(n!==null&&(isNaN(n)||n<=0)){J.error(e(`budget.invalidNumber`));return}return n}function h(){let t=m(n);t!==void 0&&p({dailyBudgetUsd:t},t==null?e(`budget.dailyRemoved`):e(`budget.dailySet`,{amount:t}),`budget.saveBudgetFailed`,a)}function g(){let t=m(o);t!==void 0&&p({jobCostThresholdUsd:t},t==null?e(`budget.perJobAlertDisabled`):e(`budget.alertSet`,{amount:t}),`budget.saveThresholdFailed`,l)}return u?(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`budget.title`)}),(0,$.jsx)($H,{children:e(`budget.description`)})]}),(0,$.jsx)(eU,{children:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs font-medium`,children:e(`budget.dailyLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`budget.dailyHelper`)})]}),(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:n,onChange:e=>{f.current.daily=!0,r(e.target.value)},placeholder:e(`budget.dailyPlaceholder`),className:`h-8 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:i,onClick:h,children:e(i?`common:states.saving`:`common:actions.save`)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs font-medium`,children:e(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`budget.perJobHelper`)})]}),(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:o,onChange:e=>{f.current.perJob=!0,s(e.target.value)},placeholder:e(`budget.perJobPlaceholder`),className:`h-8 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:c,onClick:g,children:e(c?`common:states.saving`:`common:actions.save`)})})]})]})})]}):(0,$.jsx)(cU,{})}function vU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),n=p(),r=t!==null;(0,Q.useEffect)(()=>{if(!n.hash)return;let e=n.hash.slice(1),t=!1,r=Date.now()+3e3,i=()=>{if(t)return;let n=document.getElementById(e);if(n){n.scrollIntoView({behavior:`smooth`,block:`center`}),n.classList.add(`ring-2`,`ring-accent-primary/60`,`rounded`),window.setTimeout(()=>{n.classList.remove(`ring-2`,`ring-accent-primary/60`,`rounded`)},1800);return}Date.now()<r&&window.setTimeout(i,80)};return i(),()=>{t=!0}},[n.hash,n.key]);let[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!0),c=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{if(t){let e=c.current.get(t);e?(a(e),s(!1)):s(!0)}async function e(){try{let e=await fetch(`${nt()}/config`);if(!e.ok)return;let n=await e.json();a(n),t&&c.current.set(t,n)}catch{}finally{s(!1)}}e()},[t]),o?(0,$.jsx)(`div`,{className:`max-w-2xl mx-auto px-4 py-6 space-y-3`,children:[0,1,2].map(e=>(0,$.jsx)(`div`,{className:`h-32 bg-muted/30 rounded-lg animate-pulse`},e))}):(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto px-4 py-6 space-y-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`page.title`)}),i&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[i.project.name,i.project.repo&&` · ${i.project.repo}`]})]}),r&&(0,$.jsx)(lU,{}),(0,$.jsx)(gU,{}),(0,$.jsx)(oU,{}),(0,$.jsx)(uU,{}),(0,$.jsx)(mU,{}),(0,$.jsx)(_U,{}),(0,$.jsx)(rU,{mode:`project`})]})}function yU(){let{t:e}=K(`settings`),t=rk();return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`effects-section`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`effects.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`effects.description`)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t.agentThinkingHalo,onClick:()=>tk({agentThinkingHalo:!t.agentThinkingHalo}),className:X(`relative mt-0.5 inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors`,t.agentThinkingHalo?`bg-accent-primary/70`:`bg-muted-foreground/30`),"data-testid":`effects-thinking-halo-toggle`,children:(0,$.jsx)(`span`,{className:X(`absolute h-3 w-3 rounded-full bg-background shadow transition-transform`,t.agentThinkingHalo?`translate-x-3.5`:`translate-x-0.5`)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[(0,$.jsx)(un,{className:`h-3.5 w-3.5 text-accent-primary`,"aria-hidden":!0}),e(`effects.thinkingHalo.label`)]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:e(`effects.thinkingHalo.description`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground/80`,children:e(`effects.reducedMotion`)}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`p`,{className:`mb-1.5 text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`effects.preview`)}),(0,$.jsxs)(`div`,{className:`relative max-w-sm rounded-xl border border-border/60 bg-background/60 px-3 py-2`,"data-testid":`effects-thinking-halo-preview`,"data-active":t.agentThinkingHalo,children:[(0,$.jsx)(JO,{active:t.agentThinkingHalo,radius:`0.75rem`,inset:-3,fadeInMs:450,fadeOutMs:800}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex gap-0.5`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary`}),(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary [animation-delay:300ms]`})]}),e(`effects.previewThinking`)]})]})]})]})]})]})]})}function bU(){let{t:e}=K(`settings`),t=sa();if(!t)return null;let{themeId:n,setTheme:r,isUpdating:i}=t;async function a(t){if(t!==n)try{await r(t)}catch(t){J.error(e(`appearance.updateFailed`),{description:t instanceof Error?t.message:void 0})}}return(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2`,role:`radiogroup`,"aria-label":e(`appearance.themeGroupLabel`),children:Pi.map(t=>{let r=Yi[t],o=t===n;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:i,onClick:()=>void a(t),className:`group relative overflow-hidden rounded-lg border text-left transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/60 disabled:opacity-60 disabled:cursor-not-allowed `+(o?`border-accent-primary ring-1 ring-accent-primary shadow-[0_0_0_1px_var(--color-accent-primary)] `:`border-border hover:border-accent-primary/40 hover:shadow-md `),"data-testid":`theme-card-${t}`,"data-selected":o?`true`:`false`,children:[(0,$.jsx)(`div`,{className:`h-20 w-full flex items-end gap-1 p-2`,style:{background:`linear-gradient(135deg, ${r.previewSwatches.background} 0%, ${r.previewSwatches.background} 60%, color-mix(in srgb, ${r.previewSwatches.accents[0]} 18%, ${r.previewSwatches.background}) 100%)`},"aria-hidden":`true`,children:r.previewSwatches.accents.map((e,t)=>(0,$.jsx)(`span`,{className:`h-3 w-3 rounded-full ring-1 ring-black/10`,style:{background:e}},t))}),(0,$.jsxs)(`div`,{className:`p-3 space-y-1 bg-card`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold`,children:r.displayName}),o&&(0,$.jsx)(Ht,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-label":e(`appearance.currentlyActive`)})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-tight`,children:e(`appearance.taglines.${t}`,{defaultValue:r.tagline})})]})]},t)})})}function xU(){let{t:e}=K(`settings`);return sa()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`appearance.heading`)}),(0,$.jsx)(bU,{})]}):null}function SU(e={}){let t={...e},n=Ve();return n&&(t[`X-Desktop-Token`]=n),t}var CU=(0,Q.createContext)(null);function wU(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(ze,e)}catch{}}function TU(){if(!(typeof localStorage>`u`))try{localStorage.removeItem(ze)}catch{}}function EU({children:e,endpoint:t=`/api/language`}){let[n,r]=(0,Q.useState)(()=>Ke()),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(o.current)return;o.current=!0;let e=!1;return(async()=>{try{let n=await fetch(t,{headers:SU()});if(!n.ok)return;let i=await n.json();if(e)return;Fe(i.language)&&i.language!==Ke()&&(await Ze(i.language),wU(i.language),e||r(i.language))}catch{}})(),()=>{e=!0}},[t]);let s=(0,Q.useCallback)(async e=>{if(e===n)return;let i=n,o=typeof localStorage<`u`&&Fe(localStorage.getItem(`specrails-desktop:ui-language`));await Ze(e),wU(e),r(e),a(!0);try{let n=await fetch(t,{method:`PATCH`,headers:SU({"Content-Type":`application/json`}),body:JSON.stringify({language:e})});if(!n.ok)throw Error(`server rejected language: ${n.status}`)}catch(e){throw await Ze(i),o?wU(i):TU(),r(i),e}finally{a(!1)}},[n,t]),c=(0,Q.useMemo)(()=>({languageId:n,language:Xe[n],setLanguage:s,isUpdating:i}),[n,s,i]);return(0,$.jsx)(CU.Provider,{value:c,children:e})}function DU(){return(0,Q.useContext)(CU)}function OU(){let{t:e}=K(`settings`),t=DU();if(!t)return null;let{languageId:n,setLanguage:r,isUpdating:i}=t;async function a(t){if(t!==n)try{await r(t)}catch(t){J.error(e(`language.updateFailed`),{description:t instanceof Error?t.message:void 0})}}return(0,$.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,role:`radiogroup`,"aria-label":e(`language.selectLabel`),children:Re.map(e=>{let t=Xe[e],r=e===n;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:i,onClick:()=>void a(e),className:`flex items-center justify-between gap-2 rounded-lg border bg-card px-3 py-2 text-left transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/60 disabled:opacity-60 disabled:cursor-not-allowed `+(r?`border-accent-primary ring-1 ring-accent-primary `:`border-border hover:border-accent-primary/40 hover:shadow-md `),"data-testid":`language-card-${e}`,"data-selected":r?`true`:`false`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-xs font-semibold truncate`,children:t.nativeName}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground truncate`,children:t.englishName})]}),r&&(0,$.jsx)(Ht,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-hidden":`true`})]},e)})})}function kU(){let{t:e}=K(`settings`);return DU()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`language.title`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`language.description`)}),(0,$.jsx)(OU,{})]}):null}function AU(){if(!se)return null;let{t:e}=K(`settings`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return fetch(`/api/code-explorer-settings`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{e||n(t)}).catch(()=>{e||n({language:`en`,monthlyBudgetUsd:5})}),()=>{e=!0}},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let e=await fetch(`/api/code-explorer-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(r){J.error(e(`errors.saveFailed`,{message:r.message})),n(t)}finally{i(!1)}}return t?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`codeSection.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`codeSection.summaryLanguage`)}),(0,$.jsxs)(`select`,{value:t.language,disabled:r,onChange:e=>a({language:e.target.value}),className:`bg-background border border-border rounded px-2 py-1 text-xs`,children:[(0,$.jsx)(`option`,{value:`en`,children:`English`}),(0,$.jsx)(`option`,{value:`es`,children:`Español`})]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`codeSection.monthlyBudget`)}),(0,$.jsx)(`input`,{type:`number`,min:0,step:.5,value:t.monthlyBudgetUsd,disabled:r,onChange:e=>{let t=parseFloat(e.target.value);!isNaN(t)&&t>=0&&a({monthlyBudgetUsd:t})},className:`bg-background border border-border rounded px-2 py-1 text-xs w-24 text-right`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:e(`codeSection.budgetHelper`)})]})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var jU=`__default__`,MU={"sr-architect":Yo,"sr-developer":ps,"sr-reviewer":ec};function NU(e){let t=e;return!t||!Array.isArray(t.catalog)||typeof t.settings!=`object`||t.settings===null||typeof t.settings.providers!=`object`||t.settings.providers===null?null:t}function PU(){let{t:e}=K(`settings`),t=gz(),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return fetch(`/api/agent-defaults`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{if(e)return;let n=NU(t);n?r(n):a(!0)}).catch(()=>{e||a(!0)}),()=>{e=!0}},[]);async function o(t,i){if(!n)return;let a=n;r({...a,settings:{...a.settings,providers:{...a.settings.providers,[t]:i}}});try{let e=await fetch(`/api/agent-defaults`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providers:{[t]:i}})});if(!e.ok){let t=await e.json().catch(()=>({message:`HTTP ${e.status}`}));throw Error(t.message??`HTTP ${e.status}`)}let n=NU(await e.json());if(!n)throw Error(`unexpected response`);r(n)}catch(t){r(a),J.error(e(`errors.saveFailed`,{message:t.message}))}}return i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`specrailsAgents.loadFailed`)})]}):n?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`specrailsAgents.description`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:n.catalog.map(e=>(0,$.jsx)(IU,{entry:e,config:n.settings.providers[e.id]??{custom:!1},detected:t.loading||t.detected.includes(e.id),unauthenticated:t.providers[e.id]?.authState===`unauthenticated`,version:t.providers[e.id]?.version,onChange:t=>void o(e.id,t)},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})]})}function FU({t:e}){return(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:[(0,$.jsx)(wo,{className:`h-3.5 w-3.5`}),e(`specrailsAgents.heading`)]})}function IU({entry:e,config:t,detected:n,unauthenticated:r,version:i,onChange:a}){let{t:o}=K(`settings`),s=t.custom===!0,c=s||!!t.pipelineModel||!!t.pipelineEffort||Object.keys(t.agentModels??{}).length>0,l=t.pipelineModel??e.defaultModel,u=e.effortsByModel[l]??[],d=e.models.find(t=>t.value===e.defaultModel)?.label??e.defaultModel,f=(0,Q.useMemo)(()=>[{value:jU,label:o(`specrailsAgents.defaultModel`,{model:d})},...e.models.map(e=>({value:e.value,label:e.label})),...t.pipelineModel&&!e.models.some(e=>e.value===t.pipelineModel)?[{value:t.pipelineModel,label:t.pipelineModel}]:[]],[e.models,t.pipelineModel,d,o]),p=(0,Q.useMemo)(()=>[{value:jU,label:o(`specrailsAgents.defaultEffort`)},...u.map(e=>({value:e,label:e}))],[u,o]);function m(n){let r=t.agentModels?.[n];return[{value:jU,label:o(`specrailsAgents.defaultModel`,{model:d})},...e.models.map(e=>({value:e.value,label:e.label})),...r&&!e.models.some(e=>e.value===r)?[{value:r,label:r}]:[]]}function h(e){a({...t,custom:!0,...e})}function g(e,n){let r={...t.agentModels??{}};n===jU?delete r[e]:r[e]=n,h({agentModels:r})}return(0,$.jsxs)(`div`,{"data-testid":`agent-defaults-card-${e.id}`,className:X(`rounded-lg border transition-colors`,s&&n?`border-accent-primary/45`:`border-border`,!n&&`opacity-60`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5`,children:[(0,$.jsx)(Go,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.displayName}),i&&(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:i}),!n&&(0,$.jsx)(`span`,{className:`rounded-full bg-muted/50 px-1.5 py-px text-[10px] leading-4 text-muted-foreground`,children:o(`specrailsAgents.notDetected`)}),n&&r&&(0,$.jsx)(`span`,{className:`rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] leading-4 text-accent-warning`,children:o(`specrailsAgents.notSignedIn`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[c&&n&&(0,$.jsx)(`button`,{type:`button`,title:o(`specrailsAgents.reset`),"aria-label":o(`specrailsAgents.reset`),"data-testid":`agent-defaults-reset-${e.id}`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,onClick:()=>a({custom:!1}),children:(0,$.jsx)(Zs,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(LU,{custom:s,disabled:!n,providerId:e.id,onToggle:e=>e?h({}):a({...t,custom:!1})})]})]}),(0,$.jsx)(f_,{initial:!1,children:s&&(0,$.jsx)(fy.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.16,ease:`easeOut`},className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-border/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:o(`specrailsAgents.pipeline`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(uD,{label:o(`specrailsAgents.model`),value:t.pipelineModel??jU,options:f,icon:un,disabled:!n,testId:`agent-defaults-model-${e.id}`,onSelect:e=>h({pipelineModel:e===jU?void 0:e})}),e.supportsEffort&&u.length>0&&(0,$.jsx)(uD,{label:o(`specrailsAgents.effort`),value:t.pipelineEffort??jU,options:p,icon:ss,disabled:!n,testId:`agent-defaults-effort-${e.id}`,onSelect:e=>h({pipelineEffort:e===jU?void 0:e})})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`specrailsAgents.pipelineHint`)})]}),e.perAgentModels?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:o(`specrailsAgents.agentsTitle`)}),(0,$.jsx)(`div`,{className:`space-y-1`,children:e.baselineAgents.map(r=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/60 px-2.5 py-1.5`,children:[(0,$.jsx)(MU[r]??wo,{className:`h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:o(`specrailsAgents.agentNames.${r}`,{defaultValue:r})}),(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:r}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(uD,{label:o(`specrailsAgents.model`),value:t.agentModels?.[r]??jU,options:m(r),icon:un,disabled:!n,testId:`agent-defaults-agent-${e.id}-${r}`,onSelect:e=>g(r,e)})})]},r))}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`specrailsAgents.agentsHint`)})]}):(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(vs,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),e.id===`codex`?o(`specrailsAgents.inheritNote`):o(`specrailsAgents.noPerAgentNote`)]})]})},`body`)})]})}function LU({custom:e,disabled:t,providerId:n,onToggle:r}){let{t:i}=K(`settings`),a=`rounded-full px-2.5 py-0.5 text-[10px] font-medium transition-colors disabled:cursor-not-allowed`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-full bg-muted/30 p-0.5`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`agent-defaults-mode-default-${n}`,className:X(a,e?`text-muted-foreground hover:text-foreground`:`bg-surface text-foreground shadow-sm`),onClick:()=>r(!1),children:i(`specrailsAgents.modeDefault`)}),(0,$.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`agent-defaults-mode-custom-${n}`,className:X(a,e?`bg-accent-primary/15 text-accent-primary shadow-sm`:`text-muted-foreground hover:text-foreground`),onClick:()=>r(!0),children:i(`specrailsAgents.modeCustom`)})]})}function RU(){let{t:e}=K(`settings`),{registerHandler:t,unregisterHandler:n}=qe(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(0),f=(0,Q.useRef)(null),p=(0,Q.useCallback)(async()=>{let e=++d.current;try{let t=await fetch(`/api/core-update/status`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return e===d.current?(i(n),u(!1),n.updating||c(null),n):null}catch{return e===d.current&&u(!0),null}},[]);(0,Q.useEffect)(()=>{p();let e=()=>{p()};return window.addEventListener(`focus`,e),()=>{d.current++,window.removeEventListener(`focus`,e)}},[p]);let m=(0,Q.useRef)(p);m.current=p,(0,Q.useEffect)(()=>(t(`core-update`,t=>{let n=t;if(n.type===`framework.updated`){m.current();return}if(n.type!==`core_update.progress`)return;let r=n.phase;c(r),r===`done`?(J.success(e(`coreUpdate.toastDone`,{version:String(n.version??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),2500)):r===`error`&&(J.error(e(`coreUpdate.toastError`,{message:String(n.message??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),4e3))}),()=>{n(`core-update`),f.current&&clearTimeout(f.current)}),[t,n,e]);let h=(0,Q.useCallback)(async()=>{let t=++d.current;o(!0);try{let n=await fetch(`/api/core-update/check`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(t!==d.current)return;i(r),r.updateAvailable||J.success(e(`coreUpdate.toastUpToDate`))}catch(t){J.error(e(`coreUpdate.toastCheckFailed`,{message:t.message}))}finally{o(!1)}},[e]),g=s===`downloading`||s===`materializing`||!!r?.updating;(0,Q.useEffect)(()=>{if(!g)return;let e=setInterval(()=>{p()},1500);return()=>clearInterval(e)},[g,p]);let _=(0,Q.useCallback)(async()=>{c(`downloading`);try{let e=await fetch(`/api/core-update/update`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(e.status!==202){let t=await e.json().catch(()=>({}));throw Error(t.message??`HTTP ${e.status}`)}}catch(t){c(null),J.error(e(`coreUpdate.toastError`,{message:t.message}))}},[e]);if(!r)return l?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`text-xs text-destructive`,children:e(`coreUpdate.loadFailed`)}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`});let v=r.currentVersion??`—`,y=r.pendingVersion??r.latestVersion;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`coreUpdate.heading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:r.available?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-foreground`,children:[e(`coreUpdate.installed`),` `,(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:v})]}),r.runtimeVersion&&(0,$.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[e(`coreUpdate.runtime`,{version:r.runtimeVersion}),r.runtimeSource?` · ${e(`coreUpdate.sources.${r.runtimeSource}`)}`:``]}),r.bundledVersion&&r.bundledVersion!==r.runtimeVersion&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`coreUpdate.bundled`,{version:r.bundledVersion})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:r.updateAvailable&&r.latestVersion?e(`coreUpdate.updateAvailable`,{version:r.latestVersion}):r.lastCheckedAt?e(`coreUpdate.upToDate`):e(`coreUpdate.neverChecked`)})]}),r.updateAvailable&&y?(0,$.jsxs)(`button`,{type:`button`,onClick:_,disabled:g,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-accent-primary/45 bg-accent-primary/15 px-3 text-[11px] font-semibold text-accent-primary disabled:opacity-50`,children:[g?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(tn,{className:`h-3.5 w-3.5`}),g?e(s===`materializing`?`coreUpdate.materializing`:`coreUpdate.downloading`):r.pendingVersion?e(`coreUpdate.repair`,{version:y}):e(`coreUpdate.update`,{version:y})]}):(0,$.jsxs)(`button`,{type:`button`,onClick:h,disabled:a||g,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[a?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):s===`done`?(0,$.jsx)(Mo,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Js,{className:`h-3.5 w-3.5`}),e(a?`coreUpdate.checking`:`coreUpdate.check`)]})]}),r.runtimeError&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.runtimeError}),r.migrationError&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.migrationError}),l&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-destructive`,onClick:()=>{p()},children:e(`coreUpdate.loadFailed`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:e(`coreUpdate.affectsAll`)})]}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`coreUpdate.unavailable`)})})]})}var zU=class extends st{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,t){VU(t);let n=new lt;e&&(n.onmessage=e);let r=await Y(`plugin:updater|download`,{onEvent:n,rid:this.rid,...t});this.downloadedBytes=new st(r)}async install(){if(!this.downloadedBytes)throw Error(`Update.install called before Update.download`);await Y(`plugin:updater|install`,{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(e,t){VU(t);let n=new lt;e&&(n.onmessage=e),await Y(`plugin:updater|download_and_install`,{onEvent:n,rid:this.rid,...t})}async close(){await this.downloadedBytes?.close(),await super.close()}};async function BU(e){VU(e);let t=await Y(`plugin:updater|check`,{...e});return t?new zU(t):null}function VU(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}var HU;(function(e){e.Nsis=`nsis`,e.Msi=`msi`,e.Deb=`deb`,e.Rpm=`rpm`,e.AppImage=`appimage`,e.App=`app`})(HU||={});async function UU(){return Y(`plugin:app|version`)}async function WU(){await Y(`plugin:process|restart`)}var GU=`specrails-desktop:dismissedDesktopUpdateVersion`,KU=`specrails-desktop-desktop-update`,qU=360*60*1e3;function JU(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function YU(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE===`true`}function XU(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE_VERSION||`99.0.0-test`}function ZU(e){return new Promise(t=>setTimeout(t,e))}function QU(){return{currentVersion:`1.40.1`,version:XU(),isMock:!0,async downloadAndInstall(e){e({event:`Started`,data:{contentLength:18874368}});for(let t=0;t<12;t+=1)await ZU(180),e({event:`Progress`,data:{chunkLength:1572864}});e({event:`Finished`})}}}function $U(e){return e<1024*1024?G.t(`commands:update.units.kb`,{value:Math.max(1,Math.round(e/1024))}):G.t(`commands:update.units.mb`,{value:(e/(1024*1024)).toFixed(1)})}function eW(){try{return localStorage.getItem(GU)}catch{return null}}function tW(e){try{localStorage.setItem(GU,e)}catch{}J.dismiss(KU)}function nW(e){switch(e){case`downloading`:return`var(--color-accent-info)`;case`ready`:return`var(--color-accent-success)`;default:return`var(--color-accent-primary)`}}function rW({state:e}){let t=`h-[15px] w-[15px]`;return e===`installing`?(0,$.jsx)(Ro,{className:`${t} u-spin`,"aria-hidden":!0}):e===`ready`?(0,$.jsx)(Ht,{className:`${t} u-check`,"aria-hidden":!0}):e===`error`?(0,$.jsx)(fn,{className:t,"aria-hidden":!0}):(0,$.jsx)(Io,{className:t,"aria-hidden":!0})}function iW({state:e,progress:t}){let n=e===`downloading`&&t!=null,r=e===`installing`||e===`downloading`&&t==null,i=e===`ready`;return(0,$.jsxs)(`div`,{className:`relative h-1.5 w-full overflow-hidden rounded-full border border-border/30 bg-background/70`,children:[n&&(0,$.jsx)(`div`,{className:`relative h-full overflow-hidden rounded-full bg-[color:var(--u-accent)] transition-[width] duration-300 ease-out`,style:{width:`${t}%`},role:`progressbar`,"aria-valuenow":t??0,"aria-valuemin":0,"aria-valuemax":100,children:(0,$.jsx)(`span`,{className:`u-shimmer`,"aria-hidden":!0})}),r&&(0,$.jsx)(`span`,{className:`u-indeterminate`,"aria-hidden":!0}),i&&(0,$.jsx)(`div`,{className:`h-full w-full rounded-full bg-[color:var(--u-accent)]/80`,"aria-hidden":!0})]})}function aW({update:e,onClose:t}){let{t:n}=K(`commands`),[r,i]=(0,Q.useState)(`available`),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);async function d(){try{i(`downloading`),o(0),c(null),u(null),await e.downloadAndInstall(e=>{if(e.event===`Started`){c(e.data.contentLength??null),o(0);return}if(e.event===`Progress`){o(t=>t+e.data.chunkLength);return}i(`installing`)}),i(`ready`)}catch(e){u(e.message||n(`update.errors.installFailed`)),i(`error`)}}function f(){if(e.isMock){J.success(n(`update.mockReady`),{duration:2500}),J.dismiss(KU),t?.();return}Y(`restart_app`).catch(()=>{WU()})}let p=s&&s>0?Math.min(100,Math.round(a/s*100)):null,m=nW(r),h=r===`downloading`||r===`installing`,g=n(r===`downloading`?`update.title.downloading`:r===`installing`?`update.title.installing`:r===`ready`?`update.title.ready`:r===`error`?`update.title.error`:`update.title.available`),_=r===`available`?n(`update.desc.available`):r===`downloading`?p==null?n(`update.desc.fetching`,{size:$U(a)}):n(`update.desc.progress`,{percent:p,downloaded:$U(a),total:$U(s??0)}):r===`installing`?n(`update.desc.installing`):r===`ready`?n(`update.desc.ready`,{version:e.version}):l&&l.length<=80?l:n(`update.desc.errorFallback`),v=r===`available`?`${e.currentVersion} → ${e.version}`:r===`downloading`?n(`update.pill.downloading`):r===`installing`?n(`update.pill.installing`):r===`ready`?n(`update.pill.ready`):null;return(0,$.jsxs)(`div`,{className:`u-update-card relative flex w-full flex-col gap-2 overflow-hidden`,style:{"--u-accent":m},role:r===`error`?`alert`:`status`,"aria-live":r===`error`?`assertive`:`polite`,"data-state":r,children:[(0,$.jsx)(`span`,{className:`u-glow`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`u-badge grid h-7 w-7 shrink-0 place-items-center rounded-lg border border-border/50 bg-background/60 text-[color:var(--u-accent)]`,"aria-hidden":!0,children:(0,$.jsx)(rW,{state:r})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold leading-tight text-foreground`,children:g}),v!=null&&(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap rounded-md border border-border/40 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground`,style:r===`available`?void 0:{color:`var(--u-accent)`},children:v})]}),(0,$.jsx)(`p`,{className:`h-4 truncate text-[11px] leading-4 text-muted-foreground`,"data-testid":`update-description`,children:_}),(0,$.jsx)(iW,{state:r,progress:p}),(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-1.5`,children:r===`ready`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-grid h-7 min-w-[64px] place-items-center rounded-lg border border-[color:var(--u-accent)]/45 bg-[color:var(--u-accent)]/15 px-3 text-[11px] font-semibold leading-none text-foreground transition-colors hover:bg-[color:var(--u-accent)]/25`,onClick:f,children:n(`update.actions.restart`)}),(0,$.jsx)(`button`,{type:`button`,className:`h-7 rounded-lg px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground`,onClick:()=>{J.dismiss(KU),t?.()},children:n(`update.actions.later`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-grid h-7 min-w-[64px] place-items-center rounded-lg border border-[color:var(--u-accent)]/45 bg-[color:var(--u-accent)]/15 px-3 text-[11px] font-semibold leading-none text-foreground transition-colors hover:bg-[color:var(--u-accent)]/25 disabled:cursor-not-allowed disabled:opacity-50`,disabled:h,onClick:()=>void d(),children:n(r===`installing`?`update.actions.installing`:r===`error`?`update.actions.tryAgain`:`update.actions.update`)}),(0,$.jsx)(`button`,{type:`button`,className:`h-7 rounded-lg px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,disabled:h,onClick:()=>{tW(e.version),t?.()},children:n(`update.actions.dismiss`)})]})})]})}function oW(e){J.custom(()=>(0,$.jsx)(aW,{update:e}),{id:KU,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1})}function sW(){(0,Q.useEffect)(()=>{let e=YU();if(!e&&!JU())return;let t=!1,n={current:!1};async function r(){if(!(t||n.current))try{let r=e?QU():await BU();if(t||!r||eW()===r.version)return;n.current=!0,J.custom(()=>(0,$.jsx)(aW,{update:r,onClose:()=>{n.current=!1}}),{id:KU,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1,onDismiss:()=>{n.current=!1},onAutoClose:()=>{n.current=!1}})}catch(e){console.warn(`[desktop-update] update check failed:`,e)}}r();let i=setInterval(()=>void r(),qU);return()=>{t=!0,clearInterval(i)}},[])}function cW(){let{t:e}=K(`settings`),t=YU(),n=JU()||t,[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!JU())return;let e=!0;return UU().then(t=>{e&&i(t)}).catch(()=>{}),()=>{e=!1}},[]);let d=(0,Q.useCallback)(async()=>{o(!0),c(null);try{let n=t?QU():await BU();n?(c(`update-available`),u(n.version),oW(n)):(c(`up-to-date`),J.success(e(`appUpdate.toastUpToDate`)))}catch(t){J.error(e(`appUpdate.toastCheckFailed`,{message:t.message}))}finally{o(!1)}},[t,e]);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`appUpdate.heading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:n?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-foreground`,children:[e(`appUpdate.installed`),` `,(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:r??`—`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:s===`update-available`&&l?e(`appUpdate.updateAvailable`,{version:l}):e(s===`up-to-date`?`appUpdate.upToDate`:`appUpdate.autoHint`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void d(),disabled:a,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[a?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):s===`up-to-date`?(0,$.jsx)(Mo,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Js,{className:`h-3.5 w-3.5`}),e(a?`appUpdate.checking`:`appUpdate.check`)]})]})}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`appUpdate.unavailable`)})})]})}var lW=Object.defineProperty,uW=Object.getOwnPropertySymbols,dW=Object.prototype.hasOwnProperty,fW=Object.prototype.propertyIsEnumerable,pW=(e,t,n)=>t in e?lW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mW=(e,t)=>{for(var n in t||={})dW.call(t,n)&&pW(e,n,t[n]);if(uW)for(var n of uW(t))fW.call(t,n)&&pW(e,n,t[n]);return e},hW=(e,t)=>{var n={};for(var r in e)dW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&uW)for(var r of uW(e))t.indexOf(r)<0&&fW.call(e,r)&&(n[r]=e[r]);return n},gW;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(gW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(gW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(gW||={});var _W=gW,vW={L:_W.QrCode.Ecc.LOW,M:_W.QrCode.Ecc.MEDIUM,Q:_W.QrCode.Ecc.QUARTILE,H:_W.QrCode.Ecc.HIGH},yW=128,bW=`L`,xW=`#FFFFFF`,SW=`#000000`,CW=!1,wW=1,TW=4,EW=0,DW=.1;function OW(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function kW(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function AW(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*DW),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function jW(e,t){return t==null?e?TW:EW:Math.max(Math.floor(t),0)}function MW({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Q.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(..._W.QrSegment.makeSegments(t)),e),[]);return _W.QrCode.encodeSegments(r,vW[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Q.useMemo(()=>{let e=c.getModules(),t=jW(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:AW(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var NW=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),PW=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=yW,level:a=bW,bgColor:o=xW,fgColor:s=SW,includeMargin:c=CW,minVersion:l=wW,boostLevel:u,marginSize:d,imageSettings:f}=n,p=hW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=hW(p,[`style`]),g=f?.src,_=Q.useRef(null),v=Q.useRef(null),y=Q.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Q.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=MW({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Q.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=kW(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,NW?t.fill(new Path2D(OW(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Q.useEffect(()=>{x(!1)},[g]);let E=mW({height:i,width:i},m),D=null;return g!=null&&(D=Q.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Q.createElement(Q.Fragment,null,Q.createElement(`canvas`,mW({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});PW.displayName=`QRCodeCanvas`;var FW=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=yW,level:a=bW,bgColor:o=xW,fgColor:s=SW,includeMargin:c=CW,minVersion:l=wW,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=hW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=MW({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=kW(g,v.excavation)),b=Q.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=OW(y,h);return Q.createElement(`svg`,mW({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Q.createElement(`title`,null,d),Q.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Q.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});FW.displayName=`QRCodeSVG`;var IW=e(i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.jsQR=r():n.jsQR=r()})(typeof self<`u`?self:e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=3)})([(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitMatrix=function(){function e(e,t){this.width=t,this.height=e.length/t,this.data=e}return e.createEmpty=function(t,n){return new e(new Uint8ClampedArray(t*n),t)},e.prototype.get=function(e,t){return e<0||e>=this.width||t<0||t>=this.height?!1:!!this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=+!!n},e.prototype.setRegion=function(e,t,n,r,i){for(var a=t;a<t+r;a++)for(var o=e;o<e+n;o++)this.set(o,a,!!i)},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(2);function i(e,t){return e^t}t.addOrSubtractGF=i,t.default=function(){function e(e,t,n){this.primitive=e,this.size=t,this.generatorBase=n,this.expTable=Array(this.size),this.logTable=Array(this.size);for(var i=1,a=0;a<this.size;a++)this.expTable[a]=i,i*=2,i>=this.size&&(i=(i^this.primitive)&this.size-1);for(var a=0;a<this.size-1;a++)this.logTable[this.expTable[a]]=a;this.zero=new r.default(this,Uint8ClampedArray.from([0])),this.one=new r.default(this,Uint8ClampedArray.from([1]))}return e.prototype.multiply=function(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.size-1)]},e.prototype.inverse=function(e){if(e===0)throw Error(`Can't invert 0`);return this.expTable[this.size-this.logTable[e]-1]},e.prototype.buildMonomial=function(e,t){if(e<0)throw Error(`Invalid monomial degree less than 0`);if(t===0)return this.zero;var n=new Uint8ClampedArray(e+1);return n[0]=t,new r.default(this,n)},e.prototype.log=function(e){if(e===0)throw Error(`Can't take log(0)`);return this.logTable[e]},e.prototype.exp=function(e){return this.expTable[e]},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);t.default=function(){function e(e,t){if(t.length===0)throw Error(`No coefficients.`);this.field=e;var n=t.length;if(n>1&&t[0]===0){for(var r=1;r<n&&t[r]===0;)r++;if(r===n)this.coefficients=e.zero.coefficients;else{this.coefficients=new Uint8ClampedArray(n-r);for(var i=0;i<this.coefficients.length;i++)this.coefficients[i]=t[r+i]}}else this.coefficients=t}return e.prototype.degree=function(){return this.coefficients.length-1},e.prototype.isZero=function(){return this.coefficients[0]===0},e.prototype.getCoefficient=function(e){return this.coefficients[this.coefficients.length-1-e]},e.prototype.addOrSubtract=function(t){var n;if(this.isZero())return t;if(t.isZero())return this;var i=this.coefficients,a=t.coefficients;i.length>a.length&&(n=[a,i],i=n[0],a=n[1]);for(var o=new Uint8ClampedArray(a.length),s=a.length-i.length,c=0;c<s;c++)o[c]=a[c];for(var c=s;c<a.length;c++)o[c]=r.addOrSubtractGF(i[c-s],a[c]);return new e(this.field,o)},e.prototype.multiply=function(t){if(t===0)return this.field.zero;if(t===1)return this;for(var n=this.coefficients.length,r=new Uint8ClampedArray(n),i=0;i<n;i++)r[i]=this.field.multiply(this.coefficients[i],t);return new e(this.field,r)},e.prototype.multiplyPoly=function(t){if(this.isZero()||t.isZero())return this.field.zero;for(var n=this.coefficients,i=n.length,a=t.coefficients,o=a.length,s=new Uint8ClampedArray(i+o-1),c=0;c<i;c++)for(var l=n[c],u=0;u<o;u++)s[c+u]=r.addOrSubtractGF(s[c+u],this.field.multiply(l,a[u]));return new e(this.field,s)},e.prototype.multiplyByMonomial=function(t,n){if(t<0)throw Error(`Invalid degree less than 0`);if(n===0)return this.field.zero;for(var r=this.coefficients.length,i=new Uint8ClampedArray(r+t),a=0;a<r;a++)i[a]=this.field.multiply(this.coefficients[a],n);return new e(this.field,i)},e.prototype.evaluateAt=function(e){var t=0;if(e===0)return this.getCoefficient(0);var n=this.coefficients.length;if(e===1)return this.coefficients.forEach(function(e){t=r.addOrSubtractGF(t,e)}),t;t=this.coefficients[0];for(var i=1;i<n;i++)t=r.addOrSubtractGF(this.field.multiply(e,t),this.coefficients[i]);return t},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(4),i=n(5),a=n(11),o=n(12);function s(e){var t=o.locate(e);if(!t)return null;for(var n=0,r=t;n<r.length;n++){var s=r[n],c=a.extract(e,s),l=i.decode(c.matrix);if(l)return{binaryData:l.bytes,data:l.text,chunks:l.chunks,version:l.version,location:{topRightCorner:c.mappingFunction(s.dimension,0),topLeftCorner:c.mappingFunction(0,0),bottomRightCorner:c.mappingFunction(s.dimension,s.dimension),bottomLeftCorner:c.mappingFunction(0,s.dimension),topRightFinderPattern:s.topRight,topLeftFinderPattern:s.topLeft,bottomLeftFinderPattern:s.bottomLeft,bottomRightAlignmentPattern:s.alignmentPattern}}}return null}var c={inversionAttempts:`attemptBoth`};function l(e,t,n,i){i===void 0&&(i={});var a=c;Object.keys(a||{}).forEach(function(e){a[e]=i[e]||a[e]});var o=a.inversionAttempts===`attemptBoth`||a.inversionAttempts===`invertFirst`,l=a.inversionAttempts===`onlyInvert`||a.inversionAttempts===`invertFirst`,u=r.binarize(e,t,n,o),d=u.binarized,f=u.inverted,p=s(l?f:d);return!p&&(a.inversionAttempts===`attemptBoth`||a.inversionAttempts===`invertFirst`)&&(p=s(l?d:f)),p}l.default=l,t.default=l}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=8,a=24;function o(e,t,n){return e<t?t:e>n?n:e}var s=function(){function e(e,t){this.width=e,this.data=new Uint8ClampedArray(e*t)}return e.prototype.get=function(e,t){return this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=n},e}();function c(e,t,n,c){if(e.length!==t*n*4)throw Error(`Malformed data passed to binarizer.`);for(var l=new s(t,n),u=0;u<t;u++)for(var d=0;d<n;d++){var f=e[(d*t+u)*4+0],p=e[(d*t+u)*4+1],m=e[(d*t+u)*4+2];l.set(u,d,.2126*f+.7152*p+.0722*m)}for(var h=Math.ceil(t/i),g=Math.ceil(n/i),_=new s(h,g),v=0;v<g;v++)for(var y=0;y<h;y++){for(var b=0,x=1/0,S=0,d=0;d<i;d++)for(var u=0;u<i;u++){var C=l.get(y*i+u,v*i+d);b+=C,x=Math.min(x,C),S=Math.max(S,C)}var w=b/i**2;if(S-x<=a&&(w=x/2,v>0&&y>0)){var T=(_.get(y,v-1)+2*_.get(y-1,v)+_.get(y-1,v-1))/4;x<T&&(w=T)}_.set(y,v,w)}var E=r.BitMatrix.createEmpty(t,n),D=null;c&&(D=r.BitMatrix.createEmpty(t,n));for(var v=0;v<g;v++)for(var y=0;y<h;y++){for(var O=o(y,2,h-3),k=o(v,2,g-3),b=0,A=-2;A<=2;A++)for(var j=-2;j<=2;j++)b+=_.get(O+A,k+j);for(var M=b/25,A=0;A<i;A++)for(var j=0;j<i;j++){var u=y*i+A,d=v*i+j,N=l.get(u,d);E.set(u,d,N<=M),c&&D.set(u,d,!(N<=M))}}return c?{binarized:E,inverted:D}:{binarized:E}}t.binarize=c}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(6),a=n(9),o=n(10);function s(e,t){for(var n=e^t,r=0;n;)r++,n&=n-1;return r}function c(e,t){return t<<1|e}var l=[{bits:21522,formatInfo:{errorCorrectionLevel:1,dataMask:0}},{bits:20773,formatInfo:{errorCorrectionLevel:1,dataMask:1}},{bits:24188,formatInfo:{errorCorrectionLevel:1,dataMask:2}},{bits:23371,formatInfo:{errorCorrectionLevel:1,dataMask:3}},{bits:17913,formatInfo:{errorCorrectionLevel:1,dataMask:4}},{bits:16590,formatInfo:{errorCorrectionLevel:1,dataMask:5}},{bits:20375,formatInfo:{errorCorrectionLevel:1,dataMask:6}},{bits:19104,formatInfo:{errorCorrectionLevel:1,dataMask:7}},{bits:30660,formatInfo:{errorCorrectionLevel:0,dataMask:0}},{bits:29427,formatInfo:{errorCorrectionLevel:0,dataMask:1}},{bits:32170,formatInfo:{errorCorrectionLevel:0,dataMask:2}},{bits:30877,formatInfo:{errorCorrectionLevel:0,dataMask:3}},{bits:26159,formatInfo:{errorCorrectionLevel:0,dataMask:4}},{bits:25368,formatInfo:{errorCorrectionLevel:0,dataMask:5}},{bits:27713,formatInfo:{errorCorrectionLevel:0,dataMask:6}},{bits:26998,formatInfo:{errorCorrectionLevel:0,dataMask:7}},{bits:5769,formatInfo:{errorCorrectionLevel:3,dataMask:0}},{bits:5054,formatInfo:{errorCorrectionLevel:3,dataMask:1}},{bits:7399,formatInfo:{errorCorrectionLevel:3,dataMask:2}},{bits:6608,formatInfo:{errorCorrectionLevel:3,dataMask:3}},{bits:1890,formatInfo:{errorCorrectionLevel:3,dataMask:4}},{bits:597,formatInfo:{errorCorrectionLevel:3,dataMask:5}},{bits:3340,formatInfo:{errorCorrectionLevel:3,dataMask:6}},{bits:2107,formatInfo:{errorCorrectionLevel:3,dataMask:7}},{bits:13663,formatInfo:{errorCorrectionLevel:2,dataMask:0}},{bits:12392,formatInfo:{errorCorrectionLevel:2,dataMask:1}},{bits:16177,formatInfo:{errorCorrectionLevel:2,dataMask:2}},{bits:14854,formatInfo:{errorCorrectionLevel:2,dataMask:3}},{bits:9396,formatInfo:{errorCorrectionLevel:2,dataMask:4}},{bits:8579,formatInfo:{errorCorrectionLevel:2,dataMask:5}},{bits:11994,formatInfo:{errorCorrectionLevel:2,dataMask:6}},{bits:11245,formatInfo:{errorCorrectionLevel:2,dataMask:7}}],u=[function(e){return(e.y+e.x)%2==0},function(e){return e.y%2==0},function(e){return e.x%3==0},function(e){return(e.y+e.x)%3==0},function(e){return(Math.floor(e.y/2)+Math.floor(e.x/3))%2==0},function(e){return e.x*e.y%2+e.x*e.y%3==0},function(e){return(e.y*e.x%2+e.y*e.x%3)%2==0},function(e){return((e.y+e.x)%2+e.y*e.x%3)%2==0}];function d(e){var t=17+4*e.versionNumber,n=r.BitMatrix.createEmpty(t,t);n.setRegion(0,0,9,9,!0),n.setRegion(t-8,0,8,9,!0),n.setRegion(0,t-8,9,8,!0);for(var i=0,a=e.alignmentPatternCenters;i<a.length;i++)for(var o=a[i],s=0,c=e.alignmentPatternCenters;s<c.length;s++){var l=c[s];o===6&&l===6||o===6&&l===t-7||o===t-7&&l===6||n.setRegion(o-2,l-2,5,5,!0)}return n.setRegion(6,9,1,t-17,!0),n.setRegion(9,6,t-17,1,!0),e.versionNumber>6&&(n.setRegion(t-11,0,3,6,!0),n.setRegion(0,t-11,6,3,!0)),n}function f(e,t,n){for(var r=u[n.dataMask],i=e.height,a=d(t),o=[],s=0,l=0,f=!0,p=i-1;p>0;p-=2){p===6&&p--;for(var m=0;m<i;m++)for(var h=f?i-1-m:m,g=0;g<2;g++){var _=p-g;if(!a.get(_,h)){l++;var v=e.get(_,h);r({y:h,x:_})&&(v=!v),s=c(v,s),l===8&&(o.push(s),l=0,s=0)}}f=!f}return o}function p(e){var t=e.height,n=Math.floor((t-17)/4);if(n<=6)return o.VERSIONS[n-1];for(var r=0,i=5;i>=0;i--)for(var a=t-9;a>=t-11;a--)r=c(e.get(a,i),r);for(var l=0,a=5;a>=0;a--)for(var i=t-9;i>=t-11;i--)l=c(e.get(a,i),l);for(var u=1/0,d,f=0,p=o.VERSIONS;f<p.length;f++){var m=p[f];if(m.infoBits===r||m.infoBits===l)return m;var h=s(r,m.infoBits);h<u&&(d=m,u=h),h=s(l,m.infoBits),h<u&&(d=m,u=h)}if(u<=3)return d}function m(e){for(var t=0,n=0;n<=8;n++)n!==6&&(t=c(e.get(n,8),t));for(var r=7;r>=0;r--)r!==6&&(t=c(e.get(8,r),t));for(var i=e.height,a=0,r=i-1;r>=i-7;r--)a=c(e.get(8,r),a);for(var n=i-8;n<i;n++)a=c(e.get(n,8),a);for(var o=1/0,u=null,d=0,f=l;d<f.length;d++){var p=f[d],m=p.bits,h=p.formatInfo;if(m===t||m===a)return h;var g=s(t,m);g<o&&(u=h,o=g),t!==a&&(g=s(a,m),g<o&&(u=h,o=g))}return o<=3?u:null}function h(e,t,n){var r=t.errorCorrectionLevels[n],i=[],a=0;if(r.ecBlocks.forEach(function(e){for(var t=0;t<e.numBlocks;t++)i.push({numDataCodewords:e.dataCodewordsPerBlock,codewords:[]}),a+=e.dataCodewordsPerBlock+r.ecCodewordsPerBlock}),e.length<a)return null;e=e.slice(0,a);for(var o=r.ecBlocks[0].dataCodewordsPerBlock,s=0;s<o;s++)for(var c=0,l=i;c<l.length;c++){var u=l[c];u.codewords.push(e.shift())}if(r.ecBlocks.length>1)for(var d=r.ecBlocks[0].numBlocks,f=r.ecBlocks[1].numBlocks,s=0;s<f;s++)i[d+s].codewords.push(e.shift());for(;e.length>0;)for(var p=0,m=i;p<m.length;p++){var u=m[p];u.codewords.push(e.shift())}return i}function g(e){var t=p(e);if(!t)return null;var n=m(e);if(!n)return null;var r=h(f(e,t,n),t,n.errorCorrectionLevel);if(!r)return null;for(var o=r.reduce(function(e,t){return e+t.numDataCodewords},0),s=new Uint8ClampedArray(o),c=0,l=0,u=r;l<u.length;l++){var d=u[l],g=a.decode(d.codewords,d.codewords.length-d.numDataCodewords);if(!g)return null;for(var _=0;_<d.numDataCodewords;_++)s[c++]=g[_]}try{return i.decode(s,t.versionNumber)}catch{return null}}function _(e){if(e==null)return null;var t=g(e);if(t)return t;for(var n=0;n<e.width;n++)for(var r=n+1;r<e.height;r++)e.get(n,r)!==e.get(r,n)&&(e.set(n,r,!e.get(n,r)),e.set(r,n,!e.get(r,n)));return g(e)}t.decode=_}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(8),a;(function(e){e.Numeric=`numeric`,e.Alphanumeric=`alphanumeric`,e.Byte=`byte`,e.Kanji=`kanji`,e.ECI=`eci`})(a=t.Mode||={});var o;(function(e){e[e.Terminator=0]=`Terminator`,e[e.Numeric=1]=`Numeric`,e[e.Alphanumeric=2]=`Alphanumeric`,e[e.Byte=4]=`Byte`,e[e.Kanji=8]=`Kanji`,e[e.ECI=7]=`ECI`})(o||={});function s(e,t){for(var n=[],r=``,i=[10,12,14][t],a=e.readBits(i);a>=3;){var o=e.readBits(10);if(o>=1e3)throw Error(`Invalid numeric value above 999`);var s=Math.floor(o/100),c=Math.floor(o/10)%10,l=o%10;n.push(48+s,48+c,48+l),r+=s.toString()+c.toString()+l.toString(),a-=3}if(a===2){var o=e.readBits(7);if(o>=100)throw Error(`Invalid numeric value above 99`);var s=Math.floor(o/10),c=o%10;n.push(48+s,48+c),r+=s.toString()+c.toString()}else if(a===1){var o=e.readBits(4);if(o>=10)throw Error(`Invalid numeric value above 9`);n.push(48+o),r+=o.toString()}return{bytes:n,text:r}}var c=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function l(e,t){for(var n=[],r=``,i=[9,11,13][t],a=e.readBits(i);a>=2;){var o=e.readBits(11),s=Math.floor(o/45),l=o%45;n.push(c[s].charCodeAt(0),c[l].charCodeAt(0)),r+=c[s]+c[l],a-=2}if(a===1){var s=e.readBits(6);n.push(c[s].charCodeAt(0)),r+=c[s]}return{bytes:n,text:r}}function u(e,t){for(var n=[],r=``,i=[8,16,16][t],a=e.readBits(i),o=0;o<a;o++){var s=e.readBits(8);n.push(s)}try{r+=decodeURIComponent(n.map(function(e){return`%`+(`0`+e.toString(16)).substr(-2)}).join(``))}catch{}return{bytes:n,text:r}}function d(e,t){for(var n=[],r=``,a=[8,10,12][t],o=e.readBits(a),s=0;s<o;s++){var c=e.readBits(13),l=Math.floor(c/192)<<8|c%192;l<7936?l+=33088:l+=49472,n.push(l>>8,l&255),r+=String.fromCharCode(i.shiftJISTable[l])}return{bytes:n,text:r}}function f(e,t){for(var n,i,c,f,p=new r.BitStream(e),m=t<=9?0:t<=26?1:2,h={text:``,bytes:[],chunks:[],version:t};p.available()>=4;){var g=p.readBits(4);if(g===o.Terminator)return h;if(g===o.ECI)p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(7)}):p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(14)}):p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(21)}):h.chunks.push({type:a.ECI,assignmentNumber:-1});else if(g===o.Numeric){var _=s(p,m);h.text+=_.text,(n=h.bytes).push.apply(n,_.bytes),h.chunks.push({type:a.Numeric,text:_.text})}else if(g===o.Alphanumeric){var v=l(p,m);h.text+=v.text,(i=h.bytes).push.apply(i,v.bytes),h.chunks.push({type:a.Alphanumeric,text:v.text})}else if(g===o.Byte){var y=u(p,m);h.text+=y.text,(c=h.bytes).push.apply(c,y.bytes),h.chunks.push({type:a.Byte,bytes:y.bytes,text:y.text})}else if(g===o.Kanji){var b=d(p,m);h.text+=b.text,(f=h.bytes).push.apply(f,b.bytes),h.chunks.push({type:a.Kanji,bytes:b.bytes,text:b.text})}}if(p.available()===0||p.readBits(p.available())===0)return h}t.decode=f}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitStream=function(){function e(e){this.byteOffset=0,this.bitOffset=0,this.bytes=e}return e.prototype.readBits=function(e){if(e<1||e>32||e>this.available())throw Error(`Cannot read `+e.toString()+` bits`);var t=0;if(this.bitOffset>0){var n=8-this.bitOffset,r=e<n?e:n,i=n-r,a=255>>8-r<<i;t=(this.bytes[this.byteOffset]&a)>>i,e-=r,this.bitOffset+=r,this.bitOffset===8&&(this.bitOffset=0,this.byteOffset++)}if(e>0){for(;e>=8;)t=t<<8|this.bytes[this.byteOffset]&255,this.byteOffset++,e-=8;if(e>0){var i=8-e,a=255>>i<<i;t=t<<e|(this.bytes[this.byteOffset]&a)>>i,this.bitOffset+=e}}return t},e.prototype.available=function(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.shiftJISTable={32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,47:47,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,58:58,59:59,60:60,61:61,62:62,63:63,64:64,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,91:91,92:165,93:93,94:94,95:95,96:96,97:97,98:98,99:99,100:100,101:101,102:102,103:103,104:104,105:105,106:106,107:107,108:108,109:109,110:110,111:111,112:112,113:113,114:114,115:115,116:116,117:117,118:118,119:119,120:120,121:121,122:122,123:123,124:124,125:125,126:8254,33088:12288,33089:12289,33090:12290,33091:65292,33092:65294,33093:12539,33094:65306,33095:65307,33096:65311,33097:65281,33098:12443,33099:12444,33100:180,33101:65344,33102:168,33103:65342,33104:65507,33105:65343,33106:12541,33107:12542,33108:12445,33109:12446,33110:12291,33111:20189,33112:12293,33113:12294,33114:12295,33115:12540,33116:8213,33117:8208,33118:65295,33119:92,33120:12316,33121:8214,33122:65372,33123:8230,33124:8229,33125:8216,33126:8217,33127:8220,33128:8221,33129:65288,33130:65289,33131:12308,33132:12309,33133:65339,33134:65341,33135:65371,33136:65373,33137:12296,33138:12297,33139:12298,33140:12299,33141:12300,33142:12301,33143:12302,33144:12303,33145:12304,33146:12305,33147:65291,33148:8722,33149:177,33150:215,33152:247,33153:65309,33154:8800,33155:65308,33156:65310,33157:8806,33158:8807,33159:8734,33160:8756,33161:9794,33162:9792,33163:176,33164:8242,33165:8243,33166:8451,33167:65509,33168:65284,33169:162,33170:163,33171:65285,33172:65283,33173:65286,33174:65290,33175:65312,33176:167,33177:9734,33178:9733,33179:9675,33180:9679,33181:9678,33182:9671,33183:9670,33184:9633,33185:9632,33186:9651,33187:9650,33188:9661,33189:9660,33190:8251,33191:12306,33192:8594,33193:8592,33194:8593,33195:8595,33196:12307,33208:8712,33209:8715,33210:8838,33211:8839,33212:8834,33213:8835,33214:8746,33215:8745,33224:8743,33225:8744,33226:172,33227:8658,33228:8660,33229:8704,33230:8707,33242:8736,33243:8869,33244:8978,33245:8706,33246:8711,33247:8801,33248:8786,33249:8810,33250:8811,33251:8730,33252:8765,33253:8733,33254:8757,33255:8747,33256:8748,33264:8491,33265:8240,33266:9839,33267:9837,33268:9834,33269:8224,33270:8225,33271:182,33276:9711,33359:65296,33360:65297,33361:65298,33362:65299,33363:65300,33364:65301,33365:65302,33366:65303,33367:65304,33368:65305,33376:65313,33377:65314,33378:65315,33379:65316,33380:65317,33381:65318,33382:65319,33383:65320,33384:65321,33385:65322,33386:65323,33387:65324,33388:65325,33389:65326,33390:65327,33391:65328,33392:65329,33393:65330,33394:65331,33395:65332,33396:65333,33397:65334,33398:65335,33399:65336,33400:65337,33401:65338,33409:65345,33410:65346,33411:65347,33412:65348,33413:65349,33414:65350,33415:65351,33416:65352,33417:65353,33418:65354,33419:65355,33420:65356,33421:65357,33422:65358,33423:65359,33424:65360,33425:65361,33426:65362,33427:65363,33428:65364,33429:65365,33430:65366,33431:65367,33432:65368,33433:65369,33434:65370,33439:12353,33440:12354,33441:12355,33442:12356,33443:12357,33444:12358,33445:12359,33446:12360,33447:12361,33448:12362,33449:12363,33450:12364,33451:12365,33452:12366,33453:12367,33454:12368,33455:12369,33456:12370,33457:12371,33458:12372,33459:12373,33460:12374,33461:12375,33462:12376,33463:12377,33464:12378,33465:12379,33466:12380,33467:12381,33468:12382,33469:12383,33470:12384,33471:12385,33472:12386,33473:12387,33474:12388,33475:12389,33476:12390,33477:12391,33478:12392,33479:12393,33480:12394,33481:12395,33482:12396,33483:12397,33484:12398,33485:12399,33486:12400,33487:12401,33488:12402,33489:12403,33490:12404,33491:12405,33492:12406,33493:12407,33494:12408,33495:12409,33496:12410,33497:12411,33498:12412,33499:12413,33500:12414,33501:12415,33502:12416,33503:12417,33504:12418,33505:12419,33506:12420,33507:12421,33508:12422,33509:12423,33510:12424,33511:12425,33512:12426,33513:12427,33514:12428,33515:12429,33516:12430,33517:12431,33518:12432,33519:12433,33520:12434,33521:12435,33600:12449,33601:12450,33602:12451,33603:12452,33604:12453,33605:12454,33606:12455,33607:12456,33608:12457,33609:12458,33610:12459,33611:12460,33612:12461,33613:12462,33614:12463,33615:12464,33616:12465,33617:12466,33618:12467,33619:12468,33620:12469,33621:12470,33622:12471,33623:12472,33624:12473,33625:12474,33626:12475,33627:12476,33628:12477,33629:12478,33630:12479,33631:12480,33632:12481,33633:12482,33634:12483,33635:12484,33636:12485,33637:12486,33638:12487,33639:12488,33640:12489,33641:12490,33642:12491,33643:12492,33644:12493,33645:12494,33646:12495,33647:12496,33648:12497,33649:12498,33650:12499,33651:12500,33652:12501,33653:12502,33654:12503,33655:12504,33656:12505,33657:12506,33658:12507,33659:12508,33660:12509,33661:12510,33662:12511,33664:12512,33665:12513,33666:12514,33667:12515,33668:12516,33669:12517,33670:12518,33671:12519,33672:12520,33673:12521,33674:12522,33675:12523,33676:12524,33677:12525,33678:12526,33679:12527,33680:12528,33681:12529,33682:12530,33683:12531,33684:12532,33685:12533,33686:12534,33695:913,33696:914,33697:915,33698:916,33699:917,33700:918,33701:919,33702:920,33703:921,33704:922,33705:923,33706:924,33707:925,33708:926,33709:927,33710:928,33711:929,33712:931,33713:932,33714:933,33715:934,33716:935,33717:936,33718:937,33727:945,33728:946,33729:947,33730:948,33731:949,33732:950,33733:951,33734:952,33735:953,33736:954,33737:955,33738:956,33739:957,33740:958,33741:959,33742:960,33743:961,33744:963,33745:964,33746:965,33747:966,33748:967,33749:968,33750:969,33856:1040,33857:1041,33858:1042,33859:1043,33860:1044,33861:1045,33862:1025,33863:1046,33864:1047,33865:1048,33866:1049,33867:1050,33868:1051,33869:1052,33870:1053,33871:1054,33872:1055,33873:1056,33874:1057,33875:1058,33876:1059,33877:1060,33878:1061,33879:1062,33880:1063,33881:1064,33882:1065,33883:1066,33884:1067,33885:1068,33886:1069,33887:1070,33888:1071,33904:1072,33905:1073,33906:1074,33907:1075,33908:1076,33909:1077,33910:1105,33911:1078,33912:1079,33913:1080,33914:1081,33915:1082,33916:1083,33917:1084,33918:1085,33920:1086,33921:1087,33922:1088,33923:1089,33924:1090,33925:1091,33926:1092,33927:1093,33928:1094,33929:1095,33930:1096,33931:1097,33932:1098,33933:1099,33934:1100,33935:1101,33936:1102,33937:1103,33951:9472,33952:9474,33953:9484,33954:9488,33955:9496,33956:9492,33957:9500,33958:9516,33959:9508,33960:9524,33961:9532,33962:9473,33963:9475,33964:9487,33965:9491,33966:9499,33967:9495,33968:9507,33969:9523,33970:9515,33971:9531,33972:9547,33973:9504,33974:9519,33975:9512,33976:9527,33977:9535,33978:9501,33979:9520,33980:9509,33981:9528,33982:9538,34975:20124,34976:21782,34977:23043,34978:38463,34979:21696,34980:24859,34981:25384,34982:23030,34983:36898,34984:33909,34985:33564,34986:31312,34987:24746,34988:25569,34989:28197,34990:26093,34991:33894,34992:33446,34993:39925,34994:26771,34995:22311,34996:26017,34997:25201,34998:23451,34999:22992,35e3:34427,35001:39156,35002:32098,35003:32190,35004:39822,35005:25110,35006:31903,35007:34999,35008:23433,35009:24245,35010:25353,35011:26263,35012:26696,35013:38343,35014:38797,35015:26447,35016:20197,35017:20234,35018:20301,35019:20381,35020:20553,35021:22258,35022:22839,35023:22996,35024:23041,35025:23561,35026:24799,35027:24847,35028:24944,35029:26131,35030:26885,35031:28858,35032:30031,35033:30064,35034:31227,35035:32173,35036:32239,35037:32963,35038:33806,35039:34915,35040:35586,35041:36949,35042:36986,35043:21307,35044:20117,35045:20133,35046:22495,35047:32946,35048:37057,35049:30959,35050:19968,35051:22769,35052:28322,35053:36920,35054:31282,35055:33576,35056:33419,35057:39983,35058:20801,35059:21360,35060:21693,35061:21729,35062:22240,35063:23035,35064:24341,35065:39154,35066:28139,35067:32996,35068:34093,35136:38498,35137:38512,35138:38560,35139:38907,35140:21515,35141:21491,35142:23431,35143:28879,35144:32701,35145:36802,35146:38632,35147:21359,35148:40284,35149:31418,35150:19985,35151:30867,35152:33276,35153:28198,35154:22040,35155:21764,35156:27421,35157:34074,35158:39995,35159:23013,35160:21417,35161:28006,35162:29916,35163:38287,35164:22082,35165:20113,35166:36939,35167:38642,35168:33615,35169:39180,35170:21473,35171:21942,35172:23344,35173:24433,35174:26144,35175:26355,35176:26628,35177:27704,35178:27891,35179:27945,35180:29787,35181:30408,35182:31310,35183:38964,35184:33521,35185:34907,35186:35424,35187:37613,35188:28082,35189:30123,35190:30410,35191:39365,35192:24742,35193:35585,35194:36234,35195:38322,35196:27022,35197:21421,35198:20870,35200:22290,35201:22576,35202:22852,35203:23476,35204:24310,35205:24616,35206:25513,35207:25588,35208:27839,35209:28436,35210:28814,35211:28948,35212:29017,35213:29141,35214:29503,35215:32257,35216:33398,35217:33489,35218:34199,35219:36960,35220:37467,35221:40219,35222:22633,35223:26044,35224:27738,35225:29989,35226:20985,35227:22830,35228:22885,35229:24448,35230:24540,35231:25276,35232:26106,35233:27178,35234:27431,35235:27572,35236:29579,35237:32705,35238:35158,35239:40236,35240:40206,35241:40644,35242:23713,35243:27798,35244:33659,35245:20740,35246:23627,35247:25014,35248:33222,35249:26742,35250:29281,35251:20057,35252:20474,35253:21368,35254:24681,35255:28201,35256:31311,35257:38899,35258:19979,35259:21270,35260:20206,35261:20309,35262:20285,35263:20385,35264:20339,35265:21152,35266:21487,35267:22025,35268:22799,35269:23233,35270:23478,35271:23521,35272:31185,35273:26247,35274:26524,35275:26550,35276:27468,35277:27827,35278:28779,35279:29634,35280:31117,35281:31166,35282:31292,35283:31623,35284:33457,35285:33499,35286:33540,35287:33655,35288:33775,35289:33747,35290:34662,35291:35506,35292:22057,35293:36008,35294:36838,35295:36942,35296:38686,35297:34442,35298:20420,35299:23784,35300:25105,35301:29273,35302:30011,35303:33253,35304:33469,35305:34558,35306:36032,35307:38597,35308:39187,35309:39381,35310:20171,35311:20250,35312:35299,35313:22238,35314:22602,35315:22730,35316:24315,35317:24555,35318:24618,35319:24724,35320:24674,35321:25040,35322:25106,35323:25296,35324:25913,35392:39745,35393:26214,35394:26800,35395:28023,35396:28784,35397:30028,35398:30342,35399:32117,35400:33445,35401:34809,35402:38283,35403:38542,35404:35997,35405:20977,35406:21182,35407:22806,35408:21683,35409:23475,35410:23830,35411:24936,35412:27010,35413:28079,35414:30861,35415:33995,35416:34903,35417:35442,35418:37799,35419:39608,35420:28012,35421:39336,35422:34521,35423:22435,35424:26623,35425:34510,35426:37390,35427:21123,35428:22151,35429:21508,35430:24275,35431:25313,35432:25785,35433:26684,35434:26680,35435:27579,35436:29554,35437:30906,35438:31339,35439:35226,35440:35282,35441:36203,35442:36611,35443:37101,35444:38307,35445:38548,35446:38761,35447:23398,35448:23731,35449:27005,35450:38989,35451:38990,35452:25499,35453:31520,35454:27179,35456:27263,35457:26806,35458:39949,35459:28511,35460:21106,35461:21917,35462:24688,35463:25324,35464:27963,35465:28167,35466:28369,35467:33883,35468:35088,35469:36676,35470:19988,35471:39993,35472:21494,35473:26907,35474:27194,35475:38788,35476:26666,35477:20828,35478:31427,35479:33970,35480:37340,35481:37772,35482:22107,35483:40232,35484:26658,35485:33541,35486:33841,35487:31909,35488:21e3,35489:33477,35490:29926,35491:20094,35492:20355,35493:20896,35494:23506,35495:21002,35496:21208,35497:21223,35498:24059,35499:21914,35500:22570,35501:23014,35502:23436,35503:23448,35504:23515,35505:24178,35506:24185,35507:24739,35508:24863,35509:24931,35510:25022,35511:25563,35512:25954,35513:26577,35514:26707,35515:26874,35516:27454,35517:27475,35518:27735,35519:28450,35520:28567,35521:28485,35522:29872,35523:29976,35524:30435,35525:30475,35526:31487,35527:31649,35528:31777,35529:32233,35530:32566,35531:32752,35532:32925,35533:33382,35534:33694,35535:35251,35536:35532,35537:36011,35538:36996,35539:37969,35540:38291,35541:38289,35542:38306,35543:38501,35544:38867,35545:39208,35546:33304,35547:20024,35548:21547,35549:23736,35550:24012,35551:29609,35552:30284,35553:30524,35554:23721,35555:32747,35556:36107,35557:38593,35558:38929,35559:38996,35560:39e3,35561:20225,35562:20238,35563:21361,35564:21916,35565:22120,35566:22522,35567:22855,35568:23305,35569:23492,35570:23696,35571:24076,35572:24190,35573:24524,35574:25582,35575:26426,35576:26071,35577:26082,35578:26399,35579:26827,35580:26820,35648:27231,35649:24112,35650:27589,35651:27671,35652:27773,35653:30079,35654:31048,35655:23395,35656:31232,35657:32e3,35658:24509,35659:35215,35660:35352,35661:36020,35662:36215,35663:36556,35664:36637,35665:39138,35666:39438,35667:39740,35668:20096,35669:20605,35670:20736,35671:22931,35672:23452,35673:25135,35674:25216,35675:25836,35676:27450,35677:29344,35678:30097,35679:31047,35680:32681,35681:34811,35682:35516,35683:35696,35684:25516,35685:33738,35686:38816,35687:21513,35688:21507,35689:21931,35690:26708,35691:27224,35692:35440,35693:30759,35694:26485,35695:40653,35696:21364,35697:23458,35698:33050,35699:34384,35700:36870,35701:19992,35702:20037,35703:20167,35704:20241,35705:21450,35706:21560,35707:23470,35708:24339,35709:24613,35710:25937,35712:26429,35713:27714,35714:27762,35715:27875,35716:28792,35717:29699,35718:31350,35719:31406,35720:31496,35721:32026,35722:31998,35723:32102,35724:26087,35725:29275,35726:21435,35727:23621,35728:24040,35729:25298,35730:25312,35731:25369,35732:28192,35733:34394,35734:35377,35735:36317,35736:37624,35737:28417,35738:31142,35739:39770,35740:20136,35741:20139,35742:20140,35743:20379,35744:20384,35745:20689,35746:20807,35747:31478,35748:20849,35749:20982,35750:21332,35751:21281,35752:21375,35753:21483,35754:21932,35755:22659,35756:23777,35757:24375,35758:24394,35759:24623,35760:24656,35761:24685,35762:25375,35763:25945,35764:27211,35765:27841,35766:29378,35767:29421,35768:30703,35769:33016,35770:33029,35771:33288,35772:34126,35773:37111,35774:37857,35775:38911,35776:39255,35777:39514,35778:20208,35779:20957,35780:23597,35781:26241,35782:26989,35783:23616,35784:26354,35785:26997,35786:29577,35787:26704,35788:31873,35789:20677,35790:21220,35791:22343,35792:24062,35793:37670,35794:26020,35795:27427,35796:27453,35797:29748,35798:31105,35799:31165,35800:31563,35801:32202,35802:33465,35803:33740,35804:34943,35805:35167,35806:35641,35807:36817,35808:37329,35809:21535,35810:37504,35811:20061,35812:20534,35813:21477,35814:21306,35815:29399,35816:29590,35817:30697,35818:33510,35819:36527,35820:39366,35821:39368,35822:39378,35823:20855,35824:24858,35825:34398,35826:21936,35827:31354,35828:20598,35829:23507,35830:36935,35831:38533,35832:20018,35833:27355,35834:37351,35835:23633,35836:23624,35904:25496,35905:31391,35906:27795,35907:38772,35908:36705,35909:31402,35910:29066,35911:38536,35912:31874,35913:26647,35914:32368,35915:26705,35916:37740,35917:21234,35918:21531,35919:34219,35920:35347,35921:32676,35922:36557,35923:37089,35924:21350,35925:34952,35926:31041,35927:20418,35928:20670,35929:21009,35930:20804,35931:21843,35932:22317,35933:29674,35934:22411,35935:22865,35936:24418,35937:24452,35938:24693,35939:24950,35940:24935,35941:25001,35942:25522,35943:25658,35944:25964,35945:26223,35946:26690,35947:28179,35948:30054,35949:31293,35950:31995,35951:32076,35952:32153,35953:32331,35954:32619,35955:33550,35956:33610,35957:34509,35958:35336,35959:35427,35960:35686,35961:36605,35962:38938,35963:40335,35964:33464,35965:36814,35966:39912,35968:21127,35969:25119,35970:25731,35971:28608,35972:38553,35973:26689,35974:20625,35975:27424,35976:27770,35977:28500,35978:31348,35979:32080,35980:34880,35981:35363,35982:26376,35983:20214,35984:20537,35985:20518,35986:20581,35987:20860,35988:21048,35989:21091,35990:21927,35991:22287,35992:22533,35993:23244,35994:24314,35995:25010,35996:25080,35997:25331,35998:25458,35999:26908,36e3:27177,36001:29309,36002:29356,36003:29486,36004:30740,36005:30831,36006:32121,36007:30476,36008:32937,36009:35211,36010:35609,36011:36066,36012:36562,36013:36963,36014:37749,36015:38522,36016:38997,36017:39443,36018:40568,36019:20803,36020:21407,36021:21427,36022:24187,36023:24358,36024:28187,36025:28304,36026:29572,36027:29694,36028:32067,36029:33335,36030:35328,36031:35578,36032:38480,36033:20046,36034:20491,36035:21476,36036:21628,36037:22266,36038:22993,36039:23396,36040:24049,36041:24235,36042:24359,36043:25144,36044:25925,36045:26543,36046:28246,36047:29392,36048:31946,36049:34996,36050:32929,36051:32993,36052:33776,36053:34382,36054:35463,36055:36328,36056:37431,36057:38599,36058:39015,36059:40723,36060:20116,36061:20114,36062:20237,36063:21320,36064:21577,36065:21566,36066:23087,36067:24460,36068:24481,36069:24735,36070:26791,36071:27278,36072:29786,36073:30849,36074:35486,36075:35492,36076:35703,36077:37264,36078:20062,36079:39881,36080:20132,36081:20348,36082:20399,36083:20505,36084:20502,36085:20809,36086:20844,36087:21151,36088:21177,36089:21246,36090:21402,36091:21475,36092:21521,36160:21518,36161:21897,36162:22353,36163:22434,36164:22909,36165:23380,36166:23389,36167:23439,36168:24037,36169:24039,36170:24055,36171:24184,36172:24195,36173:24218,36174:24247,36175:24344,36176:24658,36177:24908,36178:25239,36179:25304,36180:25511,36181:25915,36182:26114,36183:26179,36184:26356,36185:26477,36186:26657,36187:26775,36188:27083,36189:27743,36190:27946,36191:28009,36192:28207,36193:28317,36194:30002,36195:30343,36196:30828,36197:31295,36198:31968,36199:32005,36200:32024,36201:32094,36202:32177,36203:32789,36204:32771,36205:32943,36206:32945,36207:33108,36208:33167,36209:33322,36210:33618,36211:34892,36212:34913,36213:35611,36214:36002,36215:36092,36216:37066,36217:37237,36218:37489,36219:30783,36220:37628,36221:38308,36222:38477,36224:38917,36225:39321,36226:39640,36227:40251,36228:21083,36229:21163,36230:21495,36231:21512,36232:22741,36233:25335,36234:28640,36235:35946,36236:36703,36237:40633,36238:20811,36239:21051,36240:21578,36241:22269,36242:31296,36243:37239,36244:40288,36245:40658,36246:29508,36247:28425,36248:33136,36249:29969,36250:24573,36251:24794,36252:39592,36253:29403,36254:36796,36255:27492,36256:38915,36257:20170,36258:22256,36259:22372,36260:22718,36261:23130,36262:24680,36263:25031,36264:26127,36265:26118,36266:26681,36267:26801,36268:28151,36269:30165,36270:32058,36271:33390,36272:39746,36273:20123,36274:20304,36275:21449,36276:21766,36277:23919,36278:24038,36279:24046,36280:26619,36281:27801,36282:29811,36283:30722,36284:35408,36285:37782,36286:35039,36287:22352,36288:24231,36289:25387,36290:20661,36291:20652,36292:20877,36293:26368,36294:21705,36295:22622,36296:22971,36297:23472,36298:24425,36299:25165,36300:25505,36301:26685,36302:27507,36303:28168,36304:28797,36305:37319,36306:29312,36307:30741,36308:30758,36309:31085,36310:25998,36311:32048,36312:33756,36313:35009,36314:36617,36315:38555,36316:21092,36317:22312,36318:26448,36319:32618,36320:36001,36321:20916,36322:22338,36323:38442,36324:22586,36325:27018,36326:32948,36327:21682,36328:23822,36329:22524,36330:30869,36331:40442,36332:20316,36333:21066,36334:21643,36335:25662,36336:26152,36337:26388,36338:26613,36339:31364,36340:31574,36341:32034,36342:37679,36343:26716,36344:39853,36345:31545,36346:21273,36347:20874,36348:21047,36416:23519,36417:25334,36418:25774,36419:25830,36420:26413,36421:27578,36422:34217,36423:38609,36424:30352,36425:39894,36426:25420,36427:37638,36428:39851,36429:30399,36430:26194,36431:19977,36432:20632,36433:21442,36434:23665,36435:24808,36436:25746,36437:25955,36438:26719,36439:29158,36440:29642,36441:29987,36442:31639,36443:32386,36444:34453,36445:35715,36446:36059,36447:37240,36448:39184,36449:26028,36450:26283,36451:27531,36452:20181,36453:20180,36454:20282,36455:20351,36456:21050,36457:21496,36458:21490,36459:21987,36460:22235,36461:22763,36462:22987,36463:22985,36464:23039,36465:23376,36466:23629,36467:24066,36468:24107,36469:24535,36470:24605,36471:25351,36472:25903,36473:23388,36474:26031,36475:26045,36476:26088,36477:26525,36478:27490,36480:27515,36481:27663,36482:29509,36483:31049,36484:31169,36485:31992,36486:32025,36487:32043,36488:32930,36489:33026,36490:33267,36491:35222,36492:35422,36493:35433,36494:35430,36495:35468,36496:35566,36497:36039,36498:36060,36499:38604,36500:39164,36501:27503,36502:20107,36503:20284,36504:20365,36505:20816,36506:23383,36507:23546,36508:24904,36509:25345,36510:26178,36511:27425,36512:28363,36513:27835,36514:29246,36515:29885,36516:30164,36517:30913,36518:31034,36519:32780,36520:32819,36521:33258,36522:33940,36523:36766,36524:27728,36525:40575,36526:24335,36527:35672,36528:40235,36529:31482,36530:36600,36531:23437,36532:38635,36533:19971,36534:21489,36535:22519,36536:22833,36537:23241,36538:23460,36539:24713,36540:28287,36541:28422,36542:30142,36543:36074,36544:23455,36545:34048,36546:31712,36547:20594,36548:26612,36549:33437,36550:23649,36551:34122,36552:32286,36553:33294,36554:20889,36555:23556,36556:25448,36557:36198,36558:26012,36559:29038,36560:31038,36561:32023,36562:32773,36563:35613,36564:36554,36565:36974,36566:34503,36567:37034,36568:20511,36569:21242,36570:23610,36571:26451,36572:28796,36573:29237,36574:37196,36575:37320,36576:37675,36577:33509,36578:23490,36579:24369,36580:24825,36581:20027,36582:21462,36583:23432,36584:25163,36585:26417,36586:27530,36587:29417,36588:29664,36589:31278,36590:33131,36591:36259,36592:37202,36593:39318,36594:20754,36595:21463,36596:21610,36597:23551,36598:25480,36599:27193,36600:32172,36601:38656,36602:22234,36603:21454,36604:21608,36672:23447,36673:23601,36674:24030,36675:20462,36676:24833,36677:25342,36678:27954,36679:31168,36680:31179,36681:32066,36682:32333,36683:32722,36684:33261,36685:33311,36686:33936,36687:34886,36688:35186,36689:35728,36690:36468,36691:36655,36692:36913,36693:37195,36694:37228,36695:38598,36696:37276,36697:20160,36698:20303,36699:20805,36700:21313,36701:24467,36702:25102,36703:26580,36704:27713,36705:28171,36706:29539,36707:32294,36708:37325,36709:37507,36710:21460,36711:22809,36712:23487,36713:28113,36714:31069,36715:32302,36716:31899,36717:22654,36718:29087,36719:20986,36720:34899,36721:36848,36722:20426,36723:23803,36724:26149,36725:30636,36726:31459,36727:33308,36728:39423,36729:20934,36730:24490,36731:26092,36732:26991,36733:27529,36734:28147,36736:28310,36737:28516,36738:30462,36739:32020,36740:24033,36741:36981,36742:37255,36743:38918,36744:20966,36745:21021,36746:25152,36747:26257,36748:26329,36749:28186,36750:24246,36751:32210,36752:32626,36753:26360,36754:34223,36755:34295,36756:35576,36757:21161,36758:21465,36759:22899,36760:24207,36761:24464,36762:24661,36763:37604,36764:38500,36765:20663,36766:20767,36767:21213,36768:21280,36769:21319,36770:21484,36771:21736,36772:21830,36773:21809,36774:22039,36775:22888,36776:22974,36777:23100,36778:23477,36779:23558,36780:23567,36781:23569,36782:23578,36783:24196,36784:24202,36785:24288,36786:24432,36787:25215,36788:25220,36789:25307,36790:25484,36791:25463,36792:26119,36793:26124,36794:26157,36795:26230,36796:26494,36797:26786,36798:27167,36799:27189,36800:27836,36801:28040,36802:28169,36803:28248,36804:28988,36805:28966,36806:29031,36807:30151,36808:30465,36809:30813,36810:30977,36811:31077,36812:31216,36813:31456,36814:31505,36815:31911,36816:32057,36817:32918,36818:33750,36819:33931,36820:34121,36821:34909,36822:35059,36823:35359,36824:35388,36825:35412,36826:35443,36827:35937,36828:36062,36829:37284,36830:37478,36831:37758,36832:37912,36833:38556,36834:38808,36835:19978,36836:19976,36837:19998,36838:20055,36839:20887,36840:21104,36841:22478,36842:22580,36843:22732,36844:23330,36845:24120,36846:24773,36847:25854,36848:26465,36849:26454,36850:27972,36851:29366,36852:30067,36853:31331,36854:33976,36855:35698,36856:37304,36857:37664,36858:22065,36859:22516,36860:39166,36928:25325,36929:26893,36930:27542,36931:29165,36932:32340,36933:32887,36934:33394,36935:35302,36936:39135,36937:34645,36938:36785,36939:23611,36940:20280,36941:20449,36942:20405,36943:21767,36944:23072,36945:23517,36946:23529,36947:24515,36948:24910,36949:25391,36950:26032,36951:26187,36952:26862,36953:27035,36954:28024,36955:28145,36956:30003,36957:30137,36958:30495,36959:31070,36960:31206,36961:32051,36962:33251,36963:33455,36964:34218,36965:35242,36966:35386,36967:36523,36968:36763,36969:36914,36970:37341,36971:38663,36972:20154,36973:20161,36974:20995,36975:22645,36976:22764,36977:23563,36978:29978,36979:23613,36980:33102,36981:35338,36982:36805,36983:38499,36984:38765,36985:31525,36986:35535,36987:38920,36988:37218,36989:22259,36990:21416,36992:36887,36993:21561,36994:22402,36995:24101,36996:25512,36997:27700,36998:28810,36999:30561,37e3:31883,37001:32736,37002:34928,37003:36930,37004:37204,37005:37648,37006:37656,37007:38543,37008:29790,37009:39620,37010:23815,37011:23913,37012:25968,37013:26530,37014:36264,37015:38619,37016:25454,37017:26441,37018:26905,37019:33733,37020:38935,37021:38592,37022:35070,37023:28548,37024:25722,37025:23544,37026:19990,37027:28716,37028:30045,37029:26159,37030:20932,37031:21046,37032:21218,37033:22995,37034:24449,37035:24615,37036:25104,37037:25919,37038:25972,37039:26143,37040:26228,37041:26866,37042:26646,37043:27491,37044:28165,37045:29298,37046:29983,37047:30427,37048:31934,37049:32854,37050:22768,37051:35069,37052:35199,37053:35488,37054:35475,37055:35531,37056:36893,37057:37266,37058:38738,37059:38745,37060:25993,37061:31246,37062:33030,37063:38587,37064:24109,37065:24796,37066:25114,37067:26021,37068:26132,37069:26512,37070:30707,37071:31309,37072:31821,37073:32318,37074:33034,37075:36012,37076:36196,37077:36321,37078:36447,37079:30889,37080:20999,37081:25305,37082:25509,37083:25666,37084:25240,37085:35373,37086:31363,37087:31680,37088:35500,37089:38634,37090:32118,37091:33292,37092:34633,37093:20185,37094:20808,37095:21315,37096:21344,37097:23459,37098:23554,37099:23574,37100:24029,37101:25126,37102:25159,37103:25776,37104:26643,37105:26676,37106:27849,37107:27973,37108:27927,37109:26579,37110:28508,37111:29006,37112:29053,37113:26059,37114:31359,37115:31661,37116:32218,37184:32330,37185:32680,37186:33146,37187:33307,37188:33337,37189:34214,37190:35438,37191:36046,37192:36341,37193:36984,37194:36983,37195:37549,37196:37521,37197:38275,37198:39854,37199:21069,37200:21892,37201:28472,37202:28982,37203:20840,37204:31109,37205:32341,37206:33203,37207:31950,37208:22092,37209:22609,37210:23720,37211:25514,37212:26366,37213:26365,37214:26970,37215:29401,37216:30095,37217:30094,37218:30990,37219:31062,37220:31199,37221:31895,37222:32032,37223:32068,37224:34311,37225:35380,37226:38459,37227:36961,37228:40736,37229:20711,37230:21109,37231:21452,37232:21474,37233:20489,37234:21930,37235:22766,37236:22863,37237:29245,37238:23435,37239:23652,37240:21277,37241:24803,37242:24819,37243:25436,37244:25475,37245:25407,37246:25531,37248:25805,37249:26089,37250:26361,37251:24035,37252:27085,37253:27133,37254:28437,37255:29157,37256:20105,37257:30185,37258:30456,37259:31379,37260:31967,37261:32207,37262:32156,37263:32865,37264:33609,37265:33624,37266:33900,37267:33980,37268:34299,37269:35013,37270:36208,37271:36865,37272:36973,37273:37783,37274:38684,37275:39442,37276:20687,37277:22679,37278:24974,37279:33235,37280:34101,37281:36104,37282:36896,37283:20419,37284:20596,37285:21063,37286:21363,37287:24687,37288:25417,37289:26463,37290:28204,37291:36275,37292:36895,37293:20439,37294:23646,37295:36042,37296:26063,37297:32154,37298:21330,37299:34966,37300:20854,37301:25539,37302:23384,37303:23403,37304:23562,37305:25613,37306:26449,37307:36956,37308:20182,37309:22810,37310:22826,37311:27760,37312:35409,37313:21822,37314:22549,37315:22949,37316:24816,37317:25171,37318:26561,37319:33333,37320:26965,37321:38464,37322:39364,37323:39464,37324:20307,37325:22534,37326:23550,37327:32784,37328:23729,37329:24111,37330:24453,37331:24608,37332:24907,37333:25140,37334:26367,37335:27888,37336:28382,37337:32974,37338:33151,37339:33492,37340:34955,37341:36024,37342:36864,37343:36910,37344:38538,37345:40667,37346:39899,37347:20195,37348:21488,37349:22823,37350:31532,37351:37261,37352:38988,37353:40441,37354:28381,37355:28711,37356:21331,37357:21828,37358:23429,37359:25176,37360:25246,37361:25299,37362:27810,37363:28655,37364:29730,37365:35351,37366:37944,37367:28609,37368:35582,37369:33592,37370:20967,37371:34552,37372:21482,37440:21481,37441:20294,37442:36948,37443:36784,37444:22890,37445:33073,37446:24061,37447:31466,37448:36799,37449:26842,37450:35895,37451:29432,37452:40008,37453:27197,37454:35504,37455:20025,37456:21336,37457:22022,37458:22374,37459:25285,37460:25506,37461:26086,37462:27470,37463:28129,37464:28251,37465:28845,37466:30701,37467:31471,37468:31658,37469:32187,37470:32829,37471:32966,37472:34507,37473:35477,37474:37723,37475:22243,37476:22727,37477:24382,37478:26029,37479:26262,37480:27264,37481:27573,37482:30007,37483:35527,37484:20516,37485:30693,37486:22320,37487:24347,37488:24677,37489:26234,37490:27744,37491:30196,37492:31258,37493:32622,37494:33268,37495:34584,37496:36933,37497:39347,37498:31689,37499:30044,37500:31481,37501:31569,37502:33988,37504:36880,37505:31209,37506:31378,37507:33590,37508:23265,37509:30528,37510:20013,37511:20210,37512:23449,37513:24544,37514:25277,37515:26172,37516:26609,37517:27880,37518:34411,37519:34935,37520:35387,37521:37198,37522:37619,37523:39376,37524:27159,37525:28710,37526:29482,37527:33511,37528:33879,37529:36015,37530:19969,37531:20806,37532:20939,37533:21899,37534:23541,37535:24086,37536:24115,37537:24193,37538:24340,37539:24373,37540:24427,37541:24500,37542:25074,37543:25361,37544:26274,37545:26397,37546:28526,37547:29266,37548:30010,37549:30522,37550:32884,37551:33081,37552:33144,37553:34678,37554:35519,37555:35548,37556:36229,37557:36339,37558:37530,37559:38263,37560:38914,37561:40165,37562:21189,37563:25431,37564:30452,37565:26389,37566:27784,37567:29645,37568:36035,37569:37806,37570:38515,37571:27941,37572:22684,37573:26894,37574:27084,37575:36861,37576:37786,37577:30171,37578:36890,37579:22618,37580:26626,37581:25524,37582:27131,37583:20291,37584:28460,37585:26584,37586:36795,37587:34086,37588:32180,37589:37716,37590:26943,37591:28528,37592:22378,37593:22775,37594:23340,37595:32044,37596:29226,37597:21514,37598:37347,37599:40372,37600:20141,37601:20302,37602:20572,37603:20597,37604:21059,37605:35998,37606:21576,37607:22564,37608:23450,37609:24093,37610:24213,37611:24237,37612:24311,37613:24351,37614:24716,37615:25269,37616:25402,37617:25552,37618:26799,37619:27712,37620:30855,37621:31118,37622:31243,37623:32224,37624:33351,37625:35330,37626:35558,37627:36420,37628:36883,37696:37048,37697:37165,37698:37336,37699:40718,37700:27877,37701:25688,37702:25826,37703:25973,37704:28404,37705:30340,37706:31515,37707:36969,37708:37841,37709:28346,37710:21746,37711:24505,37712:25764,37713:36685,37714:36845,37715:37444,37716:20856,37717:22635,37718:22825,37719:23637,37720:24215,37721:28155,37722:32399,37723:29980,37724:36028,37725:36578,37726:39003,37727:28857,37728:20253,37729:27583,37730:28593,37731:3e4,37732:38651,37733:20814,37734:21520,37735:22581,37736:22615,37737:22956,37738:23648,37739:24466,37740:26007,37741:26460,37742:28193,37743:30331,37744:33759,37745:36077,37746:36884,37747:37117,37748:37709,37749:30757,37750:30778,37751:21162,37752:24230,37753:22303,37754:22900,37755:24594,37756:20498,37757:20826,37758:20908,37760:20941,37761:20992,37762:21776,37763:22612,37764:22616,37765:22871,37766:23445,37767:23798,37768:23947,37769:24764,37770:25237,37771:25645,37772:26481,37773:26691,37774:26812,37775:26847,37776:30423,37777:28120,37778:28271,37779:28059,37780:28783,37781:29128,37782:24403,37783:30168,37784:31095,37785:31561,37786:31572,37787:31570,37788:31958,37789:32113,37790:21040,37791:33891,37792:34153,37793:34276,37794:35342,37795:35588,37796:35910,37797:36367,37798:36867,37799:36879,37800:37913,37801:38518,37802:38957,37803:39472,37804:38360,37805:20685,37806:21205,37807:21516,37808:22530,37809:23566,37810:24999,37811:25758,37812:27934,37813:30643,37814:31461,37815:33012,37816:33796,37817:36947,37818:37509,37819:23776,37820:40199,37821:21311,37822:24471,37823:24499,37824:28060,37825:29305,37826:30563,37827:31167,37828:31716,37829:27602,37830:29420,37831:35501,37832:26627,37833:27233,37834:20984,37835:31361,37836:26932,37837:23626,37838:40182,37839:33515,37840:23493,37841:37193,37842:28702,37843:22136,37844:23663,37845:24775,37846:25958,37847:27788,37848:35930,37849:36929,37850:38931,37851:21585,37852:26311,37853:37389,37854:22856,37855:37027,37856:20869,37857:20045,37858:20970,37859:34201,37860:35598,37861:28760,37862:25466,37863:37707,37864:26978,37865:39348,37866:32260,37867:30071,37868:21335,37869:26976,37870:36575,37871:38627,37872:27741,37873:20108,37874:23612,37875:24336,37876:36841,37877:21250,37878:36049,37879:32905,37880:34425,37881:24319,37882:26085,37883:20083,37884:20837,37952:22914,37953:23615,37954:38894,37955:20219,37956:22922,37957:24525,37958:35469,37959:28641,37960:31152,37961:31074,37962:23527,37963:33905,37964:29483,37965:29105,37966:24180,37967:24565,37968:25467,37969:25754,37970:29123,37971:31896,37972:20035,37973:24316,37974:20043,37975:22492,37976:22178,37977:24745,37978:28611,37979:32013,37980:33021,37981:33075,37982:33215,37983:36786,37984:35223,37985:34468,37986:24052,37987:25226,37988:25773,37989:35207,37990:26487,37991:27874,37992:27966,37993:29750,37994:30772,37995:23110,37996:32629,37997:33453,37998:39340,37999:20467,38e3:24259,38001:25309,38002:25490,38003:25943,38004:26479,38005:30403,38006:29260,38007:32972,38008:32954,38009:36649,38010:37197,38011:20493,38012:22521,38013:23186,38014:26757,38016:26995,38017:29028,38018:29437,38019:36023,38020:22770,38021:36064,38022:38506,38023:36889,38024:34687,38025:31204,38026:30695,38027:33833,38028:20271,38029:21093,38030:21338,38031:25293,38032:26575,38033:27850,38034:30333,38035:31636,38036:31893,38037:33334,38038:34180,38039:36843,38040:26333,38041:28448,38042:29190,38043:32283,38044:33707,38045:39361,38046:40614,38047:20989,38048:31665,38049:30834,38050:31672,38051:32903,38052:31560,38053:27368,38054:24161,38055:32908,38056:30033,38057:30048,38058:20843,38059:37474,38060:28300,38061:30330,38062:37271,38063:39658,38064:20240,38065:32624,38066:25244,38067:31567,38068:38309,38069:40169,38070:22138,38071:22617,38072:34532,38073:38588,38074:20276,38075:21028,38076:21322,38077:21453,38078:21467,38079:24070,38080:25644,38081:26001,38082:26495,38083:27710,38084:27726,38085:29256,38086:29359,38087:29677,38088:30036,38089:32321,38090:33324,38091:34281,38092:36009,38093:31684,38094:37318,38095:29033,38096:38930,38097:39151,38098:25405,38099:26217,38100:30058,38101:30436,38102:30928,38103:34115,38104:34542,38105:21290,38106:21329,38107:21542,38108:22915,38109:24199,38110:24444,38111:24754,38112:25161,38113:25209,38114:25259,38115:26e3,38116:27604,38117:27852,38118:30130,38119:30382,38120:30865,38121:31192,38122:32203,38123:32631,38124:32933,38125:34987,38126:35513,38127:36027,38128:36991,38129:38750,38130:39131,38131:27147,38132:31800,38133:20633,38134:23614,38135:24494,38136:26503,38137:27608,38138:29749,38139:30473,38140:32654,38208:40763,38209:26570,38210:31255,38211:21305,38212:30091,38213:39661,38214:24422,38215:33181,38216:33777,38217:32920,38218:24380,38219:24517,38220:30050,38221:31558,38222:36924,38223:26727,38224:23019,38225:23195,38226:32016,38227:30334,38228:35628,38229:20469,38230:24426,38231:27161,38232:27703,38233:28418,38234:29922,38235:31080,38236:34920,38237:35413,38238:35961,38239:24287,38240:25551,38241:30149,38242:31186,38243:33495,38244:37672,38245:37618,38246:33948,38247:34541,38248:39981,38249:21697,38250:24428,38251:25996,38252:27996,38253:28693,38254:36007,38255:36051,38256:38971,38257:25935,38258:29942,38259:19981,38260:20184,38261:22496,38262:22827,38263:23142,38264:23500,38265:20904,38266:24067,38267:24220,38268:24598,38269:25206,38270:25975,38272:26023,38273:26222,38274:28014,38275:29238,38276:31526,38277:33104,38278:33178,38279:33433,38280:35676,38281:36e3,38282:36070,38283:36212,38284:38428,38285:38468,38286:20398,38287:25771,38288:27494,38289:33310,38290:33889,38291:34154,38292:37096,38293:23553,38294:26963,38295:39080,38296:33914,38297:34135,38298:20239,38299:21103,38300:24489,38301:24133,38302:26381,38303:31119,38304:33145,38305:35079,38306:35206,38307:28149,38308:24343,38309:25173,38310:27832,38311:20175,38312:29289,38313:39826,38314:20998,38315:21563,38316:22132,38317:22707,38318:24996,38319:25198,38320:28954,38321:22894,38322:31881,38323:31966,38324:32027,38325:38640,38326:25991,38327:32862,38328:19993,38329:20341,38330:20853,38331:22592,38332:24163,38333:24179,38334:24330,38335:26564,38336:20006,38337:34109,38338:38281,38339:38491,38340:31859,38341:38913,38342:20731,38343:22721,38344:30294,38345:30887,38346:21029,38347:30629,38348:34065,38349:31622,38350:20559,38351:22793,38352:29255,38353:31687,38354:32232,38355:36794,38356:36820,38357:36941,38358:20415,38359:21193,38360:23081,38361:24321,38362:38829,38363:20445,38364:33303,38365:37610,38366:22275,38367:25429,38368:27497,38369:29995,38370:35036,38371:36628,38372:31298,38373:21215,38374:22675,38375:24917,38376:25098,38377:26286,38378:27597,38379:31807,38380:33769,38381:20515,38382:20472,38383:21253,38384:21574,38385:22577,38386:22857,38387:23453,38388:23792,38389:23791,38390:23849,38391:24214,38392:25265,38393:25447,38394:25918,38395:26041,38396:26379,38464:27861,38465:27873,38466:28921,38467:30770,38468:32299,38469:32990,38470:33459,38471:33804,38472:34028,38473:34562,38474:35090,38475:35370,38476:35914,38477:37030,38478:37586,38479:39165,38480:40179,38481:40300,38482:20047,38483:20129,38484:20621,38485:21078,38486:22346,38487:22952,38488:24125,38489:24536,38490:24537,38491:25151,38492:26292,38493:26395,38494:26576,38495:26834,38496:20882,38497:32033,38498:32938,38499:33192,38500:35584,38501:35980,38502:36031,38503:37502,38504:38450,38505:21536,38506:38956,38507:21271,38508:20693,38509:21340,38510:22696,38511:25778,38512:26420,38513:29287,38514:30566,38515:31302,38516:37350,38517:21187,38518:27809,38519:27526,38520:22528,38521:24140,38522:22868,38523:26412,38524:32763,38525:20961,38526:30406,38528:25705,38529:30952,38530:39764,38531:40635,38532:22475,38533:22969,38534:26151,38535:26522,38536:27598,38537:21737,38538:27097,38539:24149,38540:33180,38541:26517,38542:39850,38543:26622,38544:40018,38545:26717,38546:20134,38547:20451,38548:21448,38549:25273,38550:26411,38551:27819,38552:36804,38553:20397,38554:32365,38555:40639,38556:19975,38557:24930,38558:28288,38559:28459,38560:34067,38561:21619,38562:26410,38563:39749,38564:24051,38565:31637,38566:23724,38567:23494,38568:34588,38569:28234,38570:34001,38571:31252,38572:33032,38573:22937,38574:31885,38575:27665,38576:30496,38577:21209,38578:22818,38579:28961,38580:29279,38581:30683,38582:38695,38583:40289,38584:26891,38585:23167,38586:23064,38587:20901,38588:21517,38589:21629,38590:26126,38591:30431,38592:36855,38593:37528,38594:40180,38595:23018,38596:29277,38597:28357,38598:20813,38599:26825,38600:32191,38601:32236,38602:38754,38603:40634,38604:25720,38605:27169,38606:33538,38607:22916,38608:23391,38609:27611,38610:29467,38611:30450,38612:32178,38613:32791,38614:33945,38615:20786,38616:26408,38617:40665,38618:30446,38619:26466,38620:21247,38621:39173,38622:23588,38623:25147,38624:31870,38625:36016,38626:21839,38627:24758,38628:32011,38629:38272,38630:21249,38631:20063,38632:20918,38633:22812,38634:29242,38635:32822,38636:37326,38637:24357,38638:30690,38639:21380,38640:24441,38641:32004,38642:34220,38643:35379,38644:36493,38645:38742,38646:26611,38647:34222,38648:37971,38649:24841,38650:24840,38651:27833,38652:30290,38720:35565,38721:36664,38722:21807,38723:20305,38724:20778,38725:21191,38726:21451,38727:23461,38728:24189,38729:24736,38730:24962,38731:25558,38732:26377,38733:26586,38734:28263,38735:28044,38736:29494,38737:29495,38738:30001,38739:31056,38740:35029,38741:35480,38742:36938,38743:37009,38744:37109,38745:38596,38746:34701,38747:22805,38748:20104,38749:20313,38750:19982,38751:35465,38752:36671,38753:38928,38754:20653,38755:24188,38756:22934,38757:23481,38758:24248,38759:25562,38760:25594,38761:25793,38762:26332,38763:26954,38764:27096,38765:27915,38766:28342,38767:29076,38768:29992,38769:31407,38770:32650,38771:32768,38772:33865,38773:33993,38774:35201,38775:35617,38776:36362,38777:36965,38778:38525,38779:39178,38780:24958,38781:25233,38782:27442,38784:27779,38785:28020,38786:32716,38787:32764,38788:28096,38789:32645,38790:34746,38791:35064,38792:26469,38793:33713,38794:38972,38795:38647,38796:27931,38797:32097,38798:33853,38799:37226,38800:20081,38801:21365,38802:23888,38803:27396,38804:28651,38805:34253,38806:34349,38807:35239,38808:21033,38809:21519,38810:23653,38811:26446,38812:26792,38813:29702,38814:29827,38815:30178,38816:35023,38817:35041,38818:37324,38819:38626,38820:38520,38821:24459,38822:29575,38823:31435,38824:33870,38825:25504,38826:30053,38827:21129,38828:27969,38829:28316,38830:29705,38831:30041,38832:30827,38833:31890,38834:38534,38835:31452,38836:40845,38837:20406,38838:24942,38839:26053,38840:34396,38841:20102,38842:20142,38843:20698,38844:20001,38845:20940,38846:23534,38847:26009,38848:26753,38849:28092,38850:29471,38851:30274,38852:30637,38853:31260,38854:31975,38855:33391,38856:35538,38857:36988,38858:37327,38859:38517,38860:38936,38861:21147,38862:32209,38863:20523,38864:21400,38865:26519,38866:28107,38867:29136,38868:29747,38869:33256,38870:36650,38871:38563,38872:40023,38873:40607,38874:29792,38875:22593,38876:28057,38877:32047,38878:39006,38879:20196,38880:20278,38881:20363,38882:20919,38883:21169,38884:23994,38885:24604,38886:29618,38887:31036,38888:33491,38889:37428,38890:38583,38891:38646,38892:38666,38893:40599,38894:40802,38895:26278,38896:27508,38897:21015,38898:21155,38899:28872,38900:35010,38901:24265,38902:24651,38903:24976,38904:28451,38905:29001,38906:31806,38907:32244,38908:32879,38976:34030,38977:36899,38978:37676,38979:21570,38980:39791,38981:27347,38982:28809,38983:36034,38984:36335,38985:38706,38986:21172,38987:23105,38988:24266,38989:24324,38990:26391,38991:27004,38992:27028,38993:28010,38994:28431,38995:29282,38996:29436,38997:31725,38998:32769,38999:32894,39e3:34635,39001:37070,39002:20845,39003:40595,39004:31108,39005:32907,39006:37682,39007:35542,39008:20525,39009:21644,39010:35441,39011:27498,39012:36036,39013:33031,39014:24785,39015:26528,39016:40434,39017:20121,39018:20120,39019:39952,39020:35435,39021:34241,39022:34152,39023:26880,39024:28286,39025:30871,39026:33109,39071:24332,39072:19984,39073:19989,39074:20010,39075:20017,39076:20022,39077:20028,39078:20031,39079:20034,39080:20054,39081:20056,39082:20098,39083:20101,39084:35947,39085:20106,39086:33298,39087:24333,39088:20110,39089:20126,39090:20127,39091:20128,39092:20130,39093:20144,39094:20147,39095:20150,39096:20174,39097:20173,39098:20164,39099:20166,39100:20162,39101:20183,39102:20190,39103:20205,39104:20191,39105:20215,39106:20233,39107:20314,39108:20272,39109:20315,39110:20317,39111:20311,39112:20295,39113:20342,39114:20360,39115:20367,39116:20376,39117:20347,39118:20329,39119:20336,39120:20369,39121:20335,39122:20358,39123:20374,39124:20760,39125:20436,39126:20447,39127:20430,39128:20440,39129:20443,39130:20433,39131:20442,39132:20432,39133:20452,39134:20453,39135:20506,39136:20520,39137:20500,39138:20522,39139:20517,39140:20485,39141:20252,39142:20470,39143:20513,39144:20521,39145:20524,39146:20478,39147:20463,39148:20497,39149:20486,39150:20547,39151:20551,39152:26371,39153:20565,39154:20560,39155:20552,39156:20570,39157:20566,39158:20588,39159:20600,39160:20608,39161:20634,39162:20613,39163:20660,39164:20658,39232:20681,39233:20682,39234:20659,39235:20674,39236:20694,39237:20702,39238:20709,39239:20717,39240:20707,39241:20718,39242:20729,39243:20725,39244:20745,39245:20737,39246:20738,39247:20758,39248:20757,39249:20756,39250:20762,39251:20769,39252:20794,39253:20791,39254:20796,39255:20795,39256:20799,39257:20800,39258:20818,39259:20812,39260:20820,39261:20834,39262:31480,39263:20841,39264:20842,39265:20846,39266:20864,39267:20866,39268:22232,39269:20876,39270:20873,39271:20879,39272:20881,39273:20883,39274:20885,39275:20886,39276:20900,39277:20902,39278:20898,39279:20905,39280:20906,39281:20907,39282:20915,39283:20913,39284:20914,39285:20912,39286:20917,39287:20925,39288:20933,39289:20937,39290:20955,39291:20960,39292:34389,39293:20969,39294:20973,39296:20976,39297:20981,39298:20990,39299:20996,39300:21003,39301:21012,39302:21006,39303:21031,39304:21034,39305:21038,39306:21043,39307:21049,39308:21071,39309:21060,39310:21067,39311:21068,39312:21086,39313:21076,39314:21098,39315:21108,39316:21097,39317:21107,39318:21119,39319:21117,39320:21133,39321:21140,39322:21138,39323:21105,39324:21128,39325:21137,39326:36776,39327:36775,39328:21164,39329:21165,39330:21180,39331:21173,39332:21185,39333:21197,39334:21207,39335:21214,39336:21219,39337:21222,39338:39149,39339:21216,39340:21235,39341:21237,39342:21240,39343:21241,39344:21254,39345:21256,39346:30008,39347:21261,39348:21264,39349:21263,39350:21269,39351:21274,39352:21283,39353:21295,39354:21297,39355:21299,39356:21304,39357:21312,39358:21318,39359:21317,39360:19991,39361:21321,39362:21325,39363:20950,39364:21342,39365:21353,39366:21358,39367:22808,39368:21371,39369:21367,39370:21378,39371:21398,39372:21408,39373:21414,39374:21413,39375:21422,39376:21424,39377:21430,39378:21443,39379:31762,39380:38617,39381:21471,39382:26364,39383:29166,39384:21486,39385:21480,39386:21485,39387:21498,39388:21505,39389:21565,39390:21568,39391:21548,39392:21549,39393:21564,39394:21550,39395:21558,39396:21545,39397:21533,39398:21582,39399:21647,39400:21621,39401:21646,39402:21599,39403:21617,39404:21623,39405:21616,39406:21650,39407:21627,39408:21632,39409:21622,39410:21636,39411:21648,39412:21638,39413:21703,39414:21666,39415:21688,39416:21669,39417:21676,39418:21700,39419:21704,39420:21672,39488:21675,39489:21698,39490:21668,39491:21694,39492:21692,39493:21720,39494:21733,39495:21734,39496:21775,39497:21780,39498:21757,39499:21742,39500:21741,39501:21754,39502:21730,39503:21817,39504:21824,39505:21859,39506:21836,39507:21806,39508:21852,39509:21829,39510:21846,39511:21847,39512:21816,39513:21811,39514:21853,39515:21913,39516:21888,39517:21679,39518:21898,39519:21919,39520:21883,39521:21886,39522:21912,39523:21918,39524:21934,39525:21884,39526:21891,39527:21929,39528:21895,39529:21928,39530:21978,39531:21957,39532:21983,39533:21956,39534:21980,39535:21988,39536:21972,39537:22036,39538:22007,39539:22038,39540:22014,39541:22013,39542:22043,39543:22009,39544:22094,39545:22096,39546:29151,39547:22068,39548:22070,39549:22066,39550:22072,39552:22123,39553:22116,39554:22063,39555:22124,39556:22122,39557:22150,39558:22144,39559:22154,39560:22176,39561:22164,39562:22159,39563:22181,39564:22190,39565:22198,39566:22196,39567:22210,39568:22204,39569:22209,39570:22211,39571:22208,39572:22216,39573:22222,39574:22225,39575:22227,39576:22231,39577:22254,39578:22265,39579:22272,39580:22271,39581:22276,39582:22281,39583:22280,39584:22283,39585:22285,39586:22291,39587:22296,39588:22294,39589:21959,39590:22300,39591:22310,39592:22327,39593:22328,39594:22350,39595:22331,39596:22336,39597:22351,39598:22377,39599:22464,39600:22408,39601:22369,39602:22399,39603:22409,39604:22419,39605:22432,39606:22451,39607:22436,39608:22442,39609:22448,39610:22467,39611:22470,39612:22484,39613:22482,39614:22483,39615:22538,39616:22486,39617:22499,39618:22539,39619:22553,39620:22557,39621:22642,39622:22561,39623:22626,39624:22603,39625:22640,39626:27584,39627:22610,39628:22589,39629:22649,39630:22661,39631:22713,39632:22687,39633:22699,39634:22714,39635:22750,39636:22715,39637:22712,39638:22702,39639:22725,39640:22739,39641:22737,39642:22743,39643:22745,39644:22744,39645:22757,39646:22748,39647:22756,39648:22751,39649:22767,39650:22778,39651:22777,39652:22779,39653:22780,39654:22781,39655:22786,39656:22794,39657:22800,39658:22811,39659:26790,39660:22821,39661:22828,39662:22829,39663:22834,39664:22840,39665:22846,39666:31442,39667:22869,39668:22864,39669:22862,39670:22874,39671:22872,39672:22882,39673:22880,39674:22887,39675:22892,39676:22889,39744:22904,39745:22913,39746:22941,39747:20318,39748:20395,39749:22947,39750:22962,39751:22982,39752:23016,39753:23004,39754:22925,39755:23001,39756:23002,39757:23077,39758:23071,39759:23057,39760:23068,39761:23049,39762:23066,39763:23104,39764:23148,39765:23113,39766:23093,39767:23094,39768:23138,39769:23146,39770:23194,39771:23228,39772:23230,39773:23243,39774:23234,39775:23229,39776:23267,39777:23255,39778:23270,39779:23273,39780:23254,39781:23290,39782:23291,39783:23308,39784:23307,39785:23318,39786:23346,39787:23248,39788:23338,39789:23350,39790:23358,39791:23363,39792:23365,39793:23360,39794:23377,39795:23381,39796:23386,39797:23387,39798:23397,39799:23401,39800:23408,39801:23411,39802:23413,39803:23416,39804:25992,39805:23418,39806:23424,39808:23427,39809:23462,39810:23480,39811:23491,39812:23495,39813:23497,39814:23508,39815:23504,39816:23524,39817:23526,39818:23522,39819:23518,39820:23525,39821:23531,39822:23536,39823:23542,39824:23539,39825:23557,39826:23559,39827:23560,39828:23565,39829:23571,39830:23584,39831:23586,39832:23592,39833:23608,39834:23609,39835:23617,39836:23622,39837:23630,39838:23635,39839:23632,39840:23631,39841:23409,39842:23660,39843:23662,39844:20066,39845:23670,39846:23673,39847:23692,39848:23697,39849:23700,39850:22939,39851:23723,39852:23739,39853:23734,39854:23740,39855:23735,39856:23749,39857:23742,39858:23751,39859:23769,39860:23785,39861:23805,39862:23802,39863:23789,39864:23948,39865:23786,39866:23819,39867:23829,39868:23831,39869:23900,39870:23839,39871:23835,39872:23825,39873:23828,39874:23842,39875:23834,39876:23833,39877:23832,39878:23884,39879:23890,39880:23886,39881:23883,39882:23916,39883:23923,39884:23926,39885:23943,39886:23940,39887:23938,39888:23970,39889:23965,39890:23980,39891:23982,39892:23997,39893:23952,39894:23991,39895:23996,39896:24009,39897:24013,39898:24019,39899:24018,39900:24022,39901:24027,39902:24043,39903:24050,39904:24053,39905:24075,39906:24090,39907:24089,39908:24081,39909:24091,39910:24118,39911:24119,39912:24132,39913:24131,39914:24128,39915:24142,39916:24151,39917:24148,39918:24159,39919:24162,39920:24164,39921:24135,39922:24181,39923:24182,39924:24186,39925:40636,39926:24191,39927:24224,39928:24257,39929:24258,39930:24264,39931:24272,39932:24271,4e4:24278,40001:24291,40002:24285,40003:24282,40004:24283,40005:24290,40006:24289,40007:24296,40008:24297,40009:24300,40010:24305,40011:24307,40012:24304,40013:24308,40014:24312,40015:24318,40016:24323,40017:24329,40018:24413,40019:24412,40020:24331,40021:24337,40022:24342,40023:24361,40024:24365,40025:24376,40026:24385,40027:24392,40028:24396,40029:24398,40030:24367,40031:24401,40032:24406,40033:24407,40034:24409,40035:24417,40036:24429,40037:24435,40038:24439,40039:24451,40040:24450,40041:24447,40042:24458,40043:24456,40044:24465,40045:24455,40046:24478,40047:24473,40048:24472,40049:24480,40050:24488,40051:24493,40052:24508,40053:24534,40054:24571,40055:24548,40056:24568,40057:24561,40058:24541,40059:24755,40060:24575,40061:24609,40062:24672,40064:24601,40065:24592,40066:24617,40067:24590,40068:24625,40069:24603,40070:24597,40071:24619,40072:24614,40073:24591,40074:24634,40075:24666,40076:24641,40077:24682,40078:24695,40079:24671,40080:24650,40081:24646,40082:24653,40083:24675,40084:24643,40085:24676,40086:24642,40087:24684,40088:24683,40089:24665,40090:24705,40091:24717,40092:24807,40093:24707,40094:24730,40095:24708,40096:24731,40097:24726,40098:24727,40099:24722,40100:24743,40101:24715,40102:24801,40103:24760,40104:24800,40105:24787,40106:24756,40107:24560,40108:24765,40109:24774,40110:24757,40111:24792,40112:24909,40113:24853,40114:24838,40115:24822,40116:24823,40117:24832,40118:24820,40119:24826,40120:24835,40121:24865,40122:24827,40123:24817,40124:24845,40125:24846,40126:24903,40127:24894,40128:24872,40129:24871,40130:24906,40131:24895,40132:24892,40133:24876,40134:24884,40135:24893,40136:24898,40137:24900,40138:24947,40139:24951,40140:24920,40141:24921,40142:24922,40143:24939,40144:24948,40145:24943,40146:24933,40147:24945,40148:24927,40149:24925,40150:24915,40151:24949,40152:24985,40153:24982,40154:24967,40155:25004,40156:24980,40157:24986,40158:24970,40159:24977,40160:25003,40161:25006,40162:25036,40163:25034,40164:25033,40165:25079,40166:25032,40167:25027,40168:25030,40169:25018,40170:25035,40171:32633,40172:25037,40173:25062,40174:25059,40175:25078,40176:25082,40177:25076,40178:25087,40179:25085,40180:25084,40181:25086,40182:25088,40183:25096,40184:25097,40185:25101,40186:25100,40187:25108,40188:25115,40256:25118,40257:25121,40258:25130,40259:25134,40260:25136,40261:25138,40262:25139,40263:25153,40264:25166,40265:25182,40266:25187,40267:25179,40268:25184,40269:25192,40270:25212,40271:25218,40272:25225,40273:25214,40274:25234,40275:25235,40276:25238,40277:25300,40278:25219,40279:25236,40280:25303,40281:25297,40282:25275,40283:25295,40284:25343,40285:25286,40286:25812,40287:25288,40288:25308,40289:25292,40290:25290,40291:25282,40292:25287,40293:25243,40294:25289,40295:25356,40296:25326,40297:25329,40298:25383,40299:25346,40300:25352,40301:25327,40302:25333,40303:25424,40304:25406,40305:25421,40306:25628,40307:25423,40308:25494,40309:25486,40310:25472,40311:25515,40312:25462,40313:25507,40314:25487,40315:25481,40316:25503,40317:25525,40318:25451,40320:25449,40321:25534,40322:25577,40323:25536,40324:25542,40325:25571,40326:25545,40327:25554,40328:25590,40329:25540,40330:25622,40331:25652,40332:25606,40333:25619,40334:25638,40335:25654,40336:25885,40337:25623,40338:25640,40339:25615,40340:25703,40341:25711,40342:25718,40343:25678,40344:25898,40345:25749,40346:25747,40347:25765,40348:25769,40349:25736,40350:25788,40351:25818,40352:25810,40353:25797,40354:25799,40355:25787,40356:25816,40357:25794,40358:25841,40359:25831,40360:33289,40361:25824,40362:25825,40363:25260,40364:25827,40365:25839,40366:25900,40367:25846,40368:25844,40369:25842,40370:25850,40371:25856,40372:25853,40373:25880,40374:25884,40375:25861,40376:25892,40377:25891,40378:25899,40379:25908,40380:25909,40381:25911,40382:25910,40383:25912,40384:30027,40385:25928,40386:25942,40387:25941,40388:25933,40389:25944,40390:25950,40391:25949,40392:25970,40393:25976,40394:25986,40395:25987,40396:35722,40397:26011,40398:26015,40399:26027,40400:26039,40401:26051,40402:26054,40403:26049,40404:26052,40405:26060,40406:26066,40407:26075,40408:26073,40409:26080,40410:26081,40411:26097,40412:26482,40413:26122,40414:26115,40415:26107,40416:26483,40417:26165,40418:26166,40419:26164,40420:26140,40421:26191,40422:26180,40423:26185,40424:26177,40425:26206,40426:26205,40427:26212,40428:26215,40429:26216,40430:26207,40431:26210,40432:26224,40433:26243,40434:26248,40435:26254,40436:26249,40437:26244,40438:26264,40439:26269,40440:26305,40441:26297,40442:26313,40443:26302,40444:26300,40512:26308,40513:26296,40514:26326,40515:26330,40516:26336,40517:26175,40518:26342,40519:26345,40520:26352,40521:26357,40522:26359,40523:26383,40524:26390,40525:26398,40526:26406,40527:26407,40528:38712,40529:26414,40530:26431,40531:26422,40532:26433,40533:26424,40534:26423,40535:26438,40536:26462,40537:26464,40538:26457,40539:26467,40540:26468,40541:26505,40542:26480,40543:26537,40544:26492,40545:26474,40546:26508,40547:26507,40548:26534,40549:26529,40550:26501,40551:26551,40552:26607,40553:26548,40554:26604,40555:26547,40556:26601,40557:26552,40558:26596,40559:26590,40560:26589,40561:26594,40562:26606,40563:26553,40564:26574,40565:26566,40566:26599,40567:27292,40568:26654,40569:26694,40570:26665,40571:26688,40572:26701,40573:26674,40574:26702,40576:26803,40577:26667,40578:26713,40579:26723,40580:26743,40581:26751,40582:26783,40583:26767,40584:26797,40585:26772,40586:26781,40587:26779,40588:26755,40589:27310,40590:26809,40591:26740,40592:26805,40593:26784,40594:26810,40595:26895,40596:26765,40597:26750,40598:26881,40599:26826,40600:26888,40601:26840,40602:26914,40603:26918,40604:26849,40605:26892,40606:26829,40607:26836,40608:26855,40609:26837,40610:26934,40611:26898,40612:26884,40613:26839,40614:26851,40615:26917,40616:26873,40617:26848,40618:26863,40619:26920,40620:26922,40621:26906,40622:26915,40623:26913,40624:26822,40625:27001,40626:26999,40627:26972,40628:27e3,40629:26987,40630:26964,40631:27006,40632:26990,40633:26937,40634:26996,40635:26941,40636:26969,40637:26928,40638:26977,40639:26974,40640:26973,40641:27009,40642:26986,40643:27058,40644:27054,40645:27088,40646:27071,40647:27073,40648:27091,40649:27070,40650:27086,40651:23528,40652:27082,40653:27101,40654:27067,40655:27075,40656:27047,40657:27182,40658:27025,40659:27040,40660:27036,40661:27029,40662:27060,40663:27102,40664:27112,40665:27138,40666:27163,40667:27135,40668:27402,40669:27129,40670:27122,40671:27111,40672:27141,40673:27057,40674:27166,40675:27117,40676:27156,40677:27115,40678:27146,40679:27154,40680:27329,40681:27171,40682:27155,40683:27204,40684:27148,40685:27250,40686:27190,40687:27256,40688:27207,40689:27234,40690:27225,40691:27238,40692:27208,40693:27192,40694:27170,40695:27280,40696:27277,40697:27296,40698:27268,40699:27298,40700:27299,40768:27287,40769:34327,40770:27323,40771:27331,40772:27330,40773:27320,40774:27315,40775:27308,40776:27358,40777:27345,40778:27359,40779:27306,40780:27354,40781:27370,40782:27387,40783:27397,40784:34326,40785:27386,40786:27410,40787:27414,40788:39729,40789:27423,40790:27448,40791:27447,40792:30428,40793:27449,40794:39150,40795:27463,40796:27459,40797:27465,40798:27472,40799:27481,40800:27476,40801:27483,40802:27487,40803:27489,40804:27512,40805:27513,40806:27519,40807:27520,40808:27524,40809:27523,40810:27533,40811:27544,40812:27541,40813:27550,40814:27556,40815:27562,40816:27563,40817:27567,40818:27570,40819:27569,40820:27571,40821:27575,40822:27580,40823:27590,40824:27595,40825:27603,40826:27615,40827:27628,40828:27627,40829:27635,40830:27631,40832:40638,40833:27656,40834:27667,40835:27668,40836:27675,40837:27684,40838:27683,40839:27742,40840:27733,40841:27746,40842:27754,40843:27778,40844:27789,40845:27802,40846:27777,40847:27803,40848:27774,40849:27752,40850:27763,40851:27794,40852:27792,40853:27844,40854:27889,40855:27859,40856:27837,40857:27863,40858:27845,40859:27869,40860:27822,40861:27825,40862:27838,40863:27834,40864:27867,40865:27887,40866:27865,40867:27882,40868:27935,40869:34893,40870:27958,40871:27947,40872:27965,40873:27960,40874:27929,40875:27957,40876:27955,40877:27922,40878:27916,40879:28003,40880:28051,40881:28004,40882:27994,40883:28025,40884:27993,40885:28046,40886:28053,40887:28644,40888:28037,40889:28153,40890:28181,40891:28170,40892:28085,40893:28103,40894:28134,40895:28088,40896:28102,40897:28140,40898:28126,40899:28108,40900:28136,40901:28114,40902:28101,40903:28154,40904:28121,40905:28132,40906:28117,40907:28138,40908:28142,40909:28205,40910:28270,40911:28206,40912:28185,40913:28274,40914:28255,40915:28222,40916:28195,40917:28267,40918:28203,40919:28278,40920:28237,40921:28191,40922:28227,40923:28218,40924:28238,40925:28196,40926:28415,40927:28189,40928:28216,40929:28290,40930:28330,40931:28312,40932:28361,40933:28343,40934:28371,40935:28349,40936:28335,40937:28356,40938:28338,40939:28372,40940:28373,40941:28303,40942:28325,40943:28354,40944:28319,40945:28481,40946:28433,40947:28748,40948:28396,40949:28408,40950:28414,40951:28479,40952:28402,40953:28465,40954:28399,40955:28466,40956:28364,161:65377,162:65378,163:65379,164:65380,165:65381,166:65382,167:65383,168:65384,169:65385,170:65386,171:65387,172:65388,173:65389,174:65390,175:65391,176:65392,177:65393,178:65394,179:65395,180:65396,181:65397,182:65398,183:65399,184:65400,185:65401,186:65402,187:65403,188:65404,189:65405,190:65406,191:65407,192:65408,193:65409,194:65410,195:65411,196:65412,197:65413,198:65414,199:65415,200:65416,201:65417,202:65418,203:65419,204:65420,205:65421,206:65422,207:65423,208:65424,209:65425,210:65426,211:65427,212:65428,213:65429,214:65430,215:65431,216:65432,217:65433,218:65434,219:65435,220:65436,221:65437,222:65438,223:65439,57408:28478,57409:28435,57410:28407,57411:28550,57412:28538,57413:28536,57414:28545,57415:28544,57416:28527,57417:28507,57418:28659,57419:28525,57420:28546,57421:28540,57422:28504,57423:28558,57424:28561,57425:28610,57426:28518,57427:28595,57428:28579,57429:28577,57430:28580,57431:28601,57432:28614,57433:28586,57434:28639,57435:28629,57436:28652,57437:28628,57438:28632,57439:28657,57440:28654,57441:28635,57442:28681,57443:28683,57444:28666,57445:28689,57446:28673,57447:28687,57448:28670,57449:28699,57450:28698,57451:28532,57452:28701,57453:28696,57454:28703,57455:28720,57456:28734,57457:28722,57458:28753,57459:28771,57460:28825,57461:28818,57462:28847,57463:28913,57464:28844,57465:28856,57466:28851,57467:28846,57468:28895,57469:28875,57470:28893,57472:28889,57473:28937,57474:28925,57475:28956,57476:28953,57477:29029,57478:29013,57479:29064,57480:29030,57481:29026,57482:29004,57483:29014,57484:29036,57485:29071,57486:29179,57487:29060,57488:29077,57489:29096,57490:29100,57491:29143,57492:29113,57493:29118,57494:29138,57495:29129,57496:29140,57497:29134,57498:29152,57499:29164,57500:29159,57501:29173,57502:29180,57503:29177,57504:29183,57505:29197,57506:29200,57507:29211,57508:29224,57509:29229,57510:29228,57511:29232,57512:29234,57513:29243,57514:29244,57515:29247,57516:29248,57517:29254,57518:29259,57519:29272,57520:29300,57521:29310,57522:29314,57523:29313,57524:29319,57525:29330,57526:29334,57527:29346,57528:29351,57529:29369,57530:29362,57531:29379,57532:29382,57533:29380,57534:29390,57535:29394,57536:29410,57537:29408,57538:29409,57539:29433,57540:29431,57541:20495,57542:29463,57543:29450,57544:29468,57545:29462,57546:29469,57547:29492,57548:29487,57549:29481,57550:29477,57551:29502,57552:29518,57553:29519,57554:40664,57555:29527,57556:29546,57557:29544,57558:29552,57559:29560,57560:29557,57561:29563,57562:29562,57563:29640,57564:29619,57565:29646,57566:29627,57567:29632,57568:29669,57569:29678,57570:29662,57571:29858,57572:29701,57573:29807,57574:29733,57575:29688,57576:29746,57577:29754,57578:29781,57579:29759,57580:29791,57581:29785,57582:29761,57583:29788,57584:29801,57585:29808,57586:29795,57587:29802,57588:29814,57589:29822,57590:29835,57591:29854,57592:29863,57593:29898,57594:29903,57595:29908,57596:29681,57664:29920,57665:29923,57666:29927,57667:29929,57668:29934,57669:29938,57670:29936,57671:29937,57672:29944,57673:29943,57674:29956,57675:29955,57676:29957,57677:29964,57678:29966,57679:29965,57680:29973,57681:29971,57682:29982,57683:29990,57684:29996,57685:30012,57686:30020,57687:30029,57688:30026,57689:30025,57690:30043,57691:30022,57692:30042,57693:30057,57694:30052,57695:30055,57696:30059,57697:30061,57698:30072,57699:30070,57700:30086,57701:30087,57702:30068,57703:30090,57704:30089,57705:30082,57706:30100,57707:30106,57708:30109,57709:30117,57710:30115,57711:30146,57712:30131,57713:30147,57714:30133,57715:30141,57716:30136,57717:30140,57718:30129,57719:30157,57720:30154,57721:30162,57722:30169,57723:30179,57724:30174,57725:30206,57726:30207,57728:30204,57729:30209,57730:30192,57731:30202,57732:30194,57733:30195,57734:30219,57735:30221,57736:30217,57737:30239,57738:30247,57739:30240,57740:30241,57741:30242,57742:30244,57743:30260,57744:30256,57745:30267,57746:30279,57747:30280,57748:30278,57749:30300,57750:30296,57751:30305,57752:30306,57753:30312,57754:30313,57755:30314,57756:30311,57757:30316,57758:30320,57759:30322,57760:30326,57761:30328,57762:30332,57763:30336,57764:30339,57765:30344,57766:30347,57767:30350,57768:30358,57769:30355,57770:30361,57771:30362,57772:30384,57773:30388,57774:30392,57775:30393,57776:30394,57777:30402,57778:30413,57779:30422,57780:30418,57781:30430,57782:30433,57783:30437,57784:30439,57785:30442,57786:34351,57787:30459,57788:30472,57789:30471,57790:30468,57791:30505,57792:30500,57793:30494,57794:30501,57795:30502,57796:30491,57797:30519,57798:30520,57799:30535,57800:30554,57801:30568,57802:30571,57803:30555,57804:30565,57805:30591,57806:30590,57807:30585,57808:30606,57809:30603,57810:30609,57811:30624,57812:30622,57813:30640,57814:30646,57815:30649,57816:30655,57817:30652,57818:30653,57819:30651,57820:30663,57821:30669,57822:30679,57823:30682,57824:30684,57825:30691,57826:30702,57827:30716,57828:30732,57829:30738,57830:31014,57831:30752,57832:31018,57833:30789,57834:30862,57835:30836,57836:30854,57837:30844,57838:30874,57839:30860,57840:30883,57841:30901,57842:30890,57843:30895,57844:30929,57845:30918,57846:30923,57847:30932,57848:30910,57849:30908,57850:30917,57851:30922,57852:30956,57920:30951,57921:30938,57922:30973,57923:30964,57924:30983,57925:30994,57926:30993,57927:31001,57928:31020,57929:31019,57930:31040,57931:31072,57932:31063,57933:31071,57934:31066,57935:31061,57936:31059,57937:31098,57938:31103,57939:31114,57940:31133,57941:31143,57942:40779,57943:31146,57944:31150,57945:31155,57946:31161,57947:31162,57948:31177,57949:31189,57950:31207,57951:31212,57952:31201,57953:31203,57954:31240,57955:31245,57956:31256,57957:31257,57958:31264,57959:31263,57960:31104,57961:31281,57962:31291,57963:31294,57964:31287,57965:31299,57966:31319,57967:31305,57968:31329,57969:31330,57970:31337,57971:40861,57972:31344,57973:31353,57974:31357,57975:31368,57976:31383,57977:31381,57978:31384,57979:31382,57980:31401,57981:31432,57982:31408,57984:31414,57985:31429,57986:31428,57987:31423,57988:36995,57989:31431,57990:31434,57991:31437,57992:31439,57993:31445,57994:31443,57995:31449,57996:31450,57997:31453,57998:31457,57999:31458,58e3:31462,58001:31469,58002:31472,58003:31490,58004:31503,58005:31498,58006:31494,58007:31539,58008:31512,58009:31513,58010:31518,58011:31541,58012:31528,58013:31542,58014:31568,58015:31610,58016:31492,58017:31565,58018:31499,58019:31564,58020:31557,58021:31605,58022:31589,58023:31604,58024:31591,58025:31600,58026:31601,58027:31596,58028:31598,58029:31645,58030:31640,58031:31647,58032:31629,58033:31644,58034:31642,58035:31627,58036:31634,58037:31631,58038:31581,58039:31641,58040:31691,58041:31681,58042:31692,58043:31695,58044:31668,58045:31686,58046:31709,58047:31721,58048:31761,58049:31764,58050:31718,58051:31717,58052:31840,58053:31744,58054:31751,58055:31763,58056:31731,58057:31735,58058:31767,58059:31757,58060:31734,58061:31779,58062:31783,58063:31786,58064:31775,58065:31799,58066:31787,58067:31805,58068:31820,58069:31811,58070:31828,58071:31823,58072:31808,58073:31824,58074:31832,58075:31839,58076:31844,58077:31830,58078:31845,58079:31852,58080:31861,58081:31875,58082:31888,58083:31908,58084:31917,58085:31906,58086:31915,58087:31905,58088:31912,58089:31923,58090:31922,58091:31921,58092:31918,58093:31929,58094:31933,58095:31936,58096:31941,58097:31938,58098:31960,58099:31954,58100:31964,58101:31970,58102:39739,58103:31983,58104:31986,58105:31988,58106:31990,58107:31994,58108:32006,58176:32002,58177:32028,58178:32021,58179:32010,58180:32069,58181:32075,58182:32046,58183:32050,58184:32063,58185:32053,58186:32070,58187:32115,58188:32086,58189:32078,58190:32114,58191:32104,58192:32110,58193:32079,58194:32099,58195:32147,58196:32137,58197:32091,58198:32143,58199:32125,58200:32155,58201:32186,58202:32174,58203:32163,58204:32181,58205:32199,58206:32189,58207:32171,58208:32317,58209:32162,58210:32175,58211:32220,58212:32184,58213:32159,58214:32176,58215:32216,58216:32221,58217:32228,58218:32222,58219:32251,58220:32242,58221:32225,58222:32261,58223:32266,58224:32291,58225:32289,58226:32274,58227:32305,58228:32287,58229:32265,58230:32267,58231:32290,58232:32326,58233:32358,58234:32315,58235:32309,58236:32313,58237:32323,58238:32311,58240:32306,58241:32314,58242:32359,58243:32349,58244:32342,58245:32350,58246:32345,58247:32346,58248:32377,58249:32362,58250:32361,58251:32380,58252:32379,58253:32387,58254:32213,58255:32381,58256:36782,58257:32383,58258:32392,58259:32393,58260:32396,58261:32402,58262:32400,58263:32403,58264:32404,58265:32406,58266:32398,58267:32411,58268:32412,58269:32568,58270:32570,58271:32581,58272:32588,58273:32589,58274:32590,58275:32592,58276:32593,58277:32597,58278:32596,58279:32600,58280:32607,58281:32608,58282:32616,58283:32617,58284:32615,58285:32632,58286:32642,58287:32646,58288:32643,58289:32648,58290:32647,58291:32652,58292:32660,58293:32670,58294:32669,58295:32666,58296:32675,58297:32687,58298:32690,58299:32697,58300:32686,58301:32694,58302:32696,58303:35697,58304:32709,58305:32710,58306:32714,58307:32725,58308:32724,58309:32737,58310:32742,58311:32745,58312:32755,58313:32761,58314:39132,58315:32774,58316:32772,58317:32779,58318:32786,58319:32792,58320:32793,58321:32796,58322:32801,58323:32808,58324:32831,58325:32827,58326:32842,58327:32838,58328:32850,58329:32856,58330:32858,58331:32863,58332:32866,58333:32872,58334:32883,58335:32882,58336:32880,58337:32886,58338:32889,58339:32893,58340:32895,58341:32900,58342:32902,58343:32901,58344:32923,58345:32915,58346:32922,58347:32941,58348:20880,58349:32940,58350:32987,58351:32997,58352:32985,58353:32989,58354:32964,58355:32986,58356:32982,58357:33033,58358:33007,58359:33009,58360:33051,58361:33065,58362:33059,58363:33071,58364:33099,58432:38539,58433:33094,58434:33086,58435:33107,58436:33105,58437:33020,58438:33137,58439:33134,58440:33125,58441:33126,58442:33140,58443:33155,58444:33160,58445:33162,58446:33152,58447:33154,58448:33184,58449:33173,58450:33188,58451:33187,58452:33119,58453:33171,58454:33193,58455:33200,58456:33205,58457:33214,58458:33208,58459:33213,58460:33216,58461:33218,58462:33210,58463:33225,58464:33229,58465:33233,58466:33241,58467:33240,58468:33224,58469:33242,58470:33247,58471:33248,58472:33255,58473:33274,58474:33275,58475:33278,58476:33281,58477:33282,58478:33285,58479:33287,58480:33290,58481:33293,58482:33296,58483:33302,58484:33321,58485:33323,58486:33336,58487:33331,58488:33344,58489:33369,58490:33368,58491:33373,58492:33370,58493:33375,58494:33380,58496:33378,58497:33384,58498:33386,58499:33387,58500:33326,58501:33393,58502:33399,58503:33400,58504:33406,58505:33421,58506:33426,58507:33451,58508:33439,58509:33467,58510:33452,58511:33505,58512:33507,58513:33503,58514:33490,58515:33524,58516:33523,58517:33530,58518:33683,58519:33539,58520:33531,58521:33529,58522:33502,58523:33542,58524:33500,58525:33545,58526:33497,58527:33589,58528:33588,58529:33558,58530:33586,58531:33585,58532:33600,58533:33593,58534:33616,58535:33605,58536:33583,58537:33579,58538:33559,58539:33560,58540:33669,58541:33690,58542:33706,58543:33695,58544:33698,58545:33686,58546:33571,58547:33678,58548:33671,58549:33674,58550:33660,58551:33717,58552:33651,58553:33653,58554:33696,58555:33673,58556:33704,58557:33780,58558:33811,58559:33771,58560:33742,58561:33789,58562:33795,58563:33752,58564:33803,58565:33729,58566:33783,58567:33799,58568:33760,58569:33778,58570:33805,58571:33826,58572:33824,58573:33725,58574:33848,58575:34054,58576:33787,58577:33901,58578:33834,58579:33852,58580:34138,58581:33924,58582:33911,58583:33899,58584:33965,58585:33902,58586:33922,58587:33897,58588:33862,58589:33836,58590:33903,58591:33913,58592:33845,58593:33994,58594:33890,58595:33977,58596:33983,58597:33951,58598:34009,58599:33997,58600:33979,58601:34010,58602:34e3,58603:33985,58604:33990,58605:34006,58606:33953,58607:34081,58608:34047,58609:34036,58610:34071,58611:34072,58612:34092,58613:34079,58614:34069,58615:34068,58616:34044,58617:34112,58618:34147,58619:34136,58620:34120,58688:34113,58689:34306,58690:34123,58691:34133,58692:34176,58693:34212,58694:34184,58695:34193,58696:34186,58697:34216,58698:34157,58699:34196,58700:34203,58701:34282,58702:34183,58703:34204,58704:34167,58705:34174,58706:34192,58707:34249,58708:34234,58709:34255,58710:34233,58711:34256,58712:34261,58713:34269,58714:34277,58715:34268,58716:34297,58717:34314,58718:34323,58719:34315,58720:34302,58721:34298,58722:34310,58723:34338,58724:34330,58725:34352,58726:34367,58727:34381,58728:20053,58729:34388,58730:34399,58731:34407,58732:34417,58733:34451,58734:34467,58735:34473,58736:34474,58737:34443,58738:34444,58739:34486,58740:34479,58741:34500,58742:34502,58743:34480,58744:34505,58745:34851,58746:34475,58747:34516,58748:34526,58749:34537,58750:34540,58752:34527,58753:34523,58754:34543,58755:34578,58756:34566,58757:34568,58758:34560,58759:34563,58760:34555,58761:34577,58762:34569,58763:34573,58764:34553,58765:34570,58766:34612,58767:34623,58768:34615,58769:34619,58770:34597,58771:34601,58772:34586,58773:34656,58774:34655,58775:34680,58776:34636,58777:34638,58778:34676,58779:34647,58780:34664,58781:34670,58782:34649,58783:34643,58784:34659,58785:34666,58786:34821,58787:34722,58788:34719,58789:34690,58790:34735,58791:34763,58792:34749,58793:34752,58794:34768,58795:38614,58796:34731,58797:34756,58798:34739,58799:34759,58800:34758,58801:34747,58802:34799,58803:34802,58804:34784,58805:34831,58806:34829,58807:34814,58808:34806,58809:34807,58810:34830,58811:34770,58812:34833,58813:34838,58814:34837,58815:34850,58816:34849,58817:34865,58818:34870,58819:34873,58820:34855,58821:34875,58822:34884,58823:34882,58824:34898,58825:34905,58826:34910,58827:34914,58828:34923,58829:34945,58830:34942,58831:34974,58832:34933,58833:34941,58834:34997,58835:34930,58836:34946,58837:34967,58838:34962,58839:34990,58840:34969,58841:34978,58842:34957,58843:34980,58844:34992,58845:35007,58846:34993,58847:35011,58848:35012,58849:35028,58850:35032,58851:35033,58852:35037,58853:35065,58854:35074,58855:35068,58856:35060,58857:35048,58858:35058,58859:35076,58860:35084,58861:35082,58862:35091,58863:35139,58864:35102,58865:35109,58866:35114,58867:35115,58868:35137,58869:35140,58870:35131,58871:35126,58872:35128,58873:35148,58874:35101,58875:35168,58876:35166,58944:35174,58945:35172,58946:35181,58947:35178,58948:35183,58949:35188,58950:35191,58951:35198,58952:35203,58953:35208,58954:35210,58955:35219,58956:35224,58957:35233,58958:35241,58959:35238,58960:35244,58961:35247,58962:35250,58963:35258,58964:35261,58965:35263,58966:35264,58967:35290,58968:35292,58969:35293,58970:35303,58971:35316,58972:35320,58973:35331,58974:35350,58975:35344,58976:35340,58977:35355,58978:35357,58979:35365,58980:35382,58981:35393,58982:35419,58983:35410,58984:35398,58985:35400,58986:35452,58987:35437,58988:35436,58989:35426,58990:35461,58991:35458,58992:35460,58993:35496,58994:35489,58995:35473,58996:35493,58997:35494,58998:35482,58999:35491,59e3:35524,59001:35533,59002:35522,59003:35546,59004:35563,59005:35571,59006:35559,59008:35556,59009:35569,59010:35604,59011:35552,59012:35554,59013:35575,59014:35550,59015:35547,59016:35596,59017:35591,59018:35610,59019:35553,59020:35606,59021:35600,59022:35607,59023:35616,59024:35635,59025:38827,59026:35622,59027:35627,59028:35646,59029:35624,59030:35649,59031:35660,59032:35663,59033:35662,59034:35657,59035:35670,59036:35675,59037:35674,59038:35691,59039:35679,59040:35692,59041:35695,59042:35700,59043:35709,59044:35712,59045:35724,59046:35726,59047:35730,59048:35731,59049:35734,59050:35737,59051:35738,59052:35898,59053:35905,59054:35903,59055:35912,59056:35916,59057:35918,59058:35920,59059:35925,59060:35938,59061:35948,59062:35960,59063:35962,59064:35970,59065:35977,59066:35973,59067:35978,59068:35981,59069:35982,59070:35988,59071:35964,59072:35992,59073:25117,59074:36013,59075:36010,59076:36029,59077:36018,59078:36019,59079:36014,59080:36022,59081:36040,59082:36033,59083:36068,59084:36067,59085:36058,59086:36093,59087:36090,59088:36091,59089:36100,59090:36101,59091:36106,59092:36103,59093:36111,59094:36109,59095:36112,59096:40782,59097:36115,59098:36045,59099:36116,59100:36118,59101:36199,59102:36205,59103:36209,59104:36211,59105:36225,59106:36249,59107:36290,59108:36286,59109:36282,59110:36303,59111:36314,59112:36310,59113:36300,59114:36315,59115:36299,59116:36330,59117:36331,59118:36319,59119:36323,59120:36348,59121:36360,59122:36361,59123:36351,59124:36381,59125:36382,59126:36368,59127:36383,59128:36418,59129:36405,59130:36400,59131:36404,59132:36426,59200:36423,59201:36425,59202:36428,59203:36432,59204:36424,59205:36441,59206:36452,59207:36448,59208:36394,59209:36451,59210:36437,59211:36470,59212:36466,59213:36476,59214:36481,59215:36487,59216:36485,59217:36484,59218:36491,59219:36490,59220:36499,59221:36497,59222:36500,59223:36505,59224:36522,59225:36513,59226:36524,59227:36528,59228:36550,59229:36529,59230:36542,59231:36549,59232:36552,59233:36555,59234:36571,59235:36579,59236:36604,59237:36603,59238:36587,59239:36606,59240:36618,59241:36613,59242:36629,59243:36626,59244:36633,59245:36627,59246:36636,59247:36639,59248:36635,59249:36620,59250:36646,59251:36659,59252:36667,59253:36665,59254:36677,59255:36674,59256:36670,59257:36684,59258:36681,59259:36678,59260:36686,59261:36695,59262:36700,59264:36706,59265:36707,59266:36708,59267:36764,59268:36767,59269:36771,59270:36781,59271:36783,59272:36791,59273:36826,59274:36837,59275:36834,59276:36842,59277:36847,59278:36999,59279:36852,59280:36869,59281:36857,59282:36858,59283:36881,59284:36885,59285:36897,59286:36877,59287:36894,59288:36886,59289:36875,59290:36903,59291:36918,59292:36917,59293:36921,59294:36856,59295:36943,59296:36944,59297:36945,59298:36946,59299:36878,59300:36937,59301:36926,59302:36950,59303:36952,59304:36958,59305:36968,59306:36975,59307:36982,59308:38568,59309:36978,59310:36994,59311:36989,59312:36993,59313:36992,59314:37002,59315:37001,59316:37007,59317:37032,59318:37039,59319:37041,59320:37045,59321:37090,59322:37092,59323:25160,59324:37083,59325:37122,59326:37138,59327:37145,59328:37170,59329:37168,59330:37194,59331:37206,59332:37208,59333:37219,59334:37221,59335:37225,59336:37235,59337:37234,59338:37259,59339:37257,59340:37250,59341:37282,59342:37291,59343:37295,59344:37290,59345:37301,59346:37300,59347:37306,59348:37312,59349:37313,59350:37321,59351:37323,59352:37328,59353:37334,59354:37343,59355:37345,59356:37339,59357:37372,59358:37365,59359:37366,59360:37406,59361:37375,59362:37396,59363:37420,59364:37397,59365:37393,59366:37470,59367:37463,59368:37445,59369:37449,59370:37476,59371:37448,59372:37525,59373:37439,59374:37451,59375:37456,59376:37532,59377:37526,59378:37523,59379:37531,59380:37466,59381:37583,59382:37561,59383:37559,59384:37609,59385:37647,59386:37626,59387:37700,59388:37678,59456:37657,59457:37666,59458:37658,59459:37667,59460:37690,59461:37685,59462:37691,59463:37724,59464:37728,59465:37756,59466:37742,59467:37718,59468:37808,59469:37804,59470:37805,59471:37780,59472:37817,59473:37846,59474:37847,59475:37864,59476:37861,59477:37848,59478:37827,59479:37853,59480:37840,59481:37832,59482:37860,59483:37914,59484:37908,59485:37907,59486:37891,59487:37895,59488:37904,59489:37942,59490:37931,59491:37941,59492:37921,59493:37946,59494:37953,59495:37970,59496:37956,59497:37979,59498:37984,59499:37986,59500:37982,59501:37994,59502:37417,59503:38e3,59504:38005,59505:38007,59506:38013,59507:37978,59508:38012,59509:38014,59510:38017,59511:38015,59512:38274,59513:38279,59514:38282,59515:38292,59516:38294,59517:38296,59518:38297,59520:38304,59521:38312,59522:38311,59523:38317,59524:38332,59525:38331,59526:38329,59527:38334,59528:38346,59529:28662,59530:38339,59531:38349,59532:38348,59533:38357,59534:38356,59535:38358,59536:38364,59537:38369,59538:38373,59539:38370,59540:38433,59541:38440,59542:38446,59543:38447,59544:38466,59545:38476,59546:38479,59547:38475,59548:38519,59549:38492,59550:38494,59551:38493,59552:38495,59553:38502,59554:38514,59555:38508,59556:38541,59557:38552,59558:38549,59559:38551,59560:38570,59561:38567,59562:38577,59563:38578,59564:38576,59565:38580,59566:38582,59567:38584,59568:38585,59569:38606,59570:38603,59571:38601,59572:38605,59573:35149,59574:38620,59575:38669,59576:38613,59577:38649,59578:38660,59579:38662,59580:38664,59581:38675,59582:38670,59583:38673,59584:38671,59585:38678,59586:38681,59587:38692,59588:38698,59589:38704,59590:38713,59591:38717,59592:38718,59593:38724,59594:38726,59595:38728,59596:38722,59597:38729,59598:38748,59599:38752,59600:38756,59601:38758,59602:38760,59603:21202,59604:38763,59605:38769,59606:38777,59607:38789,59608:38780,59609:38785,59610:38778,59611:38790,59612:38795,59613:38799,59614:38800,59615:38812,59616:38824,59617:38822,59618:38819,59619:38835,59620:38836,59621:38851,59622:38854,59623:38856,59624:38859,59625:38876,59626:38893,59627:40783,59628:38898,59629:31455,59630:38902,59631:38901,59632:38927,59633:38924,59634:38968,59635:38948,59636:38945,59637:38967,59638:38973,59639:38982,59640:38991,59641:38987,59642:39019,59643:39023,59644:39024,59712:39025,59713:39028,59714:39027,59715:39082,59716:39087,59717:39089,59718:39094,59719:39108,59720:39107,59721:39110,59722:39145,59723:39147,59724:39171,59725:39177,59726:39186,59727:39188,59728:39192,59729:39201,59730:39197,59731:39198,59732:39204,59733:39200,59734:39212,59735:39214,59736:39229,59737:39230,59738:39234,59739:39241,59740:39237,59741:39248,59742:39243,59743:39249,59744:39250,59745:39244,59746:39253,59747:39319,59748:39320,59749:39333,59750:39341,59751:39342,59752:39356,59753:39391,59754:39387,59755:39389,59756:39384,59757:39377,59758:39405,59759:39406,59760:39409,59761:39410,59762:39419,59763:39416,59764:39425,59765:39439,59766:39429,59767:39394,59768:39449,59769:39467,59770:39479,59771:39493,59772:39490,59773:39488,59774:39491,59776:39486,59777:39509,59778:39501,59779:39515,59780:39511,59781:39519,59782:39522,59783:39525,59784:39524,59785:39529,59786:39531,59787:39530,59788:39597,59789:39600,59790:39612,59791:39616,59792:39631,59793:39633,59794:39635,59795:39636,59796:39646,59797:39647,59798:39650,59799:39651,59800:39654,59801:39663,59802:39659,59803:39662,59804:39668,59805:39665,59806:39671,59807:39675,59808:39686,59809:39704,59810:39706,59811:39711,59812:39714,59813:39715,59814:39717,59815:39719,59816:39720,59817:39721,59818:39722,59819:39726,59820:39727,59821:39730,59822:39748,59823:39747,59824:39759,59825:39757,59826:39758,59827:39761,59828:39768,59829:39796,59830:39827,59831:39811,59832:39825,59833:39830,59834:39831,59835:39839,59836:39840,59837:39848,59838:39860,59839:39872,59840:39882,59841:39865,59842:39878,59843:39887,59844:39889,59845:39890,59846:39907,59847:39906,59848:39908,59849:39892,59850:39905,59851:39994,59852:39922,59853:39921,59854:39920,59855:39957,59856:39956,59857:39945,59858:39955,59859:39948,59860:39942,59861:39944,59862:39954,59863:39946,59864:39940,59865:39982,59866:39963,59867:39973,59868:39972,59869:39969,59870:39984,59871:40007,59872:39986,59873:40006,59874:39998,59875:40026,59876:40032,59877:40039,59878:40054,59879:40056,59880:40167,59881:40172,59882:40176,59883:40201,59884:40200,59885:40171,59886:40195,59887:40198,59888:40234,59889:40230,59890:40367,59891:40227,59892:40223,59893:40260,59894:40213,59895:40210,59896:40257,59897:40255,59898:40254,59899:40262,59900:40264,59968:40285,59969:40286,59970:40292,59971:40273,59972:40272,59973:40281,59974:40306,59975:40329,59976:40327,59977:40363,59978:40303,59979:40314,59980:40346,59981:40356,59982:40361,59983:40370,59984:40388,59985:40385,59986:40379,59987:40376,59988:40378,59989:40390,59990:40399,59991:40386,59992:40409,59993:40403,59994:40440,59995:40422,59996:40429,59997:40431,59998:40445,59999:40474,6e4:40475,60001:40478,60002:40565,60003:40569,60004:40573,60005:40577,60006:40584,60007:40587,60008:40588,60009:40594,60010:40597,60011:40593,60012:40605,60013:40613,60014:40617,60015:40632,60016:40618,60017:40621,60018:38753,60019:40652,60020:40654,60021:40655,60022:40656,60023:40660,60024:40668,60025:40670,60026:40669,60027:40672,60028:40677,60029:40680,60030:40687,60032:40692,60033:40694,60034:40695,60035:40697,60036:40699,60037:40700,60038:40701,60039:40711,60040:40712,60041:30391,60042:40725,60043:40737,60044:40748,60045:40766,60046:40778,60047:40786,60048:40788,60049:40803,60050:40799,60051:40800,60052:40801,60053:40806,60054:40807,60055:40812,60056:40810,60057:40823,60058:40818,60059:40822,60060:40853,60061:40860,60062:40864,60063:22575,60064:27079,60065:36953,60066:29796,60067:20956,60068:29081}}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(2);function a(e,t,n,r){var i;t.degree()<n.degree()&&(i=[n,t],t=i[0],n=i[1]);for(var a=t,o=n,s=e.zero,c=e.one;o.degree()>=r/2;){var l=a,u=s;if(a=o,s=c,a.isZero())return null;o=l;for(var d=e.zero,f=a.getCoefficient(a.degree()),p=e.inverse(f);o.degree()>=a.degree()&&!o.isZero();){var m=o.degree()-a.degree(),h=e.multiply(o.getCoefficient(o.degree()),p);d=d.addOrSubtract(e.buildMonomial(m,h)),o=o.addOrSubtract(a.multiplyByMonomial(m,h))}if(c=d.multiplyPoly(s).addOrSubtract(u),o.degree()>=a.degree())return null}var g=c.getCoefficient(0);if(g===0)return null;var _=e.inverse(g);return[c.multiply(_),o.multiply(_)]}function o(e,t){var n=t.degree();if(n===1)return[t.getCoefficient(1)];for(var r=Array(n),i=0,a=1;a<e.size&&i<n;a++)t.evaluateAt(a)===0&&(r[i]=e.inverse(a),i++);return i===n?r:null}function s(e,t,n){for(var i=n.length,a=Array(i),o=0;o<i;o++){for(var s=e.inverse(n[o]),c=1,l=0;l<i;l++)o!==l&&(c=e.multiply(c,r.addOrSubtractGF(1,e.multiply(n[l],s))));a[o]=e.multiply(t.evaluateAt(s),e.inverse(c)),e.generatorBase!==0&&(a[o]=e.multiply(a[o],s))}return a}function c(e,t){var n=new Uint8ClampedArray(e.length);n.set(e);for(var c=new r.default(285,256,0),l=new i.default(c,n),u=new Uint8ClampedArray(t),d=!1,f=0;f<t;f++){var p=l.evaluateAt(c.exp(f+c.generatorBase));u[u.length-1-f]=p,p!==0&&(d=!0)}if(!d)return n;var m=new i.default(c,u),h=a(c,c.buildMonomial(t,1),m,t);if(h===null)return null;var g=o(c,h[0]);if(g==null)return null;for(var _=s(c,h[1],g),v=0;v<g.length;v++){var y=n.length-1-c.log(g[v]);if(y<0)return null;n[y]=r.addOrSubtractGF(n[y],_[v])}return n}t.decode=c}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.VERSIONS=[{infoBits:null,versionNumber:1,alignmentPatternCenters:[],errorCorrectionLevels:[{ecCodewordsPerBlock:7,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:13,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:13}]},{ecCodewordsPerBlock:17,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:2,alignmentPatternCenters:[6,18],errorCorrectionLevels:[{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:34}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:28}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]}]},{infoBits:null,versionNumber:3,alignmentPatternCenters:[6,22],errorCorrectionLevels:[{ecCodewordsPerBlock:15,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:55}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:13}]}]},{infoBits:null,versionNumber:4,alignmentPatternCenters:[6,26],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:80}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:32}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:5,alignmentPatternCenters:[6,30],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:43}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:11},{numBlocks:2,dataCodewordsPerBlock:12}]}]},{infoBits:null,versionNumber:6,alignmentPatternCenters:[6,34],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:27}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:31892,versionNumber:7,alignmentPatternCenters:[6,22,38],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:78}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:31}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:13},{numBlocks:1,dataCodewordsPerBlock:14}]}]},{infoBits:34236,versionNumber:8,alignmentPatternCenters:[6,24,42],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:97}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:38},{numBlocks:2,dataCodewordsPerBlock:39}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:18},{numBlocks:2,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:14},{numBlocks:2,dataCodewordsPerBlock:15}]}]},{infoBits:39577,versionNumber:9,alignmentPatternCenters:[6,26,46],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:12},{numBlocks:4,dataCodewordsPerBlock:13}]}]},{infoBits:42195,versionNumber:10,alignmentPatternCenters:[6,28,50],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68},{numBlocks:2,dataCodewordsPerBlock:69}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:43},{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]}]},{infoBits:48118,versionNumber:11,alignmentPatternCenters:[6,30,54],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:81}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:50},{numBlocks:4,dataCodewordsPerBlock:51}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:22},{numBlocks:4,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:12},{numBlocks:8,dataCodewordsPerBlock:13}]}]},{infoBits:51042,versionNumber:12,alignmentPatternCenters:[6,32,58],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:92},{numBlocks:2,dataCodewordsPerBlock:93}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:20},{numBlocks:6,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:55367,versionNumber:13,alignmentPatternCenters:[6,34,62],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:37},{numBlocks:1,dataCodewordsPerBlock:38}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:20},{numBlocks:4,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:11},{numBlocks:4,dataCodewordsPerBlock:12}]}]},{infoBits:58893,versionNumber:14,alignmentPatternCenters:[6,26,46,66],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:40},{numBlocks:5,dataCodewordsPerBlock:41}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:16},{numBlocks:5,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:5,dataCodewordsPerBlock:13}]}]},{infoBits:63784,versionNumber:15,alignmentPatternCenters:[6,26,48,70],errorCorrectionLevels:[{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:87},{numBlocks:1,dataCodewordsPerBlock:88}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:41},{numBlocks:5,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:7,dataCodewordsPerBlock:13}]}]},{infoBits:68472,versionNumber:16,alignmentPatternCenters:[6,26,50,74],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:98},{numBlocks:1,dataCodewordsPerBlock:99}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:70749,versionNumber:17,alignmentPatternCenters:[6,30,54,78],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:1,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22},{numBlocks:15,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:17,dataCodewordsPerBlock:15}]}]},{infoBits:76311,versionNumber:18,alignmentPatternCenters:[6,30,56,82],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:120},{numBlocks:1,dataCodewordsPerBlock:121}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:43},{numBlocks:4,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:1,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:19,dataCodewordsPerBlock:15}]}]},{infoBits:79154,versionNumber:19,alignmentPatternCenters:[6,30,58,86],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:113},{numBlocks:4,dataCodewordsPerBlock:114}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:44},{numBlocks:11,dataCodewordsPerBlock:45}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:21},{numBlocks:4,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:13},{numBlocks:16,dataCodewordsPerBlock:14}]}]},{infoBits:84390,versionNumber:20,alignmentPatternCenters:[6,34,62,90],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:41},{numBlocks:13,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:5,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:15},{numBlocks:10,dataCodewordsPerBlock:16}]}]},{infoBits:87683,versionNumber:21,alignmentPatternCenters:[6,28,50,72,94],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:116},{numBlocks:4,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:16},{numBlocks:6,dataCodewordsPerBlock:17}]}]},{infoBits:92361,versionNumber:22,alignmentPatternCenters:[6,26,50,74,98],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:111},{numBlocks:7,dataCodewordsPerBlock:112}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:13}]}]},{infoBits:96236,versionNumber:23,alignmentPatternCenters:[6,30,54,74,102],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:121},{numBlocks:5,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:47},{numBlocks:14,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:16,dataCodewordsPerBlock:15},{numBlocks:14,dataCodewordsPerBlock:16}]}]},{infoBits:102084,versionNumber:24,alignmentPatternCenters:[6,28,54,80,106],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:45},{numBlocks:14,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:30,dataCodewordsPerBlock:16},{numBlocks:2,dataCodewordsPerBlock:17}]}]},{infoBits:102881,versionNumber:25,alignmentPatternCenters:[6,32,58,84,110],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:106},{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:47},{numBlocks:13,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:110507,versionNumber:26,alignmentPatternCenters:[6,30,58,86,114],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:114},{numBlocks:2,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:46},{numBlocks:4,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:28,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:33,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]}]},{infoBits:110734,versionNumber:27,alignmentPatternCenters:[6,34,62,90,118],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:23},{numBlocks:26,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:117786,versionNumber:28,alignmentPatternCenters:[6,26,50,74,98,122],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:117},{numBlocks:10,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:45},{numBlocks:23,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:24},{numBlocks:31,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:31,dataCodewordsPerBlock:16}]}]},{infoBits:119615,versionNumber:29,alignmentPatternCenters:[6,30,54,78,102,126],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:116},{numBlocks:7,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:21,dataCodewordsPerBlock:45},{numBlocks:7,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:23},{numBlocks:37,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:26,dataCodewordsPerBlock:16}]}]},{infoBits:126325,versionNumber:30,alignmentPatternCenters:[6,26,52,78,104,130],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:115},{numBlocks:10,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:47},{numBlocks:10,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:25,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:25,dataCodewordsPerBlock:16}]}]},{infoBits:127568,versionNumber:31,alignmentPatternCenters:[6,30,56,82,108,134],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:3,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:46},{numBlocks:29,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:24},{numBlocks:1,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:133589,versionNumber:32,alignmentPatternCenters:[6,34,60,86,112,138],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:24},{numBlocks:35,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:35,dataCodewordsPerBlock:16}]}]},{infoBits:136944,versionNumber:33,alignmentPatternCenters:[6,30,58,86,114,142],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:21,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:24},{numBlocks:19,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:141498,versionNumber:34,alignmentPatternCenters:[6,34,62,90,118,146],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:6,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:44,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:59,dataCodewordsPerBlock:16},{numBlocks:1,dataCodewordsPerBlock:17}]}]},{infoBits:145311,versionNumber:35,alignmentPatternCenters:[6,30,54,78,102,126,150],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:121},{numBlocks:7,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:47},{numBlocks:26,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:39,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:41,dataCodewordsPerBlock:16}]}]},{infoBits:150283,versionNumber:36,alignmentPatternCenters:[6,24,50,76,102,128,154],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:121},{numBlocks:14,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:47},{numBlocks:34,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:46,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:64,dataCodewordsPerBlock:16}]}]},{infoBits:152622,versionNumber:37,alignmentPatternCenters:[6,28,54,80,106,132,158],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:46},{numBlocks:14,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:49,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:24,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:158308,versionNumber:38,alignmentPatternCenters:[6,32,58,84,110,136,162],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:122},{numBlocks:18,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:46},{numBlocks:32,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:48,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:15},{numBlocks:32,dataCodewordsPerBlock:16}]}]},{infoBits:161089,versionNumber:39,alignmentPatternCenters:[6,26,54,82,110,138,166],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:40,dataCodewordsPerBlock:47},{numBlocks:7,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:43,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:15},{numBlocks:67,dataCodewordsPerBlock:16}]}]},{infoBits:167017,versionNumber:40,alignmentPatternCenters:[6,30,58,86,114,142,170],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:118},{numBlocks:6,dataCodewordsPerBlock:119}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:18,dataCodewordsPerBlock:47},{numBlocks:31,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:24},{numBlocks:34,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:15},{numBlocks:61,dataCodewordsPerBlock:16}]}]}]}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e,t,n,r){var i=e.x-t.x+n.x-r.x,a=e.y-t.y+n.y-r.y;if(i===0&&a===0)return{a11:t.x-e.x,a12:t.y-e.y,a13:0,a21:n.x-t.x,a22:n.y-t.y,a23:0,a31:e.x,a32:e.y,a33:1};var o=t.x-n.x,s=r.x-n.x,c=t.y-n.y,l=r.y-n.y,u=o*l-s*c,d=(i*l-s*a)/u,f=(o*a-i*c)/u;return{a11:t.x-e.x+d*t.x,a12:t.y-e.y+d*t.y,a13:d,a21:r.x-e.x+f*r.x,a22:r.y-e.y+f*r.y,a23:f,a31:e.x,a32:e.y,a33:1}}function a(e,t,n,r){var a=i(e,t,n,r);return{a11:a.a22*a.a33-a.a23*a.a32,a12:a.a13*a.a32-a.a12*a.a33,a13:a.a12*a.a23-a.a13*a.a22,a21:a.a23*a.a31-a.a21*a.a33,a22:a.a11*a.a33-a.a13*a.a31,a23:a.a13*a.a21-a.a11*a.a23,a31:a.a21*a.a32-a.a22*a.a31,a32:a.a12*a.a31-a.a11*a.a32,a33:a.a11*a.a22-a.a12*a.a21}}function o(e,t){return{a11:e.a11*t.a11+e.a21*t.a12+e.a31*t.a13,a12:e.a12*t.a11+e.a22*t.a12+e.a32*t.a13,a13:e.a13*t.a11+e.a23*t.a12+e.a33*t.a13,a21:e.a11*t.a21+e.a21*t.a22+e.a31*t.a23,a22:e.a12*t.a21+e.a22*t.a22+e.a32*t.a23,a23:e.a13*t.a21+e.a23*t.a22+e.a33*t.a23,a31:e.a11*t.a31+e.a21*t.a32+e.a31*t.a33,a32:e.a12*t.a31+e.a22*t.a32+e.a32*t.a33,a33:e.a13*t.a31+e.a23*t.a32+e.a33*t.a33}}function s(e,t){for(var n=a({x:3.5,y:3.5},{x:t.dimension-3.5,y:3.5},{x:t.dimension-6.5,y:t.dimension-6.5},{x:3.5,y:t.dimension-3.5}),s=o(i(t.topLeft,t.topRight,t.alignmentPattern,t.bottomLeft),n),c=r.BitMatrix.createEmpty(t.dimension,t.dimension),l=function(e,t){var n=s.a13*e+s.a23*t+s.a33;return{x:(s.a11*e+s.a21*t+s.a31)/n,y:(s.a12*e+s.a22*t+s.a32)/n}},u=0;u<t.dimension;u++)for(var d=0;d<t.dimension;d++){var f=l(d+.5,u+.5);c.set(d,u,e.get(Math.floor(f.x),Math.floor(f.y)))}return{matrix:c,mappingFunction:l}}t.extract=s}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=4,i=.5,a=1.5,o=function(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)};function s(e){return e.reduce(function(e,t){return e+t})}function c(e,t,n){var r,i,a,s,c=o(e,t),l=o(t,n),u=o(e,n),d,f,p;return l>=c&&l>=u?(r=[t,e,n],d=r[0],f=r[1],p=r[2]):u>=l&&u>=c?(i=[e,t,n],d=i[0],f=i[1],p=i[2]):(a=[e,n,t],d=a[0],f=a[1],p=a[2]),(p.x-f.x)*(d.y-f.y)-(p.y-f.y)*(d.x-f.x)<0&&(s=[p,d],d=s[0],p=s[1]),{bottomLeft:d,topLeft:f,topRight:p}}function l(e,t,n,r){var i=(s(d(e,n,r,5))/7+s(d(e,t,r,5))/7+s(d(n,e,r,5))/7+s(d(t,e,r,5))/7)/4;if(i<1)throw Error(`Invalid module size`);var a=Math.round(o(e,t)/i),c=Math.round(o(e,n)/i),l=Math.floor((a+c)/2)+7;switch(l%4){case 0:l++;break;case 2:l--;break}return{dimension:l,moduleSize:i}}function u(e,t,n,r){var i=[{x:Math.floor(e.x),y:Math.floor(e.y)}],a=Math.abs(t.y-e.y)>Math.abs(t.x-e.x),s,c,l,u;a?(s=Math.floor(e.y),c=Math.floor(e.x),l=Math.floor(t.y),u=Math.floor(t.x)):(s=Math.floor(e.x),c=Math.floor(e.y),l=Math.floor(t.x),u=Math.floor(t.y));for(var d=Math.abs(l-s),f=Math.abs(u-c),p=Math.floor(-d/2),m=s<l?1:-1,h=c<u?1:-1,g=!0,_=s,v=c;_!==l+m;_+=m){var y=a?v:_,b=a?_:v;if(n.get(y,b)!==g&&(g=!g,i.push({x:y,y:b}),i.length===r+1))break;if(p+=f,p>0){if(v===u)break;v+=h,p-=d}}for(var x=[],S=0;S<r;S++)i[S]&&i[S+1]?x.push(o(i[S],i[S+1])):x.push(0);return x}function d(e,t,n,r){var i,a=t.y-e.y,o=t.x-e.x,s=u(e,t,n,Math.ceil(r/2)),c=u(e,{x:e.x-o,y:e.y-a},n,Math.ceil(r/2)),l=s.shift()+c.shift()-1;return(i=c.concat(l)).concat.apply(i,s)}function f(e,t){var n=s(e)/s(t),r=0;return t.forEach(function(t,i){r+=(e[i]-t*n)**2}),{averageSize:n,error:r}}function p(e,t,n){try{var r=d(e,{x:-1,y:e.y},n,t.length),i=d(e,{x:e.x,y:-1},n,t.length),a=d(e,{x:Math.max(0,e.x-e.y)-1,y:Math.max(0,e.y-e.x)-1},n,t.length),o=d(e,{x:Math.min(n.width,e.x+e.y)+1,y:Math.min(n.height,e.y+e.x)+1},n,t.length),s=f(r,t),c=f(i,t),l=f(a,t),u=f(o,t),p=Math.sqrt(s.error*s.error+c.error*c.error+l.error*l.error+u.error*u.error),m=(s.averageSize+c.averageSize+l.averageSize+u.averageSize)/4;return p+((s.averageSize-m)**2+(c.averageSize-m)**2+(l.averageSize-m)**2+(u.averageSize-m)**2)/m}catch{return 1/0}}function m(e,t){for(var n=Math.round(t.x);e.get(n,Math.round(t.y));)n--;for(var r=Math.round(t.x);e.get(r,Math.round(t.y));)r++;for(var i=(n+r)/2,a=Math.round(t.y);e.get(Math.round(i),a);)a--;for(var o=Math.round(t.y);e.get(Math.round(i),o);)o++;return{x:i,y:(a+o)/2}}function h(e){for(var t=[],n=[],o=[],l=[],u=function(r){for(var c=0,u=!1,d=[0,0,0,0,0],f=function(t){var o=e.get(t,r);if(o===u)c++;else{d=[d[1],d[2],d[3],d[4],c],c=1,u=o;var f=s(d)/7,p=Math.abs(d[0]-f)<f&&Math.abs(d[1]-f)<f&&Math.abs(d[2]-3*f)<3*f&&Math.abs(d[3]-f)<f&&Math.abs(d[4]-f)<f&&!o,m=s(d.slice(-3))/3,h=Math.abs(d[2]-m)<m&&Math.abs(d[3]-m)<m&&Math.abs(d[4]-m)<m&&o;if(p){var g=t-d[3]-d[4],_=g-d[2],v={startX:_,endX:g,y:r},y=n.filter(function(e){return _>=e.bottom.startX&&_<=e.bottom.endX||g>=e.bottom.startX&&_<=e.bottom.endX||_<=e.bottom.startX&&g>=e.bottom.endX&&d[2]/(e.bottom.endX-e.bottom.startX)<a&&d[2]/(e.bottom.endX-e.bottom.startX)>i});y.length>0?y[0].bottom=v:n.push({top:v,bottom:v})}if(h){var b=t-d[4],x=b-d[3],v={startX:x,y:r,endX:b},y=l.filter(function(e){return x>=e.bottom.startX&&x<=e.bottom.endX||b>=e.bottom.startX&&x<=e.bottom.endX||x<=e.bottom.startX&&b>=e.bottom.endX&&d[2]/(e.bottom.endX-e.bottom.startX)<a&&d[2]/(e.bottom.endX-e.bottom.startX)>i});y.length>0?y[0].bottom=v:l.push({top:v,bottom:v})}}},p=-1;p<=e.width;p++)f(p);t.push.apply(t,n.filter(function(e){return e.bottom.y!==r&&e.bottom.y-e.top.y>=2})),n=n.filter(function(e){return e.bottom.y===r}),o.push.apply(o,l.filter(function(e){return e.bottom.y!==r})),l=l.filter(function(e){return e.bottom.y===r})},d=0;d<=e.height;d++)u(d);t.push.apply(t,n.filter(function(e){return e.bottom.y-e.top.y>=2})),o.push.apply(o,l);var f=t.filter(function(e){return e.bottom.y-e.top.y>=2}).map(function(t){var n=(t.top.startX+t.top.endX+t.bottom.startX+t.bottom.endX)/4,r=(t.top.y+t.bottom.y+1)/2;if(e.get(Math.round(n),Math.round(r))){var i=[t.top.endX-t.top.startX,t.bottom.endX-t.bottom.startX,t.bottom.y-t.top.y+1],a=s(i)/i.length;return{score:p({x:Math.round(n),y:Math.round(r)},[1,1,3,1,1],e),x:n,y:r,size:a}}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score}).map(function(e,t,n){if(t>r)return null;var i=n.filter(function(e,n){return t!==n}).map(function(t){return{x:t.x,y:t.y,score:t.score+(t.size-e.size)**2/e.size,size:t.size}}).sort(function(e,t){return e.score-t.score});if(i.length<2)return null;var a=e.score+i[0].score+i[1].score;return{points:[e].concat(i.slice(0,2)),score:a}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score});if(f.length===0)return null;var h=c(f[0].points[0],f[0].points[1],f[0].points[2]),_=h.topRight,v=h.topLeft,y=h.bottomLeft,b=g(e,o,_,v,y),x=[];b&&x.push({alignmentPattern:{x:b.alignmentPattern.x,y:b.alignmentPattern.y},bottomLeft:{x:y.x,y:y.y},dimension:b.dimension,topLeft:{x:v.x,y:v.y},topRight:{x:_.x,y:_.y}});var S=m(e,_),C=m(e,v),w=m(e,y),T=g(e,o,S,C,w);return T&&x.push({alignmentPattern:{x:T.alignmentPattern.x,y:T.alignmentPattern.y},bottomLeft:{x:w.x,y:w.y},topLeft:{x:C.x,y:C.y},topRight:{x:S.x,y:S.y},dimension:T.dimension}),x.length===0?null:x}t.locate=h;function g(e,t,n,r,i){var a,c,u;try{a=l(r,n,i,e),c=a.dimension,u=a.moduleSize}catch{return null}var d={x:n.x-r.x+i.x,y:n.y-r.y+i.y},f=(o(r,i)+o(r,n))/2/u,m=1-3/f,h={x:r.x+m*(d.x-r.x),y:r.y+m*(d.y-r.y)},g=t.map(function(t){var n=(t.top.startX+t.top.endX+t.bottom.startX+t.bottom.endX)/4,r=(t.top.y+t.bottom.y+1)/2;if(e.get(Math.floor(n),Math.floor(r))){var i=[t.top.endX-t.top.startX,t.bottom.endX-t.bottom.startX,t.bottom.y-t.top.y+1];return s(i)/i.length,{x:n,y:r,score:p({x:Math.floor(n),y:Math.floor(r)},[1,1,1],e)+o({x:n,y:r},h)}}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score});return{alignmentPattern:f>=15&&g.length?g[0]:h,dimension:c}}})]).default})}))(),1);function LW(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function RW(e){let t=e.length%4,n=(e+(t?`=`.repeat(4-t):``)).replace(/-/g,`+`).replace(/_/g,`/`),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}async function zW(e,t){let n=t.writable.getWriter();n.write(e),n.close();let r=t.readable.getReader(),i=[],a=0;for(;;){let{value:e,done:t}=await r.read();if(t)break;e&&(i.push(e),a+=e.length)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}async function BW(e){let t=new TextEncoder().encode(e),n=await zW(t,new CompressionStream(`deflate-raw`));return n.length<t.length?`D`+LW(n):`R`+LW(t)}async function VW(e){let t=e.trim();if(!t)throw Error(`empty signal token`);let n=RW(t.slice(1));if(t[0]===`D`)return new TextDecoder().decode(await zW(n,new DecompressionStream(`deflate-raw`)));if(t[0]===`R`)return new TextDecoder().decode(n);throw Error(`unknown signal codec tag: ${t[0]}`)}async function HW(e){return BW(JSON.stringify({k:`offer`,v:2,hub:e.hubInstanceId,name:e.hubName,sdp:e.sdp,sec:e.secret}))}async function UW(e){try{let t=JSON.parse(await VW(e.trim()));return t.k!==`answer`||typeof t.sdp!=`string`?null:{sdp:t.sdp,deviceName:typeof t.dev==`string`?t.dev:`Mobile device`,platform:typeof t.plat==`string`?t.plat:`web`,secret:typeof t.sec==`string`?t.sec:``}}catch{return null}}function WW({open:e,onClose:t,onPaired:n}){let{t:r}=K(`settings`),[i,a]=(0,Q.useState)(`loading`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useCallback)(()=>{f.current!=null&&(cancelAnimationFrame(f.current),f.current=null),d.current?.getTracks().forEach(e=>e.stop()),d.current=null},[]),m=(0,Q.useCallback)(()=>{p(),a(`loading`),s(``),l(null),t()},[t,p]),h=(0,Q.useCallback)(async e=>{let t=await UW(e);if(!t){J.error(r(`pairWeb.notAnswer`));return}p(),a(`connecting`);try{let e=await fetch(`/api/mobile/webrtc/answer`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sdp:t.sdp})}),i=await e.json().catch(()=>({}));if(!e.ok||!i.ok)throw Error(`rejected`);a(`paired`),J.success(r(`pairWeb.pairedToast`)),n();let o=0,s=setInterval(()=>{n(),++o>=3&&(clearInterval(s),m())},1500)}catch{l(r(`pairWeb.answerRejected`)),a(`offer`)}},[r,p,n,m]);(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return l(null),a(`loading`),(async()=>{try{let e=await fetch(`/api/mobile/webrtc/offer`,{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json(),r=await HW({hubInstanceId:n.hubInstanceId,hubName:n.hubName,sdp:n.sdp,secret:n.secret});t||(s(r),a(`offer`))}catch(e){t||(l(e.message),a(`offer`))}})(),()=>{t=!0}},[e]),(0,Q.useEffect)(()=>{if(i!==`scanning`)return;let e=d.current,t=u.current;if(!e||!t)return;t.srcObject=e,t.play().catch(()=>{});let n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return;let a=()=>{if(d.current){if(t.videoWidth){n.width=t.videoWidth,n.height=t.videoHeight,r.drawImage(t,0,0);let e=r.getImageData(0,0,n.width,n.height),i=(0,IW.default)(e.data,e.width,e.height);if(i){h(i.data);return}}f.current=requestAnimationFrame(a)}};f.current=requestAnimationFrame(a)},[i,h]),(0,Q.useEffect)(()=>()=>p(),[p]);async function g(){if(l(null),!navigator.mediaDevices?.getUserMedia){J.error(r(`pairWeb.cameraFailed`,{message:`unsupported`}));return}try{d.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),a(`scanning`)}catch(e){J.error(r(`pairWeb.cameraFailed`,{message:e.message})),a(`offer`)}}return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-md`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:r(`pairWeb.title`)}),(0,$.jsx)(Mn,{children:r(`pairWeb.description`)})]}),c&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:r(`pairWeb.startFailed`,{error:c})}),i===`loading`&&(0,$.jsx)(`div`,{className:`h-56 bg-muted/30 rounded-lg animate-pulse`}),i===`offer`&&o&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,children:[(0,$.jsx)(`div`,{className:`bg-white p-3 rounded-lg`,children:(0,$.jsx)(FW,{value:o,size:220})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:r(`pairWeb.showThenScan`)}),(0,$.jsx)(Z,{onClick:()=>void g(),className:`gap-2`,children:r(`pairWeb.scanAnswer`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent-info underline`,onClick:()=>{navigator.clipboard?.writeText(o),J.success(r(`pairWeb.codeCopied`))},children:r(`pairWeb.copyCode`)})]}),i===`scanning`&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,children:[(0,$.jsx)(`video`,{ref:u,playsInline:!0,className:`w-full max-h-72 rounded-lg bg-black`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:r(`pairWeb.scanning`)}),(0,$.jsx)(Z,{variant:`outline`,onClick:()=>{p(),a(`offer`)},children:r(`pairWeb.cancel`)})]}),i===`connecting`&&(0,$.jsx)(`p`,{className:`py-6 text-center text-muted-foreground`,children:r(`pairWeb.connecting`)}),i===`paired`&&(0,$.jsx)(`p`,{className:`py-6 text-center text-accent-success font-medium`,children:r(`pairWeb.paired`)})]})})}var GW=typeof navigator<`u`&&/Win/i.test(navigator.platform);function KW(e){return!e||e.length<16?e??`—`:`${e.slice(0,8)}…${e.slice(-8)}`}function qW(){let{t:e}=K(`settings`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/mobile/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/mobile/devices`);e.ok&&i((await e.json()).devices)}catch{}},[]);(0,Q.useEffect)(()=>{l(),u()},[l,u]);let{registerHandler:d,unregisterHandler:f}=qe();(0,Q.useEffect)(()=>{let e=`mobile-access-devices`;return d(e,e=>{let t=e?.type;(t===`mobile.device_paired`||t===`mobile.device_revoked`)&&u()}),()=>f(e)},[d,f,u]);async function p(){if(t){o(!0);try{let e=t.enabled?`disable`:`enable`,r=await fetch(`/api/mobile/${e}`,{method:`POST`});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}n(await r.json())}catch(n){J.error(t.enabled?e(`mobile.disableFailed`,{message:n.message}):e(`mobile.enableFailed`,{message:n.message}))}finally{o(!1)}}}async function m(e){await fetch(`/api/mobile/devices/${e}`,{method:`DELETE`}).catch(()=>{}),u()}async function h(){if(window.confirm(e(`mobile.resetConfirm`))){o(!0);try{let t=await fetch(`/api/mobile/cert/rotate`,{method:`POST`});t.ok&&n(await t.json()),u(),J.success(e(`mobile.identityReset`))}finally{o(!1)}}}return t?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,$.jsx)(oc,{className:`h-3.5 w-3.5`}),` `,e(`mobile.heading`)]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`mobile.description`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:t.enabled?e(`mobile.accessOn`):e(`mobile.accessOff`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.running?e(`mobile.listeningOnPort`,{port:t.port}):e(`mobile.notListening`)})]}),(0,$.jsx)(Z,{variant:t.enabled?`outline`:`default`,disabled:a,onClick:p,children:t.enabled?e(`mobile.turnOff`):e(`mobile.turnOn`)})]}),t.enabled&&t.running&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(Z,{onClick:()=>c(!0),className:`gap-2`,children:[(0,$.jsx)(E,{className:`h-4 w-4`}),` `,e(`mobile.pairWebDevice`)]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(ic,{className:`h-3.5 w-3.5 text-accent-success`}),(0,$.jsx)(`span`,{title:t.certFingerprint??``,children:KW(t.certFingerprint)}),(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:h,disabled:a,children:e(`mobile.reset`)})]})]}),GW&&(0,$.jsx)(`p`,{className:`text-xs text-accent-warning`,children:e(`mobile.windowsFirewall`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground`,children:e(`mobile.pairedDevices`)}),r.filter(e=>!e.revoked).length===0?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e(`mobile.noDevices`)}):r.filter(e=>!e.revoked).map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/30 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`text-sm`,children:[t.name,` `,(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,t.platform]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`mobile.revokeDevice`,{name:t.name}),className:`text-muted-foreground hover:text-destructive`,onClick:()=>m(t.id),children:(0,$.jsx)(dn,{className:`h-4 w-4`})})]},t.id))]})]}),(0,$.jsx)(WW,{open:s,onClose:()=>c(!1),onPaired:u})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var JW=[`claude`,`codex`,`gemini`,`kimi`],YW=[`claude`,`gemini`,`kimi`],XW=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function ZW(e){return`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium transition-all duration-150 disabled:opacity-50 ${e?`border-accent-primary/50 bg-accent-primary/15 text-accent-primary shadow-[0_0_8px_-2px] shadow-accent-primary/30`:`border-border/60 bg-transparent text-muted-foreground/70 hover:border-border hover:text-foreground hover:bg-muted/30`}`}function QW(){let{t:e}=K(`mcp`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)({}),[_,v]=(0,Q.useState)(null),y=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/external-mcp`);if(!e.ok)return;let t=await e.json();t?.settings?.servers&&t?.discovered?.orphanIds&&n(t)}catch{}},[]);(0,Q.useEffect)(()=>{y()},[y]);let b=(0,Q.useCallback)(async r=>{if(!t)return;let a=t;n({...t,settings:{version:1,servers:r}}),i(!0);try{let e=await fetch(`${He}/api/external-mcp`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({servers:r})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();return t?.settings?.servers&&t?.discovered?.orphanIds&&n(t),!0}catch(t){n(a);let r=t.message;return J.error(e([`external.errors.${r}`,`external.updateFailed`])),!1}finally{i(!1)}},[t,e]),x=(0,Q.useMemo)(()=>{if(!t)return[];let{settings:e,discovered:n}=t,r=[],i=new Set(Object.keys(e.servers));for(let[t,i]of Object.entries(e.servers))r.push({id:t,name:i.name,source:i.source,sourceProvider:i.sourceProvider,providers:i.providers,orphan:n.orphanIds.includes(t),stored:!0});for(let e of YW)for(let t of n[e])i.has(t.id)||r.push({id:t.id,name:t.name,source:`discovered`,sourceProvider:e,providers:{},orphan:!1,stored:!1});return r.sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))},[t]),S=(0,Q.useCallback)((e,n)=>{if(!t)return;let r={...t.settings.servers},i=r[e.id],a={...i?.providers??{}};a[n]?delete a[n]:a[n]=!0,e.source===`discovered`&&Object.keys(a).length===0?delete r[e.id]:r[e.id]=i?{...i,providers:a}:{source:`discovered`,sourceProvider:e.sourceProvider,name:e.name,providers:a},b(r)},[t,b]),C=(0,Q.useCallback)(e=>{if(!t)return;let n={...t.settings.servers};delete n[e],b(n)},[t,b]),w=s.trim(),T=w!==``&&(!XW.test(w)||w===`specrails`),D=w!==``&&!T&&`c:${w}`!==_&&!!t?.settings.servers[`c:${w}`],O=w!==``&&!T&&!D&&l.trim()!==``,k=(0,Q.useCallback)(()=>{o(!1),v(null),c(``),u(``),f(``),m([]),g({})},[]),A=(0,Q.useCallback)(()=>{v(null),c(``),u(``),f(``),m([]),g({}),o(!0)},[]),j=(0,Q.useCallback)(e=>{let n=t?.settings.servers[e];!n||n.source!==`custom`||!n.transport||(v(e),c(n.name),u(n.transport.command),f(n.transport.args.join(` `)),m(Object.entries(n.transport.env).map(([e,t])=>({key:e,value:t}))),g({...n.providers}),o(!0))},[t]),M=(0,Q.useCallback)(async()=>{if(!t||!O)return;let e=w,n={};for(let e of p){let t=e.key.trim();t&&(n[t]=e.value)}let r={};for(let[e,t]of Object.entries(h))t&&(r[e]=!0);let i={...t.settings.servers};_&&_!==`c:${e}`&&delete i[_],i[`c:${e}`]={source:`custom`,name:e,providers:r,transport:{command:l.trim(),args:d.trim()?d.trim().split(/\s+/):[],env:n}},await b(i)&&k()},[t,O,w,l,d,p,h,_,b,k]);return t?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,"data-testid":`external-mcp-card`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-semibold text-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),` `,e(`external.heading`)]}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-[11px]`,disabled:r,onClick:()=>a&&!_?o(!1):A(),"data-testid":`external-mcp-add`,children:[(0,$.jsx)(cn,{className:`h-3 w-3`}),` `,e(`external.addCustom`)]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`external.description`)}),(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] text-accent-warning`,children:[(0,$.jsx)(fn,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),e(`external.warning`)]}),a&&(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-md border border-border/70 bg-muted/20 p-3`,"data-testid":`external-mcp-form`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-name`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.nameLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-name`,autoFocus:!0,value:s,onChange:e=>c(e.target.value),placeholder:e(`external.form.name`),className:`w-full rounded-md border bg-background px-2 py-1 text-xs transition-colors ${T||D?`border-destructive/60 focus:outline-destructive`:`border-border`}`}),(T||D)&&(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`external-mcp-name-hint`,children:e(T?`external.form.nameInvalid`:`external.form.nameTaken`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-command`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.commandLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-command`,value:l,onChange:e=>u(e.target.value),placeholder:e(`external.form.command`),className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-args`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.argsLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-args`,value:d,onChange:e=>f(e.target.value),placeholder:e(`external.form.args`),className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.envLabel`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>[...e,{key:``,value:``}]),className:`inline-flex items-center gap-1 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`external-mcp-env-add`,children:[(0,$.jsx)(cn,{className:`h-2.5 w-2.5`}),` `,e(`external.form.addVar`)]})]}),p.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`input`,{value:t.key,onChange:e=>m(t=>t.map((t,r)=>r===n?{...t,key:e.target.value}:t)),placeholder:e(`external.form.envKey`),"aria-label":`${e(`external.form.envKey`)} ${n+1}`,className:`w-2/5 rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`=`}),(0,$.jsx)(`input`,{value:t.value,onChange:e=>m(t=>t.map((t,r)=>r===n?{...t,value:e.target.value}:t)),placeholder:e(`external.form.envValue`),"aria-label":`${e(`external.form.envValue`)} ${n+1}`,className:`flex-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e=>e.filter((e,t)=>t!==n)),className:`text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`${e(`external.remove`)} ${n+1}`,children:(0,$.jsx)(dn,{className:`h-3 w-3`})})]},n))]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.enableFor`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:JW.map(e=>{let t=h[e]===!0;return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`custom · ${e}`,onClick:()=>g(t=>({...t,[e]:!t[e]})),className:ZW(t),"data-testid":`external-mcp-form-provider-${e}`,children:[t&&(0,$.jsx)(Ht,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-1.5 pt-0.5`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px]`,onClick:k,children:e(`external.form.cancel`)}),(0,$.jsx)(Z,{size:`sm`,className:`h-7 text-[11px]`,disabled:r||!O,onClick:()=>void M(),"data-testid":`external-mcp-form-save`,children:e(`external.form.save`)})]})]}),x.length===0&&t.discovered.codexNative.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:e(`external.empty`)}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[x.map(t=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border/60 px-2 py-1.5`,"data-testid":`external-mcp-row-${t.id}`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground min-w-0 truncate`,children:t.name}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-1.5 py-px text-[10px] text-muted-foreground`,children:t.source===`custom`?e(`external.sourceCustom`):e(`external.sourceDiscovered`,{provider:t.sourceProvider})}),t.orphan&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] text-accent-warning`,"data-testid":`external-mcp-orphan`,children:[(0,$.jsx)(fn,{className:`h-2.5 w-2.5`}),` `,e(`external.orphan`)]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex items-center gap-1`,children:JW.map(e=>{let n=t.providers[e]===!0;return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":`${t.name} · ${e}`,disabled:r,onClick:()=>S(t,e),className:ZW(n),children:[n&&(0,$.jsx)(Ht,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})}),t.stored&&t.source===`custom`&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(t.id),disabled:r,className:`text-muted-foreground hover:text-foreground`,"aria-label":e(`external.edit`),"data-testid":`external-mcp-edit-${t.id}`,children:(0,$.jsx)(an,{className:`h-3 w-3`})}),t.stored&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t.id),disabled:r,className:`text-muted-foreground hover:text-destructive`,"aria-label":e(`external.remove`),"data-testid":`external-mcp-remove-${t.id}`,children:(0,$.jsx)(dn,{className:`h-3 w-3`})})]})]},t.id)),t.discovered.codexNative.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border/40 px-2 py-1.5 opacity-70`,"data-testid":`external-mcp-codex-${t}`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground min-w-0 truncate`,children:t}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-1.5 py-px text-[10px] text-muted-foreground`,children:e(`external.codexNative`)})]},`codex:${t}`))]})]}):(0,$.jsx)(`div`,{className:`h-16 bg-muted/30 rounded-lg animate-pulse`,"data-testid":`external-mcp-skeleton`})}async function $W(e){try{if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function eG(e){return JSON.stringify({mcpServers:{specrails:{command:e.bridgeCommand}}},null,2)}function tG(){let{t:e}=K(`mcp`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/mcp-admin/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/mcp-admin/config`);e.ok&&i(await e.json())}catch{}},[]);(0,Q.useEffect)(()=>{l(),u()},[l,u]);let d=(0,Q.useCallback)(async()=>{if(t){o(!0);try{let e=t.enabled?`disable`:`enable`,n=await fetch(`${He}/api/mcp-admin/${e}`,{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}await l()}catch(n){J.error(t.enabled?e(`enable.disableFailed`,{message:n.message}):e(`enable.enableFailed`,{message:n.message}))}finally{o(!1)}}},[t,l,e]),f=(0,Q.useCallback)(async r=>{if(!t)return;o(!0);let i=!t.tiers[r];try{let e=await fetch(`${He}/api/mcp-admin/tiers`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[r]:i})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();n(e=>e&&{...e,tiers:t.tiers})}catch(t){J.error(e(`tiers.updateFailed`,{message:t.message}))}finally{o(!1)}},[t,e]),p=(0,Q.useCallback)(async()=>{r&&(await $W(eG(r))?(c(`config`),window.setTimeout(()=>c(e=>e===`config`?null:e),1500)):J.error(e(`config.copyFailed`)))},[r,e]),m=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${He}/api/mcp-admin/token`);if(!t.ok)throw Error(`HTTP ${t.status}`);let{token:n}=await t.json();await $W(n)?(c(`token`),window.setTimeout(()=>c(e=>e===`token`?null:e),1500)):J.error(e(`config.copyFailed`))}catch{J.error(e(`config.copyFailed`))}},[e]),h=(0,Q.useCallback)(async()=>{if(window.confirm(e(`token.regenerateConfirm`))){o(!0);try{let t=await fetch(`${He}/api/mcp-admin/regenerate-token`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}`);await l(),J.success(e(`token.regenerated`))}catch(t){J.error(e(`token.regenerateFailed`,{message:t.message}))}finally{o(!1)}}},[l,e]);if(!t)return(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`});let g=[{key:`write`,label:e(`tiers.write`),help:e(`tiers.writeHelp`)},{key:`aiSpawn`,label:e(`tiers.aiSpawn`),help:e(`tiers.aiSpawnHelp`)},{key:`destructive`,label:e(`tiers.destructive`),help:e(`tiers.destructiveHelp`)}];return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,$.jsx)(Us,{className:`h-3.5 w-3.5`}),` `,e(`heading`)]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`explainer.what`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80`,children:e(`explainer.how`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:t.enabled?e(`enable.on`):e(`enable.off`)}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[t.running?e(`enable.running`,{count:t.toolCount}):e(`enable.stopped`),t.enabled&&t.activeSessions>0&&(0,$.jsxs)($.Fragment,{children:[` · `,e(`enable.activeSessions`,{count:t.activeSessions})]})]})]}),(0,$.jsx)(Z,{variant:t.enabled?`outline`:`default`,disabled:a,onClick:()=>void d(),children:t.enabled?e(`enable.turnOff`):e(`enable.turnOn`)})]}),t.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`tiers.heading`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`explainer.grants`)}),(0,$.jsxs)(`label`,{className:`flex items-start gap-2 opacity-70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!0,className:`mt-0.5`,"aria-label":e(`tiers.read`)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e(`tiers.read`)}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e(`tiers.readHelp`)})]})]}),g.map(e=>(0,$.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.tiers[e.key],disabled:a,onChange:()=>void f(e.key),className:`mt-0.5`,"aria-label":e.label}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e.help})]})]},e.key))]}),r&&(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`config.heading`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,"data-testid":`mcp-copy-config`,children:s===`config`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}),` `,e(`config.configCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`h-3 w-3`}),` `,e(`config.copyConfig`)]})})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`config.description`)}),(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-muted/40 p-2 text-[10px] leading-relaxed text-foreground`,children:eG(r)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`token.heading`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`token.description`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:e(`token.hint`,{hint:t.tokenHint})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,"data-testid":`mcp-copy-token`,children:s===`token`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}),` `,e(`token.tokenCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`h-3 w-3`}),` `,e(`token.copyToken`)]})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void h(),disabled:a,className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`mcp-regenerate-token`,children:[(0,$.jsx)(Js,{className:`h-3 w-3`}),` `,e(`token.regenerate`)]})]})]})]})]}),(0,$.jsx)(QW,{})]})}var nG=`specrails-os-notifications`,rG={enabled:!0,filter:`all`};function iG(){try{let e=localStorage.getItem(nG);if(!e)return rG;let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:rG.enabled,filter:t.filter===`completed`||t.filter===`failed`?t.filter:rG.filter}}catch{return rG}}function aG(e){localStorage.setItem(nG,JSON.stringify(e))}function oG({setActiveProjectId:e,projectsById:t}={}){let n=v(),r=(0,Q.useRef)(n);(0,Q.useEffect)(()=>{r.current=n},[n]);let i=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{i.current=e},[e]);let a=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{a.current=t},[t]);let o=(0,Q.useRef)(new Map),s=(0,Q.useRef)(new Map),{registerHandler:c,unregisterHandler:l}=qe(),u=(0,Q.useCallback)(e=>{let t=e;if(!t)return;if(t.type===`job.stuck`&&typeof t.jobId==`string`){let e=Array.isArray(t.actions)?t.actions.filter(e=>e===`stop`):[];f(t.jobId,t.projectId??null,t.staleMs??0,e);return}if(t.type===`loop.provider_limit`&&typeof t.runId==`string`){d(t.runId,t.projectId??null,typeof t.provider==`string`?t.provider:``,typeof t.resetsAt==`string`&&t.resetsAt?t.resetsAt:null,typeof t.message==`string`?t.message:``);return}if(t.type!==`queue`||!Array.isArray(t.jobs))return;let n=t.projectId??null;for(let e of t.jobs){let t=o.current.get(e.id),r=e.status;n&&s.current.set(e.id,n),t===`running`&&(r===`completed`||r===`failed`)&&m(e,n),o.current.set(e.id,r)}},[]);function d(e,t,n,r,i){let o=iG();if(!o.enabled||o.filter===`completed`)return;let s=t?a.current?.get(t)??``:``,c=n?n.charAt(0).toUpperCase()+n.slice(1):`AI`,l=r?G.t(`commands:notifications.providerLimitBody`,{provider:c,resetsAt:r}):G.t(`commands:notifications.providerLimitBodyNoReset`,{provider:c}),u=G.t(`commands:notifications.providerLimit`);J.error(u,{id:`provider-limit:${e}`,description:`${s?`[${s}] `:``}${l}${i?` · ${i}`:``}`,duration:6e4}),!(typeof Notification>`u`)&&Notification.permission===`granted`&&(()=>{let t=new Notification(u,{body:s?`[${s}] ${l}`:l,tag:`specrails-provider-limit:${e}`});t.onclick=()=>{window.focus(),t.close()}})()}function f(e,t,n,o=[]){let s=iG();if(!s.enabled||s.filter===`completed`)return;let c=Math.max(1,Math.round(n/6e4)),l=t?a.current?.get(t)??``:``,u=G.t(`commands:notifications.jobStuckBody`,{count:c});if(t&&o.includes(`stop`)&&J.warning(G.t(`commands:notifications.jobStuck`),{id:`job-stuck:${e}`,description:l?`[${l}] ${u}`:u,duration:2e4,action:{label:G.t(`commands:notifications.jobStuckStop`),onClick:()=>{p(t,e)}}}),typeof Notification>`u`)return;function d(){let n=new Notification(G.t(`commands:notifications.jobStuck`),{body:l?`[${l}] ${u}`:u,tag:`specrails-job-stuck:${e}`});n.onclick=()=>{window.focus(),t&&i.current?(i.current(t),setTimeout(()=>{r.current(`/jobs/${e}`)},100)):r.current(`/jobs/${e}`),n.close()}}Notification.permission===`granted`?d():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&d()})}async function p(e,t){try{let n=await fetch(`/api/projects/${e}/jobs/${t}/cancel`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);J.success(G.t(`commands:notifications.jobStuckStopped`),{id:`job-stuck:${t}`})}catch{J.error(G.t(`commands:notifications.jobStuckStopFailed`),{id:`job-stuck:${t}`})}}function m(e,t){if(typeof Notification>`u`||typeof document<`u`&&!document.hidden)return;let n=iG();if(!n.enabled||n.filter===`completed`&&e.status!==`completed`||n.filter===`failed`&&e.status!==`failed`)return;function o(){let n=e.status===`completed`?G.t(`commands:notifications.jobCompleted`):G.t(`commands:notifications.jobFailed`),o=t?a.current?.get(t)??``:``,s=e.command?e.command.slice(0,80):G.t(`commands:notifications.unknownCommand`),c=o?`[${o}] ${s}`:s,l=new Notification(n,{body:c,tag:`specrails-job:${e.id}:${e.status}`}),u=e.id,d=t;l.onclick=()=>{window.focus(),d&&i.current?(i.current(d),setTimeout(()=>{r.current(`/jobs/${u}`)},100)):r.current(`/jobs/${u}`),l.close()}}Notification.permission===`granted`?o():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&o()})}(0,Q.useLayoutEffect)(()=>(c(`os-notifications`,u),()=>l(`os-notifications`)),[u,c,l])}var sG=[{value:`job.completed`,labelKey:`webhooks.eventJobCompleted`},{value:`job.failed`,labelKey:`webhooks.eventJobFailed`},{value:`daily_budget_exceeded`,labelKey:`webhooks.eventDailyBudgetExceeded`}];function cG({project:e,onRemove:t}){let{t:n}=K(`settings`);return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 p-2.5 rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:e.path})]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`h-6 px-2 text-[10px] text-muted-foreground hover:text-destructive shrink-0`,onClick:()=>t(e.id),children:n(`common:actions.remove`)})]})}var lG=[{id:`appearance`,icon:Fs,labelKey:`desktop.nav.appearance`},{id:`effects`,icon:un,labelKey:`desktop.nav.effects`},{id:`specrailsAgents`,icon:wo,labelKey:`desktop.nav.specrailsAgents`},{id:`code`,icon:Lo,labelKey:`desktop.nav.code`},{id:`terminal`,icon:sc,labelKey:`desktop.nav.terminal`},{id:`updates`,icon:Js,labelKey:`desktop.nav.updates`},{id:`mobile`,icon:oc,labelKey:`desktop.nav.mobile`},{id:`mcp`,icon:So,labelKey:`desktop.nav.mcp`},{id:`projects`,icon:as,labelKey:`desktop.nav.projects`},{id:`advanced`,icon:ac,labelKey:`desktop.nav.advanced`},{id:`webhooks`,icon:hc,labelKey:`desktop.nav.webhooks`},{id:`about`,icon:vs,labelKey:`desktop.nav.about`}];function uG({open:e,onClose:t,onOpenOnboarding:n}){let{t:r}=K(`settings`),{projects:i,removeProject:a}=at(),[o,s]=(0,Q.useState)(`appearance`),c=e=>X(`space-y-5`,o===e?``:`hidden`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)([]),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)([`job.completed`,`job.failed`]),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(()=>iG().enabled),[N,P]=(0,Q.useState)(()=>iG().filter);function F(e){M(e),aG({enabled:e,filter:N}),J.success(r(e?`notifications.enabledToast`:`notifications.disabledToast`))}function I(e){P(e),aG({enabled:j,filter:e})}let L=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/webhooks`);if(e.ok){let t=await e.json();S(t.webhooks)}}catch{}},[]);(0,Q.useEffect)(()=>{if(!e)return;f(!0);async function t(){try{let e=await fetch(`/api/settings`);if(e.ok){let t=await e.json();u(t),m(t.costAlertThresholdUsd==null?``:String(t.costAlertThresholdUsd))}}catch{}finally{f(!1)}}t(),L()},[e,L]),(0,Q.useEffect)(()=>{e&&fetch(`/api/budget`).then(e=>e.json()).then(e=>{e.desktopDailyBudgetUsd==null?v(``):v(String(e.desktopDailyBudgetUsd))}).catch(()=>{})},[e]);async function R(){g(!0);try{let e=p.trim()===``?null:parseFloat(p);if(e!==null&&(isNaN(e)||e<=0)){J.error(r(`budget.invalidNumber`));return}(await fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({costAlertThresholdUsd:e})})).ok?J.success(e==null?r(`desktop.costAlertsDisabled`):r(`budget.alertSet`,{amount:e})):J.error(r(`budget.saveThresholdFailed`))}catch{J.error(r(`budget.saveThresholdFailed`))}finally{g(!1)}}async function z(){b(!0);try{let e=_.trim()===``?null:parseFloat(_);if(e!==null&&(isNaN(e)||e<=0)){J.error(r(`budget.invalidNumber`));return}(await fetch(`/api/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({desktopDailyBudgetUsd:e})})).ok?J.success(e==null?r(`desktop.dailyBudgetRemoved`):r(`desktop.dailyBudgetSet`,{amount:e})):J.error(r(`desktop.dailyBudgetSaveFailed`))}catch{J.error(r(`desktop.dailyBudgetSaveFailed`))}finally{b(!1)}}async function B(e){try{await a(e),J.success(r(`desktop.projectRemoved`))}catch(e){J.error(r(`desktop.projectRemoveFailed`),{description:e.message})}}async function ee(){if(!C.trim()){J.error(r(`webhooks.urlRequired`));return}if(D.length===0){J.error(r(`webhooks.selectEvent`));return}A(!0);try{let e=await fetch(`/api/webhooks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:C.trim(),secret:T.trim(),events:D})});if(e.ok)J.success(r(`webhooks.added`)),w(``),E(``),O([`job.completed`,`job.failed`]),await L();else{let t=await e.json();J.error(t.error??r(`webhooks.addFailed`))}}catch{J.error(r(`webhooks.addFailed`))}finally{A(!1)}}async function V(e,t){try{await fetch(`/api/webhooks/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),await L()}catch{J.error(r(`webhooks.updateFailed`))}}async function H(e){try{(await fetch(`/api/webhooks/${e}`,{method:`DELETE`})).ok&&(J.success(r(`webhooks.removed`)),await L())}catch{J.error(r(`webhooks.removeFailed`))}}async function te(e){try{(await fetch(`/api/webhooks/${e}/test`,{method:`POST`})).ok&&J.success(r(`webhooks.testPingSent`))}catch{J.error(r(`webhooks.testPingFailed`))}}function ne(e){O(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(nc,{className:`w-4 h-4`}),r(`desktop.title`)]}),(0,$.jsx)(Mn,{children:r(`desktop.description`)})]}),d?(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,$.jsx)(`div`,{className:`h-16 bg-muted/30 rounded-lg animate-pulse`})]}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,$.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:lG.map(e=>{if(e.id===`mcp`&&!xe)return null;let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,$.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:r(e.labelKey)})]},e.id)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:c(`appearance`),children:[(0,$.jsx)(xU,{}),(0,$.jsx)(kU,{})]}),(0,$.jsx)(`div`,{className:c(`effects`),children:(0,$.jsx)(yU,{})}),(0,$.jsx)(`div`,{className:c(`specrailsAgents`),children:(0,$.jsx)(PU,{})}),(0,$.jsx)(`div`,{className:c(`code`),children:(0,$.jsx)(AU,{})}),(0,$.jsxs)(`div`,{className:c(`updates`),children:[(0,$.jsx)(cW,{}),(0,$.jsx)(RU,{})]}),(0,$.jsx)(`div`,{className:c(`mobile`),children:(0,$.jsx)(qW,{})}),xe&&(0,$.jsx)(`div`,{className:c(`mcp`),children:(0,$.jsx)(tG,{})}),(0,$.jsx)(`div`,{className:c(`projects`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.registeredProjects`)}),i.length===0?(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border p-4 text-center`,children:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`desktop.noProjects`)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:i.map(e=>(0,$.jsx)(cG,{project:e,onRemove:B},e.id))})]})}),(0,$.jsxs)(`div`,{className:c(`advanced`),children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.budgetAlertsHeading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`desktop.dailyBudgetLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.dailyBudgetHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:_,onChange:e=>v(e.target.value),placeholder:r(`desktop.dailyBudgetPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:y,onClick:()=>void z(),children:r(`common:actions.save`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.perJobHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:p,onChange:e=>m(e.target.value),placeholder:r(`budget.perJobPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:h,onClick:R,children:r(`common:actions.save`)})]})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`notifications.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`notifications.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>F(e.target.checked),className:`w-3.5 h-3.5`,"data-testid":`notif-toggle`}),(0,$.jsx)(bo,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs`,children:r(`notifications.enableLabel`)})]}),j&&(0,$.jsxs)(`div`,{className:`space-y-1.5 pl-6`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`notifications.notifyOn`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:[{value:`all`,label:r(`notifications.filterAll`)},{value:`completed`,label:r(`notifications.filterCompleted`)},{value:`failed`,label:r(`notifications.filterFailed`)}].map(({value:e,label:t})=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`notif-filter`,checked:N===e,onChange:()=>I(e),className:`w-3 h-3`}),t]},e))})]})]})]})]}),(0,$.jsx)(`div`,{className:c(`webhooks`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`webhooks.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`webhooks.description`,components:{code:(0,$.jsx)(`code`,{className:`font-mono`})}})}),x.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>{let t=(()=>{try{return JSON.parse(e.events)}catch{return[]}})();return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border p-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-mono truncate`,children:e.url}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t.join(`, `)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{onClick:()=>void V(e.id,!e.enabled),className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${e.enabled?`bg-green-500/10 aurora-light:bg-accent-success/10 text-green-600 aurora-light:text-accent-success dark:text-green-400`:`bg-muted text-muted-foreground`}`,title:e.enabled?r(`webhooks.disable`):r(`webhooks.enable`),children:e.enabled?r(`webhooks.statusOn`):r(`webhooks.statusOff`)}),(0,$.jsx)(`button`,{onClick:()=>void te(e.id),className:`text-muted-foreground hover:text-foreground p-0.5`,title:r(`webhooks.sendTestPing`),children:(0,$.jsx)(hn,{className:`w-3 h-3`})}),(0,$.jsx)(`button`,{onClick:()=>void H(e.id),className:`text-muted-foreground hover:text-destructive p-0.5`,title:r(`common:actions.remove`),children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]})]},e.id)})}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-muted-foreground`,children:r(`webhooks.addHeading`)}),(0,$.jsx)(Qk,{value:C,onChange:e=>w(e.target.value),placeholder:`https://hooks.example.com/...`,className:`h-7 text-xs font-mono`}),(0,$.jsx)(Qk,{value:T,onChange:e=>E(e.target.value),placeholder:r(`webhooks.secretPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:sG.map(({value:e,labelKey:t})=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:D.includes(e),onChange:()=>ne(e),className:`w-3 h-3`}),r(t)]},e))}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs w-full`,disabled:k||!C.trim(),onClick:()=>void ee(),children:[(0,$.jsx)(cn,{className:`w-3 h-3 mr-1`}),r(`webhooks.addButton`)]})]})]})]})}),(0,$.jsx)(`div`,{className:c(`about`),children:n&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.onboardingHeading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`desktop.platformTour`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.platformTourDescription`)})]}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,onClick:n,"data-testid":`replay-onboarding`,children:[(0,$.jsx)(ds,{className:`w-3 h-3 mr-1`}),r(`desktop.replayTour`)]})]})})]})}),(0,$.jsx)(`div`,{className:c(`terminal`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.terminalPanelHeading`)}),(0,$.jsx)(rU,{mode:`desktop`})]})}),(0,$.jsx)(`div`,{className:c(`about`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.infoHeading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoPort`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:l?.port??4200})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoProjects`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:i.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoDb`)}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`~/.specrails/desktop.sqlite`})]})]})]})})]})]})]})})}var dG=[{keys:`?`,descriptionKey:`shortcuts.items.showCheatsheet`,category:`general`},{keys:`Esc`,descriptionKey:`shortcuts.items.closeModal`,category:`general`},{keys:`⌘B`,descriptionKey:`shortcuts.items.toggleRightSidebar`,category:`general`},{keys:`⌥⌘B`,descriptionKey:`shortcuts.items.toggleLeftSidebar`,category:`general`},{keys:`⌘J`,descriptionKey:`shortcuts.items.toggleTerminal`,category:`general`},...P?[{keys:`⌘⇧A`,descriptionKey:`shortcuts.items.toggleAgent`,category:`general`}]:[],{keys:V?`⌘1–5`:`⌘1–4`,descriptionKey:V?`shortcuts.items.navigateProjectPageWithAgents`:`shortcuts.items.navigateProjectPage`,category:`general`},{keys:`⌥⌘1–9`,descriptionKey:`shortcuts.items.switchProject`,category:`general`},{keys:`G D`,descriptionKey:`shortcuts.items.goDashboard`,category:`navigation`},{keys:`G J`,descriptionKey:`shortcuts.items.goActivity`,category:`navigation`},{keys:`G A`,descriptionKey:`shortcuts.items.goAnalytics`,category:`navigation`},{keys:`G S`,descriptionKey:`shortcuts.items.goSettings`,category:`navigation`},{keys:`J`,descriptionKey:`shortcuts.items.nextItem`,category:`actions`},{keys:`K`,descriptionKey:`shortcuts.items.prevItem`,category:`actions`}];function fG(e){let t=e.target;if(!t)return!1;let n=t.tagName;return!!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable)}function pG(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`[role="dialog"]`)}function mG(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`.specrails-xterm-container, .xterm`)}function hG({onOpenCheatsheet:e,onListNavigate:t,onToggleLeftSidebar:n,onToggleRightSidebar:r,onSwitchProject:i,onSwitchProjectPage:a,onToggleTerminalPanel:o,onToggleAgentChat:s}){let c=v(),l=p(),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(e);f.current=e;let m=(0,Q.useRef)(t);m.current=t;let h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(r);g.current=r;let _=(0,Q.useRef)(i);_.current=i;let y=(0,Q.useRef)(a);y.current=a;let b=(0,Q.useRef)(o);b.current=o;let x=(0,Q.useRef)(s);x.current=s;let S=(0,Q.useRef)(l);S.current=l,(0,Q.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.code===`KeyJ`){if(pG(e))return;e.preventDefault(),b.current?.();return}if((e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.code===`KeyA`){if(pG(e))return;e.preventDefault(),x.current?.();return}if(fG(e)||mG(e)||pG(e))return;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.code===`KeyB`){e.preventDefault(),g.current?.();return}if((e.metaKey||e.ctrlKey)&&e.altKey&&e.code===`KeyB`){e.preventDefault(),h.current?.();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.code.match(/^Digit([1-9])$/);if(t){e.preventDefault(),y.current?.(parseInt(t[1],10));return}}if((e.metaKey||e.ctrlKey)&&e.altKey&&!e.shiftKey){let t=e.code.match(/^Digit([1-9])$/);if(t){e.preventDefault(),_.current?.(parseInt(t[1],10));return}}if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key;if(u.current===`g`){d.current&&clearTimeout(d.current),u.current=null;let n=t.toUpperCase(),r={D:`/`,P:`/`,J:`/activity`,A:`/analytics`,S:`/settings`};if(r[n]){e.preventDefault(),c(r[n]);return}return}if(t===`?`){e.preventDefault(),f.current();return}if(t===`g`){e.preventDefault(),u.current=`g`,d.current=setTimeout(()=>{u.current=null},800);return}if(t===`j`){m.current?.(`down`);return}if(t===`k`){m.current?.(`up`);return}}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),d.current&&clearTimeout(d.current)}},[c])}function gG(){let[e,t]=(0,Q.useState)(!1);return{cheatsheetOpen:e,setCheatsheetOpen:t,openCheatsheet:(0,Q.useCallback)(()=>t(!0),[]),closeCheatsheet:(0,Q.useCallback)(()=>t(!1),[])}}var _G={general:`shortcuts.categories.general`,navigation:`shortcuts.categories.navigation`,actions:`shortcuts.categories.actions`},vG=[`general`,`navigation`,`actions`];function yG({children:e}){return(0,$.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.5rem] h-6 px-1.5 rounded border border-border/50 bg-card/80 font-mono text-xs text-foreground`,children:e})}function bG({shortcut:e}){let{t}=K(`commands`),n=jH(e.keys).split(` `);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(e.descriptionKey)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 ml-4 shrink-0`,children:n.map((e,t)=>(0,$.jsx)(yG,{children:e},t))})]})}function xG({open:e,onOpenChange:t}){let{t:n}=K(`commands`),r=vG.map(e=>({category:e,label:n(_G[e]),shortcuts:dG.filter(t=>t.category===e)})).filter(e=>e.shortcuts.length>0);return(0,$.jsx)(Hn,{open:e,onOpenChange:t,children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-md`,"data-testid":`shortcuts-cheatsheet`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:n(`shortcuts.title`)}),(0,$.jsx)(Mn,{children:(0,$.jsxs)(tt,{i18nKey:`shortcuts.subtitle`,ns:`commands`,children:[`Press `,(0,$.jsx)(yG,{children:`?`}),` anywhere to toggle this panel`]})})]}),(0,$.jsx)(`div`,{className:`space-y-4 mt-2`,children:r.map(e=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-accent-primary mb-2`,children:e.label}),(0,$.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.shortcuts.map(e=>(0,$.jsx)(bG,{shortcut:e},e.keys))})]},e.category))})]})})}function SG(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function CG(){return SG()&&/mac/i.test(navigator.platform)}function wG({onClick:e,icon:t,hoverColor:n=`var(--color-accent)`,hoverTextColor:r=`var(--color-accent-foreground)`,ariaLabel:i}){let[a,o]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{onClick:e,"aria-label":i,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:34,height:28,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:7,border:`none`,cursor:`pointer`,background:a?n:`transparent`,color:a?r:`var(--color-muted-foreground)`,transition:`background 0.12s ease, color 0.12s ease`,WebkitAppRegion:`no-drag`},children:t})}function TG({projectName:e,hidden:t=!1}){let{t:n}=K(`nav`),[r,i]=(0,Q.useState)(!1);function a(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,bubbles:!0}))}return(0,$.jsxs)(`button`,{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":n(`titleBar.searchShortcut`),"aria-hidden":t||void 0,tabIndex:t?-1:void 0,style:{position:`absolute`,left:`50%`,top:`50%`,transform:`translate(-50%, -50%) scale(${t?.96:1})`,width:`40%`,maxWidth:360,minWidth:160,height:20,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,paddingLeft:8,paddingRight:8,borderRadius:9999,border:`1px solid color-mix(in srgb, var(--color-border) 70%, transparent)`,cursor:`pointer`,background:r?`color-mix(in srgb, var(--color-accent) 82%, transparent)`:`color-mix(in srgb, var(--color-surface) 72%, transparent)`,color:e?`var(--color-foreground)`:`var(--color-muted-foreground)`,fontSize:12,fontWeight:400,letterSpacing:0,opacity:+!t,pointerEvents:t?`none`:`auto`,transition:`background 0.12s ease, opacity 0.22s ease, transform 0.22s ease`,WebkitAppRegion:`no-drag`,overflow:`hidden`,whiteSpace:`nowrap`},children:[(0,$.jsx)(ln,{size:11,style:{flexShrink:0,opacity:e?.72:.48}}),(0,$.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e??n(`titleBar.searchPlaceholder`)})]})}function EG(){return SG()?CG()?(0,$.jsx)(DG,{}):(0,$.jsx)(OG,{}):null}function DG(){let{projects:e,activeProjectId:t}=at(),{uiMode:n}=Ij();return(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,style:{position:`relative`,height:28,minHeight:28,background:`var(--color-background-deep)`,display:`flex`,alignItems:`center`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:(0,$.jsx)(TG,{projectName:(e.find(e=>e.id===t)??null)?.name??null,hidden:n===`agent`})})}function OG(){let{t:e}=K(`nav`),{projects:t,activeProjectId:n}=at(),{uiMode:r}=Ij(),i=t.find(e=>e.id===n)??null,a=(0,Q.useMemo)(()=>xM(),[]),[o,s]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1,t=0,n,r=async()=>{let n=++t;try{let r=await a.isMaximized?.();!e&&n===t&&s(r===!0)}catch{}};return r(),a.onResized?.(()=>{r()}).then(t=>{e?t():n=t}).catch(()=>{}),()=>{e=!0,n?.()}},[a]);let c=(0,Q.useCallback)(()=>{a.minimize()},[a]),l=(0,Q.useCallback)(()=>{a.toggleMaximize()},[a]),u=(0,Q.useCallback)(()=>{a.close()},[a]);return(0,$.jsxs)(`div`,{"data-tauri-drag-region":!0,style:{position:`relative`,height:36,minHeight:36,background:`var(--color-background-deep)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`0 10px`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:[(0,$.jsx)(TG,{projectName:i?.name??null,hidden:r===`agent`}),(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,style:{minWidth:116,height:`100%`}}),(0,$.jsxs)(`div`,{style:{minWidth:116,display:`flex`,justifyContent:`flex-end`,gap:2,alignItems:`center`,WebkitAppRegion:`no-drag`},children:[(0,$.jsx)(wG,{onClick:c,icon:(0,$.jsx)(As,{size:14,strokeWidth:1.8}),ariaLabel:e(`titleBar.minimizeWindow`)}),(0,$.jsx)(wG,{onClick:l,icon:o?(0,$.jsx)(Ho,{size:12,strokeWidth:1.8}):(0,$.jsx)(sn,{size:12,strokeWidth:1.8}),ariaLabel:e(o?`titleBar.restoreWindow`:`titleBar.maximizeWindow`)}),(0,$.jsx)(wG,{onClick:u,icon:(0,$.jsx)(mn,{size:15,strokeWidth:1.8}),hoverColor:`var(--color-destructive)`,hoverTextColor:`var(--color-destructive-foreground)`,ariaLabel:e(`titleBar.closeWindow`)})]})]})}var kG=`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン0123456789ABCDEF`,AG=16,jG=AG,MG=AG*1.1,NG=180,PG=340,FG=.07,IG=.22,LG=18,RG=600,zG=48,BG=160,VG=360;function HG(){return kG[Math.floor(Math.random()*61)]??` `}function UG(e){return{head:-Math.random()*Math.max(e,12),speed:FG+Math.random()*(IG-FG),glyphs:Array.from({length:LG},()=>HG()),nextSwapAt:0}}function WG(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=null,s=[],c=0,l=0,u=!document.hidden;function d(){let e=window.devicePixelRatio||1,t=window.innerWidth,n=window.innerHeight;r.width=Math.max(1,Math.floor(t*e)),r.height=Math.max(1,Math.floor(n*e)),r.style.width=`${t}px`,r.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0),i.font=`${AG}px "DM Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace`,i.textBaseline=`top`;let o=Math.ceil(t/jG),s=Math.ceil(n/MG);if(a.length===0)a=Array.from({length:o},()=>UG(s));else if(a.length<o){let e=Array.from({length:o-a.length},()=>UG(s));a=a.concat(e)}else a.length>o&&(a=a.slice(0,o))}function f(e){let t=performance.now();o&&(Math.abs(o.x-e.clientX)>=2||Math.abs(o.y-e.clientY)>=2)&&(s.push({x:o.x,y:o.y,t}),s.length>zG&&s.splice(0,s.length-zG)),o={x:e.clientX,y:e.clientY}}function p(){o=null}function m(){u=!document.hidden,u?(l=0,c=requestAnimationFrame(h)):cancelAnimationFrame(c)}function h(e){if(!u)return;let t=l===0?1:Math.min(2.5,(e-l)/16.67);l=e;let n=performance.now();for(;s.length>0&&n-s[0].t>RG;)s.shift();let r=window.innerWidth,d=window.innerHeight;i.clearRect(0,0,r,d);let f=Math.ceil(d/MG),p=o!==null||s.length>0;for(let r=0;r<a.length;r++){let c=a[r];if(c.head+=c.speed*t,c.head-LG>f+4&&(c.head=-Math.random()*12,c.speed=FG+Math.random()*(IG-FG)),e>c.nextSwapAt&&(c.glyphs[Math.floor(Math.random()*LG)]=HG(),c.nextSwapAt=e+BG+Math.random()*VG),!p)continue;let l=r*jG+jG/2,u=o===null?1/0:Math.abs(l-o.x);for(let e of s){let t=Math.abs(l-e.x);if(t<u&&(u=t),u===0)break}if(!(u>PG))for(let e=0;e<LG;e++){let t=c.head-e;if(t<-1||t>f+2)continue;let a=t*MG,u=0;if(o!==null){let e=l-o.x,t=a-o.y,n=Math.sqrt(e*e+t*t);if(n<=PG){let e=n<NG?1:1-(n-NG)/(PG-NG);e>u&&(u=e)}}if(u<.999)for(let e of s){let t=l-e.x,r=a-e.y,i=Math.sqrt(t*t+r*r);if(i>PG)continue;let o=i<NG?1:1-(i-NG)/(PG-NG),s=n-e.t,c=o*(s>RG?0:1-s/RG);if(c>u&&(u=c),u>=.999)break}if(u<.02)continue;let d=1-e/LG,p=u*d*.85;p<.02||(i.fillStyle=e===0?`hsla(150, 100%, 92%, ${p.toFixed(3)})`:`hsla(144, 100%, 55%, ${p.toFixed(3)})`,i.fillText(c.glyphs[e],r*jG,a))}}c=requestAnimationFrame(h)}return d(),window.addEventListener(`resize`,d),window.addEventListener(`pointermove`,f),document.addEventListener(`mouseleave`,p),document.addEventListener(`visibilitychange`,m),c=requestAnimationFrame(h),()=>{cancelAnimationFrame(c),window.removeEventListener(`resize`,d),window.removeEventListener(`pointermove`,f),document.removeEventListener(`mouseleave`,p),document.removeEventListener(`visibilitychange`,m)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`fixed inset-0 pointer-events-none`,style:{zIndex:-1}})}var GG=24,KG=200,qG=3.5,JG=10,YG=`hsl(210, 60%, 96%)`,XG=`hsl(212, 100%, 62%)`;function ZG(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=0,s=!document.hidden;function c(){let e=window.devicePixelRatio||1,t=window.innerWidth,n=window.innerHeight;r.width=Math.max(1,Math.floor(t*e)),r.height=Math.max(1,Math.floor(n*e)),r.style.width=`${t}px`,r.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0)}function l(e){let t=performance.now();a.push({x:e.clientX,y:e.clientY,t}),a.length>GG&&a.splice(0,a.length-GG)}function u(){a=[]}function d(){s=!document.hidden,s?o=requestAnimationFrame(f):cancelAnimationFrame(o)}function f(){if(!s)return;let e=performance.now();for(;a.length>0&&e-a[0].t>KG;)a.shift();let t=window.innerWidth,n=window.innerHeight;if(i.clearRect(0,0,t,n),a.length>=2){i.lineCap=`round`,i.lineJoin=`round`,i.shadowColor=XG;for(let t=1;t<a.length;t++){let n=a[t-1],r=a[t],o=e-r.t,s=Math.max(0,1-o/KG);if(s<=0)continue;let c=t/a.length;i.globalAlpha=s*(.25+.75*c),i.lineWidth=Math.max(.5,qG*c),i.shadowBlur=JG*c,i.strokeStyle=c>.6?YG:XG,i.beginPath(),i.moveTo(n.x,n.y),i.lineTo(r.x,r.y),i.stroke()}i.globalAlpha=1,i.shadowBlur=0}o=requestAnimationFrame(f)}return c(),window.addEventListener(`resize`,c),window.addEventListener(`pointermove`,l),document.addEventListener(`mouseleave`,u),document.addEventListener(`visibilitychange`,d),o=requestAnimationFrame(f),()=>{cancelAnimationFrame(o),window.removeEventListener(`resize`,c),window.removeEventListener(`pointermove`,l),document.removeEventListener(`mouseleave`,u),document.removeEventListener(`visibilitychange`,d)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`fixed inset-0 pointer-events-none`,style:{zIndex:-1}})}var QG={"code-rain":WG,galaxy:ZG};function $G(){let e=QG[ca().id];return e?(0,$.jsx)(e,{}):null}function eK({project:e}){let{t}=K(`nav`),n=sB(),{registerHandler:r,unregisterHandler:i}=qe(),[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(e.id);return s.current=e.id,(0,Q.useEffect)(()=>{let n=`cost-alerts-${e.id}`;return r(n,e=>{let n=e;n.projectId!==void 0&&n.projectId!==``&&n.projectId!==s.current||(n.type===`cost_alert`?J.warning(t(`costAlerts.costAlertTitle`),{description:t(`costAlerts.costAlertDescription`,{cost:(n.cost??0).toFixed(4),threshold:(n.threshold??0).toFixed(2)})}):n.type===`daily_budget_exceeded`?(J.error(t(`costAlerts.dailyBudgetTitle`),{description:t(`costAlerts.dailyBudgetDescription`,{spent:(n.dailySpend??0).toFixed(2),budget:(n.budget??0).toFixed(2)}),duration:1/0}),o({dailySpend:n.dailySpend??0,budget:n.budget??0})):n.type===`desktop_daily_budget_exceeded`&&J.error(t(`costAlerts.desktopBudgetTitle`),{description:t(`costAlerts.desktopBudgetDescription`,{spent:(n.desktopDailySpend??0).toFixed(2),budget:(n.desktopBudget??0).toFixed(2)}),duration:1/0}))}),()=>i(n)},[e.id,r,i,t]),(0,$.jsx)(TO,{delayDuration:400,children:(0,$.jsx)(aB.Provider,{value:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-destructive/10 border-b border-destructive/20 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-destructive font-medium`,children:t(`costAlerts.bannerMessage`,{spent:a.dailySpend.toFixed(2),budget:a.budget.toFixed(2)})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`text-muted-foreground hover:text-foreground ml-4 shrink-0`,children:t(`costAlerts.dismiss`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden min-h-0`,children:[(0,$.jsx)(`main`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(l,{})}),!1]})]})})})}function tK({projectName:e,errorMessage:t,onRetry:n}){let{t:r}=K(`nav`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-8`,children:[(0,$.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`errorBoundary.title`)}),e&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`nav`,i18nKey:`errorBoundary.occurredIn`,values:{name:e},components:{strong:(0,$.jsx)(`span`,{className:`font-medium`})}})}),t&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 font-mono`,children:t})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,$.jsx)(Js,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]})]})}var nK=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ProjectErrorBoundary]`,e,t.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,$.jsx)(tK,{projectName:this.props.projectName,errorMessage:this.state.error?.message??null,onRetry:this.handleRetry}):this.props.children}};function rK({onAddProject:e}){let{t}=K(`setup`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[400px] gap-6 px-8 text-center`,children:[(0,$.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-muted/50 flex items-center justify-center`,children:(0,$.jsx)(dc,{className:`w-7 h-7 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,$.jsx)(tt,{t,i18nKey:`welcome.title`,components:{spec:(0,$.jsx)(`span`,{className:`text-accent-primary`}),rails:(0,$.jsx)(`span`,{className:`text-accent-secondary`})}})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-sm`,children:t(`welcome.description`)}),we&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.jiraHint`)}),xe&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.mcpHint`)}),P&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.agentChatHint`)})]}),(0,$.jsxs)(Z,{onClick:e,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(as,{className:`w-3.5 h-3.5`}),t(`welcome.addFirstProject`)]})]})}var iK=`https://specrails.dev/companion-app`,aK=`specrails-desktop:onboarding-dismissed`;function oK(){try{return localStorage.getItem(aK)===`true`}catch{return!1}}function sK(){try{localStorage.setItem(aK,`true`)}catch{}}var cK=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||``),lK=cK?`⌘`:`Ctrl`,uK=cK?`⌥`:`Alt`,dK={primary:{text:`text-accent-primary`,bar:`bg-accent-primary`,glow:`glow-primary`,btn:`bg-accent-primary hover:bg-accent-primary/90 text-primary-foreground`,softBorder:`border-accent-primary/30`,softBg:`bg-accent-primary/5`,chipBg:`bg-accent-primary/10 text-accent-primary`},info:{text:`text-accent-info`,bar:`bg-accent-info`,glow:`glow-info`,btn:`bg-accent-info hover:bg-accent-info/90 text-primary-foreground`,softBorder:`border-accent-info/30`,softBg:`bg-accent-info/5`,chipBg:`bg-accent-info/10 text-accent-info`},success:{text:`text-accent-success`,bar:`bg-accent-success`,glow:`glow-success`,btn:`bg-accent-success hover:bg-accent-success/90 text-primary-foreground`,softBorder:`border-accent-success/30`,softBg:`bg-accent-success/5`,chipBg:`bg-accent-success/10 text-accent-success`},secondary:{text:`text-accent-secondary`,bar:`bg-accent-secondary`,glow:`glow-secondary`,btn:`bg-accent-secondary hover:bg-accent-secondary/90 text-primary-foreground`,softBorder:`border-accent-secondary/30`,softBg:`bg-accent-secondary/5`,chipBg:`bg-accent-secondary/10 text-accent-secondary`},warning:{text:`text-accent-warning`,bar:`bg-accent-warning`,glow:`glow-warning`,btn:`bg-accent-warning hover:bg-accent-warning/90 text-primary-foreground`,softBorder:`border-accent-warning/30`,softBg:`bg-accent-warning/5`,chipBg:`bg-accent-warning/10 text-accent-warning`},highlight:{text:`text-accent-highlight`,bar:`bg-accent-highlight`,glow:`glow-highlight`,btn:`bg-accent-highlight hover:bg-accent-highlight/90 text-primary-foreground`,softBorder:`border-accent-highlight/30`,softBg:`bg-accent-highlight/5`,chipBg:`bg-accent-highlight/10 text-accent-highlight`}};function fK({children:e}){return(0,$.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.5rem] h-5 px-1.5 rounded border border-border/60 bg-card/80 font-mono text-[11px] text-foreground shadow-sm`,children:e})}function pK({icon:e,label:t,children:n,accent:r}){return(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(`div`,{className:X(`mt-0.5 shrink-0 grid place-items-center w-7 h-7 rounded-md border border-border/40`,r.softBg,r.text),children:e}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground leading-tight`,children:t}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground leading-relaxed`,children:n})]})]})}function mK({accent:e,label:t,children:n}){return(0,$.jsxs)(`div`,{className:X(`rounded-lg border p-3`,e.softBorder,e.softBg),children:[t&&(0,$.jsx)(`p`,{className:X(`text-[10px] font-semibold uppercase tracking-wider mb-1.5`,e.text),children:t}),(0,$.jsx)(`div`,{className:`text-xs text-foreground/90 leading-relaxed`,children:n})]})}function hK({steps:e}){return(0,$.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap text-[13px] font-medium`,children:e.map((t,n)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:t.cls,children:t.label}),n<e.length-1&&(0,$.jsx)(B,{className:`w-3.5 h-3.5 text-muted-foreground`})]},t.label))})}function gK(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`onboarding.language.intro`)}),(0,$.jsx)(OU,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.language.note`)})]})}function _K(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`onboarding.theme.intro`)}),(0,$.jsx)(bU,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.theme.note`)})]})}function vK({icon:e,url:t,label:n,testId:r}){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border/40 bg-card/40 p-3`,children:[(0,$.jsx)(`div`,{className:`shrink-0 rounded-md bg-white p-1.5`,"aria-hidden":`true`,children:(0,$.jsx)(FW,{value:t,size:72})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] font-semibold text-foreground leading-tight`,children:[e,n]}),(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,"data-testid":r,"aria-label":n,className:`inline-flex items-center gap-1 text-xs text-accent-info hover:underline break-all`,children:[t.replace(`https://`,``),(0,$.jsx)(Vt,{className:`w-3 h-3 shrink-0`,"aria-hidden":`true`})]})]})]})}function yK(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.companion.intro`,components:{b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,$.jsx)(mK,{accent:dK.success,label:e(`onboarding.companion.localLabel`),children:e(`onboarding.companion.localBody`)}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:e(`onboarding.companion.downloadLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`onboarding.companion.downloadHint`)}),(0,$.jsx)(vK,{icon:(0,$.jsx)(oc,{className:`w-4 h-4 shrink-0`,"aria-hidden":`true`}),url:iK,label:e(`onboarding.companion.open`),testId:`companion-web-link`})]}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Gs,{className:`w-4 h-4`}),label:e(`onboarding.companion.pairLabel`),accent:dK.success,children:e(`onboarding.companion.pairBody`)})]})}function bK(e){let t={b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})};return[{navLabel:e(`onboarding.language.nav`),icon:(0,$.jsx)(bs,{className:`w-6 h-6`}),accent:dK.info,title:e(`onboarding.language.title`),subtitle:e(`onboarding.language.subtitle`),content:(0,$.jsx)(gK,{})},{navLabel:e(`onboarding.theme.nav`),icon:(0,$.jsx)(Fs,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.theme.title`),subtitle:e(`onboarding.theme.subtitle`),content:(0,$.jsx)(_K,{})},{navLabel:e(`onboarding.welcome.nav`),icon:(0,$.jsx)(un,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.welcome.title`),subtitle:e(`onboarding.welcome.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.intro`,components:t})}),(0,$.jsxs)(mK,{accent:dK.primary,label:e(`onboarding.welcome.coreLoopLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.describe`),cls:`text-accent-info`},{label:e(`onboarding.flow.specs`),cls:`text-accent-success`},{label:e(`onboarding.flow.rails`),cls:`text-accent-warning`},{label:e(`onboarding.flow.review`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.flowCaption`,components:t})})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.welcome.missionLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.missionBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Ss,{className:`w-4 h-4`}),label:e(`onboarding.welcome.boardLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.boardBody`,components:t})})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(ic,{className:`w-4 h-4 mt-0.5 shrink-0 text-accent-success`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.localNote`,components:{...t,i:(0,$.jsx)(`span`,{className:`italic`})}})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.welcome.tourNote`)})]})},...P?[{navLabel:e(`onboarding.mission.nav`),icon:(0,$.jsx)(So,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.mission.title`),subtitle:e(`onboarding.mission.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.mission.missionsLabel`),accent:dK.primary,children:e(`onboarding.mission.missionsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ic,{className:`w-4 h-4`}),label:e(`onboarding.mission.levelsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.levelsBody`,components:{...t,shift:(0,$.jsx)(fK,{children:`Shift`}),tab:(0,$.jsx)(fK,{children:`Tab`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(xs,{className:`w-4 h-4`}),label:e(`onboarding.mission.cardsLabel`),accent:dK.primary,children:e(`onboarding.mission.cardsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Co,{className:`w-4 h-4`}),label:e(`onboarding.mission.workspaceLabel`),accent:dK.primary,children:e(`onboarding.mission.workspaceBody`)})]}),(0,$.jsx)(mK,{accent:dK.primary,label:e(`onboarding.mission.mcpLabel`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.mcpBody`,components:t})})]})}]:[],...ne?[{navLabel:e(`onboarding.builder.nav`),icon:(0,$.jsx)(ps,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.builder.title`),subtitle:e(`onboarding.builder.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.builder.intro`,components:t})}),(0,$.jsxs)(mK,{accent:dK.highlight,label:e(`onboarding.builder.flowLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.blueprint`),cls:`text-accent-info`},{label:e(`onboarding.flow.approve`),cls:`text-accent-success`},{label:e(`onboarding.flow.m1Specs`),cls:`text-accent-warning`},{label:e(`onboarding.flow.milestones`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:e(`onboarding.builder.flowCaption`)})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(mc,{className:`w-4 h-4`}),label:e(`onboarding.builder.cardsLabel`),accent:dK.highlight,children:e(`onboarding.builder.cardsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(es,{className:`w-4 h-4`}),label:e(`onboarding.builder.specsLabel`),accent:dK.highlight,children:e(`onboarding.builder.specsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Xs,{className:`w-4 h-4`}),label:e(`onboarding.builder.milestonesLabel`),accent:dK.highlight,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.builder.milestonesBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ss,{className:`w-4 h-4`}),label:e(`onboarding.builder.progressLabel`),accent:dK.highlight,children:e(`onboarding.builder.progressBody`)})]})]})}]:[],{navLabel:e(`onboarding.authorSpecs.nav`),icon:(0,$.jsx)(x,{className:`w-6 h-6`}),accent:dK.info,title:e(`onboarding.authorSpecs.title`),subtitle:e(`onboarding.authorSpecs.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.authorSpecs.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.agentLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.agentBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.exploreLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.exploreBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(hn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.quickLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.quickBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(E,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.websiteLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.websiteBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Qs,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.smashLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.smashBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(zt,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.draftsLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.draftsBody`)})]}),we&&(0,$.jsx)(mK,{accent:dK.info,label:e(`onboarding.jira.label`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.jira.body`,components:t})})]})},{navLabel:e(`onboarding.rails.nav`),icon:(0,$.jsx)(gc,{className:`w-6 h-6`}),accent:dK.success,title:e(`onboarding.rails.title`),subtitle:e(`onboarding.rails.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.intro`,components:{...t,play:(0,$.jsx)(`span`,{className:`text-accent-warning font-medium`})}})}),(0,$.jsxs)(mK,{accent:dK.success,label:e(`onboarding.rails.jobLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.architect`),cls:`text-accent-info`},{label:e(`onboarding.flow.developer`),cls:`text-accent-success`},{label:e(`onboarding.flow.reviewer`),cls:`text-accent-warning`},{label:e(`onboarding.flow.yourReview`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:e(`onboarding.rails.flowCaption`)})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(nn,{className:`w-4 h-4`}),label:e(`onboarding.rails.reviewLabel`),accent:dK.success,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.reviewBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Qo,{className:`w-4 h-4`}),label:e(`onboarding.rails.packetLabel`),accent:dK.success,children:e(`onboarding.rails.packetBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.rails.steerLabel`),accent:dK.success,children:e(`onboarding.rails.steerBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Ys,{className:`w-4 h-4`}),label:e(`onboarding.rails.loopsLabel`),accent:dK.success,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.loopsBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.rails.profilesLabel`),accent:dK.success,children:e(`onboarding.rails.profilesBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(as,{className:`w-4 h-4`}),label:e(`onboarding.rails.isolationLabel`),accent:dK.success,children:e(`onboarding.rails.isolationBody`)})]})]})},{navLabel:e(`onboarding.providers.nav`),icon:(0,$.jsx)(So,{className:`w-6 h-6`}),accent:dK.secondary,title:e(`onboarding.providers.title`),subtitle:e(`onboarding.providers.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.providers.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden text-xs`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.4fr_1fr_1fr_1fr_1fr] bg-card/40`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-muted-foreground`,children:e(`onboarding.providers.table.capability`)}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-secondary text-center`,children:`Claude Code`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-success text-center`,children:`Codex CLI`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-info text-center`,children:`Gemini CLI`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-purple-300 text-center`,children:`Kimi Code`})]}),[[e(`onboarding.providers.table.streamingResume`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`)],[e(`onboarding.providers.table.costReporting`),e(`onboarding.providers.table.providerBilled`),e(`onboarding.providers.table.estimated`),e(`onboarding.providers.table.estimated`),e(`onboarding.providers.table.unavailable`)],[e(`onboarding.providers.table.telemetry`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.synthesized`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.synthesized`)],[e(`onboarding.providers.table.agentProfiles`),e(`common:states.yes`),`—`,`—`,e(`common:states.yes`)]].map(e=>(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.4fr_1fr_1fr_1fr_1fr] border-t border-border/30`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 text-foreground/90`,children:e[0]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[1]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[2]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[3]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[4]})]},e[0]))]}),(0,$.jsx)(mK,{accent:dK.secondary,label:e(`onboarding.providers.calloutLabel`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.providers.calloutBody`,components:{...t,mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]})},{navLabel:e(`onboarding.cost.nav`),icon:(0,$.jsx)(zo,{className:`w-6 h-6`}),accent:dK.warning,title:e(`onboarding.cost.title`),subtitle:e(`onboarding.cost.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.cost.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(ss,{className:`w-4 h-4`}),label:e(`onboarding.cost.analyticsLabel`),accent:dK.warning,children:e(`onboarding.cost.analyticsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(qs,{className:`w-4 h-4`}),label:e(`onboarding.cost.perTicketLabel`),accent:dK.warning,children:e(`onboarding.cost.perTicketBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Jo,{className:`w-4 h-4`}),label:e(`onboarding.cost.honestLabel`),accent:dK.warning,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.cost.honestBody`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(pc,{className:`w-4 h-4`}),label:e(`onboarding.cost.budgetsLabel`),accent:dK.warning,children:e(`onboarding.cost.budgetsBody`)})]})]})},{navLabel:e(`onboarding.workspace.nav`),icon:(0,$.jsx)(Co,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.workspace.title`),subtitle:e(`onboarding.workspace.subtitle`),content:(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(dc,{className:`w-4 h-4`}),label:e(`onboarding.workspace.terminalLabel`),accent:dK.highlight,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.workspace.terminalBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),j:(0,$.jsx)(fK,{children:`J`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(es,{className:`w-4 h-4`}),label:e(`onboarding.workspace.codeLabel`),accent:dK.highlight,children:e(`onboarding.workspace.codeBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(E,{className:`w-4 h-4`}),label:e(`onboarding.workspace.browserLabel`),accent:dK.highlight,children:e(`onboarding.workspace.browserBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Us,{className:`w-4 h-4`}),label:e(`onboarding.workspace.integrationsLabel`),accent:dK.highlight,children:e(`onboarding.workspace.integrationsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Fs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.themesLabel`),accent:dK.highlight,children:e(`onboarding.workspace.themesBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(xs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.chatsLabel`),accent:dK.highlight,children:e(`onboarding.workspace.chatsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(U,{className:`w-4 h-4`}),label:e(`onboarding.workspace.compareLabel`),accent:dK.highlight,children:e(`onboarding.workspace.compareBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Xs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.desktopLabel`),accent:dK.highlight,children:e(`onboarding.workspace.desktopBody`)})]})})},{navLabel:e(`onboarding.companion.nav`),icon:(0,$.jsx)(oc,{className:`w-6 h-6`}),accent:dK.success,title:e(`onboarding.companion.title`),subtitle:e(`onboarding.companion.subtitle`),content:(0,$.jsx)(yK,{})},{navLabel:e(`onboarding.moveFast.nav`),icon:(0,$.jsx)(Vo,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.moveFast.title`),subtitle:e(`onboarding.moveFast.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(mK,{accent:dK.primary,label:e(`onboarding.moveFast.paletteLabel`),children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.paletteShortcut`,values:{mod:lK},components:{f:(0,$.jsx)(`span`,{className:`text-foreground`}),m:(0,$.jsx)(`span`,{className:`text-muted-foreground`}),mod:(0,$.jsx)(fK,{children:lK}),k:(0,$.jsx)(fK,{children:`K`})}})}),e(`onboarding.moveFast.paletteBody`)]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-3`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.agentLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.agentBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),shift:(0,$.jsx)(fK,{children:`Shift`}),a:(0,$.jsx)(fK,{children:`A`}),tab:(0,$.jsx)(fK,{children:`Tab`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(dc,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.terminalLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.terminalBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),j:(0,$.jsx)(fK,{children:`J`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ys,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.shortcutsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.shortcutsBody`,components:{q:(0,$.jsx)(fK,{children:`?`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.chatLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.chatBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),bkey:(0,$.jsx)(fK,{children:`B`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(as,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.projectsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.projectsBody`,values:{alt:uK,mod:lK},components:{alt:(0,$.jsx)(fK,{children:uK}),mod:(0,$.jsx)(fK,{children:lK}),bkey:(0,$.jsx)(fK,{children:`B`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Vo,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.pagesLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.pagesBody`,values:{alt:uK,mod:lK},components:{alt:(0,$.jsx)(fK,{children:uK}),mod:(0,$.jsx)(fK,{children:lK}),n:(0,$.jsx)(fK,{children:`1–9`})}})})]}),(0,$.jsx)(mK,{accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.outro`,components:t})})]})}]}function xK({open:e,onClose:t}){let{t:n}=K(`setup`),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),s=(0,Q.useMemo)(()=>bK(n),[n]),c=s[r],l=r===0,u=r===s.length-1,d=(0,Q.useCallback)(()=>{a&&sK(),i(0),t()},[a,t]),f=(0,Q.useCallback)(()=>{sK(),i(0),t()},[t]),p=(0,Q.useCallback)(()=>{u?f():i(e=>e+1)},[u,f]),m=(0,Q.useCallback)(()=>i(e=>Math.max(0,e-1)),[]);return(0,$.jsx)(zn,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(kn,{children:[(0,$.jsx)(On,{className:`fixed inset-0 z-50 bg-black/70 backdrop-blur-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),(0,$.jsxs)(Un,{className:`fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-5xl h-[min(88vh,820px)] translate-x-[-50%] translate-y-[-50%] overflow-hidden border border-border/30 bg-popover shadow-2xl backdrop-blur-xl sm:rounded-2xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,"data-testid":`onboarding-wizard`,"aria-describedby":`onboarding-description`,children:[(0,$.jsx)(`div`,{className:X(`h-1 w-full shrink-0 transition-all duration-500`,c.accent.bar)}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`nav`,{className:`hidden md:flex w-60 shrink-0 flex-col border-r border-border/30 bg-card/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`px-2 mb-5`,children:[(0,$.jsxs)(`p`,{className:`text-sm font-bold tracking-tight`,children:[(0,$.jsx)(`span`,{className:`text-accent-primary`,children:`spec`}),(0,$.jsx)(`span`,{className:`text-accent-secondary`,children:`rails`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`onboarding.productTour`)})]}),(0,$.jsx)(`ol`,{className:`space-y-0.5 min-h-0 overflow-y-auto`,children:s.map((e,t)=>{let a=t===r,o=t<r;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":n(`onboarding.goToStep`,{step:t+1,label:e.navLabel}),"aria-current":a?`step`:void 0,className:X(`w-full flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,a?X(`bg-card/70`,e.accent.text):`text-muted-foreground hover:bg-card/40 hover:text-foreground`),children:[(0,$.jsx)(`span`,{className:X(`grid place-items-center w-5 h-5 shrink-0 rounded-full text-[10px] font-bold border`,a?X(e.accent.bar,`text-primary-foreground border-transparent`):o?`bg-accent-success/15 text-accent-success border-accent-success/30`:`border-border/50 text-muted-foreground`),children:o?(0,$.jsx)(Ht,{className:`w-3 h-3`}):t+1}),(0,$.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.navLabel})]})},e.navLabel)})}),(0,$.jsx)(`div`,{className:`mt-auto px-2.5 pt-4 text-[10px] text-muted-foreground`,children:n(`onboarding.stepCount`,{current:r+1,total:s.length})})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 sm:p-7`,children:[(0,$.jsxs)(`div`,{className:X(`flex items-center gap-3.5 mb-5`,c.accent.text),children:[(0,$.jsx)(`div`,{className:X(`grid place-items-center w-12 h-12 shrink-0 rounded-xl border border-border/30 bg-card/40`,c.accent.glow),children:c.icon}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(In,{className:`text-lg font-bold leading-tight text-foreground`,children:c.title}),(0,$.jsx)(`p`,{id:`onboarding-description`,className:`text-xs text-muted-foreground mt-0.5`,children:c.subtitle})]})]}),(0,$.jsx)(`div`,{className:`md:hidden flex items-center gap-1.5 mb-5`,children:s.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":n(`onboarding.stepLabel`,{step:t+1}),"aria-current":t===r?`step`:void 0,className:X(`h-1.5 rounded-full transition-all`,t===r?X(`w-6`,e.accent.bar):`w-1.5 bg-muted-foreground/30`)},e.navLabel))}),(0,$.jsx)(`div`,{className:`min-h-[300px]`,children:c.content})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border/30 px-6 sm:px-7 py-3.5`,children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:l&&(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-2 cursor-pointer group`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`w-3.5 h-3.5 rounded`,"data-testid":`onboarding-dismiss-checkbox`}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground group-hover:text-foreground transition-colors`,children:n(`onboarding.dontShowAgain`)})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs text-muted-foreground`,"data-testid":`onboarding-skip`,children:n(`onboarding.skipTour`)}):(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:m,className:`text-xs`,"data-testid":`onboarding-back`,children:[(0,$.jsx)(Rt,{className:`w-3.5 h-3.5 mr-1`}),n(`common:actions.back`)]}),(0,$.jsxs)(Z,{size:`sm`,onClick:p,className:X(`text-xs`,c.accent.btn),"data-testid":`onboarding-next`,children:[n(u?`onboarding.getStarted`:`common:actions.next`),!u&&(0,$.jsx)(B,{className:`w-3.5 h-3.5 ml-1`})]})]})]})]})]})]})]})})}function SK(){let[e,t]=(0,Q.useState)(new Map),n=(0,Q.useContext)(Ye);return(0,Q.useEffect)(()=>n?(n.registerHandler(`assemble-progress`,e=>{let n=e;if(n.type!==`project.assemble_progress`||typeof n.projectId!=`string`||typeof n.provider!=`string`)return;let{projectId:r,provider:i,status:a}=n;t(e=>{let t=new Map(e),n=t.get(r)?{running:new Set(t.get(r).running),failed:new Set(t.get(r).failed)}:{running:new Set,failed:new Set};return a===`running`?(n.running.add(i),n.failed.delete(i)):a===`done`?(n.running.delete(i),n.failed.delete(i)):a===`failed`&&(n.running.delete(i),n.failed.add(i)),t.set(r,n),t})}),()=>n.unregisterHandler(`assemble-progress`)):void 0,[n]),{statusFor:(0,Q.useCallback)(t=>{let n=e.get(t);return n?n.running.size>0?`assembling`:n.failed.size>0?`failed`:`ready`:`ready`},[e]),retry:(0,Q.useCallback)(async e=>{await fetch(`${He}/api/projects/${e}/assemble-retry`,{method:`POST`})},[])}}var CK=(0,Q.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-CVTj4VLt.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([84,1,7,42,44,8,12,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,53,63,49,64,65]))),wK=`specrails-desktop:agentTreeExpanded`;function TK(){try{let e=localStorage.getItem(wK);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function EK(e){try{localStorage.setItem(wK,JSON.stringify([...e]))}catch{}}function DK(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var OK=`__home__`,kK=`__favorites__`;function AK({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=K(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,Q.useState)(!1),p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(r);(0,Q.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,Q.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);function _(e){e.stopPropagation(),d?(p.current&&clearTimeout(p.current),f(!1),c()):(f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},3e3))}function v(e){e.stopPropagation(),s?.()}function y(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o()))}return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:y,className:X(`group relative flex items-center gap-2 w-full h-7 rounded-md transition-colors`,n?`pl-7 pr-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:u,"aria-current":t?`true`:void 0,children:[(0,$.jsx)(x,{className:X(`w-3.5 h-3.5 flex-shrink-0`,t&&`text-accent-primary`,r&&!i&&`text-accent-primary animate-pulse`,i&&`text-destructive conversation-unread-glow`)}),n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`title-shimmer pointer-events-none absolute inset-0 truncate transition-opacity duration-700`,r?`opacity-100`:`opacity-0`),children:u})]}),(0,$.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:Ob(e.updated_at),children:Db(e.updated_at)}),(0,$.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,a?`flex w-3.5 h-3.5 text-accent-primary hover:text-accent-primary`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-accent-primary`),"aria-label":l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),title:l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),children:(0,$.jsx)(ms,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,$.jsx)(`button`,{type:`button`,onClick:_,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,d?`flex px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-foreground`),"aria-label":l(d?`confirmDeleteConversation`:`deleteConversation`,{title:u}),children:d?l(`confirmShort`):(0,$.jsx)(mn,{className:`w-2.5 h-2.5`})})]})]})}function jK({project:e,isActive:t,expanded:n,onSelect:r,onRemove:i,agentMode:a=!1,hasTree:o=!1,treeOpen:s=!1,onToggleTree:c,conversations:l=[],activeConversationId:u=null,streamingConversationIds:d,unreadConversationIds:f,onSelectConversation:p,onToggleConversationFavorite:m,onDeleteConversation:h,onOpenProjectSettings:g,assembleStatus:_=`ready`,onRetryAssemble:v}){let{t:y}=K(`nav`),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);function C(e){e.stopPropagation(),b?(S.current&&clearTimeout(S.current),x(!1),i()):(x(!0),S.current=setTimeout(()=>{x(!1),S.current=null},3e3))}function w(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let T=a&&o&&n,E=(0,$.jsx)(as,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:w,className:X(`group relative flex items-center gap-2 w-full h-8 rounded-md transition-colors`,n?`px-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:e.name,"aria-current":t?`page`:void 0,children:[T?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:E}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c?.()},className:`absolute inset-0 hidden items-center justify-center rounded-sm hover:bg-muted group-hover:flex group-focus-within:flex`,"aria-label":y(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):E,n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),_===`assembling`&&(0,$.jsx)(`span`,{className:`flex-shrink-0 h-1.5 w-1.5 rounded-full bg-accent-info animate-pulse`,title:y(`projects.assembling`),"data-testid":`assemble-indicator`,"aria-label":y(`projects.assembling`)}),_===`failed`&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v?.()},className:`flex-shrink-0 h-2 w-2 rounded-full bg-accent-warning hover:ring-2 hover:ring-accent-warning/40 transition-shadow`,title:y(`projects.assembleFailed`),"data-testid":`assemble-retry`,"aria-label":y(`projects.assembleFailed`)}),g&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all w-3.5 h-3.5`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`),"aria-label":y(`projects.settings`,{name:e.name}),title:y(`projects.settings`,{name:e.name}),children:(0,$.jsx)(nc,{className:`w-2.5 h-2.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:C,className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`,b?`opacity-100 px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`w-3.5 h-3.5`),"aria-label":y(b?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:b?y(`projects.confirmShort`):(0,$.jsx)(mn,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===u,streaming:d?.has(e.id)??!1,unread:f?.has(e.id)??!1,expanded:n,onSelect:()=>p?.(e.id),onToggleFavorite:()=>m?.(e.id),onDelete:()=>h?.(e.id)},e.id))})]})}var MK={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function NK({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=K(`nav`),{t:s}=K(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:u,removeProject:d}=at(),f=SK(),m=v(),h=p(),g=h.pathname.startsWith(`/loops`),_=h.pathname.startsWith(`/plugins`),b=g||_||h.pathname.startsWith(`/docs`),{leftMode:x,cycleLeftMode:S}=eN(),{uiMode:C,toggleUiMode:w}=Ij(),T=lM(),E=C===`agent`,D=(0,Q.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of T.conversations){if(T.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:OK,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[T.conversations,T.favoriteConversationIds,c]),O=(0,Q.useMemo)(()=>T.conversations.filter(e=>T.favoriteConversationIds.has(e.id)),[T.conversations,T.favoriteConversationIds]),k=D.get(OK)??[],[A,j]=(0,Q.useState)(TK),M=A.has(kK),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!E||!l||j(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),EK(t),t})},[E,l]);let F=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),EK(n),n})},I=e=>{T.selectConversation(e),b&&m(`/`)},L=e=>{T.deleteConversation(e).catch(()=>{})},R=e=>{T.toggleFavoriteConversation(e)};function z(e){if(E){u(e),F(e);return}if(e===l){b&&m(`/`);return}u(e)}let[B,ee]=(0,Q.useState)(!1),V=x===`pinned-open`||x===`unpinned`&&B,H=UM(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:V}),te=x!==`unpinned`,ne=o(MK[x]),re=[{label:o(`arcSidebar.docs`),icon:xo,action:i},{label:o(`arcSidebar.analytics`),icon:Oo,action:r},{label:o(`arcSidebar.settings`),icon:nc,action:a}];async function ie(e){try{await d(e.id)}catch{}}return(0,$.jsxs)(`div`,{ref:H.panelRef,className:X(`relative flex flex-col h-full border-r border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{x===`unpinned`&&ee(!0)},onMouseLeave:()=>{x===`unpinned`&&!H.dragging&&ee(!1)},children:[V&&(0,$.jsx)(WM,{side:`left`,dragging:H.dragging,width:H.width,min:200,max:460,label:o(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:H.onGripPointerDown,onKeyDown:H.onGripKeyDown}),(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,V?`px-3 justify-between`:`justify-center`),children:[V&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:S,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,te?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":ne,title:o(`sidebarPin.withShortcut`,{label:ne,shortcut:jH(`⌥⌘B`)}),children:(0,$.jsx)(Is,{className:`w-4 h-4`})})]}),y&&(0,$.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[E&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{T.startNewConversation(l),b&&m(`/`)},className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`bg-accent-primary/15 text-accent-primary hover:bg-accent-primary/25`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`newAgent`),title:V?void 0:s(`newAgent`),children:[(0,$.jsx)(cn,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:w,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(E?`switchToKanban`:`switchToAgent`),title:s(E?`switchToKanban`:`switchToAgent`),children:[E?(0,$.jsx)(Ss,{className:`w-4 h-4 flex-shrink-0`}):(0,$.jsx)(So,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),V&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(E?`switchToKanban`:`switchToAgent`)})]}),E&&(0,$.jsxs)(`button`,{type:`button`,onClick:DK,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`search`),title:V?void 0:s(`search`),children:[(0,$.jsx)(ln,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,V?`px-2`:`px-0 justify-center`,g?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.loops`),"aria-current":g?`page`:void 0,title:V?void 0:o(`arcSidebar.loops`),children:[(0,$.jsx)(gc,{className:X(`w-4 h-4 flex-shrink-0`,g&&`text-accent-primary`)}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:X(`mt-0.5 flex items-center gap-2 w-full h-8 rounded-md transition-colors`,V?`px-2`:`px-0 justify-center`,_?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.plugins`),"aria-current":_?`page`:void 0,title:V?void 0:o(`arcSidebar.plugins`),children:[(0,$.jsx)(Ws,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,$.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[E&&O.length>0&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(kK),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`favoriteMissions`),"aria-expanded":M,title:V?void 0:s(`favoriteMissions`),children:[V?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(ms,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,$.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:M?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(ms,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),V&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),M&&V&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:O.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===T.active?.id,streaming:T.streamingConversationIds.has(e.id),unread:T.unreadConversationIds.has(e.id),favorite:!0,expanded:V,onSelect:()=>I(e.id),onToggleFavorite:()=>R(e.id),onDelete:()=>L(e.id)},e.id))})]}),E&&k.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(OK),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`home`),"aria-expanded":A.has(OK),title:V?void 0:s(`home`),children:[V?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(gs,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,$.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:A.has(OK)?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(gs,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),A.has(OK)&&V&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:k.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===T.active?.id,streaming:T.streamingConversationIds.has(e.id),unread:T.unreadConversationIds.has(e.id),expanded:V,onSelect:()=>I(e.id),onToggleFavorite:()=>R(e.id),onDelete:()=>L(e.id)},e.id))})]}),c.map(e=>{let t=D.get(e.id)??[];return(0,$.jsx)(jK,{project:e,isActive:e.id===l&&!b,expanded:V,onSelect:()=>z(e.id),onRemove:()=>ie(e),agentMode:E,hasTree:t.length>0,treeOpen:A.has(e.id),onToggleTree:()=>F(e.id),conversations:t,activeConversationId:T.active?.id??null,streamingConversationIds:T.streamingConversationIds,unreadConversationIds:T.unreadConversationIds,onSelectConversation:I,onToggleConversationFavorite:R,onDeleteConversation:L,assembleStatus:f.statusFor(e.id),onRetryAssemble:()=>{f.retry(e.id)},onOpenProjectSettings:E?()=>{u(e.id),P(!0)}:void 0},e.id)}),(0,$.jsxs)(`button`,{type:`button`,onClick:e,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":o(`projects.addProject`),title:V?void 0:o(`projects.addProject`),children:[(0,$.jsx)(cn,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,$.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:re.map(({label:e,icon:t,action:n})=>(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":e,title:V?void 0:e,children:[(0,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),N&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(CK,{open:!0,onClose:()=>P(!1)})})]})}var PK={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function FK(){let{t:e}=K(`nav`),{rightMode:t,cycleRightMode:n}=eN(),[r,i]=(0,Q.useState)(!1),a=t===`pinned-open`||t===`unpinned`&&r,o=t!==`unpinned`,s=e(PK[t]),c=[{to:`/`,end:!0,icon:Cs,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Eo,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Do,label:e(`rightSidebar.analytics`)},...se?[{to:`/code`,end:!1,icon:Lo,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:nc,label:e(`rightSidebar.settings`)}];return(0,$.jsxs)(`div`,{className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0`,`transition-all duration-200 ease-in-out overflow-hidden`,a?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&i(!0)},onMouseLeave:()=>{t===`unpinned`&&i(!1)},children:[(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,a?`px-3 justify-between`:`justify-center`),children:[a&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,o?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":s,title:e(`sidebarPin.withShortcut`,{label:s,shortcut:jH(`⌘B`)}),children:(0,$.jsx)(Ls,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,$.jsx)(nN,{expanded:a}),c.map(({to:e,end:t,icon:n,label:r})=>(0,$.jsxs)(h,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,a?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:a?void 0:r,children:[(0,$.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),a&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))]})]})}function IK(e,t){return e.error===`corrupted-bundle`?t(`setup:prerequisites.corruptedBundle`):e.installed?e.executable===!1?e.resolvedPath&&e.executionError?t(`setup:prerequisites.failedToExecuteAtWithError`,{path:e.resolvedPath,error:e.executionError}):e.resolvedPath?t(`setup:prerequisites.failedToExecuteAt`,{path:e.resolvedPath}):e.executionError?t(`setup:prerequisites.failedToExecuteWithError`,{error:e.executionError}):t(`setup:prerequisites.failedToExecute`):!e.meetsMinimum&&e.minVersion?t(`setup:prerequisites.needsMinimum`,{version:e.version??t(`setup:prerequisites.unknownVersion`),minVersion:e.minVersion}):e.version??t(`setup:prerequisites.installedLabel`):t(`setup:prerequisites.notInstalled`)}function LK({status:e,isLoading:t,error:n,onRefresh:r,onMoreInfo:i}){let{t:a}=K(`setup`);if(t&&!e)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`loading`,className:`rounded-lg border border-border/30 bg-background/30 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-muted-foreground/20 animate-pulse`}),(0,$.jsx)(`div`,{className:`h-3 w-32 rounded bg-muted-foreground/15 animate-pulse`})]})});if(n&&!e)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`error`,className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`prerequisites.verifyError`)})});if(!e)return null;if(e.ok)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`ok`,className:`rounded-lg border border-accent-success/25 bg-accent-success/5 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Mo,{className:`w-4 h-4 text-accent-success flex-shrink-0`}),(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:a(`prerequisites.allDetected`)})]}),r&&(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-[11px] flex-shrink-0`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,t&&`animate-spin`)}),a(`common:actions.refresh`)]})]})});let o=e.missingRequired?.length??0,s=o>0&&(e.missingRequired??[]).every(e=>e.error===`corrupted-bundle`),c=(e.missingRequired??[]).some(e=>e.error===`corrupted-bundle`);return(0,$.jsxs)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`missing`,className:X(`rounded-lg border px-3 py-2`,c?`border-destructive/40 bg-destructive/10`:`border-accent-primary/40 bg-accent-primary/10`),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(fn,{className:X(`w-4 h-4 flex-shrink-0`,c?`text-destructive`:`text-accent-primary`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:s?a(`prerequisites.bundleCorruptedTitle`):a(`prerequisites.toolsRequired`,{count:o})}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(s?`prerequisites.reinstallHint`:`prerequisites.installMissingHint`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[i&&!s&&(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`prerequisites-more-info`,children:a(`prerequisites.moreInfo`)}),r&&(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-[11px]`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,t&&`animate-spin`)}),a(`common:actions.refresh`)]})]})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.prerequisites.map(e=>{let t=e.error===`corrupted-bundle`,n=e.bundled===!0&&e.executable===!0&&!t,r=!t&&e.installed&&e.meetsMinimum,i=e.key===`gh`||e.key===`uv`,o=!r&&!t&&i;return(0,$.jsxs)(`li`,{"data-testid":`prereq-row-${e.key}`,"data-ok":r?`true`:`false`,"data-bundled":e.bundled?`true`:void 0,"data-corrupted":t?`true`:void 0,className:X(`flex items-center gap-2 rounded-md border px-2 py-1.5 text-[11px]`,t?`border-destructive/40 bg-destructive/10 text-foreground`:r||o?`border-border/30 bg-background/30 text-muted-foreground`:`border-accent-primary/30 bg-background/50 text-foreground`),children:[t?(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-destructive flex-shrink-0`}):n||r?(0,$.jsx)(Mo,{className:`w-3.5 h-3.5 text-accent-success flex-shrink-0`}):o?(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-accent-primary flex-shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),i&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:a(`prerequisites.optional`)}),e.key===`gh`&&e.executable&&e.authenticated===!1&&(0,$.jsx)(`span`,{"data-testid":`prereq-gh-noauth`,className:`inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium bg-accent-warning/15 text-accent-warning border border-accent-warning/30`,children:a(`prerequisites.ghNoAuth`)}),n&&(0,$.jsxs)(`span`,{"data-testid":`prereq-bundled-badge-${e.key}`,className:`inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium bg-accent-secondary/20 text-accent-secondary border border-accent-secondary/30`,children:[(0,$.jsx)(Ps,{className:`w-2.5 h-2.5`}),a(`prerequisites.bundledBadge`)]}),(0,$.jsxs)(`span`,{className:X(`text-muted-foreground`,t&&`text-destructive/80`),children:[`— `,IK(e,a)]})]},e.key)})})]})}function RK(e){return{darwin:{title:`macOS`,intro:e(`setup:instructions.darwin.intro`),commands:[{label:e(`setup:instructions.darwin.installNodeGit`),command:`brew install node git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`},{label:`Homebrew`,url:`https://brew.sh`}]},win32:{title:`Windows`,intro:e(`setup:instructions.win32.intro`),commands:[{label:e(`setup:instructions.win32.installNode`),command:`winget install OpenJS.NodeJS.LTS`},{label:e(`setup:instructions.win32.installGit`),command:`winget install Git.Git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitWindows`),url:`https://git-scm.com/download/win`}],note:e(`setup:instructions.win32.note`)},linux:{title:`Linux`,intro:e(`setup:instructions.linux.intro`),commands:[{label:e(`setup:instructions.linux.debian`),command:`sudo apt install -y nodejs npm git`},{label:e(`setup:instructions.linux.fedora`),command:`sudo dnf install -y nodejs npm git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`}]}}}var zK=[`darwin`,`win32`,`linux`];async function BK(e){try{if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function VK({command:e}){let{t}=K(`setup`),[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await BK(e)&&(r(!0),window.setTimeout(()=>r(!1),1500))},className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`install-copy-button`,children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function HK({platform:e,primary:t}){let{t:n}=K(`setup`),r=RK(n)[e];return(0,$.jsxs)(`section`,{"data-testid":`install-section-${e}`,className:X(`rounded-lg border px-3 py-3`,t?`border-border/40 bg-background/40`:`border-border/20 bg-background/20`),children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,$.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,$.jsx)(VK,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,$.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-info hover:underline`,children:[e.label,(0,$.jsx)(Vt,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function UK(){let{t:e}=K(`setup`),[t,n]=(0,Q.useState)(`idle`);return(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${He}/api/setup-prerequisites?diagnostic=1`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n(`copied`),setTimeout(()=>n(`idle`),1800)}catch{n(`error`),setTimeout(()=>n(`idle`),2400)}},disabled:t===`copying`,className:`gap-1.5 text-[11px]`,"data-testid":`copy-diagnostics-button`,children:[t===`copied`?(0,$.jsx)(Ht,{className:`w-3 h-3 text-accent-success`}):(0,$.jsx)(Fo,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function WK({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=K(`setup`),[o,s]=(0,Q.useState)(!1),c=n?.platform??`darwin`,l=zK.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:a(`instructions.corrupted.title`)}),(0,$.jsx)(Mn,{children:a(`instructions.corrupted.description`)})]}),(0,$.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,$.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-xl`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:a(`instructions.title`)}),(0,$.jsx)(Mn,{children:a(`instructions.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(HK,{platform:c,primary:!0}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground underline-offset-2 hover:underline`,"data-testid":`install-toggle-others`,children:a(o?`instructions.hideOtherPlatforms`:`instructions.showOtherPlatforms`)}),o&&(0,$.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,$.jsx)(HK,{platform:e,primary:!1},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,$.jsx)(UK,{}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,$.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var GK=typeof window<`u`&&`__TAURI_INTERNALS__`in window;function KK({open:e,onClose:t,onOpenBuilder:n}){let r=ne&&!!n,[i,a]=(0,Q.useState)(r?`choose`:`existing`),[o,s]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)({claude:!0}),[_,v]=(0,Q.useState)(!1),{t:y}=K(`setup`),{addProject:b}=at(),{status:x,isLoading:S,error:C,recheck:w}=sA(),T=(0,Q.useMemo)(()=>{if(!x||x.ok)return null;let e=x.missingRequired.map(e=>e.label);return e.length===0?null:y(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[x,y]),E=x!==null&&!x.ok&&!C;(0,Q.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n===`tiers`||n===`providerIssues`||n===`launchDescriptors`||typeof r==`boolean`&&(t[n]=r);g(t)}).catch(()=>{})},[e]);async function D(){let e=o.trim();if(!e){J.error(y(`addProject.errors.pathRequired`));return}m(!0);try{let t=d.map(e=>({path:e.trim()})).filter(e=>e.path),n=t.length?await b(e,l.trim()||void 0,void 0,t):await b(e,l.trim()||void 0);if(!n)return;J.success(y(`addProject.toasts.registered`,{name:n.project.name})),O()}catch(e){J.error(y(`addProject.errors.addFailed`),{description:e.message})}finally{m(!1)}}function O(){s(``),u(``),f([]),a(r?`choose`:`existing`),t()}function k(e){e||O()}let A=!Object.values(h).some(Boolean);return i===`choose`?(0,$.jsx)(Hn,{open:e,onOpenChange:k,children:(0,$.jsxs)(Bn,{className:`max-w-md`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(as,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,$.jsx)(Mn,{children:y(`addProject.chooser.description`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 py-2`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chooser-existing`,onClick:()=>a(`existing`),className:`flex flex-col items-start gap-2 rounded-lg border border-border/40 p-4 text-left transition-colors hover:border-accent-primary/50 hover:bg-accent-primary/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,$.jsx)(is,{className:`h-5 w-5 text-accent-info`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.existingTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.existingDescription`)})]}),(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chooser-new`,onClick:()=>{O(),n?.()},className:`flex flex-col items-start gap-2 rounded-lg border border-border/40 p-4 text-left transition-colors hover:border-accent-highlight/50 hover:bg-accent-highlight/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,$.jsx)(un,{className:`h-5 w-5 text-accent-highlight`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.newTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.newDescription`)})]})]})]})}):(0,$.jsx)(Hn,{open:e,onOpenChange:k,children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-h-[calc(100vh-2rem)] w-[calc(100vw-2rem)] max-w-2xl overflow-x-hidden`,"data-testid":`existing-project-dialog`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(as,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,$.jsx)(Mn,{children:y(`addProject.description`)})]}),A&&(0,$.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:y(`addProject.noProviderDetected`)}),(0,$.jsx)(LK,{status:x,isLoading:S,error:C,onMoreInfo:()=>v(!0),onRefresh:w}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.pathLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{placeholder:y(`addProject.pathPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()},autoFocus:!0,className:`flex-1`}),GK&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,title:y(`addProject.browseForFolder`),onClick:async()=>{try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!1,title:y(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(s(t),l||u(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,$.jsx)(as,{className:`w-4 h-4`})})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.pathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:y(`addProject.optional`)})]}),(0,$.jsx)(Qk,{placeholder:y(`addProject.namePlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()}}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.nameHint`)})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2`,disabled:p,children:[(0,$.jsx)(`legend`,{className:`text-xs font-medium`,children:y(`common:repositories.additional`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:y(`common:repositories.sharedBacklog`)}),d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{"aria-label":y(`common:repositories.folderNumber`,{number:t+2}),value:e,placeholder:y(`addProject.pathPlaceholder`),onChange:e=>f(n=>n.map((n,r)=>r===t?e.target.value:n))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":y(`common:repositories.removeFolder`),onClick:()=>f(e=>e.filter((e,n)=>n!==t)),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]},t)),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(GK)try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!0});t&&f(e=>[...e,...Array.isArray(t)?t:[t]]);return}catch{}f(e=>[...e,``])},children:[(0,$.jsx)(cn,{className:`mr-1 h-3.5 w-3.5`}),y(`common:repositories.addFolder`)]})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,disabled:p,children:y(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,onClick:D,disabled:p||!o.trim()||E||S,title:E?T??void 0:void 0,"data-testid":`add-project-submit`,children:y(p?`addProject.adding`:`addProject.submit`)})]}),(0,$.jsx)(WK,{open:_,onClose:()=>v(!1),status:x,onRecheck:w,isRechecking:S})]})})}var qK=1,JK=.9,YK=.8,XK=.17,ZK=.1,QK=.999,$K=.9999,eq=.99,tq=/[\\\/_+.#"@\[\(\{&]/,nq=/[\\\/_+.#"@\[\(\{&]/g,rq=/[\s-]/,iq=/[\s-]/g;function aq(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?qK:eq;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=aq(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=qK:tq.test(e.charAt(l-1))?(d*=YK,p=e.slice(i,l-1).match(nq),p&&i>0&&(d*=QK**+p.length)):rq.test(e.charAt(l-1))?(d*=JK,m=e.slice(i,l-1).match(iq),m&&i>0&&(d*=QK**+m.length)):(d*=XK,i>0&&(d*=QK**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=$K)),(d<ZK&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=aq(e,t,n,r,l+1,a+2,o),f*ZK>d&&(d=f*ZK)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function oq(e){return e.toLowerCase().replace(iq,` `)}function sq(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,aq(e,t,oq(e),oq(t),0,0,{})}var cq=`[cmdk-group=""]`,lq=`[cmdk-group-items=""]`,uq=`[cmdk-group-heading=""]`,dq=`[cmdk-item=""]`,fq=`${dq}:not([aria-disabled="true"])`,pq=`cmdk-item-select`,mq=`data-value`,hq=(e,t,n)=>sq(e,t,n),gq=Q.createContext(void 0),_q=()=>Q.useContext(gq),vq=Q.createContext(void 0),yq=()=>Q.useContext(vq),bq=Q.createContext(void 0),xq=Q.forwardRef((e,t)=>{let n=Fq(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Fq(()=>new Set),i=Fq(()=>new Map),a=Fq(()=>new Map),o=Fq(()=>new Set),s=Nq(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Cn(),y=Cn(),b=Cn(),x=Q.useRef(null),S=Rq();Pq(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Pq(()=>{S(6,k)},[]);let C=Q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??hq;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(lq);t?t.appendChild(e.parentElement===t?e:e.closest(`${lq} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${lq} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${cq}[${mq}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(mq);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(cq)?.querySelector(uq))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${dq}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(fq)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(mq))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(mq))}function P(e){let t=A()?.closest(cq),n;for(;t&&!n;)t=e>0?jq(t,cq):Mq(t,cq),n=t?.querySelector(fq);n?C.setState(`value`,n.getAttribute(mq)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Q.createElement(_n.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(pq);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Vq},c),Bq(e,e=>Q.createElement(vq.Provider,{value:C},Q.createElement(gq.Provider,{value:w},e))))}),Sq=Q.forwardRef((e,t)=>{let n=Cn(),r=Q.useRef(null),i=Q.useContext(bq),a=_q(),o=Nq(e),s=o.current?.forceMount??i?.forceMount;Pq(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Lq(n,r,[e.value,e.children,r],e.keywords),l=yq(),u=Iq(e=>e.value&&e.value===c.current),d=Iq(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(pq,f),()=>t.removeEventListener(pq,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Q.createElement(_n.div,{ref:Pn(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Cq=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Cn(),s=Q.useRef(null),c=Q.useRef(null),l=Cn(),u=_q(),d=Iq(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Pq(()=>u.group(o),[]),Lq(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(_n.div,{ref:Pn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Bq(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(bq.Provider,{value:f},e))))}),wq=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=Iq(e=>!e.search);return!n&&!a?null:Q.createElement(_n.div,{ref:Pn(i,t),...r,"cmdk-separator":``,role:`separator`})}),Tq=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=yq(),o=Iq(e=>e.search),s=Iq(e=>e.selectedItemId),c=_q();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(_n.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Eq=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=Iq(e=>e.selectedItemId),c=_q();return Q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Q.createElement(_n.div,{ref:Pn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Bq(e,e=>Q.createElement(`div`,{ref:Pn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Dq=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(zn,{open:n,onOpenChange:r},Q.createElement(kn,{container:o},Q.createElement(On,{"cmdk-overlay":``,className:i}),Q.createElement(Un,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(xq,{ref:t,...s}))))}),Oq=Q.forwardRef((e,t)=>Iq(e=>e.filtered.count===0)?Q.createElement(_n.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),kq=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(_n.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Bq(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),Aq=Object.assign(xq,{List:Eq,Item:Sq,Input:Tq,Group:Cq,Separator:wq,Dialog:Dq,Empty:Oq,Loading:kq});function jq(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Mq(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Nq(e){let t=Q.useRef(e);return Pq(()=>{t.current=e}),t}var Pq=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Fq(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function Iq(e){let t=yq(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function Lq(e,t,n,r=[]){let i=Q.useRef(),a=_q();return Pq(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(mq,s),i.current=s}),i}var Rq=()=>{let[e,t]=Q.useState(),n=Fq(()=>new Map);return Pq(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function zq(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Bq({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(zq(t),{ref:t.ref},n(t.props.children)):n(t)}var Vq={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Hq(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase()}function Uq(e,t,n=[]){let r=Hq(e.trim());return!r||Hq(t).includes(r)?!0:n.some(e=>e&&Hq(e).includes(r))}function Wq(e,t){return Tb(t.updated_at)-Tb(e.updated_at)}function Gq(e,t=8){return[...e].sort(Wq).slice(0,Math.max(0,t)).map(e=>({conversation:e,match:`recent`,messageId:null,snippet:null}))}function Kq(e,t,n,r=20){let i=Hq(t.trim());if(!i)return[];let a=Hq(n);return[...e].sort(Wq).filter(e=>Hq(e.title?.trim()||``).includes(i)||!e.title?.trim()&&a.includes(i)).slice(0,Math.max(0,r)).map(e=>({conversation:e,match:`title`,messageId:null,snippet:null}))}function qq(e,t,n=20){let r=new Map;for(let e of t)r.has(e.conversation.id)||r.set(e.conversation.id,e);let i=[],a=new Set;for(let t of e){let e=r.get(t.conversation.id);i.push(e?{conversation:e.conversation,match:`title`,messageId:e.messageId,snippet:e.snippet}:t),a.add(t.conversation.id)}for(let e of[`title`,`content`])for(let n of t)n.match!==e||a.has(n.conversation.id)||(a.add(n.conversation.id),i.push({conversation:n.conversation,match:n.match,messageId:n.messageId,snippet:n.snippet}));return i.slice(0,Math.max(0,n))}function Jq(e){return e===`agent`?[`missions`,`projects`,`spec`,`jobs`,`navigation`]:[`projects`,`missions`,`spec`,`jobs`,`navigation`]}var Yq=[];function Xq(e){let t=[],n=0;return e.ranges.forEach(([r,i],a)=>{r>n&&t.push(e.text.slice(n,r)),t.push((0,$.jsx)(`mark`,{className:`rounded-sm bg-accent-primary/20 px-0.5 text-foreground`,children:e.text.slice(r,i)},a)),n=i}),n<e.text.length&&t.push(e.text.slice(n)),t}function Zq({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=K(`commands`),{t:i}=K(`agent`),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)({query:``,hits:Yq}),{projects:h,activeProjectId:g,setActiveProjectId:_}=at(),{leftMode:y,rightMode:b,cycleLeftMode:x,cycleRightMode:S}=eN(),{uiMode:C}=Ij(),{conversations:w,liveByConversation:T,selectConversation:E,open:D}=lM(),O=r(y===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:y===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),k=r(b===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:b===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),A=v(),j=(0,Q.useRef)(!1),M=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Q.useEffect)(()=>{if(!a){j.current=!1,c(``);return}if(j.current)return;j.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${nt()}/config`),fetch(`${nt()}/jobs?limit=10`)]);if(e.ok){let t=await e.json();u(t.commands)}if(t.ok){let e=await t.json();f(e.jobs)}}catch{}}e()},[a]),(0,Q.useEffect)(()=>{let e=s.trim(),t=++M.current;if(!a||!e)return;let n=new AbortController,r=setTimeout(()=>{za(e,20,n.signal).then(n=>{t===M.current&&m({query:e,hits:n})}).catch(()=>{})},80);return()=>{clearTimeout(r),n.abort()}},[s,a]);let N=i(`mission.untitled`),P=(0,Q.useMemo)(()=>{let e=s.trim();return e?qq(Kq(w,e,N),p.query===e?p.hits:Yq):Gq(w)},[w,s,p,N]),F=(0,Q.useMemo)(()=>new Map(h.map(e=>[e.id,e.name])),[h]),I=(0,Q.useCallback)(e=>{_(e),o(!1)},[_]),L=(0,Q.useCallback)(e=>{o(!1),E(e),C!==`agent`&&D()},[E,D,C]),R=(0,Q.useCallback)(async e=>{o(!1);try{let t=await fetch(`${nt()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:`/specrails:${e}`})}),n=await t.json();if(!t.ok)throw Error(n.error??r(`errors.spawnFailed`));J.success(r(`toasts.queued`,{name:e})),A(`/jobs/${n.jobId}`)}catch(e){J.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[A,r]),z=(0,Q.useCallback)(e=>{o(!1),A(`/jobs/${e}`)},[A]),B=(0,Q.useCallback)(e=>{o(!1),A(e)},[A]),ee=(0,Q.useCallback)(e=>{e&&(o(!1),e())},[]),V=`flex items-center gap-3 px-3 py-2 rounded-lg cursor-pointer text-sm data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground`,H=h.filter(e=>Uq(s,e.name,[e.slug])),te=l.filter(e=>Uq(s,e.name,[e.slug,e.description??``])),ne=d.filter(e=>Uq(s,`${e.command} ${e.id}`,[e.status])),re=[{key:`dashboard`,label:r(`palette.nav.dashboard`),keywords:[`home`],icon:(0,$.jsx)(Cs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/`)},...t?[{key:`desktopAnalytics`,label:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],icon:(0,$.jsx)(ko,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>ee(t)}]:[],{key:`projectAnalytics`,label:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],icon:(0,$.jsx)(Do,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/analytics`)},{key:`activityFeed`,label:r(`palette.nav.activityFeed`),keywords:[`log`],icon:(0,$.jsx)(po,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/activity`)},{key:`desktopSettings`,label:r(`palette.nav.desktopSettings`),keywords:[`configuration`],icon:(0,$.jsx)(nc,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>e?ee(e):B(`/settings`)},{key:`docs`,label:r(`palette.nav.docs`),keywords:[`documentation`],icon:(0,$.jsx)($t,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>n?ee(n):B(`/docs`)},{key:`leftSidebar`,label:O,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(Is,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{x(),o(!1)}},{key:`rightSidebar`,label:k,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(Ls,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{S(),o(!1)}}].filter(e=>Uq(s,e.label,e.keywords)),ie={missions:P.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.missions`),"data-testid":`palette-group-missions`,children:P.map(e=>{let{conversation:t}=e,n=T.get(t.id)?.isStreaming===!0,a=t.pinned_project_id?F.get(t.pinned_project_id)??null:null;return(0,$.jsxs)(Aq.Item,{value:`mission:${t.id}`,onSelect:()=>L(t.id),className:X(V,`items-start`),"data-testid":`palette-mission-${t.id}`,children:[(0,$.jsx)(Yt,{className:`w-4 h-4 mt-0.5 text-accent-primary shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:t.title?.trim()||N}),n&&(0,$.jsxs)(`span`,{"aria-label":i(`mission.working`),"data-testid":`palette-mission-live-${t.id}`,className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] tabular-nums text-muted-foreground/60`,title:Ob(t.updated_at),children:Db(t.updated_at)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 text-[11px] text-muted-foreground/60`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:a??r(`palette.missions.home`)}),e.snippet&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,"data-testid":`palette-mission-snippet-${t.id}`,children:Xq(e.snippet)})]})]})]})]},t.id)})},`missions`),projects:H.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.projects`),"data-testid":`palette-group-projects`,children:H.map(e=>(0,$.jsxs)(Aq.Item,{value:e.name,keywords:[e.slug],onSelect:()=>I(e.id),className:X(V,e.id===g&&`text-accent-primary`),children:[(0,$.jsx)(as,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===g&&(0,$.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))},`projects`),spec:te.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.spec`),children:te.map(e=>(0,$.jsxs)(Aq.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>R(e.slug),className:V,children:[(0,$.jsx)(hn,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))},`spec`),jobs:ne.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.jobs`),children:ne.map(e=>(0,$.jsxs)(Aq.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>z(e.id),className:V,children:[(0,$.jsx)(Eo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,$.jsx)(`span`,{className:X(`text-[10px] font-medium`,e.status===`completed`&&`text-accent-success`,e.status===`failed`&&`text-destructive`,e.status===`running`&&`text-accent-info`,e.status===`queued`&&`text-muted-foreground`),children:r(`common:status.${e.status}`,{defaultValue:e.status})})]},e.id))},`jobs`),navigation:re.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.navigation`),children:re.map(e=>(0,$.jsxs)(Aq.Item,{value:e.label,keywords:e.keywords,onSelect:e.onSelect,className:V,children:[e.icon,(0,$.jsx)(`span`,{children:e.label})]},e.key))},`navigation`)};return(0,$.jsxs)(Aq.Dialog,{open:a,onOpenChange:o,shouldFilter:!1,label:r(`palette.label`),className:X(`fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%]`,`border border-border/30 bg-popover shadow-2xl backdrop-blur-md rounded-xl overflow-hidden`),children:[(0,$.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,$.jsx)(ln,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(Aq.Input,{value:s,onValueChange:c,placeholder:r(C===`agent`?`palette.searchPlaceholderAgent`:`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 rounded border border-border/50 bg-muted/30 px-1.5 py-0.5 text-[10px] text-muted-foreground font-mono`,children:`esc`})]}),(0,$.jsxs)(Aq.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,$.jsx)(Aq.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),Jq(C).map(e=>ie[e])]}),(0,$.jsx)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var Qq=`
71
+
72
+ ---
73
+
74
+ ## Contract Layer
75
+
76
+ `;function $q(e){return`contract-refine:${e}`}async function eJ(e,t){try{let n=await fetch(`${He}/api/projects/${e}/tickets/${t}/contract-refine`,{method:`POST`});if(n.ok)J.loading(G.t(`activity:contractRefine.refining`),{id:$q(t)});else{let e=await n.json().catch(()=>({}));J.error(e.error?G.t(`activity:contractRefine.retryRejectedWithError`,{error:e.error}):G.t(`activity:contractRefine.retryRejected`),{id:$q(t)})}}catch(e){J.error(G.t(`activity:contractRefine.retryFailed`,{message:e.message}),{id:$q(t)})}}function tJ({children:e}){let{registerHandler:t,unregisterHandler:n}=qe(),r=(0,Q.useRef)(new Map),i=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`explore.contract_refine_failed`)return;let n=t.ticketId,i=t.projectId,a=typeof t.provider==`string`?t.provider:void 0,o=t.reason??`unknown`;if(typeof n!=`number`||!i)return;r.current.set(n,i);let s=pr(a)?{label:G.t(`common:actions.retry`),onClick:()=>void eJ(i,n)}:void 0;J.error(G.t(`activity:contractRefine.skipped`),{id:$q(n),description:G.t(`activity:contractRefine.reason`,{reason:o}),...s?{action:s}:{},duration:15e3})},[]),a=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`ticket_updated`)return;let n=t.ticket;n&&typeof n.description==`string`&&n.description.includes(Qq)&&J.success(G.t(`activity:contractRefine.added`,{title:n.title||`#${n.id}`}),{id:$q(n.id),duration:3500})},[]);return(0,Q.useLayoutEffect)(()=>(t(`_contract_refine_failed`,i),t(`_contract_refine_ticket_updated`,a),()=>{n(`_contract_refine_failed`),n(`_contract_refine_ticket_updated`)}),[t,n,i,a]),(0,Q.useEffect)(()=>()=>r.current.clear(),[]),(0,$.jsx)($.Fragment,{children:e})}function nJ(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function rJ(){let{t:e}=K(`mcp`),t=DU()?.languageId;(0,Q.useEffect)(()=>{nJ()&&Y(`set_tray_labels`,{open:e(`tray.open`),exit:e(`tray.exit`)}).catch(()=>{})},[e,t])}var iJ=`input, textarea, select, [contenteditable="true"], [contenteditable=""], .monaco-editor, .xterm, [data-native-menu]`;function aJ(e){return e instanceof Element&&e.closest(iJ)!==null}function oJ(e){aJ(e.target)||e.preventDefault()}function sJ(){(0,Q.useEffect)(()=>(document.addEventListener(`contextmenu`,oJ),()=>document.removeEventListener(`contextmenu`,oJ)),[])}var cJ={jobs:[],activeJobId:null,paused:!1};function lJ(e){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(cJ),[p,m]=(0,Q.useState)(0),h=(0,Q.useRef)(e);h.current=e;let g=(0,Q.useRef)(new Map),_=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(_.current&&_.current,_.current=e,e){let t=g.current.get(e);t?(n(t.phaseDefinitions),i(t.phases),o(t.projectName),u(t.recentJobs),f(t.queueState)):(n([]),i({}),o(``),u([]),f(cJ))}c([])},[e]);let v=(0,Q.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`)return;let r=h.current;if(!(r&&t.projectId&&t.projectId!==r))if(t.type===`desktop.project_recovered`)t.projectId===r&&m(e=>e+1);else if(t.type===`init`){let e=t.projectName??``,a=t.phaseDefinitions??[],s={};for(let e of a)s[e.key]=t.phases?.[e.key]??`idle`;let l=t.recentJobs??[],d=t.queue??cJ;o(e),n(a),i(s),c(t.logBuffer??[]),u(l),f(d),r&&g.current.set(r,{phaseDefinitions:a,phases:s,projectName:e,recentJobs:l,queueState:d})}else t.type===`phase`?i(e=>({...e,[t.phase]:t.state})):t.type===`log`?c(e=>[...e,{source:t.source,line:t.line,timestamp:t.timestamp,processId:t.processId}]):t.type===`queue`&&f({jobs:t.jobs??[],activeJobId:t.activeJobId??null,paused:t.paused??!1})},[]),{registerHandler:y,unregisterHandler:b,connectionStatus:x}=qe();return(0,Q.useLayoutEffect)(()=>(y(`pipeline`,v),()=>b(`pipeline`)),[v,y,b]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let e=await fetch(`${nt()}/state`);if(t||!e.ok)return;let r=await e.json();if(t)return;if(r.projectName&&o(r.projectName),r.phaseDefinitions){n(r.phaseDefinitions);let e={};for(let t of r.phaseDefinitions)e[t.key]=r.phases?.[t.key]??`idle`;i(e)}r.recentJobs&&u(r.recentJobs),r.queue&&f(r.queue)}catch{}}return r(),()=>{t=!0}},[e,p]),{phases:r,phaseDefinitions:t,projectName:a,logLines:s,connectionStatus:x,recentJobs:l,queueState:d}}function uJ({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=K(`nav`),{t:i}=K(`analytics`),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(`connecting`),u=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){J.success(r(`statusBar.connectionRestored`)),c(!0);let e=setTimeout(()=>c(!1),2e3);return()=>clearTimeout(e)}u.current&&e===`connected`&&(u.current=!1),l.current=e},[e]),(0,Q.useEffect)(()=>{u.current&&=!1},[]),(0,Q.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${nt()}/stats`);if(e.ok){let t=await e.json();o(t)}}catch{}}e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[e,n]);let d=!n||e!==`connected`||s;return(0,$.jsxs)(`footer`,{className:`h-7 flex items-center justify-between px-4 border-t border-border/30 bg-background/80 backdrop-blur-sm text-[10px] text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,$.jsx)(`span`,{className:X(`w-1.5 h-1.5 rounded-full transition-colors`,e===`connected`&&!s&&`bg-accent-success`,e===`connected`&&s&&`bg-accent-info animate-pulse`,e===`connecting`&&`bg-accent-warning animate-[pulse_0.75s_ease-in-out_infinite]`,e===`disconnected`&&`bg-destructive`)}),(0,$.jsxs)(`span`,{className:X(`transition-colors`,e===`connected`&&!s&&`text-accent-success`,e===`connected`&&s&&`text-accent-info`,e===`connecting`&&`text-accent-warning`,e===`disconnected`&&`text-destructive`),children:[e===`connected`&&!s&&r(`statusBar.connected`),e===`connected`&&s&&r(`statusBar.syncing`),e===`connecting`&&r(`statusBar.reconnecting`),e===`disconnected`&&r(`statusBar.disconnected`)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&(a.totalCostUsd>0||(a.unpricedRuns??0)>0)&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0),t=a.unpricedRuns??0,n=a.pricedRuns??Math.max(0,(a.totalJobs??0)-t),r=a.totalCostUsd===0&&t>0&&n===0,o=t>0&&(n>0||a.totalCostUsd>0);return(0,$.jsx)(`span`,{"data-estimated":e?`true`:void 0,"data-testid":r?`statusbar-cost-unavailable`:void 0,title:r?i(`desktop.costUnavailable`):o?i(`desktop.costPartiallyUnavailable`,{count:t}):e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:r?i(`desktop.costUnavailableShort`):`${e?`~`:``}${o?`≥`:``}$${a.totalCostUsd.toFixed(2)}`})})(),t]})]})}var dJ=(0,Q.lazy)(()=>c(()=>import(`./AgentBrowserCapture-C_WpXceT.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([85,1,7,9,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72])));function fJ(){let{browserOpen:e}=Ux(),{active:t}=lM(),n=si(),r=!n.current&&n.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),{activeProjectId:i}=at();return!e||!i||r?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(dJ,{projectId:i,conversationId:t?.id??null})})}function pJ(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=he(),{tickets:i}=T(),a=p(),o=v(),s=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(s.current||i.length===0||new URLSearchParams(a.search).get(`compare`)&&typeof window<`u`&&window.innerWidth<900)return;s.current=!0;let e=new URLSearchParams(a.search),c=e.get(`compare`),l=e.get(`compareSide`);if(!c)return;let u=Number.parseInt(c,10),d=l===`right`?`right`:`left`;if(!i.some(e=>e.id===u)){let e=new URLSearchParams(a.search);e.delete(`compare`),e.delete(`compareSide`);let t=e.toString();o({pathname:a.pathname,search:t?`?${t}`:``},{replace:!0});return}let f=e.get(`compareOrigin`);if(f){let e=Number.parseInt(f,10);if(i.some(t=>t.id===e)){t(e),n(d),r(u,d===`left`?`right`:`left`);return}}t(u)},[i,a.search,a.pathname,o,t,n,r]),(0,Q.useEffect)(()=>{if(!s.current)return;let t=new URLSearchParams(a.search),n=t.has(`compare`);if(e.originSide===null){if(n){t.delete(`compare`),t.delete(`compareSide`),t.delete(`compareOrigin`);let e=t.toString();o({pathname:a.pathname,search:e?`?${e}`:``},{replace:!0})}return}let r=e.originSide===`left`?e.leftId:e.rightId,i=e.originSide===`left`?e.rightId:e.leftId;if(r==null||e.originSide==null)return;let c=new URLSearchParams(a.search);c.set(`compareSide`,e.originSide),c.set(`compareOrigin`,String(r)),i==null?c.delete(`compare`):c.set(`compare`,String(i));let l=c.toString();l!==(a.search.startsWith(`?`)?a.search.slice(1):a.search)&&o({pathname:a.pathname,search:l?`?${l}`:``},{replace:!0})},[e,a.search,a.pathname,o])}function mJ(e){let{key:t,detail:n}=jt(e);return[`chunk_failed`,`chunk_stalled`,`chunk_stopped`,`provider_limit`,`launch_rejected`,`head_missing`,`head_discarded`,`run_lost`].includes(t)?G.t(`builder:milestoneProgress.chain.reasons.${t}`,{detail:n}):e??``}function hJ({setActiveProjectId:e}={}){let t=v(),n=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{n.current=t},[t]);let r=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{r.current=e},[e]);let i=(0,Q.useRef)(new Map),a=(0,Q.useRef)(new Map),{registerHandler:o,unregisterHandler:s}=qe();(0,Q.useEffect)(()=>{let e=`milestone-notifications`;return o(e,e=>{let t=e;if(!t||typeof t.projectId!=`string`)return;let o=t.projectId;if(t.type===`milestone.chain_changed`){let e=yt(t.chain);if(!e)return;let n=i.current.get(e.id);i.current.set(e.id,e);let r=xt(e.milestoneN);if(e.status===`running`&&e.nextChunk>1&&(!n||n.nextChunk<e.nextChunk)&&J.success(G.t(`builder:milestoneProgress.toast.chunkLaunched`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:`chain-launch:${e.id}:${e.nextChunk}`}),e.status===`awaiting_approval`&&(!n||n.status!==`awaiting_approval`||n.nextChunk!==e.nextChunk)){let t=`chain-checkpoint:${e.id}:${e.nextChunk}`;J.success(G.t(`builder:milestoneProgress.toast.checkpoint`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:t,duration:6e4,action:{label:G.t(`builder:milestoneProgress.toast.launchNext`),onClick:()=>{OA(o,e.id).then(e=>{e.ok?J.success(G.t(`builder:milestoneProgress.chain.nextLaunched`),{id:t}):J.error(G.t(`builder:milestoneProgress.chain.resumeFailed`),{id:t,description:e.detail??e.error})})}},cancel:{label:G.t(`builder:milestoneProgress.toast.autoContinue`),onClick:()=>{AA(o,e.id,!0).then(e=>{e.ok?J.success(G.t(`builder:milestoneProgress.chain.autoOn`),{id:t}):J.error(G.t(`builder:milestoneProgress.chain.autoFailed`),{id:t,description:e.detail??e.error})})}}})}e.status===`paused`&&(!n||n.status!==`paused`||n.pauseReason!==e.pauseReason)&&J.warning(G.t(`builder:milestoneProgress.toast.paused`,{milestone:r,reason:mJ(e.pauseReason)}),{id:`chain-paused:${e.id}`,duration:3e4,action:{label:G.t(`builder:milestoneProgress.toast.resume`),onClick:()=>{OA(o,e.id).then(t=>{t.ok?J.success(G.t(`builder:milestoneProgress.chain.resumed`),{id:`chain-paused:${e.id}`}):J.error(G.t(`builder:milestoneProgress.chain.resumeFailed`),{id:`chain-paused:${e.id}`,description:t.detail??t.error})})}}});return}if(t.type===`blueprint.milestone_progress`){for(let e of Tt(t.progress)){let t=`${o}:${e.id}`,i=a.current.get(t);if(a.current.set(t,e.state),!(i===void 0||i===e.state)&&e.state===`delivered`){let i=Et(e);J.success(G.t(`builder:milestoneProgress.toast.delivered`,{milestone:xt(e.n),count:e.counts.onReview}),{id:`milestone-delivered:${t}`,duration:3e4,...i?{action:{label:G.t(`builder:milestoneProgress.toast.review`),onClick:()=>{r.current?.(o);let e=ve?`/review/${i.id}`:`/`;setTimeout(()=>{n.current(e)},50)}}}:{}})}}return}t.type===`blueprint.milestone_completed`&&typeof t.n==`number`&&J.success(G.t(`builder:milestoneProgress.toast.completed`,{milestone:xt(t.n)}),{id:`milestone-completed:${o}:${t.milestoneId??t.n}`,duration:15e3})}),()=>s(e)},[o,s])}function gJ(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:_J(e)?`review`:null}function _J(e){let t=/^\/review\/([^/]+)\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function vJ(e){let t=/^\/loops\/([^/]+)\/edit\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function yJ({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r,reviewOpen:i=null}){if(e===`agent`){let e=gJ(t);if(!e)return null;if(e===`review`)return{kind:`modalize`,surface:e,backgroundPath:`/`,reviewDeliveryId:_J(t)??void 0};let n=e===`loops`?vJ(t):null;return n?{kind:`modalize`,surface:e,backgroundPath:`/`,loopBuilderId:n}:{kind:`modalize`,surface:e,backgroundPath:`/`}}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:i?{kind:`route`,surface:`review`,path:`/review/${encodeURIComponent(i)}`}:null}var bJ=(0,Q.lazy)(()=>c(()=>import(`./JobDetailPage-_rIDpNfo.js`),__vite__mapDeps([86,1,7,11,10,9,8,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,81]))),xJ=(0,Q.lazy)(()=>c(()=>import(`./ReviewPacketPage-BBd617OM.js`),__vite__mapDeps([87,1,7,11,10,9,8,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,88]))),SJ=(0,Q.lazy)(()=>c(()=>import(`./JobsPage-C6xcijbs.js`),__vite__mapDeps([89,1,7,11,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,8,51,59,60,49,63,64,65,66,67,68,69,76,81,90,52]))),CJ=(0,Q.lazy)(()=>c(()=>import(`./AnalyticsPage-C6ZZI_zg.js`),__vite__mapDeps([91,1,7,11,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,8,46,65,67,68,72,90,52,92,93]))),wJ=(0,Q.lazy)(()=>c(()=>import(`./ActivityFeedPage-C7XJ5-bJ.js`),__vite__mapDeps([94,1,7,12,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,8,51,54,62]))),TJ=(0,Q.lazy)(()=>c(()=>import(`./AgentsPage-D577NzIM.js`),__vite__mapDeps([95,1,7,8,12,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,47,11,48,49,50,54,55,57,58,59,60,63,64,65,69,72,81]))),EJ=(0,Q.lazy)(()=>c(()=>import(`./CodePage-B5z5oLnP.js`),__vite__mapDeps([96,1,7,8,10,11,9,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72]))),DJ=(0,Q.lazy)(()=>c(()=>import(`./IntegrationsPage-Bhy58lnQ.js`),__vite__mapDeps([97,7,1,11,10]))),OJ=(0,Q.lazy)(()=>c(()=>import(`./PluginsPage-Dn2jPvJL.js`),__vite__mapDeps([98,1,7,12,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,8,52,54,58,59,60,61,63,49,64,65,69,72]))),kJ=(0,Q.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-D_V9RuGg.js`),__vite__mapDeps([99,1,7,12,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,65,64,92,8,93]))),AJ=(0,Q.lazy)(()=>c(()=>import(`./DocsPage-BkE4m4wp.js`),__vite__mapDeps([100,1,7,11,10,42,50,54,64,65,66,75,101,102]))),jJ=(0,Q.lazy)(()=>c(()=>import(`./DocsDialog-Beg82MEe.js`),__vite__mapDeps([103,1,7,42,50,54,63,8,49,64,65,66,75,101,102]))),MJ=(0,Q.lazy)(()=>c(()=>import(`./LoopsPage-B-ketPET.js`),__vite__mapDeps([104,1,7,11,10,42,44,8,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,52,55,56,57,48,59,105,63,49,64,65,69,70,71,72,78,74,53]))),NJ=(0,Q.lazy)(()=>c(()=>import(`./LoopBuilderPage-A-Mt6EjT.js`),__vite__mapDeps([106,1,7,8,11,10,42,44,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,45,74,53,56,57,59,60,105,63,49,64,65,69,71,93,107]))),PJ=28;function FJ({surface:e,onClose:t}){let{t:n}=K(`nav`),r=n(e===`loops`?`arcSidebar.loops`:e===`review`?`arcSidebar.review`:`arcSidebar.plugins`);return(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-border bg-popover/95 px-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`grid h-7 w-7 shrink-0 place-items-center rounded-md border border-accent-primary/20 bg-accent-primary/10 text-accent-primary`,children:(0,$.jsx)(e===`loops`?gc:e===`review`?Qo:Ws,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-popover`,"aria-label":n(`common:actions.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})})]})}var IJ=new Set([`/settings`,`/loops`,`/plugins`]);function LJ(e){return IJ.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var RJ=`specrails-desktop:routeMemory`;try{localStorage.removeItem(RJ)}catch{}function zJ(e){let t=p(),n=v(),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{hk((e,t)=>{r.current.set(e,t)})},[]),(0,Q.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,Q.useEffect)(()=>{if(i.current&&i.current!==e&&!LJ(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!LJ(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Q.useEffect)(()=>{e&&t.pathname!==`/`&&!LJ(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function BJ(){let{t:e}=K(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setActiveProjectId:a}=at(),{cycleLeftMode:o,cycleRightMode:s}=eN(),c=v(),l=p(),u=Ca(),d=lM(),{startNewConversation:h}=d,{uiMode:_}=Ij();pJ();let[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(!1),I=(0,Q.useCallback)(()=>F(!1),[]),[L,R]=(0,Q.useState)(()=>!oK());zJ(n),rJ();let{cheatsheetOpen:z,setCheatsheetOpen:B,openCheatsheet:ee}=gG(),H=[`/`,`/jobs`,`/analytics`,...V?[`/agents`]:[],...se?[`/code`]:[],`/integrations`,`/settings`];hG({onOpenCheatsheet:ee,onToggleLeftSidebar:o,onToggleRightSidebar:s,onSwitchProject:e=>{let n=t[e-1];n&&a(n.id)},onSwitchProjectPage:e=>{let t=H[e-1];t&&c(t)},onToggleTerminalPanel:Ce?()=>{n&&(u.togglePanel(n),u.getState(n).visibility===`hidden`?queueMicrotask(()=>u.focusActive(n)):u.focusActive(n))}:void 0,onToggleAgentChat:P&&_!==`agent`?()=>d.toggle():void 0}),oG({setActiveProjectId:a,projectsById:(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])}),hJ({setActiveProjectId:a}),(0,Q.useEffect)(()=>{SA()},[]);let te=t.find(e=>e.id===n),ne=l.pathname.startsWith(`/loops`),re=l.pathname.startsWith(`/plugins`),ie=l.pathname.startsWith(`/docs`)||_!==`agent`&&(ne||re);(0,Q.useLayoutEffect)(()=>{let e=yJ({uiMode:_,pathname:l.pathname,loopsOpen:T,pluginsOpen:k,reviewOpen:j});if(e){if(e.kind===`modalize`){if(e.surface===`review`){e.reviewDeliveryId&&M(e.reviewDeliveryId),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}e.surface===`loops`?(A(!1),E(!0),e.loopBuilderId&&O(e.loopBuilderId)):(E(!1),A(!0)),h(n),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}E(!1),A(!1),M(null),l.pathname!==e.path&&c(e.path,{replace:!0})}},[n,l.pathname,T,c,k,j,h,_]);let{connectionStatus:ae}=lJ(),oe=wa(n),ce=_===`agent`?0:PJ,le=(0,Q.useRef)(null),[ue,de]=(0,Q.useState)(typeof window<`u`?window.innerHeight:820);(0,Q.useLayoutEffect)(()=>{if(!Ce)return;let e=le.current;if(!e)return;let t=()=>de(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Q.useEffect)(()=>{!Ce||!n||u.ensureProject(n)},[n,u]);let fe=Ce&&_===`kanban`&&oe.visibility===`hidden`?(0,$.jsx)(CN,{isOpen:!1,onClick:()=>n&&u.setVisibility(n,`restored`)}):null;return r?(0,$.jsxs)(`div`,{className:`flex h-full`,children:[(0,$.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,$.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,$.jsx)(NK,{onAddProject:()=>b(!0),onOpenLoops:()=>{_===`agent`?E(!0):c(`/loops`)},onOpenPlugins:()=>{_===`agent`?A(!0):c(`/plugins`)},onOpenAnalytics:()=>w(!0),onOpenDocs:()=>F(!0),onOpenSettings:()=>S(!0)}),(0,$.jsxs)(`div`,{ref:le,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,$.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:_===`agent`&&!ie?(0,$.jsx)(BM,{}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsxs)(g,{children:[(0,$.jsx)(m,{path:`/docs`,element:(0,$.jsx)(AJ,{})}),(0,$.jsx)(m,{path:`/docs/:category/:slug`,element:(0,$.jsx)(AJ,{})}),ge&&(0,$.jsx)(m,{path:`/loops`,element:(0,$.jsx)(MJ,{})}),ge&&(0,$.jsx)(m,{path:`/loops/:id/edit`,element:(0,$.jsx)(NJ,{})}),(0,$.jsx)(m,{path:`/plugins`,element:(0,$.jsx)(OJ,{})}),t.length===0?(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(rK,{onAddProject:()=>b(!0)})}):te?(0,$.jsxs)(m,{element:(0,$.jsx)(nK,{projectName:te.name,children:(0,$.jsx)(eK,{project:te})},te.id),children:[(0,$.jsx)(m,{path:`/`,element:(0,$.jsx)(YH,{})}),(0,$.jsx)(m,{path:`/jobs`,element:(0,$.jsx)(SJ,{})}),(0,$.jsx)(m,{path:`/jobs/:id`,element:(0,$.jsx)(bJ,{})}),ve&&(0,$.jsx)(m,{path:`/review/:prDeliveryId`,element:(0,$.jsx)(xJ,{})}),(0,$.jsx)(m,{path:`/analytics`,element:(0,$.jsx)(CJ,{})}),(0,$.jsx)(m,{path:`/activity`,element:(0,$.jsx)(wJ,{})}),(0,$.jsx)(m,{path:`/agents`,element:(0,$.jsx)(TJ,{})}),(0,$.jsx)(m,{path:`/code`,element:se?(0,$.jsx)(EJ,{}):(0,$.jsx)(f,{to:`/`,replace:!0})}),(0,$.jsx)(m,{path:`/integrations`,element:(0,$.jsx)(DJ,{})}),(0,$.jsx)(m,{path:`/settings`,element:(0,$.jsx)(vU,{})}),(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(f,{to:`/`,replace:!0})})]}):(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(rK,{onAddProject:()=>b(!0)})})]})})}),Ce&&n&&te&&(0,$.jsx)(WN,{projectId:n,provider:te.provider,providers:rt(te),state:oe,viewportHeight:ue,statusBarHeight:ce}),_!==`agent`&&(0,$.jsx)(uJ,{connectionStatus:ae,rightSlot:fe})]}),_===`agent`?!ie&&(0,$.jsx)(iN,{}):te&&!ie&&(0,$.jsx)(FK,{}),(0,$.jsx)(KK,{open:y,onClose:()=>b(!1),onOpenBuilder:()=>d.builderMode.enter()}),(0,$.jsx)(uG,{open:x,onClose:()=>S(!1),onOpenOnboarding:()=>{S(!1),R(!0)}}),(0,$.jsx)(Hn,{open:C,onOpenChange:w,children:(0,$.jsx)(Bn,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsx)(kJ,{})})})})}),(0,$.jsx)(Hn,{open:T,onOpenChange:e=>{E(e),e||O(null)},children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,$.jsx)(FJ,{surface:`loops`,onClose:()=>{E(!1),O(null)}}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:D?(0,$.jsx)(`div`,{className:`h-full`,children:(0,$.jsx)(NJ,{loopId:D,onExit:()=>O(null)})}):(0,$.jsx)(MJ,{onOpenBuilder:O})})})]})}),ve&&(0,$.jsx)(Hn,{open:j!==null,onOpenChange:e=>{e||M(null)},children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`review-packet-modal`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.review`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.reviewDescription`)}),(0,$.jsx)(FJ,{surface:`review`,onClose:()=>M(null)}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:j&&(0,$.jsx)(xJ,{prDeliveryId:j,onClose:()=>M(null)})})})]})}),(0,$.jsx)(Hn,{open:k,onOpenChange:A,children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,$.jsx)(FJ,{surface:`plugins`,onClose:()=>A(!1)}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsx)(OJ,{})})})]})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(jJ,{open:N,onClose:I})}),(0,$.jsx)(Zq,{onOpenSettings:()=>S(!0),onOpenAnalytics:()=>w(!0),onOpenDocs:()=>F(!0)}),(0,$.jsx)(xG,{open:z,onOpenChange:B}),(0,$.jsx)(xK,{open:L,onClose:()=>R(!1)})]})}function VJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(xa,{activeProjectId:t,children:e})}function HJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(fH,{activeProjectId:t,children:e})}function UJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(yH,{activeProjectId:t,children:e})}function WJ(){return(0,$.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function GJ(){let{theme:e}=oa(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,xb.createPortal)((0,$.jsx)(it,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,$.jsx)(WJ,{})},style:{"--accent":t,"--toast-success-border":`color-mix(in srgb, ${n} 38%, transparent)`,"--toast-error-border":`color-mix(in srgb, ${r} 38%, transparent)`,"--toast-warning-border":`color-mix(in srgb, ${i} 38%, transparent)`,"--toast-info-border":`color-mix(in srgb, ${a} 38%, transparent)`},toastOptions:{unstyled:!0,classNames:{toast:`glass-card border border-border/30 text-foreground text-xs p-3 rounded-lg flex items-start gap-2 w-[356px] max-w-[356px] overflow-hidden shadow-lg`,content:`flex-1 min-w-0 flex flex-col gap-0.5`,icon:`shrink-0 mt-[2px] flex items-center justify-center`,title:`font-medium text-sm`,description:`text-muted-foreground mt-0.5`,actionButton:`text-[11px] px-2.5 py-1 rounded-md bg-accent-primary text-white hover:bg-accent-primary/90 whitespace-nowrap shrink-0 self-start`,cancelButton:`text-[11px] px-2.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/50 whitespace-nowrap shrink-0 self-start`,closeButton:`text-muted-foreground hover:text-foreground rounded-md p-0.5`,success:`border-l-4 border-l-[var(--toast-success-border)]`,error:`border-l-4 border-l-[var(--toast-error-border)]`,warning:`border-l-4 border-l-[var(--toast-warning-border)]`,info:`border-l-4 border-l-[var(--toast-info-border)]`,loading:``}}}),document.body)}function KJ(){return sW(),null}function qJ(){let e=$r();return sJ(),(0,$.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,$.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,$.jsx)(We,{url:ae,children:(0,$.jsx)(aa,{children:(0,$.jsxs)(EU,{children:[(0,$.jsx)($G,{}),(0,$.jsx)(ot,{isolated:e,children:(0,$.jsxs)(Pj,{initialMode:e?`agent`:void 0,persist:!e,children:[!e&&(0,$.jsx)(KJ,{}),(0,$.jsx)(EG,{}),(0,$.jsx)($R,{children:(0,$.jsx)(tJ,{children:(0,$.jsx)(te,{children:(0,$.jsx)($M,{children:(0,$.jsx)(VJ,{children:(0,$.jsx)(HJ,{children:(0,$.jsx)(UJ,{children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Vx,{children:(0,$.jsx)(oi,{secondary:e,children:(0,$.jsx)(sM,{children:(0,$.jsx)(rS,{children:(0,$.jsx)(W,{children:(0,$.jsxs)(_e,{children:[(0,$.jsx)(dM,{}),(0,$.jsx)(vc,{}),e?(0,$.jsx)(GN,{}):(0,$.jsx)(BJ,{}),(0,$.jsx)(fJ,{}),(0,$.jsx)(GJ,{})]})})})})})})})})})})})})})})]})})]})})})})})}async function JJ(){await Ge(),Je(),await Be(),(0,Cr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(_,{children:(0,$.jsx)(qJ,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}JJ();export{Cy as $,HP as A,Fo as At,TO as B,Ka as Bt,nL as C,fs as Ct,FI as D,ts as Dt,lL as E,ns as Et,Qk as F,So as Ft,ax as G,_D as H,si as Ht,pk as I,xo as It,_b as J,ox as K,uk as L,yo as Lt,NP as M,jo as Mt,_P as N,Do as Nt,NF as O,Qo as Ot,lM as P,Eo as Pt,hy as Q,EO as R,_o as Rt,pL as S,hs as St,xL as T,as as Tt,gD as U,DO as V,ca as Vt,Ux as W,wy as X,pb as Y,my as Z,aV as _,Os as _t,lU as a,sc as at,fz as b,vs as bt,rU as c,nc as ct,ZV as d,Ys as dt,gc as et,lH as f,Js as ft,kV as g,ks as gt,TV as h,As as ht,gU as i,uc as it,MP as j,Mo as jt,RF as k,Ho as kt,jH as l,tc as lt,MV as m,Vs as mt,_U as n,pc as nt,mU as o,ac as ot,cH as p,Ws as pt,bx as q,uU as r,dc as rt,oU as s,ic as st,lJ as t,mc as tt,mH as u,Zs as ut,Wz as v,Ds as vt,TL as w,os as wt,kL as x,gs as xt,pz as y,ws as yt,OO as z,po as zt};