vibora 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vibora.js +26 -5
- package/dist/assets/{index-BgERyT4Q.js → index-C28vAs6n.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/index.js +28 -11
package/bin/vibora.js
CHANGED
|
@@ -785,7 +785,7 @@ var init_prompt = __esm(() => {
|
|
|
785
785
|
});
|
|
786
786
|
|
|
787
787
|
// cli/src/utils/server.ts
|
|
788
|
-
import { existsSync, readFileSync } from "fs";
|
|
788
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
789
789
|
import { join } from "path";
|
|
790
790
|
import { homedir } from "os";
|
|
791
791
|
function getPortFromSettings(settings) {
|
|
@@ -846,6 +846,24 @@ function discoverServerUrl(urlOverride, portOverride) {
|
|
|
846
846
|
}
|
|
847
847
|
return `http://localhost:${DEFAULT_PORT}`;
|
|
848
848
|
}
|
|
849
|
+
function updateSettingsPort(port) {
|
|
850
|
+
const viboraDir = getViboraDir();
|
|
851
|
+
const settingsPath = join(viboraDir, "settings.json");
|
|
852
|
+
let settings = {};
|
|
853
|
+
try {
|
|
854
|
+
if (existsSync(settingsPath)) {
|
|
855
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
856
|
+
}
|
|
857
|
+
} catch {}
|
|
858
|
+
if (!settings.server || typeof settings.server !== "object") {
|
|
859
|
+
settings.server = {};
|
|
860
|
+
}
|
|
861
|
+
settings.server.port = port;
|
|
862
|
+
if (!existsSync(viboraDir)) {
|
|
863
|
+
mkdirSync(viboraDir, { recursive: true });
|
|
864
|
+
}
|
|
865
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
866
|
+
}
|
|
849
867
|
function getViboraDir() {
|
|
850
868
|
if (process.env.VIBORA_DIR) {
|
|
851
869
|
return expandPath(process.env.VIBORA_DIR);
|
|
@@ -32338,7 +32356,7 @@ init_errors();
|
|
|
32338
32356
|
|
|
32339
32357
|
// cli/src/utils/process.ts
|
|
32340
32358
|
init_server();
|
|
32341
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync, unlinkSync, mkdirSync } from "fs";
|
|
32359
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, unlinkSync, mkdirSync as mkdirSync2 } from "fs";
|
|
32342
32360
|
import { join as join2, dirname } from "path";
|
|
32343
32361
|
function getPidPath() {
|
|
32344
32362
|
return join2(getViboraDir(), "vibora.pid");
|
|
@@ -32347,9 +32365,9 @@ function writePid(pid) {
|
|
|
32347
32365
|
const pidPath = getPidPath();
|
|
32348
32366
|
const dir = dirname(pidPath);
|
|
32349
32367
|
if (!existsSync2(dir)) {
|
|
32350
|
-
|
|
32368
|
+
mkdirSync2(dir, { recursive: true });
|
|
32351
32369
|
}
|
|
32352
|
-
|
|
32370
|
+
writeFileSync2(pidPath, pid.toString(), "utf-8");
|
|
32353
32371
|
}
|
|
32354
32372
|
function readPid() {
|
|
32355
32373
|
const pidPath = getPidPath();
|
|
@@ -32592,7 +32610,7 @@ function installUv() {
|
|
|
32592
32610
|
var package_default = {
|
|
32593
32611
|
name: "vibora",
|
|
32594
32612
|
private: true,
|
|
32595
|
-
version: "5.
|
|
32613
|
+
version: "5.6.0",
|
|
32596
32614
|
description: "The Vibe Engineer's Cockpit",
|
|
32597
32615
|
license: "PolyForm-Shield-1.0.0",
|
|
32598
32616
|
type: "module",
|
|
@@ -32776,6 +32794,9 @@ async function handleUpCommand(flags) {
|
|
|
32776
32794
|
}
|
|
32777
32795
|
}
|
|
32778
32796
|
const port = getPort(flags.port);
|
|
32797
|
+
if (flags.port) {
|
|
32798
|
+
updateSettingsPort(port);
|
|
32799
|
+
}
|
|
32779
32800
|
const host = flags.host ? "0.0.0.0" : "localhost";
|
|
32780
32801
|
const packageRoot = getPackageRoot();
|
|
32781
32802
|
const serverPath = join3(packageRoot, "server", "index.js");
|
|
@@ -28,7 +28,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
28
28
|
|
|
29
29
|
`)+n.map(SOe).join(`
|
|
30
30
|
`)}var TOe=0,COe=(function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:TOe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:hr.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:hr.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,n===void 0?1:n+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.lastCacheModificationPerId.get(t)||0;return"".concat(this.cacheId,"-").concat(n)}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(n===void 0&&(n=!0),t.identifierAttribute){var r=t.identifier;this.cache.has(r)||this.cache.set(r,hr.array([],Ew));var i=this.cache.get(r);if(i.indexOf(t)!==-1)throw new St("Already registered");i.push(t),n&&this.updateLastCacheModificationPerId(r)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;Ore(t.identifierCache.cache).forEach(function(r){return r.forEach(function(i){n.addNodeToCache(i)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(t.identifierAttribute){var n=t.identifier,r=this.cache.get(n);r&&(r.remove(t),r.length||this.cache.delete(n),this.updateLastCacheModificationPerId(t.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,r=new e,i=t.path+"/";return Bke(this.cache).forEach(function(a){for(var s=Su(a,2),o=s[0],l=s[1],u=!1,f=l.length-1;f>=0;f--){var d=l[f];(d===t||d.path.indexOf(i)===0)&&(r.addNodeToCache(d,!1),l.splice(f,1),l.length||n.cache.delete(o),u=!0)}u&&n.updateLastCacheModificationPerId(o)}),r}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.cache.get(n);return r?r.some(function(i){return t.isAssignableFrom(i.type)}):!1}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.cache.get(n);if(!r)return null;var i=r.filter(function(a){return t.isAssignableFrom(a.type)});switch(i.length){case 0:return null;case 1:return i[0];default:throw new St("Cannot resolve a reference to type '".concat(t.name,"' with id: '").concat(n,"' unambigously, there are multiple candidates: ").concat(i.map(function(a){return a.path}).join(", ")))}}}),e})();function JM(e,t,n,r,i){var a=Xre(i);if(a){if(a.parent)throw new St("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(t?t.path:"","/").concat(n,"', but it lives already at '").concat(a.path,"'"));return t&&a.setParent(t,n),a}return new Ia(e,t,n,r,i)}function fd(e,t,n,r,i){return new Fv(e,t,n,r,i)}function AOe(e){return e instanceof Fv||e instanceof Ia}var ki;(function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"})(ki||(ki={}));function Sr(e){return!!(e&&e.$treenode)}function On(e){if(!Sr(e))throw new St("Value ".concat(e," is no MST Node"));return e.$treenode}function Xre(e){return e&&e.$treenode||null}function kOe(){return On(this).snapshot}function OOe(e,t,n){n===void 0&&(n=!0);var r=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(a===".."){if(r=r.parent,r)continue}else{if(a===".")continue;if(r){if(r instanceof Fv){var s=r.value;Sr(s)&&(r=On(s))}if(r instanceof Ia){var o=r.getChildType(a);if(o&&(r=r.getChildNode(a),r))continue}}}throw new St("Could not resolve '".concat(a,"' in path '").concat(qz(t.slice(0,i))||"/","' while resolving '").concat(qz(t),"'"))}}catch(l){if(!n)return;throw l}return r}function Zre(e){if(!e)return Gp;var t=Object.keys(e);if(!t.length)return Gp;var n=new Array(t.length);return t.forEach(function(r,i){n[i]=e[r]}),n}var ROe=Object.toString(),Gp=Object.freeze([]),qp=Object.freeze({}),Ew=dke().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Ew);var St=(function(e){rr(t,e);function t(n){return n===void 0&&(n="Illegal state"),e.call(this,"[mobx-state-tree] ".concat(n))||this}return t})(Error);function NOe(e){return e}var IOe=Number.isInteger;function DOe(e){return Number(e)===e&&e%1!==0}function LOe(e){return Number.isFinite(e)}function Qre(e){return Array.isArray(e)||_l(e)}function Jre(e){return e?Qre(e)?e:[e]:Gp}function POe(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++){var i=t[r];for(var a in i)e[a]=i[a]}return e}function cp(e){var t;if(e===null||typeof e!="object")return!1;var n=Object.getPrototypeOf(e);return n==null?!0:((t=n.constructor)===null||t===void 0?void 0:t.toString())===ROe}function eie(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function Uv(e,t){return t===void 0&&(t=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||t&&e instanceof Date}function tie(e){return typeof e!="function"}function MOe(e,t,n){Ro(e)?Nre(e,t,n):Object.defineProperty(e,t,n)}function _f(e,t,n){MOe(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}var jOe=(function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this;return n===void 0&&(n=!1),n?this.handlers.unshift(t):this.handlers.push(t),function(){r.unregister(t)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.handlers.indexOf(t)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.handlers.indexOf(t);n>=0&&this.handlers.splice(n,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this.handlers.slice();r.forEach(function(i){return i.apply(void 0,xu([],Su(t),!1))})}}),e})(),nie=(function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){r===void 0&&(r=!1),this.eventHandlers||(this.eventHandlers={});var i=this.eventHandlers[t];return i||(i=this.eventHandlers[t]=new jOe),i.register(n,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.eventHandlers&&this.eventHandlers[t];return!!r&&r.has(n)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.eventHandlers&&this.eventHandlers[t];r&&r.unregister(n)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.eventHandlers&&delete this.eventHandlers[t]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(t){for(var n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var a=this.eventHandlers&&this.eventHandlers[t];a&&(n=a).emit.apply(n,xu([],Su(r),!1))}}),e})();function rie(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function Tk(e,t){return e.indexOf(t)===0}function FOe(e){console.warn(new Error("[mobx-state-tree] ".concat(e)))}function BOe(){return typeof process<"u"&&Vz&&Vz.ENABLE_TYPE_CHECK==="true"}function Ck(e){typeof queueMicrotask=="function"?queueMicrotask(e):typeof setImmediate=="function"?setImmediate(e):setTimeout(e,1)}function Ak(e){return UOe(e.name,e)}function UOe(e,t){var n=function(){var i=qre(),a=Gre();if(!a)throw new St("a mst flow must always have a parent context");var s=Kre(a);if(!s)throw new St("a mst flow must always have a parent action context");var o={name:e,id:i,tree:a.tree,context:a.context,parentId:a.id,allParentIds:xu(xu([],Su(a.allParentIds),!1),[a.id],!1),rootId:a.rootId,parentEvent:a,parentActionEvent:s},l=arguments;function u(f,d,p){return f.$mst_middleware=n.$mst_middleware,SD(Ca(Ca({},o),{type:d,args:[p]}),f)}return new Promise(function(f,d){var p,m=function(){p=t.apply(null,arguments),E(void 0)};m.$mst_middleware=n.$mst_middleware,SD(Ca(Ca({},o),{type:"flow_spawn",args:rie(l)}),m);function E(y){var v;try{var x=u(function(T){v=p.next(T)},"flow_resume",y);x instanceof Error&&(v=p.throw(x))}catch(T){Ck(function(){u(function(w){d(T)},"flow_throw",T)});return}b(v)}function S(y){var v;try{u(function(x){v=p.throw(x)},"flow_resume_error",y)}catch(x){Ck(function(){u(function(T){d(x)},"flow_throw",x)});return}b(v)}function b(y){if(y.done){Ck(function(){u(function(v){f(v)},"flow_return",y.value)});return}if(!y.value||typeof y.value.then!="function")throw new St("Only promises can be yielded to `async`, got: "+y);return y.value.then(E,S)}})};return n._isFlowAction=!0,n}function $Oe(e){if(!("oldValue"in e))throw new St("Patches without `oldValue` field cannot be inversed");return[zOe(e),HOe(e)]}function zOe(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function HOe(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function WOe(e){return typeof e=="number"}function Ef(e){return WOe(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function VOe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function qz(e){if(e.length===0)return"";var t=function(n){return n.map(Ef).join("/")};return e[0]==="."||e[0]===".."?t(e):"/"+t(e)}function GOe(e){var t=e.split("/").map(VOe),n=e===""||e==="."||e===".."||Tk(e,"/")||Tk(e,"./")||Tk(e,"../");if(!n)throw new St("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return t[0]===""&&t.shift(),t}var kk=Symbol("$preProcessorFailed"),qOe=(function(e){rr(t,e);function t(n,r,i){var a=e.call(this,i||n.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),a}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|_n.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor(".concat(this._subtype.describe(),")")}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._processors.preProcessor?this._processors.preProcessor.call(null,n):n}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(n){try{return this.preProcessSnapshot(n)}catch{return kk}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this._processors.postProcessor?this._processors.postProcessor.call(null,n,r.storedValue):n}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;KOe(n.type,this,"create"),n instanceof Ia&&(n.hasSnapshotPostProcessor=!!this._processors.postProcessor);var i=n.getSnapshot;n.getSnapshot=function(){return r.postProcessSnapshot(i.call(n),n)},pRe(this._subtype)||(n.getReconciliationType=function(){return r})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?a:this.preProcessSnapshot(a),o=this._subtype.instantiate(n,r,i,s);return this._fixNode(o),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this._subtype.reconcile(n,Sr(r)?r:this.preProcessSnapshot(r),i,a);return s!==n&&this._fixNode(s),s}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r=!0);var i=this._subtype.getSnapshot(n);return r?this.postProcessSnapshot(i,n):i}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this.preProcessSnapshotSafe(n);return i===kk?Ma(r,n,"Failed to preprocess value"):this._subtype.validate(i,r)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Tu(n)?this._subtype:Sr(n)?n:this.preProcessSnapshotSafe(n);return r===kk?!1:this._subtype.validate(r,[{path:"",type:this._subtype}]).length===0}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._subtype.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(!(this._subtype instanceof Vp))return!1;var i=this.preProcessSnapshot(r);return this._subtype.isMatchingSnapshotId(n,i)}}),t})(wu);function KOe(e,t){for(var n,r,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var s=Kb(i),o=s.next();!o.done;o=s.next()){var l=o.value;e[l]=t[l].bind(t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}function YOe(e,t,n){return new qOe(e,t,n)}var Kz="Map.put can only be used to store complex values that have an identifier type attribute";function iie(e,t){var n,r,i=e.getSubTypes();if(i===Vre)return!1;if(i){var a=Jre(i);try{for(var s=Kb(a),o=s.next();!o.done;o=s.next()){var l=o.value;if(!iie(l,t))return!1}}catch(u){n={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}return e instanceof $v&&t.push(e),!0}var Tc;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(Tc||(Tc={}));var XOe=(function(e){rr(t,e);function t(n,r){return e.call(this,n,hr.ref.enhancer,r)||this}return Object.defineProperty(t.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return e.prototype.get.call(this,""+n)}}),Object.defineProperty(t.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return e.prototype.has.call(this,""+n)}}),Object.defineProperty(t.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return e.prototype.delete.call(this,""+n)}}),Object.defineProperty(t.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return e.prototype.set.call(this,""+n,r)}}),Object.defineProperty(t.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(!n)throw new St("Map.put cannot be used to set empty values");if(Sr(n)){var r=On(n);if(r.identifier===null)throw new St(Kz);return this.set(r.identifier,n),n}else if(eie(n)){var i=On(this),a=i.type;if(a.identifierMode!==Tc.YES)throw new St(Kz);var s=a.mapIdentifierAttribute,o=n[s];if(!e3(o)){var l=this.put(a.getChildType().create(n,i.environment));return this.put(cOe(l))}var u=h0(o);return this.set(u,n),this.get(u)}else throw new St("Map.put can only be used to store complex values")}}),t})(YM),dS=(function(e){rr(t,e);function t(n,r,i){i===void 0&&(i=[]);var a=e.call(this,n)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Tc.UNKNOWN}),Object.defineProperty(a,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Map}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a._determineIdentifierMode(),a.hookInitializers=i,a}return Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.hookInitializers.length>0?this.hookInitializers.concat(n):[n];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._determineIdentifierMode(),JM(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Tc.UNKNOWN){var n=[];if(iie(this._subType,n)){var r=n.reduce(function(i,a){if(!a.identifierAttribute)return i;if(i&&i!==a.identifierAttribute)throw new St("The objects in a map should all have the same identifier attribute, expected '".concat(i,"', but child of type '").concat(a.name,"' declared attribute '").concat(a.identifierAttribute,"' as identifier"));return a.identifierAttribute},void 0);r?(this.identifierMode=Tc.YES,this.mapIdentifierAttribute=r):this.identifierMode=Tc.NO}}}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r={});var i=n.type._subType,a={};return Object.keys(r).forEach(function(s){a[s]=i.instantiate(n,s,void 0,r[s])}),a}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return new XOe(n,this.name)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){Are(r,n.unbox);var i=n.type;i.hookInitializers.forEach(function(a){var s=a(r);Object.keys(s).forEach(function(o){var l=s[o],u=Bv(r,o,l);_f(r,o,u)})}),GM(r,this.willChange),qM(r,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return Ore(n.storedValue)}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=n.storedValue.get(""+r);if(!i)throw new St("Not a child "+r);return i}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object),i=n.name;r.assertWritable({subpath:i});var a=r.type,s=a._subType;switch(n.type){case"update":{var o=n.newValue,l=n.object.get(i);if(o===l)return null;fu(s,o),n.newValue=s.reconcile(r.getChildNode(i),n.newValue,r,i),a.processIdentifier(i,n.newValue)}break;case"add":fu(s,n.newValue),n.newValue=s.instantiate(r,i,void 0,n.newValue),a.processIdentifier(i,n.newValue);break}return n}}),Object.defineProperty(t.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this.identifierMode===Tc.YES&&r instanceof Ia){var i=r.identifier;if(i!==n)throw new St("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(i,"', but expected: '").concat(n,"'"))}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r={};return n.getChildren().forEach(function(i){r[i.subpath]=i.snapshot}),r}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r={};return Object.keys(n).forEach(function(i){r[i]=n[i].getSnapshot()}),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object);switch(n.type){case"update":return void r.emitPatch({op:"replace",path:Ef(n.name),value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"add":return void r.emitPatch({op:"add",path:Ef(n.name),value:n.newValue.snapshot,oldValue:void 0},r);case"delete":var i=n.oldValue.snapshot;return n.oldValue.die(),void r.emitPatch({op:"remove",path:Ef(n.name),oldValue:i},r)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var a=n.storedValue;switch(i.op){case"add":case"replace":a.set(r,i.value);break;case"remove":a.delete(r);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){fu(this,r);var i=n.storedValue,a={};if(Array.from(i.keys()).forEach(function(o){a[o]=!1}),r)for(var s in r)i.set(s,r[s]),a[""+s]=!0;Object.keys(a).forEach(function(o){a[o]===!1&&i.delete(o)})}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;return cp(n)?_w(Object.keys(n).map(function(a){return i._subType.validate(n[a],QM(r,a,i._subType))})):Ma(r,n,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return qp}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.delete(r)}}),t})(Vp);dS.prototype.applySnapshot=ni(dS.prototype.applySnapshot);function ZOe(e){return new dS("Map<string, ".concat(e.name,">"),e)}var fS=(function(e){rr(t,e);function t(n,r,i){i===void 0&&(i=[]);var a=e.call(this,n)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Array}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a.hookInitializers=i,a}return Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.hookInitializers.length>0?this.hookInitializers.concat(n):[n];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return JM(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r=[]);var i=n.type._subType,a={};return r.forEach(function(s,o){var l=""+o;a[l]=i.instantiate(n,l,void 0,s)}),a}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Ca(Ca({},Ew),{name:this.name});return hr.array(Zre(n),r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){hl(r).dehancer=n.unbox;var i=n.type;i.hookInitializers.forEach(function(a){var s=a(r);Object.keys(s).forEach(function(o){var l=s[o],u=Bv(r,o,l);_f(r,o,u)})}),GM(r,this.willChange),qM(r,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue.slice()}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=Number(r);if(i<n.storedValue.length)return n.storedValue[i];throw new St("Not a child: "+r)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object);r.assertWritable({subpath:""+n.index});var i=r.type._subType,a=r.getChildren();switch(n.type){case"update":{if(n.newValue===n.object[n.index])return null;var s=Yz(r,i,[a[n.index]],[n.newValue],[n.index]);if(!s)return null;n.newValue=s[0]}break;case"splice":{var o=n.index,l=n.removedCount,u=n.added,f=Yz(r,i,a.slice(o,o+l),u,u.map(function(p,m){return o+m}));if(!f)return null;n.added=f;for(var d=o+l;d<a.length;d++)a[d].setParent(r,""+(d+u.length-l))}break}return n}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.getChildren().map(function(r){return r.snapshot})}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=[];return Object.keys(n).forEach(function(i){r.push(n[i].getSnapshot())}),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object);switch(n.type){case"update":return void r.emitPatch({op:"replace",path:""+n.index,value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"splice":if(n.removedCount&&n.addedCount===n.object.length)return void r.emitPatch({op:"replace",path:"",value:r.snapshot,oldValue:n.removed.map(function(a){return a.snapshot})},r);for(var i=n.removedCount-1;i>=0;i--)r.emitPatch({op:"remove",path:""+(n.index+i),oldValue:n.removed[i].snapshot},r);for(var i=0;i<n.addedCount;i++)r.emitPatch({op:"add",path:""+(n.index+i),value:n.added[i].snapshot,oldValue:void 0},r);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var a=n.storedValue,s=r==="-"?a.length:Number(r);switch(i.op){case"replace":a[s]=i.value;break;case"add":a.splice(s,0,i.value);break;case"remove":a.splice(s,1);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){fu(this,r);var i=n.storedValue;i.replace(r)}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;return Qre(n)?_w(n.map(function(a,s){return i._subType.validate(a,QM(r,""+s,i._subType))})):Ma(r,n,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Gp}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.splice(Number(r),1)}}),t})(Vp);fS.prototype.applySnapshot=ni(fS.prototype.applySnapshot);function QOe(e){return new fS("".concat(e.name,"[]"),e)}function Yz(e,t,n,r,i){for(var a=!0,s=0;;s++){var o=s<=r.length-1,l=n[s],u=o?r[s]:void 0,f=""+i[s];if(AOe(u)&&(u=u.storedValue),!l&&!o)break;if(!o)a=!1,n.splice(s,1),l instanceof Ia&&l.createObservableInstanceIfNeeded(),l.die(),s--;else if(l)if(Xz(l,u))n[s]=Ok(t,e,f,u,l);else{for(var p=void 0,m=s;m<n.length;m++)if(Xz(n[m],u)){p=n.splice(m,1)[0];break}a=!1;var d=Ok(t,e,f,u,p);n.splice(s,0,d)}else{if(Sr(u)&&On(u).parent===e)throw new St("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(e.path,"/").concat(f,"', but it lives already at '").concat(On(u).path,"'"));a=!1;var d=Ok(t,e,f,u);n.splice(s,0,d)}}return a?null:n}function Ok(e,t,n,r,i){fu(e,r);function a(){if(Sr(r)){var o=On(r);if(o.assertAlive(qp),o.parent!==null&&o.parent===t)return o.setParent(t,n),o}return i?e.reconcile(i,r,t,n):e.instantiate(t,n,void 0,r)}var s=a();return i&&i!==s&&(i instanceof Ia&&i.createObservableInstanceIfNeeded(),i.die()),s}function Xz(e,t){if(!e.isAlive)return!1;if(Sr(t)){var n=On(t);return n.isAlive&&n===e}if(e.snapshot===t)return!0;if(!(e instanceof Ia))return!1;var r=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&cp(t)&&r.is(t)&&r.isMatchingSnapshotId(e,t)}var Zz="preProcessSnapshot",Qz="postProcessSnapshot";function JOe(){return On(this).toString()}var Jz={name:"AnonymousModel",properties:{},initializers:Gp};function eRe(e){var t=Object.keys(e),n=new Set;return t.forEach(function(r){if(n.has(r))throw new St("".concat(r," is declared twice in the model. Model should not contain the same keys"));n.add(r)}),t.reduce(function(r,i){if(i in ti)throw new St("Hook '".concat(i,"' was defined as property. Hooks should be defined as part of the actions"));var a=Object.getOwnPropertyDescriptor(e,i);if("get"in a)throw new St("Getters are not supported as properties. Please use views instead");var s=a.value;if(s==null)throw new St("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Uv(s))r[i]=Sf(oRe(s),s);else if(s instanceof dS)r[i]=Sf(s,{});else if(s instanceof fS)r[i]=Sf(s,[]);else if(!Tu(s))throw new St("Invalid type definition for property '".concat(i,"', cannot infer a type from a value like '").concat(s,"' (").concat(typeof s,")"));return r},Ca({},e))}var $v=(function(e){rr(t,e);function t(n){var r=e.call(this,n.name||Jz.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return r.cloneAndEnhance({name:i})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return r.cloneAndEnhance({properties:i})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=r.preProcessor;return a?r.cloneAndEnhance({preProcessor:function(s){return a(i(s))}}):r.cloneAndEnhance({preProcessor:i})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=r.postProcessor;return a?r.cloneAndEnhance({postProcessor:function(s){return i(a(s))}}):r.cloneAndEnhance({postProcessor:i})}}),Object.assign(r,Jz,n),r.properties=eRe(r.properties),r.properties,r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return Object.defineProperty(t.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=void 0;return this.forAllProps(function(r,i){if(i.flags&_n.Identifier){if(n)throw new St("Cannot define property '".concat(r,"' as object identifier, property '").concat(n,"' is already defined as identifier property"));n=r}}),n}}),Object.defineProperty(t.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return new t({name:n.name||this.name,properties:Object.assign({},this.properties,n.properties),initializers:this.initializers.concat(n.initializers||[]),preProcessor:n.preProcessor||this.preProcessor,postProcessor:n.postProcessor||this.postProcessor})}}),Object.defineProperty(t.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(a){return r.instantiateActions(a,n(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!cp(r))throw new St("actions initializer should return a plain object containing actions");Object.getOwnPropertyNames(r).forEach(function(a){if(a in i.properties)throw new St("'".concat(a,"' is a property and cannot be declared as an action"));if(a===Zz)throw new St("Cannot define action '".concat(Zz,"', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if(a===Qz)throw new St("Cannot define action '".concat(Qz,"', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var s=r[a],o=n[a];if(a in ti&&o){var l=s;s=function(){o.apply(null,arguments),l.apply(null,arguments)}}var u=s.$mst_middleware,f=s.bind(r);f._isFlowAction=s._isFlowAction||!1,f.$mst_middleware=u;var d=Bv(n,a,f);r[a]=d,_f(n,a,d)})}}),Object.defineProperty(t.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;if(typeof n!="function")throw new St("You passed an ".concat(typeof n," to volatile state as an argument, when function is expected"));var i=function(a){return r.instantiateVolatileState(a,n(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!cp(r))throw new St("volatile state initializer should return a plain object containing state");Object.getOwnPropertyNames(r).forEach(function(a){if(a in i.properties)throw new St("'".concat(a,"' is a property and cannot be declared as volatile state"));Rre(n,a,r[a])})}}),Object.defineProperty(t.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(a){var s=n(a),o=s.actions,l=s.views,u=s.state,f=lOe(s,["actions","views","state"]);for(var d in f)throw new St("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(d,"'"));return u&&r.instantiateVolatileState(a,u),l&&r.instantiateViews(a,l),o&&r.instantiateActions(a,o),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(a){return r.instantiateViews(a,n(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!cp(r))throw new St("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach(function(a){var s;if(a in i.properties)throw new St("'".concat(a,"' is a property and cannot be declared as a view"));var o=Object.getOwnPropertyDescriptor(r,a);if("get"in o)Nre(n,a,o),Dre(n,(s={},s[a]=Um,s));else if(typeof o.value=="function")_f(n,a,o.value);else throw new St("A view member should either be a function or getter based property")})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?a:this.applySnapshotPreProcessor(a);return JM(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r={});var i=n.type,a={};return i.forAllProps(function(s,o){a[s]=o.instantiate(n,s,void 0,r[s])}),a}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Ca(Ca({},Ew),{name:this.name});return hr.object(n,qp,r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){_f(r,"toString",JOe),this.forAllProps(function(i){Are(r,i,n.unbox)}),this.initializers.reduce(function(i,a){return a(i)},r),GM(r,this.willChange),qM(r,this.didChange)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=On(r.object),a=r.name;i.assertWritable({subpath:a});var s=i.type.properties[a];return s&&(fu(s,r.newValue),r.newValue=s.reconcile(i.getChildNode(a),r.newValue,i,a)),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=On(r.object),a=i.type.properties[r.name];if(a){var s=r.oldValue?r.oldValue.snapshot:void 0;i.emitPatch({op:"replace",path:Ef(r.name),value:r.newValue.snapshot,oldValue:s},i)}}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=[];return this.forAllProps(function(a){i.push(r.getChildNode(n,a))}),i}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i;if(!(r in this.properties))throw new St("Not a value property: "+r);var a=hl(n.storedValue,r),s=(i=a.raw)===null||i===void 0?void 0:i.call(a);if(!s)throw new St("Node not available for property "+r);return s}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;r===void 0&&(r=!0);var a={};return this.forAllProps(function(s,o){var l=Wp(n.storedValue,s);l.reportObserved(),a[s]=i.getChildNode(n,s).snapshot}),r?this.applySnapshotPostProcessor(a):a}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r={};return Object.keys(n).forEach(function(i){r[i]=n[i].getSnapshot()}),this.applySnapshotPostProcessor(r)}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){if(!(i.op==="replace"||i.op==="add"))throw new St("object does not support operation ".concat(i.op));n.storedValue[r]=i.value}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){fu(this,r);var i=this.applySnapshotPreProcessor(r);this.forAllProps(function(a){n.storedValue[a]=i[a]})}}),Object.defineProperty(t.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.preProcessor;return r?r.call(null,n):n}}),Object.defineProperty(t.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.postProcessor;return r?r.call(null,n):n}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.properties[n]}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this,a=this.applySnapshotPreProcessor(n);return cp(a)?_w(this.propertyNames.map(function(s){return i.properties[s].validate(a[s],QM(r,s,i.properties[s]))})):Ma(r,a,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;this.propertyNames.forEach(function(i){return n(i,r.properties[i])})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this;return"{ "+this.propertyNames.map(function(r){return r+": "+n.properties[r].describe()}).join("; ")+" }"}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return qp}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue[r]=void 0}}),t})(Vp);$v.prototype.applySnapshot=ni($v.prototype.applySnapshot);function tRe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():"AnonymousModel",r=e.shift()||{};return new $v({name:n,properties:r})}function nRe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string",r=n?e[0]:"AnonymousModel";return n&&e.shift(),e.reduce(function(i,a){return i.cloneAndEnhance({name:i.name+"_"+a.name,properties:a.properties,initializers:a.initializers,preProcessor:function(s){return a.applySnapshotPreProcessor(i.applySnapshotPreProcessor(s))},postProcessor:function(s){return a.applySnapshotPostProcessor(i.applySnapshotPostProcessor(s))}})}).named(r)}function rRe(e){return Tu(e)&&(e.flags&_n.Object)>0}var Mu=(function(e){rr(t,e);function t(n,r,i,a){a===void 0&&(a=NOe);var s=e.call(this,n)||this;return Object.defineProperty(s,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"checker",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:a}),s.flags=r,s}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return fd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.initializer(n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(Uv(n)&&this.checker(n))return Da();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return Ma(r,n,"Value is not a ".concat(i))}}),t})(Jf),aie=new Mu("string",_n.String,function(e){return typeof e=="string"}),sie=new Mu("number",_n.Number,function(e){return typeof e=="number"}),iRe=new Mu("integer",_n.Integer,function(e){return IOe(e)}),aRe=new Mu("float",_n.Float,function(e){return DOe(e)}),sRe=new Mu("finite",_n.Finite,function(e){return LOe(e)}),oie=new Mu("boolean",_n.Boolean,function(e){return typeof e=="boolean"}),lie=new Mu("null",_n.Null,function(e){return e===null}),uie=new Mu("undefined",_n.Undefined,function(e){return e===void 0}),cie=new Mu("Date",_n.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});cie.getSnapshot=function(e){return e.storedValue.getTime()};var die=cie;function oRe(e){switch(typeof e){case"string":return aie;case"number":return sie;case"boolean":return oie;case"object":if(e instanceof Date)return die}throw new St("Cannot determine primitive type from value "+e)}function lRe(e){return Tu(e)&&(e.flags&(_n.String|_n.Number|_n.Integer|_n.Boolean|_n.Date))>0}var uRe=(function(e){rr(t,e);function t(n){var r=e.call(this,JSON.stringify(n))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Literal}),r.value=n,r}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return fd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return Uv(n)&&n===this.value?Da():Ma(r,n,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t})(Jf);function fie(e){return new uRe(e)}var cRe=(function(e){rr(t,e);function t(n,r,i,a){var s=e.call(this,n)||this;return Object.defineProperty(s,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_message",{enumerable:!0,configurable:!0,writable:!0,value:a}),s}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|_n.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._subtype.instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._subtype.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this._subtype.validate(n,r);if(i.length>0)return i;var a=Sr(n)?On(n).snapshot:n;return this._predicate(a)?Da():Ma(r,n,this._message(n))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._subtype.reconcile(n,r,i,a)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t})(wu);function dRe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():Tu(e[0])?e[0].name:null,r=e[0],i=e[1],a=e[2]?e[2]:function(s){return"Value does not respect the refinement predicate"};return new cRe(n,r,i,a)}function fRe(e,t){var n=typeof e=="string"?t:e,r=Sw.apply(void 0,xu([],Su(n.map(function(i){return fie(""+i)})),!1));return typeof e=="string"&&(r.name=e),r}var hRe=(function(e){rr(t,e);function t(n,r,i){var a=e.call(this,n)||this;return Object.defineProperty(a,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),i=Ca({eager:!0,dispatcher:void 0},i),a._dispatcher=i.dispatcher,i.eager||(a._eager=!1),a}return Object.defineProperty(t.prototype,"flags",{get:function(){var n=_n.Union;return this._types.forEach(function(r){n|=r.flags}),n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._types.some(function(r){return r.isAssignableFrom(n)})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(n){return n.describe()}).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this.determineType(a,void 0);if(!s)throw new St("No matching type for union "+this.describe());return s.instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this.determineType(r,n.getReconciliationType());if(!s)throw new St("No matching type for union "+this.describe());return s.reconcile(n,r,i,a)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this._dispatcher?this._dispatcher(n):r?r.is(n)?r:this._types.filter(function(i){return i!==r}).find(function(i){return i.is(n)}):this._types.find(function(i){return i.is(n)})}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this._dispatcher)return this._dispatcher(n).validate(n,r);for(var i=[],a=0,s=0;s<this._types.length;s++){var o=this._types[s],l=o.validate(n,r);if(l.length===0){if(this._eager)return Da();a++}else i.push(l)}return a===1?Da():Ma(r,n,"No type is applicable for the union").concat(_w(i))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t})(wu);function Sw(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=Tu(e)?void 0:e,i=Tu(e)?xu([e],Su(t),!1):t,a="("+i.map(function(s){return s.name}).join(" | ")+")";return new hRe(a,i,r)}function pRe(e){return Tu(e)&&(e.flags&_n.Union)>0}var mRe=(function(e){rr(t,e);function t(n,r,i){var a=e.call(this,n.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|_n.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(this.optionalValues.indexOf(a)>=0){var s=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(n,r,i,s)}return this._subtype.instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._subtype.reconcile(n,this.optionalValues.indexOf(r)<0&&this._subtype.is(r)?r:this.getDefaultInstanceOrSnapshot(),i,a)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=typeof this._defaultValue=="function"?this._defaultValue():this._defaultValue;return typeof this._defaultValue=="function"&&fu(this,n),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.optionalValues.indexOf(n)>=0?Da():this._subtype.validate(n,r)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._subtype.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t})(wu);function gRe(e,t){if(typeof t!="function"&&Sr(t))throw new St("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}function Sf(e,t,n){return gRe(e,t),new mRe(e,t,n||bRe)}var bRe=[void 0],vRe=Sf(uie,void 0),yRe=Sf(lie,null);function hie(e){return Sw(e,vRe)}function _Re(e){return Sw(e,yRe)}var ERe=(function(e){rr(t,e);function t(n,r){var i=e.call(this,n)||this;return Object.defineProperty(i,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i}return Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|_n.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(!this._subType){var r=void 0;try{r=this._definition()}catch(i){if(i instanceof ReferenceError)r=void 0;else throw i}if(n&&r===void 0)throw new St("Late type seems to be used too early, the definition (still) returns undefined");r&&(this._subType=r)}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this.getSubType(!0).instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this.getSubType(!0).reconcile(n,r,i,a)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this.getSubType(!1);return n?n.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this.getSubType(!1);return i?i.validate(n,r):Da()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.getSubType(!1);return r?r.isAssignableFrom(n):!1}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this.getSubType(!1);return n||Vre}}),t})(wu);function SRe(e,t){var n=typeof e=="string"?e:"late(".concat(e.toString(),")"),r=typeof e=="string"?t:e;return new ERe(n,r)}function xRe(e,t){return new wRe(e,t)}var wRe=(function(e){rr(t,e);function t(n,r){var i=e.call(this,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:hr.array()}),Lz(function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some(function(a){return a.isAlive&&i.options.shouldLoadPredicate(a.parent?a.parent.value:null)})},function(){i.options.loadType().then(ni(function(a){i.loadedType=a,i.pendingNodeList.forEach(function(s){s.parent&&i.loadedType&&s.parent.applyPatches([{op:"replace",path:"/".concat(s.subpath),value:s.snapshot}])})}))}),i}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<lazy ".concat(this.name,">")}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this;if(this.loadedType)return this.loadedType.instantiate(n,r,i,a);var o=fd(this,n,r,i,a);return this.pendingNodeList.push(o),Lz(function(){return!o.isAlive},function(){return s.pendingNodeList.splice(s.pendingNodeList.indexOf(o),1)}),o}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.loadedType?this.loadedType.validate(n,r):tie(n)?Da():Ma(r,n,"Value is not serializable and cannot be lazy")}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this.loadedType?(n.die(),this.loadedType.instantiate(i,a,i.environment,r)):e.prototype.reconcile.call(this,n,r,i,a)}}),t})(Jf),pie=(function(e){rr(t,e);function t(n){var r=e.call(this,n?"frozen(".concat(n.name,")"):"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Frozen}),r}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return fd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return tie(n)?this.subType?this.subType.validate(n,r):Da():Ma(r,n,"Value is not serializable and cannot be frozen")}}),t})(Jf),eH=new pie;function TRe(e){return arguments.length===0?eH:Tu(e)?new pie(e):Sf(eH,e)}function CRe(e){switch(e){case ti.beforeDestroy:return"destroy";case ti.beforeDetach:return"detach";default:return}}var ARe=(function(){function e(t,n){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e3(t))this.identifier=t;else if(Sr(t)){var r=On(t);if(!r.identifierAttribute)throw new St("Can only store references with a defined identifier attribute.");var i=r.unnormalizedIdentifier;if(i==null)throw new St("Can only store references to tree nodes with a defined identifier.");this.identifier=i}else throw new St("Can only store references to tree nodes or identifiers, got: '".concat(t,"'"))}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=h0(this.identifier),r=t.root,i=r.identifierCache.getLastCacheModificationPerId(n);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==i){var a=this.targetType,s=r.identifierCache.resolve(a,n);if(!s)throw new kRe("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(t.path,")"));this.resolvedReference={node:s,lastCacheModification:i}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e})(),kRe=(function(e){rr(t,e);function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return t})(Error),mie=(function(e){rr(t,e);function t(n,r){var i=e.call(this,"reference(".concat(n.name,")"))||this;return Object.defineProperty(i,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Reference}),i}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.targetType.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return e3(n)?Da():Ma(r,n,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(t.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=r.parent;if(!(!s||!s.isAlive)){var o=s.storedValue;o&&this.onInvalidated({cause:n,parent:o,invalidTarget:a?a.storedValue:void 0,invalidId:i,replaceRef:function(l){jv(r.root.storedValue,{op:"replace",value:l,path:r.path})},removeRef:function(){rRe(s.type)?this.replaceRef(void 0):jv(r.root.storedValue,{op:"remove",path:r.path})}})}}}),Object.defineProperty(t.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this,a=this.getValue(n);if(a){var s=On(a),o=function(f,d){var p=CRe(d);p&&i.fireInvalidated(p,n,r,s)},l=s.registerHook(ti.beforeDetach,o),u=s.registerHook(ti.beforeDestroy,o);return function(){l(),u()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var a=this;if(this.onInvalidated){var s;n.registerHook(ti.beforeDestroy,function(){s&&s()});var o=function(l){s&&s();var u=n.parent,f=u&&u.storedValue;if(u&&u.isAlive&&f){var d=void 0;i?d=!!i.get(r,f):d=n.root.identifierCache.has(a.targetType,h0(r)),d?s=a.addTargetNodeWatcher(n,r):l||a.fireInvalidated("invalidSnapshotReference",n,r,null)}};n.state===ki.FINALIZED?o(!0):(n.isRoot||n.root.registerHook(ti.afterCreationFinalization,function(){n.parent&&n.parent.createObservableInstanceIfNeeded()}),n.registerHook(ti.afterAttach,function(){o(!1)}))}}}),t})(Jf),ORe=(function(e){rr(t,e);function t(n,r){return e.call(this,n,r)||this}return Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(n.isAlive){var r=n.storedValue;return r.resolvedValue}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n.storedValue;return r.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?fOe(a):a,o=new ARe(a,this.targetType),l=fd(this,n,r,i,o);return o.node=l,this.watchTargetNodeForInvalidations(l,s,void 0),l}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(!n.isDetaching&&n.type===this){var s=Sr(r),o=n.storedValue;if(!s&&o.identifier===r||s&&o.resolvedValue===r)return n.setParent(i,a),n}var l=this.instantiate(i,a,void 0,r);return n.die(),l}}),t})(mie),RRe=(function(e){rr(t,e);function t(n,r,i){var a=e.call(this,n,i)||this;return Object.defineProperty(a,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),a}return Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(n.isAlive){var r=this.options.get(n.storedValue,n.parent?n.parent.storedValue:null);return r}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?this.options.set(a,n?n.storedValue:null):a,o=fd(this,n,r,i,s);return this.watchTargetNodeForInvalidations(o,s,this.options),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(r)?this.options.set(r,n?n.storedValue:null):r;if(!n.isDetaching&&n.type===this&&n.storedValue===s)return n.setParent(i,a),n;var o=this.instantiate(i,a,void 0,s);return n.die(),o}}),t})(mie);function gie(e,t){var n=t||void 0,r=t?t.onInvalidated:void 0;return n&&(n.get||n.set)?new RRe(e,{get:n.get,set:n.set},r):new ORe(e,r)}function NRe(e,t){var n=gie(e,Ca(Ca({},t),{onInvalidated:function(r){t&&t.onInvalidated&&t.onInvalidated(r),r.removeRef()}}));return t&&t.acceptsUndefined===!1?n:hie(n)}var bie=(function(e){rr(t,e);function t(n,r){var i=e.call(this,n)||this;return Object.defineProperty(i,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Identifier}),i}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(!n||!(n.type instanceof $v))throw new St("Identifier types can only be instantiated as direct child of a model type");return fd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(n.storedValue!==r)throw new St("Tried to change identifier from '".concat(n.storedValue,"' to '").concat(r,"'. Changing identifiers is not allowed."));return n.setParent(i,a),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return typeof n!==this.validType?Ma(r,n,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):Da()}}),t})(Jf),IRe=(function(e){rr(t,e);function t(){var n=e.call(this,"identifier","string")||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Identifier}),n}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t})(bie),DRe=(function(e){rr(t,e);function t(){return e.call(this,"identifierNumber","number")||this}return Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t})(bie),LRe=new IRe,PRe=new DRe;function h0(e){return""+e}function e3(e){return typeof e=="string"||typeof e=="number"}function MRe(e){return new jRe(e)}var jRe=(function(e){rr(t,e);function t(n){var r=e.call(this,n.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Custom}),r}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this.options.isTargetType(n))return Da();var i=this.options.getValidationMessage(n);return i?Ma(r,n,"Invalid value for type '".concat(this.name,"': ").concat(i)):Da()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.options.toSnapshot(n.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this.options.isTargetType(a)?a:this.options.fromSnapshot(a,n&&n.root.environment);return fd(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=!this.options.isTargetType(r);if(!n.isDetaching){var o=n.type===this&&(s?r===n.snapshot:r===n.storedValue);if(o)return n.setParent(i,a),n}var l=s?this.options.fromSnapshot(r,i.root.environment):r,u=this.instantiate(i,a,void 0,l);return n.die(),u}}),t})(Jf),Ot={enumeration:fRe,model:tRe,compose:nRe,custom:MRe,reference:gie,safeReference:NRe,union:Sw,optional:Sf,literal:fie,maybe:hie,maybeNull:_Re,refinement:dRe,string:aie,boolean:oie,number:sie,integer:iRe,float:aRe,finite:sRe,Date:die,map:ZOe,array:QOe,frozen:TRe,identifier:LRe,identifierNumber:PRe,late:SRe,lazy:xRe,undefined:uie,null:lie,snapshotProcessor:YOe};const FRe=Ot.enumeration("TerminalStatus",["running","exited","error"]),BRe=Ot.model("Terminal",{id:Ot.identifier,name:Ot.string,cwd:Ot.string,status:FRe,exitCode:Ot.maybe(Ot.number),cols:Ot.number,rows:Ot.number,createdAt:Ot.number,tabId:Ot.maybeNull(Ot.string),positionInTab:Ot.optional(Ot.number,0)}).volatile(()=>({xterm:null,attachCleanup:null,isPending:!1,pendingId:null,isStartingUp:!1})).views(e=>({get isAlive(){return e.status==="running"},get isTabTerminal(){return e.tabId!=null}})).actions(e=>({updateFromServer(t){t.name!==void 0&&(e.name=t.name),t.cwd!==void 0&&(e.cwd=t.cwd),t.status!==void 0&&(e.status=t.status),t.exitCode!==void 0&&(e.exitCode=t.exitCode),t.cols!==void 0&&(e.cols=t.cols),t.rows!==void 0&&(e.rows=t.rows),t.tabId!==void 0&&(e.tabId=t.tabId),t.positionInTab!==void 0&&(e.positionInTab=t.positionInTab)},setXterm(t){e.xterm=t},setAttachCleanup(t){e.attachCleanup=t},markExited(t){e.status="exited",e.exitCode=t},assignToTab(t,n){e.tabId=t,n!==void 0&&(e.positionInTab=n)},rename(t){e.name=t},resize(t,n){e.cols=t,e.rows=n},setPending(t,n){e.isPending=t,n!==void 0&&(e.pendingId=n)},setStartingUp(t){e.isStartingUp=t},cleanup(){e.attachCleanup&&(e.attachCleanup(),e.attachCleanup=null),e.xterm=null}})),URe=Ot.model("Tab",{id:Ot.identifier,name:Ot.string,position:Ot.number,directory:Ot.maybeNull(Ot.string),createdAt:Ot.number}).volatile(()=>({isPending:!1})).views(e=>({get terminals(){const t=zre(e);return t.terminals?.items?t.terminals.items.filter(n=>n.tabId===e.id).sort((n,r)=>n.positionInTab-r.positionInTab):[]},get terminalCount(){return this.terminals.length}})).actions(e=>({updateFromServer(t){t.name!==void 0&&(e.name=t.name),t.directory!==void 0&&(e.directory=t.directory),t.position!==void 0&&(e.position=t.position)},rename(t){e.name=t},setDirectory(t){e.directory=t},setPosition(t){e.position=t},setPending(t){e.isPending=t}})),$Re=Ot.map(Ot.string),zRe=Ot.model("ViewState",{focusedTerminals:Ot.optional($Re,{}),currentView:Ot.maybeNull(Ot.string),currentTaskId:Ot.maybeNull(Ot.string),isTabVisible:Ot.maybeNull(Ot.boolean),viewUpdatedAt:Ot.maybeNull(Ot.string)}).volatile(()=>({pendingUpdates:{},debounceTimer:null})).views(e=>({getFocusedTerminal(t){return e.focusedTerminals.get(t)??null}})).actions(e=>({setFocusedTerminal(t,n){n===null?e.focusedTerminals.delete(t):e.focusedTerminals.set(t,n)},clearFocusedTerminalForTab(t){e.focusedTerminals.delete(t)},updateViewTracking(t,n){e.currentView=t,e.currentTaskId=n,e.viewUpdatedAt=new Date().toISOString()},setTabVisible(t){e.isTabVisible=t,e.viewUpdatedAt=new Date().toISOString()},hydrateFromServer(t){if(t.focusedTerminals){e.focusedTerminals.clear();for(const[n,r]of Object.entries(t.focusedTerminals))e.focusedTerminals.set(n,r)}t.currentView!==void 0&&(e.currentView=t.currentView),t.currentTaskId!==void 0&&(e.currentTaskId=t.currentTaskId),t.isTabVisible!==void 0&&(e.isTabVisible=t.isTabVisible),t.viewUpdatedAt!==void 0&&(e.viewUpdatedAt=t.viewUpdatedAt)}}));function xD(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function tH(){return`temp-${xD()}`}const HRe=Ot.model("TerminalsStore",{items:Ot.array(BRe)}).views(e=>({get(t){return e.items.find(n=>n.id===t)},getByTab(t){return e.items.filter(n=>n.tabId===t).sort((n,r)=>n.positionInTab-r.positionInTab)},get taskTerminals(){return e.items.filter(t=>t.tabId==null)},has(t){return e.items.some(n=>n.id===t)}})).actions(e=>({add(t){if(e.items.some(n=>n.id===t.id)){At.ws.debug("Terminal already exists, skipping add",{id:t.id});return}e.items.push(t)},remove(t){const n=e.items.find(r=>r.id===t);n&&(n.cleanup(),cS(n))},replaceAll(t){for(const n of e.items)n.cleanup();e.items.clear();for(const n of t)e.items.push(n)},clear(){for(const t of e.items)t.cleanup();e.items.clear()}})),WRe=Ot.model("TabsStore",{items:Ot.array(URe)}).views(e=>({get(t){return e.items.find(n=>n.id===t)},get sorted(){return[...e.items].sort((t,n)=>t.position-n.position)},has(t){return e.items.some(n=>n.id===t)},get first(){return this.sorted[0]}})).actions(e=>({add(t){if(e.items.some(n=>n.id===t.id)){At.ws.debug("Tab already exists, skipping add",{id:t.id});return}e.items.push(t)},remove(t){const n=e.items.find(r=>r.id===t);n&&cS(n)},replaceAll(t){e.items.clear();for(const n of t)e.items.push(n)},clear(){e.items.clear()}})),VRe=Ot.model("RootStore",{terminals:Ot.optional(HRe,{items:[]}),tabs:Ot.optional(WRe,{items:[]}),viewState:Ot.optional(zRe,{})}).volatile(()=>({connected:!1,initialized:!1,hasEverConnected:!1,reconnectAttempt:0,maxReconnectAttempts:10,newTerminalIds:new Set,pendingUpdates:new Map,onAttachedCallbacks:new Map,terminalsReadyForCallback:new Set,lastFocusedTerminalId:null,terminalsPendingStartup:new Map,pendingTabCreation:null,lastCreatedTabId:null,broadcastedTheme:null})).views(e=>({get isReady(){return e.connected&&e.initialized}})).actions(e=>{const t=()=>hOe(e);return{setConnected(n){const r=e.connected;if(e.connected=n,!n)e.initialized=!1;else if(!r&&n&&(e.hasEverConnected=!0,e.reconnectAttempt=0,e.pendingUpdates.size>0)){t().log.ws.info("Reconnected: clearing stale pending updates",{count:e.pendingUpdates.size});for(const i of e.pendingUpdates.values())if(i.entityType==="terminal"){const a=e.terminals.get(i.tempId);a&&(a.cleanup(),e.terminals.remove(i.tempId)),e.newTerminalIds.delete(i.tempId)}else i.entityType==="tab"&&e.tabs.remove(i.tempId);e.pendingUpdates.clear()}},setInitialized(n){e.initialized=n},setReconnectAttempt(n){e.reconnectAttempt=n},setMaxReconnectAttempts(n){e.maxReconnectAttempts=n},markNewTerminal(n){e.newTerminalIds.add(n)},clearNewTerminal(n){e.newTerminalIds.delete(n)},setLastFocusedTerminal(n){e.lastFocusedTerminalId=n},consumePendingStartup(n){const r=e.terminalsPendingStartup.get(n);return r&&(e.terminalsPendingStartup.delete(n),t().log.ws.info("consumed pending startup",{terminalId:n,taskName:r.taskName})),r},clearStartingUp(n){const r=e.terminals.get(n);r&&(r.setStartingUp(!1),t().log.ws.info("cleared isStartingUp",{terminalId:n}))},setPendingTabCreation(n){e.pendingTabCreation=n},clearLastCreatedTabId(){e.lastCreatedTabId=null},syncTheme(n){t().send({type:"theme:sync",payload:{theme:n}})},clearBroadcastedTheme(){e.broadcastedTheme=null},createTerminal(n){const r=xD(),i=tH(),a={id:i,name:n.name,cwd:n.cwd??"~",status:"running",cols:n.cols,rows:n.rows,createdAt:Date.now(),tabId:n.tabId??null,positionInTab:n.positionInTab??0},s=Gz(e.terminals);e.terminals.add(a),s.stop();const o=e.terminals.get(i);o?.setPending(!0,i),e.pendingUpdates.set(r,{entityType:"terminal",tempId:i,inversePatches:s.inversePatches,createdAt:Date.now()}),e.newTerminalIds.add(i),n.startup&&(e.terminalsPendingStartup.set(i,n.startup),o?.setStartingUp(!0),t().log.ws.info("createTerminal registered startup",{tempId:i,taskName:n.startup.taskName,isStartingUp:o?.isStartingUp}));const{startup:l,...u}=n;t().send({type:"terminal:create",payload:{...u,requestId:r,tempId:i}}),t().log.ws.debug("createTerminal optimistic",{requestId:r,tempId:i,name:n.name})},destroyTerminal(n,r){t().send({type:"terminal:destroy",payload:{terminalId:n,force:r?.force,reason:r?.reason}});const i=e.terminals.get(n);i&&i.cleanup(),e.terminals.remove(n)},writeToTerminal(n,r){t().send({type:"terminal:input",payload:{terminalId:n,data:r}})},sendInputToTerminal(n,r){t().send({type:"terminal:input",payload:{terminalId:n,data:r}}),setTimeout(()=>{t().send({type:"terminal:input",payload:{terminalId:n,data:"\r"}})},50)},resizeTerminal(n,r,i){t().send({type:"terminal:resize",payload:{terminalId:n,cols:r,rows:i}}),e.terminals.get(n)?.resize(r,i)},renameTerminal(n,r){t().send({type:"terminal:rename",payload:{terminalId:n,name:r}}),e.terminals.get(n)?.rename(r)},attachXterm(n,r,i){const a=e.terminals.get(n);if(!a)return t().log.ws.warn("attachXterm: terminal not found",{terminalId:n}),()=>{};if(a.xterm===r)return t().log.ws.debug("attachXterm: already attached, skipping",{terminalId:n}),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):e.onAttachedCallbacks.set(n,i.onAttached)),a.attachCleanup||(()=>{});a.attachCleanup&&a.attachCleanup(),a.setXterm(r),r.attachCustomKeyEventHandler(u=>u.type==="keydown"&&u.shiftKey&&u.key==="Enter"?(u.preventDefault(),u.stopPropagation(),t().send({type:"terminal:input",payload:{terminalId:n,data:`
|
|
31
|
-
`}}),!1):(u.type==="keydown"&&u.key==="Escape"&&window.parent!==window&&u.stopPropagation(),!0));const s=r.onData(u=>{t().send({type:"terminal:input",payload:{terminalId:n,data:u}})}),o=()=>{this.setLastFocusedTerminal(n)};r.textarea?.addEventListener("focus",o),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(t().log.ws.debug("attachXterm: terminal already attached, calling callback immediately",{terminalId:n}),e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):(t().log.ws.debug("attachXterm: registering onAttached callback",{terminalId:n,existingCallbacks:Array.from(e.onAttachedCallbacks.keys())}),e.onAttachedCallbacks.set(n,i.onAttached)));const l=()=>{s.dispose(),r.textarea?.removeEventListener("focus",o),e.terminals.get(n)?.setXterm(null)};return a.setAttachCleanup(l),t().send({type:"terminal:attach",payload:{terminalId:n}}),l},requestAttach(n){t().send({type:"terminal:attach",payload:{terminalId:n}})},clearTerminalBuffer(n){t().send({type:"terminal:clearBuffer",payload:{terminalId:n}})},assignTerminalToTab(n,r,i){t().send({type:"terminal:assignTab",payload:{terminalId:n,tabId:r,positionInTab:i}}),e.terminals.get(n)?.assignToTab(r,i)},createTab(n,r,i,a){const s=xD(),o=tH(),l=r??e.tabs.items.length,u={id:o,name:n,position:l,directory:i??null,createdAt:Date.now()},f=Gz(e.tabs);e.tabs.add(u),f.stop(),e.tabs.get(o)?.setPending(!0),e.pendingTabCreation=o,e.pendingUpdates.set(s,{entityType:"tab",tempId:o,inversePatches:f.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,adoptTerminalId:a,requestId:s,tempId:o}}),t().log.ws.debug("createTab optimistic",{requestId:s,tempId:o,name:n,adoptTerminalId:a})},updateTab(n,r){t().send({type:"tab:update",payload:{tabId:n,...r}}),e.tabs.get(n)?.updateFromServer(r)},deleteTab(n){t().send({type:"tab:delete",payload:{tabId:n}}),e.tabs.remove(n),e.viewState.clearFocusedTerminalForTab(n)},reorderTab(n,r){const i=e.tabs.get(n);if(!i)return;const a=i.position;if(t().send({type:"tab:reorder",payload:{tabId:n,position:r}}),r>a)for(const s of e.tabs.items)s.position>a&&s.position<=r&&s.setPosition(s.position-1);else if(r<a)for(const s of e.tabs.items)s.position>=r&&s.position<a&&s.setPosition(s.position+1);i.setPosition(r)},handleMessage(n){const{type:r,payload:i}=n;switch(r){case"terminals:list":e.terminals.replaceAll(i.terminals);break;case"terminal:created":{const{terminal:a,isNew:s,requestId:o,tempId:l}=i;if(o&&l){const u=e.pendingUpdates.get(o);if(u&&u.tempId===l){e.pendingUpdates.delete(o);const f=e.terminals.get(l);if(f){const d=f.xterm,p=e.onAttachedCallbacks.get(l),m=f.attachCleanup;if(t().log.ws.info("terminal:created optimistic handling",{tempId:l,realId:a.id,hasXterm:!!d,hasCallback:!!p,isNew:s}),m&&m(),f.setXterm(null),f.setAttachCleanup(null),e.onAttachedCallbacks.delete(l),s){const E=f.isStartingUp,S=e.terminals.items.findIndex(v=>v.id===l);S>=0&&cS(e.terminals.items[S]),e.terminals.add(a);const b=e.terminals.get(a.id);E&&b&&(b.setStartingUp(!0),t().log.ws.info("terminal:created transferred isStartingUp",{tempId:l,realId:a.id,isStartingUp:b.isStartingUp})),t().log.ws.info("terminal:created re-attaching xterm",{realId:a.id,hasRealTerminal:!!b,hasXterm:!!d,willAttach:!!(b&&d)}),b&&d?this.attachXterm(a.id,d,{onAttached:p}):p&&(t().log.ws.info("terminal:created preserving callback for later",{realId:a.id}),e.onAttachedCallbacks.set(a.id,p)),e.newTerminalIds.delete(l),e.newTerminalIds.add(a.id);const y=e.terminalsPendingStartup.get(l);y&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,y),t().log.ws.debug("transferred pending startup",{tempId:l,realId:a.id})),t().log.ws.debug("terminal:created confirmed",{requestId:o,tempId:l,realId:a.id,xtermReattached:!!d,hasPendingStartup:!!y})}else{const E=e.terminals.items.findIndex(b=>b.id===l);E>=0&&cS(e.terminals.items[E]),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l),e.terminals.has(a.id)||e.terminals.add(a),e.terminals.get(a.id)&&d&&this.attachXterm(a.id,d,{onAttached:p}),t().log.ws.debug("terminal:created deduplicated",{requestId:o,tempId:l,existingId:a.id,xtermReattached:!!d})}}break}}e.terminals.add(a),s&&e.newTerminalIds.add(a.id);break}case"terminal:destroyed":{const{terminalId:a}=i;e.terminals.remove(a),e.newTerminalIds.delete(a),e.terminalsReadyForCallback.delete(a),e.onAttachedCallbacks.delete(a);break}case"terminal:output":{const{terminalId:a,data:s}=i,o=e.terminals.get(a);o?.xterm?o.xterm.write(s):t().log.ws.warn("terminal:output but no xterm",{terminalId:a});break}case"terminal:attached":{const{terminalId:a,buffer:s}=i,o=e.terminals.get(a);t().log.ws.info("terminal:attached received",{terminalId:a,hasTerminal:!!o,hasXterm:!!o?.xterm,bufferLength:s?.length??0,hasCallback:e.onAttachedCallbacks.has(a),isReadyForCallback:e.terminalsReadyForCallback.has(a),registeredCallbacks:Array.from(e.onAttachedCallbacks.keys())});const l=()=>{const u=e.onAttachedCallbacks.get(a);u?(e.onAttachedCallbacks.delete(a),t().log.ws.debug("terminal:attached calling callback",{terminalId:a}),u(a)):(t().log.ws.debug("terminal:attached no callback yet, marking ready",{terminalId:a}),e.terminalsReadyForCallback.add(a))};o?.xterm?(o.xterm.reset(),s?o.xterm.write(s,l):l()):l();break}case"terminal:bufferCleared":{const{terminalId:a}=i,s=e.terminals.get(a);s?.xterm&&s.xterm.reset();break}case"terminal:exit":{const{terminalId:a,exitCode:s}=i;e.terminals.get(a)?.markExited(s);break}case"terminal:renamed":{const{terminalId:a,name:s}=i;e.terminals.get(a)?.rename(s);break}case"terminal:tabAssigned":{const{terminalId:a,tabId:s,positionInTab:o}=i;e.terminals.get(a)?.assignToTab(s,o);break}case"tabs:list":e.tabs.replaceAll(i.tabs),e.initialized=!0;break;case"tab:created":{const{tab:a,requestId:s,tempId:o,adoptTerminalId:l}=i;if(s&&o){const u=e.pendingUpdates.get(s);if(u&&u.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,l||(e.lastCreatedTabId=a.id),t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id,adoptTerminalId:l}));break}}e.tabs.add(a);break}case"tab:updated":{const{tabId:a,name:s,directory:o}=i;e.tabs.get(a)?.updateFromServer({name:s,directory:o});break}case"tab:deleted":{const{tabId:a}=i;e.tabs.remove(a),e.viewState.clearFocusedTerminalForTab(a);break}case"terminal:error":{const{error:a,requestId:s,tempId:o}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s);for(let u=l.inversePatches.length-1;u>=0;u--)jv(e.terminals,l.inversePatches[u]);e.newTerminalIds.delete(o),e.terminalsPendingStartup.delete(o),t().log.ws.warn("terminal:error rollback",{requestId:s,tempId:o,error:a});break}}At.ws.error("Terminal error from server",{error:a});break}case"sync:stale":{const{entityType:a,entityId:s,requestId:o,tempId:l,error:u}=i;if(t().log.ws.warn("sync:stale received",{entityType:a,entityId:s,error:u}),o&&l){const f=e.pendingUpdates.get(o);if(f&&f.tempId===l)if(e.pendingUpdates.delete(o),f.entityType==="terminal"){const d=e.terminals.get(l);d&&(d.cleanup(),e.terminals.remove(l)),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l)}else f.entityType==="tab"&&e.tabs.remove(l)}if(a==="terminal"){if(e.terminals.has(s)){const f=e.terminals.get(s);f&&(f.cleanup(),e.terminals.remove(s))}e.terminalsPendingStartup.delete(s)}else a==="tab"&&e.tabs.has(s)&&(e.tabs.remove(s),e.viewState.clearFocusedTerminalForTab(s));break}case"theme:synced":{const{theme:a}=i;e.broadcastedTheme=a,t().log.ws.debug("theme:synced received",{theme:a});break}}},reset(){e.terminals.clear(),e.tabs.clear(),e.connected=!1,e.initialized=!1,e.newTerminalIds.clear(),e.pendingUpdates.clear(),e.terminalsPendingStartup.clear()}}});function vie(){const e=zm();return k.useMemo(()=>{const t=(n,r)=>{const i=async a=>{const s=a.clipboardData?.items;if(s){for(const o of s)if(o.type.startsWith("image/")){a.preventDefault(),a.stopPropagation();const l=o.getAsFile();if(!l)return;try{const u=await Fte(l);e.writeToTerminal(r,u)}catch(u){At.ws.error("Failed to upload image",{error:String(u)})}return}}};return n.addEventListener("paste",i,!0),()=>{n.removeEventListener("paste",i,!0)}};return{get terminals(){return[...e.terminals.items]},get terminalsLoaded(){return e.initialized},get tabs(){return[...e.tabs.sorted]},get connected(){return e.connected},get newTerminalIds(){return e.newTerminalIds},get pendingTabCreation(){return e.pendingTabCreation},get lastCreatedTabId(){return e.lastCreatedTabId},createTerminal:e.createTerminal.bind(e),destroyTerminal:e.destroyTerminal.bind(e),writeToTerminal:e.writeToTerminal.bind(e),sendInputToTerminal:e.sendInputToTerminal.bind(e),resizeTerminal:e.resizeTerminal.bind(e),renameTerminal:e.renameTerminal.bind(e),clearTerminalBuffer:e.clearTerminalBuffer.bind(e),assignTerminalToTab:e.assignTerminalToTab.bind(e),createTab:e.createTab.bind(e),updateTab:e.updateTab.bind(e),deleteTab:e.deleteTab.bind(e),reorderTab:e.reorderTab.bind(e),attachXterm:e.attachXterm.bind(e),setupImagePaste:t,consumePendingStartup:e.consumePendingStartup.bind(e),clearStartingUp:e.clearStartingUp.bind(e),clearLastCreatedTabId:e.clearLastCreatedTabId.bind(e)}},[e])}const Rk="",GRe=Ot.model("File",{path:Ot.identifier,content:Ot.string,originalContent:Ot.string,mimeType:Ot.string,size:Ot.number,lineCount:Ot.number,truncated:Ot.boolean,isMarkdownView:Ot.optional(Ot.boolean,!1)}).views(e=>({get isDirty(){return e.content!==e.originalContent},get isMarkdown(){return e.path.toLowerCase().endsWith(".md")},get isImage(){return e.mimeType.startsWith("image/")},get isBinary(){return e.mimeType==="application/octet-stream"},get isEditable(){return!e.mimeType.startsWith("image/")&&e.mimeType!=="application/octet-stream"}})).actions(e=>({setContent(t){e.content=t},markSaved(){e.originalContent=e.content},toggleMarkdownView(){e.isMarkdownView=!e.isMarkdownView},setMarkdownView(t){e.isMarkdownView=t}})),qRe=Ot.model("FilesStore",{selectedFile:Ot.maybeNull(Ot.string),expandedDirs:Ot.array(Ot.string),openFiles:Ot.map(GRe)}).volatile(()=>({worktreePath:null,readOnly:!1,isLoading:!1,isSaving:!1,loadError:null,saveError:null,fileTree:null,isLoadingTree:!1,treeError:null})).views(e=>({get currentFile(){if(e.selectedFile)return e.openFiles.get(e.selectedFile)},get isDirty(){return(e.selectedFile?e.openFiles.get(e.selectedFile):void 0)?.isDirty??!1},isFileMarkdownView(t){return e.openFiles.get(t)?.isMarkdownView??!1},isDirExpanded(t){return e.expandedDirs.includes(t)}})).actions(e=>({setWorktreePath(t){e.worktreePath!==t&&(e.worktreePath=t,e.selectedFile=null,e.expandedDirs.clear(),e.openFiles.clear(),e.fileTree=null)},setReadOnly(t){e.readOnly=t},selectFile(t){e.selectedFile=t},toggleDir(t){const n=e.expandedDirs.indexOf(t);n>=0?e.expandedDirs.splice(n,1):e.expandedDirs.push(t)},collapseAll(){e.expandedDirs.clear()},updateContent(t,n){const r=e.openFiles.get(t);r&&r.setContent(n)},toggleMarkdownView(t){const n=e.openFiles.get(t);n&&n.toggleMarkdownView()},_setLoading(t){e.isLoading=t},_setLoadError(t){e.loadError=t},_setSaving(t){e.isSaving=t},_setSaveError(t){e.saveError=t},_setFileTree(t){e.fileTree=t},_setLoadingTree(t){e.isLoadingTree=t},_setTreeError(t){e.treeError=t},_addFile(t){e.openFiles.set(t.path,{path:t.path,content:t.content,originalContent:t.content,mimeType:t.mimeType,size:t.size,lineCount:t.lineCount,truncated:t.truncated,isMarkdownView:!1})},_markFileSaved(t){const n=e.openFiles.get(t);n&&n.markSaved()}})).actions(e=>({loadFileTree:Ak(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield $t(`${Rk}/api/fs/tree?root=${encodeURIComponent(e.worktreePath)}`);e._setFileTree(t.entries)}catch(t){e._setTreeError(t instanceof Error?t.message:"Failed to load file tree")}finally{e._setLoadingTree(!1)}}}),loadFile:Ak(function*(t){if(e.worktreePath){if(e.openFiles.has(t)){e.selectedFile=t;return}e._setLoading(!0),e._setLoadError(null);try{const n=new URLSearchParams({path:t,root:e.worktreePath}),r=yield $t(`${Rk}/api/fs/read?${n}`);e._addFile({path:t,content:r.content,mimeType:r.mimeType,size:r.size,lineCount:r.lineCount,truncated:r.truncated}),e.selectedFile=t}catch(n){e._setLoadError(n instanceof Error?n.message:"Failed to load file")}finally{e._setLoading(!1)}}}),saveFile:Ak(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(!(!n||!n.isDirty)){e._setSaving(!0),e._setSaveError(null);try{(yield fetch(`${Rk}/api/fs/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,root:e.worktreePath,content:n.content})}).then(i=>i.ok?i.json():i.json().then(a=>{throw new Error(a.error||"Failed to save file")}))).success&&e._markFileSaved(t)}catch(r){throw e._setSaveError(r instanceof Error?r.message:"Failed to save file"),r}finally{e._setSaving(!1)}}}),closeFile(t){e.openFiles.delete(t),e.selectedFile===t&&(e.selectedFile=null)}}));function KRe(){return qRe.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const yie=k.createContext(null);function YRe(e,t=!1,n){const r=k.useMemo(()=>KRe(),[]),i=k.useRef(!1);return k.useEffect(()=>{r.setWorktreePath(e),r.setReadOnly(t),i.current=!1,e&&r.loadFileTree().then(()=>{n&&!i.current&&(i.current=!0,r.selectFile(n),r.loadFile(n))})},[r,e,t,n]),r}function XRe(){const e=k.useContext(yie);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function _ie(){const e=XRe();return{worktreePath:e.worktreePath,readOnly:e.readOnly,selectedFile:e.selectedFile,currentFile:e.currentFile,expandedDirs:[...e.expandedDirs],fileTree:e.fileTree,isLoading:e.isLoading,isSaving:e.isSaving,isLoadingTree:e.isLoadingTree,loadError:e.loadError,saveError:e.saveError,treeError:e.treeError,isDirty:e.isDirty,selectFile:e.selectFile,loadFile:e.loadFile,saveFile:e.saveFile,closeFile:e.closeFile,updateContent:e.updateContent,toggleDir:e.toggleDir,collapseAll:e.collapseAll,toggleMarkdownView:e.toggleMarkdownView,isFileMarkdownView:e.isFileMarkdownView,isDirExpanded:e.isDirExpanded,refreshTree:e.loadFileTree}}const Eie=k.createContext(null);function zm(){const e=k.useContext(Eie);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function ZRe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function QRe({children:e,wsUrl:t=ZRe(),reconnectInterval:n=2e3,maxReconnectAttempts:r=10}){const i=k.useRef(null),a=k.useRef(0),s=k.useRef(void 0),o=k.useRef(null),[,l]=k.useState({}),u=k.useCallback(d=>{i.current?.readyState===WebSocket.OPEN?(At.ws.debug("send",{type:d.type}),i.current.send(JSON.stringify(d))):At.ws.warn("send dropped (WebSocket not open)",{type:d.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const d={send:u,log:At};o.current=VRe.create({},d)}const f=o.current;return k.useEffect(()=>{f.setMaxReconnectAttempts(r)},[f,r]),k.useEffect(()=>{let d=!0;const p=()=>{const m=i.current;if(m&&(m.readyState===WebSocket.CONNECTING||m.readyState===WebSocket.OPEN))return;const E=new WebSocket(t);i.current=E,E.onopen=()=>{d&&(At.ws.info("WebSocket connected"),f.setConnected(!0),a.current=0)},E.onmessage=S=>{if(d)try{const b=JSON.parse(S.data);f.handleMessage(b)}catch(b){At.ws.error("Failed to parse WebSocket message",{error:String(b)})}},E.onclose=()=>{if(d)if(At.ws.info("WebSocket disconnected"),f.setConnected(!1),i.current===E&&(i.current=null),a.current<r){a.current++,f.setReconnectAttempt(a.current);const S=n*Math.pow(1.5,a.current-1);At.ws.info("Scheduling reconnect",{attempt:a.current,delay:S}),s.current=setTimeout(p,S)}else At.ws.warn("Max reconnect attempts reached"),f.setReconnectAttempt(a.current)},E.onerror=S=>{At.ws.error("WebSocket error",{event:String(S)})}};return p(),()=>{d=!1,s.current&&clearTimeout(s.current);const m=i.current;m?.readyState===WebSocket.OPEN&&m.close(),i.current=null}},[t,n,r,f]),k.useEffect(()=>{l({})},[]),g.jsx(Eie.Provider,{value:f,children:e})}function Sie(){const e=zm(),{setTheme:t,resolvedTheme:n,theme:r}=ed(),{data:i}=nwe(),a=k.useRef(void 0),s=k.useRef(!1),o=k.useRef(!1);k.useEffect(()=>VM(()=>e.broadcastedTheme,f=>{f&&(o.current=!0,t(f),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),k.useEffect(()=>{let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.type="image/png",u.href="/logo.png"},[]),k.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&$t("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:n})}).catch(()=>{})},[i,n]);const l=k.useCallback(u=>{if(!o.current&&(t(u),e.syncTheme(u),i)){const f=u==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":u;$t("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:f})}).catch(()=>{})}},[t,e,i]);return{theme:r??"system",resolvedTheme:n,syncClaudeCode:i,changeTheme:l,isUpdating:!1}}let Nk=!1;const nH={activeTabId:null,focusedTerminals:{},currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function xie(){const e=wr(),t=k.useRef(void 0),n=k.useRef({}),{data:r=nH,isLoading:i}=qn({queryKey:["terminal-view-state"],queryFn:async()=>{const p=await fetch("/api/terminal-view-state");if(!p.ok)throw new Error("Failed to fetch terminal view state");return p.json()},staleTime:2e3}),a=Fn({mutationFn:async p=>{const m=await fetch("/api/terminal-view-state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!m.ok)throw new Error("Failed to update terminal view state");return m.json()},onSuccess:p=>{e.setQueryData(["terminal-view-state"],p)}}),s=k.useRef(a);s.current=a;const o=k.useCallback(p=>{const m=n.current;n.current={...m,...p,focusedTerminals:p.focusedTerminals||m.focusedTerminals?{...m.focusedTerminals,...p.focusedTerminals}:void 0};const E=n.current;e.setQueryData(["terminal-view-state"],S=>{const b=S??nH;return{activeTabId:E.activeTabId!==void 0?E.activeTabId:b.activeTabId,focusedTerminals:{...b.focusedTerminals,...E.focusedTerminals},currentView:E.currentView!==void 0?E.currentView:b.currentView,currentTaskId:E.currentTaskId!==void 0?E.currentTaskId:b.currentTaskId,isTabVisible:E.isTabVisible!==void 0?E.isTabVisible:b.isTabVisible,viewUpdatedAt:E.viewUpdatedAt!==void 0?E.viewUpdatedAt:b.viewUpdatedAt}}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{s.current.mutate(n.current),n.current={}},500)},[e]),l=k.useCallback((p,m)=>{if(m===null){const E=e.getQueryData(["terminal-view-state"]);if(E){const{[p]:S,...b}=E.focusedTerminals;o({focusedTerminals:b})}}else o({focusedTerminals:{[p]:m}})},[e,o]),u=k.useCallback(p=>r.focusedTerminals[p]??null,[r.focusedTerminals]),f=k.useRef(!1);k.useEffect(()=>{if(Nk){f.current=!1;return}Nk=!0,f.current=!0;const p=()=>{o({isTabVisible:document.visibilityState==="visible",viewUpdatedAt:new Date().toISOString()})};return document.addEventListener("visibilitychange",p),p(),()=>{document.removeEventListener("visibilitychange",p),f.current&&(Nk=!1)}},[o]);const d=k.useCallback((p,m,E)=>{o({currentView:p,currentTaskId:m,activeTabId:E,viewUpdatedAt:new Date().toISOString()})},[o]);return{viewState:r,isLoading:i,getFocusedTerminal:u,setFocusedTerminal:l,updateViewTracking:d}}function ao(e,t){const n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 100;if(n.startsWith(r))return 80;if(n.includes(r))return 60;let i=0,a=0,s=0;for(;i<n.length&&a<r.length;)n[i]===r[a]&&(s+=1,a++),i++;return a===r.length?s:0}function JRe(e,t){return t.trim()?e.map(r=>{let i=ao(r.label,t);if(r.keywords)for(const a of r.keywords){const s=ao(a,t);s>i&&(i=s)}return{command:r,score:i}}).filter(({score:r})=>r>0).sort((r,i)=>i.score-r.score).map(({command:r})=>r):e}function e2e(e){const t=new Map;for(const n of e){const r=t.get(n.category)||[];r.push(n),t.set(n.category,r)}return t}function t2e({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r,onOpenInEditor:i}){const{t:a}=Jt("navigation"),[s,o]=k.useState(!1),l=e??s,u=t??o,[f,d]=k.useState(""),[p,m]=k.useState(0),E=k.useRef(null),S=k.useRef(null),b=Li(),y=k.useMemo(()=>[{id:"goto-tasks",label:a("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:g.jsx(fe,{icon:Bp,size:16,strokeWidth:2}),action:()=>{b({to:"/tasks"}),u(!1)}},{id:"goto-terminals",label:a("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:g.jsx(fe,{icon:R1e,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals"}),u(!1)}},{id:"goto-task-terminals",label:a("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+i",keywords:["tasks","shell","console","cli"],category:"navigation",icon:g.jsx(fe,{icon:Bp,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals",search:{tab:"all-tasks"}}),u(!1)}},{id:"goto-repositories",label:a("commandPalette.commands.goToRepositories"),shortcut:"meta+3",keywords:["repos","git","projects"],category:"navigation",icon:g.jsx(fe,{icon:I1e,size:16,strokeWidth:2}),action:()=>{b({to:"/repositories"}),u(!1)}},{id:"goto-review",label:a("commandPalette.commands.goToReview"),shortcut:"meta+4",keywords:["pr","pull request","issues","github"],category:"navigation",icon:g.jsx(fe,{icon:uu,size:16,strokeWidth:2}),action:()=>{b({to:"/review"}),u(!1)}},{id:"goto-monitoring",label:a("commandPalette.commands.goToMonitoring"),shortcut:"meta+5",keywords:["system","cpu","memory","processes","usage"],category:"navigation",icon:g.jsx(fe,{icon:hte,size:16,strokeWidth:2}),action:()=>{b({to:"/monitoring"}),u(!1)}},{id:"goto-settings",label:a("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:g.jsx(fe,{icon:xte,size:16,strokeWidth:2}),action:()=>{b({to:"/settings"}),u(!1)}},{id:"new-task",label:a("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:g.jsx(fe,{icon:Dv,size:16,strokeWidth:2}),action:()=>{u(!1),n?.()}},{id:"open-in-editor",label:a("commandPalette.commands.openInEditor"),shortcut:"meta+e",keywords:["editor","code","vscode","cursor","folder","path"],category:"actions",icon:g.jsx(fe,{icon:iD,size:16,strokeWidth:2}),action:()=>{u(!1),i?.()}},{id:"show-shortcuts",label:a("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:g.jsx(fe,{icon:vte,size:16,strokeWidth:2}),action:()=>{u(!1),r?.()}}],[b,n,r,i,u,a]),v=k.useMemo(()=>JRe(y,f),[y,f]),x=k.useMemo(()=>e2e(v),[v]),T=k.useMemo(()=>{const R=[],O=["navigation","actions"];for(const N of O){const D=x.get(N);D&&R.push(...D)}return R},[x]);k.useEffect(()=>{m(0)},[f]),k.useEffect(()=>{if(!S.current)return;const R=S.current.querySelector('[data-selected="true"]');R&&R.scrollIntoView({block:"nearest"})},[p]),Ea("meta+k",()=>u(!0),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+1",()=>b({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+2",()=>b({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+i",()=>{b({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),Ea("meta+3",()=>b({to:"/repositories"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+4",()=>b({to:"/review"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+5",()=>b({to:"/monitoring"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+,",()=>b({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),Ea("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]}),Ea("meta+e",()=>{i?.()},{allowInInput:!1,deps:[i]});const w=k.useCallback(R=>{switch(R.key){case"ArrowDown":R.preventDefault(),m(O=>Math.min(O+1,T.length-1));break;case"ArrowUp":R.preventDefault(),m(O=>Math.max(O-1,0));break;case"Enter":R.preventDefault(),T[p]&&T[p].action();break;case"Escape":R.preventDefault(),u(!1);break;case"1":R.preventDefault(),b({to:"/tasks"}),u(!1);break;case"2":R.preventDefault(),b({to:"/terminals"}),u(!1);break;case"3":R.preventDefault(),b({to:"/repositories"}),u(!1);break;case"4":R.preventDefault(),b({to:"/review"}),u(!1);break;case"5":R.preventDefault(),b({to:"/monitoring"}),u(!1);break}},[T,p,u,b]);k.useEffect(()=>{l&&(d(""),m(0),setTimeout(()=>E.current?.focus(),50))},[l]),k.useEffect(()=>{const R=O=>{if(O.data?.type==="vibora:action")switch(O.data.action){case"openCommandPalette":u(!0);break;case"openNewTask":n?.();break;case"showShortcuts":r?.();break}};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[u,n,r]);let C=0;return g.jsx(Du,{open:l,onOpenChange:u,children:g.jsxs(Lu,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:w,children:[g.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[g.jsx("span",{className:"text-muted-foreground mr-2",children:">"}),g.jsx(ln,{ref:E,value:f,onChange:R=>d(R.target.value),placeholder:a("commandPalette.placeholder"),className:"border-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0 h-12"}),g.jsx("kbd",{className:"pointer-events-none ml-2 inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"Esc"})]}),g.jsx("div",{ref:S,className:"max-h-80 overflow-y-auto p-2",children:v.length===0?g.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:a("commandPalette.noResults")}):g.jsx(g.Fragment,{children:["navigation","actions"].map(R=>{const O=x.get(R);return!O||O.length===0?null:g.jsxs("div",{className:"mb-2 last:mb-0",children:[g.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:a(`commandPalette.categories.${R}`)}),O.map(N=>{const D=C++,L=D===p;return g.jsxs("button",{"data-selected":L,onClick:()=>N.action(),onMouseEnter:()=>m(D),className:Be("flex w-full items-center gap-3 rounded-md px-2 py-2 text-sm",L?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[N.icon&&g.jsx("span",{className:"text-muted-foreground",children:N.icon}),g.jsx("span",{className:"flex-1 text-left",children:N.label}),N.shortcut&&g.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Cte(N.shortcut)})]},N.id)})]},R)})})})]})})}const rH={sm:"w-8 h-8",md:"w-9 h-9 md:w-12 md:h-12",lg:"w-12 h-12 md:w-16 md:h-16"};function n2e({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return g.jsx("div",{className:Be("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>g.jsx("div",{className:Be(rH[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>g.jsx("div",{className:Be(rH[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const r2e=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function i2e(){const e=ii({select:n=>n.location.pathname});return r2e.some(n=>e===n||e.startsWith(n+"/"))?g.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:g.jsx(n2e,{rows:100,cols:50,tileSize:"sm"})}):null}if(!k.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!Dre)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function a2e(e){e()}function s2e(e){e||(e=a2e),Rke({reactionScheduler:e})}function o2e(e){return Ike(e)}var l2e=1e4,u2e=1e4,c2e=(function(){function e(t){var n=this;Object.defineProperty(this,"finalize",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"registrations",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"sweepTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sweep",{enumerable:!0,configurable:!0,writable:!0,value:function(r){r===void 0&&(r=l2e),clearTimeout(n.sweepTimeout),n.sweepTimeout=void 0;var i=Date.now();n.registrations.forEach(function(a,s){i-a.registeredAt>=r&&(n.finalize(a.value),n.registrations.delete(s))}),n.registrations.size>0&&n.scheduleSweep()}}),Object.defineProperty(this,"finalizeAllImmediately",{enumerable:!0,configurable:!0,writable:!0,value:function(){n.sweep(0)}})}return Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){this.registrations.set(r,{value:n,registeredAt:Date.now()}),this.scheduleSweep()}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.registrations.delete(t)}}),Object.defineProperty(e.prototype,"scheduleSweep",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sweepTimeout===void 0&&(this.sweepTimeout=setTimeout(this.sweep,u2e))}}),e})(),d2e=typeof FinalizationRegistry<"u"?FinalizationRegistry:c2e,wD=new d2e(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function iH(e){e.reaction=new fl("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function f2e(e,t){t===void 0&&(t="observed");var n=oe.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(o){return wD.unregister(r),r.onStoreChange=o,r.reaction||(iH(r),r.stateVersion=Symbol()),function(){var l;r.onStoreChange=null,(l=r.reaction)===null||l===void 0||l.dispose(),r.reaction=null}},getSnapshot:function(){return r.stateVersion}};n.current=r}var i=n.current;i.reaction||(iH(i),wD.register(n,i,i)),oe.useDebugValue(i.reaction,o2e),BP.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot);var a,s;if(i.reaction.track(function(){try{a=e()}catch(o){s=o}}),s)throw s;return a}var Ik,Dk,wie=typeof Symbol=="function"&&Symbol.for,h2e=(Dk=(Ik=Object.getOwnPropertyDescriptor(function(){},"name"))===null||Ik===void 0?void 0:Ik.configurable)!==null&&Dk!==void 0?Dk:!1,aH=wie?Symbol.for("react.forward_ref"):typeof k.forwardRef=="function"&&k.forwardRef(function(e){return null}).$$typeof,sH=wie?Symbol.for("react.memo"):typeof k.memo=="function"&&k.memo(function(e){return null}).$$typeof;function p0(e,t){var n;if(sH&&e.$$typeof===sH)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var r=(n=void 0)!==null&&n!==void 0?n:!1,i=e,a=e.displayName||e.name;if(aH&&e.$$typeof===aH&&(r=!0,i=e.render,typeof i!="function"))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var s=function(o,l){return f2e(function(){return i(o,l)},a)};return s.displayName=e.displayName,h2e&&Object.defineProperty(s,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(s.contextTypes=e.contextTypes),r&&(s=k.forwardRef(s)),s=k.memo(s),m2e(e,s),s}var p2e={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function m2e(e,t){Object.keys(e).forEach(function(n){p2e[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var Lk;s2e(xr.unstable_batchedUpdates);Lk=wD.finalizeAllImmediately;const g2e=p0(function(){const t=zm();if(t.connected||!t.hasEverConnected)return null;const n=t.reconnectAttempt>0&&t.reconnectAttempt<t.maxReconnectAttempts,r=t.reconnectAttempt>=t.maxReconnectAttempts;return g.jsx("div",{className:Be("flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium","border-b",r?"bg-destructive/10 border-destructive/30 text-destructive":"bg-amber-500/10 border-amber-500/30 text-amber-600 dark:text-amber-400"),role:"alert","aria-live":"polite",children:r?g.jsxs(g.Fragment,{children:[g.jsx(fe,{icon:ss,size:16,strokeWidth:2}),g.jsx("span",{children:"Connection lost. Please check if the server is running."})]}):n?g.jsxs(g.Fragment,{children:[g.jsx(fe,{icon:rn,size:16,strokeWidth:2,className:"animate-spin"}),g.jsxs("span",{children:["Reconnecting... (attempt ",t.reconnectAttempt,"/",t.maxReconnectAttempts,")"]})]}):g.jsxs(g.Fragment,{children:[g.jsx(fe,{icon:ss,size:16,strokeWidth:2}),g.jsx("span",{children:"Disconnected from server"})]})})});function b2e(){return qn({queryKey:["system","dependencies"],queryFn:()=>$t("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}const oH="npm install -g @anthropic/claude-code",v2e="https://docs.anthropic.com/en/docs/claude-code/overview";function y2e(){const{data:e,isLoading:t}=b2e(),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(async()=>{try{await navigator.clipboard.writeText(oH),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=k.useCallback(()=>{r(!0)},[]);return t||n||e?.claudeCode?.installed?null:g.jsxs("div",{className:Be("flex items-center justify-between gap-4 px-4 py-3","border-b bg-amber-500/10 border-amber-500/30"),role:"alert",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(fe,{icon:ss,size:18,strokeWidth:2,className:"shrink-0 text-amber-600 dark:text-amber-400"}),g.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[g.jsx("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:"Claude Code CLI not found"}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("code",{className:"rounded bg-amber-500/20 px-2 py-0.5 text-xs font-mono text-amber-700 dark:text-amber-300",children:oH}),g.jsx("button",{onClick:s,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:i?"Copied!":"Copy to clipboard",children:g.jsx(fe,{icon:i?bl:N1e,size:14,strokeWidth:2})})]})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("a",{href:v2e,target:"_blank",rel:"noopener noreferrer",className:Be("text-xs font-medium px-2 py-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),children:"View Docs"}),g.jsx("button",{onClick:o,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:"Dismiss",children:g.jsx(fe,{icon:hi,size:16,strokeWidth:2})})]})]})}const _2e=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+i"},{labelKey:"goToRepositories",shortcut:"meta+3"},{labelKey:"goToReview",shortcut:"meta+4"},{labelKey:"goToMonitoring",shortcut:"meta+5"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{labelKey:"openInEditor",shortcut:"meta+e"},{labelKey:"keyboardShortcuts",shortcut:"meta+/"}]},{titleKey:"terminals",items:[{labelKey:"newTerminal",shortcut:"meta+d"},{labelKey:"closeTerminal",shortcut:"meta+w"}]},{titleKey:"general",items:[{labelKey:"closeModal",shortcut:"escape"},{labelKey:"submitForm",shortcut:"meta+enter"}]}];function E2e({open:e,onOpenChange:t}){const{t:n}=Jt("navigation");return g.jsx(Du,{open:e,onOpenChange:t,children:g.jsxs(Lu,{className:"sm:max-w-md",children:[g.jsx(sd,{children:g.jsx(od,{children:n("shortcuts.title")})}),g.jsx(jm,{className:"max-h-[60vh]",children:g.jsx("div",{className:"space-y-4 mt-2 pr-4",children:_2e.map(r=>g.jsxs("div",{children:[g.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:n(`shortcuts.groups.${r.titleKey}`)}),g.jsx("div",{className:"space-y-1",children:r.items.map(i=>g.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[g.jsx("span",{className:"text-sm",children:n(`shortcuts.labels.${i.labelKey}`)}),g.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Cte(i.shortcut)})]},i.shortcut))})]},r.titleKey))})})]})})}const S2e={vscode:"vscode",cursor:"cursor",windsurf:"windsurf",zed:"zed",antigravity:"antigravity"};function xw(e,t,n,r){const i=S2e[t];if(!n)return`${i}://file${e}`;const a=r!==22?`${n}:${r}`:n;return`${i}://vscode-remote/ssh-remote+${a}${e}`}function t3(e){return{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}[e]}function il(e){window.parent!==window?window.parent.postMessage({type:"vibora:openUrl",url:e},"*"):window.open(e,"_blank")}function x2e({open:e,onOpenChange:t}){const{t:n}=Jt("navigation"),[r,i]=k.useState(""),[a,s]=k.useState(!1),{data:o}=i0(),{data:l}=a0(),{data:u}=s0();k.useEffect(()=>{e&&i("")},[e]);const f=()=>{if(!r.trim())return;const m=xw(r.trim(),o??"vscode",l??"",u??22);il(m),t(!1)},d=m=>{i(m)},p=t3(o??"vscode");return g.jsxs(g.Fragment,{children:[g.jsx(Du,{open:e,onOpenChange:t,children:g.jsxs(Lu,{className:"sm:max-w-md",children:[g.jsxs(sd,{children:[g.jsx(od,{children:n("openInEditor.title")}),g.jsx(Jy,{children:n("openInEditor.description",{editor:p})})]}),g.jsx("div",{className:"space-y-4",children:g.jsxs("div",{className:"space-y-2",children:[g.jsx("label",{className:"text-sm font-medium",children:n("openInEditor.pathLabel")}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(ln,{value:r,onChange:m=>i(m.target.value),placeholder:n("openInEditor.pathPlaceholder"),onKeyDown:m=>m.key==="Enter"&&f(),className:"flex-1 font-mono text-sm"}),g.jsx(Ve,{variant:"outline",size:"icon",onClick:()=>s(!0),title:n("openInEditor.browse"),children:g.jsx(fe,{icon:Di,size:16,strokeWidth:2})})]}),g.jsx("p",{className:"text-xs text-muted-foreground",children:n("openInEditor.pathHint")})]})}),g.jsxs(Kc,{children:[g.jsx(Mf,{render:g.jsx(Ve,{variant:"outline"}),children:n("openInEditor.cancel")}),g.jsx(Ve,{onClick:f,disabled:!r.trim(),children:n("openInEditor.open")})]})]})}),g.jsx(Hc,{open:a,onOpenChange:s,onSelect:d})]})}const w2e=({...e})=>{const{resolvedTheme:t}=ed();return g.jsx(k_e,{theme:t,className:"toaster group",icons:{success:g.jsx(fe,{icon:pte,strokeWidth:2,className:"size-4"}),info:g.jsx(fe,{icon:B1e,strokeWidth:2,className:"size-4"}),warning:g.jsx(fe,{icon:ss,strokeWidth:2,className:"size-4"}),error:g.jsx(fe,{icon:H1e,strokeWidth:2,className:"size-4"}),loading:g.jsx(fe,{icon:rn,strokeWidth:2,className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...e})},No=nme({component:R2e});function T2e(){return wwe(),null}function C2e(){return Hne(),null}function A2e(){return Sie(),null}function k2e(){const e=ii({select:n=>n.location}),{updateViewTracking:t}=xie();return k.useEffect(()=>{const n=e.pathname;let r="other",i=null,a=null;n.startsWith("/tasks/")?(r="task-detail",i=n.split("/")[2]||null):n==="/terminals"&&(r="terminals",a=new URLSearchParams(e.search).get("tab")),t(r,i,a)},[e.pathname,e.search,t]),null}function O2e(){const e=ii({select:t=>t.location});return k.useEffect(()=>{window.parent!==window&&window.parent.postMessage({type:"vibora:route",pathname:e.pathname,search:e.search},"*")},[e.pathname,e.search]),null}function R2e(){const[e,t]=k.useState(null),[n,r]=k.useState(!1),[i,a]=k.useState(!1),[s,o]=k.useState(!1),l=typeof window<"u"&&window.parent!==window,u=k.useCallback(E=>{t(()=>E)},[]),f=k.useCallback(()=>{e?.()},[e]),d=k.useCallback(()=>{r(!0)},[]),p=k.useCallback(()=>{a(!0)},[]),m=k.useCallback(()=>{o(!0)},[]);return g.jsx(I_e,{children:g.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[g.jsx(T2e,{}),g.jsx(C2e,{}),g.jsx(A2e,{}),g.jsx(k2e,{}),g.jsx(O2e,{}),g.jsx(g2e,{}),g.jsx(y2e,{}),g.jsx(_we,{onNewTaskRef:u,onOpenCommandPalette:p}),g.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[g.jsx(i2e,{}),g.jsx(fJ,{})]}),g.jsx(t2e,{open:i,onOpenChange:a,onNewTask:f,onShowShortcuts:d,onOpenInEditor:m}),g.jsx(E2e,{open:n,onOpenChange:r}),g.jsx(x2e,{open:s,onOpenChange:o}),g.jsx(w2e,{position:l?"bottom-center":"bottom-right"})]})})}const N2e=$s("/")({beforeLoad:()=>{throw XQ({to:"/tasks"})}}),TD="";function Tie(){const[e,t]=k.useState(new Map),[n,r]=k.useState(null),[i,a]=k.useState(!0),[s,o]=k.useState(!1),[l,u]=k.useState(null),f=k.useRef(null),d=k.useRef(0),p=k.useRef(!1),m=k.useCallback(async()=>{a(!0),u(null);try{const b=await fetch(`${TD}/api/worktrees/json`);if(!b.ok)throw new Error("Failed to fetch worktrees");const y=await b.json();t(new Map(y.worktrees.map(v=>[v.path,{...v,size:v.size||0,sizeFormatted:v.sizeFormatted||"0 B",branch:v.branch||"unknown"}]))),r(y.summary),a(!1),o(!1)}catch(b){u(b instanceof Error?b:new Error("Failed to load worktrees")),a(!1),o(!1)}},[]),E=k.useCallback(()=>{if(p.current){m();return}f.current?.close(),a(!0),o(!1),u(null),t(new Map),r(null);const b=new EventSource(`${TD}/api/worktrees`);f.current=b,b.addEventListener("worktree:basic",y=>{const v=JSON.parse(y.data);d.current=v.length,t(new Map(v.map(x=>[x.path,{...x,size:0,sizeFormatted:"...",branch:"..."}]))),a(!1),o(v.length>0)}),b.addEventListener("worktree:details",y=>{const v=JSON.parse(y.data);t(x=>{const T=new Map(x),w=T.get(v.path);return w&&T.set(v.path,{...w,size:v.size,sizeFormatted:v.sizeFormatted,branch:v.branch}),T}),d.current--,d.current<=0&&o(!1)}),b.addEventListener("worktree:complete",y=>{const v=JSON.parse(y.data);r(v),o(!1),b.close()}),b.addEventListener("worktree:error",y=>{const{path:v}=JSON.parse(y.data);At.viewer.error("Error loading worktree details",{path:v}),d.current--,d.current<=0&&o(!1)}),b.onerror=()=>{b.close(),At.viewer.info("SSE connection failed, trying JSON fallback"),p.current=!0,m()}},[m]);return k.useEffect(()=>(E(),()=>{f.current?.close()}),[E]),{worktrees:k.useMemo(()=>Array.from(e.values()).sort((y,v)=>y.isOrphaned!==v.isOrphaned?y.isOrphaned?-1:1:new Date(v.lastModified).getTime()-new Date(y.lastModified).getTime()),[e]),summary:n,isLoading:i,isLoadingDetails:s,error:l,refetch:E}}function Cie(){const e=wr();return Fn({mutationFn:({worktreePath:t,repoPath:n,deleteLinkedTask:r})=>$t(`${TD}/api/worktrees`,{method:"DELETE",body:JSON.stringify({worktreePath:t,repoPath:n,deleteLinkedTask:r})}),onSuccess:()=>{e.invalidateQueries({queryKey:["worktrees"]}),e.invalidateQueries({queryKey:["tasks"]})}})}const I2e=nd("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function po({className:e,variant:t="default",render:n,...r}){return Axe({defaultTagName:"span",props:cl({className:Be(I2e({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function Ra({className:e,size:t="default",...n}){return g.jsx("div",{"data-slot":"card","data-size":t,className:Be("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),...n})}function D2e({className:e,...t}){return g.jsx("div",{"data-slot":"card-header",className:Be("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function L2e({className:e,...t}){return g.jsx("div",{"data-slot":"card-title",className:Be("text-sm font-medium",e),...t})}function Bf({className:e,...t}){return g.jsx("div",{"data-slot":"card-content",className:Be("px-4 group-data-[size=sm]/card:px-3",e),...t})}function yo({...e}){return g.jsx(zEe,{"data-slot":"alert-dialog",...e})}function Cu({...e}){return g.jsx(Mte,{"data-slot":"alert-dialog-trigger",...e})}function P2e({...e}){return g.jsx(Ite,{"data-slot":"alert-dialog-portal",...e})}function M2e({className:e,...t}){return g.jsx(kte,{"data-slot":"alert-dialog-overlay",className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",e),...t})}function _o({className:e,size:t="default",...n}){return g.jsxs(P2e,{children:[g.jsx(M2e,{}),g.jsx(Nte,{"data-slot":"alert-dialog-content","data-size":t,className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",e),...n})]})}function Eo({className:e,...t}){return g.jsx("div",{"data-slot":"alert-dialog-header",className:Be("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function So({className:e,...t}){return g.jsx("div",{"data-slot":"alert-dialog-footer",className:Be("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function xo({className:e,...t}){return g.jsx(Pte,{"data-slot":"alert-dialog-title",className:Be("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function wo({className:e,...t}){return g.jsx(Ote,{"data-slot":"alert-dialog-description",className:Be("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function Kp({className:e,...t}){return g.jsx(Ve,{"data-slot":"alert-dialog-action",className:Be(e),...t})}function To({className:e,variant:t="outline",size:n="default",...r}){return g.jsx(Jx,{"data-slot":"alert-dialog-cancel",className:Be(e),render:g.jsx(Ve,{variant:t,size:n}),...r})}const pi=k.forwardRef(({className:e,...t},n)=>g.jsx(bSe,{ref:n,className:Be("peer size-4 shrink-0 rounded border border-input ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-checked:border-primary data-checked:text-primary-foreground","flex items-center justify-center transition-colors",e),...t,children:g.jsx(vSe,{className:"flex items-center justify-center",children:g.jsx(fe,{icon:bl,size:12,strokeWidth:3})})}));pi.displayName="Checkbox";const CD={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},j2e=$s("/worktrees/")({component:$2e});function F2e(){const{t:e}=Jt("common");return t=>{const n=new Date(t),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),s=Math.floor(a/60),o=Math.floor(s/60),l=Math.floor(o/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):o>0?o===1?e("time.hourAgo"):e("time.hoursAgo",{count:o}):s>0?s===1?e("time.minuteAgo"):e("time.minutesAgo",{count:s}):e("time.justNow")}}function lH({className:e}){return g.jsx("span",{className:`inline-block animate-pulse rounded bg-muted ${e}`})}function B2e({worktree:e,onDelete:t}){const{t:n}=Jt("common"),{t:r}=Jt("worktrees"),i=F2e(),[a,s]=k.useState(!1),[o,l]=k.useState(!1),[u,f]=k.useState(!1),d=e.sizeFormatted==="..."||e.branch==="...",p=!e.isOrphaned&&e.taskId,m=async()=>{l(!0);try{await t(e,u),s(!1)}catch{}finally{l(!1)}},E=S=>{s(S),S||f(!1)};return g.jsx(Ra,{className:"transition-colors hover:border-border/80",children:g.jsxs(Bf,{className:"flex items-start justify-between gap-4 py-4",children:[g.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"truncate font-medium",children:e.name}),e.isOrphaned?g.jsx(po,{className:Be("shrink-0",CD.ORPHANED),children:n("statuses.ORPHANED")}):e.taskStatus?g.jsx(po,{className:Be("shrink-0",CD[e.taskStatus]),children:n(`statuses.${e.taskStatus}`)}):null]}),g.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:Di,size:12,strokeWidth:2,className:"shrink-0"}),g.jsx("span",{className:"truncate font-mono",children:e.path})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:Zx,size:12,strokeWidth:2,className:"shrink-0"}),e.branch==="..."?g.jsx(lH,{className:"h-3 w-16"}):g.jsx("span",{className:"font-mono",children:e.branch})]}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:bte,size:12,strokeWidth:2,className:"shrink-0"}),e.sizeFormatted==="..."?g.jsx(lH,{className:"h-3 w-12"}):g.jsx("span",{children:e.sizeFormatted})]}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:fte,size:12,strokeWidth:2,className:"shrink-0"}),g.jsx("span",{children:i(e.lastModified)})]})]}),e.taskId&&e.taskTitle&&g.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:g.jsxs(Ri,{to:"/tasks/$taskId",params:{taskId:e.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[g.jsx("span",{className:"truncate",children:e.taskTitle}),g.jsx(fe,{icon:Qy,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),g.jsxs(yo,{open:a,onOpenChange:E,children:[g.jsx(Cu,{render:g.jsx(Ve,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d}),children:g.jsx(fe,{icon:yu,size:14,strokeWidth:2})}),g.jsxs(_o,{children:[g.jsxs(Eo,{children:[g.jsx(xo,{children:r("delete.title")}),g.jsxs(wo,{children:[r("delete.description")," ",g.jsx("span",{className:"font-mono",children:e.name}),".",u&&p&&g.jsxs(g.Fragment,{children:[" ",r("delete.linkedTaskWillBeDeleted",{title:e.taskTitle})]})," ",r("delete.cannotUndo")]}),p&&g.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[g.jsx(pi,{checked:u,onCheckedChange:S=>f(S===!0),disabled:o}),r("delete.alsoDeleteLinkedTask",{title:e.taskTitle})]})]}),g.jsxs(So,{children:[g.jsx(To,{disabled:o,children:n("buttons.cancel")}),g.jsxs(Ve,{variant:"destructive",onClick:m,disabled:o,className:"gap-2",children:[o&&g.jsx(fe,{icon:rn,size:14,strokeWidth:2,className:"animate-spin"}),n(o?"status.deleting":"buttons.delete")]})]})]})]})]})})}const U2e=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function $2e(){const{t:e}=Jt("common"),{t}=Jt("worktrees"),{worktrees:n,summary:r,isLoading:i,isLoadingDetails:a,error:s,refetch:o}=Tie(),l=Cie(),[u,f]=k.useState(new Set),[d,p]=k.useState(!1),[m,E]=k.useState(!1),[S,b]=k.useState(!1),y=O=>{f(N=>{const D=new Set(N);return D.has(O)?D.delete(O):D.add(O),D})},v=()=>{f(new Set)},x=k.useMemo(()=>u.size===0?n:n.filter(O=>!!(O.isOrphaned&&u.has("ORPHANED")||O.taskStatus&&u.has(O.taskStatus))),[n,u]),T=k.useMemo(()=>n.filter(O=>O.taskStatus==="DONE"||O.taskStatus==="CANCELED"),[n]),w=async()=>{if(T.length!==0){E(!0);try{for(const O of T)await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:S});p(!1),o()}catch{}finally{E(!1)}}},C=O=>{p(O),O||b(!1)},R=async(O,N)=>{await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:N}),o()};return g.jsxs("div",{className:"flex h-full flex-col",children:[g.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border bg-background px-4 py-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx("h1",{className:"text-sm font-medium",children:t("title")}),(r||n.length>0)&&g.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[g.jsx("span",{children:t("summary.total",{count:r?.total??n.length})}),(r?.orphaned??n.filter(O=>O.isOrphaned).length)>0&&g.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:r?.orphaned??n.filter(O=>O.isOrphaned).length})}),a?g.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):r?g.jsx("span",{children:r.totalSizeFormatted}):null]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&g.jsxs(yo,{open:d,onOpenChange:C,children:[g.jsxs(Cu,{render:g.jsx(Ve,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:a}),children:[g.jsx(fe,{icon:mte,size:12,strokeWidth:2}),t("cleanup.button",{count:T.length})]}),g.jsxs(_o,{children:[g.jsxs(Eo,{children:[g.jsx(xo,{children:t("cleanup.title")}),g.jsxs(wo,{children:[t("cleanup.description",{count:T.length}),S&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),g.jsxs("div",{className:"space-y-3",children:[g.jsxs("p",{className:"text-sm text-muted-foreground",children:[T.filter(O=>O.taskStatus==="DONE").length>0&&g.jsxs("span",{className:"mr-3",children:[g.jsx("span",{className:"font-medium text-accent",children:T.filter(O=>O.taskStatus==="DONE").length})," ",t("cleanup.done")]}),T.filter(O=>O.taskStatus==="CANCELED").length>0&&g.jsxs("span",{children:[g.jsx("span",{className:"font-medium text-destructive",children:T.filter(O=>O.taskStatus==="CANCELED").length})," ",t("cleanup.canceled")]})]}),g.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[g.jsx(pi,{checked:S,onCheckedChange:O=>b(O===!0),disabled:m}),t("cleanup.alsoDeleteLinkedTasks")]}),g.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),g.jsxs(So,{children:[g.jsx(To,{disabled:m,children:e("buttons.cancel")}),g.jsxs(Ve,{variant:"destructive",onClick:w,disabled:m,className:"gap-2",children:[m&&g.jsx(fe,{icon:rn,size:14,strokeWidth:2,className:"animate-spin"}),m?e("status.deleting"):t("delete.button",{count:T.length})]})]})]})]}),u.size>0&&g.jsxs(Ve,{variant:"ghost",size:"sm",onClick:v,className:"gap-1.5 text-xs",children:[g.jsx(fe,{icon:hi,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),g.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:U2e.map(O=>{const N=u.has(O);return g.jsx("button",{onClick:()=>y(O),className:Be("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",N?CD[O]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${O}`)},O)})})]}),g.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[i&&g.jsx("div",{className:"flex items-center justify-center py-12",children:g.jsx(fe,{icon:rn,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),s&&g.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[g.jsx(fe,{icon:ss,size:20,strokeWidth:2}),g.jsx("span",{className:"text-sm",children:t("error.failedToLoad",{message:s.message})})]}),!i&&!s&&x.length===0&&g.jsx("div",{className:"py-12 text-muted-foreground",children:g.jsx("p",{className:"text-sm",children:u.size>0?t("empty.noMatch"):t("empty.noWorktrees")})}),!i&&g.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:x.map(O=>g.jsx(B2e,{worktree:O,onDelete:R},O.path))})]})]})}function Wn(e,t="Assertion error"){if(!e)throw Error(t)}function Yp({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function AD(e,t){return t.sort(e==="horizontal"?z2e:H2e)}function z2e(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function H2e(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Aie(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function W2e({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,a=Number.MAX_VALUE;for(const s of t){const{x:o,y:l}=Aie(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return Wn(i,"No rect found"),i}function kie(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=AD(n,Array.from(t.children).filter(f=>f instanceof HTMLElement).map(f=>({element:f}))).map(({element:f})=>f),s=[];let o=!1,l,u=[];for(const f of a)if(f.hasAttribute("data-panel")){const d=r.find(p=>p.element===f);if(d){if(l){const p=l.element.getBoundingClientRect(),m=f.getBoundingClientRect();let E;if(o){const S=n==="horizontal"?new DOMRect(p.right,p.top,0,p.height):new DOMRect(p.left,p.bottom,p.width,0),b=n==="horizontal"?new DOMRect(m.left,m.top,0,m.height):new DOMRect(m.left,m.top,m.width,0);switch(u.length){case 0:{E=[S,b];break}case 1:{const y=u[0],v=W2e({orientation:n,rects:[p,m],targetRect:y.element.getBoundingClientRect()});E=[y,v===p?b:S];break}default:{E=u;break}}}else u.length?E=u:E=[n==="horizontal"?new DOMRect(p.right,m.top,m.left-p.right,m.height):new DOMRect(m.left,p.bottom,m.width,m.top-p.bottom)];for(const S of E)s.push({group:e,groupSize:Yp({group:e}),panels:[l,d],separator:"width"in S?void 0:S,rect:"width"in S?S:S.element.getBoundingClientRect()})}o=!1,l=d,u=[]}}else if(f.hasAttribute("data-separator")){const d=i.find(p=>p.element===f);d?u.push(d):(l=void 0,u=[])}else o=!0;return s}function V2e(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function G2e(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function q2e(e){return e/100*window.innerHeight}function K2e(e){return e/100*window.innerWidth}function Y2e(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function D_({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=Y2e(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=G2e(t,i);break}case"em":{r=V2e(t,i);break}case"vh":{r=q2e(i);break}case"vw":{r=K2e(i);break}}return r}function lo(e){return parseFloat(e.toFixed(3))}function uH(e){const{panels:t}=e,n=Yp({group:e});return n===0?t.map(r=>({collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:a}=r;let s=0;if(a.collapsedSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=lo(f/n*100)}let o;if(a.defaultSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=lo(f/n*100)}let l=0;if(a.minSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.minSize});l=lo(f/n*100)}let u=100;if(a.maxSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.maxSize});u=lo(f/n*100)}return{collapsedSize:s,collapsible:a.collapsible===!0,defaultSize:o,minSize:l,maxSize:u,panelId:r.id}})}class X2e{#e={};addListener(t,n){const r=this.#e[t];return r===void 0?this.#e[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=this.#e[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,a=null;const s=Array.from(r);for(let o=0;o<s.length;o++){const l=s[o];try{l.call(null,n)}catch(u){a===null&&(i=!0,a=u)}}if(i)throw a}}removeAllListeners(){this.#e={}}removeListener(t,n){const r=this.#e[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}function na(e,t,n=0){return Math.abs(lo(e)-lo(t))<=n}let ws={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const xf=new X2e;function El(){return ws}function Fs(e){const t=typeof e=="function"?e(ws):e;if(ws===t)return ws;const n=ws;return ws={...ws,...t},t.cursorFlags!==void 0&&xf.emit("cursorFlagsChange",ws.cursorFlags),t.interactionState!==void 0&&xf.emit("interactionStateChange",ws.interactionState),t.mountedGroups!==void 0&&(ws.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=na(a.collapsedSize,r.layout[a.panelId]),l=na(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),xf.emit("mountedGroupsChange",ws.mountedGroups)),ws}const Z2e=e=>e,Pk=()=>{},Oie=1,Rie=2,Nie=4,Iie=8,cH={coarse:10,precise:5};function Q2e({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(a=>{if(!a.disableCursor)switch(a.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(r===0&&i===0)return null;switch(n){case"active":{const a=(e&Oie)!==0,s=(e&Rie)!==0,o=(e&Nie)!==0,l=(e&Iie)!==0;if(e){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}break}}return r>0&&i>0?"move":r>0?"ew-resize":"ns-resize"}let Mk,Uo;function n3(){Uo===void 0&&(Uo=new CSSStyleSheet,document.adoptedStyleSheets=[Uo]);const{cursorFlags:e,interactionState:t}=El();switch(t.state){case"active":case"hover":{const n=Q2e({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(Mk===r)return;Mk=r,n?Uo.cssRules.length===0?Uo.insertRule(r):Uo.replaceSync(r):Uo.cssRules.length===1&&Uo.deleteRule(0);break}case"inactive":{Mk=void 0,Uo.cssRules.length===1&&Uo.deleteRule(0);break}}}function J2e(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function zv(e,t){return na(e,t)?0:e>t?1:-1}function dp({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if(zv(t,a)<0)if(r){const s=(n+a)/2;zv(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=lo(t),t}function Hv({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(na(e,0))return t;const s=Object.values(t),o=Object.values(i),l=[...s],[u,f]=r;Wn(u!=null,"Invalid first pivot index"),Wn(f!=null,"Invalid second pivot index");let d=0;if(a==="keyboard"){{const E=e<0?f:u,S=n[E];Wn(S,`Panel constraints not found for index ${E}`);const{collapsedSize:b=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),na(x,b)){const T=v-x;zv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const E=e<0?u:f,S=n[E];Wn(S,`No panel constraints found for index ${E}`);const{collapsedSize:b=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),na(x,v)){const T=x-b;zv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const E=e<0?1:-1;let S=e<0?f:u,b=0;for(;;){const v=s[S];Wn(v!=null,`Previous layout not found for panel index ${S}`);const x=dp({panelConstraints:n[S],size:100})-v;if(b+=x,S+=E,S<0||S>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-y:y}{let E=e<0?u:f;for(;E>=0&&E<n.length;){const S=Math.abs(e)-Math.abs(d),b=s[E];Wn(b!=null,`Previous layout not found for panel index ${E}`);const y=b-S,v=dp({panelConstraints:n[E],size:y});if(!na(b,v)&&(d+=b-v,l[E]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?E--:E++}}if(J2e(o,l))return i;{const E=e<0?f:u,S=s[E];Wn(S!=null,`Previous layout not found for panel index ${E}`);const b=S+d,y=dp({panelConstraints:n[E],size:b});if(l[E]=y,!na(y,b)){let v=b-y,x=e<0?f:u;for(;x>=0&&x<n.length;){const T=l[x];Wn(T!=null,`Previous layout not found for panel index ${x}`);const w=T+v,C=dp({panelConstraints:n[x],size:w});if(na(T,C)||(v-=C-T,l[x]=C),na(v,0))break;e>0?x--:x++}}}const p=Object.values(l).reduce((E,S)=>S+E,0);if(!na(p,100,.1))return i;const m=Object.keys(i);return l.reduce((E,S,b)=>(E[m[b]]=S,E),{})}function Hm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||zv(e[n],t[n])!==0)return!1;return!0}function Die({event:e,hitRegions:t,initialLayoutMap:n,mountedGroups:r,pointerDownAtPoint:i}){let a=0;const s=new Map(r);t.forEach(o=>{const{group:l,groupSize:u}=o,{disableCursor:f,orientation:d,panels:p}=l;let m=0;i?d==="horizontal"?m=(e.clientX-i.x)/u*100:m=(e.clientY-i.y)/u*100:d==="horizontal"?m=e.clientX<0?-100:100:m=e.clientY<0?-100:100;const E=n.get(l),{defaultLayoutDeferred:S,derivedPanelConstraints:b,layout:y,separatorToPanels:v}=r.get(l)??{defaultLayoutDeferred:!1};if(b&&E&&y&&v){const x=Hv({delta:m,initialLayout:E,panelConstraints:b,pivotIndices:o.panels.map(T=>p.indexOf(T)),prevLayout:y,trigger:"mouse-or-touch"});if(Hm(x,y)){if(m!==0&&!f)switch(d){case"horizontal":{a|=m<0?Oie:Rie;break}case"vertical":{a|=m<0?Nie:Iie;break}}}else{s.set(o.group,{defaultLayoutDeferred:S,derivedPanelConstraints:b,layout:x,separatorToPanels:v});const T=o.group.panels.map(({id:w})=>w).join(",");o.group.inMemoryLayouts[T]=x}}}),Fs({cursorFlags:a,mountedGroups:s}),n3()}function dH(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=El();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&Die({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function _E(e){const t=e.parentElement;Wn(t,"Parent group element not found");const{mountedGroups:n}=El();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Uf({layout:e,panelConstraints:t}){const n=[...Object.values(e)],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!na(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=100/r*o;n[s]=l}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=dp({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!na(i,0))for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=o+i,u=dp({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,na(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Lie({groupId:e}){const t=()=>{const{mountedGroups:n}=El();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:a,layout:s,separatorToPanels:o}=t(),l=Uf({layout:n,panelConstraints:i});return r?s:(Hm(s,l)||Fs(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function Pie(e){const{mountedGroups:t}=El(),n=t.get(e);return Wn(n,`Mounted Group ${e.id} not found`),n}function Bd(e,t){const n=_E(e),r=Pie(n),i=n.separators.find(f=>f.element===e);Wn(i,"Matching separator not found");const a=r.separatorToPanels.get(i);Wn(a,"Matching panels not found");const s=a.map(f=>n.panels.indexOf(f)),o=Lie({groupId:n.id}).getLayout(),l=Hv({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Uf({layout:l,panelConstraints:r.derivedPanelConstraints});Hm(o,u)||Fs(f=>({mountedGroups:new Map(f.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function fH(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=_E(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,-5);break}case"End":{e.preventDefault(),Bd(t,100);break}case"Enter":{e.preventDefault();const r=_E(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=Pie(r),o=r.separators.find(d=>d.element===t);Wn(o,"Matching separator not found");const l=s.get(o);Wn(l,"Matching panels not found");const u=l[0],f=i.find(d=>d.panelId===u.id);if(Wn(f,"Panel metadata not found"),f.collapsible){const d=a[u.id],p=f.collapsedSize===d?r.inMemoryLastExpandedPanelSizes[u.id]??f.minSize:f.collapsedSize;Bd(t,p-d)}break}case"F6":{e.preventDefault();const r=_E(t).separators.map(s=>s.element),i=Array.from(r).findIndex(s=>s===e.currentTarget);Wn(i!==null,"Index not found");const a=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[a].focus();break}case"Home":{e.preventDefault(),Bd(t,-100);break}}}function eNe(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=Aie(n,a.rect);switch(e){case"horizontal":{s.x<=i.x&&(r=a,i=s);break}case"vertical":{s.y<=i.y&&(r=a,i=s);break}}}return r?{distance:i,hitRegion:r}:void 0}let L_;function tNe(){return L_===void 0&&(typeof matchMedia=="function"?L_=!!matchMedia("(pointer:coarse)").matches:L_=!1),L_}function nNe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mH(e),b:mH(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Wn(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pH(hH(n.a)),b:pH(hH(n.b))};if(i.a===i.b){const a=r.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let o=a.length;for(;o--;){const l=a[o];if(l===s.a)return 1;if(l===s.b)return-1}}return Math.sign(i.a-i.b)}const rNe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function iNe(e){const t=getComputedStyle(Mie(e)??e).display;return t==="flex"||t==="inline-flex"}function aNe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||iNe(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||rNe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function hH(e){let t=e.length;for(;t--;){const n=e[t];if(Wn(n,"Missing node"),aNe(n))return n}return null}function pH(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mH(e){const t=[];for(;e;)t.push(e),e=Mie(e);return t}function Mie(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function sNe(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function oNe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if(nNe(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(sNe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function jie(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=tNe()?cH.coarse:cH.precise,s=kie(i),o=eNe(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&oNe({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function gH(e){if(e.defaultPrevented)return;const{mountedGroups:t}=El(),n=jie(e,t),r=new Set,i=new Set,a=new Set,s=new Map;let o=!1;n.forEach(l=>{r.add(l.group),l.panels.forEach(f=>{i.add(f)}),l.separator&&(a.add(l.separator),o||(o=!0,l.separator.element.focus()));const u=t.get(l.group);u&&s.set(l.group,u.layout)}),Fs({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function bH(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=El();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){Fs(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}Die({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=jie(e,n);r.length===0?t.state!=="inactive"&&Fs({interactionState:{state:"inactive"}}):Fs({interactionState:{hitRegions:r,state:"hover"}}),n3();break}}}function vH(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=El();t.state==="active"&&(Fs({cursorFlags:0,interactionState:{state:"inactive"}}),n3())}function yH(e){let t=0,n=0;const r={};for(const a of e)if(a.defaultSize!==void 0){t++;const s=lo(a.defaultSize);n+=s,r[a.panelId]=s}else r[a.panelId]=void 0;const i=e.length-t;if(i!==0){const a=lo((100-n)/i);for(const s of e)s.defaultSize===void 0&&(r[s.panelId]=a)}return r}function lNe(e,t,n){const r=n[0];if(!r)return;const i=e.panels.find(s=>s.element===t);if(!i||!i.onResize)return;const a=Yp({group:e});i.onResize({asPercentage:lo(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function uNe(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function cNe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(m=>{for(const E of m){const{borderBoxSize:S,target:b}=E;if(b===e.element){if(t){if(Yp({group:e})===0)return;Fs(y=>{const v=y.mountedGroups.get(e);if(v){const x=uH(e),T=v.defaultLayoutDeferred?yH(x):v.layout,w=Uf({layout:T,panelConstraints:x});return!v.defaultLayoutDeferred&&Hm(T,w)&&uNe(v.derivedPanelConstraints,x)?y:{mountedGroups:new Map(y.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:x,layout:w,separatorToPanels:v.separatorToPanels})}}return y})}}else lNe(e,b,S)}});i.observe(e.element),e.panels.forEach(m=>{Wn(!n.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.onResize&&i.observe(m.element)});const a=Yp({group:e}),s=uH(e),o=e.panels.map(({id:m})=>m).join(",");let l=e.defaultLayout;l&&e.panels.length!==Object.keys(l).length&&(l=void 0);const u=e.inMemoryLayouts[o]??l??yH(s),f=Uf({layout:u,panelConstraints:s}),d=kie(e),p=Fs(m=>{const E=new Map;return d.forEach(S=>{S.separator&&E.set(S.separator,S.panels)}),{mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:f,separatorToPanels:E})}});return e.element.addEventListener("pointerleave",dH),e.separators.forEach(m=>{Wn(!r.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.element.addEventListener("keydown",fH)}),p.mountedGroups.size===1&&(window.addEventListener("pointerdown",gH),window.addEventListener("pointermove",bH),window.addEventListener("pointerup",vH)),function(){t=!1;const m=Fs(E=>{const S=new Map(E.mountedGroups);return S.delete(e),{mountedGroups:S}});e.element.removeEventListener("pointerleave",dH),e.separators.forEach(E=>{E.element.removeEventListener("keydown",fH)}),m.mountedGroups.size===0&&(window.removeEventListener("pointerdown",gH),window.removeEventListener("pointermove",bH),window.removeEventListener("pointerup",vH)),i.disconnect()}}function r3(e){const t=k.useId();return`${e??t}`}const eh=typeof window<"u"?k.useLayoutEffect:k.useEffect;function i3(e){const t=k.useRef(e);return eh(()=>{t.current=e},[e]),k.useCallback(n=>t.current?.(n),[t])}function a3(...e){return i3(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function dNe(e){const t=k.useRef({...e});return eh(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Fie="--react-resizable-panels--panel--pointer-events";function Bie(e,t){const n=e.replace(/[^a-zA-Z0-9\-_]/g,""),r=t.replace(/[^a-zA-Z0-9\-_]/g,"");return`--react-resizable-panels--${n}--${r}`}const Uie=k.createContext(null);function fNe(e,t){const n=k.useRef({getLayout:()=>({}),setLayout:Z2e});k.useImperativeHandle(t,()=>n.current,[]),eh(()=>{Object.assign(n.current,Lie({groupId:e}))})}function hNe({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:s,id:o,onLayoutChange:l,orientation:u="horizontal",style:f,...d}){const p=k.useRef({}),m=i3(H=>{Hm(p.current,H)||(p.current=H,l?.(H))}),E=r3(o),[S,b]=k.useState(!1),[y,v]=k.useState(null),[x,T]=k.useState(n??{}),[w,C]=k.useState([]),[R,O]=k.useState([]),N=k.useRef({lastExpandedPanelSizes:{},layouts:{}}),D=a3(v,a);fNe(E,s);const L=k.useMemo(()=>({id:E,orientation:u,registerPanel:H=>(C(B=>AD(u,[...B,H])),()=>{C(B=>B.filter(q=>q!==H))}),registerSeparator:H=>(O(B=>AD(u,[...B,H])),()=>{O(B=>B.filter(q=>q!==H))})}),[E,u]),z=dNe({defaultLayout:n,disableCursor:r}),P=k.useRef(null);eh(()=>{if(y===null)return;const H={defaultLayout:z.defaultLayout,disableCursor:!!z.disableCursor,disabled:!!i,element:y,id:E,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:R};P.current=H;const B=cNe(H),q=El().mountedGroups.get(H);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:$,layout:Y}=q;!j&&$.length>0&&(T(Y),m?.(Y))}const K=xf.addListener("interactionStateChange",j=>{j.state==="active"?b(j.hitRegions.some($=>$.group===H)):b(!1)}),U=xf.addListener("mountedGroupsChange",j=>{const $=j.get(H);if($){const{defaultLayoutDeferred:Y,derivedPanelConstraints:W,layout:ee}=$;if(Y||W.length===0)return;T(ee),m?.(ee)}});return()=>{P.current=null,B(),K(),U()}},[i,y,E,m,u,w,R,z]),k.useEffect(()=>{const H=P.current;H&&(H.defaultLayout=n,H.disableCursor=!!r)});const G={[Fie]:S?"none":void 0};for(const H in x){const B=Bie(E,H),q=x[H];G[B]=q}return g.jsx(Uie.Provider,{value:L,children:g.jsx("div",{...d,"aria-orientation":u,className:t,"data-group":!0,"data-testid":E,id:E,ref:D,style:{...f,...G,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function s3(){const e=k.useContext(Uie);return Wn(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function pNe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=El();for(const[l,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:d,separatorToPanels:p}]of o)if(l.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:l,layout:d,separatorToPanels:p};throw Error(`Group ${e} not found`)},r=()=>{const o=n().derivedPanelConstraints.find(l=>l.panelId===t);if(o!==void 0)return o;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const o=n().group.panels.find(l=>l.id===t);if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},a=()=>{const o=n().layout[t];if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},s=o=>{const l=a();if(o===l)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:d,layout:p,separatorToPanels:m}=n(),E=d.panels.findIndex(v=>v.id===t),S=E===d.panels.length-1,b=Hv({delta:S?l-o:o-l,initialLayout:p,panelConstraints:f,pivotIndices:S?[E-1,E]:[E,E+1],prevLayout:p,trigger:"imperative-api"}),y=Uf({layout:b,panelConstraints:f});Hm(p,y)||Fs(v=>({mountedGroups:new Map(v.mountedGroups).set(d,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:y,separatorToPanels:m})}))};return{collapse:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();o&&u!==l&&s(l)},expand:()=>{const{collapsible:o,collapsedSize:l,minSize:u}=r(),f=a();o&&f===l&&s(u)},getSize:()=>{const{group:o}=n(),l=a(),{element:u}=i(),f=o.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:l,inPixels:f}},isCollapsed:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();return o&&na(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),f=Yp({group:u});l=lo(o/f*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function mNe(e,t){const{id:n}=s3(),r=k.useRef({collapse:Pk,expand:Pk,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Pk});k.useImperativeHandle(t,()=>r.current,[]),eh(()=>{Object.assign(r.current,pNe({groupId:n,panelId:e}))})}function gNe({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,elementRef:a,id:s,maxSize:o="100%",minSize:l="0%",onResize:u,panelRef:f,style:d,...p}){const m=!!s,E=r3(s),[S,b]=k.useState(null),y=a3(b,a),{id:v,registerPanel:x}=s3(),T=u!==null,w=i3(R=>{u?.(R,s)});eh(()=>{if(S!==null)return x({element:S,id:E,idIsStable:m,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,S,T,E,m,o,l,w,x]),mNe(E,f);const C=Bie(v,E);return g.jsx("div",{...p,"data-panel":!0,"data-testid":E,id:E,ref:y,style:{...bNe,flexBasis:0,flexGrow:`var(${C}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Fie})`},children:g.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const bNe={minHeight:"unset",maxHeight:"unset",height:"unset",minWidth:"unset",maxWidth:"unset",width:"unset",flex:"unset",flexBasis:"unset",flexShrink:"unset",flexGrow:"unset",border:"unset",borderWidth:"unset",padding:"unset",margin:"unset"};function vNe({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a;const s=e[n],o=t.find(l=>l.panelId===n);if(o){const l=o.maxSize,u=a=o.collapsible?o.collapsedSize:o.minSize,f=[r,r+1];a=Uf({layout:Hv({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Uf({layout:Hv({delta:l-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:s}}function yNe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=r3(r),[o,l]=k.useState({}),[u,f]=k.useState("inactive"),[d,p]=k.useState(null),m=a3(p,n),{id:E,orientation:S,registerSeparator:b}=s3(),y=S==="horizontal"?"vertical":"horizontal";return eh(()=>{if(d!==null){const v={element:d,id:s},x=b(v),T=xf.addListener("interactionStateChange",C=>{f(C.state!=="inactive"&&C.hitRegions.some(R=>R.separator===v)?C.state:"inactive")}),w=xf.addListener("mountedGroupsChange",C=>{C.forEach(({derivedPanelConstraints:R,layout:O,separatorToPanels:N},D)=>{if(D.id===E){const L=N.get(v);if(L){const z=L[0],P=D.panels.indexOf(z);l(vNe({layout:O,panelConstraints:R,panelId:z.id,panelIndex:P}))}}})});return()=>{T(),w(),x()}}},[d,E,s,b]),g.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":y,"aria-valuemax":o.valueMax,"aria-valuemin":o.valueMin,"aria-valuenow":o.valueNow,children:e,className:t,"data-separator":u,"data-testid":s,id:s,ref:m,role:"separator",style:{flexBasis:"auto",...i,flexGrow:0,flexShrink:0},tabIndex:0})}function Yd({className:e,direction:t,...n}){return g.jsx(hNe,{"data-slot":"resizable-panel-group",orientation:t,className:Be("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function As({...e}){return g.jsx(gNe,{"data-slot":"resizable-panel",...e})}function Xd({withHandle:e,className:t,...n}){return g.jsx(yNe,{"data-slot":"resizable-handle",className:Be("relative flex w-px items-center justify-center bg-border cursor-grab active:cursor-grabbing group touch-none","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","focus-visible:ring-offset-1 focus-visible:ring-offset-background","data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:cursor-row-resize","[&[data-orientation=vertical]>div]:rotate-90",t),...n,children:e&&g.jsxs("div",{className:"pointer-events-none absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center gap-1 bg-muted/90 border border-border rounded-full px-1 py-3 opacity-70 group-hover:opacity-100 group-focus:opacity-100 transition-opacity shadow-sm",children:[g.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),g.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),g.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"})]})})}var jk={exports:{}},_H;function _Ne(){return _H||(_H=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(s,o,l){var u=this&&this.__decorate||function(v,x,T,w){var C,R=arguments.length,O=R<3?x:w===null?w=Object.getOwnPropertyDescriptor(x,T):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,x,T,w);else for(var N=v.length-1;N>=0;N--)(C=v[N])&&(O=(R<3?C(O):R>3?C(x,T,O):C(x,T))||O);return R>3&&O&&Object.defineProperty(x,T,O),O},f=this&&this.__param||function(v,x){return function(T,w){x(T,w,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const d=l(9042),p=l(9924),m=l(844),E=l(4725),S=l(2585),b=l(3656);let y=o.AccessibilityManager=class extends m.Disposable{constructor(v,x,T,w){super(),this._terminal=v,this._coreBrowserService=T,this._renderService=w,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new p.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
31
|
+
`}}),!1):(u.type==="keydown"&&u.key==="Escape"&&window.parent!==window&&u.stopPropagation(),!0));const s=r.onData(u=>{t().send({type:"terminal:input",payload:{terminalId:n,data:u}})}),o=()=>{this.setLastFocusedTerminal(n)};r.textarea?.addEventListener("focus",o),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(t().log.ws.debug("attachXterm: terminal already attached, calling callback immediately",{terminalId:n}),e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):(t().log.ws.debug("attachXterm: registering onAttached callback",{terminalId:n,existingCallbacks:Array.from(e.onAttachedCallbacks.keys())}),e.onAttachedCallbacks.set(n,i.onAttached)));const l=()=>{s.dispose(),r.textarea?.removeEventListener("focus",o),e.terminals.get(n)?.setXterm(null)};return a.setAttachCleanup(l),t().send({type:"terminal:attach",payload:{terminalId:n}}),l},requestAttach(n){t().send({type:"terminal:attach",payload:{terminalId:n}})},clearTerminalBuffer(n){t().send({type:"terminal:clearBuffer",payload:{terminalId:n}})},assignTerminalToTab(n,r,i){t().send({type:"terminal:assignTab",payload:{terminalId:n,tabId:r,positionInTab:i}}),e.terminals.get(n)?.assignToTab(r,i)},createTab(n,r,i,a){const s=xD(),o=tH(),l=r??e.tabs.items.length,u={id:o,name:n,position:l,directory:i??null,createdAt:Date.now()},f=Gz(e.tabs);e.tabs.add(u),f.stop(),e.tabs.get(o)?.setPending(!0),e.pendingTabCreation=o,e.pendingUpdates.set(s,{entityType:"tab",tempId:o,inversePatches:f.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,adoptTerminalId:a,requestId:s,tempId:o}}),t().log.ws.debug("createTab optimistic",{requestId:s,tempId:o,name:n,adoptTerminalId:a})},updateTab(n,r){t().send({type:"tab:update",payload:{tabId:n,...r}}),e.tabs.get(n)?.updateFromServer(r)},deleteTab(n){t().send({type:"tab:delete",payload:{tabId:n}}),e.tabs.remove(n),e.viewState.clearFocusedTerminalForTab(n)},reorderTab(n,r){const i=e.tabs.get(n);if(!i)return;const a=i.position;if(t().send({type:"tab:reorder",payload:{tabId:n,position:r}}),r>a)for(const s of e.tabs.items)s.position>a&&s.position<=r&&s.setPosition(s.position-1);else if(r<a)for(const s of e.tabs.items)s.position>=r&&s.position<a&&s.setPosition(s.position+1);i.setPosition(r)},handleMessage(n){const{type:r,payload:i}=n;switch(r){case"terminals:list":e.terminals.replaceAll(i.terminals);break;case"terminal:created":{const{terminal:a,isNew:s,requestId:o,tempId:l}=i;if(o&&l){const u=e.pendingUpdates.get(o);if(u&&u.tempId===l){e.pendingUpdates.delete(o);const f=e.terminals.get(l);if(f){const d=f.xterm,p=e.onAttachedCallbacks.get(l),m=f.attachCleanup;if(t().log.ws.info("terminal:created optimistic handling",{tempId:l,realId:a.id,hasXterm:!!d,hasCallback:!!p,isNew:s}),m&&m(),f.setXterm(null),f.setAttachCleanup(null),e.onAttachedCallbacks.delete(l),s){const E=f.isStartingUp,S=e.terminals.items.findIndex(v=>v.id===l);S>=0&&cS(e.terminals.items[S]),e.terminals.add(a);const b=e.terminals.get(a.id);E&&b&&(b.setStartingUp(!0),t().log.ws.info("terminal:created transferred isStartingUp",{tempId:l,realId:a.id,isStartingUp:b.isStartingUp})),t().log.ws.info("terminal:created re-attaching xterm",{realId:a.id,hasRealTerminal:!!b,hasXterm:!!d,willAttach:!!(b&&d)}),b&&d?this.attachXterm(a.id,d,{onAttached:p}):p&&(t().log.ws.info("terminal:created preserving callback for later",{realId:a.id}),e.onAttachedCallbacks.set(a.id,p)),e.newTerminalIds.delete(l),e.newTerminalIds.add(a.id);const y=e.terminalsPendingStartup.get(l);y&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,y),t().log.ws.debug("transferred pending startup",{tempId:l,realId:a.id})),t().log.ws.debug("terminal:created confirmed",{requestId:o,tempId:l,realId:a.id,xtermReattached:!!d,hasPendingStartup:!!y})}else{const E=e.terminals.items.findIndex(b=>b.id===l);E>=0&&cS(e.terminals.items[E]),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l),e.terminals.has(a.id)||e.terminals.add(a),e.terminals.get(a.id)&&d&&this.attachXterm(a.id,d,{onAttached:p}),t().log.ws.debug("terminal:created deduplicated",{requestId:o,tempId:l,existingId:a.id,xtermReattached:!!d})}}break}}e.terminals.add(a),s&&e.newTerminalIds.add(a.id);break}case"terminal:destroyed":{const{terminalId:a}=i;e.terminals.remove(a),e.newTerminalIds.delete(a),e.terminalsReadyForCallback.delete(a),e.onAttachedCallbacks.delete(a);break}case"terminal:output":{const{terminalId:a,data:s}=i,o=e.terminals.get(a);o?.xterm?o.xterm.write(s):t().log.ws.warn("terminal:output but no xterm",{terminalId:a});break}case"terminal:attached":{const{terminalId:a,buffer:s}=i,o=e.terminals.get(a);t().log.ws.info("terminal:attached received",{terminalId:a,hasTerminal:!!o,hasXterm:!!o?.xterm,bufferLength:s?.length??0,hasCallback:e.onAttachedCallbacks.has(a),isReadyForCallback:e.terminalsReadyForCallback.has(a),registeredCallbacks:Array.from(e.onAttachedCallbacks.keys())});const l=()=>{const u=e.onAttachedCallbacks.get(a);u?(e.onAttachedCallbacks.delete(a),t().log.ws.debug("terminal:attached calling callback",{terminalId:a}),u(a)):(t().log.ws.debug("terminal:attached no callback yet, marking ready",{terminalId:a}),e.terminalsReadyForCallback.add(a))};o?.xterm?(o.xterm.reset(),s?o.xterm.write(s,l):l()):l();break}case"terminal:bufferCleared":{const{terminalId:a}=i,s=e.terminals.get(a);s?.xterm&&s.xterm.reset();break}case"terminal:exit":{const{terminalId:a,exitCode:s}=i;e.terminals.get(a)?.markExited(s);break}case"terminal:renamed":{const{terminalId:a,name:s}=i;e.terminals.get(a)?.rename(s);break}case"terminal:tabAssigned":{const{terminalId:a,tabId:s,positionInTab:o}=i;e.terminals.get(a)?.assignToTab(s,o);break}case"tabs:list":e.tabs.replaceAll(i.tabs),e.initialized=!0;break;case"tab:created":{const{tab:a,requestId:s,tempId:o,adoptTerminalId:l}=i;if(s&&o){const u=e.pendingUpdates.get(s);if(u&&u.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,l||(e.lastCreatedTabId=a.id),t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id,adoptTerminalId:l}));break}}e.tabs.add(a);break}case"tab:updated":{const{tabId:a,name:s,directory:o}=i;e.tabs.get(a)?.updateFromServer({name:s,directory:o});break}case"tab:deleted":{const{tabId:a}=i;e.tabs.remove(a),e.viewState.clearFocusedTerminalForTab(a);break}case"terminal:error":{const{error:a,requestId:s,tempId:o}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s);for(let u=l.inversePatches.length-1;u>=0;u--)jv(e.terminals,l.inversePatches[u]);e.newTerminalIds.delete(o),e.terminalsPendingStartup.delete(o),t().log.ws.warn("terminal:error rollback",{requestId:s,tempId:o,error:a});break}}At.ws.error("Terminal error from server",{error:a});break}case"sync:stale":{const{entityType:a,entityId:s,requestId:o,tempId:l,error:u}=i;if(t().log.ws.warn("sync:stale received",{entityType:a,entityId:s,error:u}),o&&l){const f=e.pendingUpdates.get(o);if(f&&f.tempId===l)if(e.pendingUpdates.delete(o),f.entityType==="terminal"){const d=e.terminals.get(l);d&&(d.cleanup(),e.terminals.remove(l)),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l)}else f.entityType==="tab"&&e.tabs.remove(l)}if(a==="terminal"){if(e.terminals.has(s)){const f=e.terminals.get(s);f&&(f.cleanup(),e.terminals.remove(s))}e.terminalsPendingStartup.delete(s)}else a==="tab"&&e.tabs.has(s)&&(e.tabs.remove(s),e.viewState.clearFocusedTerminalForTab(s));break}case"theme:synced":{const{theme:a}=i;e.broadcastedTheme=a,t().log.ws.debug("theme:synced received",{theme:a});break}}},reset(){e.terminals.clear(),e.tabs.clear(),e.connected=!1,e.initialized=!1,e.newTerminalIds.clear(),e.pendingUpdates.clear(),e.terminalsPendingStartup.clear()}}});function vie(){const e=zm();return k.useMemo(()=>{const t=(n,r)=>{const i=async a=>{const s=a.clipboardData?.items;if(s){for(const o of s)if(o.type.startsWith("image/")){a.preventDefault(),a.stopPropagation();const l=o.getAsFile();if(!l)return;try{const u=await Fte(l);e.writeToTerminal(r,u)}catch(u){At.ws.error("Failed to upload image",{error:String(u)})}return}}};return n.addEventListener("paste",i,!0),()=>{n.removeEventListener("paste",i,!0)}};return{get terminals(){return[...e.terminals.items]},get terminalsLoaded(){return e.initialized},get tabs(){return[...e.tabs.sorted]},get connected(){return e.connected},get newTerminalIds(){return e.newTerminalIds},get pendingTabCreation(){return e.pendingTabCreation},get lastCreatedTabId(){return e.lastCreatedTabId},createTerminal:e.createTerminal.bind(e),destroyTerminal:e.destroyTerminal.bind(e),writeToTerminal:e.writeToTerminal.bind(e),sendInputToTerminal:e.sendInputToTerminal.bind(e),resizeTerminal:e.resizeTerminal.bind(e),renameTerminal:e.renameTerminal.bind(e),clearTerminalBuffer:e.clearTerminalBuffer.bind(e),assignTerminalToTab:e.assignTerminalToTab.bind(e),createTab:e.createTab.bind(e),updateTab:e.updateTab.bind(e),deleteTab:e.deleteTab.bind(e),reorderTab:e.reorderTab.bind(e),attachXterm:e.attachXterm.bind(e),setupImagePaste:t,consumePendingStartup:e.consumePendingStartup.bind(e),clearStartingUp:e.clearStartingUp.bind(e),clearLastCreatedTabId:e.clearLastCreatedTabId.bind(e)}},[e])}const Rk="",GRe=Ot.model("File",{path:Ot.identifier,content:Ot.string,originalContent:Ot.string,mimeType:Ot.string,size:Ot.number,lineCount:Ot.number,truncated:Ot.boolean,isMarkdownView:Ot.optional(Ot.boolean,!1)}).views(e=>({get isDirty(){return e.content!==e.originalContent},get isMarkdown(){return e.path.toLowerCase().endsWith(".md")},get isImage(){return e.mimeType.startsWith("image/")},get isBinary(){return e.mimeType==="application/octet-stream"},get isEditable(){return!e.mimeType.startsWith("image/")&&e.mimeType!=="application/octet-stream"}})).actions(e=>({setContent(t){e.content=t},markSaved(){e.originalContent=e.content},toggleMarkdownView(){e.isMarkdownView=!e.isMarkdownView},setMarkdownView(t){e.isMarkdownView=t}})),qRe=Ot.model("FilesStore",{selectedFile:Ot.maybeNull(Ot.string),expandedDirs:Ot.array(Ot.string),openFiles:Ot.map(GRe)}).volatile(()=>({worktreePath:null,readOnly:!1,isLoading:!1,isSaving:!1,loadError:null,saveError:null,fileTree:null,isLoadingTree:!1,treeError:null})).views(e=>({get currentFile(){if(e.selectedFile)return e.openFiles.get(e.selectedFile)},get isDirty(){return(e.selectedFile?e.openFiles.get(e.selectedFile):void 0)?.isDirty??!1},isFileMarkdownView(t){return e.openFiles.get(t)?.isMarkdownView??!1},isDirExpanded(t){return e.expandedDirs.includes(t)}})).actions(e=>({setWorktreePath(t){e.worktreePath!==t&&(e.worktreePath=t,e.selectedFile=null,e.expandedDirs.clear(),e.openFiles.clear(),e.fileTree=null)},setReadOnly(t){e.readOnly=t},selectFile(t){e.selectedFile=t},toggleDir(t){const n=e.expandedDirs.indexOf(t);n>=0?e.expandedDirs.splice(n,1):e.expandedDirs.push(t)},collapseAll(){e.expandedDirs.clear()},updateContent(t,n){const r=e.openFiles.get(t);r&&r.setContent(n)},toggleMarkdownView(t){const n=e.openFiles.get(t);n&&n.toggleMarkdownView()},_setLoading(t){e.isLoading=t},_setLoadError(t){e.loadError=t},_setSaving(t){e.isSaving=t},_setSaveError(t){e.saveError=t},_setFileTree(t){e.fileTree=t},_setLoadingTree(t){e.isLoadingTree=t},_setTreeError(t){e.treeError=t},_addFile(t){e.openFiles.set(t.path,{path:t.path,content:t.content,originalContent:t.content,mimeType:t.mimeType,size:t.size,lineCount:t.lineCount,truncated:t.truncated,isMarkdownView:!1})},_markFileSaved(t){const n=e.openFiles.get(t);n&&n.markSaved()}})).actions(e=>({loadFileTree:Ak(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield $t(`${Rk}/api/fs/tree?root=${encodeURIComponent(e.worktreePath)}`);e._setFileTree(t.entries)}catch(t){e._setTreeError(t instanceof Error?t.message:"Failed to load file tree")}finally{e._setLoadingTree(!1)}}}),loadFile:Ak(function*(t){if(e.worktreePath){if(e.openFiles.has(t)){e.selectedFile=t;return}e._setLoading(!0),e._setLoadError(null);try{const n=new URLSearchParams({path:t,root:e.worktreePath}),r=yield $t(`${Rk}/api/fs/read?${n}`);e._addFile({path:t,content:r.content,mimeType:r.mimeType,size:r.size,lineCount:r.lineCount,truncated:r.truncated}),e.selectedFile=t}catch(n){e._setLoadError(n instanceof Error?n.message:"Failed to load file")}finally{e._setLoading(!1)}}}),saveFile:Ak(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(!(!n||!n.isDirty)){e._setSaving(!0),e._setSaveError(null);try{(yield fetch(`${Rk}/api/fs/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,root:e.worktreePath,content:n.content})}).then(i=>i.ok?i.json():i.json().then(a=>{throw new Error(a.error||"Failed to save file")}))).success&&e._markFileSaved(t)}catch(r){throw e._setSaveError(r instanceof Error?r.message:"Failed to save file"),r}finally{e._setSaving(!1)}}}),closeFile(t){e.openFiles.delete(t),e.selectedFile===t&&(e.selectedFile=null)}}));function KRe(){return qRe.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const yie=k.createContext(null);function YRe(e,t=!1,n){const r=k.useMemo(()=>KRe(),[]),i=k.useRef(!1);return k.useEffect(()=>{r.setWorktreePath(e),r.setReadOnly(t),i.current=!1,e&&r.loadFileTree().then(()=>{n&&!i.current&&(i.current=!0,r.selectFile(n),r.loadFile(n))})},[r,e,t,n]),r}function XRe(){const e=k.useContext(yie);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function _ie(){const e=XRe();return{worktreePath:e.worktreePath,readOnly:e.readOnly,selectedFile:e.selectedFile,currentFile:e.currentFile,expandedDirs:[...e.expandedDirs],fileTree:e.fileTree,isLoading:e.isLoading,isSaving:e.isSaving,isLoadingTree:e.isLoadingTree,loadError:e.loadError,saveError:e.saveError,treeError:e.treeError,isDirty:e.isDirty,selectFile:e.selectFile,loadFile:e.loadFile,saveFile:e.saveFile,closeFile:e.closeFile,updateContent:e.updateContent,toggleDir:e.toggleDir,collapseAll:e.collapseAll,toggleMarkdownView:e.toggleMarkdownView,isFileMarkdownView:e.isFileMarkdownView,isDirExpanded:e.isDirExpanded,refreshTree:e.loadFileTree}}const Eie=k.createContext(null);function zm(){const e=k.useContext(Eie);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function ZRe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function QRe({children:e,wsUrl:t=ZRe(),reconnectInterval:n=2e3,maxReconnectAttempts:r=10}){const i=k.useRef(null),a=k.useRef(0),s=k.useRef(void 0),o=k.useRef(null),[,l]=k.useState({}),u=k.useCallback(d=>{i.current?.readyState===WebSocket.OPEN?(At.ws.debug("send",{type:d.type}),i.current.send(JSON.stringify(d))):At.ws.warn("send dropped (WebSocket not open)",{type:d.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const d={send:u,log:At};o.current=VRe.create({},d)}const f=o.current;return k.useEffect(()=>{f.setMaxReconnectAttempts(r)},[f,r]),k.useEffect(()=>{let d=!0;const p=()=>{const m=i.current;if(m&&(m.readyState===WebSocket.CONNECTING||m.readyState===WebSocket.OPEN))return;const E=new WebSocket(t);i.current=E,E.onopen=()=>{d&&(At.ws.info("WebSocket connected"),f.setConnected(!0),a.current=0)},E.onmessage=S=>{if(d)try{const b=JSON.parse(S.data);f.handleMessage(b)}catch(b){At.ws.error("Failed to parse WebSocket message",{error:String(b)})}},E.onclose=()=>{if(d)if(At.ws.info("WebSocket disconnected"),f.setConnected(!1),i.current===E&&(i.current=null),a.current<r){a.current++,f.setReconnectAttempt(a.current);const S=n*Math.pow(1.5,a.current-1);At.ws.info("Scheduling reconnect",{attempt:a.current,delay:S}),s.current=setTimeout(p,S)}else At.ws.warn("Max reconnect attempts reached"),f.setReconnectAttempt(a.current)},E.onerror=S=>{At.ws.error("WebSocket error",{event:String(S)})}};return p(),()=>{d=!1,s.current&&clearTimeout(s.current);const m=i.current;m?.readyState===WebSocket.OPEN&&m.close(),i.current=null}},[t,n,r,f]),k.useEffect(()=>{l({})},[]),g.jsx(Eie.Provider,{value:f,children:e})}function Sie(){const e=zm(),{setTheme:t,resolvedTheme:n,theme:r}=ed(),{data:i}=nwe(),a=k.useRef(void 0),s=k.useRef(!1),o=k.useRef(!1);k.useEffect(()=>VM(()=>e.broadcastedTheme,f=>{f&&(o.current=!0,t(f),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),k.useEffect(()=>{let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.type="image/png",u.href="/logo.png"},[]),k.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&$t("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:n})}).catch(()=>{})},[i,n]);const l=k.useCallback(u=>{if(!o.current&&(t(u),e.syncTheme(u),i)){const f=u==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":u;$t("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:f})}).catch(()=>{})}},[t,e,i]);return{theme:r??"system",resolvedTheme:n,syncClaudeCode:i,changeTheme:l,isUpdating:!1}}let Nk=!1;const nH={activeTabId:null,focusedTerminals:{},currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function xie(){const e=wr(),t=k.useRef(void 0),n=k.useRef({}),{data:r=nH,isLoading:i}=qn({queryKey:["terminal-view-state"],queryFn:async()=>{const p=await fetch("/api/terminal-view-state");if(!p.ok)throw new Error("Failed to fetch terminal view state");return p.json()},staleTime:2e3}),a=Fn({mutationFn:async p=>{const m=await fetch("/api/terminal-view-state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!m.ok)throw new Error("Failed to update terminal view state");return m.json()},onSuccess:p=>{e.setQueryData(["terminal-view-state"],p)}}),s=k.useRef(a);s.current=a;const o=k.useCallback(p=>{const m=n.current;n.current={...m,...p,focusedTerminals:p.focusedTerminals||m.focusedTerminals?{...m.focusedTerminals,...p.focusedTerminals}:void 0};const E=n.current;e.setQueryData(["terminal-view-state"],S=>{const b=S??nH;return{activeTabId:E.activeTabId!==void 0?E.activeTabId:b.activeTabId,focusedTerminals:{...b.focusedTerminals,...E.focusedTerminals},currentView:E.currentView!==void 0?E.currentView:b.currentView,currentTaskId:E.currentTaskId!==void 0?E.currentTaskId:b.currentTaskId,isTabVisible:E.isTabVisible!==void 0?E.isTabVisible:b.isTabVisible,viewUpdatedAt:E.viewUpdatedAt!==void 0?E.viewUpdatedAt:b.viewUpdatedAt}}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{s.current.mutate(n.current),n.current={}},500)},[e]),l=k.useCallback((p,m)=>{if(m===null){const E=e.getQueryData(["terminal-view-state"]);if(E){const{[p]:S,...b}=E.focusedTerminals;o({focusedTerminals:b})}}else o({focusedTerminals:{[p]:m}})},[e,o]),u=k.useCallback(p=>r.focusedTerminals[p]??null,[r.focusedTerminals]),f=k.useRef(!1);k.useEffect(()=>{if(Nk){f.current=!1;return}Nk=!0,f.current=!0;const p=()=>{o({isTabVisible:document.visibilityState==="visible",viewUpdatedAt:new Date().toISOString()})};return document.addEventListener("visibilitychange",p),p(),()=>{document.removeEventListener("visibilitychange",p),f.current&&(Nk=!1)}},[o]);const d=k.useCallback((p,m,E)=>{o({currentView:p,currentTaskId:m,activeTabId:E,viewUpdatedAt:new Date().toISOString()})},[o]);return{viewState:r,isLoading:i,getFocusedTerminal:u,setFocusedTerminal:l,updateViewTracking:d}}function ao(e,t){const n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 100;if(n.startsWith(r))return 80;if(n.includes(r))return 60;let i=0,a=0,s=0;for(;i<n.length&&a<r.length;)n[i]===r[a]&&(s+=1,a++),i++;return a===r.length?s:0}function JRe(e,t){return t.trim()?e.map(r=>{let i=ao(r.label,t);if(r.keywords)for(const a of r.keywords){const s=ao(a,t);s>i&&(i=s)}return{command:r,score:i}}).filter(({score:r})=>r>0).sort((r,i)=>i.score-r.score).map(({command:r})=>r):e}function e2e(e){const t=new Map;for(const n of e){const r=t.get(n.category)||[];r.push(n),t.set(n.category,r)}return t}function t2e({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r,onOpenInEditor:i}){const{t:a}=Jt("navigation"),[s,o]=k.useState(!1),l=e??s,u=t??o,[f,d]=k.useState(""),[p,m]=k.useState(0),E=k.useRef(null),S=k.useRef(null),b=Li(),y=k.useMemo(()=>[{id:"goto-tasks",label:a("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:g.jsx(fe,{icon:Bp,size:16,strokeWidth:2}),action:()=>{b({to:"/tasks"}),u(!1)}},{id:"goto-terminals",label:a("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:g.jsx(fe,{icon:R1e,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals"}),u(!1)}},{id:"goto-task-terminals",label:a("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+i",keywords:["tasks","shell","console","cli"],category:"navigation",icon:g.jsx(fe,{icon:Bp,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals",search:{tab:"all-tasks"}}),u(!1)}},{id:"goto-repositories",label:a("commandPalette.commands.goToRepositories"),shortcut:"meta+3",keywords:["repos","git","projects"],category:"navigation",icon:g.jsx(fe,{icon:I1e,size:16,strokeWidth:2}),action:()=>{b({to:"/repositories"}),u(!1)}},{id:"goto-review",label:a("commandPalette.commands.goToReview"),shortcut:"meta+4",keywords:["pr","pull request","issues","github"],category:"navigation",icon:g.jsx(fe,{icon:uu,size:16,strokeWidth:2}),action:()=>{b({to:"/review"}),u(!1)}},{id:"goto-monitoring",label:a("commandPalette.commands.goToMonitoring"),shortcut:"meta+5",keywords:["system","cpu","memory","processes","usage"],category:"navigation",icon:g.jsx(fe,{icon:hte,size:16,strokeWidth:2}),action:()=>{b({to:"/monitoring"}),u(!1)}},{id:"goto-settings",label:a("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:g.jsx(fe,{icon:xte,size:16,strokeWidth:2}),action:()=>{b({to:"/settings"}),u(!1)}},{id:"new-task",label:a("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:g.jsx(fe,{icon:Dv,size:16,strokeWidth:2}),action:()=>{u(!1),n?.()}},{id:"open-in-editor",label:a("commandPalette.commands.openInEditor"),shortcut:"meta+e",keywords:["editor","code","vscode","cursor","folder","path"],category:"actions",icon:g.jsx(fe,{icon:iD,size:16,strokeWidth:2}),action:()=>{u(!1),i?.()}},{id:"show-shortcuts",label:a("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:g.jsx(fe,{icon:vte,size:16,strokeWidth:2}),action:()=>{u(!1),r?.()}}],[b,n,r,i,u,a]),v=k.useMemo(()=>JRe(y,f),[y,f]),x=k.useMemo(()=>e2e(v),[v]),T=k.useMemo(()=>{const R=[],O=["navigation","actions"];for(const N of O){const D=x.get(N);D&&R.push(...D)}return R},[x]);k.useEffect(()=>{m(0)},[f]),k.useEffect(()=>{if(!S.current)return;const R=S.current.querySelector('[data-selected="true"]');R&&R.scrollIntoView({block:"nearest"})},[p]),Ea("meta+k",()=>u(!0),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+1",()=>b({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+2",()=>b({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+i",()=>{b({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),Ea("meta+3",()=>b({to:"/repositories"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+4",()=>b({to:"/review"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+5",()=>b({to:"/monitoring"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+,",()=>b({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),Ea("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),Ea("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]}),Ea("meta+e",()=>{i?.()},{allowInInput:!1,allowInTerminal:!0,deps:[i]});const w=k.useCallback(R=>{switch(R.key){case"ArrowDown":R.preventDefault(),m(O=>Math.min(O+1,T.length-1));break;case"ArrowUp":R.preventDefault(),m(O=>Math.max(O-1,0));break;case"Enter":R.preventDefault(),T[p]&&T[p].action();break;case"Escape":R.preventDefault(),u(!1);break;case"1":R.preventDefault(),b({to:"/tasks"}),u(!1);break;case"2":R.preventDefault(),b({to:"/terminals"}),u(!1);break;case"3":R.preventDefault(),b({to:"/repositories"}),u(!1);break;case"4":R.preventDefault(),b({to:"/review"}),u(!1);break;case"5":R.preventDefault(),b({to:"/monitoring"}),u(!1);break}},[T,p,u,b]);k.useEffect(()=>{l&&(d(""),m(0),setTimeout(()=>E.current?.focus(),50))},[l]),k.useEffect(()=>{const R=O=>{if(O.data?.type==="vibora:action")switch(O.data.action){case"openCommandPalette":u(!0);break;case"openNewTask":n?.();break;case"showShortcuts":r?.();break}};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[u,n,r]);let C=0;return g.jsx(Du,{open:l,onOpenChange:u,children:g.jsxs(Lu,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:w,children:[g.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[g.jsx("span",{className:"text-muted-foreground mr-2",children:">"}),g.jsx(ln,{ref:E,value:f,onChange:R=>d(R.target.value),placeholder:a("commandPalette.placeholder"),className:"border-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0 h-12"}),g.jsx("kbd",{className:"pointer-events-none ml-2 inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"Esc"})]}),g.jsx("div",{ref:S,className:"max-h-80 overflow-y-auto p-2",children:v.length===0?g.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:a("commandPalette.noResults")}):g.jsx(g.Fragment,{children:["navigation","actions"].map(R=>{const O=x.get(R);return!O||O.length===0?null:g.jsxs("div",{className:"mb-2 last:mb-0",children:[g.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:a(`commandPalette.categories.${R}`)}),O.map(N=>{const D=C++,L=D===p;return g.jsxs("button",{"data-selected":L,onClick:()=>N.action(),onMouseEnter:()=>m(D),className:Be("flex w-full items-center gap-3 rounded-md px-2 py-2 text-sm",L?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[N.icon&&g.jsx("span",{className:"text-muted-foreground",children:N.icon}),g.jsx("span",{className:"flex-1 text-left",children:N.label}),N.shortcut&&g.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Cte(N.shortcut)})]},N.id)})]},R)})})})]})})}const rH={sm:"w-8 h-8",md:"w-9 h-9 md:w-12 md:h-12",lg:"w-12 h-12 md:w-16 md:h-16"};function n2e({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return g.jsx("div",{className:Be("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>g.jsx("div",{className:Be(rH[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>g.jsx("div",{className:Be(rH[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const r2e=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function i2e(){const e=ii({select:n=>n.location.pathname});return r2e.some(n=>e===n||e.startsWith(n+"/"))?g.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:g.jsx(n2e,{rows:100,cols:50,tileSize:"sm"})}):null}if(!k.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!Dre)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function a2e(e){e()}function s2e(e){e||(e=a2e),Rke({reactionScheduler:e})}function o2e(e){return Ike(e)}var l2e=1e4,u2e=1e4,c2e=(function(){function e(t){var n=this;Object.defineProperty(this,"finalize",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"registrations",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"sweepTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sweep",{enumerable:!0,configurable:!0,writable:!0,value:function(r){r===void 0&&(r=l2e),clearTimeout(n.sweepTimeout),n.sweepTimeout=void 0;var i=Date.now();n.registrations.forEach(function(a,s){i-a.registeredAt>=r&&(n.finalize(a.value),n.registrations.delete(s))}),n.registrations.size>0&&n.scheduleSweep()}}),Object.defineProperty(this,"finalizeAllImmediately",{enumerable:!0,configurable:!0,writable:!0,value:function(){n.sweep(0)}})}return Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){this.registrations.set(r,{value:n,registeredAt:Date.now()}),this.scheduleSweep()}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.registrations.delete(t)}}),Object.defineProperty(e.prototype,"scheduleSweep",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sweepTimeout===void 0&&(this.sweepTimeout=setTimeout(this.sweep,u2e))}}),e})(),d2e=typeof FinalizationRegistry<"u"?FinalizationRegistry:c2e,wD=new d2e(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function iH(e){e.reaction=new fl("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function f2e(e,t){t===void 0&&(t="observed");var n=oe.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(o){return wD.unregister(r),r.onStoreChange=o,r.reaction||(iH(r),r.stateVersion=Symbol()),function(){var l;r.onStoreChange=null,(l=r.reaction)===null||l===void 0||l.dispose(),r.reaction=null}},getSnapshot:function(){return r.stateVersion}};n.current=r}var i=n.current;i.reaction||(iH(i),wD.register(n,i,i)),oe.useDebugValue(i.reaction,o2e),BP.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot);var a,s;if(i.reaction.track(function(){try{a=e()}catch(o){s=o}}),s)throw s;return a}var Ik,Dk,wie=typeof Symbol=="function"&&Symbol.for,h2e=(Dk=(Ik=Object.getOwnPropertyDescriptor(function(){},"name"))===null||Ik===void 0?void 0:Ik.configurable)!==null&&Dk!==void 0?Dk:!1,aH=wie?Symbol.for("react.forward_ref"):typeof k.forwardRef=="function"&&k.forwardRef(function(e){return null}).$$typeof,sH=wie?Symbol.for("react.memo"):typeof k.memo=="function"&&k.memo(function(e){return null}).$$typeof;function p0(e,t){var n;if(sH&&e.$$typeof===sH)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var r=(n=void 0)!==null&&n!==void 0?n:!1,i=e,a=e.displayName||e.name;if(aH&&e.$$typeof===aH&&(r=!0,i=e.render,typeof i!="function"))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var s=function(o,l){return f2e(function(){return i(o,l)},a)};return s.displayName=e.displayName,h2e&&Object.defineProperty(s,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(s.contextTypes=e.contextTypes),r&&(s=k.forwardRef(s)),s=k.memo(s),m2e(e,s),s}var p2e={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function m2e(e,t){Object.keys(e).forEach(function(n){p2e[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var Lk;s2e(xr.unstable_batchedUpdates);Lk=wD.finalizeAllImmediately;const g2e=p0(function(){const t=zm();if(t.connected||!t.hasEverConnected)return null;const n=t.reconnectAttempt>0&&t.reconnectAttempt<t.maxReconnectAttempts,r=t.reconnectAttempt>=t.maxReconnectAttempts;return g.jsx("div",{className:Be("flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium","border-b",r?"bg-destructive/10 border-destructive/30 text-destructive":"bg-amber-500/10 border-amber-500/30 text-amber-600 dark:text-amber-400"),role:"alert","aria-live":"polite",children:r?g.jsxs(g.Fragment,{children:[g.jsx(fe,{icon:ss,size:16,strokeWidth:2}),g.jsx("span",{children:"Connection lost. Please check if the server is running."})]}):n?g.jsxs(g.Fragment,{children:[g.jsx(fe,{icon:rn,size:16,strokeWidth:2,className:"animate-spin"}),g.jsxs("span",{children:["Reconnecting... (attempt ",t.reconnectAttempt,"/",t.maxReconnectAttempts,")"]})]}):g.jsxs(g.Fragment,{children:[g.jsx(fe,{icon:ss,size:16,strokeWidth:2}),g.jsx("span",{children:"Disconnected from server"})]})})});function b2e(){return qn({queryKey:["system","dependencies"],queryFn:()=>$t("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}const oH="npm install -g @anthropic/claude-code",v2e="https://docs.anthropic.com/en/docs/claude-code/overview";function y2e(){const{data:e,isLoading:t}=b2e(),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(async()=>{try{await navigator.clipboard.writeText(oH),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=k.useCallback(()=>{r(!0)},[]);return t||n||e?.claudeCode?.installed?null:g.jsxs("div",{className:Be("flex items-center justify-between gap-4 px-4 py-3","border-b bg-amber-500/10 border-amber-500/30"),role:"alert",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(fe,{icon:ss,size:18,strokeWidth:2,className:"shrink-0 text-amber-600 dark:text-amber-400"}),g.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[g.jsx("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:"Claude Code CLI not found"}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("code",{className:"rounded bg-amber-500/20 px-2 py-0.5 text-xs font-mono text-amber-700 dark:text-amber-300",children:oH}),g.jsx("button",{onClick:s,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:i?"Copied!":"Copy to clipboard",children:g.jsx(fe,{icon:i?bl:N1e,size:14,strokeWidth:2})})]})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("a",{href:v2e,target:"_blank",rel:"noopener noreferrer",className:Be("text-xs font-medium px-2 py-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),children:"View Docs"}),g.jsx("button",{onClick:o,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:"Dismiss",children:g.jsx(fe,{icon:hi,size:16,strokeWidth:2})})]})]})}const _2e=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+i"},{labelKey:"goToRepositories",shortcut:"meta+3"},{labelKey:"goToReview",shortcut:"meta+4"},{labelKey:"goToMonitoring",shortcut:"meta+5"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{labelKey:"openInEditor",shortcut:"meta+e"},{labelKey:"keyboardShortcuts",shortcut:"meta+/"}]},{titleKey:"terminals",items:[{labelKey:"newTerminal",shortcut:"meta+d"},{labelKey:"closeTerminal",shortcut:"meta+w"}]},{titleKey:"general",items:[{labelKey:"closeModal",shortcut:"escape"},{labelKey:"submitForm",shortcut:"meta+enter"}]}];function E2e({open:e,onOpenChange:t}){const{t:n}=Jt("navigation");return g.jsx(Du,{open:e,onOpenChange:t,children:g.jsxs(Lu,{className:"sm:max-w-md",children:[g.jsx(sd,{children:g.jsx(od,{children:n("shortcuts.title")})}),g.jsx(jm,{className:"max-h-[60vh]",children:g.jsx("div",{className:"space-y-4 mt-2 pr-4",children:_2e.map(r=>g.jsxs("div",{children:[g.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:n(`shortcuts.groups.${r.titleKey}`)}),g.jsx("div",{className:"space-y-1",children:r.items.map(i=>g.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[g.jsx("span",{className:"text-sm",children:n(`shortcuts.labels.${i.labelKey}`)}),g.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Cte(i.shortcut)})]},i.shortcut))})]},r.titleKey))})})]})})}const S2e={vscode:"vscode",cursor:"cursor",windsurf:"windsurf",zed:"zed",antigravity:"antigravity"};function xw(e,t,n,r){const i=S2e[t];if(!n)return`${i}://file${e}`;const a=r!==22?`${n}:${r}`:n;return`${i}://vscode-remote/ssh-remote+${a}${e}`}function t3(e){return{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}[e]}function il(e){window.parent!==window?window.parent.postMessage({type:"vibora:openUrl",url:e},"*"):window.open(e,"_blank")}function x2e({open:e,onOpenChange:t}){const{t:n}=Jt("navigation"),[r,i]=k.useState(""),[a,s]=k.useState(!1),{data:o}=i0(),{data:l}=a0(),{data:u}=s0();k.useEffect(()=>{e&&i("")},[e]);const f=()=>{if(!r.trim())return;const m=xw(r.trim(),o??"vscode",l??"",u??22);il(m),t(!1)},d=m=>{i(m)},p=t3(o??"vscode");return g.jsxs(g.Fragment,{children:[g.jsx(Du,{open:e,onOpenChange:t,children:g.jsxs(Lu,{className:"sm:max-w-md",children:[g.jsxs(sd,{children:[g.jsx(od,{children:n("openInEditor.title")}),g.jsx(Jy,{children:n("openInEditor.description",{editor:p})})]}),g.jsx("div",{className:"space-y-4",children:g.jsxs("div",{className:"space-y-2",children:[g.jsx("label",{className:"text-sm font-medium",children:n("openInEditor.pathLabel")}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(ln,{value:r,onChange:m=>i(m.target.value),placeholder:n("openInEditor.pathPlaceholder"),onKeyDown:m=>m.key==="Enter"&&f(),className:"flex-1 font-mono text-sm"}),g.jsx(Ve,{variant:"outline",size:"icon",onClick:()=>s(!0),title:n("openInEditor.browse"),children:g.jsx(fe,{icon:Di,size:16,strokeWidth:2})})]}),g.jsx("p",{className:"text-xs text-muted-foreground",children:n("openInEditor.pathHint")})]})}),g.jsxs(Kc,{children:[g.jsx(Mf,{render:g.jsx(Ve,{variant:"outline"}),children:n("openInEditor.cancel")}),g.jsx(Ve,{onClick:f,disabled:!r.trim(),children:n("openInEditor.open")})]})]})}),g.jsx(Hc,{open:a,onOpenChange:s,onSelect:d})]})}const w2e=({...e})=>{const{resolvedTheme:t}=ed();return g.jsx(k_e,{theme:t,className:"toaster group",icons:{success:g.jsx(fe,{icon:pte,strokeWidth:2,className:"size-4"}),info:g.jsx(fe,{icon:B1e,strokeWidth:2,className:"size-4"}),warning:g.jsx(fe,{icon:ss,strokeWidth:2,className:"size-4"}),error:g.jsx(fe,{icon:H1e,strokeWidth:2,className:"size-4"}),loading:g.jsx(fe,{icon:rn,strokeWidth:2,className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...e})},No=nme({component:R2e});function T2e(){return wwe(),null}function C2e(){return Hne(),null}function A2e(){return Sie(),null}function k2e(){const e=ii({select:n=>n.location}),{updateViewTracking:t}=xie();return k.useEffect(()=>{const n=e.pathname;let r="other",i=null,a=null;n.startsWith("/tasks/")?(r="task-detail",i=n.split("/")[2]||null):n==="/terminals"&&(r="terminals",a=new URLSearchParams(e.search).get("tab")),t(r,i,a)},[e.pathname,e.search,t]),null}function O2e(){const e=ii({select:t=>t.location});return k.useEffect(()=>{window.parent!==window&&window.parent.postMessage({type:"vibora:route",pathname:e.pathname,search:e.search},"*")},[e.pathname,e.search]),null}function R2e(){const[e,t]=k.useState(null),[n,r]=k.useState(!1),[i,a]=k.useState(!1),[s,o]=k.useState(!1),l=typeof window<"u"&&window.parent!==window,u=k.useCallback(E=>{t(()=>E)},[]),f=k.useCallback(()=>{e?.()},[e]),d=k.useCallback(()=>{r(!0)},[]),p=k.useCallback(()=>{a(!0)},[]),m=k.useCallback(()=>{o(!0)},[]);return g.jsx(I_e,{children:g.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[g.jsx(T2e,{}),g.jsx(C2e,{}),g.jsx(A2e,{}),g.jsx(k2e,{}),g.jsx(O2e,{}),g.jsx(g2e,{}),g.jsx(y2e,{}),g.jsx(_we,{onNewTaskRef:u,onOpenCommandPalette:p}),g.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[g.jsx(i2e,{}),g.jsx(fJ,{})]}),g.jsx(t2e,{open:i,onOpenChange:a,onNewTask:f,onShowShortcuts:d,onOpenInEditor:m}),g.jsx(E2e,{open:n,onOpenChange:r}),g.jsx(x2e,{open:s,onOpenChange:o}),g.jsx(w2e,{position:l?"bottom-center":"bottom-right"})]})})}const N2e=$s("/")({beforeLoad:()=>{throw XQ({to:"/tasks"})}}),TD="";function Tie(){const[e,t]=k.useState(new Map),[n,r]=k.useState(null),[i,a]=k.useState(!0),[s,o]=k.useState(!1),[l,u]=k.useState(null),f=k.useRef(null),d=k.useRef(0),p=k.useRef(!1),m=k.useCallback(async()=>{a(!0),u(null);try{const b=await fetch(`${TD}/api/worktrees/json`);if(!b.ok)throw new Error("Failed to fetch worktrees");const y=await b.json();t(new Map(y.worktrees.map(v=>[v.path,{...v,size:v.size||0,sizeFormatted:v.sizeFormatted||"0 B",branch:v.branch||"unknown"}]))),r(y.summary),a(!1),o(!1)}catch(b){u(b instanceof Error?b:new Error("Failed to load worktrees")),a(!1),o(!1)}},[]),E=k.useCallback(()=>{if(p.current){m();return}f.current?.close(),a(!0),o(!1),u(null),t(new Map),r(null);const b=new EventSource(`${TD}/api/worktrees`);f.current=b,b.addEventListener("worktree:basic",y=>{const v=JSON.parse(y.data);d.current=v.length,t(new Map(v.map(x=>[x.path,{...x,size:0,sizeFormatted:"...",branch:"..."}]))),a(!1),o(v.length>0)}),b.addEventListener("worktree:details",y=>{const v=JSON.parse(y.data);t(x=>{const T=new Map(x),w=T.get(v.path);return w&&T.set(v.path,{...w,size:v.size,sizeFormatted:v.sizeFormatted,branch:v.branch}),T}),d.current--,d.current<=0&&o(!1)}),b.addEventListener("worktree:complete",y=>{const v=JSON.parse(y.data);r(v),o(!1),b.close()}),b.addEventListener("worktree:error",y=>{const{path:v}=JSON.parse(y.data);At.viewer.error("Error loading worktree details",{path:v}),d.current--,d.current<=0&&o(!1)}),b.onerror=()=>{b.close(),At.viewer.info("SSE connection failed, trying JSON fallback"),p.current=!0,m()}},[m]);return k.useEffect(()=>(E(),()=>{f.current?.close()}),[E]),{worktrees:k.useMemo(()=>Array.from(e.values()).sort((y,v)=>y.isOrphaned!==v.isOrphaned?y.isOrphaned?-1:1:new Date(v.lastModified).getTime()-new Date(y.lastModified).getTime()),[e]),summary:n,isLoading:i,isLoadingDetails:s,error:l,refetch:E}}function Cie(){const e=wr();return Fn({mutationFn:({worktreePath:t,repoPath:n,deleteLinkedTask:r})=>$t(`${TD}/api/worktrees`,{method:"DELETE",body:JSON.stringify({worktreePath:t,repoPath:n,deleteLinkedTask:r})}),onSuccess:()=>{e.invalidateQueries({queryKey:["worktrees"]}),e.invalidateQueries({queryKey:["tasks"]})}})}const I2e=nd("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function po({className:e,variant:t="default",render:n,...r}){return Axe({defaultTagName:"span",props:cl({className:Be(I2e({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function Ra({className:e,size:t="default",...n}){return g.jsx("div",{"data-slot":"card","data-size":t,className:Be("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),...n})}function D2e({className:e,...t}){return g.jsx("div",{"data-slot":"card-header",className:Be("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function L2e({className:e,...t}){return g.jsx("div",{"data-slot":"card-title",className:Be("text-sm font-medium",e),...t})}function Bf({className:e,...t}){return g.jsx("div",{"data-slot":"card-content",className:Be("px-4 group-data-[size=sm]/card:px-3",e),...t})}function yo({...e}){return g.jsx(zEe,{"data-slot":"alert-dialog",...e})}function Cu({...e}){return g.jsx(Mte,{"data-slot":"alert-dialog-trigger",...e})}function P2e({...e}){return g.jsx(Ite,{"data-slot":"alert-dialog-portal",...e})}function M2e({className:e,...t}){return g.jsx(kte,{"data-slot":"alert-dialog-overlay",className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",e),...t})}function _o({className:e,size:t="default",...n}){return g.jsxs(P2e,{children:[g.jsx(M2e,{}),g.jsx(Nte,{"data-slot":"alert-dialog-content","data-size":t,className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",e),...n})]})}function Eo({className:e,...t}){return g.jsx("div",{"data-slot":"alert-dialog-header",className:Be("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function So({className:e,...t}){return g.jsx("div",{"data-slot":"alert-dialog-footer",className:Be("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function xo({className:e,...t}){return g.jsx(Pte,{"data-slot":"alert-dialog-title",className:Be("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function wo({className:e,...t}){return g.jsx(Ote,{"data-slot":"alert-dialog-description",className:Be("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function Kp({className:e,...t}){return g.jsx(Ve,{"data-slot":"alert-dialog-action",className:Be(e),...t})}function To({className:e,variant:t="outline",size:n="default",...r}){return g.jsx(Jx,{"data-slot":"alert-dialog-cancel",className:Be(e),render:g.jsx(Ve,{variant:t,size:n}),...r})}const pi=k.forwardRef(({className:e,...t},n)=>g.jsx(bSe,{ref:n,className:Be("peer size-4 shrink-0 rounded border border-input ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-checked:border-primary data-checked:text-primary-foreground","flex items-center justify-center transition-colors",e),...t,children:g.jsx(vSe,{className:"flex items-center justify-center",children:g.jsx(fe,{icon:bl,size:12,strokeWidth:3})})}));pi.displayName="Checkbox";const CD={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},j2e=$s("/worktrees/")({component:$2e});function F2e(){const{t:e}=Jt("common");return t=>{const n=new Date(t),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),s=Math.floor(a/60),o=Math.floor(s/60),l=Math.floor(o/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):o>0?o===1?e("time.hourAgo"):e("time.hoursAgo",{count:o}):s>0?s===1?e("time.minuteAgo"):e("time.minutesAgo",{count:s}):e("time.justNow")}}function lH({className:e}){return g.jsx("span",{className:`inline-block animate-pulse rounded bg-muted ${e}`})}function B2e({worktree:e,onDelete:t}){const{t:n}=Jt("common"),{t:r}=Jt("worktrees"),i=F2e(),[a,s]=k.useState(!1),[o,l]=k.useState(!1),[u,f]=k.useState(!1),d=e.sizeFormatted==="..."||e.branch==="...",p=!e.isOrphaned&&e.taskId,m=async()=>{l(!0);try{await t(e,u),s(!1)}catch{}finally{l(!1)}},E=S=>{s(S),S||f(!1)};return g.jsx(Ra,{className:"transition-colors hover:border-border/80",children:g.jsxs(Bf,{className:"flex items-start justify-between gap-4 py-4",children:[g.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"truncate font-medium",children:e.name}),e.isOrphaned?g.jsx(po,{className:Be("shrink-0",CD.ORPHANED),children:n("statuses.ORPHANED")}):e.taskStatus?g.jsx(po,{className:Be("shrink-0",CD[e.taskStatus]),children:n(`statuses.${e.taskStatus}`)}):null]}),g.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:Di,size:12,strokeWidth:2,className:"shrink-0"}),g.jsx("span",{className:"truncate font-mono",children:e.path})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:Zx,size:12,strokeWidth:2,className:"shrink-0"}),e.branch==="..."?g.jsx(lH,{className:"h-3 w-16"}):g.jsx("span",{className:"font-mono",children:e.branch})]}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:bte,size:12,strokeWidth:2,className:"shrink-0"}),e.sizeFormatted==="..."?g.jsx(lH,{className:"h-3 w-12"}):g.jsx("span",{children:e.sizeFormatted})]}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(fe,{icon:fte,size:12,strokeWidth:2,className:"shrink-0"}),g.jsx("span",{children:i(e.lastModified)})]})]}),e.taskId&&e.taskTitle&&g.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:g.jsxs(Ri,{to:"/tasks/$taskId",params:{taskId:e.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[g.jsx("span",{className:"truncate",children:e.taskTitle}),g.jsx(fe,{icon:Qy,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),g.jsxs(yo,{open:a,onOpenChange:E,children:[g.jsx(Cu,{render:g.jsx(Ve,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d}),children:g.jsx(fe,{icon:yu,size:14,strokeWidth:2})}),g.jsxs(_o,{children:[g.jsxs(Eo,{children:[g.jsx(xo,{children:r("delete.title")}),g.jsxs(wo,{children:[r("delete.description")," ",g.jsx("span",{className:"font-mono",children:e.name}),".",u&&p&&g.jsxs(g.Fragment,{children:[" ",r("delete.linkedTaskWillBeDeleted",{title:e.taskTitle})]})," ",r("delete.cannotUndo")]}),p&&g.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[g.jsx(pi,{checked:u,onCheckedChange:S=>f(S===!0),disabled:o}),r("delete.alsoDeleteLinkedTask",{title:e.taskTitle})]})]}),g.jsxs(So,{children:[g.jsx(To,{disabled:o,children:n("buttons.cancel")}),g.jsxs(Ve,{variant:"destructive",onClick:m,disabled:o,className:"gap-2",children:[o&&g.jsx(fe,{icon:rn,size:14,strokeWidth:2,className:"animate-spin"}),n(o?"status.deleting":"buttons.delete")]})]})]})]})]})})}const U2e=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function $2e(){const{t:e}=Jt("common"),{t}=Jt("worktrees"),{worktrees:n,summary:r,isLoading:i,isLoadingDetails:a,error:s,refetch:o}=Tie(),l=Cie(),[u,f]=k.useState(new Set),[d,p]=k.useState(!1),[m,E]=k.useState(!1),[S,b]=k.useState(!1),y=O=>{f(N=>{const D=new Set(N);return D.has(O)?D.delete(O):D.add(O),D})},v=()=>{f(new Set)},x=k.useMemo(()=>u.size===0?n:n.filter(O=>!!(O.isOrphaned&&u.has("ORPHANED")||O.taskStatus&&u.has(O.taskStatus))),[n,u]),T=k.useMemo(()=>n.filter(O=>O.taskStatus==="DONE"||O.taskStatus==="CANCELED"),[n]),w=async()=>{if(T.length!==0){E(!0);try{for(const O of T)await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:S});p(!1),o()}catch{}finally{E(!1)}}},C=O=>{p(O),O||b(!1)},R=async(O,N)=>{await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:N}),o()};return g.jsxs("div",{className:"flex h-full flex-col",children:[g.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border bg-background px-4 py-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx("h1",{className:"text-sm font-medium",children:t("title")}),(r||n.length>0)&&g.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[g.jsx("span",{children:t("summary.total",{count:r?.total??n.length})}),(r?.orphaned??n.filter(O=>O.isOrphaned).length)>0&&g.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:r?.orphaned??n.filter(O=>O.isOrphaned).length})}),a?g.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):r?g.jsx("span",{children:r.totalSizeFormatted}):null]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&g.jsxs(yo,{open:d,onOpenChange:C,children:[g.jsxs(Cu,{render:g.jsx(Ve,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:a}),children:[g.jsx(fe,{icon:mte,size:12,strokeWidth:2}),t("cleanup.button",{count:T.length})]}),g.jsxs(_o,{children:[g.jsxs(Eo,{children:[g.jsx(xo,{children:t("cleanup.title")}),g.jsxs(wo,{children:[t("cleanup.description",{count:T.length}),S&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),g.jsxs("div",{className:"space-y-3",children:[g.jsxs("p",{className:"text-sm text-muted-foreground",children:[T.filter(O=>O.taskStatus==="DONE").length>0&&g.jsxs("span",{className:"mr-3",children:[g.jsx("span",{className:"font-medium text-accent",children:T.filter(O=>O.taskStatus==="DONE").length})," ",t("cleanup.done")]}),T.filter(O=>O.taskStatus==="CANCELED").length>0&&g.jsxs("span",{children:[g.jsx("span",{className:"font-medium text-destructive",children:T.filter(O=>O.taskStatus==="CANCELED").length})," ",t("cleanup.canceled")]})]}),g.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[g.jsx(pi,{checked:S,onCheckedChange:O=>b(O===!0),disabled:m}),t("cleanup.alsoDeleteLinkedTasks")]}),g.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),g.jsxs(So,{children:[g.jsx(To,{disabled:m,children:e("buttons.cancel")}),g.jsxs(Ve,{variant:"destructive",onClick:w,disabled:m,className:"gap-2",children:[m&&g.jsx(fe,{icon:rn,size:14,strokeWidth:2,className:"animate-spin"}),m?e("status.deleting"):t("delete.button",{count:T.length})]})]})]})]}),u.size>0&&g.jsxs(Ve,{variant:"ghost",size:"sm",onClick:v,className:"gap-1.5 text-xs",children:[g.jsx(fe,{icon:hi,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),g.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:U2e.map(O=>{const N=u.has(O);return g.jsx("button",{onClick:()=>y(O),className:Be("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",N?CD[O]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${O}`)},O)})})]}),g.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[i&&g.jsx("div",{className:"flex items-center justify-center py-12",children:g.jsx(fe,{icon:rn,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),s&&g.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[g.jsx(fe,{icon:ss,size:20,strokeWidth:2}),g.jsx("span",{className:"text-sm",children:t("error.failedToLoad",{message:s.message})})]}),!i&&!s&&x.length===0&&g.jsx("div",{className:"py-12 text-muted-foreground",children:g.jsx("p",{className:"text-sm",children:u.size>0?t("empty.noMatch"):t("empty.noWorktrees")})}),!i&&g.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:x.map(O=>g.jsx(B2e,{worktree:O,onDelete:R},O.path))})]})]})}function Wn(e,t="Assertion error"){if(!e)throw Error(t)}function Yp({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function AD(e,t){return t.sort(e==="horizontal"?z2e:H2e)}function z2e(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function H2e(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Aie(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function W2e({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,a=Number.MAX_VALUE;for(const s of t){const{x:o,y:l}=Aie(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return Wn(i,"No rect found"),i}function kie(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=AD(n,Array.from(t.children).filter(f=>f instanceof HTMLElement).map(f=>({element:f}))).map(({element:f})=>f),s=[];let o=!1,l,u=[];for(const f of a)if(f.hasAttribute("data-panel")){const d=r.find(p=>p.element===f);if(d){if(l){const p=l.element.getBoundingClientRect(),m=f.getBoundingClientRect();let E;if(o){const S=n==="horizontal"?new DOMRect(p.right,p.top,0,p.height):new DOMRect(p.left,p.bottom,p.width,0),b=n==="horizontal"?new DOMRect(m.left,m.top,0,m.height):new DOMRect(m.left,m.top,m.width,0);switch(u.length){case 0:{E=[S,b];break}case 1:{const y=u[0],v=W2e({orientation:n,rects:[p,m],targetRect:y.element.getBoundingClientRect()});E=[y,v===p?b:S];break}default:{E=u;break}}}else u.length?E=u:E=[n==="horizontal"?new DOMRect(p.right,m.top,m.left-p.right,m.height):new DOMRect(m.left,p.bottom,m.width,m.top-p.bottom)];for(const S of E)s.push({group:e,groupSize:Yp({group:e}),panels:[l,d],separator:"width"in S?void 0:S,rect:"width"in S?S:S.element.getBoundingClientRect()})}o=!1,l=d,u=[]}}else if(f.hasAttribute("data-separator")){const d=i.find(p=>p.element===f);d?u.push(d):(l=void 0,u=[])}else o=!0;return s}function V2e(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function G2e(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function q2e(e){return e/100*window.innerHeight}function K2e(e){return e/100*window.innerWidth}function Y2e(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function D_({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=Y2e(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=G2e(t,i);break}case"em":{r=V2e(t,i);break}case"vh":{r=q2e(i);break}case"vw":{r=K2e(i);break}}return r}function lo(e){return parseFloat(e.toFixed(3))}function uH(e){const{panels:t}=e,n=Yp({group:e});return n===0?t.map(r=>({collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:a}=r;let s=0;if(a.collapsedSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=lo(f/n*100)}let o;if(a.defaultSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=lo(f/n*100)}let l=0;if(a.minSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.minSize});l=lo(f/n*100)}let u=100;if(a.maxSize){const f=D_({groupSize:n,panelElement:i,styleProp:a.maxSize});u=lo(f/n*100)}return{collapsedSize:s,collapsible:a.collapsible===!0,defaultSize:o,minSize:l,maxSize:u,panelId:r.id}})}class X2e{#e={};addListener(t,n){const r=this.#e[t];return r===void 0?this.#e[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=this.#e[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,a=null;const s=Array.from(r);for(let o=0;o<s.length;o++){const l=s[o];try{l.call(null,n)}catch(u){a===null&&(i=!0,a=u)}}if(i)throw a}}removeAllListeners(){this.#e={}}removeListener(t,n){const r=this.#e[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}function na(e,t,n=0){return Math.abs(lo(e)-lo(t))<=n}let ws={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const xf=new X2e;function El(){return ws}function Fs(e){const t=typeof e=="function"?e(ws):e;if(ws===t)return ws;const n=ws;return ws={...ws,...t},t.cursorFlags!==void 0&&xf.emit("cursorFlagsChange",ws.cursorFlags),t.interactionState!==void 0&&xf.emit("interactionStateChange",ws.interactionState),t.mountedGroups!==void 0&&(ws.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=na(a.collapsedSize,r.layout[a.panelId]),l=na(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),xf.emit("mountedGroupsChange",ws.mountedGroups)),ws}const Z2e=e=>e,Pk=()=>{},Oie=1,Rie=2,Nie=4,Iie=8,cH={coarse:10,precise:5};function Q2e({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(a=>{if(!a.disableCursor)switch(a.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(r===0&&i===0)return null;switch(n){case"active":{const a=(e&Oie)!==0,s=(e&Rie)!==0,o=(e&Nie)!==0,l=(e&Iie)!==0;if(e){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}break}}return r>0&&i>0?"move":r>0?"ew-resize":"ns-resize"}let Mk,Uo;function n3(){Uo===void 0&&(Uo=new CSSStyleSheet,document.adoptedStyleSheets=[Uo]);const{cursorFlags:e,interactionState:t}=El();switch(t.state){case"active":case"hover":{const n=Q2e({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(Mk===r)return;Mk=r,n?Uo.cssRules.length===0?Uo.insertRule(r):Uo.replaceSync(r):Uo.cssRules.length===1&&Uo.deleteRule(0);break}case"inactive":{Mk=void 0,Uo.cssRules.length===1&&Uo.deleteRule(0);break}}}function J2e(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function zv(e,t){return na(e,t)?0:e>t?1:-1}function dp({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if(zv(t,a)<0)if(r){const s=(n+a)/2;zv(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=lo(t),t}function Hv({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(na(e,0))return t;const s=Object.values(t),o=Object.values(i),l=[...s],[u,f]=r;Wn(u!=null,"Invalid first pivot index"),Wn(f!=null,"Invalid second pivot index");let d=0;if(a==="keyboard"){{const E=e<0?f:u,S=n[E];Wn(S,`Panel constraints not found for index ${E}`);const{collapsedSize:b=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),na(x,b)){const T=v-x;zv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const E=e<0?u:f,S=n[E];Wn(S,`No panel constraints found for index ${E}`);const{collapsedSize:b=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),na(x,v)){const T=x-b;zv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const E=e<0?1:-1;let S=e<0?f:u,b=0;for(;;){const v=s[S];Wn(v!=null,`Previous layout not found for panel index ${S}`);const x=dp({panelConstraints:n[S],size:100})-v;if(b+=x,S+=E,S<0||S>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-y:y}{let E=e<0?u:f;for(;E>=0&&E<n.length;){const S=Math.abs(e)-Math.abs(d),b=s[E];Wn(b!=null,`Previous layout not found for panel index ${E}`);const y=b-S,v=dp({panelConstraints:n[E],size:y});if(!na(b,v)&&(d+=b-v,l[E]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?E--:E++}}if(J2e(o,l))return i;{const E=e<0?f:u,S=s[E];Wn(S!=null,`Previous layout not found for panel index ${E}`);const b=S+d,y=dp({panelConstraints:n[E],size:b});if(l[E]=y,!na(y,b)){let v=b-y,x=e<0?f:u;for(;x>=0&&x<n.length;){const T=l[x];Wn(T!=null,`Previous layout not found for panel index ${x}`);const w=T+v,C=dp({panelConstraints:n[x],size:w});if(na(T,C)||(v-=C-T,l[x]=C),na(v,0))break;e>0?x--:x++}}}const p=Object.values(l).reduce((E,S)=>S+E,0);if(!na(p,100,.1))return i;const m=Object.keys(i);return l.reduce((E,S,b)=>(E[m[b]]=S,E),{})}function Hm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||zv(e[n],t[n])!==0)return!1;return!0}function Die({event:e,hitRegions:t,initialLayoutMap:n,mountedGroups:r,pointerDownAtPoint:i}){let a=0;const s=new Map(r);t.forEach(o=>{const{group:l,groupSize:u}=o,{disableCursor:f,orientation:d,panels:p}=l;let m=0;i?d==="horizontal"?m=(e.clientX-i.x)/u*100:m=(e.clientY-i.y)/u*100:d==="horizontal"?m=e.clientX<0?-100:100:m=e.clientY<0?-100:100;const E=n.get(l),{defaultLayoutDeferred:S,derivedPanelConstraints:b,layout:y,separatorToPanels:v}=r.get(l)??{defaultLayoutDeferred:!1};if(b&&E&&y&&v){const x=Hv({delta:m,initialLayout:E,panelConstraints:b,pivotIndices:o.panels.map(T=>p.indexOf(T)),prevLayout:y,trigger:"mouse-or-touch"});if(Hm(x,y)){if(m!==0&&!f)switch(d){case"horizontal":{a|=m<0?Oie:Rie;break}case"vertical":{a|=m<0?Nie:Iie;break}}}else{s.set(o.group,{defaultLayoutDeferred:S,derivedPanelConstraints:b,layout:x,separatorToPanels:v});const T=o.group.panels.map(({id:w})=>w).join(",");o.group.inMemoryLayouts[T]=x}}}),Fs({cursorFlags:a,mountedGroups:s}),n3()}function dH(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=El();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&Die({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function _E(e){const t=e.parentElement;Wn(t,"Parent group element not found");const{mountedGroups:n}=El();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Uf({layout:e,panelConstraints:t}){const n=[...Object.values(e)],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!na(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=100/r*o;n[s]=l}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=dp({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!na(i,0))for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=o+i,u=dp({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,na(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Lie({groupId:e}){const t=()=>{const{mountedGroups:n}=El();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:a,layout:s,separatorToPanels:o}=t(),l=Uf({layout:n,panelConstraints:i});return r?s:(Hm(s,l)||Fs(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function Pie(e){const{mountedGroups:t}=El(),n=t.get(e);return Wn(n,`Mounted Group ${e.id} not found`),n}function Bd(e,t){const n=_E(e),r=Pie(n),i=n.separators.find(f=>f.element===e);Wn(i,"Matching separator not found");const a=r.separatorToPanels.get(i);Wn(a,"Matching panels not found");const s=a.map(f=>n.panels.indexOf(f)),o=Lie({groupId:n.id}).getLayout(),l=Hv({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Uf({layout:l,panelConstraints:r.derivedPanelConstraints});Hm(o,u)||Fs(f=>({mountedGroups:new Map(f.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function fH(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=_E(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,-5);break}case"End":{e.preventDefault(),Bd(t,100);break}case"Enter":{e.preventDefault();const r=_E(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=Pie(r),o=r.separators.find(d=>d.element===t);Wn(o,"Matching separator not found");const l=s.get(o);Wn(l,"Matching panels not found");const u=l[0],f=i.find(d=>d.panelId===u.id);if(Wn(f,"Panel metadata not found"),f.collapsible){const d=a[u.id],p=f.collapsedSize===d?r.inMemoryLastExpandedPanelSizes[u.id]??f.minSize:f.collapsedSize;Bd(t,p-d)}break}case"F6":{e.preventDefault();const r=_E(t).separators.map(s=>s.element),i=Array.from(r).findIndex(s=>s===e.currentTarget);Wn(i!==null,"Index not found");const a=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[a].focus();break}case"Home":{e.preventDefault(),Bd(t,-100);break}}}function eNe(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=Aie(n,a.rect);switch(e){case"horizontal":{s.x<=i.x&&(r=a,i=s);break}case"vertical":{s.y<=i.y&&(r=a,i=s);break}}}return r?{distance:i,hitRegion:r}:void 0}let L_;function tNe(){return L_===void 0&&(typeof matchMedia=="function"?L_=!!matchMedia("(pointer:coarse)").matches:L_=!1),L_}function nNe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mH(e),b:mH(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Wn(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pH(hH(n.a)),b:pH(hH(n.b))};if(i.a===i.b){const a=r.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let o=a.length;for(;o--;){const l=a[o];if(l===s.a)return 1;if(l===s.b)return-1}}return Math.sign(i.a-i.b)}const rNe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function iNe(e){const t=getComputedStyle(Mie(e)??e).display;return t==="flex"||t==="inline-flex"}function aNe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||iNe(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||rNe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function hH(e){let t=e.length;for(;t--;){const n=e[t];if(Wn(n,"Missing node"),aNe(n))return n}return null}function pH(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mH(e){const t=[];for(;e;)t.push(e),e=Mie(e);return t}function Mie(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function sNe(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function oNe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if(nNe(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(sNe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function jie(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=tNe()?cH.coarse:cH.precise,s=kie(i),o=eNe(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&oNe({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function gH(e){if(e.defaultPrevented)return;const{mountedGroups:t}=El(),n=jie(e,t),r=new Set,i=new Set,a=new Set,s=new Map;let o=!1;n.forEach(l=>{r.add(l.group),l.panels.forEach(f=>{i.add(f)}),l.separator&&(a.add(l.separator),o||(o=!0,l.separator.element.focus()));const u=t.get(l.group);u&&s.set(l.group,u.layout)}),Fs({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function bH(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=El();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){Fs(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}Die({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=jie(e,n);r.length===0?t.state!=="inactive"&&Fs({interactionState:{state:"inactive"}}):Fs({interactionState:{hitRegions:r,state:"hover"}}),n3();break}}}function vH(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=El();t.state==="active"&&(Fs({cursorFlags:0,interactionState:{state:"inactive"}}),n3())}function yH(e){let t=0,n=0;const r={};for(const a of e)if(a.defaultSize!==void 0){t++;const s=lo(a.defaultSize);n+=s,r[a.panelId]=s}else r[a.panelId]=void 0;const i=e.length-t;if(i!==0){const a=lo((100-n)/i);for(const s of e)s.defaultSize===void 0&&(r[s.panelId]=a)}return r}function lNe(e,t,n){const r=n[0];if(!r)return;const i=e.panels.find(s=>s.element===t);if(!i||!i.onResize)return;const a=Yp({group:e});i.onResize({asPercentage:lo(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function uNe(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function cNe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(m=>{for(const E of m){const{borderBoxSize:S,target:b}=E;if(b===e.element){if(t){if(Yp({group:e})===0)return;Fs(y=>{const v=y.mountedGroups.get(e);if(v){const x=uH(e),T=v.defaultLayoutDeferred?yH(x):v.layout,w=Uf({layout:T,panelConstraints:x});return!v.defaultLayoutDeferred&&Hm(T,w)&&uNe(v.derivedPanelConstraints,x)?y:{mountedGroups:new Map(y.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:x,layout:w,separatorToPanels:v.separatorToPanels})}}return y})}}else lNe(e,b,S)}});i.observe(e.element),e.panels.forEach(m=>{Wn(!n.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.onResize&&i.observe(m.element)});const a=Yp({group:e}),s=uH(e),o=e.panels.map(({id:m})=>m).join(",");let l=e.defaultLayout;l&&e.panels.length!==Object.keys(l).length&&(l=void 0);const u=e.inMemoryLayouts[o]??l??yH(s),f=Uf({layout:u,panelConstraints:s}),d=kie(e),p=Fs(m=>{const E=new Map;return d.forEach(S=>{S.separator&&E.set(S.separator,S.panels)}),{mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:f,separatorToPanels:E})}});return e.element.addEventListener("pointerleave",dH),e.separators.forEach(m=>{Wn(!r.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.element.addEventListener("keydown",fH)}),p.mountedGroups.size===1&&(window.addEventListener("pointerdown",gH),window.addEventListener("pointermove",bH),window.addEventListener("pointerup",vH)),function(){t=!1;const m=Fs(E=>{const S=new Map(E.mountedGroups);return S.delete(e),{mountedGroups:S}});e.element.removeEventListener("pointerleave",dH),e.separators.forEach(E=>{E.element.removeEventListener("keydown",fH)}),m.mountedGroups.size===0&&(window.removeEventListener("pointerdown",gH),window.removeEventListener("pointermove",bH),window.removeEventListener("pointerup",vH)),i.disconnect()}}function r3(e){const t=k.useId();return`${e??t}`}const eh=typeof window<"u"?k.useLayoutEffect:k.useEffect;function i3(e){const t=k.useRef(e);return eh(()=>{t.current=e},[e]),k.useCallback(n=>t.current?.(n),[t])}function a3(...e){return i3(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function dNe(e){const t=k.useRef({...e});return eh(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Fie="--react-resizable-panels--panel--pointer-events";function Bie(e,t){const n=e.replace(/[^a-zA-Z0-9\-_]/g,""),r=t.replace(/[^a-zA-Z0-9\-_]/g,"");return`--react-resizable-panels--${n}--${r}`}const Uie=k.createContext(null);function fNe(e,t){const n=k.useRef({getLayout:()=>({}),setLayout:Z2e});k.useImperativeHandle(t,()=>n.current,[]),eh(()=>{Object.assign(n.current,Lie({groupId:e}))})}function hNe({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:s,id:o,onLayoutChange:l,orientation:u="horizontal",style:f,...d}){const p=k.useRef({}),m=i3(H=>{Hm(p.current,H)||(p.current=H,l?.(H))}),E=r3(o),[S,b]=k.useState(!1),[y,v]=k.useState(null),[x,T]=k.useState(n??{}),[w,C]=k.useState([]),[R,O]=k.useState([]),N=k.useRef({lastExpandedPanelSizes:{},layouts:{}}),D=a3(v,a);fNe(E,s);const L=k.useMemo(()=>({id:E,orientation:u,registerPanel:H=>(C(B=>AD(u,[...B,H])),()=>{C(B=>B.filter(q=>q!==H))}),registerSeparator:H=>(O(B=>AD(u,[...B,H])),()=>{O(B=>B.filter(q=>q!==H))})}),[E,u]),z=dNe({defaultLayout:n,disableCursor:r}),P=k.useRef(null);eh(()=>{if(y===null)return;const H={defaultLayout:z.defaultLayout,disableCursor:!!z.disableCursor,disabled:!!i,element:y,id:E,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:R};P.current=H;const B=cNe(H),q=El().mountedGroups.get(H);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:$,layout:Y}=q;!j&&$.length>0&&(T(Y),m?.(Y))}const K=xf.addListener("interactionStateChange",j=>{j.state==="active"?b(j.hitRegions.some($=>$.group===H)):b(!1)}),U=xf.addListener("mountedGroupsChange",j=>{const $=j.get(H);if($){const{defaultLayoutDeferred:Y,derivedPanelConstraints:W,layout:ee}=$;if(Y||W.length===0)return;T(ee),m?.(ee)}});return()=>{P.current=null,B(),K(),U()}},[i,y,E,m,u,w,R,z]),k.useEffect(()=>{const H=P.current;H&&(H.defaultLayout=n,H.disableCursor=!!r)});const G={[Fie]:S?"none":void 0};for(const H in x){const B=Bie(E,H),q=x[H];G[B]=q}return g.jsx(Uie.Provider,{value:L,children:g.jsx("div",{...d,"aria-orientation":u,className:t,"data-group":!0,"data-testid":E,id:E,ref:D,style:{...f,...G,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function s3(){const e=k.useContext(Uie);return Wn(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function pNe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=El();for(const[l,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:d,separatorToPanels:p}]of o)if(l.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:l,layout:d,separatorToPanels:p};throw Error(`Group ${e} not found`)},r=()=>{const o=n().derivedPanelConstraints.find(l=>l.panelId===t);if(o!==void 0)return o;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const o=n().group.panels.find(l=>l.id===t);if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},a=()=>{const o=n().layout[t];if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},s=o=>{const l=a();if(o===l)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:d,layout:p,separatorToPanels:m}=n(),E=d.panels.findIndex(v=>v.id===t),S=E===d.panels.length-1,b=Hv({delta:S?l-o:o-l,initialLayout:p,panelConstraints:f,pivotIndices:S?[E-1,E]:[E,E+1],prevLayout:p,trigger:"imperative-api"}),y=Uf({layout:b,panelConstraints:f});Hm(p,y)||Fs(v=>({mountedGroups:new Map(v.mountedGroups).set(d,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:y,separatorToPanels:m})}))};return{collapse:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();o&&u!==l&&s(l)},expand:()=>{const{collapsible:o,collapsedSize:l,minSize:u}=r(),f=a();o&&f===l&&s(u)},getSize:()=>{const{group:o}=n(),l=a(),{element:u}=i(),f=o.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:l,inPixels:f}},isCollapsed:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();return o&&na(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),f=Yp({group:u});l=lo(o/f*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function mNe(e,t){const{id:n}=s3(),r=k.useRef({collapse:Pk,expand:Pk,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Pk});k.useImperativeHandle(t,()=>r.current,[]),eh(()=>{Object.assign(r.current,pNe({groupId:n,panelId:e}))})}function gNe({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,elementRef:a,id:s,maxSize:o="100%",minSize:l="0%",onResize:u,panelRef:f,style:d,...p}){const m=!!s,E=r3(s),[S,b]=k.useState(null),y=a3(b,a),{id:v,registerPanel:x}=s3(),T=u!==null,w=i3(R=>{u?.(R,s)});eh(()=>{if(S!==null)return x({element:S,id:E,idIsStable:m,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,S,T,E,m,o,l,w,x]),mNe(E,f);const C=Bie(v,E);return g.jsx("div",{...p,"data-panel":!0,"data-testid":E,id:E,ref:y,style:{...bNe,flexBasis:0,flexGrow:`var(${C}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Fie})`},children:g.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const bNe={minHeight:"unset",maxHeight:"unset",height:"unset",minWidth:"unset",maxWidth:"unset",width:"unset",flex:"unset",flexBasis:"unset",flexShrink:"unset",flexGrow:"unset",border:"unset",borderWidth:"unset",padding:"unset",margin:"unset"};function vNe({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a;const s=e[n],o=t.find(l=>l.panelId===n);if(o){const l=o.maxSize,u=a=o.collapsible?o.collapsedSize:o.minSize,f=[r,r+1];a=Uf({layout:Hv({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Uf({layout:Hv({delta:l-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:s}}function yNe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=r3(r),[o,l]=k.useState({}),[u,f]=k.useState("inactive"),[d,p]=k.useState(null),m=a3(p,n),{id:E,orientation:S,registerSeparator:b}=s3(),y=S==="horizontal"?"vertical":"horizontal";return eh(()=>{if(d!==null){const v={element:d,id:s},x=b(v),T=xf.addListener("interactionStateChange",C=>{f(C.state!=="inactive"&&C.hitRegions.some(R=>R.separator===v)?C.state:"inactive")}),w=xf.addListener("mountedGroupsChange",C=>{C.forEach(({derivedPanelConstraints:R,layout:O,separatorToPanels:N},D)=>{if(D.id===E){const L=N.get(v);if(L){const z=L[0],P=D.panels.indexOf(z);l(vNe({layout:O,panelConstraints:R,panelId:z.id,panelIndex:P}))}}})});return()=>{T(),w(),x()}}},[d,E,s,b]),g.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":y,"aria-valuemax":o.valueMax,"aria-valuemin":o.valueMin,"aria-valuenow":o.valueNow,children:e,className:t,"data-separator":u,"data-testid":s,id:s,ref:m,role:"separator",style:{flexBasis:"auto",...i,flexGrow:0,flexShrink:0},tabIndex:0})}function Yd({className:e,direction:t,...n}){return g.jsx(hNe,{"data-slot":"resizable-panel-group",orientation:t,className:Be("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function As({...e}){return g.jsx(gNe,{"data-slot":"resizable-panel",...e})}function Xd({withHandle:e,className:t,...n}){return g.jsx(yNe,{"data-slot":"resizable-handle",className:Be("relative flex w-px items-center justify-center bg-border cursor-grab active:cursor-grabbing group touch-none","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","focus-visible:ring-offset-1 focus-visible:ring-offset-background","data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:cursor-row-resize","[&[data-orientation=vertical]>div]:rotate-90",t),...n,children:e&&g.jsxs("div",{className:"pointer-events-none absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center gap-1 bg-muted/90 border border-border rounded-full px-1 py-3 opacity-70 group-hover:opacity-100 group-focus:opacity-100 transition-opacity shadow-sm",children:[g.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),g.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),g.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"})]})})}var jk={exports:{}},_H;function _Ne(){return _H||(_H=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(s,o,l){var u=this&&this.__decorate||function(v,x,T,w){var C,R=arguments.length,O=R<3?x:w===null?w=Object.getOwnPropertyDescriptor(x,T):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,x,T,w);else for(var N=v.length-1;N>=0;N--)(C=v[N])&&(O=(R<3?C(O):R>3?C(x,T,O):C(x,T))||O);return R>3&&O&&Object.defineProperty(x,T,O),O},f=this&&this.__param||function(v,x){return function(T,w){x(T,w,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const d=l(9042),p=l(9924),m=l(844),E=l(4725),S=l(2585),b=l(3656);let y=o.AccessibilityManager=class extends m.Disposable{constructor(v,x,T,w){super(),this._terminal=v,this._coreBrowserService=T,this._renderService=w,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new p.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
32
32
|
`)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,b.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,m.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(v){for(let x=0;x<v;x++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
|
|
33
33
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=d.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,x){this._liveRegionDebouncer.refresh(v,x,this._terminal.rows)}_renderRows(v,x){const T=this._terminal.buffer,w=T.lines.length.toString();for(let C=v;C<=x;C++){const R=T.lines.get(T.ydisp+C),O=[],N=R?.translateToString(!0,void 0,void 0,O)||"",D=(T.ydisp+C+1).toString(),L=this._rowElements[C];L&&(N.length===0?(L.innerText=" ",this._rowColumns.set(L,[0,1])):(L.textContent=N,this._rowColumns.set(L,O)),L.setAttribute("aria-posinset",D),L.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,x){const T=v.target,w=this._rowElements[x===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==w)return;let C,R;if(x===0?(C=T,R=this._rowElements.pop(),this._rowContainer.removeChild(R)):(C=this._rowElements.shift(),R=T,this._rowContainer.removeChild(C)),C.removeEventListener("focus",this._topBoundaryFocusListener),R.removeEventListener("focus",this._bottomBoundaryFocusListener),x===0){const O=this._createAccessibilityTreeNode();this._rowElements.unshift(O),this._rowContainer.insertAdjacentElement("afterbegin",O)}else{const O=this._createAccessibilityTreeNode();this._rowElements.push(O),this._rowContainer.appendChild(O)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let x={node:v.anchorNode,offset:v.anchorOffset},T={node:v.focusNode,offset:v.focusOffset};if((x.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||x.node===T.node&&x.offset>T.offset)&&([x,T]=[T,x]),x.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(x={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(x.node))return;const w=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(w)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:w,offset:w.textContent?.length??0}),!this._rowContainer.contains(T.node))return;const C=({node:N,offset:D})=>{const L=N instanceof Text?N.parentNode:N;let z=parseInt(L?.getAttribute("aria-posinset"),10)-1;if(isNaN(z))return console.warn("row is invalid. Race condition?"),null;const P=this._rowColumns.get(L);if(!P)return console.warn("columns is null. Race condition?"),null;let G=D<P.length?P[D]:P.slice(-1)[0]+1;return G>=this._terminal.cols&&(++z,G=0),{row:z,column:G}},R=C(x),O=C(T);if(R&&O){if(R.row>O.row||R.row===O.row&&R.column>=O.column)throw new Error("invalid range");this._terminal.select(R.column,R.row,(O.row-R.row)*this._terminal.cols-R.column+O.column)}}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=y=u([f(1,S.IInstantiationService),f(2,E.ICoreBrowserService),f(3,E.IRenderService)],y)},3614:(s,o)=>{function l(p){return p.replace(/\r?\n/g,"\r")}function u(p,m){return m?"\x1B[200~"+p+"\x1B[201~":p}function f(p,m,E,S){p=u(p=l(p),E.decPrivateModes.bracketedPasteMode&&S.rawOptions.ignoreBracketedPasteMode!==!0),E.triggerDataEvent(p,!0),m.value=""}function d(p,m,E){const S=E.getBoundingClientRect(),b=p.clientX-S.left-10,y=p.clientY-S.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${b}px`,m.style.top=`${y}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=l,o.bracketTextForPaste=u,o.copyHandler=function(p,m){p.clipboardData&&p.clipboardData.setData("text/plain",m.selectionText),p.preventDefault()},o.handlePasteEvent=function(p,m,E,S){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),m,E,S)},o.paste=f,o.moveTextAreaUnderMouseCursor=d,o.rightClickHandler=function(p,m,E,S,b){d(p,m,E),b&&S.rightClickSelect(p),m.value=S.selectionText,m.select()}},7239:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const u=l(1505);o.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(f,d,p){this._css.set(f,d,p)}getCss(f,d){return this._css.get(f,d)}setColor(f,d,p){this._color.set(f,d,p)}getColor(f,d){return this._color.get(f,d)}clear(){this._color.clear(),this._css.clear()}}},3656:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(l,u,f,d){l.addEventListener(u,f,d);let p=!1;return{dispose:()=>{p||(p=!0,l.removeEventListener(u,f,d))}}}},3551:function(s,o,l){var u=this&&this.__decorate||function(y,v,x,T){var w,C=arguments.length,R=C<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,x):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,v,x,T);else for(var O=y.length-1;O>=0;O--)(w=y[O])&&(R=(C<3?w(R):C>3?w(v,x,R):w(v,x))||R);return C>3&&R&&Object.defineProperty(v,x,R),R},f=this&&this.__param||function(y,v){return function(x,T){v(x,T,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const d=l(3656),p=l(8460),m=l(844),E=l(2585),S=l(4725);let b=o.Linkifier=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(y,v,x,T,w){super(),this._element=y,this._mouseService=v,this._renderService=x,this._bufferService=T,this._linkProviderService=w,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,d.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,d.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(y){this._lastMouseEvent=y;const v=this._positionFromMouseEvent(y,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const x=y.composedPath();for(let T=0;T<x.length;T++){const w=x[T];if(w.classList.contains("xterm"))break;if(w.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_handleHover(y){if(this._activeLine!==y.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(y,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,y)||(this._clearCurrentLink(),this._askForLink(y,!0))}_askForLink(y,v){this._activeProviderReplies&&v||(this._activeProviderReplies?.forEach((T=>{T?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=y.y);let x=!1;for(const[T,w]of this._linkProviderService.linkProviders.entries())v?this._activeProviderReplies?.get(T)&&(x=this._checkLinkProviderResult(T,y,x)):w.provideLinks(y.y,(C=>{if(this._isMouseOut)return;const R=C?.map((O=>({link:O})));this._activeProviderReplies?.set(T,R),x=this._checkLinkProviderResult(T,y,x),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(y.y,this._activeProviderReplies)}))}_removeIntersectingLinks(y,v){const x=new Set;for(let T=0;T<v.size;T++){const w=v.get(T);if(w)for(let C=0;C<w.length;C++){const R=w[C],O=R.link.range.start.y<y?0:R.link.range.start.x,N=R.link.range.end.y>y?this._bufferService.cols:R.link.range.end.x;for(let D=O;D<=N;D++){if(x.has(D)){w.splice(C--,1);break}x.add(D)}}}}_checkLinkProviderResult(y,v,x){if(!this._activeProviderReplies)return x;const T=this._activeProviderReplies.get(y);let w=!1;for(let C=0;C<y;C++)this._activeProviderReplies.has(C)&&!this._activeProviderReplies.get(C)||(w=!0);if(!w&&T){const C=T.find((R=>this._linkAtPosition(R.link,v)));C&&(x=!0,this._handleNewLink(C))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!x)for(let C=0;C<this._activeProviderReplies.size;C++){const R=this._activeProviderReplies.get(C)?.find((O=>this._linkAtPosition(O.link,v)));if(R){x=!0,this._handleNewLink(R);break}}return x}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(y){if(!this._currentLink)return;const v=this._positionFromMouseEvent(y,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(y,this._currentLink.link.text)}_clearCurrentLink(y,v){this._currentLink&&this._lastMouseEvent&&(!y||!v||this._currentLink.link.range.start.y>=y&&this._currentLink.link.range.end.y<=v)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(y){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(y.link,v)&&(this._currentLink=y,this._currentLink.state={decorations:{underline:y.link.decorations===void 0||y.link.decorations.underline,pointerCursor:y.link.decorations===void 0||y.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,y.link,this._lastMouseEvent),y.link.decorations={},Object.defineProperties(y.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:x=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==x&&(this._currentLink.state.decorations.pointerCursor=x,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",x))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:x=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==x&&(this._currentLink.state.decorations.underline=x,this._currentLink.state.isHovered&&this._fireUnderlineEvent(y.link,x))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((x=>{if(!this._currentLink)return;const T=x.start===0?0:x.start+1+this._bufferService.buffer.ydisp,w=this._bufferService.buffer.ydisp+1+x.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=w&&(this._clearCurrentLink(T,w),this._lastMouseEvent)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(y,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&y.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(x,v.text)}_fireUnderlineEvent(y,v){const x=y.range,T=this._bufferService.buffer.ydisp,w=this._createLinkUnderlineEvent(x.start.x-1,x.start.y-T-1,x.end.x,x.end.y-T-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(w)}_linkLeave(y,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&y.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(x,v.text)}_linkAtPosition(y,v){const x=y.range.start.y*this._bufferService.cols+y.range.start.x,T=y.range.end.y*this._bufferService.cols+y.range.end.x,w=v.y*this._bufferService.cols+v.x;return x<=w&&w<=T}_positionFromMouseEvent(y,v,x){const T=x.getCoords(y,v,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(y,v,x,T,w){return{x1:y,y1:v,x2:x,y2:T,cols:this._bufferService.cols,fg:w}}};o.Linkifier=b=u([f(1,S.IMouseService),f(2,S.IRenderService),f(3,E.IBufferService),f(4,S.ILinkProviderService)],b)},9042:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(s,o,l){var u=this&&this.__decorate||function(S,b,y,v){var x,T=arguments.length,w=T<3?b:v===null?v=Object.getOwnPropertyDescriptor(b,y):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(S,b,y,v);else for(var C=S.length-1;C>=0;C--)(x=S[C])&&(w=(T<3?x(w):T>3?x(b,y,w):x(b,y))||w);return T>3&&w&&Object.defineProperty(b,y,w),w},f=this&&this.__param||function(S,b){return function(y,v){b(y,v,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const d=l(511),p=l(2585);let m=o.OscLinkProvider=class{constructor(S,b,y){this._bufferService=S,this._optionsService=b,this._oscLinkService=y}provideLinks(S,b){const y=this._bufferService.buffer.lines.get(S-1);if(!y)return void b(void 0);const v=[],x=this._optionsService.rawOptions.linkHandler,T=new d.CellData,w=y.getTrimmedLength();let C=-1,R=-1,O=!1;for(let N=0;N<w;N++)if(R!==-1||y.hasContent(N)){if(y.loadCell(N,T),T.hasExtendedAttrs()&&T.extended.urlId){if(R===-1){R=N,C=T.extended.urlId;continue}O=T.extended.urlId!==C}else R!==-1&&(O=!0);if(O||R!==-1&&N===w-1){const D=this._oscLinkService.getLinkData(C)?.uri;if(D){const L={start:{x:R+1,y:S},end:{x:N+(O||N!==w-1?0:1),y:S}};let z=!1;if(!x?.allowNonHttpProtocols)try{const P=new URL(D);["http:","https:"].includes(P.protocol)||(z=!0)}catch{z=!0}z||v.push({text:D,range:L,activate:(P,G)=>x?x.activate(P,G,L):E(0,G),hover:(P,G)=>x?.hover?.(P,G,L),leave:(P,G)=>x?.leave?.(P,G,L)})}O=!1,T.hasExtendedAttrs()&&T.extended.urlId?(R=N,C=T.extended.urlId):(R=-1,C=-1)}}b(v)}};function E(S,b){if(confirm(`Do you want to navigate to ${b}?
|
|
34
34
|
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="/logo.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vibora</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-C28vAs6n.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-_L2gAsP8.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -20809,7 +20809,17 @@ class BufferManager {
|
|
|
20809
20809
|
}
|
|
20810
20810
|
}
|
|
20811
20811
|
|
|
20812
|
-
// server/
|
|
20812
|
+
// server/lib/env.ts
|
|
20813
|
+
var SERVER_ENV_VARS = [
|
|
20814
|
+
"DEBUG",
|
|
20815
|
+
"LOG_LEVEL",
|
|
20816
|
+
"VITE_LOG_LEVEL",
|
|
20817
|
+
"VIBORA_PACKAGE_ROOT",
|
|
20818
|
+
"VIBORA_DEVELOPER",
|
|
20819
|
+
"HOST",
|
|
20820
|
+
"VIBORA_DIR",
|
|
20821
|
+
"BUN_PTY_LIB"
|
|
20822
|
+
];
|
|
20813
20823
|
var ZAI_ENV_VARS = [
|
|
20814
20824
|
"ANTHROPIC_AUTH_TOKEN",
|
|
20815
20825
|
"ANTHROPIC_BASE_URL",
|
|
@@ -20819,21 +20829,28 @@ var ZAI_ENV_VARS = [
|
|
|
20819
20829
|
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
20820
20830
|
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
|
20821
20831
|
];
|
|
20822
|
-
function
|
|
20832
|
+
function getShellEnv() {
|
|
20823
20833
|
const { PORT: _PORT, NODE_ENV: _NODE_ENV, ...envWithoutFiltered } = process.env;
|
|
20824
|
-
const zaiSettings = getZAiSettings();
|
|
20825
|
-
if (zaiSettings.enabled) {
|
|
20826
|
-
return envWithoutFiltered;
|
|
20827
|
-
}
|
|
20828
20834
|
const filtered = {};
|
|
20829
20835
|
for (const [key, value] of Object.entries(envWithoutFiltered)) {
|
|
20830
|
-
if (!
|
|
20836
|
+
if (!SERVER_ENV_VARS.includes(key) && value !== undefined) {
|
|
20831
20837
|
filtered[key] = value;
|
|
20832
20838
|
}
|
|
20833
20839
|
}
|
|
20834
|
-
|
|
20840
|
+
const zaiSettings = getZAiSettings();
|
|
20841
|
+
if (zaiSettings.enabled) {
|
|
20842
|
+
return filtered;
|
|
20843
|
+
}
|
|
20844
|
+
const result = {};
|
|
20845
|
+
for (const [key, value] of Object.entries(filtered)) {
|
|
20846
|
+
if (!ZAI_ENV_VARS.includes(key)) {
|
|
20847
|
+
result[key] = value;
|
|
20848
|
+
}
|
|
20849
|
+
}
|
|
20850
|
+
return result;
|
|
20835
20851
|
}
|
|
20836
20852
|
|
|
20853
|
+
// server/terminal/terminal-session.ts
|
|
20837
20854
|
class TerminalSession {
|
|
20838
20855
|
id;
|
|
20839
20856
|
_name;
|
|
@@ -20896,7 +20913,7 @@ class TerminalSession {
|
|
|
20896
20913
|
rows: this.rows,
|
|
20897
20914
|
cwd: this.cwd,
|
|
20898
20915
|
env: {
|
|
20899
|
-
...
|
|
20916
|
+
...getShellEnv(),
|
|
20900
20917
|
TERM: "xterm-256color",
|
|
20901
20918
|
COLORTERM: "truecolor",
|
|
20902
20919
|
SSH_TTY: "/dev/pts/vibora",
|
|
@@ -20949,7 +20966,7 @@ class TerminalSession {
|
|
|
20949
20966
|
rows: this.rows,
|
|
20950
20967
|
cwd: this.cwd,
|
|
20951
20968
|
env: {
|
|
20952
|
-
...
|
|
20969
|
+
...getShellEnv(),
|
|
20953
20970
|
TERM: "xterm-256color",
|
|
20954
20971
|
COLORTERM: "truecolor",
|
|
20955
20972
|
NODE_ENV: "",
|
|
@@ -152770,7 +152787,7 @@ function createSession(cwd, name) {
|
|
|
152770
152787
|
const initialCwd = cwd || os6.homedir();
|
|
152771
152788
|
const proc2 = spawn3("/bin/bash", ["--norc", "--noprofile"], {
|
|
152772
152789
|
cwd: initialCwd,
|
|
152773
|
-
env: { ...
|
|
152790
|
+
env: { ...getShellEnv(), TERM: "dumb" },
|
|
152774
152791
|
stdio: ["pipe", "pipe", "pipe"]
|
|
152775
152792
|
});
|
|
152776
152793
|
const session = {
|