import type { ReactElement } from 'react'; /** * Mirrors `TransformedText` from @wordpress/i18n. * We don't import directly to avoid a circular dependency. */ type TransformedText = string & { readonly __transformedText: T; }; /** * The input that can be passed to `createInterpolateElement`. */ export type InterpolationInput = string | TransformedText; /** * The literal string extracted from the input. */ export type InterpolationString = Input extends TransformedText ? Text : Input; /** * Recursively trims trailing spaces from a string type. * Matches the runtime tokenizer's `\s*` before the closing `>` or `/>`. */ type TrimTrailingSpaces = S extends `${infer Rest} ` ? TrimTrailingSpaces : S; /** * Helper type to extract tag name and handle closing/self-closing indicators. * Filters out tags with spaces as they won't be parsed by the tokenizer. */ type ExtractTagName = T extends `/${string}` ? never : TrimTrailingSpaces extends infer Name extends string ? Name extends '' ? never : Name extends `${string} ${string}` ? never : Name extends `${infer Base}/` ? Base : Name : never; /** * Utility type to extract all tag names from a template literal string. * Only handles simple tags without attributes, matching the runtime tokenizer. */ export type ExtractTags = T extends `${string}<${infer Tag}>${infer After}` ? ExtractTagName | ExtractTags : never; /** * Utility type to create a conversion map that: * - Makes extracted tag keys optional * - Only allows properties for tags found in the template literal */ export type ConversionMap = Partial, ReactElement>>; export {}; //# sourceMappingURL=types.d.ts.map