UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1,820 lines • 52.1 kB
import { $n as init_sqlite_lifecycle_errors, $r as toRetryError, A as init_openclaw_agent_db_registry_read, Ar as init_deferred, Bi as init_global_singleton, Bn as literal, Br as init_secret_redaction_registry, Bt as init_sqlite_schema_contract, Dn as init_private_mode, Dr as init_sqlite_user_version, Dt as init_config_env_vars, E as init_agent_deletion_journal_read, Ei as init_sqlite_schema_issues, Fn as _enum, Fr as init_redact, G as init_openclaw_agent_db_discovery_paths, Gn as unknown, Gt as init_sqlite_files, H as init_openclaw_state_db_readonly, Hi as init_session_key, Hn as number, Hr as init_paths$1, Ht as init_sqlite_worker_contract, I as init_openclaw_state_db, In as array, Ji as init_string_coerce, Kr as init_utils, Li as init_kysely_sync_cache_state, Ln as boolean, Lr as redactToolPayloadText, M as init_session_dirs, Mn as init_openclaw_state_db_paths, Mr as init_error_graph_internal, Nt as init_openclaw_agent_db_contract, Oi as init_path_guards, On as init_crypto_digest, P as init_native_error_response, Pi as init_kysely_sync, Pn as init_zod, Pr as init_errors, Pt as init_sqlite_strict, Qt as init_sqlite_readonly_worker, Ri as init_listeners, Rn as discriminatedUnion, Sn as init_runtime_process_url, Sr as init_openclaw_state_db_schema_migration_required, T as init_openclaw_agent_db_registry, Tt as init_sqlite_worker_store, Un as object, Ut as init_sqlite_snapshot_source, Vi as resolveGlobalSingleton, Vn as map, W as init_openclaw_state_worker_context, Wn as string, X as init_agent_scope_config, Xr as init_src, Y as init_artifacts, Yr as createRetryRunner, Yt as init_openclaw_state_worker_error, Zn as init_sqlite_transaction, Zt as init_workspace_state_identity, _ as init_absolute_deadline, _n as init_sqlite_file_generation, ai as init_src$1, an as init_sqlite_schema_header, b as init_backoff, bi as init_record_coerce, bn as init_node_sqlite, br as init_openclaw_state_db_schema_version, c as init_tool_policy_match, cn as init_sqlite_wal, cr as init_tmp_openclaw_dir, ct as init_openclaw_state_schema_publication, dn as init_sqlite_readonly_location_cleanup, ea as init_error_coercion, et as init_command_format, f as init_agent_database_admission, fn as init_artifact_preserving_state_reads, fr as init_ansi, ft as init_openclaw_state_schema_compatibility, g as init_agent_database_preparation_context, gn as init_sqlite_integrity, gr as init_global_state, hr as init_runtime$1, ht as init_openclaw_state_ownership, ia as __esmMin, ii as init_boundary_path, in as init_sqlite_readonly_worker_protocol, ir as init_console, ji as init_errno, jr as init_detached_async_context, kn as init_openclaw_state_db_async_lifecycle, kt as init_openclaw_agent_db_paths, l as init_tool_policy_shared, m as init_openclaw_database_verify, mi as init_number_coercion, n as init_store_readonly, ni as init_home_dir, nr as init_subsystem, oa as __toESM, oi as init_utf16_slice, ot as init_openclaw_state_db_maintenance, q as init_session_sqlite_target_paths, qn as init_fs_safe, qr as init_abort_signal, ra as __commonJSMin, rt as init_openclaw_state_db_schema_repair, sr as init_logger$1, tr as createSubsystemLogger, tt as init_openclaw_state_db_fast_path, ui as init_string_normalization, ur as init_signal_exit_barrier, v as generateSecureFraction, vi as init_redact_sensitive_url, vr as init_promise_like, vt as init_openclaw_state_schema, w as init_session_store_owner, wi as init_openclaw_state_db_contract, wn as init_runtime_worker_url, wr as init_sqlite_error_diagnostics, wt as init_openclaw_state_worker_store, x as init_targets, y as init_secure_random, yn as init_file_descriptor, yt as init_openclaw_state_db_cache, z as init_directory_durability } from "./state/openclaw-state-read.worker.js";
import { createRequire } from "node:module";
import "node:buffer";
import "node:crypto";
import { AsyncLocalStorage } from "node:async_hooks";
import "node:path";
import "node:fs";
import "node:fs/promises";
import "node:url";
import { createAsyncLock } from "@openclaw/fs-safe/advanced";
import "node:os";
import chalk, { Chalk } from "chalk";
import "node:child_process";
import "node:v8";
import "node:net";
import "node:net";
import "node:events";
import "node:zlib";
import "node:process";
import "node:string_decoder";
import "@openclaw/ai/diagnostics";
import "node:dns";
import "node:dns/promises";
import "@openclaw/proxyline";
import "@openclaw/fs-safe/store";
//#region src/infra/retry-attempt-errors.ts
function recordRetryAttemptErrors(error, attemptErrors) {
	retryAttemptErrors.set(error, [...attemptErrors]);
}
function getRetryAttemptErrors(err) {
	return err !== null && (typeof err === "object" || typeof err === "function") ? retryAttemptErrors.get(err) : void 0;
}
var retryAttemptErrors;
var init_retry_attempt_errors = __esmMin((() => {
	retryAttemptErrors = /* @__PURE__ */ new WeakMap();
}));
//#endregion
//#region src/infra/retry.ts
function createRetryFailure(rawAttemptErrors) {
	const attemptErrors = rawAttemptErrors.flatMap((err) => getRetryAttemptErrors(err) ?? [err]);
	const failure = toRetryError(attemptErrors.at(-1) ?? /* @__PURE__ */ new Error("Retry failed"), "Non-Error thrown");
	if (attemptErrors.length > 1) recordRetryAttemptErrors(failure, attemptErrors);
	return failure;
}
var init_retry = __esmMin((() => {
	init_src();
	init_retry_attempt_errors();
	init_secure_random();
	createRetryRunner({
		random: generateSecureFraction,
		createFailure: createRetryFailure
	});
})), init_permit_pool = __esmMin((() => {
	init_absolute_deadline();
}));
var init_agent_database_startup = __esmMin((() => {
	init_config_env_vars();
	init_abort_signal();
	init_backoff();
	init_errors();
	init_file_descriptor();
	init_retry();
	init_sqlite_error_diagnostics();
	init_sqlite_file_generation();
	init_sqlite_readonly_worker();
	init_subsystem();
	init_session_key();
	init_detached_async_context();
	init_permit_pool();
	init_agent_database_admission();
	init_agent_database_preparation_context();
	init_agent_deletion_journal_read();
	init_openclaw_agent_db_contract();
	init_openclaw_agent_db_paths();
	init_openclaw_state_db_paths();
	createSubsystemLogger("state/agent-admission");
	new AsyncLocalStorage();
}));
//#endregion
//#region src/infra/native-error-response-schema.ts
var nativeErrorDetailsSchema, nativeErrorResponseSchema;
var init_native_error_response_schema = __esmMin((() => {
	init_zod();
	nativeErrorDetailsSchema = object({
		message: string(),
		code: string().optional(),
		errcode: number().optional()
	});
	nativeErrorResponseSchema = nativeErrorDetailsSchema.extend({
		name: string(),
		cause: nativeErrorDetailsSchema.optional()
	});
}));
var agentSchemaInspectionErrorSchema;
var init_openclaw_agent_schema_inspection_response = __esmMin((() => {
	init_zod();
	init_native_error_response_schema();
	init_native_error_response();
	init_sqlite_error_diagnostics();
	init_openclaw_state_worker_error();
	agentSchemaInspectionErrorSchema = nativeErrorResponseSchema.extend({ stateError: unknown().optional() });
})), stateSchemaRow, deletionFacts, schemaContract, stateInspectionSchema;
var init_openclaw_agent_schema_inspection_worker = __esmMin((() => {
	init_error_coercion();
	init_zod();
	init_runtime_process_url();
	init_runtime_worker_url();
	init_sqlite_file_generation();
	init_sqlite_readonly_worker();
	init_deferred();
	init_openclaw_agent_schema_inspection_response();
	stateSchemaRow = object({
		kind: literal("state"),
		path: string(),
		foundVersion: number(),
		supportedVersion: number(),
		writerAppVersion: string().optional()
	});
	deletionFacts = object({
		entries: array(object({
			agentId: string(),
			agentDir: string(),
			databasePaths: array(string())
		})),
		held: array(object({
			agentId: string(),
			path: string()
		}))
	});
	schemaContract = object({
		schemaSql: string(),
		tables: map(string(), object({
			definition: object({
				columns: map(string(), string()),
				constraints: array(string())
			}).nullable(),
			indexes: array(object({
				name: string().nullable(),
				origin: string(),
				partial: number(),
				sql: string().nullable(),
				terms: array(object({
					coll: string(),
					desc: number(),
					key: number(),
					kind: _enum([
						"column",
						"expression",
						"rowid"
					]),
					name: string().nullable(),
					seqno: number()
				})),
				unique: number()
			})),
			strict: number(),
			triggers: array(object({
				name: string(),
				sql: string().nullable()
			})),
			virtualTableSql: string().nullable(),
			withoutRowid: number()
		}))
	});
	stateInspectionSchema = object({
		schemas: object({
			incompatible: array(stateSchemaRow),
			indeterminate: array(object({
				kind: literal("state"),
				path: string(),
				reason: string()
			})),
			pendingMigrations: array(stateSchemaRow).optional(),
			deferredSchemaPublications: array(object({
				kind: literal("state"),
				path: string(),
				foundVersion: number(),
				contentVersion: number(),
				runId: string().optional(),
				publishAfterMs: number().nullable().optional(),
				message: string()
			})).optional()
		}),
		registeredDatabases: array(object({
			agentId: string(),
			path: string()
		})).optional(),
		deletionJournal: discriminatedUnion("status", [
			object({ status: literal("empty") }),
			deletionFacts.extend({ status: literal("present") }),
			object({
				status: literal("unavailable"),
				cause: _enum(["missing", "unreadable"]),
				reason: string(),
				known: deletionFacts.optional()
			})
		]).optional(),
		inspectionErrors: array(agentSchemaInspectionErrorSchema)
	});
	discriminatedUnion("ok", [object({
		requestId: number().int().safe(),
		ok: literal(false),
		error: agentSchemaInspectionErrorSchema
	}), object({
		requestId: number().int().safe(),
		ok: literal(true),
		stateInspection: stateInspectionSchema.optional(),
		schemaContracts: array(schemaContract).optional(),
		inspection: object({
			version: number().int().safe(),
			integrityGateOutcome: _enum(["cached", "healthy"]).optional(),
			preparationPending: literal(true).optional(),
			emptyStore: boolean().optional(),
			writerAppVersion: string().optional(),
			reason: string().optional(),
			failure: agentSchemaInspectionErrorSchema.optional(),
			agentSchemaMeta: object({
				agentId: string().nullable(),
				role: string().nullable(),
				schemaVersion: number().nullable()
			}).nullable().optional()
		}).nullable()
	})]);
}));
var init_usingCtx = __esmMin((() => {}));
var init_openclaw_database_preflight_agent_scheduler = __esmMin((() => {
	init_sqlite_readonly_worker();
	init_deferred();
	init_openclaw_agent_db_contract();
	init_openclaw_agent_schema_inspection_worker();
	init_usingCtx();
}));
var init_openclaw_database_preflight_cleanup = __esmMin((() => {
	init_kysely_sync();
	init_sqlite_lifecycle_errors();
	init_sqlite_readonly_location_cleanup();
}));
var init_agent_deletion_discovery = __esmMin((() => {
	init_paths$1();
	init_session_sqlite_target_paths();
	init_errno();
	init_home_dir();
	init_path_guards();
	init_sqlite_files();
	init_session_key();
	init_agent_deletion_journal_read();
	init_openclaw_agent_db_paths();
	init_openclaw_state_db_readonly();
	init_openclaw_state_db_paths();
}));
var init_backup_audit_paths = __esmMin((() => {
	init_errno();
	[
		{
			directory: "logs",
			basename: "config-audit.jsonl"
		},
		{
			directory: "audit",
			basename: "system-agent.jsonl"
		},
		{
			directory: "audit",
			basename: "crestodian.jsonl"
		}
	].map(({ directory, basename }) => {
		const escaped = basename.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
		return {
			directory,
			pattern: new RegExp(`^(?:${escaped}|\\.${escaped}\\.doctor-importing(?:\\.(?:[2-9]|[1-9][0-9]+))?|${escaped}\\.migrated(?:\\.(?:[2-9]|[1-9][0-9]+))?\\.raw(?:\\.doctor-scrub-(?:progress|restore|staging))?)$`, "u")
		};
	});
}));
var init_backup_volatile_filter = __esmMin((() => {
	init_backup_audit_paths();
}));
var init_state_migrations_media_persistence_targets = __esmMin((() => {
	init_ansi();
	init_session_dirs();
	init_command_format();
	init_paths$1();
	init_artifacts();
	init_session_key();
	init_agent_deletion_discovery();
	init_agent_deletion_journal_read();
	init_openclaw_agent_db_discovery_paths();
	init_openclaw_agent_db_registry();
	init_openclaw_agent_db_paths();
	init_backup_volatile_filter();
	init_errno();
	init_path_guards();
	init_sqlite_files();
}));
var init_openclaw_database_preflight_targets = __esmMin((() => {
	init_paths$1();
	init_session_sqlite_target_paths();
	init_errors();
	init_path_guards();
	init_state_migrations_media_persistence_targets();
	init_session_key();
	init_agent_deletion_discovery();
	init_openclaw_agent_db_paths();
}));
var init_openclaw_database_preflight_messages = __esmMin((() => {
	init_sqlite_readonly_worker_protocol();
	init_sqlite_user_version();
	init_openclaw_state_db_contract();
}));
var init_openclaw_state_schema_inspection = __esmMin((() => {
	init_sqlite_schema_contract();
	init_sqlite_schema_issues();
	init_openclaw_state_db_maintenance();
	init_openclaw_state_schema_compatibility();
	init_openclaw_state_schema();
}));
var init_openclaw_state_schema_preflight = __esmMin((() => {
	init_errors();
	init_sqlite_integrity();
	init_sqlite_schema_contract();
	init_sqlite_schema_header();
	init_sqlite_schema_issues();
	init_sqlite_user_version();
	init_agent_deletion_journal_read();
	init_openclaw_agent_db_registry_read();
	init_openclaw_database_preflight_messages();
	init_openclaw_state_db_contract();
	init_openclaw_state_db_maintenance();
	init_openclaw_state_db_schema_migration_required();
	init_openclaw_state_db_schema_repair();
	init_openclaw_state_db_schema_version();
	init_openclaw_state_ownership();
	init_openclaw_state_schema_inspection();
	init_openclaw_state_schema_publication();
	init_openclaw_state_schema();
}));
//#endregion
//#region src/state/openclaw-database-preflight-state-path.ts
var init_openclaw_database_preflight_state_path = __esmMin((() => {
	init_errors();
	init_node_sqlite();
	init_sqlite_integrity();
	init_sqlite_user_version();
	init_sqlite_wal();
	init_openclaw_database_preflight_messages();
	init_openclaw_state_db_contract();
	init_openclaw_state_db_fast_path();
	init_openclaw_state_db_schema_version();
	init_openclaw_state_ownership();
	init_openclaw_state_schema_inspection();
	init_openclaw_state_schema_publication();
}));
__esmMin((() => {
	init_agent_scope_config();
	init_paths$1();
	init_targets();
	init_errors();
	init_node_sqlite();
	init_sqlite_schema_contract();
	init_sqlite_snapshot_source();
	init_subsystem();
	init_agent_database_admission();
	init_agent_database_startup();
	init_agent_deletion_journal_read();
	init_artifact_preserving_state_reads();
	init_openclaw_agent_db_contract();
	init_openclaw_agent_db_paths();
	init_openclaw_agent_schema_inspection_worker();
	init_openclaw_database_preflight_agent_scheduler();
	init_openclaw_database_preflight_cleanup();
	init_openclaw_database_preflight_targets();
	init_openclaw_database_preflight_messages();
	init_openclaw_database_verify();
	init_openclaw_state_db_contract();
	init_openclaw_state_db_readonly();
	init_openclaw_state_db_schema_migration_required();
	init_openclaw_state_db_paths();
	init_openclaw_state_schema_preflight();
	init_usingCtx();
	init_openclaw_state_db();
	init_openclaw_database_preflight_state_path();
}));
//#endregion
//#region packages/terminal-core/src/palette.ts
var LOBSTER_PALETTE;
var init_palette = __esmMin((() => {
	LOBSTER_PALETTE = {
		accent: "#FF5A2D",
		accentBright: "#FF7A3D",
		accentDim: "#D14A22",
		info: "#FF8A5B",
		success: "#2FBF71",
		warn: "#FFB020",
		error: "#E23D2D",
		muted: "#8B7F77"
	};
})), hasForceColor, baseChalk, hex;
var init_theme = __esmMin((() => {
	init_palette();
	hasForceColor = typeof process.env.FORCE_COLOR === "string" && process.env.FORCE_COLOR.trim().length > 0 && process.env.FORCE_COLOR.trim() !== "0";
	baseChalk = process.env.NO_COLOR && !hasForceColor ? new Chalk({ level: 0 }) : chalk;
	hex = (value) => baseChalk.hex(value);
	hex(LOBSTER_PALETTE.accent), hex(LOBSTER_PALETTE.accentBright), hex(LOBSTER_PALETTE.accentDim), hex(LOBSTER_PALETTE.info), hex(LOBSTER_PALETTE.success), hex(LOBSTER_PALETTE.warn), hex(LOBSTER_PALETTE.error), hex(LOBSTER_PALETTE.muted), baseChalk.bold.hex(LOBSTER_PALETTE.accent), hex(LOBSTER_PALETTE.accentBright), hex(LOBSTER_PALETTE.warn);
}));
var init_logger = __esmMin((() => {
	init_theme();
	init_global_state();
	init_console();
	init_logger$1();
	init_subsystem();
	init_runtime$1();
}));
var init_constants = __esmMin((() => {}));
var init_content_length = __esmMin((() => {}));
var init_file_name = __esmMin((() => {}));
//#endregion
//#region packages/media-core/src/mime.ts
function buildMimeByExt() {
	const byExt = {};
	for (const [mime, ext] of Object.entries(EXT_BY_MIME)) byExt[ext] ??= mime;
	return byExt;
}
var EXT_BY_MIME;
var init_mime = __esmMin((() => {
	init_file_name();
	EXT_BY_MIME = {
		"image/avif": ".avif",
		"image/heic": ".heic",
		"image/heic-sequence": ".heic",
		"image/heif": ".heif",
		"image/heif-sequence": ".heif",
		"image/bmp": ".bmp",
		"image/jpg": ".jpg",
		"image/jpeg": ".jpg",
		"image/png": ".png",
		"image/svg+xml": ".svg",
		"image/webp": ".webp",
		"image/gif": ".gif",
		"audio/aiff": ".aiff",
		"audio/x-aiff": ".aiff",
		"audio/ogg": ".ogg",
		"audio/mpeg": ".mp3",
		"audio/mp3": ".mp3",
		"audio/wav": ".wav",
		"audio/wave": ".wav",
		"audio/x-wav": ".wav",
		"audio/flac": ".flac",
		"audio/aac": ".aac",
		"audio/amr": ".amr",
		"audio/opus": ".opus",
		"audio/webm": ".webm",
		"audio/x-m4a": ".m4a",
		"audio/m4a": ".m4a",
		"audio/mp4": ".m4a",
		"audio/x-caf": ".caf",
		"video/x-msvideo": ".avi",
		"video/x-m4v": ".m4v",
		"video/mp4": ".mp4",
		"video/x-matroska": ".mkv",
		"video/webm": ".webm",
		"video/x-flv": ".flv",
		"video/x-ms-wmv": ".wmv",
		"video/quicktime": ".mov",
		"application/pdf": ".pdf",
		"application/json": ".json",
		"application/yaml": ".yaml",
		"application/zip": ".zip",
		"application/gzip": ".gz",
		"application/x-tar": ".tar",
		"application/x-7z-compressed": ".7z",
		"application/vnd.rar": ".rar",
		"application/msword": ".doc",
		"application/vnd.ms-excel": ".xls",
		"application/vnd.ms-powerpoint": ".ppt",
		"application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
		"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
		"application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
		"text/csv": ".csv",
		"text/plain": ".txt",
		"text/markdown": ".md",
		"text/html": ".html",
		"text/xml": ".xml",
		"text/css": ".css",
		"application/xml": ".xml"
	};
	({ ...buildMimeByExt() });
}));
var init_http_response_body_timeout = __esmMin((() => {
	init_error_coercion();
	init_number_coercion();
}));
var init_http_response_body = __esmMin((() => {
	init_src$1();
	init_utf16_slice();
	init_http_response_body_timeout();
}));
//#endregion
//#region src/infra/http-body.ts
var init_http_body = __esmMin((() => {
	init_number_coercion();
	init_errors();
	init_http_response_body_timeout();
	init_http_response_body();
}));
var init_effect_authority = __esmMin((() => {
	init_global_singleton();
	resolveGlobalSingleton(Symbol.for("openclaw.effectAuthority"), () => new AsyncLocalStorage());
}));
var init_timeouts = __esmMin((() => {
	init_number_coercion();
}));
//#endregion
//#region src/utils/timer-delay.ts
var init_timer_delay = __esmMin((() => {
	init_timeouts();
}));
var init_fetch_timeout = __esmMin((() => {
	init_redact_sensitive_url();
	init_utf16_slice();
	init_subsystem();
	init_timer_delay();
	createSubsystemLogger("fetch-timeout");
}));
var init_fetch_headers = __esmMin((() => {}));
//#endregion
//#region node_modules/.pnpm/ipaddr.js@2.5.0/node_modules/ipaddr.js/lib/ipaddr.js
var require_ipaddr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	(function(root) {
		"use strict";
		const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
		const ipv4Regexes = {
			fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
			threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
			twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, "i"),
			longValue: new RegExp(`^${ipv4Part}$`, "i")
		};
		const octalRegex = new RegExp(`^0[0-7]+$`, "i");
		const hexRegex = new RegExp(`^0x[a-f0-9]+$`, "i");
		const zoneIndex = "%[0-9a-z]{1,}";
		const ipv6Part = "(?:[0-9a-f]+::?)+";
		const ipv6Regexes = {
			zoneIndex: new RegExp(zoneIndex, "i"),
			"native": new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, "i"),
			deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, "i"),
			transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, "i")
		};
		function expandIPv6(string, parts) {
			if (string.indexOf("::") !== string.lastIndexOf("::")) return null;
			let colonCount = 0;
			let lastColon = -1;
			let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
			let replacement, replacementCount;
			if (zoneId) {
				zoneId = zoneId.substring(1);
				string = string.replace(/%.+$/, "");
			}
			while ((lastColon = string.indexOf(":", lastColon + 1)) >= 0) colonCount++;
			if (string.substr(0, 2) === "::") colonCount--;
			if (string.substr(-2, 2) === "::") colonCount--;
			if (colonCount >= parts) return null;
			replacementCount = parts - colonCount;
			replacement = ":";
			while (replacementCount--) replacement += "0:";
			string = string.replace("::", replacement);
			if (string[0] === ":") string = string.slice(1);
			if (string[string.length - 1] === ":") string = string.slice(0, -1);
			parts = (function() {
				const ref = string.split(":");
				const results = [];
				for (let i = 0; i < ref.length; i++) results.push(ref[i].length > 4 ? NaN : parseInt(ref[i], 16));
				return results;
			})();
			return {
				parts,
				zoneId
			};
		}
		function matchCIDR(first, second, partSize, cidrBits) {
			if (first.length !== second.length) throw new Error("ipaddr: cannot match CIDR for objects with different lengths");
			let part = 0;
			let shift;
			while (cidrBits > 0) {
				shift = partSize - cidrBits;
				if (shift < 0) shift = 0;
				if (first[part] >> shift !== second[part] >> shift) return false;
				cidrBits -= partSize;
				part += 1;
			}
			return true;
		}
		function parseIntAuto(string) {
			if (hexRegex.test(string)) return parseInt(string, 16);
			if (string[0] === "0" && !isNaN(parseInt(string[1], 10))) {
				if (octalRegex.test(string)) return parseInt(string, 8);
				throw new Error(`ipaddr: cannot parse ${string} as octal`);
			}
			return parseInt(string, 10);
		}
		function padPart(part, length) {
			while (part.length < length) part = `0${part}`;
			return part;
		}
		const ipaddr = {};
		ipaddr.IPv4 = (function() {
			function IPv4(octets) {
				if (octets.length !== 4) throw new Error("ipaddr: ipv4 octet count should be 4");
				let i, octet;
				for (i = 0; i < octets.length; i++) {
					octet = octets[i];
					if (!(0 <= octet && octet <= 255)) throw new Error("ipaddr: ipv4 octet should fit in 8 bits");
				}
				this.octets = octets;
			}
			IPv4.prototype.SpecialRanges = {
				unspecified: [[new IPv4([
					0,
					0,
					0,
					0
				]), 8]],
				broadcast: [[new IPv4([
					255,
					255,
					255,
					255
				]), 32]],
				multicast: [[new IPv4([
					224,
					0,
					0,
					0
				]), 4]],
				linkLocal: [[new IPv4([
					169,
					254,
					0,
					0
				]), 16]],
				loopback: [[new IPv4([
					127,
					0,
					0,
					0
				]), 8]],
				carrierGradeNat: [[new IPv4([
					100,
					64,
					0,
					0
				]), 10]],
				"private": [
					[new IPv4([
						10,
						0,
						0,
						0
					]), 8],
					[new IPv4([
						172,
						16,
						0,
						0
					]), 12],
					[new IPv4([
						192,
						168,
						0,
						0
					]), 16]
				],
				reserved: [
					[new IPv4([
						192,
						0,
						0,
						0
					]), 24],
					[new IPv4([
						192,
						0,
						2,
						0
					]), 24],
					[new IPv4([
						192,
						88,
						99,
						0
					]), 24],
					[new IPv4([
						198,
						18,
						0,
						0
					]), 15],
					[new IPv4([
						198,
						51,
						100,
						0
					]), 24],
					[new IPv4([
						203,
						0,
						113,
						0
					]), 24],
					[new IPv4([
						240,
						0,
						0,
						0
					]), 4]
				],
				as112: [[new IPv4([
					192,
					175,
					48,
					0
				]), 24], [new IPv4([
					192,
					31,
					196,
					0
				]), 24]],
				amt: [[new IPv4([
					192,
					52,
					193,
					0
				]), 24]]
			};
			IPv4.prototype.kind = function() {
				return "ipv4";
			};
			IPv4.prototype.match = function(other, cidrRange) {
				let ref;
				if (cidrRange === void 0) {
					ref = other;
					other = ref[0];
					cidrRange = ref[1];
				}
				if (other.kind() !== "ipv4") throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");
				return matchCIDR(this.octets, other.octets, 8, cidrRange);
			};
			IPv4.prototype.prefixLengthFromSubnetMask = function() {
				let cidr = 0;
				let stop = false;
				const zerotable = {
					0: 8,
					128: 7,
					192: 6,
					224: 5,
					240: 4,
					248: 3,
					252: 2,
					254: 1,
					255: 0
				};
				let i, octet, zeros;
				for (i = 3; i >= 0; i -= 1) {
					octet = this.octets[i];
					if (octet in zerotable) {
						zeros = zerotable[octet];
						if (stop && zeros !== 0) return null;
						if (zeros !== 8) stop = true;
						cidr += zeros;
					} else return null;
				}
				return 32 - cidr;
			};
			IPv4.prototype.range = function() {
				return ipaddr.subnetMatch(this, this.SpecialRanges);
			};
			IPv4.prototype.toByteArray = function() {
				return this.octets.slice(0);
			};
			IPv4.prototype.toIPv4MappedAddress = function() {
				return ipaddr.IPv6.parse(`::ffff:${this.toString()}`);
			};
			IPv4.prototype.toNormalizedString = function() {
				return this.toString();
			};
			IPv4.prototype.toString = function() {
				return this.octets.join(".");
			};
			return IPv4;
		})();
		ipaddr.IPv4.broadcastAddressFromCIDR = function(string) {
			try {
				const cidr = this.parseCIDR(string);
				const ipInterfaceOctets = cidr[0].toByteArray();
				const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
				const octets = [];
				let i = 0;
				while (i < 4) {
					octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
					i++;
				}
				return new this(octets);
			} catch (e) {
				throw new Error("ipaddr: the address does not have IPv4 CIDR format", { cause: e });
			}
		};
		ipaddr.IPv4.isIPv4 = function(string) {
			return this.parser(string) !== null;
		};
		ipaddr.IPv4.isValid = function(string) {
			try {
				new this(this.parser(string));
				return true;
			} catch {
				return false;
			}
		};
		ipaddr.IPv4.isValidCIDR = function(string) {
			try {
				this.parseCIDR(string);
				return true;
			} catch {
				return false;
			}
		};
		ipaddr.IPv4.isValidFourPartDecimal = function(string) {
			if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/)) return true;
			else return false;
		};
		ipaddr.IPv4.isValidCIDRFourPartDecimal = function(string) {
			const match = string.match(/^(.+)\/(\d+)$/);
			if (!ipaddr.IPv4.isValidCIDR(string) || !match) return false;
			return ipaddr.IPv4.isValidFourPartDecimal(match[1]);
		};
		ipaddr.IPv4.networkAddressFromCIDR = function(string) {
			let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
			try {
				cidr = this.parseCIDR(string);
				ipInterfaceOctets = cidr[0].toByteArray();
				subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
				octets = [];
				i = 0;
				while (i < 4) {
					octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
					i++;
				}
				return new this(octets);
			} catch (e) {
				throw new Error("ipaddr: the address does not have IPv4 CIDR format", { cause: e });
			}
		};
		ipaddr.IPv4.parse = function(string) {
			const parts = this.parser(string);
			if (parts === null) throw new Error("ipaddr: string is not formatted like an IPv4 Address");
			return new this(parts);
		};
		ipaddr.IPv4.parseCIDR = function(string) {
			let match;
			if (match = string.match(/^(.+)\/(\d+)$/)) {
				const maskLength = parseInt(match[2]);
				if (maskLength >= 0 && maskLength <= 32) {
					const parsed = [this.parse(match[1]), maskLength];
					Object.defineProperty(parsed, "toString", { value: function() {
						return this.join("/");
					} });
					return parsed;
				}
			}
			throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
		};
		ipaddr.IPv4.parser = function(string) {
			let match, part, value;
			if (match = string.match(ipv4Regexes.fourOctet)) return (function() {
				const ref = match.slice(1, 6);
				const results = [];
				for (let i = 0; i < ref.length; i++) {
					part = ref[i];
					results.push(parseIntAuto(part));
				}
				return results;
			})();
			else if (match = string.match(ipv4Regexes.longValue)) {
				value = parseIntAuto(match[1]);
				if (value > 4294967295 || value < 0) throw new Error("ipaddr: address outside defined range");
				return (function() {
					const results = [];
					let shift = 0;
					for (; shift <= 24; shift += 8) results.push(value >> shift & 255);
					return results;
				})().reverse();
			} else if (match = string.match(ipv4Regexes.twoOctet)) return (function() {
				const ref = match.slice(1, 4);
				const results = [];
				value = parseIntAuto(ref[1]);
				if (value > 16777215 || value < 0) throw new Error("ipaddr: address outside defined range");
				results.push(parseIntAuto(ref[0]));
				results.push(value >> 16 & 255);
				results.push(value >> 8 & 255);
				results.push(value & 255);
				return results;
			})();
			else if (match = string.match(ipv4Regexes.threeOctet)) return (function() {
				const ref = match.slice(1, 5);
				const results = [];
				value = parseIntAuto(ref[2]);
				if (value > 65535 || value < 0) throw new Error("ipaddr: address outside defined range");
				results.push(parseIntAuto(ref[0]));
				results.push(parseIntAuto(ref[1]));
				results.push(value >> 8 & 255);
				results.push(value & 255);
				return results;
			})();
			else return null;
		};
		ipaddr.IPv4.subnetMaskFromPrefixLength = function(prefix) {
			prefix = parseInt(prefix);
			if (Number.isNaN(prefix) || prefix < 0 || prefix > 32) throw new Error("ipaddr: invalid IPv4 prefix length");
			const octets = [
				0,
				0,
				0,
				0
			];
			let j = 0;
			const filledOctetCount = Math.floor(prefix / 8);
			while (j < filledOctetCount) {
				octets[j] = 255;
				j++;
			}
			if (filledOctetCount < 4) octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
			return new this(octets);
		};
		ipaddr.IPv6 = (function() {
			function IPv6(parts, zoneId) {
				let i, part;
				if (parts.length === 16) {
					this.parts = [];
					for (i = 0; i <= 14; i += 2) this.parts.push(parts[i] << 8 | parts[i + 1]);
				} else if (parts.length === 8) this.parts = parts;
				else throw new Error("ipaddr: ipv6 part count should be 8 or 16");
				for (i = 0; i < this.parts.length; i++) {
					part = this.parts[i];
					if (!(0 <= part && part <= 65535)) throw new Error("ipaddr: ipv6 part should fit in 16 bits");
				}
				if (zoneId) this.zoneId = zoneId;
			}
			IPv6.prototype.SpecialRanges = {
				unspecified: [new IPv6([
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 128],
				linkLocal: [new IPv6([
					65152,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 10],
				multicast: [new IPv6([
					65280,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 8],
				loopback: [new IPv6([
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					1
				]), 128],
				uniqueLocal: [new IPv6([
					64512,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 7],
				ipv4Mapped: [new IPv6([
					0,
					0,
					0,
					0,
					0,
					65535,
					0,
					0
				]), 96],
				deprecatedSiteLocal: [new IPv6([
					65216,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 10],
				discard: [new IPv6([
					256,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 64],
				rfc6145: [new IPv6([
					0,
					0,
					0,
					0,
					65535,
					0,
					0,
					0
				]), 96],
				rfc6052: [[new IPv6([
					100,
					65435,
					0,
					0,
					0,
					0,
					0,
					0
				]), 96], [new IPv6([
					100,
					65435,
					1,
					0,
					0,
					0,
					0,
					0
				]), 48]],
				"6to4": [new IPv6([
					8194,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 16],
				teredo: [new IPv6([
					8193,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 32],
				benchmarking: [new IPv6([
					8193,
					2,
					0,
					0,
					0,
					0,
					0,
					0
				]), 48],
				amt: [new IPv6([
					8193,
					3,
					0,
					0,
					0,
					0,
					0,
					0
				]), 32],
				as112v6: [[new IPv6([
					8193,
					4,
					274,
					0,
					0,
					0,
					0,
					0
				]), 48], [new IPv6([
					9760,
					79,
					32768,
					0,
					0,
					0,
					0,
					0
				]), 48]],
				deprecatedOrchid: [new IPv6([
					8193,
					16,
					0,
					0,
					0,
					0,
					0,
					0
				]), 28],
				orchid2: [new IPv6([
					8193,
					32,
					0,
					0,
					0,
					0,
					0,
					0
				]), 28],
				droneRemoteIdProtocolEntityTags: [new IPv6([
					8193,
					48,
					0,
					0,
					0,
					0,
					0,
					0
				]), 28],
				segmentRouting: [new IPv6([
					24320,
					0,
					0,
					0,
					0,
					0,
					0,
					0
				]), 16],
				reserved: [
					[new IPv6([
						8193,
						0,
						0,
						0,
						0,
						0,
						0,
						0
					]), 23],
					[new IPv6([
						8193,
						3512,
						0,
						0,
						0,
						0,
						0,
						0
					]), 32],
					[new IPv6([
						16383,
						0,
						0,
						0,
						0,
						0,
						0,
						0
					]), 20]
				]
			};
			IPv6.prototype.isIPv4MappedAddress = function() {
				return this.range() === "ipv4Mapped";
			};
			IPv6.prototype.kind = function() {
				return "ipv6";
			};
			IPv6.prototype.match = function(other, cidrRange) {
				let ref;
				if (cidrRange === void 0) {
					ref = other;
					other = ref[0];
					cidrRange = ref[1];
				}
				if (other.kind() !== "ipv6") throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");
				return matchCIDR(this.parts, other.parts, 16, cidrRange);
			};
			IPv6.prototype.prefixLengthFromSubnetMask = function() {
				let cidr = 0;
				let stop = false;
				const zerotable = {
					0: 16,
					32768: 15,
					49152: 14,
					57344: 13,
					61440: 12,
					63488: 11,
					64512: 10,
					65024: 9,
					65280: 8,
					65408: 7,
					65472: 6,
					65504: 5,
					65520: 4,
					65528: 3,
					65532: 2,
					65534: 1,
					65535: 0
				};
				let part, zeros;
				for (let i = 7; i >= 0; i -= 1) {
					part = this.parts[i];
					if (part in zerotable) {
						zeros = zerotable[part];
						if (stop && zeros !== 0) return null;
						if (zeros !== 16) stop = true;
						cidr += zeros;
					} else return null;
				}
				return 128 - cidr;
			};
			IPv6.prototype.range = function() {
				return ipaddr.subnetMatch(this, this.SpecialRanges);
			};
			IPv6.prototype.toByteArray = function() {
				let part;
				const bytes = [];
				const ref = this.parts;
				for (let i = 0; i < ref.length; i++) {
					part = ref[i];
					bytes.push(part >> 8);
					bytes.push(part & 255);
				}
				return bytes;
			};
			IPv6.prototype.toFixedLengthString = function() {
				const addr = (function() {
					const results = [];
					for (let i = 0; i < this.parts.length; i++) results.push(padPart(this.parts[i].toString(16), 4));
					return results;
				}).call(this).join(":");
				let suffix = "";
				if (this.zoneId) suffix = `%${this.zoneId}`;
				return addr + suffix;
			};
			IPv6.prototype.toIPv4Address = function() {
				if (!this.isIPv4MappedAddress()) throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");
				const ref = this.parts.slice(-2);
				const high = ref[0];
				const low = ref[1];
				return new ipaddr.IPv4([
					high >> 8,
					high & 255,
					low >> 8,
					low & 255
				]);
			};
			IPv6.prototype.toNormalizedString = function() {
				const addr = (function() {
					const results = [];
					for (let i = 0; i < this.parts.length; i++) results.push(this.parts[i].toString(16));
					return results;
				}).call(this).join(":");
				let suffix = "";
				if (this.zoneId) suffix = `%${this.zoneId}`;
				return addr + suffix;
			};
			IPv6.prototype.toRFC5952String = function() {
				const regex = /((^|:)(0(:|$)){2,})/g;
				let suffix = "";
				if (this.zoneId) suffix = `%${this.zoneId}`;
				const normalized = this.toNormalizedString();
				const string = normalized.slice(0, normalized.length - suffix.length);
				let bestMatchIndex = 0;
				let bestMatchLength = -1;
				let bestMatchGroups = -1;
				let match;
				while (match = regex.exec(string)) {
					const groups = (match[0].match(/0/g) || []).length;
					if (groups > bestMatchGroups) {
						bestMatchGroups = groups;
						bestMatchIndex = match.index;
						bestMatchLength = match[0].length;
					}
				}
				if (bestMatchLength < 0) return string + suffix;
				return `${string.substring(0, bestMatchIndex)}::${string.substring(bestMatchIndex + bestMatchLength)}${suffix}`;
			};
			IPv6.prototype.toString = function() {
				return this.toRFC5952String();
			};
			return IPv6;
		})();
		ipaddr.IPv6.broadcastAddressFromCIDR = function(string) {
			try {
				const cidr = this.parseCIDR(string);
				const ipInterfaceOctets = cidr[0].toByteArray();
				const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
				const octets = [];
				let i = 0;
				while (i < 16) {
					octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
					i++;
				}
				return new this(octets);
			} catch (e) {
				throw new Error("ipaddr: the address does not have IPv6 CIDR format", { cause: e });
			}
		};
		ipaddr.IPv6.isIPv6 = function(string) {
			return this.parser(string) !== null;
		};
		ipaddr.IPv6.isValid = function(string) {
			if (typeof string === "string" && string.indexOf(":") === -1) return false;
			try {
				const addr = this.parser(string);
				new this(addr.parts, addr.zoneId);
				return true;
			} catch {
				return false;
			}
		};
		ipaddr.IPv6.isValidCIDR = function(string) {
			if (typeof string === "string" && string.indexOf(":") === -1) return false;
			try {
				this.parseCIDR(string);
				return true;
			} catch {
				return false;
			}
		};
		ipaddr.IPv6.networkAddressFromCIDR = function(string) {
			let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
			try {
				cidr = this.parseCIDR(string);
				ipInterfaceOctets = cidr[0].toByteArray();
				subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
				octets = [];
				i = 0;
				while (i < 16) {
					octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
					i++;
				}
				return new this(octets);
			} catch (e) {
				throw new Error("ipaddr: the address does not have IPv6 CIDR format", { cause: e });
			}
		};
		ipaddr.IPv6.parse = function(string) {
			const addr = this.parser(string);
			if (addr === null) throw new Error("ipaddr: string is not formatted like an IPv6 Address");
			return new this(addr.parts, addr.zoneId);
		};
		ipaddr.IPv6.parseCIDR = function(string) {
			let maskLength, match, parsed;
			if (match = string.match(/^(.+)\/(\d+)$/)) {
				maskLength = parseInt(match[2]);
				if (maskLength >= 0 && maskLength <= 128) {
					parsed = [this.parse(match[1]), maskLength];
					Object.defineProperty(parsed, "toString", { value: function() {
						return this.join("/");
					} });
					return parsed;
				}
			}
			throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");
		};
		ipaddr.IPv6.parser = function(string) {
			let addr, i, match, octet, octets, zoneId;
			if (match = string.match(ipv6Regexes.deprecatedTransitional)) return this.parser(`::ffff:${match[1]}`);
			if (ipv6Regexes.native.test(string)) return expandIPv6(string, 8);
			if (match = string.match(ipv6Regexes.transitional)) {
				zoneId = match[6] || "";
				addr = match[1];
				if (!match[1].endsWith("::")) addr = addr.slice(0, -1);
				addr = expandIPv6(addr + zoneId, 6);
				if (addr && addr.parts) {
					octets = [
						parseInt(match[2]),
						parseInt(match[3]),
						parseInt(match[4]),
						parseInt(match[5])
					];
					for (i = 0; i < octets.length; i++) {
						octet = octets[i];
						if (!(0 <= octet && octet <= 255)) return null;
					}
					addr.parts.push(octets[0] << 8 | octets[1]);
					addr.parts.push(octets[2] << 8 | octets[3]);
					return {
						parts: addr.parts,
						zoneId: addr.zoneId
					};
				}
			}
			return null;
		};
		ipaddr.IPv6.subnetMaskFromPrefixLength = function(prefix) {
			prefix = parseInt(prefix);
			if (Number.isNaN(prefix) || prefix < 0 || prefix > 128) throw new Error("ipaddr: invalid IPv6 prefix length");
			const octets = [
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0
			];
			let j = 0;
			const filledOctetCount = Math.floor(prefix / 8);
			while (j < filledOctetCount) {
				octets[j] = 255;
				j++;
			}
			if (filledOctetCount < 16) octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
			return new this(octets);
		};
		ipaddr.fromByteArray = function(bytes) {
			const length = bytes.length;
			if (length === 4) return new ipaddr.IPv4(bytes);
			else if (length === 16) return new ipaddr.IPv6(bytes);
			else throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address");
		};
		ipaddr.isValid = function(string) {
			return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string);
		};
		ipaddr.isValidCIDR = function(string) {
			return ipaddr.IPv6.isValidCIDR(string) || ipaddr.IPv4.isValidCIDR(string);
		};
		ipaddr.parse = function(string) {
			if (ipaddr.IPv6.isValid(string)) return ipaddr.IPv6.parse(string);
			else if (ipaddr.IPv4.isValid(string)) return ipaddr.IPv4.parse(string);
			else throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format");
		};
		ipaddr.parseCIDR = function(string) {
			try {
				return ipaddr.IPv6.parseCIDR(string);
			} catch {
				try {
					return ipaddr.IPv4.parseCIDR(string);
				} catch (e) {
					throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format", { cause: e });
				}
			}
		};
		ipaddr.process = function(string) {
			const addr = this.parse(string);
			if (addr.kind() === "ipv6" && addr.isIPv4MappedAddress()) return addr.toIPv4Address();
			else return addr;
		};
		ipaddr.subnetMatch = function(address, rangeList, defaultName) {
			let i, rangeName, rangeSubnets, subnet;
			if (defaultName === void 0 || defaultName === null) defaultName = "unicast";
			for (rangeName in rangeList) if (Object.prototype.hasOwnProperty.call(rangeList, rangeName)) {
				rangeSubnets = rangeList[rangeName];
				if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) rangeSubnets = [rangeSubnets];
				for (i = 0; i < rangeSubnets.length; i++) {
					subnet = rangeSubnets[i];
					if (address.kind() === subnet[0].kind() && address.match.apply(address, subnet)) return rangeName;
				}
			}
			return defaultName;
		};
		if (typeof module !== "undefined" && module.exports) module.exports = ipaddr;
		else root.ipaddr = ipaddr;
	})(exports);
})), import_ipaddr;
var init_ip = __esmMin((() => {
	init_string_coerce();
	import_ipaddr = /* @__PURE__ */ __toESM(require_ipaddr(), 1);
	import_ipaddr.default.IPv4.parse("198.18.0.0");
}));
var init_hostname = __esmMin((() => {
	init_string_coerce();
}));
var init_active_proxy_state = __esmMin((() => {}));
var init_proxy_env = __esmMin((() => {
	init_src$1();
	init_string_coerce();
}));
var init_proxy_tls = __esmMin((() => {
	init_string_coerce();
	init_errors();
}));
var init_active_managed_proxy_tls = __esmMin((() => {
	init_proxy_env();
	init_active_proxy_state();
	init_proxy_tls();
}));
var init_managed_proxy_undici = __esmMin((() => {
	init_record_coerce();
	init_active_managed_proxy_tls();
}));
var init_undici_error_diagnostics = __esmMin((() => {
	init_logger();
	init_errors();
})), init_wsl = __esmMin((() => {
	init_string_coerce();
})), init_undici_family_policy = __esmMin((() => {
	init_wsl();
}));
var init_undici_dispatcher_options = __esmMin((() => {
	init_record_coerce();
	init_managed_proxy_undici();
	init_undici_error_diagnostics();
	init_undici_family_policy();
	createRequire(import.meta.url);
	Object.freeze({ allowH2: false });
}));
var init_undici_runtime = __esmMin((() => {
	init_error_coercion();
	init_proxy_env();
	init_undici_dispatcher_options();
	init_undici_error_diagnostics();
}));
var init_ssrf = __esmMin((() => {
	init_ip();
	init_src$1();
	init_string_normalization();
	init_src();
	init_deferred();
	init_hostname();
	init_undici_runtime();
}));
var init_configured_local_origin_bypass = __esmMin((() => {
	init_ip();
	init_hostname();
	init_active_proxy_state();
	init_ssrf();
}));
var init_fetch_request_authority = __esmMin((() => {
	init_global_singleton();
	resolveGlobalSingleton(Symbol.for("openclaw.guardedFetchRequestAuthority"), () => new AsyncLocalStorage());
}));
var init_guarded_body_stream = __esmMin((() => {
	new FinalizationRegistry((held) => {
		held.finalize().catch(() => void 0);
	});
}));
var init_pinned_dispatcher_pool = __esmMin((() => {
	init_ssrf();
	AsyncLocalStorage.snapshot();
}));
var init_redirect_headers = __esmMin((() => {
	init_fetch_headers();
}));
var init_form_data = __esmMin((() => {}));
var init_runtime_fetch = __esmMin((() => {
	init_fetch_headers();
	init_form_data();
	init_undici_runtime();
})), init_paths = __esmMin((() => {
	init_paths$1();
}));
var init_env = __esmMin((() => {
	init_paths();
}));
var init_model_provider_header_policy = __esmMin((() => {
	init_string_coerce();
}));
var init_header_redaction = __esmMin((() => {
	init_fetch_headers();
	init_secret_redaction_registry();
	init_model_provider_header_policy();
}));
var init_runtime_deferral = __esmMin((() => {
	new AsyncLocalStorage();
})), init_runtime_cleanup = __esmMin((() => {
	init_signal_exit_barrier();
}));
var init_store_lifecycle = __esmMin((() => {
	init_deferred();
	init_listeners();
}));
var init_store_async = __esmMin((() => {
	init_sqlite_worker_contract();
	init_openclaw_state_db_cache();
	init_openclaw_state_worker_context();
	init_openclaw_state_worker_store();
	init_store_lifecycle();
}));
var init_store_kernel = __esmMin((() => {
	init_string_normalization();
	init_crypto_digest();
	init_kysely_sync_cache_state();
	init_kysely_sync();
	init_private_mode();
	init_sqlite_transaction();
	init_store_readonly();
}));
var init_store_sqlite = __esmMin((() => {
	init_node_sqlite();
	init_private_mode();
	init_sqlite_files();
	init_sqlite_strict();
	init_sqlite_wal();
	init_openclaw_state_db_cache();
	init_openclaw_state_db();
	init_store_lifecycle();
	init_store_kernel();
}));
var init_runtime_owner = __esmMin((() => {
	init_error_graph_internal();
	init_sqlite_worker_contract();
	init_sqlite_worker_store();
	init_secret_redaction_registry();
	init_deferred();
	init_openclaw_state_db_async_lifecycle();
	init_openclaw_state_worker_context();
	init_env();
	init_header_redaction();
	init_runtime_cleanup();
	init_runtime_deferral();
	init_store_lifecycle();
	init_store_async();
	init_store_sqlite();
}));
var init_runtime_fetch_patch = __esmMin((() => {
	init_fetch_headers();
	init_runtime_owner();
}));
var init_runtime_response_body = __esmMin((() => {
	init_http_response_body_timeout();
	init_runtime_owner();
}));
__esmMin((() => {
	init_fetch_headers();
	init_secret_redaction_registry();
	init_deferred();
	init_env();
	init_header_redaction();
	init_runtime_deferral();
	init_runtime_fetch_patch();
	init_runtime_owner();
	init_runtime_response_body();
	init_store_sqlite();
	Buffer.from("[REDACTED BINARY PAYLOAD]", "utf8");
}));
var init_fetch_guard = __esmMin((() => {
	init_promise_like();
	init_logger();
	init_effect_authority();
	init_fetch_timeout();
	init_fetch_headers();
	init_http_body();
	init_configured_local_origin_bypass();
	init_fetch_request_authority();
	init_guarded_body_stream();
	init_pinned_dispatcher_pool();
	init_proxy_env();
	init_redirect_headers();
	init_runtime_fetch();
	init_ssrf();
	init_undici_dispatcher_options();
	init_undici_family_policy();
	init_undici_runtime();
}));
//#endregion
//#region src/infra/retryable-network-errors.ts
var init_retryable_network_errors = __esmMin((() => {}));
var init_channel_read_authority = __esmMin((() => {
	init_effect_authority();
	init_global_singleton();
	resolveGlobalSingleton(Symbol.for("openclaw.channelReadAuthority"), () => new AsyncLocalStorage());
}));
var init_fetch_read_scope = __esmMin((() => {
	init_channel_read_authority();
}));
var init_sibling_temp_file = __esmMin((() => {}));
var init_store_shared = __esmMin((() => {
	init_src$1();
}));
__esmMin((() => {
	init_directory_durability();
	init_fs_safe();
	init_redact();
	init_channel_read_authority();
	init_global_singleton();
	init_store_shared();
	resolveGlobalSingleton(Symbol.for("openclaw.readMediaExitCleanup"), () => {
		const callbacks = /* @__PURE__ */ new Set();
		process.once("exit", () => {
			for (const cleanup of callbacks) try {
				cleanup();
			} catch (error) {
				console.error(`Channel read output cleanup failed at exit: ${redactToolPayloadText(String(error))}`);
			}
		});
		return callbacks;
	});
}));
__esmMin((() => {
	init_mime();
	init_runtime_fetch();
	init_fetch();
}));
var init_inbound_path_policy = __esmMin((() => {}));
//#endregion
//#region src/config/model-input.ts
var init_model_input = __esmMin((() => {
	init_number_coercion();
}));
//#endregion
//#region src/skills/discovery/agent-filter.ts
var init_agent_filter = __esmMin((() => {
	init_agent_scope_config();
}));
//#endregion
//#region src/agents/agent-scope.ts
var init_agent_scope = __esmMin((() => {
	init_model_input();
	init_session_store_owner();
	init_path_guards();
	init_session_key();
	init_agent_scope_config();
	init_workspace_state_identity();
	init_agent_filter();
}));
//#endregion
//#region src/agents/tool-policy.ts
var init_tool_policy = __esmMin((() => {
	init_tool_policy_shared();
}));
//#endregion
//#region src/agents/tool-fs-policy.ts
var init_tool_fs_policy = __esmMin((() => {
	init_agent_scope();
	init_tool_policy_match();
	init_tool_policy();
}));
//#endregion
//#region src/media/local-media-path.ts
var init_local_media_path = __esmMin((() => {
	init_utils();
}));
var init_local_roots = __esmMin((() => {
	init_agent_scope();
	init_tool_fs_policy();
	init_paths$1();
	init_boundary_path();
	init_path_guards();
	init_tmp_openclaw_dir();
	init_utils();
	init_local_media_path();
}));
var init_inbound_media_uri = __esmMin((() => {}));
var init_media_reference = __esmMin((() => {
	init_utils();
	init_inbound_media_uri();
	init_store();
}));
__esmMin((() => {
	init_inbound_path_policy();
	init_fs_safe();
	init_path_guards();
	init_channel_read_authority();
	init_local_roots();
	init_media_reference();
}));
var init_store = __esmMin((() => {
	init_file_name();
	init_mime();
	init_utf16_slice();
	init_fs_safe();
	init_retry();
	init_sibling_temp_file();
	init_channel_read_authority();
	init_openclaw_state_worker_context();
	init_utils();
	init_store_shared();
	init_usingCtx();
	createAsyncLock();
}));
var init_fetch = __esmMin((() => {
	init_constants();
	init_content_length();
	init_file_name();
	init_mime();
	init_src$1();
	init_abort_signal();
	init_backoff();
	init_errors();
	init_http_body();
	init_fetch_guard();
	init_retry();
	init_retryable_network_errors();
	init_redact();
	init_channel_read_authority();
	init_fetch_timeout();
	init_fetch_read_scope();
	init_store();
	init_store_shared();
}));
//#endregion
export {};