/**
 * Static/fallback-visible FAQ markup.
 *
 * Uses native details/summary for accordion so content remains readable
 * and operable without the plugin or JavaScript.
 */

import { useBlockProps } from '@wordpress/block-editor';
import { RawHTML } from '@wordpress/element';
import { buildFaqClassList, buildFaqInnerHtml } from './utils/serialize';

/**
 * @param {Object} props
 * @param {Object} props.attributes
 * @return {JSX.Element} Saved markup.
 */
export default function save({ attributes }) {
	const attrs = attributes || {};
	const schemaVersion = attrs.schemaVersion || 1;

	const blockProps = useBlockProps.save({
		className: buildFaqClassList(attrs).join(' '),
		'data-seovault-block': 'faq',
		'data-schema-version': String(schemaVersion),
	});

	return (
		<section {...blockProps}>
			<RawHTML>{buildFaqInnerHtml(attrs)}</RawHTML>
		</section>
	);
}
