function lazyInherit(target, source, sourceKey) { for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) { if (key === "constructor") continue; const targetDesc = Object.getOwnPropertyDescriptor(target, key); const desc = Object.getOwnPropertyDescriptor(source, key); let modified = false; if (desc.get) { modified = true; desc.get = targetDesc?.get || function() { return this[sourceKey][key]; }; } if (desc.set) { modified = true; desc.set = targetDesc?.set || function(value) { this[sourceKey][key] = value; }; } if (!targetDesc?.value && typeof desc.value === "function") { modified = true; desc.value = function(...args) { return this[sourceKey][key](...args); }; } if (modified) Object.defineProperty(target, key, desc); } } const _needsNormRE = /(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^#"<>{}`\x00-\x20\x7f-\uffff]/i; const _searchNeedsNormRE = /[#"'<>\x00-\x20\x7f-\uffff]/; const FastURL = /* @__PURE__ */ (() => { const NativeURL = globalThis.URL; const NativeSearchParams = globalThis.URLSearchParams; const FastURLSearchParams = class URLSearchParams { #owner; #params; constructor(owner) { this.#owner = owner; } static [Symbol.hasInstance](val) { return val instanceof NativeSearchParams; } _adopt(params) { this.#params = params; } get _params() { if (!this.#params) { const search = this.#owner.search; this.#params ??= new NativeSearchParams(search); } return this.#params; } #mutable() { this.#owner._url; return this.#params; } append(name, value) { this.#mutable().append(name, value); } set(name, value) { this.#mutable().set(name, value); } delete(name, value) { this.#mutable().delete(name, value); } sort() { this.#mutable().sort(); } }; lazyInherit(FastURLSearchParams.prototype, NativeSearchParams.prototype, "_params"); Object.setPrototypeOf(FastURLSearchParams.prototype, NativeSearchParams.prototype); Object.setPrototypeOf(FastURLSearchParams, NativeSearchParams); const FastURL = class URL { #url; #href; #protocol; #host; #pathname; #search; #searchParams; #pos; constructor(url) { if (typeof url === "string") { const isOriginForm = url[0] === "/"; if (isOriginForm && !_searchNeedsNormRE.test(url)) this.#href = `http://localhost${url}`; else this.#url = new NativeURL(isOriginForm ? `http://localhost${url}` : url); } else if (_needsNormRE.test(url.pathname) || url.search && _searchNeedsNormRE.test(url.search)) this.#url = new NativeURL(`${url.protocol || "http:"}//${url.host || "localhost"}${url.pathname}${url.search || ""}`); else { this.#protocol = url.protocol; this.#host = url.host; this.#pathname = url.pathname; this.#search = url.search; } } static [Symbol.hasInstance](val) { return val instanceof NativeURL; } get _url() { if (this.#url) return this.#url; this.#url = new NativeURL(this.href); this.#href = void 0; this.#protocol = void 0; this.#host = void 0; this.#pathname = void 0; this.#search = void 0; this.#pos = void 0; this.#searchParams?._adopt(this.#url.searchParams); return this.#url; } get href() { if (this.#url) return this.#url.href; if (!this.#href) this.#href = `${this.#protocol || "http:"}//${this.#host || "localhost"}${this.#pathname || "/"}${this.#search || ""}`; return this.#href; } #getPos() { if (!this.#pos) { const url = this.href; const protoIndex = url.indexOf("://"); const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4); const qIndex = pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex); this.#pos = [ protoIndex, pathnameIndex, qIndex ]; } return this.#pos; } get pathname() { if (this.#url) return this.#url.pathname; if (this.#pathname === void 0) { const [, pathnameIndex, queryIndex] = this.#getPos(); if (pathnameIndex === -1) return this._url.pathname; this.#pathname = this.href.slice(pathnameIndex, queryIndex === -1 ? void 0 : queryIndex); } return this.#pathname; } get search() { if (this.#url) return this.#url.search; if (this.#search === void 0) { const [, pathnameIndex, queryIndex] = this.#getPos(); if (pathnameIndex === -1) return this._url.search; const url = this.href; this.#search = queryIndex === -1 || queryIndex === url.length - 1 ? "" : url.slice(queryIndex); } return this.#search; } get searchParams() { if (this.#searchParams) return this.#searchParams; if (this.#url) return this.#url.searchParams; return this.#searchParams = new FastURLSearchParams(this); } get protocol() { if (this.#url) return this.#url.protocol; if (this.#protocol === void 0) { const [protocolIndex] = this.#getPos(); if (protocolIndex === -1) return this._url.protocol; const url = this.href; this.#protocol = url.slice(0, protocolIndex + 1); } return this.#protocol; } get hash() { if (this.#url) return this.#url.hash; return ""; } toString() { return this.href; } toJSON() { return this.href; } }; lazyInherit(FastURL.prototype, NativeURL.prototype, "_url"); Object.setPrototypeOf(FastURL.prototype, NativeURL.prototype); Object.setPrototypeOf(FastURL, NativeURL); return FastURL; })(); export { FastURL, lazyInherit };