@hyperpuncher/pi-ui 0.43.1 → 0.43.3
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{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e as Kr,f as na,g as Qs,h as Zs,i as Zr,j as ra,k as Jr,n as ia,o as ao,p as lo,q as ti,r as oa,s as Ou,t as fd,u as sa,v as aa,w as co,x as dr,y as la,z as pd}from"./main-27505rdd.js";import{H as Lh}from"./main-mwzht33t.js";import{_ as io,qa as ei,ra as oo,sa as so}from"./main-f40c0hm2.js";import{gc as Yu,hc as Xu}from"./main-pq3eh5fy.js";import{ic as Wn,jc as un,kc as Pu,lc as qt}from"./main-b1kpnx3v.js";import{mc as Nh,pc as km}from"./main-jgbmmpjx.js";function Zi(e){let t=[];for(let n of e){let r=Kr.get(n);if(r==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function Ji(e){for(let t of Array.isArray(e)?e:[e])if(!Kr.has(t))return!1;return!0}async function eo(e){let t=[],n=[];for(let r of e){if(r==="text"||r==="ansi")continue;let i=Zs(r)??Qs(r);if("then"in i)n.push(i);else t.push(i)}if(n.length>0)await Promise.all(n).then((r)=>{for(let i of r){if(i==null)throw Error("resolvedLanguages: unable to resolve language");t.push(i)}});return t}function to(e){return Gr.getResolvedThemes(e)}async function no(e){for(let n of e)Js(n);let t=await Gr.resolveThemes(e);for(let n=0;n<e.length;n++)ea(e[n],t[n]);return t}var uo=Nh(Lh(),1),Yr=Symbol("IGNORE_RESPONSE"),Fh=1e4,Xr=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},ro=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed")}},ca=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=io,useTokenTransformer:r=!1,lineDiffType:i="word-alt",maxLineDiffLength:o=1000,tokenizeMaxLineLength:s=1000,preferredHighlighter:a="shiki-js"}){this.options=e,this.preferredHighlighter=a,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:o,tokenizeMaxLineLength:s},this.fileCache=new uo.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new uo.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??io,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1000,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1000}){let{lifecycleGeneration:o}=this,s=++this.renderOptionsRequestVersion,a=()=>this.isCurrentLifecycle(o)&&this.renderOptionsRequestVersion===s;try{let l={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(!this.isInitialized())await this.initialize();if(!a()||dr(l,this.renderOptions))return;let d=Zr(e),u=[];if(!ia(l.theme,this.renderOptions.theme))if(lo(d))u=to(d);else u=await no(d);if(!a())return;if(this.highlighter!=null)ra(u,this.highlighter);else{let c=await Jr({themes:d,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!a())return;this.highlighter=c}let f=this.setRenderOptionsOnWorkers(l,u);this.renderOptions=l,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let c of this.themeSubscribers)c.onThemeChange();await f}catch(l){if(l instanceof Xr||!a())return;throw l}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;if(!this.isInitialized())await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");n.push(new Promise((i,o)=>{let s=this.generateRequestId(),a={type:"set-render-options",id:s,request:{type:"set-render-options",id:s,renderOptions:e,resolvedThemes:t},resolve:i,reject:o,requestStart:Date.now()};this.activeTaskById.set(s,a),r.pendingSetupRequestId=s,r.worker.postMessage(a.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){if(this._queuedBroadcast!=null)return;this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{if(this._queuedBroadcast!=null)cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0;let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);if(At(n)){if(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeActiveTask(n)}else this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0)return;else if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let i=Zr(this.renderOptions.theme),o=[];if(lo(i))o=to(i);else o=await no(i);if(!this.isCurrentLifecycle(t)){n();return}let s=[];if(Ji(e))s=Zi(e);else s=await eo(e);if(!this.isCurrentLifecycle(t)){n();return}let[a]=await Promise.all([Jr({themes:i,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(o,s)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=a,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(i){if(i instanceof Xr||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(let o of this.queuedTasks)this.rejectRenderTaskCallbacks(o,Qr(i));this.queueBroadcastStateChanges(),r(i)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=oo(),i=r>0?so():void 0;if(this.workers.length>0)this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let l=this.options.workerFactory(),d={worker:l,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:u})=>u)]),customExtensionsVersion:0};l.addEventListener("message",(u)=>{this.handleWorkerMessage(d,u.data)}),l.addEventListener("error",(u)=>this.handleWorkerError(d,u)),this.workers.push(d),n.push(new Promise((u,f)=>{let c=this.generateRequestId(),m={type:"initialize",id:c,request:{type:"initialize",id:c,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i!=null?r:void 0,customExtensionMap:i},resolve(){d.initialized=!0,u()},reject:f,requestStart:Date.now()};d.pendingSetupRequestId=c,this.activeTaskById.set(c,m),this.executeTask(d,m)}))}let o=this.options.workerInitializationTimeout??Fh,s;try{await Promise.race([Promise.all(n),new Promise((a,l)=>{s=setTimeout(()=>{l(Error(`WorkerPoolManager: worker initialization timed out after ${o}ms`))},o)})])}finally{if(s!=null)clearTimeout(s)}}handleWorkerError(e,t){console.error("Worker error:",t,e);let{pendingSetupRequestId:n}=e;if(n==null)return;let r=this.activeTaskById.get(n);if(r?.type!=="initialize")return;r.reject(Qr(t)),this.cleanWorkerAndTask(e,r)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized!==!0||this.queuedTasks.length===0)return;for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=ta(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()};highlightFileAST(e,t){let n=this.getFileResultCache(t);if(ao(t)||n!=null&&ti(n.options,this.getFileRenderOptions()))return;if(!this.hasMatchingFileInstanceTask(e,t))this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeFileHighlightCache: worker pool is not working"));let t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||ao(e)||t!=null&&ti(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="file"?r:void 0;else{let i=this.submitCacheTask({type:"file",file:e},n);return i.type==="file"?i:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return oa(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);if(co(t)||n!=null&&dr(n.options,this.getDiffRenderOptions()))return;if(!this.hasMatchingDiffInstanceTask(e,t))this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeDiffHighlightCache: worker pool is not working"));let t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||co(e)||t!=null&&dr(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="diff"?r:void 0;else{let i=this.submitCacheTask({type:"diff",diff:e},n);return i.type==="diff"?i:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter!=null?la(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new Xr;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch((t)=>{console.error(t)})}cancelActiveWorkerTasks(){let e=new Xr;for(let t of this.activeTaskById.values())if("reject"in t)t.reject(e);else if(At(t))this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:(()=>{if(this.initialized===!1)return"waiting";if(this.initialized!==!0)return"initializing";return"initialized"})(),totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter((e)=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n!=null?this.getTaskByHighlightKey(n):void 0;if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),o=Date.now(),{renderOptionsVersion:s}=this,a=(()=>{switch(t.type){case"file":return{type:"file",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o};case"diff":return{type:"diff",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o}}})();this.enqueueRenderTask(a,e)}submitCacheTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,o=(()=>{switch(e.type){case"file":return{type:"file",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case"diff":return{type:"diff",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(o),o}enqueueRenderTask(e,t){if(this.queuedTasks.push(e),t!=null)this.queuedTaskByInstance.set(t,e);if(e.highlightKey!=null)this.taskByHighlightKey.set(e.highlightKey,e);this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter((o)=>!na(o));if(r.length>0)Jr({themes:Zr(this.renderOptions.theme),langs:["text",...r],preferredHighlighter:this.preferredHighlighter}).catch((o)=>{console.error(o)});let i=n.filter((o)=>!e.langs.has(o));if(i.length>0)if(Ji(i))t.request.resolvedLanguages=Zi(i);else t.request.resolvedLanguages=await eo(i);if(!this.activeTaskById.has(t.id)){if(e.requestId===t.id){if(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}return}this.executeTask(e,t)}catch(r){if(this.rejectRenderTaskCallbacks(t,Qr(r)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw Yr;else if(t.type==="error"){let r=Error(t.error);if(t.stack)r.stack=t.stack;if("reject"in n)n.reject(r);else if(At(n))this.notifyHighlightError(n,r),this.rejectRenderTaskCallbacks(n,r);else throw Error("handleWorkerMessage: unknown task type");throw r}else switch(t.requestType){case"initialize":if(n.type!=="initialize")throw Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case"set-render-options":if(n.type!=="set-render-options")throw Error("handleWorkerMessage: task/response dont match");n.resolve();break;case"file":{if(n.type!=="file")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!ti(i,this.getFileRenderOptions()))throw Yr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case"diff":{if(n.type!=="diff")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!dr(i,this.getDiffRenderOptions()))throw Yr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(r){if(r!==Yr)console.error(r,n,t)}if(this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}_queuedDrain;queueDrain(){if(this._queuedDrain!=null)return;this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges()}assignWorkerToTask(e,t){if(t.requestId=e.id,At(e))this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e);this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){if(e.requestId===n)e.requestId=void 0;if(e.pendingSetupRequestId===n)e.pendingSetupRequestId=void 0;if(t!=null){if(At(t))this.rejectRenderTaskCallbacks(t,new ro),this.clearInstanceRequests(t),this.clearHighlightKey(t);this.activeTaskById.delete(t.id)}}executeTask(e,t){if(Bh(t.request))this.maybeAttachCustomExtensions(e,t.request);if(!this.activeTaskById.has(t.id))this.assignWorkerToTask(t,e);for(let n of ta(t))e.langs.add(n);try{if(t.type==="file")t.cacheKeyAtDispatch=t.request.file.cacheKey;else if(t.type==="diff")t.cacheKeyAtDispatch=t.request.diff.cacheKey;e.worker.postMessage(t.request)}catch(n){if(console.error("Failed to post message to worker:",n),At(t))this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Qr(n));else if("reject"in t)t.reject(n);if(this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0)this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=oo();if(e.customExtensionsVersion>=n)return;t.customExtensionsVersion=n,t.customExtensionMap=so()}syncCustomExtensionVersion(e,t){if(t.customExtensionsVersion==null)return;e.customExtensionsVersion=t.customExtensionsVersion}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let i of e)if(!n.langs.has(i)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey==null)return;return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey==null)return;return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of ur(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){if(e.type==="file")e.instances.add(t);else e.instances.add(t);if(this.activeTaskById.has(e.id))this.activeRequestByInstance.set(t,e.id);else this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);if(n==null||n===t)return;if(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeQueuedTask(n)}detachInstanceFromRenderTask(e,t){if(e.type==="file")e.instances.delete(t);else e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);if(t!==-1)this.queuedTasks.splice(t,1);this.rejectRenderTaskCallbacks(e,new ro),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new ro),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];if(t.renderOptionsVersion!==this.renderOptionsVersion)this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))if(At(e)&&e.renderOptionsVersion!==this.renderOptionsVersion)this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of ur(e))if(this.queuedTaskByInstance.get(t)===e)this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){if(e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e)this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of ur(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of ur(e))if(this.activeRequestByInstance.get(t)===e.id)this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of ur(e))if(this.activeRequestByInstance.get(n)===e.id)n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="file"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&aa(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="diff"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&sa(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())if(At(e))yield e}generateRequestId(){return`req_${++this.nextRequestId}`}};function Bh(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function ta(e){let t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??ei(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??ei(e.request.diff.name)),t.add(e.request.diff.lang??ei(e.request.diff.prevName??"-"));break}return t.delete("text"),Array.from(t)}function At(e){return e?.type==="file"||e?.type==="diff"}function ur(e){return e.instances}function Qr(e){if(e instanceof Error)return e;if(e!=null&&typeof e==="object"){if("error"in e&&e.error instanceof Error)return e.error;if("message"in e&&typeof e.message==="string")return Error(e.message)}return Error(String(e))}var hr;function ho({poolOptions:e,highlighterOptions:t}){return hr??=new ca(e,t),hr}function fo(){if(hr==null)return;hr.terminate(),hr=void 0}function rn(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function po(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Nt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let i=e[r];if(i!=null)n.set(i.nameId,r)}return t.childIdByNameId=n,n}function Sn(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];if(r!=null)t.set(r,n)}return e.childPositionById=t,t}function Cn(e,t){if(e.childPositionById!=null)e.childPositionById.set(t,e.childIds.length);e.childIds.push(t)}function mo(e,t){if(e.childPositionById==null)return;for(let n=t;n<e.childIds.length;n++){let r=e.childIds[n];if(r!=null)e.childPositionById.set(r,n)}}function on(e,t){let n=0,r=0;for(let i of t.childIds){let o=e[i];if(o==null)continue;n+=o.subtreeNodeCount,r+=o.visibleSubtreeCount}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,Lt(e,t)}function ni(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Sn(e).get(t);if(i===void 0)return;let o=i>>5;e.childVisibleChunkSums[o]+=r}function ri(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let o=n,s=0;for(let a of r){if(o<a){let l=Hh(e,t,s,o);return{...l,childVisibleIndex:n-l.localVisibleIndex}}o-=a,s+=32}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let o=0;o<t.childIds.length;o++){let s=t.childIds[o];if(s==null)continue;let a=e[s];if(a==null)continue;if(i<a.visibleSubtreeCount)return{childIndex:o,childVisibleIndex:n-i,localVisibleIndex:i};i-=a.visibleSubtreeCount}throw Error(`Visible child index ${String(n)} is out of range`)}function ua(e,t,n){let r=0,i=t.childVisibleChunkSums,o=0;if(i!=null){let s=n>>5;for(let a=0;a<s;a+=1)r+=i[a]??0;o=s<<5}for(let s=o;s<n;s+=1){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;r+=l.visibleSubtreeCount}return r}function Lt(e,t){if(t.childIds.length<128){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/32),r=new Int32Array(n);for(let i=0;i<t.childIds.length;i++){let o=t.childIds[i];if(o==null)continue;let s=e[o];if(s==null)continue;r[i>>5]+=s.visibleSubtreeCount}t.childVisibleChunkSums=r}function Hh(e,t,n,r){let i=Math.min(t.childIds.length,n+32),o=r;for(let s=n;s<i;s++){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;if(o<l.visibleSubtreeCount)return{childIndex:s,localVisibleIndex:o};o-=l.visibleSubtreeCount}throw Error(`Visible child index ${String(r)} is out of range`)}function Ae(e,t,n=0){return e<<4|n<<3|t}function qe(e){return e.depthAndFlags>>>4}function fr(e){return(e.depthAndFlags&8)>>3}function R(e){return(e.depthAndFlags&8)!==0}function da(e){return e.depthAndFlags&7}function ue(e,t){return(da(e)&t)!==0}function xn(e,t){e.depthAndFlags|=t}function ha(e,t){e.depthAndFlags=Ae(t,da(e),fr(e))}var fa=Symbol("benchmarkInstrumentation");function pa(e,t){if(t==null)return e;return Object.defineProperty(e,fa,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function pr(e){if(e==null)return null;return e[fa]??null}function E(e,t,n){if(e==null)return n();return e.measurePhase(t,n)}function kn(e,t,n){if(!Number.isFinite(n)||e==null)return;e.setCounter(t,n)}function ma(e){return e>=48&&e<=57}function Vh(e){let t=[],n=0,r=0;while(r<e.length){while(r<e.length&&!ma(e.charCodeAt(r)))r+=1;if(r>=e.length)break;if(r>n)t.push(e.slice(n,r));let i=0;while(r<e.length&&ma(e.charCodeAt(r)))i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}if(n<e.length||t.length===0)t.push(e.slice(n));return t}function sn(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Vh(t)}}function Oh(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let i=e[r],o=t[r];if(i===o)continue;if(typeof i==="number"&&typeof o==="number")return i<o?-1:1;let s=String(i),a=String(o);if(s!==a)return s<a?-1:1}if(e.length!==t.length)return e.length<t.length?-1:1;return 0}function mr(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==="string"&&typeof t.tokens[0]==="string"){if(e.lowerValue===t.lowerValue)return 0;return e.lowerValue<t.lowerValue?-1:1}let n=Oh(e.tokens,t.tokens);if(n!==0)return n;if(e.lowerValue!==t.lowerValue)return e.lowerValue<t.lowerValue?-1:1;return 0}function ga(e,t,n){let r=mr(n(e),n(t));if(r!==0)return r;if(e===t)return 0;return e<t?-1:1}function qh(e,t){return ga(e,t,sn)}function ii(e,t){if(t!==e.segments.length-1)return 1;return e.isDirectory?1:0}function zh(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let i=e.segments[r],o=t.segments[r];if(i===o)continue;let s=ii(e,r);if(s!==ii(t,r))return s===1?-1:1;return qh(i,o)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function va(e,t){return zh(e,t)}function ya(e,t,n){let r=(o)=>{let s=n.get(o);if(s!=null)return s;let a=sn(o);return n.set(o,a),a},i=Math.min(e.segments.length,t.segments.length);for(let o=0;o<i;o++){let s=e.segments[o],a=t.segments[o];if(s===a)continue;let l=ii(e,o);if(l!==ii(t,o))return l===1?-1:1;return ga(s,a,r)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function gr(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=sn(r);return e.sortKeyById[t]=i,i}function go(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??"default"}}function ba(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let o=0;o<n;o++){if(e.charCodeAt(o)!==47)continue;r.push(e.slice(i,o)),i=o+1}return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function an(e){let{hasTrailingSlash:t,segments:n}=ba(e);return{basename:n[n.length-1]??"",isDirectory:t,path:e,segments:n}}function oi(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=ba(e);return{requiresDirectory:t,segments:n}}function si(){let e=new Map;return e.set("",0),{idByValue:e,valueById:[""],sortKeyById:[sn("")]}}function st(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 Ue(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var vo=Symbol("pathStorePreparedInputKind");function Sa(e,t){return e[vo]=t,e}function wa(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function Ca(e,t,n){if(n==="default")return va(e,t);return n(wa(e),wa(t))}function Wh(){return{depthAndFlags:Ae(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function $h(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 Ia(e){return e.isDirectory?e.segments.length:e.segments.length-1}function jh(e){return Array.isArray(e)&&e.every((t)=>t!=null&&typeof t==="object"&&typeof t.path==="string"&&Array.isArray(t.segments)&&typeof t.basename==="string"&&typeof t.isDirectory==="boolean")}function Uh(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function xa(e,t={}){return ai(e,t).map((n)=>n.path)}function ka(e,t={}){let n=ai(e,t);return Sa({paths:n.map((r)=>r.path),preparedPaths:n},"prepared")}function _a(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let i=e[r];if(i.length>0&&i.charCodeAt(i.length-1)===47){n=!0;break}}return Sa({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},"presorted")}function Ea(e){let t=e,n=t.preparedPaths;if(t[vo]==="prepared"&&n!=null)return n;if(!jh(n))throw Error("preparedInput must come from PathStore.prepareInput()");return n}function Ta(e){let t=e;if(t[vo]==="presorted"&&t.presortedPaths!=null)return t.presortedPaths;return Uh(t.presortedPaths)?t.presortedPaths:null}function Pa(e){let t=e;return typeof t.presortedPathsContainDirectories==="boolean"?t.presortedPathsContainDirectories:null}function ai(e,t={}){let n=go(t),r=pr(t);kn(r,"workload.inputFiles",e.length);let i=E(r,"store.preparePathEntries.parse",()=>e.map((o)=>an(o)));return E(r,"store.preparePathEntries.sort",()=>i.sort((o,s)=>Ca(o,s,n.sort))),i}var li=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Wh()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=si();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=pr(e),this.options=go(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let n=new Set,r=t.length;for(let i=0;i<r;i+=1){let o=t[i],s=o.length;n.add(s>0&&o.charCodeAt(s-1)===47?o.slice(0,s-1):o)}this.initialExpandedPathSet=n,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,rn())}appendPaths(e){return E(this.instrumentation,"store.builder.appendPaths.parse",()=>this.appendPreparedPaths(e.map((t)=>an(t))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,E(this.instrumentation,"store.builder.appendPreparedPaths",()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return E(this.instrumentation,"store.builder.appendPresortedPaths",()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,o=this.segmentTable,s=o.idByValue,a=o.valueById,l=this.directoryStack,d=0,u="",f=0;for(let c of e){if(n===c)throw Error(`Duplicate path: "${c}"`);let m=c.length>0&&c.charCodeAt(c.length-1)===47,p=m?c.length-1:c.length,g=0,v=0;if(n!=null)if(u.length>0&&c.length>u.length&&c.startsWith(u))g=f,v=u.length;else{let y=Math.min(p,n.length),S=!0;for(let x=0;x<y;x++){let T=c.charCodeAt(x);if(T!==n.charCodeAt(x)){S=!1;break}if(T===47)g++,v=x+1}if(S&&m&&y===p&&n.length>p&&n.charCodeAt(p)===47)g++,v=p+1}d=g,r=g;let I=v,C=c.indexOf("/",I);while(C>=0&&C<p){let y=l[d];if(y===void 0)throw Error("Directory stack underflow while building the path store");r++;let S=c.slice(I,C),x=s.get(S);if(x===void 0)x=a.length,s.set(S,x),a.push(S);let T=i.length;i.push({depthAndFlags:Ae(r,0,1),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(c.slice(0,C)),d++,l[d]=T,I=C+1,C=c.indexOf("/",I)}if(m){if(I<p){let S=l[d];if(S===void 0)throw Error(`Unable to resolve directory parent for "${c}"`);r++;let x=c.slice(I,p),T=s.get(x);if(T===void 0)T=a.length,s.set(x,T),a.push(x);let O=i.length;i.push({depthAndFlags:Ae(r,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),d++,l[d]=O,I=p+1}let y=l[d];if(y===void 0)throw Error(`Unable to resolve directory node for "${c}"`);this.promoteDirectoryToExplicit(y,c)}else{let y=l[d];if(y===void 0)throw Error(`Unable to resolve file parent for "${c}"`);let S=c.slice(I),x=s.get(S);if(x===void 0)x=a.length,s.set(S,x),a.push(S);i.push({depthAndFlags:Ae(r+1,0),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1})}if(I!==u.length)u=c.substring(0,I),f=r;n=c}if(l.length=d+1,n!=null)this.lastPreparedPath=an(n);this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,o=i.idByValue,s=i.valueById,a=this.directoryStack,l=0,d="",u=0;for(let f of e){if(t===f)throw Error(`Duplicate path: "${f}"`);let c=f.length,m=0,p=0;if(t!=null)if(d.length>0&&f.length>d.length&&f.startsWith(d))m=u,p=d.length;else{let S=Math.min(c,t.length);for(let x=0;x<S;x++){let T=f.charCodeAt(x);if(T!==t.charCodeAt(x))break;if(T===47)m++,p=x+1}}l=m,n=m;let g=p,v=f.indexOf("/",g);while(v>=0){let S=a[l];if(S===void 0)throw Error("Directory stack underflow while building the path store");n++;let x=f.slice(g,v),T=o.get(x);if(T===void 0)T=s.length,o.set(x,T),s.push(x);let O=r.length;r.push({depthAndFlags:Ae(n,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(f.slice(0,v)),this.presortedDirectoryNodeIds.push(O),l++,a[l]=O,g=v+1,v=f.indexOf("/",g)}let I=a[l];if(I===void 0)throw Error(`Unable to resolve file parent for "${f}"`);let C=f.slice(g),y=o.get(C);if(y===void 0)y=s.length,o.set(C,y),s.push(C);if(r.push({depthAndFlags:Ae(n+1,0),nameId:y,parentId:I,subtreeNodeCount:1,visibleSubtreeCount:1}),g!==d.length)d=f.substring(0,g),u=n;t=f}if(a.length=l+1,t!=null)this.lastPreparedPath=an(t);this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;if(this.hasDeferredDirectoryIndexes)E(this.instrumentation,"store.builder.buildDirectoryIndexes",()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1;else if(!t)E(this.instrumentation,"store.builder.computeSubtreeCounts",()=>this.computeSubtreeCounts(0));return{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(),this.hasDeferredDirectoryIndexes=!1;if(this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t){if((this.options.sort==="default"?ya(this.lastPreparedPath,e,this.segmentSortKeyCache):Ca(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}}let n=this.lastPreparedPath,r=Ia(e),i=n==null?0:Ia(n),o=n==null?0:$h(n.segments,e.segments),s=Math.min(o,r,i);this.directoryStack.length=s+1;for(let l=s;l<r;l++){let d=this.directoryStack[this.directoryStack.length-1];if(d===void 0)throw Error("Directory stack underflow while building the path store");let u=t?this.getOrCreateDirectoryChild(d,e.segments[l]):this.createDirectoryChild(d,e.segments[l]);this.directoryStack.push(u)}if(e.isDirectory){let l=this.directoryStack[this.directoryStack.length-1];if(l===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(l,e.path),this.lastPreparedPath=e;return}let a=this.directoryStack[this.directoryStack.length-1];if(a===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);if(t)this.createFileChild(a,e.basename,e.path);else this.createFileChildUnchecked(a,e.basename);this.lastPreparedPath=e}recordCreatedDirectoryPath(e){if(!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null)return;if(this.createdDirectoryCount+=1,!this.initialExpandedPathSet.has(e))this.createdDirectoriesAllExpanded=!1}createFileChild(e,t,n){let r=st(this.segmentTable,t),i=this.getDirectoryIndex(e),o=i.childIdByNameId;if(o!=null){if(o.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`)}let s=this.nodes[e];if(s===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;if(this.nodes.push({depthAndFlags:Ae(qe(s)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),o!=null)o.set(r,a);return Cn(i,a),a}createFileChildUnchecked(e,t){let n=st(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Ae(qe(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Cn(r,o),o}getOrCreateDirectoryChild(e,t){let n=st(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let s=r.childIdByNameId.get(n);if(s!==void 0){let a=this.nodes[s];if(a!=null&&!R(a))throw Error(`Path collides with an existing file while creating directory "${t}"`);return s}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Ae(qe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Cn(r,o),this.directories.set(o,rn()),o}createDirectoryChild(e,t){let n=st(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Ae(qe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Cn(r,o),this.directories.set(o,rn()),o}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!R(n))throw Error(`Path is not a directory: "${t}"`);if(ue(n,1))throw Error(`Duplicate path: "${t}"`);xn(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,po());let r=-1,i=null;for(let o=1;o<t.length;o++){let s=t[o];if(s==null)continue;if(R(s)){let l=po();n.set(o,l),r=o,i=l}let a;if(s.parentId===r)a=i;else a=n.get(s.parentId),r=s.parentId,i=a??null;if(a!=null)a.childIds.push(o)}if(e)return;for(let o=t.length-1;o>=1;o--){let s=t[o];if(s==null)continue;let a=t[s.parentId];if(a!=null)a.subtreeNodeCount+=s.subtreeNodeCount,a.visibleSubtreeCount+=s.visibleSubtreeCount}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;if(R(n))this.directories.set(t,rn());let r=this.directories.get(n.parentId);if(r!=null){if(r.childIdByNameId!=null)r.childIdByNameId.set(n.nameId,t);Cn(r,t)}}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!R(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let i of n.childIds)r+=this.computeSubtreeCounts(i);return on(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Ra(e,t="closed",n=null){let r=Kh(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 Da(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Kh(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 Ma(e,t){if(ue(t,2))return!0;if(e.defaultExpansion==="open")return!0;if(e.defaultExpansion==="closed")return!1;return qe(t)<=e.defaultExpansion}function ke(e,t,n=e.snapshot.nodes[t]){if(n==null||!R(n))return!1;if(e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides)return!0;if(e.collapsedDirectoryIds.has(t))return!1;if(e.expandedDirectoryIds.has(t))return!0;return Ma(e,n)}function Ft(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!R(r))return;let i=Ma(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 Aa(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 Bt(e,t){return e.directoryLoadInfoById.get(t)?.state??"loaded"}function Na(e,t){let n=Aa(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 La(e,t){let n=Aa(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state="unloaded"}function Fa(e,t,n){let r=e.directoryLoadInfoById.get(t);if(r==null||r.activeAttemptId!==n)return!1;return r.activeAttemptId=null,r.errorMessage=null,r.state="loaded",!0}function Ba(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Ha(e,t,n,r){let i=e.directoryLoadInfoById.get(t);if(i==null||i.activeAttemptId!==n)return!1;return i.activeAttemptId=null,i.errorMessage=r??null,i.state="error",!0}function Va(e,t){e.directoryLoadInfoById.delete(t)}function $a(e,t,n){let r=n,i=e.listeners.get(t);if(i!=null)i.add(r);else e.listeners.set(t,new Set([r]));return()=>{let o=e.listeners.get(t);if(o==null)return;if(o.delete(r),o.size===0)e.listeners.delete(t)}}function ja(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"add",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ua(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"remove",path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Ka(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:"move",projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Ga(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"expand",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Ya(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"collapse",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Xa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"mark-directory-unloaded",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Qa(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 Za(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some((t)=>t.canonicalChanged),childEvents:e.childEvents,operation:"apply-child-patch",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ja(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 el(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 tl(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 Ne(e,t,n){return{...n,visibleCountDelta:bo(e)-t}}function nl(e,t){let n=bo(e),r=Da();e.transactionStack.push(r);try{t()}catch(i){throw qa(e,r,!1),i}qa(e,r,!0,bo(e)-n)}function Xe(e,t){let n=e.instrumentation;if(n==null){Oa(e,t);return}E(n,"store.events.record",()=>Oa(e,t))}function Oa(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){yo(e,t);return}n.events.push(t),Xh(n,t)}function qa(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 a=e.instrumentation;if(a==null)za(i,t);else E(a,"store.events.batch.merge",()=>za(i,t));return}let o=Gh(t,r),s=e.instrumentation;if(s==null){yo(e,o);return}E(s,"store.events.batch.commit",()=>yo(e,o))}function Gh(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some((n)=>n.canonicalChanged),events:[...e.events],operation:"batch",projectionChanged:e.events.some((n)=>n.projectionChanged),visibleCountDelta:t}}function Yh(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function za(e,t){for(let n of t.events)e.events.push(n);Yh(e,t)}function Xh(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function yo(e,t){let n=e.instrumentation;if(n==null){Wa(e,t);return}E(n,"store.events.emit",()=>Wa(e,t))}function Wa(e,t){e.listeners.get(t.operation)?.forEach((n)=>n(t)),e.listeners.get("*")?.forEach((n)=>n(t))}function bo(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Ct(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!R(n)||ue(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 o=e.snapshot.nodes[i];if(o==null||!R(o))return null;return i}function xt(e,t){let n=t;while(!0){let r=Ct(e,n);if(r==null)return n;n=r}}function _n(e,t){let n=[t],r=t;while(!0){let i=Ct(e,r);if(i==null)return n;n.push(i),r=i}}function ci(e,t){let n=t==null?e.snapshot.rootId:Le(e,t);if(n==null)return[];return Zh(e,n)}function Io(e,t){let n=an(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Ht(e,lf(e,r)),{createdNodeIds:o,directoryId:s}=Jh(e,r),a=new Set(o),l=s;if(n.isDirectory){let u=D(e,s);if(ue(u,1))throw Error(`Path already exists: "${t}"`);xn(u,1),e.pathCacheByNodeId.set(s,{path:t,version:e.pathCacheVersion}),a.add(s)}else l=tf(e,s,n.basename),a.add(l);Vt(e,s);let d=Ht(e,s);return ja({affectedAncestorIds:Ke(e,l),affectedNodeIds:[...a],path:t,projectionChanged:cl(i,d)})}function So(e,t,n){let r=Le(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=D(e,r);if(ue(i,2))throw Error("The root node cannot be removed");if(R(i)&&ie(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let o=i.parentId,s=Ht(e,o),a=ll(e,r);ko(e,o,r,i.nameId),_o(e,o),Vt(e,o);let l=Ht(e,o);return Ua({affectedAncestorIds:Ke(e,o),affectedNodeIds:a,path:t,projectionChanged:cl(s,l),recursive:n.recursive===!0})}function Co(e,t,n,r){let i=Le(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let o=D(e,i);if(ue(o,2))throw Error("The root node cannot be moved");let s=r.collision??"error",a=sf(e,i,n),l=Ht(e,o.parentId),d=Ht(e,a.parentId),u=Ue(e.snapshot.segmentTable,o.nameId),f=st(e.snapshot.segmentTable,a.basename);if(a.parentId===o.parentId&&u===a.basename)return null;if(R(o)&&uf(e,i,a.parentId))throw Error("Cannot move a directory into one of its descendants");let c=Nt(e.snapshot.nodes,ie(e,a.parentId)).get(f),m=a.existingNodeId??c??null;if(m!=null&&m!==i){if(af(e,m,s,fr(o))==="skip")return null}let p=o.parentId;if(ko(e,p,i,o.nameId),o.parentId=a.parentId,o.nameId=f,e.pathCacheByNodeId.delete(i),dl(e,i),xo(e,a.parentId,i),_o(e,p),e.pathCacheVersion++,Vt(e,p),a.parentId!==p)Vt(e,a.parentId);let g=Ht(e,p),v=Ht(e,a.parentId);return Ka({affectedAncestorIds:[...new Set([...Ke(e,p),...Ke(e,a.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:ul([l,d],[g,v]),to:te(e,i)})}function Qh(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function rl(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function te(e,t){let n=D(e,t),r=Qh(e,t);if(r!=null)return r;if(ue(n,2))return rl(e,t,"");let i=te(e,n.parentId),o=Ue(e.snapshot.segmentTable,n.nameId),s=i.length===0?o:`${i}${o}`;return rl(e,t,R(n)?`${s}/`:s)}function Vt(e,t){let n=e.instrumentation;if(n==null){ol(e,t);return}E(n,"store.recomputeCountsUpwardFrom",()=>ol(e,t))}function vr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;while(n.length>0){let o=n[n.length-1],s=o[0],a=r[s];if(a==null||!R(a)){wo(e,s,a,!0),n.pop();continue}let l=i.get(s);if(l==null||o[1]>=l.childIds.length){wo(e,s,a,!0),n.pop();continue}let d=l.childIds[o[1]++];n.push([d,0])}}function Ke(e,t){let n=[],r=t;while(r!=null){let i=D(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=i.parentId}return n}function Le(e,t){if(t.length===0)return e.snapshot.rootId;let n=oi(t);return al(e,n.segments,n.requiresDirectory)}function al(e,t,n){let r=e.snapshot.rootId;for(let o of t){let s=e.snapshot.segmentTable.idByValue.get(o);if(s===void 0)return null;let a=ie(e,r),l=Nt(e.snapshot.nodes,a).get(s);if(l===void 0)return null;r=l}let i=D(e,r);if(n&&!R(i))return null;return r}function ie(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 D(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Zh(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))return[];if(!R(n))return[te(e,t)];if(ie(e,t).childIds.length===0)return ue(n,1)&&!ue(n,2)?[te(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];while(i.length>0){let o=i[i.length-1];if(o==null)break;let s=e.snapshot.nodes[o.nodeId];if(s===void 0||ue(s,4)){i.pop();continue}if(!R(s)){r.push(te(e,o.nodeId)),i.pop();continue}let a=ie(e,o.nodeId);if(a.childIds.length===0){if(ue(s,1)&&!ue(s,2))r.push(te(e,o.nodeId));i.pop();continue}let l=a.childIds[o.childIndex];if(l==null){i.pop();continue}o.childIndex++,i.push({childIndex:0,nodeId:l})}return r}function Jh(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let o=st(e.snapshot.segmentTable,i),s=ie(e,r),a=Nt(e.snapshot.nodes,s).get(o);if(a!==void 0){if(!R(D(e,a)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=a;continue}r=ef(e,r,o),n.push(r)}return{createdNodeIds:n,directoryId:r}}function ef(e,t,n){let r=D(e,t),i=e.snapshot.nodes.length;if(e.snapshot.nodes.push({depthAndFlags:Ae(qe(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,rn()),xo(e,t,i),e.collapseNewDirectoriesByDefault)e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0;return e.activeNodeCount++,i}function tf(e,t,n){let r=st(e.snapshot.segmentTable,n),i=ie(e,t);if(Nt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${df(e,t,n)}"`);let o=D(e,t),s=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Ae(qe(o)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),xo(e,t,s),e.activeNodeCount++,s}function nf(e,t,n){let r=0,i=t.childIds.length;while(r<i){let o=r+i>>>1,s=t.childIds[o];if(s==null){i=o;continue}if(rf(e,n,s)<0)i=o;else r=o+1}return r}function xo(e,t,n){let r=ie(e,t),i=D(e,n);Nt(e.snapshot.nodes,r).set(i.nameId,n),ni(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let o=nf(e,r,n);r.childIds.splice(o,0,n),mo(r,o),Lt(e.snapshot.nodes,r)}function ko(e,t,n,r){let i=ie(e,t),o=Sn(i),s=o.get(n)??-1;Nt(e.snapshot.nodes,i).delete(r),o.delete(n);let a=e.snapshot.nodes[n];if(a!=null)ni(i,n,-a.subtreeNodeCount,-a.visibleSubtreeCount);if(s>=0)i.childIds.splice(s,1),mo(i,s),Lt(e.snapshot.nodes,i)}function rf(e,t,n){let r=e.snapshot.options.sort;if(r==="default")return of(e,t,n);return r(il(e,t),il(e,n))}function of(e,t,n){let r=D(e,t),i=D(e,n),o=R(r);if(o!==R(i))return o?-1:1;let s=mr(gr(e.snapshot.segmentTable,r.nameId),gr(e.snapshot.segmentTable,i.nameId));if(s!==0)return s;let a=Ue(e.snapshot.segmentTable,r.nameId),l=Ue(e.snapshot.segmentTable,i.nameId);if(a!==l)return a<l?-1:1;return t<n?-1:1}function il(e,t){let n=D(e,t),r=te(e,t),i=R(n),o=i?r.slice(0,-1):r;return{basename:Ue(e.snapshot.segmentTable,n.nameId),depth:qe(n),isDirectory:i,path:r,segments:o.length===0?[]:o.split("/")}}function sf(e,t,n){let r=D(e,t),i=Le(e,n);if(i!=null){let d=D(e,i);if(R(d))return{basename:Ue(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let u=oi(n).segments;return{basename:u[u.length-1]??"",existingNodeId:i,parentId:d.parentId}}let o=oi(n),s=o.segments[o.segments.length-1]??"",a=o.segments.slice(0,-1),l=a.length===0?e.snapshot.rootId:al(e,a,!0);if(l==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:s,existingNodeId:null,parentId:l}}function af(e,t,n,r){if(n==="skip")return"skip";if(n==="error")throw Error(`Destination already exists: "${te(e,t)}"`);let i=D(e,t);if(fr(i)!==r)throw Error("replace collision requires the same source and destination kinds");if(R(i)&&ie(e,t).childIds.length>0)throw Error("replace collision does not support non-empty directories");let{parentId:o,nameId:s}=i;return ll(e,t),ko(e,o,t,s),_o(e,o),Vt(e,o),"handled"}function ll(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];while(r.length>0){let i=r.pop();if(i==null)break;let o=D(e,i.nodeId);if(i.visitedChildren||!R(o)){if(R(o))e.snapshot.directories.delete(i.nodeId);if(xn(o,4),e.pathCacheByNodeId.delete(i.nodeId),e.collapsedDirectoryIds.delete(i.nodeId))e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;e.expandedDirectoryIds.delete(i.nodeId),Va(e,i.nodeId),e.activeNodeCount--,n.push(i.nodeId);continue}r.push({nodeId:i.nodeId,visitedChildren:!0});let s=ie(e,i.nodeId);for(let a=s.childIds.length-1;a>=0;a--){let l=s.childIds[a];if(l!=null)r.push({nodeId:l,visitedChildren:!1})}}return n}function _o(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return;if(ie(e,n).childIds.length>0)return;xn(r,1),n=r.parentId===n?null:r.parentId}}function lf(e,t){let n=e.snapshot.rootId;for(let r of t){let i=e.snapshot.segmentTable.idByValue.get(r);if(i==null)break;let o=Nt(e.snapshot.nodes,ie(e,n)).get(i);if(o==null)break;if(!R(D(e,o)))break;n=o}return n}function Ht(e,t){let n=cf(e,t);if(n==null)return null;let r=xt(e,n),i=D(e,r),o=n===r?null:_n(e,n).map((s)=>te(e,s));return JSON.stringify({flattenedSegmentPaths:o,hasChildren:ie(e,r).childIds.length>0,path:te(e,r),terminalKind:fr(i)})}function cl(e,t){return ul([e],[t])}function ul(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 cf(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return null;if(!ke(e,n,r))return n;n=r.parentId}return null}function dl(e,t){let n=D(e,t);if(ha(n,(t===e.snapshot.rootId?-1:qe(D(e,n.parentId)))+1),!R(n))return;let r=ie(e,t);for(let i of r.childIds)dl(e,i)}function uf(e,t,n){let r=n;while(r!=null){if(r===t)return!0;let i=D(e,r);if(r===e.snapshot.rootId)return!1;r=i.parentId}return!1}function wo(e,t,n=D(e,t),r=!1){let i=e.instrumentation;if(i==null){sl(e,t,n,r);return}E(i,"store.recomputeNodeCounts",()=>sl(e,t,n,r))}function ol(e,t){let n=t;while(n!=null){let r=D(e,n),i=r.subtreeNodeCount,o=r.visibleSubtreeCount;if(wo(e,n,r),n===e.snapshot.rootId)return;let s=r.subtreeNodeCount-i,a=r.visibleSubtreeCount-o,l=r.parentId;if(s!==0||a!==0)ni(ie(e,l),n,s,a);n=l}}function sl(e,t,n,r){if(!R(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=ie(e,t);if(r){let a=e.instrumentation;if(a==null)on(e.snapshot.nodes,i);else E(a,"store.recomputeNodeCounts.rebuildChildAggregates",()=>on(e.snapshot.nodes,i))}let o=1+i.totalChildSubtreeNodeCount,s=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=o,ue(n,2)){n.visibleSubtreeCount=s;return}n.visibleSubtreeCount=Ct(e,t)!=null?s:ke(e,t,n)?1+s:1}function df(e,t,n){let r=te(e,t);return r.length===0?n:`${r}${n}`}function En(e){return e!=null&&!ue(e,4)}function ui(e,t){let n=e.snapshot.nodes[t];if(!En(n)||!R(n)||ue(n,2))return null;return n}function hf(e){let t=0;for(let[n,r]of e.pathCacheByNodeId){if(r.version!==e.pathCacheVersion)continue;if(!En(e.snapshot.nodes[n]))continue;t+=1}return t}function ff(e){return Math.max(0,e.valueById.length-1)}function hl(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:hf(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ff(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function pf(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 fl(e){let t=[],n=[];for(let r of e.collapsedDirectoryIds)if(ui(e,r)!=null)t.push(te(e,r));for(let r of e.expandedDirectoryIds)if(ui(e,r)!=null)n.push(te(e,r));return{collapsedPaths:t,expandedPaths:n}}function pl(e){let t=[];for(let[n,r]of e.directoryLoadInfoById){if(ui(e,n)==null||Bt(e,n)==="loaded")continue;t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:te(e,n)})}return t}function ml(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let r=Le(e,n);if(r==null)continue;Ft(e,r,!0,D(e,r))}for(let n of t.collapsedPaths){let r=Le(e,n);if(r==null)continue;Ft(e,r,!1,D(e,r))}}function gl(e,t){e.directoryLoadInfoById.clear();for(let n of t){let r=Le(e,n.path);if(r==null)continue;if(ui(e,r)==null)continue;e.directoryLoadInfoById.set(r,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function mf(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:"",version:e.pathCacheVersion})}function gf(e){let t=e.snapshot.segmentTable,n=si();for(let r of e.snapshot.nodes){if(!En(r))continue;if(ue(r,2)){r.nameId=0;continue}r.nameId=st(n,Ue(t,r.nameId))}e.snapshot.segmentTable=n}function vf(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!En(r)||!R(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter((o)=>{let s=e.snapshot.nodes[o];return En(s)&&s.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map((o)=>[D(e,o).nameId,o])),n.childPositionById=new Map(i.map((o,s)=>[o,s])),on(e.snapshot.nodes,n)}}function yf(e){let t=e.snapshot.nodes.length-1;while(t>e.snapshot.rootId){let n=e.snapshot.nodes[t];if(En(n))break;t-=1}e.snapshot.nodes.length=t+1}function bf(e){let t=fl(e),n=pl(e);E(e.instrumentation,"store.cleanup.stable.clearPathCaches",()=>mf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildSegmentTable",()=>gf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildDirectoryIndexes",()=>vf(e)),E(e.instrumentation,"store.cleanup.stable.trimTrailingRemovedNodeSlots",()=>yf(e)),E(e.instrumentation,"store.cleanup.stable.restoreExpansionOverrides",()=>ml(e,t)),E(e.instrumentation,"store.cleanup.stable.restoreDirectoryLoadInfos",()=>gl(e,n)),E(e.instrumentation,"store.cleanup.stable.recomputeCounts",()=>vr(e,e.snapshot.rootId))}function wf(e){let t=fl(e),n=pl(e),r=E(e.instrumentation,"store.cleanup.aggressive.listPaths",()=>ci(e)),i=pa({...e.snapshot.options},e.instrumentation),o=E(e.instrumentation,"store.cleanup.aggressive.rebuildSnapshot",()=>{let s=new li(i);return s.appendPaths(r),s.finish()});e.snapshot=o,e.activeNodeCount=o.nodes.length-1,e.pathCacheByNodeId=new Map([[o.rootId,{path:"",version:0}]]),e.pathCacheVersion=0,E(e.instrumentation,"store.cleanup.aggressive.restoreExpansionOverrides",()=>ml(e,t)),E(e.instrumentation,"store.cleanup.aggressive.restoreDirectoryLoadInfos",()=>gl(e,n)),E(e.instrumentation,"store.cleanup.aggressive.recomputeCounts",()=>vr(e,e.snapshot.rootId))}function vl(e){for(let t of e.directoryLoadInfoById.values())if(t.state==="loading"&&t.activeAttemptId!=null)return!0;return!1}function yl(e,t){let n=hl(e);if(t==="stable")E(e.instrumentation,"store.cleanup.stable",()=>bf(e));else E(e.instrumentation,"store.cleanup.aggressive",()=>wf(e));let r=hl(e);return pf(t,t==="stable",n,r)}var If=64;function Sf(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;while(r<n)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function _e(e){return D(e,e.snapshot.rootId).visibleSubtreeCount}function Sl(e,t,n,r){let i=D(e,t.terminalNodeId),o=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+o-1)}function Cf(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:yr(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Sl(e,t.cursor,t.index,n)}}function Cl(e,t,n,r,i,o){let s=ie(e,t),{childIndex:a,childVisibleIndex:l,localVisibleIndex:d}=ri(e.snapshot.nodes,s,n),u=s.childIds[a];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return xf(e,u,d,r+l,i+1,a,s.childIds.length,o)}function xf(e,t,n,r,i,o,s,a){if(!R(D(e,t))){if(n===0)return{ancestors:a,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:o,setSize:s};throw Error(`Visible index ${String(n)} is out of range for file`)}let l=Dl(e,t,i);if(n===0)return{ancestors:a,cursor:l,index:r,posInSet:o,setSize:s};let d=D(e,l.terminalNodeId);if(!R(d)||!ke(e,l.terminalNodeId,d))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Cl(e,l.terminalNodeId,n-1,r+1,l.visibleDepth,[...a,{cursor:l,index:r,posInSet:o,setSize:s}])}function xl(e,t){let n=_e(e);if(t<0||t>=n)return null;let r=Cl(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map((s)=>te(e,s.cursor.terminalNodeId)),o=null;return{ancestorPaths:i,get ancestorRows(){if(o!=null)return o;let s=[],a=[];for(let l of r.ancestors){let d=Cf(e,l,n,[...a]);s.push(d),a.push(d.row.path)}return o=s,o},index:r.index,posInSet:r.posInSet,row:yr(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Sl(e,r.cursor,r.index,n)}}function kl(e,t,n){let r=e.instrumentation,i=_e(e);if(i<=0||n<t)return[];let o=Math.max(0,Math.min(t,i-1)),s=Math.max(o,Math.min(n,i-1));if(r==null){if(o===0)return Ef(e,s+1);let f=[],c=bl(e,o);for(let m=o;m<=s&&c!=null;m++){let p=yr(e,c);f.push(p),c=wl(e,c)}return f}let a=[],l=0,d=0,u=E(r,"store.getVisibleSlice.selectFirstRow",()=>bl(e,o));for(let f=o;f<=s&&u!=null;f++){let c=E(r,"store.getVisibleSlice.materializeRow",()=>yr(e,u));if(a.push(c),c.isFlattened)l++,d+=c.flattenedSegments?.length??0;u=E(r,"store.getVisibleSlice.advanceCursor",()=>wl(e,u))}return kn(r,"workload.visibleRowsRead",a.length),kn(r,"workload.flattenedRowsRead",l),kn(r,"workload.flattenedSegmentsRead",d),a}function To(e,t=_e(e)){let n=e.instrumentation;if(n==null)return Il(e,t);return E(n,"store.getVisibleTreeProjection",()=>Il(e,t))}function _l(e){return _f(To(e))}function El(e,t){let n=Le(e,t);if(n==null||n===e.snapshot.rootId)return null;if(R(D(e,n))&&xt(e,n)!==n)return null;let r=0,i=n,{nodes:o,rootId:s}=e.snapshot;while(i!==s){let a=D(e,i).parentId,l=ie(e,a),d=Sn(l).get(i);if(d==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=ua(o,l,d),a!==s){let u=D(e,a),f=Ct(e,a);if(!ke(e,a,u)&&f!==i)return null;if(xt(e,a)===a)r+=1}i=a}return r}function Tl(e,t){let n=Le(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(ke(e,n,r))return null;return Ft(e,n,!0,r),Vt(e,n),Ga({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function Pl(e,t){let n=Le(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(!ke(e,n,r))return null;return Ft(e,n,!1,r),Vt(e,n),Ya({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function bl(e,t){if(t<0||t>=_e(e))return null;return Rl(e,e.snapshot.rootId,t,-1)}function Rl(e,t,n,r){let i=ie(e,t),o=e.instrumentation,{childIndex:s,localVisibleIndex:a}=o==null?ri(e.snapshot.nodes,i,n):E(o,"store.getVisibleSlice.selectChildIndex",()=>ri(e.snapshot.nodes,i,n)),l=i.childIds[s];if(l!=null)return Eo(e,l,a,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Eo(e,t,n,r){if(!R(D(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=Dl(e,t,r);if(n===0)return i;let o=D(e,i.terminalNodeId);if(!R(o)||!ke(e,i.terminalNodeId,o))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Rl(e,i.terminalNodeId,n-1,i.visibleDepth)}function Dl(e,t,n){if(!R(D(e,t)))return{headNodeId:t,terminalNodeId:t,visibleDepth:n};if(e.instrumentation==null)return{headNodeId:t,terminalNodeId:xt(e,t),visibleDepth:n};return{headNodeId:t,terminalNodeId:E(e.instrumentation,"store.getVisibleSlice.flatten.resolveTerminalDirectory",()=>xt(e,t)),visibleDepth:n}}function kf(e,t){let n=D(e,t);if(!R(n))return!0;let r=n.parentId;if(r===e.snapshot.rootId)return!0;return Ct(e,r)!==t}function wl(e,t){let n=D(e,t.terminalNodeId);if(R(n)){let o=ie(e,t.terminalNodeId);if(ke(e,t.terminalNodeId,n)&&o.childIds.length>0){let s=o.childIds[0];return s==null?null:Eo(e,s,0,t.visibleDepth+1)}}let{terminalNodeId:r,visibleDepth:i}=t;while(!0){let o=D(e,r);if(r===e.snapshot.rootId)return null;let s=o.parentId,a=ie(e,s),l=Sn(a).get(r)??-1;if(l<0)throw Error(`Child ${String(r)} was not found in its parent index`);let d=a.childIds[l+1]??null;if(d!=null)return Eo(e,d,0,i);if(kf(e,r))i--;r=s}}function _f(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let i=e.getParentIndex(r);n[r]={index:r,parentPath:i>=0?e.paths[i]??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 Il(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),o=new Int32Array(t),s=new Int32Array(If);s.fill(-1);let a=0,{nodes:l,directories:d,segmentTable:u}=e.snapshot,f=[[d.get(e.snapshot.rootId),0,-1,""]],c=e.snapshot.options.flattenEmptyDirectories,m=e.pathCacheByNodeId,p=e.pathCacheVersion,g=u.valueById;while(f.length>0&&a<t){let S=f[f.length-1],x=S[0];if(S[1]>=x.childIds.length){f.pop();continue}let T=S[1],O=x.childIds[S[1]++],fe=l[O],Z=S[2]+1,pe=S[3];s=Sf(s,Z);let J,K=O;if(!R(fe)){let ae=m.get(O);J=ae!=null&&ae.version===p?ae.path:`${pe}${g[fe.nameId]}`}else K=c?xt(e,O):O,J=K===O?`${pe}${g[fe.nameId]}/`:te(e,K);r[a]=s[Z],n[a]=J,i[a]=T,o[a]=x.childIds.length,s[Z+1]=a,a+=1;let B=l[K];if(B!=null&&R(B)&&ke(e,K,B))f.push([d.get(K),0,Z,J])}if(a<t)n.length=a;let v=r.subarray(0,a),I=i.subarray(0,a),C=o.subarray(0,a),y=null;return{getParentIndex(S){return S<0||S>=a?-1:v[S]??-1},paths:n,posInSetByIndex:I,setSizeByIndex:C,get visibleIndexByPath(){if(y==null){y=new Map;for(let S=0;S<a;S+=1)y.set(n[S]??"",S)}return y}}}function Ef(e,t){let n=Array(t),r=0,{nodes:i,directories:o,segmentTable:s}=e.snapshot,a=[[o.get(e.snapshot.rootId),0,-1]],l=s.valueById,d=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,f=e.pathCacheVersion;while(a.length>0&&r<t){let c=a[a.length-1],m=c[0];if(c[1]>=m.childIds.length){a.pop();continue}let p=m.childIds[c[1]++],g=i[p],v=c[2]+1;if(!R(g)){let S=u.get(p);n[r++]={depth:v,flattenedSegments:void 0,hasChildren:!1,id:p,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:"file",loadState:void 0,name:l[g.nameId],path:S!=null&&S.version===f?S.path:te(e,p)};continue}let I=d?xt(e,p):p,C={headNodeId:p,terminalNodeId:I,visibleDepth:v};n[r++]=yr(e,C);let y=i[I];if(y!=null&&R(y)&&ke(e,I,y))a.push([o.get(I),0,v])}if(r<t)n.length=r;return n}function yr(e,t){let n=D(e,t.terminalNodeId),r=R(n)?Tf(e,t):null,i=te(e,t.terminalNodeId),o=Ue(e.snapshot.segmentTable,n.nameId),s=R(n)&&ie(e,t.terminalNodeId).childIds.length>0,a=t.headNodeId!==t.terminalNodeId,l=e.instrumentation,d=a?l==null?_n(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ue(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}}):E(l,"store.getVisibleSlice.flatten.collectSegments",()=>_n(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ue(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:d,hasChildren:s,id:t.terminalNodeId,isExpanded:R(n)&&ke(e,t.terminalNodeId,n),isFlattened:a,isLoading:r==="loading",kind:R(n)?"directory":"file",loadState:r==null||r==="loaded"?void 0:r,name:o,path:i}}function Tf(e,t){if(t.headNodeId===t.terminalNodeId)return Bt(e,t.terminalNodeId);let n=_n(e,t.headNodeId),r=!1,i=!1;for(let o of n){let s=Bt(e,o);if(s==="loading")return"loading";if(s==="error"){i=!0;continue}if(s==="unloaded")r=!0}if(i)return"error";if(r)return"unloaded";return"loaded"}var Ml=8;function Al(e){let{nodes:t,directories:n,rootId:r,options:i}=e,o=t.length,s=new Int32Array(o),a=new Int32Array(o),l=new Int32Array(o),d=new Int32Array(o),u=new Int32Array(o),f=new Int32Array(o),c=new Int32Array(o);for(let v=0;v<o;v+=1){let I=t[v];if(I==null)continue;s[v]=I.parentId,a[v]=I.nameId,l[v]=I.depthAndFlags,d[v]=I.subtreeNodeCount,u[v]=I.visibleSubtreeCount}let m=0;for(let v of n.values())m+=v.childIds.length;let p=new Int32Array(m),g=0;for(let[v,I]of n){let C=I.childIds;f[v]=g,c[v]=C.length;for(let y=0;y<C.length;y+=1)p[g]=C[y],g+=1}return{nodeCount:o,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:s,nameId:a,depthAndFlags:l,subtreeNodeCount:d,visibleSubtreeCount:u,childStart:f,childCount:c,childIdsFlat:p}}function Nl(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:o,visibleSubtreeCount:s,childStart:a,childCount:l,childIdsFlat:d}=e;for(let p=t-1;p>=1;p-=1){if((i[p]&Ml)===0)continue;let g=a[p],v=l[p],I=0,C=0;for(let S=0;S<v;S+=1){let x=d[g+S];I+=o[x],C+=s[x]}o[p]=1+I;let y;if(r&&v===1)y=(i[d[g]]&Ml)!==0?C:1+C;else y=1+C;s[p]=y}let u=a[n],f=l[n],c=0,m=0;for(let p=0;p<f;p+=1){let g=d[u+p];c+=o[g],m+=s[g]}o[n]=1+c,s[n]=m}function Pf(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:o}=e.snapshot,s=r.flattenEmptyDirectories===!0,a=(m)=>{let p=n[m];if(p==null||!R(p))return;let g=t.get(m);if(g==null)throw Error(`Unknown directory child index for node ${String(m)}`);let v=g.childIds,I=v.length,C=0,y=0;for(let x=0;x<I;x++){let T=v[x];if(T==null)continue;let O=n[T];C+=O.subtreeNodeCount,y+=O.visibleSubtreeCount}if(g.totalChildSubtreeNodeCount=C,g.totalChildVisibleSubtreeCount=y,I>=128)Lt(n,g);p.subtreeNodeCount=1+C;let S;if(s&&I===1){let x=n[v[0]];S=x!=null&&R(x)?y:1+y}else S=1+y;p.visibleSubtreeCount=S};if(o!=null)for(let m=o.length-1;m>=0;m--)a(o[m]);else for(let m=n.length-1;m>=1;m--)a(m);let l=n[i],d=t.get(i);if(l==null||d==null)return;let u=d.childIds,f=0,c=0;for(let m=0;m<u.length;m++){let p=u[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}d.totalChildSubtreeNodeCount=f,d.totalChildVisibleSubtreeCount=c,Lt(n,d),l.subtreeNodeCount=1+f,l.visibleSubtreeCount=c}function Rf(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Al(e.snapshot);Nl(i);let{subtreeNodeCount:o,visibleSubtreeCount:s}=i;for(let a=0;a<n.length;a+=1){let l=n[a];if(l==null)continue;l.subtreeNodeCount=o[a],l.visibleSubtreeCount=s[a]}for(let[a,l]of t){let d=l.childIds,u=d.length,f=0,c=0;for(let m=0;m<u;m++){let p=d[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}if(l.totalChildSubtreeNodeCount=f,l.totalChildVisibleSubtreeCount=c,a===r||u>=128)Lt(n,l)}}function Df(e){return e.initialExpansion==="open"&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var di=class e{#e;constructor(t={}){let n=pr(t),r=E(n,"store.builder.create",()=>new li(t));if(t.preparedInput!=null){let a=Ta(t.preparedInput);if(a!=null)r.appendPresortedPaths(a,Pa(t.preparedInput));else r.appendPreparedPaths(Ea(t.preparedInput),!1)}else{let a=t.paths??[];if(t.presorted===!0)r.appendPaths(a);else r.appendPreparedPaths(E(n,"store.preparePathEntries",()=>ai(a,t)))}let i=E(n,"store.builder.finish",()=>r.finish({skipSubtreeCountPass:!0})),o=E(n,"store.state.detectAllDirectoriesExpanded",()=>(t.initialExpansion??"closed")==="closed"&&r.didMatchAllInitialExpandedPaths());if(this.#e=E(n,"store.state.create",()=>Ra(i,o?"open":t.initialExpansion??"closed",n)),o)this.#e.collapseNewDirectoriesByDefault=!0;let s=o?this.#e.snapshot.directories.size-1:E(n,"store.state.initializeExpandedPaths",()=>this.initializeExpandedPaths(t.initialExpandedPaths));if(o||Df(t)||(t.initialExpansion??"closed")==="closed"&&s===this.#e.snapshot.directories.size-1||(t.initialExpandedPaths?.length??0)>0&&E(n,"store.state.checkAllDirectoriesExpanded",()=>this.hasAllDirectoriesExpanded()))if(t.useSoaCountSweep===!0)E(n,"store.state.initializeOpenVisibleCountsViaSoa",()=>Rf(this.#e));else E(n,"store.state.initializeOpenVisibleCounts",()=>Pf(this.#e));else E(n,"store.state.recomputeCounts",()=>vr(this.#e,this.#e.snapshot.rootId))}static preparePaths(t,n={}){return xa(t,n)}static prepareInput(t,n={}){return ka(t,n)}static preparePresortedInput(t){return _a(t)}list(t){return E(this.#e.instrumentation,"store.list",()=>ci(this.#e,t))}add(t){E(this.#e.instrumentation,"store.add",()=>{let n=_e(this.#e);Xe(this.#e,Ne(this.#e,n,Io(this.#e,t)))})}remove(t,n={}){E(this.#e.instrumentation,"store.remove",()=>{let r=_e(this.#e);Xe(this.#e,Ne(this.#e,r,So(this.#e,t,n)))})}move(t,n,r={}){E(this.#e.instrumentation,"store.move",()=>{let i=_e(this.#e),o=Co(this.#e,t,n,r);if(o!=null)Xe(this.#e,Ne(this.#e,i,o))})}batch(t){nl(this.#e,()=>{if(typeof t==="function"){t(this);return}for(let n of t)switch(n.type){case"add":this.add(n.path);break;case"remove":this.remove(n.path,{recursive:n.recursive});break;case"move":this.move(n.from,n.to,{collision:n.collision});break}})}getVisibleCount(){return E(this.#e.instrumentation,"store.getVisibleCount",()=>_e(this.#e))}getVisibleSlice(t,n){return E(this.#e.instrumentation,"store.getVisibleSlice",()=>kl(this.#e,t,n))}getVisibleRowContext(t){return E(this.#e.instrumentation,"store.getVisibleRowContext",()=>xl(this.#e,t))}getVisibleTreeProjection(){return _l(this.#e)}getVisibleTreeProjectionData(t){return To(this.#e,t)}getVisibleIndex(t){return E(this.#e.instrumentation,"store.getVisibleIndex",()=>El(this.#e,t))}getPathInfo(t){return E(this.#e.instrumentation,"store.getPathInfo",()=>{let n=Le(this.#e,t);if(n==null)return null;let r=D(this.#e,n);return{depth:qe(r),kind:R(r)?"directory":"file",path:te(this.#e,n)}})}isExpanded(t){return E(this.#e.instrumentation,"store.isExpanded",()=>{let n=this.requireDirectoryNodeId(t),r=D(this.#e,n);return ke(this.#e,n,r)})}expand(t){E(this.#e.instrumentation,"store.expand",()=>{let n=_e(this.#e),r=Tl(this.#e,t);if(r!=null)Xe(this.#e,Ne(this.#e,n,r))})}collapse(t){E(this.#e.instrumentation,"store.collapse",()=>{let n=_e(this.#e),r=Pl(this.#e,t);if(r!=null)Xe(this.#e,Ne(this.#e,n,r))})}on(t,n){return $a(this.#e,t,n)}getDirectoryLoadState(t){let n=this.requireDirectoryNodeId(t);return Bt(this.#e,n)}markDirectoryUnloaded(t){E(this.#e.instrumentation,"store.markDirectoryUnloaded",()=>{let n=this.requireDirectoryNodeId(t);if(ie(this.#e,n).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${t}"`);let r=_e(this.#e);La(this.#e,n),Xe(this.#e,Ne(this.#e,r,Xa({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],path:t,projectionChanged:this.isDirectoryProjectionVisible(n)})))})}beginChildLoad(t){return E(this.#e.instrumentation,"store.beginChildLoad",()=>{let n=this.requireDirectoryNodeId(t),r=_e(this.#e),i=Na(this.#e,n);return Xe(this.#e,Ne(this.#e,r,Qa({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],attemptId:i.attemptId,path:t,projectionChanged:this.isDirectoryProjectionVisible(n),reused:i.reused}))),i})}applyChildPatch(t,n){return E(this.#e.instrumentation,"store.applyChildPatch",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null||Bt(this.#e,r)!=="loading"||!Ba(this.#e,r,t.attemptId))return!1;let i=te(this.#e,r);this.validateChildPatch(i,n);let o=_e(this.#e),s=[];for(let l of n.operations){Mf(i,l);let d=_e(this.#e);switch(l.type){case"add":s.push(Ne(this.#e,d,Io(this.#e,l.path)));break;case"remove":s.push(Ne(this.#e,d,So(this.#e,l.path,{recursive:l.recursive})));break;case"move":{let u=Co(this.#e,l.from,l.to,{collision:l.collision});if(u!=null)s.push(Ne(this.#e,d,u));break}}}let a=s.some((l)=>l.projectionChanged)||this.isDirectoryProjectionVisible(r);return Xe(this.#e,Ne(this.#e,o,Za({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,childEvents:s,path:te(this.#e,r),projectionChanged:a}))),!0})}completeChildLoad(t){return E(this.#e.instrumentation,"store.completeChildLoad",()=>{let n=this.resolveActiveDirectoryNodeId(t.nodeId);if(n==null)return!1;let r=_e(this.#e),i=Fa(this.#e,n,t.attemptId);return Xe(this.#e,Ne(this.#e,r,Ja({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],attemptId:t.attemptId,path:te(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}failChildLoad(t,n){return E(this.#e.instrumentation,"store.failChildLoad",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null)return!1;let i=_e(this.#e),o=Ha(this.#e,r,t.attemptId,n);return Xe(this.#e,Ne(this.#e,i,el({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,errorMessage:n,path:te(this.#e,r),projectionChanged:this.isDirectoryProjectionVisible(r),stale:!o}))),o})}cleanup(t={}){return E(this.#e.instrumentation,"store.cleanup",()=>{if(this.#e.transactionStack.length>0)throw Error("Cleanup cannot run during an open batch or transaction.");if(vl(this.#e))throw Error("Cleanup cannot run while directory loads are active.");let n=_e(this.#e),r=yl(this.#e,t.mode??"stable");return Xe(this.#e,Ne(this.#e,n,tl({...r,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:r.idsPreserved===!1}))),r})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(t){if(t==null||t.length===0)return 0;let n=0,r=[],i=[],o=0,s=null,a=this.#e.snapshot.segmentTable,l=a.valueById,d=this.#e.snapshot.nodes,u=new Map;for(let f of t){if(s!=null&&f<s)s=null,o=0,r.length=0,i.length=0;let c=f.length>0&&f.charCodeAt(f.length-1)===47?f.length-1:f.length;if(c===0){s=f,o=c,r.length=0,i.length=0;continue}let m=0,p=0;if(s!=null){let y=Math.min(c,o),S=!0;for(let x=0;x<y;x+=1){let T=f.charCodeAt(x);if(T!==s.charCodeAt(x)){S=!1;break}if(T===47)m+=1,p=x+1}if(S){if(y===o&&c>y&&f.charCodeAt(y)===47)m+=1,p=y+1;else if(y===c&&o>y&&s.charCodeAt(y)===47)m+=1,p=c+1}m=Math.min(m,i.length)}let g=m===0?this.#e.snapshot.rootId:i[m-1]??this.#e.snapshot.rootId,v=m,I=!0,C=p;while(C<=c){let y=f.indexOf("/",C),S=y===-1||y>c?c:y,x=f.slice(C,S),T=ie(this.#e,g).childIds,O=v===m?r[v]??0:0,fe=O,Z,pe=u.get(x)??sn(x);u.set(x,pe);let J=(K,B)=>{for(fe=K;fe<B;fe+=1){let ae=T[fe],Se=d[ae],z=l[Se.nameId];if(z===x)return Z=ae,!0;let le=mr(gr(a,Se.nameId),pe);if(le>0||le===0&&z>x)return!1}return!1};if(!J(O,T.length)&&O>0)J(0,O);if(Z===void 0){I=!1;break}if(!R(D(this.#e,Z))){I=!1;break}if(r[v]=fe,i[v]=Z,g=Z,v+=1,S===c)break;C=S+1}if(s=f,o=c,r.length=v,i.length=v,!I){s=null,o=0,r.length=0,i.length=0;continue}for(let y=m;y<v;y+=1){let S=i[y];if(S==null)continue;let x=D(this.#e,S);if(ke(this.#e,S,x))continue;Ft(this.#e,S,!0,x),n+=1}}return n}hasAllDirectoriesExpanded(){for(let t of this.#e.snapshot.directories.keys()){if(t===this.#e.snapshot.rootId)continue;let n=D(this.#e,t);if(!ke(this.#e,t,n))return!1}return!0}requireDirectoryNodeId(t){let n=Le(this.#e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);if(!R(D(this.#e,n)))throw Error(`Path is not a directory: "${t}"`);return n}resolveActiveDirectoryNodeId(t){try{if(!R(D(this.#e,t)))throw Error(`Node is not a directory: ${String(t)}`);return t}catch{return null}}isDirectoryProjectionVisible(t){let n=t;while(n!==this.#e.snapshot.rootId){let r=D(this.#e,n).parentId;if(r!==this.#e.snapshot.rootId){let i=D(this.#e,r),o=Ct(this.#e,r);if(!ke(this.#e,r,i)&&o!==n)return!1}n=r}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Mf(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 Af=[`<symbol id="file-tree-builtin-bash" viewBox="0 0 16 16">
|
|
1
|
+
import{A as M,B as ws,C as Di,D as gd,F as Pr,G as _s,a as Yr,b as ea,c as ta,e as Gr,f as ra,g as Zs,h as Js,i as Jr,j as ia,k as ei,n as oa,o as lo,p as co,q as ni,r as sa,s as qu,t as pd,u as aa,v as la,w as uo,x as hr,y as ca,z as md}from"./main-27505rdd.js";import{H as Fh}from"./main-mwzht33t.js";import{_ as oo,qa as ti,ra as so,sa as ao}from"./main-f40c0hm2.js";import{gc as Xu,hc as Qu}from"./main-pq3eh5fy.js";import{ic as $n,jc as dn,kc as Ru,lc as zt}from"./main-b1kpnx3v.js";import{mc as Lh,pc as _m}from"./main-jgbmmpjx.js";function Ji(e){let t=[];for(let n of e){let r=Gr.get(n);if(r==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function eo(e){for(let t of Array.isArray(e)?e:[e])if(!Gr.has(t))return!1;return!0}async function to(e){let t=[],n=[];for(let r of e){if(r==="text"||r==="ansi")continue;let i=Js(r)??Zs(r);if("then"in i)n.push(i);else t.push(i)}if(n.length>0)await Promise.all(n).then((r)=>{for(let i of r){if(i==null)throw Error("resolvedLanguages: unable to resolve language");t.push(i)}});return t}function no(e){return Yr.getResolvedThemes(e)}async function ro(e){for(let n of e)ea(n);let t=await Yr.resolveThemes(e);for(let n=0;n<e.length;n++)ta(e[n],t[n]);return t}var ho=Lh(Fh(),1),Xr=Symbol("IGNORE_RESPONSE"),Bh=1e4,Qr=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},io=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed")}},ua=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=oo,useTokenTransformer:r=!1,lineDiffType:i="word-alt",maxLineDiffLength:o=1000,tokenizeMaxLineLength:s=1000,preferredHighlighter:a="shiki-js"}){this.options=e,this.preferredHighlighter=a,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:o,tokenizeMaxLineLength:s},this.fileCache=new ho.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new ho.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??oo,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1000,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1000}){let{lifecycleGeneration:o}=this,s=++this.renderOptionsRequestVersion,a=()=>this.isCurrentLifecycle(o)&&this.renderOptionsRequestVersion===s;try{let l={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(!this.isInitialized())await this.initialize();if(!a()||hr(l,this.renderOptions))return;let d=Jr(e),u=[];if(!oa(l.theme,this.renderOptions.theme))if(co(d))u=no(d);else u=await ro(d);if(!a())return;if(this.highlighter!=null)ia(u,this.highlighter);else{let c=await ei({themes:d,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!a())return;this.highlighter=c}let f=this.setRenderOptionsOnWorkers(l,u);this.renderOptions=l,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let c of this.themeSubscribers)c.onThemeChange();await f}catch(l){if(l instanceof Qr||!a())return;throw l}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;if(!this.isInitialized())await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");n.push(new Promise((i,o)=>{let s=this.generateRequestId(),a={type:"set-render-options",id:s,request:{type:"set-render-options",id:s,renderOptions:e,resolvedThemes:t},resolve:i,reject:o,requestStart:Date.now()};this.activeTaskById.set(s,a),r.pendingSetupRequestId=s,r.worker.postMessage(a.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){if(this._queuedBroadcast!=null)return;this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{if(this._queuedBroadcast!=null)cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0;let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);if(Nt(n)){if(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeActiveTask(n)}else this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0)return;else if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let i=Jr(this.renderOptions.theme),o=[];if(co(i))o=no(i);else o=await ro(i);if(!this.isCurrentLifecycle(t)){n();return}let s=[];if(eo(e))s=Ji(e);else s=await to(e);if(!this.isCurrentLifecycle(t)){n();return}let[a]=await Promise.all([ei({themes:i,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(o,s)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=a,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(i){if(i instanceof Qr||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(let o of this.queuedTasks)this.rejectRenderTaskCallbacks(o,Zr(i));this.queueBroadcastStateChanges(),r(i)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=so(),i=r>0?ao():void 0;if(this.workers.length>0)this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let l=this.options.workerFactory(),d={worker:l,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:u})=>u)]),customExtensionsVersion:0};l.addEventListener("message",(u)=>{this.handleWorkerMessage(d,u.data)}),l.addEventListener("error",(u)=>this.handleWorkerError(d,u)),this.workers.push(d),n.push(new Promise((u,f)=>{let c=this.generateRequestId(),m={type:"initialize",id:c,request:{type:"initialize",id:c,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i!=null?r:void 0,customExtensionMap:i},resolve(){d.initialized=!0,u()},reject:f,requestStart:Date.now()};d.pendingSetupRequestId=c,this.activeTaskById.set(c,m),this.executeTask(d,m)}))}let o=this.options.workerInitializationTimeout??Bh,s;try{await Promise.race([Promise.all(n),new Promise((a,l)=>{s=setTimeout(()=>{l(Error(`WorkerPoolManager: worker initialization timed out after ${o}ms`))},o)})])}finally{if(s!=null)clearTimeout(s)}}handleWorkerError(e,t){console.error("Worker error:",t,e);let{pendingSetupRequestId:n}=e;if(n==null)return;let r=this.activeTaskById.get(n);if(r?.type!=="initialize")return;r.reject(Zr(t)),this.cleanWorkerAndTask(e,r)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized!==!0||this.queuedTasks.length===0)return;for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=na(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()};highlightFileAST(e,t){let n=this.getFileResultCache(t);if(lo(t)||n!=null&&ni(n.options,this.getFileRenderOptions()))return;if(!this.hasMatchingFileInstanceTask(e,t))this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeFileHighlightCache: worker pool is not working"));let t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||lo(e)||t!=null&&ni(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="file"?r:void 0;else{let i=this.submitCacheTask({type:"file",file:e},n);return i.type==="file"?i:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return sa(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);if(uo(t)||n!=null&&hr(n.options,this.getDiffRenderOptions()))return;if(!this.hasMatchingDiffInstanceTask(e,t))this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeDiffHighlightCache: worker pool is not working"));let t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||uo(e)||t!=null&&hr(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="diff"?r:void 0;else{let i=this.submitCacheTask({type:"diff",diff:e},n);return i.type==="diff"?i:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter!=null?ca(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new Qr;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch((t)=>{console.error(t)})}cancelActiveWorkerTasks(){let e=new Qr;for(let t of this.activeTaskById.values())if("reject"in t)t.reject(e);else if(Nt(t))this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:(()=>{if(this.initialized===!1)return"waiting";if(this.initialized!==!0)return"initializing";return"initialized"})(),totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter((e)=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n!=null?this.getTaskByHighlightKey(n):void 0;if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),o=Date.now(),{renderOptionsVersion:s}=this,a=(()=>{switch(t.type){case"file":return{type:"file",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o};case"diff":return{type:"diff",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o}}})();this.enqueueRenderTask(a,e)}submitCacheTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,o=(()=>{switch(e.type){case"file":return{type:"file",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case"diff":return{type:"diff",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(o),o}enqueueRenderTask(e,t){if(this.queuedTasks.push(e),t!=null)this.queuedTaskByInstance.set(t,e);if(e.highlightKey!=null)this.taskByHighlightKey.set(e.highlightKey,e);this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter((o)=>!ra(o));if(r.length>0)ei({themes:Jr(this.renderOptions.theme),langs:["text",...r],preferredHighlighter:this.preferredHighlighter}).catch((o)=>{console.error(o)});let i=n.filter((o)=>!e.langs.has(o));if(i.length>0)if(eo(i))t.request.resolvedLanguages=Ji(i);else t.request.resolvedLanguages=await to(i);if(!this.activeTaskById.has(t.id)){if(e.requestId===t.id){if(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}return}this.executeTask(e,t)}catch(r){if(this.rejectRenderTaskCallbacks(t,Zr(r)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw Xr;else if(t.type==="error"){let r=Error(t.error);if(t.stack)r.stack=t.stack;if("reject"in n)n.reject(r);else if(Nt(n))this.notifyHighlightError(n,r),this.rejectRenderTaskCallbacks(n,r);else throw Error("handleWorkerMessage: unknown task type");throw r}else switch(t.requestType){case"initialize":if(n.type!=="initialize")throw Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case"set-render-options":if(n.type!=="set-render-options")throw Error("handleWorkerMessage: task/response dont match");n.resolve();break;case"file":{if(n.type!=="file")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!ni(i,this.getFileRenderOptions()))throw Xr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case"diff":{if(n.type!=="diff")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!hr(i,this.getDiffRenderOptions()))throw Xr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(r){if(r!==Xr)console.error(r,n,t)}if(this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}_queuedDrain;queueDrain(){if(this._queuedDrain!=null)return;this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges()}assignWorkerToTask(e,t){if(t.requestId=e.id,Nt(e))this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e);this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){if(e.requestId===n)e.requestId=void 0;if(e.pendingSetupRequestId===n)e.pendingSetupRequestId=void 0;if(t!=null){if(Nt(t))this.rejectRenderTaskCallbacks(t,new io),this.clearInstanceRequests(t),this.clearHighlightKey(t);this.activeTaskById.delete(t.id)}}executeTask(e,t){if(Hh(t.request))this.maybeAttachCustomExtensions(e,t.request);if(!this.activeTaskById.has(t.id))this.assignWorkerToTask(t,e);for(let n of na(t))e.langs.add(n);try{if(t.type==="file")t.cacheKeyAtDispatch=t.request.file.cacheKey;else if(t.type==="diff")t.cacheKeyAtDispatch=t.request.diff.cacheKey;e.worker.postMessage(t.request)}catch(n){if(console.error("Failed to post message to worker:",n),Nt(t))this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Zr(n));else if("reject"in t)t.reject(n);if(this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0)this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=so();if(e.customExtensionsVersion>=n)return;t.customExtensionsVersion=n,t.customExtensionMap=ao()}syncCustomExtensionVersion(e,t){if(t.customExtensionsVersion==null)return;e.customExtensionsVersion=t.customExtensionsVersion}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let i of e)if(!n.langs.has(i)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey==null)return;return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey==null)return;return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of dr(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){if(e.type==="file")e.instances.add(t);else e.instances.add(t);if(this.activeTaskById.has(e.id))this.activeRequestByInstance.set(t,e.id);else this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);if(n==null||n===t)return;if(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeQueuedTask(n)}detachInstanceFromRenderTask(e,t){if(e.type==="file")e.instances.delete(t);else e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);if(t!==-1)this.queuedTasks.splice(t,1);this.rejectRenderTaskCallbacks(e,new io),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new io),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];if(t.renderOptionsVersion!==this.renderOptionsVersion)this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))if(Nt(e)&&e.renderOptionsVersion!==this.renderOptionsVersion)this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of dr(e))if(this.queuedTaskByInstance.get(t)===e)this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){if(e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e)this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of dr(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of dr(e))if(this.activeRequestByInstance.get(t)===e.id)this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of dr(e))if(this.activeRequestByInstance.get(n)===e.id)n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="file"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&la(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="diff"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&aa(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())if(Nt(e))yield e}generateRequestId(){return`req_${++this.nextRequestId}`}};function Hh(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function na(e){let t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??ti(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??ti(e.request.diff.name)),t.add(e.request.diff.lang??ti(e.request.diff.prevName??"-"));break}return t.delete("text"),Array.from(t)}function Nt(e){return e?.type==="file"||e?.type==="diff"}function dr(e){return e.instances}function Zr(e){if(e instanceof Error)return e;if(e!=null&&typeof e==="object"){if("error"in e&&e.error instanceof Error)return e.error;if("message"in e&&typeof e.message==="string")return Error(e.message)}return Error(String(e))}var fr;function fo({poolOptions:e,highlighterOptions:t}){return fr??=new ua(e,t),fr}function po(){if(fr==null)return;fr.terminate(),fr=void 0}function on(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function mo(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Lt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let i=e[r];if(i!=null)n.set(i.nameId,r)}return t.childIdByNameId=n,n}function Cn(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];if(r!=null)t.set(r,n)}return e.childPositionById=t,t}function xn(e,t){if(e.childPositionById!=null)e.childPositionById.set(t,e.childIds.length);e.childIds.push(t)}function go(e,t){if(e.childPositionById==null)return;for(let n=t;n<e.childIds.length;n++){let r=e.childIds[n];if(r!=null)e.childPositionById.set(r,n)}}function sn(e,t){let n=0,r=0;for(let i of t.childIds){let o=e[i];if(o==null)continue;n+=o.subtreeNodeCount,r+=o.visibleSubtreeCount}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,Ft(e,t)}function ri(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Cn(e).get(t);if(i===void 0)return;let o=i>>5;e.childVisibleChunkSums[o]+=r}function ii(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let o=n,s=0;for(let a of r){if(o<a){let l=Vh(e,t,s,o);return{...l,childVisibleIndex:n-l.localVisibleIndex}}o-=a,s+=32}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let o=0;o<t.childIds.length;o++){let s=t.childIds[o];if(s==null)continue;let a=e[s];if(a==null)continue;if(i<a.visibleSubtreeCount)return{childIndex:o,childVisibleIndex:n-i,localVisibleIndex:i};i-=a.visibleSubtreeCount}throw Error(`Visible child index ${String(n)} is out of range`)}function da(e,t,n){let r=0,i=t.childVisibleChunkSums,o=0;if(i!=null){let s=n>>5;for(let a=0;a<s;a+=1)r+=i[a]??0;o=s<<5}for(let s=o;s<n;s+=1){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;r+=l.visibleSubtreeCount}return r}function Ft(e,t){if(t.childIds.length<128){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/32),r=new Int32Array(n);for(let i=0;i<t.childIds.length;i++){let o=t.childIds[i];if(o==null)continue;let s=e[o];if(s==null)continue;r[i>>5]+=s.visibleSubtreeCount}t.childVisibleChunkSums=r}function Vh(e,t,n,r){let i=Math.min(t.childIds.length,n+32),o=r;for(let s=n;s<i;s++){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;if(o<l.visibleSubtreeCount)return{childIndex:s,localVisibleIndex:o};o-=l.visibleSubtreeCount}throw Error(`Visible child index ${String(r)} is out of range`)}function Ne(e,t,n=0){return e<<4|n<<3|t}function qe(e){return e.depthAndFlags>>>4}function pr(e){return(e.depthAndFlags&8)>>3}function R(e){return(e.depthAndFlags&8)!==0}function ha(e){return e.depthAndFlags&7}function ue(e,t){return(ha(e)&t)!==0}function kn(e,t){e.depthAndFlags|=t}function fa(e,t){e.depthAndFlags=Ne(t,ha(e),pr(e))}var pa=Symbol("benchmarkInstrumentation");function ma(e,t){if(t==null)return e;return Object.defineProperty(e,pa,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function mr(e){if(e==null)return null;return e[pa]??null}function E(e,t,n){if(e==null)return n();return e.measurePhase(t,n)}function _n(e,t,n){if(!Number.isFinite(n)||e==null)return;e.setCounter(t,n)}function ga(e){return e>=48&&e<=57}function Oh(e){let t=[],n=0,r=0;while(r<e.length){while(r<e.length&&!ga(e.charCodeAt(r)))r+=1;if(r>=e.length)break;if(r>n)t.push(e.slice(n,r));let i=0;while(r<e.length&&ga(e.charCodeAt(r)))i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}if(n<e.length||t.length===0)t.push(e.slice(n));return t}function an(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Oh(t)}}function qh(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let i=e[r],o=t[r];if(i===o)continue;if(typeof i==="number"&&typeof o==="number")return i<o?-1:1;let s=String(i),a=String(o);if(s!==a)return s<a?-1:1}if(e.length!==t.length)return e.length<t.length?-1:1;return 0}function gr(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==="string"&&typeof t.tokens[0]==="string"){if(e.lowerValue===t.lowerValue)return 0;return e.lowerValue<t.lowerValue?-1:1}let n=qh(e.tokens,t.tokens);if(n!==0)return n;if(e.lowerValue!==t.lowerValue)return e.lowerValue<t.lowerValue?-1:1;return 0}function va(e,t,n){let r=gr(n(e),n(t));if(r!==0)return r;if(e===t)return 0;return e<t?-1:1}function zh(e,t){return va(e,t,an)}function oi(e,t){if(t!==e.segments.length-1)return 1;return e.isDirectory?1:0}function Wh(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let i=e.segments[r],o=t.segments[r];if(i===o)continue;let s=oi(e,r);if(s!==oi(t,r))return s===1?-1:1;return zh(i,o)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function ya(e,t){return Wh(e,t)}function ba(e,t,n){let r=(o)=>{let s=n.get(o);if(s!=null)return s;let a=an(o);return n.set(o,a),a},i=Math.min(e.segments.length,t.segments.length);for(let o=0;o<i;o++){let s=e.segments[o],a=t.segments[o];if(s===a)continue;let l=oi(e,o);if(l!==oi(t,o))return l===1?-1:1;return va(s,a,r)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function vr(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=an(r);return e.sortKeyById[t]=i,i}function vo(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??"default"}}function wa(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let o=0;o<n;o++){if(e.charCodeAt(o)!==47)continue;r.push(e.slice(i,o)),i=o+1}return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function ln(e){let{hasTrailingSlash:t,segments:n}=wa(e);return{basename:n[n.length-1]??"",isDirectory:t,path:e,segments:n}}function si(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=wa(e);return{requiresDirectory:t,segments:n}}function ai(){let e=new Map;return e.set("",0),{idByValue:e,valueById:[""],sortKeyById:[an("")]}}function st(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 Ue(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var yo=Symbol("pathStorePreparedInputKind");function Ca(e,t){return e[yo]=t,e}function Ia(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function xa(e,t,n){if(n==="default")return ya(e,t);return n(Ia(e),Ia(t))}function $h(){return{depthAndFlags:Ne(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function jh(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 Sa(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Uh(e){return Array.isArray(e)&&e.every((t)=>t!=null&&typeof t==="object"&&typeof t.path==="string"&&Array.isArray(t.segments)&&typeof t.basename==="string"&&typeof t.isDirectory==="boolean")}function Kh(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function ka(e,t={}){return li(e,t).map((n)=>n.path)}function _a(e,t={}){let n=li(e,t);return Ca({paths:n.map((r)=>r.path),preparedPaths:n},"prepared")}function Ea(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let i=e[r];if(i.length>0&&i.charCodeAt(i.length-1)===47){n=!0;break}}return Ca({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},"presorted")}function Ta(e){let t=e,n=t.preparedPaths;if(t[yo]==="prepared"&&n!=null)return n;if(!Uh(n))throw Error("preparedInput must come from PathStore.prepareInput()");return n}function Pa(e){let t=e;if(t[yo]==="presorted"&&t.presortedPaths!=null)return t.presortedPaths;return Kh(t.presortedPaths)?t.presortedPaths:null}function Ra(e){let t=e;return typeof t.presortedPathsContainDirectories==="boolean"?t.presortedPathsContainDirectories:null}function li(e,t={}){let n=vo(t),r=mr(t);_n(r,"workload.inputFiles",e.length);let i=E(r,"store.preparePathEntries.parse",()=>e.map((o)=>ln(o)));return E(r,"store.preparePathEntries.sort",()=>i.sort((o,s)=>xa(o,s,n.sort))),i}var ci=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[$h()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=ai();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=mr(e),this.options=vo(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let n=new Set,r=t.length;for(let i=0;i<r;i+=1){let o=t[i],s=o.length;n.add(s>0&&o.charCodeAt(s-1)===47?o.slice(0,s-1):o)}this.initialExpandedPathSet=n,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,on())}appendPaths(e){return E(this.instrumentation,"store.builder.appendPaths.parse",()=>this.appendPreparedPaths(e.map((t)=>ln(t))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,E(this.instrumentation,"store.builder.appendPreparedPaths",()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return E(this.instrumentation,"store.builder.appendPresortedPaths",()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,o=this.segmentTable,s=o.idByValue,a=o.valueById,l=this.directoryStack,d=0,u="",f=0;for(let c of e){if(n===c)throw Error(`Duplicate path: "${c}"`);let m=c.length>0&&c.charCodeAt(c.length-1)===47,p=m?c.length-1:c.length,g=0,v=0;if(n!=null)if(u.length>0&&c.length>u.length&&c.startsWith(u))g=f,v=u.length;else{let y=Math.min(p,n.length),S=!0;for(let x=0;x<y;x++){let T=c.charCodeAt(x);if(T!==n.charCodeAt(x)){S=!1;break}if(T===47)g++,v=x+1}if(S&&m&&y===p&&n.length>p&&n.charCodeAt(p)===47)g++,v=p+1}d=g,r=g;let I=v,C=c.indexOf("/",I);while(C>=0&&C<p){let y=l[d];if(y===void 0)throw Error("Directory stack underflow while building the path store");r++;let S=c.slice(I,C),x=s.get(S);if(x===void 0)x=a.length,s.set(S,x),a.push(S);let T=i.length;i.push({depthAndFlags:Ne(r,0,1),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(c.slice(0,C)),d++,l[d]=T,I=C+1,C=c.indexOf("/",I)}if(m){if(I<p){let S=l[d];if(S===void 0)throw Error(`Unable to resolve directory parent for "${c}"`);r++;let x=c.slice(I,p),T=s.get(x);if(T===void 0)T=a.length,s.set(x,T),a.push(x);let O=i.length;i.push({depthAndFlags:Ne(r,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),d++,l[d]=O,I=p+1}let y=l[d];if(y===void 0)throw Error(`Unable to resolve directory node for "${c}"`);this.promoteDirectoryToExplicit(y,c)}else{let y=l[d];if(y===void 0)throw Error(`Unable to resolve file parent for "${c}"`);let S=c.slice(I),x=s.get(S);if(x===void 0)x=a.length,s.set(S,x),a.push(S);i.push({depthAndFlags:Ne(r+1,0),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1})}if(I!==u.length)u=c.substring(0,I),f=r;n=c}if(l.length=d+1,n!=null)this.lastPreparedPath=ln(n);this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,o=i.idByValue,s=i.valueById,a=this.directoryStack,l=0,d="",u=0;for(let f of e){if(t===f)throw Error(`Duplicate path: "${f}"`);let c=f.length,m=0,p=0;if(t!=null)if(d.length>0&&f.length>d.length&&f.startsWith(d))m=u,p=d.length;else{let S=Math.min(c,t.length);for(let x=0;x<S;x++){let T=f.charCodeAt(x);if(T!==t.charCodeAt(x))break;if(T===47)m++,p=x+1}}l=m,n=m;let g=p,v=f.indexOf("/",g);while(v>=0){let S=a[l];if(S===void 0)throw Error("Directory stack underflow while building the path store");n++;let x=f.slice(g,v),T=o.get(x);if(T===void 0)T=s.length,o.set(x,T),s.push(x);let O=r.length;r.push({depthAndFlags:Ne(n,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(f.slice(0,v)),this.presortedDirectoryNodeIds.push(O),l++,a[l]=O,g=v+1,v=f.indexOf("/",g)}let I=a[l];if(I===void 0)throw Error(`Unable to resolve file parent for "${f}"`);let C=f.slice(g),y=o.get(C);if(y===void 0)y=s.length,o.set(C,y),s.push(C);if(r.push({depthAndFlags:Ne(n+1,0),nameId:y,parentId:I,subtreeNodeCount:1,visibleSubtreeCount:1}),g!==d.length)d=f.substring(0,g),u=n;t=f}if(a.length=l+1,t!=null)this.lastPreparedPath=ln(t);this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;if(this.hasDeferredDirectoryIndexes)E(this.instrumentation,"store.builder.buildDirectoryIndexes",()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1;else if(!t)E(this.instrumentation,"store.builder.computeSubtreeCounts",()=>this.computeSubtreeCounts(0));return{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(),this.hasDeferredDirectoryIndexes=!1;if(this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t){if((this.options.sort==="default"?ba(this.lastPreparedPath,e,this.segmentSortKeyCache):xa(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}}let n=this.lastPreparedPath,r=Sa(e),i=n==null?0:Sa(n),o=n==null?0:jh(n.segments,e.segments),s=Math.min(o,r,i);this.directoryStack.length=s+1;for(let l=s;l<r;l++){let d=this.directoryStack[this.directoryStack.length-1];if(d===void 0)throw Error("Directory stack underflow while building the path store");let u=t?this.getOrCreateDirectoryChild(d,e.segments[l]):this.createDirectoryChild(d,e.segments[l]);this.directoryStack.push(u)}if(e.isDirectory){let l=this.directoryStack[this.directoryStack.length-1];if(l===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(l,e.path),this.lastPreparedPath=e;return}let a=this.directoryStack[this.directoryStack.length-1];if(a===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);if(t)this.createFileChild(a,e.basename,e.path);else this.createFileChildUnchecked(a,e.basename);this.lastPreparedPath=e}recordCreatedDirectoryPath(e){if(!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null)return;if(this.createdDirectoryCount+=1,!this.initialExpandedPathSet.has(e))this.createdDirectoriesAllExpanded=!1}createFileChild(e,t,n){let r=st(this.segmentTable,t),i=this.getDirectoryIndex(e),o=i.childIdByNameId;if(o!=null){if(o.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`)}let s=this.nodes[e];if(s===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;if(this.nodes.push({depthAndFlags:Ne(qe(s)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),o!=null)o.set(r,a);return xn(i,a),a}createFileChildUnchecked(e,t){let n=st(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Ne(qe(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return xn(r,o),o}getOrCreateDirectoryChild(e,t){let n=st(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let s=r.childIdByNameId.get(n);if(s!==void 0){let a=this.nodes[s];if(a!=null&&!R(a))throw Error(`Path collides with an existing file while creating directory "${t}"`);return s}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Ne(qe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return xn(r,o),this.directories.set(o,on()),o}createDirectoryChild(e,t){let n=st(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Ne(qe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return xn(r,o),this.directories.set(o,on()),o}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!R(n))throw Error(`Path is not a directory: "${t}"`);if(ue(n,1))throw Error(`Duplicate path: "${t}"`);kn(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,mo());let r=-1,i=null;for(let o=1;o<t.length;o++){let s=t[o];if(s==null)continue;if(R(s)){let l=mo();n.set(o,l),r=o,i=l}let a;if(s.parentId===r)a=i;else a=n.get(s.parentId),r=s.parentId,i=a??null;if(a!=null)a.childIds.push(o)}if(e)return;for(let o=t.length-1;o>=1;o--){let s=t[o];if(s==null)continue;let a=t[s.parentId];if(a!=null)a.subtreeNodeCount+=s.subtreeNodeCount,a.visibleSubtreeCount+=s.visibleSubtreeCount}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;if(R(n))this.directories.set(t,on());let r=this.directories.get(n.parentId);if(r!=null){if(r.childIdByNameId!=null)r.childIdByNameId.set(n.nameId,t);xn(r,t)}}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!R(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let i of n.childIds)r+=this.computeSubtreeCounts(i);return sn(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Da(e,t="closed",n=null){let r=Gh(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 Ma(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Gh(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 Aa(e,t){if(ue(t,2))return!0;if(e.defaultExpansion==="open")return!0;if(e.defaultExpansion==="closed")return!1;return qe(t)<=e.defaultExpansion}function ke(e,t,n=e.snapshot.nodes[t]){if(n==null||!R(n))return!1;if(e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides)return!0;if(e.collapsedDirectoryIds.has(t))return!1;if(e.expandedDirectoryIds.has(t))return!0;return Aa(e,n)}function Bt(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!R(r))return;let i=Aa(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 Na(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 Ht(e,t){return e.directoryLoadInfoById.get(t)?.state??"loaded"}function La(e,t){let n=Na(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 Fa(e,t){let n=Na(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state="unloaded"}function Ba(e,t,n){let r=e.directoryLoadInfoById.get(t);if(r==null||r.activeAttemptId!==n)return!1;return r.activeAttemptId=null,r.errorMessage=null,r.state="loaded",!0}function Ha(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Va(e,t,n,r){let i=e.directoryLoadInfoById.get(t);if(i==null||i.activeAttemptId!==n)return!1;return i.activeAttemptId=null,i.errorMessage=r??null,i.state="error",!0}function Oa(e,t){e.directoryLoadInfoById.delete(t)}function ja(e,t,n){let r=n,i=e.listeners.get(t);if(i!=null)i.add(r);else e.listeners.set(t,new Set([r]));return()=>{let o=e.listeners.get(t);if(o==null)return;if(o.delete(r),o.size===0)e.listeners.delete(t)}}function Ua(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"add",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ka(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"remove",path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Ga(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:"move",projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Ya(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"expand",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Xa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"collapse",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Qa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"mark-directory-unloaded",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Za(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 Ja(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some((t)=>t.canonicalChanged),childEvents:e.childEvents,operation:"apply-child-patch",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function el(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 tl(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 nl(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 Le(e,t,n){return{...n,visibleCountDelta:wo(e)-t}}function rl(e,t){let n=wo(e),r=Ma();e.transactionStack.push(r);try{t()}catch(i){throw za(e,r,!1),i}za(e,r,!0,wo(e)-n)}function Xe(e,t){let n=e.instrumentation;if(n==null){qa(e,t);return}E(n,"store.events.record",()=>qa(e,t))}function qa(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){bo(e,t);return}n.events.push(t),Qh(n,t)}function za(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 a=e.instrumentation;if(a==null)Wa(i,t);else E(a,"store.events.batch.merge",()=>Wa(i,t));return}let o=Yh(t,r),s=e.instrumentation;if(s==null){bo(e,o);return}E(s,"store.events.batch.commit",()=>bo(e,o))}function Yh(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some((n)=>n.canonicalChanged),events:[...e.events],operation:"batch",projectionChanged:e.events.some((n)=>n.projectionChanged),visibleCountDelta:t}}function Xh(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function Wa(e,t){for(let n of t.events)e.events.push(n);Xh(e,t)}function Qh(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function bo(e,t){let n=e.instrumentation;if(n==null){$a(e,t);return}E(n,"store.events.emit",()=>$a(e,t))}function $a(e,t){e.listeners.get(t.operation)?.forEach((n)=>n(t)),e.listeners.get("*")?.forEach((n)=>n(t))}function wo(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Ct(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!R(n)||ue(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 o=e.snapshot.nodes[i];if(o==null||!R(o))return null;return i}function xt(e,t){let n=t;while(!0){let r=Ct(e,n);if(r==null)return n;n=r}}function En(e,t){let n=[t],r=t;while(!0){let i=Ct(e,r);if(i==null)return n;n.push(i),r=i}}function ui(e,t){let n=t==null?e.snapshot.rootId:Fe(e,t);if(n==null)return[];return Jh(e,n)}function So(e,t){let n=ln(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Vt(e,cf(e,r)),{createdNodeIds:o,directoryId:s}=ef(e,r),a=new Set(o),l=s;if(n.isDirectory){let u=D(e,s);if(ue(u,1))throw Error(`Path already exists: "${t}"`);kn(u,1),e.pathCacheByNodeId.set(s,{path:t,version:e.pathCacheVersion}),a.add(s)}else l=nf(e,s,n.basename),a.add(l);Ot(e,s);let d=Vt(e,s);return Ua({affectedAncestorIds:Ke(e,l),affectedNodeIds:[...a],path:t,projectionChanged:ul(i,d)})}function Co(e,t,n){let r=Fe(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=D(e,r);if(ue(i,2))throw Error("The root node cannot be removed");if(R(i)&&ie(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let o=i.parentId,s=Vt(e,o),a=cl(e,r);_o(e,o,r,i.nameId),Eo(e,o),Ot(e,o);let l=Vt(e,o);return Ka({affectedAncestorIds:Ke(e,o),affectedNodeIds:a,path:t,projectionChanged:ul(s,l),recursive:n.recursive===!0})}function xo(e,t,n,r){let i=Fe(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let o=D(e,i);if(ue(o,2))throw Error("The root node cannot be moved");let s=r.collision??"error",a=af(e,i,n),l=Vt(e,o.parentId),d=Vt(e,a.parentId),u=Ue(e.snapshot.segmentTable,o.nameId),f=st(e.snapshot.segmentTable,a.basename);if(a.parentId===o.parentId&&u===a.basename)return null;if(R(o)&&df(e,i,a.parentId))throw Error("Cannot move a directory into one of its descendants");let c=Lt(e.snapshot.nodes,ie(e,a.parentId)).get(f),m=a.existingNodeId??c??null;if(m!=null&&m!==i){if(lf(e,m,s,pr(o))==="skip")return null}let p=o.parentId;if(_o(e,p,i,o.nameId),o.parentId=a.parentId,o.nameId=f,e.pathCacheByNodeId.delete(i),hl(e,i),ko(e,a.parentId,i),Eo(e,p),e.pathCacheVersion++,Ot(e,p),a.parentId!==p)Ot(e,a.parentId);let g=Vt(e,p),v=Vt(e,a.parentId);return Ga({affectedAncestorIds:[...new Set([...Ke(e,p),...Ke(e,a.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:dl([l,d],[g,v]),to:te(e,i)})}function Zh(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function il(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function te(e,t){let n=D(e,t),r=Zh(e,t);if(r!=null)return r;if(ue(n,2))return il(e,t,"");let i=te(e,n.parentId),o=Ue(e.snapshot.segmentTable,n.nameId),s=i.length===0?o:`${i}${o}`;return il(e,t,R(n)?`${s}/`:s)}function Ot(e,t){let n=e.instrumentation;if(n==null){sl(e,t);return}E(n,"store.recomputeCountsUpwardFrom",()=>sl(e,t))}function yr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;while(n.length>0){let o=n[n.length-1],s=o[0],a=r[s];if(a==null||!R(a)){Io(e,s,a,!0),n.pop();continue}let l=i.get(s);if(l==null||o[1]>=l.childIds.length){Io(e,s,a,!0),n.pop();continue}let d=l.childIds[o[1]++];n.push([d,0])}}function Ke(e,t){let n=[],r=t;while(r!=null){let i=D(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=i.parentId}return n}function Fe(e,t){if(t.length===0)return e.snapshot.rootId;let n=si(t);return ll(e,n.segments,n.requiresDirectory)}function ll(e,t,n){let r=e.snapshot.rootId;for(let o of t){let s=e.snapshot.segmentTable.idByValue.get(o);if(s===void 0)return null;let a=ie(e,r),l=Lt(e.snapshot.nodes,a).get(s);if(l===void 0)return null;r=l}let i=D(e,r);if(n&&!R(i))return null;return r}function ie(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 D(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Jh(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))return[];if(!R(n))return[te(e,t)];if(ie(e,t).childIds.length===0)return ue(n,1)&&!ue(n,2)?[te(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];while(i.length>0){let o=i[i.length-1];if(o==null)break;let s=e.snapshot.nodes[o.nodeId];if(s===void 0||ue(s,4)){i.pop();continue}if(!R(s)){r.push(te(e,o.nodeId)),i.pop();continue}let a=ie(e,o.nodeId);if(a.childIds.length===0){if(ue(s,1)&&!ue(s,2))r.push(te(e,o.nodeId));i.pop();continue}let l=a.childIds[o.childIndex];if(l==null){i.pop();continue}o.childIndex++,i.push({childIndex:0,nodeId:l})}return r}function ef(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let o=st(e.snapshot.segmentTable,i),s=ie(e,r),a=Lt(e.snapshot.nodes,s).get(o);if(a!==void 0){if(!R(D(e,a)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=a;continue}r=tf(e,r,o),n.push(r)}return{createdNodeIds:n,directoryId:r}}function tf(e,t,n){let r=D(e,t),i=e.snapshot.nodes.length;if(e.snapshot.nodes.push({depthAndFlags:Ne(qe(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,on()),ko(e,t,i),e.collapseNewDirectoriesByDefault)e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0;return e.activeNodeCount++,i}function nf(e,t,n){let r=st(e.snapshot.segmentTable,n),i=ie(e,t);if(Lt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${hf(e,t,n)}"`);let o=D(e,t),s=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Ne(qe(o)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),ko(e,t,s),e.activeNodeCount++,s}function rf(e,t,n){let r=0,i=t.childIds.length;while(r<i){let o=r+i>>>1,s=t.childIds[o];if(s==null){i=o;continue}if(of(e,n,s)<0)i=o;else r=o+1}return r}function ko(e,t,n){let r=ie(e,t),i=D(e,n);Lt(e.snapshot.nodes,r).set(i.nameId,n),ri(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let o=rf(e,r,n);r.childIds.splice(o,0,n),go(r,o),Ft(e.snapshot.nodes,r)}function _o(e,t,n,r){let i=ie(e,t),o=Cn(i),s=o.get(n)??-1;Lt(e.snapshot.nodes,i).delete(r),o.delete(n);let a=e.snapshot.nodes[n];if(a!=null)ri(i,n,-a.subtreeNodeCount,-a.visibleSubtreeCount);if(s>=0)i.childIds.splice(s,1),go(i,s),Ft(e.snapshot.nodes,i)}function of(e,t,n){let r=e.snapshot.options.sort;if(r==="default")return sf(e,t,n);return r(ol(e,t),ol(e,n))}function sf(e,t,n){let r=D(e,t),i=D(e,n),o=R(r);if(o!==R(i))return o?-1:1;let s=gr(vr(e.snapshot.segmentTable,r.nameId),vr(e.snapshot.segmentTable,i.nameId));if(s!==0)return s;let a=Ue(e.snapshot.segmentTable,r.nameId),l=Ue(e.snapshot.segmentTable,i.nameId);if(a!==l)return a<l?-1:1;return t<n?-1:1}function ol(e,t){let n=D(e,t),r=te(e,t),i=R(n),o=i?r.slice(0,-1):r;return{basename:Ue(e.snapshot.segmentTable,n.nameId),depth:qe(n),isDirectory:i,path:r,segments:o.length===0?[]:o.split("/")}}function af(e,t,n){let r=D(e,t),i=Fe(e,n);if(i!=null){let d=D(e,i);if(R(d))return{basename:Ue(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let u=si(n).segments;return{basename:u[u.length-1]??"",existingNodeId:i,parentId:d.parentId}}let o=si(n),s=o.segments[o.segments.length-1]??"",a=o.segments.slice(0,-1),l=a.length===0?e.snapshot.rootId:ll(e,a,!0);if(l==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:s,existingNodeId:null,parentId:l}}function lf(e,t,n,r){if(n==="skip")return"skip";if(n==="error")throw Error(`Destination already exists: "${te(e,t)}"`);let i=D(e,t);if(pr(i)!==r)throw Error("replace collision requires the same source and destination kinds");if(R(i)&&ie(e,t).childIds.length>0)throw Error("replace collision does not support non-empty directories");let{parentId:o,nameId:s}=i;return cl(e,t),_o(e,o,t,s),Eo(e,o),Ot(e,o),"handled"}function cl(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];while(r.length>0){let i=r.pop();if(i==null)break;let o=D(e,i.nodeId);if(i.visitedChildren||!R(o)){if(R(o))e.snapshot.directories.delete(i.nodeId);if(kn(o,4),e.pathCacheByNodeId.delete(i.nodeId),e.collapsedDirectoryIds.delete(i.nodeId))e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;e.expandedDirectoryIds.delete(i.nodeId),Oa(e,i.nodeId),e.activeNodeCount--,n.push(i.nodeId);continue}r.push({nodeId:i.nodeId,visitedChildren:!0});let s=ie(e,i.nodeId);for(let a=s.childIds.length-1;a>=0;a--){let l=s.childIds[a];if(l!=null)r.push({nodeId:l,visitedChildren:!1})}}return n}function Eo(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return;if(ie(e,n).childIds.length>0)return;kn(r,1),n=r.parentId===n?null:r.parentId}}function cf(e,t){let n=e.snapshot.rootId;for(let r of t){let i=e.snapshot.segmentTable.idByValue.get(r);if(i==null)break;let o=Lt(e.snapshot.nodes,ie(e,n)).get(i);if(o==null)break;if(!R(D(e,o)))break;n=o}return n}function Vt(e,t){let n=uf(e,t);if(n==null)return null;let r=xt(e,n),i=D(e,r),o=n===r?null:En(e,n).map((s)=>te(e,s));return JSON.stringify({flattenedSegmentPaths:o,hasChildren:ie(e,r).childIds.length>0,path:te(e,r),terminalKind:pr(i)})}function ul(e,t){return dl([e],[t])}function dl(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 uf(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return null;if(!ke(e,n,r))return n;n=r.parentId}return null}function hl(e,t){let n=D(e,t);if(fa(n,(t===e.snapshot.rootId?-1:qe(D(e,n.parentId)))+1),!R(n))return;let r=ie(e,t);for(let i of r.childIds)hl(e,i)}function df(e,t,n){let r=n;while(r!=null){if(r===t)return!0;let i=D(e,r);if(r===e.snapshot.rootId)return!1;r=i.parentId}return!1}function Io(e,t,n=D(e,t),r=!1){let i=e.instrumentation;if(i==null){al(e,t,n,r);return}E(i,"store.recomputeNodeCounts",()=>al(e,t,n,r))}function sl(e,t){let n=t;while(n!=null){let r=D(e,n),i=r.subtreeNodeCount,o=r.visibleSubtreeCount;if(Io(e,n,r),n===e.snapshot.rootId)return;let s=r.subtreeNodeCount-i,a=r.visibleSubtreeCount-o,l=r.parentId;if(s!==0||a!==0)ri(ie(e,l),n,s,a);n=l}}function al(e,t,n,r){if(!R(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=ie(e,t);if(r){let a=e.instrumentation;if(a==null)sn(e.snapshot.nodes,i);else E(a,"store.recomputeNodeCounts.rebuildChildAggregates",()=>sn(e.snapshot.nodes,i))}let o=1+i.totalChildSubtreeNodeCount,s=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=o,ue(n,2)){n.visibleSubtreeCount=s;return}n.visibleSubtreeCount=Ct(e,t)!=null?s:ke(e,t,n)?1+s:1}function hf(e,t,n){let r=te(e,t);return r.length===0?n:`${r}${n}`}function Tn(e){return e!=null&&!ue(e,4)}function di(e,t){let n=e.snapshot.nodes[t];if(!Tn(n)||!R(n)||ue(n,2))return null;return n}function ff(e){let t=0;for(let[n,r]of e.pathCacheByNodeId){if(r.version!==e.pathCacheVersion)continue;if(!Tn(e.snapshot.nodes[n]))continue;t+=1}return t}function pf(e){return Math.max(0,e.valueById.length-1)}function fl(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:ff(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:pf(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function mf(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 pl(e){let t=[],n=[];for(let r of e.collapsedDirectoryIds)if(di(e,r)!=null)t.push(te(e,r));for(let r of e.expandedDirectoryIds)if(di(e,r)!=null)n.push(te(e,r));return{collapsedPaths:t,expandedPaths:n}}function ml(e){let t=[];for(let[n,r]of e.directoryLoadInfoById){if(di(e,n)==null||Ht(e,n)==="loaded")continue;t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:te(e,n)})}return t}function gl(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let r=Fe(e,n);if(r==null)continue;Bt(e,r,!0,D(e,r))}for(let n of t.collapsedPaths){let r=Fe(e,n);if(r==null)continue;Bt(e,r,!1,D(e,r))}}function vl(e,t){e.directoryLoadInfoById.clear();for(let n of t){let r=Fe(e,n.path);if(r==null)continue;if(di(e,r)==null)continue;e.directoryLoadInfoById.set(r,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function gf(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:"",version:e.pathCacheVersion})}function vf(e){let t=e.snapshot.segmentTable,n=ai();for(let r of e.snapshot.nodes){if(!Tn(r))continue;if(ue(r,2)){r.nameId=0;continue}r.nameId=st(n,Ue(t,r.nameId))}e.snapshot.segmentTable=n}function yf(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Tn(r)||!R(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter((o)=>{let s=e.snapshot.nodes[o];return Tn(s)&&s.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map((o)=>[D(e,o).nameId,o])),n.childPositionById=new Map(i.map((o,s)=>[o,s])),sn(e.snapshot.nodes,n)}}function bf(e){let t=e.snapshot.nodes.length-1;while(t>e.snapshot.rootId){let n=e.snapshot.nodes[t];if(Tn(n))break;t-=1}e.snapshot.nodes.length=t+1}function wf(e){let t=pl(e),n=ml(e);E(e.instrumentation,"store.cleanup.stable.clearPathCaches",()=>gf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildSegmentTable",()=>vf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildDirectoryIndexes",()=>yf(e)),E(e.instrumentation,"store.cleanup.stable.trimTrailingRemovedNodeSlots",()=>bf(e)),E(e.instrumentation,"store.cleanup.stable.restoreExpansionOverrides",()=>gl(e,t)),E(e.instrumentation,"store.cleanup.stable.restoreDirectoryLoadInfos",()=>vl(e,n)),E(e.instrumentation,"store.cleanup.stable.recomputeCounts",()=>yr(e,e.snapshot.rootId))}function If(e){let t=pl(e),n=ml(e),r=E(e.instrumentation,"store.cleanup.aggressive.listPaths",()=>ui(e)),i=ma({...e.snapshot.options},e.instrumentation),o=E(e.instrumentation,"store.cleanup.aggressive.rebuildSnapshot",()=>{let s=new ci(i);return s.appendPaths(r),s.finish()});e.snapshot=o,e.activeNodeCount=o.nodes.length-1,e.pathCacheByNodeId=new Map([[o.rootId,{path:"",version:0}]]),e.pathCacheVersion=0,E(e.instrumentation,"store.cleanup.aggressive.restoreExpansionOverrides",()=>gl(e,t)),E(e.instrumentation,"store.cleanup.aggressive.restoreDirectoryLoadInfos",()=>vl(e,n)),E(e.instrumentation,"store.cleanup.aggressive.recomputeCounts",()=>yr(e,e.snapshot.rootId))}function yl(e){for(let t of e.directoryLoadInfoById.values())if(t.state==="loading"&&t.activeAttemptId!=null)return!0;return!1}function bl(e,t){let n=fl(e);if(t==="stable")E(e.instrumentation,"store.cleanup.stable",()=>wf(e));else E(e.instrumentation,"store.cleanup.aggressive",()=>If(e));let r=fl(e);return mf(t,t==="stable",n,r)}var Sf=64;function Cf(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;while(r<n)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function _e(e){return D(e,e.snapshot.rootId).visibleSubtreeCount}function Cl(e,t,n,r){let i=D(e,t.terminalNodeId),o=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+o-1)}function xf(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:br(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Cl(e,t.cursor,t.index,n)}}function xl(e,t,n,r,i,o){let s=ie(e,t),{childIndex:a,childVisibleIndex:l,localVisibleIndex:d}=ii(e.snapshot.nodes,s,n),u=s.childIds[a];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return kf(e,u,d,r+l,i+1,a,s.childIds.length,o)}function kf(e,t,n,r,i,o,s,a){if(!R(D(e,t))){if(n===0)return{ancestors:a,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:o,setSize:s};throw Error(`Visible index ${String(n)} is out of range for file`)}let l=Ml(e,t,i);if(n===0)return{ancestors:a,cursor:l,index:r,posInSet:o,setSize:s};let d=D(e,l.terminalNodeId);if(!R(d)||!ke(e,l.terminalNodeId,d))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return xl(e,l.terminalNodeId,n-1,r+1,l.visibleDepth,[...a,{cursor:l,index:r,posInSet:o,setSize:s}])}function kl(e,t){let n=_e(e);if(t<0||t>=n)return null;let r=xl(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map((s)=>te(e,s.cursor.terminalNodeId)),o=null;return{ancestorPaths:i,get ancestorRows(){if(o!=null)return o;let s=[],a=[];for(let l of r.ancestors){let d=xf(e,l,n,[...a]);s.push(d),a.push(d.row.path)}return o=s,o},index:r.index,posInSet:r.posInSet,row:br(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Cl(e,r.cursor,r.index,n)}}function _l(e,t,n){let r=e.instrumentation,i=_e(e);if(i<=0||n<t)return[];let o=Math.max(0,Math.min(t,i-1)),s=Math.max(o,Math.min(n,i-1));if(r==null){if(o===0)return Tf(e,s+1);let f=[],c=wl(e,o);for(let m=o;m<=s&&c!=null;m++){let p=br(e,c);f.push(p),c=Il(e,c)}return f}let a=[],l=0,d=0,u=E(r,"store.getVisibleSlice.selectFirstRow",()=>wl(e,o));for(let f=o;f<=s&&u!=null;f++){let c=E(r,"store.getVisibleSlice.materializeRow",()=>br(e,u));if(a.push(c),c.isFlattened)l++,d+=c.flattenedSegments?.length??0;u=E(r,"store.getVisibleSlice.advanceCursor",()=>Il(e,u))}return _n(r,"workload.visibleRowsRead",a.length),_n(r,"workload.flattenedRowsRead",l),_n(r,"workload.flattenedSegmentsRead",d),a}function Po(e,t=_e(e)){let n=e.instrumentation;if(n==null)return Sl(e,t);return E(n,"store.getVisibleTreeProjection",()=>Sl(e,t))}function El(e){return Ef(Po(e))}function Tl(e,t){let n=Fe(e,t);if(n==null||n===e.snapshot.rootId)return null;if(R(D(e,n))&&xt(e,n)!==n)return null;let r=0,i=n,{nodes:o,rootId:s}=e.snapshot;while(i!==s){let a=D(e,i).parentId,l=ie(e,a),d=Cn(l).get(i);if(d==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=da(o,l,d),a!==s){let u=D(e,a),f=Ct(e,a);if(!ke(e,a,u)&&f!==i)return null;if(xt(e,a)===a)r+=1}i=a}return r}function Pl(e,t){let n=Fe(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(ke(e,n,r))return null;return Bt(e,n,!0,r),Ot(e,n),Ya({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function Rl(e,t){let n=Fe(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(!ke(e,n,r))return null;return Bt(e,n,!1,r),Ot(e,n),Xa({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function wl(e,t){if(t<0||t>=_e(e))return null;return Dl(e,e.snapshot.rootId,t,-1)}function Dl(e,t,n,r){let i=ie(e,t),o=e.instrumentation,{childIndex:s,localVisibleIndex:a}=o==null?ii(e.snapshot.nodes,i,n):E(o,"store.getVisibleSlice.selectChildIndex",()=>ii(e.snapshot.nodes,i,n)),l=i.childIds[s];if(l!=null)return To(e,l,a,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function To(e,t,n,r){if(!R(D(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=Ml(e,t,r);if(n===0)return i;let o=D(e,i.terminalNodeId);if(!R(o)||!ke(e,i.terminalNodeId,o))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Dl(e,i.terminalNodeId,n-1,i.visibleDepth)}function Ml(e,t,n){if(!R(D(e,t)))return{headNodeId:t,terminalNodeId:t,visibleDepth:n};if(e.instrumentation==null)return{headNodeId:t,terminalNodeId:xt(e,t),visibleDepth:n};return{headNodeId:t,terminalNodeId:E(e.instrumentation,"store.getVisibleSlice.flatten.resolveTerminalDirectory",()=>xt(e,t)),visibleDepth:n}}function _f(e,t){let n=D(e,t);if(!R(n))return!0;let r=n.parentId;if(r===e.snapshot.rootId)return!0;return Ct(e,r)!==t}function Il(e,t){let n=D(e,t.terminalNodeId);if(R(n)){let o=ie(e,t.terminalNodeId);if(ke(e,t.terminalNodeId,n)&&o.childIds.length>0){let s=o.childIds[0];return s==null?null:To(e,s,0,t.visibleDepth+1)}}let{terminalNodeId:r,visibleDepth:i}=t;while(!0){let o=D(e,r);if(r===e.snapshot.rootId)return null;let s=o.parentId,a=ie(e,s),l=Cn(a).get(r)??-1;if(l<0)throw Error(`Child ${String(r)} was not found in its parent index`);let d=a.childIds[l+1]??null;if(d!=null)return To(e,d,0,i);if(_f(e,r))i--;r=s}}function Ef(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let i=e.getParentIndex(r);n[r]={index:r,parentPath:i>=0?e.paths[i]??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 Sl(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),o=new Int32Array(t),s=new Int32Array(Sf);s.fill(-1);let a=0,{nodes:l,directories:d,segmentTable:u}=e.snapshot,f=[[d.get(e.snapshot.rootId),0,-1,""]],c=e.snapshot.options.flattenEmptyDirectories,m=e.pathCacheByNodeId,p=e.pathCacheVersion,g=u.valueById;while(f.length>0&&a<t){let S=f[f.length-1],x=S[0];if(S[1]>=x.childIds.length){f.pop();continue}let T=S[1],O=x.childIds[S[1]++],fe=l[O],Z=S[2]+1,pe=S[3];s=Cf(s,Z);let J,K=O;if(!R(fe)){let ae=m.get(O);J=ae!=null&&ae.version===p?ae.path:`${pe}${g[fe.nameId]}`}else K=c?xt(e,O):O,J=K===O?`${pe}${g[fe.nameId]}/`:te(e,K);r[a]=s[Z],n[a]=J,i[a]=T,o[a]=x.childIds.length,s[Z+1]=a,a+=1;let B=l[K];if(B!=null&&R(B)&&ke(e,K,B))f.push([d.get(K),0,Z,J])}if(a<t)n.length=a;let v=r.subarray(0,a),I=i.subarray(0,a),C=o.subarray(0,a),y=null;return{getParentIndex(S){return S<0||S>=a?-1:v[S]??-1},paths:n,posInSetByIndex:I,setSizeByIndex:C,get visibleIndexByPath(){if(y==null){y=new Map;for(let S=0;S<a;S+=1)y.set(n[S]??"",S)}return y}}}function Tf(e,t){let n=Array(t),r=0,{nodes:i,directories:o,segmentTable:s}=e.snapshot,a=[[o.get(e.snapshot.rootId),0,-1]],l=s.valueById,d=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,f=e.pathCacheVersion;while(a.length>0&&r<t){let c=a[a.length-1],m=c[0];if(c[1]>=m.childIds.length){a.pop();continue}let p=m.childIds[c[1]++],g=i[p],v=c[2]+1;if(!R(g)){let S=u.get(p);n[r++]={depth:v,flattenedSegments:void 0,hasChildren:!1,id:p,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:"file",loadState:void 0,name:l[g.nameId],path:S!=null&&S.version===f?S.path:te(e,p)};continue}let I=d?xt(e,p):p,C={headNodeId:p,terminalNodeId:I,visibleDepth:v};n[r++]=br(e,C);let y=i[I];if(y!=null&&R(y)&&ke(e,I,y))a.push([o.get(I),0,v])}if(r<t)n.length=r;return n}function br(e,t){let n=D(e,t.terminalNodeId),r=R(n)?Pf(e,t):null,i=te(e,t.terminalNodeId),o=Ue(e.snapshot.segmentTable,n.nameId),s=R(n)&&ie(e,t.terminalNodeId).childIds.length>0,a=t.headNodeId!==t.terminalNodeId,l=e.instrumentation,d=a?l==null?En(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ue(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}}):E(l,"store.getVisibleSlice.flatten.collectSegments",()=>En(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ue(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:d,hasChildren:s,id:t.terminalNodeId,isExpanded:R(n)&&ke(e,t.terminalNodeId,n),isFlattened:a,isLoading:r==="loading",kind:R(n)?"directory":"file",loadState:r==null||r==="loaded"?void 0:r,name:o,path:i}}function Pf(e,t){if(t.headNodeId===t.terminalNodeId)return Ht(e,t.terminalNodeId);let n=En(e,t.headNodeId),r=!1,i=!1;for(let o of n){let s=Ht(e,o);if(s==="loading")return"loading";if(s==="error"){i=!0;continue}if(s==="unloaded")r=!0}if(i)return"error";if(r)return"unloaded";return"loaded"}var Al=8;function Nl(e){let{nodes:t,directories:n,rootId:r,options:i}=e,o=t.length,s=new Int32Array(o),a=new Int32Array(o),l=new Int32Array(o),d=new Int32Array(o),u=new Int32Array(o),f=new Int32Array(o),c=new Int32Array(o);for(let v=0;v<o;v+=1){let I=t[v];if(I==null)continue;s[v]=I.parentId,a[v]=I.nameId,l[v]=I.depthAndFlags,d[v]=I.subtreeNodeCount,u[v]=I.visibleSubtreeCount}let m=0;for(let v of n.values())m+=v.childIds.length;let p=new Int32Array(m),g=0;for(let[v,I]of n){let C=I.childIds;f[v]=g,c[v]=C.length;for(let y=0;y<C.length;y+=1)p[g]=C[y],g+=1}return{nodeCount:o,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:s,nameId:a,depthAndFlags:l,subtreeNodeCount:d,visibleSubtreeCount:u,childStart:f,childCount:c,childIdsFlat:p}}function Ll(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:o,visibleSubtreeCount:s,childStart:a,childCount:l,childIdsFlat:d}=e;for(let p=t-1;p>=1;p-=1){if((i[p]&Al)===0)continue;let g=a[p],v=l[p],I=0,C=0;for(let S=0;S<v;S+=1){let x=d[g+S];I+=o[x],C+=s[x]}o[p]=1+I;let y;if(r&&v===1)y=(i[d[g]]&Al)!==0?C:1+C;else y=1+C;s[p]=y}let u=a[n],f=l[n],c=0,m=0;for(let p=0;p<f;p+=1){let g=d[u+p];c+=o[g],m+=s[g]}o[n]=1+c,s[n]=m}function Rf(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:o}=e.snapshot,s=r.flattenEmptyDirectories===!0,a=(m)=>{let p=n[m];if(p==null||!R(p))return;let g=t.get(m);if(g==null)throw Error(`Unknown directory child index for node ${String(m)}`);let v=g.childIds,I=v.length,C=0,y=0;for(let x=0;x<I;x++){let T=v[x];if(T==null)continue;let O=n[T];C+=O.subtreeNodeCount,y+=O.visibleSubtreeCount}if(g.totalChildSubtreeNodeCount=C,g.totalChildVisibleSubtreeCount=y,I>=128)Ft(n,g);p.subtreeNodeCount=1+C;let S;if(s&&I===1){let x=n[v[0]];S=x!=null&&R(x)?y:1+y}else S=1+y;p.visibleSubtreeCount=S};if(o!=null)for(let m=o.length-1;m>=0;m--)a(o[m]);else for(let m=n.length-1;m>=1;m--)a(m);let l=n[i],d=t.get(i);if(l==null||d==null)return;let u=d.childIds,f=0,c=0;for(let m=0;m<u.length;m++){let p=u[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}d.totalChildSubtreeNodeCount=f,d.totalChildVisibleSubtreeCount=c,Ft(n,d),l.subtreeNodeCount=1+f,l.visibleSubtreeCount=c}function Df(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Nl(e.snapshot);Ll(i);let{subtreeNodeCount:o,visibleSubtreeCount:s}=i;for(let a=0;a<n.length;a+=1){let l=n[a];if(l==null)continue;l.subtreeNodeCount=o[a],l.visibleSubtreeCount=s[a]}for(let[a,l]of t){let d=l.childIds,u=d.length,f=0,c=0;for(let m=0;m<u;m++){let p=d[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}if(l.totalChildSubtreeNodeCount=f,l.totalChildVisibleSubtreeCount=c,a===r||u>=128)Ft(n,l)}}function Mf(e){return e.initialExpansion==="open"&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var hi=class e{#e;constructor(t={}){let n=mr(t),r=E(n,"store.builder.create",()=>new ci(t));if(t.preparedInput!=null){let a=Pa(t.preparedInput);if(a!=null)r.appendPresortedPaths(a,Ra(t.preparedInput));else r.appendPreparedPaths(Ta(t.preparedInput),!1)}else{let a=t.paths??[];if(t.presorted===!0)r.appendPaths(a);else r.appendPreparedPaths(E(n,"store.preparePathEntries",()=>li(a,t)))}let i=E(n,"store.builder.finish",()=>r.finish({skipSubtreeCountPass:!0})),o=E(n,"store.state.detectAllDirectoriesExpanded",()=>(t.initialExpansion??"closed")==="closed"&&r.didMatchAllInitialExpandedPaths());if(this.#e=E(n,"store.state.create",()=>Da(i,o?"open":t.initialExpansion??"closed",n)),o)this.#e.collapseNewDirectoriesByDefault=!0;let s=o?this.#e.snapshot.directories.size-1:E(n,"store.state.initializeExpandedPaths",()=>this.initializeExpandedPaths(t.initialExpandedPaths));if(o||Mf(t)||(t.initialExpansion??"closed")==="closed"&&s===this.#e.snapshot.directories.size-1||(t.initialExpandedPaths?.length??0)>0&&E(n,"store.state.checkAllDirectoriesExpanded",()=>this.hasAllDirectoriesExpanded()))if(t.useSoaCountSweep===!0)E(n,"store.state.initializeOpenVisibleCountsViaSoa",()=>Df(this.#e));else E(n,"store.state.initializeOpenVisibleCounts",()=>Rf(this.#e));else E(n,"store.state.recomputeCounts",()=>yr(this.#e,this.#e.snapshot.rootId))}static preparePaths(t,n={}){return ka(t,n)}static prepareInput(t,n={}){return _a(t,n)}static preparePresortedInput(t){return Ea(t)}list(t){return E(this.#e.instrumentation,"store.list",()=>ui(this.#e,t))}add(t){E(this.#e.instrumentation,"store.add",()=>{let n=_e(this.#e);Xe(this.#e,Le(this.#e,n,So(this.#e,t)))})}remove(t,n={}){E(this.#e.instrumentation,"store.remove",()=>{let r=_e(this.#e);Xe(this.#e,Le(this.#e,r,Co(this.#e,t,n)))})}move(t,n,r={}){E(this.#e.instrumentation,"store.move",()=>{let i=_e(this.#e),o=xo(this.#e,t,n,r);if(o!=null)Xe(this.#e,Le(this.#e,i,o))})}batch(t){rl(this.#e,()=>{if(typeof t==="function"){t(this);return}for(let n of t)switch(n.type){case"add":this.add(n.path);break;case"remove":this.remove(n.path,{recursive:n.recursive});break;case"move":this.move(n.from,n.to,{collision:n.collision});break}})}getVisibleCount(){return E(this.#e.instrumentation,"store.getVisibleCount",()=>_e(this.#e))}getVisibleSlice(t,n){return E(this.#e.instrumentation,"store.getVisibleSlice",()=>_l(this.#e,t,n))}getVisibleRowContext(t){return E(this.#e.instrumentation,"store.getVisibleRowContext",()=>kl(this.#e,t))}getVisibleTreeProjection(){return El(this.#e)}getVisibleTreeProjectionData(t){return Po(this.#e,t)}getVisibleIndex(t){return E(this.#e.instrumentation,"store.getVisibleIndex",()=>Tl(this.#e,t))}getPathInfo(t){return E(this.#e.instrumentation,"store.getPathInfo",()=>{let n=Fe(this.#e,t);if(n==null)return null;let r=D(this.#e,n);return{depth:qe(r),kind:R(r)?"directory":"file",path:te(this.#e,n)}})}isExpanded(t){return E(this.#e.instrumentation,"store.isExpanded",()=>{let n=this.requireDirectoryNodeId(t),r=D(this.#e,n);return ke(this.#e,n,r)})}expand(t){E(this.#e.instrumentation,"store.expand",()=>{let n=_e(this.#e),r=Pl(this.#e,t);if(r!=null)Xe(this.#e,Le(this.#e,n,r))})}collapse(t){E(this.#e.instrumentation,"store.collapse",()=>{let n=_e(this.#e),r=Rl(this.#e,t);if(r!=null)Xe(this.#e,Le(this.#e,n,r))})}on(t,n){return ja(this.#e,t,n)}getDirectoryLoadState(t){let n=this.requireDirectoryNodeId(t);return Ht(this.#e,n)}markDirectoryUnloaded(t){E(this.#e.instrumentation,"store.markDirectoryUnloaded",()=>{let n=this.requireDirectoryNodeId(t);if(ie(this.#e,n).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${t}"`);let r=_e(this.#e);Fa(this.#e,n),Xe(this.#e,Le(this.#e,r,Qa({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],path:t,projectionChanged:this.isDirectoryProjectionVisible(n)})))})}beginChildLoad(t){return E(this.#e.instrumentation,"store.beginChildLoad",()=>{let n=this.requireDirectoryNodeId(t),r=_e(this.#e),i=La(this.#e,n);return Xe(this.#e,Le(this.#e,r,Za({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],attemptId:i.attemptId,path:t,projectionChanged:this.isDirectoryProjectionVisible(n),reused:i.reused}))),i})}applyChildPatch(t,n){return E(this.#e.instrumentation,"store.applyChildPatch",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null||Ht(this.#e,r)!=="loading"||!Ha(this.#e,r,t.attemptId))return!1;let i=te(this.#e,r);this.validateChildPatch(i,n);let o=_e(this.#e),s=[];for(let l of n.operations){Af(i,l);let d=_e(this.#e);switch(l.type){case"add":s.push(Le(this.#e,d,So(this.#e,l.path)));break;case"remove":s.push(Le(this.#e,d,Co(this.#e,l.path,{recursive:l.recursive})));break;case"move":{let u=xo(this.#e,l.from,l.to,{collision:l.collision});if(u!=null)s.push(Le(this.#e,d,u));break}}}let a=s.some((l)=>l.projectionChanged)||this.isDirectoryProjectionVisible(r);return Xe(this.#e,Le(this.#e,o,Ja({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,childEvents:s,path:te(this.#e,r),projectionChanged:a}))),!0})}completeChildLoad(t){return E(this.#e.instrumentation,"store.completeChildLoad",()=>{let n=this.resolveActiveDirectoryNodeId(t.nodeId);if(n==null)return!1;let r=_e(this.#e),i=Ba(this.#e,n,t.attemptId);return Xe(this.#e,Le(this.#e,r,el({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],attemptId:t.attemptId,path:te(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}failChildLoad(t,n){return E(this.#e.instrumentation,"store.failChildLoad",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null)return!1;let i=_e(this.#e),o=Va(this.#e,r,t.attemptId,n);return Xe(this.#e,Le(this.#e,i,tl({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,errorMessage:n,path:te(this.#e,r),projectionChanged:this.isDirectoryProjectionVisible(r),stale:!o}))),o})}cleanup(t={}){return E(this.#e.instrumentation,"store.cleanup",()=>{if(this.#e.transactionStack.length>0)throw Error("Cleanup cannot run during an open batch or transaction.");if(yl(this.#e))throw Error("Cleanup cannot run while directory loads are active.");let n=_e(this.#e),r=bl(this.#e,t.mode??"stable");return Xe(this.#e,Le(this.#e,n,nl({...r,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:r.idsPreserved===!1}))),r})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(t){if(t==null||t.length===0)return 0;let n=0,r=[],i=[],o=0,s=null,a=this.#e.snapshot.segmentTable,l=a.valueById,d=this.#e.snapshot.nodes,u=new Map;for(let f of t){if(s!=null&&f<s)s=null,o=0,r.length=0,i.length=0;let c=f.length>0&&f.charCodeAt(f.length-1)===47?f.length-1:f.length;if(c===0){s=f,o=c,r.length=0,i.length=0;continue}let m=0,p=0;if(s!=null){let y=Math.min(c,o),S=!0;for(let x=0;x<y;x+=1){let T=f.charCodeAt(x);if(T!==s.charCodeAt(x)){S=!1;break}if(T===47)m+=1,p=x+1}if(S){if(y===o&&c>y&&f.charCodeAt(y)===47)m+=1,p=y+1;else if(y===c&&o>y&&s.charCodeAt(y)===47)m+=1,p=c+1}m=Math.min(m,i.length)}let g=m===0?this.#e.snapshot.rootId:i[m-1]??this.#e.snapshot.rootId,v=m,I=!0,C=p;while(C<=c){let y=f.indexOf("/",C),S=y===-1||y>c?c:y,x=f.slice(C,S),T=ie(this.#e,g).childIds,O=v===m?r[v]??0:0,fe=O,Z,pe=u.get(x)??an(x);u.set(x,pe);let J=(K,B)=>{for(fe=K;fe<B;fe+=1){let ae=T[fe],Se=d[ae],z=l[Se.nameId];if(z===x)return Z=ae,!0;let le=gr(vr(a,Se.nameId),pe);if(le>0||le===0&&z>x)return!1}return!1};if(!J(O,T.length)&&O>0)J(0,O);if(Z===void 0){I=!1;break}if(!R(D(this.#e,Z))){I=!1;break}if(r[v]=fe,i[v]=Z,g=Z,v+=1,S===c)break;C=S+1}if(s=f,o=c,r.length=v,i.length=v,!I){s=null,o=0,r.length=0,i.length=0;continue}for(let y=m;y<v;y+=1){let S=i[y];if(S==null)continue;let x=D(this.#e,S);if(ke(this.#e,S,x))continue;Bt(this.#e,S,!0,x),n+=1}}return n}hasAllDirectoriesExpanded(){for(let t of this.#e.snapshot.directories.keys()){if(t===this.#e.snapshot.rootId)continue;let n=D(this.#e,t);if(!ke(this.#e,t,n))return!1}return!0}requireDirectoryNodeId(t){let n=Fe(this.#e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);if(!R(D(this.#e,n)))throw Error(`Path is not a directory: "${t}"`);return n}resolveActiveDirectoryNodeId(t){try{if(!R(D(this.#e,t)))throw Error(`Node is not a directory: ${String(t)}`);return t}catch{return null}}isDirectoryProjectionVisible(t){let n=t;while(n!==this.#e.snapshot.rootId){let r=D(this.#e,n).parentId;if(r!==this.#e.snapshot.rootId){let i=D(this.#e,r),o=Ct(this.#e,r);if(!ke(this.#e,r,i)&&o!==n)return!1}n=r}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Af(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 Nf=[`<symbol id="file-tree-builtin-bash" viewBox="0 0 16 16">
|
|
2
2
|
<path fill="currentColor" d="M8 1C2.24 1 1 2.24 1 8s1.24 7 7 7 7-1.24 7-7-1.24-7-7-7" class="bg" opacity=".2"/>
|
|
3
3
|
<path fill="currentColor" d="M11.5 11a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1zM7 6.75C7 6.42 6.64 6 6 6s-1 .42-1 .75q-.01.25.22.41.26.21.89.35.74.14 1.28.53c.37.29.61.7.61 1.21 0 .87-.68 1.5-1.5 1.7v.55a.5.5 0 0 1-1 0v-.56c-.82-.18-1.5-.82-1.5-1.69a.5.5 0 0 1 1 0c0 .33.36.75 1 .75s1-.42 1-.75q.01-.25-.22-.41a2 2 0 0 0-.89-.35q-.74-.14-1.28-.53A1.5 1.5 0 0 1 4 6.75c0-.87.68-1.5 1.5-1.7V4.5a.5.5 0 0 1 1 0v.56c.82.18 1.5.82 1.5 1.69a.5.5 0 0 1-1 0" class="fg-stroke"/>
|
|
4
4
|
</symbol>`,`<symbol id="file-tree-builtin-c" viewBox="0 0 16 16">
|
|
@@ -58,7 +58,7 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
58
58
|
</symbol>`,`<symbol id="file-tree-builtin-zip" viewBox="0 0 16 16">
|
|
59
59
|
<path fill="currentColor" d="M4.585 2a2 2 0 0 1 1.028.285l1.788 1.072a1 1 0 0 0 .514.143H12A2 2 0 0 1 13.935 5H0V4a2 2 0 0 1 2-2z" class="bg" opacity=".5"/>
|
|
60
60
|
<path fill="currentColor" fill-rule="evenodd" d="M14 12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-1.25h1v-1H0V6h14zM9.9 8.25c-.883 0-1.9.5-1.9.5H7v1h1v1s1.017.5 1.9.5c.884 0 1.6-.672 1.6-1.5s-.716-1.5-1.6-1.5M2 9.75v1h1v-1zm2 0v1h1v-1zm2 0v1h1v-1zm-5-1v1h1v-1zm2 0v1h1v-1zm2 0v1h1v-1z" class="fg" clip-rule="evenodd"/>
|
|
61
|
-
</symbol>`],
|
|
61
|
+
</symbol>`],Lf=[`<symbol id="file-tree-builtin-astro" viewBox="0 0 16 16">
|
|
62
62
|
<path fill="currentColor" d="M6.08 13.92c-.63-.57-.81-1.79-.55-2.67.45.56 1.08.73 1.73.83 1 .15 1.99.1 2.92-.37l.32-.19q.13.38.08.78a2.1 2.1 0 0 1-.9 1.5q-.3.24-.61.43c-.64.44-.81.95-.57 1.69l.02.08a1.7 1.7 0 0 1-.74-.64 2 2 0 0 1-.3-.98q0-.27-.02-.52-.07-.61-.61-.62a.7.7 0 0 0-.75.6z" class="bg" opacity=".6"/>
|
|
63
63
|
<path fill="currentColor" d="M2.5 11.1s1.86-.9 3.72-.9l1.4-4.39c.05-.21.2-.36.38-.36s.33.15.38.36l1.4 4.38c2.2 0 3.72.92 3.72.92l-3.16-8.69q-.13-.4-.45-.42H6.11q-.3.02-.45.42z" class="fg"/>
|
|
64
64
|
</symbol>`,`<symbol id="file-tree-builtin-babel" viewBox="0 0 16 16">
|
|
@@ -147,10 +147,10 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
147
147
|
</symbol>`,`<symbol id="file-tree-builtin-zig" viewBox="0 0 16 16">
|
|
148
148
|
<path fill="currentColor" d="m14.73 1.5-7.29 8.82h4.17l-1.73 2.04H5.76L1.27 14.5l7.3-8.91H4.39l1.73-2.05h4.12z"/>
|
|
149
149
|
<path fill="currentColor" d="M5.21 3.54 3.56 5.6h-.55v4.73h.83L2.1 12.36H1V3.54zm9.79 0v8.82h-4.3l1.74-2.04h.55V5.68h-.83l1.74-2.14z"/>
|
|
150
|
-
</symbol>`];function
|
|
150
|
+
</symbol>`];function Hl(e,t){if(t.length===0)return e;return e.replace("</svg>",`
|
|
151
151
|
${t.join(`
|
|
152
152
|
`)}
|
|
153
|
-
</svg>`)}var
|
|
153
|
+
</svg>`)}var Fl=Hl(`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
154
154
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
155
155
|
<path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
|
|
156
156
|
</symbol>
|
|
@@ -167,7 +167,7 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
167
167
|
<symbol id="file-tree-icon-ellipsis" viewBox="0 0 16 16">
|
|
168
168
|
<path d="M5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M9.5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M14 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0" />
|
|
169
169
|
</symbol>
|
|
170
|
-
</svg>`,
|
|
170
|
+
</svg>`,Nf),Ff={minimal:`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
171
171
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
172
172
|
<path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
|
|
173
173
|
</symbol>
|
|
@@ -184,7 +184,7 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
184
184
|
<symbol id="file-tree-icon-ellipsis" viewBox="0 0 16 16">
|
|
185
185
|
<path d="M5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M9.5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M14 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0" />
|
|
186
186
|
</symbol>
|
|
187
|
-
</svg>`,standard:
|
|
187
|
+
</svg>`,standard:Fl,complete:Hl(Fl,Lf)},Bf={".babelrc":"babel",".babelrc.json":"babel",".bash_profile":"bash",".bashrc":"bash",".browserslistrc":"browserslist",".dockerignore":"docker",".eslintignore":"eslint",".eslintrc":"eslint",".eslintrc.cjs":"eslint",".eslintrc.js":"eslint",".eslintrc.json":"eslint",".eslintrc.yaml":"eslint",".eslintrc.yml":"eslint",".gitattributes":"git",".gitignore":"git",".gitkeep":"git",".gitmodules":"git",".oxlintrc.json":"oxc",".postcssrc":"postcss",".postcssrc.json":"postcss",".postcssrc.yaml":"postcss",".postcssrc.yml":"postcss",".prettierignore":"prettier",".prettierrc":"prettier",".prettierrc.cjs":"prettier",".prettierrc.js":"prettier",".prettierrc.json":"prettier",".prettierrc.mjs":"prettier",".prettierrc.toml":"prettier",".prettierrc.yaml":"prettier",".prettierrc.yml":"prettier",".stylelintignore":"stylelint",".stylelintrc":"stylelint",".stylelintrc.cjs":"stylelint",".stylelintrc.js":"stylelint",".stylelintrc.json":"stylelint",".stylelintrc.mjs":"stylelint",".stylelintrc.yaml":"stylelint",".stylelintrc.yml":"stylelint",".terraform.lock.hcl":"terraform",".zprofile":"bash",".zshenv":"bash",".zshrc":"bash","babel.config.cjs":"babel","babel.config.js":"babel","babel.config.json":"babel","babel.config.mjs":"babel","biome.json":"biome","biome.jsonc":"biome","bootstrap.bundle.js":"bootstrap","bootstrap.bundle.min.js":"bootstrap","bootstrap.css":"bootstrap","bootstrap.js":"bootstrap","bootstrap.min.css":"bootstrap","bootstrap.min.js":"bootstrap","bun.lock":"bun","bun.lockb":"bun","bunfig.toml":"bun","claude.md":"claude","compose.yaml":"docker","compose.yml":"docker","docker-compose.override.yml":"docker","docker-compose.yaml":"docker","docker-compose.yml":"docker",dockerfile:"docker","eslint.config.cjs":"eslint","eslint.config.js":"eslint","eslint.config.mjs":"eslint","eslint.config.mts":"eslint","eslint.config.ts":"eslint",gemfile:"ruby","next.config.js":"nextjs","next.config.mjs":"nextjs","next.config.mts":"nextjs","next.config.ts":"nextjs","postcss.config.cjs":"postcss","postcss.config.js":"postcss","postcss.config.mjs":"postcss","postcss.config.ts":"postcss","prettier.config.cjs":"prettier","prettier.config.js":"prettier","prettier.config.mjs":"prettier",rakefile:"ruby","readme.md":"markdown","stylelint.config.cjs":"stylelint","stylelint.config.js":"stylelint","stylelint.config.mjs":"stylelint","svgo.config.cjs":"svgo","svgo.config.js":"svgo","svgo.config.mjs":"svgo","svgo.config.ts":"svgo","tailwind.config.cjs":"tailwind","tailwind.config.js":"tailwind","tailwind.config.mjs":"tailwind","tailwind.config.ts":"tailwind","vite.config.js":"vite","vite.config.mjs":"vite","vite.config.mts":"vite","vite.config.ts":"vite","webpack.config.babel.js":"webpack","webpack.config.cjs":"webpack","webpack.config.js":"webpack","webpack.config.mjs":"webpack","webpack.config.ts":"webpack"},Hf={"7z":"zip",astro:"astro",AUTHORS:"text",avif:"image",bash:"bash",bmp:"image",bz2:"zip",c:"c",cc:"cpp",cfg:"text",CHANGELOG:"text",cjs:"javascript","code-workspace":"vscode",conf:"text",CONTRIBUTORS:"text",cpp:"cpp",csh:"bash",css:"css",csv:"table",cts:"typescript",cxx:"cpp",db:"database",editorconfig:"text",env:"text","env.development":"text","env.local":"text","env.production":"text",eot:"font",erb:"ruby",fish:"bash",gemspec:"ruby",gif:"image",go:"go",gql:"graphql",graphql:"graphql",gz:"zip",h:"c",hh:"cpp",hpp:"cpp",htm:"html",html:"html",hxx:"cpp",icns:"image",ico:"image",ini:"text",inl:"cpp",jar:"zip",jpeg:"image",jpg:"image",js:"javascript",json:"json",json5:"json",jsonc:"json",jsonl:"json",jsx:"javascript",ksh:"bash",less:"css",LICENSE:"text",log:"text",markdown:"markdown",mcp:"mcp",md:"markdown",mdx:"markdown","mdx.tsx":"markdown",mjs:"javascript",mm:"cpp",mts:"typescript",ods:"table",otf:"font",png:"image",postcss:"css",py:"python",pyi:"python",pyw:"python",pyx:"python",rake:"ruby",rar:"zip",rb:"ruby",rs:"rust",rst:"text",rtf:"text",sass:"css",scss:"css",sh:"bash",sql:"database",sqlite:"database",sqlite3:"database",styl:"css",svelte:"svelte",svg:"svg",swift:"swift",tar:"zip",tf:"terraform",tfstate:"terraform",tfvars:"terraform",tgz:"zip",tif:"image",tiff:"image",ts:"typescript",tsv:"table",tsx:"typescript",ttf:"font",txt:"text",vue:"vue",war:"zip",wasm:"wasm",wast:"wasm",wat:"wasm",webp:"image",woff:"font",woff2:"font",xhtml:"html",xls:"table",xlsx:"table",xz:"zip",yaml:"yml",yml:"yml",zig:"zig",zip:"zip",zsh:"bash"},Vf={jsx:"react",sass:"sass",scss:"sass",tsx:"react"},Bl=new Set(["bash","c","cpp","css","database","default","font","git","go","html","image","javascript","json","markdown","mcp","python","ruby","rust","swift","table","text","typescript","zip"]),Of=new Set(["complete"]);function Vl(e){return Ff[e==="none"?"minimal":e]}function Ol(e){return`file-tree-builtin-${e}`}function ql(e){return e!=="none"&&Of.has(e)}function zl(e,t,n){if(e==="minimal"||e==="none")return;let r=e==="complete",i=Bf[t.toLowerCase()];if(i!=null){if(r||Bl.has(i))return i}for(let o of n){if(r){let a=Vf[o];if(a!=null)return a}let s=Hf[o];if(s!=null){if(r||Bl.has(s))return s}}return"default"}var Ro="file-tree-container",fi="data-file-tree-style",Do="data-file-tree-unsafe-css",Wl="data-file-tree-scrollbar-measure",Mo="data-file-tree-scrollbar-gutter-measured",$l="--trees-scrollbar-gutter-measured";var wr="header",Ir="context-menu",jl="context-menu-trigger";function qf(e){return e.spriteSheet!=null||e.remap!=null||e.byFileName!=null||e.byFileExtension!=null||e.byFileNameContains!=null}function Pn(e){if(e==null)return{set:"complete",colored:!0};if(typeof e==="string")return{set:e,colored:!0};return{...e,set:e.set??(qf(e)?"none":"complete"),colored:e.colored??!0}}var pi={compact:{itemHeight:24,factor:0.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Ul(e,t){if(typeof e==="number")return{itemHeight:t??pi.default.itemHeight,factor:e};let n=pi[e??"default"];return{itemHeight:t??n.itemHeight,factor:n.factor}}var mi=pi.default.itemHeight;var Ao=`@layer base {
|
|
188
188
|
:host {
|
|
189
189
|
--trees-accent: var(--trees-accent-override, #009fff);
|
|
190
190
|
--trees-fg: var(--trees-fg-override, var(--trees-theme-sidebar-fg, light-dark(#6c6c71, #adadb1)));
|
|
@@ -1276,16 +1276,16 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
1276
1276
|
}
|
|
1277
1277
|
|
|
1278
1278
|
@layer theme, unsafe;
|
|
1279
|
-
`;function
|
|
1279
|
+
`;function gi(e){return`@layer base, unsafe;
|
|
1280
1280
|
@layer base {
|
|
1281
1281
|
${e}
|
|
1282
|
-
}`}function
|
|
1282
|
+
}`}function Kl(e){return`@layer base, unsafe;
|
|
1283
1283
|
@layer unsafe {
|
|
1284
1284
|
${e}
|
|
1285
|
-
}`}var Kl=new WeakMap;function qf(e){let t=Kl.get(e);if(t!=null)return t;let n=document.createElement("div");n.setAttribute(zl,"true");let r=document.createElement("div");r.style.position="relative",r.style.height="200%",n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),Kl.set(e,i),i}function Gl(e,t){if(!e.isConnected)return;let n=qf(t);if(n==null)return;let r=t.querySelector(`style[${Do}]`),i=r instanceof HTMLStyleElement?r:document.createElement("style");if(!(r instanceof HTMLStyleElement))i.setAttribute(Do,""),t.appendChild(i);i.textContent=`:host { ${Wl}: ${n}px; }`}var gi;function zf(e){if(typeof CSSStyleSheet<"u"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in e){if(gi==null)gi=new CSSStyleSheet,gi.replaceSync(mi(Mo));let t=!1;try{e.adoptedStyleSheets=[gi],t=!0}catch{}if(t){e.querySelector(`style[${hi}]`)?.remove();return}}if(e.querySelector("style[data-file-tree-style]")==null){let t=document.createElement("style");t.setAttribute(hi,""),t.textContent=mi(Mo),e.prepend(t)}}function vi(e,t){Wf(e,t),zf(t),Gl(e,t)}function Wf(e,t){let n=e.querySelector('template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]');if(!(n instanceof HTMLTemplateElement))return;if(t.childNodes.length>0)return;if(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute("shadowrootmode"))n.remove()}if(typeof HTMLElement<"u"&&customElements.get("file-tree-container")==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let t=this.shadowRoot??this.attachShadow({mode:"open"});vi(this,t)}}if(customElements.define(Po,e),typeof document<"u")for(let t of Array.from(document.querySelectorAll(Po))){if(!(t instanceof HTMLElement))continue;vi(t,t.shadowRoot??t.attachShadow({mode:"open"}))}}var Yl=(e)=>e.startsWith("f::")?e.slice(3):e;function $f(e){let t=e.lastIndexOf("/");if(t<0)return{parentPath:"",baseName:e};return{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function jf(e,t){return e===""?t:`${e}/${t}`}function Xl({files:e,path:t,isFolder:n,nextBasename:r}){let i=Yl(t),o=r.trim();if(o.length===0)return{error:"Name cannot be empty."};if(o.includes("/"))return{error:'Name cannot include "/".'};let{parentPath:s,baseName:a}=$f(i);if(o===a)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let l=jf(s,o),d=Array(e.length),u=new Set;if(!n){let p=`${l}/`,g=!1;for(let v=0;v<e.length;v++){let I=e[v];if(I!==i&&I.startsWith(p))return{error:`"${l}" already exists.`};let C=I===i?l:I;if(u.has(C))return{error:`"${l}" already exists.`};if(u.add(C),d[v]=C,I===i)g=!0}if(!g)return{error:"Could not find the selected file to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}let f=`${i}/`,c=`${l}/`,m=0;for(let p=0;p<e.length;p++){let g=e[p],v=g===i||g.startsWith(f);if(!v&&(g===l||g.startsWith(c)))return{error:`"${l}" already exists.`};let I=v?`${l}${g.slice(i.length)}`:g;if(u.has(I))return{error:`"${l}" already exists.`};if(u.add(I),d[p]=I,v)m++}if(m===0)return{error:"Could not find the selected folder to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}function Uf(e){return e.endsWith("/")}function Kf(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/"),r=n<0?t:t.slice(n+1);return e.endsWith("/")?`${r}/`:r}function Gf(e){let t=[],n=new Set;for(let i of e){if(n.has(i))continue;n.add(i),t.push(i)}let r=new Set;for(let i of t.toSorted((o,s)=>{if(o.length!==s.length)return o.length-s.length;return o.localeCompare(s)})){let o=(i.endsWith("/")?i.slice(0,-1):i).split("/"),s=!1;for(let a=0;a<o.length-1;a+=1){let l=`${o.slice(0,a+1).join("/")}/`;if(!r.has(l))continue;s=!0;break}if(s)continue;r.add(i)}return t.filter((i)=>r.has(i))}function Ql(e,t){return t.includes(e)?Gf(t):[e]}function Zl(e,t){if(e===t)return!0;if(e==null||t==null)return!1;return e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function Ao(e,t){return{draggedPaths:e,target:t}}function No(e,t){if(t.kind!=="directory"||t.directoryPath==null)return!1;for(let n of e){if(!Uf(n))continue;if(t.directoryPath===n||t.directoryPath.startsWith(n))return!0}return!1}function Yf(e,t){if(t.kind==="root"||t.directoryPath==null)return Kf(e);return t.directoryPath}function Jl(e,t){let n=e.map((r)=>{let i=Yf(r,t);if(i===r)return null;return{from:r,to:i,type:"move"}}).filter((r)=>r!=null);if(n.length===0)return null;return{operations:n,result:{draggedPaths:e,operation:n.length===1?"move":"batch",target:t}}}function Xf(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Lo(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error("FileTree requires paths or preparedInput");return{paths:r,preparedInput:void 0}}let o=i.paths;if(r==null)return{paths:o,preparedInput:i};if(!Xf(di.preparePaths(r,n==null?{}:{sort:n}),o))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:o,preparedInput:i}}function Fo(e){return e.operation==="add"||e.operation==="remove"||e.operation==="move"||e.operation==="batch"}function Qf(e,t,n){if(e===t)return n;let r=t.endsWith("/")?t:`${t}/`;if(!e.startsWith(r))return e;return`${n.endsWith("/")?n:`${n}/`}${e.slice(r.length)}`}function Zf(e,t){if(e===t)return!0;let n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)}function Pn(e,t,n=!1){if(e==null)return null;switch(t.operation){case"add":case"expand":case"collapse":case"mark-directory-unloaded":case"begin-child-load":case"apply-child-patch":case"complete-child-load":case"fail-child-load":case"cleanup":return e;case"remove":return Zf(e,t.path)?n?e:null:e;case"move":return Qf(e,t.from,t.to);case"batch":{let r=e;for(let i of t.events)if(r=Pn(r,i,n),r==null)return null;return r}}}function yi(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function ec(e){switch(e.operation){case"add":return{...yi(e),operation:"add",path:e.path};case"remove":return{...yi(e),operation:"remove",path:e.path,recursive:e.recursive};case"move":return{...yi(e),from:e.from,operation:"move",to:e.to}}}function Jf(e){return{...yi(e),events:e.events.filter((t)=>t.operation==="add"||t.operation==="remove"||t.operation==="move").map((t)=>ec(t)),operation:"batch"}}function tc(e){switch(e.operation){case"add":case"remove":case"move":return ec(e);case"batch":return Jf(e);default:return null}}function bi(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function kt(e){let t=e.endsWith("/")?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split("/");return n.slice(0,-1).map((r,i)=>`${n.slice(0,i+1).join("/")}/`)}function wi(e){return kt(e).at(-1)??null}function Bo(e,t){if(t==null)return e;return e.startsWith(t)?e.slice(t.length):e}function Ir(e){return e.endsWith("/")}var Ho=(e)=>e.toLowerCase();function nc(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n<0?t:t.slice(n+1)}function Vo(e){return e.endsWith("/")?e.slice(0,-1):e}function Oo(e,t){return t&&!e.endsWith("/")?`${e}/`:e}var rc=(e)=>{let t=e.trim();if(t.length===0)return"";return(t.includes("\\")?t.replaceAll("\\","/"):t).toLowerCase()};var qo=Symbol("FILE_TREE_RENAME_VIEW"),ep=512,tp=512;function np(e){return e==="top"||e==="center"?e:"nearest"}function rp(e,t,n){if(e===0)return-1;if(n!=null){let r=t(n);if(r!=null)return r;let i=kt(n);for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s==null)continue;let a=t(s);if(a!=null)return a}}return 0}function ip(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??((i)=>e.visibleIndexByPath.get(i)??null);return{focusedIndex:rp(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var ic=class e{static{Object.defineProperty(e.prototype,qo,{configurable:!0,value(){return{cancel:()=>{this.#_e()},commit:()=>{this.#Ee()},getPath:()=>this.#s,getValue:()=>this.#g,isActive:()=>this.#s!=null,setValue:(t)=>{this.#Te(t)}}},writable:!0})}#e;#t=new Set;#c=new Map;#u=null;#a=null;#V=new Map;#O=new Map;#v=-1;#r=null;#y=!1;#T=(t)=>-1;#b=new Map;#m=null;#h=null;#w=null;#I=null;#f=null;#q;#z;#N;#i=[];#W=new Int32Array(0);#$=new Int32Array(0);#Z=void 0;#P=!1;#s=null;#g="";#R=!1;#k=new Set;#j=[];#U;#K=null;#l=null;#L=null;#M=null;#x=null;#F=null;#J=null;#ke=0;#S=null;#o=new Set;#G=0;#n;#ne=0;#re=!1;#p=0;#Y;constructor(t){let{dragAndDrop:n,fileTreeSearchMode:r,initialSearchQuery:i,initialSelectedPaths:o,renaming:s,onSearchChange:a,paths:l,preparedInput:d,...u}=t,f=Lo({paths:l,preparedInput:d},"constructor",u.sort);if(this.#e=u,n!=null&&n!==!1)this.#u=n===!0?{}:n;if(this.#P=s!=null&&s!==!1,s!=null&&s!==!1&&s!==!0)this.#Z=s.canRename,this.#z=s.onError,this.#q=s.onRename;this.#N=a,this.#U=r??"hide-non-matches",this.#n=this.#oe(f.paths,f.preparedInput);let c=o?.map((p)=>this.#A(p)).filter((p)=>p!=null)??[],m=c.at(-1)??null;if(c.length>0)this.#o=new Set(c),this.#S=m,this.#G=1;if(this.#H(m,!1),i!=null)this.#X(i,!1);this.#Y=this.#Ce()}destroy(){this.#Y?.(),this.#Y=null,this.#c.clear(),this.#t.clear(),this.#b.clear(),this.#a=null,this.#ae()}focusFirstItem(){if(this.#_().length>0)this.#E(0)}focusLastItem(){if(this.#p<=0)return;this.#D(),this.#E(this.#p-1)}focusNextItem(){this.#Se(1)}focusParentItem(){if(this.#r==null)return;let t=wi(this.#r);if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n)}focusPath(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;this.#D();let r=this.#B(n);if(r>=0)this.#E(r)}scrollToPath(t,n){let r=this.#n.getPathInfo(t)?.path??null;if(r==null)return;this.#D();let i=this.#He(r);if(i<0)return;if(this.#le(i)==null)return;if(n?.focus!==!1)this.#E(i,!1);this.#J={id:this.#ke+=1,offset:np(n?.offset),visibleIndex:i},this.#d()}focusMountedPathFromInput(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;let r=this.#B(n);if(r>=0)this.#E(r)}focusNearestPath(t){let n=this.resolveNearestVisiblePath(t);if(n==null)return null;let r=this.#B(n);if(r>=0)return this.#E(r),this.#_()[r]??n;return null}focusPreviousItem(){this.#Se(-1)}getFocusedIndex(){return this.#v}getFocusedItem(){return this.#r==null?null:this.#ce(this.#r)}getFocusedPath(){return this.#r}getScrollRequest(){return this.#J}clearScrollRequest(t){if(this.#J?.id===t)this.#J=null}resolveNearestVisiblePath(t){let n=this.#_();if(this.#p===0)return null;if(t==null)return this.#r??n[0]??null;let r=this.#n.getPathInfo(t)?.path??t,i=this.#B(r);if(i>=0)return n[i]??r;let o=this.#Pe(r);if(o!=null)return o;return this.#r??n[0]??null}getSelectedPaths(){return[...this.#o]}getSelectionVersion(){return this.#G}getVisibleCount(){return this.#p}getVisibleRows(t,n){if(n<t||this.#p===0)return[];let r=Math.max(0,t),i=Math.min(this.#p-1,n);if(i<r)return[];let o=i-r+1;if(this.#x==null&&!this.#y&&i>=this.#i.length&&o<=tp){let s=[];for(let a=r;a<=i;a+=1){let l=this.#n.getVisibleRowContext(a);if(l==null)break;s.push(this.#ue(l))}return s}if(!this.#y&&i>=this.#i.length)this.#D();if(this.#x!=null){let s=Array.from({length:i-r+1},(u,f)=>this.#ve(r+f)),a=new Map,l=s[0]??-1,d=l;for(let u=1;u<=s.length;u+=1){let f=s[u];if(f!=null&&f===d+1){d=f;continue}if(l>=0)this.#n.getVisibleSlice(l,d).forEach((c,m)=>{a.set(l+m,c)});if(f==null){l=-1,d=-1;continue}l=f,d=f}return Array.from({length:i-r+1},(u,f)=>{let c=r+f,m=this.#ve(c),p=a.get(m),g=this.#i[m];if(p==null||g==null)throw Error(`Missing projection row for filtered visible index ${String(c)}`);return this.#ie(p,c,m,{ancestorPaths:this.#fe(m),path:g})})}return this.#n.getVisibleSlice(r,i).map((s,a)=>{let l=r+a,d=this.#i[l];if(d==null)throw Error(`Missing projection path for visible index ${String(l)}`);return this.#ie(s,l,l,{ancestorPaths:this.#fe(l),path:d})})}getStickyRowCandidates(t,n){if(this.#x!=null)return null;if(this.#p===0||t<=0||n<=0)return[];let r=[];for(let i=0;i<this.#p;i+=1){let o=t+i*n,s=Math.min(this.#p-1,Math.floor(o/n)),a=this.#de(s,i)??(s>0?this.#de(s-1,i):void 0);if(a==null)break;r.push({row:this.#ue(a),subtreeEndIndex:a.subtreeEndIndex})}return r}getItem(t){let n=this.#n.getPathInfo(t);return n==null?null:this.#ce(n.path,n)}resolveMountedDirectoryPathFromInput(t){let n=this.#n.getPathInfo(t);return n?.kind==="directory"?n.path:null}toggleMountedDirectoryFromInput(t){let n=this.resolveMountedDirectoryPathFromInput(t);if(n==null)return;this.#xe(n)}selectAllVisiblePaths(){this.#D();let t=[...this.#_()];this.#C(t,this.#r??this.#S)}selectOnlyPath(t){let n=this.#A(t);if(n==null)return;this.#C([n],n)}selectOnlyMountedPathFromInput(t){this.#C([t],t)}selectPath(t){let n=this.#A(t);if(n==null||this.#o.has(n))return;this.#C([...this.#o,n])}deselectPath(t){let n=this.#A(t);if(n==null||!this.#o.has(n))return;this.#C([...this.#o].filter((r)=>r!==n))}toggleFocusedSelection(){if(this.#r==null)return;this.togglePathSelectionFromInput(this.#r)}togglePathSelection(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.deselectPath(n);return}this.selectPath(n)}togglePathSelectionFromInput(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.#C([...this.#o].filter((r)=>r!==n),n);return}this.#C([...this.#o,n],n)}selectPathRange(t,n){let r=this.#A(t);if(r==null)return;this.#D();let i=this.#S,o=i==null?-1:this.#te(i),s=this.#te(r);if(o===-1||s===-1){let f=n?[...this.#o,r]:[r];this.#C(f,r);return}let[a,l]=o<=s?[o,s]:[s,o],d=this.#_().slice(a,l+1),u=n?[...this.#o,...d]:d;this.#C(u,i)}extendSelectionFromFocused(t){if(this.#r==null)return;let n=this.#v;if(n===-1)return;let r=Math.min(this.#p-1,Math.max(0,n+t));if(r===n)return;if(!this.#y&&r>=this.#i.length)this.#D();let i=this.#_(),o=i[n]??null,s=i[r]??null;if(o==null||s==null)return;let a=new Set(this.#o);if(a.has(o)&&a.has(s))a.delete(o);else a.add(s);this.#C([...a],this.#S??o,!1),this.#E(r)}getDragAndDropConfig(){return this.#u}isDragAndDropEnabled(){return this.#u!=null}getDragSession(){if(this.#a==null)return null;return{draggedPaths:[...this.#a.draggedPaths],primaryPath:this.#a.primaryPath,target:this.#a.target==null?null:{...this.#a.target}}}startDrag(t){if(this.#u==null)return!1;let n=this.#A(t);if(n==null)return!1;if(this.#l!=null&&this.#l.length>0)return!1;let r=this.getSelectedPaths(),i=Ql(n,r);if(this.#u.canDrag?.(i)===!1)return!1;if(!r.includes(n))this.#C([n],n,!1);return this.#Q(n),this.#a={draggedPaths:i,primaryPath:n,target:null},this.#d(),!0}setDragTarget(t){let n=this.#a;if(n==null)return;let r=t;if(r!=null){let i=Ao(n.draggedPaths,r);if(No(n.draggedPaths,r)||this.#u?.canDrop?.(i)===!1)r=null}if(Zl(n.target,r))return;this.#a={...n,target:r},this.#d()}cancelDrag(){if(this.#a==null)return;this.#a=null,this.#d()}completeDrag(){let t=this.#a;if(t==null)return!1;this.#a=null;let n=t.target==null?null:{...t.target};if(n==null)return this.#d(),!1;let r=Ao(t.draggedPaths,n);if(No(t.draggedPaths,n)||this.#u?.canDrop?.(r)===!1)return this.#d(),!1;let i=Jl(t.draggedPaths,n);if(i==null)return this.#d(),!1;try{if(i.operations.length===1){let o=i.operations[0];if(o==null||o.type!=="move")throw Error("Expected a single move operation for one-item drops");this.#n.move(o.from,o.to,{collision:o.collision})}else this.#Me(i.operations),this.#n.batch(i.operations)}catch(o){return this.#d(),this.#u?.onDropError?.(o instanceof Error?o.message:String(o),r),!1}return this.#u?.onDropComplete?.(i.result),!0}subscribe(t){return this.#t.add(t),t(),()=>{this.#t.delete(t)}}add(t){this.#n.add(t)}remove(t,n={}){this.#n.remove(t,n)}move(t,n,r={}){this.#n.move(t,n,r)}batch(t){this.#n.batch(t)}onMutation(t,n){let r=t,i=n,o=this.#c.get(r);if(o==null)o=new Set,this.#c.set(r,o);return o.add(i),()=>{let s=this.#c.get(r);if(s?.delete(i),s?.size===0)this.#c.delete(r)}}setSearch(t){this.#X(t,!0)}openSearch(t=""){this.#X(t,!0)}closeSearch(){this.#X(null,!0)}isSearchOpen(){return this.#l!==null}getSearchValue(){return this.#l??""}getSearchMatchingPaths(){return this.#j}focusNextSearchMatch(){this.#ye(1)}focusPreviousSearchMatch(){this.#ye(-1)}startRenaming(t=this.#r??"",n={}){if(!this.#P)return!1;let r=this.#n.getPathInfo(t);if(r==null)return!1;let i=r.path,o=Ir(i),s=Vo(i);if(this.#Z?.({isFolder:o,path:s})===!1)return!1;for(let a of kt(i))if(!this.#n.isExpanded(a))this.#n.expand(a);if(this.#C([i],i,!1),this.#l!=null)this.#X(null,!1),this.#N?.(this.#l);return this.#Q(i),this.#s=i,this.#g=nc(i),this.#R=n.removeIfCanceled??!1,this.#d(),!0}#_e(){if(this.#s==null)return;let t=this.#s,n=this.#R;if(this.#s=null,this.#g="",this.#R=!1,n){this.remove(t,Ir(t)?{recursive:!0}:void 0);return}this.#Q(t),this.#d()}#Ee(){let t=this.#s;if(t==null)return;if(this.#R&&this.#g.trim().length===0){this.#s=null,this.#g="",this.#R=!1,this.remove(t,Ir(t)?{recursive:!0}:void 0);return}let n=Ir(t),r=Xl({files:this.#n.list(),isFolder:n,nextBasename:this.#g,path:Vo(t)});if(this.#s=null,this.#g="",this.#R=!1,"error"in r){this.#Q(t),this.#z?.(r.error),this.#d();return}if(r.sourcePath===r.destinationPath){this.#Q(t),this.#d();return}this.#q?.({destinationPath:r.destinationPath,isFolder:r.isFolder,sourcePath:r.sourcePath}),this.move(Oo(r.sourcePath,n),Oo(r.destinationPath,n))}#Te(t){if(this.#s==null||this.#g===t)return;this.#g=t,this.#d()}resetPaths(t,n={}){let r=!Array.isArray(t),i=r?void 0:t,o=r?t:n,s=this.#n.list().length,a=this.#p,l=Lo({paths:i,preparedInput:o.preparedInput},"resetPaths",this.#e.sort),d=this.#oe(l.paths,l.preparedInput,o.initialExpandedPaths),u=this.#r,f=this.#s,c=this.getSelectedPaths(),m=this.#S;this.#Y?.(),this.#n=d,this.#b.clear(),this.#ae();let p=c.map((v)=>d.getPathInfo(v)?.path??null).filter((v)=>v!=null),g=!bi(this.#o,p);if(this.#o=new Set(p),g)this.#G+=1;if(this.#S=m==null?null:d.getPathInfo(m)?.path??null,this.#s=f==null?null:d.getPathInfo(f)?.path??null,this.#s==null)this.#g="",this.#R=!1;this.#H(u,u!=null||p.length>0||this.#S!=null),this.#Y=this.#Ce(),this.#d(),this.#we({canonicalChanged:!0,operation:"reset",pathCountAfter:l.paths.length,pathCountBefore:s,projectionChanged:!0,usedPreparedInput:o.preparedInput!=null,visibleCountDelta:this.#p-a})}#Pe(t){this.#D();let n=wi(t),r=Bo(t,n),i=null,o=null;for(let s of this.#_()){if(wi(s)!==n)continue;let a=Bo(s,n);if(a<r){i=s;continue}if(a>r){o=s;break}}return i??o}#B(t){let n=this.#te(t);if(n!==-1)return n;let r=kt(t);for(let i=r.length-1;i>=0;i-=1){let o=r[i];if(o==null)continue;let s=this.#te(o);if(s!==-1)return s}return this.#_().length>0?0:-1}#ce(t,n){let r=this.#b.get(t);if(r!=null)return r;let i=n??this.#n.getPathInfo(t);if(i==null)return null;let o=i.kind==="directory"?this.#Re(i.path):this.#De(i.path);return this.#b.set(i.path,o),o}#ie(t,n,r,i){return{ancestorPaths:i.ancestorPaths,depth:t.depth,flattenedSegments:t.flattenedSegments?.map((o)=>({isTerminal:o.isTerminal,name:o.name,path:o.path})),hasChildren:t.hasChildren,index:n,isExpanded:t.isExpanded,isFlattened:t.isFlattened,isFocused:i.path===this.#r,isSelected:this.#o.has(i.path),kind:t.kind,level:t.depth,name:t.name,path:i.path,posInSet:i.posInSet??this.#W[r]??0,setSize:i.setSize??this.#$[r]??0}}#ue(t){return this.#ie(t.row,t.index,t.index,{ancestorPaths:t.ancestorPaths,path:t.row.path,posInSet:t.posInSet,setSize:t.setSize})}#de(t,n){let r=this.#n.getVisibleRowContext(t);if(r==null)return;let i=r.ancestorRows[n];if(i!=null)return i;return n===r.ancestorRows.length&&r.row.kind==="directory"&&r.row.isExpanded?r:void 0}#he(t){let n=this.#V.get(t);if(n!=null)return n;let r=this.#T(t),i=r<0?[]:[...this.#he(r),r];return this.#V.set(t,i),i}#fe(t){let n=this.#O.get(t);if(n!=null)return n;let r=this.#he(t).map((i)=>this.#i[i]??"").filter((i)=>i!=="");return this.#O.set(t,r),r}#pe(t){this.#n.collapse(t)}#C(t,n=this.#S,r=!0){let i=[...new Set(t)],o=!bi(this.#o,i),s=this.#S!==n;if(!o&&!s)return;if(this.#o=new Set(i),this.#S=n,o)this.#G+=1;if(r)this.#d()}#Re(t){return{collapse:()=>{this.#pe(t)},deselect:()=>{this.deselectPath(t)},expand:()=>{this.#Ie(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!0,isExpanded:()=>this.#n.isExpanded(t),isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)},toggle:()=>{this.#xe(t)}}}#De(t){return{deselect:()=>{this.deselectPath(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!1,isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)}}}#Me(t){let n=this.#n.list();this.#oe(n).batch(t)}#oe(t,n,r){return new di({...this.#e,paths:t,preparedInput:n==null?void 0:n,...r!==void 0?{initialExpandedPaths:r}:{}})}#se(){if(this.#I!=null)return this.#I;return this.#I=this.#n.list(),this.#I}#Ae(){if(this.#w!=null)return this.#w;let t=new Set;for(let n of this.#se()){t.add(n);for(let r of kt(n))t.add(r)}return this.#w=[...t].sort(),this.#w}#Ne(){if(this.#f!=null)return this.#f;return this.#f=this.#se().map(Ho),this.#f}#ee(){if(this.#m!=null)return this.#m;return this.#m=this.#Ae().filter((t)=>t.endsWith("/")),this.#m}#Le(){if(this.#h!=null)return this.#h;return this.#h=this.#ee().map(Ho),this.#h}#ae(){this.#m=null,this.#h=null,this.#w=null,this.#I=null,this.#f=null}#Fe(){return this.#ee().filter((t)=>this.#n.isExpanded(t))}#me(t){let n=new Set(this.#K??[]);if(t)for(let r of this.#o)for(let i of kt(r))n.add(i);this.#ge(n)}#ge(t){this.#re=!0;try{for(let n of this.#ee()){let r=t.has(n),i=this.#n.isExpanded(n);if(r&&!i)this.#n.expand(n);else if(!r&&i)this.#n.collapse(n)}}finally{this.#re=!1}}#Be(){if(this.#l==null||this.#l.length===0){this.#j=[],this.#x=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let t=this.#i;if(this.#j=t.filter((o)=>this.#k.has(o)),this.#U!=="hide-non-matches"||this.#k.size===0){this.#x=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let n=[],r=[],i=new Map;for(let[o,s]of t.entries()){if(this.#L?.has(s)!==!0)continue;i.set(s,r.length),n.push(o),r.push(s)}this.#x=n,this.#F=r,this.#M=i,this.#p=r.length}#_(){return this.#F??this.#i}#He(t){if(this.#F!=null)return this.#M?.get(t)??-1;return this.#n.getVisibleIndex(t)??-1}#ve(t){return this.#x?.[t]??t}#te(t){let n=this.#M?.get(t);if(n!=null)return n;return this.#n.getVisibleIndex(t)??-1}#ye(t){let n=this.#j;if(n.length===0)return;let r=this.#r,i=r==null?-1:n.indexOf(r),o=n[i<0?t>0?0:n.length-1:Math.min(n.length-1,Math.max(0,i+t))];if(o!=null)this.focusPath(o)}#X(t,n){let r=t==null?null:rc(t),i=this.#l;if(i===r)return;if(i==null&&r!=null)this.#K=this.#Fe();if(this.#l=r,r==null)this.#me(!0),this.#K=null,this.#k.clear(),this.#L=null,this.#H(this.#r,!0);else if(r.length===0)this.#me(!1),this.#k.clear(),this.#L=null,this.#H(this.#r,!0);else{let o=this.#be();this.#H(o,!0)}if(n)this.#N?.(this.#l),this.#d()}#be(){if(this.#l==null||this.#l.length===0)return this.#k.clear(),this.#r;let t=this.#l,n=this.#se(),r=this.#Ne(),i=[],o=new Set,s=null;for(let f=0;f<n.length;f+=1){if(!r[f].includes(t))continue;let c=n[f];i.push(c),o.add(c),s??=c}let a=this.#ee(),l=this.#Le();for(let f=0;f<a.length;f+=1){if(!l[f].includes(t))continue;let c=a[f];if(o.has(c))continue;i.push(c),o.add(c),s??=c}this.#k=o;let d=this.#U==="hide-non-matches"&&i.length>0?new Set:null;this.#L=d;let u=this.#U==="expand-matches"?new Set(this.#K??[]):new Set;for(let f of i){if(d!=null)d.add(f);if(f.endsWith("/"))u.add(f);for(let c of kt(f))if(u.add(c),d!=null)d.add(c)}return this.#ge(u),s??this.#r}#d(){for(let t of this.#t)t()}#we(t){this.#c.get(t.operation)?.forEach((n)=>{n(t)}),this.#c.get("*")?.forEach((n)=>{n(t)})}#Ie(t){for(let n of kt(t)){if(this.#n.isExpanded(n))continue;this.#n.expand(n)}if(!this.#n.isExpanded(t))this.#n.expand(t)}#Se(t){let n=this.#p;if(n===0)return;let r=this.#v===-1?0:this.#v,i=Math.min(n-1,Math.max(0,r+t));if(i!==r||this.#v===-1){if(!this.#y&&this.#x==null&&i>=this.#i.length)this.#D();this.#E(i)}}#H(t,n=!0){let r=this.#n.getVisibleCount();this.#ne=r;let i=ip(this.#n.getVisibleTreeProjectionData(n?void 0:Math.min(r,ep)),t,n?(o)=>this.#n.getVisibleIndex(o):void 0);this.#V.clear(),this.#O.clear(),this.#y=i.paths.length>=r,this.#T=i.getParentIndex,this.#i=i.paths,this.#W=i.posInSetByIndex,this.#$=i.setSizeByIndex,this.#Be(),this.#v=t==null?this.#_().length>0?0:-1:this.#B(t),this.#r=this.#v<0?null:this.#le(this.#v)}#le(t){let n=this.#_()[t];if(n!=null)return n;if(this.#x!=null)return null;return this.#n.getVisibleRowContext(t)?.row.path??null}#A(t){return this.#n.getPathInfo(t)?.path??null}#Q(t){if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n,!1)}#E(t,n=!0){let r=this.#le(t);if(r==null)return;if(this.#v===t&&this.#r===r)return;if(this.#v=t,this.#r=r,n)this.#d()}#D(){if(this.#y)return;this.#H(this.#r,!0)}#Ve(t){let n=Pn(this.#s,t);if(n==null&&this.#s!=null)this.#g="";this.#s=n;let r=Pn(this.#r,t,!0),i=[...this.#o].map((l)=>Pn(l,t)).filter((l)=>l!=null).map((l)=>this.#n.getPathInfo(l)?.path??null).filter((l)=>l!=null),o=Pn(this.#S,t),s=o==null?null:this.#n.getPathInfo(o)?.path??null,a=[...new Set(i)];if(!bi(this.#o,a))this.#o=new Set(a),this.#G+=1;return this.#S=s,r}#Ce(){return this.#n.on("*",(t)=>{if(this.#re)return;if(t.canonicalChanged)this.#b.clear(),this.#ae();if(this.#a!=null&&Fo(t))this.#a=null;let n=Fo(t)?this.#Ve(t):this.#r,r=this.#l!=null&&this.#l.length>0?this.#be():this.#l===""?this.#r:n,i=this.#l!=null||t.operation!=="expand"&&t.operation!=="collapse";this.#H(r,i),this.#d();let o=tc(t);if(o!=null)this.#we(o)})}#xe(t){if(this.#n.isExpanded(t)){this.#pe(t);return}this.#Ie(t)}};var oc=(e)=>{if(e==null||e.length===0)return"0";let t=`${e.length}`;for(let n of e)t+=`\x00${n.path}\x00${n.status}`;return t};function sc(e){let t=e.endsWith("/"),n="",r=-1;for(let i=0;i<=e.length;i+=1){if(!(e[i]==="/"||i===e.length)){if(r===-1)r=i;continue}if(r===-1)continue;if(n!=="")n+="/";n+=e.slice(r,i),r=-1}if(n==="")return null;return{isDirectory:t,path:n}}function ac(e){let t=e.endsWith("/")?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let i=t.indexOf("/",r);if(i===-1)break;n.push(t.slice(0,i+1)),r=i+1}return n}function op(e,t){return t?`${e}/`:e}function zo(e,t=null){let n=oc(e==null?void 0:[...e]);if(n==="0")return null;if(t?.signature===n)return t;let r=new Map,i=new Set,o=new Set,s=new Map;for(let a of e??[]){let l=cc(a);if(l==null)continue;dc({canonicalPath:l.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,isDirectory:l.isDirectory,status:a.status,statusByPath:r})}if(r.size===0)return null;return{changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,signature:n,statusByPath:r}}function lc(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),o=new Set(e?.directoriesWithChanges),s=new Set(e?.ignoredDirectoryPaths),a=new Map(e?.changeCountByDirectoryPath),l=!1;for(let d of n){let u=uc(d);if(u==null)continue;l=sp({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,statusByPath:i})||l}for(let d of r){let u=cc(d);if(u==null)continue;l=dc({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,isDirectory:u.isDirectory,status:d.status,statusByPath:i})||l}if(!l)return e;if(i.size===0)return null;return{changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,signature:cp(i),statusByPath:i}}function cc(e){return uc(e.path)}function uc(e){let t=sc(e);if(t==null)return;return{canonicalPath:op(t.path,t.isDirectory),isDirectory:t.isDirectory}}function sp({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let o=i.get(e);if(o==null)return!1;if(i.delete(e),o==="ignored"&&e.endsWith("/"))r.delete(e);return lp(t,n,e),!0}function dc({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:o,statusByPath:s}){let a=s.get(e);if(a===o)return!1;if(a==null)ap(t,n,e);if(s.set(e,o),o==="ignored"&&i)r.add(e);else if(i)r.delete(e);return!0}function ap(e,t,n){for(let r of ac(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function lp(e,t,n){for(let r of ac(n)){let i=(e.get(r)??0)-1;if(i>0)e.set(r,i);else e.delete(r),t.delete(r)}}function cp(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\x00${n}\x00${r}`;return t}var up=(e)=>e.trim().toLowerCase(),dp=(e)=>e.split("/").at(-1)??e,hp=(e)=>{let t=e.toLowerCase().split("."),n=[];for(let r=1;r<t.length;r+=1)n.push(t.slice(r).join("."));return n};function Sr(e,t){if(typeof e==="string")return{name:e,remappedFrom:t};return{...e,remappedFrom:t}}function hc(e){let t=Tn(e),n=t.remap,r=new Map;for(let[a,l]of Object.entries(t.byFileName??{}))r.set(a.toLowerCase(),l);let i=new Map;for(let[a,l]of Object.entries(t.byFileExtension??{}))i.set(up(a),l);let o=Object.entries(t.byFileNameContains??{}).map(([a,l])=>[a.toLowerCase(),l]);return{resolveIcon:(a,l)=>{if(a==="file-tree-icon-file"&&l!=null){let u=dp(l),f=u.toLowerCase(),c=r.get(f);if(c!=null)return Sr(c,a);for(let[g,v]of o)if(f.includes(g))return Sr(v,a);let m=hp(u);for(let g of m){let v=i.get(g);if(v!=null)return Sr(v,a)}let p=ql(t.set,u,m);if(p!=null&&t.set!=="none"){if(p==="default"){let g=n?.[a];if(g!=null)return Sr(g,a)}return{name:Vl(p),remappedFrom:a,token:p}}}let d=n?.[a];if(d==null)return{name:a};return Sr(d,a)}}}var Y,vc,fp,ln,fc,xi,yc,bc,Uo,Wo,$o,pp,Cr={},wc=[],ki=Array.isArray,Ko=wc.slice,Ot=Object.assign;function Go(e){e&&e.parentNode&&e.remove()}function Dn(e,t,n){var r,i,o,s={};for(o in t)o=="key"?r=t[o]:o=="ref"&&typeof e!="function"?i=t[o]:s[o]=t[o];return arguments.length>2&&(s.children=arguments.length>3?Ko.call(arguments,2):n),Si(e,s,r,i,null)}function Si(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i==null?++vc:i,__i:-1,__u:0};return i==null&&Y.vnode!=null&&Y.vnode(o),o}function pt(e){return e.children}function Ci(e,t){this.props=e,this.context=t,this.__g=0}function Rn(e,t){if(t==null)return e.__?Rn(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Rn(e):null}function Ic(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return Ic(e)}}function pc(e){(8&e.__g||!(e.__g|=8)||!ln.push(e)||xi++)&&fc==Y.debounceRendering||((fc=Y.debounceRendering)||queueMicrotask)(mp)}function mp(){for(var e,t,n,r,i,o,s,a,l=1;ln.length;)ln.length>l&&ln.sort(yc),e=ln.shift(),l=ln.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,o=[],s=[],(a=t.__P)&&((n=Ot({},r)).__v=r.__v+1,Y.vnode&&Y.vnode(n),Yo(a,n,r,t.__n,a.namespaceURI,32&r.__u?[i]:null,o,i==null?Rn(r):i,!!(32&r.__u),s,a.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,xc(o,n,s),n.__e!=i&&Ic(n)));xi=0}function Sc(e,t,n,r,i,o,s,a,l,d,u,f){var c,m,p,g,v,I,C,y=r&&r.__k||wc,S=t.length;for(l=gp(n,t,y,l,S),c=0;c<S;c++)(p=n.__k[c])!=null&&(m=p.__i==-1?Cr:y[p.__i]||Cr,p.__i=c,I=Yo(e,p,m,i,o,s,a,l,d,u,f),g=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Xo(m.ref,null,p),u.push(p.ref,p.__c||g,p)),v==null&&g!=null&&(v=g),(C=!!(4&p.__u))||m.__k===p.__k?l=Cc(p,l,e,C):typeof p.type=="function"&&I!==void 0?l=I:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=v,l}function gp(e,t,n,r,i){var o,s,a,l,d,u=n.length,f=u,c=0;for(e.__k=Array(i),o=0;o<i;o++)(s=t[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(l=o+c,(s=e.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?Si(null,s,null,null,null):ki(s)?Si(pt,{children:s},null,null,null):s.constructor==null&&s.__b>0?Si(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,(d=s.__i=vp(s,n,l,f))!=-1&&(f--,(a=n[d])&&(a.__u|=2)),a==null||a.__v==null?(d==-1&&(i>u?c--:i<u&&c++),typeof s.type!="function"&&(s.__u|=4)):d!=l&&(d==l-1?c--:d==l+1?c++:(d>l?c--:c++,s.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<u;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==r&&(r=Rn(a)),_c(a,a));return r}function Cc(e,t,n,r){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=Cc(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Rn(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function vp(e,t,n,r){var i,o,s,a=e.key,l=e.type,d=t[n],u=d!=null&&(2&d.__u)==0;if(d===null&&e.key==null||u&&a==d.key&&l==d.type)return n;if(r>(u?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((d=t[s=i>=0?i--:o++])!=null&&(2&d.__u)==0&&a==d.key&&l==d.type)return s}return-1}function mc(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":n}function Ii(e,t,n,r,i){var o;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||mc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||mc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(bc,"$1")),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||(e.__l={}),e.__l[t+o]=n,n?r?n.l=r.l:(n.l=Uo,e.addEventListener(t,o?$o:Wo,o)):e.removeEventListener(t,o?$o:Wo,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n==null?"":n;break e}catch(s){}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function gc(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=Uo++;else if(t.u<n.l)return;return n(Y.event?Y.event(t):t)}}}function Yo(e,t,n,r,i,o,s,a,l,d,u){var f,c,m,p,g,v,I,C,y,S,x,T,O,fe,Z,pe,J,K,B,ae,Se,z=t.type;if(t.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),n.__c.__z&&(a=t.__e=n.__e=(o=n.__c.__z)[0],n.__c.__z=null)),(f=Y.__b)&&f(t);e:if(typeof z=="function")try{if(C=t.props,y="prototype"in z&&z.prototype.render,S=(f=z.contextType)&&r[f.__c],x=f?S?S.props.value:f.__:r,n.__c?2&(c=t.__c=n.__c).__g&&(c.__g|=1,I=!0):(y?t.__c=c=new z(C,x):(t.__c=c=new Ci(C,x),c.constructor=z,c.render=bp),S&&S.sub(c),c.props=C,c.state||(c.state={}),c.context=x,c.__n=r,m=!0,c.__g|=8,c.__h=[],c._sb=[]),y&&c.__s==null&&(c.__s=c.state),y&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ot({},c.__s)),Ot(c.__s,z.getDerivedStateFromProps(C,c.__s))),p=c.props,g=c.state,c.__v=t,m)y&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),y&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(y&&z.getDerivedStateFromProps==null&&C!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(C,x),!(4&c.__g)&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(C,c.__s,x)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(c.props=C,c.state=c.__s,c.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(le){le&&(le.__=t)}),T=0;T<c._sb.length;T++)c.__h.push(c._sb[T]);c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(C,c.__s,x),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,v)})}if(c.context=x,c.props=C,c.__P=e,c.__g&=-5,O=Y.__r,fe=0,y){for(c.state=c.__s,c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),Z=0;Z<c._sb.length;Z++)c.__h.push(c._sb[Z]);c._sb=[]}else do c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(8&c.__g&&++fe<25);c.state=c.__s,c.getChildContext!=null&&(r=Ot({},r,c.getChildContext())),y&&!m&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(p,g)),pe=f,f!=null&&f.type===pt&&f.key==null&&(pe=kc(f.props.children)),a=Sc(e,ki(pe)?pe:[pe],t,n,r,i,o,s,a,l,d,u),t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__g&=-4)}catch(le){if(t.__v=null,l||o!=null)if(le.then){for(J=0,K=!1,t.__u|=l?160:128,t.__c.__z=[],B=0;B<o.length;B++)(ae=o[B])==null||K||(ae.nodeType==8&&ae.data=="$s"?(J>0&&t.__c.__z.push(ae),J++,o[B]=null):ae.nodeType==8&&ae.data=="/$s"?(--J>0&&t.__c.__z.push(ae),K=J===0,a=o[B],o[B]=null):J>0&&(t.__c.__z.push(ae),o[B]=null));if(!K){for(;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__c.__z=[a]}t.__e=a}else{for(Se=o.length;Se--;)Go(o[Se]);jo(t)}else t.__e=n.__e,t.__k=n.__k,le.then||jo(t);Y.__e(le,t,n)}else a=t.__e=yp(n.__e,t,n,r,i,o,s,l,d,u);return(f=Y.diffed)&&f(t),128&t.__u?void 0:a}function jo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(jo)}function xc(e,t,n){for(var r=0;r<n.length;r++)Xo(n[r],n[++r],n[++r]);Y.__c&&Y.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){Y.__e(o,i.__v)}})}function kc(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:ki(e)?e.map(kc):Ot({},e)}function yp(e,t,n,r,i,o,s,a,l,d){var u,f,c,m,p,g,v,I,C=n.props,y=t.props,S=t.type;if(S=="svg"?i="http://www.w3.org/2000/svg":S=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!S&&(S?p.localName==S:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(S==null)return d.createTextNode(y);e=d.createElementNS(i,S,y.is&&y),a&&(Y.__m&&Y.__m(t,o),a=!1),o=null}if(S==null)C===y||a&&e.data==y||(e.data=y);else{if(o=o&&Ko.call(e.childNodes),C=n.props||Cr,!a&&o!=null)for(C={},u=0;u<e.attributes.length;u++)C[(p=e.attributes[u]).name]=p.value;for(u in C)if(p=C[u],u=="children");else if(u=="dangerouslySetInnerHTML")c=p;else if(!(u in y)){if(u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y)continue;Ii(e,u,null,p,i)}for(u in I=1&n.__u,y)p=y[u],u=="children"?m=p:u=="dangerouslySetInnerHTML"?f=p:u=="value"?g=p:u=="checked"?v=p:a&&typeof p!="function"||C[u]===p&&!I||Ii(e,u,p,C[u],i);if(f)a||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=""),Sc(S=="template"?e.content:e,ki(m)?m:[m],t,n,r,S=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Rn(n,0),a,l,d),o!=null)for(u=o.length;u--;)Go(o[u]);a||(u="value",S=="progress"&&g==null?e.removeAttribute("value"):g==null||g===e[u]&&(S!=="progress"||g)||Ii(e,u,g,C[u],i),u="checked",v!=null&&v!=e[u]&&Ii(e,u,v,C[u],i))}return e}function Xo(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){Y.__e(i,n)}}function _c(e,t,n){var r,i;if(Y.unmount&&Y.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Xo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){Y.__e(o,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&_c(r[i],t,n||typeof e.type!="function");n||Go(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function bp(e,t,n){return this.constructor(e,n)}function _i(e,t){var n,r,i,o;t==document&&(t=document.documentElement),Y.__&&Y.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=Dn(pt,null,[e]),i=[],o=[],Yo(t,e,r||Cr,Cr,t.namespaceURI,r?null:t.firstChild?Ko.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o,t.ownerDocument),xc(i,e,o)}function Ec(e,t){e.__u|=32,_i(e,t)}Y={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(a){e=a}}throw xi=0,e}},vc=0,fp=function(e){return e!=null&&e.constructor==null},Ci.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ot({},this.state),typeof e=="function"&&(e=e(Ot({},n),this.props)),e&&Ot(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),pc(this))},Ci.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),pc(this))},Ci.prototype.render=pt,ln=[],xi=0,yc=function(e,t){return e.__v.__b-t.__v.__b},bc=/(PointerCapture)$|Capture$/i,Uo=0,Wo=gc(!1),$o=gc(!0),pp=0;var wp=0;function k(e,t,n,r,i,o){t||(t={});var s,a,l=t;if("ref"in l&&typeof e!="function")for(a in l={},t)a=="ref"?s=t[a]:l[a]=t[a];var d={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--wp,__i:-1,__u:0,__source:i,__self:o};return Y.vnode&&Y.vnode(d),d}var Ip=16,Sp=16,Cp={};function Mn({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:o,label:s,alignCapitals:a=!1}){let l=`#${e.replace(/^#/,"")}`,{width:d,height:u,viewBox:f}=Cp[e]??{width:Ip,height:Sp},c=r??d,m=i??u,p=o??f??`0 0 ${d} ${u}`;return k("svg",{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":a,...s!=null?{"aria-label":s,role:"img"}:{"aria-hidden":!0},viewBox:p,width:c,height:m,children:k("use",{href:l})})}var Tc=(e)=>e!==void 0&&/\s/.test(e),xp=(e,t)=>{let n=(r)=>Tc(e[r-1])||Tc(e[r]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let o=t+r;if(o<e.length&&!n(o))return o}return t},Rc=(e)=>xp(e,Math.ceil(e.length/2)),Pc=(e)=>{if(e.length<2)return[e,""];let t=Rc(e);return[e.slice(0,t),e.slice(t)]},kp=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf(".")+1,n=e.length-t>10,r=t>=1&&!n?t:Rc(e);return[e.slice(0,r),e.slice(r)]},_p=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf("/")+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},Ep=(e,{splitIndex:t}={})=>{if(typeof t!=="number"){let n=Math.ceil(e.length/2);return[e.slice(0,n),e.slice(n)]}return[e.slice(0,t),e.slice(t)]},Tp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},Pp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=t;return[e.slice(0,n),e.slice(n)]};function Rp({children:e,marker:t,variant:n="default"}){return k("div",{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:k("div",{"data-truncate-marker":!0,children:typeof t==="function"?t({children:e}):n==="fade"?k("span",{"data-truncate-fade":!0}):t})})}function Dp(e){let{mode:t,children:n}=e;return k("div",{children:[k("div",{"data-truncate-content":"visible",children:t==="fruncate"?k("span",{children:n}):n}),k("div",{"data-truncate-content":"overflow","aria-hidden":!0,children:t==="fruncate"?k("span",{children:n}):n})]})}function Dc({children:e,mode:t="truncate",marker:n="…",variant:r="default",...i}){let o=k(Dp,{mode:t,children:e},"content"),s=k(Rp,{marker:n,mode:t,variant:r},"marker");return k("div",{"data-truncate-container":t,"data-truncate-variant":r,...i,children:k("div",{"data-truncate-grid":!0,children:t==="truncate"?[o,s]:[s,o,k("div",{"data-truncate-fill":!0},"fill")]})})}function xr({children:e,...t}){return k(Dc,{mode:"truncate",...t,children:e})}function Qo({children:e,...t}){return k(Dc,{mode:"fruncate",...t,children:e})}function Mc({children:e,contents:t,priority:n="end",split:r="center",minimumLength:i=12,className:o,style:s,...a}){let l=null,d=null;if(Array.isArray(t)){if(t.length!==2)return console.error("MiddleTruncate: contents must be an array of two items"),null;l=k(xr,{...a,children:t[0]}),d=k(Qo,{...a,children:t[1]})}else{if(typeof e!=="string")return console.error("MiddleTruncate: children must be a string"),null;if(e.length===0)return k("div",{className:o,style:s});if(e.length<i)if(n==="end")return k(Qo,{...a,className:o,style:s,children:e});else return k(xr,{...a,className:o,style:s,children:e});let u=null,f=null,c=null;if(typeof r==="string"){if(r==="center")u=Pc;else if(r==="extension")u=kp;else if(r==="leaf-path")u=_p}else if(typeof r==="number")u=Ep,f=r;else if(Array.isArray(r)){let[S,x]=r;if(c=x,S==="last")u=Tp;else if(S==="first")u=Pp}else if(typeof r==="function")u=r;u??=Pc;let[m,p]=u(e,{priority:n,variant:a.variant,splitIndex:typeof f==="number"?f:void 0,splitOffset:typeof c==="number"?c:void 0}),g=m.length>=p.length,v=n==="equal"&&!g,I=n==="equal"&&g,C={},y={};if(v)C.marker="";if(I)y.marker="";l=k(xr,{...a,...C,children:m}),d=k(Qo,{...a,...y,children:p})}return k("div",{"data-truncate-group-container":"middle",className:o,style:s,children:[k("div",{"data-truncate-segment-priority":n==="start"||n==="equal"?"1":"2",children:l}),k("div",{"data-truncate-segment-priority":n==="end"||n==="equal"?"1":"2",children:d})]})}var Zo={endIndex:-1,startIndex:-1};function Mp(e,t,n){return Math.min(Math.max(e,t),n)}function Ac(e,t){return e<0||t<e?Zo:{endIndex:t,startIndex:e}}function Jo(e){return e.startIndex<0||e.endIndex<e.startIndex}function Ap(e,t){return Jo(e)?0:(e.endIndex-e.startIndex+1)*t}function Nc(e,t,n){if(t<=0)return-1;let r=t*n;if(e<=0)return 0;if(e>=r)return t;return Math.floor(e/n)}function Np(e,t,n){if(t<=0||e<=0)return-1;if(e>=t*n)return t-1;return Math.ceil(e/n)-1}function Lp(e){let t=new Map;return e.forEach((n,r)=>{if(n.kind!=="directory"||!n.isExpanded)return;let i=n.ancestorPaths.length,o=t.get(i);if(o==null){t.set(i,[r]);return}o.push(r)}),t}function Fp(e,t){let n=0,r=e.length-1,i=-1;while(n<=r){let o=Math.floor((n+r)/2),s=e[o];if(s==null)break;if(s<=t){i=o,n=o+1;continue}r=o-1}return i}function Bp(e){let t=new Map,n=[];for(let i=0;i<e.length;i+=1){let o=e[i];if(o==null)continue;let s=o.kind==="directory"&&o.isExpanded?[...o.ancestorPaths,o.path]:o.ancestorPaths,a=0;while(a<n.length&&a<s.length&&n[a]===s[a])a+=1;for(let l=n.length-1;l>=a;l-=1){let d=n[l];if(d!=null)t.set(d,i-1)}n.length=a;for(let l=a;l<s.length;l+=1){let d=s[l];if(d!=null)n.push(d)}}let r=e.length-1;for(let i of n)t.set(i,r);return t}function es(e,t,n){if(e.length===0||t<=0)return[];let r=Bp(e),i=Lp(e),o=[];for(let s=0;s<e.length;s+=1){let a=i.get(s);if(a==null||a.length===0)break;let l=t+s*n,d=Fp(a,Math.min(e.length-1,Math.floor(l/n))),u=null;while(d>=0){let f=a[d],c=f==null?null:e[f]??null;if(c!=null&&(s===0||c.ancestorPaths[s-1]===o[s-1]?.path)){u=c;break}d-=1}if(u==null)break;o.push(u)}return o.map((s,a)=>{let l=a*n,d=(r.get(s.path)??e.length-1)+1;if(d>=e.length)return{row:s,top:l};let u=d*n-t;return{row:s,top:Math.min(l,u-n)}}).filter((s)=>s.top+n>0)}function Lc(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),o=Math.max(0,Math.floor(t.overscan)),s=Math.max(0,r-i),a=Mp(t.scrollTop,0,s),l=t.stickyRows??es(e,a,t.itemHeight),d=l.reduce((T,O)=>Math.max(T,O.top+t.itemHeight),0),u=Math.min(r,a+d),f=Math.max(0,i-d),c=Math.max(0,r-u),m=Nc(a,n,t.itemHeight),p=Nc(u,n,t.itemHeight),g=d<=0||m<0||m>=n?-1:m,v=g===-1?-1:Math.min(n-1,p-1),I=g===-1||v<g?0:v-g+1,C=f<=0||p>=n?Zo:Ac(p,Np(u+f,n,t.itemHeight)),y=v+1,S=Jo(C)?Zo:Ac(Math.max(y,C.startIndex-o),Math.min(n-1,C.endIndex+o)),x=Ap(S,t.itemHeight);return{occlusion:{firstOccludedIndex:g,lastOccludedIndex:v,occludedCount:I},physical:{itemHeight:t.itemHeight,maxScrollTop:s,overscan:o,scrollTop:a,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:c,paneHeight:f,paneTop:u},sticky:{height:d,rows:l},visible:C,window:{endIndex:S.endIndex,height:x,offsetTop:Jo(S)?0:S.startIndex*t.itemHeight,startIndex:S.startIndex}}}var Fc={added:"A",deleted:"D",ignored:null,modified:"M",renamed:"R",untracked:"U"},Bc={added:"Git status: added",deleted:"Git status: deleted",ignored:"Git status: ignored",modified:"Git status: modified",renamed:"Git status: renamed",untracked:"Git status: untracked"},Hc="Contains git status items";function Vc(e){if(e.current)return!0;return e.current=!0,!1}function ts(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),a=n*r,l=a+r;if(a<t+s){let d=Math.max(0,a-s);return d===t?null:d}if(l>t+o){let d=l-o;return d===t?null:d}return null}function Oc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:o=0,totalHeight:s,viewportHeight:a}=e;if(i==="nearest")return ts({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:o,viewportHeight:a});if(n<0)return null;let l=Math.max(0,o),d=n*r,u=Math.max(0,a-l),f=i==="center"?l+Math.max(0,(u-r)/2):l,c=Math.max(0,s-a),m=Math.max(0,Math.min(d-f,c));return m===t?null:m}function qc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:o,viewportHeight:s}=e;if(n<0)return null;let a=Math.max(0,i),l=n*r,d=l+r,u=t+a,f=t+s;if(l>=u&&d<=f)return null;let c=Math.max(0,o-s),m=Math.max(0,Math.min(l-a,c));return m===t?null:m}function cn(e){if(e==null||!e.isConnected)return!1;if(e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();if(t instanceof ShadowRoot)return t.activeElement===e;return document.activeElement===e}function kr(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let r=t.activeElement;return r instanceof HTMLElement?r:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function An(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;if(n>0)return n;return e.clientHeight>0?e.clientHeight:t}function ns(e,t){return e!=null&&e>0?e:t}function zc(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;if(n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0)return n.blockSize;return e.contentRect.height>0?e.contentRect.height:null}function rs(e,t,n,r,i=0){let o=ts({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});if(o==null)return!1;return e.scrollTop=o,!0}function Wc(e,t,n,r,i,o,s=0){let a=Oc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:o,topInset:s,totalHeight:i,viewportHeight:r});if(a==null)return!1;return e.scrollTop=a,!0}function Nn(e,t,n,r,i,o){let s=qc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:o,totalHeight:i,viewportHeight:r});if(s==null)return!1;return e.scrollTop=s,!0}function is(e,t,n,r){if(n.end<n.start)return null;if(e<n.start)return-t;if(e>n.end)return r;return null}function $c(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;if(t==null)return"reset";if(!r)return"reveal-canonical";if(n===t)return"ignore";return"focus-input"}function jc({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:o}){return k("input",{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:o,onClick:(s)=>s.stopPropagation(),onMouseDown:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation()})}function Uc(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:o,isParked:s,itemHeight:a,features:l,state:d,extraStyle:u}=e,f=n==="sticky",c=t.ancestorPaths.at(-1)??"",m={};if(d.isFocusRinged)m["data-item-focused"]=!0;if(t.isSelected)m["data-item-selected"]=!0;if(d.isContextHovered)m["data-item-context-hover"]="true";if(d.isDragTarget)m["data-item-drag-target"]=!0;if(d.isDragging)m["data-item-dragging"]=!0;if(d.effectiveGitStatus!=null)m["data-item-git-status"]=d.effectiveGitStatus;if(d.containsGitChange)m["data-item-contains-git-change"]="true";return{"aria-expanded":!f&&t.kind==="directory"?t.isExpanded:void 0,"aria-haspopup":l.contextMenuEnabled?"menu":void 0,"aria-label":i,"aria-level":!f?t.level+1:void 0,"aria-posinset":!f?t.posInSet+1:void 0,"aria-selected":!f?t.isSelected?"true":"false":void 0,"aria-setsize":!f?t.setSize:void 0,"data-file-tree-sticky-path":f?r:void 0,"data-file-tree-sticky-row":f?"true":void 0,"data-item-context-menu-button-visibility":l.actionLaneEnabled?l.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":l.contextMenuEnabled?l.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":l.actionLaneEnabled?"true":void 0,"data-item-has-git-lane":l.gitLaneActive?"true":void 0,"data-item-parent-path":c.length>0?c:void 0,"data-item-parked":s?"true":void 0,"data-item-path":r,"data-item-type":t.kind==="directory"?"folder":"file","data-type":"item",id:!f?o:void 0,role:!f?"treeitem":void 0,style:{minHeight:`${a}px`,...u},tabIndex:!f&&t.isFocused?0:-1,...m}}function Kc(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,o=t.ctrlKey||t.metaKey,s=t.shiftKey||o,a=t.shiftKey?{additive:o,kind:"range"}:o?{kind:"toggle"}:{kind:"single"};return{closeSearch:r,revealCanonical:n==="sticky",selection:a,toggleDirectory:!s&&i}}var Ln,ve,os,Gc,ss=Object.is,_r=0,nu=[],we=Y,Yc=we.__b,Xc=we.__r,Qc=we.diffed,Zc=we.__c,Jc=we.unmount,eu=we.__;function Ti(e,t){we.__h&&we.__h(ve,e,_r||t),_r=0;var n=ve.__H||(ve.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function at(e){return _r=1,Hp(ru,e)}function Hp(e,t,n){var r=Ti(Ln++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ru(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],d=r.t(l,a);ss(l,d)||(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ve,!ve.__f)){var i=function(a,l,d){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return!!c.__c});if(u.every(function(c){return!c.__N}))return!o||o.call(this,a,l,d);var f=r.__c.props!==a;return u.forEach(function(c){if(c.__N){var m=c.__[0];c.__=c.__N,c.__N=void 0,ss(m,c.__[0])||(f=!0)}}),o&&o.call(this,a,l,d)||f};ve.__f=!0;var{shouldComponentUpdate:o,componentWillUpdate:s}=ve;ve.componentWillUpdate=function(a,l,d){if(4&this.__g){var u=o;o=void 0,i(a,l,d),o=u}s&&s.call(this,a,l,d)},ve.shouldComponentUpdate=i}return r.__N||r.__}function ls(e,t){var n=Ti(Ln++,3);!we.__s&&cs(n.__H,t)&&(n.__=e,n.u=t,ve.__H.__h.push(n))}function ze(e,t){var n=Ti(Ln++,4);!we.__s&&cs(n.__H,t)&&(n.__=e,n.u=t,ve.__h.push(n))}function V(e){return _r=5,_t(function(){return{current:e}},[])}function _t(e,t){var n=Ti(Ln++,7);return cs(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Pe(e,t){return _r=8,_t(function(){return e},t)}function Vp(){for(var e;e=nu.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ei),e.__H.__h.forEach(as),e.__H.__h=[]}catch(t){e.__H.__h=[],we.__e(t,e.__v)}}we.__b=function(e){ve=null,Yc&&Yc(e)},we.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),eu&&eu(e,t)},we.__r=function(e){Xc&&Xc(e),Ln=0;var t=(ve=e.__c).__H;t&&(os===ve?(t.__h=[],ve.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(Ei),t.__h.forEach(as),t.__h=[],Ln=0)),os=ve},we.diffed=function(e){Qc&&Qc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(nu.push(t)!==1&&Gc===we.requestAnimationFrame||((Gc=we.requestAnimationFrame)||Op)(Vp)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),os=ve=null},we.__c=function(e,t){t.some(function(n){try{n.__h.forEach(Ei),n.__h=n.__h.filter(function(r){return!r.__||as(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],we.__e(r,n.__v)}}),Zc&&Zc(e,t)},we.unmount=function(e){Jc&&Jc(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Ei(r)}catch(i){t=i}}),n.__H=void 0,t&&we.__e(t,n.__v))};var tu=typeof requestAnimationFrame=="function";function Op(e){var t,n=function(){clearTimeout(r),tu&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);tu&&(t=requestAnimationFrame(n))}function Ei(e){var t=ve,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ve=t}function as(e){var t=ve;e.__c=e.__(),ve=t}function cs(e,t){return!e||e.length!==t.length||t.some(function(n,r){return!ss(n,e[r])})}function ru(e,t){return typeof t=="function"?t(e):t}function qp(e,t=null,n=null){let r=e.flattenedSegments;if(r==null||r.length===0)return t??e.name;return k("span",{"data-item-flattened-subitems":!0,children:r.map((i,o)=>{let s=o===r.length-1;return k(pt,{children:[k("span",{"data-item-flattened-subitem":i.path,"data-item-flattened-subitem-drag-target":n===i.path?"true":void 0,children:s&&t!=null?t:k(xr,{children:i.name})}),o<r.length-1?" / ":""]},i.path)})})}function Bn(e){return e.isFlattened?e.flattenedSegments?.findLast((t)=>t.isTerminal)?.path??e.path:e.path}function ds(e){let t=e.flattenedSegments;if(t==null||t.length===0)return e.name;return t.map((n)=>n.name).join(" / ")}function iu(e,t,n,r){return e.map((i,o)=>{let s=o*n,a=i.subtreeEndIndex+1;if(a>=r)return{row:i.row,top:s};let l=a*n-t;return{row:i.row,top:Math.min(s,l-n)}}).filter((i)=>i.top+n>0)}function us({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:o}){let s=e.getVisibleCount(),a=i&&s>0?e.getStickyRowCandidates(r,t):[],l=a==null&&i&&s>0?e.getVisibleRows(0,s-1):[],d=Lc(l,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:a==null?void 0:iu(a,r,t,s),totalRowCount:s,viewportHeight:o}),u=i&&r<=0&&s>0?e.getStickyRowCandidates(1,t):[],f=u!=null&&r<=0?iu(u,1,t,s):i&&r<=0&&l.length>0?es(l,1,t):d.sticky.rows;return{overlayHeight:f.reduce((c,m)=>Math.max(c,m.top+t),0),overlayRows:f,snapshot:d,visibleRows:l}}var zp=400,ou=10,Fn=40,su=18;function Wp(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,o=r.elementFromPoint?.(t,n)??i?.(t,n)??null;if(e instanceof ShadowRoot&&(o==null||!e.contains(o)))return $p(e,t,n);return o instanceof HTMLElement?o:null}function $p(e,t,n){let r=Array.from(e.querySelectorAll('[data-type="item"], [data-item-flattened-subitem]'));for(let i=r.length-1;i>=0;i--){let o=r[i],s=o.getBoundingClientRect();if(t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom)return o}return null}function au(e){let t=e?.closest?.('[data-type="item"]');if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.("[data-item-flattened-subitem]"),i=r instanceof HTMLElement?r.getAttribute("data-item-flattened-subitem")??null:null;if(i!=null&&i.endsWith("/"))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:"directory"};if(t.dataset.itemType==="folder")return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:"directory"};let o=t.dataset.itemParentPath??null;if(o==null||o.length===0)return{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:"root"};return{directoryPath:o,flattenedSegmentPath:null,hoveredPath:n,kind:"directory"}}function lu(e){let t=e.cloneNode(!0);return t.removeAttribute("id"),t.dataset.fileTreeDragPreview="true",t.setAttribute("aria-hidden","true"),t.tabIndex=-1,Object.assign(t.style,{boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",left:"0px",margin:"0",pointerEvents:"none",position:"fixed",top:"0px",willChange:"transform",zIndex:"10000"}),t}function jp(){return navigator.vendor!=="Apple Computer, Inc."}function Up(e,t){let n=e-t.top;if(n<Fn)return-Math.ceil((Fn-Math.max(0,n))/Fn*su);let r=t.bottom-e;if(r<Fn)return Math.ceil((Fn-Math.max(0,r))/Fn*su);return 0}function Kp(e,t){if(e!=null){let n=Fc[e];if(n==null)return null;return{text:n,title:Bc[e]}}if(t)return{icon:{name:"file-tree-icon-dot",width:6,height:6},title:Hc};return null}function Gp(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;i-=1){let o=e[i],s=n.get(o);if(s!=null){for(let a of r)n.set(a,s);return s?"ignored":null}if(t.has(o)){n.set(o,!0);for(let a of r)n.set(a,!0);return"ignored"}r.push(o)}for(let i of r)n.set(i,!1);return null}function cu(e){return e!=null&&"toggle"in e}function vu(e){return e.code==="Space"||e.key===" "||e.key==="Spacebar"}function Yp(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Xp(e){if(e==null)return"";return`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"] { opacity: 1; }`}function yu(e){return e.shiftKey&&e.key==="F10"||e.key==="ContextMenu"}function Qp(e,t){if(t&&yu(e))return!0;if((e.ctrlKey||e.metaKey)&&vu(e))return!0;return e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"}var Zp=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp"]);function uu(e){for(let t of e.composedPath()){if(!(t instanceof HTMLElement))continue;if(t.dataset.fileTreeContextMenuRoot==="true")return!0;if(t.dataset.type==="context-menu-anchor"||t.dataset.type==="context-menu-trigger")return!0;if(t.getAttribute("slot")==="context-menu")return!0}return!1}function Jp(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function em(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function tm(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function du(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function hu(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked==="true"?null:i}function nm(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll('button[data-file-tree-sticky-row="true"]')){if(!(n instanceof HTMLElement))continue;let r=n.dataset.fileTreeStickyPath;if(r!=null)t.push(r)}return t}function rm(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll('button[data-item-focused="true"][data-item-parked="true"]'))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function im(e,t,n,r,i,o,s){let a=Math.max(0,o-i),l=t?.getBoundingClientRect()??null,d=l==null||n==null?null:n.getBoundingClientRect().top-l.top,u=rm(e,r),f=l==null||u==null?null:u.getBoundingClientRect().top-l.top;return Math.max(0,Math.min(f??Math.max(d??0,a),Math.max(0,s-i)))}function fu(e,t){return{kind:e.kind,name:ds(e),path:t}}function om(e){return e==null?void 0:`${e}__tree`}function bu(e,t,n){if(e==null)return;return`${e}__focused-item-${encodeURIComponent(t)}${n?"__parked":""}`}function pu(e){return e==="file-tree-icon-chevron"||e==="file-tree-icon-dot"||e==="file-tree-icon-file"||e==="file-tree-icon-lock"}function mu(e,t){if(e==null)return null;if("text"in e){if(e.parts!=null)return k("span",{title:e.title,children:e.parts.map((r,i)=>k("span",{style:{color:r.color},children:r.text},i))});return k("span",{title:e.title,children:e.text})}let n=typeof e.icon==="string"?pu(e.icon)?t(e.icon):{name:e.icon}:pu(e.icon.name)?(()=>{let r=t(e.icon.name),{name:i,...o}=e.icon;return{...r,...o}})():e.icon;return k("span",{title:e.title,children:k(Mn,{...n})})}function gu(e){if(e==null)return;cn(e.querySelector(["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "))??e)}function sm(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:o=null,gitDecoration:s=null,gitLaneActive:a=!1,renameInput:l=null,showDecorativeActionAffordance:d=!1}={}){let u=Bn(e);return k(pt,{children:[e.depth>0?k("div",{"data-item-section":"spacing",children:Array.from({length:e.depth}).map((f,c)=>k("div",{"data-item-section":"spacing-item","data-ancestor-path":e.ancestorPaths[c]},c))}):null,k("div",{"data-item-section":"icon",children:e.kind==="directory"?k(Mn,{...t("file-tree-icon-chevron")}):k(Mn,{...t("file-tree-icon-file",u)})}),k("div",{"data-item-section":"content",children:e.isFlattened?qp(e,l,o):l??k(Mc,{minimumLength:5,split:"extension",children:e.name})}),i?k("div",{"data-item-section":"decoration",children:r!=null?mu(r,t):null}):null,a?k("div",{"data-item-section":"git",children:mu(s,t)}):null,n?k("div",{"data-item-section":"action",children:d?k("span",{"aria-hidden":"true","data-item-action-affordance":"decorative",children:k(Mn,{...t("file-tree-icon-ellipsis")})}):null}):null]})}function Pi(e,t,n,r={}){let{controller:i,renameView:o,visualFocusPath:s,contextHoverPath:a,draggedPathSet:l,dragTarget:d,dragAndDropEnabled:u,shouldSuppressContextMenu:f,handleRowDragStart:c,handleRowDragEnd:m,handleRowTouchStart:p,instanceId:g,itemHeight:v,gitStatusByPath:I,ignoredGitDirectories:C,ignoredInheritanceCache:y,directoriesWithGitChanges:S,gitLaneActive:x,contextMenuEnabled:T,contextMenuTriggerMode:O,contextMenuButtonTriggerEnabled:fe,contextMenuButtonVisibility:Z,contextMenuRightClickEnabled:pe,registerRenameInput:J,registerButton:K,resolveIcon:B,renderDecorationForRow:ae,openContextMenuForRow:Se,onRowClick:z,onKeyDown:le}=e,X=Bn(t),{isParked:ye=!1,mode:oe="flow",style:bt}=r,He=oe==="sticky",ct=I?.get(X)??null??Gp(t.ancestorPaths,C,y),Tt=t.kind==="directory"&&(S?.has(X)??!1),tt=ae(t,X),We=Kp(ct,Tt),Ee=T&&fe,Ve=tt!=null||x||Ee,Kt=Ee&&Z==="always",Ce=o.getPath()===X,wt=Ce?o.getValue():"",$e=He||!Ce?null:k(jc,{ref:J,ariaLabel:`Rename ${ds(t)}`,isFlattened:t.isFlattened,value:wt,onBlur:()=>{o.commit()},onInput:(be)=>{o.setValue(be.currentTarget.value)}}),Gt=sm(t,B,{actionLaneEnabled:Ee,customDecoration:tt,decorationLaneEnabled:Ve,dragTargetFlattenedSegmentPath:d?.flattenedSegmentPath??null,gitDecoration:We,gitLaneActive:x,renameInput:$e,showDecorativeActionAffordance:Kt}),nt={...Uc({ariaLabel:ds(t),domId:t.isFocused?bu(g,X,ye):void 0,extraStyle:bt,features:{actionLaneEnabled:Ee,contextMenuButtonVisibility:Ee?Z:null,contextMenuEnabled:T,contextMenuTriggerMode:T?O:null,gitLaneActive:x},isParked:ye,itemHeight:v,mode:oe,row:t,state:{containsGitChange:Tt,effectiveGitStatus:ct,isContextHovered:a===X,isDragTarget:d?.kind==="directory"&&d.directoryPath===X,isDragging:l?.has(X)===!0,isFocusRinged:t.isFocused&&s===X},targetPath:X}),key:n,onContextMenu:T||u?(be)=>{if(f()){be.preventDefault();return}if(!T)return;if(be.preventDefault(),!pe)return;i.focusMountedPathFromInput(X),Se(t,X,{anchorRect:em(be.clientX,be.clientY),source:"right-click"})}:void 0,onFocus:!He?()=>{i.focusMountedPathFromInput(X)}:void 0,onKeyDown:!He?le:void 0,ref:(be)=>{K(X,be)}};if(!He&&Ce)return k("div",{...nt,children:Gt});return k("button",{...nt,type:"button",draggable:u&&!ye,onDragEnd:u&&!ye?m:void 0,onDragStart:u&&!ye?(be)=>{c(be,t,X)}:void 0,onMouseDown:(be)=>{if(He){be.preventDefault();return}if(i.isSearchOpen())be.preventDefault()},onTouchStart:u&&!ye?(be)=>{p(be,t,X)}:void 0,onClick:(be)=>{z(be,t,X,oe)},children:Gt})}function am(e,t,n){if(t.end<t.start)return[];return e.controller.getVisibleRows(t.start,t.end).filter((r)=>!n.has(Bn(r))).map((r,i)=>Pi(e,r,t.start+i))}function hs({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:o,instanceId:s,itemHeight:a=pi,overscan:l=10,renamingEnabled:d=!1,renderRowDecoration:u,searchBlurBehavior:f="close",searchEnabled:c=!1,searchFakeFocus:m=!1,slotHost:p,stickyFolders:g=!1,initialViewportHeight:v=420}){let I=V(null),C=V(null),y=V(!1),S=V(null),x=V(null),T=V(null),O=V(null),fe=V(null),Z=V(new Map),pe=V(new Map),J=V(()=>{}),K=V(null),B=V(0),ae=V(!1),Se=V(null);if(Se.current!==t)ae.current=!1,Se.current=t;let z=V(!1),le=V(null),X=V(null),ye=V(!1),oe=V(null),bt=V(null),He=V(null),ct=V(null),Tt=V(null),tt=V(null),We=V(null),Ee=V(null),Ve=V(!1),Kt=V(null),Ce=V(null),wt=V(null),$e=V(null),Gt=_t(()=>new Map,[]),[,nt]=at(0),be=V(!1),[ut,rt]=at(null),[fn,Yt]=at(null),[Pt,pn]=at(null),[je,De]=at(null),[$i,de]=at(0),[G,mn]=at(null),dt=V(G);dt.current=G;let Rt=V(null),Xt=V(null),Qt=V(null),Zt=V(null),w=V(null),A=V(!1),H=()=>{Xt.current=null,Qt.current=null,Zt.current=null},j=(h,b)=>{Xt.current=h,Qt.current=null,Zt.current=b==null?null:{path:h,scrollTop:b}},It=(h,b)=>{Xt.current=null,Qt.current={path:h,viewportOffset:b},Zt.current=null},Jt=V(f==="retain"&&t.isSearchOpen()),[Zn,Rs]=at(m);ls(()=>{if(!m)Rs(!1)},[m]);let Ds=V(!1),ji=Pe(()=>{Ds.current=!0,Rs((h)=>h?!1:h)},[]),[zd,Wd]=at(()=>us({controller:t,itemHeight:a,overscan:l,scrollTop:0,stickyFolders:g,viewportHeight:v})),[$d,jd]=at(!1);ls(()=>{jd(!0)},[]);let Oe=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,gn=e?.contextMenu?.triggerMode??(Oe?"right-click":"both"),vn=gn==="both"||gn==="button",Ms=e?.contextMenu?.buttonVisibility??"when-needed",Ud=gn==="both"||gn==="right-click";ze(()=>{let h=T.current;if(h==null)return;let b=(_)=>{if(!(_ instanceof CustomEvent))return;let P=_.detail?.path??null;w.current=P,Yt(P),De(P==null?null:"pointer")},N=(_)=>{if(!(_ instanceof CustomEvent))return;A.current=_.detail?.disabled===!0};return h.addEventListener("file-tree-debug-set-context-menu-trigger",b),h.addEventListener("file-tree-debug-set-scroll-suppression",N),()=>{h.removeEventListener("file-tree-debug-set-context-menu-trigger",b),h.removeEventListener("file-tree-debug-set-scroll-suppression",N)}},[]);let Kd=Pe((h,b)=>{du(Z.current,h,b)},[]),Gd=Pe((h,b)=>{du(pe.current,h,b)},[]),Yd=Pe((h)=>{x.current=h},[]),Jn=Pe((h)=>hu(h,pe.current,Z.current),[]),As=n!=null||r!=null||i!=null,{resolveIcon:Ns}=_t(()=>hc(o),[o]),er=t[qo](),yn=er.getPath(),Ui=yn!=null,ht=t.isSearchOpen(),Xd=t.getSearchValue(),W=t.getFocusedPath(),ne=t.getFocusedIndex(),en=t.getScrollRequest(),St=t.isDragAndDropEnabled(),tr=t.getDragSession(),Qd=_t(()=>tr==null?null:new Set(tr.draggedPaths),[tr]),Zd=tr?.target??null,nr=tr?.primaryPath??null,Ls=om(s),{overlayHeight:Jd,overlayRows:eh,snapshot:xe,visibleRows:Fr}=zd,Te=xe.physical.viewportHeight,it=_t(()=>({end:xe.window.endIndex,start:xe.window.startIndex}),[xe.window.endIndex,xe.window.startIndex]),rr=eh,Fs=xe.sticky.rows,tn=xe.physical.totalHeight,bn=xe.sticky.height,Br=_t(()=>new Set(Fs.map((h)=>Bn(h.row))),[Fs]),Ki=ne>=0&&ne>=it.start&&ne<=it.end,th=Pe((h,b)=>u?.({item:fu(h,b),row:h})??null,[u]),Bs=Pe((h)=>{if(cn(h==null?null:Z.current.get(h)??null))return!0;return cn(T.current)},[]),Hr=Pe((h)=>{Bs(t.focusNearestPath(h))},[t,Bs]),Hs=V(Hr);Hs.current=Hr;let wn=V(!0),Gi=V(()=>{}),Ye=Pe((h=!0)=>{let b=dt.current;if(b==null)return;if(wn.current=wn.current&&h,mn(null),e?.contextMenu?.onClose?.(),wn.current)Hr(b.path)},[e?.contextMenu,Hr]);Gi.current=Ye;let ir=Pe((h)=>{let b=h==null?null:tm(T.current,h);pn((N)=>N===b?N:b)},[]),Vs=Pe((h,b,N)=>{let _=t.getItem(b);if(_==null)return;let P=Jn(b);if(P?.dataset.fileTreeStickyRow==="true"){let F=O.current;j(b,F?.scrollTop??null),z.current=!0,rt((ce)=>ce===b?ce:b)}_.focus(),ir(P),wn.current=!0,mn({anchorRect:N?.anchorRect??null,item:fu(h,b),path:b,source:N?.source??"keyboard"})},[t,Jn,ir]),nh=Pe((h)=>{if(!d)return;if(t.isSearchOpen()){let b=O.current,N=An(b,Te);oe.current=ne<0||b==null?null:Math.max(0,Math.min(ne*a-b.scrollTop,Math.max(0,N-a))),ye.current=!0}if(t.startRenaming(h)===!1)return;De("focus"),nt((b)=>b+1)},[t,ne,a,d,Te]),Vr=Pe((h,{restoreTreeFocus:b=!0,targetOffset:N="live-overlay"}={})=>{let _=O.current;if(_==null)return!1;t.focusPath(h);let P=t.getFocusedIndex();if(P<0)return!1;let F=t.getVisibleRows(P,P)[0]??null;if(F==null)return!1;let ce=An(_,Te),L=t.getVisibleCount()*a,ee=N==="sticky-parents"?F.ancestorPaths.length*a:us({controller:t,itemHeight:a,overscan:l,scrollTop:_.scrollTop,stickyFolders:g,viewportHeight:ce}).snapshot.sticky.height;return z.current=!0,Nn(_,P,a,ce,L,ee),J.current(),Rt.current=b?h:null,!0},[t,a,l,Te,g]),rh=()=>y.current===!0||$e.current!=null||Ve.current===!0,Os=(h)=>typeof window.requestAnimationFrame==="function"?window.requestAnimationFrame(()=>{h()}):window.setTimeout(h,16),ih=(h)=>{if(h==null)return;if(typeof window.cancelAnimationFrame==="function"){window.cancelAnimationFrame(h);return}window.clearTimeout(h)},Dt=()=>{if(ct.current!=null)clearTimeout(ct.current),ct.current=null;He.current=null},Or=()=>{tt.current?.remove(),tt.current=null},or=()=>{ih(bt.current),bt.current=null,Tt.current=null},qs=(h)=>{let b=T.current?.getRootNode();if(b instanceof ShadowRoot){b.append(h);return}document.body.append(h)},sr=()=>{if(Ee.current?.(),Ee.current=null,$e.current!=null)clearTimeout($e.current),$e.current=null;if(Ve.current=!1,Kt.current=null,wt.current=null,Ce.current!=null)Ce.current.setAttribute("draggable","true"),Ce.current.style.removeProperty("touch-action"),Ce.current=null;Or(),Dt(),or(),We.current=null},qr=(h,b)=>{let N=T.current?.getRootNode(),_=au(Wp(N instanceof ShadowRoot?N:document,h,b));return t.setDragTarget(_),t.getDragSession()?.target??null},Yi=(h)=>{let b=t.getDragAndDropConfig()?.openOnDropDelay??800;if(h==null||h.kind!=="directory"||h.directoryPath==null||b<=0){Dt();return}let N=t.getItem(h.directoryPath),_=cu(N)?N:null;if(_==null||_.isExpanded()){Dt();return}let P=`${h.directoryPath}::${h.flattenedSegmentPath??""}`;if(He.current===P)return;Dt(),He.current=P,ct.current=setTimeout(()=>{let F=t.getDragSession()?.target;if(F?.kind!=="directory"||F.directoryPath!==h.directoryPath||F.flattenedSegmentPath!==h.flattenedSegmentPath)return;_.expand()},b)},zs=()=>{bt.current=null;let h=Tt.current,b=O.current;if(h==null||b==null||t.getDragSession()==null)return;let N=b.getBoundingClientRect(),_=Up(h.clientY,N);if(_===0)return;let P=Math.max(0,b.scrollHeight-b.clientHeight),F=Math.max(0,Math.min(P,b.scrollTop+_));if(F!==b.scrollTop)b.scrollTop=F,J.current();Yi(qr(h.clientX,h.clientY)),bt.current=Os(zs)},Ws=(h,b)=>{Tt.current={clientX:h,clientY:b},bt.current??=Os(zs)},oh=(h,b,N)=>{let _=h.currentTarget;if(_==null)return;if(sr(),Or(),Dt(),or(),t.startDrag(N)===!1){h.preventDefault();return}if(We.current=b,h.dataTransfer!=null){if(h.dataTransfer.effectAllowed="move",h.dataTransfer.dropEffect="move",h.dataTransfer.setData("text/plain",N),jp()){let P=lu(_),F=_.getBoundingClientRect();Object.assign(P.style,{height:`${F.height}px`,opacity:"0.85",transform:"translate3d(-9999px, 0px, 0)",width:`${F.width}px`}),qs(P),tt.current=P,h.dataTransfer.setDragImage(P,Math.max(0,h.clientX-F.left),Math.max(0,h.clientY-F.top))}}},sh=()=>{Or(),Dt(),or(),We.current=null,t.cancelDrag()},ah=(h,b,N)=>{if($e.current!=null||Ve.current)return;let _=h.touches[0],P=h.currentTarget;if(_==null||P==null)return;wt.current={clientX:_.clientX,clientY:_.clientY},Ce.current=P,P.setAttribute("draggable","false");let F=(ee={})=>{let se=ee.restoreNativeDraggable??!Ve.current;if($e.current!=null)clearTimeout($e.current),$e.current=null;if(document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",L),document.removeEventListener("touchcancel",L),Ee.current===F)Ee.current=null;if(se){if(P.setAttribute("draggable","true"),Ce.current===P)Ce.current=null;wt.current=null}},ce=(ee)=>{let se=ee.touches[0],re=wt.current;if(se==null||re==null)return;let he=se.clientX-re.clientX,Re=se.clientY-re.clientY;if(he*he+Re*Re<=ou*ou)return;F()},L=()=>{F()};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),Ee.current=F,$e.current=setTimeout(()=>{if(F({restoreNativeDraggable:!1}),t.startDrag(N)===!1){if(P.setAttribute("draggable","true"),Ce.current===P)Ce.current=null;wt.current=null;return}Ve.current=!0,Ce.current=P,P.setAttribute("draggable","false"),P.style.setProperty("touch-action","none"),We.current=b;let ee=P.getBoundingClientRect(),se=lu(P);Object.assign(se.style,{height:`${ee.height}px`,opacity:"0.85",transform:`translate3d(${ee.left}px, ${ee.top}px, 0)`,width:`${ee.width}px`}),qs(se),tt.current=se,Kt.current={x:_.clientX-ee.left,y:_.clientY-ee.top};let re=(ot)=>{let Ie=ot.touches[0];if(Ie==null)return;ot.preventDefault();let Q=Kt.current;if(Q!=null&&tt.current!=null)tt.current.style.transform=`translate3d(${Ie.clientX-Q.x}px, ${Ie.clientY-Q.y}px, 0)`;Yi(qr(Ie.clientX,Ie.clientY)),Ws(Ie.clientX,Ie.clientY)},he=(ot)=>{let Ie=ot.changedTouches[0];if(Ie!=null)qr(Ie.clientX,Ie.clientY);t.completeDrag(),sr()},Re=()=>{t.cancelDrag(),sr()};Ee.current=()=>{document.removeEventListener("touchmove",re),document.removeEventListener("touchend",he),document.removeEventListener("touchcancel",Re)},document.addEventListener("touchmove",re,{passive:!1}),document.addEventListener("touchend",he),document.addEventListener("touchcancel",Re)},zp)},$s=(h)=>{if(G!=null){if(h.key==="Escape"){Ye(),h.preventDefault(),h.stopPropagation();return}if(Zp.has(h.key))h.preventDefault(),h.stopPropagation();return}if(er.isActive()){if(h.isComposing||h.keyCode===229)return;if(h.key==="Escape")er.cancel();else if(h.key==="Enter")er.commit();else return;De("focus"),nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(d&&h.key==="F2"){nh(W??void 0),h.preventDefault(),h.stopPropagation();return}if(ht){if(h.key==="Escape")ye.current=!1,oe.current=null,t.closeSearch();else if(h.key==="Enter"){let ge=t.getFocusedPath();if(ge!=null)t.selectOnlyPath(ge);let ft=O.current,Ur=An(ft,Te);oe.current=ne<0||ft==null?null:Math.max(0,Math.min(ne*a-ft.scrollTop,Math.max(0,Ur-a))),ye.current=!0,t.closeSearch()}else if(h.key==="ArrowDown")t.focusNextSearchMatch();else if(h.key==="ArrowUp")t.focusPreviousSearchMatch();else return;De("focus"),nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(c&&Yp(h)){t.openSearch(h.key),nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}let b=Oe&&yu(h),N=Qp(h,Oe),_=N&&T.current!=null?kr(T.current):null,P=N?new Set(nm(T.current)):new Set,F=_?.dataset.fileTreeStickyPath??null,ce=_?.dataset.fileTreeStickyRow==="true"&&F!=null;if(ce&&F!==W&&P.has(F)){let ge=O.current;j(F,ge?.scrollTop??null),t.focusPath(F)}let L=t.getFocusedPath(),ee=t.getFocusedIndex(),se=t.getFocusedItem();if(se==null)return;let re=cu(se)?se:null,he=L!=null&&(Br.has(L)||ce&&F===L&&P.has(L)),Re=h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="ArrowRight"&&re!=null&&re.isExpanded(),ot=h.key==="ArrowLeft"&&he&&re!=null&&re.isExpanded(),Ie=O.current,Q=!0;if(h.shiftKey&&h.key==="ArrowDown")t.extendSelectionFromFocused(1);else if(h.shiftKey&&h.key==="ArrowUp")t.extendSelectionFromFocused(-1);else if(b&&L!=null&&ee>=0){let ge=t.getVisibleRows(ee,ee)[0]??null,ft=hu(L,pe.current,Z.current);if(ge==null||ft==null)Q=!1;else Vs(ge,L)}else if((h.ctrlKey||h.metaKey)&&vu(h))t.toggleFocusedSelection();else if((h.ctrlKey||h.metaKey)&&h.key.toLowerCase()==="a")t.selectAllVisiblePaths();else switch(h.key){case"ArrowDown":t.focusNextItem();break;case"ArrowUp":t.focusPreviousItem();break;case"ArrowRight":if(re==null||re.isExpanded())t.focusNextItem();else re.expand();break;case"ArrowLeft":if(re!=null&&re.isExpanded())re.collapse();else t.focusParentItem();break;case"Home":t.focusFirstItem();break;case"End":t.focusLastItem();break;default:Q=!1}if(!Q)return;De("focus");let me=t.getFocusedPath(),Me=me!=null&&(Br.has(me)||P.has(me)),$r=Re&&me!==L,jr=b&&ce&&F===L&&me===L;if((he||jr)&&me!=null&&($r&&Me||jr))j(me,Ie?.scrollTop??null),z.current=!0,rt((ge)=>ge===me?ge:me);else{let ge=h.key==="ArrowUp"&&he&&me!==L;if(me!=null&&(ge||ot&&me===L))It(me,im(T.current,Ie,_,L,a,bn,Te)),z.current=!0,rt((ft)=>ft===me?ft:me);else H()}nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation()};ze(()=>{if(!c||!ht)return;if(Jt.current){Jt.current=!1;return}cn(fe.current)},[ht,c]),ze(()=>{let h=x.current;switch($c({hasRenderedInput:h!=null,previousRenamingPath:X.current,renamingPath:yn})){case"reset":X.current=null;return;case"reveal-canonical":if(yn!=null)Vr(yn,{restoreTreeFocus:!1,targetOffset:"live-overlay"});return;case"ignore":return;case"focus-input":if(h!=null)Rt.current=null,X.current=yn,cn(h),h.select();return}},[it.end,it.start,yn,Vr,Br]),ze(()=>{let h=T.current;if(h==null)return;let b=null,N=()=>{if(b==null)return;clearTimeout(b),b=null},_=()=>{let ce=kr(h)?.dataset.itemPath??null;rt((L)=>L===ce?L:ce)},P=()=>{N(),z.current=!0,_()},F=(ce)=>{let L=ce.relatedTarget;if(L==null){N(),b=setTimeout(()=>{if(b=null,kr(h)!=null){_();return}z.current=!1,rt(null)},0);return}if(!(L instanceof Node)||!h.contains(L)){N(),z.current=!1,rt(null);return}let ee=L instanceof HTMLElement?L.dataset.itemPath??null:null;rt((se)=>se===ee?se:ee)};return h.addEventListener("focusin",P),h.addEventListener("focusout",F),()=>{N(),h.removeEventListener("focusin",P),h.removeEventListener("focusout",F)}},[]),ze(()=>{let h=T.current;if(h==null)return;if(xe.physical.scrollTop<=0)h.dataset.scrollAtTop="true";else delete h.dataset.scrollAtTop},[xe.physical.scrollTop]),ze(()=>{let h=null,b=O.current,N=S.current,_=T.current;if(b==null)return;K.current=An(b,v);let P=()=>{let Q=t.getVisibleCount(),me=ns(K.current,v),Me=Math.max(0,Q*a-me);if(b.scrollTop>Me)b.scrollTop=Me;Wd(us({controller:t,itemHeight:a,overscan:l,scrollTop:Math.min(b.scrollTop,Me),stickyFolders:g,viewportHeight:me}))};if(!ae.current){ae.current=!0;let Q=t.getFocusedIndex();if(Q>=0){let me=ns(K.current,v),Me=t.getVisibleRows(Q,Q)[0]??null;rs(b,Q,a,me,g&&Me!=null?Math.max(0,Math.min(Me.ancestorPaths.length*a,Math.max(0,me-a))):0)}}J.current=P;let F=t.subscribe(()=>{if(Vc(be))nt((Q)=>Q+1);P()}),ce=()=>{if(A.current===!0)return;if(N!=null)N.dataset.isScrolling??="";if(_!=null)_.dataset.isScrolling??="";if(y.current=!0,h!=null)clearTimeout(h);h=setTimeout(()=>{if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling;y.current=!1,de((Q)=>Q+1),h=null},50)},L=null,ee=()=>{if(_!=null)delete _.dataset.overlayReveal;if(L!=null)clearTimeout(L),L=null},se=()=>{if(_==null||A.current===!0)return;if(b.scrollTop>0)return;if(_.dataset.overlayReveal="true",L!=null)clearTimeout(L);L=setTimeout(()=>{ee()},200)},re=()=>{if(P(),b.scrollTop>0)ee();if(dt.current!=null&&y.current)Gi.current();if(A.current===!0){y.current=!1;return}Yt((Q)=>Q==null?Q:null),ce()},he=()=>{ce(),se()},Re=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," ","Spacebar"]),ot=(Q)=>{if(!Re.has(Q.key))return;he()};b.addEventListener("scroll",re,{passive:!0}),b.addEventListener("wheel",he,{passive:!0}),b.addEventListener("touchmove",he,{passive:!0}),b.addEventListener("keydown",ot);let Ie=typeof ResizeObserver<"u"?new ResizeObserver((Q)=>{K.current=(Q[0]==null?null:zc(Q[0]))??An(b,v),P()}):null;return Ie?.observe(b),()=>{if(J.current=()=>{},F(),b.removeEventListener("scroll",re),b.removeEventListener("wheel",he),b.removeEventListener("touchmove",he),b.removeEventListener("keydown",ot),h!=null)clearTimeout(h);if(L!=null)clearTimeout(L);if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling,delete _.dataset.overlayReveal;y.current=!1,K.current=null,Ie?.disconnect()}},[t,v,a,l,g]),ze(()=>{if(Oe||G==null)return;Ye(!1)},[Ye,Oe,G]);let js=_t(()=>G==null?null:`${G.path}::${G.source}`,[G]);ze(()=>{if(js==null){p?.clearSlotContent(wr);return}let h=dt.current;if(h==null)return;let b=C.current??I.current;if(b==null)return;let N={anchorElement:b,anchorRect:h.anchorRect??Jp(b.getBoundingClientRect()),close:(P)=>{Gi.current(P?.restoreFocus??!0)},restoreFocus:()=>{if(!wn.current)return;Hs.current(dt.current?.path??null)}},_=e?.contextMenu?.render?.(h.item,N)??null;return p?.setSlotContent(wr,_),e?.contextMenu?.onOpen?.(h.item,N),gu(_),queueMicrotask(()=>{if(_==null||!_.isConnected)return;if(document.activeElement!==_)return;gu(_)}),()=>{p?.clearSlotContent(wr)}},[js,e?.contextMenu,p]),ze(()=>{if(G!=null&&t.getItem(G.path)==null)Ye()},[Ye,G,t]),ze(()=>{if(G==null)return;let h=T.current?.getRootNode(),b=h instanceof ShadowRoot?h.host:T.current,N=(P)=>{let F=P.target;if(!(F instanceof Node))return;if(uu(P))return;if(I.current?.contains(F)===!0)return;if(b?.contains(F)===!0)return;Ye()},_=(P)=>{if(P.key==="Escape")P.preventDefault(),P.stopPropagation(),Ye()};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",_,!0)}},[Ye,G]),ze(()=>{let h=O.current,b=T.current;if(h==null||b==null){le.current=W;return}let N=W==null?null:Z.current.get(W)??null,_=kr(b),P=_?.dataset.itemPath??null,F=Ui&&x.current===_,ce=c&&fe.current===_,L=ye.current&&!ht,ee=oe.current??0,se=Rt.current,re=Xt.current,he=Qt.current,Re=Zt.current,ot=_!=null,Ie=z.current||ot,Q=le.current!==W,me=re!=null&&re===W&&W!=null,Me=!1,$r=!1;if(en!=null&&en.id!==B.current){B.current=en.id;let Qi=en.visibleIndex,Xs=t.getVisibleRows(Qi,Qi)[0]??null;if(Xs!=null){let Ah=g?Math.max(0,Math.min(Xs.ancestorPaths.length*a,Math.max(0,Te-a))):bn;Me=!0,$r=Wc(h,Qi,a,Te,tn,en.offset,Ah)}t.clearScrollRequest(en.id)}let jr=!Me&&L&&Nn(h,ne,a,Te,tn,ee),ge=!Me&&se!=null&&se===W&&Nn(h,ne,a,Te,tn,bn),ft=!Me&&he!=null&&he.path===W&&Nn(h,ne,a,Te,tn,he.viewportOffset),Ur=!Me&&Re!=null&&Re.path===W&&h.scrollTop!==Re.scrollTop;if(Ur)h.scrollTop=Re.scrollTop;if(Ur||$r||ge||ft||jr||Ie&&Q&&se!==W&&!me&&rs(h,ne,a,Te,bn))J.current();if(Me){le.current=W;return}if(!Ie){le.current=W;return}if(F){le.current=W;return}if(ce&&!L){le.current=W;return}if(N==null){if(L&&ne>=0)Nn(h,ne,a,Te,tn,ee),J.current();le.current=W;return}if(Q||L||se===W||re===W||he?.path===W||Re?.path===W||P==null||P!==W){if(cn(N),se===W)Rt.current=null;if(re===W)Xt.current=null;if(he?.path===W)Qt.current=null;if(Re?.path===W)Zt.current=null;ye.current=!1,oe.current=null}le.current=W},[t,ne,W,Ki,a,Ui,ht,it,Te,c,en,g,bn,tn,Fr]);let lh=ne>=0&&ne>=xe.visible.startIndex&&ne<=xe.visible.endIndex,ch=W!=null&&rr.some((h)=>Bn(h.row)===W),uh=lh||ch,dh=vn&&z.current===!0&&uh?W:null,hh=je==="pointer"?fn:null,nn=G?.path??w.current??hh??dh??fn,Us=G?.source==="right-click";ze(()=>{if(y.current&&G==null)return;ir(Jn(nn))},[G,Jn,it,Te,$i,rr,nn,ir,Fr]);let fh=Pe((h)=>{if(y.current)return;if(uu(h))return;let b=h.target;if(!(b instanceof HTMLElement))return;if(b.closest?.('[data-type="context-menu-trigger"]')!=null)return;let N=b.closest?.('[data-file-tree-sticky-row="true"]'),_=b.closest?.('[data-type="item"]'),P=N instanceof HTMLElement?N.dataset.fileTreeStickyPath??null:_ instanceof HTMLElement?_.dataset.itemPath??null:null;if(P!=null)De((F)=>F==="pointer"?F:"pointer");Yt((F)=>F===P?F:P)},[]),ph=Pe(()=>{Yt(null)},[]);ze(()=>{if(!St)return;let h=()=>{sr(),t.cancelDrag()};return window.addEventListener("dragend",h),()=>{window.removeEventListener("dragend",h),sr(),t.cancelDrag()}},[t,St]);let mh=(h)=>{if(!St||t.getDragSession()==null||Ve.current)return;let b=au(h.target instanceof HTMLElement?h.target:null);if(t.setDragTarget(b),Yi(t.getDragSession()?.target??null),Ws(h.clientX,h.clientY),h.dataTransfer!=null)h.dataTransfer.dropEffect="move";h.preventDefault()},gh=(h)=>{if(!St||t.getDragSession()==null||Ve.current)return;let b=h.relatedTarget;if(b instanceof Node&&T.current?.contains(b)===!0)return;Dt(),or(),t.setDragTarget(null)},vh=(h)=>{if(!St||t.getDragSession()==null||Ve.current)return;h.preventDefault(),qr(h.clientX,h.clientY),t.completeDrag(),Or(),Dt(),or(),We.current=null},ar=xe.window.height,yh=xe.window.offsetTop,bh=Math.min(0,Te-ar),wh=Math.min(0,Te-ar-bn),Ih=ut===W||ye.current,In=W!=null&&Ih&&!Ki&&ne>=0?Fr[ne]??t.getVisibleRows(ne,ne)[0]??null:null,Ks=In==null?null:is(ne,a,it,ar),Mt=We.current,Sh=nr!=null&&Mt!=null&&Mt.path===nr&&Mt.index>=it.start&&Mt.index<=it.end,lr=nr!=null&&Mt!=null&&Mt.path===nr&&!Sh&&Mt.path!==In?.path?Mt:null,Gs=lr==null?null:is(lr.index,a,it,ar),Ch=Xp((ne>=0?Fr[ne]??t.getVisibleRows(ne,ne)[0]??null:null)?.ancestorPaths.at(-1)??null),xh=ht&&W!=null?bu(s,W,!Ki):void 0,kh=G?.path??(ht?W:ut),_h=G?.path??fn,cr=Jn(nn),Xi=Oe&&vn&&!Us&&!Ui&&cr!=null&&Pt!=null&&nn!=null,Eh=Oe&&(Xi||G!=null),zr=G?.anchorRect,Ys=zr==null&&cr!=null&&Pt!=null&&(G!=null||Xi)?Pt:null,Th=zr!=null?{left:`${zr.left}px`,position:"fixed",right:"auto",top:`${zr.top}px`}:Ys!=null?{top:`${Ys}px`}:void 0,Ph=Us?{opacity:"0"}:void 0,Rh=Pe((h,b,N,_)=>{let P=Kc({event:{ctrlKey:h.ctrlKey,metaKey:h.metaKey,shiftKey:h.shiftKey},isDirectory:b.kind==="directory",isSearchOpen:ht,mode:_}),F=P.toggleDirectory&&b.kind==="directory",ce=F?t.resolveMountedDirectoryPathFromInput(N):null;if(F&&ce==null)return;let L=ce??N;switch(P.selection.kind){case"range":t.selectPathRange(L,P.selection.additive);break;case"toggle":t.togglePathSelectionFromInput(L);break;case"single":t.selectOnlyMountedPathFromInput(L);break}let ee=h.currentTarget instanceof HTMLElement?h.currentTarget:null,se=b.index>=xe.visible.startIndex&&b.index<=xe.visible.endIndex,re=_==="flow"&&se&&ee!=null&&ee.dataset.itemParked!=="true";if(t.focusMountedPathFromInput(L),re)z.current=!0,rt((he)=>he===L?he:L),De("focus");if(F)t.toggleMountedDirectoryFromInput(L);if(P.closeSearch)t.closeSearch();if(P.revealCanonical)Vr(L,{targetOffset:"sticky-parents"})},[t,ht,xe.visible.endIndex,xe.visible.startIndex,Vr]),Dh=()=>{if(y.current)return;if(!vn)return;if(nn==null||cr==null)return;let h=t.getItem(nn);if(h==null)return;ir(cr),wn.current=!0,mn({anchorRect:null,item:{kind:h.isDirectory()?"directory":"file",name:cr.getAttribute("aria-label")??nn,path:h.getPath()},path:h.getPath(),source:"button"})},Wr={contextHoverPath:_h,contextMenuButtonTriggerEnabled:vn,contextMenuButtonVisibility:Ms,contextMenuEnabled:Oe,contextMenuRightClickEnabled:Ud,contextMenuTriggerMode:gn,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:St,draggedPathSet:Qd,dragTarget:Zd,gitLaneActive:As,gitStatusByPath:n,handleRowDragEnd:sh,handleRowDragStart:oh,handleRowTouchStart:ah,ignoredGitDirectories:r,ignoredInheritanceCache:Gt,instanceId:s,itemHeight:a,onKeyDown:$s,onRowClick:Rh,openContextMenuForRow:Vs,registerButton:Kd,registerRenameInput:Yd,renameView:er,renderDecorationForRow:th,resolveIcon:Ns,shouldSuppressContextMenu:rh,visualFocusPath:kh},Mh={...Wr,registerButton:Gd};return k("div",{ref:T,id:Ls,"data-file-tree-context-menu-button-visibility":Oe&&vn?Ms:void 0,"data-file-tree-context-menu-trigger-mode":Oe?gn:void 0,"data-file-tree-has-context-menu-action-lane":Oe&&vn?"true":void 0,"data-file-tree-has-git-lane":As?"true":void 0,"data-file-tree-virtualized-root":"true",onDragLeave:St?gh:void 0,onDragOver:St?mh:void 0,onDrop:St?vh:void 0,onKeyDown:$s,onPointerLeave:Oe?ph:void 0,onPointerOver:Oe?fh:void 0,role:"tree",tabIndex:-1,style:{outline:"none",position:"relative"},children:[k("style",{"data-file-tree-guide-style":"true",dangerouslySetInnerHTML:{__html:Ch}}),k("slot",{name:br,"data-type":"header-slot"}),c?k("div",{"data-file-tree-search-container":!0,"data-open":ht?"true":"false",children:k("input",{ref:fe,"aria-activedescendant":xh,"aria-controls":Ls,placeholder:"Search…","data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Zn?"true":void 0,value:Xd,onBlur:()=>{if(f==="retain"&&!Ds.current)return;t.closeSearch()},onFocus:ji,onPointerDown:ji,onInput:(h)=>{ji();let b=h.currentTarget;t.setSearch(b.value)}})}):null,k("div",{ref:O,"data-file-tree-virtualized-scroll":"true",children:[g&&$d&&rr.length>0?k("div",{"aria-hidden":"true","data-file-tree-sticky-overlay":"true",children:k("div",{"data-file-tree-sticky-overlay-content":"true",style:{height:`${Jd}px`},children:rr.map((h,b)=>Pi(Mh,h.row,`sticky:${Bn(h.row)}`,{mode:"sticky",style:{left:"0",position:"absolute",right:"0",top:`${h.top}px`,zIndex:`${rr.length-b}`}}))})}):null,k("div",{ref:S,"data-file-tree-virtualized-list":"true",style:{height:`${tn}px`},children:[k("div",{"data-file-tree-virtualized-sticky-offset":"true","aria-hidden":"true",style:{height:`${yh}px`}}),k("div",{"data-file-tree-virtualized-sticky":"true",style:{height:`${ar}px`,top:`${bh}px`,bottom:`${wh}px`},children:[am(Wr,it,Br),In!=null&&Ks!=null?Pi(Wr,In,`parked:${In.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:nr===In.path?"none":void 0,position:"absolute",right:"0",top:`${Ks}px`}}):null,lr!=null&&Gs!=null?Pi(Wr,lr,`parked-drag:${lr.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:"none",position:"absolute",right:"0",top:`${Gs}px`}}):null]})]})]}),Oe?k("div",{ref:I,"data-type":"context-menu-anchor","data-visible":Eh?"true":"false",style:Th,children:[k("button",{ref:C,type:"button","data-type":$l,"aria-label":"Options","aria-haspopup":"menu","aria-expanded":G!=null?"true":"false","data-visible":Xi?"true":"false",onMouseDown:(h)=>{h.preventDefault()},onClick:(h)=>{if(h.preventDefault(),h.stopPropagation(),G!=null){Ye();return}Dh()},tabIndex:-1,style:Ph,children:k(Mn,{...Ns("file-tree-icon-ellipsis")})}),G!=null?k("slot",{name:wr}):null]}):null,G!=null?k("div",{"data-type":"context-menu-wash","aria-hidden":"true",onMouseDownCapture:(h)=>{h.preventDefault(),Ye()},onTouchStartCapture:(h)=>{h.preventDefault(),h.stopPropagation(),Ye()},onTouchMoveCapture:(h)=>{h.preventDefault(),h.stopPropagation()},onWheelCapture:(h)=>{h.preventDefault(),h.stopPropagation()}}):null]})}var fs={hydrateRoot:(e,t)=>{Ec(Dn(hs,t),e)},renderRoot:(e,t)=>{_i(Dn(hs,t),e)},unmountRoot:(e)=>{_i(null,e)}};function Hn(e,t){fs.renderRoot(e,t)}function wu(e,t){fs.hydrateRoot(e,t)}function Iu(e){fs.unmountRoot(e)}var Su=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#c(e);if(t==null)return;t.remove(),this.#e.delete(e)}setHost(e){if(this.#t=e,e==null)return;this.#a(e);for(let[t,n]of this.#e)this.#u(t,n)}setSlotContent(e,t){let n=this.#c(e);if(n===t){if(t!=null)this.#e.set(e,t),this.#u(e,t);return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#u(e,t)}setSlotHtml(e,t){let n=t?.trim()??"";if(n.length===0){this.setSlotContent(e,null);return}let r=this.#c(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#u(e,r);return}let i=document.createElement("div");i.innerHTML=n,this.setSlotContent(e,i)}#c(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let r of Array.from(n.children)){if(!(r instanceof HTMLElement))continue;if(r.dataset.fileTreeManagedSlot===e)return r}return null}#u(e,t){if(t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t)this.#t.appendChild(t)}#a(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let n=t.dataset.fileTreeManagedSlot;if(n==null||this.#e.has(n))continue;this.#e.set(n,t)}}};var Cu=0;function lm(e){if(e!=null&&e.length>0)return e;return Cu+=1,`pst_ft_${Cu}`}function cm({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??pi)}function xu(e){if(typeof document>"u")return;let t=document.createElement("div");t.innerHTML=e;let n=t.querySelector("svg");return n instanceof SVGElement?n:void 0}function ku(e){return e.querySelector("#file-tree-icon-chevron")instanceof SVGElement&&e.querySelector("#file-tree-icon-file")instanceof SVGElement&&e.querySelector("#file-tree-icon-dot")instanceof SVGElement&&e.querySelector("#file-tree-icon-lock")instanceof SVGElement}function _u(e){return Array.from(e.children).filter((t)=>t instanceof SVGElement)}var Er=class{static LoadedCustomComponent=!0;#e;#t;#c;#u;#a;#V;#O;#v;#r;#y=new Su;#T;#b;#m;#h;#w;#I;#f;#q;#z;#N=null;#i;#W=!1;#$=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:o,initialSearchQuery:s,icons:a,itemHeight:l,onSearchChange:d,onSelectionChange:u,overscan:f,renderRowDecoration:c,renaming:m,search:p,searchBlurBehavior:g,searchFakeFocus:v,stickyFolders:I,unsafeCSS:C,initialVisibleRowCount:y,...S}=e;this.#e=t,this.#c=lm(o),this.#h=zo(i),this.#w=a,this.#I=C,this.#u=u,this.#a=c,this.#V=m!=null&&m!==!1,this.#O=g,this.#v=p===!0,this.#r=v===!0,this.#T=jl(n,l),this.#b={itemHeight:this.#T.itemHeight,overscan:f,stickyFolders:I,initialVisibleRowCount:y},this.#t=new ic({...S,fileTreeSearchMode:r,initialSearchQuery:s,onSearchChange:d,renaming:m}),this.#z=this.#t.getSelectionVersion(),this.#N=this.#u==null?null:this.subscribe(()=>{this.#R()})}unmount(){if(this.#i!=null)Iu(this.#i),delete this.#i.dataset.fileTreeVirtualizedWrapper,this.#i=void 0;if(this.#y.clearAll(),this.#y.setHost(null),this.#m!=null)delete this.#m.dataset.fileTreeVirtualized,this.#F(this.#m),this.#m=void 0}cleanUp(){this.unmount(),this.#N?.(),this.#N=null,this.#t.destroy()}getFileTreeContainer(){return this.#m}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#T.itemHeight}getDensityFactor(){return this.#T.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=lc(this.#h,e);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Hn(n.wrapper,this.#P())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){if(Array.isArray(e))this.#t.resetPaths(e,t);else this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#s();if(t==null)return;this.#k(),Hn(t.wrapper,this.#P())}setGitStatus(e){let t=zo(e,this.#h);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Hn(n.wrapper,this.#P())}setIcons(e){this.#w=e;let t=this.#s();if(t==null)return;this.#g(t.host,t.wrapper),Hn(t.wrapper,this.#P())}hydrate({fileTreeContainer:e}){let t=this.#M(e),n=this.#L(t);this.#k(),wu(n,this.#P())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#M(t??this.#m,e),r=this.#L(n);this.#k(),Hn(r,this.#P())}#Z(){return{initialViewportHeight:cm({initialVisibleRowCount:this.#b.initialVisibleRowCount,itemHeight:this.#b.itemHeight}),itemHeight:this.#b.itemHeight,overscan:this.#b.overscan,stickyFolders:this.#b.stickyFolders}}#P(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#h?.statusByPath,ignoredGitDirectories:this.#h?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#h?.directoriesWithChanges,icons:this.#w,instanceId:this.#c,renamingEnabled:this.#V,renderRowDecoration:this.#a,searchBlurBehavior:this.#O,searchEnabled:this.#v,searchFakeFocus:this.#r,slotHost:this.#y,...this.#Z()}}#s(){let e=this.#m,t=this.#i;if(e==null||t==null)return null;return{host:e,wrapper:t}}#g(e,t){let n=e.shadowRoot;if(n!=null)this.#j(n),this.#U(n);this.#K(t)}#R(){let e=this.#u;if(e==null)return;let t=this.#t.getSelectionVersion();if(t===this.#z)return;this.#z=t,e(this.#t.getSelectedPaths())}#k(){let e=this.#e?.header?.render;if(e!=null){this.#y.setSlotContent(br,e());return}this.#y.setSlotHtml(br,this.#e?.header?.html??null)}#j(e){let t=_u(e).find((r)=>ku(r)),n=xu(Hl(Tn(this.#w).set));if(n==null)return;if(t!=null&&t.outerHTML===n.outerHTML)return;if(t!=null)t.replaceWith(n);else e.prepend(n)}#U(e){let t=_u(e),n=t.find((s)=>ku(s)),r=t.filter((s)=>s!==n),i=Tn(this.#w).spriteSheet?.trim()??"";if(i.length===0){for(let s of r)s.remove();return}let o=xu(i);if(o==null){for(let s of r)s.remove();return}if(r.length===1&&r[0].outerHTML===o.outerHTML)return;for(let s of r)s.remove();e.appendChild(o)}#K(e){let t=Tn(this.#w);if(t.colored&&Ol(t.set))e.dataset.fileTreeColoredIcons="true";else delete e.dataset.fileTreeColoredIcons}#l(e){let t=e.querySelector(`style[${Ro}]`);if(this.#f==null&&t instanceof HTMLStyleElement)this.#f=t;if(this.#I==null||this.#I===""){this.#f?.remove(),this.#f=void 0,this.#q=void 0;return}if(this.#f?.parentNode===e&&this.#q===this.#I)return;if(this.#f??=document.createElement("style"),this.#f.setAttribute(Ro,""),this.#f.parentNode!==e)e.appendChild(this.#f);this.#f.textContent=Ul(this.#I),this.#q=this.#I}#L(e){if(this.#i!=null)return this.#i;let t=e.shadowRoot;if(t==null)throw Error("FileTree requires a shadow root");let n=Array.from(t.children).filter((i)=>i instanceof HTMLDivElement&&typeof i.dataset.fileTreeId==="string"&&i.dataset.fileTreeId.length>0),r=n.find((i)=>i.dataset.fileTreeId===this.#c)??n[0];if(r!=null)this.#c=r.dataset.fileTreeId??this.#c;if(this.#i=r??document.createElement("div"),this.#i.dataset.fileTreeId=this.#c,this.#i.dataset.fileTreeVirtualizedWrapper="true",this.#g(e,this.#i),this.#i.parentNode!==t)t.appendChild(this.#i);return this.#i}#M(e,t){let n=e??this.#m??document.createElement("file-tree-container");if(t!=null&&n.parentNode!==t)t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:"open"});return vi(n,r),this.#l(r),n.dataset.fileTreeVirtualized="true",n.style.display="flex",this.#x(n),this.#y.setHost(n),this.#m=n,n}#x(e){if(e.style.getPropertyValue("--trees-item-height")==="")e.style.setProperty("--trees-item-height",`${String(this.#T.itemHeight)}px`),this.#W=!0;if(e.style.getPropertyValue("--trees-density-override")==="")e.style.setProperty("--trees-density-override",String(this.#T.factor)),this.#$=!0}#F(e){if(this.#W)e.style.removeProperty("--trees-item-height"),this.#W=!1;if(this.#$)e.style.removeProperty("--trees-density-override"),this.#$=!1}};var Eu=["--trees-bg-override: var(--surface-pane)","--trees-bg-muted-override: var(--surface-muted)","--trees-border-color-override: transparent","--trees-fg-override: var(--text)","--trees-font-family-override: var(--font-sans)","--trees-focus-ring-color-override: var(--text-muted)","--trees-padding-inline-override: 8px","--trees-scrollbar-gutter-override: 4px","--trees-search-bg-override: light-dark(var(--surface-base), var(--surface-control))","--trees-selected-bg-override: var(--selection)","--trees-selected-focused-border-color-override: var(--text-muted)"].join("; "),ps=`
|
|
1285
|
+
}`}var Gl=new WeakMap;function zf(e){let t=Gl.get(e);if(t!=null)return t;let n=document.createElement("div");n.setAttribute(Wl,"true");let r=document.createElement("div");r.style.position="relative",r.style.height="200%",n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),Gl.set(e,i),i}function Yl(e,t){if(!e.isConnected)return;let n=zf(t);if(n==null)return;let r=t.querySelector(`style[${Mo}]`),i=r instanceof HTMLStyleElement?r:document.createElement("style");if(!(r instanceof HTMLStyleElement))i.setAttribute(Mo,""),t.appendChild(i);i.textContent=`:host { ${$l}: ${n}px; }`}var vi;function Wf(e){if(typeof CSSStyleSheet<"u"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in e){if(vi==null)vi=new CSSStyleSheet,vi.replaceSync(gi(Ao));let t=!1;try{e.adoptedStyleSheets=[vi],t=!0}catch{}if(t){e.querySelector(`style[${fi}]`)?.remove();return}}if(e.querySelector("style[data-file-tree-style]")==null){let t=document.createElement("style");t.setAttribute(fi,""),t.textContent=gi(Ao),e.prepend(t)}}function yi(e,t){$f(e,t),Wf(t),Yl(e,t)}function $f(e,t){let n=e.querySelector('template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]');if(!(n instanceof HTMLTemplateElement))return;if(t.childNodes.length>0)return;if(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute("shadowrootmode"))n.remove()}if(typeof HTMLElement<"u"&&customElements.get("file-tree-container")==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let t=this.shadowRoot??this.attachShadow({mode:"open"});yi(this,t)}}if(customElements.define(Ro,e),typeof document<"u")for(let t of Array.from(document.querySelectorAll(Ro))){if(!(t instanceof HTMLElement))continue;yi(t,t.shadowRoot??t.attachShadow({mode:"open"}))}}var Xl=(e)=>e.startsWith("f::")?e.slice(3):e;function jf(e){let t=e.lastIndexOf("/");if(t<0)return{parentPath:"",baseName:e};return{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function Uf(e,t){return e===""?t:`${e}/${t}`}function Ql({files:e,path:t,isFolder:n,nextBasename:r}){let i=Xl(t),o=r.trim();if(o.length===0)return{error:"Name cannot be empty."};if(o.includes("/"))return{error:'Name cannot include "/".'};let{parentPath:s,baseName:a}=jf(i);if(o===a)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let l=Uf(s,o),d=Array(e.length),u=new Set;if(!n){let p=`${l}/`,g=!1;for(let v=0;v<e.length;v++){let I=e[v];if(I!==i&&I.startsWith(p))return{error:`"${l}" already exists.`};let C=I===i?l:I;if(u.has(C))return{error:`"${l}" already exists.`};if(u.add(C),d[v]=C,I===i)g=!0}if(!g)return{error:"Could not find the selected file to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}let f=`${i}/`,c=`${l}/`,m=0;for(let p=0;p<e.length;p++){let g=e[p],v=g===i||g.startsWith(f);if(!v&&(g===l||g.startsWith(c)))return{error:`"${l}" already exists.`};let I=v?`${l}${g.slice(i.length)}`:g;if(u.has(I))return{error:`"${l}" already exists.`};if(u.add(I),d[p]=I,v)m++}if(m===0)return{error:"Could not find the selected folder to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}function Kf(e){return e.endsWith("/")}function Gf(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/"),r=n<0?t:t.slice(n+1);return e.endsWith("/")?`${r}/`:r}function Yf(e){let t=[],n=new Set;for(let i of e){if(n.has(i))continue;n.add(i),t.push(i)}let r=new Set;for(let i of t.toSorted((o,s)=>{if(o.length!==s.length)return o.length-s.length;return o.localeCompare(s)})){let o=(i.endsWith("/")?i.slice(0,-1):i).split("/"),s=!1;for(let a=0;a<o.length-1;a+=1){let l=`${o.slice(0,a+1).join("/")}/`;if(!r.has(l))continue;s=!0;break}if(s)continue;r.add(i)}return t.filter((i)=>r.has(i))}function Zl(e,t){return t.includes(e)?Yf(t):[e]}function Jl(e,t){if(e===t)return!0;if(e==null||t==null)return!1;return e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function No(e,t){return{draggedPaths:e,target:t}}function Lo(e,t){if(t.kind!=="directory"||t.directoryPath==null)return!1;for(let n of e){if(!Kf(n))continue;if(t.directoryPath===n||t.directoryPath.startsWith(n))return!0}return!1}function Xf(e,t){if(t.kind==="root"||t.directoryPath==null)return Gf(e);return t.directoryPath}function ec(e,t){let n=e.map((r)=>{let i=Xf(r,t);if(i===r)return null;return{from:r,to:i,type:"move"}}).filter((r)=>r!=null);if(n.length===0)return null;return{operations:n,result:{draggedPaths:e,operation:n.length===1?"move":"batch",target:t}}}function Qf(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Fo(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error("FileTree requires paths or preparedInput");return{paths:r,preparedInput:void 0}}let o=i.paths;if(r==null)return{paths:o,preparedInput:i};if(!Qf(hi.preparePaths(r,n==null?{}:{sort:n}),o))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:o,preparedInput:i}}function Bo(e){return e.operation==="add"||e.operation==="remove"||e.operation==="move"||e.operation==="batch"}function Zf(e,t,n){if(e===t)return n;let r=t.endsWith("/")?t:`${t}/`;if(!e.startsWith(r))return e;return`${n.endsWith("/")?n:`${n}/`}${e.slice(r.length)}`}function Jf(e,t){if(e===t)return!0;let n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)}function Rn(e,t,n=!1){if(e==null)return null;switch(t.operation){case"add":case"expand":case"collapse":case"mark-directory-unloaded":case"begin-child-load":case"apply-child-patch":case"complete-child-load":case"fail-child-load":case"cleanup":return e;case"remove":return Jf(e,t.path)?n?e:null:e;case"move":return Zf(e,t.from,t.to);case"batch":{let r=e;for(let i of t.events)if(r=Rn(r,i,n),r==null)return null;return r}}}function bi(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function tc(e){switch(e.operation){case"add":return{...bi(e),operation:"add",path:e.path};case"remove":return{...bi(e),operation:"remove",path:e.path,recursive:e.recursive};case"move":return{...bi(e),from:e.from,operation:"move",to:e.to}}}function ep(e){return{...bi(e),events:e.events.filter((t)=>t.operation==="add"||t.operation==="remove"||t.operation==="move").map((t)=>tc(t)),operation:"batch"}}function nc(e){switch(e.operation){case"add":case"remove":case"move":return tc(e);case"batch":return ep(e);default:return null}}function wi(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function kt(e){let t=e.endsWith("/")?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split("/");return n.slice(0,-1).map((r,i)=>`${n.slice(0,i+1).join("/")}/`)}function Ii(e){return kt(e).at(-1)??null}function Ho(e,t){if(t==null)return e;return e.startsWith(t)?e.slice(t.length):e}function Sr(e){return e.endsWith("/")}var Vo=(e)=>e.toLowerCase();function rc(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n<0?t:t.slice(n+1)}function Oo(e){return e.endsWith("/")?e.slice(0,-1):e}function qo(e,t){return t&&!e.endsWith("/")?`${e}/`:e}var ic=(e)=>{let t=e.trim();if(t.length===0)return"";return(t.includes("\\")?t.replaceAll("\\","/"):t).toLowerCase()};var zo=Symbol("FILE_TREE_RENAME_VIEW"),tp=512,np=512;function rp(e){return e==="top"||e==="center"?e:"nearest"}function ip(e,t,n){if(e===0)return-1;if(n!=null){let r=t(n);if(r!=null)return r;let i=kt(n);for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s==null)continue;let a=t(s);if(a!=null)return a}}return 0}function op(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??((i)=>e.visibleIndexByPath.get(i)??null);return{focusedIndex:ip(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var oc=class e{static{Object.defineProperty(e.prototype,zo,{configurable:!0,value(){return{cancel:()=>{this.#_e()},commit:()=>{this.#Ee()},getPath:()=>this.#s,getValue:()=>this.#g,isActive:()=>this.#s!=null,setValue:(t)=>{this.#Te(t)}}},writable:!0})}#e;#t=new Set;#c=new Map;#u=null;#a=null;#V=new Map;#O=new Map;#v=-1;#r=null;#y=!1;#T=(t)=>-1;#b=new Map;#m=null;#h=null;#w=null;#I=null;#f=null;#q;#z;#N;#i=[];#W=new Int32Array(0);#$=new Int32Array(0);#Z=void 0;#P=!1;#s=null;#g="";#R=!1;#k=new Set;#j=[];#U;#K=null;#l=null;#L=null;#M=null;#x=null;#F=null;#J=null;#ke=0;#S=null;#o=new Set;#G=0;#n;#ne=0;#re=!1;#p=0;#Y;constructor(t){let{dragAndDrop:n,fileTreeSearchMode:r,initialSearchQuery:i,initialSelectedPaths:o,renaming:s,onSearchChange:a,paths:l,preparedInput:d,...u}=t,f=Fo({paths:l,preparedInput:d},"constructor",u.sort);if(this.#e=u,n!=null&&n!==!1)this.#u=n===!0?{}:n;if(this.#P=s!=null&&s!==!1,s!=null&&s!==!1&&s!==!0)this.#Z=s.canRename,this.#z=s.onError,this.#q=s.onRename;this.#N=a,this.#U=r??"hide-non-matches",this.#n=this.#oe(f.paths,f.preparedInput);let c=o?.map((p)=>this.#A(p)).filter((p)=>p!=null)??[],m=c.at(-1)??null;if(c.length>0)this.#o=new Set(c),this.#S=m,this.#G=1;if(this.#H(m,!1),i!=null)this.#X(i,!1);this.#Y=this.#Ce()}destroy(){this.#Y?.(),this.#Y=null,this.#c.clear(),this.#t.clear(),this.#b.clear(),this.#a=null,this.#ae()}focusFirstItem(){if(this.#_().length>0)this.#E(0)}focusLastItem(){if(this.#p<=0)return;this.#D(),this.#E(this.#p-1)}focusNextItem(){this.#Se(1)}focusParentItem(){if(this.#r==null)return;let t=Ii(this.#r);if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n)}focusPath(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;this.#D();let r=this.#B(n);if(r>=0)this.#E(r)}scrollToPath(t,n){let r=this.#n.getPathInfo(t)?.path??null;if(r==null)return;this.#D();let i=this.#He(r);if(i<0)return;if(this.#le(i)==null)return;if(n?.focus!==!1)this.#E(i,!1);this.#J={id:this.#ke+=1,offset:rp(n?.offset),visibleIndex:i},this.#d()}focusMountedPathFromInput(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;let r=this.#B(n);if(r>=0)this.#E(r)}focusNearestPath(t){let n=this.resolveNearestVisiblePath(t);if(n==null)return null;let r=this.#B(n);if(r>=0)return this.#E(r),this.#_()[r]??n;return null}focusPreviousItem(){this.#Se(-1)}getFocusedIndex(){return this.#v}getFocusedItem(){return this.#r==null?null:this.#ce(this.#r)}getFocusedPath(){return this.#r}getScrollRequest(){return this.#J}clearScrollRequest(t){if(this.#J?.id===t)this.#J=null}resolveNearestVisiblePath(t){let n=this.#_();if(this.#p===0)return null;if(t==null)return this.#r??n[0]??null;let r=this.#n.getPathInfo(t)?.path??t,i=this.#B(r);if(i>=0)return n[i]??r;let o=this.#Pe(r);if(o!=null)return o;return this.#r??n[0]??null}getSelectedPaths(){return[...this.#o]}getSelectionVersion(){return this.#G}getVisibleCount(){return this.#p}getVisibleRows(t,n){if(n<t||this.#p===0)return[];let r=Math.max(0,t),i=Math.min(this.#p-1,n);if(i<r)return[];let o=i-r+1;if(this.#x==null&&!this.#y&&i>=this.#i.length&&o<=np){let s=[];for(let a=r;a<=i;a+=1){let l=this.#n.getVisibleRowContext(a);if(l==null)break;s.push(this.#ue(l))}return s}if(!this.#y&&i>=this.#i.length)this.#D();if(this.#x!=null){let s=Array.from({length:i-r+1},(u,f)=>this.#ve(r+f)),a=new Map,l=s[0]??-1,d=l;for(let u=1;u<=s.length;u+=1){let f=s[u];if(f!=null&&f===d+1){d=f;continue}if(l>=0)this.#n.getVisibleSlice(l,d).forEach((c,m)=>{a.set(l+m,c)});if(f==null){l=-1,d=-1;continue}l=f,d=f}return Array.from({length:i-r+1},(u,f)=>{let c=r+f,m=this.#ve(c),p=a.get(m),g=this.#i[m];if(p==null||g==null)throw Error(`Missing projection row for filtered visible index ${String(c)}`);return this.#ie(p,c,m,{ancestorPaths:this.#fe(m),path:g})})}return this.#n.getVisibleSlice(r,i).map((s,a)=>{let l=r+a,d=this.#i[l];if(d==null)throw Error(`Missing projection path for visible index ${String(l)}`);return this.#ie(s,l,l,{ancestorPaths:this.#fe(l),path:d})})}getStickyRowCandidates(t,n){if(this.#x!=null)return null;if(this.#p===0||t<=0||n<=0)return[];let r=[];for(let i=0;i<this.#p;i+=1){let o=t+i*n,s=Math.min(this.#p-1,Math.floor(o/n)),a=this.#de(s,i)??(s>0?this.#de(s-1,i):void 0);if(a==null)break;r.push({row:this.#ue(a),subtreeEndIndex:a.subtreeEndIndex})}return r}getItem(t){let n=this.#n.getPathInfo(t);return n==null?null:this.#ce(n.path,n)}resolveMountedDirectoryPathFromInput(t){let n=this.#n.getPathInfo(t);return n?.kind==="directory"?n.path:null}toggleMountedDirectoryFromInput(t){let n=this.resolveMountedDirectoryPathFromInput(t);if(n==null)return;this.#xe(n)}selectAllVisiblePaths(){this.#D();let t=[...this.#_()];this.#C(t,this.#r??this.#S)}selectOnlyPath(t){let n=this.#A(t);if(n==null)return;this.#C([n],n)}selectOnlyMountedPathFromInput(t){this.#C([t],t)}selectPath(t){let n=this.#A(t);if(n==null||this.#o.has(n))return;this.#C([...this.#o,n])}deselectPath(t){let n=this.#A(t);if(n==null||!this.#o.has(n))return;this.#C([...this.#o].filter((r)=>r!==n))}toggleFocusedSelection(){if(this.#r==null)return;this.togglePathSelectionFromInput(this.#r)}togglePathSelection(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.deselectPath(n);return}this.selectPath(n)}togglePathSelectionFromInput(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.#C([...this.#o].filter((r)=>r!==n),n);return}this.#C([...this.#o,n],n)}selectPathRange(t,n){let r=this.#A(t);if(r==null)return;this.#D();let i=this.#S,o=i==null?-1:this.#te(i),s=this.#te(r);if(o===-1||s===-1){let f=n?[...this.#o,r]:[r];this.#C(f,r);return}let[a,l]=o<=s?[o,s]:[s,o],d=this.#_().slice(a,l+1),u=n?[...this.#o,...d]:d;this.#C(u,i)}extendSelectionFromFocused(t){if(this.#r==null)return;let n=this.#v;if(n===-1)return;let r=Math.min(this.#p-1,Math.max(0,n+t));if(r===n)return;if(!this.#y&&r>=this.#i.length)this.#D();let i=this.#_(),o=i[n]??null,s=i[r]??null;if(o==null||s==null)return;let a=new Set(this.#o);if(a.has(o)&&a.has(s))a.delete(o);else a.add(s);this.#C([...a],this.#S??o,!1),this.#E(r)}getDragAndDropConfig(){return this.#u}isDragAndDropEnabled(){return this.#u!=null}getDragSession(){if(this.#a==null)return null;return{draggedPaths:[...this.#a.draggedPaths],primaryPath:this.#a.primaryPath,target:this.#a.target==null?null:{...this.#a.target}}}startDrag(t){if(this.#u==null)return!1;let n=this.#A(t);if(n==null)return!1;if(this.#l!=null&&this.#l.length>0)return!1;let r=this.getSelectedPaths(),i=Zl(n,r);if(this.#u.canDrag?.(i)===!1)return!1;if(!r.includes(n))this.#C([n],n,!1);return this.#Q(n),this.#a={draggedPaths:i,primaryPath:n,target:null},this.#d(),!0}setDragTarget(t){let n=this.#a;if(n==null)return;let r=t;if(r!=null){let i=No(n.draggedPaths,r);if(Lo(n.draggedPaths,r)||this.#u?.canDrop?.(i)===!1)r=null}if(Jl(n.target,r))return;this.#a={...n,target:r},this.#d()}cancelDrag(){if(this.#a==null)return;this.#a=null,this.#d()}completeDrag(){let t=this.#a;if(t==null)return!1;this.#a=null;let n=t.target==null?null:{...t.target};if(n==null)return this.#d(),!1;let r=No(t.draggedPaths,n);if(Lo(t.draggedPaths,n)||this.#u?.canDrop?.(r)===!1)return this.#d(),!1;let i=ec(t.draggedPaths,n);if(i==null)return this.#d(),!1;try{if(i.operations.length===1){let o=i.operations[0];if(o==null||o.type!=="move")throw Error("Expected a single move operation for one-item drops");this.#n.move(o.from,o.to,{collision:o.collision})}else this.#Me(i.operations),this.#n.batch(i.operations)}catch(o){return this.#d(),this.#u?.onDropError?.(o instanceof Error?o.message:String(o),r),!1}return this.#u?.onDropComplete?.(i.result),!0}subscribe(t){return this.#t.add(t),t(),()=>{this.#t.delete(t)}}add(t){this.#n.add(t)}remove(t,n={}){this.#n.remove(t,n)}move(t,n,r={}){this.#n.move(t,n,r)}batch(t){this.#n.batch(t)}onMutation(t,n){let r=t,i=n,o=this.#c.get(r);if(o==null)o=new Set,this.#c.set(r,o);return o.add(i),()=>{let s=this.#c.get(r);if(s?.delete(i),s?.size===0)this.#c.delete(r)}}setSearch(t){this.#X(t,!0)}openSearch(t=""){this.#X(t,!0)}closeSearch(){this.#X(null,!0)}isSearchOpen(){return this.#l!==null}getSearchValue(){return this.#l??""}getSearchMatchingPaths(){return this.#j}focusNextSearchMatch(){this.#ye(1)}focusPreviousSearchMatch(){this.#ye(-1)}startRenaming(t=this.#r??"",n={}){if(!this.#P)return!1;let r=this.#n.getPathInfo(t);if(r==null)return!1;let i=r.path,o=Sr(i),s=Oo(i);if(this.#Z?.({isFolder:o,path:s})===!1)return!1;for(let a of kt(i))if(!this.#n.isExpanded(a))this.#n.expand(a);if(this.#C([i],i,!1),this.#l!=null)this.#X(null,!1),this.#N?.(this.#l);return this.#Q(i),this.#s=i,this.#g=rc(i),this.#R=n.removeIfCanceled??!1,this.#d(),!0}#_e(){if(this.#s==null)return;let t=this.#s,n=this.#R;if(this.#s=null,this.#g="",this.#R=!1,n){this.remove(t,Sr(t)?{recursive:!0}:void 0);return}this.#Q(t),this.#d()}#Ee(){let t=this.#s;if(t==null)return;if(this.#R&&this.#g.trim().length===0){this.#s=null,this.#g="",this.#R=!1,this.remove(t,Sr(t)?{recursive:!0}:void 0);return}let n=Sr(t),r=Ql({files:this.#n.list(),isFolder:n,nextBasename:this.#g,path:Oo(t)});if(this.#s=null,this.#g="",this.#R=!1,"error"in r){this.#Q(t),this.#z?.(r.error),this.#d();return}if(r.sourcePath===r.destinationPath){this.#Q(t),this.#d();return}this.#q?.({destinationPath:r.destinationPath,isFolder:r.isFolder,sourcePath:r.sourcePath}),this.move(qo(r.sourcePath,n),qo(r.destinationPath,n))}#Te(t){if(this.#s==null||this.#g===t)return;this.#g=t,this.#d()}resetPaths(t,n={}){let r=!Array.isArray(t),i=r?void 0:t,o=r?t:n,s=this.#n.list().length,a=this.#p,l=Fo({paths:i,preparedInput:o.preparedInput},"resetPaths",this.#e.sort),d=this.#oe(l.paths,l.preparedInput,o.initialExpandedPaths),u=this.#r,f=this.#s,c=this.getSelectedPaths(),m=this.#S;this.#Y?.(),this.#n=d,this.#b.clear(),this.#ae();let p=c.map((v)=>d.getPathInfo(v)?.path??null).filter((v)=>v!=null),g=!wi(this.#o,p);if(this.#o=new Set(p),g)this.#G+=1;if(this.#S=m==null?null:d.getPathInfo(m)?.path??null,this.#s=f==null?null:d.getPathInfo(f)?.path??null,this.#s==null)this.#g="",this.#R=!1;this.#H(u,u!=null||p.length>0||this.#S!=null),this.#Y=this.#Ce(),this.#d(),this.#we({canonicalChanged:!0,operation:"reset",pathCountAfter:l.paths.length,pathCountBefore:s,projectionChanged:!0,usedPreparedInput:o.preparedInput!=null,visibleCountDelta:this.#p-a})}#Pe(t){this.#D();let n=Ii(t),r=Ho(t,n),i=null,o=null;for(let s of this.#_()){if(Ii(s)!==n)continue;let a=Ho(s,n);if(a<r){i=s;continue}if(a>r){o=s;break}}return i??o}#B(t){let n=this.#te(t);if(n!==-1)return n;let r=kt(t);for(let i=r.length-1;i>=0;i-=1){let o=r[i];if(o==null)continue;let s=this.#te(o);if(s!==-1)return s}return this.#_().length>0?0:-1}#ce(t,n){let r=this.#b.get(t);if(r!=null)return r;let i=n??this.#n.getPathInfo(t);if(i==null)return null;let o=i.kind==="directory"?this.#Re(i.path):this.#De(i.path);return this.#b.set(i.path,o),o}#ie(t,n,r,i){return{ancestorPaths:i.ancestorPaths,depth:t.depth,flattenedSegments:t.flattenedSegments?.map((o)=>({isTerminal:o.isTerminal,name:o.name,path:o.path})),hasChildren:t.hasChildren,index:n,isExpanded:t.isExpanded,isFlattened:t.isFlattened,isFocused:i.path===this.#r,isSelected:this.#o.has(i.path),kind:t.kind,level:t.depth,name:t.name,path:i.path,posInSet:i.posInSet??this.#W[r]??0,setSize:i.setSize??this.#$[r]??0}}#ue(t){return this.#ie(t.row,t.index,t.index,{ancestorPaths:t.ancestorPaths,path:t.row.path,posInSet:t.posInSet,setSize:t.setSize})}#de(t,n){let r=this.#n.getVisibleRowContext(t);if(r==null)return;let i=r.ancestorRows[n];if(i!=null)return i;return n===r.ancestorRows.length&&r.row.kind==="directory"&&r.row.isExpanded?r:void 0}#he(t){let n=this.#V.get(t);if(n!=null)return n;let r=this.#T(t),i=r<0?[]:[...this.#he(r),r];return this.#V.set(t,i),i}#fe(t){let n=this.#O.get(t);if(n!=null)return n;let r=this.#he(t).map((i)=>this.#i[i]??"").filter((i)=>i!=="");return this.#O.set(t,r),r}#pe(t){this.#n.collapse(t)}#C(t,n=this.#S,r=!0){let i=[...new Set(t)],o=!wi(this.#o,i),s=this.#S!==n;if(!o&&!s)return;if(this.#o=new Set(i),this.#S=n,o)this.#G+=1;if(r)this.#d()}#Re(t){return{collapse:()=>{this.#pe(t)},deselect:()=>{this.deselectPath(t)},expand:()=>{this.#Ie(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!0,isExpanded:()=>this.#n.isExpanded(t),isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)},toggle:()=>{this.#xe(t)}}}#De(t){return{deselect:()=>{this.deselectPath(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!1,isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)}}}#Me(t){let n=this.#n.list();this.#oe(n).batch(t)}#oe(t,n,r){return new hi({...this.#e,paths:t,preparedInput:n==null?void 0:n,...r!==void 0?{initialExpandedPaths:r}:{}})}#se(){if(this.#I!=null)return this.#I;return this.#I=this.#n.list(),this.#I}#Ae(){if(this.#w!=null)return this.#w;let t=new Set;for(let n of this.#se()){t.add(n);for(let r of kt(n))t.add(r)}return this.#w=[...t].sort(),this.#w}#Ne(){if(this.#f!=null)return this.#f;return this.#f=this.#se().map(Vo),this.#f}#ee(){if(this.#m!=null)return this.#m;return this.#m=this.#Ae().filter((t)=>t.endsWith("/")),this.#m}#Le(){if(this.#h!=null)return this.#h;return this.#h=this.#ee().map(Vo),this.#h}#ae(){this.#m=null,this.#h=null,this.#w=null,this.#I=null,this.#f=null}#Fe(){return this.#ee().filter((t)=>this.#n.isExpanded(t))}#me(t){let n=new Set(this.#K??[]);if(t)for(let r of this.#o)for(let i of kt(r))n.add(i);this.#ge(n)}#ge(t){this.#re=!0;try{for(let n of this.#ee()){let r=t.has(n),i=this.#n.isExpanded(n);if(r&&!i)this.#n.expand(n);else if(!r&&i)this.#n.collapse(n)}}finally{this.#re=!1}}#Be(){if(this.#l==null||this.#l.length===0){this.#j=[],this.#x=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let t=this.#i;if(this.#j=t.filter((o)=>this.#k.has(o)),this.#U!=="hide-non-matches"||this.#k.size===0){this.#x=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let n=[],r=[],i=new Map;for(let[o,s]of t.entries()){if(this.#L?.has(s)!==!0)continue;i.set(s,r.length),n.push(o),r.push(s)}this.#x=n,this.#F=r,this.#M=i,this.#p=r.length}#_(){return this.#F??this.#i}#He(t){if(this.#F!=null)return this.#M?.get(t)??-1;return this.#n.getVisibleIndex(t)??-1}#ve(t){return this.#x?.[t]??t}#te(t){let n=this.#M?.get(t);if(n!=null)return n;return this.#n.getVisibleIndex(t)??-1}#ye(t){let n=this.#j;if(n.length===0)return;let r=this.#r,i=r==null?-1:n.indexOf(r),o=n[i<0?t>0?0:n.length-1:Math.min(n.length-1,Math.max(0,i+t))];if(o!=null)this.focusPath(o)}#X(t,n){let r=t==null?null:ic(t),i=this.#l;if(i===r)return;if(i==null&&r!=null)this.#K=this.#Fe();if(this.#l=r,r==null)this.#me(!0),this.#K=null,this.#k.clear(),this.#L=null,this.#H(this.#r,!0);else if(r.length===0)this.#me(!1),this.#k.clear(),this.#L=null,this.#H(this.#r,!0);else{let o=this.#be();this.#H(o,!0)}if(n)this.#N?.(this.#l),this.#d()}#be(){if(this.#l==null||this.#l.length===0)return this.#k.clear(),this.#r;let t=this.#l,n=this.#se(),r=this.#Ne(),i=[],o=new Set,s=null;for(let f=0;f<n.length;f+=1){if(!r[f].includes(t))continue;let c=n[f];i.push(c),o.add(c),s??=c}let a=this.#ee(),l=this.#Le();for(let f=0;f<a.length;f+=1){if(!l[f].includes(t))continue;let c=a[f];if(o.has(c))continue;i.push(c),o.add(c),s??=c}this.#k=o;let d=this.#U==="hide-non-matches"&&i.length>0?new Set:null;this.#L=d;let u=this.#U==="expand-matches"?new Set(this.#K??[]):new Set;for(let f of i){if(d!=null)d.add(f);if(f.endsWith("/"))u.add(f);for(let c of kt(f))if(u.add(c),d!=null)d.add(c)}return this.#ge(u),s??this.#r}#d(){for(let t of this.#t)t()}#we(t){this.#c.get(t.operation)?.forEach((n)=>{n(t)}),this.#c.get("*")?.forEach((n)=>{n(t)})}#Ie(t){for(let n of kt(t)){if(this.#n.isExpanded(n))continue;this.#n.expand(n)}if(!this.#n.isExpanded(t))this.#n.expand(t)}#Se(t){let n=this.#p;if(n===0)return;let r=this.#v===-1?0:this.#v,i=Math.min(n-1,Math.max(0,r+t));if(i!==r||this.#v===-1){if(!this.#y&&this.#x==null&&i>=this.#i.length)this.#D();this.#E(i)}}#H(t,n=!0){let r=this.#n.getVisibleCount();this.#ne=r;let i=op(this.#n.getVisibleTreeProjectionData(n?void 0:Math.min(r,tp)),t,n?(o)=>this.#n.getVisibleIndex(o):void 0);this.#V.clear(),this.#O.clear(),this.#y=i.paths.length>=r,this.#T=i.getParentIndex,this.#i=i.paths,this.#W=i.posInSetByIndex,this.#$=i.setSizeByIndex,this.#Be(),this.#v=t==null?this.#_().length>0?0:-1:this.#B(t),this.#r=this.#v<0?null:this.#le(this.#v)}#le(t){let n=this.#_()[t];if(n!=null)return n;if(this.#x!=null)return null;return this.#n.getVisibleRowContext(t)?.row.path??null}#A(t){return this.#n.getPathInfo(t)?.path??null}#Q(t){if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n,!1)}#E(t,n=!0){let r=this.#le(t);if(r==null)return;if(this.#v===t&&this.#r===r)return;if(this.#v=t,this.#r=r,n)this.#d()}#D(){if(this.#y)return;this.#H(this.#r,!0)}#Ve(t){let n=Rn(this.#s,t);if(n==null&&this.#s!=null)this.#g="";this.#s=n;let r=Rn(this.#r,t,!0),i=[...this.#o].map((l)=>Rn(l,t)).filter((l)=>l!=null).map((l)=>this.#n.getPathInfo(l)?.path??null).filter((l)=>l!=null),o=Rn(this.#S,t),s=o==null?null:this.#n.getPathInfo(o)?.path??null,a=[...new Set(i)];if(!wi(this.#o,a))this.#o=new Set(a),this.#G+=1;return this.#S=s,r}#Ce(){return this.#n.on("*",(t)=>{if(this.#re)return;if(t.canonicalChanged)this.#b.clear(),this.#ae();if(this.#a!=null&&Bo(t))this.#a=null;let n=Bo(t)?this.#Ve(t):this.#r,r=this.#l!=null&&this.#l.length>0?this.#be():this.#l===""?this.#r:n,i=this.#l!=null||t.operation!=="expand"&&t.operation!=="collapse";this.#H(r,i),this.#d();let o=nc(t);if(o!=null)this.#we(o)})}#xe(t){if(this.#n.isExpanded(t)){this.#pe(t);return}this.#Ie(t)}};var sc=(e)=>{if(e==null||e.length===0)return"0";let t=`${e.length}`;for(let n of e)t+=`\x00${n.path}\x00${n.status}`;return t};function ac(e){let t=e.endsWith("/"),n="",r=-1;for(let i=0;i<=e.length;i+=1){if(!(e[i]==="/"||i===e.length)){if(r===-1)r=i;continue}if(r===-1)continue;if(n!=="")n+="/";n+=e.slice(r,i),r=-1}if(n==="")return null;return{isDirectory:t,path:n}}function lc(e){let t=e.endsWith("/")?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let i=t.indexOf("/",r);if(i===-1)break;n.push(t.slice(0,i+1)),r=i+1}return n}function sp(e,t){return t?`${e}/`:e}function Wo(e,t=null){let n=sc(e==null?void 0:[...e]);if(n==="0")return null;if(t?.signature===n)return t;let r=new Map,i=new Set,o=new Set,s=new Map;for(let a of e??[]){let l=uc(a);if(l==null)continue;hc({canonicalPath:l.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,isDirectory:l.isDirectory,status:a.status,statusByPath:r})}if(r.size===0)return null;return{changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,signature:n,statusByPath:r}}function cc(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),o=new Set(e?.directoriesWithChanges),s=new Set(e?.ignoredDirectoryPaths),a=new Map(e?.changeCountByDirectoryPath),l=!1;for(let d of n){let u=dc(d);if(u==null)continue;l=ap({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,statusByPath:i})||l}for(let d of r){let u=uc(d);if(u==null)continue;l=hc({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,isDirectory:u.isDirectory,status:d.status,statusByPath:i})||l}if(!l)return e;if(i.size===0)return null;return{changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,signature:up(i),statusByPath:i}}function uc(e){return dc(e.path)}function dc(e){let t=ac(e);if(t==null)return;return{canonicalPath:sp(t.path,t.isDirectory),isDirectory:t.isDirectory}}function ap({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let o=i.get(e);if(o==null)return!1;if(i.delete(e),o==="ignored"&&e.endsWith("/"))r.delete(e);return cp(t,n,e),!0}function hc({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:o,statusByPath:s}){let a=s.get(e);if(a===o)return!1;if(a==null)lp(t,n,e);if(s.set(e,o),o==="ignored"&&i)r.add(e);else if(i)r.delete(e);return!0}function lp(e,t,n){for(let r of lc(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function cp(e,t,n){for(let r of lc(n)){let i=(e.get(r)??0)-1;if(i>0)e.set(r,i);else e.delete(r),t.delete(r)}}function up(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\x00${n}\x00${r}`;return t}var dp=(e)=>e.trim().toLowerCase(),hp=(e)=>e.split("/").at(-1)??e,fp=(e)=>{let t=e.toLowerCase().split("."),n=[];for(let r=1;r<t.length;r+=1)n.push(t.slice(r).join("."));return n};function Cr(e,t){if(typeof e==="string")return{name:e,remappedFrom:t};return{...e,remappedFrom:t}}function fc(e){let t=Pn(e),n=t.remap,r=new Map;for(let[a,l]of Object.entries(t.byFileName??{}))r.set(a.toLowerCase(),l);let i=new Map;for(let[a,l]of Object.entries(t.byFileExtension??{}))i.set(dp(a),l);let o=Object.entries(t.byFileNameContains??{}).map(([a,l])=>[a.toLowerCase(),l]);return{resolveIcon:(a,l)=>{if(a==="file-tree-icon-file"&&l!=null){let u=hp(l),f=u.toLowerCase(),c=r.get(f);if(c!=null)return Cr(c,a);for(let[g,v]of o)if(f.includes(g))return Cr(v,a);let m=fp(u);for(let g of m){let v=i.get(g);if(v!=null)return Cr(v,a)}let p=zl(t.set,u,m);if(p!=null&&t.set!=="none"){if(p==="default"){let g=n?.[a];if(g!=null)return Cr(g,a)}return{name:Ol(p),remappedFrom:a,token:p}}}let d=n?.[a];if(d==null)return{name:a};return Cr(d,a)}}}var Y,yc,pp,cn,pc,ki,bc,wc,Ko,$o,jo,mp,xr={},Ic=[],_i=Array.isArray,Go=Ic.slice,qt=Object.assign;function Yo(e){e&&e.parentNode&&e.remove()}function Mn(e,t,n){var r,i,o,s={};for(o in t)o=="key"?r=t[o]:o=="ref"&&typeof e!="function"?i=t[o]:s[o]=t[o];return arguments.length>2&&(s.children=arguments.length>3?Go.call(arguments,2):n),Ci(e,s,r,i,null)}function Ci(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i==null?++yc:i,__i:-1,__u:0};return i==null&&Y.vnode!=null&&Y.vnode(o),o}function pt(e){return e.children}function xi(e,t){this.props=e,this.context=t,this.__g=0}function Dn(e,t){if(t==null)return e.__?Dn(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Dn(e):null}function Sc(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return Sc(e)}}function mc(e){(8&e.__g||!(e.__g|=8)||!cn.push(e)||ki++)&&pc==Y.debounceRendering||((pc=Y.debounceRendering)||queueMicrotask)(gp)}function gp(){for(var e,t,n,r,i,o,s,a,l=1;cn.length;)cn.length>l&&cn.sort(bc),e=cn.shift(),l=cn.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,o=[],s=[],(a=t.__P)&&((n=qt({},r)).__v=r.__v+1,Y.vnode&&Y.vnode(n),Xo(a,n,r,t.__n,a.namespaceURI,32&r.__u?[i]:null,o,i==null?Dn(r):i,!!(32&r.__u),s,a.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,kc(o,n,s),n.__e!=i&&Sc(n)));ki=0}function Cc(e,t,n,r,i,o,s,a,l,d,u,f){var c,m,p,g,v,I,C,y=r&&r.__k||Ic,S=t.length;for(l=vp(n,t,y,l,S),c=0;c<S;c++)(p=n.__k[c])!=null&&(m=p.__i==-1?xr:y[p.__i]||xr,p.__i=c,I=Xo(e,p,m,i,o,s,a,l,d,u,f),g=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Qo(m.ref,null,p),u.push(p.ref,p.__c||g,p)),v==null&&g!=null&&(v=g),(C=!!(4&p.__u))||m.__k===p.__k?l=xc(p,l,e,C):typeof p.type=="function"&&I!==void 0?l=I:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=v,l}function vp(e,t,n,r,i){var o,s,a,l,d,u=n.length,f=u,c=0;for(e.__k=Array(i),o=0;o<i;o++)(s=t[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(l=o+c,(s=e.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?Ci(null,s,null,null,null):_i(s)?Ci(pt,{children:s},null,null,null):s.constructor==null&&s.__b>0?Ci(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,(d=s.__i=yp(s,n,l,f))!=-1&&(f--,(a=n[d])&&(a.__u|=2)),a==null||a.__v==null?(d==-1&&(i>u?c--:i<u&&c++),typeof s.type!="function"&&(s.__u|=4)):d!=l&&(d==l-1?c--:d==l+1?c++:(d>l?c--:c++,s.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<u;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==r&&(r=Dn(a)),Ec(a,a));return r}function xc(e,t,n,r){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=xc(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Dn(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function yp(e,t,n,r){var i,o,s,a=e.key,l=e.type,d=t[n],u=d!=null&&(2&d.__u)==0;if(d===null&&e.key==null||u&&a==d.key&&l==d.type)return n;if(r>(u?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((d=t[s=i>=0?i--:o++])!=null&&(2&d.__u)==0&&a==d.key&&l==d.type)return s}return-1}function gc(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":n}function Si(e,t,n,r,i){var o;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||gc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||gc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(wc,"$1")),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||(e.__l={}),e.__l[t+o]=n,n?r?n.l=r.l:(n.l=Ko,e.addEventListener(t,o?jo:$o,o)):e.removeEventListener(t,o?jo:$o,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n==null?"":n;break e}catch(s){}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function vc(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=Ko++;else if(t.u<n.l)return;return n(Y.event?Y.event(t):t)}}}function Xo(e,t,n,r,i,o,s,a,l,d,u){var f,c,m,p,g,v,I,C,y,S,x,T,O,fe,Z,pe,J,K,B,ae,Se,z=t.type;if(t.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),n.__c.__z&&(a=t.__e=n.__e=(o=n.__c.__z)[0],n.__c.__z=null)),(f=Y.__b)&&f(t);e:if(typeof z=="function")try{if(C=t.props,y="prototype"in z&&z.prototype.render,S=(f=z.contextType)&&r[f.__c],x=f?S?S.props.value:f.__:r,n.__c?2&(c=t.__c=n.__c).__g&&(c.__g|=1,I=!0):(y?t.__c=c=new z(C,x):(t.__c=c=new xi(C,x),c.constructor=z,c.render=wp),S&&S.sub(c),c.props=C,c.state||(c.state={}),c.context=x,c.__n=r,m=!0,c.__g|=8,c.__h=[],c._sb=[]),y&&c.__s==null&&(c.__s=c.state),y&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=qt({},c.__s)),qt(c.__s,z.getDerivedStateFromProps(C,c.__s))),p=c.props,g=c.state,c.__v=t,m)y&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),y&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(y&&z.getDerivedStateFromProps==null&&C!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(C,x),!(4&c.__g)&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(C,c.__s,x)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(c.props=C,c.state=c.__s,c.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(le){le&&(le.__=t)}),T=0;T<c._sb.length;T++)c.__h.push(c._sb[T]);c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(C,c.__s,x),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,v)})}if(c.context=x,c.props=C,c.__P=e,c.__g&=-5,O=Y.__r,fe=0,y){for(c.state=c.__s,c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),Z=0;Z<c._sb.length;Z++)c.__h.push(c._sb[Z]);c._sb=[]}else do c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(8&c.__g&&++fe<25);c.state=c.__s,c.getChildContext!=null&&(r=qt({},r,c.getChildContext())),y&&!m&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(p,g)),pe=f,f!=null&&f.type===pt&&f.key==null&&(pe=_c(f.props.children)),a=Cc(e,_i(pe)?pe:[pe],t,n,r,i,o,s,a,l,d,u),t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__g&=-4)}catch(le){if(t.__v=null,l||o!=null)if(le.then){for(J=0,K=!1,t.__u|=l?160:128,t.__c.__z=[],B=0;B<o.length;B++)(ae=o[B])==null||K||(ae.nodeType==8&&ae.data=="$s"?(J>0&&t.__c.__z.push(ae),J++,o[B]=null):ae.nodeType==8&&ae.data=="/$s"?(--J>0&&t.__c.__z.push(ae),K=J===0,a=o[B],o[B]=null):J>0&&(t.__c.__z.push(ae),o[B]=null));if(!K){for(;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__c.__z=[a]}t.__e=a}else{for(Se=o.length;Se--;)Yo(o[Se]);Uo(t)}else t.__e=n.__e,t.__k=n.__k,le.then||Uo(t);Y.__e(le,t,n)}else a=t.__e=bp(n.__e,t,n,r,i,o,s,l,d,u);return(f=Y.diffed)&&f(t),128&t.__u?void 0:a}function Uo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(Uo)}function kc(e,t,n){for(var r=0;r<n.length;r++)Qo(n[r],n[++r],n[++r]);Y.__c&&Y.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){Y.__e(o,i.__v)}})}function _c(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:_i(e)?e.map(_c):qt({},e)}function bp(e,t,n,r,i,o,s,a,l,d){var u,f,c,m,p,g,v,I,C=n.props,y=t.props,S=t.type;if(S=="svg"?i="http://www.w3.org/2000/svg":S=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!S&&(S?p.localName==S:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(S==null)return d.createTextNode(y);e=d.createElementNS(i,S,y.is&&y),a&&(Y.__m&&Y.__m(t,o),a=!1),o=null}if(S==null)C===y||a&&e.data==y||(e.data=y);else{if(o=o&&Go.call(e.childNodes),C=n.props||xr,!a&&o!=null)for(C={},u=0;u<e.attributes.length;u++)C[(p=e.attributes[u]).name]=p.value;for(u in C)if(p=C[u],u=="children");else if(u=="dangerouslySetInnerHTML")c=p;else if(!(u in y)){if(u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y)continue;Si(e,u,null,p,i)}for(u in I=1&n.__u,y)p=y[u],u=="children"?m=p:u=="dangerouslySetInnerHTML"?f=p:u=="value"?g=p:u=="checked"?v=p:a&&typeof p!="function"||C[u]===p&&!I||Si(e,u,p,C[u],i);if(f)a||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=""),Cc(S=="template"?e.content:e,_i(m)?m:[m],t,n,r,S=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Dn(n,0),a,l,d),o!=null)for(u=o.length;u--;)Yo(o[u]);a||(u="value",S=="progress"&&g==null?e.removeAttribute("value"):g==null||g===e[u]&&(S!=="progress"||g)||Si(e,u,g,C[u],i),u="checked",v!=null&&v!=e[u]&&Si(e,u,v,C[u],i))}return e}function Qo(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){Y.__e(i,n)}}function Ec(e,t,n){var r,i;if(Y.unmount&&Y.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Qo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){Y.__e(o,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ec(r[i],t,n||typeof e.type!="function");n||Yo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function wp(e,t,n){return this.constructor(e,n)}function Ei(e,t){var n,r,i,o;t==document&&(t=document.documentElement),Y.__&&Y.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=Mn(pt,null,[e]),i=[],o=[],Xo(t,e,r||xr,xr,t.namespaceURI,r?null:t.firstChild?Go.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o,t.ownerDocument),kc(i,e,o)}function Tc(e,t){e.__u|=32,Ei(e,t)}Y={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(a){e=a}}throw ki=0,e}},yc=0,pp=function(e){return e!=null&&e.constructor==null},xi.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=qt({},this.state),typeof e=="function"&&(e=e(qt({},n),this.props)),e&&qt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),mc(this))},xi.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),mc(this))},xi.prototype.render=pt,cn=[],ki=0,bc=function(e,t){return e.__v.__b-t.__v.__b},wc=/(PointerCapture)$|Capture$/i,Ko=0,$o=vc(!1),jo=vc(!0),mp=0;var Ip=0;function k(e,t,n,r,i,o){t||(t={});var s,a,l=t;if("ref"in l&&typeof e!="function")for(a in l={},t)a=="ref"?s=t[a]:l[a]=t[a];var d={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ip,__i:-1,__u:0,__source:i,__self:o};return Y.vnode&&Y.vnode(d),d}var Sp=16,Cp=16,xp={};function An({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:o,label:s,alignCapitals:a=!1}){let l=`#${e.replace(/^#/,"")}`,{width:d,height:u,viewBox:f}=xp[e]??{width:Sp,height:Cp},c=r??d,m=i??u,p=o??f??`0 0 ${d} ${u}`;return k("svg",{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":a,...s!=null?{"aria-label":s,role:"img"}:{"aria-hidden":!0},viewBox:p,width:c,height:m,children:k("use",{href:l})})}var Pc=(e)=>e!==void 0&&/\s/.test(e),kp=(e,t)=>{let n=(r)=>Pc(e[r-1])||Pc(e[r]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let o=t+r;if(o<e.length&&!n(o))return o}return t},Dc=(e)=>kp(e,Math.ceil(e.length/2)),Rc=(e)=>{if(e.length<2)return[e,""];let t=Dc(e);return[e.slice(0,t),e.slice(t)]},_p=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf(".")+1,n=e.length-t>10,r=t>=1&&!n?t:Dc(e);return[e.slice(0,r),e.slice(r)]},Ep=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf("/")+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},Tp=(e,{splitIndex:t}={})=>{if(typeof t!=="number"){let n=Math.ceil(e.length/2);return[e.slice(0,n),e.slice(n)]}return[e.slice(0,t),e.slice(t)]},Pp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},Rp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=t;return[e.slice(0,n),e.slice(n)]};function Dp({children:e,marker:t,variant:n="default"}){return k("div",{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:k("div",{"data-truncate-marker":!0,children:typeof t==="function"?t({children:e}):n==="fade"?k("span",{"data-truncate-fade":!0}):t})})}function Mp(e){let{mode:t,children:n}=e;return k("div",{children:[k("div",{"data-truncate-content":"visible",children:t==="fruncate"?k("span",{children:n}):n}),k("div",{"data-truncate-content":"overflow","aria-hidden":!0,children:t==="fruncate"?k("span",{children:n}):n})]})}function Mc({children:e,mode:t="truncate",marker:n="…",variant:r="default",...i}){let o=k(Mp,{mode:t,children:e},"content"),s=k(Dp,{marker:n,mode:t,variant:r},"marker");return k("div",{"data-truncate-container":t,"data-truncate-variant":r,...i,children:k("div",{"data-truncate-grid":!0,children:t==="truncate"?[o,s]:[s,o,k("div",{"data-truncate-fill":!0},"fill")]})})}function kr({children:e,...t}){return k(Mc,{mode:"truncate",...t,children:e})}function Zo({children:e,...t}){return k(Mc,{mode:"fruncate",...t,children:e})}function Ac({children:e,contents:t,priority:n="end",split:r="center",minimumLength:i=12,className:o,style:s,...a}){let l=null,d=null;if(Array.isArray(t)){if(t.length!==2)return console.error("MiddleTruncate: contents must be an array of two items"),null;l=k(kr,{...a,children:t[0]}),d=k(Zo,{...a,children:t[1]})}else{if(typeof e!=="string")return console.error("MiddleTruncate: children must be a string"),null;if(e.length===0)return k("div",{className:o,style:s});if(e.length<i)if(n==="end")return k(Zo,{...a,className:o,style:s,children:e});else return k(kr,{...a,className:o,style:s,children:e});let u=null,f=null,c=null;if(typeof r==="string"){if(r==="center")u=Rc;else if(r==="extension")u=_p;else if(r==="leaf-path")u=Ep}else if(typeof r==="number")u=Tp,f=r;else if(Array.isArray(r)){let[S,x]=r;if(c=x,S==="last")u=Pp;else if(S==="first")u=Rp}else if(typeof r==="function")u=r;u??=Rc;let[m,p]=u(e,{priority:n,variant:a.variant,splitIndex:typeof f==="number"?f:void 0,splitOffset:typeof c==="number"?c:void 0}),g=m.length>=p.length,v=n==="equal"&&!g,I=n==="equal"&&g,C={},y={};if(v)C.marker="";if(I)y.marker="";l=k(kr,{...a,...C,children:m}),d=k(Zo,{...a,...y,children:p})}return k("div",{"data-truncate-group-container":"middle",className:o,style:s,children:[k("div",{"data-truncate-segment-priority":n==="start"||n==="equal"?"1":"2",children:l}),k("div",{"data-truncate-segment-priority":n==="end"||n==="equal"?"1":"2",children:d})]})}var Jo={endIndex:-1,startIndex:-1};function Ap(e,t,n){return Math.min(Math.max(e,t),n)}function Nc(e,t){return e<0||t<e?Jo:{endIndex:t,startIndex:e}}function es(e){return e.startIndex<0||e.endIndex<e.startIndex}function Np(e,t){return es(e)?0:(e.endIndex-e.startIndex+1)*t}function Lc(e,t,n){if(t<=0)return-1;let r=t*n;if(e<=0)return 0;if(e>=r)return t;return Math.floor(e/n)}function Lp(e,t,n){if(t<=0||e<=0)return-1;if(e>=t*n)return t-1;return Math.ceil(e/n)-1}function Fp(e){let t=new Map;return e.forEach((n,r)=>{if(n.kind!=="directory"||!n.isExpanded)return;let i=n.ancestorPaths.length,o=t.get(i);if(o==null){t.set(i,[r]);return}o.push(r)}),t}function Bp(e,t){let n=0,r=e.length-1,i=-1;while(n<=r){let o=Math.floor((n+r)/2),s=e[o];if(s==null)break;if(s<=t){i=o,n=o+1;continue}r=o-1}return i}function Hp(e){let t=new Map,n=[];for(let i=0;i<e.length;i+=1){let o=e[i];if(o==null)continue;let s=o.kind==="directory"&&o.isExpanded?[...o.ancestorPaths,o.path]:o.ancestorPaths,a=0;while(a<n.length&&a<s.length&&n[a]===s[a])a+=1;for(let l=n.length-1;l>=a;l-=1){let d=n[l];if(d!=null)t.set(d,i-1)}n.length=a;for(let l=a;l<s.length;l+=1){let d=s[l];if(d!=null)n.push(d)}}let r=e.length-1;for(let i of n)t.set(i,r);return t}function ts(e,t,n){if(e.length===0||t<=0)return[];let r=Hp(e),i=Fp(e),o=[];for(let s=0;s<e.length;s+=1){let a=i.get(s);if(a==null||a.length===0)break;let l=t+s*n,d=Bp(a,Math.min(e.length-1,Math.floor(l/n))),u=null;while(d>=0){let f=a[d],c=f==null?null:e[f]??null;if(c!=null&&(s===0||c.ancestorPaths[s-1]===o[s-1]?.path)){u=c;break}d-=1}if(u==null)break;o.push(u)}return o.map((s,a)=>{let l=a*n,d=(r.get(s.path)??e.length-1)+1;if(d>=e.length)return{row:s,top:l};let u=d*n-t;return{row:s,top:Math.min(l,u-n)}}).filter((s)=>s.top+n>0)}function Fc(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),o=Math.max(0,Math.floor(t.overscan)),s=Math.max(0,r-i),a=Ap(t.scrollTop,0,s),l=t.stickyRows??ts(e,a,t.itemHeight),d=l.reduce((T,O)=>Math.max(T,O.top+t.itemHeight),0),u=Math.min(r,a+d),f=Math.max(0,i-d),c=Math.max(0,r-u),m=Lc(a,n,t.itemHeight),p=Lc(u,n,t.itemHeight),g=d<=0||m<0||m>=n?-1:m,v=g===-1?-1:Math.min(n-1,p-1),I=g===-1||v<g?0:v-g+1,C=f<=0||p>=n?Jo:Nc(p,Lp(u+f,n,t.itemHeight)),y=v+1,S=es(C)?Jo:Nc(Math.max(y,C.startIndex-o),Math.min(n-1,C.endIndex+o)),x=Np(S,t.itemHeight);return{occlusion:{firstOccludedIndex:g,lastOccludedIndex:v,occludedCount:I},physical:{itemHeight:t.itemHeight,maxScrollTop:s,overscan:o,scrollTop:a,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:c,paneHeight:f,paneTop:u},sticky:{height:d,rows:l},visible:C,window:{endIndex:S.endIndex,height:x,offsetTop:es(S)?0:S.startIndex*t.itemHeight,startIndex:S.startIndex}}}var Bc={added:"A",deleted:"D",ignored:null,modified:"M",renamed:"R",untracked:"U"},Hc={added:"Git status: added",deleted:"Git status: deleted",ignored:"Git status: ignored",modified:"Git status: modified",renamed:"Git status: renamed",untracked:"Git status: untracked"},Vc="Contains git status items";function Oc(e){if(e.current)return!0;return e.current=!0,!1}function ns(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),a=n*r,l=a+r;if(a<t+s){let d=Math.max(0,a-s);return d===t?null:d}if(l>t+o){let d=l-o;return d===t?null:d}return null}function qc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:o=0,totalHeight:s,viewportHeight:a}=e;if(i==="nearest")return ns({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:o,viewportHeight:a});if(n<0)return null;let l=Math.max(0,o),d=n*r,u=Math.max(0,a-l),f=i==="center"?l+Math.max(0,(u-r)/2):l,c=Math.max(0,s-a),m=Math.max(0,Math.min(d-f,c));return m===t?null:m}function zc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:o,viewportHeight:s}=e;if(n<0)return null;let a=Math.max(0,i),l=n*r,d=l+r,u=t+a,f=t+s;if(l>=u&&d<=f)return null;let c=Math.max(0,o-s),m=Math.max(0,Math.min(l-a,c));return m===t?null:m}function un(e){if(e==null||!e.isConnected)return!1;if(e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();if(t instanceof ShadowRoot)return t.activeElement===e;return document.activeElement===e}function _r(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let r=t.activeElement;return r instanceof HTMLElement?r:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function Nn(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;if(n>0)return n;return e.clientHeight>0?e.clientHeight:t}function rs(e,t){return e!=null&&e>0?e:t}function Wc(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;if(n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0)return n.blockSize;return e.contentRect.height>0?e.contentRect.height:null}function is(e,t,n,r,i=0){let o=ns({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});if(o==null)return!1;return e.scrollTop=o,!0}function $c(e,t,n,r,i,o,s=0){let a=qc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:o,topInset:s,totalHeight:i,viewportHeight:r});if(a==null)return!1;return e.scrollTop=a,!0}function Ln(e,t,n,r,i,o){let s=zc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:o,totalHeight:i,viewportHeight:r});if(s==null)return!1;return e.scrollTop=s,!0}function os(e,t,n,r){if(n.end<n.start)return null;if(e<n.start)return-t;if(e>n.end)return r;return null}function jc(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;if(t==null)return"reset";if(!r)return"reveal-canonical";if(n===t)return"ignore";return"focus-input"}function Uc({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:o}){return k("input",{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:o,onClick:(s)=>s.stopPropagation(),onMouseDown:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation()})}function Kc(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:o,isParked:s,itemHeight:a,features:l,state:d,extraStyle:u}=e,f=n==="sticky",c=t.ancestorPaths.at(-1)??"",m={};if(d.isFocusRinged)m["data-item-focused"]=!0;if(t.isSelected)m["data-item-selected"]=!0;if(d.isContextHovered)m["data-item-context-hover"]="true";if(d.isDragTarget)m["data-item-drag-target"]=!0;if(d.isDragging)m["data-item-dragging"]=!0;if(d.effectiveGitStatus!=null)m["data-item-git-status"]=d.effectiveGitStatus;if(d.containsGitChange)m["data-item-contains-git-change"]="true";return{"aria-expanded":!f&&t.kind==="directory"?t.isExpanded:void 0,"aria-haspopup":l.contextMenuEnabled?"menu":void 0,"aria-label":i,"aria-level":!f?t.level+1:void 0,"aria-posinset":!f?t.posInSet+1:void 0,"aria-selected":!f?t.isSelected?"true":"false":void 0,"aria-setsize":!f?t.setSize:void 0,"data-file-tree-sticky-path":f?r:void 0,"data-file-tree-sticky-row":f?"true":void 0,"data-item-context-menu-button-visibility":l.actionLaneEnabled?l.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":l.contextMenuEnabled?l.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":l.actionLaneEnabled?"true":void 0,"data-item-has-git-lane":l.gitLaneActive?"true":void 0,"data-item-parent-path":c.length>0?c:void 0,"data-item-parked":s?"true":void 0,"data-item-path":r,"data-item-type":t.kind==="directory"?"folder":"file","data-type":"item",id:!f?o:void 0,role:!f?"treeitem":void 0,style:{minHeight:`${a}px`,...u},tabIndex:!f&&t.isFocused?0:-1,...m}}function Gc(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,o=t.ctrlKey||t.metaKey,s=t.shiftKey||o,a=t.shiftKey?{additive:o,kind:"range"}:o?{kind:"toggle"}:{kind:"single"};return{closeSearch:r,revealCanonical:n==="sticky",selection:a,toggleDirectory:!s&&i}}var Fn,ve,ss,Yc,as=Object.is,Er=0,ru=[],we=Y,Xc=we.__b,Qc=we.__r,Zc=we.diffed,Jc=we.__c,eu=we.unmount,tu=we.__;function Pi(e,t){we.__h&&we.__h(ve,e,Er||t),Er=0;var n=ve.__H||(ve.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function at(e){return Er=1,Vp(iu,e)}function Vp(e,t,n){var r=Pi(Fn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):iu(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],d=r.t(l,a);as(l,d)||(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ve,!ve.__f)){var i=function(a,l,d){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return!!c.__c});if(u.every(function(c){return!c.__N}))return!o||o.call(this,a,l,d);var f=r.__c.props!==a;return u.forEach(function(c){if(c.__N){var m=c.__[0];c.__=c.__N,c.__N=void 0,as(m,c.__[0])||(f=!0)}}),o&&o.call(this,a,l,d)||f};ve.__f=!0;var{shouldComponentUpdate:o,componentWillUpdate:s}=ve;ve.componentWillUpdate=function(a,l,d){if(4&this.__g){var u=o;o=void 0,i(a,l,d),o=u}s&&s.call(this,a,l,d)},ve.shouldComponentUpdate=i}return r.__N||r.__}function cs(e,t){var n=Pi(Fn++,3);!we.__s&&us(n.__H,t)&&(n.__=e,n.u=t,ve.__H.__h.push(n))}function ze(e,t){var n=Pi(Fn++,4);!we.__s&&us(n.__H,t)&&(n.__=e,n.u=t,ve.__h.push(n))}function V(e){return Er=5,_t(function(){return{current:e}},[])}function _t(e,t){var n=Pi(Fn++,7);return us(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Pe(e,t){return Er=8,_t(function(){return e},t)}function Op(){for(var e;e=ru.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ti),e.__H.__h.forEach(ls),e.__H.__h=[]}catch(t){e.__H.__h=[],we.__e(t,e.__v)}}we.__b=function(e){ve=null,Xc&&Xc(e)},we.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),tu&&tu(e,t)},we.__r=function(e){Qc&&Qc(e),Fn=0;var t=(ve=e.__c).__H;t&&(ss===ve?(t.__h=[],ve.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(Ti),t.__h.forEach(ls),t.__h=[],Fn=0)),ss=ve},we.diffed=function(e){Zc&&Zc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ru.push(t)!==1&&Yc===we.requestAnimationFrame||((Yc=we.requestAnimationFrame)||qp)(Op)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ss=ve=null},we.__c=function(e,t){t.some(function(n){try{n.__h.forEach(Ti),n.__h=n.__h.filter(function(r){return!r.__||ls(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],we.__e(r,n.__v)}}),Jc&&Jc(e,t)},we.unmount=function(e){eu&&eu(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Ti(r)}catch(i){t=i}}),n.__H=void 0,t&&we.__e(t,n.__v))};var nu=typeof requestAnimationFrame=="function";function qp(e){var t,n=function(){clearTimeout(r),nu&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);nu&&(t=requestAnimationFrame(n))}function Ti(e){var t=ve,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ve=t}function ls(e){var t=ve;e.__c=e.__(),ve=t}function us(e,t){return!e||e.length!==t.length||t.some(function(n,r){return!as(n,e[r])})}function iu(e,t){return typeof t=="function"?t(e):t}function zp(e,t=null,n=null){let r=e.flattenedSegments;if(r==null||r.length===0)return t??e.name;return k("span",{"data-item-flattened-subitems":!0,children:r.map((i,o)=>{let s=o===r.length-1;return k(pt,{children:[k("span",{"data-item-flattened-subitem":i.path,"data-item-flattened-subitem-drag-target":n===i.path?"true":void 0,children:s&&t!=null?t:k(kr,{children:i.name})}),o<r.length-1?" / ":""]},i.path)})})}function Hn(e){return e.isFlattened?e.flattenedSegments?.findLast((t)=>t.isTerminal)?.path??e.path:e.path}function hs(e){let t=e.flattenedSegments;if(t==null||t.length===0)return e.name;return t.map((n)=>n.name).join(" / ")}function ou(e,t,n,r){return e.map((i,o)=>{let s=o*n,a=i.subtreeEndIndex+1;if(a>=r)return{row:i.row,top:s};let l=a*n-t;return{row:i.row,top:Math.min(s,l-n)}}).filter((i)=>i.top+n>0)}function ds({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:o}){let s=e.getVisibleCount(),a=i&&s>0?e.getStickyRowCandidates(r,t):[],l=a==null&&i&&s>0?e.getVisibleRows(0,s-1):[],d=Fc(l,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:a==null?void 0:ou(a,r,t,s),totalRowCount:s,viewportHeight:o}),u=i&&r<=0&&s>0?e.getStickyRowCandidates(1,t):[],f=u!=null&&r<=0?ou(u,1,t,s):i&&r<=0&&l.length>0?ts(l,1,t):d.sticky.rows;return{overlayHeight:f.reduce((c,m)=>Math.max(c,m.top+t),0),overlayRows:f,snapshot:d,visibleRows:l}}var Wp=400,su=10,Bn=40,au=18;function $p(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,o=r.elementFromPoint?.(t,n)??i?.(t,n)??null;if(e instanceof ShadowRoot&&(o==null||!e.contains(o)))return jp(e,t,n);return o instanceof HTMLElement?o:null}function jp(e,t,n){let r=Array.from(e.querySelectorAll('[data-type="item"], [data-item-flattened-subitem]'));for(let i=r.length-1;i>=0;i--){let o=r[i],s=o.getBoundingClientRect();if(t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom)return o}return null}function lu(e){let t=e?.closest?.('[data-type="item"]');if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.("[data-item-flattened-subitem]"),i=r instanceof HTMLElement?r.getAttribute("data-item-flattened-subitem")??null:null;if(i!=null&&i.endsWith("/"))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:"directory"};if(t.dataset.itemType==="folder")return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:"directory"};let o=t.dataset.itemParentPath??null;if(o==null||o.length===0)return{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:"root"};return{directoryPath:o,flattenedSegmentPath:null,hoveredPath:n,kind:"directory"}}function cu(e){let t=e.cloneNode(!0);return t.removeAttribute("id"),t.dataset.fileTreeDragPreview="true",t.setAttribute("aria-hidden","true"),t.tabIndex=-1,Object.assign(t.style,{boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",left:"0px",margin:"0",pointerEvents:"none",position:"fixed",top:"0px",willChange:"transform",zIndex:"10000"}),t}function Up(){return navigator.vendor!=="Apple Computer, Inc."}function Kp(e,t){let n=e-t.top;if(n<Bn)return-Math.ceil((Bn-Math.max(0,n))/Bn*au);let r=t.bottom-e;if(r<Bn)return Math.ceil((Bn-Math.max(0,r))/Bn*au);return 0}function Gp(e,t){if(e!=null){let n=Bc[e];if(n==null)return null;return{text:n,title:Hc[e]}}if(t)return{icon:{name:"file-tree-icon-dot",width:6,height:6},title:Vc};return null}function Yp(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;i-=1){let o=e[i],s=n.get(o);if(s!=null){for(let a of r)n.set(a,s);return s?"ignored":null}if(t.has(o)){n.set(o,!0);for(let a of r)n.set(a,!0);return"ignored"}r.push(o)}for(let i of r)n.set(i,!1);return null}function uu(e){return e!=null&&"toggle"in e}function yu(e){return e.code==="Space"||e.key===" "||e.key==="Spacebar"}function Xp(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Qp(e){if(e==null)return"";return`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"] { opacity: 1; }`}function bu(e){return e.shiftKey&&e.key==="F10"||e.key==="ContextMenu"}function Zp(e,t){if(t&&bu(e))return!0;if((e.ctrlKey||e.metaKey)&&yu(e))return!0;return e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"}var Jp=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp"]);function du(e){for(let t of e.composedPath()){if(!(t instanceof HTMLElement))continue;if(t.dataset.fileTreeContextMenuRoot==="true")return!0;if(t.dataset.type==="context-menu-anchor"||t.dataset.type==="context-menu-trigger")return!0;if(t.getAttribute("slot")==="context-menu")return!0}return!1}function em(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function tm(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function nm(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function hu(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function fu(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked==="true"?null:i}function rm(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll('button[data-file-tree-sticky-row="true"]')){if(!(n instanceof HTMLElement))continue;let r=n.dataset.fileTreeStickyPath;if(r!=null)t.push(r)}return t}function im(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll('button[data-item-focused="true"][data-item-parked="true"]'))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function om(e,t,n,r,i,o,s){let a=Math.max(0,o-i),l=t?.getBoundingClientRect()??null,d=l==null||n==null?null:n.getBoundingClientRect().top-l.top,u=im(e,r),f=l==null||u==null?null:u.getBoundingClientRect().top-l.top;return Math.max(0,Math.min(f??Math.max(d??0,a),Math.max(0,s-i)))}function pu(e,t){return{kind:e.kind,name:hs(e),path:t}}function sm(e){return e==null?void 0:`${e}__tree`}function wu(e,t,n){if(e==null)return;return`${e}__focused-item-${encodeURIComponent(t)}${n?"__parked":""}`}function mu(e){return e==="file-tree-icon-chevron"||e==="file-tree-icon-dot"||e==="file-tree-icon-file"||e==="file-tree-icon-lock"}function gu(e,t){if(e==null)return null;if("text"in e){if(e.parts!=null)return k("span",{title:e.title,children:e.parts.map((r,i)=>k("span",{style:{color:r.color},children:r.text},i))});return k("span",{title:e.title,children:e.text})}let n=typeof e.icon==="string"?mu(e.icon)?t(e.icon):{name:e.icon}:mu(e.icon.name)?(()=>{let r=t(e.icon.name),{name:i,...o}=e.icon;return{...r,...o}})():e.icon;return k("span",{title:e.title,children:k(An,{...n})})}function vu(e){if(e==null)return;un(e.querySelector(["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "))??e)}function am(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:o=null,gitDecoration:s=null,gitLaneActive:a=!1,renameInput:l=null,showDecorativeActionAffordance:d=!1}={}){let u=Hn(e);return k(pt,{children:[e.depth>0?k("div",{"data-item-section":"spacing",children:Array.from({length:e.depth}).map((f,c)=>k("div",{"data-item-section":"spacing-item","data-ancestor-path":e.ancestorPaths[c]},c))}):null,k("div",{"data-item-section":"icon",children:e.kind==="directory"?k(An,{...t("file-tree-icon-chevron")}):k(An,{...t("file-tree-icon-file",u)})}),k("div",{"data-item-section":"content",children:e.isFlattened?zp(e,l,o):l??k(Ac,{minimumLength:5,split:"extension",children:e.name})}),i?k("div",{"data-item-section":"decoration",children:r!=null?gu(r,t):null}):null,a?k("div",{"data-item-section":"git",children:gu(s,t)}):null,n?k("div",{"data-item-section":"action",children:d?k("span",{"aria-hidden":"true","data-item-action-affordance":"decorative",children:k(An,{...t("file-tree-icon-ellipsis")})}):null}):null]})}function Ri(e,t,n,r={}){let{controller:i,renameView:o,visualFocusPath:s,contextHoverPath:a,draggedPathSet:l,dragTarget:d,dragAndDropEnabled:u,shouldSuppressContextMenu:f,handleRowDragStart:c,handleRowDragEnd:m,handleRowTouchStart:p,instanceId:g,itemHeight:v,gitStatusByPath:I,ignoredGitDirectories:C,ignoredInheritanceCache:y,directoriesWithGitChanges:S,gitLaneActive:x,contextMenuEnabled:T,contextMenuTriggerMode:O,contextMenuButtonTriggerEnabled:fe,contextMenuButtonVisibility:Z,contextMenuRightClickEnabled:pe,registerRenameInput:J,registerButton:K,resolveIcon:B,renderDecorationForRow:ae,openContextMenuForRow:Se,onRowClick:z,onKeyDown:le}=e,X=Hn(t),{isParked:ye=!1,mode:oe="flow",style:bt}=r,He=oe==="sticky",ct=I?.get(X)??null??Yp(t.ancestorPaths,C,y),Pt=t.kind==="directory"&&(S?.has(X)??!1),tt=ae(t,X),We=Gp(ct,Pt),Ee=T&&fe,Ve=tt!=null||x||Ee,Gt=Ee&&Z==="always",Ce=o.getPath()===X,wt=Ce?o.getValue():"",$e=He||!Ce?null:k(Uc,{ref:J,ariaLabel:`Rename ${hs(t)}`,isFlattened:t.isFlattened,value:wt,onBlur:()=>{o.commit()},onInput:(be)=>{o.setValue(be.currentTarget.value)}}),Yt=am(t,B,{actionLaneEnabled:Ee,customDecoration:tt,decorationLaneEnabled:Ve,dragTargetFlattenedSegmentPath:d?.flattenedSegmentPath??null,gitDecoration:We,gitLaneActive:x,renameInput:$e,showDecorativeActionAffordance:Gt}),nt={...Kc({ariaLabel:hs(t),domId:t.isFocused?wu(g,X,ye):void 0,extraStyle:bt,features:{actionLaneEnabled:Ee,contextMenuButtonVisibility:Ee?Z:null,contextMenuEnabled:T,contextMenuTriggerMode:T?O:null,gitLaneActive:x},isParked:ye,itemHeight:v,mode:oe,row:t,state:{containsGitChange:Pt,effectiveGitStatus:ct,isContextHovered:a===X,isDragTarget:d?.kind==="directory"&&d.directoryPath===X,isDragging:l?.has(X)===!0,isFocusRinged:t.isFocused&&s===X},targetPath:X}),key:n,onContextMenu:T||u?(be)=>{if(f()){be.preventDefault();return}if(!T)return;if(be.preventDefault(),!pe)return;i.focusMountedPathFromInput(X),Se(t,X,{anchorRect:tm(be.clientX,be.clientY),source:"right-click"})}:void 0,onFocus:!He?()=>{i.focusMountedPathFromInput(X)}:void 0,onKeyDown:!He?le:void 0,ref:(be)=>{K(X,be)}};if(!He&&Ce)return k("div",{...nt,children:Yt});return k("button",{...nt,type:"button",draggable:u&&!ye,onDragEnd:u&&!ye?m:void 0,onDragStart:u&&!ye?(be)=>{c(be,t,X)}:void 0,onMouseDown:(be)=>{if(He){be.preventDefault();return}if(i.isSearchOpen())be.preventDefault()},onTouchStart:u&&!ye?(be)=>{p(be,t,X)}:void 0,onClick:(be)=>{z(be,t,X,oe)},children:Yt})}function lm(e,t,n){if(t.end<t.start)return[];return e.controller.getVisibleRows(t.start,t.end).filter((r)=>!n.has(Hn(r))).map((r,i)=>Ri(e,r,t.start+i))}function fs({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:o,instanceId:s,itemHeight:a=mi,overscan:l=10,renamingEnabled:d=!1,renderRowDecoration:u,searchBlurBehavior:f="close",searchEnabled:c=!1,searchFakeFocus:m=!1,slotHost:p,stickyFolders:g=!1,initialViewportHeight:v=420}){let I=V(null),C=V(null),y=V(!1),S=V(null),x=V(null),T=V(null),O=V(null),fe=V(null),Z=V(new Map),pe=V(new Map),J=V(()=>{}),K=V(null),B=V(0),ae=V(!1),Se=V(null);if(Se.current!==t)ae.current=!1,Se.current=t;let z=V(!1),le=V(null),X=V(null),ye=V(!1),oe=V(null),bt=V(null),He=V(null),ct=V(null),Pt=V(null),tt=V(null),We=V(null),Ee=V(null),Ve=V(!1),Gt=V(null),Ce=V(null),wt=V(null),$e=V(null),Yt=_t(()=>new Map,[]),[,nt]=at(0),be=V(!1),[ut,rt]=at(null),[pn,Xt]=at(null),[Rt,mn]=at(null),[je,Me]=at(null),[ji,de]=at(0),[G,gn]=at(null),dt=V(G);dt.current=G;let Dt=V(null),Qt=V(null),Zt=V(null),Jt=V(null),w=V(null),A=V(!1),H=()=>{Qt.current=null,Zt.current=null,Jt.current=null},j=(h,b)=>{Qt.current=h,Zt.current=null,Jt.current=b==null?null:{path:h,scrollTop:b}},It=(h,b)=>{Qt.current=null,Zt.current={path:h,viewportOffset:b},Jt.current=null},en=V(f==="retain"&&t.isSearchOpen()),[Jn,Ds]=at(m);cs(()=>{if(!m)Ds(!1)},[m]);let Ms=V(!1),Ui=Pe(()=>{Ms.current=!0,Ds((h)=>h?!1:h)},[]),[Wd,$d]=at(()=>ds({controller:t,itemHeight:a,overscan:l,scrollTop:0,stickyFolders:g,viewportHeight:v})),[jd,Ud]=at(!1);cs(()=>{Ud(!0)},[]);let Oe=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,vn=e?.contextMenu?.triggerMode??(Oe?"right-click":"both"),yn=vn==="both"||vn==="button",As=e?.contextMenu?.buttonVisibility??"when-needed",Kd=vn==="both"||vn==="right-click";ze(()=>{let h=T.current;if(h==null)return;let b=(_)=>{if(!(_ instanceof CustomEvent))return;let P=_.detail?.path??null;w.current=P,Xt(P),Me(P==null?null:"pointer")},N=(_)=>{if(!(_ instanceof CustomEvent))return;A.current=_.detail?.disabled===!0};return h.addEventListener("file-tree-debug-set-context-menu-trigger",b),h.addEventListener("file-tree-debug-set-scroll-suppression",N),()=>{h.removeEventListener("file-tree-debug-set-context-menu-trigger",b),h.removeEventListener("file-tree-debug-set-scroll-suppression",N)}},[]);let Gd=Pe((h,b)=>{hu(Z.current,h,b)},[]),Yd=Pe((h,b)=>{hu(pe.current,h,b)},[]),Xd=Pe((h)=>{x.current=h},[]),er=Pe((h)=>fu(h,pe.current,Z.current),[]),Ns=n!=null||r!=null||i!=null,{resolveIcon:Ls}=_t(()=>fc(o),[o]),tr=t[zo](),bn=tr.getPath(),Ki=bn!=null,ht=t.isSearchOpen(),Qd=t.getSearchValue(),W=t.getFocusedPath(),ne=t.getFocusedIndex(),tn=t.getScrollRequest(),St=t.isDragAndDropEnabled(),nr=t.getDragSession(),Zd=_t(()=>nr==null?null:new Set(nr.draggedPaths),[nr]),Jd=nr?.target??null,rr=nr?.primaryPath??null,Fs=sm(s),{overlayHeight:eh,overlayRows:th,snapshot:xe,visibleRows:Br}=Wd,Te=xe.physical.viewportHeight,it=_t(()=>({end:xe.window.endIndex,start:xe.window.startIndex}),[xe.window.endIndex,xe.window.startIndex]),ir=th,Bs=xe.sticky.rows,nn=xe.physical.totalHeight,wn=xe.sticky.height,Hr=_t(()=>new Set(Bs.map((h)=>Hn(h.row))),[Bs]),Gi=ne>=0&&ne>=it.start&&ne<=it.end,nh=Pe((h,b)=>u?.({item:pu(h,b),row:h})??null,[u]),Hs=Pe((h)=>{if(un(h==null?null:Z.current.get(h)??null))return!0;return un(T.current)},[]),Vr=Pe((h)=>{Hs(t.focusNearestPath(h))},[t,Hs]),Vs=V(Vr);Vs.current=Vr;let In=V(!0),Yi=V(()=>{}),Ye=Pe((h=!0)=>{let b=dt.current;if(b==null)return;if(In.current=In.current&&h,gn(null),e?.contextMenu?.onClose?.(),In.current)Vr(b.path)},[e?.contextMenu,Vr]);Yi.current=Ye;let or=Pe((h)=>{let b=h==null?null:nm(T.current,h);mn((N)=>N===b?N:b)},[]),Os=Pe((h,b,N)=>{let _=t.getItem(b);if(_==null)return;let P=er(b);if(P?.dataset.fileTreeStickyRow==="true"){let F=O.current;j(b,F?.scrollTop??null),z.current=!0,rt((ce)=>ce===b?ce:b)}_.focus(),or(P),In.current=!0,gn({anchorRect:N?.anchorRect??null,item:pu(h,b),path:b,source:N?.source??"keyboard"})},[t,er,or]),rh=Pe((h)=>{if(!d)return;if(t.isSearchOpen()){let b=O.current,N=Nn(b,Te);oe.current=ne<0||b==null?null:Math.max(0,Math.min(ne*a-b.scrollTop,Math.max(0,N-a))),ye.current=!0}if(t.startRenaming(h)===!1)return;Me("focus"),nt((b)=>b+1)},[t,ne,a,d,Te]),Or=Pe((h,{restoreTreeFocus:b=!0,targetOffset:N="live-overlay"}={})=>{let _=O.current;if(_==null)return!1;t.focusPath(h);let P=t.getFocusedIndex();if(P<0)return!1;let F=t.getVisibleRows(P,P)[0]??null;if(F==null)return!1;let ce=Nn(_,Te),L=t.getVisibleCount()*a,ee=N==="sticky-parents"?F.ancestorPaths.length*a:ds({controller:t,itemHeight:a,overscan:l,scrollTop:_.scrollTop,stickyFolders:g,viewportHeight:ce}).snapshot.sticky.height;return z.current=!0,Ln(_,P,a,ce,L,ee),J.current(),Dt.current=b?h:null,!0},[t,a,l,Te,g]),ih=()=>y.current===!0||$e.current!=null||Ve.current===!0,qs=(h)=>typeof window.requestAnimationFrame==="function"?window.requestAnimationFrame(()=>{h()}):window.setTimeout(h,16),oh=(h)=>{if(h==null)return;if(typeof window.cancelAnimationFrame==="function"){window.cancelAnimationFrame(h);return}window.clearTimeout(h)},Mt=()=>{if(ct.current!=null)clearTimeout(ct.current),ct.current=null;He.current=null},qr=()=>{tt.current?.remove(),tt.current=null},sr=()=>{oh(bt.current),bt.current=null,Pt.current=null},zs=(h)=>{let b=T.current?.getRootNode();if(b instanceof ShadowRoot){b.append(h);return}document.body.append(h)},ar=()=>{if(Ee.current?.(),Ee.current=null,$e.current!=null)clearTimeout($e.current),$e.current=null;if(Ve.current=!1,Gt.current=null,wt.current=null,Ce.current!=null)Ce.current.setAttribute("draggable","true"),Ce.current.style.removeProperty("touch-action"),Ce.current=null;qr(),Mt(),sr(),We.current=null},zr=(h,b)=>{let N=T.current?.getRootNode(),_=lu($p(N instanceof ShadowRoot?N:document,h,b));return t.setDragTarget(_),t.getDragSession()?.target??null},Xi=(h)=>{let b=t.getDragAndDropConfig()?.openOnDropDelay??800;if(h==null||h.kind!=="directory"||h.directoryPath==null||b<=0){Mt();return}let N=t.getItem(h.directoryPath),_=uu(N)?N:null;if(_==null||_.isExpanded()){Mt();return}let P=`${h.directoryPath}::${h.flattenedSegmentPath??""}`;if(He.current===P)return;Mt(),He.current=P,ct.current=setTimeout(()=>{let F=t.getDragSession()?.target;if(F?.kind!=="directory"||F.directoryPath!==h.directoryPath||F.flattenedSegmentPath!==h.flattenedSegmentPath)return;_.expand()},b)},Ws=()=>{bt.current=null;let h=Pt.current,b=O.current;if(h==null||b==null||t.getDragSession()==null)return;let N=b.getBoundingClientRect(),_=Kp(h.clientY,N);if(_===0)return;let P=Math.max(0,b.scrollHeight-b.clientHeight),F=Math.max(0,Math.min(P,b.scrollTop+_));if(F!==b.scrollTop)b.scrollTop=F,J.current();Xi(zr(h.clientX,h.clientY)),bt.current=qs(Ws)},$s=(h,b)=>{Pt.current={clientX:h,clientY:b},bt.current??=qs(Ws)},sh=(h,b,N)=>{let _=h.currentTarget;if(_==null)return;if(ar(),qr(),Mt(),sr(),t.startDrag(N)===!1){h.preventDefault();return}if(We.current=b,h.dataTransfer!=null){if(h.dataTransfer.effectAllowed="move",h.dataTransfer.dropEffect="move",h.dataTransfer.setData("text/plain",N),Up()){let P=cu(_),F=_.getBoundingClientRect();Object.assign(P.style,{height:`${F.height}px`,opacity:"0.85",transform:"translate3d(-9999px, 0px, 0)",width:`${F.width}px`}),zs(P),tt.current=P,h.dataTransfer.setDragImage(P,Math.max(0,h.clientX-F.left),Math.max(0,h.clientY-F.top))}}},ah=()=>{qr(),Mt(),sr(),We.current=null,t.cancelDrag()},lh=(h,b,N)=>{if($e.current!=null||Ve.current)return;let _=h.touches[0],P=h.currentTarget;if(_==null||P==null)return;wt.current={clientX:_.clientX,clientY:_.clientY},Ce.current=P,P.setAttribute("draggable","false");let F=(ee={})=>{let se=ee.restoreNativeDraggable??!Ve.current;if($e.current!=null)clearTimeout($e.current),$e.current=null;if(document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",L),document.removeEventListener("touchcancel",L),Ee.current===F)Ee.current=null;if(se){if(P.setAttribute("draggable","true"),Ce.current===P)Ce.current=null;wt.current=null}},ce=(ee)=>{let se=ee.touches[0],re=wt.current;if(se==null||re==null)return;let he=se.clientX-re.clientX,Re=se.clientY-re.clientY;if(he*he+Re*Re<=su*su)return;F()},L=()=>{F()};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),Ee.current=F,$e.current=setTimeout(()=>{if(F({restoreNativeDraggable:!1}),t.startDrag(N)===!1){if(P.setAttribute("draggable","true"),Ce.current===P)Ce.current=null;wt.current=null;return}Ve.current=!0,Ce.current=P,P.setAttribute("draggable","false"),P.style.setProperty("touch-action","none"),We.current=b;let ee=P.getBoundingClientRect(),se=cu(P);Object.assign(se.style,{height:`${ee.height}px`,opacity:"0.85",transform:`translate3d(${ee.left}px, ${ee.top}px, 0)`,width:`${ee.width}px`}),zs(se),tt.current=se,Gt.current={x:_.clientX-ee.left,y:_.clientY-ee.top};let re=(ot)=>{let Ie=ot.touches[0];if(Ie==null)return;ot.preventDefault();let Q=Gt.current;if(Q!=null&&tt.current!=null)tt.current.style.transform=`translate3d(${Ie.clientX-Q.x}px, ${Ie.clientY-Q.y}px, 0)`;Xi(zr(Ie.clientX,Ie.clientY)),$s(Ie.clientX,Ie.clientY)},he=(ot)=>{let Ie=ot.changedTouches[0];if(Ie!=null)zr(Ie.clientX,Ie.clientY);t.completeDrag(),ar()},Re=()=>{t.cancelDrag(),ar()};Ee.current=()=>{document.removeEventListener("touchmove",re),document.removeEventListener("touchend",he),document.removeEventListener("touchcancel",Re)},document.addEventListener("touchmove",re,{passive:!1}),document.addEventListener("touchend",he),document.addEventListener("touchcancel",Re)},Wp)},js=(h)=>{if(G!=null){if(h.key==="Escape"){Ye(),h.preventDefault(),h.stopPropagation();return}if(Jp.has(h.key))h.preventDefault(),h.stopPropagation();return}if(tr.isActive()){if(h.isComposing||h.keyCode===229)return;if(h.key==="Escape")tr.cancel();else if(h.key==="Enter")tr.commit();else return;Me("focus"),nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(d&&h.key==="F2"){rh(W??void 0),h.preventDefault(),h.stopPropagation();return}if(ht){if(h.key==="Escape")ye.current=!1,oe.current=null,t.closeSearch();else if(h.key==="Enter"){let ge=t.getFocusedPath();if(ge!=null)t.selectOnlyPath(ge);let ft=O.current,Kr=Nn(ft,Te);oe.current=ne<0||ft==null?null:Math.max(0,Math.min(ne*a-ft.scrollTop,Math.max(0,Kr-a))),ye.current=!0,t.closeSearch()}else if(h.key==="ArrowDown")t.focusNextSearchMatch();else if(h.key==="ArrowUp")t.focusPreviousSearchMatch();else return;Me("focus"),nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(c&&Xp(h)){t.openSearch(h.key),nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}let b=Oe&&bu(h),N=Zp(h,Oe),_=N&&T.current!=null?_r(T.current):null,P=N?new Set(rm(T.current)):new Set,F=_?.dataset.fileTreeStickyPath??null,ce=_?.dataset.fileTreeStickyRow==="true"&&F!=null;if(ce&&F!==W&&P.has(F)){let ge=O.current;j(F,ge?.scrollTop??null),t.focusPath(F)}let L=t.getFocusedPath(),ee=t.getFocusedIndex(),se=t.getFocusedItem();if(se==null)return;let re=uu(se)?se:null,he=L!=null&&(Hr.has(L)||ce&&F===L&&P.has(L)),Re=h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="ArrowRight"&&re!=null&&re.isExpanded(),ot=h.key==="ArrowLeft"&&he&&re!=null&&re.isExpanded(),Ie=O.current,Q=!0;if(h.shiftKey&&h.key==="ArrowDown")t.extendSelectionFromFocused(1);else if(h.shiftKey&&h.key==="ArrowUp")t.extendSelectionFromFocused(-1);else if(b&&L!=null&&ee>=0){let ge=t.getVisibleRows(ee,ee)[0]??null,ft=fu(L,pe.current,Z.current);if(ge==null||ft==null)Q=!1;else Os(ge,L)}else if((h.ctrlKey||h.metaKey)&&yu(h))t.toggleFocusedSelection();else if((h.ctrlKey||h.metaKey)&&h.key.toLowerCase()==="a")t.selectAllVisiblePaths();else switch(h.key){case"ArrowDown":t.focusNextItem();break;case"ArrowUp":t.focusPreviousItem();break;case"ArrowRight":if(re==null||re.isExpanded())t.focusNextItem();else re.expand();break;case"ArrowLeft":if(re!=null&&re.isExpanded())re.collapse();else t.focusParentItem();break;case"Home":t.focusFirstItem();break;case"End":t.focusLastItem();break;default:Q=!1}if(!Q)return;Me("focus");let me=t.getFocusedPath(),Ae=me!=null&&(Hr.has(me)||P.has(me)),jr=Re&&me!==L,Ur=b&&ce&&F===L&&me===L;if((he||Ur)&&me!=null&&(jr&&Ae||Ur))j(me,Ie?.scrollTop??null),z.current=!0,rt((ge)=>ge===me?ge:me);else{let ge=h.key==="ArrowUp"&&he&&me!==L;if(me!=null&&(ge||ot&&me===L))It(me,om(T.current,Ie,_,L,a,wn,Te)),z.current=!0,rt((ft)=>ft===me?ft:me);else H()}nt((ge)=>ge+1),h.preventDefault(),h.stopPropagation()};ze(()=>{if(!c||!ht)return;if(en.current){en.current=!1;return}un(fe.current)},[ht,c]),ze(()=>{let h=x.current;switch(jc({hasRenderedInput:h!=null,previousRenamingPath:X.current,renamingPath:bn})){case"reset":X.current=null;return;case"reveal-canonical":if(bn!=null)Or(bn,{restoreTreeFocus:!1,targetOffset:"live-overlay"});return;case"ignore":return;case"focus-input":if(h!=null)Dt.current=null,X.current=bn,un(h),h.select();return}},[it.end,it.start,bn,Or,Hr]),ze(()=>{let h=T.current;if(h==null)return;let b=null,N=()=>{if(b==null)return;clearTimeout(b),b=null},_=()=>{let ce=_r(h)?.dataset.itemPath??null;rt((L)=>L===ce?L:ce)},P=()=>{N(),z.current=!0,_()},F=(ce)=>{let L=ce.relatedTarget;if(L==null){N(),b=setTimeout(()=>{if(b=null,_r(h)!=null){_();return}z.current=!1,rt(null)},0);return}if(!(L instanceof Node)||!h.contains(L)){N(),z.current=!1,rt(null);return}let ee=L instanceof HTMLElement?L.dataset.itemPath??null:null;rt((se)=>se===ee?se:ee)};return h.addEventListener("focusin",P),h.addEventListener("focusout",F),()=>{N(),h.removeEventListener("focusin",P),h.removeEventListener("focusout",F)}},[]),ze(()=>{let h=T.current;if(h==null)return;if(xe.physical.scrollTop<=0)h.dataset.scrollAtTop="true";else delete h.dataset.scrollAtTop},[xe.physical.scrollTop]),ze(()=>{let h=null,b=O.current,N=S.current,_=T.current;if(b==null)return;K.current=Nn(b,v);let P=()=>{let Q=t.getVisibleCount(),me=rs(K.current,v),Ae=Math.max(0,Q*a-me);if(b.scrollTop>Ae)b.scrollTop=Ae;$d(ds({controller:t,itemHeight:a,overscan:l,scrollTop:Math.min(b.scrollTop,Ae),stickyFolders:g,viewportHeight:me}))};if(!ae.current){ae.current=!0;let Q=t.getFocusedIndex();if(Q>=0){let me=rs(K.current,v),Ae=t.getVisibleRows(Q,Q)[0]??null;is(b,Q,a,me,g&&Ae!=null?Math.max(0,Math.min(Ae.ancestorPaths.length*a,Math.max(0,me-a))):0)}}J.current=P;let F=t.subscribe(()=>{if(Oc(be))nt((Q)=>Q+1);P()}),ce=()=>{if(A.current===!0)return;if(N!=null)N.dataset.isScrolling??="";if(_!=null)_.dataset.isScrolling??="";if(y.current=!0,h!=null)clearTimeout(h);h=setTimeout(()=>{if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling;y.current=!1,de((Q)=>Q+1),h=null},50)},L=null,ee=()=>{if(_!=null)delete _.dataset.overlayReveal;if(L!=null)clearTimeout(L),L=null},se=()=>{if(_==null||A.current===!0)return;if(b.scrollTop>0)return;if(_.dataset.overlayReveal="true",L!=null)clearTimeout(L);L=setTimeout(()=>{ee()},200)},re=()=>{if(P(),b.scrollTop>0)ee();if(dt.current!=null&&y.current)Yi.current();if(A.current===!0){y.current=!1;return}Xt((Q)=>Q==null?Q:null),ce()},he=()=>{ce(),se()},Re=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," ","Spacebar"]),ot=(Q)=>{if(!Re.has(Q.key))return;he()};b.addEventListener("scroll",re,{passive:!0}),b.addEventListener("wheel",he,{passive:!0}),b.addEventListener("touchmove",he,{passive:!0}),b.addEventListener("keydown",ot);let Ie=typeof ResizeObserver<"u"?new ResizeObserver((Q)=>{K.current=(Q[0]==null?null:Wc(Q[0]))??Nn(b,v),P()}):null;return Ie?.observe(b),()=>{if(J.current=()=>{},F(),b.removeEventListener("scroll",re),b.removeEventListener("wheel",he),b.removeEventListener("touchmove",he),b.removeEventListener("keydown",ot),h!=null)clearTimeout(h);if(L!=null)clearTimeout(L);if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling,delete _.dataset.overlayReveal;y.current=!1,K.current=null,Ie?.disconnect()}},[t,v,a,l,g]),ze(()=>{if(Oe||G==null)return;Ye(!1)},[Ye,Oe,G]);let Us=_t(()=>G==null?null:`${G.path}::${G.source}`,[G]);ze(()=>{if(Us==null){p?.clearSlotContent(Ir);return}let h=dt.current;if(h==null)return;let b=C.current??I.current;if(b==null)return;let N={anchorElement:b,anchorRect:h.anchorRect??em(b.getBoundingClientRect()),close:(P)=>{Yi.current(P?.restoreFocus??!0)},restoreFocus:()=>{if(!In.current)return;Vs.current(dt.current?.path??null)}},_=e?.contextMenu?.render?.(h.item,N)??null;return p?.setSlotContent(Ir,_),e?.contextMenu?.onOpen?.(h.item,N),vu(_),queueMicrotask(()=>{if(_==null||!_.isConnected)return;if(document.activeElement!==_)return;vu(_)}),()=>{p?.clearSlotContent(Ir)}},[Us,e?.contextMenu,p]),ze(()=>{if(G!=null&&t.getItem(G.path)==null)Ye()},[Ye,G,t]),ze(()=>{if(G==null)return;let h=T.current?.getRootNode(),b=h instanceof ShadowRoot?h.host:T.current,N=(P)=>{let F=P.target;if(!(F instanceof Node))return;if(du(P))return;if(I.current?.contains(F)===!0)return;if(b?.contains(F)===!0)return;Ye()},_=(P)=>{if(P.key==="Escape")P.preventDefault(),P.stopPropagation(),Ye()};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",_,!0)}},[Ye,G]),ze(()=>{let h=O.current,b=T.current;if(h==null||b==null){le.current=W;return}let N=W==null?null:Z.current.get(W)??null,_=_r(b),P=_?.dataset.itemPath??null,F=Ki&&x.current===_,ce=c&&fe.current===_,L=ye.current&&!ht,ee=oe.current??0,se=Dt.current,re=Qt.current,he=Zt.current,Re=Jt.current,ot=_!=null,Ie=z.current||ot,Q=le.current!==W,me=re!=null&&re===W&&W!=null,Ae=!1,jr=!1;if(tn!=null&&tn.id!==B.current){B.current=tn.id;let Zi=tn.visibleIndex,Qs=t.getVisibleRows(Zi,Zi)[0]??null;if(Qs!=null){let Nh=g?Math.max(0,Math.min(Qs.ancestorPaths.length*a,Math.max(0,Te-a))):wn;Ae=!0,jr=$c(h,Zi,a,Te,nn,tn.offset,Nh)}t.clearScrollRequest(tn.id)}let Ur=!Ae&&L&&Ln(h,ne,a,Te,nn,ee),ge=!Ae&&se!=null&&se===W&&Ln(h,ne,a,Te,nn,wn),ft=!Ae&&he!=null&&he.path===W&&Ln(h,ne,a,Te,nn,he.viewportOffset),Kr=!Ae&&Re!=null&&Re.path===W&&h.scrollTop!==Re.scrollTop;if(Kr)h.scrollTop=Re.scrollTop;if(Kr||jr||ge||ft||Ur||Ie&&Q&&se!==W&&!me&&is(h,ne,a,Te,wn))J.current();if(Ae){le.current=W;return}if(!Ie){le.current=W;return}if(F){le.current=W;return}if(ce&&!L){le.current=W;return}if(N==null){if(L&&ne>=0)Ln(h,ne,a,Te,nn,ee),J.current();le.current=W;return}if(Q||L||se===W||re===W||he?.path===W||Re?.path===W||P==null||P!==W){if(un(N),se===W)Dt.current=null;if(re===W)Qt.current=null;if(he?.path===W)Zt.current=null;if(Re?.path===W)Jt.current=null;ye.current=!1,oe.current=null}le.current=W},[t,ne,W,Gi,a,Ki,ht,it,Te,c,tn,g,wn,nn,Br]);let ch=ne>=0&&ne>=xe.visible.startIndex&&ne<=xe.visible.endIndex,uh=W!=null&&ir.some((h)=>Hn(h.row)===W),dh=ch||uh,hh=yn&&z.current===!0&&dh?W:null,fh=je==="pointer"?pn:null,rn=G?.path??w.current??fh??hh??pn,Ks=G?.source==="right-click";ze(()=>{if(y.current&&G==null)return;or(er(rn))},[G,er,it,Te,ji,ir,rn,or,Br]);let ph=Pe((h)=>{if(y.current)return;if(du(h))return;let b=h.target;if(!(b instanceof HTMLElement))return;if(b.closest?.('[data-type="context-menu-trigger"]')!=null)return;let N=b.closest?.('[data-file-tree-sticky-row="true"]'),_=b.closest?.('[data-type="item"]'),P=N instanceof HTMLElement?N.dataset.fileTreeStickyPath??null:_ instanceof HTMLElement?_.dataset.itemPath??null:null;if(P!=null)Me((F)=>F==="pointer"?F:"pointer");Xt((F)=>F===P?F:P)},[]),mh=Pe(()=>{Xt(null)},[]);ze(()=>{if(!St)return;let h=()=>{ar(),t.cancelDrag()};return window.addEventListener("dragend",h),()=>{window.removeEventListener("dragend",h),ar(),t.cancelDrag()}},[t,St]);let gh=(h)=>{if(!St||t.getDragSession()==null||Ve.current)return;let b=lu(h.target instanceof HTMLElement?h.target:null);if(t.setDragTarget(b),Xi(t.getDragSession()?.target??null),$s(h.clientX,h.clientY),h.dataTransfer!=null)h.dataTransfer.dropEffect="move";h.preventDefault()},vh=(h)=>{if(!St||t.getDragSession()==null||Ve.current)return;let b=h.relatedTarget;if(b instanceof Node&&T.current?.contains(b)===!0)return;Mt(),sr(),t.setDragTarget(null)},yh=(h)=>{if(!St||t.getDragSession()==null||Ve.current)return;h.preventDefault(),zr(h.clientX,h.clientY),t.completeDrag(),qr(),Mt(),sr(),We.current=null},lr=xe.window.height,bh=xe.window.offsetTop,wh=Math.min(0,Te-lr),Ih=Math.min(0,Te-lr-wn),Sh=ut===W||ye.current,Sn=W!=null&&Sh&&!Gi&&ne>=0?Br[ne]??t.getVisibleRows(ne,ne)[0]??null:null,Gs=Sn==null?null:os(ne,a,it,lr),At=We.current,Ch=rr!=null&&At!=null&&At.path===rr&&At.index>=it.start&&At.index<=it.end,cr=rr!=null&&At!=null&&At.path===rr&&!Ch&&At.path!==Sn?.path?At:null,Ys=cr==null?null:os(cr.index,a,it,lr),xh=Qp((ne>=0?Br[ne]??t.getVisibleRows(ne,ne)[0]??null:null)?.ancestorPaths.at(-1)??null),kh=ht&&W!=null?wu(s,W,!Gi):void 0,_h=G?.path??(ht?W:ut),Eh=G?.path??pn,ur=er(rn),Qi=Oe&&yn&&!Ks&&!Ki&&ur!=null&&Rt!=null&&rn!=null,Th=Oe&&(Qi||G!=null),Wr=G?.anchorRect,Xs=Wr==null&&ur!=null&&Rt!=null&&(G!=null||Qi)?Rt:null,Ph=Wr!=null?{left:`${Wr.left}px`,position:"fixed",right:"auto",top:`${Wr.top}px`}:Xs!=null?{top:`${Xs}px`}:void 0,Rh=Ks?{opacity:"0"}:void 0,Dh=Pe((h,b,N,_)=>{let P=Gc({event:{ctrlKey:h.ctrlKey,metaKey:h.metaKey,shiftKey:h.shiftKey},isDirectory:b.kind==="directory",isSearchOpen:ht,mode:_}),F=P.toggleDirectory&&b.kind==="directory",ce=F?t.resolveMountedDirectoryPathFromInput(N):null;if(F&&ce==null)return;let L=ce??N;switch(P.selection.kind){case"range":t.selectPathRange(L,P.selection.additive);break;case"toggle":t.togglePathSelectionFromInput(L);break;case"single":t.selectOnlyMountedPathFromInput(L);break}let ee=h.currentTarget instanceof HTMLElement?h.currentTarget:null,se=b.index>=xe.visible.startIndex&&b.index<=xe.visible.endIndex,re=_==="flow"&&se&&ee!=null&&ee.dataset.itemParked!=="true";if(t.focusMountedPathFromInput(L),re)z.current=!0,rt((he)=>he===L?he:L),Me("focus");if(F)t.toggleMountedDirectoryFromInput(L);if(P.closeSearch)t.closeSearch();if(P.revealCanonical)Or(L,{targetOffset:"sticky-parents"})},[t,ht,xe.visible.endIndex,xe.visible.startIndex,Or]),Mh=()=>{if(y.current)return;if(!yn)return;if(rn==null||ur==null)return;let h=t.getItem(rn);if(h==null)return;or(ur),In.current=!0,gn({anchorRect:null,item:{kind:h.isDirectory()?"directory":"file",name:ur.getAttribute("aria-label")??rn,path:h.getPath()},path:h.getPath(),source:"button"})},$r={contextHoverPath:Eh,contextMenuButtonTriggerEnabled:yn,contextMenuButtonVisibility:As,contextMenuEnabled:Oe,contextMenuRightClickEnabled:Kd,contextMenuTriggerMode:vn,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:St,draggedPathSet:Zd,dragTarget:Jd,gitLaneActive:Ns,gitStatusByPath:n,handleRowDragEnd:ah,handleRowDragStart:sh,handleRowTouchStart:lh,ignoredGitDirectories:r,ignoredInheritanceCache:Yt,instanceId:s,itemHeight:a,onKeyDown:js,onRowClick:Dh,openContextMenuForRow:Os,registerButton:Gd,registerRenameInput:Xd,renameView:tr,renderDecorationForRow:nh,resolveIcon:Ls,shouldSuppressContextMenu:ih,visualFocusPath:_h},Ah={...$r,registerButton:Yd};return k("div",{ref:T,id:Fs,"data-file-tree-context-menu-button-visibility":Oe&&yn?As:void 0,"data-file-tree-context-menu-trigger-mode":Oe?vn:void 0,"data-file-tree-has-context-menu-action-lane":Oe&&yn?"true":void 0,"data-file-tree-has-git-lane":Ns?"true":void 0,"data-file-tree-virtualized-root":"true",onDragLeave:St?vh:void 0,onDragOver:St?gh:void 0,onDrop:St?yh:void 0,onKeyDown:js,onPointerLeave:Oe?mh:void 0,onPointerOver:Oe?ph:void 0,role:"tree",tabIndex:-1,style:{outline:"none",position:"relative"},children:[k("style",{"data-file-tree-guide-style":"true",dangerouslySetInnerHTML:{__html:xh}}),k("slot",{name:wr,"data-type":"header-slot"}),c?k("div",{"data-file-tree-search-container":!0,"data-open":ht?"true":"false",children:k("input",{ref:fe,"aria-activedescendant":kh,"aria-controls":Fs,placeholder:"Search…","data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Jn?"true":void 0,value:Qd,onBlur:()=>{if(f==="retain"&&!Ms.current)return;t.closeSearch()},onFocus:Ui,onPointerDown:Ui,onInput:(h)=>{Ui();let b=h.currentTarget;t.setSearch(b.value)}})}):null,k("div",{ref:O,"data-file-tree-virtualized-scroll":"true",children:[g&&jd&&ir.length>0?k("div",{"aria-hidden":"true","data-file-tree-sticky-overlay":"true",children:k("div",{"data-file-tree-sticky-overlay-content":"true",style:{height:`${eh}px`},children:ir.map((h,b)=>Ri(Ah,h.row,`sticky:${Hn(h.row)}`,{mode:"sticky",style:{left:"0",position:"absolute",right:"0",top:`${h.top}px`,zIndex:`${ir.length-b}`}}))})}):null,k("div",{ref:S,"data-file-tree-virtualized-list":"true",style:{height:`${nn}px`},children:[k("div",{"data-file-tree-virtualized-sticky-offset":"true","aria-hidden":"true",style:{height:`${bh}px`}}),k("div",{"data-file-tree-virtualized-sticky":"true",style:{height:`${lr}px`,top:`${wh}px`,bottom:`${Ih}px`},children:[lm($r,it,Hr),Sn!=null&&Gs!=null?Ri($r,Sn,`parked:${Sn.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:rr===Sn.path?"none":void 0,position:"absolute",right:"0",top:`${Gs}px`}}):null,cr!=null&&Ys!=null?Ri($r,cr,`parked-drag:${cr.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:"none",position:"absolute",right:"0",top:`${Ys}px`}}):null]})]})]}),Oe?k("div",{ref:I,"data-type":"context-menu-anchor","data-visible":Th?"true":"false",style:Ph,children:[k("button",{ref:C,type:"button","data-type":jl,"aria-label":"Options","aria-haspopup":"menu","aria-expanded":G!=null?"true":"false","data-visible":Qi?"true":"false",onMouseDown:(h)=>{h.preventDefault()},onClick:(h)=>{if(h.preventDefault(),h.stopPropagation(),G!=null){Ye();return}Mh()},tabIndex:-1,style:Rh,children:k(An,{...Ls("file-tree-icon-ellipsis")})}),G!=null?k("slot",{name:Ir}):null]}):null,G!=null?k("div",{"data-type":"context-menu-wash","aria-hidden":"true",onMouseDownCapture:(h)=>{h.preventDefault(),Ye()},onTouchStartCapture:(h)=>{h.preventDefault(),h.stopPropagation(),Ye()},onTouchMoveCapture:(h)=>{h.preventDefault(),h.stopPropagation()},onWheelCapture:(h)=>{h.preventDefault(),h.stopPropagation()}}):null]})}var ps={hydrateRoot:(e,t)=>{Tc(Mn(fs,t),e)},renderRoot:(e,t)=>{Ei(Mn(fs,t),e)},unmountRoot:(e)=>{Ei(null,e)}};function Vn(e,t){ps.renderRoot(e,t)}function Iu(e,t){ps.hydrateRoot(e,t)}function Su(e){ps.unmountRoot(e)}var Cu=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#c(e);if(t==null)return;t.remove(),this.#e.delete(e)}setHost(e){if(this.#t=e,e==null)return;this.#a(e);for(let[t,n]of this.#e)this.#u(t,n)}setSlotContent(e,t){let n=this.#c(e);if(n===t){if(t!=null)this.#e.set(e,t),this.#u(e,t);return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#u(e,t)}setSlotHtml(e,t){let n=t?.trim()??"";if(n.length===0){this.setSlotContent(e,null);return}let r=this.#c(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#u(e,r);return}let i=document.createElement("div");i.innerHTML=n,this.setSlotContent(e,i)}#c(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let r of Array.from(n.children)){if(!(r instanceof HTMLElement))continue;if(r.dataset.fileTreeManagedSlot===e)return r}return null}#u(e,t){if(t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t)this.#t.appendChild(t)}#a(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let n=t.dataset.fileTreeManagedSlot;if(n==null||this.#e.has(n))continue;this.#e.set(n,t)}}};var xu=0;function cm(e){if(e!=null&&e.length>0)return e;return xu+=1,`pst_ft_${xu}`}function um({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??mi)}function ku(e){if(typeof document>"u")return;let t=document.createElement("div");t.innerHTML=e;let n=t.querySelector("svg");return n instanceof SVGElement?n:void 0}function _u(e){return e.querySelector("#file-tree-icon-chevron")instanceof SVGElement&&e.querySelector("#file-tree-icon-file")instanceof SVGElement&&e.querySelector("#file-tree-icon-dot")instanceof SVGElement&&e.querySelector("#file-tree-icon-lock")instanceof SVGElement}function Eu(e){return Array.from(e.children).filter((t)=>t instanceof SVGElement)}var Tr=class{static LoadedCustomComponent=!0;#e;#t;#c;#u;#a;#V;#O;#v;#r;#y=new Cu;#T;#b;#m;#h;#w;#I;#f;#q;#z;#N=null;#i;#W=!1;#$=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:o,initialSearchQuery:s,icons:a,itemHeight:l,onSearchChange:d,onSelectionChange:u,overscan:f,renderRowDecoration:c,renaming:m,search:p,searchBlurBehavior:g,searchFakeFocus:v,stickyFolders:I,unsafeCSS:C,initialVisibleRowCount:y,...S}=e;this.#e=t,this.#c=cm(o),this.#h=Wo(i),this.#w=a,this.#I=C,this.#u=u,this.#a=c,this.#V=m!=null&&m!==!1,this.#O=g,this.#v=p===!0,this.#r=v===!0,this.#T=Ul(n,l),this.#b={itemHeight:this.#T.itemHeight,overscan:f,stickyFolders:I,initialVisibleRowCount:y},this.#t=new oc({...S,fileTreeSearchMode:r,initialSearchQuery:s,onSearchChange:d,renaming:m}),this.#z=this.#t.getSelectionVersion(),this.#N=this.#u==null?null:this.subscribe(()=>{this.#R()})}unmount(){if(this.#i!=null)Su(this.#i),delete this.#i.dataset.fileTreeVirtualizedWrapper,this.#i=void 0;if(this.#y.clearAll(),this.#y.setHost(null),this.#m!=null)delete this.#m.dataset.fileTreeVirtualized,this.#F(this.#m),this.#m=void 0}cleanUp(){this.unmount(),this.#N?.(),this.#N=null,this.#t.destroy()}getFileTreeContainer(){return this.#m}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#T.itemHeight}getDensityFactor(){return this.#T.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=cc(this.#h,e);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Vn(n.wrapper,this.#P())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){if(Array.isArray(e))this.#t.resetPaths(e,t);else this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#s();if(t==null)return;this.#k(),Vn(t.wrapper,this.#P())}setGitStatus(e){let t=Wo(e,this.#h);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Vn(n.wrapper,this.#P())}setIcons(e){this.#w=e;let t=this.#s();if(t==null)return;this.#g(t.host,t.wrapper),Vn(t.wrapper,this.#P())}hydrate({fileTreeContainer:e}){let t=this.#M(e),n=this.#L(t);this.#k(),Iu(n,this.#P())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#M(t??this.#m,e),r=this.#L(n);this.#k(),Vn(r,this.#P())}#Z(){return{initialViewportHeight:um({initialVisibleRowCount:this.#b.initialVisibleRowCount,itemHeight:this.#b.itemHeight}),itemHeight:this.#b.itemHeight,overscan:this.#b.overscan,stickyFolders:this.#b.stickyFolders}}#P(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#h?.statusByPath,ignoredGitDirectories:this.#h?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#h?.directoriesWithChanges,icons:this.#w,instanceId:this.#c,renamingEnabled:this.#V,renderRowDecoration:this.#a,searchBlurBehavior:this.#O,searchEnabled:this.#v,searchFakeFocus:this.#r,slotHost:this.#y,...this.#Z()}}#s(){let e=this.#m,t=this.#i;if(e==null||t==null)return null;return{host:e,wrapper:t}}#g(e,t){let n=e.shadowRoot;if(n!=null)this.#j(n),this.#U(n);this.#K(t)}#R(){let e=this.#u;if(e==null)return;let t=this.#t.getSelectionVersion();if(t===this.#z)return;this.#z=t,e(this.#t.getSelectedPaths())}#k(){let e=this.#e?.header?.render;if(e!=null){this.#y.setSlotContent(wr,e());return}this.#y.setSlotHtml(wr,this.#e?.header?.html??null)}#j(e){let t=Eu(e).find((r)=>_u(r)),n=ku(Vl(Pn(this.#w).set));if(n==null)return;if(t!=null&&t.outerHTML===n.outerHTML)return;if(t!=null)t.replaceWith(n);else e.prepend(n)}#U(e){let t=Eu(e),n=t.find((s)=>_u(s)),r=t.filter((s)=>s!==n),i=Pn(this.#w).spriteSheet?.trim()??"";if(i.length===0){for(let s of r)s.remove();return}let o=ku(i);if(o==null){for(let s of r)s.remove();return}if(r.length===1&&r[0].outerHTML===o.outerHTML)return;for(let s of r)s.remove();e.appendChild(o)}#K(e){let t=Pn(this.#w);if(t.colored&&ql(t.set))e.dataset.fileTreeColoredIcons="true";else delete e.dataset.fileTreeColoredIcons}#l(e){let t=e.querySelector(`style[${Do}]`);if(this.#f==null&&t instanceof HTMLStyleElement)this.#f=t;if(this.#I==null||this.#I===""){this.#f?.remove(),this.#f=void 0,this.#q=void 0;return}if(this.#f?.parentNode===e&&this.#q===this.#I)return;if(this.#f??=document.createElement("style"),this.#f.setAttribute(Do,""),this.#f.parentNode!==e)e.appendChild(this.#f);this.#f.textContent=Kl(this.#I),this.#q=this.#I}#L(e){if(this.#i!=null)return this.#i;let t=e.shadowRoot;if(t==null)throw Error("FileTree requires a shadow root");let n=Array.from(t.children).filter((i)=>i instanceof HTMLDivElement&&typeof i.dataset.fileTreeId==="string"&&i.dataset.fileTreeId.length>0),r=n.find((i)=>i.dataset.fileTreeId===this.#c)??n[0];if(r!=null)this.#c=r.dataset.fileTreeId??this.#c;if(this.#i=r??document.createElement("div"),this.#i.dataset.fileTreeId=this.#c,this.#i.dataset.fileTreeVirtualizedWrapper="true",this.#g(e,this.#i),this.#i.parentNode!==t)t.appendChild(this.#i);return this.#i}#M(e,t){let n=e??this.#m??document.createElement("file-tree-container");if(t!=null&&n.parentNode!==t)t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:"open"});return yi(n,r),this.#l(r),n.dataset.fileTreeVirtualized="true",n.style.display="flex",this.#x(n),this.#y.setHost(n),this.#m=n,n}#x(e){if(e.style.getPropertyValue("--trees-item-height")==="")e.style.setProperty("--trees-item-height",`${String(this.#T.itemHeight)}px`),this.#W=!0;if(e.style.getPropertyValue("--trees-density-override")==="")e.style.setProperty("--trees-density-override",String(this.#T.factor)),this.#$=!0}#F(e){if(this.#W)e.style.removeProperty("--trees-item-height"),this.#W=!1;if(this.#$)e.style.removeProperty("--trees-density-override"),this.#$=!1}};var Tu=["--trees-bg-override: var(--surface-pane)","--trees-bg-muted-override: var(--surface-muted)","--trees-border-color-override: transparent","--trees-fg-override: var(--text)","--trees-font-family-override: var(--font-sans)","--trees-focus-ring-color-override: var(--text-muted)","--trees-padding-inline-override: 8px","--trees-scrollbar-gutter-override: 4px","--trees-search-bg-override: light-dark(var(--surface-base), var(--surface-control))","--trees-selected-bg-override: var(--selection)","--trees-selected-focused-border-color-override: var(--text-muted)"].join("; "),ms=`
|
|
1286
1286
|
[data-item-git-status] > [data-item-section='content'] { color: var(--trees-fg); }
|
|
1287
1287
|
[data-file-tree-virtualized-sticky='true'] { will-change: auto; }
|
|
1288
|
-
`,
|
|
1288
|
+
`,Pu={density:"compact",fileTreeSearchMode:"hide-non-matches",flattenEmptyDirectories:!0,id:"review-file-tree",initialExpansion:"open",initialVisibleRowCount:20,search:!0,searchBlurBehavior:"retain",stickyFolders:!1,unsafeCSS:ms};var On=50;var dm=0.35,hm=0.65;var fm=224,pm=480;var mm=0.3,gm=0.7;function Du(e){if(!zt(e))return{};return{changesRatio:gs(e.changesRatio,mm,gm),gitPaneRatio:gs(e.gitPaneRatio,dm,hm),layout:e.layout==="split"||e.layout==="unified"?e.layout:void 0,mode:e.mode==="all"||e.mode==="selected"?e.mode:void 0,reviewSidebarWidth:gs(e.reviewSidebarWidth,fm,pm),tab:e.tab==="files"||e.tab==="git"?e.tab:void 0,wrap:Ru(e.wrap)?e.wrap:void 0}}function gs(e,t,n){return dn(e)&&Number.isFinite(e)?Math.min(Math.max(e,t),n):void 0}var vm={branch:null,changes:[],commits:[],isGitRepository:!1,changeCount:0,revision:"non-git"},Wy={...vm,revision:"git-unloaded"},Mu=M.ReadonlyObject(M.Object({additions:M.Number(),deletions:M.Number(),path:M.String(),status:M.Union([M.Literal("added"),M.Literal("deleted"),M.Literal("modified"),M.Literal("renamed"),M.Literal("untracked")])})),vs=M.ReadonlyObject(M.Object({author:M.String(),authoredAt:M.String(),hash:M.String(),pushed:M.Union([M.Boolean(),M.Null()]),shortHash:M.String(),subject:M.String()})),ym=M.ReadonlyObject(M.Object({changes:M.ReadonlyObject(M.Array(Mu)),commit:vs,patch:M.String()})),bm=M.ReadonlyObject(M.Object({branch:M.Union([M.String(),M.Null()]),changes:M.ReadonlyObject(M.Array(Mu)),commits:M.ReadonlyObject(M.Array(vs)),isGitRepository:M.Boolean(),changeCount:M.Number(),revision:M.String()})),wm=Di(ym),Im=Di(M.Array(vs)),Sm=Di(bm);function Au(e){return wm.Check(e)}function Nu(e){return Im.Check(e)}function ys(e){return Sm.Check(e)}var Lu=M.Object({path:M.String(),contents:M.String(),revision:M.String(),size:M.Number()}),Cm=M.Union([Lu,M.Object({message:M.String(),path:M.String(),size:M.Number()})]),xm=M.Object({paths:M.Array(M.String()),workspacePath:M.String()}),bs=M.Object({path:M.String()}),km=M.Object({error:M.String()});function Fu(e){let t=`${e}/content`,n=`${e}/entry`;return{async create(r,i){return(await qn(n,bs,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:i,path:r})})).path},async list(){return await qn(e,xm)},async move(r,i){return(await qn(n,bs,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({destination:i,path:r})})).path},async read(r){return await qn(`${t}?path=${encodeURIComponent(r)}`,Cm)},async remove(r){await qn(n,bs,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({path:r})})},async save(r,i,o){return await qn(t,Lu,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({contents:i,path:r,revision:o})})}}}async function qn(e,t,n){let r=await fetch(e,{...n,headers:{accept:"application/json",...n?.headers}});if(!r.ok){let i=`Request failed (${r.status})`;try{i=ws(km,await r.json()).error}catch{}throw Error(i)}return ws(t,await r.json())}function Bu(e){let t=new Set(e);for(let n of e)for(let r=n.indexOf("/");r!==-1;r=n.indexOf("/",r+1))t.add(n.slice(0,r+1));return t}function Mi(e,t,n){if(!t){e.resetPaths(n);return}if(t.length===n.length&&t.every((s,a)=>s===n[a]))return;let r=Bu(t),i=Bu(n),o=[];for(let s of n)if(!r.has(s))o.push({type:"add",path:s});for(let s of[...r].filter((a)=>!i.has(a)).sort((a,l)=>l.length-a.length))o.push({type:"remove",path:s});if(o.length>0)e.batch(o)}function zu(e){let t=Fu(e.endpoint),n=lt("workspace-file-tree"),r=lt("workspace-file-main"),i=lt("workspace-file-view"),o=lt("workspace-file-empty"),s=lt("workspace-file-path"),a=lt("workspace-file-status"),l=Wn("workspace-file-edit"),d=Wn("workspace-file-download"),u=Wn("workspace-file-wrap"),f=Ou("workspace-entry-dialog"),c=lt("workspace-entry-title"),m=lt("workspace-entry-description"),p=Tm("workspace-entry-input"),g=lt("workspace-entry-error"),v=Wn("workspace-entry-action"),I=Ou("workspace-confirm-dialog"),C=lt("workspace-confirm-title"),y=lt("workspace-confirm-description"),S=Wn("workspace-confirm-cancel"),x=Wn("workspace-confirm-action");n.style.cssText=Tu;let T=e.initialWorkspacePath,O=[],fe,Z=!1,pe=!1,J=0,K=0,B,ae,Se="",z=!1,le=!0,X,ye=new qu(Ve()),oe=new Tr({composition:{contextMenu:{enabled:!0,render:bt,triggerMode:"right-click"}},density:"compact",fileTreeSearchMode:"hide-non-matches",flattenEmptyDirectories:!0,gitStatus:e.initialGitStatus,id:"workspace-files-tree",initialExpansion:"closed",paths:[],search:!0,searchBlurBehavior:"retain",stickyFolders:!1,unsafeCSS:ms,onSelectionChange(w){let A=w.length===1?w[0]:void 0;if(!A)return;let H=oe.getItem(A);if(H?.isDirectory()){de(""),H.deselect();return}rt(A)}});oe.render({containerWrapper:n}),d.addEventListener("click",()=>{let w=ae;if(!w)return;let A=document.createElement("a");A.href=`${e.endpoint}/content?path=${encodeURIComponent(w)}&download=1`,A.download=w.split("/").at(-1)??"download",A.click()}),l.addEventListener("click",()=>void Xt()),i.addEventListener("keydown",(w)=>{if((w.ctrlKey||w.metaKey)&&!w.altKey&&!w.shiftKey&&w.code==="KeyS")w.preventDefault(),Xt()}),u.addEventListener("click",()=>{le=!le,u.setAttribute("aria-pressed",String(le)),ye.setOptions(Ve())}),window.addEventListener("pi-ui-code-theme-changed",()=>{ye.setOptions(Ve()),ye.rerender()});function bt(w,A){let H=document.createElement("div");return H.className="workspace-tree-context-menu",H.setAttribute("role","menu"),H.append(He("New file",()=>{A.close({restoreFocus:!1}),ct(w,"file")}),He("New folder",()=>{A.close({restoreFocus:!1}),ct(w,"folder")}),He("Rename",()=>{A.close({restoreFocus:!1}),Pt(w)}),He("Delete",()=>{A.close({restoreFocus:!1}),tt(w)},!0)),H}function He(w,A,H=!1){let j=document.createElement("button");return j.type="button",j.className=`workspace-tree-context-menu-item${H?" workspace-tree-context-menu-item-destructive":""}`,j.setAttribute("role","menuitem"),j.textContent=w,j.addEventListener("click",A),j}async function ct(w,A){let H=await G({title:`New ${A}`,description:`Enter a name for the new ${A}.`,action:"Create"});if(!H)return;let j=w.kind==="directory"?w.path:Hu(w.path),It=Vu(j,H);try{let en=await t.create(It,A);if(await ut(!0),A==="file")await Ce(en);else{let Jn=oe.getItem(en);if(Jn&&"expand"in Jn)Jn.expand()}}catch(en){de(Wt(en))}}async function Pt(w){if(Ee(w.path)&&z){await Dt("Unsaved changes","Save or discard your changes before renaming this item.");return}let A=await G({title:`Rename ${w.kind==="directory"?"folder":"file"}`,description:`Enter a new name for ${w.name}.`,action:"Rename",initialValue:w.name});if(!A||A===w.name)return;let H=Vu(Hu(w.path),A),j=B&&Ee(w.path)?`${H}${B.path.slice(w.path.length)}`:void 0;try{if(await t.move(w.path,H),j)We();if(await ut(!0),j)await Ce(j)}catch(It){de(Wt(It))}}async function tt(w){if(Ee(w.path)&&z){await Dt("Unsaved changes","Save or discard your changes before deleting this item.");return}let A=w.kind==="directory"?"folder":"file";if(!await dt({title:`Delete ${A}?`,description:`This will permanently delete ${w.name}${w.kind==="directory"?" and all of its contents":""}. This action cannot be undone.`,action:"Delete"}))return;try{if(await t.remove(w.path),Ee(w.path))We();await ut(!0)}catch(H){de(Wt(H))}}function We(){K+=1,Rt(),B=void 0,Se="",z=!1,mn(),s.textContent="Select a file",de(""),Me("Open a file from the workspace"),je()}function Ee(w){return B?.path===w||B?.path.startsWith(`${w}/`)===!0}function Ve(){return{disableFileHeader:!0,overflow:le?"wrap":"scroll",theme:Pr(),themeType:"system",onEditChange({file:w}){Se=w.contents,z=Se!==B?.contents,je()},unsafeCSS:`
|
|
1289
1289
|
@media (prefers-reduced-motion: no-preference) {
|
|
1290
1290
|
[data-caret] {
|
|
1291
1291
|
animation-timing-function: step-end;
|
|
@@ -1299,7 +1299,7 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
1299
1299
|
[data-file] {
|
|
1300
1300
|
min-width: 100%;
|
|
1301
1301
|
}
|
|
1302
|
-
`}}function Kt(w){if(pe=w,pe)ut()}async function Ce(w){pe=!0,await ut();for(let H of oe.getSelectedPaths())oe.getItem(H)?.deselect();let A=oe.getItem(w);if(A)A.select();else await rt(w)}function wt(w=!0){Gt(w)}function $e(w){if(B?.path===w)z=!1,je();Gt()}async function Gt(w=!0){let A=B,H=K;if(await ut(w),!A||B!==A||K!==H)return;try{let j=await t.read(A.path);if(B!==A||K!==H)return;if("message"in j){if(z)de("File changed on disk");else We(),pn(j.path),s.textContent=j.path,de(qn(j.size)),De(j.message);return}if(j.revision===A.revision)return;if(z){de("File changed on disk");return}let It=++K;Pt(),B=j,Se=j.contents,ye.render({file:{cacheKey:`${T}:${j.path}:${j.revision}`,contents:j.contents,name:j.path},containerWrapper:i}),de(qn(j.size)),je(),await fn(It)}catch(j){if(B!==A||K!==H)return;de(zt(j))}}function nt(w){oe.setGitStatus(w)}function be(w){if(T===w)return;if(T=w,O=[],fe=void 0,J+=1,We(),oe.resetPaths([]),pe)ut()}async function ut(w=!1){if(w)Z=!0;let A=++J;if(!pe||!Z&&fe===T)return;if(!w)de("Loading files…");try{let H=await t.list();if(A!==J||H.workspacePath!==T)return;if(Di(oe,fe===T?O:void 0,H.paths),fe=T,O=H.paths,Z=!1,ae){if(B)de(qn(B.size));return}let j=H.paths.includes("README.md")?"README.md":H.paths.find((It)=>!It.endsWith("/"));if(j)oe.getItem(j)?.select();else de(""),De("No files in this workspace")}catch(H){if(A!==J)return;de(zt(H)),De("Could not load workspace files")}}async function rt(w){if(B?.path===w)return;if(z&&!await dt({title:"Discard unsaved changes?",description:`Your unsaved changes to ${B?.path??"this file"} will be lost.`,action:"Discard"})){oe.getItem(w)?.deselect(),oe.getItem(B?.path??"")?.select();return}let A=++K;Pt(),z=!1,s.textContent=w,pn(),de("");try{let H=await t.read(w);if(A!==K)return;if(pn(H.path),de(qn(H.size)),"message"in H){B=void 0,De(H.message),je();return}B=H,Se=H.contents,s.textContent=H.path,ye.render({file:{cacheKey:`${T}:${H.path}:${H.revision}`,contents:H.contents,name:H.path},containerWrapper:i}),$i(),de(qn(H.size)),je(),await fn(A)}catch(H){if(A!==K)return;B=void 0,de(""),De(zt(H)),je()}}async function fn(w){l.disabled=!0;try{let{Editor:A}=await import("./index-wmew1h99.js");if(w!==K||!B)return;X=new A("file"),X.edit(ye)}catch(A){X=void 0,de(zt(A))}finally{je()}}async function Yt(){if(!B||!X||!z)return;l.disabled=!0,de("Saving…");try{B=await t.save(B.path,Se,B.revision),Se=B.contents,z=!1,de(qn(B.size))}catch(w){de(zt(w))}finally{je()}}function Pt(){X?.cleanUp("discard"),X=void 0,je()}function pn(w){ae=w,d.disabled=!w}function je(){l.disabled=!B||!X||!z}function De(w){o.textContent=w,o.style.display="grid",i.style.display="none"}function $i(){o.style.display="none",i.style.display="block"}function de(w){a.textContent=w}function G(w){return c.textContent=w.title,m.textContent=w.description,v.textContent=w.action,p.value=w.initialValue??"",g.textContent="",g.hidden=!0,f.returnValue="",new Promise((A)=>{f.addEventListener("close",()=>A(f.returnValue==="submit"?p.value:void 0),{once:!0}),f.showModal(),p.select()})}function mn(){if(!_m(p.value)){g.textContent="Use a non-empty name without slashes, '.', or '..'.",g.hidden=!1;return}f.close("submit")}function dt(w){return C.textContent=w.title,y.textContent=w.description,x.textContent=w.action,S.hidden=w.showCancel===!1,x.dataset.variant=w.destructive===!1?"default":"destructive",I.returnValue="",new Promise((A)=>{I.addEventListener("close",()=>A(I.returnValue==="confirm"),{once:!0}),I.showModal()})}async function Rt(w,A){await dt({title:w,description:A,action:"OK",showCancel:!1,destructive:!1})}v.addEventListener("click",mn),p.addEventListener("keydown",(w)=>{if(w.key!=="Enter"||w.isComposing)return;w.preventDefault(),mn()});function Xt(){let w=oe.getSelectedPaths()[0]??oe.getFocusedPath()??O[0];if(w)oe.scrollToPath(w,{focus:!0});requestAnimationFrame(()=>{(n.querySelector("file-tree-container")?.shadowRoot?.querySelector('[role="tree"]')??n).focus({preventScroll:!0})})}function Qt(){(B?i:r).focus({preventScroll:!0})}function Zt(){Pt(),ye.cleanUp(),oe.cleanUp()}return je(),De("Open a file from the workspace"),{cleanUp:Zt,focusEditor:Qt,focusTree:Xt,openFile:Ce,refresh:wt,refreshAfterDiscard:$e,requestConfirmation:dt,requestNotice:Rt,setGitStatus:nt,setVisible:Kt,setWorkspace:be}}function zt(e){return String(e).replace(/^Error: /,"")}function _m(e){return Boolean(e&&e===e.trim()&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\"))}function Bu(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Hu(e,t){return e?`${e}/${t}`:t}function qn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(1)} MB`}function lt(e){let t=document.getElementById(e);if(!(t instanceof HTMLElement))throw Error(`Missing #${e}`);return t}function zn(e){let t=document.getElementById(e);if(!(t instanceof HTMLButtonElement))throw Error(`Missing #${e}`);return t}function Vu(e){let t=document.getElementById(e);if(!(t instanceof HTMLDialogElement))throw Error(`Missing #${e}`);return t}function Em(e){let t=document.getElementById(e);if(!(t instanceof HTMLInputElement))throw Error(`Missing #${e}`);return t}function zu(e){return{async loadDiff(t,n,r){let i=new URLSearchParams({workspacePath:t});if(n!==void 0)i.set("path",n);let o=await fetch(`${e}/diff?${i}`,{signal:r});if(o.ok)return o.text();let s=await o.json();throw Error(qt(s)&&Wn(s.error)?s.error:`Unable to load diff (${o.status})`)},async discard(t){let n=await fetch(`${e}/discard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:t})});if(n.ok)return;let r=`Request failed (${n.status})`;try{let i=await n.json();if(qt(i)&&Wn(i.error))r=i.error}catch{}throw Error(r)},async loadCommit(t){try{let n=await fetch(`${e}/commit?hash=${encodeURIComponent(t)}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Mu(r)?r:void 0}catch{return}},async loadHistory(t){try{let n=await fetch(`${e}/history?offset=${t}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Au(r)?r:void 0}catch{return}}}}var Mi=globalThis.navigator?.platform??globalThis.process?.platform,Wu=Mi==="win32"||Mi?.startsWith("Win")?"windows":Mi==="darwin"||Mi?.startsWith("Mac")?"darwin":"linux";function $u(e,t=Wu){return t==="darwin"?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function ju(){let e=new Map,t=new Map,n=0;function r(f,c,m){if(a())return!1;let p={lineNumber:Math.max(m.start,m.end),metadata:{body:null,id:`review-comment-${++n}`,range:{...m}},side:Tm(m)};return e.set(f,[...e.get(f)??[],p]),t.set(f,c),!0}function i(f,c){let m=c.trim();if(!m)return;return u(f,(p)=>({...p,metadata:{...p.metadata,body:m}}))}function o(f){for(let[c,m]of e){let p=m.filter((g)=>g.metadata.id!==f);if(p.length===m.length)continue;if(p.length>0)e.set(c,p);else e.delete(c),t.delete(c);return c}return}function s(f,c){let m=[];for(let p of e.keys()){if(!f.has(p)&&c?.has(p))continue;if(f.get(p)===t.get(p))continue;e.delete(p),t.delete(p),m.push(p)}return m}function a(){for(let f of e.values())if(f.some((c)=>c.metadata.body===null))return!0;return!1}function l(){let f=[];for(let[c,m]of e)for(let p of m){let g=p.metadata.body;if(g===null)continue;f.push({body:g,endLine:p.metadata.range.end,endSide:p.metadata.range.endSide??p.metadata.range.side??p.side,path:c,startLine:p.metadata.range.start,startSide:p.metadata.range.side??p.side})}return f}function d(){e.clear(),t.clear()}function u(f,c){for(let[m,p]of e){let g=p.findIndex((I)=>I.metadata.id===f);if(g<0)continue;let v=[...p];return v[g]=c(v[g]),e.set(m,v),m}return}return{add:r,annotations:e,hasDraft:a,reconcileFiles:s,remove:o,reset:d,save:i,savedComments:l}}function Tm(e){return e.endSide??e.side??"additions"}var Pm=navigator.userAgent.includes("Macintosh")?"darwin":"linux";function Ku(e){let t=ju(),n,r=!1;e.submitButton.addEventListener("click",()=>void u()),f();function i(p,g){let v=p.fileDiff.name;if(t.add(v,Uu(p.fileDiff),g))d(v)}function o(p){if(!("side"in p))return;let{metadata:g}=p,v=document.createElement("div");v.className="review-comment-wrapper",v.dataset.reviewCommentId=g.id;let I=document.createElement("div");I.className="review-comment-card",v.append(I);let C=document.createElement("p");if(C.className="review-comment-label",C.textContent=Rm(g.range,p.side),I.append(C),g.body===null)s(I,g.id);else a(I,g.id,g.body);return v}function s(p,g){let v=document.createElement("textarea");v.className="textarea review-comment-input",v.placeholder="Leave a comment for the agent…",v.setAttribute("aria-label","Review comment");let I=document.createElement("div");I.className="review-comment-actions";let C=ws("Add comment");C.disabled=!0;let y=ws("Cancel","outline"),S=()=>{let x=t.save(g,v.value);if(!x)return;d(x),e.clearSelection()};C.addEventListener("click",S),y.addEventListener("click",()=>l(g)),v.addEventListener("input",()=>{C.disabled=v.value.trim()===""}),v.addEventListener("keydown",(x)=>{if(x.key==="Escape")x.preventDefault(),l(g);else if(x.key==="Enter"&&$u(x,Pm))x.preventDefault(),S()}),I.append(C,y),p.append(v,I),setTimeout(()=>v.focus(),0)}function a(p,g,v){let I=document.createElement("p");I.className="review-comment-body",I.textContent=v;let C=document.createElement("div");C.className="review-comment-actions";let y=ws("Remove","ghost");y.classList.add("error-foreground"),y.addEventListener("click",()=>l(g)),C.append(y),p.append(I,C)}function l(p){let g=t.remove(p);if(!g)return;e.clearSelection(),d(g)}function d(p){n=void 0,f(),e.onAnnotationsChange(p)}async function u(){let p=t.savedComments();if(p.length===0||t.hasDraft()||r)return;r=!0,n=void 0,f();let g=await e.submit(p).catch(()=>!1);if(r=!1,!g){n="Couldn’t send",f();return}t.reset(),f(),e.onSubmitted()}function f(){let p=t.savedComments().length,g=t.hasDraft();e.submitButton.hidden=p===0&&!g,e.submitButton.disabled=p===0||g||r,e.submitButton.textContent=r?"Sending…":`Submit review${p>0?` (${p})`:""}`,e.status.hidden=!n,e.status.textContent=n??""}function c(p,g){if(t.reconcileFiles(new Map(p.filter((I)=>t.annotations.has(I.fileDiff.name)).map((I)=>[I.fileDiff.name,Uu(I.fileDiff)])),g).length===0)return;e.clearSelection(),n="Changes updated; outdated comments removed",f()}function m(){t.reset(),n=void 0,f()}return{add:i,annotations:t.annotations,canAdd:()=>!t.hasDraft(),reconcileItems:c,render:o,reset:m}}function ws(e,t){let n=document.createElement("button");if(n.type="button",n.className="btn",n.dataset.size="xs",t)n.dataset.variant=t;return n.textContent=e,n}function Uu(e){return JSON.stringify(e)}function Rm(e,t){let n=e.side??t,r=e.endSide??e.side??t,i=(a)=>a==="additions"?"new":"old";if(n!==r)return`${i(n)} line ${e.start} to ${i(r)} line ${e.end}`;let o=Math.min(e.start,e.end),s=Math.max(e.start,e.end);return o===s?`${i(n)} line ${o}`:`${i(n)} lines ${o}–${s}`}function Qu({commits:e,getCommitDetail:t,history:n,loading:r,onSelectCommit:i,onSelectCommitPath:o,revision:s,selection:a}){let l=n.scrollTop;if(n.replaceChildren(),e.length===0){let u=document.createElement("p");u.className="review-history-message",u.textContent=s==="git-unloaded"?"Loading history…":"No commits yet",n.append(u);return}let d;for(let u of e){if(u.pushed!==d)n.append(Dm(u.pushed)),d=u.pushed;let f=a.kind==="commit"&&a.hash===u.hash,c=document.createElement("div"),m=document.createElement("button");m.type="button",m.className="review-commit",m.setAttribute("aria-pressed",String(f)),m.title=u.subject,m.addEventListener("click",()=>i(u.hash));let p=document.createElement("span");p.className="review-commit-subject",p.textContent=u.subject||"Untitled commit";let g=document.createElement("span");g.className="fine-print review-commit-meta";let v=document.createElement("span");v.className="review-commit-hash",v.textContent=u.shortHash;let I=document.createElement("span");I.className="review-commit-author",I.textContent=u.author;let C=document.createElement("time");if(C.className="formatted-date",C.dateTime=u.authoredAt,C.title=ed(u.authoredAt),C.textContent=Am(u.authoredAt),g.append(v,I,C),m.append(p,g),c.append(m),f){let y=t(u.hash);if(y)c.append(Mm(u.hash,y.changes,a.path,o))}n.append(c)}if(r){let u=document.createElement("p");u.className="fine-print review-history-loading",u.textContent="Loading older commits…",n.append(u)}n.scrollTop=l}function Zu(e,t){e.replaceChildren(),e.hidden=!1;let n=document.createElement("div");n.className="review-detail-heading";let r=document.createElement("div");r.className="review-detail-subject",r.textContent=t.commit.subject||"Untitled commit";let i=document.createElement("span");i.className="review-detail-totals";let o=document.createElement("span");o.className="review-additions",o.textContent=`+${Gu(t.changes,"additions")}`;let s=document.createElement("span");s.className="review-deletions",s.textContent=`-${Gu(t.changes,"deletions")}`,i.append(o,s),n.append(r,i);let a=document.createElement("div");a.className="fine-print review-detail-meta";let l=document.createElement("span");l.className="review-detail-hash",l.textContent=t.commit.shortHash;let d=document.createElement("span");d.className="review-detail-author",d.textContent=t.commit.author;let u=document.createElement("time");u.className="formatted-date",u.dateTime=t.commit.authoredAt,u.title=ed(t.commit.authoredAt),u.textContent=u.title,a.append(l,d,u),e.append(n,a)}function Ju(e){e.hidden=!0,e.replaceChildren()}function Dm(e){let t=document.createElement("div");t.className="fine-print review-push-group";let n=document.createElement("span");n.textContent=e===null?"No upstream":e?"Pushed":"Not pushed";let r=document.createElement("span");return r.className="review-push-rule",t.append(n,r),t}function Mm(e,t,n,r){let i=document.createElement("div");i.className="review-commit-files";for(let o of t){let s=document.createElement("button");s.type="button",s.className="fine-print review-commit-file",s.setAttribute("aria-pressed",String(n===o.path)),s.title=o.path,s.addEventListener("click",()=>r(e,o.path));let a=document.createElement("span");a.className="review-commit-file-status",a.textContent=Nm(o.status);let l=document.createElement("span");l.className="review-commit-file-path",l.textContent=o.path,s.append(a,l),i.append(s)}return i}function ed(e,t){return Xu(new Date(e),t)}function Am(e,t=new Date,n){return Yu(new Date(e),t,n)}function Gu(e,t){return e.reduce((n,r)=>n+r[t],0)}function Nm(e){if(e==="added")return"A";if(e==="deleted")return"D";if(e==="renamed")return"R";if(e==="untracked")return"U";return"M"}function Pr(e){return e==="git-unloaded"}function td(e,t){return e.workspacePath!==t.workspacePath||e.revision!==t.revision}function nd(e,t,n){if(e[0]?.hash!==n[0]?.hash)return{commits:[...n],hasMore:n.length===Vn,reset:!0};let i=new Set(n.map(({hash:o})=>o));return{commits:[...n,...e.slice(Vn).filter(({hash:o})=>!i.has(o))],hasMore:t,reset:!1}}function rd(e,t){if(e.kind==="commit"&&t[0])return{kind:"working",path:t[0].path};return e}function id(e,t,n,r){if(t){if(n[0])return{kind:"working",path:n[0].path};if(r[0])return{hash:r[0].hash,kind:"commit"};return{kind:"working"}}if(e.kind!=="working")return e;return{kind:"working",path:n.some(({path:i})=>i===e.path)?e.path:n[0]?.path}}function od(e,t){let n=new Set(e.map(({hash:i})=>i)),r=t.filter(({hash:i})=>!n.has(i));return{commits:[...e,...r],hasMore:t.length===Vn&&r.length>0}}var Lm=10,Fm=2,sd=document.body.dataset.codeThemeLight,ad=document.body.dataset.codeThemeDark;if(sd&&ad)ks({dark:ad,light:sd});var Bm=document.body.dataset.workspaceReviewEndpoint??"",Hm=document.body.dataset.workspaceFilesEndpoint??"",Bi=zu(Bm);window.addEventListener("pi-ui-code-theme-changed",(e)=>{if(!(e instanceof CustomEvent)||!md(e.detail))return;let t=e.detail;if(ks(t),Fe)Hd().setRenderOptions({theme:t}).then(Yn).catch((n)=>console.error("Failed to update workspace theme",n))});var Vm=et("app"),Om=document.querySelectorAll("[data-workspace-mode]"),Li=et("review-tree"),vt=et("review-history"),gd=et("review-detail-header"),jn=et("review-diff-view"),qm=et("workspace-file-tree"),ld=et("workspace-file-view"),cd=et("review-empty"),vd=Qn("review-mode-all"),yd=Qn("review-mode-selected"),bd=Qn("review-layout-split"),wd=Qn("review-layout-stacked"),Is=Qn("review-wrap"),zm=et("workspace-review"),Wm=Qn("review-submit-comments"),$m=et("review-comment-status"),jm=et("workspace-review-data-region"),Um=et("workspace-review-data"),mt=JSON.parse(Um.textContent??"");if(!qt(mt)||!un(mt.filesRevision)||!un(mt.treeRevision)||!Wn(mt.workspacePath)||!vs(mt.snapshot))throw Error("Invalid initial workspace review state");var Hi=Ru(mt.preferences),Wt=mt.workspacePath,ud=mt.filesRevision,dd=mt.treeRevision,q=mt.snapshot,dn=[...q.commits],Un=q.commits.length===Vn,Kn=!1,Fi=0,Ze=Hi.mode??"selected",U={kind:"working",path:q.changes[0]?.path},_s=Hi.layout,$n=Hi.wrap??!0,Id=0,Ss=new Map,Fe,Cs,jt=Ku({clearSelection:()=>Fe?.clearSelectedLines(),onAnnotationsChange:m1,onSubmitted(){if(Qe=Ld(Qe),U.kind==="working")Je=Qe,Ut=Ar(Je),Fe?.clearSelectedLines(),hn();window.piUi.messageScroll.scrollBottom()},status:$m,submit:f1,submitButton:Wm}),Qe=[],Rr,Es,Dr,Je=Qe,Ut=Ar(Je),Ai=q.revision!=="git-unloaded",Vi=new Map,Ni=new Map,xs=0,Be=qu({endpoint:Hm,initialGitStatus:q.changes,initialWorkspacePath:Wt}),Oi=Hi.tab,gt=n1(Oi,q.isGitRepository),yt=d1(Vm,!0,(e)=>{if(Be.setVisible(e&>==="files"),e&>==="git")qd();else Gn()});for(let e of Om)e.addEventListener("click",()=>{let t=e.dataset.workspaceMode;if(t==="files"||t==="git"&&q.isGitRepository)Nr(t)});var Ge=new Er({...Tu,composition:{contextMenu:{enabled:!0,render:c1,triggerMode:"right-click"}},gitStatus:q.changes,paths:q.changes.map(({path:e})=>e),onSelectionChange(e){let t=e.length===1?e[0]:void 0;if(t&&!Ge.getItem(t)?.isDirectory())Pd(t,!0)}});Ge.render({containerWrapper:Li});a1();window.piUi.workspaceReview={...yt,focusEditor:s1,focusFiles:r1,focusGit:i1};vt.addEventListener("scroll",zi,{passive:!0});vt.addEventListener("keydown",o1);vd.addEventListener("click",()=>Ed("all"));yd.addEventListener("click",()=>Ed("selected"));bd.addEventListener("click",()=>Td("split"));wd.addEventListener("click",()=>Td("unified"));Is.addEventListener("click",()=>{$n=!$n,Is.setAttribute("aria-pressed",String($n)),Lr(),Yn()});var Mr=Xn(),Sd=new ResizeObserver(()=>{let e=Xn();if(Ps(e),e===Mr)return;Mr=e,Yn()});Sd.observe(jn);var Cd=new MutationObserver(Yn);Cd.observe(document.documentElement,{attributeFilter:["class"],attributes:!0});function xd(){try{let e=document.getElementById("workspace-review-data"),t=JSON.parse(e?.textContent??"");if(qt(t)&&un(t.filesRevision)&&un(t.treeRevision)&&Wn(t.workspacePath)&&vs(t.snapshot)){let n=t.workspacePath===Wt&&t.filesRevision!==ud,r=t.treeRevision!==dd;if(ud=t.filesRevision,dd=t.treeRevision,n)Ad();if(Km(t.workspacePath,t.snapshot),n){if(Be.refresh(r),U.kind==="working")qi(U.path)}}}catch{}}var kd=new MutationObserver(xd);kd.observe(jm,{characterData:!0,childList:!0,subtree:!0});Ts();Ps();Is.setAttribute("aria-pressed",String($n));_d(q);xd();window.addEventListener("pagehide",()=>{kd.disconnect(),Sd.disconnect(),Cd.disconnect(),Ge.cleanUp(),Be.cleanUp(),Fe?.cleanUp(),Gn(),fo()},{once:!0});function Km(e,t){if(!td({revision:q.revision,workspacePath:Wt},{revision:t.revision,workspacePath:e}))return;if(e!==Wt)Wt=e,Be.setWorkspace(Wt),xs++,Fi++,dn=[],Un=!1,Kn=!1,Vi.clear(),Ni.clear(),Ss.clear(),jt.reset(),Ai=!1,U={kind:"working"};_d(t)}function _d(e){let t=Pr(q.revision)||!Ai,n=t?void 0:q.changes.map(({path:o})=>o),r=q.isGitRepository,i=nd(dn,Un,e.commits);if(q=e,Be.setGitStatus(q.changes),dn=i.commits,Un=i.hasMore,i.reset)Fi++,Kn=!1;if(!q.isGitRepository)gt="files";else if(!r&&Oi!=="files")gt="git";if(Be.setVisible(yt.isOpen()&>==="files"),Ad(),Di(Ge,n,q.changes.map(({path:o})=>o)),Ge.setGitStatus(q.changes),Pr(q.revision)){Ai=!1,Et(),Fe?.setItems([]),$t("Loading Git data…");return}if(U=id(U,t,Md(),q.commits),t)Ai=!0;if(Et(),yt.isOpen()&>==="git")requestAnimationFrame(zi);if(U.kind==="commit")Rd(U.hash,U.path);else qi(U.path)}function Ed(e){if(Ze=e,Ts(),Lr(),Ze==="selected"&&!U.path)U.path=Je[0]?.fileDiff.name;Et(),hn()}function Td(e){_s=e,Mr=Xn(),Ps(Mr),Lr(),Yn()}function Pd(e,t=!1){if(t&&Dr&&Ze==="all")Ze="selected",Ts(),Lr();if(qi(e),Et(),e&&!t)Ge.scrollToPath(e,{focus:!1,offset:"nearest"});if(e)Dd(e)}function qi(e){U={kind:"working",path:e},Je=Qe,Ut=Ar(Je),t1(),hn()}async function Rd(e,t){Gn(),U={hash:e,kind:"commit",path:t},Xm(),Et();let n=Vi.get(e);if(n){hd(n,t);return}$t("Loading commit…");let r=await Gm(e);if(U.kind!=="commit"||U.hash!==e)return;if(!r){$t("Unable to load commit");return}hd(r,t)}function hd(e,t){Je=e.items,Ut=Ar(Je),U={hash:e.detail.commit.hash,kind:"commit",path:t&&Ut.has(t)?t:Je[0]?.fileDiff.name},e1(e.detail),Et(),hn()}function Gm(e){let t=Ni.get(e);if(t)return t;let n=xs,r=Bi.loadCommit(e).then((i)=>{if(!i)return;let o={detail:i,items:Nd(i.changes,i.patch,i.commit.hash)};if(n!==xs)return;return Vi.set(e,o),o}).finally(()=>Ni.delete(e));return Ni.set(e,r),r}function Ym(e,t){if(U.kind!=="commit"||U.hash!==e)return;if(U.path=t,Et(),Ze==="selected")hn();else Dd(t)}function Dd(e){let t=Ut.get(e);if(t&&Fe)Fe.scrollTo({type:"item",id:t.id,align:"start",behavior:"smooth-auto"})}function Md(){let e=new Set(q.changes.map(({path:r})=>r)),t=Ge.getVisibleRows(0,Ge.getVisibleCount()).find((r)=>r.kind==="file"&&e.has(r.path))?.path;if(!t||t===q.changes[0]?.path)return q.changes;let n=q.changes.find(({path:r})=>r===t);return n?[n,...q.changes.filter(({path:r})=>r!==t)]:q.changes}function Xm(){for(let e of Ge.getSelectedPaths())Ge.getItem(e)?.deselect()}function Gn(){Rr?.abort(),Rr=void 0,Es=void 0,Dr=void 0}function Ad(){Gn(),Qe=[],jt.reconcileItems([],new Set(q.changes.map((e)=>e.path)))}async function Qm(e){Gn(),Es=e;let t=new AbortController;Rr=t,Fe?.setItems([]),$t("Loading diff…");let n=Ze==="selected"?U.path:void 0,r=q.changes.filter((i)=>n===void 0||i.path===n);try{let i=await Bi.loadDiff(Wt,n,t.signal);if(t.signal.aborted)return;let o=Nd(r,i,"working");jt.reconcileItems(o,new Set(q.changes.map((s)=>s.path))),Qe=Ld(o)}catch(i){if(t.signal.aborted)return;Qe=[],Dr=i instanceof Error?i.message:"Unable to load diff"}finally{if(!t.signal.aborted)Rr=void 0,qi(U.path)}}function hn(){if(!yt.isOpen()||gt!=="git")return;if(U.kind==="working"&&q.changes.length>0&&!Pr(q.revision)){let t=JSON.stringify([Ze,Ze==="selected"?U.path:null]);if(Es!==t){Qm(t);return}if(Rr||Dr){$t(Dr??"Loading diff…");return}}let e=Ze==="all"?Je:U.path&&Ut.has(U.path)?[Ut.get(U.path)]:[];if(e.length===0){Fe?.setItems([]),$t(h1());return}if($t(),!Fe){Mr=Xn();let t=Bd();Fe=new pd(t,Hd()),Cs=t.enableGutterUtility,Fe.setup(jn)}else if(Cs!==Fd())Yn();Fe.setItems(e)}function Nd(e,t,n){let r=new Map;for(let i of fd(t))for(let o of i.files)r.set(o.name,o);return e.map((i)=>{let o=r.get(i.path)??Zm(i),s=`${n}:${i.path}`,a=JSON.stringify({...o,cacheKey:void 0}),l=Ss.get(s),d=l?.content===a?l.version:++Id;return Ss.set(s,{content:a,version:d}),{fileDiff:{...o,cacheKey:`pi-ui:${s}:${d}`},id:`diff:${s}`,type:"diff",version:d}})}function Ld(e){return e.map((t)=>({...t,annotations:jt.annotations.get(t.fileDiff.name)}))}function Ar(e){return new Map(e.map((t)=>[t.fileDiff.name,t]))}function Zm(e){return{additionLines:[],deletionLines:[],hunks:[],isPartial:!0,name:e.path,splitLineCount:0,type:e.status==="added"||e.status==="untracked"?"new":e.status==="deleted"?"deleted":e.status==="renamed"?"rename-pure":"change",unifiedLineCount:0}}function Et(){Qu({commits:dn,getCommitDetail:(e)=>Vi.get(e)?.detail,history:vt,loading:Kn,onSelectCommit:(e)=>void Rd(e),onSelectCommitPath:Ym,revision:q.revision,selection:U})}function zi(){if(!yt.isOpen()||Kn||!Un||vt.scrollHeight-vt.scrollTop-vt.clientHeight>120)return;Jm()}async function Jm(){Kn=!0;let e=Fi;Et();let t=await Bi.loadHistory(dn.length);if(e!==Fi)return;if(t){let n=od(dn,t);dn=n.commits,Un=n.hasMore}else Un=!1;Kn=!1,Et(),requestAnimationFrame(zi)}function e1(e){Zu(gd,e)}function t1(){Ju(gd)}function Fd(){return U.kind==="working"&&jt.canAdd()}function Yn(){if(!Fe)return;let e=Bd();Fe.setOptions(e),Cs=e.enableGutterUtility}function Bd(){let e=Fd();return{diffIndicators:"none",enableGutterUtility:e,enableLineSelection:e,onGutterUtilityClick(t,n){if(n.item.type==="diff")jt.add(n.item,t)},pointerEventsOnScroll:!0,renderAnnotation:jt.render,diffStyle:Xn(),hunkSeparators:"simple",itemMetrics:{diffHeaderHeight:36,paddingBottom:0,spacing:0},layout:{gap:Fm,paddingBottom:Lm,paddingTop:0},lineHoverHighlight:"both",overflow:$n?"wrap":"scroll",stickyHeaders:!0,theme:Tr(),themeType:document.documentElement.classList.contains("dark")?"dark":"light",unsafeCSS:`
|
|
1302
|
+
`}}function Gt(w){if(pe=w,pe)ut()}async function Ce(w){pe=!0,await ut();for(let H of oe.getSelectedPaths())oe.getItem(H)?.deselect();let A=oe.getItem(w);if(A)A.select();else await rt(w)}function wt(w=!0){Yt(w)}function $e(w){if(B?.path===w)z=!1,je();Yt()}async function Yt(w=!0){let A=B,H=K;if(await ut(w),!A||B!==A||K!==H)return;try{let j=await t.read(A.path);if(B!==A||K!==H)return;if("message"in j){if(z)de("File changed on disk");else We(),mn(j.path),s.textContent=j.path,de(zn(j.size)),Me(j.message);return}if(j.revision===A.revision)return;if(z){de("File changed on disk");return}let It=++K;Rt(),B=j,Se=j.contents,ye.render({file:{cacheKey:`${T}:${j.path}:${j.revision}`,contents:j.contents,name:j.path},containerWrapper:i}),de(zn(j.size)),je(),await pn(It)}catch(j){if(B!==A||K!==H)return;de(Wt(j))}}function nt(w){oe.setGitStatus(w)}function be(w){if(T===w)return;if(T=w,O=[],fe=void 0,J+=1,We(),oe.resetPaths([]),pe)ut()}async function ut(w=!1){if(w)Z=!0;let A=++J;if(!pe||!Z&&fe===T)return;if(!w)de("Loading files…");try{let H=await t.list();if(A!==J||H.workspacePath!==T)return;if(Mi(oe,fe===T?O:void 0,H.paths),fe=T,O=H.paths,Z=!1,ae){if(B)de(zn(B.size));return}let j=H.paths.includes("README.md")?"README.md":H.paths.find((It)=>!It.endsWith("/"));if(j)oe.getItem(j)?.select();else de(""),Me("No files in this workspace")}catch(H){if(A!==J)return;de(Wt(H)),Me("Could not load workspace files")}}async function rt(w){if(B?.path===w)return;if(z&&!await dt({title:"Discard unsaved changes?",description:`Your unsaved changes to ${B?.path??"this file"} will be lost.`,action:"Discard"})){oe.getItem(w)?.deselect(),oe.getItem(B?.path??"")?.select();return}let A=++K;Rt(),z=!1,s.textContent=w,mn(),de("");try{let H=await t.read(w);if(A!==K)return;if(mn(H.path),de(zn(H.size)),"message"in H){B=void 0,Me(H.message),je();return}B=H,Se=H.contents,s.textContent=H.path,ye.render({file:{cacheKey:`${T}:${H.path}:${H.revision}`,contents:H.contents,name:H.path},containerWrapper:i}),ji(),de(zn(H.size)),je(),await pn(A)}catch(H){if(A!==K)return;B=void 0,de(""),Me(Wt(H)),je()}}async function pn(w){l.disabled=!0;try{let{Editor:A}=await import("./index-wmew1h99.js");if(w!==K||!B)return;X=new A("file"),X.edit(ye)}catch(A){X=void 0,de(Wt(A))}finally{je()}}async function Xt(){if(!B||!X||!z)return;l.disabled=!0,de("Saving…");try{B=await t.save(B.path,Se,B.revision),Se=B.contents,z=!1,de(zn(B.size))}catch(w){de(Wt(w))}finally{je()}}function Rt(){X?.cleanUp("discard"),X=void 0,je()}function mn(w){ae=w,d.disabled=!w}function je(){l.disabled=!B||!X||!z}function Me(w){o.textContent=w,o.style.display="grid",i.style.display="none"}function ji(){o.style.display="none",i.style.display="block"}function de(w){a.textContent=w}function G(w){return c.textContent=w.title,m.textContent=w.description,v.textContent=w.action,p.value=w.initialValue??"",g.textContent="",g.hidden=!0,f.returnValue="",new Promise((A)=>{f.addEventListener("close",()=>A(f.returnValue==="submit"?p.value:void 0),{once:!0}),f.showModal(),p.select()})}function gn(){if(!Em(p.value)){g.textContent="Use a non-empty name without slashes, '.', or '..'.",g.hidden=!1;return}f.close("submit")}function dt(w){return C.textContent=w.title,y.textContent=w.description,x.textContent=w.action,S.hidden=w.showCancel===!1,x.dataset.variant=w.destructive===!1?"default":"destructive",I.returnValue="",new Promise((A)=>{I.addEventListener("close",()=>A(I.returnValue==="confirm"),{once:!0}),I.showModal()})}async function Dt(w,A){await dt({title:w,description:A,action:"OK",showCancel:!1,destructive:!1})}v.addEventListener("click",gn),p.addEventListener("keydown",(w)=>{if(w.key!=="Enter"||w.isComposing)return;w.preventDefault(),gn()});function Qt(){let w=oe.getSelectedPaths()[0]??oe.getFocusedPath()??O[0];if(w)oe.scrollToPath(w,{focus:!0});requestAnimationFrame(()=>{(n.querySelector("file-tree-container")?.shadowRoot?.querySelector('[role="tree"]')??n).focus({preventScroll:!0})})}function Zt(){(B?i:r).focus({preventScroll:!0})}function Jt(){Rt(),ye.cleanUp(),oe.cleanUp()}return je(),Me("Open a file from the workspace"),{cleanUp:Jt,focusEditor:Zt,focusTree:Qt,openFile:Ce,refresh:wt,refreshAfterDiscard:$e,requestConfirmation:dt,requestNotice:Dt,setGitStatus:nt,setVisible:Gt,setWorkspace:be}}function Wt(e){return String(e).replace(/^Error: /,"")}function Em(e){return Boolean(e&&e===e.trim()&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\"))}function Hu(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Vu(e,t){return e?`${e}/${t}`:t}function zn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(1)} MB`}function lt(e){let t=document.getElementById(e);if(!(t instanceof HTMLElement))throw Error(`Missing #${e}`);return t}function Wn(e){let t=document.getElementById(e);if(!(t instanceof HTMLButtonElement))throw Error(`Missing #${e}`);return t}function Ou(e){let t=document.getElementById(e);if(!(t instanceof HTMLDialogElement))throw Error(`Missing #${e}`);return t}function Tm(e){let t=document.getElementById(e);if(!(t instanceof HTMLInputElement))throw Error(`Missing #${e}`);return t}function Wu(e){return{async loadDiff(t,n,r){let i=new URLSearchParams({workspacePath:t});if(n!==void 0)i.set("path",n);let o=await fetch(`${e}/diff?${i}`,{signal:r});if(o.ok)return o.text();let s=await o.json();throw Error(zt(s)&&$n(s.error)?s.error:`Unable to load diff (${o.status})`)},async discard(t){let n=await fetch(`${e}/discard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:t})});if(n.ok)return;let r=`Request failed (${n.status})`;try{let i=await n.json();if(zt(i)&&$n(i.error))r=i.error}catch{}throw Error(r)},async loadCommit(t){try{let n=await fetch(`${e}/commit?hash=${encodeURIComponent(t)}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Au(r)?r:void 0}catch{return}},async loadHistory(t){try{let n=await fetch(`${e}/history?offset=${t}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Nu(r)?r:void 0}catch{return}}}}var Ai=globalThis.navigator?.platform??globalThis.process?.platform,$u=Ai==="win32"||Ai?.startsWith("Win")?"windows":Ai==="darwin"||Ai?.startsWith("Mac")?"darwin":"linux";function ju(e,t=$u){return t==="darwin"?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Uu(){let e=new Map,t=new Map,n=0;function r(f,c,m){if(a())return!1;let p={lineNumber:Math.max(m.start,m.end),metadata:{body:null,id:`review-comment-${++n}`,range:{...m}},side:Pm(m)};return e.set(f,[...e.get(f)??[],p]),t.set(f,c),!0}function i(f,c){let m=c.trim();if(!m)return;return u(f,(p)=>({...p,metadata:{...p.metadata,body:m}}))}function o(f){for(let[c,m]of e){let p=m.filter((g)=>g.metadata.id!==f);if(p.length===m.length)continue;if(p.length>0)e.set(c,p);else e.delete(c),t.delete(c);return c}return}function s(f,c){let m=[];for(let p of e.keys()){if(!f.has(p)&&c?.has(p))continue;if(f.get(p)===t.get(p))continue;e.delete(p),t.delete(p),m.push(p)}return m}function a(){for(let f of e.values())if(f.some((c)=>c.metadata.body===null))return!0;return!1}function l(){let f=[];for(let[c,m]of e)for(let p of m){let g=p.metadata.body;if(g===null)continue;f.push({body:g,endLine:p.metadata.range.end,endSide:p.metadata.range.endSide??p.metadata.range.side??p.side,path:c,startLine:p.metadata.range.start,startSide:p.metadata.range.side??p.side})}return f}function d(){e.clear(),t.clear()}function u(f,c){for(let[m,p]of e){let g=p.findIndex((I)=>I.metadata.id===f);if(g<0)continue;let v=[...p];return v[g]=c(v[g]),e.set(m,v),m}return}return{add:r,annotations:e,hasDraft:a,reconcileFiles:s,remove:o,reset:d,save:i,savedComments:l}}function Pm(e){return e.endSide??e.side??"additions"}var Rm=navigator.userAgent.includes("Macintosh")?"darwin":"linux";function Gu(e){let t=Uu(),n,r=!1;e.submitButton.addEventListener("click",()=>void u()),f();function i(p,g){let v=p.fileDiff.name;if(t.add(v,Ku(p.fileDiff),g))d(v)}function o(p){if(!("side"in p))return;let{metadata:g}=p,v=document.createElement("div");v.className="review-comment-wrapper",v.dataset.reviewCommentId=g.id;let I=document.createElement("div");I.className="review-comment-card",v.append(I);let C=document.createElement("p");if(C.className="review-comment-label",C.textContent=Dm(g.range,p.side),I.append(C),g.body===null)s(I,g.id);else a(I,g.id,g.body);return v}function s(p,g){let v=document.createElement("textarea");v.className="textarea review-comment-input",v.placeholder="Leave a comment for the agent…",v.setAttribute("aria-label","Review comment");let I=document.createElement("div");I.className="review-comment-actions";let C=Is("Add comment");C.disabled=!0;let y=Is("Cancel","outline"),S=()=>{let x=t.save(g,v.value);if(!x)return;d(x),e.clearSelection()};C.addEventListener("click",S),y.addEventListener("click",()=>l(g)),v.addEventListener("input",()=>{C.disabled=v.value.trim()===""}),v.addEventListener("keydown",(x)=>{if(x.key==="Escape")x.preventDefault(),l(g);else if(x.key==="Enter"&&ju(x,Rm))x.preventDefault(),S()}),I.append(C,y),p.append(v,I),setTimeout(()=>v.focus(),0)}function a(p,g,v){let I=document.createElement("p");I.className="review-comment-body",I.textContent=v;let C=document.createElement("div");C.className="review-comment-actions";let y=Is("Remove","ghost");y.classList.add("error-foreground"),y.addEventListener("click",()=>l(g)),C.append(y),p.append(I,C)}function l(p){let g=t.remove(p);if(!g)return;e.clearSelection(),d(g)}function d(p){n=void 0,f(),e.onAnnotationsChange(p)}async function u(){let p=t.savedComments();if(p.length===0||t.hasDraft()||r)return;r=!0,n=void 0,f();let g=await e.submit(p).catch(()=>!1);if(r=!1,!g){n="Couldn’t send",f();return}t.reset(),f(),e.onSubmitted()}function f(){let p=t.savedComments().length,g=t.hasDraft();e.submitButton.hidden=p===0&&!g,e.submitButton.disabled=p===0||g||r,e.submitButton.textContent=r?"Sending…":`Submit review${p>0?` (${p})`:""}`,e.status.hidden=!n,e.status.textContent=n??""}function c(p,g){if(t.reconcileFiles(new Map(p.filter((I)=>t.annotations.has(I.fileDiff.name)).map((I)=>[I.fileDiff.name,Ku(I.fileDiff)])),g).length===0)return;e.clearSelection(),n="Changes updated; outdated comments removed",f()}function m(){t.reset(),n=void 0,f()}return{add:i,annotations:t.annotations,canAdd:()=>!t.hasDraft(),reconcileItems:c,render:o,reset:m}}function Is(e,t){let n=document.createElement("button");if(n.type="button",n.className="btn",n.dataset.size="xs",t)n.dataset.variant=t;return n.textContent=e,n}function Ku(e){return JSON.stringify(e)}function Dm(e,t){let n=e.side??t,r=e.endSide??e.side??t,i=(a)=>a==="additions"?"new":"old";if(n!==r)return`${i(n)} line ${e.start} to ${i(r)} line ${e.end}`;let o=Math.min(e.start,e.end),s=Math.max(e.start,e.end);return o===s?`${i(n)} line ${o}`:`${i(n)} lines ${o}–${s}`}function Zu({commits:e,getCommitDetail:t,history:n,loading:r,onSelectCommit:i,onSelectCommitPath:o,revision:s,selection:a}){let l=n.scrollTop;if(n.replaceChildren(),e.length===0){let u=document.createElement("p");u.className="review-history-message",u.textContent=s==="git-unloaded"?"Loading history…":"No commits yet",n.append(u);return}let d;for(let u of e){if(u.pushed!==d)n.append(Mm(u.pushed)),d=u.pushed;let f=a.kind==="commit"&&a.hash===u.hash,c=document.createElement("div"),m=document.createElement("button");m.type="button",m.className="review-commit",m.setAttribute("aria-pressed",String(f)),m.title=u.subject,m.addEventListener("click",()=>i(u.hash));let p=document.createElement("span");p.className="review-commit-subject",p.textContent=u.subject||"Untitled commit";let g=document.createElement("span");g.className="fine-print review-commit-meta";let v=document.createElement("span");v.className="review-commit-hash",v.textContent=u.shortHash;let I=document.createElement("span");I.className="review-commit-author",I.textContent=u.author;let C=document.createElement("time");if(C.className="formatted-date",C.dateTime=u.authoredAt,C.title=td(u.authoredAt),C.textContent=Nm(u.authoredAt),g.append(v,I,C),m.append(p,g),c.append(m),f){let y=t(u.hash);if(y)c.append(Am(u.hash,y.changes,a.path,o))}n.append(c)}if(r){let u=document.createElement("p");u.className="fine-print review-history-loading",u.textContent="Loading older commits…",n.append(u)}n.scrollTop=l}function Ju(e,t){e.replaceChildren(),e.hidden=!1;let n=document.createElement("div");n.className="review-detail-heading";let r=document.createElement("div");r.className="review-detail-subject",r.textContent=t.commit.subject||"Untitled commit";let i=document.createElement("span");i.className="review-detail-totals";let o=document.createElement("span");o.className="review-additions",o.textContent=`+${Yu(t.changes,"additions")}`;let s=document.createElement("span");s.className="review-deletions",s.textContent=`-${Yu(t.changes,"deletions")}`,i.append(o,s),n.append(r,i);let a=document.createElement("div");a.className="fine-print review-detail-meta";let l=document.createElement("span");l.className="review-detail-hash",l.textContent=t.commit.shortHash;let d=document.createElement("span");d.className="review-detail-author",d.textContent=t.commit.author;let u=document.createElement("time");u.className="formatted-date",u.dateTime=t.commit.authoredAt,u.title=td(t.commit.authoredAt),u.textContent=u.title,a.append(l,d,u),e.append(n,a)}function ed(e){e.hidden=!0,e.replaceChildren()}function Mm(e){let t=document.createElement("div");t.className="fine-print review-push-group";let n=document.createElement("span");n.textContent=e===null?"No upstream":e?"Pushed":"Not pushed";let r=document.createElement("span");return r.className="review-push-rule",t.append(n,r),t}function Am(e,t,n,r){let i=document.createElement("div");i.className="review-commit-files";for(let o of t){let s=document.createElement("button");s.type="button",s.className="fine-print review-commit-file",s.setAttribute("aria-pressed",String(n===o.path)),s.title=o.path,s.addEventListener("click",()=>r(e,o.path));let a=document.createElement("span");a.className="review-commit-file-status",a.textContent=Lm(o.status);let l=document.createElement("span");l.className="review-commit-file-path",l.textContent=o.path,s.append(a,l),i.append(s)}return i}function td(e,t){return Qu(new Date(e),t)}function Nm(e,t=new Date,n){return Xu(new Date(e),t,n)}function Yu(e,t){return e.reduce((n,r)=>n+r[t],0)}function Lm(e){if(e==="added")return"A";if(e==="deleted")return"D";if(e==="renamed")return"R";if(e==="untracked")return"U";return"M"}function Rr(e){return e==="git-unloaded"}function nd(e,t){return e.workspacePath!==t.workspacePath||e.revision!==t.revision}function rd(e,t,n){if(e[0]?.hash!==n[0]?.hash)return{commits:[...n],hasMore:n.length===On,reset:!0};let i=new Set(n.map(({hash:o})=>o));return{commits:[...n,...e.slice(On).filter(({hash:o})=>!i.has(o))],hasMore:t,reset:!1}}function id(e,t){if(e.kind==="commit"&&t[0])return{kind:"working",path:t[0].path};return e}function od(e,t,n,r){if(t){if(n[0])return{kind:"working",path:n[0].path};if(r[0])return{hash:r[0].hash,kind:"commit"};return{kind:"working"}}if(e.kind!=="working")return e;return{kind:"working",path:n.some(({path:i})=>i===e.path)?e.path:n[0]?.path}}function sd(e,t){let n=new Set(e.map(({hash:i})=>i)),r=t.filter(({hash:i})=>!n.has(i));return{commits:[...e,...r],hasMore:t.length===On&&r.length>0}}var Fm=10,Bm=2,ad=document.body.dataset.codeThemeLight,ld=document.body.dataset.codeThemeDark;if(ad&&ld)_s({dark:ld,light:ad});var Hm=document.body.dataset.workspaceReviewEndpoint??"",Vm=document.body.dataset.workspaceFilesEndpoint??"",Hi=Wu(Hm);window.addEventListener("pi-ui-code-theme-changed",(e)=>{if(!(e instanceof CustomEvent)||!gd(e.detail))return;let t=e.detail;if(_s(t),De)Vd().setRenderOptions({theme:t}).then(Xn).catch((n)=>console.error("Failed to update workspace theme",n))});var Om=et("app"),qm=document.querySelectorAll("[data-workspace-mode]"),Fi=et("review-tree"),vt=et("review-history"),vd=et("review-detail-header"),Un=et("review-diff-view"),zm=et("workspace-file-tree"),cd=et("workspace-file-view"),ud=et("review-empty"),yd=Zn("review-mode-all"),bd=Zn("review-mode-selected"),wd=Zn("review-layout-split"),Id=Zn("review-layout-stacked"),Ss=Zn("review-wrap"),Wm=et("workspace-review"),$m=Zn("review-submit-comments"),jm=et("review-comment-status"),Um=et("workspace-review-data-region"),Km=et("workspace-review-data"),mt=JSON.parse(Km.textContent??"");if(!zt(mt)||!dn(mt.filesRevision)||!dn(mt.treeRevision)||!$n(mt.workspacePath)||!ys(mt.snapshot))throw Error("Invalid initial workspace review state");var Vi=Du(mt.preferences),Et=mt.workspacePath,dd=mt.filesRevision,hd=mt.treeRevision,q=mt.snapshot,hn=[...q.commits],Kn=q.commits.length===On,Gn=!1,Bi=0,Ze=Vi.mode??"selected",U={kind:"working",path:q.changes[0]?.path},Es=Vi.layout,jn=Vi.wrap??!0,Sd=0,Cs=new Map,De,xs,Ut=Gu({clearSelection:()=>De?.clearSelectedLines(),onAnnotationsChange:g1,onSubmitted(){if(Qe=Fd(Qe),U.kind==="working")Je=Qe,Kt=Nr(Je),De?.clearSelectedLines(),fn();window.piUi.messageScroll.scrollBottom()},status:jm,submit:p1,submitButton:$m}),Qe=[],Dr,Ts,$t,Mr,Je=Qe,Kt=Nr(Je),Ni=q.revision!=="git-unloaded",Oi=new Map,Li=new Map,ks=0,Be=zu({endpoint:Vm,initialGitStatus:q.changes,initialWorkspacePath:Et}),qi=Vi.tab,gt=r1(qi,q.isGitRepository),yt=h1(Om,!0,(e)=>{if(Be.setVisible(e&>==="files"),e&>==="git")zd();else Yn()});for(let e of qm)e.addEventListener("click",()=>{let t=e.dataset.workspaceMode;if(t==="files"||t==="git"&&q.isGitRepository)Lr(t)});var Ge=new Tr({...Pu,composition:{contextMenu:{enabled:!0,render:u1,triggerMode:"right-click"}},gitStatus:q.changes,paths:q.changes.map(({path:e})=>e),onSelectionChange(e){let t=e.length===1?e[0]:void 0;if(t&&!Ge.getItem(t)?.isDirectory())Rd(t,!0)}});Ge.render({containerWrapper:Fi});l1();window.piUi.workspaceReview={...yt,focusEditor:a1,focusFiles:i1,focusGit:o1};vt.addEventListener("scroll",Wi,{passive:!0});vt.addEventListener("keydown",s1);yd.addEventListener("click",()=>Td("all"));bd.addEventListener("click",()=>Td("selected"));wd.addEventListener("click",()=>Pd("split"));Id.addEventListener("click",()=>Pd("unified"));Ss.addEventListener("click",()=>{jn=!jn,Ss.setAttribute("aria-pressed",String(jn)),Fr(),Xn()});var Ar=Qn(),Cd=new ResizeObserver(()=>{let e=Qn();if(Rs(e),e===Ar)return;Ar=e,Xn()});Cd.observe(Un);var xd=new MutationObserver(Xn);xd.observe(document.documentElement,{attributeFilter:["class"],attributes:!0});function kd(){try{let e=document.getElementById("workspace-review-data"),t=JSON.parse(e?.textContent??"");if(zt(t)&&dn(t.filesRevision)&&dn(t.treeRevision)&&$n(t.workspacePath)&&ys(t.snapshot)){let n=t.workspacePath===Et&&t.filesRevision!==dd,r=t.treeRevision!==hd;if(dd=t.filesRevision,hd=t.treeRevision,n)Nd();if(Gm(t.workspacePath,t.snapshot),n){if(Be.refresh(r),U.kind==="working")zi(U.path)}}}catch{}}var _d=new MutationObserver(kd);_d.observe(Um,{characterData:!0,childList:!0,subtree:!0});Ps();Rs();Ss.setAttribute("aria-pressed",String(jn));Ed(q);kd();window.addEventListener("pagehide",()=>{_d.disconnect(),Cd.disconnect(),xd.disconnect(),Ge.cleanUp(),Be.cleanUp(),De?.cleanUp(),Yn(),po()},{once:!0});function Gm(e,t){if(!nd({revision:q.revision,workspacePath:Et},{revision:t.revision,workspacePath:e}))return;if(e!==Et)Et=e,Be.setWorkspace(Et),ks++,Bi++,hn=[],Kn=!1,Gn=!1,Oi.clear(),Li.clear(),Cs.clear(),Ut.reset(),Ni=!1,U={kind:"working"};Ed(t)}function Ed(e){let t=Rr(q.revision)||!Ni,n=t?void 0:q.changes.map(({path:o})=>o),r=q.isGitRepository,i=rd(hn,Kn,e.commits);if(q=e,Be.setGitStatus(q.changes),hn=i.commits,Kn=i.hasMore,i.reset)Bi++,Gn=!1;if(!q.isGitRepository)gt="files";else if(!r&&qi!=="files")gt="git";if(Be.setVisible(yt.isOpen()&>==="files"),Nd(),Mi(Ge,n,q.changes.map(({path:o})=>o)),Ge.setGitStatus(q.changes),Rr(q.revision)){Ni=!1,Tt(),De?.setItems([]),$t=void 0,jt("Loading Git data…");return}if(U=od(U,t,Ad(),q.commits),t)Ni=!0;if(Tt(),yt.isOpen()&>==="git")requestAnimationFrame(Wi);if(U.kind==="commit")Dd(U.hash,U.path);else zi(U.path)}function Td(e){if(Ze=e,Ps(),Fr(),Ze==="selected"&&!U.path)U.path=Je[0]?.fileDiff.name;Tt(),fn()}function Pd(e){Es=e,Ar=Qn(),Rs(Ar),Fr(),Xn()}function Rd(e,t=!1){if(t&&Mr&&Ze==="all")Ze="selected",Ps(),Fr();if(zi(e),Tt(),e&&!t)Ge.scrollToPath(e,{focus:!1,offset:"nearest"});if(e)Md(e)}function zi(e){U={kind:"working",path:e},Je=Qe,Kt=Nr(Je),n1(),fn()}async function Dd(e,t){Yn(),$t=void 0,U={hash:e,kind:"commit",path:t},Qm(),Tt();let n=Oi.get(e);if(n){fd(n,t);return}jt("Loading commit…");let r=await Ym(e);if(U.kind!=="commit"||U.hash!==e)return;if(!r){jt("Unable to load commit");return}fd(r,t)}function fd(e,t){Je=e.items,Kt=Nr(Je),U={hash:e.detail.commit.hash,kind:"commit",path:t&&Kt.has(t)?t:Je[0]?.fileDiff.name},t1(e.detail),Tt(),fn()}function Ym(e){let t=Li.get(e);if(t)return t;let n=ks,r=Hi.loadCommit(e).then((i)=>{if(!i)return;let o={detail:i,items:Ld(i.changes,i.patch,i.commit.hash)};if(n!==ks)return;return Oi.set(e,o),o}).finally(()=>Li.delete(e));return Li.set(e,r),r}function Xm(e,t){if(U.kind!=="commit"||U.hash!==e)return;if(U.path=t,Tt(),Ze==="selected")fn();else Md(t)}function Md(e){let t=Kt.get(e);if(t&&De)De.scrollTo({type:"item",id:t.id,align:"start",behavior:"smooth-auto"})}function Ad(){let e=new Set(q.changes.map(({path:r})=>r)),t=Ge.getVisibleRows(0,Ge.getVisibleCount()).find((r)=>r.kind==="file"&&e.has(r.path))?.path;if(!t||t===q.changes[0]?.path)return q.changes;let n=q.changes.find(({path:r})=>r===t);return n?[n,...q.changes.filter(({path:r})=>r!==t)]:q.changes}function Qm(){for(let e of Ge.getSelectedPaths())Ge.getItem(e)?.deselect()}function Yn(){Dr?.abort(),Dr=void 0,Ts=void 0,Mr=void 0}function Nd(){Yn(),Qe=[],Ut.reconcileItems([],new Set(q.changes.map((e)=>e.path)))}async function Zm(e){Yn(),Ts=e;let t=new AbortController;if(Dr=t,$t!==e)$t=void 0,De?.setItems([]),jt("Loading diff…");let n=Ze==="selected"?U.path:void 0,r=q.changes.filter((i)=>n===void 0||i.path===n);try{let i=await Hi.loadDiff(Et,n,t.signal);if(t.signal.aborted)return;let o=Ld(r,i,"working");Ut.reconcileItems(o,new Set(q.changes.map((s)=>s.path))),Qe=Fd(o),$t=e}catch(i){if(t.signal.aborted)return;Qe=[],$t=void 0,De?.setItems([]),Mr=i instanceof Error?i.message:"Unable to load diff"}finally{if(!t.signal.aborted)Dr=void 0,zi(U.path)}}function fn(){if(!yt.isOpen()||gt!=="git")return;if(U.kind==="working"&&q.changes.length>0&&!Rr(q.revision)){let t=JSON.stringify([Et,Ze,Ze==="selected"?U.path:null]);if(Ts!==t){Zm(t);return}if(Dr||Mr){if($t!==t)jt(Mr??"Loading diff…");return}}let e=Ze==="all"?Je:U.path&&Kt.has(U.path)?[Kt.get(U.path)]:[];if(e.length===0){$t=void 0,De?.setItems([]),jt(f1());return}if(jt(),!De){Ar=Qn();let t=Hd();De=new md(t,Vd()),xs=t.enableGutterUtility,De.setup(Un)}else if(xs!==Bd())Xn();De.setItems(e)}function Ld(e,t,n){let r=new Map;for(let i of pd(t))for(let o of i.files)r.set(o.name,o);return e.map((i)=>{let o=r.get(i.path)??Jm(i),s=`${n}:${i.path}`,a=JSON.stringify({...o,cacheKey:void 0}),l=Cs.get(s),d=l?.content===a?l.version:++Sd;return Cs.set(s,{content:a,version:d}),{fileDiff:{...o,cacheKey:`pi-ui:${s}:${d}`},id:`diff:${s}`,type:"diff",version:d}})}function Fd(e){return e.map((t)=>({...t,annotations:Ut.annotations.get(t.fileDiff.name)}))}function Nr(e){return new Map(e.map((t)=>[t.fileDiff.name,t]))}function Jm(e){return{additionLines:[],deletionLines:[],hunks:[],isPartial:!0,name:e.path,splitLineCount:0,type:e.status==="added"||e.status==="untracked"?"new":e.status==="deleted"?"deleted":e.status==="renamed"?"rename-pure":"change",unifiedLineCount:0}}function Tt(){Zu({commits:hn,getCommitDetail:(e)=>Oi.get(e)?.detail,history:vt,loading:Gn,onSelectCommit:(e)=>void Dd(e),onSelectCommitPath:Xm,revision:q.revision,selection:U})}function Wi(){if(!yt.isOpen()||Gn||!Kn||vt.scrollHeight-vt.scrollTop-vt.clientHeight>120)return;e1()}async function e1(){Gn=!0;let e=Bi;Tt();let t=await Hi.loadHistory(hn.length);if(e!==Bi)return;if(t){let n=sd(hn,t);hn=n.commits,Kn=n.hasMore}else Kn=!1;Gn=!1,Tt(),requestAnimationFrame(Wi)}function t1(e){Ju(vd,e)}function n1(){ed(vd)}function Bd(){return U.kind==="working"&&Ut.canAdd()}function Xn(){if(!De)return;let e=Hd();De.setOptions(e),xs=e.enableGutterUtility}function Hd(){let e=Bd();return{diffIndicators:"none",enableGutterUtility:e,enableLineSelection:e,onGutterUtilityClick(t,n){if(n.item.type==="diff")Ut.add(n.item,t)},pointerEventsOnScroll:!0,renderAnnotation:Ut.render,diffStyle:Qn(),hunkSeparators:"simple",itemMetrics:{diffHeaderHeight:36,paddingBottom:0,spacing:0},layout:{gap:Bm,paddingBottom:Fm,paddingTop:0},lineHoverHighlight:"both",overflow:jn?"wrap":"scroll",stickyHeaders:!0,theme:Pr(),themeType:document.documentElement.classList.contains("dark")?"dark":"light",unsafeCSS:`
|
|
1303
1303
|
:host {
|
|
1304
1304
|
--diffs-bg: var(--surface-code);
|
|
1305
1305
|
--diffs-dark-bg: var(--surface-code);
|
|
@@ -1358,4 +1358,4 @@ import{A as M,B as bs,C as Ri,D as md,F as Tr,G as ks,a as Gr,b as Js,c as ea,e
|
|
|
1358
1358
|
min-width: 0;
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
-
`}}function
|
|
1361
|
+
`}}function Vd(){return fo({highlighterOptions:{langs:["text"],preferredHighlighter:"shiki-js",theme:Pr(),useTokenTransformer:!0},poolOptions:{poolSize:1,totalASTLRUCacheSize:100,workerFactory:()=>new Worker(new URL("../pierre-worker.js",import.meta.url),{type:"module"})}})}function r1(e,t){return t&&e!=="files"?"git":"files"}function Lr(e){if(e===gt||e==="git"&&!q.isGitRepository)return;if(gt=e,qi=e,Fr(),!yt.isOpen())return;if(Be.setVisible(e==="files"),e==="git")zd();else Yn()}async function P2(e,t){if(t!==Et)throw Error("The workspace changed. Open the file link again.");yt.open(),Lr("files"),await Be.openFile(e),$i(()=>Be.focusEditor())}function i1(){yt.open(),Lr("files"),$i(()=>Be.focusTree())}function o1(){if(!q.isGitRepository)return;yt.open(),Lr("git"),$i(()=>{if(U.kind==="commit"||q.changes.length===0){qd();return}let e=Ge.getSelectedPaths()[0]??Ge.getFocusedPath()??q.changes[0]?.path;if(e)Ge.scrollToPath(e,{focus:!0});requestAnimationFrame(()=>{(Fi.querySelector("file-tree-container")?.shadowRoot?.querySelector('[role="tree"]')??Fi).focus({preventScroll:!0})})})}function Od(){return[...vt.querySelectorAll(".review-commit")]}function qd(){let e=vt.querySelector('.review-commit[aria-pressed="true"]')??Od()[0];(e??vt).focus({preventScroll:!0}),e?.scrollIntoView({block:"nearest"})}function s1(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||!["ArrowDown","ArrowUp","Home","End"].includes(e.code))return;let t=Od();if(t.length===0)return;let n=e.target instanceof HTMLButtonElement?t.indexOf(e.target):-1,r=n;if(e.code==="ArrowDown")r=Math.min(n+1,t.length-1);if(e.code==="ArrowUp")r=n<0?t.length-1:Math.max(0,n-1);if(e.code==="Home")r=0;if(e.code==="End")r=t.length-1;let i=t[r];if(!i)return;e.preventDefault(),i.click(),requestAnimationFrame(qd)}function a1(){yt.open(),$i(()=>{if(gt==="files")Be.focusEditor();else Un.focus({preventScroll:!0})})}function $i(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function l1(){Wm.addEventListener("keydown",(e)=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.code!=="KeyJ"&&e.code!=="KeyK")return;let t=e.composedPath();if(t.some(c1))return;let n=e.code==="KeyJ"?"ArrowDown":"ArrowUp";if(t.includes(vt)){e.preventDefault(),t[0]?.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,code:n,key:n}));return}if(t.some((i)=>i===Fi||i===zm)){e.preventDefault(),t[0]?.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,code:n,composed:!0,key:n}));return}let r=t.includes(cd)?cd:t.includes(Un)?Un:void 0;if(!r)return;e.preventDefault(),r.scrollBy({behavior:"smooth",top:e.code==="KeyJ"?100:-100})})}function c1(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable}function u1(e,t){if(e.kind!=="file")return null;let n=document.createElement("div");n.className="workspace-tree-context-menu",n.setAttribute("role","menu");let r=document.createElement("button");r.type="button",r.className="workspace-tree-context-menu-item",r.setAttribute("role","menuitem"),r.textContent="Open in editor",r.addEventListener("click",()=>{t.close({restoreFocus:!1}),Lr("files"),Be.openFile(e.path)});let i=document.createElement("button");return i.type="button",i.className="workspace-tree-context-menu-item workspace-tree-context-menu-item-destructive",i.setAttribute("role","menuitem"),i.textContent="Discard changes",i.addEventListener("click",()=>{t.close({restoreFocus:!1}),d1(e.path)}),n.append(r,i),n}async function d1(e){let t=q.changes.find((r)=>r.path===e);if(!t)return;if(!await Be.requestConfirmation({title:"Discard changes?",description:t.status==="untracked"?`${e} is untracked and will be permanently deleted. This action cannot be undone.`:`All changes to ${e} will be permanently discarded. This action cannot be undone.`,action:"Discard"}))return;try{await Hi.discard(e),Be.refreshAfterDiscard(e)}catch(r){await Be.requestNotice("Could not discard changes",String(r).replace(/^Error: /,""))}}function zd(){let e=id(U,Ad());if(e!==U&&e.kind==="working")Rd(e.path);if(q.revision==="git-unloaded")jt("Loading Git data…");else requestAnimationFrame(()=>{fn(),Wi()})}function h1(e,t,n){let r=t,i=!1,o=()=>{let l=document.querySelector('[data-pi-ui-action="review"]');if(!l)return;l.inert=!r,l.style.visibility=r?"visible":"hidden"},s=(l)=>{e.dispatchEvent(new CustomEvent("pi-ui-workspace-review-open",{detail:{open:r&&l}}))},a=(l)=>{if(l&&!r){s(!1);return}let d=i;if(i=l,i!==d)n(i)};return o(),a(e.classList.contains("review-open")),{applyOpen:a,isAvailable:()=>r,isOpen:()=>i,open:()=>s(!0),setAvailable(l){if(r=l,o(),!r)s(!1)}}}function Ps(){yd.setAttribute("aria-pressed",String(Ze==="all")),bd.setAttribute("aria-pressed",String(Ze==="selected"))}function Qn(){if(Un.clientWidth<720)return"unified";return Es??"split"}function Rs(e=Qn()){let t=e==="split";wd.setAttribute("aria-pressed",String(t)),Id.setAttribute("aria-pressed",String(!t))}function f1(){if(Rr(q.revision))return"Loading Git data…";if(!q.isGitRepository)return"Open a Git repository";if(U.kind==="commit")return"This commit has no file changes";if(q.changes.length===0)return"Working tree clean";return"No changes to display"}function jt(e){if(ud.style.display=e?"grid":"none",e)ud.textContent=e}function Fr(){m1({layout:Es,mode:Ze,tab:qi,wrap:jn})}function p1(e){return new Promise((t)=>{let n=setTimeout(()=>t(!1),1e4);window.addEventListener("pi-ui-workspace-review-submitted",()=>{clearTimeout(n),t(!0)},{once:!0}),document.body.dispatchEvent(new CustomEvent("pi-ui-workspace-review-submit",{detail:{comments:e}}))})}function m1(e){document.body.dispatchEvent(new CustomEvent("pi-ui-workspace-review-preferences",{detail:e}))}function g1(e){let t=Qe.findIndex((r)=>r.fileDiff.name===e);if(t<0)return;let n=[...Qe];if(n[t]={...n[t],annotations:Ut.annotations.get(e),version:++Sd},Qe=n,U.kind==="working")Je=Qe,Kt=Nr(Je),fn()}function et(e){let t=document.getElementById(e);if(!(t instanceof HTMLElement))throw Error(`Missing #${e}`);return t}function Zn(e){let t=document.getElementById(e);if(!(t instanceof HTMLButtonElement))throw Error(`Missing #${e}`);return t}export{P2 as openLinkedWorkspaceFile};
|