@p4code/cli 0.0.45 → 0.0.46

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.
@@ -1,4 +1,4 @@
1
- import{$t as e,C as t,E as n,Go as r,Ho as i,Jt as a,Kl as o,Pf as s,Pt as c,Ts as l,Uf as u,as as d,b as f,bs as p,g as m,is as h,lp as g,m as _,op as v,p as y,v as b}from"./textarea-lBMORu4g.js";import{a as x,c as S,i as C,n as ee,o as w,r as T,s as E,t as te}from"./fileCommentAnnotations-BBX2usb_.js";import{C as ne,Cn as D,Ct as O,D as k,Dn as A,Dt as j,En as M,Fr as re,Gn as ie,H as ae,Hn as oe,Nr as se,Qn as ce,Qt as le,Rt as ue,S as de,Sn as fe,Sr as pe,Tn as me,Tr as N,Tt as he,U as ge,V as _e,W as ve,Wn as ye,X as be,b as xe,bn as Se,d as Ce,dr as we,f as Te,fr as Ee,jr as De,l as P,ln as Oe,lr as ke,m as Ae,mr as je,p as Me,pn as Ne,pr as Pe,qn as Fe,u as Ie,ur as Le,v as Re,vr as ze,w as Be,x as Ve,xn as He,y as Ue,yn as We,yr as Ge,z as Ke,zt as qe}from"./index-DnkEkLTH.js";var Je=r(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ye=r(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Xe=`file-tree-container`,Ze=`data-file-tree-style`,Qe=`data-file-tree-unsafe-css`,$e=`data-file-tree-scrollbar-measure`,et=`data-file-tree-scrollbar-gutter-measured`,tt=`--trees-scrollbar-gutter-measured`,nt=`header`,rt=`context-menu`,it=`context-menu-trigger`,at=5,ot=1<<at,st=ot*4;function ct(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function lt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function ut(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function dt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function ft(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function F(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function I(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,gt(e,t)}function pt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=dt(e).get(t);if(i===void 0)return;let a=i>>at;e.childVisibleChunkSums[a]+=r}function mt(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=_t(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=ot}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function ht(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>at;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<at}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function gt(e,t){if(t.childIds.length<st){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/ot),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>at]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function _t(e,t,n,r){let i=Math.min(t.childIds.length,n+ot),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var vt=7,yt=3,bt=1<<yt,xt=4;function L(e,t,n=0){return e<<xt|n<<yt|t}function St(e){return e.depthAndFlags>>>xt}function R(e){return(e.depthAndFlags&bt)>>yt}function z(e){return(e.depthAndFlags&bt)!==0}function Ct(e){return e.depthAndFlags&vt}function B(e,t){return(Ct(e)&t)!==0}function wt(e,t){e.depthAndFlags|=t}function Tt(e,t){e.depthAndFlags=L(t,Ct(e),R(e))}var Et=Symbol(`benchmarkInstrumentation`);function Dt(e,t){return t==null||Object.defineProperty(e,Et,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Ot(e){return e==null?null:e[Et]??null}function V(e,t,n){return e==null?n():e.measurePhase(t,n)}function kt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function At(e){return e>=48&&e<=57}function jt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!At(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&At(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Mt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:jt(t)}}function Nt(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Pt(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Nt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Ft(e,t,n){let r=Pt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function It(e,t){return Ft(e,t,Mt)}function Lt(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function Rt(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=Lt(e,r);return a===Lt(t,r)?It(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function zt(e,t){return Rt(e,t)}function Bt(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Mt(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=Lt(e,n);return o===Lt(t,n)?Ft(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function Vt(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Mt(r);return e.sortKeyById[t]=i,i}function Ht(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Ut(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function Wt(e){let{hasTrailingSlash:t,segments:n}=Ut(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function Gt(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Ut(e);return{requiresDirectory:t,segments:n}}var Kt=``;function qt(){let e=new Map;return e.set(Kt,0),{idByValue:e,valueById:[Kt],sortKeyById:[Mt(Kt)]}}function Jt(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function Yt(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Xt=Symbol(`pathStorePreparedInputKind`);function Zt(e,t){return e[Xt]=t,e}function Qt(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function $t(e,t,n){return n==="default"?zt(e,t):n(Qt(e),Qt(t))}function en(){return{depthAndFlags:L(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function tn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function nn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function rn(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function an(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function on(e,t={}){return fn(e,t).map(e=>e.path)}function sn(e,t={}){let n=fn(e,t);return Zt({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function cn(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return Zt({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function ln(e){let t=e,n=t.preparedPaths;if(t[Xt]===`prepared`&&n!=null)return n;if(!rn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function un(e){let t=e;return t[Xt]===`presorted`&&t.presortedPaths!=null||an(t.presortedPaths)?t.presortedPaths:null}function dn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function fn(e,t={}){let n=Ht(t),r=Ot(t);kt(r,`workload.inputFiles`,e.length);let i=V(r,`store.preparePathEntries.parse`,()=>e.map(e=>Wt(e)));return V(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>$t(e,t,n.sort))),i}var pn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[en()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=qt();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Ot(e),this.options=Ht(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,ct())}appendPaths(e){return V(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>Wt(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,V(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return V(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:L(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:L(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:L(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=Wt(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:L(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:L(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=Wt(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(V(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||V(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?Bt(this.lastPreparedPath,e,this.segmentSortKeyCache):$t(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=nn(e),i=n==null?0:nn(n),a=n==null?0:tn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=Jt(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),ft(i,s),s}createFileChildUnchecked(e,t){let n=Jt(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),ft(r,a),a}getOrCreateDirectoryChild(e,t){let n=Jt(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!z(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),ft(r,a),this.directories.set(a,ct()),a}createDirectoryChild(e,t){let n=Jt(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),ft(r,a),this.directories.set(a,ct()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!z(n))throw Error(`Path is not a directory: "${t}"`);if(B(n,1))throw Error(`Duplicate path: "${t}"`);wt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,lt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(z(a)){let t=lt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;z(n)&&this.directories.set(t,ct());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),ft(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!z(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return I(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function mn(e,t=`closed`,n=null){let r=gn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function hn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function gn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function _n(e,t){return B(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:St(t)<=e.defaultExpansion}function vn(e,t,n=e.snapshot.nodes[t]){return n==null||!z(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:_n(e,n)}function yn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!z(r))return;let i=_n(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function bn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function xn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Sn(e,t){let n=bn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Cn(e,t){let n=bn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function wn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Tn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function En(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Dn(e,t){e.directoryLoadInfoById.delete(t)}function On(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function kn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function An(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Mn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Nn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Pn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Fn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function In(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ln(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function Rn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function zn(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function Bn(e,t,n){return{...n,visibleCountDelta:Zn(e)-t}}function Vn(e,t){let n=Zn(e),r=hn();e.transactionStack.push(r);try{t()}catch(t){throw Wn(e,r,!1),t}Wn(e,r,!0,Zn(e)-n)}function Hn(e,t){let n=e.instrumentation;if(n==null){Un(e,t);return}V(n,`store.events.record`,()=>Un(e,t))}function Un(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){Yn(e,t);return}n.events.push(t),Jn(n,t)}function Wn(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?qn(i,t):V(n,`store.events.batch.merge`,()=>qn(i,t));return}let a=Gn(t,r),o=e.instrumentation;if(o==null){Yn(e,a);return}V(o,`store.events.batch.commit`,()=>Yn(e,a))}function Gn(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function Kn(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function qn(e,t){for(let n of t.events)e.events.push(n);Kn(e,t)}function Jn(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function Yn(e,t){let n=e.instrumentation;if(n==null){Xn(e,t);return}V(n,`store.events.emit`,()=>Xn(e,t))}function Xn(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Zn(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Qn(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!z(n)||B(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!z(a)?null:i}function $n(e,t){let n=t;for(;;){let t=Qn(e,n);if(t==null)return n;n=t}}function er(e,t){let n=[t],r=t;for(;;){let t=Qn(e,r);if(t==null)return n;n.push(t),r=t}}function tr(e,t){let n=t==null?e.snapshot.rootId:ur(e,t);return n==null?[]:fr(e,n)}function nr(e,t){let n=Wt(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Dr(e,Er(e,r)),{createdNodeIds:a,directoryId:o}=pr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=W(e,o);if(B(n,1))throw Error(`Path already exists: "${t}"`);wt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=hr(e,o,n.basename),s.add(c);sr(e,o);let l=Dr(e,o);return kn({affectedAncestorIds:lr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Or(i,l)})}function rr(e,t,n){let r=ur(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=W(e,r);if(B(i,2))throw Error(`The root node cannot be removed`);if(z(i)&&U(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Dr(e,a),s=wr(e,r);vr(e,a,r,i.nameId),Tr(e,a),sr(e,a);let c=Dr(e,a);return An({affectedAncestorIds:lr(e,a),affectedNodeIds:s,path:t,projectionChanged:Or(o,c),recursive:n.recursive===!0})}function ir(e,t,n,r){let i=ur(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=W(e,i);if(B(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Sr(e,i,n),c=Dr(e,a.parentId),l=Dr(e,s.parentId),u=Yt(e.snapshot.segmentTable,a.nameId),d=Jt(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(z(a)&&Mr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=ut(e.snapshot.nodes,U(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Cr(e,p,o,R(a))===`skip`)return null;let m=a.parentId;vr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),jr(e,i),_r(e,s.parentId,i),Tr(e,m),e.pathCacheVersion++,sr(e,m),s.parentId!==m&&sr(e,s.parentId);let h=Dr(e,m),g=Dr(e,s.parentId);return jn({affectedAncestorIds:[...new Set([...lr(e,m),...lr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:kr([c,l],[h,g]),to:H(e,i)})}function ar(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function or(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function H(e,t){let n=W(e,t),r=ar(e,t);if(r!=null)return r;if(B(n,2))return or(e,t,``);let i=H(e,n.parentId),a=Yt(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return or(e,t,z(n)?`${o}/`:o)}function sr(e,t){let n=e.instrumentation;if(n==null){Pr(e,t);return}V(n,`store.recomputeCountsUpwardFrom`,()=>Pr(e,t))}function cr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!z(o)){Nr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Nr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function lr(e,t){let n=[],r=t;for(;r!=null;){let t=W(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function ur(e,t){if(t.length===0)return e.snapshot.rootId;let n=Gt(t);return dr(e,n.segments,n.requiresDirectory)}function dr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=U(e,r),a=ut(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=W(e,r);return n&&!z(i)?null:r}function U(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function W(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function fr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))return[];if(!z(n))return[H(e,t)];if(U(e,t).childIds.length===0)return B(n,1)&&!B(n,2)?[H(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||B(n,4)){i.pop();continue}if(!z(n)){r.push(H(e,t.nodeId)),i.pop();continue}let a=U(e,t.nodeId);if(a.childIds.length===0){B(n,1)&&!B(n,2)&&r.push(H(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function pr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=Jt(e.snapshot.segmentTable,i),a=U(e,r),o=ut(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!z(W(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=mr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function mr(e,t,n){let r=W(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:L(St(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,ct()),_r(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function hr(e,t,n){let r=Jt(e.snapshot.segmentTable,n),i=U(e,t);if(ut(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Ir(e,t,n)}"`);let a=W(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:L(St(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),_r(e,t,o),e.activeNodeCount++,o}function gr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}yr(e,n,o)<0?i=a:r=a+1}return r}function _r(e,t,n){let r=U(e,t),i=W(e,n);ut(e.snapshot.nodes,r).set(i.nameId,n),pt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=gr(e,r,n);r.childIds.splice(a,0,n),F(r,a),gt(e.snapshot.nodes,r)}function vr(e,t,n,r){let i=U(e,t),a=dt(i),o=a.get(n)??-1;ut(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&pt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),F(i,o),gt(e.snapshot.nodes,i))}function yr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?br(e,t,n):r(xr(e,t),xr(e,n))}function br(e,t,n){let r=W(e,t),i=W(e,n),a=z(r);if(a!==z(i))return a?-1:1;let o=Pt(Vt(e.snapshot.segmentTable,r.nameId),Vt(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Yt(e.snapshot.segmentTable,r.nameId),c=Yt(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function xr(e,t){let n=W(e,t),r=H(e,t),i=z(n),a=i?r.slice(0,-1):r;return{basename:Yt(e.snapshot.segmentTable,n.nameId),depth:St(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Sr(e,t,n){let r=W(e,t),i=ur(e,n);if(i!=null){let t=W(e,i);if(z(t))return{basename:Yt(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=Gt(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=Gt(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:dr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Cr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${H(e,t)}"`);let i=W(e,t);if(R(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(z(i)&&U(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return wr(e,t),vr(e,a,t,o),Tr(e,a),sr(e,a),`handled`}function wr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=W(e,t.nodeId);if(t.visitedChildren||!z(i)){z(i)&&e.snapshot.directories.delete(t.nodeId),wt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Dn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=U(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Tr(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2)||U(e,n).childIds.length>0)return;wt(t,1),n=t.parentId===n?null:t.parentId}}function Er(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=ut(e.snapshot.nodes,U(e,n)).get(t);if(i==null||!z(W(e,i)))break;n=i}return n}function Dr(e,t){let n=Ar(e,t);if(n==null)return null;let r=$n(e,n),i=W(e,r),a=n===r?null:er(e,n).map(t=>H(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:U(e,r).childIds.length>0,path:H(e,r),terminalKind:R(i)})}function Or(e,t){return kr([e],[t])}function kr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function Ar(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2))return null;if(!vn(e,n,t))return n;n=t.parentId}return null}function jr(e,t){let n=W(e,t);if(Tt(n,(t===e.snapshot.rootId?-1:St(W(e,n.parentId)))+1),!z(n))return;let r=U(e,t);for(let t of r.childIds)jr(e,t)}function Mr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=W(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Nr(e,t,n=W(e,t),r=!1){let i=e.instrumentation;if(i==null){Fr(e,t,n,r);return}V(i,`store.recomputeNodeCounts`,()=>Fr(e,t,n,r))}function Pr(e,t){let n=t;for(;n!=null;){let t=W(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Nr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&pt(U(e,s),n,a,o),n=s}}function Fr(e,t,n,r){if(!z(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=U(e,t);if(r){let t=e.instrumentation;t==null?I(e.snapshot.nodes,i):V(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>I(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,B(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=Qn(e,t)==null?vn(e,t,n)?1+o:1:o}function Ir(e,t,n){let r=H(e,t);return r.length===0?n:`${r}${n}`}function Lr(e){return e!=null&&!B(e,4)}function Rr(e,t){let n=e.snapshot.nodes[t];return!Lr(n)||!z(n)||B(n,2)?null:n}function zr(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&Lr(e.snapshot.nodes[n])&&(t+=1);return t}function Br(e){return Math.max(0,e.valueById.length-1)}function Vr(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:zr(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:Br(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Hr(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function Ur(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)Rr(e,n)!=null&&t.push(H(e,n));for(let t of e.expandedDirectoryIds)Rr(e,t)!=null&&n.push(H(e,t));return{collapsedPaths:t,expandedPaths:n}}function Wr(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)Rr(e,n)==null||xn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:H(e,n)});return t}function Gr(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=ur(e,n);t!=null&&yn(e,t,!0,W(e,t))}for(let n of t.collapsedPaths){let t=ur(e,n);t!=null&&yn(e,t,!1,W(e,t))}}function Kr(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=ur(e,n.path);t!=null&&Rr(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function qr(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function Jr(e){let t=e.snapshot.segmentTable,n=qt();for(let r of e.snapshot.nodes)if(Lr(r)){if(B(r,2)){r.nameId=0;continue}r.nameId=Jt(n,Yt(t,r.nameId))}e.snapshot.segmentTable=n}function Yr(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Lr(r)||!z(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return Lr(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[W(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),I(e.snapshot.nodes,n)}}function Xr(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(Lr(n))break;--t}e.snapshot.nodes.length=t+1}function Zr(e){let t=Ur(e),n=Wr(e);V(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>qr(e)),V(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>Jr(e)),V(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Yr(e)),V(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Xr(e)),V(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Gr(e,t)),V(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>Kr(e,n)),V(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>cr(e,e.snapshot.rootId))}function Qr(e){let t=Ur(e),n=Wr(e),r=V(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>tr(e)),i=Dt({...e.snapshot.options},e.instrumentation),a=V(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new pn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,V(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>Gr(e,t)),V(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>Kr(e,n)),V(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>cr(e,e.snapshot.rootId))}function $r(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function ei(e,t){let n=Vr(e);t===`stable`?V(e.instrumentation,`store.cleanup.stable`,()=>Zr(e)):V(e.instrumentation,`store.cleanup.aggressive`,()=>Qr(e));let r=Vr(e);return Hr(t,t===`stable`,n,r)}var ti=64;function ni(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function ri(e){return W(e,e.snapshot.rootId).visibleSubtreeCount}function ii(e,t,n,r){let i=W(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function ai(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:wi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:ii(e,t.cursor,t.index,n)}}function oi(e,t,n,r,i,a){let o=U(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=mt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return si(e,u,l,r+c,i+1,s,o.childIds.length,a)}function si(e,t,n,r,i,a,o,s){if(!z(W(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=vi(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=W(e,c.terminalNodeId);if(!z(l)||!vn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return oi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function ci(e,t){let n=ri(e);if(t<0||t>=n)return null;let r=oi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>H(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=ai(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:wi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:ii(e,r.cursor,r.index,n)}}function li(e,t,n){let r=e.instrumentation,i=ri(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Ci(e,o+1);let t=[],n=hi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=wi(e,n);t.push(r),n=bi(e,n)}return t}let s=[],c=0,l=0,u=V(r,`store.getVisibleSlice.selectFirstRow`,()=>hi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=V(r,`store.getVisibleSlice.materializeRow`,()=>wi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=V(r,`store.getVisibleSlice.advanceCursor`,()=>bi(e,u))}return kt(r,`workload.visibleRowsRead`,s.length),kt(r,`workload.flattenedRowsRead`,c),kt(r,`workload.flattenedSegmentsRead`,l),s}function ui(e,t=ri(e)){let n=e.instrumentation;return n==null?Si(e,t):V(n,`store.getVisibleTreeProjection`,()=>Si(e,t))}function di(e){return xi(ui(e))}function fi(e,t){let n=ur(e,t);if(n==null||n===e.snapshot.rootId||z(W(e,n))&&$n(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=W(e,i).parentId,n=U(e,t),s=dt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=ht(a,n,s),t!==o){let n=W(e,t),a=Qn(e,t);if(!vn(e,t,n)&&a!==i)return null;$n(e,t)===t&&(r+=1)}i=t}return r}function pi(e,t){let n=ur(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return vn(e,n,r)?null:(yn(e,n,!0,r),sr(e,n),Mn({affectedAncestorIds:lr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function mi(e,t){let n=ur(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return vn(e,n,r)?(yn(e,n,!1,r),sr(e,n),Nn({affectedAncestorIds:lr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function hi(e,t){return t<0||t>=ri(e)?null:gi(e,e.snapshot.rootId,t,-1)}function gi(e,t,n,r){let i=U(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?mt(e.snapshot.nodes,i,n):V(a,`store.getVisibleSlice.selectChildIndex`,()=>mt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return _i(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function _i(e,t,n,r){if(!z(W(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=vi(e,t,r);if(n===0)return i;let a=W(e,i.terminalNodeId);if(!z(a)||!vn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return gi(e,i.terminalNodeId,n-1,i.visibleDepth)}function vi(e,t,n){return z(W(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:$n(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:V(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>$n(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function yi(e,t){let n=W(e,t);if(!z(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:Qn(e,r)!==t}function bi(e,t){let n=W(e,t.terminalNodeId);if(z(n)){let r=U(e,t.terminalNodeId);if(vn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:_i(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=W(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=U(e,n),o=dt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return _i(e,s,0,i);yi(e,r)&&i--,r=n}}function xi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Si(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(ti);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=ni(o,y);let x,S=_;if(z(v))S=f?$n(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:H(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&z(C)&&vn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Ci(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!z(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:H(e,f)};continue}let h=l?$n(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=wi(e,g);let _=i[h];_!=null&&z(_)&&vn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function wi(e,t){let n=W(e,t.terminalNodeId),r=z(n)?Ti(e,t):null,i=H(e,t.terminalNodeId),a=Yt(e.snapshot.segmentTable,n.nameId),o=z(n)&&U(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Yt(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}}):V(c,`store.getVisibleSlice.flatten.collectSegments`,()=>er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Yt(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:z(n)&&vn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:z(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Ti(e,t){if(t.headNodeId===t.terminalNodeId)return xn(e,t.terminalNodeId);let n=er(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=xn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Ei(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!z(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&gt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&z(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,gt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Di(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Oi=class e{#e;constructor(e={}){let t=Ot(e),n=V(t,`store.builder.create`,()=>new pn(e));if(e.preparedInput!=null){let t=un(e.preparedInput);t==null?n.appendPreparedPaths(ln(e.preparedInput),!1):n.appendPresortedPaths(t,dn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(V(t,`store.preparePathEntries`,()=>fn(r,e)))}let r=V(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=V(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=V(t,`store.state.create`,()=>mn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:V(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Di(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&V(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?V(t,`store.state.initializeOpenVisibleCounts`,()=>Ei(this.#e)):V(t,`store.state.recomputeCounts`,()=>cr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return on(e,t)}static prepareInput(e,t={}){return sn(e,t)}static preparePresortedInput(e){return cn(e)}list(e){return V(this.#e.instrumentation,`store.list`,()=>tr(this.#e,e))}add(e){V(this.#e.instrumentation,`store.add`,()=>{let t=ri(this.#e);Hn(this.#e,Bn(this.#e,t,nr(this.#e,e)))})}remove(e,t={}){V(this.#e.instrumentation,`store.remove`,()=>{let n=ri(this.#e);Hn(this.#e,Bn(this.#e,n,rr(this.#e,e,t)))})}move(e,t,n={}){V(this.#e.instrumentation,`store.move`,()=>{let r=ri(this.#e),i=ir(this.#e,e,t,n);i!=null&&Hn(this.#e,Bn(this.#e,r,i))})}batch(e){Vn(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return V(this.#e.instrumentation,`store.getVisibleCount`,()=>ri(this.#e))}getVisibleSlice(e,t){return V(this.#e.instrumentation,`store.getVisibleSlice`,()=>li(this.#e,e,t))}getVisibleRowContext(e){return V(this.#e.instrumentation,`store.getVisibleRowContext`,()=>ci(this.#e,e))}getVisibleTreeProjection(){return di(this.#e)}getVisibleTreeProjectionData(e){return ui(this.#e,e)}getVisibleIndex(e){return V(this.#e.instrumentation,`store.getVisibleIndex`,()=>fi(this.#e,e))}getPathInfo(e){return V(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=ur(this.#e,e);if(t==null)return null;let n=W(this.#e,t);return{depth:St(n),kind:z(n)?`directory`:`file`,path:H(this.#e,t)}})}isExpanded(e){return V(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=W(this.#e,t);return vn(this.#e,t,n)})}expand(e){V(this.#e.instrumentation,`store.expand`,()=>{let t=ri(this.#e),n=pi(this.#e,e);n!=null&&Hn(this.#e,Bn(this.#e,t,n))})}collapse(e){V(this.#e.instrumentation,`store.collapse`,()=>{let t=ri(this.#e),n=mi(this.#e,e);n!=null&&Hn(this.#e,Bn(this.#e,t,n))})}on(e,t){return On(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return xn(this.#e,t)}markDirectoryUnloaded(e){V(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(U(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=ri(this.#e);Cn(this.#e,t),Hn(this.#e,Bn(this.#e,n,Pn({affectedAncestorIds:lr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return V(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=ri(this.#e),r=Sn(this.#e,t);return Hn(this.#e,Bn(this.#e,n,Fn({affectedAncestorIds:lr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return V(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||xn(this.#e,n)!==`loading`||!Tn(this.#e,n,e.attemptId))return!1;let r=H(this.#e,n);this.validateChildPatch(r,t);let i=ri(this.#e),a=[];for(let e of t.operations){ki(r,e);let t=ri(this.#e);switch(e.type){case`add`:a.push(Bn(this.#e,t,nr(this.#e,e.path)));break;case`remove`:a.push(Bn(this.#e,t,rr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=ir(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(Bn(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return Hn(this.#e,Bn(this.#e,i,In({affectedAncestorIds:lr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:H(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return V(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=ri(this.#e),r=wn(this.#e,t,e.attemptId);return Hn(this.#e,Bn(this.#e,n,Ln({affectedAncestorIds:lr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:H(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return V(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=ri(this.#e),i=En(this.#e,n,e.attemptId,t);return Hn(this.#e,Bn(this.#e,r,Rn({affectedAncestorIds:lr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:H(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return V(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if($r(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=ri(this.#e),n=ei(this.#e,e.mode??`stable`);return Hn(this.#e,Bn(this.#e,t,zn({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=U(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Mt(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Pt(Vt(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!z(W(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=W(this.#e,n);vn(this.#e,n,i)||(yn(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=W(this.#e,e);if(!vn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=ur(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!z(W(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!z(W(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=W(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=W(this.#e,e),r=Qn(this.#e,e);if(!vn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function ki(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var Ai={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function ji(e,t){if(typeof e==`number`)return{itemHeight:t??Ai.default.itemHeight,factor:e};let n=Ai[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Mi=Ai.default.itemHeight,Ni=`@layer base, theme, unsafe;
1
+ import{$t as e,C as t,E as n,Go as r,Ho as i,Jt as a,Kl as o,Pf as s,Pt as c,Ts as l,Uf as u,as as d,b as f,bs as p,g as m,is as h,lp as g,m as _,op as v,p as y,v as b}from"./textarea-lBMORu4g.js";import{a as x,c as S,i as C,n as ee,o as w,r as T,s as E,t as te}from"./fileCommentAnnotations-KGEG7lCT.js";import{C as ne,Cn as D,Ct as O,D as k,Dn as A,Dt as j,En as M,Fr as re,Gn as ie,H as ae,Hn as oe,Nr as se,Qn as ce,Qt as le,Rt as ue,S as de,Sn as fe,Sr as pe,Tn as me,Tr as N,Tt as he,U as ge,V as _e,W as ve,Wn as ye,X as be,b as xe,bn as Se,d as Ce,dr as we,f as Te,fr as Ee,jr as De,l as P,ln as Oe,lr as ke,m as Ae,mr as je,p as Me,pn as Ne,pr as Pe,qn as Fe,u as Ie,ur as Le,v as Re,vr as ze,w as Be,x as Ve,xn as He,y as Ue,yn as We,yr as Ge,z as Ke,zt as qe}from"./index-Cxz8lImj.js";var Je=r(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ye=r(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Xe=`file-tree-container`,Ze=`data-file-tree-style`,Qe=`data-file-tree-unsafe-css`,$e=`data-file-tree-scrollbar-measure`,et=`data-file-tree-scrollbar-gutter-measured`,tt=`--trees-scrollbar-gutter-measured`,nt=`header`,rt=`context-menu`,it=`context-menu-trigger`,at=5,ot=1<<at,st=ot*4;function ct(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function lt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function ut(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function dt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function ft(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function F(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function I(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,gt(e,t)}function pt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=dt(e).get(t);if(i===void 0)return;let a=i>>at;e.childVisibleChunkSums[a]+=r}function mt(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=_t(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=ot}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function ht(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>at;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<at}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function gt(e,t){if(t.childIds.length<st){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/ot),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>at]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function _t(e,t,n,r){let i=Math.min(t.childIds.length,n+ot),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var vt=7,yt=3,bt=1<<yt,xt=4;function L(e,t,n=0){return e<<xt|n<<yt|t}function St(e){return e.depthAndFlags>>>xt}function R(e){return(e.depthAndFlags&bt)>>yt}function z(e){return(e.depthAndFlags&bt)!==0}function Ct(e){return e.depthAndFlags&vt}function B(e,t){return(Ct(e)&t)!==0}function wt(e,t){e.depthAndFlags|=t}function Tt(e,t){e.depthAndFlags=L(t,Ct(e),R(e))}var Et=Symbol(`benchmarkInstrumentation`);function Dt(e,t){return t==null||Object.defineProperty(e,Et,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Ot(e){return e==null?null:e[Et]??null}function V(e,t,n){return e==null?n():e.measurePhase(t,n)}function kt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function At(e){return e>=48&&e<=57}function jt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!At(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&At(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Mt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:jt(t)}}function Nt(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Pt(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Nt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Ft(e,t,n){let r=Pt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function It(e,t){return Ft(e,t,Mt)}function Lt(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function Rt(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=Lt(e,r);return a===Lt(t,r)?It(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function zt(e,t){return Rt(e,t)}function Bt(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Mt(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=Lt(e,n);return o===Lt(t,n)?Ft(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function Vt(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Mt(r);return e.sortKeyById[t]=i,i}function Ht(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function Ut(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function Wt(e){let{hasTrailingSlash:t,segments:n}=Ut(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function Gt(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Ut(e);return{requiresDirectory:t,segments:n}}var Kt=``;function qt(){let e=new Map;return e.set(Kt,0),{idByValue:e,valueById:[Kt],sortKeyById:[Mt(Kt)]}}function Jt(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function Yt(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Xt=Symbol(`pathStorePreparedInputKind`);function Zt(e,t){return e[Xt]=t,e}function Qt(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function $t(e,t,n){return n==="default"?zt(e,t):n(Qt(e),Qt(t))}function en(){return{depthAndFlags:L(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function tn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function nn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function rn(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function an(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function on(e,t={}){return fn(e,t).map(e=>e.path)}function sn(e,t={}){let n=fn(e,t);return Zt({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function cn(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return Zt({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function ln(e){let t=e,n=t.preparedPaths;if(t[Xt]===`prepared`&&n!=null)return n;if(!rn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function un(e){let t=e;return t[Xt]===`presorted`&&t.presortedPaths!=null||an(t.presortedPaths)?t.presortedPaths:null}function dn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function fn(e,t={}){let n=Ht(t),r=Ot(t);kt(r,`workload.inputFiles`,e.length);let i=V(r,`store.preparePathEntries.parse`,()=>e.map(e=>Wt(e)));return V(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>$t(e,t,n.sort))),i}var pn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[en()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=qt();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Ot(e),this.options=Ht(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,ct())}appendPaths(e){return V(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>Wt(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,V(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return V(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:L(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:L(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:L(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=Wt(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:L(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:L(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=Wt(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(V(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||V(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?Bt(this.lastPreparedPath,e,this.segmentSortKeyCache):$t(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=nn(e),i=n==null?0:nn(n),a=n==null?0:tn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=Jt(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),ft(i,s),s}createFileChildUnchecked(e,t){let n=Jt(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),ft(r,a),a}getOrCreateDirectoryChild(e,t){let n=Jt(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!z(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),ft(r,a),this.directories.set(a,ct()),a}createDirectoryChild(e,t){let n=Jt(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:L(St(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),ft(r,a),this.directories.set(a,ct()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!z(n))throw Error(`Path is not a directory: "${t}"`);if(B(n,1))throw Error(`Duplicate path: "${t}"`);wt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,lt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(z(a)){let t=lt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;z(n)&&this.directories.set(t,ct());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),ft(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!z(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return I(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function mn(e,t=`closed`,n=null){let r=gn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function hn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function gn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function _n(e,t){return B(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:St(t)<=e.defaultExpansion}function vn(e,t,n=e.snapshot.nodes[t]){return n==null||!z(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:_n(e,n)}function yn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!z(r))return;let i=_n(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function bn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function xn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Sn(e,t){let n=bn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Cn(e,t){let n=bn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function wn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Tn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function En(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Dn(e,t){e.directoryLoadInfoById.delete(t)}function On(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function kn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function An(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Mn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Nn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Pn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Fn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function In(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ln(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function Rn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function zn(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function Bn(e,t,n){return{...n,visibleCountDelta:Zn(e)-t}}function Vn(e,t){let n=Zn(e),r=hn();e.transactionStack.push(r);try{t()}catch(t){throw Wn(e,r,!1),t}Wn(e,r,!0,Zn(e)-n)}function Hn(e,t){let n=e.instrumentation;if(n==null){Un(e,t);return}V(n,`store.events.record`,()=>Un(e,t))}function Un(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){Yn(e,t);return}n.events.push(t),Jn(n,t)}function Wn(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?qn(i,t):V(n,`store.events.batch.merge`,()=>qn(i,t));return}let a=Gn(t,r),o=e.instrumentation;if(o==null){Yn(e,a);return}V(o,`store.events.batch.commit`,()=>Yn(e,a))}function Gn(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function Kn(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function qn(e,t){for(let n of t.events)e.events.push(n);Kn(e,t)}function Jn(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function Yn(e,t){let n=e.instrumentation;if(n==null){Xn(e,t);return}V(n,`store.events.emit`,()=>Xn(e,t))}function Xn(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Zn(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Qn(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!z(n)||B(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!z(a)?null:i}function $n(e,t){let n=t;for(;;){let t=Qn(e,n);if(t==null)return n;n=t}}function er(e,t){let n=[t],r=t;for(;;){let t=Qn(e,r);if(t==null)return n;n.push(t),r=t}}function tr(e,t){let n=t==null?e.snapshot.rootId:ur(e,t);return n==null?[]:fr(e,n)}function nr(e,t){let n=Wt(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Dr(e,Er(e,r)),{createdNodeIds:a,directoryId:o}=pr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=W(e,o);if(B(n,1))throw Error(`Path already exists: "${t}"`);wt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=hr(e,o,n.basename),s.add(c);sr(e,o);let l=Dr(e,o);return kn({affectedAncestorIds:lr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Or(i,l)})}function rr(e,t,n){let r=ur(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=W(e,r);if(B(i,2))throw Error(`The root node cannot be removed`);if(z(i)&&U(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Dr(e,a),s=wr(e,r);vr(e,a,r,i.nameId),Tr(e,a),sr(e,a);let c=Dr(e,a);return An({affectedAncestorIds:lr(e,a),affectedNodeIds:s,path:t,projectionChanged:Or(o,c),recursive:n.recursive===!0})}function ir(e,t,n,r){let i=ur(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=W(e,i);if(B(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Sr(e,i,n),c=Dr(e,a.parentId),l=Dr(e,s.parentId),u=Yt(e.snapshot.segmentTable,a.nameId),d=Jt(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(z(a)&&Mr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=ut(e.snapshot.nodes,U(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Cr(e,p,o,R(a))===`skip`)return null;let m=a.parentId;vr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),jr(e,i),_r(e,s.parentId,i),Tr(e,m),e.pathCacheVersion++,sr(e,m),s.parentId!==m&&sr(e,s.parentId);let h=Dr(e,m),g=Dr(e,s.parentId);return jn({affectedAncestorIds:[...new Set([...lr(e,m),...lr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:kr([c,l],[h,g]),to:H(e,i)})}function ar(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function or(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function H(e,t){let n=W(e,t),r=ar(e,t);if(r!=null)return r;if(B(n,2))return or(e,t,``);let i=H(e,n.parentId),a=Yt(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return or(e,t,z(n)?`${o}/`:o)}function sr(e,t){let n=e.instrumentation;if(n==null){Pr(e,t);return}V(n,`store.recomputeCountsUpwardFrom`,()=>Pr(e,t))}function cr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!z(o)){Nr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Nr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function lr(e,t){let n=[],r=t;for(;r!=null;){let t=W(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function ur(e,t){if(t.length===0)return e.snapshot.rootId;let n=Gt(t);return dr(e,n.segments,n.requiresDirectory)}function dr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=U(e,r),a=ut(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=W(e,r);return n&&!z(i)?null:r}function U(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function W(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function fr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))return[];if(!z(n))return[H(e,t)];if(U(e,t).childIds.length===0)return B(n,1)&&!B(n,2)?[H(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||B(n,4)){i.pop();continue}if(!z(n)){r.push(H(e,t.nodeId)),i.pop();continue}let a=U(e,t.nodeId);if(a.childIds.length===0){B(n,1)&&!B(n,2)&&r.push(H(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function pr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=Jt(e.snapshot.segmentTable,i),a=U(e,r),o=ut(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!z(W(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=mr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function mr(e,t,n){let r=W(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:L(St(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,ct()),_r(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function hr(e,t,n){let r=Jt(e.snapshot.segmentTable,n),i=U(e,t);if(ut(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${Ir(e,t,n)}"`);let a=W(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:L(St(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),_r(e,t,o),e.activeNodeCount++,o}function gr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}yr(e,n,o)<0?i=a:r=a+1}return r}function _r(e,t,n){let r=U(e,t),i=W(e,n);ut(e.snapshot.nodes,r).set(i.nameId,n),pt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=gr(e,r,n);r.childIds.splice(a,0,n),F(r,a),gt(e.snapshot.nodes,r)}function vr(e,t,n,r){let i=U(e,t),a=dt(i),o=a.get(n)??-1;ut(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&pt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),F(i,o),gt(e.snapshot.nodes,i))}function yr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?br(e,t,n):r(xr(e,t),xr(e,n))}function br(e,t,n){let r=W(e,t),i=W(e,n),a=z(r);if(a!==z(i))return a?-1:1;let o=Pt(Vt(e.snapshot.segmentTable,r.nameId),Vt(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Yt(e.snapshot.segmentTable,r.nameId),c=Yt(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function xr(e,t){let n=W(e,t),r=H(e,t),i=z(n),a=i?r.slice(0,-1):r;return{basename:Yt(e.snapshot.segmentTable,n.nameId),depth:St(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Sr(e,t,n){let r=W(e,t),i=ur(e,n);if(i!=null){let t=W(e,i);if(z(t))return{basename:Yt(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=Gt(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=Gt(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:dr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Cr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${H(e,t)}"`);let i=W(e,t);if(R(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(z(i)&&U(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return wr(e,t),vr(e,a,t,o),Tr(e,a),sr(e,a),`handled`}function wr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=W(e,t.nodeId);if(t.visitedChildren||!z(i)){z(i)&&e.snapshot.directories.delete(t.nodeId),wt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Dn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=U(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Tr(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2)||U(e,n).childIds.length>0)return;wt(t,1),n=t.parentId===n?null:t.parentId}}function Er(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=ut(e.snapshot.nodes,U(e,n)).get(t);if(i==null||!z(W(e,i)))break;n=i}return n}function Dr(e,t){let n=Ar(e,t);if(n==null)return null;let r=$n(e,n),i=W(e,r),a=n===r?null:er(e,n).map(t=>H(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:U(e,r).childIds.length>0,path:H(e,r),terminalKind:R(i)})}function Or(e,t){return kr([e],[t])}function kr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function Ar(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2))return null;if(!vn(e,n,t))return n;n=t.parentId}return null}function jr(e,t){let n=W(e,t);if(Tt(n,(t===e.snapshot.rootId?-1:St(W(e,n.parentId)))+1),!z(n))return;let r=U(e,t);for(let t of r.childIds)jr(e,t)}function Mr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=W(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Nr(e,t,n=W(e,t),r=!1){let i=e.instrumentation;if(i==null){Fr(e,t,n,r);return}V(i,`store.recomputeNodeCounts`,()=>Fr(e,t,n,r))}function Pr(e,t){let n=t;for(;n!=null;){let t=W(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Nr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&pt(U(e,s),n,a,o),n=s}}function Fr(e,t,n,r){if(!z(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=U(e,t);if(r){let t=e.instrumentation;t==null?I(e.snapshot.nodes,i):V(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>I(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,B(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=Qn(e,t)==null?vn(e,t,n)?1+o:1:o}function Ir(e,t,n){let r=H(e,t);return r.length===0?n:`${r}${n}`}function Lr(e){return e!=null&&!B(e,4)}function Rr(e,t){let n=e.snapshot.nodes[t];return!Lr(n)||!z(n)||B(n,2)?null:n}function zr(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&Lr(e.snapshot.nodes[n])&&(t+=1);return t}function Br(e){return Math.max(0,e.valueById.length-1)}function Vr(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:zr(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:Br(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function Hr(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function Ur(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)Rr(e,n)!=null&&t.push(H(e,n));for(let t of e.expandedDirectoryIds)Rr(e,t)!=null&&n.push(H(e,t));return{collapsedPaths:t,expandedPaths:n}}function Wr(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)Rr(e,n)==null||xn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:H(e,n)});return t}function Gr(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=ur(e,n);t!=null&&yn(e,t,!0,W(e,t))}for(let n of t.collapsedPaths){let t=ur(e,n);t!=null&&yn(e,t,!1,W(e,t))}}function Kr(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=ur(e,n.path);t!=null&&Rr(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function qr(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function Jr(e){let t=e.snapshot.segmentTable,n=qt();for(let r of e.snapshot.nodes)if(Lr(r)){if(B(r,2)){r.nameId=0;continue}r.nameId=Jt(n,Yt(t,r.nameId))}e.snapshot.segmentTable=n}function Yr(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Lr(r)||!z(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return Lr(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[W(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),I(e.snapshot.nodes,n)}}function Xr(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(Lr(n))break;--t}e.snapshot.nodes.length=t+1}function Zr(e){let t=Ur(e),n=Wr(e);V(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>qr(e)),V(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>Jr(e)),V(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>Yr(e)),V(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Xr(e)),V(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>Gr(e,t)),V(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>Kr(e,n)),V(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>cr(e,e.snapshot.rootId))}function Qr(e){let t=Ur(e),n=Wr(e),r=V(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>tr(e)),i=Dt({...e.snapshot.options},e.instrumentation),a=V(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new pn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,V(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>Gr(e,t)),V(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>Kr(e,n)),V(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>cr(e,e.snapshot.rootId))}function $r(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function ei(e,t){let n=Vr(e);t===`stable`?V(e.instrumentation,`store.cleanup.stable`,()=>Zr(e)):V(e.instrumentation,`store.cleanup.aggressive`,()=>Qr(e));let r=Vr(e);return Hr(t,t===`stable`,n,r)}var ti=64;function ni(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function ri(e){return W(e,e.snapshot.rootId).visibleSubtreeCount}function ii(e,t,n,r){let i=W(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function ai(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:wi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:ii(e,t.cursor,t.index,n)}}function oi(e,t,n,r,i,a){let o=U(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=mt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return si(e,u,l,r+c,i+1,s,o.childIds.length,a)}function si(e,t,n,r,i,a,o,s){if(!z(W(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=vi(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=W(e,c.terminalNodeId);if(!z(l)||!vn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return oi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function ci(e,t){let n=ri(e);if(t<0||t>=n)return null;let r=oi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>H(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=ai(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:wi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:ii(e,r.cursor,r.index,n)}}function li(e,t,n){let r=e.instrumentation,i=ri(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Ci(e,o+1);let t=[],n=hi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=wi(e,n);t.push(r),n=bi(e,n)}return t}let s=[],c=0,l=0,u=V(r,`store.getVisibleSlice.selectFirstRow`,()=>hi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=V(r,`store.getVisibleSlice.materializeRow`,()=>wi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=V(r,`store.getVisibleSlice.advanceCursor`,()=>bi(e,u))}return kt(r,`workload.visibleRowsRead`,s.length),kt(r,`workload.flattenedRowsRead`,c),kt(r,`workload.flattenedSegmentsRead`,l),s}function ui(e,t=ri(e)){let n=e.instrumentation;return n==null?Si(e,t):V(n,`store.getVisibleTreeProjection`,()=>Si(e,t))}function di(e){return xi(ui(e))}function fi(e,t){let n=ur(e,t);if(n==null||n===e.snapshot.rootId||z(W(e,n))&&$n(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=W(e,i).parentId,n=U(e,t),s=dt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=ht(a,n,s),t!==o){let n=W(e,t),a=Qn(e,t);if(!vn(e,t,n)&&a!==i)return null;$n(e,t)===t&&(r+=1)}i=t}return r}function pi(e,t){let n=ur(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return vn(e,n,r)?null:(yn(e,n,!0,r),sr(e,n),Mn({affectedAncestorIds:lr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function mi(e,t){let n=ur(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return vn(e,n,r)?(yn(e,n,!1,r),sr(e,n),Nn({affectedAncestorIds:lr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function hi(e,t){return t<0||t>=ri(e)?null:gi(e,e.snapshot.rootId,t,-1)}function gi(e,t,n,r){let i=U(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?mt(e.snapshot.nodes,i,n):V(a,`store.getVisibleSlice.selectChildIndex`,()=>mt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return _i(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function _i(e,t,n,r){if(!z(W(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=vi(e,t,r);if(n===0)return i;let a=W(e,i.terminalNodeId);if(!z(a)||!vn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return gi(e,i.terminalNodeId,n-1,i.visibleDepth)}function vi(e,t,n){return z(W(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:$n(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:V(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>$n(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function yi(e,t){let n=W(e,t);if(!z(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:Qn(e,r)!==t}function bi(e,t){let n=W(e,t.terminalNodeId);if(z(n)){let r=U(e,t.terminalNodeId);if(vn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:_i(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=W(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=U(e,n),o=dt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return _i(e,s,0,i);yi(e,r)&&i--,r=n}}function xi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Si(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(ti);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=ni(o,y);let x,S=_;if(z(v))S=f?$n(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:H(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&z(C)&&vn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Ci(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!z(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:H(e,f)};continue}let h=l?$n(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=wi(e,g);let _=i[h];_!=null&&z(_)&&vn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function wi(e,t){let n=W(e,t.terminalNodeId),r=z(n)?Ti(e,t):null,i=H(e,t.terminalNodeId),a=Yt(e.snapshot.segmentTable,n.nameId),o=z(n)&&U(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Yt(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}}):V(c,`store.getVisibleSlice.flatten.collectSegments`,()=>er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Yt(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:z(n)&&vn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:z(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Ti(e,t){if(t.headNodeId===t.terminalNodeId)return xn(e,t.terminalNodeId);let n=er(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=xn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Ei(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!z(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&gt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&z(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,gt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Di(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Oi=class e{#e;constructor(e={}){let t=Ot(e),n=V(t,`store.builder.create`,()=>new pn(e));if(e.preparedInput!=null){let t=un(e.preparedInput);t==null?n.appendPreparedPaths(ln(e.preparedInput),!1):n.appendPresortedPaths(t,dn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(V(t,`store.preparePathEntries`,()=>fn(r,e)))}let r=V(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=V(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=V(t,`store.state.create`,()=>mn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:V(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Di(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&V(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?V(t,`store.state.initializeOpenVisibleCounts`,()=>Ei(this.#e)):V(t,`store.state.recomputeCounts`,()=>cr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return on(e,t)}static prepareInput(e,t={}){return sn(e,t)}static preparePresortedInput(e){return cn(e)}list(e){return V(this.#e.instrumentation,`store.list`,()=>tr(this.#e,e))}add(e){V(this.#e.instrumentation,`store.add`,()=>{let t=ri(this.#e);Hn(this.#e,Bn(this.#e,t,nr(this.#e,e)))})}remove(e,t={}){V(this.#e.instrumentation,`store.remove`,()=>{let n=ri(this.#e);Hn(this.#e,Bn(this.#e,n,rr(this.#e,e,t)))})}move(e,t,n={}){V(this.#e.instrumentation,`store.move`,()=>{let r=ri(this.#e),i=ir(this.#e,e,t,n);i!=null&&Hn(this.#e,Bn(this.#e,r,i))})}batch(e){Vn(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return V(this.#e.instrumentation,`store.getVisibleCount`,()=>ri(this.#e))}getVisibleSlice(e,t){return V(this.#e.instrumentation,`store.getVisibleSlice`,()=>li(this.#e,e,t))}getVisibleRowContext(e){return V(this.#e.instrumentation,`store.getVisibleRowContext`,()=>ci(this.#e,e))}getVisibleTreeProjection(){return di(this.#e)}getVisibleTreeProjectionData(e){return ui(this.#e,e)}getVisibleIndex(e){return V(this.#e.instrumentation,`store.getVisibleIndex`,()=>fi(this.#e,e))}getPathInfo(e){return V(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=ur(this.#e,e);if(t==null)return null;let n=W(this.#e,t);return{depth:St(n),kind:z(n)?`directory`:`file`,path:H(this.#e,t)}})}isExpanded(e){return V(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=W(this.#e,t);return vn(this.#e,t,n)})}expand(e){V(this.#e.instrumentation,`store.expand`,()=>{let t=ri(this.#e),n=pi(this.#e,e);n!=null&&Hn(this.#e,Bn(this.#e,t,n))})}collapse(e){V(this.#e.instrumentation,`store.collapse`,()=>{let t=ri(this.#e),n=mi(this.#e,e);n!=null&&Hn(this.#e,Bn(this.#e,t,n))})}on(e,t){return On(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return xn(this.#e,t)}markDirectoryUnloaded(e){V(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(U(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=ri(this.#e);Cn(this.#e,t),Hn(this.#e,Bn(this.#e,n,Pn({affectedAncestorIds:lr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return V(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=ri(this.#e),r=Sn(this.#e,t);return Hn(this.#e,Bn(this.#e,n,Fn({affectedAncestorIds:lr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return V(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||xn(this.#e,n)!==`loading`||!Tn(this.#e,n,e.attemptId))return!1;let r=H(this.#e,n);this.validateChildPatch(r,t);let i=ri(this.#e),a=[];for(let e of t.operations){ki(r,e);let t=ri(this.#e);switch(e.type){case`add`:a.push(Bn(this.#e,t,nr(this.#e,e.path)));break;case`remove`:a.push(Bn(this.#e,t,rr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=ir(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(Bn(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return Hn(this.#e,Bn(this.#e,i,In({affectedAncestorIds:lr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:H(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return V(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=ri(this.#e),r=wn(this.#e,t,e.attemptId);return Hn(this.#e,Bn(this.#e,n,Ln({affectedAncestorIds:lr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:H(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return V(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=ri(this.#e),i=En(this.#e,n,e.attemptId,t);return Hn(this.#e,Bn(this.#e,r,Rn({affectedAncestorIds:lr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:H(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return V(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if($r(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=ri(this.#e),n=ei(this.#e,e.mode??`stable`);return Hn(this.#e,Bn(this.#e,t,zn({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=U(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Mt(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Pt(Vt(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!z(W(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=W(this.#e,n);vn(this.#e,n,i)||(yn(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=W(this.#e,e);if(!vn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=ur(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!z(W(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!z(W(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=W(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=W(this.#e,e),r=Qn(this.#e,e);if(!vn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function ki(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var Ai={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function ji(e,t){if(typeof e==`number`)return{itemHeight:t??Ai.default.itemHeight,factor:e};let n=Ai[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Mi=Ai.default.itemHeight,Ni=`@layer base, theme, unsafe;
2
2
 
3
3
  @layer base {
4
4
  :host {
@@ -1775,4 +1775,4 @@ import{$t as e,C as t,E as n,Go as r,Ho as i,Jt as a,Kl as o,Pf as s,Pt as c,Ts
1775
1775
  color: var(--diffs-selection-number-fg) !important;
1776
1776
  }
1777
1777
  `;function gf(e){let t=(0,kl.c)(8),n;t[0]!==e.absolutePath||t[1]!==e.threadRef.threadId?(n={_tag:`workspace-file`,threadId:e.threadRef.threadId,path:e.absolutePath},t[0]=e.absolutePath,t[1]=e.threadRef.threadId,t[2]=n):n=t[2];let r=Pe(e.environmentId,n),[i,a]=(0,X.useState)(null);if(r._tag===`Failure`||r._tag===`Success`&&i===r.url){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[3]=e):e=t[3],e}let o;return t[4]!==r._tag||t[5]!==r.url||t[6]!==e.alt?(o=r._tag===`Success`?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Z.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:r.url,alt:e.alt,onError:()=>a(r.url)})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Z.jsx)(De,{className:`size-5 animate-spin`})}),t[4]=r._tag,t[5]=r.url,t[6]=e.alt,t[7]=o):o=t[7],o}function _f(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function vf(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${mf}]`))e.removeAttribute(mf);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(mf,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(mf,``))}function yf(e,t,n){let r=(0,kl.c)(7),[i]=(0,X.useState)(Sf),[a]=(0,X.useState)(xf),[o]=(0,X.useState)(bf),s;return r[0]!==i||r[1]!==a||r[2]!==o||r[3]!==e||r[4]!==t||r[5]!==n?(s=(r,s,c)=>{if(e===null)return;let l=()=>{let t=o.get(e);t!==void 0&&(cancelAnimationFrame(t),o.delete(e))};if(c===`unmount`){l();return}let u=t===null?null:_f(s.file?.contents??``,t);if(vf(r,u),!(s instanceof E))return;if(a.get(e)!==n&&(l(),a.set(e,n)),u===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);!d||(r.style.minHeight=`${Math.ceil(Math.max(s.height,d.clientHeight))}px`,i.get(e)===n||o.has(e))||o.set(e,requestAnimationFrame(()=>{if(o.delete(e),a.get(e)!==n||!r.isConnected)return;let t=s.getLinePosition(u);if(!t)return;let c=d.scrollTop+r.getBoundingClientRect().top-d.getBoundingClientRect().top,l=Math.max(0,c+t.top-Math.max(0,(d.clientHeight-t.height)/2)),f=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=Math.min(l,f),i.set(e,n)}))},r[0]=i,r[1]=a,r[2]=o,r[3]=e,r[4]=t,r[5]=n,r[6]=s):s=r[6],s}function bf(){return new Map}function xf(){return new Map}function Sf(){return new Map}function Cf(e){let t=(0,kl.c)(19),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=b(ze.writeFile),s;t[0]!==a||t[1]!==i?(s=e=>a(i,e),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n||t[5]!==i||t[6]!==o?(c=e=>o({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),t[3]=r,t[4]=n,t[5]=i,t[6]=o,t[7]=c):c=t[7];let l;t[8]!==r||t[9]!==n||t[10]!==i?(l=e=>{P(n,r,i,e)},t[8]=r,t[9]=n,t[10]=i,t[11]=l):l=t[11];let u;t[12]!==s||t[13]!==c||t[14]!==l?(u=new df({debounceMs:pf,onPendingChange:s,persist:c,onConfirmed:l}),t[12]=s,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=u,f,p;return t[16]===d?(f=t[17],p=t[18]):(f=()=>()=>d.dispose(),p=[d],t[16]=d,t[17]=f,t[18]=p),(0,X.useEffect)(f,p),d}function wf(t){let n=(0,kl.c)(74),{environmentId:r,cwd:i,relativePath:o,composerDraftTarget:s,contents:c,resolvedTheme:l,revealRequestId:u,wordWrap:d,onPostRender:f,onPendingChange:p}=t,m=a(jf),h=a(Af),g;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[0]=g):g=n[0];let[_,v]=(0,X.useState)(g),[y,b]=(0,X.useState)(null),S=y?.revealRequestId===u?y.range:null,w;n[1]===u?w=n[2]:(w=e=>{b({revealRequestId:u,range:e})},n[1]=u,n[2]=w);let E=w,ne=(0,X.useRef)(null),D=(0,X.useRef)(null),O;n[3]!==i||n[4]!==r||n[5]!==p||n[6]!==o?(O={environmentId:r,cwd:i,relativePath:o,onPendingChange:p},n[3]=i,n[4]=r,n[5]=p,n[6]=o,n[7]=O):O=n[7];let k=Cf(O),A;n[8]!==m||n[9]!==s||n[10]!==i||n[11]!==r||n[12]!==o||n[13]!==k?(A=new Ud({onChange:(t,n)=>{if(Ce(r,i,o,t.contents),k.change(t.contents),n){let r=C(n);v(r);for(let n of r)for(let r of n.metadata.entries)r.kind===`comment`&&m(s,e({id:r.id,filePath:o,startLine:r.startLine,endLine:r.endLine,text:r.text,contents:t.contents}))}}}),n[8]=m,n[9]=s,n[10]=i,n[11]=r,n[12]=o,n[13]=k,n[14]=A):A=n[14];let j=A,M,re;n[15]===j?(M=n[16],re=n[17]):(M=()=>()=>{j.cleanUp()},re=[j],n[15]=j,n[16]=M,n[17]=re),(0,X.useEffect)(M,re);let ie;n[18]!==s||n[19]!==h||n[20]!==E?(ie=e=>{E(null),h(s,e),v(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},n[18]=s,n[19]=h,n[20]=E,n[21]=ie):ie=n[21];let ae=ie,oe;n[22]!==m||n[23]!==s||n[24]!==c||n[25]!==_||n[26]!==o||n[27]!==E?(oe=(t,n)=>{E(null);let r=_.flatMap(kf).find(e=>e.id===t);r&&m(s,e({id:r.id,filePath:o,startLine:r.startLine,endLine:r.endLine,text:n,contents:c})),v(e=>e.map(e=>({...e,metadata:{entries:e.metadata.entries.map(e=>e.id===t?{...e,kind:`comment`,text:n}:e)}})))},n[22]=m,n[23]=s,n[24]=c,n[25]=_,n[26]=o,n[27]=E,n[28]=oe):oe=n[28];let se=oe,ce;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>{let{startLine:t,endLine:n}=T(e),r={id:ee(),kind:`draft`,startLine:t,endLine:n,text:``};v(e=>{let t=e.flatMap(Df),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},n[29]=ce):ce=n[29];let le=ce,ue;n[30]===_?ue=n[31]:(ue=_.some(Tf),n[30]=_,n[31]=ue);let de=ue,fe,pe;n[32]!==j||n[33]!==de||n[34]!==E?(fe=()=>{let e=ne.current;if(e)return af({root:e,editor:j,isBlocked:()=>de,onDismiss:()=>E(null)})},pe=[j,de,E],n[32]=j,n[33]=de,n[34]=E,n[35]=fe,n[36]=pe):(fe=n[35],pe=n[36]),(0,X.useEffect)(fe,pe);let me;n[37]===E?me=n[38]:(me=e=>{E(e),e&&le(e)},n[37]=E,n[38]=me);let N=me,he;n[39]!==f||n[40]!==S?(he=(e,t,n)=>{f(e,t,n),D.current!==null&&(cancelAnimationFrame(D.current),D.current=null),n!==`unmount`&&(D.current=requestAnimationFrame(()=>{D.current=null,e.isConnected&&t.setSelectedLines(S,{notify:!1})}))},n[39]=f,n[40]=S,n[41]=he):he=n[41];let ge=he,_e;n[42]===Symbol.for(`react.memo_cache_sentinel`)?(_e={overscrollSize:600,intersectionObserverMargin:1200},n[42]=_e):_e=n[42];let ve;n[43]!==c||n[44]!==i||n[45]!==o?(ve=sf(i,o,c),n[43]=c,n[44]=i,n[45]=o,n[46]=ve):ve=n[46];let ye;n[47]!==c||n[48]!==o||n[49]!==ve?(ye={name:o,contents:c,cacheKey:ve},n[47]=c,n[48]=o,n[49]=ve,n[50]=ye):ye=n[50];let xe=!de,Se=!de,we=d?`wrap`:`scroll`,Te;n[51]===l?Te=n[52]:(Te=be(l),n[51]=l,n[52]=Te);let Ee;n[53]!==N||n[54]!==ge||n[55]!==l||n[56]!==E||n[57]!==xe||n[58]!==Se||n[59]!==we||n[60]!==Te?(Ee={disableFileHeader:!0,enableGutterUtility:xe,enableLineSelection:Se,onGutterUtilityClick:E,onLineSelectionChange:E,onLineSelectionEnd:N,overflow:we,theme:Te,themeType:l,unsafeCSS:hf,onPostRender:ge},n[53]=N,n[54]=ge,n[55]=l,n[56]=E,n[57]=xe,n[58]=Se,n[59]=we,n[60]=Te,n[61]=Ee):Ee=n[61];let De;n[62]!==ae||n[63]!==se?(De=e=>(0,Z.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,Z.jsx)(x,{kind:e.kind,rangeLabel:te(e.startLine,e.endLine),text:e.text,onCancel:()=>ae(e.id),onComment:t=>se(e.id,t),onDelete:()=>ae(e.id)},e.id))}),n[62]=ae,n[63]=se,n[64]=De):De=n[64];let P;n[65]!==_||n[66]!==S||n[67]!==ye||n[68]!==Ee||n[69]!==De?(P=(0,Z.jsx)(`div`,{ref:ne,className:`flex min-h-0 flex-1`,children:(0,Z.jsx)(Re,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:_e,children:(0,Z.jsx)(Ol,{file:ye,options:Ee,selectedLines:S,lineAnnotations:_,renderAnnotation:De,className:`min-h-full`,contentEditable:!0})})}),n[65]=_,n[66]=S,n[67]=ye,n[68]=Ee,n[69]=De,n[70]=P):P=n[70];let Oe;return n[71]!==j||n[72]!==P?(Oe=(0,Z.jsx)(Ve,{editor:j,children:P}),n[71]=j,n[72]=P,n[73]=Oe):Oe=n[73],Oe}function Tf(e){return e.metadata.entries.some(Ef)}function Ef(e){return e.kind===`draft`}function Df(e){let t=e.metadata.entries.filter(Of);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Of(e){return e.kind!==`draft`}function kf(e){return e.metadata.entries}function Af(e){return e.removeReviewComment}function jf(e){return e.addReviewComment}function Mf(e){let t=(0,kl.c)(16),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,onPendingChange:s}=e,c;t[0]!==r||t[1]!==n||t[2]!==s||t[3]!==i?(c={environmentId:n,cwd:r,relativePath:i,onPendingChange:s},t[0]=r,t[1]=n,t[2]=s,t[3]=i,t[4]=c):c=t[4];let l=Cf(c),u;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==i||t[9]!==l?(u=e=>{let{markerOffset:t,checked:o}=e,s=Ie(n,r,i)?.contents??a,c=uf(s,t,o);c!==s&&(Ce(n,r,i,c),l.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==a||t[12]!==r||t[13]!==u||t[14]!==o?(d=(0,Z.jsx)(Fe,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(_e,{text:a,cwd:r,threadRef:o,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:u})}),t[11]=a,t[12]=r,t[13]=u,t[14]=o,t[15]=d):d=t[15],d}function Nf(){try{return h(ff,o)??!0}catch(e){return console.error(e),!0}}function Pf(e){let n=(0,kl.c)(78),{environmentId:r,cwd:a,projectName:o,relativePath:s,threadRef:u,composerDraftTarget:d,keybindings:h,availableEditors:g,revealLine:v,revealRequestId:x,onOpenFile:S,onPendingChange:C}=e,{resolvedTheme:ee}=oe(),w=Ge(If),T=t(),E=f(r),te;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(te={reportFailure:!1},n[0]=te):te=n[0];let ne=ie(je.createUrl,te),D;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(D={reportFailure:!1},n[1]=D):D=n[1];let O=b(ke.open,D),k;n[2]===s?k=n[3]:(k=s!==null&&Ml(s),n[2]=s,n[3]=k);let A=k,j=Me(r,a,s,!A),[M,le]=(0,X.useState)(Nf),ue;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(ue={path:null,revealRequestId:null},n[4]=ue):ue=n[4];let[de,fe]=(0,X.useState)(ue),pe=(0,X.useRef)(null),me;n[5]===s?me=n[6]:(me=s?lf(s):!1,n[5]=s,n[6]=me);let N=me,he=N&&de.path===s&&(v===null||de.revealRequestId===x),_e;n[7]===s?_e=n[8]:(_e=s!==null&&ce()&&ae(s),n[7]=s,n[8]=_e);let ye=_e,xe;n[9]!==a||n[10]!==s?(xe=s?ve(s,a):null,n[9]=a,n[10]=s,n[11]=xe):xe=n[11];let Se=xe,Ce;n[12]!==o||n[13]!==s?(Ce=s?cf(o,s):[],n[12]=o,n[13]=s,n[14]=Ce):Ce=n[14];let Te=Ce,Ee=yf(s,v,x),P;n[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{(pe.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},n[15]=P):P=n[15];let Oe;n[16]===s?Oe=n[17]:(Oe=[s],n[16]=s,n[17]=Oe),(0,X.useEffect)(P,Oe);let Ne;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=()=>{le(Ff)},n[18]=Ne):Ne=n[18];let Pe=Ne,Ie;n[19]!==Se||n[20]!==ne||n[21]!==E||n[22]!==O||n[23]!==u?(Ie=()=>{!Se||!E||(async()=>{let e=await ge({threadRef:u,filePath:Se,httpBaseUrl:E,createAssetUrl:ne,openPreview:O});if(e._tag===`Success`||p(e))return;let t=l(e);Le.add(we({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},n[19]=Se,n[20]=ne,n[21]=E,n[22]=O,n[23]=u,n[24]=Ie):Ie=n[24];let ze=Ie,Be;n[25]!==Se||n[26]!==g||n[27]!==Te||n[28]!==ye||n[29]!==r||n[30]!==M||n[31]!==ze||n[32]!==N||n[33]!==h||n[34]!==T||n[35]!==o||n[36]!==s||n[37]!==he||n[38]!==x?(Be=s?(0,Z.jsxs)(`div`,{className:`surface-subheader gap-2 px-3`,"data-surface-subheader":!0,children:[(0,Z.jsx)(Fe,{ref:pe,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1 rounded-none`,"data-file-breadcrumbs":!0,children:(0,Z.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:Te.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":e.kind===`file`,children:[t>0?(0,Z.jsx)(i,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,(0,Z.jsx)(`span`,{className:c(`max-w-40 truncate`,e.kind===`file`?`font-medium text-foreground`:`text-muted-foreground`),title:e.path||o,children:e.label})]},e.path||`project`))})}),Se&&r===T?(0,Z.jsx)(Ae,{environmentId:r,keybindings:h,availableEditors:g,openInCwd:Se,compact:!0,enableShortcut:!1}):null,N?(0,Z.jsxs)(y,{children:[(0,Z.jsx)(m,{render:(0,Z.jsx)(Ke,{className:`shrink-0`,pressed:he,onPressedChange:e=>{fe({path:e?s:null,revealRequestId:e?x:null})},"aria-label":he?`Show markdown source`:`Show rendered markdown`,variant:`ghost`,size:`sm`,children:he?(0,Z.jsx)(Je,{className:`size-3.5`}):(0,Z.jsx)(se,{className:`size-3.5`})})}),(0,Z.jsx)(_,{children:he?`Show markdown source`:`Show rendered markdown`})]}):null,ye?(0,Z.jsxs)(y,{children:[(0,Z.jsx)(m,{render:(0,Z.jsx)(Ke,{className:`shrink-0`,pressed:!1,onPressedChange:ze,"aria-label":`Open file in preview browser`,variant:`ghost`,size:`sm`,children:(0,Z.jsx)(re,{className:`size-3.5`})})}),(0,Z.jsx)(_,{children:`Open file in preview browser`})]}):null,(0,Z.jsxs)(y,{children:[(0,Z.jsx)(m,{render:(0,Z.jsx)(Ke,{className:`shrink-0`,pressed:M,onPressedChange:Pe,"aria-label":M?`Hide file explorer`:`Show file explorer`,variant:`ghost`,size:`sm`,children:(0,Z.jsx)(Ye,{className:`size-3.5`})})}),(0,Z.jsx)(_,{children:M?`Hide file explorer`:`Show file explorer`})]})]}):null,n[25]=Se,n[26]=g,n[27]=Te,n[28]=ye,n[29]=r,n[30]=M,n[31]=ze,n[32]=N,n[33]=h,n[34]=T,n[35]=o,n[36]=s,n[37]=he,n[38]=x,n[39]=Be):Be=n[39];let Ve;n[40]!==j||n[41]!==s?(Ve=s&&j.data?.truncated?(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-amber-500/20 bg-amber-500/8 px-3 py-1.5 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Preview limited to the first 1 MB of a `,j.data.byteLength.toLocaleString(),` byte file.`]}):null,n[40]=j,n[41]=s,n[42]=Ve):Ve=n[42];let He=s?`flex`:`hidden`,Ue;n[43]===He?Ue=n[44]:(Ue=c(`min-w-0 flex-1 flex-col overflow-hidden`,He),n[43]=He,n[44]=Ue);let We;n[45]!==Se||n[46]!==d||n[47]!==a||n[48]!==r||n[49]!==j||n[50]!==A||n[51]!==N||n[52]!==Ee||n[53]!==C||n[54]!==s||n[55]!==he||n[56]!==ee||n[57]!==x||n[58]!==u||n[59]!==w?(We=s&&A&&Se?(0,Z.jsx)(gf,{environmentId:r,threadRef:u,absolutePath:Se,alt:s},Se):s&&j.error&&j.data===null?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:j.error}):s&&j.data===null?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Z.jsx)(De,{className:`size-5 animate-spin`})}):s&&j.data?N&&he?(0,Z.jsx)(Mf,{environmentId:r,cwd:a,relativePath:s,threadRef:u,contents:j.data.contents,onPendingChange:C}):j.data.truncated?(0,Z.jsx)(Re,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:(0,Z.jsx)(Ol,{file:{name:s,contents:j.data.contents,cacheKey:sf(a,s,j.data.contents)},options:{disableFileHeader:!0,overflow:w?`wrap`:`scroll`,theme:be(ee),themeType:ee,unsafeCSS:hf,onPostRender:Ee},className:`min-h-full`})},`${s}:${ee}:${j.data.byteLength}`):(0,Z.jsx)(wf,{environmentId:r,cwd:a,relativePath:s,composerDraftTarget:d,contents:j.data.contents,resolvedTheme:ee,revealRequestId:x,wordWrap:w,onPostRender:Ee,onPendingChange:C},`${s}:${ee}`):null,n[45]=Se,n[46]=d,n[47]=a,n[48]=r,n[49]=j,n[50]=A,n[51]=N,n[52]=Ee,n[53]=C,n[54]=s,n[55]=he,n[56]=ee,n[57]=x,n[58]=u,n[59]=w,n[60]=We):We=n[60];let qe;n[61]!==Ue||n[62]!==We?(qe=(0,Z.jsx)(`div`,{className:Ue,children:We}),n[61]=Ue,n[62]=We,n[63]=qe):qe=n[63];let Xe;n[64]!==a||n[65]!==r||n[66]!==M||n[67]!==S||n[68]!==o||n[69]!==s?(Xe=M||s===null?(0,Z.jsx)(`aside`,{className:c(`flex min-h-0 shrink-0 bg-background`,s?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,Z.jsx)(tf,{environmentId:r,cwd:a,projectName:o,onOpenFile:S},`${r}:${a}`)}):null,n[64]=a,n[65]=r,n[66]=M,n[67]=S,n[68]=o,n[69]=s,n[70]=Xe):Xe=n[70];let Ze;n[71]!==qe||n[72]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[qe,Xe]}),n[71]=qe,n[72]=Xe,n[73]=Ze):Ze=n[73];let Qe;return n[74]!==Be||n[75]!==Ve||n[76]!==Ze?(Qe=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Be,Ve,Ze]}),n[74]=Be,n[75]=Ve,n[76]=Ze,n[77]=Qe):Qe=n[77],Qe}function Ff(e){let t=!e;try{d(ff,t,o)}catch(e){console.error(e)}return t}function If(e){return e.wordWrap}export{Pf as default};
1778
- //# sourceMappingURL=FilePreviewPanel-DdLy8b8b.js.map
1778
+ //# sourceMappingURL=FilePreviewPanel-CuP4WCgv.js.map
@@ -1,2 +1,2 @@
1
- import{Br as e,Dc as t,Go as n,Gr as r,Hr as i,Ir as a,Is as o,Jr as s,Jt as c,Kr as l,Ls as u,Mr as d,Pf as f,Ps as p,Pt as m,T as h,Ts as g,Uf as _,Ur as v,Vr as y,Ws as b,Zs as x,b as S,eu as C,g as w,lp as T,ls as E,m as D,nu as O,o as k,op as A,p as j,qr as ee,qs as M,rs as te,v as N,y as ne,zr as P,zs as F}from"./textarea-lBMORu4g.js";import{t as re}from"./arrow-right-BNeeftk2.js";import{$n as I,A as L,An as R,Cr as ie,Dr as ae,Er as oe,F as z,Jn as B,M as V,Mn as H,Mr as U,N as se,O as W,On as G,Or as ce,P as K,Pr as le,Qn as q,Rr as ue,Xn as de,Zn as J,a as fe,ar as pe,c as me,cr as he,dr as Y,er as ge,g as _e,i as ve,ir as ye,j as be,jn as xe,k as Se,kn as Ce,kr as we,lr as Te,n as Ee,nr as De,o as Oe,or as ke,r as Ae,rr as je,s as Me,sr as Ne,t as Pe,tr as Fe,ur as X,wr as Ie}from"./index-DnkEkLTH.js";var Le=n(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Re=n(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ze=n(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Be=n(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=T(A(),1),Q=f(),$=_();function Ve(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=m(`relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,"data-slot":`input-group`,role:`group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var He=te(`[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80`,{defaultVariants:{align:`inline-start`},variants:{align:{"block-end":`order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"block-start":`order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"inline-end":`has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]`,"inline-start":`has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]`}}});function Ue(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=m(He({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,$.jsx)(`div`,{className:o,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:We,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function We(e){if(e.target.closest(`button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']`))return;e.preventDefault();let t=e.currentTarget.parentElement,n=t?.querySelector(`input, textarea`);n&&!t?.querySelector(`input:focus, textarea:focus`)&&n.focus()}function Ge(e){let t=(0,Q.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,$.jsx)(B,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Ke=()=>{};function qe(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:s,refreshDisabled:c,inputDisabled:l,focusUrlNonce:u,onBack:f,onForward:p,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:x,pictureInPicture:S,pictureInPictureDisabled:C,onPickElement:T,pickActive:E,pickDisabled:O,pickDisabledReason:k,trailingActions:A}=e,ee=(0,Z.useRef)(null),[M,te]=(0,Z.useState)(n),[N,ne]=(0,Z.useState)(!1),P,F;t[0]===u?(P=t[1],F=t[2]):(P=()=>{if(u==null)return;let e=ee.current;e&&e.focus()},F=[u],t[0]=u,t[1]=P,t[2]=F),(0,Z.useEffect)(P,F);let I;t[3]!==M||t[4]!==g?(I=e=>{e?.preventDefault();let t=M.trim();t.length!==0&&(g(t),ee.current?.blur())},t[3]=M,t[4]=g,t[5]=I):I=t[5];let L=I,R=o?f:Ke,oe=!o,z;t[6]!==R||t[7]!==oe?(z=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:R,disabled:oe,"aria-label":`Back`,type:`button`}),t[6]=R,t[7]=oe,t[8]=z):z=t[8];let B;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ue,{}),t[9]=B):B=t[9];let V;t[10]===z?V=t[11]:(V=(0,$.jsx)(w,{render:z,children:B}),t[10]=z,t[11]=V);let H;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(D,{children:`Back`}),t[12]=H):H=t[12];let U;t[13]===V?U=t[14]:(U=(0,$.jsxs)(j,{children:[V,H]}),t[13]=V,t[14]=U);let se=s?p:Ke,W=!s,G;t[15]!==se||t[16]!==W?(G=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:W,"aria-label":`Forward`,type:`button`}),t[15]=se,t[16]=W,t[17]=G):G=t[17];let K;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(re,{}),t[18]=K):K=t[18];let q;t[19]===G?q=t[20]:(q=(0,$.jsx)(w,{render:G,children:K}),t[19]=G,t[20]=q);let de;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(D,{children:`Forward`}),t[21]=de):de=t[21];let J;t[22]===q?J=t[23]:(J=(0,$.jsxs)(j,{children:[q,de]}),t[22]=q,t[23]=J);let fe=c?Ke:h,pe=i?`Stop`:`Refresh`,me;t[24]!==c||t[25]!==fe||t[26]!==pe?(me=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:fe,disabled:c,"aria-label":pe,type:`button`}),t[24]=c,t[25]=fe,t[26]=pe,t[27]=me):me=t[27];let he=i&&`animate-spin`,Y;t[28]===he?Y=t[29]:(Y=m(he),t[28]=he,t[29]=Y);let ge;t[30]===Y?ge=t[31]:(ge=(0,$.jsx)(ie,{className:Y}),t[30]=Y,t[31]=ge);let _e;t[32]!==me||t[33]!==ge?(_e=(0,$.jsx)(w,{render:me,children:ge}),t[32]=me,t[33]=ge,t[34]=_e):_e=t[34];let ve=i?`Loading…`:`Refresh`,ye;t[35]===ve?ye=t[36]:(ye=(0,$.jsx)(D,{children:ve}),t[35]=ve,t[36]=ye);let be;t[37]!==_e||t[38]!==ye?(be=(0,$.jsxs)(j,{children:[_e,ye]}),t[37]=_e,t[38]=ye,t[39]=be):be=t[39];let xe;t[40]!==U||t[41]!==J||t[42]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[U,J,be]}),t[40]=U,t[41]=J,t[42]=be,t[43]=xe):xe=t[43];let Se=N?M:r??n,Ce=_&&!N&&`group-hover/address:pe-7 transition-[padding]`,we;t[44]===Ce?we=t[45]:(we=m(Ce),t[44]=Ce,t[45]=we);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>te(e.target.value),t[46]=Te):Te=t[46];let Ee;t[47]===n?Ee=t[48]:(Ee=()=>{te(n),ne(!0),queueMicrotask(()=>ee.current?.select())},t[47]=n,t[48]=Ee);let De;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(De=()=>{ne(!1)},t[49]=De):De=t[49];let Oe;t[50]!==L||t[51]!==n?(Oe=e=>{e.key===`Enter`&&L(e),e.key===`Escape`&&(e.preventDefault(),te(n),ee.current?.blur())},t[50]=L,t[51]=n,t[52]=Oe):Oe=t[52];let ke;t[53]!==l||t[54]!==Se||t[55]!==we||t[56]!==Ee||t[57]!==Oe?(ke=(0,$.jsx)(w,{render:(0,$.jsx)(Ge,{ref:ee,value:Se,className:we,onChange:Te,onFocus:Ee,onBlur:De,onKeyDown:Oe,placeholder:`Search or enter URL`,spellCheck:!1,disabled:l,"data-preview-url-input":!0,size:`sm`})}),t[53]=l,t[54]=Se,t[55]=we,t[56]=Ee,t[57]=Oe,t[58]=ke):ke=t[58];let Ae;t[59]!==r||t[60]!==N||t[61]!==n?(Ae=!N&&r?(0,$.jsx)(D,{children:n}):null,t[59]=r,t[60]=N,t[61]=n,t[62]=Ae):Ae=t[62];let je;t[63]!==ke||t[64]!==Ae?(je=(0,$.jsxs)(j,{children:[ke,Ae]}),t[63]=ke,t[64]=Ae,t[65]=je):je=t[65];let Me;t[66]!==N||t[67]!==_?(Me=_&&!N?(0,$.jsx)(Ue,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(le,{})}),(0,$.jsx)(D,{children:`Open in system browser`})]})}):null,t[66]=N,t[67]=_,t[68]=Me):Me=t[68];let Ne;t[69]!==je||t[70]!==Me?(Ne=(0,$.jsxs)(Ve,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[je,Me]}),t[69]=je,t[70]=Me,t[71]=Ne):Ne=t[71];let Pe;t[72]!==T||t[73]!==E||t[74]!==O||t[75]!==k?(Pe=T?(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(d,{variant:E?`secondary`:`ghost`,size:`icon-xs`,onClick:T,disabled:O,"aria-label":E?`Cancel annotation`:`Annotate preview`,"aria-pressed":E?`true`:`false`,type:`button`}),children:(0,$.jsx)(ce,{className:m(E&&`text-primary`)})}),(0,$.jsx)(D,{children:O&&k?k:E?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=T,t[73]=E,t[74]=O,t[75]=k,t[76]=Pe):Pe=t[76];let Fe;t[77]!==y||t[78]!==v||t[79]!==b?(Fe=v?(0,$.jsxs)(j,{children:[(0,$.jsxs)(w,{render:(0,$.jsx)(d,{variant:b?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>v(e.shiftKey),"aria-label":b?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:y}),children:[(0,$.jsx)(Le,{className:m(b&&`text-destructive`)}),b?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(D,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=y,t[78]=v,t[79]=b,t[80]=Fe):Fe=t[80];let X;t[81]!==x||t[82]!==S||t[83]!==C?(X=x?(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(d,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:x,"aria-label":S?`Close floating preview`:`Float preview over chat`,"aria-pressed":S?`true`:`false`,type:`button`,disabled:C}),children:(0,$.jsx)(ae,{className:m(S&&`text-primary`)})}),(0,$.jsx)(D,{children:S?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=x,t[82]=S,t[83]=C,t[84]=X):X=t[84];let Ie;t[85]!==L||t[86]!==xe||t[87]!==Ne||t[88]!==Pe||t[89]!==Fe||t[90]!==X||t[91]!==A?(Ie=(0,$.jsxs)(`form`,{onSubmit:L,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[xe,Ne,Pe,Fe,X,A]}),t[85]=L,t[86]=xe,t[87]=Ne,t[88]=Pe,t[89]=Fe,t[90]=X,t[91]=A,t[92]=Ie):Ie=t[92];let Re;t[93]===a?Re=t[94]:(Re=a>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Re);let ze;return t[95]!==Ie||t[96]!==Re?(ze=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Re]}),t[95]=Ie,t[96]=Re,t[97]=ze):ze=t[97],ze}function Je(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function Ye(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=m(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=a):a=t[3];let o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Xe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=Ze(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ye,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(Qe,{}):(0,$.jsx)($e,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function Ze(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function Qe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function $e(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function et(e){let t=(0,Q.c)(7),n=he(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:pe(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=tt({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function tt(e){let t=new Map;for(let n of e.configuredUrls){let e=rt(n);if(!e)continue;let r=nt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=nt(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=rt(n);if(!e)continue;let r=nt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function nt(e,t){return`${e.toLowerCase()}:${t}`}function rt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!ke(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function it(e){let t=(0,Q.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=et(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(G,{children:[(0,$.jsx)(R,{variant:`icon`,children:(0,$.jsx)(U,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(xe,{children:`No preview yet`}),(0,$.jsx)(Ce,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Be,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(Xe,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var at=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ot(t){let n=(0,Q.c)(74),{tabId:i,hasWebContents:o,zoomFactor:c,colorScheme:u,deviceToolbarVisible:f,onToggleDeviceToolbar:p,nativePictureInPicture:m,onNativePictureInPicture:h}=t;if(!L)return null;let g=!i||!o,_;n[0]===i?_=n[1]:(_=e=>()=>{i&&e(i).catch(mt)},n[0]=i,n[1]=_);let b=_,x;n[2]===c?x=n[3]:(x=Math.round(c*100),n[2]=c,n[3]=x);let S=`${x}%`,C;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(s,{render:(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Re,{})}),(0,$.jsx)(D,{children:`More`})]}),n[4]=C):C=n[4];let T;n[5]===b?T=n[6]:(T=b(L.hardReload),n[5]=b,n[6]=T);let E;n[7]!==T||n[8]!==g?(E=(0,$.jsx)(P,{onClick:T,disabled:g,children:`Hard reload`}),n[7]=T,n[8]=g,n[9]=E):E=n[9];let O;n[10]===b?O=n[11]:(O=b(L.openDevTools),n[10]=b,n[11]=O);let k;n[12]!==O||n[13]!==g?(k=(0,$.jsx)(P,{onClick:O,disabled:g,children:`Open DevTools`}),n[12]=O,n[13]=g,n[14]=k):k=n[14];let A=m?`Close separate preview window`:`Open separate preview window`,M;n[15]!==h||n[16]!==A||n[17]!==g?(M=(0,$.jsx)(P,{onClick:h,disabled:g,children:A}),n[15]=h,n[16]=A,n[17]=g,n[18]=M):M=n[18];let te=f?`Hide device toolbar`:`Show device toolbar`,N;n[19]!==p||n[20]!==te||n[21]!==g?(N=(0,$.jsx)(P,{onClick:p,disabled:g,children:te}),n[19]=p,n[20]=te,n[21]=g,n[22]=N):N=n[22];let ne;n[23]===g?ne=n[24]:(ne=(0,$.jsx)(ee,{disabled:g,children:`Appearance`}),n[23]=g,n[24]=ne);let F;n[25]===i?F=n[26]:(F=e=>{i&&L.setColorScheme(i,e).catch(pt)},n[25]=i,n[26]=F);let re;n[27]===Symbol.for(`react.memo_cache_sentinel`)?(re=at.map(ft),n[27]=re):re=n[27];let I;n[28]!==u||n[29]!==F?(I=(0,$.jsx)(l,{className:`min-w-32`,children:(0,$.jsx)(y,{value:u,onValueChange:F,children:re})}),n[28]=u,n[29]=F,n[30]=I):I=n[30];let R;n[31]!==ne||n[32]!==I?(R=(0,$.jsxs)(r,{children:[ne,I]}),n[31]=ne,n[32]=I,n[33]=R):R=n[33];let ie;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(v,{}),n[34]=ie):ie=n[34];let ae;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),n[35]=ae):ae=n[35];let z;n[36]===b?z=n[37]:(z=b(L.zoomOut),n[36]=b,n[37]=z);let B;n[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(we,{}),n[38]=B):B=n[38];let V;n[39]!==z||n[40]!==g?(V=(0,$.jsx)(d,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:z,"aria-label":`Zoom out`,disabled:g,children:B}),n[39]=z,n[40]=g,n[41]=V):V=n[41];let H;n[42]===S?H=n[43]:(H=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:S}),n[42]=S,n[43]=H);let U;n[44]===b?U=n[45]:(U=b(L.zoomIn),n[44]=b,n[45]=U);let se;n[46]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(oe,{}),n[46]=se):se=n[46];let W;n[47]!==U||n[48]!==g?(W=(0,$.jsx)(d,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:U,"aria-label":`Zoom in`,disabled:g,children:se}),n[47]=U,n[48]=g,n[49]=W):W=n[49];let G;n[50]===b?G=n[51]:(G=b(L.resetZoom),n[50]=b,n[51]=G);let ce;n[52]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Ie,{}),n[52]=ce):ce=n[52];let K;n[53]!==G||n[54]!==g?(K=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:G,"aria-label":`Reset zoom`,disabled:g,children:ce}),n[53]=G,n[54]=g,n[55]=K):K=n[55];let le;n[56]!==V||n[57]!==H||n[58]!==W||n[59]!==K?(le=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[V,H,W,K]}),n[56]=V,n[57]=H,n[58]=W,n[59]=K,n[60]=le):le=n[60];let q;n[61]!==le||n[62]!==g?(q=(0,$.jsxs)(P,{closeOnClick:!1,onClick:dt,className:`justify-between`,disabled:g,children:[ae,le]}),n[61]=le,n[62]=g,n[63]=q):q=n[63];let ue,de,J;n[64]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(v,{}),de=(0,$.jsx)(P,{onClick:lt,children:`Clear cookies`}),J=(0,$.jsx)(P,{onClick:st,children:`Clear cache`}),n[64]=ue,n[65]=de,n[66]=J):(ue=n[64],de=n[65],J=n[66]);let fe;return n[67]!==N||n[68]!==R||n[69]!==q||n[70]!==E||n[71]!==k||n[72]!==M?(fe=(0,$.jsxs)(a,{children:[C,(0,$.jsxs)(e,{align:`end`,sideOffset:6,className:`min-w-56`,children:[E,k,M,N,R,ie,q,ue,de,J]})]}),n[67]=N,n[68]=R,n[69]=q,n[70]=E,n[71]=k,n[72]=M,n[73]=fe):fe=n[73],fe}function st(){L.clearCache().catch(ct)}function ct(){}function lt(){L.clearCookies().catch(ut)}function ut(){}function dt(e){return e.preventDefault()}function ft(e){return(0,$.jsx)(i,{value:e.value,children:e.label},e.value)}function pt(){}function mt(){}function ht(e){return ye[e]||(e.length>0?e:`Network error`)}function gt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=yt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=ht(i),t[2]=i,t[3]=u);let f=u,p;t[4]!==r||t[5]!==i?(p=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=p):p=t[6];let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(vt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==f||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,f,`.`]}),t[11]=f,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(_t),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(d,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[h,g,v,y,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function _t(e){return!e}function vt(e){let t=(0,Q.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function yt(e){try{return new URL(e).host}catch{return null}}function bt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var xt=120,St=220,Ct=4,wt=90,Tt=.08,Et=.5;function Dt(e){let[t,n]=(0,Z.useState)(0),r=(0,Z.useRef)(0);return r.current=t,(0,Z.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),St);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Ct);let t=window.setInterval(()=>{let e=r.current;if(e>=wt)return;let t=wt-e,i=Math.max(Et,t*Tt);n(Math.min(wt,e+i))},xt);return()=>window.clearInterval(t)},[e]),t}var Ot=class extends O()(`PreviewSessionThreadKeyParseError`,{threadKey:C}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},kt=p(e=>{let t=M(e);if(t===null)throw new Ot({threadKey:e});let n=Te.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=Te.events({environmentId:t.environmentId,input:{}});return o(e=>{let i=!1,a=0,o=e=>{b(e)&&ge(t,e.value)},s=r=>{if(!b(r)||r.value.threadId!==t.threadId)return;let i=I(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}J(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(u(1e3),F(`preview:session-sync:${e}`))});function At(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=kt(x(e)),t[0]=e,t[1]=n),E(n)}var jt=1500,Mt=.001;function Nt(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Mt))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},jt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=m(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,f),t[5]=f,t[6]=p);let h;return t[7]!==u||t[8]!==d||t[9]!==p?(h=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=h):h=t[10],h}function Pt(e,t){return e?1:t===`human`?.18:.35}var Ft=700;function It(e){let t=(0,Q.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=me(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=z(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Lt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function Lt(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Ft);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Pt(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ze,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Rt=typeof window>`u`?null:h();function zt({threadRef:e,tabId:n,configuredUrls:r,visible:i}){let[a,o]=(0,Z.useState)(void 0),[s,l]=(0,Z.useState)(!1),u=Oe(),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!0),p=je(e),m=V(t=>be(t.byThreadKey,e)),h=c(e=>e.addPreviewAnnotation),_=c(e=>e.addImage),v=ne(e.environmentId),y=S(e.environmentId),b=N(Te.open),C=N(Te.resize,`preview viewport resize`);At(e),(0,Z.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let w=n??p.activeTabId,T=w?se(e,p.serverEpoch,w):null,E=w&&T?u.has(T)?T:Ae(e,w):null,D=w?p.sessions[w]??null:null,O=w?p.desktopByTabId[w]??null:null,A=D?.navStatus??{_tag:`Idle`},j=A._tag===`Idle`?``:A.url,ee=O?.loading??A._tag===`Loading`,M=O?.canGoBack??D?.canGoBack??!1,te=O?.canGoForward??D?.canGoForward??!1,P=A._tag===`Idle`,F=A._tag===`LoadFailed`,re=Se(D),I=O?.controller??`none`,R=Dt(ee),ie=j&&v&&y?Je({url:j,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,ae=D?.viewport??t,oe=z(e=>T?e.byTabId[T]?.rect??null:null),B=(0,Z.useCallback)(async t=>{T&&L?(await L.navigate(T,t),Fe(e,t)):await de({openPreview:b,threadRef:e,url:t})},[b,T,e]),U=(0,Z.useCallback)(async e=>{try{await B(Ne(e))}catch{}},[B]),W=(0,Z.useCallback)(async t=>{try{await B(pe(e.environmentId,t))}catch{}},[B,e.environmentId]),G=(0,Z.useCallback)(()=>{L&&T&&L.refresh(T)},[T]),ce=(0,Z.useCallback)(()=>{L&&T&&L.zoomIn(T)},[T]),le=(0,Z.useCallback)(()=>{L&&T&&L.zoomOut(T)},[T]),q=(0,Z.useCallback)(()=>{L&&T&&L.resetZoom(T)},[T]),ue=(0,Z.useCallback)(async t=>{if(!w)return;let n=await C({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:w,viewport:t}});if(n._tag===`Failure`){let e=g(n);throw X.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}De(e,n.value)},[C,w,e]),J=()=>{if(!T)return;if(ae._tag!==`fill`){Pe(T,t).catch(()=>void 0);return}let e=oe?Me(oe,O?.zoomFactor):{width:1024,height:768};Pe(T,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(T)return Ee(T,ue)},[ue,T]);let me=(0,Z.useCallback)(()=>{L&&T&&L.goBack(T)},[T]),he=(0,Z.useCallback)(()=>{L&&T&&L.goForward(T)},[T]),ge=(0,Z.useCallback)(()=>{!Rt||!j||Rt.shell.openExternal(j).catch(()=>void 0)},[j]),ye=(0,Z.useCallback)(()=>{if(w){if(m?.tabId===w){V.getState().close(e);return}V.getState().open(e,w),k.getState().close(e)}},[m?.tabId,w,e]),xe=(0,Z.useCallback)(()=>{!L||!T||(O?.pictureInPicture?L.pictureInPicture.close:L.pictureInPicture.open)(T).catch(e=>{X.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[O?.pictureInPicture,T]),Ce=(0,Z.useCallback)(t=>{if(!L||!T||!w)return;let n=L;if(E){fe(E).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:bt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{X.update(r,Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=X.add(Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){ve(T,e,w).catch(e=>{X.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(T).then(e=>{let t={children:bt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{X.update(a,Y({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=X.add(Y({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[E,T,w,e]),we=(0,Z.useCallback)(()=>{if(!L||!T)return;if(d.current){L.cancelPickElement(T).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await L.pickElement(T);if(!t)return;h(e,t);let n=await _e(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,f.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,h,T,e]);return(0,Z.useEffect)(()=>()=>{d.current&&(d.current=!1,L&&T&&L.cancelPickElement(T).catch(()=>void 0),f.current&&l(!1))},[T]),(0,Z.useEffect)(()=>{if(i)return H(e=>{switch(e){case`refresh`:G();return;case`focus-url`:o(e=>(e??0)+1);return;case`zoom-in`:ce();return;case`zoom-out`:le();return;case`reset-zoom`:q();return;case`toggle-panel`:return}})},[G,q,ce,le,i]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":x(e),children:[(0,$.jsx)(qe,{url:j,displayUrl:ie,loading:ee,loadProgress:R,canGoBack:M,canGoForward:te,refreshDisabled:P,focusUrlNonce:a,onBack:me,onForward:he,onRefresh:G,onSubmit:e=>void U(e),onOpenInBrowser:w?ge:void 0,onCapture:L&&w?Ce:void 0,captureDisabled:!O||F,recording:E!==null,onPictureInPicture:L&&w?ye:void 0,pictureInPicture:m?.tabId===w,pictureInPictureDisabled:!O?.hasWebContents||F,onPickElement:L&&w?we:void 0,pickActive:s,pickDisabled:!w||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:L?(0,$.jsx)(ot,{tabId:T,hasWebContents:O?.hasWebContents??!1,zoomFactor:O?.zoomFactor??1,colorScheme:O?.colorScheme??`system`,deviceToolbarVisible:ae._tag!==`fill`,onToggleDeviceToolbar:J,nativePictureInPicture:O?.pictureInPicture??!1,onNativePictureInPicture:xe}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[T&&D&&!re?(0,$.jsx)(K,{tabId:T,visible:i&&!F,className:`absolute inset-0 h-full w-full`},T):null,re?(0,$.jsx)(it,{environmentId:e.environmentId,configuredUrls:r,recentlySeenUrls:p.recentlySeenUrls,onOpenUrl:e=>void W(e)}):null,D&&O?(0,$.jsx)(Nt,{zoomFactor:O.zoomFactor}):null,T&&O&&!re&&!F?(0,$.jsx)(It,{tabId:T,zoomFactor:O.zoomFactor,controller:I}):null,I===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:I===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(gt,{url:A.url,code:A.code,description:A.description,onReload:G})}):null]})]})}function Bt(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!q()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(W,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(zt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(W,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Bt as PreviewPanel};
2
- //# sourceMappingURL=PreviewPanel-BKsstY2H.js.map
1
+ import{Br as e,Dc as t,Go as n,Gr as r,Hr as i,Ir as a,Is as o,Jr as s,Jt as c,Kr as l,Ls as u,Mr as d,Pf as f,Ps as p,Pt as m,T as h,Ts as g,Uf as _,Ur as v,Vr as y,Ws as b,Zs as x,b as S,eu as C,g as w,lp as T,ls as E,m as D,nu as O,o as k,op as A,p as j,qr as ee,qs as M,rs as te,v as N,y as ne,zr as P,zs as F}from"./textarea-lBMORu4g.js";import{t as re}from"./arrow-right-BNeeftk2.js";import{$n as I,A as L,An as R,Cr as ie,Dr as ae,Er as oe,F as z,Jn as B,M as V,Mn as H,Mr as U,N as se,O as W,On as G,Or as ce,P as K,Pr as le,Qn as q,Rr as ue,Xn as de,Zn as J,a as fe,ar as pe,c as me,cr as he,dr as Y,er as ge,g as _e,i as ve,ir as ye,j as be,jn as xe,k as Se,kn as Ce,kr as we,lr as Te,n as Ee,nr as De,o as Oe,or as ke,r as Ae,rr as je,s as Me,sr as Ne,t as Pe,tr as Fe,ur as X,wr as Ie}from"./index-Cxz8lImj.js";var Le=n(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Re=n(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ze=n(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Be=n(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=T(A(),1),Q=f(),$=_();function Ve(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=m(`relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,"data-slot":`input-group`,role:`group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var He=te(`[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80`,{defaultVariants:{align:`inline-start`},variants:{align:{"block-end":`order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"block-start":`order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"inline-end":`has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]`,"inline-start":`has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]`}}});function Ue(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=m(He({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,$.jsx)(`div`,{className:o,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:We,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function We(e){if(e.target.closest(`button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']`))return;e.preventDefault();let t=e.currentTarget.parentElement,n=t?.querySelector(`input, textarea`);n&&!t?.querySelector(`input:focus, textarea:focus`)&&n.focus()}function Ge(e){let t=(0,Q.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,$.jsx)(B,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Ke=()=>{};function qe(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:s,refreshDisabled:c,inputDisabled:l,focusUrlNonce:u,onBack:f,onForward:p,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:x,pictureInPicture:S,pictureInPictureDisabled:C,onPickElement:T,pickActive:E,pickDisabled:O,pickDisabledReason:k,trailingActions:A}=e,ee=(0,Z.useRef)(null),[M,te]=(0,Z.useState)(n),[N,ne]=(0,Z.useState)(!1),P,F;t[0]===u?(P=t[1],F=t[2]):(P=()=>{if(u==null)return;let e=ee.current;e&&e.focus()},F=[u],t[0]=u,t[1]=P,t[2]=F),(0,Z.useEffect)(P,F);let I;t[3]!==M||t[4]!==g?(I=e=>{e?.preventDefault();let t=M.trim();t.length!==0&&(g(t),ee.current?.blur())},t[3]=M,t[4]=g,t[5]=I):I=t[5];let L=I,R=o?f:Ke,oe=!o,z;t[6]!==R||t[7]!==oe?(z=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:R,disabled:oe,"aria-label":`Back`,type:`button`}),t[6]=R,t[7]=oe,t[8]=z):z=t[8];let B;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ue,{}),t[9]=B):B=t[9];let V;t[10]===z?V=t[11]:(V=(0,$.jsx)(w,{render:z,children:B}),t[10]=z,t[11]=V);let H;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(D,{children:`Back`}),t[12]=H):H=t[12];let U;t[13]===V?U=t[14]:(U=(0,$.jsxs)(j,{children:[V,H]}),t[13]=V,t[14]=U);let se=s?p:Ke,W=!s,G;t[15]!==se||t[16]!==W?(G=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:W,"aria-label":`Forward`,type:`button`}),t[15]=se,t[16]=W,t[17]=G):G=t[17];let K;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(re,{}),t[18]=K):K=t[18];let q;t[19]===G?q=t[20]:(q=(0,$.jsx)(w,{render:G,children:K}),t[19]=G,t[20]=q);let de;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(D,{children:`Forward`}),t[21]=de):de=t[21];let J;t[22]===q?J=t[23]:(J=(0,$.jsxs)(j,{children:[q,de]}),t[22]=q,t[23]=J);let fe=c?Ke:h,pe=i?`Stop`:`Refresh`,me;t[24]!==c||t[25]!==fe||t[26]!==pe?(me=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:fe,disabled:c,"aria-label":pe,type:`button`}),t[24]=c,t[25]=fe,t[26]=pe,t[27]=me):me=t[27];let he=i&&`animate-spin`,Y;t[28]===he?Y=t[29]:(Y=m(he),t[28]=he,t[29]=Y);let ge;t[30]===Y?ge=t[31]:(ge=(0,$.jsx)(ie,{className:Y}),t[30]=Y,t[31]=ge);let _e;t[32]!==me||t[33]!==ge?(_e=(0,$.jsx)(w,{render:me,children:ge}),t[32]=me,t[33]=ge,t[34]=_e):_e=t[34];let ve=i?`Loading…`:`Refresh`,ye;t[35]===ve?ye=t[36]:(ye=(0,$.jsx)(D,{children:ve}),t[35]=ve,t[36]=ye);let be;t[37]!==_e||t[38]!==ye?(be=(0,$.jsxs)(j,{children:[_e,ye]}),t[37]=_e,t[38]=ye,t[39]=be):be=t[39];let xe;t[40]!==U||t[41]!==J||t[42]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[U,J,be]}),t[40]=U,t[41]=J,t[42]=be,t[43]=xe):xe=t[43];let Se=N?M:r??n,Ce=_&&!N&&`group-hover/address:pe-7 transition-[padding]`,we;t[44]===Ce?we=t[45]:(we=m(Ce),t[44]=Ce,t[45]=we);let Te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>te(e.target.value),t[46]=Te):Te=t[46];let Ee;t[47]===n?Ee=t[48]:(Ee=()=>{te(n),ne(!0),queueMicrotask(()=>ee.current?.select())},t[47]=n,t[48]=Ee);let De;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(De=()=>{ne(!1)},t[49]=De):De=t[49];let Oe;t[50]!==L||t[51]!==n?(Oe=e=>{e.key===`Enter`&&L(e),e.key===`Escape`&&(e.preventDefault(),te(n),ee.current?.blur())},t[50]=L,t[51]=n,t[52]=Oe):Oe=t[52];let ke;t[53]!==l||t[54]!==Se||t[55]!==we||t[56]!==Ee||t[57]!==Oe?(ke=(0,$.jsx)(w,{render:(0,$.jsx)(Ge,{ref:ee,value:Se,className:we,onChange:Te,onFocus:Ee,onBlur:De,onKeyDown:Oe,placeholder:`Search or enter URL`,spellCheck:!1,disabled:l,"data-preview-url-input":!0,size:`sm`})}),t[53]=l,t[54]=Se,t[55]=we,t[56]=Ee,t[57]=Oe,t[58]=ke):ke=t[58];let Ae;t[59]!==r||t[60]!==N||t[61]!==n?(Ae=!N&&r?(0,$.jsx)(D,{children:n}):null,t[59]=r,t[60]=N,t[61]=n,t[62]=Ae):Ae=t[62];let je;t[63]!==ke||t[64]!==Ae?(je=(0,$.jsxs)(j,{children:[ke,Ae]}),t[63]=ke,t[64]=Ae,t[65]=je):je=t[65];let Me;t[66]!==N||t[67]!==_?(Me=_&&!N?(0,$.jsx)(Ue,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(le,{})}),(0,$.jsx)(D,{children:`Open in system browser`})]})}):null,t[66]=N,t[67]=_,t[68]=Me):Me=t[68];let Ne;t[69]!==je||t[70]!==Me?(Ne=(0,$.jsxs)(Ve,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[je,Me]}),t[69]=je,t[70]=Me,t[71]=Ne):Ne=t[71];let Pe;t[72]!==T||t[73]!==E||t[74]!==O||t[75]!==k?(Pe=T?(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(d,{variant:E?`secondary`:`ghost`,size:`icon-xs`,onClick:T,disabled:O,"aria-label":E?`Cancel annotation`:`Annotate preview`,"aria-pressed":E?`true`:`false`,type:`button`}),children:(0,$.jsx)(ce,{className:m(E&&`text-primary`)})}),(0,$.jsx)(D,{children:O&&k?k:E?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=T,t[73]=E,t[74]=O,t[75]=k,t[76]=Pe):Pe=t[76];let Fe;t[77]!==y||t[78]!==v||t[79]!==b?(Fe=v?(0,$.jsxs)(j,{children:[(0,$.jsxs)(w,{render:(0,$.jsx)(d,{variant:b?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>v(e.shiftKey),"aria-label":b?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:y}),children:[(0,$.jsx)(Le,{className:m(b&&`text-destructive`)}),b?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(D,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=y,t[78]=v,t[79]=b,t[80]=Fe):Fe=t[80];let X;t[81]!==x||t[82]!==S||t[83]!==C?(X=x?(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(d,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:x,"aria-label":S?`Close floating preview`:`Float preview over chat`,"aria-pressed":S?`true`:`false`,type:`button`,disabled:C}),children:(0,$.jsx)(ae,{className:m(S&&`text-primary`)})}),(0,$.jsx)(D,{children:S?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=x,t[82]=S,t[83]=C,t[84]=X):X=t[84];let Ie;t[85]!==L||t[86]!==xe||t[87]!==Ne||t[88]!==Pe||t[89]!==Fe||t[90]!==X||t[91]!==A?(Ie=(0,$.jsxs)(`form`,{onSubmit:L,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[xe,Ne,Pe,Fe,X,A]}),t[85]=L,t[86]=xe,t[87]=Ne,t[88]=Pe,t[89]=Fe,t[90]=X,t[91]=A,t[92]=Ie):Ie=t[92];let Re;t[93]===a?Re=t[94]:(Re=a>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Re);let ze;return t[95]!==Ie||t[96]!==Re?(ze=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Re]}),t[95]=Ie,t[96]=Re,t[97]=ze):ze=t[97],ze}function Je(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function Ye(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=m(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=a):a=t[3];let o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Xe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=Ze(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ye,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(Qe,{}):(0,$.jsx)($e,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function Ze(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function Qe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function $e(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function et(e){let t=(0,Q.c)(7),n=he(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:pe(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=tt({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function tt(e){let t=new Map;for(let n of e.configuredUrls){let e=rt(n);if(!e)continue;let r=nt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=nt(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=rt(n);if(!e)continue;let r=nt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function nt(e,t){return`${e.toLowerCase()}:${t}`}function rt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!ke(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function it(e){let t=(0,Q.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=et(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(G,{children:[(0,$.jsx)(R,{variant:`icon`,children:(0,$.jsx)(U,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(xe,{children:`No preview yet`}),(0,$.jsx)(Ce,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Be,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(Xe,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var at=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ot(t){let n=(0,Q.c)(74),{tabId:i,hasWebContents:o,zoomFactor:c,colorScheme:u,deviceToolbarVisible:f,onToggleDeviceToolbar:p,nativePictureInPicture:m,onNativePictureInPicture:h}=t;if(!L)return null;let g=!i||!o,_;n[0]===i?_=n[1]:(_=e=>()=>{i&&e(i).catch(mt)},n[0]=i,n[1]=_);let b=_,x;n[2]===c?x=n[3]:(x=Math.round(c*100),n[2]=c,n[3]=x);let S=`${x}%`,C;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsxs)(j,{children:[(0,$.jsx)(w,{render:(0,$.jsx)(s,{render:(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Re,{})}),(0,$.jsx)(D,{children:`More`})]}),n[4]=C):C=n[4];let T;n[5]===b?T=n[6]:(T=b(L.hardReload),n[5]=b,n[6]=T);let E;n[7]!==T||n[8]!==g?(E=(0,$.jsx)(P,{onClick:T,disabled:g,children:`Hard reload`}),n[7]=T,n[8]=g,n[9]=E):E=n[9];let O;n[10]===b?O=n[11]:(O=b(L.openDevTools),n[10]=b,n[11]=O);let k;n[12]!==O||n[13]!==g?(k=(0,$.jsx)(P,{onClick:O,disabled:g,children:`Open DevTools`}),n[12]=O,n[13]=g,n[14]=k):k=n[14];let A=m?`Close separate preview window`:`Open separate preview window`,M;n[15]!==h||n[16]!==A||n[17]!==g?(M=(0,$.jsx)(P,{onClick:h,disabled:g,children:A}),n[15]=h,n[16]=A,n[17]=g,n[18]=M):M=n[18];let te=f?`Hide device toolbar`:`Show device toolbar`,N;n[19]!==p||n[20]!==te||n[21]!==g?(N=(0,$.jsx)(P,{onClick:p,disabled:g,children:te}),n[19]=p,n[20]=te,n[21]=g,n[22]=N):N=n[22];let ne;n[23]===g?ne=n[24]:(ne=(0,$.jsx)(ee,{disabled:g,children:`Appearance`}),n[23]=g,n[24]=ne);let F;n[25]===i?F=n[26]:(F=e=>{i&&L.setColorScheme(i,e).catch(pt)},n[25]=i,n[26]=F);let re;n[27]===Symbol.for(`react.memo_cache_sentinel`)?(re=at.map(ft),n[27]=re):re=n[27];let I;n[28]!==u||n[29]!==F?(I=(0,$.jsx)(l,{className:`min-w-32`,children:(0,$.jsx)(y,{value:u,onValueChange:F,children:re})}),n[28]=u,n[29]=F,n[30]=I):I=n[30];let R;n[31]!==ne||n[32]!==I?(R=(0,$.jsxs)(r,{children:[ne,I]}),n[31]=ne,n[32]=I,n[33]=R):R=n[33];let ie;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(v,{}),n[34]=ie):ie=n[34];let ae;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),n[35]=ae):ae=n[35];let z;n[36]===b?z=n[37]:(z=b(L.zoomOut),n[36]=b,n[37]=z);let B;n[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(we,{}),n[38]=B):B=n[38];let V;n[39]!==z||n[40]!==g?(V=(0,$.jsx)(d,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:z,"aria-label":`Zoom out`,disabled:g,children:B}),n[39]=z,n[40]=g,n[41]=V):V=n[41];let H;n[42]===S?H=n[43]:(H=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:S}),n[42]=S,n[43]=H);let U;n[44]===b?U=n[45]:(U=b(L.zoomIn),n[44]=b,n[45]=U);let se;n[46]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(oe,{}),n[46]=se):se=n[46];let W;n[47]!==U||n[48]!==g?(W=(0,$.jsx)(d,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:U,"aria-label":`Zoom in`,disabled:g,children:se}),n[47]=U,n[48]=g,n[49]=W):W=n[49];let G;n[50]===b?G=n[51]:(G=b(L.resetZoom),n[50]=b,n[51]=G);let ce;n[52]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Ie,{}),n[52]=ce):ce=n[52];let K;n[53]!==G||n[54]!==g?(K=(0,$.jsx)(d,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:G,"aria-label":`Reset zoom`,disabled:g,children:ce}),n[53]=G,n[54]=g,n[55]=K):K=n[55];let le;n[56]!==V||n[57]!==H||n[58]!==W||n[59]!==K?(le=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[V,H,W,K]}),n[56]=V,n[57]=H,n[58]=W,n[59]=K,n[60]=le):le=n[60];let q;n[61]!==le||n[62]!==g?(q=(0,$.jsxs)(P,{closeOnClick:!1,onClick:dt,className:`justify-between`,disabled:g,children:[ae,le]}),n[61]=le,n[62]=g,n[63]=q):q=n[63];let ue,de,J;n[64]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(v,{}),de=(0,$.jsx)(P,{onClick:lt,children:`Clear cookies`}),J=(0,$.jsx)(P,{onClick:st,children:`Clear cache`}),n[64]=ue,n[65]=de,n[66]=J):(ue=n[64],de=n[65],J=n[66]);let fe;return n[67]!==N||n[68]!==R||n[69]!==q||n[70]!==E||n[71]!==k||n[72]!==M?(fe=(0,$.jsxs)(a,{children:[C,(0,$.jsxs)(e,{align:`end`,sideOffset:6,className:`min-w-56`,children:[E,k,M,N,R,ie,q,ue,de,J]})]}),n[67]=N,n[68]=R,n[69]=q,n[70]=E,n[71]=k,n[72]=M,n[73]=fe):fe=n[73],fe}function st(){L.clearCache().catch(ct)}function ct(){}function lt(){L.clearCookies().catch(ut)}function ut(){}function dt(e){return e.preventDefault()}function ft(e){return(0,$.jsx)(i,{value:e.value,children:e.label},e.value)}function pt(){}function mt(){}function ht(e){return ye[e]||(e.length>0?e:`Network error`)}function gt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=yt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=ht(i),t[2]=i,t[3]=u);let f=u,p;t[4]!==r||t[5]!==i?(p=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=p):p=t[6];let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(vt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==f||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,f,`.`]}),t[11]=f,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(_t),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(d,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[h,g,v,y,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function _t(e){return!e}function vt(e){let t=(0,Q.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function yt(e){try{return new URL(e).host}catch{return null}}function bt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var xt=120,St=220,Ct=4,wt=90,Tt=.08,Et=.5;function Dt(e){let[t,n]=(0,Z.useState)(0),r=(0,Z.useRef)(0);return r.current=t,(0,Z.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),St);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Ct);let t=window.setInterval(()=>{let e=r.current;if(e>=wt)return;let t=wt-e,i=Math.max(Et,t*Tt);n(Math.min(wt,e+i))},xt);return()=>window.clearInterval(t)},[e]),t}var Ot=class extends O()(`PreviewSessionThreadKeyParseError`,{threadKey:C}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},kt=p(e=>{let t=M(e);if(t===null)throw new Ot({threadKey:e});let n=Te.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=Te.events({environmentId:t.environmentId,input:{}});return o(e=>{let i=!1,a=0,o=e=>{b(e)&&ge(t,e.value)},s=r=>{if(!b(r)||r.value.threadId!==t.threadId)return;let i=I(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}J(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(u(1e3),F(`preview:session-sync:${e}`))});function At(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=kt(x(e)),t[0]=e,t[1]=n),E(n)}var jt=1500,Mt=.001;function Nt(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Mt))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},jt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=m(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,f),t[5]=f,t[6]=p);let h;return t[7]!==u||t[8]!==d||t[9]!==p?(h=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=h):h=t[10],h}function Pt(e,t){return e?1:t===`human`?.18:.35}var Ft=700;function It(e){let t=(0,Q.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=me(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=z(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Lt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function Lt(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Ft);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Pt(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ze,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Rt=typeof window>`u`?null:h();function zt({threadRef:e,tabId:n,configuredUrls:r,visible:i}){let[a,o]=(0,Z.useState)(void 0),[s,l]=(0,Z.useState)(!1),u=Oe(),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!0),p=je(e),m=V(t=>be(t.byThreadKey,e)),h=c(e=>e.addPreviewAnnotation),_=c(e=>e.addImage),v=ne(e.environmentId),y=S(e.environmentId),b=N(Te.open),C=N(Te.resize,`preview viewport resize`);At(e),(0,Z.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let w=n??p.activeTabId,T=w?se(e,p.serverEpoch,w):null,E=w&&T?u.has(T)?T:Ae(e,w):null,D=w?p.sessions[w]??null:null,O=w?p.desktopByTabId[w]??null:null,A=D?.navStatus??{_tag:`Idle`},j=A._tag===`Idle`?``:A.url,ee=O?.loading??A._tag===`Loading`,M=O?.canGoBack??D?.canGoBack??!1,te=O?.canGoForward??D?.canGoForward??!1,P=A._tag===`Idle`,F=A._tag===`LoadFailed`,re=Se(D),I=O?.controller??`none`,R=Dt(ee),ie=j&&v&&y?Je({url:j,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,ae=D?.viewport??t,oe=z(e=>T?e.byTabId[T]?.rect??null:null),B=(0,Z.useCallback)(async t=>{T&&L?(await L.navigate(T,t),Fe(e,t)):await de({openPreview:b,threadRef:e,url:t})},[b,T,e]),U=(0,Z.useCallback)(async e=>{try{await B(Ne(e))}catch{}},[B]),W=(0,Z.useCallback)(async t=>{try{await B(pe(e.environmentId,t))}catch{}},[B,e.environmentId]),G=(0,Z.useCallback)(()=>{L&&T&&L.refresh(T)},[T]),ce=(0,Z.useCallback)(()=>{L&&T&&L.zoomIn(T)},[T]),le=(0,Z.useCallback)(()=>{L&&T&&L.zoomOut(T)},[T]),q=(0,Z.useCallback)(()=>{L&&T&&L.resetZoom(T)},[T]),ue=(0,Z.useCallback)(async t=>{if(!w)return;let n=await C({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:w,viewport:t}});if(n._tag===`Failure`){let e=g(n);throw X.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}De(e,n.value)},[C,w,e]),J=()=>{if(!T)return;if(ae._tag!==`fill`){Pe(T,t).catch(()=>void 0);return}let e=oe?Me(oe,O?.zoomFactor):{width:1024,height:768};Pe(T,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(T)return Ee(T,ue)},[ue,T]);let me=(0,Z.useCallback)(()=>{L&&T&&L.goBack(T)},[T]),he=(0,Z.useCallback)(()=>{L&&T&&L.goForward(T)},[T]),ge=(0,Z.useCallback)(()=>{!Rt||!j||Rt.shell.openExternal(j).catch(()=>void 0)},[j]),ye=(0,Z.useCallback)(()=>{if(w){if(m?.tabId===w){V.getState().close(e);return}V.getState().open(e,w),k.getState().close(e)}},[m?.tabId,w,e]),xe=(0,Z.useCallback)(()=>{!L||!T||(O?.pictureInPicture?L.pictureInPicture.close:L.pictureInPicture.open)(T).catch(e=>{X.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[O?.pictureInPicture,T]),Ce=(0,Z.useCallback)(t=>{if(!L||!T||!w)return;let n=L;if(E){fe(E).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{X.update(r,Y({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:bt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{X.update(r,Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=X.add(Y({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){ve(T,e,w).catch(e=>{X.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(T).then(e=>{let t={children:bt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{X.update(a,Y({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=X.add(Y({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{X.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[E,T,w,e]),we=(0,Z.useCallback)(()=>{if(!L||!T)return;if(d.current){L.cancelPickElement(T).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await L.pickElement(T);if(!t)return;h(e,t);let n=await _e(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,f.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,h,T,e]);return(0,Z.useEffect)(()=>()=>{d.current&&(d.current=!1,L&&T&&L.cancelPickElement(T).catch(()=>void 0),f.current&&l(!1))},[T]),(0,Z.useEffect)(()=>{if(i)return H(e=>{switch(e){case`refresh`:G();return;case`focus-url`:o(e=>(e??0)+1);return;case`zoom-in`:ce();return;case`zoom-out`:le();return;case`reset-zoom`:q();return;case`toggle-panel`:return}})},[G,q,ce,le,i]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":x(e),children:[(0,$.jsx)(qe,{url:j,displayUrl:ie,loading:ee,loadProgress:R,canGoBack:M,canGoForward:te,refreshDisabled:P,focusUrlNonce:a,onBack:me,onForward:he,onRefresh:G,onSubmit:e=>void U(e),onOpenInBrowser:w?ge:void 0,onCapture:L&&w?Ce:void 0,captureDisabled:!O||F,recording:E!==null,onPictureInPicture:L&&w?ye:void 0,pictureInPicture:m?.tabId===w,pictureInPictureDisabled:!O?.hasWebContents||F,onPickElement:L&&w?we:void 0,pickActive:s,pickDisabled:!w||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:L?(0,$.jsx)(ot,{tabId:T,hasWebContents:O?.hasWebContents??!1,zoomFactor:O?.zoomFactor??1,colorScheme:O?.colorScheme??`system`,deviceToolbarVisible:ae._tag!==`fill`,onToggleDeviceToolbar:J,nativePictureInPicture:O?.pictureInPicture??!1,onNativePictureInPicture:xe}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[T&&D&&!re?(0,$.jsx)(K,{tabId:T,visible:i&&!F,className:`absolute inset-0 h-full w-full`},T):null,re?(0,$.jsx)(it,{environmentId:e.environmentId,configuredUrls:r,recentlySeenUrls:p.recentlySeenUrls,onOpenUrl:e=>void W(e)}):null,D&&O?(0,$.jsx)(Nt,{zoomFactor:O.zoomFactor}):null,T&&O&&!re&&!F?(0,$.jsx)(It,{tabId:T,zoomFactor:O.zoomFactor,controller:I}):null,I===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:I===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(gt,{url:A.url,code:A.code,description:A.description,onReload:G})}):null]})]})}function Bt(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!q()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(W,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(zt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(W,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Bt as PreviewPanel};
2
+ //# sourceMappingURL=PreviewPanel-B5G_VRJZ.js.map