@i14ks/ccv 0.16.1 → 0.16.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.
- package/package.json +1 -1
- package/web/assets/{codemirror-XwUmM20V.js → codemirror-CMssNlj1.js} +1 -1
- package/web/assets/{index-B3ZG7Mgh.js → index-4OYhLb6v.js} +1 -1
- package/web/assets/{index-Cu0rli8K.js → index-B20zmSkd.js} +1 -1
- package/web/assets/{index-BAMLmkAm.js → index-B8wBlTJK.js} +1 -1
- package/web/assets/{index-_rsPujXt.js → index-BDlE7XrJ.js} +4 -4
- package/web/assets/{index-CWJg4zA3.js → index-BbaEOHHE.js} +1 -1
- package/web/assets/{index-CdFloc-n.js → index-BpOx8-W2.js} +1 -1
- package/web/assets/{index-BiGxRIQL.js → index-CMpPRV85.js} +1 -1
- package/web/assets/{index-Bjmeb0mL.js → index-CMsLxeb-.js} +1 -1
- package/web/assets/{index-C3lLfrzk.js → index-CrUrevEN.js} +1 -1
- package/web/assets/{index-BBdH0WyS.js → index-DMeJ3xy0.js} +1 -1
- package/web/assets/{index-PcpAtAyR.js → index-DPVHF0JV.js} +1 -1
- package/web/assets/{index-Ceqv0JQi.js → index-DbZeX0xl.js} +1 -1
- package/web/assets/{index-B3KPQ0Jq.js → index-DhS8IelO.js} +1 -1
- package/web/assets/{index-CXp-N-a3.js → index-DyY1FCgf.js} +1 -1
- package/web/assets/{index-B3X6gKS4.js → index-HnPp_JMB.js} +1 -1
- package/web/assets/{index-EhM5ESQH.js → index-PkTbpJ8b.js} +1 -1
- package/web/assets/{index-byQstcIo.js → index-hzfPIc5t.js} +1 -1
- package/web/assets/{index-DaN46jfw.js → index-k2hhaMZJ.js} +1 -1
- package/web/assets/{index-B3mW0ScK.js → index-kRQFCBLi.js} +1 -1
- package/web/assets/{index-BCeVhzZf.js → index-umqVrxlG.js} +1 -1
- package/web/index.html +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DyY1FCgf.js","./index-BpOx8-W2.js","./index-hzfPIc5t.js","./index-BHot-lnj.js","./index-891wE-Rj.js","./index-DPVHF0JV.js","./index-CMpPRV85.js","./index-DMeJ3xy0.js","./index-B20zmSkd.js","./index-kRQFCBLi.js","./index-DbZeX0xl.js","./index-BbaEOHHE.js","./index-PkTbpJ8b.js","./index-k2hhaMZJ.js","./index-B8wBlTJK.js","./index-CMsLxeb-.js","./index-HnPp_JMB.js","./index-CrUrevEN.js","./index-umqVrxlG.js","./index-4OYhLb6v.js","./index-DhS8IelO.js","./codemirror-CMssNlj1.js","./xterm-D6Mng-DB.js","./_commonjsHelpers-CqkleIqs.js","./addon-fit-CevVMrUA.js","./addon-web-links-CnB65OV_.js","./xterm-DYP7pi_n.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var p0=Object.defineProperty;var vb=s=>{throw TypeError(s)};var m0=(s,l,r)=>l in s?p0(s,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[l]=r;var Dt=(s,l,r)=>m0(s,typeof l!="symbol"?l+"":l,r),Eh=(s,l,r)=>l.has(s)||vb("Cannot "+r);var Ye=(s,l,r)=>(Eh(s,l,"read from private field"),r?r.call(s):l.get(s)),fn=(s,l,r)=>l.has(s)?vb("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(s):l.set(s,r),vt=(s,l,r,c)=>(Eh(s,l,"write to private field"),c?c.call(s,r):l.set(s,r),r),Mn=(s,l,r)=>(Eh(s,l,"access private method"),r);(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))c(o);new MutationObserver(o=>{for(const d of o)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function r(o){const d={};return o.integrity&&(d.integrity=o.integrity),o.referrerPolicy&&(d.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?d.credentials="include":o.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function c(o){if(o.ep)return;o.ep=!0;const d=r(o);fetch(o.href,d)}})();var Ch={exports:{}},No={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -114,8 +114,8 @@ ${s}</tr>
|
|
|
114
114
|
Please report this to https://github.com/markedjs/marked.`,s){let c="<p>An error occurred:</p><pre>"+Js(r.message+"",!0)+"</pre>";return l?Promise.resolve(c):c}if(l)return Promise.reject(r);throw r}}},hr=new $v;function jt(s,l){return hr.parse(s,l)}jt.options=jt.setOptions=function(s){return hr.setOptions(s),jt.defaults=hr.defaults,my(jt.defaults),jt};jt.getDefaults=xp;jt.defaults=pr;jt.use=function(...s){return hr.use(...s),jt.defaults=hr.defaults,my(jt.defaults),jt};jt.walkTokens=function(s,l){return hr.walkTokens(s,l)};jt.parseInline=hr.parseInline;jt.Parser=Es;jt.parser=Es.parse;jt.Renderer=Uf;jt.TextRenderer=Np;jt.Lexer=Ts;jt.lexer=Ts.lex;jt.Tokenizer=zf;jt.Hooks=zo;jt.parse=jt;jt.options;jt.setOptions;jt.use;jt.walkTokens;jt.parseInline;Es.parse;Ts.lex;/*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */function Xb(s,l){(l==null||l>s.length)&&(l=s.length);for(var r=0,c=Array(l);r<l;r++)c[r]=s[r];return c}function Vv(s){if(Array.isArray(s))return s}function Qv(s,l){var r=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(r!=null){var c,o,d,h,m=[],g=!0,b=!1;try{if(d=(r=r.call(s)).next,l!==0)for(;!(g=(c=d.call(r)).done)&&(m.push(c.value),m.length!==l);g=!0);}catch(_){b=!0,o=_}finally{try{if(!g&&r.return!=null&&(h=r.return(),Object(h)!==h))return}finally{if(b)throw o}}return m}}function Kv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
115
115
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zv(s,l){return Vv(s)||Qv(s,l)||Fv(s,l)||Kv()}function Fv(s,l){if(s){if(typeof s=="string")return Xb(s,l);var r={}.toString.call(s).slice(8,-1);return r==="Object"&&s.constructor&&(r=s.constructor.name),r==="Map"||r==="Set"?Array.from(s):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xb(s,l):void 0}}const ky=Object.entries,$b=Object.setPrototypeOf,Jv=Object.isFrozen,Wv=Object.getPrototypeOf,Pv=Object.getOwnPropertyDescriptor;let nl=Object.freeze,ll=Object.seal,ic=Object.create,Ny=typeof Reflect<"u"&&Reflect,cp=Ny.apply,op=Ny.construct;nl||(nl=function(l){return l});ll||(ll=function(l){return l});cp||(cp=function(l,r){for(var c=arguments.length,o=new Array(c>2?c-2:0),d=2;d<c;d++)o[d-2]=arguments[d];return l.apply(r,o)});op||(op=function(l){for(var r=arguments.length,c=new Array(r>1?r-1:0),o=1;o<r;o++)c[o-1]=arguments[o];return new l(...c)});const tc=Rn(Array.prototype.forEach),e1=Rn(Array.prototype.lastIndexOf),Vb=Rn(Array.prototype.pop),nc=Rn(Array.prototype.push),t1=Rn(Array.prototype.splice),Ci=Array.isArray,Uo=Rn(String.prototype.toLowerCase),Bh=Rn(String.prototype.toString),Qb=Rn(String.prototype.match),Co=Rn(String.prototype.replace),Kb=Rn(String.prototype.indexOf),n1=Rn(String.prototype.trim),l1=Rn(Number.prototype.toString),s1=Rn(Boolean.prototype.toString),Zb=typeof BigInt>"u"?null:Rn(BigInt.prototype.toString),Fb=typeof Symbol>"u"?null:Rn(Symbol.prototype.toString),Kn=Rn(Object.prototype.hasOwnProperty),Ao=Rn(Object.prototype.toString),Qn=Rn(RegExp.prototype.test),Pi=a1(TypeError);function Rn(s){return function(l){l instanceof RegExp&&(l.lastIndex=0);for(var r=arguments.length,c=new Array(r>1?r-1:0),o=1;o<r;o++)c[o-1]=arguments[o];return cp(s,l,c)}}function a1(s){return function(){for(var l=arguments.length,r=new Array(l),c=0;c<l;c++)r[c]=arguments[c];return op(s,r)}}function pt(s,l){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Uo;if($b&&$b(s,null),!Ci(l))return s;let c=l.length;for(;c--;){let o=l[c];if(typeof o=="string"){const d=r(o);d!==o&&(Jv(l)||(l[c]=d),o=d)}s[o]=!0}return s}function i1(s){for(let l=0;l<s.length;l++)Kn(s,l)||(s[l]=null);return s}function jl(s){const l=ic(null);for(const c of ky(s)){var r=Zv(c,2);const o=r[0],d=r[1];Kn(s,o)&&(Ci(d)?l[o]=i1(d):d&&typeof d=="object"&&d.constructor===Object?l[o]=jl(d):l[o]=d)}return l}function r1(s){switch(typeof s){case"string":return s;case"number":return l1(s);case"boolean":return s1(s);case"bigint":return Zb?Zb(s):"0";case"symbol":return Fb?Fb(s):"Symbol()";case"undefined":return Ao(s);case"function":case"object":{if(s===null)return Ao(s);const l=s,r=Ws(l,"toString");if(typeof r=="function"){const c=r(l);return typeof c=="string"?c:Ao(c)}return Ao(s)}default:return Ao(s)}}function Ws(s,l){for(;s!==null;){const c=Pv(s,l);if(c){if(c.get)return Rn(c.get);if(typeof c.value=="function")return Rn(c.value)}s=Wv(s)}function r(){return null}return r}function c1(s){try{return Qn(s,""),!0}catch{return!1}}const Jb=nl(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ih=nl(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qh=nl(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),o1=nl(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Gh=nl(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),u1=nl(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Wb=nl(["#text"]),Pb=nl(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Yh=nl(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ex=nl(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ff=nl(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),f1=ll(/{{[\w\W]*|^[\w\W]*}}/g),d1=ll(/<%[\w\W]*|^[\w\W]*%>/g),h1=ll(/\${[\w\W]*/g),p1=ll(/^data-[\-\w.\u00B7-\uFFFF]+$/),m1=ll(/^aria-[\-\w]+$/),tx=ll(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),g1=ll(/^(?:\w+script|data):/i),b1=ll(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),x1=ll(/^html$/i),y1=ll(/^[a-z][.\w]*(-[.\w]+)+$/i),nx=ll(/<[/\w!]/g),lx=ll(/<[/\w]/g),_1=ll(/<\/no(script|embed|frames)/i),v1=ll(/\/>/i),Kl={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},j1=function(){return typeof window>"u"?null:window},S1=function(l,r){if(typeof l!="object"||typeof l.createPolicy!="function")return null;let c=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(c=r.getAttribute(o));const d="dompurify"+(c?"#"+c:"");try{return l.createPolicy(d,{createHTML(h){return h},createScriptURL(h){return h}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},sx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wi=function(l,r,c,o){return Kn(l,r)&&Ci(l[r])?pt(o.base?jl(o.base):{},l[r],o.transform):c};function Ty(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:j1();const l=pe=>Ty(pe);if(l.version="3.4.12",l.removed=[],!s||!s.document||s.document.nodeType!==Kl.document||!s.Element)return l.isSupported=!1,l;let r=s.document;const c=r,o=c.currentScript;s.DocumentFragment;const d=s.HTMLTemplateElement,h=s.Node,m=s.Element,g=s.NodeFilter,b=s.NamedNodeMap;b===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const _=s.DOMParser,S=s.trustedTypes,v=m.prototype,E=Ws(v,"cloneNode"),T=Ws(v,"remove"),C=Ws(v,"nextSibling"),L=Ws(v,"childNodes"),X=Ws(v,"parentNode"),J=Ws(v,"shadowRoot"),G=Ws(v,"attributes"),O=h&&h.prototype?Ws(h.prototype,"nodeType"):null,Z=h&&h.prototype?Ws(h.prototype,"nodeName"):null;if(typeof d=="function"){const pe=r.createElement("template");pe.content&&pe.content.ownerDocument&&(r=pe.content.ownerDocument)}let M,D="",H,ne=!1,he=0;const W=function(){if(he>0)throw Pi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ue=function(k){W(),he++;try{return M.createHTML(k)}finally{he--}},je=function(k){W(),he++;try{return M.createScriptURL(k)}finally{he--}},Me=function(){return ne||(H=S1(S,o),ne=!0),H},Ce=r,A=Ce.implementation,ce=Ce.createNodeIterator,z=Ce.createDocumentFragment,be=Ce.getElementsByTagName,ye=c.importNode;let N=sx();l.isSupported=typeof ky=="function"&&typeof X=="function"&&A&&A.createHTMLDocument!==void 0;const V=f1,re=d1,me=h1,Ne=p1,ve=m1,De=g1,yt=b1,Xe=y1;let $e=tx,Ve=null;const It=pt({},[...Jb,...Ih,...qh,...Gh,...Wb]);let rt=null;const dn=pt({},[...Pb,...Yh,...ex,...ff]);let ft=Object.seal(ic(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),hn=null,Sn=null;const xn=Object.seal(ic(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let en=!0,tt=!0,et=!1,tn=!0,Xt=!1,nt=!0,St=!1,$t=!1,cn=null,wt=null,yn=!1,qt=!1,pn=!1,Dn=!1,Gt=!0,ct=!1;const Et="user-content-";let Pe=!0,wl=!1,le={},ge=null;const He=pt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let B=null;const P=pt({},["audio","video","img","source","image","track"]);let _e=null;const Be=pt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ot="http://www.w3.org/1998/Math/MathML",fl="http://www.w3.org/2000/svg",On="http://www.w3.org/1999/xhtml";let dl=On,sl=!1,Bl=null;const ds=pt({},[Ot,fl,On],Bh),hl=nl(["mi","mo","mn","ms","mtext"]);let al=pt({},hl);const pl=nl(["annotation-xml"]);let Yt=pt({},pl);const Vt=pt({},["title","style","font","a","script"]);let kl=null;const kt=["application/xhtml+xml","text/html"],Qt="text/html";let Oe=null,Ct=null;const qn=r.createElement("form"),nn=function(k){return k instanceof RegExp||k instanceof Function},Ln=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ct&&Ct===k)return;(!k||typeof k!="object")&&(k={}),k=jl(k),kl=kt.indexOf(k.PARSER_MEDIA_TYPE)===-1?Qt:k.PARSER_MEDIA_TYPE,Oe=kl==="application/xhtml+xml"?Bh:Uo,Ve=wi(k,"ALLOWED_TAGS",It,{transform:Oe}),rt=wi(k,"ALLOWED_ATTR",dn,{transform:Oe}),Bl=wi(k,"ALLOWED_NAMESPACES",ds,{transform:Bh}),_e=wi(k,"ADD_URI_SAFE_ATTR",Be,{transform:Oe,base:Be}),B=wi(k,"ADD_DATA_URI_TAGS",P,{transform:Oe,base:P}),ge=wi(k,"FORBID_CONTENTS",He,{transform:Oe}),hn=wi(k,"FORBID_TAGS",jl({}),{transform:Oe}),Sn=wi(k,"FORBID_ATTR",jl({}),{transform:Oe}),le=Kn(k,"USE_PROFILES")?k.USE_PROFILES&&typeof k.USE_PROFILES=="object"?jl(k.USE_PROFILES):k.USE_PROFILES:!1,en=k.ALLOW_ARIA_ATTR!==!1,tt=k.ALLOW_DATA_ATTR!==!1,et=k.ALLOW_UNKNOWN_PROTOCOLS||!1,tn=k.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Xt=k.SAFE_FOR_TEMPLATES||!1,nt=k.SAFE_FOR_XML!==!1,St=k.WHOLE_DOCUMENT||!1,qt=k.RETURN_DOM||!1,pn=k.RETURN_DOM_FRAGMENT||!1,Dn=k.RETURN_TRUSTED_TYPE||!1,yn=k.FORCE_BODY||!1,Gt=k.SANITIZE_DOM!==!1,ct=k.SANITIZE_NAMED_PROPS||!1,Pe=k.KEEP_CONTENT!==!1,wl=k.IN_PLACE||!1,$e=c1(k.ALLOWED_URI_REGEXP)?k.ALLOWED_URI_REGEXP:tx,dl=typeof k.NAMESPACE=="string"?k.NAMESPACE:On,al=Kn(k,"MATHML_TEXT_INTEGRATION_POINTS")&&k.MATHML_TEXT_INTEGRATION_POINTS&&typeof k.MATHML_TEXT_INTEGRATION_POINTS=="object"?jl(k.MATHML_TEXT_INTEGRATION_POINTS):pt({},hl),Yt=Kn(k,"HTML_INTEGRATION_POINTS")&&k.HTML_INTEGRATION_POINTS&&typeof k.HTML_INTEGRATION_POINTS=="object"?jl(k.HTML_INTEGRATION_POINTS):pt({},pl);const Y=Kn(k,"CUSTOM_ELEMENT_HANDLING")&&k.CUSTOM_ELEMENT_HANDLING&&typeof k.CUSTOM_ELEMENT_HANDLING=="object"?jl(k.CUSTOM_ELEMENT_HANDLING):ic(null);if(ft=ic(null),Kn(Y,"tagNameCheck")&&nn(Y.tagNameCheck)&&(ft.tagNameCheck=Y.tagNameCheck),Kn(Y,"attributeNameCheck")&&nn(Y.attributeNameCheck)&&(ft.attributeNameCheck=Y.attributeNameCheck),Kn(Y,"allowCustomizedBuiltInElements")&&typeof Y.allowCustomizedBuiltInElements=="boolean"&&(ft.allowCustomizedBuiltInElements=Y.allowCustomizedBuiltInElements),ll(ft),Xt&&(tt=!1),pn&&(qt=!0),le&&(Ve=pt({},Wb),rt=ic(null),le.html===!0&&(pt(Ve,Jb),pt(rt,Pb)),le.svg===!0&&(pt(Ve,Ih),pt(rt,Yh),pt(rt,ff)),le.svgFilters===!0&&(pt(Ve,qh),pt(rt,Yh),pt(rt,ff)),le.mathMl===!0&&(pt(Ve,Gh),pt(rt,ex),pt(rt,ff))),xn.tagCheck=null,xn.attributeCheck=null,Kn(k,"ADD_TAGS")&&(typeof k.ADD_TAGS=="function"?xn.tagCheck=k.ADD_TAGS:Ci(k.ADD_TAGS)&&(Ve===It&&(Ve=jl(Ve)),pt(Ve,k.ADD_TAGS,Oe))),Kn(k,"ADD_ATTR")&&(typeof k.ADD_ATTR=="function"?xn.attributeCheck=k.ADD_ATTR:Ci(k.ADD_ATTR)&&(rt===dn&&(rt=jl(rt)),pt(rt,k.ADD_ATTR,Oe))),Kn(k,"ADD_URI_SAFE_ATTR")&&Ci(k.ADD_URI_SAFE_ATTR)&&pt(_e,k.ADD_URI_SAFE_ATTR,Oe),Kn(k,"FORBID_CONTENTS")&&Ci(k.FORBID_CONTENTS)&&(ge===He&&(ge=jl(ge)),pt(ge,k.FORBID_CONTENTS,Oe)),Kn(k,"ADD_FORBID_CONTENTS")&&Ci(k.ADD_FORBID_CONTENTS)&&(ge===He&&(ge=jl(ge)),pt(ge,k.ADD_FORBID_CONTENTS,Oe)),Pe&&(Ve["#text"]=!0),St&&pt(Ve,["html","head","body"]),Ve.table&&(pt(Ve,["tbody"]),delete hn.tbody),k.TRUSTED_TYPES_POLICY){if(typeof k.TRUSTED_TYPES_POLICY.createHTML!="function")throw Pi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof k.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Pi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const fe=M;M=k.TRUSTED_TYPES_POLICY;try{D=ue("")}catch(we){throw M=fe,we}}else k.TRUSTED_TYPES_POLICY===null?(M=void 0,D=""):(M===void 0&&(M=Me()),M&&typeof D=="string"&&(D=ue("")));nl&&nl(k),Ct=k},il=pt({},[...Ih,...qh,...o1]),wn=pt({},[...Gh,...u1]),Il=function(k,Y,fe){return Y.namespaceURI===On?k==="svg":Y.namespaceURI===Ot?k==="svg"&&(fe==="annotation-xml"||al[fe]):!!il[k]},rl=function(k,Y,fe){return Y.namespaceURI===On?k==="math":Y.namespaceURI===fl?k==="math"&&Yt[fe]:!!wn[k]},ln=function(k,Y,fe){return Y.namespaceURI===fl&&!Yt[fe]||Y.namespaceURI===Ot&&!al[fe]?!1:!wn[k]&&(Vt[k]||!il[k])},Kt=function(k){let Y=X(k);(!Y||!Y.tagName)&&(Y={namespaceURI:dl,tagName:"template"});const fe=Uo(k.tagName),we=Uo(Y.tagName);return Bl[k.namespaceURI]?k.namespaceURI===fl?Il(fe,Y,we):k.namespaceURI===Ot?rl(fe,Y,we):k.namespaceURI===On?ln(fe,Y,we):!!(kl==="application/xhtml+xml"&&Bl[k.namespaceURI]):!1},on=function(k){nc(l.removed,{element:k});try{X(k).removeChild(k)}catch{if(T(k),!X(k))throw Pi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Fe=function(k){Gn(k);const Y=L(k);if(Y){const we=[];tc(Y,Ae=>{nc(we,Ae)}),tc(we,Ae=>{try{T(Ae)}catch{}})}const fe=G(k);if(fe)for(let we=fe.length-1;we>=0;--we){const Ae=fe[we],ze=Ae&&Ae.name;if(typeof ze=="string")try{k.removeAttribute(ze)}catch{}}},ml=function(k,Y){try{nc(l.removed,{attribute:Y.getAttributeNode(k),from:Y})}catch{nc(l.removed,{attribute:null,from:Y})}if(Y.removeAttribute(k),k==="is")if(qt||pn)try{on(Y)}catch{}else try{Y.setAttribute(k,"")}catch{}},Ms=function(k){const Y=G(k);if(Y)for(let fe=Y.length-1;fe>=0;--fe){const we=Y[fe],Ae=we&&we.name;if(!(typeof Ae!="string"||rt[Oe(Ae)]))try{k.removeAttribute(Ae)}catch{}}},Gn=function(k){const Y=[k];for(;Y.length>0;){const fe=Y.pop();(O?O(fe):fe.nodeType)===Kl.element&&Ms(fe);const Ae=L(fe);if(Ae)for(let ze=Ae.length-1;ze>=0;--ze)Y.push(Ae[ze])}},Zl=function(k){if(!nt)return;const Y=[k];for(;Y.length>0;){const fe=Y.pop(),we=O?O(fe):fe.nodeType;if(we===Kl.processingInstruction||we===Kl.comment&&Qn(lx,fe.data)){try{T(fe)}catch{}continue}if(we===Kl.element){const ze=fe,dt=Oe(Z?Z(fe):fe.nodeName);try{ze.hasAttribute&&ze.hasAttribute("patchsrc")&&ze.removeAttribute("patchsrc"),ze.hasAttribute&&ze.hasAttribute("for")&&dt!=="label"&&dt!=="output"&&ze.removeAttribute("for")}catch{}}const Ae=L(fe);if(Ae)for(let ze=Ae.length-1;ze>=0;--ze)Y.push(Ae[ze])}},hs=function(k){let Y=null,fe=null;if(yn)k="<remove></remove>"+k;else{const ze=Qb(k,/^[\r\n\t ]+/);fe=ze&&ze[0]}kl==="application/xhtml+xml"&&dl===On&&(k='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+k+"</body></html>");const we=M?ue(k):k;if(dl===On)try{Y=new _().parseFromString(we,kl)}catch{}if(!Y||!Y.documentElement){Y=A.createDocument(dl,"template",null);try{Y.documentElement.innerHTML=sl?D:we}catch{}}const Ae=Y.body||Y.documentElement;return k&&fe&&Ae.insertBefore(r.createTextNode(fe),Ae.childNodes[0]||null),dl===On?be.call(Y,St?"html":"body")[0]:St?Y.documentElement:Ae},ps=function(k){return ce.call(k.ownerDocument||k,k,g.SHOW_ELEMENT|g.SHOW_COMMENT|g.SHOW_TEXT|g.SHOW_PROCESSING_INSTRUCTION|g.SHOW_CDATA_SECTION,null)},mn=function(k){return k=Co(k,V," "),k=Co(k,re," "),k=Co(k,me," "),k},Fl=function(k){var Y;k.normalize();const fe=ce.call(k.ownerDocument||k,k,g.SHOW_TEXT|g.SHOW_COMMENT|g.SHOW_CDATA_SECTION|g.SHOW_PROCESSING_INSTRUCTION,null);let we=fe.nextNode();for(;we;)we.data=mn(we.data),we=fe.nextNode();const Ae=(Y=k.querySelectorAll)===null||Y===void 0?void 0:Y.call(k,"template");Ae&&tc(Ae,ze=>{zn(ze.content)&&Fl(ze.content)})},Zn=function(k){const Y=Z?Z(k):null;return typeof Y!="string"||Oe(Y)!=="form"?!1:typeof k.nodeName!="string"||typeof k.textContent!="string"||typeof k.removeChild!="function"||k.attributes!==G(k)||typeof k.removeAttribute!="function"||typeof k.setAttribute!="function"||typeof k.namespaceURI!="string"||typeof k.insertBefore!="function"||typeof k.hasChildNodes!="function"||k.nodeType!==O(k)||k.childNodes!==L(k)},zn=function(k){if(!O||typeof k!="object"||k===null)return!1;try{return O(k)===Kl.documentFragment}catch{return!1}},kn=function(k){if(!O||typeof k!="object"||k===null)return!1;try{return typeof O(k)=="number"}catch{return!1}};function Lt(pe,k,Y){pe.length!==0&&tc(pe,fe=>{fe.call(l,k,Y,Ct)})}const Rs=function(k,Y){return!!(nt&&k.hasChildNodes()&&!kn(k.firstElementChild)&&Qn(nx,k.textContent)&&Qn(nx,k.innerHTML)||nt&&k.namespaceURI===On&&Y==="style"&&kn(k.firstElementChild)||k.nodeType===Kl.processingInstruction||nt&&k.nodeType===Kl.comment&&Qn(lx,k.data))},Di=function(k,Y){if(!hn[Y]&&La(Y)&&(ft.tagNameCheck instanceof RegExp&&Qn(ft.tagNameCheck,Y)||ft.tagNameCheck instanceof Function&&ft.tagNameCheck(Y)))return!1;if(Pe&&!ge[Y]){const fe=X(k),we=L(k);if(we&&fe){const Ae=we.length;for(let ze=Ae-1;ze>=0;--ze){const dt=wl?we[ze]:E(we[ze],!0);fe.insertBefore(dt,C(k))}}}return on(k),!0},Ds=function(k,Y){if(Lt(N.beforeSanitizeElements,k,null),k!==Y&&X(k)===null)return!0;if(Zn(k))return on(k),!0;const fe=Oe(Z?Z(k):k.nodeName);if(Lt(N.uponSanitizeElement,k,{tagName:fe,allowedTags:Ve}),k!==Y&&X(k)===null)return!0;if(Rs(k,fe))return on(k),!0;if(hn[fe]||!(xn.tagCheck instanceof Function&&xn.tagCheck(fe))&&!Ve[fe]){const Ae=Di(k,fe);return Ae===!1&&Lt(N.afterSanitizeElements,k,null),Ae}if((O?O(k):k.nodeType)===Kl.element&&!Kt(k)||(fe==="noscript"||fe==="noembed"||fe==="noframes")&&Qn(_1,k.innerHTML))return on(k),!0;if(Xt&&k.nodeType===Kl.text){const Ae=mn(k.textContent);k.textContent!==Ae&&(nc(l.removed,{element:k.cloneNode()}),k.textContent=Ae)}return Lt(N.afterSanitizeElements,k,null),!1},Yn=function(k,Y,fe){if(Sn[Y]||nt&&Y==="patchsrc"||nt&&Y==="for"&&k!=="label"&&k!=="output"||Gt&&(Y==="id"||Y==="name")&&(fe in r||fe in qn))return!1;const we=rt[Y]||xn.attributeCheck instanceof Function&&xn.attributeCheck(Y,k);if(!(tt&&Qn(Ne,Y))){if(!(en&&Qn(ve,Y))){if(we){if(!_e[Y]){if(!Qn($e,Co(fe,yt,""))){if(!((Y==="src"||Y==="xlink:href"||Y==="href")&&k!=="script"&&Kb(fe,"data:")===0&&B[k])){if(!(et&&!Qn(De,Co(fe,yt,"")))){if(fe)return!1}}}}}else if(!(La(k)&&(ft.tagNameCheck instanceof RegExp&&Qn(ft.tagNameCheck,k)||ft.tagNameCheck instanceof Function&&ft.tagNameCheck(k))&&(ft.attributeNameCheck instanceof RegExp&&Qn(ft.attributeNameCheck,Y)||ft.attributeNameCheck instanceof Function&&ft.attributeNameCheck(Y,k))||Y==="is"&&ft.allowCustomizedBuiltInElements&&(ft.tagNameCheck instanceof RegExp&&Qn(ft.tagNameCheck,fe)||ft.tagNameCheck instanceof Function&&ft.tagNameCheck(fe))))return!1}}return!0},Nl=pt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),La=function(k){return!Nl[Uo(k)]&&Qn(Xe,k)},Nn=function(k,Y,fe,we){if(M&&typeof S=="object"&&typeof S.getAttributeType=="function"&&!fe)switch(S.getAttributeType(k,Y)){case"TrustedHTML":return ue(we);case"TrustedScriptURL":return je(we)}return we},sn=function(k,Y,fe,we){try{fe?k.setAttributeNS(fe,Y,we):k.setAttribute(Y,we),Zn(k)?on(k):Vb(l.removed)}catch{ml(Y,k)}},Jl=function(k){Lt(N.beforeSanitizeAttributes,k,null);const Y=k.attributes;if(!Y||Zn(k))return;const fe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:rt,forceKeepAttr:void 0};let we=Y.length;const Ae=Oe(k.nodeName);for(;we--;){const ze=Y[we],dt=ze.name,w=ze.namespaceURI,se=ze.value,ke=Oe(dt),Je=se;let ht=dt==="value"?Je:n1(Je);if(fe.attrName=ke,fe.attrValue=ht,fe.keepAttr=!0,fe.forceKeepAttr=void 0,Lt(N.uponSanitizeAttribute,k,fe),ht=fe.attrValue,ct&&(ke==="id"||ke==="name")&&Kb(ht,Et)!==0&&(ml(dt,k),ht=Et+ht),nt&&Qn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ht)){ml(dt,k);continue}if(ke==="attributename"&&Qb(ht,"href")){ml(dt,k);continue}if(!fe.forceKeepAttr){if(!fe.keepAttr){ml(dt,k);continue}if(!tn&&Qn(v1,ht)){ml(dt,k);continue}if(Xt&&(ht=mn(ht)),!Yn(Ae,ke,ht)){ml(dt,k);continue}ht=Nn(Ae,ke,w,ht),ht!==Je&&sn(k,dt,w,ht)}}Lt(N.afterSanitizeAttributes,k,null)},lt=function(k){let Y=null;const fe=ps(k);for(Lt(N.beforeSanitizeShadowDOM,k,null);Y=fe.nextNode();)if(Lt(N.uponSanitizeShadowNode,Y,null),Ds(Y,k),Jl(Y),zn(Y.content)&<(Y.content),(O?O(Y):Y.nodeType)===Kl.element){const Ae=J(Y);zn(Ae)&&(Xn(Ae),lt(Ae))}Lt(N.afterSanitizeShadowDOM,k,null)},Xn=function(k){const Y=[{node:k,shadow:null}];for(;Y.length>0;){const fe=Y.pop();if(fe.shadow){lt(fe.shadow);continue}const we=fe.node,ze=(O?O(we):we.nodeType)===Kl.element,dt=L(we);if(dt)for(let w=dt.length-1;w>=0;--w)Y.push({node:dt[w],shadow:null});if(ze){const w=Z?Z(we):null;if(typeof w=="string"&&Oe(w)==="template"){const se=we.content;zn(se)&&Y.push({node:se,shadow:null})}}if(ze){const w=J(we);zn(w)&&Y.push({node:null,shadow:w},{node:w,shadow:null})}}};return l.sanitize=function(pe){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Y=null,fe=null,we=null,Ae=null;if(sl=!pe,sl&&(pe="<!-->"),typeof pe!="string"&&!kn(pe)&&(pe=r1(pe),typeof pe!="string"))throw Pi("dirty is not a string, aborting");if(!l.isSupported)return pe;$t?(Ve=cn,rt=wt):Ln(k),(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&(Ve=jl(Ve)),N.uponSanitizeAttribute.length>0&&(rt=jl(rt)),l.removed=[];const ze=wl&&typeof pe!="string"&&kn(pe);if(ze){Zl(pe);const ke=Z?Z(pe):pe.nodeName;if(typeof ke=="string"){const Je=Oe(ke);if(!Ve[Je]||hn[Je])throw Fe(pe),Pi("root node is forbidden and cannot be sanitized in-place")}if(Zn(pe))throw Fe(pe),Pi("root node is clobbered and cannot be sanitized in-place");try{Xn(pe)}catch(Je){throw Fe(pe),Je}}else if(kn(pe))Y=hs("<!---->"),fe=Y.ownerDocument.importNode(pe,!0),fe.nodeType===Kl.element&&fe.nodeName==="BODY"||fe.nodeName==="HTML"?Y=fe:Y.appendChild(fe),Xn(fe);else{if(!qt&&!Xt&&!St&&pe.indexOf("<")===-1)return M&&Dn?ue(pe):pe;if(Y=hs(pe),!Y)return qt?null:Dn?D:""}Y&&yn&&on(Y.firstChild);const dt=ze?pe:Y,w=ps(dt);try{for(;we=w.nextNode();)Ds(we,dt),Jl(we),zn(we.content)&<(we.content)}catch(ke){throw ze&&(Fe(pe),tc(l.removed,Je=>{Je.element&&Gn(Je.element)})),ke}if(ze)return tc(l.removed,ke=>{ke.element&&Gn(ke.element)}),Xt&&Fl(pe),pe;if(qt){if(Xt&&Fl(Y),pn)for(Ae=z.call(Y.ownerDocument);Y.firstChild;)Ae.appendChild(Y.firstChild);else Ae=Y;return(rt.shadowroot||rt.shadowrootmode)&&(Ae=ye.call(c,Ae,!0)),Ae}let se=St?Y.outerHTML:Y.innerHTML;return St&&Ve["!doctype"]&&Y.ownerDocument&&Y.ownerDocument.doctype&&Y.ownerDocument.doctype.name&&Qn(x1,Y.ownerDocument.doctype.name)&&(se="<!DOCTYPE "+Y.ownerDocument.doctype.name+`>
|
|
116
116
|
`+se),Xt&&(se=mn(se)),M&&Dn?ue(se):se},l.setConfig=function(){let pe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ln(pe),$t=!0,cn=Ve,wt=rt},l.clearConfig=function(){Ct=null,$t=!1,cn=null,wt=null,M=H,D=""},l.isValidAttribute=function(pe,k,Y){Ct||Ln({});const fe=Oe(pe),we=Oe(k);return Yn(fe,we,Y)},l.addHook=function(pe,k){typeof k=="function"&&Kn(N,pe)&&nc(N[pe],k)},l.removeHook=function(pe,k){if(Kn(N,pe)){if(k!==void 0){const Y=e1(N[pe],k);return Y===-1?void 0:t1(N[pe],Y,1)[0]}return Vb(N[pe])}},l.removeHooks=function(pe){Kn(N,pe)&&(N[pe]=[])},l.removeAllHooks=function(){N=sx()},l}var w1=Ty();const k1=1024;let N1=0;class fs{constructor(l,r){this.from=l,this.to=r}}class Pt{constructor(l={}){this.id=N1++,this.perNode=!!l.perNode,this.deserialize=l.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=l.combine||null}add(l){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof l!="function"&&(l=As.match(l)),r=>{let c=l(r);return c===void 0?null:[this,c]}}}Pt.closedBy=new Pt({deserialize:s=>s.split(" ")});Pt.openedBy=new Pt({deserialize:s=>s.split(" ")});Pt.group=new Pt({deserialize:s=>s.split(" ")});Pt.isolate=new Pt({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});Pt.contextHash=new Pt({perNode:!0});Pt.lookAhead=new Pt({perNode:!0});Pt.mounted=new Pt({perNode:!0});class uc{constructor(l,r,c,o=!1){this.tree=l,this.overlay=r,this.parser=c,this.bracketed=o}static get(l){return l&&l.props&&l.props[Pt.mounted.id]}}const T1=Object.create(null);class As{constructor(l,r,c,o=0){this.name=l,this.props=r,this.id=c,this.flags=o}static define(l){let r=l.props&&l.props.length?Object.create(null):T1,c=(l.top?1:0)|(l.skipped?2:0)|(l.error?4:0)|(l.name==null?8:0),o=new As(l.name||"",r,l.id,c);if(l.props){for(let d of l.props)if(Array.isArray(d)||(d=d(o)),d){if(d[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");r[d[0].id]=d[1]}}return o}prop(l){return this.props[l.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(l){if(typeof l=="string"){if(this.name==l)return!0;let r=this.prop(Pt.group);return r?r.indexOf(l)>-1:!1}return this.id==l}static match(l){let r=Object.create(null);for(let c in l)for(let o of c.split(" "))r[o]=l[c];return c=>{for(let o=c.prop(Pt.group),d=-1;d<(o?o.length:0);d++){let h=r[d<0?c.name:o[d]];if(h)return h}}}}As.none=new As("",Object.create(null),0,8);class Ey{constructor(l){this.types=l;for(let r=0;r<l.length;r++)if(l[r].id!=r)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...l){let r=[];for(let c of this.types){let o=null;for(let d of l){let h=d(c);if(h){o||(o=Object.assign({},c.props));let m=h[1],g=h[0];g.combine&&g.id in o&&(m=g.combine(o[g.id],m)),o[g.id]=m}}r.push(o?new As(c.name,o,c.id,c.flags):c)}return new Ey(r)}}const df=new WeakMap,ax=new WeakMap;var Jt;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(Jt||(Jt={}));class Hl{constructor(l,r,c,o,d){if(this.type=l,this.children=r,this.positions=c,this.length=o,this.props=null,d&&d.length){this.props=Object.create(null);for(let[h,m]of d)this.props[typeof h=="number"?h:h.id]=m}}toString(){let l=uc.get(this);if(l&&!l.overlay)return l.tree.toString();let r="";for(let c of this.children){let o=c.toString();o&&(r&&(r+=","),r+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":""):r}cursor(l=0){return new Hf(this.topNode,l)}cursorAt(l,r=0,c=0){let o=df.get(this)||this.topNode,d=new Hf(o);return d.moveTo(l,r),df.set(this,d._tree),d}get topNode(){return new ul(this,0,0,null)}resolve(l,r=0){let c=Io(df.get(this)||this.topNode,l,r,!1);return df.set(this,c),c}resolveInner(l,r=0){let c=Io(ax.get(this)||this.topNode,l,r,!0);return ax.set(this,c),c}resolveStack(l,r=0){return A1(this,l,r)}iterate(l){let{enter:r,leave:c,from:o=0,to:d=this.length}=l,h=l.mode||0,m=(h&Jt.IncludeAnonymous)>0;for(let g=this.cursor(h|Jt.IncludeAnonymous);;){let b=!1;if(g.from<=d&&g.to>=o&&(!m&&g.type.isAnonymous||r(g)!==!1)){if(g.firstChild())continue;b=!0}for(;b&&c&&(m||!g.type.isAnonymous)&&c(g),!g.nextSibling();){if(!g.parent())return;b=!0}}}prop(l){return l.perNode?this.props?this.props[l.id]:void 0:this.type.prop(l)}get propValues(){let l=[];if(this.props)for(let r in this.props)l.push([+r,this.props[r]]);return l}balance(l={}){return this.children.length<=8?this:Cp(As.none,this.children,this.positions,0,this.children.length,0,this.length,(r,c,o)=>new Hl(this.type,r,c,o,this.propValues),l.makeTree||((r,c,o)=>new Hl(As.none,r,c,o)))}static build(l){return M1(l)}}Hl.empty=new Hl(As.none,[],[],0);class Tp{constructor(l,r){this.buffer=l,this.index=r}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Tp(this.buffer,this.index)}}class Ri{constructor(l,r,c){this.buffer=l,this.length=r,this.set=c}get type(){return As.none}toString(){let l=[];for(let r=0;r<this.buffer.length;)l.push(this.childString(r)),r=this.buffer[r+3];return l.join(",")}childString(l){let r=this.buffer[l],c=this.buffer[l+3],o=this.set.types[r],d=o.name;if(/\W/.test(d)&&!o.isError&&(d=JSON.stringify(d)),l+=4,c==l)return d;let h=[];for(;l<c;)h.push(this.childString(l)),l=this.buffer[l+3];return d+"("+h.join(",")+")"}findChild(l,r,c,o,d){let{buffer:h}=this,m=-1;for(let g=l;g!=r&&!(Cy(d,o,h[g+1],h[g+2])&&(m=g,c>0));g=h[g+3]);return m}slice(l,r,c){let o=this.buffer,d=new Uint16Array(r-l),h=0;for(let m=l,g=0;m<r;){d[g++]=o[m++],d[g++]=o[m++]-c;let b=d[g++]=o[m++]-c;d[g++]=o[m++]-l,h=Math.max(h,b)}return new Ri(d,h,this.set)}}function Cy(s,l,r,c){switch(s){case-2:return r<l;case-1:return c>=l&&r<l;case 0:return r<l&&c>l;case 1:return r<=l&&c>l;case 2:return c>l;case 4:return!0}}function Io(s,l,r,c){for(var o;s.from==s.to||(r<1?s.from>=l:s.from>l)||(r>-1?s.to<=l:s.to<l);){let h=!c&&s instanceof ul&&s.index<0?null:s.parent;if(!h)return s;s=h}let d=c?0:Jt.IgnoreOverlays;if(c)for(let h=s,m=h.parent;m;h=m,m=h.parent)h instanceof ul&&h.index<0&&((o=m.enter(l,r,d))===null||o===void 0?void 0:o.from)!=h.from&&(s=m);for(;;){let h=s.enter(l,r,d);if(!h)return s;s=h}}class Ay{cursor(l=0){return new Hf(this,l)}getChild(l,r=null,c=null){let o=ix(this,l,r,c);return o.length?o[0]:null}getChildren(l,r=null,c=null){return ix(this,l,r,c)}resolve(l,r=0){return Io(this,l,r,!1)}resolveInner(l,r=0){return Io(this,l,r,!0)}matchContext(l){return up(this.parent,l)}enterUnfinishedNodesBefore(l){let r=this.childBefore(l),c=this;for(;r;){let o=r.lastChild;if(!o||o.to!=r.to)break;o.type.isError&&o.from==o.to?(c=r,r=o.prevSibling):r=o}return c}get node(){return this}get next(){return this.parent}}class ul extends Ay{constructor(l,r,c,o){super(),this._tree=l,this.from=r,this.index=c,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(l,r,c,o,d=0){for(let h=this;;){for(let{children:m,positions:g}=h._tree,b=r>0?m.length:-1;l!=b;l+=r){let _=m[l],S=g[l]+h.from,v;if(!(!(d&Jt.EnterBracketed&&_ instanceof Hl&&(v=uc.get(_))&&!v.overlay&&v.bracketed&&c>=S&&c<=S+_.length)&&!Cy(o,c,S,S+_.length))){if(_ instanceof Ri){if(d&Jt.ExcludeBuffers)continue;let E=_.findChild(0,_.buffer.length,r,c-S,o);if(E>-1)return new la(new E1(h,_,l,S),null,E)}else if(d&Jt.IncludeAnonymous||!_.type.isAnonymous||Ep(_)){let E;if(!(d&Jt.IgnoreMounts)&&(E=uc.get(_))&&!E.overlay)return new ul(E.tree,S,l,h);let T=new ul(_,S,l,h);return d&Jt.IncludeAnonymous||!T.type.isAnonymous?T:T.nextChild(r<0?_.children.length-1:0,r,c,o,d)}}}if(d&Jt.IncludeAnonymous||!h.type.isAnonymous||(h.index>=0?l=h.index+r:l=r<0?-1:h._parent._tree.children.length,h=h._parent,!h))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(l){return this.nextChild(0,1,l,2)}childBefore(l){return this.nextChild(this._tree.children.length-1,-1,l,-2)}prop(l){return this._tree.prop(l)}enter(l,r,c=0){let o;if(!(c&Jt.IgnoreOverlays)&&(o=uc.get(this._tree))&&o.overlay){let d=l-this.from,h=c&Jt.EnterBracketed&&o.bracketed;for(let{from:m,to:g}of o.overlay)if((r>0||h?m<=d:m<d)&&(r<0||h?g>=d:g>d))return new ul(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,l,r,c)}nextSignificantParent(){let l=this;for(;l.type.isAnonymous&&l._parent;)l=l._parent;return l}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function ix(s,l,r,c){let o=s.cursor(),d=[];if(!o.firstChild())return d;if(r!=null){for(let h=!1;!h;)if(h=o.type.is(r),!o.nextSibling())return d}for(;;){if(c!=null&&o.type.is(c))return d;if(o.type.is(l)&&d.push(o.node),!o.nextSibling())return c==null?d:[]}}function up(s,l,r=l.length-1){for(let c=s;r>=0;c=c.parent){if(!c)return!1;if(!c.type.isAnonymous){if(l[r]&&l[r]!=c.name)return!1;r--}}return!0}class E1{constructor(l,r,c,o){this.parent=l,this.buffer=r,this.index=c,this.start=o}}class la extends Ay{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(l,r,c){super(),this.context=l,this._parent=r,this.index=c,this.type=l.buffer.set.types[l.buffer.buffer[c]]}child(l,r,c){let{buffer:o}=this.context,d=o.findChild(this.index+4,o.buffer[this.index+3],l,r-this.context.start,c);return d<0?null:new la(this.context,this,d)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(l){return this.child(1,l,2)}childBefore(l){return this.child(-1,l,-2)}prop(l){return this.type.prop(l)}enter(l,r,c=0){if(c&Jt.ExcludeBuffers)return null;let{buffer:o}=this.context,d=o.findChild(this.index+4,o.buffer[this.index+3],r>0?1:-1,l-this.context.start,r);return d<0?null:new la(this.context,this,d)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(l){return this._parent?null:this.context.parent.nextChild(this.context.index+l,l,0,4)}get nextSibling(){let{buffer:l}=this.context,r=l.buffer[this.index+3];return r<(this._parent?l.buffer[this._parent.index+3]:l.buffer.length)?new la(this.context,this._parent,r):this.externalSibling(1)}get prevSibling(){let{buffer:l}=this.context,r=this._parent?this._parent.index+4:0;return this.index==r?this.externalSibling(-1):new la(this.context,this._parent,l.findChild(r,this.index,-1,0,4))}get tree(){return null}toTree(){let l=[],r=[],{buffer:c}=this.context,o=this.index+4,d=c.buffer[this.index+3];if(d>o){let h=c.buffer[this.index+1];l.push(c.slice(o,d,h)),r.push(0)}return new Hl(this.type,l,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function My(s){if(!s.length)return null;let l=0,r=s[0];for(let d=1;d<s.length;d++){let h=s[d];(h.from>r.from||h.to<r.to)&&(r=h,l=d)}let c=r instanceof ul&&r.index<0?null:r.parent,o=s.slice();return c?o[l]=c:o.splice(l,1),new C1(o,r)}class C1{constructor(l,r){this.heads=l,this.node=r}get next(){return My(this.heads)}}function A1(s,l,r){let c=s.resolveInner(l,r),o=null;for(let d=c instanceof ul?c:c.context.parent;d;d=d.parent)if(d.index<0){let h=d.parent;(o||(o=[c])).push(h.resolve(l,r)),d=h}else{let h=uc.get(d.tree);if(h&&h.overlay&&h.overlay[0].from<=l&&h.overlay[h.overlay.length-1].to>=l){let m=new ul(h.tree,h.overlay[0].from+d.from,-1,d);(o||(o=[c])).push(Io(m,l,r,!1))}}return o?My(o):c}class Hf{get name(){return this.type.name}constructor(l,r=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=r&~Jt.EnterBracketed,l instanceof ul)this.yieldNode(l);else{this._tree=l.context.parent,this.buffer=l.context;for(let c=l._parent;c;c=c._parent)this.stack.unshift(c.index);this.bufferNode=l,this.yieldBuf(l.index)}}yieldNode(l){return l?(this._tree=l,this.type=l.type,this.from=l.from,this.to=l.to,!0):!1}yieldBuf(l,r){this.index=l;let{start:c,buffer:o}=this.buffer;return this.type=r||o.set.types[o.buffer[l]],this.from=c+o.buffer[l+1],this.to=c+o.buffer[l+2],!0}yield(l){return l?l instanceof ul?(this.buffer=null,this.yieldNode(l)):(this.buffer=l.context,this.yieldBuf(l.index,l.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(l,r,c){if(!this.buffer)return this.yield(this._tree.nextChild(l<0?this._tree._tree.children.length-1:0,l,r,c,this.mode));let{buffer:o}=this.buffer,d=o.findChild(this.index+4,o.buffer[this.index+3],l,r-this.buffer.start,c);return d<0?!1:(this.stack.push(this.index),this.yieldBuf(d))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(l){return this.enterChild(1,l,2)}childBefore(l){return this.enterChild(-1,l,-2)}enter(l,r,c=this.mode){return this.buffer?c&Jt.ExcludeBuffers?!1:this.enterChild(1,l,r):this.yield(this._tree.enter(l,r,c))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Jt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let l=this.mode&Jt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(l)}sibling(l){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+l,l,0,4,this.mode)):!1;let{buffer:r}=this.buffer,c=this.stack.length-1;if(l<0){let o=c<0?0:this.stack[c]+4;if(this.index!=o)return this.yieldBuf(r.findChild(o,this.index,-1,0,4))}else{let o=r.buffer[this.index+3];if(o<(c<0?r.buffer.length:r.buffer[this.stack[c]+3]))return this.yieldBuf(o)}return c<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+l,l,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(l){let r,c,{buffer:o}=this;if(o){if(l>0){if(this.index<o.buffer.buffer.length)return!1}else for(let d=0;d<this.index;d++)if(o.buffer.buffer[d+3]<this.index)return!1;({index:r,parent:c}=o)}else({index:r,_parent:c}=this._tree);for(;c;{index:r,_parent:c}=c)if(r>-1)for(let d=r+l,h=l<0?-1:c._tree.children.length;d!=h;d+=l){let m=c._tree.children[d];if(this.mode&Jt.IncludeAnonymous||m instanceof Ri||!m.type.isAnonymous||Ep(m))return!1}return!0}move(l,r){if(r&&this.enterChild(l,0,4))return!0;for(;;){if(this.sibling(l))return!0;if(this.atLastNode(l)||!this.parent())return!1}}next(l=!0){return this.move(1,l)}prev(l=!0){return this.move(-1,l)}moveTo(l,r=0){for(;(this.from==this.to||(r<1?this.from>=l:this.from>l)||(r>-1?this.to<=l:this.to<l))&&this.parent(););for(;this.enterChild(1,l,r););return this}get node(){if(!this.buffer)return this._tree;let l=this.bufferNode,r=null,c=0;if(l&&l.context==this.buffer)e:for(let o=this.index,d=this.stack.length;d>=0;){for(let h=l;h;h=h._parent)if(h.index==o){if(o==this.index)return h;r=h,c=d+1;break e}o=this.stack[--d]}for(let o=c;o<this.stack.length;o++)r=new la(this.buffer,r,this.stack[o]);return this.bufferNode=new la(this.buffer,r,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(l,r){for(let c=0;;){let o=!1;if(this.type.isAnonymous||l(this)!==!1){if(this.firstChild()){c++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&r&&r(this),o=this.type.isAnonymous,!c)return;if(this.nextSibling())break;this.parent(),c--,o=!0}}}matchContext(l){if(!this.buffer)return up(this.node.parent,l);let{buffer:r}=this.buffer,{types:c}=r.set;for(let o=l.length-1,d=this.stack.length-1;o>=0;d--){if(d<0)return up(this._tree,l,o);let h=c[r.buffer[this.stack[d]]];if(!h.isAnonymous){if(l[o]&&l[o]!=h.name)return!1;o--}}return!0}}function Ep(s){return s.children.some(l=>l instanceof Ri||!l.type.isAnonymous||Ep(l))}function M1(s){var l;let{buffer:r,nodeSet:c,maxBufferLength:o=k1,reused:d=[],minRepeatType:h=c.types.length}=s,m=Array.isArray(r)?new Tp(r,r.length):r,g=c.types,b=0,_=0;function S(Z,M,D,H,ne,he){let{id:W,start:ue,end:je,size:Me}=m,Ce=_,A=b;if(Me<0)if(m.next(),Me==-1){let N=d[W];D.push(N),H.push(ue-Z);return}else if(Me==-3){b=W;return}else if(Me==-4){_=W;return}else throw new RangeError(`Unrecognized record size: ${Me}`);let ce=g[W],z,be,ye=ue-Z;if(je-ue<=o&&(be=L(m.pos-M,ne))){let N=new Uint16Array(be.size-be.skip),V=m.pos-be.size,re=N.length;for(;m.pos>V;)re=X(be.start,N,re);z=new Ri(N,je-be.start,c),ye=be.start-Z}else{let N=m.pos-Me;m.next();let V=[],re=[],me=W>=h?W:-1,Ne=0,ve=je;for(;m.pos>N;)me>=0&&m.id==me&&m.size>=0?(m.end<=ve-o&&(T(V,re,ue,Ne,m.end,ve,me,Ce,A),Ne=V.length,ve=m.end),m.next()):he>2500?v(ue,N,V,re):S(ue,N,V,re,me,he+1);if(me>=0&&Ne>0&&Ne<V.length&&T(V,re,ue,Ne,ue,ve,me,Ce,A),V.reverse(),re.reverse(),me>-1&&Ne>0){let De=E(ce,A);z=Cp(ce,V,re,0,V.length,0,je-ue,De,De)}else z=C(ce,V,re,je-ue,Ce-je,A)}D.push(z),H.push(ye)}function v(Z,M,D,H){let ne=[],he=0,W=-1;for(;m.pos>M;){let{id:ue,start:je,end:Me,size:Ce}=m;if(Ce>4)m.next();else{if(W>-1&&je<W)break;W<0&&(W=Me-o),ne.push(ue,je,Me),he++,m.next()}}if(he){let ue=new Uint16Array(he*4),je=ne[ne.length-2];for(let Me=ne.length-3,Ce=0;Me>=0;Me-=3)ue[Ce++]=ne[Me],ue[Ce++]=ne[Me+1]-je,ue[Ce++]=ne[Me+2]-je,ue[Ce++]=Ce;D.push(new Ri(ue,ne[2]-je,c)),H.push(je-Z)}}function E(Z,M){return(D,H,ne)=>{let he=0,W=D.length-1,ue,je;if(W>=0&&(ue=D[W])instanceof Hl){if(!W&&ue.type==Z&&ue.length==ne)return ue;(je=ue.prop(Pt.lookAhead))&&(he=H[W]+ue.length+je)}return C(Z,D,H,ne,he,M)}}function T(Z,M,D,H,ne,he,W,ue,je){let Me=[],Ce=[];for(;Z.length>H;)Me.push(Z.pop()),Ce.push(M.pop()+D-ne);Z.push(C(c.types[W],Me,Ce,he-ne,ue-he,je)),M.push(ne-D)}function C(Z,M,D,H,ne,he,W){if(he){let ue=[Pt.contextHash,he];W=W?[ue].concat(W):[ue]}if(ne>25){let ue=[Pt.lookAhead,ne];W=W?[ue].concat(W):[ue]}return new Hl(Z,M,D,H,W)}function L(Z,M){let D=m.fork(),H=0,ne=0,he=0,W=D.end-o,ue={size:0,start:0,skip:0};e:for(let je=D.pos-Z;D.pos>je;){let Me=D.size;if(D.id==M&&Me>=0){ue.size=H,ue.start=ne,ue.skip=he,he+=4,H+=4,D.next();continue}let Ce=D.pos-Me;if(Me<0||Ce<je||D.start<W)break;let A=D.id>=h?4:0,ce=D.start;for(D.next();D.pos>Ce;){if(D.size<0)if(D.size==-3||D.size==-4)A+=4;else break e;else D.id>=h&&(A+=4);D.next()}ne=ce,H+=Me,he+=A}return(M<0||H==Z)&&(ue.size=H,ue.start=ne,ue.skip=he),ue.size>4?ue:void 0}function X(Z,M,D){let{id:H,start:ne,end:he,size:W}=m;if(m.next(),W>=0&&H<h){let ue=D;if(W>4){let je=m.pos-(W-4);for(;m.pos>je;)D=X(Z,M,D)}M[--D]=ue,M[--D]=he-Z,M[--D]=ne-Z,M[--D]=H}else W==-3?b=H:W==-4&&(_=H);return D}let J=[],G=[];for(;m.pos>0;)S(s.start||0,s.bufferStart||0,J,G,-1,0);let O=(l=s.length)!==null&&l!==void 0?l:J.length?G[0]+J[0].length:0;return new Hl(g[s.topID],J.reverse(),G.reverse(),O)}const rx=new WeakMap;function Df(s,l){if(!s.isAnonymous||l instanceof Ri||l.type!=s)return 1;let r=rx.get(l);if(r==null){r=1;for(let c of l.children){if(c.type!=s||!(c instanceof Hl)){r=1;break}r+=Df(s,c)}rx.set(l,r)}return r}function Cp(s,l,r,c,o,d,h,m,g){let b=0;for(let T=c;T<o;T++)b+=Df(s,l[T]);let _=Math.ceil(b*1.5/8),S=[],v=[];function E(T,C,L,X,J){for(let G=L;G<X;){let O=G,Z=C[G],M=Df(s,T[G]);for(G++;G<X;G++){let D=Df(s,T[G]);if(M+D>=_)break;M+=D}if(G==O+1){if(M>_){let D=T[O];E(D.children,D.positions,0,D.children.length,C[O]+J);continue}S.push(T[O])}else{let D=C[G-1]+T[G-1].length-Z;S.push(Cp(s,T,C,O,G,Z,D,null,g))}v.push(Z+J-d)}}return E(l,r,c,o,0),(m||g)(S,v,h)}class EN{constructor(){this.map=new WeakMap}setBuffer(l,r,c){let o=this.map.get(l);o||this.map.set(l,o=new Map),o.set(r,c)}getBuffer(l,r){let c=this.map.get(l);return c&&c.get(r)}set(l,r){l instanceof la?this.setBuffer(l.context.buffer,l.index,r):l instanceof ul&&this.map.set(l.tree,r)}get(l){return l instanceof la?this.getBuffer(l.context.buffer,l.index):l instanceof ul?this.map.get(l.tree):void 0}cursorSet(l,r){l.buffer?this.setBuffer(l.buffer.buffer,l.index,r):this.map.set(l.tree,r)}cursorGet(l){return l.buffer?this.getBuffer(l.buffer.buffer,l.index):this.map.get(l.tree)}}class qo{constructor(l,r,c,o,d=!1,h=!1){this.from=l,this.to=r,this.tree=c,this.offset=o,this.open=(d?1:0)|(h?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(l,r=[],c=!1){let o=[new qo(0,l.length,l,0,!1,c)];for(let d of r)d.to>l.length&&o.push(d);return o}static applyChanges(l,r,c=128){if(!r.length)return l;let o=[],d=1,h=l.length?l[0]:null;for(let m=0,g=0,b=0;;m++){let _=m<r.length?r[m]:null,S=_?_.fromA:1e9;if(S-g>=c)for(;h&&h.from<S;){let v=h;if(g>=v.from||S<=v.to||b){let E=Math.max(v.from,g)-b,T=Math.min(v.to,S)-b;v=E>=T?null:new qo(E,T,v.tree,v.offset+b,m>0,!!_)}if(v&&o.push(v),h.to>S)break;h=d<l.length?l[d++]:null}if(!_)break;g=_.toA,b=_.toA-_.toB}return o}}class CN{startParse(l,r,c){return typeof l=="string"&&(l=new R1(l)),c=c?c.length?c.map(o=>new fs(o.from,o.to)):[new fs(0,0)]:[new fs(0,l.length)],this.createParse(l,r||[],c)}parse(l,r,c){let o=this.startParse(l,r,c);for(;;){let d=o.advance();if(d)return d}}}class R1{constructor(l){this.string=l}get length(){return this.string.length}chunk(l){return this.string.slice(l)}get lineChunks(){return!1}read(l,r){return this.string.slice(l,r)}}function AN(s){return(l,r,c,o)=>new O1(l,s,r,c,o)}class cx{constructor(l,r,c,o,d,h){this.parser=l,this.parse=r,this.overlay=c,this.bracketed=o,this.target=d,this.from=h}}function ox(s){if(!s.length||s.some(l=>l.from>=l.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}class D1{constructor(l,r,c,o,d,h,m,g){this.parser=l,this.predicate=r,this.mounts=c,this.index=o,this.start=d,this.bracketed=h,this.target=m,this.prev=g,this.depth=0,this.ranges=[]}}const fp=new Pt({perNode:!0});class O1{constructor(l,r,c,o,d){this.nest=r,this.input=c,this.fragments=o,this.ranges=d,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=l}advance(){if(this.baseParse){let c=this.baseParse.advance();if(!c)return null;if(this.baseParse=null,this.baseTree=c,this.startInner(),this.stoppedAt!=null)for(let o of this.inner)o.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let c=this.baseTree;return this.stoppedAt!=null&&(c=new Hl(c.type,c.children,c.positions,c.length,c.propValues.concat([[fp,this.stoppedAt]]))),c}let l=this.inner[this.innerDone],r=l.parse.advance();if(r){this.innerDone++;let c=Object.assign(Object.create(null),l.target.props);c[Pt.mounted.id]=new uc(r,l.overlay,l.parser,l.bracketed),l.target.props=c}return null}get parsedPos(){if(this.baseParse)return 0;let l=this.input.length;for(let r=this.innerDone;r<this.inner.length;r++)this.inner[r].from<l&&(l=Math.min(l,this.inner[r].parse.parsedPos));return l}stopAt(l){if(this.stoppedAt=l,this.baseParse)this.baseParse.stopAt(l);else for(let r=this.innerDone;r<this.inner.length;r++)this.inner[r].parse.stopAt(l)}startInner(){let l=new U1(this.fragments),r=null,c=null,o=new Hf(new ul(this.baseTree,this.ranges[0].from,0,null),Jt.IncludeAnonymous|Jt.IgnoreMounts);e:for(let d,h;;){let m=!0,g;if(this.stoppedAt!=null&&o.from>=this.stoppedAt)m=!1;else if(l.hasNode(o)){if(r){let b=r.mounts.find(_=>_.frag.from<=o.from&&_.frag.to>=o.to&&_.mount.overlay);if(b)for(let _ of b.mount.overlay){let S=_.from+b.pos,v=_.to+b.pos;S>=o.from&&v<=o.to&&!r.ranges.some(E=>E.from<v&&E.to>S)&&r.ranges.push({from:S,to:v})}}m=!1}else if(c&&(h=L1(c.ranges,o.from,o.to)))m=h!=2;else if(!o.type.isAnonymous&&(d=this.nest(o,this.input))&&(o.from<o.to||!d.overlay)){o.tree||(z1(o),r&&r.depth++,c&&c.depth++);let b=l.findMounts(o.from,d.parser);if(typeof d.overlay=="function")r=new D1(d.parser,d.overlay,b,this.inner.length,o.from,!!d.bracketed,o.tree,r);else{let _=dx(this.ranges,d.overlay||(o.from<o.to?[new fs(o.from,o.to)]:[]));_.length&&ox(_),(_.length||!d.overlay)&&this.inner.push(new cx(d.parser,_.length?d.parser.startParse(this.input,hx(b,_),_):d.parser.startParse(""),d.overlay?d.overlay.map(S=>new fs(S.from-o.from,S.to-o.from)):null,!!d.bracketed,o.tree,_.length?_[0].from:o.from)),d.overlay?_.length&&(c={ranges:_,depth:0,prev:c}):m=!1}}else if(r&&(g=r.predicate(o))&&(g===!0&&(g=new fs(o.from,o.to)),g.from<g.to)){let b=r.ranges.length-1;b>=0&&r.ranges[b].to==g.from?r.ranges[b]={from:r.ranges[b].from,to:g.to}:r.ranges.push(g)}if(m&&o.firstChild())r&&r.depth++,c&&c.depth++;else for(;!o.nextSibling();){if(!o.parent())break e;if(r&&!--r.depth){let b=dx(this.ranges,r.ranges);b.length&&(ox(b),this.inner.splice(r.index,0,new cx(r.parser,r.parser.startParse(this.input,hx(r.mounts,b),b),r.ranges.map(_=>new fs(_.from-r.start,_.to-r.start)),r.bracketed,r.target,b[0].from))),r=r.prev}c&&!--c.depth&&(c=c.prev)}}}}function L1(s,l,r){for(let c of s){if(c.from>=r)break;if(c.to>l)return c.from<=l&&c.to>=r?2:1}return 0}function ux(s,l,r,c,o,d){if(l<r){let h=s.buffer[l+1];c.push(s.slice(l,r,h)),o.push(h-d)}}function z1(s){let{node:l}=s,r=[],c=l.context.buffer;do r.push(s.index),s.parent();while(!s.tree);let o=s.tree,d=o.children.indexOf(c),h=o.children[d],m=h.buffer,g=[d];function b(_,S,v,E,T,C){let L=r[C],X=[],J=[];ux(h,_,L,X,J,E);let G=m[L+1],O=m[L+2];g.push(X.length);let Z=C?b(L+4,m[L+3],h.set.types[m[L]],G,O-G,C-1):l.toTree();return X.push(Z),J.push(G-E),ux(h,m[L+3],S,X,J,E),new Hl(v,X,J,T)}o.children[d]=b(0,m.length,As.none,0,h.length,r.length-1);for(let _ of g){let S=s.tree.children[_],v=s.tree.positions[_];s.yield(new ul(S,v+s.from,_,s._tree))}}class fx{constructor(l,r){this.offset=r,this.done=!1,this.cursor=l.cursor(Jt.IncludeAnonymous|Jt.IgnoreMounts)}moveTo(l){let{cursor:r}=this,c=l-this.offset;for(;!this.done&&r.from<c;)if(!(r.to>=l&&r.enter(c,1,Jt.IgnoreOverlays|Jt.ExcludeBuffers)))if(r.to<=l)r.next(!1)||(this.done=!0);else break}hasNode(l){if(this.moveTo(l.from),!this.done&&this.cursor.from+this.offset==l.from&&this.cursor.tree)for(let r=this.cursor.tree;;){if(r==l.tree)return!0;if(r.children.length&&r.positions[0]==0&&r.children[0]instanceof Hl)r=r.children[0];else break}return!1}}class U1{constructor(l){var r;if(this.fragments=l,this.curTo=0,this.fragI=0,l.length){let c=this.curFrag=l[0];this.curTo=(r=c.tree.prop(fp))!==null&&r!==void 0?r:c.to,this.inner=new fx(c.tree,-c.offset)}else this.curFrag=this.inner=null}hasNode(l){for(;this.curFrag&&l.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=l.from&&this.curTo>=l.to&&this.inner.hasNode(l)}nextFrag(){var l;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let r=this.curFrag=this.fragments[this.fragI];this.curTo=(l=r.tree.prop(fp))!==null&&l!==void 0?l:r.to,this.inner=new fx(r.tree,-r.offset)}}findMounts(l,r){var c;let o=[];if(this.inner){this.inner.cursor.moveTo(l,1);for(let d=this.inner.cursor.node;d;d=d.parent){let h=(c=d.tree)===null||c===void 0?void 0:c.prop(Pt.mounted);if(h&&h.parser==r)for(let m=this.fragI;m<this.fragments.length;m++){let g=this.fragments[m];if(g.from>=d.to)break;g.tree==this.curFrag.tree&&o.push({frag:g,pos:d.from-g.offset,mount:h})}}}return o}}function dx(s,l){let r=null,c=l;for(let o=1,d=0;o<s.length;o++){let h=s[o-1].to,m=s[o].from;for(;d<c.length;d++){let g=c[d];if(g.from>=m)break;g.to<=h||(r||(c=r=l.slice()),g.from<h?(r[d]=new fs(g.from,h),g.to>m&&r.splice(d+1,0,new fs(m,g.to))):g.to>m?r[d--]=new fs(m,g.to):r.splice(d--,1))}}return c}function H1(s,l,r,c){let o=0,d=0,h=!1,m=!1,g=-1e9,b=[];for(;;){let _=o==s.length?1e9:h?s[o].to:s[o].from,S=d==l.length?1e9:m?l[d].to:l[d].from;if(h!=m){let v=Math.max(g,r),E=Math.min(_,S,c);v<E&&b.push(new fs(v,E))}if(g=Math.min(_,S),g==1e9)break;_==g&&(h?(h=!1,o++):h=!0),S==g&&(m?(m=!1,d++):m=!0)}return b}function hx(s,l){let r=[];for(let{pos:c,mount:o,frag:d}of s){let h=c+(o.overlay?o.overlay[0].from:0),m=h+o.tree.length,g=Math.max(d.from,h),b=Math.min(d.to,m);if(o.overlay){let _=o.overlay.map(v=>new fs(v.from+c,v.to+c)),S=H1(l,_,g,b);for(let v=0,E=g;;v++){let T=v==S.length,C=T?b:S[v].from;if(C>E&&r.push(new qo(E,C,o.tree,-h,d.from>=E||d.openStart,d.to<=C||d.openEnd)),T)break;E=S[v].to}}else r.push(new qo(g,b,o.tree,-h,d.from>=h||d.openStart,d.to<=m||d.openEnd))}return r}let B1=0;class us{constructor(l,r,c,o){this.name=l,this.set=r,this.base=c,this.modified=o,this.id=B1++}toString(){let{name:l}=this;for(let r of this.modified)r.name&&(l=`${r.name}(${l})`);return l}static define(l,r){let c=typeof l=="string"?l:"?";if(l instanceof us&&(r=l),r!=null&&r.base)throw new Error("Can not derive from a modified tag");let o=new us(c,[],null,[]);if(o.set.push(o),r)for(let d of r.set)o.set.push(d);return o}static defineModifier(l){let r=new Bf(l);return c=>c.modified.indexOf(r)>-1?c:Bf.get(c.base||c,c.modified.concat(r).sort((o,d)=>o.id-d.id))}}let I1=0;class Bf{constructor(l){this.name=l,this.instances=[],this.id=I1++}static get(l,r){if(!r.length)return l;let c=r[0].instances.find(m=>m.base==l&&q1(r,m.modified));if(c)return c;let o=[],d=new us(l.name,o,l,r);for(let m of r)m.instances.push(d);let h=G1(r);for(let m of l.set)if(!m.modified.length)for(let g of h)o.push(Bf.get(m,g));return d}}function q1(s,l){return s.length==l.length&&s.every((r,c)=>r==l[c])}function G1(s){let l=[[]];for(let r=0;r<s.length;r++)for(let c=0,o=l.length;c<o;c++)l.push(l[c].concat(s[r]));return l.sort((r,c)=>c.length-r.length)}function MN(s){let l=Object.create(null);for(let r in s){let c=s[r];Array.isArray(c)||(c=[c]);for(let o of r.split(" "))if(o){let d=[],h=2,m=o;for(let S=0;;){if(m=="..."&&S>0&&S+3==o.length){h=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(m);if(!v)throw new RangeError("Invalid path: "+o);if(d.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),S+=v[0].length,S==o.length)break;let E=o[S++];if(S==o.length&&E=="!"){h=0;break}if(E!="/")throw new RangeError("Invalid path: "+o);m=o.slice(S)}let g=d.length-1,b=d[g];if(!b)throw new RangeError("Invalid path: "+o);let _=new Go(c,h,g>0?d.slice(0,g):null);l[b]=_.sort(l[b])}}return Ry.add(l)}const Ry=new Pt({combine(s,l){let r,c,o;for(;s||l;){if(!s||l&&s.depth>=l.depth?(o=l,l=l.next):(o=s,s=s.next),r&&r.mode==o.mode&&!o.context&&!r.context)continue;let d=new Go(o.tags,o.mode,o.context);r?r.next=d:c=d,r=d}return c}});class Go{constructor(l,r,c,o){this.tags=l,this.mode=r,this.context=c,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(l){return!l||l.depth<this.depth?(this.next=l,this):(l.next=this.sort(l.next),l)}get depth(){return this.context?this.context.length:0}}Go.empty=new Go([],2,null);function Dy(s,l){let r=Object.create(null);for(let d of s)if(!Array.isArray(d.tag))r[d.tag.id]=d.class;else for(let h of d.tag)r[h.id]=d.class;let{scope:c,all:o=null}=l||{};return{style:d=>{let h=o;for(let m of d)for(let g of m.set){let b=r[g.id];if(b){h=h?h+" "+b:b;break}}return h},scope:c}}function Y1(s,l){let r=null;for(let c of s){let o=c.style(l);o&&(r=r?r+" "+o:o)}return r}function X1(s,l,r,c=0,o=s.length){let d=new V1(c,Array.isArray(l)?l:[l],r);d.highlightRange(s.cursor(),c,o,"",d.highlighters),d.flush(o)}function $1(s,l,r,c,o,d=0,h=s.length){let m=d;function g(b,_){if(!(b<=m)){for(let S=s.slice(m,b),v=0;;){let E=S.indexOf(`
|
|
117
|
-
`,v),T=E<0?S.length:E;if(T>v&&c(S.slice(v,T),_),E<0)break;o(),v=E+1}m=b}}X1(l,r,(b,_,S)=>{g(b,""),g(_,S)},d,h),g(h,"")}class V1{constructor(l,r,c){this.at=l,this.highlighters=r,this.span=c,this.class=""}startSpan(l,r){r!=this.class&&(this.flush(l),l>this.at&&(this.at=l),this.class=r)}flush(l){l>this.at&&this.class&&this.span(this.at,l,this.class)}highlightRange(l,r,c,o,d){let{type:h,from:m,to:g}=l;if(m>=c||g<=r)return;h.isTop&&(d=this.highlighters.filter(E=>!E.scope||E.scope(h)));let b=o,_=Q1(l)||Go.empty,S=Y1(d,_.tags);if(S&&(b&&(b+=" "),b+=S,_.mode==1&&(o+=(o?" ":"")+S)),this.startSpan(Math.max(r,m),b),_.opaque)return;let v=l.tree&&l.tree.prop(Pt.mounted);if(v&&v.overlay){let E=l.node.enter(v.overlay[0].from+m,1),T=this.highlighters.filter(L=>!L.scope||L.scope(v.tree.type)),C=l.firstChild();for(let L=0,X=m;;L++){let J=L<v.overlay.length?v.overlay[L]:null,G=J?J.from+m:g,O=Math.max(r,X),Z=Math.min(c,G);if(O<Z&&C)for(;l.from<Z&&(this.highlightRange(l,O,Z,o,d),this.startSpan(Math.min(Z,l.to),b),!(l.to>=G||!l.nextSibling())););if(!J||G>c)break;X=J.to+m,X>r&&(this.highlightRange(E.cursor(),Math.max(r,J.from+m),Math.min(c,X),"",T),this.startSpan(Math.min(c,X),b))}C&&l.parent()}else if(l.firstChild()){v&&(o="");do if(!(l.to<=r)){if(l.from>=c)break;this.highlightRange(l,r,c,o,d),this.startSpan(Math.min(c,l.to),b)}while(l.nextSibling());l.parent()}}}function Q1(s){let l=s.type.prop(Ry);for(;l&&l.context&&!s.matchContext(l.context);)l=l.next;return l||null}const Se=us.define,hf=Se(),Ti=Se(),px=Se(Ti),mx=Se(Ti),Ei=Se(),pf=Se(Ei),Xh=Se(Ei),Ps=Se(),er=Se(Ps),Ks=Se(),Zs=Se(),dp=Se(),Mo=Se(dp),mf=Se(),Te={comment:hf,lineComment:Se(hf),blockComment:Se(hf),docComment:Se(hf),name:Ti,variableName:Se(Ti),typeName:px,tagName:Se(px),propertyName:mx,attributeName:Se(mx),className:Se(Ti),labelName:Se(Ti),namespace:Se(Ti),macroName:Se(Ti),literal:Ei,string:pf,docString:Se(pf),character:Se(pf),attributeValue:Se(pf),number:Xh,integer:Se(Xh),float:Se(Xh),bool:Se(Ei),regexp:Se(Ei),escape:Se(Ei),color:Se(Ei),url:Se(Ei),keyword:Ks,self:Se(Ks),null:Se(Ks),atom:Se(Ks),unit:Se(Ks),modifier:Se(Ks),operatorKeyword:Se(Ks),controlKeyword:Se(Ks),definitionKeyword:Se(Ks),moduleKeyword:Se(Ks),operator:Zs,derefOperator:Se(Zs),arithmeticOperator:Se(Zs),logicOperator:Se(Zs),bitwiseOperator:Se(Zs),compareOperator:Se(Zs),updateOperator:Se(Zs),definitionOperator:Se(Zs),typeOperator:Se(Zs),controlOperator:Se(Zs),punctuation:dp,separator:Se(dp),bracket:Mo,angleBracket:Se(Mo),squareBracket:Se(Mo),paren:Se(Mo),brace:Se(Mo),content:Ps,heading:er,heading1:Se(er),heading2:Se(er),heading3:Se(er),heading4:Se(er),heading5:Se(er),heading6:Se(er),contentSeparator:Se(Ps),list:Se(Ps),quote:Se(Ps),emphasis:Se(Ps),strong:Se(Ps),link:Se(Ps),monospace:Se(Ps),strikethrough:Se(Ps),inserted:Se(),deleted:Se(),changed:Se(),invalid:Se(),meta:mf,documentMeta:Se(mf),annotation:Se(mf),processingInstruction:Se(mf),definition:us.defineModifier("definition"),constant:us.defineModifier("constant"),function:us.defineModifier("function"),standard:us.defineModifier("standard"),local:us.defineModifier("local"),special:us.defineModifier("special")};for(let s in Te){let l=Te[s];l instanceof us&&(l.name=s)}Dy([{tag:Te.link,class:"tok-link"},{tag:Te.heading,class:"tok-heading"},{tag:Te.emphasis,class:"tok-emphasis"},{tag:Te.strong,class:"tok-strong"},{tag:Te.keyword,class:"tok-keyword"},{tag:Te.atom,class:"tok-atom"},{tag:Te.bool,class:"tok-bool"},{tag:Te.url,class:"tok-url"},{tag:Te.labelName,class:"tok-labelName"},{tag:Te.inserted,class:"tok-inserted"},{tag:Te.deleted,class:"tok-deleted"},{tag:Te.literal,class:"tok-literal"},{tag:Te.string,class:"tok-string"},{tag:Te.number,class:"tok-number"},{tag:[Te.regexp,Te.escape,Te.special(Te.string)],class:"tok-string2"},{tag:Te.variableName,class:"tok-variableName"},{tag:Te.local(Te.variableName),class:"tok-variableName tok-local"},{tag:Te.definition(Te.variableName),class:"tok-variableName tok-definition"},{tag:Te.special(Te.variableName),class:"tok-variableName2"},{tag:Te.definition(Te.propertyName),class:"tok-propertyName tok-definition"},{tag:Te.typeName,class:"tok-typeName"},{tag:Te.namespace,class:"tok-namespace"},{tag:Te.className,class:"tok-className"},{tag:Te.macroName,class:"tok-macroName"},{tag:Te.propertyName,class:"tok-propertyName"},{tag:Te.operator,class:"tok-operator"},{tag:Te.comment,class:"tok-comment"},{tag:Te.meta,class:"tok-meta"},{tag:Te.invalid,class:"tok-invalid"},{tag:Te.punctuation,class:"tok-punctuation"}]);const K1="modulepreload",Z1=function(s,l){return new URL(s,l).href},gx={},Ke=function(l,r,c){let o=Promise.resolve();if(r&&r.length>0){let h=function(_){return Promise.all(_.map(S=>Promise.resolve(S).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const m=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),b=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=h(r.map(_=>{if(_=Z1(_,c),_ in gx)return;gx[_]=!0;const S=_.endsWith(".css"),v=S?'[rel="stylesheet"]':"";if(!!c)for(let C=m.length-1;C>=0;C--){const L=m[C];if(L.href===_&&(!S||L.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${_}"]${v}`))return;const T=document.createElement("link");if(T.rel=S?"stylesheet":K1,S||(T.as="script"),T.crossOrigin="",T.href=_,b&&T.setAttribute("nonce",b),document.head.appendChild(T),S)return new Promise((C,L)=>{T.addEventListener("load",C),T.addEventListener("error",()=>L(new Error(`Unable to preload CSS for ${_}`)))})}))}function d(h){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=h,window.dispatchEvent(m),!m.defaultPrevented)throw h}return o.then(h=>{for(const m of h||[])m.status==="rejected"&&d(m.reason);return l().catch(d)})},Oy={js:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),cjs:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),mjs:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),jsx:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),ts:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),mts:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),cts:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),tsx:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-CXp-N-a3.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0,jsx:!0}),json:async()=>(await Ke(async()=>{const{json:s}=await import("./index-BiGxRIQL.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),jsonc:async()=>(await Ke(async()=>{const{json:s}=await import("./index-BiGxRIQL.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),css:async()=>(await Ke(async()=>{const{css:s}=await import("./index-BBdH0WyS.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),scss:async()=>(await Ke(async()=>{const{css:s}=await import("./index-BBdH0WyS.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),less:async()=>(await Ke(async()=>{const{css:s}=await import("./index-BBdH0WyS.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),html:async()=>(await Ke(async()=>{const{html:s}=await import("./index-Cu0rli8K.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),htm:async()=>(await Ke(async()=>{const{html:s}=await import("./index-Cu0rli8K.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),vue:async()=>(await Ke(async()=>{const{html:s}=await import("./index-Cu0rli8K.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),svelte:async()=>(await Ke(async()=>{const{html:s}=await import("./index-Cu0rli8K.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),md:async()=>(await Ke(async()=>{const{markdown:s}=await import("./index-B3mW0ScK.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),markdown:async()=>(await Ke(async()=>{const{markdown:s}=await import("./index-B3mW0ScK.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),py:async()=>(await Ke(async()=>{const{python:s}=await import("./index-Ceqv0JQi.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),pyi:async()=>(await Ke(async()=>{const{python:s}=await import("./index-Ceqv0JQi.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),yaml:async()=>(await Ke(async()=>{const{yaml:s}=await import("./index-CWJg4zA3.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),yml:async()=>(await Ke(async()=>{const{yaml:s}=await import("./index-CWJg4zA3.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),rs:async()=>(await Ke(async()=>{const{rust:s}=await import("./index-EhM5ESQH.js");return{rust:s}},__vite__mapDeps([12,1,2,3,4]),import.meta.url)).rust(),c:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-DaN46jfw.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),h:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-DaN46jfw.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cc:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-DaN46jfw.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cpp:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-DaN46jfw.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),hpp:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-DaN46jfw.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),java:async()=>(await Ke(async()=>{const{java:s}=await import("./index-BAMLmkAm.js");return{java:s}},__vite__mapDeps([14,1,2,3,4]),import.meta.url)).java(),go:async()=>(await Ke(async()=>{const{go:s}=await import("./index-Bjmeb0mL.js");return{go:s}},__vite__mapDeps([15,1,2,3,4,5]),import.meta.url)).go(),php:async()=>(await Ke(async()=>{const{php:s}=await import("./index-B3X6gKS4.js");return{php:s}},__vite__mapDeps([16,1,8,7,2,3,4,0,5]),import.meta.url)).php(),sql:async()=>(await Ke(async()=>{const{sql:s}=await import("./index-C3lLfrzk.js");return{sql:s}},__vite__mapDeps([17,2,3,4,1,5]),import.meta.url)).sql(),xml:async()=>(await Ke(async()=>{const{xml:s}=await import("./index-BCeVhzZf.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml(),svg:async()=>(await Ke(async()=>{const{xml:s}=await import("./index-BCeVhzZf.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml()},F1={".mcp.json":"json",dockerfile:"yaml",makefile:"yaml"},J1={javascript:"js",node:"js",typescript:"ts",python:"py",python3:"py",yml:"yaml",rust:"rs",golang:"go","c++":"cpp",cplusplus:"cpp"};async function W1(s){const l=J1[s.toLowerCase()]??s.toLowerCase(),r=Oy[l];return r?r().catch(()=>null):null}async function P1(s){const l=(s.split("/").pop()??"").toLowerCase(),r=F1[l]??l.split(".").pop()??"",c=Oy[r];return c?c().catch(()=>null):null}const ej=Dy([{tag:[Te.keyword,Te.modifier,Te.controlKeyword,Te.moduleKeyword],class:"cmh-key"},{tag:[Te.propertyName],class:"cmh-prop"},{tag:[Te.function(Te.variableName),Te.labelName],class:"cmh-fn"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name),Te.bool],class:"cmh-const"},{tag:[Te.typeName,Te.className,Te.changed,Te.annotation,Te.self,Te.namespace],class:"cmh-type"},{tag:[Te.number,Te.integer,Te.float],class:"cmh-num"},{tag:[Te.string,Te.special(Te.string),Te.regexp],class:"cmh-str"},{tag:[Te.operator,Te.operatorKeyword,Te.escape],class:"cmh-op"},{tag:[Te.meta,Te.comment],class:"cmh-comment"},{tag:Te.invalid,class:"cmh-invalid"}]);function gf(s){return s.replace(/[&<>]/g,l=>l==="&"?"&":l==="<"?"<":">")}async function tj(s,l){const r=l?await W1(l):null;if(!r)return gf(s);try{const c=r.language.parser.parse(s);let o="";return $1(s,c,ej,(d,h)=>{o+=h?`<span class="${h}">${gf(d)}</span>`:gf(d)},()=>{o+=`
|
|
118
|
-
`}),o}catch{return gf(s)}}jt.setOptions({gfm:!0,breaks:!1});function Ly(s){var r;const l=(r=s.split(".").pop())==null?void 0:r.toLowerCase();return l==="md"||l==="markdown"}async function Qf(s){const l=await jt.parse(s,{async:!0,walkTokens:async r=>{if(r.type!=="code")return;const c=r;c.text=await tj(c.text,c.lang??""),c.escaped=!0}});return w1.sanitize(l)}function bx(s,l){return{path:s.path,text:s.content,saved:s.content,eol:s.eol,encoding:s.encoding,mtime:s.mtime,size:s.size,binary:s.binary,tooLarge:s.tooLarge,mediaMime:s.mediaMime,mediaTooLarge:s.mediaTooLarge,stale:!1,revision:l,previewMode:Ly(s.path)}}function Ra(s){return!s.binary&&!s.tooLarge&&s.text!==s.saved}function nj(s){return s.split("/").pop()??s}function fr(s){const l=s.lastIndexOf("/");return l===-1?"":s.slice(0,l)}function Of(s){return s<1024?`${s} Б`:s<1024*1024?`${(s/1024).toFixed(1)} КБ`:`${(s/1024/1024).toFixed(1)} МБ`}function sr({x:s,y:l,items:r,note:c,onClose:o}){const d=y.useRef(null),[h,m]=y.useState({left:s,top:l}),[g,b]=y.useState(()=>{const v=r.findIndex(E=>!E.disabled);return v===-1?0:v});y.useLayoutEffect(()=>{const v=d.current;if(!v)return;const E=v.getBoundingClientRect(),T=8,C=Math.max(T,Math.min(s,window.innerWidth-E.width-T)),L=Math.max(T,Math.min(l,window.innerHeight-E.height-T));m({left:C,top:L})},[s,l]),y.useLayoutEffect(()=>{var v;(v=d.current)==null||v.focus()},[]),y.useLayoutEffect(()=>{function v(T){var C;(C=d.current)!=null&&C.contains(T.target)||o()}function E(){o()}return document.addEventListener("mousedown",v),document.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("scroll",E,!0)}},[o]);function _(v){v.disabled||(v.onSelect(),o())}function S(v){if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),o();return}const E=r.map((T,C)=>({item:T,index:C})).filter(T=>!T.item.disabled);if(E.length!==0){if(v.key==="ArrowDown"||v.key==="ArrowUp"){v.preventDefault();const T=v.key==="ArrowDown"?1:-1,C=E.findIndex(X=>X.index===g),L=E[(((C===-1?0:C)+T)%E.length+E.length)%E.length];L&&b(L.index);return}if(v.key==="Enter"||v.key===" "){v.preventDefault();const T=r[g];T&&_(T)}}}return i.jsxs("div",{ref:d,className:"ctxmenu",style:{left:h.left,top:h.top},role:"menu",tabIndex:-1,onKeyDown:S,children:[c&&i.jsx("div",{className:"ctxmenu__note",children:c}),r.map((v,E)=>i.jsxs("button",{type:"button",role:"menuitem","aria-disabled":v.disabled,className:"ctxmenu__item"+(E===g?" is-cursor":""),onMouseEnter:()=>b(E),onClick:()=>_(v),children:[i.jsx("span",{className:"ctxmenu__label",children:v.label}),v.hint&&i.jsx("span",{className:"ctxmenu__hint",children:v.hint})]},v.id))]})}const lj=3500,sj=9e3,xx=220;function mr({result:s,onDismiss:l}){const[r,c]=y.useState(s),[o,d]=y.useState(!1);if(y.useEffect(()=>{if(!s){c(null),d(!1);return}if(c(s),d(!1),s.url)return;const m=s.ok?lj:sj,g=setTimeout(()=>d(!0),m),b=setTimeout(()=>c(null),m+xx);return()=>{clearTimeout(g),clearTimeout(b)}},[s]),!r)return null;const h=()=>{d(!0),setTimeout(()=>{c(null),l==null||l()},xx)};return i.jsxs("div",{className:"oplog "+(r.ok?"oplog--ok":"oplog--bad")+(o?" oplog--leaving":"")+(r.url?" oplog--dismissible":""),role:"status","aria-live":r.ok?"polite":"assertive",children:[r.message,r.url&&i.jsxs("a",{className:"oplog__link",href:r.url,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),children:[r.url.replace(/^https?:\/\//,"")," ↗"]}),r.url&&l&&i.jsx("button",{type:"button",className:"oplog__dismiss",title:"Закрыть","aria-label":"Закрыть сообщение",onClick:h,children:"✕"})]})}function na({value:s,className:l,placeholder:r="Название сессии",onCommit:c,onCancel:o}){const[d,h]=y.useState(s),m=y.useRef(null);y.useEffect(()=>{var b;(b=m.current)==null||b.select()},[]);function g(){const b=d.trim();if(!b||b===s)return o();c(b)}return i.jsx("input",{ref:m,className:l?`rename ${l}`:"rename",value:d,autoFocus:!0,spellCheck:!1,placeholder:r,onChange:b=>h(b.target.value),onBlur:g,onKeyDown:b=>{b.stopPropagation(),b.key==="Enter"?(b.preventDefault(),g()):b.key==="Escape"&&(b.preventDefault(),o())}})}function Sc({active:s}){return s?i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M2 5h3V2"}),i.jsx("path",{d:"M14 5h-3V2"}),i.jsx("path",{d:"M2 11h3v3"}),i.jsx("path",{d:"M14 11h-3v3"})]}):i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2H2v3"}),i.jsx("path",{d:"M11 2h3v3"}),i.jsx("path",{d:"M2 11v3h3"}),i.jsx("path",{d:"M14 11v3h-3"})]})}const aj=500,tr="application/x-ccv-fs-path",ij=200;function rj({open:s,tree:l,expanded:r,activePath:c,dirty:o,gitChanges:d,result:h,searchResult:m,onSearch:g,onReveal:b,onToggle:_,onOpen:S,onCreate:v,onRename:E,onMove:T,onCopy:C,onDelete:L,onRefresh:X,onClose:J,zoomed:G,onToggleZoom:O}){const[Z,M]=y.useState(""),[D,H]=y.useState(null),[ne,he]=y.useState(null),[W,ue]=y.useState(null),[je,Me]=y.useState(null),[Ce,A]=y.useState(null),[ce,z]=y.useState(null),be=Xf("(hover: hover)"),ye=y.useRef(null),N=y.useMemo(()=>uj(d),[d]);function V(le){return!(!W||le===W.path||W.kind==="dir"&&le.startsWith(`${W.path}/`)||le===fr(W.path))}function re(le){return!(!Ce||le===Ce.path||Ce.kind==="dir"&&le.startsWith(`${Ce.path}/`)||Ce.mode==="cut"&&le===fr(Ce.path))}function me(le){A({path:le.path,kind:le.kind,mode:"copy"})}function Ne(le){A({path:le.path,kind:le.kind,mode:"cut"})}function ve(le){!Ce||!re(le)||(le&&!r.has(le)&&_(le),Ce.mode==="cut"?(T(Ce.path,le),A(null)):C(Ce.path,le))}function De(le,ge){const He=le.touches[0];if(!He)return;const B={timer:0,x:He.clientX,y:He.clientY,el:le.currentTarget,fired:!1};B.timer=window.setTimeout(()=>{B.fired=!0,ge(B.x,B.y,B.el)},aj),ye.current=B}function yt(le){const ge=ye.current,He=le.touches[0];!ge||!He||Math.hypot(He.clientX-ge.x,He.clientY-ge.y)>10&&(window.clearTimeout(ge.timer),ye.current=null)}function Xe(le){const ge=ye.current;ge&&(window.clearTimeout(ge.timer),ge.fired&&le.preventDefault())}function $e(){var le;return(le=ye.current)!=null&&le.fired?(ye.current=null,!0):!1}function Ve(le,ge,He,B){M((B==null?void 0:B.path)??""),z({x:le,y:ge,opener:He,entry:B})}function It(){const le=ce==null?void 0:ce.opener;z(null),le!=null&&le.isConnected&&le.focus()}function rt(le){return{onContextMenu:ge=>{ge.preventDefault(),Ve(ge.clientX,ge.clientY,ge.currentTarget,le)},onTouchStart:ge=>De(ge,(He,B,P)=>Ve(He,B,P,le)),onTouchMove:yt,onTouchEnd:Xe,onTouchCancel:Xe}}function dn(le){le.target===le.currentTarget&&(le.preventDefault(),Ve(le.clientX,le.clientY,le.currentTarget,null))}function ft(le){le.target===le.currentTarget&&De(le,(ge,He,B)=>Ve(ge,He,B,null))}function hn(le){if(!(le.ctrlKey||le.metaKey)||le.target instanceof HTMLInputElement)return;const ge=le.key.toLowerCase();if(ge==="v"){le.preventDefault(),ve(Dn());return}if(!Z)return;const He=yx(l,Z);He&&(ge==="c"?(le.preventDefault(),me(He)):ge==="x"&&(le.preventDefault(),Ne(He)))}function Sn(le){return ge=>{ge.dataTransfer.effectAllowed="move",ge.dataTransfer.setData(tr,le.path),ue({path:le.path,kind:le.kind})}}function xn(){ue(null),Me(null)}function en(le){return ge=>{ge.dataTransfer.types.includes(tr)&&(ge.stopPropagation(),!(le.kind!=="dir"||!V(le.path))&&(ge.preventDefault(),Me(le.path)))}}function tt(le){return ge=>{if(!ge.dataTransfer.types.includes(tr)||(ge.stopPropagation(),le.kind!=="dir"||!V(le.path)))return;ge.preventDefault();const He=ge.dataTransfer.getData(tr);Me(null),He&&T(He,le.path)}}function et(le){!le.dataTransfer.types.includes(tr)||!V("")||(le.preventDefault(),Me(""))}function tn(le){if(!le.dataTransfer.types.includes(tr)||!V(""))return;le.preventDefault();const ge=le.dataTransfer.getData(tr);Me(null),ge&&T(ge,"")}const[Xt,nt]=y.useState(""),St=Xt.trim(),$t=St.length>0,cn=y.useRef(null),wt=y.useRef(g);wt.current=g;function yn(le){nt(le),cn.current&&clearTimeout(cn.current);const ge=le.trim();if(!ge){wt.current("");return}cn.current=setTimeout(()=>wt.current(ge),ij)}function qt(le){cn.current&&clearTimeout(cn.current),nt(""),wt.current(""),M(le.path),b(le)}const pn=$t&&(m==null?void 0:m.query)===St?m:null;function Dn(){if(Z==="")return"";const le=yx(l,Z);if((le==null?void 0:le.kind)==="dir")return Z;const ge=Z.lastIndexOf("/");return ge===-1?"":Z.slice(0,ge)}function Gt(le,ge){const He=ge??Dn();He&&!r.has(He)&&_(He),he({parent:He,kind:le})}function ct(){if(!ce)return[];const le=B=>be?B:void 0;if(!ce.entry)return[{id:"paste",label:"Вставить в корень проекта",hint:le("Ctrl+V"),disabled:!re(""),onSelect:()=>ve("")},{id:"new-file",label:"Создать файл",onSelect:()=>Gt("file","")},{id:"new-dir",label:"Создать каталог",onSelect:()=>Gt("dir","")}];const ge=ce.entry,He=[ge.kind==="file"?{id:"open",label:"Открыть",onSelect:()=>S(ge.path)}:{id:"toggle",label:r.has(ge.path)?"Свернуть":"Развернуть",onSelect:()=>_(ge.path)},{id:"copy",label:"Копировать",hint:le("Ctrl+C"),onSelect:()=>me(ge)},{id:"cut",label:"Вырезать",hint:le("Ctrl+X"),onSelect:()=>Ne(ge)}];return ge.kind==="dir"&&(He.push({id:"paste",label:"Вставить",hint:le("Ctrl+V"),disabled:!re(ge.path),onSelect:()=>ve(ge.path)}),He.push({id:"new-file",label:"Создать файл",onSelect:()=>Gt("file",ge.path)}),He.push({id:"new-dir",label:"Создать каталог",onSelect:()=>Gt("dir",ge.path)})),He.push({id:"rename",label:"Переименовать",onSelect:()=>H(ge.path)}),He.push({id:"delete",label:"Удалить",onSelect:()=>L(ge)}),He}const Et=$t?[]:Pe("",0);function Pe(le,ge){const He=l[le],B=[];if(ne&&ne.parent===le&&B.push(i.jsxs("div",{className:"fsrow fsrow--draft",style:Da(ge),children:[i.jsx("span",{className:"fsrow__icon",children:ne.kind==="dir"?i.jsx(qf,{}):i.jsx(Gf,{})}),i.jsx(na,{className:"rename--file",value:"",placeholder:ne.kind==="dir"?"имя каталога":"имя файла",onCommit:P=>{he(null),v(le,ne.kind,P)},onCancel:()=>he(null)})]},`draft:${le}`)),!He)return B.push(i.jsx("p",{className:"fsrow__pending",style:Da(ge),children:"читаем…"},`wait:${le}`)),B;He.length===0&&!ne&&B.push(i.jsx("p",{className:"fsrow__pending",style:Da(ge),children:"пусто"},`empty:${le}`));for(const P of He){const _e=P.kind==="dir"&&r.has(P.path);B.push(D===P.path?i.jsxs("div",{className:"fsrow fsrow--draft",style:Da(ge),children:[i.jsx("span",{className:"fsrow__icon",children:P.kind==="dir"?i.jsx(qf,{open:_e}):i.jsx(Gf,{})}),i.jsx(na,{className:"rename--file",value:P.name,placeholder:"новое имя",onCommit:Be=>{H(null),E(P.path,Be)},onCancel:()=>H(null)})]},P.path):i.jsx(cj,{entry:P,depth:ge,open:_e,active:P.path===c,selected:P.path===Z,dirty:o.has(P.path),gitStatus:N.get(P.path),dragging:(W==null?void 0:W.path)===P.path,dropTarget:je===P.path,cut:(Ce==null?void 0:Ce.mode)==="cut"&&Ce.path===P.path,onClick:()=>{$e()||(M(P.path),P.kind==="dir"?_(P.path):S(P.path))},onRename:()=>H(P.path),onDelete:()=>L(P),onDragStart:Sn(P),onDragEnd:xn,onDragOver:en(P),onDrop:tt(P),...rt(P)},P.path)),_e&&B.push(...Pe(P.path,ge+1))}return B}function wl(){if(!pn)return[i.jsx("p",{className:"fsrow__pending",style:Da(0),children:"ищем…"},"search:wait")];if(pn.entries.length===0)return[i.jsx("p",{className:"fsrow__pending",style:Da(0),children:"ничего не найдено"},"search:empty")];const le=pn.entries.map(ge=>i.jsx(oj,{entry:ge,gitStatus:N.get(ge.path),onClick:()=>qt(ge)},ge.path));return pn.truncated&&le.push(i.jsxs("p",{className:"fsrow__pending",style:Da(0),children:["показаны первые ",pn.entries.length," — уточните запрос"]},"search:truncated")),le}return i.jsxs("aside",{className:(s?"sidepane sidepane--files sidepane--open":"sidepane sidepane--files")+(G?" sidepane--zoomed":""),"aria-label":"Файлы проекта",onKeyDown:hn,children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:le=>{O&&(le.target.closest("button")||O())},children:[i.jsx(pj,{}),i.jsx("span",{className:"sidepane__title",children:"Файлы"}),i.jsx("button",{className:"sidepane__btn",title:"Новый файл","aria-label":"Новый файл",onClick:()=>Gt("file"),children:i.jsx(dj,{})}),i.jsx("button",{className:"sidepane__btn",title:"Новый каталог","aria-label":"Новый каталог",onClick:()=>Gt("dir"),children:i.jsx(hj,{})}),i.jsx("button",{className:"sidepane__btn",title:"Перечитать дерево","aria-label":"Перечитать дерево",onClick:X,children:"↻"}),O&&i.jsx("button",{className:"sidepane__btn",title:G?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":G?"Свернуть панель файлов":"Развернуть панель файлов на весь экран","aria-pressed":G,onClick:O,children:i.jsx(Sc,{active:G})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель файлов",onClick:J,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(mj,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:Xt,spellCheck:!1,placeholder:"Поиск файлов и папок…","aria-label":"Поиск файлов и папок",onChange:le=>yn(le.target.value),onKeyDown:le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),Xt?yn(""):le.currentTarget.blur())}}),Xt&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>yn(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree"+(je===""?" fstree--drop-target":""),tabIndex:-1,onDragOver:et,onDrop:tn,onContextMenu:dn,onTouchStart:ft,onTouchMove:yt,onTouchEnd:Xe,onTouchCancel:Xe,children:$t?wl():Et}),i.jsx(mr,{result:h}),ce&&i.jsx(sr,{x:ce.x,y:ce.y,items:ct(),onClose:It})]})}function cj({entry:s,depth:l,open:r,active:c,selected:o,dirty:d,gitStatus:h,dragging:m,dropTarget:g,cut:b,onClick:_,onRename:S,onDelete:v,onDragStart:E,onDragEnd:T,onDragOver:C,onDrop:L,onContextMenu:X,onTouchStart:J,onTouchMove:G,onTouchEnd:O,onTouchCancel:Z}){const M="fsrow"+(c?" is-open":"")+(o&&!c?" is-selected":"")+(s.ignored?" fsrow--ignored":"")+(m?" fsrow--dragging":"")+(g?" fsrow--drop-target":"")+(b?" fsrow--cut":"");return i.jsxs("div",{className:M,style:Da(l),draggable:!0,onDragStart:E,onDragEnd:T,onDragOver:C,onDrop:L,onContextMenu:X,onTouchStart:J,onTouchMove:G,onTouchEnd:O,onTouchCancel:Z,children:[i.jsxs("button",{className:"fsrow__main",onClick:_,title:zy(s),children:[i.jsx("span",{className:"fsrow__icon"+If("fsrow__icon",h),children:s.kind==="dir"?i.jsx(qf,{open:r}):i.jsx(Gf,{})}),i.jsx("span",{className:"fsrow__name"+If("fsrow__name",h),children:s.name}),s.ignored&&i.jsx("span",{className:"fsrow__tag",title:"Игнорируется git (.gitignore)",children:"git-ignore"}),d&&i.jsx("span",{className:"fsrow__dot",title:"Есть несохранённые правки"})]}),i.jsx("button",{className:"fsrow__act",title:"Переименовать","aria-label":`Переименовать ${s.name}`,onClick:S,children:"✎"}),i.jsx("button",{className:"fsrow__act",title:"Удалить","aria-label":`Удалить ${s.name}`,onClick:v,children:"✕"})]})}function oj({entry:s,gitStatus:l,onClick:r}){const c=s.path.slice(0,s.path.length-s.name.length-1);return i.jsxs("button",{className:"fsrow fsrow--search"+(s.ignored?" fsrow--ignored":""),style:Da(0),onClick:r,title:zy(s),children:[i.jsx("span",{className:"fsrow__icon"+If("fsrow__icon",l),children:s.kind==="dir"?i.jsx(qf,{}):i.jsx(Gf,{})}),i.jsx("span",{className:"fsrow__name"+If("fsrow__name",l),children:s.name}),s.ignored&&i.jsx("span",{className:"fsrow__tag",children:"git-ignore"}),c&&i.jsx("span",{className:"fsrow__path",children:c})]})}function zy(s){return s.ignored?`${s.path} — игнорируется git (.gitignore)`:s.path}function Da(s){return{"--depth":s}}function yx(s,l){var o;const r=l.lastIndexOf("/"),c=r===-1?"":l.slice(0,r);return((o=s[c])==null?void 0:o.find(d=>d.path===l))??null}function uj(s){const l=new Map,r={added:1,modified:2},c=(o,d)=>{const h=l.get(o);(!h||r[d]>r[h])&&l.set(o,d)};for(const o of s){const d=fj(o.status);if(!d)continue;c(o.path,d);let h=fr(o.path);for(;c(h,d),!!h;)h=fr(h)}return l}function fj(s){if(s==="??")return"added";const[l="",r=""]=s;return l==="A"||l==="R"||l==="C"?"added":l==="M"||r==="M"?"modified":null}function If(s,l){return l?` ${s}--git-${l}`:""}function qf({open:s=!1}){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,"aria-hidden":"true",children:s?i.jsx("path",{d:"M2 12.5V4.2a.7.7 0 0 1 .7-.7h3.1l1.5 1.6h4.4a.7.7 0 0 1 .7.7v1.2M2 12.5l1.7-4.6a.7.7 0 0 1 .66-.46h9.2a.5.5 0 0 1 .47.66L12.4 12.5Z"}):i.jsx("path",{d:"M2 12.4V4.2a.7.7 0 0 1 .7-.7h3.1l1.5 1.6h5.9a.7.7 0 0 1 .7.7v6.6a.7.7 0 0 1-.7.7H2.7a.7.7 0 0 1-.7-.7Z"})})}function Gf(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M9 2H4.4a.7.7 0 0 0-.7.7v10.6a.7.7 0 0 0 .7.7h7.2a.7.7 0 0 0 .7-.7V5.2Z"}),i.jsx("path",{d:"M9 2v3.2h3.3"})]})}function dj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,"aria-hidden":"true",children:[i.jsxs("g",{transform:"translate(-1.3,-1.6) scale(0.78)",strokeLinejoin:"round",children:[i.jsx("path",{d:"M9 2H4.4a.7.7 0 0 0-.7.7v10.6a.7.7 0 0 0 .7.7h7.2a.7.7 0 0 0 .7-.7V5.2Z"}),i.jsx("path",{d:"M9 2v3.2h3.3"})]}),i.jsx("path",{d:"M12.2 10.3v3.8M10.3 12.2h3.8",strokeLinecap:"round"})]})}function hj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,"aria-hidden":"true",children:[i.jsx("g",{transform:"translate(-1.3,-1.6) scale(0.78)",children:i.jsx("path",{d:"M2 12.4V4.2a.7.7 0 0 1 .7-.7h3.1l1.5 1.6h5.9a.7.7 0 0 1 .7.7v6.6a.7.7 0 0 1-.7.7H2.7a.7.7 0 0 1-.7-.7Z"})}),i.jsx("path",{d:"M12.2 10.3v3.8M10.3 12.2h3.8",strokeLinecap:"round"})]})}function pj(){return i.jsxs("svg",{className:"sidepane__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M2 4.1V3a.6.6 0 0 1 .6-.6h2.6l1.2 1.4h5a.6.6 0 0 1 .6.6v1.1"}),i.jsx("path",{d:"M2 12.6V5.7h11.4a.6.6 0 0 1 .58.75l-1.5 6.2a.6.6 0 0 1-.58.45H2.6a.6.6 0 0 1-.6-.5Z"})]})}function mj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}const gj=200;function bj({open:s,result:l,onSearch:r,onOpenMatch:c,onClose:o,zoomed:d,onToggleZoom:h}){const[m,g]=y.useState(""),b=m.trim(),_=b.length>0,S=y.useRef(null),v=y.useRef(r);v.current=r;function E(L){g(L),S.current&&clearTimeout(S.current);const X=L.trim();if(!X){v.current("");return}S.current=setTimeout(()=>v.current(X),gj)}const T=_&&(l==null?void 0:l.query)===b?l:null;function C(){if(!T)return[i.jsx("p",{className:"fsrow__pending",children:"ищем…"},"grep:wait")];if(T.matches.length===0)return[i.jsx("p",{className:"fsrow__pending",children:"ничего не найдено"},"grep:empty")];const L=[];let X="";for(const J of T.matches)J.path!==X&&(X=J.path,L.push(i.jsx("p",{className:"searchgroup__path",title:J.path,children:J.path},`path:${J.path}`))),L.push(i.jsx(xj,{match:J,onClick:()=>c(J)},`${J.path}:${J.line}:${J.column}`));return T.truncated&&L.push(i.jsxs("p",{className:"fsrow__pending",children:["показаны первые ",T.matches.length," — уточните запрос"]},"grep:truncated")),L}return i.jsxs("aside",{className:(s?"sidepane sidepane--search sidepane--open":"sidepane sidepane--search")+(d?" sidepane--zoomed":""),"aria-label":"Поиск по тексту в проекте",children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:L=>{h&&(L.target.closest("button")||h())},children:[i.jsx(yj,{}),i.jsx("span",{className:"sidepane__title",children:"Поиск по тексту"}),h&&i.jsx("button",{className:"sidepane__btn",title:d?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":d?"Свернуть панель поиска":"Развернуть панель поиска на весь экран","aria-pressed":d,onClick:h,children:i.jsx(Sc,{active:d})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель поиска",onClick:o,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(_j,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:m,spellCheck:!1,placeholder:"Поиск по тексту во всех файлах…","aria-label":"Поиск по тексту во всех файлах",onChange:L=>E(L.target.value),onKeyDown:L=>{L.stopPropagation(),L.key==="Escape"&&(L.preventDefault(),m?E(""):L.currentTarget.blur())}}),m&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>E(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree",children:_?C():i.jsx("p",{className:"sidepane__empty",children:"Введите текст, чтобы найти его во всех файлах проекта."})})]})}function xj({match:s,onClick:l}){const r=s.lineText.slice(0,s.column-1),c=s.lineText.slice(s.column-1,s.column-1+s.matchLength),o=s.lineText.slice(s.column-1+s.matchLength);return i.jsxs("button",{className:"searchmatch",onClick:l,title:`${s.path}:${s.line}`,children:[i.jsx("span",{className:"searchmatch__line",children:s.line}),i.jsxs("span",{className:"searchmatch__text",children:[r,i.jsx("mark",{children:c}),o]})]})}function yj(){return i.jsxs("svg",{className:"sidepane__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"6.8",cy:"6.8",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1"})]})}function _j(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}let bf=null;function vj(){return bf||(bf=Promise.all([Ke(()=>import("./index-B3ZG7Mgh.js"),__vite__mapDeps([19,4,3,2,20,5]),import.meta.url),Ke(()=>import("./index-891wE-Rj.js").then(s=>s.v),__vite__mapDeps([4,3]),import.meta.url),Ke(()=>import("./index-BHot-lnj.js"),[],import.meta.url),Ke(()=>import("./index-B3KPQ0Jq.js"),__vite__mapDeps([20,3,4,2]),import.meta.url),Ke(()=>import("./codemirror-XwUmM20V.js"),__vite__mapDeps([21,2,3,4]),import.meta.url)]).then(([s,l,r,c,o])=>({EditorView:l.EditorView,EditorState:r.EditorState,Compartment:r.Compartment,EditorSelection:r.EditorSelection,Prec:r.Prec,keymap:l.keymap,indentWithTab:c.indentWithTab,basicSetup:s.basicSetup,editorTheme:o.editorTheme,editorHighlight:o.editorHighlight})).catch(s=>{throw bf=null,s})),bf}function jj({path:s,doc:l,revision:r,goto:c,onChange:o,onSave:d}){const h=y.useRef(null),m=y.useRef(null),g=y.useRef(null),b=y.useRef(new Map),_=y.useRef(new Map),S=y.useRef(new Set),v=y.useRef(null),E=y.useRef(o),T=y.useRef(d),C=y.useRef(s),L=y.useRef(r),X=y.useRef(l);E.current=o,T.current=d,C.current=s,L.current=r,X.current=l;const[J,G]=y.useState("loading"),[O,Z]=y.useState(!1);function M(H,ne,he,W,ue){const je=b.current.get(W),Me=_.current.get(W)===ue;if(je&&Me)he.setState(je);else{const A=H.EditorState.create({doc:X.current,extensions:[H.basicSetup,H.Prec.highest(H.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(T.current(C.current),!0)}])),H.keymap.of([H.indentWithTab]),ne.of([]),H.editorTheme,H.editorHighlight,H.EditorView.updateListener.of(ce=>{ce.docChanged&&E.current(C.current,ce.state.doc.toString())})]});b.current.set(W,A),_.current.set(W,ue),he.setState(A),S.current.delete(W)}if(S.current.has(W))return()=>{};let Ce=!1;return P1(W).then(A=>{Ce||!A||C.current!==W||(he.dispatch({effects:ne.reconfigure(A)}),b.current.set(W,he.state),S.current.add(W))}),()=>{Ce=!0}}y.useEffect(()=>{if(!h.current)return;let ne=!1,he=null,W=null;G("loading"),Z(!1);const ue=window.setTimeout(()=>{ne||Z(!0)},200);return(async()=>{let je;try{je=await vj()}catch{window.clearTimeout(ue),ne||G("error");return}if(ne||!h.current)return;window.clearTimeout(ue);const Me=new je.Compartment;v.current=Me,g.current=je,W=new je.EditorView({parent:h.current}),m.current=W,he=M(je,Me,W,C.current,L.current),G("ready")})(),()=>{ne=!0,window.clearTimeout(ue),he==null||he(),W==null||W.destroy(),m.current===W&&(m.current=null),g.current=null,v.current=null}},[]),y.useEffect(()=>{const H=g.current,ne=m.current,he=v.current;if(!(!H||!ne||!he))return M(H,he,ne,s,r)},[s,r]);const D=y.useRef(0);return y.useEffect(()=>{const H=m.current,ne=g.current;if(!H||!ne||!c||c.token===D.current)return;D.current=c.token;const he=H.state.doc.lines,W=Math.min(Math.max(c.line,1),he),ue=H.state.doc.line(W),je=Math.min(ue.from+Math.max(c.column-1,0),ue.to);H.dispatch({selection:ne.EditorSelection.cursor(je),effects:ne.EditorView.scrollIntoView(je,{y:"center"})}),H.focus()},[c]),y.useEffect(()=>()=>{const H=m.current;H&&b.current.set(s,H.state)},[s]),i.jsxs("div",{className:"editor__code",children:[i.jsx("div",{ref:h,className:"editor__code-surface"+(J==="ready"?"":" is-hidden")}),J==="loading"&&O&&i.jsxs("div",{className:"editor__state work",role:"status",children:[i.jsxs("div",{className:"work__dots",children:[i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"})]}),i.jsx("span",{className:"work__label",children:"Загружается редактор…"})]}),J==="error"&&i.jsxs("div",{className:"editor__fallback",children:[i.jsxs("div",{className:"editor__fallback-banner",role:"alert",children:[i.jsx("span",{children:"Редактор не загрузился — ниже только просмотр, без сохранения правок."}),i.jsx("button",{className:"btn btn--sm btn--primary",onClick:()=>window.location.reload(),children:"Перезагрузить страницу"})]}),i.jsx("pre",{className:"editor__fallback-text",children:l})]})]})}function Cs({value:s,options:l,onChange:r,className:c,title:o,ariaLabel:d,placeholder:h="—"}){const[m,g]=y.useState(!1),[b,_]=y.useState(0),S=y.useRef(null),v=y.useRef(null),E=l.find(L=>L.value===s)??null;y.useEffect(()=>{if(!m)return;const L=l.findIndex(X=>X.value===s);_(L===-1?0:L)},[m]),y.useEffect(()=>{if(!m)return;function L(X){var J;(J=S.current)!=null&&J.contains(X.target)||g(!1)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[m]),y.useEffect(()=>{var L,X;m&&((X=(L=v.current)==null?void 0:L.querySelector(".is-cursor"))==null||X.scrollIntoView({block:"nearest"}))},[m,b]),y.useEffect(()=>{if(!m)return;const L=v.current,X=Sj(S.current);if(!L||!X)return;const J=L.getBoundingClientRect().bottom-X.getBoundingClientRect().bottom;J>0&&(X.scrollTop+=Math.min(J+8,L.offsetHeight))},[m]);function T(L){g(!1),L.value!==s&&r(L.value)}function C(L){if(L.key==="Escape"){if(!m)return;L.preventDefault(),L.stopPropagation(),g(!1);return}if(L.key==="ArrowDown"||L.key==="ArrowUp"){if(L.preventDefault(),!m)return g(!0);const X=L.key==="ArrowDown"?1:l.length-1;return _(J=>(J+X)%l.length)}if(L.key==="Enter"||L.key===" "){if(L.preventDefault(),!m)return g(!0);const X=l[b];X&&T(X)}}return i.jsxs("div",{ref:S,className:"select"+(m?" select--open":"")+(c?` ${c}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:o,"aria-label":d??o,"aria-haspopup":"listbox","aria-expanded":m,onClick:()=>g(L=>!L),onKeyDown:C,children:[i.jsx("span",{className:"select__value",children:(E==null?void 0:E.label)??h}),i.jsx(wj,{})]}),m&&i.jsx("div",{ref:v,className:"select__menu",role:"listbox","aria-label":d??o,children:l.map((L,X)=>i.jsxs("button",{type:"button",role:"option","aria-selected":L.value===s,className:"select__option"+(X===b?" is-cursor":"")+(L.value===s?" is-on":""),onMouseEnter:()=>_(X),onClick:()=>T(L),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:L.value===s?"✓":""}),i.jsx("span",{className:"select__label",children:L.label}),L.hint&&i.jsx("span",{className:"select__hint",children:L.hint})]},L.value))})]})}function Sj(s){let l=(s==null?void 0:s.parentElement)??null;for(;l;){if(l.scrollHeight>l.clientHeight&&getComputedStyle(l).overflowY!=="visible")return l;l=l.parentElement}return null}function wj(){return i.jsx("svg",{className:"select__chev",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M3 4.5 6 7.5 9 4.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function kj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"6.6",cy:"6.6",r:"4.3"}),i.jsx("path",{d:"M9.7 9.7 14 14"}),i.jsx("path",{d:"M6.6 4.6v4M4.6 6.6h4"})]})}function Nj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"6.6",cy:"6.6",r:"4.3"}),i.jsx("path",{d:"M9.7 9.7 14 14"}),i.jsx("path",{d:"M4.6 6.6h4"})]})}function Tj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M13 8a5 5 0 1 1-1.6-3.7"}),i.jsx("path",{d:"M13 2.5v3.3h-3.3"})]})}function Ej({path:s,mime:l,base64:r,error:c,tooLarge:o,size:d,onRequestMedia:h}){y.useEffect(()=>{!o&&r===void 0&&c===void 0&&h(s)},[]);const m=Cj(r,l);return o?i.jsx("div",{className:"mediaview mediaview--message",children:i.jsxs("p",{className:"mediaview__error",children:["Файл слишком велик для просмотра (",Of(d),"). Лимит — 64 МБ."]})}):c?i.jsxs("div",{className:"mediaview mediaview--message",role:"alert",children:[i.jsx("p",{className:"mediaview__error",children:c}),i.jsx("button",{className:"btn btn--sm btn--primary",onClick:()=>h(s),children:"Повторить"})]}):m?l.startsWith("image/")?i.jsx(Mj,{url:m}):l.startsWith("video/")?i.jsx(Dj,{url:m}):null:i.jsxs("div",{className:"mediaview mediaview--message",role:"status",children:[i.jsx("div",{className:"mediaview__progress",children:i.jsx("div",{className:"mediaview__progress-fill"})}),i.jsx("span",{className:"mediaview__label",children:"Загружается…"})]})}function Cj(s,l){const[r,c]=y.useState(null);return y.useEffect(()=>{if(s===void 0){c(null);return}const o=atob(s),d=new Uint8Array(o.length);for(let m=0;m<o.length;m++)d[m]=o.charCodeAt(m);const h=URL.createObjectURL(new Blob([d],{type:l}));return c(h),()=>URL.revokeObjectURL(h)},[s,l]),r}const Ni=1,Uy=8,xf=1.25;function Aj(s){return Math.min(Uy,Math.max(Ni,s))}function Mj({url:s}){const[l,r]=y.useState({scale:Ni,x:0,y:0}),[c,o]=y.useState(!1),d=y.useRef(null),h=y.useRef(null);function m(E,T,C){r(L=>{const X=Aj(L.scale*E);if(X===L.scale)return L;if(X<=Ni)return{scale:Ni,x:0,y:0};const J=(T-L.x)/L.scale,G=(C-L.y)/L.scale;return{scale:X,x:T-X*J,y:C-X*G}})}y.useEffect(()=>{const E=d.current;if(!E)return;function T(C){C.preventDefault();const L=E.getBoundingClientRect(),X=C.clientX-L.left-L.width/2,J=C.clientY-L.top-L.height/2;m(C.deltaY<0?xf:1/xf,X,J)}return E.addEventListener("wheel",T,{passive:!1}),()=>E.removeEventListener("wheel",T)},[]);function g(E){l.scale<=Ni||(E.currentTarget.setPointerCapture(E.pointerId),h.current={pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,origX:l.x,origY:l.y},o(!0))}function b(E){const T=h.current;!T||T.pointerId!==E.pointerId||r(C=>({...C,x:T.origX+(E.clientX-T.startX),y:T.origY+(E.clientY-T.startY)}))}function _(){h.current=null,o(!1)}const S=l.scale>Ni,v=!S&&l.x===0&&l.y===0;return i.jsxs("div",{className:"mediaview mediaview--image",children:[i.jsx("div",{ref:d,className:"mediaview__stage"+(S?c?" is-dragging":" is-zoomed":""),onPointerDown:g,onPointerMove:b,onPointerUp:_,onPointerCancel:_,children:i.jsx("img",{src:s,alt:"",className:"mediaview__image",draggable:!1,style:{transform:`translate(${l.x}px, ${l.y}px) scale(${l.scale})`}})}),i.jsxs("div",{className:"mediaview__toolbar",children:[i.jsx("button",{className:"btn btn--sm",disabled:l.scale<=Ni,title:"Уменьшить","aria-label":"Уменьшить",onClick:()=>m(1/xf,0,0),children:i.jsx(Nj,{})}),i.jsxs("span",{className:"mediaview__zoomlabel",children:[Math.round(l.scale*100),"%"]}),i.jsx("button",{className:"btn btn--sm",disabled:l.scale>=Uy,title:"Увеличить","aria-label":"Увеличить",onClick:()=>m(xf,0,0),children:i.jsx(kj,{})}),i.jsx("button",{className:"btn btn--sm",disabled:v,title:"Вписать в окно","aria-label":"Сбросить масштаб — вписать в окно",onClick:()=>r({scale:Ni,x:0,y:0}),children:i.jsx(Tj,{})})]})]})}const Rj=[{value:"0.5",label:"0.5×"},{value:"0.75",label:"0.75×"},{value:"1",label:"1× — обычная"},{value:"1.25",label:"1.25×"},{value:"1.5",label:"1.5×"},{value:"2",label:"2×"}];function Dj({url:s}){const l=y.useRef(null),[r,c]=y.useState("1");return y.useEffect(()=>{l.current&&(l.current.playbackRate=Number(r))},[r]),i.jsxs("div",{className:"mediaview mediaview--video",children:[i.jsx("video",{ref:l,className:"mediaview__video",src:s,controls:!0}),i.jsxs("div",{className:"mediaview__speedbar",children:[i.jsx("span",{className:"mediaview__speedlabel",children:"Скорость"}),i.jsx(Cs,{className:"mediaview__speedselect",value:r,onChange:c,ariaLabel:"Скорость воспроизведения",options:Rj})]})]})}function Oj({file:s,goto:l,onChange:r,onSave:c,onReload:o,onOverwrite:d,onRequestMedia:h,onTogglePreview:m}){const g=Ra(s),b=Ly(s.path)&&!s.binary&&!s.tooLarge;return i.jsxs("div",{className:"editor",children:[i.jsxs("div",{className:"editor__bar",children:[i.jsx("span",{className:"editor__path",title:s.path,children:s.path}),i.jsxs("span",{className:"editor__meta",children:[Of(s.size),s.eol==="crlf"&&" · CRLF"]}),b&&i.jsxs("div",{className:"editor__viewtoggle",role:"tablist","aria-label":"Режим просмотра",children:[i.jsx("button",{className:"btn btn--sm"+(s.previewMode?" is-on":""),role:"tab","aria-selected":s.previewMode,onClick:()=>!s.previewMode&&m(s.path),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(s.previewMode?"":" is-on"),role:"tab","aria-selected":!s.previewMode,onClick:()=>s.previewMode&&m(s.path),children:"Код"})]}),i.jsx("button",{className:"btn btn--sm",disabled:!g,title:"Сохранить (Ctrl+S)",onClick:()=>c(s.path),children:g?"Сохранить":"Сохранено"})]}),s.stale&&i.jsxs("div",{className:"editor__warn",children:[i.jsxs("span",{children:["Файл изменился на диске",g?" — а здесь есть несохранённые правки.":"."]}),i.jsx("button",{className:"btn btn--sm",onClick:()=>o(s.path),children:"Взять с диска"}),g&&i.jsx("button",{className:"btn btn--sm btn--danger",onClick:()=>d(s.path),children:"Сохранить поверх"})]}),s.binary&&s.mediaMime?i.jsx(Ej,{path:s.path,mime:s.mediaMime,base64:s.mediaBase64,error:s.mediaError,tooLarge:s.mediaTooLarge,size:s.size,onRequestMedia:h},s.path):s.binary?i.jsxs("p",{className:"editor__empty",children:["Это не текстовый файл — редактировать его здесь нечем. ",Of(s.size)," на диске."]}):s.tooLarge?i.jsxs("p",{className:"editor__empty",children:["Файл слишком велик для редактора (",Of(s.size),"). Такие правит агент, а не браузер."]}):b&&s.previewMode?i.jsx(Lj,{text:s.text}):i.jsx(jj,{path:s.path,doc:s.text,revision:s.revision,goto:l,onChange:r,onSave:c})]})}function Lj({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return Qf(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:l}})}function zj({files:s,activePath:l,busy:r,onSelect:c,onClose:o,zoomed:d,onToggleZoom:h}){return i.jsxs("div",{className:"worktabs",role:"tablist",onDoubleClick:m=>{h&&(m.target.closest("button")||h())},children:[i.jsxs("button",{className:"worktab"+(l===null?" is-on":""),role:"tab","aria-selected":l===null,onClick:()=>c(null),onDoubleClick:()=>h==null?void 0:h(),children:[i.jsx("span",{className:"worktab__name",children:"Разговор"}),r&&i.jsx("span",{className:"worktab__dot worktab__dot--busy",title:"Агент работает"})]}),s.map(m=>i.jsxs("div",{className:"worktab"+(m.path===l?" is-on":""),role:"tab","aria-selected":m.path===l,onDoubleClick:g=>{h&&(g.target.closest(".worktab__close, .worktab__dot")||h())},children:[i.jsx("button",{className:"worktab__name",title:m.path,onClick:()=>c(m.path),children:nj(m.path)}),Ra(m)?i.jsx("button",{className:"worktab__dot",title:"Не сохранено — закрыть","aria-label":`Закрыть ${m.path}`,onClick:()=>o(m.path)}):i.jsx("button",{className:"worktab__close",title:"Закрыть","aria-label":`Закрыть ${m.path}`,onClick:()=>o(m.path),children:"✕"})]},m.path)),i.jsx("div",{className:"worktabs__spacer"}),h&&i.jsx("button",{className:"worktabs__zoom",title:d?"Свернуть — то же самое, что двойной клик по вкладке":"Развернуть на весь экран — то же самое, что двойной клик по вкладке","aria-label":d?"Свернуть колонку разговора":"Развернуть колонку разговора на весь экран","aria-pressed":d,onClick:h,children:i.jsx(Sc,{active:d})})]})}function os(s){return s.claudeSessionId??s.id}function yf(s,l,r,c){if(!l||l.length===0)return s;const o=new Map(l.map((m,g)=>[m,g])),d=[],h=[];for(const m of s)(o.has(r(m))?d:h).push(m);return d.sort((m,g)=>o.get(r(m))-o.get(r(g))),c==="top"?[...h,...d]:[...d,...h]}function _x(s){return s.state!=="closed"}function vx(s){return[...s.filter(_x),...s.filter(l=>!_x(l))]}function _f(s,l,r,c){if(l===r||!s.includes(l)||!s.includes(r))return null;const o=s.filter(m=>m!==l),d=o.indexOf(r)+(c==="after"?1:0),h=[...o.slice(0,d),l,...o.slice(d)];return h.every((m,g)=>m===s[g])?null:h}function Ap(s,l,r,c){const o=s%10,d=s%100;return o===1&&d!==11?l:o>=2&&o<=4&&(d<12||d>14)?r:c}function Hy(s){return`${s} ${Ap(s,"агент","агента","агентов")}`}function Uj(s){const l=s.filter(o=>o.kind==="agent").length,r=s.length-l,c=[];return l>0&&c.push(Hy(l)),r>0&&c.push(`${r} ${Ap(r,"задача","задачи","задач")} в фоне`),c.join(" · ")}function Hj(s){switch(s.kind){case"agent":return s.agentType??"агент";case"shell":return"команда";case"workflow":return"сценарий";default:return"задача"}}function Bj(s){const l=Math.max(0,Math.floor(s/1e3)),r=Math.floor(l/3600),c=Math.floor(l%3600/60),o=l%60,d=String(o).padStart(2,"0");return r>0?`${r}:${String(c).padStart(2,"0")}:${d}`:`${c}:${d}`}function Ij(s){return s<1e3?`${s} ток.`:`${(s/1e3).toFixed(1).replace(".",",")} k ток.`}function qj({tasks:s,onStop:l}){const[r,c]=y.useState(!1),[o,d]=y.useState(()=>Date.now()),[h,m]=y.useState(()=>new Set);y.useEffect(()=>{const b=window.setInterval(()=>d(Date.now()),1e3);return()=>window.clearInterval(b)},[]),y.useEffect(()=>{m(b=>{const _=new Set(s.map(v=>v.id)),S=new Set([...b].filter(v=>_.has(v)));return S.size===b.size?b:S})},[s]);const g=b=>{m(_=>new Set(_).add(b)),l(b),window.setTimeout(()=>{m(_=>{if(!_.has(b))return _;const S=new Set(_);return S.delete(b),S})},1e4)};return i.jsxs("div",{className:r?"tasks is-open":"tasks",children:[i.jsxs("button",{type:"button",className:"tasks__toggle","aria-expanded":r,"aria-controls":"tasks-list",onClick:()=>c(b=>!b),children:[i.jsx("span",{className:"tasks__dot","aria-hidden":"true"}),i.jsx("span",{className:"tasks__summary",children:Uj(s)}),i.jsx("svg",{className:"tasks__chev",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4 6.5l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),r&&i.jsx("ul",{className:"tasks__list",id:"tasks-list",children:s.map(b=>{const _=h.has(b.id);return i.jsxs("li",{className:_?"task is-stopping":"task",children:[i.jsxs("div",{className:"task__main",children:[i.jsxs("div",{className:"task__head",children:[i.jsx("span",{className:"task__kind",children:Hj(b)}),b.background&&i.jsx("span",{className:"task__bg",children:"фон"}),i.jsx("span",{className:"task__time",children:Bj(o-b.startedAt)})]}),i.jsx("div",{className:"task__desc",title:b.description,children:b.description}),(b.activity||b.lastTool)&&i.jsx("div",{className:"task__activity",title:b.activity??b.lastTool??void 0,children:b.activity??b.lastTool}),i.jsxs("div",{className:"task__stats",children:[Ij(b.tokens)," · ",b.toolUses," ",Ap(b.toolUses,"вызов","вызова","вызовов")]})]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--danger task__stop",disabled:_,"aria-label":`Остановить: ${b.description}`,onClick:()=>g(b.id),children:_?"Останавливается":"Стоп"})]},b.id)})})]})}const Gj=""+new URL("antigravity-logo-DRKQga2U.png",import.meta.url).href;function By({className:s}){return i.jsx("img",{src:Gj,alt:"","aria-hidden":"true",className:s,style:{aspectRatio:"200 / 184"}})}const Yj=450,Xj=6,vf=[{id:"claude",label:"Claude",hint:"Claude Code — как обычно"},{id:"antigravity",label:"Antigravity",hint:"Google agy, отдельная палитра и права"}];function $j({disabled:s,onStart:l}){const[r,c]=y.useState(!1),[o,d]=y.useState(0),[h,m]=y.useState({left:0,top:0}),g=y.useRef(null),b=y.useRef(null),_=y.useRef(null);function S(){_.current&&window.clearTimeout(_.current.timer),_.current=null}function v(){S(),d(0),c(!0)}function E(M){var D;c(!1),M&&((D=g.current)==null||D.focus())}function T(M){if(s||M.button!==0)return;const D={timer:0,x:M.clientX,y:M.clientY,fired:!1};D.timer=window.setTimeout(()=>{D.fired=!0,v()},Yj),_.current=D}function C(M){const D=_.current;!D||D.fired||Math.hypot(M.clientX-D.x,M.clientY-D.y)>Xj&&S()}function L(){_.current&&!_.current.fired&&S()}function X(M){var D;if((D=_.current)!=null&&D.fired){_.current=null,M.preventDefault();return}s||l("claude")}function J(M){M.preventDefault(),!s&&v()}function G(M){if(s)return;(M.key==="ArrowDown"||M.key==="ArrowUp"||M.key==="Enter"&&M.shiftKey)&&(M.preventDefault(),v())}y.useLayoutEffect(()=>{if(!r)return;const M=g.current,D=b.current;if(!M||!D)return;const H=M.getBoundingClientRect(),ne=D.getBoundingClientRect(),he=8,W=Math.max(he,Math.min(H.right-ne.width,window.innerWidth-ne.width-he));let ue=H.top-ne.height-8;ue<he&&(ue=Math.min(H.bottom+8,window.innerHeight-ne.height-he)),m({left:W,top:ue})},[r]),y.useLayoutEffect(()=>{var M;r&&((M=b.current)==null||M.focus())},[r]),y.useLayoutEffect(()=>{if(!r)return;function M(D){var ne,he;const H=D.target;!((ne=b.current)!=null&&ne.contains(H))&&!((he=g.current)!=null&&he.contains(H))&&E(!1)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[r]);function O(M){E(!1),l(M.id)}function Z(M){if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),E(!0);return}if(M.key==="ArrowDown"||M.key==="ArrowUp"){M.preventDefault();const D=M.key==="ArrowDown"?1:-1;d(H=>(H+D+vf.length)%vf.length);return}if(M.key==="Enter"||M.key===" "){M.preventDefault();const D=vf[o];D&&O(D);return}M.key==="Tab"&&E(!1)}return i.jsxs("div",{className:"newsession",children:[i.jsxs("button",{ref:g,type:"button",className:"btn btn--primary newsession__btn",disabled:s,title:"Удерживайте, чтобы выбрать агента","aria-haspopup":"menu","aria-expanded":r,onClick:X,onContextMenu:J,onPointerDown:T,onPointerMove:C,onPointerUp:L,onPointerCancel:L,onPointerLeave:L,onKeyDown:G,children:["+ Сессия",i.jsx(Vj,{})]}),r&&i.jsx("div",{ref:b,className:"newsession__menu",style:{left:h.left,top:h.top},role:"menu","aria-label":"Выбрать агента для новой сессии",tabIndex:-1,onKeyDown:Z,children:vf.map((M,D)=>i.jsxs("button",{type:"button",role:"menuitem",className:"newsession__item"+(D===o?" is-cursor":""),onMouseEnter:()=>d(D),onClick:()=>O(M),children:[i.jsx("span",{className:`newsession__mark newsession__mark--${M.id}`,"aria-hidden":"true",children:M.id==="antigravity"?i.jsx(By,{className:"newsession__mark-logo"}):i.jsx(Qj,{})}),i.jsxs("span",{className:"newsession__text",children:[i.jsx("span",{className:"newsession__label",children:M.label}),i.jsx("span",{className:"newsession__hint",children:M.hint})]})]},M.id))})]})}function Vj(){return i.jsx("svg",{className:"newsession__caret",viewBox:"0 0 10 6",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M1 1.2 5 5 9 1.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qj(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"var(--accent)"})})}const Iy="ccv:sidebar.collapsed",qy="ccv:sidebar.mode",Gy="ccv:sidebar.foldersCollapsed",Kj=500,$h="транскрипт остаётся на диске — сессию можно вернуть из архива в любой момент.";function Zj({open:s,connected:l,status:r,workspaces:c,archivedWorkspaces:o,workspaceFolders:d,sessionFolders:h,pinnedFolders:m,sessions:g,archived:b,pinned:_,live:S,listOrder:v,liveSessionsFirst:E,onReorder:T,activeWorkspaceId:C,activeSessionId:L,onSelectWorkspace:X,onSelectSession:J,onRenameSession:G,onStopSession:O,onPinSessions:Z,onSelectPinned:M,onCloseWorkspaces:D,onRestoreWorkspaces:H,onArchiveSessions:ne,onUnarchiveSessions:he,onCreateFolder:W,onRenameFolder:ue,onDeleteFolder:je,onAssignToFolder:Me,onOpenWorkspace:Ce,onNewSession:A,onOpenExtensions:ce,account:z,onOpenAccount:be,relay:ye,onOpenRelay:N,onOpenSettings:V,themeMode:re,onCycleTheme:me}){var dt;const[Ne,ve]=y.useState(null),[De,yt]=y.useState(null),[Xe,$e]=y.useState(null),[Ve,It]=y.useState(""),[rt,dn]=y.useState(oS),[ft,hn]=y.useState(uS),[Sn,xn]=y.useState(fS);function en(w){xn(w);try{localStorage.setItem(qy,w)}catch{}}const tt=Ve.trim().toLowerCase(),et=tt!=="",tn=y.useMemo(()=>yf(c,v==null?void 0:v.workspaces,w=>w.id,"bottom"),[c,v]),Xt=y.useMemo(()=>{const w=yf(g,C?v==null?void 0:v.sessions[C]:void 0,os,"top");return E?vx(w):w},[g,v,C,E]),nt=y.useMemo(()=>{const w=yf(_,v==null?void 0:v.pinned,os,"bottom");return E?vx(w):w},[_,v,E]),St=y.useMemo(()=>yf(S,v==null?void 0:v.live,os,"bottom"),[S,v]),$t=y.useMemo(()=>et?tn.filter(w=>w.name.toLowerCase().includes(tt)||w.path.toLowerCase().includes(tt)):tn,[tn,tt,et]),cn=y.useMemo(()=>et?o.filter(w=>w.name.toLowerCase().includes(tt)||w.path.toLowerCase().includes(tt)):o,[o,tt,et]),wt=y.useMemo(()=>et?Xt.filter(w=>(w.title??"").toLowerCase().includes(tt)):Xt,[Xt,tt,et]),yn=y.useMemo(()=>et?b.filter(w=>(w.title??"").toLowerCase().includes(tt)):b,[b,tt,et]),qt=w=>{var se;return((se=c.find(ke=>ke.id===w))==null?void 0:se.name)??"—"},pn=w=>{var se;return(se=c.find(ke=>ke.id===w))==null?void 0:se.path},Dn=y.useMemo(()=>et?nt.filter(w=>(w.title??"").toLowerCase().includes(tt)||qt(w.workspaceId).toLowerCase().includes(tt)):nt,[nt,c,tt,et]),Gt=y.useMemo(()=>et?St.filter(w=>(w.title??"").toLowerCase().includes(tt)||qt(w.workspaceId).toLowerCase().includes(tt)):St,[St,c,tt,et]),ct=!et;function Et(w){dn(se=>{const ke=se.includes(w)?se.filter(Je=>Je!==w):[...se,w];try{localStorage.setItem(Iy,JSON.stringify(ke))}catch{}return ke})}const Pe=w=>!rt.includes(w);function wl(w){hn(se=>{const ke=se.includes(w)?se.filter(Je=>Je!==w):[...se,w];try{localStorage.setItem(Gy,JSON.stringify(ke))}catch{}return ke})}const le=w=>!ft.includes(w),ge=y.useMemo(()=>Ro($t,d),[$t,d]),He=y.useMemo(()=>Ro(cn,d),[cn,d]),B=y.useMemo(()=>Ro(wt,h),[wt,h]),P=y.useMemo(()=>Ro(yn,h),[yn,h]),_e=y.useMemo(()=>Ro(Dn,m,w=>w.pinnedFolderId),[Dn,m]),Be=y.useMemo(()=>({groups:[],ungrouped:Gt}),[Gt]),Ot=((v==null?void 0:v.workspaces.length)??0)>0,fl=C?(((dt=v==null?void 0:v.sessions[C])==null?void 0:dt.length)??0)>0:!1,On=((v==null?void 0:v.pinned.length)??0)>0,dl=((v==null?void 0:v.live.length)??0)>0,sl=jf({enabled:ct,scope:"workspaces",itemKey:w=>w.id,groups:ge.groups,ungrouped:ge.ungrouped,onReorder:T}),Bl=jf({enabled:ct,scope:"sessions",workspaceId:C??void 0,itemKey:os,groups:B.groups,ungrouped:B.ungrouped,onReorder:T}),ds=jf({enabled:ct,scope:"pinned",itemKey:os,groups:_e.groups,ungrouped:_e.ungrouped,onReorder:T}),hl=jf({enabled:ct,scope:"live",itemKey:os,groups:Be.groups,ungrouped:Be.ungrouped,onReorder:T}),al=Qh($t),pl=Qh(cn),Yt=Qh(wt),[Vt,kl]=y.useState(null),[kt,Qt]=y.useState(null),[Oe,Ct]=y.useState(null),[qn,nn]=y.useState(null),[Ln,il]=y.useState(null),wn=y.useRef(null);function Il(w,se){const ke=w.touches[0];if(!ke)return;const Je={timer:0,x:ke.clientX,y:ke.clientY,el:w.currentTarget,fired:!1};Je.timer=window.setTimeout(()=>{Je.fired=!0,se(Je.x,Je.y,Je.el)},Kj),wn.current=Je}function rl(w){const se=wn.current,ke=w.touches[0];!se||!ke||Math.hypot(ke.clientX-se.x,ke.clientY-se.y)>10&&(window.clearTimeout(se.timer),wn.current=null)}function ln(w){const se=wn.current;se&&(window.clearTimeout(se.timer),se.fired&&w.preventDefault())}function Kt(){var w;return(w=wn.current)!=null&&w.fired?(wn.current=null,!0):!1}function on(){const w=Vt==null?void 0:Vt.opener;kl(null),w!=null&&w.isConnected&&w.focus()}function Fe(){const w=kt==null?void 0:kt.opener;Qt(null),w!=null&&w.isConnected&&w.focus()}function ml(){const w=Oe==null?void 0:Oe.opener;Ct(null),w!=null&&w.isConnected&&w.focus()}function Ms(){const w=qn==null?void 0:qn.opener;nn(null),w!=null&&w.isConnected&&w.focus()}function Gn(){const w=Ln==null?void 0:Ln.opener;il(null),w!=null&&w.isConnected&&w.focus()}function Zl(w){return{onContextMenu:se=>{se.preventDefault(),kl({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:al.targetsFor(w)})},onTouchStart:se=>Il(se,(ke,Je,ht)=>kl({x:ke,y:Je,opener:ht,ids:al.targetsFor(w)})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function hs(w){return{onContextMenu:se=>{se.preventDefault(),Qt({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:pl.targetsFor(w)})},onTouchStart:se=>Il(se,(ke,Je,ht)=>Qt({x:ke,y:Je,opener:ht,ids:pl.targetsFor(w)})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function ps(w){return{onContextMenu:se=>{se.preventDefault(),Ct({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:Yt.targetsFor(w)})},onTouchStart:se=>Il(se,(ke,Je,ht)=>Ct({x:ke,y:Je,opener:ht,ids:Yt.targetsFor(w)})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function mn(w){return{onContextMenu:se=>{se.preventDefault(),nn({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:[w.id]})},onTouchStart:se=>Il(se,(ke,Je,ht)=>nn({x:ke,y:Je,opener:ht,ids:[w.id]})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function Fl(w){return{onContextMenu:se=>{se.preventDefault(),il({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:[w.id]})},onTouchStart:se=>Il(se,(ke,Je,ht)=>il({x:ke,y:Je,opener:ht,ids:[w.id]})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}const Zn=g.filter(w=>w.state!=="closed").length,zn=Vt?$t.find(w=>w.id===Vt.ids[0]):void 0,kn=Vt?[{id:"close",label:Vt.ids.length>1?`Закрыть проекты (${Vt.ids.length})`:"Закрыть проект",onSelect:()=>{D(Vt.ids),al.clear()}},...Do({folders:d,ids:Vt.ids,hasFolder:(zn==null?void 0:zn.folderId)!=null,assign:(w,se)=>Me("workspace",w,se),onClear:()=>al.clear(),onNewFolder:()=>$e("workspace")}),...Vt.ids.length===1&&ct?sl.menuItems(Vt.ids[0],Ot):[]]:[],Lt=Vt?"закрытие не удаляет проект: каталог и история сессий остаются на диске — открыть его снова можно кнопкой «+ Проект»."+(C&&Vt.ids.includes(C)&&Zn>0?` в нём сейчас незавершённых сессий: ${Zn} — при закрытии они остановятся на хосте.`:""):void 0,Rs=kt?cn.find(w=>w.id===kt.ids[0]):void 0,Di=kt?[{id:"restore",label:kt.ids.length>1?`Вернуть проекты (${kt.ids.length})`:"Вернуть проект",onSelect:()=>{H(kt.ids),pl.clear()}},...Do({folders:d,ids:kt.ids,hasFolder:(Rs==null?void 0:Rs.folderId)!=null,assign:(w,se)=>Me("workspace",w,se),onClear:()=>pl.clear(),onNewFolder:()=>$e("workspace")})]:[],Ds=kt?"каталог и история сессий всё это время оставались на диске — восстановление их не трогает.":void 0,Yn=Oe?wt.find(w=>w.id===Oe.ids[0]):void 0,Nl=(Yn==null?void 0:Yn.pinned)!==!0,La=Oe?[...Oe.ids.length===1?[{id:"rename",label:"Переименовать",onSelect:()=>ve(Oe.ids[0])}]:[],{id:"pin",label:Nl?Oe.ids.length>1?`Закрепить (${Oe.ids.length})`:"Закрепить":Oe.ids.length>1?`Открепить (${Oe.ids.length})`:"Открепить",onSelect:()=>{Yn&&Z(Yn.workspaceId,Oe.ids,Nl),Yt.clear()}},{id:"archive",label:Oe.ids.length>1?`Убрать в архив (${Oe.ids.length})`:"Убрать в архив",onSelect:()=>{ne(C,Oe.ids),Yt.clear()}},...Do({folders:h,ids:Oe.ids,hasFolder:(Yn==null?void 0:Yn.folderId)!=null,assign:(w,se)=>Me("session",w,se,C),onClear:()=>Yt.clear(),onNewFolder:()=>$e("session")}),...Oe.ids.length===1&&ct&&Yn?Bl.menuItems(os(Yn),fl):[]]:[],Nn=Oe?$h:void 0,sn=qn?Dn.find(w=>w.id===qn.ids[0]):void 0,Jl=qn?[{id:"rename",label:"Переименовать",onSelect:()=>ve(qn.ids[0])},{id:"unpin",label:"Открепить",onSelect:()=>{sn&&Z(sn.workspaceId,[sn.id],!1)}},{id:"archive",label:"Убрать в архив",onSelect:()=>{sn&&ne(sn.workspaceId,[sn.id])}},...sn&&sn.workspaceId===C?Do({folders:h,ids:[sn.id],hasFolder:sn.folderId!=null,assign:(w,se)=>Me("session",w,se,sn.workspaceId),onClear:()=>{},onNewFolder:()=>$e("session")}):[],...Pj(sn?Do({folders:m,ids:[sn.id],hasFolder:sn.pinnedFolderId!=null,assign:(w,se)=>Me("pinned",w,se),onClear:()=>{},onNewFolder:()=>$e("pinned")}):[]),...ct&&sn?ds.menuItems(os(sn),On):[]]:[],lt=Ln?Gt.find(w=>w.id===Ln.ids[0]):void 0,Xn=Ln?[{id:"stop",label:"Остановить",onSelect:()=>{lt&&O(lt)}},{id:"rename",label:"Переименовать",onSelect:()=>ve(Ln.ids[0])},{id:"pin",label:(lt==null?void 0:lt.pinned)===!0?"Открепить":"Закрепить",onSelect:()=>{lt&&Z(lt.workspaceId,[lt.id],lt.pinned!==!0)}},{id:"archive",label:"Убрать в архив",onSelect:()=>{lt&&ne(lt.workspaceId,[lt.id])}},...ct&<?hl.menuItems(os(lt),dl):[]]:[];function pe(w){return i.jsxs("div",{"data-row-key":w.id,className:lc(w.id===C,al.selected.includes(w.id))+sl.dropClass(w.id),...Zl(w),children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить проект, чтобы изменить порядок в списке",...sl.gripHandlers(w.id),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:se=>{Kt()||al.click(se,w,()=>X(w.id))},onKeyDown:se=>sl.onKeyDown(w.id,se),children:[i.jsxs("span",{className:"row__title",children:[w.name,w.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",title:w.path,children:w.path})]})]},w.id)}function k(w){return i.jsxs("div",{className:lc(w.id===C,pl.selected.includes(w.id)),...hs(w),children:[i.jsxs("button",{className:"row__main",onClick:se=>{Kt()||pl.click(se,w,()=>X(w.id))},children:[i.jsxs("span",{className:"row__title",children:[w.name,w.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",children:yS(w)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть проект из архива",onClick:()=>H([w.id]),children:"Вернуть"})]},w.id)}function Y(w){const se=os(w);return i.jsx("div",{"data-row-key":se,className:lc(w.id===L,Yt.selected.includes(w.id),w.provider==="antigravity")+Bl.dropClass(se),...Ne===w.id?{}:ps(w),children:Ne===w.id?i.jsx("div",{className:"row__main",children:i.jsx(na,{value:w.title??"",onCommit:ke=>{G(w,ke),ve(null)},onCancel:()=>ve(null)})}):i.jsxs(i.Fragment,{children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить сессию, чтобы изменить порядок в списке",...Bl.gripHandlers(se),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:ke=>{Kt()||Yt.click(ke,w,()=>J(w))},onKeyDown:ke=>Bl.onKeyDown(se,ke),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:w.pinned===!0,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx(Kh,{session:w,tail:new Date(w.updatedAt).toLocaleString()})]}),i.jsx("button",{className:"row__edit",title:"Переименовать","aria-label":"Переименовать сессию",onClick:()=>{Kt()||ve(w.id)},children:"✎"})]})},w.id)}function fe(w){return i.jsxs("div",{className:lc(w.id===L,!1,w.provider==="antigravity"),children:[i.jsxs("button",{className:"row__main",onClick:()=>J(w),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:!1,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx("span",{className:"row__meta",children:xS(w)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть сессию из архива",onClick:()=>he([w.id]),children:"Вернуть"})]},w.id)}function we(w){const se=os(w);return i.jsx("div",{"data-row-key":se,className:lc(w.id===L,!1,w.provider==="antigravity")+ds.dropClass(se),...Ne===w.id?{}:{title:"Действия со строкой — правый клик или долгое нажатие",...mn(w)},children:Ne===w.id?i.jsx("div",{className:"row__main",children:i.jsx(na,{value:w.title??"",onCommit:ke=>{G(w,ke),ve(null)},onCancel:()=>ve(null)})}):i.jsxs(i.Fragment,{children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить сессию, чтобы изменить порядок в списке",...ds.gripHandlers(se),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:()=>{Kt()||M(w)},onKeyDown:ke=>ds.onKeyDown(se,ke),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:!1,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx(Kh,{session:w,tail:new Date(w.updatedAt).toLocaleString()})]})]})},w.id)}function Ae(w){const se=os(w);return i.jsx("div",{"data-row-key":se,className:lc(w.id===L,!1,w.provider==="antigravity")+hl.dropClass(se),...Ne===w.id?{}:{title:"Действия со строкой — правый клик или долгое нажатие",...Fl(w)},children:Ne===w.id?i.jsx("div",{className:"row__main",children:i.jsx(na,{value:w.title??"",onCommit:ke=>{G(w,ke),ve(null)},onCancel:()=>ve(null)})}):i.jsxs(i.Fragment,{children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить сессию, чтобы изменить порядок в списке",...hl.gripHandlers(se),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:()=>{Kt()||M(w)},onKeyDown:ke=>hl.onKeyDown(se,ke),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:w.pinned===!0,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx(Kh,{session:w,tail:new Date(w.updatedAt).toLocaleString()})]}),i.jsx("button",{type:"button",className:"row__stop",title:"Остановить сессию","aria-label":"Остановить сессию",onClick:ke=>{ke.stopPropagation(),!Kt()&&O(w)},children:i.jsx(aS,{})})]})},w.id)}function ze(w,se){return i.jsx(sS,{folder:w,count:se,open:le(w.id),renaming:De===w.id,onToggle:()=>wl(w.id),onStartRename:()=>yt(w.id),onCommitRename:ke=>{ue(w.id,ke),yt(null)},onCancelRename:()=>yt(null),onDelete:()=>je(w.id)},w.id)}return i.jsxs("aside",{className:s?"sidebar sidebar--open":"sidebar",children:[i.jsxs("div",{className:"sidebar__head",children:[i.jsx("span",{className:l?"dot dot--on":"dot",title:r}),i.jsx("span",{className:"brand",children:"Claude Code Visual"}),i.jsx("button",{className:"theme-btn",title:`Тема: ${Sx[re]}`,"aria-label":`Тема: ${Sx[re]}. Переключить`,onClick:me,children:i.jsx(dS,{mode:re})})]}),i.jsxs("div",{className:"sidebar__tabs",role:"tablist","aria-label":"Что показывать в списке",children:[i.jsx("button",{type:"button",role:"tab","aria-selected":Sn==="default",className:Sn==="default"?"sidebar__tab is-active":"sidebar__tab",onClick:()=>en("default"),children:i.jsx("span",{className:"sidebar__tab-label",children:"Все"})}),i.jsx("button",{type:"button",role:"tab","aria-selected":Sn==="pinned",className:Sn==="pinned"?"sidebar__tab is-active":"sidebar__tab",onClick:()=>en("pinned"),children:i.jsx("span",{className:"sidebar__tab-label",children:"Закреплённые"})}),i.jsxs("button",{type:"button",role:"tab","aria-selected":Sn==="live",className:Sn==="live"?"sidebar__tab is-active":"sidebar__tab",onClick:()=>en("live"),children:[i.jsx("span",{className:"sidebar__tab-label",children:"Запущенные"}),S.length>0&&i.jsx("span",{className:"sidebar__tab-count",children:S.length})]})]}),i.jsxs("div",{className:"fssearch fssearch--sidebar",children:[i.jsx(rS,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:Ve,spellCheck:!1,placeholder:"Проект или сессия…","aria-label":"Поиск по проектам и сессиям",onChange:w=>It(w.target.value),onKeyDown:w=>{w.stopPropagation(),w.key==="Escape"&&(w.preventDefault(),Ve?It(""):w.currentTarget.blur())}}),Ve&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>It(""),children:"✕"})]}),i.jsx("div",{className:"sidebar__scroll",children:Sn==="pinned"?i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Закреплённые",count:Dn.length,open:Pe("pinned"),onToggle:()=>Et("pinned"),action:{label:"Новая папка закреплённых",onClick:()=>{$e("pinned"),Pe("pinned")||Et("pinned")}}}),Pe("pinned")&&i.jsxs(i.Fragment,{children:[Xe==="pinned"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:"",placeholder:"Название папки",onCommit:w=>{W("pinned",w),$e(null)},onCancel:()=>$e(null)})})}),Dn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"закрепите сессию через её меню (правый клик или долгое нажатие) — она останется под рукой из любого проекта"})}),_e.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>we(se))]},w.folder.id)),_e.ungrouped.map(w=>we(w))]})]}):Sn==="live"?i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Запущенные",count:Gt.length,open:Pe("live"),onToggle:()=>Et("live")}),Pe("live")&&i.jsxs(i.Fragment,{children:[Gt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Нет запущенных сессий"})}),Gt.map(w=>Ae(w))]})]}):i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Проекты",count:$t.length,open:Pe("workspaces"),onToggle:()=>Et("workspaces"),action:{label:"Новая папка проектов",onClick:()=>{$e("workspace"),Pe("workspaces")||Et("workspaces")}}}),Pe("workspaces")&&i.jsxs(i.Fragment,{children:[Xe==="workspace"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:"",placeholder:"Название папки",onCommit:w=>{W("workspace",w),$e(null)},onCancel:()=>$e(null)})})}),$t.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока ни одного"})}),ge.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>pe(se))]},w.folder.id)),ge.ungrouped.map(w=>pe(w))]}),o.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Архив проектов",count:cn.length,open:Pe("workspacesArchive"),onToggle:()=>Et("workspacesArchive"),hint:"проект закрывают вручную; каталог и история сессий остаются на диске и открываются заново отсюда или через «+ Проект»"}),Pe("workspacesArchive")&&i.jsxs(i.Fragment,{children:[cn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока пусто"})}),He.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>k(se))]},w.folder.id)),He.ungrouped.map(w=>k(w))]})]}),C&&i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Сессии",count:wt.length,open:Pe("sessions"),onToggle:()=>Et("sessions"),action:{label:"Новая папка сессий",onClick:()=>{$e("session"),Pe("sessions")||Et("sessions")}}}),Pe("sessions")&&i.jsxs(i.Fragment,{children:[Xe==="session"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:"",placeholder:"Название папки",onCommit:w=>{W("session",w,C),$e(null)},onCancel:()=>$e(null)})})}),wt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока ни одной"})}),B.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>Y(se))]},w.folder.id)),B.ungrouped.map(w=>Y(w))]}),b.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Архив",count:yn.length,open:Pe("archive"),onToggle:()=>Et("archive"),hint:"сессии без обращения дольше двух суток уезжают сюда сами; ничего не удаляется"}),Pe("archive")&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:"сюда сами уезжают сессии без обращения дольше двух суток; транскрипт остаётся на диске, ничего не удаляется"})}),yn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока пусто"})}),P.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>fe(se))]},w.folder.id)),P.ungrouped.map(w=>fe(w))]})]})]})]})}),i.jsxs("div",{className:"sidebar__foot",children:[i.jsxs("button",{className:"account-btn",title:"Аккаунт Claude",onClick:be,children:[i.jsx("span",{className:z!=null&&z.loggedIn?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:z===null?"Аккаунт":z.loggedIn?z.email||"Вход выполнен":"Войти в аккаунт"}),(z==null?void 0:z.plan)&&i.jsx("span",{className:"chip",children:z.plan})]}),N&&i.jsxs("button",{className:"account-btn",title:"Доступ с телефона и из браузера",onClick:N,children:[i.jsx("span",{className:ye!=null&&ye.connected?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:ye===null?"Удалённый доступ":ye.paired?ye.connected?ye.name||"Удалённый доступ включён":"Удалённый доступ · нет связи":"Удалённый доступ"}),(ye==null?void 0:ye.connected)&&ye.clients>0&&i.jsx("span",{className:"chip",children:ye.clients})]}),i.jsxs("div",{className:"sidebar__foot-row",children:[i.jsx("button",{className:"btn btn--ghost",disabled:!ce,title:"MCP-серверы и плагины",onClick:()=>ce==null?void 0:ce(),children:"Расширения"}),i.jsx("button",{className:"btn btn--ghost",title:"Настройки приложения",onClick:V,children:"Настройки"})]}),i.jsxs("div",{className:"sidebar__foot-row",children:[i.jsx("button",{className:"btn btn--ghost",onClick:Ce,children:"+ Проект"}),i.jsx($j,{disabled:!C,onStart:A})]})]}),Vt&&i.jsx(sr,{x:Vt.x,y:Vt.y,items:kn,note:Lt,onClose:on}),kt&&i.jsx(sr,{x:kt.x,y:kt.y,items:Di,note:Ds,onClose:Fe}),Oe&&i.jsx(sr,{x:Oe.x,y:Oe.y,items:La,note:Nn,onClose:ml}),qn&&i.jsx(sr,{x:qn.x,y:qn.y,items:Jl,note:$h,onClose:Ms}),Ln&&i.jsx(sr,{x:Ln.x,y:Ln.y,items:Xn,note:$h,onClose:Gn})]})}function lc(s,l,r){const c=["row"];return s&&c.push("row--active"),l&&c.push("row--selected"),r&&c.push("row--antigravity"),c.join(" ")}function Ro(s,l,r=c=>c.folderId){const c=new Map(l.map(m=>[m.id,m])),o=new Map,d=[];for(const m of s){const g=r(m),b=g?c.get(g):void 0;if(!b){d.push(m);continue}const _=o.get(b.id);_?_.push(m):o.set(b.id,[m])}return{groups:[...o.entries()].map(([m,g])=>({folder:c.get(m),items:g})).sort((m,g)=>m.folder.name.localeCompare(g.folder.name,"ru")),ungrouped:d}}function Fj(s,l,r){return[...s.flatMap(c=>c.items.map(r)),...l.map(r)]}const Jj="\0ungrouped";function Wj(s,l,r){const c=new Map;for(const o of s)for(const d of o.items)c.set(r(d),o.folder.id);for(const o of l)c.set(r(o),Jj);return c}function Vh(s,l,r,c,o){const d=[...l.map(m=>m.items),r].find(m=>m.some(g=>c(g)===s));if(!d)return null;const h=d.findIndex(m=>c(m)===s);return o==="up"?h<=0?null:{target:c(d[h-1]),position:"before"}:h===-1||h>=d.length-1?null:{target:c(d[h+1]),position:"after"}}function jf(s){const[l,r]=y.useState(null),[c,o]=y.useState(null),d=y.useMemo(()=>Fj(s.groups,s.ungrouped,s.itemKey),[s.groups,s.ungrouped,s.itemKey]),h=y.useMemo(()=>Wj(s.groups,s.ungrouped,s.itemKey),[s.groups,s.ungrouped,s.itemKey]);function m(){r(null),o(null)}function g(X,J){s.enabled&&(J.preventDefault(),J.currentTarget.setPointerCapture(J.pointerId),r(X),o(null))}function b(X,J){var D;if(!l)return;const G=(D=document.elementFromPoint(X,J))==null?void 0:D.closest("[data-row-key]"),O=G==null?void 0:G.dataset.rowKey;if(!O||O===l||h.get(O)!==h.get(l)){o(null);return}const Z=G.getBoundingClientRect(),M=J-Z.top<Z.height/2?"before":"after";o(H=>(H==null?void 0:H.key)===O&&H.position===M?H:{key:O,position:M})}function _(X){b(X.clientX,X.clientY)}function S(){if(l&&c){const X=_f(d,l,c.key,c.position);X&&s.onReorder(s.scope,X,s.workspaceId)}m()}function v(X,J){if(!s.enabled)return;const G=Vh(X,s.groups,s.ungrouped,s.itemKey,J);if(!G)return;const O=_f(d,X,G.target,G.position);O&&s.onReorder(s.scope,O,s.workspaceId)}function E(X,J){const G=Vh(X,s.groups,s.ungrouped,s.itemKey,"up"),O=Vh(X,s.groups,s.ungrouped,s.itemKey,"down"),Z=[{id:"move-up",label:"Переместить выше",disabled:!G,onSelect:()=>{if(!G)return;const M=_f(d,X,G.target,G.position);M&&s.onReorder(s.scope,M,s.workspaceId)}},{id:"move-down",label:"Переместить ниже",disabled:!O,onSelect:()=>{if(!O)return;const M=_f(d,X,O.target,O.position);M&&s.onReorder(s.scope,M,s.workspaceId)}}];return J&&Z.push({id:"reset-order",label:"Сбросить порядок",onSelect:()=>s.onReorder(s.scope,null,s.workspaceId)}),Z}function T(X){return l===X?" row--dragging":(c==null?void 0:c.key)===X?c.position==="before"?" row--drop-before":" row--drop-after":""}function C(X){return{onPointerDown:J=>g(X,J),onPointerMove:_,onPointerUp:S,onPointerCancel:m}}function L(X,J){!J.altKey||J.key!=="ArrowUp"&&J.key!=="ArrowDown"||(J.preventDefault(),v(X,J.key==="ArrowUp"?"up":"down"))}return{dragging:l!==null,dropClass:T,gripHandlers:C,onKeyDown:L,menuItems:E}}function Do(s){return[...[...s.folders].sort((r,c)=>r.name.localeCompare(c.name,"ru")).map(r=>({id:`folder:${r.id}`,label:`В папку «${r.name}»`,onSelect:()=>{s.ids.forEach(c=>s.assign(c,r.id)),s.onClear()}})),...s.hasFolder?[{id:"folder:none",label:"Без папки",onSelect:()=>{s.ids.forEach(r=>s.assign(r,null)),s.onClear()}}]:[],{id:"folder:new",label:"Новая папка…",onSelect:s.onNewFolder}]}function Pj(s){return s.map(l=>({...l,id:`pinned:${l.id}`,label:l.id==="folder:new"?"Новая папка закреплённых…":l.id==="folder:none"?"Без папки закреплённых":l.label}))}function Qh(s){const[l,r]=y.useState([]),c=y.useRef(null);function o(){r([]),c.current=null}function d(m,g,b){if(m.ctrlKey||m.metaKey){r(_=>_.includes(g.id)?_.filter(S=>S!==g.id):[..._,g.id]),c.current=g.id;return}if(m.shiftKey&&c.current){const _=s.findIndex(v=>v.id===c.current),S=s.findIndex(v=>v.id===g.id);if(_!==-1&&S!==-1){const[v,E]=_<S?[_,S]:[S,_];r(s.slice(v,E+1).map(T=>T.id));return}}o(),c.current=g.id,b()}function h(m){return l.includes(m.id)?l:(r([m.id]),c.current=m.id,[m.id])}return{selected:l,click:d,targetsFor:h,clear:o}}const eS={display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0,textAlign:"left"},tS={width:22,height:22,borderRadius:6};function sc({title:s,count:l,open:r,onToggle:c,hint:o,action:d}){const h=r?`Свернуть «${s}»`:`Развернуть «${s}»`;return i.jsxs("div",{className:"sidebar__section",children:[i.jsxs("button",{className:"sidebar__section--btn",style:eS,"aria-expanded":r,title:o?`${h} — ${o}`:h,onClick:c,children:[i.jsx(Yy,{open:r}),i.jsx("span",{className:"sidebar__section-name",children:s}),i.jsx("span",{className:"sidebar__count",children:l})]}),d&&i.jsx("button",{className:"theme-btn",style:tS,title:d.label,"aria-label":d.label,onClick:d.onClick,children:i.jsx(cS,{})})]})}const jx={paddingLeft:22},nS={display:"flex",alignItems:"center",gap:6,width:"100%"},lS={flex:1,minWidth:0,color:"var(--text-2)",fontWeight:500};function sS({folder:s,count:l,open:r,renaming:c,onToggle:o,onStartRename:d,onCommitRename:h,onCancelRename:m,onDelete:g}){return c?i.jsx("div",{className:"row",style:jx,children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:s.name,placeholder:"Название папки",onCommit:h,onCancel:m})})}):i.jsxs("div",{className:"row",style:jx,children:[i.jsxs("button",{className:"row__main",style:nS,"aria-expanded":r,title:r?`Свернуть папку «${s.name}»`:`Развернуть папку «${s.name}»`,onClick:o,children:[i.jsx(Yy,{open:r}),i.jsx("span",{style:lS,children:s.name}),i.jsx("span",{className:"sidebar__count",children:l})]}),i.jsx("button",{className:"row__edit",title:"Переименовать папку","aria-label":`Переименовать папку «${s.name}»`,onClick:d,children:"✎"}),i.jsx("button",{className:"row__edit",title:"Удалить папку — содержимое останется, просто станет без папки","aria-label":`Удалить папку «${s.name}»`,onClick:g,children:"✕"})]})}function Yy({open:s}){return i.jsx("svg",{className:s?"sidebar__chev sidebar__chev--open":"sidebar__chev",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M6 3.5 10.5 8 6 12.5"})})}function Sf(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"5.5",cy:"4",r:"1.15"}),i.jsx("circle",{cx:"5.5",cy:"8",r:"1.15"}),i.jsx("circle",{cx:"5.5",cy:"12",r:"1.15"}),i.jsx("circle",{cx:"10.5",cy:"4",r:"1.15"}),i.jsx("circle",{cx:"10.5",cy:"8",r:"1.15"}),i.jsx("circle",{cx:"10.5",cy:"12",r:"1.15"})]})}function aS(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:i.jsx("rect",{x:"3.6",y:"3.6",width:"8.8",height:"8.8",rx:"1.8"})})}function iS({className:s}){return i.jsxs("svg",{className:s,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"4.5",y:"2.4",width:"7",height:"4.2",rx:"1.6"}),i.jsx("path",{d:"M5.4 6.6 8 12.2 10.6 6.6"}),i.jsx("path",{d:"M8 12.2v1.4"})]})}function rS(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}function cS(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 3.2v9.6M3.2 8h9.6"})})}function oS(){try{const s=localStorage.getItem(Iy);if(s===null)return["archive","workspacesArchive"];const l=JSON.parse(s);return Array.isArray(l)?l.filter(r=>r==="workspaces"||r==="workspacesArchive"||r==="sessions"||r==="archive"||r==="pinned"||r==="live"):["archive","workspacesArchive"]}catch{return["archive","workspacesArchive"]}}function uS(){try{const s=localStorage.getItem(Gy);if(s===null)return[];const l=JSON.parse(s);return Array.isArray(l)?l.filter(r=>typeof r=="string"):[]}catch{return[]}}function fS(){try{const s=localStorage.getItem(qy);return s==="pinned"||s==="live"?s:"default"}catch{return"default"}}const Sx={system:"как в системе",light:"светлая",dark:"тёмная"};function dS({mode:s}){const l={viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return s==="dark"?i.jsx("svg",{...l,children:i.jsx("path",{d:"M13.2 9.7A5.4 5.4 0 0 1 6.3 2.8a5.6 5.6 0 1 0 6.9 6.9Z"})}):s==="light"?i.jsxs("svg",{...l,children:[i.jsx("circle",{cx:"8",cy:"8",r:"3.1"}),i.jsx("path",{d:"M8 1.4v1.4M8 13.2v1.4M2.4 8H1M15 8h-1.4M4 4l-1-1M13 13l-1-1M12 4l1-1M3 13l1-1"})]}):i.jsxs("svg",{...l,children:[i.jsx("rect",{x:"1.8",y:"2.6",width:"12.4",height:"8.4",rx:"1.4"}),i.jsx("path",{d:"M5.6 13.4h4.8"})]})}function hS(s){const l=pS(s),r=(s.tasks??[]).filter(c=>c.kind==="agent").length;return r>0?`${l} · ${Hy(r)}`:l}function pS(s){switch(s.state){case"running":return"работает";case"waiting_permission":return"ждёт разрешения";case"idle":return s.backgroundWork?"работает в фоне":mS(s.lastTurn);case"starting":return"запускается";case"reconnecting":return"переподключается";case"error":return"ошибка";case"closed":return"на диске"}}function mS(s){switch(s){case"interrupted":return"прервана";case"stopped":return"остановлена";case"failed":return"оборвалась";case"completed":return"готова";case null:return"ждёт задачу"}}function gS(s){switch(s.state){case"running":return"running";case"starting":return"starting";case"reconnecting":return"reconnecting";case"waiting_permission":return"waiting";case"idle":return s.backgroundWork?"background":bS(s.lastTurn);case"error":return"error";case"closed":return"closed"}}function bS(s){switch(s){case"interrupted":case"stopped":return"halted";case"failed":return"error";case"completed":return"ready";case null:return"fresh"}}function Kh({session:s,tail:l}){return i.jsxs("span",{className:"row__meta",children:[i.jsxs("span",{className:`row__state row__state--${gS(s)}`,children:[i.jsx("span",{className:"row__state-dot","aria-hidden":"true"}),hS(s)]})," · ",l]})}function wf({title:s,pinned:l,provider:r,projectName:c,projectPath:o}){return i.jsxs("span",{className:"row__head",children:[i.jsxs("span",{className:"row__title",children:[l&&i.jsx(iS,{className:"row__pin"}),r==="antigravity"&&i.jsx(By,{className:"row__provider"}),s]}),i.jsx("span",{className:"row__project",title:o,children:c})]})}function xS(s){const l=s.archivedAuto?"сама, по сроку молчания":"убрана вручную";return s.archivedAt?`${new Date(s.archivedAt).toLocaleString()} · ${l}`:l}function yS(s){return s.archivedAt?`закрыт ${new Date(s.archivedAt).toLocaleString()}`:"закрыт"}const wx=3,_S=15e5;function Xy(s,l){if(!l||typeof l!="object")return null;const r=l,c=typeof r.file_path=="string"?r.file_path:"";if(!c)return null;if(s==="Write"){if(typeof r.content!="string")return null;const o=Zh(r.content).map(d=>({type:"add",text:d}));return{kind:"create",filePath:c,rows:o,added:o.length,removed:0,note:"файл записывается целиком"}}if(s==="Edit"){if(typeof r.old_string!="string"||typeof r.new_string!="string")return null;const o=wS(vS(Zh(r.old_string),Zh(r.new_string)));return{kind:"edit",filePath:c,rows:o,added:o.filter(d=>d.type==="add").length,removed:o.filter(d=>d.type==="del").length,note:r.replace_all===!0?"все вхождения":null}}return null}function Zh(s){if(s==="")return[];const l=s.split(/\r?\n/);return l.length>1&&l[l.length-1]===""&&l.pop(),l}function vS(s,l){let r=0;for(;r<s.length&&r<l.length&&s[r]===l[r];)r++;let c=s.length,o=l.length;for(;c>r&&o>r&&s[c-1]===l[o-1];)c--,o--;const d=h=>({type:"ctx",text:h});return[...s.slice(0,r).map(d),...jS(s.slice(r,c),l.slice(r,o)),...s.slice(c).map(d)]}function jS(s,l){if(s.length===0&&l.length===0)return[];if(s.length===0)return l.map(_=>({type:"add",text:_}));if(l.length===0)return s.map(_=>({type:"del",text:_}));if((s.length+1)*(l.length+1)>_S)return[...s.map(_=>({type:"del",text:_})),...l.map(_=>({type:"add",text:_}))];const r=s.length,c=l.length,o=c+1,d=new Uint32Array((r+1)*o),h=(_,S)=>d[_*o+S]??0;for(let _=r-1;_>=0;_--)for(let S=c-1;S>=0;S--)d[_*o+S]=s[_]===l[S]?h(_+1,S+1)+1:Math.max(h(_+1,S),h(_,S+1));const m=[];let g=0,b=0;for(;g<r&&b<c;){const _=s[g],S=l[b];_===S?(m.push({type:"ctx",text:_}),g++,b++):h(g+1,b)>=h(g,b+1)?(m.push({type:"del",text:_}),g++):(m.push({type:"add",text:S}),b++)}for(;g<r;)m.push({type:"del",text:s[g++]});for(;b<c;)m.push({type:"add",text:l[b++]});return SS(m)}function SS(s){const l=[];let r=[];function c(){l.push(...r.filter(o=>o.type==="del")),l.push(...r.filter(o=>o.type==="add")),r=[]}for(const o of s)o.type==="ctx"?(c(),l.push(o)):r.push(o);return c(),l}function wS(s){if(!s.some(d=>d.type!=="ctx"))return s;const l=s.map(()=>!1);s.forEach((d,h)=>{if(d.type!=="ctx")for(let m=Math.max(0,h-wx);m<=Math.min(s.length-1,h+wx);m++)l[m]=!0});const r=[];let c=[];function o(){c.length===1?r.push(...c):c.length>1&&r.push({type:"gap",text:`⋯ ${c.length} ${kS(c.length)} без изменений`}),c=[]}return s.forEach((d,h)=>{l[h]?(o(),r.push(d)):c.push(d)}),o(),r}function kS(s){const l=s%100;if(l>=11&&l<=14)return"строк";switch(s%10){case 1:return"строка";case 2:case 3:case 4:return"строки";default:return"строк"}}async function vc(s){try{return await navigator.clipboard.writeText(s),!0}catch{}const l=document.createElement("textarea");l.value=s,l.setAttribute("readonly",""),l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l);try{return l.select(),document.execCommand("copy")}catch{return!1}finally{l.remove()}}async function hp(){try{return await navigator.clipboard.readText()}catch{return null}}const Mp=1600,dr="Копировать",fc="Скопировано";function Rp({text:s,hint:l,className:r}){const[c,o]=y.useState(!1);return y.useEffect(()=>{if(!c)return;const d=setTimeout(()=>o(!1),Mp);return()=>clearTimeout(d)},[c]),y.useEffect(()=>o(!1),[s]),i.jsx("button",{type:"button",className:"copybtn"+(c?" copybtn--done":"")+(r?` ${r}`:""),"aria-label":c?fc:`${dr} ${l}`,title:c?fc:`${dr} ${l}`,onClick:()=>{vc(s).then(d=>{d&&o(!0)})},children:c?fc:dr})}function Dp({diff:s}){return i.jsxs("div",{className:"diff",children:[i.jsxs("div",{className:"diff__head",children:[i.jsx("span",{className:"diff__path",title:s.filePath,children:s.filePath}),i.jsxs("span",{className:"diff__stat",children:[s.added>0&&i.jsxs("span",{className:"diff__stat--add",children:["+",s.added]}),s.removed>0&&i.jsxs("span",{className:"diff__stat--del",children:["−",s.removed]})]})]}),s.note&&i.jsx("div",{className:"diff__note",children:s.note}),i.jsx("div",{className:"diff__body",children:s.rows.length===0?i.jsx("div",{className:"diff__row diff__row--gap",children:i.jsx("span",{className:"diff__text",children:"пустое содержимое"})}):s.rows.map((l,r)=>i.jsxs("div",{className:`diff__row diff__row--${l.type}`,children:[i.jsx("span",{className:"diff__mark","aria-hidden":"true",children:l.type==="add"?"+":l.type==="del"?"−":""}),i.jsx("span",{className:"diff__text",children:l.text===""?" ":l.text})]},r))})]})}function NS({waiting:s}){const[l,r]=y.useState(0);return y.useEffect(()=>{const c=window.setInterval(()=>r(o=>o+1),1e3);return()=>window.clearInterval(c)},[]),i.jsxs("div",{className:s?"work work--wait":"work",children:[i.jsxs("span",{className:"work__dots","aria-hidden":"true",children:[i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"})]}),i.jsx("span",{className:"work__label",children:s?"ждёт разрешения":"думает"}),!s&&i.jsxs("span",{className:"work__time",children:[l," с"]})]})}function Op({items:s,busy:l,waiting:r,history:c=[],historyHasMore:o=!1,historyLoading:d=!1,onLoadHistory:h,sessionId:m,onEditMessage:g,empty:b="Сессия пуста. Опишите задачу — Claude Code работает в каталоге проекта с полным набором инструментов."}){const _=y.useRef(null),S=y.useRef(null),v=y.useRef(!0),E=y.useRef(null),T=y.useRef(null),C=y.useRef(!1);y.useEffect(()=>{v.current=!0,E.current=null,C.current=!1,T.current!==null&&(clearTimeout(T.current),T.current=null)},[m]),y.useEffect(()=>{const O=_.current,Z=S.current;if(!O||!Z)return;function M(ne){!O||ne===O.scrollTop||(C.current=!0,O.scrollTop=ne)}function D(){if(!O)return;const ne=E.current;if(ne){const he=Nx(O,ne.id);if(he){const W=he.getBoundingClientRect().top-O.getBoundingClientRect().top;M(O.scrollTop+(W-ne.top))}T.current!==null&&clearTimeout(T.current),T.current=setTimeout(()=>{E.current=null},500);return}v.current&&M(O.scrollHeight)}const H=new ResizeObserver(D);return H.observe(Z),()=>{H.disconnect(),T.current!==null&&clearTimeout(T.current)}},[]);function L(){const O=_.current;if(O){if(C.current){C.current=!1;return}v.current=O.scrollHeight-O.scrollTop-O.clientHeight<80}}function X(){if(d)return;const O=_.current,Z=c[0];if(O&&Z){const M=Nx(O,Z.id);M&&(E.current={id:Z.id,top:M.getBoundingClientRect().top-O.getBoundingClientRect().top})}h==null||h()}let J=0;function G(O){return O.kind==="user"?J++:-1}return i.jsx("div",{className:"transcript",ref:_,onScroll:L,children:i.jsxs("div",{className:"stream",ref:S,children:[o&&i.jsx("button",{type:"button",className:"transcript__more",onClick:X,disabled:d,children:d?"Загружаем…":"Показать более раннее"}),c.map(O=>i.jsx(kx,{item:O,userIndex:G(O),onEditMessage:g},O.id)),c.length>0&&s.length>0&&i.jsx("div",{className:"transcript__divider",children:i.jsx("span",{children:"дальше — сессия открыта заново"})}),c.length===0&&s.length===0&&i.jsx("p",{className:"empty",children:b}),s.map(O=>i.jsx(kx,{item:O,userIndex:G(O),onEditMessage:g},O.id)),l&&i.jsx(NS,{waiting:r})]})})}function kx({item:s,userIndex:l,onEditMessage:r}){switch(s.kind){case"user":return i.jsx(ES,{item:s,userIndex:l,onEditMessage:r});case"assistant":return i.jsxs("div",{className:"msg--assistant","data-item-id":s.id,children:[i.jsx(CS,{text:s.text}),s.streaming&&i.jsx("span",{className:"caret"}),s.text.trim()!==""&&i.jsx("div",{className:"msg--assistant__foot",children:i.jsx(Rp,{text:s.text,hint:"ответ целиком"})})]});case"thinking":return i.jsx("div",{className:"thinking","data-item-id":s.id,children:s.text});case"tool":return i.jsx(MS,{item:s});case"result":return i.jsxs("div",{className:"result-line","data-item-id":s.id,children:[i.jsx("span",{children:s.isError?"✗ "+s.subtype:"✓ готово"}),i.jsxs("span",{children:[(s.durationMs/1e3).toFixed(1)," с"]}),s.costUsd!==null&&i.jsxs("span",{children:["$",s.costUsd.toFixed(4)]}),i.jsxs("span",{children:["↑",Ex(s.inputTokens)," ↓",Ex(s.outputTokens)]})]});case"notice":return i.jsx("div",{className:s.tone==="error"?"notice notice--error":"notice","data-item-id":s.id,children:s.text})}}const TS=500;function ES({item:s,userIndex:l,onEditMessage:r}){const[c,o]=y.useState(null),[d,h]=y.useState(!1),[m,g]=y.useState(s.text),b=y.useRef(null),_=Xf("(max-width: 860px)"),S=y.useRef(null);function v(D,H){o({x:D,y:H})}function E(D){D.preventDefault(),v(D.clientX,D.clientY)}function T(D){const H=D.touches[0];if(!H)return;const ne={timer:0,x:H.clientX,y:H.clientY,fired:!1};ne.timer=window.setTimeout(()=>{ne.fired=!0,v(ne.x,ne.y)},TS),S.current=ne}function C(D){const H=S.current,ne=D.touches[0];!H||!ne||Math.hypot(ne.clientX-H.x,ne.clientY-H.y)>10&&(window.clearTimeout(H.timer),S.current=null)}function L(D){const H=S.current;H&&(window.clearTimeout(H.timer),H.fired&&D.preventDefault())}function X(){g(s.text),h(!0)}function J(){h(!1)}function G(){const D=m.trim();D===""&&!(s.images&&s.images.length>0)||(r==null||r(l,D,s.images),h(!1))}y.useEffect(()=>{const D=b.current;!D||!d||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[m,d]),y.useEffect(()=>{if(!d)return;const D=b.current;D&&(D.focus(),D.setSelectionRange(D.value.length,D.value.length))},[d]);function O(D){if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),J();return}D.key==="Enter"&&!D.shiftKey&&!_&&(D.preventDefault(),G())}const Z=s.images&&s.images.length>0&&i.jsx("div",{className:"msg--user__images",children:s.images.map((D,H)=>i.jsx("img",{className:"msg--user__image",src:`data:${D.mediaType};base64,${D.data}`,alt:"Вложение"},H))});if(d){const D=m.trim()!==""||!!(s.images&&s.images.length>0);return i.jsxs("div",{className:"msg--user msg--user--editing","data-item-id":s.id,children:[Z,i.jsxs("div",{className:"msg--user__edit",children:[i.jsx("textarea",{ref:b,className:"msg--user__edit-field",value:m,onChange:H=>g(H.target.value),onKeyDown:O,rows:1}),i.jsxs("div",{className:"msg--user__edit-actions",children:[i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:J,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--primary",onClick:G,disabled:!D,children:"Сохранить"})]})]})]})}const M=[{id:"copy",label:"Копировать",onSelect:()=>void vc(s.text)},...r?[{id:"edit",label:"Изменить",onSelect:X}]:[]];return i.jsxs("div",{className:"msg--user","data-item-id":s.id,onContextMenu:E,onTouchStart:T,onTouchMove:C,onTouchEnd:L,onTouchCancel:L,children:[Z,s.text,c&&i.jsx(sr,{x:c.x,y:c.y,items:M,onClose:()=>o(null)})]})}function Nx(s,l){const r=s.querySelectorAll("[data-item-id]");for(const c of r)if(c.dataset.itemId===l)return c;return null}function CS({text:s}){const[l,r]=y.useState(""),c=y.useRef([]);y.useEffect(()=>{let d=!1;return Qf(s).then(h=>{d||r(AS(h))}),()=>{d=!0}},[s]),y.useEffect(()=>{const d=c.current;return()=>d.forEach(h=>clearTimeout(h))},[]);function o(d){var g,b;const h=d.target.closest(".codeblock__copy");if(!(h instanceof HTMLElement))return;const m=((b=(g=h.parentElement)==null?void 0:g.querySelector("pre"))==null?void 0:b.textContent)??"";m!==""&&vc(m).then(_=>{if(!_)return;h.textContent=fc,h.setAttribute("aria-label",fc),h.classList.add("copybtn--done");const S=window.setTimeout(()=>{h.isConnected&&(h.textContent=dr,h.setAttribute("aria-label",pp),h.classList.remove("copybtn--done"))},Mp);c.current.push(S)})}return i.jsx("div",{className:"markdown-preview msg--assistant__body",onClick:o,dangerouslySetInnerHTML:{__html:l}})}const pp=`${dr} блок кода`;function AS(s){if(!s.includes("<pre"))return s;const l=new DOMParser().parseFromString(s,"text/html");for(const r of l.body.querySelectorAll("pre")){const c=l.createElement("div");c.className="codeblock",r.replaceWith(c),c.append(r);const o=l.createElement("button");o.type="button",o.className="copybtn codeblock__copy",o.setAttribute("aria-label",pp),o.title=pp,o.textContent=dr,c.append(o)}return l.body.innerHTML}function MS({item:s}){const[l,r]=y.useState(!1),c=s.result===null,o=Xy(s.name,s.input),d=s.name==="AskUserQuestion"?OS(s.input):null;return i.jsxs("div",{className:"tool"+(s.isError?" tool--error":"")+(s.awaitingPermission?" tool--wait":""),"data-item-id":s.id,children:[i.jsxs("button",{className:"tool__head",onClick:()=>r(h=>!h),children:[i.jsx("span",{className:"tool__name",children:s.name}),i.jsx("span",{className:"tool__arg",children:d?DS(d):RS(s.input)}),i.jsx("span",{className:"tool__status",children:c?"…":s.isError?"ошибка":l?"▴":"▾"})]}),l&&i.jsxs("div",{className:"tool__body",children:[d?i.jsx(LS,{questions:d,answers:s.answers}):o?i.jsx(Dp,{diff:o}):i.jsx(Tx,{text:JSON.stringify(s.input,null,2),hint:"аргументы вызова"}),s.result!==null&&(!d||s.isError)&&i.jsx(Tx,{text:s.result,hint:"результат вызова",style:{marginTop:10}})]})]})}function Tx({text:s,hint:l,style:r}){return i.jsxs("div",{className:"codeblock",style:r,children:[i.jsx("pre",{className:"code",children:s}),i.jsx(Rp,{text:s,hint:l,className:"codeblock__copy"})]})}function RS(s){if(!s||typeof s!="object")return"";const l=s;for(const r of["file_path","command","pattern","path","url","prompt"]){const c=l[r];if(typeof c=="string")return c.replace(/\s+/g," ").slice(0,160)}return JSON.stringify(l).slice(0,160)}function DS(s){var r;const l=s.map(c=>c.header).filter(c=>c.length>0);return l.length===s.length?l.join(" · "):((r=s[0])==null?void 0:r.question.replace(/\s+/g," ").slice(0,160))??""}function OS(s){if(typeof s!="object"||s===null)return null;const l=s.questions;if(!Array.isArray(l)||l.length===0)return null;const r=[];for(const c of l){if(typeof c!="object"||c===null)return null;const{question:o,header:d,options:h,multiSelect:m}=c;if(typeof o!="string"||!Array.isArray(h)||h.length===0)return null;const g=[];for(const b of h){if(typeof b!="object"||b===null)return null;const{label:_,description:S,preview:v}=b;if(typeof _!="string"||typeof S!="string")return null;g.push({label:_,description:S,...typeof v=="string"?{preview:v}:{}})}r.push({question:o,header:typeof d=="string"?d:"",options:g,multiSelect:m===!0})}return r}function LS({questions:s,answers:l}){return i.jsx("div",{className:"tool__questions",children:s.map((r,c)=>i.jsxs("div",{className:"tool__question",children:[i.jsxs("div",{className:"tool__question-head",children:[r.header&&i.jsx("span",{className:"chip chip--accent",children:r.header}),i.jsx("span",{className:"tool__question-text",children:r.question})]}),i.jsx("div",{className:"tool__question-answer",children:l!=null&&l[r.question]?i.jsx("span",{className:"tool__answer-value",children:l[r.question]}):i.jsx("span",{className:"tool__answer-empty",children:"не отвечено"})})]},c))})}function Ex(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}const zS="ccv.dictation.lang",Cx="ru-RU";function US(s){try{return Function.prototype.toString.call(s).includes("[native code]")}catch{return!1}}function Ax(){const s=window,l=[s.SpeechRecognition,s.webkitSpeechRecognition].filter(c=>typeof c=="function"),r=l.find(US);return!r&&l.length>0&&Ns("распознавание подменено: родной реализации в странице нет"),r??l[0]??null}function $y(){var s;try{return((s=localStorage.getItem(zS))==null?void 0:s.trim())||Cx}catch{return Cx}}function Ns(s,l){l===void 0?console.debug(`[dictation] ${s}`):console.debug(`[dictation] ${s}`,l)}const HS=3,BS=400,IS=5,qS=250,GS=2e3,YS=2e4;async function XS(){try{return(await navigator.permissions.query({name:"microphone"})).state==="granted"}catch{return!1}}const $S={"not-allowed":"Браузер не дал доступ к микрофону","service-not-allowed":"Браузер не дал доступ к микрофону","audio-capture":"Микрофон не найден",network:"Сервис распознавания недоступен","language-not-supported":`Распознавание не знает языка ${$y()}`};function VS(s){const[l]=y.useState(()=>Ax()!==null),[r,c]=y.useState(!1),[o,d]=y.useState(null),h=y.useRef(null),m=y.useRef(!1),g=y.useRef(!1),b=y.useRef(s),_=y.useRef({openedAt:0,audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1}),S=y.useRef(null),v=y.useRef(!1),E=y.useRef(null),T=y.useCallback(()=>{E.current&&clearTimeout(E.current),E.current=null},[]),C=y.useCallback(()=>{T();const O=async Z=>{if(E.current=null,!(!m.current||v.current)){if(!Z&&!await XS()){if(Ns("ждём ответа на запрос доступа к микрофону"),!m.current||v.current)return;E.current=setTimeout(()=>void O(!0),YS);return}Ns("движок не ответил на start()"),m.current=!1,c(!1),d("Распознавание не отвечает — проверьте расширения браузера и доступ к микрофону")}};E.current=setTimeout(()=>void O(!1),GS)},[T]);y.useEffect(()=>{b.current=s}),y.useEffect(()=>{const O=Ax();if(!O)return;const Z=new O;return Z.lang=$y(),Z.continuous=!0,Z.interimResults=!0,Z.onstart=()=>{Ns("сессия открыта"),v.current=!0,T(),c(!0)},Z.onaudiostart=()=>{Ns("пошёл звук с микрофона"),_.current.audio=!0},Z.onresult=M=>{var he;if(g.current)return;let D="",H="";for(let W=M.resultIndex;W<M.results.length;W++){const ue=M.results[W];if(!ue)continue;const je=((he=ue[0])==null?void 0:he.transcript)??"";ue.isFinal?D+=je:H+=je}const ne=_.current;ne.heard=!0,ne.everHeard=!0,Ns("распознано",{final:D,interim:H}),b.current(D,H)},Z.onerror=M=>{_.current.lastError=M.error,Ns("ошибка движка",M.error),!(M.error==="no-speech"||M.error==="aborted")&&(m.current=!1,c(!1),d($S[M.error]??`Распознавание не работает: ${M.error}`))},Z.onend=()=>{g.current=!1,v.current=!1;const M=_.current,D=Date.now()-M.openedAt;if(Ns("сессия закрыта",{мс:D,звук:M.audio,слова:M.heard,ошибка:M.lastError||null}),!m.current){c(!1);return}if(M.dead=!M.audio&&D<BS?M.dead+1:0,M.dead>=IS){m.current=!1,c(!1),d(M.lastError?`Распознавание не работает: ${M.lastError}`:"Распознавание закрывается сразу после запуска — проверьте доступ к микрофону в настройках сайта");return}M.silent=M.heard?0:M.silent+1,!M.everHeard&&!M.warned&&M.silent>=HS&&(M.warned=!0,d(M.audio?"Микрофон слушает, но речь не распознаётся — проверьте язык диктовки и уровень звука":"С микрофона не идёт звук — проверьте устройство ввода в настройках сайта в браузере")),S.current=setTimeout(()=>{if(S.current=null,!!m.current){M.openedAt=Date.now(),M.audio=!1,M.heard=!1,M.lastError="",C();try{Z.start()}catch{}}},qS)},h.current=Z,()=>{m.current=!1,S.current&&clearTimeout(S.current),S.current=null,T(),Z.onend=null,Z.onresult=null,Z.onerror=null,Z.onstart=null,Z.onaudiostart=null,Z.abort(),h.current=null}},[]);const L=y.useCallback(()=>{var O;if(m.current){if(m.current=!1,Ns("выключение микрофона"),S.current&&clearTimeout(S.current),S.current=null,T(),!v.current){c(!1);return}(O=h.current)==null||O.stop()}},[]),X=y.useCallback(()=>{const O=h.current;if(O){if(!window.isSecureContext){d("Микрофон доступен только по https или с localhost");return}d(null),m.current=!0,g.current=!1,S.current&&clearTimeout(S.current),S.current=null,_.current={openedAt:Date.now(),audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1},c(!0),Ns("включение микрофона",{язык:O.lang}),C();try{O.start()}catch(Z){Ns("start() не прошёл",Z)}}},[C]),J=y.useCallback(()=>{m.current?L():X()},[X,L]),G=y.useCallback(()=>{var O;m.current&&v.current&&(g.current=!0,(O=h.current)==null||O.abort())},[]);return{supported:l,listening:r,error:o,toggle:J,stop:L,drop:G}}const QS="(max-width: 860px)",Mx=/^\/(\S*)$/,KS=new Set(["model","permissions"]);function ZS(s){return KS.has(s.name)||s.name.startsWith("__")}const FS=new Set(["clear","rename"]),Rx=/(?:^|\s)@([^\s@]*)$/,JS=200,WS=100,PS=190,ew=5,tw=20*1024*1024,nw=1568,lw=.85;let Dx=0;async function sw(s){var S,v;if(!s.type.startsWith("image/")||s.size>tw)return null;const l=await aw(s);if(!l)return null;const{width:r,height:c}=l;if(r<=0||c<=0)return null;const o=Math.min(1,nw/Math.max(r,c)),d=document.createElement("canvas");d.width=Math.max(1,Math.round(r*o)),d.height=Math.max(1,Math.round(c*o));const h=d.getContext("2d");if(!h)return null;h.drawImage(l.image,0,0,d.width,d.height),(v=(S=l.image).close)==null||v.call(S);const m=s.type==="image/png",g=m?"image/png":"image/jpeg",b=d.toDataURL(g,m?void 0:lw),_=b.slice(b.indexOf(",")+1);return _?(Dx+=1,{id:`att${Dx}`,mediaType:g,data:_,previewUrl:b}):null}async function aw(s){if(typeof createImageBitmap=="function")try{const l=await createImageBitmap(s);return{image:l,width:l.width,height:l.height}}catch{}return new Promise(l=>{const r=URL.createObjectURL(s),c=new Image;c.onload=()=>{URL.revokeObjectURL(r),l({image:c,width:c.naturalWidth,height:c.naturalHeight})},c.onerror=()=>{URL.revokeObjectURL(r),l(null)},c.src=r})}function Vy({disabled:s,busy:l,commands:r,sessionTitle:c,contextResult:o,className:d,placeholder:h,draftKey:m,sendLabel:g="Отправить",autoFocus:b=!1,attachmentsEnabled:_=!0,onContextSearch:S,onCommand:v,onSend:E,onInterrupt:T,onEscape:C}){var He;const L=Xf(QS),[X,J]=y.useState(()=>m?Lh(m):""),[G,O]=y.useState(!1),[Z,M]=y.useState(0),D=y.useRef(null),H=y.useRef(null),ne=y.useRef(null),[he,W]=y.useState(()=>m?Lh(m).length:0),[ue,je]=y.useState([]),Me=y.useRef(null),Ce=y.useCallback(B=>{!_||B.length===0||Promise.all(B.map(sw)).then(P=>{const _e=P.filter(Be=>Be!==null);_e.length!==0&&je(Be=>[...Be,..._e].slice(0,ew))})},[_]);function A(B){je(P=>P.filter(_e=>_e.id!==B))}function ce(B){var Be;if(!_)return;const P=(Be=B.clipboardData)==null?void 0:Be.items;if(!P)return;const _e=[];for(const Ot of P){if(!Ot.type.startsWith("image/"))continue;const fl=Ot.getAsFile();fl&&_e.push(fl)}_e.length!==0&&(B.preventDefault(),Ce(_e))}function z(B){const P=B.target.files?Array.from(B.target.files):[];B.target.value="",Ce(P)}y.useEffect(()=>{_||je([])},[_]);const[be,ye]=y.useState([]),[N,V]=y.useState(-1),re=y.useRef(""),[me,Ne]=y.useState(""),ve=VS(y.useCallback((B,P)=>{B&&J(_e=>Fh(_e,B)),Ne(P.trim())},[])),De=me?Fh(X,me):X;y.useEffect(()=>{ve.listening||me===""||(J(B=>Fh(B,me)),Ne(""))},[ve.listening,me]),y.useEffect(()=>{var B;b&&((B=D.current)==null||B.focus())},[b]);const yt=y.useRef(new Map),Xe=y.useRef(new Map),$e=y.useRef(m),Ve=y.useRef({text:X,caret:he});Ve.current={text:X,caret:he};const It=y.useCallback((B,P,_e)=>{P===""?(yt.current.delete(B),Xe.current.delete(B)):(yt.current.set(B,P),Xe.current.set(B,_e)),iy(B,P)},[]),rt=ve.drop;y.useLayoutEffect(()=>{const B=$e.current;if(B===m)return;$e.current=m,B&&It(B,Ve.current.text,Ve.current.caret);const P=m?yt.current.get(m)??Lh(m):"",_e=m?Xe.current.get(m):void 0,Be=Math.min(_e??P.length,P.length);J(P),W(Be),ne.current=[Be,Be],Ne(""),M(0),O(!1),V(-1),re.current="",je([]),rt()},[m,It,rt]),y.useEffect(()=>{m&&It(m,X,he)},[m,X,he,It]);const dn=s?"Выберите сессию":h??"Опишите задачу… («/» — команды, «@» — файлы)",ft=y.useRef(0),hn=y.useCallback(B=>{const P=parseFloat(getComputedStyle(B).maxHeight),_e=Number.isFinite(P)&&P>0?P:PS;B.style.height="auto";const Be=B.scrollHeight;B.style.height=`${Math.min(Be,_e)}px`,B.style.overflowY=Be>_e?"auto":"hidden"},[]);y.useEffect(()=>{const B=D.current;B&&hn(B)},[De,dn,s,hn]),y.useLayoutEffect(()=>{const B=D.current,P=ne.current;!B||!P||(ne.current=null,B.setSelectionRange(P[0],P[1]))}),y.useEffect(()=>{const B=D.current;if(!B)return;const P=new ResizeObserver(([_e])=>{const Be=_e==null?void 0:_e.contentRect.width;Be===void 0||Math.abs(Be-ft.current)<1||(ft.current=Be,hn(B))});return P.observe(B),()=>P.disconnect()},[hn]);const Sn=ve.stop;y.useEffect(()=>{s&&Sn()},[s,Sn]);const xn=y.useMemo(()=>ve.error?{ok:!1,message:ve.error}:null,[ve.error]),en=y.useMemo(()=>{var _e;const B=(_e=Mx.exec(X))==null?void 0:_e[1];if(B===void 0)return[];const P=B.toLowerCase();return r.filter(Be=>!ZS(Be)&&Jh(Be,P)<Qy).sort((Be,Ot)=>Jh(Be,P)-Jh(Ot,P))},[X,r]),tt=!G&&en.length>0,et=Math.min(Z,en.length-1),tn=G?null:((He=Rx.exec(De.slice(0,he)))==null?void 0:He[1])??null,Xt=y.useRef(S);Xt.current=S,y.useEffect(()=>{if(tn===null||tn===""||tn.endsWith("/")){Xt.current(tn);return}const B=setTimeout(()=>Xt.current(tn),JS);return()=>clearTimeout(B)},[tn]);const nt=tn!==null&&(o==null?void 0:o.query)===tn,St=nt?o.entries:[],$t=tn!==null,cn=$t&&!nt,wt=Math.min(Z,Math.max(St.length-1,0));y.useEffect(()=>{var P,_e;if(!tt&&!$t)return;const B=tt?et:wt;(_e=(P=H.current)==null?void 0:P.children[B])==null||_e.scrollIntoView({block:"nearest"})},[tt,$t,et,wt]);function yn(B,P){var _e;J(B),W(P),ne.current=[P,P],M(0),O(!1),me!==""&&(Ne(""),ve.drop()),(_e=D.current)==null||_e.focus()}function qt(){J(""),Ne(""),M(0),W(0),O(!1),V(-1),re.current="",je([]),ve.drop(),m&&It(m,"",0)}function pn(B){const P=B.trim();P===""&&ue.length===0||s||(E(P,ue.length>0?ue.map(_e=>({mediaType:_e.mediaType,data:_e.data})):void 0),P!==""&&ye(_e=>[P,..._e.filter(Be=>Be!==P)].slice(0,WS)),qt())}function Dn(B){if(B<-1||B>=be.length)return;N===-1&&(re.current=X);const P=B===-1?re.current:be[B]??"";V(B),yn(P,P.length)}function Gt(){var Be;const B=((Be=D.current)==null?void 0:Be.selectionStart)??De.length,_e=`${B>0&&!/\s$/.test(De.slice(0,B))?" ":""}@`;yn(De.slice(0,B)+_e+De.slice(B),B+_e.length)}function ct(B){var Ot;const P=(Ot=Rx.exec(De.slice(0,he)))==null?void 0:Ot[1];if(P===void 0)return;const _e=he-P.length-1,Be=B.kind==="dir"?`@${B.path}/`:`@${B.path} `;yn(De.slice(0,_e)+Be+De.slice(he),_e+Be.length)}function Et(){var P;const B=(P=Mx.exec(De.trim()))==null?void 0:P[1];if(B&&v(B)){qt();return}pn(De)}function Pe(B,P){J(B),W(P),M(0),O(!1),V(-1),me!==""&&(Ne(""),ve.drop())}function wl(B){var Be;const P=FS.has(B.name)?c:null,_e=`/${B.name} `;J(_e+(P??"")),W(_e.length+((P==null?void 0:P.length)??0)),P&&(ne.current=[_e.length,_e.length+P.length]),M(0),(Be=D.current)==null||Be.focus()}function le(B){if(v(B.name)){J(""),M(0),O(!1);return}B.argumentHint?wl(B):pn(`/${B.name}`)}function ge(B){if(tt){if(B.key==="ArrowDown")return B.preventDefault(),M(P=>(Math.min(P,en.length-1)+1)%en.length);if(B.key==="ArrowUp"){B.preventDefault();const P=en.length-1;return M(_e=>(Math.min(_e,P)+P)%en.length)}if(B.key==="Enter"&&!B.shiftKey){B.preventDefault();const P=en[et];P&&le(P);return}if(B.key==="Tab"){B.preventDefault();const P=en[et];P&&wl(P);return}if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),O(!0);return}}if($t){if(B.key==="ArrowDown"&&St.length>0)return B.preventDefault(),M(P=>(Math.min(P,St.length-1)+1)%St.length);if(B.key==="ArrowUp"&&St.length>0){B.preventDefault();const P=St.length-1;return M(_e=>(Math.min(_e,P)+P)%St.length)}if(B.key==="Enter"&&!B.shiftKey||B.key==="Tab"){const P=St[wt];if(P){B.preventDefault(),ct(P);return}if(B.key==="Tab")return}if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),O(!0);return}}if((B.key==="ArrowUp"||B.key==="ArrowDown")&&!B.shiftKey){const P=B.currentTarget,_e=P.selectionStart;if(P.selectionEnd===_e){const Ot=B.key==="ArrowUp"?N+1:N-1;Ot>=-1&&Ot<be.length&&requestAnimationFrame(()=>{P.selectionStart===_e&&P.selectionEnd===_e&&Dn(Ot)})}}if(B.key==="Escape"&&C){B.preventDefault(),B.stopPropagation(),C();return}B.key==="Enter"&&!B.shiftKey&&!L&&(B.preventDefault(),Et())}return i.jsx("div",{className:d?`composer ${d}`:"composer",children:i.jsxs("div",{className:"composer__inner",children:[i.jsx(mr,{result:xn}),$t&&!tt&&i.jsxs("div",{className:"cmdmenu",role:"listbox",ref:H,children:[St.map((B,P)=>i.jsxs("button",{role:"option","aria-selected":P===wt,className:P===wt?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>M(P),onMouseDown:_e=>{_e.preventDefault(),ct(B)},children:[i.jsxs("span",{className:"cmdmenu__name",children:[B.name,B.kind==="dir"?"/":""]}),i.jsx("span",{className:"cmdmenu__desc",children:B.path}),B.ignored&&i.jsx("span",{className:"cmdmenu__tag",children:"git-ignore"})]},B.path)),St.length===0&&i.jsx("div",{className:"cmdmenu__empty",children:cn?"ищем…":tn?"Ничего не нашлось":"Наберите имя файла или каталога"})]}),tt&&i.jsx("div",{className:"cmdmenu",role:"listbox",ref:H,children:en.map((B,P)=>i.jsxs("button",{role:"option","aria-selected":P===et,className:P===et?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>M(P),onMouseDown:_e=>{_e.preventDefault(),le(B)},children:[i.jsxs("span",{className:"cmdmenu__name",children:["/",B.name]}),B.argumentHint&&i.jsx("span",{className:"cmdmenu__hint",children:B.argumentHint}),i.jsx("span",{className:"cmdmenu__desc",children:B.description})]},B.name))}),ue.length>0&&i.jsx("div",{className:"composer__attachments",children:ue.map(B=>i.jsxs("div",{className:"composer__thumb",children:[i.jsx("img",{src:B.previewUrl,alt:"Вложение"}),i.jsx("button",{type:"button",className:"composer__thumb-remove","aria-label":"Удалить вложение",onClick:()=>A(B.id),children:i.jsx(fw,{})})]},B.id))}),i.jsxs("div",{className:"composer__field",children:[i.jsx("button",{type:"button",className:"addbtn",title:"Добавить контекст — файл проекта («@»)","aria-label":"Добавить контекст",disabled:s,onClick:Gt,children:i.jsx(cw,{})}),_&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Me,type:"file",accept:"image/*",multiple:!0,className:"composer__fileinput",tabIndex:-1,"aria-hidden":"true",onChange:z}),i.jsx("button",{type:"button",className:"attachbtn",title:"Прикрепить изображение","aria-label":"Прикрепить изображение",disabled:s,onClick:()=>{var B;return(B=Me.current)==null?void 0:B.click()},children:i.jsx(uw,{})})]}),i.jsx("textarea",{ref:D,value:De,disabled:s,placeholder:dn,onChange:B=>Pe(B.target.value,B.target.selectionStart),onSelect:B=>W(B.currentTarget.selectionStart),onKeyDown:ge,onPaste:ce}),ve.supported&&i.jsx("button",{type:"button",className:ve.listening?"micbtn is-on":"micbtn",title:ve.listening?"Остановить диктовку":"Продиктовать промпт","aria-label":ve.listening?"Остановить диктовку":"Продиктовать промпт","aria-pressed":ve.listening,disabled:s,onClick:ve.toggle,children:i.jsx(dw,{on:ve.listening})}),l?i.jsx("button",{className:"btn",onClick:T,title:"Прервать (Esc)",children:"Стоп"}):i.jsxs("button",{className:"btn btn--primary sendbtn",onClick:Et,disabled:s||De.trim()===""&&ue.length===0,"aria-label":g,title:g,children:[i.jsx("span",{className:"sendbtn__label",children:g}),i.jsx(ow,{})]})]})]})})}function Fh(s,l){const r=l.trim();if(r==="")return s;const c=mp(r).slice(iw(s,r)).join(" ");return c===""?s:s===""||/\s$/.test(s)?s+c:`${s} ${c}`}function iw(s,l){const r=mp(s),c=mp(l);for(let o=Math.min(r.length,c.length);o>0;o--)if(r.slice(r.length-o).every((d,h)=>rw(d,c[h]??"")))return o;return 0}function mp(s){return s.split(/\s+/).filter(l=>l!=="")}function rw(s,l){const r=c=>c.toLowerCase().replace(/[.,!?;:…]+$/u,"");return r(s)===r(l)}function cw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 3.4v9.2M3.4 8h9.2"})})}function ow(){return i.jsx("svg",{className:"sendbtn__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 12.5V3.5M4 7.5 8 3.5l4 4"})})}function uw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M10.8 4.2 5.9 9.1a2 2 0 0 0 2.8 2.8l4.6-4.6a3.3 3.3 0 0 0-4.7-4.7L3.9 7.3a4.6 4.6 0 0 0 6.5 6.5l4.4-4.4"})})}function fw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})}function dw({on:s}){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"5.9",y:"1.7",width:"4.2",height:"7.6",rx:"2.1",fill:s?"currentColor":"none"}),i.jsx("path",{d:"M3.3 7.3v.8a4.7 4.7 0 0 0 9.4 0v-.8"}),i.jsx("path",{d:"M8 12.8v1.5"})]})}const Qy=4;function Jh(s,l){const r=s.name.toLowerCase();return r===l?0:r.startsWith(l)?1:s.aliases.some(c=>c.toLowerCase().startsWith(l))?2:r.includes(l)?3:Qy}function hw({request:s,queued:l,onDecide:r}){const c=Xy(s.toolName,s.input);return i.jsx("div",{className:"modal-backdrop modal-backdrop--sheet",children:i.jsxs("div",{className:"sheet",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"sheet__head",children:["Разрешить действие?",l>0&&` (ещё ${l} в очереди)`]}),i.jsxs("div",{className:"sheet__body",children:[i.jsx("div",{className:"sheet__tool",children:s.toolName}),s.reason&&i.jsx("p",{className:"sheet__reason",children:s.reason}),c?i.jsx(Dp,{diff:c}):i.jsx("pre",{className:"code",children:JSON.stringify(s.input,null,2)})]}),i.jsxs("div",{className:"sheet__actions",children:[i.jsx("button",{className:"btn",onClick:()=>r(s.requestId,"deny"),children:"Отклонить"}),i.jsx("button",{className:"btn btn--warn",autoFocus:!0,onClick:()=>r(s.requestId,"allow"),children:"Разрешить"})]})]})})}function pw({request:s,queued:l,onAnswer:r,onDecline:c}){const{questions:o}=s,[d,h]=y.useState(()=>o.map(()=>new Set)),[m,g]=y.useState(()=>o.map(()=>"")),[b,_]=y.useState(()=>Ox(o));y.useEffect(()=>{h(o.map(()=>new Set)),g(o.map(()=>"")),_(Ox(o))},[s.requestId]);const S=y.useMemo(()=>gw(o,d,m),[o,d,m]),v=S!==null;function E(G,O){var Z,M;(M=(Z=o[G])==null?void 0:Z.options[O])!=null&&M.preview&&_(D=>{const H=D.slice();return H[G]=O,H})}function T(G,O,Z){h(M=>{const D=M.slice(),H=new Set(D[G]);return Z?H.has(O)?H.delete(O):H.add(O):H.has(O)||(H.clear(),H.add(O)),D[G]=H,D}),O!=="other"&&E(G,O)}function C(G,O){g(Z=>{const M=Z.slice();return M[G]=O,M})}function L(){S&&r(s.requestId,S)}function X(G){G.key==="Enter"&&(G.target.closest("button")||v&&(G.preventDefault(),L()))}function J(G){var D;if(!["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(G.key))return;const O=Array.from(G.currentTarget.querySelectorAll("button.qsheet__option")),Z=O.indexOf(document.activeElement);if(Z===-1)return;G.preventDefault();const M=G.key==="ArrowDown"||G.key==="ArrowRight"?1:-1;(D=O[(Z+M+O.length)%O.length])==null||D.focus()}return i.jsx("div",{className:"modal-backdrop modal-backdrop--sheet",children:i.jsxs("div",{className:"qsheet",role:"dialog","aria-modal":"true","aria-label":"Вопрос от Claude",onKeyDown:X,children:[i.jsxs("div",{className:"qsheet__head",children:[i.jsx("span",{className:"qsheet__head-icon","aria-hidden":"true",children:"?"}),i.jsxs("span",{children:[o.length===1?"Уточняющий вопрос":`Уточняющие вопросы (${o.length})`,l>0&&` — ещё ${l} в очереди`]})]}),i.jsxs("div",{className:"qsheet__body",children:[s.reason&&i.jsx("p",{className:"qsheet__reason",children:s.reason}),o.map((G,O)=>i.jsx(mw,{q:G,qi:O,selected:d[O]??new Set,otherText:m[O]??"",previewIndex:b[O]??null,onToggle:T,onFocusOption:E,onOtherText:C,onOptionsKeyDown:J},O))]}),i.jsxs("div",{className:"qsheet__actions",children:[i.jsx("button",{className:"btn",onClick:()=>c(s.requestId),children:"Не отвечать"}),i.jsx("button",{className:"btn btn--primary",disabled:!v,onClick:L,children:"Ответить"})]})]})})}function mw({q:s,qi:l,selected:r,otherText:c,previewIndex:o,onToggle:d,onFocusOption:h,onOtherText:m,onOptionsKeyDown:g}){var E;const b=s.options.some(T=>T.preview),_=o!==null?(E=s.options[o])==null?void 0:E.preview:void 0,S=r.has("other"),v=s.multiSelect?"checkbox":"radio";return i.jsxs("div",{className:"qsheet__question",children:[i.jsxs("div",{className:"qsheet__qhead",children:[i.jsx("span",{className:"chip chip--accent",children:s.header}),i.jsx("span",{className:"qsheet__qtext",children:s.question})]}),i.jsxs("div",{className:"qsheet__options"+(s.multiSelect?"":" qsheet__options--radio"),role:s.multiSelect?"group":"radiogroup","aria-label":s.question,onKeyDown:g,children:[s.options.map((T,C)=>{const L=r.has(C);return i.jsxs("button",{type:"button",role:v,"aria-checked":L,className:"qsheet__option"+(L?" is-selected":""),onClick:()=>d(l,C,s.multiSelect),onFocus:()=>h(l,C),onMouseEnter:()=>h(l,C),children:[i.jsx("span",{className:"qsheet__opt-mark","aria-hidden":"true"}),i.jsxs("span",{className:"qsheet__opt-body",children:[i.jsx("span",{className:"qsheet__opt-label",children:T.label}),i.jsx("span",{className:"qsheet__opt-desc",children:T.description})]})]},C)}),i.jsxs("div",{className:"qsheet__other",children:[i.jsxs("button",{type:"button",role:v,"aria-checked":S,className:"qsheet__option qsheet__option--other"+(S?" is-selected":""),onClick:()=>d(l,"other",s.multiSelect),children:[i.jsx("span",{className:"qsheet__opt-mark","aria-hidden":"true"}),i.jsxs("span",{className:"qsheet__opt-body",children:[i.jsx("span",{className:"qsheet__opt-label",children:"Другое"}),i.jsx("span",{className:"qsheet__opt-desc",children:"Свой вариант ответа"})]})]}),S&&i.jsx("input",{type:"text",className:"qsheet__other-input",placeholder:"Впишите свой вариант…","aria-label":`Свой вариант ответа на вопрос «${s.question}»`,value:c,onChange:T=>m(l,T.target.value),autoFocus:!0})]})]}),b&&i.jsx("pre",{className:"qsheet__preview",children:_??""})]})}function Ox(s){return s.map(l=>{const r=l.options.findIndex(c=>c.preview);return r===-1?null:r})}function gw(s,l,r){const c={};for(let o=0;o<s.length;o++){const d=s[o];if(!d)continue;const h=l[o]??new Set,m=[];for(let g=0;g<d.options.length;g++){const b=d.options[g];b&&h.has(g)&&m.push(b.label)}if(h.has("other")){const g=(r[o]??"").trim();g&&m.push(g)}if(m.length===0)return null;c[d.question]=m.join(", ")}return c}function bw({request:s,plan:l,queued:r,onAccept:c,onDecline:o}){const[d,h]=y.useState(l),[m,g]=y.useState("preview");y.useEffect(()=>{h(l),g("preview")},[s.requestId,l]);const b=d.trim().length>0;function _(){b&&c(s.requestId,d)}return i.jsx("div",{className:"modal-backdrop modal-backdrop--sheet",children:i.jsxs("div",{className:"plansheet",role:"dialog","aria-modal":"true","aria-label":"План агента",children:[i.jsxs("div",{className:"plansheet__head",children:[i.jsx("span",{className:"plansheet__head-icon","aria-hidden":"true",children:i.jsx(yw,{})}),i.jsxs("span",{className:"plansheet__head-text",children:["План на согласование",r>0&&` — ещё ${r} в очереди`]}),i.jsxs("div",{className:"plansheet__viewtoggle",role:"tablist","aria-label":"Режим просмотра",children:[i.jsx("button",{className:"btn btn--sm"+(m==="preview"?" is-on":""),role:"tab","aria-selected":m==="preview",onClick:()=>g("preview"),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(m==="source"?" is-on":""),role:"tab","aria-selected":m==="source",onClick:()=>g("source"),children:"Код"})]})]}),i.jsxs("div",{className:"plansheet__body",children:[s.reason&&i.jsx("p",{className:"plansheet__reason",children:s.reason}),i.jsx("div",{className:"plansheet__content",children:m==="preview"?i.jsx(xw,{text:d}):i.jsx("textarea",{className:"plansheet__source",value:d,onChange:S=>h(S.target.value),spellCheck:!1,"aria-label":"Текст плана — можно отредактировать перед тем, как согласиться",autoFocus:!0})})]}),i.jsxs("div",{className:"plansheet__actions",children:[i.jsx("button",{className:"btn",onClick:()=>o(s.requestId),children:"Доработать"}),i.jsx("button",{className:"btn btn--ok",disabled:!b,autoFocus:!0,onClick:_,children:"Одобрить план"})]})]})})}function xw({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return Qf(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview plansheet__preview",dangerouslySetInnerHTML:{__html:l}})}function yw(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M4.4 2.5h5.6L13 5.5v7.4a.6.6 0 0 1-.6.6H4.4a.6.6 0 0 1-.6-.6V3.1a.6.6 0 0 1 .6-.6Z"}),i.jsx("path",{d:"M9.5 2.5v2.5a.5.5 0 0 0 .5.5h3"}),i.jsx("path",{d:"M5.6 8.6 7 10l3-3.2"})]})}function _w(s,l){if(s!=="ExitPlanMode"||!l||typeof l!="object")return null;const r=l.plan;return typeof r=="string"?r:null}function Ky({path:s}){const[l,r]=y.useState(!1),[c,o]=y.useState(!1),d=y.useRef(null);y.useEffect(()=>{if(!l)return;function m(g){var b;(b=d.current)!=null&&b.contains(g.target)||r(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),y.useEffect(()=>{if(!c)return;const m=setTimeout(()=>o(!1),Mp);return()=>clearTimeout(m)},[c]),y.useEffect(()=>r(!1),[s]);async function h(){await vc(s)&&o(!0)}return i.jsxs("div",{ref:d,className:"cwd",children:[i.jsxs("button",{type:"button",className:"cwd__toggle","aria-expanded":l,title:l?"Свернуть путь":`Полный путь: ${s}`,onClick:()=>r(m=>!m),onKeyDown:m=>{m.key!=="Escape"||!l||(m.preventDefault(),m.stopPropagation(),r(!1))},children:[i.jsx(vw,{open:l}),i.jsx("span",{className:"cwd__short",children:s})]}),l&&i.jsxs("div",{className:"cwd__pop",children:[i.jsx("span",{className:"cwd__full",children:s}),i.jsx("button",{type:"button",className:"btn btn--ghost cwd__copy",onClick:()=>void h(),children:c?fc:dr})]})]})}function vw({open:s}){return i.jsx("svg",{className:s?"cwd__chev cwd__chev--open":"cwd__chev",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M6 3.5 10.5 8 6 12.5"})})}const jw=["low","medium","high"];function Zy({models:s,value:l,effort:r,ultracode:c,thinking:o,switchOnFlag:d,showSwitchOnFlag:h=!0,className:m,onModel:g,onEffort:b,onUltracode:_,onThinking:S,onSwitchOnFlag:v}){const[E,T]=y.useState(!1),[C,L]=y.useState(0),X=y.useRef(null),J=y.useRef(null),G=s.find(H=>H.value===l)??null,O=G&&G.supportsEffort?G.effortLevels.length>0?G.effortLevels:jw:[],Z=O.includes("xhigh");y.useEffect(()=>{if(!E)return;const H=s.findIndex(ne=>ne.value===l);L(H===-1?0:H)},[E]),y.useEffect(()=>{if(!E)return;function H(ne){var he;(he=X.current)!=null&&he.contains(ne.target)||T(!1)}return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[E]),y.useEffect(()=>{var H,ne;E&&((ne=(H=J.current)==null?void 0:H.querySelector(".is-cursor"))==null||ne.scrollIntoView({block:"nearest"}))},[E,C]);function M(H){T(!1),H.value!==l&&g(H.value)}function D(H){if(H.key==="Escape"){if(!E)return;H.preventDefault(),H.stopPropagation(),T(!1);return}if(H.key==="ArrowDown"||H.key==="ArrowUp"){if(H.preventDefault(),!E)return T(!0);if(s.length===0)return;const ne=H.key==="ArrowDown"?1:s.length-1;return L(he=>(he+ne)%s.length)}if(H.key==="Enter"||H.key===" "){if(H.preventDefault(),!E)return T(!0);const ne=s[C];ne&&M(ne)}}return i.jsxs("div",{ref:X,className:"select"+(E?" select--open":"")+(m?` ${m}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:"Модель, усилие и размышления","aria-label":"Модель, усилие и размышления","aria-haspopup":"menu","aria-expanded":E,onClick:()=>T(H=>!H),onKeyDown:D,children:[(G==null?void 0:G.displayName)??l?i.jsx("span",{className:"select__value",children:(G==null?void 0:G.displayName)??l}):i.jsx("span",{className:"select__value select__value--muted",children:"по умолчанию"}),c?i.jsx("span",{className:"select__suffix select__suffix--hot",children:"ultracode"}):O.length>0&&r&&i.jsx("span",{className:"select__suffix",children:r}),i.jsx(Sw,{})]}),E&&i.jsxs("div",{ref:J,className:"select__menu modelmenu",role:"menu",children:[i.jsx("div",{className:"modelmenu__head",children:"Модель"}),s.map((H,ne)=>i.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":H.value===l,className:"select__option"+(ne===C?" is-cursor":"")+(H.value===l?" is-on":""),onMouseEnter:()=>L(ne),onClick:()=>M(H),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:H.value===l?"✓":""}),i.jsx("span",{className:"select__label",children:H.displayName}),H.description&&i.jsx("span",{className:"select__hint",children:H.description})]},H.value)),O.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"modelmenu__sep",role:"separator"}),i.jsxs("div",{className:"modelmenu__row",children:[i.jsxs("span",{className:"modelmenu__label",children:["Усилие",i.jsx("span",{className:"modelmenu__desc",children:"насколько усердно модель думает"})]}),i.jsx("span",{className:"modelmenu__levels",children:O.map(H=>i.jsx("button",{type:"button",role:"menuitemradio","aria-checked":H===r,className:H===r?"modelmenu__level is-on":"modelmenu__level",onClick:()=>b(H),children:H},H))})]}),Z&&i.jsx(Wh,{label:"Ultracode",desc:"xhigh и постоянная оркестрация подагентами",on:c,onToggle:()=>_(!c)})]}),i.jsx("div",{className:"modelmenu__sep",role:"separator"}),(G==null?void 0:G.supportsThinking)!==!1&&i.jsx(Wh,{label:"Размышления",desc:"расширенное обдумывание перед ответом",on:o,onToggle:()=>S(!o)}),h&&i.jsx(Wh,{label:"Менять модель по флагу",desc:"иначе помеченный ход встаёт на паузу",on:d,onToggle:()=>v(!d)})]})]})}function Wh({label:s,desc:l,on:r,onToggle:c}){return i.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":r,className:"modelmenu__row modelmenu__row--btn",onClick:c,children:[i.jsxs("span",{className:"modelmenu__label",children:[s,i.jsx("span",{className:"modelmenu__desc",children:l})]}),i.jsx("span",{className:r?"switch is-on":"switch","aria-hidden":"true",children:i.jsx("span",{className:"switch__knob"})})]})}function Sw(){return i.jsx("svg",{className:"select__chev",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M3 4.5 6 7.5 9 4.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Sl({title:s,children:l,actions:r,className:c,sheet:o=!1,onClose:d}){const h=y.useRef(null);return y.useEffect(()=>{function m(g){if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),d();return}if(g.key!=="Tab")return;const b=h.current;if(!b)return;const _=b.querySelectorAll('button, input, textarea, select, a[href], [tabindex]:not([tabindex="-1"])'),S=_[0],v=_[_.length-1];!S||!v||(g.shiftKey&&document.activeElement===S?(g.preventDefault(),v.focus()):!g.shiftKey&&document.activeElement===v&&(g.preventDefault(),S.focus()))}return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[d]),i.jsx("div",{className:o?"modal-backdrop modal-backdrop--sheet":"modal-backdrop",onMouseDown:m=>{m.target===m.currentTarget&&d()},children:i.jsxs("div",{ref:h,className:c?`modal ${c}`:"modal",role:"dialog","aria-modal":"true","aria-label":s,children:[i.jsxs("div",{className:"modal__head",children:[i.jsx("h2",{className:"modal__title",children:s}),i.jsx("button",{className:"modal__close","aria-label":"Закрыть",onClick:d,children:"✕"})]}),i.jsx("div",{className:"modal__body",children:l}),r&&i.jsx("div",{className:"modal__actions",children:r})]})})}function ww({candidates:s,searching:l,agentItems:r,agentBusy:c,error:o,roots:d,created:h,onSearch:m,onAskAgent:g,onInterrupt:b,onSubmit:_,onCreate:S,onClose:v}){const[E,T]=y.useState("open"),[C,L]=y.useState(""),[X,J]=y.useState(!1),[G,O]=y.useState(""),[Z,M]=y.useState(""),[D,H]=y.useState({git:!0,claudeMd:!0,readme:!0}),ne=C.trim(),he=ne!=="",W=G.trim(),ue=Z.trim(),je=W!==""&&ue!=="";y.useEffect(()=>{G===""&&d.length>0&&O(d[0])},[d]);const Me=y.useRef(m);Me.current=m,y.useEffect(()=>{if(E!=="open")return;const z=C.trim(),be=setTimeout(()=>Me.current(z),200);return()=>clearTimeout(be)},[C,E]);function Ce(){he&&_(ne)}function A(){je&&S(W,ue,D)}function ce(){he&&(J(!0),g(ne))}return h?i.jsxs(Sl,{title:"Новый проект",onClose:v,actions:i.jsx("button",{className:"btn btn--primary",onClick:v,autoFocus:!0,children:"Понятно"}),children:[i.jsx("p",{className:"modal__text",children:"Каталог создан и открыт как проект, но часть шагов не удалась."}),i.jsx("p",{className:"newproj__preview",children:h.path}),i.jsx("div",{className:"modal__error",children:i.jsx("ul",{className:"newproj__warnings",children:h.warnings.map(z=>i.jsx("li",{children:z},z))})}),i.jsx("p",{className:"modal__text modal__text--dim",children:"Проект открыт и работает — недостающее можно добавить руками, в дереве файлов или из терминала."})]}):i.jsxs(Sl,{title:"Новый проект",className:X&&E==="open"?"modal--wide":void 0,onClose:v,actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:v,children:"Отмена"}),E==="open"?i.jsxs(i.Fragment,{children:[c?i.jsx("button",{className:"btn",onClick:b,children:"Остановить"}):i.jsx("button",{className:"btn",disabled:!he,onClick:ce,title:"Найти по описанию",children:"Попросить агента"}),i.jsx("button",{className:"btn btn--primary",disabled:!he,onClick:Ce,children:"Открыть"})]}):i.jsx("button",{className:"btn btn--primary",disabled:!je,onClick:A,children:"Создать"})]}),children:[i.jsxs("div",{className:"tabs",children:[i.jsx(Lx,{label:"Открыть",on:E==="open",onClick:()=>T("open")}),i.jsx(Lx,{label:"Создать",on:E==="create",onClick:()=>T("create")})]}),E==="open"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"modal__text",children:"Каталог, в котором будет работать агент. Введите путь или часть имени — подходящие каталоги появятся ниже."}),i.jsx("label",{className:"field",htmlFor:"workspace-path",children:"Путь или название"}),i.jsx("input",{id:"workspace-path",className:"input input--mono",value:C,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects\\my-app",onChange:z=>L(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),Ce())}}),o&&i.jsx("p",{className:"modal__error",children:o}),s.length>0&&i.jsx("ul",{className:"finds",children:s.map(z=>i.jsx("li",{children:i.jsxs("button",{className:"find",disabled:z.open,title:z.open?"Этот проект уже открыт":z.path,onClick:()=>L(z.path),onDoubleClick:()=>_(z.path),children:[i.jsx("span",{className:"find__name",children:z.name}),i.jsx("span",{className:"find__path",children:z.path}),i.jsx("span",{className:"find__note",children:Tw(z)})]})},z.path))}),s.length===0&&he&&!l&&!X&&i.jsx("p",{className:"modal__text modal__text--dim",children:"Ничего похожего среди каталогов, где вы работали. Если помните не имя, а суть проекта — опишите его и нажмите «Попросить агента». Проекта ещё нет вовсе — рядом вкладка «Создать»."}),X&&i.jsx("div",{className:"finds__agent",children:i.jsx(Op,{items:r,busy:c,waiting:!1,empty:"Агент ищет…"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"modal__text",children:"Пустой каталог для нового проекта. Дальше в нём работает агент — с первого промпта, без отдельной настройки."}),i.jsx("label",{className:"field",htmlFor:"workspace-parent",children:"Где создать"}),i.jsx("input",{id:"workspace-parent",className:"input input--mono",value:G,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects",onChange:z=>O(z.target.value)}),d.length>0&&i.jsx("div",{className:"newproj__roots",children:d.map(z=>i.jsx("button",{type:"button",className:z===W?"newproj__root is-on":"newproj__root",title:z,onClick:()=>O(z),children:Nw(z)},z))}),i.jsx("label",{className:"field newproj__field",htmlFor:"workspace-name",children:"Имя проекта"}),i.jsx("input",{id:"workspace-name",className:"input input--mono",value:Z,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"my-app",onChange:z=>M(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),A())}}),i.jsx("p",{className:"newproj__preview",children:je?kw(W,ue):"Каталог появится здесь"}),o&&i.jsx("p",{className:"modal__error",children:o}),i.jsxs("div",{className:"newproj__opts",children:[i.jsx(Ph,{label:"git init",desc:"панель истории работает сразу",on:D.git,onToggle:()=>H(z=>({...z,git:!z.git}))}),i.jsx(Ph,{label:"CLAUDE.md",desc:"заготовка инструкций для агента",on:D.claudeMd,onToggle:()=>H(z=>({...z,claudeMd:!z.claudeMd}))}),i.jsx(Ph,{label:"README.md",desc:"по нему проект потом узнаёт поиск",on:D.readme,onToggle:()=>H(z=>({...z,readme:!z.readme}))})]})]})]})}function Lx({label:s,on:l,onClick:r}){return i.jsx("button",{type:"button",className:l?"tabs__tab is-on":"tabs__tab","aria-pressed":l,onClick:r,children:s})}function Ph({label:s,desc:l,on:r,onToggle:c}){return i.jsxs("button",{type:"button",role:"checkbox","aria-checked":r,className:"newproj__opt",onClick:c,children:[i.jsxs("span",{className:"newproj__optlabel",children:[s,i.jsx("span",{className:"newproj__optdesc",children:l})]}),i.jsx("span",{className:r?"switch is-on":"switch","aria-hidden":"true",children:i.jsx("span",{className:"switch__knob"})})]})}function kw(s,l){const r=s.includes("\\")?"\\":"/";return s.replace(/[\\/]+$/,"")+r+l}function Nw(s){const l=s.includes("\\")?"\\":"/",r=s.split(/[\\/]/).filter(Boolean);return r.length<=2?s:`…${l}${r.slice(-2).join(l)}`}function Tw(s){return s.open?"уже открыт":s.why?s.why:s.sessions===0?"рядом с вашими проектами":`${Ew(s.sessions)}${Cw(s.lastUsedAt)}`}function Ew(s){const l=s%10,r=s%100;return r>=11&&r<=14?`${s} сессий`:l===1?`${s} сессия`:l>=2&&l<=4?`${s} сессии`:`${s} сессий`}function Cw(s){if(!s)return"";const l=Math.floor((Date.now()-s)/864e5);return l<=0?" · сегодня":l===1?" · вчера":l<30?` · ${l} дн. назад`:` · ${new Date(s).toLocaleDateString("ru-RU")}`}const Lp=7;function Aw(s){const l=[],r=[];let c=1;for(const o of s){const d=l.slice();let h=l.indexOf(o.hash);h===-1&&(h=zx(l),l[h]=o.hash);const[m,...g]=o.parents;l[h]=m??null;const b=[];m!==void 0&&b.push({from:h,to:h});for(const v of g){let E=l.indexOf(v);E===-1&&(E=zx(l),l[E]=v),b.push({from:h,to:E})}const _=[];for(let v=0;v<d.length;v++)d[v]===o.hash&&(_.push({from:v,to:h}),v!==h&&(l[v]=null));const S=[];for(let v=0;v<d.length;v++){const E=d[v];!E||E===o.hash||v===h||l[v]===E&&S.push(v)}Mw(l),c=Math.max(c,l.length,h+1),r.push({commit:o,col:h,up:_,down:b,through:S})}return{rows:r,columns:Math.min(c,Lp)}}function zx(s){const l=s.indexOf(null);return l!==-1?l:(s.push(null),s.length-1)}function Mw(s){for(;s.length>0&&s[s.length-1]===null;)s.pop()}const Fy=1500;function Rw(s){const l=[];let r=!1;for(const c of s.patch.split(`
|
|
117
|
+
`,v),T=E<0?S.length:E;if(T>v&&c(S.slice(v,T),_),E<0)break;o(),v=E+1}m=b}}X1(l,r,(b,_,S)=>{g(b,""),g(_,S)},d,h),g(h,"")}class V1{constructor(l,r,c){this.at=l,this.highlighters=r,this.span=c,this.class=""}startSpan(l,r){r!=this.class&&(this.flush(l),l>this.at&&(this.at=l),this.class=r)}flush(l){l>this.at&&this.class&&this.span(this.at,l,this.class)}highlightRange(l,r,c,o,d){let{type:h,from:m,to:g}=l;if(m>=c||g<=r)return;h.isTop&&(d=this.highlighters.filter(E=>!E.scope||E.scope(h)));let b=o,_=Q1(l)||Go.empty,S=Y1(d,_.tags);if(S&&(b&&(b+=" "),b+=S,_.mode==1&&(o+=(o?" ":"")+S)),this.startSpan(Math.max(r,m),b),_.opaque)return;let v=l.tree&&l.tree.prop(Pt.mounted);if(v&&v.overlay){let E=l.node.enter(v.overlay[0].from+m,1),T=this.highlighters.filter(L=>!L.scope||L.scope(v.tree.type)),C=l.firstChild();for(let L=0,X=m;;L++){let J=L<v.overlay.length?v.overlay[L]:null,G=J?J.from+m:g,O=Math.max(r,X),Z=Math.min(c,G);if(O<Z&&C)for(;l.from<Z&&(this.highlightRange(l,O,Z,o,d),this.startSpan(Math.min(Z,l.to),b),!(l.to>=G||!l.nextSibling())););if(!J||G>c)break;X=J.to+m,X>r&&(this.highlightRange(E.cursor(),Math.max(r,J.from+m),Math.min(c,X),"",T),this.startSpan(Math.min(c,X),b))}C&&l.parent()}else if(l.firstChild()){v&&(o="");do if(!(l.to<=r)){if(l.from>=c)break;this.highlightRange(l,r,c,o,d),this.startSpan(Math.min(c,l.to),b)}while(l.nextSibling());l.parent()}}}function Q1(s){let l=s.type.prop(Ry);for(;l&&l.context&&!s.matchContext(l.context);)l=l.next;return l||null}const Se=us.define,hf=Se(),Ti=Se(),px=Se(Ti),mx=Se(Ti),Ei=Se(),pf=Se(Ei),Xh=Se(Ei),Ps=Se(),er=Se(Ps),Ks=Se(),Zs=Se(),dp=Se(),Mo=Se(dp),mf=Se(),Te={comment:hf,lineComment:Se(hf),blockComment:Se(hf),docComment:Se(hf),name:Ti,variableName:Se(Ti),typeName:px,tagName:Se(px),propertyName:mx,attributeName:Se(mx),className:Se(Ti),labelName:Se(Ti),namespace:Se(Ti),macroName:Se(Ti),literal:Ei,string:pf,docString:Se(pf),character:Se(pf),attributeValue:Se(pf),number:Xh,integer:Se(Xh),float:Se(Xh),bool:Se(Ei),regexp:Se(Ei),escape:Se(Ei),color:Se(Ei),url:Se(Ei),keyword:Ks,self:Se(Ks),null:Se(Ks),atom:Se(Ks),unit:Se(Ks),modifier:Se(Ks),operatorKeyword:Se(Ks),controlKeyword:Se(Ks),definitionKeyword:Se(Ks),moduleKeyword:Se(Ks),operator:Zs,derefOperator:Se(Zs),arithmeticOperator:Se(Zs),logicOperator:Se(Zs),bitwiseOperator:Se(Zs),compareOperator:Se(Zs),updateOperator:Se(Zs),definitionOperator:Se(Zs),typeOperator:Se(Zs),controlOperator:Se(Zs),punctuation:dp,separator:Se(dp),bracket:Mo,angleBracket:Se(Mo),squareBracket:Se(Mo),paren:Se(Mo),brace:Se(Mo),content:Ps,heading:er,heading1:Se(er),heading2:Se(er),heading3:Se(er),heading4:Se(er),heading5:Se(er),heading6:Se(er),contentSeparator:Se(Ps),list:Se(Ps),quote:Se(Ps),emphasis:Se(Ps),strong:Se(Ps),link:Se(Ps),monospace:Se(Ps),strikethrough:Se(Ps),inserted:Se(),deleted:Se(),changed:Se(),invalid:Se(),meta:mf,documentMeta:Se(mf),annotation:Se(mf),processingInstruction:Se(mf),definition:us.defineModifier("definition"),constant:us.defineModifier("constant"),function:us.defineModifier("function"),standard:us.defineModifier("standard"),local:us.defineModifier("local"),special:us.defineModifier("special")};for(let s in Te){let l=Te[s];l instanceof us&&(l.name=s)}Dy([{tag:Te.link,class:"tok-link"},{tag:Te.heading,class:"tok-heading"},{tag:Te.emphasis,class:"tok-emphasis"},{tag:Te.strong,class:"tok-strong"},{tag:Te.keyword,class:"tok-keyword"},{tag:Te.atom,class:"tok-atom"},{tag:Te.bool,class:"tok-bool"},{tag:Te.url,class:"tok-url"},{tag:Te.labelName,class:"tok-labelName"},{tag:Te.inserted,class:"tok-inserted"},{tag:Te.deleted,class:"tok-deleted"},{tag:Te.literal,class:"tok-literal"},{tag:Te.string,class:"tok-string"},{tag:Te.number,class:"tok-number"},{tag:[Te.regexp,Te.escape,Te.special(Te.string)],class:"tok-string2"},{tag:Te.variableName,class:"tok-variableName"},{tag:Te.local(Te.variableName),class:"tok-variableName tok-local"},{tag:Te.definition(Te.variableName),class:"tok-variableName tok-definition"},{tag:Te.special(Te.variableName),class:"tok-variableName2"},{tag:Te.definition(Te.propertyName),class:"tok-propertyName tok-definition"},{tag:Te.typeName,class:"tok-typeName"},{tag:Te.namespace,class:"tok-namespace"},{tag:Te.className,class:"tok-className"},{tag:Te.macroName,class:"tok-macroName"},{tag:Te.propertyName,class:"tok-propertyName"},{tag:Te.operator,class:"tok-operator"},{tag:Te.comment,class:"tok-comment"},{tag:Te.meta,class:"tok-meta"},{tag:Te.invalid,class:"tok-invalid"},{tag:Te.punctuation,class:"tok-punctuation"}]);const K1="modulepreload",Z1=function(s,l){return new URL(s,l).href},gx={},Ke=function(l,r,c){let o=Promise.resolve();if(r&&r.length>0){let h=function(_){return Promise.all(_.map(S=>Promise.resolve(S).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const m=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),b=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=h(r.map(_=>{if(_=Z1(_,c),_ in gx)return;gx[_]=!0;const S=_.endsWith(".css"),v=S?'[rel="stylesheet"]':"";if(!!c)for(let C=m.length-1;C>=0;C--){const L=m[C];if(L.href===_&&(!S||L.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${_}"]${v}`))return;const T=document.createElement("link");if(T.rel=S?"stylesheet":K1,S||(T.as="script"),T.crossOrigin="",T.href=_,b&&T.setAttribute("nonce",b),document.head.appendChild(T),S)return new Promise((C,L)=>{T.addEventListener("load",C),T.addEventListener("error",()=>L(new Error(`Unable to preload CSS for ${_}`)))})}))}function d(h){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=h,window.dispatchEvent(m),!m.defaultPrevented)throw h}return o.then(h=>{for(const m of h||[])m.status==="rejected"&&d(m.reason);return l().catch(d)})},Oy={js:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),cjs:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),mjs:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),jsx:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),ts:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),mts:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),cts:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),tsx:async()=>(await Ke(async()=>{const{javascript:s}=await import("./index-DyY1FCgf.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0,jsx:!0}),json:async()=>(await Ke(async()=>{const{json:s}=await import("./index-CMpPRV85.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),jsonc:async()=>(await Ke(async()=>{const{json:s}=await import("./index-CMpPRV85.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),css:async()=>(await Ke(async()=>{const{css:s}=await import("./index-DMeJ3xy0.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),scss:async()=>(await Ke(async()=>{const{css:s}=await import("./index-DMeJ3xy0.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),less:async()=>(await Ke(async()=>{const{css:s}=await import("./index-DMeJ3xy0.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),html:async()=>(await Ke(async()=>{const{html:s}=await import("./index-B20zmSkd.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),htm:async()=>(await Ke(async()=>{const{html:s}=await import("./index-B20zmSkd.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),vue:async()=>(await Ke(async()=>{const{html:s}=await import("./index-B20zmSkd.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),svelte:async()=>(await Ke(async()=>{const{html:s}=await import("./index-B20zmSkd.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),md:async()=>(await Ke(async()=>{const{markdown:s}=await import("./index-kRQFCBLi.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),markdown:async()=>(await Ke(async()=>{const{markdown:s}=await import("./index-kRQFCBLi.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),py:async()=>(await Ke(async()=>{const{python:s}=await import("./index-DbZeX0xl.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),pyi:async()=>(await Ke(async()=>{const{python:s}=await import("./index-DbZeX0xl.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),yaml:async()=>(await Ke(async()=>{const{yaml:s}=await import("./index-BbaEOHHE.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),yml:async()=>(await Ke(async()=>{const{yaml:s}=await import("./index-BbaEOHHE.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),rs:async()=>(await Ke(async()=>{const{rust:s}=await import("./index-PkTbpJ8b.js");return{rust:s}},__vite__mapDeps([12,1,2,3,4]),import.meta.url)).rust(),c:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-k2hhaMZJ.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),h:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-k2hhaMZJ.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cc:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-k2hhaMZJ.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cpp:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-k2hhaMZJ.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),hpp:async()=>(await Ke(async()=>{const{cpp:s}=await import("./index-k2hhaMZJ.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),java:async()=>(await Ke(async()=>{const{java:s}=await import("./index-B8wBlTJK.js");return{java:s}},__vite__mapDeps([14,1,2,3,4]),import.meta.url)).java(),go:async()=>(await Ke(async()=>{const{go:s}=await import("./index-CMsLxeb-.js");return{go:s}},__vite__mapDeps([15,1,2,3,4,5]),import.meta.url)).go(),php:async()=>(await Ke(async()=>{const{php:s}=await import("./index-HnPp_JMB.js");return{php:s}},__vite__mapDeps([16,1,8,7,2,3,4,0,5]),import.meta.url)).php(),sql:async()=>(await Ke(async()=>{const{sql:s}=await import("./index-CrUrevEN.js");return{sql:s}},__vite__mapDeps([17,2,3,4,1,5]),import.meta.url)).sql(),xml:async()=>(await Ke(async()=>{const{xml:s}=await import("./index-umqVrxlG.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml(),svg:async()=>(await Ke(async()=>{const{xml:s}=await import("./index-umqVrxlG.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml()},F1={".mcp.json":"json",dockerfile:"yaml",makefile:"yaml"},J1={javascript:"js",node:"js",typescript:"ts",python:"py",python3:"py",yml:"yaml",rust:"rs",golang:"go","c++":"cpp",cplusplus:"cpp"};async function W1(s){const l=J1[s.toLowerCase()]??s.toLowerCase(),r=Oy[l];return r?r().catch(()=>null):null}async function P1(s){const l=(s.split("/").pop()??"").toLowerCase(),r=F1[l]??l.split(".").pop()??"",c=Oy[r];return c?c().catch(()=>null):null}const ej=Dy([{tag:[Te.keyword,Te.modifier,Te.controlKeyword,Te.moduleKeyword],class:"cmh-key"},{tag:[Te.propertyName],class:"cmh-prop"},{tag:[Te.function(Te.variableName),Te.labelName],class:"cmh-fn"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name),Te.bool],class:"cmh-const"},{tag:[Te.typeName,Te.className,Te.changed,Te.annotation,Te.self,Te.namespace],class:"cmh-type"},{tag:[Te.number,Te.integer,Te.float],class:"cmh-num"},{tag:[Te.string,Te.special(Te.string),Te.regexp],class:"cmh-str"},{tag:[Te.operator,Te.operatorKeyword,Te.escape],class:"cmh-op"},{tag:[Te.meta,Te.comment],class:"cmh-comment"},{tag:Te.invalid,class:"cmh-invalid"}]);function gf(s){return s.replace(/[&<>]/g,l=>l==="&"?"&":l==="<"?"<":">")}async function tj(s,l){const r=l?await W1(l):null;if(!r)return gf(s);try{const c=r.language.parser.parse(s);let o="";return $1(s,c,ej,(d,h)=>{o+=h?`<span class="${h}">${gf(d)}</span>`:gf(d)},()=>{o+=`
|
|
118
|
+
`}),o}catch{return gf(s)}}jt.setOptions({gfm:!0,breaks:!1});function Ly(s){var r;const l=(r=s.split(".").pop())==null?void 0:r.toLowerCase();return l==="md"||l==="markdown"}async function Qf(s){const l=await jt.parse(s,{async:!0,walkTokens:async r=>{if(r.type!=="code")return;const c=r;c.text=await tj(c.text,c.lang??""),c.escaped=!0}});return w1.sanitize(l)}function bx(s,l){return{path:s.path,text:s.content,saved:s.content,eol:s.eol,encoding:s.encoding,mtime:s.mtime,size:s.size,binary:s.binary,tooLarge:s.tooLarge,mediaMime:s.mediaMime,mediaTooLarge:s.mediaTooLarge,stale:!1,revision:l,previewMode:Ly(s.path)}}function Ra(s){return!s.binary&&!s.tooLarge&&s.text!==s.saved}function nj(s){return s.split("/").pop()??s}function fr(s){const l=s.lastIndexOf("/");return l===-1?"":s.slice(0,l)}function Of(s){return s<1024?`${s} Б`:s<1024*1024?`${(s/1024).toFixed(1)} КБ`:`${(s/1024/1024).toFixed(1)} МБ`}function sr({x:s,y:l,items:r,note:c,onClose:o}){const d=y.useRef(null),[h,m]=y.useState({left:s,top:l}),[g,b]=y.useState(()=>{const v=r.findIndex(E=>!E.disabled);return v===-1?0:v});y.useLayoutEffect(()=>{const v=d.current;if(!v)return;const E=v.getBoundingClientRect(),T=8,C=Math.max(T,Math.min(s,window.innerWidth-E.width-T)),L=Math.max(T,Math.min(l,window.innerHeight-E.height-T));m({left:C,top:L})},[s,l]),y.useLayoutEffect(()=>{var v;(v=d.current)==null||v.focus()},[]),y.useLayoutEffect(()=>{function v(T){var C;(C=d.current)!=null&&C.contains(T.target)||o()}function E(){o()}return document.addEventListener("mousedown",v),document.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("scroll",E,!0)}},[o]);function _(v){v.disabled||(v.onSelect(),o())}function S(v){if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),o();return}const E=r.map((T,C)=>({item:T,index:C})).filter(T=>!T.item.disabled);if(E.length!==0){if(v.key==="ArrowDown"||v.key==="ArrowUp"){v.preventDefault();const T=v.key==="ArrowDown"?1:-1,C=E.findIndex(X=>X.index===g),L=E[(((C===-1?0:C)+T)%E.length+E.length)%E.length];L&&b(L.index);return}if(v.key==="Enter"||v.key===" "){v.preventDefault();const T=r[g];T&&_(T)}}}return i.jsxs("div",{ref:d,className:"ctxmenu",style:{left:h.left,top:h.top},role:"menu",tabIndex:-1,onKeyDown:S,children:[c&&i.jsx("div",{className:"ctxmenu__note",children:c}),r.map((v,E)=>i.jsxs("button",{type:"button",role:"menuitem","aria-disabled":v.disabled,className:"ctxmenu__item"+(E===g?" is-cursor":""),onMouseEnter:()=>b(E),onClick:()=>_(v),children:[i.jsx("span",{className:"ctxmenu__label",children:v.label}),v.hint&&i.jsx("span",{className:"ctxmenu__hint",children:v.hint})]},v.id))]})}const lj=3500,sj=9e3,xx=220;function mr({result:s,onDismiss:l}){const[r,c]=y.useState(s),[o,d]=y.useState(!1);if(y.useEffect(()=>{if(!s){c(null),d(!1);return}if(c(s),d(!1),s.url)return;const m=s.ok?lj:sj,g=setTimeout(()=>d(!0),m),b=setTimeout(()=>c(null),m+xx);return()=>{clearTimeout(g),clearTimeout(b)}},[s]),!r)return null;const h=()=>{d(!0),setTimeout(()=>{c(null),l==null||l()},xx)};return i.jsxs("div",{className:"oplog "+(r.ok?"oplog--ok":"oplog--bad")+(o?" oplog--leaving":"")+(r.url?" oplog--dismissible":""),role:"status","aria-live":r.ok?"polite":"assertive",children:[r.message,r.url&&i.jsxs("a",{className:"oplog__link",href:r.url,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),children:[r.url.replace(/^https?:\/\//,"")," ↗"]}),r.url&&l&&i.jsx("button",{type:"button",className:"oplog__dismiss",title:"Закрыть","aria-label":"Закрыть сообщение",onClick:h,children:"✕"})]})}function na({value:s,className:l,placeholder:r="Название сессии",onCommit:c,onCancel:o}){const[d,h]=y.useState(s),m=y.useRef(null);y.useEffect(()=>{var b;(b=m.current)==null||b.select()},[]);function g(){const b=d.trim();if(!b||b===s)return o();c(b)}return i.jsx("input",{ref:m,className:l?`rename ${l}`:"rename",value:d,autoFocus:!0,spellCheck:!1,placeholder:r,onChange:b=>h(b.target.value),onBlur:g,onKeyDown:b=>{b.stopPropagation(),b.key==="Enter"?(b.preventDefault(),g()):b.key==="Escape"&&(b.preventDefault(),o())}})}function Sc({active:s}){return s?i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M2 5h3V2"}),i.jsx("path",{d:"M14 5h-3V2"}),i.jsx("path",{d:"M2 11h3v3"}),i.jsx("path",{d:"M14 11h-3v3"})]}):i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2H2v3"}),i.jsx("path",{d:"M11 2h3v3"}),i.jsx("path",{d:"M2 11v3h3"}),i.jsx("path",{d:"M14 11v3h-3"})]})}const aj=500,tr="application/x-ccv-fs-path",ij=200;function rj({open:s,tree:l,expanded:r,activePath:c,dirty:o,gitChanges:d,result:h,searchResult:m,onSearch:g,onReveal:b,onToggle:_,onOpen:S,onCreate:v,onRename:E,onMove:T,onCopy:C,onDelete:L,onRefresh:X,onClose:J,zoomed:G,onToggleZoom:O}){const[Z,M]=y.useState(""),[D,H]=y.useState(null),[ne,he]=y.useState(null),[W,ue]=y.useState(null),[je,Me]=y.useState(null),[Ce,A]=y.useState(null),[ce,z]=y.useState(null),be=Xf("(hover: hover)"),ye=y.useRef(null),N=y.useMemo(()=>uj(d),[d]);function V(le){return!(!W||le===W.path||W.kind==="dir"&&le.startsWith(`${W.path}/`)||le===fr(W.path))}function re(le){return!(!Ce||le===Ce.path||Ce.kind==="dir"&&le.startsWith(`${Ce.path}/`)||Ce.mode==="cut"&&le===fr(Ce.path))}function me(le){A({path:le.path,kind:le.kind,mode:"copy"})}function Ne(le){A({path:le.path,kind:le.kind,mode:"cut"})}function ve(le){!Ce||!re(le)||(le&&!r.has(le)&&_(le),Ce.mode==="cut"?(T(Ce.path,le),A(null)):C(Ce.path,le))}function De(le,ge){const He=le.touches[0];if(!He)return;const B={timer:0,x:He.clientX,y:He.clientY,el:le.currentTarget,fired:!1};B.timer=window.setTimeout(()=>{B.fired=!0,ge(B.x,B.y,B.el)},aj),ye.current=B}function yt(le){const ge=ye.current,He=le.touches[0];!ge||!He||Math.hypot(He.clientX-ge.x,He.clientY-ge.y)>10&&(window.clearTimeout(ge.timer),ye.current=null)}function Xe(le){const ge=ye.current;ge&&(window.clearTimeout(ge.timer),ge.fired&&le.preventDefault())}function $e(){var le;return(le=ye.current)!=null&&le.fired?(ye.current=null,!0):!1}function Ve(le,ge,He,B){M((B==null?void 0:B.path)??""),z({x:le,y:ge,opener:He,entry:B})}function It(){const le=ce==null?void 0:ce.opener;z(null),le!=null&&le.isConnected&&le.focus()}function rt(le){return{onContextMenu:ge=>{ge.preventDefault(),Ve(ge.clientX,ge.clientY,ge.currentTarget,le)},onTouchStart:ge=>De(ge,(He,B,P)=>Ve(He,B,P,le)),onTouchMove:yt,onTouchEnd:Xe,onTouchCancel:Xe}}function dn(le){le.target===le.currentTarget&&(le.preventDefault(),Ve(le.clientX,le.clientY,le.currentTarget,null))}function ft(le){le.target===le.currentTarget&&De(le,(ge,He,B)=>Ve(ge,He,B,null))}function hn(le){if(!(le.ctrlKey||le.metaKey)||le.target instanceof HTMLInputElement)return;const ge=le.key.toLowerCase();if(ge==="v"){le.preventDefault(),ve(Dn());return}if(!Z)return;const He=yx(l,Z);He&&(ge==="c"?(le.preventDefault(),me(He)):ge==="x"&&(le.preventDefault(),Ne(He)))}function Sn(le){return ge=>{ge.dataTransfer.effectAllowed="move",ge.dataTransfer.setData(tr,le.path),ue({path:le.path,kind:le.kind})}}function xn(){ue(null),Me(null)}function en(le){return ge=>{ge.dataTransfer.types.includes(tr)&&(ge.stopPropagation(),!(le.kind!=="dir"||!V(le.path))&&(ge.preventDefault(),Me(le.path)))}}function tt(le){return ge=>{if(!ge.dataTransfer.types.includes(tr)||(ge.stopPropagation(),le.kind!=="dir"||!V(le.path)))return;ge.preventDefault();const He=ge.dataTransfer.getData(tr);Me(null),He&&T(He,le.path)}}function et(le){!le.dataTransfer.types.includes(tr)||!V("")||(le.preventDefault(),Me(""))}function tn(le){if(!le.dataTransfer.types.includes(tr)||!V(""))return;le.preventDefault();const ge=le.dataTransfer.getData(tr);Me(null),ge&&T(ge,"")}const[Xt,nt]=y.useState(""),St=Xt.trim(),$t=St.length>0,cn=y.useRef(null),wt=y.useRef(g);wt.current=g;function yn(le){nt(le),cn.current&&clearTimeout(cn.current);const ge=le.trim();if(!ge){wt.current("");return}cn.current=setTimeout(()=>wt.current(ge),ij)}function qt(le){cn.current&&clearTimeout(cn.current),nt(""),wt.current(""),M(le.path),b(le)}const pn=$t&&(m==null?void 0:m.query)===St?m:null;function Dn(){if(Z==="")return"";const le=yx(l,Z);if((le==null?void 0:le.kind)==="dir")return Z;const ge=Z.lastIndexOf("/");return ge===-1?"":Z.slice(0,ge)}function Gt(le,ge){const He=ge??Dn();He&&!r.has(He)&&_(He),he({parent:He,kind:le})}function ct(){if(!ce)return[];const le=B=>be?B:void 0;if(!ce.entry)return[{id:"paste",label:"Вставить в корень проекта",hint:le("Ctrl+V"),disabled:!re(""),onSelect:()=>ve("")},{id:"new-file",label:"Создать файл",onSelect:()=>Gt("file","")},{id:"new-dir",label:"Создать каталог",onSelect:()=>Gt("dir","")}];const ge=ce.entry,He=[ge.kind==="file"?{id:"open",label:"Открыть",onSelect:()=>S(ge.path)}:{id:"toggle",label:r.has(ge.path)?"Свернуть":"Развернуть",onSelect:()=>_(ge.path)},{id:"copy",label:"Копировать",hint:le("Ctrl+C"),onSelect:()=>me(ge)},{id:"cut",label:"Вырезать",hint:le("Ctrl+X"),onSelect:()=>Ne(ge)}];return ge.kind==="dir"&&(He.push({id:"paste",label:"Вставить",hint:le("Ctrl+V"),disabled:!re(ge.path),onSelect:()=>ve(ge.path)}),He.push({id:"new-file",label:"Создать файл",onSelect:()=>Gt("file",ge.path)}),He.push({id:"new-dir",label:"Создать каталог",onSelect:()=>Gt("dir",ge.path)})),He.push({id:"rename",label:"Переименовать",onSelect:()=>H(ge.path)}),He.push({id:"delete",label:"Удалить",onSelect:()=>L(ge)}),He}const Et=$t?[]:Pe("",0);function Pe(le,ge){const He=l[le],B=[];if(ne&&ne.parent===le&&B.push(i.jsxs("div",{className:"fsrow fsrow--draft",style:Da(ge),children:[i.jsx("span",{className:"fsrow__icon",children:ne.kind==="dir"?i.jsx(qf,{}):i.jsx(Gf,{})}),i.jsx(na,{className:"rename--file",value:"",placeholder:ne.kind==="dir"?"имя каталога":"имя файла",onCommit:P=>{he(null),v(le,ne.kind,P)},onCancel:()=>he(null)})]},`draft:${le}`)),!He)return B.push(i.jsx("p",{className:"fsrow__pending",style:Da(ge),children:"читаем…"},`wait:${le}`)),B;He.length===0&&!ne&&B.push(i.jsx("p",{className:"fsrow__pending",style:Da(ge),children:"пусто"},`empty:${le}`));for(const P of He){const _e=P.kind==="dir"&&r.has(P.path);B.push(D===P.path?i.jsxs("div",{className:"fsrow fsrow--draft",style:Da(ge),children:[i.jsx("span",{className:"fsrow__icon",children:P.kind==="dir"?i.jsx(qf,{open:_e}):i.jsx(Gf,{})}),i.jsx(na,{className:"rename--file",value:P.name,placeholder:"новое имя",onCommit:Be=>{H(null),E(P.path,Be)},onCancel:()=>H(null)})]},P.path):i.jsx(cj,{entry:P,depth:ge,open:_e,active:P.path===c,selected:P.path===Z,dirty:o.has(P.path),gitStatus:N.get(P.path),dragging:(W==null?void 0:W.path)===P.path,dropTarget:je===P.path,cut:(Ce==null?void 0:Ce.mode)==="cut"&&Ce.path===P.path,onClick:()=>{$e()||(M(P.path),P.kind==="dir"?_(P.path):S(P.path))},onRename:()=>H(P.path),onDelete:()=>L(P),onDragStart:Sn(P),onDragEnd:xn,onDragOver:en(P),onDrop:tt(P),...rt(P)},P.path)),_e&&B.push(...Pe(P.path,ge+1))}return B}function wl(){if(!pn)return[i.jsx("p",{className:"fsrow__pending",style:Da(0),children:"ищем…"},"search:wait")];if(pn.entries.length===0)return[i.jsx("p",{className:"fsrow__pending",style:Da(0),children:"ничего не найдено"},"search:empty")];const le=pn.entries.map(ge=>i.jsx(oj,{entry:ge,gitStatus:N.get(ge.path),onClick:()=>qt(ge)},ge.path));return pn.truncated&&le.push(i.jsxs("p",{className:"fsrow__pending",style:Da(0),children:["показаны первые ",pn.entries.length," — уточните запрос"]},"search:truncated")),le}return i.jsxs("aside",{className:(s?"sidepane sidepane--files sidepane--open":"sidepane sidepane--files")+(G?" sidepane--zoomed":""),"aria-label":"Файлы проекта",onKeyDown:hn,children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:le=>{O&&(le.target.closest("button")||O())},children:[i.jsx(pj,{}),i.jsx("span",{className:"sidepane__title",children:"Файлы"}),i.jsx("button",{className:"sidepane__btn",title:"Новый файл","aria-label":"Новый файл",onClick:()=>Gt("file"),children:i.jsx(dj,{})}),i.jsx("button",{className:"sidepane__btn",title:"Новый каталог","aria-label":"Новый каталог",onClick:()=>Gt("dir"),children:i.jsx(hj,{})}),i.jsx("button",{className:"sidepane__btn",title:"Перечитать дерево","aria-label":"Перечитать дерево",onClick:X,children:"↻"}),O&&i.jsx("button",{className:"sidepane__btn",title:G?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":G?"Свернуть панель файлов":"Развернуть панель файлов на весь экран","aria-pressed":G,onClick:O,children:i.jsx(Sc,{active:G})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель файлов",onClick:J,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(mj,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:Xt,spellCheck:!1,placeholder:"Поиск файлов и папок…","aria-label":"Поиск файлов и папок",onChange:le=>yn(le.target.value),onKeyDown:le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),Xt?yn(""):le.currentTarget.blur())}}),Xt&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>yn(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree"+(je===""?" fstree--drop-target":""),tabIndex:-1,onDragOver:et,onDrop:tn,onContextMenu:dn,onTouchStart:ft,onTouchMove:yt,onTouchEnd:Xe,onTouchCancel:Xe,children:$t?wl():Et}),i.jsx(mr,{result:h}),ce&&i.jsx(sr,{x:ce.x,y:ce.y,items:ct(),onClose:It})]})}function cj({entry:s,depth:l,open:r,active:c,selected:o,dirty:d,gitStatus:h,dragging:m,dropTarget:g,cut:b,onClick:_,onRename:S,onDelete:v,onDragStart:E,onDragEnd:T,onDragOver:C,onDrop:L,onContextMenu:X,onTouchStart:J,onTouchMove:G,onTouchEnd:O,onTouchCancel:Z}){const M="fsrow"+(c?" is-open":"")+(o&&!c?" is-selected":"")+(s.ignored?" fsrow--ignored":"")+(m?" fsrow--dragging":"")+(g?" fsrow--drop-target":"")+(b?" fsrow--cut":"");return i.jsxs("div",{className:M,style:Da(l),draggable:!0,onDragStart:E,onDragEnd:T,onDragOver:C,onDrop:L,onContextMenu:X,onTouchStart:J,onTouchMove:G,onTouchEnd:O,onTouchCancel:Z,children:[i.jsxs("button",{className:"fsrow__main",onClick:_,title:zy(s),children:[i.jsx("span",{className:"fsrow__icon"+If("fsrow__icon",h),children:s.kind==="dir"?i.jsx(qf,{open:r}):i.jsx(Gf,{})}),i.jsx("span",{className:"fsrow__name"+If("fsrow__name",h),children:s.name}),s.ignored&&i.jsx("span",{className:"fsrow__tag",title:"Игнорируется git (.gitignore)",children:"git-ignore"}),d&&i.jsx("span",{className:"fsrow__dot",title:"Есть несохранённые правки"})]}),i.jsx("button",{className:"fsrow__act",title:"Переименовать","aria-label":`Переименовать ${s.name}`,onClick:S,children:"✎"}),i.jsx("button",{className:"fsrow__act",title:"Удалить","aria-label":`Удалить ${s.name}`,onClick:v,children:"✕"})]})}function oj({entry:s,gitStatus:l,onClick:r}){const c=s.path.slice(0,s.path.length-s.name.length-1);return i.jsxs("button",{className:"fsrow fsrow--search"+(s.ignored?" fsrow--ignored":""),style:Da(0),onClick:r,title:zy(s),children:[i.jsx("span",{className:"fsrow__icon"+If("fsrow__icon",l),children:s.kind==="dir"?i.jsx(qf,{}):i.jsx(Gf,{})}),i.jsx("span",{className:"fsrow__name"+If("fsrow__name",l),children:s.name}),s.ignored&&i.jsx("span",{className:"fsrow__tag",children:"git-ignore"}),c&&i.jsx("span",{className:"fsrow__path",children:c})]})}function zy(s){return s.ignored?`${s.path} — игнорируется git (.gitignore)`:s.path}function Da(s){return{"--depth":s}}function yx(s,l){var o;const r=l.lastIndexOf("/"),c=r===-1?"":l.slice(0,r);return((o=s[c])==null?void 0:o.find(d=>d.path===l))??null}function uj(s){const l=new Map,r={added:1,modified:2},c=(o,d)=>{const h=l.get(o);(!h||r[d]>r[h])&&l.set(o,d)};for(const o of s){const d=fj(o.status);if(!d)continue;c(o.path,d);let h=fr(o.path);for(;c(h,d),!!h;)h=fr(h)}return l}function fj(s){if(s==="??")return"added";const[l="",r=""]=s;return l==="A"||l==="R"||l==="C"?"added":l==="M"||r==="M"?"modified":null}function If(s,l){return l?` ${s}--git-${l}`:""}function qf({open:s=!1}){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,"aria-hidden":"true",children:s?i.jsx("path",{d:"M2 12.5V4.2a.7.7 0 0 1 .7-.7h3.1l1.5 1.6h4.4a.7.7 0 0 1 .7.7v1.2M2 12.5l1.7-4.6a.7.7 0 0 1 .66-.46h9.2a.5.5 0 0 1 .47.66L12.4 12.5Z"}):i.jsx("path",{d:"M2 12.4V4.2a.7.7 0 0 1 .7-.7h3.1l1.5 1.6h5.9a.7.7 0 0 1 .7.7v6.6a.7.7 0 0 1-.7.7H2.7a.7.7 0 0 1-.7-.7Z"})})}function Gf(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M9 2H4.4a.7.7 0 0 0-.7.7v10.6a.7.7 0 0 0 .7.7h7.2a.7.7 0 0 0 .7-.7V5.2Z"}),i.jsx("path",{d:"M9 2v3.2h3.3"})]})}function dj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,"aria-hidden":"true",children:[i.jsxs("g",{transform:"translate(-1.3,-1.6) scale(0.78)",strokeLinejoin:"round",children:[i.jsx("path",{d:"M9 2H4.4a.7.7 0 0 0-.7.7v10.6a.7.7 0 0 0 .7.7h7.2a.7.7 0 0 0 .7-.7V5.2Z"}),i.jsx("path",{d:"M9 2v3.2h3.3"})]}),i.jsx("path",{d:"M12.2 10.3v3.8M10.3 12.2h3.8",strokeLinecap:"round"})]})}function hj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,"aria-hidden":"true",children:[i.jsx("g",{transform:"translate(-1.3,-1.6) scale(0.78)",children:i.jsx("path",{d:"M2 12.4V4.2a.7.7 0 0 1 .7-.7h3.1l1.5 1.6h5.9a.7.7 0 0 1 .7.7v6.6a.7.7 0 0 1-.7.7H2.7a.7.7 0 0 1-.7-.7Z"})}),i.jsx("path",{d:"M12.2 10.3v3.8M10.3 12.2h3.8",strokeLinecap:"round"})]})}function pj(){return i.jsxs("svg",{className:"sidepane__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M2 4.1V3a.6.6 0 0 1 .6-.6h2.6l1.2 1.4h5a.6.6 0 0 1 .6.6v1.1"}),i.jsx("path",{d:"M2 12.6V5.7h11.4a.6.6 0 0 1 .58.75l-1.5 6.2a.6.6 0 0 1-.58.45H2.6a.6.6 0 0 1-.6-.5Z"})]})}function mj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}const gj=200;function bj({open:s,result:l,onSearch:r,onOpenMatch:c,onClose:o,zoomed:d,onToggleZoom:h}){const[m,g]=y.useState(""),b=m.trim(),_=b.length>0,S=y.useRef(null),v=y.useRef(r);v.current=r;function E(L){g(L),S.current&&clearTimeout(S.current);const X=L.trim();if(!X){v.current("");return}S.current=setTimeout(()=>v.current(X),gj)}const T=_&&(l==null?void 0:l.query)===b?l:null;function C(){if(!T)return[i.jsx("p",{className:"fsrow__pending",children:"ищем…"},"grep:wait")];if(T.matches.length===0)return[i.jsx("p",{className:"fsrow__pending",children:"ничего не найдено"},"grep:empty")];const L=[];let X="";for(const J of T.matches)J.path!==X&&(X=J.path,L.push(i.jsx("p",{className:"searchgroup__path",title:J.path,children:J.path},`path:${J.path}`))),L.push(i.jsx(xj,{match:J,onClick:()=>c(J)},`${J.path}:${J.line}:${J.column}`));return T.truncated&&L.push(i.jsxs("p",{className:"fsrow__pending",children:["показаны первые ",T.matches.length," — уточните запрос"]},"grep:truncated")),L}return i.jsxs("aside",{className:(s?"sidepane sidepane--search sidepane--open":"sidepane sidepane--search")+(d?" sidepane--zoomed":""),"aria-label":"Поиск по тексту в проекте",children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:L=>{h&&(L.target.closest("button")||h())},children:[i.jsx(yj,{}),i.jsx("span",{className:"sidepane__title",children:"Поиск по тексту"}),h&&i.jsx("button",{className:"sidepane__btn",title:d?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":d?"Свернуть панель поиска":"Развернуть панель поиска на весь экран","aria-pressed":d,onClick:h,children:i.jsx(Sc,{active:d})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель поиска",onClick:o,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(_j,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:m,spellCheck:!1,placeholder:"Поиск по тексту во всех файлах…","aria-label":"Поиск по тексту во всех файлах",onChange:L=>E(L.target.value),onKeyDown:L=>{L.stopPropagation(),L.key==="Escape"&&(L.preventDefault(),m?E(""):L.currentTarget.blur())}}),m&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>E(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree",children:_?C():i.jsx("p",{className:"sidepane__empty",children:"Введите текст, чтобы найти его во всех файлах проекта."})})]})}function xj({match:s,onClick:l}){const r=s.lineText.slice(0,s.column-1),c=s.lineText.slice(s.column-1,s.column-1+s.matchLength),o=s.lineText.slice(s.column-1+s.matchLength);return i.jsxs("button",{className:"searchmatch",onClick:l,title:`${s.path}:${s.line}`,children:[i.jsx("span",{className:"searchmatch__line",children:s.line}),i.jsxs("span",{className:"searchmatch__text",children:[r,i.jsx("mark",{children:c}),o]})]})}function yj(){return i.jsxs("svg",{className:"sidepane__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"6.8",cy:"6.8",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1"})]})}function _j(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}let bf=null;function vj(){return bf||(bf=Promise.all([Ke(()=>import("./index-4OYhLb6v.js"),__vite__mapDeps([19,4,3,2,20,5]),import.meta.url),Ke(()=>import("./index-891wE-Rj.js").then(s=>s.v),__vite__mapDeps([4,3]),import.meta.url),Ke(()=>import("./index-BHot-lnj.js"),[],import.meta.url),Ke(()=>import("./index-DhS8IelO.js"),__vite__mapDeps([20,3,4,2]),import.meta.url),Ke(()=>import("./codemirror-CMssNlj1.js"),__vite__mapDeps([21,2,3,4]),import.meta.url)]).then(([s,l,r,c,o])=>({EditorView:l.EditorView,EditorState:r.EditorState,Compartment:r.Compartment,EditorSelection:r.EditorSelection,Prec:r.Prec,keymap:l.keymap,indentWithTab:c.indentWithTab,basicSetup:s.basicSetup,editorTheme:o.editorTheme,editorHighlight:o.editorHighlight})).catch(s=>{throw bf=null,s})),bf}function jj({path:s,doc:l,revision:r,goto:c,onChange:o,onSave:d}){const h=y.useRef(null),m=y.useRef(null),g=y.useRef(null),b=y.useRef(new Map),_=y.useRef(new Map),S=y.useRef(new Set),v=y.useRef(null),E=y.useRef(o),T=y.useRef(d),C=y.useRef(s),L=y.useRef(r),X=y.useRef(l);E.current=o,T.current=d,C.current=s,L.current=r,X.current=l;const[J,G]=y.useState("loading"),[O,Z]=y.useState(!1);function M(H,ne,he,W,ue){const je=b.current.get(W),Me=_.current.get(W)===ue;if(je&&Me)he.setState(je);else{const A=H.EditorState.create({doc:X.current,extensions:[H.basicSetup,H.Prec.highest(H.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(T.current(C.current),!0)}])),H.keymap.of([H.indentWithTab]),ne.of([]),H.editorTheme,H.editorHighlight,H.EditorView.updateListener.of(ce=>{ce.docChanged&&E.current(C.current,ce.state.doc.toString())})]});b.current.set(W,A),_.current.set(W,ue),he.setState(A),S.current.delete(W)}if(S.current.has(W))return()=>{};let Ce=!1;return P1(W).then(A=>{Ce||!A||C.current!==W||(he.dispatch({effects:ne.reconfigure(A)}),b.current.set(W,he.state),S.current.add(W))}),()=>{Ce=!0}}y.useEffect(()=>{if(!h.current)return;let ne=!1,he=null,W=null;G("loading"),Z(!1);const ue=window.setTimeout(()=>{ne||Z(!0)},200);return(async()=>{let je;try{je=await vj()}catch{window.clearTimeout(ue),ne||G("error");return}if(ne||!h.current)return;window.clearTimeout(ue);const Me=new je.Compartment;v.current=Me,g.current=je,W=new je.EditorView({parent:h.current}),m.current=W,he=M(je,Me,W,C.current,L.current),G("ready")})(),()=>{ne=!0,window.clearTimeout(ue),he==null||he(),W==null||W.destroy(),m.current===W&&(m.current=null),g.current=null,v.current=null}},[]),y.useEffect(()=>{const H=g.current,ne=m.current,he=v.current;if(!(!H||!ne||!he))return M(H,he,ne,s,r)},[s,r]);const D=y.useRef(0);return y.useEffect(()=>{const H=m.current,ne=g.current;if(!H||!ne||!c||c.token===D.current)return;D.current=c.token;const he=H.state.doc.lines,W=Math.min(Math.max(c.line,1),he),ue=H.state.doc.line(W),je=Math.min(ue.from+Math.max(c.column-1,0),ue.to);H.dispatch({selection:ne.EditorSelection.cursor(je),effects:ne.EditorView.scrollIntoView(je,{y:"center"})}),H.focus()},[c]),y.useEffect(()=>()=>{const H=m.current;H&&b.current.set(s,H.state)},[s]),i.jsxs("div",{className:"editor__code",children:[i.jsx("div",{ref:h,className:"editor__code-surface"+(J==="ready"?"":" is-hidden")}),J==="loading"&&O&&i.jsxs("div",{className:"editor__state work",role:"status",children:[i.jsxs("div",{className:"work__dots",children:[i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"})]}),i.jsx("span",{className:"work__label",children:"Загружается редактор…"})]}),J==="error"&&i.jsxs("div",{className:"editor__fallback",children:[i.jsxs("div",{className:"editor__fallback-banner",role:"alert",children:[i.jsx("span",{children:"Редактор не загрузился — ниже только просмотр, без сохранения правок."}),i.jsx("button",{className:"btn btn--sm btn--primary",onClick:()=>window.location.reload(),children:"Перезагрузить страницу"})]}),i.jsx("pre",{className:"editor__fallback-text",children:l})]})]})}function Cs({value:s,options:l,onChange:r,className:c,title:o,ariaLabel:d,placeholder:h="—"}){const[m,g]=y.useState(!1),[b,_]=y.useState(0),S=y.useRef(null),v=y.useRef(null),E=l.find(L=>L.value===s)??null;y.useEffect(()=>{if(!m)return;const L=l.findIndex(X=>X.value===s);_(L===-1?0:L)},[m]),y.useEffect(()=>{if(!m)return;function L(X){var J;(J=S.current)!=null&&J.contains(X.target)||g(!1)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[m]),y.useEffect(()=>{var L,X;m&&((X=(L=v.current)==null?void 0:L.querySelector(".is-cursor"))==null||X.scrollIntoView({block:"nearest"}))},[m,b]),y.useEffect(()=>{if(!m)return;const L=v.current,X=Sj(S.current);if(!L||!X)return;const J=L.getBoundingClientRect().bottom-X.getBoundingClientRect().bottom;J>0&&(X.scrollTop+=Math.min(J+8,L.offsetHeight))},[m]);function T(L){g(!1),L.value!==s&&r(L.value)}function C(L){if(L.key==="Escape"){if(!m)return;L.preventDefault(),L.stopPropagation(),g(!1);return}if(L.key==="ArrowDown"||L.key==="ArrowUp"){if(L.preventDefault(),!m)return g(!0);const X=L.key==="ArrowDown"?1:l.length-1;return _(J=>(J+X)%l.length)}if(L.key==="Enter"||L.key===" "){if(L.preventDefault(),!m)return g(!0);const X=l[b];X&&T(X)}}return i.jsxs("div",{ref:S,className:"select"+(m?" select--open":"")+(c?` ${c}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:o,"aria-label":d??o,"aria-haspopup":"listbox","aria-expanded":m,onClick:()=>g(L=>!L),onKeyDown:C,children:[i.jsx("span",{className:"select__value",children:(E==null?void 0:E.label)??h}),i.jsx(wj,{})]}),m&&i.jsx("div",{ref:v,className:"select__menu",role:"listbox","aria-label":d??o,children:l.map((L,X)=>i.jsxs("button",{type:"button",role:"option","aria-selected":L.value===s,className:"select__option"+(X===b?" is-cursor":"")+(L.value===s?" is-on":""),onMouseEnter:()=>_(X),onClick:()=>T(L),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:L.value===s?"✓":""}),i.jsx("span",{className:"select__label",children:L.label}),L.hint&&i.jsx("span",{className:"select__hint",children:L.hint})]},L.value))})]})}function Sj(s){let l=(s==null?void 0:s.parentElement)??null;for(;l;){if(l.scrollHeight>l.clientHeight&&getComputedStyle(l).overflowY!=="visible")return l;l=l.parentElement}return null}function wj(){return i.jsx("svg",{className:"select__chev",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M3 4.5 6 7.5 9 4.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function kj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"6.6",cy:"6.6",r:"4.3"}),i.jsx("path",{d:"M9.7 9.7 14 14"}),i.jsx("path",{d:"M6.6 4.6v4M4.6 6.6h4"})]})}function Nj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"6.6",cy:"6.6",r:"4.3"}),i.jsx("path",{d:"M9.7 9.7 14 14"}),i.jsx("path",{d:"M4.6 6.6h4"})]})}function Tj(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M13 8a5 5 0 1 1-1.6-3.7"}),i.jsx("path",{d:"M13 2.5v3.3h-3.3"})]})}function Ej({path:s,mime:l,base64:r,error:c,tooLarge:o,size:d,onRequestMedia:h}){y.useEffect(()=>{!o&&r===void 0&&c===void 0&&h(s)},[]);const m=Cj(r,l);return o?i.jsx("div",{className:"mediaview mediaview--message",children:i.jsxs("p",{className:"mediaview__error",children:["Файл слишком велик для просмотра (",Of(d),"). Лимит — 64 МБ."]})}):c?i.jsxs("div",{className:"mediaview mediaview--message",role:"alert",children:[i.jsx("p",{className:"mediaview__error",children:c}),i.jsx("button",{className:"btn btn--sm btn--primary",onClick:()=>h(s),children:"Повторить"})]}):m?l.startsWith("image/")?i.jsx(Mj,{url:m}):l.startsWith("video/")?i.jsx(Dj,{url:m}):null:i.jsxs("div",{className:"mediaview mediaview--message",role:"status",children:[i.jsx("div",{className:"mediaview__progress",children:i.jsx("div",{className:"mediaview__progress-fill"})}),i.jsx("span",{className:"mediaview__label",children:"Загружается…"})]})}function Cj(s,l){const[r,c]=y.useState(null);return y.useEffect(()=>{if(s===void 0){c(null);return}const o=atob(s),d=new Uint8Array(o.length);for(let m=0;m<o.length;m++)d[m]=o.charCodeAt(m);const h=URL.createObjectURL(new Blob([d],{type:l}));return c(h),()=>URL.revokeObjectURL(h)},[s,l]),r}const Ni=1,Uy=8,xf=1.25;function Aj(s){return Math.min(Uy,Math.max(Ni,s))}function Mj({url:s}){const[l,r]=y.useState({scale:Ni,x:0,y:0}),[c,o]=y.useState(!1),d=y.useRef(null),h=y.useRef(null);function m(E,T,C){r(L=>{const X=Aj(L.scale*E);if(X===L.scale)return L;if(X<=Ni)return{scale:Ni,x:0,y:0};const J=(T-L.x)/L.scale,G=(C-L.y)/L.scale;return{scale:X,x:T-X*J,y:C-X*G}})}y.useEffect(()=>{const E=d.current;if(!E)return;function T(C){C.preventDefault();const L=E.getBoundingClientRect(),X=C.clientX-L.left-L.width/2,J=C.clientY-L.top-L.height/2;m(C.deltaY<0?xf:1/xf,X,J)}return E.addEventListener("wheel",T,{passive:!1}),()=>E.removeEventListener("wheel",T)},[]);function g(E){l.scale<=Ni||(E.currentTarget.setPointerCapture(E.pointerId),h.current={pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,origX:l.x,origY:l.y},o(!0))}function b(E){const T=h.current;!T||T.pointerId!==E.pointerId||r(C=>({...C,x:T.origX+(E.clientX-T.startX),y:T.origY+(E.clientY-T.startY)}))}function _(){h.current=null,o(!1)}const S=l.scale>Ni,v=!S&&l.x===0&&l.y===0;return i.jsxs("div",{className:"mediaview mediaview--image",children:[i.jsx("div",{ref:d,className:"mediaview__stage"+(S?c?" is-dragging":" is-zoomed":""),onPointerDown:g,onPointerMove:b,onPointerUp:_,onPointerCancel:_,children:i.jsx("img",{src:s,alt:"",className:"mediaview__image",draggable:!1,style:{transform:`translate(${l.x}px, ${l.y}px) scale(${l.scale})`}})}),i.jsxs("div",{className:"mediaview__toolbar",children:[i.jsx("button",{className:"btn btn--sm",disabled:l.scale<=Ni,title:"Уменьшить","aria-label":"Уменьшить",onClick:()=>m(1/xf,0,0),children:i.jsx(Nj,{})}),i.jsxs("span",{className:"mediaview__zoomlabel",children:[Math.round(l.scale*100),"%"]}),i.jsx("button",{className:"btn btn--sm",disabled:l.scale>=Uy,title:"Увеличить","aria-label":"Увеличить",onClick:()=>m(xf,0,0),children:i.jsx(kj,{})}),i.jsx("button",{className:"btn btn--sm",disabled:v,title:"Вписать в окно","aria-label":"Сбросить масштаб — вписать в окно",onClick:()=>r({scale:Ni,x:0,y:0}),children:i.jsx(Tj,{})})]})]})}const Rj=[{value:"0.5",label:"0.5×"},{value:"0.75",label:"0.75×"},{value:"1",label:"1× — обычная"},{value:"1.25",label:"1.25×"},{value:"1.5",label:"1.5×"},{value:"2",label:"2×"}];function Dj({url:s}){const l=y.useRef(null),[r,c]=y.useState("1");return y.useEffect(()=>{l.current&&(l.current.playbackRate=Number(r))},[r]),i.jsxs("div",{className:"mediaview mediaview--video",children:[i.jsx("video",{ref:l,className:"mediaview__video",src:s,controls:!0}),i.jsxs("div",{className:"mediaview__speedbar",children:[i.jsx("span",{className:"mediaview__speedlabel",children:"Скорость"}),i.jsx(Cs,{className:"mediaview__speedselect",value:r,onChange:c,ariaLabel:"Скорость воспроизведения",options:Rj})]})]})}function Oj({file:s,goto:l,onChange:r,onSave:c,onReload:o,onOverwrite:d,onRequestMedia:h,onTogglePreview:m}){const g=Ra(s),b=Ly(s.path)&&!s.binary&&!s.tooLarge;return i.jsxs("div",{className:"editor",children:[i.jsxs("div",{className:"editor__bar",children:[i.jsx("span",{className:"editor__path",title:s.path,children:s.path}),i.jsxs("span",{className:"editor__meta",children:[Of(s.size),s.eol==="crlf"&&" · CRLF"]}),b&&i.jsxs("div",{className:"editor__viewtoggle",role:"tablist","aria-label":"Режим просмотра",children:[i.jsx("button",{className:"btn btn--sm"+(s.previewMode?" is-on":""),role:"tab","aria-selected":s.previewMode,onClick:()=>!s.previewMode&&m(s.path),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(s.previewMode?"":" is-on"),role:"tab","aria-selected":!s.previewMode,onClick:()=>s.previewMode&&m(s.path),children:"Код"})]}),i.jsx("button",{className:"btn btn--sm",disabled:!g,title:"Сохранить (Ctrl+S)",onClick:()=>c(s.path),children:g?"Сохранить":"Сохранено"})]}),s.stale&&i.jsxs("div",{className:"editor__warn",children:[i.jsxs("span",{children:["Файл изменился на диске",g?" — а здесь есть несохранённые правки.":"."]}),i.jsx("button",{className:"btn btn--sm",onClick:()=>o(s.path),children:"Взять с диска"}),g&&i.jsx("button",{className:"btn btn--sm btn--danger",onClick:()=>d(s.path),children:"Сохранить поверх"})]}),s.binary&&s.mediaMime?i.jsx(Ej,{path:s.path,mime:s.mediaMime,base64:s.mediaBase64,error:s.mediaError,tooLarge:s.mediaTooLarge,size:s.size,onRequestMedia:h},s.path):s.binary?i.jsxs("p",{className:"editor__empty",children:["Это не текстовый файл — редактировать его здесь нечем. ",Of(s.size)," на диске."]}):s.tooLarge?i.jsxs("p",{className:"editor__empty",children:["Файл слишком велик для редактора (",Of(s.size),"). Такие правит агент, а не браузер."]}):b&&s.previewMode?i.jsx(Lj,{text:s.text}):i.jsx(jj,{path:s.path,doc:s.text,revision:s.revision,goto:l,onChange:r,onSave:c})]})}function Lj({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return Qf(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:l}})}function zj({files:s,activePath:l,busy:r,onSelect:c,onClose:o,zoomed:d,onToggleZoom:h}){return i.jsxs("div",{className:"worktabs",role:"tablist",onDoubleClick:m=>{h&&(m.target.closest("button")||h())},children:[i.jsxs("button",{className:"worktab"+(l===null?" is-on":""),role:"tab","aria-selected":l===null,onClick:()=>c(null),onDoubleClick:()=>h==null?void 0:h(),children:[i.jsx("span",{className:"worktab__name",children:"Разговор"}),r&&i.jsx("span",{className:"worktab__dot worktab__dot--busy",title:"Агент работает"})]}),s.map(m=>i.jsxs("div",{className:"worktab"+(m.path===l?" is-on":""),role:"tab","aria-selected":m.path===l,onDoubleClick:g=>{h&&(g.target.closest(".worktab__close, .worktab__dot")||h())},children:[i.jsx("button",{className:"worktab__name",title:m.path,onClick:()=>c(m.path),children:nj(m.path)}),Ra(m)?i.jsx("button",{className:"worktab__dot",title:"Не сохранено — закрыть","aria-label":`Закрыть ${m.path}`,onClick:()=>o(m.path)}):i.jsx("button",{className:"worktab__close",title:"Закрыть","aria-label":`Закрыть ${m.path}`,onClick:()=>o(m.path),children:"✕"})]},m.path)),i.jsx("div",{className:"worktabs__spacer"}),h&&i.jsx("button",{className:"worktabs__zoom",title:d?"Свернуть — то же самое, что двойной клик по вкладке":"Развернуть на весь экран — то же самое, что двойной клик по вкладке","aria-label":d?"Свернуть колонку разговора":"Развернуть колонку разговора на весь экран","aria-pressed":d,onClick:h,children:i.jsx(Sc,{active:d})})]})}function os(s){return s.claudeSessionId??s.id}function yf(s,l,r,c){if(!l||l.length===0)return s;const o=new Map(l.map((m,g)=>[m,g])),d=[],h=[];for(const m of s)(o.has(r(m))?d:h).push(m);return d.sort((m,g)=>o.get(r(m))-o.get(r(g))),c==="top"?[...h,...d]:[...d,...h]}function _x(s){return s.state!=="closed"}function vx(s){return[...s.filter(_x),...s.filter(l=>!_x(l))]}function _f(s,l,r,c){if(l===r||!s.includes(l)||!s.includes(r))return null;const o=s.filter(m=>m!==l),d=o.indexOf(r)+(c==="after"?1:0),h=[...o.slice(0,d),l,...o.slice(d)];return h.every((m,g)=>m===s[g])?null:h}function Ap(s,l,r,c){const o=s%10,d=s%100;return o===1&&d!==11?l:o>=2&&o<=4&&(d<12||d>14)?r:c}function Hy(s){return`${s} ${Ap(s,"агент","агента","агентов")}`}function Uj(s){const l=s.filter(o=>o.kind==="agent").length,r=s.length-l,c=[];return l>0&&c.push(Hy(l)),r>0&&c.push(`${r} ${Ap(r,"задача","задачи","задач")} в фоне`),c.join(" · ")}function Hj(s){switch(s.kind){case"agent":return s.agentType??"агент";case"shell":return"команда";case"workflow":return"сценарий";default:return"задача"}}function Bj(s){const l=Math.max(0,Math.floor(s/1e3)),r=Math.floor(l/3600),c=Math.floor(l%3600/60),o=l%60,d=String(o).padStart(2,"0");return r>0?`${r}:${String(c).padStart(2,"0")}:${d}`:`${c}:${d}`}function Ij(s){return s<1e3?`${s} ток.`:`${(s/1e3).toFixed(1).replace(".",",")} k ток.`}function qj({tasks:s,onStop:l}){const[r,c]=y.useState(!1),[o,d]=y.useState(()=>Date.now()),[h,m]=y.useState(()=>new Set);y.useEffect(()=>{const b=window.setInterval(()=>d(Date.now()),1e3);return()=>window.clearInterval(b)},[]),y.useEffect(()=>{m(b=>{const _=new Set(s.map(v=>v.id)),S=new Set([...b].filter(v=>_.has(v)));return S.size===b.size?b:S})},[s]);const g=b=>{m(_=>new Set(_).add(b)),l(b),window.setTimeout(()=>{m(_=>{if(!_.has(b))return _;const S=new Set(_);return S.delete(b),S})},1e4)};return i.jsxs("div",{className:r?"tasks is-open":"tasks",children:[i.jsxs("button",{type:"button",className:"tasks__toggle","aria-expanded":r,"aria-controls":"tasks-list",onClick:()=>c(b=>!b),children:[i.jsx("span",{className:"tasks__dot","aria-hidden":"true"}),i.jsx("span",{className:"tasks__summary",children:Uj(s)}),i.jsx("svg",{className:"tasks__chev",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4 6.5l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),r&&i.jsx("ul",{className:"tasks__list",id:"tasks-list",children:s.map(b=>{const _=h.has(b.id);return i.jsxs("li",{className:_?"task is-stopping":"task",children:[i.jsxs("div",{className:"task__main",children:[i.jsxs("div",{className:"task__head",children:[i.jsx("span",{className:"task__kind",children:Hj(b)}),b.background&&i.jsx("span",{className:"task__bg",children:"фон"}),i.jsx("span",{className:"task__time",children:Bj(o-b.startedAt)})]}),i.jsx("div",{className:"task__desc",title:b.description,children:b.description}),(b.activity||b.lastTool)&&i.jsx("div",{className:"task__activity",title:b.activity??b.lastTool??void 0,children:b.activity??b.lastTool}),i.jsxs("div",{className:"task__stats",children:[Ij(b.tokens)," · ",b.toolUses," ",Ap(b.toolUses,"вызов","вызова","вызовов")]})]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--danger task__stop",disabled:_,"aria-label":`Остановить: ${b.description}`,onClick:()=>g(b.id),children:_?"Останавливается":"Стоп"})]},b.id)})})]})}const Gj=""+new URL("antigravity-logo-DRKQga2U.png",import.meta.url).href;function By({className:s}){return i.jsx("img",{src:Gj,alt:"","aria-hidden":"true",className:s,style:{aspectRatio:"200 / 184"}})}const Yj=450,Xj=6,vf=[{id:"claude",label:"Claude",hint:"Claude Code — как обычно"},{id:"antigravity",label:"Antigravity",hint:"Google agy, отдельная палитра и права"}];function $j({disabled:s,onStart:l}){const[r,c]=y.useState(!1),[o,d]=y.useState(0),[h,m]=y.useState({left:0,top:0}),g=y.useRef(null),b=y.useRef(null),_=y.useRef(null);function S(){_.current&&window.clearTimeout(_.current.timer),_.current=null}function v(){S(),d(0),c(!0)}function E(M){var D;c(!1),M&&((D=g.current)==null||D.focus())}function T(M){if(s||M.button!==0)return;const D={timer:0,x:M.clientX,y:M.clientY,fired:!1};D.timer=window.setTimeout(()=>{D.fired=!0,v()},Yj),_.current=D}function C(M){const D=_.current;!D||D.fired||Math.hypot(M.clientX-D.x,M.clientY-D.y)>Xj&&S()}function L(){_.current&&!_.current.fired&&S()}function X(M){var D;if((D=_.current)!=null&&D.fired){_.current=null,M.preventDefault();return}s||l("claude")}function J(M){M.preventDefault(),!s&&v()}function G(M){if(s)return;(M.key==="ArrowDown"||M.key==="ArrowUp"||M.key==="Enter"&&M.shiftKey)&&(M.preventDefault(),v())}y.useLayoutEffect(()=>{if(!r)return;const M=g.current,D=b.current;if(!M||!D)return;const H=M.getBoundingClientRect(),ne=D.getBoundingClientRect(),he=8,W=Math.max(he,Math.min(H.right-ne.width,window.innerWidth-ne.width-he));let ue=H.top-ne.height-8;ue<he&&(ue=Math.min(H.bottom+8,window.innerHeight-ne.height-he)),m({left:W,top:ue})},[r]),y.useLayoutEffect(()=>{var M;r&&((M=b.current)==null||M.focus())},[r]),y.useLayoutEffect(()=>{if(!r)return;function M(D){var ne,he;const H=D.target;!((ne=b.current)!=null&&ne.contains(H))&&!((he=g.current)!=null&&he.contains(H))&&E(!1)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[r]);function O(M){E(!1),l(M.id)}function Z(M){if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),E(!0);return}if(M.key==="ArrowDown"||M.key==="ArrowUp"){M.preventDefault();const D=M.key==="ArrowDown"?1:-1;d(H=>(H+D+vf.length)%vf.length);return}if(M.key==="Enter"||M.key===" "){M.preventDefault();const D=vf[o];D&&O(D);return}M.key==="Tab"&&E(!1)}return i.jsxs("div",{className:"newsession",children:[i.jsxs("button",{ref:g,type:"button",className:"btn btn--primary newsession__btn",disabled:s,title:"Удерживайте, чтобы выбрать агента","aria-haspopup":"menu","aria-expanded":r,onClick:X,onContextMenu:J,onPointerDown:T,onPointerMove:C,onPointerUp:L,onPointerCancel:L,onPointerLeave:L,onKeyDown:G,children:["+ Сессия",i.jsx(Vj,{})]}),r&&i.jsx("div",{ref:b,className:"newsession__menu",style:{left:h.left,top:h.top},role:"menu","aria-label":"Выбрать агента для новой сессии",tabIndex:-1,onKeyDown:Z,children:vf.map((M,D)=>i.jsxs("button",{type:"button",role:"menuitem",className:"newsession__item"+(D===o?" is-cursor":""),onMouseEnter:()=>d(D),onClick:()=>O(M),children:[i.jsx("span",{className:`newsession__mark newsession__mark--${M.id}`,"aria-hidden":"true",children:M.id==="antigravity"?i.jsx(By,{className:"newsession__mark-logo"}):i.jsx(Qj,{})}),i.jsxs("span",{className:"newsession__text",children:[i.jsx("span",{className:"newsession__label",children:M.label}),i.jsx("span",{className:"newsession__hint",children:M.hint})]})]},M.id))})]})}function Vj(){return i.jsx("svg",{className:"newsession__caret",viewBox:"0 0 10 6",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M1 1.2 5 5 9 1.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qj(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"var(--accent)"})})}const Iy="ccv:sidebar.collapsed",qy="ccv:sidebar.mode",Gy="ccv:sidebar.foldersCollapsed",Kj=500,$h="транскрипт остаётся на диске — сессию можно вернуть из архива в любой момент.";function Zj({open:s,connected:l,status:r,workspaces:c,archivedWorkspaces:o,workspaceFolders:d,sessionFolders:h,pinnedFolders:m,sessions:g,archived:b,pinned:_,live:S,listOrder:v,liveSessionsFirst:E,onReorder:T,activeWorkspaceId:C,activeSessionId:L,onSelectWorkspace:X,onSelectSession:J,onRenameSession:G,onStopSession:O,onPinSessions:Z,onSelectPinned:M,onCloseWorkspaces:D,onRestoreWorkspaces:H,onArchiveSessions:ne,onUnarchiveSessions:he,onCreateFolder:W,onRenameFolder:ue,onDeleteFolder:je,onAssignToFolder:Me,onOpenWorkspace:Ce,onNewSession:A,onOpenExtensions:ce,account:z,onOpenAccount:be,relay:ye,onOpenRelay:N,onOpenSettings:V,themeMode:re,onCycleTheme:me}){var dt;const[Ne,ve]=y.useState(null),[De,yt]=y.useState(null),[Xe,$e]=y.useState(null),[Ve,It]=y.useState(""),[rt,dn]=y.useState(oS),[ft,hn]=y.useState(uS),[Sn,xn]=y.useState(fS);function en(w){xn(w);try{localStorage.setItem(qy,w)}catch{}}const tt=Ve.trim().toLowerCase(),et=tt!=="",tn=y.useMemo(()=>yf(c,v==null?void 0:v.workspaces,w=>w.id,"bottom"),[c,v]),Xt=y.useMemo(()=>{const w=yf(g,C?v==null?void 0:v.sessions[C]:void 0,os,"top");return E?vx(w):w},[g,v,C,E]),nt=y.useMemo(()=>{const w=yf(_,v==null?void 0:v.pinned,os,"bottom");return E?vx(w):w},[_,v,E]),St=y.useMemo(()=>yf(S,v==null?void 0:v.live,os,"bottom"),[S,v]),$t=y.useMemo(()=>et?tn.filter(w=>w.name.toLowerCase().includes(tt)||w.path.toLowerCase().includes(tt)):tn,[tn,tt,et]),cn=y.useMemo(()=>et?o.filter(w=>w.name.toLowerCase().includes(tt)||w.path.toLowerCase().includes(tt)):o,[o,tt,et]),wt=y.useMemo(()=>et?Xt.filter(w=>(w.title??"").toLowerCase().includes(tt)):Xt,[Xt,tt,et]),yn=y.useMemo(()=>et?b.filter(w=>(w.title??"").toLowerCase().includes(tt)):b,[b,tt,et]),qt=w=>{var se;return((se=c.find(ke=>ke.id===w))==null?void 0:se.name)??"—"},pn=w=>{var se;return(se=c.find(ke=>ke.id===w))==null?void 0:se.path},Dn=y.useMemo(()=>et?nt.filter(w=>(w.title??"").toLowerCase().includes(tt)||qt(w.workspaceId).toLowerCase().includes(tt)):nt,[nt,c,tt,et]),Gt=y.useMemo(()=>et?St.filter(w=>(w.title??"").toLowerCase().includes(tt)||qt(w.workspaceId).toLowerCase().includes(tt)):St,[St,c,tt,et]),ct=!et;function Et(w){dn(se=>{const ke=se.includes(w)?se.filter(Je=>Je!==w):[...se,w];try{localStorage.setItem(Iy,JSON.stringify(ke))}catch{}return ke})}const Pe=w=>!rt.includes(w);function wl(w){hn(se=>{const ke=se.includes(w)?se.filter(Je=>Je!==w):[...se,w];try{localStorage.setItem(Gy,JSON.stringify(ke))}catch{}return ke})}const le=w=>!ft.includes(w),ge=y.useMemo(()=>Ro($t,d),[$t,d]),He=y.useMemo(()=>Ro(cn,d),[cn,d]),B=y.useMemo(()=>Ro(wt,h),[wt,h]),P=y.useMemo(()=>Ro(yn,h),[yn,h]),_e=y.useMemo(()=>Ro(Dn,m,w=>w.pinnedFolderId),[Dn,m]),Be=y.useMemo(()=>({groups:[],ungrouped:Gt}),[Gt]),Ot=((v==null?void 0:v.workspaces.length)??0)>0,fl=C?(((dt=v==null?void 0:v.sessions[C])==null?void 0:dt.length)??0)>0:!1,On=((v==null?void 0:v.pinned.length)??0)>0,dl=((v==null?void 0:v.live.length)??0)>0,sl=jf({enabled:ct,scope:"workspaces",itemKey:w=>w.id,groups:ge.groups,ungrouped:ge.ungrouped,onReorder:T}),Bl=jf({enabled:ct,scope:"sessions",workspaceId:C??void 0,itemKey:os,groups:B.groups,ungrouped:B.ungrouped,onReorder:T}),ds=jf({enabled:ct,scope:"pinned",itemKey:os,groups:_e.groups,ungrouped:_e.ungrouped,onReorder:T}),hl=jf({enabled:ct,scope:"live",itemKey:os,groups:Be.groups,ungrouped:Be.ungrouped,onReorder:T}),al=Qh($t),pl=Qh(cn),Yt=Qh(wt),[Vt,kl]=y.useState(null),[kt,Qt]=y.useState(null),[Oe,Ct]=y.useState(null),[qn,nn]=y.useState(null),[Ln,il]=y.useState(null),wn=y.useRef(null);function Il(w,se){const ke=w.touches[0];if(!ke)return;const Je={timer:0,x:ke.clientX,y:ke.clientY,el:w.currentTarget,fired:!1};Je.timer=window.setTimeout(()=>{Je.fired=!0,se(Je.x,Je.y,Je.el)},Kj),wn.current=Je}function rl(w){const se=wn.current,ke=w.touches[0];!se||!ke||Math.hypot(ke.clientX-se.x,ke.clientY-se.y)>10&&(window.clearTimeout(se.timer),wn.current=null)}function ln(w){const se=wn.current;se&&(window.clearTimeout(se.timer),se.fired&&w.preventDefault())}function Kt(){var w;return(w=wn.current)!=null&&w.fired?(wn.current=null,!0):!1}function on(){const w=Vt==null?void 0:Vt.opener;kl(null),w!=null&&w.isConnected&&w.focus()}function Fe(){const w=kt==null?void 0:kt.opener;Qt(null),w!=null&&w.isConnected&&w.focus()}function ml(){const w=Oe==null?void 0:Oe.opener;Ct(null),w!=null&&w.isConnected&&w.focus()}function Ms(){const w=qn==null?void 0:qn.opener;nn(null),w!=null&&w.isConnected&&w.focus()}function Gn(){const w=Ln==null?void 0:Ln.opener;il(null),w!=null&&w.isConnected&&w.focus()}function Zl(w){return{onContextMenu:se=>{se.preventDefault(),kl({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:al.targetsFor(w)})},onTouchStart:se=>Il(se,(ke,Je,ht)=>kl({x:ke,y:Je,opener:ht,ids:al.targetsFor(w)})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function hs(w){return{onContextMenu:se=>{se.preventDefault(),Qt({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:pl.targetsFor(w)})},onTouchStart:se=>Il(se,(ke,Je,ht)=>Qt({x:ke,y:Je,opener:ht,ids:pl.targetsFor(w)})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function ps(w){return{onContextMenu:se=>{se.preventDefault(),Ct({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:Yt.targetsFor(w)})},onTouchStart:se=>Il(se,(ke,Je,ht)=>Ct({x:ke,y:Je,opener:ht,ids:Yt.targetsFor(w)})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function mn(w){return{onContextMenu:se=>{se.preventDefault(),nn({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:[w.id]})},onTouchStart:se=>Il(se,(ke,Je,ht)=>nn({x:ke,y:Je,opener:ht,ids:[w.id]})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}function Fl(w){return{onContextMenu:se=>{se.preventDefault(),il({x:se.clientX,y:se.clientY,opener:se.currentTarget,ids:[w.id]})},onTouchStart:se=>Il(se,(ke,Je,ht)=>il({x:ke,y:Je,opener:ht,ids:[w.id]})),onTouchMove:rl,onTouchEnd:ln,onTouchCancel:ln}}const Zn=g.filter(w=>w.state!=="closed").length,zn=Vt?$t.find(w=>w.id===Vt.ids[0]):void 0,kn=Vt?[{id:"close",label:Vt.ids.length>1?`Закрыть проекты (${Vt.ids.length})`:"Закрыть проект",onSelect:()=>{D(Vt.ids),al.clear()}},...Do({folders:d,ids:Vt.ids,hasFolder:(zn==null?void 0:zn.folderId)!=null,assign:(w,se)=>Me("workspace",w,se),onClear:()=>al.clear(),onNewFolder:()=>$e("workspace")}),...Vt.ids.length===1&&ct?sl.menuItems(Vt.ids[0],Ot):[]]:[],Lt=Vt?"закрытие не удаляет проект: каталог и история сессий остаются на диске — открыть его снова можно кнопкой «+ Проект»."+(C&&Vt.ids.includes(C)&&Zn>0?` в нём сейчас незавершённых сессий: ${Zn} — при закрытии они остановятся на хосте.`:""):void 0,Rs=kt?cn.find(w=>w.id===kt.ids[0]):void 0,Di=kt?[{id:"restore",label:kt.ids.length>1?`Вернуть проекты (${kt.ids.length})`:"Вернуть проект",onSelect:()=>{H(kt.ids),pl.clear()}},...Do({folders:d,ids:kt.ids,hasFolder:(Rs==null?void 0:Rs.folderId)!=null,assign:(w,se)=>Me("workspace",w,se),onClear:()=>pl.clear(),onNewFolder:()=>$e("workspace")})]:[],Ds=kt?"каталог и история сессий всё это время оставались на диске — восстановление их не трогает.":void 0,Yn=Oe?wt.find(w=>w.id===Oe.ids[0]):void 0,Nl=(Yn==null?void 0:Yn.pinned)!==!0,La=Oe?[...Oe.ids.length===1?[{id:"rename",label:"Переименовать",onSelect:()=>ve(Oe.ids[0])}]:[],{id:"pin",label:Nl?Oe.ids.length>1?`Закрепить (${Oe.ids.length})`:"Закрепить":Oe.ids.length>1?`Открепить (${Oe.ids.length})`:"Открепить",onSelect:()=>{Yn&&Z(Yn.workspaceId,Oe.ids,Nl),Yt.clear()}},{id:"archive",label:Oe.ids.length>1?`Убрать в архив (${Oe.ids.length})`:"Убрать в архив",onSelect:()=>{ne(C,Oe.ids),Yt.clear()}},...Do({folders:h,ids:Oe.ids,hasFolder:(Yn==null?void 0:Yn.folderId)!=null,assign:(w,se)=>Me("session",w,se,C),onClear:()=>Yt.clear(),onNewFolder:()=>$e("session")}),...Oe.ids.length===1&&ct&&Yn?Bl.menuItems(os(Yn),fl):[]]:[],Nn=Oe?$h:void 0,sn=qn?Dn.find(w=>w.id===qn.ids[0]):void 0,Jl=qn?[{id:"rename",label:"Переименовать",onSelect:()=>ve(qn.ids[0])},{id:"unpin",label:"Открепить",onSelect:()=>{sn&&Z(sn.workspaceId,[sn.id],!1)}},{id:"archive",label:"Убрать в архив",onSelect:()=>{sn&&ne(sn.workspaceId,[sn.id])}},...sn&&sn.workspaceId===C?Do({folders:h,ids:[sn.id],hasFolder:sn.folderId!=null,assign:(w,se)=>Me("session",w,se,sn.workspaceId),onClear:()=>{},onNewFolder:()=>$e("session")}):[],...Pj(sn?Do({folders:m,ids:[sn.id],hasFolder:sn.pinnedFolderId!=null,assign:(w,se)=>Me("pinned",w,se),onClear:()=>{},onNewFolder:()=>$e("pinned")}):[]),...ct&&sn?ds.menuItems(os(sn),On):[]]:[],lt=Ln?Gt.find(w=>w.id===Ln.ids[0]):void 0,Xn=Ln?[{id:"stop",label:"Остановить",onSelect:()=>{lt&&O(lt)}},{id:"rename",label:"Переименовать",onSelect:()=>ve(Ln.ids[0])},{id:"pin",label:(lt==null?void 0:lt.pinned)===!0?"Открепить":"Закрепить",onSelect:()=>{lt&&Z(lt.workspaceId,[lt.id],lt.pinned!==!0)}},{id:"archive",label:"Убрать в архив",onSelect:()=>{lt&&ne(lt.workspaceId,[lt.id])}},...ct&<?hl.menuItems(os(lt),dl):[]]:[];function pe(w){return i.jsxs("div",{"data-row-key":w.id,className:lc(w.id===C,al.selected.includes(w.id))+sl.dropClass(w.id),...Zl(w),children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить проект, чтобы изменить порядок в списке",...sl.gripHandlers(w.id),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:se=>{Kt()||al.click(se,w,()=>X(w.id))},onKeyDown:se=>sl.onKeyDown(w.id,se),children:[i.jsxs("span",{className:"row__title",children:[w.name,w.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",title:w.path,children:w.path})]})]},w.id)}function k(w){return i.jsxs("div",{className:lc(w.id===C,pl.selected.includes(w.id)),...hs(w),children:[i.jsxs("button",{className:"row__main",onClick:se=>{Kt()||pl.click(se,w,()=>X(w.id))},children:[i.jsxs("span",{className:"row__title",children:[w.name,w.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",children:yS(w)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть проект из архива",onClick:()=>H([w.id]),children:"Вернуть"})]},w.id)}function Y(w){const se=os(w);return i.jsx("div",{"data-row-key":se,className:lc(w.id===L,Yt.selected.includes(w.id),w.provider==="antigravity")+Bl.dropClass(se),...Ne===w.id?{}:ps(w),children:Ne===w.id?i.jsx("div",{className:"row__main",children:i.jsx(na,{value:w.title??"",onCommit:ke=>{G(w,ke),ve(null)},onCancel:()=>ve(null)})}):i.jsxs(i.Fragment,{children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить сессию, чтобы изменить порядок в списке",...Bl.gripHandlers(se),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:ke=>{Kt()||Yt.click(ke,w,()=>J(w))},onKeyDown:ke=>Bl.onKeyDown(se,ke),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:w.pinned===!0,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx(Kh,{session:w,tail:new Date(w.updatedAt).toLocaleString()})]}),i.jsx("button",{className:"row__edit",title:"Переименовать","aria-label":"Переименовать сессию",onClick:()=>{Kt()||ve(w.id)},children:"✎"})]})},w.id)}function fe(w){return i.jsxs("div",{className:lc(w.id===L,!1,w.provider==="antigravity"),children:[i.jsxs("button",{className:"row__main",onClick:()=>J(w),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:!1,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx("span",{className:"row__meta",children:xS(w)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть сессию из архива",onClick:()=>he([w.id]),children:"Вернуть"})]},w.id)}function we(w){const se=os(w);return i.jsx("div",{"data-row-key":se,className:lc(w.id===L,!1,w.provider==="antigravity")+ds.dropClass(se),...Ne===w.id?{}:{title:"Действия со строкой — правый клик или долгое нажатие",...mn(w)},children:Ne===w.id?i.jsx("div",{className:"row__main",children:i.jsx(na,{value:w.title??"",onCommit:ke=>{G(w,ke),ve(null)},onCancel:()=>ve(null)})}):i.jsxs(i.Fragment,{children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить сессию, чтобы изменить порядок в списке",...ds.gripHandlers(se),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:()=>{Kt()||M(w)},onKeyDown:ke=>ds.onKeyDown(se,ke),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:!1,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx(Kh,{session:w,tail:new Date(w.updatedAt).toLocaleString()})]})]})},w.id)}function Ae(w){const se=os(w);return i.jsx("div",{"data-row-key":se,className:lc(w.id===L,!1,w.provider==="antigravity")+hl.dropClass(se),...Ne===w.id?{}:{title:"Действия со строкой — правый клик или долгое нажатие",...Fl(w)},children:Ne===w.id?i.jsx("div",{className:"row__main",children:i.jsx(na,{value:w.title??"",onCommit:ke=>{G(w,ke),ve(null)},onCancel:()=>ve(null)})}):i.jsxs(i.Fragment,{children:[ct&&i.jsx("button",{type:"button",className:"row__grip",title:"Перетащить, чтобы изменить порядок","aria-label":"Перетащить сессию, чтобы изменить порядок в списке",...hl.gripHandlers(se),children:i.jsx(Sf,{})}),i.jsxs("button",{className:"row__main",onClick:()=>{Kt()||M(w)},onKeyDown:ke=>hl.onKeyDown(se,ke),children:[i.jsx(wf,{title:w.title??"Без названия",pinned:w.pinned===!0,provider:w.provider,projectName:qt(w.workspaceId),projectPath:pn(w.workspaceId)}),i.jsx(Kh,{session:w,tail:new Date(w.updatedAt).toLocaleString()})]}),i.jsx("button",{type:"button",className:"row__stop",title:"Остановить сессию","aria-label":"Остановить сессию",onClick:ke=>{ke.stopPropagation(),!Kt()&&O(w)},children:i.jsx(aS,{})})]})},w.id)}function ze(w,se){return i.jsx(sS,{folder:w,count:se,open:le(w.id),renaming:De===w.id,onToggle:()=>wl(w.id),onStartRename:()=>yt(w.id),onCommitRename:ke=>{ue(w.id,ke),yt(null)},onCancelRename:()=>yt(null),onDelete:()=>je(w.id)},w.id)}return i.jsxs("aside",{className:s?"sidebar sidebar--open":"sidebar",children:[i.jsxs("div",{className:"sidebar__head",children:[i.jsx("span",{className:l?"dot dot--on":"dot",title:r}),i.jsx("span",{className:"brand",children:"Claude Code Visual"}),i.jsx("button",{className:"theme-btn",title:`Тема: ${Sx[re]}`,"aria-label":`Тема: ${Sx[re]}. Переключить`,onClick:me,children:i.jsx(dS,{mode:re})})]}),i.jsxs("div",{className:"sidebar__tabs",role:"tablist","aria-label":"Что показывать в списке",children:[i.jsx("button",{type:"button",role:"tab","aria-selected":Sn==="default",className:Sn==="default"?"sidebar__tab is-active":"sidebar__tab",onClick:()=>en("default"),children:i.jsx("span",{className:"sidebar__tab-label",children:"Все"})}),i.jsx("button",{type:"button",role:"tab","aria-selected":Sn==="pinned",className:Sn==="pinned"?"sidebar__tab is-active":"sidebar__tab",onClick:()=>en("pinned"),children:i.jsx("span",{className:"sidebar__tab-label",children:"Закреплённые"})}),i.jsxs("button",{type:"button",role:"tab","aria-selected":Sn==="live",className:Sn==="live"?"sidebar__tab is-active":"sidebar__tab",onClick:()=>en("live"),children:[i.jsx("span",{className:"sidebar__tab-label",children:"Запущенные"}),S.length>0&&i.jsx("span",{className:"sidebar__tab-count",children:S.length})]})]}),i.jsxs("div",{className:"fssearch fssearch--sidebar",children:[i.jsx(rS,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:Ve,spellCheck:!1,placeholder:"Проект или сессия…","aria-label":"Поиск по проектам и сессиям",onChange:w=>It(w.target.value),onKeyDown:w=>{w.stopPropagation(),w.key==="Escape"&&(w.preventDefault(),Ve?It(""):w.currentTarget.blur())}}),Ve&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>It(""),children:"✕"})]}),i.jsx("div",{className:"sidebar__scroll",children:Sn==="pinned"?i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Закреплённые",count:Dn.length,open:Pe("pinned"),onToggle:()=>Et("pinned"),action:{label:"Новая папка закреплённых",onClick:()=>{$e("pinned"),Pe("pinned")||Et("pinned")}}}),Pe("pinned")&&i.jsxs(i.Fragment,{children:[Xe==="pinned"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:"",placeholder:"Название папки",onCommit:w=>{W("pinned",w),$e(null)},onCancel:()=>$e(null)})})}),Dn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"закрепите сессию через её меню (правый клик или долгое нажатие) — она останется под рукой из любого проекта"})}),_e.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>we(se))]},w.folder.id)),_e.ungrouped.map(w=>we(w))]})]}):Sn==="live"?i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Запущенные",count:Gt.length,open:Pe("live"),onToggle:()=>Et("live")}),Pe("live")&&i.jsxs(i.Fragment,{children:[Gt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Нет запущенных сессий"})}),Gt.map(w=>Ae(w))]})]}):i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Проекты",count:$t.length,open:Pe("workspaces"),onToggle:()=>Et("workspaces"),action:{label:"Новая папка проектов",onClick:()=>{$e("workspace"),Pe("workspaces")||Et("workspaces")}}}),Pe("workspaces")&&i.jsxs(i.Fragment,{children:[Xe==="workspace"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:"",placeholder:"Название папки",onCommit:w=>{W("workspace",w),$e(null)},onCancel:()=>$e(null)})})}),$t.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока ни одного"})}),ge.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>pe(se))]},w.folder.id)),ge.ungrouped.map(w=>pe(w))]}),o.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Архив проектов",count:cn.length,open:Pe("workspacesArchive"),onToggle:()=>Et("workspacesArchive"),hint:"проект закрывают вручную; каталог и история сессий остаются на диске и открываются заново отсюда или через «+ Проект»"}),Pe("workspacesArchive")&&i.jsxs(i.Fragment,{children:[cn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока пусто"})}),He.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>k(se))]},w.folder.id)),He.ungrouped.map(w=>k(w))]})]}),C&&i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Сессии",count:wt.length,open:Pe("sessions"),onToggle:()=>Et("sessions"),action:{label:"Новая папка сессий",onClick:()=>{$e("session"),Pe("sessions")||Et("sessions")}}}),Pe("sessions")&&i.jsxs(i.Fragment,{children:[Xe==="session"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:"",placeholder:"Название папки",onCommit:w=>{W("session",w,C),$e(null)},onCancel:()=>$e(null)})})}),wt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока ни одной"})}),B.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>Y(se))]},w.folder.id)),B.ungrouped.map(w=>Y(w))]}),b.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(sc,{title:"Архив",count:yn.length,open:Pe("archive"),onToggle:()=>Et("archive"),hint:"сессии без обращения дольше двух суток уезжают сюда сами; ничего не удаляется"}),Pe("archive")&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:"сюда сами уезжают сессии без обращения дольше двух суток; транскрипт остаётся на диске, ничего не удаляется"})}),yn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:et?"Ничего не найдено":"Пока пусто"})}),P.groups.map(w=>i.jsxs(y.Fragment,{children:[ze(w.folder,w.items.length),le(w.folder.id)&&w.items.map(se=>fe(se))]},w.folder.id)),P.ungrouped.map(w=>fe(w))]})]})]})]})}),i.jsxs("div",{className:"sidebar__foot",children:[i.jsxs("button",{className:"account-btn",title:"Аккаунт Claude",onClick:be,children:[i.jsx("span",{className:z!=null&&z.loggedIn?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:z===null?"Аккаунт":z.loggedIn?z.email||"Вход выполнен":"Войти в аккаунт"}),(z==null?void 0:z.plan)&&i.jsx("span",{className:"chip",children:z.plan})]}),N&&i.jsxs("button",{className:"account-btn",title:"Доступ с телефона и из браузера",onClick:N,children:[i.jsx("span",{className:ye!=null&&ye.connected?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:ye===null?"Удалённый доступ":ye.paired?ye.connected?ye.name||"Удалённый доступ включён":"Удалённый доступ · нет связи":"Удалённый доступ"}),(ye==null?void 0:ye.connected)&&ye.clients>0&&i.jsx("span",{className:"chip",children:ye.clients})]}),i.jsxs("div",{className:"sidebar__foot-row",children:[i.jsx("button",{className:"btn btn--ghost",disabled:!ce,title:"MCP-серверы и плагины",onClick:()=>ce==null?void 0:ce(),children:"Расширения"}),i.jsx("button",{className:"btn btn--ghost",title:"Настройки приложения",onClick:V,children:"Настройки"})]}),i.jsxs("div",{className:"sidebar__foot-row",children:[i.jsx("button",{className:"btn btn--ghost",onClick:Ce,children:"+ Проект"}),i.jsx($j,{disabled:!C,onStart:A})]})]}),Vt&&i.jsx(sr,{x:Vt.x,y:Vt.y,items:kn,note:Lt,onClose:on}),kt&&i.jsx(sr,{x:kt.x,y:kt.y,items:Di,note:Ds,onClose:Fe}),Oe&&i.jsx(sr,{x:Oe.x,y:Oe.y,items:La,note:Nn,onClose:ml}),qn&&i.jsx(sr,{x:qn.x,y:qn.y,items:Jl,note:$h,onClose:Ms}),Ln&&i.jsx(sr,{x:Ln.x,y:Ln.y,items:Xn,note:$h,onClose:Gn})]})}function lc(s,l,r){const c=["row"];return s&&c.push("row--active"),l&&c.push("row--selected"),r&&c.push("row--antigravity"),c.join(" ")}function Ro(s,l,r=c=>c.folderId){const c=new Map(l.map(m=>[m.id,m])),o=new Map,d=[];for(const m of s){const g=r(m),b=g?c.get(g):void 0;if(!b){d.push(m);continue}const _=o.get(b.id);_?_.push(m):o.set(b.id,[m])}return{groups:[...o.entries()].map(([m,g])=>({folder:c.get(m),items:g})).sort((m,g)=>m.folder.name.localeCompare(g.folder.name,"ru")),ungrouped:d}}function Fj(s,l,r){return[...s.flatMap(c=>c.items.map(r)),...l.map(r)]}const Jj="\0ungrouped";function Wj(s,l,r){const c=new Map;for(const o of s)for(const d of o.items)c.set(r(d),o.folder.id);for(const o of l)c.set(r(o),Jj);return c}function Vh(s,l,r,c,o){const d=[...l.map(m=>m.items),r].find(m=>m.some(g=>c(g)===s));if(!d)return null;const h=d.findIndex(m=>c(m)===s);return o==="up"?h<=0?null:{target:c(d[h-1]),position:"before"}:h===-1||h>=d.length-1?null:{target:c(d[h+1]),position:"after"}}function jf(s){const[l,r]=y.useState(null),[c,o]=y.useState(null),d=y.useMemo(()=>Fj(s.groups,s.ungrouped,s.itemKey),[s.groups,s.ungrouped,s.itemKey]),h=y.useMemo(()=>Wj(s.groups,s.ungrouped,s.itemKey),[s.groups,s.ungrouped,s.itemKey]);function m(){r(null),o(null)}function g(X,J){s.enabled&&(J.preventDefault(),J.currentTarget.setPointerCapture(J.pointerId),r(X),o(null))}function b(X,J){var D;if(!l)return;const G=(D=document.elementFromPoint(X,J))==null?void 0:D.closest("[data-row-key]"),O=G==null?void 0:G.dataset.rowKey;if(!O||O===l||h.get(O)!==h.get(l)){o(null);return}const Z=G.getBoundingClientRect(),M=J-Z.top<Z.height/2?"before":"after";o(H=>(H==null?void 0:H.key)===O&&H.position===M?H:{key:O,position:M})}function _(X){b(X.clientX,X.clientY)}function S(){if(l&&c){const X=_f(d,l,c.key,c.position);X&&s.onReorder(s.scope,X,s.workspaceId)}m()}function v(X,J){if(!s.enabled)return;const G=Vh(X,s.groups,s.ungrouped,s.itemKey,J);if(!G)return;const O=_f(d,X,G.target,G.position);O&&s.onReorder(s.scope,O,s.workspaceId)}function E(X,J){const G=Vh(X,s.groups,s.ungrouped,s.itemKey,"up"),O=Vh(X,s.groups,s.ungrouped,s.itemKey,"down"),Z=[{id:"move-up",label:"Переместить выше",disabled:!G,onSelect:()=>{if(!G)return;const M=_f(d,X,G.target,G.position);M&&s.onReorder(s.scope,M,s.workspaceId)}},{id:"move-down",label:"Переместить ниже",disabled:!O,onSelect:()=>{if(!O)return;const M=_f(d,X,O.target,O.position);M&&s.onReorder(s.scope,M,s.workspaceId)}}];return J&&Z.push({id:"reset-order",label:"Сбросить порядок",onSelect:()=>s.onReorder(s.scope,null,s.workspaceId)}),Z}function T(X){return l===X?" row--dragging":(c==null?void 0:c.key)===X?c.position==="before"?" row--drop-before":" row--drop-after":""}function C(X){return{onPointerDown:J=>g(X,J),onPointerMove:_,onPointerUp:S,onPointerCancel:m}}function L(X,J){!J.altKey||J.key!=="ArrowUp"&&J.key!=="ArrowDown"||(J.preventDefault(),v(X,J.key==="ArrowUp"?"up":"down"))}return{dragging:l!==null,dropClass:T,gripHandlers:C,onKeyDown:L,menuItems:E}}function Do(s){return[...[...s.folders].sort((r,c)=>r.name.localeCompare(c.name,"ru")).map(r=>({id:`folder:${r.id}`,label:`В папку «${r.name}»`,onSelect:()=>{s.ids.forEach(c=>s.assign(c,r.id)),s.onClear()}})),...s.hasFolder?[{id:"folder:none",label:"Без папки",onSelect:()=>{s.ids.forEach(r=>s.assign(r,null)),s.onClear()}}]:[],{id:"folder:new",label:"Новая папка…",onSelect:s.onNewFolder}]}function Pj(s){return s.map(l=>({...l,id:`pinned:${l.id}`,label:l.id==="folder:new"?"Новая папка закреплённых…":l.id==="folder:none"?"Без папки закреплённых":l.label}))}function Qh(s){const[l,r]=y.useState([]),c=y.useRef(null);function o(){r([]),c.current=null}function d(m,g,b){if(m.ctrlKey||m.metaKey){r(_=>_.includes(g.id)?_.filter(S=>S!==g.id):[..._,g.id]),c.current=g.id;return}if(m.shiftKey&&c.current){const _=s.findIndex(v=>v.id===c.current),S=s.findIndex(v=>v.id===g.id);if(_!==-1&&S!==-1){const[v,E]=_<S?[_,S]:[S,_];r(s.slice(v,E+1).map(T=>T.id));return}}o(),c.current=g.id,b()}function h(m){return l.includes(m.id)?l:(r([m.id]),c.current=m.id,[m.id])}return{selected:l,click:d,targetsFor:h,clear:o}}const eS={display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0,textAlign:"left"},tS={width:22,height:22,borderRadius:6};function sc({title:s,count:l,open:r,onToggle:c,hint:o,action:d}){const h=r?`Свернуть «${s}»`:`Развернуть «${s}»`;return i.jsxs("div",{className:"sidebar__section",children:[i.jsxs("button",{className:"sidebar__section--btn",style:eS,"aria-expanded":r,title:o?`${h} — ${o}`:h,onClick:c,children:[i.jsx(Yy,{open:r}),i.jsx("span",{className:"sidebar__section-name",children:s}),i.jsx("span",{className:"sidebar__count",children:l})]}),d&&i.jsx("button",{className:"theme-btn",style:tS,title:d.label,"aria-label":d.label,onClick:d.onClick,children:i.jsx(cS,{})})]})}const jx={paddingLeft:22},nS={display:"flex",alignItems:"center",gap:6,width:"100%"},lS={flex:1,minWidth:0,color:"var(--text-2)",fontWeight:500};function sS({folder:s,count:l,open:r,renaming:c,onToggle:o,onStartRename:d,onCommitRename:h,onCancelRename:m,onDelete:g}){return c?i.jsx("div",{className:"row",style:jx,children:i.jsx("div",{className:"row__main",children:i.jsx(na,{value:s.name,placeholder:"Название папки",onCommit:h,onCancel:m})})}):i.jsxs("div",{className:"row",style:jx,children:[i.jsxs("button",{className:"row__main",style:nS,"aria-expanded":r,title:r?`Свернуть папку «${s.name}»`:`Развернуть папку «${s.name}»`,onClick:o,children:[i.jsx(Yy,{open:r}),i.jsx("span",{style:lS,children:s.name}),i.jsx("span",{className:"sidebar__count",children:l})]}),i.jsx("button",{className:"row__edit",title:"Переименовать папку","aria-label":`Переименовать папку «${s.name}»`,onClick:d,children:"✎"}),i.jsx("button",{className:"row__edit",title:"Удалить папку — содержимое останется, просто станет без папки","aria-label":`Удалить папку «${s.name}»`,onClick:g,children:"✕"})]})}function Yy({open:s}){return i.jsx("svg",{className:s?"sidebar__chev sidebar__chev--open":"sidebar__chev",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M6 3.5 10.5 8 6 12.5"})})}function Sf(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"5.5",cy:"4",r:"1.15"}),i.jsx("circle",{cx:"5.5",cy:"8",r:"1.15"}),i.jsx("circle",{cx:"5.5",cy:"12",r:"1.15"}),i.jsx("circle",{cx:"10.5",cy:"4",r:"1.15"}),i.jsx("circle",{cx:"10.5",cy:"8",r:"1.15"}),i.jsx("circle",{cx:"10.5",cy:"12",r:"1.15"})]})}function aS(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:i.jsx("rect",{x:"3.6",y:"3.6",width:"8.8",height:"8.8",rx:"1.8"})})}function iS({className:s}){return i.jsxs("svg",{className:s,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"4.5",y:"2.4",width:"7",height:"4.2",rx:"1.6"}),i.jsx("path",{d:"M5.4 6.6 8 12.2 10.6 6.6"}),i.jsx("path",{d:"M8 12.2v1.4"})]})}function rS(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}function cS(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 3.2v9.6M3.2 8h9.6"})})}function oS(){try{const s=localStorage.getItem(Iy);if(s===null)return["archive","workspacesArchive"];const l=JSON.parse(s);return Array.isArray(l)?l.filter(r=>r==="workspaces"||r==="workspacesArchive"||r==="sessions"||r==="archive"||r==="pinned"||r==="live"):["archive","workspacesArchive"]}catch{return["archive","workspacesArchive"]}}function uS(){try{const s=localStorage.getItem(Gy);if(s===null)return[];const l=JSON.parse(s);return Array.isArray(l)?l.filter(r=>typeof r=="string"):[]}catch{return[]}}function fS(){try{const s=localStorage.getItem(qy);return s==="pinned"||s==="live"?s:"default"}catch{return"default"}}const Sx={system:"как в системе",light:"светлая",dark:"тёмная"};function dS({mode:s}){const l={viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return s==="dark"?i.jsx("svg",{...l,children:i.jsx("path",{d:"M13.2 9.7A5.4 5.4 0 0 1 6.3 2.8a5.6 5.6 0 1 0 6.9 6.9Z"})}):s==="light"?i.jsxs("svg",{...l,children:[i.jsx("circle",{cx:"8",cy:"8",r:"3.1"}),i.jsx("path",{d:"M8 1.4v1.4M8 13.2v1.4M2.4 8H1M15 8h-1.4M4 4l-1-1M13 13l-1-1M12 4l1-1M3 13l1-1"})]}):i.jsxs("svg",{...l,children:[i.jsx("rect",{x:"1.8",y:"2.6",width:"12.4",height:"8.4",rx:"1.4"}),i.jsx("path",{d:"M5.6 13.4h4.8"})]})}function hS(s){const l=pS(s),r=(s.tasks??[]).filter(c=>c.kind==="agent").length;return r>0?`${l} · ${Hy(r)}`:l}function pS(s){switch(s.state){case"running":return"работает";case"waiting_permission":return"ждёт разрешения";case"idle":return s.backgroundWork?"работает в фоне":mS(s.lastTurn);case"starting":return"запускается";case"reconnecting":return"переподключается";case"error":return"ошибка";case"closed":return"на диске"}}function mS(s){switch(s){case"interrupted":return"прервана";case"stopped":return"остановлена";case"failed":return"оборвалась";case"completed":return"готова";case null:return"ждёт задачу"}}function gS(s){switch(s.state){case"running":return"running";case"starting":return"starting";case"reconnecting":return"reconnecting";case"waiting_permission":return"waiting";case"idle":return s.backgroundWork?"background":bS(s.lastTurn);case"error":return"error";case"closed":return"closed"}}function bS(s){switch(s){case"interrupted":case"stopped":return"halted";case"failed":return"error";case"completed":return"ready";case null:return"fresh"}}function Kh({session:s,tail:l}){return i.jsxs("span",{className:"row__meta",children:[i.jsxs("span",{className:`row__state row__state--${gS(s)}`,children:[i.jsx("span",{className:"row__state-dot","aria-hidden":"true"}),hS(s)]})," · ",l]})}function wf({title:s,pinned:l,provider:r,projectName:c,projectPath:o}){return i.jsxs("span",{className:"row__head",children:[i.jsxs("span",{className:"row__title",children:[l&&i.jsx(iS,{className:"row__pin"}),r==="antigravity"&&i.jsx(By,{className:"row__provider"}),s]}),i.jsx("span",{className:"row__project",title:o,children:c})]})}function xS(s){const l=s.archivedAuto?"сама, по сроку молчания":"убрана вручную";return s.archivedAt?`${new Date(s.archivedAt).toLocaleString()} · ${l}`:l}function yS(s){return s.archivedAt?`закрыт ${new Date(s.archivedAt).toLocaleString()}`:"закрыт"}const wx=3,_S=15e5;function Xy(s,l){if(!l||typeof l!="object")return null;const r=l,c=typeof r.file_path=="string"?r.file_path:"";if(!c)return null;if(s==="Write"){if(typeof r.content!="string")return null;const o=Zh(r.content).map(d=>({type:"add",text:d}));return{kind:"create",filePath:c,rows:o,added:o.length,removed:0,note:"файл записывается целиком"}}if(s==="Edit"){if(typeof r.old_string!="string"||typeof r.new_string!="string")return null;const o=wS(vS(Zh(r.old_string),Zh(r.new_string)));return{kind:"edit",filePath:c,rows:o,added:o.filter(d=>d.type==="add").length,removed:o.filter(d=>d.type==="del").length,note:r.replace_all===!0?"все вхождения":null}}return null}function Zh(s){if(s==="")return[];const l=s.split(/\r?\n/);return l.length>1&&l[l.length-1]===""&&l.pop(),l}function vS(s,l){let r=0;for(;r<s.length&&r<l.length&&s[r]===l[r];)r++;let c=s.length,o=l.length;for(;c>r&&o>r&&s[c-1]===l[o-1];)c--,o--;const d=h=>({type:"ctx",text:h});return[...s.slice(0,r).map(d),...jS(s.slice(r,c),l.slice(r,o)),...s.slice(c).map(d)]}function jS(s,l){if(s.length===0&&l.length===0)return[];if(s.length===0)return l.map(_=>({type:"add",text:_}));if(l.length===0)return s.map(_=>({type:"del",text:_}));if((s.length+1)*(l.length+1)>_S)return[...s.map(_=>({type:"del",text:_})),...l.map(_=>({type:"add",text:_}))];const r=s.length,c=l.length,o=c+1,d=new Uint32Array((r+1)*o),h=(_,S)=>d[_*o+S]??0;for(let _=r-1;_>=0;_--)for(let S=c-1;S>=0;S--)d[_*o+S]=s[_]===l[S]?h(_+1,S+1)+1:Math.max(h(_+1,S),h(_,S+1));const m=[];let g=0,b=0;for(;g<r&&b<c;){const _=s[g],S=l[b];_===S?(m.push({type:"ctx",text:_}),g++,b++):h(g+1,b)>=h(g,b+1)?(m.push({type:"del",text:_}),g++):(m.push({type:"add",text:S}),b++)}for(;g<r;)m.push({type:"del",text:s[g++]});for(;b<c;)m.push({type:"add",text:l[b++]});return SS(m)}function SS(s){const l=[];let r=[];function c(){l.push(...r.filter(o=>o.type==="del")),l.push(...r.filter(o=>o.type==="add")),r=[]}for(const o of s)o.type==="ctx"?(c(),l.push(o)):r.push(o);return c(),l}function wS(s){if(!s.some(d=>d.type!=="ctx"))return s;const l=s.map(()=>!1);s.forEach((d,h)=>{if(d.type!=="ctx")for(let m=Math.max(0,h-wx);m<=Math.min(s.length-1,h+wx);m++)l[m]=!0});const r=[];let c=[];function o(){c.length===1?r.push(...c):c.length>1&&r.push({type:"gap",text:`⋯ ${c.length} ${kS(c.length)} без изменений`}),c=[]}return s.forEach((d,h)=>{l[h]?(o(),r.push(d)):c.push(d)}),o(),r}function kS(s){const l=s%100;if(l>=11&&l<=14)return"строк";switch(s%10){case 1:return"строка";case 2:case 3:case 4:return"строки";default:return"строк"}}async function vc(s){try{return await navigator.clipboard.writeText(s),!0}catch{}const l=document.createElement("textarea");l.value=s,l.setAttribute("readonly",""),l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l);try{return l.select(),document.execCommand("copy")}catch{return!1}finally{l.remove()}}async function hp(){try{return await navigator.clipboard.readText()}catch{return null}}const Mp=1600,dr="Копировать",fc="Скопировано";function Rp({text:s,hint:l,className:r}){const[c,o]=y.useState(!1);return y.useEffect(()=>{if(!c)return;const d=setTimeout(()=>o(!1),Mp);return()=>clearTimeout(d)},[c]),y.useEffect(()=>o(!1),[s]),i.jsx("button",{type:"button",className:"copybtn"+(c?" copybtn--done":"")+(r?` ${r}`:""),"aria-label":c?fc:`${dr} ${l}`,title:c?fc:`${dr} ${l}`,onClick:()=>{vc(s).then(d=>{d&&o(!0)})},children:c?fc:dr})}function Dp({diff:s}){return i.jsxs("div",{className:"diff",children:[i.jsxs("div",{className:"diff__head",children:[i.jsx("span",{className:"diff__path",title:s.filePath,children:s.filePath}),i.jsxs("span",{className:"diff__stat",children:[s.added>0&&i.jsxs("span",{className:"diff__stat--add",children:["+",s.added]}),s.removed>0&&i.jsxs("span",{className:"diff__stat--del",children:["−",s.removed]})]})]}),s.note&&i.jsx("div",{className:"diff__note",children:s.note}),i.jsx("div",{className:"diff__body",children:s.rows.length===0?i.jsx("div",{className:"diff__row diff__row--gap",children:i.jsx("span",{className:"diff__text",children:"пустое содержимое"})}):s.rows.map((l,r)=>i.jsxs("div",{className:`diff__row diff__row--${l.type}`,children:[i.jsx("span",{className:"diff__mark","aria-hidden":"true",children:l.type==="add"?"+":l.type==="del"?"−":""}),i.jsx("span",{className:"diff__text",children:l.text===""?" ":l.text})]},r))})]})}function NS({waiting:s}){const[l,r]=y.useState(0);return y.useEffect(()=>{const c=window.setInterval(()=>r(o=>o+1),1e3);return()=>window.clearInterval(c)},[]),i.jsxs("div",{className:s?"work work--wait":"work",children:[i.jsxs("span",{className:"work__dots","aria-hidden":"true",children:[i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"})]}),i.jsx("span",{className:"work__label",children:s?"ждёт разрешения":"думает"}),!s&&i.jsxs("span",{className:"work__time",children:[l," с"]})]})}function Op({items:s,busy:l,waiting:r,history:c=[],historyHasMore:o=!1,historyLoading:d=!1,onLoadHistory:h,sessionId:m,onEditMessage:g,empty:b="Сессия пуста. Опишите задачу — Claude Code работает в каталоге проекта с полным набором инструментов."}){const _=y.useRef(null),S=y.useRef(null),v=y.useRef(!0),E=y.useRef(null),T=y.useRef(null),C=y.useRef(!1);y.useEffect(()=>{v.current=!0,E.current=null,C.current=!1,T.current!==null&&(clearTimeout(T.current),T.current=null)},[m]),y.useEffect(()=>{const O=_.current,Z=S.current;if(!O||!Z)return;function M(ne){!O||ne===O.scrollTop||(C.current=!0,O.scrollTop=ne)}function D(){if(!O)return;const ne=E.current;if(ne){const he=Nx(O,ne.id);if(he){const W=he.getBoundingClientRect().top-O.getBoundingClientRect().top;M(O.scrollTop+(W-ne.top))}T.current!==null&&clearTimeout(T.current),T.current=setTimeout(()=>{E.current=null},500);return}v.current&&M(O.scrollHeight)}const H=new ResizeObserver(D);return H.observe(Z),()=>{H.disconnect(),T.current!==null&&clearTimeout(T.current)}},[]);function L(){const O=_.current;if(O){if(C.current){C.current=!1;return}v.current=O.scrollHeight-O.scrollTop-O.clientHeight<80}}function X(){if(d)return;const O=_.current,Z=c[0];if(O&&Z){const M=Nx(O,Z.id);M&&(E.current={id:Z.id,top:M.getBoundingClientRect().top-O.getBoundingClientRect().top})}h==null||h()}let J=0;function G(O){return O.kind==="user"?J++:-1}return i.jsx("div",{className:"transcript",ref:_,onScroll:L,children:i.jsxs("div",{className:"stream",ref:S,children:[o&&i.jsx("button",{type:"button",className:"transcript__more",onClick:X,disabled:d,children:d?"Загружаем…":"Показать более раннее"}),c.map(O=>i.jsx(kx,{item:O,userIndex:G(O),onEditMessage:g},O.id)),c.length>0&&s.length>0&&i.jsx("div",{className:"transcript__divider",children:i.jsx("span",{children:"дальше — сессия открыта заново"})}),c.length===0&&s.length===0&&i.jsx("p",{className:"empty",children:b}),s.map(O=>i.jsx(kx,{item:O,userIndex:G(O),onEditMessage:g},O.id)),l&&i.jsx(NS,{waiting:r})]})})}function kx({item:s,userIndex:l,onEditMessage:r}){switch(s.kind){case"user":return i.jsx(ES,{item:s,userIndex:l,onEditMessage:r});case"assistant":return i.jsxs("div",{className:"msg--assistant","data-item-id":s.id,children:[i.jsx(CS,{text:s.text}),s.streaming&&i.jsx("span",{className:"caret"}),s.text.trim()!==""&&i.jsx("div",{className:"msg--assistant__foot",children:i.jsx(Rp,{text:s.text,hint:"ответ целиком"})})]});case"thinking":return i.jsx("div",{className:"thinking","data-item-id":s.id,children:s.text});case"tool":return i.jsx(MS,{item:s});case"result":return i.jsxs("div",{className:"result-line","data-item-id":s.id,children:[i.jsx("span",{children:s.isError?"✗ "+s.subtype:"✓ готово"}),i.jsxs("span",{children:[(s.durationMs/1e3).toFixed(1)," с"]}),s.costUsd!==null&&i.jsxs("span",{children:["$",s.costUsd.toFixed(4)]}),i.jsxs("span",{children:["↑",Ex(s.inputTokens)," ↓",Ex(s.outputTokens)]})]});case"notice":return i.jsx("div",{className:s.tone==="error"?"notice notice--error":"notice","data-item-id":s.id,children:s.text})}}const TS=500;function ES({item:s,userIndex:l,onEditMessage:r}){const[c,o]=y.useState(null),[d,h]=y.useState(!1),[m,g]=y.useState(s.text),b=y.useRef(null),_=Xf("(max-width: 860px)"),S=y.useRef(null);function v(D,H){o({x:D,y:H})}function E(D){D.preventDefault(),v(D.clientX,D.clientY)}function T(D){const H=D.touches[0];if(!H)return;const ne={timer:0,x:H.clientX,y:H.clientY,fired:!1};ne.timer=window.setTimeout(()=>{ne.fired=!0,v(ne.x,ne.y)},TS),S.current=ne}function C(D){const H=S.current,ne=D.touches[0];!H||!ne||Math.hypot(ne.clientX-H.x,ne.clientY-H.y)>10&&(window.clearTimeout(H.timer),S.current=null)}function L(D){const H=S.current;H&&(window.clearTimeout(H.timer),H.fired&&D.preventDefault())}function X(){g(s.text),h(!0)}function J(){h(!1)}function G(){const D=m.trim();D===""&&!(s.images&&s.images.length>0)||(r==null||r(l,D,s.images),h(!1))}y.useEffect(()=>{const D=b.current;!D||!d||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[m,d]),y.useEffect(()=>{if(!d)return;const D=b.current;D&&(D.focus(),D.setSelectionRange(D.value.length,D.value.length))},[d]);function O(D){if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),J();return}D.key==="Enter"&&!D.shiftKey&&!_&&(D.preventDefault(),G())}const Z=s.images&&s.images.length>0&&i.jsx("div",{className:"msg--user__images",children:s.images.map((D,H)=>i.jsx("img",{className:"msg--user__image",src:`data:${D.mediaType};base64,${D.data}`,alt:"Вложение"},H))});if(d){const D=m.trim()!==""||!!(s.images&&s.images.length>0);return i.jsxs("div",{className:"msg--user msg--user--editing","data-item-id":s.id,children:[Z,i.jsxs("div",{className:"msg--user__edit",children:[i.jsx("textarea",{ref:b,className:"msg--user__edit-field",value:m,onChange:H=>g(H.target.value),onKeyDown:O,rows:1}),i.jsxs("div",{className:"msg--user__edit-actions",children:[i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:J,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--primary",onClick:G,disabled:!D,children:"Сохранить"})]})]})]})}const M=[{id:"copy",label:"Копировать",onSelect:()=>void vc(s.text)},...r?[{id:"edit",label:"Изменить",onSelect:X}]:[]];return i.jsxs("div",{className:"msg--user","data-item-id":s.id,onContextMenu:E,onTouchStart:T,onTouchMove:C,onTouchEnd:L,onTouchCancel:L,children:[Z,s.text,c&&i.jsx(sr,{x:c.x,y:c.y,items:M,onClose:()=>o(null)})]})}function Nx(s,l){const r=s.querySelectorAll("[data-item-id]");for(const c of r)if(c.dataset.itemId===l)return c;return null}function CS({text:s}){const[l,r]=y.useState(""),c=y.useRef([]);y.useEffect(()=>{let d=!1;return Qf(s).then(h=>{d||r(AS(h))}),()=>{d=!0}},[s]),y.useEffect(()=>{const d=c.current;return()=>d.forEach(h=>clearTimeout(h))},[]);function o(d){var g,b;const h=d.target.closest(".codeblock__copy");if(!(h instanceof HTMLElement))return;const m=((b=(g=h.parentElement)==null?void 0:g.querySelector("pre"))==null?void 0:b.textContent)??"";m!==""&&vc(m).then(_=>{if(!_)return;h.textContent=fc,h.setAttribute("aria-label",fc),h.classList.add("copybtn--done");const S=window.setTimeout(()=>{h.isConnected&&(h.textContent=dr,h.setAttribute("aria-label",pp),h.classList.remove("copybtn--done"))},Mp);c.current.push(S)})}return i.jsx("div",{className:"markdown-preview msg--assistant__body",onClick:o,dangerouslySetInnerHTML:{__html:l}})}const pp=`${dr} блок кода`;function AS(s){if(!s.includes("<pre"))return s;const l=new DOMParser().parseFromString(s,"text/html");for(const r of l.body.querySelectorAll("pre")){const c=l.createElement("div");c.className="codeblock",r.replaceWith(c),c.append(r);const o=l.createElement("button");o.type="button",o.className="copybtn codeblock__copy",o.setAttribute("aria-label",pp),o.title=pp,o.textContent=dr,c.append(o)}return l.body.innerHTML}function MS({item:s}){const[l,r]=y.useState(!1),c=s.result===null,o=Xy(s.name,s.input),d=s.name==="AskUserQuestion"?OS(s.input):null;return i.jsxs("div",{className:"tool"+(s.isError?" tool--error":"")+(s.awaitingPermission?" tool--wait":""),"data-item-id":s.id,children:[i.jsxs("button",{className:"tool__head",onClick:()=>r(h=>!h),children:[i.jsx("span",{className:"tool__name",children:s.name}),i.jsx("span",{className:"tool__arg",children:d?DS(d):RS(s.input)}),i.jsx("span",{className:"tool__status",children:c?"…":s.isError?"ошибка":l?"▴":"▾"})]}),l&&i.jsxs("div",{className:"tool__body",children:[d?i.jsx(LS,{questions:d,answers:s.answers}):o?i.jsx(Dp,{diff:o}):i.jsx(Tx,{text:JSON.stringify(s.input,null,2),hint:"аргументы вызова"}),s.result!==null&&(!d||s.isError)&&i.jsx(Tx,{text:s.result,hint:"результат вызова",style:{marginTop:10}})]})]})}function Tx({text:s,hint:l,style:r}){return i.jsxs("div",{className:"codeblock",style:r,children:[i.jsx("pre",{className:"code",children:s}),i.jsx(Rp,{text:s,hint:l,className:"codeblock__copy"})]})}function RS(s){if(!s||typeof s!="object")return"";const l=s;for(const r of["file_path","command","pattern","path","url","prompt"]){const c=l[r];if(typeof c=="string")return c.replace(/\s+/g," ").slice(0,160)}return JSON.stringify(l).slice(0,160)}function DS(s){var r;const l=s.map(c=>c.header).filter(c=>c.length>0);return l.length===s.length?l.join(" · "):((r=s[0])==null?void 0:r.question.replace(/\s+/g," ").slice(0,160))??""}function OS(s){if(typeof s!="object"||s===null)return null;const l=s.questions;if(!Array.isArray(l)||l.length===0)return null;const r=[];for(const c of l){if(typeof c!="object"||c===null)return null;const{question:o,header:d,options:h,multiSelect:m}=c;if(typeof o!="string"||!Array.isArray(h)||h.length===0)return null;const g=[];for(const b of h){if(typeof b!="object"||b===null)return null;const{label:_,description:S,preview:v}=b;if(typeof _!="string"||typeof S!="string")return null;g.push({label:_,description:S,...typeof v=="string"?{preview:v}:{}})}r.push({question:o,header:typeof d=="string"?d:"",options:g,multiSelect:m===!0})}return r}function LS({questions:s,answers:l}){return i.jsx("div",{className:"tool__questions",children:s.map((r,c)=>i.jsxs("div",{className:"tool__question",children:[i.jsxs("div",{className:"tool__question-head",children:[r.header&&i.jsx("span",{className:"chip chip--accent",children:r.header}),i.jsx("span",{className:"tool__question-text",children:r.question})]}),i.jsx("div",{className:"tool__question-answer",children:l!=null&&l[r.question]?i.jsx("span",{className:"tool__answer-value",children:l[r.question]}):i.jsx("span",{className:"tool__answer-empty",children:"не отвечено"})})]},c))})}function Ex(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}const zS="ccv.dictation.lang",Cx="ru-RU";function US(s){try{return Function.prototype.toString.call(s).includes("[native code]")}catch{return!1}}function Ax(){const s=window,l=[s.SpeechRecognition,s.webkitSpeechRecognition].filter(c=>typeof c=="function"),r=l.find(US);return!r&&l.length>0&&Ns("распознавание подменено: родной реализации в странице нет"),r??l[0]??null}function $y(){var s;try{return((s=localStorage.getItem(zS))==null?void 0:s.trim())||Cx}catch{return Cx}}function Ns(s,l){l===void 0?console.debug(`[dictation] ${s}`):console.debug(`[dictation] ${s}`,l)}const HS=3,BS=400,IS=5,qS=250,GS=2e3,YS=2e4;async function XS(){try{return(await navigator.permissions.query({name:"microphone"})).state==="granted"}catch{return!1}}const $S={"not-allowed":"Браузер не дал доступ к микрофону","service-not-allowed":"Браузер не дал доступ к микрофону","audio-capture":"Микрофон не найден",network:"Сервис распознавания недоступен","language-not-supported":`Распознавание не знает языка ${$y()}`};function VS(s){const[l]=y.useState(()=>Ax()!==null),[r,c]=y.useState(!1),[o,d]=y.useState(null),h=y.useRef(null),m=y.useRef(!1),g=y.useRef(!1),b=y.useRef(s),_=y.useRef({openedAt:0,audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1}),S=y.useRef(null),v=y.useRef(!1),E=y.useRef(null),T=y.useCallback(()=>{E.current&&clearTimeout(E.current),E.current=null},[]),C=y.useCallback(()=>{T();const O=async Z=>{if(E.current=null,!(!m.current||v.current)){if(!Z&&!await XS()){if(Ns("ждём ответа на запрос доступа к микрофону"),!m.current||v.current)return;E.current=setTimeout(()=>void O(!0),YS);return}Ns("движок не ответил на start()"),m.current=!1,c(!1),d("Распознавание не отвечает — проверьте расширения браузера и доступ к микрофону")}};E.current=setTimeout(()=>void O(!1),GS)},[T]);y.useEffect(()=>{b.current=s}),y.useEffect(()=>{const O=Ax();if(!O)return;const Z=new O;return Z.lang=$y(),Z.continuous=!0,Z.interimResults=!0,Z.onstart=()=>{Ns("сессия открыта"),v.current=!0,T(),c(!0)},Z.onaudiostart=()=>{Ns("пошёл звук с микрофона"),_.current.audio=!0},Z.onresult=M=>{var he;if(g.current)return;let D="",H="";for(let W=M.resultIndex;W<M.results.length;W++){const ue=M.results[W];if(!ue)continue;const je=((he=ue[0])==null?void 0:he.transcript)??"";ue.isFinal?D+=je:H+=je}const ne=_.current;ne.heard=!0,ne.everHeard=!0,Ns("распознано",{final:D,interim:H}),b.current(D,H)},Z.onerror=M=>{_.current.lastError=M.error,Ns("ошибка движка",M.error),!(M.error==="no-speech"||M.error==="aborted")&&(m.current=!1,c(!1),d($S[M.error]??`Распознавание не работает: ${M.error}`))},Z.onend=()=>{g.current=!1,v.current=!1;const M=_.current,D=Date.now()-M.openedAt;if(Ns("сессия закрыта",{мс:D,звук:M.audio,слова:M.heard,ошибка:M.lastError||null}),!m.current){c(!1);return}if(M.dead=!M.audio&&D<BS?M.dead+1:0,M.dead>=IS){m.current=!1,c(!1),d(M.lastError?`Распознавание не работает: ${M.lastError}`:"Распознавание закрывается сразу после запуска — проверьте доступ к микрофону в настройках сайта");return}M.silent=M.heard?0:M.silent+1,!M.everHeard&&!M.warned&&M.silent>=HS&&(M.warned=!0,d(M.audio?"Микрофон слушает, но речь не распознаётся — проверьте язык диктовки и уровень звука":"С микрофона не идёт звук — проверьте устройство ввода в настройках сайта в браузере")),S.current=setTimeout(()=>{if(S.current=null,!!m.current){M.openedAt=Date.now(),M.audio=!1,M.heard=!1,M.lastError="",C();try{Z.start()}catch{}}},qS)},h.current=Z,()=>{m.current=!1,S.current&&clearTimeout(S.current),S.current=null,T(),Z.onend=null,Z.onresult=null,Z.onerror=null,Z.onstart=null,Z.onaudiostart=null,Z.abort(),h.current=null}},[]);const L=y.useCallback(()=>{var O;if(m.current){if(m.current=!1,Ns("выключение микрофона"),S.current&&clearTimeout(S.current),S.current=null,T(),!v.current){c(!1);return}(O=h.current)==null||O.stop()}},[]),X=y.useCallback(()=>{const O=h.current;if(O){if(!window.isSecureContext){d("Микрофон доступен только по https или с localhost");return}d(null),m.current=!0,g.current=!1,S.current&&clearTimeout(S.current),S.current=null,_.current={openedAt:Date.now(),audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1},c(!0),Ns("включение микрофона",{язык:O.lang}),C();try{O.start()}catch(Z){Ns("start() не прошёл",Z)}}},[C]),J=y.useCallback(()=>{m.current?L():X()},[X,L]),G=y.useCallback(()=>{var O;m.current&&v.current&&(g.current=!0,(O=h.current)==null||O.abort())},[]);return{supported:l,listening:r,error:o,toggle:J,stop:L,drop:G}}const QS="(max-width: 860px)",Mx=/^\/(\S*)$/,KS=new Set(["model","permissions"]);function ZS(s){return KS.has(s.name)||s.name.startsWith("__")}const FS=new Set(["clear","rename"]),Rx=/(?:^|\s)@([^\s@]*)$/,JS=200,WS=100,PS=190,ew=5,tw=20*1024*1024,nw=1568,lw=.85;let Dx=0;async function sw(s){var S,v;if(!s.type.startsWith("image/")||s.size>tw)return null;const l=await aw(s);if(!l)return null;const{width:r,height:c}=l;if(r<=0||c<=0)return null;const o=Math.min(1,nw/Math.max(r,c)),d=document.createElement("canvas");d.width=Math.max(1,Math.round(r*o)),d.height=Math.max(1,Math.round(c*o));const h=d.getContext("2d");if(!h)return null;h.drawImage(l.image,0,0,d.width,d.height),(v=(S=l.image).close)==null||v.call(S);const m=s.type==="image/png",g=m?"image/png":"image/jpeg",b=d.toDataURL(g,m?void 0:lw),_=b.slice(b.indexOf(",")+1);return _?(Dx+=1,{id:`att${Dx}`,mediaType:g,data:_,previewUrl:b}):null}async function aw(s){if(typeof createImageBitmap=="function")try{const l=await createImageBitmap(s);return{image:l,width:l.width,height:l.height}}catch{}return new Promise(l=>{const r=URL.createObjectURL(s),c=new Image;c.onload=()=>{URL.revokeObjectURL(r),l({image:c,width:c.naturalWidth,height:c.naturalHeight})},c.onerror=()=>{URL.revokeObjectURL(r),l(null)},c.src=r})}function Vy({disabled:s,busy:l,commands:r,sessionTitle:c,contextResult:o,className:d,placeholder:h,draftKey:m,sendLabel:g="Отправить",autoFocus:b=!1,attachmentsEnabled:_=!0,onContextSearch:S,onCommand:v,onSend:E,onInterrupt:T,onEscape:C}){var He;const L=Xf(QS),[X,J]=y.useState(()=>m?Lh(m):""),[G,O]=y.useState(!1),[Z,M]=y.useState(0),D=y.useRef(null),H=y.useRef(null),ne=y.useRef(null),[he,W]=y.useState(()=>m?Lh(m).length:0),[ue,je]=y.useState([]),Me=y.useRef(null),Ce=y.useCallback(B=>{!_||B.length===0||Promise.all(B.map(sw)).then(P=>{const _e=P.filter(Be=>Be!==null);_e.length!==0&&je(Be=>[...Be,..._e].slice(0,ew))})},[_]);function A(B){je(P=>P.filter(_e=>_e.id!==B))}function ce(B){var Be;if(!_)return;const P=(Be=B.clipboardData)==null?void 0:Be.items;if(!P)return;const _e=[];for(const Ot of P){if(!Ot.type.startsWith("image/"))continue;const fl=Ot.getAsFile();fl&&_e.push(fl)}_e.length!==0&&(B.preventDefault(),Ce(_e))}function z(B){const P=B.target.files?Array.from(B.target.files):[];B.target.value="",Ce(P)}y.useEffect(()=>{_||je([])},[_]);const[be,ye]=y.useState([]),[N,V]=y.useState(-1),re=y.useRef(""),[me,Ne]=y.useState(""),ve=VS(y.useCallback((B,P)=>{B&&J(_e=>Fh(_e,B)),Ne(P.trim())},[])),De=me?Fh(X,me):X;y.useEffect(()=>{ve.listening||me===""||(J(B=>Fh(B,me)),Ne(""))},[ve.listening,me]),y.useEffect(()=>{var B;b&&((B=D.current)==null||B.focus())},[b]);const yt=y.useRef(new Map),Xe=y.useRef(new Map),$e=y.useRef(m),Ve=y.useRef({text:X,caret:he});Ve.current={text:X,caret:he};const It=y.useCallback((B,P,_e)=>{P===""?(yt.current.delete(B),Xe.current.delete(B)):(yt.current.set(B,P),Xe.current.set(B,_e)),iy(B,P)},[]),rt=ve.drop;y.useLayoutEffect(()=>{const B=$e.current;if(B===m)return;$e.current=m,B&&It(B,Ve.current.text,Ve.current.caret);const P=m?yt.current.get(m)??Lh(m):"",_e=m?Xe.current.get(m):void 0,Be=Math.min(_e??P.length,P.length);J(P),W(Be),ne.current=[Be,Be],Ne(""),M(0),O(!1),V(-1),re.current="",je([]),rt()},[m,It,rt]),y.useEffect(()=>{m&&It(m,X,he)},[m,X,he,It]);const dn=s?"Выберите сессию":h??"Опишите задачу… («/» — команды, «@» — файлы)",ft=y.useRef(0),hn=y.useCallback(B=>{const P=parseFloat(getComputedStyle(B).maxHeight),_e=Number.isFinite(P)&&P>0?P:PS;B.style.height="auto";const Be=B.scrollHeight;B.style.height=`${Math.min(Be,_e)}px`,B.style.overflowY=Be>_e?"auto":"hidden"},[]);y.useEffect(()=>{const B=D.current;B&&hn(B)},[De,dn,s,hn]),y.useLayoutEffect(()=>{const B=D.current,P=ne.current;!B||!P||(ne.current=null,B.setSelectionRange(P[0],P[1]))}),y.useEffect(()=>{const B=D.current;if(!B)return;const P=new ResizeObserver(([_e])=>{const Be=_e==null?void 0:_e.contentRect.width;Be===void 0||Math.abs(Be-ft.current)<1||(ft.current=Be,hn(B))});return P.observe(B),()=>P.disconnect()},[hn]);const Sn=ve.stop;y.useEffect(()=>{s&&Sn()},[s,Sn]);const xn=y.useMemo(()=>ve.error?{ok:!1,message:ve.error}:null,[ve.error]),en=y.useMemo(()=>{var _e;const B=(_e=Mx.exec(X))==null?void 0:_e[1];if(B===void 0)return[];const P=B.toLowerCase();return r.filter(Be=>!ZS(Be)&&Jh(Be,P)<Qy).sort((Be,Ot)=>Jh(Be,P)-Jh(Ot,P))},[X,r]),tt=!G&&en.length>0,et=Math.min(Z,en.length-1),tn=G?null:((He=Rx.exec(De.slice(0,he)))==null?void 0:He[1])??null,Xt=y.useRef(S);Xt.current=S,y.useEffect(()=>{if(tn===null||tn===""||tn.endsWith("/")){Xt.current(tn);return}const B=setTimeout(()=>Xt.current(tn),JS);return()=>clearTimeout(B)},[tn]);const nt=tn!==null&&(o==null?void 0:o.query)===tn,St=nt?o.entries:[],$t=tn!==null,cn=$t&&!nt,wt=Math.min(Z,Math.max(St.length-1,0));y.useEffect(()=>{var P,_e;if(!tt&&!$t)return;const B=tt?et:wt;(_e=(P=H.current)==null?void 0:P.children[B])==null||_e.scrollIntoView({block:"nearest"})},[tt,$t,et,wt]);function yn(B,P){var _e;J(B),W(P),ne.current=[P,P],M(0),O(!1),me!==""&&(Ne(""),ve.drop()),(_e=D.current)==null||_e.focus()}function qt(){J(""),Ne(""),M(0),W(0),O(!1),V(-1),re.current="",je([]),ve.drop(),m&&It(m,"",0)}function pn(B){const P=B.trim();P===""&&ue.length===0||s||(E(P,ue.length>0?ue.map(_e=>({mediaType:_e.mediaType,data:_e.data})):void 0),P!==""&&ye(_e=>[P,..._e.filter(Be=>Be!==P)].slice(0,WS)),qt())}function Dn(B){if(B<-1||B>=be.length)return;N===-1&&(re.current=X);const P=B===-1?re.current:be[B]??"";V(B),yn(P,P.length)}function Gt(){var Be;const B=((Be=D.current)==null?void 0:Be.selectionStart)??De.length,_e=`${B>0&&!/\s$/.test(De.slice(0,B))?" ":""}@`;yn(De.slice(0,B)+_e+De.slice(B),B+_e.length)}function ct(B){var Ot;const P=(Ot=Rx.exec(De.slice(0,he)))==null?void 0:Ot[1];if(P===void 0)return;const _e=he-P.length-1,Be=B.kind==="dir"?`@${B.path}/`:`@${B.path} `;yn(De.slice(0,_e)+Be+De.slice(he),_e+Be.length)}function Et(){var P;const B=(P=Mx.exec(De.trim()))==null?void 0:P[1];if(B&&v(B)){qt();return}pn(De)}function Pe(B,P){J(B),W(P),M(0),O(!1),V(-1),me!==""&&(Ne(""),ve.drop())}function wl(B){var Be;const P=FS.has(B.name)?c:null,_e=`/${B.name} `;J(_e+(P??"")),W(_e.length+((P==null?void 0:P.length)??0)),P&&(ne.current=[_e.length,_e.length+P.length]),M(0),(Be=D.current)==null||Be.focus()}function le(B){if(v(B.name)){J(""),M(0),O(!1);return}B.argumentHint?wl(B):pn(`/${B.name}`)}function ge(B){if(tt){if(B.key==="ArrowDown")return B.preventDefault(),M(P=>(Math.min(P,en.length-1)+1)%en.length);if(B.key==="ArrowUp"){B.preventDefault();const P=en.length-1;return M(_e=>(Math.min(_e,P)+P)%en.length)}if(B.key==="Enter"&&!B.shiftKey){B.preventDefault();const P=en[et];P&&le(P);return}if(B.key==="Tab"){B.preventDefault();const P=en[et];P&&wl(P);return}if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),O(!0);return}}if($t){if(B.key==="ArrowDown"&&St.length>0)return B.preventDefault(),M(P=>(Math.min(P,St.length-1)+1)%St.length);if(B.key==="ArrowUp"&&St.length>0){B.preventDefault();const P=St.length-1;return M(_e=>(Math.min(_e,P)+P)%St.length)}if(B.key==="Enter"&&!B.shiftKey||B.key==="Tab"){const P=St[wt];if(P){B.preventDefault(),ct(P);return}if(B.key==="Tab")return}if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),O(!0);return}}if((B.key==="ArrowUp"||B.key==="ArrowDown")&&!B.shiftKey){const P=B.currentTarget,_e=P.selectionStart;if(P.selectionEnd===_e){const Ot=B.key==="ArrowUp"?N+1:N-1;Ot>=-1&&Ot<be.length&&requestAnimationFrame(()=>{P.selectionStart===_e&&P.selectionEnd===_e&&Dn(Ot)})}}if(B.key==="Escape"&&C){B.preventDefault(),B.stopPropagation(),C();return}B.key==="Enter"&&!B.shiftKey&&!L&&(B.preventDefault(),Et())}return i.jsx("div",{className:d?`composer ${d}`:"composer",children:i.jsxs("div",{className:"composer__inner",children:[i.jsx(mr,{result:xn}),$t&&!tt&&i.jsxs("div",{className:"cmdmenu",role:"listbox",ref:H,children:[St.map((B,P)=>i.jsxs("button",{role:"option","aria-selected":P===wt,className:P===wt?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>M(P),onMouseDown:_e=>{_e.preventDefault(),ct(B)},children:[i.jsxs("span",{className:"cmdmenu__name",children:[B.name,B.kind==="dir"?"/":""]}),i.jsx("span",{className:"cmdmenu__desc",children:B.path}),B.ignored&&i.jsx("span",{className:"cmdmenu__tag",children:"git-ignore"})]},B.path)),St.length===0&&i.jsx("div",{className:"cmdmenu__empty",children:cn?"ищем…":tn?"Ничего не нашлось":"Наберите имя файла или каталога"})]}),tt&&i.jsx("div",{className:"cmdmenu",role:"listbox",ref:H,children:en.map((B,P)=>i.jsxs("button",{role:"option","aria-selected":P===et,className:P===et?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>M(P),onMouseDown:_e=>{_e.preventDefault(),le(B)},children:[i.jsxs("span",{className:"cmdmenu__name",children:["/",B.name]}),B.argumentHint&&i.jsx("span",{className:"cmdmenu__hint",children:B.argumentHint}),i.jsx("span",{className:"cmdmenu__desc",children:B.description})]},B.name))}),ue.length>0&&i.jsx("div",{className:"composer__attachments",children:ue.map(B=>i.jsxs("div",{className:"composer__thumb",children:[i.jsx("img",{src:B.previewUrl,alt:"Вложение"}),i.jsx("button",{type:"button",className:"composer__thumb-remove","aria-label":"Удалить вложение",onClick:()=>A(B.id),children:i.jsx(fw,{})})]},B.id))}),i.jsxs("div",{className:"composer__field",children:[i.jsx("button",{type:"button",className:"addbtn",title:"Добавить контекст — файл проекта («@»)","aria-label":"Добавить контекст",disabled:s,onClick:Gt,children:i.jsx(cw,{})}),_&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Me,type:"file",accept:"image/*",multiple:!0,className:"composer__fileinput",tabIndex:-1,"aria-hidden":"true",onChange:z}),i.jsx("button",{type:"button",className:"attachbtn",title:"Прикрепить изображение","aria-label":"Прикрепить изображение",disabled:s,onClick:()=>{var B;return(B=Me.current)==null?void 0:B.click()},children:i.jsx(uw,{})})]}),i.jsx("textarea",{ref:D,value:De,disabled:s,placeholder:dn,onChange:B=>Pe(B.target.value,B.target.selectionStart),onSelect:B=>W(B.currentTarget.selectionStart),onKeyDown:ge,onPaste:ce}),ve.supported&&i.jsx("button",{type:"button",className:ve.listening?"micbtn is-on":"micbtn",title:ve.listening?"Остановить диктовку":"Продиктовать промпт","aria-label":ve.listening?"Остановить диктовку":"Продиктовать промпт","aria-pressed":ve.listening,disabled:s,onClick:ve.toggle,children:i.jsx(dw,{on:ve.listening})}),l?i.jsx("button",{className:"btn",onClick:T,title:"Прервать (Esc)",children:"Стоп"}):i.jsxs("button",{className:"btn btn--primary sendbtn",onClick:Et,disabled:s||De.trim()===""&&ue.length===0,"aria-label":g,title:g,children:[i.jsx("span",{className:"sendbtn__label",children:g}),i.jsx(ow,{})]})]})]})})}function Fh(s,l){const r=l.trim();if(r==="")return s;const c=mp(r).slice(iw(s,r)).join(" ");return c===""?s:s===""||/\s$/.test(s)?s+c:`${s} ${c}`}function iw(s,l){const r=mp(s),c=mp(l);for(let o=Math.min(r.length,c.length);o>0;o--)if(r.slice(r.length-o).every((d,h)=>rw(d,c[h]??"")))return o;return 0}function mp(s){return s.split(/\s+/).filter(l=>l!=="")}function rw(s,l){const r=c=>c.toLowerCase().replace(/[.,!?;:…]+$/u,"");return r(s)===r(l)}function cw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 3.4v9.2M3.4 8h9.2"})})}function ow(){return i.jsx("svg",{className:"sendbtn__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 12.5V3.5M4 7.5 8 3.5l4 4"})})}function uw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M10.8 4.2 5.9 9.1a2 2 0 0 0 2.8 2.8l4.6-4.6a3.3 3.3 0 0 0-4.7-4.7L3.9 7.3a4.6 4.6 0 0 0 6.5 6.5l4.4-4.4"})})}function fw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})}function dw({on:s}){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"5.9",y:"1.7",width:"4.2",height:"7.6",rx:"2.1",fill:s?"currentColor":"none"}),i.jsx("path",{d:"M3.3 7.3v.8a4.7 4.7 0 0 0 9.4 0v-.8"}),i.jsx("path",{d:"M8 12.8v1.5"})]})}const Qy=4;function Jh(s,l){const r=s.name.toLowerCase();return r===l?0:r.startsWith(l)?1:s.aliases.some(c=>c.toLowerCase().startsWith(l))?2:r.includes(l)?3:Qy}function hw({request:s,queued:l,onDecide:r}){const c=Xy(s.toolName,s.input);return i.jsx("div",{className:"modal-backdrop modal-backdrop--sheet",children:i.jsxs("div",{className:"sheet",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"sheet__head",children:["Разрешить действие?",l>0&&` (ещё ${l} в очереди)`]}),i.jsxs("div",{className:"sheet__body",children:[i.jsx("div",{className:"sheet__tool",children:s.toolName}),s.reason&&i.jsx("p",{className:"sheet__reason",children:s.reason}),c?i.jsx(Dp,{diff:c}):i.jsx("pre",{className:"code",children:JSON.stringify(s.input,null,2)})]}),i.jsxs("div",{className:"sheet__actions",children:[i.jsx("button",{className:"btn",onClick:()=>r(s.requestId,"deny"),children:"Отклонить"}),i.jsx("button",{className:"btn btn--warn",autoFocus:!0,onClick:()=>r(s.requestId,"allow"),children:"Разрешить"})]})]})})}function pw({request:s,queued:l,onAnswer:r,onDecline:c}){const{questions:o}=s,[d,h]=y.useState(()=>o.map(()=>new Set)),[m,g]=y.useState(()=>o.map(()=>"")),[b,_]=y.useState(()=>Ox(o));y.useEffect(()=>{h(o.map(()=>new Set)),g(o.map(()=>"")),_(Ox(o))},[s.requestId]);const S=y.useMemo(()=>gw(o,d,m),[o,d,m]),v=S!==null;function E(G,O){var Z,M;(M=(Z=o[G])==null?void 0:Z.options[O])!=null&&M.preview&&_(D=>{const H=D.slice();return H[G]=O,H})}function T(G,O,Z){h(M=>{const D=M.slice(),H=new Set(D[G]);return Z?H.has(O)?H.delete(O):H.add(O):H.has(O)||(H.clear(),H.add(O)),D[G]=H,D}),O!=="other"&&E(G,O)}function C(G,O){g(Z=>{const M=Z.slice();return M[G]=O,M})}function L(){S&&r(s.requestId,S)}function X(G){G.key==="Enter"&&(G.target.closest("button")||v&&(G.preventDefault(),L()))}function J(G){var D;if(!["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(G.key))return;const O=Array.from(G.currentTarget.querySelectorAll("button.qsheet__option")),Z=O.indexOf(document.activeElement);if(Z===-1)return;G.preventDefault();const M=G.key==="ArrowDown"||G.key==="ArrowRight"?1:-1;(D=O[(Z+M+O.length)%O.length])==null||D.focus()}return i.jsx("div",{className:"modal-backdrop modal-backdrop--sheet",children:i.jsxs("div",{className:"qsheet",role:"dialog","aria-modal":"true","aria-label":"Вопрос от Claude",onKeyDown:X,children:[i.jsxs("div",{className:"qsheet__head",children:[i.jsx("span",{className:"qsheet__head-icon","aria-hidden":"true",children:"?"}),i.jsxs("span",{children:[o.length===1?"Уточняющий вопрос":`Уточняющие вопросы (${o.length})`,l>0&&` — ещё ${l} в очереди`]})]}),i.jsxs("div",{className:"qsheet__body",children:[s.reason&&i.jsx("p",{className:"qsheet__reason",children:s.reason}),o.map((G,O)=>i.jsx(mw,{q:G,qi:O,selected:d[O]??new Set,otherText:m[O]??"",previewIndex:b[O]??null,onToggle:T,onFocusOption:E,onOtherText:C,onOptionsKeyDown:J},O))]}),i.jsxs("div",{className:"qsheet__actions",children:[i.jsx("button",{className:"btn",onClick:()=>c(s.requestId),children:"Не отвечать"}),i.jsx("button",{className:"btn btn--primary",disabled:!v,onClick:L,children:"Ответить"})]})]})})}function mw({q:s,qi:l,selected:r,otherText:c,previewIndex:o,onToggle:d,onFocusOption:h,onOtherText:m,onOptionsKeyDown:g}){var E;const b=s.options.some(T=>T.preview),_=o!==null?(E=s.options[o])==null?void 0:E.preview:void 0,S=r.has("other"),v=s.multiSelect?"checkbox":"radio";return i.jsxs("div",{className:"qsheet__question",children:[i.jsxs("div",{className:"qsheet__qhead",children:[i.jsx("span",{className:"chip chip--accent",children:s.header}),i.jsx("span",{className:"qsheet__qtext",children:s.question})]}),i.jsxs("div",{className:"qsheet__options"+(s.multiSelect?"":" qsheet__options--radio"),role:s.multiSelect?"group":"radiogroup","aria-label":s.question,onKeyDown:g,children:[s.options.map((T,C)=>{const L=r.has(C);return i.jsxs("button",{type:"button",role:v,"aria-checked":L,className:"qsheet__option"+(L?" is-selected":""),onClick:()=>d(l,C,s.multiSelect),onFocus:()=>h(l,C),onMouseEnter:()=>h(l,C),children:[i.jsx("span",{className:"qsheet__opt-mark","aria-hidden":"true"}),i.jsxs("span",{className:"qsheet__opt-body",children:[i.jsx("span",{className:"qsheet__opt-label",children:T.label}),i.jsx("span",{className:"qsheet__opt-desc",children:T.description})]})]},C)}),i.jsxs("div",{className:"qsheet__other",children:[i.jsxs("button",{type:"button",role:v,"aria-checked":S,className:"qsheet__option qsheet__option--other"+(S?" is-selected":""),onClick:()=>d(l,"other",s.multiSelect),children:[i.jsx("span",{className:"qsheet__opt-mark","aria-hidden":"true"}),i.jsxs("span",{className:"qsheet__opt-body",children:[i.jsx("span",{className:"qsheet__opt-label",children:"Другое"}),i.jsx("span",{className:"qsheet__opt-desc",children:"Свой вариант ответа"})]})]}),S&&i.jsx("input",{type:"text",className:"qsheet__other-input",placeholder:"Впишите свой вариант…","aria-label":`Свой вариант ответа на вопрос «${s.question}»`,value:c,onChange:T=>m(l,T.target.value),autoFocus:!0})]})]}),b&&i.jsx("pre",{className:"qsheet__preview",children:_??""})]})}function Ox(s){return s.map(l=>{const r=l.options.findIndex(c=>c.preview);return r===-1?null:r})}function gw(s,l,r){const c={};for(let o=0;o<s.length;o++){const d=s[o];if(!d)continue;const h=l[o]??new Set,m=[];for(let g=0;g<d.options.length;g++){const b=d.options[g];b&&h.has(g)&&m.push(b.label)}if(h.has("other")){const g=(r[o]??"").trim();g&&m.push(g)}if(m.length===0)return null;c[d.question]=m.join(", ")}return c}function bw({request:s,plan:l,queued:r,onAccept:c,onDecline:o}){const[d,h]=y.useState(l),[m,g]=y.useState("preview");y.useEffect(()=>{h(l),g("preview")},[s.requestId,l]);const b=d.trim().length>0;function _(){b&&c(s.requestId,d)}return i.jsx("div",{className:"modal-backdrop modal-backdrop--sheet",children:i.jsxs("div",{className:"plansheet",role:"dialog","aria-modal":"true","aria-label":"План агента",children:[i.jsxs("div",{className:"plansheet__head",children:[i.jsx("span",{className:"plansheet__head-icon","aria-hidden":"true",children:i.jsx(yw,{})}),i.jsxs("span",{className:"plansheet__head-text",children:["План на согласование",r>0&&` — ещё ${r} в очереди`]}),i.jsxs("div",{className:"plansheet__viewtoggle",role:"tablist","aria-label":"Режим просмотра",children:[i.jsx("button",{className:"btn btn--sm"+(m==="preview"?" is-on":""),role:"tab","aria-selected":m==="preview",onClick:()=>g("preview"),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(m==="source"?" is-on":""),role:"tab","aria-selected":m==="source",onClick:()=>g("source"),children:"Код"})]})]}),i.jsxs("div",{className:"plansheet__body",children:[s.reason&&i.jsx("p",{className:"plansheet__reason",children:s.reason}),i.jsx("div",{className:"plansheet__content",children:m==="preview"?i.jsx(xw,{text:d}):i.jsx("textarea",{className:"plansheet__source",value:d,onChange:S=>h(S.target.value),spellCheck:!1,"aria-label":"Текст плана — можно отредактировать перед тем, как согласиться",autoFocus:!0})})]}),i.jsxs("div",{className:"plansheet__actions",children:[i.jsx("button",{className:"btn",onClick:()=>o(s.requestId),children:"Доработать"}),i.jsx("button",{className:"btn btn--ok",disabled:!b,autoFocus:!0,onClick:_,children:"Одобрить план"})]})]})})}function xw({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return Qf(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview plansheet__preview",dangerouslySetInnerHTML:{__html:l}})}function yw(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M4.4 2.5h5.6L13 5.5v7.4a.6.6 0 0 1-.6.6H4.4a.6.6 0 0 1-.6-.6V3.1a.6.6 0 0 1 .6-.6Z"}),i.jsx("path",{d:"M9.5 2.5v2.5a.5.5 0 0 0 .5.5h3"}),i.jsx("path",{d:"M5.6 8.6 7 10l3-3.2"})]})}function _w(s,l){if(s!=="ExitPlanMode"||!l||typeof l!="object")return null;const r=l.plan;return typeof r=="string"?r:null}function Ky({path:s}){const[l,r]=y.useState(!1),[c,o]=y.useState(!1),d=y.useRef(null);y.useEffect(()=>{if(!l)return;function m(g){var b;(b=d.current)!=null&&b.contains(g.target)||r(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),y.useEffect(()=>{if(!c)return;const m=setTimeout(()=>o(!1),Mp);return()=>clearTimeout(m)},[c]),y.useEffect(()=>r(!1),[s]);async function h(){await vc(s)&&o(!0)}return i.jsxs("div",{ref:d,className:"cwd",children:[i.jsxs("button",{type:"button",className:"cwd__toggle","aria-expanded":l,title:l?"Свернуть путь":`Полный путь: ${s}`,onClick:()=>r(m=>!m),onKeyDown:m=>{m.key!=="Escape"||!l||(m.preventDefault(),m.stopPropagation(),r(!1))},children:[i.jsx(vw,{open:l}),i.jsx("span",{className:"cwd__short",children:s})]}),l&&i.jsxs("div",{className:"cwd__pop",children:[i.jsx("span",{className:"cwd__full",children:s}),i.jsx("button",{type:"button",className:"btn btn--ghost cwd__copy",onClick:()=>void h(),children:c?fc:dr})]})]})}function vw({open:s}){return i.jsx("svg",{className:s?"cwd__chev cwd__chev--open":"cwd__chev",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M6 3.5 10.5 8 6 12.5"})})}const jw=["low","medium","high"];function Zy({models:s,value:l,effort:r,ultracode:c,thinking:o,switchOnFlag:d,showSwitchOnFlag:h=!0,className:m,onModel:g,onEffort:b,onUltracode:_,onThinking:S,onSwitchOnFlag:v}){const[E,T]=y.useState(!1),[C,L]=y.useState(0),X=y.useRef(null),J=y.useRef(null),G=s.find(H=>H.value===l)??null,O=G&&G.supportsEffort?G.effortLevels.length>0?G.effortLevels:jw:[],Z=O.includes("xhigh");y.useEffect(()=>{if(!E)return;const H=s.findIndex(ne=>ne.value===l);L(H===-1?0:H)},[E]),y.useEffect(()=>{if(!E)return;function H(ne){var he;(he=X.current)!=null&&he.contains(ne.target)||T(!1)}return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[E]),y.useEffect(()=>{var H,ne;E&&((ne=(H=J.current)==null?void 0:H.querySelector(".is-cursor"))==null||ne.scrollIntoView({block:"nearest"}))},[E,C]);function M(H){T(!1),H.value!==l&&g(H.value)}function D(H){if(H.key==="Escape"){if(!E)return;H.preventDefault(),H.stopPropagation(),T(!1);return}if(H.key==="ArrowDown"||H.key==="ArrowUp"){if(H.preventDefault(),!E)return T(!0);if(s.length===0)return;const ne=H.key==="ArrowDown"?1:s.length-1;return L(he=>(he+ne)%s.length)}if(H.key==="Enter"||H.key===" "){if(H.preventDefault(),!E)return T(!0);const ne=s[C];ne&&M(ne)}}return i.jsxs("div",{ref:X,className:"select"+(E?" select--open":"")+(m?` ${m}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:"Модель, усилие и размышления","aria-label":"Модель, усилие и размышления","aria-haspopup":"menu","aria-expanded":E,onClick:()=>T(H=>!H),onKeyDown:D,children:[(G==null?void 0:G.displayName)??l?i.jsx("span",{className:"select__value",children:(G==null?void 0:G.displayName)??l}):i.jsx("span",{className:"select__value select__value--muted",children:"по умолчанию"}),c?i.jsx("span",{className:"select__suffix select__suffix--hot",children:"ultracode"}):O.length>0&&r&&i.jsx("span",{className:"select__suffix",children:r}),i.jsx(Sw,{})]}),E&&i.jsxs("div",{ref:J,className:"select__menu modelmenu",role:"menu",children:[i.jsx("div",{className:"modelmenu__head",children:"Модель"}),s.map((H,ne)=>i.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":H.value===l,className:"select__option"+(ne===C?" is-cursor":"")+(H.value===l?" is-on":""),onMouseEnter:()=>L(ne),onClick:()=>M(H),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:H.value===l?"✓":""}),i.jsx("span",{className:"select__label",children:H.displayName}),H.description&&i.jsx("span",{className:"select__hint",children:H.description})]},H.value)),O.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"modelmenu__sep",role:"separator"}),i.jsxs("div",{className:"modelmenu__row",children:[i.jsxs("span",{className:"modelmenu__label",children:["Усилие",i.jsx("span",{className:"modelmenu__desc",children:"насколько усердно модель думает"})]}),i.jsx("span",{className:"modelmenu__levels",children:O.map(H=>i.jsx("button",{type:"button",role:"menuitemradio","aria-checked":H===r,className:H===r?"modelmenu__level is-on":"modelmenu__level",onClick:()=>b(H),children:H},H))})]}),Z&&i.jsx(Wh,{label:"Ultracode",desc:"xhigh и постоянная оркестрация подагентами",on:c,onToggle:()=>_(!c)})]}),i.jsx("div",{className:"modelmenu__sep",role:"separator"}),(G==null?void 0:G.supportsThinking)!==!1&&i.jsx(Wh,{label:"Размышления",desc:"расширенное обдумывание перед ответом",on:o,onToggle:()=>S(!o)}),h&&i.jsx(Wh,{label:"Менять модель по флагу",desc:"иначе помеченный ход встаёт на паузу",on:d,onToggle:()=>v(!d)})]})]})}function Wh({label:s,desc:l,on:r,onToggle:c}){return i.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":r,className:"modelmenu__row modelmenu__row--btn",onClick:c,children:[i.jsxs("span",{className:"modelmenu__label",children:[s,i.jsx("span",{className:"modelmenu__desc",children:l})]}),i.jsx("span",{className:r?"switch is-on":"switch","aria-hidden":"true",children:i.jsx("span",{className:"switch__knob"})})]})}function Sw(){return i.jsx("svg",{className:"select__chev",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M3 4.5 6 7.5 9 4.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Sl({title:s,children:l,actions:r,className:c,sheet:o=!1,onClose:d}){const h=y.useRef(null);return y.useEffect(()=>{function m(g){if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),d();return}if(g.key!=="Tab")return;const b=h.current;if(!b)return;const _=b.querySelectorAll('button, input, textarea, select, a[href], [tabindex]:not([tabindex="-1"])'),S=_[0],v=_[_.length-1];!S||!v||(g.shiftKey&&document.activeElement===S?(g.preventDefault(),v.focus()):!g.shiftKey&&document.activeElement===v&&(g.preventDefault(),S.focus()))}return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[d]),i.jsx("div",{className:o?"modal-backdrop modal-backdrop--sheet":"modal-backdrop",onMouseDown:m=>{m.target===m.currentTarget&&d()},children:i.jsxs("div",{ref:h,className:c?`modal ${c}`:"modal",role:"dialog","aria-modal":"true","aria-label":s,children:[i.jsxs("div",{className:"modal__head",children:[i.jsx("h2",{className:"modal__title",children:s}),i.jsx("button",{className:"modal__close","aria-label":"Закрыть",onClick:d,children:"✕"})]}),i.jsx("div",{className:"modal__body",children:l}),r&&i.jsx("div",{className:"modal__actions",children:r})]})})}function ww({candidates:s,searching:l,agentItems:r,agentBusy:c,error:o,roots:d,created:h,onSearch:m,onAskAgent:g,onInterrupt:b,onSubmit:_,onCreate:S,onClose:v}){const[E,T]=y.useState("open"),[C,L]=y.useState(""),[X,J]=y.useState(!1),[G,O]=y.useState(""),[Z,M]=y.useState(""),[D,H]=y.useState({git:!0,claudeMd:!0,readme:!0}),ne=C.trim(),he=ne!=="",W=G.trim(),ue=Z.trim(),je=W!==""&&ue!=="";y.useEffect(()=>{G===""&&d.length>0&&O(d[0])},[d]);const Me=y.useRef(m);Me.current=m,y.useEffect(()=>{if(E!=="open")return;const z=C.trim(),be=setTimeout(()=>Me.current(z),200);return()=>clearTimeout(be)},[C,E]);function Ce(){he&&_(ne)}function A(){je&&S(W,ue,D)}function ce(){he&&(J(!0),g(ne))}return h?i.jsxs(Sl,{title:"Новый проект",onClose:v,actions:i.jsx("button",{className:"btn btn--primary",onClick:v,autoFocus:!0,children:"Понятно"}),children:[i.jsx("p",{className:"modal__text",children:"Каталог создан и открыт как проект, но часть шагов не удалась."}),i.jsx("p",{className:"newproj__preview",children:h.path}),i.jsx("div",{className:"modal__error",children:i.jsx("ul",{className:"newproj__warnings",children:h.warnings.map(z=>i.jsx("li",{children:z},z))})}),i.jsx("p",{className:"modal__text modal__text--dim",children:"Проект открыт и работает — недостающее можно добавить руками, в дереве файлов или из терминала."})]}):i.jsxs(Sl,{title:"Новый проект",className:X&&E==="open"?"modal--wide":void 0,onClose:v,actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:v,children:"Отмена"}),E==="open"?i.jsxs(i.Fragment,{children:[c?i.jsx("button",{className:"btn",onClick:b,children:"Остановить"}):i.jsx("button",{className:"btn",disabled:!he,onClick:ce,title:"Найти по описанию",children:"Попросить агента"}),i.jsx("button",{className:"btn btn--primary",disabled:!he,onClick:Ce,children:"Открыть"})]}):i.jsx("button",{className:"btn btn--primary",disabled:!je,onClick:A,children:"Создать"})]}),children:[i.jsxs("div",{className:"tabs",children:[i.jsx(Lx,{label:"Открыть",on:E==="open",onClick:()=>T("open")}),i.jsx(Lx,{label:"Создать",on:E==="create",onClick:()=>T("create")})]}),E==="open"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"modal__text",children:"Каталог, в котором будет работать агент. Введите путь или часть имени — подходящие каталоги появятся ниже."}),i.jsx("label",{className:"field",htmlFor:"workspace-path",children:"Путь или название"}),i.jsx("input",{id:"workspace-path",className:"input input--mono",value:C,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects\\my-app",onChange:z=>L(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),Ce())}}),o&&i.jsx("p",{className:"modal__error",children:o}),s.length>0&&i.jsx("ul",{className:"finds",children:s.map(z=>i.jsx("li",{children:i.jsxs("button",{className:"find",disabled:z.open,title:z.open?"Этот проект уже открыт":z.path,onClick:()=>L(z.path),onDoubleClick:()=>_(z.path),children:[i.jsx("span",{className:"find__name",children:z.name}),i.jsx("span",{className:"find__path",children:z.path}),i.jsx("span",{className:"find__note",children:Tw(z)})]})},z.path))}),s.length===0&&he&&!l&&!X&&i.jsx("p",{className:"modal__text modal__text--dim",children:"Ничего похожего среди каталогов, где вы работали. Если помните не имя, а суть проекта — опишите его и нажмите «Попросить агента». Проекта ещё нет вовсе — рядом вкладка «Создать»."}),X&&i.jsx("div",{className:"finds__agent",children:i.jsx(Op,{items:r,busy:c,waiting:!1,empty:"Агент ищет…"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"modal__text",children:"Пустой каталог для нового проекта. Дальше в нём работает агент — с первого промпта, без отдельной настройки."}),i.jsx("label",{className:"field",htmlFor:"workspace-parent",children:"Где создать"}),i.jsx("input",{id:"workspace-parent",className:"input input--mono",value:G,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects",onChange:z=>O(z.target.value)}),d.length>0&&i.jsx("div",{className:"newproj__roots",children:d.map(z=>i.jsx("button",{type:"button",className:z===W?"newproj__root is-on":"newproj__root",title:z,onClick:()=>O(z),children:Nw(z)},z))}),i.jsx("label",{className:"field newproj__field",htmlFor:"workspace-name",children:"Имя проекта"}),i.jsx("input",{id:"workspace-name",className:"input input--mono",value:Z,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"my-app",onChange:z=>M(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),A())}}),i.jsx("p",{className:"newproj__preview",children:je?kw(W,ue):"Каталог появится здесь"}),o&&i.jsx("p",{className:"modal__error",children:o}),i.jsxs("div",{className:"newproj__opts",children:[i.jsx(Ph,{label:"git init",desc:"панель истории работает сразу",on:D.git,onToggle:()=>H(z=>({...z,git:!z.git}))}),i.jsx(Ph,{label:"CLAUDE.md",desc:"заготовка инструкций для агента",on:D.claudeMd,onToggle:()=>H(z=>({...z,claudeMd:!z.claudeMd}))}),i.jsx(Ph,{label:"README.md",desc:"по нему проект потом узнаёт поиск",on:D.readme,onToggle:()=>H(z=>({...z,readme:!z.readme}))})]})]})]})}function Lx({label:s,on:l,onClick:r}){return i.jsx("button",{type:"button",className:l?"tabs__tab is-on":"tabs__tab","aria-pressed":l,onClick:r,children:s})}function Ph({label:s,desc:l,on:r,onToggle:c}){return i.jsxs("button",{type:"button",role:"checkbox","aria-checked":r,className:"newproj__opt",onClick:c,children:[i.jsxs("span",{className:"newproj__optlabel",children:[s,i.jsx("span",{className:"newproj__optdesc",children:l})]}),i.jsx("span",{className:r?"switch is-on":"switch","aria-hidden":"true",children:i.jsx("span",{className:"switch__knob"})})]})}function kw(s,l){const r=s.includes("\\")?"\\":"/";return s.replace(/[\\/]+$/,"")+r+l}function Nw(s){const l=s.includes("\\")?"\\":"/",r=s.split(/[\\/]/).filter(Boolean);return r.length<=2?s:`…${l}${r.slice(-2).join(l)}`}function Tw(s){return s.open?"уже открыт":s.why?s.why:s.sessions===0?"рядом с вашими проектами":`${Ew(s.sessions)}${Cw(s.lastUsedAt)}`}function Ew(s){const l=s%10,r=s%100;return r>=11&&r<=14?`${s} сессий`:l===1?`${s} сессия`:l>=2&&l<=4?`${s} сессии`:`${s} сессий`}function Cw(s){if(!s)return"";const l=Math.floor((Date.now()-s)/864e5);return l<=0?" · сегодня":l===1?" · вчера":l<30?` · ${l} дн. назад`:` · ${new Date(s).toLocaleDateString("ru-RU")}`}const Lp=7;function Aw(s){const l=[],r=[];let c=1;for(const o of s){const d=l.slice();let h=l.indexOf(o.hash);h===-1&&(h=zx(l),l[h]=o.hash);const[m,...g]=o.parents;l[h]=m??null;const b=[];m!==void 0&&b.push({from:h,to:h});for(const v of g){let E=l.indexOf(v);E===-1&&(E=zx(l),l[E]=v),b.push({from:h,to:E})}const _=[];for(let v=0;v<d.length;v++)d[v]===o.hash&&(_.push({from:v,to:h}),v!==h&&(l[v]=null));const S=[];for(let v=0;v<d.length;v++){const E=d[v];!E||E===o.hash||v===h||l[v]===E&&S.push(v)}Mw(l),c=Math.max(c,l.length,h+1),r.push({commit:o,col:h,up:_,down:b,through:S})}return{rows:r,columns:Math.min(c,Lp)}}function zx(s){const l=s.indexOf(null);return l!==-1?l:(s.push(null),s.length-1)}function Mw(s){for(;s.length>0&&s[s.length-1]===null;)s.pop()}const Fy=1500;function Rw(s){const l=[];let r=!1;for(const c of s.patch.split(`
|
|
119
119
|
`)){if(l.length>=Fy){r=!0;break}if(c.startsWith("@@"))l.push({type:"gap",text:Dw(c)});else if(c.startsWith("+"))l.push({type:"add",text:c.slice(1)});else if(c.startsWith("-"))l.push({type:"del",text:c.slice(1)});else{if(c.startsWith("\\"))continue;(c!==""||l.length>0)&&l.push({type:"ctx",text:c.startsWith(" ")?c.slice(1):c})}}return{kind:"patch",filePath:s.path||s.oldPath,rows:l,added:s.added,removed:s.removed,note:Ow(s,r)}}function Dw(s){const l=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@ ?(.*)$/.exec(s);if(!l)return s;const r=Number(l[1]),c=l[2]===void 0?1:Number(l[2]),o=(l[3]??"").trim(),d=c>1?`строки ${r}–${r+c-1}`:`строка ${r}`;return o?`⋯ ${d} · ${o}`:`⋯ ${d}`}function Ow(s,l){const r=[];return s.status==="added"&&r.push("новый файл"),s.status==="deleted"&&r.push("файл удалён"),s.status==="renamed"&&r.push(`переименован из ${s.oldPath}`),s.binary?r.push("двоичный файл"):s.patch===""&&r.push("содержимое не показано"),l&&r.push(`показаны первые ${Fy} строк`),r.length>0?r.join(" · "):null}function Lw({open:s,state:l,result:r,selected:c,busy:o,onRefresh:d,onShow:h,onCheckout:m,onPush:g,onPull:b,onPublish:_,onConnectRemote:S,onDismissResult:v,onClose:E,zoomed:T,onToggleZoom:C}){const L=Aw((l==null?void 0:l.commits)??[]),X=[...l!=null&&l.detached?[{value:"",label:`отделён · ${l.head.slice(0,8)}`}]:[],...((l==null?void 0:l.branches)??[]).map(J=>({value:J.name,label:J.name,hint:J.hash.slice(0,8)}))];return i.jsxs("aside",{className:(s?"sidepane sidepane--git sidepane--open":"sidepane sidepane--git")+(T?" sidepane--zoomed":""),"aria-label":"История git",children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:J=>{C&&(J.target.closest("button")||C())},children:[i.jsx(Iw,{}),i.jsx("span",{className:"sidepane__title",children:"История"}),i.jsx("button",{className:"sidepane__btn",title:"Обновить","aria-label":"Обновить историю",onClick:d,children:"↻"}),C&&i.jsx("button",{className:"sidepane__btn",title:T?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":T?"Свернуть панель истории":"Развернуть панель истории на весь экран","aria-pressed":T,onClick:C,children:i.jsx(Sc,{active:T})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель истории",onClick:E,children:"✕"})]}),l===null?i.jsx("p",{className:"sidepane__empty",children:"Читаем репозиторий…"}):l.available?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"gitbar",children:i.jsx(Cs,{className:"gitbar__branch",title:"Ветка — выбрать значит переключиться",value:l.detached?"":l.branch,options:X,onChange:J=>{J&&m(J,`ветку ${J}`)}})}),l.detached&&i.jsx("p",{className:"gitbar__note",children:"HEAD отделён от ветки. Выберите ветку в списке, чтобы вернуться."}),i.jsx("div",{className:"gitbar__actions",children:o?i.jsxs("p",{className:"gitbar__busy",children:[i.jsx(Xw,{}),o]}):l.hasRemote?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"btn btn--sm",title:"Отправить текущую ветку в origin",onClick:g,children:[i.jsx(qw,{}),"Отправить",l.ahead>0&&i.jsx("span",{className:"gitbar__count",children:l.ahead})]}),i.jsxs("div",{className:"gitbar__group",children:[i.jsxs("button",{type:"button",className:"btn btn--sm",title:"Забрать с origin и перемотать вперёд (git pull --ff-only)",onClick:()=>b(!0),children:[i.jsx(Gw,{}),"Забрать",l.behind>0&&i.jsx("span",{className:"gitbar__count",children:l.behind})]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost gitbar__check",title:"Только проверить — git fetch, рабочее дерево не меняется","aria-label":"Проверить, что нового на origin, без изменений на диске",onClick:()=>b(!1),children:i.jsx(Yw,{})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"btn btn--sm btn--primary",title:"Создать репозиторий на GitHub и отправить в него ветку",onClick:_,children:[i.jsx(Hx,{}),"Опубликовать на GitHub"]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",title:"Прописать origin на уже существующий репозиторий",onClick:S,children:"уже есть репозиторий"})]})}),i.jsxs("div",{className:"sidepane__scroll",children:[i.jsx("button",{className:"gitrow gitrow--work"+(c===""?" is-on":""),onClick:()=>h(""),children:i.jsxs("span",{className:"gitrow__body",children:[i.jsx("span",{className:"gitrow__subject",children:l.changed.length>0?`Рабочее дерево · ${l.changed.length} ${Qw(l.changed.length)}`:"Рабочее дерево чистое"}),i.jsx("span",{className:"gitrow__meta",children:l.changed.length>0?l.changed.slice(0,4).map(J=>Vw(J.path)).join(", "):"незакоммиченных изменений нет"})]})}),L.rows.map(J=>i.jsx(zw,{row:J,columns:L.columns,head:J.commit.hash===l.head,local:l.hasRemote&&!J.commit.pushed,active:c===J.commit.hash,onOpen:()=>h(J.commit.hash)},J.commit.hash)),L.rows.length===0&&i.jsx("p",{className:"sidepane__empty",children:"В репозитории ещё нет коммитов"})]})]}):i.jsxs("div",{className:"gitempty",children:[i.jsx("p",{className:"gitempty__text",children:l.message||"Это не git-репозиторий"}),l.noRepo&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"btn btn--sm btn--primary gitempty__btn",onClick:_,children:[i.jsx(Hx,{}),"Опубликовать на GitHub"]}),i.jsx("p",{className:"gitempty__hint",children:"Заведёт репозиторий, сделает первый коммит и отправит его на GitHub."})]})]}),i.jsx(mr,{result:r,onDismiss:v})]})}const Oo=50,Ux=13;function zw({row:s,columns:l,head:r,local:c,active:o,onOpen:d}){const{commit:h}=s,m=h.refs.map($w).filter(Boolean);return i.jsxs("button",{className:"gitrow"+(o?" is-on":""),title:c?"Коммит ещё не отправлен на удалённый репозиторий":void 0,onClick:d,children:[i.jsx(Uw,{row:s,columns:l,head:r,local:c}),i.jsxs("span",{className:"gitrow__body",children:[i.jsxs("span",{className:"gitrow__subject",children:[m.map(g=>i.jsx("span",{className:"gitrow__ref",children:g},g)),h.subject]}),i.jsxs("span",{className:"gitrow__meta",children:[h.shortHash," · ",h.author," · ",Kw(h.date),c&&i.jsx("span",{className:"gitrow__local",children:"· не отправлен"})]})]})]})}function Uw({row:s,columns:l,head:r,local:c}){const o=l*Ux+6,d=Oo/2,h=b=>8+Math.min(b,Lp-1)*Ux,m=c?"3.5 2.5":void 0,g=kf(s.col);return i.jsxs("svg",{className:"gitgraph",width:o,height:Oo,viewBox:`0 0 ${o} ${Oo}`,"aria-hidden":"true",children:[s.through.map(b=>i.jsx("line",{x1:h(b),y1:0,x2:h(b),y2:Oo,style:{stroke:kf(b)}},`t${b}`)),s.up.map((b,_)=>i.jsx("path",{d:`M${h(b.from)} 0 L${h(b.from)} ${d-12} L${h(b.to)} ${d}`,fill:"none",style:{stroke:kf(b.from),strokeDasharray:m}},`u${_}`)),s.down.map((b,_)=>i.jsx("path",{d:`M${h(b.from)} ${d} L${h(b.to)} ${d+12} L${h(b.to)} ${Oo}`,fill:"none",style:{stroke:kf(b.to),strokeDasharray:m}},`d${_}`)),r&&i.jsx("circle",{className:"gitgraph__head",cx:h(s.col),cy:d,r:s.commit.parents.length>1?7.4:6.6}),i.jsx("circle",{className:"gitgraph__dot",cx:h(s.col),cy:d,r:s.commit.parents.length>1?4.6:3.6,style:{stroke:g,fill:c?void 0:g}})]})}function kf(s){return`var(--lane-${s%Lp})`}function Hw({detail:s,local:l,onCheckout:r,onClose:c}){const o=s.hash==="";return i.jsxs(Sl,{className:"modal--wide",title:o?"Незакоммиченные изменения":`Коммит ${s.shortHash}`,onClose:c,actions:i.jsxs(i.Fragment,{children:[!o&&i.jsx("button",{className:"btn",onClick:()=>r(s.hash,`коммит ${s.shortHash} (HEAD отделится от ветки)`),children:"Переключиться сюда"}),i.jsx("button",{className:"btn btn--primary",onClick:c,children:"Закрыть"})]}),children:[!o&&i.jsxs("div",{className:"commit__head",children:[i.jsx("p",{className:"commit__subject",children:s.subject}),i.jsxs("p",{className:"commit__meta",children:[s.author,s.email&&` <${s.email}>`," · ",Zw(s.date)," ·"," ",i.jsx("span",{className:"commit__hash",children:s.hash})]}),l&&i.jsx("p",{className:"commit__meta commit__meta--local",children:"Не отправлен: этого коммита нет ни в одной удалённой ветке."}),s.parents.length>0&&i.jsxs("p",{className:"commit__meta",children:[s.parents.length>1?"слияние: ":"родитель: ",s.parents.map(d=>d.slice(0,8)).join(", ")]}),s.body&&i.jsx("pre",{className:"commit__body",children:s.body})]}),s.truncated&&i.jsx("p",{className:"modal__text",children:"Изменения слишком велики — часть патча не показана."}),s.files.length===0?i.jsx("p",{className:"modal__text",children:"Изменений нет."}):s.files.map(d=>i.jsx(Bw,{file:d,defaultOpen:s.files.length<=3},d.path+d.oldPath))]})}function Bw({file:s,defaultOpen:l}){const[r,c]=y.useState(l);return i.jsxs("div",{className:"commit__file",children:[i.jsxs("button",{className:"commit__filehead",onClick:()=>c(o=>!o),children:[i.jsx("span",{className:"commit__filepath",children:s.path||s.oldPath}),i.jsxs("span",{className:"diff__stat",children:[s.added>0&&i.jsxs("span",{className:"diff__stat--add",children:["+",s.added]}),s.removed>0&&i.jsxs("span",{className:"diff__stat--del",children:["−",s.removed]})]}),i.jsx("span",{className:"tool__status",children:r?"▴":"▾"})]}),r&&i.jsx(Dp,{diff:Rw(s)})]})}function Iw(){return i.jsxs("svg",{className:"sidepane__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"4.5",cy:"3.5",r:"1.9"}),i.jsx("circle",{cx:"4.5",cy:"12.5",r:"1.9"}),i.jsx("circle",{cx:"11.5",cy:"8",r:"1.9"}),i.jsx("path",{d:"M4.5 5.4v5.2M6.4 3.9h2.2a1.6 1.6 0 0 1 1.6 1.6v.8"})]})}function qw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 13V3M4.5 6.5 8 3l3.5 3.5"})})}function Gw(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 3v10M4.5 9.5 8 13l3.5-3.5"})})}function Yw(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4"}),i.jsx("path",{d:"m13 13-2.6-2.6"})]})}function Hx(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:i.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})})}function Xw(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M14 8a6 6 0 1 1-6-6c1.68 0 3.29.67 4.49 1.83L14 5.33"}),i.jsx("path",{d:"M14 2v3.33h-3.33"})]})}function $w(s){return s.replace(/^HEAD -> /,"").replace(/^tag: /,"⌂ ").trim()}function Vw(s){const l=s.split("/");return l[l.length-1]??s}function Qw(s){const l=s%100;if(l>=11&&l<=14)return"файлов";switch(s%10){case 1:return"файл";case 2:case 3:case 4:return"файла";default:return"файлов"}}function Kw(s){const l=Date.parse(s);if(Number.isNaN(l))return s;const r=Math.round((Date.now()-l)/6e4);if(r<1)return"только что";if(r<60)return`${r} мин назад`;const c=Math.round(r/60);if(c<24)return`${c} ч назад`;const o=Math.round(c/24);return o<30?`${o} дн назад`:new Date(l).toLocaleDateString()}function Zw(s){const l=Date.parse(s);return Number.isNaN(l)?s:new Date(l).toLocaleString()}function Bx(s){return s.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")}function Fw({status:s,owners:l,files:r,defaultName:c,hasCommits:o,busy:d,result:h,onRefreshStatus:m,onSaveToken:g,onPublish:b,onDismissResult:_,onClose:S}){var z;const[v,E]=y.useState(()=>Bx(c)),[T,C]=y.useState(""),[L,X]=y.useState(""),[J,G]=y.useState(!0),[O,Z]=y.useState("Первый коммит"),[M,D]=y.useState(null),[H,ne]=y.useState("");y.useEffect(()=>{!T&&l.length>0&&C(l[0].login)},[T,l]),y.useEffect(()=>{r&&M===null&&D(new Set(r.files))},[r,M]);const he=(s==null?void 0:s.connected)===!0,W=l.map(be=>({value:be.login,label:be.login,hint:be.kind==="org"?"организация":void 0})),ue=y.useMemo(()=>{if(!r)return[];const be=H.trim().toLowerCase();return be?r.files.filter(ye=>ye.toLowerCase().includes(be)):r.files},[r,H]),je=(M==null?void 0:M.size)??0,Me=he&&v.trim()!==""&&T!==""&&d===""&&(o||je>0);function Ce(be){D(ye=>{const N=new Set(ye??[]);return N.has(be)?N.delete(be):N.add(be),N})}function A(be){D(ye=>{const N=new Set(ye??[]);for(const V of ue)be?N.add(V):N.delete(V);return N})}function ce(){if(!Me)return;const be=(r==null?void 0:r.files)??[];b({owner:T,name:v.trim(),description:L.trim(),private:J,include:o?[]:be.filter(ye=>M==null?void 0:M.has(ye)),ignore:o?[]:be.filter(ye=>!(M!=null&&M.has(ye))),message:o?"":O.trim()||"Первый коммит"})}return i.jsxs(Sl,{className:"modal--wide",title:"Опубликовать на GitHub",onClose:S,actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"btn",onClick:S,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--primary",disabled:!Me,onClick:ce,children:d||"Опубликовать"})]}),children:[i.jsx(Jw,{status:s,onRefreshStatus:m,onSaveToken:g}),i.jsxs("div",{className:"publish__section",children:[i.jsx("h3",{className:"publish__heading",children:"Репозиторий"}),i.jsxs("label",{className:"field publish__field",children:[i.jsx("span",{children:"Имя"}),i.jsx("input",{className:"input input--mono",value:v,spellCheck:!1,autoComplete:"off",onChange:be=>E(Bx(be.target.value))})]}),v.trim()===""&&i.jsx("p",{className:"modal__error",children:"Имя репозитория не может быть пустым."}),i.jsxs("label",{className:"field publish__field",children:[i.jsx("span",{children:"Владелец"}),l.length>1?i.jsx(Cs,{className:"settings__select",value:T,options:W,onChange:C,placeholder:"выберите владельца",ariaLabel:"Владелец репозитория"}):i.jsx("p",{className:"publish__static",children:((z=l[0])==null?void 0:z.login)??"—"})]}),i.jsxs("label",{className:"field publish__field",children:[i.jsx("span",{children:"Описание (необязательно)"}),i.jsx("input",{className:"input",value:L,placeholder:"о чём проект — одной строкой",onChange:be=>X(be.target.value)})]}),i.jsxs("div",{className:"field publish__field",children:[i.jsx("span",{children:"Видимость"}),i.jsxs("div",{className:"access",role:"radiogroup","aria-label":"Видимость репозитория",children:[i.jsx(Ix,{title:"Приватный",desc:"Виден только вам и тем, кого вы пригласите. Стоит по умолчанию: репозиторий с чужим кодом, случайно ставший публичным, потом не отозвать.",on:J,onClick:()=>G(!0)}),i.jsx(Ix,{title:"Публичный",desc:"Виден всем в интернете — код, история коммитов, всё содержимое.",risky:!0,on:!J,onClick:()=>G(!1)})]})]})]}),!o&&i.jsxs("div",{className:"publish__section",children:[i.jsx("h3",{className:"publish__heading",children:"Файлы первого коммита"}),r===null?i.jsx("p",{className:"modal__text",children:"Читаем файлы…"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"publish__filehead",children:[i.jsxs("span",{className:"publish__filecount",children:[je," из ",r.files.length," файлов"]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:()=>A(!0),children:"Отметить все"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:()=>A(!1),children:"Снять все"})]}),r.files.length>8&&i.jsx("input",{className:"input publish__filter",value:H,placeholder:"Фильтр по пути…",spellCheck:!1,onChange:be=>ne(be.target.value)}),i.jsx("div",{className:"publish__filelist",children:ue.length===0?i.jsx("p",{className:"modal__text publish__filesempty",children:"Ничего не найдено по фильтру."}):ue.map(be=>i.jsxs("button",{type:"button",role:"checkbox","aria-checked":(M==null?void 0:M.has(be))===!0,className:"publish__file",onClick:()=>Ce(be),children:[i.jsx("span",{className:"publish__box"+(M!=null&&M.has(be)?" is-on":""),"aria-hidden":"true",children:(M==null?void 0:M.has(be))&&"✓"}),i.jsx("span",{className:"publish__filepath",children:be})]},be))}),r.truncated&&i.jsx("p",{className:"publish__truncated",children:"Каталог больше, чем показано здесь, — часть файлов в список не попала. Их всё равно можно закоммитить потом обычным образом."}),i.jsxs("label",{className:"field publish__field",children:[i.jsx("span",{children:"Сообщение коммита"}),i.jsx("input",{className:"input",value:O,onChange:be=>Z(be.target.value)})]})]})]}),i.jsx(mr,{result:h,onDismiss:_})]})}function Ix({title:s,desc:l,on:r,risky:c,onClick:o}){return i.jsxs("button",{type:"button",role:"radio","aria-checked":r,className:"access__card"+(r?" is-on":"")+(c?" access__card--risky":""),onClick:o,children:[i.jsx("span",{className:"access__radio","aria-hidden":"true"}),i.jsxs("span",{className:"access__body",children:[i.jsxs("span",{className:"access__title",children:[s,c&&i.jsx("span",{className:"access__risk",children:"видно всем"})]}),i.jsx("span",{className:"access__desc",children:l})]})]})}function Jw({status:s,onRefreshStatus:l,onSaveToken:r}){const[c,o]=y.useState(""),[d,h]=y.useState(!1);return i.jsxs("div",{className:"publish__section publish__section--first",children:[i.jsx("h3",{className:"publish__heading",children:"Учётная запись GitHub"}),s===null?i.jsx("p",{className:"modal__text",children:"Проверяем подключение…"}):s.connected?i.jsxs("div",{className:"publish__account",children:[i.jsx("span",{className:"chip chip--ok",children:s.login}),i.jsx("span",{className:"publish__accountvia",children:s.source==="gh"?"через GitHub CLI":"по личному токену"}),s.source==="token"&&i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:()=>r(""),children:"Отключить токен"})]}):i.jsxs("div",{className:"publish__connect",children:[s.ghInstalled&&i.jsxs("p",{className:"modal__text",children:["В системе установлен ",i.jsx("code",{children:"gh"}),", но вход в нём не выполнен. Можно вместо токена выполнить ",i.jsx("code",{children:"gh auth login"})," в панели терминала и нажать «Проверить снова» — либо ввести личный токен ниже."]}),i.jsxs("label",{className:"field publish__field",children:[i.jsx("span",{children:"Личный токен GitHub"}),i.jsx(Ww,{value:c,onChange:o,visible:d,onToggleVisible:()=>h(m=>!m),placeholder:"ghp_…"})]}),i.jsxs("p",{className:"publish__tokenhint",children:["Нужен токен с доступом ",i.jsx("code",{children:"repo"})," — им приложение создаст репозиторий и отправит в него код."," ",i.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=Claude%20Code%20Visual",target:"_blank",rel:"noreferrer",children:"Создать токен на GitHub ↗"})]}),s.message&&i.jsx("p",{className:"modal__error",children:s.message}),i.jsxs("div",{className:"extbar",children:[i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:l,children:"Проверить снова"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--primary",disabled:c.trim()==="",onClick:()=>r(c.trim()),children:"Сохранить токен"})]})]})]})}function Ww({value:s,onChange:l,visible:r,onToggleVisible:c,placeholder:o,autoFocus:d}){return i.jsxs("div",{className:"pwfield",children:[i.jsx("input",{className:"input input--mono pwfield__input",type:r?"text":"password",value:s,placeholder:o,spellCheck:!1,autoComplete:"off",autoFocus:d,onChange:h=>l(h.target.value)}),i.jsx("button",{type:"button",className:"pwfield__toggle","aria-label":r?"Скрыть токен":"Показать токен","aria-pressed":r,onClick:c,children:r?i.jsx(ek,{}):i.jsx(Pw,{})})]})}function Pw(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M1 8s2.5-5 7-5 7 5 7 5-2.5 5-7 5-7-5-7-5Z"}),i.jsx("circle",{cx:"8",cy:"8",r:"2.1"})]})}function ek(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M1 8s2.5-5 7-5 7 5 7 5-2.5 5-7 5-7-5-7-5Z"}),i.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),i.jsx("path",{d:"M2 14 14 2"})]})}function tk({busy:s,result:l,onSubmit:r,onDismissResult:c,onClose:o}){const[d,h]=y.useState(""),m=/^(https?|ssh|git):\/\/\S+/i.test(d.trim())||/^[\w.-]+@[\w.-]+:.+/.test(d.trim());return i.jsxs(Sl,{title:"Подключить существующий репозиторий",onClose:o,actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"btn",onClick:o,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--primary",disabled:!m||s!=="",onClick:()=>r(d.trim()),children:s||"Подключить"})]}),children:[i.jsxs("p",{className:"modal__text",children:["Пропишет этот адрес как ",i.jsx("code",{children:"origin"})," текущего репозитория. Ничего не отправляется само — после этого в панели появятся обычные «Отправить» и «Забрать»."]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Адрес репозитория"}),i.jsx("input",{className:"input input--mono",value:d,placeholder:"https://github.com/owner/name.git",spellCheck:!1,autoComplete:"off",autoFocus:!0,onChange:g=>h(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m&&s===""&&r(d.trim())}})]}),i.jsxs("p",{className:"modal__text modal__text--dim",children:["Подходят адреса вида ",i.jsx("code",{children:"https://…"}),", ",i.jsx("code",{children:"ssh://…"}),", ",i.jsx("code",{children:"git://…"})," и"," ",i.jsx("code",{children:"git@host:path"}),"."]}),i.jsx(mr,{result:l,onDismiss:c})]})}function nk({open:s,items:l,busy:r,ready:c,commands:o,contextResult:d,draftKey:h,models:m,model:g,effort:b,ultracode:_,thinking:S,switchOnFlag:v,onContextSearch:E,onCommand:T,onModel:C,onEffort:L,onUltracode:X,onThinking:J,onSwitchOnFlag:G,onAsk:O,onInterrupt:Z,onReset:M,onClose:D,zoomed:H,onToggleZoom:ne}){return i.jsxs("aside",{className:(s?"sidepane sidepane--ask sidepane--open":"sidepane sidepane--ask")+(H?" sidepane--zoomed":""),"aria-label":"Вопрос на полях",children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:he=>{ne&&(he.target.closest("button")||ne())},children:[i.jsx(lk,{}),i.jsx("span",{className:"sidepane__title",children:"Вопрос на полях"}),i.jsx("button",{className:"sidepane__btn",title:"Начать заново — следующий вопрос возьмёт свежий контекст","aria-label":"Начать боковой разговор заново",disabled:l.length===0,onClick:M,children:"↻"}),ne&&i.jsx("button",{className:"sidepane__btn",title:H?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":H?"Свернуть панель вопроса":"Развернуть панель вопроса на весь экран","aria-pressed":H,onClick:ne,children:i.jsx(Sc,{active:H})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель вопроса",onClick:D,children:"✕"})]}),m.length>0&&i.jsxs("div",{className:"sidepane__tools",children:[i.jsx(Zy,{className:"select--compact",models:m,value:g,effort:b,ultracode:_,thinking:S,switchOnFlag:v,onModel:C,onEffort:L,onUltracode:X,onThinking:J,onSwitchOnFlag:G}),i.jsx("span",{className:"sidepane__note",title:"Боковой вопрос работает только на чтение",children:"только чтение"})]}),i.jsx(Op,{items:l,busy:r,waiting:!1,empty:c?"Спросите о том, что происходит: вопрос уйдёт в сторону от основного разговора и не попадёт в его контекст. Отвечающий видит сессию и проект, но ничего не меняет.":"Откройте сессию — вопрос задаётся о ней."}),i.jsx(Vy,{className:"composer--side",disabled:!c,busy:r,commands:o,sessionTitle:null,contextResult:d,draftKey:h?`side:${h}`:null,placeholder:"Спросить, не мешая работе…",sendLabel:"Спросить",autoFocus:s,attachmentsEnabled:!1,onContextSearch:E,onCommand:T,onSend:O,onInterrupt:Z,onEscape:r?Z:D})]})}function lk(){return i.jsxs("svg",{className:"sidepane__icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M13.6 9.4a1.6 1.6 0 0 1-1.6 1.6H6.2L3.2 13.4V4.2a1.6 1.6 0 0 1 1.6-1.6h7.2a1.6 1.6 0 0 1 1.6 1.6Z"}),i.jsx("path",{d:"M8.4 8.5v-.3c0-.7.9-.9.9-1.7a1 1 0 0 0-1.9-.4"})]})}const sk=75,ak=90;function Jy({usage:s}){if(!(s!=null&&s.available))return null;const l=s.buckets??[],r=l.length>0?l.map(o=>({key:o.id,label:o.label,window:o.window})):[...s.fiveHour?[{key:"five",label:"5 ч",window:s.fiveHour}]:[],...s.sevenDay?[{key:"week",label:"нед",window:s.sevenDay}]:[]];if(r.length===0)return null;const c=l.length>0?"Квота Antigravity":`Расход лимитов плана${s.plan?` ${s.plan}`:""}`;return i.jsx("div",{className:"usage",title:ck(s,l),"aria-label":c,children:r.map(o=>i.jsx(ik,{label:o.label,window:o.window},o.key))})}function ik({label:s,window:l}){const r=Math.round(l.utilization),c=uk(l.resetsAt);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"usage__label",children:s}),i.jsx("span",{className:"usage__track",role:"progressbar","aria-label":s,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,children:i.jsx("span",{className:`usage__fill${rk(r)}`,style:{width:`${r}%`}})}),i.jsxs("span",{className:"usage__pct",children:[r,"%"]}),i.jsx("span",{className:"usage__reset",title:zp(l.resetsAt)||void 0,children:c&&`↻ ${c}`})]})}function rk(s){return s>=ak?" usage__fill--over":s>=sk?" usage__fill--warn":""}function ck(s,l){if(l.length>0)return ok(l);const r=[s.plan?`Лимиты плана ${s.plan}`:"Лимиты плана"],c=(o,d)=>{if(!d)return;const h=zp(d.resetsAt);r.push(`${o}: ${Math.round(d.utilization)}%${h?`, ${h}`:""}`)};return c("5 часов",s.fiveHour),c("Неделя",s.sevenDay),c("Неделя, Opus",s.sevenDayOpus),r.join(`
|
|
120
120
|
`)}function ok(s){const l=["Квота Antigravity"];for(const r of s){const c=zp(r.window.resetsAt),o=Math.round(r.window.utilization);l.push(`${r.title}: ${o}%${c?`, ${c}`:""}`),r.description&&l.push(r.description)}return l.join(`
|
|
121
121
|
`)}function Wy(s){if(!s)return null;const l=new Date(s);return Number.isNaN(l.getTime())?null:l}function Py(s){return s.getTime()-Date.now()<1440*60*1e3}function uk(s){const l=Wy(s);return l?Py(l)?l.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):l.toLocaleDateString(void 0,{day:"numeric",month:"short"}):""}function zp(s){const l=Wy(s);return l?`обнулится ${Py(l)?`в ${l.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:l.toLocaleDateString(void 0,{day:"numeric",month:"long"})}`:""}function e_(){const[s,l]=y.useState(()=>new Date);return y.useEffect(()=>{let r=0;const c=()=>{const d=new Date;l(d),r=window.setTimeout(c,6e4-(d.getSeconds()*1e3+d.getMilliseconds()))};c();const o=()=>{document.hidden||(window.clearTimeout(r),c())};return document.addEventListener("visibilitychange",o),()=>{window.clearTimeout(r),document.removeEventListener("visibilitychange",o)}},[]),i.jsxs("time",{className:"clock",dateTime:s.toISOString(),title:fk(s),children:[i.jsx("span",{className:"clock__time",children:s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),i.jsx("span",{className:"clock__date",children:s.toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})})]})}function fk(s){return s.toLocaleDateString(void 0,{weekday:"long",day:"numeric",month:"long",year:"numeric"})}function dk({onClose:s,permission:l,model:r,usage:c,cwd:o,costLabel:d,onRefresh:h,refreshing:m,metersFetchedAt:g,onRename:b,onHandoff:_,onFreshSession:S,handoffWriting:v,onStop:E}){const T=py({onLongPress:()=>S==null?void 0:S(),onClick:()=>_==null?void 0:_(),disabled:v});return i.jsx(Sl,{title:"Настройки сессии",className:"modal--sheet",sheet:!0,onClose:s,children:i.jsxs("div",{className:"sessionmenu",children:[l&&i.jsx(ac,{label:"Режим прав",children:l}),i.jsx(ac,{label:"Модель",children:r}),(c==null?void 0:c.available)&&(c.fiveHour||c.sevenDay||c.buckets&&c.buckets.length>0)&&i.jsx(ac,{label:"Лимиты плана",children:i.jsx(Jy,{usage:c})}),i.jsxs("button",{type:"button",className:m?"sessionmenu__refresh is-busy":"sessionmenu__refresh","aria-busy":m,disabled:m,onClick:h,children:[i.jsx(hk,{}),i.jsxs("span",{className:"sessionmenu__refresh-text",children:["Обновить показания",g&&i.jsxs("span",{className:"sessionmenu__refresh-time",children:["обновлено в"," ",new Date(g).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]})]}),i.jsx(ac,{label:"Время",children:i.jsx(e_,{})}),d&&i.jsx(ac,{label:"Стоимость хода",children:i.jsx("span",{className:"badge badge--cost",children:d})}),o&&i.jsx(ac,{label:"Каталог проекта",children:i.jsx(Ky,{path:o})}),b&&i.jsx("button",{type:"button",className:"sessionmenu__rename",onClick:b,children:"Переименовать сессию"}),_&&i.jsxs("button",{type:"button",className:v?"sessionmenu__handoff is-busy":T.holding?"sessionmenu__handoff is-holding":"sessionmenu__handoff",style:{"--hold-ms":`${T.thresholdMs}ms`},"aria-busy":v,disabled:v,...T.handlers,children:[i.jsx("span",{className:"sessionmenu__handoff-hold","aria-hidden":"true"}),i.jsxs("span",{className:"sessionmenu__handoff-text",children:[v?"Пишется хэндофф…":"Хэндофф и новая сессия",!v&&i.jsx("span",{className:"sessionmenu__handoff-hint",children:"Зажмите — новая сессия без хэндоффа"})]})]}),E&&i.jsx("button",{type:"button",className:"sessionmenu__stop",onClick:E,children:"Остановить сессию"})]})})}function ac({label:s,children:l}){return i.jsxs("div",{className:"sessionmenu__row",children:[i.jsx("span",{className:"sessionmenu__label",children:s}),l]})}function hk(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M14 8a6 6 0 1 1-6-6c1.68 0 3.29.67 4.49 1.83L14 5.33"}),i.jsx("path",{d:"M14 2v3.33h-3.33"})]})}function pk({tab:s,servers:l,plugins:r,marketplaces:c,catalog:o,result:d,actions:h,onTab:m,onClose:g}){const b=[{id:"mcp",label:"MCP-серверы",count:l.length},{id:"plugins",label:"Плагины",count:r.length},{id:"catalog",label:"Каталог",count:o.length}];return i.jsxs(Sl,{title:"Расширения",className:"modal--wide",onClose:g,children:[i.jsx("div",{className:"tabs",role:"tablist",children:b.map(_=>i.jsxs("button",{role:"tab","aria-selected":s===_.id,className:s===_.id?"tabs__tab is-on":"tabs__tab",onClick:()=>m(_.id),children:[_.label,i.jsx("span",{className:"tabs__count",children:_.count})]},_.id))}),s==="mcp"&&i.jsx(mk,{servers:l,actions:h}),s==="plugins"&&i.jsx(_k,{plugins:r,marketplaces:c,actions:h}),s==="catalog"&&i.jsx(vk,{catalog:o,hasMarketplaces:c.length>0,actions:h,onMarketplaces:()=>m("plugins")}),i.jsx(mr,{result:d})]})}function mk({servers:s,actions:l}){const[r,c]=y.useState(!1);return i.jsxs(i.Fragment,{children:[s.length===0&&!r&&i.jsxs("p",{className:"modal__text",children:["Ни одного MCP-сервера. Добавленный здесь попадёт в ",i.jsx("code",{children:".mcp.json"})," ","проекта — его увидит и консольный ",i.jsx("code",{children:"claude mcp list"}),"."]}),i.jsx("ul",{className:"extlist",children:s.map(o=>i.jsxs("li",{className:"extlist__row",children:[i.jsxs("div",{className:"extlist__head",children:[i.jsx("span",{className:"extlist__name",children:o.name}),i.jsx("span",{className:`chip chip--${bk(o.status)}`,children:gk[o.status]}),o.scope&&i.jsx("span",{className:"chip",children:o.scope}),o.transport&&i.jsx("span",{className:"chip",children:o.transport})]}),o.target&&i.jsx("div",{className:"extlist__meta",title:o.target,children:o.target}),o.error&&i.jsx("div",{className:"extlist__error",children:o.error}),o.tools.length>0&&i.jsxs("div",{className:"extlist__meta",children:["Инструментов: ",o.tools.length," · ",o.tools.slice(0,6).join(", "),o.tools.length>6&&"…"]}),i.jsxs("div",{className:"extlist__actions",children:[i.jsx("button",{className:"btn btn--ghost btn--sm",onClick:()=>l.mcpAction(o.name,"reconnect"),children:"Переподключить"}),o.status==="disabled"?i.jsx("button",{className:"btn btn--ghost btn--sm",onClick:()=>l.mcpAction(o.name,"enable"),children:"Включить"}):i.jsx("button",{className:"btn btn--ghost btn--sm",onClick:()=>l.mcpAction(o.name,"disable"),children:"Выключить"}),o.editable&&i.jsx("button",{className:"btn btn--ghost btn--sm btn--danger",onClick:()=>l.mcpRemove(o.name),children:"Удалить"})]})]},o.name))}),r?i.jsx(xk,{onCancel:()=>c(!1),onSubmit:(o,d)=>{l.mcpAdd(o,d),c(!1)}}):i.jsx("div",{className:"extbar",children:i.jsx("button",{className:"btn btn--primary",onClick:()=>c(!0),children:"+ Сервер"})})]})}const gk={connected:"подключён",failed:"ошибка","needs-auth":"нужна авторизация",pending:"подключается",disabled:"выключен",unknown:"неизвестно"};function bk(s){return s==="connected"?"ok":s==="failed"?"bad":s==="needs-auth"?"warn":"mute"}function xk({onSubmit:s,onCancel:l}){const[r,c]=y.useState(""),[o,d]=y.useState("stdio"),[h,m]=y.useState(""),[g,b]=y.useState(""),[_,S]=y.useState(""),v=o==="stdio",E=r.trim()!==""&&(v?h.trim()!=="":g.trim()!=="");function T(){if(E)if(v){const[C,...L]=yk(h);s(r.trim(),{transport:"stdio",command:C??"",args:L,env:qx(_)})}else s(r.trim(),{transport:o,url:g.trim(),headers:qx(_)})}return i.jsxs("div",{className:"extform extform--card",children:[i.jsx("label",{className:"field",htmlFor:"mcp-name",children:"Имя сервера"}),i.jsx("input",{id:"mcp-name",className:"input input--mono",value:r,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"context7",onChange:C=>c(C.target.value)}),i.jsx("label",{className:"field",children:"Транспорт"}),i.jsx(Cs,{title:"Транспорт",value:o,options:[{value:"stdio",label:"stdio",hint:"локальный процесс"},{value:"http",label:"http",hint:"удалённый сервер"},{value:"sse",label:"sse",hint:"удалённый, поток событий"}],onChange:C=>d(C)}),v?i.jsxs(i.Fragment,{children:[i.jsx("label",{className:"field",htmlFor:"mcp-command",children:"Команда с аргументами"}),i.jsx("input",{id:"mcp-command",className:"input input--mono",value:h,spellCheck:!1,autoComplete:"off",placeholder:"npx -y @upstash/context7-mcp",onChange:C=>m(C.target.value)})]}):i.jsxs(i.Fragment,{children:[i.jsx("label",{className:"field",htmlFor:"mcp-url",children:"URL"}),i.jsx("input",{id:"mcp-url",className:"input input--mono",value:g,spellCheck:!1,autoComplete:"off",placeholder:"https://mcp.example.dev/mcp",onChange:C=>b(C.target.value)})]}),i.jsxs("label",{className:"field",htmlFor:"mcp-pairs",children:[v?"Переменные окружения":"Заголовки"," — по одной на строку, необязательно"]}),i.jsx("textarea",{id:"mcp-pairs",className:"input input--mono input--area",value:_,spellCheck:!1,placeholder:v?"API_KEY=xxx":"Authorization: Bearer xxx",onChange:C=>S(C.target.value)}),i.jsxs("div",{className:"extbar",children:[i.jsx("button",{className:"btn",onClick:l,children:"Отмена"}),i.jsx("button",{className:"btn btn--primary",disabled:!E,onClick:T,children:"Подключить"})]})]})}function qx(s){const l={};for(const r of s.split(`
|
|
@@ -130,5 +130,5 @@ ${m}`,"aria-label":"Переподключить сессию",disabled:h,onClic
|
|
|
130
130
|
`)),r&&W.focus(),Z=()=>{var N;A!==null&&window.clearTimeout(A),z.disconnect(),(N=W.element)==null||N.removeEventListener("contextmenu",je),Me.dispose(),ce.dispose(),be(),W.dispose(),_.current=null},L("ready")})(),()=>{O=!0,window.clearTimeout(M),Z==null||Z(),Z=null}},[s]),y.useEffect(()=>{if(!o)return;const G=b.current;if(!G)return;let O=null,Z=0,M=!1;const D=W=>{W.pointerType==="mouse"||O!==null||(O=W.pointerId,Z=W.clientY,M=!1)},H=W=>{if(W.pointerId!==O)return;const ue=Z-W.clientY;if(!M){if(Math.abs(ue)<4)return;M=!0,G.setPointerCapture(W.pointerId)}Z=W.clientY;const je=G.querySelector(".xterm-viewport");je&&(je.scrollTop+=ue)},ne=W=>{W.pointerId===O&&(G.hasPointerCapture(W.pointerId)&&G.releasePointerCapture(W.pointerId),O=null,M=!1)},he=W=>W.stopPropagation();return G.addEventListener("pointerdown",D),G.addEventListener("pointermove",H),G.addEventListener("pointerup",ne),G.addEventListener("pointercancel",ne),G.addEventListener("touchmove",he,{capture:!0}),()=>{G.removeEventListener("pointerdown",D),G.removeEventListener("pointermove",H),G.removeEventListener("pointerup",ne),G.removeEventListener("pointercancel",ne),G.removeEventListener("touchmove",he,{capture:!0}),O!==null&&G.hasPointerCapture(O)&&G.releasePointerCapture(O)}},[o]),y.useEffect(()=>{E.current=c,_.current&&(_.current.options.theme=c)},[c]),y.useEffect(()=>{var G;r&&((G=_.current)==null||G.focus())},[r]),y.useEffect(()=>{if(T.current=l,l===null){S.current=!1;return}if(S.current)return;const G=_.current;G&&(S.current=!0,G.write(`\r
|
|
131
131
|
\x1B[2m— Процесс завершён (код ${l}) —\x1B[0m\r
|
|
132
132
|
`))},[l]),i.jsxs("div",{className:"termview"+(r?" is-active":""),children:[i.jsx("div",{ref:b,className:"termview__surface"+(C==="ready"?"":" is-hidden")}),C==="loading"&&X&&i.jsxs("div",{className:"termview__state work",role:"status",children:[i.jsxs("div",{className:"work__dots",children:[i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"}),i.jsx("span",{className:"work__dot"})]}),i.jsx("span",{className:"work__label",children:"Загружается терминал…"})]}),C==="error"&&i.jsxs("div",{className:"termview__state termview__state--error",role:"alert",children:[i.jsx("p",{children:"Не удалось загрузить терминал"}),i.jsx("p",{className:"termpanel__hint",children:"Соединение оборвалось раньше, чем приехал нужный модуль — на мобильном relay это обычное дело на слабой сети. Ниже — перезагрузка страницы, а не тихий повтор: открытые терминалы и их содержимое приедут обратно с хоста, а вот черновик в поле ввода внизу — нет."}),i.jsx("button",{className:"btn btn--primary",onClick:()=>window.location.reload(),children:"Перезагрузить страницу"})]})]})}const aN=2e5,iN=75,rN=90;function cN({tokens:s,maxTokens:l,fetchedAt:r}){if(s===null)return null;const c=l??aN,o=Math.min(100,Math.round(s/c*100)),d=`${s.toLocaleString()} из ${c.toLocaleString()} токенов${r?`
|
|
133
|
-
обновлено в ${new Date(r).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}`;return i.jsxs("div",{className:"contextbar","aria-label":`Занято контекста: ${o}%`,title:d,children:[i.jsx("span",{className:"contextbar__label",children:"контекст"}),i.jsx("span",{className:"contextbar__track",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,children:i.jsx("span",{className:`contextbar__fill${oN(o)}`,style:{width:`${o}%`}})}),i.jsxs("span",{className:"contextbar__pct",children:[o,"%"]})]})}function oN(s){return s>=rN?" contextbar__fill--over":s>=iN?" contextbar__fill--warn":""}const t_="ccv:last-session",uN=300*1e3,fN=1e4;function dN(){try{const s=localStorage.getItem(t_);if(!s)return null;const l=JSON.parse(s);if(typeof l!="object"||l===null)return null;const{workspaceId:r,sessionId:c,claudeSessionId:o}=l;return typeof r!="string"||typeof c!="string"?null:{workspaceId:r,sessionId:c,claudeSessionId:typeof o=="string"?o:null}}catch{return null}}function hN(s,l){return s.id===l.sessionId?!0:l.claudeSessionId?s.id===l.claudeSessionId||s.claudeSessionId===l.claudeSessionId:!1}const pN={mcp:"mcp",plugins:"plugins",plugin:"plugins"},Zx=[{name:"login",description:"Войти в аккаунт Claude — окно приложения",argumentHint:"",aliases:["signin","вход"]},{name:"switch-account",description:"Сменить аккаунт: выйти и войти заново",argumentHint:"",aliases:["account","аккаунт"]},{name:"logout",description:"Выйти из аккаунта Claude",argumentHint:"",aliases:["signout","выход"]}],mN={active:!1,url:"",awaitingCode:!1,output:"",error:null};function Fx(s,l,r){if(s===null)return null;const c=s.lastIndexOf("/");if(c===-1&&s!=="")return l;const o=r[c===-1?"":s.slice(0,c)];if(!o)return null;const d=s.slice(c+1).toLowerCase();return d===""?{query:s,entries:o}:{query:s,entries:o.filter(h=>h.name.toLowerCase().includes(d)).sort((h,m)=>Jx(h.name,d)-Jx(m.name,d))}}function Jx(s,l){return s.toLowerCase().startsWith(l)?0:1}function Wx(s,l){const r=s.find(o=>o.value===l)??s.find(o=>o.resolvedModel===l),c=l&&!r?l:null;return{rows:[...c?[{value:c,resolvedModel:c,displayName:c,description:"задана в настройках",supportsEffort:!1,effortLevels:[],supportsThinking:!0,supportsAutoMode:!1}]:[],...s],selected:(r==null?void 0:r.value)??c??(s.some(o=>o.value==="default")?"default":"")}}function gN(){var Jc,ya;const s=y.useRef(null),[l,r]=y.useState(!1),[c,o]=y.useState("Нет связи с хостом"),[d,h]=y.useState(null),[m,g]=y.useState(!1),b=y.useMemo(()=>Mf()==="relay",[]),[_,S]=y.useState([]),[v,E]=y.useState([]),[T,C]=y.useState([]),[L,X]=y.useState([]),[J,G]=y.useState([]),[O,Z]=y.useState([]),[M,D]=y.useState([]),[H,ne]=y.useState([]),[he,W]=y.useState([]),[ue,je]=y.useState(null),[Me,Ce]=y.useState(null),[A,ce]=y.useState(null),[z,be]=y.useState(null),[ye,N]=y.useState(null),[V,re]=y.useState(vl),[me,Ne]=y.useState(zh),[ve,De]=y.useState(!1),[yt,Xe]=y.useState(!1),$e=Xf("(max-width: 860px)"),[Ve,It]=y.useState(!1);y.useEffect(()=>{$e||It(!1)},[$e]);const[rt,dn]=y.useState(!1),[ft,hn]=y.useState([]),[Sn,xn]=y.useState(!1),[en,tt]=y.useState(vl),[et,tn]=y.useState(null),[Xt,nt]=y.useState(null),[St,$t]=y.useState([]),[cn,wt]=y.useState(null),[yn,qt]=y.useState(null),[pn,Dn]=y.useState([]),[Gt,ct]=y.useState([]),[Et,Pe]=y.useState([]),[wl,le]=y.useState([]),[ge,He]=y.useState(null),[B,P]=y.useState({}),[_e,Be]=y.useState(null),[Ot,fl]=y.useState({}),[On,dl]=y.useState(null),[sl,Bl]=y.useState([]),[ds,hl]=y.useState(!1),[al,pl]=y.useState(null),[Yt,Vt]=y.useState(null),[kl,kt]=y.useState(!1),[Qt,Oe]=y.useState(mN),[Ct,qn]=y.useState(null),[nn,Ln]=y.useState(null),[il,wn]=y.useState(!1),[Il,,rl]=X0(),ln=F0(),[Kt,on]=y.useState(!1),[Fe,ml]=y.useState(null),[Ms,Gn]=y.useState(null),[Zl,hs]=y.useState(null),[ps,mn]=y.useState(null),[Fl,Zn]=y.useState(null),[zn,kn]=y.useState(""),[Lt,Rs]=y.useState(null),[Di,Ds]=y.useState([]),[Yn,Nl]=y.useState(!1),[La,Nn]=y.useState(null),[sn,Jl]=y.useState(!1),[lt,Xn]=y.useState(!1),[pe,k]=y.useState({}),[Y,fe]=y.useState([""]),[we,Ae]=y.useState([]),[ze,dt]=y.useState(null),[w,se]=y.useState(null),[ke,Je]=y.useState(null),[ht,ms]=y.useState(null),[za,gr]=y.useState(null),[Ua,wc]=y.useState({}),[Os,Wl]=y.useState({}),[gs,bs]=y.useState(!1),[Ls,Oi]=y.useState(null),[sa,br]=y.useState(null),Li=y.useRef(0),aa=y.useRef(null),[ia,$n]=y.useState(!1),[Pl,zs]=y.useState([]),[zi,xr]=y.useState(null),[kc,Ha]=y.useState(null),Us=W0(),Ba=nv($e&&ia),Ia=y.useRef(new Map),ra=(Yt==null?void 0:Yt.terminalEnabled)===!0,yr=Mf()==="relay"&&((Jc=d==null?void 0:d.shell)==null?void 0:Jc.enabled)!==!0,Nc=y.useRef(!1),Tc=y.useCallback((p,I)=>(Ia.current.set(p,I),()=>{Ia.current.get(p)===I&&Ia.current.delete(p)}),[]),[ca,_r]=y.useState(!1),[$o,vr]=y.useState(null),[Vo,Ui]=y.useState(vl),[xs,jr]=y.useState(null),[Hi,oa]=y.useState({}),ua=y.useRef([]),[an,Ec]=y.useState(null);function Kf(p){Ec(I=>I===p?null:p)}y.useEffect(()=>{($e||an==="terminal"&&!ia||an==="files"&&!lt||an==="search"&&!gs||an==="git"&&!Kt||an==="ask"&&!ca||an==="main"&&we.length===0)&&Ec(null)},[an,$e,ia,lt,gs,Kt,ca,we.length]);const[Qo]=y.useState(dN),Ko=y.useRef(Qo),Sr=y.useRef(!1),Un=y.useRef(null),Bi=y.useRef(null),Ii=y.useRef(null),Zo=y.useRef(0),Tn=y.useRef(null),Fo=y.useRef(0);Un.current=z,Tn.current=A,Fo.current=V.lastSeq;const Jo=y.useRef(me);Jo.current=me;const ql=y.useRef(null),qa=y.useRef(0);qa.current=Vo.lastSeq;const wr=y.useRef(null),qi=y.useRef(""),Ga=y.useRef(null),Hs=y.useRef([]),Cc=y.useRef([""]);Hs.current=we,Cc.current=Y;const Ya=y.useRef(new Map),ys=y.useRef(new Set),Gi=y.useRef(null),Yi=y.useRef(null),Wo=y.useRef(0),Xa=y.useRef(new Set);y.useEffect(()=>{const p=R0();if(!p)return;s.current=p;const I=()=>{r(p.connected),o(p.statusText)};p.onStatus(I),p.onReconnect(()=>{I(),fl({});const Ut=Un.current;Ut&&p.send({type:"session.sync",sessionId:Ut,sinceSeq:Fo.current});const Zt=ql.current;Zt&&p.send({type:"session.sync",sessionId:Zt,sinceSeq:qa.current})});const de=p.on(Ut=>Po(Ut));p.connect();const Ge=window.setInterval(()=>{I(),p.connected&&p.send({type:"ping",nonce:Date.now()})},15e3);return()=>{de(),window.clearInterval(Ge),p.close()}},[]);const Po=y.useCallback(p=>{var I,de,Ge,Ut,Zt,Bn,si,Wc,_a;switch(p.type){case"hello.ok":r(!0);break;case"workspace.list":{S(p.workspaces),E(p.archived),ce(Ie=>{var Pn;if(Ie)return Ie;const gt=Ko.current,Ht=gt&&p.workspaces.find(zr=>zr.id===gt.workspaceId);return(Ht==null?void 0:Ht.id)??((Pn=p.workspaces[0])==null?void 0:Pn.id)??null});const xe=Ga.current;if(!xe)break;const Ee=p.workspaces.find(Ie=>jN(Ie.path,xe));if(!Ee)break;Ga.current=null,dn(!1),ce(Ee.id);break}case"workspace.candidates":if(p.query.trim()!==qi.current)break;hn(p.candidates),p.source==="host"&&xn(!1);break;case"finder.opened":wr.current=p.sessionId;break;case"workspace.roots":$t(p.roots);break;case"workspace.created":if(ce(p.workspace.id),p.warnings.length===0){dn(!1),nt(null);break}wt({path:p.workspace.path,warnings:p.warnings});break;case"session.list":if(p.workspaceId!==Tn.current)break;Z(p.sessions),D(p.archived);break;case"folder.list":C(p.workspaceFolders),X(p.sessionFolders),G(p.pinnedFolders??[]);break;case"session.pinned":ne(p.sessions);break;case"session.live":W(p.sessions);break;case"order.state":Ce(p.order);break;case"session.summary":if(p.session.id===wr.current){tn(p.session);break}if(p.session.parentSessionId){p.session.id===ql.current&&jr(p.session);break}if(W(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.session.id);if(p.session.state==="closed")return Ee===-1?xe:xe.filter(gt=>gt.id!==p.session.id);if(Ee===-1)return[...xe,p.session];const Ie=xe.slice();return Ie[Ee]=p.session,Ie}),Z(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.session.id);if(Ee===-1)return[p.session,...xe];const Ie=xe.slice();return Ie[Ee]=p.session,Ie}),ne(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.session.id);if(Ee===-1)return xe;const Ie=xe.slice();return Ie[Ee]={...p.session,pinned:!0,...xe[Ee].pinnedAt?{pinnedAt:xe[Ee].pinnedAt}:{}},Ie}),Un.current===null&&Ii.current&&Ii.current.workspaceId===p.session.workspaceId&&(iy(p.session.id,Ii.current.text),Ii.current=null),be(xe=>xe??p.session.id),((I=Bi.current)==null?void 0:I.sessionId)===p.session.id){const xe=Bi.current;p.session.state==="error"?Bi.current=null:p.session.state!=="closed"&&(Bi.current=null,(de=s.current)==null||de.send({type:"prompt.send",sessionId:xe.sessionId,text:xe.text,images:xe.images}))}break;case"usage.state":p.sessionId===Un.current&&(qn(p.usage),wn(!1));break;case"context.state":p.sessionId===Un.current&&(Ln(p.context),wn(!1));break;case"session.capabilities":p.sessionId===Un.current&&N(p.capabilities);break;case"session.events":if(p.sessionId===ql.current){Ui(xe=>Rf(xe,p.entries));break}if(p.sessionId===wr.current){tt(xe=>Rf(xe,p.entries));break}if(p.sessionId!==Un.current)break;for(const xe of p.entries){if(xe.event.kind!=="rewound")continue;const Ee=xe.event.toUserIndex,Ie=G0(Jo.current.entries,Ee),gt=Ie.reduce((Ht,Pn)=>Pn.event.kind==="user.message"?Ht+1:Ht,0);Ne(Ht=>({...Ht,entries:Ie})),re(Ht=>({...Ht,items:Y0(Ht.items,Ee,gt)}))}re(xe=>Rf(xe,p.entries));break;case"session.history":if(p.sessionId!==Un.current)break;Ne(xe=>B0(xe,p));break;case"side.opened":{if(p.parentSessionId!==Un.current)break;ql.current=p.sessionId,vr(p.sessionId);const xe=ua.current;ua.current=[];for(const Ee of xe)Ee(p.sessionId);break}case"side.closed":if(p.parentSessionId!==Un.current)break;ql.current=null,vr(null),Ui(vl),jr(null);break;case"git.state":if(p.workspaceId!==Tn.current)break;ml(p.state);break;case"git.commit":if(p.workspaceId!==Tn.current)break;Gn(p.detail);break;case"git.result":if(p.workspaceId!==Tn.current)break;mn({ok:p.ok,message:p.message,url:p.url}),p.ok&&(Gn(null),hs(null),Nl(!1),Jl(!1));break;case"git.busy":if(p.workspaceId!==Tn.current)break;kn(p.label);break;case"git.files":if(p.workspaceId!==Tn.current)break;Nn({files:p.files,truncated:p.truncated});break;case"github.status":Rs(p.status);break;case"github.owners":Ds(p.owners);break;case"fs.dir":if(p.workspaceId!==Tn.current)break;k(xe=>({...xe,[p.path]:p.entries}));break;case"fs.search":if(p.workspaceId!==Tn.current)break;if(p.scope!=="tree"){const xe=p.scope;Wl(Ee=>({...Ee,[xe]:{query:p.query,entries:p.entries}}));break}gr({query:p.query,entries:p.entries,truncated:p.truncated});break;case"fs.grep":if(p.workspaceId!==Tn.current)break;Oi({query:p.query,matches:p.matches,truncated:p.truncated});break;case"fs.file":{if(p.workspaceId!==Tn.current)break;const xe=ys.current.delete(p.file.path);Ae(Ie=>{const gt=Ie.findIndex(zr=>zr.path===p.file.path);if(gt===-1)return[...Ie,bx(p.file,++Wo.current)];const Ht=Ie[gt],Pn=Ie.slice();return Pn[gt]=Ht.saved===p.file.content&&!Ra(Ht)?{...Ht,mtime:p.file.mtime,size:p.file.size,stale:!1}:bx(p.file,++Wo.current),Pn}),xe&&dt(p.file.path);const Ee=aa.current;Ee&&Ee.path===p.file.path&&(aa.current=null,br({...Ee,token:++Li.current}));break}case"fs.media":{if(p.workspaceId!==Tn.current)break;Xa.current.delete(p.path),Ae(xe=>xe.map(Ee=>Ee.path===p.path?{...Ee,mediaBase64:p.base64,mediaError:void 0}:Ee));break}case"fs.mediaFailed":{if(p.workspaceId!==Tn.current)break;Xa.current.delete(p.path),Ae(xe=>xe.map(Ee=>Ee.path===p.path?{...Ee,mediaError:p.message}:Ee));break}case"fs.saved":{if(p.workspaceId!==Tn.current)break;const xe=Ya.current.get(p.path);Ya.current.delete(p.path);const Ee=xe!==void 0;Ae(gt=>gt.map(Ht=>Ht.path!==p.path?Ht:Ee?{...Ht,saved:xe,mtime:p.mtime,size:p.size,stale:!1}:{...Ht,stale:!0}));const Ie=Hs.current.find(gt=>gt.path===p.path);!Ee&&Ie&&!Ra(Ie)&&((Ge=s.current)==null||Ge.send({type:"fs.read",workspaceId:p.workspaceId,path:p.path})),(Ut=s.current)==null||Ut.send({type:"git.state",workspaceId:p.workspaceId});break}case"fs.result":{if(p.workspaceId!==Tn.current)break;if(se({ok:p.ok,message:p.message}),p.ok||Ya.current.delete(p.path),p.conflict&&Ae(Ee=>Ee.map(Ie=>Ie.path===p.path?{...Ie,stale:!0}:Ie)),Yi.current===p.path){const Ee=Yi.current;Yi.current=null,p.ok&&(ys.current.add(Ee),(Zt=s.current)==null||Zt.send({type:"fs.read",workspaceId:p.workspaceId,path:Ee}))}const xe=Gi.current;if(p.ok&&xe&&xe.to===p.path){Gi.current=null;const Ee=Ie=>Ie===xe.from?xe.to:Ie.startsWith(`${xe.from}/`)?xe.to+Ie.slice(xe.from.length):Ie;Ae(Ie=>Ie.map(gt=>({...gt,path:Ee(gt.path)}))),dt(Ie=>Ie===null?null:Ee(Ie)),fe(Ie=>Ie.map(Ee)),k(Ie=>{const gt={};for(const[Ht,Pn]of Object.entries(Ie))Ht===xe.from||Ht.startsWith(`${xe.from}/`)||(gt[Ht]=Pn);return gt})}p.ok&&((Bn=s.current)==null||Bn.send({type:"git.state",workspaceId:p.workspaceId}));break}case"term.list":if(p.workspaceId!==Tn.current)break;zs(p.terminals);break;case"term.opened":if(p.terminal.workspaceId!==Tn.current)break;Ha(null),zs(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.terminal.id);if(Ee===-1)return[...xe,p.terminal];const Ie=xe.slice();return Ie[Ee]=p.terminal,Ie}),Nc.current&&(Nc.current=!1,xr(p.terminal.id));break;case"term.buffer":(si=Ia.current.get(p.id))==null||si({kind:"buffer",data:p.data});break;case"term.data":(Wc=Ia.current.get(p.id))==null||Wc({kind:"data",data:p.data});break;case"term.exit":zs(xe=>xe.map(Ee=>Ee.id===p.id?{...Ee,exitCode:p.exitCode}:Ee));break;case"term.closed":zs(xe=>xe.filter(Ee=>Ee.id!==p.id));break;case"mcp.list":p.sessionId===Un.current&&Dn(p.servers);break;case"plugin.list":if(p.sessionId!==Un.current)break;ct(p.plugins),Pe(p.marketplaces),le(p.catalog);break;case"operation.result":p.sessionId===Un.current&&He(p.result);break;case"auth.status":pl(p.status);break;case"relay.state":h(p.state);break;case"settings.state":Vt(p.settings);break;case"handoff.state":P(xe=>{if(!p.handoff){if(!(p.sessionId in xe))return xe;const Ee={...xe};return delete Ee[p.sessionId],Ee}return{...xe,[p.sessionId]:p.handoff}});break;case"handoff.written":fl(xe=>{if(!(p.sessionId in xe))return xe;const Ee={...xe};return delete Ee[p.sessionId],Ee}),p.handoff&&Un.current===p.sessionId?dl(p.handoff):p.handoff||console.warn("[handoff] хост не смог записать хэндофф",p.sessionId);break;case"limit.stopped":Zo.current+=1,Bl(xe=>[...xe,{id:Zo.current,limit:p.limit,utilization:p.utilization,stopped:p.stopped,handoffs:p.handoffs}]);break;case"auth.login":Oe(p.state),p.state.active&&hl(!0);break;case"session.closed":W(xe=>xe.filter(Ee=>Ee.id!==p.sessionId)),Z(xe=>xe.map(Ee=>Ee.id===p.sessionId?{...Ee,state:"closed"}:Ee));break;case"error":console.error("[host]",p.message,p.context??""),(p.context==="workspace.open"||p.context==="workspace.create")&&(Ga.current=null,nt(p.message)),(_a=p.context)!=null&&_a.startsWith("term.")&&Ha(p.message);break}},[]),ee=y.useCallback(p=>{var I;(I=s.current)==null||I.send(p)},[]);y.useEffect(()=>{A&&ee({type:"session.list",workspaceId:A})},[A,ee]),y.useEffect(()=>{l&&ee({type:"session.pins"})},[l,ee]),y.useEffect(()=>{l&&ee({type:"settings.get"})},[l,ee]),y.useEffect(()=>{if(l)return ee({type:"session.drafts",sessionIds:ry()}),z0(p=>ee({type:"session.drafts",sessionIds:p}))},[l,ee]),y.useEffect(()=>{if(Sr.current)return;const p=Ko.current;if(!p||!A)return;if(A!==p.workspaceId){Sr.current=!0;return}if(z){Sr.current=!0;return}if(O.length===0)return;const I=O.find(de=>hN(de,p));Sr.current=!0,I&&Xi(I)},[O,A,z]),y.useEffect(()=>{!A||yr||!ra||ee({type:"term.list",workspaceId:A})},[A,yr,ra,ee]),y.useEffect(()=>{xr(p=>{var I;return p&&Pl.some(de=>de.id===p)?p:((I=Pl[0])==null?void 0:I.id)??null})},[Pl]),y.useEffect(()=>{rt&&ee({type:"workspace.roots"})},[rt,ee]);const es=y.useCallback(()=>{const p=Un.current;p&&(wn(!0),ee({type:"usage.get",sessionId:p}),ee({type:"context.get",sessionId:p}))},[ee]);y.useEffect(()=>{if(!il)return;const p=window.setTimeout(()=>wn(!1),fN);return()=>window.clearTimeout(p)},[il]);const Ac=y.useMemo(()=>{const p=Math.max((Ct==null?void 0:Ct.fetchedAt)??0,(nn==null?void 0:nn.fetchedAt)??0);return p>0?p:null},[Ct==null?void 0:Ct.fetchedAt,nn==null?void 0:nn.fetchedAt]);y.useEffect(()=>{if(Ln(null),!z)return;es();const p=()=>{document.hidden||es()},I=window.setInterval(p,uN),de=()=>{document.hidden||es()};return document.addEventListener("visibilitychange",de),()=>{window.clearInterval(I),document.removeEventListener("visibilitychange",de)}},[z,es]),y.useEffect(()=>{if(!z){Ne(zh);return}Ne({...zh,loading:!0}),ee({type:"session.history",sessionId:z})},[z,ee]);const kr=y.useCallback(()=>{!z||me.loading||!Db(me)||(Ne(p=>({...p,loading:!0})),ee({type:"session.history",sessionId:z,before:oy(me)}))},[z,me,ee]),eu=y.useMemo(()=>I0(me.entries),[me.entries]),$=y.useMemo(()=>O.find(p=>p.id===z)??null,[O,z]),fa=z?($==null?void 0:$.claudeSessionId)??z:null,da=fa?B[fa]??null:null;y.useEffect(()=>{fa&&ee({type:"handoff.get",sessionId:fa})},[fa,ee]),y.useEffect(()=>{_e&&!(_e.sessionId in B)&&Be(null)},[B,_e]);const Mc=y.useMemo(()=>{var de;if(!Ct)return null;const p=(((de=Ct.buckets)==null?void 0:de.length)??0)>0,I=($==null?void 0:$.provider)==="antigravity";return p===I?Ct:null},[Ct,$==null?void 0:$.provider]),Rc="Обновить лимиты и контекст",tu=Rc+(Ac?`
|
|
133
|
+
обновлено в ${new Date(r).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}`;return i.jsxs("div",{className:"contextbar","aria-label":`Занято контекста: ${o}%`,title:d,children:[i.jsx("span",{className:"contextbar__label",children:"контекст"}),i.jsx("span",{className:"contextbar__track",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,children:i.jsx("span",{className:`contextbar__fill${oN(o)}`,style:{width:`${o}%`}})}),i.jsxs("span",{className:"contextbar__pct",children:[o,"%"]})]})}function oN(s){return s>=rN?" contextbar__fill--over":s>=iN?" contextbar__fill--warn":""}const t_="ccv:last-session",uN=300*1e3,fN=1e4;function dN(){try{const s=localStorage.getItem(t_);if(!s)return null;const l=JSON.parse(s);if(typeof l!="object"||l===null)return null;const{workspaceId:r,sessionId:c,claudeSessionId:o}=l;return typeof r!="string"||typeof c!="string"?null:{workspaceId:r,sessionId:c,claudeSessionId:typeof o=="string"?o:null}}catch{return null}}function hN(s,l){return s.id===l.sessionId?!0:l.claudeSessionId?s.id===l.claudeSessionId||s.claudeSessionId===l.claudeSessionId:!1}const pN={mcp:"mcp",plugins:"plugins",plugin:"plugins"},Zx=[{name:"login",description:"Войти в аккаунт Claude — окно приложения",argumentHint:"",aliases:["signin","вход"]},{name:"switch-account",description:"Сменить аккаунт: выйти и войти заново",argumentHint:"",aliases:["account","аккаунт"]},{name:"logout",description:"Выйти из аккаунта Claude",argumentHint:"",aliases:["signout","выход"]}],mN={active:!1,url:"",awaitingCode:!1,output:"",error:null};function Fx(s,l,r){if(s===null)return null;const c=s.lastIndexOf("/");if(c===-1&&s!=="")return l;const o=r[c===-1?"":s.slice(0,c)];if(!o)return null;const d=s.slice(c+1).toLowerCase();return d===""?{query:s,entries:o}:{query:s,entries:o.filter(h=>h.name.toLowerCase().includes(d)).sort((h,m)=>Jx(h.name,d)-Jx(m.name,d))}}function Jx(s,l){return s.toLowerCase().startsWith(l)?0:1}function Wx(s,l){const r=s.find(o=>o.value===l)??s.find(o=>o.resolvedModel===l),c=l&&!r?l:null;return{rows:[...c?[{value:c,resolvedModel:c,displayName:c,description:"задана в настройках",supportsEffort:!1,effortLevels:[],supportsThinking:!0,supportsAutoMode:!1}]:[],...s],selected:(r==null?void 0:r.value)??c??(s.some(o=>o.value==="default")?"default":"")}}function gN(){var Jc,ya;const s=y.useRef(null),[l,r]=y.useState(!1),[c,o]=y.useState("Нет связи с хостом"),[d,h]=y.useState(null),[m,g]=y.useState(!1),b=y.useMemo(()=>Mf()==="relay",[]),[_,S]=y.useState([]),[v,E]=y.useState([]),[T,C]=y.useState([]),[L,X]=y.useState([]),[J,G]=y.useState([]),[O,Z]=y.useState([]),[M,D]=y.useState([]),[H,ne]=y.useState([]),[he,W]=y.useState([]),[ue,je]=y.useState(null),[Me,Ce]=y.useState(null),[A,ce]=y.useState(null),[z,be]=y.useState(null),[ye,N]=y.useState(null),[V,re]=y.useState(vl),[me,Ne]=y.useState(zh),[ve,De]=y.useState(!1),[yt,Xe]=y.useState(!1),$e=Xf("(max-width: 860px)"),[Ve,It]=y.useState(!1);y.useEffect(()=>{$e||It(!1)},[$e]);const[rt,dn]=y.useState(!1),[ft,hn]=y.useState([]),[Sn,xn]=y.useState(!1),[en,tt]=y.useState(vl),[et,tn]=y.useState(null),[Xt,nt]=y.useState(null),[St,$t]=y.useState([]),[cn,wt]=y.useState(null),[yn,qt]=y.useState(null),[pn,Dn]=y.useState([]),[Gt,ct]=y.useState([]),[Et,Pe]=y.useState([]),[wl,le]=y.useState([]),[ge,He]=y.useState(null),[B,P]=y.useState({}),[_e,Be]=y.useState(null),[Ot,fl]=y.useState({}),[On,dl]=y.useState(null),[sl,Bl]=y.useState([]),[ds,hl]=y.useState(!1),[al,pl]=y.useState(null),[Yt,Vt]=y.useState(null),[kl,kt]=y.useState(!1),[Qt,Oe]=y.useState(mN),[Ct,qn]=y.useState(null),[nn,Ln]=y.useState(null),[il,wn]=y.useState(!1),[Il,,rl]=X0(),ln=F0(),[Kt,on]=y.useState(!1),[Fe,ml]=y.useState(null),[Ms,Gn]=y.useState(null),[Zl,hs]=y.useState(null),[ps,mn]=y.useState(null),[Fl,Zn]=y.useState(null),[zn,kn]=y.useState(""),[Lt,Rs]=y.useState(null),[Di,Ds]=y.useState([]),[Yn,Nl]=y.useState(!1),[La,Nn]=y.useState(null),[sn,Jl]=y.useState(!1),[lt,Xn]=y.useState(!1),[pe,k]=y.useState({}),[Y,fe]=y.useState([""]),[we,Ae]=y.useState([]),[ze,dt]=y.useState(null),[w,se]=y.useState(null),[ke,Je]=y.useState(null),[ht,ms]=y.useState(null),[za,gr]=y.useState(null),[Ua,wc]=y.useState({}),[Os,Wl]=y.useState({}),[gs,bs]=y.useState(!1),[Ls,Oi]=y.useState(null),[sa,br]=y.useState(null),Li=y.useRef(0),aa=y.useRef(null),[ia,$n]=y.useState(!1),[Pl,zs]=y.useState([]),[zi,xr]=y.useState(null),[kc,Ha]=y.useState(null),Us=W0(),Ba=nv($e&&ia),Ia=y.useRef(new Map),ra=(Yt==null?void 0:Yt.terminalEnabled)===!0,yr=Mf()==="relay"&&((Jc=d==null?void 0:d.shell)==null?void 0:Jc.enabled)!==!0,Nc=y.useRef(!1),Tc=y.useCallback((p,I)=>(Ia.current.set(p,I),()=>{Ia.current.get(p)===I&&Ia.current.delete(p)}),[]),[ca,_r]=y.useState(!1),[$o,vr]=y.useState(null),[Vo,Ui]=y.useState(vl),[xs,jr]=y.useState(null),[Hi,oa]=y.useState({}),ua=y.useRef([]),[an,Ec]=y.useState(null);function Kf(p){Ec(I=>I===p?null:p)}y.useEffect(()=>{($e||an==="terminal"&&!ia||an==="files"&&!lt||an==="search"&&!gs||an==="git"&&!Kt||an==="ask"&&!ca||an==="main"&&we.length===0)&&Ec(null)},[an,$e,ia,lt,gs,Kt,ca,we.length]);const[Qo]=y.useState(dN),Ko=y.useRef(Qo),Sr=y.useRef(!1),Un=y.useRef(null),Bi=y.useRef(null),Ii=y.useRef(null),Zo=y.useRef(0),Tn=y.useRef(null),Fo=y.useRef(0);Un.current=z,Tn.current=A,Fo.current=V.lastSeq;const Jo=y.useRef(me);Jo.current=me;const ql=y.useRef(null),qa=y.useRef(0);qa.current=Vo.lastSeq;const wr=y.useRef(null),qi=y.useRef(""),Ga=y.useRef(null),Hs=y.useRef([]),Cc=y.useRef([""]);Hs.current=we,Cc.current=Y;const Ya=y.useRef(new Map),ys=y.useRef(new Set),Gi=y.useRef(null),Yi=y.useRef(null),Wo=y.useRef(0),Xa=y.useRef(new Set);y.useEffect(()=>{const p=R0();if(!p)return;s.current=p;const I=()=>{r(p.connected),o(p.statusText)};p.onStatus(I),p.onReconnect(()=>{I(),fl({});const Ut=Un.current;Ut&&p.send({type:"session.sync",sessionId:Ut,sinceSeq:Fo.current});const Zt=ql.current;Zt&&p.send({type:"session.sync",sessionId:Zt,sinceSeq:qa.current})});const de=p.on(Ut=>Po(Ut));p.connect();const Ge=window.setInterval(()=>{I(),p.connected&&p.send({type:"ping",nonce:Date.now()})},15e3);return()=>{de(),window.clearInterval(Ge),p.close()}},[]);const Po=y.useCallback(p=>{var I,de,Ge,Ut,Zt,Bn,si,Wc,_a;switch(p.type){case"hello.ok":r(!0);break;case"workspace.list":{S(p.workspaces),E(p.archived),ce(Ie=>{var Pn;if(Ie)return Ie;const gt=Ko.current,Ht=gt&&p.workspaces.find(zr=>zr.id===gt.workspaceId);return(Ht==null?void 0:Ht.id)??((Pn=p.workspaces[0])==null?void 0:Pn.id)??null});const xe=Ga.current;if(!xe)break;const Ee=p.workspaces.find(Ie=>jN(Ie.path,xe));if(!Ee)break;Ga.current=null,dn(!1),ce(Ee.id);break}case"workspace.candidates":if(p.query.trim()!==qi.current)break;hn(p.candidates),p.source==="host"&&xn(!1);break;case"finder.opened":wr.current=p.sessionId;break;case"workspace.roots":$t(p.roots);break;case"workspace.created":if(ce(p.workspace.id),p.warnings.length===0){dn(!1),nt(null);break}wt({path:p.workspace.path,warnings:p.warnings});break;case"session.list":if(p.workspaceId!==Tn.current)break;Z(p.sessions),D(p.archived);break;case"folder.list":C(p.workspaceFolders),X(p.sessionFolders),G(p.pinnedFolders??[]);break;case"session.pinned":ne(p.sessions);break;case"session.live":W(p.sessions);break;case"order.state":Ce(p.order);break;case"session.summary":if(p.session.id===wr.current){tn(p.session);break}if(p.session.parentSessionId){p.session.id===ql.current&&jr(p.session);break}if(W(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.session.id);if(p.session.state==="closed")return Ee===-1?xe:xe.filter(gt=>gt.id!==p.session.id);if(Ee===-1)return[...xe,p.session];const Ie=xe.slice();return Ie[Ee]=p.session,Ie}),Z(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.session.id);if(Ee===-1)return[p.session,...xe];const Ie=xe.slice();return Ie[Ee]=p.session,Ie}),ne(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.session.id);if(Ee===-1)return xe;const Ie=xe.slice();return Ie[Ee]={...p.session,pinned:!0,...xe[Ee].pinnedAt?{pinnedAt:xe[Ee].pinnedAt}:{}},Ie}),Un.current===null&&Ii.current&&Ii.current.workspaceId===p.session.workspaceId&&(iy(p.session.id,Ii.current.text),Ii.current=null),be(xe=>xe??p.session.id),((I=Bi.current)==null?void 0:I.sessionId)===p.session.id){const xe=Bi.current;p.session.state==="error"?Bi.current=null:p.session.state!=="closed"&&(Bi.current=null,(de=s.current)==null||de.send({type:"prompt.send",sessionId:xe.sessionId,text:xe.text,images:xe.images}))}break;case"usage.state":p.sessionId===Un.current&&(qn(p.usage),wn(!1));break;case"context.state":p.sessionId===Un.current&&(Ln(p.context),wn(!1));break;case"session.capabilities":p.sessionId===Un.current&&N(p.capabilities);break;case"session.events":if(p.sessionId===ql.current){Ui(xe=>Rf(xe,p.entries));break}if(p.sessionId===wr.current){tt(xe=>Rf(xe,p.entries));break}if(p.sessionId!==Un.current)break;for(const xe of p.entries){if(xe.event.kind!=="rewound")continue;const Ee=xe.event.toUserIndex,Ie=G0(Jo.current.entries,Ee),gt=Ie.reduce((Ht,Pn)=>Pn.event.kind==="user.message"?Ht+1:Ht,0);Ne(Ht=>({...Ht,entries:Ie})),re(Ht=>({...Ht,items:Y0(Ht.items,Ee,gt)}))}re(xe=>Rf(xe,p.entries));break;case"session.history":if(p.sessionId!==Un.current)break;Ne(xe=>B0(xe,p));break;case"side.opened":{if(p.parentSessionId!==Un.current)break;ql.current=p.sessionId,vr(p.sessionId);const xe=ua.current;ua.current=[];for(const Ee of xe)Ee(p.sessionId);break}case"side.closed":if(p.parentSessionId!==Un.current)break;ql.current=null,vr(null),Ui(vl),jr(null);break;case"git.state":if(p.workspaceId!==Tn.current)break;ml(p.state);break;case"git.commit":if(p.workspaceId!==Tn.current)break;Gn(p.detail);break;case"git.result":if(p.workspaceId!==Tn.current)break;mn({ok:p.ok,message:p.message,url:p.url}),p.ok&&(Gn(null),hs(null),Nl(!1),Jl(!1));break;case"git.busy":if(p.workspaceId!==Tn.current)break;kn(p.label);break;case"git.files":if(p.workspaceId!==Tn.current)break;Nn({files:p.files,truncated:p.truncated});break;case"github.status":Rs(p.status);break;case"github.owners":Ds(p.owners);break;case"fs.dir":if(p.workspaceId!==Tn.current)break;k(xe=>({...xe,[p.path]:p.entries}));break;case"fs.search":if(p.workspaceId!==Tn.current)break;if(p.scope!=="tree"){const xe=p.scope;Wl(Ee=>({...Ee,[xe]:{query:p.query,entries:p.entries}}));break}gr({query:p.query,entries:p.entries,truncated:p.truncated});break;case"fs.grep":if(p.workspaceId!==Tn.current)break;Oi({query:p.query,matches:p.matches,truncated:p.truncated});break;case"fs.file":{if(p.workspaceId!==Tn.current)break;const xe=ys.current.delete(p.file.path);Ae(Ie=>{const gt=Ie.findIndex(zr=>zr.path===p.file.path);if(gt===-1)return[...Ie,bx(p.file,++Wo.current)];const Ht=Ie[gt],Pn=Ie.slice();return Pn[gt]=Ht.saved===p.file.content&&!Ra(Ht)?{...Ht,mtime:p.file.mtime,size:p.file.size,stale:!1}:bx(p.file,++Wo.current),Pn}),xe&&dt(p.file.path);const Ee=aa.current;Ee&&Ee.path===p.file.path&&(aa.current=null,br({...Ee,token:++Li.current}));break}case"fs.media":{if(p.workspaceId!==Tn.current)break;Xa.current.delete(p.path),Ae(xe=>xe.map(Ee=>Ee.path===p.path?{...Ee,mediaBase64:p.base64,mediaError:void 0}:Ee));break}case"fs.mediaFailed":{if(p.workspaceId!==Tn.current)break;Xa.current.delete(p.path),Ae(xe=>xe.map(Ee=>Ee.path===p.path?{...Ee,mediaError:p.message}:Ee));break}case"fs.saved":{if(p.workspaceId!==Tn.current)break;const xe=Ya.current.get(p.path);Ya.current.delete(p.path);const Ee=xe!==void 0;Ae(gt=>gt.map(Ht=>Ht.path!==p.path?Ht:Ee?{...Ht,saved:xe,mtime:p.mtime,size:p.size,stale:!1}:{...Ht,stale:!0}));const Ie=Hs.current.find(gt=>gt.path===p.path);!Ee&&Ie&&!Ra(Ie)&&((Ge=s.current)==null||Ge.send({type:"fs.read",workspaceId:p.workspaceId,path:p.path})),(Ut=s.current)==null||Ut.send({type:"git.state",workspaceId:p.workspaceId});break}case"fs.result":{if(p.workspaceId!==Tn.current)break;if(se({ok:p.ok,message:p.message}),p.ok||Ya.current.delete(p.path),p.conflict&&Ae(Ee=>Ee.map(Ie=>Ie.path===p.path?{...Ie,stale:!0}:Ie)),Yi.current===p.path){const Ee=Yi.current;Yi.current=null,p.ok&&(ys.current.add(Ee),(Zt=s.current)==null||Zt.send({type:"fs.read",workspaceId:p.workspaceId,path:Ee}))}const xe=Gi.current;if(p.ok&&xe&&xe.to===p.path){Gi.current=null;const Ee=Ie=>Ie===xe.from?xe.to:Ie.startsWith(`${xe.from}/`)?xe.to+Ie.slice(xe.from.length):Ie;Ae(Ie=>Ie.map(gt=>({...gt,path:Ee(gt.path)}))),dt(Ie=>Ie===null?null:Ee(Ie)),fe(Ie=>Ie.map(Ee)),k(Ie=>{const gt={};for(const[Ht,Pn]of Object.entries(Ie))Ht===xe.from||Ht.startsWith(`${xe.from}/`)||(gt[Ht]=Pn);return gt})}p.ok&&((Bn=s.current)==null||Bn.send({type:"git.state",workspaceId:p.workspaceId}));break}case"term.list":if(p.workspaceId!==Tn.current)break;zs(p.terminals);break;case"term.opened":if(p.terminal.workspaceId!==Tn.current)break;Ha(null),zs(xe=>{const Ee=xe.findIndex(gt=>gt.id===p.terminal.id);if(Ee===-1)return[...xe,p.terminal];const Ie=xe.slice();return Ie[Ee]=p.terminal,Ie}),Nc.current&&(Nc.current=!1,xr(p.terminal.id));break;case"term.buffer":(si=Ia.current.get(p.id))==null||si({kind:"buffer",data:p.data});break;case"term.data":(Wc=Ia.current.get(p.id))==null||Wc({kind:"data",data:p.data});break;case"term.exit":zs(xe=>xe.map(Ee=>Ee.id===p.id?{...Ee,exitCode:p.exitCode}:Ee));break;case"term.closed":zs(xe=>xe.filter(Ee=>Ee.id!==p.id));break;case"mcp.list":p.sessionId===Un.current&&Dn(p.servers);break;case"plugin.list":if(p.sessionId!==Un.current)break;ct(p.plugins),Pe(p.marketplaces),le(p.catalog);break;case"operation.result":p.sessionId===Un.current&&He(p.result);break;case"auth.status":pl(p.status);break;case"relay.state":h(p.state);break;case"settings.state":Vt(p.settings);break;case"handoff.state":P(xe=>{if(!p.handoff){if(!(p.sessionId in xe))return xe;const Ee={...xe};return delete Ee[p.sessionId],Ee}return{...xe,[p.sessionId]:p.handoff}});break;case"handoff.written":fl(xe=>{if(!(p.sessionId in xe))return xe;const Ee={...xe};return delete Ee[p.sessionId],Ee}),p.handoff&&Un.current===p.sessionId?dl(p.handoff):p.handoff||console.warn("[handoff] хост не смог записать хэндофф",p.sessionId);break;case"limit.stopped":Zo.current+=1,Bl(xe=>[...xe,{id:Zo.current,limit:p.limit,utilization:p.utilization,stopped:p.stopped,handoffs:p.handoffs}]);break;case"auth.login":Oe(p.state),p.state.active&&hl(!0);break;case"session.closed":W(xe=>xe.filter(Ee=>Ee.id!==p.sessionId)),Z(xe=>xe.map(Ee=>Ee.id===p.sessionId?{...Ee,state:"closed"}:Ee));break;case"error":console.error("[host]",p.message,p.context??""),(p.context==="workspace.open"||p.context==="workspace.create")&&(Ga.current=null,nt(p.message)),(_a=p.context)!=null&&_a.startsWith("term.")&&Ha(p.message);break}},[]),ee=y.useCallback(p=>{var I;(I=s.current)==null||I.send(p)},[]);y.useEffect(()=>{A&&ee({type:"session.list",workspaceId:A})},[A,ee]),y.useEffect(()=>{l&&ee({type:"session.pins"})},[l,ee]),y.useEffect(()=>{l&&ee({type:"settings.get"})},[l,ee]),y.useEffect(()=>{if(l)return ee({type:"session.drafts",sessionIds:ry()}),z0(p=>ee({type:"session.drafts",sessionIds:p}))},[l,ee]),y.useEffect(()=>{if(Sr.current)return;const p=Ko.current;if(!p||!A)return;if(A!==p.workspaceId){Sr.current=!0;return}if(z){Sr.current=!0;return}if(O.length===0)return;const I=O.find(de=>hN(de,p));Sr.current=!0,I&&I.state!=="closed"&&Xi(I)},[O,A,z]),y.useEffect(()=>{!A||yr||!ra||ee({type:"term.list",workspaceId:A})},[A,yr,ra,ee]),y.useEffect(()=>{xr(p=>{var I;return p&&Pl.some(de=>de.id===p)?p:((I=Pl[0])==null?void 0:I.id)??null})},[Pl]),y.useEffect(()=>{rt&&ee({type:"workspace.roots"})},[rt,ee]);const es=y.useCallback(()=>{const p=Un.current;p&&(wn(!0),ee({type:"usage.get",sessionId:p}),ee({type:"context.get",sessionId:p}))},[ee]);y.useEffect(()=>{if(!il)return;const p=window.setTimeout(()=>wn(!1),fN);return()=>window.clearTimeout(p)},[il]);const Ac=y.useMemo(()=>{const p=Math.max((Ct==null?void 0:Ct.fetchedAt)??0,(nn==null?void 0:nn.fetchedAt)??0);return p>0?p:null},[Ct==null?void 0:Ct.fetchedAt,nn==null?void 0:nn.fetchedAt]);y.useEffect(()=>{if(Ln(null),!z)return;es();const p=()=>{document.hidden||es()},I=window.setInterval(p,uN),de=()=>{document.hidden||es()};return document.addEventListener("visibilitychange",de),()=>{window.clearInterval(I),document.removeEventListener("visibilitychange",de)}},[z,es]),y.useEffect(()=>{if(!z){Ne(zh);return}Ne({...zh,loading:!0}),ee({type:"session.history",sessionId:z})},[z,ee]);const kr=y.useCallback(()=>{!z||me.loading||!Db(me)||(Ne(p=>({...p,loading:!0})),ee({type:"session.history",sessionId:z,before:oy(me)}))},[z,me,ee]),eu=y.useMemo(()=>I0(me.entries),[me.entries]),$=y.useMemo(()=>O.find(p=>p.id===z)??null,[O,z]),fa=z?($==null?void 0:$.claudeSessionId)??z:null,da=fa?B[fa]??null:null;y.useEffect(()=>{fa&&ee({type:"handoff.get",sessionId:fa})},[fa,ee]),y.useEffect(()=>{_e&&!(_e.sessionId in B)&&Be(null)},[B,_e]);const Mc=y.useMemo(()=>{var de;if(!Ct)return null;const p=(((de=Ct.buckets)==null?void 0:de.length)??0)>0,I=($==null?void 0:$.provider)==="antigravity";return p===I?Ct:null},[Ct,$==null?void 0:$.provider]),Rc="Обновить лимиты и контекст",tu=Rc+(Ac?`
|
|
134
134
|
обновлено в ${new Date(Ac).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:"");y.useEffect(()=>{document.documentElement.dataset.provider=($==null?void 0:$.provider)??"claude"},[$==null?void 0:$.provider]),y.useEffect(()=>{($==null?void 0:$.provider)==="antigravity"&&_r(!1)},[$==null?void 0:$.provider]);const $a=_.find(p=>p.id===A)??v.find(p=>p.id===A)??null;y.useEffect(()=>{if(!A||!z)return;const p={workspaceId:A,sessionId:z,claudeSessionId:($==null?void 0:$.claudeSessionId)??null};try{localStorage.setItem(t_,JSON.stringify(p))}catch{}},[A,z,$==null?void 0:$.claudeSessionId]);function Zf(p){Ga.current=p,nt(null),ee({type:"workspace.open",path:p})}function Ff(p,I,de){nt(null),ee({type:"workspace.create",parent:p,name:I,init:de})}function Jf(p){if(qi.current=p,!p){hn([]),xn(!1);return}xn(!0),ee({type:"workspace.find",query:p})}function Wf(p){qi.current=p,tt(vl),ee({type:"workspace.find.agent",query:p})}function gl(){dn(!1),nt(null),wt(null),hn([]),tt(vl),tn(null),qi.current="",Ga.current=null}function ts(){const p=Un.current;p&&ql.current&&ee({type:"side.reset",sessionId:p}),ql.current=null,vr(null),Ui(vl),jr(null),oa({}),ua.current=[]}function nu(p){ee({type:"workspace.close",workspaceIds:p}),!(!A||!p.includes(A))&&(ts(),ce(null),be(null),Z([]),D([]),re(vl),N(null),Xe(!1))}function lu(p,I){ee({type:"session.archive",workspaceId:p,sessionIds:I}),z&&(I.includes(z)||$!=null&&$.claudeSessionId&&I.includes($.claudeSessionId))&&(ts(),be(null),re(vl),N(null),Xe(!1))}function su(p){ee({type:"workspace.restore",workspaceIds:p})}function au(p,I,de){ee({type:"folder.create",scope:p,name:I,workspaceId:de})}function Dc(p,I){ee({type:"folder.rename",folderId:p,name:I})}function Pf(p){ee({type:"folder.delete",folderId:p})}function Va(p,I,de,Ge){ee({type:"folder.assign",scope:p,itemId:I,folderId:de,workspaceId:Ge})}function Oc(p="claude"){A&&(ts(),be(null),N(null),re(vl),Xe(!1),ee({type:"session.start",workspaceId:A,provider:p}),De(!1))}function ha(p){ts(),Hn(),ce(p),be(null),re(vl),N(null),Xe(!1),ml(null),Gn(null),hs(null),mn(null),kn(""),Nl(!1),Nn(null),Jl(!1),zs([]),xr(null)}function Lc(p,I,de){ee({type:"session.pin",workspaceId:p,sessionIds:I,pinned:de})}function iu(p){return p.state==="running"||p.state==="waiting_permission"||p.state==="reconnecting"||p.backgroundWork}function _s(p){if(iu(p)){je(p);return}ee({type:"session.close",sessionId:p.id})}function Qa(p,I,de){Ce(Ge=>{const Ut=Ge??{workspaces:[],sessions:{},pinned:[],live:[]};if(p==="sessions"){if(!de)return Ge;const Zt={...Ut.sessions};return I&&I.length>0?Zt[de]=I:delete Zt[de],{...Ut,sessions:Zt}}return{...Ut,[p]:I??[]}}),ee({type:"order.set",scope:p,ids:I,...de?{workspaceId:de}:{}})}function zc(p){p.workspaceId!==A&&ha(p.workspaceId),Xi(p)}function Xi(p){if(De(!1),ts(),re(vl),N(null),Xe(!1),p.state==="closed"){be(null),ee({type:"session.start",workspaceId:p.workspaceId,resume:p.id});return}be(p.id),ee({type:"session.sync",sessionId:p.id,sinceSeq:0})}function pa(p,I){if(z){if(($==null?void 0:$.state)==="closed"){Bi.current={sessionId:$.id,text:p,images:I},Xi($);return}ee({type:"prompt.send",sessionId:z,text:p,images:I})}}function Uc(p){const I=he.find(de=>(de.claudeSessionId??de.id)===p.sessionId&&de.state!=="closed");Bc(p.workspaceId,p.sessionId,p.text),I&&ee({type:"session.close",sessionId:I.id})}function Hc(p){Bc(p.workspaceId,p.claudeSessionId??p.id,null)}function Bc(p,I,de){Ii.current=de===null?null:{workspaceId:p,text:de},p!==A?ha(p):(ts(),be(null),N(null),re(vl),Xe(!1)),ee({type:"session.start",workspaceId:p,provider:"claude",continuesFrom:I}),De(!1)}y.useEffect(()=>{On&&(dl(null),Uc(On))},[On]);function ru(p){Ot[p.id]||(fl(I=>({...I,[p.id]:!0})),ee({type:"session.handoff",sessionId:p.id}))}function ed(p){ee({type:"handoff.dismiss",sessionId:p})}function cu(p,I){ee({type:"session.rename",sessionId:p.id,title:I,workspaceId:p.workspaceId}),Z(de=>de.map(Ge=>Ge.id===p.id?{...Ge,title:I}:Ge))}function Ic(p){z&&(De(!1),He(null),qt(p),ee({type:"mcp.list",sessionId:z}),ee({type:"plugin.list",sessionId:z}))}const ou={mcpAction:(p,I)=>{z&&(ee({type:"mcp.action",sessionId:z,name:p,action:I}),qt(null))},mcpAdd:(p,I)=>{z&&ee({type:"mcp.add",sessionId:z,name:p,draft:I})},mcpRemove:p=>{z&&ee({type:"mcp.remove",sessionId:z,name:p})},pluginInstall:p=>{z&&ee({type:"plugin.install",sessionId:z,spec:p})},pluginUninstall:p=>{z&&ee({type:"plugin.uninstall",sessionId:z,id:p})},pluginToggle:(p,I)=>{z&&ee({type:"plugin.toggle",sessionId:z,id:p,enabled:I})},marketplaceAdd:p=>{z&&ee({type:"marketplace.add",sessionId:z,source:p})},marketplaceRemove:p=>{z&&ee({type:"marketplace.remove",sessionId:z,name:p})}};function Nr(){De(!1),hl(!0),ee({type:"auth.status"})}const bl={login:(p,I)=>ee({type:"auth.login",mode:p,switchAccount:I}),submitCode:p=>ee({type:"auth.code",code:p}),cancel:()=>ee({type:"auth.cancel"}),logout:()=>ee({type:"auth.logout"})};function Tr(){De(!1),kt(!0),ee({type:"settings.get"})}function Tl(p){Vt(I=>I&&{...I,...p}),ee({type:"settings.update",settings:p})}function Ka(p){z&&ee({type:"side.ask",sessionId:z,text:p})}function qc(){z&&(ee({type:"side.reset",sessionId:z}),ql.current=null,vr(null),Ui(vl),jr(null),oa({}),ua.current=[])}function Bs(p){const I=ql.current;if(I){p(I);return}const de=Un.current;de&&(ua.current.push(p),ee({type:"side.open",sessionId:de}))}function $i(){A&&ee({type:"git.state",workspaceId:A})}function Gc(p){A&&(hs(p),ee({type:"git.show",workspaceId:A,ref:p}))}function Is(p,I){mn(null),Zn({target:p,label:I})}function uu(){!A||!Fl||(ee({type:"git.checkout",workspaceId:A,target:Fl.target}),Zn(null))}function Er(){A&&(mn(null),ee({type:"git.push",workspaceId:A}))}function Za(p){A&&(mn(null),ee({type:"git.pull",workspaceId:A,merge:p}))}function td(){A&&(mn(null),Nn(null),Nl(!0),ee({type:"github.status"}),ee({type:"github.owners"}),ee({type:"git.files",workspaceId:A}))}function xl(p){A&&(mn(null),ee({type:"git.publish",workspaceId:A,...p}))}function Yc(p){A&&(mn(null),ee({type:"git.remote",workspaceId:A,url:p}))}function vs(){mn(null),Jl(!0)}function fu(p){ee({type:"github.token",token:p}),ee({type:"github.owners"})}function Cr(){ee({type:"github.status"}),ee({type:"github.owners"})}y.useEffect(()=>{if(!(!lt||!A))for(const p of Y)p in pe||ee({type:"fs.list",workspaceId:A,path:p})},[lt,Y,pe,A,ee]);function ma(p){fe(I=>I.includes(p)?I.filter(de=>de!==p):[...I,p])}function Xc(p){if(!p){gr(null);return}A&&ee({type:"fs.search",workspaceId:A,query:p})}function du(p){if(!p){Oi(null);return}A&&ee({type:"fs.grep",workspaceId:A,query:p})}const Ar=y.useCallback((p,I)=>{wc(Ut=>({...Ut,[p]:I}));const de=Tn.current;if(I===null||!de)return;const Ge=I.lastIndexOf("/");if(Ge!==-1){ee({type:"fs.list",workspaceId:de,path:I.slice(0,Ge)});return}if(I===""){ee({type:"fs.list",workspaceId:de,path:""});return}ee({type:"fs.search",workspaceId:de,query:I,scope:p})},[ee]),hu=y.useMemo(()=>Fx(Ua.mention??null,Os.mention??null,pe),[Ua.mention,Os.mention,pe]),El=y.useMemo(()=>Fx(Ua.side??null,Os.side??null,pe),[Ua.side,Os.side,pe]);function Fa(p){Wa(p.path,{line:p.line,column:p.column})}function Ja(p){const I=[];let de=fr(p.path);for(;I.push(de),!!de;)de=fr(de);fe(Ge=>{const Ut=new Set(Ge);for(const Zt of I)Ut.add(Zt);return p.kind==="dir"&&Ut.add(p.path),[...Ut]}),p.kind==="file"&&Wa(p.path)}function Wa(p,I){if(Hs.current.find(Ge=>Ge.path===p)){dt(p),I&&br({path:p,...I,token:++Li.current});return}A&&(I&&(aa.current={path:p,...I}),ys.current.add(p),ee({type:"fs.read",workspaceId:A,path:p}))}function ga(p,I=!1){const de=Hs.current,Ge=de.find(Bn=>Bn.path===p);if(Ge&&Ra(Ge)&&!I){ms(p);return}ms(null);const Ut=de.findIndex(Bn=>Bn.path===p),Zt=de.filter(Bn=>Bn.path!==p);Ae(Zt),dt(Bn=>{var si;return Bn===p?((si=Zt[Math.min(Ut,Zt.length-1)])==null?void 0:si.path)??null:Bn})}function Fn(p,I=!1){const de=Hs.current.find(Ge=>Ge.path===p);!de||!A||!I&&!Ra(de)||(Ya.current.set(p,de.text),ee({type:"fs.write",workspaceId:A,path:p,content:de.text,eol:de.eol,encoding:de.encoding,baseMtime:de.mtime,...I?{force:!0}:{}}))}function Cl(p){A&&ee({type:"fs.read",workspaceId:A,path:p})}function qs(p){A&&(Xa.current.has(p)||(Xa.current.add(p),ee({type:"fs.readMedia",workspaceId:A,path:p})))}const ns=y.useRef(new Map);function ls(p){const I=ns.current,de=I.get(p);de&&clearTimeout(de);const Ge=(Yt==null?void 0:Yt.autoSaveAfterPauseMs)??0;Ge<=0||I.set(p,setTimeout(()=>{I.delete(p);const Ut=Hs.current.find(Zt=>Zt.path===p);Ut&&Ra(Ut)&&!Ut.stale&&Fn(p)},Ge))}function js(p,I,de){if(!A)return;const Ge=p?`${p}/${de}`:de;se(null),I==="file"&&(Yi.current=Ge),ee({type:"fs.create",workspaceId:A,path:Ge,kind:I})}function pu(p,I){if(!A)return;const de=fr(p),Ge=de?`${de}/${I}`:I;se(null),Gi.current={from:p,to:Ge},ee({type:"fs.rename",workspaceId:A,path:p,to:Ge})}function $c(p,I){if(!A)return;const de=p.slice(p.lastIndexOf("/")+1),Ge=I?`${I}/${de}`:de;Ge!==p&&(se(null),Gi.current={from:p,to:Ge},ee({type:"fs.rename",workspaceId:A,path:p,to:Ge}))}function Vc(p,I){A&&(se(null),ee({type:"fs.copy",workspaceId:A,path:p,toDir:I}))}function mu(p){A&&(se(null),Je(null),ee({type:"fs.delete",workspaceId:A,path:p.path}),Ae(I=>I.filter(de=>de.path!==p.path&&!de.path.startsWith(`${p.path}/`))),dt(I=>I&&(I===p.path||I.startsWith(`${p.path}/`))?null:I))}function Hn(){k({}),fe([""]),Ae([]),dt(null),se(null),gr(null),Oi(null),wc({}),Wl({}),br(null),ys.current.clear(),Ya.current.clear(),Xa.current.clear(),aa.current=null,Gi.current=null,Yi.current=null}function zt(){!A||yr||!ra||(Ha(null),Nc.current=!0,ee({type:"term.open",workspaceId:A,cols:80,rows:24}))}function st(p){ee({type:"term.close",id:p})}function Gs(p,I){z&&ee({type:"permission.respond",sessionId:z,requestId:p,decision:I})}function Al(p,I){z&&ee({type:"permission.respond",sessionId:z,requestId:p,decision:"allow",answers:I})}function Qc(p){z&&ee({type:"permission.respond",sessionId:z,requestId:p,decision:"deny",reason:"Пользователь не стал отвечать на вопросы"})}function Ys(p,I){z&&ee({type:"permission.respond",sessionId:z,requestId:p,decision:"allow",plan:I})}function gu(p){z&&ee({type:"permission.respond",sessionId:z,requestId:p,decision:"deny",reason:"Пользователь просит продолжить планирование"})}y.useEffect(()=>{function p(I){if(I.key!=="Escape")return;if(an!==null){const Ge=I.target;if(!(Ge instanceof HTMLElement&&Ge.closest(".termview, .editor, .sidepane"))){Ec(null);return}}if(!z||V.pending.length>0)return;const de=I.target;de instanceof HTMLElement&&de.closest(".sidepane, .editor")||ee({type:"control.interrupt",sessionId:z})}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[z,V.pending.length,ee,an]),y.useEffect(()=>{function p(I){I.key!=="`"||!(I.ctrlKey||I.metaKey)||ra&&(I.preventDefault(),$n(de=>!de))}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[ra]);const Kc=y.useMemo(()=>{const p=(ye==null?void 0:ye.commands)??[];return p.length===0||($==null?void 0:$.provider)==="antigravity"?p:[...p,{name:"plugins",description:"Плагины и маркетплейсы — окно приложения",argumentHint:"",aliases:["plugin"]},...Zx]},[ye,$==null?void 0:$.provider]);function ba(p){const I=pN[p];return I&&($==null?void 0:$.provider)!=="antigravity"?(Ic(I),!0):($==null?void 0:$.provider)==="antigravity"||!Zx.some(de=>de.name===p)?!1:(Nr(),p==="logout"&&bl.logout(),p==="switch-account"&&bl.login("claudeai",!0),!0)}const ss=($==null?void 0:$.state)==="waiting_permission",yl=($==null?void 0:$.state)==="reconnecting",Jn=($==null?void 0:$.state)==="running"||yl||ss,Wn=V.pending[0]??null,Xs=Wn?_w(Wn.toolName,Wn.input):null;y.useEffect(()=>{!Kt&&!lt||!A||Jn||ee({type:"git.state",workspaceId:A})},[Kt,lt,A,Jn,ee]),y.useEffect(()=>{if(!(Jn||!A)){lt&&k(p=>{const I={};for(const[de,Ge]of Object.entries(p))Cc.current.includes(de)||(I[de]=Ge);return I});for(const p of Hs.current)Ra(p)||ee({type:"fs.read",workspaceId:A,path:p.path})}},[Jn,A,lt,ee]);const Gl=($==null?void 0:$.cwd)??(ye==null?void 0:ye.cwd)??null,Ss=(ye==null?void 0:ye.models)??[],Ml=($==null?void 0:$.model)??(ye==null?void 0:ye.model)??null,{rows:Mr,selected:Zc}=Wx(Ss,Ml),as=xs?{model:xs.model,effort:xs.effort,ultracode:xs.ultracode,thinking:xs.thinking,switchOnFlag:xs.switchModelsOnFlag}:{model:Hi.model??Ml,effort:Hi.effort??($==null?void 0:$.effort)??null,ultracode:Hi.ultracode??($==null?void 0:$.ultracode)??!1,thinking:Hi.thinking??($==null?void 0:$.thinking)??!0,switchOnFlag:Hi.switchOnFlag??($==null?void 0:$.switchModelsOnFlag)??!0},Vi=Wx(Ss,as.model),xa=(xs==null?void 0:xs.state)==="running",_n=ze?we.find(p=>p.path===ze)??null:null,Rr=new Set(we.filter(Ra).map(p=>p.path)),Pa=p=>i.jsx(Fk,{pane:p,width:ln.widths[p],onResize:I=>ln.setWidth(p,I),onReset:()=>ln.reset(p)}),ei=p=>$e?null:()=>Kf(p),nd=($==null?void 0:$.provider)==="antigravity"?V0:uy,bu=ye&&i.jsx(Cs,{title:"Режим прав",value:($==null?void 0:$.permissionMode)??"default",options:nd.map(p=>({value:p.value,label:p.value,hint:p.hint})),onChange:p=>{z&&ee({type:"control.set_mode",sessionId:z,mode:p})}}),un=Mr.length>0?i.jsx(Zy,{models:Mr,value:Zc,effort:($==null?void 0:$.effort)??null,ultracode:($==null?void 0:$.ultracode)??!1,thinking:($==null?void 0:$.thinking)??!0,switchOnFlag:($==null?void 0:$.switchModelsOnFlag)??!0,showSwitchOnFlag:($==null?void 0:$.provider)!=="antigravity",onModel:p=>{!z||!p||ee({type:"control.set_model",sessionId:z,model:p})},onEffort:p=>{z&&ee({type:"control.set_effort",sessionId:z,effort:p})},onUltracode:p=>{z&&ee({type:"control.set_ultracode",sessionId:z,enabled:p})},onThinking:p=>{z&&ee({type:"control.set_thinking",sessionId:z,enabled:p})},onSwitchOnFlag:p=>{z&&ee({type:"control.set_flag_switch",sessionId:z,enabled:p})}}):Ml&&i.jsx("span",{className:"badge",children:Ml}),Fc=Jn&&i.jsx("span",{className:ss?"badge badge--wait":"badge badge--live",children:ss?"ждёт":yl?"переподключается":"работает"}),Qi=($==null?void 0:$.state)==="closed"&&i.jsx("span",{className:"badge",title:"Разговор сохранён — сессия поднимется заново, как только вы отправите сообщение",children:"остановлена"}),ti=Fc||Qi,Dr=()=>{z&&ee({type:"session.reconnect",sessionId:z})},ni=yl?"Сессия уже поднимает новый процесс":Jn?"Недоступно, пока идёт ход":"Поднять сессии новый процесс — разговор сохранён",li=z&&(yl||($==null?void 0:$.state)==="error")?i.jsxs("div",{className:yl?"relink":"relink relink--error",role:"status",children:[i.jsxs("span",{className:"relink__msg",children:[i.jsx("span",{className:"relink__dot","aria-hidden":"true"}),yl?"Связь оборвалась. Сессия поднимает новый процесс — разговор сохранён.":"Переподключиться не удалось. Разговор сохранён — сессия продолжит с этого места."]}),i.jsx("button",{className:"btn btn--sm",title:yl?"Не ждать паузы между попытками — попробовать сейчас":"Поднять сессии новый процесс и продолжить разговор",onClick:Dr,children:yl?"Переподключить сейчас":"Переподключить"})]}):null,ld=da?i.jsx(Yk,{handoff:da,onContinue:()=>Uc(da),onShow:()=>Be(da),onDismiss:()=>ed(da.sessionId)}):null,Or=$&&$.totalCostUsd>0?`$${$.totalCostUsd.toFixed(3)}`:null,xu=($==null?void 0:$.provider)!=="antigravity"&&i.jsx("button",{className:ca?"pane-btn is-on":"pane-btn",title:"Вопрос на полях — спросить, не мешая работе","aria-label":"Вопрос на полях","aria-pressed":ca,onClick:()=>_r(p=>!p),children:i.jsx(wN,{})}),yu=$&&$.state!=="closed"&&i.jsx("button",{type:"button",className:"pane-btn pane-btn--stop",title:"Остановить сессию — освобождает память хоста, разговор остаётся на диске","aria-label":"Остановить сессию",onClick:()=>_s($),children:i.jsx(_N,{})}),Rl=$?Ot[$.id]===!0:!1,Ki=py({onLongPress:()=>{$&&Hc($)},onClick:()=>{$&&ru($)},disabled:Rl}),Lr=$&&$.state!=="closed"&&$.provider!=="antigravity"&&i.jsxs("button",{type:"button",className:Rl?"pane-btn pane-btn--handoff is-busy":Ki.holding?"pane-btn pane-btn--handoff is-holding":"pane-btn pane-btn--handoff",style:{"--hold-ms":`${Ki.thresholdMs}ms`},title:Rl?"Пишется хэндофф…":"Клик — хэндофф и новая сессия: агент запишет сводку, сессия остановится, работа продолжится в новой. Зажать (или Shift+клик) — новая пустая сессия без хэндоффа: закрепление переходит, старая сессия продолжает работать.","aria-label":"Хэндофф и новая сессия","aria-busy":Rl,disabled:Rl,...Ki.handlers,children:[i.jsx("span",{className:"pane-btn__hold","aria-hidden":"true"}),i.jsx(vN,{})]});return i.jsxs("div",{className:"app",style:ln.style,children:[i.jsx(Zj,{open:ve,connected:l,status:c,workspaces:_,archivedWorkspaces:v,workspaceFolders:T,sessionFolders:L.filter(p=>p.workspaceId===A),pinnedFolders:J,sessions:O.filter(p=>p.workspaceId===A),archived:M.filter(p=>p.workspaceId===A),pinned:H,live:he,listOrder:Me,liveSessionsFirst:(Yt==null?void 0:Yt.liveSessionsFirst)===!0,onReorder:Qa,activeWorkspaceId:A,activeSessionId:z,onPinSessions:Lc,onSelectPinned:zc,onCloseWorkspaces:nu,onRestoreWorkspaces:su,onArchiveSessions:lu,onUnarchiveSessions:p=>{A&&ee({type:"session.unarchive",workspaceId:A,sessionIds:p})},onCreateFolder:au,onRenameFolder:Dc,onDeleteFolder:Pf,onAssignToFolder:Va,onSelectWorkspace:ha,onSelectSession:Xi,onRenameSession:cu,onStopSession:_s,onOpenWorkspace:()=>dn(!0),onNewSession:Oc,onOpenExtensions:z&&($==null?void 0:$.provider)!=="antigravity"?()=>Ic("mcp"):null,account:al,onOpenAccount:Nr,relay:d,onOpenRelay:b?null:()=>g(!0),onOpenSettings:Tr,themeMode:Il,onCycleTheme:rl}),Pa("sidebar"),ve&&i.jsx("div",{className:"scrim",onClick:()=>De(!1)}),i.jsx(rj,{open:lt,tree:pe,expanded:new Set(Y),activePath:ze,dirty:Rr,gitChanges:(Fe==null?void 0:Fe.changed)??[],result:w,searchResult:za,onSearch:Xc,onReveal:Ja,onToggle:ma,onOpen:Wa,onCreate:js,onRename:pu,onMove:$c,onCopy:Vc,onDelete:Je,onRefresh:()=>{se(null),k({}),$i()},onClose:()=>Xn(!1),zoomed:an==="files",onToggleZoom:ei("files")}),lt&&an!=="files"&&Pa("files"),i.jsx(bj,{open:gs,result:Ls,onSearch:du,onOpenMatch:Fa,onClose:()=>bs(!1),zoomed:an==="search",onToggleZoom:ei("search")}),gs&&an!=="search"&&Pa("search"),i.jsx(Lw,{open:Kt,state:Fe,result:ps,selected:Zl,busy:zn,onRefresh:$i,onShow:Gc,onCheckout:Is,onPush:Er,onPull:Za,onPublish:td,onConnectRemote:vs,onDismissResult:()=>mn(null),onClose:()=>on(!1),zoomed:an==="git",onToggleZoom:ei("git")}),Kt&&an!=="git"&&Pa("git"),i.jsxs("main",{className:an==="main"||an==="terminal"?"main main--zoomed":"main",children:[i.jsxs("header",{className:"topbar",children:[i.jsx("button",{className:"btn btn--ghost menu-btn",onClick:()=>De(!0),children:"☰"}),i.jsx("button",{className:lt?"pane-btn is-on":"pane-btn",title:"Файлы проекта","aria-label":"Файлы проекта","aria-pressed":lt,onClick:()=>{Xn(p=>!p),on(!1),bs(!1)},children:i.jsx(bN,{})}),i.jsx("button",{className:gs?"pane-btn is-on":"pane-btn",title:"Поиск по тексту в проекте","aria-label":"Поиск по тексту в проекте","aria-pressed":gs,onClick:()=>{bs(p=>!p),Xn(!1),on(!1)},children:i.jsx(xN,{})}),i.jsx("button",{className:Kt?"pane-btn is-on":"pane-btn",title:"История git","aria-label":"История git","aria-pressed":Kt,onClick:()=>{on(p=>!p),Xn(!1),bs(!1)},children:i.jsx(yN,{})}),ra&&i.jsx("button",{className:ia?"pane-btn is-on":"pane-btn",title:"Терминал (Ctrl+`)","aria-label":"Терминал","aria-pressed":ia,onClick:()=>$n(p=>!p),children:i.jsx(SN,{})}),$e&&xu,$e&&i.jsx("button",{className:Ve?"pane-btn is-on":"pane-btn",title:"Ещё","aria-label":"Ещё","aria-haspopup":"menu","aria-pressed":Ve,onClick:()=>It(!0),children:i.jsx(kN,{})}),i.jsxs("div",{className:"topbar__id",children:[yt&&$?i.jsx(na,{className:"rename--title",value:$.title??"",onCommit:p=>{cu($,p),Xe(!1)},onCancel:()=>Xe(!1)}):i.jsxs("div",{className:"topbar__head",children:[i.jsx("button",{className:"topbar__title",disabled:!$||$e,title:$&&!$e?"Переименовать сессию":void 0,onClick:()=>Xe(!0),children:($==null?void 0:$.title)??"Claude Code Visual"}),$a&&i.jsx("span",{className:"topbar__project",title:$a.path,children:$a.name})]}),$e?ti:Gl&&i.jsx(Ky,{path:Gl})]}),!$e&&i.jsxs("div",{className:"topbar__tools",children:[i.jsx("button",{type:"button",className:il?"meters-refresh is-busy":"meters-refresh",title:tu,"aria-label":Rc,"aria-busy":il,disabled:!z||il,onClick:es,children:i.jsx(NN,{})}),i.jsx(Jy,{usage:Mc}),i.jsx(e_,{}),bu,un,ti,Or&&i.jsx("span",{className:"badge badge--cost",children:Or}),Lr,yu,xu]})]}),i.jsx(cN,{tokens:(nn==null?void 0:nn.tokens)??V.contextTokens,maxTokens:(nn==null?void 0:nn.maxTokens)??null,fetchedAt:(nn==null?void 0:nn.fetchedAt)??null}),$e&&Ve&&i.jsx(dk,{onClose:()=>It(!1),permission:bu,model:un,usage:Mc,cwd:Gl,costLabel:Or,onRefresh:es,refreshing:il,metersFetchedAt:Ac,onRename:$?()=>{Xe(!0),It(!1)}:null,onHandoff:$&&$.state!=="closed"&&$.provider!=="antigravity"?()=>{ru($),It(!1)}:null,onFreshSession:$&&$.state!=="closed"&&$.provider!=="antigravity"?()=>{Hc($),It(!1)}:null,handoffWriting:Rl,onStop:$&&$.state!=="closed"?()=>{_s($),It(!1)}:null}),we.length>0&&i.jsx(zj,{files:we,activePath:ze,busy:Jn,onSelect:dt,onClose:p=>ga(p),zoomed:an==="main",onToggleZoom:ei("main")}),_n?i.jsx(Oj,{file:_n,goto:(sa==null?void 0:sa.path)===_n.path?sa:null,onChange:(p,I)=>{Ae(de=>de.map(Ge=>Ge.path===p?{...Ge,text:I}:Ge)),ls(p)},onSave:p=>Fn(p),onReload:Cl,onOverwrite:p=>Fn(p,!0),onRequestMedia:qs,onTogglePreview:p=>Ae(I=>I.map(de=>de.path===p?{...de,previewMode:!de.previewMode}:de))}):i.jsxs(i.Fragment,{children:[i.jsx(Op,{items:V.items,busy:Jn&&!yl,waiting:ss,empty:($==null?void 0:$.provider)==="antigravity"?"Сессия пуста. Опишите задачу — Antigravity работает в каталоге проекта.":void 0,history:eu,historyHasMore:Db(me),historyLoading:me.loading,onLoadHistory:kr,sessionId:z??void 0,onEditMessage:($==null?void 0:$.provider)==="antigravity"?void 0:(p,I,de)=>{z&&ee({type:"prompt.edit",sessionId:z,userIndex:p,text:I,images:de})}}),li,ld,z&&((ya=$==null?void 0:$.tasks)!=null&&ya.length)?i.jsx(qj,{tasks:$.tasks,onStop:p=>ee({type:"task.stop",sessionId:z,taskId:p})}):null,i.jsx(Vy,{disabled:!z,busy:Jn&&!yl,placeholder:yl?"Промпт уйдёт, как только связь вернётся":($==null?void 0:$.state)==="closed"?"Остановлена — отправьте сообщение, чтобы продолжить":void 0,commands:Kc,sessionTitle:($==null?void 0:$.title)??null,contextResult:hu,draftKey:z,onContextSearch:p=>Ar("mention",p),onCommand:ba,onSend:pa,onInterrupt:()=>{z&&ee({type:"control.interrupt",sessionId:z})}})]}),ia&&ra&&i.jsxs(i.Fragment,{children:[!$e&&an!=="terminal"&&i.jsx(Wk,{height:Us.height,onResize:Us.setHeight,onReset:Us.reset}),i.jsx(nN,{mobile:$e,zoomed:an==="terminal",onToggleZoom:ei("terminal"),terminals:Pl,activeId:zi,blocked:yr,error:kc,onDismissError:()=>Ha(null),height:$e?Ba.height:Us.height,offset:$e?{top:Ba.offsetTop,left:Ba.offsetLeft}:void 0,onSelect:xr,onOpen:zt,onClose:st,onInput:(p,I)=>ee({type:"term.input",id:p,data:I}),onResize:(p,I,de)=>ee({type:"term.resize",id:p,cols:I,rows:de}),onAttach:p=>ee({type:"term.attach",id:p}),onHide:()=>$n(!1),registerSink:Tc})]})]}),i.jsx(nk,{open:ca,items:Vo.items,busy:xa,ready:z!==null,commands:Kc,contextResult:El,draftKey:z,models:Vi.rows,model:Vi.selected,effort:as.effort,ultracode:as.ultracode,thinking:as.thinking,switchOnFlag:as.switchOnFlag,onContextSearch:p=>Ar("side",p),onCommand:ba,onModel:p=>{p&&(oa(I=>({...I,model:p})),Bs(I=>ee({type:"control.set_model",sessionId:I,model:p})))},onEffort:p=>{oa(I=>({...I,effort:p,ultracode:!1})),Bs(I=>ee({type:"control.set_effort",sessionId:I,effort:p}))},onUltracode:p=>{oa(I=>({...I,ultracode:p,...p?{effort:"xhigh"}:{}})),Bs(I=>ee({type:"control.set_ultracode",sessionId:I,enabled:p}))},onThinking:p=>{oa(I=>({...I,thinking:p})),Bs(I=>ee({type:"control.set_thinking",sessionId:I,enabled:p}))},onSwitchOnFlag:p=>{oa(I=>({...I,switchOnFlag:p})),Bs(I=>ee({type:"control.set_flag_switch",sessionId:I,enabled:p}))},onAsk:Ka,onInterrupt:()=>{$o&&ee({type:"control.interrupt",sessionId:$o})},onReset:qc,onClose:()=>_r(!1),zoomed:an==="ask",onToggleZoom:ei("ask")}),ca&&an!=="ask"&&Pa("ask"),(Kt||ca||lt||gs)&&i.jsx("div",{className:"scrim scrim--pane",onClick:()=>{on(!1),_r(!1),Xn(!1),bs(!1)}}),Ms&&i.jsx(Hw,{detail:Ms,local:((Fe==null?void 0:Fe.hasRemote)??!1)&&(Fe==null?void 0:Fe.commits.some(p=>p.hash===Ms.hash&&!p.pushed))===!0,onCheckout:Is,onClose:()=>{Gn(null),hs(null)}}),ue&&i.jsx(Sl,{title:"Остановить сессию?",onClose:()=>je(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>je(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:()=>{ee({type:"session.close",sessionId:ue.id}),je(null)},children:"Остановить"})]}),children:i.jsx("p",{className:"modal__text",children:"Сессия сейчас работает — остановка прервёт текущий ход. Разговор останется на диске: открыть сессию заново или просто написать в неё снова можно в любой момент."})}),Fl&&i.jsxs(Sl,{title:"Переключить рабочее дерево?",onClose:()=>Zn(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>Zn(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:uu,children:"Переключиться"})]}),children:[i.jsxs("p",{className:"modal__text",children:["git переключится на ",Fl.label,". Файлы в каталоге проекта изменятся — это тот же каталог, в котором работает агент."]}),Jn&&i.jsx("p",{className:"modal__text",children:"Сейчас идёт ход агента: он читает и правит файлы прямо сейчас."}),Fe&&Fe.changed.length>0&&i.jsxs("p",{className:"modal__text",children:["Незакоммиченных изменений: ",Fe.changed.length,". Git откажется переключаться, если они будут затёрты."]})]}),Yn&&i.jsx(Fw,{status:Lt,owners:Di,files:La,defaultName:($a==null?void 0:$a.name)??"",hasCommits:Fe===null||Fe.head!=="",busy:zn,result:ps,onRefreshStatus:Cr,onSaveToken:fu,onPublish:xl,onDismissResult:()=>mn(null),onClose:()=>Nl(!1)}),sn&&i.jsx(tk,{busy:zn,result:ps,onSubmit:Yc,onDismissResult:()=>mn(null),onClose:()=>Jl(!1)}),ke&&i.jsx(Sl,{title:ke.kind==="dir"?"Удалить каталог?":"Удалить файл?",onClose:()=>Je(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>Je(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:()=>mu(ke),children:"Удалить"})]}),children:i.jsxs("p",{className:"modal__text",children:[ke.path," будет удалён с диска",ke.kind==="dir"?" вместе со всем содержимым":"",". Корзины здесь нет: это тот же каталог, в котором работает агент."]})}),ht&&i.jsx(Sl,{title:"Закрыть без сохранения?",onClose:()=>ms(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>ms(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:()=>ga(ht,!0),children:"Закрыть"}),i.jsx("button",{className:"btn btn--primary",onClick:()=>{Fn(ht),ga(ht,!0)},children:"Сохранить и закрыть"})]}),children:i.jsxs("p",{className:"modal__text",children:["В ",ht," есть несохранённые правки."]})}),yn&&i.jsx(pk,{tab:yn,servers:pn,plugins:Gt,marketplaces:Et,catalog:wl,result:ge,actions:ou,onTab:qt,onClose:()=>qt(null)}),ds&&i.jsx(jk,{status:al,login:Qt,actions:bl,remote:b,runningSessions:O.filter(p=>p.state==="running"||p.state==="waiting_permission").length,onReconnect:z?()=>{Dr(),hl(!1)}:null,reconnectBlocked:Jn,reconnectHint:ni,onClose:()=>hl(!1)}),m&&i.jsx(Tk,{state:d,onPair:(p,I)=>ee({type:"relay.pair",code:p,...I?{name:I}:{}}),onUnpair:()=>ee({type:"relay.unpair"}),onClose:()=>g(!1)}),kl&&i.jsx(Ik,{settings:Yt,models:(ye==null?void 0:ye.models)??[],relayState:d,local:Mf()==="local",onChange:Tl,onEnableShell:()=>ee({type:"relay.shell.enable"}),onDisableShell:()=>ee({type:"relay.shell.disable"}),onOpenRelay:()=>{kt(!1),g(!0)},onClose:()=>kt(!1)}),rt&&i.jsx(ww,{candidates:ft,searching:Sn,agentItems:en.items,agentBusy:(et==null?void 0:et.state)==="running",error:Xt,roots:St,created:cn,onSearch:Jf,onAskAgent:Wf,onInterrupt:()=>{const p=wr.current;p&&ee({type:"control.interrupt",sessionId:p})},onSubmit:Zf,onCreate:Ff,onClose:gl}),Wn!=null&&Wn.questions&&Wn.questions.length>0?i.jsx(pw,{request:{...Wn,questions:Wn.questions},queued:V.pending.length-1,onAnswer:Al,onDecline:Qc}):Wn&&Xs!==null?i.jsx(bw,{request:Wn,plan:Xs,queued:V.pending.length-1,onAccept:Ys,onDecline:gu}):Wn&&i.jsx(hw,{request:Wn,queued:V.pending.length-1,onDecide:Gs}),_e&&i.jsx(Xk,{handoff:_e,onClose:()=>Be(null)}),i.jsx(Qk,{notices:sl,onDismiss:p=>Bl(I=>I.filter(de=>de.id!==p))})]})}function bN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M2 4.1V3a.6.6 0 0 1 .6-.6h2.6l1.2 1.4h5a.6.6 0 0 1 .6.6v1.1"}),i.jsx("path",{d:"M2 12.6V5.7h11.4a.6.6 0 0 1 .58.75l-1.5 6.2a.6.6 0 0 1-.58.45H2.6a.6.6 0 0 1-.6-.5Z"})]})}function xN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:[i.jsx("circle",{cx:"7",cy:"7",r:"4.3"}),i.jsx("path",{d:"M13.2 13.2 10.1 10.1",strokeLinecap:"round"})]})}function yN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"4.5",cy:"3.5",r:"1.9"}),i.jsx("circle",{cx:"4.5",cy:"12.5",r:"1.9"}),i.jsx("circle",{cx:"11.5",cy:"8",r:"1.9"}),i.jsx("path",{d:"M4.5 5.4v5.2M6.4 3.9h2.2a1.6 1.6 0 0 1 1.6 1.6v.8"})]})}function _N(){return i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,"aria-hidden":"true",children:i.jsx("rect",{x:"3.6",y:"3.6",width:"8.8",height:"8.8",rx:"1.8"})})}function vN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"1.4",y:"4.6",width:"6",height:"6.8",rx:"1.3"}),i.jsx("rect",{x:"8.6",y:"4.6",width:"6",height:"6.8",rx:"1.3"}),i.jsx("path",{d:"M6.9 8h2.6M8 6.5 9.6 8 8 9.5"})]})}function jN(s,l){return Px(s)===Px(l)}function Px(s){return s.replace(/[\\/]+/g,"/").replace(/\/+$/,"").toLowerCase()}function SN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"1.6",y:"2.6",width:"12.8",height:"10.8",rx:"1.7"}),i.jsx("path",{d:"M4.3 6 6.6 8l-2.3 2"}),i.jsx("path",{d:"M8.2 10h3.1"})]})}function wN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M13.6 9.4a1.6 1.6 0 0 1-1.6 1.6H6.2L3.2 13.4V4.2a1.6 1.6 0 0 1 1.6-1.6h7.2a1.6 1.6 0 0 1 1.6 1.6Z"}),i.jsx("path",{d:"M8.4 8.5v-.3c0-.7.9-.9.9-1.7a1 1 0 0 0-1.9-.4"})]})}function kN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"3.2",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"12.8",cy:"8",r:"1.5"})]})}function NN(){return i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M14 8a6 6 0 1 1-6-6c1.68 0 3.29.67 4.49 1.83L14 5.33"}),i.jsx("path",{d:"M14 2v3.33h-3.33"})]})}const n_=document.getElementById("root");if(!n_)throw new Error("#root not found");k0.createRoot(n_).render(i.jsx(y.StrictMode,{children:i.jsx(gN,{})}));export{k1 as D,Jt as I,Pt as N,CN as P,us as T,As as a,Ey as b,Hl as c,EN as d,Dy as e,qo as f,X1 as h,AN as p,MN as s,Te as t};
|