import { a as FeedbackConfig, F as FeedbackApi } from './types-CfSqqfkw.js'; import { ErrorTrackingOptions } from './error-tracking.js'; import './types-CRbb2Pp0.js'; /** * Fetch the widget-manifest from the Mhosaic backend. * * The loader calls this on every page load. The backend reads `Project. * pinned_version` (or current stable) + `Project.widget_enabled` and * returns the bundle URL + SRI hash for the version this tenant should * receive — or `{enabled: false}` if the widget is killed for the tenant. * * Network failures are surfaced to the caller. The loader degrades to * "widget not present" rather than crashing the host page. */ interface Manifest { /** False when the widget is disabled for this project (kill switch) or * no stable release exists. Loader bails silently. */ enabled: boolean; /** Semver of the bundle being served. Present when enabled=true. */ version?: string; /** Fully-qualified URL to the version-pinned bundle (jsDelivr). */ bundle_url?: string; /** Subresource integrity hash for the bundle. The loader injects the * script tag with `integrity=…` so the browser refuses to run a * bundle whose bytes don't match. */ sri_hash?: string; /** Static config the manifest endpoint passes through to the widget. */ config?: { endpoint: string; project_slug: string; share_reports_with_widget: boolean; /** Phase 4: project gates the widget per end-user (default false). */ requires_visibility_check?: boolean; /** Per-project switch for the bundle's default error capture. When the * backend omits it, the bundle falls back to its own default (on). */ error_tracking?: boolean; }; /** Human-readable detail when `enabled` is false. */ detail?: string; } /** * `@mhosaic/feedback/loader` — public entry for the loader architecture. * * Same shape as the direct-import path (`@mhosaic/feedback`), but the * widget bundle is fetched at runtime from a CDN URL the Mhosaic backend * dictates via the manifest endpoint. Letting hosts switch from the * direct-import path to the loader path gives them auto-updates without * any further code changes — Mhosaic ships a new Release row, every host * picks up the new bundle on next page load. * * Public surface MUST mirror the direct-import path exactly: * - `createFeedback(config)` returns a `FeedbackApi`-shaped handle. * - Method calls before the bundle finishes loading queue up and replay. * - `submit()` returns a Promise that resolves after the bundle is up * and the real submit completes. * * If the manifest endpoint reports the widget is disabled for this * project (`enabled: false` — kill switch or no stable release configured), * the deferred handle silently no-ops void calls and rejects `submit()` * calls with a clear error. The host page never crashes. */ /** Loader config = the public widget config plus the loader-only knobs the * host can set to override what the manifest dictates. */ type LoaderConfig = FeedbackConfig & { /** Override the bundle's default error capture. Omit (or pass `undefined`) * to let the project's manifest flag decide (which itself defaults on). */ errorTracking?: boolean | ErrorTrackingOptions | undefined; }; declare function createFeedback(config: LoaderConfig): FeedbackApi; export { FeedbackApi, FeedbackConfig, type LoaderConfig, type Manifest, createFeedback };