/*!--------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
/******************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

export function __extends(d, b) {
    if (typeof b !== "function" && b !== null)
        throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

export var __assign = function() {
    __assign = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    }
    return __assign.apply(this, arguments);
}

export function __rest(s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
}

export function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

export function __param(paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
}

export function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
    var _, done = false;
    for (var i = decorators.length - 1; i >= 0; i--) {
        var context = {};
        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
        if (kind === "accessor") {
            if (result === void 0) continue;
            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
            if (_ = accept(result.get)) descriptor.get = _;
            if (_ = accept(result.set)) descriptor.set = _;
            if (_ = accept(result.init)) initializers.unshift(_);
        }
        else if (_ = accept(result)) {
            if (kind === "field") initializers.unshift(_);
            else descriptor[key] = _;
        }
    }
    if (target) Object.defineProperty(target, contextIn.name, descriptor);
    done = true;
};

export function __runInitializers(thisArg, initializers, value) {
    var useValue = arguments.length > 2;
    for (var i = 0; i < initializers.length; i++) {
        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
    }
    return useValue ? value : void 0;
};

export function __propKey(x) {
    return typeof x === "symbol" ? x : "".concat(x);
};

export function __setFunctionName(f, name, prefix) {
    if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
    return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
};

export function __metadata(metadataKey, metadataValue) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}

export function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

export function __generator(thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
}

export var __createBinding = Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
        desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
});

export function __exportStar(m, o) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
}

export function __values(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

export function __read(o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
}

/** @deprecated */
export function __spread() {
    for (var ar = [], i = 0; i < arguments.length; i++)
        ar = ar.concat(__read(arguments[i]));
    return ar;
}

/** @deprecated */
export function __spreadArrays() {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
}

export function __spreadArray(to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
}

export function __await(v) {
    return this instanceof __await ? (this.v = v, this) : new __await(v);
}

export function __asyncGenerator(thisArg, _arguments, generator) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var g = generator.apply(thisArg, _arguments || []), i, q = [];
    return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
    function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
    function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
    function fulfill(value) { resume("next", value); }
    function reject(value) { resume("throw", value); }
    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}

export function __asyncDelegator(o) {
    var i, p;
    return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
    function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
}

export function __asyncValues(o) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var m = o[Symbol.asyncIterator], i;
    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}

export function __makeTemplateObject(cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};

var __setModuleDefault = Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
};

export function __importStar(mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
}

export function __importDefault(mod) {
    return (mod && mod.__esModule) ? mod : { default: mod };
}

export function __classPrivateFieldGet(receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}

export function __classPrivateFieldSet(receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}

export function __classPrivateFieldIn(state, receiver) {
    if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
    return typeof state === "function" ? receiver === state : state.has(receiver);
}

export function __addDisposableResource(env, value, async) {
    if (value !== null && value !== void 0) {
        if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
        var dispose, inner;
        if (async) {
            if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
            dispose = value[Symbol.asyncDispose];
        }
        if (dispose === void 0) {
            if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
            dispose = value[Symbol.dispose];
            if (async) inner = dispose;
        }
        if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
        if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
        env.stack.push({ value: value, dispose: dispose, async: async });
    }
    else if (async) {
        env.stack.push({ async: true });
    }
    return value;

}

var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
    var e = new Error(message);
    return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

export function __disposeResources(env) {
    function fail(e) {
        env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
        env.hasError = true;
    }
    function next() {
        while (env.stack.length) {
            var rec = env.stack.pop();
            try {
                var result = rec.dispose && rec.dispose.call(rec.value);
                if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
            }
            catch (e) {
                fail(e);
            }
        }
        if (env.hasError) throw env.error;
    }
    return next();
}

export default {
    __extends: __extends,
    __assign: __assign,
    __rest: __rest,
    __decorate: __decorate,
    __param: __param,
    __metadata: __metadata,
    __awaiter: __awaiter,
    __generator: __generator,
    __createBinding: __createBinding,
    __exportStar: __exportStar,
    __values: __values,
    __read: __read,
    __spread: __spread,
    __spreadArrays: __spreadArrays,
    __spreadArray: __spreadArray,
    __await: __await,
    __asyncGenerator: __asyncGenerator,
    __asyncDelegator: __asyncDelegator,
    __asyncValues: __asyncValues,
    __makeTemplateObject: __makeTemplateObject,
    __importStar: __importStar,
    __importDefault: __importDefault,
    __classPrivateFieldGet: __classPrivateFieldGet,
    __classPrivateFieldSet: __classPrivateFieldSet,
    __classPrivateFieldIn: __classPrivateFieldIn,
    __addDisposableResource: __addDisposableResource,
    __disposeResources: __disposeResources,
};

var Rp=Object.defineProperty;var Ep=Object.getOwnPropertyDescriptor;var D=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ep(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Rp(t,e,i),i},re=(r,t)=>(e,n)=>t(e,n,r);function wp(r,t,e=0,n=r.length){let i=e,o=n;for(;i<o;){let s=Math.floor((i+o)/2);t(r[s])?i=s+1:o=s}return i-1}var Pl=class r{constructor(t){this._array=t;this._findLastMonotonousLastIdx=0}static{this.assertInvariants=!1}findLastMonotonous(t){if(r.assertInvariants){if(this._prevFindLastPredicate){for(let n of this._array)if(this._prevFindLastPredicate(n)&&!t(n))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}let e=wp(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=e+1,e===-1?void 0:this._array[e]}};var bs=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?ot.isErrorNoTelemetry(t)?new ot(t.message+`

`+t.stack):new Error(t.message+`

`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},kl=new bs;function Pt(r){kl.onUnexpectedError(r)}function oe(r){Cp(r)||kl.onUnexpectedError(r)}var gi="Canceled";function Cp(r){return r instanceof Ie?!0:r instanceof Error&&r.name===gi&&r.message===gi}var Ie=class extends Error{constructor(){super(gi),this.name=this.message}},Al=class r extends Error{static{this._name="PendingMigrationError"}static is(t){return t instanceof r||t instanceof Error&&t.name===r._name}constructor(t){super(t),this.name=r._name}};function mi(){let r=new Error(gi);return r.name=r.message,r}function vi(r){return r?new Error(`Illegal state: ${r}`):new Error("Illegal state")}var ot=class r extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof r)return t;let e=new r;return e.message=t.message,e.stack=t.stack,e}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},X=class r extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,r.prototype)}};function yr(r,t,e=(n,i)=>n===i){if(r===t)return!0;if(!r||!t||r.length!==t.length)return!1;for(let n=0,i=r.length;n<i;n++)if(!e(r[n],t[n]))return!1;return!0}function yi(r){return r.filter(t=>!!t)}function Is(r,t){return r.push(t),()=>Pp(r,t)}function Pp(r,t){let e=r.indexOf(t);if(e>-1)return r.splice(e,1),t}function Ts(r,t){let e;if(typeof t=="number"){let n=t;e=()=>{let i=Math.sin(n++)*179426549;return i-Math.floor(i)}}else e=Math.random;for(let n=r.length-1;n>0;n-=1){let i=Math.floor(e()*(n+1)),o=r[n];r[n]=r[i],r[i]=o}}function Ll(r){return r[Math.floor(Math.random()*r.length)]}var Fl;(a=>{function r(l){return l<0}a.isLessThan=r;function t(l){return l<=0}a.isLessThanOrEqual=t;function e(l){return l>0}a.isGreaterThan=e;function n(l){return l===0}a.isNeitherLessOrGreaterThan=n,a.greaterThan=1,a.lessThan=-1,a.neitherLessOrGreaterThan=0})(Fl||={});function Ul(r,t){return(e,n)=>t(r(e),r(n))}var Nl=(r,t)=>r-t;var Ol=class r{constructor(t){this.iterate=t}static{this.empty=new r(t=>{})}forEach(t){this.iterate(e=>(t(e),!0))}toArray(){let t=[];return this.iterate(e=>(t.push(e),!0)),t}filter(t){return new r(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new r(e=>this.iterate(n=>e(t(n))))}some(t){let e=!1;return this.iterate(n=>(e=t(n),!e)),e}findFirst(t){let e;return this.iterate(n=>t(n)?(e=n,!1):!0),e}findLast(t){let e;return this.iterate(n=>(t(n)&&(e=n),!0)),e}findLastMaxBy(t){let e,n=!0;return this.iterate(i=>((n||Fl.isGreaterThan(t(i,e)))&&(n=!1,e=i),!0)),e}};function Vl(r,t){let e=Object.create(null);for(let n of r){let i=t(n),o=e[i];o||(o=e[i]=[]),o.push(n)}return e}var Bl,ql,Wl=class{constructor(t,e){this.toKey=e;this._map=new Map;this[Bl]="SetWithKey";for(let n of t)this.add(n)}get size(){return this._map.size}add(t){let e=this.toKey(t);return this._map.set(e,t),this}delete(t){return this._map.delete(this.toKey(t))}has(t){return this._map.has(this.toKey(t))}*entries(){for(let t of this._map.values())yield[t,t]}keys(){return this.values()}*values(){for(let t of this._map.values())yield t}clear(){this._map.clear()}forEach(t,e){this._map.forEach(n=>t.call(e,n,n,this))}[(ql=Symbol.iterator,Bl=Symbol.toStringTag,ql)](){return this.values()}};function In(r,t){let e=this,n=!1,i;return function(){if(n)return i;if(n=!0,t)try{i=r.apply(e,arguments)}finally{t()}else i=r.apply(e,arguments);return i}}var Ss=class{constructor(t,e){this.uri=t;this.value=e}};function Ap(r){return Array.isArray(r)}var Kl,ht=class r{constructor(t,e){this[Kl]="ResourceMap";if(t instanceof r)this.map=new Map(t.map),this.toKey=e??r.defaultToKey;else if(Ap(t)){this.map=new Map,this.toKey=e??r.defaultToKey;for(let[n,i]of t)this.set(n,i)}else this.map=new Map,this.toKey=t??r.defaultToKey}static{this.defaultToKey=t=>t.toString()}set(t,e){return this.map.set(this.toKey(t),new Ss(t,e)),this}get(t){return this.map.get(this.toKey(t))?.value}has(t){return this.map.has(this.toKey(t))}get size(){return this.map.size}clear(){this.map.clear()}delete(t){return this.map.delete(this.toKey(t))}forEach(t,e){typeof e<"u"&&(t=t.bind(e));for(let[n,i]of this.map)t(i.value,i.uri,this)}*values(){for(let t of this.map.values())yield t.value}*keys(){for(let t of this.map.values())yield t.uri}*entries(){for(let t of this.map.values())yield[t.uri,t.value]}*[(Kl=Symbol.toStringTag,Symbol.iterator)](){for(let[,t]of this.map)yield[t.uri,t.value]}},jl,$l=class{constructor(t,e){this[jl]="ResourceSet";!t||typeof t=="function"?this._map=new ht(t):(this._map=new ht(e),t.forEach(this.add,this))}get size(){return this._map.size}add(t){return this._map.set(t,t),this}clear(){this._map.clear()}delete(t){return this._map.delete(t)}forEach(t,e){this._map.forEach((n,i)=>t.call(e,i,i,this))}has(t){return this._map.has(t)}entries(){return this._map.entries()}keys(){return this._map.keys()}values(){return this._map.keys()}[(jl=Symbol.toStringTag,Symbol.iterator)](){return this.keys()}};var zl,_s=class{constructor(){this[zl]="LinkedMap";this._map=new Map,this._head=void 0,this._tail=void 0,this._size=0,this._state=0}clear(){this._map.clear(),this._head=void 0,this._tail=void 0,this._size=0,this._state++}isEmpty(){return!this._head&&!this._tail}get size(){return this._size}get first(){return this._head?.value}get last(){return this._tail?.value}has(t){return this._map.has(t)}get(t,e=0){let n=this._map.get(t);if(n)return e!==0&&this.touch(n,e),n.value}set(t,e,n=0){let i=this._map.get(t);if(i)i.value=e,n!==0&&this.touch(i,n);else{switch(i={key:t,value:e,next:void 0,previous:void 0},n){case 0:this.addItemLast(i);break;case 1:this.addItemFirst(i);break;case 2:this.addItemLast(i);break;default:this.addItemLast(i);break}this._map.set(t,i),this._size++}return this}delete(t){return!!this.remove(t)}remove(t){let e=this._map.get(t);if(e)return this._map.delete(t),this.removeItem(e),this._size--,e.value}shift(){if(!this._head&&!this._tail)return;if(!this._head||!this._tail)throw new Error("Invalid list");let t=this._head;return this._map.delete(t.key),this.removeItem(t),this._size--,t.value}forEach(t,e){let n=this._state,i=this._head;for(;i;){if(e?t.bind(e)(i.value,i.key,this):t(i.value,i.key,this),this._state!==n)throw new Error("LinkedMap got modified during iteration.");i=i.next}}keys(){let t=this,e=this._state,n=this._head,i={[Symbol.iterator](){return i},next(){if(t._state!==e)throw new Error("LinkedMap got modified during iteration.");if(n){let o={value:n.key,done:!1};return n=n.next,o}else return{value:void 0,done:!0}}};return i}values(){let t=this,e=this._state,n=this._head,i={[Symbol.iterator](){return i},next(){if(t._state!==e)throw new Error("LinkedMap got modified during iteration.");if(n){let o={value:n.value,done:!1};return n=n.next,o}else return{value:void 0,done:!0}}};return i}entries(){let t=this,e=this._state,n=this._head,i={[Symbol.iterator](){return i},next(){if(t._state!==e)throw new Error("LinkedMap got modified during iteration.");if(n){let o={value:[n.key,n.value],done:!1};return n=n.next,o}else return{value:void 0,done:!0}}};return i}[(zl=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld(t){if(t>=this.size)return;if(t===0){this.clear();return}let e=this._head,n=this.size;for(;e&&n>t;)this._map.delete(e.key),e=e.next,n--;this._head=e,this._size=n,e&&(e.previous=void 0),this._state++}trimNew(t){if(t>=this.size)return;if(t===0){this.clear();return}let e=this._tail,n=this.size;for(;e&&n>t;)this._map.delete(e.key),e=e.previous,n--;this._tail=e,this._size=n,e&&(e.next=void 0),this._state++}addItemFirst(t){if(!this._head&&!this._tail)this._tail=t;else if(this._head)t.next=this._head,this._head.previous=t;else throw new Error("Invalid list");this._head=t,this._state++}addItemLast(t){if(!this._head&&!this._tail)this._head=t;else if(this._tail)t.previous=this._tail,this._tail.next=t;else throw new Error("Invalid list");this._tail=t,this._state++}removeItem(t){if(t===this._head&&t===this._tail)this._head=void 0,this._tail=void 0;else if(t===this._head){if(!t.next)throw new Error("Invalid list");t.next.previous=void 0,this._head=t.next}else if(t===this._tail){if(!t.previous)throw new Error("Invalid list");t.previous.next=void 0,this._tail=t.previous}else{let e=t.next,n=t.previous;if(!e||!n)throw new Error("Invalid list");e.previous=n,n.next=e}t.next=void 0,t.previous=void 0,this._state++}touch(t,e){if(!this._head||!this._tail)throw new Error("Invalid list");if(!(e!==1&&e!==2)){if(e===1){if(t===this._head)return;let n=t.next,i=t.previous;t===this._tail?(i.next=void 0,this._tail=i):(n.previous=i,i.next=n),t.previous=void 0,t.next=this._head,this._head.previous=t,this._head=t,this._state++}else if(e===2){if(t===this._tail)return;let n=t.next,i=t.previous;t===this._head?(n.previous=void 0,this._head=n):(n.previous=i,i.next=n),t.next=void 0,t.previous=this._tail,this._tail.next=t,this._tail=t,this._state++}}}toJSON(){let t=[];return this.forEach((e,n)=>{t.push([n,e])}),t}fromJSON(t){this.clear();for(let[e,n]of t)this.set(e,n)}},xs=class extends _s{constructor(t,e=1){super(),this._limit=t,this._ratio=Math.min(Math.max(0,e),1)}get limit(){return this._limit}set limit(t){this._limit=t,this.checkTrim()}get ratio(){return this._ratio}set ratio(t){this._ratio=Math.min(Math.max(0,t),1),this.checkTrim()}get(t,e=2){return super.get(t,e)}peek(t){return super.get(t,0)}set(t,e){return super.set(t,e,2),this}checkTrim(){this.size>this._limit&&this.trim(Math.round(this._limit*this._ratio))}},At=class extends xs{constructor(t,e=1){super(t,e)}trim(t){this.trimOld(t)}set(t,e){return super.set(t,e),this.checkTrim(),this}};var bi=class{constructor(){this.map=new Map}add(t,e){let n=this.map.get(t);n||(n=new Set,this.map.set(t,n)),n.add(e)}delete(t,e){let n=this.map.get(t);n&&(n.delete(e),n.size===0&&this.map.delete(t))}forEach(t,e){let n=this.map.get(t);n&&n.forEach(e)}get(t){let e=this.map.get(t);return e||new Set}};function Ii(r,t="unexpected state"){if(!r)throw typeof t=="string"?new X(`Assertion Failed: ${t}`):t}function br(r){if(!r()){debugger;r(),oe(new X("Assertion Failed"))}}function Jt(r){return typeof r=="string"}function Hl(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof RegExp)&&!(r instanceof Date)}function Ir(r){return typeof r=="number"&&!isNaN(r)}function Gl(r){return!!r&&typeof r[Symbol.iterator]=="function"}function kp(r){return typeof r>"u"}function Tn(r){return!Tr(r)}function Tr(r){return kp(r)||r===null}function Jl(r,t){if(!r)throw new Error(t?`Unexpected type, expected '${t}'`:"Unexpected type")}function Rs(r){return typeof r=="function"}function $e(r,t){for(let e in t)if(!(e in r))return!1;return!0}var Sr;(vr=>{function r(P){return!!P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}vr.is=r;let t=Object.freeze([]);function e(){return t}vr.empty=e;function*n(P){yield P}vr.single=n;function i(P){return r(P)?P:n(P)}vr.wrap=i;function o(P){return P??t}vr.from=o;function*s(P){for(let F=P.length-1;F>=0;F--)yield P[F]}vr.reverse=s;function a(P){return!P||P[Symbol.iterator]().next().done===!0}vr.isEmpty=a;function l(P){return P[Symbol.iterator]().next().value}vr.first=l;function c(P,F){let w=0;for(let ne of P)if(F(ne,w++))return!0;return!1}vr.some=c;function d(P,F){let w=0;for(let ne of P)if(!F(ne,w++))return!1;return!0}vr.every=d;function u(P,F){for(let w of P)if(F(w))return w}vr.find=u;function*p(P,F){for(let w of P)F(w)&&(yield w)}vr.filter=p;function*h(P,F){let w=0;for(let ne of P)yield F(ne,w++)}vr.map=h;function*v(P,F){let w=0;for(let ne of P)yield*F(ne,w++)}vr.flatMap=v;function*g(...P){for(let F of P)Gl(F)?yield*F:yield F}vr.concat=g;function E(P,F,w){let ne=w;for(let it of P)ne=F(ne,it);return ne}vr.reduce=E;function R(P){let F=0;for(let w of P)F++;return F}vr.length=R;function*C(P,F,w=P.length){for(F<-P.length&&(F=0),F<0&&(F+=P.length),w<0?w+=P.length:w>P.length&&(w=P.length);F<w;F++)yield P[F]}vr.slice=C;function J(P,F=Number.POSITIVE_INFINITY){let w=[];if(F===0)return[w,P];let ne=P[Symbol.iterator]();for(let it=0;it<F;it++){let pt=ne.next();if(pt.done)return[w,vr.empty()];w.push(pt.value)}return[w,{[Symbol.iterator](){return ne}}]}vr.consume=J;async function rt(P){let F=[];for await(let w of P)F.push(w);return F}vr.asyncToArray=rt;async function bn(P){let F=[];for await(let w of P)F=F.concat(w);return F}vr.asyncToArrayFlat=bn})(Sr||={});var Dp=!1,Sn=null;var Yl=class r{constructor(){this.livingDisposables=new Map}static{this.idx=0}getDisposableData(t){let e=this.livingDisposables.get(t);return e||(e={parent:null,source:null,isSingleton:!1,value:t,idx:r.idx++},this.livingDisposables.set(t,e)),e}trackDisposable(t){let e=this.getDisposableData(t);e.source||(e.source=new Error().stack)}setParent(t,e){let n=this.getDisposableData(t);n.parent=e}markAsDisposed(t){this.livingDisposables.delete(t)}markAsSingleton(t){this.getDisposableData(t).isSingleton=!0}getRootParent(t,e){let n=e.get(t);if(n)return n;let i=t.parent?this.getRootParent(this.getDisposableData(t.parent),e):t;return e.set(t,i),i}getTrackedDisposables(){let t=new Map;return[...this.livingDisposables.entries()].filter(([,n])=>n.source!==null&&!this.getRootParent(n,t).isSingleton).flatMap(([n])=>n)}computeLeakingDisposables(t=10,e){let n;if(e)n=e;else{let l=new Map,c=[...this.livingDisposables.values()].filter(u=>u.source!==null&&!this.getRootParent(u,l).isSingleton);if(c.length===0)return;let d=new Set(c.map(u=>u.value));if(n=c.filter(u=>!(u.parent&&d.has(u.parent))),n.length===0)throw new Error("There are cyclic diposable chains!")}if(!n)return;function i(l){function c(u,p){for(;u.length>0&&p.some(h=>typeof h=="string"?h===u[0]:u[0].match(h));)u.shift()}let d=l.source.split(`
`).map(u=>u.trim().replace("at ","")).filter(u=>u!=="");return c(d,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),d.reverse()}let o=new bi;for(let l of n){let c=i(l);for(let d=0;d<=c.length;d++)o.add(c.slice(0,d).join(`
`),l)}n.sort(Ul(l=>l.idx,Nl));let s="",a=0;for(let l of n.slice(0,t)){a++;let c=i(l),d=[];for(let u=0;u<c.length;u++){let p=c[u];p=`(shared with ${o.get(c.slice(0,u+1).join(`
`)).size}/${n.length} leaks) at ${p}`;let v=o.get(c.slice(0,u).join(`
`)),g=Vl([...v].map(E=>i(E)[u]),E=>E);delete g[c[u]];for(let[E,R]of Object.entries(g))R&&d.unshift(`    - stacktraces of ${R.length} other leaks continue with ${E}`);d.unshift(p)}s+=`


==================== Leaking disposable ${a}/${n.length}: ${l.value.constructor.name} ====================
${d.join(`
`)}
============================================================

`}return n.length>t&&(s+=`


... and ${n.length-t} more leaking disposables

`),{leaks:n,details:s}}};function Op(r){Sn=r}if(Dp){let r="__is_disposable_tracked__";Op(new class{trackDisposable(t){let e=new Error("Potentially leaked disposable").stack;setTimeout(()=>{t[r]||console.log(e)},3e3)}setParent(t,e){if(t&&t!==A.None)try{t[r]=!0}catch{}}markAsDisposed(t){if(t&&t!==A.None)try{t[r]=!0}catch{}}markAsSingleton(t){}})}function Dt(r){return Sn?.trackDisposable(r),r}function Ot(r){Sn?.markAsDisposed(r)}function Qt(r,t){Sn?.setParent(r,t)}function Lp(r,t){if(Sn)for(let e of r)Sn.setParent(e,t)}function Si(r){return typeof r=="object"&&r!==null&&typeof r.dispose=="function"&&r.dispose.length===0}function Ae(r){if(Sr.is(r)){let t=[];for(let e of r)if(e)try{e.dispose()}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(r)?[]:r}else if(r)return r.dispose(),r}function Xl(...r){let t=O(()=>Ae(r));return Lp(r,t),t}var Es=class{constructor(t){this._isDisposed=!1,this._fn=t,Dt(this)}dispose(){if(!this._isDisposed){if(!this._fn)throw new Error("Unbound disposable context: Need to use an arrow function to preserve the value of this");this._isDisposed=!0,Ot(this),this._fn()}}};function O(r){return new Es(r)}var N=class r{constructor(){this._toDispose=new Set;this._isDisposed=!1;Dt(this)}static{this.DISABLE_DISPOSED_WARNING=!1}dispose(){this._isDisposed||(Ot(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ae(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t||t===A.None)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return Qt(t,this),this._isDisposed?r.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.delete(t)&&Qt(t,null)}assertNotDisposed(){this._isDisposed&&oe(new X("Object disposed"))}},A=class{constructor(){this._store=new N;Dt(this),Qt(this._store,this)}static{this.None=Object.freeze({dispose(){}})}dispose(){Ot(this),this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}},kt=class{constructor(){this._isDisposed=!1;Dt(this)}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),t&&Qt(t,this),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Ot(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t&&Qt(t,null),t}};var Ti=class{constructor(){this.references=new Map}acquire(t,...e){let n=this.references.get(t);n||(n={counter:0,object:this.createReferencedObject(t,...e)},this.references.set(t,n));let{object:i}=n,o=In(()=>{--n.counter===0&&(this.destroyReferencedObject(t,n.object),this.references.delete(t))});return n.counter++,{object:i,dispose:o}}};var st=class{constructor(t=new Map){this._isDisposed=!1;this._store=t,Dt(this)}dispose(){Ot(this),this._isDisposed=!0,this.clearAndDisposeAll()}clearAndDisposeAll(){if(this._store.size)try{Ae(this._store.values())}finally{this._store.clear()}}has(t){return this._store.has(t)}get size(){return this._store.size}get(t){return this._store.get(t)}set(t,e,n=!1){this._isDisposed&&console.warn(new Error("Trying to add a disposable to a DisposableMap that has already been disposed of. The added object will be leaked!").stack),n||this._store.get(t)?.dispose(),this._store.set(t,e),Qt(e,this)}deleteAndDispose(t){this._store.get(t)?.dispose(),this._store.delete(t)}deleteAndLeak(t){let e=this._store.get(t);return e&&Qt(e,null),this._store.delete(t),e}keys(){return this._store.keys()}values(){return this._store.values()}[Symbol.iterator](){return this._store[Symbol.iterator]()}};function Zl(r,t){return r.then(e=>(t.isDisposed?e.dispose():t.add(e),e))}var Z=class r{static{this.Undefined=new r(void 0)}constructor(t){this.element=t,this.next=r.Undefined,this.prev=r.Undefined}},_r=class{constructor(){this._first=Z.Undefined;this._last=Z.Undefined;this._size=0}get size(){return this._size}isEmpty(){return this._first===Z.Undefined}clear(){let t=this._first;for(;t!==Z.Undefined;){let e=t.next;t.prev=Z.Undefined,t.next=Z.Undefined,t=e}this._first=Z.Undefined,this._last=Z.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let n=new Z(t);if(this._first===Z.Undefined)this._first=n,this._last=n;else if(e){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(n))}}shift(){if(this._first!==Z.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==Z.Undefined){let t=this._last.element;return this._remove(this._last),t}}peek(){if(this._last!==Z.Undefined)return this._last.element}_remove(t){if(t.prev!==Z.Undefined&&t.next!==Z.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===Z.Undefined&&t.next===Z.Undefined?(this._first=Z.Undefined,this._last=Z.Undefined):t.next===Z.Undefined?(this._last=this._last.prev,this._last.next=Z.Undefined):t.prev===Z.Undefined&&(this._first=this._first.next,this._first.prev=Z.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==Z.Undefined;)yield t.element,t=t.next}};function Fp(){return globalThis._VSCODE_NLS_MESSAGES}function ws(){return globalThis._VSCODE_NLS_LANGUAGE}var Up=ws()==="pseudo"||typeof document<"u"&&document.location&&typeof document.location.hash=="string"&&document.location.hash.indexOf("pseudo=true")>=0;function ec(r,t){let e;return t.length===0?e=r:e=r.replace(/\{(\d+)\}/g,(n,i)=>{let o=i[0],s=t[o],a=n;return typeof s=="string"?a=s:(typeof s=="number"||typeof s=="boolean"||s===void 0||s===null)&&(a=String(s)),a}),Up&&(e="\uFF3B"+e.replace(/[aouei]/g,"$&$&")+"\uFF3D"),e}function f(r,t,...e){return ec(typeof r=="number"?Np(r,t):t,e)}function Np(r,t){let e=Fp()?.[r];if(typeof e!="string"){if(typeof t=="string")return t;throw new Error(`!!! NLS MISSING: ${r} !!!`)}return e}var Yt="en",Rr=!1,Er=!1,xr=!1,Mp=!1,nc=!1,As=!1,Wp=!1,rc=!1,Bp=!1,qp=!1,_i,xi=Yt,tc=Yt,Vp,gt,mt=globalThis,Fe;typeof mt.vscode<"u"&&typeof mt.vscode.process<"u"?Fe=mt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Fe=process);var ic=typeof Fe?.versions?.electron=="string",$p=ic&&Fe?.type==="renderer";if(typeof Fe=="object"){Rr=Fe.platform==="win32",Er=Fe.platform==="darwin",xr=Fe.platform==="linux",Mp=xr&&!!Fe.env.SNAP&&!!Fe.env.SNAP_REVISION,Wp=ic,Bp=!!Fe.env.CI||!!Fe.env.BUILD_ARTIFACTSTAGINGDIRECTORY||!!Fe.env.GITHUB_WORKSPACE,_i=Yt,xi=Yt;let r=Fe.env.VSCODE_NLS_CONFIG;if(r)try{let t=JSON.parse(r);_i=t.userLocale,tc=t.osLocale,xi=t.resolvedLanguage||Yt,Vp=t.languagePack?.translationsConfigFile}catch{}nc=!0}else typeof navigator=="object"&&!$p?(gt=navigator.userAgent,Rr=gt.indexOf("Windows")>=0,Er=gt.indexOf("Macintosh")>=0,rc=(gt.indexOf("Macintosh")>=0||gt.indexOf("iPad")>=0||gt.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,xr=gt.indexOf("Linux")>=0,qp=gt?.indexOf("Mobi")>=0,As=!0,xi=ws()||Yt,_i=navigator.language.toLowerCase(),tc=_i):console.error("Unable to resolve platform.");var Ps=0;Er?Ps=1:Rr?Ps=3:xr&&(Ps=2);var H=Rr,Ke=Er,le=xr;var oc=nc;var _n=As,Kp=As&&typeof mt.importScripts=="function",sc=Kp?mt.origin:void 0;var at=gt,Lt=xi,jp;(n=>{function r(){return Lt}n.value=r;function t(){return Lt.length===2?Lt==="en":Lt.length>=3?Lt[0]==="e"&&Lt[1]==="n"&&Lt[2]==="-":!1}n.isDefaultVariant=t;function e(){return Lt==="en"}n.isDefault=e})(jp||={});var zp=typeof mt.postMessage=="function"&&!mt.importScripts,ac=(()=>{if(zp){let r=[];mt.addEventListener("message",e=>{if(e.data&&e.data.vscodeScheduleAsyncWork)for(let n=0,i=r.length;n<i;n++){let o=r[n];if(o.id===e.data.vscodeScheduleAsyncWork){r.splice(n,1),o.callback();return}}});let t=0;return e=>{let n=++t;r.push({id:n,callback:e}),mt.postMessage({vscodeScheduleAsyncWork:n},"*")}}return r=>setTimeout(r)})();var Ri=Er||rc?2:Rr?1:3;var ks=!!(at&&at.indexOf("Chrome")>=0),lc=!!(at&&at.indexOf("Firefox")>=0),cc=!!(!ks&&at&&at.indexOf("Safari")>=0),uc=!!(at&&at.indexOf("Edg/")>=0),u1=!!(at&&at.indexOf("Android")>=0);var Xt,Ds=globalThis.vscode;if(typeof Ds<"u"&&typeof Ds.process<"u"){let r=Ds.process;Xt={get platform(){return r.platform},get arch(){return r.arch},get env(){return r.env},cwd(){return r.cwd()}}}else typeof process<"u"&&typeof process?.versions?.node=="string"?Xt={get platform(){return process.platform},get arch(){return process.arch},get env(){return process.env},cwd(){return process.env.VSCODE_CWD||process.cwd()}}:Xt={get platform(){return H?"win32":Ke?"darwin":"linux"},get arch(){},get env(){return{}},cwd(){return"/"}};var xn=Xt.cwd,Te=Xt.env,pc=Xt.platform,f1=Xt.arch;var Hp=globalThis.performance.now.bind(globalThis.performance),Ei=class r{static create(t){return new r(t)}constructor(t){this._now=t===!1?Date.now:Hp,this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}};var hc=!1,Gp=!1,Jp=100,gc=6e4;function mc(){return!!Te.VSCODE_DEV}var z;(Ht=>{Ht.None=()=>A.None;function t(_){if(Gp){let{onDidAddListener:y}=_,I=En.create(),T=0;_.onDidAddListener=()=>{++T===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),I.print()),y?.()}}}function e(_,y,I){return h(_,()=>{},0,void 0,y??!0,void 0,I)}Ht.defer=e;function n(_){return(y,I=null,T)=>{let x=!1,k;return k=_(M=>{if(!x)return k?k.dispose():x=!0,y.call(I,M)},null,T),x&&k.dispose(),k}}Ht.once=n;function i(_,y){return Ht.once(Ht.filter(_,y))}Ht.onceIf=i;function o(_,y,I){return u((T,x=null,k)=>_(M=>T.call(x,y(M)),null,k),I)}Ht.map=o;function s(_,y,I){return u((T,x=null,k)=>_(M=>{y(M),T.call(x,M)},null,k),I)}Ht.forEach=s;function a(_,y,I){return u((T,x=null,k)=>_(M=>y(M)&&T.call(x,M),null,k),I)}Ht.filter=a;function l(_){return _}Ht.signal=l;function c(..._){return(y,I=null,T)=>{let x=Xl(..._.map(k=>k(M=>y.call(I,M))));return p(x,T)}}Ht.any=c;function d(_,y,I,T){let x=I;return o(_,k=>(x=y(x,k),x),T)}Ht.reduce=d;function u(_,y){let I,T={onWillAddFirstListener(){I=_(x.fire,x)},onDidRemoveLastListener(){I?.dispose()}};y||t(T);let x=new b(T);return y?.add(x),x.event}function p(_,y){return y instanceof Array?y.push(_):y&&y.add(_),_}function h(_,y,I=100,T=!1,x=!1,k,M){let ye,Q,Ee,be=0,Pe,ft={leakWarningThreshold:k,onWillAddFirstListener(){ye=_(wl=>{be++,Q=y(Q,wl),T&&!Ee&&(Gt.fire(Q),Q=void 0),Pe=()=>{let Cl=Q;Q=void 0,Ee=void 0,(!T||be>1)&&Gt.fire(Cl),be=0},typeof I=="number"?(Ee&&clearTimeout(Ee),Ee=setTimeout(Pe,I)):Ee===void 0&&(Ee=null,queueMicrotask(Pe))})},onWillRemoveListener(){x&&be>0&&Pe?.()},onDidRemoveLastListener(){Pe=void 0,ye.dispose()}};M||t(ft);let Gt=new b(ft);return M?.add(Gt),Gt.event}Ht.debounce=h;function v(_,y=0,I,T){return Ht.debounce(_,(x,k)=>x?(x.push(k),x):[k],y,void 0,I??!0,void 0,T)}Ht.accumulate=v;function g(_,y,I=100,T=!0,x=!0,k,M){let ye,Q,Ee,be=0,Pe={leakWarningThreshold:k,onWillAddFirstListener(){ye=_(Gt=>{be++,Q=y(Q,Gt),Ee===void 0&&(T&&(ft.fire(Q),Q=void 0,be=0),typeof I=="number"?Ee=setTimeout(()=>{x&&be>0&&ft.fire(Q),Q=void 0,Ee=void 0,be=0},I):(Ee=0,queueMicrotask(()=>{x&&be>0&&ft.fire(Q),Q=void 0,Ee=void 0,be=0})))})},onDidRemoveLastListener(){ye.dispose()}};M||t(Pe);let ft=new b(Pe);return M?.add(ft),ft.event}Ht.throttle=g;function E(_,y=(T,x)=>T===x,I){let T=!0,x;return a(_,k=>{let M=T||!y(k,x);return T=!1,x=k,M},I)}Ht.latch=E;function R(_,y,I){return[Ht.filter(_,y,I),Ht.filter(_,T=>!y(T),I)]}Ht.split=R;function C(_,y,I=!1,T=[],x){let k=T.slice(),M;mc()&&(M={stack:En.create(),timerId:setTimeout(()=>{k&&k.length>0&&M&&!M.warned&&(M.warned=!0,console.warn(`[Event.buffer][${y}] potential LEAK detected: ${k.length} events buffered for ${gc/1e3}s without being consumed. Buffered here:`),M.stack.print())},gc),warned:!1},x&&x.add(O(()=>clearTimeout(M.timerId))));let ye=()=>{M&&clearTimeout(M.timerId)},Q=_(Pe=>{k?(k.push(Pe),mc()&&M&&!M.warned&&k.length>=Jp&&(M.warned=!0,console.warn(`[Event.buffer][${y}] potential LEAK detected: ${k.length} events buffered without being consumed. Buffered here:`),M.stack.print())):be.fire(Pe)});x&&x.add(Q);let Ee=()=>{k?.forEach(Pe=>be.fire(Pe)),k=null,ye()},be=new b({onWillAddFirstListener(){Q||(Q=_(Pe=>be.fire(Pe)),x&&x.add(Q))},onDidAddFirstListener(){k&&(I?setTimeout(Ee):Ee())},onDidRemoveLastListener(){Q&&Q.dispose(),Q=null,ye()}});return x&&x.add(be),be.event}Ht.buffer=C;function J(_,y){return(T,x,k)=>{let M=y(new bn);return _(function(ye){let Q=M.evaluate(ye);Q!==rt&&T.call(x,Q)},void 0,k)}}Ht.chain=J;let rt=Symbol("HaltChainable");class bn{constructor(){this.steps=[]}map(y){return this.steps.push(y),this}forEach(y){return this.steps.push(I=>(y(I),I)),this}filter(y){return this.steps.push(I=>y(I)?I:rt),this}reduce(y,I){let T=I;return this.steps.push(x=>(T=y(T,x),T)),this}latch(y=(I,T)=>I===T){let I=!0,T;return this.steps.push(x=>{let k=I||!y(x,T);return I=!1,T=x,k?x:rt}),this}evaluate(y){for(let I of this.steps)if(y=I(y),y===rt)break;return y}}function vr(_,y,I=T=>T){let T=(...ye)=>M.fire(I(...ye)),x=()=>_.on(y,T),k=()=>_.removeListener(y,T),M=new b({onWillAddFirstListener:x,onDidRemoveLastListener:k});return M.event}Ht.fromNodeEventEmitter=vr;function P(_,y,I=T=>T){let T=(...ye)=>M.fire(I(...ye)),x=()=>_.addEventListener(y,T),k=()=>_.removeEventListener(y,T),M=new b({onWillAddFirstListener:x,onDidRemoveLastListener:k});return M.event}Ht.fromDOMEventEmitter=P;function F(_,y){let I,T,x=new Promise(k=>{T=n(_)(k),Ms(T,y),I=()=>{yc(T,y)}});return x.cancel=I,y&&x.finally(()=>yc(T,y)),x}Ht.toPromise=F;function w(_,y){return _(I=>y.fire(I))}Ht.forward=w;function ne(_,y,I){return y(I),_(T=>y(T))}Ht.runAndSubscribe=ne;class it{constructor(y,I){this._observable=y;this._counter=0;this._hasChanged=!1;let T={onWillAddFirstListener:()=>{y.addObserver(this),this._observable.reportChanges()},onDidRemoveLastListener:()=>{y.removeObserver(this)}};I||t(T),this.emitter=new b(T),I&&I.add(this.emitter)}beginUpdate(y){this._counter++}handlePossibleChange(y){}handleChange(y,I){this._hasChanged=!0}endUpdate(y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function pt(_,y){return new it(_,y).emitter.event}Ht.fromObservable=pt;function xp(_){return(y,I,T)=>{let x=0,k=!1,M={beginUpdate(){x++},endUpdate(){x--,x===0&&(_.reportChanges(),k&&(k=!1,y.call(I)))},handlePossibleChange(){},handleChange(){k=!0}};_.addObserver(M),_.reportChanges();let ye={dispose(){_.removeObserver(M)}};return Ms(ye,T),ye}}Ht.fromObservableLight=xp})(z||={});var Os=class r{constructor(t){this.listenerCount=0;this.invocationCount=0;this.elapsedOverall=0;this.durations=[];this.name=`${t}_${r._idPool++}`,r.all.add(this)}static{this.all=new Set}static{this._idPool=0}start(t){this._stopWatch=new Ei,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}},vc=-1;var Ls=class r{constructor(t,e,n=(r._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t;this.threshold=e;this.name=n;this._warnCountdown=0}static{this._idPool=1}dispose(){this._stacks?.clear()}check(t,e){let n=this.threshold;if(n<=0||e<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[o,s]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${e} listeners already. MOST frequent listener (${s}):`;console.warn(a),console.warn(o);let l=s/e>.3?"dominated":"popular",c=new Fs(l,a,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,e=0;for(let[n,i]of this._stacks)(!t||e<i)&&(t=[n,i],e=i);return t}},En=class r{constructor(t){this.value=t}static create(){let t=new Error;return new r(t.stack??"")}print(){console.warn(this.value.split(`
`).slice(2).join(`
`))}},Fs=class extends Error{constructor(t,e,n){super(`potential listener LEAK detected, ${t}`),this.name="ListenerLeakError",this.details=e,this.stack=n}},Us=class extends Error{constructor(t,e,n){super(`potential listener LEAK detected, ${t} (REFUSED to add)`),this.name="ListenerRefusalError",this.details=e,this.stack=n}},Qp=0,Rn=class{constructor(t){this.value=t;this.id=Qp++}},Yp=2,Xp=(r,t)=>{if(r instanceof Rn)t(r);else for(let e=0;e<r.length;e++){let n=r[e];n&&t(n)}},b=class{constructor(t){this._size=0;this._options=t,this._leakageMon=vc>0||this._options?.leakWarningThreshold?new Ls(t?.onListenerError??oe,this._options?.leakWarningThreshold??vc):void 0,this._perfMon=this._options?._profName?new Os(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(hc){let t=this._listeners;queueMicrotask(()=>{Xp(t,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(t,e,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let l=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(l);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],d=c[1]/this._size>.3?"dominated":"popular",u=new Us(d,`${l}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(this._options?.onListenerError||oe)(u),A.None}if(this._disposed)return A.None;e&&(t=t.bind(e));let i=new Rn(t),o,s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=En.create(),o=this._leakageMon.check(i.stack,this._size+1)),hc&&(i.stack=s??En.create()),this._listeners?this._listeners instanceof Rn?(this._deliveryQueue??=new Ns,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._options?.onDidAddListener?.(this),this._size++;let a=O(()=>{o?.(),this._removeListener(i)});return Ms(a,n),a},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Yp<=e.length){let o=0;for(let s=0;s<e.length;s++)e[s]?e[o++]=e[s]:i&&o<this._deliveryQueue.end&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=o}}_deliver(t,e){if(!t)return;let n=this._options?.onListenerError||oe;if(!n){t.value(e);return}try{t.value(e)}catch(i){n(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Rn)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}};var Ns=class{constructor(){this.i=-1;this.end=0}enqueue(t,e,n){this.i=0,this.end=n,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}};var wi=class{constructor(){this.hasListeners=!1;this.events=[];this.emitter=new b({onWillAddFirstListener:()=>this.onFirstListenerAdd(),onDidRemoveLastListener:()=>this.onLastListenerRemove()})}get event(){return this.emitter.event}add(t){let e={event:t,listener:null};return this.events.push(e),this.hasListeners&&this.hook(e),O(In(()=>{this.hasListeners&&this.unhook(e);let i=this.events.indexOf(e);this.events.splice(i,1)}))}onFirstListenerAdd(){this.hasListeners=!0,this.events.forEach(t=>this.hook(t))}onLastListenerRemove(){this.hasListeners=!1,this.events.forEach(t=>this.unhook(t))}hook(t){t.listener=t.event(e=>this.emitter.fire(e))}unhook(t){t.listener?.dispose(),t.listener=null}dispose(){this.emitter.dispose();for(let t of this.events)t.listener?.dispose();this.events=[]}};var wr=class{constructor(){this.listening=!1;this.inputEvent=z.None;this.inputEventListener=A.None;this.emitter=new b({onDidAddFirstListener:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onDidRemoveLastListener:()=>{this.listening=!1,this.inputEventListener.dispose()}});this.event=this.emitter.event}set input(t){this.inputEvent=t,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=t(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}};function Ms(r,t){t instanceof N?t.add(r):Array.isArray(t)&&t.push(r)}function yc(r,t){if(t instanceof N)t.delete(r);else if(Array.isArray(t)){let e=t.indexOf(r);e!==-1&&t.splice(e,1)}r.dispose()}var bc=Object.freeze(function(r,t){let e=setTimeout(r.bind(t),0);return{dispose(){clearTimeout(e)}}}),Be;(n=>{function r(i){return i===n.None||i===n.Cancelled||i instanceof wn?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}n.isCancellationToken=r,n.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:z.None}),n.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:bc})})(Be||={});var wn=class{constructor(){this._isCancelled=!1;this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?bc:(this._emitter||(this._emitter=new b),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},fe=class{constructor(t){this._token=void 0;this._parentListener=void 0;this._parentListener=t&&t.onCancellationRequested(this.cancel,this)}get token(){return this._token||(this._token=new wn),this._token}cancel(){this._token?this._token instanceof wn&&this._token.cancel():this._token=Be.Cancelled}dispose(t=!1){t&&this.cancel(),this._parentListener?.dispose(),this._token?this._token instanceof wn&&this._token.dispose():this._token=Be.None}};var Zp=65,ef=97,tf=90,nf=122,Zt=46,Se=47,Ue=92,vt=58,rf=63,Ci=class extends Error{constructor(t,e,n){let i;typeof e=="string"&&e.indexOf("not ")===0?(i="must not be",e=e.replace(/^not /,"")):i="must be";let o=t.indexOf(".")!==-1?"property":"argument",s=`The "${t}" ${o} ${i} of type ${e}`;s+=`. Received type ${typeof n}`,super(s),this.code="ERR_INVALID_ARG_TYPE"}};function of(r,t){if(r===null||typeof r!="object")throw new Ci(t,"Object",r)}function ce(r,t){if(typeof r!="string")throw new Ci(t,"string",r)}var Ne=pc==="win32";function B(r){return r===Se||r===Ue}function Ws(r){return r===Se}function yt(r){return r>=Zp&&r<=tf||r>=ef&&r<=nf}function Pi(r,t,e,n){let i="",o=0,s=-1,a=0,l=0;for(let c=0;c<=r.length;++c){if(c<r.length)l=r.charCodeAt(c);else{if(n(l))break;l=Se}if(n(l)){if(!(s===c-1||a===1))if(a===2){if(i.length<2||o!==2||i.charCodeAt(i.length-1)!==Zt||i.charCodeAt(i.length-2)!==Zt){if(i.length>2){let d=i.lastIndexOf(e);d===-1?(i="",o=0):(i=i.slice(0,d),o=i.length-1-i.lastIndexOf(e)),s=c,a=0;continue}else if(i.length!==0){i="",o=0,s=c,a=0;continue}}t&&(i+=i.length>0?`${e}..`:"..",o=2)}else i.length>0?i+=`${e}${r.slice(s+1,c)}`:i=r.slice(s+1,c),o=c-s-1;s=c,a=0}else l===Zt&&a!==-1?++a:a=-1}return i}function sf(r){return r?`${r[0]==="."?"":"."}${r}`:""}function Ic(r,t){of(t,"pathObject");let e=t.dir||t.root,n=t.base||`${t.name||""}${sf(t.ext)}`;return e?e===t.root?`${e}${n}`:`${e}${r}${n}`:n}var se={resolve(...r){let t="",e="",n=!1;for(let i=r.length-1;i>=-1;i--){let o;if(i>=0){if(o=r[i],ce(o,`paths[${i}]`),o.length===0)continue}else t.length===0?o=xn():(o=Te[`=${t}`]||xn(),(o===void 0||o.slice(0,2).toLowerCase()!==t.toLowerCase()&&o.charCodeAt(2)===Ue)&&(o=`${t}\\`));let s=o.length,a=0,l="",c=!1,d=o.charCodeAt(0);if(s===1)B(d)&&(a=1,c=!0);else if(B(d))if(c=!0,B(o.charCodeAt(1))){let u=2,p=u;for(;u<s&&!B(o.charCodeAt(u));)u++;if(u<s&&u!==p){let h=o.slice(p,u);for(p=u;u<s&&B(o.charCodeAt(u));)u++;if(u<s&&u!==p){for(p=u;u<s&&!B(o.charCodeAt(u));)u++;(u===s||u!==p)&&(l=`\\\\${h}\\${o.slice(p,u)}`,a=u)}}}else a=1;else yt(d)&&o.charCodeAt(1)===vt&&(l=o.slice(0,2),a=2,s>2&&B(o.charCodeAt(2))&&(c=!0,a=3));if(l.length>0)if(t.length>0){if(l.toLowerCase()!==t.toLowerCase())continue}else t=l;if(n){if(t.length>0)break}else if(e=`${o.slice(a)}\\${e}`,n=c,c&&t.length>0)break}return e=Pi(e,!n,"\\",B),n?`${t}\\${e}`:`${t}${e}`||"."},normalize(r){ce(r,"path");let t=r.length;if(t===0)return".";let e=0,n,i=!1,o=r.charCodeAt(0);if(t===1)return Ws(o)?"\\":r;if(B(o))if(i=!0,B(r.charCodeAt(1))){let a=2,l=a;for(;a<t&&!B(r.charCodeAt(a));)a++;if(a<t&&a!==l){let c=r.slice(l,a);for(l=a;a<t&&B(r.charCodeAt(a));)a++;if(a<t&&a!==l){for(l=a;a<t&&!B(r.charCodeAt(a));)a++;if(a===t)return`\\\\${c}\\${r.slice(l)}\\`;a!==l&&(n=`\\\\${c}\\${r.slice(l,a)}`,e=a)}}}else e=1;else yt(o)&&r.charCodeAt(1)===vt&&(n=r.slice(0,2),e=2,t>2&&B(r.charCodeAt(2))&&(i=!0,e=3));let s=e<t?Pi(r.slice(e),!i,"\\",B):"";if(s.length===0&&!i&&(s="."),s.length>0&&B(r.charCodeAt(t-1))&&(s+="\\"),!i&&n===void 0&&r.includes(":")){if(s.length>=2&&yt(s.charCodeAt(0))&&s.charCodeAt(1)===vt)return`.\\${s}`;let a=r.indexOf(":");do if(a===t-1||B(r.charCodeAt(a+1)))return`.\\${s}`;while((a=r.indexOf(":",a+1))!==-1)}return n===void 0?i?`\\${s}`:s:i?`${n}\\${s}`:`${n}${s}`},isAbsolute(r){ce(r,"path");let t=r.length;if(t===0)return!1;let e=r.charCodeAt(0);return B(e)||t>2&&yt(e)&&r.charCodeAt(1)===vt&&B(r.charCodeAt(2))},join(...r){if(r.length===0)return".";let t,e;for(let o=0;o<r.length;++o){let s=r[o];ce(s,"path"),s.length>0&&(t===void 0?t=e=s:t+=`\\${s}`)}if(t===void 0)return".";let n=!0,i=0;if(typeof e=="string"&&B(e.charCodeAt(0))){++i;let o=e.length;o>1&&B(e.charCodeAt(1))&&(++i,o>2&&(B(e.charCodeAt(2))?++i:n=!1))}if(n){for(;i<t.length&&B(t.charCodeAt(i));)i++;i>=2&&(t=`\\${t.slice(i)}`)}return se.normalize(t)},relative(r,t){if(ce(r,"from"),ce(t,"to"),r===t)return"";let e=se.resolve(r),n=se.resolve(t);if(e===n||(r=e.toLowerCase(),t=n.toLowerCase(),r===t))return"";if(e.length!==r.length||n.length!==t.length){let v=e.split("\\"),g=n.split("\\");v[v.length-1]===""&&v.pop(),g[g.length-1]===""&&g.pop();let E=v.length,R=g.length,C=E<R?E:R,J;for(J=0;J<C&&v[J].toLowerCase()===g[J].toLowerCase();J++);return J===0?n:J===C?R>C?g.slice(J).join("\\"):E>C?"..\\".repeat(E-1-J)+"..":"":"..\\".repeat(E-J)+g.slice(J).join("\\")}let i=0;for(;i<r.length&&r.charCodeAt(i)===Ue;)i++;let o=r.length;for(;o-1>i&&r.charCodeAt(o-1)===Ue;)o--;let s=o-i,a=0;for(;a<t.length&&t.charCodeAt(a)===Ue;)a++;let l=t.length;for(;l-1>a&&t.charCodeAt(l-1)===Ue;)l--;let c=l-a,d=s<c?s:c,u=-1,p=0;for(;p<d;p++){let v=r.charCodeAt(i+p);if(v!==t.charCodeAt(a+p))break;v===Ue&&(u=p)}if(p!==d){if(u===-1)return n}else{if(c>d){if(t.charCodeAt(a+p)===Ue)return n.slice(a+p+1);if(p===2)return n.slice(a+p)}s>d&&(r.charCodeAt(i+p)===Ue?u=p:p===2&&(u=3)),u===-1&&(u=0)}let h="";for(p=i+u+1;p<=o;++p)(p===o||r.charCodeAt(p)===Ue)&&(h+=h.length===0?"..":"\\..");return a+=u,h.length>0?`${h}${n.slice(a,l)}`:(n.charCodeAt(a)===Ue&&++a,n.slice(a,l))},toNamespacedPath(r){if(typeof r!="string"||r.length===0)return r;let t=se.resolve(r);if(t.length<=2)return r;if(t.charCodeAt(0)===Ue){if(t.charCodeAt(1)===Ue){let e=t.charCodeAt(2);if(e!==rf&&e!==Zt)return`\\\\?\\UNC\\${t.slice(2)}`}}else if(yt(t.charCodeAt(0))&&t.charCodeAt(1)===vt&&t.charCodeAt(2)===Ue)return`\\\\?\\${t}`;return t},dirname(r){ce(r,"path");let t=r.length;if(t===0)return".";let e=-1,n=0,i=r.charCodeAt(0);if(t===1)return B(i)?r:".";if(B(i)){if(e=n=1,B(r.charCodeAt(1))){let a=2,l=a;for(;a<t&&!B(r.charCodeAt(a));)a++;if(a<t&&a!==l){for(l=a;a<t&&B(r.charCodeAt(a));)a++;if(a<t&&a!==l){for(l=a;a<t&&!B(r.charCodeAt(a));)a++;if(a===t)return r;a!==l&&(e=n=a+1)}}}}else yt(i)&&r.charCodeAt(1)===vt&&(e=t>2&&B(r.charCodeAt(2))?3:2,n=e);let o=-1,s=!0;for(let a=t-1;a>=n;--a)if(B(r.charCodeAt(a))){if(!s){o=a;break}}else s=!1;if(o===-1){if(e===-1)return".";o=e}return r.slice(0,o)},basename(r,t){t!==void 0&&ce(t,"suffix"),ce(r,"path");let e=0,n=-1,i=!0,o;if(r.length>=2&&yt(r.charCodeAt(0))&&r.charCodeAt(1)===vt&&(e=2),t!==void 0&&t.length>0&&t.length<=r.length){if(t===r)return"";let s=t.length-1,a=-1;for(o=r.length-1;o>=e;--o){let l=r.charCodeAt(o);if(B(l)){if(!i){e=o+1;break}}else a===-1&&(i=!1,a=o+1),s>=0&&(l===t.charCodeAt(s)?--s===-1&&(n=o):(s=-1,n=a))}return e===n?n=a:n===-1&&(n=r.length),r.slice(e,n)}for(o=r.length-1;o>=e;--o)if(B(r.charCodeAt(o))){if(!i){e=o+1;break}}else n===-1&&(i=!1,n=o+1);return n===-1?"":r.slice(e,n)},extname(r){ce(r,"path");let t=0,e=-1,n=0,i=-1,o=!0,s=0;r.length>=2&&r.charCodeAt(1)===vt&&yt(r.charCodeAt(0))&&(t=n=2);for(let a=r.length-1;a>=t;--a){let l=r.charCodeAt(a);if(B(l)){if(!o){n=a+1;break}continue}i===-1&&(o=!1,i=a+1),l===Zt?e===-1?e=a:s!==1&&(s=1):e!==-1&&(s=-1)}return e===-1||i===-1||s===0||s===1&&e===i-1&&e===n+1?"":r.slice(e,i)},format:Ic.bind(null,"\\"),parse(r){ce(r,"path");let t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;let e=r.length,n=0,i=r.charCodeAt(0);if(e===1)return B(i)?(t.root=t.dir=r,t):(t.base=t.name=r,t);if(B(i)){if(n=1,B(r.charCodeAt(1))){let u=2,p=u;for(;u<e&&!B(r.charCodeAt(u));)u++;if(u<e&&u!==p){for(p=u;u<e&&B(r.charCodeAt(u));)u++;if(u<e&&u!==p){for(p=u;u<e&&!B(r.charCodeAt(u));)u++;u===e?n=u:u!==p&&(n=u+1)}}}}else if(yt(i)&&r.charCodeAt(1)===vt){if(e<=2)return t.root=t.dir=r,t;if(n=2,B(r.charCodeAt(2))){if(e===3)return t.root=t.dir=r,t;n=3}}n>0&&(t.root=r.slice(0,n));let o=-1,s=n,a=-1,l=!0,c=r.length-1,d=0;for(;c>=n;--c){if(i=r.charCodeAt(c),B(i)){if(!l){s=c+1;break}continue}a===-1&&(l=!1,a=c+1),i===Zt?o===-1?o=c:d!==1&&(d=1):o!==-1&&(d=-1)}return a!==-1&&(o===-1||d===0||d===1&&o===a-1&&o===s+1?t.base=t.name=r.slice(s,a):(t.name=r.slice(s,o),t.base=r.slice(s,a),t.ext=r.slice(o,a))),s>0&&s!==n?t.dir=r.slice(0,s-1):t.dir=t.root,t},sep:"\\",delimiter:";",win32:null,posix:null},af=(()=>{if(Ne){let r=/\\/g;return()=>{let t=xn().replace(r,"/");return t.slice(t.indexOf("/"))}}return()=>xn()})(),q={resolve(...r){let t="",e=!1;for(let n=r.length-1;n>=0&&!e;n--){let i=r[n];ce(i,`paths[${n}]`),i.length!==0&&(t=`${i}/${t}`,e=i.charCodeAt(0)===Se)}if(!e){let n=af();t=`${n}/${t}`,e=n.charCodeAt(0)===Se}return t=Pi(t,!e,"/",Ws),e?`/${t}`:t.length>0?t:"."},normalize(r){if(ce(r,"path"),r.length===0)return".";let t=r.charCodeAt(0)===Se,e=r.charCodeAt(r.length-1)===Se;return r=Pi(r,!t,"/",Ws),r.length===0?t?"/":e?"./":".":(e&&(r+="/"),t?`/${r}`:r)},isAbsolute(r){return ce(r,"path"),r.length>0&&r.charCodeAt(0)===Se},join(...r){if(r.length===0)return".";let t=[];for(let e=0;e<r.length;++e){let n=r[e];ce(n,"path"),n.length>0&&t.push(n)}return t.length===0?".":q.normalize(t.join("/"))},relative(r,t){if(ce(r,"from"),ce(t,"to"),r===t||(r=q.resolve(r),t=q.resolve(t),r===t))return"";let e=1,n=r.length,i=n-e,o=1,s=t.length-o,a=i<s?i:s,l=-1,c=0;for(;c<a;c++){let u=r.charCodeAt(e+c);if(u!==t.charCodeAt(o+c))break;u===Se&&(l=c)}if(c===a)if(s>a){if(t.charCodeAt(o+c)===Se)return t.slice(o+c+1);if(c===0)return t.slice(o+c)}else i>a&&(r.charCodeAt(e+c)===Se?l=c:c===0&&(l=0));let d="";for(c=e+l+1;c<=n;++c)(c===n||r.charCodeAt(c)===Se)&&(d+=d.length===0?"..":"/..");return`${d}${t.slice(o+l)}`},toNamespacedPath(r){return r},dirname(r){if(ce(r,"path"),r.length===0)return".";let t=r.charCodeAt(0)===Se,e=-1,n=!0;for(let i=r.length-1;i>=1;--i)if(r.charCodeAt(i)===Se){if(!n){e=i;break}}else n=!1;return e===-1?t?"/":".":t&&e===1?"//":r.slice(0,e)},basename(r,t){t!==void 0&&ce(t,"suffix"),ce(r,"path");let e=0,n=-1,i=!0,o;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t===r)return"";let s=t.length-1,a=-1;for(o=r.length-1;o>=0;--o){let l=r.charCodeAt(o);if(l===Se){if(!i){e=o+1;break}}else a===-1&&(i=!1,a=o+1),s>=0&&(l===t.charCodeAt(s)?--s===-1&&(n=o):(s=-1,n=a))}return e===n?n=a:n===-1&&(n=r.length),r.slice(e,n)}for(o=r.length-1;o>=0;--o)if(r.charCodeAt(o)===Se){if(!i){e=o+1;break}}else n===-1&&(i=!1,n=o+1);return n===-1?"":r.slice(e,n)},extname(r){ce(r,"path");let t=-1,e=0,n=-1,i=!0,o=0;for(let s=r.length-1;s>=0;--s){let a=r[s];if(a==="/"){if(!i){e=s+1;break}continue}n===-1&&(i=!1,n=s+1),a==="."?t===-1?t=s:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||n===-1||o===0||o===1&&t===n-1&&t===e+1?"":r.slice(t,n)},format:Ic.bind(null,"/"),parse(r){ce(r,"path");let t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;let e=r.charCodeAt(0)===Se,n;e?(t.root="/",n=1):n=0;let i=-1,o=0,s=-1,a=!0,l=r.length-1,c=0;for(;l>=n;--l){let d=r.charCodeAt(l);if(d===Se){if(!a){o=l+1;break}continue}s===-1&&(a=!1,s=l+1),d===Zt?i===-1?i=l:c!==1&&(c=1):i!==-1&&(c=-1)}if(s!==-1){let d=o===0&&e?1:o;i===-1||c===0||c===1&&i===s-1&&i===o+1?t.base=t.name=r.slice(d,s):(t.name=r.slice(d,i),t.base=r.slice(d,s),t.ext=r.slice(i,s))}return o>0?t.dir=r.slice(0,o-1):e&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};q.win32=se.win32=se;q.posix=se.posix=q;var je=Ne?se.normalize:q.normalize,Cn=Ne?se.isAbsolute:q.isAbsolute,W=Ne?se.join:q.join,en=Ne?se.resolve:q.resolve,Tc=Ne?se.relative:q.relative,he=Ne?se.dirname:q.dirname,ze=Ne?se.basename:q.basename,Sc=Ne?se.extname:q.extname,A1=Ne?se.format:q.format,k1=Ne?se.parse:q.parse,D1=Ne?se.toNamespacedPath:q.toNamespacedPath,ue=Ne?se.sep:q.sep,Bs=Ne?se.delimiter:q.delimiter;function lf(r){return r}var Ai=class{constructor(t,e){this.lastCache=void 0;this.lastArgKey=void 0;typeof t=="function"?(this._fn=t,this._computeKey=lf):(this._fn=e,this._computeKey=t.getCacheKey)}get(t){let e=this._computeKey(t);return this.lastArgKey!==e&&(this.lastArgKey=e,this.lastCache=this._fn(t)),this.lastCache}};var Oe=class{constructor(t){this.executor=t;this._state=0}get hasValue(){return this._state===2}get value(){if(this._state===0){this._state=1;try{this._value=this.executor()}catch(t){this._error=t}finally{this._state=2}}else if(this._state===1)throw new Error("Cannot read the value of a lazy that is being initialized");if(this._error)throw this._error;return this._value}get rawValue(){return this._value}};function wc(r){return!r||typeof r!="string"?!0:r.trim().length===0}function Ft(r){return r.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g,"\\$&")}function Cc(r,t){if(!r||!t)return r;let e=t.length,n=0;if(e===1){let i=t.charCodeAt(0);for(;n<r.length&&r.charCodeAt(n)===i;)n++}else for(;r.startsWith(t,n);)n+=e;return r.substring(n)}function Pn(r,t){if(!r||!t)return r;let e=t.length,n=r.length;if(e===1){let o=n,s=t.charCodeAt(0);for(;o>0&&r.charCodeAt(o-1)===s;)o--;return r.substring(0,o)}let i=n;for(;i>0&&r.endsWith(t,i);)i-=e;return r.substring(0,i)}function Pc(r){return r.source==="^"||r.source==="^$"||r.source==="$"||r.source==="^\\s*$"?!1:!!(r.exec("")&&r.lastIndex===0)}function Pr(r,t){return r<t?-1:r>t?1:0}function ki(r,t,e=0,n=r.length,i=0,o=t.length){for(;e<n&&i<o;e++,i++){let l=r.charCodeAt(e),c=t.charCodeAt(i);if(l<c)return-1;if(l>c)return 1}let s=n-e,a=o-i;return s<a?-1:s>a?1:0}function qs(r,t){return nn(r,t,0,r.length,0,t.length)}function nn(r,t,e=0,n=r.length,i=0,o=t.length){for(;e<n&&i<o;e++,i++){let l=r.charCodeAt(e),c=t.charCodeAt(i);if(l===c)continue;if(l>=128||c>=128)return ki(r.toLowerCase(),t.toLowerCase(),e,n,i,o);_c(l)&&(l-=32),_c(c)&&(c-=32);let d=l-c;if(d!==0)return d}let s=n-e,a=o-i;return s<a?-1:s>a?1:0}function _c(r){return r>=97&&r<=122}function Vs(r){return r>=65&&r<=90}function rn(r,t){return r.length===t.length&&nn(r,t)===0}function An(r,t){let e=t.length;return e<=r.length&&nn(r,t,0,e)===0}function Ac(r,t){let e=r.length,n=e-t.length;return n>=0&&nn(r,t,n,e)===0}function kc(r){return 55296<=r&&r<=56319}function $s(r){return 56320<=r&&r<=57343}function Dc(r,t){return(r-55296<<10)+(t-56320)+65536}var cf=/(?:\x1b\[|\x9b)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~]/,uf=/(?:\x1b\]|\x9d).*?(?:\x1b\\|\x07|\x9c)/,df=/\x1b(?:[ #%\(\)\*\+\-\.\/]?[a-zA-Z0-9\|}~@])/,$1=new RegExp("(?:"+[cf.source,uf.source,df.source].join("|")+")","g");var K1=String.fromCharCode(65279);var xc=class r{static{this._INSTANCE=null}static getInstance(){return r._INSTANCE||(r._INSTANCE=new r),r._INSTANCE}constructor(){this._data=pf()}getGraphemeBreakType(t){if(t<32)return t===10?3:t===13?2:4;if(t<127)return 0;let e=this._data,n=e.length/3,i=1;for(;i<=n;)if(t<e[3*i])i=2*i;else if(t>e[3*i+1])i=2*i+1;else return e[3*i+2];return 0}};function pf(){return JSON.parse("[0,0,0,51229,51255,12,44061,44087,12,127462,127487,6,7083,7085,5,47645,47671,12,54813,54839,12,128678,128678,14,3270,3270,5,9919,9923,14,45853,45879,12,49437,49463,12,53021,53047,12,71216,71218,7,128398,128399,14,129360,129374,14,2519,2519,5,4448,4519,9,9742,9742,14,12336,12336,14,44957,44983,12,46749,46775,12,48541,48567,12,50333,50359,12,52125,52151,12,53917,53943,12,69888,69890,5,73018,73018,5,127990,127990,14,128558,128559,14,128759,128760,14,129653,129655,14,2027,2035,5,2891,2892,7,3761,3761,5,6683,6683,5,8293,8293,4,9825,9826,14,9999,9999,14,43452,43453,5,44509,44535,12,45405,45431,12,46301,46327,12,47197,47223,12,48093,48119,12,48989,49015,12,49885,49911,12,50781,50807,12,51677,51703,12,52573,52599,12,53469,53495,12,54365,54391,12,65279,65279,4,70471,70472,7,72145,72147,7,119173,119179,5,127799,127818,14,128240,128244,14,128512,128512,14,128652,128652,14,128721,128722,14,129292,129292,14,129445,129450,14,129734,129743,14,1476,1477,5,2366,2368,7,2750,2752,7,3076,3076,5,3415,3415,5,4141,4144,5,6109,6109,5,6964,6964,5,7394,7400,5,9197,9198,14,9770,9770,14,9877,9877,14,9968,9969,14,10084,10084,14,43052,43052,5,43713,43713,5,44285,44311,12,44733,44759,12,45181,45207,12,45629,45655,12,46077,46103,12,46525,46551,12,46973,46999,12,47421,47447,12,47869,47895,12,48317,48343,12,48765,48791,12,49213,49239,12,49661,49687,12,50109,50135,12,50557,50583,12,51005,51031,12,51453,51479,12,51901,51927,12,52349,52375,12,52797,52823,12,53245,53271,12,53693,53719,12,54141,54167,12,54589,54615,12,55037,55063,12,69506,69509,5,70191,70193,5,70841,70841,7,71463,71467,5,72330,72342,5,94031,94031,5,123628,123631,5,127763,127765,14,127941,127941,14,128043,128062,14,128302,128317,14,128465,128467,14,128539,128539,14,128640,128640,14,128662,128662,14,128703,128703,14,128745,128745,14,129004,129007,14,129329,129330,14,129402,129402,14,129483,129483,14,129686,129704,14,130048,131069,14,173,173,4,1757,1757,1,2200,2207,5,2434,2435,7,2631,2632,5,2817,2817,5,3008,3008,5,3201,3201,5,3387,3388,5,3542,3542,5,3902,3903,7,4190,4192,5,6002,6003,5,6439,6440,5,6765,6770,7,7019,7027,5,7154,7155,7,8205,8205,13,8505,8505,14,9654,9654,14,9757,9757,14,9792,9792,14,9852,9853,14,9890,9894,14,9937,9937,14,9981,9981,14,10035,10036,14,11035,11036,14,42654,42655,5,43346,43347,7,43587,43587,5,44006,44007,7,44173,44199,12,44397,44423,12,44621,44647,12,44845,44871,12,45069,45095,12,45293,45319,12,45517,45543,12,45741,45767,12,45965,45991,12,46189,46215,12,46413,46439,12,46637,46663,12,46861,46887,12,47085,47111,12,47309,47335,12,47533,47559,12,47757,47783,12,47981,48007,12,48205,48231,12,48429,48455,12,48653,48679,12,48877,48903,12,49101,49127,12,49325,49351,12,49549,49575,12,49773,49799,12,49997,50023,12,50221,50247,12,50445,50471,12,50669,50695,12,50893,50919,12,51117,51143,12,51341,51367,12,51565,51591,12,51789,51815,12,52013,52039,12,52237,52263,12,52461,52487,12,52685,52711,12,52909,52935,12,53133,53159,12,53357,53383,12,53581,53607,12,53805,53831,12,54029,54055,12,54253,54279,12,54477,54503,12,54701,54727,12,54925,54951,12,55149,55175,12,68101,68102,5,69762,69762,7,70067,70069,7,70371,70378,5,70720,70721,7,71087,71087,5,71341,71341,5,71995,71996,5,72249,72249,7,72850,72871,5,73109,73109,5,118576,118598,5,121505,121519,5,127245,127247,14,127568,127569,14,127777,127777,14,127872,127891,14,127956,127967,14,128015,128016,14,128110,128172,14,128259,128259,14,128367,128368,14,128424,128424,14,128488,128488,14,128530,128532,14,128550,128551,14,128566,128566,14,128647,128647,14,128656,128656,14,128667,128673,14,128691,128693,14,128715,128715,14,128728,128732,14,128752,128752,14,128765,128767,14,129096,129103,14,129311,129311,14,129344,129349,14,129394,129394,14,129413,129425,14,129466,129471,14,129511,129535,14,129664,129666,14,129719,129722,14,129760,129767,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2307,2307,7,2382,2383,7,2497,2500,5,2563,2563,7,2677,2677,5,2763,2764,7,2879,2879,5,2914,2915,5,3021,3021,5,3142,3144,5,3263,3263,5,3285,3286,5,3398,3400,7,3530,3530,5,3633,3633,5,3864,3865,5,3974,3975,5,4155,4156,7,4229,4230,5,5909,5909,7,6078,6085,7,6277,6278,5,6451,6456,7,6744,6750,5,6846,6846,5,6972,6972,5,7074,7077,5,7146,7148,7,7222,7223,5,7416,7417,5,8234,8238,4,8417,8417,5,9000,9000,14,9203,9203,14,9730,9731,14,9748,9749,14,9762,9763,14,9776,9783,14,9800,9811,14,9831,9831,14,9872,9873,14,9882,9882,14,9900,9903,14,9929,9933,14,9941,9960,14,9974,9974,14,9989,9989,14,10006,10006,14,10062,10062,14,10160,10160,14,11647,11647,5,12953,12953,14,43019,43019,5,43232,43249,5,43443,43443,5,43567,43568,7,43696,43696,5,43765,43765,7,44013,44013,5,44117,44143,12,44229,44255,12,44341,44367,12,44453,44479,12,44565,44591,12,44677,44703,12,44789,44815,12,44901,44927,12,45013,45039,12,45125,45151,12,45237,45263,12,45349,45375,12,45461,45487,12,45573,45599,12,45685,45711,12,45797,45823,12,45909,45935,12,46021,46047,12,46133,46159,12,46245,46271,12,46357,46383,12,46469,46495,12,46581,46607,12,46693,46719,12,46805,46831,12,46917,46943,12,47029,47055,12,47141,47167,12,47253,47279,12,47365,47391,12,47477,47503,12,47589,47615,12,47701,47727,12,47813,47839,12,47925,47951,12,48037,48063,12,48149,48175,12,48261,48287,12,48373,48399,12,48485,48511,12,48597,48623,12,48709,48735,12,48821,48847,12,48933,48959,12,49045,49071,12,49157,49183,12,49269,49295,12,49381,49407,12,49493,49519,12,49605,49631,12,49717,49743,12,49829,49855,12,49941,49967,12,50053,50079,12,50165,50191,12,50277,50303,12,50389,50415,12,50501,50527,12,50613,50639,12,50725,50751,12,50837,50863,12,50949,50975,12,51061,51087,12,51173,51199,12,51285,51311,12,51397,51423,12,51509,51535,12,51621,51647,12,51733,51759,12,51845,51871,12,51957,51983,12,52069,52095,12,52181,52207,12,52293,52319,12,52405,52431,12,52517,52543,12,52629,52655,12,52741,52767,12,52853,52879,12,52965,52991,12,53077,53103,12,53189,53215,12,53301,53327,12,53413,53439,12,53525,53551,12,53637,53663,12,53749,53775,12,53861,53887,12,53973,53999,12,54085,54111,12,54197,54223,12,54309,54335,12,54421,54447,12,54533,54559,12,54645,54671,12,54757,54783,12,54869,54895,12,54981,55007,12,55093,55119,12,55243,55291,10,66045,66045,5,68325,68326,5,69688,69702,5,69817,69818,5,69957,69958,7,70089,70092,5,70198,70199,5,70462,70462,5,70502,70508,5,70750,70750,5,70846,70846,7,71100,71101,5,71230,71230,7,71351,71351,5,71737,71738,5,72000,72000,7,72160,72160,5,72273,72278,5,72752,72758,5,72882,72883,5,73031,73031,5,73461,73462,7,94192,94193,7,119149,119149,7,121403,121452,5,122915,122916,5,126980,126980,14,127358,127359,14,127535,127535,14,127759,127759,14,127771,127771,14,127792,127793,14,127825,127867,14,127897,127899,14,127945,127945,14,127985,127986,14,128000,128007,14,128021,128021,14,128066,128100,14,128184,128235,14,128249,128252,14,128266,128276,14,128335,128335,14,128379,128390,14,128407,128419,14,128444,128444,14,128481,128481,14,128499,128499,14,128526,128526,14,128536,128536,14,128543,128543,14,128556,128556,14,128564,128564,14,128577,128580,14,128643,128645,14,128649,128649,14,128654,128654,14,128660,128660,14,128664,128664,14,128675,128675,14,128686,128689,14,128695,128696,14,128705,128709,14,128717,128719,14,128725,128725,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129009,129023,14,129160,129167,14,129296,129304,14,129320,129327,14,129340,129342,14,129356,129356,14,129388,129392,14,129399,129400,14,129404,129407,14,129432,129442,14,129454,129455,14,129473,129474,14,129485,129487,14,129648,129651,14,129659,129660,14,129671,129679,14,129709,129711,14,129728,129730,14,129751,129753,14,129776,129782,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2274,2274,1,2363,2363,7,2377,2380,7,2402,2403,5,2494,2494,5,2507,2508,7,2558,2558,5,2622,2624,7,2641,2641,5,2691,2691,7,2759,2760,5,2786,2787,5,2876,2876,5,2881,2884,5,2901,2902,5,3006,3006,5,3014,3016,7,3072,3072,5,3134,3136,5,3157,3158,5,3260,3260,5,3266,3266,5,3274,3275,7,3328,3329,5,3391,3392,7,3405,3405,5,3457,3457,5,3536,3537,7,3551,3551,5,3636,3642,5,3764,3772,5,3895,3895,5,3967,3967,7,3993,4028,5,4146,4151,5,4182,4183,7,4226,4226,5,4253,4253,5,4957,4959,5,5940,5940,7,6070,6070,7,6087,6088,7,6158,6158,4,6432,6434,5,6448,6449,7,6679,6680,5,6742,6742,5,6754,6754,5,6783,6783,5,6912,6915,5,6966,6970,5,6978,6978,5,7042,7042,7,7080,7081,5,7143,7143,7,7150,7150,7,7212,7219,5,7380,7392,5,7412,7412,5,8203,8203,4,8232,8232,4,8265,8265,14,8400,8412,5,8421,8432,5,8617,8618,14,9167,9167,14,9200,9200,14,9410,9410,14,9723,9726,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9774,14,9786,9786,14,9794,9794,14,9823,9823,14,9828,9828,14,9833,9850,14,9855,9855,14,9875,9875,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9935,9935,14,9939,9939,14,9962,9962,14,9972,9972,14,9978,9978,14,9986,9986,14,9997,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10133,10135,14,10548,10549,14,11093,11093,14,12330,12333,5,12441,12442,5,42608,42610,5,43010,43010,5,43045,43046,5,43188,43203,7,43302,43309,5,43392,43394,5,43446,43449,5,43493,43493,5,43571,43572,7,43597,43597,7,43703,43704,5,43756,43757,5,44003,44004,7,44009,44010,7,44033,44059,12,44089,44115,12,44145,44171,12,44201,44227,12,44257,44283,12,44313,44339,12,44369,44395,12,44425,44451,12,44481,44507,12,44537,44563,12,44593,44619,12,44649,44675,12,44705,44731,12,44761,44787,12,44817,44843,12,44873,44899,12,44929,44955,12,44985,45011,12,45041,45067,12,45097,45123,12,45153,45179,12,45209,45235,12,45265,45291,12,45321,45347,12,45377,45403,12,45433,45459,12,45489,45515,12,45545,45571,12,45601,45627,12,45657,45683,12,45713,45739,12,45769,45795,12,45825,45851,12,45881,45907,12,45937,45963,12,45993,46019,12,46049,46075,12,46105,46131,12,46161,46187,12,46217,46243,12,46273,46299,12,46329,46355,12,46385,46411,12,46441,46467,12,46497,46523,12,46553,46579,12,46609,46635,12,46665,46691,12,46721,46747,12,46777,46803,12,46833,46859,12,46889,46915,12,46945,46971,12,47001,47027,12,47057,47083,12,47113,47139,12,47169,47195,12,47225,47251,12,47281,47307,12,47337,47363,12,47393,47419,12,47449,47475,12,47505,47531,12,47561,47587,12,47617,47643,12,47673,47699,12,47729,47755,12,47785,47811,12,47841,47867,12,47897,47923,12,47953,47979,12,48009,48035,12,48065,48091,12,48121,48147,12,48177,48203,12,48233,48259,12,48289,48315,12,48345,48371,12,48401,48427,12,48457,48483,12,48513,48539,12,48569,48595,12,48625,48651,12,48681,48707,12,48737,48763,12,48793,48819,12,48849,48875,12,48905,48931,12,48961,48987,12,49017,49043,12,49073,49099,12,49129,49155,12,49185,49211,12,49241,49267,12,49297,49323,12,49353,49379,12,49409,49435,12,49465,49491,12,49521,49547,12,49577,49603,12,49633,49659,12,49689,49715,12,49745,49771,12,49801,49827,12,49857,49883,12,49913,49939,12,49969,49995,12,50025,50051,12,50081,50107,12,50137,50163,12,50193,50219,12,50249,50275,12,50305,50331,12,50361,50387,12,50417,50443,12,50473,50499,12,50529,50555,12,50585,50611,12,50641,50667,12,50697,50723,12,50753,50779,12,50809,50835,12,50865,50891,12,50921,50947,12,50977,51003,12,51033,51059,12,51089,51115,12,51145,51171,12,51201,51227,12,51257,51283,12,51313,51339,12,51369,51395,12,51425,51451,12,51481,51507,12,51537,51563,12,51593,51619,12,51649,51675,12,51705,51731,12,51761,51787,12,51817,51843,12,51873,51899,12,51929,51955,12,51985,52011,12,52041,52067,12,52097,52123,12,52153,52179,12,52209,52235,12,52265,52291,12,52321,52347,12,52377,52403,12,52433,52459,12,52489,52515,12,52545,52571,12,52601,52627,12,52657,52683,12,52713,52739,12,52769,52795,12,52825,52851,12,52881,52907,12,52937,52963,12,52993,53019,12,53049,53075,12,53105,53131,12,53161,53187,12,53217,53243,12,53273,53299,12,53329,53355,12,53385,53411,12,53441,53467,12,53497,53523,12,53553,53579,12,53609,53635,12,53665,53691,12,53721,53747,12,53777,53803,12,53833,53859,12,53889,53915,12,53945,53971,12,54001,54027,12,54057,54083,12,54113,54139,12,54169,54195,12,54225,54251,12,54281,54307,12,54337,54363,12,54393,54419,12,54449,54475,12,54505,54531,12,54561,54587,12,54617,54643,12,54673,54699,12,54729,54755,12,54785,54811,12,54841,54867,12,54897,54923,12,54953,54979,12,55009,55035,12,55065,55091,12,55121,55147,12,55177,55203,12,65024,65039,5,65520,65528,4,66422,66426,5,68152,68154,5,69291,69292,5,69633,69633,5,69747,69748,5,69811,69814,5,69826,69826,5,69932,69932,7,70016,70017,5,70079,70080,7,70095,70095,5,70196,70196,5,70367,70367,5,70402,70403,7,70464,70464,5,70487,70487,5,70709,70711,7,70725,70725,7,70833,70834,7,70843,70844,7,70849,70849,7,71090,71093,5,71103,71104,5,71227,71228,7,71339,71339,5,71344,71349,5,71458,71461,5,71727,71735,5,71985,71989,7,71998,71998,5,72002,72002,7,72154,72155,5,72193,72202,5,72251,72254,5,72281,72283,5,72344,72345,5,72766,72766,7,72874,72880,5,72885,72886,5,73023,73029,5,73104,73105,5,73111,73111,5,92912,92916,5,94095,94098,5,113824,113827,4,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,125252,125258,5,127183,127183,14,127340,127343,14,127377,127386,14,127491,127503,14,127548,127551,14,127744,127756,14,127761,127761,14,127769,127769,14,127773,127774,14,127780,127788,14,127796,127797,14,127820,127823,14,127869,127869,14,127894,127895,14,127902,127903,14,127943,127943,14,127947,127950,14,127972,127972,14,127988,127988,14,127992,127994,14,128009,128011,14,128019,128019,14,128023,128041,14,128064,128064,14,128102,128107,14,128174,128181,14,128238,128238,14,128246,128247,14,128254,128254,14,128264,128264,14,128278,128299,14,128329,128330,14,128348,128359,14,128371,128377,14,128392,128393,14,128401,128404,14,128421,128421,14,128433,128434,14,128450,128452,14,128476,128478,14,128483,128483,14,128495,128495,14,128506,128506,14,128519,128520,14,128528,128528,14,128534,128534,14,128538,128538,14,128540,128542,14,128544,128549,14,128552,128555,14,128557,128557,14,128560,128563,14,128565,128565,14,128567,128576,14,128581,128591,14,128641,128642,14,128646,128646,14,128648,128648,14,128650,128651,14,128653,128653,14,128655,128655,14,128657,128659,14,128661,128661,14,128663,128663,14,128665,128666,14,128674,128674,14,128676,128677,14,128679,128685,14,128690,128690,14,128694,128694,14,128697,128702,14,128704,128704,14,128710,128714,14,128716,128716,14,128720,128720,14,128723,128724,14,128726,128727,14,128733,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129008,129008,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129661,129663,14,129667,129670,14,129680,129685,14,129705,129708,14,129712,129718,14,129723,129727,14,129731,129733,14,129744,129750,14,129754,129759,14,129768,129775,14,129783,129791,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2192,2193,1,2250,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3132,3132,5,3137,3140,7,3146,3149,5,3170,3171,5,3202,3203,7,3262,3262,7,3264,3265,7,3267,3268,7,3271,3272,7,3276,3277,5,3298,3299,5,3330,3331,7,3390,3390,5,3393,3396,5,3402,3404,7,3406,3406,1,3426,3427,5,3458,3459,7,3535,3535,5,3538,3540,5,3544,3550,7,3570,3571,7,3635,3635,7,3655,3662,5,3763,3763,7,3784,3789,5,3893,3893,5,3897,3897,5,3953,3966,5,3968,3972,5,3981,3991,5,4038,4038,5,4145,4145,7,4153,4154,5,4157,4158,5,4184,4185,5,4209,4212,5,4228,4228,7,4237,4237,5,4352,4447,8,4520,4607,10,5906,5908,5,5938,5939,5,5970,5971,5,6068,6069,5,6071,6077,5,6086,6086,5,6089,6099,5,6155,6157,5,6159,6159,5,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6862,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7679,5,8204,8204,5,8206,8207,4,8233,8233,4,8252,8252,14,8288,8292,4,8294,8303,4,8413,8416,5,8418,8420,5,8482,8482,14,8596,8601,14,8986,8987,14,9096,9096,14,9193,9196,14,9199,9199,14,9201,9202,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9729,14,9732,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9775,9775,14,9784,9785,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9874,14,9876,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9934,14,9936,9936,14,9938,9938,14,9940,9940,14,9961,9961,14,9963,9967,14,9970,9971,14,9973,9973,14,9975,9977,14,9979,9980,14,9982,9985,14,9987,9988,14,9992,9996,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10083,14,10085,10087,14,10145,10145,14,10175,10175,14,11013,11015,14,11088,11088,14,11503,11505,5,11744,11775,5,12334,12335,5,12349,12349,14,12951,12951,14,42607,42607,5,42612,42621,5,42736,42737,5,43014,43014,5,43043,43044,7,43047,43047,7,43136,43137,7,43204,43205,5,43263,43263,5,43335,43345,5,43360,43388,8,43395,43395,7,43444,43445,7,43450,43451,7,43454,43456,7,43561,43566,5,43569,43570,5,43573,43574,5,43596,43596,5,43644,43644,5,43698,43700,5,43710,43711,5,43755,43755,7,43758,43759,7,43766,43766,5,44005,44005,5,44008,44008,5,44012,44012,7,44032,44032,11,44060,44060,11,44088,44088,11,44116,44116,11,44144,44144,11,44172,44172,11,44200,44200,11,44228,44228,11,44256,44256,11,44284,44284,11,44312,44312,11,44340,44340,11,44368,44368,11,44396,44396,11,44424,44424,11,44452,44452,11,44480,44480,11,44508,44508,11,44536,44536,11,44564,44564,11,44592,44592,11,44620,44620,11,44648,44648,11,44676,44676,11,44704,44704,11,44732,44732,11,44760,44760,11,44788,44788,11,44816,44816,11,44844,44844,11,44872,44872,11,44900,44900,11,44928,44928,11,44956,44956,11,44984,44984,11,45012,45012,11,45040,45040,11,45068,45068,11,45096,45096,11,45124,45124,11,45152,45152,11,45180,45180,11,45208,45208,11,45236,45236,11,45264,45264,11,45292,45292,11,45320,45320,11,45348,45348,11,45376,45376,11,45404,45404,11,45432,45432,11,45460,45460,11,45488,45488,11,45516,45516,11,45544,45544,11,45572,45572,11,45600,45600,11,45628,45628,11,45656,45656,11,45684,45684,11,45712,45712,11,45740,45740,11,45768,45768,11,45796,45796,11,45824,45824,11,45852,45852,11,45880,45880,11,45908,45908,11,45936,45936,11,45964,45964,11,45992,45992,11,46020,46020,11,46048,46048,11,46076,46076,11,46104,46104,11,46132,46132,11,46160,46160,11,46188,46188,11,46216,46216,11,46244,46244,11,46272,46272,11,46300,46300,11,46328,46328,11,46356,46356,11,46384,46384,11,46412,46412,11,46440,46440,11,46468,46468,11,46496,46496,11,46524,46524,11,46552,46552,11,46580,46580,11,46608,46608,11,46636,46636,11,46664,46664,11,46692,46692,11,46720,46720,11,46748,46748,11,46776,46776,11,46804,46804,11,46832,46832,11,46860,46860,11,46888,46888,11,46916,46916,11,46944,46944,11,46972,46972,11,47000,47000,11,47028,47028,11,47056,47056,11,47084,47084,11,47112,47112,11,47140,47140,11,47168,47168,11,47196,47196,11,47224,47224,11,47252,47252,11,47280,47280,11,47308,47308,11,47336,47336,11,47364,47364,11,47392,47392,11,47420,47420,11,47448,47448,11,47476,47476,11,47504,47504,11,47532,47532,11,47560,47560,11,47588,47588,11,47616,47616,11,47644,47644,11,47672,47672,11,47700,47700,11,47728,47728,11,47756,47756,11,47784,47784,11,47812,47812,11,47840,47840,11,47868,47868,11,47896,47896,11,47924,47924,11,47952,47952,11,47980,47980,11,48008,48008,11,48036,48036,11,48064,48064,11,48092,48092,11,48120,48120,11,48148,48148,11,48176,48176,11,48204,48204,11,48232,48232,11,48260,48260,11,48288,48288,11,48316,48316,11,48344,48344,11,48372,48372,11,48400,48400,11,48428,48428,11,48456,48456,11,48484,48484,11,48512,48512,11,48540,48540,11,48568,48568,11,48596,48596,11,48624,48624,11,48652,48652,11,48680,48680,11,48708,48708,11,48736,48736,11,48764,48764,11,48792,48792,11,48820,48820,11,48848,48848,11,48876,48876,11,48904,48904,11,48932,48932,11,48960,48960,11,48988,48988,11,49016,49016,11,49044,49044,11,49072,49072,11,49100,49100,11,49128,49128,11,49156,49156,11,49184,49184,11,49212,49212,11,49240,49240,11,49268,49268,11,49296,49296,11,49324,49324,11,49352,49352,11,49380,49380,11,49408,49408,11,49436,49436,11,49464,49464,11,49492,49492,11,49520,49520,11,49548,49548,11,49576,49576,11,49604,49604,11,49632,49632,11,49660,49660,11,49688,49688,11,49716,49716,11,49744,49744,11,49772,49772,11,49800,49800,11,49828,49828,11,49856,49856,11,49884,49884,11,49912,49912,11,49940,49940,11,49968,49968,11,49996,49996,11,50024,50024,11,50052,50052,11,50080,50080,11,50108,50108,11,50136,50136,11,50164,50164,11,50192,50192,11,50220,50220,11,50248,50248,11,50276,50276,11,50304,50304,11,50332,50332,11,50360,50360,11,50388,50388,11,50416,50416,11,50444,50444,11,50472,50472,11,50500,50500,11,50528,50528,11,50556,50556,11,50584,50584,11,50612,50612,11,50640,50640,11,50668,50668,11,50696,50696,11,50724,50724,11,50752,50752,11,50780,50780,11,50808,50808,11,50836,50836,11,50864,50864,11,50892,50892,11,50920,50920,11,50948,50948,11,50976,50976,11,51004,51004,11,51032,51032,11,51060,51060,11,51088,51088,11,51116,51116,11,51144,51144,11,51172,51172,11,51200,51200,11,51228,51228,11,51256,51256,11,51284,51284,11,51312,51312,11,51340,51340,11,51368,51368,11,51396,51396,11,51424,51424,11,51452,51452,11,51480,51480,11,51508,51508,11,51536,51536,11,51564,51564,11,51592,51592,11,51620,51620,11,51648,51648,11,51676,51676,11,51704,51704,11,51732,51732,11,51760,51760,11,51788,51788,11,51816,51816,11,51844,51844,11,51872,51872,11,51900,51900,11,51928,51928,11,51956,51956,11,51984,51984,11,52012,52012,11,52040,52040,11,52068,52068,11,52096,52096,11,52124,52124,11,52152,52152,11,52180,52180,11,52208,52208,11,52236,52236,11,52264,52264,11,52292,52292,11,52320,52320,11,52348,52348,11,52376,52376,11,52404,52404,11,52432,52432,11,52460,52460,11,52488,52488,11,52516,52516,11,52544,52544,11,52572,52572,11,52600,52600,11,52628,52628,11,52656,52656,11,52684,52684,11,52712,52712,11,52740,52740,11,52768,52768,11,52796,52796,11,52824,52824,11,52852,52852,11,52880,52880,11,52908,52908,11,52936,52936,11,52964,52964,11,52992,52992,11,53020,53020,11,53048,53048,11,53076,53076,11,53104,53104,11,53132,53132,11,53160,53160,11,53188,53188,11,53216,53216,11,53244,53244,11,53272,53272,11,53300,53300,11,53328,53328,11,53356,53356,11,53384,53384,11,53412,53412,11,53440,53440,11,53468,53468,11,53496,53496,11,53524,53524,11,53552,53552,11,53580,53580,11,53608,53608,11,53636,53636,11,53664,53664,11,53692,53692,11,53720,53720,11,53748,53748,11,53776,53776,11,53804,53804,11,53832,53832,11,53860,53860,11,53888,53888,11,53916,53916,11,53944,53944,11,53972,53972,11,54000,54000,11,54028,54028,11,54056,54056,11,54084,54084,11,54112,54112,11,54140,54140,11,54168,54168,11,54196,54196,11,54224,54224,11,54252,54252,11,54280,54280,11,54308,54308,11,54336,54336,11,54364,54364,11,54392,54392,11,54420,54420,11,54448,54448,11,54476,54476,11,54504,54504,11,54532,54532,11,54560,54560,11,54588,54588,11,54616,54616,11,54644,54644,11,54672,54672,11,54700,54700,11,54728,54728,11,54756,54756,11,54784,54784,11,54812,54812,11,54840,54840,11,54868,54868,11,54896,54896,11,54924,54924,11,54952,54952,11,54980,54980,11,55008,55008,11,55036,55036,11,55064,55064,11,55092,55092,11,55120,55120,11,55148,55148,11,55176,55176,11,55216,55238,9,64286,64286,5,65056,65071,5,65438,65439,5,65529,65531,4,66272,66272,5,68097,68099,5,68108,68111,5,68159,68159,5,68900,68903,5,69446,69456,5,69632,69632,7,69634,69634,7,69744,69744,5,69759,69761,5,69808,69810,7,69815,69816,7,69821,69821,1,69837,69837,1,69927,69931,5,69933,69940,5,70003,70003,5,70018,70018,7,70070,70078,5,70082,70083,1,70094,70094,7,70188,70190,7,70194,70195,7,70197,70197,7,70206,70206,5,70368,70370,7,70400,70401,5,70459,70460,5,70463,70463,7,70465,70468,7,70475,70477,7,70498,70499,7,70512,70516,5,70712,70719,5,70722,70724,5,70726,70726,5,70832,70832,5,70835,70840,5,70842,70842,5,70845,70845,5,70847,70848,5,70850,70851,5,71088,71089,7,71096,71099,7,71102,71102,7,71132,71133,5,71219,71226,5,71229,71229,5,71231,71232,5,71340,71340,7,71342,71343,7,71350,71350,7,71453,71455,5,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,118528,118573,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123566,123566,5,125136,125142,5,126976,126979,14,126981,127182,14,127184,127231,14,127279,127279,14,127344,127345,14,127374,127374,14,127405,127461,14,127489,127490,14,127514,127514,14,127538,127546,14,127561,127567,14,127570,127743,14,127757,127758,14,127760,127760,14,127762,127762,14,127766,127768,14,127770,127770,14,127772,127772,14,127775,127776,14,127778,127779,14,127789,127791,14,127794,127795,14,127798,127798,14,127819,127819,14,127824,127824,14,127868,127868,14,127870,127871,14,127892,127893,14,127896,127896,14,127900,127901,14,127904,127940,14,127942,127942,14,127944,127944,14,127946,127946,14,127951,127955,14,127968,127971,14,127973,127984,14,127987,127987,14,127989,127989,14,127991,127991,14,127995,127999,5,128008,128008,14,128012,128014,14,128017,128018,14,128020,128020,14,128022,128022,14,128042,128042,14,128063,128063,14,128065,128065,14,128101,128101,14,128108,128109,14,128173,128173,14,128182,128183,14,128236,128237,14,128239,128239,14,128245,128245,14,128248,128248,14,128253,128253,14,128255,128258,14,128260,128263,14,128265,128265,14,128277,128277,14,128300,128301,14,128326,128328,14,128331,128334,14,128336,128347,14,128360,128366,14,128369,128370,14,128378,128378,14,128391,128391,14,128394,128397,14,128400,128400,14,128405,128406,14,128420,128420,14,128422,128423,14,128425,128432,14,128435,128443,14,128445,128449,14,128453,128464,14,128468,128475,14,128479,128480,14,128482,128482,14,128484,128487,14,128489,128494,14,128496,128498,14,128500,128505,14,128507,128511,14,128513,128518,14,128521,128525,14,128527,128527,14,128529,128529,14,128533,128533,14,128535,128535,14,128537,128537,14]")}var Rc=class r{constructor(t){this.confusableDictionary=t}static{this.ambiguousCharacterData=new Oe(()=>JSON.parse('{"_common":[8232,32,8233,32,5760,32,8192,32,8193,32,8194,32,8195,32,8196,32,8197,32,8198,32,8200,32,8201,32,8202,32,8287,32,8199,32,8239,32,2042,95,65101,95,65102,95,65103,95,8208,45,8209,45,8210,45,65112,45,1748,45,8259,45,727,45,8722,45,10134,45,11450,45,1549,44,1643,44,184,44,42233,44,894,59,2307,58,2691,58,1417,58,1795,58,1796,58,5868,58,65072,58,6147,58,6153,58,8282,58,1475,58,760,58,42889,58,8758,58,720,58,42237,58,451,33,11601,33,660,63,577,63,2429,63,5038,63,42731,63,119149,46,8228,46,1793,46,1794,46,42510,46,68176,46,1632,46,1776,46,42232,46,1373,96,65287,96,8219,96,1523,96,8242,96,1370,96,8175,96,65344,96,900,96,8189,96,8125,96,8127,96,8190,96,697,96,884,96,712,96,714,96,715,96,756,96,699,96,701,96,700,96,702,96,42892,96,1497,96,2036,96,2037,96,5194,96,5836,96,94033,96,94034,96,65339,91,10088,40,10098,40,12308,40,64830,40,65341,93,10089,41,10099,41,12309,41,64831,41,10100,123,119060,123,10101,125,65342,94,8270,42,1645,42,8727,42,66335,42,5941,47,8257,47,8725,47,8260,47,9585,47,10187,47,10744,47,119354,47,12755,47,12339,47,11462,47,20031,47,12035,47,65340,92,65128,92,8726,92,10189,92,10741,92,10745,92,119311,92,119355,92,12756,92,20022,92,12034,92,42872,38,708,94,710,94,5869,43,10133,43,66203,43,8249,60,10094,60,706,60,119350,60,5176,60,5810,60,5120,61,11840,61,12448,61,42239,61,8250,62,10095,62,707,62,119351,62,5171,62,94015,62,8275,126,732,126,8128,126,8764,126,65372,124,65293,45,118002,50,120784,50,120794,50,120804,50,120814,50,120824,50,130034,50,42842,50,423,50,1000,50,42564,50,5311,50,42735,50,119302,51,118003,51,120785,51,120795,51,120805,51,120815,51,120825,51,130035,51,42923,51,540,51,439,51,42858,51,11468,51,1248,51,94011,51,71882,51,118004,52,120786,52,120796,52,120806,52,120816,52,120826,52,130036,52,5070,52,71855,52,118005,53,120787,53,120797,53,120807,53,120817,53,120827,53,130037,53,444,53,71867,53,118006,54,120788,54,120798,54,120808,54,120818,54,120828,54,130038,54,11474,54,5102,54,71893,54,119314,55,118007,55,120789,55,120799,55,120809,55,120819,55,120829,55,130039,55,66770,55,71878,55,2819,56,2538,56,2666,56,125131,56,118008,56,120790,56,120800,56,120810,56,120820,56,120830,56,130040,56,547,56,546,56,66330,56,2663,57,2920,57,2541,57,3437,57,118009,57,120791,57,120801,57,120811,57,120821,57,120831,57,130041,57,42862,57,11466,57,71884,57,71852,57,71894,57,9082,97,65345,97,119834,97,119886,97,119938,97,119990,97,120042,97,120094,97,120146,97,120198,97,120250,97,120302,97,120354,97,120406,97,120458,97,593,97,945,97,120514,97,120572,97,120630,97,120688,97,120746,97,65313,65,117974,65,119808,65,119860,65,119912,65,119964,65,120016,65,120068,65,120120,65,120172,65,120224,65,120276,65,120328,65,120380,65,120432,65,913,65,120488,65,120546,65,120604,65,120662,65,120720,65,5034,65,5573,65,42222,65,94016,65,66208,65,119835,98,119887,98,119939,98,119991,98,120043,98,120095,98,120147,98,120199,98,120251,98,120303,98,120355,98,120407,98,120459,98,388,98,5071,98,5234,98,5551,98,65314,66,8492,66,117975,66,119809,66,119861,66,119913,66,120017,66,120069,66,120121,66,120173,66,120225,66,120277,66,120329,66,120381,66,120433,66,42932,66,914,66,120489,66,120547,66,120605,66,120663,66,120721,66,5108,66,5623,66,42192,66,66178,66,66209,66,66305,66,65347,99,8573,99,119836,99,119888,99,119940,99,119992,99,120044,99,120096,99,120148,99,120200,99,120252,99,120304,99,120356,99,120408,99,120460,99,7428,99,1010,99,11429,99,43951,99,66621,99,128844,67,71913,67,71922,67,65315,67,8557,67,8450,67,8493,67,117976,67,119810,67,119862,67,119914,67,119966,67,120018,67,120174,67,120226,67,120278,67,120330,67,120382,67,120434,67,1017,67,11428,67,5087,67,42202,67,66210,67,66306,67,66581,67,66844,67,8574,100,8518,100,119837,100,119889,100,119941,100,119993,100,120045,100,120097,100,120149,100,120201,100,120253,100,120305,100,120357,100,120409,100,120461,100,1281,100,5095,100,5231,100,42194,100,8558,68,8517,68,117977,68,119811,68,119863,68,119915,68,119967,68,120019,68,120071,68,120123,68,120175,68,120227,68,120279,68,120331,68,120383,68,120435,68,5024,68,5598,68,5610,68,42195,68,8494,101,65349,101,8495,101,8519,101,119838,101,119890,101,119942,101,120046,101,120098,101,120150,101,120202,101,120254,101,120306,101,120358,101,120410,101,120462,101,43826,101,1213,101,8959,69,65317,69,8496,69,117978,69,119812,69,119864,69,119916,69,120020,69,120072,69,120124,69,120176,69,120228,69,120280,69,120332,69,120384,69,120436,69,917,69,120492,69,120550,69,120608,69,120666,69,120724,69,11577,69,5036,69,42224,69,71846,69,71854,69,66182,69,119839,102,119891,102,119943,102,119995,102,120047,102,120099,102,120151,102,120203,102,120255,102,120307,102,120359,102,120411,102,120463,102,43829,102,42905,102,383,102,7837,102,1412,102,119315,70,8497,70,117979,70,119813,70,119865,70,119917,70,120021,70,120073,70,120125,70,120177,70,120229,70,120281,70,120333,70,120385,70,120437,70,42904,70,988,70,120778,70,5556,70,42205,70,71874,70,71842,70,66183,70,66213,70,66853,70,65351,103,8458,103,119840,103,119892,103,119944,103,120048,103,120100,103,120152,103,120204,103,120256,103,120308,103,120360,103,120412,103,120464,103,609,103,7555,103,397,103,1409,103,117980,71,119814,71,119866,71,119918,71,119970,71,120022,71,120074,71,120126,71,120178,71,120230,71,120282,71,120334,71,120386,71,120438,71,1292,71,5056,71,5107,71,42198,71,65352,104,8462,104,119841,104,119945,104,119997,104,120049,104,120101,104,120153,104,120205,104,120257,104,120309,104,120361,104,120413,104,120465,104,1211,104,1392,104,5058,104,65320,72,8459,72,8460,72,8461,72,117981,72,119815,72,119867,72,119919,72,120023,72,120179,72,120231,72,120283,72,120335,72,120387,72,120439,72,919,72,120494,72,120552,72,120610,72,120668,72,120726,72,11406,72,5051,72,5500,72,42215,72,66255,72,731,105,9075,105,65353,105,8560,105,8505,105,8520,105,119842,105,119894,105,119946,105,119998,105,120050,105,120102,105,120154,105,120206,105,120258,105,120310,105,120362,105,120414,105,120466,105,120484,105,618,105,617,105,953,105,8126,105,890,105,120522,105,120580,105,120638,105,120696,105,120754,105,1110,105,42567,105,1231,105,43893,105,5029,105,71875,105,65354,106,8521,106,119843,106,119895,106,119947,106,119999,106,120051,106,120103,106,120155,106,120207,106,120259,106,120311,106,120363,106,120415,106,120467,106,1011,106,1112,106,65322,74,117983,74,119817,74,119869,74,119921,74,119973,74,120025,74,120077,74,120129,74,120181,74,120233,74,120285,74,120337,74,120389,74,120441,74,42930,74,895,74,1032,74,5035,74,5261,74,42201,74,119844,107,119896,107,119948,107,120000,107,120052,107,120104,107,120156,107,120208,107,120260,107,120312,107,120364,107,120416,107,120468,107,8490,75,65323,75,117984,75,119818,75,119870,75,119922,75,119974,75,120026,75,120078,75,120130,75,120182,75,120234,75,120286,75,120338,75,120390,75,120442,75,922,75,120497,75,120555,75,120613,75,120671,75,120729,75,11412,75,5094,75,5845,75,42199,75,66840,75,1472,108,8739,73,9213,73,65512,73,1633,108,1777,73,66336,108,125127,108,118001,108,120783,73,120793,73,120803,73,120813,73,120823,73,130033,73,65321,73,8544,73,8464,73,8465,73,117982,108,119816,73,119868,73,119920,73,120024,73,120128,73,120180,73,120232,73,120284,73,120336,73,120388,73,120440,73,65356,108,8572,73,8467,108,119845,108,119897,108,119949,108,120001,108,120053,108,120105,73,120157,73,120209,73,120261,73,120313,73,120365,73,120417,73,120469,73,448,73,120496,73,120554,73,120612,73,120670,73,120728,73,11410,73,1030,73,1216,73,1493,108,1503,108,1575,108,126464,108,126592,108,65166,108,65165,108,1994,108,11599,73,5825,73,42226,73,93992,73,66186,124,66313,124,119338,76,8556,76,8466,76,117985,76,119819,76,119871,76,119923,76,120027,76,120079,76,120131,76,120183,76,120235,76,120287,76,120339,76,120391,76,120443,76,11472,76,5086,76,5290,76,42209,76,93974,76,71843,76,71858,76,66587,76,66854,76,65325,77,8559,77,8499,77,117986,77,119820,77,119872,77,119924,77,120028,77,120080,77,120132,77,120184,77,120236,77,120288,77,120340,77,120392,77,120444,77,924,77,120499,77,120557,77,120615,77,120673,77,120731,77,1018,77,11416,77,5047,77,5616,77,5846,77,42207,77,66224,77,66321,77,119847,110,119899,110,119951,110,120003,110,120055,110,120107,110,120159,110,120211,110,120263,110,120315,110,120367,110,120419,110,120471,110,1400,110,1404,110,65326,78,8469,78,117987,78,119821,78,119873,78,119925,78,119977,78,120029,78,120081,78,120185,78,120237,78,120289,78,120341,78,120393,78,120445,78,925,78,120500,78,120558,78,120616,78,120674,78,120732,78,11418,78,42208,78,66835,78,3074,111,3202,111,3330,111,3458,111,2406,111,2662,111,2790,111,3046,111,3174,111,3302,111,3430,111,3664,111,3792,111,4160,111,1637,111,1781,111,65359,111,8500,111,119848,111,119900,111,119952,111,120056,111,120108,111,120160,111,120212,111,120264,111,120316,111,120368,111,120420,111,120472,111,7439,111,7441,111,43837,111,959,111,120528,111,120586,111,120644,111,120702,111,120760,111,963,111,120532,111,120590,111,120648,111,120706,111,120764,111,11423,111,4351,111,1413,111,1505,111,1607,111,126500,111,126564,111,126596,111,65259,111,65260,111,65258,111,65257,111,1726,111,64428,111,64429,111,64427,111,64426,111,1729,111,64424,111,64425,111,64423,111,64422,111,1749,111,3360,111,4125,111,66794,111,71880,111,71895,111,66604,111,1984,79,2534,79,2918,79,12295,79,70864,79,71904,79,118000,79,120782,79,120792,79,120802,79,120812,79,120822,79,130032,79,65327,79,117988,79,119822,79,119874,79,119926,79,119978,79,120030,79,120082,79,120134,79,120186,79,120238,79,120290,79,120342,79,120394,79,120446,79,927,79,120502,79,120560,79,120618,79,120676,79,120734,79,11422,79,1365,79,11604,79,4816,79,2848,79,66754,79,42227,79,71861,79,66194,79,66219,79,66564,79,66838,79,9076,112,65360,112,119849,112,119901,112,119953,112,120005,112,120057,112,120109,112,120161,112,120213,112,120265,112,120317,112,120369,112,120421,112,120473,112,961,112,120530,112,120544,112,120588,112,120602,112,120646,112,120660,112,120704,112,120718,112,120762,112,120776,112,11427,112,65328,80,8473,80,117989,80,119823,80,119875,80,119927,80,119979,80,120031,80,120083,80,120187,80,120239,80,120291,80,120343,80,120395,80,120447,80,929,80,120504,80,120562,80,120620,80,120678,80,120736,80,11426,80,5090,80,5229,80,42193,80,66197,80,119850,113,119902,113,119954,113,120006,113,120058,113,120110,113,120162,113,120214,113,120266,113,120318,113,120370,113,120422,113,120474,113,1307,113,1379,113,1382,113,8474,81,117990,81,119824,81,119876,81,119928,81,119980,81,120032,81,120084,81,120188,81,120240,81,120292,81,120344,81,120396,81,120448,81,11605,81,119851,114,119903,114,119955,114,120007,114,120059,114,120111,114,120163,114,120215,114,120267,114,120319,114,120371,114,120423,114,120475,114,43847,114,43848,114,7462,114,11397,114,43905,114,119318,82,8475,82,8476,82,8477,82,117991,82,119825,82,119877,82,119929,82,120033,82,120189,82,120241,82,120293,82,120345,82,120397,82,120449,82,422,82,5025,82,5074,82,66740,82,5511,82,42211,82,94005,82,65363,115,119852,115,119904,115,119956,115,120008,115,120060,115,120112,115,120164,115,120216,115,120268,115,120320,115,120372,115,120424,115,120476,115,42801,115,445,115,1109,115,43946,115,71873,115,66632,115,65331,83,117992,83,119826,83,119878,83,119930,83,119982,83,120034,83,120086,83,120138,83,120190,83,120242,83,120294,83,120346,83,120398,83,120450,83,1029,83,1359,83,5077,83,5082,83,42210,83,94010,83,66198,83,66592,83,119853,116,119905,116,119957,116,120009,116,120061,116,120113,116,120165,116,120217,116,120269,116,120321,116,120373,116,120425,116,120477,116,8868,84,10201,84,128872,84,65332,84,117993,84,119827,84,119879,84,119931,84,119983,84,120035,84,120087,84,120139,84,120191,84,120243,84,120295,84,120347,84,120399,84,120451,84,932,84,120507,84,120565,84,120623,84,120681,84,120739,84,11430,84,5026,84,42196,84,93962,84,71868,84,66199,84,66225,84,66325,84,119854,117,119906,117,119958,117,120010,117,120062,117,120114,117,120166,117,120218,117,120270,117,120322,117,120374,117,120426,117,120478,117,42911,117,7452,117,43854,117,43858,117,651,117,965,117,120534,117,120592,117,120650,117,120708,117,120766,117,1405,117,66806,117,71896,117,8746,85,8899,85,117994,85,119828,85,119880,85,119932,85,119984,85,120036,85,120088,85,120140,85,120192,85,120244,85,120296,85,120348,85,120400,85,120452,85,1357,85,4608,85,66766,85,5196,85,42228,85,94018,85,71864,85,8744,118,8897,118,65366,118,8564,118,119855,118,119907,118,119959,118,120011,118,120063,118,120115,118,120167,118,120219,118,120271,118,120323,118,120375,118,120427,118,120479,118,7456,118,957,118,120526,118,120584,118,120642,118,120700,118,120758,118,1141,118,1496,118,71430,118,43945,118,71872,118,119309,86,1639,86,1783,86,8548,86,117995,86,119829,86,119881,86,119933,86,119985,86,120037,86,120089,86,120141,86,120193,86,120245,86,120297,86,120349,86,120401,86,120453,86,1140,86,11576,86,5081,86,5167,86,42719,86,42214,86,93960,86,71840,86,66845,86,623,119,119856,119,119908,119,119960,119,120012,119,120064,119,120116,119,120168,119,120220,119,120272,119,120324,119,120376,119,120428,119,120480,119,7457,119,1121,119,1309,119,1377,119,71434,119,71438,119,71439,119,43907,119,71910,87,71919,87,117996,87,119830,87,119882,87,119934,87,119986,87,120038,87,120090,87,120142,87,120194,87,120246,87,120298,87,120350,87,120402,87,120454,87,1308,87,5043,87,5076,87,42218,87,5742,120,10539,120,10540,120,10799,120,65368,120,8569,120,119857,120,119909,120,119961,120,120013,120,120065,120,120117,120,120169,120,120221,120,120273,120,120325,120,120377,120,120429,120,120481,120,5441,120,5501,120,5741,88,9587,88,66338,88,71916,88,65336,88,8553,88,117997,88,119831,88,119883,88,119935,88,119987,88,120039,88,120091,88,120143,88,120195,88,120247,88,120299,88,120351,88,120403,88,120455,88,42931,88,935,88,120510,88,120568,88,120626,88,120684,88,120742,88,11436,88,11613,88,5815,88,42219,88,66192,88,66228,88,66327,88,66855,88,611,121,7564,121,65369,121,119858,121,119910,121,119962,121,120014,121,120066,121,120118,121,120170,121,120222,121,120274,121,120326,121,120378,121,120430,121,120482,121,655,121,7935,121,43866,121,947,121,8509,121,120516,121,120574,121,120632,121,120690,121,120748,121,1199,121,4327,121,71900,121,65337,89,117998,89,119832,89,119884,89,119936,89,119988,89,120040,89,120092,89,120144,89,120196,89,120248,89,120300,89,120352,89,120404,89,120456,89,933,89,978,89,120508,89,120566,89,120624,89,120682,89,120740,89,11432,89,1198,89,5033,89,5053,89,42220,89,94019,89,71844,89,66226,89,119859,122,119911,122,119963,122,120015,122,120067,122,120119,122,120171,122,120223,122,120275,122,120327,122,120379,122,120431,122,120483,122,7458,122,43923,122,71876,122,71909,90,66293,90,65338,90,8484,90,8488,90,117999,90,119833,90,119885,90,119937,90,119989,90,120041,90,120197,90,120249,90,120301,90,120353,90,120405,90,120457,90,918,90,120493,90,120551,90,120609,90,120667,90,120725,90,5059,90,42204,90,71849,90,65282,34,65283,35,65284,36,65285,37,65286,38,65290,42,65291,43,65294,46,65295,47,65296,48,65298,50,65299,51,65300,52,65301,53,65302,54,65303,55,65304,56,65305,57,65308,60,65309,61,65310,62,65312,64,65316,68,65318,70,65319,71,65324,76,65329,81,65330,82,65333,85,65334,86,65335,87,65343,95,65346,98,65348,100,65350,102,65355,107,65357,109,65358,110,65361,113,65362,114,65364,116,65365,117,65367,119,65370,122,65371,123,65373,125,119846,109],"_default":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"cs":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"de":[65374,126,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"es":[8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"fr":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"it":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"ja":[8211,45,8218,44,65281,33,8216,96,8245,96,180,96,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65292,44,65297,49,65307,59],"ko":[8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"pl":[65374,126,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"pt-BR":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"qps-ploc":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"ru":[65374,126,8218,44,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,305,105,921,73,1009,112,215,120,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"tr":[160,32,8211,45,65374,126,8218,44,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41,65292,44,65297,49,65307,59,65311,63],"zh-hans":[160,32,65374,126,8218,44,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65297,49],"zh-hant":[8211,45,65374,126,8218,44,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89]}'))}static{this.cache=new Ai(t=>{let e=t.split(",");function n(u){let p=new Map;for(let h=0;h<u.length;h+=2)p.set(u[h],u[h+1]);return p}function i(u,p){let h=new Map(u);for(let[v,g]of p)h.set(v,g);return h}function o(u,p){if(!u)return p;let h=new Map;for(let[v,g]of u)p.has(v)&&h.set(v,g);return h}let s=this.ambiguousCharacterData.value,a=e.filter(u=>!u.startsWith("_")&&Object.hasOwn(s,u));a.length===0&&(a=["_default"]);let l;for(let u of a){let p=n(s[u]);l=o(l,p)}let c=n(s._common),d=i(c,l);return new r(d)})}static getInstance(t){return r.cache.get(Array.from(t).join(","))}static{this._locales=new Oe(()=>Object.keys(r.ambiguousCharacterData.value).filter(t=>!t.startsWith("_")))}static getLocales(){return r._locales.value}isAmbiguous(t){return this.confusableDictionary.has(t)}containsAmbiguousCharacter(t){for(let e=0;e<t.length;e++){let n=t.codePointAt(e);if(typeof n=="number"&&this.isAmbiguous(n))return!0}return!1}getPrimaryConfusable(t){return this.confusableDictionary.get(t)}getConfusableCodePoints(){return new Set(this.confusableDictionary.keys())}},Ec=class r{static getRawData(){return JSON.parse('{"_common":[11,12,13,127,847,1564,4447,4448,6068,6069,6155,6156,6157,6158,7355,7356,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8204,8205,8206,8207,8234,8235,8236,8237,8238,8239,8287,8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,10240,12644,65024,65025,65026,65027,65028,65029,65030,65031,65032,65033,65034,65035,65036,65037,65038,65039,65279,65440,65520,65521,65522,65523,65524,65525,65526,65527,65528,65532,78844,119155,119156,119157,119158,119159,119160,119161,119162,917504,917505,917506,917507,917508,917509,917510,917511,917512,917513,917514,917515,917516,917517,917518,917519,917520,917521,917522,917523,917524,917525,917526,917527,917528,917529,917530,917531,917532,917533,917534,917535,917536,917537,917538,917539,917540,917541,917542,917543,917544,917545,917546,917547,917548,917549,917550,917551,917552,917553,917554,917555,917556,917557,917558,917559,917560,917561,917562,917563,917564,917565,917566,917567,917568,917569,917570,917571,917572,917573,917574,917575,917576,917577,917578,917579,917580,917581,917582,917583,917584,917585,917586,917587,917588,917589,917590,917591,917592,917593,917594,917595,917596,917597,917598,917599,917600,917601,917602,917603,917604,917605,917606,917607,917608,917609,917610,917611,917612,917613,917614,917615,917616,917617,917618,917619,917620,917621,917622,917623,917624,917625,917626,917627,917628,917629,917630,917631,917760,917761,917762,917763,917764,917765,917766,917767,917768,917769,917770,917771,917772,917773,917774,917775,917776,917777,917778,917779,917780,917781,917782,917783,917784,917785,917786,917787,917788,917789,917790,917791,917792,917793,917794,917795,917796,917797,917798,917799,917800,917801,917802,917803,917804,917805,917806,917807,917808,917809,917810,917811,917812,917813,917814,917815,917816,917817,917818,917819,917820,917821,917822,917823,917824,917825,917826,917827,917828,917829,917830,917831,917832,917833,917834,917835,917836,917837,917838,917839,917840,917841,917842,917843,917844,917845,917846,917847,917848,917849,917850,917851,917852,917853,917854,917855,917856,917857,917858,917859,917860,917861,917862,917863,917864,917865,917866,917867,917868,917869,917870,917871,917872,917873,917874,917875,917876,917877,917878,917879,917880,917881,917882,917883,917884,917885,917886,917887,917888,917889,917890,917891,917892,917893,917894,917895,917896,917897,917898,917899,917900,917901,917902,917903,917904,917905,917906,917907,917908,917909,917910,917911,917912,917913,917914,917915,917916,917917,917918,917919,917920,917921,917922,917923,917924,917925,917926,917927,917928,917929,917930,917931,917932,917933,917934,917935,917936,917937,917938,917939,917940,917941,917942,917943,917944,917945,917946,917947,917948,917949,917950,917951,917952,917953,917954,917955,917956,917957,917958,917959,917960,917961,917962,917963,917964,917965,917966,917967,917968,917969,917970,917971,917972,917973,917974,917975,917976,917977,917978,917979,917980,917981,917982,917983,917984,917985,917986,917987,917988,917989,917990,917991,917992,917993,917994,917995,917996,917997,917998,917999],"cs":[173,8203,12288],"de":[173,8203,12288],"es":[8203,12288],"fr":[173,8203,12288],"it":[160,173,12288],"ja":[173],"ko":[173,12288],"pl":[173,8203,12288],"pt-BR":[173,8203,12288],"qps-ploc":[160,173,8203,12288],"ru":[173,12288],"tr":[160,173,8203,12288],"zh-hans":[160,173,8203,12288],"zh-hant":[173,12288]}')}static{this._data=void 0}static getData(){return this._data||(this._data=new Set([...Object.values(r.getRawData())].flat())),this._data}static isInvisibleCharacter(t){return r.getData().has(t)}static containsInvisibleCharacter(t){for(let e=0;e<t.length;e++){let n=t.codePointAt(e);if(typeof n=="number"&&(r.isInvisibleCharacter(n)||n===32))return!0}return!1}static get codePoints(){return r.getData()}};function Ut(r){return r===47||r===92}function Di(r){return r.replace(/[\\/]/g,q.sep)}function Lc(r){return r.indexOf("/")===-1&&(r=Di(r)),/^[a-zA-Z]:(\/|$)/.test(r)&&(r="/"+r),r}function Ks(r,t=q.sep){if(!r)return"";let e=r.length,n=r.charCodeAt(0);if(Ut(n)){if(Ut(r.charCodeAt(1))&&!Ut(r.charCodeAt(2))){let o=3,s=o;for(;o<e&&!Ut(r.charCodeAt(o));o++);if(s!==o&&!Ut(r.charCodeAt(o+1))){for(o+=1;o<e;o++)if(Ut(r.charCodeAt(o)))return r.slice(0,o+1).replace(/[\\/]/g,t)}}return t}else if(Fc(n)&&r.charCodeAt(1)===58)return Ut(r.charCodeAt(2))?r.slice(0,2)+t:r.slice(0,2);let i=r.indexOf("://");if(i!==-1){for(i+=3;i<e;i++)if(Ut(r.charCodeAt(i)))return r.slice(0,i+1)}return""}function kn(r,t,e){let n=r===t;return!e||n?n:!r||!t?!1:rn(r,t)}function bt(r,t,e,n=ue){if(r===t)return!0;if(!r||!t||t.length>r.length)return!1;if(e){if(!An(r,t))return!1;if(t.length===r.length)return!0;let o=t.length;return t.charAt(t.length-1)===n&&o--,r.charAt(o)===n}return t.charAt(t.length-1)!==n&&(t+=n),r.indexOf(t)===0}function Fc(r){return r>=65&&r<=90||r>=97&&r<=122}function Uc(r){return H?(r=Pn(r,ue),r.endsWith(":")&&(r+=ue)):(r=Pn(r,ue),r||(r=ue)),r}function js(r){let t=je(r);return H?r.length>3?!1:Nc(t)&&(r.length===2||t.charCodeAt(2)===92):t===q.sep}function Nc(r,t=H){return t?Fc(r.charCodeAt(0))&&r.charCodeAt(1)===58:!1}var ff="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",hf="BDEFGHIJKMOQRSTUVWXYZbdefghijkmoqrstuvwxyz0123456789";function Mc(r,t,e=8){let n="";for(let o=0;o<e;o++){let s;o===0&&H&&!t&&(e===3||e===4)?s=hf:s=ff,n+=s.charAt(Math.floor(Math.random()*s.length))}let i;return t?i=`${t}-${n}`:i=n,r?W(r,i):i}var mf=/^\w[\w\d+.-]*$/,vf=/^\//,yf=/^\/\//;function bf(r,t){if(!r.scheme&&t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${r.authority}", path: "${r.path}", query: "${r.query}", fragment: "${r.fragment}"}`);if(r.scheme&&!mf.test(r.scheme)){let e=[...r.scheme.matchAll(/[^\w\d+.-]/gu)],n=e.length>0?` Found '${e[0][0]}' at index ${e[0].index} (${e.length} total)`:"";throw new Error(`[UriError]: Scheme contains illegal characters.${n} (len:${r.scheme.length})`)}if(r.path){if(r.authority){if(!vf.test(r.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(yf.test(r.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}}function If(r,t){return!r&&!t?"file":r}function Tf(r,t){switch(r){case"https":case"http":case"file":t?t[0]!==Ye&&(t=Ye+t):t=Ye;break}return t}var Y="",Ye="/",Sf=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,m=class r{static isUri(t){return t instanceof r?!0:!t||typeof t!="object"?!1:typeof t.authority=="string"&&typeof t.fragment=="string"&&typeof t.path=="string"&&typeof t.query=="string"&&typeof t.scheme=="string"&&typeof t.fsPath=="string"&&typeof t.with=="function"&&typeof t.toString=="function"}constructor(t,e,n,i,o,s=!1){typeof t=="object"?(this.scheme=t.scheme||Y,this.authority=t.authority||Y,this.path=t.path||Y,this.query=t.query||Y,this.fragment=t.fragment||Y):(this.scheme=If(t,s),this.authority=e||Y,this.path=Tf(this.scheme,n||Y),this.query=i||Y,this.fragment=o||Y,bf(this,s))}get fsPath(){return Ar(this,!1)}with(t){if(!t)return this;let{scheme:e,authority:n,path:i,query:o,fragment:s}=t;return e===void 0?e=this.scheme:e===null&&(e=Y),n===void 0?n=this.authority:n===null&&(n=Y),i===void 0?i=this.path:i===null&&(i=Y),o===void 0?o=this.query:o===null&&(o=Y),s===void 0?s=this.fragment:s===null&&(s=Y),e===this.scheme&&n===this.authority&&i===this.path&&o===this.query&&s===this.fragment?this:new Nt(e,n,i,o,s)}static parse(t,e=!1){let n=Sf.exec(t);return n?new Nt(n[2]||Y,Oi(n[4]||Y),Oi(n[5]||Y),Oi(n[7]||Y),Oi(n[9]||Y),e):new Nt(Y,Y,Y,Y,Y)}static file(t){let e=Y;if(H&&(t=t.replace(/\\/g,Ye)),t[0]===Ye&&t[1]===Ye){let n=t.indexOf(Ye,2);n===-1?(e=t.substring(2),t=Ye):(e=t.substring(2,n),t=t.substring(n)||Ye)}return new Nt("file",e,t,Y,Y)}static from(t,e){return new Nt(t.scheme,t.authority,t.path,t.query,t.fragment,e)}static joinPath(t,...e){if(!t.path)throw new Error("[UriError]: cannot call joinPath on URI without path");let n;return H&&t.scheme==="file"?n=r.file(se.join(Ar(t,!0),...e)).path:n=q.join(t.path,...e),t.with({path:n})}toString(t=!1){return zs(this,t)}toJSON(){return this}static revive(t){if(t){if(t instanceof r)return t;{let e=new Nt(t);return e._formatted=t.external??null,e._fsPath=t._sep===Vc?t.fsPath??null:null,e}}else return t}[Symbol.for("debug.description")](){return`URI(${this.toString()})`}};var Vc=H?1:void 0,Nt=class extends m{constructor(){super(...arguments);this._formatted=null;this._fsPath=null}get fsPath(){return this._fsPath||(this._fsPath=Ar(this,!1)),this._fsPath}toString(e=!1){return e?zs(this,!0):(this._formatted||(this._formatted=zs(this,!1)),this._formatted)}toJSON(){let e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath,e._sep=Vc),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e}},$c={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function Wc(r,t,e){let n,i=-1;for(let o=0;o<r.length;o++){let s=r.charCodeAt(o);if(s>=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||s===45||s===46||s===95||s===126||t&&s===47||e&&s===91||e&&s===93||e&&s===58)i!==-1&&(n+=encodeURIComponent(r.substring(i,o)),i=-1),n!==void 0&&(n+=r.charAt(o));else{n===void 0&&(n=r.substr(0,o));let a=$c[s];a!==void 0?(i!==-1&&(n+=encodeURIComponent(r.substring(i,o)),i=-1),n+=a):i===-1&&(i=o)}}return i!==-1&&(n+=encodeURIComponent(r.substring(i))),n!==void 0?n:r}function _f(r){let t;for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);n===35||n===63?(t===void 0&&(t=r.substr(0,e)),t+=$c[n]):t!==void 0&&(t+=r[e])}return t!==void 0?t:r}function Ar(r,t){let e;return r.authority&&r.path.length>1&&r.scheme==="file"?e=`//${r.authority}${r.path}`:r.path.charCodeAt(0)===47&&(r.path.charCodeAt(1)>=65&&r.path.charCodeAt(1)<=90||r.path.charCodeAt(1)>=97&&r.path.charCodeAt(1)<=122)&&r.path.charCodeAt(2)===58?t?e=r.path.substr(1):e=r.path[1].toLowerCase()+r.path.substr(2):e=r.path,H&&(e=e.replace(/\//g,"\\")),e}function zs(r,t){let e=t?_f:Wc,n="",{scheme:i,authority:o,path:s,query:a,fragment:l}=r;if(i&&(n+=i,n+=":"),(o||i==="file")&&(n+=Ye,n+=Ye),o){let c=o.indexOf("@");if(c!==-1){let d=o.substr(0,c);o=o.substr(c+1),c=d.lastIndexOf(":"),c===-1?n+=e(d,!1,!1):(n+=e(d.substr(0,c),!1,!1),n+=":",n+=e(d.substr(c+1),!1,!0)),n+="@"}o=o.toLowerCase(),c=o.lastIndexOf(":"),c===-1?n+=e(o,!1,!0):(n+=e(o.substr(0,c),!1,!0),n+=o.substr(c))}if(s){if(s.length>=3&&s.charCodeAt(0)===47&&s.charCodeAt(2)===58){let c=s.charCodeAt(1);c>=65&&c<=90&&(s=`/${String.fromCharCode(c+32)}:${s.substr(3)}`)}else if(s.length>=2&&s.charCodeAt(1)===58){let c=s.charCodeAt(0);c>=65&&c<=90&&(s=`${String.fromCharCode(c+32)}:${s.substr(2)}`)}n+=e(s,!0,!1)}return a&&(n+="?",n+=e(a,!1,!1)),l&&(n+="#",n+=t?l:Wc(l,!1,!1)),n}function Kc(r){try{return decodeURIComponent(r)}catch{return r.length>3?r.substr(0,3)+Kc(r.substr(3)):r}}var Bc=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function Oi(r){return r.match(Bc)?r.replace(Bc,t=>Kc(t)):r}var ee;(U=>(U.inMemory="inmemory",U.vscode="vscode",U.internal="private",U.walkThrough="walkThrough",U.walkThroughSnippet="walkThroughSnippet",U.http="http",U.https="https",U.file="file",U.mailto="mailto",U.untitled="untitled",U.data="data",U.command="command",U.vscodeRemote="vscode-remote",U.vscodeRemoteResource="vscode-remote-resource",U.vscodeManagedRemoteResource="vscode-managed-remote-resource",U.vscodeUserData="vscode-userdata",U.vscodeCustomEditor="vscode-custom-editor",U.vscodeNotebookCell="vscode-notebook-cell",U.vscodeNotebookCellMetadata="vscode-notebook-cell-metadata",U.vscodeNotebookCellMetadataDiff="vscode-notebook-cell-metadata-diff",U.vscodeNotebookCellOutput="vscode-notebook-cell-output",U.vscodeNotebookCellOutputDiff="vscode-notebook-cell-output-diff",U.vscodeNotebookMetadata="vscode-notebook-metadata",U.vscodeInteractiveInput="vscode-interactive-input",U.vscodeSettings="vscode-settings",U.vscodeWorkspaceTrust="vscode-workspace-trust",U.vscodeTerminal="vscode-terminal",U.vscodeImageCarousel="vscode-image-carousel",U.vscodeChatCodeBlock="vscode-chat-code-block",U.vscodeChatCodeCompareBlock="vscode-chat-code-compare-block",U.vscodeChatEditor="vscode-chat-editor",U.vscodeChatInput="chatSessionInput",U.vscodeLocalChatSession="vscode-chat-session",U.webviewPanel="webview-panel",U.vscodeWebview="vscode-webview",U.vscodeBrowser="vscode-browser",U.extension="extension",U.vscodeFileResource="vscode-file",U.tmp="tmp",U.vsls="vsls",U.vscodeSourceControl="vscode-scm",U.commentsInput="comment",U.codeSetting="code-setting",U.outputChannel="output",U.accessibleView="accessible-view",U.chatEditingSnapshotScheme="chat-editing-snapshot-text-model",U.chatEditingModel="chat-editing-text-model",U.copilotPr="copilot-pr"))(ee||={});var Js="tkn",Hs=class{constructor(){this._hosts=Object.create(null);this._ports=Object.create(null);this._connectionTokens=Object.create(null);this._preferredWebSchema="http";this._delegate=null;this._serverRootPath="/"}setPreferredWebSchema(t){this._preferredWebSchema=t}setDelegate(t){this._delegate=t}setServerRootPath(t,e){this._serverRootPath=q.join(e??"/",Rf(t))}getServerRootPath(){return this._serverRootPath}get _remoteResourcesPath(){return q.join(this._serverRootPath,ee.vscodeRemoteResource)}set(t,e,n){this._hosts[t]=e,this._ports[t]=n}setConnectionToken(t,e){this._connectionTokens[t]=e}getPreferredWebSchema(){return this._preferredWebSchema}rewrite(t){if(this._delegate)try{return this._delegate(t)}catch(a){return oe(a),t}let e=t.authority,n=this._hosts[e];n&&n.indexOf(":")!==-1&&n.indexOf("[")===-1&&(n=`[${n}]`);let i=this._ports[e],o=this._connectionTokens[e],s=`path=${encodeURIComponent(t.path)}`;return typeof o=="string"&&(s+=`&${Js}=${encodeURIComponent(o)}`),m.from({scheme:_n?this._preferredWebSchema:ee.vscodeRemoteResource,authority:`${n}:${i}`,path:this._remoteResourcesPath,query:s})}},xf=new Hs;function Rf(r){return`${r.quality??"oss"}-${r.commit??"dev"}`}var Ef="vscode-app",Gs=class r{static{this.FALLBACK_AUTHORITY=Ef}asBrowserUri(t){let e=this.toUri(t);return this.uriToBrowserUri(e)}uriToBrowserUri(t){return t.scheme===ee.vscodeRemote?xf.rewrite(t):t.scheme===ee.file&&(oc||sc===`${ee.vscodeFileResource}://${r.FALLBACK_AUTHORITY}`)?t.with({scheme:ee.vscodeFileResource,authority:t.authority||r.FALLBACK_AUTHORITY,query:null,fragment:null}):t}asFileUri(t){let e=this.toUri(t);return this.uriToFileUri(e)}uriToFileUri(t){return t.scheme===ee.vscodeFileResource?t.with({scheme:ee.file,authority:t.authority!==r.FALLBACK_AUTHORITY?t.authority:null,query:null,fragment:null}):t}toUri(t){if(m.isUri(t))return t;if(globalThis._VSCODE_FILE_ROOT){let e=globalThis._VSCODE_FILE_ROOT;if(/^\w[\w\d+.-]*:\/\//.test(e))return m.joinPath(m.parse(e,!0),t);let n=W(e,t);return m.file(n)}throw new Error("Cannot determine URI for module id!")}},lt=new Gs,rv=Object.freeze({"Cache-Control":"no-cache, no-store"}),iv=Object.freeze({"Document-Policy":"include-js-call-stacks-in-crash-reports"}),wf;(o=>{let r=new Map([["1",{"Cross-Origin-Opener-Policy":"same-origin"}],["2",{"Cross-Origin-Embedder-Policy":"require-corp"}],["3",{"Cross-Origin-Opener-Policy":"same-origin","Cross-Origin-Embedder-Policy":"require-corp"}]]);o.CoopAndCoep=Object.freeze(r.get("3"));let e="vscode-coi";function n(s){let a;typeof s=="string"?a=new URL(s).searchParams:s instanceof URL?a=s.searchParams:m.isUri(s)&&(a=new URL(s.toString(!0)).searchParams);let l=a?.get(e);if(l)return r.get(l)}o.getHeadersFromQuery=n;function i(s,a,l){if(!globalThis.crossOriginIsolated)return;let c=a&&l?"3":l?"2":"1";s instanceof URLSearchParams?s.set(e,c):s[e]=c}o.addSearchParam=i})(wf||={});function It(r){return Ar(r,!0)}var kr=class{constructor(t){this._ignorePathCasing=t}compare(t,e,n=!1){return t===e?0:Pr(this.getComparisonKey(t,n),this.getComparisonKey(e,n))}isEqual(t,e,n=!1){return t===e?!0:!t||!e?!1:this.getComparisonKey(t,n)===this.getComparisonKey(e,n)}getComparisonKey(t,e=!1){return t.with({path:this._ignorePathCasing(t)?t.path.toLowerCase():void 0,fragment:e?null:void 0}).toString()}ignorePathCasing(t){return this._ignorePathCasing(t)}isEqualOrParent(t,e,n=!1){if(t.scheme===e.scheme){if(t.scheme===ee.file)return bt(It(t),It(e),this._ignorePathCasing(t))&&t.query===e.query&&(n||t.fragment===e.fragment);if(jc(t.authority,e.authority))return bt(t.path,e.path,this._ignorePathCasing(t),"/")&&t.query===e.query&&(n||t.fragment===e.fragment)}return!1}joinPath(t,...e){return m.joinPath(t,...e)}basenameOrAuthority(t){return Xe(t)||t.authority}basename(t,e){return q.basename(t.path,e)}extname(t){return q.extname(t.path)}dirname(t){if(t.path.length===0)return t;let e;return t.scheme===ee.file?e=m.file(he(It(t))).path:(e=q.dirname(t.path),t.authority&&e.length&&e.charCodeAt(0)!==47&&(console.error(`dirname("${t.toString})) resulted in a relative path`),e="/")),t.with({path:e})}normalizePath(t){if(!t.path.length)return t;let e;return t.scheme===ee.file?e=m.file(je(It(t))).path:e=q.normalize(t.path),t.with({path:e})}relativePath(t,e){if(t.scheme!==e.scheme||!jc(t.authority,e.authority))return;if(t.scheme===ee.file){let o=Tc(It(t),It(e));return H?Di(o):o}let n=t.path||"/",i=e.path||"/";if(this._ignorePathCasing(t)){let o=0;for(let s=Math.min(n.length,i.length);o<s&&!(n.charCodeAt(o)!==i.charCodeAt(o)&&n.charAt(o).toLowerCase()!==i.charAt(o).toLowerCase());o++);n=i.substr(0,o)+n.substr(o)}return q.relative(n,i)}resolvePath(t,e){if(t.scheme===ee.file){let n=m.file(en(It(t),e));return t.with({authority:n.authority,path:n.path})}return e=Lc(e),t.with({path:q.resolve(t.path,e)})}isAbsolutePath(t){return!!t.path&&t.path[0]==="/"}isEqualAuthority(t,e){return t===e||t!==void 0&&e!==void 0&&rn(t,e)}hasTrailingPathSeparator(t,e=ue){if(t.scheme===ee.file){let n=It(t);return n.length>Ks(n).length&&n[n.length-1]===e}else{let n=t.path;return n.length>1&&n.charCodeAt(n.length-1)===47&&!/^[a-zA-Z]:(\/$|\\$)/.test(t.fsPath)}}removeTrailingPathSeparator(t,e=ue){return zc(t,e)?t.with({path:t.path.substr(0,t.path.length-1)}):t}addTrailingPathSeparator(t,e=ue){let n=!1;if(t.scheme===ee.file){let i=It(t);n=i!==void 0&&i.length===Ks(i).length&&i[i.length-1]===e}else{e="/";let i=t.path;n=i.length===1&&i.charCodeAt(i.length-1)===47}return!n&&!zc(t,e)?t.with({path:t.path+"/"}):t}},V=new kr(()=>!1),Mt=new kr(r=>r.scheme===ee.file?!le:!0),Qs=new kr(r=>!0),dv=V.isEqual.bind(V),Hc=V.isEqualOrParent.bind(V),pv=V.getComparisonKey.bind(V),fv=V.basenameOrAuthority.bind(V),Xe=V.basename.bind(V),Ys=V.extname.bind(V),Li=V.dirname.bind(V),G=V.joinPath.bind(V),Dn=V.normalizePath.bind(V),hv=V.relativePath.bind(V),gv=V.resolvePath.bind(V),Gc=V.isAbsolutePath.bind(V),jc=V.isEqualAuthority.bind(V),zc=V.hasTrailingPathSeparator.bind(V),mv=V.removeTrailingPathSeparator.bind(V),vv=V.addTrailingPathSeparator.bind(V);var Cf;(o=>{o.META_DATA_LABEL="label",o.META_DATA_DESCRIPTION="description",o.META_DATA_SIZE="size",o.META_DATA_MIME="mime";function i(s){let a=new Map;s.path.substring(s.path.indexOf(";")+1,s.path.lastIndexOf(";")).split(";").forEach(d=>{let[u,p]=d.split(":");u&&p&&a.set(u,p)});let c=s.path.substring(0,s.path.indexOf(";"));return c&&a.set(o.META_DATA_MIME,c),a}o.parseMetaData=i})(Cf||={});var Jc=Symbol("MicrotaskDelay");function Bi(r){return!!r&&typeof r.then=="function"}function Fn(r){let t=new fe,e=r(t.token),n=!1,i=new Promise((o,s)=>{let a=t.token.onCancellationRequested(()=>{n=!0,a.dispose(),s(new Ie)});Promise.resolve(e).then(l=>{a.dispose(),t.dispose(),n?Si(l)&&l.dispose():o(l)},l=>{a.dispose(),t.dispose(),s(l)})});return new class{cancel(){t.cancel(),t.dispose()}then(o,s){return i.then(o,s)}catch(o){return this.then(void 0,o)}finally(o){return i.finally(o)}}}var Xs=class{constructor(){this.activePromise=null,this.queuedPromise=null,this.queuedPromiseFactory=null,this.cancellationTokenSource=new fe}queue(t){if(this.cancellationTokenSource.token.isCancellationRequested)return Promise.reject(new Error("Throttler is disposed"));if(this.activePromise){if(this.queuedPromiseFactory=t,!this.queuedPromise){let e=()=>{if(this.queuedPromise=null,this.cancellationTokenSource.token.isCancellationRequested)return;let n=this.queue(this.queuedPromiseFactory);return this.queuedPromiseFactory=null,n};this.queuedPromise=new Promise(n=>{this.activePromise.then(e,e).then(n)})}return new Promise((e,n)=>{this.queuedPromise.then(e,n)})}return this.activePromise=t(this.cancellationTokenSource.token),new Promise((e,n)=>{this.activePromise.then(i=>{this.activePromise=null,e(i)},i=>{this.activePromise=null,n(i)})})}dispose(){this.cancellationTokenSource.cancel()}};var Wt=class{constructor(){this.promiseMap=new Map}queue(t,e){let i=(this.promiseMap.get(t)??Promise.resolve()).catch(()=>{}).then(e).finally(()=>{this.promiseMap.get(t)===i&&this.promiseMap.delete(t)});return this.promiseMap.set(t,i),i}peek(t){return this.promiseMap.get(t)||void 0}keys(){return this.promiseMap.keys()}},Pf=(r,t)=>{let e=!0,n=setTimeout(()=>{e=!1,t()},r);return{isTriggered:()=>e,dispose:()=>{clearTimeout(n),e=!1}}},Af=r=>{let t=!0;return queueMicrotask(()=>{t&&(t=!1,r())}),{isTriggered:()=>t,dispose:()=>{t=!1}}},Dr=class{constructor(t){this.defaultDelay=t;this.deferred=null,this.completionPromise=null,this.doResolve=null,this.doReject=null,this.task=null}trigger(t,e=this.defaultDelay){this.task=t,this.cancelTimeout(),this.completionPromise||(this.completionPromise=new Promise((i,o)=>{this.doResolve=i,this.doReject=o}).then(()=>{if(this.completionPromise=null,this.doResolve=null,this.task){let i=this.task;return this.task=null,i()}}));let n=()=>{this.deferred=null,this.doResolve?.(null)};return this.deferred=e===Jc?Af(n):Pf(e,n),this.completionPromise}isTriggered(){return!!this.deferred?.isTriggered()}cancel(){this.cancelTimeout(),this.completionPromise&&(this.doReject?.(new Ie),this.completionPromise=null)}cancelTimeout(){this.deferred?.dispose(),this.deferred=null}dispose(){this.cancel()}},on=class{constructor(t){this.delayer=new Dr(t),this.throttler=new Xs}trigger(t,e){return this.delayer.trigger(()=>this.throttler.queue(t),e)}isTriggered(){return this.delayer.isTriggered()}cancel(){this.delayer.cancel()}dispose(){this.delayer.dispose(),this.throttler.dispose()}},Ui=class{constructor(){this._isOpen=!1,this._promise=new Promise((t,e)=>{this._completePromise=t})}isOpen(){return this._isOpen}open(){this._isOpen=!0,this._completePromise(!0)}wait(){return this._promise}};function sn(r,t){return t?new Promise((e,n)=>{let i=setTimeout(()=>{o.dispose(),e()},r),o=t.onCancellationRequested(()=>{clearTimeout(i),o.dispose(),n(new Ie)})}):Fn(e=>sn(r,e))}var Zs=class{constructor(t){this._size=0;this._isDisposed=!1;this.maxDegreeOfParalellism=t,this.outstandingPromises=[],this.runningPromises=0,this._onDrained=new b}whenIdle(){return this.size>0?z.toPromise(this.onDrained):Promise.resolve()}get onDrained(){return this._onDrained.event}get size(){return this._size}queue(t){if(this._isDisposed)throw new Error("Object has been disposed");return this._size++,new Promise((e,n)=>{this.outstandingPromises.push({factory:t,c:e,e:n}),this.consume()})}consume(){for(;this.outstandingPromises.length&&this.runningPromises<this.maxDegreeOfParalellism;){let t=this.outstandingPromises.shift();this.runningPromises++;let e=t.factory();e.then(t.c,t.e),e.then(()=>this.consumed(),()=>this.consumed())}}consumed(){this._isDisposed||(this.runningPromises--,--this._size===0&&this._onDrained.fire(),this.outstandingPromises.length>0&&this.consume())}clear(){if(this._isDisposed)throw new Error("Object has been disposed");this.outstandingPromises.length=0,this._size=this.runningPromises}dispose(){this._isDisposed=!0,this.outstandingPromises.length=0,this._size=0,this._onDrained.dispose()}},ea=class extends Zs{constructor(){super(1)}};var On=class{constructor(){this.queues=new Map;this.drainers=new Set;this.drainListeners=void 0;this.drainListenerCount=0}async whenDrained(){if(this.isDrained())return;let t=new He;return this.drainers.add(t),t.p}isDrained(){for(let[,t]of this.queues)if(t.size>0)return!1;return!0}queueSize(t,e=V){let n=e.getComparisonKey(t);return this.queues.get(n)?.size??0}queueFor(t,e,n=V){let i=n.getComparisonKey(t),o=this.queues.get(i);if(!o){o=new ea;let s=this.drainListenerCount++,a=z.once(o.onDrained)(()=>{o?.dispose(),this.queues.delete(i),this.onDidQueueDrain(),this.drainListeners?.deleteAndDispose(s),this.drainListeners?.size===0&&(this.drainListeners.dispose(),this.drainListeners=void 0)});this.drainListeners||(this.drainListeners=new st),this.drainListeners.set(s,a),this.queues.set(i,o)}return o.queue(e)}onDidQueueDrain(){this.isDrained()&&this.releaseDrainers()}releaseDrainers(){for(let t of this.drainers)t.complete();this.drainers.clear()}dispose(){for(let[,t]of this.queues)t.dispose();this.queues.clear(),this.releaseDrainers(),this.drainListeners?.dispose()}};var Ni=class{constructor(t,e){this.timeoutToken=void 0,this.runner=t,this.timeout=e,this.timeoutHandler=this.onTimeout.bind(this)}dispose(){this.cancel(),this.runner=null}cancel(){this.isScheduled()&&(clearTimeout(this.timeoutToken),this.timeoutToken=void 0)}schedule(t=this.timeout){this.cancel(),this.timeoutToken=setTimeout(this.timeoutHandler,t)}get delay(){return this.timeout}set delay(t){this.timeout=t}isScheduled(){return this.timeoutToken!==void 0}flush(){this.isScheduled()&&(this.cancel(),this.doRun())}onTimeout(){this.timeoutToken=void 0,this.runner&&this.doRun()}doRun(){this.runner?.()}};var Mi=class extends Ni{constructor(e,n){super(e,n);this.units=[]}work(e){this.units.push(e),this.isScheduled()||this.schedule()}doRun(){let e=this.units;this.units=[],this.runner?.(e)}dispose(){this.units=[],super.dispose()}},Ln=class extends A{constructor(e,n){super();this.options=e;this.handler=n;this.pendingWork=[];this.throttler=this._register(new kt);this.disposed=!1;this.lastExecutionTime=0}get pending(){return this.pendingWork.length}work(e){if(this.disposed)return!1;if(typeof this.options.maxBufferedWork=="number"){if(this.throttler.value){if(this.pending+e.length>this.options.maxBufferedWork)return!1}else if(this.pending+e.length-this.options.maxWorkChunkSize>this.options.maxBufferedWork)return!1}for(let i of e)this.pendingWork.push(i);let n=Date.now()-this.lastExecutionTime;return!this.throttler.value&&(!this.options.waitThrottleDelayBetweenWorkUnits||n>=this.options.throttleDelay)?this.doWork():!this.throttler.value&&this.options.waitThrottleDelayBetweenWorkUnits&&this.scheduleThrottler(Math.max(this.options.throttleDelay-n,0)),!0}doWork(){this.lastExecutionTime=Date.now(),this.handler(this.pendingWork.splice(0,this.options.maxWorkChunkSize)),this.pendingWork.length>0&&this.scheduleThrottler()}scheduleThrottler(e=this.options.throttleDelay){this.throttler.value=new Ni(()=>{this.throttler.clear(),this.doWork()},e),this.throttler.value.schedule()}dispose(){super.dispose(),this.pendingWork.length=0,this.disposed=!0}},kf,Fi;(function(){let r=globalThis;typeof r.requestIdleCallback!="function"||typeof r.cancelIdleCallback!="function"?Fi=(t,e,n)=>{ac(()=>{if(i)return;let o=Date.now()+15;e(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,o-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:Fi=(t,e,n)=>{let i=t.requestIdleCallback(e,typeof n=="number"?{timeout:n}:void 0),o=!1;return{dispose(){o||(o=!0,t.cancelIdleCallback(i))}}},kf=(t,e)=>Fi(globalThis,t,e)})();var ta=class{constructor(t,e){this._didRun=!1;this._executor=()=>{try{this._value=e()}catch(n){this._error=n}finally{this._didRun=!0}},this._handle=Fi(t,()=>this._executor())}dispose(){this._handle.dispose()}get value(){if(this._didRun||(this._handle.dispose(),this._executor()),this._error)throw this._error;return this._value}get isInitialized(){return this._didRun}},Wi=class extends ta{constructor(t){super(globalThis,t)}};async function Xc(r,t,e){let n;for(let i=0;i<e;i++)try{return await r()}catch(o){n=o,await sn(t)}throw n}var He=class r{static fromPromise(t){let e=new r;return e.settleWith(t),e}get isRejected(){return this.outcome?.outcome===1}get isResolved(){return this.outcome?.outcome===0}get isSettled(){return!!this.outcome}get value(){return this.outcome?.outcome===0?this.outcome?.value:void 0}constructor(){this.p=new Promise((t,e)=>{this.completeCallback=t,this.errorCallback=e})}complete(t){return this.isSettled?Promise.resolve():new Promise(e=>{this.completeCallback(t),this.outcome={outcome:0,value:t},e()})}error(t){return this.isSettled?Promise.resolve():new Promise(e=>{this.errorCallback(t),this.outcome={outcome:1,value:t},e()})}settleWith(t){return t.then(e=>this.complete(e),e=>this.error(e))}cancel(){return this.error(new Ie)}},an;(e=>{async function r(n){let i,o=await Promise.all(n.map(s=>s.then(a=>a,a=>{i||(i=a)})));if(typeof i<"u")throw i;return o}e.settled=r;function t(n){return new Promise(async(i,o)=>{try{await n(i,o)}catch(s){o(s)}})}e.withAsyncBody=t})(an||={});var Qc=class r{static fromArray(t){return new r(e=>{e.emitMany(t)})}static fromPromise(t){return new r(async e=>{e.emitMany(await t)})}static fromPromisesResolveOrder(t){return new r(async e=>{await Promise.all(t.map(async n=>e.emitOne(await n)))})}static merge(t){return new r(async e=>{await Promise.all(t.map(async n=>{for await(let i of n)e.emitOne(i)}))})}static{this.EMPTY=r.fromArray([])}constructor(t,e){this._state=0,this._results=[],this._error=null,this._onReturn=e,this._onStateChanged=new b,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await z.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,e){return new r(async n=>{for await(let i of t)n.emitOne(e(i))})}map(t){return r.map(this,t)}static filter(t,e){return new r(async n=>{for await(let i of t)e(i)&&n.emitOne(i)})}filter(t){return r.filter(this,t)}static coalesce(t){return r.filter(t,e=>!!e)}coalesce(){return r.coalesce(this)}static async toPromise(t){let e=[];for await(let n of t)e.push(n);return e}toPromise(){return r.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};var na=class{constructor(){this._unsatisfiedConsumers=[];this._unconsumedValues=[]}get hasFinalValue(){return!!this._finalValue}produce(t){if(this._ensureNoFinalValue(),this._unsatisfiedConsumers.length>0){let e=this._unsatisfiedConsumers.shift();this._resolveOrRejectDeferred(e,t)}else this._unconsumedValues.push(t)}produceFinal(t){this._ensureNoFinalValue(),this._finalValue=t;for(let e of this._unsatisfiedConsumers)this._resolveOrRejectDeferred(e,t);this._unsatisfiedConsumers.length=0}_ensureNoFinalValue(){if(this._finalValue)throw new X("ProducerConsumer: cannot produce after final value has been set")}_resolveOrRejectDeferred(t,e){e.ok?t.complete(e.value):t.error(e.error)}consume(){if(this._unconsumedValues.length>0||this._finalValue){let t=this._unconsumedValues.length>0?this._unconsumedValues.shift():this._finalValue;return t.ok?Promise.resolve(t.value):Promise.reject(t.error)}else{let t=new He;return this._unsatisfiedConsumers.push(t),t.p}}},Yc=class r{constructor(t,e){this._onReturn=e;this._producerConsumer=new na;this._iterator={next:()=>this._producerConsumer.consume(),return:()=>(this._onReturn?.(),Promise.resolve({done:!0,value:void 0})),throw:async t=>(this._finishError(t),{done:!0,value:void 0})};queueMicrotask(async()=>{let n=t({emitOne:i=>this._producerConsumer.produce({ok:!0,value:{done:!1,value:i}}),emitMany:i=>{for(let o of i)this._producerConsumer.produce({ok:!0,value:{done:!1,value:o}})},reject:i=>this._finishError(i)});if(!this._producerConsumer.hasFinalValue)try{await n,this._finishOk()}catch(i){this._finishError(i)}})}static fromArray(t){return new r(e=>{e.emitMany(t)})}static fromPromise(t){return new r(async e=>{e.emitMany(await t)})}static fromPromisesResolveOrder(t){return new r(async e=>{await Promise.all(t.map(async n=>e.emitOne(await n)))})}static merge(t){return new r(async e=>{await Promise.all(t.map(async n=>{for await(let i of n)e.emitOne(i)}))})}static{this.EMPTY=r.fromArray([])}static map(t,e){return new r(async n=>{for await(let i of t)n.emitOne(e(i))})}static tee(t){let e,n,i=new He,o=async()=>{if(!(!e||!n))try{for await(let l of t)e.emitOne(l),n.emitOne(l)}catch(l){e.reject(l),n.reject(l)}finally{i.complete()}},s=new r(async l=>(e=l,o(),i.p)),a=new r(async l=>(n=l,o(),i.p));return[s,a]}map(t){return r.map(this,t)}static coalesce(t){return r.filter(t,e=>!!e)}coalesce(){return r.coalesce(this)}static filter(t,e){return new r(async n=>{for await(let i of t)e(i)&&n.emitOne(i)})}filter(t){return r.filter(this,t)}_finishOk(){this._producerConsumer.hasFinalValue||this._producerConsumer.produceFinal({ok:!0,value:{done:!0,value:void 0}})}_finishError(t){this._producerConsumer.hasFinalValue||this._producerConsumer.produceFinal({ok:!1,error:t})}[Symbol.asyncIterator](){return this._iterator}};function Or(r){let t=r;return t?[t.on,t.pause,t.resume,t.destroy].every(e=>typeof e=="function"):!1}function qi(r){let t=r;return t?Or(t.stream)&&Array.isArray(t.buffer)&&typeof t.ended=="boolean":!1}function ln(r,t){return new ra(r,t)}var ra=class{constructor(t,e){this.reducer=t;this.options=e;this.state={flowing:!1,ended:!1,destroyed:!1};this.buffer={data:[],error:[]};this.listeners={data:[],error:[],end:[]};this.pendingWritePromises=[]}pause(){this.state.destroyed||(this.state.flowing=!1)}resume(){this.state.destroyed||this.state.flowing||(this.state.flowing=!0,this.flowData(),this.flowErrors(),this.flowEnd())}write(t){if(!this.state.destroyed){if(this.state.flowing)this.emitData(t);else if(this.buffer.data.push(t),typeof this.options?.highWaterMark=="number"&&this.buffer.data.length>this.options.highWaterMark)return new Promise(e=>this.pendingWritePromises.push(e))}}error(t){this.state.destroyed||(this.state.flowing?this.emitError(t):this.buffer.error.push(t))}end(t){this.state.destroyed||(typeof t<"u"&&this.write(t),this.state.flowing?(this.emitEnd(),this.destroy()):this.state.ended=!0)}emitData(t){this.listeners.data.slice(0).forEach(e=>e(t))}emitError(t){this.listeners.error.length===0?oe(t):this.listeners.error.slice(0).forEach(e=>e(t))}emitEnd(){this.listeners.end.slice(0).forEach(t=>t())}on(t,e){if(!this.state.destroyed)switch(t){case"data":this.listeners.data.push(e),this.resume();break;case"end":this.listeners.end.push(e),this.state.flowing&&this.flowEnd()&&this.destroy();break;case"error":this.listeners.error.push(e),this.state.flowing&&this.flowErrors();break}}removeListener(t,e){if(this.state.destroyed)return;let n;switch(t){case"data":n=this.listeners.data;break;case"end":n=this.listeners.end;break;case"error":n=this.listeners.error;break}if(n){let i=n.indexOf(e);i>=0&&n.splice(i,1)}}flowData(){if(this.buffer.data.length===0)return;if(typeof this.reducer=="function"){let e=this.reducer(this.buffer.data);this.emitData(e)}else for(let e of this.buffer.data)this.emitData(e);this.buffer.data.length=0;let t=[...this.pendingWritePromises];this.pendingWritePromises.length=0,t.forEach(e=>e())}flowErrors(){if(this.listeners.error.length>0){for(let t of this.buffer.error)this.emitError(t);this.buffer.error.length=0}}flowEnd(){return this.state.ended?(this.emitEnd(),this.listeners.end.length>0):!1}destroy(){this.state.destroyed||(this.state.destroyed=!0,this.state.ended=!0,this.buffer.data.length=0,this.buffer.error.length=0,this.listeners.data.length=0,this.listeners.error.length=0,this.listeners.end.length=0,this.pendingWritePromises.length=0)}};function Zc(r,t){let e=[],n;for(;(n=r.read())!==null;)e.push(n);return t(e)}function eu(r,t,e){let n=[],i;for(;(i=r.read())!==null&&n.length<e;)n.push(i);return i===null&&n.length>0?t(n):{read:()=>{if(n.length>0)return n.shift();if(typeof i<"u"){let o=i;return i=void 0,o}return r.read()}}}function Vi(r,t){return new Promise((e,n)=>{let i=[];$i(r,{onData:o=>{t&&i.push(o)},onError:o=>{t?n(o):e(void 0)},onEnd:()=>{e(t?t(i):void 0)}})})}function $i(r,t,e){r.on("error",n=>{e?.isCancellationRequested||t.onError(n)}),r.on("end",()=>{e?.isCancellationRequested||t.onEnd()}),r.on("data",n=>{e?.isCancellationRequested||t.onData(n)})}function tu(r,t){return new Promise((e,n)=>{let i=new N,o=[],s=c=>{if(o.push(c),o.length>t)return i.dispose(),r.pause(),e({stream:r,buffer:o,ended:!1})},a=c=>(i.dispose(),n(c)),l=()=>(i.dispose(),e({stream:r,buffer:o,ended:!0}));i.add(O(()=>r.removeListener("error",a))),r.on("error",a),i.add(O(()=>r.removeListener("end",l))),r.on("end",l),i.add(O(()=>r.removeListener("data",s))),r.on("data",s)})}function nu(r){let t=!1;return{read:()=>t?null:(t=!0,r)}}function ia(r,t,e){let n=ln(e);return $i(r,{onData:i=>n.write(t.data(i)),onError:i=>n.error(t.error?t.error(i):i),onEnd:()=>n.end()}),n}var Lr=typeof Buffer<"u",Of=new Oe(()=>new Uint8Array(256)),oa,sa,S=class r{static alloc(t){return Lr?new r(Buffer.allocUnsafe(t)):new r(new Uint8Array(t))}static wrap(t){return Lr&&!Buffer.isBuffer(t)&&(t=Buffer.from(t.buffer,t.byteOffset,t.byteLength)),new r(t)}static fromString(t,e){return!(e?.dontUseNodeBuffer||!1)&&Lr?new r(Buffer.from(t)):(oa||(oa=new TextEncoder),new r(oa.encode(t)))}static fromByteArray(t){let e=r.alloc(t.length);for(let n=0,i=t.length;n<i;n++)e.buffer[n]=t[n];return e}static concat(t,e){if(typeof e>"u"){e=0;for(let o=0,s=t.length;o<s;o++)e+=t[o].byteLength}let n=r.alloc(e),i=0;for(let o=0,s=t.length;o<s;o++){let a=t[o];n.set(a,i),i+=a.byteLength}return n}static isNativeBuffer(t){return Lr&&Buffer.isBuffer(t)}constructor(t){this.buffer=t,this.byteLength=this.buffer.byteLength}clone(){let t=r.alloc(this.byteLength);return t.set(this),t}toString(){return Lr?this.buffer.toString():(sa||(sa=new TextDecoder(void 0,{ignoreBOM:!0})),sa.decode(this.buffer))}slice(t,e){return new r(this.buffer.subarray(t,e))}set(t,e){if(t instanceof r)this.buffer.set(t.buffer,e);else if(t instanceof Uint8Array)this.buffer.set(t,e);else if(t instanceof ArrayBuffer)this.buffer.set(new Uint8Array(t),e);else if(ArrayBuffer.isView(t))this.buffer.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e);else throw new Error("Unknown argument 'array'")}readUInt32BE(t){return Ff(this.buffer,t)}writeUInt32BE(t,e){Uf(this.buffer,t,e)}readUInt32LE(t){return Nf(this.buffer,t)}writeUInt32LE(t,e){Mf(this.buffer,t,e)}readUInt8(t){return Wf(this.buffer,t)}writeUInt8(t,e){Bf(this.buffer,t,e)}indexOf(t,e=0){return Lf(this.buffer,t instanceof r?t.buffer:t,e)}equals(t){return this===t?!0:this.byteLength!==t.byteLength?!1:this.buffer.every((e,n)=>e===t.buffer[n])}};function Lf(r,t,e=0){let n=t.byteLength,i=r.byteLength;if(n===0)return 0;if(n===1)return r.indexOf(t[0],e);if(n>i-e)return-1;let o=Of.value;o.fill(t.length);for(let c=0;c<t.length;c++)o[t[c]]=t.length-c-1;let s=e+t.length-1,a=s,l=-1;for(;s<i;)if(r[s]===t[a]){if(a===0){l=s;break}s--,a--}else s+=Math.max(t.length-a,o[r[s]]),a=t.length-1;return l}function Ff(r,t){return r[t]*2**24+r[t+1]*2**16+r[t+2]*2**8+r[t+3]}function Uf(r,t,e){r[e+3]=t,t=t>>>8,r[e+2]=t,t=t>>>8,r[e+1]=t,t=t>>>8,r[e]=t}function Nf(r,t){return r[t+0]<<0>>>0|r[t+1]<<8>>>0|r[t+2]<<16>>>0|r[t+3]<<24>>>0}function Mf(r,t,e){r[e+0]=t&255,t=t>>>8,r[e+1]=t&255,t=t>>>8,r[e+2]=t&255,t=t>>>8,r[e+3]=t&255}function Wf(r,t){return r[t]}function Bf(r,t,e){r[e]=t}function ou(r){return Zc(r,t=>S.concat(t))}function su(r){return nu(r)}function Fr(r){return Vi(r,t=>S.concat(t))}async function au(r){return r.ended?S.concat(r.buffer):S.concat([...r.buffer,await Fr(r.stream)])}function lu(r){return ln(t=>S.concat(t),r)}function Ki(r){let t=0,e=0,n=0,i=new Uint8Array(Math.floor(r.length/4*3)),o=a=>{switch(e){case 3:i[n++]=t|a,e=0;break;case 2:i[n++]=t|a>>>2,t=a<<6,e=3;break;case 1:i[n++]=t|a>>>4,t=a<<4,e=2;break;default:t=a<<2,e=1}};for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);if(l>=65&&l<=90)o(l-65);else if(l>=97&&l<=122)o(l-97+26);else if(l>=48&&l<=57)o(l-48+52);else if(l===43||l===45)o(62);else if(l===47||l===95)o(63);else{if(l===61)break;throw new SyntaxError(`Unexpected base64 character ${r[a]}`)}}let s=n;for(;e>0;)o(0);return S.wrap(i).slice(0,s)}var ru="0123456789abcdef";function Ur({buffer:r}){let t="";for(let e=0;e<r.length;e++){let n=r[e];t+=ru[n>>>4],t+=ru[n&15]}return t}function aa(r){if(r.length%2!==0)throw new SyntaxError("Hex string must have an even length");let t=new Uint8Array(r.length>>1);for(let e=0;e<r.length;)t[e>>1]=iu(r,e++)<<4|iu(r,e++);return S.wrap(t)}function iu(r,t){let e=r.charCodeAt(t);if(e>=48&&e<=57)return e-48;if(e>=97&&e<=102)return e-87;if(e>=65&&e<=70)return e-55;throw new SyntaxError(`Invalid hex character at position ${t}`)}function K(r,t,e){let n=null,i=null;if(typeof e.value=="function"?(n="value",i=e.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof e.get=="function"&&(n="get",i=e.get),!i)throw new Error("not supported");let o=`$memoize$${t}`;e[n]=function(...s){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,s)}),this[o]}}function Nr(r,t=0){if(!r||t>200)return r;if(typeof r=="object"){switch(r.$mid){case 1:return m.revive(r);case 2:return new RegExp(r.source,r.flags);case 17:return new Date(r.source)}if(r instanceof S||r instanceof Uint8Array)return r;if(Array.isArray(r))for(let e=0;e<r.length;++e)r[e]=Nr(r[e],t+1);else for(let e in r)Object.hasOwnProperty.call(r,e)&&(r[e]=Nr(r[e],t+1))}return r}function Mn(r){switch(r){case 100:return"req";case 101:return"cancel";case 102:return"subscribe";case 103:return"unsubscribe"}}function ji(r){switch(r){case 200:return"init";case 201:return"reply:";case 202:case 203:return"replyErr:";case 204:return"event:"}}function Un(r){let t=0;for(let e=0;;e+=7){let n=r.read(1);if(t|=(n.buffer[0]&127)<<e,!(n.buffer[0]&128))return t}}var qf=Bt(0);function Nn(r,t){if(t===0){r.write(qf);return}let e=0;for(let i=t;i!==0;i=i>>>7)e++;let n=S.alloc(e);for(let i=0;t!==0;i++)n.buffer[i]=t&127,t=t>>>7,t>0&&(n.buffer[i]|=128);r.write(n)}var Mr=class{constructor(t){this.buffer=t;this.pos=0}read(t){let e=this.buffer.slice(this.pos,this.pos+t);return this.pos+=e.byteLength,e}},zi=class{constructor(){this.buffers=[]}get buffer(){return S.concat(this.buffers)}write(t){this.buffers.push(t)}};function Bt(r){let t=S.alloc(1);return t.writeUInt8(r,0),t}var cn={Undefined:Bt(0),String:Bt(1),Buffer:Bt(2),VSBuffer:Bt(3),Array:Bt(4),Object:Bt(5),Uint:Bt(6)};function Wr(r,t){if(typeof t>"u")r.write(cn.Undefined);else if(typeof t=="string"){let e=S.fromString(t);r.write(cn.String),Nn(r,e.byteLength),r.write(e)}else if(S.isNativeBuffer(t)){let e=S.wrap(t);r.write(cn.Buffer),Nn(r,e.byteLength),r.write(e)}else if(t instanceof S)r.write(cn.VSBuffer),Nn(r,t.byteLength),r.write(t);else if(Array.isArray(t)){r.write(cn.Array),Nn(r,t.length);for(let e of t)Wr(r,e)}else if(typeof t=="number"&&(t|0)===t)r.write(cn.Uint),Nn(r,t);else{let e=S.fromString(JSON.stringify(t));r.write(cn.Object),Nn(r,e.byteLength),r.write(e)}}function Bn(r){switch(r.read(1).readUInt8(0)){case 0:return;case 1:return r.read(Un(r)).toString();case 2:return r.read(Un(r)).buffer;case 3:return r.read(Un(r));case 4:{let e=Un(r),n=[];for(let i=0;i<e;i++)n.push(Bn(r));return n}case 5:return JSON.parse(r.read(Un(r)).toString());case 6:return Un(r)}}var Br=class{constructor(t,e,n=null,i=1e3){this.protocol=t;this.ctx=e;this.logger=n;this.timeoutDelay=i;this.channels=new Map;this.activeRequests=new Map;this.pendingRequests=new Map;this.protocolListener=this.protocol.onMessage(o=>this.onRawMessage(o)),this.sendResponse({type:200})}registerChannel(t,e){this.channels.set(t,e),setTimeout(()=>this.flushPendingRequests(t),0)}sendResponse(t){switch(t.type){case 200:{let e=this.send([t.type]);this.logger?.logOutgoing(e,0,1,ji(t.type));return}case 201:case 202:case 204:case 203:{let e=this.send([t.type,t.id],t.data);this.logger?.logOutgoing(e,t.id,1,ji(t.type),t.data);return}}}send(t,e=void 0){let n=new zi;return Wr(n,t),Wr(n,e),this.sendBuffer(n.buffer)}sendBuffer(t){try{return this.protocol.send(t),t.byteLength}catch{return 0}}onRawMessage(t){let e=new Mr(t),n=Bn(e),i=Bn(e),o=n[0];switch(o){case 100:return this.logger?.logIncoming(t.byteLength,n[1],1,`${Mn(o)}: ${n[2]}.${n[3]}`,i),this.onPromise({type:o,id:n[1],channelName:n[2],name:n[3],arg:i});case 102:return this.logger?.logIncoming(t.byteLength,n[1],1,`${Mn(o)}: ${n[2]}.${n[3]}`,i),this.onEventListen({type:o,id:n[1],channelName:n[2],name:n[3],arg:i});case 101:return this.logger?.logIncoming(t.byteLength,n[1],1,`${Mn(o)}`),this.disposeActiveRequest({type:o,id:n[1]});case 103:return this.logger?.logIncoming(t.byteLength,n[1],1,`${Mn(o)}`),this.disposeActiveRequest({type:o,id:n[1]})}}onPromise(t){let e=this.channels.get(t.channelName);if(!e){this.collectPendingRequest(t);return}let n=new fe,i;try{i=e.call(this.ctx,t.name,t.arg,n.token)}catch(a){i=Promise.reject(a)}let o=t.id;i.then(a=>{this.sendResponse({id:o,data:a,type:201})},a=>{a instanceof Error?this.sendResponse({id:o,data:{message:a.message,name:a.name,stack:a.stack?a.stack.split(`
`):void 0},type:202}):this.sendResponse({id:o,data:a,type:203})}).finally(()=>{s.dispose(),this.activeRequests.delete(t.id)});let s=O(()=>n.cancel());this.activeRequests.set(t.id,s)}onEventListen(t){let e=this.channels.get(t.channelName);if(!e){this.collectPendingRequest(t);return}let n=t.id,o=e.listen(this.ctx,t.name,t.arg)(s=>this.sendResponse({id:n,data:s,type:204}));this.activeRequests.set(t.id,o)}disposeActiveRequest(t){let e=this.activeRequests.get(t.id);e&&(e.dispose(),this.activeRequests.delete(t.id))}collectPendingRequest(t){let e=this.pendingRequests.get(t.channelName);e||(e=[],this.pendingRequests.set(t.channelName,e));let n=setTimeout(()=>{console.error(`Unknown channel: ${t.channelName}`),t.type===100&&this.sendResponse({id:t.id,data:{name:"Unknown channel",message:`Channel name '${t.channelName}' timed out after ${this.timeoutDelay}ms`,stack:void 0},type:202})},this.timeoutDelay);e.push({request:t,timeoutTimer:n})}flushPendingRequests(t){let e=this.pendingRequests.get(t);if(e){for(let n of e)switch(clearTimeout(n.timeoutTimer),n.request.type){case 100:this.onPromise(n.request);break;case 102:this.onEventListen(n.request);break}this.pendingRequests.delete(t)}}dispose(){this.protocolListener&&(this.protocolListener.dispose(),this.protocolListener=null),Ae(this.activeRequests.values()),this.activeRequests.clear()}};var Wn=class{constructor(t,e=null){this.protocol=t;this.isDisposed=!1;this.state=0;this.activeRequests=new Set;this.handlers=new Map;this.lastRequestId=0;this._onDidInitialize=new b;this.onDidInitialize=this._onDidInitialize.event;this.protocolListener=this.protocol.onMessage(n=>this.onBuffer(n)),this.logger=e}getChannel(t){let e=this;return{call(n,i,o){return e.isDisposed?Promise.reject(new Ie):e.requestPromise(t,n,i,o)},listen(n,i){return e.isDisposed?z.None:e.requestEvent(t,n,i)}}}requestPromise(t,e,n,i=Be.None){let o=this.lastRequestId++,a={id:o,type:100,channelName:t,name:e,arg:n};if(i.isCancellationRequested)return Promise.reject(new Ie);let l,c;return new Promise((u,p)=>{if(i.isCancellationRequested)return p(new Ie);let h=()=>{let E=R=>{switch(R.type){case 201:this.handlers.delete(o),u(R.data);break;case 202:{this.handlers.delete(o);let C=new Error(R.data.message);C.stack=Array.isArray(R.data.stack)?R.data.stack.join(`
`):R.data.stack,C.name=R.data.name,p(C);break}case 203:this.handlers.delete(o),p(R.data);break}};this.handlers.set(o,E),this.sendRequest(a)},v=null;this.state===1?h():(v=Fn(E=>this.whenInitialized()),v.then(()=>{v=null,h()}));let g=()=>{v?(v.cancel(),v=null):this.sendRequest({id:o,type:101}),p(new Ie)};l=i.onCancellationRequested(g),c={dispose:In(()=>{g(),l.dispose()})},this.activeRequests.add(c)}).finally(()=>{l?.dispose(),this.activeRequests.delete(c)})}requestEvent(t,e,n){let i=this.lastRequestId++,s={id:i,type:102,channelName:t,name:e,arg:n},a=null,l=new b({onWillAddFirstListener:()=>{let d=()=>{this.activeRequests.add(l),this.sendRequest(s)};this.state===1?d():(a=Fn(u=>this.whenInitialized()),a.then(()=>{a=null,d()}))},onDidRemoveLastListener:()=>{a?(a.cancel(),a=null):(this.activeRequests.delete(l),this.sendRequest({id:i,type:103})),this.handlers.delete(i)}}),c=d=>l.fire(d.data);return this.handlers.set(i,c),l.event}sendRequest(t){switch(t.type){case 100:case 102:{let e=this.send([t.type,t.id,t.channelName,t.name],t.arg);this.logger?.logOutgoing(e,t.id,0,`${Mn(t.type)}: ${t.channelName}.${t.name}`,t.arg);return}case 101:case 103:{let e=this.send([t.type,t.id]);this.logger?.logOutgoing(e,t.id,0,Mn(t.type));return}}}send(t,e=void 0){let n=new zi;return Wr(n,t),Wr(n,e),this.sendBuffer(n.buffer)}sendBuffer(t){try{return this.protocol.send(t),t.byteLength}catch{return 0}}onBuffer(t){let e=new Mr(t),n=Bn(e),i=Bn(e),o=n[0];switch(o){case 200:return this.logger?.logIncoming(t.byteLength,0,0,ji(o)),this.onResponse({type:n[0]});case 201:case 202:case 204:case 203:return this.logger?.logIncoming(t.byteLength,n[1],0,ji(o),i),this.onResponse({type:n[0],id:n[1],data:i})}}onResponse(t){if(t.type===200){this.state=1,this._onDidInitialize.fire();return}this.handlers.get(t.id)?.(t)}get onDidInitializePromise(){return z.toPromise(this.onDidInitialize)}whenInitialized(){return this.state===1?Promise.resolve():this.onDidInitializePromise}dispose(){this.isDisposed=!0,this.protocolListener&&(this.protocolListener.dispose(),this.protocolListener=null),Ae(this.activeRequests.values()),this.activeRequests.clear(),this._onDidInitialize.dispose()}};D([K],Wn.prototype,"onDidInitializePromise",1);var Hi=class{constructor(t,e,n){this.channels=new Map;this._connections=new Set;this._onDidAddConnection=new b;this.onDidAddConnection=this._onDidAddConnection.event;this._onDidRemoveConnection=new b;this.onDidRemoveConnection=this._onDidRemoveConnection.event;this.disposables=new N;this.disposables.add(t(({protocol:i,onDidClientDisconnect:o})=>{let s=z.once(i.onMessage);this.disposables.add(s(a=>{let l=new Mr(a),c=Bn(l),d=new Br(i,c,e,n),u=new Wn(i,e);this.channels.forEach((h,v)=>d.registerChannel(v,h));let p={channelServer:d,channelClient:u,ctx:c};this._connections.add(p),this._onDidAddConnection.fire(p),this.disposables.add(o(()=>{d.dispose(),u.dispose(),this._connections.delete(p),this._onDidRemoveConnection.fire(p)}))}))}))}get connections(){let t=[];return this._connections.forEach(e=>t.push(e)),t}getChannel(t,e){let n=this;return{call(i,o,s){let a;if(Rs(e)){let c=Ll(n.connections.filter(e));a=c?Promise.resolve(c):z.toPromise(z.filter(n.onDidAddConnection,e))}else a=e.routeCall(n,i,o);let l=a.then(c=>c.channelClient.getChannel(t));return cu(l).call(i,o,s)},listen(i,o){if(Rs(e))return n.getMulticastEvent(t,e,i,o);let s=e.routeEvent(n,i,o).then(a=>a.channelClient.getChannel(t));return cu(s).listen(i,o)}}}getMulticastEvent(t,e,n,i){let o=this,s,a=new b({onWillAddFirstListener:()=>{s=new N;let l=new wi,c=new Map,d=p=>{let v=p.channelClient.getChannel(t).listen(n,i),g=l.add(v);c.set(p,g)},u=p=>{let h=c.get(p);h&&(h.dispose(),c.delete(p))};o.connections.filter(e).forEach(d),z.filter(o.onDidAddConnection,e)(d,void 0,s),o.onDidRemoveConnection(u,void 0,s),l.event(a.fire,a,s),s.add(l)},onDidRemoveLastListener:()=>{s?.dispose(),s=void 0}});return o.disposables.add(a),a.event}registerChannel(t,e){this.channels.set(t,e);for(let n of this._connections)n.channelServer.registerChannel(t,e)}dispose(){this.disposables.dispose();for(let t of this._connections)t.channelClient.dispose(),t.channelServer.dispose();this._connections.clear(),this.channels.clear(),this._onDidAddConnection.dispose(),this._onDidRemoveConnection.dispose()}};function cu(r){return{call(t,e,n){return r.then(i=>i.call(t,e,n))},listen(t,e){let n=new wr;return r.then(i=>n.input=i.listen(t,e)),n.event}}}function uu(r){let t=!1;return{call(e,n,i){return t?r.call(e,n,i):sn(0).then(()=>t=!0).then(()=>r.call(e,n,i))},listen(e,n){if(t)return r.listen(e,n);let i=new wr;return sn(0).then(()=>t=!0).then(()=>i.input=r.listen(e,n)),i.event}}}var qn;(i=>{function r(o,s,a){let l=o,c=a?.disableMarshalling,d=new Map;for(let u in l)e(u)&&d.set(u,z.buffer(l[u],u,!0,void 0,s));return new class{listen(u,p,h){let v=d.get(p);if(v)return v;let g=l[p];if(typeof g=="function"){if(n(p))return g.call(l,h);if(e(p))return d.set(p,z.buffer(l[p],p,!0,void 0,s)),d.get(p)}throw new ot(`Event not found: ${p}`)}call(u,p,h){let v=l[p];if(typeof v=="function"){if(!c&&Array.isArray(h))for(let E=0;E<h.length;E++)h[E]=Nr(h[E]);let g=v.apply(l,h);return g instanceof Promise||(g=Promise.resolve(g)),g}throw new ot(`Method not found: ${p}`)}}}i.fromService=r;function t(o,s){let a=s?.disableMarshalling;return new Proxy({},{get(l,c){if(typeof c=="string")return s?.properties?.has(c)?s.properties.get(c):n(c)?function(d){return o.listen(c,d)}:e(c)?o.listen(c):async function(...d){let u;s&&!Tr(s.context)?u=[s.context,...d]:u=d;let p=await o.call(c,u);return a?p:Nr(p)};throw new ot(`Property not found: ${String(c)}`)}})}i.toService=t;function e(o){return o[0]==="o"&&o[1]==="n"&&Vs(o.charCodeAt(2))}function n(o){return/^onDynamic/.test(o)&&Vs(o.charCodeAt(9))}})(qn||={});import{fork as fh}from"child_process";function du(r){let t=r;return t&&typeof t.type=="string"&&typeof t.severity=="string"}function Vf(r){let t=[],e;try{let n=JSON.parse(r.arguments),i=n[n.length-1];i&&i.__$stack&&(n.pop(),e=i.__$stack),t.push(...n)}catch{t.push("Unable to log remote console arguments",r.arguments)}return{args:t,stack:e}}function $f(r){if(!r)return r;let t=r.indexOf(`
`);return t===-1?r:r.substring(0,t)}function pu(r,t){let{args:e,stack:n}=Vf(r),i=typeof e[0]=="string"&&e.length===1,o=$f(n);o&&(o=`(${o.trim()})`);let s=[];if(typeof e[0]=="string"?o&&i?s=[`%c[${t}] %c${e[0]} %c${o}`,Vn("blue"),Vn(""),Vn("grey")]:s=[`%c[${t}] %c${e[0]}`,Vn("blue"),Vn(""),...e.slice(1)]:s=[`%c[${t}]%`,Vn("blue"),...e],o&&!i&&s.push(o),typeof console[r.severity]!="function")throw new Error("Unknown console method");console[r.severity].apply(console,s)}function Vn(r){return`color: ${r}`}function ca(r){if(!r||typeof r!="object"||r instanceof RegExp)return r;let t=Array.isArray(r)?[]:{};return Object.entries(r).forEach(([e,n])=>{t[e]=n&&typeof n=="object"?ca(n):n}),t}var Kf=Object.prototype.hasOwnProperty;function ua(r,t){return la(r,t,new Set)}function la(r,t,e){if(Tr(r))return r;let n=t(r);if(typeof n<"u")return n;if(Array.isArray(r)){let i=[];for(let o of r)i.push(la(o,t,e));return i}if(Hl(r)){if(e.has(r))throw new Error("Cannot clone recursive data-structure");e.add(r);let i={};for(let o in r)Kf.call(r,o)&&(i[o]=la(r[o],t,e));return e.delete(r),i}return r}import*as ph from"child_process";import{promises as Ky}from"fs";function fu(r){r&&(delete r.DEBUG,le&&delete r.LD_PRELOAD)}import*as L from"fs";import{tmpdir as Jf}from"os";import{promisify as Vr}from"util";var jf=new At(1e4);function qr(r){return hu(r,"NFC",jf)}var zf=new At(1e4);function Hf(r){return hu(r,"NFD",zf)}var Gf=/[^\u0000-\u0080]/;function hu(r,t,e){if(!r)return r;let n=e.get(r);if(n)return n;let i;return Gf.test(r)?i=r.normalize(t):i=r,e.set(r,i),i}var Ey=(function(){let r=new At(1e4),t=/[\u0300-\u036f]/g;return function(e){let n=r.get(e);if(n)return n;let i=Hf(e).replace(t,""),o=(i.length===e.length?i:e).toLowerCase();return r.set(e,o),o}})();async function vu(r,t=0,e){if(js(r))throw new Error("rimraf - will refuse to recursively delete root");return t===0?da(r):Qf(r,e)}async function Qf(r,t=Mc(Jf())){try{try{await L.promises.rename(r,t)}catch(e){return e.code==="ENOENT"?void 0:da(r)}da(t).catch(()=>{})}catch(e){if(e.code!=="ENOENT")throw e}}async function da(r){return L.promises.rm(r,{recursive:!0,force:!0,maxRetries:3})}async function Gi(r,t){try{return await gu(r,t)}catch(e){if(e.code==="ENOENT"&&H&&js(r))try{return await gu(`${r}.`,t)}catch{}throw e}}async function gu(r,t){return Xf(await(t?Yf(r):L.promises.readdir(r)))}async function Yf(r){try{return await L.promises.readdir(r,{withFileTypes:!0})}catch(n){n.code!=="ENOENT"&&console.warn("[node.js fs] readdir with filetypes failed with error: ",n)}let t=[],e=await Gi(r);for(let n of e){let i=!1,o=!1,s=!1;try{let a=await L.promises.lstat(W(r,n));i=a.isFile(),o=a.isDirectory(),s=a.isSymbolicLink()}catch(a){a.code!=="ENOENT"&&console.warn("[node.js fs] unexpected error from lstat after readdir: ",a)}t.push({name:n,isFile:()=>i,isDirectory:()=>o,isSymbolicLink:()=>s})}return t}function Xf(r){return r.map(t=>typeof t=="string"?Ke?qr(t):t:(t.name=Ke?qr(t.name):t.name,t))}async function Zf(r){let t=await Gi(r),e=[];for(let n of t)await ct.existsDirectory(W(r,n))&&e.push(n);return e}var ct;(n=>{async function r(i){let o;try{if(o=await L.promises.lstat(i),!o.isSymbolicLink())return{stat:o}}catch{}try{return{stat:await L.promises.stat(i),symbolicLink:o?.isSymbolicLink()?{dangling:!1}:void 0}}catch(s){if(s.code==="ENOENT"&&o)return{stat:o,symbolicLink:{dangling:!0}};if(H&&s.code==="EACCES")try{return{stat:await L.promises.stat(await L.promises.readlink(i)),symbolicLink:{dangling:!1}}}catch(a){if(a.code==="ENOENT"&&o)return{stat:o,symbolicLink:{dangling:!0}};throw a}throw s}}n.stat=r;async function t(i){try{let{stat:o,symbolicLink:s}=await n.stat(i);return o.isFile()&&s?.dangling!==!0}catch{}return!1}n.existsFile=t;async function e(i){try{let{stat:o,symbolicLink:s}=await n.stat(i);return o.isDirectory()&&s?.dangling!==!0}catch{}return!1}n.existsDirectory=e})(ct||={});var eh=new On;function th(r,t,e){return eh.queueFor(m.file(r),()=>{let n=ih(e);return new Promise((i,o)=>rh(r,t,n,s=>s?o(s):i()))},Mt)}var yu=!0;function nh(r){yu=r}function rh(r,t,e,n){if(!yu)return L.writeFile(r,t,{mode:e.mode,flag:e.flag},n);L.open(r,e.flag,e.mode,(i,o)=>{if(i)return n(i);L.writeFile(o,t,s=>{if(s)return L.close(o,()=>n(s));L.fdatasync(o,a=>(a&&(console.warn("[node.js fs] fdatasync is now disabled for this session because it failed: ",a),nh(!1)),L.close(o,l=>n(l))))})})}function ih(r){return r?{mode:typeof r.mode=="number"?r.mode:438,flag:typeof r.flag=="string"?r.flag:"w"}:{mode:438,flag:"w"}}async function oh(r,t,e=6e4){if(r!==t)try{H&&typeof e=="number"?await bu(r,t,Date.now(),e):await L.promises.rename(r,t)}catch(n){if(r.toLowerCase()!==t.toLowerCase()&&n.code==="EXDEV"||r.endsWith("."))await Iu(r,t,{preserveSymlinks:!1}),await vu(r,1);else throw n}}async function bu(r,t,e,n,i=0){try{return await L.promises.rename(r,t)}catch(o){if(o.code!=="EACCES"&&o.code!=="EPERM"&&o.code!=="EBUSY")throw o;if(Date.now()-e>=n)throw console.error(`[node.js fs] rename failed after ${i} retries with error: ${o}`),o;if(i===0){let s=!1;try{let{stat:a}=await ct.stat(t);a.isFile()||(s=!0)}catch{}if(s)throw o}return await sn(Math.min(100,i*10)),bu(r,t,e,n,i+1)}}async function Iu(r,t,e){return Tu(r,t,{root:{source:r,target:t},options:e,handledSourcePaths:new Set})}var mu=511;async function Tu(r,t,e){if(e.handledSourcePaths.has(r))return;e.handledSourcePaths.add(r);let{stat:n,symbolicLink:i}=await ct.stat(r);if(i){if(e.options.preserveSymlinks)try{return await lh(r,t,e)}catch{}if(i.dangling)return}return n.isDirectory()?sh(r,t,n.mode&mu,e):ah(r,t,n.mode&mu)}async function sh(r,t,e,n){await L.promises.mkdir(t,{recursive:!0,mode:e});let i=await Gi(r);for(let o of i)await Tu(W(r,o),W(t,o),n)}async function ah(r,t,e){await L.promises.copyFile(r,t),await L.promises.chmod(t,e)}async function lh(r,t,e){let n=await L.promises.readlink(r);bt(n,e.root.source,!le)&&(n=W(e.root.target,n.substr(e.root.source.length+1))),await L.promises.symlink(n,t)}async function ch(r){try{return await Vr(L.realpath)(r)}catch{let t=uh(r);return await L.promises.access(t,L.constants.R_OK),t}}function uh(r){return Pn(je(r),ue)}var ae=new class{get read(){return(r,t,e,n,i)=>new Promise((o,s)=>{L.read(r,t,e,n,i,(a,l,c)=>a?s(a):o({bytesRead:l,buffer:c}))})}get write(){return(r,t,e,n,i)=>new Promise((o,s)=>{L.write(r,t,e,n,i,(a,l,c)=>a?s(a):o({bytesWritten:l,buffer:c}))})}get fdatasync(){return Vr(L.fdatasync)}get open(){return Vr(L.open)}get close(){return Vr(L.close)}get ftruncate(){return Vr(L.ftruncate)}async exists(r){try{return await L.promises.access(r),!0}catch{return!1}}get readdir(){return Gi}get readDirsInDir(){return Zf}get writeFile(){return th}get rm(){return vu}get rename(){return oh}get copy(){return Iu}get realpath(){return ch}};function Su(r){let t=[],e=!1,n=function(i){if(e){t.push(i);return}(!r.send(i,s=>{if(s&&console.error(s),e=!1,t.length>0){let a=t.slice(0);t=[],a.forEach(l=>n(l))}})||H)&&(e=!0)};return{send:n}}var Ji=class extends Br{constructor(t){super({send:e=>{try{process.send?.(e.buffer.toString("base64"))}catch{}},onMessage:z.fromNodeEventEmitter(process,"message",e=>S.wrap(Buffer.from(e,"base64")))},t),process.once("disconnect",()=>this.dispose())}},Qi=class{constructor(t,e){this.modulePath=t;this.options=e;this.activeRequests=new Set;this.channels=new Map;this._onDidProcessExit=new b;this.onDidProcessExit=this._onDidProcessExit.event;let n=e.timeout||6e4;this.disposeDelayer=new Dr(n),this.child=null,this._client=null}getChannel(t){let e=this;return{call(n,i,o){return e.requestPromise(t,n,i,o)},listen(n,i){return e.requestEvent(t,n,i)}}}requestPromise(t,e,n,i=Be.None){if(!this.disposeDelayer)return Promise.reject(new Error("disposed"));if(i.isCancellationRequested)return Promise.reject(mi());this.disposeDelayer.cancel();let o=this.getCachedChannel(t),s=Fn(c=>o.call(e,n,c)),a=i.onCancellationRequested(()=>s.cancel()),l=O(()=>s.cancel());return this.activeRequests.add(l),s.finally(()=>{a.dispose(),this.activeRequests.delete(l),this.activeRequests.size===0&&this.disposeDelayer&&this.disposeDelayer.trigger(()=>this.disposeClient())}),s}requestEvent(t,e,n){if(!this.disposeDelayer)return z.None;this.disposeDelayer.cancel();let i,o=new b({onWillAddFirstListener:()=>{i=this.getCachedChannel(t).listen(e,n)(o.fire,o),this.activeRequests.add(i)},onDidRemoveLastListener:()=>{this.activeRequests.delete(i),i.dispose(),this.activeRequests.size===0&&this.disposeDelayer&&this.disposeDelayer.trigger(()=>this.disposeClient())}});return o.event}get client(){if(!this._client){let t=this.options.args||[],e=Object.create(null);e.env={...ca(process.env),VSCODE_PARENT_PID:String(process.pid)},this.options.env&&(e.env={...e.env,...this.options.env}),this.options.freshExecArgv&&(e.execArgv=[]),typeof this.options.debug=="number"&&(e.execArgv=["--nolazy","--inspect="+this.options.debug]),typeof this.options.debugBrk=="number"&&(e.execArgv=["--nolazy","--inspect-brk="+this.options.debugBrk]),e.execArgv===void 0&&(e.execArgv=process.execArgv.filter(u=>!/^--inspect(-brk)?=/.test(u)).filter(u=>!u.startsWith("--vscode-"))),fu(e.env),this.child=fh(this.modulePath,t,e);let n=new b,o=z.fromNodeEventEmitter(this.child,"message",u=>u)(u=>{if(du(u)){pu(u,`IPC Library: ${this.options.serverName}`);return}n.fire(S.wrap(Buffer.from(u,"base64")))}),s=this.options.useQueue?Su(this.child):this.child,a=u=>this.child?.connected&&s.send(u.buffer.toString("base64")),l=n.event,c={send:a,onMessage:l};this._client=new Wn(c);let d=()=>this.disposeClient();process.once("exit",d),this.child.on("error",u=>console.warn('IPC "'+this.options.serverName+'" errored with '+u)),this.child.on("exit",(u,p)=>{process.removeListener("exit",d),o.dispose(),this.activeRequests.forEach(h=>Ae(h)),this.activeRequests.clear(),u!==0&&p!=="SIGTERM"&&console.warn('IPC "'+this.options.serverName+'" crashed with exit code '+u+" and signal "+p),this.disposeDelayer?.cancel(),this.disposeClient(),this._onDidProcessExit.fire({code:u,signal:p})})}return this._client}getCachedChannel(t){let e=this.channels.get(t);return e||(e=this.client.getChannel(t),this.channels.set(t,e)),e}disposeClient(){this._client&&(this.child&&(this.child.kill(),this.child=null),this._client=null,this.channels.clear())}dispose(){this._onDidProcessExit.dispose(),this.disposeDelayer?.cancel(),this.disposeDelayer=void 0,this.disposeClient(),this.activeRequests.clear()}};function Yi(r){return!!r.parentPort}var pa=class{constructor(t){this.port=t;this.onMessage=z.fromNodeEventEmitter(this.port,"message",e=>e.data?S.wrap(e.data):S.alloc(0)),t.start()}send(t){this.port.postMessage(t.buffer)}disconnect(){this.port.close()}},Xi=class r extends Hi{static getOnDidClientConnect(t){Jl(Yi(process),"Electron Utility Process");let e=new b;return process.parentPort.on("message",n=>{if(t?.handledClientConnection(n))return;let i=n.ports.at(0);i&&e.fire(i)}),z.map(e.event,n=>({protocol:new pa(n),onDidClientDisconnect:z.fromNodeEventEmitter(n,"close")}))}constructor(t){super(r.getOnDidClientConnect(t))}};import*as _p from"os";var Ze;(i=>{i.serviceIds=new Map,i.DI_TARGET="$di$target",i.DI_DEPENDENCIES="$di$dependencies";function n(o){return o[i.DI_DEPENDENCIES]||[]}i.getServiceDependencies=n})(Ze||={});var Zi=Le("instantiationService");function hh(r,t,e){t[Ze.DI_TARGET]===t?t[Ze.DI_DEPENDENCIES].push({id:r,index:e}):(t[Ze.DI_DEPENDENCIES]=[{id:r,index:e}],t[Ze.DI_TARGET]=t)}function Le(r){if(Ze.serviceIds.has(r))return Ze.serviceIds.get(r);let t=function(e,n,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");hh(t,e,i)};return t.toString=()=>r,Ze.serviceIds.set(r,t),t}var ie;(n=>{function r(i,o){return m.from({scheme:i,path:`/${o}`})}n.uri=r;function t(i){return(typeof i=="string"?m.parse(i):i).path.substring(1)}n.id=t;function e(i){return(typeof i=="string"?m.parse(i):i).scheme||void 0}n.provider=e})(ie||={});var Ab=Le("agentService"),kb=Le("agentHostService");var ke=class{constructor(t,e,n){this.owner=t;this.debugNameSource=e;this.referenceFn=n}getDebugName(t){return Eu(t,this)}},_u=new Map,fa=new WeakMap;function Eu(r,t){let e=fa.get(r);if(e)return e;let n=gh(r,t);if(n){let i=_u.get(n)??0;i++,_u.set(n,i);let o=i===1?n:`${n}#${i}`;return fa.set(r,o),o}}function gh(r,t){let e=fa.get(r);if(e)return e;let n=t.owner?vh(t.owner)+".":"",i,o=t.debugNameSource;if(o!==void 0)if(typeof o=="function"){if(i=o(),i!==void 0)return n+i}else return n+o;let s=t.referenceFn;if(s!==void 0&&(i=$r(s),i!==void 0))return n+i;if(t.owner!==void 0){let a=mh(t.owner,r);if(a!==void 0)return n+a}}function mh(r,t){for(let e in r)if(r[e]===t)return e}var xu=new Map,Ru=new WeakMap;function vh(r){let t=Ru.get(r);if(t)return t;let e=ha(r)??"Object",n=xu.get(e)??0;n++,xu.set(e,n);let i=n===1?e:`${e}#${n}`;return Ru.set(r,i),i}function ha(r){let t=r.constructor;if(t)return t.name==="Object"?void 0:t.name}function $r(r){let t=r.toString(),n=/\/\*\*\s*@description\s*([^*]*)\*\//.exec(t);return(n?n[1]:void 0)?.trim()}function Ge(r,t){return r===t}function yh(){return(r,t)=>r===t}function bh(r,t,e){return yr(r,t,e??Ge)}function Ih(r){return(t,e)=>yr(t,e,r??Ge)}function eo(r,t){if(r===t)return!0;if(Array.isArray(r)&&Array.isArray(t)){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(!eo(r[e],t[e]))return!1;return!0}if(r&&typeof r=="object"&&t&&typeof t=="object"&&Object.getPrototypeOf(r)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){let e=r,n=t,i=Object.keys(e),o=Object.keys(n),s=new Set(o);if(i.length!==o.length)return!1;for(let a of i)if(!s.has(a)||!eo(e[a],n[a]))return!1;return!0}return!1}function Th(){return(r,t)=>eo(r,t)}function Sh(r,t){return JSON.stringify(r)===JSON.stringify(t)}function _h(){return(r,t)=>JSON.stringify(r)===JSON.stringify(t)}function xh(){return(r,t)=>r.equals(t)}function Rh(r,t,e){return r==null||t===void 0||t===null?t===r:e(r,t)}function Eh(r){return(t,e)=>t==null||e===void 0||e===null?e===t:r(t,e)}var wh;(u=>(u.strict=Ge,u.strictC=yh,u.array=bh,u.arrayC=Ih,u.structural=eo,u.structuralC=Th,u.jsonStringify=Sh,u.jsonStringifyC=_h,u.thisC=xh,u.ifDefined=Rh,u.ifDefinedC=Eh))(wh||={});function ga(r){let t=new Error("BugIndicatingErrorRecovery: "+r);oe(t),console.error("recovered from an error that indicates a bug",t)}var un;function Kr(r){un?un instanceof to?un.loggers.push(r):un=new to([un,r]):un=r}function te(){return un}var ma;function wu(r){ma=r}function Cu(r){ma&&ma(r)}var to=class{constructor(t){this.loggers=t}handleObservableCreated(t,e){for(let n of this.loggers)n.handleObservableCreated(t,e)}handleOnListenerCountChanged(t,e){for(let n of this.loggers)n.handleOnListenerCountChanged(t,e)}handleObservableUpdated(t,e){for(let n of this.loggers)n.handleObservableUpdated(t,e)}handleAutorunCreated(t,e){for(let n of this.loggers)n.handleAutorunCreated(t,e)}handleAutorunDisposed(t){for(let e of this.loggers)e.handleAutorunDisposed(t)}handleAutorunDependencyChanged(t,e,n){for(let i of this.loggers)i.handleAutorunDependencyChanged(t,e,n)}handleAutorunStarted(t){for(let e of this.loggers)e.handleAutorunStarted(t)}handleAutorunFinished(t){for(let e of this.loggers)e.handleAutorunFinished(t)}handleDerivedDependencyChanged(t,e,n){for(let i of this.loggers)i.handleDerivedDependencyChanged(t,e,n)}handleDerivedCleared(t){for(let e of this.loggers)e.handleDerivedCleared(t)}handleBeginTransaction(t){for(let e of this.loggers)e.handleBeginTransaction(t)}handleEndTransaction(t){for(let e of this.loggers)e.handleEndTransaction(t)}};function $n(r,t){let e=new dn(r,t);try{r(e)}finally{e.finish()}}function va(r,t,e){r?t(r):$n(t,e)}var dn=class{constructor(t,e){this._fn=t;this._getDebugName=e;this._updatingObservers=[];te()?.handleBeginTransaction(this)}getDebugName(){return this._getDebugName?this._getDebugName():$r(this._fn)}updateObserver(t,e){if(!this._updatingObservers){ga("Transaction already finished!"),$n(n=>{n.updateObserver(t,e)});return}this._updatingObservers.push({observer:t,observable:e}),t.beginUpdate(e)}finish(){let t=this._updatingObservers;if(!t){ga("transaction.finish() has already been called!");return}for(let e=0;e<t.length;e++){let{observer:n,observable:i}=t[e];n.endUpdate(i)}this._updatingObservers=null,te()?.handleEndTransaction(this)}debugGetUpdatingObservers(){return this._updatingObservers}};var de;(n=>{let r=!1;function t(){r=!0}n.enable=t;function e(){if(!r)return;let i=Error,o=i.stackTraceLimit;i.stackTraceLimit=3;let s=new Error().stack;return i.stackTraceLimit=o,ya.fromStack(s,2)}n.ofCaller=e})(de||={});var ya=class r{constructor(t,e,n,i){this.fileName=t;this.line=e;this.column=n;this.id=i}static fromStack(t,e){let n=t.split(`
`),i=Ch(n[e+1]);if(i)return new r(i.fileName,i.line,i.column,i.id)}};function Ch(r){let t=r.match(/\((.*):(\d+):(\d+)\)/);if(t)return{fileName:t[1],line:parseInt(t[2]),column:parseInt(t[3]),id:r};let e=r.match(/at ([^\(\)]*):(\d+):(\d+)/);if(e)return{fileName:e[1],line:parseInt(e[2]),column:parseInt(e[3]),id:r}}var ba;function Pu(r){ba=r}var Au;function ku(r){Au=r}var Du;function Ou(r){Du=r}var Ia;function Lu(r){Ia=r}var no=class{get TChange(){return null}reportChanges(){this.get()}read(t){return t?t.readObservable(this):this.get()}map(t,e,n=de.ofCaller()){let i=e===void 0?void 0:t,o=e===void 0?t:e;return ba({owner:i,debugName:()=>{let s=$r(o);if(s!==void 0)return s;let l=/^\s*\(?\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\)?\s*=>\s*\1(?:\??)\.([a-zA-Z_$][a-zA-Z_$0-9]*)\s*$/.exec(o.toString());if(l)return`${this.debugName}.${l[2]}`;if(!i)return`${this.debugName} (mapped)`},debugReferenceFn:o},s=>o(this.read(s),s),n)}flatten(){return ba({owner:void 0,debugName:()=>`${this.debugName} (flattened)`},t=>this.read(t).read(t))}recomputeInitiallyAndOnChange(t,e){return t.add(Au(this,e)),this}keepObserved(t){return t.add(Du(this)),this}get debugValue(){return this.get()}get debug(){return new Ta(this)}},Ta=class{constructor(t){this.observable=t}getDependencyGraph(){return Ia(this.observable,{type:"dependencies"})}getObserverGraph(){return Ia(this.observable,{type:"observers"})}},et=class extends no{constructor(e){super();this._observers=new Set;te()?.handleObservableCreated(this,e)}addObserver(e){let n=this._observers.size;this._observers.add(e),n===0&&this.onFirstObserverAdded(),n!==this._observers.size&&te()?.handleOnListenerCountChanged(this,this._observers.size)}removeObserver(e){let n=this._observers.delete(e);n&&this._observers.size===0&&this.onLastObserverRemoved(),n&&te()?.handleOnListenerCountChanged(this,this._observers.size)}onFirstObserverAdded(){}onLastObserverRemoved(){}log(){let e=!!te();return Cu(this),e||te()?.handleObservableCreated(this,de.ofCaller()),this}debugGetObservers(){return this._observers}};function jr(r,t,e=de.ofCaller()){let n;return typeof r=="string"?n=new ke(void 0,r,void 0):n=new ke(r,void 0,void 0),new Tt(n,t,Ge,e)}var Tt=class extends et{constructor(e,n,i,o){super(o);this._debugNameData=e;this._equalityComparator=i;this._value=n,te()?.handleObservableUpdated(this,{hadValue:!1,newValue:n,change:void 0,didChange:!0,oldValue:void 0})}get debugName(){return this._debugNameData.getDebugName(this)??"ObservableValue"}get(){return this._value}set(e,n,i){if(i===void 0&&this._equalityComparator(this._value,e))return;let o;n||(n=o=new dn(()=>{},()=>`Setting ${this.debugName}`));try{let s=this._value;this._setValue(e),te()?.handleObservableUpdated(this,{oldValue:s,newValue:e,change:i,didChange:!0,hadValue:!0});for(let a of this._observers)n.updateObserver(a,this),a.handleChange(this,i)}finally{o&&o.finish()}}toString(){return`${this.debugName}: ${this._value}`}_setValue(e){this._value=e}debugGetState(){return{value:this._value}}debugSetValue(e){this._value=e}};function Ph(r){switch(r){case 1:return"dependenciesMightHaveChanged";case 2:return"stale";case 3:return"upToDate";default:return"<unknown>"}}var St=class{constructor(t,e,n,i){this._debugNameData=t;this._runFn=e;this._changeTracker=n;this._state=2;this._updateCount=0;this._disposed=!1;this._dependencies=new Set;this._dependenciesToBeRemoved=new Set;this._isRunning=!1;this._iteration=0;this._store=void 0;this._delayedStore=void 0;this._changeSummary=this._changeTracker?.createChangeSummary(void 0),te()?.handleAutorunCreated(this,i),this._run(),Dt(this)}get debugName(){return this._debugNameData.getDebugName(this)??"(anonymous)"}dispose(){if(!this._disposed){this._disposed=!0;for(let t of this._dependencies)t.removeObserver(this);this._dependencies.clear(),this._store!==void 0&&this._store.dispose(),this._delayedStore!==void 0&&this._delayedStore.dispose(),te()?.handleAutorunDisposed(this),Ot(this)}}_run(){let t=this._dependenciesToBeRemoved;this._dependenciesToBeRemoved=this._dependencies,this._dependencies=t,this._state=3;try{if(!this._disposed){te()?.handleAutorunStarted(this);let e=this._changeSummary,n=this._delayedStore;n!==void 0&&(this._delayedStore=void 0);try{this._isRunning=!0,this._changeTracker&&(this._changeTracker.beforeUpdate?.(this,e),this._changeSummary=this._changeTracker.createChangeSummary(e)),this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._runFn(this,e)}catch(i){Pt(i)}finally{this._isRunning=!1,n!==void 0&&n.dispose()}}}finally{this._disposed||te()?.handleAutorunFinished(this);for(let e of this._dependenciesToBeRemoved)e.removeObserver(this);this._dependenciesToBeRemoved.clear()}}toString(){return`Autorun<${this.debugName}>`}beginUpdate(t){this._state===3&&(this._checkIterations(),this._state=1),this._updateCount++}endUpdate(t){try{if(this._updateCount===1){this._iteration=1;do{if(this._checkIterations())return;if(this._state===1){this._state=3;for(let e of this._dependencies)if(e.reportChanges(),this._state===2)break}this._iteration++,this._state!==3&&this._run()}while(this._state!==3)}}finally{this._updateCount--}br(()=>this._updateCount>=0)}handlePossibleChange(t){this._state===3&&this._isDependency(t)&&(this._checkIterations(),this._state=1)}handleChange(t,e){if(this._isDependency(t)){te()?.handleAutorunDependencyChanged(this,t,e);try{(!this._changeTracker||this._changeTracker.handleChange({changedObservable:t,change:e,didChange:i=>i===t},this._changeSummary))&&(this._checkIterations(),this._state=2)}catch(n){Pt(n)}}}_isDependency(t){return this._dependencies.has(t)&&!this._dependenciesToBeRemoved.has(t)}_ensureNoRunning(){if(!this._isRunning)throw new X("The reader object cannot be used outside its compute function!")}readObservable(t){if(this._ensureNoRunning(),this._disposed)return t.get();t.addObserver(this);let e=t.get();return this._dependencies.add(t),this._dependenciesToBeRemoved.delete(t),e}get store(){if(this._ensureNoRunning(),this._disposed)throw new X("Cannot access store after dispose");return this._store===void 0&&(this._store=new N),this._store}get delayedStore(){if(this._ensureNoRunning(),this._disposed)throw new X("Cannot access store after dispose");return this._delayedStore===void 0&&(this._delayedStore=new N),this._delayedStore}debugGetState(){return{isRunning:this._isRunning,updateCount:this._updateCount,dependencies:this._dependencies,state:this._state,stateStr:Ph(this._state)}}debugRerun(){this._isRunning?this._state=2:this._run()}_checkIterations(){return this._iteration>100?(Pt(new X(`Autorun '${this.debugName}' is stuck in an infinite update loop.`)),!0):!1}};function zr(r,t=de.ofCaller()){return new St(new ke(void 0,void 0,r),r,void 0,t)}function Ah(r){switch(r){case 0:return"initial";case 1:return"dependenciesMightHaveChanged";case 2:return"stale";case 3:return"upToDate";default:return"<unknown>"}}var _e=class extends et{constructor(e,n,i,o=void 0,s,a){super(a);this._debugNameData=e;this._computeFn=n;this._changeTracker=i;this._handleLastObserverRemoved=o;this._equalityComparator=s;this._state=0;this._value=void 0;this._updateCount=0;this._dependencies=new Set;this._dependenciesToBeRemoved=new Set;this._changeSummary=void 0;this._isUpdating=!1;this._isComputing=!1;this._didReportChange=!1;this._isInBeforeUpdate=!1;this._isReaderValid=!1;this._store=void 0;this._delayedStore=void 0;this._removedObserverToCallEndUpdateOn=null;this._changeSummary=this._changeTracker?.createChangeSummary(void 0)}get debugName(){return this._debugNameData.getDebugName(this)??"(anonymous)"}onLastObserverRemoved(){this._state=0,this._value=void 0,te()?.handleDerivedCleared(this);for(let e of this._dependencies)e.removeObserver(this);this._dependencies.clear(),this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._delayedStore!==void 0&&(this._delayedStore.dispose(),this._delayedStore=void 0),this._handleLastObserverRemoved?.()}get(){if(this._isComputing,this._observers.size===0){let n;try{this._isReaderValid=!0;let i;this._changeTracker&&(i=this._changeTracker.createChangeSummary(void 0),this._changeTracker.beforeUpdate?.(this,i)),n=this._computeFn(this,i)}finally{this._isReaderValid=!1}return this.onLastObserverRemoved(),n}else{do{if(this._state===1){for(let n of this._dependencies)if(n.reportChanges(),this._state===2)break}this._state===1&&(this._state=3),this._state!==3&&this._recompute()}while(this._state!==3);return this._value}}_recompute(){let e=!1;this._isComputing=!0,this._didReportChange=!1;let n=this._dependenciesToBeRemoved;this._dependenciesToBeRemoved=this._dependencies,this._dependencies=n;try{let i=this._changeSummary;this._isReaderValid=!0,this._changeTracker&&(this._isInBeforeUpdate=!0,this._changeTracker.beforeUpdate?.(this,i),this._isInBeforeUpdate=!1,this._changeSummary=this._changeTracker?.createChangeSummary(i));let o=this._state!==0,s=this._value;this._state=3;let a=this._delayedStore;a!==void 0&&(this._delayedStore=void 0);try{this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._value=this._computeFn(this,i)}finally{this._isReaderValid=!1;for(let l of this._dependenciesToBeRemoved)l.removeObserver(this);this._dependenciesToBeRemoved.clear(),a!==void 0&&a.dispose()}e=this._didReportChange||o&&!this._equalityComparator(s,this._value),te()?.handleObservableUpdated(this,{oldValue:s,newValue:this._value,change:void 0,didChange:e,hadValue:o})}catch(i){Pt(i)}if(this._isComputing=!1,!this._didReportChange&&e)for(let i of this._observers)i.handleChange(this,void 0);else this._didReportChange=!1}toString(){return`LazyDerived<${this.debugName}>`}beginUpdate(e){if(this._isUpdating)throw new X("Cyclic deriveds are not supported yet!");this._updateCount++,this._isUpdating=!0;try{let n=this._updateCount===1;if(this._state===3&&(this._state=1,!n))for(let i of this._observers)i.handlePossibleChange(this);if(n)for(let i of this._observers)i.beginUpdate(this)}finally{this._isUpdating=!1}}endUpdate(e){if(this._updateCount--,this._updateCount===0){let n=[...this._observers];for(let i of n)i.endUpdate(this);if(this._removedObserverToCallEndUpdateOn){let i=[...this._removedObserverToCallEndUpdateOn];this._removedObserverToCallEndUpdateOn=null;for(let o of i)o.endUpdate(this)}}br(()=>this._updateCount>=0)}handlePossibleChange(e){if(this._state===3&&this._dependencies.has(e)&&!this._dependenciesToBeRemoved.has(e)){this._state=1;for(let n of this._observers)n.handlePossibleChange(this)}}handleChange(e,n){if(this._dependencies.has(e)&&!this._dependenciesToBeRemoved.has(e)||this._isInBeforeUpdate){te()?.handleDerivedDependencyChanged(this,e,n);let i=!1;try{i=this._changeTracker?this._changeTracker.handleChange({changedObservable:e,change:n,didChange:s=>s===e},this._changeSummary):!0}catch(s){Pt(s)}let o=this._state===3;if(i&&(this._state===1||o)&&(this._state=2,o))for(let s of this._observers)s.handlePossibleChange(this)}}_ensureReaderValid(){if(!this._isReaderValid)throw new X("The reader object cannot be used outside its compute function!")}readObservable(e){this._ensureReaderValid(),e.addObserver(this);let n=e.get();return this._dependencies.add(e),this._dependenciesToBeRemoved.delete(e),n}reportChange(e){this._ensureReaderValid(),this._didReportChange=!0;for(let n of this._observers)n.handleChange(this,e)}get store(){return this._ensureReaderValid(),this._store===void 0&&(this._store=new N),this._store}get delayedStore(){return this._ensureReaderValid(),this._delayedStore===void 0&&(this._delayedStore=new N),this._delayedStore}addObserver(e){let n=!this._observers.has(e)&&this._updateCount>0;super.addObserver(e),n&&(this._removedObserverToCallEndUpdateOn?.delete(e)||e.beginUpdate(this))}removeObserver(e){this._observers.has(e)&&this._updateCount>0&&(this._removedObserverToCallEndUpdateOn||(this._removedObserverToCallEndUpdateOn=new Set),this._removedObserverToCallEndUpdateOn.add(e)),super.removeObserver(e)}debugGetState(){return{state:this._state,stateStr:Ah(this._state),updateCount:this._updateCount,isComputing:this._isComputing,dependencies:this._dependencies,value:this._value}}debugSetValue(e){this._value=e}debugRecompute(){this.beginUpdate(this);try{this._isComputing?this._state=2:this._recompute()}finally{this.endUpdate(this)}}setValue(e,n,i){this._value=e;let o=this._observers;n.updateObserver(this,this);for(let s of o)s.handleChange(this,i)}};function Sa(r,t,e=de.ofCaller()){return new _e(new ke(r.owner,r.debugName,r.debugReferenceFn),t,void 0,r.onLastObserverRemoved,r.equalsFn??Ge,e)}Pu(Sa);function Kn(...r){let t,e,n,i;return r.length===2?[e,n]=r:[t,e,n,i]=r,new Je(new ke(t,void 0,n),e,n,()=>Je.globalTransaction,Ge,i??de.ofCaller())}var Je=class extends et{constructor(e,n,i,o,s,a){super(a);this._debugNameData=e;this.event=n;this._getValue=i;this._getTransaction=o;this._equalityComparator=s;this._hasValue=!1;this.handleEvent=e=>{let n=this._getValue(e),i=this._value,o=!this._hasValue||!this._equalityComparator(i,n),s=!1;o&&(this._value=n,this._hasValue&&(s=!0,va(this._getTransaction(),a=>{te()?.handleObservableUpdated(this,{oldValue:i,newValue:n,change:void 0,didChange:o,hadValue:this._hasValue});for(let l of this._observers)a.updateObserver(l,this),l.handleChange(this,void 0)},()=>{let a=this.getDebugName();return"Event fired"+(a?`: ${a}`:"")})),this._hasValue=!0),s||te()?.handleObservableUpdated(this,{oldValue:i,newValue:n,change:void 0,didChange:o,hadValue:this._hasValue})}}getDebugName(){return this._debugNameData.getDebugName(this)}get debugName(){let e=this.getDebugName();return"From Event"+(e?`: ${e}`:"")}onFirstObserverAdded(){this._subscription=this.event(this.handleEvent)}onLastObserverRemoved(){this._subscription.dispose(),this._subscription=void 0,this._hasValue=!1,this._value=void 0}get(){return this._subscription?(this._hasValue||this.handleEvent(void 0),this._value):this._getValue(void 0)}debugSetValue(e){this._value=e}debugGetState(){return{value:this._value,hasValue:this._hasValue}}};(e=>{e.Observer=Je;function t(n,i){let o=!1;Je.globalTransaction===void 0&&(Je.globalTransaction=n,o=!0);try{i()}finally{o&&(Je.globalTransaction=void 0)}}e.batchEventsGlobally=t})(Kn||={});function Uu(r){let t=new ro(!1,void 0);return r.addObserver(t),O(()=>{r.removeObserver(t)})}Ou(Uu);function Nu(r,t){let e=new ro(!0,t);r.addObserver(e);try{e.beginUpdate(r)}finally{e.endUpdate(r)}return O(()=>{r.removeObserver(e)})}ku(Nu);var ro=class{constructor(t,e){this._forceRecompute=t;this._handleValue=e;this._counter=0}beginUpdate(t){this._counter++}endUpdate(t){this._counter===1&&this._forceRecompute&&(this._handleValue?this._handleValue(t.get()):t.reportChanges()),this._counter--}handlePossibleChange(t){}handleChange(t,e){}};var io;function Wu(r){io||(io=new Hr,Kr(io)),io.addFilteredObj(r)}var Hr=class{constructor(){this.indentation=0;this.changedObservablesSets=new WeakMap}addFilteredObj(t){this._filteredObjects||(this._filteredObjects=new Set),this._filteredObjects.add(t)}_isIncluded(t){return this._filteredObjects?.has(t)??!0}textToConsoleArgs(t){return Uh([jn(Wh("|  ",this.indentation)),t])}formatInfo(t){return t.hadValue?t.didChange?[jn(" "),Qe(qe(t.oldValue,70),{color:"red",strikeThrough:!0}),jn(" "),Qe(qe(t.newValue,60),{color:"green"})]:[jn(" (unchanged)")]:[jn(" "),Qe(qe(t.newValue,60),{color:"green"}),jn(" (initial)")]}handleObservableCreated(t){if(t instanceof _e){let e=t;if(this.changedObservablesSets.set(e,new Set),!1){let i=[];e.__debugUpdating=i;let o=e.beginUpdate;e.beginUpdate=a=>(i.push(a),o.apply(e,[a]));let s=e.endUpdate;e.endUpdate=a=>{let l=i.indexOf(a);return l===-1&&console.error("endUpdate called without beginUpdate",e.debugName,a.debugName),i.splice(l,1),s.apply(e,[a])}}}}handleOnListenerCountChanged(t,e){}handleObservableUpdated(t,e){if(this._isIncluded(t)){if(t instanceof _e){this._handleDerivedRecomputed(t,e);return}console.log(...this.textToConsoleArgs([zn("observable value changed"),Qe(t.debugName,{color:"BlueViolet"}),...this.formatInfo(e)]))}}formatChanges(t){if(t.size!==0)return Qe(" (changed deps: "+[...t].map(e=>e.debugName).join(", ")+")",{color:"gray"})}handleDerivedDependencyChanged(t,e,n){this._isIncluded(t)&&this.changedObservablesSets.get(t)?.add(e)}_handleDerivedRecomputed(t,e){if(!this._isIncluded(t))return;let n=this.changedObservablesSets.get(t);n&&(console.log(...this.textToConsoleArgs([zn("derived recomputed"),Qe(t.debugName,{color:"BlueViolet"}),...this.formatInfo(e),this.formatChanges(n),{data:[{fn:t._debugNameData.referenceFn??t._computeFn}]}])),n.clear())}handleDerivedCleared(t){this._isIncluded(t)&&console.log(...this.textToConsoleArgs([zn("derived cleared"),Qe(t.debugName,{color:"BlueViolet"})]))}handleFromEventObservableTriggered(t,e){this._isIncluded(t)&&console.log(...this.textToConsoleArgs([zn("observable from event triggered"),Qe(t.debugName,{color:"BlueViolet"}),...this.formatInfo(e),{data:[{fn:t._getValue}]}]))}handleAutorunCreated(t){this._isIncluded(t)&&this.changedObservablesSets.set(t,new Set)}handleAutorunDisposed(t){}handleAutorunDependencyChanged(t,e,n){this._isIncluded(t)&&this.changedObservablesSets.get(t).add(e)}handleAutorunStarted(t){let e=this.changedObservablesSets.get(t);e&&(this._isIncluded(t)&&console.log(...this.textToConsoleArgs([zn("autorun"),Qe(t.debugName,{color:"BlueViolet"}),this.formatChanges(e),{data:[{fn:t._debugNameData.referenceFn??t._runFn}]}])),e.clear(),this.indentation++)}handleAutorunFinished(t){this.indentation--}handleBeginTransaction(t){let e=t.getDebugName();e===void 0&&(e=""),this._isIncluded(t)&&console.log(...this.textToConsoleArgs([zn("transaction"),Qe(e,{color:"BlueViolet"}),{data:[{fn:t._fn}]}])),this.indentation++}handleEndTransaction(){this.indentation--}};function Uh(r){let t=new Array,e=[],n="";function i(s){if("length"in s)for(let a of s)a&&i(a);else"text"in s?(n+=`%c${s.text}`,t.push(s.style),s.data&&e.push(...s.data)):"data"in s&&e.push(...s.data)}i(r);let o=[n,...t];return o.push(...e),o}function jn(r){return Qe(r,{color:"black"})}function zn(r){return Qe(Bh(`${r}: `,10),{color:"black",bold:!0})}function Qe(r,t={color:"black"}){function e(i){return Object.entries(i).reduce((o,[s,a])=>`${o}${s}:${a};`,"")}let n={color:t.color};return t.strikeThrough&&(n["text-decoration"]="line-through"),t.bold&&(n["font-weight"]="bold"),{text:r,style:e(n)}}function qe(r,t){switch(typeof r){case"number":return""+r;case"string":return r.length+2<=t?`"${r}"`:`"${r.substr(0,t-7)}"+...`;case"boolean":return r?"true":"false";case"undefined":return"undefined";case"object":return r===null?"null":Array.isArray(r)?Nh(r,t):Mh(r,t);case"symbol":return r.toString();case"function":return`[[Function${r.name?" "+r.name:""}]]`;default:return""+r}}function Nh(r,t){let e="[ ",n=!0;for(let i of r){if(n||(e+=", "),e.length-5>t){e+="...";break}n=!1,e+=`${qe(i,t-e.length)}`}return e+=" ]",e}function Mh(r,t){if(typeof r.toString=="function"&&r.toString!==Object.prototype.toString){let o=r.toString();return o.length<=t?o:o.substring(0,t-3)+"..."}let e=ha(r),n=e?e+"(":"{ ",i=!0;for(let[o,s]of Object.entries(r)){if(i||(n+=", "),n.length-5>t){n+="...";break}i=!1,n+=`${o}: ${qe(s,t-n.length)}`}return n+=e?")":" }",n}function Wh(r,t){let e="";for(let n=1;n<=t;n++)e+=r;return e}function Bh(r,t){for(;r.length<t;)r+=" ";return r}var oo=class r{constructor(t,e){this._channelFactory=t;this._getHandler=e;this._channel=this._channelFactory({handleNotification:o=>{let s=o,a=this._getHandler().notifications[s[0]];if(!a)throw new Error(`Unknown notification "${s[0]}"!`);a(...s[1])},handleRequest:o=>{let s=o;try{return{type:"result",value:this._getHandler().requests[s[0]](...s[1])}}catch(a){return{type:"error",value:a}}}});let n=new Proxy({},{get:(o,s)=>async(...a)=>{let l=await this._channel.sendRequest([s,a]);if(l.type==="error")throw l.value;return l.value}}),i=new Proxy({},{get:(o,s)=>(...a)=>{this._channel.sendNotification([s,a])}});this.api={notifications:i,requests:n}}static createHost(t,e){return new r(t,e)}static createClient(t,e){return new r(t,e)}};function Bu(r,t){let e=globalThis,n=[],i,{channel:o,handler:s}=qh({sendNotification:l=>{i?i.sendNotification(l):n.push(l)}}),a;return(e.$$debugValueEditor_debugChannels??(e.$$debugValueEditor_debugChannels={}))[r]=l=>{a=t(),i=l;for(let c of n)l.sendNotification(c);return n=[],s},oo.createClient(o,()=>{if(!a)throw new Error("Not supported");return a})}function qh(r){let t;return{channel:n=>(t=n,{sendNotification:i=>{r.sendNotification(i)},sendRequest:i=>{throw new Error("not supported")}}),handler:{handleRequest:n=>n.type==="notification"?t?.handleNotification(n.data):t?.handleRequest(n.data)}}}var so=class{constructor(){this._timeout=void 0}throttle(t,e){this._timeout===void 0&&(this._timeout=setTimeout(()=>{this._timeout=void 0,t()},e))}dispose(){this._timeout!==void 0&&clearTimeout(this._timeout)}};function _a(r,t){for(let e in t)r[e]&&typeof r[e]=="object"&&t[e]&&typeof t[e]=="object"?_a(r[e],t[e]):r[e]=t[e]}function xa(r,t){for(let e in t)t[e]===null?delete r[e]:r[e]&&typeof r[e]=="object"&&t[e]&&typeof t[e]=="object"?xa(r[e],t[e]):r[e]=t[e]}var ao=class r{constructor(){this._declarationId=0;this._instanceId=0;this._declarations=new Map;this._instanceInfos=new WeakMap;this._aliveInstances=new Map;this._activeTransactions=new Set;this._channel=Bu("observableDevTools",()=>({notifications:{setDeclarationIdFilter:t=>{},logObservableValue:t=>{console.log("logObservableValue",t)},flushUpdates:()=>{this._flushUpdates()},resetUpdates:()=>{this._pendingChanges=null,this._channel.api.notifications.handleChange(this._fullState,!0)}},requests:{getDeclarations:()=>{let t={};for(let e of this._declarations.values())t[e.id]=e;return{decls:t}},getSummarizedInstances:()=>null,getObservableValueInfo:t=>({observers:[...this._aliveInstances.get(t).debugGetObservers()].map(n=>this._formatObserver(n)).filter(Tn)}),getDerivedInfo:t=>{let e=this._aliveInstances.get(t);return{dependencies:[...e.debugGetState().dependencies].map(n=>this._formatObservable(n)).filter(Tn),observers:[...e.debugGetObservers()].map(n=>this._formatObserver(n)).filter(Tn)}},getAutorunInfo:t=>({dependencies:[...this._aliveInstances.get(t).debugGetState().dependencies].map(n=>this._formatObservable(n)).filter(Tn)}),getTransactionState:()=>this.getTransactionState(),setValue:(t,e)=>{let n=this._aliveInstances.get(t);if(n instanceof _e)n.debugSetValue(e);else if(n instanceof Tt)n.debugSetValue(e);else if(n instanceof Je)n.debugSetValue(e);else throw new X("Observable is not supported");let i=[...n.debugGetObservers()];for(let o of i)o.beginUpdate(n);for(let o of i)o.handleChange(n,void 0);for(let o of i)o.endUpdate(n)},getValue:t=>{let e=this._aliveInstances.get(t);if(e instanceof _e)return qe(e.debugGetState().value,200);if(e instanceof Tt)return qe(e.debugGetState().value,200)},logValue:t=>{let e=this._aliveInstances.get(t);if(e&&"get"in e)console.log("Logged Value:",e.get());else throw new X("Observable is not supported")},rerun:t=>{let e=this._aliveInstances.get(t);if(e instanceof _e)e.debugRecompute();else if(e instanceof St)e.debugRerun();else throw new X("Observable is not supported")}}}));this._pendingChanges=null;this._changeThrottler=new so;this._fullState={};this._flushUpdates=()=>{this._pendingChanges!==null&&(this._channel.api.notifications.handleChange(this._pendingChanges,!1),this._pendingChanges=null)};de.enable()}static{this._instance=void 0}static getInstance(){return r._instance===void 0&&(r._instance=new r),r._instance}getTransactionState(){let t=[],e=[...this._activeTransactions];if(e.length===0)return;let n=e.flatMap(o=>o.debugGetUpdatingObservers()??[]).map(o=>o.observer),i=new Set;for(;n.length>0;){let o=n.shift();if(i.has(o))continue;i.add(o);let s=this._getInfo(o,a=>{i.has(a)||n.push(a)});s&&t.push(s)}return{names:e.map(o=>o.getDebugName()??"tx"),affected:t}}_getObservableInfo(t){let e=this._instanceInfos.get(t);if(!e){oe(new X("No info found"));return}return e}_getAutorunInfo(t){let e=this._instanceInfos.get(t);if(!e){oe(new X("No info found"));return}return e}_getInfo(t,e){if(t instanceof _e){let n=[...t.debugGetObservers()];for(let l of n)e(l);let i=this._getObservableInfo(t);if(!i)return;let o=t.debugGetState(),s={name:t.debugName,instanceId:i.instanceId,updateCount:o.updateCount},a=[...i.changedObservables].map(l=>this._instanceInfos.get(l)?.instanceId).filter(Tn);if(o.isComputing)return{...s,type:"observable/derived",state:"updating",changedDependencies:a,initialComputation:!1};switch(o.state){case 0:return{...s,type:"observable/derived",state:"noValue"};case 3:return{...s,type:"observable/derived",state:"upToDate"};case 2:return{...s,type:"observable/derived",state:"stale",changedDependencies:a};case 1:return{...s,type:"observable/derived",state:"possiblyStale"}}}else if(t instanceof St){let n=this._getAutorunInfo(t);if(!n)return;let i={name:t.debugName,instanceId:n.instanceId,updateCount:n.updateCount},o=[...n.changedObservables].map(s=>this._instanceInfos.get(s).instanceId);if(t.debugGetState().isRunning)return{...i,type:"autorun",state:"updating",changedDependencies:o};switch(t.debugGetState().state){case 3:return{...i,type:"autorun",state:"upToDate"};case 2:return{...i,type:"autorun",state:"stale",changedDependencies:o};case 1:return{...i,type:"autorun",state:"possiblyStale"}}}}_formatObservable(t){let e=this._getObservableInfo(t);if(e)return{name:t.debugName,instanceId:e.instanceId}}_formatObserver(t){if(t instanceof _e)return{name:t.toString(),instanceId:this._getObservableInfo(t)?.instanceId};let e=this._getAutorunInfo(t);if(e)return{name:t.toString(),instanceId:e.instanceId}}_handleChange(t){xa(this._fullState,t),this._pendingChanges===null?this._pendingChanges=t:_a(this._pendingChanges,t),this._changeThrottler.throttle(this._flushUpdates,10)}_getDeclarationId(t,e){if(!e)return-1;let n=this._declarations.get(e.id);return n===void 0&&(n={id:this._declarationId++,type:t,url:e.fileName,line:e.line,column:e.column},this._declarations.set(e.id,n),this._handleChange({decls:{[n.id]:n}})),n.id}handleObservableCreated(t,e){let i={declarationId:this._getDeclarationId("observable/value",e),instanceId:this._instanceId++,listenerCount:0,lastValue:void 0,updateCount:0,changedObservables:new Set};this._instanceInfos.set(t,i)}handleOnListenerCountChanged(t,e){let n=this._getObservableInfo(t);if(n){if(n.listenerCount===0&&e>0){let i=t instanceof _e?"observable/derived":"observable/value";this._aliveInstances.set(n.instanceId,t),this._handleChange({instances:{[n.instanceId]:{instanceId:n.instanceId,declarationId:n.declarationId,formattedValue:n.lastValue,type:i,name:t.debugName}}})}else n.listenerCount>0&&e===0&&(this._handleChange({instances:{[n.instanceId]:null}}),this._aliveInstances.delete(n.instanceId));n.listenerCount=e}}handleObservableUpdated(t,e){if(t instanceof _e){this._handleDerivedRecomputed(t,e);return}let n=this._getObservableInfo(t);n&&e.didChange&&(n.lastValue=qe(e.newValue,30),n.listenerCount>0&&this._handleChange({instances:{[n.instanceId]:{formattedValue:n.lastValue}}}))}handleAutorunCreated(t,e){let i={declarationId:this._getDeclarationId("autorun",e),instanceId:this._instanceId++,updateCount:0,changedObservables:new Set};this._instanceInfos.set(t,i),this._aliveInstances.set(i.instanceId,t),i&&this._handleChange({instances:{[i.instanceId]:{instanceId:i.instanceId,declarationId:i.declarationId,runCount:0,type:"autorun",name:t.debugName}}})}handleAutorunDisposed(t){let e=this._getAutorunInfo(t);e&&(this._handleChange({instances:{[e.instanceId]:null}}),this._instanceInfos.delete(t),this._aliveInstances.delete(e.instanceId))}handleAutorunDependencyChanged(t,e,n){let i=this._getAutorunInfo(t);i&&i.changedObservables.add(e)}handleAutorunStarted(t){}handleAutorunFinished(t){let e=this._getAutorunInfo(t);e&&(e.changedObservables.clear(),e.updateCount++,this._handleChange({instances:{[e.instanceId]:{runCount:e.updateCount}}}))}handleDerivedDependencyChanged(t,e,n){let i=this._getObservableInfo(t);i&&i.changedObservables.add(e)}_handleDerivedRecomputed(t,e){let n=this._getObservableInfo(t);if(!n)return;let i=qe(e.newValue,30);n.updateCount++,n.changedObservables.clear(),n.lastValue=i,n.listenerCount>0&&this._handleChange({instances:{[n.instanceId]:{formattedValue:i,recomputationCount:n.updateCount}}})}handleDerivedCleared(t){let e=this._getObservableInfo(t);e&&(e.lastValue=void 0,e.changedObservables.clear(),e.listenerCount>0&&this._handleChange({instances:{[e.instanceId]:{formattedValue:void 0}}}))}handleBeginTransaction(t){this._activeTransactions.add(t)}handleEndTransaction(t){this._activeTransactions.delete(t)}};function qu(r,t){let e=t?.debugNamePostProcessor??(o=>o),n=pn.from(r,e);if(!n)return"";let i=new Set;return t.type==="observers"?$u(n,0,i,t).trim():Vu(n,0,i,t).trim()}function Vu(r,t,e,n){let i="		".repeat(t),o=[];if(e.has(r.sourceObj))return o.push(`${i}* ${r.type} ${r.name} (already listed)`),o.join(`
`);if(e.add(r.sourceObj),o.push(`${i}* ${r.type} ${r.name}:`),o.push(`${i}  value: ${qe(r.value,50)}`),o.push(`${i}  state: ${r.state}`),r.dependencies.length>0){o.push(`${i}  dependencies:`);for(let a of r.dependencies){let l=pn.from(a,n.debugNamePostProcessor??(c=>c))??pn.unknown(a);o.push(Vu(l,t+1,e,n))}}return o.join(`
`)}function $u(r,t,e,n){let i="		".repeat(t),o=[];if(e.has(r.sourceObj))return o.push(`${i}* ${r.type} ${r.name} (already listed)`),o.join(`
`);if(e.add(r.sourceObj),o.push(`${i}* ${r.type} ${r.name}:`),o.push(`${i}  value: ${qe(r.value,50)}`),o.push(`${i}  state: ${r.state}`),r.observers.length>0){o.push(`${i}  observers:`);for(let a of r.observers){let l=pn.from(a,n.debugNamePostProcessor??(c=>c))??pn.unknown(a);o.push($u(l,t+1,e,n))}}return o.join(`
`)}var pn=class r{constructor(t,e,n,i,o,s,a){this.sourceObj=t;this.name=e;this.type=n;this.value=i;this.state=o;this.dependencies=s;this.observers=a}static from(t,e){if(t instanceof St){let n=t.debugGetState();return new r(t,e(t.debugName),"autorun",void 0,n.stateStr,Array.from(n.dependencies),[])}else if(t instanceof _e){let n=t.debugGetState();return new r(t,e(t.debugName),"derived",n.value,n.stateStr,Array.from(n.dependencies),Array.from(t.debugGetObservers()))}else if(t instanceof Tt){let n=t.debugGetState();return new r(t,e(t.debugName),"observableValue",n.value,"upToDate",[],Array.from(t.debugGetObservers()))}else if(t instanceof Je){let n=t.debugGetState();return new r(t,e(t.debugName),"fromEvent",n.value,n.hasValue?"upToDate":"initial",[],Array.from(t.debugGetObservers()))}}static unknown(t){return new r(t,"(unknown)","unknown",void 0,"unknown",[],[])}};Lu(qu);wu(Wu);var Vh=!1;Vh&&Kr(new Hr);Te&&Te.VSCODE_DEV_DEBUG_OBSERVABLES&&Kr(ao.getInstance());var ge=(function(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID.bind(crypto);let r=new Uint8Array(16),t=[];for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,"0"));return function(){crypto.getRandomValues(r),r[6]=r[6]&15|64,r[8]=r[8]&63|128;let n=0,i="";return i+=t[r[n++]],i+=t[r[n++]],i+=t[r[n++]],i+=t[r[n++]],i+="-",i+=t[r[n++]],i+=t[r[n++]],i+="-",i+=t[r[n++]],i+=t[r[n++]],i+="-",i+=t[r[n++]],i+=t[r[n++]],i+="-",i+=t[r[n++]],i+=t[r[n++]],i+=t[r[n++]],i+=t[r[n++]],i+=t[r[n++]],i+=t[r[n++]],i}})();var Ra=class{constructor(){this._value="";this._pos=0}reset(t){return this._value=t,this._pos=0,this}next(){return this._pos+=1,this}hasNext(){return this._pos<this._value.length-1}cmp(t){let e=t.charCodeAt(0),n=this._value.charCodeAt(this._pos);return e-n}value(){return this._value[this._pos]}},Ea=class{constructor(t=!0){this._caseSensitive=t}reset(t){return this._value=t,this._from=0,this._to=0,this.next()}hasNext(){return this._to<this._value.length}next(){this._from=this._to;let t=!0;for(;this._to<this._value.length;this._to++)if(this._value.charCodeAt(this._to)===46)if(t)this._from++;else break;else t=!1;return this}cmp(t){return this._caseSensitive?ki(t,this._value,0,t.length,this._from,this._to):nn(t,this._value,0,t.length,this._from,this._to)}value(){return this._value.substring(this._from,this._to)}},lo=class{constructor(t=!0,e=!0){this._splitOnBackslash=t;this._caseSensitive=e}reset(t){this._from=0,this._to=0,this._value=t,this._valueLen=t.length;for(let e=t.length-1;e>=0;e--,this._valueLen--){let n=this._value.charCodeAt(e);if(!(n===47||this._splitOnBackslash&&n===92))break}return this.next()}hasNext(){return this._to<this._valueLen}next(){this._from=this._to;let t=!0;for(;this._to<this._valueLen;this._to++){let e=this._value.charCodeAt(this._to);if(e===47||this._splitOnBackslash&&e===92)if(t)this._from++;else break;else t=!1}return this}cmp(t){return this._caseSensitive?ki(t,this._value,0,t.length,this._from,this._to):nn(t,this._value,0,t.length,this._from,this._to)}value(){return this._value.substring(this._from,this._to)}};var wa=class{constructor(t,e){this._ignorePathCasing=t;this._ignoreQueryAndFragment=e;this._states=[];this._stateIdx=0}reset(t){return this._value=t,this._states=[],this._value.scheme&&this._states.push(1),this._value.authority&&this._states.push(2),this._value.path&&(this._pathIterator=new lo(!1,!this._ignorePathCasing(t)),this._pathIterator.reset(t.path),this._pathIterator.value()&&this._states.push(3)),this._ignoreQueryAndFragment(t)||(this._value.query&&this._states.push(4),this._value.fragment&&this._states.push(5)),this._stateIdx=0,this}next(){return this._states[this._stateIdx]===3&&this._pathIterator.hasNext()?this._pathIterator.next():this._stateIdx+=1,this}hasNext(){return this._states[this._stateIdx]===3&&this._pathIterator.hasNext()||this._stateIdx<this._states.length-1}cmp(t){if(this._states[this._stateIdx]===1)return qs(t,this._value.scheme);if(this._states[this._stateIdx]===2)return qs(t,this._value.authority);if(this._states[this._stateIdx]===3)return this._pathIterator.cmp(t);if(this._states[this._stateIdx]===4)return Pr(t,this._value.query);if(this._states[this._stateIdx]===5)return Pr(t,this._value.fragment);throw new Error}value(){if(this._states[this._stateIdx]===1)return this._value.scheme;if(this._states[this._stateIdx]===2)return this._value.authority;if(this._states[this._stateIdx]===3)return this._pathIterator.value();if(this._states[this._stateIdx]===4)return this._value.query;if(this._states[this._stateIdx]===5)return this._value.fragment;throw new Error}},_t=class r{static{this.Val=Symbol("undefined_placeholder")}static wrap(t){return t===void 0?r.Val:t}static unwrap(t){return t===r.Val?void 0:t}},Hn=class{constructor(){this.height=1;this.value=void 0;this.key=void 0;this.left=void 0;this.mid=void 0;this.right=void 0}isEmpty(){return!this.left&&!this.mid&&!this.right&&this.value===void 0}rotateLeft(){let t=this.right;return this.right=t.left,t.left=this,this.updateHeight(),t.updateHeight(),t}rotateRight(){let t=this.left;return this.left=t.right,t.right=this,this.updateHeight(),t.updateHeight(),t}updateHeight(){this.height=1+Math.max(this.heightLeft,this.heightRight)}balanceFactor(){return this.heightRight-this.heightLeft}get heightLeft(){return this.left?.height??0}get heightRight(){return this.right?.height??0}};var qt=class r{static forUris(t=()=>!1,e=()=>!1){return new r(new wa(t,e))}static forPaths(t=!1){return new r(new lo(void 0,!t))}static forStrings(){return new r(new Ra)}static forConfigKeys(){return new r(new Ea)}constructor(t){this._iter=t}clear(){this._root=void 0}fill(t,e){if(e){let n=e.slice(0);Ts(n);for(let i of n)this.set(i,t)}else{let n=t.slice(0);Ts(n);for(let i of n)this.set(i[0],i[1])}}set(t,e){let n=this._iter.reset(t),i;this._root||(this._root=new Hn,this._root.segment=n.value());let o=[];for(i=this._root;;){let a=n.cmp(i.segment);if(a>0)i.left||(i.left=new Hn,i.left.segment=n.value()),o.push([-1,i]),i=i.left;else if(a<0)i.right||(i.right=new Hn,i.right.segment=n.value()),o.push([1,i]),i=i.right;else if(n.hasNext())n.next(),i.mid||(i.mid=new Hn,i.mid.segment=n.value()),o.push([0,i]),i=i.mid;else break}let s=_t.unwrap(i.value);i.value=_t.wrap(e),i.key=t;for(let a=o.length-1;a>=0;a--){let l=o[a][1];l.updateHeight();let c=l.balanceFactor();if(c<-1||c>1){let d=o[a][0],u=o[a+1][0];if(d===1&&u===1)o[a][1]=l.rotateLeft();else if(d===-1&&u===-1)o[a][1]=l.rotateRight();else if(d===1&&u===-1)l.right=o[a+1][1]=o[a+1][1].rotateRight(),o[a][1]=l.rotateLeft();else if(d===-1&&u===1)l.left=o[a+1][1]=o[a+1][1].rotateLeft(),o[a][1]=l.rotateRight();else throw new Error;if(a>0)switch(o[a-1][0]){case-1:o[a-1][1].left=o[a][1];break;case 1:o[a-1][1].right=o[a][1];break;case 0:o[a-1][1].mid=o[a][1];break}else this._root=o[0][1]}}return s}get(t){return _t.unwrap(this._getNode(t)?.value)}_getNode(t){let e=this._iter.reset(t),n=this._root;for(;n;){let i=e.cmp(n.segment);if(i>0)n=n.left;else if(i<0)n=n.right;else if(e.hasNext())e.next(),n=n.mid;else break}return n}has(t){let e=this._getNode(t);return!(e?.value===void 0&&e?.mid===void 0)}delete(t){return this._delete(t,!1)}deleteSuperstr(t){return this._delete(t,!0)}_delete(t,e){let n=this._iter.reset(t),i=[],o=this._root;for(;o;){let s=n.cmp(o.segment);if(s>0)i.push([-1,o]),o=o.left;else if(s<0)i.push([1,o]),o=o.right;else if(n.hasNext())n.next(),i.push([0,o]),o=o.mid;else break}if(o){if(e?(o.left=void 0,o.mid=void 0,o.right=void 0,o.height=1):(o.key=void 0,o.value=void 0),!o.mid&&!o.value)if(o.left&&o.right){let s=[[1,o]],a=this._min(o.right,s);if(a.key){o.key=a.key,o.value=a.value,o.segment=a.segment;let l=a.right;if(s.length>1){let[d,u]=s[s.length-1];switch(d){case-1:u.left=l;break;case 0:Ii(!1);case 1:Ii(!1)}}else o.right=l;let c=this._balanceByStack(s);if(i.length>0){let[d,u]=i[i.length-1];switch(d){case-1:u.left=c;break;case 0:u.mid=c;break;case 1:u.right=c;break}}else this._root=c}}else{let s=o.left??o.right;if(i.length>0){let[a,l]=i[i.length-1];switch(a){case-1:l.left=s;break;case 0:l.mid=s;break;case 1:l.right=s;break}}else this._root=s}this._root=this._balanceByStack(i)??this._root}}_min(t,e){for(;t.left;)e.push([-1,t]),t=t.left;return t}_balanceByStack(t){for(let e=t.length-1;e>=0;e--){let n=t[e][1];n.updateHeight();let i=n.balanceFactor();if(i>1?(n.right.balanceFactor()>=0||(n.right=n.right.rotateRight()),t[e][1]=n.rotateLeft()):i<-1&&(n.left.balanceFactor()<=0||(n.left=n.left.rotateLeft()),t[e][1]=n.rotateRight()),e>0)switch(t[e-1][0]){case-1:t[e-1][1].left=t[e][1];break;case 1:t[e-1][1].right=t[e][1];break;case 0:t[e-1][1].mid=t[e][1];break}else return t[0][1]}}findSubstr(t){let e=this._iter.reset(t),n=this._root,i;for(;n;){let o=e.cmp(n.segment);if(o>0)n=n.left;else if(o<0)n=n.right;else if(e.hasNext())e.next(),i=_t.unwrap(n.value)||i,n=n.mid;else break}return n&&_t.unwrap(n.value)||i}findSuperstr(t){return this._findSuperstrOrElement(t,!1)}_findSuperstrOrElement(t,e){let n=this._iter.reset(t),i=this._root;for(;i;){let o=n.cmp(i.segment);if(o>0)i=i.left;else if(o<0)i=i.right;else if(n.hasNext())n.next(),i=i.mid;else return i.mid?this._entries(i.mid):e?_t.unwrap(i.value):void 0}}hasElementOrSubtree(t){return this._findSuperstrOrElement(t,!0)!==void 0}forEach(t){for(let[e,n]of this)t(n,e)}*[Symbol.iterator](){yield*this._entries(this._root)}_entries(t){let e=[];return this._dfsEntries(t,e),e[Symbol.iterator]()}_dfsEntries(t,e){t&&(t.left&&this._dfsEntries(t.left,e),t.value!==void 0&&e.push([t.key,_t.unwrap(t.value)]),t.mid&&this._dfsEntries(t.mid,e),t.right&&this._dfsEntries(t.right,e))}_isBalanced(){let t=e=>{if(!e)return!0;let n=e.balanceFactor();return n<-1||n>1?!1:t(e.left)&&t(e.right)};return t(this._root)}};var tt=Le("fileService");function fn(r){return r.create===!0}function Ve(r){return!!(r.capabilities&2)}function Ku(r){return!!(r.capabilities&524288)}function Ca(r){return!!(r.capabilities&8)}function ju(r){return!!(r.capabilities&131072)}function zu(r){return!!(r.capabilities&262144)}function Rt(r){return!!(r.capabilities&4)}function po(r){return!!(r.capabilities&16)}function fo(r){return Ve(r)?!!(r.capabilities&16384):!1}function Pa(r){return Ve(r)?!!(r.capabilities&32768):!1}function Hu(r){return!!(r.capabilities&65536)}var Gn=class r extends Error{constructor(e,n){super(e);this.code=n}static create(e,n){let i=new r(e.toString(),n);return $h(i,n),i}};function pe(r,t){return Gn.create(r,t)}function Et(r){return r||pe(f(2136,null),"Unknown")}function $h(r,t){return r.name=t?`${t} (FileSystemError)`:"FileSystemError",r}function ut(r){if(!r)return"Unknown";if(r instanceof Gn)return r.code;let t=/^(.+) \(FileSystemError\)$/.exec(r.name);if(!t)return"Unknown";switch(t[1]){case"EntryExists":return"EntryExists";case"EntryIsADirectory":return"EntryIsADirectory";case"EntryNotADirectory":return"EntryNotADirectory";case"EntryNotFound":return"EntryNotFound";case"EntryTooLarge":return"EntryTooLarge";case"EntryWriteLocked":return"EntryWriteLocked";case"NoPermissions":return"NoPermissions";case"Unavailable":return"Unavailable"}return"Unknown"}function Aa(r){if(r instanceof me)return r.fileOperationResult;switch(ut(r)){case"EntryNotFound":return 1;case"EntryIsADirectory":return 0;case"EntryNotADirectory":return 9;case"EntryWriteLocked":return 5;case"NoPermissions":return 6;case"EntryExists":return 4;case"EntryTooLarge":return 7;default:return 10}}var xt=class{constructor(t,e,n){this.resource=t;this.operation=e;this.target=n}isOperation(t){return this.operation===t}};var co=class r{constructor(t,e){this.ignorePathCasing=e;this.correlationId=void 0;this.added=new Oe(()=>{let t=qt.forUris(()=>this.ignorePathCasing);return t.fill(this.rawAdded.map(e=>[e,!0])),t});this.updated=new Oe(()=>{let t=qt.forUris(()=>this.ignorePathCasing);return t.fill(this.rawUpdated.map(e=>[e,!0])),t});this.deleted=new Oe(()=>{let t=qt.forUris(()=>this.ignorePathCasing);return t.fill(this.rawDeleted.map(e=>[e,!0])),t});this.rawAdded=[];this.rawUpdated=[];this.rawDeleted=[];for(let n of t){switch(n.type){case 1:this.rawAdded.push(n.resource);break;case 0:this.rawUpdated.push(n.resource);break;case 2:this.rawDeleted.push(n.resource);break}this.correlationId!==r.MIXED_CORRELATION&&(typeof n.cId=="number"?this.correlationId===void 0?this.correlationId=n.cId:this.correlationId!==n.cId&&(this.correlationId=r.MIXED_CORRELATION):this.correlationId!==void 0&&(this.correlationId=r.MIXED_CORRELATION))}}static{this.MIXED_CORRELATION=null}contains(t,...e){return this.doContains(t,{includeChildren:!1},...e)}affects(t,...e){return this.doContains(t,{includeChildren:!0},...e)}doContains(t,e,...n){if(!t)return!1;let i=n.length>0;return!!((!i||n.includes(1))&&(this.added.value.get(t)||e.includeChildren&&this.added.value.findSuperstr(t))||(!i||n.includes(0))&&(this.updated.value.get(t)||e.includeChildren&&this.updated.value.findSuperstr(t))||(!i||n.includes(2))&&(this.deleted.value.findSubstr(t)||e.includeChildren&&this.deleted.value.findSuperstr(t)))}gotAdded(){return this.rawAdded.length>0}gotDeleted(){return this.rawDeleted.length>0}gotUpdated(){return this.rawUpdated.length>0}correlates(t){return this.correlationId===t}hasCorrelation(){return typeof this.correlationId=="number"}};function Gu(r,t,e){return!r||!t||r===t||t.length>r.length?!1:(t.charAt(t.length-1)!==ue&&(t+=ue),e?An(r,t):r.indexOf(t)===0)}var me=class extends Error{constructor(e,n,i){super(e);this.fileOperationResult=n;this.options=i}},Jn=class extends me{constructor(e,n,i,o){super(e,n,o);this.fileOperationResult=n;this.size=i}},Qn=class extends me{constructor(e,n,i){super(e,2,i);this.stat=n}};var ho="";function ka(r){if(!(typeof r.size!="number"||typeof r.mtime!="number"))return r.mtime.toString(29)+r.size.toString(31)}var uo=class r{static{this.KB=1024}static{this.MB=r.KB*r.KB}static{this.GB=r.MB*r.KB}static{this.TB=r.GB*r.KB}static formatSize(t){return Ir(t)||(t=0),t<r.KB?f(2131,null,t.toFixed(0)):t<r.MB?f(2133,null,(t/r.KB).toFixed(2)):t<r.GB?f(2134,null,(t/r.MB).toFixed(2)):t<r.TB?f(2132,null,(t/r.GB).toFixed(2)):f(2135,null,(t/r.TB).toFixed(2))}};function Ju(r){return r.type.startsWith("root/")}function go(r){return r.type.startsWith("session/")}var xe={SessionNotFound:-32001,ProviderNotFound:-32002,SessionAlreadyExists:-32003,TurnInProgress:-32004,UnsupportedProtocolVersion:-32005,ContentNotFound:-32006,AuthRequired:-32007,NotFound:-32008,PermissionDenied:-32009,AlreadyExists:-32010};var Yu=-32700,Xn=-32603,Vt=-32001,Xu=-32002;var Zu=-32005;function ed(r){return"method"in r&&"id"in r}function td(r){return"method"in r&&!("id"in r)}var j=class extends Error{constructor(e,n,i){super(n);this.code=e;this.data=i}};var vo="agenthost:/root";function od(){return{agents:[],activeSessions:0}}function Na(r){return{summary:r,lifecycle:"creating",turns:[],activeTurn:void 0}}var Zn="**",sd="/",yo="[/\\\\]",bo="[^/\\\\]",zh=/\//g;function ad(r,t){switch(r){case 0:return"";case 1:return`${bo}*?`;default:return`(?:${yo}|${bo}+${yo}${t?`|${yo}${bo}+`:""})*?`}}function ld(r,t){if(!r)return[];let e=[],n=!1,i=!1,o="";for(let s of r){switch(s){case t:if(!n&&!i){e.push(o),o="";continue}break;case"{":n=!0;break;case"}":n=!1;break;case"[":i=!0;break;case"]":i=!1;break}o+=s}return o&&e.push(o),e}function fd(r){if(!r)return"";let t="",e=ld(r,sd);if(e.every(n=>n===Zn))t=".*";else{let n=!1;e.forEach((i,o)=>{if(i===Zn){if(n)return;t+=ad(2,o===e.length-1)}else{let s=!1,a="",l=!1,c="";for(let d of i){if(d!=="}"&&s){a+=d;continue}if(l&&(d!=="]"||!c)){let u;d==="-"?u=d:(d==="^"||d==="!")&&!c?u="^":d===sd?u="":u=Ft(d),c+=u;continue}switch(d){case"{":s=!0;continue;case"[":l=!0;continue;case"}":{let p=`(?:${ld(a,",").map(h=>fd(h)).join("|")})`;t+=p,s=!1,a="";break}case"]":{t+="["+c+"]",l=!1,c="";break}case"?":t+=bo;continue;case"*":t+=ad(1);continue;default:t+=Ft(d)}}o<e.length-1&&(e[o+1]!==Zn||o+2<e.length)&&(t+=yo)}n=i===Zn})}return t}var Hh=/^\*\*\/\*\.[\w\.-]+$/,Gh=/^\*\*\/([\w\.-]+)\/?$/,Jh=/^{\*\*\/\*?[\w\.-]+\/?(,\*\*\/\*?[\w\.-]+\/?)*}$/,Qh=/^{\*\*\/\*?[\w\.-]+(\/(\*\*)?)?(,\*\*\/\*?[\w\.-]+(\/(\*\*)?)?)*}$/,Yh=/^\*\*((\/[\w\.-]+)+)\/?$/,Xh=/^([\w\.-]+(\/[\w\.-]+)*)\/?$/,cd=new At(1e4),ud=function(){return!1},dt=function(){return null};function Wa(r,t){if(!r)return dt;let e;typeof r!="string"?e=r.pattern:e=r,e=e.trim();let n=t.ignoreCase??!1,i={...t,equals:n?rn:(l,c)=>l===c,endsWith:n?Ac:(l,c)=>l.endsWith(c),isEqualOrParent:(l,c)=>bt(l,c,t.ignoreCase??!le)},o=`${n?e.toLowerCase():e}_${!!t.trimForExclusions}_${n}`,s=cd.get(o);if(s)return dd(s,r,i);let a;return Hh.test(e)?s=Zh(e.substring(4),e,i):(a=Gh.exec(Ma(e,i)))?s=eg(a[1],e,i):(t.trimForExclusions?Qh:Jh).test(e)?s=tg(e,i):(a=Yh.exec(Ma(e,i)))?s=pd(a[1].substring(1),e,!0,i):(a=Xh.exec(Ma(e,i)))?s=pd(a[1],e,!1,i):s=ng(e,i),cd.set(o,s),dd(s,r,i)}function dd(r,t,e){if(typeof t=="string")return r;let n=function(i,o){return e.isEqualOrParent(i,t.base)?r(Cc(i.substring(t.base.length),ue),o):null};return n.allBasenames=r.allBasenames,n.allPaths=r.allPaths,n.basenames=r.basenames,n.patterns=r.patterns,n}function Ma(r,t){return t.trimForExclusions&&r.endsWith("/**")?r.substring(0,r.length-2):r}function Zh(r,t,e){return function(n,i){return typeof n=="string"&&e.endsWith(n,r)?t:null}}function eg(r,t,e){let n=`/${r}`,i=`\\${r}`,o=function(a,l){return typeof a!="string"?null:l?e.equals(l,r)?t:null:e.equals(a,r)||e.endsWith(a,n)||e.endsWith(a,i)?t:null},s=[r];return o.basenames=s,o.patterns=[t],o.allBasenames=s,o}function tg(r,t){let e=gd(r.slice(1,-1).split(",").map(a=>Wa(a,t)).filter(a=>a!==dt),r),n=e.length;if(!n)return dt;if(n===1)return e[0];let i=function(a,l){for(let c=0,d=e.length;c<d;c++)if(e[c](a,l))return r;return null},o=e.find(a=>!!a.allBasenames);o&&(i.allBasenames=o.allBasenames);let s=e.reduce((a,l)=>l.allPaths?a.concat(l.allPaths):a,[]);return s.length&&(i.allPaths=s),i}function pd(r,t,e,n){let i=ue===q.sep,o=i?r:r.replace(zh,ue),s=ue+o,a=q.sep+r,l;return e?l=function(c,d){return typeof c=="string"&&(n.equals(c,o)||n.endsWith(c,s)||!i&&(n.equals(c,r)||n.endsWith(c,a)))?t:null}:l=function(c,d){return typeof c=="string"&&(n.equals(c,o)||!i&&n.equals(c,r))?t:null},l.allPaths=[(e?"*/":"./")+r],l}function ng(r,t){try{let e=new RegExp(`^${fd(r)}$`,t.ignoreCase?"i":void 0);return function(n){return e.lastIndex=0,typeof n=="string"&&e.test(n)?r:null}}catch{return dt}}function hd(r,t,e){return!r||typeof t!="string"?!1:Ba(r,e)(t)}function Ba(r,t={}){if(!r)return ud;if(typeof r=="string"||rg(r)){let e=Wa(r,t);if(e===dt)return ud;let n=function(i,o){return!!e(i,o)};return e.allBasenames&&(n.allBasenames=e.allBasenames),e.allPaths&&(n.allPaths=e.allPaths),n}return ig(r,t)}function rg(r){let t=r;return t?typeof t.base=="string"&&typeof t.pattern=="string":!1}function ig(r,t){let e=gd(Object.getOwnPropertyNames(r).map(a=>og(a,r[a],t)).filter(a=>a!==dt)),n=e.length;if(!n)return dt;if(!e.some(a=>!!a.requiresSiblings)){if(n===1)return e[0];let a=function(d,u){let p;for(let h=0,v=e.length;h<v;h++){let g=e[h](d,u);if(typeof g=="string")return g;Bi(g)&&(p||(p=[]),p.push(g))}return p?(async()=>{for(let h of p){let v=await h;if(typeof v=="string")return v}return null})():null},l=e.find(d=>!!d.allBasenames);l&&(a.allBasenames=l.allBasenames);let c=e.reduce((d,u)=>u.allPaths?d.concat(u.allPaths):d,[]);return c.length&&(a.allPaths=c),a}let i=function(a,l,c){let d,u;for(let p=0,h=e.length;p<h;p++){let v=e[p];v.requiresSiblings&&c&&(l||(l=ze(a)),d||(d=l.substring(0,l.length-Sc(a).length)));let g=v(a,l,d,c);if(typeof g=="string")return g;Bi(g)&&(u||(u=[]),u.push(g))}return u?(async()=>{for(let p of u){let h=await p;if(typeof h=="string")return h}return null})():null},o=e.find(a=>!!a.allBasenames);o&&(i.allBasenames=o.allBasenames);let s=e.reduce((a,l)=>l.allPaths?a.concat(l.allPaths):a,[]);return s.length&&(i.allPaths=s),i}function og(r,t,e){if(t===!1)return dt;let n=Wa(r,e);if(n===dt)return dt;if(typeof t=="boolean")return n;if(t){let i=t.when;if(typeof i=="string"){let o=(s,a,l,c)=>{if(!c||!n(s,a))return null;let d=i.replace("$(basename)",()=>l),u=c(d);return Bi(u)?u.then(p=>p?r:null):u?r:null};return o.requiresSiblings=!0,o}}return n}function gd(r,t){let e=r.filter(a=>!!a.basenames);if(e.length<2)return r;let n=e.reduce((a,l)=>{let c=l.basenames;return c?a.concat(c):a},[]),i;if(t){i=[];for(let a=0,l=n.length;a<l;a++)i.push(t)}else i=e.reduce((a,l)=>{let c=l.patterns;return c?a.concat(c):a},[]);let o=function(a,l){if(typeof a!="string")return null;if(!l){let d;for(d=a.length;d>0;d--){let u=a.charCodeAt(d-1);if(u===47||u===92)break}l=a.substring(d)}let c=n.indexOf(l);return c!==-1?i[c]:null};o.basenames=n,o.patterns=i,o.allBasenames=n;let s=r.filter(a=>!a.basenames);return s.push(o),s}function qa(r,t){return yr(r,t,(e,n)=>typeof e=="string"&&typeof n=="string"?e===n:typeof e!="string"&&typeof n!="string"?e.base===n.base&&e.pattern===n.pattern:!1)}var Io=class{constructor(){this._currentMarkdownPartId=new Map;this._currentReasoningPartId=new Map}reset(t){this._currentMarkdownPartId.delete(t),this._currentReasoningPartId.delete(t)}mapProgressEventToActions(t,e,n){switch(t.type){case"delta":{let i=t,o=this._currentMarkdownPartId.get(e);if(!o){let s=ge();return this._currentMarkdownPartId.set(e,s),{type:"session/responsePart",session:e,turnId:n,part:{kind:"markdown",id:s,content:i.content}}}return{type:"session/delta",session:e,turnId:n,partId:o,content:i.content}}case"tool_start":{this._currentMarkdownPartId.delete(e);let i=t,o={type:"session/toolCallStart",session:e,turnId:n,toolCallId:i.toolCallId,toolName:i.toolName,displayName:i.displayName,_meta:{toolKind:i.toolKind,language:i.language}},s={type:"session/toolCallReady",session:e,turnId:n,toolCallId:i.toolCallId,invocationMessage:i.invocationMessage,toolInput:i.toolInput,confirmed:"not-needed"};return[o,s]}case"tool_ready":{let i=t;return{type:"session/toolCallReady",session:e,turnId:n,toolCallId:i.toolCallId,invocationMessage:i.invocationMessage,toolInput:i.toolInput,confirmationTitle:i.confirmationTitle}}case"tool_complete":{let i=t;return{type:"session/toolCallComplete",session:e,turnId:n,toolCallId:i.toolCallId,result:i.result}}case"idle":return{type:"session/turnComplete",session:e,turnId:n};case"error":{let i=t;return{type:"session/error",session:e,turnId:n,error:{errorType:i.errorType,message:i.message,stack:i.stack}}}case"usage":{let i=t;return{type:"session/usage",session:e,turnId:n,usage:{inputTokens:i.inputTokens,outputTokens:i.outputTokens,model:i.model,cacheReadTokens:i.cacheReadTokens}}}case"title_changed":return{type:"session/titleChanged",session:e,title:t.title};case"reasoning":{let i=t,o=this._currentReasoningPartId.get(e);if(!o){let s=ge();return this._currentReasoningPartId.set(e,s),{type:"session/responsePart",session:e,turnId:n,part:{kind:"reasoning",id:s,content:i.content}}}return{type:"session/reasoning",session:e,turnId:n,partId:o,content:i.content}}case"message":{let i=t;if(i.role!=="assistant"||!i.content||this._currentMarkdownPartId.get(e))return;let s=ge();return this._currentMarkdownPartId.set(e,s),{type:"session/responsePart",session:e,turnId:n,part:{kind:"markdown",id:s,content:i.content}}}default:return}}};import*as vd from"fs";var sg=/&&|\|\||[;|]|`|\$\(/,Va=/(?!.*)/,md=/^[A-Z_][A-Z0-9_]*=/i,To=class extends A{constructor(e){super();this._logService=e;this._initPromise=this._initTreeSitter()}initialize(){return this._initPromise}shouldAutoApprove(e){let n=e.trimStart();if(n.length===0)return"approved";this._ensureRules();let i=this._extractSubCommands(n);return i&&i.length>0?this._matchSubCommands(i):sg.test(n)?(this._logService.trace("[CommandAutoApprover] Compound command without tree-sitter, requiring confirmation"),"noMatch"):this._matchCommandLine(n)}_matchSubCommands(e){let n=!0;for(let i of e){if(md.test(i))return"denied";let o=this._matchSingleCommand(i);if(o==="denied")return"denied";o!=="approved"&&(n=!1)}return n?"approved":"noMatch"}_matchCommandLine(e){return md.test(e)?"denied":this._matchSingleCommand(e)}_matchSingleCommand(e){for(let n of this._denyRules)if(n.regex.test(e))return"denied";for(let n of this._allowRules)if(n.regex.test(e))return"approved";return"noMatch"}_extractSubCommands(e){if(!(!this._parser||!this._bashLanguage||!this._queryClass))try{this._parser.setLanguage(this._bashLanguage);let n=this._parser.parse(e);if(!n)return;try{let i=new this._queryClass(this._bashLanguage,"(command) @command"),s=i.captures(n.rootNode).map(a=>a.node.text);return i.delete(),s.length>0?s:void 0}finally{n.delete()}}catch(n){this._logService.warn("[CommandAutoApprover] Tree-sitter parsing failed",n);return}}async _initTreeSitter(){try{let e=await import("@vscode/tree-sitter-wasm"),n=m.joinPath(lt.asFileUri(""),"..","node_modules","@vscode","tree-sitter-wasm","wasm"),i=m.joinPath(n,"tree-sitter.wasm").fsPath;await e.Parser.init({locateFile(){return i}});let o=new e.Parser;this._register(O(()=>o.delete()));let s=m.joinPath(n,"tree-sitter-bash.wasm").fsPath,a=await vd.promises.readFile(s),l=await e.Language.load(new Uint8Array(a.buffer,a.byteOffset,a.byteLength));this._parser=o,this._bashLanguage=l,this._queryClass=e.Query,this._logService.info("[CommandAutoApprover] Tree-sitter initialized successfully")}catch(e){this._logService.warn("[CommandAutoApprover] Failed to initialize tree-sitter",e)}}_ensureRules(){if(this._allowRules&&this._denyRules)return;let e=[],n=[];for(let[i,o]of Object.entries(lg)){let s=ag(i);o===!0?e.push({regex:s}):o===!1&&n.push({regex:s})}this._allowRules=e,this._denyRules=n}};function ag(r){let t=r.match(/^\/(?<pattern>.+)\/(?<flags>[dgimsuvy]*)$/),e=t?.groups?.pattern;if(e){let i=t.groups?.flags;if(i&&(i=i.replaceAll("g","")),e===".*")return new RegExp(e);try{let o=new RegExp(e,i||void 0);return Pc(o)?Va:o}catch{return Va}}if(r==="")return Va;let n;if(r.includes("/")||r.includes("\\")){let i=r.replace(/[/\\]/g,"%%PATH_SEP%%");i=Ft(i),i=i.replace(/%%PATH_SEP%%*/g,"[/\\\\]"),n=`^(?:\\.[/\\\\])?${i}`}else n=Ft(r);return new RegExp(`^${n}\\b`)}var lg={cd:!0,echo:!0,ls:!0,dir:!0,pwd:!0,cat:!0,head:!0,tail:!0,findstr:!0,wc:!0,tr:!0,cut:!0,cmp:!0,which:!0,basename:!0,dirname:!0,realpath:!0,readlink:!0,stat:!0,file:!0,od:!0,du:!0,df:!0,sleep:!0,nl:!0,grep:!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+status\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+log\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+log\\b.*\\s--output(=|\\s|$)/":!1,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+show\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+diff\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+ls-files\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+grep\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+branch\\b/":!0,"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+branch\\b.*\\s-(d|D|m|M|-delete|-force)\\b/":!1,"/^docker\\s+(ps|images|info|version|inspect|logs|top|stats|port|diff|search|events)\\b/":!0,"/^docker\\s+(container|image|network|volume|context|system)\\s+(ls|ps|inspect|history|show|df|info)\\b/":!0,"/^docker\\s+compose\\s+(ps|ls|top|logs|images|config|version|port|events)\\b/":!0,"Get-ChildItem":!0,"Get-Content":!0,"Get-Date":!0,"Get-Random":!0,"Get-Location":!0,"Set-Location":!0,"Write-Host":!0,"Write-Output":!0,"Out-String":!0,"Split-Path":!0,"Join-Path":!0,"Start-Sleep":!0,"Where-Object":!0,"/^Select-[a-z0-9]/i":!0,"/^Measure-[a-z0-9]/i":!0,"/^Compare-[a-z0-9]/i":!0,"/^Format-[a-z0-9]/i":!0,"/^Sort-[a-z0-9]/i":!0,"/^npm\\s+(ls|list|outdated|view|info|show|explain|why|root|prefix|bin|search|doctor|fund|repo|bugs|docs|home|help(-search)?)\\b/":!0,"/^npm\\s+config\\s+(list|get)\\b/":!0,"/^npm\\s+pkg\\s+get\\b/":!0,"/^npm\\s+audit$/":!0,"/^npm\\s+cache\\s+verify\\b/":!0,"/^yarn\\s+(list|outdated|info|why|bin|help|versions)\\b/":!0,"/^yarn\\s+licenses\\b/":!0,"/^yarn\\s+audit\\b(?!.*\\bfix\\b)/":!0,"/^yarn\\s+config\\s+(list|get)\\b/":!0,"/^yarn\\s+cache\\s+dir\\b/":!0,"/^pnpm\\s+(ls|list|outdated|why|root|bin|doctor)\\b/":!0,"/^pnpm\\s+licenses\\b/":!0,"/^pnpm\\s+audit\\b(?!.*\\bfix\\b)/":!0,"/^pnpm\\s+config\\s+(list|get)\\b/":!0,"npm ci":!0,"/^yarn\\s+install\\s+--frozen-lockfile\\b/":!0,"/^pnpm\\s+install\\s+--frozen-lockfile\\b/":!0,column:!0,"/^column\\b.*\\s-c\\s+[0-9]{4,}/":!1,date:!0,"/^date\\b.*\\s(-s|--set)\\b/":!1,find:!0,"/^find\\b.*\\s-(delete|exec|execdir|fprint|fprintf|fls|ok|okdir)\\b/":!1,rg:!0,"/^rg\\b.*\\s(--pre|--hostname-bin)\\b/":!1,sed:!0,"/^sed\\b.*\\s(-[a-zA-Z]*(e|f)[a-zA-Z]*|--expression|--file)\\b/":!1,"/^sed\\b.*s\\/.*\\/.*\\/[ew]/":!1,"/^sed\\b.*;W/":!1,sort:!0,"/^sort\\b.*\\s-(o|S)\\b/":!1,tree:!0,"/^tree\\b.*\\s-o\\b/":!1,"/^xxd$/":!0,"/^xxd\\b(\\s+-\\S+)*\\s+[^-\\s]\\S*$/":!0,rm:!1,rmdir:!1,del:!1,"Remove-Item":!1,ri:!1,rd:!1,erase:!1,dd:!1,kill:!1,ps:!1,top:!1,"Stop-Process":!1,spps:!1,taskkill:!1,"taskkill.exe":!1,curl:!1,wget:!1,"Invoke-RestMethod":!1,"Invoke-WebRequest":!1,irm:!1,iwr:!1,chmod:!1,chown:!1,"Set-ItemProperty":!1,sp:!1,"Set-Acl":!1,jq:!1,xargs:!1,eval:!1,"Invoke-Expression":!1,iex:!1};var So=class r extends A{constructor(e,n,i){super();this._stateManager=e;this._options=n;this._logService=i;this._toolCallAgents=new Map;this._eventMappers=new Map;this._commandAutoApprover=this._register(new To(this._logService)),this._register(zr(o=>{let s=this._options.agents.read(o);this._publishAgentInfos(s)}))}async _publishAgentInfos(e){let n=await Promise.all(e.map(async i=>{let o=i.getDescriptor(),s;try{s=(await i.listModels()).map(l=>({id:l.id,provider:l.provider,name:l.name,maxContextWindow:l.maxContextWindow,supportsVision:l.supportsVision,policyState:l.policyState}))}catch{s=[]}return{provider:o.provider,displayName:o.displayName,description:o.description,models:s}}));this._stateManager.dispatchServerAction({type:"root/agentsChanged",agents:n})}static{this._DEFAULT_EDIT_AUTO_APPROVE_PATTERNS={"**/*":!0,"**/.vscode/*.json":!1,"**/.git/**":!1,"**/{package.json,server.xml,build.rs,web.config,.gitattributes,.env}":!1,"**/*.{code-workspace,csproj,fsproj,vbproj,vcxproj,proj,targets,props}":!1,"**/*.lock":!1,"**/*-lock.{yaml,json}":!1}}_shouldAutoApproveEdit(e){let n=r._DEFAULT_EDIT_AUTO_APPROVE_PATTERNS,i=!0;for(let[o,s]of Object.entries(n))s!==i&&hd(o,e)&&(i=s);return i}initialize(){return this._commandAutoApprover.initialize()}_tryAutoApproveToolReady(e,n,i){if(e.permissionKind==="write"&&e.permissionPath){let o=this._stateManager.getSessionState(n),s=o?.workingDirectory??o?.summary.workingDirectory,a=s?m.parse(s):void 0;return a&&Mt.isEqualOrParent(Dn(m.file(e.permissionPath)),a)&&this._shouldAutoApproveEdit(e.permissionPath)?(this._logService.trace(`[AgentSideEffects] Auto-approving write to ${e.permissionPath}`),this._toolCallAgents.delete(`${n}:${e.toolCallId}`),i.respondToPermissionRequest(e.toolCallId,!0),!0):!1}if(e.permissionKind==="shell"&&e.toolInput){let o=this._commandAutoApprover.shouldAutoApprove(e.toolInput);return o==="approved"?(this._logService.trace("[AgentSideEffects] Auto-approving shell command"),this._toolCallAgents.delete(`${n}:${e.toolCallId}`),i.respondToPermissionRequest(e.toolCallId,!0),!0):(o==="denied"&&this._logService.trace("[AgentSideEffects] Shell command denied by rule"),!1)}return!1}registerProgressListener(e){let n=new N,i=this._eventMappers.get(e.id);i||(i=new Io,this._eventMappers.set(e.id,i));let o=i;return n.add(e.onDidSessionProgress(s=>{s.type==="tool_start"&&this._toolCallAgents.set(`${s.session.toString()}:${s.toolCallId}`,e.id);let a=s.session.toString(),l=this._stateManager.getActiveTurnId(a);if(l){if(s.type==="tool_ready"&&this._tryAutoApproveToolReady(s,a,e))return;this._dispatchProgressActions(o,s,a,l)}s.type==="idle"&&this._tryConsumeNextQueuedMessage(a),s.type==="steering_consumed"&&this._stateManager.dispatchServerAction({type:"session/pendingMessageRemoved",session:a,kind:"steering",id:s.id})})),n}_dispatchProgressActions(e,n,i,o){let s=e.mapProgressEventToActions(n,i,o);if(s)if(Array.isArray(s))for(let a of s)this._stateManager.dispatchServerAction(a);else this._stateManager.dispatchServerAction(s)}handleAction(e){switch(e.type){case"session/turnStarted":{for(let o of this._eventMappers.values())o.reset(e.session);let n=this._options.getAgent(e.session);if(!n){this._stateManager.dispatchServerAction({type:"session/error",session:e.session,turnId:e.turnId,error:{errorType:"noAgent",message:"No agent found for session"}});return}let i=e.userMessage.attachments?.map(o=>({type:o.type,path:o.path,displayName:o.displayName}));n.sendMessage(m.parse(e.session),e.userMessage.text,i).catch(o=>{this._logService.error("[AgentSideEffects] sendMessage failed",o),this._stateManager.dispatchServerAction({type:"session/error",session:e.session,turnId:e.turnId,error:{errorType:"sendFailed",message:String(o)}})});break}case"session/toolCallConfirmed":{let n=`${e.session}:${e.toolCallId}`,i=this._toolCallAgents.get(n);i?(this._toolCallAgents.delete(n),this._options.agents.get().find(s=>s.id===i)?.respondToPermissionRequest(e.toolCallId,e.approved)):this._logService.warn(`[AgentSideEffects] No agent for tool call confirmation: ${e.toolCallId}`);break}case"session/turnCancelled":{this._options.getAgent(e.session)?.abortSession(m.parse(e.session)).catch(i=>{this._logService.error("[AgentSideEffects] abortSession failed",i)});break}case"session/modelChanged":{this._options.getAgent(e.session)?.changeModel?.(m.parse(e.session),e.model).catch(i=>{this._logService.error("[AgentSideEffects] changeModel failed",i)});break}case"session/titleChanged":{this._persistTitle(e.session,e.title);break}case"session/pendingMessageSet":case"session/pendingMessageRemoved":case"session/queuedMessagesReordered":{this._syncPendingMessages(e.session);break}case"session/truncated":{let n=this._options.getAgent(e.session),i;if(e.turnId!==void 0){let o=this._stateManager.getSessionState(e.session);if(o){let s=o.turns.findIndex(a=>a.id===e.turnId);s>=0&&(i=s)}}n?.truncateSession?.(m.parse(e.session),i).catch(o=>{this._logService.error("[AgentSideEffects] truncateSession failed",o)});break}case"session/activeClientChanged":{let n=this._options.getAgent(e.session),i=e.activeClient?.customizations;if(!n?.setClientCustomizations||!i?.length)break;let o=i.map(s=>({customization:s,enabled:!0,status:"loading"}));this._stateManager.dispatchServerAction({type:"session/customizationsChanged",session:e.session,customizations:o}),n.setClientCustomizations(e.activeClient.clientId,i,s=>{let a=s.map(l=>l.customization);this._stateManager.dispatchServerAction({type:"session/customizationsChanged",session:e.session,customizations:a})}).then(s=>{let a=s.map(l=>l.customization);this._stateManager.dispatchServerAction({type:"session/customizationsChanged",session:e.session,customizations:a})}).catch(s=>{this._logService.error("[AgentSideEffects] setClientCustomizations failed",s)});break}case"session/customizationToggled":{this._options.getAgent(e.session)?.setCustomizationEnabled?.(e.uri,e.enabled);break}}}_persistTitle(e,n){let i=this._options.sessionDataService.openDatabase(m.parse(e));i.object.setMetadata("customTitle",n).catch(o=>{this._logService.warn("[AgentSideEffects] Failed to persist session title",o)}).finally(()=>{i.dispose()})}_syncPendingMessages(e){let n=this._stateManager.getSessionState(e);if(!n)return;this._options.getAgent(e)?.setPendingMessages?.(m.parse(e),n.steeringMessage,[]),this._tryConsumeNextQueuedMessage(e)}_tryConsumeNextQueuedMessage(e){if(this._stateManager.getActiveTurnId(e))return;let n=this._stateManager.getSessionState(e);if(!n?.queuedMessages?.length)return;let i=n.queuedMessages[0],o=ge();for(let l of this._eventMappers.values())l.reset(e);this._stateManager.dispatchServerAction({type:"session/turnStarted",session:e,turnId:o,userMessage:i.userMessage,queuedMessageId:i.id});let s=this._options.getAgent(e);if(!s){this._stateManager.dispatchServerAction({type:"session/error",session:e,turnId:o,error:{errorType:"noAgent",message:"No agent found for session"}});return}let a=i.userMessage.attachments?.map(l=>({type:l.type,path:l.path,displayName:l.displayName}));s.sendMessage(m.parse(e),i.userMessage.text,a).catch(l=>{this._logService.error("[AgentSideEffects] sendMessage failed (queued)",l),this._stateManager.dispatchServerAction({type:"session/error",session:e,turnId:o,error:{errorType:"sendFailed",message:String(l)}})})}dispose(){this._toolCallAgents.clear(),super.dispose()}};var yd="session-db";function Gr(r,t,e,n){return m.from({scheme:yd,authority:Ur(S.fromString(r)).toString(),path:`/${encodeURIComponent(t)}/${Ur(S.fromString(e))}/${n}`}).toString()}function bd(r){let t=m.parse(r);if(t.scheme!==yd)return;let[,e,n,i]=t.path.split("/");if(!(!e||!n||i!=="before"&&i!=="after"))try{return{sessionUri:aa(t.authority).toString(),toolCallId:decodeURIComponent(e),filePath:aa(n).toString(),part:i}}catch{return}}var _o=class{constructor(t,e,n,i){this._sessionUri=t;this._db=e;this._fileService=n;this._logService=i;this._pendingEdits=new Map;this._completedEdits=new Map}async trackEditStart(t){let e=this._readFile(t),n={beforeContent:S.fromString(""),snapshotDone:e.then(i=>{n.beforeContent=i})};this._pendingEdits.set(t,n),await n.snapshotDone}async completeEdit(t){let e=this._pendingEdits.get(t);if(!e)return;this._pendingEdits.delete(t),await e.snapshotDone;let n=await this._readFile(t);this._completedEdits.set(t,{beforeContent:e.beforeContent,afterContent:n})}takeCompletedEdit(t,e,n){let i=this._completedEdits.get(n);if(!i)return;this._completedEdits.delete(n);let o=i.beforeContent.buffer,s=i.afterContent.buffer;return this._db.storeFileEdit({turnId:t,toolCallId:e,filePath:n,kind:"edit",beforeContent:o,afterContent:s,addedLines:void 0,removedLines:void 0}).catch(a=>this._logService.warn(`[FileEditTracker] Failed to persist file edit to database: ${n}`,a)),{type:"fileEdit",before:{uri:m.file(n).toString(),content:{uri:Gr(this._sessionUri,e,n,"before")}},after:{uri:m.file(n).toString(),content:{uri:Gr(this._sessionUri,e,n,"after")}}}}async _readFile(t){try{return(await this._fileService.readFile(m.file(t))).value}catch(e){return this._logService.trace(`[FileEditTracker] Could not read file for snapshot: ${t}`,e),S.fromString("")}}};function $a(r,t){return t&&(r.stack||r.stacktrace)?f(116,null,Td(r),Id(r.stack)||Id(r.stacktrace)):Td(r)}function Id(r){return Array.isArray(r)?r.join(`
`):r}function Td(r){return r.code==="ERR_UNC_HOST_NOT_ALLOWED"?`${r.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.`:typeof r.code=="string"&&typeof r.errno=="number"&&typeof r.syscall=="string"?f(115,null,r.message):r.message||f(113,null)}function Ka(r=null,t=!1){if(!r)return f(113,null);if(Array.isArray(r)){let e=yi(r),n=Ka(e[0],t);return e.length>1?f(114,null,n,e.length):n}if(Jt(r))return r;if(r.detail){let e=r.detail;if(e.error)return $a(e.error,t);if(e.exception)return $a(e.exception,t)}return r.stack?$a(r,t):r.message?r.message:f(113,null)}function er(r){return za(r,0)}function za(r,t){switch(typeof r){case"object":return r===null?wt(349,t):Array.isArray(r)?ug(r,t):dg(r,t);case"string":return _d(r,t);case"boolean":return cg(r,t);case"number":return wt(r,t);case"undefined":return wt(937,t);default:return wt(617,t)}}function wt(r,t){return(t<<5)-t+r|0}function cg(r,t){return wt(r?433:863,t)}function _d(r,t){t=wt(149417,t);for(let e=0,n=r.length;e<n;e++)t=wt(r.charCodeAt(e),t);return t}function ug(r,t){return t=wt(104579,t),r.reduce((e,n)=>za(n,e),t)}function dg(r,t){return t=wt(181387,t),Object.keys(r).sort().reduce((e,n)=>(e=_d(n,e),za(r[n],e)),t)}function ja(r,t,e=32){let n=e-t,i=~((1<<n)-1);return(r<<t|(i&r)>>>n)>>>0}function Jr(r,t=32){return r instanceof ArrayBuffer?Ur(S.wrap(new Uint8Array(r))):(r>>>0).toString(16).padStart(t/4,"0")}var Sd=class r{constructor(){this._h0=1732584193;this._h1=4023233417;this._h2=2562383102;this._h3=271733878;this._h4=3285377520;this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}static{this._bigBlock32=new DataView(new ArrayBuffer(320))}update(t){let e=t.length;if(e===0)return;let n=this._buff,i=this._buffLen,o=this._leftoverHighSurrogate,s,a;for(o!==0?(s=o,a=-1,o=0):(s=t.charCodeAt(0),a=0);;){let l=s;if(kc(s))if(a+1<e){let c=t.charCodeAt(a+1);$s(c)?(a++,l=Dc(s,c)):l=65533}else{o=s;break}else $s(s)&&(l=65533);if(i=this._push(n,i,l),a++,a<e)s=t.charCodeAt(a);else break}this._buffLen=i,this._leftoverHighSurrogate=o}_push(t,e,n){return n<128?t[e++]=n:n<2048?(t[e++]=192|(n&1984)>>>6,t[e++]=128|(n&63)>>>0):n<65536?(t[e++]=224|(n&61440)>>>12,t[e++]=128|(n&4032)>>>6,t[e++]=128|(n&63)>>>0):(t[e++]=240|(n&1835008)>>>18,t[e++]=128|(n&258048)>>>12,t[e++]=128|(n&4032)>>>6,t[e++]=128|(n&63)>>>0),e>=64&&(this._step(),e-=64,this._totalLen+=64,t[0]=t[64],t[1]=t[65],t[2]=t[66]),e}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),Jr(this._h0)+Jr(this._h1)+Jr(this._h2)+Jr(this._h3)+Jr(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,this._buff.subarray(this._buffLen).fill(0),this._buffLen>56&&(this._step(),this._buff.fill(0));let t=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(t/4294967296),!1),this._buffDV.setUint32(60,t%4294967296,!1),this._step()}_step(){let t=r._bigBlock32,e=this._buffDV;for(let u=0;u<64;u+=4)t.setUint32(u,e.getUint32(u,!1),!1);for(let u=64;u<320;u+=4)t.setUint32(u,ja(t.getUint32(u-12,!1)^t.getUint32(u-32,!1)^t.getUint32(u-56,!1)^t.getUint32(u-64,!1),1),!1);let n=this._h0,i=this._h1,o=this._h2,s=this._h3,a=this._h4,l,c,d;for(let u=0;u<80;u++)u<20?(l=i&o|~i&s,c=1518500249):u<40?(l=i^o^s,c=1859775393):u<60?(l=i&o|i&s|o&s,c=2400959708):(l=i^o^s,c=3395469782),d=ja(n,5)+l+a+c+t.getUint32(u*4,!1)&4294967295,a=s,s=o,o=ja(i,30),i=n,n=d;this._h0=this._h0+n&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+o&4294967295,this._h3=this._h3+s&4294967295,this._h4=this._h4+a&4294967295}};function Ha(...r){switch(r.length){case 1:return f(1937,null,r[0]);case 2:return f(1938,null,r[0],r[1]);case 3:return f(1939,null,r[0],r[1],r[2]);default:return}}var pg=f(1936,null),fg=f(1935,null),$t=class r{constructor(){this._input="";this._start=0;this._current=0;this._tokens=[];this._errors=[];this.stringRe=/[a-zA-Z0-9_<>\-\./\\:\*\?\+\[\]\^,#@;"%\$\p{L}-]+/uy}static getLexeme(t){switch(t.type){case 0:return"(";case 1:return")";case 2:return"!";case 3:return t.isTripleEq?"===":"==";case 4:return t.isTripleEq?"!==":"!=";case 5:return"<";case 6:return"<=";case 7:return">=";case 8:return">=";case 9:return"=~";case 10:return t.lexeme;case 11:return"true";case 12:return"false";case 13:return"in";case 14:return"not";case 15:return"&&";case 16:return"||";case 17:return t.lexeme;case 18:return t.lexeme;case 19:return t.lexeme;case 20:return"EOF";default:throw vi(`unhandled token type: ${JSON.stringify(t)}; have you forgotten to add a case?`)}}static{this._regexFlags=new Set(["i","g","s","m","y","u"].map(t=>t.charCodeAt(0)))}static{this._keywords=new Map([["not",14],["in",13],["false",12],["true",11]])}get errors(){return this._errors}reset(t){return this._input=t,this._start=0,this._current=0,this._tokens=[],this._errors=[],this}scan(){for(;!this._isAtEnd();)switch(this._start=this._current,this._advance()){case 40:this._addToken(0);break;case 41:this._addToken(1);break;case 33:if(this._match(61)){let e=this._match(61);this._tokens.push({type:4,offset:this._start,isTripleEq:e})}else this._addToken(2);break;case 39:this._quotedString();break;case 47:this._regex();break;case 61:if(this._match(61)){let e=this._match(61);this._tokens.push({type:3,offset:this._start,isTripleEq:e})}else this._match(126)?this._addToken(9):this._error(Ha("==","=~"));break;case 60:this._addToken(this._match(61)?6:5);break;case 62:this._addToken(this._match(61)?8:7);break;case 38:this._match(38)?this._addToken(15):this._error(Ha("&&"));break;case 124:this._match(124)?this._addToken(16):this._error(Ha("||"));break;case 32:case 13:case 9:case 10:case 160:break;default:this._string()}return this._start=this._current,this._addToken(20),Array.from(this._tokens)}_match(t){return this._isAtEnd()||this._input.charCodeAt(this._current)!==t?!1:(this._current++,!0)}_advance(){return this._input.charCodeAt(this._current++)}_peek(){return this._isAtEnd()?0:this._input.charCodeAt(this._current)}_addToken(t){this._tokens.push({type:t,offset:this._start})}_error(t){let e=this._start,n=this._input.substring(this._start,this._current),i={type:19,offset:this._start,lexeme:n};this._errors.push({offset:e,lexeme:n,additionalInfo:t}),this._tokens.push(i)}_string(){this.stringRe.lastIndex=this._start;let t=this.stringRe.exec(this._input);if(t){this._current=this._start+t[0].length;let e=this._input.substring(this._start,this._current),n=r._keywords.get(e);n?this._addToken(n):this._tokens.push({type:17,lexeme:e,offset:this._start})}}_quotedString(){for(;this._peek()!==39&&!this._isAtEnd();)this._advance();if(this._isAtEnd()){this._error(pg);return}this._advance(),this._tokens.push({type:18,lexeme:this._input.substring(this._start+1,this._current-1),offset:this._start+1})}_regex(){let t=this._current,e=!1,n=!1;for(;;){if(t>=this._input.length){this._current=t,this._error(fg);return}let o=this._input.charCodeAt(t);if(e)e=!1;else if(o===47&&!n){t++;break}else o===91?n=!0:o===92?e=!0:o===93&&(n=!1);t++}for(;t<this._input.length&&r._regexFlags.has(this._input.charCodeAt(t));)t++;this._current=t;let i=this._input.substring(this._start,this._current);this._tokens.push({type:10,lexeme:i,offset:this._start})}_isAtEnd(){return this._current>=this._input.length}};var ve=new Map;ve.set("false",!1);ve.set("true",!0);ve.set("isMac",Ke);ve.set("isLinux",le);ve.set("isWindows",H);ve.set("isWeb",_n);ve.set("isMacNative",Ke&&!_n);ve.set("isEdge",uc);ve.set("isFirefox",lc);ve.set("isChrome",ks);ve.set("isSafari",cc);var hg=Object.prototype.hasOwnProperty;var gg={regexParsingWithErrorRecovery:!0},mg=f(1916,null),vg=f(1917,null),yg=f(1919,null),xd=f(1915,null),bg=f(1922,null),Ig=f(1923,null),Tg=f(1920,null),Sg=f(1921,null),Ga=class r{constructor(t=gg){this._config=t;this._scanner=new $t;this._tokens=[];this._current=0;this._parsingErrors=[];this._flagsGYRe=/g|y/g}static{this._parseError=new Error}get lexingErrors(){return this._scanner.errors}get parsingErrors(){return this._parsingErrors}parse(t){if(t===""){this._parsingErrors.push({message:mg,offset:0,lexeme:"",additionalInfo:vg});return}this._tokens=this._scanner.reset(t).scan(),this._current=0,this._parsingErrors=[];try{let e=this._expr();if(!this._isAtEnd()){let n=this._peek(),i=n.type===17?Ig:void 0;throw this._parsingErrors.push({message:bg,offset:n.offset,lexeme:$t.getLexeme(n),additionalInfo:i}),r._parseError}return e}catch(e){if(e!==r._parseError)throw e;return}}_expr(){return this._or()}_or(){let t=[this._and()];for(;this._matchOne(16);){let e=this._and();t.push(e)}return t.length===1?t[0]:Re.or(...t)}_and(){let t=[this._term()];for(;this._matchOne(15);){let e=this._term();t.push(e)}return t.length===1?t[0]:Re.and(...t)}_term(){if(this._matchOne(2)){let t=this._peek();switch(t.type){case 11:return this._advance(),we.INSTANCE;case 12:return this._advance(),De.INSTANCE;case 0:{this._advance();let e=this._expr();return this._consume(1,xd),e?.negate()}case 17:return this._advance(),gn.create(t.lexeme);default:throw this._errExpectedButGot("KEY | true | false | '(' expression ')'",t)}}return this._primary()}_primary(){let t=this._peek();switch(t.type){case 11:return this._advance(),Re.true();case 12:return this._advance(),Re.false();case 0:{this._advance();let e=this._expr();return this._consume(1,xd),e}case 17:{let e=t.lexeme;if(this._advance(),this._matchOne(9)){let i=this._peek();if(!this._config.regexParsingWithErrorRecovery){if(this._advance(),i.type!==10)throw this._errExpectedButGot("REGEX",i);let o=i.lexeme,s=o.lastIndexOf("/"),a=s===o.length-1?void 0:this._removeFlagsGY(o.substring(s+1)),l;try{l=new RegExp(o.substring(1,s),a)}catch{throw this._errExpectedButGot("REGEX",i)}return ni.create(e,l)}switch(i.type){case 10:case 19:{let o=[i.lexeme];this._advance();let s=this._peek(),a=0;for(let p=0;p<i.lexeme.length;p++)i.lexeme.charCodeAt(p)===40?a++:i.lexeme.charCodeAt(p)===41&&a--;for(;!this._isAtEnd()&&s.type!==15&&s.type!==16;){switch(s.type){case 0:a++;break;case 1:a--;break;case 10:case 18:for(let p=0;p<s.lexeme.length;p++)s.lexeme.charCodeAt(p)===40?a++:i.lexeme.charCodeAt(p)===41&&a--}if(a<0)break;o.push($t.getLexeme(s)),this._advance(),s=this._peek()}let l=o.join(""),c=l.lastIndexOf("/"),d=c===l.length-1?void 0:this._removeFlagsGY(l.substring(c+1)),u;try{u=new RegExp(l.substring(1,c),d)}catch{throw this._errExpectedButGot("REGEX",i)}return Re.regex(e,u)}case 18:{let o=i.lexeme;this._advance();let s=null;if(!wc(o)){let a=o.indexOf("/"),l=o.lastIndexOf("/");if(a!==l&&a>=0){let c=o.slice(a+1,l),d=o[l+1]==="i"?"i":"";try{s=new RegExp(c,d)}catch{throw this._errExpectedButGot("REGEX",i)}}}if(s===null)throw this._errExpectedButGot("REGEX",i);return ni.create(e,s)}default:throw this._errExpectedButGot("REGEX",this._peek())}}if(this._matchOne(14)){this._consume(13,yg);let i=this._value();return Re.notIn(e,i)}switch(this._peek().type){case 3:{this._advance();let i=this._value();if(this._previous().type===18)return Re.equals(e,i);switch(i){case"true":return Re.has(e);case"false":return Re.not(e);default:return Re.equals(e,i)}}case 4:{this._advance();let i=this._value();if(this._previous().type===18)return Re.notEquals(e,i);switch(i){case"true":return Re.not(e);case"false":return Re.has(e);default:return Re.notEquals(e,i)}}case 5:return this._advance(),ei.create(e,this._value());case 6:return this._advance(),ti.create(e,this._value());case 7:return this._advance(),tr.create(e,this._value());case 8:return this._advance(),Zr.create(e,this._value());case 13:return this._advance(),Re.in(e,this._value());default:return Re.has(e)}}case 20:throw this._parsingErrors.push({message:Tg,offset:t.offset,lexeme:"",additionalInfo:Sg}),r._parseError;default:throw this._errExpectedButGot(`true | false | KEY 
	| KEY '=~' REGEX 
	| KEY ('==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not' 'in') value`,this._peek())}}_value(){let t=this._peek();switch(t.type){case 17:case 18:return this._advance(),t.lexeme;case 11:return this._advance(),"true";case 12:return this._advance(),"false";case 13:return this._advance(),"in";default:return""}}_removeFlagsGY(t){return t.replaceAll(this._flagsGYRe,"")}_previous(){return this._tokens[this._current-1]}_matchOne(t){return this._check(t)?(this._advance(),!0):!1}_advance(){return this._isAtEnd()||this._current++,this._previous()}_consume(t,e){if(this._check(t))return this._advance();throw this._errExpectedButGot(e,this._peek())}_errExpectedButGot(t,e,n){let i=f(1918,null,t,$t.getLexeme(e)),o=e.offset,s=$t.getLexeme(e);return this._parsingErrors.push({message:i,offset:o,lexeme:s,additionalInfo:n}),r._parseError}_check(t){return this._peek().type===t}_peek(){return this._tokens[this._current]}_isAtEnd(){return this._peek().type===20}},Re=class{static false(){return we.INSTANCE}static true(){return De.INSTANCE}static has(t){return hn.create(t)}static equals(t,e){return Yr.create(t,e)}static notEquals(t,e){return Xr.create(t,e)}static regex(t,e){return ni.create(t,e)}static in(t,e){return xo.create(t,e)}static notIn(t,e){return Ro.create(t,e)}static not(t){return gn.create(t)}static and(...t){return Eo.create(t,null,!0)}static or(...t){return ri.create(t,null,!0)}static greater(t,e){return tr.create(t,e)}static greaterEquals(t,e){return Zr.create(t,e)}static smaller(t,e){return ei.create(t,e)}static smallerEquals(t,e){return ti.create(t,e)}static{this._parser=new Ga({regexParsingWithErrorRecovery:!1})}static deserialize(t){return t==null?void 0:this._parser.parse(t)}};function Qr(r,t){return r.cmp(t)}var we=class r{constructor(){this.type=0}static{this.INSTANCE=new r}cmp(t){return this.type-t.type}equals(t){return t.type===this.type}substituteConstants(){return this}evaluate(t){return!1}serialize(){return"false"}keys(){return[]}map(t){return this}negate(){return De.INSTANCE}},De=class r{constructor(){this.type=1}static{this.INSTANCE=new r}cmp(t){return this.type-t.type}equals(t){return t.type===this.type}substituteConstants(){return this}evaluate(t){return!0}serialize(){return"true"}keys(){return[]}map(t){return this}negate(){return we.INSTANCE}},hn=class r{constructor(t,e){this.key=t;this.negated=e;this.type=2}static create(t,e=null){let n=ve.get(t);return typeof n=="boolean"?n?De.INSTANCE:we.INSTANCE:new r(t,e)}cmp(t){return t.type!==this.type?this.type-t.type:wd(this.key,t.key)}equals(t){return t.type===this.type?this.key===t.key:!1}substituteConstants(){let t=ve.get(this.key);return typeof t=="boolean"?t?De.INSTANCE:we.INSTANCE:this}evaluate(t){return!!t.getValue(this.key)}serialize(){return this.key}keys(){return[this.key]}map(t){return t.mapDefined(this.key)}negate(){return this.negated||(this.negated=gn.create(this.key,this)),this.negated}},Yr=class r{constructor(t,e,n){this.key=t;this.value=e;this.negated=n;this.type=4}static create(t,e,n=null){if(typeof e=="boolean")return e?hn.create(t,n):gn.create(t,n);let i=ve.get(t);return typeof i=="boolean"?e===(i?"true":"false")?De.INSTANCE:we.INSTANCE:new r(t,e,n)}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.value,t.key,t.value)}equals(t){return t.type===this.type?this.key===t.key&&this.value===t.value:!1}substituteConstants(){let t=ve.get(this.key);if(typeof t=="boolean"){let e=t?"true":"false";return this.value===e?De.INSTANCE:we.INSTANCE}return this}evaluate(t){return t.getValue(this.key)==this.value}serialize(){return`${this.key} == '${this.value}'`}keys(){return[this.key]}map(t){return t.mapEquals(this.key,this.value)}negate(){return this.negated||(this.negated=Xr.create(this.key,this.value,this)),this.negated}},xo=class r{constructor(t,e){this.key=t;this.valueKey=e;this.type=10;this.negated=null}static create(t,e){return new r(t,e)}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.valueKey,t.key,t.valueKey)}equals(t){return t.type===this.type?this.key===t.key&&this.valueKey===t.valueKey:!1}substituteConstants(){return this}evaluate(t){let e=t.getValue(this.valueKey),n=t.getValue(this.key);if(Array.isArray(e)){if(e.includes(n))return!0;if(H&&typeof n=="string"&&n.startsWith("file:///")){let i=n.toLowerCase();return e.some(o=>typeof o=="string"&&o.toLowerCase()===i)}return!1}if(typeof n=="string"&&typeof e=="object"&&e!==null){if(hg.call(e,n))return!0;if(H&&n.startsWith("file:///")){let i=n.toLowerCase();return Object.keys(e).some(o=>o.toLowerCase()===i)}return!1}return!1}serialize(){return`${this.key} in '${this.valueKey}'`}keys(){return[this.key,this.valueKey]}map(t){return t.mapIn(this.key,this.valueKey)}negate(){return this.negated||(this.negated=Ro.create(this.key,this.valueKey)),this.negated}},Ro=class r{constructor(t,e){this.key=t;this.valueKey=e;this.type=11;this._negated=xo.create(t,e)}static create(t,e){return new r(t,e)}cmp(t){return t.type!==this.type?this.type-t.type:this._negated.cmp(t._negated)}equals(t){return t.type===this.type?this._negated.equals(t._negated):!1}substituteConstants(){return this}evaluate(t){return!this._negated.evaluate(t)}serialize(){return`${this.key} not in '${this.valueKey}'`}keys(){return this._negated.keys()}map(t){return t.mapNotIn(this.key,this.valueKey)}negate(){return this._negated}},Xr=class r{constructor(t,e,n){this.key=t;this.value=e;this.negated=n;this.type=5}static create(t,e,n=null){if(typeof e=="boolean")return e?gn.create(t,n):hn.create(t,n);let i=ve.get(t);return typeof i=="boolean"?e===(i?"true":"false")?we.INSTANCE:De.INSTANCE:new r(t,e,n)}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.value,t.key,t.value)}equals(t){return t.type===this.type?this.key===t.key&&this.value===t.value:!1}substituteConstants(){let t=ve.get(this.key);if(typeof t=="boolean"){let e=t?"true":"false";return this.value===e?we.INSTANCE:De.INSTANCE}return this}evaluate(t){return t.getValue(this.key)!=this.value}serialize(){return`${this.key} != '${this.value}'`}keys(){return[this.key]}map(t){return t.mapNotEquals(this.key,this.value)}negate(){return this.negated||(this.negated=Yr.create(this.key,this.value,this)),this.negated}},gn=class r{constructor(t,e){this.key=t;this.negated=e;this.type=3}static create(t,e=null){let n=ve.get(t);return typeof n=="boolean"?n?we.INSTANCE:De.INSTANCE:new r(t,e)}cmp(t){return t.type!==this.type?this.type-t.type:wd(this.key,t.key)}equals(t){return t.type===this.type?this.key===t.key:!1}substituteConstants(){let t=ve.get(this.key);return typeof t=="boolean"?t?we.INSTANCE:De.INSTANCE:this}evaluate(t){return!t.getValue(this.key)}serialize(){return`!${this.key}`}keys(){return[this.key]}map(t){return t.mapNot(this.key)}negate(){return this.negated||(this.negated=hn.create(this.key,this)),this.negated}};function Co(r,t){if(typeof r=="string"){let e=parseFloat(r);isNaN(e)||(r=e)}return typeof r=="string"||typeof r=="number"?t(r):we.INSTANCE}var tr=class r{constructor(t,e,n){this.key=t;this.value=e;this.negated=n;this.type=12}static create(t,e,n=null){return Co(e,i=>new r(t,i,n))}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.value,t.key,t.value)}equals(t){return t.type===this.type?this.key===t.key&&this.value===t.value:!1}substituteConstants(){return this}evaluate(t){return typeof this.value=="string"?!1:parseFloat(t.getValue(this.key))>this.value}serialize(){return`${this.key} > ${this.value}`}keys(){return[this.key]}map(t){return t.mapGreater(this.key,this.value)}negate(){return this.negated||(this.negated=ti.create(this.key,this.value,this)),this.negated}},Zr=class r{constructor(t,e,n){this.key=t;this.value=e;this.negated=n;this.type=13}static create(t,e,n=null){return Co(e,i=>new r(t,i,n))}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.value,t.key,t.value)}equals(t){return t.type===this.type?this.key===t.key&&this.value===t.value:!1}substituteConstants(){return this}evaluate(t){return typeof this.value=="string"?!1:parseFloat(t.getValue(this.key))>=this.value}serialize(){return`${this.key} >= ${this.value}`}keys(){return[this.key]}map(t){return t.mapGreaterEquals(this.key,this.value)}negate(){return this.negated||(this.negated=ei.create(this.key,this.value,this)),this.negated}},ei=class r{constructor(t,e,n){this.key=t;this.value=e;this.negated=n;this.type=14}static create(t,e,n=null){return Co(e,i=>new r(t,i,n))}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.value,t.key,t.value)}equals(t){return t.type===this.type?this.key===t.key&&this.value===t.value:!1}substituteConstants(){return this}evaluate(t){return typeof this.value=="string"?!1:parseFloat(t.getValue(this.key))<this.value}serialize(){return`${this.key} < ${this.value}`}keys(){return[this.key]}map(t){return t.mapSmaller(this.key,this.value)}negate(){return this.negated||(this.negated=Zr.create(this.key,this.value,this)),this.negated}},ti=class r{constructor(t,e,n){this.key=t;this.value=e;this.negated=n;this.type=15}static create(t,e,n=null){return Co(e,i=>new r(t,i,n))}cmp(t){return t.type!==this.type?this.type-t.type:mn(this.key,this.value,t.key,t.value)}equals(t){return t.type===this.type?this.key===t.key&&this.value===t.value:!1}substituteConstants(){return this}evaluate(t){return typeof this.value=="string"?!1:parseFloat(t.getValue(this.key))<=this.value}serialize(){return`${this.key} <= ${this.value}`}keys(){return[this.key]}map(t){return t.mapSmallerEquals(this.key,this.value)}negate(){return this.negated||(this.negated=tr.create(this.key,this.value,this)),this.negated}},ni=class r{constructor(t,e){this.key=t;this.regexp=e;this.type=7;this.negated=null}static create(t,e){return new r(t,e)}cmp(t){if(t.type!==this.type)return this.type-t.type;if(this.key<t.key)return-1;if(this.key>t.key)return 1;let e=this.regexp?this.regexp.source:"",n=t.regexp?t.regexp.source:"";return e<n?-1:e>n?1:0}equals(t){if(t.type===this.type){let e=this.regexp?this.regexp.source:"",n=t.regexp?t.regexp.source:"";return this.key===t.key&&e===n}return!1}substituteConstants(){return this}evaluate(t){let e=t.getValue(this.key);return this.regexp?this.regexp.test(e):!1}serialize(){let t=this.regexp?`/${this.regexp.source}/${this.regexp.flags}`:"/invalid/";return`${this.key} =~ ${t}`}keys(){return[this.key]}map(t){return t.mapRegex(this.key,this.regexp)}negate(){return this.negated||(this.negated=Ja.create(this)),this.negated}},Ja=class r{constructor(t){this._actual=t;this.type=8}static create(t){return new r(t)}cmp(t){return t.type!==this.type?this.type-t.type:this._actual.cmp(t._actual)}equals(t){return t.type===this.type?this._actual.equals(t._actual):!1}substituteConstants(){return this}evaluate(t){return!this._actual.evaluate(t)}serialize(){return`!(${this._actual.serialize()})`}keys(){return this._actual.keys()}map(t){return new r(this._actual.map(t))}negate(){return this._actual}};function Ed(r){let t=null;for(let e=0,n=r.length;e<n;e++){let i=r[e].substituteConstants();if(r[e]!==i&&t===null){t=[];for(let o=0;o<e;o++)t[o]=r[o]}t!==null&&(t[e]=i)}return t===null?r:t}var Eo=class r{constructor(t,e){this.expr=t;this.negated=e;this.type=6}static create(t,e,n){return r._normalizeArr(t,e,n)}cmp(t){if(t.type!==this.type)return this.type-t.type;if(this.expr.length<t.expr.length)return-1;if(this.expr.length>t.expr.length)return 1;for(let e=0,n=this.expr.length;e<n;e++){let i=Qr(this.expr[e],t.expr[e]);if(i!==0)return i}return 0}equals(t){if(t.type===this.type){if(this.expr.length!==t.expr.length)return!1;for(let e=0,n=this.expr.length;e<n;e++)if(!this.expr[e].equals(t.expr[e]))return!1;return!0}return!1}substituteConstants(){let t=Ed(this.expr);return t===this.expr?this:r.create(t,this.negated,!1)}evaluate(t){for(let e=0,n=this.expr.length;e<n;e++)if(!this.expr[e].evaluate(t))return!1;return!0}static _normalizeArr(t,e,n){let i=[],o=!1;for(let s of t)if(s){if(s.type===1){o=!0;continue}if(s.type===0)return we.INSTANCE;if(s.type===6){i.push(...s.expr);continue}i.push(s)}if(i.length===0&&o)return De.INSTANCE;if(i.length!==0){if(i.length===1)return i[0];i.sort(Qr);for(let s=1;s<i.length;s++)i[s-1].equals(i[s])&&(i.splice(s,1),s--);if(i.length===1)return i[0];for(;i.length>1;){let s=i[i.length-1];if(s.type!==9)break;i.pop();let a=i.pop(),l=i.length===0,c=ri.create(s.expr.map(d=>r.create([d,a],null,n)),null,l);c&&(i.push(c),i.sort(Qr))}if(i.length===1)return i[0];if(n){for(let s=0;s<i.length;s++)for(let a=s+1;a<i.length;a++)if(i[s].negate().equals(i[a]))return we.INSTANCE;if(i.length===1)return i[0]}return new r(i,e)}}serialize(){return this.expr.map(t=>t.serialize()).join(" && ")}keys(){let t=[];for(let e of this.expr)t.push(...e.keys());return t}map(t){return new r(this.expr.map(e=>e.map(t)),null)}negate(){if(!this.negated){let t=[];for(let e of this.expr)t.push(e.negate());this.negated=ri.create(t,this,!0)}return this.negated}},ri=class r{constructor(t,e){this.expr=t;this.negated=e;this.type=9}static create(t,e,n){return r._normalizeArr(t,e,n)}cmp(t){if(t.type!==this.type)return this.type-t.type;if(this.expr.length<t.expr.length)return-1;if(this.expr.length>t.expr.length)return 1;for(let e=0,n=this.expr.length;e<n;e++){let i=Qr(this.expr[e],t.expr[e]);if(i!==0)return i}return 0}equals(t){if(t.type===this.type){if(this.expr.length!==t.expr.length)return!1;for(let e=0,n=this.expr.length;e<n;e++)if(!this.expr[e].equals(t.expr[e]))return!1;return!0}return!1}substituteConstants(){let t=Ed(this.expr);return t===this.expr?this:r.create(t,this.negated,!1)}evaluate(t){for(let e=0,n=this.expr.length;e<n;e++)if(this.expr[e].evaluate(t))return!0;return!1}static _normalizeArr(t,e,n){let i=[],o=!1;if(t){for(let s=0,a=t.length;s<a;s++){let l=t[s];if(l){if(l.type===0){o=!0;continue}if(l.type===1)return De.INSTANCE;if(l.type===9){i=i.concat(l.expr);continue}i.push(l)}}if(i.length===0&&o)return we.INSTANCE;i.sort(Qr)}if(i.length!==0){if(i.length===1)return i[0];for(let s=1;s<i.length;s++)i[s-1].equals(i[s])&&(i.splice(s,1),s--);if(i.length===1)return i[0];if(n){for(let s=0;s<i.length;s++)for(let a=s+1;a<i.length;a++)if(i[s].negate().equals(i[a]))return De.INSTANCE;if(i.length===1)return i[0]}return new r(i,e)}}serialize(){return this.expr.map(t=>t.serialize()).join(" || ")}keys(){let t=[];for(let e of this.expr)t.push(...e.keys());return t}map(t){return new r(this.expr.map(e=>e.map(t)),null)}negate(){if(!this.negated){let t=[];for(let e of this.expr)t.push(e.negate());for(;t.length>1;){let e=t.shift(),n=t.shift(),i=[];for(let o of Rd(e))for(let s of Rd(n))i.push(Eo.create([o,s],null,!1));t.unshift(r.create(i,null,!1))}this.negated=r.create(t,this,!0)}return this.negated}},wo=class r extends hn{static{this._info=[]}static all(){return r._info.values()}constructor(t,e,n){super(t,null),this._defaultValue=e,typeof n=="object"?r._info.push({...n,key:t}):n!==!0&&r._info.push({key:t,description:n,type:e!=null?typeof e:void 0})}bindTo(t){return t.createKey(this.key,this._defaultValue)}getValue(t){return t.getContextKeyValue(this.key)}toNegated(){return this.negate()}isEqualTo(t){return Yr.create(this.key,t)}notEqualsTo(t){return Xr.create(this.key,t)}greater(t){return tr.create(this.key,t)}},tx=Le("contextKeyService");function wd(r,t){return r<t?-1:r>t?1:0}function mn(r,t,e,n){return r<e?-1:r>e?1:t<n?-1:t>n?1:0}function Rd(r){return r.type===9?r.expr:[r]}var Ce=Le("logService"),vx=Le("loggerService");function Qa(r){return Ir(r)}var Cd=3;function _g(r,t){return r!==0&&r<=t}function nr(r,t=!1){let e="";for(let n=0;n<r.length;n++){let i=r[n];if(i instanceof Error&&(i=Ka(i,t)),typeof i=="object")try{i=JSON.stringify(i)}catch{}e+=(n>0?" ":"")+i}return e}var Po=class extends A{constructor(){super(...arguments);this.level=Cd;this._onDidChangeLogLevel=this._register(new b)}get onDidChangeLogLevel(){return this._onDidChangeLogLevel.event}setLevel(e){this.level!==e&&(this.level=e,this._onDidChangeLogLevel.fire(this.level))}getLevel(){return this.level}checkLogLevel(e){return _g(this.level,e)}canLog(e){return this._store.isDisposed?!1:this.checkLogLevel(e)}},ii=class extends Po{constructor(e){super();this.logAlways=e}checkLogLevel(e){return this.logAlways||super.checkLogLevel(e)}trace(e,...n){this.canLog(1)&&this.log(1,nr([e,...n],!0))}debug(e,...n){this.canLog(2)&&this.log(2,nr([e,...n]))}info(e,...n){this.canLog(3)&&this.log(3,nr([e,...n]))}warn(e,...n){this.canLog(4)&&this.log(4,nr([e,...n]))}error(e,...n){if(this.canLog(5))if(e instanceof Error){let i=Array.prototype.slice.call(arguments);i[0]=e.stack,this.log(5,nr(i))}else this.log(5,nr([e,...n]))}flush(){}};var Ao=class extends Po{constructor(e){super();this.loggers=e;e.length&&this.setLevel(e[0].getLevel())}setLevel(e){for(let n of this.loggers)n.setLevel(e);super.setLevel(e)}trace(e,...n){for(let i of this.loggers)i.trace(e,...n)}debug(e,...n){for(let i of this.loggers)i.debug(e,...n)}info(e,...n){for(let i of this.loggers)i.info(e,...n)}warn(e,...n){for(let i of this.loggers)i.warn(e,...n)}error(e,...n){for(let i of this.loggers)i.error(e,...n)}flush(){for(let e of this.loggers)e.flush()}dispose(){for(let e of this.loggers)e.dispose();super.dispose()}},oi=class extends A{constructor(e,n,i){super();this.logLevel=e;this.logsHome=n;this._loggers=new ht;this._onDidChangeLoggers=this._register(new b);this.onDidChangeLoggers=this._onDidChangeLoggers.event;this._onDidChangeLogLevel=this._register(new b);this.onDidChangeLogLevel=this._onDidChangeLogLevel.event;this._onDidChangeVisibility=this._register(new b);this.onDidChangeVisibility=this._onDidChangeVisibility.event;if(i)for(let o of i)this._loggers.set(o.resource,{logger:void 0,info:o})}getLoggerEntry(e){return Jt(e)?[...this._loggers.values()].find(n=>n.info.id===e):this._loggers.get(e)}getLogger(e){return this.getLoggerEntry(e)?.logger}createLogger(e,n){let i=this.toResource(e),o=Jt(e)?e:n?.id??er(i.toString()).toString(16),s=this._loggers.get(i)?.logger,a=n?.logLevel==="always"?1:n?.logLevel;s||(s=this.doCreateLogger(i,a??this.getLogLevel(i)??this.logLevel,{...n,id:o}));let l={logger:s,info:{resource:i,id:o,logLevel:a,name:n?.name,hidden:n?.hidden,group:n?.group,extensionId:n?.extensionId,when:n?.when}};return this.registerLogger(l.info),this._loggers.set(i,l),s}toResource(e){return Jt(e)?G(this.logsHome,`${e.replace(/[\\/:\*\?"<>\|]/g,"")}.log`):e}setLogLevel(e,n){if(m.isUri(e)){let i=e,o=n,s=this._loggers.get(i);s&&o!==s.info.logLevel&&(s.info.logLevel=o===this.logLevel?void 0:o,s.logger?.setLevel(o),this._loggers.set(s.info.resource,s),this._onDidChangeLogLevel.fire([i,o]))}else{this.logLevel=e;for(let[i,o]of this._loggers.entries())this._loggers.get(i)?.info.logLevel===void 0&&o.logger?.setLevel(this.logLevel);this._onDidChangeLogLevel.fire(this.logLevel)}}setVisibility(e,n){let i=this.getLoggerEntry(e);i&&n!==!i.info.hidden&&(i.info.hidden=!n,this._loggers.set(i.info.resource,i),this._onDidChangeVisibility.fire([i.info.resource,n]))}getLogLevel(e){let n;return e&&(n=this._loggers.get(e)?.info.logLevel),n??this.logLevel}registerLogger(e){let n=this._loggers.get(e.resource);n?n.info.hidden!==e.hidden&&this.setVisibility(e.resource,!e.hidden):(this._loggers.set(e.resource,{info:e,logger:void 0}),this._onDidChangeLoggers.fire({added:[e],removed:[]}))}deregisterLogger(e){let n=this.toResource(e),i=this._loggers.get(n);i&&(i.logger&&i.logger.dispose(),this._loggers.delete(n),this._onDidChangeLoggers.fire({added:[],removed:[i.info]}))}*getRegisteredLoggers(){for(let e of this._loggers.values())yield e.info}getRegisteredLogger(e){return this._loggers.get(e)?.info}dispose(){this._loggers.forEach(e=>e.logger?.dispose()),this._loggers.clear(),super.dispose()}};function Pd(r){if(r.verbose)return 1;if(typeof r.logLevel=="string"){let t=Rg(r.logLevel.toLowerCase());if(t!==void 0)return t}return Cd}function xg(r){switch(r){case 1:return"trace";case 2:return"debug";case 3:return"info";case 4:return"warn";case 5:return"error";case 0:return"off"}}function Rg(r){switch(r){case"trace":return 1;case"debug":return 2;case"info":return 3;case"warn":return 4;case"error":return 5;case"critical":return 5;case"off":return 0}}var yx=new wo("logLevel",xg(3));var Eg={"root/agentsChanged":!1,"root/activeSessionsChanged":!1,"session/ready":!1,"session/creationFailed":!1,"session/turnStarted":!0,"session/delta":!1,"session/responsePart":!1,"session/toolCallStart":!1,"session/toolCallDelta":!1,"session/toolCallReady":!1,"session/toolCallConfirmed":!0,"session/toolCallComplete":!0,"session/toolCallResultConfirmed":!0,"session/turnComplete":!1,"session/turnCancelled":!0,"session/error":!1,"session/titleChanged":!0,"session/usage":!1,"session/reasoning":!1,"session/modelChanged":!0,"session/serverToolsChanged":!1,"session/activeClientChanged":!0,"session/activeClientToolsChanged":!0,"session/pendingMessageSet":!0,"session/pendingMessageRemoved":!0,"session/queuedMessagesReordered":!0,"session/customizationsChanged":!1,"session/customizationToggled":!0,"session/truncated":!0};function Xa(r,t){let e=`Unhandled action type: ${JSON.stringify(r)}`;(t??console.warn)(e)}function ai(r){return{toolCallId:r.toolCallId,toolName:r.toolName,displayName:r.displayName,toolClientId:r.toolClientId,_meta:r._meta}}function Ya(r,t,e,n,i){if(!r.activeTurn||r.activeTurn.id!==t)return r;let o=r.activeTurn,s=o.responseParts.map(l=>{if(l.kind!=="toolCall")return l;let c=l.toolCall;return c.status==="completed"||c.status==="cancelled"?l:{kind:"toolCall",toolCall:{status:"cancelled",...ai(c),invocationMessage:c.status==="streaming"?c.invocationMessage??"":c.invocationMessage,toolInput:c.status==="streaming"?void 0:c.toolInput,reason:"skipped"}}}),a={id:o.id,userMessage:o.userMessage,responseParts:s,usage:o.usage,state:e,error:i};return{...r,turns:[...r.turns,a],activeTurn:void 0,summary:{...r.summary,status:n,modifiedAt:Date.now()}}}function si(r,t,e,n){let i=r.activeTurn;if(!i||i.id!==t)return r;let o=!1,s=i.responseParts.map(a=>{if(a.kind==="toolCall"&&a.toolCall.toolCallId===e){let l=n(a.toolCall);return l===a.toolCall?a:(o=!0,{...a,toolCall:l})}return a});return o?{...r,activeTurn:{...i,responseParts:s}}:r}function Ad(r,t,e,n){let i=r.activeTurn;if(!i||i.id!==t)return r;let o=!1,s=i.responseParts.map(a=>!o&&(a.kind==="toolCall"?a.toolCall.toolCallId:"id"in a?a.id:void 0)===e?(o=!0,n(a)):a);return o?{...r,activeTurn:{...i,responseParts:s}}:r}function Za(r,t,e){switch(t.type){case"root/agentsChanged":return{...r,agents:t.agents};case"root/activeSessionsChanged":return{...r,activeSessions:t.activeSessions};default:return Xa(t,e),r}}function el(r,t,e){switch(t.type){case"session/ready":return{...r,lifecycle:"ready",summary:{...r.summary,status:"idle"}};case"session/creationFailed":return{...r,lifecycle:"creationFailed",creationError:t.error};case"session/turnStarted":{let n={...r,summary:{...r.summary,status:"in-progress",modifiedAt:Date.now()},activeTurn:{id:t.turnId,userMessage:t.userMessage,responseParts:[],usage:void 0}};if(t.queuedMessageId&&(n.steeringMessage?.id===t.queuedMessageId&&(n={...n,steeringMessage:void 0}),n.queuedMessages)){let i=n.queuedMessages.filter(o=>o.id!==t.queuedMessageId);n={...n,queuedMessages:i.length>0?i:void 0}}return n}case"session/delta":return Ad(r,t.turnId,t.partId,n=>n.kind==="markdown"?{...n,content:n.content+t.content}:n);case"session/responsePart":return!r.activeTurn||r.activeTurn.id!==t.turnId?r:{...r,activeTurn:{...r.activeTurn,responseParts:[...r.activeTurn.responseParts,t.part]}};case"session/turnComplete":return Ya(r,t.turnId,"complete","idle");case"session/turnCancelled":return Ya(r,t.turnId,"cancelled","idle");case"session/error":return Ya(r,t.turnId,"error","error",t.error);case"session/toolCallStart":return!r.activeTurn||r.activeTurn.id!==t.turnId?r:{...r,activeTurn:{...r.activeTurn,responseParts:[...r.activeTurn.responseParts,{kind:"toolCall",toolCall:{toolCallId:t.toolCallId,toolName:t.toolName,displayName:t.displayName,toolClientId:t.toolClientId,_meta:t._meta,status:"streaming"}}]}};case"session/toolCallDelta":return si(r,t.turnId,t.toolCallId,n=>n.status!=="streaming"?n:{...n,partialInput:(n.partialInput??"")+t.content,invocationMessage:t.invocationMessage??n.invocationMessage});case"session/toolCallReady":return si(r,t.turnId,t.toolCallId,n=>{if(n.status!=="streaming"&&n.status!=="running")return n;let i=ai(n);return t.confirmed?{status:"running",...i,invocationMessage:t.invocationMessage,toolInput:t.toolInput,confirmed:t.confirmed}:{status:"pending-confirmation",...i,invocationMessage:t.invocationMessage,toolInput:t.toolInput,confirmationTitle:t.confirmationTitle}});case"session/toolCallConfirmed":return si(r,t.turnId,t.toolCallId,n=>{if(n.status!=="pending-confirmation")return n;let i=ai(n);return t.approved?{status:"running",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:t.confirmed}:{status:"cancelled",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,reason:t.reason,reasonMessage:t.reasonMessage,userSuggestion:t.userSuggestion}});case"session/toolCallComplete":return si(r,t.turnId,t.toolCallId,n=>{if(n.status!=="running"&&n.status!=="pending-confirmation")return n;let i=ai(n),o=n.status==="running"?n.confirmed:"not-needed";return t.requiresResultConfirmation?{status:"pending-result-confirmation",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:o,...t.result}:{status:"completed",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:o,...t.result}});case"session/toolCallResultConfirmed":return si(r,t.turnId,t.toolCallId,n=>{if(n.status!=="pending-result-confirmation")return n;let i=ai(n);return t.approved?{status:"completed",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,confirmed:n.confirmed,success:n.success,pastTenseMessage:n.pastTenseMessage,content:n.content,structuredContent:n.structuredContent,error:n.error}:{status:"cancelled",...i,invocationMessage:n.invocationMessage,toolInput:n.toolInput,reason:"result-denied"}});case"session/titleChanged":return{...r,summary:{...r.summary,title:t.title,modifiedAt:Date.now()}};case"session/usage":return!r.activeTurn||r.activeTurn.id!==t.turnId?r:{...r,activeTurn:{...r.activeTurn,usage:t.usage}};case"session/reasoning":return Ad(r,t.turnId,t.partId,n=>n.kind==="reasoning"?{...n,content:n.content+t.content}:n);case"session/modelChanged":return{...r,summary:{...r.summary,model:t.model,modifiedAt:Date.now()}};case"session/serverToolsChanged":return{...r,serverTools:t.tools};case"session/activeClientChanged":return{...r,activeClient:t.activeClient??void 0};case"session/activeClientToolsChanged":return r.activeClient?{...r,activeClient:{...r.activeClient,tools:t.tools}}:r;case"session/customizationsChanged":return{...r,customizations:t.customizations};case"session/customizationToggled":{let n=r.customizations;if(!n)return r;let i=n.findIndex(s=>s.customization.uri===t.uri);if(i<0)return r;let o=[...n];return o[i]={...n[i],enabled:t.enabled},{...r,customizations:o}}case"session/truncated":{let n;if(t.turnId===void 0)n=[];else{let i=r.turns.findIndex(o=>o.id===t.turnId);if(i<0)return r;n=r.turns.slice(0,i+1)}return{...r,turns:n,activeTurn:void 0,summary:{...r.summary,status:"idle",modifiedAt:Date.now()}}}case"session/pendingMessageSet":{let n={id:t.id,userMessage:t.userMessage};if(t.kind==="steering")return{...r,steeringMessage:n};let i=r.queuedMessages??[],o=i.findIndex(s=>s.id===t.id);if(o>=0){let s=[...i];return s[o]=n,{...r,queuedMessages:s}}return{...r,queuedMessages:[...i,n]}}case"session/pendingMessageRemoved":{if(t.kind==="steering")return!r.steeringMessage||r.steeringMessage.id!==t.id?r:{...r,steeringMessage:void 0};let n=r.queuedMessages;if(!n)return r;let i=n.filter(o=>o.id!==t.id);return i.length===n.length?r:{...r,queuedMessages:i.length>0?i:void 0}}case"session/queuedMessagesReordered":{let n=r.queuedMessages;if(!n)return r;let i=new Map(n.map(a=>[a.id,a])),o=new Set,s=t.order.filter(a=>i.has(a)&&!o.has(a)?(o.add(a),!0):!1).map(a=>i.get(a));for(let a of n)o.has(a.id)||s.push(a);return{...r,queuedMessages:s}}default:return Xa(t,e),r}}var rr=class extends A{constructor(e){super();this._logService=e;this._serverSeq=0;this._sessionStates=new Map;this._activeTurnToSession=new Map;this._onDidEmitEnvelope=this._register(new b);this.onDidEmitEnvelope=this._onDidEmitEnvelope.event;this._onDidEmitNotification=this._register(new b);this.onDidEmitNotification=this._onDidEmitNotification.event;this._log=e=>this._logService.warn(`[SessionStateManager] ${e}`);this._rootState=od()}get hasActiveSessions(){return this._activeTurnToSession.size>0}get rootState(){return this._rootState}getSessionState(e){return this._sessionStates.get(e)}get serverSeq(){return this._serverSeq}getSnapshot(e){if(e===vo)return{resource:e,state:this._rootState,fromSeq:this._serverSeq};let n=this._sessionStates.get(e);if(n)return{resource:e,state:n,fromSeq:this._serverSeq}}createSession(e){let n=e.resource;if(this._sessionStates.has(n))return this._logService.warn(`[SessionStateManager] Session already exists: ${n}`),this._sessionStates.get(n);let i=Na(e);return this._sessionStates.set(n,i),this._logService.trace(`[SessionStateManager] Created session: ${n}`),this._onDidEmitNotification.fire({type:"notify/sessionAdded",summary:e}),i}restoreSession(e,n){let i=e.resource;if(this._sessionStates.has(i))return this._logService.warn(`[SessionStateManager] Session already exists (restore): ${i}`),this._sessionStates.get(i);let o={...Na(e),lifecycle:"ready",turns:n};return this._sessionStates.set(i,o),this._logService.trace(`[SessionStateManager] Restored session: ${i} (${n.length} turns)`),o}removeSession(e){let n=this._sessionStates.get(e);n&&(n.activeTurn&&this._activeTurnToSession.delete(n.activeTurn.id),this._sessionStates.delete(e),this._logService.trace(`[SessionStateManager] Removed session: ${e}`))}deleteSession(e){this.removeSession(e),this._onDidEmitNotification.fire({type:"notify/sessionRemoved",session:e})}getActiveTurnId(e){return this._sessionStates.get(e)?.activeTurn?.id}dispatchServerAction(e){this._applyAndEmit(e,void 0)}dispatchClientAction(e,n){return this._applyAndEmit(e,n)}_applyAndEmit(e,n){let i;if(Ju(e)&&(this._rootState=Za(this._rootState,e,this._log),i=this._rootState),go(e)){let s=e,a=s.session,l=this._sessionStates.get(a);if(l){let c=el(l,s,this._log);this._sessionStates.set(a,c),s.type==="session/turnStarted"?(this._activeTurnToSession.set(s.turnId,a),this.dispatchServerAction({type:"root/activeSessionsChanged",activeSessions:this._activeTurnToSession.size})):(s.type==="session/turnComplete"||s.type==="session/turnCancelled"||s.type==="session/error")&&(this._activeTurnToSession.delete(s.turnId),this.dispatchServerAction({type:"root/activeSessionsChanged",activeSessions:this._activeTurnToSession.size})),i=c}else this._logService.warn(`[SessionStateManager] Action for unknown session: ${a}, type=${e.type}`)}let o={action:e,serverSeq:++this._serverSeq,origin:n};return this._logService.trace(`[SessionStateManager] Emitting envelope: seq=${o.serverSeq}, type=${e.type}${n?`, origin=${n.clientId}:${n.clientSeq}`:""}`),this._onDidEmitEnvelope.fire(o),i}};rr=D([re(0,Ce)],rr);var ko=class extends A{constructor(e,n,i){super();this._logService=e;this._fileService=n;this._sessionDataService=i;this._onDidAction=this._register(new b);this.onDidAction=this._onDidAction.event;this._onDidNotification=this._register(new b);this.onDidNotification=this._onDidNotification.event;this._providers=new Map;this._sessionToProvider=new Map;this._providerSubscriptions=this._register(new N);this._agents=jr("agents",[]);this._logService.info("AgentService initialized"),this._stateManager=this._register(new rr(e)),this._register(this._stateManager.onDidEmitEnvelope(o=>this._onDidAction.fire(o))),this._register(this._stateManager.onDidEmitNotification(o=>this._onDidNotification.fire(o))),this._sideEffects=this._register(new So(this._stateManager,{getAgent:o=>this._findProviderForSession(o),sessionDataService:this._sessionDataService,agents:this._agents},this._logService))}get stateManager(){return this._stateManager}registerProvider(e){if(this._providers.has(e.id))throw new Error(`Agent provider already registered: ${e.id}`);this._logService.info(`Registering agent provider: ${e.id}`),this._providers.set(e.id,e),this._providerSubscriptions.add(this._sideEffects.registerProgressListener(e)),this._defaultProvider||(this._defaultProvider=e.id),this._updateAgents()}async listAgents(){return[...this._providers.values()].map(e=>e.getDescriptor())}async getResourceMetadata(){return{resources:[...this._providers.values()].flatMap(n=>n.getProtectedResources())}}getResourceMetadataSync(){return{resources:[...this._providers.values()].flatMap(n=>n.getProtectedResources())}}async authenticate(e){this._logService.trace(`[AgentService] authenticate called: resource=${e.resource}`);for(let n of this._providers.values())if(n.getProtectedResources().some(o=>o.resource===e.resource)&&await n.authenticate(e.resource,e.token))return{authenticated:!0};return{authenticated:!1}}async listSessions(){this._logService.trace("[AgentService] listSessions called");let n=(await Promise.all([...this._providers.values()].map(o=>o.listSessions()))).flat(),i=await Promise.all(n.map(async o=>{try{let s=await this._sessionDataService.tryOpenDatabase(o.session);if(!s)return o;try{let a=await s.object.getMetadata("customTitle");if(a)return{...o,summary:a}}finally{s.dispose()}}catch{}return o}));return this._logService.trace(`[AgentService] listSessions returned ${i.length} sessions`),i}async refreshModels(){this._logService.trace("[AgentService] refreshModels called"),this._updateAgents()}async createSession(e){let n=e?.provider??this._defaultProvider,i=n?this._providers.get(n):void 0;if(!i)throw new Error(`No agent provider registered for: ${n??"(none)"}`);this._logService.trace("[AgentService] createSession: initializing auto-approver and creating session...");let[,o]=await Promise.all([this._sideEffects.initialize(),i.createSession(e)]);if(this._logService.trace("[AgentService] createSession: initialization complete"),this._logService.trace(`[AgentService] createSession: provider=${i.id} model=${e?.model??"(default)"}`),this._sessionToProvider.set(o.toString(),i.id),this._logService.trace(`[AgentService] createSession returned: ${o.toString()}`),e?.fork){let s=this._stateManager.getSessionState(e.fork.session.toString()),a=[];s&&(a=s.turns.slice(0,e.fork.turnIndex+1).map(d=>({...d,id:ge()})));let l={resource:o.toString(),provider:i.id,title:s?.summary.title??"Forked Session",status:"idle",createdAt:Date.now(),modifiedAt:Date.now(),workingDirectory:e.workingDirectory?.toString()},c=this._stateManager.createSession(l);c.turns=a}else{let s={resource:o.toString(),provider:i.id,title:"New Session",status:"idle",createdAt:Date.now(),modifiedAt:Date.now(),workingDirectory:e?.workingDirectory?.toString()};this._stateManager.createSession(s)}return this._stateManager.dispatchServerAction({type:"session/ready",session:o.toString()}),o}async disposeSession(e){this._logService.trace(`[AgentService] disposeSession: ${e.toString()}`);let n=this._findProviderForSession(e);n&&(await n.disposeSession(e),this._sessionToProvider.delete(e.toString())),this._stateManager.deleteSession(e.toString())}async subscribe(e){this._logService.trace(`[AgentService] subscribe: ${e.toString()}`);let n=this._stateManager.getSnapshot(e.toString());if(n||(await this.restoreSession(e),n=this._stateManager.getSnapshot(e.toString())),!n)throw new Error(`Cannot subscribe to unknown resource: ${e.toString()}`);return n}unsubscribe(e){this._logService.trace(`[AgentService] unsubscribe: ${e.toString()}`)}dispatchAction(e,n,i){this._logService.trace(`[AgentService] dispatchAction: type=${e.type}, clientId=${n}, clientSeq=${i}`,e);let o={clientId:n,clientSeq:i},s=this._stateManager.dispatchClientAction(e,o);this._logService.trace("[AgentService] resulting state:",s),this._sideEffects.handleAction(e)}async resourceList(e){let n;try{n=await this._fileService.resolve(e)}catch{throw new j(xe.NotFound,`Directory not found: ${e.toString()}`)}if(!n.isDirectory)throw new j(xe.NotFound,`Not a directory: ${e.toString()}`);return{entries:(n.children??[]).map(o=>({name:o.name,type:o.isDirectory?"directory":"file"}))}}async restoreSession(e){let n=e.toString();if(this._stateManager.getSessionState(n))return;let i=this._findProviderForSession(e);if(!i)throw new j(Vt,`No agent for session: ${n}`);let o;try{o=await i.listSessions()}catch(p){if(p instanceof j)throw p;let h=p instanceof Error?p.message:String(p);throw new j(Xn,`Failed to list sessions for ${n}: ${h}`)}let s=o.find(p=>p.session.toString()===n);if(!s)throw new j(Vt,`Session not found on backend: ${n}`);let a;try{a=await i.getSessionMessages(e)}catch(p){if(p instanceof j)throw p;let h=p instanceof Error?p.message:String(p);throw new j(Xn,`Failed to restore session ${n}: ${h}`)}let l=this._buildTurnsFromMessages(a),c=s.summary??"Session",d=this._sessionDataService.tryOpenDatabase?.(e);if(d)try{let p=await d;if(p)try{let h=await p.object.getMetadata("customTitle");h&&(c=h)}finally{p.dispose()}}catch{}let u={resource:n,provider:i.id,title:c,status:"idle",createdAt:s.startTime,modifiedAt:s.modifiedTime,workingDirectory:s.workingDirectory?.toString()};this._stateManager.restoreSession(u,l),this._logService.info(`[AgentService] Restored session ${n} with ${l.length} turns`)}async resourceRead(e){let n=bd(e.toString());if(n)return this._fetchSessionDbContent(n);try{return{data:(await this._fileService.readFile(e)).value.toString(),encoding:"utf-8",contentType:"text/plain"}}catch{throw new j(xe.NotFound,`Content not found: ${e.toString()}`)}}async resourceWrite(e){let n=typeof e.uri=="string"?m.parse(e.uri):m.revive(e.uri),i;e.encoding==="base64"?i=Ki(e.data):i=S.fromString(e.data);try{return e.createOnly?await this._fileService.createFile(n,i,{overwrite:!1}):await this._fileService.writeFile(n,i),{}}catch(o){let s=ut(o);throw s==="EntryExists"?new j(xe.AlreadyExists,`File already exists: ${n.toString()}`):s==="NoPermissions"?new j(xe.PermissionDenied,`Permission denied: ${n.toString()}`):new j(xe.NotFound,`Failed to write file: ${n.toString()}`)}}async resourceCopy(e){let n=m.parse(e.source),i=m.parse(e.destination);try{return await this._fileService.copy(n,i,!e.failIfExists),{}}catch(o){let s=ut(o);throw s==="EntryExists"?new j(xe.AlreadyExists,`Destination already exists: ${i.toString()}`):s==="NoPermissions"?new j(xe.PermissionDenied,`Permission denied: ${n.toString()}`):new j(xe.NotFound,`Source not found: ${n.toString()}`)}}async resourceDelete(e){let n=m.parse(e.uri);try{return await this._fileService.del(n,{recursive:e.recursive}),{}}catch(i){throw ut(i)==="NoPermissions"?new j(xe.PermissionDenied,`Permission denied: ${n.toString()}`):new j(xe.NotFound,`Resource not found: ${n.toString()}`)}}async resourceMove(e){let n=m.parse(e.source),i=m.parse(e.destination);try{return await this._fileService.move(n,i,!e.failIfExists),{}}catch(o){let s=ut(o);throw s==="EntryExists"?new j(xe.AlreadyExists,`Destination already exists: ${i.toString()}`):s==="NoPermissions"?new j(xe.PermissionDenied,`Permission denied: ${n.toString()}`):new j(xe.NotFound,`Source not found: ${n.toString()}`)}}async shutdown(){this._logService.info("AgentService: shutting down all providers...");let e=[];for(let n of this._providers.values())e.push(n.shutdown());await Promise.all(e),this._sessionToProvider.clear()}_buildTurnsFromMessages(e){let n=[],i,o=(a,l)=>{n.push({id:a.id,userMessage:a.userMessage,responseParts:a.responseParts,usage:void 0,state:l})},s=(a,l)=>({id:a,userMessage:{text:l},responseParts:[],pendingTools:new Map});for(let a of e)if(a.type==="message"&&a.role==="user")i&&o(i,"cancelled"),i=s(a.messageId,a.content);else if(a.type==="message"&&a.role==="assistant")i||(i=s(a.messageId,"")),a.content&&i.responseParts.push({kind:"markdown",id:ge(),content:a.content}),(!a.toolRequests||a.toolRequests.length===0)&&(o(i,"complete"),i=void 0);else if(a.type==="tool_start")i?.pendingTools.set(a.toolCallId,a);else if(a.type==="tool_complete"&&i){let l=i.pendingTools.get(a.toolCallId);i.pendingTools.delete(a.toolCallId);let c={status:"completed",toolCallId:a.toolCallId,toolName:l?.toolName??"unknown",displayName:l?.displayName??"Unknown Tool",invocationMessage:l?.invocationMessage??"",toolInput:l?.toolInput,success:a.result.success,pastTenseMessage:a.result.pastTenseMessage,content:a.result.content,error:a.result.error,confirmed:"not-needed",_meta:l?{toolKind:l.toolKind,language:l.language}:void 0};i.responseParts.push({kind:"toolCall",toolCall:c})}return i&&o(i,"cancelled"),n}async _fetchSessionDbContent(e){let n=m.parse(e.sessionUri),i=this._sessionDataService.openDatabase(n);try{let o=await i.object.readFileEditContent(e.toolCallId,e.filePath);if(!o)throw new j(xe.NotFound,`File edit not found: toolCallId=${e.toolCallId}, filePath=${e.filePath}`);let s=e.part==="before"?o.beforeContent:o.afterContent;if(!s)throw new j(xe.NotFound,`No ${e.part} content for: toolCallId=${e.toolCallId}, filePath=${e.filePath}`);return{data:new TextDecoder().decode(s),encoding:"utf-8",contentType:"text/plain"}}finally{i.dispose()}}_findProviderForSession(e){let n=typeof e=="string"?e:e.toString(),i=this._sessionToProvider.get(n);if(i)return this._providers.get(i);let o=ie.provider(e);if(o)return this._providers.get(o);if(this._defaultProvider)return this._providers.get(this._defaultProvider)}_updateAgents(){this._agents.set([...this._providers.values()],void 0)}dispose(){for(let e of this._providers.values())e.dispose();this._providers.clear(),super.dispose()}};import{CopilotClient as am}from"@github/copilot-sdk";import{rgPath as lm}from"@vscode/ripgrep";var nl;(t=>t.DEFAULT={allowTrailingComma:!0})(nl||={});function wg(r,t=!1){let e=0,n=r.length,i="",o=0,s=16,a=0;function l(g){let E=0,R=0;for(;E<g;){let C=r.charCodeAt(e);if(C>=48&&C<=57)R=R*16+C-48;else if(C>=65&&C<=70)R=R*16+C-65+10;else if(C>=97&&C<=102)R=R*16+C-97+10;else break;e++,E++}return E<g&&(R=-1),R}function c(g){e=g,i="",o=0,s=16,a=0}function d(){let g=e;if(r.charCodeAt(e)===48)e++;else for(e++;e<r.length&&ir(r.charCodeAt(e));)e++;if(e<r.length&&r.charCodeAt(e)===46)if(e++,e<r.length&&ir(r.charCodeAt(e)))for(e++;e<r.length&&ir(r.charCodeAt(e));)e++;else return a=3,r.substring(g,e);let E=e;if(e<r.length&&(r.charCodeAt(e)===69||r.charCodeAt(e)===101))if(e++,(e<r.length&&r.charCodeAt(e)===43||r.charCodeAt(e)===45)&&e++,e<r.length&&ir(r.charCodeAt(e))){for(e++;e<r.length&&ir(r.charCodeAt(e));)e++;E=e}else a=3;return r.substring(g,E)}function u(){let g="",E=e;for(;;){if(e>=n){g+=r.substring(E,e),a=2;break}let R=r.charCodeAt(e);if(R===34){g+=r.substring(E,e),e++;break}if(R===92){if(g+=r.substring(E,e),e++,e>=n){a=2;break}switch(r.charCodeAt(e++)){case 34:g+='"';break;case 92:g+="\\";break;case 47:g+="/";break;case 98:g+="\b";break;case 102:g+="\f";break;case 110:g+=`
`;break;case 114:g+="\r";break;case 116:g+="	";break;case 117:{let J=l(4);J>=0?g+=String.fromCharCode(J):a=4;break}default:a=5}E=e;continue}if(R>=0&&R<=31)if(Oo(R)){g+=r.substring(E,e),a=2;break}else a=6;e++}return g}function p(){if(i="",a=0,o=e,e>=n)return o=n,s=17;let g=r.charCodeAt(e);if(tl(g)){do e++,i+=String.fromCharCode(g),g=r.charCodeAt(e);while(tl(g));return s=15}if(Oo(g))return e++,i+=String.fromCharCode(g),g===13&&r.charCodeAt(e)===10&&(e++,i+=`
`),s=14;switch(g){case 123:return e++,s=1;case 125:return e++,s=2;case 91:return e++,s=3;case 93:return e++,s=4;case 58:return e++,s=6;case 44:return e++,s=5;case 34:return e++,i=u(),s=10;case 47:{let E=e-1;if(r.charCodeAt(e+1)===47){for(e+=2;e<n&&!Oo(r.charCodeAt(e));)e++;return i=r.substring(E,e),s=12}if(r.charCodeAt(e+1)===42){e+=2;let R=n-1,C=!1;for(;e<R;){if(r.charCodeAt(e)===42&&r.charCodeAt(e+1)===47){e+=2,C=!0;break}e++}return C||(e++,a=1),i=r.substring(E,e),s=13}return i+=String.fromCharCode(g),e++,s=16}case 45:if(i+=String.fromCharCode(g),e++,e===n||!ir(r.charCodeAt(e)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=d(),s=11;default:for(;e<n&&h(g);)e++,g=r.charCodeAt(e);if(o!==e){switch(i=r.substring(o,e),i){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(g),e++,s=16}}function h(g){if(tl(g)||Oo(g))return!1;switch(g){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function v(){let g;do g=p();while(g>=12&&g<=15);return g}return{setPosition:c,getPosition:()=>e,scan:t?v:p,getToken:()=>s,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>e-o,getTokenError:()=>a}}function tl(r){return r===32||r===9||r===11||r===12||r===160||r===5760||r>=8192&&r<=8203||r===8239||r===8287||r===12288||r===65279}function Oo(r){return r===10||r===13||r===8232||r===8233}function ir(r){return r>=48&&r<=57}function kd(r,t=[],e=nl.DEFAULT){let n=null,i=[],o=[];function s(l){Array.isArray(i)?i.push(l):n!==null&&(i[n]=l)}return Cg(r,{onObjectBegin:()=>{let l={};s(l),o.push(i),i=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{let l=[];s(l),o.push(i),i=l,n=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:s,onError:(l,c,d)=>{t.push({error:l,offset:c,length:d})}},e),i[0]}function Cg(r,t,e=nl.DEFAULT){let n=wg(r,!1);function i(w){return w?()=>w(n.getTokenOffset(),n.getTokenLength()):()=>!0}function o(w){return w?ne=>w(ne,n.getTokenOffset(),n.getTokenLength()):()=>!0}let s=i(t.onObjectBegin),a=o(t.onObjectProperty),l=i(t.onObjectEnd),c=i(t.onArrayBegin),d=i(t.onArrayEnd),u=o(t.onLiteralValue),p=o(t.onSeparator),h=i(t.onComment),v=o(t.onError),g=e&&e.disallowComments,E=e&&e.allowTrailingComma;function R(){for(;;){let w=n.scan();switch(n.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:g||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(w){case 12:case 13:g?C(10):h();break;case 16:C(1);break;case 15:case 14:break;default:return w}}}function C(w,ne=[],it=[]){if(v(w),ne.length+it.length>0){let pt=n.getToken();for(;pt!==17;){if(ne.indexOf(pt)!==-1){R();break}else if(it.indexOf(pt)!==-1)break;pt=R()}}}function J(w){let ne=n.getTokenValue();return w?u(ne):a(ne),R(),!0}function rt(){switch(n.getToken()){case 11:{let w=0;try{w=JSON.parse(n.getTokenValue()),typeof w!="number"&&(C(2),w=0)}catch{C(2)}u(w);break}case 7:u(null);break;case 8:u(!0);break;case 9:u(!1);break;default:return!1}return R(),!0}function bn(){return n.getToken()!==10?(C(3,[],[2,5]),!1):(J(!1),n.getToken()===6?(p(":"),R(),F()||C(4,[],[2,5])):C(5,[],[2,5]),!0)}function vr(){s(),R();let w=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(w||C(4,[],[]),p(","),R(),n.getToken()===2&&E)break}else w&&C(6,[],[]);bn()||C(4,[],[2,5]),w=!0}return l(),n.getToken()!==2?C(7,[2],[]):R(),!0}function P(){c(),R();let w=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(w||C(4,[],[]),p(","),R(),n.getToken()===4&&E)break}else w&&C(6,[],[]);F()||C(4,[],[4,5]),w=!0}return d(),n.getToken()!==4?C(8,[4],[]):R(),!0}function F(){switch(n.getToken()){case 3:return P();case 1:return vr();case 10:return J(!0);default:return rt()}}return R(),n.getToken()===17?e.allowEmptyContent?!0:(C(4,[],[]),!1):F()?(n.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}function Dd(r,t){return r.replace(/^~($|\/|\\)/,`${t}$1`)}var kg={format:0,manifestPath:"plugin.json",hookConfigPath:"hooks.json",pluginRootToken:void 0,pluginRootEnvVar:void 0,parseHooks(r,t,e,n,i){return Ld(r,t,n,i)}},Dg={format:1,manifestPath:".claude-plugin/plugin.json",hookConfigPath:"hooks/hooks.json",pluginRootToken:"${CLAUDE_PLUGIN_ROOT}",pluginRootEnvVar:"CLAUDE_PLUGIN_ROOT",parseHooks(r,t,e,n,i){return Fd(r,t,e,n,i,"${CLAUDE_PLUGIN_ROOT}","CLAUDE_PLUGIN_ROOT")}},Og={format:2,manifestPath:".plugin/plugin.json",hookConfigPath:"hooks/hooks.json",pluginRootToken:"${PLUGIN_ROOT}",pluginRootEnvVar:"PLUGIN_ROOT",parseHooks(r,t,e,n,i){return Fd(r,t,e,n,i,"${PLUGIN_ROOT}","PLUGIN_ROOT")}};async function Lg(r,t){return await li(G(r,".plugin","plugin.json"),t)?Og:r.path.split("/").includes(".claude")||await li(G(r,".claude-plugin","plugin.json"),t)?Dg:kg}var rl={paths:[],exclusive:!1};function Lo(r){if(r==null)return rl;if(typeof r=="string"){let t=r.trim();return t?{paths:[t],exclusive:!1}:rl}if(Array.isArray(r))return{paths:r.filter(e=>typeof e=="string").map(e=>e.trim()).filter(e=>e.length>0),exclusive:!1};if(typeof r=="object"){let t=r;if(Array.isArray(t.paths)){let e=t.paths.filter(i=>typeof i=="string").map(i=>i.trim()).filter(i=>i.length>0),n=t.exclusive===!0;return{paths:e,exclusive:n}}}return rl}function Fo(r,t,e){let n=[];e.exclusive||n.push(G(r,t));for(let i of e.paths){let o=Dn(G(r,i));Hc(o,r)&&n.push(o)}return n}function Fg(r){if(!r||typeof r!="object"||Array.isArray(r))return;let t=r;return Object.hasOwn(t,"mcpServers")?t.mcpServers:t}function Ug(r){if(!r||typeof r!="object")return;let t=r,e=typeof t.type=="string"?t.type:void 0,n=typeof t.command=="string"?t.command:void 0,i=typeof t.url=="string"?t.url:void 0,o=Array.isArray(t.args)?t.args.filter(u=>typeof u=="string"):void 0,s=t.env&&typeof t.env=="object"?Object.fromEntries(Object.entries(t.env).filter(([,u])=>typeof u=="string"||typeof u=="number"||u===null).map(([u,p])=>[u,p])):void 0,a=typeof t.envFile=="string"?t.envFile:void 0,l=typeof t.cwd=="string"?t.cwd:void 0,c=t.headers&&typeof t.headers=="object"?Object.fromEntries(Object.entries(t.headers).filter(([,u])=>typeof u=="string").map(([u,p])=>[u,p])):void 0,d=t.dev&&typeof t.dev=="object"?t.dev:void 0;if(e!=="ws"){if(e==="stdio"||!e&&n)return n?{type:"stdio",command:n,args:o,env:s,envFile:a,cwd:l,dev:d}:void 0;if(e==="http"||e==="sse"||!e&&i)return i?{type:"http",url:i,headers:c,dev:d}:void 0}}var Ng=/[\s&|<>()^;!`"']/;function Mg(r,t,e){if(!r.includes(e))return r;if(!Ng.test(t))return r.replaceAll(e,t);let n=Ft(e),i=new RegExp(`(["']?)`+n+"([\\w./\\\\~:-]*)","g");return r.replace(i,(o,s,a)=>{let l=t+a;return s?s+l:'"'+l.replace(/"/g,'\\"')+'"'})}function Wg(r,t,e,n){let i=a=>a.replaceAll(e,t),o=r.configuration,s;if(o.type==="stdio"){let a={...o};a.command=i(a.command),a.args&&(a.args=a.args.map(i)),a.cwd&&(a.cwd=i(a.cwd)),a.env={...a.env};for(let[l,c]of Object.entries(a.env))typeof c=="string"&&(a.env[l]=i(c));a.env[n]=t,a.envFile&&(a.envFile=i(a.envFile)),s=a}else{let a={...o};a.url=i(a.url),a.headers&&(a.headers=Object.fromEntries(Object.entries(a.headers).map(([l,c])=>[l,i(c)]))),s=a}return{name:r.name,configuration:s,uri:r.uri}}var Bg=/\$\{(?![A-Za-z]+:)([A-Z_][A-Z0-9_]*)\}/g;function qg(r){return ua(r,t=>{if(m.isUri(t))return t;if(typeof t=="string"){let e=t.replace(Bg,"${env:$1}");return e!==t?e:void 0}})}var Vg={SessionStart:"SessionStart",SessionEnd:"SessionEnd",UserPromptSubmit:"UserPromptSubmit",PreToolUse:"PreToolUse",PostToolUse:"PostToolUse",PreCompact:"PreCompact",SubagentStart:"SubagentStart",SubagentStop:"SubagentStop",Stop:"Stop",ErrorOccurred:"ErrorOccurred",sessionStart:"SessionStart",sessionEnd:"SessionEnd",userPromptSubmitted:"UserPromptSubmit",preToolUse:"PreToolUse",postToolUse:"PostToolUse",agentStop:"Stop",subagentStop:"SubagentStop",errorOccurred:"ErrorOccurred"};function $g(r){if(r.type!==void 0&&r.type!=="command")return;let t=typeof r.command=="string"&&r.command.length>0,e=typeof r.bash=="string"&&r.bash.length>0,n=typeof r.powershell=="string"&&r.powershell.length>0,i=typeof r.windows=="string"&&r.windows.length>0,o=typeof r.linux=="string"&&r.linux.length>0,s=typeof r.osx=="string"&&r.osx.length>0;if(!t&&!e&&!n&&!i&&!o&&!s)return;let a=i?r.windows:n?r.powershell:void 0,l=o?r.linux:e?r.bash:void 0,c=s?r.osx:e?r.bash:void 0,d=typeof r.timeout=="number"?r.timeout:typeof r.timeoutSec=="number"?r.timeoutSec:void 0;return{...t&&{command:r.command},...a&&{windows:a},...l&&{linux:l},...c&&{osx:c},...typeof r.env=="object"&&r.env!==null&&{env:r.env},...d!==void 0&&{timeout:d}}}function Od(r,t,e){let n=$g(r);if(!n)return;let i,o=typeof r.cwd=="string"?r.cwd:void 0;if(o){let s=Dd(o,e);Cn(s)?i=m.file(s):t&&(i=G(t,s))}else i=t;return{...n,cwd:i}}function Kg(r,t,e){if(!r||typeof r!="object")return[];let n=r,i=[],o=n.hooks;if(o!==void 0&&Array.isArray(o))for(let s of o){if(!s||typeof s!="object")continue;let a=Od(s,t,e);a&&i.push(a)}else{let s=Od(n,t,e);s&&i.push(s)}return i}function Ld(r,t,e,n){if(!t||typeof t!="object")return[];let i=t;if(i.disableAllHooks===!0)return[];let o=i.hooks;if(!o||typeof o!="object")return[];let s=o,a=[];for(let l of Object.keys(s)){let c=Vg[l];if(!c)continue;let d=s[l];if(!Array.isArray(d))continue;let u=[];for(let p of d)u.push(...Kg(p,e,n));u.length>0&&a.push({type:c,commands:u,uri:r,originalId:l})}return a}function Fd(r,t,e,n,i,o,s){let a=e.fsPath,l=t,c=u=>{for(let p of["command","windows","linux","osx"])typeof u[p]=="string"&&(u[p]=Mg(u[p],a,o));(!u.env||typeof u.env!="object")&&(u.env={}),u.env[s]=a};for(let u of Object.values(l.hooks??{}))if(Array.isArray(u))for(let p of u){if(!p||typeof p!="object")continue;let h=p;if(Array.isArray(h.hooks))for(let v of h.hooks)c(v);else c(h)}return Ld(r,ua(t,u=>typeof u=="string"?u.replaceAll(o,e.fsPath):void 0),n,i)}async function il(r,t){try{let e=await t.readFile(r);return kd(e.value.toString())}catch{return}}async function li(r,t){try{return await t.resolve(r),!0}catch{return!1}}var Uo=".md";async function jg(r,t,e){let n=new Set,i=[],o=(s,a)=>{n.has(s)||(n.add(s),i.push({uri:a,name:s}))};for(let s of t){let a=m.joinPath(s,"SKILL.md");if(await li(a,e)){o(Xe(s),a);continue}let l;try{l=await e.resolve(s)}catch{continue}if(!(!l.isDirectory||!l.children))for(let c of l.children){let d=m.joinPath(c.resource,"SKILL.md");await li(d,e)&&o(Xe(c.resource),d)}}if(i.length===0){let s=m.joinPath(r,"SKILL.md");await li(s,e)&&o(Xe(r),s)}return i.sort((s,a)=>s.name.localeCompare(a.name)),i}async function zg(r,t){let e=new Set,n=[],i=(o,s)=>{e.has(o)||(e.add(o),n.push({uri:s,name:o}))};for(let o of r){let s;try{s=await t.resolve(o)}catch{continue}if(s.isFile&&Ys(o).toLowerCase()===Uo){i(Xe(o).slice(0,-Uo.length),o);continue}if(!(!s.isDirectory||!s.children))for(let a of s.children)!a.isFile||Ys(a.resource).toLowerCase()!==Uo||i(Xe(a.resource).slice(0,-Uo.length),a.resource)}return n.sort((o,s)=>o.name.localeCompare(s.name)),n}async function Hg(r,t,e,n,i,o){for(let s of t){let a=await il(s,n);if(a)return e.parseHooks(s,a,r,i,o)}return[]}async function Gg(r,t,e,n){let i=new Map;for(let o of r){let s=await il(o,n);for(let a of Ud(o,s,t,e))i.has(a.name)||i.set(a.name,a)}return[...i.values()].sort((o,s)=>o.name.localeCompare(s.name))}function Ud(r,t,e,n){let i=Fg(t);if(!i)return[];let o=[];for(let[s,a]of Object.entries(i)){let l=Ug(a);if(!l)continue;let c={name:s,configuration:l,uri:r};n.pluginRootToken&&n.pluginRootEnvVar&&(c=Wg(c,e,n.pluginRootToken,n.pluginRootEnvVar)),c=qg(c),o.push(c)}return o}async function Nd(r,t,e,n){let i=await Lg(r,t),o=await il(G(r,i.manifestPath),t),s=o&&typeof o=="object"?o:void 0,a=Fo(r,i.hookConfigPath,Lo(s?.hooks)),l=Fo(r,".mcp.json",Lo(s?.mcpServers)),c=Fo(r,"skills",Lo(s?.skills)),d=Fo(r,"agents",Lo(s?.agents)),u=[],p=s?.mcpServers;p&&typeof p=="object"&&!Array.isArray(p)&&!$e(p,{paths:!0})&&(u=Ud(G(r,i.manifestPath),{mcpServers:p},r.fsPath,i));let h=[],v=s?.hooks;if(v&&typeof v=="object"&&!Array.isArray(v)&&!$e(v,{paths:!0})){let J=G(r,i.manifestPath);h=i.parseHooks(J,{hooks:v},r,e,n)}let[g,E,R,C]=await Promise.all([h.length>0?Promise.resolve(h):Hg(r,a,i,t,e,n),u.length>0?Promise.resolve(u):Gg(l,r.fsPath,i,t),jg(r,c,t),zg(d,t)]);return{hooks:g,mcpServers:E,skills:R,agents:C}}var No=Le("agentPluginManager");var or=Le("sessionDataService");var Jg=new Set(["edit","write","patch"]);function ar(r){return Jg.has(r)}function Mo(r){if(typeof r=="string")try{r=JSON.parse(r)}catch{return}return r?.path}var Wo=new Set(["bash","powershell"]),Qg=new Set(["report_intent"]);function ci(r){return Qg.has(r)}function sr(r,t){return r.length>t?r.substring(0,t-3)+"...":r}function ui(r){switch(r){case"bash":return f(1875,null);case"powershell":return f(1882,null);case"read_bash":case"read_powershell":return f(1883,null);case"write_bash":case"write_powershell":return f(1887,null);case"bash_shutdown":return f(1876,null);case"list_bash":case"list_powershell":return f(1880,null);case"view":return f(1884,null);case"edit":return f(1877,null);case"write":return f(1886,null);case"grep":return f(1879,null);case"glob":return f(1878,null);case"patch":return f(1881,null);case"web_search":return f(1885,null);case"ask_user":return f(1874,null);default:return r}}function Bo(r,t,e){if(Wo.has(r)){let n=e;if(n?.command){let i=n.command.split(`
`)[0];return f(1869,null,sr(i,80))}return f(1868,null,t)}switch(r){case"view":{let n=e;return n?.path?f(1871,null,n.path):f(1870,null)}case"edit":{let n=e;return n?.path?f(1862,null,n.path):f(1861,null)}case"write":{let n=e;return n?.path?f(1873,null,n.path):f(1872,null)}case"grep":{let n=e;return n?.pattern?f(1867,null,sr(n.pattern,80)):f(1866,null)}case"glob":{let n=e;return n?.pattern?f(1865,null,sr(n.pattern,80)):f(1864,null)}default:return f(1863,null,t)}}function qo(r,t,e,n){if(!n)return f(1849,null,t);if(Wo.has(r)){let i=e;if(i?.command){let o=i.command.split(`
`)[0];return f(1856,null,sr(o,80))}return f(1855,null,t)}switch(r){case"view":{let i=e;return i?.path?f(1858,null,i.path):f(1857,null)}case"edit":{let i=e;return i?.path?f(1848,null,i.path):f(1847,null)}case"write":{let i=e;return i?.path?f(1860,null,i.path):f(1859,null)}case"grep":{let i=e;return i?.pattern?f(1854,null,sr(i.pattern,80)):f(1853,null)}case"glob":{let i=e;return i?.pattern?f(1852,null,sr(i.pattern,80)):f(1851,null)}default:return f(1850,null,t)}}function Vo(r,t,e){if(!(!t&&!e)){if(Wo.has(r))return t?.command??e;switch(r){case"grep":return t?.pattern??e;default:if(t)try{return JSON.stringify(t,null,2)}catch{return e}return e}}}function $o(r){if(Wo.has(r))return"terminal"}function Ko(r){return r==="powershell"?"powershell":"shellscript"}function jo(r){try{return JSON.stringify(r)}catch{return}}async function Md(r,t,e){let n=[],i=new Map,o=[];for(let l of e)if(l.type==="tool.execution_start"){let c=l.data;if(ci(c.toolName))continue;let d=c.arguments!==void 0?jo(c.arguments):void 0,u;if(d)try{u=JSON.parse(d)}catch{}i.set(c.toolCallId,{toolName:c.toolName,parameters:u}),ar(c.toolName)&&o.push(c.toolCallId)}let s;if(t&&o.length>0)try{let l=await t.getFileEdits(o);if(l.length>0){s=new Map;for(let c of l){let d=s.get(c.toolCallId);d||(d=[],s.set(c.toolCallId,d)),d.push(c)}}}catch{}let a=r.toString();for(let l of e)if(l.type==="assistant.message"||l.type==="user.message"){let c=l.data;n.push({session:r,type:"message",role:l.type==="user.message"?"user":"assistant",messageId:c?.messageId??c?.interactionId??"",content:c?.content??"",toolRequests:c?.toolRequests?.map(d=>({toolCallId:d.toolCallId,name:d.name,arguments:d.arguments!==void 0?jo(d.arguments):void 0,type:d.type})),reasoningOpaque:c?.reasoningOpaque,reasoningText:c?.reasoningText,encryptedContent:c?.encryptedContent,parentToolCallId:c?.parentToolCallId})}else if(l.type==="tool.execution_start"){let c=l.data;if(ci(c.toolName))continue;let d=i.get(c.toolCallId),u=ui(c.toolName),p=$o(c.toolName),h=c.arguments!==void 0?jo(c.arguments):void 0;n.push({session:r,type:"tool_start",toolCallId:c.toolCallId,toolName:c.toolName,displayName:u,invocationMessage:Bo(c.toolName,u,d?.parameters),toolInput:Vo(c.toolName,d?.parameters,h),toolKind:p,language:p==="terminal"?Ko(c.toolName):void 0,toolArguments:h,mcpServerName:c.mcpServerName,mcpToolName:c.mcpToolName,parentToolCallId:c.parentToolCallId})}else if(l.type==="tool.execution_complete"){let c=l.data,d=i.get(c.toolCallId);if(!d)continue;i.delete(c.toolCallId);let u=ui(d.toolName),p=c.error?.message??c.result?.content,h=[];p!==void 0&&h.push({type:"text",text:p});let v=s?.get(c.toolCallId);if(v)for(let g of v){let E=g.kind==="rename"&&g.originalPath?m.file(g.originalPath).toString():m.file(g.filePath).toString(),R=m.file(g.filePath).toString(),C=g.kind!=="create",J=g.kind!=="delete";h.push({type:"fileEdit",before:C?{uri:E,content:{uri:Gr(a,g.toolCallId,g.filePath,"before")}}:void 0,after:J?{uri:R,content:{uri:Gr(a,g.toolCallId,g.filePath,"after")}}:void 0,diff:g.addedLines!==void 0||g.removedLines!==void 0?{added:g.addedLines,removed:g.removedLines}:void 0})}n.push({session:r,type:"tool_complete",toolCallId:c.toolCallId,result:{success:c.success,pastTenseMessage:qo(d.toolName,u,d.parameters,c.success),content:h.length>0?h:void 0,error:c.error},isUserRequested:c.isUserRequested,toolTelemetry:c.toolTelemetry!==void 0?jo(c.toolTelemetry):void 0,parentToolCallId:c.parentToolCallId})}return n}function vn(r){try{return JSON.stringify(r)}catch{return}}function Yg(r){let t=typeof r.path=="string"?r.path:typeof r.fileName=="string"?r.fileName:void 0,e=typeof r.fullCommandText=="string"?r.fullCommandText:void 0,n=typeof r.intention=="string"?r.intention:void 0,i=typeof r.serverName=="string"?r.serverName:void 0,o=typeof r.toolName=="string"?r.toolName:void 0;switch(r.kind){case"shell":return{confirmationTitle:f(1843,null),invocationMessage:n??f(1842,null),toolInput:e};case"write":return{confirmationTitle:f(1846,null),invocationMessage:t?f(1844,null,t):f(1845,null),toolInput:vn(t?{path:t}:r)??void 0};case"mcp":{let s=o??f(1839,null);return{confirmationTitle:i?`${i}: ${s}`:s,invocationMessage:i?`${i}: ${s}`:s,toolInput:vn({serverName:i,toolName:o})??void 0}}case"read":return{confirmationTitle:f(1841,null),invocationMessage:n??f(1840,null),toolInput:vn(t?{path:t,intention:n}:r)??void 0};default:return{confirmationTitle:f(1838,null),invocationMessage:f(1837,null),toolInput:vn(r)??void 0}}}var lr=class extends A{constructor(e,n,i,o,s,a,l,c){super();this._onDidSessionProgress=o;this._wrapperFactory=s;this._fileService=a;this._logService=l;this._activeToolCalls=new Map;this._pendingPermissions=new Map;this._turnId="";this.sessionId=n,this.sessionUri=e,this._workingDirectory=i,this._databaseRef=c.openDatabase(e),this._register(O(()=>this._databaseRef.dispose())),this._editTracker=new _o(e.toString(),this._databaseRef.object,this._fileService,this._logService),this._register(O(()=>this._denyPendingPermissions()))}async initializeSession(){this._wrapper=this._register(await this._wrapperFactory({onPermissionRequest:e=>this.handlePermissionRequest(e),hooks:{onPreToolUse:async e=>{if(ar(e.toolName)){let n=Mo(e.toolArgs);n&&await this._editTracker.trackEditStart(n)}},onPostToolUse:async e=>{if(ar(e.toolName)){let n=Mo(e.toolArgs);n&&await this._editTracker.completeEdit(n)}}}})),this._subscribeToEvents(),this._subscribeForLogging()}async send(e,n){this._logService.info(`[Copilot:${this.sessionId}] sendMessage called: "${e.substring(0,100)}${e.length>100?"...":""}" (${n?.length??0} attachments)`);let i=n?.map(o=>o.type==="selection"?{type:"selection",filePath:o.path,displayName:o.displayName??o.path,text:o.text,selection:o.selection}:{type:o.type,path:o.path,displayName:o.displayName});i?.length&&this._logService.trace(`[Copilot:${this.sessionId}] Attachments: ${JSON.stringify(i.map(o=>({type:o.type,path:o.type==="selection"?o.filePath:o.path})))}`),await this._wrapper.session.send({prompt:e,attachments:i}),this._logService.info(`[Copilot:${this.sessionId}] session.send() returned`)}async sendSteering(e){this._logService.info(`[Copilot:${this.sessionId}] Sending steering message: "${e.userMessage.text.substring(0,100)}"`);try{await this._wrapper.session.send({prompt:e.userMessage.text,mode:"immediate"}),this._onDidSessionProgress.fire({session:this.sessionUri,type:"steering_consumed",id:e.id})}catch(n){this._logService.error(`[Copilot:${this.sessionId}] Steering message failed`,n)}}async getMessages(){let e=await this._wrapper.session.getMessages(),n;try{n=this._databaseRef.object}catch{}return Md(this.sessionUri,n,e)}async abort(){this._logService.info(`[Copilot:${this.sessionId}] Aborting session...`),this._denyPendingPermissions(),await this._wrapper.session.abort()}async destroySession(){await this._wrapper.session.destroy()}async setModel(e){this._logService.info(`[Copilot:${this.sessionId}] Changing model to: ${e}`),await this._wrapper.session.setModel(e)}async handlePermissionRequest(e){if(this._logService.info(`[Copilot:${this.sessionId}] Permission request: kind=${e.kind}`),e.kind==="read"){let c=typeof e.path=="string"?e.path:void 0;if(c&&this._workingDirectory&&Mt.isEqualOrParent(Dn(m.file(c)),this._workingDirectory))return this._logService.trace(`[Copilot:${this.sessionId}] Auto-approving read inside working directory: ${c}`),{kind:"approved"}}let n=e.toolCallId;if(!n)return this._logService.warn(`[Copilot:${this.sessionId}] Permission request without toolCallId, auto-denying: kind=${e.kind}`),{kind:"denied-interactively-by-user"};this._logService.info(`[Copilot:${this.sessionId}] Requesting confirmation for tool call: ${n}`);let i=new He;this._pendingPermissions.set(n,i);let{confirmationTitle:o,invocationMessage:s,toolInput:a}=Yg(e);this._onDidSessionProgress.fire({session:this.sessionUri,type:"tool_ready",toolCallId:n,invocationMessage:s,toolInput:a,confirmationTitle:o,permissionKind:e.kind,permissionPath:typeof e.path=="string"?e.path:typeof e.fileName=="string"?e.fileName:void 0});let l=await i.p;return this._logService.info(`[Copilot:${this.sessionId}] Permission response: toolCallId=${n}, approved=${l}`),{kind:l?"approved":"denied-interactively-by-user"}}respondToPermissionRequest(e,n){let i=this._pendingPermissions.get(e);return i?(this._pendingPermissions.delete(e),i.complete(n),!0):!1}_subscribeToEvents(){let e=this._wrapper,n=this.sessionId,i=this.sessionUri;this._register(e.onMessageDelta(o=>{this._logService.trace(`[Copilot:${n}] delta: ${o.data.deltaContent}`),this._onDidSessionProgress.fire({session:i,type:"delta",messageId:o.data.messageId,content:o.data.deltaContent,parentToolCallId:o.data.parentToolCallId})})),this._register(e.onMessage(o=>{this._logService.info(`[Copilot:${n}] Full message received: ${o.data.content.length} chars`),this._onDidSessionProgress.fire({session:i,type:"message",role:"assistant",messageId:o.data.messageId,content:o.data.content,toolRequests:o.data.toolRequests?.map(s=>({toolCallId:s.toolCallId,name:s.name,arguments:s.arguments!==void 0?vn(s.arguments):void 0,type:s.type})),reasoningOpaque:o.data.reasoningOpaque,reasoningText:o.data.reasoningText,encryptedContent:o.data.encryptedContent,parentToolCallId:o.data.parentToolCallId})})),this._register(e.onToolStart(o=>{if(ci(o.data.toolName)){this._logService.trace(`[Copilot:${n}] Tool started (hidden): ${o.data.toolName}`);return}this._logService.info(`[Copilot:${n}] Tool started: ${o.data.toolName}`);let s=o.data.arguments!==void 0?vn(o.data.arguments):void 0,a;if(s)try{a=JSON.parse(s)}catch{}let l=ui(o.data.toolName);this._activeToolCalls.set(o.data.toolCallId,{toolName:o.data.toolName,displayName:l,parameters:a});let c=$o(o.data.toolName);this._onDidSessionProgress.fire({session:i,type:"tool_start",toolCallId:o.data.toolCallId,toolName:o.data.toolName,displayName:l,invocationMessage:Bo(o.data.toolName,l,a),toolInput:Vo(o.data.toolName,a,s),toolKind:c,language:c==="terminal"?Ko(o.data.toolName):void 0,toolArguments:s,mcpServerName:o.data.mcpServerName,mcpToolName:o.data.mcpToolName,parentToolCallId:o.data.parentToolCallId})})),this._register(e.onTurnStart(o=>{this._turnId=o.data.turnId})),this._register(e.onToolComplete(o=>{let s=this._activeToolCalls.get(o.data.toolCallId);if(!s)return;this._logService.info(`[Copilot:${n}] Tool completed: ${o.data.toolCallId}`),this._activeToolCalls.delete(o.data.toolCallId);let a=s.displayName,l=o.data.error?.message??o.data.result?.content,c=[];l!==void 0&&c.push({type:"text",text:l});let d=ar(s.toolName)?Mo(s.parameters):void 0;if(d){let u=this._editTracker.takeCompletedEdit(this._turnId,o.data.toolCallId,d);u&&c.push(u)}this._onDidSessionProgress.fire({session:i,type:"tool_complete",toolCallId:o.data.toolCallId,result:{success:o.data.success,pastTenseMessage:qo(s.toolName,a,s.parameters,o.data.success),content:c.length>0?c:void 0,error:o.data.error},isUserRequested:o.data.isUserRequested,toolTelemetry:o.data.toolTelemetry!==void 0?vn(o.data.toolTelemetry):void 0,parentToolCallId:o.data.parentToolCallId})})),this._register(e.onIdle(()=>{this._logService.info(`[Copilot:${n}] Session idle`),this._onDidSessionProgress.fire({session:i,type:"idle"})})),this._register(e.onSessionError(o=>{this._logService.error(`[Copilot:${n}] Session error: ${o.data.errorType} - ${o.data.message}`),this._onDidSessionProgress.fire({session:i,type:"error",errorType:o.data.errorType,message:o.data.message,stack:o.data.stack})})),this._register(e.onUsage(o=>{this._logService.trace(`[Copilot:${n}] Usage: model=${o.data.model}, in=${o.data.inputTokens??"?"}, out=${o.data.outputTokens??"?"}, cacheRead=${o.data.cacheReadTokens??"?"}`),this._onDidSessionProgress.fire({session:i,type:"usage",inputTokens:o.data.inputTokens,outputTokens:o.data.outputTokens,model:o.data.model,cacheReadTokens:o.data.cacheReadTokens})})),this._register(e.onReasoningDelta(o=>{this._logService.trace(`[Copilot:${n}] Reasoning delta: ${o.data.deltaContent.length} chars`),this._onDidSessionProgress.fire({session:i,type:"reasoning",content:o.data.deltaContent})}))}_subscribeForLogging(){let e=this._wrapper,n=this.sessionId;this._register(e.onSessionStart(i=>{this._logService.trace(`[Copilot:${n}] Session started: model=${i.data.selectedModel??"default"}, producer=${i.data.producer}`)})),this._register(e.onSessionResume(i=>{this._logService.trace(`[Copilot:${n}] Session resumed: eventCount=${i.data.eventCount}`)})),this._register(e.onSessionInfo(i=>{this._logService.trace(`[Copilot:${n}] Session info [${i.data.infoType}]: ${i.data.message}`)})),this._register(e.onSessionModelChange(i=>{this._logService.trace(`[Copilot:${n}] Model changed: ${i.data.previousModel??"(none)"} -> ${i.data.newModel}`)})),this._register(e.onSessionHandoff(i=>{this._logService.trace(`[Copilot:${n}] Session handoff: sourceType=${i.data.sourceType}, remoteSessionId=${i.data.remoteSessionId??"(none)"}`)})),this._register(e.onSessionTruncation(i=>{this._logService.trace(`[Copilot:${n}] Session truncation: removed ${i.data.tokensRemovedDuringTruncation} tokens, ${i.data.messagesRemovedDuringTruncation} messages`)})),this._register(e.onSessionSnapshotRewind(i=>{this._logService.trace(`[Copilot:${n}] Snapshot rewind: upTo=${i.data.upToEventId}, eventsRemoved=${i.data.eventsRemoved}`)})),this._register(e.onSessionShutdown(i=>{this._logService.trace(`[Copilot:${n}] Session shutdown: type=${i.data.shutdownType}, premiumRequests=${i.data.totalPremiumRequests}, apiDuration=${i.data.totalApiDurationMs}ms`)})),this._register(e.onSessionUsageInfo(i=>{this._logService.trace(`[Copilot:${n}] Usage info: ${i.data.currentTokens}/${i.data.tokenLimit} tokens, ${i.data.messagesLength} messages`)})),this._register(e.onSessionCompactionStart(()=>{this._logService.trace(`[Copilot:${n}] Compaction started`)})),this._register(e.onSessionCompactionComplete(i=>{this._logService.trace(`[Copilot:${n}] Compaction complete: success=${i.data.success}, tokensRemoved=${i.data.tokensRemoved??"?"}`)})),this._register(e.onUserMessage(i=>{this._logService.trace(`[Copilot:${n}] User message: ${i.data.content.length} chars, ${i.data.attachments?.length??0} attachments`)})),this._register(e.onPendingMessagesModified(()=>{this._logService.trace(`[Copilot:${n}] Pending messages modified`)})),this._register(e.onTurnStart(i=>{this._logService.trace(`[Copilot:${n}] Turn started: ${i.data.turnId}`)})),this._register(e.onIntent(i=>{this._logService.trace(`[Copilot:${n}] Intent: ${i.data.intent}`)})),this._register(e.onReasoning(i=>{this._logService.trace(`[Copilot:${n}] Reasoning: ${i.data.content.length} chars`)})),this._register(e.onTurnEnd(i=>{this._logService.trace(`[Copilot:${n}] Turn ended: ${i.data.turnId}`)})),this._register(e.onAbort(i=>{this._logService.trace(`[Copilot:${n}] Aborted: ${i.data.reason}`)})),this._register(e.onToolUserRequested(i=>{this._logService.trace(`[Copilot:${n}] Tool user-requested: ${i.data.toolName} (${i.data.toolCallId})`)})),this._register(e.onToolPartialResult(i=>{this._logService.trace(`[Copilot:${n}] Tool partial result: ${i.data.toolCallId} (${i.data.partialOutput.length} chars)`)})),this._register(e.onToolProgress(i=>{this._logService.trace(`[Copilot:${n}] Tool progress: ${i.data.toolCallId} - ${i.data.progressMessage}`)})),this._register(e.onSkillInvoked(i=>{this._logService.trace(`[Copilot:${n}] Skill invoked: ${i.data.name} (${i.data.path})`)})),this._register(e.onSubagentStarted(i=>{this._logService.trace(`[Copilot:${n}] Subagent started: ${i.data.agentName} (${i.data.agentDisplayName})`)})),this._register(e.onSubagentCompleted(i=>{this._logService.trace(`[Copilot:${n}] Subagent completed: ${i.data.agentName}`)})),this._register(e.onSubagentFailed(i=>{this._logService.error(`[Copilot:${n}] Subagent failed: ${i.data.agentName} - ${i.data.error}`)})),this._register(e.onSubagentSelected(i=>{this._logService.trace(`[Copilot:${n}] Subagent selected: ${i.data.agentName}`)})),this._register(e.onHookStart(i=>{this._logService.trace(`[Copilot:${n}] Hook started: ${i.data.hookType} (${i.data.hookInvocationId})`)})),this._register(e.onHookEnd(i=>{this._logService.trace(`[Copilot:${n}] Hook ended: ${i.data.hookType} (${i.data.hookInvocationId}), success=${i.data.success}`)})),this._register(e.onSystemMessage(i=>{this._logService.trace(`[Copilot:${n}] System message [${i.data.role}]: ${i.data.content.length} chars`)}))}_denyPendingPermissions(){for(let[,e]of this._pendingPermissions)e.complete(!1);this._pendingPermissions.clear()}};lr=D([re(5,tt),re(6,Ce),re(7,or)],lr);import{spawn as Xg}from"child_process";function ol(r){let t={};for(let e of r){let n=e.configuration;n.type==="stdio"?t[e.name]={type:"local",command:n.command,args:n.args?[...n.args]:[],tools:["*"],...n.env&&{env:Zg(n.env)},...n.cwd&&{cwd:n.cwd}}:t[e.name]={type:"http",url:n.url,tools:["*"],...n.headers&&{headers:{...n.headers}}}}return t}function Zg(r){let t={};for(let[e,n]of Object.entries(r))n!==null&&(t[e]=String(n));return t}async function sl(r,t){let e=[];for(let n of r)try{let i=await t.readFile(n.uri);e.push({name:n.name,prompt:i.value.toString()})}catch{}return e}function al(r){let t=new Set,e=[];for(let n of r){let i=he(n.uri.fsPath);t.has(i)||(t.add(i),e.push(i))}return e}function em(r,t){return t===1&&r.windows?r.windows:t===2&&r.osx?r.osx:t===3&&r.linux?r.linux:r.command}function cr(r,t){let e=em(r,Ri);if(!e)return Promise.resolve("");let n=(r.timeout??30)*1e3,i=r.cwd?.fsPath;return new Promise((o,s)=>{let a=Ri===1,d=Xg(a?"cmd.exe":"/bin/sh",a?["/c",e]:["-c",e],{cwd:i,env:{...process.env,...r.env},stdio:["pipe","pipe","pipe"],timeout:n}),u="",p="";d.stdout.on("data",h=>{u+=h.toString()}),d.stderr.on("data",h=>{p+=h.toString()}),t&&d.stdin.write(t),d.stdin.end(),d.on("error",s),d.on("close",h=>{h===0?o(u):s(new Error(`Hook command exited with code ${h}: ${p||u}`))})})}var tm={PreToolUse:"onPreToolUse",PostToolUse:"onPostToolUse",UserPromptSubmit:"onUserPromptSubmitted",SessionStart:"onSessionStart",SessionEnd:"onSessionEnd",ErrorOccurred:"onErrorOccurred"};function ll(r,t){let e=new Map;for(let d of r){let u=tm[d.type];if(!u)continue;let p=e.get(u)??[];p.push(...d.commands),e.set(u,p)}let n={},i=e.get("onPreToolUse");(i?.length||t)&&(n.onPreToolUse=async d=>{if(await t?.onPreToolUse(d),i){let u=JSON.stringify(d);for(let p of i)try{let h=await cr(p,u);if(h.trim())try{let v=JSON.parse(h);if(v&&typeof v=="object")return v}catch{}}catch{}}});let o=e.get("onPostToolUse");(o?.length||t)&&(n.onPostToolUse=async d=>{if(await t?.onPostToolUse(d),o){let u=JSON.stringify(d);for(let p of o)try{await cr(p,u)}catch{}}});let s=e.get("onUserPromptSubmitted");s?.length&&(n.onUserPromptSubmitted=async d=>{let u=JSON.stringify(d);for(let p of s)try{await cr(p,u)}catch{}});let a=e.get("onSessionStart");a?.length&&(n.onSessionStart=async d=>{let u=JSON.stringify(d);for(let p of a)try{await cr(p,u)}catch{}});let l=e.get("onSessionEnd");l?.length&&(n.onSessionEnd=async d=>{let u=JSON.stringify(d);for(let p of l)try{await cr(p,u)}catch{}});let c=e.get("onErrorOccurred");return c?.length&&(n.onErrorOccurred=async d=>{let u=JSON.stringify(d);for(let p of c)try{await cr(p,u)}catch{}}),n}function Wd(r,t){let e=n=>JSON.stringify(n.map(i=>({hooks:i.hooks.map(o=>({type:o.type,commands:o.commands.map(s=>({command:s.command,windows:s.windows,linux:s.linux,osx:s.osx,cwd:s.cwd?.toString(),env:s.env,timeout:s.timeout}))})),mcpServers:i.mcpServers.map(o=>({name:o.name,configuration:o.configuration})),skills:i.skills.map(o=>({uri:o.uri.toString(),name:o.name})),agents:i.agents.map(o=>({uri:o.uri.toString(),name:o.name}))})));return e(r)===e(t)}var ur=class extends A{constructor(e){super();this.session=e;this._register(O(()=>{e.destroy().catch(()=>{})}))}get sessionId(){return this.session.sessionId}get onMessageDelta(){return this._onMessageDelta??=this._sdkEvent("assistant.message_delta")}get onMessage(){return this._onMessage??=this._sdkEvent("assistant.message")}get onToolStart(){return this._onToolStart??=this._sdkEvent("tool.execution_start")}get onToolComplete(){return this._onToolComplete??=this._sdkEvent("tool.execution_complete")}get onIdle(){return this._onIdle??=this._sdkEvent("session.idle")}get onSessionStart(){return this._onSessionStart??=this._sdkEvent("session.start")}get onSessionResume(){return this._onSessionResume??=this._sdkEvent("session.resume")}get onSessionError(){return this._onSessionError??=this._sdkEvent("session.error")}get onSessionInfo(){return this._onSessionInfo??=this._sdkEvent("session.info")}get onSessionModelChange(){return this._onSessionModelChange??=this._sdkEvent("session.model_change")}get onSessionHandoff(){return this._onSessionHandoff??=this._sdkEvent("session.handoff")}get onSessionTruncation(){return this._onSessionTruncation??=this._sdkEvent("session.truncation")}get onSessionSnapshotRewind(){return this._onSessionSnapshotRewind??=this._sdkEvent("session.snapshot_rewind")}get onSessionShutdown(){return this._onSessionShutdown??=this._sdkEvent("session.shutdown")}get onSessionUsageInfo(){return this._onSessionUsageInfo??=this._sdkEvent("session.usage_info")}get onSessionCompactionStart(){return this._onSessionCompactionStart??=this._sdkEvent("session.compaction_start")}get onSessionCompactionComplete(){return this._onSessionCompactionComplete??=this._sdkEvent("session.compaction_complete")}get onUserMessage(){return this._onUserMessage??=this._sdkEvent("user.message")}get onPendingMessagesModified(){return this._onPendingMessagesModified??=this._sdkEvent("pending_messages.modified")}get onTurnStart(){return this._onTurnStart??=this._sdkEvent("assistant.turn_start")}get onIntent(){return this._onIntent??=this._sdkEvent("assistant.intent")}get onReasoning(){return this._onReasoning??=this._sdkEvent("assistant.reasoning")}get onReasoningDelta(){return this._onReasoningDelta??=this._sdkEvent("assistant.reasoning_delta")}get onTurnEnd(){return this._onTurnEnd??=this._sdkEvent("assistant.turn_end")}get onUsage(){return this._onUsage??=this._sdkEvent("assistant.usage")}get onAbort(){return this._onAbort??=this._sdkEvent("abort")}get onToolUserRequested(){return this._onToolUserRequested??=this._sdkEvent("tool.user_requested")}get onToolPartialResult(){return this._onToolPartialResult??=this._sdkEvent("tool.execution_partial_result")}get onToolProgress(){return this._onToolProgress??=this._sdkEvent("tool.execution_progress")}get onSkillInvoked(){return this._onSkillInvoked??=this._sdkEvent("skill.invoked")}get onSubagentStarted(){return this._onSubagentStarted??=this._sdkEvent("subagent.started")}get onSubagentCompleted(){return this._onSubagentCompleted??=this._sdkEvent("subagent.completed")}get onSubagentFailed(){return this._onSubagentFailed??=this._sdkEvent("subagent.failed")}get onSubagentSelected(){return this._onSubagentSelected??=this._sdkEvent("subagent.selected")}get onHookStart(){return this._onHookStart??=this._sdkEvent("hook.start")}get onHookEnd(){return this._onHookEnd??=this._sdkEvent("hook.end")}get onSystemMessage(){return this._onSystemMessage??=this._sdkEvent("system.message")}_sdkEvent(e){let n=this._register(new b),i=this.session.on(e,o=>n.fire(o));return this._register(O(i)),n.event}};import*as Me from"fs";import*as Bd from"os";function jt(r,t){return new Promise((e,n)=>{r.exec(t,i=>i?n(i):e())})}function Kt(r,t,e){return new Promise((n,i)=>{r.run(t,e,function(o){if(o)return i(o);n()})})}function qd(r,t,e){return new Promise((n,i)=>{r.all(t,e,(o,s)=>{if(o)return i(o);n(s)})})}function Vd(r){return new Promise((t,e)=>{r.close(n=>n?e(n):t())})}function $d(r){return new Promise((t,e)=>{import("@vscode/sqlite3").then(n=>{let i=new n.default.Database(r,o=>{if(o)return e(o);t(i)})},e)})}function Kd(r){let t=[];for(let e of r.split(`
`)){let n=e.trim();n.length!==0&&t.push(JSON.parse(n))}return t}function jd(r){return r.map(t=>JSON.stringify(t)).join(`
`)+`
`}function zd(r,t){let e=-1,n=-1;for(let i=0;i<r.length;i++){if(r[i].type==="user.message"&&(e++,e>t))return n;e===t&&(n=i)}return n}function nm(r,t,e){let n=zd(r,t);if(n<0)throw new Error(`Fork turn index ${t} not found in event log`);let i=r.slice(0,n+1).filter(a=>a.type!=="session.shutdown"&&a.type!=="session.resume"),o=new Map,s=[];for(let a of i){let l=ge();o.set(a.id,l);let c=a.data;a.type==="session.start"&&(c={...c,sessionId:e});let d=a.parentId!==null?o.get(a.parentId)??s[s.length-1]?.id??null:null;s.push({type:a.type,data:c,id:l,timestamp:a.timestamp,parentId:d})}return s}function rm(r,t){let e=zd(r,t);if(e<0)throw new Error(`Turn index ${t} not found in event log`);let n=r.find(d=>d.type==="session.start");if(!n)throw new Error("No session.start event found in event log");let i=r.slice(0,e+1).filter(d=>d.type!=="session.start"&&d.type!=="session.shutdown"&&d.type!=="session.resume"),o=ge(),s={type:"session.start",data:{...n.data,startTime:new Date().toISOString()},id:o,timestamp:new Date().toISOString(),parentId:null},a=new Map;a.set(n.id,o);let l=[s],c=o;for(let d of i){let u=ge();a.set(d.id,u);let p=d.parentId!==null?a.get(d.parentId)??c:c;l.push({type:d.type,data:d.data,id:u,timestamp:d.timestamp,parentId:p}),c=u}return l}function im(r,t,e){let n=new Date().toISOString();return[`id: ${r}`,`cwd: ${t}`,"summary_count: 0",`created_at: ${n}`,`updated_at: ${n}`,`summary: ${e}`,""].join(`
`)}async function om(r,t,e,n){await jt(r,"PRAGMA foreign_keys = ON"),await jt(r,"BEGIN TRANSACTION");try{let i=new Date().toISOString();await Kt(r,`INSERT INTO sessions (id, cwd, repository, branch, summary, created_at, updated_at, host_type)
			SELECT ?, cwd, repository, branch, summary, ?, ?, host_type
			FROM sessions WHERE id = ?`,[e,i,i,t]),await Kt(r,`INSERT INTO turns (session_id, turn_index, user_message, assistant_response, timestamp)
			SELECT ?, turn_index, user_message, assistant_response, timestamp
			FROM turns
			WHERE session_id = ? AND turn_index <= ?`,[e,t,n]),await Kt(r,`INSERT INTO session_files (session_id, file_path, tool_name, turn_index, first_seen_at)
			SELECT ?, file_path, tool_name, turn_index, first_seen_at
			FROM session_files
			WHERE session_id = ? AND turn_index <= ?`,[e,t,n]),await qd(r,`SELECT content, source_type, source_id
			FROM search_index
			WHERE session_id = ? AND source_type = 'turn'`,[t]).then(async o=>{let s=`${t}:turn:`;for(let a of o){let l=a.source_id;if(l.startsWith(s)){let c=parseInt(l.substring(s.length),10);if(!isNaN(c)&&c<=n){let d=l.replace(t,e);await Kt(r,`INSERT INTO search_index (content, session_id, source_type, source_id)
							VALUES (?, ?, ?, ?)`,[a.content,e,a.source_type,d])}}}}),await Kt(r,`INSERT INTO checkpoints (session_id, checkpoint_number, title, overview, history, work_done, technical_details, important_files, next_steps, created_at)
			SELECT ?, checkpoint_number, title, overview, history, work_done, technical_details, important_files, next_steps, created_at
			FROM checkpoints
			WHERE session_id = ? AND checkpoint_number <= ?`,[e,t,n+1]),await jt(r,"COMMIT")}catch(i){throw await jt(r,"ROLLBACK"),i}}async function sm(r,t,e){await jt(r,"PRAGMA foreign_keys = ON"),await jt(r,"BEGIN TRANSACTION");try{let n=new Date().toISOString();await Kt(r,"DELETE FROM turns WHERE session_id = ? AND turn_index > ?",[t,e]),await Kt(r,"UPDATE sessions SET updated_at = ? WHERE id = ?",[n,t]),await qd(r,`SELECT source_id FROM search_index
			WHERE session_id = ? AND source_type = 'turn'`,[t]).then(async i=>{let o=`${t}:turn:`;for(let s of i){let a=s.source_id;if(a.startsWith(o)){let l=parseInt(a.substring(o.length),10);!isNaN(l)&&l>e&&await Kt(r,"DELETE FROM search_index WHERE source_id = ? AND session_id = ?",[a,t])}}}),await jt(r,"COMMIT")}catch(n){throw await jt(r,"ROLLBACK"),n}}function zo(){return process.env.COPILOT_CONFIG_DIR??W(Bd.homedir(),".copilot")}async function cl(r,t,e,n){let i=W(r,"session-state"),o=W(i,t,"events.jsonl"),s=await Me.promises.readFile(o,"utf-8"),a=Kd(s),l=nm(a,n,e),c="",d="";try{let v=W(i,t,"workspace.yaml"),g=await Me.promises.readFile(v,"utf-8"),E=g.match(/^cwd:\s*(.+)$/m),R=g.match(/^summary:\s*(.+)$/m);E&&(c=E[1].trim()),R&&(d=R[1].trim())}catch{let v=a.find(g=>g.type==="session.start");v&&(c=v.data.context?.cwd??"")}let u=W(i,e);await Me.promises.mkdir(W(u,"checkpoints"),{recursive:!0}),await Me.promises.mkdir(W(u,"files"),{recursive:!0}),await Me.promises.mkdir(W(u,"research"),{recursive:!0}),await Me.promises.writeFile(W(u,"events.jsonl"),jd(l),"utf-8"),await Me.promises.writeFile(W(u,"workspace.yaml"),im(e,c,d),"utf-8"),await Me.promises.writeFile(W(u,"vscode.metadata.json"),"{}","utf-8"),await Me.promises.writeFile(W(u,"checkpoints","index.md"),"","utf-8");let p=W(r,"session-store.db"),h=await $d(p);try{await om(h,t,e,n)}finally{await Vd(h)}}async function Hd(r,t,e){let n=W(r,"session-state"),i=W(n,t),o=W(i,"events.jsonl"),s=await Me.promises.readFile(o,"utf-8"),a=Kd(s),l;if(e<0){let u=a.find(p=>p.type==="session.start");if(!u)throw new Error("No session.start event found in event log");l=[{type:"session.start",data:{...u.data,startTime:new Date().toISOString()},id:ge(),timestamp:new Date().toISOString(),parentId:null}]}else l=rm(a,e);await Me.promises.writeFile(o,jd(l),"utf-8");try{let u=W(i,"workspace.yaml"),p=await Me.promises.readFile(u,"utf-8");p=p.replace(/^updated_at:\s*.+$/m,`updated_at: ${new Date().toISOString()}`),await Me.promises.writeFile(u,p,"utf-8")}catch{}let c=W(r,"session-store.db"),d=await $d(c);try{await sm(d,t,e)}finally{await Vd(d)}}var nt=class extends A{constructor(e,n,i,o){super();this._logService=e;this._instantiationService=n;this._fileService=i;this._sessionDataService=o;this.id="copilot";this._onDidSessionProgress=this._register(new b);this.onDidSessionProgress=this._onDidSessionProgress.event;this._sessions=this._register(new st);this._sessionSequencer=new Wt;this._plugins=this._instantiationService.createInstance(di)}getDescriptor(){return{provider:"copilot",displayName:"Agent Host - Copilot",description:"Copilot SDK agent running in a dedicated process",requiresAuth:!0}}getProtectedResources(){return[{resource:"https://api.github.com",resource_name:"GitHub Copilot",authorization_servers:["https://github.com/login/oauth"],scopes_supported:["read:user","user:email"]}]}async authenticate(e,n){if(e!=="https://api.github.com")return!1;let i=this._githubToken!==n;if(this._githubToken=n,this._logService.info(`[Copilot] Auth token ${i?"updated":"unchanged"}`),i&&this._client&&this._sessions.size===0){this._logService.info("[Copilot] Restarting CopilotClient with new token");let o=this._client;this._client=void 0,this._clientStarting=void 0,await o.stop()}return!0}async _ensureClient(){return this._client?this._client:this._clientStarting?this._clientStarting:(this._clientStarting=(async()=>{this._logService.info(`[Copilot] Starting CopilotClient... ${this._githubToken?"(with token)":"(no token)"}`);let e=Object.assign({},process.env,{ELECTRON_RUN_AS_NODE:"1"});delete e.NODE_OPTIONS,delete e.VSCODE_INSPECTOR_OPTIONS,delete e.VSCODE_ESM_ENTRYPOINT,delete e.VSCODE_HANDLES_UNCAUGHT_ERRORS;for(let c of Object.keys(e))c!=="ELECTRON_RUN_AS_NODE"&&(c.startsWith("VSCODE_")||c.startsWith("ELECTRON_"))&&delete e[c];e.COPILOT_CLI_RUN_AS_NODE="1",e.USE_BUILTIN_RIPGREP="false";let n=m.joinPath(lt.asFileUri(""),"..","node_modules","@github","copilot","index.js").fsPath,i=lm.replace(/\bnode_modules\.asar\b/,"node_modules.asar.unpacked"),o=he(i),s=Object.keys(e).find(c=>c.toUpperCase()==="PATH")??"PATH",a=e[s];e[s]=a?`${a}${Bs}${o}`:o,this._logService.info(`[Copilot] Resolved CLI path: ${n}`);let l=new am({githubToken:this._githubToken,useLoggedInUser:!this._githubToken,useStdio:!0,autoStart:!0,env:e,cliPath:n});return await l.start(),this._logService.info("[Copilot] CopilotClient started successfully"),this._client=l,this._clientStarting=void 0,l})(),this._clientStarting)}async listSessions(){this._logService.info("[Copilot] Listing sessions...");let i=(await(await this._ensureClient()).listSessions()).map(o=>({session:ie.uri(this.id,o.sessionId),startTime:o.startTime.getTime(),modifiedTime:o.modifiedTime.getTime(),summary:o.summary,workingDirectory:typeof o.context?.cwd=="string"?m.file(o.context.cwd):void 0}));return this._logService.info(`[Copilot] Found ${i.length} sessions`),i}async listModels(){this._logService.info("[Copilot] Listing models...");let i=(await(await this._ensureClient()).listModels()).map(o=>({provider:this.id,id:o.id,name:o.name,maxContextWindow:o.capabilities.limits.max_context_window_tokens,supportsVision:o.capabilities.supports.vision,supportsReasoningEffort:o.capabilities.supports.reasoningEffort,supportedReasoningEfforts:o.supportedReasoningEfforts,defaultReasoningEffort:o.defaultReasoningEffort,policyState:o.policy?.state,billingMultiplier:o.billing?.multiplier}));return this._logService.info(`[Copilot] Found ${i.length} models`),i}async createSession(e){this._logService.info(`[Copilot] Creating session... ${e?.model?`model=${e.model}`:""}`);let n=await this._ensureClient(),i=await this._plugins.getAppliedPlugins();if(e?.fork){let c=ie.id(e.fork.session),d=e.session?ie.id(e.session):ge();return this._sessionSequencer.queue(c,async()=>{this._logService.info(`[Copilot] Forking session ${c} at index ${e.fork.turnIndex} \u2192 ${d}`),this._sessions.has(c)||await this._resumeSession(c);let u=zo();await cl(u,c,d,e.fork.turnIndex);let h=(await this._resumeSession(d)).sessionUri;return this._logService.info(`[Copilot] Forked session created: ${h.toString()}`),h})}let o=e?.session?ie.id(e.session):ge(),s=async c=>{let d=await sl(i.flatMap(p=>p.agents),this._fileService),u=await n.createSession({model:e?.model,sessionId:o,streaming:!0,workingDirectory:e?.workingDirectory?.fsPath,onPermissionRequest:c.onPermissionRequest,hooks:ll(i.flatMap(p=>p.hooks),c.hooks),mcpServers:ol(i.flatMap(p=>p.mcpServers)),customAgents:d,skillDirectories:al(i.flatMap(p=>p.skills))});return new ur(u)},a=this._createAgentSession(s,e?.workingDirectory,o);this._plugins.setAppliedPlugins(a,i),await a.initializeSession(),this._storeSessionMetadata(a.sessionUri,e?.model,e?.workingDirectory);let l=a.sessionUri;return this._logService.info(`[Copilot] Session created: ${l.toString()}`),l}async setClientCustomizations(e,n,i){return this._plugins.sync(e,n,i)}setCustomizationEnabled(e,n){this._plugins.setEnabled(e,n)}async sendMessage(e,n,i){let o=ie.id(e);await this._sessionSequencer.queue(o,async()=>{let s=this._sessions.get(o);s&&await this._plugins.needsSessionRefresh(s)&&(this._logService.info(`[Copilot:${o}] Plugin config changed, refreshing session`),this._sessions.deleteAndDispose(o),s=void 0),s??=await this._resumeSession(o),await s.send(n,i)})}setPendingMessages(e,n,i){let o=ie.id(e),s=this._sessions.get(o);if(!s){this._logService.warn(`[Copilot:${o}] setPendingMessages: session not found`);return}n&&s.sendSteering(n)}async getSessionMessages(e){let n=ie.id(e),i=this._sessions.get(n)??await this._resumeSession(n).catch(()=>{});return i?i.getMessages():[]}async disposeSession(e){let n=ie.id(e);await this._sessionSequencer.queue(n,async()=>{this._sessions.deleteAndDispose(n)})}async abortSession(e){let n=ie.id(e);await this._sessionSequencer.queue(n,async()=>{let i=this._sessions.get(n);i&&await i.abort()})}async truncateSession(e,n){let i=ie.id(e);await this._sessionSequencer.queue(i,async()=>{this._logService.info(`[Copilot:${i}] Truncating session${n!==void 0?` at index ${n}`:" (all turns)"}`);let o=n??-1,s=this._sessions.get(i);s&&await s.destroySession(),this._sessions.deleteAndDispose(i);let a=zo();await Hd(a,i,o),await this._resumeSession(i),this._logService.info(`[Copilot:${i}] Session truncated and resumed`)})}async forkSession(e,n,i){let o=ie.id(e);await this._sessionSequencer.queue(o,async()=>{this._logService.info(`[Copilot] Forking session ${o} at index ${i} \u2192 ${n}`);let s=zo();await cl(s,o,n,i),this._logService.info(`[Copilot] Forked session ${n} created on disk`)})}async changeModel(e,n){let i=ie.id(e),o=this._sessions.get(i);o&&await o.setModel(n),this._storeSessionMetadata(e,n,void 0)}async shutdown(){this._logService.info("[Copilot] Shutting down..."),this._sessions.clearAndDisposeAll(),await this._client?.stop(),this._client=void 0}respondToPermissionRequest(e,n){for(let[,i]of this._sessions)if(i.respondToPermissionRequest(e,n))return}hasSession(e){return this._sessions.has(ie.id(e))}_createAgentSession(e,n,i){let o=ie.uri(this.id,i),s=this._instantiationService.createInstance(lr,o,i,n,this._onDidSessionProgress,e);return this._sessions.set(i,s),s}async _resumeSession(e){this._logService.info(`[Copilot:${e}] Session not in memory, resuming...`);let n=await this._ensureClient(),i=await this._plugins.getAppliedPlugins(),o=async l=>{let c=await sl(i.flatMap(d=>d.agents),this._fileService);return{onPermissionRequest:l.onPermissionRequest,hooks:ll(i.flatMap(d=>d.hooks),l.hooks),mcpServers:ol(i.flatMap(d=>d.mcpServers)),customAgents:c,skillDirectories:al(i.flatMap(d=>d.skills))}},s=async l=>{let c=await o(l);try{let d=await n.resumeSession(e,{...c});return new ur(d)}catch(d){if(!d||d.code!==-32603)throw d;this._logService.warn(`[Copilot:${e}] Resume failed (session not found in SDK), recreating`);let u=await this._readSessionMetadata(ie.uri(this.id,e)),p=await n.createSession({...c,sessionId:e,streaming:!0,model:u.model,workingDirectory:u.workingDirectory?.fsPath});return new ur(p)}},a=this._createAgentSession(s,void 0,e);return this._plugins.setAppliedPlugins(a,i),await a.initializeSession(),a}static{this._META_MODEL="copilot.model"}static{this._META_CWD="copilot.workingDirectory"}_storeSessionMetadata(e,n,i){this._sessionDataService.tryOpenDatabase(e)?.then(s=>{if(!s)return;let a=s.object,l=[];n&&l.push(a.setMetadata(nt._META_MODEL,n)),i&&l.push(a.setMetadata(nt._META_CWD,i.toString())),Promise.all(l).finally(()=>s.dispose())})}async _readSessionMetadata(e){let n=await this._sessionDataService.tryOpenDatabase(e);if(!n)return{};try{let[i,o]=await Promise.all([n.object.getMetadata(nt._META_MODEL),n.object.getMetadata(nt._META_CWD)]);return{model:i,workingDirectory:o?m.parse(o):void 0}}finally{n.dispose()}}dispose(){this._client?.stop().catch(()=>{}),super.dispose()}};nt=D([re(0,Ce),re(1,Zi),re(2,tt),re(3,or)],nt);var di=class{constructor(t,e,n){this._pluginManager=t;this._logService=e;this._fileService=n;this._enablement=new Map;this._lastSynced=Promise.resolve({synced:[],parsed:[]});this._appliedParsed=new WeakMap}async needsSessionRefresh(t){let{parsed:e}=await this._lastSynced;return!Wd(this._appliedParsed.get(t)||[],e)}async getAppliedPlugins(){let{parsed:t}=await this._lastSynced;return t}setAppliedPlugins(t,e){this._appliedParsed.set(t,e)}setEnabled(t,e){this._enablement.set(t,e)}sync(t,e,n){let i=this._lastSynced;return(this._lastSynced=i.catch(()=>[]).then(async()=>{let s=await this._pluginManager.syncCustomizations(t,e,c=>{n?.(c.map(d=>({customization:d})))}),a=[],l=[];for(let c of s)if(c.pluginDir)try{a.push(await Nd(c.pluginDir,this._fileService,void 0,this._getUserHome())),l.push(c)}catch(d){this._logService.warn(`[Copilot:PluginController] Error parsing plugin: ${d}`),l.push({customization:{...c.customization,status:"error",statusMessage:`Error parsing plugin: ${d}`}})}else l.push(c);return{synced:l,parsed:a}})).then(s=>s.synced)}_getUserHome(){return process.env.HOME??process.env.USERPROFILE??""}};di=D([re(0,No),re(1,Ce),re(2,tt)],di);var Ho=class extends Error{constructor(e,n,i){super(n);this.code=e;this.data=i}},Gd=class r extends A{constructor(e,n){super();this._send=e;this._handlers=n;this._nextRequestId=1;this._pendingRequests=new Map}static{this.ParseError=-32700}static{this.MethodNotFound=-32601}static{this.InternalError=-32603}sendNotification(e){this._send({jsonrpc:"2.0",...e})}sendRequest(e,n=Be.None,i){if(this._store.isDisposed)return Promise.reject(new Ie);let o=this._nextRequestId++,s=new He,a=new fe;this._pendingRequests.set(o,{promise:s,cts:a});let l=n.onCancellationRequested(()=>{s.isSettled||(this._pendingRequests.delete(o),a.cancel(),i?.(o),s.cancel()),l.dispose()});return this._send({jsonrpc:"2.0",id:o,...e}),s.p.finally(()=>{l.dispose(),this._pendingRequests.delete(o),a.dispose(!0)})}async handleMessage(e){if(Array.isArray(e)){let i=[];for(let o of e){let s=await this._handleMessage(o);s&&i.push(s)}return i}let n=await this._handleMessage(e);return n?[n]:[]}cancelPendingRequest(e){let n=this._pendingRequests.get(e);n&&(this._pendingRequests.delete(e),n.cts.cancel(),n.promise.cancel(),n.cts.dispose(!0))}cancelAllRequests(){for(let[e,n]of this._pendingRequests)this._pendingRequests.delete(e),n.cts.cancel(),n.promise.cancel(),n.cts.dispose(!0)}async _handleMessage(e){if(ul(e)){$e(e,{result:!0})?this._handleResult(e):this._handleError(e);return}if(cm(e))return this._handleRequest(e);um(e)&&this._handlers.handleNotification?.(e)}_handleResult(e){let n=this._pendingRequests.get(e.id);n&&(this._pendingRequests.delete(e.id),n.promise.complete(e.result),n.cts.dispose(!0))}_handleError(e){if(e.id===void 0)return;let n=this._pendingRequests.get(e.id);n&&(this._pendingRequests.delete(e.id),n.promise.error(new Ho(e.error.code,e.error.message,e.error.data)),n.cts.dispose(!0))}async _handleRequest(e){if(!this._handlers.handleRequest){let i={jsonrpc:"2.0",id:e.id,error:{code:r.MethodNotFound,message:`Method not found: ${e.method}`}};return this._send(i),i}let n=new fe;this._register(O(()=>n.dispose(!0)));try{let i=this._handlers.handleRequest(e,n.token),o=dm(i)?await i:i,s={jsonrpc:"2.0",id:e.id,result:o};return this._send(s),s}catch(i){let o;return i instanceof Ho?o={jsonrpc:"2.0",id:e.id,error:{code:i.code,message:i.message,data:i.data}}:o={jsonrpc:"2.0",id:e.id,error:{code:r.InternalError,message:i instanceof Error?i.message:"Internal error"}},this._send(o),o}finally{n.dispose(!0)}}dispose(){this.cancelAllRequests(),super.dispose()}static createParseError(e,n){return{jsonrpc:"2.0",error:{code:r.ParseError,message:e,data:n}}}};function cm(r){return"method"in r&&"id"in r&&(typeof r.id=="string"||typeof r.id=="number")}function ul(r){return $e(r,{id:!0,result:!0})||$e(r,{id:!0,error:!0})}function um(r){return $e(r,{method:!0})&&!$e(r,{id:!0})}function dm(r){return typeof r=="object"&&r!==null&&"then"in r&&typeof r.then=="function"}var pm=1e3;function Go(r,t){return{jsonrpc:"2.0",id:r,result:t}}function dl(r,t,e,n){return{jsonrpc:"2.0",id:r,error:{code:t,message:e,...n!==void 0?{data:n}:{}}}}function Jo(r,t){if(t instanceof j)return dl(r,t.code,t.message,t.data);let e=t instanceof Error?t.stack??t.message:String(t);return dl(r,Xn,e)}var dr=class extends A{constructor(e,n,i,o,s,a){super();this._agentService=e;this._stateManager=n;this._server=i;this._config=o;this._clientFileSystemProvider=s;this._logService=a;this._clients=new Map;this._replayBuffer=[];this._onDidChangeConnectionCount=this._register(new b);this.onDidChangeConnectionCount=this._onDidChangeConnectionCount.event;this._requestHandlers={subscribe:async(e,n)=>{try{let i=await this._agentService.subscribe(m.parse(n.resource));return e.subscriptions.add(n.resource),{snapshot:i}}catch(i){throw i instanceof j?i:new j(Vt,`Resource not found: ${n.resource}`)}},createSession:async(e,n)=>{let i,o;if(n.fork){let s=this._stateManager.getSessionState(n.fork.session);if(!s)throw new j(Vt,`Fork source session not found: ${n.fork.session}`);let a=s.turns.findIndex(l=>l.id===n.fork.turnId);if(a<0)throw new j(Vt,`Fork turn ID ${n.fork.turnId} not found in session ${n.fork.session}`);o={session:m.parse(n.fork.session),turnIndex:a}}try{i=await this._agentService.createSession({provider:n.provider,model:n.model,workingDirectory:n.workingDirectory?m.parse(n.workingDirectory):void 0,session:m.parse(n.session),fork:o})}catch(s){throw s instanceof j?s:new j(Xu,s instanceof Error?s.message:String(s))}return i.toString()!==m.parse(n.session).toString()&&this._logService.warn(`[ProtocolServer] createSession: provider returned URI ${i.toString()} but client requested ${n.session}`),null},disposeSession:async(e,n)=>(await this._agentService.disposeSession(m.parse(n.session)),null),resourceWrite:async(e,n)=>this._agentService.resourceWrite(n),listSessions:async()=>({items:(await this._agentService.listSessions()).map(i=>({resource:i.session.toString(),provider:ie.provider(i.session)??"copilot",title:i.summary??"Session",status:"idle",createdAt:i.startTime,modifiedAt:i.modifiedTime,workingDirectory:i.workingDirectory?.toString()}))}),fetchTurns:async(e,n)=>{let i=this._stateManager.getSessionState(n.session);if(!i)throw new j(Vt,`Session not found: ${n.session}`);let o=i.turns,s=Math.min(n.limit??50,100),a=o.length;if(n.before){let c=o.findIndex(d=>d.id===n.before);c!==-1&&(a=c)}let l=Math.max(0,a-s);return{turns:o.slice(l,a),hasMore:l>0}},resourceList:async(e,n)=>this._agentService.resourceList(m.parse(n.uri)),resourceRead:async(e,n)=>this._agentService.resourceRead(m.parse(n.uri)),resourceCopy:async(e,n)=>this._agentService.resourceCopy(n),resourceDelete:async(e,n)=>this._agentService.resourceDelete(n),resourceMove:async(e,n)=>this._agentService.resourceMove(n)};this._reverseRequestId=0;this._pendingReverseRequests=new Map;this._register(this._server.onConnection(l=>{this._handleNewConnection(l)})),this._register(this._stateManager.onDidEmitEnvelope(l=>{this._replayBuffer.push(l),this._replayBuffer.length>pm&&this._replayBuffer.shift(),this._broadcastAction(l)})),this._register(this._stateManager.onDidEmitNotification(l=>{this._broadcastNotification(l)}))}_handleNewConnection(e){let n=new N,i;n.add(e.onMessage(o=>{if(ed(o)){if(this._logService.trace(`[ProtocolServer] request: method=${o.method} id=${o.id}`),!i&&o.method==="initialize"){try{let s=this._handleInitialize(o.params,e,n);i=s.client,e.send(Go(o.id,s.response))}catch(s){e.send(Jo(o.id,s))}return}if(!i&&o.method==="reconnect"){try{let s=this._handleReconnect(o.params,e,n);i=s.client,e.send(Go(o.id,s.response))}catch(s){e.send(Jo(o.id,s))}return}if(!i)return;this._handleRequest(i,o.method,o.params,o.id)}else if(td(o))switch(this._logService.trace(`[ProtocolServer] notification: method=${o.method}`),o.method){case"unsubscribe":i&&i.subscriptions.delete(o.params.resource);break;case"dispatchAction":if(i){this._logService.trace(`[ProtocolServer] dispatchAction: ${JSON.stringify(o.params.action.type)}`);let s=o.params.action;this._agentService.dispatchAction(s,i.clientId,o.params.clientSeq)}break}else if(ul(o)){let s=this._pendingReverseRequests.get(o.id);s&&(this._pendingReverseRequests.delete(o.id),$e(o,{error:!0})?s.reject(new Error(o.error?.message??"Reverse RPC error")):s.resolve(o.result))}})),n.add(e.onClose(()=>{i&&this._clients.get(i.clientId)===i&&(this._logService.info(`[ProtocolServer] Client disconnected: ${i.clientId}`),this._clients.delete(i.clientId),this._rejectPendingReverseRequests(i.clientId),this._onDidChangeConnectionCount.fire(this._clients.size)),n.dispose()})),n.add(e)}_handleInitialize(e,n,i){if(this._logService.info(`[ProtocolServer] Initialize: clientId=${e.clientId}, version=${e.protocolVersion}`),e.protocolVersion<1)throw new j(Zu,`Client protocol version ${e.protocolVersion} is below minimum ${1}`);let o={clientId:e.clientId,protocolVersion:e.protocolVersion,transport:n,subscriptions:new Set,disposables:i};this._clients.set(e.clientId,o),this._onDidChangeConnectionCount.fire(this._clients.size),i.add(this._clientFileSystemProvider.registerAuthority(e.clientId,{resourceList:a=>this._sendReverseRequest(e.clientId,"resourceList",{uri:a.toString()}),resourceRead:a=>this._sendReverseRequest(e.clientId,"resourceRead",{uri:a.toString()}),resourceWrite:a=>this._sendReverseRequest(e.clientId,"resourceWrite",a),resourceDelete:a=>this._sendReverseRequest(e.clientId,"resourceDelete",a),resourceMove:a=>this._sendReverseRequest(e.clientId,"resourceMove",a)}));let s=[];if(e.initialSubscriptions)for(let a of e.initialSubscriptions){let l=this._stateManager.getSnapshot(a);l&&(s.push(l),o.subscriptions.add(a.toString()))}return{client:o,response:{protocolVersion:1,serverSeq:this._stateManager.serverSeq,snapshots:s,defaultDirectory:this._config.defaultDirectory}}}_handleReconnect(e,n,i){this._logService.info(`[ProtocolServer] Reconnect: clientId=${e.clientId}, lastSeenSeq=${e.lastSeenServerSeq}`);let o={clientId:e.clientId,protocolVersion:1,transport:n,subscriptions:new Set,disposables:i};this._clients.set(e.clientId,o),this._onDidChangeConnectionCount.fire(this._clients.size);let s=this._replayBuffer.length>0?this._replayBuffer[0].serverSeq:this._stateManager.serverSeq;if(e.lastSeenServerSeq>=s){let l=[];for(let c of e.subscriptions)o.subscriptions.add(c.toString());for(let c of this._replayBuffer)c.serverSeq>e.lastSeenServerSeq&&this._isRelevantToClient(o,c)&&l.push(c);return{client:o,response:{type:"replay",actions:l}}}else{let l=[];for(let c of e.subscriptions){let d=this._stateManager.getSnapshot(c);d&&(l.push(d),o.subscriptions.add(c))}return{client:o,response:{type:"snapshot",snapshots:l}}}}_sendReverseRequest(e,n,i){let o=this._clients.get(e);if(!o)return Promise.reject(new Error(`Client ${e} is not connected`));let s=++this._reverseRequestId;return new Promise((a,l)=>{this._pendingReverseRequests.set(s,{clientId:e,resolve:a,reject:l});let c={jsonrpc:"2.0",id:s,method:n,params:i};o.transport.send(c)})}_rejectPendingReverseRequests(e){for(let[n,i]of this._pendingReverseRequests)i.clientId===e&&(this._pendingReverseRequests.delete(n),i.reject(new Error(`Client ${e} disconnected`)))}_handleRequest(e,n,i,o){let s=this._requestHandlers.hasOwnProperty(n)?this._requestHandlers[n]:void 0;if(s){s(e,i).then(l=>{this._logService.trace(`[ProtocolServer] Request '${n}' id=${o} succeeded`),e.transport.send(Go(o,l??null))}).catch(l=>{this._logService.error(`[ProtocolServer] Request '${n}' failed`,l),e.transport.send(Jo(o,l))});return}let a=this._handleExtensionRequest(n,i);if(a){a.then(l=>{e.transport.send(Go(o,l??null))}).catch(l=>{this._logService.error(`[ProtocolServer] Extension request '${n}' failed`,l),e.transport.send(Jo(o,l))});return}e.transport.send(dl(o,Xn,`Unknown method: ${n}`))}_handleExtensionRequest(e,n){switch(e){case"getResourceMetadata":return this._agentService.getResourceMetadata();case"authenticate":{let i=n;return!i||typeof i.resource!="string"||typeof i.token!="string"?Promise.reject(new j(-32602,"Invalid authenticate params")):this._agentService.authenticate(i)}case"refreshModels":return this._agentService.refreshModels();case"listAgents":return this._agentService.listAgents();case"shutdown":return this._agentService.shutdown();default:return}}_broadcastAction(e){this._logService.trace(`[ProtocolServer] Broadcasting action: ${e.action.type}`);let n={jsonrpc:"2.0",method:"action",params:e};for(let i of this._clients.values())this._isRelevantToClient(i,e)&&i.transport.send(n)}_broadcastNotification(e){let n={jsonrpc:"2.0",method:"notification",params:{notification:e}};for(let i of this._clients.values())i.transport.send(n)}_isRelevantToClient(e,n){let i=n.action;return i.type.startsWith("root/")?e.subscriptions.has(vo):go(i)?e.subscriptions.has(i.session):!1}dispose(){for(let e of this._clients.values())e.disposables.dispose();this._clients.clear();for(let[,e]of this._pendingReverseRequests)e.reject(new Error("ProtocolServerHandler disposed"));this._pendingReverseRequests.clear(),this._replayBuffer.length=0,super.dispose()}};dr=D([re(5,Ce)],dr);var pl=class extends A{constructor(e,n){super();this._ws=e;this._WebSocket=n;this._onMessage=this._register(new b);this.onMessage=this._onMessage.event;this._onClose=this._register(new b);this.onClose=this._onClose.event;this._ws.on("message",i=>{try{let o=typeof i=="string"?i:i.toString("utf-8"),s=JSON.parse(o);this._onMessage.fire(s)}catch{this.send({jsonrpc:"2.0",id:null,error:{code:Yu,message:"Parse error"}})}}),this._ws.on("close",()=>{this._onClose.fire()}),this._ws.on("error",()=>{this._onClose.fire()})}send(e){this._ws.readyState===this._WebSocket.OPEN&&this._ws.send(JSON.stringify(e))}dispose(){this._ws.close(),super.dispose()}},Qo=class r extends A{constructor(e,n,i,o,s){super();this._logService=n;this._onConnection=this._register(new b);this.onConnection=this._onConnection.event;this._WebSocket=i.WebSocket;let a=typeof e=="number"?{port:e}:e,l=a.host??"127.0.0.1",c=a.connectionTokenValidate?(d,u)=>{let h=s.parse(d.req.url??"",!0).query[Js];if(!a.connectionTokenValidate(h)){this._logService.warn("[WebSocketProtocol] Connection rejected: invalid connection token"),u(!1,403,"Forbidden");return}u(!0)}:void 0;a.socketPath?(this._httpServer=o.createServer(),this._wss=new i.WebSocketServer({server:this._httpServer,verifyClient:c}),this._httpServer.listen(a.socketPath,()=>{this._logService.info(`[WebSocketProtocol] Server listening on socket ${a.socketPath}`)})):(this._wss=new i.WebSocketServer({port:a.port,host:l,verifyClient:c}),this._logService.info(`[WebSocketProtocol] Server listening on ${l}:${a.port}`)),this._wss.on("connection",d=>{this._logService.trace("[WebSocketProtocol] New client connection");let u=new pl(d,this._WebSocket);this._onConnection.fire(u)}),this._wss.on("error",d=>{this._logService.error("[WebSocketProtocol] Server error",d)})}get address(){let e=this._wss.address();return!e||typeof e=="string"?e??void 0:`${e.address}:${e.port}`}static async create(e,n){let[i,o,s]=await Promise.all([import("ws"),import("http"),import("url")]);return new r(e,n,i,o,s)}dispose(){this._wss.close(),this._httpServer?.close(),super.dispose()}};import{homedir as Im,tmpdir as Tm}from"os";var fm=60,hm=fm*60,fl=hm*24,VE=fl*7,$E=fl*30,KE=fl*365;function Yd(r){return r.getFullYear()+"-"+String(r.getMonth()+1).padStart(2,"0")+"-"+String(r.getDate()).padStart(2,"0")+"T"+String(r.getHours()).padStart(2,"0")+":"+String(r.getMinutes()).padStart(2,"0")+":"+String(r.getSeconds()).padStart(2,"0")+"."+(r.getMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"}var Xd=/^([^.]+\..+)[:=](.+)$/,$=class{constructor(t,e,n){this._args=t;this.paths=e;this.productService=n}get appRoot(){return he(lt.asFileUri("").fsPath)}get userHome(){return m.file(this.paths.homeDir)}get userDataPath(){return this.paths.userDataDir}get appSettingsHome(){return m.file(W(this.userDataPath,"User"))}get tmpDir(){return m.file(this.paths.tmpDir)}get cacheHome(){return m.file(this.userDataPath)}get stateResource(){return G(this.appSettingsHome,"globalStorage","storage.json")}get userRoamingDataHome(){return this.appSettingsHome.with({scheme:ee.vscodeUserData})}get userDataSyncHome(){return G(this.appSettingsHome,"sync")}get logsHome(){if(!this.args.logsPath){let t=Yd(new Date).replace(/-|:|\.\d+Z$/g,"");this.args.logsPath=W(this.userDataPath,"logs",t)}return m.file(this.args.logsPath)}get sync(){return this.args.sync}get workspaceStorageHome(){return G(this.appSettingsHome,"workspaceStorage")}get localHistoryHome(){return G(this.appSettingsHome,"History")}get keyboardLayoutResource(){return G(this.userRoamingDataHome,"keyboardLayout.json")}get argvResource(){let t=Te.VSCODE_PORTABLE;return t?m.file(W(t,"argv.json")):G(this.userHome,this.productService.dataFolderName,"argv.json")}get isExtensionDevelopment(){return!!this.args.extensionDevelopmentPath}get untitledWorkspacesHome(){return m.file(W(this.userDataPath,"Workspaces"))}get builtinExtensionsPath(){let t=this.args["builtin-extensions-dir"];return t?en(t):je(W(lt.asFileUri("").fsPath,"..","extensions"))}get extensionsDownloadLocation(){let t=this.args["extensions-download-dir"];return t?m.file(en(t)):m.file(W(this.userDataPath,"CachedExtensionVSIXs"))}get extensionsPath(){let t=this.args["extensions-dir"];if(t)return en(t);let e=Te.VSCODE_EXTENSIONS;if(e)return e;let n=Te.VSCODE_PORTABLE;return n?W(n,"extensions"):G(this.userHome,this.productService.dataFolderName,"extensions").fsPath}get agentPluginsPath(){let t=this.args["agent-plugins-dir"];if(t)return en(t);let e=Te.VSCODE_AGENT_PLUGINS;if(e)return e;let n=Te.VSCODE_PORTABLE;return n?W(n,"agent-plugins"):G(this.userHome,this.productService.dataFolderName,"agent-plugins").fsPath}get extensionDevelopmentLocationURI(){let t=this.args.extensionDevelopmentPath;if(Array.isArray(t))return t.map(e=>/^[^:/?#]+?:\/\//.test(e)?m.parse(e):m.file(je(e)))}get extensionDevelopmentKind(){return this.args.extensionDevelopmentKind?.map(t=>t==="ui"||t==="workspace"||t==="web"?t:"workspace")}get extensionTestsLocationURI(){let t=this.args.extensionTestsPath;if(t)return/^[^:/?#]+?:\/\//.test(t)?m.parse(t):m.file(je(t))}get disableExtensions(){if(this.args["disable-extensions"])return!0;let t=this.args["disable-extension"];if(t){if(typeof t=="string")return[t];if(Array.isArray(t)&&t.length>0)return t}return!1}get debugExtensionHost(){return gm(this.args,this.isBuilt)}get debugRenderer(){return!!this.args.debugRenderer}get isBuilt(){return!Te.VSCODE_DEV}get verbose(){return!!this.args.verbose}get logLevel(){return this.args.log?.find(t=>!Xd.test(t))}get extensionLogLevel(){let t=[];for(let e of this.args.log||[]){let n=Xd.exec(e);n?.[1]&&n[2]&&t.push([n[1],n[2]])}return t.length?t:void 0}get serviceMachineIdResource(){return G(m.file(this.userDataPath),"machineid")}get crashReporterId(){return this.args["crash-reporter-id"]}get crashReporterDirectory(){return this.args["crash-reporter-directory"]}get disableTelemetry(){return!!this.args["disable-telemetry"]}get disableExperiments(){return!!this.args["disable-experiments"]}get disableWorkspaceTrust(){return!!this.args["disable-workspace-trust"]}get useInMemorySecretStorage(){return!!this.args["use-inmemory-secretstorage"]}get policyFile(){if(this.args["__enable-file-policy"]){let t=Te.VSCODE_PORTABLE;return t?m.file(W(t,"policy.json")):G(this.userHome,this.productService.dataFolderName,"policy.json")}}get agentSessionsWorkspace(){return G(this.appSettingsHome,"agent-sessions.code-workspace")}get editSessionId(){return this.args.editSessionId}get exportPolicyData(){return this.args["export-policy-data"]}get exportDefaultKeybindings(){return this.args["export-default-keybindings"]}get continueOn(){return this.args.continueOn}set continueOn(t){this.args.continueOn=t}get args(){return this._args}};D([K],$.prototype,"appRoot",1),D([K],$.prototype,"userHome",1),D([K],$.prototype,"userDataPath",1),D([K],$.prototype,"appSettingsHome",1),D([K],$.prototype,"tmpDir",1),D([K],$.prototype,"cacheHome",1),D([K],$.prototype,"stateResource",1),D([K],$.prototype,"userRoamingDataHome",1),D([K],$.prototype,"userDataSyncHome",1),D([K],$.prototype,"sync",1),D([K],$.prototype,"workspaceStorageHome",1),D([K],$.prototype,"localHistoryHome",1),D([K],$.prototype,"keyboardLayoutResource",1),D([K],$.prototype,"argvResource",1),D([K],$.prototype,"isExtensionDevelopment",1),D([K],$.prototype,"untitledWorkspacesHome",1),D([K],$.prototype,"builtinExtensionsPath",1),D([K],$.prototype,"extensionsDownloadLocation",1),D([K],$.prototype,"extensionsPath",1),D([K],$.prototype,"agentPluginsPath",1),D([K],$.prototype,"extensionDevelopmentLocationURI",1),D([K],$.prototype,"extensionDevelopmentKind",1),D([K],$.prototype,"extensionTestsLocationURI",1),D([K],$.prototype,"debugExtensionHost",1),D([K],$.prototype,"logLevel",1),D([K],$.prototype,"extensionLogLevel",1),D([K],$.prototype,"serviceMachineIdResource",1),D([K],$.prototype,"disableTelemetry",1),D([K],$.prototype,"disableExperiments",1),D([K],$.prototype,"disableWorkspaceTrust",1),D([K],$.prototype,"useInMemorySecretStorage",1),D([K],$.prototype,"policyFile",1),D([K],$.prototype,"agentSessionsWorkspace",1);function gm(r,t){return Zd(r["inspect-extensions"],r["inspect-brk-extensions"],5870,t,r.debugId,r.extensionEnvironment)}function Zd(r,t,e,n,i,o){let a=Number(t||r)||(n?null:e),l=a?!!t:!1,c;if(o)try{c=JSON.parse(o)}catch{}return{port:a,break:l,debugId:i,env:c}}import{homedir as ep}from"os";import{resolve as mm,isAbsolute as vm,join as pr}from"path";var ym=process.env.VSCODE_CWD||process.cwd();function tp(r,t){let e=bm(r,t),n=[e];return vm(e)||n.unshift(ym),mm(...n)}function bm(r,t){process.env.VSCODE_DEV&&(process.isEmbeddedApp?t="agents-oss-dev":t="code-oss-dev");let e=process.env.VSCODE_PORTABLE;if(e)return pr(e,"user-data");let n=process.env.VSCODE_APPDATA;if(n)return pr(n,t);let i=r["user-data-dir"];if(i)return i;switch(process.platform){case"win32":if(n=process.env.APPDATA,!n){let o=process.env.USERPROFILE;if(typeof o!="string")throw new Error("Windows: Unexpected undefined %USERPROFILE% environment variable");n=pr(o,"AppData","Roaming")}break;case"darwin":n=pr(ep(),"Library","Application Support");break;case"linux":n=process.env.XDG_CONFIG_HOME||pr(ep(),".config");break;default:throw new Error("Platform not supported")}return pr(n,t)}var Yo=class extends ${constructor(t,e){super(t,{homeDir:Im(),tmpDir:Tm(),userDataDir:tp(t,e.nameShort)},e)}};import Sm from"minimist";var dw={o:f(1987,null),e:f(1971,null),t:f(2001,null),m:f(1982,null)};var np={chat:{type:"subcommand",description:"Pass in a prompt to run in a chat session in the current working directory.",options:{_:{type:"string[]",description:f(1991,null)},mode:{type:"string",cat:"o",alias:"m",args:"mode",description:f(1959,null)},"add-file":{type:"string[]",cat:"o",alias:"a",args:"path",description:f(1954,null)},maximize:{type:"boolean",cat:"o",description:f(1958,null)},"reuse-window":{type:"boolean",cat:"o",alias:"r",description:f(1994,null)},"new-window":{type:"boolean",cat:"o",alias:"n",description:f(1985,null)},profile:{type:"string",cat:"o",args:"profileName",description:f(1990,null)},help:{type:"boolean",alias:"h",description:f(1973,null)}}},"serve-web":{type:"subcommand",description:"Run a server that displays the editor UI in browsers.",options:{"cli-data-dir":{type:"string",args:"dir",description:f(1960,null)},"disable-telemetry":{type:"boolean"},"telemetry-level":{type:"string"}}},"agent-host":{type:"subcommand",description:"Run a server that hosts agents.",options:{"cli-data-dir":{type:"string",args:"dir",description:f(1960,null)},"disable-telemetry":{type:"boolean"},"telemetry-level":{type:"string"}}},tunnel:{type:"subcommand",description:"Make the current machine accessible from vscode.dev or other machines through a secure tunnel.",options:{"cli-data-dir":{type:"string",args:"dir",description:f(1960,null)},"disable-telemetry":{type:"boolean"},"telemetry-level":{type:"string"},user:{type:"subcommand",options:{login:{type:"subcommand",options:{provider:{type:"string"},"access-token":{type:"string"}}}}}}},diff:{type:"boolean",cat:"o",alias:"d",args:["file","file"],description:f(1963,null)},merge:{type:"boolean",cat:"o",alias:"m",args:["path1","path2","base","result"],description:f(1983,null)},add:{type:"boolean",cat:"o",alias:"a",args:"folder",description:f(1953,null)},remove:{type:"boolean",cat:"o",args:"folder",description:f(1992,null)},goto:{type:"boolean",cat:"o",alias:"g",args:"file:line[:character]",description:f(1972,null)},"new-window":{type:"boolean",cat:"o",alias:"n",description:f(1984,null)},"reuse-window":{type:"boolean",cat:"o",alias:"r",description:f(1993,null)},agents:{type:"boolean",cat:"o",deprecates:["sessions"],description:f(1956,null)},wait:{type:"boolean",cat:"o",alias:"w",description:f(2011,null)},waitMarkerFilePath:{type:"string"},locale:{type:"string",cat:"o",args:"locale",description:f(1979,null)},"user-data-dir":{type:"string",cat:"o",args:"dir",description:f(2008,null)},profile:{type:"string",cat:"o",args:"profileName",description:f(1990,null)},help:{type:"boolean",cat:"o",alias:"h",description:f(1973,null)},"extensions-dir":{type:"string",deprecates:["extensionHomePath"],cat:"e",args:"dir",description:f(1970,null)},"extensions-download-dir":{type:"string"},"builtin-extensions-dir":{type:"string"},"list-extensions":{type:"boolean",cat:"e",description:f(1978,null)},"agent-plugins-dir":{type:"string"},"show-versions":{type:"boolean",cat:"e",description:f(1995,null)},category:{type:"string",allowEmptyValue:!0,cat:"e",description:f(1957,null),args:"category"},"install-extension":{type:"string[]",cat:"e",args:"ext-id | path",description:f(1977,null)},"pre-release":{type:"boolean",cat:"e",description:f(1976,null)},"uninstall-extension":{type:"string[]",cat:"e",args:"ext-id",description:f(2003,null)},"update-extensions":{type:"boolean",cat:"e",description:f(2006,null)},"enable-proposed-api":{type:"string[]",allowEmptyValue:!0,cat:"e",args:"ext-id",description:f(1969,null)},"add-mcp":{type:"string[]",cat:"m",args:"json",description:f(1955,null)},version:{type:"boolean",cat:"t",alias:"v",description:f(2010,null)},verbose:{type:"boolean",cat:"t",global:!0,description:f(2009,null)},log:{type:"string[]",cat:"t",args:"level",global:!0,description:f(1981,null)},status:{type:"boolean",alias:"s",cat:"t",description:f(1996,null)},"prof-startup":{type:"boolean",cat:"t",description:f(1989,null)},"prof-append-timers":{type:"string"},"prof-duration-markers":{type:"string[]"},"prof-duration-markers-file":{type:"string"},"no-cached-data":{type:"boolean"},"prof-startup-prefix":{type:"string"},"prof-v8-extensions":{type:"boolean"},"disable-extensions":{type:"boolean",deprecates:["disableExtensions"],cat:"t",description:f(1966,null)},"disable-extension":{type:"string[]",cat:"t",args:"ext-id",description:f(1965,null)},sync:{type:"string",cat:"t",description:f(2002,null),args:["on | off"]},"inspect-extensions":{type:"string",allowEmptyValue:!0,deprecates:["debugPluginHost"],args:"port",cat:"t",description:f(1975,null)},"inspect-brk-extensions":{type:"string",allowEmptyValue:!0,deprecates:["debugBrkPluginHost"],args:"port",cat:"t",description:f(1974,null)},"disable-lcd-text":{type:"boolean",cat:"t",description:f(1968,null)},"disable-gpu":{type:"boolean",cat:"t",description:f(1967,null)},"disable-chromium-sandbox":{type:"boolean",cat:"t",description:f(1964,null)},sandbox:{type:"boolean"},"locate-shell-integration-path":{type:"string",cat:"t",args:["shell"],description:f(1980,null)},telemetry:{type:"boolean",cat:"t",description:f(1999,null)},remote:{type:"string",allowEmptyValue:!0},"folder-uri":{type:"string[]",cat:"o",args:"uri"},"file-uri":{type:"string[]",cat:"o",args:"uri"},"locate-extension":{type:"string[]"},extensionDevelopmentPath:{type:"string[]"},extensionDevelopmentKind:{type:"string[]"},extensionTestsPath:{type:"string"},extensionEnvironment:{type:"string"},debugId:{type:"string"},debugRenderer:{type:"boolean"},"inspect-ptyhost":{type:"string",allowEmptyValue:!0},"inspect-brk-ptyhost":{type:"string",allowEmptyValue:!0},"inspect-agenthost":{type:"string",allowEmptyValue:!0},"inspect-brk-agenthost":{type:"string",allowEmptyValue:!0},"inspect-search":{type:"string",deprecates:["debugSearch"],allowEmptyValue:!0},"inspect-brk-search":{type:"string",deprecates:["debugBrkSearch"],allowEmptyValue:!0},"inspect-sharedprocess":{type:"string",allowEmptyValue:!0},"inspect-brk-sharedprocess":{type:"string",allowEmptyValue:!0},"export-default-configuration":{type:"string"},"export-policy-data":{type:"string",allowEmptyValue:!0},"export-default-keybindings":{type:"string",allowEmptyValue:!0},"install-source":{type:"string"},"enable-smoke-test-driver":{type:"boolean"},"skip-sessions-welcome":{type:"boolean"},logExtensionHostCommunication:{type:"boolean"},"skip-release-notes":{type:"boolean"},"skip-welcome":{type:"boolean"},"disable-telemetry":{type:"boolean"},"disable-updates":{type:"boolean"},transient:{type:"boolean",cat:"t",description:f(2000,null)},"use-inmemory-secretstorage":{type:"boolean",deprecates:["disable-keytar"]},"password-store":{type:"string"},"disable-workspace-trust":{type:"boolean"},"disable-crash-reporter":{type:"boolean"},"crash-reporter-directory":{type:"string"},"crash-reporter-id":{type:"string"},"skip-add-to-recently-opened":{type:"boolean"},"open-url":{type:"boolean"},"file-write":{type:"boolean"},"file-chmod":{type:"boolean"},"install-builtin-extension":{type:"string[]"},force:{type:"boolean"},"do-not-sync":{type:"boolean"},"do-not-include-pack-dependencies":{type:"boolean"},trace:{type:"boolean"},"trace-memory-infra":{type:"boolean"},"trace-category-filter":{type:"string"},"trace-options":{type:"string"},"preserve-env":{type:"boolean"},"force-user-env":{type:"boolean"},"force-disable-user-env":{type:"boolean"},"open-devtools":{type:"boolean"},"disable-gpu-sandbox":{type:"boolean"},logsPath:{type:"string"},"__enable-file-policy":{type:"boolean"},editSessionId:{type:"string"},continueOn:{type:"string"},"enable-coi":{type:"boolean"},"unresponsive-sample-interval":{type:"string"},"unresponsive-sample-period":{type:"string"},"enable-rdp-display-tracking":{type:"boolean"},"disable-layout-restore":{type:"boolean"},"disable-experiments":{type:"boolean"},"no-proxy-server":{type:"boolean"},"no-sandbox":{type:"boolean",alias:"sandbox"},"proxy-server":{type:"string"},"proxy-bypass-list":{type:"string"},"proxy-pac-url":{type:"string"},"js-flags":{type:"string"},inspect:{type:"string",allowEmptyValue:!0},"inspect-brk":{type:"string",allowEmptyValue:!0},nolazy:{type:"boolean"},"force-device-scale-factor":{type:"string"},"force-renderer-accessibility":{type:"boolean"},"ignore-certificate-errors":{type:"boolean"},"allow-insecure-localhost":{type:"boolean"},"log-net-log":{type:"string"},vmodule:{type:"string"},_urls:{type:"string[]"},"disable-dev-shm-usage":{type:"boolean"},"profile-temp":{type:"boolean"},"ozone-platform":{type:"string"},"enable-tracing":{type:"string"},"trace-startup-format":{type:"string"},"trace-startup-file":{type:"string"},"trace-startup-duration":{type:"string"},"xdg-portal-required-version":{type:"string"},_:{type:"string[]"}},_m={onUnknownOption:()=>{},onMultipleValues:()=>{},onEmptyValue:()=>{},onDeprecatedOption:()=>{}};function hl(r,t,e=_m){let n=r.find((p,h)=>p.length>0&&p[0]!=="-"&&t.hasOwnProperty(p)&&t[p].type==="subcommand"),i={},o=["_"],s=[],a={},l;for(let p in t){let h=t[p];h.type==="subcommand"?p===n&&(l=h):(h.alias&&(i[p]=h.alias),h.type==="string"||h.type==="string[]"?(o.push(p),h.deprecates&&o.push(...h.deprecates)):h.type==="boolean"&&(s.push(p),h.deprecates&&s.push(...h.deprecates)),h.global&&(a[p]=h))}if(l&&n){let p=a;for(let E in l.options)p[E]=l.options[E];let h=r.filter(E=>E!==n),v=e.getSubcommandReporter?e.getSubcommandReporter(n):void 0,g=hl(h,p,v);return{[n]:g,_:[]}}let c=Sm(r,{string:o,boolean:s,alias:i}),d={},u=c;d._=c._.map(p=>String(p)).filter(p=>p.length>0),delete u._;for(let p in t){let h=t[p];if(h.type==="subcommand")continue;h.alias&&delete u[h.alias];let v=u[p];if(h.deprecates)for(let g of h.deprecates)u.hasOwnProperty(g)&&(v||(v=u[g],v&&e.onDeprecatedOption(g,h.deprecationMessage||f(1962,null,p))),delete u[g]);if(typeof v<"u"){if(h.type==="string[]"){if(Array.isArray(v)||(v=[v]),!h.allowEmptyValue){let g=v.filter(E=>E.length>0);g.length!==v.length&&(e.onEmptyValue(p),v=g.length>0?g:void 0)}}else h.type==="string"&&(Array.isArray(v)?(v=v.pop(),e.onMultipleValues(p,v)):!v&&!h.allowEmptyValue&&(e.onEmptyValue(p),v=void 0));d[p]=v,h.deprecationMessage&&e.onDeprecatedOption(p,h.deprecationMessage)}delete u[p]}for(let p in u)e.onUnknownOption(p);return d}var Xo=class extends A{constructor(t,e=[]){super(),this.logger=new Ao([t,...e]),this._register(t.onDidChangeLogLevel(n=>this.setLevel(n)))}get onDidChangeLogLevel(){return this.logger.onDidChangeLogLevel}setLevel(t){this.logger.setLevel(t)}getLevel(){return this.logger.getLevel()}trace(t,...e){this.logger.trace(t,...e)}debug(t,...e){this.logger.debug(t,...e)}info(t,...e){this.logger.info(t,...e)}warn(t,...e){this.logger.warn(t,...e)}error(t,...e){this.logger.error(t,...e)}flush(){this.logger.flush()}};async function Rm(r,t,e,n,i){try{let o=await import("@vscode/spdlog");o.setFlushOn(0);let s=await o.createAsyncRotatingLogger(r,t,e,n);return i?s.clearFormatters():s.setPattern("%Y-%m-%d %H:%M:%S.%e [%l] %v"),s}catch(o){console.error(o)}return null}function rp(r,t,e){switch(t){case 1:r.trace(e);break;case 2:r.debug(e);break;case 3:r.info(e);break;case 4:r.warn(e);break;case 5:r.error(e);break;case 0:break;default:throw new Error(`Invalid log level ${t}`)}}function ip(r,t){switch(t){case 1:r.setLevel(0);break;case 2:r.setLevel(1);break;case 3:r.setLevel(2);break;case 4:r.setLevel(3);break;case 5:r.setLevel(4);break;case 0:r.setLevel(6);break;default:throw new Error(`Invalid log level ${t}`)}}var Zo=class extends ii{constructor(e,n,i,o,s){super();this.buffer=[];this.setLevel(s),this._loggerCreationPromise=this._createSpdLogLogger(e,n,i,o),this._register(this.onDidChangeLogLevel(a=>{this._logger&&ip(this._logger,a)}))}async _createSpdLogLogger(e,n,i,o){let s=i?6:1,a=30/s*uo.MB,l=await Rm(e,n,a,s,o);if(l){this._logger=l,ip(this._logger,this.getLevel());for(let{level:c,message:d}of this.buffer)rp(this._logger,c,d);this.buffer=[]}}log(e,n){this._logger?rp(this._logger,e,n):this.getLevel()<=e&&this.buffer.push({level:e,message:n})}flush(){this._logger?this.flushLogger():this._loggerCreationPromise.then(()=>this.flushLogger())}dispose(){this._logger?this.disposeLogger():this._loggerCreationPromise.then(()=>this.disposeLogger()),super.dispose()}flushLogger(){this._logger&&this._logger.flush()}disposeLogger(){this._logger&&(this._logger.drop(),this._logger=void 0)}};var es=class extends oi{doCreateLogger(t,e,n){return new Zo(ge(),t.fsPath,!n?.donotRotate,!!n?.donotUseFormatters,e)}};var ts=class{constructor(t,e){this.loggerService=t;this.getUriTransformer=e}listen(t,e){let n=this.getUriTransformer(t);switch(e){case"onDidChangeLoggers":return z.map(this.loggerService.onDidChangeLoggers,i=>({added:[...i.added].map(o=>this.transformLogger(o,n)),removed:[...i.removed].map(o=>this.transformLogger(o,n))}));case"onDidChangeVisibility":return z.map(this.loggerService.onDidChangeVisibility,i=>[n.transformOutgoingURI(i[0]),i[1]]);case"onDidChangeLogLevel":return z.map(this.loggerService.onDidChangeLogLevel,i=>Qa(i)?i:[n.transformOutgoingURI(i[0]),i[1]])}throw new Error(`Event not found: ${e}`)}async call(t,e,n){let i=this.getUriTransformer(t);switch(e){case"setLogLevel":return Qa(n[0])?this.loggerService.setLogLevel(n[0]):this.loggerService.setLogLevel(m.revive(i.transformIncoming(n[0][0])),n[0][1]);case"getRegisteredLoggers":return Promise.resolve([...this.loggerService.getRegisteredLoggers()].map(o=>this.transformLogger(o,i)))}throw new Error(`Call not found: ${e}`)}transformLogger(t,e){return{...t,resource:e.transformOutgoingURI(t.resource)}}};var op=new class{transformIncoming(r){return r}transformOutgoing(r){return r}transformOutgoingURI(r){return r}transformOutgoingScheme(r){return r}};var We,gl=globalThis.vscode;if(typeof gl<"u"&&typeof gl.context<"u"){let r=gl.context.configuration();if(r)We=r.product;else throw new Error("Sandbox: unable to resolve product configuration from preload script.")}else if(globalThis._VSCODE_PRODUCT_JSON&&globalThis._VSCODE_PACKAGE_JSON){if(We=globalThis._VSCODE_PRODUCT_JSON,Te.VSCODE_DEV&&Object.assign(We,{nameShort:`${We.nameShort} Dev`,nameLong:`${We.nameLong} Dev`,dataFolderName:`${We.dataFolderName}-dev`,serverDataFolderName:We.serverDataFolderName?`${We.serverDataFolderName}-dev`:void 0}),!We.version){let r=globalThis._VSCODE_PACKAGE_JSON;Object.assign(We,{version:r.version})}}else We={nameShort:"Code",nameLong:"Visual Studio Code",applicationName:"code",win32x64AppId:"{{EA457B21-F73E-494C-ACAB-524FDE069978}",win32arm64AppId:"{{A5270FC5-65AD-483E-AC30-2C276B63D0AC}",win32x64UserAppId:"{{771FD6B0-FA20-440A-A002-3B3BAC16DC50}",win32arm64UserAppId:"{{D9E514E7-1A56-452D-9337-2990C0DC4310}",win32NameVersion:"Microsoft Visual Studio Code",win32DirName:"Microsoft VS Code",win32SetupExeBasename:"VSCodeSetup",win32AppUserModelId:"Microsoft.VisualStudioCode",win32ShellNameShort:"Code",win32MutexName:"vscode",win32RegValueName:"VSCode",win32VersionedUpdate:!0,darwinCredits:"resources/darwin/Credits.rtf",darwinBundleIdentifier:"com.microsoft.VSCode",darwinProfileUUID:"EBAE60D6-C8A2-4419-92FF-24F8AD5077AB",darwinProfilePayloadUUID:"C6B5723A-6539-4F31-8A4E-3CC96E51F48C",darwinExecutable:"VSCode",linuxIconName:"vscode",licenseFileName:"LICENSE.rtf",licenseName:"Multiple, see https://code.visualstudio.com/license",serverGreeting:[],serverLicense:["*","* Visual Studio Code Server","*","* By using the software, you agree to","* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and","* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).","*"],serverLicensePrompt:"Do you accept the terms in the License Agreement (Y/n)?",serverApplicationName:"code-server",urlProtocol:"vscode",dataFolderName:".vscode",serverDataFolderName:".vscode-server",downloadUrl:"https://code.visualstudio.com",updateUrl:"https://update.code.visualstudio.com",webUrl:"https://vscode.dev",webEndpointUrl:"https://main.vscode-cdn.net",webEndpointUrlTemplate:"https://{{uuid}}.vscode-cdn.net/{{quality}}/{{commit}}",nlsCoreBaseUrl:"https://www.vscode-unpkg.net/nls/",webviewContentExternalBaseUrlTemplate:"https://{{uuid}}.vscode-cdn.net/{{quality}}/{{commit}}/out/vs/workbench/contrib/webview/browser/pre/",quality:"stable",embedded:{nameShort:"Agents",nameLong:"Visual Studio Code Agents",applicationName:"agents",telemetryAppName:"agents",win32AppUserModelId:"Microsoft.VisualStudioCodeAgents",win32MutexName:"vscodeagents",win32RegValueName:"VSCodeAgents",win32NameVersion:"Microsoft Visual Studio Code Agents",win32VersionedUpdate:!0,darwinBundleIdentifier:"com.microsoft.VSCodeAgents",dataFolderName:".vscode-agents",urlProtocol:"vscode-agents",inheritAuthAccountPreference:{"github.copilot":["github.copilot-chat"],"vscode.github":["github.copilot-chat"]}},extensionsGallery:{nlsBaseUrl:"https://www.vscode-unpkg.net/_lp/",serviceUrl:"https://marketplace.visualstudio.com/_apis/public/gallery",itemUrl:"https://marketplace.visualstudio.com/items",publisherUrl:"https://marketplace.visualstudio.com/publishers",resourceUrlTemplate:"https://{publisher}.vscode-unpkg.net/{publisher}/{name}/{version}/{path}",extensionUrlTemplate:"https://www.vscode-unpkg.net/_gallery/{publisher}/{name}/latest",controlUrl:"https://main.vscode-cdn.net/extensions/marketplace.json",mcpUrl:"https://main.vscode-cdn.net/mcp/servers.json",accessSKUs:["copilot_enterprise_seat","copilot_enterprise_seat_quota","copilot_enterprise_seat_multi_quota","copilot_enterprise_seat_assignment","copilot_enterprise_seat_assignment_quota","copilot_enterprise_seat_assignment_multi_quota","copilot_enterprise_trial_seat","copilot_enterprise_trial_seat_quota","copilot_for_business_seat","copilot_for_business_seat_quota","copilot_for_business_seat_multi_quota","copilot_for_business_seat_assignment","copilot_for_business_seat_assignment_quota","copilot_for_business_seat_assignment_multi_quota","copilot_for_business_trial_seat","copilot_for_business_trial_seat_quota"]},mcpGallery:{serviceUrl:"https://api.mcp.github.com",itemWebUrl:"https://github.com/mcp/{name}",publisherUrl:"https://github.com/{name}",supportUrl:"https://support.github.com",privacyPolicyUrl:"https://docs.github.com/site-policy/privacy-policies/github-general-privacy-statement",termsOfServiceUrl:"https://docs.github.com/site-policy/github-terms/github-terms-of-service",reportUrl:"https://docs.github.com/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam"},extensionProperties:{"github.copilot-chat":{hasPrereleaseVersion:!1,excludeVersionRange:"<=0.16.1"},"github.copilot":{hasPrereleaseVersion:!0}},extensionsForceVersionByQuality:["github.copilot-chat","github.copilot"],profileTemplatesUrl:"https://main.vscode-cdn.net/core/profile-templates.json",emergencyAlertUrl:"https://main.vscode-cdn.net/core/stable.json",extensionPublisherOrgs:["microsoft"],trustedExtensionPublishers:["microsoft","github","openai"],extensionRecommendations:{"ms-dotnettools.csdevkit":{onFileOpen:[{pathGlob:"{**/*.cs,**/global.json,**/*.csproj,**/*.cshtml,**/*.sln}",important:!0},{languages:["csharp"],important:!0},{pathGlob:"{**/project.json,**/appsettings.json}"}]},"ms-python.python":{onFileOpen:[{pathGlob:"{**/*.py}",important:!0},{languages:["python"],important:!0},{pathGlob:"{**/*.ipynb}"}]},"ms-toolsai.jupyter":{onFileOpen:[{pathGlob:"{**/*.py}",contentPattern:"^#\\s*%%$",important:!0,whenInstalled:["ms-python.python"]},{pathGlob:"{**/*.ipynb}"}]},"ms-toolsai.datawrangler":{onFileOpen:[{pathGlob:"{**/*.ipynb}",contentPattern:"import\\s*pandas|from\\s*pandas",whenInstalled:["ms-toolsai.jupyter"]}]},"golang.Go":{onFileOpen:[{pathGlob:"**/*.go",important:!0},{languages:["go"],important:!0}]},"vscjava.vscode-java-pack":{onFileOpen:[{pathGlob:"{**/*.java}",important:!0,whenNotInstalled:["ASF.apache-netbeans-java","Oracle.oracle-java"]},{languages:["java"],important:!0,whenNotInstalled:["ASF.apache-netbeans-java","Oracle.oracle-java"]}]},"ms-vscode.PowerShell":{onFileOpen:[{pathGlob:"{**/*.ps1,**/*.psd1,**/*.psm1}",important:!0},{languages:["powershell"],important:!0},{pathGlob:"{**/*.ps.config,**/*.ps1.config}"}]},"ms-toolsai.prompty":{onFileOpen:[{pathGlob:"{**/*.prompty}",important:!1}]},"quantum.qsharp-lang-vscode":{onFileOpen:[{pathGlob:"{**/*.qs,**/*.qsc,**/*.qasm}",important:!0}]},"typespec.typespec-vscode":{onFileOpen:[{pathGlob:"{**/*.tsp,**/tspconfig.yaml}",important:!0}]},"ms-vscode.cpptools-extension-pack":{onFileOpen:[{pathGlob:"{**/*.c,**/*.cpp,**/*.cc,**/.cxx,**/*.hh,**/*.hpp,**/*.hxx,**/*.h}",important:!0,whenNotInstalled:["llvm-vs-code-extensions.vscode-clangd"]},{languages:["c","cpp"],important:!0,whenNotInstalled:["llvm-vs-code-extensions.vscode-clangd"]}]},"ms-azuretools.vscode-containers":{onFileOpen:[{pathGlob:"{**/dockerfile,**/Dockerfile,**/docker-compose.yml,**/docker-compose.*.yml}",important:!0,whenNotInstalled:["ms-azuretools.vscode-docker"]},{languages:["dockerfile"],important:!0,whenNotInstalled:["ms-azuretools.vscode-docker"]},{pathGlob:"{**/*.cs,**/project.json,**/global.json,**/*.csproj,**/*.cshtml,**/*.sln,**/appsettings.json,**/*.py,**/*.ipynb,**/*.js,**/*.ts,**/package.json}",whenNotInstalled:["ms-azuretools.vscode-docker"]}]},"vue.volar":{onFileOpen:[{pathGlob:"{**/*.vue}",important:!0},{languages:["vue"],important:!0}]},"ms-vscode.makefile-tools":{onFileOpen:[{pathGlob:"{**/makefile,**/Makefile}",important:!0},{languages:["makefile"],important:!0}]},"ms-vscode.cmake-tools":{onFileOpen:[{pathGlob:"{**/CMakeLists.txt}",important:!0}]},"ms-azure-devops.azure-pipelines":{onFileOpen:[{pathGlob:"{**/azure-pipelines.yaml}",important:!0}]},"msazurermtools.azurerm-vscode-tools":{onFileOpen:[{pathGlob:"{**/azuredeploy.json}",important:!0}]},"ms-vscode-remote.remote-containers":{onFileOpen:[{pathGlob:"{**/devcontainer.json}",important:!0}]},"ms-azuretools.vscode-bicep":{onFileOpen:[{pathGlob:"{**/*.bicep}",important:!0,whenNotInstalled:["ms-azuretools.rad-vscode-bicep"]}]},"svelte.svelte-vscode":{onFileOpen:[{pathGlob:"{**/*.svelte}",important:!0}]},"ms-vscode.vscode-github-issue-notebooks":{onFileOpen:[{pathGlob:"{**/*.github-issues}",important:!0}]},"ms-playwright.playwright":{onFileOpen:[{pathGlob:"{**/*playwright*.config.ts,**/*playwright*.config.js,**/*playwright*.config.mjs}",important:!0}]},"vscjava.vscode-gradle":{onFileOpen:[{pathGlob:"{**/gradlew,**/gradlew.bat,**/build.gradle,**/build.gradle.kts,**/settings.gradle,**/settings.gradle.kts}",important:!0}]},"REditorSupport.r":{onFileOpen:[{pathGlob:"{**/*.r}",important:!0},{languages:["r"],important:!0}]},"firefox-devtools.vscode-firefox-debug":{onFileOpen:[{pathGlob:"{**/*.ts,**/*.tsx,**/*.js,**/*.jsx,**/*.es6,**/.babelrc}"}]},"ms-edgedevtools.vscode-edge-devtools":{onFileOpen:[{pathGlob:"{**/*.ts,**/*.tsx,**/*.js,**/*.css,**/*.html}"}]},"Ionide.Ionide-fsharp":{onFileOpen:[{pathGlob:"{**/*.fsx,**/*.fsi,**/*.fs,**/*.ml,**/*.mli}"}]},"dbaeumer.vscode-eslint":{onFileOpen:[{pathGlob:"{**/*.js,**/*.jsx,**/*.es6,**/.eslintrc.*,**/.eslintrc,**/.babelrc,**/jsconfig.json}"}]},"bmewburn.vscode-intelephense-client":{onFileOpen:[{pathGlob:"{**/*.php,**/php.ini}"}]},"xdebug.php-debug":{onFileOpen:[{pathGlob:"{**/*.php,**/php.ini}"}]},"rust-lang.rust-analyzer":{onFileOpen:[{pathGlob:"{**/*.rs,**/*.rslib}"}]},"DavidAnson.vscode-markdownlint":{onFileOpen:[{pathGlob:"{**/*.md}"}]},"EditorConfig.EditorConfig":{onFileOpen:[{pathGlob:"{**/.editorconfig}"}]},"HookyQR.beautify":{onFileOpen:[{pathGlob:"{**/.jsbeautifyrc}"}]},"donjayamanne.githistory":{onFileOpen:[{pathGlob:"{**/.gitignore,**/.git}"}]},"eamodio.gitlens":{onFileOpen:[{pathGlob:"{**/.gitignore,**/.git}"}]},"Shopify.ruby-lsp":{onFileOpen:[{pathGlob:"{**/*.rb,**/*.erb,**/*.reek,**/.fasterer.yml,**/ruby-lint.yml,**/.rubocop.yml}"}]},"swiftlang.swift-vscode":{onFileOpen:[{pathGlob:"{**/*.swift,**/*.swiftinterface}",important:!0}]},"DotJoshJohnson.xml":{onFileOpen:[{pathGlob:"{**/*.xml}"}]},"stylelint.vscode-stylelint":{onFileOpen:[{pathGlob:"{**/.stylelintrc,**/stylelint.config.js}"}]},"ms-mssql.mssql":{onFileOpen:[{pathGlob:"{**/*.sql}"}]},"mtxr.sqltools":{onFileOpen:[{pathGlob:"{**/*.sql}"}]},"usqlextpublisher.usql-vscode-ext":{onFileOpen:[{pathGlob:"{**/*.usql}"}]},"ms-vscode.sublime-keybindings":{onFileOpen:[{pathGlob:"{**/.sublime-project,**/.sublime-workspace}"}]},"k--kato.intellij-idea-keybindings":{onFileOpen:[{pathGlob:"{**/.idea}"}]},"christian-kohler.npm-intellisense":{onFileOpen:[{pathGlob:"{**/package.json}"}]},"cake-build.cake-vscode":{onFileOpen:[{pathGlob:"{**/build.cake}"}]},"Angular.ng-template":{onFileOpen:[{pathGlob:"{**/.angular-cli.json,**/angular.json,**/*.ng.html,**/*.ng,**/*.ngml}"}]},"vscjava.vscode-maven":{onFileOpen:[{pathGlob:"**/pom.xml"}]},"ms-azuretools.vscode-azureterraform":{onFileOpen:[{pathGlob:"**/*.tf"}]},"HashiCorp.terraform":{onFileOpen:[{pathGlob:"**/*.tf"}]},"vsciot-vscode.vscode-arduino":{onFileOpen:[{pathGlob:"**/*.ino"}]},"ms-kubernetes-tools.vscode-kubernetes-tools":{onFileOpen:[{pathGlob:"{**/Chart.yaml}"}]},"Oracle.oracledevtools":{onFileOpen:[{pathGlob:"{**/*.sql}"}]},"betterthantomorrow.calva":{onFileOpen:[{pathGlob:"{**/*.clj,**/*.cljs}"}]},"vmware.vscode-boot-dev-pack":{onFileOpen:[{pathGlob:"{**/application.properties}"}]},"GitHub.copilot":{onFileOpen:[{pathGlob:"{**/*.ts,**/*.tsx,**/*.js,**/*.jsx,**/*.py,**/*.go,**/*.rb,**/*.html,**/*.css,**/*.php,**/*.cpp,**/*.vue,**/*.c,**/*.sql,**/*.java,**/*.cs,**/*.rs,**/*.dart,**/*.ps,**/*.ps1,**/*.tex}"}]},"GitHub.copilot-chat":{onSettingsEditorOpen:{descriptionOverride:"GitHub Copilot is an AI-powered coding assistant that helps you write code faster and smarter."}},"GitHub.vscode-github-actions":{onFileOpen:[{pathGlob:"{**/.github/workflows/*.yml}",important:!0}]},"circleci.circleci":{onFileOpen:[{pathGlob:"{**/.circleci/config.yml}"}]},"mechatroner.rainbow-csv":{onFileOpen:[{pathGlob:"**/*.csv",important:!0}]},"tomoki1207.pdf":{onFileOpen:[{pathGlob:"**/*.pdf",important:!0}]},"Redis.redis-for-vscode":{onFileOpen:[{pathGlob:"{**/redis.*,**/redis-server.*,**/redis_*,**/redisinsight.*}",important:!0}]},"SonarSource.sonarlint-vscode":{onFileOpen:[{pathGlob:"{**/sonar-project.properties,**/sonarcloud.properties,**/sonarlint.*}",important:!0}]}},keymapExtensionTips:["vscodevim.vim","ms-vscode.sublime-keybindings","ms-vscode.atom-keybindings","ms-vscode.brackets-keybindings","ms-vscode.vs-keybindings","ms-vscode.notepadplusplus-keybindings","k--kato.intellij-idea-keybindings","lfs.vscode-emacs-friendly","alphabotsec.vscode-eclipse-keybindings","alefragnani.delphi-keybindings"],languageExtensionTips:["ms-python.python","ms-vscode.cpptools-extension-pack","ms-dotnettools.csdevkit","ms-toolsai.jupyter","vscjava.vscode-java-pack","ecmel.vscode-html-css","vue.volar","bmewburn.vscode-intelephense-client","dsznajder.es7-react-js-snippets","golang.go","ms-vscode.powershell","dart-code.dart-code","rust-lang.rust-analyzer","Shopify.ruby-lsp","GitHub.copilot"],configBasedExtensionTips:{git:{configPath:".git/config",configName:"Git",recommendations:{"github.vscode-pull-request-github":{name:"GitHub Pull Request",contentPattern:"^\\s*url\\s*=\\s*https:\\/\\/github\\.com.*$"},"eamodio.gitlens":{name:"GitLens"}}},devContainer:{configPath:".devcontainer/devcontainer.json",configName:"Dev Container",recommendations:{"ms-vscode-remote.remote-containers":{name:"Dev Containers",important:!0}}},maven:{configPath:"pom.xml",configName:"Maven",recommendations:{"vscjava.vscode-java-pack":{name:"Java",important:!0,isExtensionPack:!0,whenNotInstalled:["ASF.apache-netbeans-java","Oracle.oracle-java"]},"vmware.vscode-boot-dev-pack":{name:"Spring Boot Extension Pack",isExtensionPack:!0}}},gradle:{configPath:"build.gradle",configName:"Gradle",recommendations:{"vscjava.vscode-java-pack":{name:"Java",important:!0,isExtensionPack:!0,whenNotInstalled:["ASF.apache-netbeans-java","Oracle.oracle-java"]}}},"github-pull-request":{configPath:".vscode/.github-pull-request.rec",configName:"GitHub",configScheme:"vscode-vfs",recommendations:{"github.vscode-pull-request-github":{name:"GitHub Pull Request",important:!0}}},"pyproject-formatter":{configPath:"pyproject.toml",configName:"Python Formatter",recommendations:{"ms-python.black-formatter":{name:"Black Formatter",contentPattern:'(^\\s*\\[\\[?\\s*"?tool"?\\s*\\.\\s*"?black"?\\s*[\\].])|("black\\s*["[(<=>!~;@])'},"ms-python.autopep8":{name:"Autopep8",contentPattern:'(^\\s*\\[\\[?\\s*"?tool"?\\s*\\.\\s*"?autopep8"?\\s*[\\].])|("autopep8\\s*["[(<=>!~;@])'}}},"pep8-formatter":{configPath:".pep8",configName:"Python Formatter",recommendations:{"ms-python.autopep8":{name:"Autopep8"}}},"python-setup-cgf-formatter":{configPath:"setup.cfg",configName:"Python Formatter",recommendations:{"ms-python.autopep8":{name:"Autopep8",contentPattern:"^\\[pep8\\]"}}},"tox-ini-formatter":{configPath:"tox.ini",configName:"Python Formatter",recommendations:{"ms-python.autopep8":{name:"Autopep8",contentPattern:"^\\[pep8\\]"}}},"pyproject-linter":{configPath:"pyproject.toml",configName:"Python Linter",recommendations:{"ms-python.pylint":{name:"Pylint",contentPattern:'(^\\s*\\[\\[?\\s*"?tool"?\\s*\\.\\s*"?pylint"?\\s*[\\].])|("pylint\\s*["[(<=>!~;@])'},"charliermarsh.ruff":{name:"Ruff",contentPattern:'(^\\s*\\[\\[?\\s*"?tool"?\\s*\\.\\s*"?ruff"?\\s*[\\].])|("ruff\\s*["[(<=>!~;@])'},"ms-python.mypy-type-checker":{name:"Mypy Type Checker",contentPattern:'(^\\s*\\[\\[?\\s*"?tool"?\\s*\\.\\s*"?mypy"?\\s*[\\].])|("mypy\\s*["[(<=>!~;@])'},"ms-python.flake8":{name:"Flake8",contentPattern:'(^\\s*\\[\\[?\\s*"?tool"?\\s*\\.\\s*"?flake8"?\\s*[\\].])|("flake8\\s*["[(<=>!~;@])'}}},".pylintrc-linter":{configPath:".pylintrc",configName:"Python Linter",recommendations:{"ms-python.pylint":{name:"Pylint"}}},"pylintrc-linter":{configPath:"pylintrc",configName:"Python Linter",recommendations:{"ms-python.pylint":{name:"Pylint"}}},"mypy-ini-linter":{configPath:".mypy.ini",configName:"Python Linter",recommendations:{"ms-python.mypy-type-checker":{name:"Mypy Type Checker"}}},"tox-ini-linter":{configPath:"tox.ini",configName:"Python Linter",recommendations:{"ms-python.flake8":{name:"Flake8",contentPattern:"^\\[flake8\\]"}}},".flake8-linter":{configPath:".flake8",configName:"Python Linter",recommendations:{"ms-python.flake8":{name:"Flake8"}}},"python-setup-cgf-linter":{configPath:"setup.cfg",configName:"Python Linter",recommendations:{"ms-python.flake8":{name:"Flake8",contentPattern:"^\\[flake8\\]"}}}},exeBasedExtensionTips:{az:{friendlyName:"Azure CLI",windowsPath:"%ProgramFiles(x86)%\\Microsoft SDKs\\Azure\\CLI2\\wbin\\az.cmd",recommendations:{"ms-vscode.vscode-node-azure-pack":{name:"Azure Tools"},"ms-azuretools.vscode-azure-github-copilot":{name:"GitHub Copilot for Azure"}}},azd:{friendlyName:"Azure Dev CLI",windowsPath:"%USERPROFILE%\\AppData\\Local\\Programs\\Azure Dev CLI\\azd.exe",recommendations:{"ms-vscode.vscode-node-azure-pack":{name:"Azure Tools"},"ms-azuretools.vscode-azure-github-copilot":{name:"GitHub Copilot for Azure"}}},"azd-user":{friendlyName:"Azure Dev CLI",windowsPath:"%ProgramFiles%\\Azure Dev CLI\\azd.exe",recommendations:{"ms-vscode.vscode-node-azure-pack":{name:"Azure Tools"},"ms-azuretools.vscode-azure-github-copilot":{name:"GitHub Copilot for Azure"}}},"azure-powershell":{friendlyName:"Azure PowerShell",windowsPath:"%USERPROFILE%\\.Azure",recommendations:{"ms-vscode.vscode-node-azure-pack":{name:"Azure Tools"}}},heroku:{friendlyName:"Heroku CLI",windowsPath:"%ProgramFiles%\\Heroku\\bin\\heroku.cmd",recommendations:{"ms-azuretools.vscode-azureappservice":{name:"Azure App Service"},"pkosta2005.heroku-command":{name:"heroku-cli"}}},mongo:{friendlyName:"Mongo",windowsPath:"%ProgramFiles%\\MongoDB\\Server\\3.6\\bin\\mongod.exe",recommendations:{"ms-azuretools.vscode-cosmosdb":{name:"Azure Databases"}}},serverless:{friendlyName:"Serverless framework",windowsPath:"%APPDATA%\\npm\\serverless.cmd",recommendations:{"ms-azuretools.vscode-azurefunctions":{name:"Azure Functions"}}},func:{friendlyName:"Azure Function SDK",windowsPath:"%APPDATA%\\npm\\func.cmd",recommendations:{"ms-azuretools.vscode-azurefunctions":{name:"Azure Functions"}}},mysql:{friendlyName:"MySQL",windowsPath:"%ProgramFiles%\\MySQL\\MySQL Server 8.0\\bin\\mysqld.exe",recommendations:{"mtxr.sqltools":{name:"SQLTools"}}},postgres:{friendlyName:"PostgreSQL",windowsPath:"%ProgramFiles%\\PostgreSQL\\11\\bin\\psql.exe",recommendations:{"ms-ossdata.vscode-postgresql":{name:"PostgreSQL"},"mtxr.sqltools":{name:"SQLTools"}}},sqlcmd:{friendlyName:"SQL CLI",recommendations:{"ms-mssql.mssql":{name:"SQL Server (mssql)"}}},now:{friendlyName:"Now CLI",windowsPath:"%APPDATA%\\npm\\now.cmd",recommendations:{"ms-azuretools.vscode-azureappservice":{name:"Azure App Service"},"ms-azuretools.vscode-containers":{name:"Docker"}}},docker:{friendlyName:"Docker",windowsPath:"%ProgramFiles%\\Docker\\Docker\\Resources\\bin\\docker.exe",recommendations:{"ms-azuretools.vscode-containers":{name:"Docker",important:!0,whenNotInstalled:["ms-azuretools.vscode-docker"]},"ms-vscode-remote.remote-containers":{name:"Dev Containers",important:!0},"ms-kubernetes-tools.vscode-kubernetes-tools":{name:"Kubernetes"}}},kubectl:{friendlyName:"Kubernetes",windowsPath:"%ProgramFiles%\\Docker\\Docker\\Resources\\bin\\kubectl.exe",recommendations:{"ms-azuretools.vscode-containers":{name:"Docker"},"ms-kubernetes-tools.vscode-kubernetes-tools":{name:"Kubernetes"},"ms-vscode-remote.remote-containers":{name:"Dev Containers"}}},ng:{friendlyName:"Angular CLI",windowsPath:"%APPDATA%\\npmexit\\ng.cmd",recommendations:{"johnpapa.Angular2":{name:"Angular Snippets"}}},"create-react-app":{friendlyName:"Create React App",windowsPath:"%APPDATA%\\npm\\create-react-app.cmd",recommendations:{"msjsdiag.vscode-react-native":{name:"React Native Tools"}}},"react-native":{friendlyName:"React Native",windowsPath:"%APPDATA%\\npm\\react-native-cli",recommendations:{"msjsdiag.vscode-react-native":{name:"React Native Tools"}}},p4:{friendlyName:"Perforce",recommendations:{"slevesque.perforce":{name:"Perforce for VS Code"}}},hg:{friendlyName:"Mercurial",recommendations:{"mrcrowl.hg":{name:"Hg"}}},git:{friendlyName:"Git",windowsPath:"%ProgramFiles%\\Git\\git-bash.exe",recommendations:{"eamodio.gitlens":{name:"GitLens"}}},svn:{friendlyName:"Subversion",windowsPath:"%ProgramFiles%\\TortoiseSVN\\bin\\TortoiseProc.exe",recommendations:{"johnstoncode.svn-scm":{name:"SVN"}}},subl:{friendlyName:"Sublime",windowsPath:"%ProgramFiles%\\Sublime Text3\\sublime_text.exe",recommendations:{"ms-vscode.sublime-keybindings":{name:"Sublime Text Keymap and Settings Importer"}}},atom:{friendlyName:"Atom",windowsPath:"%USERPROFILE%\\AppData\\Local\\atom\\bin\\atom.cmd",recommendations:{"ms-vscode.atom-keybindings":{name:"Atom Keymap"}}},brackets:{friendlyName:"Brackets",windowsPath:"%ProgramFiles(x86)%\\Brackets\\Brackets.exe",recommendations:{"ms-vscode.brackets-keybindings":{name:"Brackets Keymap"}}},notepadplusplus:{friendlyName:"Notepad++",windowsPath:"%ProgramFiles%\\Notepad++\\Notepad++.exe",recommendations:{"ms-vscode.notepadplusplus-keybindings":{name:"Notepad++ keymap"}}},vi:{friendlyName:"VIM",windowsPath:"%ProgramFiles(x86)%\\Vim\\vim80\\gvim.exe",recommendations:{"vscodevim.vim":{name:"Vim"}}},mvn:{friendlyName:"Maven",recommendations:{"vscjava.vscode-java-pack":{name:"Java",important:!0,isExtensionPack:!0,whenNotInstalled:["ASF.apache-netbeans-java","Oracle.oracle-java"]}}},gradle:{friendlyName:"Gradle",recommendations:{"vscjava.vscode-java-pack":{name:"Java",important:!0,isExtensionPack:!0,whenNotInstalled:["ASF.apache-netbeans-java","Oracle.oracle-java"]}}},ollama:{friendlyName:"Ollama",windowsPath:"%USERPROFILE%\\AppData\\Local\\Programs\\Ollama\\ollama.exe",recommendations:{"ms-windows-ai-studio.windows-ai-studio":{name:"AI Toolkit for Visual Studio Code"}}},"Microsoft Edge":{friendlyName:"Microsoft Edge",windowsPath:"%USERPROFILE%\\AppData\\Local\\Microsoft\\Edge\\Application\\msedge.exe",recommendations:{"ms-edgedevtools.vscode-edge-devtools":{name:"Microsoft Edge Developer Tools"}}},"Microsoft Edge Dev":{friendlyName:"Microsoft Edge Dev",windowsPath:"%USERPROFILE%\\AppData\\Local\\Microsoft\\Edge Dev\\Application\\msedge.exe",recommendations:{"ms-edgedevtools.vscode-edge-devtools":{name:"Microsoft Edge Developer Tools"}}},"Microsoft Edge Beta":{friendlyName:"Microsoft Edge Beta",windowsPath:"%USERPROFILE%\\AppData\\Local\\Microsoft\\Edge Beta\\Application\\msedge.exe",recommendations:{"ms-edgedevtools.vscode-edge-devtools":{name:"Microsoft Edge Developer Tools"}}},"Microsoft Edge Canary":{friendlyName:"Microsoft Edge Canary",windowsPath:"%USERPROFILE%\\AppData\\Local\\Microsoft\\Edge SxS\\Application\\msedge.exe",recommendations:{"ms-edgedevtools.vscode-edge-devtools":{name:"Microsoft Edge Developer Tools"}}},"Mozilla Firefox (x86)":{friendlyName:"Mozilla Firefox",windowsPath:"%ProgramFiles(x86)%\\Mozilla Firefox\\firefox.exe",recommendations:{"firefox-devtools.vscode-firefox-debug":{name:"Debugger for Firefox"}}},"Mozilla Firefox Developer Edition (x86)":{friendlyName:"Mozilla Firefox Developer Edition",windowsPath:"%ProgramFiles(x86)%\\Firefox Developer Edition\\firefox.exe",recommendations:{"firefox-devtools.vscode-firefox-debug":{name:"Debugger for Firefox"}}},"Mozilla Firefox":{friendlyName:"Mozilla Firefox",windowsPath:"%ProgramFiles%\\Mozilla Firefox\\firefox.exe",recommendations:{"firefox-devtools.vscode-firefox-debug":{name:"Debugger for Firefox"}}},"Mozilla Firefox Developer Edition":{friendlyName:"Mozilla Firefox Developer Edition",windowsPath:"%ProgramFiles%\\Firefox Developer Edition\\firefox.exe",recommendations:{"firefox-devtools.vscode-firefox-debug":{name:"Debugger for Firefox"}}},cordova:{friendlyName:"Cordova",windowsPath:"%APPDATA%\\npm\\cordova",recommendations:{"msjsdiag.cordova-tools":{name:"Cordova Tools"}}},gcloud:{friendlyName:"Google GCloud CLI",windowsPath:"%ProgramFiles(x86)%\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\gcloud.cmd",recommendations:{"GoogleCloudTools.cloudcode":{name:"Cloud Code"}}},skaffold:{friendlyName:"Skaffold Code to Cluster",recommendations:{"ms-azuretools.vscode-containers":{name:"Docker"},"ms-kubernetes-tools.vscode-kubernetes-tools":{name:"Kubernetes"}}},minikube:{friendlyName:"MiniKube Local Kubernetes Cluster",recommendations:{"ms-azuretools.vscode-containers":{name:"Docker"},"ms-kubernetes-tools.vscode-kubernetes-tools":{name:"Kubernetes"},"ms-vscode-remote.remote-containers":{name:"Dev Containers"}}},podman:{friendlyName:"Podman",recommendations:{"ms-vscode-remote.remote-containers":{name:"Dev Containers"}}},wsl:{friendlyName:"Windows Subsystem for Linux (WSL)",windowsPath:"%WINDIR%\\system32\\lxss\\LxssManager.dll",recommendations:{"ms-vscode-remote.remote-wsl":{name:"WSL"}}}},webExtensionTips:["tyriar.luna-paint","codespaces-contrib.codeswing","ms-vscode.vscode-github-issue-notebooks","esbenp.prettier-vscode","hediet.vscode-drawio"],virtualWorkspaceExtensionTips:{"vscode-vfs":{friendlyName:"Remote Repositories",extensionId:"ms-vscode.remote-repositories",startEntry:{helpLink:"https://aka.ms/vscode-remote/remote-repositories",startConnectLabel:"Remote Repository",startCommand:"remoteHub.continueOn.openRepository",priority:5}}},remoteExtensionTips:{wsl:{friendlyName:"WSL",extensionId:"ms-vscode-remote.remote-wsl",supportedPlatforms:["Windows","Web"],startEntry:{helpLink:"https://aka.ms/vscode-remote/wsl",startConnectLabel:"WSL",startCommand:"remote-wsl.connect",priority:3}},"ssh-remote":{friendlyName:"Remote - SSH",extensionId:"ms-vscode-remote.remote-ssh",supportedPlatforms:["Windows","Linux","Mac"],startEntry:{helpLink:"https://aka.ms/vscode-remote/ssh",startConnectLabel:"SSH ",startCommand:"opensshremotes.openEmptyWindowInCurrentWindow",priority:1}},"dev-container":{friendlyName:"Dev Containers",extensionId:"ms-vscode-remote.remote-containers",supportedPlatforms:["Windows","Linux","Mac"],startEntry:{helpLink:"https://aka.ms/vscode-remote/containers",startConnectLabel:"Dev Container",startCommand:"remote-containers.reopenInContainer",priority:2}},"attached-container":{friendlyName:"Dev Containers",extensionId:"ms-vscode-remote.remote-containers"},codespaces:{friendlyName:"GitHub Codespaces",extensionId:"github.codespaces",startEntry:{helpLink:"https://aka.ms/vscode-remote-codespaces",startConnectLabel:"GitHub Codespace ",startCommand:"github.codespaces.connect",priority:4}},tunnel:{friendlyName:"Remote - Tunnels",extensionId:"ms-vscode.remote-server",startEntry:{helpLink:"https://aka.ms/remote-tunnels-doc",startConnectLabel:"Tunnel",startCommand:"remote-tunnels.connectCurrentWindowToTunnel",priority:0}},amlext:{friendlyName:"Azure Machine Learning",extensionId:"ms-toolsai.vscode-ai-remote"}},commandPaletteSuggestedCommandIds:["workbench.action.files.openFile","workbench.action.files.openFileFolder","workbench.action.files.openFolder","workbench.action.remote.showMenu","editor.action.formatDocument","editor.action.commentLine","workbench.action.tasks.runTask","workbench.action.openSettings2","workbench.action.selectTheme","workbench.action.openWalkthrough","workbench.action.openIssueReporter"],extensionKeywords:{md:["Markdown"],js:["JavaScript"],jsx:["JavaScript"],es6:["JavaScript"],html:["Html"],ts:["TypeScript"],tsx:["TypeScript"],css:["CSS"],scss:["SASS"],txt:["Text"],php:["PHP"],php3:["PHP"],php4:["PHP"],ph3:["PHP"],ph4:["PHP"],xml:["XML"],py:["Python"],pyc:["Python"],pyd:["Python"],pyo:["Python"],pyw:["Python"],pyz:["Python"],java:["Java"],class:["Java"],jar:["Java"],c:["c","objective c","objective-c"],m:["objective c","objective-c"],mm:["objective c","objective-c"],cpp:["cpp","c plus plus","c","c++"],cc:["cpp","c plus plus","c","c++"],cxx:["cpp","c plus plus","c++"],hh:["cpp","c plus plus","c++"],hpp:["cpp","c++"],h:["cpp","c plus plus","c++","c","objective c","objective-c"],sql:["sql"],sh:["bash"],bash:["bash"],zsh:["bash","zshell"],cs:["c#","csharp"],csproj:["c#","csharp"],sln:["c#","csharp"],go:["go"],sty:["latex"],tex:["latex"],ps:["powershell"],ps1:["powershell"],rs:["rust"],rslib:["rust"],hs:["haskell"],lhs:["haskell"],scm:["scheme"],ss:["scheme"],clj:["clojure"],cljs:["clojure"],cljc:["clojure"],edn:["clojure"],erl:["erlang"],hrl:["erlang"],scala:["scala"],sc:["scala"],pl:["perl"],pm:["perl"],t:["perl"],pod:["perl"],groovy:["groovy"],swift:["swift"],rb:["ruby"],rbw:["ruby"],jl:["julia"],f:["fortran"],for:["fortran"],f90:["fortran"],f95:["fortran"],coffee:["CoffeeScript"],litcoffee:["CoffeeScript"],yaml:["yaml"],yml:["yaml"],dart:["dart"],json:["json"]},extensionAllowedBadgeProviders:["api.travis-ci.com","app.fossa.io","badge.buildkite.com","badge.fury.io","badgen.net","badges.frapsoft.com","badges.gitter.im","cdn.travis-ci.com","ci.appveyor.com","circleci.com","cla.opensource.microsoft.com","codacy.com","codeclimate.com","codecov.io","coveralls.io","david-dm.org","deepscan.io","dev.azure.com","docs.rs","flat.badgen.net","gitlab.com","godoc.org","goreportcard.com","img.shields.io","isitmaintained.com","marketplace.visualstudio.com","nodesecurity.io","opencollective.com","snyk.io","travis-ci.com","travis-ci.org","visualstudio.com","vsmarketplacebadge.apphb.com"],extensionAllowedBadgeProvidersRegex:["^https:\\/\\/github\\.com\\/[^/]+\\/[^/]+\\/(actions\\/)?workflows\\/.*badge\\.svg"],crashReporter:{productName:"VSCode",companyName:"Microsoft"},appCenter:{"win32-x64":"appcenter://code?aid=a4e3233c-699c-46ec-b4f4-9c2a77254662","win32-arm64":"appcenter://code?aid=3712d786-7cc8-4f11-8b08-cc12eab6d4f7","linux-x64":"appcenter://code?aid=fba07a4d-84bd-4fc8-a125-9640fc8ce171",darwin:"appcenter://code?aid=860d6632-f65b-490b-85a8-3e72944f7774","darwin-arm64":"appcenter://code?aid=be71415d-3893-4ae5-b453-e537b9668a10","darwin-universal":"appcenter://code?aid=de75e3cc-e22f-4f42-a03f-1409c21d8af8"},enableTelemetry:!0,aiConfig:{ariaKey:"5bbf946d11a54f6783919c455abaddaf-fd62977b-c92d-4714-a45d-649d06980372-7168"},msftInternalDomains:["redmond.corp.microsoft.com","northamerica.corp.microsoft.com","fareast.corp.microsoft.com","ntdev.corp.microsoft.com","wingroup.corp.microsoft.com","southpacific.corp.microsoft.com","wingroup.windeploy.ntdev.microsoft.com","ddnet.microsoft.com","europe.corp.microsoft.com"],documentationUrl:"https://go.microsoft.com/fwlink/?LinkID=533484#vscode",serverDocumentationUrl:"https://aka.ms/vscode-server-doc",releaseNotesUrl:"https://go.microsoft.com/fwlink/?LinkID=533483#vscode",keyboardShortcutsUrlMac:"https://go.microsoft.com/fwlink/?linkid=832143",keyboardShortcutsUrlLinux:"https://go.microsoft.com/fwlink/?linkid=832144",keyboardShortcutsUrlWin:"https://go.microsoft.com/fwlink/?linkid=832145",introductoryVideosUrl:"https://go.microsoft.com/fwlink/?linkid=832146",tipsAndTricksUrl:"https://go.microsoft.com/fwlink/?linkid=852118",newsletterSignupUrl:"https://www.research.net/r/vsc-newsletter",youTubeUrl:"https://aka.ms/vscode-youtube",requestFeatureUrl:"https://go.microsoft.com/fwlink/?LinkID=533482",reportIssueUrl:"https://github.com/Microsoft/vscode/issues/new",reportMarketplaceIssueUrl:"https://github.com/microsoft/vsmarketplace/issues/new",licenseUrl:"https://go.microsoft.com/fwlink/?LinkID=533485",serverLicenseUrl:"https://aka.ms/vscode-server-license",privacyStatementUrl:"https://go.microsoft.com/fwlink/?LinkId=521839",showTelemetryOptOut:!0,npsSurveyUrl:"https://aka.ms/vscode-nps",checksumFailMoreInfoUrl:"https://go.microsoft.com/fwlink/?LinkId=828886",electronRepository:"Microsoft/vscode-electron-prebuilt",nodejsRepository:"Microsoft/vscode-node",settingsSearchUrl:"https://bingsettingssearch.trafficmanager.net/api/Search",surveys:[{surveyId:"cpp.1",surveyUrl:"https://www.research.net/r/VBVV6C6",languageId:"cpp",editCount:10,userProbability:.15},{surveyId:"java.2",surveyUrl:"https://www.research.net/r/vscodejava",languageId:"java",editCount:10,userProbability:.3},{surveyId:"javascript.1",surveyUrl:"https://www.research.net/r/vscode-js",languageId:"javascript",editCount:10,userProbability:.05},{surveyId:"typescript.1",surveyUrl:"https://www.research.net/r/vscode-ts",languageId:"typescript",editCount:10,userProbability:.05},{surveyId:"csharp.1",surveyUrl:"https://www.research.net/r/8KGJ9V8",languageId:"csharp",editCount:10,userProbability:.1}],extensionsEnabledWithApiProposalVersion:["GitHub.copilot-chat","ms-vscode.vscode-commander","ms-vscode.vscode-copilot-vision","GitHub.vscode-pull-request-github"],extensionEnabledApiProposals:{"mrleemurray.theme-2026":["css"],"ms-azuretools.vscode-containers":["authenticationChallenges"],"ms-azuretools.vscode-azureresourcegroups":["authenticationChallenges"],"ms-azuretools.vscode-azure-github-copilot":["authenticationChallenges"],"ms-azuretools.vscode-dev-azurecloudshell":["contribEditSessions","authenticationChallenges"],"ms-toolsai.vscode-ai":["authenticationChallenges"],"TeamsDevApp.vscode-ai-foundry":["authenticationChallenges"],"ms-vscode.vscode-selfhost-test-provider":["testObserver","testRelatedCode"],"VisualStudioExptTeam.vscodeintellicode-completions":["inlineCompletionsAdditions"],"ms-vsliveshare.vsliveshare":["contribMenuBarHome","contribShareMenu","contribStatusBarItems","diffCommand","documentFiltersExclusive","fileSearchProvider","findTextInFiles","notebookLiveShare","terminalDimensions","terminalDataWriteEvent","textSearchProvider"],"ms-vscode.js-debug":["portsAttributes","findTextInFiles","workspaceTrust","tunnels","browser"],"ms-toolsai.vscode-ai-remote":["resolvers","authenticationChallenges"],"ms-python.python":["codeActionAI","contribEditorContentMenu","quickPickSortByLabel","portsAttributes","testObserver","quickPickItemTooltip","terminalDataWriteEvent","terminalExecuteCommandEvent","notebookReplDocument","notebookVariableProvider","terminalShellEnv"],"ms-python.vscode-python-envs":["terminalShellEnv","terminalDataWriteEvent","taskExecutionTerminal"],"ms-dotnettools.dotnet-interactive-vscode":["notebookMessaging"],"GitHub.codespaces":["contribEditSessions","contribMenuBarHome","contribRemoteHelp","contribViewsRemote","resolvers","tunnels","terminalDataWriteEvent","treeViewReveal","notebookKernelSource"],"ms-vscode.azure-repos":["extensionRuntime","fileSearchProvider","textSearchProvider"],"ms-vscode.remote-repositories":["canonicalUriProvider","contribEditSessions","contribRemoteHelp","contribMenuBarHome","contribViewsRemote","contribViewsWelcome","contribShareMenu","documentFiltersExclusive","editSessionIdentityProvider","extensionRuntime","fileSearchProvider","quickPickSortByLabel","workspaceTrust","shareProvider","scmActionButton","scmSelectedProvider","scmValidation","textSearchProvider","timeline"],"ms-vscode-remote.remote-wsl":["resolvers","contribRemoteHelp","contribViewsRemote","telemetry"],"ms-vscode-remote.remote-ssh":["resolvers","tunnels","terminalDataWriteEvent","contribRemoteHelp","contribViewsRemote","telemetry"],"ms-vscode.remote-server":["resolvers","tunnels","contribViewsWelcome"],"ms-vscode.remote-explorer":["contribRemoteHelp","contribViewsRemote","extensionsAny"],"ms-vscode-remote.remote-containers":["contribEditSessions","resolvers","portsAttributes","tunnels","workspaceTrust","terminalDimensions","contribRemoteHelp","contribViewsRemote"],"ms-vscode.js-debug-nightly":["portsAttributes","findTextInFiles","workspaceTrust","tunnels","browser"],"ms-vscode.lsif-browser":["documentFiltersExclusive"],"ms-vscode.vscode-speech":["speech"],"GitHub.vscode-pull-request-github":["activeComment","chatContextProvider","chatParticipantAdditions","chatParticipantPrivate","chatSessionsProvider","codiconDecoration","codeActionRanges","commentingRangeHint","commentReactor","commentReveal","commentsDraftState","commentThreadApplicability","contribAccessibilityHelpContent","contribCommentEditorActionsMenu","contribCommentPeekContext","contribCommentThreadAdditionalMenu","contribCommentsViewThreadMenus","contribEditorContentMenu","contribMultiDiffEditorMenus","contribShareMenu","diffCommand","languageModelToolResultAudience","markdownAlertSyntax","quickDiffProvider","remoteCodingAgents","shareProvider","tabInputMultiDiff","tabInputTextMerge","tokenInformation","treeItemMarkdownLabel","treeViewMarkdownMessage"],"GitHub.copilot":["inlineCompletionsAdditions","devDeviceId"],"GitHub.copilot-nightly":["inlineCompletionsAdditions","devDeviceId"],"GitHub.copilot-chat":["agentSessionsWorkspace","interactive","terminalDataWriteEvent","terminalExecuteCommandEvent","terminalSelection","terminalQuickFixProvider","chatParticipantAdditions","defaultChatParticipant","embeddings","chatProvider","mappedEditsProvider","aiRelatedInformation","aiSettingsSearch","codeActionAI","findTextInFiles","findTextInFiles2","textSearchProvider","textSearchProvider2","activeComment","commentReveal","contribSourceControlInputBoxMenu","contribCommentEditorActionsMenu","contribCommentThreadAdditionalMenu","contribCommentsViewThreadMenus","contribChatEditorInlineGutterMenu","extensionAffinity","newSymbolNamesProvider","findFiles2","chatReferenceDiagnostic","extensionsAny","authLearnMore","testObserver","aiTextSearchProvider","documentFiltersExclusive","chatParticipantPrivate","contribDebugCreateConfiguration","inlineCompletionsAdditions","chatReferenceBinaryData","languageModelSystem","languageModelCapabilities","languageModelThinkingPart","languageModelToolSupportsModel","chatStatusItem","taskProblemMatcherStatus","contribLanguageModelToolSets","textDocumentChangeReason","resolvers","taskExecutionTerminal","dataChannels","chatSessionsProvider","chatSessionCustomizationProvider","devDeviceId","contribEditorContentMenu","tokenInformation","toolInvocationApproveCombination","chatPromptFiles","mcpServerDefinitions","tabInputMultiDiff","workspaceTrust","chatHooks","chatDebug","environmentPower","terminalTitle"],"GitHub.remotehub":["contribRemoteHelp","contribMenuBarHome","contribViewsRemote","contribViewsWelcome","documentFiltersExclusive","extensionRuntime","fileSearchProvider","quickPickSortByLabel","workspaceTrust","scmSelectedProvider","scmValidation","textSearchProvider","timeline"],"ms-python.vscode-pylance":["terminalShellEnv","portsAttributes","codeActionAI"],"ms-python.debugpy":["contribViewsWelcome","debugVisualization","portsAttributes"],"ms-toolsai.jupyter-renderers":["contribNotebookStaticPreloads"],"ms-toolsai.jupyter":["notebookDeprecated","notebookMessaging","notebookMime","portsAttributes","quickPickSortByLabel","notebookKernelSource","interactiveWindow","notebookControllerAffinityHidden","contribNotebookStaticPreloads","quickPickItemTooltip","notebookExecution","notebookCellExecution","notebookVariableProvider","notebookReplDocument"],"donjayamanne.kusto":["notebookVariableProvider"],"ms-toolsai.tensorboard":["portsAttributes"],"dbaeumer.vscode-eslint":[],"ms-vscode.azure-sphere-tools-ui":["tunnels"],"ms-azuretools.vscode-azureappservice":["terminalDataWriteEvent"],"ms-vscode.anycode":["extensionsAny"],"ms-vscode.cpptools":["terminalDataWriteEvent","chatParticipantAdditions"],"vscjava.vscode-java-pack":[],"ms-dotnettools.csdevkit":["inlineCompletionsAdditions"],"ms-dotnettools.vscodeintellicode-csharp":["inlineCompletionsAdditions"],"ms-dotnettools.vscode-dotnet-modernize":["chatParticipantAdditions","chatPromptFiles"],"microsoft-IsvExpTools.powerplatform-vscode":["fileSearchProvider","textSearchProvider"],"microsoft-IsvExpTools.powerplatform-vscode-preview":["fileSearchProvider","textSearchProvider"],"TeamsDevApp.ms-teams-vscode-extension":["chatParticipantAdditions","languageModelSystem","mcpServerDefinitions"],"ms-toolsai.datawrangler":[],"ms-vscode.vscode-commander":[],"ms-vscode.vscode-websearchforcopilot":[],"ms-vscode.vscode-copilot-vision":["chatReferenceBinaryData","codeActionAI"],"ms-autodev.vscode-autodev":["chatParticipantAdditions"],"vscjava.migrate-java-to-azure":["chatParticipantAdditions","chatParticipantPrivate"],"vscjava.vscode-java-upgrade":["chatParticipantAdditions","chatParticipantPrivate"],"FoundryLocal.foundry-local-chat":["chatProvider"],"Microsoft.foundry-local-chat":["chatProvider"],"ms-wmcp.windows-mcp-server-extension":["mcpToolDefinitions"],"openai.chatgpt":["languageModelProxy","chatSessionsProvider"],"TypeScriptTeam.native-preview":["editorHoverVerbosityLevel","multiDocumentHighlightProvider"],"ms-vscode.vscode-eng-codereview":["chatContextProvider"]},tasConfig:{endpoint:"https://default.exp-tas.com/vscode/ab",telemetryEventName:"query-expfeature",assignmentContextTelemetryPropertyName:"abexp.assignmentcontext"},extensionKind:{"Shan.code-settings-sync":["ui"],"shalldie.background":["ui"],"techer.open-in-browser":["ui"],"CoenraadS.bracket-pair-colorizer-2":["ui"],"CoenraadS.bracket-pair-colorizer":["ui","workspace"],"hiro-sun.vscode-emacs":["ui","workspace"],"hnw.vscode-auto-open-markdown-preview":["ui","workspace"],"wayou.vscode-todo-highlight":["ui","workspace"],"aaron-bond.better-comments":["ui","workspace"],"vscodevim.vim":["ui"],"ollyhayes.colmak-vim":["ui"]},extensionPointExtensionKind:{typescriptServerPlugins:["workspace"]},extensionSyncedKeys:{"ritwickdey.liveserver":["liveServer.setup.version"]},extensionVirtualWorkspacesSupport:{"esbenp.prettier-vscode":{default:!1},"msjsdiag.debugger-for-chrome":{default:!1},"redhat.java":{default:!1},"HookyQR.beautify":{default:!1},"ritwickdey.LiveServer":{default:!1},"VisualStudioExptTeam.vscodeintellicode":{default:!1},"octref.vetur":{default:!1},"formulahendry.code-runner":{default:!1},"xdebug.php-debug":{default:!1},"ms-mssql.mssql":{default:!1},"christian-kohler.path-intellisense":{default:!1},"eg2.tslint":{default:!1},"eg2.vscode-npm-script":{default:!1},"donjayamanne.githistory":{default:!1},"Zignd.html-css-class-completion":{default:!1},"christian-kohler.npm-intellisense":{default:!1},"EditorConfig.EditorConfig":{default:!1},"austin.code-gnu-global":{default:!1},"johnpapa.Angular2":{default:!1},"ms-vscode.vscode-typescript-tslint-plugin":{default:!1},"DotJoshJohnson.xml":{default:!1},"techer.open-in-browser":{default:!1},"tht13.python":{default:!1},"bmewburn.vscode-intelephense-client":{default:!1},"Angular.ng-template":{default:!1},"xdebug.php-pack":{default:!1},"dbaeumer.jshint":{default:!1},"yzhang.markdown-all-in-one":{default:!1},"Dart-Code.flutter":{default:!1},"streetsidesoftware.code-spell-checker":{default:!1},"rebornix.Ruby":{default:!1},"ms-vscode.sublime-keybindings":{default:!1},"mitaki28.vscode-clang":{default:!1},"steoates.autoimport":{default:!1},"donjayamanne.python-extension-pack":{default:!1},"shd101wyy.markdown-preview-enhanced":{default:!1},"mikestead.dotenv":{default:!1},"pranaygp.vscode-css-peek":{default:!1},"ikappas.phpcs":{default:!1},"platformio.platformio-ide":{default:!1},"jchannon.csharpextensions":{default:!1},"gruntfuggly.todo-tree":{default:!1}},linkProtectionTrustedDomains:["https://*.visualstudio.com","https://*.microsoft.com","https://aka.ms","https://*.gallerycdn.vsassets.io","https://*.github.com","https://login.microsoftonline.com","https://*.vscode.dev","https://*.github.dev","https://gh.io","https://portal.azure.com","https://raw.githubusercontent.com","https://private-user-images.githubusercontent.com","https://avatars.githubusercontent.com","https://auth.openai.com"],trustedExtensionAuthAccess:{github:["vscode.github","github.remotehub","ms-vscode.remote-server","github.vscode-pull-request-github","github.codespaces","github.copilot","github.copilot-chat","ms-vsliveshare.vsliveshare","ms-azuretools.vscode-azure-github-copilot"],"github-enterprise":["vscode.github","github.remotehub","ms-vscode.remote-server","github.vscode-pull-request-github","github.codespaces","github.copilot","github.copilot-chat","ms-vsliveshare.vsliveshare","ms-azuretools.vscode-azure-github-copilot"],microsoft:["github.copilot-chat","ms-vscode.azure-repos","ms-vscode.remote-server","ms-vsliveshare.vsliveshare","ms-azuretools.vscode-azure-github-copilot","ms-azuretools.vscode-azureresourcegroups","ms-azuretools.vscode-dev-azurecloudshell","ms-edu.vscode-learning","ms-toolsai.vscode-ai","ms-toolsai.vscode-ai-remote"],"microsoft-sovereign-cloud":["ms-vscode.azure-repos","ms-vscode.remote-server","ms-vsliveshare.vsliveshare","ms-azuretools.vscode-azure-github-copilot","ms-azuretools.vscode-azureresourcegroups","ms-azuretools.vscode-dev-azurecloudshell","ms-edu.vscode-learning","ms-toolsai.vscode-ai","ms-toolsai.vscode-ai-remote"],"__GitHub.copilot-chat":["ms-azuretools.vscode-azure-github-copilot","github.vscode-pull-request-github"]},trustedExtensionProtocolHandlers:["vscode.git","vscode.github-authentication","vscode.microsoft-authentication","github.vscode-pull-request-github"],authClientIdMetadataUrl:"https://vscode.dev/oauth/client-metadata.json",inheritAuthAccountPreference:{"github.copilot":["github.copilot-chat"]},auth:{loginUrl:"https://login.microsoftonline.com/common/oauth2/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/token",redirectUrl:"https://vscode-redirect.azurewebsites.net/",clientId:"aebc6443-996d-45c2-90f0-388ff96faa56"},"configurationSync.store":{url:"https://vscode-sync.trafficmanager.net/",stableUrl:"https://vscode-sync.trafficmanager.net/",insidersUrl:"https://vscode-sync-insiders.trafficmanager.net/",canSwitch:!1,authenticationProviders:{github:{scopes:["user:email"]},microsoft:{scopes:["openid","profile","email","offline_access"]}}},"editSessions.store":{url:"https://vscode-sync.trafficmanager.net/",authenticationProviders:{microsoft:{scopes:["openid","profile","email","offline_access"]},github:{scopes:["user:email"]}}},tunnelServerQualities:{stable:{serverApplicationName:"code-server"},exploration:{serverApplicationName:"code-server-exploration"},insider:{serverApplicationName:"code-server-insiders"}},tunnelApplicationName:"code-tunnel",tunnelApplicationConfig:{editorWebUrl:"https://vscode.dev",extension:{friendlyName:"Remote - Tunnels",extensionId:"ms-vscode.remote-server"},authenticationProviders:{github:{scopes:["user:email","read:org"]},microsoft:{scopes:["46da2f7e-b5ef-422a-88d4-2a7f9de6a0b2/.default","profile","openid"]}}},win32TunnelServiceMutex:"vscode-tunnelservice",win32TunnelMutex:"vscode-tunnel",aiGeneratedWorkspaceTrust:{title:"This workspace was generated by GitHub Copilot",checkboxText:"Trust the contents of all files in this workspace",trustOption:"Yes, I trust the contents",dontTrustOption:"No, I don't trust the contents",startupTrustRequestLearnMore:"If you don't trust the contents of the files generated by GitHub Copilot, we recommend continuing in restricted mode. See [our docs](https://aka.ms/vscode-workspace-trust) to learn more. "},defaultChatAgent:{providerExtensionId:"vscode.github-authentication",extensionId:"GitHub.copilot",chatExtensionId:"GitHub.copilot-chat",chatExtensionOutputId:"GitHub.copilot-chat.GitHub Copilot Chat.log",chatExtensionOutputExtensionStateCommand:"github.copilot.debug.extensionState",documentationUrl:"https://aka.ms/github-copilot-overview",termsStatementUrl:"https://aka.ms/github-copilot-terms-statement",privacyStatementUrl:"https://aka.ms/github-copilot-privacy-statement",skusDocumentationUrl:"https://aka.ms/github-copilot-plans",publicCodeMatchesUrl:"https://aka.ms/github-copilot-match-public-code",manageSettingsUrl:"https://aka.ms/github-copilot-settings",managePlanUrl:"https://aka.ms/github-copilot-manage-plan",manageOverageUrl:"https://aka.ms/github-copilot-manage-overage",upgradePlanUrl:"https://aka.ms/github-copilot-upgrade-plan",signUpUrl:"https://aka.ms/github-sign-up",provider:{default:{id:"github",name:"GitHub"},enterprise:{id:"github-enterprise",name:"GHE.com"},google:{id:"google",name:"Google"},apple:{id:"apple",name:"Apple"}},providerUriSetting:"github-enterprise.uri",providerScopes:[["read:user","user:email","repo","workflow"],["user:email"],["read:user"]],entitlementUrl:"https://api.github.com/copilot_internal/user",entitlementSignupLimitedUrl:"https://api.github.com/copilot_internal/subscribe_limited_user",chatQuotaExceededContext:"github.copilot.chat.quotaExceeded",completionsQuotaExceededContext:"github.copilot.completions.quotaExceeded",walkthroughCommand:"github.copilot.open.walkthrough",completionsMenuCommand:"github.copilot.toggleStatusMenu",completionsRefreshTokenCommand:"github.copilot.signIn",chatRefreshTokenCommand:"github.copilot.refreshToken",generateCommitMessageCommand:"github.copilot.git.generateCommitMessage",resolveMergeConflictsCommand:"github.copilot.git.resolveMergeConflicts",completionsAdvancedSetting:"github.copilot.advanced",completionsEnablementSetting:"github.copilot.enable",nextEditSuggestionsSetting:"github.copilot.nextEditSuggestions.enabled",tokenEntitlementUrl:"https://api.github.com/copilot_internal/v2/token",mcpRegistryDataUrl:"https://api.github.com/copilot/mcp_registry"},chatParticipantRegistry:"https://main.vscode-cdn.net/extensions/chat.json",remoteDefaultExtensionsIfInstalledLocally:["GitHub.copilot","GitHub.copilot-chat","GitHub.vscode-pull-request-github"],extensionConfigurationPolicy:{"github.copilot.nextEditSuggestions.enabled":{name:"CopilotNextEditSuggestions",minimumVersion:"1.99",category:"InteractiveSession",description:"Whether to enable next edit suggestions (NES). NES can propose a next edit based on your recent changes."},"github.copilot.chat.reviewSelection.enabled":{name:"CopilotReviewSelection",minimumVersion:"1.104",category:"InteractiveSession",description:"Enables code review on current selection."},"github.copilot.chat.reviewAgent.enabled":{name:"CopilotReviewAgent",minimumVersion:"1.104",category:"InteractiveSession",description:"Enables the code review agent."},"github.copilot.chat.claudeAgent.enabled":{name:"Claude3PIntegration",minimumVersion:"1.113",category:"InteractiveSession",description:"Enable Claude Agent sessions in VS Code. Start and resume agentic coding sessions powered by Anthropic Claude Agent SDK directly in the editor. Uses your existing Copilot subscription."}},win32ContextMenu:{x64:{clsid:"1C6DF0C0-192A-4451-BE36-6A59A86A692E"},arm64:{clsid:"F5EA5883-1DA8-4A05-864A-D5DE2D2B2854"}},chatSessionRecommendations:[{extensionId:"openai.chatgpt",extensionName:"Codex - OpenAI's coding agent",displayName:"Codex Agent",name:"codex",description:"Codex is OpenAI's coding agent that helps you write, review, and ship code faster.",postInstallCommand:"chatgpt.newCodexPanel"},{extensionId:"GitHub.copilot-chat",extensionName:"GitHub Copilot Chat",displayName:"Background Agent",name:"cli",description:"Delegate tasks to a background agent.",postInstallCommand:"workbench.action.chat.openNewSessionSidebar.copilotcli"},{extensionId:"GitHub.copilot-chat",extensionName:"GitHub Copilot Chat",displayName:"Cloud Agent",name:"cloud",description:"Delegate tasks to the GitHub Copilot Cloud Agent. The agent works asynchronously in the cloud to implement changes, iterates via chat, and can create or update pull requests as needed.",postInstallCommand:"workbench.action.chat.openNewSessionSidebar.copilot-cloud-agent"}],builtInExtensions:[{name:"ms-vscode.js-debug-companion",version:"1.1.3",sha256:"7380a890787452f14b2db7835dfa94de538caf358ebc263f9d46dd68ac52de93",repo:"https://github.com/microsoft/vscode-js-debug-companion",metadata:{id:"99cb0b7f-7354-4278-b8da-6cc79972169d",publisherId:{publisherId:"5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",publisherName:"ms-vscode",displayName:"Microsoft",flags:"verified"},publisherDisplayName:"Microsoft"}},{name:"ms-vscode.js-debug",version:"1.112.0",sha256:"c24322931434940938f8cf76ebc3dac1e95a5539b9625b165b6672d7f7eafea8",repo:"https://github.com/microsoft/vscode-js-debug",metadata:{id:"25629058-ddac-4e17-abba-74678e126c5d",publisherId:{publisherId:"5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",publisherName:"ms-vscode",displayName:"Microsoft",flags:"verified"},publisherDisplayName:"Microsoft"}},{name:"ms-vscode.vscode-js-profile-table",version:"1.0.10",sha256:"7361748ddf9fd09d8a2ed1f2a2d7376a2cf9aae708692820b799708385c38e08",repo:"https://github.com/microsoft/vscode-js-profile-visualizer",metadata:{id:"7e52b41b-71ad-457b-ab7e-0620f1fc4feb",publisherId:{publisherId:"5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",publisherName:"ms-vscode",displayName:"Microsoft",flags:"verified"},publisherDisplayName:"Microsoft"}}],version:"1.115.0",commit:"41dd792b5e652393e7787322889ed5fdc58bd75b",date:"2026-04-07T22:04:57Z"},Object.keys(We).length===0&&Object.assign(We,{version:"1.104.0-dev",nameShort:"Code - OSS Dev",nameLong:"Code - OSS Dev",applicationName:"code-oss",dataFolderName:".vscode-oss",urlProtocol:"code-oss",reportIssueUrl:"https://github.com/microsoft/vscode/issues/new",licenseName:"MIT",licenseUrl:"https://github.com/microsoft/vscode/blob/main/LICENSE.txt",serverLicenseUrl:"https://github.com/microsoft/vscode/blob/main/LICENSE.txt",defaultChatAgent:{extensionId:"GitHub.copilot",chatExtensionId:"GitHub.copilot-chat",provider:{default:{id:"github",name:"GitHub"},enterprise:{id:"github-enterprise",name:"GitHub Enterprise"}},providerScopes:[]}});var sp=We;function ml(r){let t=[];typeof r=="number"&&t.push("code/timeOrigin",r);function e(o,s){t.push(o,s?.startTime??Date.now())}function n(){let o=[];for(let s=0;s<t.length;s+=2)o.push({name:t[s],startTime:t[s+1]});return o}function i(o){for(let s=t.length-2;s>=0;s-=2)typeof t[s]=="string"&&t[s].startsWith(o)&&t.splice(s,2)}return{mark:e,getMarks:n,clearMarks:i}}function Em(){if(typeof performance=="object"&&typeof performance.mark=="function"&&!performance.nodeTiming)return typeof performance.timeOrigin!="number"&&!performance.timing?ml():{mark(r,t){performance.mark(r,t)},clearMarks(r){let t=new Set;for(let e of performance.getEntriesByType("mark"))e.name.startsWith(r)&&t.add(e.name);for(let e of t)performance.clearMarks(e)},getMarks(){let r=performance.timeOrigin;typeof r!="number"&&(r=(performance.timing.navigationStart||performance.timing.redirectStart||performance.timing.fetchStart)??0);let t=[{name:"code/timeOrigin",startTime:Math.round(r)}];for(let e of performance.getEntriesByType("mark"))t.push({name:e.name,startTime:Math.round(r+e.startTime)});return t}};if(typeof process=="object"){let r=performance?.timeOrigin;return ml(r)}else return console.trace("perf-util loaded in UNKNOWN environment"),ml()}function wm(r){return r.MonacoPerformanceMarks||(r.MonacoPerformanceMarks=Em()),r.MonacoPerformanceMarks}var vl=wm(globalThis),ap=vl.mark,Yw=vl.clearMarks,Xw=vl.getMarks;async function ns(r,t,e,n,i,o){let s;try{await Cm(r,t,e,n,i,o)}catch(a){s=a}finally{s&&i.errorTransformer&&(s=i.errorTransformer(s)),typeof s<"u"&&e.error(s),e.end()}}async function Cm(r,t,e,n,i,o){yl(o);let s=await r.open(t,{create:!1});try{yl(o);let a=0,l=0,c=i&&typeof i.length=="number"?i.length:void 0,d=S.alloc(Math.min(i.bufferSize,typeof c=="number"?c:i.bufferSize)),u=i&&typeof i.position=="number"?i.position:0,p=0;do l=await r.read(s,u,d.buffer,p,d.byteLength-p),u+=l,p+=l,a+=l,typeof c=="number"&&(c-=l),p===d.byteLength&&(await e.write(n(d)),d=S.alloc(Math.min(i.bufferSize,typeof c=="number"?c:i.bufferSize)),p=0);while(l>0&&(typeof c!="number"||c>0)&&yl(o)&&Pm(a,i));if(p>0){let h=p;typeof c=="number"&&(h=Math.min(p,c)),e.write(n(d.slice(0,h)))}}catch(a){throw Et(a)}finally{await r.close(s)}}function yl(r){if(r.isCancellationRequested)throw mi();return!0}function Pm(r,t){if(typeof t?.limits?.size=="number"&&r>t.limits.size)throw pe(f(2164,null),"EntryTooLarge");return!0}var zt=class extends A{constructor(e){super();this.logService=e;this.BUFFER_SIZE=256*1024;this._onDidChangeFileSystemProviderRegistrations=this._register(new b);this.onDidChangeFileSystemProviderRegistrations=this._onDidChangeFileSystemProviderRegistrations.event;this._onWillActivateFileSystemProvider=this._register(new b);this.onWillActivateFileSystemProvider=this._onWillActivateFileSystemProvider.event;this._onDidChangeFileSystemProviderCapabilities=this._register(new b);this.onDidChangeFileSystemProviderCapabilities=this._onDidChangeFileSystemProviderCapabilities.event;this.provider=new Map;this._onDidRunOperation=this._register(new b);this.onDidRunOperation=this._onDidRunOperation.event;this.internalOnDidFilesChange=this._register(new b);this._onDidUncorrelatedFilesChange=this._register(new b);this.onDidFilesChange=this._onDidUncorrelatedFilesChange.event;this._onDidWatchError=this._register(new b);this.onDidWatchError=this._onDidWatchError.event;this.activeWatchers=new Map;this.writeQueue=this._register(new On)}registerProvider(e,n){if(this.provider.has(e))throw new Error(`A filesystem provider for the scheme '${e}' is already registered.`);ap(`code/registerFilesystem/${e}`);let i=new N;return this.provider.set(e,n),this._onDidChangeFileSystemProviderRegistrations.fire({added:!0,scheme:e,provider:n}),i.add(n.onDidChangeFile(o=>{let s=new co(o,!this.isPathCaseSensitive(n));this.internalOnDidFilesChange.fire(s),s.hasCorrelation()||this._onDidUncorrelatedFilesChange.fire(s)})),typeof n.onDidWatchError=="function"&&i.add(n.onDidWatchError(o=>this._onDidWatchError.fire(new Error(o)))),i.add(n.onDidChangeCapabilities(()=>this._onDidChangeFileSystemProviderCapabilities.fire({provider:n,scheme:e}))),O(()=>{this._onDidChangeFileSystemProviderRegistrations.fire({added:!1,scheme:e,provider:n}),this.provider.delete(e),Ae(i)})}getProvider(e){return this.provider.get(e)}async activateProvider(e){let n=[];this._onWillActivateFileSystemProvider.fire({scheme:e,join(i){n.push(i)}}),!this.provider.has(e)&&await an.settled(n)}async canHandleResource(e){return await this.activateProvider(e.scheme),this.hasProvider(e)}hasProvider(e){return this.provider.has(e.scheme)}hasCapability(e,n){let i=this.provider.get(e.scheme);return!!(i&&i.capabilities&n)}listCapabilities(){return Sr.map(this.provider,([e,n])=>({scheme:e,capabilities:n.capabilities}))}async withProvider(e){if(!Gc(e))throw new me(f(2153,null,this.resourceForError(e)),8);await this.activateProvider(e.scheme);let n=this.provider.get(e.scheme);if(!n){let i=new ot;throw i.message=f(2155,null,e.toString()),i}return n}async withReadProvider(e){let n=await this.withProvider(e);if(Rt(n)||Ve(n)||po(n))return n;throw new Error(`Filesystem provider for scheme '${e.scheme}' neither has FileReadWrite, FileReadStream nor FileOpenReadWriteClose capability which is needed for the read operation.`)}async withWriteProvider(e){let n=await this.withProvider(e);if(Rt(n)||Ve(n))return n;throw new Error(`Filesystem provider for scheme '${e.scheme}' neither has FileReadWrite nor FileOpenReadWriteClose capability which is needed for the write operation.`)}async resolve(e,n){try{return await this.doResolveFile(e,n)}catch(i){throw ut(i)==="EntryNotFound"?new me(f(2150,null,this.resourceForError(e)),1):Et(i)}}async doResolveFile(e,n){let i=await this.withProvider(e),o=this.isPathCaseSensitive(i),s=n?.resolveTo,a=n?.resolveSingleChildDescendants,l=n?.resolveMetadata,c=await i.stat(e),d;return this.toFileStat(i,e,c,void 0,!!l,(u,p)=>(d||(d=qt.forUris(()=>!o),d.set(e,!0),s&&d.fill(!0,s)),d.get(u.resource)||d.findSuperstr(u.resource.with({query:null,fragment:null}))?!0:u.isDirectory&&a?p===1:!1))}async toFileStat(e,n,i,o,s,a){let{providerExtUri:l}=this.getExtUri(e),c={resource:n,name:l.basename(n),isFile:(i.type&1)!==0,isDirectory:(i.type&2)!==0,isSymbolicLink:(i.type&64)!==0,mtime:i.mtime,ctime:i.ctime,size:i.size,readonly:!!((i.permissions??0)&1)||!!(e.capabilities&2048),locked:!!((i.permissions??0)&2),executable:!!((i.permissions??0)&4),etag:ka({mtime:i.mtime,size:i.size}),children:void 0};if(c.isDirectory&&a(c,o)){try{let d=await e.readdir(n),u=await an.settled(d.map(async([p,h])=>{try{let v=l.joinPath(n,p),g=s?await e.stat(v):{type:h};return await this.toFileStat(e,v,g,d.length,s,a)}catch(v){return this.logService.trace(v),null}}));c.children=yi(u)}catch(d){this.logService.trace(d),c.children=[]}return c}return c}async resolveAll(e){return an.settled(e.map(async n=>{try{return{stat:await this.doResolveFile(n.resource,n.options),success:!0}}catch(i){return this.logService.trace(i),{stat:void 0,success:!1}}}))}async stat(e){let n=await this.withProvider(e),i=await n.stat(e);return this.toFileStat(n,e,i,void 0,!0,()=>!1)}async realpath(e){let n=await this.withProvider(e);if(zu(n)){let i=await n.realpath(e);return e.with({path:i})}}async exists(e){let n=await this.withProvider(e);try{return!!await n.stat(e)}catch{return!1}}async canCreateFile(e,n){try{await this.doValidateCreateFile(e,n)}catch(i){return i}return!0}async doValidateCreateFile(e,n){if(!n?.overwrite&&await this.exists(e))throw new me(f(2146,null,this.resourceForError(e)),3,n)}async createFile(e,n=S.fromString(""),i){await this.doValidateCreateFile(e,i);let o=await this.writeFile(e,n);return this._onDidRunOperation.fire(new xt(e,0,o)),o}async writeFile(e,n,i){let o=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(e),e),{providerExtUri:s}=this.getExtUri(o),a=i;if(Pa(o)&&!a?.atomic){let l=o.enforceAtomicWriteFile?.(e);l&&(a={...i,atomic:l})}try{let{stat:l,buffer:c}=await this.validateWriteFile(o,e,n,a);l||await this.mkdirp(o,s.dirname(e)),c||(c=await this.peekBufferForWriting(o,n)),!Rt(o)||Ve(o)&&c instanceof S||Ve(o)&&Pa(o)&&a?.atomic?await this.doWriteUnbuffered(o,e,a,c):await this.doWriteBuffered(o,e,a,c instanceof S?su(c):c),this._onDidRunOperation.fire(new xt(e,4))}catch(l){throw new me(f(2145,null,this.resourceForError(e),Et(l).toString()),Aa(l),a)}return this.resolve(e,{resolveMetadata:!0})}async peekBufferForWriting(e,n){let i;if(Ve(e)&&!(n instanceof S))if(Or(n)){let o=await tu(n,3);o.ended?i=S.concat(o.buffer):i=o}else i=eu(n,o=>S.concat(o),3);else i=n;return i}async validateWriteFile(e,n,i,o){let s=!!o?.unlock;if(s&&!(e.capabilities&8192))throw new Error(f(2163,null,this.resourceForError(n)));if(o?.append&&!Ku(e))throw new me(f(2142,null,this.resourceForError(n)),6);if(!!o?.atomic){if(!(e.capabilities&32768))throw new Error(f(2161,null,this.resourceForError(n)));if(!(e.capabilities&2))throw new Error(f(2162,null,this.resourceForError(n)));if(s)throw new Error(f(2160,null,this.resourceForError(n)))}let l;try{l=await e.stat(n)}catch{return Object.create(null)}if((l.type&2)!==0)throw new me(f(2148,null,this.resourceForError(n)),0,o);this.throwIfFileIsReadonly(n,l);let c;if(typeof o?.mtime=="number"&&typeof o.etag=="string"&&o.etag!==ho&&typeof l.mtime=="number"&&typeof l.size=="number"&&o.mtime<l.mtime&&o.etag!==ka({mtime:o.mtime,size:l.size})){if(c=await this.peekBufferForWriting(e,i),c instanceof S&&c.byteLength===l.size)try{let{value:d}=await this.readFile(n,{limits:{size:l.size}});if(c.equals(d))return{stat:l,buffer:c}}catch{}throw new me(f(2149,null),3,o)}return{stat:l,buffer:c}}async readFile(e,n,i){let o=await this.withReadProvider(e);return n?.atomic?this.doReadFileAtomic(o,e,n,i):this.doReadFile(o,e,n,i)}async doReadFileAtomic(e,n,i,o){return new Promise((s,a)=>{this.writeQueue.queueFor(n,async()=>{try{let l=await this.doReadFile(e,n,i,o);s(l)}catch(l){a(l)}},this.getExtUri(e).providerExtUri)})}async doReadFile(e,n,i,o){let s=await this.doReadFileStream(e,n,{...i,preferUnbuffered:!0},o);return{...s,value:await Fr(s.value)}}async readFileStream(e,n,i){let o=await this.withReadProvider(e);return this.doReadFileStream(o,e,n,i)}async doReadFileStream(e,n,i,o){let s=new fe(o),a=i;fo(e)&&e.enforceAtomicReadFile?.(n)&&(a={...i,atomic:!0});let l=this.validateReadFile(n,a).then(d=>d,d=>{throw s.dispose(!0),d}),c;try{return typeof a?.etag=="string"&&a.etag!==ho&&await l,a?.atomic&&fo(e)||!(Rt(e)||po(e))||Ve(e)&&a?.preferUnbuffered?c=this.readFileUnbuffered(e,n,a):po(e)?c=this.readFileStreamed(e,n,s.token,a):c=this.readFileBuffered(e,n,s.token,a),c.on("end",()=>s.dispose()),c.on("error",()=>s.dispose()),{...await l,value:c}}catch(d){throw c&&await Vi(c),this.restoreReadError(d,n,a)}}restoreReadError(e,n,i){let o=f(2143,null,this.resourceForError(n),Et(e).toString());return e instanceof Qn?new Qn(o,e.stat,i):e instanceof Jn?new Jn(o,e.fileOperationResult,e.size,e.options):new me(o,Aa(e),i)}readFileStreamed(e,n,i,o=Object.create(null)){let s=e.readFileStream(n,o,i);return ia(s,{data:a=>a instanceof S?a:S.wrap(a),error:a=>this.restoreReadError(a,n,o)},a=>S.concat(a))}readFileBuffered(e,n,i,o=Object.create(null)){let s=lu();return ns(e,n,s,a=>a,{...o,bufferSize:this.BUFFER_SIZE,errorTransformer:a=>this.restoreReadError(a,n,o)},i),s}readFileUnbuffered(e,n,i){let o=ln(s=>S.concat(s));return(async()=>{try{let s;i?.atomic&&fo(e)?s=await e.readFile(n,{atomic:!0}):s=await e.readFile(n),typeof i?.position=="number"&&(s=s.slice(i.position)),typeof i?.length=="number"&&(s=s.slice(0,i.length)),this.validateReadFileLimits(n,s.byteLength,i),o.end(S.wrap(s))}catch(s){o.error(s),o.end()}})(),o}async validateReadFile(e,n){let i=await this.resolve(e,{resolveMetadata:!0});if(i.isDirectory)throw new me(f(2147,null,this.resourceForError(e)),0,n);if(typeof n?.etag=="string"&&n.etag!==ho&&n.etag===i.etag)throw new Qn(f(2151,null),i,n);return this.validateReadFileLimits(e,i.size,n),i}validateReadFileLimits(e,n,i){if(typeof i?.limits?.size=="number"&&n>i.limits.size)throw new Jn(f(2152,null,this.resourceForError(e)),7,n,i)}async canMove(e,n,i){return this.doCanMoveCopy(e,n,"move",i)}async canCopy(e,n,i){return this.doCanMoveCopy(e,n,"copy",i)}async doCanMoveCopy(e,n,i,o){if(e.toString()!==n.toString())try{let s=i==="move"?this.throwIfFileSystemIsReadonly(await this.withWriteProvider(e),e):await this.withReadProvider(e),a=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n);await this.doValidateMoveCopy(s,e,a,n,i,o)}catch(s){return s}return!0}async move(e,n,i){let o=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(e),e),s=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n),a=await this.doMoveCopy(o,e,s,n,"move",!!i),l=await this.resolve(n,{resolveMetadata:!0});return this._onDidRunOperation.fire(new xt(e,a==="move"?2:3,l)),l}async copy(e,n,i){let o=await this.withReadProvider(e),s=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n),a=await this.doMoveCopy(o,e,s,n,"copy",!!i),l=await this.resolve(n,{resolveMetadata:!0});return this._onDidRunOperation.fire(new xt(e,a==="copy"?3:2,l)),l}async doMoveCopy(e,n,i,o,s,a){if(n.toString()===o.toString())return s;let{exists:l,isSameResourceWithDifferentPathCase:c}=await this.doValidateMoveCopy(e,n,i,o,s,a);if(l&&!c&&a&&await this.del(o,{recursive:!0}),await this.mkdirp(i,this.getExtUri(i).providerExtUri.dirname(o)),s==="copy"){if(e===i&&Ca(e))await e.copy(n,o,{overwrite:a});else{let d=await this.resolve(n);d.isDirectory?await this.doCopyFolder(e,d,i,o):await this.doCopyFile(e,n,i,o)}return s}else return e===i?(await e.rename(n,o,{overwrite:a}),s):(await this.doMoveCopy(e,n,i,o,"copy",a),await this.del(n,{recursive:!0}),"copy")}async doCopyFile(e,n,i,o){if(Rt(e)&&Rt(i))return this.doPipeBuffered(e,n,i,o);if(Rt(e)&&Ve(i))return this.doPipeBufferedToUnbuffered(e,n,i,o);if(Ve(e)&&Rt(i))return this.doPipeUnbufferedToBuffered(e,n,i,o);if(Ve(e)&&Ve(i))return this.doPipeUnbuffered(e,n,i,o)}async doCopyFolder(e,n,i,o){await i.mkdir(o),Array.isArray(n.children)&&await an.settled(n.children.map(async s=>{let a=this.getExtUri(i).providerExtUri.joinPath(o,s.name);return s.isDirectory?this.doCopyFolder(e,await this.resolve(s.resource),i,a):this.doCopyFile(e,s.resource,i,a)}))}async doValidateMoveCopy(e,n,i,o,s,a){let l=!1;if(e===i){let{providerExtUri:d,isPathCaseSensitive:u}=this.getExtUri(e);if(u||(l=d.isEqual(n,o)),l&&s==="copy")throw new Error(f(2156,null,this.resourceForError(n),this.resourceForError(o)));if(!l&&d.isEqualOrParent(o,n))throw new Error(f(2157,null,this.resourceForError(n),this.resourceForError(o)))}let c=await this.exists(o);if(c&&!l){if(!a)throw new me(f(2158,null,this.resourceForError(n),this.resourceForError(o)),4);if(e===i){let{providerExtUri:d}=this.getExtUri(e);if(d.isEqualOrParent(n,o))throw new Error(f(2159,null,this.resourceForError(n),this.resourceForError(o)))}}return{exists:c,isSameResourceWithDifferentPathCase:l}}getExtUri(e){let n=this.isPathCaseSensitive(e);return{providerExtUri:n?V:Qs,isPathCaseSensitive:n}}isPathCaseSensitive(e){return!!(e.capabilities&1024)}async createFolder(e){let n=this.throwIfFileSystemIsReadonly(await this.withProvider(e),e);await this.mkdirp(n,e);let i=await this.resolve(e,{resolveMetadata:!0});return this._onDidRunOperation.fire(new xt(e,0,i)),i}async mkdirp(e,n){let i=[],{providerExtUri:o}=this.getExtUri(e);for(;!o.isEqual(n,o.dirname(n));)try{if(((await e.stat(n)).type&2)===0)throw new Error(f(2154,null,this.resourceForError(n)));break}catch(s){if(ut(s)!=="EntryNotFound")throw s;i.push(o.basename(n)),n=o.dirname(n)}for(let s=i.length-1;s>=0;s--){n=o.joinPath(n,i[s]);try{await e.mkdir(n)}catch(a){if(ut(a)!=="EntryExists")throw a}}}async canDelete(e,n){try{await this.doValidateDelete(e,n)}catch(i){return i}return!0}async doValidateDelete(e,n){let i=this.throwIfFileSystemIsReadonly(await this.withProvider(e),e),o=!!n?.useTrash;if(o&&!(i.capabilities&4096))throw new Error(f(2141,null,this.resourceForError(e)));let s=n?.atomic;if(s&&!(i.capabilities&65536))throw new Error(f(2137,null,this.resourceForError(e)));if(o&&s)throw new Error(f(2140,null,this.resourceForError(e)));let a;try{a=await i.stat(e)}catch{}if(a)this.throwIfFileIsReadonly(e,a);else throw new me(f(2139,null,this.resourceForError(e)),1);if(!!!n?.recursive){let c=await this.resolve(e);if(c.isDirectory&&Array.isArray(c.children)&&c.children.length>0)throw new Error(f(2138,null,this.resourceForError(e)))}return i}async del(e,n){let i=await this.doValidateDelete(e,n),o=n;if(Hu(i)&&!o?.atomic){let c=i.enforceAtomicDelete?.(e);c&&(o={...n,atomic:c})}let s=!!o?.useTrash,a=!!o?.recursive,l=o?.atomic??!1;await i.delete(e,{recursive:a,useTrash:s,atomic:l}),this._onDidRunOperation.fire(new xt(e,1))}async cloneFile(e,n){let i=await this.withProvider(e),o=this.throwIfFileSystemIsReadonly(await this.withWriteProvider(n),n);if(!(i===o&&this.getExtUri(i).providerExtUri.isEqual(e,n)))return i===o&&ju(i)?i.cloneFile(e,n):(await this.mkdirp(o,this.getExtUri(o).providerExtUri.dirname(n)),i===o&&Ca(i)?this.writeQueue.queueFor(e,()=>i.copy(e,n,{overwrite:!0}),this.getExtUri(i).providerExtUri):this.writeQueue.queueFor(e,()=>this.doCopyFile(i,e,o,n),this.getExtUri(i).providerExtUri))}static{this.WATCHER_CORRELATION_IDS=0}createWatcher(e,n){return this.watch(e,{...n,correlationId:zt.WATCHER_CORRELATION_IDS++})}watch(e,n={recursive:!1,excludes:[]}){let i=new N,o=!1,s=()=>{o=!0};i.add(O(()=>s())),(async()=>{try{let l=await this.doWatch(e,n);o?Ae(l):s=()=>Ae(l)}catch(l){this.logService.error(l)}})();let a=n.correlationId;if(typeof a=="number"){let l=i.add(new b);return i.add(this.internalOnDidFilesChange.event(d=>{d.correlates(a)&&l.fire(d)})),{onDidChange:l.event,dispose:()=>i.dispose()}}return i}async doWatch(e,n){let i=await this.withProvider(e),o=er([this.getExtUri(i).providerExtUri.getComparisonKey(e),n]),s=this.activeWatchers.get(o);return s||(s={count:0,disposable:i.watch(e,n)},this.activeWatchers.set(o,s)),s.count+=1,O(()=>{s&&(s.count--,s.count===0&&(Ae(s.disposable),this.activeWatchers.delete(o)))})}dispose(){super.dispose();for(let[,e]of this.activeWatchers)Ae(e.disposable);this.activeWatchers.clear()}async doWriteBuffered(e,n,i,o){return this.writeQueue.queueFor(n,async()=>{let s=await e.open(n,{create:!0,unlock:i?.unlock??!1,append:i?.append??!1});try{Or(o)||qi(o)?await this.doWriteStreamBufferedQueued(e,s,o):await this.doWriteReadableBufferedQueued(e,s,o)}catch(a){throw Et(a)}finally{await e.close(s)}},this.getExtUri(e).providerExtUri)}async doWriteStreamBufferedQueued(e,n,i){let o=0,s;if(qi(i)){if(i.buffer.length>0){let a=S.concat(i.buffer);await this.doWriteBuffer(e,n,a,a.byteLength,o,0),o+=a.byteLength}if(i.ended)return;s=i.stream}else s=i;return new Promise((a,l)=>{$i(s,{onData:async c=>{s.pause();try{await this.doWriteBuffer(e,n,c,c.byteLength,o,0)}catch(d){return l(d)}o+=c.byteLength,setTimeout(()=>s.resume())},onError:c=>l(c),onEnd:()=>a()})})}async doWriteReadableBufferedQueued(e,n,i){let o=0,s;for(;(s=i.read())!==null;)await this.doWriteBuffer(e,n,s,s.byteLength,o,0),o+=s.byteLength}async doWriteBuffer(e,n,i,o,s,a){let l=0;for(;l<o;){let c=await e.write(n,s+l,i.buffer,a+l,o-l);l+=c}}async doWriteUnbuffered(e,n,i,o){return this.writeQueue.queueFor(n,()=>this.doWriteUnbufferedQueued(e,n,i,o),this.getExtUri(e).providerExtUri)}async doWriteUnbufferedQueued(e,n,i,o){let s;o instanceof S?s=o:Or(o)?s=await Fr(o):qi(o)?s=await au(o):s=ou(o),await e.writeFile(n,s.buffer,{create:!0,overwrite:!0,unlock:i?.unlock??!1,atomic:i?.atomic??!1,append:i?.append??!1})}async doPipeBuffered(e,n,i,o){return this.writeQueue.queueFor(o,()=>this.doPipeBufferedQueued(e,n,i,o),this.getExtUri(i).providerExtUri)}async doPipeBufferedQueued(e,n,i,o){let s,a;try{s=await e.open(n,{create:!1}),a=await i.open(o,{create:!0,unlock:!1});let l=S.alloc(this.BUFFER_SIZE),c=0,d=0,u=0;do u=await e.read(s,c,l.buffer,d,l.byteLength-d),await this.doWriteBuffer(i,a,l,u,c,d),c+=u,d+=u,d===l.byteLength&&(d=0);while(u>0)}catch(l){throw Et(l)}finally{await an.settled([typeof s=="number"?e.close(s):Promise.resolve(),typeof a=="number"?i.close(a):Promise.resolve()])}}async doPipeUnbuffered(e,n,i,o){return this.writeQueue.queueFor(o,()=>this.doPipeUnbufferedQueued(e,n,i,o),this.getExtUri(i).providerExtUri)}async doPipeUnbufferedQueued(e,n,i,o){return i.writeFile(o,await e.readFile(n),{create:!0,overwrite:!0,unlock:!1,atomic:!1})}async doPipeUnbufferedToBuffered(e,n,i,o){return this.writeQueue.queueFor(o,()=>this.doPipeUnbufferedToBufferedQueued(e,n,i,o),this.getExtUri(i).providerExtUri)}async doPipeUnbufferedToBufferedQueued(e,n,i,o){let s=await i.open(o,{create:!0,unlock:!1});try{let a=await e.readFile(n);await this.doWriteBuffer(i,s,S.wrap(a),a.byteLength,0,0)}catch(a){throw Et(a)}finally{await i.close(s)}}async doPipeBufferedToUnbuffered(e,n,i,o){let s=await Fr(this.readFileBuffered(e,n,Be.None));await this.doWriteUnbuffered(i,o,void 0,s)}throwIfFileSystemIsReadonly(e,n){if(e.capabilities&2048)throw new me(f(2144,null,this.resourceForError(n)),6);return e}throwIfFileIsReadonly(e,n){if((n.permissions??0)&1)throw new me(f(2144,null,this.resourceForError(e)),6)}resourceForError(e){return e.scheme===ee.file?e.fsPath:e.toString(!0)}};zt=D([re(0,Ce)],zt);import{constants as Sl,promises as yn}from"fs";function ss(r){return typeof r.correlationId=="number"}function pp(r){return r.recursive===!0}var rs=class r extends A{constructor(e,n,i,o){super();this.onFileChanges=e;this.onLogMessage=n;this.verboseLogging=i;this.options=o;this.watcherDisposables=this._register(new kt);this.requests=void 0;this.restartCounter=0}static{this.MAX_RESTARTS=5}init(){let e=new N;this.watcherDisposables.value=e,this.watcher=this.createWatcher(e),this.watcher.setVerboseLogging(this.verboseLogging),e.add(this.watcher.onDidChangeFile(n=>this.onFileChanges(n))),e.add(this.watcher.onDidLogMessage(n=>this.onLogMessage(n))),e.add(this.watcher.onDidError(n=>this.onError(n.error,n.request)))}onError(e,n){this.canRestart(e,n)?this.restartCounter<r.MAX_RESTARTS&&this.requests?(this.error(`restarting watcher after unexpected error: ${e}`),this.restart(this.requests)):this.error(`gave up attempting to restart watcher after unexpected error: ${e}`):this.error(e)}canRestart(e,n){return!(!this.options.restartOnError||n||e.indexOf("No space left on device")!==-1||e.indexOf("EMFILE")!==-1)}restart(e){this.restartCounter++,this.init(),this.watch(e)}async watch(e){this.requests=e,await this.watcher?.watch(e)}async setVerboseLogging(e){this.verboseLogging=e,await this.watcher?.setVerboseLogging(e)}error(e){this.onLogMessage({type:"error",message:`[File Watcher (${this.options.type})] ${e}`})}trace(e){this.onLogMessage({type:"trace",message:`[File Watcher (${this.options.type})] ${e}`})}dispose(){return this.watcher=void 0,super.dispose()}},is=class extends rs{constructor(t,e,n){super(t,e,n,{type:"node.js",restartOnError:!1})}},os=class extends rs{constructor(t,e,n){super(t,e,n,{type:"universal",restartOnError:!0})}};function Il(r){return r.map(t=>({type:t.type,resource:m.revive(t.resource),cId:t.cId}))}function fp(r){let t=new bl;for(let e of r)t.processEvent(e);return t.coalesce()}function Am(r,t){return typeof t=="string"&&!t.startsWith(Zn)&&!Cn(t)?{base:r,pattern:t}:t}function Tl(r,t,e){let n=[];for(let i of t)n.push(Ba(Am(r,i),{ignoreCase:e}));return n}var bl=class{constructor(){this.coalesced=new Set;this.mapPathToChange=new Map}toKey(t){return le?t.resource.fsPath:t.resource.fsPath.toLowerCase()}processEvent(t){let e=this.mapPathToChange.get(this.toKey(t)),n=!1;if(e){let i=e.type,o=t.type;e.resource.fsPath!==t.resource.fsPath&&(t.type===2||t.type===1)?n=!0:i===1&&o===2?(this.mapPathToChange.delete(this.toKey(t)),this.coalesced.delete(e)):i===2&&o===1?e.type=0:i===1&&o===0||(e.type=o)}else n=!0;n&&(this.coalesced.add(t),this.mapPathToChange.set(this.toKey(t),t))}coalesce(){let t=[],e=[];return Array.from(this.coalesced).filter(n=>n.type!==2?(t.push(n),!1):!0).sort((n,i)=>n.resource.fsPath.length-i.resource.fsPath.length).filter(n=>e.some(i=>Gu(n.resource.fsPath,i,!le))?!1:(e.push(n.resource.fsPath),!0)).concat(t)}};function hp(r,t){if(typeof t=="number")switch(r.type){case 1:return(t&4)===0;case 2:return(t&8)===0;case 0:return(t&2)===0}return!1}function gp(r){if(typeof r=="number"){let t=[];return r&4&&t.push("Added"),r&8&&t.push("Deleted"),r&2&&t.push("Updated"),t.length===0?"<all>":`[${t.join(", ")}]`}return"<none>"}var as=class extends A{constructor(e,n){super();this.logService=e;this.options=n;this._onDidChangeFile=this._register(new b);this.onDidChangeFile=this._onDidChangeFile.event;this._onDidWatchError=this._register(new b);this.onDidWatchError=this._onDidWatchError.event;this.universalWatchRequests=[];this.universalWatchRequestDelayer=this._register(new on(this.getRefreshWatchersDelay(this.universalWatchRequests.length)));this.nonRecursiveWatchRequests=[];this.nonRecursiveWatchRequestDelayer=this._register(new on(this.getRefreshWatchersDelay(this.nonRecursiveWatchRequests.length)))}watch(e,n){return n.recursive||this.options?.watcher?.forceUniversal?this.watchUniversal(e,n):this.watchNonRecursive(e,n)}getRefreshWatchersDelay(e){return e>200?500:0}watchUniversal(e,n){let i=this.toWatchRequest(e,n),o=Is(this.universalWatchRequests,i);return this.refreshUniversalWatchers(),O(()=>{o(),this.refreshUniversalWatchers()})}toWatchRequest(e,n){let i={path:this.toWatchPath(e),excludes:n.excludes,includes:n.includes,recursive:n.recursive,filter:n.filter,correlationId:n.correlationId};if(pp(i)){let o=this.options?.watcher?.recursive?.usePolling;o===!0?i.pollingInterval=this.options?.watcher?.recursive?.pollingInterval??5e3:Array.isArray(o)&&o.includes(i.path)&&(i.pollingInterval=this.options?.watcher?.recursive?.pollingInterval??5e3)}return i}refreshUniversalWatchers(){this.universalWatchRequestDelayer.trigger(()=>this.doRefreshUniversalWatchers(),this.getRefreshWatchersDelay(this.universalWatchRequests.length)).catch(e=>oe(e))}doRefreshUniversalWatchers(){return this.universalWatcher||(this.universalWatcher=this._register(this.createUniversalWatcher(e=>this._onDidChangeFile.fire(Il(e)),e=>this.onWatcherLogMessage(e),this.logService.getLevel()===1)),this._register(this.logService.onDidChangeLogLevel(()=>{this.universalWatcher?.setVerboseLogging(this.logService.getLevel()===1)}))),this.universalWatcher.watch(this.universalWatchRequests)}watchNonRecursive(e,n){let i={path:this.toWatchPath(e),excludes:n.excludes,includes:n.includes,recursive:!1,filter:n.filter,correlationId:n.correlationId},o=Is(this.nonRecursiveWatchRequests,i);return this.refreshNonRecursiveWatchers(),O(()=>{o(),this.refreshNonRecursiveWatchers()})}refreshNonRecursiveWatchers(){this.nonRecursiveWatchRequestDelayer.trigger(()=>this.doRefreshNonRecursiveWatchers(),this.getRefreshWatchersDelay(this.nonRecursiveWatchRequests.length)).catch(e=>oe(e))}doRefreshNonRecursiveWatchers(){return this.nonRecursiveWatcher||(this.nonRecursiveWatcher=this._register(this.createNonRecursiveWatcher(e=>this._onDidChangeFile.fire(Il(e)),e=>this.onWatcherLogMessage(e),this.logService.getLevel()===1)),this._register(this.logService.onDidChangeLogLevel(()=>{this.nonRecursiveWatcher?.setVerboseLogging(this.logService.getLevel()===1)}))),this.nonRecursiveWatcher.watch(this.nonRecursiveWatchRequests)}onWatcherLogMessage(e){e.type==="error"&&this._onDidWatchError.fire(e.message),this.logWatcherMessage(e)}logWatcherMessage(e){this.logService[e.type](e.message)}toFilePath(e){return je(e.fsPath)}toWatchPath(e){let n=this.toFilePath(e);return Uc(n)}};var ls=class extends os{constructor(t,e,n){super(t,e,n),this.init()}createWatcher(t){let e=t.add(new Qi(lt.asFileUri("bootstrap-fork").fsPath,{serverName:"File Watcher",args:["--type=fileWatcher"],env:{VSCODE_ESM_ENTRYPOINT:"vs/platform/files/node/watcher/watcherMain",VSCODE_PIPE_LOGGING:"true",VSCODE_VERBOSE_LOGGING:"true"}}));return t.add(e.onDidProcessExit(({code:n,signal:i})=>this.onError(`terminated by itself with code ${n}, signal: ${i} (ETERM)`))),qn.toService(uu(e.getChannel("watcher")))}};import{watchFile as km,unwatchFile as Dm}from"fs";var cs=class extends A{constructor(){super();this._onDidChangeFile=this._register(new b);this.onDidChangeFile=this._onDidChangeFile.event;this._onDidLogMessage=this._register(new b);this.onDidLogMessage=this._onDidLogMessage.event;this._onDidWatchFail=this._register(new b);this.onDidWatchFail=this._onDidWatchFail.event;this.correlatedWatchRequests=new Map;this.nonCorrelatedWatchRequests=new Map;this.suspendedWatchRequests=this._register(new st);this.suspendedWatchRequestsWithPolling=new Set;this.updateWatchersDelayer=this._register(new on(this.getUpdateWatchersDelay()));this.suspendedWatchRequestPollingInterval=5007;this.joinWatch=new He;this.verboseLogging=!1;this._register(this.onDidWatchFail(e=>this.suspendWatchRequest({id:this.computeId(e),correlationId:this.isCorrelated(e)?e.correlationId:void 0,path:e.path})))}isCorrelated(e){return ss(e)}computeId(e){return this.isCorrelated(e)?e.correlationId:er(e)}async watch(e){this.joinWatch.isSettled||this.joinWatch.complete(),this.joinWatch=new He;try{this.correlatedWatchRequests.clear(),this.nonCorrelatedWatchRequests.clear();for(let n of e)this.isCorrelated(n)?this.correlatedWatchRequests.set(n.correlationId,n):this.nonCorrelatedWatchRequests.set(this.computeId(n),n);for(let[n]of this.suspendedWatchRequests)!this.nonCorrelatedWatchRequests.has(n)&&!this.correlatedWatchRequests.has(n)&&(this.suspendedWatchRequests.deleteAndDispose(n),this.suspendedWatchRequestsWithPolling.delete(n));return await this.updateWatchers(!1)}finally{this.joinWatch.complete()}}updateWatchers(e){let n=[];for(let[i,o]of[...this.nonCorrelatedWatchRequests,...this.correlatedWatchRequests])this.suspendedWatchRequests.has(i)||n.push(o);return this.updateWatchersDelayer.trigger(()=>this.doWatch(n),e?this.getUpdateWatchersDelay():0).catch(i=>oe(i))}getUpdateWatchersDelay(){return 800}isSuspended(e){let n=this.computeId(e);return this.suspendedWatchRequestsWithPolling.has(n)?"polling":this.suspendedWatchRequests.has(n)}async suspendWatchRequest(e){if(this.suspendedWatchRequests.has(e.id))return;let n=new N;this.suspendedWatchRequests.set(e.id,n),await this.joinWatch.p,!n.isDisposed&&(this.monitorSuspendedWatchRequest(e,n),this.updateWatchers(!0))}resumeWatchRequest(e){this.suspendedWatchRequests.deleteAndDispose(e.id),this.suspendedWatchRequestsWithPolling.delete(e.id),this.updateWatchers(!1)}monitorSuspendedWatchRequest(e,n){this.doMonitorWithExistingWatcher(e,n)?(this.trace(`reusing an existing recursive watcher to monitor ${e.path}`),this.suspendedWatchRequestsWithPolling.delete(e.id)):(this.doMonitorWithNodeJS(e,n),this.suspendedWatchRequestsWithPolling.add(e.id))}doMonitorWithExistingWatcher(e,n){let i=this.recursiveWatcher?.subscribe(e.path,(o,s)=>{n.isDisposed||(o?this.monitorSuspendedWatchRequest(e,n):s?.type===1&&this.onMonitoredPathAdded(e))});return i?(n.add(i),!0):!1}doMonitorWithNodeJS(e,n){let i=!1,o=(s,a)=>{if(n.isDisposed)return;let l=this.isPathNotFound(s),c=this.isPathNotFound(a),d=i;i=l,!l&&(c||d)&&this.onMonitoredPathAdded(e)};this.trace(`starting fs.watchFile() on ${e.path} (correlationId: ${e.correlationId})`);try{km(e.path,{persistent:!1,interval:this.suspendedWatchRequestPollingInterval},o)}catch(s){this.warn(`fs.watchFile() failed with error ${s} on path ${e.path} (correlationId: ${e.correlationId})`)}n.add(O(()=>{this.trace(`stopping fs.watchFile() on ${e.path} (correlationId: ${e.correlationId})`);try{Dm(e.path,o)}catch(s){this.warn(`fs.unwatchFile() failed with error ${s} on path ${e.path} (correlationId: ${e.correlationId})`)}}))}onMonitoredPathAdded(e){this.trace(`detected ${e.path} exists again, resuming watcher (correlationId: ${e.correlationId})`);let n={resource:m.file(e.path),type:1,cId:e.correlationId};this._onDidChangeFile.fire([n]),this.traceEvent(n,e),this.resumeWatchRequest(e)}isPathNotFound(e){return e.ctimeMs===0&&e.ino===0}async stop(){this.suspendedWatchRequests.clearAndDisposeAll(),this.suspendedWatchRequestsWithPolling.clear()}traceEvent(e,n){if(this.verboseLogging){let i=` >> normalized ${e.type===1?"[ADDED]":e.type===2?"[DELETED]":"[CHANGED]"} ${e.resource.fsPath}`;this.traceWithCorrelation(i,n)}}traceWithCorrelation(e,n){this.verboseLogging&&this.trace(`${e}${typeof n.correlationId=="number"?` <${n.correlationId}> `:""}`)}requestToString(e){return`${e.path} (excludes: ${e.excludes.length>0?e.excludes:"<none>"}, includes: ${e.includes&&e.includes.length>0?JSON.stringify(e.includes):"<all>"}, filter: ${gp(e.filter)}, correlationId: ${typeof e.correlationId=="number"?e.correlationId:"<none>"})`}async setVerboseLogging(e){this.verboseLogging=e}};import{watch as Om,promises as Lm}from"fs";var us=class r extends A{constructor(e,n,i,o,s,a){super();this.request=e;this.recursiveWatcher=n;this.onDidFilesChange=i;this.onDidWatchFail=o;this.onLogMessage=s;this.verboseLogging=a;this.throttledFileChangesEmitter=this._register(new Ln({maxWorkChunkSize:100,throttleDelay:200,maxBufferedWork:1e4},e=>this.onDidFilesChange(e)));this.fileChangesAggregator=this._register(new Mi(e=>this.handleFileChanges(e),r.FILE_CHANGES_HANDLER_DELAY));this.cts=new fe;this.realPath=new Oe(async()=>{let e=this.request.path;try{e=await ae.realpath(this.request.path),this.request.path!==e&&this.trace(`correcting a path to watch that seems to be a symbolic link (original: ${this.request.path}, real: ${e})`)}catch{}return e});this._isReusingRecursiveWatcher=!1;this.didFail=!1;let l=!le;this.excludes=Tl(this.request.path,this.request.excludes,l),this.includes=this.request.includes?Tl(this.request.path,this.request.includes,l):void 0,this.filter=ss(this.request)?this.request.filter:void 0,this.ready=this.watch()}static{this.FILE_DELETE_HANDLER_DELAY=100}static{this.FILE_CHANGES_HANDLER_DELAY=75}get isReusingRecursiveWatcher(){return this._isReusingRecursiveWatcher}get failed(){return this.didFail}async watch(){try{let e=await Lm.stat(this.request.path);if(this.cts.token.isCancellationRequested)return;this._register(await this.doWatch(e.isDirectory()))}catch(e){e.code!=="ENOENT"?this.error(e):this.trace(`ignoring a path for watching who's stat info failed to resolve: ${this.request.path} (error: ${e})`),this.notifyWatchFailed()}}notifyWatchFailed(){this.didFail=!0,this.onDidWatchFail?.()}async doWatch(e){let n=new N;return this.doWatchWithExistingWatcher(e,n)?(this.trace(`reusing an existing recursive watcher for ${this.request.path}`),this._isReusingRecursiveWatcher=!0):(this._isReusingRecursiveWatcher=!1,await this.doWatchWithNodeJS(e,n)),n}doWatchWithExistingWatcher(e,n){if(e)return!1;let i=m.file(this.request.path),o=this.recursiveWatcher?.subscribe(this.request.path,async(s,a)=>{n.isDisposed||(s?await Zl(this.doWatch(e),n):a&&(typeof a.cId=="number"||typeof this.request.correlationId=="number")&&this.onFileChange({resource:i,type:a.type,cId:this.request.correlationId},!0))});return o?(n.add(o),!0):!1}async doWatchWithNodeJS(e,n){let i=await this.realPath.value;if(this.cts.token.isCancellationRequested)return;if(Ke&&bt(i,"/Volumes/",!0)){this.error(`Refusing to watch ${i} for changes using fs.watch() for possibly being a network share where watching is unreliable and unstable.`);return}let o=new fe(this.cts.token);n.add(O(()=>o.dispose(!0)));let s=new N;n.add(s);try{let a=m.file(this.request.path),l=ze(i),c=Om(i);s.add(O(()=>{c.removeAllListeners(),c.close()})),this.trace(`Started watching: '${i}'`);let d=new Set;if(e)try{for(let p of await ae.readdir(i))d.add(p)}catch(p){this.error(p)}if(o.token.isCancellationRequested)return;let u=new Map;s.add(O(()=>{for(let[,p]of u)p.dispose();u.clear()})),c.on("error",(p,h)=>{o.token.isCancellationRequested||(this.error(`Failed to watch ${i} for changes using fs.watch() (${p}, ${h})`),this.notifyWatchFailed())}),c.on("change",(p,h)=>{if(o.token.isCancellationRequested)return;this.verboseLogging&&this.traceWithCorrelation(`[raw] ["${p}"] ${h}`);let v="";if(h&&(v=h.toString(),Ke&&(v=qr(v))),!(!v||p!=="change"&&p!=="rename"))if(e)if(p==="rename"){u.get(v)?.dispose();let g=setTimeout(async()=>{if(u.delete(v),kn(v,l,!le)&&!await ae.exists(i)){this.onWatchedPathDeleted(a);return}if(o.token.isCancellationRequested)return;let E=await this.existsChildStrictCase(W(i,v));if(o.token.isCancellationRequested)return;let R;E?d.has(v)?R=0:(R=1,d.add(v)):(d.delete(v),R=2),this.onFileChange({resource:G(a,v),type:R,cId:this.request.correlationId})},r.FILE_DELETE_HANDLER_DELAY);u.set(v,O(()=>clearTimeout(g)))}else{let g;d.has(v)?g=0:(g=1,d.add(v)),this.onFileChange({resource:G(a,v),type:g,cId:this.request.correlationId})}else if(p==="rename"||!kn(v,l,!le)){let g=setTimeout(async()=>{let E=await ae.exists(i);o.token.isCancellationRequested||(E?(this.onFileChange({resource:a,type:0,cId:this.request.correlationId},!0),s.add(await this.doWatch(!1))):this.onWatchedPathDeleted(a))},r.FILE_DELETE_HANDLER_DELAY);s.clear(),s.add(O(()=>clearTimeout(g)))}else this.onFileChange({resource:a,type:0,cId:this.request.correlationId},!0)})}catch(a){if(o.token.isCancellationRequested)return;this.error(`Failed to watch ${i} for changes using fs.watch() (${a.toString()})`),this.notifyWatchFailed()}}onWatchedPathDeleted(e){this.warn("Watcher shutdown because watched path got deleted"),this.onFileChange({resource:e,type:2,cId:this.request.correlationId},!0),this.fileChangesAggregator.flush(),this.notifyWatchFailed()}onFileChange(e,n=!1){this.cts.token.isCancellationRequested||(this.verboseLogging&&this.traceWithCorrelation(`${e.type===1?"[ADDED]":e.type===2?"[DELETED]":"[CHANGED]"} ${e.resource.fsPath}`),!n&&this.excludes.some(i=>i(e.resource.fsPath))?this.verboseLogging&&this.traceWithCorrelation(` >> ignored (excluded) ${e.resource.fsPath}`):!n&&this.includes&&this.includes.length>0&&!this.includes.some(i=>i(e.resource.fsPath))?this.verboseLogging&&this.traceWithCorrelation(` >> ignored (not included) ${e.resource.fsPath}`):this.fileChangesAggregator.work(e))}handleFileChanges(e){let n=fp(e),i=[];for(let s of n){if(hp(s,this.filter)){this.verboseLogging&&this.traceWithCorrelation(` >> ignored (filtered) ${s.resource.fsPath}`);continue}i.push(s)}if(i.length===0)return;if(this.verboseLogging)for(let s of i)this.traceWithCorrelation(` >> normalized ${s.type===1?"[ADDED]":s.type===2?"[DELETED]":"[CHANGED]"} ${s.resource.fsPath}`);this.throttledFileChangesEmitter.work(i)?this.throttledFileChangesEmitter.pending>0&&this.trace(`started throttling events due to large amount of file change events at once (pending: ${this.throttledFileChangesEmitter.pending}, most recent change: ${i[0].resource.fsPath}). Use 'files.watcherExclude' setting to exclude folders with lots of changing files (e.g. compilation output).`):this.warn(`started ignoring events due to too many file change events at once (incoming: ${i.length}, most recent change: ${i[0].resource.fsPath}). Use 'files.watcherExclude' setting to exclude folders with lots of changing files (e.g. compilation output).`)}async existsChildStrictCase(e){if(le)return ae.exists(e);try{let n=ze(e);return(await ae.readdir(he(e))).some(o=>o===n)}catch(n){return this.trace(n),!1}}setVerboseLogging(e){this.verboseLogging=e}error(e){this.cts.token.isCancellationRequested||this.onLogMessage?.({type:"error",message:`[File Watcher (node.js)] ${e}`})}warn(e){this.cts.token.isCancellationRequested||this.onLogMessage?.({type:"warn",message:`[File Watcher (node.js)] ${e}`})}trace(e){!this.cts.token.isCancellationRequested&&this.verboseLogging&&this.onLogMessage?.({type:"trace",message:`[File Watcher (node.js)] ${e}`})}traceWithCorrelation(e){!this.cts.token.isCancellationRequested&&this.verboseLogging&&this.trace(`${e}${typeof this.request.correlationId=="number"?` <${this.request.correlationId}> `:""}`)}dispose(){this.cts.dispose(!0),super.dispose()}};var ds=class extends cs{constructor(e){super();this.recursiveWatcher=e;this.onDidError=z.None;this._watchers=new Map;this.worker=this._register(new kt)}get watchers(){return this._watchers.values()}async doWatch(e){e=this.removeDuplicateRequests(e);let n=[],i=new Set(Array.from(this.watchers));for(let o of e){let s=this._watchers.get(this.requestToWatcherKey(o));s&&qa(s.request.excludes,o.excludes)&&qa(s.request.includes,o.includes)?i.delete(s):n.push(o)}n.length&&this.trace(`Request to start watching: ${n.map(o=>this.requestToString(o)).join(",")}`),i.size&&this.trace(`Request to stop watching: ${Array.from(i).map(o=>this.requestToString(o.request)).join(",")}`),this.worker.clear();for(let o of i)this.stopWatching(o);this.createWatchWorker().work(n)}createWatchWorker(){return this.worker.value=new Ln({maxWorkChunkSize:100,throttleDelay:100,maxBufferedWork:Number.MAX_VALUE},e=>{for(let n of e)this.startWatching(n)}),this.worker.value}requestToWatcherKey(e){return typeof e.correlationId=="number"?e.correlationId:this.pathToWatcherKey(e.path)}pathToWatcherKey(e){return le?e:e.toLowerCase()}startWatching(e){let n=new us(e,this.recursiveWatcher,o=>this._onDidChangeFile.fire(o),()=>this._onDidWatchFail.fire(e),o=>this._onDidLogMessage.fire(o),this.verboseLogging),i={request:e,instance:n};this._watchers.set(this.requestToWatcherKey(e),i)}async stop(){await super.stop();for(let e of this.watchers)this.stopWatching(e)}stopWatching(e){this.trace("stopping file watcher",e),this._watchers.delete(this.requestToWatcherKey(e.request)),e.instance.dispose()}removeDuplicateRequests(e){let n=new Map;for(let i of e){let o=n.get(i.correlationId);o||(o=new Map,n.set(i.correlationId,o));let s=this.pathToWatcherKey(i.path);o.has(s)&&this.trace(`ignoring a request for watching who's path is already watched: ${this.requestToString(i)}`),o.set(s,i)}return Array.from(n.values()).flatMap(i=>Array.from(i.values()))}async setVerboseLogging(e){super.setVerboseLogging(e);for(let n of this.watchers)n.instance.setVerboseLogging(e)}trace(e,n){this.verboseLogging&&this._onDidLogMessage.fire({type:"trace",message:this.toMessage(e,n)})}warn(e){this._onDidLogMessage.fire({type:"warn",message:this.toMessage(e)})}toMessage(e,n){return n?`[File Watcher (node.js)] ${e} (${this.requestToString(n.request)})`:`[File Watcher (node.js)] ${e}`}};var ps=class extends is{constructor(t,e,n){super(t,e,n),this.init()}createWatcher(t){return t.add(new ds(void 0))}};var fs=class r extends as{constructor(){super(...arguments);this.onDidChangeCapabilities=z.None;this.resourceLocks=new ht(e=>Mt.getComparisonKey(e));this.mapHandleToPos=new Map;this.mapHandleToLock=new Map;this.writeHandles=new Map}static{this.TRACE_LOG_RESOURCE_LOCKS=!1}get capabilities(){return this._capabilities||(this._capabilities=1040414,le&&(this._capabilities|=1024)),this._capabilities}async stat(e){try{let{stat:n,symbolicLink:i}=await ct.stat(this.toFilePath(e)),o;return(n.mode&128)===0&&(o=2),(n.mode&Sl.S_IXUSR||n.mode&Sl.S_IXGRP||n.mode&Sl.S_IXOTH)&&(o=(o??0)|4),{type:this.toType(n,i),ctime:n.birthtime.getTime(),mtime:n.mtime.getTime(),size:n.size,permissions:o}}catch(n){throw this.toFileSystemProviderError(n)}}async statIgnoreError(e){try{return await this.stat(e)}catch{return}}async realpath(e){let n=this.toFilePath(e);return ae.realpath(n)}async readdir(e){try{let n=await ae.readdir(this.toFilePath(e),{withFileTypes:!0}),i=[];return await Promise.all(n.map(async o=>{try{let s;o.isSymbolicLink()?s=(await this.stat(G(e,o.name))).type:s=this.toType(o),i.push([o.name,s])}catch(s){this.logService.trace(s)}})),i}catch(n){throw this.toFileSystemProviderError(n)}}toType(e,n){let i;return n?.dangling?i=0:e.isFile()?i=1:e.isDirectory()?i=2:i=0,n&&(i|=64),i}async createResourceLock(e){let n=this.toFilePath(e);this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - request to acquire resource lock (${n})`);let i;for(;i=this.resourceLocks.get(e);)this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - waiting for resource lock to be released (${n})`),await i.wait();let o=new Ui;return this.resourceLocks.set(e,o),this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - new resource lock created (${n})`),O(()=>{this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - resource lock dispose() (${n})`),this.resourceLocks.get(e)===o&&(this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - resource lock removed from resource-lock map (${n})`),this.resourceLocks.delete(e)),this.traceLock(`[Disk FileSystemProvider]: createResourceLock() - resource lock barrier open() (${n})`),o.open()})}async readFile(e,n){let i;try{n?.atomic&&(this.traceLock(`[Disk FileSystemProvider]: atomic read operation started (${this.toFilePath(e)})`),i=await this.createResourceLock(e));let o=this.toFilePath(e);return await yn.readFile(o)}catch(o){throw this.toFileSystemProviderError(o)}finally{i?.dispose()}}traceLock(e){r.TRACE_LOG_RESOURCE_LOCKS&&this.logService.trace(e)}readFileStream(e,n,i){let o=ln(s=>S.concat(s.map(a=>S.wrap(a))).buffer);return ns(this,e,o,s=>s.buffer,{...n,bufferSize:256*1024},i),o}async writeFile(e,n,i){return i?.atomic!==!1&&i?.atomic?.postfix&&await this.canWriteFileAtomic(e)?this.doWriteFileAtomic(e,G(Li(e),`${Xe(e)}${i.atomic.postfix}`),n,i):this.doWriteFile(e,n,i)}async canWriteFileAtomic(e){try{let n=this.toFilePath(e),{symbolicLink:i}=await ct.stat(n);if(i)return!1}catch{}return!0}async doWriteFileAtomic(e,n,i,o){let s=new N;try{s.add(await this.createResourceLock(e)),s.add(await this.createResourceLock(n)),await this.doWriteFile(n,i,{...o,create:!0,overwrite:!0},!0);try{await this.rename(n,e,{overwrite:!0})}catch(a){try{await this.delete(n,{recursive:!1,useTrash:!1,atomic:!1})}catch{}throw a}}finally{s.dispose()}}async doWriteFile(e,n,i,o){let s;try{let a=this.toFilePath(e);if(!i.create||!i.overwrite){if(await ae.exists(a)){if(!i.overwrite)throw pe(f(2169,null),"EntryExists")}else if(!i.create)throw pe(f(2172,null),"EntryNotFound")}s=await this.open(e,{create:!0,append:i.append,unlock:i.unlock},o),await this.write(s,0,n,0,n.byteLength)}catch(a){throw await this.toFileSystemProviderWriteError(e,a)}finally{typeof s=="number"&&await this.close(s)}}static{this.canFlush=!0}static configureFlushOnWrite(e){r.canFlush=e}async open(e,n,i){let o=this.toFilePath(e),s;fn(n)&&!i&&(s=await this.createResourceLock(e));let a;try{if(fn(n)&&n.unlock)try{let{stat:l}=await ct.stat(o);l.mode&128||await yn.chmod(o,l.mode|128)}catch(l){l.code!=="ENOENT"&&this.logService.trace(l)}if(H&&fn(n)&&!n.append)try{a=await ae.open(o,"r+"),await ae.ftruncate(a,0)}catch(l){if(l.code!=="ENOENT"&&this.logService.trace(l),typeof a=="number"){try{await ae.close(a)}catch(c){this.logService.trace(c)}a=void 0}}typeof a!="number"&&(a=await ae.open(o,fn(n)?n.append?"a":"w":"r"))}catch(l){throw s?.dispose(),fn(n)?await this.toFileSystemProviderWriteError(e,l):this.toFileSystemProviderError(l)}if(this.mapHandleToPos.set(a,0),fn(n)&&this.writeHandles.set(a,e),s){let l=this.mapHandleToLock.get(a);this.traceLock(`[Disk FileSystemProvider]: open() - storing lock for handle ${a} (${o})`),this.mapHandleToLock.set(a,s),l&&(this.traceLock(`[Disk FileSystemProvider]: open() - disposing a previous lock that was still stored on same handle ${a} (${o})`),l.dispose())}return a}async close(e){let n=this.mapHandleToLock.get(e);try{if(this.mapHandleToPos.delete(e),this.writeHandles.delete(e)&&r.canFlush)try{await ae.fdatasync(e)}catch(i){r.configureFlushOnWrite(!1),this.logService.error(i)}return await ae.close(e)}catch(i){throw this.toFileSystemProviderError(i)}finally{n&&(this.mapHandleToLock.get(e)===n&&(this.traceLock(`[Disk FileSystemProvider]: close() - resource lock removed from handle-lock map ${e}`),this.mapHandleToLock.delete(e)),this.traceLock(`[Disk FileSystemProvider]: close() - disposing lock for handle ${e}`),n.dispose())}}async read(e,n,i,o,s){let a=this.normalizePos(e,n),l=null;try{l=(await ae.read(e,i,o,s,a)).bytesRead}catch(c){throw this.toFileSystemProviderError(c)}finally{this.updatePos(e,a,l)}return l}normalizePos(e,n){return n===this.mapHandleToPos.get(e)?null:n}updatePos(e,n,i){let o=this.mapHandleToPos.get(e);typeof o=="number"&&(typeof n=="number"||(typeof i=="number"?this.mapHandleToPos.set(e,o+i):this.mapHandleToPos.delete(e)))}async write(e,n,i,o,s){return Xc(()=>this.doWrite(e,n,i,o,s),100,3)}async doWrite(e,n,i,o,s){let a=this.normalizePos(e,n),l=null;try{l=(await ae.write(e,i,o,s,a)).bytesWritten}catch(c){throw await this.toFileSystemProviderWriteError(this.writeHandles.get(e),c)}finally{this.updatePos(e,a,l)}return l}async mkdir(e){try{await yn.mkdir(this.toFilePath(e))}catch(n){throw this.toFileSystemProviderError(n)}}async delete(e,n){try{let i=this.toFilePath(e);if(n.recursive){let o;n?.atomic!==!1&&n.atomic.postfix&&(o=W(he(i),`${ze(i)}${n.atomic.postfix}`)),await ae.rm(i,1,o)}else try{await yn.unlink(i)}catch(o){if(o.code==="EPERM"||o.code==="EISDIR"){let s=!1;try{let{stat:a,symbolicLink:l}=await ct.stat(i);s=a.isDirectory()&&!l}catch{}if(s)await yn.rmdir(i);else throw o}else throw o}}catch(i){throw this.toFileSystemProviderError(i)}}async rename(e,n,i){let o=this.toFilePath(e),s=this.toFilePath(n);if(o!==s)try{await this.validateMoveCopy(e,n,"move",i.overwrite),await ae.rename(o,s)}catch(a){throw(a.code==="EINVAL"||a.code==="EBUSY"||a.code==="ENAMETOOLONG")&&(a=new Error(f(2173,null,ze(o),ze(he(s)),a.toString()))),this.toFileSystemProviderError(a)}}async copy(e,n,i){let o=this.toFilePath(e),s=this.toFilePath(n);if(o!==s)try{await this.validateMoveCopy(e,n,"copy",i.overwrite),await ae.copy(o,s,{preserveSymlinks:!0})}catch(a){throw(a.code==="EINVAL"||a.code==="EBUSY"||a.code==="ENAMETOOLONG")&&(a=new Error(f(2167,null,ze(o),ze(he(s)),a.toString()))),this.toFileSystemProviderError(a)}}async validateMoveCopy(e,n,i,o){let s=this.toFilePath(e),a=this.toFilePath(n),l=!1;if(this.capabilities&1024||(l=kn(s,a,!0)),l){if(i==="copy")throw pe(f(2168,null),"EntryExists");if(i==="move")return}let d=await this.statIgnoreError(e);if(!d)throw pe(f(2171,null),"EntryNotFound");let u=await this.statIgnoreError(n);if(u){if(!o)throw pe(f(2170,null),"EntryExists");(d.type&1)!==0&&(u.type&1)!==0||await this.delete(n,{recursive:!0,useTrash:!1,atomic:!1})}}async cloneFile(e,n){return this.doCloneFile(e,n,!1)}async doCloneFile(e,n,i){let o=this.toFilePath(e),s=this.toFilePath(n),a=!!(this.capabilities&1024);if(kn(o,s,!a))return;let l=new N;try{l.add(await this.createResourceLock(e)),l.add(await this.createResourceLock(n)),i&&await yn.mkdir(he(s),{recursive:!0}),await yn.copyFile(o,s)}catch(c){if(c.code==="ENOENT"&&!i)return this.doCloneFile(e,n,!0);throw this.toFileSystemProviderError(c)}finally{l.dispose()}}createUniversalWatcher(e,n,i){return new ls(o=>e(o),o=>n(o),i)}createNonRecursiveWatcher(e,n,i){return new ps(o=>e(o),o=>n(o),i)}toFileSystemProviderError(e){if(e instanceof Gn)return e;let n=e,i;switch(e.code){case"ENOENT":i="EntryNotFound";break;case"EISDIR":i="EntryIsADirectory";break;case"ENOTDIR":i="EntryNotADirectory";break;case"EEXIST":i="EntryExists";break;case"EPERM":case"EACCES":i="NoPermissions";break;case"ERR_UNC_HOST_NOT_ALLOWED":n=`${e.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.`,i="Unknown";break;default:i="Unknown"}return pe(n,i)}async toFileSystemProviderWriteError(e,n){let i=this.toFileSystemProviderError(n);if(e&&i.code==="NoPermissions")try{let{stat:o}=await ct.stat(this.toFilePath(e));o.mode&128||(i=pe(n,"EntryWriteLocked"))}catch(o){this.logService.trace(o)}return i}};var Ct=class{constructor(t,e=[],n=!1){this.ctor=t,this.staticArguments=e,this.supportsDelayedInstantiation=n}};var _l=class{constructor(t,e){this.key=t;this.data=e;this.incoming=new Map;this.outgoing=new Map}},pi=class{constructor(t){this._hashFn=t;this._nodes=new Map}roots(){let t=[];for(let e of this._nodes.values())e.outgoing.size===0&&t.push(e);return t}insertEdge(t,e){let n=this.lookupOrInsertNode(t),i=this.lookupOrInsertNode(e);n.outgoing.set(i.key,i),i.incoming.set(n.key,n)}removeNode(t){let e=this._hashFn(t);this._nodes.delete(e);for(let n of this._nodes.values())n.outgoing.delete(e),n.incoming.delete(e)}lookupOrInsertNode(t){let e=this._hashFn(t),n=this._nodes.get(e);return n||(n=new _l(e,t),this._nodes.set(e,n)),n}lookup(t){return this._nodes.get(this._hashFn(t))}isEmpty(){return this._nodes.size===0}toString(){let t=[];for(let[e,n]of this._nodes)t.push(`${e}
	(-> incoming)[${[...n.incoming.keys()].join(", ")}]
	(outgoing ->)[${[...n.outgoing.keys()].join(",")}]
`);return t.join(`
`)}findCycleSlow(){for(let[t,e]of this._nodes){let n=new Set([t]),i=this._findCycle(e,n);if(i)return i}}_findCycle(t,e){for(let[n,i]of t.outgoing){if(e.has(n))return[...e,n].join(" -> ");e.add(n);let o=this._findCycle(i,e);if(o)return o;e.delete(n)}}};var fr=class{constructor(...t){this._entries=new Map;for(let[e,n]of t)this.set(e,n)}set(t,e){let n=this._entries.get(t);return this._entries.set(t,e),n}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}};var Fm=!1,hs=class extends Error{constructor(t){super("cyclic dependency between services"),this.message=t.findCycleSlow()??`UNABLE to detect cycle, dumping graph: 
${t.toString()}`}},gs=class r{constructor(t=new fr,e=!1,n,i=Fm){this._services=t;this._strict=e;this._parent=n;this._enableTracing=i;this._isDisposed=!1;this._servicesToMaybeDispose=new Set;this._children=new Set;this._activeInstantiations=new Set;this._services.set(Zi,this),this._globalGraph=i?n?._globalGraph??new pi(o=>o):void 0}dispose(){if(!this._isDisposed){this._isDisposed=!0,Ae(this._children),this._children.clear();for(let t of this._servicesToMaybeDispose)Si(t)&&t.dispose();this._servicesToMaybeDispose.clear()}}_throwIfDisposed(){if(this._isDisposed)throw new Error("InstantiationService has been disposed")}createChild(t,e){this._throwIfDisposed();let n=this,i=new class extends r{dispose(){n._children.delete(i),super.dispose()}}(t,this._strict,this,this._enableTracing);return this._children.add(i),e?.add(i),i}invokeFunction(t,...e){this._throwIfDisposed();let n=fi.traceInvocation(this._enableTracing,t),i=!1;try{return t({get:s=>{if(i)throw vi("service accessor is only valid during the invocation of its target method");let a=this._getOrCreateServiceInstance(s,n);return a||this._throwIfStrict(`[invokeFunction] unknown service '${s}'`,!1),a}},...e)}finally{i=!0,n.stop()}}createInstance(t,...e){this._throwIfDisposed();let n,i;return t instanceof Ct?(n=fi.traceCreation(this._enableTracing,t.ctor),i=this._createInstance(t.ctor,t.staticArguments.concat(e),n)):(n=fi.traceCreation(this._enableTracing,t),i=this._createInstance(t,e,n)),n.stop(),i}_createInstance(t,e=[],n){let i=Ze.getServiceDependencies(t).sort((a,l)=>a.index-l.index),o=[];for(let a of i){let l=this._getOrCreateServiceInstance(a.id,n);l||this._throwIfStrict(`[createInstance] ${t.name} depends on UNKNOWN service ${a.id}.`,!1),o.push(l)}let s=i.length>0?i[0].index:e.length;if(e.length!==s){console.trace(`[createInstance] First service dependency of ${t.name} at position ${s+1} conflicts with ${e.length} static arguments`);let a=s-e.length;a>0?e=e.concat(new Array(a)):e=e.slice(0,s)}return Reflect.construct(t,e.concat(o))}_setCreatedServiceInstance(t,e){if(this._services.get(t)instanceof Ct)this._services.set(t,e);else if(this._parent)this._parent._setCreatedServiceInstance(t,e);else throw new Error("illegalState - setting UNKNOWN service instance")}_getServiceInstanceOrDescriptor(t){let e=this._services.get(t);return!e&&this._parent?this._parent._getServiceInstanceOrDescriptor(t):e}_getOrCreateServiceInstance(t,e){this._globalGraph&&this._globalGraphImplicitDependency&&this._globalGraph.insertEdge(this._globalGraphImplicitDependency,String(t));let n=this._getServiceInstanceOrDescriptor(t);return n instanceof Ct?this._safeCreateAndCacheServiceInstance(t,n,e.branch(t,!0)):(e.branch(t,!1),n)}_safeCreateAndCacheServiceInstance(t,e,n){if(this._activeInstantiations.has(t))throw new Error(`illegal state - RECURSIVELY instantiating service '${t}'`);this._activeInstantiations.add(t);try{return this._createAndCacheServiceInstance(t,e,n)}finally{this._activeInstantiations.delete(t)}}_createAndCacheServiceInstance(t,e,n){let i=new pi(l=>l.id.toString()),o=0,s=[{id:t,desc:e,_trace:n}],a=new Set;for(;s.length;){let l=s.pop();if(!a.has(String(l.id))){if(a.add(String(l.id)),i.lookupOrInsertNode(l),o++>1e3)throw new hs(i);for(let c of Ze.getServiceDependencies(l.desc.ctor)){let d=this._getServiceInstanceOrDescriptor(c.id);if(d||this._throwIfStrict(`[createInstance] ${t} depends on ${c.id} which is NOT registered.`,!0),this._globalGraph?.insertEdge(String(l.id),String(c.id)),d instanceof Ct){let u={id:c.id,desc:d,_trace:l._trace.branch(c.id,!0)};i.insertEdge(l,u),s.push(u)}}}}for(;;){let l=i.roots();if(l.length===0){if(!i.isEmpty())throw new hs(i);break}for(let{data:c}of l){if(this._getServiceInstanceOrDescriptor(c.id)instanceof Ct){let u=this._createServiceInstanceWithOwner(c.id,c.desc.ctor,c.desc.staticArguments,c.desc.supportsDelayedInstantiation,c._trace);this._setCreatedServiceInstance(c.id,u)}i.removeNode(c)}}return this._getServiceInstanceOrDescriptor(t)}_createServiceInstanceWithOwner(t,e,n=[],i,o){if(this._services.get(t)instanceof Ct)return this._createServiceInstance(t,e,n,i,o,this._servicesToMaybeDispose);if(this._parent)return this._parent._createServiceInstanceWithOwner(t,e,n,i,o);throw new Error(`illegalState - creating UNKNOWN service instance ${e.name}`)}_createServiceInstance(t,e,n=[],i,o,s){if(i){let a=new r(void 0,this._strict,this,this._enableTracing);a._globalGraphImplicitDependency=String(t);let l=new Map,c=new Wi(()=>{let d=a._createInstance(e,n,o);for(let[u,p]of l){let h=d[u];if(typeof h=="function")for(let v of p)v.disposable=h.apply(d,v.listener)}return l.clear(),s.add(d),d});return new Proxy(Object.create(null),{get(d,u){if(!c.isInitialized&&typeof u=="string"&&(u.startsWith("onDid")||u.startsWith("onWill"))){let v=l.get(u);return v||(v=new _r,l.set(u,v)),(E,R,C)=>{if(c.isInitialized)return c.value[u](E,R,C);{let J={listener:[E,R,C],disposable:void 0},rt=v.push(J);return O(()=>{rt(),J.disposable?.dispose()})}}}if(u in d)return d[u];let p=c.value,h=p[u];return typeof h!="function"||(h=h.bind(p),d[u]=h),h},set(d,u,p){return c.value[u]=p,!0},getPrototypeOf(d){return e.prototype}})}else{let a=this._createInstance(e,n,o);return s.add(a),a}}_throwIfStrict(t,e){if(e&&console.warn(t),this._strict)throw new Error(t)}};var fi=class r{constructor(t,e){this.type=t;this.name=e;this._start=Date.now();this._dep=[]}static{this.all=new Set}static{this._None=new class extends r{constructor(){super(0,null)}stop(){}branch(){return this}}}static traceInvocation(t,e){return t?new r(2,e.name||new Error().stack.split(`
`).slice(3,4).join(`
`)):r._None}static traceCreation(t,e){return t?new r(1,e.name):r._None}static{this._totals=0}branch(t,e){let n=new r(3,t.toString());return this._dep.push([t,e,n]),n}stop(){let t=Date.now()-this._start;r._totals+=t;let e=!1;function n(o,s){let a=[],l=new Array(o+1).join("	");for(let[c,d,u]of s._dep)if(d&&u){e=!0,a.push(`${l}CREATES -> ${c}`);let p=n(o+1,u);p&&a.push(p)}else a.push(`${l}uses -> ${c}`);return a.join(`
`)}let i=[`${this.type===1?"CREATE":"CALL"} ${this.name}`,`${n(1,this)}`,`DONE, took ${t.toFixed(2)}ms (grand total ${r._totals.toFixed(2)}ms)`];(t>2||e)&&r.all.add(i.join(`
`))}};import*as Ip from"fs";var mp=[{version:1,sql:[`CREATE TABLE IF NOT EXISTS turns (
				id TEXT PRIMARY KEY NOT NULL
			)`,`CREATE TABLE IF NOT EXISTS file_edits (
				turn_id        TEXT    NOT NULL REFERENCES turns(id) ON DELETE CASCADE,
				tool_call_id   TEXT    NOT NULL,
				file_path      TEXT    NOT NULL,
				before_content BLOB   NOT NULL,
				after_content  BLOB   NOT NULL,
				added_lines    INTEGER,
				removed_lines  INTEGER,
				PRIMARY KEY (tool_call_id, file_path)
			)`].join(`;
`)},{version:2,sql:`CREATE TABLE IF NOT EXISTS session_metadata (
			key   TEXT PRIMARY KEY NOT NULL,
			value TEXT NOT NULL
		)`},{version:3,sql:[`CREATE TABLE file_edits_v3 (
				turn_id        TEXT    NOT NULL REFERENCES turns(id) ON DELETE CASCADE,
				tool_call_id   TEXT    NOT NULL,
				file_path      TEXT    NOT NULL,
				edit_type      TEXT    NOT NULL DEFAULT 'edit',
				original_path  TEXT,
				before_content BLOB,
				after_content  BLOB,
				added_lines    INTEGER,
				removed_lines  INTEGER,
				PRIMARY KEY (tool_call_id, file_path)
			)`,`INSERT INTO file_edits_v3 (turn_id, tool_call_id, file_path, edit_type, before_content, after_content, added_lines, removed_lines)
				SELECT turn_id, tool_call_id, file_path, 'edit', before_content, after_content, added_lines, removed_lines FROM file_edits`,"DROP TABLE file_edits","ALTER TABLE file_edits_v3 RENAME TO file_edits"].join(`;
`)}];function hr(r,t){return new Promise((e,n)=>{r.exec(t,i=>i?n(i):e())})}function hi(r,t,e){return new Promise((n,i)=>{r.run(t,e,function(o){if(o)return i(o);n({changes:this.changes,lastID:this.lastID})})})}function xl(r,t,e){return new Promise((n,i)=>{r.get(t,e,(o,s)=>{if(o)return i(o);n(s)})})}function vp(r,t,e){return new Promise((n,i)=>{r.all(t,e,(o,s)=>{if(o)return i(o);n(s)})})}function yp(r){return new Promise((t,e)=>{r.close(n=>n?e(n):t())})}function Um(r){return new Promise((t,e)=>{import("@vscode/sqlite3").then(n=>{let i=new n.default.Database(r,o=>{if(o)return e(o);t(i)})},e)})}async function Nm(r,t){await hr(r,"PRAGMA foreign_keys = ON");let n=(await xl(r,"PRAGMA user_version",[]))?.user_version??0,i=t.filter(o=>o.version>n).sort((o,s)=>o.version-s.version);if(i.length!==0){await hr(r,"BEGIN TRANSACTION");try{for(let o of i)await hr(r,o.sql),await hr(r,`PRAGMA user_version = ${o.version}`);await hr(r,"COMMIT")}catch(o){throw await hr(r,"ROLLBACK"),o}}}var ms=class r{constructor(t,e=mp){this._path=t;this._migrations=e;this._fileEditSequencer=new Wt}static async open(t,e=mp){let n=new r(t,e);return await n._ensureDb(),n}_ensureDb(){return this._closed?Promise.reject(new Error("SessionDatabase has been disposed")):(this._dbPromise||(this._dbPromise=(async()=>{await Ip.promises.mkdir(he(this._path),{recursive:!0});let t=await Um(this._path);try{await Nm(t,this._migrations)}catch(e){throw await yp(t),this._dbPromise=void 0,e}if(this._closed)throw await yp(t),new Error("SessionDatabase has been disposed");return t})()),this._dbPromise)}async getAllTables(){let t=await this._ensureDb();return(await vp(t,"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name",[])).map(n=>n.name)}async createTurn(t){let e=await this._ensureDb();await hi(e,"INSERT OR IGNORE INTO turns (id) VALUES (?)",[t])}async deleteTurn(t){let e=await this._ensureDb();await hi(e,"DELETE FROM turns WHERE id = ?",[t])}async storeFileEdit(t){return this._fileEditSequencer.queue(t.filePath,async()=>{let e=await this._ensureDb();await hi(e,"INSERT OR IGNORE INTO turns (id) VALUES (?)",[t.turnId]),await hi(e,`INSERT OR REPLACE INTO file_edits
					(turn_id, tool_call_id, file_path, edit_type, original_path, before_content, after_content, added_lines, removed_lines)
				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,[t.turnId,t.toolCallId,t.filePath,t.kind,t.originalPath??null,t.beforeContent?Buffer.from(t.beforeContent):null,t.afterContent?Buffer.from(t.afterContent):null,t.addedLines??null,t.removedLines??null])})}async getFileEdits(t){if(t.length===0)return[];let e=await this._ensureDb(),n=t.map(()=>"?").join(",");return(await vp(e,`SELECT turn_id, tool_call_id, file_path, edit_type, original_path, added_lines, removed_lines
				FROM file_edits
				WHERE tool_call_id IN (${n})
				ORDER BY rowid`,t)).map(o=>({turnId:o.turn_id,toolCallId:o.tool_call_id,filePath:o.file_path,kind:o.edit_type??"edit",originalPath:o.original_path??void 0,addedLines:o.added_lines??void 0,removedLines:o.removed_lines??void 0}))}async readFileEditContent(t,e){return this._fileEditSequencer.queue(e,async()=>{let n=await this._ensureDb(),i=await xl(n,`SELECT before_content, after_content
					FROM file_edits
					WHERE tool_call_id = ? AND file_path = ?`,[t,e]);if(i)return{beforeContent:i.before_content?bp(i.before_content):void 0,afterContent:i.after_content?bp(i.after_content):void 0}})}async getMetadata(t){let e=await this._ensureDb();return(await xl(e,"SELECT value FROM session_metadata WHERE key = ?",[t]))?.value}async setMetadata(t,e){let n=await this._ensureDb();await hi(n,"INSERT OR REPLACE INTO session_metadata (key, value) VALUES (?, ?)",[t,e])}async close(){await(this._closed??=this._dbPromise?.then(t=>t.close()).catch(()=>{})||!0)}dispose(){this.close()}};function bp(r){return r instanceof Buffer?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r instanceof Uint8Array?r:typeof r=="string"?new TextEncoder().encode(r):new Uint8Array(0)}var Rl=class extends Ti{constructor(e,n){super();this._getDbPath=e;this._logService=n}createReferencedObject(e){let n=this._getDbPath(e);return this._logService.trace(`[SessionDataService] Opening database: ${n}`),new ms(n)}destroyReferencedObject(e,n){n.dispose()}},gr=class{constructor(t,e,n,i){this._fileService=e;this._logService=n;this._basePath=m.joinPath(t,"agentSessionData"),this._databases=new Rl(i??(o=>m.joinPath(this._basePath,o,"session.db").fsPath),this._logService)}getSessionDataDir(t){return this.getSessionDataDirById(ie.id(t))}getSessionDataDirById(t){let e=t.replace(/[^a-zA-Z0-9_.-]/g,"-");return m.joinPath(this._basePath,e)}_sanitizedSessionKey(t){return ie.id(t).replace(/[^a-zA-Z0-9_.-]/g,"-")}openDatabase(t){return this._databases.acquire(this._sanitizedSessionKey(t))}async tryOpenDatabase(t){let e=this._sanitizedSessionKey(t),n=m.joinPath(this._basePath,e,"session.db");if(await this._fileService.exists(n))return this._databases.acquire(e)}async deleteSessionData(t){let e=this.getSessionDataDir(t);try{await this._fileService.exists(e)&&(await this._fileService.del(e,{recursive:!0}),this._logService.trace(`[SessionDataService] Deleted session data: ${e.toString()}`))}catch(n){this._logService.warn(`[SessionDataService] Failed to delete session data: ${e.toString()}`,n)}}async cleanupOrphanedData(t){try{if(!await this._fileService.exists(this._basePath))return;let n=await this._fileService.resolve(this._basePath);if(!n.children)return;let i=[];for(let o of n.children){if(!o.isDirectory)continue;let s=o.name;t.has(s)||(this._logService.trace(`[SessionDataService] Cleaning up orphaned session data: ${s}`),i.push(this._fileService.del(o.resource,{recursive:!0}).catch(a=>{this._logService.warn(`[SessionDataService] Failed to clean up orphaned data: ${s}`,a)})))}await Promise.all(i)}catch(e){this._logService.warn("[SessionDataService] Failed to run orphan cleanup",e)}}};gr=D([re(1,tt),re(2,Ce)],gr);var vs=class extends A{constructor(){super(...arguments);this.capabilities=1026;this._onDidChangeCapabilities=this._register(new b);this.onDidChangeCapabilities=this._onDidChangeCapabilities.event;this._onDidChangeFile=this._register(new b);this.onDidChangeFile=this._onDidChangeFile.event;this._authorityToConnection=new Map}registerAuthority(e,n){return this._authorityToConnection.set(e,n),O(()=>this._authorityToConnection.delete(e))}watch(){return A.None}async stat(e){let n=e.path;if(n==="/"||n==="")return{type:2,mtime:0,ctime:0,size:0,permissions:1};let i=this._decodeUri(e);if(i.scheme==="session-db")return{type:1,mtime:0,ctime:0,size:0,permissions:1};if(i.path==="/"||i.path==="")return{type:2,mtime:0,ctime:0,size:0,permissions:1};let o=Li(e),s=Xe(e),l=(await this._listDirectory(e.authority,o)).find(c=>c.name===s);if(!l)throw pe(`File not found: ${n}`,"EntryNotFound");return{type:l.type==="directory"?2:1,mtime:0,ctime:0,size:0,permissions:1}}async readdir(e){return(await this._listDirectory(e.authority,e)).map(i=>[i.name,i.type==="directory"?2:1])}async readFile(e){let n=this._getConnection(e.authority);try{let i=this._decodeUri(e),o=await n.resourceRead(i);return o.encoding==="base64"?Ki(o.data).buffer:S.fromString(o.data).buffer}catch(i){throw pe(i instanceof Error?i.message:String(i),"EntryNotFound")}}async writeFile(e,n,i){let o=this._getConnection(e.authority);try{let s=this._decodeUri(e);await o.resourceWrite({uri:s.toString(),data:S.wrap(n).toString(),encoding:"utf-8"})}catch(s){throw pe(s instanceof Error?s.message:String(s),"NoPermissions")}}async mkdir(){throw pe("mkdir not supported on remote filesystem","NoPermissions")}async delete(e,n){let i=this._getConnection(e.authority);try{let o=this._decodeUri(e);await i.resourceDelete({uri:o.toString(),recursive:n.recursive})}catch(o){throw pe(o instanceof Error?o.message:String(o),"NoPermissions")}}async rename(e,n,i){let o=this._getConnection(e.authority);try{let s=this._decodeUri(e),a=this._decodeUri(n);await o.resourceMove({source:s.toString(),destination:a.toString(),failIfExists:!i.overwrite})}catch(s){throw pe(s instanceof Error?s.message:String(s),"NoPermissions")}}_getConnection(e){let n=this._authorityToConnection.get(e);if(!n)throw pe(`No connection for authority: ${e}`,"Unavailable");return n}async _listDirectory(e,n){let i=this._getConnection(e);try{let o=this._decodeUri(n);return(await i.resourceList(o)).entries}catch(o){throw pe(o instanceof Error?o.message:String(o),"Unavailable")}}};var El="vscode-agent-client";function Tp(r,t){let e=r.authority||"-";return m.from({scheme:El,authority:t,path:`/${r.scheme}/${e}${r.path}`})}function Sp(r){let t=r.path,e=t.indexOf("/",1);if(e===-1)return m.from({scheme:"file",path:t});let n=t.substring(1,e),i=t.indexOf("/",e+1);if(i===-1){let a=t.substring(e+1);return m.from({scheme:n,authority:a==="-"?"":a,path:"/"})}let o=t.substring(e+1,i);o==="-"&&(o="");let s=t.substring(i);return m.from({scheme:n,authority:o||void 0,path:s})}var ys=class extends vs{_decodeUri(t){return Sp(t)}};var Mm=20,mr=class{constructor(t,e,n,i=Mm){this._fileService=e;this._logService=n;this._sequencer=new Wt;this._cachedNonces=new Map;this._lruOrder=[];this._cacheLoaded=!1;this._basePath=m.joinPath(t,"agentPlugins"),this._cachePath=m.joinPath(this._basePath,"cache.json"),this._maxPlugins=i}async syncCustomizations(t,e,n){await this._ensureCacheLoaded();let i=e.map(s=>({customization:s,enabled:!0,status:"loading"}));return n?.([...i]),await Promise.all(e.map((s,a)=>this._sequencer.queue(s.uri,async()=>{try{let l=await this._syncPlugin(t,s);return i[a]={customization:s,enabled:!0,status:"loaded"},n?.([...i]),{customization:i[a],pluginDir:l}}catch(l){let c=l instanceof Error?l.message:String(l);return this._logService.error(`[AgentPluginManager] Failed to sync plugin ${s.uri}: ${c}`),i[a]={customization:s,enabled:!0,status:"error",statusMessage:c},n?.([...i]),{customization:i[a]}}})))}async _syncPlugin(t,e){let n=Tp(m.parse(e.uri),t),i=this._keyForUri(e.uri),o=m.joinPath(this._basePath,i);return e.nonce&&this._cachedNonces.get(e.uri)===e.nonce?(this._touchLru(e.uri),this._logService.trace(`[AgentPluginManager] Nonce match for ${e.uri}, skipping copy`),o):(this._logService.info(`[AgentPluginManager] Syncing plugin: ${e.uri} \u2192 ${o.toString()}`),await this._fileService.copy(n,o,!0),e.nonce&&this._cachedNonces.set(e.uri,e.nonce),this._touchLru(e.uri),await this._evictIfNeeded(),await this._persistCache(),o)}_keyForUri(t){return t.replace(/[^a-zA-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").substring(0,128)}_touchLru(t){let e=this._lruOrder.indexOf(t);e!==-1&&this._lruOrder.splice(e,1),this._lruOrder.push(t)}async _evictIfNeeded(){for(;this._lruOrder.length>this._maxPlugins;){let t=this._lruOrder.shift();if(!t)break;this._cachedNonces.delete(t);let e=this._keyForUri(t),n=m.joinPath(this._basePath,e);this._logService.info(`[AgentPluginManager] Evicting plugin: ${t}`);try{await this._fileService.del(n,{recursive:!0})}catch(i){this._logService.warn(`[AgentPluginManager] Failed to evict plugin: ${t}`,i)}}}async _ensureCacheLoaded(){if(!this._cacheLoaded){this._cacheLoaded=!0;try{if(!await this._fileService.exists(this._cachePath))return;let t=await this._fileService.readFile(this._cachePath),e=JSON.parse(t.value.toString());if(!Array.isArray(e))return;for(let n of e)typeof n.uri=="string"&&typeof n.nonce=="string"&&(this._cachedNonces.set(n.uri,n.nonce),this._lruOrder.push(n.uri));this._logService.trace(`[AgentPluginManager] Loaded ${e.length} cache entries from disk`)}catch(t){this._logService.warn("[AgentPluginManager] Failed to load cache from disk",t)}}}async _persistCache(){try{let t=[];for(let e of this._lruOrder){let n=this._cachedNonces.get(e);n&&t.push({uri:e,nonce:n})}await this._fileService.createFolder(this._basePath),await this._fileService.writeFile(this._cachePath,S.fromString(JSON.stringify(t)))}catch(t){this._logService.warn("[AgentPluginManager] Failed to persist cache to disk",t)}}};mr=D([re(1,tt),re(2,Ce)],mr);Wm();function Wm(){let r;Yi(process)?r=new Xi:r=new Ji("agentHost");let t=new N,e={_serviceBrand:void 0,...sp},n=new Yo(hl(process.argv,np),e),i=new es(Pd(n),n.logsHome);r.registerChannel("agentHostLogger",new ts(i,()=>op));let o=i.createLogger("agenthost",{name:f(1836,null)}),s=new Xo(o);s.info("Agent Host process started successfully");let a=t.add(new zt(s));t.add(a.registerProvider(ee.file,t.add(new fs(s))));let l=new gr(m.file(n.userDataPath),a,s),c;try{c=new ko(s,a,l);let h=new mr(m.file(n.userDataPath),a,s),v=new fr;v.set(Ce,s),v.set(tt,a),v.set(or,l),v.set(No,h);let g=new gs(v);c.registerProvider(g.createInstance(nt))}catch(h){throw s.error("Failed to create AgentService",h),h}let d=qn.fromService(c,t);r.registerChannel("agentHost",d);let u=t.add(new b),p=qn.fromService({onDidChangeConnectionCount:u.event},t);r.registerChannel("agentHostConnectionTracker",p),Bm(c,a,s,t,h=>u.fire(h)).catch(h=>{s.error("Failed to start WebSocket server",h)}),process.once("exit",()=>{c.dispose(),s.dispose(),t.dispose()})}async function Bm(r,t,e,n,i){let o=process.env.VSCODE_AGENT_HOST_PORT,s=process.env.VSCODE_AGENT_HOST_SOCKET_PATH;if(!o&&!s)return;let a=process.env.VSCODE_AGENT_HOST_CONNECTION_TOKEN,l=process.env.VSCODE_AGENT_HOST_HOST||"localhost",c=n.add(await Qo.create(s?{socketPath:s,connectionTokenValidate:a?h=>h===a:void 0}:{port:parseInt(o,10),host:l,connectionTokenValidate:a?h=>h===a:void 0},e)),d=n.add(new ys);n.add(t.registerProvider(El,d));let u=n.add(new dr(r,r.stateManager,c,{defaultDirectory:m.file(_p.homedir()).toString()},d,e));n.add(u.onDidChangeConnectionCount(i));let p=s??`${l}:${o}`;e.info(`[AgentHost] WebSocket server listening on ${p}`),console.log(`Agent host server listening on ${p}`)}
//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/41dd792b5e652393e7787322889ed5fdc58bd75b/core/vs/platform/agentHost/node/agentHostMain.js.map
