@i14ks/ccv 0.12.0 → 0.12.1
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-Byu5BOry.js → codemirror-D11GWMsB.js} +1 -1
- package/web/assets/{index-BiJkY5lu.js → index-09MC_4AF.js} +1 -1
- package/web/assets/{index-DJN6swZl.js → index-4S0cl_O2.js} +1 -1
- package/web/assets/{index-DO6gKWcT.js → index-9Toz507b.js} +4 -4
- package/web/assets/{index-BednlsnR.js → index-BDuAzkOQ.js} +1 -1
- package/web/assets/{index-BhTNEiv0.js → index-BIhkivIg.js} +1 -1
- package/web/assets/{index-CQlHFJzv.js → index-BSEf83Uc.js} +1 -1
- package/web/assets/{index-DJPI4hL4.js → index-Bg0VD211.js} +1 -1
- package/web/assets/{index-DM4oBLe8.js → index-Bw0U50QY.js} +1 -1
- package/web/assets/{index-CPLRJruN.js → index-CZF-u-hv.js} +1 -1
- package/web/assets/{index-CmXpz6wO.js → index-CmCj0IE6.js} +1 -1
- package/web/assets/{index-DXYp3jsl.js → index-Czu0PbLS.js} +1 -1
- package/web/assets/{index-DG-5rv4t.js → index-D57ZXpBD.js} +1 -1
- package/web/assets/{index-DSzfAcOE.js → index-DABElhgt.js} +1 -1
- package/web/assets/{index-CNdrabZC.js → index-DO1FY4r1.js} +1 -1
- package/web/assets/{index-rekQBGDD.js → index-DdCJlB8h.js} +1 -1
- package/web/assets/{index-CsBX1VvC.js → index-Dn5EQ5YI.js} +1 -1
- package/web/assets/{index-Buinfinc.js → index-Iwl1w0_V.js} +1 -1
- package/web/assets/{index-CBtC705w.js → index-J2jvoYvL.js} +1 -1
- package/web/assets/{index-DNppE7jj.js → index-ZstREAcb.js} +1 -1
- package/web/assets/{index-CzPnlrTh.js → index-xSo7_4Td.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-Bw0U50QY.js","./index-BIhkivIg.js","./index-xSo7_4Td.js","./index-BHot-lnj.js","./index-891wE-Rj.js","./index-Dn5EQ5YI.js","./index-Czu0PbLS.js","./index-Iwl1w0_V.js","./index-DdCJlB8h.js","./index-BDuAzkOQ.js","./index-DO1FY4r1.js","./index-BSEf83Uc.js","./index-CZF-u-hv.js","./index-Bg0VD211.js","./index-J2jvoYvL.js","./index-4S0cl_O2.js","./index-09MC_4AF.js","./index-D57ZXpBD.js","./index-CmCj0IE6.js","./index-DABElhgt.js","./index-ZstREAcb.js","./codemirror-D11GWMsB.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 Z_=Object.defineProperty;var tb=s=>{throw TypeError(s)};var K_=(s,l,r)=>l in s?Z_(s,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[l]=r;var Mt=(s,l,r)=>K_(s,typeof l!="symbol"?l+"":l,r),nh=(s,l,r)=>l.has(s)||tb("Cannot "+r);var qe=(s,l,r)=>(nh(s,l,"read from private field"),r?r.call(s):l.get(s)),en=(s,l,r)=>l.has(s)?tb("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(s):l.set(s,r),_t=(s,l,r,c)=>(nh(s,l,"write to private field"),c?c.call(s,r):l.set(s,r),r),kn=(s,l,r)=>(nh(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 lh={exports:{}},$c={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -113,8 +113,8 @@ ${s}</tr>
|
|
|
113
113
|
Please report this to https://github.com/markedjs/marked.`,s){let c="<p>An error occurred:</p><pre>"+Ds(r.message+"",!0)+"</pre>";return l?Promise.resolve(c):c}if(l)return Promise.reject(r);throw r}}},Bi=new gv;function vt(s,l){return Bi.parse(s,l)}vt.options=vt.setOptions=function(s){return Bi.setOptions(s),vt.defaults=Bi.defaults,qx(vt.defaults),vt};vt.getDefaults=Yh;vt.defaults=Ii;vt.use=function(...s){return Bi.use(...s),vt.defaults=Bi.defaults,qx(vt.defaults),vt};vt.walkTokens=function(s,l){return Bi.walkTokens(s,l)};vt.parseInline=Bi.parseInline;vt.Parser=bs;vt.parser=bs.parse;vt.Renderer=tf;vt.TextRenderer=Jh;vt.Lexer=gs;vt.lexer=gs.lex;vt.Tokenizer=ef;vt.Hooks=lu;vt.parse=vt;vt.options;vt.setOptions;vt.use;vt.walkTokens;vt.parseInline;bs.parse;gs.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 jb(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 bv(s){if(Array.isArray(s))return s}function xv(s,l){var r=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(r!=null){var c,o,d,h,p=[],m=!0,x=!1;try{if(d=(r=r.call(s)).next,l!==0)for(;!(m=(c=d.call(r)).done)&&(p.push(c.value),p.length!==l);m=!0);}catch(_){x=!0,o=_}finally{try{if(!m&&r.return!=null&&(h=r.return(),Object(h)!==h))return}finally{if(x)throw o}}return p}}function yv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
114
114
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _v(s,l){return bv(s)||xv(s,l)||vv(s,l)||yv()}function vv(s,l){if(s){if(typeof s=="string")return jb(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)?jb(s,l):void 0}}const Jx=Object.entries,kb=Object.setPrototypeOf,Sv=Object.isFrozen,jv=Object.getPrototypeOf,kv=Object.getOwnPropertyDescriptor;let nl=Object.freeze,ll=Object.seal,Rr=Object.create,Wx=typeof Reflect<"u"&&Reflect,Dh=Wx.apply,Lh=Wx.construct;nl||(nl=function(l){return l});ll||(ll=function(l){return l});Dh||(Dh=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)});Lh||(Lh=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 Er=wn(Array.prototype.forEach),wv=wn(Array.prototype.lastIndexOf),wb=wn(Array.prototype.pop),Ar=wn(Array.prototype.push),Nv=wn(Array.prototype.splice),Ja=Array.isArray,su=wn(String.prototype.toLowerCase),dh=wn(String.prototype.toString),Nb=wn(String.prototype.match),Kc=wn(String.prototype.replace),Tb=wn(String.prototype.indexOf),Tv=wn(String.prototype.trim),Ev=wn(Number.prototype.toString),Av=wn(Boolean.prototype.toString),Eb=typeof BigInt>"u"?null:wn(BigInt.prototype.toString),Ab=typeof Symbol>"u"?null:wn(Symbol.prototype.toString),$n=wn(Object.prototype.hasOwnProperty),Fc=wn(Object.prototype.toString),Vn=wn(RegExp.prototype.test),Ni=Cv(TypeError);function wn(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 Dh(s,l,c)}}function Cv(s){return function(){for(var l=arguments.length,r=new Array(l),c=0;c<l;c++)r[c]=arguments[c];return Lh(s,r)}}function ot(s,l){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:su;if(kb&&kb(s,null),!Ja(l))return s;let c=l.length;for(;c--;){let o=l[c];if(typeof o=="string"){const d=r(o);d!==o&&(Sv(l)||(l[c]=d),o=d)}s[o]=!0}return s}function Rv(s){for(let l=0;l<s.length;l++)$n(s,l)||(s[l]=null);return s}function yl(s){const l=Rr(null);for(const c of Jx(s)){var r=_v(c,2);const o=r[0],d=r[1];$n(s,o)&&(Ja(d)?l[o]=Rv(d):d&&typeof d=="object"&&d.constructor===Object?l[o]=yl(d):l[o]=d)}return l}function Mv(s){switch(typeof s){case"string":return s;case"number":return Ev(s);case"boolean":return Av(s);case"bigint":return Eb?Eb(s):"0";case"symbol":return Ab?Ab(s):"Symbol()";case"undefined":return Fc(s);case"function":case"object":{if(s===null)return Fc(s);const l=s,r=Ls(l,"toString");if(typeof r=="function"){const c=r(l);return typeof c=="string"?c:Fc(c)}return Fc(s)}default:return Fc(s)}}function Ls(s,l){for(;s!==null;){const c=kv(s,l);if(c){if(c.get)return wn(c.get);if(typeof c.value=="function")return wn(c.value)}s=jv(s)}function r(){return null}return r}function Ov(s){try{return Vn(s,""),!0}catch{return!1}}const Cb=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"]),hh=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"]),ph=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"]),Dv=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"]),mh=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"]),Lv=nl(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rb=nl(["#text"]),Mb=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"]),gh=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"]),Ob=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"]),zo=nl(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),zv=ll(/{{[\w\W]*|^[\w\W]*}}/g),Uv=ll(/<%[\w\W]*|^[\w\W]*%>/g),Hv=ll(/\${[\w\W]*/g),Bv=ll(/^data-[\-\w.\u00B7-\uFFFF]+$/),Iv=ll(/^aria-[\-\w]+$/),Db=ll(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qv=ll(/^(?:\w+script|data):/i),Gv=ll(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Yv=ll(/^html$/i),Xv=ll(/^[a-z][.\w]*(-[.\w]+)+$/i),Lb=ll(/<[/\w!]/g),zb=ll(/<[/\w]/g),Vv=ll(/<\/no(script|embed|frames)/i),$v=ll(/\/>/i),Xl={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Qv=function(){return typeof window>"u"?null:window},Zv=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}},Ub=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},$a=function(l,r,c,o){return $n(l,r)&&Ja(l[r])?ot(o.base?yl(o.base):{},l[r],o.transform):c};function Px(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qv();const l=me=>Px(me);if(l.version="3.4.12",l.removed=[],!s||!s.document||s.document.nodeType!==Xl.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,p=s.Element,m=s.NodeFilter,x=s.NamedNodeMap;x===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const _=s.DOMParser,j=s.trustedTypes,v=p.prototype,E=Ls(v,"cloneNode"),k=Ls(v,"remove"),O=Ls(v,"nextSibling"),z=Ls(v,"childNodes"),ee=Ls(v,"parentNode"),te=Ls(v,"shadowRoot"),K=Ls(v,"attributes"),M=h&&h.prototype?Ls(h.prototype,"nodeType"):null,F=h&&h.prototype?Ls(h.prototype,"nodeName"):null;if(typeof d=="function"){const me=r.createElement("template");me.content&&me.content.ownerDocument&&(r=me.content.ownerDocument)}let H,A="",Z,ae=!1,G=0;const J=function(){if(G>0)throw Ni('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.')},D=function(N){J(),G++;try{return H.createHTML(N)}finally{G--}},ge=function(N){J(),G++;try{return H.createScriptURL(N)}finally{G--}},Se=function(){return ae||(Z=Zv(j,o),ae=!0),Z},xe=r,B=xe.implementation,ue=xe.createNodeIterator,se=xe.createDocumentFragment,be=xe.getElementsByTagName,Ce=c.importNode;let w=Ub();l.isSupported=typeof Jx=="function"&&typeof ee=="function"&&B&&B.createHTMLDocument!==void 0;const Q=zv,re=Uv,oe=Hv,ye=Bv,je=Iv,Me=qv,ht=Gv,lt=Xv;let Nn=Db,Je=null;const Kt=ot({},[...Cb,...hh,...ph,...mh,...Rb]);let ct=null;const rn=ot({},[...Mb,...gh,...Ob,...zo]);let Be=Object.seal(Rr(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}})),rt=null,Hn=null;const wt=Object.seal(Rr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ot=!0,Ft=!0,tn=!1,$t=!0,Nt=!1,Qe=!0,We=!1,dn=!1,Jt=null,Qt=null,Bn=!1,Tn=!1,hn=!1,sl=!1,zt=!0,bt=!1;const Ut="user-content-";let $e=!0,Qn=!1,W={},de=null;const we=ot({},["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 L=null;const V=ot({},["audio","video","img","source","image","track"]);let _e=null;const ze=ot({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),st="http://www.w3.org/1998/Math/MathML",al="http://www.w3.org/2000/svg",Pe="http://www.w3.org/1999/xhtml";let En=Pe,In=!1,$l=null;const da=ot({},[st,al,Pe],dh),qs=nl(["mi","mo","mn","ms","mtext"]);let Ll=ot({},qs);const qn=nl(["annotation-xml"]);let pl=ot({},qn);const nn=ot({},["title","style","font","a","script"]);let _l=null;const Gn=["application/xhtml+xml","text/html"],Ht="text/html";let Ze=null,ln=null;const is=r.createElement("form"),An=function(N){return N instanceof RegExp||N instanceof Function},Cn=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ln&&ln===N)return;(!N||typeof N!="object")&&(N={}),N=yl(N),_l=Gn.indexOf(N.PARSER_MEDIA_TYPE)===-1?Ht:N.PARSER_MEDIA_TYPE,Ze=_l==="application/xhtml+xml"?dh:su,Je=$a(N,"ALLOWED_TAGS",Kt,{transform:Ze}),ct=$a(N,"ALLOWED_ATTR",rn,{transform:Ze}),$l=$a(N,"ALLOWED_NAMESPACES",da,{transform:dh}),_e=$a(N,"ADD_URI_SAFE_ATTR",ze,{transform:Ze,base:ze}),L=$a(N,"ADD_DATA_URI_TAGS",V,{transform:Ze,base:V}),de=$a(N,"FORBID_CONTENTS",we,{transform:Ze}),rt=$a(N,"FORBID_TAGS",yl({}),{transform:Ze}),Hn=$a(N,"FORBID_ATTR",yl({}),{transform:Ze}),W=$n(N,"USE_PROFILES")?N.USE_PROFILES&&typeof N.USE_PROFILES=="object"?yl(N.USE_PROFILES):N.USE_PROFILES:!1,Ot=N.ALLOW_ARIA_ATTR!==!1,Ft=N.ALLOW_DATA_ATTR!==!1,tn=N.ALLOW_UNKNOWN_PROTOCOLS||!1,$t=N.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Nt=N.SAFE_FOR_TEMPLATES||!1,Qe=N.SAFE_FOR_XML!==!1,We=N.WHOLE_DOCUMENT||!1,Tn=N.RETURN_DOM||!1,hn=N.RETURN_DOM_FRAGMENT||!1,sl=N.RETURN_TRUSTED_TYPE||!1,Bn=N.FORCE_BODY||!1,zt=N.SANITIZE_DOM!==!1,bt=N.SANITIZE_NAMED_PROPS||!1,$e=N.KEEP_CONTENT!==!1,Qn=N.IN_PLACE||!1,Nn=Ov(N.ALLOWED_URI_REGEXP)?N.ALLOWED_URI_REGEXP:Db,En=typeof N.NAMESPACE=="string"?N.NAMESPACE:Pe,Ll=$n(N,"MATHML_TEXT_INTEGRATION_POINTS")&&N.MATHML_TEXT_INTEGRATION_POINTS&&typeof N.MATHML_TEXT_INTEGRATION_POINTS=="object"?yl(N.MATHML_TEXT_INTEGRATION_POINTS):ot({},qs),pl=$n(N,"HTML_INTEGRATION_POINTS")&&N.HTML_INTEGRATION_POINTS&&typeof N.HTML_INTEGRATION_POINTS=="object"?yl(N.HTML_INTEGRATION_POINTS):ot({},qn);const I=$n(N,"CUSTOM_ELEMENT_HANDLING")&&N.CUSTOM_ELEMENT_HANDLING&&typeof N.CUSTOM_ELEMENT_HANDLING=="object"?yl(N.CUSTOM_ELEMENT_HANDLING):Rr(null);if(Be=Rr(null),$n(I,"tagNameCheck")&&An(I.tagNameCheck)&&(Be.tagNameCheck=I.tagNameCheck),$n(I,"attributeNameCheck")&&An(I.attributeNameCheck)&&(Be.attributeNameCheck=I.attributeNameCheck),$n(I,"allowCustomizedBuiltInElements")&&typeof I.allowCustomizedBuiltInElements=="boolean"&&(Be.allowCustomizedBuiltInElements=I.allowCustomizedBuiltInElements),ll(Be),Nt&&(Ft=!1),hn&&(Tn=!0),W&&(Je=ot({},Rb),ct=Rr(null),W.html===!0&&(ot(Je,Cb),ot(ct,Mb)),W.svg===!0&&(ot(Je,hh),ot(ct,gh),ot(ct,zo)),W.svgFilters===!0&&(ot(Je,ph),ot(ct,gh),ot(ct,zo)),W.mathMl===!0&&(ot(Je,mh),ot(ct,Ob),ot(ct,zo))),wt.tagCheck=null,wt.attributeCheck=null,$n(N,"ADD_TAGS")&&(typeof N.ADD_TAGS=="function"?wt.tagCheck=N.ADD_TAGS:Ja(N.ADD_TAGS)&&(Je===Kt&&(Je=yl(Je)),ot(Je,N.ADD_TAGS,Ze))),$n(N,"ADD_ATTR")&&(typeof N.ADD_ATTR=="function"?wt.attributeCheck=N.ADD_ATTR:Ja(N.ADD_ATTR)&&(ct===rn&&(ct=yl(ct)),ot(ct,N.ADD_ATTR,Ze))),$n(N,"ADD_URI_SAFE_ATTR")&&Ja(N.ADD_URI_SAFE_ATTR)&&ot(_e,N.ADD_URI_SAFE_ATTR,Ze),$n(N,"FORBID_CONTENTS")&&Ja(N.FORBID_CONTENTS)&&(de===we&&(de=yl(de)),ot(de,N.FORBID_CONTENTS,Ze)),$n(N,"ADD_FORBID_CONTENTS")&&Ja(N.ADD_FORBID_CONTENTS)&&(de===we&&(de=yl(de)),ot(de,N.ADD_FORBID_CONTENTS,Ze)),$e&&(Je["#text"]=!0),We&&ot(Je,["html","head","body"]),Je.table&&(ot(Je,["tbody"]),delete rt.tbody),N.TRUSTED_TYPES_POLICY){if(typeof N.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ni('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof N.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ni('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const fe=H;H=N.TRUSTED_TYPES_POLICY;try{A=D("")}catch(Ne){throw H=fe,Ne}}else N.TRUSTED_TYPES_POLICY===null?(H=void 0,A=""):(H===void 0&&(H=Se()),H&&typeof A=="string"&&(A=D("")));nl&&nl(N),ln=N},zl=ot({},[...hh,...ph,...Dv]),vl=ot({},[...mh,...Lv]),ys=function(N,I,fe){return I.namespaceURI===Pe?N==="svg":I.namespaceURI===st?N==="svg"&&(fe==="annotation-xml"||Ll[fe]):!!zl[N]},It=function(N,I,fe){return I.namespaceURI===Pe?N==="math":I.namespaceURI===al?N==="math"&&pl[fe]:!!vl[N]},Ql=function(N,I,fe){return I.namespaceURI===al&&!pl[fe]||I.namespaceURI===st&&!Ll[fe]?!1:!vl[N]&&(nn[N]||!zl[N])},Zl=function(N){let I=ee(N);(!I||!I.tagName)&&(I={namespaceURI:En,tagName:"template"});const fe=su(N.tagName),Ne=su(I.tagName);return $l[N.namespaceURI]?N.namespaceURI===al?ys(fe,I,Ne):N.namespaceURI===st?It(fe,I,Ne):N.namespaceURI===Pe?Ql(fe,I,Ne):!!(_l==="application/xhtml+xml"&&$l[N.namespaceURI]):!1},pn=function(N){Ar(l.removed,{element:N});try{ee(N).removeChild(N)}catch{if(k(N),!ee(N))throw Ni("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Tt=function(N){cn(N);const I=z(N);if(I){const Ne=[];Er(I,Oe=>{Ar(Ne,Oe)}),Er(Ne,Oe=>{try{k(Oe)}catch{}})}const fe=K(N);if(fe)for(let Ne=fe.length-1;Ne>=0;--Ne){const Oe=fe[Ne],Ue=Oe&&Oe.name;if(typeof Ue=="string")try{N.removeAttribute(Ue)}catch{}}},Yn=function(N,I){try{Ar(l.removed,{attribute:I.getAttributeNode(N),from:I})}catch{Ar(l.removed,{attribute:null,from:I})}if(I.removeAttribute(N),N==="is")if(Tn||hn)try{pn(I)}catch{}else try{I.setAttribute(N,"")}catch{}},Gs=function(N){const I=K(N);if(I)for(let fe=I.length-1;fe>=0;--fe){const Ne=I[fe],Oe=Ne&&Ne.name;if(!(typeof Oe!="string"||ct[Ze(Oe)]))try{N.removeAttribute(Oe)}catch{}}},cn=function(N){const I=[N];for(;I.length>0;){const fe=I.pop();(M?M(fe):fe.nodeType)===Xl.element&&Gs(fe);const Oe=z(fe);if(Oe)for(let Ue=Oe.length-1;Ue>=0;--Ue)I.push(Oe[Ue])}},T=function(N){if(!Qe)return;const I=[N];for(;I.length>0;){const fe=I.pop(),Ne=M?M(fe):fe.nodeType;if(Ne===Xl.processingInstruction||Ne===Xl.comment&&Vn(zb,fe.data)){try{k(fe)}catch{}continue}if(Ne===Xl.element){const Ue=fe,Et=Ze(F?F(fe):fe.nodeName);try{Ue.hasAttribute&&Ue.hasAttribute("patchsrc")&&Ue.removeAttribute("patchsrc"),Ue.hasAttribute&&Ue.hasAttribute("for")&&Et!=="label"&&Et!=="output"&&Ue.removeAttribute("for")}catch{}}const Oe=z(fe);if(Oe)for(let Ue=Oe.length-1;Ue>=0;--Ue)I.push(Oe[Ue])}},he=function(N){let I=null,fe=null;if(Bn)N="<remove></remove>"+N;else{const Ue=Nb(N,/^[\r\n\t ]+/);fe=Ue&&Ue[0]}_l==="application/xhtml+xml"&&En===Pe&&(N='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+N+"</body></html>");const Ne=H?D(N):N;if(En===Pe)try{I=new _().parseFromString(Ne,_l)}catch{}if(!I||!I.documentElement){I=B.createDocument(En,"template",null);try{I.documentElement.innerHTML=In?A:Ne}catch{}}const Oe=I.body||I.documentElement;return N&&fe&&Oe.insertBefore(r.createTextNode(fe),Oe.childNodes[0]||null),En===Pe?be.call(I,We?"html":"body")[0]:We?I.documentElement:Oe},Ge=function(N){return ue.call(N.ownerDocument||N,N,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},pt=function(N){return N=Kc(N,Q," "),N=Kc(N,re," "),N=Kc(N,oe," "),N},un=function(N){var I;N.normalize();const fe=ue.call(N.ownerDocument||N,N,m.SHOW_TEXT|m.SHOW_COMMENT|m.SHOW_CDATA_SECTION|m.SHOW_PROCESSING_INSTRUCTION,null);let Ne=fe.nextNode();for(;Ne;)Ne.data=pt(Ne.data),Ne=fe.nextNode();const Oe=(I=N.querySelectorAll)===null||I===void 0?void 0:I.call(N,"template");Oe&&Er(Oe,Ue=>{il(Ue.content)&&un(Ue.content)})},ml=function(N){const I=F?F(N):null;return typeof I!="string"||Ze(I)!=="form"?!1:typeof N.nodeName!="string"||typeof N.textContent!="string"||typeof N.removeChild!="function"||N.attributes!==K(N)||typeof N.removeAttribute!="function"||typeof N.setAttribute!="function"||typeof N.namespaceURI!="string"||typeof N.insertBefore!="function"||typeof N.hasChildNodes!="function"||N.nodeType!==M(N)||N.childNodes!==z(N)},il=function(N){if(!M||typeof N!="object"||N===null)return!1;try{return M(N)===Xl.documentFragment}catch{return!1}},mn=function(N){if(!M||typeof N!="object"||N===null)return!1;try{return typeof M(N)=="number"}catch{return!1}};function xt(me,N,I){me.length!==0&&Er(me,fe=>{fe.call(l,N,I,ln)})}const rl=function(N,I){return!!(Qe&&N.hasChildNodes()&&!mn(N.firstElementChild)&&Vn(Lb,N.textContent)&&Vn(Lb,N.innerHTML)||Qe&&N.namespaceURI===Pe&&I==="style"&&mn(N.firstElementChild)||N.nodeType===Xl.processingInstruction||Qe&&N.nodeType===Xl.comment&&Vn(zb,N.data))},ha=function(N,I){if(!rt[I]&&_s(I)&&(Be.tagNameCheck instanceof RegExp&&Vn(Be.tagNameCheck,I)||Be.tagNameCheck instanceof Function&&Be.tagNameCheck(I)))return!1;if($e&&!de[I]){const fe=ee(N),Ne=z(N);if(Ne&&fe){const Oe=Ne.length;for(let Ue=Oe-1;Ue>=0;--Ue){const Et=Qn?Ne[Ue]:E(Ne[Ue],!0);fe.insertBefore(Et,O(N))}}}return pn(N),!0},Sl=function(N,I){if(xt(w.beforeSanitizeElements,N,null),N!==I&&ee(N)===null)return!0;if(ml(N))return pn(N),!0;const fe=Ze(F?F(N):N.nodeName);if(xt(w.uponSanitizeElement,N,{tagName:fe,allowedTags:Je}),N!==I&&ee(N)===null)return!0;if(rl(N,fe))return pn(N),!0;if(rt[fe]||!(wt.tagCheck instanceof Function&&wt.tagCheck(fe))&&!Je[fe]){const Oe=ha(N,fe);return Oe===!1&&xt(w.afterSanitizeElements,N,null),Oe}if((M?M(N):N.nodeType)===Xl.element&&!Zl(N)||(fe==="noscript"||fe==="noembed"||fe==="noframes")&&Vn(Vv,N.innerHTML))return pn(N),!0;if(Nt&&N.nodeType===Xl.text){const Oe=pt(N.textContent);N.textContent!==Oe&&(Ar(l.removed,{element:N.cloneNode()}),N.textContent=Oe)}return xt(w.afterSanitizeElements,N,null),!1},ti=function(N,I,fe){if(Hn[I]||Qe&&I==="patchsrc"||Qe&&I==="for"&&N!=="label"&&N!=="output"||zt&&(I==="id"||I==="name")&&(fe in r||fe in is))return!1;const Ne=ct[I]||wt.attributeCheck instanceof Function&&wt.attributeCheck(I,N);if(!(Ft&&Vn(ye,I))){if(!(Ot&&Vn(je,I))){if(Ne){if(!_e[I]){if(!Vn(Nn,Kc(fe,ht,""))){if(!((I==="src"||I==="xlink:href"||I==="href")&&N!=="script"&&Tb(fe,"data:")===0&&L[N])){if(!(tn&&!Vn(Me,Kc(fe,ht,"")))){if(fe)return!1}}}}}else if(!(_s(N)&&(Be.tagNameCheck instanceof RegExp&&Vn(Be.tagNameCheck,N)||Be.tagNameCheck instanceof Function&&Be.tagNameCheck(N))&&(Be.attributeNameCheck instanceof RegExp&&Vn(Be.attributeNameCheck,I)||Be.attributeNameCheck instanceof Function&&Be.attributeNameCheck(I,N))||I==="is"&&Be.allowCustomizedBuiltInElements&&(Be.tagNameCheck instanceof RegExp&&Vn(Be.tagNameCheck,fe)||Be.tagNameCheck instanceof Function&&Be.tagNameCheck(fe))))return!1}}return!0},gl=ot({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),_s=function(N){return!gl[su(N)]&&Vn(lt,N)},Rn=function(N,I,fe,Ne){if(H&&typeof j=="object"&&typeof j.getAttributeType=="function"&&!fe)switch(j.getAttributeType(N,I)){case"TrustedHTML":return D(Ne);case"TrustedScriptURL":return ge(Ne)}return Ne},rs=function(N,I,fe,Ne){try{fe?N.setAttributeNS(fe,I,Ne):N.setAttribute(I,Ne),ml(N)?pn(N):wb(l.removed)}catch{Yn(I,N)}},vs=function(N){xt(w.beforeSanitizeAttributes,N,null);const I=N.attributes;if(!I||ml(N))return;const fe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ct,forceKeepAttr:void 0};let Ne=I.length;const Oe=Ze(N.nodeName);for(;Ne--;){const Ue=I[Ne],Et=Ue.name,Wt=Ue.namespaceURI,gn=Ue.value,Dt=Ze(Et),bn=gn;let Bt=Et==="value"?bn:Tv(bn);if(fe.attrName=Dt,fe.attrValue=Bt,fe.keepAttr=!0,fe.forceKeepAttr=void 0,xt(w.uponSanitizeAttribute,N,fe),Bt=fe.attrValue,bt&&(Dt==="id"||Dt==="name")&&Tb(Bt,Ut)!==0&&(Yn(Et,N),Bt=Ut+Bt),Qe&&Vn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Bt)){Yn(Et,N);continue}if(Dt==="attributename"&&Nb(Bt,"href")){Yn(Et,N);continue}if(!fe.forceKeepAttr){if(!fe.keepAttr){Yn(Et,N);continue}if(!$t&&Vn($v,Bt)){Yn(Et,N);continue}if(Nt&&(Bt=pt(Bt)),!ti(Oe,Dt,Bt)){Yn(Et,N);continue}Bt=Rn(Oe,Dt,Wt,Bt),Bt!==bn&&rs(N,Et,Wt,Bt)}}xt(w.afterSanitizeAttributes,N,null)},Ss=function(N){let I=null;const fe=Ge(N);for(xt(w.beforeSanitizeShadowDOM,N,null);I=fe.nextNode();)if(xt(w.uponSanitizeShadowNode,I,null),Sl(I,N),vs(I),il(I.content)&&Ss(I.content),(M?M(I):I.nodeType)===Xl.element){const Oe=te(I);il(Oe)&&(jl(Oe),Ss(Oe))}xt(w.afterSanitizeShadowDOM,N,null)},jl=function(N){const I=[{node:N,shadow:null}];for(;I.length>0;){const fe=I.pop();if(fe.shadow){Ss(fe.shadow);continue}const Ne=fe.node,Ue=(M?M(Ne):Ne.nodeType)===Xl.element,Et=z(Ne);if(Et)for(let Wt=Et.length-1;Wt>=0;--Wt)I.push({node:Et[Wt],shadow:null});if(Ue){const Wt=F?F(Ne):null;if(typeof Wt=="string"&&Ze(Wt)==="template"){const gn=Ne.content;il(gn)&&I.push({node:gn,shadow:null})}}if(Ue){const Wt=te(Ne);il(Wt)&&I.push({node:null,shadow:Wt},{node:Wt,shadow:null})}}};return l.sanitize=function(me){let N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=null,fe=null,Ne=null,Oe=null;if(In=!me,In&&(me="<!-->"),typeof me!="string"&&!mn(me)&&(me=Mv(me),typeof me!="string"))throw Ni("dirty is not a string, aborting");if(!l.isSupported)return me;dn?(Je=Jt,ct=Qt):Cn(N),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(Je=yl(Je)),w.uponSanitizeAttribute.length>0&&(ct=yl(ct)),l.removed=[];const Ue=Qn&&typeof me!="string"&&mn(me);if(Ue){T(me);const Dt=F?F(me):me.nodeName;if(typeof Dt=="string"){const bn=Ze(Dt);if(!Je[bn]||rt[bn])throw Tt(me),Ni("root node is forbidden and cannot be sanitized in-place")}if(ml(me))throw Tt(me),Ni("root node is clobbered and cannot be sanitized in-place");try{jl(me)}catch(bn){throw Tt(me),bn}}else if(mn(me))I=he("<!---->"),fe=I.ownerDocument.importNode(me,!0),fe.nodeType===Xl.element&&fe.nodeName==="BODY"||fe.nodeName==="HTML"?I=fe:I.appendChild(fe),jl(fe);else{if(!Tn&&!Nt&&!We&&me.indexOf("<")===-1)return H&&sl?D(me):me;if(I=he(me),!I)return Tn?null:sl?A:""}I&&Bn&&pn(I.firstChild);const Et=Ue?me:I,Wt=Ge(Et);try{for(;Ne=Wt.nextNode();)Sl(Ne,Et),vs(Ne),il(Ne.content)&&Ss(Ne.content)}catch(Dt){throw Ue&&(Tt(me),Er(l.removed,bn=>{bn.element&&cn(bn.element)})),Dt}if(Ue)return Er(l.removed,Dt=>{Dt.element&&cn(Dt.element)}),Nt&&un(me),me;if(Tn){if(Nt&&un(I),hn)for(Oe=se.call(I.ownerDocument);I.firstChild;)Oe.appendChild(I.firstChild);else Oe=I;return(ct.shadowroot||ct.shadowrootmode)&&(Oe=Ce.call(c,Oe,!0)),Oe}let gn=We?I.outerHTML:I.innerHTML;return We&&Je["!doctype"]&&I.ownerDocument&&I.ownerDocument.doctype&&I.ownerDocument.doctype.name&&Vn(Yv,I.ownerDocument.doctype.name)&&(gn="<!DOCTYPE "+I.ownerDocument.doctype.name+`>
|
|
115
115
|
`+gn),Nt&&(gn=pt(gn)),H&&sl?D(gn):gn},l.setConfig=function(){let me=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cn(me),dn=!0,Jt=Je,Qt=ct},l.clearConfig=function(){ln=null,dn=!1,Jt=null,Qt=null,H=Z,A=""},l.isValidAttribute=function(me,N,I){ln||Cn({});const fe=Ze(me),Ne=Ze(N);return ti(fe,Ne,I)},l.addHook=function(me,N){typeof N=="function"&&$n(w,me)&&Ar(w[me],N)},l.removeHook=function(me,N){if($n(w,me)){if(N!==void 0){const I=wv(w[me],N);return I===-1?void 0:Nv(w[me],I,1)[0]}return wb(w[me])}},l.removeHooks=function(me){$n(w,me)&&(w[me]=[])},l.removeAllHooks=function(){w=Ub()},l}var Kv=Px();const Fv=1024;let Jv=0;class as{constructor(l,r){this.from=l,this.to=r}}class Vt{constructor(l={}){this.id=Jv++,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=xs.match(l)),r=>{let c=l(r);return c===void 0?null:[this,c]}}}Vt.closedBy=new Vt({deserialize:s=>s.split(" ")});Vt.openedBy=new Vt({deserialize:s=>s.split(" ")});Vt.group=new Vt({deserialize:s=>s.split(" ")});Vt.isolate=new Vt({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});Vt.contextHash=new Vt({perNode:!0});Vt.lookAhead=new Vt({perNode:!0});Vt.mounted=new Vt({perNode:!0});class Lr{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[Vt.mounted.id]}}const Wv=Object.create(null);class xs{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):Wv,c=(l.top?1:0)|(l.skipped?2:0)|(l.error?4:0)|(l.name==null?8:0),o=new xs(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(Vt.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(Vt.group),d=-1;d<(o?o.length:0);d++){let h=r[d<0?c.name:o[d]];if(h)return h}}}}xs.none=new xs("",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 p=h[1],m=h[0];m.combine&&m.id in o&&(p=m.combine(o[m.id],p)),o[m.id]=p}}r.push(o?new xs(c.name,o,c.id,c.flags):c)}return new ey(r)}}const Uo=new WeakMap,Hb=new WeakMap;var Yt;(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"})(Yt||(Yt={}));class Dl{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,p]of d)this.props[typeof h=="number"?h:h.id]=p}}toString(){let l=Lr.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 nf(this.topNode,l)}cursorAt(l,r=0,c=0){let o=Uo.get(this)||this.topNode,d=new nf(o);return d.moveTo(l,r),Uo.set(this,d._tree),d}get topNode(){return new hl(this,0,0,null)}resolve(l,r=0){let c=ru(Uo.get(this)||this.topNode,l,r,!1);return Uo.set(this,c),c}resolveInner(l,r=0){let c=ru(Hb.get(this)||this.topNode,l,r,!0);return Hb.set(this,c),c}resolveStack(l,r=0){return t1(this,l,r)}iterate(l){let{enter:r,leave:c,from:o=0,to:d=this.length}=l,h=l.mode||0,p=(h&Yt.IncludeAnonymous)>0;for(let m=this.cursor(h|Yt.IncludeAnonymous);;){let x=!1;if(m.from<=d&&m.to>=o&&(!p&&m.type.isAnonymous||r(m)!==!1)){if(m.firstChild())continue;x=!0}for(;x&&c&&(p||!m.type.isAnonymous)&&c(m),!m.nextSibling();){if(!m.parent())return;x=!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:ep(xs.none,this.children,this.positions,0,this.children.length,0,this.length,(r,c,o)=>new Dl(this.type,r,c,o,this.propValues),l.makeTree||((r,c,o)=>new Dl(xs.none,r,c,o)))}static build(l){return n1(l)}}Dl.empty=new Dl(xs.none,[],[],0);class Wh{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 Wh(this.buffer,this.index)}}class ei{constructor(l,r,c){this.buffer=l,this.length=r,this.set=c}get type(){return xs.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,p=-1;for(let m=l;m!=r&&!(ty(d,o,h[m+1],h[m+2])&&(p=m,c>0));m=h[m+3]);return p}slice(l,r,c){let o=this.buffer,d=new Uint16Array(r-l),h=0;for(let p=l,m=0;p<r;){d[m++]=o[p++],d[m++]=o[p++]-c;let x=d[m++]=o[p++]-c;d[m++]=o[p++]-l,h=Math.max(h,x)}return new ei(d,h,this.set)}}function ty(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 ru(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 hl&&s.index<0?null:s.parent;if(!h)return s;s=h}let d=c?0:Yt.IgnoreOverlays;if(c)for(let h=s,p=h.parent;p;h=p,p=h.parent)h instanceof hl&&h.index<0&&((o=p.enter(l,r,d))===null||o===void 0?void 0:o.from)!=h.from&&(s=p);for(;;){let h=s.enter(l,r,d);if(!h)return s;s=h}}class ny{cursor(l=0){return new nf(this,l)}getChild(l,r=null,c=null){let o=Bb(this,l,r,c);return o.length?o[0]:null}getChildren(l,r=null,c=null){return Bb(this,l,r,c)}resolve(l,r=0){return ru(this,l,r,!1)}resolveInner(l,r=0){return ru(this,l,r,!0)}matchContext(l){return zh(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 hl extends ny{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:p,positions:m}=h._tree,x=r>0?p.length:-1;l!=x;l+=r){let _=p[l],j=m[l]+h.from,v;if(!(!(d&Yt.EnterBracketed&&_ instanceof Dl&&(v=Lr.get(_))&&!v.overlay&&v.bracketed&&c>=j&&c<=j+_.length)&&!ty(o,c,j,j+_.length))){if(_ instanceof ei){if(d&Yt.ExcludeBuffers)continue;let E=_.findChild(0,_.buffer.length,r,c-j,o);if(E>-1)return new Bs(new Pv(h,_,l,j),null,E)}else if(d&Yt.IncludeAnonymous||!_.type.isAnonymous||Ph(_)){let E;if(!(d&Yt.IgnoreMounts)&&(E=Lr.get(_))&&!E.overlay)return new hl(E.tree,j,l,h);let k=new hl(_,j,l,h);return d&Yt.IncludeAnonymous||!k.type.isAnonymous?k:k.nextChild(r<0?_.children.length-1:0,r,c,o,d)}}}if(d&Yt.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&Yt.IgnoreOverlays)&&(o=Lr.get(this._tree))&&o.overlay){let d=l-this.from,h=c&Yt.EnterBracketed&&o.bracketed;for(let{from:p,to:m}of o.overlay)if((r>0||h?p<=d:p<d)&&(r<0||h?m>=d:m>d))return new hl(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 Bb(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 zh(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 Pv{constructor(l,r,c,o){this.parent=l,this.buffer=r,this.index=c,this.start=o}}class Bs extends ny{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 Bs(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&Yt.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 Bs(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 Bs(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 Bs(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 Dl(this.type,l,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ly(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 hl&&r.index<0?null:r.parent,o=s.slice();return c?o[l]=c:o.splice(l,1),new e1(o,r)}class e1{constructor(l,r){this.heads=l,this.node=r}get next(){return ly(this.heads)}}function t1(s,l,r){let c=s.resolveInner(l,r),o=null;for(let d=c instanceof hl?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=Lr.get(d.tree);if(h&&h.overlay&&h.overlay[0].from<=l&&h.overlay[h.overlay.length-1].to>=l){let p=new hl(h.tree,h.overlay[0].from+d.from,-1,d);(o||(o=[c])).push(ru(p,l,r,!1))}}return o?ly(o):c}class nf{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&~Yt.EnterBracketed,l instanceof hl)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 hl?(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&Yt.ExcludeBuffers?!1:this.enterChild(1,l,r):this.yield(this._tree.enter(l,r,c))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Yt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let l=this.mode&Yt.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 p=c._tree.children[d];if(this.mode&Yt.IncludeAnonymous||p instanceof ei||!p.type.isAnonymous||Ph(p))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 Bs(this.buffer,r,this.stack[o]);return this.bufferNode=new Bs(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 zh(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 zh(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 Ph(s){return s.children.some(l=>l instanceof ei||!l.type.isAnonymous||Ph(l))}function n1(s){var l;let{buffer:r,nodeSet:c,maxBufferLength:o=Fv,reused:d=[],minRepeatType:h=c.types.length}=s,p=Array.isArray(r)?new Wh(r,r.length):r,m=c.types,x=0,_=0;function j(F,H,A,Z,ae,G){let{id:J,start:D,end:ge,size:Se}=p,xe=_,B=x;if(Se<0)if(p.next(),Se==-1){let w=d[J];A.push(w),Z.push(D-F);return}else if(Se==-3){x=J;return}else if(Se==-4){_=J;return}else throw new RangeError(`Unrecognized record size: ${Se}`);let ue=m[J],se,be,Ce=D-F;if(ge-D<=o&&(be=z(p.pos-H,ae))){let w=new Uint16Array(be.size-be.skip),Q=p.pos-be.size,re=w.length;for(;p.pos>Q;)re=ee(be.start,w,re);se=new ei(w,ge-be.start,c),Ce=be.start-F}else{let w=p.pos-Se;p.next();let Q=[],re=[],oe=J>=h?J:-1,ye=0,je=ge;for(;p.pos>w;)oe>=0&&p.id==oe&&p.size>=0?(p.end<=je-o&&(k(Q,re,D,ye,p.end,je,oe,xe,B),ye=Q.length,je=p.end),p.next()):G>2500?v(D,w,Q,re):j(D,w,Q,re,oe,G+1);if(oe>=0&&ye>0&&ye<Q.length&&k(Q,re,D,ye,D,je,oe,xe,B),Q.reverse(),re.reverse(),oe>-1&&ye>0){let Me=E(ue,B);se=ep(ue,Q,re,0,Q.length,0,ge-D,Me,Me)}else se=O(ue,Q,re,ge-D,xe-ge,B)}A.push(se),Z.push(Ce)}function v(F,H,A,Z){let ae=[],G=0,J=-1;for(;p.pos>H;){let{id:D,start:ge,end:Se,size:xe}=p;if(xe>4)p.next();else{if(J>-1&&ge<J)break;J<0&&(J=Se-o),ae.push(D,ge,Se),G++,p.next()}}if(G){let D=new Uint16Array(G*4),ge=ae[ae.length-2];for(let Se=ae.length-3,xe=0;Se>=0;Se-=3)D[xe++]=ae[Se],D[xe++]=ae[Se+1]-ge,D[xe++]=ae[Se+2]-ge,D[xe++]=xe;A.push(new ei(D,ae[2]-ge,c)),Z.push(ge-F)}}function E(F,H){return(A,Z,ae)=>{let G=0,J=A.length-1,D,ge;if(J>=0&&(D=A[J])instanceof Dl){if(!J&&D.type==F&&D.length==ae)return D;(ge=D.prop(Vt.lookAhead))&&(G=Z[J]+D.length+ge)}return O(F,A,Z,ae,G,H)}}function k(F,H,A,Z,ae,G,J,D,ge){let Se=[],xe=[];for(;F.length>Z;)Se.push(F.pop()),xe.push(H.pop()+A-ae);F.push(O(c.types[J],Se,xe,G-ae,D-G,ge)),H.push(ae-A)}function O(F,H,A,Z,ae,G,J){if(G){let D=[Vt.contextHash,G];J=J?[D].concat(J):[D]}if(ae>25){let D=[Vt.lookAhead,ae];J=J?[D].concat(J):[D]}return new Dl(F,H,A,Z,J)}function z(F,H){let A=p.fork(),Z=0,ae=0,G=0,J=A.end-o,D={size:0,start:0,skip:0};e:for(let ge=A.pos-F;A.pos>ge;){let Se=A.size;if(A.id==H&&Se>=0){D.size=Z,D.start=ae,D.skip=G,G+=4,Z+=4,A.next();continue}let xe=A.pos-Se;if(Se<0||xe<ge||A.start<J)break;let B=A.id>=h?4:0,ue=A.start;for(A.next();A.pos>xe;){if(A.size<0)if(A.size==-3||A.size==-4)B+=4;else break e;else A.id>=h&&(B+=4);A.next()}ae=ue,Z+=Se,G+=B}return(H<0||Z==F)&&(D.size=Z,D.start=ae,D.skip=G),D.size>4?D:void 0}function ee(F,H,A){let{id:Z,start:ae,end:G,size:J}=p;if(p.next(),J>=0&&Z<h){let D=A;if(J>4){let ge=p.pos-(J-4);for(;p.pos>ge;)A=ee(F,H,A)}H[--A]=D,H[--A]=G-F,H[--A]=ae-F,H[--A]=Z}else J==-3?x=Z:J==-4&&(_=Z);return A}let te=[],K=[];for(;p.pos>0;)j(s.start||0,s.bufferStart||0,te,K,-1,0);let M=(l=s.length)!==null&&l!==void 0?l:te.length?K[0]+te[0].length:0;return new Dl(m[s.topID],te.reverse(),K.reverse(),M)}const Ib=new WeakMap;function Jo(s,l){if(!s.isAnonymous||l instanceof ei||l.type!=s)return 1;let r=Ib.get(l);if(r==null){r=1;for(let c of l.children){if(c.type!=s||!(c instanceof Dl)){r=1;break}r+=Jo(s,c)}Ib.set(l,r)}return r}function ep(s,l,r,c,o,d,h,p,m){let x=0;for(let k=c;k<o;k++)x+=Jo(s,l[k]);let _=Math.ceil(x*1.5/8),j=[],v=[];function E(k,O,z,ee,te){for(let K=z;K<ee;){let M=K,F=O[K],H=Jo(s,k[K]);for(K++;K<ee;K++){let A=Jo(s,k[K]);if(H+A>=_)break;H+=A}if(K==M+1){if(H>_){let A=k[M];E(A.children,A.positions,0,A.children.length,O[M]+te);continue}j.push(k[M])}else{let A=O[K-1]+k[K-1].length-F;j.push(ep(s,k,O,M,K,F,A,null,m))}v.push(F+te-d)}}return E(l,r,c,o,0),(p||m)(j,v,h)}class Tw{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 Bs?this.setBuffer(l.context.buffer,l.index,r):l instanceof hl&&this.map.set(l.tree,r)}get(l){return l instanceof Bs?this.getBuffer(l.context.buffer,l.index):l instanceof hl?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 cu{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 cu(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 p=0,m=0,x=0;;p++){let _=p<r.length?r[p]:null,j=_?_.fromA:1e9;if(j-m>=c)for(;h&&h.from<j;){let v=h;if(m>=v.from||j<=v.to||x){let E=Math.max(v.from,m)-x,k=Math.min(v.to,j)-x;v=E>=k?null:new cu(E,k,v.tree,v.offset+x,p>0,!!_)}if(v&&o.push(v),h.to>j)break;h=d<l.length?l[d++]:null}if(!_)break;m=_.toA,x=_.toA-_.toB}return o}}class Ew{startParse(l,r,c){return typeof l=="string"&&(l=new l1(l)),c=c?c.length?c.map(o=>new as(o.from,o.to)):[new as(0,0)]:[new as(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 l1{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 Aw(s){return(l,r,c,o)=>new a1(l,s,r,c,o)}class qb{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 Gb(s){if(!s.length||s.some(l=>l.from>=l.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}class s1{constructor(l,r,c,o,d,h,p,m){this.parser=l,this.predicate=r,this.mounts=c,this.index=o,this.start=d,this.bracketed=h,this.target=p,this.prev=m,this.depth=0,this.ranges=[]}}const Uh=new Vt({perNode:!0});class a1{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 Dl(c.type,c.children,c.positions,c.length,c.propValues.concat([[Uh,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[Vt.mounted.id]=new Lr(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 c1(this.fragments),r=null,c=null,o=new nf(new hl(this.baseTree,this.ranges[0].from,0,null),Yt.IncludeAnonymous|Yt.IgnoreMounts);e:for(let d,h;;){let p=!0,m;if(this.stoppedAt!=null&&o.from>=this.stoppedAt)p=!1;else if(l.hasNode(o)){if(r){let x=r.mounts.find(_=>_.frag.from<=o.from&&_.frag.to>=o.to&&_.mount.overlay);if(x)for(let _ of x.mount.overlay){let j=_.from+x.pos,v=_.to+x.pos;j>=o.from&&v<=o.to&&!r.ranges.some(E=>E.from<v&&E.to>j)&&r.ranges.push({from:j,to:v})}}p=!1}else if(c&&(h=i1(c.ranges,o.from,o.to)))p=h!=2;else if(!o.type.isAnonymous&&(d=this.nest(o,this.input))&&(o.from<o.to||!d.overlay)){o.tree||(r1(o),r&&r.depth++,c&&c.depth++);let x=l.findMounts(o.from,d.parser);if(typeof d.overlay=="function")r=new s1(d.parser,d.overlay,x,this.inner.length,o.from,!!d.bracketed,o.tree,r);else{let _=Vb(this.ranges,d.overlay||(o.from<o.to?[new as(o.from,o.to)]:[]));_.length&&Gb(_),(_.length||!d.overlay)&&this.inner.push(new qb(d.parser,_.length?d.parser.startParse(this.input,$b(x,_),_):d.parser.startParse(""),d.overlay?d.overlay.map(j=>new as(j.from-o.from,j.to-o.from)):null,!!d.bracketed,o.tree,_.length?_[0].from:o.from)),d.overlay?_.length&&(c={ranges:_,depth:0,prev:c}):p=!1}}else if(r&&(m=r.predicate(o))&&(m===!0&&(m=new as(o.from,o.to)),m.from<m.to)){let x=r.ranges.length-1;x>=0&&r.ranges[x].to==m.from?r.ranges[x]={from:r.ranges[x].from,to:m.to}:r.ranges.push(m)}if(p&&o.firstChild())r&&r.depth++,c&&c.depth++;else for(;!o.nextSibling();){if(!o.parent())break e;if(r&&!--r.depth){let x=Vb(this.ranges,r.ranges);x.length&&(Gb(x),this.inner.splice(r.index,0,new qb(r.parser,r.parser.startParse(this.input,$b(r.mounts,x),x),r.ranges.map(_=>new as(_.from-r.start,_.to-r.start)),r.bracketed,r.target,x[0].from))),r=r.prev}c&&!--c.depth&&(c=c.prev)}}}}function i1(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 Yb(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 r1(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],p=h.buffer,m=[d];function x(_,j,v,E,k,O){let z=r[O],ee=[],te=[];Yb(h,_,z,ee,te,E);let K=p[z+1],M=p[z+2];m.push(ee.length);let F=O?x(z+4,p[z+3],h.set.types[p[z]],K,M-K,O-1):l.toTree();return ee.push(F),te.push(K-E),Yb(h,p[z+3],j,ee,te,E),new Dl(v,ee,te,k)}o.children[d]=x(0,p.length,xs.none,0,h.length,r.length-1);for(let _ of m){let j=s.tree.children[_],v=s.tree.positions[_];s.yield(new hl(j,v+s.from,_,s._tree))}}class Xb{constructor(l,r){this.offset=r,this.done=!1,this.cursor=l.cursor(Yt.IncludeAnonymous|Yt.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,Yt.IgnoreOverlays|Yt.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 Dl)r=r.children[0];else break}return!1}}class c1{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(Uh))!==null&&r!==void 0?r:c.to,this.inner=new Xb(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(Uh))!==null&&l!==void 0?l:r.to,this.inner=new Xb(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(Vt.mounted);if(h&&h.parser==r)for(let p=this.fragI;p<this.fragments.length;p++){let m=this.fragments[p];if(m.from>=d.to)break;m.tree==this.curFrag.tree&&o.push({frag:m,pos:d.from-m.offset,mount:h})}}}return o}}function Vb(s,l){let r=null,c=l;for(let o=1,d=0;o<s.length;o++){let h=s[o-1].to,p=s[o].from;for(;d<c.length;d++){let m=c[d];if(m.from>=p)break;m.to<=h||(r||(c=r=l.slice()),m.from<h?(r[d]=new as(m.from,h),m.to>p&&r.splice(d+1,0,new as(p,m.to))):m.to>p?r[d--]=new as(p,m.to):r.splice(d--,1))}}return c}function u1(s,l,r,c){let o=0,d=0,h=!1,p=!1,m=-1e9,x=[];for(;;){let _=o==s.length?1e9:h?s[o].to:s[o].from,j=d==l.length?1e9:p?l[d].to:l[d].from;if(h!=p){let v=Math.max(m,r),E=Math.min(_,j,c);v<E&&x.push(new as(v,E))}if(m=Math.min(_,j),m==1e9)break;_==m&&(h?(h=!1,o++):h=!0),j==m&&(p?(p=!1,d++):p=!0)}return x}function $b(s,l){let r=[];for(let{pos:c,mount:o,frag:d}of s){let h=c+(o.overlay?o.overlay[0].from:0),p=h+o.tree.length,m=Math.max(d.from,h),x=Math.min(d.to,p);if(o.overlay){let _=o.overlay.map(v=>new as(v.from+c,v.to+c)),j=u1(l,_,m,x);for(let v=0,E=m;;v++){let k=v==j.length,O=k?x:j[v].from;if(O>E&&r.push(new cu(E,O,o.tree,-h,d.from>=E||d.openStart,d.to<=O||d.openEnd)),k)break;E=j[v].to}}else r.push(new cu(m,x,o.tree,-h,d.from>=h||d.openStart,d.to<=p||d.openEnd))}return r}let o1=0;class ss{constructor(l,r,c,o){this.name=l,this.set=r,this.base=c,this.modified=o,this.id=o1++}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 ss&&(r=l),r!=null&&r.base)throw new Error("Can not derive from a modified tag");let o=new ss(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 lf(l);return c=>c.modified.indexOf(r)>-1?c:lf.get(c.base||c,c.modified.concat(r).sort((o,d)=>o.id-d.id))}}let f1=0;class lf{constructor(l){this.name=l,this.instances=[],this.id=f1++}static get(l,r){if(!r.length)return l;let c=r[0].instances.find(p=>p.base==l&&d1(r,p.modified));if(c)return c;let o=[],d=new ss(l.name,o,l,r);for(let p of r)p.instances.push(d);let h=h1(r);for(let p of l.set)if(!p.modified.length)for(let m of h)o.push(lf.get(p,m));return d}}function d1(s,l){return s.length==l.length&&s.every((r,c)=>r==l[c])}function h1(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 Cw(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,p=o;for(let j=0;;){if(p=="..."&&j>0&&j+3==o.length){h=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(p);if(!v)throw new RangeError("Invalid path: "+o);if(d.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),j+=v[0].length,j==o.length)break;let E=o[j++];if(j==o.length&&E=="!"){h=0;break}if(E!="/")throw new RangeError("Invalid path: "+o);p=o.slice(j)}let m=d.length-1,x=d[m];if(!x)throw new RangeError("Invalid path: "+o);let _=new uu(c,h,m>0?d.slice(0,m):null);l[x]=_.sort(l[x])}}return sy.add(l)}const sy=new Vt({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 uu(o.tags,o.mode,o.context);r?r.next=d:c=d,r=d}return c}});class uu{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}}uu.empty=new uu([],2,null);function ay(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 p of d)for(let m of p.set){let x=r[m.id];if(x){h=h?h+" "+x:x;break}}return h},scope:c}}function p1(s,l){let r=null;for(let c of s){let o=c.style(l);o&&(r=r?r+" "+o:o)}return r}function m1(s,l,r,c=0,o=s.length){let d=new b1(c,Array.isArray(l)?l:[l],r);d.highlightRange(s.cursor(),c,o,"",d.highlighters),d.flush(o)}function g1(s,l,r,c,o,d=0,h=s.length){let p=d;function m(x,_){if(!(x<=p)){for(let j=s.slice(p,x),v=0;;){let E=j.indexOf(`
|
|
116
|
-
`,v),k=E<0?j.length:E;if(k>v&&c(j.slice(v,k),_),E<0)break;o(),v=E+1}p=x}}m1(l,r,(x,_,j)=>{m(x,""),m(_,j)},d,h),m(h,"")}class b1{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:p,to:m}=l;if(p>=c||m<=r)return;h.isTop&&(d=this.highlighters.filter(E=>!E.scope||E.scope(h)));let x=o,_=x1(l)||uu.empty,j=p1(d,_.tags);if(j&&(x&&(x+=" "),x+=j,_.mode==1&&(o+=(o?" ":"")+j)),this.startSpan(Math.max(r,p),x),_.opaque)return;let v=l.tree&&l.tree.prop(Vt.mounted);if(v&&v.overlay){let E=l.node.enter(v.overlay[0].from+p,1),k=this.highlighters.filter(z=>!z.scope||z.scope(v.tree.type)),O=l.firstChild();for(let z=0,ee=p;;z++){let te=z<v.overlay.length?v.overlay[z]:null,K=te?te.from+p:m,M=Math.max(r,ee),F=Math.min(c,K);if(M<F&&O)for(;l.from<F&&(this.highlightRange(l,M,F,o,d),this.startSpan(Math.min(F,l.to),x),!(l.to>=K||!l.nextSibling())););if(!te||K>c)break;ee=te.to+p,ee>r&&(this.highlightRange(E.cursor(),Math.max(r,te.from+p),Math.min(c,ee),"",k),this.startSpan(Math.min(c,ee),x))}O&&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),x)}while(l.nextSibling());l.parent()}}}function x1(s){let l=s.type.prop(sy);for(;l&&l.context&&!s.matchContext(l.context);)l=l.next;return l||null}const ve=ss.define,Ho=ve(),Ka=ve(),Qb=ve(Ka),Zb=ve(Ka),Fa=ve(),Bo=ve(Fa),bh=ve(Fa),zs=ve(),Ti=ve(zs),Rs=ve(),Ms=ve(),Hh=ve(),Jc=ve(Hh),Io=ve(),Te={comment:Ho,lineComment:ve(Ho),blockComment:ve(Ho),docComment:ve(Ho),name:Ka,variableName:ve(Ka),typeName:Qb,tagName:ve(Qb),propertyName:Zb,attributeName:ve(Zb),className:ve(Ka),labelName:ve(Ka),namespace:ve(Ka),macroName:ve(Ka),literal:Fa,string:Bo,docString:ve(Bo),character:ve(Bo),attributeValue:ve(Bo),number:bh,integer:ve(bh),float:ve(bh),bool:ve(Fa),regexp:ve(Fa),escape:ve(Fa),color:ve(Fa),url:ve(Fa),keyword:Rs,self:ve(Rs),null:ve(Rs),atom:ve(Rs),unit:ve(Rs),modifier:ve(Rs),operatorKeyword:ve(Rs),controlKeyword:ve(Rs),definitionKeyword:ve(Rs),moduleKeyword:ve(Rs),operator:Ms,derefOperator:ve(Ms),arithmeticOperator:ve(Ms),logicOperator:ve(Ms),bitwiseOperator:ve(Ms),compareOperator:ve(Ms),updateOperator:ve(Ms),definitionOperator:ve(Ms),typeOperator:ve(Ms),controlOperator:ve(Ms),punctuation:Hh,separator:ve(Hh),bracket:Jc,angleBracket:ve(Jc),squareBracket:ve(Jc),paren:ve(Jc),brace:ve(Jc),content:zs,heading:Ti,heading1:ve(Ti),heading2:ve(Ti),heading3:ve(Ti),heading4:ve(Ti),heading5:ve(Ti),heading6:ve(Ti),contentSeparator:ve(zs),list:ve(zs),quote:ve(zs),emphasis:ve(zs),strong:ve(zs),link:ve(zs),monospace:ve(zs),strikethrough:ve(zs),inserted:ve(),deleted:ve(),changed:ve(),invalid:ve(),meta:Io,documentMeta:ve(Io),annotation:ve(Io),processingInstruction:ve(Io),definition:ss.defineModifier("definition"),constant:ss.defineModifier("constant"),function:ss.defineModifier("function"),standard:ss.defineModifier("standard"),local:ss.defineModifier("local"),special:ss.defineModifier("special")};for(let s in Te){let l=Te[s];l instanceof ss&&(l.name=s)}ay([{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 y1="modulepreload",_1=function(s,l){return new URL(s,l).href},Kb={},Ve=function(l,r,c){let o=Promise.resolve();if(r&&r.length>0){let h=function(_){return Promise.all(_.map(j=>Promise.resolve(j).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const p=document.getElementsByTagName("link"),m=document.querySelector("meta[property=csp-nonce]"),x=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));o=h(r.map(_=>{if(_=_1(_,c),_ in Kb)return;Kb[_]=!0;const j=_.endsWith(".css"),v=j?'[rel="stylesheet"]':"";if(!!c)for(let O=p.length-1;O>=0;O--){const z=p[O];if(z.href===_&&(!j||z.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${_}"]${v}`))return;const k=document.createElement("link");if(k.rel=j?"stylesheet":y1,j||(k.as="script"),k.crossOrigin="",k.href=_,x&&k.setAttribute("nonce",x),document.head.appendChild(k),j)return new Promise((O,z)=>{k.addEventListener("load",O),k.addEventListener("error",()=>z(new Error(`Unable to preload CSS for ${_}`)))})}))}function d(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return o.then(h=>{for(const p of h||[])p.status==="rejected"&&d(p.reason);return l().catch(d)})},iy={js:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),cjs:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),mjs:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),jsx:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),ts:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),mts:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),cts:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),tsx:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-DM4oBLe8.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0,jsx:!0}),json:async()=>(await Ve(async()=>{const{json:s}=await import("./index-DXYp3jsl.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),jsonc:async()=>(await Ve(async()=>{const{json:s}=await import("./index-DXYp3jsl.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),css:async()=>(await Ve(async()=>{const{css:s}=await import("./index-Buinfinc.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),scss:async()=>(await Ve(async()=>{const{css:s}=await import("./index-Buinfinc.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),less:async()=>(await Ve(async()=>{const{css:s}=await import("./index-Buinfinc.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),html:async()=>(await Ve(async()=>{const{html:s}=await import("./index-rekQBGDD.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),htm:async()=>(await Ve(async()=>{const{html:s}=await import("./index-rekQBGDD.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),vue:async()=>(await Ve(async()=>{const{html:s}=await import("./index-rekQBGDD.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),svelte:async()=>(await Ve(async()=>{const{html:s}=await import("./index-rekQBGDD.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),md:async()=>(await Ve(async()=>{const{markdown:s}=await import("./index-BednlsnR.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),markdown:async()=>(await Ve(async()=>{const{markdown:s}=await import("./index-BednlsnR.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),py:async()=>(await Ve(async()=>{const{python:s}=await import("./index-CNdrabZC.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),pyi:async()=>(await Ve(async()=>{const{python:s}=await import("./index-CNdrabZC.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),yaml:async()=>(await Ve(async()=>{const{yaml:s}=await import("./index-CQlHFJzv.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),yml:async()=>(await Ve(async()=>{const{yaml:s}=await import("./index-CQlHFJzv.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),rs:async()=>(await Ve(async()=>{const{rust:s}=await import("./index-CPLRJruN.js");return{rust:s}},__vite__mapDeps([12,1,2,3,4]),import.meta.url)).rust(),c:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-DJPI4hL4.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),h:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-DJPI4hL4.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cc:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-DJPI4hL4.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cpp:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-DJPI4hL4.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),hpp:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-DJPI4hL4.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),java:async()=>(await Ve(async()=>{const{java:s}=await import("./index-CBtC705w.js");return{java:s}},__vite__mapDeps([14,1,2,3,4]),import.meta.url)).java(),go:async()=>(await Ve(async()=>{const{go:s}=await import("./index-DJN6swZl.js");return{go:s}},__vite__mapDeps([15,1,2,3,4,5]),import.meta.url)).go(),php:async()=>(await Ve(async()=>{const{php:s}=await import("./index-BiJkY5lu.js");return{php:s}},__vite__mapDeps([16,1,8,7,2,3,4,0,5]),import.meta.url)).php(),sql:async()=>(await Ve(async()=>{const{sql:s}=await import("./index-DG-5rv4t.js");return{sql:s}},__vite__mapDeps([17,2,3,4,1,5]),import.meta.url)).sql(),xml:async()=>(await Ve(async()=>{const{xml:s}=await import("./index-CmXpz6wO.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml(),svg:async()=>(await Ve(async()=>{const{xml:s}=await import("./index-CmXpz6wO.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml()},v1={".mcp.json":"json",dockerfile:"yaml",makefile:"yaml"},S1={javascript:"js",node:"js",typescript:"ts",python:"py",python3:"py",yml:"yaml",rust:"rs",golang:"go","c++":"cpp",cplusplus:"cpp"};async function j1(s){const l=S1[s.toLowerCase()]??s.toLowerCase(),r=iy[l];return r?r().catch(()=>null):null}async function k1(s){const l=(s.split("/").pop()??"").toLowerCase(),r=v1[l]??l.split(".").pop()??"",c=iy[r];return c?c().catch(()=>null):null}const w1=ay([{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 qo(s){return s.replace(/[&<>]/g,l=>l==="&"?"&":l==="<"?"<":">")}async function N1(s,l){const r=l?await j1(l):null;if(!r)return qo(s);try{const c=r.language.parser.parse(s);let o="";return g1(s,c,w1,(d,h)=>{o+=h?`<span class="${h}">${qo(d)}</span>`:qo(d)},()=>{o+=`
|
|
117
|
-
`}),o}catch{return qo(s)}}vt.setOptions({gfm:!0,breaks:!1});function ry(s){var r;const l=(r=s.split(".").pop())==null?void 0:r.toLowerCase();return l==="md"||l==="markdown"}async function tp(s){const l=await vt.parse(s,{async:!0,walkTokens:async r=>{if(r.type!=="code")return;const c=r;c.text=await N1(c.text,c.lang??""),c.escaped=!0}});return Kv.sanitize(l)}function Fb(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:ry(s.path)}}function ca(s){return!s.binary&&!s.tooLarge&&s.text!==s.saved}function T1(s){return s.split("/").pop()??s}function Ui(s){const l=s.lastIndexOf("/");return l===-1?"":s.slice(0,l)}function Wo(s){return s<1024?`${s} Б`:s<1024*1024?`${(s/1024).toFixed(1)} КБ`:`${(s/1024/1024).toFixed(1)} МБ`}function Mr({x:s,y:l,items:r,note:c,onClose:o}){const d=y.useRef(null),[h,p]=y.useState({left:s,top:l}),[m,x]=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(),k=8,O=Math.max(k,Math.min(s,window.innerWidth-E.width-k)),z=Math.max(k,Math.min(l,window.innerHeight-E.height-k));p({left:O,top:z})},[s,l]),y.useLayoutEffect(()=>{var v;(v=d.current)==null||v.focus()},[]),y.useLayoutEffect(()=>{function v(k){var O;(O=d.current)!=null&&O.contains(k.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 j(v){if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),o();return}const E=r.map((k,O)=>({item:k,index:O})).filter(k=>!k.item.disabled);if(E.length!==0){if(v.key==="ArrowDown"||v.key==="ArrowUp"){v.preventDefault();const k=v.key==="ArrowDown"?1:-1,O=E.findIndex(ee=>ee.index===m),z=E[(((O===-1?0:O)+k)%E.length+E.length)%E.length];z&&x(z.index);return}if(v.key==="Enter"||v.key===" "){v.preventDefault();const k=r[m];k&&_(k)}}}return i.jsxs("div",{ref:d,className:"ctxmenu",style:{left:h.left,top:h.top},role:"menu",tabIndex:-1,onKeyDown:j,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===m?" is-cursor":""),onMouseEnter:()=>x(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 E1=3500,A1=9e3,Jb=220;function qi({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 p=s.ok?E1:A1,m=setTimeout(()=>d(!0),p),x=setTimeout(()=>c(null),p+Jb);return()=>{clearTimeout(m),clearTimeout(x)}},[s]),!r)return null;const h=()=>{d(!0),setTimeout(()=>{c(null),l==null||l()},Jb)};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:p=>p.stopPropagation(),children:[r.url.replace(/^https?:\/\//,"")," ↗"]}),r.url&&l&&i.jsx("button",{type:"button",className:"oplog__dismiss",title:"Закрыть","aria-label":"Закрыть сообщение",onClick:h,children:"✕"})]})}function fa({value:s,className:l,placeholder:r="Название сессии",onCommit:c,onCancel:o}){const[d,h]=y.useState(s),p=y.useRef(null);y.useEffect(()=>{var x;(x=p.current)==null||x.select()},[]);function m(){const x=d.trim();if(!x||x===s)return o();c(x)}return i.jsx("input",{ref:p,className:l?`rename ${l}`:"rename",value:d,autoFocus:!0,spellCheck:!1,placeholder:r,onChange:x=>h(x.target.value),onBlur:m,onKeyDown:x=>{x.stopPropagation(),x.key==="Enter"?(x.preventDefault(),m()):x.key==="Escape"&&(x.preventDefault(),o())}})}function Zr({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 C1=500,Ei="application/x-ccv-fs-path",R1=200;function M1({open:s,tree:l,expanded:r,activePath:c,dirty:o,gitChanges:d,result:h,searchResult:p,onSearch:m,onReveal:x,onToggle:_,onOpen:j,onCreate:v,onRename:E,onMove:k,onCopy:O,onDelete:z,onRefresh:ee,onClose:te,zoomed:K,onToggleZoom:M}){const[F,H]=y.useState(""),[A,Z]=y.useState(null),[ae,G]=y.useState(null),[J,D]=y.useState(null),[ge,Se]=y.useState(null),[xe,B]=y.useState(null),[ue,se]=y.useState(null),be=uf("(hover: hover)"),Ce=y.useRef(null),w=y.useMemo(()=>L1(d),[d]);function Q(W){return!(!J||W===J.path||J.kind==="dir"&&W.startsWith(`${J.path}/`)||W===Ui(J.path))}function re(W){return!(!xe||W===xe.path||xe.kind==="dir"&&W.startsWith(`${xe.path}/`)||xe.mode==="cut"&&W===Ui(xe.path))}function oe(W){B({path:W.path,kind:W.kind,mode:"copy"})}function ye(W){B({path:W.path,kind:W.kind,mode:"cut"})}function je(W){!xe||!re(W)||(W&&!r.has(W)&&_(W),xe.mode==="cut"?(k(xe.path,W),B(null)):O(xe.path,W))}function Me(W,de){const we=W.touches[0];if(!we)return;const L={timer:0,x:we.clientX,y:we.clientY,el:W.currentTarget,fired:!1};L.timer=window.setTimeout(()=>{L.fired=!0,de(L.x,L.y,L.el)},C1),Ce.current=L}function ht(W){const de=Ce.current,we=W.touches[0];!de||!we||Math.hypot(we.clientX-de.x,we.clientY-de.y)>10&&(window.clearTimeout(de.timer),Ce.current=null)}function lt(W){const de=Ce.current;de&&(window.clearTimeout(de.timer),de.fired&&W.preventDefault())}function Nn(){var W;return(W=Ce.current)!=null&&W.fired?(Ce.current=null,!0):!1}function Je(W,de,we,L){H((L==null?void 0:L.path)??""),se({x:W,y:de,opener:we,entry:L})}function Kt(){const W=ue==null?void 0:ue.opener;se(null),W!=null&&W.isConnected&&W.focus()}function ct(W){return{onContextMenu:de=>{de.preventDefault(),Je(de.clientX,de.clientY,de.currentTarget,W)},onTouchStart:de=>Me(de,(we,L,V)=>Je(we,L,V,W)),onTouchMove:ht,onTouchEnd:lt,onTouchCancel:lt}}function rn(W){W.target===W.currentTarget&&(W.preventDefault(),Je(W.clientX,W.clientY,W.currentTarget,null))}function Be(W){W.target===W.currentTarget&&Me(W,(de,we,L)=>Je(de,we,L,null))}function rt(W){if(!(W.ctrlKey||W.metaKey)||W.target instanceof HTMLInputElement)return;const de=W.key.toLowerCase();if(de==="v"){W.preventDefault(),je(sl());return}if(!F)return;const we=Wb(l,F);we&&(de==="c"?(W.preventDefault(),oe(we)):de==="x"&&(W.preventDefault(),ye(we)))}function Hn(W){return de=>{de.dataTransfer.effectAllowed="move",de.dataTransfer.setData(Ei,W.path),D({path:W.path,kind:W.kind})}}function wt(){D(null),Se(null)}function Ot(W){return de=>{de.dataTransfer.types.includes(Ei)&&(de.stopPropagation(),!(W.kind!=="dir"||!Q(W.path))&&(de.preventDefault(),Se(W.path)))}}function Ft(W){return de=>{if(!de.dataTransfer.types.includes(Ei)||(de.stopPropagation(),W.kind!=="dir"||!Q(W.path)))return;de.preventDefault();const we=de.dataTransfer.getData(Ei);Se(null),we&&k(we,W.path)}}function tn(W){!W.dataTransfer.types.includes(Ei)||!Q("")||(W.preventDefault(),Se(""))}function $t(W){if(!W.dataTransfer.types.includes(Ei)||!Q(""))return;W.preventDefault();const de=W.dataTransfer.getData(Ei);Se(null),de&&k(de,"")}const[Nt,Qe]=y.useState(""),We=Nt.trim(),dn=We.length>0,Jt=y.useRef(null),Qt=y.useRef(m);Qt.current=m;function Bn(W){Qe(W),Jt.current&&clearTimeout(Jt.current);const de=W.trim();if(!de){Qt.current("");return}Jt.current=setTimeout(()=>Qt.current(de),R1)}function Tn(W){Jt.current&&clearTimeout(Jt.current),Qe(""),Qt.current(""),H(W.path),x(W)}const hn=dn&&(p==null?void 0:p.query)===We?p:null;function sl(){if(F==="")return"";const W=Wb(l,F);if((W==null?void 0:W.kind)==="dir")return F;const de=F.lastIndexOf("/");return de===-1?"":F.slice(0,de)}function zt(W,de){const we=de??sl();we&&!r.has(we)&&_(we),G({parent:we,kind:W})}function bt(){if(!ue)return[];const W=L=>be?L:void 0;if(!ue.entry)return[{id:"paste",label:"Вставить в корень проекта",hint:W("Ctrl+V"),disabled:!re(""),onSelect:()=>je("")},{id:"new-file",label:"Создать файл",onSelect:()=>zt("file","")},{id:"new-dir",label:"Создать каталог",onSelect:()=>zt("dir","")}];const de=ue.entry,we=[de.kind==="file"?{id:"open",label:"Открыть",onSelect:()=>j(de.path)}:{id:"toggle",label:r.has(de.path)?"Свернуть":"Развернуть",onSelect:()=>_(de.path)},{id:"copy",label:"Копировать",hint:W("Ctrl+C"),onSelect:()=>oe(de)},{id:"cut",label:"Вырезать",hint:W("Ctrl+X"),onSelect:()=>ye(de)}];return de.kind==="dir"&&(we.push({id:"paste",label:"Вставить",hint:W("Ctrl+V"),disabled:!re(de.path),onSelect:()=>je(de.path)}),we.push({id:"new-file",label:"Создать файл",onSelect:()=>zt("file",de.path)}),we.push({id:"new-dir",label:"Создать каталог",onSelect:()=>zt("dir",de.path)})),we.push({id:"rename",label:"Переименовать",onSelect:()=>Z(de.path)}),we.push({id:"delete",label:"Удалить",onSelect:()=>z(de)}),we}const Ut=dn?[]:$e("",0);function $e(W,de){const we=l[W],L=[];if(ae&&ae.parent===W&&L.push(i.jsxs("div",{className:"fsrow fsrow--draft",style:ua(de),children:[i.jsx("span",{className:"fsrow__icon",children:ae.kind==="dir"?i.jsx(af,{}):i.jsx(rf,{})}),i.jsx(fa,{className:"rename--file",value:"",placeholder:ae.kind==="dir"?"имя каталога":"имя файла",onCommit:V=>{G(null),v(W,ae.kind,V)},onCancel:()=>G(null)})]},`draft:${W}`)),!we)return L.push(i.jsx("p",{className:"fsrow__pending",style:ua(de),children:"читаем…"},`wait:${W}`)),L;we.length===0&&!ae&&L.push(i.jsx("p",{className:"fsrow__pending",style:ua(de),children:"пусто"},`empty:${W}`));for(const V of we){const _e=V.kind==="dir"&&r.has(V.path);L.push(A===V.path?i.jsxs("div",{className:"fsrow fsrow--draft",style:ua(de),children:[i.jsx("span",{className:"fsrow__icon",children:V.kind==="dir"?i.jsx(af,{open:_e}):i.jsx(rf,{})}),i.jsx(fa,{className:"rename--file",value:V.name,placeholder:"новое имя",onCommit:ze=>{Z(null),E(V.path,ze)},onCancel:()=>Z(null)})]},V.path):i.jsx(O1,{entry:V,depth:de,open:_e,active:V.path===c,selected:V.path===F,dirty:o.has(V.path),gitStatus:w.get(V.path),dragging:(J==null?void 0:J.path)===V.path,dropTarget:ge===V.path,cut:(xe==null?void 0:xe.mode)==="cut"&&xe.path===V.path,onClick:()=>{Nn()||(H(V.path),V.kind==="dir"?_(V.path):j(V.path))},onRename:()=>Z(V.path),onDelete:()=>z(V),onDragStart:Hn(V),onDragEnd:wt,onDragOver:Ot(V),onDrop:Ft(V),...ct(V)},V.path)),_e&&L.push(...$e(V.path,de+1))}return L}function Qn(){if(!hn)return[i.jsx("p",{className:"fsrow__pending",style:ua(0),children:"ищем…"},"search:wait")];if(hn.entries.length===0)return[i.jsx("p",{className:"fsrow__pending",style:ua(0),children:"ничего не найдено"},"search:empty")];const W=hn.entries.map(de=>i.jsx(D1,{entry:de,gitStatus:w.get(de.path),onClick:()=>Tn(de)},de.path));return hn.truncated&&W.push(i.jsxs("p",{className:"fsrow__pending",style:ua(0),children:["показаны первые ",hn.entries.length," — уточните запрос"]},"search:truncated")),W}return i.jsxs("aside",{className:(s?"sidepane sidepane--files sidepane--open":"sidepane sidepane--files")+(K?" sidepane--zoomed":""),"aria-label":"Файлы проекта",onKeyDown:rt,children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:W=>{M&&(W.target.closest("button")||M())},children:[i.jsx(B1,{}),i.jsx("span",{className:"sidepane__title",children:"Файлы"}),i.jsx("button",{className:"sidepane__btn",title:"Новый файл","aria-label":"Новый файл",onClick:()=>zt("file"),children:i.jsx(U1,{})}),i.jsx("button",{className:"sidepane__btn",title:"Новый каталог","aria-label":"Новый каталог",onClick:()=>zt("dir"),children:i.jsx(H1,{})}),i.jsx("button",{className:"sidepane__btn",title:"Перечитать дерево","aria-label":"Перечитать дерево",onClick:ee,children:"↻"}),M&&i.jsx("button",{className:"sidepane__btn",title:K?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":K?"Свернуть панель файлов":"Развернуть панель файлов на весь экран","aria-pressed":K,onClick:M,children:i.jsx(Zr,{active:K})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель файлов",onClick:te,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(I1,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:Nt,spellCheck:!1,placeholder:"Поиск файлов и папок…","aria-label":"Поиск файлов и папок",onChange:W=>Bn(W.target.value),onKeyDown:W=>{W.stopPropagation(),W.key==="Escape"&&(W.preventDefault(),Nt?Bn(""):W.currentTarget.blur())}}),Nt&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>Bn(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree"+(ge===""?" fstree--drop-target":""),tabIndex:-1,onDragOver:tn,onDrop:$t,onContextMenu:rn,onTouchStart:Be,onTouchMove:ht,onTouchEnd:lt,onTouchCancel:lt,children:dn?Qn():Ut}),i.jsx(qi,{result:h}),ue&&i.jsx(Mr,{x:ue.x,y:ue.y,items:bt(),onClose:Kt})]})}function O1({entry:s,depth:l,open:r,active:c,selected:o,dirty:d,gitStatus:h,dragging:p,dropTarget:m,cut:x,onClick:_,onRename:j,onDelete:v,onDragStart:E,onDragEnd:k,onDragOver:O,onDrop:z,onContextMenu:ee,onTouchStart:te,onTouchMove:K,onTouchEnd:M,onTouchCancel:F}){const H="fsrow"+(c?" is-open":"")+(o&&!c?" is-selected":"")+(s.ignored?" fsrow--ignored":"")+(p?" fsrow--dragging":"")+(m?" fsrow--drop-target":"")+(x?" fsrow--cut":"");return i.jsxs("div",{className:H,style:ua(l),draggable:!0,onDragStart:E,onDragEnd:k,onDragOver:O,onDrop:z,onContextMenu:ee,onTouchStart:te,onTouchMove:K,onTouchEnd:M,onTouchCancel:F,children:[i.jsxs("button",{className:"fsrow__main",onClick:_,title:cy(s),children:[i.jsx("span",{className:"fsrow__icon"+sf("fsrow__icon",h),children:s.kind==="dir"?i.jsx(af,{open:r}):i.jsx(rf,{})}),i.jsx("span",{className:"fsrow__name"+sf("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:j,children:"✎"}),i.jsx("button",{className:"fsrow__act",title:"Удалить","aria-label":`Удалить ${s.name}`,onClick:v,children:"✕"})]})}function D1({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:ua(0),onClick:r,title:cy(s),children:[i.jsx("span",{className:"fsrow__icon"+sf("fsrow__icon",l),children:s.kind==="dir"?i.jsx(af,{}):i.jsx(rf,{})}),i.jsx("span",{className:"fsrow__name"+sf("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 cy(s){return s.ignored?`${s.path} — игнорируется git (.gitignore)`:s.path}function ua(s){return{"--depth":s}}function Wb(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 L1(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=z1(o.status);if(!d)continue;c(o.path,d);let h=Ui(o.path);for(;c(h,d),!!h;)h=Ui(h)}return l}function z1(s){if(s==="??")return"added";const[l="",r=""]=s;return l==="A"||l==="R"||l==="C"?"added":l==="M"||r==="M"?"modified":null}function sf(s,l){return l?` ${s}--git-${l}`:""}function af({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 rf(){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 U1(){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 H1(){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 B1(){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 I1(){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 q1=200;function G1({open:s,result:l,onSearch:r,onOpenMatch:c,onClose:o,zoomed:d,onToggleZoom:h}){const[p,m]=y.useState(""),x=p.trim(),_=x.length>0,j=y.useRef(null),v=y.useRef(r);v.current=r;function E(z){m(z),j.current&&clearTimeout(j.current);const ee=z.trim();if(!ee){v.current("");return}j.current=setTimeout(()=>v.current(ee),q1)}const k=_&&(l==null?void 0:l.query)===x?l:null;function O(){if(!k)return[i.jsx("p",{className:"fsrow__pending",children:"ищем…"},"grep:wait")];if(k.matches.length===0)return[i.jsx("p",{className:"fsrow__pending",children:"ничего не найдено"},"grep:empty")];const z=[];let ee="";for(const te of k.matches)te.path!==ee&&(ee=te.path,z.push(i.jsx("p",{className:"searchgroup__path",title:te.path,children:te.path},`path:${te.path}`))),z.push(i.jsx(Y1,{match:te,onClick:()=>c(te)},`${te.path}:${te.line}:${te.column}`));return k.truncated&&z.push(i.jsxs("p",{className:"fsrow__pending",children:["показаны первые ",k.matches.length," — уточните запрос"]},"grep:truncated")),z}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:z=>{h&&(z.target.closest("button")||h())},children:[i.jsx(X1,{}),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(Zr,{active:d})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель поиска",onClick:o,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(V1,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:p,spellCheck:!1,placeholder:"Поиск по тексту во всех файлах…","aria-label":"Поиск по тексту во всех файлах",onChange:z=>E(z.target.value),onKeyDown:z=>{z.stopPropagation(),z.key==="Escape"&&(z.preventDefault(),p?E(""):z.currentTarget.blur())}}),p&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>E(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree",children:_?O():i.jsx("p",{className:"sidepane__empty",children:"Введите текст, чтобы найти его во всех файлах проекта."})})]})}function Y1({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 X1(){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 V1(){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 Go=null;function $1(){return Go||(Go=Promise.all([Ve(()=>import("./index-DSzfAcOE.js"),__vite__mapDeps([19,4,3,2,20,5]),import.meta.url),Ve(()=>import("./index-891wE-Rj.js").then(s=>s.v),__vite__mapDeps([4,3]),import.meta.url),Ve(()=>import("./index-BHot-lnj.js"),[],import.meta.url),Ve(()=>import("./index-DNppE7jj.js"),__vite__mapDeps([20,3,4,2]),import.meta.url),Ve(()=>import("./codemirror-Byu5BOry.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 Go=null,s})),Go}function Q1({path:s,doc:l,revision:r,goto:c,onChange:o,onSave:d}){const h=y.useRef(null),p=y.useRef(null),m=y.useRef(null),x=y.useRef(new Map),_=y.useRef(new Map),j=y.useRef(new Set),v=y.useRef(null),E=y.useRef(o),k=y.useRef(d),O=y.useRef(s),z=y.useRef(r),ee=y.useRef(l);E.current=o,k.current=d,O.current=s,z.current=r,ee.current=l;const[te,K]=y.useState("loading"),[M,F]=y.useState(!1);function H(Z,ae,G,J,D){const ge=x.current.get(J),Se=_.current.get(J)===D;if(ge&&Se)G.setState(ge);else{const B=Z.EditorState.create({doc:ee.current,extensions:[Z.basicSetup,Z.Prec.highest(Z.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(k.current(O.current),!0)}])),Z.keymap.of([Z.indentWithTab]),ae.of([]),Z.editorTheme,Z.editorHighlight,Z.EditorView.updateListener.of(ue=>{ue.docChanged&&E.current(O.current,ue.state.doc.toString())})]});x.current.set(J,B),_.current.set(J,D),G.setState(B),j.current.delete(J)}if(j.current.has(J))return()=>{};let xe=!1;return k1(J).then(B=>{xe||!B||O.current!==J||(G.dispatch({effects:ae.reconfigure(B)}),x.current.set(J,G.state),j.current.add(J))}),()=>{xe=!0}}y.useEffect(()=>{if(!h.current)return;let ae=!1,G=null,J=null;K("loading"),F(!1);const D=window.setTimeout(()=>{ae||F(!0)},200);return(async()=>{let ge;try{ge=await $1()}catch{window.clearTimeout(D),ae||K("error");return}if(ae||!h.current)return;window.clearTimeout(D);const Se=new ge.Compartment;v.current=Se,m.current=ge,J=new ge.EditorView({parent:h.current}),p.current=J,G=H(ge,Se,J,O.current,z.current),K("ready")})(),()=>{ae=!0,window.clearTimeout(D),G==null||G(),J==null||J.destroy(),p.current===J&&(p.current=null),m.current=null,v.current=null}},[]),y.useEffect(()=>{const Z=m.current,ae=p.current,G=v.current;if(!(!Z||!ae||!G))return H(Z,G,ae,s,r)},[s,r]);const A=y.useRef(0);return y.useEffect(()=>{const Z=p.current,ae=m.current;if(!Z||!ae||!c||c.token===A.current)return;A.current=c.token;const G=Z.state.doc.lines,J=Math.min(Math.max(c.line,1),G),D=Z.state.doc.line(J),ge=Math.min(D.from+Math.max(c.column-1,0),D.to);Z.dispatch({selection:ae.EditorSelection.cursor(ge),effects:ae.EditorView.scrollIntoView(ge,{y:"center"})}),Z.focus()},[c]),y.useEffect(()=>()=>{const Z=p.current;Z&&x.current.set(s,Z.state)},[s]),i.jsxs("div",{className:"editor__code",children:[i.jsx("div",{ref:h,className:"editor__code-surface"+(te==="ready"?"":" is-hidden")}),te==="loading"&&M&&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:"Загружается редактор…"})]}),te==="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 Is({value:s,options:l,onChange:r,className:c,title:o,ariaLabel:d,placeholder:h="—"}){const[p,m]=y.useState(!1),[x,_]=y.useState(0),j=y.useRef(null),v=y.useRef(null),E=l.find(z=>z.value===s)??null;y.useEffect(()=>{if(!p)return;const z=l.findIndex(ee=>ee.value===s);_(z===-1?0:z)},[p]),y.useEffect(()=>{if(!p)return;function z(ee){var te;(te=j.current)!=null&&te.contains(ee.target)||m(!1)}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[p]),y.useEffect(()=>{var z,ee;p&&((ee=(z=v.current)==null?void 0:z.querySelector(".is-cursor"))==null||ee.scrollIntoView({block:"nearest"}))},[p,x]),y.useEffect(()=>{if(!p)return;const z=v.current,ee=Z1(j.current);if(!z||!ee)return;const te=z.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;te>0&&(ee.scrollTop+=Math.min(te+8,z.offsetHeight))},[p]);function k(z){m(!1),z.value!==s&&r(z.value)}function O(z){if(z.key==="Escape"){if(!p)return;z.preventDefault(),z.stopPropagation(),m(!1);return}if(z.key==="ArrowDown"||z.key==="ArrowUp"){if(z.preventDefault(),!p)return m(!0);const ee=z.key==="ArrowDown"?1:l.length-1;return _(te=>(te+ee)%l.length)}if(z.key==="Enter"||z.key===" "){if(z.preventDefault(),!p)return m(!0);const ee=l[x];ee&&k(ee)}}return i.jsxs("div",{ref:j,className:"select"+(p?" select--open":"")+(c?` ${c}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:o,"aria-label":d??o,"aria-haspopup":"listbox","aria-expanded":p,onClick:()=>m(z=>!z),onKeyDown:O,children:[i.jsx("span",{className:"select__value",children:(E==null?void 0:E.label)??h}),i.jsx(K1,{})]}),p&&i.jsx("div",{ref:v,className:"select__menu",role:"listbox","aria-label":d??o,children:l.map((z,ee)=>i.jsxs("button",{type:"button",role:"option","aria-selected":z.value===s,className:"select__option"+(ee===x?" is-cursor":"")+(z.value===s?" is-on":""),onMouseEnter:()=>_(ee),onClick:()=>k(z),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:z.value===s?"✓":""}),i.jsx("span",{className:"select__label",children:z.label}),z.hint&&i.jsx("span",{className:"select__hint",children:z.hint})]},z.value))})]})}function Z1(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 K1(){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 F1(){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 J1(){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 W1(){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 P1({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 p=eS(r,l);return o?i.jsx("div",{className:"mediaview mediaview--message",children:i.jsxs("p",{className:"mediaview__error",children:["Файл слишком велик для просмотра (",Wo(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:"Повторить"})]}):p?l.startsWith("image/")?i.jsx(nS,{url:p}):l.startsWith("video/")?i.jsx(sS,{url:p}):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 eS(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 p=0;p<o.length;p++)d[p]=o.charCodeAt(p);const h=URL.createObjectURL(new Blob([d],{type:l}));return c(h),()=>URL.revokeObjectURL(h)},[s,l]),r}const Za=1,uy=8,Yo=1.25;function tS(s){return Math.min(uy,Math.max(Za,s))}function nS({url:s}){const[l,r]=y.useState({scale:Za,x:0,y:0}),[c,o]=y.useState(!1),d=y.useRef(null),h=y.useRef(null);function p(E,k,O){r(z=>{const ee=tS(z.scale*E);if(ee===z.scale)return z;if(ee<=Za)return{scale:Za,x:0,y:0};const te=(k-z.x)/z.scale,K=(O-z.y)/z.scale;return{scale:ee,x:k-ee*te,y:O-ee*K}})}y.useEffect(()=>{const E=d.current;if(!E)return;function k(O){O.preventDefault();const z=E.getBoundingClientRect(),ee=O.clientX-z.left-z.width/2,te=O.clientY-z.top-z.height/2;p(O.deltaY<0?Yo:1/Yo,ee,te)}return E.addEventListener("wheel",k,{passive:!1}),()=>E.removeEventListener("wheel",k)},[]);function m(E){l.scale<=Za||(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 x(E){const k=h.current;!k||k.pointerId!==E.pointerId||r(O=>({...O,x:k.origX+(E.clientX-k.startX),y:k.origY+(E.clientY-k.startY)}))}function _(){h.current=null,o(!1)}const j=l.scale>Za,v=!j&&l.x===0&&l.y===0;return i.jsxs("div",{className:"mediaview mediaview--image",children:[i.jsx("div",{ref:d,className:"mediaview__stage"+(j?c?" is-dragging":" is-zoomed":""),onPointerDown:m,onPointerMove:x,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<=Za,title:"Уменьшить","aria-label":"Уменьшить",onClick:()=>p(1/Yo,0,0),children:i.jsx(J1,{})}),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:()=>p(Yo,0,0),children:i.jsx(F1,{})}),i.jsx("button",{className:"btn btn--sm",disabled:v,title:"Вписать в окно","aria-label":"Сбросить масштаб — вписать в окно",onClick:()=>r({scale:Za,x:0,y:0}),children:i.jsx(W1,{})})]})]})}const lS=[{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 sS({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(Is,{className:"mediaview__speedselect",value:r,onChange:c,ariaLabel:"Скорость воспроизведения",options:lS})]})]})}function aS({file:s,goto:l,onChange:r,onSave:c,onReload:o,onOverwrite:d,onRequestMedia:h,onTogglePreview:p}){const m=ca(s),x=ry(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:[Wo(s.size),s.eol==="crlf"&&" · CRLF"]}),x&&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&&p(s.path),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(s.previewMode?"":" is-on"),role:"tab","aria-selected":!s.previewMode,onClick:()=>s.previewMode&&p(s.path),children:"Код"})]}),i.jsx("button",{className:"btn btn--sm",disabled:!m,title:"Сохранить (Ctrl+S)",onClick:()=>c(s.path),children:m?"Сохранить":"Сохранено"})]}),s.stale&&i.jsxs("div",{className:"editor__warn",children:[i.jsxs("span",{children:["Файл изменился на диске",m?" — а здесь есть несохранённые правки.":"."]}),i.jsx("button",{className:"btn btn--sm",onClick:()=>o(s.path),children:"Взять с диска"}),m&&i.jsx("button",{className:"btn btn--sm btn--danger",onClick:()=>d(s.path),children:"Сохранить поверх"})]}),s.binary&&s.mediaMime?i.jsx(P1,{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:["Это не текстовый файл — редактировать его здесь нечем. ",Wo(s.size)," на диске."]}):s.tooLarge?i.jsxs("p",{className:"editor__empty",children:["Файл слишком велик для редактора (",Wo(s.size),"). Такие правит агент, а не браузер."]}):x&&s.previewMode?i.jsx(iS,{text:s.text}):i.jsx(Q1,{path:s.path,doc:s.text,revision:s.revision,goto:l,onChange:r,onSave:c})]})}function iS({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return tp(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:l}})}function rS({files:s,activePath:l,busy:r,onSelect:c,onClose:o,zoomed:d,onToggleZoom:h}){return i.jsxs("div",{className:"worktabs",role:"tablist",onDoubleClick:p=>{h&&(p.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(p=>i.jsxs("div",{className:"worktab"+(p.path===l?" is-on":""),role:"tab","aria-selected":p.path===l,onDoubleClick:m=>{h&&(m.target.closest(".worktab__close, .worktab__dot")||h())},children:[i.jsx("button",{className:"worktab__name",title:p.path,onClick:()=>c(p.path),children:T1(p.path)}),ca(p)?i.jsx("button",{className:"worktab__dot",title:"Не сохранено — закрыть","aria-label":`Закрыть ${p.path}`,onClick:()=>o(p.path)}):i.jsx("button",{className:"worktab__close",title:"Закрыть","aria-label":`Закрыть ${p.path}`,onClick:()=>o(p.path),children:"✕"})]},p.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(Zr,{active:d})})]})}const oy="ccv:sidebar.collapsed",fy="ccv:sidebar.mode",dy="ccv:sidebar.foldersCollapsed",cS=500,Pb="транскрипт остаётся на диске — сессию можно вернуть из архива в любой момент.";function uS({open:s,connected:l,status:r,workspaces:c,archivedWorkspaces:o,workspaceFolders:d,sessionFolders:h,pinnedFolders:p,sessions:m,archived:x,pinned:_,activeWorkspaceId:j,activeSessionId:v,onSelectWorkspace:E,onSelectSession:k,onRenameSession:O,onPinSessions:z,onSelectPinned:ee,onCloseWorkspaces:te,onRestoreWorkspaces:K,onArchiveSessions:M,onUnarchiveSessions:F,onCreateFolder:H,onRenameFolder:A,onDeleteFolder:Z,onAssignToFolder:ae,onOpenWorkspace:G,onNewSession:J,onOpenExtensions:D,account:ge,onOpenAccount:Se,relay:xe,onOpenRelay:B,onOpenSettings:ue,themeMode:se,onCycleTheme:be}){const[Ce,w]=y.useState(null),[Q,re]=y.useState(null),[oe,ye]=y.useState(null),[je,Me]=y.useState(""),[ht,lt]=y.useState(xS),[Nn,Je]=y.useState(yS),[Kt,ct]=y.useState(_S);function rn(){ct(T=>{const he=T==="pinned"?"default":"pinned";try{localStorage.setItem(fy,he)}catch{}return he})}const Be=je.trim().toLowerCase(),rt=Be!=="",Hn=y.useMemo(()=>rt?c.filter(T=>T.name.toLowerCase().includes(Be)||T.path.toLowerCase().includes(Be)):c,[c,Be,rt]),wt=y.useMemo(()=>rt?o.filter(T=>T.name.toLowerCase().includes(Be)||T.path.toLowerCase().includes(Be)):o,[o,Be,rt]),Ot=y.useMemo(()=>rt?m.filter(T=>(T.title??"").toLowerCase().includes(Be)):m,[m,Be,rt]),Ft=y.useMemo(()=>rt?x.filter(T=>(T.title??"").toLowerCase().includes(Be)):x,[x,Be,rt]),tn=T=>{var he;return((he=c.find(Ge=>Ge.id===T))==null?void 0:he.name)??"—"},$t=T=>{var he;return(he=c.find(Ge=>Ge.id===T))==null?void 0:he.path},Nt=y.useMemo(()=>rt?_.filter(T=>(T.title??"").toLowerCase().includes(Be)||tn(T.workspaceId).toLowerCase().includes(Be)):_,[_,c,Be,rt]);function Qe(T){lt(he=>{const Ge=he.includes(T)?he.filter(pt=>pt!==T):[...he,T];try{localStorage.setItem(oy,JSON.stringify(Ge))}catch{}return Ge})}const We=T=>!ht.includes(T);function dn(T){Je(he=>{const Ge=he.includes(T)?he.filter(pt=>pt!==T):[...he,T];try{localStorage.setItem(dy,JSON.stringify(Ge))}catch{}return Ge})}const Jt=T=>!Nn.includes(T),Qt=y.useMemo(()=>Wc(Hn,d),[Hn,d]),Bn=y.useMemo(()=>Wc(wt,d),[wt,d]),Tn=y.useMemo(()=>Wc(Ot,h),[Ot,h]),hn=y.useMemo(()=>Wc(Ft,h),[Ft,h]),sl=y.useMemo(()=>Wc(Nt,p,T=>T.pinnedFolderId),[Nt,p]),zt=yh(Hn),bt=yh(wt),Ut=yh(Ot),[$e,Qn]=y.useState(null),[W,de]=y.useState(null),[we,L]=y.useState(null),[V,_e]=y.useState(null),ze=y.useRef(null);function st(T,he){const Ge=T.touches[0];if(!Ge)return;const pt={timer:0,x:Ge.clientX,y:Ge.clientY,el:T.currentTarget,fired:!1};pt.timer=window.setTimeout(()=>{pt.fired=!0,he(pt.x,pt.y,pt.el)},cS),ze.current=pt}function al(T){const he=ze.current,Ge=T.touches[0];!he||!Ge||Math.hypot(Ge.clientX-he.x,Ge.clientY-he.y)>10&&(window.clearTimeout(he.timer),ze.current=null)}function Pe(T){const he=ze.current;he&&(window.clearTimeout(he.timer),he.fired&&T.preventDefault())}function En(){var T;return(T=ze.current)!=null&&T.fired?(ze.current=null,!0):!1}function In(){const T=$e==null?void 0:$e.opener;Qn(null),T!=null&&T.isConnected&&T.focus()}function $l(){const T=W==null?void 0:W.opener;de(null),T!=null&&T.isConnected&&T.focus()}function da(){const T=we==null?void 0:we.opener;L(null),T!=null&&T.isConnected&&T.focus()}function qs(){const T=V==null?void 0:V.opener;_e(null),T!=null&&T.isConnected&&T.focus()}function Ll(T){return{onContextMenu:he=>{he.preventDefault(),Qn({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:zt.targetsFor(T)})},onTouchStart:he=>st(he,(Ge,pt,un)=>Qn({x:Ge,y:pt,opener:un,ids:zt.targetsFor(T)})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}function qn(T){return{onContextMenu:he=>{he.preventDefault(),de({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:bt.targetsFor(T)})},onTouchStart:he=>st(he,(Ge,pt,un)=>de({x:Ge,y:pt,opener:un,ids:bt.targetsFor(T)})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}function pl(T){return{onContextMenu:he=>{he.preventDefault(),L({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:Ut.targetsFor(T)})},onTouchStart:he=>st(he,(Ge,pt,un)=>L({x:Ge,y:pt,opener:un,ids:Ut.targetsFor(T)})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}function nn(T){return{onContextMenu:he=>{he.preventDefault(),_e({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:[T.id]})},onTouchStart:he=>st(he,(Ge,pt,un)=>_e({x:Ge,y:pt,opener:un,ids:[T.id]})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}const _l=m.filter(T=>T.state!=="closed").length,Gn=$e?Hn.find(T=>T.id===$e.ids[0]):void 0,Ht=$e?[{id:"close",label:$e.ids.length>1?`Закрыть проекты (${$e.ids.length})`:"Закрыть проект",onSelect:()=>{te($e.ids),zt.clear()}},...Pc({folders:d,ids:$e.ids,hasFolder:(Gn==null?void 0:Gn.folderId)!=null,assign:(T,he)=>ae("workspace",T,he),onClear:()=>zt.clear(),onNewFolder:()=>ye("workspace")})]:[],Ze=$e?"закрытие не удаляет проект: каталог и история сессий остаются на диске — открыть его снова можно кнопкой «+ Проект»."+(j&&$e.ids.includes(j)&&_l>0?` в нём сейчас незавершённых сессий: ${_l} — при закрытии они остановятся на хосте.`:""):void 0,ln=W?wt.find(T=>T.id===W.ids[0]):void 0,is=W?[{id:"restore",label:W.ids.length>1?`Вернуть проекты (${W.ids.length})`:"Вернуть проект",onSelect:()=>{K(W.ids),bt.clear()}},...Pc({folders:d,ids:W.ids,hasFolder:(ln==null?void 0:ln.folderId)!=null,assign:(T,he)=>ae("workspace",T,he),onClear:()=>bt.clear(),onNewFolder:()=>ye("workspace")})]:[],An=W?"каталог и история сессий всё это время оставались на диске — восстановление их не трогает.":void 0,Cn=we?Ot.find(T=>T.id===we.ids[0]):void 0,zl=(Cn==null?void 0:Cn.pinned)!==!0,vl=we?[...we.ids.length===1?[{id:"rename",label:"Переименовать",onSelect:()=>w(we.ids[0])}]:[],{id:"pin",label:zl?we.ids.length>1?`Закрепить (${we.ids.length})`:"Закрепить":we.ids.length>1?`Открепить (${we.ids.length})`:"Открепить",onSelect:()=>{Cn&&z(Cn.workspaceId,we.ids,zl),Ut.clear()}},{id:"archive",label:we.ids.length>1?`Убрать в архив (${we.ids.length})`:"Убрать в архив",onSelect:()=>{M(j,we.ids),Ut.clear()}},...Pc({folders:h,ids:we.ids,hasFolder:(Cn==null?void 0:Cn.folderId)!=null,assign:(T,he)=>ae("session",T,he,j),onClear:()=>Ut.clear(),onNewFolder:()=>ye("session")})]:[],ys=we?Pb:void 0,It=V?Nt.find(T=>T.id===V.ids[0]):void 0,Ql=V?[{id:"rename",label:"Переименовать",onSelect:()=>w(V.ids[0])},{id:"unpin",label:"Открепить",onSelect:()=>{It&&z(It.workspaceId,[It.id],!1)}},{id:"archive",label:"Убрать в архив",onSelect:()=>{It&&M(It.workspaceId,[It.id])}},...It&&It.workspaceId===j?Pc({folders:h,ids:[It.id],hasFolder:It.folderId!=null,assign:(T,he)=>ae("session",T,he,It.workspaceId),onClear:()=>{},onNewFolder:()=>ye("session")}):[],...oS(It?Pc({folders:p,ids:[It.id],hasFolder:It.pinnedFolderId!=null,assign:(T,he)=>ae("pinned",T,he),onClear:()=>{},onNewFolder:()=>ye("pinned")}):[])]:[];function Zl(T){return i.jsx("div",{className:xh(T.id===j,zt.selected.includes(T.id)),...Ll(T),children:i.jsxs("button",{className:"row__main",onClick:he=>{En()||zt.click(he,T,()=>E(T.id))},children:[i.jsxs("span",{className:"row__title",children:[T.name,T.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",title:T.path,children:T.path})]})},T.id)}function pn(T){return i.jsxs("div",{className:xh(T.id===j,bt.selected.includes(T.id)),...qn(T),children:[i.jsxs("button",{className:"row__main",onClick:he=>{En()||bt.click(he,T,()=>E(T.id))},children:[i.jsxs("span",{className:"row__title",children:[T.name,T.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",children:TS(T)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть проект из архива",onClick:()=>K([T.id]),children:"Вернуть"})]},T.id)}function Tt(T){return i.jsx("div",{className:xh(T.id===v,Ut.selected.includes(T.id)),...Ce===T.id?{}:pl(T),children:Ce===T.id?i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:T.title??"",onCommit:he=>{O(T,he),w(null)},onCancel:()=>w(null)})}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"row__main",onClick:he=>{En()||Ut.click(he,T,()=>k(T))},children:[i.jsx(_h,{title:T.title??"Без названия",pinned:T.pinned===!0,projectName:tn(T.workspaceId),projectPath:$t(T.workspaceId)}),i.jsx(nx,{session:T,tail:new Date(T.updatedAt).toLocaleString()})]}),i.jsx("button",{className:"row__edit",title:"Переименовать","aria-label":"Переименовать сессию",onClick:()=>{En()||w(T.id)},children:"✎"})]})},T.id)}function Yn(T){return i.jsxs("div",{className:T.id===v?"row row--active":"row",children:[i.jsxs("button",{className:"row__main",onClick:()=>k(T),children:[i.jsx(_h,{title:T.title??"Без названия",pinned:!1,projectName:tn(T.workspaceId),projectPath:$t(T.workspaceId)}),i.jsx("span",{className:"row__meta",children:NS(T)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть сессию из архива",onClick:()=>F([T.id]),children:"Вернуть"})]},T.id)}function Gs(T){return i.jsx("div",{className:T.id===v?"row row--active":"row",...Ce===T.id?{}:{title:"Действия со строкой — правый клик или долгое нажатие",...nn(T)},children:Ce===T.id?i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:T.title??"",onCommit:he=>{O(T,he),w(null)},onCancel:()=>w(null)})}):i.jsxs("button",{className:"row__main",onClick:()=>{En()||ee(T)},children:[i.jsx(_h,{title:T.title??"Без названия",pinned:!1,projectName:tn(T.workspaceId),projectPath:$t(T.workspaceId)}),i.jsx(nx,{session:T,tail:new Date(T.updatedAt).toLocaleString()})]})},T.id)}function cn(T,he){return i.jsx(mS,{folder:T,count:he,open:Jt(T.id),renaming:Q===T.id,onToggle:()=>dn(T.id),onStartRename:()=>re(T.id),onCommitRename:Ge=>{A(T.id,Ge),re(null)},onCancelRename:()=>re(null),onDelete:()=>Z(T.id)},T.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","aria-pressed":Kt==="pinned",title:Kt==="pinned"?"Показать все проекты и сессии":"Показать только закреплённые","aria-label":Kt==="pinned"?"Панель закреплённых сессий включена. Показать все проекты и сессии":"Показать только закреплённые сессии",onClick:rn,children:i.jsx(py,{})}),i.jsx("button",{className:"theme-btn",title:`Тема: ${tx[se]}`,"aria-label":`Тема: ${tx[se]}. Переключить`,onClick:be,children:i.jsx(vS,{mode:se})})]}),i.jsxs("div",{className:"fssearch fssearch--sidebar",children:[i.jsx(gS,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:je,spellCheck:!1,placeholder:"Проект или сессия…","aria-label":"Поиск по проектам и сессиям",onChange:T=>Me(T.target.value),onKeyDown:T=>{T.stopPropagation(),T.key==="Escape"&&(T.preventDefault(),je?Me(""):T.currentTarget.blur())}}),je&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>Me(""),children:"✕"})]}),i.jsx("div",{className:"sidebar__scroll",children:Kt==="pinned"?i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Закреплённые",count:Nt.length,open:We("pinned"),onToggle:()=>Qe("pinned"),action:{label:"Новая папка закреплённых",onClick:()=>{ye("pinned"),We("pinned")||Qe("pinned")}}}),We("pinned")&&i.jsxs(i.Fragment,{children:[oe==="pinned"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:"",placeholder:"Название папки",onCommit:T=>{H("pinned",T),ye(null)},onCancel:()=>ye(null)})})}),Nt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"закрепите сессию через её меню (правый клик или долгое нажатие) — она останется под рукой из любого проекта"})}),sl.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Gs(he))]},T.folder.id)),sl.ungrouped.map(T=>Gs(T))]})]}):i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Проекты",count:Hn.length,open:We("workspaces"),onToggle:()=>Qe("workspaces"),action:{label:"Новая папка проектов",onClick:()=>{ye("workspace"),We("workspaces")||Qe("workspaces")}}}),We("workspaces")&&i.jsxs(i.Fragment,{children:[oe==="workspace"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:"",placeholder:"Название папки",onCommit:T=>{H("workspace",T),ye(null)},onCancel:()=>ye(null)})})}),Hn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока ни одного"})}),Qt.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Zl(he))]},T.folder.id)),Qt.ungrouped.map(T=>Zl(T))]}),o.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Архив проектов",count:wt.length,open:We("workspacesArchive"),onToggle:()=>Qe("workspacesArchive"),hint:"проект закрывают вручную; каталог и история сессий остаются на диске и открываются заново отсюда или через «+ Проект»"}),We("workspacesArchive")&&i.jsxs(i.Fragment,{children:[wt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока пусто"})}),Bn.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>pn(he))]},T.folder.id)),Bn.ungrouped.map(T=>pn(T))]})]}),j&&i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Сессии",count:Ot.length,open:We("sessions"),onToggle:()=>Qe("sessions"),action:{label:"Новая папка сессий",onClick:()=>{ye("session"),We("sessions")||Qe("sessions")}}}),We("sessions")&&i.jsxs(i.Fragment,{children:[oe==="session"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:"",placeholder:"Название папки",onCommit:T=>{H("session",T,j),ye(null)},onCancel:()=>ye(null)})})}),Ot.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока ни одной"})}),Tn.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Tt(he))]},T.folder.id)),Tn.ungrouped.map(T=>Tt(T))]}),x.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Архив",count:Ft.length,open:We("archive"),onToggle:()=>Qe("archive"),hint:"сессии без обращения дольше двух суток уезжают сюда сами; ничего не удаляется"}),We("archive")&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:"сюда сами уезжают сессии без обращения дольше двух суток; транскрипт остаётся на диске, ничего не удаляется"})}),Ft.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока пусто"})}),hn.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Yn(he))]},T.folder.id)),hn.ungrouped.map(T=>Yn(T))]})]})]})]})}),i.jsxs("div",{className:"sidebar__foot",children:[i.jsxs("button",{className:"account-btn sidebar__wide",title:"Аккаунт Claude",onClick:Se,children:[i.jsx("span",{className:ge!=null&&ge.loggedIn?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:ge===null?"Аккаунт":ge.loggedIn?ge.email||"Вход выполнен":"Войти в аккаунт"}),(ge==null?void 0:ge.plan)&&i.jsx("span",{className:"chip",children:ge.plan})]}),B&&i.jsxs("button",{className:"account-btn sidebar__wide",title:"Доступ с телефона и из браузера",onClick:B,children:[i.jsx("span",{className:xe!=null&&xe.connected?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:xe===null?"Удалённый доступ":xe.paired?xe.connected?xe.name||"Удалённый доступ включён":"Удалённый доступ · нет связи":"Удалённый доступ"}),(xe==null?void 0:xe.connected)&&xe.clients>0&&i.jsx("span",{className:"chip",children:xe.clients})]}),i.jsx("button",{className:"btn btn--ghost sidebar__wide",disabled:!D,title:"MCP-серверы и плагины",onClick:()=>D==null?void 0:D(),children:"Расширения"}),i.jsx("button",{className:"btn btn--ghost sidebar__wide",title:"Настройки приложения",onClick:ue,children:"Настройки"}),i.jsx("button",{className:"btn btn--ghost",onClick:G,children:"+ Проект"}),i.jsx("button",{className:"btn btn--primary",onClick:J,disabled:!j,children:"+ Сессия"})]}),$e&&i.jsx(Mr,{x:$e.x,y:$e.y,items:Ht,note:Ze,onClose:In}),W&&i.jsx(Mr,{x:W.x,y:W.y,items:is,note:An,onClose:$l}),we&&i.jsx(Mr,{x:we.x,y:we.y,items:vl,note:ys,onClose:da}),V&&i.jsx(Mr,{x:V.x,y:V.y,items:Ql,note:Pb,onClose:qs})]})}function xh(s,l){const r=["row"];return s&&r.push("row--active"),l&&r.push("row--selected"),r.join(" ")}function Wc(s,l,r=c=>c.folderId){const c=new Map(l.map(p=>[p.id,p])),o=new Map,d=[];for(const p of s){const m=r(p),x=m?c.get(m):void 0;if(!x){d.push(p);continue}const _=o.get(x.id);_?_.push(p):o.set(x.id,[p])}return{groups:[...o.entries()].map(([p,m])=>({folder:c.get(p),items:m})).sort((p,m)=>p.folder.name.localeCompare(m.folder.name,"ru")),ungrouped:d}}function Pc(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 oS(s){return s.map(l=>({...l,id:`pinned:${l.id}`,label:l.id==="folder:new"?"Новая папка закреплённых…":l.id==="folder:none"?"Без папки закреплённых":l.label}))}function yh(s){const[l,r]=y.useState([]),c=y.useRef(null);function o(){r([]),c.current=null}function d(p,m,x){if(p.ctrlKey||p.metaKey){r(_=>_.includes(m.id)?_.filter(j=>j!==m.id):[..._,m.id]),c.current=m.id;return}if(p.shiftKey&&c.current){const _=s.findIndex(v=>v.id===c.current),j=s.findIndex(v=>v.id===m.id);if(_!==-1&&j!==-1){const[v,E]=_<j?[_,j]:[j,_];r(s.slice(v,E+1).map(k=>k.id));return}}o(),c.current=m.id,x()}function h(p){return l.includes(p.id)?l:(r([p.id]),c.current=p.id,[p.id])}return{selected:l,click:d,targetsFor:h,clear:o}}const fS={display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0,textAlign:"left"},dS={width:22,height:22,borderRadius:6};function eu({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:fS,"aria-expanded":r,title:o?`${h} — ${o}`:h,onClick:c,children:[i.jsx(hy,{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:dS,title:d.label,"aria-label":d.label,onClick:d.onClick,children:i.jsx(bS,{})})]})}const ex={paddingLeft:22},hS={display:"flex",alignItems:"center",gap:6,width:"100%"},pS={flex:1,minWidth:0,color:"var(--text-2)",fontWeight:500};function mS({folder:s,count:l,open:r,renaming:c,onToggle:o,onStartRename:d,onCommitRename:h,onCancelRename:p,onDelete:m}){return c?i.jsx("div",{className:"row",style:ex,children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:s.name,placeholder:"Название папки",onCommit:h,onCancel:p})})}):i.jsxs("div",{className:"row",style:ex,children:[i.jsxs("button",{className:"row__main",style:hS,"aria-expanded":r,title:r?`Свернуть папку «${s.name}»`:`Развернуть папку «${s.name}»`,onClick:o,children:[i.jsx(hy,{open:r}),i.jsx("span",{style:pS,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:m,children:"✕"})]})}function hy({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 py({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 gS(){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 bS(){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 xS(){try{const s=localStorage.getItem(oy);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"):["archive","workspacesArchive"]}catch{return["archive","workspacesArchive"]}}function yS(){try{const s=localStorage.getItem(dy);if(s===null)return[];const l=JSON.parse(s);return Array.isArray(l)?l.filter(r=>typeof r=="string"):[]}catch{return[]}}function _S(){try{return localStorage.getItem(fy)==="pinned"?"pinned":"default"}catch{return"default"}}const tx={system:"как в системе",light:"светлая",dark:"тёмная"};function vS({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 SS(s){switch(s.state){case"running":return"работает";case"waiting_permission":return"ждёт разрешения";case"idle":return s.backgroundWork?"работает в фоне":jS(s.lastTurn);case"starting":return"запускается";case"reconnecting":return"переподключается";case"error":return"ошибка";case"closed":return"на диске"}}function jS(s){switch(s){case"interrupted":return"прервана";case"stopped":return"остановлена";case"failed":return"оборвалась";case"completed":return"готова";case null:return"ждёт задачу"}}function kS(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":wS(s.lastTurn);case"error":return"error";case"closed":return"closed"}}function wS(s){switch(s){case"interrupted":case"stopped":return"halted";case"failed":return"error";case"completed":return"ready";case null:return"fresh"}}function nx({session:s,tail:l}){return i.jsxs("span",{className:"row__meta",children:[i.jsxs("span",{className:`row__state row__state--${kS(s)}`,children:[i.jsx("span",{className:"row__state-dot","aria-hidden":"true"}),SS(s)]})," · ",l]})}function _h({title:s,pinned:l,projectName:r,projectPath:c}){return i.jsxs("span",{className:"row__head",children:[i.jsxs("span",{className:"row__title",children:[l&&i.jsx(py,{className:"row__pin"}),s]}),i.jsx("span",{className:"row__project",title:c,children:r})]})}function NS(s){const l=s.archivedAuto?"сама, по сроку молчания":"убрана вручную";return s.archivedAt?`${new Date(s.archivedAt).toLocaleString()} · ${l}`:l}function TS(s){return s.archivedAt?`закрыт ${new Date(s.archivedAt).toLocaleString()}`:"закрыт"}const lx=3,ES=15e5;function my(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=vh(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=MS(AS(vh(r.old_string),vh(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 vh(s){if(s==="")return[];const l=s.split(/\r?\n/);return l.length>1&&l[l.length-1]===""&&l.pop(),l}function AS(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),...CS(s.slice(r,c),l.slice(r,o)),...s.slice(c).map(d)]}function CS(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)>ES)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=(_,j)=>d[_*o+j]??0;for(let _=r-1;_>=0;_--)for(let j=c-1;j>=0;j--)d[_*o+j]=s[_]===l[j]?h(_+1,j+1)+1:Math.max(h(_+1,j),h(_,j+1));const p=[];let m=0,x=0;for(;m<r&&x<c;){const _=s[m],j=l[x];_===j?(p.push({type:"ctx",text:_}),m++,x++):h(m+1,x)>=h(m,x+1)?(p.push({type:"del",text:_}),m++):(p.push({type:"add",text:j}),x++)}for(;m<r;)p.push({type:"del",text:s[m++]});for(;x<c;)p.push({type:"add",text:l[x++]});return RS(p)}function RS(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 MS(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 p=Math.max(0,h-lx);p<=Math.min(s.length-1,h+lx);p++)l[p]=!0});const r=[];let c=[];function o(){c.length===1?r.push(...c):c.length>1&&r.push({type:"gap",text:`⋯ ${c.length} ${OS(c.length)} без изменений`}),c=[]}return s.forEach((d,h)=>{l[h]?(o(),r.push(d)):c.push(d)}),o(),r}function OS(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 $r(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 Bh(){try{return await navigator.clipboard.readText()}catch{return null}}const np=1600,Hi="Копировать",zr="Скопировано";function lp({text:s,hint:l,className:r}){const[c,o]=y.useState(!1);return y.useEffect(()=>{if(!c)return;const d=setTimeout(()=>o(!1),np);return()=>clearTimeout(d)},[c]),y.useEffect(()=>o(!1),[s]),i.jsx("button",{type:"button",className:"copybtn"+(c?" copybtn--done":"")+(r?` ${r}`:""),"aria-label":c?zr:`${Hi} ${l}`,title:c?zr:`${Hi} ${l}`,onClick:()=>{$r(s).then(d=>{d&&o(!0)})},children:c?zr:Hi})}function sp({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 DS({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 ap({items:s,busy:l,waiting:r,history:c=[],historyHasMore:o=!1,historyLoading:d=!1,onLoadHistory:h,sessionId:p,onEditMessage:m,empty:x="Сессия пуста. Опишите задачу — Claude Code работает в каталоге проекта с полным набором инструментов."}){const _=y.useRef(null),j=y.useRef(null),v=y.useRef(!0),E=y.useRef(null),k=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{v.current=!0,E.current=null,O.current=!1,k.current!==null&&(clearTimeout(k.current),k.current=null)},[p]),y.useEffect(()=>{const M=_.current,F=j.current;if(!M||!F)return;function H(ae){!M||ae===M.scrollTop||(O.current=!0,M.scrollTop=ae)}function A(){if(!M)return;const ae=E.current;if(ae){const G=ax(M,ae.id);if(G){const J=G.getBoundingClientRect().top-M.getBoundingClientRect().top;H(M.scrollTop+(J-ae.top))}k.current!==null&&clearTimeout(k.current),k.current=setTimeout(()=>{E.current=null},500);return}v.current&&H(M.scrollHeight)}const Z=new ResizeObserver(A);return Z.observe(F),()=>{Z.disconnect(),k.current!==null&&clearTimeout(k.current)}},[]);function z(){const M=_.current;if(M){if(O.current){O.current=!1;return}v.current=M.scrollHeight-M.scrollTop-M.clientHeight<80}}function ee(){if(d)return;const M=_.current,F=c[0];if(M&&F){const H=ax(M,F.id);H&&(E.current={id:F.id,top:H.getBoundingClientRect().top-M.getBoundingClientRect().top})}h==null||h()}let te=0;function K(M){return M.kind==="user"?te++:-1}return i.jsx("div",{className:"transcript",ref:_,onScroll:z,children:i.jsxs("div",{className:"stream",ref:j,children:[o&&i.jsx("button",{type:"button",className:"transcript__more",onClick:ee,disabled:d,children:d?"Загружаем…":"Показать более раннее"}),c.map(M=>i.jsx(sx,{item:M,userIndex:K(M),onEditMessage:m},M.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:x}),s.map(M=>i.jsx(sx,{item:M,userIndex:K(M),onEditMessage:m},M.id)),l&&i.jsx(DS,{waiting:r})]})})}function sx({item:s,userIndex:l,onEditMessage:r}){switch(s.kind){case"user":return i.jsx(zS,{item:s,userIndex:l,onEditMessage:r});case"assistant":return i.jsxs("div",{className:"msg--assistant","data-item-id":s.id,children:[i.jsx(US,{text:s.text}),s.streaming&&i.jsx("span",{className:"caret"}),s.text.trim()!==""&&i.jsx("div",{className:"msg--assistant__foot",children:i.jsx(lp,{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(BS,{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:["↑",rx(s.inputTokens)," ↓",rx(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 LS=500;function zS({item:s,userIndex:l,onEditMessage:r}){const[c,o]=y.useState(null),[d,h]=y.useState(!1),[p,m]=y.useState(s.text),x=y.useRef(null),_=uf("(max-width: 860px)"),j=y.useRef(null);function v(A,Z){o({x:A,y:Z})}function E(A){A.preventDefault(),v(A.clientX,A.clientY)}function k(A){const Z=A.touches[0];if(!Z)return;const ae={timer:0,x:Z.clientX,y:Z.clientY,fired:!1};ae.timer=window.setTimeout(()=>{ae.fired=!0,v(ae.x,ae.y)},LS),j.current=ae}function O(A){const Z=j.current,ae=A.touches[0];!Z||!ae||Math.hypot(ae.clientX-Z.x,ae.clientY-Z.y)>10&&(window.clearTimeout(Z.timer),j.current=null)}function z(A){const Z=j.current;Z&&(window.clearTimeout(Z.timer),Z.fired&&A.preventDefault())}function ee(){m(s.text),h(!0)}function te(){h(!1)}function K(){const A=p.trim();A===""&&!(s.images&&s.images.length>0)||(r==null||r(l,A,s.images),h(!1))}y.useEffect(()=>{const A=x.current;!A||!d||(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[p,d]),y.useEffect(()=>{if(!d)return;const A=x.current;A&&(A.focus(),A.setSelectionRange(A.value.length,A.value.length))},[d]);function M(A){if(A.key==="Escape"){A.preventDefault(),A.stopPropagation(),te();return}A.key==="Enter"&&!A.shiftKey&&!_&&(A.preventDefault(),K())}const F=s.images&&s.images.length>0&&i.jsx("div",{className:"msg--user__images",children:s.images.map((A,Z)=>i.jsx("img",{className:"msg--user__image",src:`data:${A.mediaType};base64,${A.data}`,alt:"Вложение"},Z))});if(d){const A=p.trim()!==""||!!(s.images&&s.images.length>0);return i.jsxs("div",{className:"msg--user msg--user--editing","data-item-id":s.id,children:[F,i.jsxs("div",{className:"msg--user__edit",children:[i.jsx("textarea",{ref:x,className:"msg--user__edit-field",value:p,onChange:Z=>m(Z.target.value),onKeyDown:M,rows:1}),i.jsxs("div",{className:"msg--user__edit-actions",children:[i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:te,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--primary",onClick:K,disabled:!A,children:"Сохранить"})]})]})]})}const H=[{id:"copy",label:"Копировать",onSelect:()=>void $r(s.text)},...r?[{id:"edit",label:"Изменить",onSelect:ee}]:[]];return i.jsxs("div",{className:"msg--user","data-item-id":s.id,onContextMenu:E,onTouchStart:k,onTouchMove:O,onTouchEnd:z,onTouchCancel:z,children:[F,s.text,c&&i.jsx(Mr,{x:c.x,y:c.y,items:H,onClose:()=>o(null)})]})}function ax(s,l){const r=s.querySelectorAll("[data-item-id]");for(const c of r)if(c.dataset.itemId===l)return c;return null}function US({text:s}){const[l,r]=y.useState(""),c=y.useRef([]);y.useEffect(()=>{let d=!1;return tp(s).then(h=>{d||r(HS(h))}),()=>{d=!0}},[s]),y.useEffect(()=>{const d=c.current;return()=>d.forEach(h=>clearTimeout(h))},[]);function o(d){var m,x;const h=d.target.closest(".codeblock__copy");if(!(h instanceof HTMLElement))return;const p=((x=(m=h.parentElement)==null?void 0:m.querySelector("pre"))==null?void 0:x.textContent)??"";p!==""&&$r(p).then(_=>{if(!_)return;h.textContent=zr,h.setAttribute("aria-label",zr),h.classList.add("copybtn--done");const j=window.setTimeout(()=>{h.isConnected&&(h.textContent=Hi,h.setAttribute("aria-label",Ih),h.classList.remove("copybtn--done"))},np);c.current.push(j)})}return i.jsx("div",{className:"markdown-preview msg--assistant__body",onClick:o,dangerouslySetInnerHTML:{__html:l}})}const Ih=`${Hi} блок кода`;function HS(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",Ih),o.title=Ih,o.textContent=Hi,c.append(o)}return l.body.innerHTML}function BS({item:s}){const[l,r]=y.useState(!1),c=s.result===null,o=my(s.name,s.input),d=s.name==="AskUserQuestion"?GS(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?qS(d):IS(s.input)}),i.jsx("span",{className:"tool__status",children:c?"…":s.isError?"ошибка":l?"▴":"▾"})]}),l&&i.jsxs("div",{className:"tool__body",children:[d?i.jsx(YS,{questions:d,answers:s.answers}):o?i.jsx(sp,{diff:o}):i.jsx(ix,{text:JSON.stringify(s.input,null,2),hint:"аргументы вызова"}),s.result!==null&&(!d||s.isError)&&i.jsx(ix,{text:s.result,hint:"результат вызова",style:{marginTop:10}})]})]})}function ix({text:s,hint:l,style:r}){return i.jsxs("div",{className:"codeblock",style:r,children:[i.jsx("pre",{className:"code",children:s}),i.jsx(lp,{text:s,hint:l,className:"codeblock__copy"})]})}function IS(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 qS(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 GS(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:p}=c;if(typeof o!="string"||!Array.isArray(h)||h.length===0)return null;const m=[];for(const x of h){if(typeof x!="object"||x===null)return null;const{label:_,description:j,preview:v}=x;if(typeof _!="string"||typeof j!="string")return null;m.push({label:_,description:j,...typeof v=="string"?{preview:v}:{}})}r.push({question:o,header:typeof d=="string"?d:"",options:m,multiSelect:p===!0})}return r}function YS({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 rx(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}const XS="ccv.dictation.lang",cx="ru-RU";function VS(s){try{return Function.prototype.toString.call(s).includes("[native code]")}catch{return!1}}function ux(){const s=window,l=[s.SpeechRecognition,s.webkitSpeechRecognition].filter(c=>typeof c=="function"),r=l.find(VS);return!r&&l.length>0&&ms("распознавание подменено: родной реализации в странице нет"),r??l[0]??null}function gy(){var s;try{return((s=localStorage.getItem(XS))==null?void 0:s.trim())||cx}catch{return cx}}function ms(s,l){l===void 0?console.debug(`[dictation] ${s}`):console.debug(`[dictation] ${s}`,l)}const $S=3,QS=400,ZS=5,KS=250,FS=2e3,JS=2e4;async function WS(){try{return(await navigator.permissions.query({name:"microphone"})).state==="granted"}catch{return!1}}const PS={"not-allowed":"Браузер не дал доступ к микрофону","service-not-allowed":"Браузер не дал доступ к микрофону","audio-capture":"Микрофон не найден",network:"Сервис распознавания недоступен","language-not-supported":`Распознавание не знает языка ${gy()}`};function ej(s){const[l]=y.useState(()=>ux()!==null),[r,c]=y.useState(!1),[o,d]=y.useState(null),h=y.useRef(null),p=y.useRef(!1),m=y.useRef(!1),x=y.useRef(s),_=y.useRef({openedAt:0,audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1}),j=y.useRef(null),v=y.useRef(!1),E=y.useRef(null),k=y.useCallback(()=>{E.current&&clearTimeout(E.current),E.current=null},[]),O=y.useCallback(()=>{k();const M=async F=>{if(E.current=null,!(!p.current||v.current)){if(!F&&!await WS()){if(ms("ждём ответа на запрос доступа к микрофону"),!p.current||v.current)return;E.current=setTimeout(()=>void M(!0),JS);return}ms("движок не ответил на start()"),p.current=!1,c(!1),d("Распознавание не отвечает — проверьте расширения браузера и доступ к микрофону")}};E.current=setTimeout(()=>void M(!1),FS)},[k]);y.useEffect(()=>{x.current=s}),y.useEffect(()=>{const M=ux();if(!M)return;const F=new M;return F.lang=gy(),F.continuous=!0,F.interimResults=!0,F.onstart=()=>{ms("сессия открыта"),v.current=!0,k(),c(!0)},F.onaudiostart=()=>{ms("пошёл звук с микрофона"),_.current.audio=!0},F.onresult=H=>{var G;if(m.current)return;let A="",Z="";for(let J=H.resultIndex;J<H.results.length;J++){const D=H.results[J];if(!D)continue;const ge=((G=D[0])==null?void 0:G.transcript)??"";D.isFinal?A+=ge:Z+=ge}const ae=_.current;ae.heard=!0,ae.everHeard=!0,ms("распознано",{final:A,interim:Z}),x.current(A,Z)},F.onerror=H=>{_.current.lastError=H.error,ms("ошибка движка",H.error),!(H.error==="no-speech"||H.error==="aborted")&&(p.current=!1,c(!1),d(PS[H.error]??`Распознавание не работает: ${H.error}`))},F.onend=()=>{m.current=!1,v.current=!1;const H=_.current,A=Date.now()-H.openedAt;if(ms("сессия закрыта",{мс:A,звук:H.audio,слова:H.heard,ошибка:H.lastError||null}),!p.current){c(!1);return}if(H.dead=!H.audio&&A<QS?H.dead+1:0,H.dead>=ZS){p.current=!1,c(!1),d(H.lastError?`Распознавание не работает: ${H.lastError}`:"Распознавание закрывается сразу после запуска — проверьте доступ к микрофону в настройках сайта");return}H.silent=H.heard?0:H.silent+1,!H.everHeard&&!H.warned&&H.silent>=$S&&(H.warned=!0,d(H.audio?"Микрофон слушает, но речь не распознаётся — проверьте язык диктовки и уровень звука":"С микрофона не идёт звук — проверьте устройство ввода в настройках сайта в браузере")),j.current=setTimeout(()=>{if(j.current=null,!!p.current){H.openedAt=Date.now(),H.audio=!1,H.heard=!1,H.lastError="",O();try{F.start()}catch{}}},KS)},h.current=F,()=>{p.current=!1,j.current&&clearTimeout(j.current),j.current=null,k(),F.onend=null,F.onresult=null,F.onerror=null,F.onstart=null,F.onaudiostart=null,F.abort(),h.current=null}},[]);const z=y.useCallback(()=>{var M;if(p.current){if(p.current=!1,ms("выключение микрофона"),j.current&&clearTimeout(j.current),j.current=null,k(),!v.current){c(!1);return}(M=h.current)==null||M.stop()}},[]),ee=y.useCallback(()=>{const M=h.current;if(M){if(!window.isSecureContext){d("Микрофон доступен только по https или с localhost");return}d(null),p.current=!0,m.current=!1,j.current&&clearTimeout(j.current),j.current=null,_.current={openedAt:Date.now(),audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1},c(!0),ms("включение микрофона",{язык:M.lang}),O();try{M.start()}catch(F){ms("start() не прошёл",F)}}},[O]),te=y.useCallback(()=>{p.current?z():ee()},[ee,z]),K=y.useCallback(()=>{var M;p.current&&v.current&&(m.current=!0,(M=h.current)==null||M.abort())},[]);return{supported:l,listening:r,error:o,toggle:te,stop:z,drop:K}}const by="ccv:drafts",tj=40,nj=2e4,lj=500;let au=null,iu=null;function xy(){if(au)return au;const s=new Map;try{const l=localStorage.getItem(by);if(l){const r=JSON.parse(l);if(typeof r=="object"&&r!==null)for(const[c,o]of Object.entries(r))typeof o=="string"&&o!==""&&s.set(c,o)}}catch{}return au=s,window.addEventListener("pagehide",yy),s}function Sh(s){return xy().get(s)??""}function sj(s,l){const r=xy(),c=l.slice(0,nj),o=r.has(s);if(o&&r.delete(s),c!=="")r.set(s,c);else if(!o)return;for(;r.size>tj;){const d=r.keys().next();if(d.done)break;r.delete(d.value)}aj()}function aj(){iu===null&&(iu=window.setTimeout(yy,lj))}function yy(){if(iu!==null&&window.clearTimeout(iu),iu=null,!!au)try{localStorage.setItem(by,JSON.stringify(Object.fromEntries(au)))}catch{}}const ij="(max-width: 860px)",ox=/^\/(\S*)$/,rj=new Set(["model","permissions"]);function cj(s){return rj.has(s.name)||s.name.startsWith("__")}const uj=new Set(["clear","rename"]),fx=/(?:^|\s)@([^\s@]*)$/,oj=200,fj=100,dj=190,hj=5,pj=20*1024*1024,mj=1568,gj=.85;let dx=0;async function bj(s){var j,v;if(!s.type.startsWith("image/")||s.size>pj)return null;const l=await xj(s);if(!l)return null;const{width:r,height:c}=l;if(r<=0||c<=0)return null;const o=Math.min(1,mj/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=(j=l.image).close)==null||v.call(j);const p=s.type==="image/png",m=p?"image/png":"image/jpeg",x=d.toDataURL(m,p?void 0:gj),_=x.slice(x.indexOf(",")+1);return _?(dx+=1,{id:`att${dx}`,mediaType:m,data:_,previewUrl:x}):null}async function xj(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 _y({disabled:s,busy:l,commands:r,sessionTitle:c,contextResult:o,className:d,placeholder:h,draftKey:p,sendLabel:m="Отправить",autoFocus:x=!1,attachmentsEnabled:_=!0,onContextSearch:j,onCommand:v,onSend:E,onInterrupt:k,onEscape:O}){var we;const z=uf(ij),[ee,te]=y.useState(()=>p?Sh(p):""),[K,M]=y.useState(!1),[F,H]=y.useState(0),A=y.useRef(null),Z=y.useRef(null),ae=y.useRef(null),[G,J]=y.useState(()=>p?Sh(p).length:0),[D,ge]=y.useState([]),Se=y.useRef(null),xe=y.useCallback(L=>{!_||L.length===0||Promise.all(L.map(bj)).then(V=>{const _e=V.filter(ze=>ze!==null);_e.length!==0&&ge(ze=>[...ze,..._e].slice(0,hj))})},[_]);function B(L){ge(V=>V.filter(_e=>_e.id!==L))}function ue(L){var ze;if(!_)return;const V=(ze=L.clipboardData)==null?void 0:ze.items;if(!V)return;const _e=[];for(const st of V){if(!st.type.startsWith("image/"))continue;const al=st.getAsFile();al&&_e.push(al)}_e.length!==0&&(L.preventDefault(),xe(_e))}function se(L){const V=L.target.files?Array.from(L.target.files):[];L.target.value="",xe(V)}y.useEffect(()=>{_||ge([])},[_]);const[be,Ce]=y.useState([]),[w,Q]=y.useState(-1),re=y.useRef(""),[oe,ye]=y.useState(""),je=ej(y.useCallback((L,V)=>{L&&te(_e=>jh(_e,L)),ye(V.trim())},[])),Me=oe?jh(ee,oe):ee;y.useEffect(()=>{je.listening||oe===""||(te(L=>jh(L,oe)),ye(""))},[je.listening,oe]),y.useEffect(()=>{var L;x&&((L=A.current)==null||L.focus())},[x]);const ht=y.useRef(new Map),lt=y.useRef(new Map),Nn=y.useRef(p),Je=y.useRef({text:ee,caret:G});Je.current={text:ee,caret:G};const Kt=y.useCallback((L,V,_e)=>{V===""?(ht.current.delete(L),lt.current.delete(L)):(ht.current.set(L,V),lt.current.set(L,_e)),sj(L,V)},[]),ct=je.drop;y.useLayoutEffect(()=>{const L=Nn.current;if(L===p)return;Nn.current=p,L&&Kt(L,Je.current.text,Je.current.caret);const V=p?ht.current.get(p)??Sh(p):"",_e=p?lt.current.get(p):void 0,ze=Math.min(_e??V.length,V.length);te(V),J(ze),ae.current=[ze,ze],ye(""),H(0),M(!1),Q(-1),re.current="",ge([]),ct()},[p,Kt,ct]),y.useEffect(()=>{p&&Kt(p,ee,G)},[p,ee,G,Kt]);const rn=s?"Выберите сессию":h??"Опишите задачу… («/» — команды, «@» — файлы)",Be=y.useRef(0),rt=y.useCallback(L=>{const V=parseFloat(getComputedStyle(L).maxHeight),_e=Number.isFinite(V)&&V>0?V:dj;L.style.height="auto";const ze=L.scrollHeight;L.style.height=`${Math.min(ze,_e)}px`,L.style.overflowY=ze>_e?"auto":"hidden"},[]);y.useEffect(()=>{const L=A.current;L&&rt(L)},[Me,rn,s,rt]),y.useLayoutEffect(()=>{const L=A.current,V=ae.current;!L||!V||(ae.current=null,L.setSelectionRange(V[0],V[1]))}),y.useEffect(()=>{const L=A.current;if(!L)return;const V=new ResizeObserver(([_e])=>{const ze=_e==null?void 0:_e.contentRect.width;ze===void 0||Math.abs(ze-Be.current)<1||(Be.current=ze,rt(L))});return V.observe(L),()=>V.disconnect()},[rt]);const Hn=je.stop;y.useEffect(()=>{s&&Hn()},[s,Hn]);const wt=y.useMemo(()=>je.error?{ok:!1,message:je.error}:null,[je.error]),Ot=y.useMemo(()=>{var _e;const L=(_e=ox.exec(ee))==null?void 0:_e[1];if(L===void 0)return[];const V=L.toLowerCase();return r.filter(ze=>!cj(ze)&&kh(ze,V)<vy).sort((ze,st)=>kh(ze,V)-kh(st,V))},[ee,r]),Ft=!K&&Ot.length>0,tn=Math.min(F,Ot.length-1),$t=K?null:((we=fx.exec(Me.slice(0,G)))==null?void 0:we[1])??null,Nt=y.useRef(j);Nt.current=j,y.useEffect(()=>{if($t===null||$t===""||$t.endsWith("/")){Nt.current($t);return}const L=setTimeout(()=>Nt.current($t),oj);return()=>clearTimeout(L)},[$t]);const Qe=$t!==null&&(o==null?void 0:o.query)===$t,We=Qe?o.entries:[],dn=$t!==null,Jt=dn&&!Qe,Qt=Math.min(F,Math.max(We.length-1,0));y.useEffect(()=>{var V,_e;if(!Ft&&!dn)return;const L=Ft?tn:Qt;(_e=(V=Z.current)==null?void 0:V.children[L])==null||_e.scrollIntoView({block:"nearest"})},[Ft,dn,tn,Qt]);function Bn(L,V){var _e;te(L),J(V),ae.current=[V,V],H(0),M(!1),oe!==""&&(ye(""),je.drop()),(_e=A.current)==null||_e.focus()}function Tn(){te(""),ye(""),H(0),J(0),M(!1),Q(-1),re.current="",ge([]),je.drop(),p&&Kt(p,"",0)}function hn(L){const V=L.trim();V===""&&D.length===0||s||(E(V,D.length>0?D.map(_e=>({mediaType:_e.mediaType,data:_e.data})):void 0),V!==""&&Ce(_e=>[V,..._e.filter(ze=>ze!==V)].slice(0,fj)),Tn())}function sl(L){if(L<-1||L>=be.length)return;w===-1&&(re.current=ee);const V=L===-1?re.current:be[L]??"";Q(L),Bn(V,V.length)}function zt(){var ze;const L=((ze=A.current)==null?void 0:ze.selectionStart)??Me.length,_e=`${L>0&&!/\s$/.test(Me.slice(0,L))?" ":""}@`;Bn(Me.slice(0,L)+_e+Me.slice(L),L+_e.length)}function bt(L){var st;const V=(st=fx.exec(Me.slice(0,G)))==null?void 0:st[1];if(V===void 0)return;const _e=G-V.length-1,ze=L.kind==="dir"?`@${L.path}/`:`@${L.path} `;Bn(Me.slice(0,_e)+ze+Me.slice(G),_e+ze.length)}function Ut(){var V;const L=(V=ox.exec(Me.trim()))==null?void 0:V[1];if(L&&v(L)){Tn();return}hn(Me)}function $e(L,V){te(L),J(V),H(0),M(!1),Q(-1),oe!==""&&(ye(""),je.drop())}function Qn(L){var ze;const V=uj.has(L.name)?c:null,_e=`/${L.name} `;te(_e+(V??"")),J(_e.length+((V==null?void 0:V.length)??0)),V&&(ae.current=[_e.length,_e.length+V.length]),H(0),(ze=A.current)==null||ze.focus()}function W(L){if(v(L.name)){te(""),H(0),M(!1);return}L.argumentHint?Qn(L):hn(`/${L.name}`)}function de(L){if(Ft){if(L.key==="ArrowDown")return L.preventDefault(),H(V=>(Math.min(V,Ot.length-1)+1)%Ot.length);if(L.key==="ArrowUp"){L.preventDefault();const V=Ot.length-1;return H(_e=>(Math.min(_e,V)+V)%Ot.length)}if(L.key==="Enter"&&!L.shiftKey){L.preventDefault();const V=Ot[tn];V&&W(V);return}if(L.key==="Tab"){L.preventDefault();const V=Ot[tn];V&&Qn(V);return}if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),M(!0);return}}if(dn){if(L.key==="ArrowDown"&&We.length>0)return L.preventDefault(),H(V=>(Math.min(V,We.length-1)+1)%We.length);if(L.key==="ArrowUp"&&We.length>0){L.preventDefault();const V=We.length-1;return H(_e=>(Math.min(_e,V)+V)%We.length)}if(L.key==="Enter"&&!L.shiftKey||L.key==="Tab"){const V=We[Qt];if(V){L.preventDefault(),bt(V);return}if(L.key==="Tab")return}if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),M(!0);return}}if((L.key==="ArrowUp"||L.key==="ArrowDown")&&!L.shiftKey){const V=L.currentTarget,_e=V.selectionStart;if(V.selectionEnd===_e){const st=L.key==="ArrowUp"?w+1:w-1;st>=-1&&st<be.length&&requestAnimationFrame(()=>{V.selectionStart===_e&&V.selectionEnd===_e&&sl(st)})}}if(L.key==="Escape"&&O){L.preventDefault(),L.stopPropagation(),O();return}L.key==="Enter"&&!L.shiftKey&&!z&&(L.preventDefault(),Ut())}return i.jsx("div",{className:d?`composer ${d}`:"composer",children:i.jsxs("div",{className:"composer__inner",children:[i.jsx(qi,{result:wt}),dn&&!Ft&&i.jsxs("div",{className:"cmdmenu",role:"listbox",ref:Z,children:[We.map((L,V)=>i.jsxs("button",{role:"option","aria-selected":V===Qt,className:V===Qt?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>H(V),onMouseDown:_e=>{_e.preventDefault(),bt(L)},children:[i.jsxs("span",{className:"cmdmenu__name",children:[L.name,L.kind==="dir"?"/":""]}),i.jsx("span",{className:"cmdmenu__desc",children:L.path}),L.ignored&&i.jsx("span",{className:"cmdmenu__tag",children:"git-ignore"})]},L.path)),We.length===0&&i.jsx("div",{className:"cmdmenu__empty",children:Jt?"ищем…":$t?"Ничего не нашлось":"Наберите имя файла или каталога"})]}),Ft&&i.jsx("div",{className:"cmdmenu",role:"listbox",ref:Z,children:Ot.map((L,V)=>i.jsxs("button",{role:"option","aria-selected":V===tn,className:V===tn?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>H(V),onMouseDown:_e=>{_e.preventDefault(),W(L)},children:[i.jsxs("span",{className:"cmdmenu__name",children:["/",L.name]}),L.argumentHint&&i.jsx("span",{className:"cmdmenu__hint",children:L.argumentHint}),i.jsx("span",{className:"cmdmenu__desc",children:L.description})]},L.name))}),D.length>0&&i.jsx("div",{className:"composer__attachments",children:D.map(L=>i.jsxs("div",{className:"composer__thumb",children:[i.jsx("img",{src:L.previewUrl,alt:"Вложение"}),i.jsx("button",{type:"button",className:"composer__thumb-remove","aria-label":"Удалить вложение",onClick:()=>B(L.id),children:i.jsx(kj,{})})]},L.id))}),i.jsxs("div",{className:"composer__field",children:[i.jsx("button",{type:"button",className:"addbtn",title:"Добавить контекст — файл проекта («@»)","aria-label":"Добавить контекст",disabled:s,onClick:zt,children:i.jsx(vj,{})}),_&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Se,type:"file",accept:"image/*",multiple:!0,className:"composer__fileinput",tabIndex:-1,"aria-hidden":"true",onChange:se}),i.jsx("button",{type:"button",className:"attachbtn",title:"Прикрепить изображение","aria-label":"Прикрепить изображение",disabled:s,onClick:()=>{var L;return(L=Se.current)==null?void 0:L.click()},children:i.jsx(jj,{})})]}),i.jsx("textarea",{ref:A,value:Me,disabled:s,placeholder:rn,onChange:L=>$e(L.target.value,L.target.selectionStart),onSelect:L=>J(L.currentTarget.selectionStart),onKeyDown:de,onPaste:ue}),je.supported&&i.jsx("button",{type:"button",className:je.listening?"micbtn is-on":"micbtn",title:je.listening?"Остановить диктовку":"Продиктовать промпт","aria-label":je.listening?"Остановить диктовку":"Продиктовать промпт","aria-pressed":je.listening,disabled:s,onClick:je.toggle,children:i.jsx(wj,{on:je.listening})}),l?i.jsx("button",{className:"btn",onClick:k,title:"Прервать (Esc)",children:"Стоп"}):i.jsxs("button",{className:"btn btn--primary sendbtn",onClick:Ut,disabled:s||Me.trim()===""&&D.length===0,"aria-label":m,title:m,children:[i.jsx("span",{className:"sendbtn__label",children:m}),i.jsx(Sj,{})]})]})]})})}function jh(s,l){const r=l.trim();if(r==="")return s;const c=qh(r).slice(yj(s,r)).join(" ");return c===""?s:s===""||/\s$/.test(s)?s+c:`${s} ${c}`}function yj(s,l){const r=qh(s),c=qh(l);for(let o=Math.min(r.length,c.length);o>0;o--)if(r.slice(r.length-o).every((d,h)=>_j(d,c[h]??"")))return o;return 0}function qh(s){return s.split(/\s+/).filter(l=>l!=="")}function _j(s,l){const r=c=>c.toLowerCase().replace(/[.,!?;:…]+$/u,"");return r(s)===r(l)}function vj(){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 Sj(){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 jj(){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 kj(){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 wj({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 vy=4;function kh(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:vy}function Nj({request:s,queued:l,onDecide:r}){const c=my(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(sp,{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 Tj({request:s,queued:l,onAnswer:r,onDecline:c}){const{questions:o}=s,[d,h]=y.useState(()=>o.map(()=>new Set)),[p,m]=y.useState(()=>o.map(()=>"")),[x,_]=y.useState(()=>hx(o));y.useEffect(()=>{h(o.map(()=>new Set)),m(o.map(()=>"")),_(hx(o))},[s.requestId]);const j=y.useMemo(()=>Aj(o,d,p),[o,d,p]),v=j!==null;function E(K,M){var F,H;(H=(F=o[K])==null?void 0:F.options[M])!=null&&H.preview&&_(A=>{const Z=A.slice();return Z[K]=M,Z})}function k(K,M,F){h(H=>{const A=H.slice(),Z=new Set(A[K]);return F?Z.has(M)?Z.delete(M):Z.add(M):Z.has(M)||(Z.clear(),Z.add(M)),A[K]=Z,A}),M!=="other"&&E(K,M)}function O(K,M){m(F=>{const H=F.slice();return H[K]=M,H})}function z(){j&&r(s.requestId,j)}function ee(K){K.key==="Enter"&&(K.target.closest("button")||v&&(K.preventDefault(),z()))}function te(K){var A;if(!["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(K.key))return;const M=Array.from(K.currentTarget.querySelectorAll("button.qsheet__option")),F=M.indexOf(document.activeElement);if(F===-1)return;K.preventDefault();const H=K.key==="ArrowDown"||K.key==="ArrowRight"?1:-1;(A=M[(F+H+M.length)%M.length])==null||A.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:ee,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((K,M)=>i.jsx(Ej,{q:K,qi:M,selected:d[M]??new Set,otherText:p[M]??"",previewIndex:x[M]??null,onToggle:k,onFocusOption:E,onOtherText:O,onOptionsKeyDown:te},M))]}),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:z,children:"Ответить"})]})]})})}function Ej({q:s,qi:l,selected:r,otherText:c,previewIndex:o,onToggle:d,onFocusOption:h,onOtherText:p,onOptionsKeyDown:m}){var E;const x=s.options.some(k=>k.preview),_=o!==null?(E=s.options[o])==null?void 0:E.preview:void 0,j=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:m,children:[s.options.map((k,O)=>{const z=r.has(O);return i.jsxs("button",{type:"button",role:v,"aria-checked":z,className:"qsheet__option"+(z?" is-selected":""),onClick:()=>d(l,O,s.multiSelect),onFocus:()=>h(l,O),onMouseEnter:()=>h(l,O),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:k.label}),i.jsx("span",{className:"qsheet__opt-desc",children:k.description})]})]},O)}),i.jsxs("div",{className:"qsheet__other",children:[i.jsxs("button",{type:"button",role:v,"aria-checked":j,className:"qsheet__option qsheet__option--other"+(j?" 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:"Свой вариант ответа"})]})]}),j&&i.jsx("input",{type:"text",className:"qsheet__other-input",placeholder:"Впишите свой вариант…","aria-label":`Свой вариант ответа на вопрос «${s.question}»`,value:c,onChange:k=>p(l,k.target.value),autoFocus:!0})]})]}),x&&i.jsx("pre",{className:"qsheet__preview",children:_??""})]})}function hx(s){return s.map(l=>{const r=l.options.findIndex(c=>c.preview);return r===-1?null:r})}function Aj(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,p=[];for(let m=0;m<d.options.length;m++){const x=d.options[m];x&&h.has(m)&&p.push(x.label)}if(h.has("other")){const m=(r[o]??"").trim();m&&p.push(m)}if(p.length===0)return null;c[d.question]=p.join(", ")}return c}function Cj({request:s,plan:l,queued:r,onAccept:c,onDecline:o}){const[d,h]=y.useState(l),[p,m]=y.useState("preview");y.useEffect(()=>{h(l),m("preview")},[s.requestId,l]);const x=d.trim().length>0;function _(){x&&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(Mj,{})}),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"+(p==="preview"?" is-on":""),role:"tab","aria-selected":p==="preview",onClick:()=>m("preview"),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(p==="source"?" is-on":""),role:"tab","aria-selected":p==="source",onClick:()=>m("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:p==="preview"?i.jsx(Rj,{text:d}):i.jsx("textarea",{className:"plansheet__source",value:d,onChange:j=>h(j.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:!x,autoFocus:!0,onClick:_,children:"Одобрить план"})]})]})})}function Rj({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return tp(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview plansheet__preview",dangerouslySetInnerHTML:{__html:l}})}function Mj(){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 Oj(s,l){if(s!=="ExitPlanMode"||!l||typeof l!="object")return null;const r=l.plan;return typeof r=="string"?r:null}function Sy({path:s}){const[l,r]=y.useState(!1),[c,o]=y.useState(!1),d=y.useRef(null);y.useEffect(()=>{if(!l)return;function p(m){var x;(x=d.current)!=null&&x.contains(m.target)||r(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),y.useEffect(()=>{if(!c)return;const p=setTimeout(()=>o(!1),np);return()=>clearTimeout(p)},[c]),y.useEffect(()=>r(!1),[s]);async function h(){await $r(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(p=>!p),onKeyDown:p=>{p.key!=="Escape"||!l||(p.preventDefault(),p.stopPropagation(),r(!1))},children:[i.jsx(Dj,{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?zr:Hi})]})]})}function Dj({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 Lj=["low","medium","high"];function jy({models:s,value:l,effort:r,ultracode:c,thinking:o,switchOnFlag:d,className:h,onModel:p,onEffort:m,onUltracode:x,onThinking:_,onSwitchOnFlag:j}){const[v,E]=y.useState(!1),[k,O]=y.useState(0),z=y.useRef(null),ee=y.useRef(null),te=s.find(A=>A.value===l)??null,K=te&&te.supportsEffort?te.effortLevels.length>0?te.effortLevels:Lj:[],M=K.includes("xhigh");y.useEffect(()=>{if(!v)return;const A=s.findIndex(Z=>Z.value===l);O(A===-1?0:A)},[v]),y.useEffect(()=>{if(!v)return;function A(Z){var ae;(ae=z.current)!=null&&ae.contains(Z.target)||E(!1)}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[v]),y.useEffect(()=>{var A,Z;v&&((Z=(A=ee.current)==null?void 0:A.querySelector(".is-cursor"))==null||Z.scrollIntoView({block:"nearest"}))},[v,k]);function F(A){E(!1),A.value!==l&&p(A.value)}function H(A){if(A.key==="Escape"){if(!v)return;A.preventDefault(),A.stopPropagation(),E(!1);return}if(A.key==="ArrowDown"||A.key==="ArrowUp"){if(A.preventDefault(),!v)return E(!0);if(s.length===0)return;const Z=A.key==="ArrowDown"?1:s.length-1;return O(ae=>(ae+Z)%s.length)}if(A.key==="Enter"||A.key===" "){if(A.preventDefault(),!v)return E(!0);const Z=s[k];Z&&F(Z)}}return i.jsxs("div",{ref:z,className:"select"+(v?" select--open":"")+(h?` ${h}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:"Модель, усилие и размышления","aria-label":"Модель, усилие и размышления","aria-haspopup":"menu","aria-expanded":v,onClick:()=>E(A=>!A),onKeyDown:H,children:[i.jsx("span",{className:"select__value",children:(te==null?void 0:te.displayName)??l??"—"}),c?i.jsx("span",{className:"select__suffix select__suffix--hot",children:"ultracode"}):K.length>0&&r&&i.jsx("span",{className:"select__suffix",children:r}),i.jsx(zj,{})]}),v&&i.jsxs("div",{ref:ee,className:"select__menu modelmenu",role:"menu",children:[i.jsx("div",{className:"modelmenu__head",children:"Модель"}),s.map((A,Z)=>i.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":A.value===l,className:"select__option"+(Z===k?" is-cursor":"")+(A.value===l?" is-on":""),onMouseEnter:()=>O(Z),onClick:()=>F(A),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:A.value===l?"✓":""}),i.jsx("span",{className:"select__label",children:A.displayName}),A.description&&i.jsx("span",{className:"select__hint",children:A.description})]},A.value)),K.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:K.map(A=>i.jsx("button",{type:"button",role:"menuitemradio","aria-checked":A===r,className:A===r?"modelmenu__level is-on":"modelmenu__level",onClick:()=>m(A),children:A},A))})]}),M&&i.jsx(wh,{label:"Ultracode",desc:"xhigh и постоянная оркестрация подагентами",on:c,onToggle:()=>x(!c)})]}),i.jsx("div",{className:"modelmenu__sep",role:"separator"}),(te==null?void 0:te.supportsThinking)!==!1&&i.jsx(wh,{label:"Размышления",desc:"расширенное обдумывание перед ответом",on:o,onToggle:()=>_(!o)}),i.jsx(wh,{label:"Менять модель по флагу",desc:"иначе помеченный ход встаёт на паузу",on:d,onToggle:()=>j(!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 zj(){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 Vl({title:s,children:l,actions:r,className:c,sheet:o=!1,onClose:d}){const h=y.useRef(null);return y.useEffect(()=>{function p(m){if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),d();return}if(m.key!=="Tab")return;const x=h.current;if(!x)return;const _=x.querySelectorAll('button, input, textarea, select, a[href], [tabindex]:not([tabindex="-1"])'),j=_[0],v=_[_.length-1];!j||!v||(m.shiftKey&&document.activeElement===j?(m.preventDefault(),v.focus()):!m.shiftKey&&document.activeElement===v&&(m.preventDefault(),j.focus()))}return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[d]),i.jsx("div",{className:o?"modal-backdrop modal-backdrop--sheet":"modal-backdrop",onMouseDown:p=>{p.target===p.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 Uj({candidates:s,searching:l,agentItems:r,agentBusy:c,error:o,roots:d,created:h,onSearch:p,onAskAgent:m,onInterrupt:x,onSubmit:_,onCreate:j,onClose:v}){const[E,k]=y.useState("open"),[O,z]=y.useState(""),[ee,te]=y.useState(!1),[K,M]=y.useState(""),[F,H]=y.useState(""),[A,Z]=y.useState({git:!0,claudeMd:!0,readme:!0}),ae=O.trim(),G=ae!=="",J=K.trim(),D=F.trim(),ge=J!==""&&D!=="";y.useEffect(()=>{K===""&&d.length>0&&M(d[0])},[d]);const Se=y.useRef(p);Se.current=p,y.useEffect(()=>{if(E!=="open")return;const se=O.trim(),be=setTimeout(()=>Se.current(se),200);return()=>clearTimeout(be)},[O,E]);function xe(){G&&_(ae)}function B(){ge&&j(J,D,A)}function ue(){G&&(te(!0),m(ae))}return h?i.jsxs(Vl,{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(se=>i.jsx("li",{children:se},se))})}),i.jsx("p",{className:"modal__text modal__text--dim",children:"Проект открыт и работает — недостающее можно добавить руками, в дереве файлов или из терминала."})]}):i.jsxs(Vl,{title:"Новый проект",className:ee&&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:x,children:"Остановить"}):i.jsx("button",{className:"btn",disabled:!G,onClick:ue,title:"Найти по описанию",children:"Попросить агента"}),i.jsx("button",{className:"btn btn--primary",disabled:!G,onClick:xe,children:"Открыть"})]}):i.jsx("button",{className:"btn btn--primary",disabled:!ge,onClick:B,children:"Создать"})]}),children:[i.jsxs("div",{className:"tabs",children:[i.jsx(px,{label:"Открыть",on:E==="open",onClick:()=>k("open")}),i.jsx(px,{label:"Создать",on:E==="create",onClick:()=>k("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:O,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects\\my-app",onChange:se=>z(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(se.preventDefault(),xe())}}),o&&i.jsx("p",{className:"modal__error",children:o}),s.length>0&&i.jsx("ul",{className:"finds",children:s.map(se=>i.jsx("li",{children:i.jsxs("button",{className:"find",disabled:se.open,title:se.open?"Этот проект уже открыт":se.path,onClick:()=>z(se.path),onDoubleClick:()=>_(se.path),children:[i.jsx("span",{className:"find__name",children:se.name}),i.jsx("span",{className:"find__path",children:se.path}),i.jsx("span",{className:"find__note",children:Ij(se)})]})},se.path))}),s.length===0&&G&&!l&&!ee&&i.jsx("p",{className:"modal__text modal__text--dim",children:"Ничего похожего среди каталогов, где вы работали. Если помните не имя, а суть проекта — опишите его и нажмите «Попросить агента». Проекта ещё нет вовсе — рядом вкладка «Создать»."}),ee&&i.jsx("div",{className:"finds__agent",children:i.jsx(ap,{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:K,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects",onChange:se=>M(se.target.value)}),d.length>0&&i.jsx("div",{className:"newproj__roots",children:d.map(se=>i.jsx("button",{type:"button",className:se===J?"newproj__root is-on":"newproj__root",title:se,onClick:()=>M(se),children:Bj(se)},se))}),i.jsx("label",{className:"field newproj__field",htmlFor:"workspace-name",children:"Имя проекта"}),i.jsx("input",{id:"workspace-name",className:"input input--mono",value:F,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"my-app",onChange:se=>H(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(se.preventDefault(),B())}}),i.jsx("p",{className:"newproj__preview",children:ge?Hj(J,D):"Каталог появится здесь"}),o&&i.jsx("p",{className:"modal__error",children:o}),i.jsxs("div",{className:"newproj__opts",children:[i.jsx(Nh,{label:"git init",desc:"панель истории работает сразу",on:A.git,onToggle:()=>Z(se=>({...se,git:!se.git}))}),i.jsx(Nh,{label:"CLAUDE.md",desc:"заготовка инструкций для агента",on:A.claudeMd,onToggle:()=>Z(se=>({...se,claudeMd:!se.claudeMd}))}),i.jsx(Nh,{label:"README.md",desc:"по нему проект потом узнаёт поиск",on:A.readme,onToggle:()=>Z(se=>({...se,readme:!se.readme}))})]})]})]})}function px({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 Nh({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 Hj(s,l){const r=s.includes("\\")?"\\":"/";return s.replace(/[\\/]+$/,"")+r+l}function Bj(s){const l=s.includes("\\")?"\\":"/",r=s.split(/[\\/]/).filter(Boolean);return r.length<=2?s:`…${l}${r.slice(-2).join(l)}`}function Ij(s){return s.open?"уже открыт":s.why?s.why:s.sessions===0?"рядом с вашими проектами":`${qj(s.sessions)}${Gj(s.lastUsedAt)}`}function qj(s){const l=s%10,r=s%100;return r>=11&&r<=14?`${s} сессий`:l===1?`${s} сессия`:l>=2&&l<=4?`${s} сессии`:`${s} сессий`}function Gj(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 ip=7;function Yj(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=mx(l),l[h]=o.hash);const[p,...m]=o.parents;l[h]=p??null;const x=[];p!==void 0&&x.push({from:h,to:h});for(const v of m){let E=l.indexOf(v);E===-1&&(E=mx(l),l[E]=v),x.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 j=[];for(let v=0;v<d.length;v++){const E=d[v];!E||E===o.hash||v===h||l[v]===E&&j.push(v)}Xj(l),c=Math.max(c,l.length,h+1),r.push({commit:o,col:h,up:_,down:x,through:j})}return{rows:r,columns:Math.min(c,ip)}}function mx(s){const l=s.indexOf(null);return l!==-1?l:(s.push(null),s.length-1)}function Xj(s){for(;s.length>0&&s[s.length-1]===null;)s.pop()}const ky=1500;function Vj(s){const l=[];let r=!1;for(const c of s.patch.split(`
|
|
116
|
+
`,v),k=E<0?j.length:E;if(k>v&&c(j.slice(v,k),_),E<0)break;o(),v=E+1}p=x}}m1(l,r,(x,_,j)=>{m(x,""),m(_,j)},d,h),m(h,"")}class b1{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:p,to:m}=l;if(p>=c||m<=r)return;h.isTop&&(d=this.highlighters.filter(E=>!E.scope||E.scope(h)));let x=o,_=x1(l)||uu.empty,j=p1(d,_.tags);if(j&&(x&&(x+=" "),x+=j,_.mode==1&&(o+=(o?" ":"")+j)),this.startSpan(Math.max(r,p),x),_.opaque)return;let v=l.tree&&l.tree.prop(Vt.mounted);if(v&&v.overlay){let E=l.node.enter(v.overlay[0].from+p,1),k=this.highlighters.filter(z=>!z.scope||z.scope(v.tree.type)),O=l.firstChild();for(let z=0,ee=p;;z++){let te=z<v.overlay.length?v.overlay[z]:null,K=te?te.from+p:m,M=Math.max(r,ee),F=Math.min(c,K);if(M<F&&O)for(;l.from<F&&(this.highlightRange(l,M,F,o,d),this.startSpan(Math.min(F,l.to),x),!(l.to>=K||!l.nextSibling())););if(!te||K>c)break;ee=te.to+p,ee>r&&(this.highlightRange(E.cursor(),Math.max(r,te.from+p),Math.min(c,ee),"",k),this.startSpan(Math.min(c,ee),x))}O&&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),x)}while(l.nextSibling());l.parent()}}}function x1(s){let l=s.type.prop(sy);for(;l&&l.context&&!s.matchContext(l.context);)l=l.next;return l||null}const ve=ss.define,Ho=ve(),Ka=ve(),Qb=ve(Ka),Zb=ve(Ka),Fa=ve(),Bo=ve(Fa),bh=ve(Fa),zs=ve(),Ti=ve(zs),Rs=ve(),Ms=ve(),Hh=ve(),Jc=ve(Hh),Io=ve(),Te={comment:Ho,lineComment:ve(Ho),blockComment:ve(Ho),docComment:ve(Ho),name:Ka,variableName:ve(Ka),typeName:Qb,tagName:ve(Qb),propertyName:Zb,attributeName:ve(Zb),className:ve(Ka),labelName:ve(Ka),namespace:ve(Ka),macroName:ve(Ka),literal:Fa,string:Bo,docString:ve(Bo),character:ve(Bo),attributeValue:ve(Bo),number:bh,integer:ve(bh),float:ve(bh),bool:ve(Fa),regexp:ve(Fa),escape:ve(Fa),color:ve(Fa),url:ve(Fa),keyword:Rs,self:ve(Rs),null:ve(Rs),atom:ve(Rs),unit:ve(Rs),modifier:ve(Rs),operatorKeyword:ve(Rs),controlKeyword:ve(Rs),definitionKeyword:ve(Rs),moduleKeyword:ve(Rs),operator:Ms,derefOperator:ve(Ms),arithmeticOperator:ve(Ms),logicOperator:ve(Ms),bitwiseOperator:ve(Ms),compareOperator:ve(Ms),updateOperator:ve(Ms),definitionOperator:ve(Ms),typeOperator:ve(Ms),controlOperator:ve(Ms),punctuation:Hh,separator:ve(Hh),bracket:Jc,angleBracket:ve(Jc),squareBracket:ve(Jc),paren:ve(Jc),brace:ve(Jc),content:zs,heading:Ti,heading1:ve(Ti),heading2:ve(Ti),heading3:ve(Ti),heading4:ve(Ti),heading5:ve(Ti),heading6:ve(Ti),contentSeparator:ve(zs),list:ve(zs),quote:ve(zs),emphasis:ve(zs),strong:ve(zs),link:ve(zs),monospace:ve(zs),strikethrough:ve(zs),inserted:ve(),deleted:ve(),changed:ve(),invalid:ve(),meta:Io,documentMeta:ve(Io),annotation:ve(Io),processingInstruction:ve(Io),definition:ss.defineModifier("definition"),constant:ss.defineModifier("constant"),function:ss.defineModifier("function"),standard:ss.defineModifier("standard"),local:ss.defineModifier("local"),special:ss.defineModifier("special")};for(let s in Te){let l=Te[s];l instanceof ss&&(l.name=s)}ay([{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 y1="modulepreload",_1=function(s,l){return new URL(s,l).href},Kb={},Ve=function(l,r,c){let o=Promise.resolve();if(r&&r.length>0){let h=function(_){return Promise.all(_.map(j=>Promise.resolve(j).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const p=document.getElementsByTagName("link"),m=document.querySelector("meta[property=csp-nonce]"),x=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));o=h(r.map(_=>{if(_=_1(_,c),_ in Kb)return;Kb[_]=!0;const j=_.endsWith(".css"),v=j?'[rel="stylesheet"]':"";if(!!c)for(let O=p.length-1;O>=0;O--){const z=p[O];if(z.href===_&&(!j||z.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${_}"]${v}`))return;const k=document.createElement("link");if(k.rel=j?"stylesheet":y1,j||(k.as="script"),k.crossOrigin="",k.href=_,x&&k.setAttribute("nonce",x),document.head.appendChild(k),j)return new Promise((O,z)=>{k.addEventListener("load",O),k.addEventListener("error",()=>z(new Error(`Unable to preload CSS for ${_}`)))})}))}function d(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return o.then(h=>{for(const p of h||[])p.status==="rejected"&&d(p.reason);return l().catch(d)})},iy={js:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),cjs:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),mjs:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript(),jsx:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({jsx:!0}),ts:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),mts:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),cts:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0}),tsx:async()=>(await Ve(async()=>{const{javascript:s}=await import("./index-Bw0U50QY.js");return{javascript:s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).javascript({typescript:!0,jsx:!0}),json:async()=>(await Ve(async()=>{const{json:s}=await import("./index-Czu0PbLS.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),jsonc:async()=>(await Ve(async()=>{const{json:s}=await import("./index-Czu0PbLS.js");return{json:s}},__vite__mapDeps([6,1,2,3,4]),import.meta.url)).json(),css:async()=>(await Ve(async()=>{const{css:s}=await import("./index-Iwl1w0_V.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),scss:async()=>(await Ve(async()=>{const{css:s}=await import("./index-Iwl1w0_V.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),less:async()=>(await Ve(async()=>{const{css:s}=await import("./index-Iwl1w0_V.js");return{css:s}},__vite__mapDeps([7,1,2,3,4]),import.meta.url)).css(),html:async()=>(await Ve(async()=>{const{html:s}=await import("./index-DdCJlB8h.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),htm:async()=>(await Ve(async()=>{const{html:s}=await import("./index-DdCJlB8h.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),vue:async()=>(await Ve(async()=>{const{html:s}=await import("./index-DdCJlB8h.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),svelte:async()=>(await Ve(async()=>{const{html:s}=await import("./index-DdCJlB8h.js");return{html:s}},__vite__mapDeps([8,1,7,2,3,4,0,5]),import.meta.url)).html(),md:async()=>(await Ve(async()=>{const{markdown:s}=await import("./index-BDuAzkOQ.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),markdown:async()=>(await Ve(async()=>{const{markdown:s}=await import("./index-BDuAzkOQ.js");return{markdown:s}},__vite__mapDeps([9,3,4,2,5,8,1,7,0]),import.meta.url)).markdown(),py:async()=>(await Ve(async()=>{const{python:s}=await import("./index-DO1FY4r1.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),pyi:async()=>(await Ve(async()=>{const{python:s}=await import("./index-DO1FY4r1.js");return{python:s}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url)).python(),yaml:async()=>(await Ve(async()=>{const{yaml:s}=await import("./index-BSEf83Uc.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),yml:async()=>(await Ve(async()=>{const{yaml:s}=await import("./index-BSEf83Uc.js");return{yaml:s}},__vite__mapDeps([11,1,2,3,4]),import.meta.url)).yaml(),rs:async()=>(await Ve(async()=>{const{rust:s}=await import("./index-CZF-u-hv.js");return{rust:s}},__vite__mapDeps([12,1,2,3,4]),import.meta.url)).rust(),c:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-Bg0VD211.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),h:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-Bg0VD211.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cc:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-Bg0VD211.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),cpp:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-Bg0VD211.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),hpp:async()=>(await Ve(async()=>{const{cpp:s}=await import("./index-Bg0VD211.js");return{cpp:s}},__vite__mapDeps([13,1,2,3,4]),import.meta.url)).cpp(),java:async()=>(await Ve(async()=>{const{java:s}=await import("./index-J2jvoYvL.js");return{java:s}},__vite__mapDeps([14,1,2,3,4]),import.meta.url)).java(),go:async()=>(await Ve(async()=>{const{go:s}=await import("./index-4S0cl_O2.js");return{go:s}},__vite__mapDeps([15,1,2,3,4,5]),import.meta.url)).go(),php:async()=>(await Ve(async()=>{const{php:s}=await import("./index-09MC_4AF.js");return{php:s}},__vite__mapDeps([16,1,8,7,2,3,4,0,5]),import.meta.url)).php(),sql:async()=>(await Ve(async()=>{const{sql:s}=await import("./index-D57ZXpBD.js");return{sql:s}},__vite__mapDeps([17,2,3,4,1,5]),import.meta.url)).sql(),xml:async()=>(await Ve(async()=>{const{xml:s}=await import("./index-CmCj0IE6.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml(),svg:async()=>(await Ve(async()=>{const{xml:s}=await import("./index-CmCj0IE6.js");return{xml:s}},__vite__mapDeps([18,1,2,3,4]),import.meta.url)).xml()},v1={".mcp.json":"json",dockerfile:"yaml",makefile:"yaml"},S1={javascript:"js",node:"js",typescript:"ts",python:"py",python3:"py",yml:"yaml",rust:"rs",golang:"go","c++":"cpp",cplusplus:"cpp"};async function j1(s){const l=S1[s.toLowerCase()]??s.toLowerCase(),r=iy[l];return r?r().catch(()=>null):null}async function k1(s){const l=(s.split("/").pop()??"").toLowerCase(),r=v1[l]??l.split(".").pop()??"",c=iy[r];return c?c().catch(()=>null):null}const w1=ay([{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 qo(s){return s.replace(/[&<>]/g,l=>l==="&"?"&":l==="<"?"<":">")}async function N1(s,l){const r=l?await j1(l):null;if(!r)return qo(s);try{const c=r.language.parser.parse(s);let o="";return g1(s,c,w1,(d,h)=>{o+=h?`<span class="${h}">${qo(d)}</span>`:qo(d)},()=>{o+=`
|
|
117
|
+
`}),o}catch{return qo(s)}}vt.setOptions({gfm:!0,breaks:!1});function ry(s){var r;const l=(r=s.split(".").pop())==null?void 0:r.toLowerCase();return l==="md"||l==="markdown"}async function tp(s){const l=await vt.parse(s,{async:!0,walkTokens:async r=>{if(r.type!=="code")return;const c=r;c.text=await N1(c.text,c.lang??""),c.escaped=!0}});return Kv.sanitize(l)}function Fb(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:ry(s.path)}}function ca(s){return!s.binary&&!s.tooLarge&&s.text!==s.saved}function T1(s){return s.split("/").pop()??s}function Ui(s){const l=s.lastIndexOf("/");return l===-1?"":s.slice(0,l)}function Wo(s){return s<1024?`${s} Б`:s<1024*1024?`${(s/1024).toFixed(1)} КБ`:`${(s/1024/1024).toFixed(1)} МБ`}function Mr({x:s,y:l,items:r,note:c,onClose:o}){const d=y.useRef(null),[h,p]=y.useState({left:s,top:l}),[m,x]=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(),k=8,O=Math.max(k,Math.min(s,window.innerWidth-E.width-k)),z=Math.max(k,Math.min(l,window.innerHeight-E.height-k));p({left:O,top:z})},[s,l]),y.useLayoutEffect(()=>{var v;(v=d.current)==null||v.focus()},[]),y.useLayoutEffect(()=>{function v(k){var O;(O=d.current)!=null&&O.contains(k.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 j(v){if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),o();return}const E=r.map((k,O)=>({item:k,index:O})).filter(k=>!k.item.disabled);if(E.length!==0){if(v.key==="ArrowDown"||v.key==="ArrowUp"){v.preventDefault();const k=v.key==="ArrowDown"?1:-1,O=E.findIndex(ee=>ee.index===m),z=E[(((O===-1?0:O)+k)%E.length+E.length)%E.length];z&&x(z.index);return}if(v.key==="Enter"||v.key===" "){v.preventDefault();const k=r[m];k&&_(k)}}}return i.jsxs("div",{ref:d,className:"ctxmenu",style:{left:h.left,top:h.top},role:"menu",tabIndex:-1,onKeyDown:j,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===m?" is-cursor":""),onMouseEnter:()=>x(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 E1=3500,A1=9e3,Jb=220;function qi({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 p=s.ok?E1:A1,m=setTimeout(()=>d(!0),p),x=setTimeout(()=>c(null),p+Jb);return()=>{clearTimeout(m),clearTimeout(x)}},[s]),!r)return null;const h=()=>{d(!0),setTimeout(()=>{c(null),l==null||l()},Jb)};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:p=>p.stopPropagation(),children:[r.url.replace(/^https?:\/\//,"")," ↗"]}),r.url&&l&&i.jsx("button",{type:"button",className:"oplog__dismiss",title:"Закрыть","aria-label":"Закрыть сообщение",onClick:h,children:"✕"})]})}function fa({value:s,className:l,placeholder:r="Название сессии",onCommit:c,onCancel:o}){const[d,h]=y.useState(s),p=y.useRef(null);y.useEffect(()=>{var x;(x=p.current)==null||x.select()},[]);function m(){const x=d.trim();if(!x||x===s)return o();c(x)}return i.jsx("input",{ref:p,className:l?`rename ${l}`:"rename",value:d,autoFocus:!0,spellCheck:!1,placeholder:r,onChange:x=>h(x.target.value),onBlur:m,onKeyDown:x=>{x.stopPropagation(),x.key==="Enter"?(x.preventDefault(),m()):x.key==="Escape"&&(x.preventDefault(),o())}})}function Zr({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 C1=500,Ei="application/x-ccv-fs-path",R1=200;function M1({open:s,tree:l,expanded:r,activePath:c,dirty:o,gitChanges:d,result:h,searchResult:p,onSearch:m,onReveal:x,onToggle:_,onOpen:j,onCreate:v,onRename:E,onMove:k,onCopy:O,onDelete:z,onRefresh:ee,onClose:te,zoomed:K,onToggleZoom:M}){const[F,H]=y.useState(""),[A,Z]=y.useState(null),[ae,G]=y.useState(null),[J,D]=y.useState(null),[ge,Se]=y.useState(null),[xe,B]=y.useState(null),[ue,se]=y.useState(null),be=uf("(hover: hover)"),Ce=y.useRef(null),w=y.useMemo(()=>L1(d),[d]);function Q(W){return!(!J||W===J.path||J.kind==="dir"&&W.startsWith(`${J.path}/`)||W===Ui(J.path))}function re(W){return!(!xe||W===xe.path||xe.kind==="dir"&&W.startsWith(`${xe.path}/`)||xe.mode==="cut"&&W===Ui(xe.path))}function oe(W){B({path:W.path,kind:W.kind,mode:"copy"})}function ye(W){B({path:W.path,kind:W.kind,mode:"cut"})}function je(W){!xe||!re(W)||(W&&!r.has(W)&&_(W),xe.mode==="cut"?(k(xe.path,W),B(null)):O(xe.path,W))}function Me(W,de){const we=W.touches[0];if(!we)return;const L={timer:0,x:we.clientX,y:we.clientY,el:W.currentTarget,fired:!1};L.timer=window.setTimeout(()=>{L.fired=!0,de(L.x,L.y,L.el)},C1),Ce.current=L}function ht(W){const de=Ce.current,we=W.touches[0];!de||!we||Math.hypot(we.clientX-de.x,we.clientY-de.y)>10&&(window.clearTimeout(de.timer),Ce.current=null)}function lt(W){const de=Ce.current;de&&(window.clearTimeout(de.timer),de.fired&&W.preventDefault())}function Nn(){var W;return(W=Ce.current)!=null&&W.fired?(Ce.current=null,!0):!1}function Je(W,de,we,L){H((L==null?void 0:L.path)??""),se({x:W,y:de,opener:we,entry:L})}function Kt(){const W=ue==null?void 0:ue.opener;se(null),W!=null&&W.isConnected&&W.focus()}function ct(W){return{onContextMenu:de=>{de.preventDefault(),Je(de.clientX,de.clientY,de.currentTarget,W)},onTouchStart:de=>Me(de,(we,L,V)=>Je(we,L,V,W)),onTouchMove:ht,onTouchEnd:lt,onTouchCancel:lt}}function rn(W){W.target===W.currentTarget&&(W.preventDefault(),Je(W.clientX,W.clientY,W.currentTarget,null))}function Be(W){W.target===W.currentTarget&&Me(W,(de,we,L)=>Je(de,we,L,null))}function rt(W){if(!(W.ctrlKey||W.metaKey)||W.target instanceof HTMLInputElement)return;const de=W.key.toLowerCase();if(de==="v"){W.preventDefault(),je(sl());return}if(!F)return;const we=Wb(l,F);we&&(de==="c"?(W.preventDefault(),oe(we)):de==="x"&&(W.preventDefault(),ye(we)))}function Hn(W){return de=>{de.dataTransfer.effectAllowed="move",de.dataTransfer.setData(Ei,W.path),D({path:W.path,kind:W.kind})}}function wt(){D(null),Se(null)}function Ot(W){return de=>{de.dataTransfer.types.includes(Ei)&&(de.stopPropagation(),!(W.kind!=="dir"||!Q(W.path))&&(de.preventDefault(),Se(W.path)))}}function Ft(W){return de=>{if(!de.dataTransfer.types.includes(Ei)||(de.stopPropagation(),W.kind!=="dir"||!Q(W.path)))return;de.preventDefault();const we=de.dataTransfer.getData(Ei);Se(null),we&&k(we,W.path)}}function tn(W){!W.dataTransfer.types.includes(Ei)||!Q("")||(W.preventDefault(),Se(""))}function $t(W){if(!W.dataTransfer.types.includes(Ei)||!Q(""))return;W.preventDefault();const de=W.dataTransfer.getData(Ei);Se(null),de&&k(de,"")}const[Nt,Qe]=y.useState(""),We=Nt.trim(),dn=We.length>0,Jt=y.useRef(null),Qt=y.useRef(m);Qt.current=m;function Bn(W){Qe(W),Jt.current&&clearTimeout(Jt.current);const de=W.trim();if(!de){Qt.current("");return}Jt.current=setTimeout(()=>Qt.current(de),R1)}function Tn(W){Jt.current&&clearTimeout(Jt.current),Qe(""),Qt.current(""),H(W.path),x(W)}const hn=dn&&(p==null?void 0:p.query)===We?p:null;function sl(){if(F==="")return"";const W=Wb(l,F);if((W==null?void 0:W.kind)==="dir")return F;const de=F.lastIndexOf("/");return de===-1?"":F.slice(0,de)}function zt(W,de){const we=de??sl();we&&!r.has(we)&&_(we),G({parent:we,kind:W})}function bt(){if(!ue)return[];const W=L=>be?L:void 0;if(!ue.entry)return[{id:"paste",label:"Вставить в корень проекта",hint:W("Ctrl+V"),disabled:!re(""),onSelect:()=>je("")},{id:"new-file",label:"Создать файл",onSelect:()=>zt("file","")},{id:"new-dir",label:"Создать каталог",onSelect:()=>zt("dir","")}];const de=ue.entry,we=[de.kind==="file"?{id:"open",label:"Открыть",onSelect:()=>j(de.path)}:{id:"toggle",label:r.has(de.path)?"Свернуть":"Развернуть",onSelect:()=>_(de.path)},{id:"copy",label:"Копировать",hint:W("Ctrl+C"),onSelect:()=>oe(de)},{id:"cut",label:"Вырезать",hint:W("Ctrl+X"),onSelect:()=>ye(de)}];return de.kind==="dir"&&(we.push({id:"paste",label:"Вставить",hint:W("Ctrl+V"),disabled:!re(de.path),onSelect:()=>je(de.path)}),we.push({id:"new-file",label:"Создать файл",onSelect:()=>zt("file",de.path)}),we.push({id:"new-dir",label:"Создать каталог",onSelect:()=>zt("dir",de.path)})),we.push({id:"rename",label:"Переименовать",onSelect:()=>Z(de.path)}),we.push({id:"delete",label:"Удалить",onSelect:()=>z(de)}),we}const Ut=dn?[]:$e("",0);function $e(W,de){const we=l[W],L=[];if(ae&&ae.parent===W&&L.push(i.jsxs("div",{className:"fsrow fsrow--draft",style:ua(de),children:[i.jsx("span",{className:"fsrow__icon",children:ae.kind==="dir"?i.jsx(af,{}):i.jsx(rf,{})}),i.jsx(fa,{className:"rename--file",value:"",placeholder:ae.kind==="dir"?"имя каталога":"имя файла",onCommit:V=>{G(null),v(W,ae.kind,V)},onCancel:()=>G(null)})]},`draft:${W}`)),!we)return L.push(i.jsx("p",{className:"fsrow__pending",style:ua(de),children:"читаем…"},`wait:${W}`)),L;we.length===0&&!ae&&L.push(i.jsx("p",{className:"fsrow__pending",style:ua(de),children:"пусто"},`empty:${W}`));for(const V of we){const _e=V.kind==="dir"&&r.has(V.path);L.push(A===V.path?i.jsxs("div",{className:"fsrow fsrow--draft",style:ua(de),children:[i.jsx("span",{className:"fsrow__icon",children:V.kind==="dir"?i.jsx(af,{open:_e}):i.jsx(rf,{})}),i.jsx(fa,{className:"rename--file",value:V.name,placeholder:"новое имя",onCommit:ze=>{Z(null),E(V.path,ze)},onCancel:()=>Z(null)})]},V.path):i.jsx(O1,{entry:V,depth:de,open:_e,active:V.path===c,selected:V.path===F,dirty:o.has(V.path),gitStatus:w.get(V.path),dragging:(J==null?void 0:J.path)===V.path,dropTarget:ge===V.path,cut:(xe==null?void 0:xe.mode)==="cut"&&xe.path===V.path,onClick:()=>{Nn()||(H(V.path),V.kind==="dir"?_(V.path):j(V.path))},onRename:()=>Z(V.path),onDelete:()=>z(V),onDragStart:Hn(V),onDragEnd:wt,onDragOver:Ot(V),onDrop:Ft(V),...ct(V)},V.path)),_e&&L.push(...$e(V.path,de+1))}return L}function Qn(){if(!hn)return[i.jsx("p",{className:"fsrow__pending",style:ua(0),children:"ищем…"},"search:wait")];if(hn.entries.length===0)return[i.jsx("p",{className:"fsrow__pending",style:ua(0),children:"ничего не найдено"},"search:empty")];const W=hn.entries.map(de=>i.jsx(D1,{entry:de,gitStatus:w.get(de.path),onClick:()=>Tn(de)},de.path));return hn.truncated&&W.push(i.jsxs("p",{className:"fsrow__pending",style:ua(0),children:["показаны первые ",hn.entries.length," — уточните запрос"]},"search:truncated")),W}return i.jsxs("aside",{className:(s?"sidepane sidepane--files sidepane--open":"sidepane sidepane--files")+(K?" sidepane--zoomed":""),"aria-label":"Файлы проекта",onKeyDown:rt,children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:W=>{M&&(W.target.closest("button")||M())},children:[i.jsx(B1,{}),i.jsx("span",{className:"sidepane__title",children:"Файлы"}),i.jsx("button",{className:"sidepane__btn",title:"Новый файл","aria-label":"Новый файл",onClick:()=>zt("file"),children:i.jsx(U1,{})}),i.jsx("button",{className:"sidepane__btn",title:"Новый каталог","aria-label":"Новый каталог",onClick:()=>zt("dir"),children:i.jsx(H1,{})}),i.jsx("button",{className:"sidepane__btn",title:"Перечитать дерево","aria-label":"Перечитать дерево",onClick:ee,children:"↻"}),M&&i.jsx("button",{className:"sidepane__btn",title:K?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":K?"Свернуть панель файлов":"Развернуть панель файлов на весь экран","aria-pressed":K,onClick:M,children:i.jsx(Zr,{active:K})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель файлов",onClick:te,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(I1,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:Nt,spellCheck:!1,placeholder:"Поиск файлов и папок…","aria-label":"Поиск файлов и папок",onChange:W=>Bn(W.target.value),onKeyDown:W=>{W.stopPropagation(),W.key==="Escape"&&(W.preventDefault(),Nt?Bn(""):W.currentTarget.blur())}}),Nt&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>Bn(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree"+(ge===""?" fstree--drop-target":""),tabIndex:-1,onDragOver:tn,onDrop:$t,onContextMenu:rn,onTouchStart:Be,onTouchMove:ht,onTouchEnd:lt,onTouchCancel:lt,children:dn?Qn():Ut}),i.jsx(qi,{result:h}),ue&&i.jsx(Mr,{x:ue.x,y:ue.y,items:bt(),onClose:Kt})]})}function O1({entry:s,depth:l,open:r,active:c,selected:o,dirty:d,gitStatus:h,dragging:p,dropTarget:m,cut:x,onClick:_,onRename:j,onDelete:v,onDragStart:E,onDragEnd:k,onDragOver:O,onDrop:z,onContextMenu:ee,onTouchStart:te,onTouchMove:K,onTouchEnd:M,onTouchCancel:F}){const H="fsrow"+(c?" is-open":"")+(o&&!c?" is-selected":"")+(s.ignored?" fsrow--ignored":"")+(p?" fsrow--dragging":"")+(m?" fsrow--drop-target":"")+(x?" fsrow--cut":"");return i.jsxs("div",{className:H,style:ua(l),draggable:!0,onDragStart:E,onDragEnd:k,onDragOver:O,onDrop:z,onContextMenu:ee,onTouchStart:te,onTouchMove:K,onTouchEnd:M,onTouchCancel:F,children:[i.jsxs("button",{className:"fsrow__main",onClick:_,title:cy(s),children:[i.jsx("span",{className:"fsrow__icon"+sf("fsrow__icon",h),children:s.kind==="dir"?i.jsx(af,{open:r}):i.jsx(rf,{})}),i.jsx("span",{className:"fsrow__name"+sf("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:j,children:"✎"}),i.jsx("button",{className:"fsrow__act",title:"Удалить","aria-label":`Удалить ${s.name}`,onClick:v,children:"✕"})]})}function D1({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:ua(0),onClick:r,title:cy(s),children:[i.jsx("span",{className:"fsrow__icon"+sf("fsrow__icon",l),children:s.kind==="dir"?i.jsx(af,{}):i.jsx(rf,{})}),i.jsx("span",{className:"fsrow__name"+sf("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 cy(s){return s.ignored?`${s.path} — игнорируется git (.gitignore)`:s.path}function ua(s){return{"--depth":s}}function Wb(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 L1(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=z1(o.status);if(!d)continue;c(o.path,d);let h=Ui(o.path);for(;c(h,d),!!h;)h=Ui(h)}return l}function z1(s){if(s==="??")return"added";const[l="",r=""]=s;return l==="A"||l==="R"||l==="C"?"added":l==="M"||r==="M"?"modified":null}function sf(s,l){return l?` ${s}--git-${l}`:""}function af({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 rf(){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 U1(){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 H1(){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 B1(){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 I1(){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 q1=200;function G1({open:s,result:l,onSearch:r,onOpenMatch:c,onClose:o,zoomed:d,onToggleZoom:h}){const[p,m]=y.useState(""),x=p.trim(),_=x.length>0,j=y.useRef(null),v=y.useRef(r);v.current=r;function E(z){m(z),j.current&&clearTimeout(j.current);const ee=z.trim();if(!ee){v.current("");return}j.current=setTimeout(()=>v.current(ee),q1)}const k=_&&(l==null?void 0:l.query)===x?l:null;function O(){if(!k)return[i.jsx("p",{className:"fsrow__pending",children:"ищем…"},"grep:wait")];if(k.matches.length===0)return[i.jsx("p",{className:"fsrow__pending",children:"ничего не найдено"},"grep:empty")];const z=[];let ee="";for(const te of k.matches)te.path!==ee&&(ee=te.path,z.push(i.jsx("p",{className:"searchgroup__path",title:te.path,children:te.path},`path:${te.path}`))),z.push(i.jsx(Y1,{match:te,onClick:()=>c(te)},`${te.path}:${te.line}:${te.column}`));return k.truncated&&z.push(i.jsxs("p",{className:"fsrow__pending",children:["показаны первые ",k.matches.length," — уточните запрос"]},"grep:truncated")),z}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:z=>{h&&(z.target.closest("button")||h())},children:[i.jsx(X1,{}),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(Zr,{active:d})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель поиска",onClick:o,children:"✕"})]}),i.jsxs("div",{className:"fssearch",children:[i.jsx(V1,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:p,spellCheck:!1,placeholder:"Поиск по тексту во всех файлах…","aria-label":"Поиск по тексту во всех файлах",onChange:z=>E(z.target.value),onKeyDown:z=>{z.stopPropagation(),z.key==="Escape"&&(z.preventDefault(),p?E(""):z.currentTarget.blur())}}),p&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>E(""),children:"✕"})]}),i.jsx("div",{className:"sidepane__scroll fstree",children:_?O():i.jsx("p",{className:"sidepane__empty",children:"Введите текст, чтобы найти его во всех файлах проекта."})})]})}function Y1({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 X1(){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 V1(){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 Go=null;function $1(){return Go||(Go=Promise.all([Ve(()=>import("./index-DABElhgt.js"),__vite__mapDeps([19,4,3,2,20,5]),import.meta.url),Ve(()=>import("./index-891wE-Rj.js").then(s=>s.v),__vite__mapDeps([4,3]),import.meta.url),Ve(()=>import("./index-BHot-lnj.js"),[],import.meta.url),Ve(()=>import("./index-ZstREAcb.js"),__vite__mapDeps([20,3,4,2]),import.meta.url),Ve(()=>import("./codemirror-D11GWMsB.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 Go=null,s})),Go}function Q1({path:s,doc:l,revision:r,goto:c,onChange:o,onSave:d}){const h=y.useRef(null),p=y.useRef(null),m=y.useRef(null),x=y.useRef(new Map),_=y.useRef(new Map),j=y.useRef(new Set),v=y.useRef(null),E=y.useRef(o),k=y.useRef(d),O=y.useRef(s),z=y.useRef(r),ee=y.useRef(l);E.current=o,k.current=d,O.current=s,z.current=r,ee.current=l;const[te,K]=y.useState("loading"),[M,F]=y.useState(!1);function H(Z,ae,G,J,D){const ge=x.current.get(J),Se=_.current.get(J)===D;if(ge&&Se)G.setState(ge);else{const B=Z.EditorState.create({doc:ee.current,extensions:[Z.basicSetup,Z.Prec.highest(Z.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(k.current(O.current),!0)}])),Z.keymap.of([Z.indentWithTab]),ae.of([]),Z.editorTheme,Z.editorHighlight,Z.EditorView.updateListener.of(ue=>{ue.docChanged&&E.current(O.current,ue.state.doc.toString())})]});x.current.set(J,B),_.current.set(J,D),G.setState(B),j.current.delete(J)}if(j.current.has(J))return()=>{};let xe=!1;return k1(J).then(B=>{xe||!B||O.current!==J||(G.dispatch({effects:ae.reconfigure(B)}),x.current.set(J,G.state),j.current.add(J))}),()=>{xe=!0}}y.useEffect(()=>{if(!h.current)return;let ae=!1,G=null,J=null;K("loading"),F(!1);const D=window.setTimeout(()=>{ae||F(!0)},200);return(async()=>{let ge;try{ge=await $1()}catch{window.clearTimeout(D),ae||K("error");return}if(ae||!h.current)return;window.clearTimeout(D);const Se=new ge.Compartment;v.current=Se,m.current=ge,J=new ge.EditorView({parent:h.current}),p.current=J,G=H(ge,Se,J,O.current,z.current),K("ready")})(),()=>{ae=!0,window.clearTimeout(D),G==null||G(),J==null||J.destroy(),p.current===J&&(p.current=null),m.current=null,v.current=null}},[]),y.useEffect(()=>{const Z=m.current,ae=p.current,G=v.current;if(!(!Z||!ae||!G))return H(Z,G,ae,s,r)},[s,r]);const A=y.useRef(0);return y.useEffect(()=>{const Z=p.current,ae=m.current;if(!Z||!ae||!c||c.token===A.current)return;A.current=c.token;const G=Z.state.doc.lines,J=Math.min(Math.max(c.line,1),G),D=Z.state.doc.line(J),ge=Math.min(D.from+Math.max(c.column-1,0),D.to);Z.dispatch({selection:ae.EditorSelection.cursor(ge),effects:ae.EditorView.scrollIntoView(ge,{y:"center"})}),Z.focus()},[c]),y.useEffect(()=>()=>{const Z=p.current;Z&&x.current.set(s,Z.state)},[s]),i.jsxs("div",{className:"editor__code",children:[i.jsx("div",{ref:h,className:"editor__code-surface"+(te==="ready"?"":" is-hidden")}),te==="loading"&&M&&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:"Загружается редактор…"})]}),te==="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 Is({value:s,options:l,onChange:r,className:c,title:o,ariaLabel:d,placeholder:h="—"}){const[p,m]=y.useState(!1),[x,_]=y.useState(0),j=y.useRef(null),v=y.useRef(null),E=l.find(z=>z.value===s)??null;y.useEffect(()=>{if(!p)return;const z=l.findIndex(ee=>ee.value===s);_(z===-1?0:z)},[p]),y.useEffect(()=>{if(!p)return;function z(ee){var te;(te=j.current)!=null&&te.contains(ee.target)||m(!1)}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[p]),y.useEffect(()=>{var z,ee;p&&((ee=(z=v.current)==null?void 0:z.querySelector(".is-cursor"))==null||ee.scrollIntoView({block:"nearest"}))},[p,x]),y.useEffect(()=>{if(!p)return;const z=v.current,ee=Z1(j.current);if(!z||!ee)return;const te=z.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;te>0&&(ee.scrollTop+=Math.min(te+8,z.offsetHeight))},[p]);function k(z){m(!1),z.value!==s&&r(z.value)}function O(z){if(z.key==="Escape"){if(!p)return;z.preventDefault(),z.stopPropagation(),m(!1);return}if(z.key==="ArrowDown"||z.key==="ArrowUp"){if(z.preventDefault(),!p)return m(!0);const ee=z.key==="ArrowDown"?1:l.length-1;return _(te=>(te+ee)%l.length)}if(z.key==="Enter"||z.key===" "){if(z.preventDefault(),!p)return m(!0);const ee=l[x];ee&&k(ee)}}return i.jsxs("div",{ref:j,className:"select"+(p?" select--open":"")+(c?` ${c}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:o,"aria-label":d??o,"aria-haspopup":"listbox","aria-expanded":p,onClick:()=>m(z=>!z),onKeyDown:O,children:[i.jsx("span",{className:"select__value",children:(E==null?void 0:E.label)??h}),i.jsx(K1,{})]}),p&&i.jsx("div",{ref:v,className:"select__menu",role:"listbox","aria-label":d??o,children:l.map((z,ee)=>i.jsxs("button",{type:"button",role:"option","aria-selected":z.value===s,className:"select__option"+(ee===x?" is-cursor":"")+(z.value===s?" is-on":""),onMouseEnter:()=>_(ee),onClick:()=>k(z),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:z.value===s?"✓":""}),i.jsx("span",{className:"select__label",children:z.label}),z.hint&&i.jsx("span",{className:"select__hint",children:z.hint})]},z.value))})]})}function Z1(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 K1(){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 F1(){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 J1(){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 W1(){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 P1({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 p=eS(r,l);return o?i.jsx("div",{className:"mediaview mediaview--message",children:i.jsxs("p",{className:"mediaview__error",children:["Файл слишком велик для просмотра (",Wo(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:"Повторить"})]}):p?l.startsWith("image/")?i.jsx(nS,{url:p}):l.startsWith("video/")?i.jsx(sS,{url:p}):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 eS(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 p=0;p<o.length;p++)d[p]=o.charCodeAt(p);const h=URL.createObjectURL(new Blob([d],{type:l}));return c(h),()=>URL.revokeObjectURL(h)},[s,l]),r}const Za=1,uy=8,Yo=1.25;function tS(s){return Math.min(uy,Math.max(Za,s))}function nS({url:s}){const[l,r]=y.useState({scale:Za,x:0,y:0}),[c,o]=y.useState(!1),d=y.useRef(null),h=y.useRef(null);function p(E,k,O){r(z=>{const ee=tS(z.scale*E);if(ee===z.scale)return z;if(ee<=Za)return{scale:Za,x:0,y:0};const te=(k-z.x)/z.scale,K=(O-z.y)/z.scale;return{scale:ee,x:k-ee*te,y:O-ee*K}})}y.useEffect(()=>{const E=d.current;if(!E)return;function k(O){O.preventDefault();const z=E.getBoundingClientRect(),ee=O.clientX-z.left-z.width/2,te=O.clientY-z.top-z.height/2;p(O.deltaY<0?Yo:1/Yo,ee,te)}return E.addEventListener("wheel",k,{passive:!1}),()=>E.removeEventListener("wheel",k)},[]);function m(E){l.scale<=Za||(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 x(E){const k=h.current;!k||k.pointerId!==E.pointerId||r(O=>({...O,x:k.origX+(E.clientX-k.startX),y:k.origY+(E.clientY-k.startY)}))}function _(){h.current=null,o(!1)}const j=l.scale>Za,v=!j&&l.x===0&&l.y===0;return i.jsxs("div",{className:"mediaview mediaview--image",children:[i.jsx("div",{ref:d,className:"mediaview__stage"+(j?c?" is-dragging":" is-zoomed":""),onPointerDown:m,onPointerMove:x,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<=Za,title:"Уменьшить","aria-label":"Уменьшить",onClick:()=>p(1/Yo,0,0),children:i.jsx(J1,{})}),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:()=>p(Yo,0,0),children:i.jsx(F1,{})}),i.jsx("button",{className:"btn btn--sm",disabled:v,title:"Вписать в окно","aria-label":"Сбросить масштаб — вписать в окно",onClick:()=>r({scale:Za,x:0,y:0}),children:i.jsx(W1,{})})]})]})}const lS=[{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 sS({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(Is,{className:"mediaview__speedselect",value:r,onChange:c,ariaLabel:"Скорость воспроизведения",options:lS})]})]})}function aS({file:s,goto:l,onChange:r,onSave:c,onReload:o,onOverwrite:d,onRequestMedia:h,onTogglePreview:p}){const m=ca(s),x=ry(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:[Wo(s.size),s.eol==="crlf"&&" · CRLF"]}),x&&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&&p(s.path),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(s.previewMode?"":" is-on"),role:"tab","aria-selected":!s.previewMode,onClick:()=>s.previewMode&&p(s.path),children:"Код"})]}),i.jsx("button",{className:"btn btn--sm",disabled:!m,title:"Сохранить (Ctrl+S)",onClick:()=>c(s.path),children:m?"Сохранить":"Сохранено"})]}),s.stale&&i.jsxs("div",{className:"editor__warn",children:[i.jsxs("span",{children:["Файл изменился на диске",m?" — а здесь есть несохранённые правки.":"."]}),i.jsx("button",{className:"btn btn--sm",onClick:()=>o(s.path),children:"Взять с диска"}),m&&i.jsx("button",{className:"btn btn--sm btn--danger",onClick:()=>d(s.path),children:"Сохранить поверх"})]}),s.binary&&s.mediaMime?i.jsx(P1,{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:["Это не текстовый файл — редактировать его здесь нечем. ",Wo(s.size)," на диске."]}):s.tooLarge?i.jsxs("p",{className:"editor__empty",children:["Файл слишком велик для редактора (",Wo(s.size),"). Такие правит агент, а не браузер."]}):x&&s.previewMode?i.jsx(iS,{text:s.text}):i.jsx(Q1,{path:s.path,doc:s.text,revision:s.revision,goto:l,onChange:r,onSave:c})]})}function iS({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return tp(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:l}})}function rS({files:s,activePath:l,busy:r,onSelect:c,onClose:o,zoomed:d,onToggleZoom:h}){return i.jsxs("div",{className:"worktabs",role:"tablist",onDoubleClick:p=>{h&&(p.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(p=>i.jsxs("div",{className:"worktab"+(p.path===l?" is-on":""),role:"tab","aria-selected":p.path===l,onDoubleClick:m=>{h&&(m.target.closest(".worktab__close, .worktab__dot")||h())},children:[i.jsx("button",{className:"worktab__name",title:p.path,onClick:()=>c(p.path),children:T1(p.path)}),ca(p)?i.jsx("button",{className:"worktab__dot",title:"Не сохранено — закрыть","aria-label":`Закрыть ${p.path}`,onClick:()=>o(p.path)}):i.jsx("button",{className:"worktab__close",title:"Закрыть","aria-label":`Закрыть ${p.path}`,onClick:()=>o(p.path),children:"✕"})]},p.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(Zr,{active:d})})]})}const oy="ccv:sidebar.collapsed",fy="ccv:sidebar.mode",dy="ccv:sidebar.foldersCollapsed",cS=500,Pb="транскрипт остаётся на диске — сессию можно вернуть из архива в любой момент.";function uS({open:s,connected:l,status:r,workspaces:c,archivedWorkspaces:o,workspaceFolders:d,sessionFolders:h,pinnedFolders:p,sessions:m,archived:x,pinned:_,activeWorkspaceId:j,activeSessionId:v,onSelectWorkspace:E,onSelectSession:k,onRenameSession:O,onPinSessions:z,onSelectPinned:ee,onCloseWorkspaces:te,onRestoreWorkspaces:K,onArchiveSessions:M,onUnarchiveSessions:F,onCreateFolder:H,onRenameFolder:A,onDeleteFolder:Z,onAssignToFolder:ae,onOpenWorkspace:G,onNewSession:J,onOpenExtensions:D,account:ge,onOpenAccount:Se,relay:xe,onOpenRelay:B,onOpenSettings:ue,themeMode:se,onCycleTheme:be}){const[Ce,w]=y.useState(null),[Q,re]=y.useState(null),[oe,ye]=y.useState(null),[je,Me]=y.useState(""),[ht,lt]=y.useState(xS),[Nn,Je]=y.useState(yS),[Kt,ct]=y.useState(_S);function rn(){ct(T=>{const he=T==="pinned"?"default":"pinned";try{localStorage.setItem(fy,he)}catch{}return he})}const Be=je.trim().toLowerCase(),rt=Be!=="",Hn=y.useMemo(()=>rt?c.filter(T=>T.name.toLowerCase().includes(Be)||T.path.toLowerCase().includes(Be)):c,[c,Be,rt]),wt=y.useMemo(()=>rt?o.filter(T=>T.name.toLowerCase().includes(Be)||T.path.toLowerCase().includes(Be)):o,[o,Be,rt]),Ot=y.useMemo(()=>rt?m.filter(T=>(T.title??"").toLowerCase().includes(Be)):m,[m,Be,rt]),Ft=y.useMemo(()=>rt?x.filter(T=>(T.title??"").toLowerCase().includes(Be)):x,[x,Be,rt]),tn=T=>{var he;return((he=c.find(Ge=>Ge.id===T))==null?void 0:he.name)??"—"},$t=T=>{var he;return(he=c.find(Ge=>Ge.id===T))==null?void 0:he.path},Nt=y.useMemo(()=>rt?_.filter(T=>(T.title??"").toLowerCase().includes(Be)||tn(T.workspaceId).toLowerCase().includes(Be)):_,[_,c,Be,rt]);function Qe(T){lt(he=>{const Ge=he.includes(T)?he.filter(pt=>pt!==T):[...he,T];try{localStorage.setItem(oy,JSON.stringify(Ge))}catch{}return Ge})}const We=T=>!ht.includes(T);function dn(T){Je(he=>{const Ge=he.includes(T)?he.filter(pt=>pt!==T):[...he,T];try{localStorage.setItem(dy,JSON.stringify(Ge))}catch{}return Ge})}const Jt=T=>!Nn.includes(T),Qt=y.useMemo(()=>Wc(Hn,d),[Hn,d]),Bn=y.useMemo(()=>Wc(wt,d),[wt,d]),Tn=y.useMemo(()=>Wc(Ot,h),[Ot,h]),hn=y.useMemo(()=>Wc(Ft,h),[Ft,h]),sl=y.useMemo(()=>Wc(Nt,p,T=>T.pinnedFolderId),[Nt,p]),zt=yh(Hn),bt=yh(wt),Ut=yh(Ot),[$e,Qn]=y.useState(null),[W,de]=y.useState(null),[we,L]=y.useState(null),[V,_e]=y.useState(null),ze=y.useRef(null);function st(T,he){const Ge=T.touches[0];if(!Ge)return;const pt={timer:0,x:Ge.clientX,y:Ge.clientY,el:T.currentTarget,fired:!1};pt.timer=window.setTimeout(()=>{pt.fired=!0,he(pt.x,pt.y,pt.el)},cS),ze.current=pt}function al(T){const he=ze.current,Ge=T.touches[0];!he||!Ge||Math.hypot(Ge.clientX-he.x,Ge.clientY-he.y)>10&&(window.clearTimeout(he.timer),ze.current=null)}function Pe(T){const he=ze.current;he&&(window.clearTimeout(he.timer),he.fired&&T.preventDefault())}function En(){var T;return(T=ze.current)!=null&&T.fired?(ze.current=null,!0):!1}function In(){const T=$e==null?void 0:$e.opener;Qn(null),T!=null&&T.isConnected&&T.focus()}function $l(){const T=W==null?void 0:W.opener;de(null),T!=null&&T.isConnected&&T.focus()}function da(){const T=we==null?void 0:we.opener;L(null),T!=null&&T.isConnected&&T.focus()}function qs(){const T=V==null?void 0:V.opener;_e(null),T!=null&&T.isConnected&&T.focus()}function Ll(T){return{onContextMenu:he=>{he.preventDefault(),Qn({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:zt.targetsFor(T)})},onTouchStart:he=>st(he,(Ge,pt,un)=>Qn({x:Ge,y:pt,opener:un,ids:zt.targetsFor(T)})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}function qn(T){return{onContextMenu:he=>{he.preventDefault(),de({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:bt.targetsFor(T)})},onTouchStart:he=>st(he,(Ge,pt,un)=>de({x:Ge,y:pt,opener:un,ids:bt.targetsFor(T)})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}function pl(T){return{onContextMenu:he=>{he.preventDefault(),L({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:Ut.targetsFor(T)})},onTouchStart:he=>st(he,(Ge,pt,un)=>L({x:Ge,y:pt,opener:un,ids:Ut.targetsFor(T)})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}function nn(T){return{onContextMenu:he=>{he.preventDefault(),_e({x:he.clientX,y:he.clientY,opener:he.currentTarget,ids:[T.id]})},onTouchStart:he=>st(he,(Ge,pt,un)=>_e({x:Ge,y:pt,opener:un,ids:[T.id]})),onTouchMove:al,onTouchEnd:Pe,onTouchCancel:Pe}}const _l=m.filter(T=>T.state!=="closed").length,Gn=$e?Hn.find(T=>T.id===$e.ids[0]):void 0,Ht=$e?[{id:"close",label:$e.ids.length>1?`Закрыть проекты (${$e.ids.length})`:"Закрыть проект",onSelect:()=>{te($e.ids),zt.clear()}},...Pc({folders:d,ids:$e.ids,hasFolder:(Gn==null?void 0:Gn.folderId)!=null,assign:(T,he)=>ae("workspace",T,he),onClear:()=>zt.clear(),onNewFolder:()=>ye("workspace")})]:[],Ze=$e?"закрытие не удаляет проект: каталог и история сессий остаются на диске — открыть его снова можно кнопкой «+ Проект»."+(j&&$e.ids.includes(j)&&_l>0?` в нём сейчас незавершённых сессий: ${_l} — при закрытии они остановятся на хосте.`:""):void 0,ln=W?wt.find(T=>T.id===W.ids[0]):void 0,is=W?[{id:"restore",label:W.ids.length>1?`Вернуть проекты (${W.ids.length})`:"Вернуть проект",onSelect:()=>{K(W.ids),bt.clear()}},...Pc({folders:d,ids:W.ids,hasFolder:(ln==null?void 0:ln.folderId)!=null,assign:(T,he)=>ae("workspace",T,he),onClear:()=>bt.clear(),onNewFolder:()=>ye("workspace")})]:[],An=W?"каталог и история сессий всё это время оставались на диске — восстановление их не трогает.":void 0,Cn=we?Ot.find(T=>T.id===we.ids[0]):void 0,zl=(Cn==null?void 0:Cn.pinned)!==!0,vl=we?[...we.ids.length===1?[{id:"rename",label:"Переименовать",onSelect:()=>w(we.ids[0])}]:[],{id:"pin",label:zl?we.ids.length>1?`Закрепить (${we.ids.length})`:"Закрепить":we.ids.length>1?`Открепить (${we.ids.length})`:"Открепить",onSelect:()=>{Cn&&z(Cn.workspaceId,we.ids,zl),Ut.clear()}},{id:"archive",label:we.ids.length>1?`Убрать в архив (${we.ids.length})`:"Убрать в архив",onSelect:()=>{M(j,we.ids),Ut.clear()}},...Pc({folders:h,ids:we.ids,hasFolder:(Cn==null?void 0:Cn.folderId)!=null,assign:(T,he)=>ae("session",T,he,j),onClear:()=>Ut.clear(),onNewFolder:()=>ye("session")})]:[],ys=we?Pb:void 0,It=V?Nt.find(T=>T.id===V.ids[0]):void 0,Ql=V?[{id:"rename",label:"Переименовать",onSelect:()=>w(V.ids[0])},{id:"unpin",label:"Открепить",onSelect:()=>{It&&z(It.workspaceId,[It.id],!1)}},{id:"archive",label:"Убрать в архив",onSelect:()=>{It&&M(It.workspaceId,[It.id])}},...It&&It.workspaceId===j?Pc({folders:h,ids:[It.id],hasFolder:It.folderId!=null,assign:(T,he)=>ae("session",T,he,It.workspaceId),onClear:()=>{},onNewFolder:()=>ye("session")}):[],...oS(It?Pc({folders:p,ids:[It.id],hasFolder:It.pinnedFolderId!=null,assign:(T,he)=>ae("pinned",T,he),onClear:()=>{},onNewFolder:()=>ye("pinned")}):[])]:[];function Zl(T){return i.jsx("div",{className:xh(T.id===j,zt.selected.includes(T.id)),...Ll(T),children:i.jsxs("button",{className:"row__main",onClick:he=>{En()||zt.click(he,T,()=>E(T.id))},children:[i.jsxs("span",{className:"row__title",children:[T.name,T.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",title:T.path,children:T.path})]})},T.id)}function pn(T){return i.jsxs("div",{className:xh(T.id===j,bt.selected.includes(T.id)),...qn(T),children:[i.jsxs("button",{className:"row__main",onClick:he=>{En()||bt.click(he,T,()=>E(T.id))},children:[i.jsxs("span",{className:"row__title",children:[T.name,T.hasClaudeMd&&" ·"]}),i.jsx("span",{className:"row__meta",children:TS(T)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть проект из архива",onClick:()=>K([T.id]),children:"Вернуть"})]},T.id)}function Tt(T){return i.jsx("div",{className:xh(T.id===v,Ut.selected.includes(T.id)),...Ce===T.id?{}:pl(T),children:Ce===T.id?i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:T.title??"",onCommit:he=>{O(T,he),w(null)},onCancel:()=>w(null)})}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"row__main",onClick:he=>{En()||Ut.click(he,T,()=>k(T))},children:[i.jsx(_h,{title:T.title??"Без названия",pinned:T.pinned===!0,projectName:tn(T.workspaceId),projectPath:$t(T.workspaceId)}),i.jsx(nx,{session:T,tail:new Date(T.updatedAt).toLocaleString()})]}),i.jsx("button",{className:"row__edit",title:"Переименовать","aria-label":"Переименовать сессию",onClick:()=>{En()||w(T.id)},children:"✎"})]})},T.id)}function Yn(T){return i.jsxs("div",{className:T.id===v?"row row--active":"row",children:[i.jsxs("button",{className:"row__main",onClick:()=>k(T),children:[i.jsx(_h,{title:T.title??"Без названия",pinned:!1,projectName:tn(T.workspaceId),projectPath:$t(T.workspaceId)}),i.jsx("span",{className:"row__meta",children:NS(T)})]}),i.jsx("button",{className:"row__restore",title:"Вернуть сессию из архива",onClick:()=>F([T.id]),children:"Вернуть"})]},T.id)}function Gs(T){return i.jsx("div",{className:T.id===v?"row row--active":"row",...Ce===T.id?{}:{title:"Действия со строкой — правый клик или долгое нажатие",...nn(T)},children:Ce===T.id?i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:T.title??"",onCommit:he=>{O(T,he),w(null)},onCancel:()=>w(null)})}):i.jsxs("button",{className:"row__main",onClick:()=>{En()||ee(T)},children:[i.jsx(_h,{title:T.title??"Без названия",pinned:!1,projectName:tn(T.workspaceId),projectPath:$t(T.workspaceId)}),i.jsx(nx,{session:T,tail:new Date(T.updatedAt).toLocaleString()})]})},T.id)}function cn(T,he){return i.jsx(mS,{folder:T,count:he,open:Jt(T.id),renaming:Q===T.id,onToggle:()=>dn(T.id),onStartRename:()=>re(T.id),onCommitRename:Ge=>{A(T.id,Ge),re(null)},onCancelRename:()=>re(null),onDelete:()=>Z(T.id)},T.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","aria-pressed":Kt==="pinned",title:Kt==="pinned"?"Показать все проекты и сессии":"Показать только закреплённые","aria-label":Kt==="pinned"?"Панель закреплённых сессий включена. Показать все проекты и сессии":"Показать только закреплённые сессии",onClick:rn,children:i.jsx(py,{})}),i.jsx("button",{className:"theme-btn",title:`Тема: ${tx[se]}`,"aria-label":`Тема: ${tx[se]}. Переключить`,onClick:be,children:i.jsx(vS,{mode:se})})]}),i.jsxs("div",{className:"fssearch fssearch--sidebar",children:[i.jsx(gS,{}),i.jsx("input",{className:"fssearch__input",type:"text",value:je,spellCheck:!1,placeholder:"Проект или сессия…","aria-label":"Поиск по проектам и сессиям",onChange:T=>Me(T.target.value),onKeyDown:T=>{T.stopPropagation(),T.key==="Escape"&&(T.preventDefault(),je?Me(""):T.currentTarget.blur())}}),je&&i.jsx("button",{className:"fssearch__clear",title:"Очистить поиск","aria-label":"Очистить поиск",onClick:()=>Me(""),children:"✕"})]}),i.jsx("div",{className:"sidebar__scroll",children:Kt==="pinned"?i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Закреплённые",count:Nt.length,open:We("pinned"),onToggle:()=>Qe("pinned"),action:{label:"Новая папка закреплённых",onClick:()=>{ye("pinned"),We("pinned")||Qe("pinned")}}}),We("pinned")&&i.jsxs(i.Fragment,{children:[oe==="pinned"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:"",placeholder:"Название папки",onCommit:T=>{H("pinned",T),ye(null)},onCancel:()=>ye(null)})})}),Nt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"закрепите сессию через её меню (правый клик или долгое нажатие) — она останется под рукой из любого проекта"})}),sl.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Gs(he))]},T.folder.id)),sl.ungrouped.map(T=>Gs(T))]})]}):i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Проекты",count:Hn.length,open:We("workspaces"),onToggle:()=>Qe("workspaces"),action:{label:"Новая папка проектов",onClick:()=>{ye("workspace"),We("workspaces")||Qe("workspaces")}}}),We("workspaces")&&i.jsxs(i.Fragment,{children:[oe==="workspace"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:"",placeholder:"Название папки",onCommit:T=>{H("workspace",T),ye(null)},onCancel:()=>ye(null)})})}),Hn.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока ни одного"})}),Qt.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Zl(he))]},T.folder.id)),Qt.ungrouped.map(T=>Zl(T))]}),o.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Архив проектов",count:wt.length,open:We("workspacesArchive"),onToggle:()=>Qe("workspacesArchive"),hint:"проект закрывают вручную; каталог и история сессий остаются на диске и открываются заново отсюда или через «+ Проект»"}),We("workspacesArchive")&&i.jsxs(i.Fragment,{children:[wt.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока пусто"})}),Bn.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>pn(he))]},T.folder.id)),Bn.ungrouped.map(T=>pn(T))]})]}),j&&i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Сессии",count:Ot.length,open:We("sessions"),onToggle:()=>Qe("sessions"),action:{label:"Новая папка сессий",onClick:()=>{ye("session"),We("sessions")||Qe("sessions")}}}),We("sessions")&&i.jsxs(i.Fragment,{children:[oe==="session"&&i.jsx("div",{className:"row",children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:"",placeholder:"Название папки",onCommit:T=>{H("session",T,j),ye(null)},onCancel:()=>ye(null)})})}),Ot.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока ни одной"})}),Tn.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Tt(he))]},T.folder.id)),Tn.ungrouped.map(T=>Tt(T))]}),x.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(eu,{title:"Архив",count:Ft.length,open:We("archive"),onToggle:()=>Qe("archive"),hint:"сессии без обращения дольше двух суток уезжают сюда сами; ничего не удаляется"}),We("archive")&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:"сюда сами уезжают сессии без обращения дольше двух суток; транскрипт остаётся на диске, ничего не удаляется"})}),Ft.length===0&&i.jsx("div",{className:"row",children:i.jsx("span",{className:"row__meta",children:rt?"Ничего не найдено":"Пока пусто"})}),hn.groups.map(T=>i.jsxs(y.Fragment,{children:[cn(T.folder,T.items.length),Jt(T.folder.id)&&T.items.map(he=>Yn(he))]},T.folder.id)),hn.ungrouped.map(T=>Yn(T))]})]})]})]})}),i.jsxs("div",{className:"sidebar__foot",children:[i.jsxs("button",{className:"account-btn sidebar__wide",title:"Аккаунт Claude",onClick:Se,children:[i.jsx("span",{className:ge!=null&&ge.loggedIn?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:ge===null?"Аккаунт":ge.loggedIn?ge.email||"Вход выполнен":"Войти в аккаунт"}),(ge==null?void 0:ge.plan)&&i.jsx("span",{className:"chip",children:ge.plan})]}),B&&i.jsxs("button",{className:"account-btn sidebar__wide",title:"Доступ с телефона и из браузера",onClick:B,children:[i.jsx("span",{className:xe!=null&&xe.connected?"dot dot--on":"dot"}),i.jsx("span",{className:"account-btn__id",children:xe===null?"Удалённый доступ":xe.paired?xe.connected?xe.name||"Удалённый доступ включён":"Удалённый доступ · нет связи":"Удалённый доступ"}),(xe==null?void 0:xe.connected)&&xe.clients>0&&i.jsx("span",{className:"chip",children:xe.clients})]}),i.jsx("button",{className:"btn btn--ghost sidebar__wide",disabled:!D,title:"MCP-серверы и плагины",onClick:()=>D==null?void 0:D(),children:"Расширения"}),i.jsx("button",{className:"btn btn--ghost sidebar__wide",title:"Настройки приложения",onClick:ue,children:"Настройки"}),i.jsx("button",{className:"btn btn--ghost",onClick:G,children:"+ Проект"}),i.jsx("button",{className:"btn btn--primary",onClick:J,disabled:!j,children:"+ Сессия"})]}),$e&&i.jsx(Mr,{x:$e.x,y:$e.y,items:Ht,note:Ze,onClose:In}),W&&i.jsx(Mr,{x:W.x,y:W.y,items:is,note:An,onClose:$l}),we&&i.jsx(Mr,{x:we.x,y:we.y,items:vl,note:ys,onClose:da}),V&&i.jsx(Mr,{x:V.x,y:V.y,items:Ql,note:Pb,onClose:qs})]})}function xh(s,l){const r=["row"];return s&&r.push("row--active"),l&&r.push("row--selected"),r.join(" ")}function Wc(s,l,r=c=>c.folderId){const c=new Map(l.map(p=>[p.id,p])),o=new Map,d=[];for(const p of s){const m=r(p),x=m?c.get(m):void 0;if(!x){d.push(p);continue}const _=o.get(x.id);_?_.push(p):o.set(x.id,[p])}return{groups:[...o.entries()].map(([p,m])=>({folder:c.get(p),items:m})).sort((p,m)=>p.folder.name.localeCompare(m.folder.name,"ru")),ungrouped:d}}function Pc(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 oS(s){return s.map(l=>({...l,id:`pinned:${l.id}`,label:l.id==="folder:new"?"Новая папка закреплённых…":l.id==="folder:none"?"Без папки закреплённых":l.label}))}function yh(s){const[l,r]=y.useState([]),c=y.useRef(null);function o(){r([]),c.current=null}function d(p,m,x){if(p.ctrlKey||p.metaKey){r(_=>_.includes(m.id)?_.filter(j=>j!==m.id):[..._,m.id]),c.current=m.id;return}if(p.shiftKey&&c.current){const _=s.findIndex(v=>v.id===c.current),j=s.findIndex(v=>v.id===m.id);if(_!==-1&&j!==-1){const[v,E]=_<j?[_,j]:[j,_];r(s.slice(v,E+1).map(k=>k.id));return}}o(),c.current=m.id,x()}function h(p){return l.includes(p.id)?l:(r([p.id]),c.current=p.id,[p.id])}return{selected:l,click:d,targetsFor:h,clear:o}}const fS={display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0,textAlign:"left"},dS={width:22,height:22,borderRadius:6};function eu({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:fS,"aria-expanded":r,title:o?`${h} — ${o}`:h,onClick:c,children:[i.jsx(hy,{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:dS,title:d.label,"aria-label":d.label,onClick:d.onClick,children:i.jsx(bS,{})})]})}const ex={paddingLeft:22},hS={display:"flex",alignItems:"center",gap:6,width:"100%"},pS={flex:1,minWidth:0,color:"var(--text-2)",fontWeight:500};function mS({folder:s,count:l,open:r,renaming:c,onToggle:o,onStartRename:d,onCommitRename:h,onCancelRename:p,onDelete:m}){return c?i.jsx("div",{className:"row",style:ex,children:i.jsx("div",{className:"row__main",children:i.jsx(fa,{value:s.name,placeholder:"Название папки",onCommit:h,onCancel:p})})}):i.jsxs("div",{className:"row",style:ex,children:[i.jsxs("button",{className:"row__main",style:hS,"aria-expanded":r,title:r?`Свернуть папку «${s.name}»`:`Развернуть папку «${s.name}»`,onClick:o,children:[i.jsx(hy,{open:r}),i.jsx("span",{style:pS,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:m,children:"✕"})]})}function hy({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 py({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 gS(){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 bS(){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 xS(){try{const s=localStorage.getItem(oy);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"):["archive","workspacesArchive"]}catch{return["archive","workspacesArchive"]}}function yS(){try{const s=localStorage.getItem(dy);if(s===null)return[];const l=JSON.parse(s);return Array.isArray(l)?l.filter(r=>typeof r=="string"):[]}catch{return[]}}function _S(){try{return localStorage.getItem(fy)==="pinned"?"pinned":"default"}catch{return"default"}}const tx={system:"как в системе",light:"светлая",dark:"тёмная"};function vS({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 SS(s){switch(s.state){case"running":return"работает";case"waiting_permission":return"ждёт разрешения";case"idle":return s.backgroundWork?"работает в фоне":jS(s.lastTurn);case"starting":return"запускается";case"reconnecting":return"переподключается";case"error":return"ошибка";case"closed":return"на диске"}}function jS(s){switch(s){case"interrupted":return"прервана";case"stopped":return"остановлена";case"failed":return"оборвалась";case"completed":return"готова";case null:return"ждёт задачу"}}function kS(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":wS(s.lastTurn);case"error":return"error";case"closed":return"closed"}}function wS(s){switch(s){case"interrupted":case"stopped":return"halted";case"failed":return"error";case"completed":return"ready";case null:return"fresh"}}function nx({session:s,tail:l}){return i.jsxs("span",{className:"row__meta",children:[i.jsxs("span",{className:`row__state row__state--${kS(s)}`,children:[i.jsx("span",{className:"row__state-dot","aria-hidden":"true"}),SS(s)]})," · ",l]})}function _h({title:s,pinned:l,projectName:r,projectPath:c}){return i.jsxs("span",{className:"row__head",children:[i.jsxs("span",{className:"row__title",children:[l&&i.jsx(py,{className:"row__pin"}),s]}),i.jsx("span",{className:"row__project",title:c,children:r})]})}function NS(s){const l=s.archivedAuto?"сама, по сроку молчания":"убрана вручную";return s.archivedAt?`${new Date(s.archivedAt).toLocaleString()} · ${l}`:l}function TS(s){return s.archivedAt?`закрыт ${new Date(s.archivedAt).toLocaleString()}`:"закрыт"}const lx=3,ES=15e5;function my(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=vh(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=MS(AS(vh(r.old_string),vh(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 vh(s){if(s==="")return[];const l=s.split(/\r?\n/);return l.length>1&&l[l.length-1]===""&&l.pop(),l}function AS(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),...CS(s.slice(r,c),l.slice(r,o)),...s.slice(c).map(d)]}function CS(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)>ES)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=(_,j)=>d[_*o+j]??0;for(let _=r-1;_>=0;_--)for(let j=c-1;j>=0;j--)d[_*o+j]=s[_]===l[j]?h(_+1,j+1)+1:Math.max(h(_+1,j),h(_,j+1));const p=[];let m=0,x=0;for(;m<r&&x<c;){const _=s[m],j=l[x];_===j?(p.push({type:"ctx",text:_}),m++,x++):h(m+1,x)>=h(m,x+1)?(p.push({type:"del",text:_}),m++):(p.push({type:"add",text:j}),x++)}for(;m<r;)p.push({type:"del",text:s[m++]});for(;x<c;)p.push({type:"add",text:l[x++]});return RS(p)}function RS(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 MS(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 p=Math.max(0,h-lx);p<=Math.min(s.length-1,h+lx);p++)l[p]=!0});const r=[];let c=[];function o(){c.length===1?r.push(...c):c.length>1&&r.push({type:"gap",text:`⋯ ${c.length} ${OS(c.length)} без изменений`}),c=[]}return s.forEach((d,h)=>{l[h]?(o(),r.push(d)):c.push(d)}),o(),r}function OS(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 $r(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 Bh(){try{return await navigator.clipboard.readText()}catch{return null}}const np=1600,Hi="Копировать",zr="Скопировано";function lp({text:s,hint:l,className:r}){const[c,o]=y.useState(!1);return y.useEffect(()=>{if(!c)return;const d=setTimeout(()=>o(!1),np);return()=>clearTimeout(d)},[c]),y.useEffect(()=>o(!1),[s]),i.jsx("button",{type:"button",className:"copybtn"+(c?" copybtn--done":"")+(r?` ${r}`:""),"aria-label":c?zr:`${Hi} ${l}`,title:c?zr:`${Hi} ${l}`,onClick:()=>{$r(s).then(d=>{d&&o(!0)})},children:c?zr:Hi})}function sp({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 DS({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 ap({items:s,busy:l,waiting:r,history:c=[],historyHasMore:o=!1,historyLoading:d=!1,onLoadHistory:h,sessionId:p,onEditMessage:m,empty:x="Сессия пуста. Опишите задачу — Claude Code работает в каталоге проекта с полным набором инструментов."}){const _=y.useRef(null),j=y.useRef(null),v=y.useRef(!0),E=y.useRef(null),k=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{v.current=!0,E.current=null,O.current=!1,k.current!==null&&(clearTimeout(k.current),k.current=null)},[p]),y.useEffect(()=>{const M=_.current,F=j.current;if(!M||!F)return;function H(ae){!M||ae===M.scrollTop||(O.current=!0,M.scrollTop=ae)}function A(){if(!M)return;const ae=E.current;if(ae){const G=ax(M,ae.id);if(G){const J=G.getBoundingClientRect().top-M.getBoundingClientRect().top;H(M.scrollTop+(J-ae.top))}k.current!==null&&clearTimeout(k.current),k.current=setTimeout(()=>{E.current=null},500);return}v.current&&H(M.scrollHeight)}const Z=new ResizeObserver(A);return Z.observe(F),()=>{Z.disconnect(),k.current!==null&&clearTimeout(k.current)}},[]);function z(){const M=_.current;if(M){if(O.current){O.current=!1;return}v.current=M.scrollHeight-M.scrollTop-M.clientHeight<80}}function ee(){if(d)return;const M=_.current,F=c[0];if(M&&F){const H=ax(M,F.id);H&&(E.current={id:F.id,top:H.getBoundingClientRect().top-M.getBoundingClientRect().top})}h==null||h()}let te=0;function K(M){return M.kind==="user"?te++:-1}return i.jsx("div",{className:"transcript",ref:_,onScroll:z,children:i.jsxs("div",{className:"stream",ref:j,children:[o&&i.jsx("button",{type:"button",className:"transcript__more",onClick:ee,disabled:d,children:d?"Загружаем…":"Показать более раннее"}),c.map(M=>i.jsx(sx,{item:M,userIndex:K(M),onEditMessage:m},M.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:x}),s.map(M=>i.jsx(sx,{item:M,userIndex:K(M),onEditMessage:m},M.id)),l&&i.jsx(DS,{waiting:r})]})})}function sx({item:s,userIndex:l,onEditMessage:r}){switch(s.kind){case"user":return i.jsx(zS,{item:s,userIndex:l,onEditMessage:r});case"assistant":return i.jsxs("div",{className:"msg--assistant","data-item-id":s.id,children:[i.jsx(US,{text:s.text}),s.streaming&&i.jsx("span",{className:"caret"}),s.text.trim()!==""&&i.jsx("div",{className:"msg--assistant__foot",children:i.jsx(lp,{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(BS,{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:["↑",rx(s.inputTokens)," ↓",rx(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 LS=500;function zS({item:s,userIndex:l,onEditMessage:r}){const[c,o]=y.useState(null),[d,h]=y.useState(!1),[p,m]=y.useState(s.text),x=y.useRef(null),_=uf("(max-width: 860px)"),j=y.useRef(null);function v(A,Z){o({x:A,y:Z})}function E(A){A.preventDefault(),v(A.clientX,A.clientY)}function k(A){const Z=A.touches[0];if(!Z)return;const ae={timer:0,x:Z.clientX,y:Z.clientY,fired:!1};ae.timer=window.setTimeout(()=>{ae.fired=!0,v(ae.x,ae.y)},LS),j.current=ae}function O(A){const Z=j.current,ae=A.touches[0];!Z||!ae||Math.hypot(ae.clientX-Z.x,ae.clientY-Z.y)>10&&(window.clearTimeout(Z.timer),j.current=null)}function z(A){const Z=j.current;Z&&(window.clearTimeout(Z.timer),Z.fired&&A.preventDefault())}function ee(){m(s.text),h(!0)}function te(){h(!1)}function K(){const A=p.trim();A===""&&!(s.images&&s.images.length>0)||(r==null||r(l,A,s.images),h(!1))}y.useEffect(()=>{const A=x.current;!A||!d||(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[p,d]),y.useEffect(()=>{if(!d)return;const A=x.current;A&&(A.focus(),A.setSelectionRange(A.value.length,A.value.length))},[d]);function M(A){if(A.key==="Escape"){A.preventDefault(),A.stopPropagation(),te();return}A.key==="Enter"&&!A.shiftKey&&!_&&(A.preventDefault(),K())}const F=s.images&&s.images.length>0&&i.jsx("div",{className:"msg--user__images",children:s.images.map((A,Z)=>i.jsx("img",{className:"msg--user__image",src:`data:${A.mediaType};base64,${A.data}`,alt:"Вложение"},Z))});if(d){const A=p.trim()!==""||!!(s.images&&s.images.length>0);return i.jsxs("div",{className:"msg--user msg--user--editing","data-item-id":s.id,children:[F,i.jsxs("div",{className:"msg--user__edit",children:[i.jsx("textarea",{ref:x,className:"msg--user__edit-field",value:p,onChange:Z=>m(Z.target.value),onKeyDown:M,rows:1}),i.jsxs("div",{className:"msg--user__edit-actions",children:[i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:te,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--primary",onClick:K,disabled:!A,children:"Сохранить"})]})]})]})}const H=[{id:"copy",label:"Копировать",onSelect:()=>void $r(s.text)},...r?[{id:"edit",label:"Изменить",onSelect:ee}]:[]];return i.jsxs("div",{className:"msg--user","data-item-id":s.id,onContextMenu:E,onTouchStart:k,onTouchMove:O,onTouchEnd:z,onTouchCancel:z,children:[F,s.text,c&&i.jsx(Mr,{x:c.x,y:c.y,items:H,onClose:()=>o(null)})]})}function ax(s,l){const r=s.querySelectorAll("[data-item-id]");for(const c of r)if(c.dataset.itemId===l)return c;return null}function US({text:s}){const[l,r]=y.useState(""),c=y.useRef([]);y.useEffect(()=>{let d=!1;return tp(s).then(h=>{d||r(HS(h))}),()=>{d=!0}},[s]),y.useEffect(()=>{const d=c.current;return()=>d.forEach(h=>clearTimeout(h))},[]);function o(d){var m,x;const h=d.target.closest(".codeblock__copy");if(!(h instanceof HTMLElement))return;const p=((x=(m=h.parentElement)==null?void 0:m.querySelector("pre"))==null?void 0:x.textContent)??"";p!==""&&$r(p).then(_=>{if(!_)return;h.textContent=zr,h.setAttribute("aria-label",zr),h.classList.add("copybtn--done");const j=window.setTimeout(()=>{h.isConnected&&(h.textContent=Hi,h.setAttribute("aria-label",Ih),h.classList.remove("copybtn--done"))},np);c.current.push(j)})}return i.jsx("div",{className:"markdown-preview msg--assistant__body",onClick:o,dangerouslySetInnerHTML:{__html:l}})}const Ih=`${Hi} блок кода`;function HS(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",Ih),o.title=Ih,o.textContent=Hi,c.append(o)}return l.body.innerHTML}function BS({item:s}){const[l,r]=y.useState(!1),c=s.result===null,o=my(s.name,s.input),d=s.name==="AskUserQuestion"?GS(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?qS(d):IS(s.input)}),i.jsx("span",{className:"tool__status",children:c?"…":s.isError?"ошибка":l?"▴":"▾"})]}),l&&i.jsxs("div",{className:"tool__body",children:[d?i.jsx(YS,{questions:d,answers:s.answers}):o?i.jsx(sp,{diff:o}):i.jsx(ix,{text:JSON.stringify(s.input,null,2),hint:"аргументы вызова"}),s.result!==null&&(!d||s.isError)&&i.jsx(ix,{text:s.result,hint:"результат вызова",style:{marginTop:10}})]})]})}function ix({text:s,hint:l,style:r}){return i.jsxs("div",{className:"codeblock",style:r,children:[i.jsx("pre",{className:"code",children:s}),i.jsx(lp,{text:s,hint:l,className:"codeblock__copy"})]})}function IS(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 qS(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 GS(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:p}=c;if(typeof o!="string"||!Array.isArray(h)||h.length===0)return null;const m=[];for(const x of h){if(typeof x!="object"||x===null)return null;const{label:_,description:j,preview:v}=x;if(typeof _!="string"||typeof j!="string")return null;m.push({label:_,description:j,...typeof v=="string"?{preview:v}:{}})}r.push({question:o,header:typeof d=="string"?d:"",options:m,multiSelect:p===!0})}return r}function YS({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 rx(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}const XS="ccv.dictation.lang",cx="ru-RU";function VS(s){try{return Function.prototype.toString.call(s).includes("[native code]")}catch{return!1}}function ux(){const s=window,l=[s.SpeechRecognition,s.webkitSpeechRecognition].filter(c=>typeof c=="function"),r=l.find(VS);return!r&&l.length>0&&ms("распознавание подменено: родной реализации в странице нет"),r??l[0]??null}function gy(){var s;try{return((s=localStorage.getItem(XS))==null?void 0:s.trim())||cx}catch{return cx}}function ms(s,l){l===void 0?console.debug(`[dictation] ${s}`):console.debug(`[dictation] ${s}`,l)}const $S=3,QS=400,ZS=5,KS=250,FS=2e3,JS=2e4;async function WS(){try{return(await navigator.permissions.query({name:"microphone"})).state==="granted"}catch{return!1}}const PS={"not-allowed":"Браузер не дал доступ к микрофону","service-not-allowed":"Браузер не дал доступ к микрофону","audio-capture":"Микрофон не найден",network:"Сервис распознавания недоступен","language-not-supported":`Распознавание не знает языка ${gy()}`};function ej(s){const[l]=y.useState(()=>ux()!==null),[r,c]=y.useState(!1),[o,d]=y.useState(null),h=y.useRef(null),p=y.useRef(!1),m=y.useRef(!1),x=y.useRef(s),_=y.useRef({openedAt:0,audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1}),j=y.useRef(null),v=y.useRef(!1),E=y.useRef(null),k=y.useCallback(()=>{E.current&&clearTimeout(E.current),E.current=null},[]),O=y.useCallback(()=>{k();const M=async F=>{if(E.current=null,!(!p.current||v.current)){if(!F&&!await WS()){if(ms("ждём ответа на запрос доступа к микрофону"),!p.current||v.current)return;E.current=setTimeout(()=>void M(!0),JS);return}ms("движок не ответил на start()"),p.current=!1,c(!1),d("Распознавание не отвечает — проверьте расширения браузера и доступ к микрофону")}};E.current=setTimeout(()=>void M(!1),FS)},[k]);y.useEffect(()=>{x.current=s}),y.useEffect(()=>{const M=ux();if(!M)return;const F=new M;return F.lang=gy(),F.continuous=!0,F.interimResults=!0,F.onstart=()=>{ms("сессия открыта"),v.current=!0,k(),c(!0)},F.onaudiostart=()=>{ms("пошёл звук с микрофона"),_.current.audio=!0},F.onresult=H=>{var G;if(m.current)return;let A="",Z="";for(let J=H.resultIndex;J<H.results.length;J++){const D=H.results[J];if(!D)continue;const ge=((G=D[0])==null?void 0:G.transcript)??"";D.isFinal?A+=ge:Z+=ge}const ae=_.current;ae.heard=!0,ae.everHeard=!0,ms("распознано",{final:A,interim:Z}),x.current(A,Z)},F.onerror=H=>{_.current.lastError=H.error,ms("ошибка движка",H.error),!(H.error==="no-speech"||H.error==="aborted")&&(p.current=!1,c(!1),d(PS[H.error]??`Распознавание не работает: ${H.error}`))},F.onend=()=>{m.current=!1,v.current=!1;const H=_.current,A=Date.now()-H.openedAt;if(ms("сессия закрыта",{мс:A,звук:H.audio,слова:H.heard,ошибка:H.lastError||null}),!p.current){c(!1);return}if(H.dead=!H.audio&&A<QS?H.dead+1:0,H.dead>=ZS){p.current=!1,c(!1),d(H.lastError?`Распознавание не работает: ${H.lastError}`:"Распознавание закрывается сразу после запуска — проверьте доступ к микрофону в настройках сайта");return}H.silent=H.heard?0:H.silent+1,!H.everHeard&&!H.warned&&H.silent>=$S&&(H.warned=!0,d(H.audio?"Микрофон слушает, но речь не распознаётся — проверьте язык диктовки и уровень звука":"С микрофона не идёт звук — проверьте устройство ввода в настройках сайта в браузере")),j.current=setTimeout(()=>{if(j.current=null,!!p.current){H.openedAt=Date.now(),H.audio=!1,H.heard=!1,H.lastError="",O();try{F.start()}catch{}}},KS)},h.current=F,()=>{p.current=!1,j.current&&clearTimeout(j.current),j.current=null,k(),F.onend=null,F.onresult=null,F.onerror=null,F.onstart=null,F.onaudiostart=null,F.abort(),h.current=null}},[]);const z=y.useCallback(()=>{var M;if(p.current){if(p.current=!1,ms("выключение микрофона"),j.current&&clearTimeout(j.current),j.current=null,k(),!v.current){c(!1);return}(M=h.current)==null||M.stop()}},[]),ee=y.useCallback(()=>{const M=h.current;if(M){if(!window.isSecureContext){d("Микрофон доступен только по https или с localhost");return}d(null),p.current=!0,m.current=!1,j.current&&clearTimeout(j.current),j.current=null,_.current={openedAt:Date.now(),audio:!1,heard:!1,everHeard:!1,silent:0,dead:0,lastError:"",warned:!1},c(!0),ms("включение микрофона",{язык:M.lang}),O();try{M.start()}catch(F){ms("start() не прошёл",F)}}},[O]),te=y.useCallback(()=>{p.current?z():ee()},[ee,z]),K=y.useCallback(()=>{var M;p.current&&v.current&&(m.current=!0,(M=h.current)==null||M.abort())},[]);return{supported:l,listening:r,error:o,toggle:te,stop:z,drop:K}}const by="ccv:drafts",tj=40,nj=2e4,lj=500;let au=null,iu=null;function xy(){if(au)return au;const s=new Map;try{const l=localStorage.getItem(by);if(l){const r=JSON.parse(l);if(typeof r=="object"&&r!==null)for(const[c,o]of Object.entries(r))typeof o=="string"&&o!==""&&s.set(c,o)}}catch{}return au=s,window.addEventListener("pagehide",yy),s}function Sh(s){return xy().get(s)??""}function sj(s,l){const r=xy(),c=l.slice(0,nj),o=r.has(s);if(o&&r.delete(s),c!=="")r.set(s,c);else if(!o)return;for(;r.size>tj;){const d=r.keys().next();if(d.done)break;r.delete(d.value)}aj()}function aj(){iu===null&&(iu=window.setTimeout(yy,lj))}function yy(){if(iu!==null&&window.clearTimeout(iu),iu=null,!!au)try{localStorage.setItem(by,JSON.stringify(Object.fromEntries(au)))}catch{}}const ij="(max-width: 860px)",ox=/^\/(\S*)$/,rj=new Set(["model","permissions"]);function cj(s){return rj.has(s.name)||s.name.startsWith("__")}const uj=new Set(["clear","rename"]),fx=/(?:^|\s)@([^\s@]*)$/,oj=200,fj=100,dj=190,hj=5,pj=20*1024*1024,mj=1568,gj=.85;let dx=0;async function bj(s){var j,v;if(!s.type.startsWith("image/")||s.size>pj)return null;const l=await xj(s);if(!l)return null;const{width:r,height:c}=l;if(r<=0||c<=0)return null;const o=Math.min(1,mj/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=(j=l.image).close)==null||v.call(j);const p=s.type==="image/png",m=p?"image/png":"image/jpeg",x=d.toDataURL(m,p?void 0:gj),_=x.slice(x.indexOf(",")+1);return _?(dx+=1,{id:`att${dx}`,mediaType:m,data:_,previewUrl:x}):null}async function xj(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 _y({disabled:s,busy:l,commands:r,sessionTitle:c,contextResult:o,className:d,placeholder:h,draftKey:p,sendLabel:m="Отправить",autoFocus:x=!1,attachmentsEnabled:_=!0,onContextSearch:j,onCommand:v,onSend:E,onInterrupt:k,onEscape:O}){var we;const z=uf(ij),[ee,te]=y.useState(()=>p?Sh(p):""),[K,M]=y.useState(!1),[F,H]=y.useState(0),A=y.useRef(null),Z=y.useRef(null),ae=y.useRef(null),[G,J]=y.useState(()=>p?Sh(p).length:0),[D,ge]=y.useState([]),Se=y.useRef(null),xe=y.useCallback(L=>{!_||L.length===0||Promise.all(L.map(bj)).then(V=>{const _e=V.filter(ze=>ze!==null);_e.length!==0&&ge(ze=>[...ze,..._e].slice(0,hj))})},[_]);function B(L){ge(V=>V.filter(_e=>_e.id!==L))}function ue(L){var ze;if(!_)return;const V=(ze=L.clipboardData)==null?void 0:ze.items;if(!V)return;const _e=[];for(const st of V){if(!st.type.startsWith("image/"))continue;const al=st.getAsFile();al&&_e.push(al)}_e.length!==0&&(L.preventDefault(),xe(_e))}function se(L){const V=L.target.files?Array.from(L.target.files):[];L.target.value="",xe(V)}y.useEffect(()=>{_||ge([])},[_]);const[be,Ce]=y.useState([]),[w,Q]=y.useState(-1),re=y.useRef(""),[oe,ye]=y.useState(""),je=ej(y.useCallback((L,V)=>{L&&te(_e=>jh(_e,L)),ye(V.trim())},[])),Me=oe?jh(ee,oe):ee;y.useEffect(()=>{je.listening||oe===""||(te(L=>jh(L,oe)),ye(""))},[je.listening,oe]),y.useEffect(()=>{var L;x&&((L=A.current)==null||L.focus())},[x]);const ht=y.useRef(new Map),lt=y.useRef(new Map),Nn=y.useRef(p),Je=y.useRef({text:ee,caret:G});Je.current={text:ee,caret:G};const Kt=y.useCallback((L,V,_e)=>{V===""?(ht.current.delete(L),lt.current.delete(L)):(ht.current.set(L,V),lt.current.set(L,_e)),sj(L,V)},[]),ct=je.drop;y.useLayoutEffect(()=>{const L=Nn.current;if(L===p)return;Nn.current=p,L&&Kt(L,Je.current.text,Je.current.caret);const V=p?ht.current.get(p)??Sh(p):"",_e=p?lt.current.get(p):void 0,ze=Math.min(_e??V.length,V.length);te(V),J(ze),ae.current=[ze,ze],ye(""),H(0),M(!1),Q(-1),re.current="",ge([]),ct()},[p,Kt,ct]),y.useEffect(()=>{p&&Kt(p,ee,G)},[p,ee,G,Kt]);const rn=s?"Выберите сессию":h??"Опишите задачу… («/» — команды, «@» — файлы)",Be=y.useRef(0),rt=y.useCallback(L=>{const V=parseFloat(getComputedStyle(L).maxHeight),_e=Number.isFinite(V)&&V>0?V:dj;L.style.height="auto";const ze=L.scrollHeight;L.style.height=`${Math.min(ze,_e)}px`,L.style.overflowY=ze>_e?"auto":"hidden"},[]);y.useEffect(()=>{const L=A.current;L&&rt(L)},[Me,rn,s,rt]),y.useLayoutEffect(()=>{const L=A.current,V=ae.current;!L||!V||(ae.current=null,L.setSelectionRange(V[0],V[1]))}),y.useEffect(()=>{const L=A.current;if(!L)return;const V=new ResizeObserver(([_e])=>{const ze=_e==null?void 0:_e.contentRect.width;ze===void 0||Math.abs(ze-Be.current)<1||(Be.current=ze,rt(L))});return V.observe(L),()=>V.disconnect()},[rt]);const Hn=je.stop;y.useEffect(()=>{s&&Hn()},[s,Hn]);const wt=y.useMemo(()=>je.error?{ok:!1,message:je.error}:null,[je.error]),Ot=y.useMemo(()=>{var _e;const L=(_e=ox.exec(ee))==null?void 0:_e[1];if(L===void 0)return[];const V=L.toLowerCase();return r.filter(ze=>!cj(ze)&&kh(ze,V)<vy).sort((ze,st)=>kh(ze,V)-kh(st,V))},[ee,r]),Ft=!K&&Ot.length>0,tn=Math.min(F,Ot.length-1),$t=K?null:((we=fx.exec(Me.slice(0,G)))==null?void 0:we[1])??null,Nt=y.useRef(j);Nt.current=j,y.useEffect(()=>{if($t===null||$t===""||$t.endsWith("/")){Nt.current($t);return}const L=setTimeout(()=>Nt.current($t),oj);return()=>clearTimeout(L)},[$t]);const Qe=$t!==null&&(o==null?void 0:o.query)===$t,We=Qe?o.entries:[],dn=$t!==null,Jt=dn&&!Qe,Qt=Math.min(F,Math.max(We.length-1,0));y.useEffect(()=>{var V,_e;if(!Ft&&!dn)return;const L=Ft?tn:Qt;(_e=(V=Z.current)==null?void 0:V.children[L])==null||_e.scrollIntoView({block:"nearest"})},[Ft,dn,tn,Qt]);function Bn(L,V){var _e;te(L),J(V),ae.current=[V,V],H(0),M(!1),oe!==""&&(ye(""),je.drop()),(_e=A.current)==null||_e.focus()}function Tn(){te(""),ye(""),H(0),J(0),M(!1),Q(-1),re.current="",ge([]),je.drop(),p&&Kt(p,"",0)}function hn(L){const V=L.trim();V===""&&D.length===0||s||(E(V,D.length>0?D.map(_e=>({mediaType:_e.mediaType,data:_e.data})):void 0),V!==""&&Ce(_e=>[V,..._e.filter(ze=>ze!==V)].slice(0,fj)),Tn())}function sl(L){if(L<-1||L>=be.length)return;w===-1&&(re.current=ee);const V=L===-1?re.current:be[L]??"";Q(L),Bn(V,V.length)}function zt(){var ze;const L=((ze=A.current)==null?void 0:ze.selectionStart)??Me.length,_e=`${L>0&&!/\s$/.test(Me.slice(0,L))?" ":""}@`;Bn(Me.slice(0,L)+_e+Me.slice(L),L+_e.length)}function bt(L){var st;const V=(st=fx.exec(Me.slice(0,G)))==null?void 0:st[1];if(V===void 0)return;const _e=G-V.length-1,ze=L.kind==="dir"?`@${L.path}/`:`@${L.path} `;Bn(Me.slice(0,_e)+ze+Me.slice(G),_e+ze.length)}function Ut(){var V;const L=(V=ox.exec(Me.trim()))==null?void 0:V[1];if(L&&v(L)){Tn();return}hn(Me)}function $e(L,V){te(L),J(V),H(0),M(!1),Q(-1),oe!==""&&(ye(""),je.drop())}function Qn(L){var ze;const V=uj.has(L.name)?c:null,_e=`/${L.name} `;te(_e+(V??"")),J(_e.length+((V==null?void 0:V.length)??0)),V&&(ae.current=[_e.length,_e.length+V.length]),H(0),(ze=A.current)==null||ze.focus()}function W(L){if(v(L.name)){te(""),H(0),M(!1);return}L.argumentHint?Qn(L):hn(`/${L.name}`)}function de(L){if(Ft){if(L.key==="ArrowDown")return L.preventDefault(),H(V=>(Math.min(V,Ot.length-1)+1)%Ot.length);if(L.key==="ArrowUp"){L.preventDefault();const V=Ot.length-1;return H(_e=>(Math.min(_e,V)+V)%Ot.length)}if(L.key==="Enter"&&!L.shiftKey){L.preventDefault();const V=Ot[tn];V&&W(V);return}if(L.key==="Tab"){L.preventDefault();const V=Ot[tn];V&&Qn(V);return}if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),M(!0);return}}if(dn){if(L.key==="ArrowDown"&&We.length>0)return L.preventDefault(),H(V=>(Math.min(V,We.length-1)+1)%We.length);if(L.key==="ArrowUp"&&We.length>0){L.preventDefault();const V=We.length-1;return H(_e=>(Math.min(_e,V)+V)%We.length)}if(L.key==="Enter"&&!L.shiftKey||L.key==="Tab"){const V=We[Qt];if(V){L.preventDefault(),bt(V);return}if(L.key==="Tab")return}if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),M(!0);return}}if((L.key==="ArrowUp"||L.key==="ArrowDown")&&!L.shiftKey){const V=L.currentTarget,_e=V.selectionStart;if(V.selectionEnd===_e){const st=L.key==="ArrowUp"?w+1:w-1;st>=-1&&st<be.length&&requestAnimationFrame(()=>{V.selectionStart===_e&&V.selectionEnd===_e&&sl(st)})}}if(L.key==="Escape"&&O){L.preventDefault(),L.stopPropagation(),O();return}L.key==="Enter"&&!L.shiftKey&&!z&&(L.preventDefault(),Ut())}return i.jsx("div",{className:d?`composer ${d}`:"composer",children:i.jsxs("div",{className:"composer__inner",children:[i.jsx(qi,{result:wt}),dn&&!Ft&&i.jsxs("div",{className:"cmdmenu",role:"listbox",ref:Z,children:[We.map((L,V)=>i.jsxs("button",{role:"option","aria-selected":V===Qt,className:V===Qt?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>H(V),onMouseDown:_e=>{_e.preventDefault(),bt(L)},children:[i.jsxs("span",{className:"cmdmenu__name",children:[L.name,L.kind==="dir"?"/":""]}),i.jsx("span",{className:"cmdmenu__desc",children:L.path}),L.ignored&&i.jsx("span",{className:"cmdmenu__tag",children:"git-ignore"})]},L.path)),We.length===0&&i.jsx("div",{className:"cmdmenu__empty",children:Jt?"ищем…":$t?"Ничего не нашлось":"Наберите имя файла или каталога"})]}),Ft&&i.jsx("div",{className:"cmdmenu",role:"listbox",ref:Z,children:Ot.map((L,V)=>i.jsxs("button",{role:"option","aria-selected":V===tn,className:V===tn?"cmdmenu__row is-on":"cmdmenu__row",onMouseEnter:()=>H(V),onMouseDown:_e=>{_e.preventDefault(),W(L)},children:[i.jsxs("span",{className:"cmdmenu__name",children:["/",L.name]}),L.argumentHint&&i.jsx("span",{className:"cmdmenu__hint",children:L.argumentHint}),i.jsx("span",{className:"cmdmenu__desc",children:L.description})]},L.name))}),D.length>0&&i.jsx("div",{className:"composer__attachments",children:D.map(L=>i.jsxs("div",{className:"composer__thumb",children:[i.jsx("img",{src:L.previewUrl,alt:"Вложение"}),i.jsx("button",{type:"button",className:"composer__thumb-remove","aria-label":"Удалить вложение",onClick:()=>B(L.id),children:i.jsx(kj,{})})]},L.id))}),i.jsxs("div",{className:"composer__field",children:[i.jsx("button",{type:"button",className:"addbtn",title:"Добавить контекст — файл проекта («@»)","aria-label":"Добавить контекст",disabled:s,onClick:zt,children:i.jsx(vj,{})}),_&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Se,type:"file",accept:"image/*",multiple:!0,className:"composer__fileinput",tabIndex:-1,"aria-hidden":"true",onChange:se}),i.jsx("button",{type:"button",className:"attachbtn",title:"Прикрепить изображение","aria-label":"Прикрепить изображение",disabled:s,onClick:()=>{var L;return(L=Se.current)==null?void 0:L.click()},children:i.jsx(jj,{})})]}),i.jsx("textarea",{ref:A,value:Me,disabled:s,placeholder:rn,onChange:L=>$e(L.target.value,L.target.selectionStart),onSelect:L=>J(L.currentTarget.selectionStart),onKeyDown:de,onPaste:ue}),je.supported&&i.jsx("button",{type:"button",className:je.listening?"micbtn is-on":"micbtn",title:je.listening?"Остановить диктовку":"Продиктовать промпт","aria-label":je.listening?"Остановить диктовку":"Продиктовать промпт","aria-pressed":je.listening,disabled:s,onClick:je.toggle,children:i.jsx(wj,{on:je.listening})}),l?i.jsx("button",{className:"btn",onClick:k,title:"Прервать (Esc)",children:"Стоп"}):i.jsxs("button",{className:"btn btn--primary sendbtn",onClick:Ut,disabled:s||Me.trim()===""&&D.length===0,"aria-label":m,title:m,children:[i.jsx("span",{className:"sendbtn__label",children:m}),i.jsx(Sj,{})]})]})]})})}function jh(s,l){const r=l.trim();if(r==="")return s;const c=qh(r).slice(yj(s,r)).join(" ");return c===""?s:s===""||/\s$/.test(s)?s+c:`${s} ${c}`}function yj(s,l){const r=qh(s),c=qh(l);for(let o=Math.min(r.length,c.length);o>0;o--)if(r.slice(r.length-o).every((d,h)=>_j(d,c[h]??"")))return o;return 0}function qh(s){return s.split(/\s+/).filter(l=>l!=="")}function _j(s,l){const r=c=>c.toLowerCase().replace(/[.,!?;:…]+$/u,"");return r(s)===r(l)}function vj(){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 Sj(){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 jj(){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 kj(){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 wj({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 vy=4;function kh(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:vy}function Nj({request:s,queued:l,onDecide:r}){const c=my(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(sp,{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 Tj({request:s,queued:l,onAnswer:r,onDecline:c}){const{questions:o}=s,[d,h]=y.useState(()=>o.map(()=>new Set)),[p,m]=y.useState(()=>o.map(()=>"")),[x,_]=y.useState(()=>hx(o));y.useEffect(()=>{h(o.map(()=>new Set)),m(o.map(()=>"")),_(hx(o))},[s.requestId]);const j=y.useMemo(()=>Aj(o,d,p),[o,d,p]),v=j!==null;function E(K,M){var F,H;(H=(F=o[K])==null?void 0:F.options[M])!=null&&H.preview&&_(A=>{const Z=A.slice();return Z[K]=M,Z})}function k(K,M,F){h(H=>{const A=H.slice(),Z=new Set(A[K]);return F?Z.has(M)?Z.delete(M):Z.add(M):Z.has(M)||(Z.clear(),Z.add(M)),A[K]=Z,A}),M!=="other"&&E(K,M)}function O(K,M){m(F=>{const H=F.slice();return H[K]=M,H})}function z(){j&&r(s.requestId,j)}function ee(K){K.key==="Enter"&&(K.target.closest("button")||v&&(K.preventDefault(),z()))}function te(K){var A;if(!["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(K.key))return;const M=Array.from(K.currentTarget.querySelectorAll("button.qsheet__option")),F=M.indexOf(document.activeElement);if(F===-1)return;K.preventDefault();const H=K.key==="ArrowDown"||K.key==="ArrowRight"?1:-1;(A=M[(F+H+M.length)%M.length])==null||A.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:ee,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((K,M)=>i.jsx(Ej,{q:K,qi:M,selected:d[M]??new Set,otherText:p[M]??"",previewIndex:x[M]??null,onToggle:k,onFocusOption:E,onOtherText:O,onOptionsKeyDown:te},M))]}),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:z,children:"Ответить"})]})]})})}function Ej({q:s,qi:l,selected:r,otherText:c,previewIndex:o,onToggle:d,onFocusOption:h,onOtherText:p,onOptionsKeyDown:m}){var E;const x=s.options.some(k=>k.preview),_=o!==null?(E=s.options[o])==null?void 0:E.preview:void 0,j=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:m,children:[s.options.map((k,O)=>{const z=r.has(O);return i.jsxs("button",{type:"button",role:v,"aria-checked":z,className:"qsheet__option"+(z?" is-selected":""),onClick:()=>d(l,O,s.multiSelect),onFocus:()=>h(l,O),onMouseEnter:()=>h(l,O),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:k.label}),i.jsx("span",{className:"qsheet__opt-desc",children:k.description})]})]},O)}),i.jsxs("div",{className:"qsheet__other",children:[i.jsxs("button",{type:"button",role:v,"aria-checked":j,className:"qsheet__option qsheet__option--other"+(j?" 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:"Свой вариант ответа"})]})]}),j&&i.jsx("input",{type:"text",className:"qsheet__other-input",placeholder:"Впишите свой вариант…","aria-label":`Свой вариант ответа на вопрос «${s.question}»`,value:c,onChange:k=>p(l,k.target.value),autoFocus:!0})]})]}),x&&i.jsx("pre",{className:"qsheet__preview",children:_??""})]})}function hx(s){return s.map(l=>{const r=l.options.findIndex(c=>c.preview);return r===-1?null:r})}function Aj(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,p=[];for(let m=0;m<d.options.length;m++){const x=d.options[m];x&&h.has(m)&&p.push(x.label)}if(h.has("other")){const m=(r[o]??"").trim();m&&p.push(m)}if(p.length===0)return null;c[d.question]=p.join(", ")}return c}function Cj({request:s,plan:l,queued:r,onAccept:c,onDecline:o}){const[d,h]=y.useState(l),[p,m]=y.useState("preview");y.useEffect(()=>{h(l),m("preview")},[s.requestId,l]);const x=d.trim().length>0;function _(){x&&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(Mj,{})}),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"+(p==="preview"?" is-on":""),role:"tab","aria-selected":p==="preview",onClick:()=>m("preview"),children:"Просмотр"}),i.jsx("button",{className:"btn btn--sm"+(p==="source"?" is-on":""),role:"tab","aria-selected":p==="source",onClick:()=>m("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:p==="preview"?i.jsx(Rj,{text:d}):i.jsx("textarea",{className:"plansheet__source",value:d,onChange:j=>h(j.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:!x,autoFocus:!0,onClick:_,children:"Одобрить план"})]})]})})}function Rj({text:s}){const[l,r]=y.useState("");return y.useEffect(()=>{let c=!1;return tp(s).then(o=>{c||r(o)}),()=>{c=!0}},[s]),i.jsx("div",{className:"markdown-preview plansheet__preview",dangerouslySetInnerHTML:{__html:l}})}function Mj(){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 Oj(s,l){if(s!=="ExitPlanMode"||!l||typeof l!="object")return null;const r=l.plan;return typeof r=="string"?r:null}function Sy({path:s}){const[l,r]=y.useState(!1),[c,o]=y.useState(!1),d=y.useRef(null);y.useEffect(()=>{if(!l)return;function p(m){var x;(x=d.current)!=null&&x.contains(m.target)||r(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),y.useEffect(()=>{if(!c)return;const p=setTimeout(()=>o(!1),np);return()=>clearTimeout(p)},[c]),y.useEffect(()=>r(!1),[s]);async function h(){await $r(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(p=>!p),onKeyDown:p=>{p.key!=="Escape"||!l||(p.preventDefault(),p.stopPropagation(),r(!1))},children:[i.jsx(Dj,{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?zr:Hi})]})]})}function Dj({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 Lj=["low","medium","high"];function jy({models:s,value:l,effort:r,ultracode:c,thinking:o,switchOnFlag:d,className:h,onModel:p,onEffort:m,onUltracode:x,onThinking:_,onSwitchOnFlag:j}){const[v,E]=y.useState(!1),[k,O]=y.useState(0),z=y.useRef(null),ee=y.useRef(null),te=s.find(A=>A.value===l)??null,K=te&&te.supportsEffort?te.effortLevels.length>0?te.effortLevels:Lj:[],M=K.includes("xhigh");y.useEffect(()=>{if(!v)return;const A=s.findIndex(Z=>Z.value===l);O(A===-1?0:A)},[v]),y.useEffect(()=>{if(!v)return;function A(Z){var ae;(ae=z.current)!=null&&ae.contains(Z.target)||E(!1)}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[v]),y.useEffect(()=>{var A,Z;v&&((Z=(A=ee.current)==null?void 0:A.querySelector(".is-cursor"))==null||Z.scrollIntoView({block:"nearest"}))},[v,k]);function F(A){E(!1),A.value!==l&&p(A.value)}function H(A){if(A.key==="Escape"){if(!v)return;A.preventDefault(),A.stopPropagation(),E(!1);return}if(A.key==="ArrowDown"||A.key==="ArrowUp"){if(A.preventDefault(),!v)return E(!0);if(s.length===0)return;const Z=A.key==="ArrowDown"?1:s.length-1;return O(ae=>(ae+Z)%s.length)}if(A.key==="Enter"||A.key===" "){if(A.preventDefault(),!v)return E(!0);const Z=s[k];Z&&F(Z)}}return i.jsxs("div",{ref:z,className:"select"+(v?" select--open":"")+(h?` ${h}`:""),children:[i.jsxs("button",{type:"button",className:"select__trigger",title:"Модель, усилие и размышления","aria-label":"Модель, усилие и размышления","aria-haspopup":"menu","aria-expanded":v,onClick:()=>E(A=>!A),onKeyDown:H,children:[i.jsx("span",{className:"select__value",children:(te==null?void 0:te.displayName)??l??"—"}),c?i.jsx("span",{className:"select__suffix select__suffix--hot",children:"ultracode"}):K.length>0&&r&&i.jsx("span",{className:"select__suffix",children:r}),i.jsx(zj,{})]}),v&&i.jsxs("div",{ref:ee,className:"select__menu modelmenu",role:"menu",children:[i.jsx("div",{className:"modelmenu__head",children:"Модель"}),s.map((A,Z)=>i.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":A.value===l,className:"select__option"+(Z===k?" is-cursor":"")+(A.value===l?" is-on":""),onMouseEnter:()=>O(Z),onClick:()=>F(A),children:[i.jsx("span",{className:"select__check","aria-hidden":"true",children:A.value===l?"✓":""}),i.jsx("span",{className:"select__label",children:A.displayName}),A.description&&i.jsx("span",{className:"select__hint",children:A.description})]},A.value)),K.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:K.map(A=>i.jsx("button",{type:"button",role:"menuitemradio","aria-checked":A===r,className:A===r?"modelmenu__level is-on":"modelmenu__level",onClick:()=>m(A),children:A},A))})]}),M&&i.jsx(wh,{label:"Ultracode",desc:"xhigh и постоянная оркестрация подагентами",on:c,onToggle:()=>x(!c)})]}),i.jsx("div",{className:"modelmenu__sep",role:"separator"}),(te==null?void 0:te.supportsThinking)!==!1&&i.jsx(wh,{label:"Размышления",desc:"расширенное обдумывание перед ответом",on:o,onToggle:()=>_(!o)}),i.jsx(wh,{label:"Менять модель по флагу",desc:"иначе помеченный ход встаёт на паузу",on:d,onToggle:()=>j(!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 zj(){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 Vl({title:s,children:l,actions:r,className:c,sheet:o=!1,onClose:d}){const h=y.useRef(null);return y.useEffect(()=>{function p(m){if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),d();return}if(m.key!=="Tab")return;const x=h.current;if(!x)return;const _=x.querySelectorAll('button, input, textarea, select, a[href], [tabindex]:not([tabindex="-1"])'),j=_[0],v=_[_.length-1];!j||!v||(m.shiftKey&&document.activeElement===j?(m.preventDefault(),v.focus()):!m.shiftKey&&document.activeElement===v&&(m.preventDefault(),j.focus()))}return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[d]),i.jsx("div",{className:o?"modal-backdrop modal-backdrop--sheet":"modal-backdrop",onMouseDown:p=>{p.target===p.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 Uj({candidates:s,searching:l,agentItems:r,agentBusy:c,error:o,roots:d,created:h,onSearch:p,onAskAgent:m,onInterrupt:x,onSubmit:_,onCreate:j,onClose:v}){const[E,k]=y.useState("open"),[O,z]=y.useState(""),[ee,te]=y.useState(!1),[K,M]=y.useState(""),[F,H]=y.useState(""),[A,Z]=y.useState({git:!0,claudeMd:!0,readme:!0}),ae=O.trim(),G=ae!=="",J=K.trim(),D=F.trim(),ge=J!==""&&D!=="";y.useEffect(()=>{K===""&&d.length>0&&M(d[0])},[d]);const Se=y.useRef(p);Se.current=p,y.useEffect(()=>{if(E!=="open")return;const se=O.trim(),be=setTimeout(()=>Se.current(se),200);return()=>clearTimeout(be)},[O,E]);function xe(){G&&_(ae)}function B(){ge&&j(J,D,A)}function ue(){G&&(te(!0),m(ae))}return h?i.jsxs(Vl,{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(se=>i.jsx("li",{children:se},se))})}),i.jsx("p",{className:"modal__text modal__text--dim",children:"Проект открыт и работает — недостающее можно добавить руками, в дереве файлов или из терминала."})]}):i.jsxs(Vl,{title:"Новый проект",className:ee&&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:x,children:"Остановить"}):i.jsx("button",{className:"btn",disabled:!G,onClick:ue,title:"Найти по описанию",children:"Попросить агента"}),i.jsx("button",{className:"btn btn--primary",disabled:!G,onClick:xe,children:"Открыть"})]}):i.jsx("button",{className:"btn btn--primary",disabled:!ge,onClick:B,children:"Создать"})]}),children:[i.jsxs("div",{className:"tabs",children:[i.jsx(px,{label:"Открыть",on:E==="open",onClick:()=>k("open")}),i.jsx(px,{label:"Создать",on:E==="create",onClick:()=>k("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:O,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects\\my-app",onChange:se=>z(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(se.preventDefault(),xe())}}),o&&i.jsx("p",{className:"modal__error",children:o}),s.length>0&&i.jsx("ul",{className:"finds",children:s.map(se=>i.jsx("li",{children:i.jsxs("button",{className:"find",disabled:se.open,title:se.open?"Этот проект уже открыт":se.path,onClick:()=>z(se.path),onDoubleClick:()=>_(se.path),children:[i.jsx("span",{className:"find__name",children:se.name}),i.jsx("span",{className:"find__path",children:se.path}),i.jsx("span",{className:"find__note",children:Ij(se)})]})},se.path))}),s.length===0&&G&&!l&&!ee&&i.jsx("p",{className:"modal__text modal__text--dim",children:"Ничего похожего среди каталогов, где вы работали. Если помните не имя, а суть проекта — опишите его и нажмите «Попросить агента». Проекта ещё нет вовсе — рядом вкладка «Создать»."}),ee&&i.jsx("div",{className:"finds__agent",children:i.jsx(ap,{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:K,spellCheck:!1,autoComplete:"off",placeholder:"C:\\Projects",onChange:se=>M(se.target.value)}),d.length>0&&i.jsx("div",{className:"newproj__roots",children:d.map(se=>i.jsx("button",{type:"button",className:se===J?"newproj__root is-on":"newproj__root",title:se,onClick:()=>M(se),children:Bj(se)},se))}),i.jsx("label",{className:"field newproj__field",htmlFor:"workspace-name",children:"Имя проекта"}),i.jsx("input",{id:"workspace-name",className:"input input--mono",value:F,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"my-app",onChange:se=>H(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(se.preventDefault(),B())}}),i.jsx("p",{className:"newproj__preview",children:ge?Hj(J,D):"Каталог появится здесь"}),o&&i.jsx("p",{className:"modal__error",children:o}),i.jsxs("div",{className:"newproj__opts",children:[i.jsx(Nh,{label:"git init",desc:"панель истории работает сразу",on:A.git,onToggle:()=>Z(se=>({...se,git:!se.git}))}),i.jsx(Nh,{label:"CLAUDE.md",desc:"заготовка инструкций для агента",on:A.claudeMd,onToggle:()=>Z(se=>({...se,claudeMd:!se.claudeMd}))}),i.jsx(Nh,{label:"README.md",desc:"по нему проект потом узнаёт поиск",on:A.readme,onToggle:()=>Z(se=>({...se,readme:!se.readme}))})]})]})]})}function px({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 Nh({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 Hj(s,l){const r=s.includes("\\")?"\\":"/";return s.replace(/[\\/]+$/,"")+r+l}function Bj(s){const l=s.includes("\\")?"\\":"/",r=s.split(/[\\/]/).filter(Boolean);return r.length<=2?s:`…${l}${r.slice(-2).join(l)}`}function Ij(s){return s.open?"уже открыт":s.why?s.why:s.sessions===0?"рядом с вашими проектами":`${qj(s.sessions)}${Gj(s.lastUsedAt)}`}function qj(s){const l=s%10,r=s%100;return r>=11&&r<=14?`${s} сессий`:l===1?`${s} сессия`:l>=2&&l<=4?`${s} сессии`:`${s} сессий`}function Gj(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 ip=7;function Yj(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=mx(l),l[h]=o.hash);const[p,...m]=o.parents;l[h]=p??null;const x=[];p!==void 0&&x.push({from:h,to:h});for(const v of m){let E=l.indexOf(v);E===-1&&(E=mx(l),l[E]=v),x.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 j=[];for(let v=0;v<d.length;v++){const E=d[v];!E||E===o.hash||v===h||l[v]===E&&j.push(v)}Xj(l),c=Math.max(c,l.length,h+1),r.push({commit:o,col:h,up:_,down:x,through:j})}return{rows:r,columns:Math.min(c,ip)}}function mx(s){const l=s.indexOf(null);return l!==-1?l:(s.push(null),s.length-1)}function Xj(s){for(;s.length>0&&s[s.length-1]===null;)s.pop()}const ky=1500;function Vj(s){const l=[];let r=!1;for(const c of s.patch.split(`
|
|
118
118
|
`)){if(l.length>=ky){r=!0;break}if(c.startsWith("@@"))l.push({type:"gap",text:$j(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:Qj(s,r)}}function $j(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 Qj(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(`показаны первые ${ky} строк`),r.length>0?r.join(" · "):null}function Zj({open:s,state:l,result:r,selected:c,busy:o,onRefresh:d,onShow:h,onCheckout:p,onPush:m,onPull:x,onPublish:_,onConnectRemote:j,onDismissResult:v,onClose:E,zoomed:k,onToggleZoom:O}){const z=Yj((l==null?void 0:l.commits)??[]),ee=[...l!=null&&l.detached?[{value:"",label:`отделён · ${l.head.slice(0,8)}`}]:[],...((l==null?void 0:l.branches)??[]).map(te=>({value:te.name,label:te.name,hint:te.hash.slice(0,8)}))];return i.jsxs("aside",{className:(s?"sidepane sidepane--git sidepane--open":"sidepane sidepane--git")+(k?" sidepane--zoomed":""),"aria-label":"История git",children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:te=>{O&&(te.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:d,children:"↻"}),O&&i.jsx("button",{className:"sidepane__btn",title:k?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":k?"Свернуть панель истории":"Развернуть панель истории на весь экран","aria-pressed":k,onClick:O,children:i.jsx(Zr,{active:k})}),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(Is,{className:"gitbar__branch",title:"Ветка — выбрать значит переключиться",value:l.detached?"":l.branch,options:ee,onChange:te=>{te&&p(te,`ветку ${te}`)}})}),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(lk,{}),o]}):l.hasRemote?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"btn btn--sm",title:"Отправить текущую ветку в origin",onClick:m,children:[i.jsx(ek,{}),"Отправить",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:()=>x(!0),children:[i.jsx(tk,{}),"Забрать",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:()=>x(!1),children:i.jsx(nk,{})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"btn btn--sm btn--primary",title:"Создать репозиторий на GitHub и отправить в него ветку",onClick:_,children:[i.jsx(bx,{}),"Опубликовать на GitHub"]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",title:"Прописать origin на уже существующий репозиторий",onClick:j,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} ${ik(l.changed.length)}`:"Рабочее дерево чистое"}),i.jsx("span",{className:"gitrow__meta",children:l.changed.length>0?l.changed.slice(0,4).map(te=>ak(te.path)).join(", "):"незакоммиченных изменений нет"})]})}),z.rows.map(te=>i.jsx(Kj,{row:te,columns:z.columns,head:te.commit.hash===l.head,local:l.hasRemote&&!te.commit.pushed,active:c===te.commit.hash,onOpen:()=>h(te.commit.hash)},te.commit.hash)),z.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(bx,{}),"Опубликовать на GitHub"]}),i.jsx("p",{className:"gitempty__hint",children:"Заведёт репозиторий, сделает первый коммит и отправит его на GitHub."})]})]}),i.jsx(qi,{result:r,onDismiss:v})]})}const tu=50,gx=13;function Kj({row:s,columns:l,head:r,local:c,active:o,onOpen:d}){const{commit:h}=s,p=h.refs.map(sk).filter(Boolean);return i.jsxs("button",{className:"gitrow"+(o?" is-on":""),title:c?"Коммит ещё не отправлен на удалённый репозиторий":void 0,onClick:d,children:[i.jsx(Fj,{row:s,columns:l,head:r,local:c}),i.jsxs("span",{className:"gitrow__body",children:[i.jsxs("span",{className:"gitrow__subject",children:[p.map(m=>i.jsx("span",{className:"gitrow__ref",children:m},m)),h.subject]}),i.jsxs("span",{className:"gitrow__meta",children:[h.shortHash," · ",h.author," · ",rk(h.date),c&&i.jsx("span",{className:"gitrow__local",children:"· не отправлен"})]})]})]})}function Fj({row:s,columns:l,head:r,local:c}){const o=l*gx+6,d=tu/2,h=x=>8+Math.min(x,ip-1)*gx,p=c?"3.5 2.5":void 0,m=Xo(s.col);return i.jsxs("svg",{className:"gitgraph",width:o,height:tu,viewBox:`0 0 ${o} ${tu}`,"aria-hidden":"true",children:[s.through.map(x=>i.jsx("line",{x1:h(x),y1:0,x2:h(x),y2:tu,style:{stroke:Xo(x)}},`t${x}`)),s.up.map((x,_)=>i.jsx("path",{d:`M${h(x.from)} 0 L${h(x.from)} ${d-12} L${h(x.to)} ${d}`,fill:"none",style:{stroke:Xo(x.from),strokeDasharray:p}},`u${_}`)),s.down.map((x,_)=>i.jsx("path",{d:`M${h(x.from)} ${d} L${h(x.to)} ${d+12} L${h(x.to)} ${tu}`,fill:"none",style:{stroke:Xo(x.to),strokeDasharray:p}},`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:m,fill:c?void 0:m}})]})}function Xo(s){return`var(--lane-${s%ip})`}function Jj({detail:s,local:l,onCheckout:r,onClose:c}){const o=s.hash==="";return i.jsxs(Vl,{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}>`," · ",ck(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(Wj,{file:d,defaultOpen:s.files.length<=3},d.path+d.oldPath))]})}function Wj({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(sp,{diff:Vj(s)})]})}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("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 ek(){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 tk(){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 nk(){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 bx(){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 lk(){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 sk(s){return s.replace(/^HEAD -> /,"").replace(/^tag: /,"⌂ ").trim()}function ak(s){const l=s.split("/");return l[l.length-1]??s}function ik(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 rk(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 ck(s){const l=Date.parse(s);return Number.isNaN(l)?s:new Date(l).toLocaleString()}function xx(s){return s.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")}function uk({status:s,owners:l,files:r,defaultName:c,hasCommits:o,busy:d,result:h,onRefreshStatus:p,onSaveToken:m,onPublish:x,onDismissResult:_,onClose:j}){var se;const[v,E]=y.useState(()=>xx(c)),[k,O]=y.useState(""),[z,ee]=y.useState(""),[te,K]=y.useState(!0),[M,F]=y.useState("Первый коммит"),[H,A]=y.useState(null),[Z,ae]=y.useState("");y.useEffect(()=>{!k&&l.length>0&&O(l[0].login)},[k,l]),y.useEffect(()=>{r&&H===null&&A(new Set(r.files))},[r,H]);const G=(s==null?void 0:s.connected)===!0,J=l.map(be=>({value:be.login,label:be.login,hint:be.kind==="org"?"организация":void 0})),D=y.useMemo(()=>{if(!r)return[];const be=Z.trim().toLowerCase();return be?r.files.filter(Ce=>Ce.toLowerCase().includes(be)):r.files},[r,Z]),ge=(H==null?void 0:H.size)??0,Se=G&&v.trim()!==""&&k!==""&&d===""&&(o||ge>0);function xe(be){A(Ce=>{const w=new Set(Ce??[]);return w.has(be)?w.delete(be):w.add(be),w})}function B(be){A(Ce=>{const w=new Set(Ce??[]);for(const Q of D)be?w.add(Q):w.delete(Q);return w})}function ue(){if(!Se)return;const be=(r==null?void 0:r.files)??[];x({owner:k,name:v.trim(),description:z.trim(),private:te,include:o?[]:be.filter(Ce=>H==null?void 0:H.has(Ce)),ignore:o?[]:be.filter(Ce=>!(H!=null&&H.has(Ce))),message:o?"":M.trim()||"Первый коммит"})}return i.jsxs(Vl,{className:"modal--wide",title:"Опубликовать на GitHub",onClose:j,actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"btn",onClick:j,children:"Отмена"}),i.jsx("button",{type:"button",className:"btn btn--primary",disabled:!Se,onClick:ue,children:d||"Опубликовать"})]}),children:[i.jsx(ok,{status:s,onRefreshStatus:p,onSaveToken:m}),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(xx(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(Is,{className:"settings__select",value:k,options:J,onChange:O,placeholder:"выберите владельца",ariaLabel:"Владелец репозитория"}):i.jsx("p",{className:"publish__static",children:((se=l[0])==null?void 0:se.login)??"—"})]}),i.jsxs("label",{className:"field publish__field",children:[i.jsx("span",{children:"Описание (необязательно)"}),i.jsx("input",{className:"input",value:z,placeholder:"о чём проект — одной строкой",onChange:be=>ee(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(yx,{title:"Приватный",desc:"Виден только вам и тем, кого вы пригласите. Стоит по умолчанию: репозиторий с чужим кодом, случайно ставший публичным, потом не отозвать.",on:te,onClick:()=>K(!0)}),i.jsx(yx,{title:"Публичный",desc:"Виден всем в интернете — код, история коммитов, всё содержимое.",risky:!0,on:!te,onClick:()=>K(!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:[ge," из ",r.files.length," файлов"]}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:()=>B(!0),children:"Отметить все"}),i.jsx("button",{type:"button",className:"btn btn--sm btn--ghost",onClick:()=>B(!1),children:"Снять все"})]}),r.files.length>8&&i.jsx("input",{className:"input publish__filter",value:Z,placeholder:"Фильтр по пути…",spellCheck:!1,onChange:be=>ae(be.target.value)}),i.jsx("div",{className:"publish__filelist",children:D.length===0?i.jsx("p",{className:"modal__text publish__filesempty",children:"Ничего не найдено по фильтру."}):D.map(be=>i.jsxs("button",{type:"button",role:"checkbox","aria-checked":(H==null?void 0:H.has(be))===!0,className:"publish__file",onClick:()=>xe(be),children:[i.jsx("span",{className:"publish__box"+(H!=null&&H.has(be)?" is-on":""),"aria-hidden":"true",children:(H==null?void 0:H.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:M,onChange:be=>F(be.target.value)})]})]})]}),i.jsx(qi,{result:h,onDismiss:_})]})}function yx({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 ok({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(fk,{value:c,onChange:o,visible:d,onToggleVisible:()=>h(p=>!p),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 fk({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(hk,{}):i.jsx(dk,{})})]})}function dk(){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 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:"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 pk({busy:s,result:l,onSubmit:r,onDismissResult:c,onClose:o}){const[d,h]=y.useState(""),p=/^(https?|ssh|git):\/\/\S+/i.test(d.trim())||/^[\w.-]+@[\w.-]+:.+/.test(d.trim());return i.jsxs(Vl,{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:!p||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:m=>h(m.target.value),onKeyDown:m=>{m.key==="Enter"&&p&&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(qi,{result:l,onDismiss:c})]})}function mk({open:s,items:l,busy:r,ready:c,commands:o,contextResult:d,draftKey:h,models:p,model:m,effort:x,ultracode:_,thinking:j,switchOnFlag:v,onContextSearch:E,onCommand:k,onModel:O,onEffort:z,onUltracode:ee,onThinking:te,onSwitchOnFlag:K,onAsk:M,onInterrupt:F,onReset:H,onClose:A,zoomed:Z,onToggleZoom:ae}){return i.jsxs("aside",{className:(s?"sidepane sidepane--ask sidepane--open":"sidepane sidepane--ask")+(Z?" sidepane--zoomed":""),"aria-label":"Вопрос на полях",children:[i.jsxs("div",{className:"sidepane__head",onDoubleClick:G=>{ae&&(G.target.closest("button")||ae())},children:[i.jsx(gk,{}),i.jsx("span",{className:"sidepane__title",children:"Вопрос на полях"}),i.jsx("button",{className:"sidepane__btn",title:"Начать заново — следующий вопрос возьмёт свежий контекст","aria-label":"Начать боковой разговор заново",disabled:l.length===0,onClick:H,children:"↻"}),ae&&i.jsx("button",{className:"sidepane__btn",title:Z?"Свернуть панель — то же самое, что двойной клик по шапке":"Развернуть панель на весь экран — то же самое, что двойной клик по шапке","aria-label":Z?"Свернуть панель вопроса":"Развернуть панель вопроса на весь экран","aria-pressed":Z,onClick:ae,children:i.jsx(Zr,{active:Z})}),i.jsx("button",{className:"sidepane__btn",title:"Закрыть панель","aria-label":"Закрыть панель вопроса",onClick:A,children:"✕"})]}),p.length>0&&i.jsxs("div",{className:"sidepane__tools",children:[i.jsx(jy,{className:"select--compact",models:p,value:m,effort:x,ultracode:_,thinking:j,switchOnFlag:v,onModel:O,onEffort:z,onUltracode:ee,onThinking:te,onSwitchOnFlag:K}),i.jsx("span",{className:"sidepane__note",title:"Боковой вопрос работает только на чтение",children:"только чтение"})]}),i.jsx(ap,{items:l,busy:r,waiting:!1,empty:c?"Спросите о том, что происходит: вопрос уйдёт в сторону от основного разговора и не попадёт в его контекст. Отвечающий видит сессию и проект, но ничего не меняет.":"Откройте сессию — вопрос задаётся о ней."}),i.jsx(_y,{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:k,onSend:M,onInterrupt:F,onEscape:r?F:A})]})}function gk(){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 bk=75,xk=90;function wy({usage:s}){if(!(s!=null&&s.available))return null;const l=[];return s.fiveHour&&l.push({key:"five",label:"5 ч",window:s.fiveHour}),s.sevenDay&&l.push({key:"week",label:"нед",window:s.sevenDay}),l.length===0?null:i.jsx("div",{className:"usage",title:vk(s),"aria-label":`Расход лимитов плана${s.plan?` ${s.plan}`:""}`,children:l.map(r=>i.jsx(yk,{label:r.label,window:r.window},r.key))})}function yk({label:s,window:l}){const r=Math.round(l.utilization),c=Sk(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${_k(r)}`,style:{width:`${r}%`}})}),i.jsxs("span",{className:"usage__pct",children:[r,"%"]}),i.jsx("span",{className:"usage__reset",title:Ey(l.resetsAt)||void 0,children:c&&`↻ ${c}`})]})}function _k(s){return s>=xk?" usage__fill--over":s>=bk?" usage__fill--warn":""}function vk(s){const l=[s.plan?`Лимиты плана ${s.plan}`:"Лимиты плана"],r=(c,o)=>{if(!o)return;const d=Ey(o.resetsAt);l.push(`${c}: ${Math.round(o.utilization)}%${d?`, ${d}`:""}`)};return r("5 часов",s.fiveHour),r("Неделя",s.sevenDay),r("Неделя, Opus",s.sevenDayOpus),l.join(`
|
|
119
119
|
`)}function Ny(s){if(!s)return null;const l=new Date(s);return Number.isNaN(l.getTime())?null:l}function Ty(s){return s.getTime()-Date.now()<1440*60*1e3}function Sk(s){const l=Ny(s);return l?Ty(l)?l.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):l.toLocaleDateString(void 0,{day:"numeric",month:"short"}):""}function Ey(s){const l=Ny(s);return l?`обнулится ${Ty(l)?`в ${l.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:l.toLocaleDateString(void 0,{day:"numeric",month:"long"})}`:""}function Ay(){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:jk(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 jk(s){return s.toLocaleDateString(void 0,{weekday:"long",day:"numeric",month:"long",year:"numeric"})}function kk({onClose:s,permission:l,model:r,usage:c,cwd:o,costLabel:d,onRefresh:h,refreshing:p,metersFetchedAt:m,onRename:x}){return i.jsx(Vl,{title:"Настройки сессии",className:"modal--sheet",sheet:!0,onClose:s,children:i.jsxs("div",{className:"sessionmenu",children:[l&&i.jsx(Cr,{label:"Режим прав",children:l}),i.jsx(Cr,{label:"Модель",children:r}),(c==null?void 0:c.available)&&(c.fiveHour||c.sevenDay)&&i.jsx(Cr,{label:"Лимиты плана",children:i.jsx(wy,{usage:c})}),i.jsxs("button",{type:"button",className:p?"sessionmenu__refresh is-busy":"sessionmenu__refresh","aria-busy":p,disabled:p,onClick:h,children:[i.jsx(wk,{}),i.jsxs("span",{className:"sessionmenu__refresh-text",children:["Обновить показания",m&&i.jsxs("span",{className:"sessionmenu__refresh-time",children:["обновлено в"," ",new Date(m).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]})]}),i.jsx(Cr,{label:"Время",children:i.jsx(Ay,{})}),d&&i.jsx(Cr,{label:"Стоимость хода",children:i.jsx("span",{className:"badge badge--cost",children:d})}),o&&i.jsx(Cr,{label:"Каталог проекта",children:i.jsx(Sy,{path:o})}),x&&i.jsx("button",{type:"button",className:"sessionmenu__rename",onClick:x,children:"Переименовать сессию"})]})})}function Cr({label:s,children:l}){return i.jsxs("div",{className:"sessionmenu__row",children:[i.jsx("span",{className:"sessionmenu__label",children:s}),l]})}function wk(){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 Nk({tab:s,servers:l,plugins:r,marketplaces:c,catalog:o,result:d,actions:h,onTab:p,onClose:m}){const x=[{id:"mcp",label:"MCP-серверы",count:l.length},{id:"plugins",label:"Плагины",count:r.length},{id:"catalog",label:"Каталог",count:o.length}];return i.jsxs(Vl,{title:"Расширения",className:"modal--wide",onClose:m,children:[i.jsx("div",{className:"tabs",role:"tablist",children:x.map(_=>i.jsxs("button",{role:"tab","aria-selected":s===_.id,className:s===_.id?"tabs__tab is-on":"tabs__tab",onClick:()=>p(_.id),children:[_.label,i.jsx("span",{className:"tabs__count",children:_.count})]},_.id))}),s==="mcp"&&i.jsx(Tk,{servers:l,actions:h}),s==="plugins"&&i.jsx(Mk,{plugins:r,marketplaces:c,actions:h}),s==="catalog"&&i.jsx(Ok,{catalog:o,hasMarketplaces:c.length>0,actions:h,onMarketplaces:()=>p("plugins")}),i.jsx(qi,{result:d})]})}function Tk({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--${Ak(o.status)}`,children:Ek[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(Ck,{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 Ek={connected:"подключён",failed:"ошибка","needs-auth":"нужна авторизация",pending:"подключается",disabled:"выключен",unknown:"неизвестно"};function Ak(s){return s==="connected"?"ok":s==="failed"?"bad":s==="needs-auth"?"warn":"mute"}function Ck({onSubmit:s,onCancel:l}){const[r,c]=y.useState(""),[o,d]=y.useState("stdio"),[h,p]=y.useState(""),[m,x]=y.useState(""),[_,j]=y.useState(""),v=o==="stdio",E=r.trim()!==""&&(v?h.trim()!=="":m.trim()!=="");function k(){if(E)if(v){const[O,...z]=Rk(h);s(r.trim(),{transport:"stdio",command:O??"",args:z,env:_x(_)})}else s(r.trim(),{transport:o,url:m.trim(),headers:_x(_)})}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:O=>c(O.target.value)}),i.jsx("label",{className:"field",children:"Транспорт"}),i.jsx(Is,{title:"Транспорт",value:o,options:[{value:"stdio",label:"stdio",hint:"локальный процесс"},{value:"http",label:"http",hint:"удалённый сервер"},{value:"sse",label:"sse",hint:"удалённый, поток событий"}],onChange:O=>d(O)}),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:O=>p(O.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:m,spellCheck:!1,autoComplete:"off",placeholder:"https://mcp.example.dev/mcp",onChange:O=>x(O.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:O=>j(O.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:k,children:"Подключить"})]})]})}function _x(s){const l={};for(const r of s.split(`
|
|
120
120
|
`)){const c=r.trim();if(!c)continue;const o=c.indexOf("="),d=c.indexOf(":"),h=o===-1?d:d===-1?o:Math.min(o,d);h<=0||(l[c.slice(0,h).trim()]=c.slice(h+1).trim())}return l}function Rk(s){return(s.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(l=>l.replace(/^["']|["']$/g,""))}function Mk({plugins:s,marketplaces:l,actions:r}){const[c,o]=y.useState("");return i.jsxs(i.Fragment,{children:[s.length===0&&i.jsx("p",{className:"modal__text",children:"Ни одного установленного плагина. Что можно поставить — на вкладке «Каталог»."}),i.jsx("ul",{className:"extlist",children:s.map(d=>i.jsxs("li",{className:"extlist__row",children:[i.jsxs("div",{className:"extlist__head",children:[i.jsx("span",{className:"extlist__name",children:d.name}),i.jsx("span",{className:d.enabled?"chip chip--ok":"chip chip--mute",children:d.enabled?"включён":"выключен"}),d.version&&d.version!=="unknown"&&i.jsx("span",{className:"chip",children:d.version}),d.scope&&i.jsx("span",{className:"chip",children:d.scope})]}),d.marketplace&&i.jsx("div",{className:"extlist__meta",children:d.marketplace}),d.mcpServers.length>0&&i.jsxs("div",{className:"extlist__meta",children:["MCP-серверы: ",d.mcpServers.join(", ")]}),i.jsxs("div",{className:"extlist__actions",children:[i.jsx("button",{className:"btn btn--ghost btn--sm",onClick:()=>r.pluginToggle(d.id,!d.enabled),children:d.enabled?"Выключить":"Включить"}),i.jsx("button",{className:"btn btn--ghost btn--sm btn--danger",onClick:()=>r.pluginUninstall(d.id),children:"Удалить"})]})]},d.id))}),i.jsx("div",{className:"sidebar__section",children:"Маркетплейсы"}),i.jsx("ul",{className:"extlist",children:l.map(d=>i.jsxs("li",{className:"extlist__row",children:[i.jsx("div",{className:"extlist__head",children:i.jsx("span",{className:"extlist__name",children:d.name})}),d.source&&i.jsx("div",{className:"extlist__meta",children:d.source}),i.jsx("div",{className:"extlist__actions",children:i.jsx("button",{className:"btn btn--ghost btn--sm btn--danger",onClick:()=>r.marketplaceRemove(d.name),children:"Отключить"})})]},d.name))}),i.jsxs("div",{className:"extform__row",children:[i.jsx("input",{className:"input input--mono",value:c,spellCheck:!1,autoComplete:"off","aria-label":"Источник маркетплейса",placeholder:"owner/repo, URL или путь",onChange:d=>o(d.target.value),onKeyDown:d=>{d.key!=="Enter"||c.trim()===""||(d.preventDefault(),r.marketplaceAdd(c.trim()),o(""))}}),i.jsx("button",{className:"btn",disabled:c.trim()==="",onClick:()=>{r.marketplaceAdd(c.trim()),o("")},children:"Добавить"})]})]})}const nu=30;function Ok({catalog:s,hasMarketplaces:l,actions:r,onMarketplaces:c}){const[o,d]=y.useState(""),[h,p]=y.useState(""),[m,x]=y.useState(nu),[_,j]=y.useState(""),v=y.useMemo(()=>[...new Set(s.map(O=>O.category).filter(Boolean))].sort(),[s]),E=y.useMemo(()=>{const k=o.trim().toLowerCase();return s.filter(O=>h&&O.category!==h?!1:k?`${O.name} ${O.displayName} ${O.description} ${O.author}`.toLowerCase().includes(k):!0)},[s,o,h]);return s.length===0?i.jsxs("p",{className:"modal__text",children:[l?"Маркетплейсы подключены, но их каталог ещё не выкачан. Попробуйте открыть окно ещё раз через минуту.":"Ни одного маркетплейса — ставить нечего."," ",i.jsx("button",{className:"linkish",onClick:c,children:"Подключить маркетплейс"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"catalog__filters",children:[i.jsx("input",{className:"input",value:o,spellCheck:!1,autoComplete:"off","aria-label":"Поиск по каталогу",placeholder:"Поиск: имя, описание, автор",onChange:k=>{d(k.target.value),x(nu)}}),i.jsx(Is,{title:"Категория",value:h,options:[{value:"",label:"все категории"},...v.map(k=>({value:k,label:k}))],onChange:k=>{p(k),x(nu)}})]}),E.length===0?i.jsx("p",{className:"modal__text",children:"Ничего не нашлось."}):i.jsx("ul",{className:"extlist",children:E.slice(0,m).map(k=>i.jsxs("li",{className:"extlist__row",children:[i.jsxs("div",{className:"extlist__head",children:[i.jsx("span",{className:"extlist__name",children:k.name}),k.installed&&i.jsx("span",{className:"chip chip--ok",children:"установлен"}),k.version&&i.jsx("span",{className:"chip",children:k.version}),k.category&&i.jsx("span",{className:"chip",children:k.category})]}),k.description&&i.jsx("div",{className:"catalog__desc",children:k.description}),i.jsxs("div",{className:"extlist__meta",children:[k.author&&`${k.author} · `,k.marketplace]}),i.jsxs("div",{className:"extlist__actions",children:[i.jsx("button",{className:"btn btn--ghost btn--sm",disabled:k.installed,onClick:()=>r.pluginInstall(k.id),children:k.installed?"Уже стоит":"Установить"}),k.homepage&&i.jsx("a",{className:"btn btn--ghost btn--sm",href:k.homepage,target:"_blank",rel:"noreferrer",children:"Страница"})]})]},k.id))}),E.length>m&&i.jsx("div",{className:"extbar",children:i.jsxs("button",{className:"btn",onClick:()=>x(k=>k+nu),children:["Ещё ",Math.min(nu,E.length-m)," из ",E.length-m]})}),i.jsxs("div",{className:"extform",children:[i.jsx("label",{className:"field",htmlFor:"plugin-spec",children:"Или установить по имени — если нужного в каталоге нет"}),i.jsxs("div",{className:"extform__row",children:[i.jsx("input",{id:"plugin-spec",className:"input input--mono",value:_,spellCheck:!1,autoComplete:"off",placeholder:"имя или имя@маркетплейс",onChange:k=>j(k.target.value),onKeyDown:k=>{k.key!=="Enter"||_.trim()===""||(k.preventDefault(),r.pluginInstall(_.trim()),j(""))}}),i.jsx("button",{className:"btn",disabled:_.trim()==="",onClick:()=>{r.pluginInstall(_.trim()),j("")},children:"Установить"})]})]})]})}function Dk({status:s,login:l,actions:r,remote:c,runningSessions:o,onReconnect:d,reconnectBlocked:h,reconnectHint:p,onClose:m}){const[x,_]=y.useState(""),[j,v]=y.useState(!1),[E,k]=y.useState(!1),O=d!==null&&(s==null?void 0:s.loggedIn)===!0&&!E&&!j,z=y.useMemo(()=>{if(l.error)return{ok:!1,message:l.error};const K=l.output.trim();return K===""?null:{ok:!0,message:K}},[l.error,l.output]);function ee(K=x){const M=K.trim();M!==""&&(r.submitCode(M),_(""))}function te(){if(o>0){v(!1),k(!0);return}r.login("claudeai",!0)}return i.jsxs(Vl,{title:"Аккаунт",onClose:m,children:[s===null?i.jsx("p",{className:"modal__text",children:"Спрашиваем у хоста…"}):s.loggedIn?i.jsxs("div",{className:"account",children:[i.jsx("div",{className:"account__id",children:s.email||"Вход выполнен"}),i.jsxs("div",{className:"account__chips",children:[i.jsx("span",{className:"chip chip--ok",children:Uk[s.method]??s.method}),s.plan&&i.jsx("span",{className:"chip",children:s.plan})]}),s.organization&&i.jsx("div",{className:"extlist__meta",children:s.organization})]}):i.jsxs("p",{className:"modal__text",children:["Вход не выполнен. Сессии не запустятся, пока аккаунт не подключён — или пока в окружении хоста нет ",i.jsx("code",{children:"ANTHROPIC_API_KEY"}),"."]}),l.active?i.jsx(Hk,{login:l,remote:c,code:x,onCode:_,onSubmit:ee,onCancel:r.cancel}):i.jsxs(i.Fragment,{children:[i.jsx(qi,{result:z}),E&&i.jsx("p",{className:"account__warn",role:"alert",children:Lk(o)}),O&&h&&i.jsx("p",{className:"account__note",children:p}),i.jsx("div",{className:`extbar${s!=null&&s.loggedIn?" account__bar":""}`,children:s!=null&&s.loggedIn?i.jsxs(i.Fragment,{children:[O&&i.jsxs("button",{type:"button",className:"btn account__relink",title:`Переподключить сессию
|
|
@@ -128,5 +128,5 @@ ${p}`,"aria-label":"Переподключить сессию",disabled:h,onClic
|
|
|
128
128
|
`)),r&&J.focus(),F=()=>{var w;B!==null&&window.clearTimeout(B),se.disconnect(),(w=J.element)==null||w.removeEventListener("contextmenu",ge),Se.dispose(),ue.dispose(),be(),J.dispose(),_.current=null},z("ready")})(),()=>{M=!0,window.clearTimeout(H),F==null||F(),F=null}},[s]),y.useEffect(()=>{if(!o)return;const K=x.current;if(!K)return;let M=null,F=0,H=!1;const A=J=>{J.pointerType==="mouse"||M!==null||(M=J.pointerId,F=J.clientY,H=!1)},Z=J=>{if(J.pointerId!==M)return;const D=F-J.clientY;if(!H){if(Math.abs(D)<4)return;H=!0,K.setPointerCapture(J.pointerId)}F=J.clientY;const ge=K.querySelector(".xterm-viewport");ge&&(ge.scrollTop+=D)},ae=J=>{J.pointerId===M&&(K.hasPointerCapture(J.pointerId)&&K.releasePointerCapture(J.pointerId),M=null,H=!1)},G=J=>J.stopPropagation();return K.addEventListener("pointerdown",A),K.addEventListener("pointermove",Z),K.addEventListener("pointerup",ae),K.addEventListener("pointercancel",ae),K.addEventListener("touchmove",G,{capture:!0}),()=>{K.removeEventListener("pointerdown",A),K.removeEventListener("pointermove",Z),K.removeEventListener("pointerup",ae),K.removeEventListener("pointercancel",ae),K.removeEventListener("touchmove",G,{capture:!0}),M!==null&&K.hasPointerCapture(M)&&K.releasePointerCapture(M)}},[o]),y.useEffect(()=>{E.current=c,_.current&&(_.current.options.theme=c)},[c]),y.useEffect(()=>{var K;r&&((K=_.current)==null||K.focus())},[r]),y.useEffect(()=>{if(k.current=l,l===null){j.current=!1;return}if(j.current)return;const K=_.current;K&&(j.current=!0,K.write(`\r
|
|
129
129
|
\x1B[2m— Процесс завершён (код ${l}) —\x1B[0m\r
|
|
130
130
|
`))},[l]),i.jsxs("div",{className:"termview"+(r?" is-active":""),children:[i.jsx("div",{ref:x,className:"termview__surface"+(O==="ready"?"":" is-hidden")}),O==="loading"&&ee&&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:"Загружается терминал…"})]}),O==="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 iw=2e5,rw=75,cw=90;function uw({tokens:s,maxTokens:l,fetchedAt:r}){if(s===null)return null;const c=l??iw,o=Math.min(100,Math.round(s/c*100)),d=`${s.toLocaleString()} из ${c.toLocaleString()} токенов${r?`
|
|
131
|
-
обновлено в ${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${ow(o)}`,style:{width:`${o}%`}})}),i.jsxs("span",{className:"contextbar__pct",children:[o,"%"]})]})}function ow(s){return s>=cw?" contextbar__fill--over":s>=rw?" contextbar__fill--warn":""}const Cy="ccv:last-session",fw=300*1e3,dw=1e4;function hw(){try{const s=localStorage.getItem(Cy);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 pw(s,l){return s.id===l.sessionId?!0:l.claudeSessionId?s.id===l.claudeSessionId||s.claudeSessionId===l.claudeSessionId:!1}const mw={mcp:"mcp",plugins:"plugins",plugin:"plugins"},Nx=[{name:"login",description:"Войти в аккаунт Claude — окно приложения",argumentHint:"",aliases:["signin","вход"]},{name:"switch-account",description:"Сменить аккаунт: выйти и войти заново",argumentHint:"",aliases:["account","аккаунт"]},{name:"logout",description:"Выйти из аккаунта Claude",argumentHint:"",aliases:["signout","выход"]}],gw={active:!1,url:"",awaitingCode:!1,output:"",error:null};function Tx(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,p)=>Ex(h.name,d)-Ex(p.name,d))}}function Ex(s,l){return s.toLowerCase().startsWith(l)?0:1}function Ax(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 bw(){var ds;const s=y.useRef(null),[l,r]=y.useState(!1),[c,o]=y.useState("Нет связи с хостом"),[d,h]=y.useState(null),[p,m]=y.useState(!1),x=y.useMemo(()=>Ko()==="relay",[]),[_,j]=y.useState([]),[v,E]=y.useState([]),[k,O]=y.useState([]),[z,ee]=y.useState([]),[te,K]=y.useState([]),[M,F]=y.useState([]),[H,A]=y.useState([]),[Z,ae]=y.useState([]),[G,J]=y.useState(null),[D,ge]=y.useState(null),[Se,xe]=y.useState(null),[B,ue]=y.useState(Ol),[se,be]=y.useState(uh),[Ce,w]=y.useState(!1),[Q,re]=y.useState(!1),oe=uf("(max-width: 860px)"),[ye,je]=y.useState(!1);y.useEffect(()=>{oe||je(!1)},[oe]);const[Me,ht]=y.useState(!1),[lt,Nn]=y.useState([]),[Je,Kt]=y.useState(!1),[ct,rn]=y.useState(Ol),[Be,rt]=y.useState(null),[Hn,wt]=y.useState(null),[Ot,Ft]=y.useState([]),[tn,$t]=y.useState(null),[Nt,Qe]=y.useState(null),[We,dn]=y.useState([]),[Jt,Qt]=y.useState([]),[Bn,Tn]=y.useState([]),[hn,sl]=y.useState([]),[zt,bt]=y.useState(null),[Ut,$e]=y.useState(!1),[Qn,W]=y.useState(null),[de,we]=y.useState(null),[L,V]=y.useState(!1),[_e,ze]=y.useState(gw),[st,al]=y.useState(null),[Pe,En]=y.useState(null),[In,$l]=y.useState(!1),[da,,qs]=x0(),Ll=j0(),[qn,pl]=y.useState(!1),[nn,_l]=y.useState(null),[Gn,Ht]=y.useState(null),[Ze,ln]=y.useState(null),[is,An]=y.useState(null),[Cn,zl]=y.useState(null),[vl,ys]=y.useState(""),[It,Ql]=y.useState(null),[Zl,pn]=y.useState([]),[Tt,Yn]=y.useState(!1),[Gs,cn]=y.useState(null),[T,he]=y.useState(!1),[Ge,pt]=y.useState(!1),[un,ml]=y.useState({}),[il,mn]=y.useState([""]),[xt,rl]=y.useState([]),[ha,Sl]=y.useState(null),[ti,gl]=y.useState(null),[_s,Rn]=y.useState(null),[rs,vs]=y.useState(null),[Ss,jl]=y.useState(null),[me,N]=y.useState({}),[I,fe]=y.useState({}),[Ne,Oe]=y.useState(!1),[Ue,Et]=y.useState(null),[Wt,gn]=y.useState(null),Dt=y.useRef(0),bn=y.useRef(null),[Bt,js]=y.useState(!1),[cs,pa]=y.useState([]),[Kr,ni]=y.useState(null),[li,kl]=y.useState(null),ma=w0(),Ys=T0(oe&&Bt),wl=y.useRef(new Map),us=(de==null?void 0:de.terminalEnabled)===!0,Xs=Ko()==="relay"&&((ds=d==null?void 0:d.shell)==null?void 0:ds.enabled)!==!0,Gi=y.useRef(!1),Yi=y.useCallback((g,q)=>(wl.current.set(g,q),()=>{wl.current.get(g)===q&&wl.current.delete(g)}),[]),[Kl,Xi]=y.useState(!1),[Zn,Fl]=y.useState(null),[si,ks]=y.useState(Ol),[os,ga]=y.useState(null),[Vs,Ul]=y.useState({}),ws=y.useRef([]),[qt,Fr]=y.useState(null);function df(g){Fr(q=>q===g?null:g)}y.useEffect(()=>{(oe||qt==="terminal"&&!Bt||qt==="files"&&!Ge||qt==="search"&&!Ne||qt==="git"&&!qn||qt==="ask"&&!Kl||qt==="main"&&xt.length===0)&&Fr(null)},[qt,oe,Bt,Ge,Ne,qn,Kl,xt.length]);const[hf]=y.useState(hw),Vi=y.useRef(hf),$i=y.useRef(!1),Kn=y.useRef(null),xn=y.useRef(null),du=y.useRef(0);Kn.current=D,xn.current=G,du.current=B.lastSeq;const hu=y.useRef(se);hu.current=se;const Jl=y.useRef(null),pu=y.useRef(0);pu.current=si.lastSeq;const Qi=y.useRef(null),Zi=y.useRef(""),ai=y.useRef(null),fs=y.useRef([]),mu=y.useRef([""]);fs.current=xt,mu.current=il;const ii=y.useRef(new Map),Ki=y.useRef(new Set),ba=y.useRef(null),ri=y.useRef(null),gu=y.useRef(0),ci=y.useRef(new Set);y.useEffect(()=>{const g=d0();if(!g)return;s.current=g;const q=()=>{r(g.connected),o(g.statusText)};g.onStatus(q),g.onReconnect(()=>{q();const Pt=Kn.current;Pt&&g.send({type:"session.sync",sessionId:Pt,sinceSeq:du.current});const yn=Jl.current;yn&&g.send({type:"session.sync",sessionId:yn,sinceSeq:pu.current})});const pe=g.on(Pt=>pf(Pt));g.connect();const Ye=window.setInterval(()=>{q(),g.connected&&g.send({type:"ping",nonce:Date.now()})},15e3);return()=>{pe(),window.clearInterval(Ye),g.close()}},[]);const pf=y.useCallback(g=>{var q,pe,Ye,Pt,yn,Ln,Fs;switch(g.type){case"hello.ok":r(!0);break;case"workspace.list":{j(g.workspaces),E(g.archived),J(Ie=>{var zn;if(Ie)return Ie;const ut=Vi.current,dt=ut&&g.workspaces.find(gi=>gi.id===ut.workspaceId);return(dt==null?void 0:dt.id)??((zn=g.workspaces[0])==null?void 0:zn.id)??null});const Ee=ai.current;if(!Ee)break;const De=g.workspaces.find(Ie=>vw(Ie.path,Ee));if(!De)break;ai.current=null,ht(!1),J(De.id);break}case"workspace.candidates":if(g.query.trim()!==Zi.current)break;Nn(g.candidates),g.source==="host"&&Kt(!1);break;case"finder.opened":Qi.current=g.sessionId;break;case"workspace.roots":Ft(g.roots);break;case"workspace.created":if(J(g.workspace.id),g.warnings.length===0){ht(!1),wt(null);break}$t({path:g.workspace.path,warnings:g.warnings});break;case"session.list":if(g.workspaceId!==xn.current)break;F(g.sessions),A(g.archived);break;case"folder.list":O(g.workspaceFolders),ee(g.sessionFolders),K(g.pinnedFolders);break;case"session.pinned":ae(g.sessions);break;case"session.summary":if(g.session.id===Qi.current){rt(g.session);break}if(g.session.parentSessionId){g.session.id===Jl.current&&ga(g.session);break}F(Ee=>{const De=Ee.findIndex(ut=>ut.id===g.session.id);if(De===-1)return[g.session,...Ee];const Ie=Ee.slice();return Ie[De]=g.session,Ie}),ae(Ee=>{const De=Ee.findIndex(ut=>ut.id===g.session.id);if(De===-1)return Ee;const Ie=Ee.slice();return Ie[De]={...g.session,pinned:!0,...Ee[De].pinnedAt?{pinnedAt:Ee[De].pinnedAt}:{}},Ie}),ge(Ee=>Ee??g.session.id);break;case"usage.state":g.sessionId===Kn.current&&(al(g.usage),$l(!1));break;case"context.state":g.sessionId===Kn.current&&(En(g.context),$l(!1));break;case"session.capabilities":g.sessionId===Kn.current&&xe(g.capabilities);break;case"session.events":if(g.sessionId===Jl.current){ks(Ee=>Fo(Ee,g.entries));break}if(g.sessionId===Qi.current){rn(Ee=>Fo(Ee,g.entries));break}if(g.sessionId!==Kn.current)break;for(const Ee of g.entries){if(Ee.event.kind!=="rewound")continue;const De=Ee.event.toUserIndex,Ie=g0(hu.current.entries,De),ut=Ie.reduce((dt,zn)=>zn.event.kind==="user.message"?dt+1:dt,0);be(dt=>({...dt,entries:Ie})),ue(dt=>({...dt,items:b0(dt.items,De,ut)}))}ue(Ee=>Fo(Ee,g.entries));break;case"session.history":if(g.sessionId!==Kn.current)break;be(Ee=>h0(Ee,g));break;case"side.opened":{if(g.parentSessionId!==Kn.current)break;Jl.current=g.sessionId,Fl(g.sessionId);const Ee=ws.current;ws.current=[];for(const De of Ee)De(g.sessionId);break}case"side.closed":if(g.parentSessionId!==Kn.current)break;Jl.current=null,Fl(null),ks(Ol),ga(null);break;case"git.state":if(g.workspaceId!==xn.current)break;_l(g.state);break;case"git.commit":if(g.workspaceId!==xn.current)break;Ht(g.detail);break;case"git.result":if(g.workspaceId!==xn.current)break;An({ok:g.ok,message:g.message,url:g.url}),g.ok&&(Ht(null),ln(null),Yn(!1),he(!1));break;case"git.busy":if(g.workspaceId!==xn.current)break;ys(g.label);break;case"git.files":if(g.workspaceId!==xn.current)break;cn({files:g.files,truncated:g.truncated});break;case"github.status":Ql(g.status);break;case"github.owners":pn(g.owners);break;case"fs.dir":if(g.workspaceId!==xn.current)break;ml(Ee=>({...Ee,[g.path]:g.entries}));break;case"fs.search":if(g.workspaceId!==xn.current)break;if(g.scope!=="tree"){const Ee=g.scope;fe(De=>({...De,[Ee]:{query:g.query,entries:g.entries}}));break}jl({query:g.query,entries:g.entries,truncated:g.truncated});break;case"fs.grep":if(g.workspaceId!==xn.current)break;Et({query:g.query,matches:g.matches,truncated:g.truncated});break;case"fs.file":{if(g.workspaceId!==xn.current)break;const Ee=Ki.current.delete(g.file.path);rl(Ie=>{const ut=Ie.findIndex(gi=>gi.path===g.file.path);if(ut===-1)return[...Ie,Fb(g.file,++gu.current)];const dt=Ie[ut],zn=Ie.slice();return zn[ut]=dt.saved===g.file.content&&!ca(dt)?{...dt,mtime:g.file.mtime,size:g.file.size,stale:!1}:Fb(g.file,++gu.current),zn}),Ee&&Sl(g.file.path);const De=bn.current;De&&De.path===g.file.path&&(bn.current=null,gn({...De,token:++Dt.current}));break}case"fs.media":{if(g.workspaceId!==xn.current)break;ci.current.delete(g.path),rl(Ee=>Ee.map(De=>De.path===g.path?{...De,mediaBase64:g.base64,mediaError:void 0}:De));break}case"fs.mediaFailed":{if(g.workspaceId!==xn.current)break;ci.current.delete(g.path),rl(Ee=>Ee.map(De=>De.path===g.path?{...De,mediaError:g.message}:De));break}case"fs.saved":{if(g.workspaceId!==xn.current)break;const Ee=ii.current.get(g.path);ii.current.delete(g.path);const De=Ee!==void 0;rl(ut=>ut.map(dt=>dt.path!==g.path?dt:De?{...dt,saved:Ee,mtime:g.mtime,size:g.size,stale:!1}:{...dt,stale:!0}));const Ie=fs.current.find(ut=>ut.path===g.path);!De&&Ie&&!ca(Ie)&&((q=s.current)==null||q.send({type:"fs.read",workspaceId:g.workspaceId,path:g.path})),(pe=s.current)==null||pe.send({type:"git.state",workspaceId:g.workspaceId});break}case"fs.result":{if(g.workspaceId!==xn.current)break;if(gl({ok:g.ok,message:g.message}),g.ok||ii.current.delete(g.path),g.conflict&&rl(De=>De.map(Ie=>Ie.path===g.path?{...Ie,stale:!0}:Ie)),ri.current===g.path){const De=ri.current;ri.current=null,g.ok&&(Ki.current.add(De),(Ye=s.current)==null||Ye.send({type:"fs.read",workspaceId:g.workspaceId,path:De}))}const Ee=ba.current;if(g.ok&&Ee&&Ee.to===g.path){ba.current=null;const De=Ie=>Ie===Ee.from?Ee.to:Ie.startsWith(`${Ee.from}/`)?Ee.to+Ie.slice(Ee.from.length):Ie;rl(Ie=>Ie.map(ut=>({...ut,path:De(ut.path)}))),Sl(Ie=>Ie===null?null:De(Ie)),mn(Ie=>Ie.map(De)),ml(Ie=>{const ut={};for(const[dt,zn]of Object.entries(Ie))dt===Ee.from||dt.startsWith(`${Ee.from}/`)||(ut[dt]=zn);return ut})}g.ok&&((Pt=s.current)==null||Pt.send({type:"git.state",workspaceId:g.workspaceId}));break}case"term.list":if(g.workspaceId!==xn.current)break;pa(g.terminals);break;case"term.opened":if(g.terminal.workspaceId!==xn.current)break;kl(null),pa(Ee=>{const De=Ee.findIndex(ut=>ut.id===g.terminal.id);if(De===-1)return[...Ee,g.terminal];const Ie=Ee.slice();return Ie[De]=g.terminal,Ie}),Gi.current&&(Gi.current=!1,ni(g.terminal.id));break;case"term.buffer":(yn=wl.current.get(g.id))==null||yn({kind:"buffer",data:g.data});break;case"term.data":(Ln=wl.current.get(g.id))==null||Ln({kind:"data",data:g.data});break;case"term.exit":pa(Ee=>Ee.map(De=>De.id===g.id?{...De,exitCode:g.exitCode}:De));break;case"term.closed":pa(Ee=>Ee.filter(De=>De.id!==g.id));break;case"mcp.list":g.sessionId===Kn.current&&dn(g.servers);break;case"plugin.list":if(g.sessionId!==Kn.current)break;Qt(g.plugins),Tn(g.marketplaces),sl(g.catalog);break;case"operation.result":g.sessionId===Kn.current&&bt(g.result);break;case"auth.status":W(g.status);break;case"relay.state":h(g.state);break;case"settings.state":we(g.settings);break;case"auth.login":ze(g.state),g.state.active&&$e(!0);break;case"session.closed":F(Ee=>Ee.map(De=>De.id===g.sessionId?{...De,state:"closed"}:De));break;case"error":console.error("[host]",g.message,g.context??""),(g.context==="workspace.open"||g.context==="workspace.create")&&(ai.current=null,wt(g.message)),(Fs=g.context)!=null&&Fs.startsWith("term.")&&kl(g.message);break}},[]),le=y.useCallback(g=>{var q;(q=s.current)==null||q.send(g)},[]);y.useEffect(()=>{G&&le({type:"session.list",workspaceId:G})},[G,le]),y.useEffect(()=>{l&&le({type:"session.pins"})},[l,le]),y.useEffect(()=>{l&&le({type:"settings.get"})},[l,le]),y.useEffect(()=>{if($i.current)return;const g=Vi.current;if(!g||!G)return;if(G!==g.workspaceId){$i.current=!0;return}if(D){$i.current=!0;return}if(M.length===0)return;const q=M.find(pe=>pw(pe,g));$i.current=!0,q&&di(q)},[M,G,D]),y.useEffect(()=>{!G||Xs||!us||le({type:"term.list",workspaceId:G})},[G,Xs,us,le]),y.useEffect(()=>{ni(g=>{var q;return g&&cs.some(pe=>pe.id===g)?g:((q=cs[0])==null?void 0:q.id)??null})},[cs]),y.useEffect(()=>{Me&&le({type:"workspace.roots"})},[Me,le]);const xa=y.useCallback(()=>{const g=Kn.current;g&&($l(!0),le({type:"usage.get",sessionId:g}),le({type:"context.get",sessionId:g}))},[le]);y.useEffect(()=>{if(!In)return;const g=window.setTimeout(()=>$l(!1),dw);return()=>window.clearTimeout(g)},[In]);const Jr=y.useMemo(()=>{const g=Math.max((st==null?void 0:st.fetchedAt)??0,(Pe==null?void 0:Pe.fetchedAt)??0);return g>0?g:null},[st==null?void 0:st.fetchedAt,Pe==null?void 0:Pe.fetchedAt]),mf="Обновить лимиты и контекст"+(Jr?`
|
|
131
|
+
обновлено в ${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${ow(o)}`,style:{width:`${o}%`}})}),i.jsxs("span",{className:"contextbar__pct",children:[o,"%"]})]})}function ow(s){return s>=cw?" contextbar__fill--over":s>=rw?" contextbar__fill--warn":""}const Cy="ccv:last-session",fw=300*1e3,dw=1e4;function hw(){try{const s=localStorage.getItem(Cy);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 pw(s,l){return s.id===l.sessionId?!0:l.claudeSessionId?s.id===l.claudeSessionId||s.claudeSessionId===l.claudeSessionId:!1}const mw={mcp:"mcp",plugins:"plugins",plugin:"plugins"},Nx=[{name:"login",description:"Войти в аккаунт Claude — окно приложения",argumentHint:"",aliases:["signin","вход"]},{name:"switch-account",description:"Сменить аккаунт: выйти и войти заново",argumentHint:"",aliases:["account","аккаунт"]},{name:"logout",description:"Выйти из аккаунта Claude",argumentHint:"",aliases:["signout","выход"]}],gw={active:!1,url:"",awaitingCode:!1,output:"",error:null};function Tx(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,p)=>Ex(h.name,d)-Ex(p.name,d))}}function Ex(s,l){return s.toLowerCase().startsWith(l)?0:1}function Ax(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 bw(){var ds;const s=y.useRef(null),[l,r]=y.useState(!1),[c,o]=y.useState("Нет связи с хостом"),[d,h]=y.useState(null),[p,m]=y.useState(!1),x=y.useMemo(()=>Ko()==="relay",[]),[_,j]=y.useState([]),[v,E]=y.useState([]),[k,O]=y.useState([]),[z,ee]=y.useState([]),[te,K]=y.useState([]),[M,F]=y.useState([]),[H,A]=y.useState([]),[Z,ae]=y.useState([]),[G,J]=y.useState(null),[D,ge]=y.useState(null),[Se,xe]=y.useState(null),[B,ue]=y.useState(Ol),[se,be]=y.useState(uh),[Ce,w]=y.useState(!1),[Q,re]=y.useState(!1),oe=uf("(max-width: 860px)"),[ye,je]=y.useState(!1);y.useEffect(()=>{oe||je(!1)},[oe]);const[Me,ht]=y.useState(!1),[lt,Nn]=y.useState([]),[Je,Kt]=y.useState(!1),[ct,rn]=y.useState(Ol),[Be,rt]=y.useState(null),[Hn,wt]=y.useState(null),[Ot,Ft]=y.useState([]),[tn,$t]=y.useState(null),[Nt,Qe]=y.useState(null),[We,dn]=y.useState([]),[Jt,Qt]=y.useState([]),[Bn,Tn]=y.useState([]),[hn,sl]=y.useState([]),[zt,bt]=y.useState(null),[Ut,$e]=y.useState(!1),[Qn,W]=y.useState(null),[de,we]=y.useState(null),[L,V]=y.useState(!1),[_e,ze]=y.useState(gw),[st,al]=y.useState(null),[Pe,En]=y.useState(null),[In,$l]=y.useState(!1),[da,,qs]=x0(),Ll=j0(),[qn,pl]=y.useState(!1),[nn,_l]=y.useState(null),[Gn,Ht]=y.useState(null),[Ze,ln]=y.useState(null),[is,An]=y.useState(null),[Cn,zl]=y.useState(null),[vl,ys]=y.useState(""),[It,Ql]=y.useState(null),[Zl,pn]=y.useState([]),[Tt,Yn]=y.useState(!1),[Gs,cn]=y.useState(null),[T,he]=y.useState(!1),[Ge,pt]=y.useState(!1),[un,ml]=y.useState({}),[il,mn]=y.useState([""]),[xt,rl]=y.useState([]),[ha,Sl]=y.useState(null),[ti,gl]=y.useState(null),[_s,Rn]=y.useState(null),[rs,vs]=y.useState(null),[Ss,jl]=y.useState(null),[me,N]=y.useState({}),[I,fe]=y.useState({}),[Ne,Oe]=y.useState(!1),[Ue,Et]=y.useState(null),[Wt,gn]=y.useState(null),Dt=y.useRef(0),bn=y.useRef(null),[Bt,js]=y.useState(!1),[cs,pa]=y.useState([]),[Kr,ni]=y.useState(null),[li,kl]=y.useState(null),ma=w0(),Ys=T0(oe&&Bt),wl=y.useRef(new Map),us=(de==null?void 0:de.terminalEnabled)===!0,Xs=Ko()==="relay"&&((ds=d==null?void 0:d.shell)==null?void 0:ds.enabled)!==!0,Gi=y.useRef(!1),Yi=y.useCallback((g,q)=>(wl.current.set(g,q),()=>{wl.current.get(g)===q&&wl.current.delete(g)}),[]),[Kl,Xi]=y.useState(!1),[Zn,Fl]=y.useState(null),[si,ks]=y.useState(Ol),[os,ga]=y.useState(null),[Vs,Ul]=y.useState({}),ws=y.useRef([]),[qt,Fr]=y.useState(null);function df(g){Fr(q=>q===g?null:g)}y.useEffect(()=>{(oe||qt==="terminal"&&!Bt||qt==="files"&&!Ge||qt==="search"&&!Ne||qt==="git"&&!qn||qt==="ask"&&!Kl||qt==="main"&&xt.length===0)&&Fr(null)},[qt,oe,Bt,Ge,Ne,qn,Kl,xt.length]);const[hf]=y.useState(hw),Vi=y.useRef(hf),$i=y.useRef(!1),Kn=y.useRef(null),xn=y.useRef(null),du=y.useRef(0);Kn.current=D,xn.current=G,du.current=B.lastSeq;const hu=y.useRef(se);hu.current=se;const Jl=y.useRef(null),pu=y.useRef(0);pu.current=si.lastSeq;const Qi=y.useRef(null),Zi=y.useRef(""),ai=y.useRef(null),fs=y.useRef([]),mu=y.useRef([""]);fs.current=xt,mu.current=il;const ii=y.useRef(new Map),Ki=y.useRef(new Set),ba=y.useRef(null),ri=y.useRef(null),gu=y.useRef(0),ci=y.useRef(new Set);y.useEffect(()=>{const g=d0();if(!g)return;s.current=g;const q=()=>{r(g.connected),o(g.statusText)};g.onStatus(q),g.onReconnect(()=>{q();const Pt=Kn.current;Pt&&g.send({type:"session.sync",sessionId:Pt,sinceSeq:du.current});const yn=Jl.current;yn&&g.send({type:"session.sync",sessionId:yn,sinceSeq:pu.current})});const pe=g.on(Pt=>pf(Pt));g.connect();const Ye=window.setInterval(()=>{q(),g.connected&&g.send({type:"ping",nonce:Date.now()})},15e3);return()=>{pe(),window.clearInterval(Ye),g.close()}},[]);const pf=y.useCallback(g=>{var q,pe,Ye,Pt,yn,Ln,Fs;switch(g.type){case"hello.ok":r(!0);break;case"workspace.list":{j(g.workspaces),E(g.archived),J(Ie=>{var zn;if(Ie)return Ie;const ut=Vi.current,dt=ut&&g.workspaces.find(gi=>gi.id===ut.workspaceId);return(dt==null?void 0:dt.id)??((zn=g.workspaces[0])==null?void 0:zn.id)??null});const Ee=ai.current;if(!Ee)break;const De=g.workspaces.find(Ie=>vw(Ie.path,Ee));if(!De)break;ai.current=null,ht(!1),J(De.id);break}case"workspace.candidates":if(g.query.trim()!==Zi.current)break;Nn(g.candidates),g.source==="host"&&Kt(!1);break;case"finder.opened":Qi.current=g.sessionId;break;case"workspace.roots":Ft(g.roots);break;case"workspace.created":if(J(g.workspace.id),g.warnings.length===0){ht(!1),wt(null);break}$t({path:g.workspace.path,warnings:g.warnings});break;case"session.list":if(g.workspaceId!==xn.current)break;F(g.sessions),A(g.archived);break;case"folder.list":O(g.workspaceFolders),ee(g.sessionFolders),K(g.pinnedFolders??[]);break;case"session.pinned":ae(g.sessions);break;case"session.summary":if(g.session.id===Qi.current){rt(g.session);break}if(g.session.parentSessionId){g.session.id===Jl.current&&ga(g.session);break}F(Ee=>{const De=Ee.findIndex(ut=>ut.id===g.session.id);if(De===-1)return[g.session,...Ee];const Ie=Ee.slice();return Ie[De]=g.session,Ie}),ae(Ee=>{const De=Ee.findIndex(ut=>ut.id===g.session.id);if(De===-1)return Ee;const Ie=Ee.slice();return Ie[De]={...g.session,pinned:!0,...Ee[De].pinnedAt?{pinnedAt:Ee[De].pinnedAt}:{}},Ie}),ge(Ee=>Ee??g.session.id);break;case"usage.state":g.sessionId===Kn.current&&(al(g.usage),$l(!1));break;case"context.state":g.sessionId===Kn.current&&(En(g.context),$l(!1));break;case"session.capabilities":g.sessionId===Kn.current&&xe(g.capabilities);break;case"session.events":if(g.sessionId===Jl.current){ks(Ee=>Fo(Ee,g.entries));break}if(g.sessionId===Qi.current){rn(Ee=>Fo(Ee,g.entries));break}if(g.sessionId!==Kn.current)break;for(const Ee of g.entries){if(Ee.event.kind!=="rewound")continue;const De=Ee.event.toUserIndex,Ie=g0(hu.current.entries,De),ut=Ie.reduce((dt,zn)=>zn.event.kind==="user.message"?dt+1:dt,0);be(dt=>({...dt,entries:Ie})),ue(dt=>({...dt,items:b0(dt.items,De,ut)}))}ue(Ee=>Fo(Ee,g.entries));break;case"session.history":if(g.sessionId!==Kn.current)break;be(Ee=>h0(Ee,g));break;case"side.opened":{if(g.parentSessionId!==Kn.current)break;Jl.current=g.sessionId,Fl(g.sessionId);const Ee=ws.current;ws.current=[];for(const De of Ee)De(g.sessionId);break}case"side.closed":if(g.parentSessionId!==Kn.current)break;Jl.current=null,Fl(null),ks(Ol),ga(null);break;case"git.state":if(g.workspaceId!==xn.current)break;_l(g.state);break;case"git.commit":if(g.workspaceId!==xn.current)break;Ht(g.detail);break;case"git.result":if(g.workspaceId!==xn.current)break;An({ok:g.ok,message:g.message,url:g.url}),g.ok&&(Ht(null),ln(null),Yn(!1),he(!1));break;case"git.busy":if(g.workspaceId!==xn.current)break;ys(g.label);break;case"git.files":if(g.workspaceId!==xn.current)break;cn({files:g.files,truncated:g.truncated});break;case"github.status":Ql(g.status);break;case"github.owners":pn(g.owners);break;case"fs.dir":if(g.workspaceId!==xn.current)break;ml(Ee=>({...Ee,[g.path]:g.entries}));break;case"fs.search":if(g.workspaceId!==xn.current)break;if(g.scope!=="tree"){const Ee=g.scope;fe(De=>({...De,[Ee]:{query:g.query,entries:g.entries}}));break}jl({query:g.query,entries:g.entries,truncated:g.truncated});break;case"fs.grep":if(g.workspaceId!==xn.current)break;Et({query:g.query,matches:g.matches,truncated:g.truncated});break;case"fs.file":{if(g.workspaceId!==xn.current)break;const Ee=Ki.current.delete(g.file.path);rl(Ie=>{const ut=Ie.findIndex(gi=>gi.path===g.file.path);if(ut===-1)return[...Ie,Fb(g.file,++gu.current)];const dt=Ie[ut],zn=Ie.slice();return zn[ut]=dt.saved===g.file.content&&!ca(dt)?{...dt,mtime:g.file.mtime,size:g.file.size,stale:!1}:Fb(g.file,++gu.current),zn}),Ee&&Sl(g.file.path);const De=bn.current;De&&De.path===g.file.path&&(bn.current=null,gn({...De,token:++Dt.current}));break}case"fs.media":{if(g.workspaceId!==xn.current)break;ci.current.delete(g.path),rl(Ee=>Ee.map(De=>De.path===g.path?{...De,mediaBase64:g.base64,mediaError:void 0}:De));break}case"fs.mediaFailed":{if(g.workspaceId!==xn.current)break;ci.current.delete(g.path),rl(Ee=>Ee.map(De=>De.path===g.path?{...De,mediaError:g.message}:De));break}case"fs.saved":{if(g.workspaceId!==xn.current)break;const Ee=ii.current.get(g.path);ii.current.delete(g.path);const De=Ee!==void 0;rl(ut=>ut.map(dt=>dt.path!==g.path?dt:De?{...dt,saved:Ee,mtime:g.mtime,size:g.size,stale:!1}:{...dt,stale:!0}));const Ie=fs.current.find(ut=>ut.path===g.path);!De&&Ie&&!ca(Ie)&&((q=s.current)==null||q.send({type:"fs.read",workspaceId:g.workspaceId,path:g.path})),(pe=s.current)==null||pe.send({type:"git.state",workspaceId:g.workspaceId});break}case"fs.result":{if(g.workspaceId!==xn.current)break;if(gl({ok:g.ok,message:g.message}),g.ok||ii.current.delete(g.path),g.conflict&&rl(De=>De.map(Ie=>Ie.path===g.path?{...Ie,stale:!0}:Ie)),ri.current===g.path){const De=ri.current;ri.current=null,g.ok&&(Ki.current.add(De),(Ye=s.current)==null||Ye.send({type:"fs.read",workspaceId:g.workspaceId,path:De}))}const Ee=ba.current;if(g.ok&&Ee&&Ee.to===g.path){ba.current=null;const De=Ie=>Ie===Ee.from?Ee.to:Ie.startsWith(`${Ee.from}/`)?Ee.to+Ie.slice(Ee.from.length):Ie;rl(Ie=>Ie.map(ut=>({...ut,path:De(ut.path)}))),Sl(Ie=>Ie===null?null:De(Ie)),mn(Ie=>Ie.map(De)),ml(Ie=>{const ut={};for(const[dt,zn]of Object.entries(Ie))dt===Ee.from||dt.startsWith(`${Ee.from}/`)||(ut[dt]=zn);return ut})}g.ok&&((Pt=s.current)==null||Pt.send({type:"git.state",workspaceId:g.workspaceId}));break}case"term.list":if(g.workspaceId!==xn.current)break;pa(g.terminals);break;case"term.opened":if(g.terminal.workspaceId!==xn.current)break;kl(null),pa(Ee=>{const De=Ee.findIndex(ut=>ut.id===g.terminal.id);if(De===-1)return[...Ee,g.terminal];const Ie=Ee.slice();return Ie[De]=g.terminal,Ie}),Gi.current&&(Gi.current=!1,ni(g.terminal.id));break;case"term.buffer":(yn=wl.current.get(g.id))==null||yn({kind:"buffer",data:g.data});break;case"term.data":(Ln=wl.current.get(g.id))==null||Ln({kind:"data",data:g.data});break;case"term.exit":pa(Ee=>Ee.map(De=>De.id===g.id?{...De,exitCode:g.exitCode}:De));break;case"term.closed":pa(Ee=>Ee.filter(De=>De.id!==g.id));break;case"mcp.list":g.sessionId===Kn.current&&dn(g.servers);break;case"plugin.list":if(g.sessionId!==Kn.current)break;Qt(g.plugins),Tn(g.marketplaces),sl(g.catalog);break;case"operation.result":g.sessionId===Kn.current&&bt(g.result);break;case"auth.status":W(g.status);break;case"relay.state":h(g.state);break;case"settings.state":we(g.settings);break;case"auth.login":ze(g.state),g.state.active&&$e(!0);break;case"session.closed":F(Ee=>Ee.map(De=>De.id===g.sessionId?{...De,state:"closed"}:De));break;case"error":console.error("[host]",g.message,g.context??""),(g.context==="workspace.open"||g.context==="workspace.create")&&(ai.current=null,wt(g.message)),(Fs=g.context)!=null&&Fs.startsWith("term.")&&kl(g.message);break}},[]),le=y.useCallback(g=>{var q;(q=s.current)==null||q.send(g)},[]);y.useEffect(()=>{G&&le({type:"session.list",workspaceId:G})},[G,le]),y.useEffect(()=>{l&&le({type:"session.pins"})},[l,le]),y.useEffect(()=>{l&&le({type:"settings.get"})},[l,le]),y.useEffect(()=>{if($i.current)return;const g=Vi.current;if(!g||!G)return;if(G!==g.workspaceId){$i.current=!0;return}if(D){$i.current=!0;return}if(M.length===0)return;const q=M.find(pe=>pw(pe,g));$i.current=!0,q&&di(q)},[M,G,D]),y.useEffect(()=>{!G||Xs||!us||le({type:"term.list",workspaceId:G})},[G,Xs,us,le]),y.useEffect(()=>{ni(g=>{var q;return g&&cs.some(pe=>pe.id===g)?g:((q=cs[0])==null?void 0:q.id)??null})},[cs]),y.useEffect(()=>{Me&&le({type:"workspace.roots"})},[Me,le]);const xa=y.useCallback(()=>{const g=Kn.current;g&&($l(!0),le({type:"usage.get",sessionId:g}),le({type:"context.get",sessionId:g}))},[le]);y.useEffect(()=>{if(!In)return;const g=window.setTimeout(()=>$l(!1),dw);return()=>window.clearTimeout(g)},[In]);const Jr=y.useMemo(()=>{const g=Math.max((st==null?void 0:st.fetchedAt)??0,(Pe==null?void 0:Pe.fetchedAt)??0);return g>0?g:null},[st==null?void 0:st.fetchedAt,Pe==null?void 0:Pe.fetchedAt]),mf="Обновить лимиты и контекст"+(Jr?`
|
|
132
132
|
обновлено в ${new Date(Jr).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:"");y.useEffect(()=>{if(En(null),!D)return;xa();const g=()=>{document.hidden||xa()},q=window.setInterval(g,fw),pe=()=>{document.hidden||xa()};return document.addEventListener("visibilitychange",pe),()=>{window.clearInterval(q),document.removeEventListener("visibilitychange",pe)}},[D,xa]),y.useEffect(()=>{if(!D){be(uh);return}be({...uh,loading:!0}),le({type:"session.history",sessionId:D})},[D,le]);const gf=y.useCallback(()=>{!D||se.loading||!db(se)||(be(g=>({...g,loading:!0})),le({type:"session.history",sessionId:D,before:zx(se)}))},[D,se,le]),Wr=y.useMemo(()=>p0(se.entries),[se.entries]),ke=y.useMemo(()=>M.find(g=>g.id===D)??null,[M,D]),ya=_.find(g=>g.id===G)??v.find(g=>g.id===G)??null;y.useEffect(()=>{if(!G||!D)return;const g={workspaceId:G,sessionId:D,claudeSessionId:(ke==null?void 0:ke.claudeSessionId)??null};try{localStorage.setItem(Cy,JSON.stringify(g))}catch{}},[G,D,ke==null?void 0:ke.claudeSessionId]);function bu(g){ai.current=g,wt(null),le({type:"workspace.open",path:g})}function xu(g,q,pe){wt(null),le({type:"workspace.create",parent:g,name:q,init:pe})}function yu(g){if(Zi.current=g,!g){Nn([]),Kt(!1);return}Kt(!0),le({type:"workspace.find",query:g})}function _u(g){Zi.current=g,rn(Ol),le({type:"workspace.find.agent",query:g})}function vu(){ht(!1),wt(null),$t(null),Nn([]),rn(Ol),rt(null),Zi.current="",ai.current=null}function Wl(){const g=Kn.current;g&&Jl.current&&le({type:"side.reset",sessionId:g}),Jl.current=null,Fl(null),ks(Ol),ga(null),Ul({}),ws.current=[]}function bf(g){le({type:"workspace.close",workspaceIds:g}),!(!G||!g.includes(G))&&(Wl(),J(null),ge(null),F([]),A([]),ue(Ol),xe(null),re(!1))}function xf(g,q){le({type:"session.archive",workspaceId:g,sessionIds:q}),D&&(q.includes(D)||ke!=null&&ke.claudeSessionId&&q.includes(ke.claudeSessionId))&&(Wl(),ge(null),ue(Ol),xe(null),re(!1))}function yf(g){le({type:"workspace.restore",workspaceIds:g})}function Su(g,q,pe){le({type:"folder.create",scope:g,name:q,workspaceId:pe})}function ju(g,q){le({type:"folder.rename",folderId:g,name:q})}function ui(g){le({type:"folder.delete",folderId:g})}function oi(g,q,pe,Ye){le({type:"folder.assign",scope:g,itemId:q,folderId:pe,workspaceId:Ye})}function _f(){G&&(Wl(),ge(null),xe(null),ue(Ol),re(!1),le({type:"session.start",workspaceId:G}),w(!1))}function fi(g){Wl(),er(),J(g),ge(null),ue(Ol),xe(null),re(!1),_l(null),Ht(null),ln(null),An(null),ys(""),Yn(!1),cn(null),he(!1),pa([]),ni(null)}function ku(g,q,pe){le({type:"session.pin",workspaceId:g,sessionIds:q,pinned:pe})}function wu(g){g.workspaceId!==G&&fi(g.workspaceId),di(g)}function di(g){if(w(!1),Wl(),ue(Ol),xe(null),re(!1),g.state==="closed"){ge(null),le({type:"session.start",workspaceId:g.workspaceId,resume:g.id});return}ge(g.id),le({type:"session.sync",sessionId:g.id,sinceSeq:0})}function Fi(g,q){le({type:"session.rename",sessionId:g.id,title:q,workspaceId:g.workspaceId}),F(pe=>pe.map(Ye=>Ye.id===g.id?{...Ye,title:q}:Ye))}function Pr(g){D&&(w(!1),bt(null),Qe(g),le({type:"mcp.list",sessionId:D}),le({type:"plugin.list",sessionId:D}))}const Nu={mcpAction:(g,q)=>{D&&(le({type:"mcp.action",sessionId:D,name:g,action:q}),Qe(null))},mcpAdd:(g,q)=>{D&&le({type:"mcp.add",sessionId:D,name:g,draft:q})},mcpRemove:g=>{D&&le({type:"mcp.remove",sessionId:D,name:g})},pluginInstall:g=>{D&&le({type:"plugin.install",sessionId:D,spec:g})},pluginUninstall:g=>{D&&le({type:"plugin.uninstall",sessionId:D,id:g})},pluginToggle:(g,q)=>{D&&le({type:"plugin.toggle",sessionId:D,id:g,enabled:q})},marketplaceAdd:g=>{D&&le({type:"marketplace.add",sessionId:D,source:g})},marketplaceRemove:g=>{D&&le({type:"marketplace.remove",sessionId:D,name:g})}};function ec(){w(!1),$e(!0),le({type:"auth.status"})}const tc={login:(g,q)=>le({type:"auth.login",mode:g,switchAccount:q}),submitCode:g=>le({type:"auth.code",code:g}),cancel:()=>le({type:"auth.cancel"}),logout:()=>le({type:"auth.logout"})};function vf(){w(!1),V(!0),le({type:"settings.get"})}function Sf(g){we(q=>q&&{...q,...g}),le({type:"settings.update",settings:g})}function jf(g){D&&le({type:"side.ask",sessionId:D,text:g})}function kf(){D&&(le({type:"side.reset",sessionId:D}),Jl.current=null,Fl(null),ks(Ol),ga(null),Ul({}),ws.current=[])}function Mn(g){const q=Jl.current;if(q){g(q);return}const pe=Kn.current;pe&&(ws.current.push(g),le({type:"side.open",sessionId:pe}))}function _a(){G&&le({type:"git.state",workspaceId:G})}function Tu(g){G&&(ln(g),le({type:"git.show",workspaceId:G,ref:g}))}function nc(g,q){An(null),zl({target:g,label:q})}function Eu(){!G||!Cn||(le({type:"git.checkout",workspaceId:G,target:Cn.target}),zl(null))}function Au(){G&&(An(null),le({type:"git.push",workspaceId:G}))}function lc(g){G&&(An(null),le({type:"git.pull",workspaceId:G,merge:g}))}function wf(){G&&(An(null),cn(null),Yn(!0),le({type:"github.status"}),le({type:"github.owners"}),le({type:"git.files",workspaceId:G}))}function va(g){G&&(An(null),le({type:"git.publish",workspaceId:G,...g}))}function sc(g){G&&(An(null),le({type:"git.remote",workspaceId:G,url:g}))}function hi(){An(null),he(!0)}function ac(g){le({type:"github.token",token:g}),le({type:"github.owners"})}function Cu(){le({type:"github.status"}),le({type:"github.owners"})}y.useEffect(()=>{if(!(!Ge||!G))for(const g of il)g in un||le({type:"fs.list",workspaceId:G,path:g})},[Ge,il,un,G,le]);function $s(g){mn(q=>q.includes(g)?q.filter(pe=>pe!==g):[...q,g])}function Sa(g){if(!g){jl(null);return}G&&le({type:"fs.search",workspaceId:G,query:g})}function ic(g){if(!g){Et(null);return}G&&le({type:"fs.grep",workspaceId:G,query:g})}const rc=y.useCallback((g,q)=>{N(Pt=>({...Pt,[g]:q}));const pe=xn.current;if(q===null||!pe)return;const Ye=q.lastIndexOf("/");if(Ye!==-1){le({type:"fs.list",workspaceId:pe,path:q.slice(0,Ye)});return}if(q===""){le({type:"fs.list",workspaceId:pe,path:""});return}le({type:"fs.search",workspaceId:pe,query:q,scope:g})},[le]),Qs=y.useMemo(()=>Tx(me.mention??null,I.mention??null,un),[me.mention,I.mention,un]),Ru=y.useMemo(()=>Tx(me.side??null,I.side??null,un),[me.side,I.side,un]);function Mu(g){cc(g.path,{line:g.line,column:g.column})}function Ou(g){const q=[];let pe=Ui(g.path);for(;q.push(pe),!!pe;)pe=Ui(pe);mn(Ye=>{const Pt=new Set(Ye);for(const yn of q)Pt.add(yn);return g.kind==="dir"&&Pt.add(g.path),[...Pt]}),g.kind==="file"&&cc(g.path)}function cc(g,q){if(fs.current.find(Ye=>Ye.path===g)){Sl(g),q&&gn({path:g,...q,token:++Dt.current});return}G&&(q&&(bn.current={path:g,...q}),Ki.current.add(g),le({type:"fs.read",workspaceId:G,path:g}))}function uc(g,q=!1){const pe=fs.current,Ye=pe.find(Ln=>Ln.path===g);if(Ye&&ca(Ye)&&!q){vs(g);return}vs(null);const Pt=pe.findIndex(Ln=>Ln.path===g),yn=pe.filter(Ln=>Ln.path!==g);rl(yn),Sl(Ln=>{var Fs;return Ln===g?((Fs=yn[Math.min(Pt,yn.length-1)])==null?void 0:Fs.path)??null:Ln})}function Ji(g,q=!1){const pe=fs.current.find(Ye=>Ye.path===g);!pe||!G||!q&&!ca(pe)||(ii.current.set(g,pe.text),le({type:"fs.write",workspaceId:G,path:g,content:pe.text,eol:pe.eol,encoding:pe.encoding,baseMtime:pe.mtime,...q?{force:!0}:{}}))}function Du(g){G&&le({type:"fs.read",workspaceId:G,path:g})}function Lu(g){G&&(ci.current.has(g)||(ci.current.add(g),le({type:"fs.readMedia",workspaceId:G,path:g})))}const oc=y.useRef(new Map);function Hl(g){const q=oc.current,pe=q.get(g);pe&&clearTimeout(pe);const Ye=(de==null?void 0:de.autoSaveAfterPauseMs)??0;Ye<=0||q.set(g,setTimeout(()=>{q.delete(g);const Pt=fs.current.find(yn=>yn.path===g);Pt&&ca(Pt)&&!Pt.stale&&Ji(g)},Ye))}function Wi(g,q,pe){if(!G)return;const Ye=g?`${g}/${pe}`:pe;gl(null),q==="file"&&(ri.current=Ye),le({type:"fs.create",workspaceId:G,path:Ye,kind:q})}function Nl(g,q){if(!G)return;const pe=Ui(g),Ye=pe?`${pe}/${q}`:q;gl(null),ba.current={from:g,to:Ye},le({type:"fs.rename",workspaceId:G,path:g,to:Ye})}function ja(g,q){if(!G)return;const pe=g.slice(g.lastIndexOf("/")+1),Ye=q?`${q}/${pe}`:pe;Ye!==g&&(gl(null),ba.current={from:g,to:Ye},le({type:"fs.rename",workspaceId:G,path:g,to:Ye}))}function fc(g,q){G&&(gl(null),le({type:"fs.copy",workspaceId:G,path:g,toDir:q}))}function Pi(g){G&&(gl(null),Rn(null),le({type:"fs.delete",workspaceId:G,path:g.path}),rl(q=>q.filter(pe=>pe.path!==g.path&&!pe.path.startsWith(`${g.path}/`))),Sl(q=>q&&(q===g.path||q.startsWith(`${g.path}/`))?null:q))}function er(){ml({}),mn([""]),rl([]),Sl(null),gl(null),jl(null),Et(null),N({}),fe({}),gn(null),Ki.current.clear(),ii.current.clear(),ci.current.clear(),bn.current=null,ba.current=null,ri.current=null}function dc(){!G||Xs||!us||(kl(null),Gi.current=!0,le({type:"term.open",workspaceId:G,cols:80,rows:24}))}function Zs(g){le({type:"term.close",id:g})}function zu(g,q){D&&le({type:"permission.respond",sessionId:D,requestId:g,decision:q})}function tr(g,q){D&&le({type:"permission.respond",sessionId:D,requestId:g,decision:"allow",answers:q})}function ka(g){D&&le({type:"permission.respond",sessionId:D,requestId:g,decision:"deny",reason:"Пользователь не стал отвечать на вопросы"})}function Nf(g,q){D&&le({type:"permission.respond",sessionId:D,requestId:g,decision:"allow",plan:q})}function bl(g){D&&le({type:"permission.respond",sessionId:D,requestId:g,decision:"deny",reason:"Пользователь просит продолжить планирование"})}y.useEffect(()=>{function g(q){if(q.key!=="Escape")return;if(qt!==null){const Ye=q.target;if(!(Ye instanceof HTMLElement&&Ye.closest(".termview, .editor, .sidepane"))){Fr(null);return}}if(!D||B.pending.length>0)return;const pe=q.target;pe instanceof HTMLElement&&pe.closest(".sidepane, .editor")||le({type:"control.interrupt",sessionId:D})}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[D,B.pending.length,le,qt]),y.useEffect(()=>{function g(q){q.key!=="`"||!(q.ctrlKey||q.metaKey)||us&&(q.preventDefault(),js(pe=>!pe))}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[us]);const nr=y.useMemo(()=>{const g=(Se==null?void 0:Se.commands)??[];return g.length===0?g:[...g,{name:"plugins",description:"Плагины и маркетплейсы — окно приложения",argumentHint:"",aliases:["plugin"]},...Nx]},[Se]);function Pl(g){const q=mw[g];return q?(Pr(q),!0):Nx.some(pe=>pe.name===g)?(ec(),g==="logout"&&tc.logout(),g==="switch-account"&&tc.login("claudeai",!0),!0):!1}const pi=(ke==null?void 0:ke.state)==="waiting_permission",cl=(ke==null?void 0:ke.state)==="reconnecting",On=(ke==null?void 0:ke.state)==="running"||cl||pi,Fn=B.pending[0]??null,hc=Fn?Oj(Fn.toolName,Fn.input):null;y.useEffect(()=>{!qn&&!Ge||!G||On||le({type:"git.state",workspaceId:G})},[qn,Ge,G,On,le]),y.useEffect(()=>{if(!(On||!G)){Ge&&ml(g=>{const q={};for(const[pe,Ye]of Object.entries(g))mu.current.includes(pe)||(q[pe]=Ye);return q});for(const g of fs.current)ca(g)||le({type:"fs.read",workspaceId:G,path:g.path})}},[On,G,Ge,le]);const mi=(ke==null?void 0:ke.cwd)??(Se==null?void 0:Se.cwd)??null,pc=(Se==null?void 0:Se.models)??[],Jn=(ke==null?void 0:ke.model)??(Se==null?void 0:Se.model)??null,{rows:Ks,selected:wa}=Ax(pc,Jn),Ns=os?{model:os.model,effort:os.effort,ultracode:os.ultracode,thinking:os.thinking,switchOnFlag:os.switchModelsOnFlag}:{model:Vs.model??Jn,effort:Vs.effort??(ke==null?void 0:ke.effort)??null,ultracode:Vs.ultracode??(ke==null?void 0:ke.ultracode)??!1,thinking:Vs.thinking??(ke==null?void 0:ke.thinking)??!0,switchOnFlag:Vs.switchOnFlag??(ke==null?void 0:ke.switchModelsOnFlag)??!0},Na=Ax(pc,Ns.model),Tl=(os==null?void 0:os.state)==="running",ul=ha?xt.find(g=>g.path===ha)??null:null,Ts=new Set(xt.filter(ca).map(g=>g.path)),ol=g=>i.jsx(Jk,{pane:g,width:Ll.widths[g],onResize:q=>Ll.setWidth(g,q),onReset:()=>Ll.reset(g)}),Wn=g=>oe?null:()=>df(g),es=Se&&i.jsx(Is,{title:"Режим прав",value:(ke==null?void 0:ke.permissionMode)??"default",options:Ux.map(g=>({value:g.value,label:g.value,hint:g.hint})),onChange:g=>{D&&le({type:"control.set_mode",sessionId:D,mode:g})}}),mc=Ks.length>0?i.jsx(jy,{models:Ks,value:wa,effort:(ke==null?void 0:ke.effort)??null,ultracode:(ke==null?void 0:ke.ultracode)??!1,thinking:(ke==null?void 0:ke.thinking)??!0,switchOnFlag:(ke==null?void 0:ke.switchModelsOnFlag)??!0,onModel:g=>{!D||!g||le({type:"control.set_model",sessionId:D,model:g})},onEffort:g=>{D&&le({type:"control.set_effort",sessionId:D,effort:g})},onUltracode:g=>{D&&le({type:"control.set_ultracode",sessionId:D,enabled:g})},onThinking:g=>{D&&le({type:"control.set_thinking",sessionId:D,enabled:g})},onSwitchOnFlag:g=>{D&&le({type:"control.set_flag_switch",sessionId:D,enabled:g})}}):Jn&&i.jsx("span",{className:"badge",children:Jn}),lr=On&&i.jsx("span",{className:pi?"badge badge--wait":"badge badge--live",children:pi?"ждёт":cl?"переподключается":"работает"}),sr=()=>{D&&le({type:"session.reconnect",sessionId:D})},Uu=cl?"Сессия уже поднимает новый процесс":On?"Недоступно, пока идёт ход":"Поднять сессии новый процесс — разговор сохранён",Dn=D&&(cl||(ke==null?void 0:ke.state)==="error")?i.jsxs("div",{className:cl?"relink":"relink relink--error",role:"status",children:[i.jsxs("span",{className:"relink__msg",children:[i.jsx("span",{className:"relink__dot","aria-hidden":"true"}),cl?"Связь оборвалась. Сессия поднимает новый процесс — разговор сохранён.":"Переподключиться не удалось. Разговор сохранён — сессия продолжит с этого места."]}),i.jsx("button",{className:"btn btn--sm",title:cl?"Не ждать паузы между попытками — попробовать сейчас":"Поднять сессии новый процесс и продолжить разговор",onClick:sr,children:cl?"Переподключить сейчас":"Переподключить"})]}):null,St=ke&&ke.totalCostUsd>0?`$${ke.totalCostUsd.toFixed(3)}`:null,et=i.jsx("button",{className:Kl?"pane-btn is-on":"pane-btn",title:"Вопрос на полях — спросить, не мешая работе","aria-label":"Вопрос на полях","aria-pressed":Kl,onClick:()=>Xi(g=>!g),children:i.jsx(jw,{})});return i.jsxs("div",{className:"app",style:Ll.style,children:[i.jsx(uS,{open:Ce,connected:l,status:c,workspaces:_,archivedWorkspaces:v,workspaceFolders:k,sessionFolders:z.filter(g=>g.workspaceId===G),pinnedFolders:te,sessions:M.filter(g=>g.workspaceId===G),archived:H.filter(g=>g.workspaceId===G),pinned:Z,activeWorkspaceId:G,activeSessionId:D,onPinSessions:ku,onSelectPinned:wu,onCloseWorkspaces:bf,onRestoreWorkspaces:yf,onArchiveSessions:xf,onUnarchiveSessions:g=>{G&&le({type:"session.unarchive",workspaceId:G,sessionIds:g})},onCreateFolder:Su,onRenameFolder:ju,onDeleteFolder:ui,onAssignToFolder:oi,onSelectWorkspace:fi,onSelectSession:di,onRenameSession:Fi,onOpenWorkspace:()=>ht(!0),onNewSession:_f,onOpenExtensions:D?()=>Pr("mcp"):null,account:Qn,onOpenAccount:ec,relay:d,onOpenRelay:x?null:()=>m(!0),onOpenSettings:vf,themeMode:da,onCycleTheme:qs}),ol("sidebar"),Ce&&i.jsx("div",{className:"scrim",onClick:()=>w(!1)}),i.jsx(M1,{open:Ge,tree:un,expanded:new Set(il),activePath:ha,dirty:Ts,gitChanges:(nn==null?void 0:nn.changed)??[],result:ti,searchResult:Ss,onSearch:Sa,onReveal:Ou,onToggle:$s,onOpen:cc,onCreate:Wi,onRename:Nl,onMove:ja,onCopy:fc,onDelete:Rn,onRefresh:()=>{gl(null),ml({}),_a()},onClose:()=>pt(!1),zoomed:qt==="files",onToggleZoom:Wn("files")}),Ge&&qt!=="files"&&ol("files"),i.jsx(G1,{open:Ne,result:Ue,onSearch:ic,onOpenMatch:Mu,onClose:()=>Oe(!1),zoomed:qt==="search",onToggleZoom:Wn("search")}),Ne&&qt!=="search"&&ol("search"),i.jsx(Zj,{open:qn,state:nn,result:is,selected:Ze,busy:vl,onRefresh:_a,onShow:Tu,onCheckout:nc,onPush:Au,onPull:lc,onPublish:wf,onConnectRemote:hi,onDismissResult:()=>An(null),onClose:()=>pl(!1),zoomed:qt==="git",onToggleZoom:Wn("git")}),qn&&qt!=="git"&&ol("git"),i.jsxs("main",{className:qt==="main"||qt==="terminal"?"main main--zoomed":"main",children:[i.jsxs("header",{className:"topbar",children:[i.jsx("button",{className:"btn btn--ghost menu-btn",onClick:()=>w(!0),children:"☰"}),i.jsx("button",{className:Ge?"pane-btn is-on":"pane-btn",title:"Файлы проекта","aria-label":"Файлы проекта","aria-pressed":Ge,onClick:()=>{pt(g=>!g),pl(!1),Oe(!1)},children:i.jsx(xw,{})}),i.jsx("button",{className:Ne?"pane-btn is-on":"pane-btn",title:"Поиск по тексту в проекте","aria-label":"Поиск по тексту в проекте","aria-pressed":Ne,onClick:()=>{Oe(g=>!g),pt(!1),pl(!1)},children:i.jsx(yw,{})}),i.jsx("button",{className:qn?"pane-btn is-on":"pane-btn",title:"История git","aria-label":"История git","aria-pressed":qn,onClick:()=>{pl(g=>!g),pt(!1),Oe(!1)},children:i.jsx(_w,{})}),us&&i.jsx("button",{className:Bt?"pane-btn is-on":"pane-btn",title:"Терминал (Ctrl+`)","aria-label":"Терминал","aria-pressed":Bt,onClick:()=>js(g=>!g),children:i.jsx(Sw,{})}),oe&&et,oe&&i.jsx("button",{className:ye?"pane-btn is-on":"pane-btn",title:"Ещё","aria-label":"Ещё","aria-haspopup":"menu","aria-pressed":ye,onClick:()=>je(!0),children:i.jsx(kw,{})}),i.jsxs("div",{className:"topbar__id",children:[Q&&ke?i.jsx(fa,{className:"rename--title",value:ke.title??"",onCommit:g=>{Fi(ke,g),re(!1)},onCancel:()=>re(!1)}):i.jsxs("div",{className:"topbar__head",children:[i.jsx("button",{className:"topbar__title",disabled:!ke||oe,title:ke&&!oe?"Переименовать сессию":void 0,onClick:()=>re(!0),children:(ke==null?void 0:ke.title)??"Claude Code Visual"}),ya&&i.jsx("span",{className:"topbar__project",title:ya.path,children:ya.name})]}),oe?lr:mi&&i.jsx(Sy,{path:mi})]}),!oe&&i.jsxs("div",{className:"topbar__tools",children:[i.jsx("button",{type:"button",className:In?"meters-refresh is-busy":"meters-refresh",title:mf,"aria-label":"Обновить лимиты и контекст","aria-busy":In,disabled:!D||In,onClick:xa,children:i.jsx(ww,{})}),i.jsx(wy,{usage:st}),i.jsx(Ay,{}),es,mc,lr,St&&i.jsx("span",{className:"badge badge--cost",children:St}),et]})]}),i.jsx(uw,{tokens:(Pe==null?void 0:Pe.tokens)??B.contextTokens,maxTokens:(Pe==null?void 0:Pe.maxTokens)??null,fetchedAt:(Pe==null?void 0:Pe.fetchedAt)??null}),oe&&ye&&i.jsx(kk,{onClose:()=>je(!1),permission:es,model:mc,usage:st,cwd:mi,costLabel:St,onRefresh:xa,refreshing:In,metersFetchedAt:Jr,onRename:ke?()=>{re(!0),je(!1)}:null}),xt.length>0&&i.jsx(rS,{files:xt,activePath:ha,busy:On,onSelect:Sl,onClose:g=>uc(g),zoomed:qt==="main",onToggleZoom:Wn("main")}),ul?i.jsx(aS,{file:ul,goto:(Wt==null?void 0:Wt.path)===ul.path?Wt:null,onChange:(g,q)=>{rl(pe=>pe.map(Ye=>Ye.path===g?{...Ye,text:q}:Ye)),Hl(g)},onSave:g=>Ji(g),onReload:Du,onOverwrite:g=>Ji(g,!0),onRequestMedia:Lu,onTogglePreview:g=>rl(q=>q.map(pe=>pe.path===g?{...pe,previewMode:!pe.previewMode}:pe))}):i.jsxs(i.Fragment,{children:[i.jsx(ap,{items:B.items,busy:On&&!cl,waiting:pi,history:Wr,historyHasMore:db(se),historyLoading:se.loading,onLoadHistory:gf,sessionId:D??void 0,onEditMessage:(g,q,pe)=>{D&&le({type:"prompt.edit",sessionId:D,userIndex:g,text:q,images:pe})}}),Dn,i.jsx(_y,{disabled:!D,busy:On&&!cl,placeholder:cl?"Промпт уйдёт, как только связь вернётся":void 0,commands:nr,sessionTitle:(ke==null?void 0:ke.title)??null,contextResult:Qs,draftKey:D,onContextSearch:g=>rc("mention",g),onCommand:Pl,onSend:(g,q)=>{D&&le({type:"prompt.send",sessionId:D,text:g,images:q})},onInterrupt:()=>{D&&le({type:"control.interrupt",sessionId:D})}})]}),Bt&&us&&i.jsxs(i.Fragment,{children:[!oe&&qt!=="terminal"&&i.jsx(Pk,{height:ma.height,onResize:ma.setHeight,onReset:ma.reset}),i.jsx(lw,{mobile:oe,zoomed:qt==="terminal",onToggleZoom:Wn("terminal"),terminals:cs,activeId:Kr,blocked:Xs,error:li,onDismissError:()=>kl(null),height:oe?Ys.height:ma.height,offset:oe?{top:Ys.offsetTop,left:Ys.offsetLeft}:void 0,onSelect:ni,onOpen:dc,onClose:Zs,onInput:(g,q)=>le({type:"term.input",id:g,data:q}),onResize:(g,q,pe)=>le({type:"term.resize",id:g,cols:q,rows:pe}),onAttach:g=>le({type:"term.attach",id:g}),onHide:()=>js(!1),registerSink:Yi})]})]}),i.jsx(mk,{open:Kl,items:si.items,busy:Tl,ready:D!==null,commands:nr,contextResult:Ru,draftKey:D,models:Na.rows,model:Na.selected,effort:Ns.effort,ultracode:Ns.ultracode,thinking:Ns.thinking,switchOnFlag:Ns.switchOnFlag,onContextSearch:g=>rc("side",g),onCommand:Pl,onModel:g=>{g&&(Ul(q=>({...q,model:g})),Mn(q=>le({type:"control.set_model",sessionId:q,model:g})))},onEffort:g=>{Ul(q=>({...q,effort:g,ultracode:!1})),Mn(q=>le({type:"control.set_effort",sessionId:q,effort:g}))},onUltracode:g=>{Ul(q=>({...q,ultracode:g,...g?{effort:"xhigh"}:{}})),Mn(q=>le({type:"control.set_ultracode",sessionId:q,enabled:g}))},onThinking:g=>{Ul(q=>({...q,thinking:g})),Mn(q=>le({type:"control.set_thinking",sessionId:q,enabled:g}))},onSwitchOnFlag:g=>{Ul(q=>({...q,switchOnFlag:g})),Mn(q=>le({type:"control.set_flag_switch",sessionId:q,enabled:g}))},onAsk:jf,onInterrupt:()=>{Zn&&le({type:"control.interrupt",sessionId:Zn})},onReset:kf,onClose:()=>Xi(!1),zoomed:qt==="ask",onToggleZoom:Wn("ask")}),Kl&&qt!=="ask"&&ol("ask"),(qn||Kl||Ge||Ne)&&i.jsx("div",{className:"scrim scrim--pane",onClick:()=>{pl(!1),Xi(!1),pt(!1),Oe(!1)}}),Gn&&i.jsx(Jj,{detail:Gn,local:((nn==null?void 0:nn.hasRemote)??!1)&&(nn==null?void 0:nn.commits.some(g=>g.hash===Gn.hash&&!g.pushed))===!0,onCheckout:nc,onClose:()=>{Ht(null),ln(null)}}),Cn&&i.jsxs(Vl,{title:"Переключить рабочее дерево?",onClose:()=>zl(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>zl(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:Eu,children:"Переключиться"})]}),children:[i.jsxs("p",{className:"modal__text",children:["git переключится на ",Cn.label,". Файлы в каталоге проекта изменятся — это тот же каталог, в котором работает агент."]}),On&&i.jsx("p",{className:"modal__text",children:"Сейчас идёт ход агента: он читает и правит файлы прямо сейчас."}),nn&&nn.changed.length>0&&i.jsxs("p",{className:"modal__text",children:["Незакоммиченных изменений: ",nn.changed.length,". Git откажется переключаться, если они будут затёрты."]})]}),Tt&&i.jsx(uk,{status:It,owners:Zl,files:Gs,defaultName:(ya==null?void 0:ya.name)??"",hasCommits:nn===null||nn.head!=="",busy:vl,result:is,onRefreshStatus:Cu,onSaveToken:ac,onPublish:va,onDismissResult:()=>An(null),onClose:()=>Yn(!1)}),T&&i.jsx(pk,{busy:vl,result:is,onSubmit:sc,onDismissResult:()=>An(null),onClose:()=>he(!1)}),_s&&i.jsx(Vl,{title:_s.kind==="dir"?"Удалить каталог?":"Удалить файл?",onClose:()=>Rn(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>Rn(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:()=>Pi(_s),children:"Удалить"})]}),children:i.jsxs("p",{className:"modal__text",children:[_s.path," будет удалён с диска",_s.kind==="dir"?" вместе со всем содержимым":"",". Корзины здесь нет: это тот же каталог, в котором работает агент."]})}),rs&&i.jsx(Vl,{title:"Закрыть без сохранения?",onClose:()=>vs(null),actions:i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"btn",onClick:()=>vs(null),children:"Отмена"}),i.jsx("button",{className:"btn btn--warn",onClick:()=>uc(rs,!0),children:"Закрыть"}),i.jsx("button",{className:"btn btn--primary",onClick:()=>{Ji(rs),uc(rs,!0)},children:"Сохранить и закрыть"})]}),children:i.jsxs("p",{className:"modal__text",children:["В ",rs," есть несохранённые правки."]})}),Nt&&i.jsx(Nk,{tab:Nt,servers:We,plugins:Jt,marketplaces:Bn,catalog:hn,result:zt,actions:Nu,onTab:Qe,onClose:()=>Qe(null)}),Ut&&i.jsx(Dk,{status:Qn,login:_e,actions:tc,remote:x,runningSessions:M.filter(g=>g.state==="running"||g.state==="waiting_permission").length,onReconnect:D?()=>{sr(),$e(!1)}:null,reconnectBlocked:On,reconnectHint:Uu,onClose:()=>$e(!1)}),p&&i.jsx(Bk,{state:d,onPair:(g,q)=>le({type:"relay.pair",code:g,...q?{name:q}:{}}),onUnpair:()=>le({type:"relay.unpair"}),onClose:()=>m(!1)}),L&&i.jsx(Kk,{settings:de,models:(Se==null?void 0:Se.models)??[],relayState:d,local:Ko()==="local",onChange:Sf,onEnableShell:()=>le({type:"relay.shell.enable"}),onDisableShell:()=>le({type:"relay.shell.disable"}),onOpenRelay:()=>{V(!1),m(!0)},onClose:()=>V(!1)}),Me&&i.jsx(Uj,{candidates:lt,searching:Je,agentItems:ct.items,agentBusy:(Be==null?void 0:Be.state)==="running",error:Hn,roots:Ot,created:tn,onSearch:yu,onAskAgent:_u,onInterrupt:()=>{const g=Qi.current;g&&le({type:"control.interrupt",sessionId:g})},onSubmit:bu,onCreate:xu,onClose:vu}),Fn!=null&&Fn.questions&&Fn.questions.length>0?i.jsx(Tj,{request:{...Fn,questions:Fn.questions},queued:B.pending.length-1,onAnswer:tr,onDecline:ka}):Fn&&hc!==null?i.jsx(Cj,{request:Fn,plan:hc,queued:B.pending.length-1,onAccept:Nf,onDecline:bl}):Fn&&i.jsx(Nj,{request:Fn,queued:B.pending.length-1,onDecide:zu})]})}function xw(){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 yw(){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 _w(){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 vw(s,l){return Cx(s)===Cx(l)}function Cx(s){return s.replace(/[\\/]+/g,"/").replace(/\/+$/,"").toLowerCase()}function Sw(){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 jw(){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 kw(){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 ww(){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 Ry=document.getElementById("root");if(!Ry)throw new Error("#root not found");a0.createRoot(Ry).render(i.jsx(y.StrictMode,{children:i.jsx(bw,{})}));export{Fv as D,Yt as I,Vt as N,Ew as P,ss as T,xs as a,ey as b,Dl as c,Tw as d,ay as e,cu as f,m1 as h,Aw as p,Cw as s,Te as t};
|