/**
 * Sail Intelligence — https://api.sail.money
 *
 * AUTO-GENERATED from the OpenAPI spec at build time.
 * Do not edit manually — run `pnpm build` to regenerate.
 *
 * Spec version : 1.2.0
 * Generated at : 2026-06-11T19:02:01.807Z
 */
export const SAIL_INTELLIGENCE_BASE_URL = "https://api.sail.money";
export const SAIL_INTELLIGENCE_DOCS_URL = "https://api.sail.money/docs";
export class SailIntelligence {
    _base;
    _headers;
    constructor(opts) {
        this._base = opts.baseUrl ?? SAIL_INTELLIGENCE_BASE_URL;
        this._headers = { "Content-Type": "application/json", "X-API-Key": opts.apiKey };
    }
    async _get(path, query) {
        const url = new URL(`${this._base}${path}`);
        if (query)
            Object.entries(query).forEach(([k, v]) => url.searchParams.set(k, v));
        const res = await fetch(url.toString(), { headers: this._headers });
        if (!res.ok)
            throw new Error(`Sail Intelligence GET ${path} → ${res.status}`);
        return res.json();
    }
    async _post(path, body) {
        const res = await fetch(`${this._base}${path}`, {
            method: "POST",
            headers: this._headers,
            body: JSON.stringify(body),
        });
        if (!res.ok)
            throw new Error(`Sail Intelligence POST ${path} → ${res.status}`);
        return res.json();
    }
    /**
     * All available yield sources
     * Returns all yield sources monitored by Sail Intelligence Sonar. Filter by chain or token to narrow the result set.
     */
    vaultSources(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/vault/sources`, _p);
    }
    /**
     * Single yield source risk intelligence
     * Returns Sail Intelligence Sonar risk intelligence for a single yield source. Includes active disable flags, affected tokens, risk score context, and the collateral dependency tree used for institutional review workflows.
     */
    vault(vaultAddress) {
        return this._get(`/v1/vault/${vaultAddress}`);
    }
    /**
     * Quick yield source safety decision
     * Returns a single operational answer for institutional workflows: is this yield source currently safe to interact with. Checks both the source-level kill switch and deposit-token depeg status. For full Sonar context use GET /v1/vault/{address}.
     */
    vaultSafe(vaultAddress, query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/vault/${vaultAddress}/safe`, _p);
    }
    /**
     * Portfolio risk check
     * Given a list of institutional positions (vault address plus optional chain/token), returns which are currently affected by active Sonar risk signals (vault disabled or deposit token depegged). Maximum 500 positions per request.
     */
    portfolioCheck(body) {
        return this._post(`/v1/portfolio/check`, body);
    }
    /**
     * Sonar global risk snapshot
     * Returns a full Sonar monitoring snapshot of all currently active risk flags: disabled vault addresses (with source breakdown and cooldown state), depegged tokens per chain, per-vault risk scores, and the timestamp of the last institutional monitoring pipeline run.
     */
    risksSummary() {
        return this._get(`/v1/risks/summary`);
    }
    /**
     * Institutional yield opportunities
     * Returns the top available institutional yield opportunities for a given market, pre-filtered by Sonar risk signals. Disabled yield sources and depegged tokens are excluded by default. Results are sorted by APY descending.
     */
    engineOpportunities(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/engine/opportunities`, _p);
    }
    /**
     * Institutional market APY benchmark
     * Returns APY statistics for all Sonar-clean vaults in a given market. Useful for benchmarking institutional portfolios against the currently available Sonar-cleared yield universe.
     */
    engineBenchmark(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/engine/benchmark`, _p);
    }
    /**
     * Institutional allocation recommendation
     * Returns a recommended allocation across top-APY yield sources for a given portfolio value. Applies Sonar risk filters so disabled yield sources and depegged tokens are excluded. Uses equal-weight greedy allocation (top N by APY). For deeper execution-layer optimisation, use the institutional execution stack directly.
     */
    engineAllocate(body) {
        return this._post(`/v1/engine/allocate`, body);
    }
    /**
     * Institutional rebalancing recommendation
     * Given current institutional yield source positions, computes a rebalancing plan: which positions to exit (risk-flagged, depegged, or suboptimal APY), which to keep, and which new positions to enter. Returns current versus optimal APY and the improvement delta.
     */
    engineRebalance(body) {
        return this._post(`/v1/engine/rebalance`, body);
    }
    /**
     * Allocation audit trail
     * Returns the recommended allocation alongside a full audit trail: APY rank of each vault considered, per-detector Sonar clearance status, and explicit reasons why each vault was selected or rejected. Designed for compliance review and institutional due diligence.
     */
    engineExplain(body) {
        return this._post(`/v1/engine/explain`, body);
    }
    /**
     * Institutional portfolio comparison
     * Compares a current institutional portfolio against a proposed portfolio side by side. Returns APY delta, Sonar risk delta, which positions were exited or entered, and an overall assessment (improvement / degradation / neutral).
     */
    engineCompare(body) {
        return this._post(`/v1/engine/compare`, body);
    }
    /**
     * Institutional portfolio optimization
     * Accepts a current portfolio keyed by chain_id and returns an APY-optimized allocation across authorized vaults. Applies Sonar risk filters and the client's vault allowlist. Mirrors the contract of the fungi-core institutional_endpoint script.
     */
    engineInstitutional(body) {
        return this._post(`/v1/engine/institutional`, body);
    }
    /**
     * Allocation with execution-ready calldata
     * Runs the institutional optimisation **and** returns the on-chain transaction batch (withdraws → approvals → deposits) needed to reach the target portfolio. Calldata is rendered from the live vault catalog — no per-protocol code paths. Designed for partners running automated DeFi treasury workflows (Ampli, etc.).
     */
    engineExecute(body) {
        return this._post(`/v1/engine/execute`, body);
    }
    /**
     * Live protocol catalog (APY + TVL) for a chain × token
     * Returns every active vault we monitor for this chain + token with its current APY, TVL, and (when available) numeric risk score. Shaped to match the discovery feed in Ampli §5.3 — partners can consume it directly without an adapter.
     */
    engineProtocols(chainId, tokenAddress) {
        return this._get(`/v1/engine/protocols/${chainId}/${tokenAddress}`);
    }
    /**
     * Yield opportunities (custom risk)
     * All available institutional yield sources for a given market sorted by APY. No Sonar risk filtering is applied, so all vaults are included regardless of risk status. Sonar signals are not exposed; clients apply their own risk logic.
     */
    engineRawOpportunities(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/engine/raw/opportunities`, _p);
    }
    /**
     * Market APY benchmark (custom risk)
     * APY statistics across all vaults in a market, including Sonar-flagged ones. Useful for institutional teams that want the full yield landscape without Sonar filtering.
     */
    engineRawBenchmark(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/engine/raw/benchmark`, _p);
    }
    /**
     * Allocation recommendation (custom risk)
     * Recommended allocation across top-APY vaults with no Sonar risk filtering. Allocates purely by APY. Clients apply their own institutional risk layer.
     */
    engineRawAllocate(body) {
        return this._post(`/v1/engine/raw/allocate`, body);
    }
    /**
     * Rebalancing recommendation (custom risk)
     * Rebalancing recommendation with no Sonar risk filtering. Exit reasons are APY-based only — no risk_flagged or token_depegged exits.
     */
    engineRawRebalance(body) {
        return this._post(`/v1/engine/raw/rebalance`, body);
    }
    /**
     * Portfolio comparison (custom risk)
     * Side-by-side institutional portfolio comparison with no Sonar risk filtering. Assessment is based purely on APY delta. Sonar risk delta fields are not returned.
     */
    engineRawCompare(body) {
        return this._post(`/v1/engine/raw/compare`, body);
    }
    /**
     * Institutional Sonar screening
     * Screen up to 200 vault addresses in a single call. Returns a per-vault risk tier (blocked / caution / clear), the active Sonar detectors that flagged each vault, and a full disable-source breakdown. Designed for due diligence workflows and compliance audit trails.
     */
    sonarScreen(body) {
        return this._post(`/v1/sonar/screen`, body);
    }
    /**
     * Institutional pre-trade validation
     * Validates a proposed institutional vault position before execution. Checks the vault kill-switch, deposit token depeg status, and optionally TVL concentration if a position size is provided. Returns an operational recommendation: safe_to_enter, caution, or blocked.
     */
    sonarValidate(body) {
        return this._post(`/v1/sonar/validate`, body);
    }
    /**
     * TCN model info
     * Returns metadata about the currently loaded APY predictor: whether it is a trained neural model or the heuristic fallback, training timestamp, vault count, and validation loss.
     */
    simulationModelInfo() {
        return this._get(`/v1/simulation/model/info`);
    }
    /**
     * Available chain/token combinations
     * Returns live chain→token mapping derived from vault data in apy_data.
     */
    simulationChains() {
        return this._get(`/v1/simulation/chains`);
    }
    /**
     * Create portfolio simulation
     * Queues a simulation of portfolio performance over the specified horizon. Uses TCN-predicted APY distributions and models gas, slippage, and bridge costs at every rebalancing event. Poll the returned `poll_url` for results.
     */
    simulation(body) {
        return this._post(`/v1/simulation`, body);
    }
    /**
     * List simulations
     * Returns recent simulation jobs for the authenticated client, newest first.
     */
    simulations(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/simulations`, _p);
    }
    /**
     * Poll simulation result
     * Returns the current status of a simulation job. When `status` is `complete`, the `result` field contains the full P10/P50/P90 portfolio value curves and cost breakdown. Typical completion time: 5–15 seconds.
     */
    getSimulation(jobId) {
        return this._get(`/v1/simulation/${jobId}`);
    }
    /**
     * Delete simulation
     * Permanently deletes a simulation job and its results.
     */
    deleteSimulation(jobId) {
        return this._post(`/v1/simulation/${jobId}`, {});
    }
    /**
     * Period-by-period simulation breakdown
     * Returns a snapshot for every rebalancing period: P10/P50/P90 values, APY applied, costs incurred, and active vaults.
     */
    simulationTimeline(jobId) {
        return this._get(`/v1/simulation/${jobId}/timeline`);
    }
    /**
     * Get Pricing
     * Public pricing manifest — backs `/pricing` UI + `/docs` price badges.
     */
    pricing() {
        return this._get(`/v1/pricing`);
    }
    /**
     * Get Pricing Quote
     * Pre-flight price + accepts entries — lets clients dry-run x402 flows.
     */
    pricingQuote(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/pricing/quote`, _p);
    }
    /**
     * Siwe Nonce
     */
    billingSiweNonce(body) {
        return this._post(`/v1/billing/siwe/nonce`, body);
    }
    /**
     * Siwe Verify
     */
    billingSiweVerify(body) {
        return this._post(`/v1/billing/siwe/verify`, body);
    }
    /**
     * Logout
     */
    billingLogout() {
        return this._post(`/v1/billing/logout`, {});
    }
    /**
     * Billing Me
     */
    billingMe() {
        return this._get(`/v1/billing/me`);
    }
    /**
     * Billing Keys
     */
    billingKeys() {
        return this._get(`/v1/billing/keys`);
    }
    /**
     * Billing Payments
     */
    billingPayments(query) {
        const _p = {};
        if (query)
            Object.entries(query).forEach(([k, v]) => {
                if (v != null)
                    _p[k] = v;
            });
        return this._get(`/v1/billing/payments`, _p);
    }
    /**
     * Facilitator Verify
     */
    facilitatorVerify() {
        return this._post(`/v1/facilitator/verify`, {});
    }
    /**
     * Facilitator Settle
     */
    facilitatorSettle() {
        return this._post(`/v1/facilitator/settle`, {});
    }
    /**
     * Facilitator Supported
     */
    facilitatorSupported() {
        return this._get(`/v1/facilitator/supported`);
    }
}
//# sourceMappingURL=intelligence.js.map