/** The FileMaker object injected by the runtime into web viewers. */
export interface FileMakerAPI {
    PerformScript(script: string, parameter?: string): void;
    PerformScriptWithOption(script: string, parameter?: string, option?: ScriptOption): void;
}
declare global {
    /** Available only inside a FileMaker web viewer. Always guard with `typeof FileMaker !== 'undefined'`. */
    const FileMaker: FileMakerAPI | undefined;
    interface Window {
        resolveFileMakerCallback: typeof resolveFileMakerCallback;
    }
}
/**
 * Controls how a currently running FileMaker script is handled when a new
 * script is started via `FileMaker.PerformScriptWithOption`.
 *
 * | Value | Behaviour                                                        |
 * |-------|------------------------------------------------------------------|
 * | "0"   | Pause the current script, run the new one, then resume          |
 * | "1"   | Abort the current script and run the new one                    |
 * | "2"   | Exit the current script and run the new one                     |
 * | "3"   | Run the new script concurrently (default async behaviour)       |
 * | "4"   | Trigger script (same as 3 but fires as a script trigger would)  |
 * | "5"   | Suspend the current script; resume it after the new one exits   |
 */
export type ScriptOption = '0' | '1' | '2' | '3' | '4' | '5';
/**
 * Type-safe wrapper that calls `FileMaker.PerformScript` only when the
 * runtime is available (i.e. the page is running inside a web viewer).
 *
 * @returns `true` if the script was dispatched, `false` otherwise.
 *
 * @example
 * performScript("Delete Record", String(recordId));
 */
export declare function performScript(script: string, parameter?: string): boolean;
/**
 * Type-safe wrapper around `FileMaker.PerformScriptWithOption`.
 *
 * @returns `true` if the script was dispatched, `false` otherwise.
 */
export declare function performScriptWithOption(script: string, parameter?: string, option?: ScriptOption): boolean;
/** Error thrown when a FileMaker script signals failure. */
export interface FileMakerScriptError {
    /** The callback ID that was active when the error occurred. */
    callbackId: number;
    /** Optional error message forwarded from the FileMaker script. */
    message?: string;
}
/**
 * Invokes a FileMaker script and returns a `Promise` that resolves when
 * FileMaker calls back into JavaScript via {@link resolveFileMakerCallback}.
 *
 * **FileMaker side:** the script must eventually call
 * *Perform JavaScript in Web Viewer* targeting `resolveFileMakerCallback`
 * and pass back the same `callbackId` together with the result data.
 *
 * ```
 * // FileMaker script (pseudocode)
 * Set Variable [$payload ; Value: Get(ScriptParameter)]
 * Set Variable [$id     ; Value: JSONGetElement($payload; "callbackId")]
 * Set Variable [$result ; Value: \* … your work … *\]
 * Perform JavaScript in Web Viewer [
 *   Object Name: "MyWebViewer"
 *   Function:    "resolveFileMakerCallback"
 *   Parameters:  $id, $result
 * ]
 * ```
 *
 * @param script    - FileMaker script name.
 * @param parameter - Arbitrary string payload for the script.
 * @param timeout   - Optional ms before the promise is rejected automatically
 *                    (defaults to no timeout).
 *
 * @example
 * const json = await callFileMakerScript("Get Customer", String(customerId));
 * const customer = JSON.parse(json);
 */
export declare function callFileMakerScript(script: string, parameter?: string, timeout?: number): Promise<string>;
/**
 * Must be exposed as a global function so that FileMaker's
 * *Perform JavaScript in Web Viewer* script step can invoke it.
 *
 * Call this from your FileMaker script to resolve a promise created by
 * {@link callFileMakerScript}.
 *
 * @param callbackId - The numeric ID forwarded from the script parameter.
 * @param result     - The string result to hand back to JavaScript.
 * @param isError    - When truthy, the promise is rejected instead.
 *
 * @example
 * // Expose globally so FileMaker can reach it
 * (window as any).resolveFileMakerCallback = resolveFileMakerCallback;
 */
export declare function resolveFileMakerCallback(callbackId: string, result?: string, isError?: boolean): void;
export declare function waitForFileMaker(callback: () => void, onError?: () => void, maxAttempts?: number, // 1 Sekunde bei 100ms Intervall
attempt?: number): void;
/**
 * Returns `true` when the page is running inside a FileMaker web viewer.
 *
 * @example
 * if (isFileMakerEnvironment()) {
 *   FileMaker!.PerformScript("On Load");
 * }
 */
export declare function isFileMakerEnvironment(): boolean;
