/**
 * docx-preview 高保真 Word 渲染（预览区）
 * 使用动态 import，避免阻塞原型入口模块加载。
 */

var DEFAULT_RENDER_OPTIONS = {
	className: 'ct-docx-preview',
	inWrapper: true,
	ignoreWidth: false,
	ignoreHeight: false,
	ignoreFonts: false,
	breakPages: true,
	ignoreLastRenderedPageBreak: true,
	trimXmlDeclaration: true,
	useBase64URL: true,
};

export async function renderDocxPreview(container, arrayBuffer, options) {
	if (!container || !arrayBuffer) return;
	container.innerHTML = '';
	var mod = await import('docx-preview');
	var renderAsync = mod.renderAsync;
	if (typeof renderAsync !== 'function') {
		throw new Error('docx-preview 模块未正确加载');
	}
	await renderAsync(
		arrayBuffer,
		container,
		null,
		Object.assign({}, DEFAULT_RENDER_OPTIONS, options || {})
	);
}
