/**
 * Having Survey types in types.ts was confusing tsc
 * and generating an invalid module.d.ts
 * See https://github.com/PostHog/posthog-js/issues/698
 */
import type { Properties, PropertyMatchType } from './types';
import type { SurveyAppearance as CoreSurveyAppearance, SurveyValidationRule } from '@posthog/core';
export declare enum SurveyEventType {
    Activation = "events",
    Cancellation = "cancelEvents"
}
export type PropertyOperator = PropertyMatchType | 'gt' | 'lt';
export type PropertyFilters = {
    [propertyName: string]: {
        values: string[];
        operator: PropertyOperator;
    };
};
export interface SurveyEventWithFilters {
    name: string;
    propertyFilters?: PropertyFilters;
}
export declare enum SurveyWidgetType {
    Button = "button",
    Tab = "tab",
    Selector = "selector"
}
export declare enum SurveyPosition {
    TopLeft = "top_left",
    TopRight = "top_right",
    TopCenter = "top_center",
    MiddleLeft = "middle_left",
    MiddleRight = "middle_right",
    MiddleCenter = "middle_center",
    Left = "left",
    Center = "center",
    Right = "right",
    NextToTrigger = "next_to_trigger"
}
export declare enum SurveyTabPosition {
    Top = "top",
    Left = "left",
    Right = "right",
    Bottom = "bottom"
}
export interface SurveyAppearance extends Omit<CoreSurveyAppearance, 'position'> {
    /** @deprecated - not currently used */
    descriptionTextColor?: string;
    ratingButtonHoverColor?: string;
    whiteLabel?: boolean;
    tabPosition?: SurveyTabPosition;
    fontFamily?: string;
    maxWidth?: string;
    zIndex?: string;
    disabledButtonOpacity?: string;
    boxPadding?: string;
    /** @deprecated Use inputBackground instead (inherited from core) */
    inputBackgroundColor?: string;
    hideCancelButton?: boolean;
    position?: SurveyPosition;
}
export declare enum SurveyType {
    Popover = "popover",
    API = "api",
    Widget = "widget",
    ExternalSurvey = "external_survey"
}
export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
export type SurveyQuestionDescriptionContentType = 'html' | 'text';
interface SurveyQuestionBase {
    question: string;
    id?: string;
    description?: string | null;
    descriptionContentType?: SurveyQuestionDescriptionContentType;
    optional?: boolean;
    buttonText?: string;
    branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
    validation?: SurveyValidationRule[];
}
export interface BasicSurveyQuestion extends SurveyQuestionBase {
    type: SurveyQuestionType.Open;
}
export interface LinkSurveyQuestion extends SurveyQuestionBase {
    type: SurveyQuestionType.Link;
    link?: string | null;
}
export interface RatingSurveyQuestion extends SurveyQuestionBase {
    type: SurveyQuestionType.Rating;
    display: 'number' | 'emoji';
    scale: 2 | 3 | 5 | 7 | 10;
    lowerBoundLabel: string;
    upperBoundLabel: string;
    skipSubmitButton?: boolean;
}
export interface MultipleSurveyQuestion extends SurveyQuestionBase {
    type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
    choices: string[];
    hasOpenChoice?: boolean;
    shuffleOptions?: boolean;
    skipSubmitButton?: boolean;
}
export declare enum SurveyQuestionType {
    Open = "open",
    MultipleChoice = "multiple_choice",
    SingleChoice = "single_choice",
    Rating = "rating",
    Link = "link"
}
export declare enum SurveyQuestionBranchingType {
    NextQuestion = "next_question",
    End = "end",
    ResponseBased = "response_based",
    SpecificQuestion = "specific_question"
}
interface NextQuestionBranching {
    type: SurveyQuestionBranchingType.NextQuestion;
}
interface EndBranching {
    type: SurveyQuestionBranchingType.End;
}
interface ResponseBasedBranching {
    type: SurveyQuestionBranchingType.ResponseBased;
    responseValues: Record<string, any>;
}
interface SpecificQuestionBranching {
    type: SurveyQuestionBranchingType.SpecificQuestion;
    index: number;
}
export type SurveyCallback = (surveys: Survey[], context?: {
    isLoaded: boolean;
    error?: string;
}) => void;
export interface SurveyElement {
    text?: string;
    $el_text?: string;
    tag_name?: string;
    href?: string;
    attr_id?: string;
    attr_class?: string[];
    nth_child?: number;
    nth_of_type?: number;
    attributes?: Record<string, any>;
    event_id?: number;
    order?: number;
    group_id?: number;
}
export type { SurveyRenderReason } from '@posthog/types';
export declare enum SurveySchedule {
    Once = "once",
    Recurring = "recurring",
    Always = "always"
}
export interface Survey {
    id: string;
    name: string;
    description: string;
    type: SurveyType;
    feature_flag_keys: {
        key: string;
        value?: string;
    }[] | null;
    linked_flag_key: string | null;
    targeting_flag_key: string | null;
    internal_targeting_flag_key: string | null;
    questions: SurveyQuestion[];
    appearance: SurveyAppearance | null;
    conditions: {
        url?: string;
        selector?: string;
        seenSurveyWaitPeriodInDays?: number;
        urlMatchType?: PropertyMatchType;
        /** events that trigger surveys */
        events: {
            repeatedActivation?: boolean;
            values: SurveyEventWithFilters[];
        } | null;
        /** events that cancel "pending" (time-delayed) surveys */
        cancelEvents: {
            values: SurveyEventWithFilters[];
        } | null;
        actions: {
            values: SurveyActionType[];
        } | null;
        deviceTypes?: string[];
        deviceTypesMatchType?: PropertyMatchType;
        linkedFlagVariant?: string;
    } | null;
    start_date: string | null;
    end_date: string | null;
    current_iteration: number | null;
    current_iteration_start_date: string | null;
    schedule?: SurveySchedule | null;
    enable_partial_responses?: boolean | null;
}
export type SurveyWithTypeAndAppearance = Pick<Survey, 'id' | 'type' | 'appearance'>;
export interface SurveyActionType {
    id: number;
    name: string | null;
    steps?: ActionStepType[];
}
/** Sync with plugin-server/src/types.ts */
export type ActionStepStringMatching = 'contains' | 'exact' | 'regex';
export interface ActionStepType {
    event?: string | null;
    selector?: string | null;
    /** pre-compiled regex pattern for matching selector against $elements_chain */
    selector_regex?: string | null;
    /** @deprecated Only `selector` should be used now. */
    tag_name?: string;
    text?: string | null;
    /** @default StringMatching.Exact */
    text_matching?: ActionStepStringMatching | null;
    href?: string | null;
    /** @default ActionStepStringMatching.Exact */
    href_matching?: ActionStepStringMatching | null;
    url?: string | null;
    /** @default StringMatching.Contains */
    url_matching?: ActionStepStringMatching | null;
    /** Property filters for action step matching */
    properties?: {
        key: string;
        value?: string | number | boolean | (string | number | boolean)[] | null;
        operator?: PropertyMatchType;
        type?: string;
    }[];
}
export declare enum SurveyEventName {
    SHOWN = "survey shown",
    DISMISSED = "survey dismissed",
    SENT = "survey sent",
    ABANDONED = "survey abandoned"
}
export declare enum SurveyEventProperties {
    SURVEY_ID = "$survey_id",
    SURVEY_NAME = "$survey_name",
    SURVEY_RESPONSE = "$survey_response",
    SURVEY_ITERATION = "$survey_iteration",
    SURVEY_ITERATION_START_DATE = "$survey_iteration_start_date",
    SURVEY_PARTIALLY_COMPLETED = "$survey_partially_completed",
    SURVEY_SUBMISSION_ID = "$survey_submission_id",
    SURVEY_QUESTIONS = "$survey_questions",
    SURVEY_COMPLETED = "$survey_completed",
    PRODUCT_TOUR_ID = "$product_tour_id",
    SURVEY_LAST_SEEN_DATE = "$survey_last_seen_date"
}
export declare enum DisplaySurveyType {
    Popover = "popover",
    Inline = "inline"
}
interface DisplaySurveyOptionsBase {
    ignoreConditions: boolean;
    ignoreDelay: boolean;
    displayType: DisplaySurveyType;
    /** Additional properties to include in all survey events (shown, sent, dismissed) */
    properties?: Properties;
    /** Pre-filled responses by question index (0-based) */
    initialResponses?: Record<number, SurveyResponseValue>;
}
export interface DisplaySurveyPopoverOptions extends DisplaySurveyOptionsBase {
    displayType: DisplaySurveyType.Popover;
    /** Override the survey's configured position */
    position?: SurveyPosition;
    /** CSS selector for the element to position the survey next to (when position is NextToTrigger) */
    selector?: string;
    /** When true, `survey shown` events will not be emitted automatically */
    skipShownEvent?: boolean;
}
interface DisplaySurveyInlineOptions extends DisplaySurveyOptionsBase {
    displayType: DisplaySurveyType.Inline;
    selector: string;
}
export type DisplaySurveyOptions = DisplaySurveyPopoverOptions | DisplaySurveyInlineOptions;
export interface SurveyConfig {
    prefillFromUrl?: boolean;
    /**
     * @deprecated No longer used. Surveys will automatically advance past
     * prefilled questions with skipSubmitButton enabled. If partial response
     * collection is enabled, partial responses for pre-filled questions will
     * be submitted automatically on page load.
     */
    autoSubmitIfComplete?: boolean;
    /**
     * @deprecated No longer used. Pre-filled responses are now sent
     * immediately when partial responses are enabled, or all required
     * quesions have been pre-filled.
     */
    autoSubmitDelay?: number;
}
export type SurveyResponseValue = string | number | string[] | null;
