import type { FormSchemaEntryShared } from "../form/webcomponent.type";

/** Map source passed to embedded `hb-map`. */
export type InputCoordsMapSource = {
  type: string;
  url?: string;
};

export type InputCoordsMapOptions = {
  centerFromGeometries?: boolean;
};

export type InputCoordsParams = {
  /** Default zoom when syncing from schema. */
  zoom?: number;
  latitudePlaceholder?: string;
  longitudePlaceholder?: string;
  latitudeLabel?: string;
  longitudeLabel?: string;
  source?: InputCoordsMapSource;
  options?: InputCoordsMapOptions;
  /** `[lng, lat]` or map center tuple consumed by the map child. */
  center?: number[];
};

export type FormSchemaEntry = Omit<FormSchemaEntryShared, "params"> & {
  /**
   * Optional default value.
   */
  value?: { lat: number; lon: number };
  params?: InputCoordsParams;
};

export type Component = {
  id?: string;
  style?: string;
  show_validation?: "yes" | "no";
  schemaentry: FormSchemaEntry | undefined;
  i18nlang?: string;
};

export type Events = {
  setVal: {
    value: { lat: number; lon: number } | undefined;
    valid: boolean;
    id: string;
  };
};
