import { validateCustomElementTag } from "@pie-players/pie-players-shared/pie/tag-names";
/**
 * Canonical default web component tag mapping for toolkit tools.
 * Integrators can override any entry via ToolComponentOverrides.
 */
export const DEFAULT_TOOL_TAG_MAP = {
    calculator: "pie-tool-calculator",
    textToSpeech: "pie-tool-text-to-speech",
    ruler: "pie-tool-ruler",
    protractor: "pie-tool-protractor",
    answerEliminator: "pie-tool-answer-eliminator",
    highlighter: "pie-tool-annotation-toolbar",
    lineReader: "pie-tool-line-reader",
    theme: "pie-tool-theme",
    annotationToolbar: "pie-tool-annotation-toolbar",
    graph: "pie-tool-graph",
    periodicTable: "pie-tool-periodic-table",
};
export const resolveToolTag = (toolId, overrides) => {
    const mapped = overrides?.toolTagMap?.[toolId] ?? DEFAULT_TOOL_TAG_MAP[toolId] ?? toolId;
    return validateCustomElementTag(mapped, `tool component tag for "${toolId}"`);
};
const createDefaultToolElement = (tagName) => document.createElement(tagName);
export const createToolElement = (toolId, context, toolbarContext, overrides) => {
    const tagName = resolveToolTag(toolId, overrides);
    const factoryForTool = overrides?.toolComponentFactories?.[toolId];
    const factory = factoryForTool ?? overrides?.toolComponentFactory;
    return factory
        ? factory({ toolId, tagName, context, toolbarContext })
        : createDefaultToolElement(tagName);
};
export const toToolIdFromTag = (tagName, overrides) => {
    const validTag = validateCustomElementTag(tagName, "tool component tag");
    const map = { ...DEFAULT_TOOL_TAG_MAP, ...overrides?.toolTagMap };
    return Object.entries(map).find(([, tag]) => tag === validTag)?.[0];
};
//# sourceMappingURL=tool-tag-map.js.map