import type { MutableRefObject } from "react"; import { forwardRef } from "react"; import type { BookerLayout } from "@calcom/features/bookings/Booker/types"; import { APP_NAME } from "@calcom/lib/constants"; import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { TextArea } from "@calcom/ui/components/form"; import type { EmbedFramework, EmbedType, PreviewState } from "../types"; import { Codes } from "./EmbedCodes"; import { buildCssVarsPerTheme } from "./buildCssVarsPerTheme"; import { embedLibUrl, EMBED_PREVIEW_HTML_URL } from "./constants"; import { getApiNameForReactSnippet, getApiNameForVanillaJsSnippet } from "./getApiName"; import { getDimension } from "./getDimension"; import { useEmbedCalOrigin } from "./hooks"; export const enum EmbedTabName { HTML = "embed-code", IFRAME_REACT = "embed-react", ATOM_REACT = "embed-atom-react", } export const tabs = [ { name: "HTML (iframe)", href: "embedTabName=embed-code", icon: "code" as const, type: "code", "data-testid": "HTML", Component: forwardRef< HTMLTextAreaElement | HTMLIFrameElement | null, { embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string } >(function EmbedHtml({ embedType, calLink, previewState, namespace }, ref) { const { t } = useLocale(); const embedSnippetString = useGetEmbedSnippetString(namespace); const embedCalOrigin = useEmbedCalOrigin(); if (ref instanceof Function || !ref) { return null; } if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) { return null; } return ( <>