// @generated by scripts/build-runtime.mjs; do not edit. // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader. import { safeTerminalText } from "./chunk-W64NEHXT.ts"; import { syncConfigReviewFingerprint } from "./chunk-APZVBSM6.ts"; import { inspectRemoteSelection, remoteSelectionMismatch, sameSyncInclude, snapshotSelectionInclude } from "./chunk-YQ6UW7IF.ts"; // src/backend-factory.ts var createSyncBackend = async (config) => { switch (config.backend.type) { case "s3": { const { S3SyncBackend } = await import("./s3-backend-3QZGO2EF.ts"); return new S3SyncBackend(config.backend); } case "webdav": { const { WebDavSyncBackend } = await import("./webdav-backend-ZD5RHRIU.ts"); return new WebDavSyncBackend(config.backend); } case "git": { const { GitSyncBackend } = await import("./git-backend-E3UOUUOM.ts"); return new GitSyncBackend(config.backend); } } }; // src/remote-snapshot.ts async function readSnapshotForHead(backend, head, signal) { const snapshot = await backend.readSnapshot(head.snapshotRef, signal); if (signal?.aborted) { throw signal.reason instanceof Error ? signal.reason : new DOMException("The operation was aborted", "AbortError"); } if (snapshot.id !== head.snapshotId) { throw new Error( `Remote head ${head.snapshotId} resolved to unexpected snapshot ${snapshot.id}.` ); } if (head.selection) { const snapshotInclude = snapshotSelectionInclude(snapshot); if (!snapshotInclude || !sameSyncInclude(head.selection.include, snapshotInclude)) { throw new Error("Remote head selection does not match its immutable snapshot."); } } return snapshot; } function requireCompatibleRemoteSelection(config, snapshot) { const state = inspectRemoteSelection(config.include, snapshot); if (state.kind === "different") { throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config)); } } function formatRemoteSelectionStatus(state) { if (!state) return "remote included content: unavailable (remote is empty)"; if (state.kind === "same") return "remote included content: matches this setup"; if (state.kind === "legacy") { return `remote included content: unavailable in legacy snapshot (${state.discovered.length} path${state.discovered.length === 1 ? "" : "s"} discovered, partial)`; } return [ "remote included content: differs from this setup", `remote-only selection: ${safeList(state.remoteOnly)}`, `local-only selection: ${safeList(state.localOnly)}` ].join("\n"); } function safeList(values) { return values.length > 0 ? values.map(safeTerminalText).join(", ") : "none"; } export { createSyncBackend, readSnapshotForHead, requireCompatibleRemoteSelection, formatRemoteSelectionStatus }; //# sourceMappingURL=chunk-FR6CVXAL.ts.map