@hyperpuncher/pi-ui 0.42.1 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as M,B as ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,e as zr,f as Qs,g as Us,h as Ks,i as Kr,j as Zs,k as Gr,n as Js,o as ro,p as io,q as Xr,r as ea,s as Nu,t as ad,u as ta,v as na,w as oo,x as cr,y as ra,z as ld}from"./main-ad92gwm5.js";import{H as Ph}from"./main-mwzht33t.js";import{_ as eo,qa as Yr,ra as to,sa as no}from"./main-f40c0hm2.js";import{gc as Wu,hc as ju}from"./main-pq3eh5fy.js";import{ic as Er,jc as on,kc as xu,lc as sn}from"./main-b1kpnx3v.js";import{mc as Th,pc as bm}from"./main-jgbmmpjx.js";function Gi(e){let t=[];for(let n of e){let r=zr.get(n);if(r==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function Yi(e){for(let t of Array.isArray(e)?e:[e])if(!zr.has(t))return!1;return!0}async function Xi(e){let t=[],n=[];for(let r of e){if(r==="text"||r==="ansi")continue;let i=Ks(r)??Us(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 Qi(e){return Wr.getResolvedThemes(e)}async function Zi(e){for(let n of e)Gs(n);let t=await Wr.resolveThemes(e);for(let n=0;n<e.length;n++)Ys(e[n],t[n]);return t}var so=Th(Ph(),1),jr=Symbol("IGNORE_RESPONSE"),Rh=1e4,$r=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},Ji=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed")}},ia=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=eo,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 so.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new so.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??eo,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()||cr(l,this.renderOptions))return;let d=Kr(e),u=[];if(!Js(l.theme,this.renderOptions.theme))if(io(d))u=Qi(d);else u=await Zi(d);if(!a())return;if(this.highlighter!=null)Zs(u,this.highlighter);else{let c=await Gr({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 $r||!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(Mt(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=Kr(this.renderOptions.theme),o=[];if(io(i))o=Qi(i);else o=await Zi(i);if(!this.isCurrentLifecycle(t)){n();return}let s=[];if(Yi(e))s=Gi(e);else s=await Xi(e);if(!this.isCurrentLifecycle(t)){n();return}let[a]=await Promise.all([Gr({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 $r||!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,Ur(i));this.queueBroadcastStateChanges(),r(i)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=to(),i=r>0?no():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??Rh,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(Ur(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=Xs(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(ro(t)||n!=null&&Xr(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||ro(e)||t!=null&&Xr(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 ea(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);if(oo(t)||n!=null&&cr(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||oo(e)||t!=null&&cr(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?ra(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 $r;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 $r;for(let t of this.activeTaskById.values())if("reject"in t)t.reject(e);else if(Mt(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)=>!Qs(o));if(r.length>0)Gr({themes:Kr(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(Yi(i))t.request.resolvedLanguages=Gi(i);else t.request.resolvedLanguages=await Xi(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,Ur(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 jr;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(Mt(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)||!Xr(i,this.getFileRenderOptions()))throw jr;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)||!cr(i,this.getDiffRenderOptions()))throw jr;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!==jr)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,Mt(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(Mt(t))this.rejectRenderTaskCallbacks(t,new Ji),this.clearInstanceRequests(t),this.clearHighlightKey(t);this.activeTaskById.delete(t.id)}}executeTask(e,t){if(Dh(t.request))this.maybeAttachCustomExtensions(e,t.request);if(!this.activeTaskById.has(t.id))this.assignWorkerToTask(t,e);for(let n of Xs(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),Mt(t))this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Ur(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=to();if(e.customExtensionsVersion>=n)return;t.customExtensionsVersion=n,t.customExtensionMap=no()}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 lr(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 Ji),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new Ji),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(Mt(e)&&e.renderOptionsVersion!==this.renderOptionsVersion)this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of lr(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 lr(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of lr(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 lr(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)&&na(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)&&ta(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(Mt(e))yield e}generateRequestId(){return`req_${++this.nextRequestId}`}};function Dh(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function Xs(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??Yr(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??Yr(e.request.diff.name)),t.add(e.request.diff.lang??Yr(e.request.diff.prevName??"-"));break}return t.delete("text"),Array.from(t)}function Mt(e){return e?.type==="file"||e?.type==="diff"}function lr(e){return e.instances}function Ur(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 ur;function ao({poolOptions:e,highlighterOptions:t}){return ur??=new ia(e,t),ur}function lo(){if(ur==null)return;ur.terminate(),ur=void 0}function Zt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function co(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function At(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 In(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 Sn(e,t){if(e.childPositionById!=null)e.childPositionById.set(t,e.childIds.length);e.childIds.push(t)}function uo(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 Jt(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,Nt(e,t)}function Qr(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=In(e).get(t);if(i===void 0)return;let o=i>>5;e.childVisibleChunkSums[o]+=r}function Zr(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=Mh(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 oa(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 Nt(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 Mh(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 Oe(e){return e.depthAndFlags>>>4}function dr(e){return(e.depthAndFlags&8)>>3}function R(e){return(e.depthAndFlags&8)!==0}function sa(e){return e.depthAndFlags&7}function ue(e,t){return(sa(e)&t)!==0}function Cn(e,t){e.depthAndFlags|=t}function aa(e,t){e.depthAndFlags=Ae(t,sa(e),dr(e))}var la=Symbol("benchmarkInstrumentation");function ca(e,t){if(t==null)return e;return Object.defineProperty(e,la,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function hr(e){if(e==null)return null;return e[la]??null}function E(e,t,n){if(e==null)return n();return e.measurePhase(t,n)}function xn(e,t,n){if(!Number.isFinite(n)||e==null)return;e.setCounter(t,n)}function ua(e){return e>=48&&e<=57}function Ah(e){let t=[],n=0,r=0;while(r<e.length){while(r<e.length&&!ua(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&&ua(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 en(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Ah(t)}}function Nh(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 fr(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=Nh(e.tokens,t.tokens);if(n!==0)return n;if(e.lowerValue!==t.lowerValue)return e.lowerValue<t.lowerValue?-1:1;return 0}function da(e,t,n){let r=fr(n(e),n(t));if(r!==0)return r;if(e===t)return 0;return e<t?-1:1}function Lh(e,t){return da(e,t,en)}function Jr(e,t){if(t!==e.segments.length-1)return 1;return e.isDirectory?1:0}function Fh(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=Jr(e,r);if(s!==Jr(t,r))return s===1?-1:1;return Lh(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 ha(e,t){return Fh(e,t)}function fa(e,t,n){let r=(o)=>{let s=n.get(o);if(s!=null)return s;let a=en(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=Jr(e,o);if(l!==Jr(t,o))return l===1?-1:1;return da(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 pr(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=en(r);return e.sortKeyById[t]=i,i}function ho(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??"default"}}function pa(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 tn(e){let{hasTrailingSlash:t,segments:n}=pa(e);return{basename:n[n.length-1]??"",isDirectory:t,path:e,segments:n}}function ei(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=pa(e);return{requiresDirectory:t,segments:n}}function ti(){let e=new Map;return e.set("",0),{idByValue:e,valueById:[""],sortKeyById:[en("")]}}function it(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 fo=Symbol("pathStorePreparedInputKind");function va(e,t){return e[fo]=t,e}function ma(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function ya(e,t,n){if(n==="default")return ha(e,t);return n(ma(e),ma(t))}function Bh(){return{depthAndFlags:Ae(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function Hh(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 ga(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Vh(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 Oh(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function ba(e,t={}){return ni(e,t).map((n)=>n.path)}function wa(e,t={}){let n=ni(e,t);return va({paths:n.map((r)=>r.path),preparedPaths:n},"prepared")}function Ia(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 va({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},"presorted")}function Sa(e){let t=e,n=t.preparedPaths;if(t[fo]==="prepared"&&n!=null)return n;if(!Vh(n))throw Error("preparedInput must come from PathStore.prepareInput()");return n}function Ca(e){let t=e;if(t[fo]==="presorted"&&t.presortedPaths!=null)return t.presortedPaths;return Oh(t.presortedPaths)?t.presortedPaths:null}function xa(e){let t=e;return typeof t.presortedPathsContainDirectories==="boolean"?t.presortedPathsContainDirectories:null}function ni(e,t={}){let n=ho(t),r=hr(t);xn(r,"workload.inputFiles",e.length);let i=E(r,"store.preparePathEntries.parse",()=>e.map((o)=>tn(o)));return E(r,"store.preparePathEntries.sort",()=>i.sort((o,s)=>ya(o,s,n.sort))),i}var ri=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Bh()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=ti();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=hr(e),this.options=ho(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,Zt())}appendPaths(e){return E(this.instrumentation,"store.builder.appendPaths.parse",()=>this.appendPreparedPaths(e.map((t)=>tn(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),I=!0;for(let x=0;x<y;x++){let T=c.charCodeAt(x);if(T!==n.charCodeAt(x)){I=!1;break}if(T===47)g++,v=x+1}if(I&&m&&y===p&&n.length>p&&n.charCodeAt(p)===47)g++,v=p+1}d=g,r=g;let C=v,S=c.indexOf("/",C);while(S>=0&&S<p){let y=l[d];if(y===void 0)throw Error("Directory stack underflow while building the path store");r++;let I=c.slice(C,S),x=s.get(I);if(x===void 0)x=a.length,s.set(I,x),a.push(I);let T=i.length;i.push({depthAndFlags:Ae(r,0,1),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(c.slice(0,S)),d++,l[d]=T,C=S+1,S=c.indexOf("/",C)}if(m){if(C<p){let I=l[d];if(I===void 0)throw Error(`Unable to resolve directory parent for "${c}"`);r++;let x=c.slice(C,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:I,subtreeNodeCount:1,visibleSubtreeCount:1}),d++,l[d]=O,C=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 I=c.slice(C),x=s.get(I);if(x===void 0)x=a.length,s.set(I,x),a.push(I);i.push({depthAndFlags:Ae(r+1,0),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1})}if(C!==u.length)u=c.substring(0,C),f=r;n=c}if(l.length=d+1,n!=null)this.lastPreparedPath=tn(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 I=Math.min(c,t.length);for(let x=0;x<I;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 I=a[l];if(I===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:I,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 C=a[l];if(C===void 0)throw Error(`Unable to resolve file parent for "${f}"`);let S=f.slice(g),y=o.get(S);if(y===void 0)y=s.length,o.set(S,y),s.push(S);if(r.push({depthAndFlags:Ae(n+1,0),nameId:y,parentId:C,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=tn(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"?fa(this.lastPreparedPath,e,this.segmentSortKeyCache):ya(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}}let n=this.lastPreparedPath,r=ga(e),i=n==null?0:ga(n),o=n==null?0:Hh(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=it(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(Oe(s)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),o!=null)o.set(r,a);return Sn(i,a),a}createFileChildUnchecked(e,t){let n=it(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(Oe(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Sn(r,o),o}getOrCreateDirectoryChild(e,t){let n=it(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(Oe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Sn(r,o),this.directories.set(o,Zt()),o}createDirectoryChild(e,t){let n=it(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(Oe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Sn(r,o),this.directories.set(o,Zt()),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}"`);Cn(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,co());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=co();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,Zt());let r=this.directories.get(n.parentId);if(r!=null){if(r.childIdByNameId!=null)r.childIdByNameId.set(n.nameId,t);Sn(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 Jt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function ka(e,t="closed",n=null){let r=qh(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 _a(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function qh(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 Ea(e,t){if(ue(t,2))return!0;if(e.defaultExpansion==="open")return!0;if(e.defaultExpansion==="closed")return!1;return Oe(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 Ea(e,n)}function Lt(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!R(r))return;let i=Ea(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 Ta(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 Ft(e,t){return e.directoryLoadInfoById.get(t)?.state??"loaded"}function Pa(e,t){let n=Ta(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 Ra(e,t){let n=Ta(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state="unloaded"}function Da(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 Ma(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Aa(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 Na(e,t){e.directoryLoadInfoById.delete(t)}function Va(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 Oa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"add",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function qa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"remove",path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function za(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:"move",projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Wa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"expand",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function ja(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"collapse",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function $a(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"mark-directory-unloaded",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ua(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 Ka(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 Ga(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 Ya(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 Xa(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:mo(e)-t}}function Qa(e,t){let n=mo(e),r=_a();e.transactionStack.push(r);try{t()}catch(i){throw Fa(e,r,!1),i}Fa(e,r,!0,mo(e)-n)}function Ye(e,t){let n=e.instrumentation;if(n==null){La(e,t);return}E(n,"store.events.record",()=>La(e,t))}function La(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){po(e,t);return}n.events.push(t),jh(n,t)}function Fa(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)Ba(i,t);else E(a,"store.events.batch.merge",()=>Ba(i,t));return}let o=zh(t,r),s=e.instrumentation;if(s==null){po(e,o);return}E(s,"store.events.batch.commit",()=>po(e,o))}function zh(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 Wh(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function Ba(e,t){for(let n of t.events)e.events.push(n);Wh(e,t)}function jh(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function po(e,t){let n=e.instrumentation;if(n==null){Ha(e,t);return}E(n,"store.events.emit",()=>Ha(e,t))}function Ha(e,t){e.listeners.get(t.operation)?.forEach((n)=>n(t)),e.listeners.get("*")?.forEach((n)=>n(t))}function mo(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function wt(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 It(e,t){let n=t;while(!0){let r=wt(e,n);if(r==null)return n;n=r}}function kn(e,t){let n=[t],r=t;while(!0){let i=wt(e,r);if(i==null)return n;n.push(i),r=i}}function ii(e,t){let n=t==null?e.snapshot.rootId:Le(e,t);if(n==null)return[];return Uh(e,n)}function vo(e,t){let n=tn(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Bt(e,tf(e,r)),{createdNodeIds:o,directoryId:s}=Kh(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}"`);Cn(u,1),e.pathCacheByNodeId.set(s,{path:t,version:e.pathCacheVersion}),a.add(s)}else l=Yh(e,s,n.basename),a.add(l);Ht(e,s);let d=Bt(e,s);return Oa({affectedAncestorIds:Ke(e,l),affectedNodeIds:[...a],path:t,projectionChanged:il(i,d)})}function yo(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=Bt(e,o),a=rl(e,r);Io(e,o,r,i.nameId),So(e,o),Ht(e,o);let l=Bt(e,o);return qa({affectedAncestorIds:Ke(e,o),affectedNodeIds:a,path:t,projectionChanged:il(s,l),recursive:n.recursive===!0})}function bo(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=Jh(e,i,n),l=Bt(e,o.parentId),d=Bt(e,a.parentId),u=Ue(e.snapshot.segmentTable,o.nameId),f=it(e.snapshot.segmentTable,a.basename);if(a.parentId===o.parentId&&u===a.basename)return null;if(R(o)&&rf(e,i,a.parentId))throw Error("Cannot move a directory into one of its descendants");let c=At(e.snapshot.nodes,ie(e,a.parentId)).get(f),m=a.existingNodeId??c??null;if(m!=null&&m!==i){if(ef(e,m,s,dr(o))==="skip")return null}let p=o.parentId;if(Io(e,p,i,o.nameId),o.parentId=a.parentId,o.nameId=f,e.pathCacheByNodeId.delete(i),sl(e,i),wo(e,a.parentId,i),So(e,p),e.pathCacheVersion++,Ht(e,p),a.parentId!==p)Ht(e,a.parentId);let g=Bt(e,p),v=Bt(e,a.parentId);return za({affectedAncestorIds:[...new Set([...Ke(e,p),...Ke(e,a.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:ol([l,d],[g,v]),to:ee(e,i)})}function $h(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Za(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function ee(e,t){let n=D(e,t),r=$h(e,t);if(r!=null)return r;if(ue(n,2))return Za(e,t,"");let i=ee(e,n.parentId),o=Ue(e.snapshot.segmentTable,n.nameId),s=i.length===0?o:`${i}${o}`;return Za(e,t,R(n)?`${s}/`:s)}function Ht(e,t){let n=e.instrumentation;if(n==null){el(e,t);return}E(n,"store.recomputeCountsUpwardFrom",()=>el(e,t))}function mr(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)){go(e,s,a,!0),n.pop();continue}let l=i.get(s);if(l==null||o[1]>=l.childIds.length){go(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=ei(t);return nl(e,n.segments,n.requiresDirectory)}function nl(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=At(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 Uh(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))return[];if(!R(n))return[ee(e,t)];if(ie(e,t).childIds.length===0)return ue(n,1)&&!ue(n,2)?[ee(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(ee(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(ee(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 Kh(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let o=it(e.snapshot.segmentTable,i),s=ie(e,r),a=At(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=Gh(e,r,o),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Gh(e,t,n){let r=D(e,t),i=e.snapshot.nodes.length;if(e.snapshot.nodes.push({depthAndFlags:Ae(Oe(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,Zt()),wo(e,t,i),e.collapseNewDirectoriesByDefault)e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0;return e.activeNodeCount++,i}function Yh(e,t,n){let r=it(e.snapshot.segmentTable,n),i=ie(e,t);if(At(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${of(e,t,n)}"`);let o=D(e,t),s=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Ae(Oe(o)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),wo(e,t,s),e.activeNodeCount++,s}function Xh(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(Qh(e,n,s)<0)i=o;else r=o+1}return r}function wo(e,t,n){let r=ie(e,t),i=D(e,n);At(e.snapshot.nodes,r).set(i.nameId,n),Qr(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let o=Xh(e,r,n);r.childIds.splice(o,0,n),uo(r,o),Nt(e.snapshot.nodes,r)}function Io(e,t,n,r){let i=ie(e,t),o=In(i),s=o.get(n)??-1;At(e.snapshot.nodes,i).delete(r),o.delete(n);let a=e.snapshot.nodes[n];if(a!=null)Qr(i,n,-a.subtreeNodeCount,-a.visibleSubtreeCount);if(s>=0)i.childIds.splice(s,1),uo(i,s),Nt(e.snapshot.nodes,i)}function Qh(e,t,n){let r=e.snapshot.options.sort;if(r==="default")return Zh(e,t,n);return r(Ja(e,t),Ja(e,n))}function Zh(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=fr(pr(e.snapshot.segmentTable,r.nameId),pr(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 Ja(e,t){let n=D(e,t),r=ee(e,t),i=R(n),o=i?r.slice(0,-1):r;return{basename:Ue(e.snapshot.segmentTable,n.nameId),depth:Oe(n),isDirectory:i,path:r,segments:o.length===0?[]:o.split("/")}}function Jh(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=ei(n).segments;return{basename:u[u.length-1]??"",existingNodeId:i,parentId:d.parentId}}let o=ei(n),s=o.segments[o.segments.length-1]??"",a=o.segments.slice(0,-1),l=a.length===0?e.snapshot.rootId:nl(e,a,!0);if(l==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:s,existingNodeId:null,parentId:l}}function ef(e,t,n,r){if(n==="skip")return"skip";if(n==="error")throw Error(`Destination already exists: "${ee(e,t)}"`);let i=D(e,t);if(dr(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 rl(e,t),Io(e,o,t,s),So(e,o),Ht(e,o),"handled"}function rl(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(Cn(o,4),e.pathCacheByNodeId.delete(i.nodeId),e.collapsedDirectoryIds.delete(i.nodeId))e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;e.expandedDirectoryIds.delete(i.nodeId),Na(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 So(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;Cn(r,1),n=r.parentId===n?null:r.parentId}}function tf(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=At(e.snapshot.nodes,ie(e,n)).get(i);if(o==null)break;if(!R(D(e,o)))break;n=o}return n}function Bt(e,t){let n=nf(e,t);if(n==null)return null;let r=It(e,n),i=D(e,r),o=n===r?null:kn(e,n).map((s)=>ee(e,s));return JSON.stringify({flattenedSegmentPaths:o,hasChildren:ie(e,r).childIds.length>0,path:ee(e,r),terminalKind:dr(i)})}function il(e,t){return ol([e],[t])}function ol(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 nf(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 sl(e,t){let n=D(e,t);if(aa(n,(t===e.snapshot.rootId?-1:Oe(D(e,n.parentId)))+1),!R(n))return;let r=ie(e,t);for(let i of r.childIds)sl(e,i)}function rf(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 go(e,t,n=D(e,t),r=!1){let i=e.instrumentation;if(i==null){tl(e,t,n,r);return}E(i,"store.recomputeNodeCounts",()=>tl(e,t,n,r))}function el(e,t){let n=t;while(n!=null){let r=D(e,n),i=r.subtreeNodeCount,o=r.visibleSubtreeCount;if(go(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)Qr(ie(e,l),n,s,a);n=l}}function tl(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)Jt(e.snapshot.nodes,i);else E(a,"store.recomputeNodeCounts.rebuildChildAggregates",()=>Jt(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=wt(e,t)!=null?s:ke(e,t,n)?1+s:1}function of(e,t,n){let r=ee(e,t);return r.length===0?n:`${r}${n}`}function _n(e){return e!=null&&!ue(e,4)}function oi(e,t){let n=e.snapshot.nodes[t];if(!_n(n)||!R(n)||ue(n,2))return null;return n}function sf(e){let t=0;for(let[n,r]of e.pathCacheByNodeId){if(r.version!==e.pathCacheVersion)continue;if(!_n(e.snapshot.nodes[n]))continue;t+=1}return t}function af(e){return Math.max(0,e.valueById.length-1)}function al(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:sf(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:af(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function lf(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 ll(e){let t=[],n=[];for(let r of e.collapsedDirectoryIds)if(oi(e,r)!=null)t.push(ee(e,r));for(let r of e.expandedDirectoryIds)if(oi(e,r)!=null)n.push(ee(e,r));return{collapsedPaths:t,expandedPaths:n}}function cl(e){let t=[];for(let[n,r]of e.directoryLoadInfoById){if(oi(e,n)==null||Ft(e,n)==="loaded")continue;t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:ee(e,n)})}return t}function ul(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;Lt(e,r,!0,D(e,r))}for(let n of t.collapsedPaths){let r=Le(e,n);if(r==null)continue;Lt(e,r,!1,D(e,r))}}function dl(e,t){e.directoryLoadInfoById.clear();for(let n of t){let r=Le(e,n.path);if(r==null)continue;if(oi(e,r)==null)continue;e.directoryLoadInfoById.set(r,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function cf(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:"",version:e.pathCacheVersion})}function uf(e){let t=e.snapshot.segmentTable,n=ti();for(let r of e.snapshot.nodes){if(!_n(r))continue;if(ue(r,2)){r.nameId=0;continue}r.nameId=it(n,Ue(t,r.nameId))}e.snapshot.segmentTable=n}function df(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!_n(r)||!R(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter((o)=>{let s=e.snapshot.nodes[o];return _n(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])),Jt(e.snapshot.nodes,n)}}function hf(e){let t=e.snapshot.nodes.length-1;while(t>e.snapshot.rootId){let n=e.snapshot.nodes[t];if(_n(n))break;t-=1}e.snapshot.nodes.length=t+1}function ff(e){let t=ll(e),n=cl(e);E(e.instrumentation,"store.cleanup.stable.clearPathCaches",()=>cf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildSegmentTable",()=>uf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildDirectoryIndexes",()=>df(e)),E(e.instrumentation,"store.cleanup.stable.trimTrailingRemovedNodeSlots",()=>hf(e)),E(e.instrumentation,"store.cleanup.stable.restoreExpansionOverrides",()=>ul(e,t)),E(e.instrumentation,"store.cleanup.stable.restoreDirectoryLoadInfos",()=>dl(e,n)),E(e.instrumentation,"store.cleanup.stable.recomputeCounts",()=>mr(e,e.snapshot.rootId))}function pf(e){let t=ll(e),n=cl(e),r=E(e.instrumentation,"store.cleanup.aggressive.listPaths",()=>ii(e)),i=ca({...e.snapshot.options},e.instrumentation),o=E(e.instrumentation,"store.cleanup.aggressive.rebuildSnapshot",()=>{let s=new ri(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",()=>ul(e,t)),E(e.instrumentation,"store.cleanup.aggressive.restoreDirectoryLoadInfos",()=>dl(e,n)),E(e.instrumentation,"store.cleanup.aggressive.recomputeCounts",()=>mr(e,e.snapshot.rootId))}function hl(e){for(let t of e.directoryLoadInfoById.values())if(t.state==="loading"&&t.activeAttemptId!=null)return!0;return!1}function fl(e,t){let n=al(e);if(t==="stable")E(e.instrumentation,"store.cleanup.stable",()=>ff(e));else E(e.instrumentation,"store.cleanup.aggressive",()=>pf(e));let r=al(e);return lf(t,t==="stable",n,r)}var mf=64;function gf(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 vl(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 vf(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:gr(e,t.cursor),setSize:t.setSize,subtreeEndIndex:vl(e,t.cursor,t.index,n)}}function yl(e,t,n,r,i,o){let s=ie(e,t),{childIndex:a,childVisibleIndex:l,localVisibleIndex:d}=Zr(e.snapshot.nodes,s,n),u=s.childIds[a];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return yf(e,u,d,r+l,i+1,a,s.childIds.length,o)}function yf(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=_l(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 yl(e,l.terminalNodeId,n-1,r+1,l.visibleDepth,[...a,{cursor:l,index:r,posInSet:o,setSize:s}])}function bl(e,t){let n=_e(e);if(t<0||t>=n)return null;let r=yl(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map((s)=>ee(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=vf(e,l,n,[...a]);s.push(d),a.push(d.row.path)}return o=s,o},index:r.index,posInSet:r.posInSet,row:gr(e,r.cursor),setSize:r.setSize,subtreeEndIndex:vl(e,r.cursor,r.index,n)}}function wl(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 If(e,s+1);let f=[],c=pl(e,o);for(let m=o;m<=s&&c!=null;m++){let p=gr(e,c);f.push(p),c=ml(e,c)}return f}let a=[],l=0,d=0,u=E(r,"store.getVisibleSlice.selectFirstRow",()=>pl(e,o));for(let f=o;f<=s&&u!=null;f++){let c=E(r,"store.getVisibleSlice.materializeRow",()=>gr(e,u));if(a.push(c),c.isFlattened)l++,d+=c.flattenedSegments?.length??0;u=E(r,"store.getVisibleSlice.advanceCursor",()=>ml(e,u))}return xn(r,"workload.visibleRowsRead",a.length),xn(r,"workload.flattenedRowsRead",l),xn(r,"workload.flattenedSegmentsRead",d),a}function xo(e,t=_e(e)){let n=e.instrumentation;if(n==null)return gl(e,t);return E(n,"store.getVisibleTreeProjection",()=>gl(e,t))}function Il(e){return wf(xo(e))}function Sl(e,t){let n=Le(e,t);if(n==null||n===e.snapshot.rootId)return null;if(R(D(e,n))&&It(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=In(l).get(i);if(d==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=oa(o,l,d),a!==s){let u=D(e,a),f=wt(e,a);if(!ke(e,a,u)&&f!==i)return null;if(It(e,a)===a)r+=1}i=a}return r}function Cl(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 Lt(e,n,!0,r),Ht(e,n),Wa({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function xl(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 Lt(e,n,!1,r),Ht(e,n),ja({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function pl(e,t){if(t<0||t>=_e(e))return null;return kl(e,e.snapshot.rootId,t,-1)}function kl(e,t,n,r){let i=ie(e,t),o=e.instrumentation,{childIndex:s,localVisibleIndex:a}=o==null?Zr(e.snapshot.nodes,i,n):E(o,"store.getVisibleSlice.selectChildIndex",()=>Zr(e.snapshot.nodes,i,n)),l=i.childIds[s];if(l!=null)return Co(e,l,a,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Co(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=_l(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 kl(e,i.terminalNodeId,n-1,i.visibleDepth)}function _l(e,t,n){if(!R(D(e,t)))return{headNodeId:t,terminalNodeId:t,visibleDepth:n};if(e.instrumentation==null)return{headNodeId:t,terminalNodeId:It(e,t),visibleDepth:n};return{headNodeId:t,terminalNodeId:E(e.instrumentation,"store.getVisibleSlice.flatten.resolveTerminalDirectory",()=>It(e,t)),visibleDepth:n}}function bf(e,t){let n=D(e,t);if(!R(n))return!0;let r=n.parentId;if(r===e.snapshot.rootId)return!0;return wt(e,r)!==t}function ml(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:Co(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=In(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 Co(e,d,0,i);if(bf(e,r))i--;r=s}}function wf(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 gl(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),o=new Int32Array(t),s=new Int32Array(mf);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 I=f[f.length-1],x=I[0];if(I[1]>=x.childIds.length){f.pop();continue}let T=I[1],O=x.childIds[I[1]++],fe=l[O],Q=I[2]+1,pe=I[3];s=gf(s,Q);let Z,U=O;if(!R(fe)){let ae=m.get(O);Z=ae!=null&&ae.version===p?ae.path:`${pe}${g[fe.nameId]}`}else U=c?It(e,O):O,Z=U===O?`${pe}${g[fe.nameId]}/`:ee(e,U);r[a]=s[Q],n[a]=Z,i[a]=T,o[a]=x.childIds.length,s[Q+1]=a,a+=1;let B=l[U];if(B!=null&&R(B)&&ke(e,U,B))f.push([d.get(U),0,Q,Z])}if(a<t)n.length=a;let v=r.subarray(0,a),C=i.subarray(0,a),S=o.subarray(0,a),y=null;return{getParentIndex(I){return I<0||I>=a?-1:v[I]??-1},paths:n,posInSetByIndex:C,setSizeByIndex:S,get visibleIndexByPath(){if(y==null){y=new Map;for(let I=0;I<a;I+=1)y.set(n[I]??"",I)}return y}}}function If(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 I=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:I!=null&&I.version===f?I.path:ee(e,p)};continue}let C=d?It(e,p):p,S={headNodeId:p,terminalNodeId:C,visibleDepth:v};n[r++]=gr(e,S);let y=i[C];if(y!=null&&R(y)&&ke(e,C,y))a.push([o.get(C),0,v])}if(r<t)n.length=r;return n}function gr(e,t){let n=D(e,t.terminalNodeId),r=R(n)?Sf(e,t):null,i=ee(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?kn(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:ee(e,u)}}):E(l,"store.getVisibleSlice.flatten.collectSegments",()=>kn(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:ee(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 Sf(e,t){if(t.headNodeId===t.terminalNodeId)return Ft(e,t.terminalNodeId);let n=kn(e,t.headNodeId),r=!1,i=!1;for(let o of n){let s=Ft(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 El=8;function Tl(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 C=t[v];if(C==null)continue;s[v]=C.parentId,a[v]=C.nameId,l[v]=C.depthAndFlags,d[v]=C.subtreeNodeCount,u[v]=C.visibleSubtreeCount}let m=0;for(let v of n.values())m+=v.childIds.length;let p=new Int32Array(m),g=0;for(let[v,C]of n){let S=C.childIds;f[v]=g,c[v]=S.length;for(let y=0;y<S.length;y+=1)p[g]=S[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 Pl(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]&El)===0)continue;let g=a[p],v=l[p],C=0,S=0;for(let I=0;I<v;I+=1){let x=d[g+I];C+=o[x],S+=s[x]}o[p]=1+C;let y;if(r&&v===1)y=(i[d[g]]&El)!==0?S:1+S;else y=1+S;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 Cf(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,C=v.length,S=0,y=0;for(let x=0;x<C;x++){let T=v[x];if(T==null)continue;let O=n[T];S+=O.subtreeNodeCount,y+=O.visibleSubtreeCount}if(g.totalChildSubtreeNodeCount=S,g.totalChildVisibleSubtreeCount=y,C>=128)Nt(n,g);p.subtreeNodeCount=1+S;let I;if(s&&C===1){let x=n[v[0]];I=x!=null&&R(x)?y:1+y}else I=1+y;p.visibleSubtreeCount=I};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,Nt(n,d),l.subtreeNodeCount=1+f,l.visibleSubtreeCount=c}function xf(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Tl(e.snapshot);Pl(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)Nt(n,l)}}function kf(e){return e.initialExpansion==="open"&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var si=class e{#e;constructor(t={}){let n=hr(t),r=E(n,"store.builder.create",()=>new ri(t));if(t.preparedInput!=null){let a=Ca(t.preparedInput);if(a!=null)r.appendPresortedPaths(a,xa(t.preparedInput));else r.appendPreparedPaths(Sa(t.preparedInput),!1)}else{let a=t.paths??[];if(t.presorted===!0)r.appendPaths(a);else r.appendPreparedPaths(E(n,"store.preparePathEntries",()=>ni(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",()=>ka(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||kf(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",()=>xf(this.#e));else E(n,"store.state.initializeOpenVisibleCounts",()=>Cf(this.#e));else E(n,"store.state.recomputeCounts",()=>mr(this.#e,this.#e.snapshot.rootId))}static preparePaths(t,n={}){return ba(t,n)}static prepareInput(t,n={}){return wa(t,n)}static preparePresortedInput(t){return Ia(t)}list(t){return E(this.#e.instrumentation,"store.list",()=>ii(this.#e,t))}add(t){E(this.#e.instrumentation,"store.add",()=>{let n=_e(this.#e);Ye(this.#e,Ne(this.#e,n,vo(this.#e,t)))})}remove(t,n={}){E(this.#e.instrumentation,"store.remove",()=>{let r=_e(this.#e);Ye(this.#e,Ne(this.#e,r,yo(this.#e,t,n)))})}move(t,n,r={}){E(this.#e.instrumentation,"store.move",()=>{let i=_e(this.#e),o=bo(this.#e,t,n,r);if(o!=null)Ye(this.#e,Ne(this.#e,i,o))})}batch(t){Qa(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",()=>wl(this.#e,t,n))}getVisibleRowContext(t){return E(this.#e.instrumentation,"store.getVisibleRowContext",()=>bl(this.#e,t))}getVisibleTreeProjection(){return Il(this.#e)}getVisibleTreeProjectionData(t){return xo(this.#e,t)}getVisibleIndex(t){return E(this.#e.instrumentation,"store.getVisibleIndex",()=>Sl(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:Oe(r),kind:R(r)?"directory":"file",path:ee(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=Cl(this.#e,t);if(r!=null)Ye(this.#e,Ne(this.#e,n,r))})}collapse(t){E(this.#e.instrumentation,"store.collapse",()=>{let n=_e(this.#e),r=xl(this.#e,t);if(r!=null)Ye(this.#e,Ne(this.#e,n,r))})}on(t,n){return Va(this.#e,t,n)}getDirectoryLoadState(t){let n=this.requireDirectoryNodeId(t);return Ft(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);Ra(this.#e,n),Ye(this.#e,Ne(this.#e,r,$a({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=Pa(this.#e,n);return Ye(this.#e,Ne(this.#e,r,Ua({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||Ft(this.#e,r)!=="loading"||!Ma(this.#e,r,t.attemptId))return!1;let i=ee(this.#e,r);this.validateChildPatch(i,n);let o=_e(this.#e),s=[];for(let l of n.operations){_f(i,l);let d=_e(this.#e);switch(l.type){case"add":s.push(Ne(this.#e,d,vo(this.#e,l.path)));break;case"remove":s.push(Ne(this.#e,d,yo(this.#e,l.path,{recursive:l.recursive})));break;case"move":{let u=bo(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 Ye(this.#e,Ne(this.#e,o,Ka({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,childEvents:s,path:ee(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=Da(this.#e,n,t.attemptId);return Ye(this.#e,Ne(this.#e,r,Ga({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],attemptId:t.attemptId,path:ee(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=Aa(this.#e,r,t.attemptId,n);return Ye(this.#e,Ne(this.#e,i,Ya({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,errorMessage:n,path:ee(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(hl(this.#e))throw Error("Cleanup cannot run while directory loads are active.");let n=_e(this.#e),r=fl(this.#e,t.mode??"stable");return Ye(this.#e,Ne(this.#e,n,Xa({...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),I=!0;for(let x=0;x<y;x+=1){let T=f.charCodeAt(x);if(T!==s.charCodeAt(x)){I=!1;break}if(T===47)m+=1,p=x+1}if(I){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,C=!0,S=p;while(S<=c){let y=f.indexOf("/",S),I=y===-1||y>c?c:y,x=f.slice(S,I),T=ie(this.#e,g).childIds,O=v===m?r[v]??0:0,fe=O,Q,pe=u.get(x)??en(x);u.set(x,pe);let Z=(U,B)=>{for(fe=U;fe<B;fe+=1){let ae=T[fe],Se=d[ae],z=l[Se.nameId];if(z===x)return Q=ae,!0;let le=fr(pr(a,Se.nameId),pe);if(le>0||le===0&&z>x)return!1}return!1};if(!Z(O,T.length)&&O>0)Z(0,O);if(Q===void 0){C=!1;break}if(!R(D(this.#e,Q))){C=!1;break}if(r[v]=fe,i[v]=Q,g=Q,v+=1,I===c)break;S=I+1}if(s=f,o=c,r.length=v,i.length=v,!C){s=null,o=0,r.length=0,i.length=0;continue}for(let y=m;y<v;y+=1){let I=i[y];if(I==null)continue;let x=D(this.#e,I);if(ke(this.#e,I,x))continue;Lt(this.#e,I,!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=wt(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 _f(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 Ef=[`<symbol id="file-tree-builtin-bash" viewBox="0 0 16 16">
|
|
1
|
+
import{A as M,B as ms,C as ki,D as ud,F as _r,G as Is,a as Wr,b as Gs,c as Ys,e as zr,f as Qs,g as Us,h as Ks,i as Kr,j as Zs,k as Gr,n as Js,o as ro,p as io,q as Xr,r as ea,s as Lu,t as ld,u as ta,v as na,w as oo,x as cr,y as ra,z as cd}from"./main-ad92gwm5.js";import{H as Rh}from"./main-mwzht33t.js";import{_ as eo,qa as Yr,ra as to,sa as no}from"./main-f40c0hm2.js";import{gc as ju,hc as $u}from"./main-pq3eh5fy.js";import{ic as Er,jc as on,kc as xu,lc as sn}from"./main-b1kpnx3v.js";import{mc as Ph,pc as wm}from"./main-jgbmmpjx.js";function Gi(e){let t=[];for(let n of e){let r=zr.get(n);if(r==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function Yi(e){for(let t of Array.isArray(e)?e:[e])if(!zr.has(t))return!1;return!0}async function Xi(e){let t=[],n=[];for(let r of e){if(r==="text"||r==="ansi")continue;let i=Ks(r)??Us(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 Qi(e){return Wr.getResolvedThemes(e)}async function Zi(e){for(let n of e)Gs(n);let t=await Wr.resolveThemes(e);for(let n=0;n<e.length;n++)Ys(e[n],t[n]);return t}var so=Ph(Rh(),1),jr=Symbol("IGNORE_RESPONSE"),Dh=1e4,$r=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},Ji=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed")}},ia=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=eo,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 so.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new so.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??eo,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()||cr(l,this.renderOptions))return;let d=Kr(e),u=[];if(!Js(l.theme,this.renderOptions.theme))if(io(d))u=Qi(d);else u=await Zi(d);if(!a())return;if(this.highlighter!=null)Zs(u,this.highlighter);else{let c=await Gr({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 $r||!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(Mt(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=Kr(this.renderOptions.theme),o=[];if(io(i))o=Qi(i);else o=await Zi(i);if(!this.isCurrentLifecycle(t)){n();return}let s=[];if(Yi(e))s=Gi(e);else s=await Xi(e);if(!this.isCurrentLifecycle(t)){n();return}let[a]=await Promise.all([Gr({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 $r||!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,Ur(i));this.queueBroadcastStateChanges(),r(i)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=to(),i=r>0?no():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??Dh,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(Ur(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=Xs(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(ro(t)||n!=null&&Xr(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||ro(e)||t!=null&&Xr(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 ea(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);if(oo(t)||n!=null&&cr(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||oo(e)||t!=null&&cr(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?ra(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 $r;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 $r;for(let t of this.activeTaskById.values())if("reject"in t)t.reject(e);else if(Mt(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)=>!Qs(o));if(r.length>0)Gr({themes:Kr(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(Yi(i))t.request.resolvedLanguages=Gi(i);else t.request.resolvedLanguages=await Xi(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,Ur(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 jr;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(Mt(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)||!Xr(i,this.getFileRenderOptions()))throw jr;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)||!cr(i,this.getDiffRenderOptions()))throw jr;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!==jr)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,Mt(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(Mt(t))this.rejectRenderTaskCallbacks(t,new Ji),this.clearInstanceRequests(t),this.clearHighlightKey(t);this.activeTaskById.delete(t.id)}}executeTask(e,t){if(Mh(t.request))this.maybeAttachCustomExtensions(e,t.request);if(!this.activeTaskById.has(t.id))this.assignWorkerToTask(t,e);for(let n of Xs(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),Mt(t))this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Ur(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=to();if(e.customExtensionsVersion>=n)return;t.customExtensionsVersion=n,t.customExtensionMap=no()}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 lr(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 Ji),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new Ji),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(Mt(e)&&e.renderOptionsVersion!==this.renderOptionsVersion)this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of lr(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 lr(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of lr(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 lr(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)&&na(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)&&ta(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(Mt(e))yield e}generateRequestId(){return`req_${++this.nextRequestId}`}};function Mh(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function Xs(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??Yr(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??Yr(e.request.diff.name)),t.add(e.request.diff.lang??Yr(e.request.diff.prevName??"-"));break}return t.delete("text"),Array.from(t)}function Mt(e){return e?.type==="file"||e?.type==="diff"}function lr(e){return e.instances}function Ur(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 ur;function ao({poolOptions:e,highlighterOptions:t}){return ur??=new ia(e,t),ur}function lo(){if(ur==null)return;ur.terminate(),ur=void 0}function Zt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function co(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function At(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 In(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 Sn(e,t){if(e.childPositionById!=null)e.childPositionById.set(t,e.childIds.length);e.childIds.push(t)}function uo(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 Jt(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,Nt(e,t)}function Qr(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=In(e).get(t);if(i===void 0)return;let o=i>>5;e.childVisibleChunkSums[o]+=r}function Zr(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=Ah(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 oa(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 Nt(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 Ah(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 Oe(e){return e.depthAndFlags>>>4}function dr(e){return(e.depthAndFlags&8)>>3}function R(e){return(e.depthAndFlags&8)!==0}function sa(e){return e.depthAndFlags&7}function ue(e,t){return(sa(e)&t)!==0}function Cn(e,t){e.depthAndFlags|=t}function aa(e,t){e.depthAndFlags=Ae(t,sa(e),dr(e))}var la=Symbol("benchmarkInstrumentation");function ca(e,t){if(t==null)return e;return Object.defineProperty(e,la,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function hr(e){if(e==null)return null;return e[la]??null}function E(e,t,n){if(e==null)return n();return e.measurePhase(t,n)}function xn(e,t,n){if(!Number.isFinite(n)||e==null)return;e.setCounter(t,n)}function ua(e){return e>=48&&e<=57}function Nh(e){let t=[],n=0,r=0;while(r<e.length){while(r<e.length&&!ua(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&&ua(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 en(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Nh(t)}}function Lh(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 fr(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=Lh(e.tokens,t.tokens);if(n!==0)return n;if(e.lowerValue!==t.lowerValue)return e.lowerValue<t.lowerValue?-1:1;return 0}function da(e,t,n){let r=fr(n(e),n(t));if(r!==0)return r;if(e===t)return 0;return e<t?-1:1}function Fh(e,t){return da(e,t,en)}function Jr(e,t){if(t!==e.segments.length-1)return 1;return e.isDirectory?1:0}function Bh(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=Jr(e,r);if(s!==Jr(t,r))return s===1?-1:1;return Fh(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 ha(e,t){return Bh(e,t)}function fa(e,t,n){let r=(o)=>{let s=n.get(o);if(s!=null)return s;let a=en(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=Jr(e,o);if(l!==Jr(t,o))return l===1?-1:1;return da(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 pr(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=en(r);return e.sortKeyById[t]=i,i}function ho(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??"default"}}function pa(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 tn(e){let{hasTrailingSlash:t,segments:n}=pa(e);return{basename:n[n.length-1]??"",isDirectory:t,path:e,segments:n}}function ei(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=pa(e);return{requiresDirectory:t,segments:n}}function ti(){let e=new Map;return e.set("",0),{idByValue:e,valueById:[""],sortKeyById:[en("")]}}function it(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 fo=Symbol("pathStorePreparedInputKind");function va(e,t){return e[fo]=t,e}function ma(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function ya(e,t,n){if(n==="default")return ha(e,t);return n(ma(e),ma(t))}function Hh(){return{depthAndFlags:Ae(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function Vh(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 ga(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Oh(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 qh(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function ba(e,t={}){return ni(e,t).map((n)=>n.path)}function wa(e,t={}){let n=ni(e,t);return va({paths:n.map((r)=>r.path),preparedPaths:n},"prepared")}function Ia(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 va({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},"presorted")}function Sa(e){let t=e,n=t.preparedPaths;if(t[fo]==="prepared"&&n!=null)return n;if(!Oh(n))throw Error("preparedInput must come from PathStore.prepareInput()");return n}function Ca(e){let t=e;if(t[fo]==="presorted"&&t.presortedPaths!=null)return t.presortedPaths;return qh(t.presortedPaths)?t.presortedPaths:null}function xa(e){let t=e;return typeof t.presortedPathsContainDirectories==="boolean"?t.presortedPathsContainDirectories:null}function ni(e,t={}){let n=ho(t),r=hr(t);xn(r,"workload.inputFiles",e.length);let i=E(r,"store.preparePathEntries.parse",()=>e.map((o)=>tn(o)));return E(r,"store.preparePathEntries.sort",()=>i.sort((o,s)=>ya(o,s,n.sort))),i}var ri=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Hh()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=ti();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=hr(e),this.options=ho(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,Zt())}appendPaths(e){return E(this.instrumentation,"store.builder.appendPaths.parse",()=>this.appendPreparedPaths(e.map((t)=>tn(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),I=!0;for(let x=0;x<y;x++){let T=c.charCodeAt(x);if(T!==n.charCodeAt(x)){I=!1;break}if(T===47)g++,v=x+1}if(I&&m&&y===p&&n.length>p&&n.charCodeAt(p)===47)g++,v=p+1}d=g,r=g;let C=v,S=c.indexOf("/",C);while(S>=0&&S<p){let y=l[d];if(y===void 0)throw Error("Directory stack underflow while building the path store");r++;let I=c.slice(C,S),x=s.get(I);if(x===void 0)x=a.length,s.set(I,x),a.push(I);let T=i.length;i.push({depthAndFlags:Ae(r,0,1),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(c.slice(0,S)),d++,l[d]=T,C=S+1,S=c.indexOf("/",C)}if(m){if(C<p){let I=l[d];if(I===void 0)throw Error(`Unable to resolve directory parent for "${c}"`);r++;let x=c.slice(C,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:I,subtreeNodeCount:1,visibleSubtreeCount:1}),d++,l[d]=O,C=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 I=c.slice(C),x=s.get(I);if(x===void 0)x=a.length,s.set(I,x),a.push(I);i.push({depthAndFlags:Ae(r+1,0),nameId:x,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1})}if(C!==u.length)u=c.substring(0,C),f=r;n=c}if(l.length=d+1,n!=null)this.lastPreparedPath=tn(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 I=Math.min(c,t.length);for(let x=0;x<I;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 I=a[l];if(I===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:I,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 C=a[l];if(C===void 0)throw Error(`Unable to resolve file parent for "${f}"`);let S=f.slice(g),y=o.get(S);if(y===void 0)y=s.length,o.set(S,y),s.push(S);if(r.push({depthAndFlags:Ae(n+1,0),nameId:y,parentId:C,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=tn(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"?fa(this.lastPreparedPath,e,this.segmentSortKeyCache):ya(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}}let n=this.lastPreparedPath,r=ga(e),i=n==null?0:ga(n),o=n==null?0:Vh(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=it(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(Oe(s)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),o!=null)o.set(r,a);return Sn(i,a),a}createFileChildUnchecked(e,t){let n=it(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(Oe(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Sn(r,o),o}getOrCreateDirectoryChild(e,t){let n=it(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(Oe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Sn(r,o),this.directories.set(o,Zt()),o}createDirectoryChild(e,t){let n=it(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(Oe(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Sn(r,o),this.directories.set(o,Zt()),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}"`);Cn(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,co());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=co();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,Zt());let r=this.directories.get(n.parentId);if(r!=null){if(r.childIdByNameId!=null)r.childIdByNameId.set(n.nameId,t);Sn(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 Jt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function ka(e,t="closed",n=null){let r=zh(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 _a(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function zh(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 Ea(e,t){if(ue(t,2))return!0;if(e.defaultExpansion==="open")return!0;if(e.defaultExpansion==="closed")return!1;return Oe(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 Ea(e,n)}function Lt(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!R(r))return;let i=Ea(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 Ta(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 Ft(e,t){return e.directoryLoadInfoById.get(t)?.state??"loaded"}function Pa(e,t){let n=Ta(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 Ra(e,t){let n=Ta(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state="unloaded"}function Da(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 Ma(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Aa(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 Na(e,t){e.directoryLoadInfoById.delete(t)}function Va(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 Oa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"add",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function qa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"remove",path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function za(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:"move",projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Wa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"expand",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function ja(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"collapse",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function $a(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"mark-directory-unloaded",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ua(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 Ka(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 Ga(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 Ya(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 Xa(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:mo(e)-t}}function Qa(e,t){let n=mo(e),r=_a();e.transactionStack.push(r);try{t()}catch(i){throw Fa(e,r,!1),i}Fa(e,r,!0,mo(e)-n)}function Ye(e,t){let n=e.instrumentation;if(n==null){La(e,t);return}E(n,"store.events.record",()=>La(e,t))}function La(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){po(e,t);return}n.events.push(t),$h(n,t)}function Fa(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)Ba(i,t);else E(a,"store.events.batch.merge",()=>Ba(i,t));return}let o=Wh(t,r),s=e.instrumentation;if(s==null){po(e,o);return}E(s,"store.events.batch.commit",()=>po(e,o))}function Wh(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 jh(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function Ba(e,t){for(let n of t.events)e.events.push(n);jh(e,t)}function $h(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function po(e,t){let n=e.instrumentation;if(n==null){Ha(e,t);return}E(n,"store.events.emit",()=>Ha(e,t))}function Ha(e,t){e.listeners.get(t.operation)?.forEach((n)=>n(t)),e.listeners.get("*")?.forEach((n)=>n(t))}function mo(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function wt(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 It(e,t){let n=t;while(!0){let r=wt(e,n);if(r==null)return n;n=r}}function kn(e,t){let n=[t],r=t;while(!0){let i=wt(e,r);if(i==null)return n;n.push(i),r=i}}function ii(e,t){let n=t==null?e.snapshot.rootId:Le(e,t);if(n==null)return[];return Kh(e,n)}function vo(e,t){let n=tn(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Bt(e,nf(e,r)),{createdNodeIds:o,directoryId:s}=Gh(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}"`);Cn(u,1),e.pathCacheByNodeId.set(s,{path:t,version:e.pathCacheVersion}),a.add(s)}else l=Xh(e,s,n.basename),a.add(l);Ht(e,s);let d=Bt(e,s);return Oa({affectedAncestorIds:Ke(e,l),affectedNodeIds:[...a],path:t,projectionChanged:il(i,d)})}function yo(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=Bt(e,o),a=rl(e,r);Io(e,o,r,i.nameId),So(e,o),Ht(e,o);let l=Bt(e,o);return qa({affectedAncestorIds:Ke(e,o),affectedNodeIds:a,path:t,projectionChanged:il(s,l),recursive:n.recursive===!0})}function bo(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=ef(e,i,n),l=Bt(e,o.parentId),d=Bt(e,a.parentId),u=Ue(e.snapshot.segmentTable,o.nameId),f=it(e.snapshot.segmentTable,a.basename);if(a.parentId===o.parentId&&u===a.basename)return null;if(R(o)&&of(e,i,a.parentId))throw Error("Cannot move a directory into one of its descendants");let c=At(e.snapshot.nodes,ie(e,a.parentId)).get(f),m=a.existingNodeId??c??null;if(m!=null&&m!==i){if(tf(e,m,s,dr(o))==="skip")return null}let p=o.parentId;if(Io(e,p,i,o.nameId),o.parentId=a.parentId,o.nameId=f,e.pathCacheByNodeId.delete(i),sl(e,i),wo(e,a.parentId,i),So(e,p),e.pathCacheVersion++,Ht(e,p),a.parentId!==p)Ht(e,a.parentId);let g=Bt(e,p),v=Bt(e,a.parentId);return za({affectedAncestorIds:[...new Set([...Ke(e,p),...Ke(e,a.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:ol([l,d],[g,v]),to:ee(e,i)})}function Uh(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Za(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function ee(e,t){let n=D(e,t),r=Uh(e,t);if(r!=null)return r;if(ue(n,2))return Za(e,t,"");let i=ee(e,n.parentId),o=Ue(e.snapshot.segmentTable,n.nameId),s=i.length===0?o:`${i}${o}`;return Za(e,t,R(n)?`${s}/`:s)}function Ht(e,t){let n=e.instrumentation;if(n==null){el(e,t);return}E(n,"store.recomputeCountsUpwardFrom",()=>el(e,t))}function mr(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)){go(e,s,a,!0),n.pop();continue}let l=i.get(s);if(l==null||o[1]>=l.childIds.length){go(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=ei(t);return nl(e,n.segments,n.requiresDirectory)}function nl(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=At(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 Kh(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))return[];if(!R(n))return[ee(e,t)];if(ie(e,t).childIds.length===0)return ue(n,1)&&!ue(n,2)?[ee(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(ee(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(ee(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 Gh(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let o=it(e.snapshot.segmentTable,i),s=ie(e,r),a=At(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=Yh(e,r,o),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Yh(e,t,n){let r=D(e,t),i=e.snapshot.nodes.length;if(e.snapshot.nodes.push({depthAndFlags:Ae(Oe(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,Zt()),wo(e,t,i),e.collapseNewDirectoriesByDefault)e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0;return e.activeNodeCount++,i}function Xh(e,t,n){let r=it(e.snapshot.segmentTable,n),i=ie(e,t);if(At(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${sf(e,t,n)}"`);let o=D(e,t),s=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Ae(Oe(o)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),wo(e,t,s),e.activeNodeCount++,s}function Qh(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(Zh(e,n,s)<0)i=o;else r=o+1}return r}function wo(e,t,n){let r=ie(e,t),i=D(e,n);At(e.snapshot.nodes,r).set(i.nameId,n),Qr(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let o=Qh(e,r,n);r.childIds.splice(o,0,n),uo(r,o),Nt(e.snapshot.nodes,r)}function Io(e,t,n,r){let i=ie(e,t),o=In(i),s=o.get(n)??-1;At(e.snapshot.nodes,i).delete(r),o.delete(n);let a=e.snapshot.nodes[n];if(a!=null)Qr(i,n,-a.subtreeNodeCount,-a.visibleSubtreeCount);if(s>=0)i.childIds.splice(s,1),uo(i,s),Nt(e.snapshot.nodes,i)}function Zh(e,t,n){let r=e.snapshot.options.sort;if(r==="default")return Jh(e,t,n);return r(Ja(e,t),Ja(e,n))}function Jh(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=fr(pr(e.snapshot.segmentTable,r.nameId),pr(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 Ja(e,t){let n=D(e,t),r=ee(e,t),i=R(n),o=i?r.slice(0,-1):r;return{basename:Ue(e.snapshot.segmentTable,n.nameId),depth:Oe(n),isDirectory:i,path:r,segments:o.length===0?[]:o.split("/")}}function ef(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=ei(n).segments;return{basename:u[u.length-1]??"",existingNodeId:i,parentId:d.parentId}}let o=ei(n),s=o.segments[o.segments.length-1]??"",a=o.segments.slice(0,-1),l=a.length===0?e.snapshot.rootId:nl(e,a,!0);if(l==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:s,existingNodeId:null,parentId:l}}function tf(e,t,n,r){if(n==="skip")return"skip";if(n==="error")throw Error(`Destination already exists: "${ee(e,t)}"`);let i=D(e,t);if(dr(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 rl(e,t),Io(e,o,t,s),So(e,o),Ht(e,o),"handled"}function rl(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(Cn(o,4),e.pathCacheByNodeId.delete(i.nodeId),e.collapsedDirectoryIds.delete(i.nodeId))e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;e.expandedDirectoryIds.delete(i.nodeId),Na(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 So(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;Cn(r,1),n=r.parentId===n?null:r.parentId}}function nf(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=At(e.snapshot.nodes,ie(e,n)).get(i);if(o==null)break;if(!R(D(e,o)))break;n=o}return n}function Bt(e,t){let n=rf(e,t);if(n==null)return null;let r=It(e,n),i=D(e,r),o=n===r?null:kn(e,n).map((s)=>ee(e,s));return JSON.stringify({flattenedSegmentPaths:o,hasChildren:ie(e,r).childIds.length>0,path:ee(e,r),terminalKind:dr(i)})}function il(e,t){return ol([e],[t])}function ol(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 rf(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 sl(e,t){let n=D(e,t);if(aa(n,(t===e.snapshot.rootId?-1:Oe(D(e,n.parentId)))+1),!R(n))return;let r=ie(e,t);for(let i of r.childIds)sl(e,i)}function of(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 go(e,t,n=D(e,t),r=!1){let i=e.instrumentation;if(i==null){tl(e,t,n,r);return}E(i,"store.recomputeNodeCounts",()=>tl(e,t,n,r))}function el(e,t){let n=t;while(n!=null){let r=D(e,n),i=r.subtreeNodeCount,o=r.visibleSubtreeCount;if(go(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)Qr(ie(e,l),n,s,a);n=l}}function tl(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)Jt(e.snapshot.nodes,i);else E(a,"store.recomputeNodeCounts.rebuildChildAggregates",()=>Jt(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=wt(e,t)!=null?s:ke(e,t,n)?1+s:1}function sf(e,t,n){let r=ee(e,t);return r.length===0?n:`${r}${n}`}function _n(e){return e!=null&&!ue(e,4)}function oi(e,t){let n=e.snapshot.nodes[t];if(!_n(n)||!R(n)||ue(n,2))return null;return n}function af(e){let t=0;for(let[n,r]of e.pathCacheByNodeId){if(r.version!==e.pathCacheVersion)continue;if(!_n(e.snapshot.nodes[n]))continue;t+=1}return t}function lf(e){return Math.max(0,e.valueById.length-1)}function al(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:af(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:lf(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function cf(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 ll(e){let t=[],n=[];for(let r of e.collapsedDirectoryIds)if(oi(e,r)!=null)t.push(ee(e,r));for(let r of e.expandedDirectoryIds)if(oi(e,r)!=null)n.push(ee(e,r));return{collapsedPaths:t,expandedPaths:n}}function cl(e){let t=[];for(let[n,r]of e.directoryLoadInfoById){if(oi(e,n)==null||Ft(e,n)==="loaded")continue;t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:ee(e,n)})}return t}function ul(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;Lt(e,r,!0,D(e,r))}for(let n of t.collapsedPaths){let r=Le(e,n);if(r==null)continue;Lt(e,r,!1,D(e,r))}}function dl(e,t){e.directoryLoadInfoById.clear();for(let n of t){let r=Le(e,n.path);if(r==null)continue;if(oi(e,r)==null)continue;e.directoryLoadInfoById.set(r,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function uf(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:"",version:e.pathCacheVersion})}function df(e){let t=e.snapshot.segmentTable,n=ti();for(let r of e.snapshot.nodes){if(!_n(r))continue;if(ue(r,2)){r.nameId=0;continue}r.nameId=it(n,Ue(t,r.nameId))}e.snapshot.segmentTable=n}function hf(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!_n(r)||!R(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter((o)=>{let s=e.snapshot.nodes[o];return _n(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])),Jt(e.snapshot.nodes,n)}}function ff(e){let t=e.snapshot.nodes.length-1;while(t>e.snapshot.rootId){let n=e.snapshot.nodes[t];if(_n(n))break;t-=1}e.snapshot.nodes.length=t+1}function pf(e){let t=ll(e),n=cl(e);E(e.instrumentation,"store.cleanup.stable.clearPathCaches",()=>uf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildSegmentTable",()=>df(e)),E(e.instrumentation,"store.cleanup.stable.rebuildDirectoryIndexes",()=>hf(e)),E(e.instrumentation,"store.cleanup.stable.trimTrailingRemovedNodeSlots",()=>ff(e)),E(e.instrumentation,"store.cleanup.stable.restoreExpansionOverrides",()=>ul(e,t)),E(e.instrumentation,"store.cleanup.stable.restoreDirectoryLoadInfos",()=>dl(e,n)),E(e.instrumentation,"store.cleanup.stable.recomputeCounts",()=>mr(e,e.snapshot.rootId))}function mf(e){let t=ll(e),n=cl(e),r=E(e.instrumentation,"store.cleanup.aggressive.listPaths",()=>ii(e)),i=ca({...e.snapshot.options},e.instrumentation),o=E(e.instrumentation,"store.cleanup.aggressive.rebuildSnapshot",()=>{let s=new ri(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",()=>ul(e,t)),E(e.instrumentation,"store.cleanup.aggressive.restoreDirectoryLoadInfos",()=>dl(e,n)),E(e.instrumentation,"store.cleanup.aggressive.recomputeCounts",()=>mr(e,e.snapshot.rootId))}function hl(e){for(let t of e.directoryLoadInfoById.values())if(t.state==="loading"&&t.activeAttemptId!=null)return!0;return!1}function fl(e,t){let n=al(e);if(t==="stable")E(e.instrumentation,"store.cleanup.stable",()=>pf(e));else E(e.instrumentation,"store.cleanup.aggressive",()=>mf(e));let r=al(e);return cf(t,t==="stable",n,r)}var gf=64;function vf(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 vl(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 yf(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:gr(e,t.cursor),setSize:t.setSize,subtreeEndIndex:vl(e,t.cursor,t.index,n)}}function yl(e,t,n,r,i,o){let s=ie(e,t),{childIndex:a,childVisibleIndex:l,localVisibleIndex:d}=Zr(e.snapshot.nodes,s,n),u=s.childIds[a];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return bf(e,u,d,r+l,i+1,a,s.childIds.length,o)}function bf(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=_l(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 yl(e,l.terminalNodeId,n-1,r+1,l.visibleDepth,[...a,{cursor:l,index:r,posInSet:o,setSize:s}])}function bl(e,t){let n=_e(e);if(t<0||t>=n)return null;let r=yl(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map((s)=>ee(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=yf(e,l,n,[...a]);s.push(d),a.push(d.row.path)}return o=s,o},index:r.index,posInSet:r.posInSet,row:gr(e,r.cursor),setSize:r.setSize,subtreeEndIndex:vl(e,r.cursor,r.index,n)}}function wl(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 Sf(e,s+1);let f=[],c=pl(e,o);for(let m=o;m<=s&&c!=null;m++){let p=gr(e,c);f.push(p),c=ml(e,c)}return f}let a=[],l=0,d=0,u=E(r,"store.getVisibleSlice.selectFirstRow",()=>pl(e,o));for(let f=o;f<=s&&u!=null;f++){let c=E(r,"store.getVisibleSlice.materializeRow",()=>gr(e,u));if(a.push(c),c.isFlattened)l++,d+=c.flattenedSegments?.length??0;u=E(r,"store.getVisibleSlice.advanceCursor",()=>ml(e,u))}return xn(r,"workload.visibleRowsRead",a.length),xn(r,"workload.flattenedRowsRead",l),xn(r,"workload.flattenedSegmentsRead",d),a}function xo(e,t=_e(e)){let n=e.instrumentation;if(n==null)return gl(e,t);return E(n,"store.getVisibleTreeProjection",()=>gl(e,t))}function Il(e){return If(xo(e))}function Sl(e,t){let n=Le(e,t);if(n==null||n===e.snapshot.rootId)return null;if(R(D(e,n))&&It(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=In(l).get(i);if(d==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=oa(o,l,d),a!==s){let u=D(e,a),f=wt(e,a);if(!ke(e,a,u)&&f!==i)return null;if(It(e,a)===a)r+=1}i=a}return r}function Cl(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 Lt(e,n,!0,r),Ht(e,n),Wa({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function xl(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 Lt(e,n,!1,r),Ht(e,n),ja({affectedAncestorIds:Ke(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function pl(e,t){if(t<0||t>=_e(e))return null;return kl(e,e.snapshot.rootId,t,-1)}function kl(e,t,n,r){let i=ie(e,t),o=e.instrumentation,{childIndex:s,localVisibleIndex:a}=o==null?Zr(e.snapshot.nodes,i,n):E(o,"store.getVisibleSlice.selectChildIndex",()=>Zr(e.snapshot.nodes,i,n)),l=i.childIds[s];if(l!=null)return Co(e,l,a,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Co(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=_l(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 kl(e,i.terminalNodeId,n-1,i.visibleDepth)}function _l(e,t,n){if(!R(D(e,t)))return{headNodeId:t,terminalNodeId:t,visibleDepth:n};if(e.instrumentation==null)return{headNodeId:t,terminalNodeId:It(e,t),visibleDepth:n};return{headNodeId:t,terminalNodeId:E(e.instrumentation,"store.getVisibleSlice.flatten.resolveTerminalDirectory",()=>It(e,t)),visibleDepth:n}}function wf(e,t){let n=D(e,t);if(!R(n))return!0;let r=n.parentId;if(r===e.snapshot.rootId)return!0;return wt(e,r)!==t}function ml(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:Co(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=In(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 Co(e,d,0,i);if(wf(e,r))i--;r=s}}function If(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 gl(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),o=new Int32Array(t),s=new Int32Array(gf);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 I=f[f.length-1],x=I[0];if(I[1]>=x.childIds.length){f.pop();continue}let T=I[1],O=x.childIds[I[1]++],fe=l[O],Q=I[2]+1,pe=I[3];s=vf(s,Q);let Z,U=O;if(!R(fe)){let ae=m.get(O);Z=ae!=null&&ae.version===p?ae.path:`${pe}${g[fe.nameId]}`}else U=c?It(e,O):O,Z=U===O?`${pe}${g[fe.nameId]}/`:ee(e,U);r[a]=s[Q],n[a]=Z,i[a]=T,o[a]=x.childIds.length,s[Q+1]=a,a+=1;let B=l[U];if(B!=null&&R(B)&&ke(e,U,B))f.push([d.get(U),0,Q,Z])}if(a<t)n.length=a;let v=r.subarray(0,a),C=i.subarray(0,a),S=o.subarray(0,a),y=null;return{getParentIndex(I){return I<0||I>=a?-1:v[I]??-1},paths:n,posInSetByIndex:C,setSizeByIndex:S,get visibleIndexByPath(){if(y==null){y=new Map;for(let I=0;I<a;I+=1)y.set(n[I]??"",I)}return y}}}function Sf(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 I=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:I!=null&&I.version===f?I.path:ee(e,p)};continue}let C=d?It(e,p):p,S={headNodeId:p,terminalNodeId:C,visibleDepth:v};n[r++]=gr(e,S);let y=i[C];if(y!=null&&R(y)&&ke(e,C,y))a.push([o.get(C),0,v])}if(r<t)n.length=r;return n}function gr(e,t){let n=D(e,t.terminalNodeId),r=R(n)?Cf(e,t):null,i=ee(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?kn(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:ee(e,u)}}):E(l,"store.getVisibleSlice.flatten.collectSegments",()=>kn(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:ee(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 Cf(e,t){if(t.headNodeId===t.terminalNodeId)return Ft(e,t.terminalNodeId);let n=kn(e,t.headNodeId),r=!1,i=!1;for(let o of n){let s=Ft(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 El=8;function Tl(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 C=t[v];if(C==null)continue;s[v]=C.parentId,a[v]=C.nameId,l[v]=C.depthAndFlags,d[v]=C.subtreeNodeCount,u[v]=C.visibleSubtreeCount}let m=0;for(let v of n.values())m+=v.childIds.length;let p=new Int32Array(m),g=0;for(let[v,C]of n){let S=C.childIds;f[v]=g,c[v]=S.length;for(let y=0;y<S.length;y+=1)p[g]=S[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 Pl(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]&El)===0)continue;let g=a[p],v=l[p],C=0,S=0;for(let I=0;I<v;I+=1){let x=d[g+I];C+=o[x],S+=s[x]}o[p]=1+C;let y;if(r&&v===1)y=(i[d[g]]&El)!==0?S:1+S;else y=1+S;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 xf(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,C=v.length,S=0,y=0;for(let x=0;x<C;x++){let T=v[x];if(T==null)continue;let O=n[T];S+=O.subtreeNodeCount,y+=O.visibleSubtreeCount}if(g.totalChildSubtreeNodeCount=S,g.totalChildVisibleSubtreeCount=y,C>=128)Nt(n,g);p.subtreeNodeCount=1+S;let I;if(s&&C===1){let x=n[v[0]];I=x!=null&&R(x)?y:1+y}else I=1+y;p.visibleSubtreeCount=I};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,Nt(n,d),l.subtreeNodeCount=1+f,l.visibleSubtreeCount=c}function kf(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Tl(e.snapshot);Pl(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)Nt(n,l)}}function _f(e){return e.initialExpansion==="open"&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var si=class e{#e;constructor(t={}){let n=hr(t),r=E(n,"store.builder.create",()=>new ri(t));if(t.preparedInput!=null){let a=Ca(t.preparedInput);if(a!=null)r.appendPresortedPaths(a,xa(t.preparedInput));else r.appendPreparedPaths(Sa(t.preparedInput),!1)}else{let a=t.paths??[];if(t.presorted===!0)r.appendPaths(a);else r.appendPreparedPaths(E(n,"store.preparePathEntries",()=>ni(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",()=>ka(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||_f(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",()=>kf(this.#e));else E(n,"store.state.initializeOpenVisibleCounts",()=>xf(this.#e));else E(n,"store.state.recomputeCounts",()=>mr(this.#e,this.#e.snapshot.rootId))}static preparePaths(t,n={}){return ba(t,n)}static prepareInput(t,n={}){return wa(t,n)}static preparePresortedInput(t){return Ia(t)}list(t){return E(this.#e.instrumentation,"store.list",()=>ii(this.#e,t))}add(t){E(this.#e.instrumentation,"store.add",()=>{let n=_e(this.#e);Ye(this.#e,Ne(this.#e,n,vo(this.#e,t)))})}remove(t,n={}){E(this.#e.instrumentation,"store.remove",()=>{let r=_e(this.#e);Ye(this.#e,Ne(this.#e,r,yo(this.#e,t,n)))})}move(t,n,r={}){E(this.#e.instrumentation,"store.move",()=>{let i=_e(this.#e),o=bo(this.#e,t,n,r);if(o!=null)Ye(this.#e,Ne(this.#e,i,o))})}batch(t){Qa(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",()=>wl(this.#e,t,n))}getVisibleRowContext(t){return E(this.#e.instrumentation,"store.getVisibleRowContext",()=>bl(this.#e,t))}getVisibleTreeProjection(){return Il(this.#e)}getVisibleTreeProjectionData(t){return xo(this.#e,t)}getVisibleIndex(t){return E(this.#e.instrumentation,"store.getVisibleIndex",()=>Sl(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:Oe(r),kind:R(r)?"directory":"file",path:ee(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=Cl(this.#e,t);if(r!=null)Ye(this.#e,Ne(this.#e,n,r))})}collapse(t){E(this.#e.instrumentation,"store.collapse",()=>{let n=_e(this.#e),r=xl(this.#e,t);if(r!=null)Ye(this.#e,Ne(this.#e,n,r))})}on(t,n){return Va(this.#e,t,n)}getDirectoryLoadState(t){let n=this.requireDirectoryNodeId(t);return Ft(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);Ra(this.#e,n),Ye(this.#e,Ne(this.#e,r,$a({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=Pa(this.#e,n);return Ye(this.#e,Ne(this.#e,r,Ua({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||Ft(this.#e,r)!=="loading"||!Ma(this.#e,r,t.attemptId))return!1;let i=ee(this.#e,r);this.validateChildPatch(i,n);let o=_e(this.#e),s=[];for(let l of n.operations){Ef(i,l);let d=_e(this.#e);switch(l.type){case"add":s.push(Ne(this.#e,d,vo(this.#e,l.path)));break;case"remove":s.push(Ne(this.#e,d,yo(this.#e,l.path,{recursive:l.recursive})));break;case"move":{let u=bo(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 Ye(this.#e,Ne(this.#e,o,Ka({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,childEvents:s,path:ee(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=Da(this.#e,n,t.attemptId);return Ye(this.#e,Ne(this.#e,r,Ga({affectedAncestorIds:Ke(this.#e,n),affectedNodeIds:[n],attemptId:t.attemptId,path:ee(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=Aa(this.#e,r,t.attemptId,n);return Ye(this.#e,Ne(this.#e,i,Ya({affectedAncestorIds:Ke(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,errorMessage:n,path:ee(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(hl(this.#e))throw Error("Cleanup cannot run while directory loads are active.");let n=_e(this.#e),r=fl(this.#e,t.mode??"stable");return Ye(this.#e,Ne(this.#e,n,Xa({...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),I=!0;for(let x=0;x<y;x+=1){let T=f.charCodeAt(x);if(T!==s.charCodeAt(x)){I=!1;break}if(T===47)m+=1,p=x+1}if(I){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,C=!0,S=p;while(S<=c){let y=f.indexOf("/",S),I=y===-1||y>c?c:y,x=f.slice(S,I),T=ie(this.#e,g).childIds,O=v===m?r[v]??0:0,fe=O,Q,pe=u.get(x)??en(x);u.set(x,pe);let Z=(U,B)=>{for(fe=U;fe<B;fe+=1){let ae=T[fe],Se=d[ae],z=l[Se.nameId];if(z===x)return Q=ae,!0;let le=fr(pr(a,Se.nameId),pe);if(le>0||le===0&&z>x)return!1}return!1};if(!Z(O,T.length)&&O>0)Z(0,O);if(Q===void 0){C=!1;break}if(!R(D(this.#e,Q))){C=!1;break}if(r[v]=fe,i[v]=Q,g=Q,v+=1,I===c)break;S=I+1}if(s=f,o=c,r.length=v,i.length=v,!C){s=null,o=0,r.length=0,i.length=0;continue}for(let y=m;y<v;y+=1){let I=i[y];if(I==null)continue;let x=D(this.#e,I);if(ke(this.#e,I,x))continue;Lt(this.#e,I,!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=wt(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 Ef(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 Tf=[`<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 ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,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>`],Pf=[`<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">
|
|
@@ -167,7 +167,7 @@ import{A as M,B as ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,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>`,Tf),Rf={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 ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,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:Rl,complete:Ml(Rl,
|
|
187
|
+
</svg>`,standard:Rl,complete:Ml(Rl,Pf)},Df={".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"},Mf={"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"},Af={jsx:"react",sass:"sass",scss:"sass",tsx:"react"},Dl=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"]),Nf=new Set(["complete"]);function Al(e){return Rf[e==="none"?"minimal":e]}function Nl(e){return`file-tree-builtin-${e}`}function Ll(e){return e!=="none"&&Nf.has(e)}function Fl(e,t,n){if(e==="minimal"||e==="none")return;let r=e==="complete",i=Df[t.toLowerCase()];if(i!=null){if(r||Dl.has(i))return i}for(let o of n){if(r){let a=Af[o];if(a!=null)return a}let s=Mf[o];if(s!=null){if(r||Dl.has(s))return s}}return"default"}var ko="file-tree-container",ai="data-file-tree-style",_o="data-file-tree-unsafe-css",Bl="data-file-tree-scrollbar-measure",Eo="data-file-tree-scrollbar-gutter-measured",Hl="--trees-scrollbar-gutter-measured";var vr="header",yr="context-menu",Vl="context-menu-trigger";function Lf(e){return e.spriteSheet!=null||e.remap!=null||e.byFileName!=null||e.byFileExtension!=null||e.byFileNameContains!=null}function En(e){if(e==null)return{set:"complete",colored:!0};if(typeof e==="string")return{set:e,colored:!0};return{...e,set:e.set??(Lf(e)?"none":"complete"),colored:e.colored??!0}}var li={compact:{itemHeight:24,factor:0.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Ol(e,t){if(typeof e==="number")return{itemHeight:t??li.default.itemHeight,factor:e};let n=li[e??"default"];return{itemHeight:t??n.itemHeight,factor:n.factor}}var ci=li.default.itemHeight;var To=`@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)));
|
|
@@ -1282,10 +1282,10 @@ import{A as M,B as ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,e
|
|
|
1282
1282
|
}`}function ql(e){return`@layer base, unsafe;
|
|
1283
1283
|
@layer unsafe {
|
|
1284
1284
|
${e}
|
|
1285
|
-
}`}var zl=new WeakMap;function Lf(e){let t=zl.get(e);if(t!=null)return t;let n=document.createElement("div");n.setAttribute(Bl,"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(),zl.set(e,i),i}function Wl(e,t){if(!e.isConnected)return;let n=Lf(t);if(n==null)return;let r=t.querySelector(`style[${Eo}]`),i=r instanceof HTMLStyleElement?r:document.createElement("style");if(!(r instanceof HTMLStyleElement))i.setAttribute(Eo,""),t.appendChild(i);i.textContent=`:host { ${Hl}: ${n}px; }`}var di;function Ff(e){if(typeof CSSStyleSheet<"u"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in e){if(di==null)di=new CSSStyleSheet,di.replaceSync(ui(To));let t=!1;try{e.adoptedStyleSheets=[di],t=!0}catch{}if(t){e.querySelector(`style[${ai}]`)?.remove();return}}if(e.querySelector("style[data-file-tree-style]")==null){let t=document.createElement("style");t.setAttribute(ai,""),t.textContent=ui(To),e.prepend(t)}}function hi(e,t){Bf(e,t),Ff(t),Wl(e,t)}function Bf(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"});hi(this,t)}}if(customElements.define(ko,e),typeof document<"u")for(let t of Array.from(document.querySelectorAll(ko))){if(!(t instanceof HTMLElement))continue;hi(t,t.shadowRoot??t.attachShadow({mode:"open"}))}}var jl=(e)=>e.startsWith("f::")?e.slice(3):e;function Hf(e){let t=e.lastIndexOf("/");if(t<0)return{parentPath:"",baseName:e};return{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function Vf(e,t){return e===""?t:`${e}/${t}`}function $l({files:e,path:t,isFolder:n,nextBasename:r}){let i=jl(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}=Hf(i);if(o===a)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let l=Vf(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 C=e[v];if(C!==i&&C.startsWith(p))return{error:`"${l}" already exists.`};let S=C===i?l:C;if(u.has(S))return{error:`"${l}" already exists.`};if(u.add(S),d[v]=S,C===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 C=v?`${l}${g.slice(i.length)}`:g;if(u.has(C))return{error:`"${l}" already exists.`};if(u.add(C),d[p]=C,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 Of(e){return e.endsWith("/")}function qf(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 zf(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 Ul(e,t){return t.includes(e)?zf(t):[e]}function Kl(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 Po(e,t){return{draggedPaths:e,target:t}}function Ro(e,t){if(t.kind!=="directory"||t.directoryPath==null)return!1;for(let n of e){if(!Of(n))continue;if(t.directoryPath===n||t.directoryPath.startsWith(n))return!0}return!1}function Wf(e,t){if(t.kind==="root"||t.directoryPath==null)return qf(e);return t.directoryPath}function Gl(e,t){let n=e.map((r)=>{let i=Wf(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 jf(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 Do(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(!jf(si.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 Mo(e){return e.operation==="add"||e.operation==="remove"||e.operation==="move"||e.operation==="batch"}function $f(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 Uf(e,t){if(e===t)return!0;let n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)}function Tn(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 Uf(e,t.path)?n?e:null:e;case"move":return $f(e,t.from,t.to);case"batch":{let r=e;for(let i of t.events)if(r=Tn(r,i,n),r==null)return null;return r}}}function fi(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function Yl(e){switch(e.operation){case"add":return{...fi(e),operation:"add",path:e.path};case"remove":return{...fi(e),operation:"remove",path:e.path,recursive:e.recursive};case"move":return{...fi(e),from:e.from,operation:"move",to:e.to}}}function Kf(e){return{...fi(e),events:e.events.filter((t)=>t.operation==="add"||t.operation==="remove"||t.operation==="move").map((t)=>Yl(t)),operation:"batch"}}function Xl(e){switch(e.operation){case"add":case"remove":case"move":return Yl(e);case"batch":return Kf(e);default:return null}}function pi(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function St(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 mi(e){return St(e).at(-1)??null}function Ao(e,t){if(t==null)return e;return e.startsWith(t)?e.slice(t.length):e}function br(e){return e.endsWith("/")}var No=(e)=>e.toLowerCase();function Ql(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n<0?t:t.slice(n+1)}function Lo(e){return e.endsWith("/")?e.slice(0,-1):e}function Fo(e,t){return t&&!e.endsWith("/")?`${e}/`:e}var Zl=(e)=>{let t=e.trim();if(t.length===0)return"";return(t.includes("\\")?t.replaceAll("\\","/"):t).toLowerCase()};var Bo=Symbol("FILE_TREE_RENAME_VIEW"),Gf=512,Yf=512;function Xf(e){return e==="top"||e==="center"?e:"nearest"}function Qf(e,t,n){if(e===0)return-1;if(n!=null){let r=t(n);if(r!=null)return r;let i=St(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 Zf(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:Qf(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var Jl=class e{static{Object.defineProperty(e.prototype,Bo,{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);#j=new Int32Array(0);#Z=void 0;#P=!1;#s=null;#g="";#R=!1;#k=new Set;#$=[];#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=Do({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=mi(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:Xf(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<=Yf){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=Ul(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=Po(n.draggedPaths,r);if(Ro(n.draggedPaths,r)||this.#u?.canDrop?.(i)===!1)r=null}if(Kl(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=Po(t.draggedPaths,n);if(Ro(t.draggedPaths,n)||this.#u?.canDrop?.(r)===!1)return this.#d(),!1;let i=Gl(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.#$}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=br(i),s=Lo(i);if(this.#Z?.({isFolder:o,path:s})===!1)return!1;for(let a of St(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=Ql(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,br(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,br(t)?{recursive:!0}:void 0);return}let n=br(t),r=$l({files:this.#n.list(),isFolder:n,nextBasename:this.#g,path:Lo(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(Fo(r.sourcePath,n),Fo(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=Do({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=!pi(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=mi(t),r=Ao(t,n),i=null,o=null;for(let s of this.#_()){if(mi(s)!==n)continue;let a=Ao(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=St(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.#j[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=!pi(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 si({...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 St(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(No),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(No),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 St(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.#$=[],this.#x=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let t=this.#i;if(this.#$=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.#$;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:Zl(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 St(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 St(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=Zf(this.#n.getVisibleTreeProjectionData(n?void 0:Math.min(r,Gf)),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.#j=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=Tn(this.#s,t);if(n==null&&this.#s!=null)this.#g="";this.#s=n;let r=Tn(this.#r,t,!0),i=[...this.#o].map((l)=>Tn(l,t)).filter((l)=>l!=null).map((l)=>this.#n.getPathInfo(l)?.path??null).filter((l)=>l!=null),o=Tn(this.#S,t),s=o==null?null:this.#n.getPathInfo(o)?.path??null,a=[...new Set(i)];if(!pi(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&&Mo(t))this.#a=null;let n=Mo(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=Xl(t);if(o!=null)this.#we(o)})}#xe(t){if(this.#n.isExpanded(t)){this.#pe(t);return}this.#Ie(t)}};var ec=(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 tc(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 nc(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 Jf(e,t){return t?`${e}/`:e}function Ho(e,t=null){let n=ec(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=ic(a);if(l==null)continue;sc({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 rc(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=oc(d);if(u==null)continue;l=ep({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,statusByPath:i})||l}for(let d of r){let u=ic(d);if(u==null)continue;l=sc({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:rp(i),statusByPath:i}}function ic(e){return oc(e.path)}function oc(e){let t=tc(e);if(t==null)return;return{canonicalPath:Jf(t.path,t.isDirectory),isDirectory:t.isDirectory}}function ep({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 np(t,n,e),!0}function sc({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)tp(t,n,e);if(s.set(e,o),o==="ignored"&&i)r.add(e);else if(i)r.delete(e);return!0}function tp(e,t,n){for(let r of nc(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function np(e,t,n){for(let r of nc(n)){let i=(e.get(r)??0)-1;if(i>0)e.set(r,i);else e.delete(r),t.delete(r)}}function rp(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\x00${n}\x00${r}`;return t}var ip=(e)=>e.trim().toLowerCase(),op=(e)=>e.split("/").at(-1)??e,sp=(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 wr(e,t){if(typeof e==="string")return{name:e,remappedFrom:t};return{...e,remappedFrom:t}}function ac(e){let t=En(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(ip(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=op(l),f=u.toLowerCase(),c=r.get(f);if(c!=null)return wr(c,a);for(let[g,v]of o)if(f.includes(g))return wr(v,a);let m=sp(u);for(let g of m){let v=i.get(g);if(v!=null)return wr(v,a)}let p=Fl(t.set,u,m);if(p!=null&&t.set!=="none"){if(p==="default"){let g=n?.[a];if(g!=null)return wr(g,a)}return{name:Nl(p),remappedFrom:a,token:p}}}let d=n?.[a];if(d==null)return{name:a};return wr(d,a)}}}var G,hc,ap,nn,lc,bi,fc,pc,zo,Vo,Oo,lp,Ir={},mc=[],wi=Array.isArray,Wo=mc.slice,Vt=Object.assign;function jo(e){e&&e.parentNode&&e.remove()}function Rn(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?Wo.call(arguments,2):n),vi(e,s,r,i,null)}function vi(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?++hc:i,__i:-1,__u:0};return i==null&&G.vnode!=null&&G.vnode(o),o}function ht(e){return e.children}function yi(e,t){this.props=e,this.context=t,this.__g=0}function Pn(e,t){if(t==null)return e.__?Pn(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"?Pn(e):null}function gc(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 gc(e)}}function cc(e){(8&e.__g||!(e.__g|=8)||!nn.push(e)||bi++)&&lc==G.debounceRendering||((lc=G.debounceRendering)||queueMicrotask)(cp)}function cp(){for(var e,t,n,r,i,o,s,a,l=1;nn.length;)nn.length>l&&nn.sort(fc),e=nn.shift(),l=nn.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,o=[],s=[],(a=t.__P)&&((n=Vt({},r)).__v=r.__v+1,G.vnode&&G.vnode(n),$o(a,n,r,t.__n,a.namespaceURI,32&r.__u?[i]:null,o,i==null?Pn(r):i,!!(32&r.__u),s,a.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,bc(o,n,s),n.__e!=i&&gc(n)));bi=0}function vc(e,t,n,r,i,o,s,a,l,d,u,f){var c,m,p,g,v,C,S,y=r&&r.__k||mc,I=t.length;for(l=up(n,t,y,l,I),c=0;c<I;c++)(p=n.__k[c])!=null&&(m=p.__i==-1?Ir:y[p.__i]||Ir,p.__i=c,C=$o(e,p,m,i,o,s,a,l,d,u,f),g=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Uo(m.ref,null,p),u.push(p.ref,p.__c||g,p)),v==null&&g!=null&&(v=g),(S=!!(4&p.__u))||m.__k===p.__k?l=yc(p,l,e,S):typeof p.type=="function"&&C!==void 0?l=C:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=v,l}function up(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?vi(null,s,null,null,null):wi(s)?vi(ht,{children:s},null,null,null):s.constructor==null&&s.__b>0?vi(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=dp(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=Pn(a)),Ic(a,a));return r}function yc(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=yc(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Pn(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function dp(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 uc(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":n}function gi(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||uc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||uc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(pc,"$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=zo,e.addEventListener(t,o?Oo:Vo,o)):e.removeEventListener(t,o?Oo:Vo,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 dc(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=zo++;else if(t.u<n.l)return;return n(G.event?G.event(t):t)}}}function $o(e,t,n,r,i,o,s,a,l,d,u){var f,c,m,p,g,v,C,S,y,I,x,T,O,fe,Q,pe,Z,U,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=G.__b)&&f(t);e:if(typeof z=="function")try{if(S=t.props,y="prototype"in z&&z.prototype.render,I=(f=z.contextType)&&r[f.__c],x=f?I?I.props.value:f.__:r,n.__c?2&(c=t.__c=n.__c).__g&&(c.__g|=1,C=!0):(y?t.__c=c=new z(S,x):(t.__c=c=new yi(S,x),c.constructor=z,c.render=fp),I&&I.sub(c),c.props=S,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=Vt({},c.__s)),Vt(c.__s,z.getDerivedStateFromProps(S,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&&S!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(S,x),!(4&c.__g)&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(S,c.__s,x)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(c.props=S,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(S,c.__s,x),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,v)})}if(c.context=x,c.props=S,c.__P=e,c.__g&=-5,O=G.__r,fe=0,y){for(c.state=c.__s,c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),Q=0;Q<c._sb.length;Q++)c.__h.push(c._sb[Q]);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=Vt({},r,c.getChildContext())),y&&!m&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(p,g)),pe=f,f!=null&&f.type===ht&&f.key==null&&(pe=wc(f.props.children)),a=vc(e,wi(pe)?pe:[pe],t,n,r,i,o,s,a,l,d,u),t.__u&=-161,c.__h.length&&s.push(c),C&&(c.__g&=-4)}catch(le){if(t.__v=null,l||o!=null)if(le.then){for(Z=0,U=!1,t.__u|=l?160:128,t.__c.__z=[],B=0;B<o.length;B++)(ae=o[B])==null||U||(ae.nodeType==8&&ae.data=="$s"?(Z>0&&t.__c.__z.push(ae),Z++,o[B]=null):ae.nodeType==8&&ae.data=="/$s"?(--Z>0&&t.__c.__z.push(ae),U=Z===0,a=o[B],o[B]=null):Z>0&&(t.__c.__z.push(ae),o[B]=null));if(!U){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--;)jo(o[Se]);qo(t)}else t.__e=n.__e,t.__k=n.__k,le.then||qo(t);G.__e(le,t,n)}else a=t.__e=hp(n.__e,t,n,r,i,o,s,l,d,u);return(f=G.diffed)&&f(t),128&t.__u?void 0:a}function qo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(qo)}function bc(e,t,n){for(var r=0;r<n.length;r++)Uo(n[r],n[++r],n[++r]);G.__c&&G.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){G.__e(o,i.__v)}})}function wc(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:wi(e)?e.map(wc):Vt({},e)}function hp(e,t,n,r,i,o,s,a,l,d){var u,f,c,m,p,g,v,C,S=n.props,y=t.props,I=t.type;if(I=="svg"?i="http://www.w3.org/2000/svg":I=="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==!!I&&(I?p.localName==I:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(I==null)return d.createTextNode(y);e=d.createElementNS(i,I,y.is&&y),a&&(G.__m&&G.__m(t,o),a=!1),o=null}if(I==null)S===y||a&&e.data==y||(e.data=y);else{if(o=o&&Wo.call(e.childNodes),S=n.props||Ir,!a&&o!=null)for(S={},u=0;u<e.attributes.length;u++)S[(p=e.attributes[u]).name]=p.value;for(u in S)if(p=S[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;gi(e,u,null,p,i)}for(u in C=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"||S[u]===p&&!C||gi(e,u,p,S[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=""),vc(I=="template"?e.content:e,wi(m)?m:[m],t,n,r,I=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Pn(n,0),a,l,d),o!=null)for(u=o.length;u--;)jo(o[u]);a||(u="value",I=="progress"&&g==null?e.removeAttribute("value"):g==null||g===e[u]&&(I!=="progress"||g)||gi(e,u,g,S[u],i),u="checked",v!=null&&v!=e[u]&&gi(e,u,v,S[u],i))}return e}function Uo(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){G.__e(i,n)}}function Ic(e,t,n){var r,i;if(G.unmount&&G.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Uo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){G.__e(o,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ic(r[i],t,n||typeof e.type!="function");n||jo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function fp(e,t,n){return this.constructor(e,n)}function Ii(e,t){var n,r,i,o;t==document&&(t=document.documentElement),G.__&&G.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=Rn(ht,null,[e]),i=[],o=[],$o(t,e,r||Ir,Ir,t.namespaceURI,r?null:t.firstChild?Wo.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o,t.ownerDocument),bc(i,e,o)}function Sc(e,t){e.__u|=32,Ii(e,t)}G={__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 bi=0,e}},hc=0,ap=function(e){return e!=null&&e.constructor==null},yi.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Vt({},this.state),typeof e=="function"&&(e=e(Vt({},n),this.props)),e&&Vt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),cc(this))},yi.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),cc(this))},yi.prototype.render=ht,nn=[],bi=0,fc=function(e,t){return e.__v.__b-t.__v.__b},pc=/(PointerCapture)$|Capture$/i,zo=0,Vo=dc(!1),Oo=dc(!0),lp=0;var pp=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:--pp,__i:-1,__u:0,__source:i,__self:o};return G.vnode&&G.vnode(d),d}var mp=16,gp=16,vp={};function Dn({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}=vp[e]??{width:mp,height:gp},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 Cc=(e)=>e!==void 0&&/\s/.test(e),yp=(e,t)=>{let n=(r)=>Cc(e[r-1])||Cc(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},kc=(e)=>yp(e,Math.ceil(e.length/2)),xc=(e)=>{if(e.length<2)return[e,""];let t=kc(e);return[e.slice(0,t),e.slice(t)]},bp=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf(".")+1,n=e.length-t>10,r=t>=1&&!n?t:kc(e);return[e.slice(0,r),e.slice(r)]},wp=(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)]},Ip=(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)]},Sp=(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)]},Cp=(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 xp({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 kp(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 _c({children:e,mode:t="truncate",marker:n="…",variant:r="default",...i}){let o=k(kp,{mode:t,children:e},"content"),s=k(xp,{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 Sr({children:e,...t}){return k(_c,{mode:"truncate",...t,children:e})}function Ko({children:e,...t}){return k(_c,{mode:"fruncate",...t,children:e})}function Ec({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(Sr,{...a,children:t[0]}),d=k(Ko,{...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(Ko,{...a,className:o,style:s,children:e});else return k(Sr,{...a,className:o,style:s,children:e});let u=null,f=null,c=null;if(typeof r==="string"){if(r==="center")u=xc;else if(r==="extension")u=bp;else if(r==="leaf-path")u=wp}else if(typeof r==="number")u=Ip,f=r;else if(Array.isArray(r)){let[I,x]=r;if(c=x,I==="last")u=Sp;else if(I==="first")u=Cp}else if(typeof r==="function")u=r;u??=xc;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,C=n==="equal"&&g,S={},y={};if(v)S.marker="";if(C)y.marker="";l=k(Sr,{...a,...S,children:m}),d=k(Ko,{...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 Go={endIndex:-1,startIndex:-1};function _p(e,t,n){return Math.min(Math.max(e,t),n)}function Tc(e,t){return e<0||t<e?Go:{endIndex:t,startIndex:e}}function Yo(e){return e.startIndex<0||e.endIndex<e.startIndex}function Ep(e,t){return Yo(e)?0:(e.endIndex-e.startIndex+1)*t}function Pc(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 Tp(e,t,n){if(t<=0||e<=0)return-1;if(e>=t*n)return t-1;return Math.ceil(e/n)-1}function Pp(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 Rp(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 Dp(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 Xo(e,t,n){if(e.length===0||t<=0)return[];let r=Dp(e),i=Pp(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=Rp(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 Rc(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=_p(t.scrollTop,0,s),l=t.stickyRows??Xo(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=Pc(a,n,t.itemHeight),p=Pc(u,n,t.itemHeight),g=d<=0||m<0||m>=n?-1:m,v=g===-1?-1:Math.min(n-1,p-1),C=g===-1||v<g?0:v-g+1,S=f<=0||p>=n?Go:Tc(p,Tp(u+f,n,t.itemHeight)),y=v+1,I=Yo(S)?Go:Tc(Math.max(y,S.startIndex-o),Math.min(n-1,S.endIndex+o)),x=Ep(I,t.itemHeight);return{occlusion:{firstOccludedIndex:g,lastOccludedIndex:v,occludedCount:C},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:S,window:{endIndex:I.endIndex,height:x,offsetTop:Yo(I)?0:I.startIndex*t.itemHeight,startIndex:I.startIndex}}}var Dc={added:"A",deleted:"D",ignored:null,modified:"M",renamed:"R",untracked:"U"},Mc={added:"Git status: added",deleted:"Git status: deleted",ignored:"Git status: ignored",modified:"Git status: modified",renamed:"Git status: renamed",untracked:"Git status: untracked"},Ac="Contains git status items";function Nc(e){if(e.current)return!0;return e.current=!0,!1}function Qo(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 Lc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:o=0,totalHeight:s,viewportHeight:a}=e;if(i==="nearest")return Qo({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 Fc(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 rn(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 Cr(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 Mn(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 Zo(e,t){return e!=null&&e>0?e:t}function Bc(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 Jo(e,t,n,r,i=0){let o=Qo({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});if(o==null)return!1;return e.scrollTop=o,!0}function Hc(e,t,n,r,i,o,s=0){let a=Lc({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 An(e,t,n,r,i,o){let s=Fc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:o,totalHeight:i,viewportHeight:r});if(s==null)return!1;return e.scrollTop=s,!0}function es(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 Vc(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 Oc({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 qc(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 zc(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 Nn,ve,ts,Wc,ns=Object.is,xr=0,Qc=[],we=G,jc=we.__b,$c=we.__r,Uc=we.diffed,Kc=we.__c,Gc=we.unmount,Yc=we.__;function Ci(e,t){we.__h&&we.__h(ve,e,xr||t),xr=0;var n=ve.__H||(ve.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ot(e){return xr=1,Mp(Zc,e)}function Mp(e,t,n){var r=Ci(Nn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Zc(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],d=r.t(l,a);ns(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,ns(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 is(e,t){var n=Ci(Nn++,3);!we.__s&&os(n.__H,t)&&(n.__=e,n.u=t,ve.__H.__h.push(n))}function qe(e,t){var n=Ci(Nn++,4);!we.__s&&os(n.__H,t)&&(n.__=e,n.u=t,ve.__h.push(n))}function V(e){return xr=5,Ct(function(){return{current:e}},[])}function Ct(e,t){var n=Ci(Nn++,7);return os(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Pe(e,t){return xr=8,Ct(function(){return e},t)}function Ap(){for(var e;e=Qc.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Si),e.__H.__h.forEach(rs),e.__H.__h=[]}catch(t){e.__H.__h=[],we.__e(t,e.__v)}}we.__b=function(e){ve=null,jc&&jc(e)},we.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Yc&&Yc(e,t)},we.__r=function(e){$c&&$c(e),Nn=0;var t=(ve=e.__c).__H;t&&(ts===ve?(t.__h=[],ve.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(Si),t.__h.forEach(rs),t.__h=[],Nn=0)),ts=ve},we.diffed=function(e){Uc&&Uc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Qc.push(t)!==1&&Wc===we.requestAnimationFrame||((Wc=we.requestAnimationFrame)||Np)(Ap)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ts=ve=null},we.__c=function(e,t){t.some(function(n){try{n.__h.forEach(Si),n.__h=n.__h.filter(function(r){return!r.__||rs(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],we.__e(r,n.__v)}}),Kc&&Kc(e,t)},we.unmount=function(e){Gc&&Gc(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Si(r)}catch(i){t=i}}),n.__H=void 0,t&&we.__e(t,n.__v))};var Xc=typeof requestAnimationFrame=="function";function Np(e){var t,n=function(){clearTimeout(r),Xc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Xc&&(t=requestAnimationFrame(n))}function Si(e){var t=ve,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ve=t}function rs(e){var t=ve;e.__c=e.__(),ve=t}function os(e,t){return!e||e.length!==t.length||t.some(function(n,r){return!ns(n,e[r])})}function Zc(e,t){return typeof t=="function"?t(e):t}function Lp(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(ht,{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(Sr,{children:i.name})}),o<r.length-1?" / ":""]},i.path)})})}function Fn(e){return e.isFlattened?e.flattenedSegments?.findLast((t)=>t.isTerminal)?.path??e.path:e.path}function as(e){let t=e.flattenedSegments;if(t==null||t.length===0)return e.name;return t.map((n)=>n.name).join(" / ")}function Jc(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 ss({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=Rc(l,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:a==null?void 0:Jc(a,r,t,s),totalRowCount:s,viewportHeight:o}),u=i&&r<=0&&s>0?e.getStickyRowCandidates(1,t):[],f=u!=null&&r<=0?Jc(u,1,t,s):i&&r<=0&&l.length>0?Xo(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 Fp=400,eu=10,Ln=40,tu=18;function Bp(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 Hp(e,t,n);return o instanceof HTMLElement?o:null}function Hp(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 nu(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 ru(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 Vp(){return navigator.vendor!=="Apple Computer, Inc."}function Op(e,t){let n=e-t.top;if(n<Ln)return-Math.ceil((Ln-Math.max(0,n))/Ln*tu);let r=t.bottom-e;if(r<Ln)return Math.ceil((Ln-Math.max(0,r))/Ln*tu);return 0}function qp(e,t){if(e!=null){let n=Dc[e];if(n==null)return null;return{text:n,title:Mc[e]}}if(t)return{icon:{name:"file-tree-icon-dot",width:6,height:6},title:Ac};return null}function zp(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 iu(e){return e!=null&&"toggle"in e}function hu(e){return e.code==="Space"||e.key===" "||e.key==="Spacebar"}function Wp(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function jp(e){if(e==null)return"";return`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"] { opacity: 1; }`}function fu(e){return e.shiftKey&&e.key==="F10"||e.key==="ContextMenu"}function $p(e,t){if(t&&fu(e))return!0;if((e.ctrlKey||e.metaKey)&&hu(e))return!0;return e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"}var Up=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp"]);function ou(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 Kp(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 Gp(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function Yp(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function su(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function au(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 Xp(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 Qp(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 Zp(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=Qp(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 lu(e,t){return{kind:e.kind,name:as(e),path:t}}function Jp(e){return e==null?void 0:`${e}__tree`}function pu(e,t,n){if(e==null)return;return`${e}__focused-item-${encodeURIComponent(t)}${n?"__parked":""}`}function cu(e){return e==="file-tree-icon-chevron"||e==="file-tree-icon-dot"||e==="file-tree-icon-file"||e==="file-tree-icon-lock"}function uu(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"?cu(e.icon)?t(e.icon):{name:e.icon}:cu(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(Dn,{...n})})}function du(e){if(e==null)return;rn(e.querySelector(["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "))??e)}function em(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=Fn(e);return k(ht,{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(Dn,{...t("file-tree-icon-chevron")}):k(Dn,{...t("file-tree-icon-file",u)})}),k("div",{"data-item-section":"content",children:e.isFlattened?Lp(e,l,o):l??k(Ec,{minimumLength:5,split:"extension",children:e.name})}),i?k("div",{"data-item-section":"decoration",children:r!=null?uu(r,t):null}):null,a?k("div",{"data-item-section":"git",children:uu(s,t)}):null,n?k("div",{"data-item-section":"action",children:d?k("span",{"aria-hidden":"true","data-item-action-affordance":"decorative",children:k(Dn,{...t("file-tree-icon-ellipsis")})}):null}):null]})}function xi(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:C,ignoredGitDirectories:S,ignoredInheritanceCache:y,directoriesWithGitChanges:I,gitLaneActive:x,contextMenuEnabled:T,contextMenuTriggerMode:O,contextMenuButtonTriggerEnabled:fe,contextMenuButtonVisibility:Q,contextMenuRightClickEnabled:pe,registerRenameInput:Z,registerButton:U,resolveIcon:B,renderDecorationForRow:ae,openContextMenuForRow:Se,onRowClick:z,onKeyDown:le}=e,Y=Fn(t),{isParked:ye=!1,mode:oe="flow",style:gt}=r,Be=oe==="sticky",at=C?.get(Y)??null??zp(t.ancestorPaths,S,y),Et=t.kind==="directory"&&(I?.has(Y)??!1),Je=ae(t,Y),We=qp(at,Et),Ee=T&&fe,He=Je!=null||x||Ee,zt=Ee&&Q==="always",Ce=o.getPath()===Y,vt=Ce?o.getValue():"",je=Be||!Ce?null:k(Oc,{ref:Z,ariaLabel:`Rename ${as(t)}`,isFlattened:t.isFlattened,value:vt,onBlur:()=>{o.commit()},onInput:(be)=>{o.setValue(be.currentTarget.value)}}),Wt=em(t,B,{actionLaneEnabled:Ee,customDecoration:Je,decorationLaneEnabled:He,dragTargetFlattenedSegmentPath:d?.flattenedSegmentPath??null,gitDecoration:We,gitLaneActive:x,renameInput:je,showDecorativeActionAffordance:zt}),et={...qc({ariaLabel:as(t),domId:t.isFocused?pu(g,Y,ye):void 0,extraStyle:gt,features:{actionLaneEnabled:Ee,contextMenuButtonVisibility:Ee?Q:null,contextMenuEnabled:T,contextMenuTriggerMode:T?O:null,gitLaneActive:x},isParked:ye,itemHeight:v,mode:oe,row:t,state:{containsGitChange:Et,effectiveGitStatus:at,isContextHovered:a===Y,isDragTarget:d?.kind==="directory"&&d.directoryPath===Y,isDragging:l?.has(Y)===!0,isFocusRinged:t.isFocused&&s===Y},targetPath:Y}),key:n,onContextMenu:T||u?(be)=>{if(f()){be.preventDefault();return}if(!T)return;if(be.preventDefault(),!pe)return;i.focusMountedPathFromInput(Y),Se(t,Y,{anchorRect:Gp(be.clientX,be.clientY),source:"right-click"})}:void 0,onFocus:!Be?()=>{i.focusMountedPathFromInput(Y)}:void 0,onKeyDown:!Be?le:void 0,ref:(be)=>{U(Y,be)}};if(!Be&&Ce)return k("div",{...et,children:Wt});return k("button",{...et,type:"button",draggable:u&&!ye,onDragEnd:u&&!ye?m:void 0,onDragStart:u&&!ye?(be)=>{c(be,t,Y)}:void 0,onMouseDown:(be)=>{if(Be){be.preventDefault();return}if(i.isSearchOpen())be.preventDefault()},onTouchStart:u&&!ye?(be)=>{p(be,t,Y)}:void 0,onClick:(be)=>{z(be,t,Y,oe)},children:Wt})}function tm(e,t,n){if(t.end<t.start)return[];return e.controller.getVisibleRows(t.start,t.end).filter((r)=>!n.has(Fn(r))).map((r,i)=>xi(e,r,t.start+i))}function ls({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:o,instanceId:s,itemHeight:a=ci,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 C=V(null),S=V(null),y=V(!1),I=V(null),x=V(null),T=V(null),O=V(null),fe=V(null),Q=V(new Map),pe=V(new Map),Z=V(()=>{}),U=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),Y=V(null),ye=V(!1),oe=V(null),gt=V(null),Be=V(null),at=V(null),Et=V(null),Je=V(null),We=V(null),Ee=V(null),He=V(!1),zt=V(null),Ce=V(null),vt=V(null),je=V(null),Wt=Ct(()=>new Map,[]),[,et]=ot(0),be=V(!1),[lt,tt]=ot(null),[hn,jt]=ot(null),[Tt,fn]=ot(null),[$e,De]=ot(null),[Oi,de]=ot(0),[K,pn]=ot(null),ct=V(K);ct.current=K;let Pt=V(null),$t=V(null),Ut=V(null),Kt=V(null),w=V(null),A=V(!1),H=()=>{$t.current=null,Ut.current=null,Kt.current=null},j=(h,b)=>{$t.current=h,Ut.current=null,Kt.current=b==null?null:{path:h,scrollTop:b}},yt=(h,b)=>{$t.current=null,Ut.current={path:h,viewportOffset:b},Kt.current=null},Gt=V(f==="retain"&&t.isSearchOpen()),[Xn,ks]=ot(m);is(()=>{if(!m)ks(!1)},[m]);let _s=V(!1),qi=Pe(()=>{_s.current=!0,ks((h)=>h?!1:h)},[]),[Fd,Bd]=ot(()=>ss({controller:t,itemHeight:a,overscan:l,scrollTop:0,stickyFolders:g,viewportHeight:v})),[Hd,Vd]=ot(!1);is(()=>{Vd(!0)},[]);let Ve=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,mn=e?.contextMenu?.triggerMode??(Ve?"right-click":"both"),gn=mn==="both"||mn==="button",Es=e?.contextMenu?.buttonVisibility??"when-needed",Od=mn==="both"||mn==="right-click";qe(()=>{let h=T.current;if(h==null)return;let b=(_)=>{if(!(_ instanceof CustomEvent))return;let P=_.detail?.path??null;w.current=P,jt(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 qd=Pe((h,b)=>{su(Q.current,h,b)},[]),zd=Pe((h,b)=>{su(pe.current,h,b)},[]),Wd=Pe((h)=>{x.current=h},[]),Qn=Pe((h)=>au(h,pe.current,Q.current),[]),Ts=n!=null||r!=null||i!=null,{resolveIcon:Ps}=Ct(()=>ac(o),[o]),Zn=t[Bo](),vn=Zn.getPath(),zi=vn!=null,ut=t.isSearchOpen(),jd=t.getSearchValue(),W=t.getFocusedPath(),ne=t.getFocusedIndex(),Yt=t.getScrollRequest(),bt=t.isDragAndDropEnabled(),Jn=t.getDragSession(),$d=Ct(()=>Jn==null?null:new Set(Jn.draggedPaths),[Jn]),Ud=Jn?.target??null,er=Jn?.primaryPath??null,Rs=Jp(s),{overlayHeight:Kd,overlayRows:Gd,snapshot:xe,visibleRows:Dr}=Fd,Te=xe.physical.viewportHeight,nt=Ct(()=>({end:xe.window.endIndex,start:xe.window.startIndex}),[xe.window.endIndex,xe.window.startIndex]),tr=Gd,Ds=xe.sticky.rows,Xt=xe.physical.totalHeight,yn=xe.sticky.height,Mr=Ct(()=>new Set(Ds.map((h)=>Fn(h.row))),[Ds]),Wi=ne>=0&&ne>=nt.start&&ne<=nt.end,Yd=Pe((h,b)=>u?.({item:lu(h,b),row:h})??null,[u]),Ms=Pe((h)=>{if(rn(h==null?null:Q.current.get(h)??null))return!0;return rn(T.current)},[]),Ar=Pe((h)=>{Ms(t.focusNearestPath(h))},[t,Ms]),As=V(Ar);As.current=Ar;let bn=V(!0),ji=V(()=>{}),Ge=Pe((h=!0)=>{let b=ct.current;if(b==null)return;if(bn.current=bn.current&&h,pn(null),e?.contextMenu?.onClose?.(),bn.current)Ar(b.path)},[e?.contextMenu,Ar]);ji.current=Ge;let nr=Pe((h)=>{let b=h==null?null:Yp(T.current,h);fn((N)=>N===b?N:b)},[]),Ns=Pe((h,b,N)=>{let _=t.getItem(b);if(_==null)return;let P=Qn(b);if(P?.dataset.fileTreeStickyRow==="true"){let F=O.current;j(b,F?.scrollTop??null),z.current=!0,tt((ce)=>ce===b?ce:b)}_.focus(),nr(P),bn.current=!0,pn({anchorRect:N?.anchorRect??null,item:lu(h,b),path:b,source:N?.source??"keyboard"})},[t,Qn,nr]),Xd=Pe((h)=>{if(!d)return;if(t.isSearchOpen()){let b=O.current,N=Mn(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"),et((b)=>b+1)},[t,ne,a,d,Te]),Nr=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=Mn(_,Te),L=t.getVisibleCount()*a,J=N==="sticky-parents"?F.ancestorPaths.length*a:ss({controller:t,itemHeight:a,overscan:l,scrollTop:_.scrollTop,stickyFolders:g,viewportHeight:ce}).snapshot.sticky.height;return z.current=!0,An(_,P,a,ce,L,J),Z.current(),Pt.current=b?h:null,!0},[t,a,l,Te,g]),Qd=()=>y.current===!0||je.current!=null||He.current===!0,Ls=(h)=>typeof window.requestAnimationFrame==="function"?window.requestAnimationFrame(()=>{h()}):window.setTimeout(h,16),Zd=(h)=>{if(h==null)return;if(typeof window.cancelAnimationFrame==="function"){window.cancelAnimationFrame(h);return}window.clearTimeout(h)},Rt=()=>{if(at.current!=null)clearTimeout(at.current),at.current=null;Be.current=null},Lr=()=>{Je.current?.remove(),Je.current=null},rr=()=>{Zd(gt.current),gt.current=null,Et.current=null},Fs=(h)=>{let b=T.current?.getRootNode();if(b instanceof ShadowRoot){b.append(h);return}document.body.append(h)},ir=()=>{if(Ee.current?.(),Ee.current=null,je.current!=null)clearTimeout(je.current),je.current=null;if(He.current=!1,zt.current=null,vt.current=null,Ce.current!=null)Ce.current.setAttribute("draggable","true"),Ce.current.style.removeProperty("touch-action"),Ce.current=null;Lr(),Rt(),rr(),We.current=null},Fr=(h,b)=>{let N=T.current?.getRootNode(),_=nu(Bp(N instanceof ShadowRoot?N:document,h,b));return t.setDragTarget(_),t.getDragSession()?.target??null},$i=(h)=>{let b=t.getDragAndDropConfig()?.openOnDropDelay??800;if(h==null||h.kind!=="directory"||h.directoryPath==null||b<=0){Rt();return}let N=t.getItem(h.directoryPath),_=iu(N)?N:null;if(_==null||_.isExpanded()){Rt();return}let P=`${h.directoryPath}::${h.flattenedSegmentPath??""}`;if(Be.current===P)return;Rt(),Be.current=P,at.current=setTimeout(()=>{let F=t.getDragSession()?.target;if(F?.kind!=="directory"||F.directoryPath!==h.directoryPath||F.flattenedSegmentPath!==h.flattenedSegmentPath)return;_.expand()},b)},Bs=()=>{gt.current=null;let h=Et.current,b=O.current;if(h==null||b==null||t.getDragSession()==null)return;let N=b.getBoundingClientRect(),_=Op(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,Z.current();$i(Fr(h.clientX,h.clientY)),gt.current=Ls(Bs)},Hs=(h,b)=>{Et.current={clientX:h,clientY:b},gt.current??=Ls(Bs)},Jd=(h,b,N)=>{let _=h.currentTarget;if(_==null)return;if(ir(),Lr(),Rt(),rr(),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),Vp()){let P=ru(_),F=_.getBoundingClientRect();Object.assign(P.style,{height:`${F.height}px`,opacity:"0.85",transform:"translate3d(-9999px, 0px, 0)",width:`${F.width}px`}),Fs(P),Je.current=P,h.dataTransfer.setDragImage(P,Math.max(0,h.clientX-F.left),Math.max(0,h.clientY-F.top))}}},eh=()=>{Lr(),Rt(),rr(),We.current=null,t.cancelDrag()},th=(h,b,N)=>{if(je.current!=null||He.current)return;let _=h.touches[0],P=h.currentTarget;if(_==null||P==null)return;vt.current={clientX:_.clientX,clientY:_.clientY},Ce.current=P,P.setAttribute("draggable","false");let F=(J={})=>{let se=J.restoreNativeDraggable??!He.current;if(je.current!=null)clearTimeout(je.current),je.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;vt.current=null}},ce=(J)=>{let se=J.touches[0],re=vt.current;if(se==null||re==null)return;let he=se.clientX-re.clientX,Re=se.clientY-re.clientY;if(he*he+Re*Re<=eu*eu)return;F()},L=()=>{F()};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),Ee.current=F,je.current=setTimeout(()=>{if(F({restoreNativeDraggable:!1}),t.startDrag(N)===!1){if(P.setAttribute("draggable","true"),Ce.current===P)Ce.current=null;vt.current=null;return}He.current=!0,Ce.current=P,P.setAttribute("draggable","false"),P.style.setProperty("touch-action","none"),We.current=b;let J=P.getBoundingClientRect(),se=ru(P);Object.assign(se.style,{height:`${J.height}px`,opacity:"0.85",transform:`translate3d(${J.left}px, ${J.top}px, 0)`,width:`${J.width}px`}),Fs(se),Je.current=se,zt.current={x:_.clientX-J.left,y:_.clientY-J.top};let re=(rt)=>{let Ie=rt.touches[0];if(Ie==null)return;rt.preventDefault();let X=zt.current;if(X!=null&&Je.current!=null)Je.current.style.transform=`translate3d(${Ie.clientX-X.x}px, ${Ie.clientY-X.y}px, 0)`;$i(Fr(Ie.clientX,Ie.clientY)),Hs(Ie.clientX,Ie.clientY)},he=(rt)=>{let Ie=rt.changedTouches[0];if(Ie!=null)Fr(Ie.clientX,Ie.clientY);t.completeDrag(),ir()},Re=()=>{t.cancelDrag(),ir()};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)},Fp)},Vs=(h)=>{if(K!=null){if(h.key==="Escape"){Ge(),h.preventDefault(),h.stopPropagation();return}if(Up.has(h.key))h.preventDefault(),h.stopPropagation();return}if(Zn.isActive()){if(h.isComposing||h.keyCode===229)return;if(h.key==="Escape")Zn.cancel();else if(h.key==="Enter")Zn.commit();else return;De("focus"),et((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(d&&h.key==="F2"){Xd(W??void 0),h.preventDefault(),h.stopPropagation();return}if(ut){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 dt=O.current,qr=Mn(dt,Te);oe.current=ne<0||dt==null?null:Math.max(0,Math.min(ne*a-dt.scrollTop,Math.max(0,qr-a))),ye.current=!0,t.closeSearch()}else if(h.key==="ArrowDown")t.focusNextSearchMatch();else if(h.key==="ArrowUp")t.focusPreviousSearchMatch();else return;De("focus"),et((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(c&&Wp(h)){t.openSearch(h.key),et((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}let b=Ve&&fu(h),N=$p(h,Ve),_=N&&T.current!=null?Cr(T.current):null,P=N?new Set(Xp(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(),J=t.getFocusedIndex(),se=t.getFocusedItem();if(se==null)return;let re=iu(se)?se:null,he=L!=null&&(Mr.has(L)||ce&&F===L&&P.has(L)),Re=h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="ArrowRight"&&re!=null&&re.isExpanded(),rt=h.key==="ArrowLeft"&&he&&re!=null&&re.isExpanded(),Ie=O.current,X=!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&&J>=0){let ge=t.getVisibleRows(J,J)[0]??null,dt=au(L,pe.current,Q.current);if(ge==null||dt==null)X=!1;else Ns(ge,L)}else if((h.ctrlKey||h.metaKey)&&hu(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:X=!1}if(!X)return;De("focus");let me=t.getFocusedPath(),Me=me!=null&&(Mr.has(me)||P.has(me)),Vr=Re&&me!==L,Or=b&&ce&&F===L&&me===L;if((he||Or)&&me!=null&&(Vr&&Me||Or))j(me,Ie?.scrollTop??null),z.current=!0,tt((ge)=>ge===me?ge:me);else{let ge=h.key==="ArrowUp"&&he&&me!==L;if(me!=null&&(ge||rt&&me===L))yt(me,Zp(T.current,Ie,_,L,a,yn,Te)),z.current=!0,tt((dt)=>dt===me?dt:me);else H()}et((ge)=>ge+1),h.preventDefault(),h.stopPropagation()};qe(()=>{if(!c||!ut)return;if(Gt.current){Gt.current=!1;return}rn(fe.current)},[ut,c]),qe(()=>{let h=x.current;switch(Vc({hasRenderedInput:h!=null,previousRenamingPath:Y.current,renamingPath:vn})){case"reset":Y.current=null;return;case"reveal-canonical":if(vn!=null)Nr(vn,{restoreTreeFocus:!1,targetOffset:"live-overlay"});return;case"ignore":return;case"focus-input":if(h!=null)Pt.current=null,Y.current=vn,rn(h),h.select();return}},[nt.end,nt.start,vn,Nr,Mr]),qe(()=>{let h=T.current;if(h==null)return;let b=null,N=()=>{if(b==null)return;clearTimeout(b),b=null},_=()=>{let ce=Cr(h)?.dataset.itemPath??null;tt((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,Cr(h)!=null){_();return}z.current=!1,tt(null)},0);return}if(!(L instanceof Node)||!h.contains(L)){N(),z.current=!1,tt(null);return}let J=L instanceof HTMLElement?L.dataset.itemPath??null:null;tt((se)=>se===J?se:J)};return h.addEventListener("focusin",P),h.addEventListener("focusout",F),()=>{N(),h.removeEventListener("focusin",P),h.removeEventListener("focusout",F)}},[]),qe(()=>{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]),qe(()=>{let h=null,b=O.current,N=I.current,_=T.current;if(b==null)return;U.current=Mn(b,v);let P=()=>{let X=t.getVisibleCount(),me=Zo(U.current,v),Me=Math.max(0,X*a-me);if(b.scrollTop>Me)b.scrollTop=Me;Bd(ss({controller:t,itemHeight:a,overscan:l,scrollTop:Math.min(b.scrollTop,Me),stickyFolders:g,viewportHeight:me}))};if(!ae.current){ae.current=!0;let X=t.getFocusedIndex();if(X>=0){let me=Zo(U.current,v),Me=t.getVisibleRows(X,X)[0]??null;Jo(b,X,a,me,g&&Me!=null?Math.max(0,Math.min(Me.ancestorPaths.length*a,Math.max(0,me-a))):0)}}Z.current=P;let F=t.subscribe(()=>{if(Nc(be))et((X)=>X+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((X)=>X+1),h=null},50)},L=null,J=()=>{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(()=>{J()},200)},re=()=>{if(P(),b.scrollTop>0)J();if(ct.current!=null&&y.current)ji.current();if(A.current===!0){y.current=!1;return}jt((X)=>X==null?X:null),ce()},he=()=>{ce(),se()},Re=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," ","Spacebar"]),rt=(X)=>{if(!Re.has(X.key))return;he()};b.addEventListener("scroll",re,{passive:!0}),b.addEventListener("wheel",he,{passive:!0}),b.addEventListener("touchmove",he,{passive:!0}),b.addEventListener("keydown",rt);let Ie=typeof ResizeObserver<"u"?new ResizeObserver((X)=>{U.current=(X[0]==null?null:Bc(X[0]))??Mn(b,v),P()}):null;return Ie?.observe(b),()=>{if(Z.current=()=>{},F(),b.removeEventListener("scroll",re),b.removeEventListener("wheel",he),b.removeEventListener("touchmove",he),b.removeEventListener("keydown",rt),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,U.current=null,Ie?.disconnect()}},[t,v,a,l,g]),qe(()=>{if(Ve||K==null)return;Ge(!1)},[Ge,Ve,K]);let Os=Ct(()=>K==null?null:`${K.path}::${K.source}`,[K]);qe(()=>{if(Os==null){p?.clearSlotContent(yr);return}let h=ct.current;if(h==null)return;let b=S.current??C.current;if(b==null)return;let N={anchorElement:b,anchorRect:h.anchorRect??Kp(b.getBoundingClientRect()),close:(P)=>{ji.current(P?.restoreFocus??!0)},restoreFocus:()=>{if(!bn.current)return;As.current(ct.current?.path??null)}},_=e?.contextMenu?.render?.(h.item,N)??null;return p?.setSlotContent(yr,_),e?.contextMenu?.onOpen?.(h.item,N),du(_),queueMicrotask(()=>{if(_==null||!_.isConnected)return;if(document.activeElement!==_)return;du(_)}),()=>{p?.clearSlotContent(yr)}},[Os,e?.contextMenu,p]),qe(()=>{if(K!=null&&t.getItem(K.path)==null)Ge()},[Ge,K,t]),qe(()=>{if(K==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(ou(P))return;if(C.current?.contains(F)===!0)return;if(b?.contains(F)===!0)return;Ge()},_=(P)=>{if(P.key==="Escape")P.preventDefault(),P.stopPropagation(),Ge()};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",_,!0)}},[Ge,K]),qe(()=>{let h=O.current,b=T.current;if(h==null||b==null){le.current=W;return}let N=W==null?null:Q.current.get(W)??null,_=Cr(b),P=_?.dataset.itemPath??null,F=zi&&x.current===_,ce=c&&fe.current===_,L=ye.current&&!ut,J=oe.current??0,se=Pt.current,re=$t.current,he=Ut.current,Re=Kt.current,rt=_!=null,Ie=z.current||rt,X=le.current!==W,me=re!=null&&re===W&&W!=null,Me=!1,Vr=!1;if(Yt!=null&&Yt.id!==B.current){B.current=Yt.id;let Ki=Yt.visibleIndex,$s=t.getVisibleRows(Ki,Ki)[0]??null;if($s!=null){let Eh=g?Math.max(0,Math.min($s.ancestorPaths.length*a,Math.max(0,Te-a))):yn;Me=!0,Vr=Hc(h,Ki,a,Te,Xt,Yt.offset,Eh)}t.clearScrollRequest(Yt.id)}let Or=!Me&&L&&An(h,ne,a,Te,Xt,J),ge=!Me&&se!=null&&se===W&&An(h,ne,a,Te,Xt,yn),dt=!Me&&he!=null&&he.path===W&&An(h,ne,a,Te,Xt,he.viewportOffset),qr=!Me&&Re!=null&&Re.path===W&&h.scrollTop!==Re.scrollTop;if(qr)h.scrollTop=Re.scrollTop;if(qr||Vr||ge||dt||Or||Ie&&X&&se!==W&&!me&&Jo(h,ne,a,Te,yn))Z.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)An(h,ne,a,Te,Xt,J),Z.current();le.current=W;return}if(X||L||se===W||re===W||he?.path===W||Re?.path===W||P==null||P!==W){if(rn(N),se===W)Pt.current=null;if(re===W)$t.current=null;if(he?.path===W)Ut.current=null;if(Re?.path===W)Kt.current=null;ye.current=!1,oe.current=null}le.current=W},[t,ne,W,Wi,a,zi,ut,nt,Te,c,Yt,g,yn,Xt,Dr]);let nh=ne>=0&&ne>=xe.visible.startIndex&&ne<=xe.visible.endIndex,rh=W!=null&&tr.some((h)=>Fn(h.row)===W),ih=nh||rh,oh=gn&&z.current===!0&&ih?W:null,sh=$e==="pointer"?hn:null,Qt=K?.path??w.current??sh??oh??hn,qs=K?.source==="right-click";qe(()=>{if(y.current&&K==null)return;nr(Qn(Qt))},[K,Qn,nt,Te,Oi,tr,Qt,nr,Dr]);let ah=Pe((h)=>{if(y.current)return;if(ou(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");jt((F)=>F===P?F:P)},[]),lh=Pe(()=>{jt(null)},[]);qe(()=>{if(!bt)return;let h=()=>{ir(),t.cancelDrag()};return window.addEventListener("dragend",h),()=>{window.removeEventListener("dragend",h),ir(),t.cancelDrag()}},[t,bt]);let ch=(h)=>{if(!bt||t.getDragSession()==null||He.current)return;let b=nu(h.target instanceof HTMLElement?h.target:null);if(t.setDragTarget(b),$i(t.getDragSession()?.target??null),Hs(h.clientX,h.clientY),h.dataTransfer!=null)h.dataTransfer.dropEffect="move";h.preventDefault()},uh=(h)=>{if(!bt||t.getDragSession()==null||He.current)return;let b=h.relatedTarget;if(b instanceof Node&&T.current?.contains(b)===!0)return;Rt(),rr(),t.setDragTarget(null)},dh=(h)=>{if(!bt||t.getDragSession()==null||He.current)return;h.preventDefault(),Fr(h.clientX,h.clientY),t.completeDrag(),Lr(),Rt(),rr(),We.current=null},or=xe.window.height,hh=xe.window.offsetTop,fh=Math.min(0,Te-or),ph=Math.min(0,Te-or-yn),mh=lt===W||ye.current,wn=W!=null&&mh&&!Wi&&ne>=0?Dr[ne]??t.getVisibleRows(ne,ne)[0]??null:null,zs=wn==null?null:es(ne,a,nt,or),Dt=We.current,gh=er!=null&&Dt!=null&&Dt.path===er&&Dt.index>=nt.start&&Dt.index<=nt.end,sr=er!=null&&Dt!=null&&Dt.path===er&&!gh&&Dt.path!==wn?.path?Dt:null,Ws=sr==null?null:es(sr.index,a,nt,or),vh=jp((ne>=0?Dr[ne]??t.getVisibleRows(ne,ne)[0]??null:null)?.ancestorPaths.at(-1)??null),yh=ut&&W!=null?pu(s,W,!Wi):void 0,bh=K?.path??(ut?W:lt),wh=K?.path??hn,ar=Qn(Qt),Ui=Ve&&gn&&!qs&&!zi&&ar!=null&&Tt!=null&&Qt!=null,Ih=Ve&&(Ui||K!=null),Br=K?.anchorRect,js=Br==null&&ar!=null&&Tt!=null&&(K!=null||Ui)?Tt:null,Sh=Br!=null?{left:`${Br.left}px`,position:"fixed",right:"auto",top:`${Br.top}px`}:js!=null?{top:`${js}px`}:void 0,Ch=qs?{opacity:"0"}:void 0,xh=Pe((h,b,N,_)=>{let P=zc({event:{ctrlKey:h.ctrlKey,metaKey:h.metaKey,shiftKey:h.shiftKey},isDirectory:b.kind==="directory",isSearchOpen:ut,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 J=h.currentTarget instanceof HTMLElement?h.currentTarget:null,se=b.index>=xe.visible.startIndex&&b.index<=xe.visible.endIndex,re=_==="flow"&&se&&J!=null&&J.dataset.itemParked!=="true";if(t.focusMountedPathFromInput(L),re)z.current=!0,tt((he)=>he===L?he:L),De("focus");if(F)t.toggleMountedDirectoryFromInput(L);if(P.closeSearch)t.closeSearch();if(P.revealCanonical)Nr(L,{targetOffset:"sticky-parents"})},[t,ut,xe.visible.endIndex,xe.visible.startIndex,Nr]),kh=()=>{if(y.current)return;if(!gn)return;if(Qt==null||ar==null)return;let h=t.getItem(Qt);if(h==null)return;nr(ar),bn.current=!0,pn({anchorRect:null,item:{kind:h.isDirectory()?"directory":"file",name:ar.getAttribute("aria-label")??Qt,path:h.getPath()},path:h.getPath(),source:"button"})},Hr={contextHoverPath:wh,contextMenuButtonTriggerEnabled:gn,contextMenuButtonVisibility:Es,contextMenuEnabled:Ve,contextMenuRightClickEnabled:Od,contextMenuTriggerMode:mn,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:bt,draggedPathSet:$d,dragTarget:Ud,gitLaneActive:Ts,gitStatusByPath:n,handleRowDragEnd:eh,handleRowDragStart:Jd,handleRowTouchStart:th,ignoredGitDirectories:r,ignoredInheritanceCache:Wt,instanceId:s,itemHeight:a,onKeyDown:Vs,onRowClick:xh,openContextMenuForRow:Ns,registerButton:qd,registerRenameInput:Wd,renameView:Zn,renderDecorationForRow:Yd,resolveIcon:Ps,shouldSuppressContextMenu:Qd,visualFocusPath:bh},_h={...Hr,registerButton:zd};return k("div",{ref:T,id:Rs,"data-file-tree-context-menu-button-visibility":Ve&&gn?Es:void 0,"data-file-tree-context-menu-trigger-mode":Ve?mn:void 0,"data-file-tree-has-context-menu-action-lane":Ve&&gn?"true":void 0,"data-file-tree-has-git-lane":Ts?"true":void 0,"data-file-tree-virtualized-root":"true",onDragLeave:bt?uh:void 0,onDragOver:bt?ch:void 0,onDrop:bt?dh:void 0,onKeyDown:Vs,onPointerLeave:Ve?lh:void 0,onPointerOver:Ve?ah:void 0,role:"tree",tabIndex:-1,style:{outline:"none",position:"relative"},children:[k("style",{"data-file-tree-guide-style":"true",dangerouslySetInnerHTML:{__html:vh}}),k("slot",{name:vr,"data-type":"header-slot"}),c?k("div",{"data-file-tree-search-container":!0,"data-open":ut?"true":"false",children:k("input",{ref:fe,"aria-activedescendant":yh,"aria-controls":Rs,placeholder:"Search…","data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Xn?"true":void 0,value:jd,onBlur:()=>{if(f==="retain"&&!_s.current)return;t.closeSearch()},onFocus:qi,onPointerDown:qi,onInput:(h)=>{qi();let b=h.currentTarget;t.setSearch(b.value)}})}):null,k("div",{ref:O,"data-file-tree-virtualized-scroll":"true",children:[g&&Hd&&tr.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:`${Kd}px`},children:tr.map((h,b)=>xi(_h,h.row,`sticky:${Fn(h.row)}`,{mode:"sticky",style:{left:"0",position:"absolute",right:"0",top:`${h.top}px`,zIndex:`${tr.length-b}`}}))})}):null,k("div",{ref:I,"data-file-tree-virtualized-list":"true",style:{height:`${Xt}px`},children:[k("div",{"data-file-tree-virtualized-sticky-offset":"true","aria-hidden":"true",style:{height:`${hh}px`}}),k("div",{"data-file-tree-virtualized-sticky":"true",style:{height:`${or}px`,top:`${fh}px`,bottom:`${ph}px`},children:[tm(Hr,nt,Mr),wn!=null&&zs!=null?xi(Hr,wn,`parked:${wn.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:er===wn.path?"none":void 0,position:"absolute",right:"0",top:`${zs}px`}}):null,sr!=null&&Ws!=null?xi(Hr,sr,`parked-drag:${sr.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:"none",position:"absolute",right:"0",top:`${Ws}px`}}):null]})]})]}),Ve?k("div",{ref:C,"data-type":"context-menu-anchor","data-visible":Ih?"true":"false",style:Sh,children:[k("button",{ref:S,type:"button","data-type":Vl,"aria-label":"Options","aria-haspopup":"menu","aria-expanded":K!=null?"true":"false","data-visible":Ui?"true":"false",onMouseDown:(h)=>{h.preventDefault()},onClick:(h)=>{if(h.preventDefault(),h.stopPropagation(),K!=null){Ge();return}kh()},tabIndex:-1,style:Ch,children:k(Dn,{...Ps("file-tree-icon-ellipsis")})}),K!=null?k("slot",{name:yr}):null]}):null,K!=null?k("div",{"data-type":"context-menu-wash","aria-hidden":"true",onMouseDownCapture:(h)=>{h.preventDefault(),Ge()},onTouchStartCapture:(h)=>{h.preventDefault(),h.stopPropagation(),Ge()},onTouchMoveCapture:(h)=>{h.preventDefault(),h.stopPropagation()},onWheelCapture:(h)=>{h.preventDefault(),h.stopPropagation()}}):null]})}var cs={hydrateRoot:(e,t)=>{Sc(Rn(ls,t),e)},renderRoot:(e,t)=>{Ii(Rn(ls,t),e)},unmountRoot:(e)=>{Ii(null,e)}};function Bn(e,t){cs.renderRoot(e,t)}function mu(e,t){cs.hydrateRoot(e,t)}function gu(e){cs.unmountRoot(e)}var vu=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 yu=0;function nm(e){if(e!=null&&e.length>0)return e;return yu+=1,`pst_ft_${yu}`}function rm({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??ci)}function bu(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 wu(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 Iu(e){return Array.from(e.children).filter((t)=>t instanceof SVGElement)}var kr=class{static LoadedCustomComponent=!0;#e;#t;#c;#u;#a;#V;#O;#v;#r;#y=new vu;#T;#b;#m;#h;#w;#I;#f;#q;#z;#N=null;#i;#W=!1;#j=!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:C,unsafeCSS:S,initialVisibleRowCount:y,...I}=e;this.#e=t,this.#c=nm(o),this.#h=Ho(i),this.#w=a,this.#I=S,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=Ol(n,l),this.#b={itemHeight:this.#T.itemHeight,overscan:f,stickyFolders:C,initialVisibleRowCount:y},this.#t=new Jl({...I,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)gu(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=rc(this.#h,e);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Bn(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(),Bn(t.wrapper,this.#P())}setGitStatus(e){let t=Ho(e,this.#h);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Bn(n.wrapper,this.#P())}setIcons(e){this.#w=e;let t=this.#s();if(t==null)return;this.#g(t.host,t.wrapper),Bn(t.wrapper,this.#P())}hydrate({fileTreeContainer:e}){let t=this.#M(e),n=this.#L(t);this.#k(),mu(n,this.#P())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#M(t??this.#m,e),r=this.#L(n);this.#k(),Bn(r,this.#P())}#Z(){return{initialViewportHeight:rm({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.#$(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(vr,e());return}this.#y.setSlotHtml(vr,this.#e?.header?.html??null)}#$(e){let t=Iu(e).find((r)=>wu(r)),n=bu(Al(En(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=Iu(e),n=t.find((s)=>wu(s)),r=t.filter((s)=>s!==n),i=En(this.#w).spriteSheet?.trim()??"";if(i.length===0){for(let s of r)s.remove();return}let o=bu(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=En(this.#w);if(t.colored&&Ll(t.set))e.dataset.fileTreeColoredIcons="true";else delete e.dataset.fileTreeColoredIcons}#l(e){let t=e.querySelector(`style[${_o}]`);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(_o,""),this.#f.parentNode!==e)e.appendChild(this.#f);this.#f.textContent=ql(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 hi(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.#j=!0}#F(e){if(this.#W)e.style.removeProperty("--trees-item-height"),this.#W=!1;if(this.#j)e.style.removeProperty("--trees-density-override"),this.#j=!1}};var Su=["--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("; "),us=`
|
|
1285
|
+
}`}var zl=new WeakMap;function Ff(e){let t=zl.get(e);if(t!=null)return t;let n=document.createElement("div");n.setAttribute(Bl,"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(),zl.set(e,i),i}function Wl(e,t){if(!e.isConnected)return;let n=Ff(t);if(n==null)return;let r=t.querySelector(`style[${Eo}]`),i=r instanceof HTMLStyleElement?r:document.createElement("style");if(!(r instanceof HTMLStyleElement))i.setAttribute(Eo,""),t.appendChild(i);i.textContent=`:host { ${Hl}: ${n}px; }`}var di;function Bf(e){if(typeof CSSStyleSheet<"u"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in e){if(di==null)di=new CSSStyleSheet,di.replaceSync(ui(To));let t=!1;try{e.adoptedStyleSheets=[di],t=!0}catch{}if(t){e.querySelector(`style[${ai}]`)?.remove();return}}if(e.querySelector("style[data-file-tree-style]")==null){let t=document.createElement("style");t.setAttribute(ai,""),t.textContent=ui(To),e.prepend(t)}}function hi(e,t){Hf(e,t),Bf(t),Wl(e,t)}function Hf(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"});hi(this,t)}}if(customElements.define(ko,e),typeof document<"u")for(let t of Array.from(document.querySelectorAll(ko))){if(!(t instanceof HTMLElement))continue;hi(t,t.shadowRoot??t.attachShadow({mode:"open"}))}}var jl=(e)=>e.startsWith("f::")?e.slice(3):e;function Vf(e){let t=e.lastIndexOf("/");if(t<0)return{parentPath:"",baseName:e};return{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function Of(e,t){return e===""?t:`${e}/${t}`}function $l({files:e,path:t,isFolder:n,nextBasename:r}){let i=jl(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}=Vf(i);if(o===a)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let l=Of(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 C=e[v];if(C!==i&&C.startsWith(p))return{error:`"${l}" already exists.`};let S=C===i?l:C;if(u.has(S))return{error:`"${l}" already exists.`};if(u.add(S),d[v]=S,C===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 C=v?`${l}${g.slice(i.length)}`:g;if(u.has(C))return{error:`"${l}" already exists.`};if(u.add(C),d[p]=C,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 qf(e){return e.endsWith("/")}function zf(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 Wf(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 Ul(e,t){return t.includes(e)?Wf(t):[e]}function Kl(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 Po(e,t){return{draggedPaths:e,target:t}}function Ro(e,t){if(t.kind!=="directory"||t.directoryPath==null)return!1;for(let n of e){if(!qf(n))continue;if(t.directoryPath===n||t.directoryPath.startsWith(n))return!0}return!1}function jf(e,t){if(t.kind==="root"||t.directoryPath==null)return zf(e);return t.directoryPath}function Gl(e,t){let n=e.map((r)=>{let i=jf(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 $f(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 Do(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(!$f(si.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 Mo(e){return e.operation==="add"||e.operation==="remove"||e.operation==="move"||e.operation==="batch"}function Uf(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 Kf(e,t){if(e===t)return!0;let n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)}function Tn(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 Kf(e,t.path)?n?e:null:e;case"move":return Uf(e,t.from,t.to);case"batch":{let r=e;for(let i of t.events)if(r=Tn(r,i,n),r==null)return null;return r}}}function fi(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function Yl(e){switch(e.operation){case"add":return{...fi(e),operation:"add",path:e.path};case"remove":return{...fi(e),operation:"remove",path:e.path,recursive:e.recursive};case"move":return{...fi(e),from:e.from,operation:"move",to:e.to}}}function Gf(e){return{...fi(e),events:e.events.filter((t)=>t.operation==="add"||t.operation==="remove"||t.operation==="move").map((t)=>Yl(t)),operation:"batch"}}function Xl(e){switch(e.operation){case"add":case"remove":case"move":return Yl(e);case"batch":return Gf(e);default:return null}}function pi(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function St(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 mi(e){return St(e).at(-1)??null}function Ao(e,t){if(t==null)return e;return e.startsWith(t)?e.slice(t.length):e}function br(e){return e.endsWith("/")}var No=(e)=>e.toLowerCase();function Ql(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n<0?t:t.slice(n+1)}function Lo(e){return e.endsWith("/")?e.slice(0,-1):e}function Fo(e,t){return t&&!e.endsWith("/")?`${e}/`:e}var Zl=(e)=>{let t=e.trim();if(t.length===0)return"";return(t.includes("\\")?t.replaceAll("\\","/"):t).toLowerCase()};var Bo=Symbol("FILE_TREE_RENAME_VIEW"),Yf=512,Xf=512;function Qf(e){return e==="top"||e==="center"?e:"nearest"}function Zf(e,t,n){if(e===0)return-1;if(n!=null){let r=t(n);if(r!=null)return r;let i=St(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 Jf(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:Zf(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var Jl=class e{static{Object.defineProperty(e.prototype,Bo,{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);#j=new Int32Array(0);#Z=void 0;#P=!1;#s=null;#g="";#R=!1;#k=new Set;#$=[];#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=Do({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=mi(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:Qf(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<=Xf){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=Ul(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=Po(n.draggedPaths,r);if(Ro(n.draggedPaths,r)||this.#u?.canDrop?.(i)===!1)r=null}if(Kl(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=Po(t.draggedPaths,n);if(Ro(t.draggedPaths,n)||this.#u?.canDrop?.(r)===!1)return this.#d(),!1;let i=Gl(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.#$}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=br(i),s=Lo(i);if(this.#Z?.({isFolder:o,path:s})===!1)return!1;for(let a of St(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=Ql(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,br(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,br(t)?{recursive:!0}:void 0);return}let n=br(t),r=$l({files:this.#n.list(),isFolder:n,nextBasename:this.#g,path:Lo(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(Fo(r.sourcePath,n),Fo(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=Do({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=!pi(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=mi(t),r=Ao(t,n),i=null,o=null;for(let s of this.#_()){if(mi(s)!==n)continue;let a=Ao(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=St(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.#j[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=!pi(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 si({...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 St(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(No),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(No),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 St(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.#$=[],this.#x=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let t=this.#i;if(this.#$=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.#$;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:Zl(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 St(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 St(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=Jf(this.#n.getVisibleTreeProjectionData(n?void 0:Math.min(r,Yf)),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.#j=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=Tn(this.#s,t);if(n==null&&this.#s!=null)this.#g="";this.#s=n;let r=Tn(this.#r,t,!0),i=[...this.#o].map((l)=>Tn(l,t)).filter((l)=>l!=null).map((l)=>this.#n.getPathInfo(l)?.path??null).filter((l)=>l!=null),o=Tn(this.#S,t),s=o==null?null:this.#n.getPathInfo(o)?.path??null,a=[...new Set(i)];if(!pi(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&&Mo(t))this.#a=null;let n=Mo(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=Xl(t);if(o!=null)this.#we(o)})}#xe(t){if(this.#n.isExpanded(t)){this.#pe(t);return}this.#Ie(t)}};var ec=(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 tc(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 nc(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 ep(e,t){return t?`${e}/`:e}function Ho(e,t=null){let n=ec(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=ic(a);if(l==null)continue;sc({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 rc(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=oc(d);if(u==null)continue;l=tp({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,statusByPath:i})||l}for(let d of r){let u=ic(d);if(u==null)continue;l=sc({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:ip(i),statusByPath:i}}function ic(e){return oc(e.path)}function oc(e){let t=tc(e);if(t==null)return;return{canonicalPath:ep(t.path,t.isDirectory),isDirectory:t.isDirectory}}function tp({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 rp(t,n,e),!0}function sc({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)np(t,n,e);if(s.set(e,o),o==="ignored"&&i)r.add(e);else if(i)r.delete(e);return!0}function np(e,t,n){for(let r of nc(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function rp(e,t,n){for(let r of nc(n)){let i=(e.get(r)??0)-1;if(i>0)e.set(r,i);else e.delete(r),t.delete(r)}}function ip(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\x00${n}\x00${r}`;return t}var op=(e)=>e.trim().toLowerCase(),sp=(e)=>e.split("/").at(-1)??e,ap=(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 wr(e,t){if(typeof e==="string")return{name:e,remappedFrom:t};return{...e,remappedFrom:t}}function ac(e){let t=En(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(op(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=sp(l),f=u.toLowerCase(),c=r.get(f);if(c!=null)return wr(c,a);for(let[g,v]of o)if(f.includes(g))return wr(v,a);let m=ap(u);for(let g of m){let v=i.get(g);if(v!=null)return wr(v,a)}let p=Fl(t.set,u,m);if(p!=null&&t.set!=="none"){if(p==="default"){let g=n?.[a];if(g!=null)return wr(g,a)}return{name:Nl(p),remappedFrom:a,token:p}}}let d=n?.[a];if(d==null)return{name:a};return wr(d,a)}}}var G,hc,lp,nn,lc,bi,fc,pc,zo,Vo,Oo,cp,Ir={},mc=[],wi=Array.isArray,Wo=mc.slice,Vt=Object.assign;function jo(e){e&&e.parentNode&&e.remove()}function Rn(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?Wo.call(arguments,2):n),vi(e,s,r,i,null)}function vi(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?++hc:i,__i:-1,__u:0};return i==null&&G.vnode!=null&&G.vnode(o),o}function ht(e){return e.children}function yi(e,t){this.props=e,this.context=t,this.__g=0}function Pn(e,t){if(t==null)return e.__?Pn(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"?Pn(e):null}function gc(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 gc(e)}}function cc(e){(8&e.__g||!(e.__g|=8)||!nn.push(e)||bi++)&&lc==G.debounceRendering||((lc=G.debounceRendering)||queueMicrotask)(up)}function up(){for(var e,t,n,r,i,o,s,a,l=1;nn.length;)nn.length>l&&nn.sort(fc),e=nn.shift(),l=nn.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,o=[],s=[],(a=t.__P)&&((n=Vt({},r)).__v=r.__v+1,G.vnode&&G.vnode(n),$o(a,n,r,t.__n,a.namespaceURI,32&r.__u?[i]:null,o,i==null?Pn(r):i,!!(32&r.__u),s,a.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,bc(o,n,s),n.__e!=i&&gc(n)));bi=0}function vc(e,t,n,r,i,o,s,a,l,d,u,f){var c,m,p,g,v,C,S,y=r&&r.__k||mc,I=t.length;for(l=dp(n,t,y,l,I),c=0;c<I;c++)(p=n.__k[c])!=null&&(m=p.__i==-1?Ir:y[p.__i]||Ir,p.__i=c,C=$o(e,p,m,i,o,s,a,l,d,u,f),g=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Uo(m.ref,null,p),u.push(p.ref,p.__c||g,p)),v==null&&g!=null&&(v=g),(S=!!(4&p.__u))||m.__k===p.__k?l=yc(p,l,e,S):typeof p.type=="function"&&C!==void 0?l=C:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=v,l}function dp(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?vi(null,s,null,null,null):wi(s)?vi(ht,{children:s},null,null,null):s.constructor==null&&s.__b>0?vi(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=hp(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=Pn(a)),Ic(a,a));return r}function yc(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=yc(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Pn(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function hp(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 uc(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":n}function gi(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||uc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||uc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(pc,"$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=zo,e.addEventListener(t,o?Oo:Vo,o)):e.removeEventListener(t,o?Oo:Vo,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 dc(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=zo++;else if(t.u<n.l)return;return n(G.event?G.event(t):t)}}}function $o(e,t,n,r,i,o,s,a,l,d,u){var f,c,m,p,g,v,C,S,y,I,x,T,O,fe,Q,pe,Z,U,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=G.__b)&&f(t);e:if(typeof z=="function")try{if(S=t.props,y="prototype"in z&&z.prototype.render,I=(f=z.contextType)&&r[f.__c],x=f?I?I.props.value:f.__:r,n.__c?2&(c=t.__c=n.__c).__g&&(c.__g|=1,C=!0):(y?t.__c=c=new z(S,x):(t.__c=c=new yi(S,x),c.constructor=z,c.render=pp),I&&I.sub(c),c.props=S,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=Vt({},c.__s)),Vt(c.__s,z.getDerivedStateFromProps(S,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&&S!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(S,x),!(4&c.__g)&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(S,c.__s,x)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(c.props=S,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(S,c.__s,x),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,v)})}if(c.context=x,c.props=S,c.__P=e,c.__g&=-5,O=G.__r,fe=0,y){for(c.state=c.__s,c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),Q=0;Q<c._sb.length;Q++)c.__h.push(c._sb[Q]);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=Vt({},r,c.getChildContext())),y&&!m&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(p,g)),pe=f,f!=null&&f.type===ht&&f.key==null&&(pe=wc(f.props.children)),a=vc(e,wi(pe)?pe:[pe],t,n,r,i,o,s,a,l,d,u),t.__u&=-161,c.__h.length&&s.push(c),C&&(c.__g&=-4)}catch(le){if(t.__v=null,l||o!=null)if(le.then){for(Z=0,U=!1,t.__u|=l?160:128,t.__c.__z=[],B=0;B<o.length;B++)(ae=o[B])==null||U||(ae.nodeType==8&&ae.data=="$s"?(Z>0&&t.__c.__z.push(ae),Z++,o[B]=null):ae.nodeType==8&&ae.data=="/$s"?(--Z>0&&t.__c.__z.push(ae),U=Z===0,a=o[B],o[B]=null):Z>0&&(t.__c.__z.push(ae),o[B]=null));if(!U){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--;)jo(o[Se]);qo(t)}else t.__e=n.__e,t.__k=n.__k,le.then||qo(t);G.__e(le,t,n)}else a=t.__e=fp(n.__e,t,n,r,i,o,s,l,d,u);return(f=G.diffed)&&f(t),128&t.__u?void 0:a}function qo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(qo)}function bc(e,t,n){for(var r=0;r<n.length;r++)Uo(n[r],n[++r],n[++r]);G.__c&&G.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){G.__e(o,i.__v)}})}function wc(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:wi(e)?e.map(wc):Vt({},e)}function fp(e,t,n,r,i,o,s,a,l,d){var u,f,c,m,p,g,v,C,S=n.props,y=t.props,I=t.type;if(I=="svg"?i="http://www.w3.org/2000/svg":I=="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==!!I&&(I?p.localName==I:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(I==null)return d.createTextNode(y);e=d.createElementNS(i,I,y.is&&y),a&&(G.__m&&G.__m(t,o),a=!1),o=null}if(I==null)S===y||a&&e.data==y||(e.data=y);else{if(o=o&&Wo.call(e.childNodes),S=n.props||Ir,!a&&o!=null)for(S={},u=0;u<e.attributes.length;u++)S[(p=e.attributes[u]).name]=p.value;for(u in S)if(p=S[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;gi(e,u,null,p,i)}for(u in C=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"||S[u]===p&&!C||gi(e,u,p,S[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=""),vc(I=="template"?e.content:e,wi(m)?m:[m],t,n,r,I=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Pn(n,0),a,l,d),o!=null)for(u=o.length;u--;)jo(o[u]);a||(u="value",I=="progress"&&g==null?e.removeAttribute("value"):g==null||g===e[u]&&(I!=="progress"||g)||gi(e,u,g,S[u],i),u="checked",v!=null&&v!=e[u]&&gi(e,u,v,S[u],i))}return e}function Uo(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){G.__e(i,n)}}function Ic(e,t,n){var r,i;if(G.unmount&&G.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Uo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){G.__e(o,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ic(r[i],t,n||typeof e.type!="function");n||jo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function pp(e,t,n){return this.constructor(e,n)}function Ii(e,t){var n,r,i,o;t==document&&(t=document.documentElement),G.__&&G.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=Rn(ht,null,[e]),i=[],o=[],$o(t,e,r||Ir,Ir,t.namespaceURI,r?null:t.firstChild?Wo.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o,t.ownerDocument),bc(i,e,o)}function Sc(e,t){e.__u|=32,Ii(e,t)}G={__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 bi=0,e}},hc=0,lp=function(e){return e!=null&&e.constructor==null},yi.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Vt({},this.state),typeof e=="function"&&(e=e(Vt({},n),this.props)),e&&Vt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),cc(this))},yi.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),cc(this))},yi.prototype.render=ht,nn=[],bi=0,fc=function(e,t){return e.__v.__b-t.__v.__b},pc=/(PointerCapture)$|Capture$/i,zo=0,Vo=dc(!1),Oo=dc(!0),cp=0;var mp=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:--mp,__i:-1,__u:0,__source:i,__self:o};return G.vnode&&G.vnode(d),d}var gp=16,vp=16,yp={};function Dn({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}=yp[e]??{width:gp,height:vp},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 Cc=(e)=>e!==void 0&&/\s/.test(e),bp=(e,t)=>{let n=(r)=>Cc(e[r-1])||Cc(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},kc=(e)=>bp(e,Math.ceil(e.length/2)),xc=(e)=>{if(e.length<2)return[e,""];let t=kc(e);return[e.slice(0,t),e.slice(t)]},wp=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf(".")+1,n=e.length-t>10,r=t>=1&&!n?t:kc(e);return[e.slice(0,r),e.slice(r)]},Ip=(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)]},Sp=(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)]},Cp=(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)]},xp=(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 kp({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 _p(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 _c({children:e,mode:t="truncate",marker:n="…",variant:r="default",...i}){let o=k(_p,{mode:t,children:e},"content"),s=k(kp,{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 Sr({children:e,...t}){return k(_c,{mode:"truncate",...t,children:e})}function Ko({children:e,...t}){return k(_c,{mode:"fruncate",...t,children:e})}function Ec({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(Sr,{...a,children:t[0]}),d=k(Ko,{...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(Ko,{...a,className:o,style:s,children:e});else return k(Sr,{...a,className:o,style:s,children:e});let u=null,f=null,c=null;if(typeof r==="string"){if(r==="center")u=xc;else if(r==="extension")u=wp;else if(r==="leaf-path")u=Ip}else if(typeof r==="number")u=Sp,f=r;else if(Array.isArray(r)){let[I,x]=r;if(c=x,I==="last")u=Cp;else if(I==="first")u=xp}else if(typeof r==="function")u=r;u??=xc;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,C=n==="equal"&&g,S={},y={};if(v)S.marker="";if(C)y.marker="";l=k(Sr,{...a,...S,children:m}),d=k(Ko,{...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 Go={endIndex:-1,startIndex:-1};function Ep(e,t,n){return Math.min(Math.max(e,t),n)}function Tc(e,t){return e<0||t<e?Go:{endIndex:t,startIndex:e}}function Yo(e){return e.startIndex<0||e.endIndex<e.startIndex}function Tp(e,t){return Yo(e)?0:(e.endIndex-e.startIndex+1)*t}function Pc(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 Pp(e,t,n){if(t<=0||e<=0)return-1;if(e>=t*n)return t-1;return Math.ceil(e/n)-1}function Rp(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 Dp(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 Mp(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 Xo(e,t,n){if(e.length===0||t<=0)return[];let r=Mp(e),i=Rp(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=Dp(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 Rc(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=Ep(t.scrollTop,0,s),l=t.stickyRows??Xo(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=Pc(a,n,t.itemHeight),p=Pc(u,n,t.itemHeight),g=d<=0||m<0||m>=n?-1:m,v=g===-1?-1:Math.min(n-1,p-1),C=g===-1||v<g?0:v-g+1,S=f<=0||p>=n?Go:Tc(p,Pp(u+f,n,t.itemHeight)),y=v+1,I=Yo(S)?Go:Tc(Math.max(y,S.startIndex-o),Math.min(n-1,S.endIndex+o)),x=Tp(I,t.itemHeight);return{occlusion:{firstOccludedIndex:g,lastOccludedIndex:v,occludedCount:C},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:S,window:{endIndex:I.endIndex,height:x,offsetTop:Yo(I)?0:I.startIndex*t.itemHeight,startIndex:I.startIndex}}}var Dc={added:"A",deleted:"D",ignored:null,modified:"M",renamed:"R",untracked:"U"},Mc={added:"Git status: added",deleted:"Git status: deleted",ignored:"Git status: ignored",modified:"Git status: modified",renamed:"Git status: renamed",untracked:"Git status: untracked"},Ac="Contains git status items";function Nc(e){if(e.current)return!0;return e.current=!0,!1}function Qo(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 Lc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:o=0,totalHeight:s,viewportHeight:a}=e;if(i==="nearest")return Qo({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 Fc(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 rn(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 Cr(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 Mn(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 Zo(e,t){return e!=null&&e>0?e:t}function Bc(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 Jo(e,t,n,r,i=0){let o=Qo({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});if(o==null)return!1;return e.scrollTop=o,!0}function Hc(e,t,n,r,i,o,s=0){let a=Lc({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 An(e,t,n,r,i,o){let s=Fc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:o,totalHeight:i,viewportHeight:r});if(s==null)return!1;return e.scrollTop=s,!0}function es(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 Vc(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 Oc({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 qc(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 zc(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 Nn,ve,ts,Wc,ns=Object.is,xr=0,Qc=[],we=G,jc=we.__b,$c=we.__r,Uc=we.diffed,Kc=we.__c,Gc=we.unmount,Yc=we.__;function Ci(e,t){we.__h&&we.__h(ve,e,xr||t),xr=0;var n=ve.__H||(ve.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ot(e){return xr=1,Ap(Zc,e)}function Ap(e,t,n){var r=Ci(Nn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Zc(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],d=r.t(l,a);ns(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,ns(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 is(e,t){var n=Ci(Nn++,3);!we.__s&&os(n.__H,t)&&(n.__=e,n.u=t,ve.__H.__h.push(n))}function qe(e,t){var n=Ci(Nn++,4);!we.__s&&os(n.__H,t)&&(n.__=e,n.u=t,ve.__h.push(n))}function V(e){return xr=5,Ct(function(){return{current:e}},[])}function Ct(e,t){var n=Ci(Nn++,7);return os(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Pe(e,t){return xr=8,Ct(function(){return e},t)}function Np(){for(var e;e=Qc.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Si),e.__H.__h.forEach(rs),e.__H.__h=[]}catch(t){e.__H.__h=[],we.__e(t,e.__v)}}we.__b=function(e){ve=null,jc&&jc(e)},we.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Yc&&Yc(e,t)},we.__r=function(e){$c&&$c(e),Nn=0;var t=(ve=e.__c).__H;t&&(ts===ve?(t.__h=[],ve.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(Si),t.__h.forEach(rs),t.__h=[],Nn=0)),ts=ve},we.diffed=function(e){Uc&&Uc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Qc.push(t)!==1&&Wc===we.requestAnimationFrame||((Wc=we.requestAnimationFrame)||Lp)(Np)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ts=ve=null},we.__c=function(e,t){t.some(function(n){try{n.__h.forEach(Si),n.__h=n.__h.filter(function(r){return!r.__||rs(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],we.__e(r,n.__v)}}),Kc&&Kc(e,t)},we.unmount=function(e){Gc&&Gc(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Si(r)}catch(i){t=i}}),n.__H=void 0,t&&we.__e(t,n.__v))};var Xc=typeof requestAnimationFrame=="function";function Lp(e){var t,n=function(){clearTimeout(r),Xc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Xc&&(t=requestAnimationFrame(n))}function Si(e){var t=ve,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ve=t}function rs(e){var t=ve;e.__c=e.__(),ve=t}function os(e,t){return!e||e.length!==t.length||t.some(function(n,r){return!ns(n,e[r])})}function Zc(e,t){return typeof t=="function"?t(e):t}function Fp(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(ht,{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(Sr,{children:i.name})}),o<r.length-1?" / ":""]},i.path)})})}function Fn(e){return e.isFlattened?e.flattenedSegments?.findLast((t)=>t.isTerminal)?.path??e.path:e.path}function as(e){let t=e.flattenedSegments;if(t==null||t.length===0)return e.name;return t.map((n)=>n.name).join(" / ")}function Jc(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 ss({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=Rc(l,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:a==null?void 0:Jc(a,r,t,s),totalRowCount:s,viewportHeight:o}),u=i&&r<=0&&s>0?e.getStickyRowCandidates(1,t):[],f=u!=null&&r<=0?Jc(u,1,t,s):i&&r<=0&&l.length>0?Xo(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 Bp=400,eu=10,Ln=40,tu=18;function Hp(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 Vp(e,t,n);return o instanceof HTMLElement?o:null}function Vp(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 nu(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 ru(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 Op(){return navigator.vendor!=="Apple Computer, Inc."}function qp(e,t){let n=e-t.top;if(n<Ln)return-Math.ceil((Ln-Math.max(0,n))/Ln*tu);let r=t.bottom-e;if(r<Ln)return Math.ceil((Ln-Math.max(0,r))/Ln*tu);return 0}function zp(e,t){if(e!=null){let n=Dc[e];if(n==null)return null;return{text:n,title:Mc[e]}}if(t)return{icon:{name:"file-tree-icon-dot",width:6,height:6},title:Ac};return null}function Wp(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 iu(e){return e!=null&&"toggle"in e}function hu(e){return e.code==="Space"||e.key===" "||e.key==="Spacebar"}function jp(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function $p(e){if(e==null)return"";return`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"] { opacity: 1; }`}function fu(e){return e.shiftKey&&e.key==="F10"||e.key==="ContextMenu"}function Up(e,t){if(t&&fu(e))return!0;if((e.ctrlKey||e.metaKey)&&hu(e))return!0;return e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"}var Kp=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp"]);function ou(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 Gp(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 Yp(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function Xp(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function su(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function au(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 Qp(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 Zp(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 Jp(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=Zp(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 lu(e,t){return{kind:e.kind,name:as(e),path:t}}function em(e){return e==null?void 0:`${e}__tree`}function pu(e,t,n){if(e==null)return;return`${e}__focused-item-${encodeURIComponent(t)}${n?"__parked":""}`}function cu(e){return e==="file-tree-icon-chevron"||e==="file-tree-icon-dot"||e==="file-tree-icon-file"||e==="file-tree-icon-lock"}function uu(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"?cu(e.icon)?t(e.icon):{name:e.icon}:cu(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(Dn,{...n})})}function du(e){if(e==null)return;rn(e.querySelector(["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "))??e)}function tm(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=Fn(e);return k(ht,{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(Dn,{...t("file-tree-icon-chevron")}):k(Dn,{...t("file-tree-icon-file",u)})}),k("div",{"data-item-section":"content",children:e.isFlattened?Fp(e,l,o):l??k(Ec,{minimumLength:5,split:"extension",children:e.name})}),i?k("div",{"data-item-section":"decoration",children:r!=null?uu(r,t):null}):null,a?k("div",{"data-item-section":"git",children:uu(s,t)}):null,n?k("div",{"data-item-section":"action",children:d?k("span",{"aria-hidden":"true","data-item-action-affordance":"decorative",children:k(Dn,{...t("file-tree-icon-ellipsis")})}):null}):null]})}function xi(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:C,ignoredGitDirectories:S,ignoredInheritanceCache:y,directoriesWithGitChanges:I,gitLaneActive:x,contextMenuEnabled:T,contextMenuTriggerMode:O,contextMenuButtonTriggerEnabled:fe,contextMenuButtonVisibility:Q,contextMenuRightClickEnabled:pe,registerRenameInput:Z,registerButton:U,resolveIcon:B,renderDecorationForRow:ae,openContextMenuForRow:Se,onRowClick:z,onKeyDown:le}=e,Y=Fn(t),{isParked:ye=!1,mode:oe="flow",style:gt}=r,Be=oe==="sticky",at=C?.get(Y)??null??Wp(t.ancestorPaths,S,y),Et=t.kind==="directory"&&(I?.has(Y)??!1),Je=ae(t,Y),We=zp(at,Et),Ee=T&&fe,He=Je!=null||x||Ee,zt=Ee&&Q==="always",Ce=o.getPath()===Y,vt=Ce?o.getValue():"",je=Be||!Ce?null:k(Oc,{ref:Z,ariaLabel:`Rename ${as(t)}`,isFlattened:t.isFlattened,value:vt,onBlur:()=>{o.commit()},onInput:(be)=>{o.setValue(be.currentTarget.value)}}),Wt=tm(t,B,{actionLaneEnabled:Ee,customDecoration:Je,decorationLaneEnabled:He,dragTargetFlattenedSegmentPath:d?.flattenedSegmentPath??null,gitDecoration:We,gitLaneActive:x,renameInput:je,showDecorativeActionAffordance:zt}),et={...qc({ariaLabel:as(t),domId:t.isFocused?pu(g,Y,ye):void 0,extraStyle:gt,features:{actionLaneEnabled:Ee,contextMenuButtonVisibility:Ee?Q:null,contextMenuEnabled:T,contextMenuTriggerMode:T?O:null,gitLaneActive:x},isParked:ye,itemHeight:v,mode:oe,row:t,state:{containsGitChange:Et,effectiveGitStatus:at,isContextHovered:a===Y,isDragTarget:d?.kind==="directory"&&d.directoryPath===Y,isDragging:l?.has(Y)===!0,isFocusRinged:t.isFocused&&s===Y},targetPath:Y}),key:n,onContextMenu:T||u?(be)=>{if(f()){be.preventDefault();return}if(!T)return;if(be.preventDefault(),!pe)return;i.focusMountedPathFromInput(Y),Se(t,Y,{anchorRect:Yp(be.clientX,be.clientY),source:"right-click"})}:void 0,onFocus:!Be?()=>{i.focusMountedPathFromInput(Y)}:void 0,onKeyDown:!Be?le:void 0,ref:(be)=>{U(Y,be)}};if(!Be&&Ce)return k("div",{...et,children:Wt});return k("button",{...et,type:"button",draggable:u&&!ye,onDragEnd:u&&!ye?m:void 0,onDragStart:u&&!ye?(be)=>{c(be,t,Y)}:void 0,onMouseDown:(be)=>{if(Be){be.preventDefault();return}if(i.isSearchOpen())be.preventDefault()},onTouchStart:u&&!ye?(be)=>{p(be,t,Y)}:void 0,onClick:(be)=>{z(be,t,Y,oe)},children:Wt})}function nm(e,t,n){if(t.end<t.start)return[];return e.controller.getVisibleRows(t.start,t.end).filter((r)=>!n.has(Fn(r))).map((r,i)=>xi(e,r,t.start+i))}function ls({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:o,instanceId:s,itemHeight:a=ci,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 C=V(null),S=V(null),y=V(!1),I=V(null),x=V(null),T=V(null),O=V(null),fe=V(null),Q=V(new Map),pe=V(new Map),Z=V(()=>{}),U=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),Y=V(null),ye=V(!1),oe=V(null),gt=V(null),Be=V(null),at=V(null),Et=V(null),Je=V(null),We=V(null),Ee=V(null),He=V(!1),zt=V(null),Ce=V(null),vt=V(null),je=V(null),Wt=Ct(()=>new Map,[]),[,et]=ot(0),be=V(!1),[lt,tt]=ot(null),[hn,jt]=ot(null),[Tt,fn]=ot(null),[$e,De]=ot(null),[Oi,de]=ot(0),[K,pn]=ot(null),ct=V(K);ct.current=K;let Pt=V(null),$t=V(null),Ut=V(null),Kt=V(null),w=V(null),A=V(!1),H=()=>{$t.current=null,Ut.current=null,Kt.current=null},j=(h,b)=>{$t.current=h,Ut.current=null,Kt.current=b==null?null:{path:h,scrollTop:b}},yt=(h,b)=>{$t.current=null,Ut.current={path:h,viewportOffset:b},Kt.current=null},Gt=V(f==="retain"&&t.isSearchOpen()),[Xn,ks]=ot(m);is(()=>{if(!m)ks(!1)},[m]);let _s=V(!1),qi=Pe(()=>{_s.current=!0,ks((h)=>h?!1:h)},[]),[Bd,Hd]=ot(()=>ss({controller:t,itemHeight:a,overscan:l,scrollTop:0,stickyFolders:g,viewportHeight:v})),[Vd,Od]=ot(!1);is(()=>{Od(!0)},[]);let Ve=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,mn=e?.contextMenu?.triggerMode??(Ve?"right-click":"both"),gn=mn==="both"||mn==="button",Es=e?.contextMenu?.buttonVisibility??"when-needed",qd=mn==="both"||mn==="right-click";qe(()=>{let h=T.current;if(h==null)return;let b=(_)=>{if(!(_ instanceof CustomEvent))return;let P=_.detail?.path??null;w.current=P,jt(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 zd=Pe((h,b)=>{su(Q.current,h,b)},[]),Wd=Pe((h,b)=>{su(pe.current,h,b)},[]),jd=Pe((h)=>{x.current=h},[]),Qn=Pe((h)=>au(h,pe.current,Q.current),[]),Ts=n!=null||r!=null||i!=null,{resolveIcon:Ps}=Ct(()=>ac(o),[o]),Zn=t[Bo](),vn=Zn.getPath(),zi=vn!=null,ut=t.isSearchOpen(),$d=t.getSearchValue(),W=t.getFocusedPath(),ne=t.getFocusedIndex(),Yt=t.getScrollRequest(),bt=t.isDragAndDropEnabled(),Jn=t.getDragSession(),Ud=Ct(()=>Jn==null?null:new Set(Jn.draggedPaths),[Jn]),Kd=Jn?.target??null,er=Jn?.primaryPath??null,Rs=em(s),{overlayHeight:Gd,overlayRows:Yd,snapshot:xe,visibleRows:Dr}=Bd,Te=xe.physical.viewportHeight,nt=Ct(()=>({end:xe.window.endIndex,start:xe.window.startIndex}),[xe.window.endIndex,xe.window.startIndex]),tr=Yd,Ds=xe.sticky.rows,Xt=xe.physical.totalHeight,yn=xe.sticky.height,Mr=Ct(()=>new Set(Ds.map((h)=>Fn(h.row))),[Ds]),Wi=ne>=0&&ne>=nt.start&&ne<=nt.end,Xd=Pe((h,b)=>u?.({item:lu(h,b),row:h})??null,[u]),Ms=Pe((h)=>{if(rn(h==null?null:Q.current.get(h)??null))return!0;return rn(T.current)},[]),Ar=Pe((h)=>{Ms(t.focusNearestPath(h))},[t,Ms]),As=V(Ar);As.current=Ar;let bn=V(!0),ji=V(()=>{}),Ge=Pe((h=!0)=>{let b=ct.current;if(b==null)return;if(bn.current=bn.current&&h,pn(null),e?.contextMenu?.onClose?.(),bn.current)Ar(b.path)},[e?.contextMenu,Ar]);ji.current=Ge;let nr=Pe((h)=>{let b=h==null?null:Xp(T.current,h);fn((N)=>N===b?N:b)},[]),Ns=Pe((h,b,N)=>{let _=t.getItem(b);if(_==null)return;let P=Qn(b);if(P?.dataset.fileTreeStickyRow==="true"){let F=O.current;j(b,F?.scrollTop??null),z.current=!0,tt((ce)=>ce===b?ce:b)}_.focus(),nr(P),bn.current=!0,pn({anchorRect:N?.anchorRect??null,item:lu(h,b),path:b,source:N?.source??"keyboard"})},[t,Qn,nr]),Qd=Pe((h)=>{if(!d)return;if(t.isSearchOpen()){let b=O.current,N=Mn(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"),et((b)=>b+1)},[t,ne,a,d,Te]),Nr=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=Mn(_,Te),L=t.getVisibleCount()*a,J=N==="sticky-parents"?F.ancestorPaths.length*a:ss({controller:t,itemHeight:a,overscan:l,scrollTop:_.scrollTop,stickyFolders:g,viewportHeight:ce}).snapshot.sticky.height;return z.current=!0,An(_,P,a,ce,L,J),Z.current(),Pt.current=b?h:null,!0},[t,a,l,Te,g]),Zd=()=>y.current===!0||je.current!=null||He.current===!0,Ls=(h)=>typeof window.requestAnimationFrame==="function"?window.requestAnimationFrame(()=>{h()}):window.setTimeout(h,16),Jd=(h)=>{if(h==null)return;if(typeof window.cancelAnimationFrame==="function"){window.cancelAnimationFrame(h);return}window.clearTimeout(h)},Rt=()=>{if(at.current!=null)clearTimeout(at.current),at.current=null;Be.current=null},Lr=()=>{Je.current?.remove(),Je.current=null},rr=()=>{Jd(gt.current),gt.current=null,Et.current=null},Fs=(h)=>{let b=T.current?.getRootNode();if(b instanceof ShadowRoot){b.append(h);return}document.body.append(h)},ir=()=>{if(Ee.current?.(),Ee.current=null,je.current!=null)clearTimeout(je.current),je.current=null;if(He.current=!1,zt.current=null,vt.current=null,Ce.current!=null)Ce.current.setAttribute("draggable","true"),Ce.current.style.removeProperty("touch-action"),Ce.current=null;Lr(),Rt(),rr(),We.current=null},Fr=(h,b)=>{let N=T.current?.getRootNode(),_=nu(Hp(N instanceof ShadowRoot?N:document,h,b));return t.setDragTarget(_),t.getDragSession()?.target??null},$i=(h)=>{let b=t.getDragAndDropConfig()?.openOnDropDelay??800;if(h==null||h.kind!=="directory"||h.directoryPath==null||b<=0){Rt();return}let N=t.getItem(h.directoryPath),_=iu(N)?N:null;if(_==null||_.isExpanded()){Rt();return}let P=`${h.directoryPath}::${h.flattenedSegmentPath??""}`;if(Be.current===P)return;Rt(),Be.current=P,at.current=setTimeout(()=>{let F=t.getDragSession()?.target;if(F?.kind!=="directory"||F.directoryPath!==h.directoryPath||F.flattenedSegmentPath!==h.flattenedSegmentPath)return;_.expand()},b)},Bs=()=>{gt.current=null;let h=Et.current,b=O.current;if(h==null||b==null||t.getDragSession()==null)return;let N=b.getBoundingClientRect(),_=qp(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,Z.current();$i(Fr(h.clientX,h.clientY)),gt.current=Ls(Bs)},Hs=(h,b)=>{Et.current={clientX:h,clientY:b},gt.current??=Ls(Bs)},eh=(h,b,N)=>{let _=h.currentTarget;if(_==null)return;if(ir(),Lr(),Rt(),rr(),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),Op()){let P=ru(_),F=_.getBoundingClientRect();Object.assign(P.style,{height:`${F.height}px`,opacity:"0.85",transform:"translate3d(-9999px, 0px, 0)",width:`${F.width}px`}),Fs(P),Je.current=P,h.dataTransfer.setDragImage(P,Math.max(0,h.clientX-F.left),Math.max(0,h.clientY-F.top))}}},th=()=>{Lr(),Rt(),rr(),We.current=null,t.cancelDrag()},nh=(h,b,N)=>{if(je.current!=null||He.current)return;let _=h.touches[0],P=h.currentTarget;if(_==null||P==null)return;vt.current={clientX:_.clientX,clientY:_.clientY},Ce.current=P,P.setAttribute("draggable","false");let F=(J={})=>{let se=J.restoreNativeDraggable??!He.current;if(je.current!=null)clearTimeout(je.current),je.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;vt.current=null}},ce=(J)=>{let se=J.touches[0],re=vt.current;if(se==null||re==null)return;let he=se.clientX-re.clientX,Re=se.clientY-re.clientY;if(he*he+Re*Re<=eu*eu)return;F()},L=()=>{F()};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),Ee.current=F,je.current=setTimeout(()=>{if(F({restoreNativeDraggable:!1}),t.startDrag(N)===!1){if(P.setAttribute("draggable","true"),Ce.current===P)Ce.current=null;vt.current=null;return}He.current=!0,Ce.current=P,P.setAttribute("draggable","false"),P.style.setProperty("touch-action","none"),We.current=b;let J=P.getBoundingClientRect(),se=ru(P);Object.assign(se.style,{height:`${J.height}px`,opacity:"0.85",transform:`translate3d(${J.left}px, ${J.top}px, 0)`,width:`${J.width}px`}),Fs(se),Je.current=se,zt.current={x:_.clientX-J.left,y:_.clientY-J.top};let re=(rt)=>{let Ie=rt.touches[0];if(Ie==null)return;rt.preventDefault();let X=zt.current;if(X!=null&&Je.current!=null)Je.current.style.transform=`translate3d(${Ie.clientX-X.x}px, ${Ie.clientY-X.y}px, 0)`;$i(Fr(Ie.clientX,Ie.clientY)),Hs(Ie.clientX,Ie.clientY)},he=(rt)=>{let Ie=rt.changedTouches[0];if(Ie!=null)Fr(Ie.clientX,Ie.clientY);t.completeDrag(),ir()},Re=()=>{t.cancelDrag(),ir()};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)},Bp)},Vs=(h)=>{if(K!=null){if(h.key==="Escape"){Ge(),h.preventDefault(),h.stopPropagation();return}if(Kp.has(h.key))h.preventDefault(),h.stopPropagation();return}if(Zn.isActive()){if(h.isComposing||h.keyCode===229)return;if(h.key==="Escape")Zn.cancel();else if(h.key==="Enter")Zn.commit();else return;De("focus"),et((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(d&&h.key==="F2"){Qd(W??void 0),h.preventDefault(),h.stopPropagation();return}if(ut){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 dt=O.current,qr=Mn(dt,Te);oe.current=ne<0||dt==null?null:Math.max(0,Math.min(ne*a-dt.scrollTop,Math.max(0,qr-a))),ye.current=!0,t.closeSearch()}else if(h.key==="ArrowDown")t.focusNextSearchMatch();else if(h.key==="ArrowUp")t.focusPreviousSearchMatch();else return;De("focus"),et((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}if(c&&jp(h)){t.openSearch(h.key),et((ge)=>ge+1),h.preventDefault(),h.stopPropagation();return}let b=Ve&&fu(h),N=Up(h,Ve),_=N&&T.current!=null?Cr(T.current):null,P=N?new Set(Qp(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(),J=t.getFocusedIndex(),se=t.getFocusedItem();if(se==null)return;let re=iu(se)?se:null,he=L!=null&&(Mr.has(L)||ce&&F===L&&P.has(L)),Re=h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="ArrowRight"&&re!=null&&re.isExpanded(),rt=h.key==="ArrowLeft"&&he&&re!=null&&re.isExpanded(),Ie=O.current,X=!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&&J>=0){let ge=t.getVisibleRows(J,J)[0]??null,dt=au(L,pe.current,Q.current);if(ge==null||dt==null)X=!1;else Ns(ge,L)}else if((h.ctrlKey||h.metaKey)&&hu(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:X=!1}if(!X)return;De("focus");let me=t.getFocusedPath(),Me=me!=null&&(Mr.has(me)||P.has(me)),Vr=Re&&me!==L,Or=b&&ce&&F===L&&me===L;if((he||Or)&&me!=null&&(Vr&&Me||Or))j(me,Ie?.scrollTop??null),z.current=!0,tt((ge)=>ge===me?ge:me);else{let ge=h.key==="ArrowUp"&&he&&me!==L;if(me!=null&&(ge||rt&&me===L))yt(me,Jp(T.current,Ie,_,L,a,yn,Te)),z.current=!0,tt((dt)=>dt===me?dt:me);else H()}et((ge)=>ge+1),h.preventDefault(),h.stopPropagation()};qe(()=>{if(!c||!ut)return;if(Gt.current){Gt.current=!1;return}rn(fe.current)},[ut,c]),qe(()=>{let h=x.current;switch(Vc({hasRenderedInput:h!=null,previousRenamingPath:Y.current,renamingPath:vn})){case"reset":Y.current=null;return;case"reveal-canonical":if(vn!=null)Nr(vn,{restoreTreeFocus:!1,targetOffset:"live-overlay"});return;case"ignore":return;case"focus-input":if(h!=null)Pt.current=null,Y.current=vn,rn(h),h.select();return}},[nt.end,nt.start,vn,Nr,Mr]),qe(()=>{let h=T.current;if(h==null)return;let b=null,N=()=>{if(b==null)return;clearTimeout(b),b=null},_=()=>{let ce=Cr(h)?.dataset.itemPath??null;tt((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,Cr(h)!=null){_();return}z.current=!1,tt(null)},0);return}if(!(L instanceof Node)||!h.contains(L)){N(),z.current=!1,tt(null);return}let J=L instanceof HTMLElement?L.dataset.itemPath??null:null;tt((se)=>se===J?se:J)};return h.addEventListener("focusin",P),h.addEventListener("focusout",F),()=>{N(),h.removeEventListener("focusin",P),h.removeEventListener("focusout",F)}},[]),qe(()=>{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]),qe(()=>{let h=null,b=O.current,N=I.current,_=T.current;if(b==null)return;U.current=Mn(b,v);let P=()=>{let X=t.getVisibleCount(),me=Zo(U.current,v),Me=Math.max(0,X*a-me);if(b.scrollTop>Me)b.scrollTop=Me;Hd(ss({controller:t,itemHeight:a,overscan:l,scrollTop:Math.min(b.scrollTop,Me),stickyFolders:g,viewportHeight:me}))};if(!ae.current){ae.current=!0;let X=t.getFocusedIndex();if(X>=0){let me=Zo(U.current,v),Me=t.getVisibleRows(X,X)[0]??null;Jo(b,X,a,me,g&&Me!=null?Math.max(0,Math.min(Me.ancestorPaths.length*a,Math.max(0,me-a))):0)}}Z.current=P;let F=t.subscribe(()=>{if(Nc(be))et((X)=>X+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((X)=>X+1),h=null},50)},L=null,J=()=>{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(()=>{J()},200)},re=()=>{if(P(),b.scrollTop>0)J();if(ct.current!=null&&y.current)ji.current();if(A.current===!0){y.current=!1;return}jt((X)=>X==null?X:null),ce()},he=()=>{ce(),se()},Re=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," ","Spacebar"]),rt=(X)=>{if(!Re.has(X.key))return;he()};b.addEventListener("scroll",re,{passive:!0}),b.addEventListener("wheel",he,{passive:!0}),b.addEventListener("touchmove",he,{passive:!0}),b.addEventListener("keydown",rt);let Ie=typeof ResizeObserver<"u"?new ResizeObserver((X)=>{U.current=(X[0]==null?null:Bc(X[0]))??Mn(b,v),P()}):null;return Ie?.observe(b),()=>{if(Z.current=()=>{},F(),b.removeEventListener("scroll",re),b.removeEventListener("wheel",he),b.removeEventListener("touchmove",he),b.removeEventListener("keydown",rt),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,U.current=null,Ie?.disconnect()}},[t,v,a,l,g]),qe(()=>{if(Ve||K==null)return;Ge(!1)},[Ge,Ve,K]);let Os=Ct(()=>K==null?null:`${K.path}::${K.source}`,[K]);qe(()=>{if(Os==null){p?.clearSlotContent(yr);return}let h=ct.current;if(h==null)return;let b=S.current??C.current;if(b==null)return;let N={anchorElement:b,anchorRect:h.anchorRect??Gp(b.getBoundingClientRect()),close:(P)=>{ji.current(P?.restoreFocus??!0)},restoreFocus:()=>{if(!bn.current)return;As.current(ct.current?.path??null)}},_=e?.contextMenu?.render?.(h.item,N)??null;return p?.setSlotContent(yr,_),e?.contextMenu?.onOpen?.(h.item,N),du(_),queueMicrotask(()=>{if(_==null||!_.isConnected)return;if(document.activeElement!==_)return;du(_)}),()=>{p?.clearSlotContent(yr)}},[Os,e?.contextMenu,p]),qe(()=>{if(K!=null&&t.getItem(K.path)==null)Ge()},[Ge,K,t]),qe(()=>{if(K==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(ou(P))return;if(C.current?.contains(F)===!0)return;if(b?.contains(F)===!0)return;Ge()},_=(P)=>{if(P.key==="Escape")P.preventDefault(),P.stopPropagation(),Ge()};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",_,!0)}},[Ge,K]),qe(()=>{let h=O.current,b=T.current;if(h==null||b==null){le.current=W;return}let N=W==null?null:Q.current.get(W)??null,_=Cr(b),P=_?.dataset.itemPath??null,F=zi&&x.current===_,ce=c&&fe.current===_,L=ye.current&&!ut,J=oe.current??0,se=Pt.current,re=$t.current,he=Ut.current,Re=Kt.current,rt=_!=null,Ie=z.current||rt,X=le.current!==W,me=re!=null&&re===W&&W!=null,Me=!1,Vr=!1;if(Yt!=null&&Yt.id!==B.current){B.current=Yt.id;let Ki=Yt.visibleIndex,$s=t.getVisibleRows(Ki,Ki)[0]??null;if($s!=null){let Th=g?Math.max(0,Math.min($s.ancestorPaths.length*a,Math.max(0,Te-a))):yn;Me=!0,Vr=Hc(h,Ki,a,Te,Xt,Yt.offset,Th)}t.clearScrollRequest(Yt.id)}let Or=!Me&&L&&An(h,ne,a,Te,Xt,J),ge=!Me&&se!=null&&se===W&&An(h,ne,a,Te,Xt,yn),dt=!Me&&he!=null&&he.path===W&&An(h,ne,a,Te,Xt,he.viewportOffset),qr=!Me&&Re!=null&&Re.path===W&&h.scrollTop!==Re.scrollTop;if(qr)h.scrollTop=Re.scrollTop;if(qr||Vr||ge||dt||Or||Ie&&X&&se!==W&&!me&&Jo(h,ne,a,Te,yn))Z.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)An(h,ne,a,Te,Xt,J),Z.current();le.current=W;return}if(X||L||se===W||re===W||he?.path===W||Re?.path===W||P==null||P!==W){if(rn(N),se===W)Pt.current=null;if(re===W)$t.current=null;if(he?.path===W)Ut.current=null;if(Re?.path===W)Kt.current=null;ye.current=!1,oe.current=null}le.current=W},[t,ne,W,Wi,a,zi,ut,nt,Te,c,Yt,g,yn,Xt,Dr]);let rh=ne>=0&&ne>=xe.visible.startIndex&&ne<=xe.visible.endIndex,ih=W!=null&&tr.some((h)=>Fn(h.row)===W),oh=rh||ih,sh=gn&&z.current===!0&&oh?W:null,ah=$e==="pointer"?hn:null,Qt=K?.path??w.current??ah??sh??hn,qs=K?.source==="right-click";qe(()=>{if(y.current&&K==null)return;nr(Qn(Qt))},[K,Qn,nt,Te,Oi,tr,Qt,nr,Dr]);let lh=Pe((h)=>{if(y.current)return;if(ou(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");jt((F)=>F===P?F:P)},[]),ch=Pe(()=>{jt(null)},[]);qe(()=>{if(!bt)return;let h=()=>{ir(),t.cancelDrag()};return window.addEventListener("dragend",h),()=>{window.removeEventListener("dragend",h),ir(),t.cancelDrag()}},[t,bt]);let uh=(h)=>{if(!bt||t.getDragSession()==null||He.current)return;let b=nu(h.target instanceof HTMLElement?h.target:null);if(t.setDragTarget(b),$i(t.getDragSession()?.target??null),Hs(h.clientX,h.clientY),h.dataTransfer!=null)h.dataTransfer.dropEffect="move";h.preventDefault()},dh=(h)=>{if(!bt||t.getDragSession()==null||He.current)return;let b=h.relatedTarget;if(b instanceof Node&&T.current?.contains(b)===!0)return;Rt(),rr(),t.setDragTarget(null)},hh=(h)=>{if(!bt||t.getDragSession()==null||He.current)return;h.preventDefault(),Fr(h.clientX,h.clientY),t.completeDrag(),Lr(),Rt(),rr(),We.current=null},or=xe.window.height,fh=xe.window.offsetTop,ph=Math.min(0,Te-or),mh=Math.min(0,Te-or-yn),gh=lt===W||ye.current,wn=W!=null&&gh&&!Wi&&ne>=0?Dr[ne]??t.getVisibleRows(ne,ne)[0]??null:null,zs=wn==null?null:es(ne,a,nt,or),Dt=We.current,vh=er!=null&&Dt!=null&&Dt.path===er&&Dt.index>=nt.start&&Dt.index<=nt.end,sr=er!=null&&Dt!=null&&Dt.path===er&&!vh&&Dt.path!==wn?.path?Dt:null,Ws=sr==null?null:es(sr.index,a,nt,or),yh=$p((ne>=0?Dr[ne]??t.getVisibleRows(ne,ne)[0]??null:null)?.ancestorPaths.at(-1)??null),bh=ut&&W!=null?pu(s,W,!Wi):void 0,wh=K?.path??(ut?W:lt),Ih=K?.path??hn,ar=Qn(Qt),Ui=Ve&&gn&&!qs&&!zi&&ar!=null&&Tt!=null&&Qt!=null,Sh=Ve&&(Ui||K!=null),Br=K?.anchorRect,js=Br==null&&ar!=null&&Tt!=null&&(K!=null||Ui)?Tt:null,Ch=Br!=null?{left:`${Br.left}px`,position:"fixed",right:"auto",top:`${Br.top}px`}:js!=null?{top:`${js}px`}:void 0,xh=qs?{opacity:"0"}:void 0,kh=Pe((h,b,N,_)=>{let P=zc({event:{ctrlKey:h.ctrlKey,metaKey:h.metaKey,shiftKey:h.shiftKey},isDirectory:b.kind==="directory",isSearchOpen:ut,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 J=h.currentTarget instanceof HTMLElement?h.currentTarget:null,se=b.index>=xe.visible.startIndex&&b.index<=xe.visible.endIndex,re=_==="flow"&&se&&J!=null&&J.dataset.itemParked!=="true";if(t.focusMountedPathFromInput(L),re)z.current=!0,tt((he)=>he===L?he:L),De("focus");if(F)t.toggleMountedDirectoryFromInput(L);if(P.closeSearch)t.closeSearch();if(P.revealCanonical)Nr(L,{targetOffset:"sticky-parents"})},[t,ut,xe.visible.endIndex,xe.visible.startIndex,Nr]),_h=()=>{if(y.current)return;if(!gn)return;if(Qt==null||ar==null)return;let h=t.getItem(Qt);if(h==null)return;nr(ar),bn.current=!0,pn({anchorRect:null,item:{kind:h.isDirectory()?"directory":"file",name:ar.getAttribute("aria-label")??Qt,path:h.getPath()},path:h.getPath(),source:"button"})},Hr={contextHoverPath:Ih,contextMenuButtonTriggerEnabled:gn,contextMenuButtonVisibility:Es,contextMenuEnabled:Ve,contextMenuRightClickEnabled:qd,contextMenuTriggerMode:mn,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:bt,draggedPathSet:Ud,dragTarget:Kd,gitLaneActive:Ts,gitStatusByPath:n,handleRowDragEnd:th,handleRowDragStart:eh,handleRowTouchStart:nh,ignoredGitDirectories:r,ignoredInheritanceCache:Wt,instanceId:s,itemHeight:a,onKeyDown:Vs,onRowClick:kh,openContextMenuForRow:Ns,registerButton:zd,registerRenameInput:jd,renameView:Zn,renderDecorationForRow:Xd,resolveIcon:Ps,shouldSuppressContextMenu:Zd,visualFocusPath:wh},Eh={...Hr,registerButton:Wd};return k("div",{ref:T,id:Rs,"data-file-tree-context-menu-button-visibility":Ve&&gn?Es:void 0,"data-file-tree-context-menu-trigger-mode":Ve?mn:void 0,"data-file-tree-has-context-menu-action-lane":Ve&&gn?"true":void 0,"data-file-tree-has-git-lane":Ts?"true":void 0,"data-file-tree-virtualized-root":"true",onDragLeave:bt?dh:void 0,onDragOver:bt?uh:void 0,onDrop:bt?hh:void 0,onKeyDown:Vs,onPointerLeave:Ve?ch:void 0,onPointerOver:Ve?lh:void 0,role:"tree",tabIndex:-1,style:{outline:"none",position:"relative"},children:[k("style",{"data-file-tree-guide-style":"true",dangerouslySetInnerHTML:{__html:yh}}),k("slot",{name:vr,"data-type":"header-slot"}),c?k("div",{"data-file-tree-search-container":!0,"data-open":ut?"true":"false",children:k("input",{ref:fe,"aria-activedescendant":bh,"aria-controls":Rs,placeholder:"Search…","data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Xn?"true":void 0,value:$d,onBlur:()=>{if(f==="retain"&&!_s.current)return;t.closeSearch()},onFocus:qi,onPointerDown:qi,onInput:(h)=>{qi();let b=h.currentTarget;t.setSearch(b.value)}})}):null,k("div",{ref:O,"data-file-tree-virtualized-scroll":"true",children:[g&&Vd&&tr.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:`${Gd}px`},children:tr.map((h,b)=>xi(Eh,h.row,`sticky:${Fn(h.row)}`,{mode:"sticky",style:{left:"0",position:"absolute",right:"0",top:`${h.top}px`,zIndex:`${tr.length-b}`}}))})}):null,k("div",{ref:I,"data-file-tree-virtualized-list":"true",style:{height:`${Xt}px`},children:[k("div",{"data-file-tree-virtualized-sticky-offset":"true","aria-hidden":"true",style:{height:`${fh}px`}}),k("div",{"data-file-tree-virtualized-sticky":"true",style:{height:`${or}px`,top:`${ph}px`,bottom:`${mh}px`},children:[nm(Hr,nt,Mr),wn!=null&&zs!=null?xi(Hr,wn,`parked:${wn.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:er===wn.path?"none":void 0,position:"absolute",right:"0",top:`${zs}px`}}):null,sr!=null&&Ws!=null?xi(Hr,sr,`parked-drag:${sr.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:"none",position:"absolute",right:"0",top:`${Ws}px`}}):null]})]})]}),Ve?k("div",{ref:C,"data-type":"context-menu-anchor","data-visible":Sh?"true":"false",style:Ch,children:[k("button",{ref:S,type:"button","data-type":Vl,"aria-label":"Options","aria-haspopup":"menu","aria-expanded":K!=null?"true":"false","data-visible":Ui?"true":"false",onMouseDown:(h)=>{h.preventDefault()},onClick:(h)=>{if(h.preventDefault(),h.stopPropagation(),K!=null){Ge();return}_h()},tabIndex:-1,style:xh,children:k(Dn,{...Ps("file-tree-icon-ellipsis")})}),K!=null?k("slot",{name:yr}):null]}):null,K!=null?k("div",{"data-type":"context-menu-wash","aria-hidden":"true",onMouseDownCapture:(h)=>{h.preventDefault(),Ge()},onTouchStartCapture:(h)=>{h.preventDefault(),h.stopPropagation(),Ge()},onTouchMoveCapture:(h)=>{h.preventDefault(),h.stopPropagation()},onWheelCapture:(h)=>{h.preventDefault(),h.stopPropagation()}}):null]})}var cs={hydrateRoot:(e,t)=>{Sc(Rn(ls,t),e)},renderRoot:(e,t)=>{Ii(Rn(ls,t),e)},unmountRoot:(e)=>{Ii(null,e)}};function Bn(e,t){cs.renderRoot(e,t)}function mu(e,t){cs.hydrateRoot(e,t)}function gu(e){cs.unmountRoot(e)}var vu=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 yu=0;function rm(e){if(e!=null&&e.length>0)return e;return yu+=1,`pst_ft_${yu}`}function im({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??ci)}function bu(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 wu(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 Iu(e){return Array.from(e.children).filter((t)=>t instanceof SVGElement)}var kr=class{static LoadedCustomComponent=!0;#e;#t;#c;#u;#a;#V;#O;#v;#r;#y=new vu;#T;#b;#m;#h;#w;#I;#f;#q;#z;#N=null;#i;#W=!1;#j=!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:C,unsafeCSS:S,initialVisibleRowCount:y,...I}=e;this.#e=t,this.#c=rm(o),this.#h=Ho(i),this.#w=a,this.#I=S,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=Ol(n,l),this.#b={itemHeight:this.#T.itemHeight,overscan:f,stickyFolders:C,initialVisibleRowCount:y},this.#t=new Jl({...I,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)gu(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=rc(this.#h,e);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Bn(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(),Bn(t.wrapper,this.#P())}setGitStatus(e){let t=Ho(e,this.#h);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Bn(n.wrapper,this.#P())}setIcons(e){this.#w=e;let t=this.#s();if(t==null)return;this.#g(t.host,t.wrapper),Bn(t.wrapper,this.#P())}hydrate({fileTreeContainer:e}){let t=this.#M(e),n=this.#L(t);this.#k(),mu(n,this.#P())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#M(t??this.#m,e),r=this.#L(n);this.#k(),Bn(r,this.#P())}#Z(){return{initialViewportHeight:im({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.#$(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(vr,e());return}this.#y.setSlotHtml(vr,this.#e?.header?.html??null)}#$(e){let t=Iu(e).find((r)=>wu(r)),n=bu(Al(En(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=Iu(e),n=t.find((s)=>wu(s)),r=t.filter((s)=>s!==n),i=En(this.#w).spriteSheet?.trim()??"";if(i.length===0){for(let s of r)s.remove();return}let o=bu(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=En(this.#w);if(t.colored&&Ll(t.set))e.dataset.fileTreeColoredIcons="true";else delete e.dataset.fileTreeColoredIcons}#l(e){let t=e.querySelector(`style[${_o}]`);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(_o,""),this.#f.parentNode!==e)e.appendChild(this.#f);this.#f.textContent=ql(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 hi(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.#j=!0}#F(e){if(this.#W)e.style.removeProperty("--trees-item-height"),this.#W=!1;if(this.#j)e.style.removeProperty("--trees-density-override"),this.#j=!1}};var Su=["--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("; "),us=`
|
|
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
|
-
`,Cu={density:"compact",fileTreeSearchMode:"hide-non-matches",flattenEmptyDirectories:!0,id:"review-file-tree",initialExpansion:"open",initialVisibleRowCount:20,search:!0,searchBlurBehavior:"retain",stickyFolders:!1,unsafeCSS:us};var Hn=50;var
|
|
1288
|
+
`,Cu={density:"compact",fileTreeSearchMode:"hide-non-matches",flattenEmptyDirectories:!0,id:"review-file-tree",initialExpansion:"open",initialVisibleRowCount:20,search:!0,searchBlurBehavior:"retain",stickyFolders:!1,unsafeCSS:us};var Hn=50;var om=0.35,sm=0.65;var am=224,lm=480;var cm=0.3,um=0.7;function ku(e){if(!sn(e))return{};return{changesRatio:ds(e.changesRatio,cm,um),gitPaneRatio:ds(e.gitPaneRatio,om,sm),layout:e.layout==="split"||e.layout==="unified"?e.layout:void 0,mode:e.mode==="all"||e.mode==="selected"?e.mode:void 0,reviewSidebarWidth:ds(e.reviewSidebarWidth,am,lm),tab:e.tab==="files"||e.tab==="git"?e.tab:void 0,wrap:xu(e.wrap)?e.wrap:void 0}}function ds(e,t,n){return on(e)&&Number.isFinite(e)?Math.min(Math.max(e,t),n):void 0}var dm={branch:null,changes:[],commits:[],isGitRepository:!1,patch:"",revision:"non-git"},Fy={...dm,revision:"git-unloaded"},_u=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")])})),hs=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()})),hm=M.ReadonlyObject(M.Object({changes:M.ReadonlyObject(M.Array(_u)),commit:hs,patch:M.String()})),fm=M.ReadonlyObject(M.Object({branch:M.Union([M.String(),M.Null()]),changes:M.ReadonlyObject(M.Array(_u)),commits:M.ReadonlyObject(M.Array(hs)),isGitRepository:M.Boolean(),patch:M.String(),revision:M.String()})),pm=ki(hm),mm=ki(M.Array(hs)),gm=ki(fm);function Eu(e){return pm.Check(e)}function Tu(e){return mm.Check(e)}function fs(e){return gm.Check(e)}var Pu=M.Object({path:M.String(),contents:M.String(),revision:M.String(),size:M.Number()}),vm=M.Union([Pu,M.Object({message:M.String(),path:M.String(),size:M.Number()})]),ym=M.Object({paths:M.Array(M.String()),workspacePath:M.String()}),ps=M.Object({path:M.String()}),bm=M.Object({error:M.String()});function Ru(e){let t=`${e}/content`,n=`${e}/entry`;return{async create(r,i){return(await Vn(n,ps,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:i,path:r})})).path},async list(){return await Vn(e,ym)},async move(r,i){return(await Vn(n,ps,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({destination:i,path:r})})).path},async read(r){return await Vn(`${t}?path=${encodeURIComponent(r)}`,vm)},async remove(r){await Vn(n,ps,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({path:r})})},async save(r,i,o){return await Vn(t,Pu,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({contents:i,path:r,revision:o})})}}}async function Vn(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=ms(bm,await r.json()).error}catch{}throw Error(i)}return ms(t,await r.json())}function Du(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 _i(e,t,n){if(!t){e.resetPaths(n);return}if(t.length===n.length&&t.every((s,a)=>s===n[a]))return;let r=Du(t),i=Du(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 Fu(e){let t=Ru(e.endpoint),n=st("workspace-file-tree"),r=st("workspace-file-main"),i=st("workspace-file-view"),o=st("workspace-file-empty"),s=st("workspace-file-path"),a=st("workspace-file-status"),l=qn("workspace-file-edit"),d=qn("workspace-file-download"),u=qn("workspace-file-wrap"),f=Nu("workspace-entry-dialog"),c=st("workspace-entry-title"),m=st("workspace-entry-description"),p=Sm("workspace-entry-input"),g=st("workspace-entry-error"),v=qn("workspace-entry-action"),C=Nu("workspace-confirm-dialog"),S=st("workspace-confirm-title"),y=st("workspace-confirm-description"),I=qn("workspace-confirm-cancel"),x=qn("workspace-confirm-action");n.style.cssText=Su;let T=e.initialWorkspacePath,O=[],fe,Q=!1,pe=!1,Z=0,U=0,B,ae,Se="",z=!1,le=!0,Y,ye=new Lu(He()),oe=new kr({composition:{contextMenu:{enabled:!0,render:gt,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:us,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}tt(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 jt()),i.addEventListener("keydown",(w)=>{if((w.ctrlKey||w.metaKey)&&!w.altKey&&!w.shiftKey&&w.code==="KeyS")w.preventDefault(),jt()}),u.addEventListener("click",()=>{le=!le,u.setAttribute("aria-pressed",String(le)),ye.setOptions(He())}),window.addEventListener("pi-ui-code-theme-changed",()=>{ye.setOptions(He()),ye.rerender()});function gt(w,A){let H=document.createElement("div");return H.className="workspace-tree-context-menu",H.setAttribute("role","menu"),H.append(Be("New file",()=>{A.close({restoreFocus:!1}),at(w,"file")}),Be("New folder",()=>{A.close({restoreFocus:!1}),at(w,"folder")}),Be("Rename",()=>{A.close({restoreFocus:!1}),Et(w)}),Be("Delete",()=>{A.close({restoreFocus:!1}),Je(w)},!0)),H}function Be(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 at(w,A){let H=await K({title:`New ${A}`,description:`Enter a name for the new ${A}.`,action:"Create"});if(!H)return;let j=w.kind==="directory"?w.path:Mu(w.path),yt=Au(j,H);try{let Gt=await t.create(yt,A);if(await lt(!0),A==="file")await Ce(Gt);else{let Xn=oe.getItem(Gt);if(Xn&&"expand"in Xn)Xn.expand()}}catch(Gt){de(Ot(Gt))}}async function Et(w){if(Ee(w.path)&&z){await Pt("Unsaved changes","Save or discard your changes before renaming this item.");return}let A=await K({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=Au(Mu(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 lt(!0),j)await Ce(j)}catch(yt){de(Ot(yt))}}async function Je(w){if(Ee(w.path)&&z){await Pt("Unsaved changes","Save or discard your changes before deleting this item.");return}let A=w.kind==="directory"?"folder":"file";if(!await ct({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 lt(!0)}catch(H){de(Ot(H))}}function We(){U+=1,Tt(),B=void 0,Se="",z=!1,fn(),s.textContent="Select a file",de(""),De("Open a file from the workspace"),$e()}function Ee(w){return B?.path===w||B?.path.startsWith(`${w}/`)===!0}function He(){return{disableFileHeader:!0,overflow:le?"wrap":"scroll",theme:_r(),themeType:"system",onEditChange({file:w}){Se=w.contents,z=Se!==B?.contents,$e()},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 ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,e
|
|
|
1299
1299
|
[data-file] {
|
|
1300
1300
|
min-width: 100%;
|
|
1301
1301
|
}
|
|
1302
|
-
`}}function zt(w){if(pe=w,pe)lt()}async function Ce(w){pe=!0,await lt();for(let H of oe.getSelectedPaths())oe.getItem(H)?.deselect();let A=oe.getItem(w);if(A)A.select();else await tt(w)}function vt(w=!0){Wt(w)}function je(w){if(B?.path===w)z=!1,$e();Wt()}async function Wt(w=!0){let A=B,H=U;if(await lt(w),!A||B!==A||U!==H)return;try{let j=await t.read(A.path);if(B!==A||U!==H)return;if("message"in j){if(z)de("File changed on disk");else We(),fn(j.path),s.textContent=j.path,de(On(j.size)),De(j.message);return}if(j.revision===A.revision)return;if(z){de("File changed on disk");return}let yt=++U;Tt(),B=j,Se=j.contents,ye.render({file:{cacheKey:`${T}:${j.path}:${j.revision}`,contents:j.contents,name:j.path},containerWrapper:i}),de(On(j.size)),$e(),await hn(yt)}catch(j){if(B!==A||U!==H)return;de(Ot(j))}}function et(w){oe.setGitStatus(w)}function be(w){if(T===w)return;if(T=w,O=[],fe=void 0,Z+=1,We(),oe.resetPaths([]),pe)lt()}async function lt(w=!1){if(w)Q=!0;let A=++Z;if(!pe||!Q&&fe===T)return;if(!w)de("Loading files…");try{let H=await t.list();if(A!==Z||H.workspacePath!==T)return;if(_i(oe,fe===T?O:void 0,H.paths),fe=T,O=H.paths,Q=!1,ae){if(B)de(On(B.size));return}let j=H.paths.includes("README.md")?"README.md":H.paths.find((yt)=>!yt.endsWith("/"));if(j)oe.getItem(j)?.select();else de(""),De("No files in this workspace")}catch(H){if(A!==Z)return;de(Ot(H)),De("Could not load workspace files")}}async function tt(w){if(B?.path===w)return;if(z&&!await ct({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=++U;Tt(),z=!1,s.textContent=w,fn(),de("");try{let H=await t.read(w);if(A!==U)return;if(fn(H.path),de(On(H.size)),"message"in H){B=void 0,De(H.message),$e();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}),Oi(),de(On(H.size)),$e(),await hn(A)}catch(H){if(A!==U)return;B=void 0,de(""),De(Ot(H)),$e()}}async function hn(w){l.disabled=!0;try{let{Editor:A}=await import("./index-wmew1h99.js");if(w!==U||!B)return;Y=new A("file"),Y.edit(ye)}catch(A){Y=void 0,de(Ot(A))}finally{$e()}}async function jt(){if(!B||!Y||!z)return;l.disabled=!0,de("Saving…");try{B=await t.save(B.path,Se,B.revision),Se=B.contents,z=!1,de(On(B.size))}catch(w){de(Ot(w))}finally{$e()}}function Tt(){Y?.cleanUp("discard"),Y=void 0,$e()}function fn(w){ae=w,d.disabled=!w}function $e(){l.disabled=!B||!Y||!z}function De(w){o.textContent=w,o.style.display="grid",i.style.display="none"}function Oi(){o.style.display="none",i.style.display="block"}function de(w){a.textContent=w}function K(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 pn(){if(!wm(p.value)){g.textContent="Use a non-empty name without slashes, '.', or '..'.",g.hidden=!1;return}f.close("submit")}function ct(w){return S.textContent=w.title,y.textContent=w.description,x.textContent=w.action,I.hidden=w.showCancel===!1,x.dataset.variant=w.destructive===!1?"default":"destructive",C.returnValue="",new Promise((A)=>{C.addEventListener("close",()=>A(C.returnValue==="confirm"),{once:!0}),C.showModal()})}async function Pt(w,A){await ct({title:w,description:A,action:"OK",showCancel:!1,destructive:!1})}v.addEventListener("click",pn),p.addEventListener("keydown",(w)=>{if(w.key!=="Enter"||w.isComposing)return;w.preventDefault(),pn()});function $t(){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 Ut(){(B?i:r).focus({preventScroll:!0})}function Kt(){Tt(),ye.cleanUp(),oe.cleanUp()}return $e(),De("Open a file from the workspace"),{cleanUp:Kt,focusEditor:Ut,focusTree:$t,openFile:Ce,refresh:vt,refreshAfterDiscard:je,requestConfirmation:ct,requestNotice:Pt,setGitStatus:et,setVisible:zt,setWorkspace:be}}function Ot(e){return String(e).replace(/^Error: /,"")}function wm(e){return Boolean(e&&e===e.trim()&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\"))}function Du(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Mu(e,t){return e?`${e}/${t}`:t}function On(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(1)} MB`}function st(e){let t=document.getElementById(e);if(!(t instanceof HTMLElement))throw Error(`Missing #${e}`);return t}function qn(e){let t=document.getElementById(e);if(!(t instanceof HTMLButtonElement))throw Error(`Missing #${e}`);return t}function Au(e){let t=document.getElementById(e);if(!(t instanceof HTMLDialogElement))throw Error(`Missing #${e}`);return t}function Im(e){let t=document.getElementById(e);if(!(t instanceof HTMLInputElement))throw Error(`Missing #${e}`);return t}function Fu(e){return{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(sn(i)&&Er(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 Eu(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 Tu(r)?r:void 0}catch{return}}}}var Ei=globalThis.navigator?.platform??globalThis.process?.platform,Bu=Ei==="win32"||Ei?.startsWith("Win")?"windows":Ei==="darwin"||Ei?.startsWith("Mac")?"darwin":"linux";function Hu(e,t=Bu){return t==="darwin"?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Vu(){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:Sm(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){let c=[];for(let m of e.keys()){if(f.get(m)===t.get(m))continue;e.delete(m),t.delete(m),c.push(m)}return c}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((C)=>C.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 Sm(e){return e.endSide??e.side??"additions"}var Cm=navigator.userAgent.includes("Macintosh")?"darwin":"linux";function qu(e){let t=Vu(),n,r=!1;e.submitButton.addEventListener("click",()=>void u()),f();function i(p,g){let v=p.fileDiff.name;if(t.add(v,Ou(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 C=document.createElement("div");C.className="review-comment-card",v.append(C);let S=document.createElement("p");if(S.className="review-comment-label",S.textContent=xm(g.range,p.side),C.append(S),g.body===null)s(C,g.id);else a(C,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 C=document.createElement("div");C.className="review-comment-actions";let S=gs("Add comment");S.disabled=!0;let y=gs("Cancel","outline"),I=()=>{let x=t.save(g,v.value);if(!x)return;d(x),e.clearSelection()};S.addEventListener("click",I),y.addEventListener("click",()=>l(g)),v.addEventListener("input",()=>{S.disabled=v.value.trim()===""}),v.addEventListener("keydown",(x)=>{if(x.key==="Escape")x.preventDefault(),l(g);else if(x.key==="Enter"&&Hu(x,Cm))x.preventDefault(),I()}),C.append(S,y),p.append(v,C),setTimeout(()=>v.focus(),0)}function a(p,g,v){let C=document.createElement("p");C.className="review-comment-body",C.textContent=v;let S=document.createElement("div");S.className="review-comment-actions";let y=gs("Remove","ghost");y.classList.add("error-foreground"),y.addEventListener("click",()=>l(g)),S.append(y),p.append(C,S)}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){if(t.reconcileFiles(new Map(p.filter((v)=>t.annotations.has(v.fileDiff.name)).map((v)=>[v.fileDiff.name,Ou(v.fileDiff)]))).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 gs(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 Ou(e){return JSON.stringify(e)}function xm(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 $u({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(km(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 C=document.createElement("span");C.className="review-commit-author",C.textContent=u.author;let S=document.createElement("time");if(S.className="formatted-date",S.dateTime=u.authoredAt,S.title=Gu(u.authoredAt),S.textContent=Em(u.authoredAt),g.append(v,C,S),m.append(p,g),c.append(m),f){let y=t(u.hash);if(y)c.append(_m(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 Uu(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=`+${zu(t.changes,"additions")}`;let s=document.createElement("span");s.className="review-deletions",s.textContent=`-${zu(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=Gu(t.commit.authoredAt),u.textContent=u.title,a.append(l,d,u),e.append(n,a)}function Ku(e){e.hidden=!0,e.replaceChildren()}function km(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 _m(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=Tm(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 Gu(e,t){return ju(new Date(e),t)}function Em(e,t=new Date,n){return Wu(new Date(e),t,n)}function zu(e,t){return e.reduce((n,r)=>n+r[t],0)}function Tm(e){if(e==="added")return"A";if(e==="deleted")return"D";if(e==="renamed")return"R";if(e==="untracked")return"U";return"M"}function Ti(e){return e==="git-unloaded"||e.startsWith("git-summary:")}function Yu(e,t){return e.workspacePath!==t.workspacePath||e.revision!==t.revision}function Xu(e,t,n){if(e[0]?.hash!==n[0]?.hash)return{commits:[...n],hasMore:n.length===Hn,reset:!0};let i=new Set(n.map(({hash:o})=>o));return{commits:[...n,...e.slice(Hn).filter(({hash:o})=>!i.has(o))],hasMore:t,reset:!1}}function Qu(e,t){if(e.kind==="commit"&&t[0])return{kind:"working",path:t[0].path};return e}function Zu(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 Ju(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===Hn&&r.length>0}}var Pm=10,Rm=2,ed=document.body.dataset.codeThemeLight,td=document.body.dataset.codeThemeDark;if(ed&&td)Is({dark:td,light:ed});var Dm=document.body.dataset.workspaceReviewEndpoint??"",Mm=document.body.dataset.workspaceFilesEndpoint??"",Ss=Fu(Dm);window.addEventListener("pi-ui-code-theme-changed",(e)=>{if(!(e instanceof CustomEvent)||!cd(e.detail))return;let t=e.detail;if(Is(t),ze)Dd().setRenderOptions({theme:t}).then(Kn).catch((n)=>console.error("Failed to update workspace theme",n))});var Am=Ze("app"),Nm=document.querySelectorAll("[data-workspace-mode]"),Di=Ze("review-tree"),pt=Ze("review-history"),ud=Ze("review-detail-header"),Wn=Ze("review-diff-view"),Lm=Ze("workspace-file-tree"),nd=Ze("workspace-file-view"),rd=Ze("review-empty"),dd=Yn("review-mode-all"),hd=Yn("review-mode-selected"),fd=Yn("review-layout-split"),pd=Yn("review-layout-stacked"),vs=Yn("review-wrap"),Fm=Ze("workspace-review"),Bm=Yn("review-submit-comments"),Hm=Ze("review-comment-status"),Vm=Ze("workspace-review-data-region"),Om=Ze("workspace-review-data"),ft=JSON.parse(Om.textContent??"");if(!sn(ft)||!on(ft.filesRevision)||!on(ft.treeRevision)||!Er(ft.workspacePath)||!fs(ft.snapshot))throw Error("Invalid initial workspace review state");var Ai=ku(ft.preferences),an=ft.workspacePath,id=ft.filesRevision,od=ft.treeRevision,q=ft.snapshot,ln=[...q.commits],jn=q.commits.length===Hn,$n=!1,Mi=0,cn=Ai.mode??"all",te={kind:"working",path:q.changes[0]?.path},Cs=Ai.layout,zn=Ai.wrap??!0,md=0,ys=new Map,ze,bs,un=qu({clearSelection:()=>ze?.clearSelectedLines(),onAnnotationsChange:l1,onSubmitted(){if(xt=Fi(q.changes,q.patch,"working"),te.kind==="working")Xe=xt,qt=Pr(Xe),ze?.clearSelectedLines(),dn();window.piUi.messageScroll.scrollBottom()},status:Hm,submit:s1,submitButton:Bm}),xt=Td(Fi(q.changes,q.patch,"working")),Xe=xt,qt=Pr(Xe),Pi=q.revision!=="git-unloaded",Ni=new Map,Ri=new Map,ws=0,Fe=Lu({endpoint:Mm,initialGitStatus:q.changes,initialWorkspacePath:an}),Li=Ai.tab,kt=Ym(Li,q.isGitRepository),mt=i1(Am,!0,(e)=>{if(Fe.setVisible(e&&kt==="files"),e&&kt==="git")Nd()});for(let e of Nm)e.addEventListener("click",()=>{let t=e.dataset.workspaceMode;if(t==="files"||t==="git"&&q.isGitRepository)Rr(t)});var Qe=new kr({...Cu,composition:{contextMenu:{enabled:!0,render:n1,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)Cd(t,!0)}});Qe.render({containerWrapper:Di});e1();window.piUi.workspaceReview={...mt,focusEditor:Jm,focusFiles:Xm,focusGit:Qm};pt.addEventListener("scroll",Bi,{passive:!0});pt.addEventListener("keydown",Zm);dd.addEventListener("click",()=>Id("all"));hd.addEventListener("click",()=>Id("selected"));fd.addEventListener("click",()=>Sd("split"));pd.addEventListener("click",()=>Sd("unified"));vs.addEventListener("click",()=>{zn=!zn,vs.setAttribute("aria-pressed",String(zn)),Vi(),Kn()});var Tr=Gn(),gd=new ResizeObserver(()=>{let e=Gn();if(xs(e),e===Tr)return;Tr=e,Kn()});gd.observe(Wn);var vd=new MutationObserver(Kn);vd.observe(document.documentElement,{attributeFilter:["class"],attributes:!0});function yd(){try{let e=document.getElementById("workspace-review-data"),t=JSON.parse(e?.textContent??"");if(sn(t)&&on(t.filesRevision)&&on(t.treeRevision)&&Er(t.workspacePath)&&fs(t.snapshot)){let n=t.workspacePath===an&&t.filesRevision!==id,r=t.treeRevision!==od;if(id=t.filesRevision,od=t.treeRevision,qm(t.workspacePath,t.snapshot),n)Fe.refresh(r)}}catch{}}var bd=new MutationObserver(yd);bd.observe(Vm,{characterData:!0,childList:!0,subtree:!0});Ld();xs();vs.setAttribute("aria-pressed",String(zn));wd(q);yd();window.addEventListener("pagehide",()=>{bd.disconnect(),gd.disconnect(),vd.disconnect(),Qe.cleanUp(),Fe.cleanUp(),ze?.cleanUp(),lo()},{once:!0});function qm(e,t){if(!Yu({revision:q.revision,workspacePath:an},{revision:t.revision,workspacePath:e}))return;if(e!==an)an=e,Fe.setWorkspace(an),ws++,Mi++,ln=[],jn=!1,$n=!1,Ni.clear(),Ri.clear(),ys.clear(),un.reset(),Pi=!1,te={kind:"working"};wd(t)}function wd(e){let t=Ti(q.revision)||!Pi,n=t?void 0:q.changes.map(({path:s})=>s),r=q.isGitRepository,i=Xu(ln,jn,e.commits);if(q=e,Fe.setGitStatus(q.changes),ln=i.commits,jn=i.hasMore,i.reset)Mi++,$n=!1;if(!q.isGitRepository)kt="files";else if(!r&&Li!=="files")kt="git";Fe.setVisible(mt.isOpen()&&kt==="files");let o=Fi(q.changes,q.patch,"working");if(un.reconcileItems(o),xt=Td(o),_i(Qe,n,q.changes.map(({path:s})=>s)),Qe.setGitStatus(q.changes),Ti(q.revision)){Pi=!1,_t(),ze?.setItems([]),Un("Loading Git data…");return}if(te=Zu(te,t,Ed(),q.commits),t)Pi=!0;if(_t(),mt.isOpen()&&kt==="git")requestAnimationFrame(Bi);if(te.kind==="commit")kd(te.hash,te.path);else xd(te.path)}function Id(e){if(cn=e,Ld(),Vi(),cn==="selected"&&!te.path)te.path=Xe[0]?.fileDiff.name;_t(),dn()}function Sd(e){Cs=e,Tr=Gn(),xs(Tr),Vi(),Kn()}function Cd(e,t=!1){if(xd(e),_t(),e&&!t)Qe.scrollToPath(e,{focus:!1,offset:"nearest"});if(e)_d(e)}function xd(e){te={kind:"working",path:e},Xe=xt,qt=Pr(Xe),Gm(),dn()}async function kd(e,t){te={hash:e,kind:"commit",path:t},jm(),_t();let n=Ni.get(e);if(n){sd(n,t);return}Un("Loading commit…");let r=await zm(e);if(te.kind!=="commit"||te.hash!==e)return;if(!r){Un("Unable to load commit");return}sd(r,t)}function sd(e,t){Xe=e.items,qt=Pr(Xe),te={hash:e.detail.commit.hash,kind:"commit",path:t&&qt.has(t)?t:Xe[0]?.fileDiff.name},Km(e.detail),_t(),dn()}function zm(e){let t=Ri.get(e);if(t)return t;let n=ws,r=Ss.loadCommit(e).then((i)=>{if(!i)return;let o={detail:i,items:Fi(i.changes,i.patch,i.commit.hash)};if(n!==ws)return;return Ni.set(e,o),o}).finally(()=>Ri.delete(e));return Ri.set(e,r),r}function Wm(e,t){if(te.kind!=="commit"||te.hash!==e)return;if(te.path=t,_t(),cn==="selected")dn();else _d(t)}function _d(e){let t=qt.get(e);if(t&&ze)ze.scrollTo({type:"item",id:t.id,align:"start",behavior:"smooth-auto"})}function Ed(){let e=new Set(q.changes.map(({path:r})=>r)),t=Qe.getVisibleRows(0,Qe.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 jm(){for(let e of Qe.getSelectedPaths())Qe.getItem(e)?.deselect()}function dn(){let e=cn==="all"?Xe:te.path&&qt.has(te.path)?[qt.get(te.path)]:[];if(e.length===0){ze?.setItems([]),Un(o1());return}if(Un(),!mt.isOpen())return;if(!ze){Tr=Gn();let t=Rd();ze=new ld(t,Dd()),bs=t.enableGutterUtility,ze.setup(Wn)}else if(bs!==Pd())Kn();ze.setItems(e)}function Fi(e,t,n){let r=new Map;for(let i of ad(t))for(let o of i.files)r.set(o.name,o);return e.map((i)=>{let o=r.get(i.path)??$m(i),s=`${n}:${i.path}`,a=JSON.stringify({...o,cacheKey:void 0}),l=ys.get(s),d=l?.content===a?l.version:++md;return ys.set(s,{content:a,version:d}),{fileDiff:{...o,cacheKey:`pi-ui:${s}:${d}`},id:`diff:${s}`,type:"diff",version:d}})}function Td(e){return e.map((t)=>({...t,annotations:un.annotations.get(t.fileDiff.name)}))}function Pr(e){return new Map(e.map((t)=>[t.fileDiff.name,t]))}function $m(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 _t(){$u({commits:ln,getCommitDetail:(e)=>Ni.get(e)?.detail,history:pt,loading:$n,onSelectCommit:(e)=>void kd(e),onSelectCommitPath:Wm,revision:q.revision,selection:te})}function Bi(){if(!mt.isOpen()||$n||!jn||pt.scrollHeight-pt.scrollTop-pt.clientHeight>120)return;Um()}async function Um(){$n=!0;let e=Mi;_t();let t=await Ss.loadHistory(ln.length);if(e!==Mi)return;if(t){let n=Ju(ln,t);ln=n.commits,jn=n.hasMore}else jn=!1;$n=!1,_t(),requestAnimationFrame(Bi)}function Km(e){Uu(ud,e)}function Gm(){Ku(ud)}function Pd(){return te.kind==="working"&&un.canAdd()}function Kn(){if(!ze)return;let e=Rd();ze.setOptions(e),bs=e.enableGutterUtility}function Rd(){let e=Pd();return{diffIndicators:"none",enableGutterUtility:e,enableLineSelection:e,onGutterUtilityClick(t,n){if(n.item.type==="diff")un.add(n.item,t)},pointerEventsOnScroll:!0,renderAnnotation:un.render,diffStyle:Gn(),hunkSeparators:"simple",itemMetrics:{diffHeaderHeight:36,paddingBottom:0,spacing:0},layout:{gap:Rm,paddingBottom:Pm,paddingTop:0},lineHoverHighlight:"both",overflow:zn?"wrap":"scroll",stickyHeaders:!0,theme:_r(),themeType:document.documentElement.classList.contains("dark")?"dark":"light",unsafeCSS:`
|
|
1302
|
+
`}}function zt(w){if(pe=w,pe)lt()}async function Ce(w){pe=!0,await lt();for(let H of oe.getSelectedPaths())oe.getItem(H)?.deselect();let A=oe.getItem(w);if(A)A.select();else await tt(w)}function vt(w=!0){Wt(w)}function je(w){if(B?.path===w)z=!1,$e();Wt()}async function Wt(w=!0){let A=B,H=U;if(await lt(w),!A||B!==A||U!==H)return;try{let j=await t.read(A.path);if(B!==A||U!==H)return;if("message"in j){if(z)de("File changed on disk");else We(),fn(j.path),s.textContent=j.path,de(On(j.size)),De(j.message);return}if(j.revision===A.revision)return;if(z){de("File changed on disk");return}let yt=++U;Tt(),B=j,Se=j.contents,ye.render({file:{cacheKey:`${T}:${j.path}:${j.revision}`,contents:j.contents,name:j.path},containerWrapper:i}),de(On(j.size)),$e(),await hn(yt)}catch(j){if(B!==A||U!==H)return;de(Ot(j))}}function et(w){oe.setGitStatus(w)}function be(w){if(T===w)return;if(T=w,O=[],fe=void 0,Z+=1,We(),oe.resetPaths([]),pe)lt()}async function lt(w=!1){if(w)Q=!0;let A=++Z;if(!pe||!Q&&fe===T)return;if(!w)de("Loading files…");try{let H=await t.list();if(A!==Z||H.workspacePath!==T)return;if(_i(oe,fe===T?O:void 0,H.paths),fe=T,O=H.paths,Q=!1,ae){if(B)de(On(B.size));return}let j=H.paths.includes("README.md")?"README.md":H.paths.find((yt)=>!yt.endsWith("/"));if(j)oe.getItem(j)?.select();else de(""),De("No files in this workspace")}catch(H){if(A!==Z)return;de(Ot(H)),De("Could not load workspace files")}}async function tt(w){if(B?.path===w)return;if(z&&!await ct({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=++U;Tt(),z=!1,s.textContent=w,fn(),de("");try{let H=await t.read(w);if(A!==U)return;if(fn(H.path),de(On(H.size)),"message"in H){B=void 0,De(H.message),$e();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}),Oi(),de(On(H.size)),$e(),await hn(A)}catch(H){if(A!==U)return;B=void 0,de(""),De(Ot(H)),$e()}}async function hn(w){l.disabled=!0;try{let{Editor:A}=await import("./index-wmew1h99.js");if(w!==U||!B)return;Y=new A("file"),Y.edit(ye)}catch(A){Y=void 0,de(Ot(A))}finally{$e()}}async function jt(){if(!B||!Y||!z)return;l.disabled=!0,de("Saving…");try{B=await t.save(B.path,Se,B.revision),Se=B.contents,z=!1,de(On(B.size))}catch(w){de(Ot(w))}finally{$e()}}function Tt(){Y?.cleanUp("discard"),Y=void 0,$e()}function fn(w){ae=w,d.disabled=!w}function $e(){l.disabled=!B||!Y||!z}function De(w){o.textContent=w,o.style.display="grid",i.style.display="none"}function Oi(){o.style.display="none",i.style.display="block"}function de(w){a.textContent=w}function K(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 pn(){if(!Im(p.value)){g.textContent="Use a non-empty name without slashes, '.', or '..'.",g.hidden=!1;return}f.close("submit")}function ct(w){return S.textContent=w.title,y.textContent=w.description,x.textContent=w.action,I.hidden=w.showCancel===!1,x.dataset.variant=w.destructive===!1?"default":"destructive",C.returnValue="",new Promise((A)=>{C.addEventListener("close",()=>A(C.returnValue==="confirm"),{once:!0}),C.showModal()})}async function Pt(w,A){await ct({title:w,description:A,action:"OK",showCancel:!1,destructive:!1})}v.addEventListener("click",pn),p.addEventListener("keydown",(w)=>{if(w.key!=="Enter"||w.isComposing)return;w.preventDefault(),pn()});function $t(){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 Ut(){(B?i:r).focus({preventScroll:!0})}function Kt(){Tt(),ye.cleanUp(),oe.cleanUp()}return $e(),De("Open a file from the workspace"),{cleanUp:Kt,focusEditor:Ut,focusTree:$t,openFile:Ce,refresh:vt,refreshAfterDiscard:je,requestConfirmation:ct,requestNotice:Pt,setGitStatus:et,setVisible:zt,setWorkspace:be}}function Ot(e){return String(e).replace(/^Error: /,"")}function Im(e){return Boolean(e&&e===e.trim()&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\"))}function Mu(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Au(e,t){return e?`${e}/${t}`:t}function On(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(1)} MB`}function st(e){let t=document.getElementById(e);if(!(t instanceof HTMLElement))throw Error(`Missing #${e}`);return t}function qn(e){let t=document.getElementById(e);if(!(t instanceof HTMLButtonElement))throw Error(`Missing #${e}`);return t}function Nu(e){let t=document.getElementById(e);if(!(t instanceof HTMLDialogElement))throw Error(`Missing #${e}`);return t}function Sm(e){let t=document.getElementById(e);if(!(t instanceof HTMLInputElement))throw Error(`Missing #${e}`);return t}function Bu(e){return{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(sn(i)&&Er(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 Eu(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 Tu(r)?r:void 0}catch{return}}}}var Ei=globalThis.navigator?.platform??globalThis.process?.platform,Hu=Ei==="win32"||Ei?.startsWith("Win")?"windows":Ei==="darwin"||Ei?.startsWith("Mac")?"darwin":"linux";function Vu(e,t=Hu){return t==="darwin"?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Ou(){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:Cm(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){let c=[];for(let m of e.keys()){if(f.get(m)===t.get(m))continue;e.delete(m),t.delete(m),c.push(m)}return c}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((C)=>C.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 Cm(e){return e.endSide??e.side??"additions"}var xm=navigator.userAgent.includes("Macintosh")?"darwin":"linux";function zu(e){let t=Ou(),n,r=!1;e.submitButton.addEventListener("click",()=>void u()),f();function i(p,g){let v=p.fileDiff.name;if(t.add(v,qu(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 C=document.createElement("div");C.className="review-comment-card",v.append(C);let S=document.createElement("p");if(S.className="review-comment-label",S.textContent=km(g.range,p.side),C.append(S),g.body===null)s(C,g.id);else a(C,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 C=document.createElement("div");C.className="review-comment-actions";let S=gs("Add comment");S.disabled=!0;let y=gs("Cancel","outline"),I=()=>{let x=t.save(g,v.value);if(!x)return;d(x),e.clearSelection()};S.addEventListener("click",I),y.addEventListener("click",()=>l(g)),v.addEventListener("input",()=>{S.disabled=v.value.trim()===""}),v.addEventListener("keydown",(x)=>{if(x.key==="Escape")x.preventDefault(),l(g);else if(x.key==="Enter"&&Vu(x,xm))x.preventDefault(),I()}),C.append(S,y),p.append(v,C),setTimeout(()=>v.focus(),0)}function a(p,g,v){let C=document.createElement("p");C.className="review-comment-body",C.textContent=v;let S=document.createElement("div");S.className="review-comment-actions";let y=gs("Remove","ghost");y.classList.add("error-foreground"),y.addEventListener("click",()=>l(g)),S.append(y),p.append(C,S)}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){if(t.reconcileFiles(new Map(p.filter((v)=>t.annotations.has(v.fileDiff.name)).map((v)=>[v.fileDiff.name,qu(v.fileDiff)]))).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 gs(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 qu(e){return JSON.stringify(e)}function km(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 Uu({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(_m(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 C=document.createElement("span");C.className="review-commit-author",C.textContent=u.author;let S=document.createElement("time");if(S.className="formatted-date",S.dateTime=u.authoredAt,S.title=Yu(u.authoredAt),S.textContent=Tm(u.authoredAt),g.append(v,C,S),m.append(p,g),c.append(m),f){let y=t(u.hash);if(y)c.append(Em(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 Ku(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=`+${Wu(t.changes,"additions")}`;let s=document.createElement("span");s.className="review-deletions",s.textContent=`-${Wu(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=Yu(t.commit.authoredAt),u.textContent=u.title,a.append(l,d,u),e.append(n,a)}function Gu(e){e.hidden=!0,e.replaceChildren()}function _m(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 Em(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=Pm(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 Yu(e,t){return $u(new Date(e),t)}function Tm(e,t=new Date,n){return ju(new Date(e),t,n)}function Wu(e,t){return e.reduce((n,r)=>n+r[t],0)}function Pm(e){if(e==="added")return"A";if(e==="deleted")return"D";if(e==="renamed")return"R";if(e==="untracked")return"U";return"M"}function Ti(e){return e==="git-unloaded"||e.startsWith("git-summary:")}function Xu(e,t){return e.workspacePath!==t.workspacePath||e.revision!==t.revision}function Qu(e,t,n){if(e[0]?.hash!==n[0]?.hash)return{commits:[...n],hasMore:n.length===Hn,reset:!0};let i=new Set(n.map(({hash:o})=>o));return{commits:[...n,...e.slice(Hn).filter(({hash:o})=>!i.has(o))],hasMore:t,reset:!1}}function Zu(e,t){if(e.kind==="commit"&&t[0])return{kind:"working",path:t[0].path};return e}function Ju(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 ed(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===Hn&&r.length>0}}var Rm=10,Dm=2,td=document.body.dataset.codeThemeLight,nd=document.body.dataset.codeThemeDark;if(td&&nd)Is({dark:nd,light:td});var Mm=document.body.dataset.workspaceReviewEndpoint??"",Am=document.body.dataset.workspaceFilesEndpoint??"",Ss=Bu(Mm);window.addEventListener("pi-ui-code-theme-changed",(e)=>{if(!(e instanceof CustomEvent)||!ud(e.detail))return;let t=e.detail;if(Is(t),ze)Md().setRenderOptions({theme:t}).then(Kn).catch((n)=>console.error("Failed to update workspace theme",n))});var Nm=Ze("app"),Lm=document.querySelectorAll("[data-workspace-mode]"),Di=Ze("review-tree"),pt=Ze("review-history"),dd=Ze("review-detail-header"),Wn=Ze("review-diff-view"),Fm=Ze("workspace-file-tree"),rd=Ze("workspace-file-view"),id=Ze("review-empty"),hd=Yn("review-mode-all"),fd=Yn("review-mode-selected"),pd=Yn("review-layout-split"),md=Yn("review-layout-stacked"),vs=Yn("review-wrap"),Bm=Ze("workspace-review"),Hm=Yn("review-submit-comments"),Vm=Ze("review-comment-status"),Om=Ze("workspace-review-data-region"),qm=Ze("workspace-review-data"),ft=JSON.parse(qm.textContent??"");if(!sn(ft)||!on(ft.filesRevision)||!on(ft.treeRevision)||!Er(ft.workspacePath)||!fs(ft.snapshot))throw Error("Invalid initial workspace review state");var Ai=ku(ft.preferences),an=ft.workspacePath,od=ft.filesRevision,sd=ft.treeRevision,q=ft.snapshot,ln=[...q.commits],jn=q.commits.length===Hn,$n=!1,Mi=0,cn=Ai.mode??"all",te={kind:"working",path:q.changes[0]?.path},Cs=Ai.layout,zn=Ai.wrap??!0,gd=0,ys=new Map,ze,bs,un=zu({clearSelection:()=>ze?.clearSelectedLines(),onAnnotationsChange:c1,onSubmitted(){if(xt=Fi(q.changes,q.patch,"working"),te.kind==="working")Xe=xt,qt=Pr(Xe),ze?.clearSelectedLines(),dn();window.piUi.messageScroll.scrollBottom()},status:Vm,submit:a1,submitButton:Hm}),xt=Pd(Fi(q.changes,q.patch,"working")),Xe=xt,qt=Pr(Xe),Pi=q.revision!=="git-unloaded",Ni=new Map,Ri=new Map,ws=0,Fe=Fu({endpoint:Am,initialGitStatus:q.changes,initialWorkspacePath:an}),Li=Ai.tab,kt=Xm(Li,q.isGitRepository),mt=o1(Nm,!0,(e)=>{if(Fe.setVisible(e&&kt==="files"),e&&kt==="git")Ld()});for(let e of Lm)e.addEventListener("click",()=>{let t=e.dataset.workspaceMode;if(t==="files"||t==="git"&&q.isGitRepository)Rr(t)});var Qe=new kr({...Cu,composition:{contextMenu:{enabled:!0,render:r1,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)xd(t,!0)}});Qe.render({containerWrapper:Di});t1();window.piUi.workspaceReview={...mt,focusEditor:e1,focusFiles:Qm,focusGit:Zm};pt.addEventListener("scroll",Bi,{passive:!0});pt.addEventListener("keydown",Jm);hd.addEventListener("click",()=>Sd("all"));fd.addEventListener("click",()=>Sd("selected"));pd.addEventListener("click",()=>Cd("split"));md.addEventListener("click",()=>Cd("unified"));vs.addEventListener("click",()=>{zn=!zn,vs.setAttribute("aria-pressed",String(zn)),Vi(),Kn()});var Tr=Gn(),vd=new ResizeObserver(()=>{let e=Gn();if(xs(e),e===Tr)return;Tr=e,Kn()});vd.observe(Wn);var yd=new MutationObserver(Kn);yd.observe(document.documentElement,{attributeFilter:["class"],attributes:!0});function bd(){try{let e=document.getElementById("workspace-review-data"),t=JSON.parse(e?.textContent??"");if(sn(t)&&on(t.filesRevision)&&on(t.treeRevision)&&Er(t.workspacePath)&&fs(t.snapshot)){let n=t.workspacePath===an&&t.filesRevision!==od,r=t.treeRevision!==sd;if(od=t.filesRevision,sd=t.treeRevision,zm(t.workspacePath,t.snapshot),n)Fe.refresh(r)}}catch{}}var wd=new MutationObserver(bd);wd.observe(Om,{characterData:!0,childList:!0,subtree:!0});Fd();xs();vs.setAttribute("aria-pressed",String(zn));Id(q);bd();window.addEventListener("pagehide",()=>{wd.disconnect(),vd.disconnect(),yd.disconnect(),Qe.cleanUp(),Fe.cleanUp(),ze?.cleanUp(),lo()},{once:!0});function zm(e,t){if(!Xu({revision:q.revision,workspacePath:an},{revision:t.revision,workspacePath:e}))return;if(e!==an)an=e,Fe.setWorkspace(an),ws++,Mi++,ln=[],jn=!1,$n=!1,Ni.clear(),Ri.clear(),ys.clear(),un.reset(),Pi=!1,te={kind:"working"};Id(t)}function Id(e){let t=Ti(q.revision)||!Pi,n=t?void 0:q.changes.map(({path:s})=>s),r=q.isGitRepository,i=Qu(ln,jn,e.commits);if(q=e,Fe.setGitStatus(q.changes),ln=i.commits,jn=i.hasMore,i.reset)Mi++,$n=!1;if(!q.isGitRepository)kt="files";else if(!r&&Li!=="files")kt="git";Fe.setVisible(mt.isOpen()&&kt==="files");let o=Fi(q.changes,q.patch,"working");if(un.reconcileItems(o),xt=Pd(o),_i(Qe,n,q.changes.map(({path:s})=>s)),Qe.setGitStatus(q.changes),Ti(q.revision)){Pi=!1,_t(),ze?.setItems([]),Un("Loading Git data…");return}if(te=Ju(te,t,Td(),q.commits),t)Pi=!0;if(_t(),mt.isOpen()&&kt==="git")requestAnimationFrame(Bi);if(te.kind==="commit")_d(te.hash,te.path);else kd(te.path)}function Sd(e){if(cn=e,Fd(),Vi(),cn==="selected"&&!te.path)te.path=Xe[0]?.fileDiff.name;_t(),dn()}function Cd(e){Cs=e,Tr=Gn(),xs(Tr),Vi(),Kn()}function xd(e,t=!1){if(kd(e),_t(),e&&!t)Qe.scrollToPath(e,{focus:!1,offset:"nearest"});if(e)Ed(e)}function kd(e){te={kind:"working",path:e},Xe=xt,qt=Pr(Xe),Ym(),dn()}async function _d(e,t){te={hash:e,kind:"commit",path:t},$m(),_t();let n=Ni.get(e);if(n){ad(n,t);return}Un("Loading commit…");let r=await Wm(e);if(te.kind!=="commit"||te.hash!==e)return;if(!r){Un("Unable to load commit");return}ad(r,t)}function ad(e,t){Xe=e.items,qt=Pr(Xe),te={hash:e.detail.commit.hash,kind:"commit",path:t&&qt.has(t)?t:Xe[0]?.fileDiff.name},Gm(e.detail),_t(),dn()}function Wm(e){let t=Ri.get(e);if(t)return t;let n=ws,r=Ss.loadCommit(e).then((i)=>{if(!i)return;let o={detail:i,items:Fi(i.changes,i.patch,i.commit.hash)};if(n!==ws)return;return Ni.set(e,o),o}).finally(()=>Ri.delete(e));return Ri.set(e,r),r}function jm(e,t){if(te.kind!=="commit"||te.hash!==e)return;if(te.path=t,_t(),cn==="selected")dn();else Ed(t)}function Ed(e){let t=qt.get(e);if(t&&ze)ze.scrollTo({type:"item",id:t.id,align:"start",behavior:"smooth-auto"})}function Td(){let e=new Set(q.changes.map(({path:r})=>r)),t=Qe.getVisibleRows(0,Qe.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 $m(){for(let e of Qe.getSelectedPaths())Qe.getItem(e)?.deselect()}function dn(){let e=cn==="all"?Xe:te.path&&qt.has(te.path)?[qt.get(te.path)]:[];if(e.length===0){ze?.setItems([]),Un(s1());return}if(Un(),!mt.isOpen())return;if(!ze){Tr=Gn();let t=Dd();ze=new cd(t,Md()),bs=t.enableGutterUtility,ze.setup(Wn)}else if(bs!==Rd())Kn();ze.setItems(e)}function Fi(e,t,n){let r=new Map;for(let i of ld(t))for(let o of i.files)r.set(o.name,o);return e.map((i)=>{let o=r.get(i.path)??Um(i),s=`${n}:${i.path}`,a=JSON.stringify({...o,cacheKey:void 0}),l=ys.get(s),d=l?.content===a?l.version:++gd;return ys.set(s,{content:a,version:d}),{fileDiff:{...o,cacheKey:`pi-ui:${s}:${d}`},id:`diff:${s}`,type:"diff",version:d}})}function Pd(e){return e.map((t)=>({...t,annotations:un.annotations.get(t.fileDiff.name)}))}function Pr(e){return new Map(e.map((t)=>[t.fileDiff.name,t]))}function Um(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 _t(){Uu({commits:ln,getCommitDetail:(e)=>Ni.get(e)?.detail,history:pt,loading:$n,onSelectCommit:(e)=>void _d(e),onSelectCommitPath:jm,revision:q.revision,selection:te})}function Bi(){if(!mt.isOpen()||$n||!jn||pt.scrollHeight-pt.scrollTop-pt.clientHeight>120)return;Km()}async function Km(){$n=!0;let e=Mi;_t();let t=await Ss.loadHistory(ln.length);if(e!==Mi)return;if(t){let n=ed(ln,t);ln=n.commits,jn=n.hasMore}else jn=!1;$n=!1,_t(),requestAnimationFrame(Bi)}function Gm(e){Ku(dd,e)}function Ym(){Gu(dd)}function Rd(){return te.kind==="working"&&un.canAdd()}function Kn(){if(!ze)return;let e=Dd();ze.setOptions(e),bs=e.enableGutterUtility}function Dd(){let e=Rd();return{diffIndicators:"none",enableGutterUtility:e,enableLineSelection:e,onGutterUtilityClick(t,n){if(n.item.type==="diff")un.add(n.item,t)},pointerEventsOnScroll:!0,renderAnnotation:un.render,diffStyle:Gn(),hunkSeparators:"simple",itemMetrics:{diffHeaderHeight:36,paddingBottom:0,spacing:0},layout:{gap:Dm,paddingBottom:Rm,paddingTop:0},lineHoverHighlight:"both",overflow:zn?"wrap":"scroll",stickyHeaders:!0,theme:_r(),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 ms,C as ki,D as cd,F as _r,G as Is,a as Wr,b as Gs,c as Ys,e
|
|
|
1358
1358
|
min-width: 0;
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
-
`}}function
|
|
1361
|
+
`}}function Md(){return ao({highlighterOptions:{langs:["text"],preferredHighlighter:"shiki-js",theme:_r(),useTokenTransformer:!0},poolOptions:{poolSize:1,totalASTLRUCacheSize:100,workerFactory:()=>new Worker(new URL("../pierre-worker.js",import.meta.url),{type:"module"})}})}function Xm(e,t){return t&&e!=="files"?"git":"files"}function Rr(e){if(e===kt||e==="git"&&!q.isGitRepository)return;if(kt=e,Li=e,Vi(),!mt.isOpen())return;if(Fe.setVisible(e==="files"),e==="git")Ld()}async function S2(e,t){if(t!==an)throw Error("The workspace changed. Open the file link again.");mt.open(),Rr("files"),await Fe.openFile(e),Hi(()=>Fe.focusEditor())}function Qm(){mt.open(),Rr("files"),Hi(()=>Fe.focusTree())}function Zm(){if(!q.isGitRepository)return;mt.open(),Rr("git"),Hi(()=>{if(te.kind==="commit"||q.changes.length===0){Nd();return}let e=Qe.getSelectedPaths()[0]??Qe.getFocusedPath()??q.changes[0]?.path;if(e)Qe.scrollToPath(e,{focus:!0});requestAnimationFrame(()=>{(Di.querySelector("file-tree-container")?.shadowRoot?.querySelector('[role="tree"]')??Di).focus({preventScroll:!0})})})}function Ad(){return[...pt.querySelectorAll(".review-commit")]}function Nd(){let e=pt.querySelector('.review-commit[aria-pressed="true"]')??Ad()[0];(e??pt).focus({preventScroll:!0}),e?.scrollIntoView({block:"nearest"})}function Jm(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||!["ArrowDown","ArrowUp","Home","End"].includes(e.code))return;let t=Ad();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(Nd)}function e1(){mt.open(),Hi(()=>{if(kt==="files")Fe.focusEditor();else Wn.focus({preventScroll:!0})})}function Hi(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function t1(){Bm.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(n1))return;let n=e.code==="KeyJ"?"ArrowDown":"ArrowUp";if(t.includes(pt)){e.preventDefault(),t[0]?.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,code:n,key:n}));return}if(t.some((i)=>i===Di||i===Fm)){e.preventDefault(),t[0]?.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,code:n,composed:!0,key:n}));return}let r=t.includes(rd)?rd:t.includes(Wn)?Wn:void 0;if(!r)return;e.preventDefault(),r.scrollBy({behavior:"smooth",top:e.code==="KeyJ"?100:-100})})}function n1(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable}function r1(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}),Rr("files"),Fe.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}),i1(e.path)}),n.append(r,i),n}async function i1(e){let t=q.changes.find((r)=>r.path===e);if(!t)return;if(!await Fe.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 Ss.discard(e),Fe.refreshAfterDiscard(e)}catch(r){await Fe.requestNotice("Could not discard changes",String(r).replace(/^Error: /,""))}}function Ld(){let e=Zu(te,Td());if(e!==te&&e.kind==="working")xd(e.path);if(q.revision==="git-unloaded")Un("Loading Git data…");else requestAnimationFrame(()=>{dn(),Bi()})}function o1(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 Fd(){hd.setAttribute("aria-pressed",String(cn==="all")),fd.setAttribute("aria-pressed",String(cn==="selected"))}function Gn(){if(Wn.clientWidth<720)return"unified";return Cs??"split"}function xs(e=Gn()){let t=e==="split";pd.setAttribute("aria-pressed",String(t)),md.setAttribute("aria-pressed",String(!t))}function s1(){if(Ti(q.revision))return"Loading Git data…";if(!q.isGitRepository)return"Open a Git repository";if(te.kind==="commit")return"This commit has no file changes";if(q.changes.length===0)return"Working tree clean";return"No changes to display"}function Un(e){if(id.style.display=e?"grid":"none",e)id.textContent=e}function Vi(){l1({layout:Cs,mode:cn,tab:Li,wrap:zn})}function a1(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 l1(e){document.body.dispatchEvent(new CustomEvent("pi-ui-workspace-review-preferences",{detail:e}))}function c1(e){let t=xt.findIndex((r)=>r.fileDiff.name===e);if(t<0)return;let n=[...xt];if(n[t]={...n[t],annotations:un.annotations.get(e),version:++gd},xt=n,te.kind==="working")Xe=xt,qt=Pr(Xe),dn()}function Ze(e){let t=document.getElementById(e);if(!(t instanceof HTMLElement))throw Error(`Missing #${e}`);return t}function Yn(e){let t=document.getElementById(e);if(!(t instanceof HTMLButtonElement))throw Error(`Missing #${e}`);return t}export{S2 as openLinkedWorkspaceFile};
|