<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-scope locals in included view files are not plugin globals.

$render_variables = get_defined_vars();
if (
	! isset( $toolbar_view_model, $woocommerce_available, $auth_connected )
	|| ! is_array( $toolbar_view_model )
	|| ! is_bool( $woocommerce_available )
	|| ! is_bool( $auth_connected )
	|| ! array_key_exists( 'credits_balance', $render_variables )
) {
	return;
}
unset( $render_variables );

$selected_route = $toolbar_view_model['route'] ?? null;
$source_options = $toolbar_view_model['sourceOptions'] ?? null;
if (
	! is_array( $selected_route )
	|| ! is_string( $selected_route['workflow'] ?? null )
	|| ! is_string( $selected_route['sourceType'] ?? null )
	|| ! is_string( $selected_route['scope'] ?? null )
	|| ! is_array( $source_options )
) {
	return;
}
$selected_workflow    = sanitize_key( (string) ( $selected_route['workflow'] ?? '' ) );
$selected_source_type = sanitize_key( (string) ( $selected_route['sourceType'] ?? '' ) );
$selected_scope       = sanitize_key( (string) ( $selected_route['scope'] ?? '' ) );
?>
<div
	class="fotogenic-ai-studio-page"
	data-fa-studio-page
	data-fa-ui-state="pending"
	aria-busy="true"
>
	<main
		class="fotogenic-ai-studio fotogenic-ai-studio-app"
		id="fotogenic-ai-studio"
		data-fotogenic-page="studio"
		data-fa-studio-root
		data-workflow="<?php echo esc_attr( $selected_workflow ); ?>"
		data-source-type="<?php echo esc_attr( $selected_source_type ); ?>"
		data-scope="<?php echo esc_attr( $selected_scope ); ?>"
	>
		<div class="fotogenic-ai-studio-preparing" data-fa-studio-preparing role="status" aria-live="polite">
			<span class="fotogenic-ai-icon fotogenic-ai-icon--spin fotogenic-ai-icon--size-20" aria-hidden="true"></span>
			<strong><?php esc_html_e( 'Preparing Studio…', 'fotogenic-ai' ); ?></strong>
		</div>
		<div class="fotogenic-ai-studio-application" data-fa-studio-application>
			<?php require FOTOGENIC_AI_PATH . 'templates/studio/header.php'; ?>
			<?php require FOTOGENIC_AI_PATH . 'templates/studio/shell.php'; ?>
			<div id="fotogenic-ai-error-overlay-root" hidden aria-hidden="true"></div>
		</div>
	</main>
</div>
<?php // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
