'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React, { Fragment } from 'react';
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
import { useDocumentTitle } from '../../providers/DocumentTitle/index.js';
import { IDLabel } from '../IDLabel/index.js';
import './index.scss';
const baseClass = 'render-title';
export const RenderTitle = (props)=>{
    const { className, element = 'h1', fallback, title: titleFromProps } = props;
    const { id, isInitializing } = useDocumentInfo();
    const { title: titleFromContext } = useDocumentTitle();
    const title = titleFromProps || titleFromContext || fallback;
    const idAsTitle = title === id;
    const Tag = element;
    // Render and invisible character to prevent layout shift when the title populates from context
    const EmptySpace = /*#__PURE__*/ _jsxDEV(Fragment, {
        children: " "
    }, void 0, false, {
        fileName: "src/elements/RenderTitle/index.tsx",
        lineNumber: 32,
        columnNumber: 22
    }, this);
    return /*#__PURE__*/ _jsxDEV(Tag, {
        className: [
            className,
            baseClass,
            idAsTitle && `${baseClass}--has-id`
        ].filter(Boolean).join(' '),
        "data-doc-id": id,
        title: title,
        children: isInitializing ? EmptySpace : /*#__PURE__*/ _jsxDEV(Fragment, {
            children: idAsTitle ? /*#__PURE__*/ _jsxDEV(IDLabel, {
                className: `${baseClass}__id`,
                id: id
            }, void 0, false, {
                fileName: "src/elements/RenderTitle/index.tsx",
                lineNumber: 46,
                columnNumber: 24
            }, this) : title || EmptySpace
        }, void 0, false, {
            fileName: "src/elements/RenderTitle/index.tsx",
            lineNumber: 45,
            columnNumber: 9
        }, this)
    }, void 0, false, {
        fileName: "src/elements/RenderTitle/index.tsx",
        lineNumber: 35,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map