/**
 * Utils for knowledge studio supporting access to utilities shared between Studio and the SDK
 *
 * NOTE TO DEVS
 * MINIMIZE USE OF INTERNAL SDK ACCESS!
 * To the maximum extent possible, ArcGIS Knowledge Studio should use the same public interface as
 * PS/3rd part developers.
 *
 * @internal
 * @internal
 */
import type WebLinkChart from "../../WebLinkChart.js";
import type Extent from "../../geometry/Extent.js";
import type Point from "../../geometry/Point.js";
import type LinkChartLayer from "../../layers/LinkChartLayer.js";
import type LabelClass from "../../layers/support/LabelClass.js";
import type KnowledgeGraph from "../../rest/knowledgeGraph/KnowledgeGraph.js";
import type { LinkChartLayerProperties } from "../../layers/LinkChartLayer.js";
import type { IdTypePair } from "../../layers/knowledgeGraph/types.js";
import type { RequestOptions } from "../../request/types.js";

/**
 * @param extent
 * @internal
 * @internal
 */
export function extentToInBoundsRings(extent: Extent): number[][][];

/**
 * @internal
 * @internal
 */
export interface BindParametersFromCypherQueryResult {
  /** @internal */
  bindParameters: string[];
  /** @internal */
  parseErrors: RecognizerError[] | null;
}

/**
 * @internal
 * @internal
 */
export interface RecognizerError {
  /** @internal */
  line: number;
  /** @internal */
  column: number;
  /** @internal */
  msg: string;
  /** @internal */
  e?: any;
}

/**
 * @param query
 * @internal
 * @internal
 */
export function getBindParametersFromCypherQuery(query: string): Promise<BindParametersFromCypherQueryResult>;

/**
 * @param properties
 * @internal
 * @internal
 */
export function newLinkChartLayerWithOptimizedGeometry(properties?: LinkChartLayerWithOptimizedGeometryProperties): LinkChartLayer;

/**
 * @internal
 * @internal
 */
export type LinkChartLayerWithOptimizedGeometryProperties = Omit<LinkChartLayerProperties, "initializationInclusionModeDefinition">
  & {
  /** @internal */
  initializationInclusionModeDefinition?: InclusionModeDefinitionOptimizedGeometry;
};

/**
 * Defines the sublayer structure and the named types that will be in the KnowledgeGraphLayer
 *
 * @internal
 * @internal
 */
export interface InclusionModeDefinitionOptimizedGeometry {
  /**
   * Specifies whether to create sublayers for each [named type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphNamedObject/)
   * regardless of whether or not they are included in the `namedTypeDefinition`. If `true` all named types ([EntityType](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) and
   * [RelationshipType](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/)) will be added as an empty sublayer.
   *
   * @internal
   */
  generateAllSublayers: boolean;
  /**
   * A map of named types and the specific instances
   * of those types to include in the layer.
   *
   * @internal
   */
  namedTypeDefinitions: Map<string, LayerInclusionDefinition>;
}

/**
 * @internal
 * @internal
 */
export interface LayerInclusionDefinition {
  /**
   * If `true` all of the instances of the named type will be included regardless of if there is a defined list of members.
   * If `false` only the instances specified in the `members` property will be included.
   *
   * @internal
   */
  useAllData: boolean;
  /**
   * A map of the specific members of the named type to be included.
   * The key is the global ID of the instance.
   *
   * @internal
   */
  members?: Map<string, LayerInclusionMemberDefinition>;
}

/**
 * Defines the list of `members` for a named type in the [InclusionModeDefinitionOptimizedGeometry](https://developers.arcgis.com/javascript/latest/references/core/applications/KnowledgeStudio/generalSharedKgUtils/#InclusionModeDefinitionOptimizedGeometry).
 *
 * @internal
 * @internal
 */
export interface LayerInclusionMemberDefinition {
  /**
   * The global ID of the specific instance of the named type to be included in the layer.
   *
   * @internal
   */
  id: string;
  /**
   * The exact point location of the entity on the LinkChart.
   *
   * @internal
   */
  linkChartLocation?: Point | OptimizedGeometry;
}

/**
 * An alternative geometry format for serialized geometries
 *
 * @internal
 * @internal
 */
export interface OptimizedGeometry {
  /** @internal */
  lengths: number[];
  /** @internal */
  coords: number[];
}

/**
 * @param graphType
 * @param graphTypeName
 * @param displayLabelProperty
 * @internal
 * @internal
 */
export function getDefaultLinkChartSublayerLabelingInfos(graphType: "entity" | "relationship", graphTypeName: string, displayLabelProperty: string): LabelClass[] | null | undefined;

/**
 * @param graphTypeName
 * @param geometryType
 * @param displayLabelProperty
 * @internal
 * @internal
 */
export function getDefaultKnowledgeSublayerLabelingInfos(graphTypeName: string, geometryType: "point" | "multipoint" | "polyline" | "polygon" | null | undefined, displayLabelProperty: string): LabelClass[] | null | undefined;

/**
 * Returns the entity endpoints for the given relationships.
 *
 * @param records - Relationships to find the endpoints for.
 * @param kg - The knowledge graph service that contains the relationships.
 * @param options
 * @returns Returns the origin and destination entity and named types for each relationship.
 * @internal
 * @internal
 */
export function studioGetRelationshipEndNodeIds(records: IdTypePair[], kg: KnowledgeGraph, options?: StudioGetRelationshipEndNodeIdsOptions): Promise<IdTypePair[]>;

/**
 * @internal
 * @internal
 */
export interface StudioGetRelationshipEndNodeIdsOptions {
  /**
   * Additional [options](https://developers.arcgis.com/javascript/latest/references/core/request/types/#RequestOptions) to be used for the data request.
   *
   * @internal
   */
  requestOptions?: RequestOptions;
}

/**
 * Returns a map of origin and destination entities for  specific relationships.
 *
 * @param records - The relationships to retrieve the endpoints for.
 * @param kg - The knowledge graph containing the relationships.
 * @param options
 * @returns Returns the relationship id, and the origin and destination ids.
 * @internal
 * @internal
 */
export function studioGetRelationshipEndNodeMap(records: IdTypePair[], kg: KnowledgeGraph, options?: StudioGetRelationshipEndNodeMapOptions): Promise<Map<string, [
    string,
    string
]>>;

/**
 * @internal
 * @internal
 */
export interface StudioGetRelationshipEndNodeMapOptions {
  /**
   * Additional [options](https://developers.arcgis.com/javascript/latest/references/core/request/types/#RequestOptions) to be used for the data request.
   *
   * @internal
   */
  requestOptions?: RequestOptions;
}

/**
 * Returns a map of origin and destination entities for  specific relationships.
 *
 * @param json - The JSON representation of a WebLinkChart.
 * @internal
 * @internal
 */
export function webLinkChartFromJSON(json: any): WebLinkChart;