(event.currentTarget as HTMLInputElement).select()}
@input=${(event: Event) => {
const current = host._spaceDialog;
if (current?.copy && !current.busy) {
host._spaceDialog = {
...current,
copy: { ...current.copy, title: (event.target as HTMLInputElement).value },
};
}
}}
@keydown=${(event: KeyboardEvent) => {
if (event.key === 'Enter' && copy.title.trim() && !copy.busy) {
event.preventDefault();
submit();
}
}} />
`;
}
function showCopyError(host: HouseplanEditorHostPort, error: unknown): void {
if (error instanceof SpaceCopyError) {
host._showToast(host._t(ERROR_KEYS[error.code]));
return;
}
const code = (error as { code?: unknown } | null)?.code;
if (code === 'wall_model_client_outdated') {
host._showToast(host._t('toast.wall_model_client_outdated'));
return;
}
host._showToast(host._t('toast.error', { err: host._errText(error) }));
}
/** Submit one guarded two-step operation: optional Optimize, then config Copy. */
export async function saveSpaceCopy(
host: HouseplanEditorHostPort,
services: SpaceCopyRuntimeServices,
): Promise