stackthread 0.1.0.dev2__py3-none-any.whl → 0.1.0.dev3__py3-none-any.whl
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.
- stackthread/__init__.py +1 -1
- stackthread/lang/python/extract.py +494 -494
- stackthread/lineage.py +965 -965
- stackthread/static/app.js +1 -1
- stackthread-0.1.0.dev3.dist-info/METADATA +532 -0
- {stackthread-0.1.0.dev2.dist-info → stackthread-0.1.0.dev3.dist-info}/RECORD +9 -9
- stackthread-0.1.0.dev2.dist-info/METADATA +0 -51
- {stackthread-0.1.0.dev2.dist-info → stackthread-0.1.0.dev3.dist-info}/WHEEL +0 -0
- {stackthread-0.1.0.dev2.dist-info → stackthread-0.1.0.dev3.dist-info}/entry_points.txt +0 -0
- {stackthread-0.1.0.dev2.dist-info → stackthread-0.1.0.dev3.dist-info}/licenses/LICENSE +0 -0
stackthread/static/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var V,Yl,yO,Xt,Ps,ir,Vl,Jn,Il,_s,Ts,vO,hn=Symbol.for("pv"),nr={},rr=[],QO=/^m(i|n|o|s|text|space)$/,Cs=Array.isArray,Bl=rr.slice,Ft=Object.assign;function Nt(i){i&&i.parentNode&&i.remove()}function Kn(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:hn,__v:r||++Yl,__i:-1,__u:0};return!r&&V.vnode&&V.vnode(s),s}function fe(i){return i.children}function er(i,e){this.props=i,this.context=e,this.__g=0}function Zt(i,e){if(e==null)return i.__&&Zt(i.__,i.__i+1);for(var t;e<i.__k.length;e++)if((t=i.__k[e])&&t.__e)return t.__e;return typeof i.type!="function"||i.props.__P?null:Zt(i)}function xO(i){var e,t=i.__v,n=t.__e,r=[],s=[],o=i.__P;o&&((e=Ft({constructor:hn},t)).__v=t.__v+1,V.vnode&&V.vnode(e),Xs(o,e,t,i.__n,o.namespaceURI,32&t.__u?[n]:null,r,n||Zt(t),32&t.__u,s),e.__v=t.__v,e.__.__k[e.__i]=e,Kl(r,e,s),t.__=t.__e=null,e.__e!=n&&Gl(e))}function Gl(i){if((i=i.__)&&i.__c&&!i.props.__P)return i.__e=null,i.__k.some(function(e){return e&&(i.__e=e.__e)}),Gl(i)}function Ul(i){(8&i.__g||(i.__g|=8,Xt.push(i),ir++))&&Ps==V.debounceRendering||((Ps=V.debounceRendering)||queueMicrotask)(Nl)}function Nl(){try{for(var i,e=1;Xt.length;)Xt.length>e&&Xt.sort(Vl),i=Xt.shift(),e=Xt.length,8&i.__g&&xO(i)}finally{(ir=Xt.length)&&(Ps||queueMicrotask)(Nl)}}function Fl(i,e,t,n,r,s,o,a,l,h,c){var f,d,O,p,g,b,y=n.__k||rr,Q=e.length;for(l=SO(t,e,y,l,Q),f=0;f<Q;f++)(O=t.__k[f])!=null&&(d=~O.__i&&y[O.__i]||nr,O.__i=f,b=Xs(i,O,d,r,s,o,a,l,h,c),p=O.__e,(d.ref!=O.ref||8&d.__u)&&(d.ref&&Zs(d.ref,null,O,d),O.ref&&c.push(O.ref,O.__c||p,O)),g=g||p,4&O.__u?(l=Hl(O,l,i,!d.__v),d.__e&&(d.__e=null)):typeof O.type=="function"&&b!==void 0?l=b:p&&(l=p.nextSibling),O.__u&=-21);return t.__e=g,l}function SO(i,e,t,n,r){var s,o,a,l,h,c,f,d,O,p=t.length,g=p,b=0,y=0,Q=i.__k=Array(r);for(s=0;s<r;s++)(o=e[s])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o!="object"||o.constructor===String?o=Q[s]=Kn(null,o):Cs(o)?o=Q[s]=Kn(fe,{children:o}):o.constructor===hn&&o.__b?o=Q[s]=Kn(o.type,o.props,o.key,o.ref,o.__v):Q[s]=o,l=s+b,o.__=i,o.__b=i.__b+1,a=null,~(h=o.__i=kO(o,t,l,g))&&(g--,(a=t[h])&&(a.__u|=2)),a&&a.__v?(o.__u|=16,h==l-1?b--:h==l+1?b++:h!=l&&(h>l?b--:b++,y=1)):(~h||(r>p?b--:r<p&&b++),typeof o.type!="function"&&(o.__u|=4))):Q[s]=null;if(y){for(c=[],f=[],s=0;s<r;s++)if((o=Q[s])&&16&o.__u){for(b=0,d=c.length;b<d;)c[O=b+d>>1]<o.__i?b=O+1:d=O;c[b]=o.__i,f[s]=b+1}for(b=c.length;s--;)f[s]&&(f[s]==b?b--:Q[s].__u|=4)}if(g)for(s=0;s<p;s++)!(a=t[s])||2&a.__u||(a.__e==n&&(n=Zt(a)),Rs(a,a));return n}function Hl(i,e,t,n){var r,s,o,a;if(typeof i.type=="function"){if(i.props.__P)return e;if(r=i.__k)for(s=0;s<r.length;s++)r[s]&&(r[s].__=i,e=Hl(r[s],e,t,!1));return e}for(e&&!e.parentNode&&(e=Zt(i))&&!e.parentNode&&(e=null),o=i.__e,a=e;a&&a.nodeType==8;)a=a.nextSibling;for(o!=a&&(!n&&t.moveBefore&&o.parentNode?t.moveBefore(o,e):t.insertBefore(o,e||null)),e=o;(e=e&&e.nextSibling)&&e.nodeType==8&&!e.data.startsWith("$s"););return e}function kO(i,e,t,n){var r,s=i.key,o=i.type,a=e[t],l=a&&!(2&a.__u);if(a===null&&s==null||l&&s==a.key&&o==a.type)return t;if(n>(l?1:0)){for(r=t-1;r>=0;r--)if((a=e[r])&&!(2&a.__u)&&s==a.key&&o==a.type)return r;for(r=t+1;r<e.length;r++)if((a=e[r])&&!(2&a.__u)&&s==a.key&&o==a.type)return r}return-1}function Dl(i,e,t){t==null&&(t=""),e[0]=="-"?i.setProperty(e,t):i[e]=t}function Hn(i,e,t,n,r){var s,o;if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||Dl(i.style,e);if(t)for(e in t)n&&t[e]==n[e]||Dl(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")typeof t!="function"&&(t=null),typeof n!="function"&&(n=null),(i.__e||(i.__e={}))[e]=t,t&&n||(o=Ts[e]||(Ts[e]=wO(e)),(i.__a||(i.__a={}))[e]=_s,s=e!=(e=e.replace(Il,"$1")),(e=e.slice(2))[0]<"a"&&(e=e.toLowerCase()),t?i.addEventListener(e,o,s):i.removeEventListener(e,o,s));else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{return void(i[e]=t??"")}catch{}if(typeof t=="function")return;t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t)}}function wO(i){return function(e){var t=this.__e;if(t){if(t=t[i],e[Jn]==null)e[Jn]=_s++;else if(e[Jn]<this.__a[i])return;return t(V.event?V.event(e):e)}}}function Xs(i,e,t,n,r,s,o,a,l,h){var c,f,d,O,p,g,b,y,Q,v,k,x,w,$,q,W,L,A,X=e.type;if(e.constructor!==hn)return null;128&t.__u&&(l=32&t.__u,c=t.__c.__z)&&(e.__u|=l,f=s=[],c.nodeType==8?a=tr(c,s):s.push(c),a=s[0]||a),(c=V.__b)&&c(e);e:if(typeof X=="function"){d=o.length;try{if(y=e.props,Q=(c=X.prototype)&&c.render,v=(c=X.contextType)&&n[c.__c],k=c?v?v.props.value:c.__:n,(O=t.__c)?(e.__c=O,2&O.__g&&(O.__g|=1)):(Q?e.__c=O=new X(y,k):(e.__c=O=new er(y,k),O.constructor=X,O.render=PO),v&&v.sub(O),O.state||(O.state={}),O.__n=n,O.__g|=8,O.__h=[],O.__k=[]),Q&&(O.__s||(O.__s=O.state),X.getDerivedStateFromProps&&(O.__s==O.state&&(O.__s=Ft({},O.__s)),Ft(O.__s,X.getDerivedStateFromProps(y,O.__s)))),p=O.props,g=O.state,O.__v=e,t.__c){if(y!==p&&Q&&!X.getDerivedStateFromProps&&O.componentWillReceiveProps&&O.componentWillReceiveProps(y,k),e.__v==t.__v&&!(8&O.__g)||!(4&O.__g)&&O.shouldComponentUpdate&&O.shouldComponentUpdate(y,O.__s,k)===!1){e.__v!=t.__v&&(O.props=y,O.state=O.__s,O.__g&=-9),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(E){E&&(E.__=e)}),rr.push.apply(O.__h,O.__k),O.__k=[],O.__h.length&&o.push(O),a=Zt(t);break e}O.componentWillUpdate&&O.componentWillUpdate(y,O.__s,k),Q&&O.componentDidUpdate&&O.__h.push(function(){O.componentDidUpdate(p,g,b)})}else Q&&!X.getDerivedStateFromProps&&O.componentWillMount&&O.componentWillMount(),Q&&O.componentDidMount&&O.__h.push(O.componentDidMount);O.context=k,O.props=y,O.__P=i,O.__g&=-5,x=V.__r,w=Q?25:0;do O.__g&=-9,x&&x(e),c=O.render(O.props,O.state=O.__s,O.context);while(8&O.__g&&++w<25);Q&&(rr.push.apply(O.__h,O.__k),O.__k=[]),O.state=O.__s,O.getChildContext&&(n=Ft({},n,O.getChildContext())),Q&&t.__c&&O.getSnapshotBeforeUpdate&&(b=O.getSnapshotBeforeUpdate(p,g)),$=c&&c.type===fe&&c.key==null?c.props.children:c,y.__P&&(c=a,r=(i=y.__P).namespaceURI,l=s=null,t.props&&t.props.__P!=i&&(t.__k.some(function(E){E&&Rs(E,E)}),t.__k=null),a=t.__k?Zt(t,0):null),a=Fl(i,Cs($)?$:[$],e,t,n,r,s,o,a,l,h),y.__P&&(e.__e=null,a=c),e.__u&=-161,f&&f.some(Nt),O.__h.length&&o.push(O),1&O.__g&&(O.__g&=-4)}catch(E){if(o.length=d,e.__v=null,l||s)if(E&&E.then){if(e.__u|=128|l,s){for(~(L=s.indexOf(a||void 0))||(L=s.length);(A=s[L-1])&&A.nodeType==8;)L--;for(;L<s.length;L++)if(A=s[L])if(s[L]=null,q){if(A==W)break}else{if(A.nodeType!=8)break;A.data.startsWith("$s")&&(W=tr(q=A))}}if(!q){for(;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;q=a}(c=tr(q=e.__c.__z||(e.__c.__z=q)))?(e.__e=q,a=c):e.__e=a,a=a&&a.nextSibling}else s&&s.some(Nt);else e.__e=t.__e;e.__k||(e.__k=t.__k||[]),E&&E.then||Jl(e),V.__e(E,e,t)}}else a=e.__e=$O(t.__e,e,t,n,r,s,o,l,h,i);return(c=V.diffed)&&c(e),a}function tr(i,e){if(i&&i.nodeType==8&&i.data.startsWith("$s"))for(var t=1;i=i.nextSibling;){if(i.nodeType==8){if(i.data.startsWith("$s"))t++;else if(i.data.startsWith("/$s")&&!--t)return i}e&&e.push(i)}}function Jl(i){i&&(i.__c&&(i.__c.__g|=4),i.__k&&i.__k.some(Jl))}function Kl(i,e,t){for(var n=0;n<t.length;)Zs(t[n++],t[n++],t[n++]);V.__c&&V.__c(e,i),i.some(function(r){try{i=r.__h,r.__h=[],i.some(function(s){s.call(r)})}catch(s){V.__e(s,r.__v)}})}function $O(i,e,t,n,r,s,o,a,l,h){var c,f,d,O,p,g,b,y,Q=t.props||nr,v=e.props,k=e.type;if(k=="svg"?r="http://www.w3.org/2000/svg":k=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s){for(c=0;c<s.length;c++)if((p=s[c])&&(k?p.localName==k:p.nodeType==3)){i=p,s[c]=null;break}}if(!i){if(y=h.ownerDocument||document,!k)return y.createTextNode(v);i=y.createElementNS(r,k,v.is?v:h),a&&(V.__m&&V.__m(e,s),a=!1),s=null}if(k){if(h=k=="template"&&i.content||i,s=k=="textarea"&&v.defaultValue!=null?null:s&&Bl.call(h.childNodes),!a&&s)for(Q={},c=0;c<i.attributes.length;c++)Q[(p=i.attributes[c]).name]=p.value;for(c in Q)p=Q[c],c=="dangerouslySetInnerHTML"?d=p:c=="children"||c in v||c=="value"&&"defaultValue"in v||c=="checked"&&"defaultChecked"in v||Hn(i,c,null,p,r);for(c in v)p=v[c],c=="children"?O=p:c=="dangerouslySetInnerHTML"?f=p:c=="value"?g=p:c=="checked"?b=p:a&&typeof p!="function"||Q[c]===p||Hn(i,c,p,Q[c],r);f?(a||d&&(f.__html==d.__html||f.__html==i.innerHTML)||(i.innerHTML=f.__html),e.__k=[]):(d&&(i.textContent=""),(k=="foreignObject"||r=="http://www.w3.org/1998/Math/MathML"&&QO.test(k))&&(r="http://www.w3.org/1999/xhtml"),Fl(h,Cs(O)?O:[O],e,t,n,r,s,o,s?s[0]:t.__k&&Zt(t,0),a,l),s&&s.some(Nt)),a&&k!="textarea"||(c="value",k=="progress"&&g==null?i.removeAttribute(c):g==null||g===i[c]&&(k!="progress"||g)||Hn(i,c,g,Q[c],r),c="checked",b!=null&&b!=i[c]&&Hn(i,c,b,Q[c],r))}else Q===v||a&&i.data==v||(i.data=v);return i}function Zs(i,e,t,n){try{typeof i=="function"?e?e.__x=i(e)||1:n&&(n=n.__c||n.__e)&&(e=n.__x)&&(n.__x=null,typeof e=="function"?e():i(null)):i.current=e}catch(r){V.__e(r,t)}}function Rs(i,e,t){var n,r,s,o;if(V.unmount&&V.unmount(i),!(n=i.ref)||n.current&&n.current!=i.__e||Zs(n,null,e,i),n=i.__c){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(a){V.__e(a,e)}n.__P=n.__n=null}if(n=i.__k)for(o=0;o<n.length;o++)n[o]&&Rs(n[o],e,typeof i.type!="function"||t&&!i.props.__P);!t&&(n=i.__c)&&(n=n.__z)&&(r=tr(n,s=[]))&&(n==i.__e&&s.some(Nt),Nt(r),Nt(n)),t||Nt(i.__e),i.__e=i.__c=i.__=null}function PO(i,e,t){return this.constructor(i,t)}function eh(i,e){var t,n,r,s;V.__&&V.__(i,e),e.nodeType==9&&(e=e.documentElement),n=(t=i&&32&i.__u)?null:e.__k,e.__k=Kn(fe,{children:[i]}),r=[],s=[],Xs(e,e.__k,n||nr,nr,e.namespaceURI,n?null:e.firstChild?Bl.call(e.childNodes):null,r,n?n.__e:e.firstChild,t,s),Kl(r,e.__k,s),e.__k.props.children=null}V={__e:function(i,e,t,n){for(var r,s,o;e=e.__;)if((r=e.__c)&&!(1&r.__g)){r.__g|=4;try{if((o=(s=r.constructor)&&s.getDerivedStateFromError)&&r.setState(s.getDerivedStateFromError(i)),r.componentDidCatch&&(r.componentDidCatch(i,n||{}),o=1),o&&8&r.__g)return void(r.__g|=2)}catch(a){i=a}}throw ir=0,i}},Yl=0,yO=function(i){return i!=null&&i.constructor===hn},er.prototype.setState=function(i,e){var t=this.__s;t&&t!=this.state||(t=this.__s=Ft({},this.state)),typeof i=="function"&&(i=i(Ft({},t),this.props)),i&&(Ft(t,i),this.__v&&(e&&this.__k.push(e),Ul(this)))},er.prototype.forceUpdate=function(i){this.__v&&(this.__g|=4,i&&this.__h.push(i),Ul(this))},er.prototype.render=fe,Xt=[],ir=0,Vl=function(i,e){return i.__v.__b-e.__v.__b},Jn=Symbol(),Il=/(PointerCapture)$|Capture$/i,_s=0,Ts={},vO=0;var xi,ne,As,th,Ms=Object.is,sr=0,ch=[],Es=[],te=V,ih=te.__b,nh=te.__r,rh=te.diffed,sh=te.__c,oh=te.unmount,ah=te.__;function or(i,e){te.__h&&te.__h(ne,i,sr||e),sr=0;var t=ne.__H||(ne.__H={__:[],__h:[]});return i>=t.__.length&&t.__.push({}),t.__[i]}function oe(i){return sr=1,TO(dh,i)}function TO(i,e,t){var n=or(xi++,2);if(n.t=i,!n.__c&&(n.__=[t?t(e):dh(void 0,e),function(s){var o=(n.__N||n.__)[0],a=n.t(o,s);Ms(o,a)||(n.__N=[a,n.__[1]],n.__c.setState({}))}],n.__c=ne,!ne.__f)){ne.__f=!0;var r=ne.shouldComponentUpdate;ne.shouldComponentUpdate=function(s,o,a){var l=this.__H;if(!l)return!0;var h=!1,c=this.props!=s;if(l.__.some(function(d){d.__N&&(h=!0,Ms(d.__[0],d.__N[0])||(c=!0))}),r){var f=r.call(this,s,o,a);return h?f||c:f}return!h||c}}return n.__}function ee(i,e){var t=or(xi++,3);!te.__s&&Ws(t.__H,e)&&(t.__P=!0,t.__=i,t.u=e,ne.__H.__h.push(t))}function fh(i,e){var t=or(xi++,4);!te.__s&&Ws(t.__H,e)&&(t.__P=!1,t.__=i,t.u=e,ne.__h.push(t))}function _e(i){return sr=5,Ht(function(){return{current:i}},[])}function Ht(i,e){var t=or(xi++,7);return Ws(t.__H,e)&&(t.__=i(),t.__H=e),t.__}function _O(){var i;do{for(;i=Es.shift();)try{cn(i)}catch(t){te.__e(t,{__:(i=i.__P)&&i.__v})}for(;i=ch.shift();){var e=i.__H;if(i.__P&&e)try{e.__h.some(cn),e.__h.some(qs),e.__h=[]}catch(t){e.__h=[],te.__e(t,i.__v)}}}while(Es.length)}te.__b=function(i){ne=null,ih&&ih(i)},te.__=function(i,e){i&&e.__k&&e.__k.__m&&(i.__m=e.__k.__m),ah&&ah(i,e)},te.__r=function(i){nh&&nh(i),xi=0;var e=(ne=i.__c).__H;e&&(As==ne?ne.__h=[]:(e.__h.some(cn),e.__h.some(qs),xi=0),e.__h=[],e.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})),As=ne},te.diffed=function(i){rh&&rh(i);var e=i.__c;e&&e.__H&&(e.__H.__h.length&&hh(ch.push(e)),e.__H.__.some(function(t){t.u&&(t.__H=t.u)})),As=ne=null},te.__c=function(i,e){e.some(function(t){try{t.__h.some(cn),t.__h=t.__h.filter(function(n){return!n.__||qs(n)})}catch(n){t.__h=[function(){throw n}]}}),sh&&sh(i,e)},te.unmount=function(i){oh&&oh(i);var e,t,n=i.__c;n&&n.__H&&(n.__H.__.some(function(r){try{if(r.__P&&r.__c){if(t===void 0){for(t=i.__;t&&(!t.__c||!t.__c.__P);)t=t.__;t=t&&t.__c}r.__P=t,hh(Es.push(r))}else cn(r)}catch(s){e=s}}),n.__H=void 0,e&&te.__e(e,n.__v))};var lh=typeof requestAnimationFrame=="function";function CO(i){var e,t=function(){clearTimeout(n),lh&&cancelAnimationFrame(e),setTimeout(i)},n=setTimeout(t,35);lh&&(e=requestAnimationFrame(t))}function hh(i){i!=1&&th==te.requestAnimationFrame||((th=te.requestAnimationFrame)||CO)(_O)}function cn(i){var e=ne,t=i.__c;typeof t=="function"&&(i.__c=void 0,t()),ne=e}function qs(i){var e=ne;i.__c=i.__(),ne=e}function Ws(i,e){return!i||i.length!=e.length||e.some(function(t,n){return!Ms(t,i[n])})}function dh(i,e){return typeof e=="function"?e(i):e}var ar="stackthread:theme",uh=window.matchMedia("(prefers-color-scheme: light)");function Oh(){try{let i=localStorage.getItem(ar);return i==="light"||i==="dark"?i:"system"}catch{return"system"}}var Rt=Oh(),zs=new Set;function ph(){return Rt==="system"?uh.matches?"light":"dark":Rt}function lr(){document.documentElement.dataset.theme=ph();for(let i of zs)i()}function XO(i){Rt=i;try{i==="system"?localStorage.removeItem(ar):localStorage.setItem(ar,i)}catch{}lr()}function gh(){XO(Rt==="system"?"light":Rt==="light"?"dark":"system")}function mh(){let[,i]=oe(0);return ee(()=>{let e=()=>i(t=>t+1);return zs.add(e),()=>{zs.delete(e)}},[]),{choice:Rt,resolved:ph()}}uh.addEventListener("change",()=>{Rt==="system"&&lr()});window.addEventListener("storage",i=>{i.key===ar&&(Rt=Oh(),lr())});lr();function ZO(){let i=document.getElementById("stackthread-boot");if(i?.textContent)try{return JSON.parse(i.textContent)}catch{}return{token:"",base:"/__stackthread",version:"dev"}}var At=ZO(),hr=`${At.base}/api`,Jt=class extends Error{status;constructor(e,t){super(t),this.status=e}},bh=0,Ls=!1;function Si(i,e,t={}){if(Ls||bh>=30||!At.token)return;bh++,Ls=!0;let n=JSON.stringify({source:"ui",level:i,message:e.slice(0,2e3),url:location.pathname+location.search,stack:t.stack?.slice(0,8e3),where:t.where,detail:t.detail});fetch(`${hr}/log`,{method:"POST",headers:{"Content-Type":"application/json","X-Stackthread-Token":At.token},body:n}).catch(()=>{}).finally(()=>{Ls=!1})}async function Ne(i,e={}){let t=new Headers(e.headers);t.set("X-Stackthread-Token",At.token),e.body&&t.set("Content-Type","application/json");let n;try{n=await fetch(`${hr}/${i}`,{...e,headers:t})}catch(r){throw new Jt(0,`cannot reach the stackthread server: ${r instanceof Error?r.message:String(r)}`)}if(!n.ok){let r=`${n.status} ${n.statusText}`;try{r=(await n.json()).error??r}catch{}throw n.status>=500&&n.status!==503&&Si("error",`${e.method??"GET"} ${i.split("?")[0]} failed: ${r}`,{where:"api"}),new Jt(n.status,r)}return await n.json()}var Qe={meta:()=>Ne("meta"),graph:()=>Ne("graph"),pages:()=>Ne("pages"),findings:()=>Ne("findings"),node:i=>Ne(`node?id=${encodeURIComponent(i)}`),source:i=>Ne(`source?file=${encodeURIComponent(i)}`),search:(i,e=30)=>Ne(`search?q=${encodeURIComponent(i)}&limit=${e}`),explain:i=>Ne(`explain?loc=${encodeURIComponent(i)}`),logs:(i,e)=>Ne(`logs?level=${encodeURIComponent(i)}&n=${e}`)},fn={lineage:i=>Ne("lineage",{method:"POST",body:JSON.stringify(i)}),save:(i,e,t)=>Ne("source",{method:"PUT",body:JSON.stringify({file:i,hash:e,text:t})}),report:async i=>{let e=await fetch(`${hr}/report`,{method:"POST",headers:{"Content-Type":"application/json","X-Stackthread-Token":At.token},body:JSON.stringify({note:i})});if(!e.ok)throw new Jt(e.status,`could not make the report (${e.status})`);let t=/filename="([^"]+)"/.exec(e.headers.get("Content-Disposition")??"")?.[1]??"stackthread-report.zip";return{blob:await e.blob(),name:t,path:e.headers.get("X-Report-Path")??"",files:(e.headers.get("X-Report-Files")??"").split(",").filter(Boolean)}}};function yh(i){let e=null,t=!1,n=1e3,r=()=>{e=new EventSource(`${hr}/events?token=${encodeURIComponent(At.token)}`),e.addEventListener("hello",s=>{n=1e3,i.state("live");let o=JSON.parse(s.data);o.activity&&i.activity(o.activity)}),e.addEventListener("rev",s=>i.rev(JSON.parse(s.data))),e.addEventListener("activity",s=>i.activity(JSON.parse(s.data))),e.onerror=()=>{i.state("offline"),e?.close(),t||setTimeout(r,n=Math.min(n*2,15e3))}};return r(),()=>{t=!0,e?.close()}}var js=new URLSearchParams(location.search),Ce={embed:js.get("embed")==="panel"?"panel":null,mode:js.get("mode")||"inspector",meta:null,graph:null,index:new Map,pages:null,findings:null,selection:null,lineage:null,loading:!1,error:null,showReads:!0,appUrl:js.get("url")||"/",inspecting:!1,connected:!1,files:[],active:null,current:null,focus:null,mapTab:"overview",live:"connecting",lastBuild:null,palette:!1,toast:null,recent:[],activity:null,activityOpen:!1,reportOpen:!1},Us=new Set;function ge(){return Ce}function Z(i){let e=typeof i=="function"?i(Ce):i;Ce={...Ce,...e};for(let t of Us)t()}function C(i){let[e,t]=oe(()=>i(Ce));return ee(()=>{let n=()=>t(()=>i(Ce));return Us.add(n),n(),()=>{Us.delete(n)}},[]),e}var vh;function Mt(i,e="info"){clearTimeout(vh),Z({toast:{text:i,kind:e}}),vh=setTimeout(()=>Z({toast:null}),4200)}async function Ds(){try{let i=await Qe.meta();if(i.ready===!1){Z({meta:i,activity:i.activity??Ce.activity});return}let[e,t]=await Promise.all([Qe.graph(),Qe.pages()]);Z({meta:i,activity:i.activity??Ce.activity,graph:e,index:new Map(e.nodes.map(n=>[n.id,n])),pages:t,findings:e.findings,error:null})}catch(i){Z({error:i instanceof Error?i.message:String(i)})}}function Qh(i){let e=Ce.graph!==null;Z({activity:i}),i.state==="idle"&&!e&&Ds()}async function xh(i,e,t){let[n,r,s]=await Promise.all([Qe.meta(),Qe.graph(),Qe.pages()]);Z({meta:n,graph:r,index:new Map(r.nodes.map(l=>[l.id,l])),pages:s,findings:r.findings,lastBuild:{ms:t,changed:e,at:Date.now()}});let{selection:o,lineage:a}=Ce;o?dn(o,!1):a?.target.loc&&a.target.node&&Et(a.target.loc);for(let l of Ce.files)e.includes(l.file)&&l.text===l.original&&cr(l.file)}async function dn(i,e=!0){Z({selection:i,loading:!0,error:null});try{let t=await fn.lineage(i);Z(n=>({lineage:t,loading:!1,recent:e?[{label:Ys(t,i),selection:i},...n.recent.filter(r=>r.selection.target.loc!==i.target.loc)].slice(0,12):n.recent}))}catch(t){Z({loading:!1,error:t instanceof Error?t.message:String(t)})}}async function Et(i){Z({loading:!0,error:null,selection:null});try{Z({lineage:await Qe.explain(i),loading:!1})}catch(e){Z({loading:!1,error:e instanceof Error?e.message:String(e)})}}function Ys(i,e){let t=i.target;if(t.label)return t.label;let n=t.text||e?.target.text;return`<${t.element||t.tag||"?"}>${n?` ${n.slice(0,40)}`:""}`}async function gt(i,e=1,t=1){if(Ce.files.find(r=>r.file===i)){Z(r=>({active:i,files:r.files.map(s=>s.file===i?{...s,line:e,col:t}:s)}));return}try{let r=await Qe.source(i),s={file:i,text:r.text,original:r.text,hash:r.hash,line:e,col:t,rev:0,saving:!1,conflict:!1,notice:null};Z(o=>({files:[...o.files.slice(-7),s],active:i}))}catch(r){Mt(r instanceof Error?r.message:String(r),"bad")}}function Vs(i){Z(e=>{let t=e.files.filter(n=>n.file!==i);return{files:t,active:e.active===i?t[t.length-1]?.file??null:e.active}})}function Sh(i,e){Z(t=>({files:t.files.map(n=>n.file===i?{...n,text:e}:n)}))}function kh(i){Z(e=>({files:e.files.map(t=>t.file===i?{...t,text:t.original,rev:t.rev+1}:t)}))}async function cr(i){try{let e=await Qe.source(i);Z(t=>({files:t.files.map(n=>n.file===i?{...n,text:e.text,original:e.text,hash:e.hash,rev:n.rev+1,conflict:!1,notice:null}:n)}))}catch(e){Mt(e instanceof Error?e.message:String(e),"bad")}}async function Is(i){let e=Ce.files.find(t=>t.file===i);if(!(!e||e.saving)){Z(t=>({files:t.files.map(n=>n.file===i?{...n,saving:!0,notice:null}:n)}));try{let t=await fn.save(i,e.hash,e.text),n=t.output?{kind:t.formatted?"good":"warn",text:t.output.split(`
|
|
2
|
-
`).slice(-3).join(" ")}:{kind:"good",text:"Saved. Your dev server reloads the app; the map updates in a moment."};Z(r=>({files:r.files.map(s=>s.file===i?{...s,hash:t.hash,original:s.text,saving:!1,notice:n}:s)})),t.formatted&&cr(i),Mt(`Saved ${i.split("/").pop()}`,"good")}catch(t){let n=t instanceof Jt&&t.status===409,r=t instanceof Error?t.message:String(t);Z(s=>({files:s.files.map(o=>o.file===i?{...o,saving:!1,conflict:n,notice:{kind:"bad",text:r}}:o)}))}}}function Fe(i){Z({focus:i,mode:"map",mapTab:"focus"})}var RO="stackthread-ui",wh="stackthread-client",Ph=null;function Th(i){Ph=i}function AO(){return ge().embed==="panel"?window.parent!==window?window.parent:null:Ph?.contentWindow??null}function Kt(i){AO()?.postMessage({...i,source:RO},location.origin)}function mt(i){Z({inspecting:i}),Kt({type:"inspect",on:i})}function Bs(i){Kt({type:"highlight",loc:i})}function Gs(i){Kt({type:"reveal",loc:i})}function $h(i){switch(i.type){case"select":i.selection&&dn(i.selection);break;case"url":i.url&&ge().embed!=="panel"&&Z({appUrl:i.url});break;case"hello":Z({connected:!0,...i.url?{appUrl:i.url}:{}}),ge().inspecting&&Kt({type:"inspect",on:!0});break;case"inspecting":Z({inspecting:!!i.on});break}}function _h(){if(window.addEventListener("message",i=>{i.origin!==location.origin||!i.data||i.data.source!==wh||$h(i.data)}),typeof BroadcastChannel=="function"){let i=new BroadcastChannel("stackthread");i.onmessage=e=>{let t=e.data;t?.source===wh&&ge().embed!=="panel"&&t.type==="select"&&$h(t)}}ge().embed==="panel"&&Kt({type:"ping"})}var MO={screen:"var(--screen)",client:"var(--client)",network:"var(--network)",server:"var(--server)",data:"var(--data)",none:"var(--mute)"};function Ch(i){return MO[i]??"var(--concept)"}function bt(i){switch(i){case"page":case"component":return"var(--screen)";case"hook":case"function":case"method":case"file":case"module":case"class":return"var(--client)";case"endpoint":case"request":return"var(--network)";case"model":case"store":return"var(--data)";default:return"var(--mute)"}}function yt(i){return i.split("/").pop()??i}function Xh(i){let e=i.split("/");return e.length>3?`\u2026/${e.slice(-3).join("/")}`:i}function Zh(i,e,t=1,n=1){if(!i?.editor.url)return null;let s=`${i.root.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`;return i.editor.url.replace("{path}",encodeURI(s)).replace("{line}",String(t)).replace("{col}",String(n))}function Rh(i,e){let t=!1;return{path:i.split("/").map(r=>{let s=r.match(/^(?::|\$)(\w+)\??$|^\{(\w+)\}$/);if(!s)return r;let o=s[1]??s[2];return e[o]!==void 0?e[o]:(t=!0,r)}).join("/")||"/",open:t}}function fr(i,e){return`${i} ${e}${i===1?"":"s"}`}function Ns(i,e,t){return Math.min(Math.max(i,e),t)}function Fs(i,e){try{let t=Number(localStorage.getItem(i));return Number.isFinite(t)&&t>0?t:e}catch{return e}}function Hs(i,e){try{localStorage.setItem(i,String(Math.round(e)))}catch{}}var EO=Symbol.for("pv"),qO=0;function u(i,e,t,n,r,s){e||(e={});var o,a,l=e;if("ref"in l&&typeof i!="function")for(a in l={},e)a=="ref"?o=e[a]:l[a]=e[a];var h={type:i,props:l,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:EO,__v:--qO,__i:-1,__u:0};return(r||s)&&(h.__source=r,h.__self=s),V.vnode&&V.vnode(h),h}function Ah(i,e){if(e==="offline")return{text:"Offline, reconnecting",kind:"off"};if(!i)return{text:"Connecting",kind:""};switch(i.state){case"starting":return{text:"Starting",kind:"busy"};case"indexing":return{text:`Indexing ${i.done??0}/${i.total??0} files`,kind:"busy"};case"updating":{let t=(i.files?.[0]??"").split("/").pop(),n=(i.count??1)-1;return{text:`Re-indexing ${t}${n>0?` and ${n} more`:""}`,kind:"busy"}}case"failed":return{text:"Indexing failed",kind:"off"};default:return{text:`Live${i.rev?` \xB7 rev ${i.rev}`:""}`,kind:"on"}}}function Mh(){let i=C(s=>s.activity),e=C(s=>s.live),t=C(s=>s.activityOpen),{text:n,kind:r}=Ah(i,e);return u("button",{class:`activity ${r}`,"aria-haspopup":"dialog","aria-expanded":t,title:"What stackthread is doing",onClick:()=>Z({activityOpen:!ge().activityOpen}),children:[u("i",{class:"act-ico"}),u("span",{class:"act-text",children:n})]})}function Eh(){let i=C(t=>t.activity);if(!i||i.state!=="indexing"&&i.state!=="updating")return null;let e=i.state==="indexing"&&i.total?Math.round((i.done??0)/i.total*100):0;return u("div",{class:`act-bar ${i.state==="updating"?"indeterminate":""}`,"aria-hidden":"true",children:u("i",{style:{width:i.state==="indexing"?`${e}%`:void 0}})})}function WO({e:i}){return u("li",{class:`log ${i.level}`,children:[u("span",{class:"faint mono",children:i.ts.slice(11,19)}),u("span",{class:"log-area",children:i.area}),u("span",{class:"log-msg",children:i.msg})]})}function dr(){let i=C(d=>d.activityOpen),e=C(d=>d.activity),t=C(d=>d.live),[n,r]=oe([]),[s,o]=oe([]),[a,l]=oe("recent"),h=e?.rev;if(ee(()=>{i&&(Qe.logs("info",15).then(d=>r([...d].reverse())).catch(()=>{}),Qe.logs("warning",50).then(d=>o([...d].reverse())).catch(()=>{}))},[i,h,e?.state]),ee(()=>{if(!i)return;let d=O=>{O.key==="Escape"&&Z({activityOpen:!1})};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),!i)return null;let{text:c}=Ah(e,t),f=a==="recent"?n:s;return u("div",{class:"act-pop",role:"dialog","aria-label":"Activity",children:[u("div",{class:"row",children:[u("h4",{class:"grow",children:"Activity"}),u("button",{class:"btn ghost",onClick:()=>Z({activityOpen:!1}),"aria-label":"Close",children:"\xD7"})]}),u("p",{class:"act-now",children:c}),e?.state==="failed"&&e.error&&u("p",{class:"banner bad",children:e.error}),u("nav",{class:"tabs",style:{marginBottom:8},children:[u("button",{"aria-pressed":a==="recent",onClick:()=>l("recent"),children:"Recent"}),u("button",{"aria-pressed":a==="problems",onClick:()=>l("problems"),children:["Problems",s.length?` \xB7 ${s.length}`:""]})]}),u("ul",{class:"log-list",children:f.length?f.map((d,O)=>u(WO,{e:d},O)):u("li",{class:"faint",children:a==="recent"?"Nothing yet.":"No warnings or errors. Good."})}),u("div",{class:"row",style:{marginTop:10},children:[u("button",{class:"btn",onClick:()=>Z({reportOpen:!0,activityOpen:!1}),children:"Report a problem"}),u("span",{class:"faint",style:{fontSize:11.5},children:["Full log: ",u("code",{children:".stackthread/logs"})," \xB7 ",u("code",{children:"stackthread logs"})]})]})]})}function ur(){let i=C(a=>a.reportOpen),[e,t]=oe(""),[n,r]=oe(!1);if(ee(()=>{if(!i)return;let a=l=>{l.key==="Escape"&&Z({reportOpen:!1})};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]),!i)return null;let s=()=>Z({reportOpen:!1}),o=async()=>{r(!0);try{let a=await fn.report(e),l=URL.createObjectURL(a.blob),h=document.createElement("a");h.href=l,h.download=a.name,h.click(),setTimeout(()=>URL.revokeObjectURL(l),1e4),Mt(`Report saved. A copy is in ${a.path}`,"good"),t(""),s()}catch(a){Mt(a instanceof Error?a.message:String(a),"bad"),Si("error",`making a report failed: ${a instanceof Error?a.message:String(a)}`)}finally{r(!1)}};return u("div",{class:"overlay",onClick:a=>{a.target===a.currentTarget&&s()},children:u("div",{class:"palette report",role:"dialog","aria-label":"Report a problem",children:[u("h3",{children:"Report a problem"}),u("p",{class:"muted",children:"This makes a zip file with stackthread's logs, versions, checks and a summary of the settings, so whoever looks after stackthread can see what happened. It never contains your source code."}),u("label",{for:"report-note",children:"What were you doing, and what went wrong? (optional)"}),u("textarea",{id:"report-note",rows:5,value:e,onInput:a=>t(a.target.value),placeholder:"For example: I clicked Save on the stage form and the panel stayed empty."}),u("div",{class:"row",style:{justifyContent:"flex-end",marginTop:10},children:[u("button",{class:"btn ghost",onClick:s,children:"Cancel"}),u("button",{class:"btn primary",disabled:n,onClick:()=>{o()},children:n?"Making the report\u2026":"Make the report"})]})]})})}function qh(){let i=C(s=>s.activity),e=C(s=>s.meta),t=i?.done??0,n=i?.total??0,r=i?.state==="failed";return u("main",{class:"not-ready",children:u("div",{children:[u("h2",{children:r?"Indexing failed":`Reading the code of ${e?.name??"your project"}\u2026`}),r?u("p",{class:"muted",children:[i?.error," The details are in the log. ",u("button",{class:"btn",onClick:()=>Z({reportOpen:!0}),children:"Report a problem"})]}):u(fe,{children:[u("div",{class:"nr-bar",children:u("i",{style:{width:`${n?Math.round(t/n*100):5}%`}})}),u("p",{class:"muted",children:[n?`${t} of ${n} files`:"Looking for files",". The workbench opens by itself when this is done."]})]})]})})}function de(i){let{children:e,...t}=i;return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",class:"icon",...t,children:e})}var Wh=i=>u("svg",{viewBox:"0 0 32 32","aria-hidden":"true",...i,children:[u("rect",{width:"32",height:"32",rx:"8",fill:"var(--raise)"}),u("path",{d:"M9 6v20",stroke:"var(--screen)","stroke-width":"3","stroke-linecap":"round"}),u("path",{d:"M9 10c9 0 14 3 14 8s-5 8-14 8",stroke:"var(--action)","stroke-width":"3",fill:"none","stroke-linecap":"round"}),u("circle",{cx:"9",cy:"10",r:"2.4",fill:"var(--client)"}),u("circle",{cx:"23",cy:"18",r:"2.4",fill:"var(--server)"}),u("circle",{cx:"9",cy:"26",r:"2.4",fill:"var(--data)"})]}),un=i=>u(de,{...i,children:[u("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"}),u("path",{d:"M13 13l6 6"})]}),zh=i=>u(de,{...i,children:[u("circle",{cx:"11",cy:"11",r:"7"}),u("path",{d:"M21 21l-4.3-4.3"})]}),Lh=i=>u(de,{...i,children:[u("circle",{cx:"12",cy:"12",r:"4"}),u("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}),jh=i=>u(de,{...i,children:u("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})}),Uh=i=>u(de,{...i,children:[u("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),u("path",{d:"M8 20h8M12 16v4"})]}),Dh=i=>u(de,{...i,children:u("path",{d:"M15 18l-6-6 6-6"})}),Yh=i=>u(de,{...i,children:u("path",{d:"M9 18l6-6-6-6"})}),Vh=i=>u(de,{...i,children:[u("path",{d:"M21 12a9 9 0 1 1-2.6-6.4"}),u("path",{d:"M21 3v6h-6"})]}),Or=i=>u(de,{...i,children:[u("path",{d:"M14 3h7v7"}),u("path",{d:"M10 14L21 3"}),u("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5"})]}),Ih=i=>u(de,{...i,children:[u("path",{d:"M5 3h11l5 5v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),u("path",{d:"M7 3v6h8M7 21v-7h10v7"})]}),Bh=i=>u(de,{...i,children:[u("path",{d:"M9 14L4 9l5-5"}),u("path",{d:"M4 9h11a5 5 0 0 1 0 10h-4"})]}),Gh=i=>u(de,{...i,children:u("path",{d:"M18 6L6 18M6 6l12 12"})}),Nh=i=>u(de,{...i,children:[u("circle",{cx:"12",cy:"12",r:"8"}),u("circle",{cx:"12",cy:"12",r:"3"}),u("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]}),Js=i=>u(de,{...i,children:[u("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"}),u("circle",{cx:"12",cy:"12",r:"3"})]}),Fh=i=>u(de,{...i,children:[u("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),u("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]}),Hh=i=>u(de,{...i,children:[u("path",{d:"M9 4L3 6v14l6-2 6 2 6-2V4l-6 2-6-2z"}),u("path",{d:"M9 4v14M15 6v14"})]}),pr=i=>u(de,{...i,children:[u("path",{d:"M6 3v18"}),u("path",{d:"M6 7c8 0 12 2 12 5s-4 5-12 5"})]});async function zO(){try{return(await fetch(`${At.base}/client.js`,{method:"HEAD"})).ok?"same-origin":"direct"}catch{return"direct"}}function Jh(){let i=C(f=>f.appUrl),e=C(f=>f.meta),t=C(f=>f.connected),[n,r]=oe("checking"),[s,o]=oe(i),a=_e(null),l=_e("");ee(()=>{zO().then(r)},[]),ee(()=>o(i),[i]),ee(()=>{Th(a.current);let f=a.current;if(!f||n!=="same-origin")return;let d="";try{let O=f.contentWindow?.location;d=O?O.pathname+O.search+O.hash:""}catch{d=""}d!==i&&l.current!==i&&(l.current=i,f.src=i)},[i,n]);let h=()=>{Kt({type:"ping"}),ge().inspecting&&setTimeout(()=>mt(!0),300)},c=f=>{try{a.current?.contentWindow&&f(a.current.contentWindow)}catch{}};if(n==="direct"){let f=e?.devUrls[0];return u("section",{class:"stage",children:[u("div",{class:"urlbar",children:u("span",{class:"muted",children:"The live app is not available here"})}),u("div",{class:"frame-wrap",children:u("div",{class:"frame-note",children:u("div",{children:[u("h2",{children:"Open stackthread through your dev server"}),f?u("p",{children:["Your app runs at ",u("a",{href:`${f}/__stackthread/`,children:f}),". Open",u("a",{href:`${f}/__stackthread/`,children:[" ",f,"/__stackthread/"]})," to inspect it here. The Map and Findings views work on this page too."]}):u(fe,{children:[u("p",{children:["Add the Vite plugin to your app, start its dev server, then open ",u("code",{children:"/__stackthread/"})," on it. The Map and Findings views already work here."]}),u("pre",{children:["npm install --save-dev @stackthread/vite",`
|
|
2
|
+
`).slice(-3).join(" ")}:{kind:"good",text:"Saved. Your dev server reloads the app; the map updates in a moment."};Z(r=>({files:r.files.map(s=>s.file===i?{...s,hash:t.hash,original:s.text,saving:!1,notice:n}:s)})),t.formatted&&cr(i),Mt(`Saved ${i.split("/").pop()}`,"good")}catch(t){let n=t instanceof Jt&&t.status===409,r=t instanceof Error?t.message:String(t);Z(s=>({files:s.files.map(o=>o.file===i?{...o,saving:!1,conflict:n,notice:{kind:"bad",text:r}}:o)}))}}}function Fe(i){Z({focus:i,mode:"map",mapTab:"focus"})}var RO="stackthread-ui",wh="stackthread-client",Ph=null;function Th(i){Ph=i}function AO(){return ge().embed==="panel"?window.parent!==window?window.parent:null:Ph?.contentWindow??null}function Kt(i){AO()?.postMessage({...i,source:RO},location.origin)}function mt(i){Z({inspecting:i}),Kt({type:"inspect",on:i})}function Bs(i){Kt({type:"highlight",loc:i})}function Gs(i){Kt({type:"reveal",loc:i})}function $h(i){switch(i.type){case"select":i.selection&&dn(i.selection);break;case"url":i.url&&ge().embed!=="panel"&&Z({appUrl:i.url});break;case"hello":Z({connected:!0,...i.url?{appUrl:i.url}:{}}),ge().inspecting&&Kt({type:"inspect",on:!0});break;case"inspecting":Z({inspecting:!!i.on});break}}function _h(){if(window.addEventListener("message",i=>{i.origin!==location.origin||!i.data||i.data.source!==wh||$h(i.data)}),typeof BroadcastChannel=="function"){let i=new BroadcastChannel("stackthread");i.onmessage=e=>{let t=e.data;t?.source===wh&&ge().embed!=="panel"&&t.type==="select"&&$h(t)}}ge().embed==="panel"&&Kt({type:"ping"})}var MO={screen:"var(--screen)",client:"var(--client)",network:"var(--network)",server:"var(--server)",data:"var(--data)",none:"var(--mute)"};function Ch(i){return MO[i]??"var(--concept)"}function bt(i){switch(i){case"page":case"component":return"var(--screen)";case"hook":case"function":case"method":case"file":case"module":case"class":return"var(--client)";case"endpoint":case"request":return"var(--network)";case"model":case"store":return"var(--data)";default:return"var(--mute)"}}function yt(i){return i.split("/").pop()??i}function Xh(i){let e=i.split("/");return e.length>3?`\u2026/${e.slice(-3).join("/")}`:i}function Zh(i,e,t=1,n=1){if(!i?.editor.url)return null;let s=`${i.root.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`;return i.editor.url.replace("{path}",encodeURI(s)).replace("{line}",String(t)).replace("{col}",String(n))}function Rh(i,e){let t=!1;return{path:i.split("/").map(r=>{let s=r.match(/^(?::|\$)(\w+)\??$|^\{(\w+)\}$/);if(!s)return r;let o=s[1]??s[2];return e[o]!==void 0?e[o]:(t=!0,r)}).join("/")||"/",open:t}}function fr(i,e){return`${i} ${e}${i===1?"":"s"}`}function Ns(i,e,t){return Math.min(Math.max(i,e),t)}function Fs(i,e){try{let t=Number(localStorage.getItem(i));return Number.isFinite(t)&&t>0?t:e}catch{return e}}function Hs(i,e){try{localStorage.setItem(i,String(Math.round(e)))}catch{}}var EO=Symbol.for("pv"),qO=0;function u(i,e,t,n,r,s){e||(e={});var o,a,l=e;if("ref"in l&&typeof i!="function")for(a in l={},e)a=="ref"?o=e[a]:l[a]=e[a];var h={type:i,props:l,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:EO,__v:--qO,__i:-1,__u:0};return(r||s)&&(h.__source=r,h.__self=s),V.vnode&&V.vnode(h),h}function Ah(i,e){if(e==="offline")return{text:"Offline, reconnecting",kind:"off"};if(!i)return{text:"Connecting",kind:""};switch(i.state){case"starting":return{text:"Starting",kind:"busy"};case"indexing":return{text:`Indexing ${i.done??0}/${i.total??0} files`,kind:"busy"};case"updating":{let t=(i.files?.[0]??"").split("/").pop(),n=(i.count??1)-1;return{text:`Re-indexing ${t}${n>0?` and ${n} more`:""}`,kind:"busy"}}case"failed":return{text:"Indexing failed",kind:"off"};default:return{text:`Live${i.rev?` \xB7 rev ${i.rev}`:""}`,kind:"on"}}}function Mh(){let i=C(s=>s.activity),e=C(s=>s.live),t=C(s=>s.activityOpen),{text:n,kind:r}=Ah(i,e);return u("button",{class:`activity ${r}`,"aria-haspopup":"dialog","aria-expanded":t,title:"What stackthread is doing",onClick:()=>Z({activityOpen:!ge().activityOpen}),children:[u("i",{class:"act-ico"}),u("span",{class:"act-text",children:n})]})}function Eh(){let i=C(t=>t.activity);if(!i||i.state!=="indexing"&&i.state!=="updating")return null;let e=i.state==="indexing"&&i.total?Math.round((i.done??0)/i.total*100):0;return u("div",{class:`act-bar ${i.state==="updating"?"indeterminate":""}`,"aria-hidden":"true",children:u("i",{style:{width:i.state==="indexing"?`${e}%`:void 0}})})}function WO({e:i}){return u("li",{class:`log ${i.level}`,children:[u("span",{class:"faint mono",children:i.ts.slice(11,19)}),u("span",{class:"log-area",children:i.area}),u("span",{class:"log-msg",children:i.msg})]})}function dr(){let i=C(d=>d.activityOpen),e=C(d=>d.activity),t=C(d=>d.live),[n,r]=oe([]),[s,o]=oe([]),[a,l]=oe("recent"),h=e?.rev;if(ee(()=>{i&&(Qe.logs("info",15).then(d=>r([...d].reverse())).catch(()=>{}),Qe.logs("warning",50).then(d=>o([...d].reverse())).catch(()=>{}))},[i,h,e?.state]),ee(()=>{if(!i)return;let d=O=>{O.key==="Escape"&&Z({activityOpen:!1})};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),!i)return null;let{text:c}=Ah(e,t),f=a==="recent"?n:s;return u("div",{class:"act-pop",role:"dialog","aria-label":"Activity",children:[u("div",{class:"row",children:[u("h4",{class:"grow",children:"Activity"}),u("button",{class:"btn ghost",onClick:()=>Z({activityOpen:!1}),"aria-label":"Close",children:"\xD7"})]}),u("p",{class:"act-now",children:c}),e?.state==="failed"&&e.error&&u("p",{class:"banner bad",children:e.error}),u("nav",{class:"tabs",style:{marginBottom:8},children:[u("button",{"aria-pressed":a==="recent",onClick:()=>l("recent"),children:"Recent"}),u("button",{"aria-pressed":a==="problems",onClick:()=>l("problems"),children:["Problems",s.length?` \xB7 ${s.length}`:""]})]}),u("ul",{class:"log-list",children:f.length?f.map((d,O)=>u(WO,{e:d},O)):u("li",{class:"faint",children:a==="recent"?"Nothing yet.":"No warnings or errors. Good."})}),u("div",{class:"row",style:{marginTop:10},children:[u("button",{class:"btn",onClick:()=>Z({reportOpen:!0,activityOpen:!1}),children:"Report a problem"}),u("span",{class:"faint",style:{fontSize:11.5},children:["Full log: ",u("code",{children:".stackthread/logs"})," \xB7 ",u("code",{children:"stackthread logs"})]})]})]})}function ur(){let i=C(a=>a.reportOpen),[e,t]=oe(""),[n,r]=oe(!1);if(ee(()=>{if(!i)return;let a=l=>{l.key==="Escape"&&Z({reportOpen:!1})};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]),!i)return null;let s=()=>Z({reportOpen:!1}),o=async()=>{r(!0);try{let a=await fn.report(e),l=URL.createObjectURL(a.blob),h=document.createElement("a");h.href=l,h.download=a.name,h.click(),setTimeout(()=>URL.revokeObjectURL(l),1e4),Mt(`Report saved. A copy is in ${a.path}`,"good"),t(""),s()}catch(a){Mt(a instanceof Error?a.message:String(a),"bad"),Si("error",`making a report failed: ${a instanceof Error?a.message:String(a)}`)}finally{r(!1)}};return u("div",{class:"overlay",onClick:a=>{a.target===a.currentTarget&&s()},children:u("div",{class:"palette report",role:"dialog","aria-label":"Report a problem",children:[u("h3",{children:"Report a problem"}),u("p",{class:"muted",children:"This makes a zip file with stackthread's logs, versions, checks and a summary of the settings, so whoever looks after stackthread can see what happened. It never contains your source code."}),u("label",{for:"report-note",children:"What were you doing, and what went wrong? (optional)"}),u("textarea",{id:"report-note",rows:5,value:e,onInput:a=>t(a.target.value),placeholder:"For example: I clicked Save on the checkout form and the panel stayed empty."}),u("div",{class:"row",style:{justifyContent:"flex-end",marginTop:10},children:[u("button",{class:"btn ghost",onClick:s,children:"Cancel"}),u("button",{class:"btn primary",disabled:n,onClick:()=>{o()},children:n?"Making the report\u2026":"Make the report"})]})]})})}function qh(){let i=C(s=>s.activity),e=C(s=>s.meta),t=i?.done??0,n=i?.total??0,r=i?.state==="failed";return u("main",{class:"not-ready",children:u("div",{children:[u("h2",{children:r?"Indexing failed":`Reading the code of ${e?.name??"your project"}\u2026`}),r?u("p",{class:"muted",children:[i?.error," The details are in the log. ",u("button",{class:"btn",onClick:()=>Z({reportOpen:!0}),children:"Report a problem"})]}):u(fe,{children:[u("div",{class:"nr-bar",children:u("i",{style:{width:`${n?Math.round(t/n*100):5}%`}})}),u("p",{class:"muted",children:[n?`${t} of ${n} files`:"Looking for files",". The workbench opens by itself when this is done."]})]})]})})}function de(i){let{children:e,...t}=i;return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",class:"icon",...t,children:e})}var Wh=i=>u("svg",{viewBox:"0 0 32 32","aria-hidden":"true",...i,children:[u("rect",{width:"32",height:"32",rx:"8",fill:"var(--raise)"}),u("path",{d:"M9 6v20",stroke:"var(--screen)","stroke-width":"3","stroke-linecap":"round"}),u("path",{d:"M9 10c9 0 14 3 14 8s-5 8-14 8",stroke:"var(--action)","stroke-width":"3",fill:"none","stroke-linecap":"round"}),u("circle",{cx:"9",cy:"10",r:"2.4",fill:"var(--client)"}),u("circle",{cx:"23",cy:"18",r:"2.4",fill:"var(--server)"}),u("circle",{cx:"9",cy:"26",r:"2.4",fill:"var(--data)"})]}),un=i=>u(de,{...i,children:[u("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"}),u("path",{d:"M13 13l6 6"})]}),zh=i=>u(de,{...i,children:[u("circle",{cx:"11",cy:"11",r:"7"}),u("path",{d:"M21 21l-4.3-4.3"})]}),Lh=i=>u(de,{...i,children:[u("circle",{cx:"12",cy:"12",r:"4"}),u("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}),jh=i=>u(de,{...i,children:u("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})}),Uh=i=>u(de,{...i,children:[u("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),u("path",{d:"M8 20h8M12 16v4"})]}),Dh=i=>u(de,{...i,children:u("path",{d:"M15 18l-6-6 6-6"})}),Yh=i=>u(de,{...i,children:u("path",{d:"M9 18l6-6-6-6"})}),Vh=i=>u(de,{...i,children:[u("path",{d:"M21 12a9 9 0 1 1-2.6-6.4"}),u("path",{d:"M21 3v6h-6"})]}),Or=i=>u(de,{...i,children:[u("path",{d:"M14 3h7v7"}),u("path",{d:"M10 14L21 3"}),u("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5"})]}),Ih=i=>u(de,{...i,children:[u("path",{d:"M5 3h11l5 5v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),u("path",{d:"M7 3v6h8M7 21v-7h10v7"})]}),Bh=i=>u(de,{...i,children:[u("path",{d:"M9 14L4 9l5-5"}),u("path",{d:"M4 9h11a5 5 0 0 1 0 10h-4"})]}),Gh=i=>u(de,{...i,children:u("path",{d:"M18 6L6 18M6 6l12 12"})}),Nh=i=>u(de,{...i,children:[u("circle",{cx:"12",cy:"12",r:"8"}),u("circle",{cx:"12",cy:"12",r:"3"}),u("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]}),Js=i=>u(de,{...i,children:[u("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"}),u("circle",{cx:"12",cy:"12",r:"3"})]}),Fh=i=>u(de,{...i,children:[u("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),u("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]}),Hh=i=>u(de,{...i,children:[u("path",{d:"M9 4L3 6v14l6-2 6 2 6-2V4l-6 2-6-2z"}),u("path",{d:"M9 4v14M15 6v14"})]}),pr=i=>u(de,{...i,children:[u("path",{d:"M6 3v18"}),u("path",{d:"M6 7c8 0 12 2 12 5s-4 5-12 5"})]});async function zO(){try{return(await fetch(`${At.base}/client.js`,{method:"HEAD"})).ok?"same-origin":"direct"}catch{return"direct"}}function Jh(){let i=C(f=>f.appUrl),e=C(f=>f.meta),t=C(f=>f.connected),[n,r]=oe("checking"),[s,o]=oe(i),a=_e(null),l=_e("");ee(()=>{zO().then(r)},[]),ee(()=>o(i),[i]),ee(()=>{Th(a.current);let f=a.current;if(!f||n!=="same-origin")return;let d="";try{let O=f.contentWindow?.location;d=O?O.pathname+O.search+O.hash:""}catch{d=""}d!==i&&l.current!==i&&(l.current=i,f.src=i)},[i,n]);let h=()=>{Kt({type:"ping"}),ge().inspecting&&setTimeout(()=>mt(!0),300)},c=f=>{try{a.current?.contentWindow&&f(a.current.contentWindow)}catch{}};if(n==="direct"){let f=e?.devUrls[0];return u("section",{class:"stage",children:[u("div",{class:"urlbar",children:u("span",{class:"muted",children:"The live app is not available here"})}),u("div",{class:"frame-wrap",children:u("div",{class:"frame-note",children:u("div",{children:[u("h2",{children:"Open stackthread through your dev server"}),f?u("p",{children:["Your app runs at ",u("a",{href:`${f}/__stackthread/`,children:f}),". Open",u("a",{href:`${f}/__stackthread/`,children:[" ",f,"/__stackthread/"]})," to inspect it here. The Map and Findings views work on this page too."]}):u(fe,{children:[u("p",{children:["Add the Vite plugin to your app, start its dev server, then open ",u("code",{children:"/__stackthread/"})," on it. The Map and Findings views already work here."]}),u("pre",{children:["npm install --save-dev @stackthread/vite",`
|
|
3
3
|
`,"// vite.config.ts",`
|
|
4
4
|
`,"plugins: [stackthread(), react()]"]})]})]})})})]})}return u("section",{class:"stage",children:[u("form",{class:"urlbar",onSubmit:f=>{f.preventDefault(),Z({appUrl:s.startsWith("/")?s:`/${s}`})},children:[u("button",{type:"button",class:"btn ghost",title:"Back",onClick:()=>c(f=>f.history.back()),children:u(Dh,{})}),u("button",{type:"button",class:"btn ghost",title:"Forward",onClick:()=>c(f=>f.history.forward()),children:u(Yh,{})}),u("button",{type:"button",class:"btn ghost",title:"Reload the app",onClick:()=>c(f=>f.location.reload()),children:u(Vh,{})}),u("input",{value:s,onInput:f=>o(f.target.value),"aria-label":"App URL",spellcheck:!1}),u("span",{class:"chip",title:t?"The overlay client in the app answered":"Waiting for the app",style:{color:t?"var(--good)":"var(--mute)"},children:t?"connected":"loading"}),u("a",{class:"btn ghost",href:i,target:"_blank",rel:"noreferrer",title:"Open the app in a new tab",children:u(Or,{})})]}),u("div",{class:"frame-wrap",children:n==="same-origin"&&u("iframe",{ref:a,title:"Your app",onLoad:h})})]})}var eo=[],ic=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<i.length;e++)(e%2?ic:eo).push(t=t+i[e])})();function LO(i){if(i<768)return!1;for(let e=0,t=eo.length;;){let n=e+t>>1;if(i<eo[n])t=n;else if(i>=ic[n])e=n+1;else return!0;if(e==t)return!1}}function Kh(i){return i>=127462&&i<=127487}var ec=8205;function nc(i,e,t=!0,n=!0){return(t?rc:jO)(i,e,n)}function rc(i,e,t){if(e==i.length)return e;e&&sc(i.charCodeAt(e))&&oc(i.charCodeAt(e-1))&&e--;let n=Ks(i,e);for(e+=tc(n);e<i.length;){let r=Ks(i,e);if(n==ec||r==ec||t&&LO(r))e+=tc(r),n=r;else if(Kh(r)){let s=0,o=e-2;for(;o>=0&&Kh(Ks(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function jO(i,e,t){for(;e>1;){let n=rc(i,e-2,t);if(n<e)return n;e--}return 0}function Ks(i,e){let t=i.charCodeAt(e);if(!oc(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return sc(n)?(t-55296<<10)+(n-56320)+65536:t}function sc(i){return i>=56320&&i<57344}function oc(i){return i>=55296&&i<56320}function tc(i){return i<65536?1:2}var z=class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ti(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),wi.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ti(this,e,t);let n=[];return this.decompose(e,t,n,0),wi.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new ni(this),s=new ni(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new ni(this,e)}iterRange(e,t=this.length){return new vr(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Qr(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?i.empty:e.length<=32?new Xe(e):wi.from(Xe.split(e,[]))}},Xe=class i extends z{constructor(e,t=UO(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?n:a)>=e)return new io(r,a,n,o);r=a+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(ac(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),a=yr(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new i(a,o.length+s.length));else{let l=a.length>>1;n.push(new i(a.slice(0,l)),new i(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=Ti(this,e,t);let r=yr(this.text,yr(n.text,ac(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):wi.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=`
|
|
5
5
|
`){[e,t]=Ti(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>e&&o&&(r+=n),e<l&&t>s&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new i(n,r)),n=[],r=-1);return r>-1&&t.push(new i(n,r)),t}},wi=class i extends z{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,r);r=a+1,n=l+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(e<=l&&t>=o){let h=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!h?n.push(a):a.decompose(e-o,t-o,n,h)}o=l+1}}replace(e,t,n){if([e,t]=Ti(this,e,t),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],a=s+o.length;if(e>=s&&t<=a){let l=o.replace(e-s,t-s,n),h=this.lines-o.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let c=this.children.slice();return c[r]=l,new i(c,this.length-(t-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
|