import { computed, toValue } from 'vue' import type { ComputedRef, MaybeRefOrGetter } from 'vue' import IframeResizer from '@/utils/iframe-resizer' /** * Reactive inputs driving the embed-snippet derivation. They mirror the sizing * props of the `FormEmbed` component, accepted as plain values, refs or getters * so the composable stays adaptable to how the caller wires its props. */ export interface UseEmbedFormOptions { /** * URL to embed. When omitted (`null`/`undefined`), the current window * location is used instead. */ url: MaybeRefOrGetter /** * Iframe width. A string (e.g. `'100%'`) is used verbatim; a number is * clamped to `minWidth` before being stringified. */ width: MaybeRefOrGetter /** * Iframe height in pixels, clamped to `minHeight` before being stringified. */ height: MaybeRefOrGetter /** * Lower bound applied to a numeric `width`. */ minWidth: MaybeRefOrGetter /** * Lower bound applied to `height`. */ minHeight: MaybeRefOrGetter } /** * Reactive API returned by {@link useEmbedForm}. */ export interface UseEmbedForm { /** * The resolved URL to embed: the provided `url` when set, otherwise the * current window location. */ currentUrl: ComputedRef /** * Builds the embeddable HTML snippet for the current URL and sizing. * * @param withPym - When `true`, emit the responsive Pym.js snippet; otherwise * emit a plain `` } // Build the responsive Pym.js snippet for the given URL. function pymCodeFor(url: string): string { return IframeResizer.template(url) } /** * Owns the embed-snippet generation for the `FormEmbed` component: resolves the * URL to embed (explicit prop or current location), clamps the numeric sizing * to its minimums, and builds either a plain `