# booking/11.8/includes/page-setup/setup_steps.php

Booking Calendar, version 11.8. 2,302 lines.

- Page: https://pluginprobe.com/plugins/booking/11.8/code/includes/page-setup/setup_steps.php
- Raw: https://pluginprobe.com/plugins/booking/11.8/raw/includes/page-setup/setup_steps.php
- Modified: 2026-09-10T16:09:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/booking/11.8/code/includes/page-setup/setup_steps.php#L10-L20`.

```php
<?php /**
 * @version 1.0
 * @description Steps Structure for Setup Wizard Page
 * @category    Setup Class
 * @author wpdevelop
 *
 * @web-site http://oplugins.com/
 * @email info@oplugins.com
 *
 * @modified 2024-09-06
 */

if ( ! defined( 'ABSPATH' ) ) exit;                                             // Exit if accessed directly


class WPBC_SETUP_WIZARD_STEPS {

	private $steps_arr = array();

	/**
	 * Whether setup route data has been initialized for this instance.
	 *
	 * The class is used both as a renderer and as an early setup-state helper. Some callers can reach it before the
	 * WordPress init hook, so route data must be available before any DB normalization or status checks run.
	 *
	 * @var bool
	 */
	private $is_steps_data_initialized = false;

	/**
	 * Whether the setup bar render hook has already been registered.
	 *
	 * This class is also used as a setup-state helper in AJAX and routing code, so multiple instances can exist during
	 * one request. Only one of them should render the floating setup bar.
	 *
	 * @var bool
	 */
	private static $is_top_bar_hook_registered = false;

	/**
	 * Whether the setup bar has already been printed in the current request.
	 *
	 * @var bool
	 */
	private static $is_top_bar_rendered = false;

	/**
	 * Check whether the legacy floating Setup Wizard bar is enabled.
	 *
	 * The bar is temporarily disabled while the initial Setup Wizard hands the
	 * user directly to Form Builder. The filter preserves a bounded rollback
	 * path without changing Setup Wizard progress or stored configuration.
	 *
	 * @return bool True when the floating Setup Wizard bar may be registered.
	 */
	private static function is_floating_setup_bar_enabled() {

		/**
		 * Filter whether the legacy floating Setup Wizard bar is enabled.
		 *
		 * @param bool $is_enabled Whether the floating Setup Wizard bar is enabled.
		 */
		return (bool) apply_filters( 'wpbc_setup_wizard_floating_bar_enabled', false );
	}

	public function __construct() {

		if ( WPBC()->is_wp_inited() || did_action( 'init' ) ) {
			$this->init_steps_data();
		} else {
			add_action( 'init', array( $this, 'init_steps_data' ) );
		}

		if ( self::is_floating_setup_bar_enabled() && ! self::$is_top_bar_hook_registered ) {
			add_action( 'wpbc_after_wpbc_page_top__header_tabs', array( $this, 'show_top_right_wizard_button' ), 10, 3 );
			self::$is_top_bar_hook_registered = true;
		}

	}

	/**
	 * Check whether translated strings can be loaded without triggering WordPress just-in-time translation notices.
	 *
	 * @return bool
	 */
	private function is_i18n_ready() {

		return ( WPBC()->is_wp_inited() || did_action( 'init' ) );
	}


	/**
	 * Define Steps Data Structure  -  Init
	 *
	 * @return void
	 */
	public function init_steps_data(){

		$is_i18n_ready = $this->is_i18n_ready();

		$step_default_params = array(
										'show_section_left'  => false,
										'show_section_right' => false,
										'is_done'            => false,
										'do_action'          => 'none',
										'prior'              => '',
										'next'               => '',
										'prior_title' 		 => $is_i18n_ready ? __( 'Go Back', 'booking' ) : 'Go Back',
										'next_title' 		 => $is_i18n_ready ? __( 'Save and Continue', 'booking' ) : 'Save and Continue'
									);
		$steps_arr = array();

		if ( function_exists( 'wpbc_setup_wizard__get_intro_route' ) ) {
			$route = wpbc_setup_wizard__get_intro_route();
		} else {
			$route = array( 'welcome' );
			if ( ! wpbc_is_this_demo() ) {
				$route[] = 'general_info';
			}
			$route[] = 'date_time_formats';
			$route[] = 'bookings_types';
		}
		$route = array_merge( $route, wpbc_setup_wizard__get_profile_route() );

		foreach ( $route as $step_index => $step_name ) {
			$steps_arr[ $step_name ]              = $step_default_params;
			$steps_arr[ $step_name ]['do_action'] = 'save_and_continue__' . $step_name;
			$steps_arr[ $step_name ]['prior']     = ( 0 === $step_index ) ? '' : $route[ $step_index - 1 ];
			$steps_arr[ $step_name ]['next']      = isset( $route[ $step_index + 1 ] ) ? $route[ $step_index + 1 ] : 'welcome';

			if ( $is_i18n_ready && function_exists( 'wpbc_setup_wizard__get_step_route_metadata' ) ) {
				$steps_arr[ $step_name ] = array_merge(
					$steps_arr[ $step_name ],
					wpbc_setup_wizard__get_step_route_metadata( $step_name )
				);
			}
		}

		foreach ( array( 'service_provider', 'date_selection', 'changeover_days', 'working_time', 'time_slots_availability', 'date_availability', 'form_structure', 'color_theme', 'wizard_publish' ) as $continue_step_name ) {
			if ( isset( $steps_arr[ $continue_step_name ] ) ) {
				$steps_arr[ $continue_step_name ]['next_title'] = $is_i18n_ready ? __( 'Continue', 'booking' ) : 'Continue';
			}
		}

		$this->steps_arr = $steps_arr;
		$this->is_steps_data_initialized = true;
	}

	/**
	 * Ensure setup route data is available before this instance reads or normalizes step state.
	 *
	 * @return void
	 */
	private function ensure_steps_data_initialized() {

		if ( ! $this->is_steps_data_initialized ) {
			$this->init_steps_data();
		}
	}

	/**
	 * Get Steps Data Structure
	 * @return array
	 */
	public function get_steps_arr(){
		$this->ensure_steps_data_initialized();

		return $this->steps_arr;
	}


	// =================================================================================================================
	// ==  Steps STRUCTURE  ==
	// =================================================================================================================

	/**
	 * Actual Step Number  -> 'general_info'        or      'date_availability'
	 *
	 * @return int
	 */
	public function get_active_step_name() {

		$steps_arr = $this->db__get_steps_is_done();

		$first_step_name = '';
		foreach ( $steps_arr as $step_name => $step ) {

			$first_step_name =  (empty($first_step_name)) ? $step_name : $first_step_name;

			if ( empty( $step ) ) {
				return $step_name;
			}
		}
		return $first_step_name;
	}


	/**
	 * Actual Step Number  -> 2
	 *
	 * @return int
	 */
	public function get_active_step_num( $current_step = '' ) {

		if ( ! empty( $current_step ) ) {
			return $this->get_step_num_by_name( $current_step );
		}

		$steps_arr        = $this->db__get_steps_is_done();
		$total_steps      = count( $steps_arr );
		$completed_steps  = 0;

		foreach ( $steps_arr as $step ) {
			if ( ! empty( $step ) ) {
				$completed_steps++;
			}
		}

		if ( $completed_steps >= $total_steps ) {
			return $total_steps;
		}

		return min( $completed_steps + 1, $total_steps );
	}

	/**
	 * Get Step Number by step name.
	 *
	 * @param string $current_step Step name.
	 *
	 * @return int
	 */
	public function get_step_num_by_name( $current_step ) {

		$step_num = 1;

		foreach ( array_keys( $this->get_steps_arr() ) as $step_name ) {
			if ( $step_name === $current_step ) {
				return $step_num;
			}
			$step_num++;
		}

		return 1;
	}

	/**
	 * Get the last wizard step saved in the setup wizard request history.
	 *
	 * @return string
	 */
	public function get_saved_current_step_name() {

		$steps_arr    = $this->get_steps_arr();
		$current_step = $this->get_active_step_name();

		if ( function_exists( 'wpbc_setup_wizard_page__get_cleaned_params__saved_request_default' ) ) {
			$saved_request_params = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default();

			if (
				is_array( $saved_request_params )
				&& ( ! empty( $saved_request_params['current_step'] ) )
				&& isset( $steps_arr[ $saved_request_params['current_step'] ] )
			) {
				$current_step = $saved_request_params['current_step'];
			}
		}

		return $current_step;
	}

	/**
	 * Get target URL for a setup step.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_target_url( $step_name ) {

		$steps_arr = $this->get_steps_arr();

		if ( isset( $steps_arr[ $step_name ]['target_url'] ) && ( ! empty( $steps_arr[ $step_name ]['target_url'] ) ) ) {
			return $steps_arr[ $step_name ]['target_url'];
		}

		return function_exists( 'wpbc_setup_wizard__get_step_target_url' )
			? wpbc_setup_wizard__get_step_target_url( $step_name )
			: wpbc_get_setup_wizard_page_url();
	}

	/**
	 * Get Continue URL for the floating setup bar.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_continue_url( $step_name ) {

		return function_exists( 'wpbc_setup_wizard__get_step_continue_url' )
			? wpbc_setup_wizard__get_step_continue_url( $step_name )
			: $this->get_step_target_url( $step_name );
	}

	/**
	 * Get step name from setup URL context or first incomplete setup step.
	 *
	 * @return string
	 */
	public function get_context_step_name() {

		$steps_arr    = $this->get_steps_arr();
		$current_step = $this->get_saved_current_step_name();

		// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
		if ( isset( $_REQUEST['wpbc_setup_step'] ) ) {
			// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
			$request_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) );
			if ( isset( $steps_arr[ $request_step ] ) ) {
				$current_step = $request_step;
				$this->db__save_current_step_name( $current_step );
				return $current_step;
			}
		}

		if ( $this->db__is_step_completed( 'bookings_types' ) && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_request' ) ) {
			$detected_step = wpbc_setup_wizard__detect_step_from_admin_request();
			if ( ! empty( $detected_step ) && isset( $steps_arr[ $detected_step ] ) ) {
				$current_step = $detected_step;
				$this->db__save_current_step_name( $current_step );
				return $current_step;
			}
		}

		return $current_step;
	}

	/**
	 * Save the current setup step into the per-user wizard request state.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return bool
	 */
	public function db__save_current_step_name( $step_name ) {

		$steps_arr = $this->get_steps_arr();
		if ( empty( $step_name ) || ! isset( $steps_arr[ $step_name ] ) || ! function_exists( 'wpbc_setup_wizard_page__request_rules_structure' ) ) {
			return false;
		}

		$request_params_to_save = function_exists( 'wpbc_setup_wizard_page__get_cleaned_params__saved_request_default' )
			? wpbc_setup_wizard_page__get_cleaned_params__saved_request_default()
			: array();

		if ( ! is_array( $request_params_to_save ) || empty( $request_params_to_save ) ) {
			$request_params_to_save = function_exists( 'wpbc_setup_wizard_page__get__request_values__default' )
				? wpbc_setup_wizard_page__get__request_values__default()
				: array();
		}

		$request_params_to_save['current_step'] = $step_name;

		$user_request = new WPBC_AJX__REQUEST( array(
											   'db_option_name'          => 'booking_setup_wizard_page_request_params',
											   'user_id'                 => wpbc_get_current_user_id(),
											   'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure()
											)
					);

		return (bool) $user_request->user_request_params__db_save( $request_params_to_save );
	}

	/**
	 * Get target URL for prior setup step.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_prior_url( $step_name ) {

		$steps_arr = $this->get_steps_arr();
		$prior     = isset( $steps_arr[ $step_name ]['prior'] ) ? $steps_arr[ $step_name ]['prior'] : '';

		return ( empty( $prior ) ) ? '' : $this->get_step_target_url( $prior );
	}

	/**
	 * Get step title for setup bar.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_title( $step_name ) {

		$steps_arr = $this->get_steps_arr();

		if ( isset( $steps_arr[ $step_name ]['title'] ) ) {
			return $steps_arr[ $step_name ]['title'];
		}

		return function_exists( 'wpbc_setup_wizard__get_step_title' )
			? wpbc_setup_wizard__get_step_title( $step_name )
			: $step_name;
	}

	/**
	 * Get action-oriented setup step heading.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_heading( $step_name ) {

		$steps_arr = $this->get_steps_arr();

		if ( isset( $steps_arr[ $step_name ]['heading'] ) ) {
			return $steps_arr[ $step_name ]['heading'];
		}

		return function_exists( 'wpbc_setup_wizard__get_step_heading' )
			? wpbc_setup_wizard__get_step_heading( $step_name )
			: $this->get_step_title( $step_name );
	}

	/**
	 * Get setup step description.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_description( $step_name ) {

		$steps_arr = $this->get_steps_arr();

		if ( isset( $steps_arr[ $step_name ]['description'] ) ) {
			return $steps_arr[ $step_name ]['description'];
		}

		return function_exists( 'wpbc_setup_wizard__get_step_description' )
			? wpbc_setup_wizard__get_step_description( $step_name )
			: '';
	}

	/**
	 * Get setup step save behavior.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return string
	 */
	public function get_step_save_behavior( $step_name ) {

		$steps_arr = $this->get_steps_arr();

		if ( isset( $steps_arr[ $step_name ]['save_behavior'] ) ) {
			return $steps_arr[ $step_name ]['save_behavior'];
		}

		return function_exists( 'wpbc_setup_wizard__get_step_save_behavior' )
			? wpbc_setup_wizard__get_step_save_behavior( $step_name )
			: 'link_only';
	}

	/**
	 * Get route metadata value.
	 *
	 * @param string $step_name Step name.
	 * @param string $key       Metadata key.
	 *
	 * @return string
	 */
	public function get_step_meta_value( $step_name, $key ) {

		$steps_arr = $this->get_steps_arr();

		return ( isset( $steps_arr[ $step_name ][ $key ] ) ) ? (string) $steps_arr[ $step_name ][ $key ] : '';
	}


	/**
	 * Get Steps Count  -> 9
	 *
	 * @return int
	 */
	public function get_total_steps_count(){

		$steps_arr = $this->db__get_steps_is_done();

		return count($steps_arr);
	}


	/**
	 * Get % Progress for Setup Steps   -> 30
	 * @return int
	 */
	public function get_progess_value( $current_step = '' ) {

		$total_steps = $this->get_total_steps_count();
		if ( $total_steps <= 0 ) {
			return 0;
		}

		$progess_value = ( $this->get_active_step_num( $current_step ) * 100 ) / $total_steps;
		$progess_value = intval( $progess_value );

		return $progess_value;
	}


	// =================================================================================================================
	// ==  DB :: "Set Wizard Steps as Done"  ==
	// =================================================================================================================

	/**
	 * Get  all Steps from DB and from  Structure,
	 *
	 *    If not saved yet to DB,  then  get  default structure
	 *
	 *  And if later Wizard structure    ->init_steps_data()        was extended,  then  system  get  such  steps as uncompleted.
	 *
	 * @return array|mixed
	 */
	public function db__get_steps_is_done() {

		$steps_is_done = get_bk_option( 'booking_setup_wizard_page_steps_is_done' );
		$is_completed  = ( 'On' === get_bk_option( 'booking_setup_wizard_page_is_completed' ) );

		$active_steps_names = array_keys( $this->get_steps_arr() );
		$normalized_steps   = array();

		if ( empty( $active_steps_names ) ) {
			return is_array( $steps_is_done ) ? $steps_is_done : array();
		}

		foreach ( $active_steps_names as $step_name ) {
			$normalized_steps[ $step_name ] = $is_completed ? true : ( ( is_array( $steps_is_done ) && isset( $steps_is_done[ $step_name ] ) ) ? (bool) $steps_is_done[ $step_name ] : false );
		}

		if ( $steps_is_done !== $normalized_steps ) {
			$this->db__save_steps_is_done( $normalized_steps );
		}

		return $normalized_steps;
	}


	/**
	 * Save statuses to  all steps
	 *
	 * @param $steps_arr
	 *
	 * @return void
	 */
	public function db__save_steps_is_done( $steps_arr ) {
		update_bk_option( 'booking_setup_wizard_page_steps_is_done', $steps_arr );
	}

	/**
	 * Set specific step  as Completed
	 *
	 * @param $step_name
	 *
	 * @return void
	 */
	public function db__set_step_as_completed( $step_name ) {

		$steps_arr = $this->db__get_steps_is_done();

		$steps_arr[ $step_name ] = true;

		$this->db__save_steps_is_done( $steps_arr );
		$this->db__set_step_as_saved( $step_name, true );

		if ( ! in_array( false, $steps_arr, true ) ) {
			update_bk_option( 'booking_setup_wizard_page_is_completed', 'On' );
		}
	}

	/**
	 * Set specific step  as Uncompleted
	 *
	 * @param $step_name
	 *
	 * @return void
	 */
	public function db__set_step_as_uncompleted( $step_name ) {

		$steps_arr = $this->db__get_steps_is_done();

		$steps_arr[ $step_name ] = false;

		delete_bk_option( 'booking_setup_wizard_page_is_completed' );

		$this->db__save_steps_is_done( $steps_arr );
	}

	/**
	 * Reset a step and all following steps in the active route.
	 *
	 * Older wizard versions could leave later steps marked as completed, which made the continue handler think setup
	 * was finished too early after Step 5.
	 *
	 * @param string $first_step_name First step to reset.
	 *
	 * @return bool
	 */
	public function db__reset_steps_from( $first_step_name ) {

		$steps_is_done  = $this->db__get_steps_is_done();
		$steps_is_saved = $this->db__get_steps_is_saved();
		$should_reset   = false;

		if ( ! array_key_exists( $first_step_name, $steps_is_done ) ) {
			return false;
		}

		foreach ( array_keys( $steps_is_done ) as $step_name ) {
			if ( $first_step_name === $step_name ) {
				$should_reset = true;
			}

			if ( $should_reset ) {
				$steps_is_done[ $step_name ] = false;
				if ( array_key_exists( $step_name, $steps_is_saved ) ) {
					$steps_is_saved[ $step_name ] = false;
				}
			}
		}

		delete_bk_option( 'booking_setup_wizard_page_is_completed' );
		$this->db__save_steps_is_done( $steps_is_done );
		$this->db__save_steps_is_saved( $steps_is_saved );

		return true;
	}

	/**
	 * Check if specific step 'Is completed' ?
	 *
	 * @param string $step_name
	 *
	 * @return bool
	 */
	public function db__is_step_completed( $step_name ) {

		$steps_arr = $this->db__get_steps_is_done();

		if ( empty( $steps_arr[ $step_name ] ) ) {
			return false;
		} else {
			return true;
		}
	}


	/**
	 * Mark All Steps as Completed or Uncompleted
	 *
	 * @param $is_completed  bool  (default true)
	 *
	 * @return void
	 */
	public function db__set_all_steps_as( $is_completed = true ) {

		if ( false === $is_completed ) {
			delete_bk_option( 'booking_setup_wizard_page_steps_is_done' );
			delete_bk_option( 'booking_setup_wizard_page_is_completed' );
		} else {
			update_bk_option( 'booking_setup_wizard_page_is_completed', 'On' );
		}

		$steps_names = $this->db__get_steps_is_done();

		$steps_names   = array_keys( $steps_names );
		$steps_values  = array_fill( 0, count( $steps_names ), $is_completed );
		$steps_is_done = array_combine( $steps_names, $steps_values );

		// Set  all  steps as not completed
		$this->db__save_steps_is_done( $steps_is_done );
		$this->db__save_steps_is_saved( $steps_is_done );
	}

	/**
	 * Get saved state for setup steps.
	 *
	 * @return array
	 */
	public function db__get_steps_is_saved() {

		$steps_is_saved = get_bk_option( 'booking_setup_wizard_page_steps_is_saved' );
		$is_completed   = ( 'On' === get_bk_option( 'booking_setup_wizard_page_is_completed' ) );
		$normalized     = array();

		foreach ( array_keys( $this->get_steps_arr() ) as $step_name ) {
			$normalized[ $step_name ] = $is_completed ? true : ( ( is_array( $steps_is_saved ) && isset( $steps_is_saved[ $step_name ] ) ) ? (bool) $steps_is_saved[ $step_name ] : false );
		}

		if ( $steps_is_saved !== $normalized ) {
			$this->db__save_steps_is_saved( $normalized );
		}

		return $normalized;
	}

	/**
	 * Save setup step saved states.
	 *
	 * @param array $steps_arr Saved states.
	 *
	 * @return void
	 */
	public function db__save_steps_is_saved( $steps_arr ) {
		update_bk_option( 'booking_setup_wizard_page_steps_is_saved', $steps_arr );
	}

	/**
	 * Mark a setup step as saved or unsaved.
	 *
	 * @param string $step_name Step name.
	 * @param bool   $is_saved  Saved flag.
	 *
	 * @return bool
	 */
	public function db__set_step_as_saved( $step_name, $is_saved = true ) {

		$steps_arr = $this->db__get_steps_is_saved();
		if ( ! array_key_exists( $step_name, $steps_arr ) ) {
			return false;
		}

		$steps_arr[ $step_name ] = (bool) $is_saved;
		$this->db__save_steps_is_saved( $steps_arr );

		return true;
	}

	/**
	 * Check whether a setup step has been saved.
	 *
	 * @param string $step_name Step name.
	 *
	 * @return bool
	 */
	public function db__is_step_saved( $step_name ) {

		if ( 'manual_save_required' !== $this->get_step_save_behavior( $step_name ) ) {
			return true;
		}

		$steps_arr = $this->db__get_steps_is_saved();

		return ! empty( $steps_arr[ $step_name ] );
	}

	/**
	 * Check  Is  all steps Completed
	 * @return bool
	 */
	public function db__is_all_steps_completed() {

		if ( 'On' === get_bk_option( 'booking_setup_wizard_page_is_completed' ) ) {
			return true;
		}

		$steps_arr = $this->db__get_steps_is_done();

		if ( empty( $steps_arr ) ) {
			return false;
		}

		foreach ( $steps_arr as $step_name => $steps_val ) {
			if ( empty( $steps_val ) ) {
				return false;
			}
		}

		return true;
	}



	// =================================================================================================================
	// ==  C O N T E N T  ==
	// =================================================================================================================

	// ----------------------------------------------------------
	// ==  Left Plugin Menu  -->  "Setup" with Progress Bar  ==
	// ----------------------------------------------------------

	/**
	 * Main Left Menu Title - "Setup" with Progress Bar
	 *
	 * @return false|string
	 */
	public function get_plugin_menu_title__setup_progress( $current_step = '' ){


		$current_step_for_progress = ( ! empty( $current_step ) ) ? $current_step : $this->get_context_step_name();

		ob_start();

		?><div class="setup_wizard_page_container" style="display: flex;flex-flow: row wrap;justify-content: flex-start;align-items: center;color: #fff;margin: 0 -5px 0 0;overflow: visible;">
			<div class="name_item" style="margin-top: 0;white-space: nowrap;padding: 0 0 0 0;"><?php esc_html_e( 'Setup', 'booking' ); ?></div>
			<div style="margin:3px 0px 0 0;margin-left: auto;font-size: 9px;background: var(--wpbc_admin-theme-color, #2271b1);height: 15px;" class="wpbc_badge_count name_item update-plugins">
				<span class="update-count" style="white-space: nowrap;word-wrap: normal;"><?php
					echo esc_html( $this->get_active_step_num( $current_step_for_progress ) . ' / ' . $this->get_total_steps_count() );
				?></span>
			</div>
			<div class="progress_line_container" style="width: 100%;border: 0px solid #757575;height: 3px;border-radius: 6px;margin: 7px 0 -3px -3px;overflow: hidden;background: #555;">
				<div class="progress_line" style="font-size: 6px;font-weight: 600;word-wrap: normal;border-radius: 6px;white-space: nowrap;background: #8ECE01;width: <?php
					echo esc_html( $this->get_progess_value( $current_step_for_progress ) ); ?>%;height: 3px;"></div>
			</div>
		</div><?php

		return ob_get_clean();
	}

	// ----------------------------------------------------------
	// ==  Content Top Wizard Button  ==
	// ----------------------------------------------------------

	/**
	 * Black Button at  Top Right Side in WPBC plugin menu  ( except Wizard page )
	 *
	 * Show Continue Setup Wizard Button
	 * @return void
	 */
	public function show_top_right_wizard_button() {

		if ( ! self::is_floating_setup_bar_enabled() ) {
			return false;
		}

		if ( ! wpbc_is_setup_wizard_page() ) {
			$explicit_step_context = false;

			// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only Setup Wizard routing context.
			if ( isset( $_GET['wpbc_setup_step'] ) && is_scalar( $_GET['wpbc_setup_step'] ) ) {
				// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only Setup Wizard routing context.
				$request_step = sanitize_key( wp_unslash( $_GET['wpbc_setup_step'] ) );
				$explicit_step_context = isset( $this->steps_arr[ $request_step ] )
					&& function_exists( 'wpbc_setup_wizard_page__has_explicit_step_context' )
					&& wpbc_setup_wizard_page__has_explicit_step_context( $request_step );
			}

			if (
				( ! wpbc_is_user_can_access_wizard_page() ) ||
				( $this->db__is_all_steps_completed() && ! $explicit_step_context )
			) {
				return false;
			}

			if ( self::$is_top_bar_rendered ) {
				return false;
			}
			self::$is_top_bar_rendered = true;

			$current_step                   = $this->get_context_step_name();
			$is_external_setup_flow_started = $this->db__is_step_completed( 'bookings_types' );
			$detected_page_step             = ( $is_external_setup_flow_started && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_request' ) )
				? wpbc_setup_wizard__detect_step_from_admin_request()
				: '';
			$continue_url       = $this->get_step_continue_url( $current_step );
			if ( ! empty( $detected_page_step ) && isset( $this->steps_arr[ $detected_page_step ] ) ) {
				$continue_url = add_query_arg( 'wpbc_setup_from_page_step', $detected_page_step, $continue_url );
			}
			$prior_url    = $this->get_step_prior_url( $current_step );
			$step_title   = $this->get_step_title( $current_step );
			$step_heading = $this->get_step_heading( $current_step );
			$step_save_page_title = ( 'form_structure' === $current_step ) ? __( 'Form Builder', 'booking' ) : $step_title;
			$description  = $this->get_step_description( $current_step );
			$save_behavior = $this->get_step_save_behavior( $current_step );
			$target_selector = $this->get_step_meta_value( $current_step, 'target_selector' );
			$scroll_selector = $this->get_step_meta_value( $current_step, 'scroll_selector' );
			$highlight_selector = $this->get_step_meta_value( $current_step, 'highlight_selector' );
			$highlight_disabled = $this->get_step_meta_value( $current_step, 'highlight_disabled' );
			$highlight_all      = $this->get_step_meta_value( $current_step, 'highlight_all' );
			$form_selector   = $this->get_step_meta_value( $current_step, 'form_selector' );
			$save_selector   = $this->get_step_meta_value( $current_step, 'save_selector' );
			$save_ajax_action = $this->get_step_meta_value( $current_step, 'save_ajax_action' );
			$save_events     = $this->get_step_meta_value( $current_step, 'save_events' );
			$open_action     = $this->get_step_meta_value( $current_step, 'open_action' );
			$secondary_action_url   = $this->get_step_meta_value( $current_step, 'secondary_action_url' );
			$secondary_action_label = $this->get_step_meta_value( $current_step, 'secondary_action_label' );
			$can_save_from_bar  = ( 'manual_save_required' === $save_behavior && ! empty( $save_selector ) );
			$continue_title     = ( 'complete' === $save_behavior ) ? __( 'Finish Setup', 'booking' ) : __( 'Continue', 'booking' );
			if ( $can_save_from_bar ) {
				$continue_title = __( 'Save and Continue', 'booking' );
			}
			$is_step_saved        = $this->db__is_step_saved( $current_step );
			$is_step_unsaved      = ( 'manual_save_required' === $save_behavior && ! $is_step_saved );
			$is_continue_disabled = ( $is_step_unsaved && ! $can_save_from_bar );
			$continue_href        = $is_step_unsaved ? '#wpbc_setup_save_required' : $continue_url;
			$mark_saved_nonce    = wp_create_nonce( 'wpbc_setup_wizard_mark_step_saved' );
			$step_target_url     = $this->get_step_target_url( $current_step );
			$skip_wizard_url     = add_query_arg( 'wpbc_setup_wizard', 'completed', wpbc_get_bookings_url() );
			$reset_wizard_url    = add_query_arg( 'wpbc_setup_wizard', 'reset', wpbc_get_setup_wizard_page_url() );
			$save_required_note  = sprintf(
				/* translators: %s: setup target page title. */
				__( 'Save changes on the %s page before continuing.', 'booking' ),
				'<a href="' . esc_url( $step_target_url ) . '">' . esc_html( $step_save_page_title ) . '</a>'
			);
			$test_page_links = (
				'wizard_publish' === $current_step
				&& function_exists( 'wpbc_booking_modes_get_setup_test_page_links' )
			) ? wpbc_booking_modes_get_setup_test_page_links() : array();

			// FixIn: 10.12.1.1.
			?><style type="text/css">
				@media screen and (max-width: 782px) {
					.ui_element.wpbc_page_top__wizard_button {
						/*top: 49px !important;*/
					}
				}
				.wp-admin.wpbc_admin_full_screen .wpbc_header_news {
					display: none !important;
				}
				.wpbc_page_top__wizard_button {
					width: auto;
					min-width: 330px;
					max-width: min(420px, calc(100vw - 30px));
					position: fixed;
					z-index: 150000;
					box-shadow: 0 0 10px #c1c1c1;
					border-radius: 9px;
					background: transparent;
					right: 15px;
					top: auto !important;
					bottom: 15px !important;
				}
				.wpbc_page_top__wizard_button.wpbc_setup_wizard_bar_is_moved {
					left: var(--wpbc-setup-bar-left, auto) !important;
					top: auto !important;
					right: auto !important;
					bottom: var(--wpbc-setup-bar-bottom, auto) !important;
				}
				.wpbc_page_top__wizard_button.wpbc_setup_wizard_bar_auto_shifted {
					left: auto !important;
					top: auto !important;
					right: var(--wpbc-setup-bar-auto-right, 15px) !important;
					bottom: 15px !important;
				}
				.wpbc_page_top__wizard_button.wpbc_setup_wizard_bar_auto_top {
					left: auto !important;
					top: var(--wpbc-setup-bar-auto-top, 15px) !important;
					right: var(--wpbc-setup-bar-auto-right, 15px) !important;
					bottom: auto !important;
				}
				.wpbc_page_top__wizard_button.wpbc_setup_wizard_bar_is_dragging {
					user-select: none;
				}
				.wpbc_page_top__wizard_button.wpbc_setup_wizard_bar_collapsed {
					min-width: 260px;
				}
				.wpbc_page_top__wizard_button.wpbc_setup_wizard_bar_collapsed .wpbc_setup_wizard_bar_expandable {
					display: none !important;
				}
				div .wpbc_admin_page__tab__builder_booking_form .wpbc_page_top__wizard_button {
					top: calc(var(--wpbc_ui_top_nav__wp_top_menu_height) + var(--wpbc_ui_top_nav__height) + 10px) !important;
					top: auto !important;
				}
				.ui_element.wpbc_page_top__wizard_button .wpbc_page_top__wizard_button_content,
				.ui_element.wpbc_page_top__wizard_button .wpbc_page_top__wizard_button_content:hover {
					border-radius: 5px;
					border: none;
					background: #535353; /* #6c9e00 #0b9300;*/
					box-shadow: 0 0 10px #dbdbdb;
					text-shadow: none;
					color: #fff;
					font-weight: 600;
					padding: 8px 10px 8px 15px;
					display: flex;
					flex-flow: column nowrap;
					justify-content: flex-start;
					align-items: stretch;
					gap: 8px;
				}
				.wpbc_setup_wizard_bar_title_row {
					display: flex;
					flex-flow: row nowrap;
					justify-content: flex-start;
					align-items: center;
					gap: 8px;
					width: 100%;
					border-bottom: 2px solid #686868;
					padding-bottom: 8px;
					margin-bottom: 10px;
				}
				.wpbc_setup_wizard_bar_title {
					flex: 1 1 auto;
					min-width: 0;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					margin-top: 0;
					padding: 0;
				}
				.wpbc_setup_wizard_bar_header_actions {
					display: flex;
					flex: 0 0 auto;
					flex-flow: row nowrap;
					align-items: center;
					gap: 2px;
					margin-left: auto;
				}
				.wpbc_setup_wizard_bar_icon_button {
					display: inline-flex;
					align-items: center;
					justify-content: center;
					width: 24px;
					height: 24px;
					min-width: 24px;
					min-height: 24px;
					border: 0;
					border-radius: 4px;
					background: transparent;
					color: #fff;
					cursor: pointer;
					padding: 0;
					margin: 0;
				}
				.wpbc_setup_wizard_bar_icon_button:hover,
				.wpbc_setup_wizard_bar_icon_button:focus {
					background: rgba(255,255,255,0.16);
					color: #fff;
					outline: none;
					box-shadow: none;
				}
				.wpbc_setup_wizard_bar_drag_handle {
					cursor: move;
				}
				.wpbc_page_top__wizard_button_actions {
					display: flex;
					flex-flow: row nowrap;
					justify-content: flex-end;
					align-items: center;
					gap: 8px;
				}
				.wpbc_page_top__wizard_button_actions .button {
					font-size: 11px;
					min-height: 10px;
					line-height: 1.8;
					margin: 0;
				}
				.wpbc_page_top__wizard_button_actions .button.button-secondary {
					background-color: #e4e4e4;
				}
				.wpbc_setup_wizard_test_page_actions {
					display: flex;
					flex-flow: row wrap;
					align-items: center;
					gap: 8px;
					font-size: 11px;
					font-weight: 400;
					line-height: 1.35;
				}
				.wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions {
					flex-flow: row wrap;
				}
				.wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button,
				.wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:hover,
				.wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:focus {
					margin: 20px 0;
					background: #71a501;
					border-color: #71a501;
					color: #f0ffce;
				}
				.wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:first-child {
					margin-right: auto;
					margin-left: 0;
				}
				.wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links {
					margin: 0;
					gap: 10px 15px;
					justify-content: flex-start;
				}
				.wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links .button.wpbc_setup_wizard_test_page_button:first-child,
				.wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links a {
					margin: 0;
					flex: 0 1 auto;
				}
				.wpbc_page_top__wizard_button_actions .button.disabled,
				.wpbc_page_top__wizard_button_actions .button[aria-disabled="true"] {
					cursor: not-allowed;
					opacity: 0.55;
					pointer-events: auto;
				}
				.wpbc_page_top__wizard_button_links {
					display: flex;
					flex-flow: row wrap;
					justify-content: flex-start;
					align-items: center;
					gap: 1.5em;
					font-size: 10px;
					font-weight: 400;
					line-height: 1.4;
					margin-top: -2px;
				}
				.wpbc_page_top__wizard_button_links a {
					color: #e6e6e6;
					text-decoration: underline;
					text-underline-offset: 2px;
				}
				.wpbc_page_top__wizard_button_links a:hover,
				.wpbc_page_top__wizard_button_links a:focus {
					color: #fff;
				}
				.wpbc_page_top__wizard_button_links a.wpbc_setup_wizard_bar_danger_link {
					/*color: #ff9b00;*/
				}
				.wpbc_page_top__wizard_button_links a.wpbc_setup_wizard_bar_danger_link:hover,
				.wpbc_page_top__wizard_button_links a.wpbc_setup_wizard_bar_danger_link:focus {
					color: #fff;
				}
				.wpbc_page_top__wizard_button_note {
					font-size: 12px;
					font-weight: 400;
					line-height: 1.35;
					color: #fff;
					background: rgb(160, 160, 95);
					background: rgb(160, 132, 95);
					background: rgb(160, 116, 95);
					border-radius: 4px;
					padding: 10px 14px;
					margin: 8px 0 5px;
				}
				.wpbc_page_top__wizard_button_note a {
					color: #fff;
					text-decoration: underline;
					text-underline-offset: 2px;
				}
				.wpbc_page_top__wizard_button_note.wpbc_setup_wizard_bar_note_saved {
					background: #4f8f16;
				}
				.wpbc_setup_wizard_attention_pulse {
					animation: wpbc_setup_wizard_attention_pulse 0.62s ease-in-out 3;
				}
				@keyframes wpbc_setup_wizard_attention_pulse {
					0% {
						box-shadow: 0 0 0 0 rgba(255, 196, 0, 0.82);
						transform: scale(1);
					}
					50% {
						box-shadow: 0 0 0 7px rgba(255, 196, 0, 0.2);
						transform: scale(1.025);
					}
					100% {
						box-shadow: 0 0 0 0 rgba(255, 196, 0, 0);
						transform: scale(1);
					}
				}
				.wpbc_setup_wizard__target_highlight {
					outline: 2px solid #8ECE01 !important;
					outline-offset: 3px !important;
					box-shadow: 0 0 0 5px rgba(142, 206, 1, 0.16) !important;
					transition: outline-color 0.2s ease, box-shadow 0.2s ease;
				}
				@media screen and (max-width: 782px) {
					.wpbc_page_top__wizard_button {
						left: 10px !important;
						right: 10px !important;
						bottom: 10px !important;
						top: auto !important;
						min-width: 0;
						max-width: none;
					}
					.wpbc_setup_wizard_bar_drag_handle,
					.wpbc_setup_wizard_bar_reset_button {
						display: none;
					}
				}
			</style>
			<div style="top: 35px;font-size: 15px;"
				 class="ui_element wpbc_page_top__wizard_button"
				 data-wpbc-setup-step="<?php echo esc_attr( $current_step ); ?>"
				 data-wpbc-setup-save-behavior="<?php echo esc_attr( $save_behavior ); ?>"
				 data-wpbc-setup-is-saved="<?php echo esc_attr( $is_step_saved ? '1' : '0' ); ?>"
				 data-wpbc-setup-ajax-url="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>"
				 data-wpbc-setup-mark-saved-nonce="<?php echo esc_attr( $mark_saved_nonce ); ?>"
				 data-wpbc-setup-target-selector="<?php echo esc_attr( $target_selector ); ?>"
				 data-wpbc-setup-scroll-selector="<?php echo esc_attr( $scroll_selector ); ?>"
				 data-wpbc-setup-highlight-selector="<?php echo esc_attr( $highlight_selector ); ?>"
				 data-wpbc-setup-highlight-disabled="<?php echo esc_attr( $highlight_disabled ); ?>"
				 data-wpbc-setup-highlight-all="<?php echo esc_attr( $highlight_all ); ?>"
				 data-wpbc-setup-form-selector="<?php echo esc_attr( $form_selector ); ?>"
				 data-wpbc-setup-save-selector="<?php echo esc_attr( $save_selector ); ?>"
				 data-wpbc-setup-save-ajax-action="<?php echo esc_attr( $save_ajax_action ); ?>"
				 data-wpbc-setup-save-events="<?php echo esc_attr( $save_events ); ?>"
				 data-wpbc-setup-open-action="<?php echo esc_attr( $open_action ); ?>">
				<div class="wpbc_ui_control wpbc_page_top__wizard_button_content">
					<div class="in-button-text"
						 style="width: 100%;margin: 0;display: flex;flex-flow: column nowrap;justify-content: flex-start;align-items: stretch;gap:8px;">
						<div class="setup_wizard_page_container"
							 style="display: flex;flex-flow: row wrap;justify-content: flex-start;align-items: center;color: #fff;overflow: visible;flex: 1 1 auto;">
							<div class="wpbc_setup_wizard_bar_title_row">
								<div class="wpbc_setup_wizard_bar_header_actions">
									<button type="button"
											style="margin: -1px 5px 0 -7px;"
											class="wpbc_setup_wizard_bar_icon_button wpbc_setup_wizard_bar_drag_handle"
											title="<?php esc_attr_e( 'Move setup bar', 'booking' ); ?>"
											aria-label="<?php esc_attr_e( 'Move setup bar', 'booking' ); ?>">
										<i class="menu_icon icon-1x wpbc_icn_drag_indicator"></i>
									</button>
								</div>

								<div class="name_item wpbc_setup_wizard_bar_title">
									<i style="margin-right: 4px;" class="menu_icon icon-1x wpbc_icn_donut_large wpbc_icn_adjust0"></i> <?php echo esc_html( $step_title ); ?>
								</div>
								<div class="wpbc_setup_wizard_bar_header_actions">
									<button type="button"
											class="wpbc_setup_wizard_bar_icon_button wpbc_setup_wizard_bar_reset_button"
											title="<?php esc_attr_e( 'Reset setup bar position', 'booking' ); ?>"
											aria-label="<?php esc_attr_e( 'Reset setup bar position', 'booking' ); ?>">
										<i class="menu_icon icon-1x wpbc_icn_rotate_90 wpbc_icn_pin_invoke"></i>
									</button>
									<button type="button"
											class="wpbc_setup_wizard_bar_icon_button wpbc_setup_wizard_bar_toggle_button"
											title="<?php esc_attr_e( 'Collapse setup bar', 'booking' ); ?>"
											aria-label="<?php esc_attr_e( 'Collapse setup bar', 'booking' ); ?>"
											aria-expanded="true">
										<i class="menu_icon icon-1x wpbc_icn_minimize"></i>
									</button>
								</div>
							</div>
							<div class="name_item wpbc_setup_wizard_bar_expandable" style="flex:1 1 100%;font-size:13px;font-weight:600;line-height:1.35;margin:3px 0 0;color:#f1f1f1;">
								<?php echo esc_html( $step_heading ); ?>
							</div>
							<?php if ( ! empty( $description ) ) { ?>
							<div class="name_item wpbc_setup_wizard_bar_expandable" style="flex:1 1 100%;font-size:11px;font-weight:400;line-height:1.35;margin:2px 0 0;color:#e6e6e6;">
								<?php echo esc_html( $description ); ?>
							</div>
							<?php } ?>
							<div
								style="margin:2px 0px 0 9px;font-size: 9px;background: #3e3e3e;height: auto;border-radius: 5px;padding: 0px 7px 0px;margin-left: auto;"
								class="wpbc_badge_count name_item update-plugins">
								<span class="update-count"
									  style="white-space: nowrap;word-wrap: normal;"><?php echo esc_html( $this->get_active_step_num( $current_step ) . ' / ' . $this->get_total_steps_count() ); ?></span>
							</div>

							<div class="progress_line_container"
								 style="width: 100%;border: 0px solid #757575;height: 3px;border-radius: 6px;margin: 7px 0 0 0;overflow: hidden;background: #202020;">
								<div class="progress_line"
								 style="font-size: 6px;font-weight: 600;border-radius: 6px;word-wrap: normal;white-space: nowrap;background: #8ECE01;width: <?php echo esc_attr( $this->get_progess_value( $current_step ) ); ?>%;height: 3px;"></div>
							</div>
						</div>
						<?php if ( 'manual_save_required' === $save_behavior ) { ?>
							<div class="wpbc_page_top__wizard_button_note wpbc_setup_wizard_bar_expandable<?php echo $is_step_saved ? ' wpbc_setup_wizard_bar_note_saved' : ''; ?>">
								<?php
								if ( $is_step_saved ) {
									esc_html_e( 'Changes saved. You can continue.', 'booking' );
								} else {
									echo wp_kses_post( $save_required_note );
								}
								?>
							</div>
						<?php } ?>
						<?php if ( 'wizard_publish' === $current_step && empty( $test_page_links ) ) { ?>
							<div class="wpbc_setup_wizard_test_page_actions wpbc_setup_wizard_bar_expandable">
								<span><?php esc_html_e( 'No published booking page was found yet. Use QuickStart or the page publishing controls, then return to this step.', 'booking' ); ?></span>
							</div>
						<?php } ?>
						<?php if ( 'wizard_publish' === $current_step && ! empty( $test_page_links ) ) { ?>
							<div class="wpbc_page_top__wizard_button_actions wpbc_setup_wizard_bar_expandable wpbc_page_top__wizard_button_links">
								<?php foreach ( $test_page_links as $test_page_link ) {
									if ( empty( $test_page_link['url'] ) || empty( $test_page_link['label'] ) ) {
										continue;
									}
									?>
									<a class="button button-primary secondary wpbc_setup_wizard_test_page_button"
									   href="<?php echo esc_url( $test_page_link['url'] ); ?>"
									   target="_blank"
									   rel="noopener noreferrer"><?php echo esc_html( $test_page_link['label'] ); ?></a>
								<?php } ?>
							</div>
						<?php } ?>
						<div class="wpbc_page_top__wizard_button_actions wpbc_setup_wizard_bar_expandable">
							<?php if ( ! empty( $secondary_action_url ) && ! empty( $secondary_action_label ) ) { ?>
								<a class="button button-secondary wpbc_setup_wizard_secondary_action"
								   href="<?php echo esc_url( $secondary_action_url ); ?>"><?php echo esc_html( $secondary_action_label ); ?></a>
							<?php } ?>
							<?php if ( ! empty( $prior_url ) ) { ?>
								<a href="<?php echo esc_url( $prior_url ); ?>" class="button button-secondary"><?php esc_html_e( 'Back', 'booking' ); ?></a>
							<?php } ?>
							<a href="<?php echo esc_url( $continue_href ); ?>"
							   class="button button-primary wpbc_setup_wizard_continue_button<?php echo $is_continue_disabled ? ' disabled' : ''; ?>"
							   data-wpbc-setup-continue-url="<?php echo esc_url( $continue_url ); ?>"
							   <?php echo $is_continue_disabled ? 'aria-disabled="true"' : ''; ?>><?php echo esc_html( $continue_title ); ?></a>
						</div>
						<div class="wpbc_page_top__wizard_button_links wpbc_setup_wizard_bar_expandable">
							<a href="<?php echo esc_url( $skip_wizard_url ); ?>"
							   title="<?php esc_attr_e( 'Exit and skip the setup wizard', 'booking' ); ?>">
								<?php esc_html_e( 'Exit and skip the setup wizard', 'booking' ); ?>
							</a>
							<a href="<?php echo esc_url( $reset_wizard_url ); ?>"
							   class="wpbc_setup_wizard_bar_danger_link"
							   title="<?php esc_attr_e( 'Start Setup from Beginning', 'booking' ); ?>">
								<?php esc_html_e( 'Reset Wizard', 'booking' ); ?>
							</a>
						</div>
					</div>
				</div>
			</div>
			<script type="text/javascript">
				jQuery( document ).ready( function() {
					var $bar = jQuery( '.wpbc_page_top__wizard_button[data-wpbc-setup-step]' ).first();
					var step = $bar.attr( 'data-wpbc-setup-step' ) || '';
					var saveBehavior = $bar.attr( 'data-wpbc-setup-save-behavior' ) || '';
					var selector = $bar.attr( 'data-wpbc-setup-target-selector' ) || '';
					var scrollSelector = $bar.attr( 'data-wpbc-setup-scroll-selector' ) || selector;
					var highlightSelector = $bar.attr( 'data-wpbc-setup-highlight-selector' ) || selector;
					var highlightDisabled = ( '1' === ( $bar.attr( 'data-wpbc-setup-highlight-disabled' ) || '' ) );
					var highlightAll = ( '1' === ( $bar.attr( 'data-wpbc-setup-highlight-all' ) || '' ) );
					var formSelector = $bar.attr( 'data-wpbc-setup-form-selector' ) || '';
					var saveSelector = $bar.attr( 'data-wpbc-setup-save-selector' ) || '';
					var saveAjaxAction = $bar.attr( 'data-wpbc-setup-save-ajax-action' ) || '';
					var saveEvents = ( $bar.attr( 'data-wpbc-setup-save-events' ) || '' ).split( ',' );
					var openAction = $bar.attr( 'data-wpbc-setup-open-action' ) || '';
					var ajaxUrl = $bar.attr( 'data-wpbc-setup-ajax-url' ) || '';
					var nonce = $bar.attr( 'data-wpbc-setup-mark-saved-nonce' ) || '';
					var $continueButton = $bar.find( '.wpbc_setup_wizard_continue_button' ).first();
					var $note = $bar.find( '.wpbc_page_top__wizard_button_note' ).first();
					var savedNote = '<?php echo esc_js( __( 'Changes saved. You can continue.', 'booking' ) ); ?>';
					var saveRequiredNote = <?php echo wp_json_encode( wp_kses_post( $save_required_note ) ); ?>;
					var continueTitle = <?php echo wp_json_encode( ( 'complete' === $save_behavior ) ? __( 'Finish Setup', 'booking' ) : __( 'Continue', 'booking' ) ); ?>;
					var saveAndContinueTitle = <?php echo wp_json_encode( __( 'Save and Continue', 'booking' ) ); ?>;
					var savingTitle = <?php echo wp_json_encode( __( 'Saving', 'booking' ) . '...' ); ?>;
					var $toggleButton = $bar.find( '.wpbc_setup_wizard_bar_toggle_button' ).first();
					var $toggleIcon = $toggleButton.find( 'i' ).first();
					var $resetButton = $bar.find( '.wpbc_setup_wizard_bar_reset_button' ).first();
					var $dragHandle = $bar.find( '.wpbc_setup_wizard_bar_drag_handle' ).first();
					var positionStorageKey = 'wpbc_setup_wizard_bar_position';
					var collapsedStorageKey = 'wpbc_setup_wizard_bar_collapsed';
					var collapseLabel = <?php echo wp_json_encode( __( 'Collapse setup bar', 'booking' ) ); ?>;
					var expandLabel = <?php echo wp_json_encode( __( 'Expand setup bar', 'booking' ) ); ?>;
					var $target;
					var $highlightTargets = jQuery();
					var saveClicked = false;
					var saveAndContinueRequested = false;
					var saveAndContinueRedirecting = false;

					function wpbcSetupWizardStorageGet( key ) {
						try {
							return window.localStorage.getItem( key );
						} catch ( _e ) {
							return null;
						}
					}

					function wpbcSetupWizardStorageSet( key, value ) {
						try {
							window.localStorage.setItem( key, value );
						} catch ( _e ) {}
					}

					function wpbcSetupWizardStorageRemove( key ) {
						try {
							window.localStorage.removeItem( key );
						} catch ( _e ) {}
					}

					function wpbcSetupWizardIsSmallViewport() {
						return window.matchMedia && window.matchMedia( '(max-width: 782px)' ).matches;
					}

					function wpbcSetupWizardClampPosition( left, bottom ) {
						var margin = 10;
						var barWidth = $bar.outerWidth() || 330;
						var barHeight = $bar.outerHeight() || 120;
						var maxLeft = Math.max( margin, jQuery( window ).width() - barWidth - margin );
						var maxBottom = Math.max( margin, jQuery( window ).height() - barHeight - margin );

						return {
							left: Math.min( Math.max( margin, left ), maxLeft ),
							bottom: Math.min( Math.max( margin, bottom ), maxBottom )
						};
					}

					function wpbcSetupWizardApplyPosition( position ) {
						var clampedPosition;
						var positionBottom;

						if ( wpbcSetupWizardIsSmallViewport() || ! position ) {
						$bar
							.removeClass( 'wpbc_setup_wizard_bar_is_moved' )
							.removeClass( 'wpbc_setup_wizard_bar_auto_shifted' )
							.removeClass( 'wpbc_setup_wizard_bar_auto_top' )
							.css( {
								'--wpbc-setup-bar-left': '',
								'--wpbc-setup-bar-bottom': '',
								'--wpbc-setup-bar-auto-right': '',
								'--wpbc-setup-bar-auto-top': ''
							} );
						return;
					}

						positionBottom = parseFloat( position.bottom );
						if ( isNaN( positionBottom ) && ! isNaN( parseFloat( position.top ) ) ) {
							positionBottom = jQuery( window ).height() - parseFloat( position.top ) - ( $bar.outerHeight() || 120 );
						}

						clampedPosition = wpbcSetupWizardClampPosition( parseFloat( position.left ) || 15, isNaN( positionBottom ) ? 15 : positionBottom );
						$bar
							.addClass( 'wpbc_setup_wizard_bar_is_moved' )
							.removeClass( 'wpbc_setup_wizard_bar_auto_shifted' )
							.removeClass( 'wpbc_setup_wizard_bar_auto_top' )
							.css( {
								'--wpbc-setup-bar-left': clampedPosition.left + 'px',
								'--wpbc-setup-bar-bottom': clampedPosition.bottom + 'px',
								'--wpbc-setup-bar-auto-right': '',
								'--wpbc-setup-bar-auto-top': ''
							} );
					}

					function wpbcSetupWizardShouldUseTopDefault() {
						return -1 !== jQuery.inArray( step, [
							'date_selection',
							'changeover_days',
							'working_time',
							'time_slots_availability',
							'date_availability'
						] );
					}

					function wpbcSetupWizardGetRightSidebarOffset() {
						var viewportWidth = jQuery( window ).width();
						var viewportHeight = jQuery( window ).height();
						var $sidebar = jQuery();
						var sidebarSelectors = [
							'.wpbc_ui_el__vert_right_bar__wrapper',
							'.wpbc_ui_el__vert_right_bar',
							'.wpbc_ui_el__vert_right_bar__content',
							'.wpbc_ui_el__vert_right_bar__content .simplebar-content-wrapper'
						].join( ',' );

						jQuery( sidebarSelectors ).filter( ':visible' ).each( function() {
							var rect = this.getBoundingClientRect();

							if (
								rect.width >= 140
								&& rect.left > ( viewportWidth * 0.45 )
								&& rect.right > ( viewportWidth - 80 )
								&& rect.top < ( viewportHeight - 90 )
								&& rect.bottom > ( viewportHeight * 0.35 )
							) {
								$sidebar = jQuery( this );
								return false;
							}
						} );

						if ( ! $sidebar.length ) {
							return 0;
						}

						return Math.max( 0, viewportWidth - $sidebar[0].getBoundingClientRect().left + 15 );
					}

					function wpbcSetupWizardApplyDefaultPosition() {
						var rightOffset;
						var maxRight;
						var barWidth = $bar.outerWidth() || 330;

						if ( wpbcSetupWizardIsSmallViewport() ) {
							wpbcSetupWizardApplyPosition( null );
							return;
						}

						// Clear any visible inspector while retaining the minimum offset used by the Days Availability page.
						rightOffset = wpbcSetupWizardGetRightSidebarOffset();
						if ( 'date_availability' === step ) {
							rightOffset = Math.max( rightOffset, 60 );
						}
						maxRight = Math.max( 15, jQuery( window ).width() - barWidth - 10 );

						if ( wpbcSetupWizardShouldUseTopDefault() ) {
							$bar
								.removeClass( 'wpbc_setup_wizard_bar_is_moved' )
								.addClass( 'wpbc_setup_wizard_bar_auto_shifted' )
								.addClass( 'wpbc_setup_wizard_bar_auto_top' )
								.css( {
									'--wpbc-setup-bar-left': '',
									'--wpbc-setup-bar-bottom': '',
									'--wpbc-setup-bar-auto-right': Math.min( Math.max( rightOffset, 15 ), maxRight ) + 'px',
									'--wpbc-setup-bar-auto-top': '15px'
								} );
							return;
						}

						if ( rightOffset > 15 ) {
							$bar
								.removeClass( 'wpbc_setup_wizard_bar_is_moved' )
								.removeClass( 'wpbc_setup_wizard_bar_auto_top' )
								.addClass( 'wpbc_setup_wizard_bar_auto_shifted' )
								.css( {
									'--wpbc-setup-bar-left': '',
									'--wpbc-setup-bar-bottom': '',
									'--wpbc-setup-bar-auto-right': Math.min( rightOffset, maxRight ) + 'px',
									'--wpbc-setup-bar-auto-top': ''
								} );
							return;
						}

						wpbcSetupWizardApplyPosition( null );
					}

					function wpbcSetupWizardSavePosition( left, bottom ) {
						var clampedPosition = wpbcSetupWizardClampPosition( left, bottom );

						wpbcSetupWizardStorageSet( positionStorageKey, JSON.stringify( clampedPosition ) );
						wpbcSetupWizardApplyPosition( clampedPosition );
					}

					function wpbcSetupWizardApplySavedPosition() {
						var savedPosition = wpbcSetupWizardStorageGet( positionStorageKey );
						var rightSidebarOffset;
						var barRect;
						var sidebarLeft;

						if ( ! savedPosition ) {
							wpbcSetupWizardApplyDefaultPosition();
							return;
						}

						try {
							wpbcSetupWizardApplyPosition( JSON.parse( savedPosition ) );
						} catch ( _e ) {
							wpbcSetupWizardStorageRemove( positionStorageKey );
							wpbcSetupWizardApplyDefaultPosition();
							return;
						}

						rightSidebarOffset = wpbcSetupWizardGetRightSidebarOffset();
						if ( 'service_provider' === step && rightSidebarOffset > 15 ) {
							barRect = $bar[0].getBoundingClientRect();
							sidebarLeft = jQuery( window ).width() - rightSidebarOffset + 15;

							if ( barRect.right > ( sidebarLeft - 10 ) ) {
								wpbcSetupWizardApplyDefaultPosition();
							}
						}
					}

					function wpbcSetupWizardResetPosition() {
						wpbcSetupWizardStorageRemove( positionStorageKey );
						wpbcSetupWizardApplyDefaultPosition();
					}

					function wpbcSetupWizardSetCollapsed( isCollapsed ) {
						$bar.toggleClass( 'wpbc_setup_wizard_bar_collapsed', !! isCollapsed );
						$toggleButton
							.attr( 'aria-expanded', isCollapsed ? 'false' : 'true' )
							.attr( 'title', isCollapsed ? expandLabel : collapseLabel )
							.attr( 'aria-label', isCollapsed ? expandLabel : collapseLabel );
						$toggleIcon
							.toggleClass( 'wpbc_icn_minimize', ! isCollapsed )
							.toggleClass( 'wpbc_icn_fullscreen', !! isCollapsed );
						wpbcSetupWizardStorageSet( collapsedStorageKey, isCollapsed ? '1' : '0' );
						wpbcSetupWizardApplySavedPosition();
					}

					$toggleButton.on( 'click', function() {
						wpbcSetupWizardSetCollapsed( ! $bar.hasClass( 'wpbc_setup_wizard_bar_collapsed' ) );
					} );

					$resetButton.on( 'click', function() {
						wpbcSetupWizardResetPosition();
					} );

					$dragHandle.on( 'mousedown', function( event ) {
						var startX;
						var startY;
						var startLeft;
						var startBottom;
						var rect;
						var barHeight;

						if ( wpbcSetupWizardIsSmallViewport() || ( event.which && 1 !== event.which ) ) {
							return;
						}

						event.preventDefault();
						rect = $bar[0].getBoundingClientRect();
						startX = event.clientX;
						startY = event.clientY;
						startLeft = rect.left;
						barHeight = $bar.outerHeight() || rect.height || 120;
						startBottom = jQuery( window ).height() - rect.top - barHeight;
						$bar.addClass( 'wpbc_setup_wizard_bar_is_dragging' );

						jQuery( document )
							.off( '.wpbc_setup_wizard_bar_drag' )
							.on( 'mousemove.wpbc_setup_wizard_bar_drag', function( moveEvent ) {
								wpbcSetupWizardApplyPosition( {
									left: startLeft + moveEvent.clientX - startX,
									bottom: startBottom - moveEvent.clientY + startY
								} );
							} )
							.on( 'mouseup.wpbc_setup_wizard_bar_drag', function( upEvent ) {
								var movedRect = $bar[0].getBoundingClientRect();
								var movedBottom = jQuery( window ).height() - movedRect.top - ( $bar.outerHeight() || movedRect.height || 120 );

								wpbcSetupWizardSavePosition( movedRect.left, movedBottom );
								$bar.removeClass( 'wpbc_setup_wizard_bar_is_dragging' );
								jQuery( document ).off( '.wpbc_setup_wizard_bar_drag' );
							} );
					} );

					wpbcSetupWizardSetCollapsed( '1' === wpbcSetupWizardStorageGet( collapsedStorageKey ) );
					wpbcSetupWizardApplySavedPosition();
					setTimeout( wpbcSetupWizardApplySavedPosition, 400 );
					setTimeout( wpbcSetupWizardApplySavedPosition, 1000 );
					jQuery( window ).on( 'resize.wpbc_setup_wizard_bar', wpbcSetupWizardApplySavedPosition );
					jQuery( document ).on( 'wpbc_setup_wizard_layout_changed.wpbc_setup_wizard_bar', wpbcSetupWizardApplySavedPosition );

					function wpbcSetupWizardOpenPublishArea() {
						var currentUrl = new window.URL( window.location.href );
						var currentResourcesTab = currentUrl.searchParams.get( 'tab' ) || '';
						var isResourcesPage = 'wpbc-resources' === currentUrl.searchParams.get( 'page' )
							&& ( '' === currentResourcesTab || 'resources' === currentResourcesTab );
						var catalogMount = document.getElementById( 'wpbc_catalog_booking_resources' );
						var publishTabSelectors = [
							'.wpdvlp-sub-tabs .nav-tab',
							'.wpdvlp-top-tabs .nav-tab',
							'.wpbc_settings_navigation_item a',
							'.wpbc_ui_el__vert_nav_item a',
							'[role="tab"]',
							'[data-tab]',
							'[data-subtab]'
						].join( ',' );
						var publishToggleSelectors = [
							'.wpbc_resource_field__switchable a',
							'.wpbc_resource_field__switchable button',
							'.wpbc_ajx_toolbar a',
							'.wpbc_ajx_toolbar button',
							'a.button',
							'button.button'
						].join( ',' );
						var publishTargetSelector = [
							'.wpbc_resources_table .ui_group__publish_btn:visible',
							'#wpbc_booking_resource_table .ui_group__publish_btn:visible',
							'.wpbc_resource_field__switchable.wpbc_resource_field__publish:visible',
							'.wpbc_resource_field__publish:visible',
							'.wpbc_resource_publish:visible',
							'.wpbc_publish_resources:visible',
							'[data-wpbc-resource-publish]:visible'
						].join( ',' );
						var $publishTab;
						var $publishToggle;

						if ( 'wizard_publish' !== step || ! isResourcesPage ) {
							return;
						}

						if ( 'catalog_publish' === openAction && catalogMount ) {
							var catalogPublishRequested = false;
							/**
							 * Open the first authorized Resource at its publishing inspector section.
							 *
							 * @param {CustomEvent|null} renderEvent Shared catalog render event.
							 * @return {void}
							 */
							var openCatalogPublishing = function( renderEvent ) {
								var catalogResponse = renderEvent && renderEvent.detail ? renderEvent.detail.response : null;
								var publishAction = catalogMount.querySelector( '[data-wpbc-booking-resource-action="publish_resource"][data-wpbc-booking-resource-id]' );
								var resourceId = publishAction ? Number( publishAction.getAttribute( 'data-wpbc-booking-resource-id' ) || 0 ) : 0;

								if ( ! resourceId && catalogResponse && Array.isArray( catalogResponse.items ) ) {
									catalogResponse.items.some( function( resource ) {
										var isPublishAuthorized = Array.isArray( resource.action_items ) && resource.action_items.some( function( resourceAction ) {
											return resourceAction && 'publish_resource' === resourceAction.id;
										} );

										if ( ! isPublishAuthorized ) {
											return false;
										}

										resourceId = Number( resource.id || 0 );
										return 0 < resourceId;
									} );
								}
								if ( catalogPublishRequested || ! resourceId ) {
									return;
								}

								catalogPublishRequested = true;
								catalogMount.removeEventListener( 'wpbc:ui-catalog-rendered', openCatalogPublishing );

								// Defer until the domain catalog has completed its synchronous mount listeners.
								window.setTimeout( function() {
									var resourceActionEvent;

									if ( 'function' === typeof window.CustomEvent ) {
										resourceActionEvent = new window.CustomEvent( 'wpbc:booking-resource-action', {
											bubbles: false,
											detail: {
												action: 'publish_resource',
												resource_id: resourceId,
												source: 'setup_wizard'
											}
										} );
									} else {
										resourceActionEvent = document.createEvent( 'CustomEvent' );
										resourceActionEvent.initCustomEvent( 'wpbc:booking-resource-action', false, false, {
											action: 'publish_resource',
											resource_id: resourceId,
											source: 'setup_wizard'
										} );
									}
									document.dispatchEvent( resourceActionEvent );
								}, 0 );
							};

							catalogMount.addEventListener( 'wpbc:ui-catalog-rendered', openCatalogPublishing );
							openCatalogPublishing( null );
							return;
						}

						if ( 'publish_area' !== openAction ) {
							return;
						}

						$publishTab = jQuery( publishTabSelectors ).filter( ':visible' ).filter( function() {
							var $element = jQuery( this );
							var text = $element.text() || '';
							var href = $element.attr( 'href' ) || '';
							var dataTab = $element.attr( 'data-tab' ) || '';
							var dataSubtab = $element.attr( 'data-subtab' ) || '';
							var haystack = ( text + ' ' + href + ' ' + dataTab + ' ' + dataSubtab ).toLowerCase();

							if ( $element.closest( '.wpbc_page_top__wizard_button' ).length ) {
								return false;
							}

							return (
								-1 !== haystack.indexOf( 'publish' )
								|| -1 !== haystack.indexOf( 'shortcode' )
								|| -1 !== haystack.indexOf( 'embed' )
							);
						} ).first();

						if ( $publishTab.length && ! $publishTab.hasClass( 'nav-tab-active' ) && ! $publishTab.parent().hasClass( 'active' ) ) {
							$publishTab.trigger( 'click' );
						}

						if ( ! $publishTab.length ) {
							$publishToggle = jQuery( publishToggleSelectors ).filter( ':visible' ).filter( function() {
								var $element = jQuery( this );
								var text = $element.text() || '';
								var title = $element.attr( 'title' ) || $element.attr( 'data-original-title' ) || '';
								var onclick = $element.attr( 'onclick' ) || '';
								var className = $element.attr( 'class' ) || '';
								var haystack = ( text + ' ' + title + ' ' + className ).toLowerCase();

								if ( $element.closest( '.wpbc_page_top__wizard_button' ).length ) {
									return false;
								}

								if ( -1 !== onclick.indexOf( 'wpbc_modal_dialog__show__resource_publish' ) ) {
									return false;
								}

								return (
									-1 !== haystack.indexOf( 'show publish' )
									|| -1 !== haystack.indexOf( 'publish option' )
									|| -1 !== haystack.indexOf( 'shortcode' )
									|| -1 !== haystack.indexOf( 'resource_field__publish' )
								);
							} ).first();

							if ( $publishToggle.length ) {
								$publishToggle.trigger( 'click' );
							}
						}

						setTimeout( function() {
							var $publishTarget = jQuery( publishTargetSelector ).first();

							if ( ! $publishTarget.length ) {
								$publishTarget = jQuery( selector ).filter( ':visible' ).first();
							}

							if ( ! $publishTarget.length ) {
								return;
							}

							if ( typeof wpbc_scroll_to === 'function' ) {
								wpbc_scroll_to( $publishTarget );
							} else if ( $publishTarget.offset() ) {
								jQuery( 'html, body' ).animate( { scrollTop: $publishTarget.offset().top - 80 }, 300 );
							}

							if ( typeof wpbc_blink_element === 'function' ) {
								wpbc_blink_element( $publishTarget, 3, 300 );
							}
						}, 450 );
					}

					wpbcSetupWizardOpenPublishArea();

					function wpbcSetupWizardGetFirstElement( selectors ) {
						var $element = jQuery();

						if ( ! selectors ) {
							return $element;
						}

						try {
							$element = jQuery( selectors ).filter( ':visible' ).first();
							if ( $element.length ) {
								return $element;
							}
							return jQuery( selectors ).first();
						} catch ( _e ) {
							return jQuery();
						}
					}

					function wpbcSetupWizardGetScrollableParent( $element ) {
						var $scrollParent;

						if ( ! $element || ! $element.length ) {
							return jQuery();
						}

						$scrollParent = $element.parents().filter( function() {
							var $parent = jQuery( this );
							var overflowY = $parent.css( 'overflow-y' );

							return (
								/(auto|scroll)/.test( overflowY )
								&& this.scrollHeight > Math.ceil( $parent.innerHeight() ) + 5
							);
						} ).first();

						return $scrollParent;
					}

					function wpbcSetupWizardScrollToElement( $element ) {
						var $scrollParent;
						var targetTop;

						if ( ! $element || ! $element.length || ! $element.offset() ) {
							return;
						}

						$scrollParent = wpbcSetupWizardGetScrollableParent( $element );
						if ( $scrollParent.length && ! $scrollParent.is( 'html, body' ) ) {
							targetTop = $element.offset().top - $scrollParent.offset().top + $scrollParent.scrollTop() - 40;
							$scrollParent.stop().animate( {
								scrollTop: Math.max( 0, targetTop )
							}, 350 );
							return;
						}

						if ( typeof wpbc_scroll_to === 'function' ) {
							wpbc_scroll_to( $element );
						} else {
							jQuery( 'html, body' ).stop().animate( {
								scrollTop: Math.max( 0, $element.offset().top - 90 )
							}, 350 );
						}
					}

					function wpbcSetupWizardHighlightElement( $element ) {
						if ( ! $element || ! $element.length ) {
							return;
						}

						$element.addClass( 'wpbc_setup_wizard__target_highlight' );
						if ( typeof wpbc_blink_element === 'function' ) {
							wpbc_blink_element( $element, 3, 300 );
						}
					}

					function wpbcSetupWizardPulseElement( $element ) {
						if ( ! $element || ! $element.length ) {
							return;
						}

						$element
							.removeClass( 'wpbc_setup_wizard_attention_pulse' )
							.each( function() {
								// Restart the CSS animation when the user clicks Continue repeatedly.
								void this.offsetWidth;
							} )
							.addClass( 'wpbc_setup_wizard_attention_pulse' );

						setTimeout( function() {
							$element.removeClass( 'wpbc_setup_wizard_attention_pulse' );
						}, 2100 );
					}

					function wpbcSetupWizardPulseSaveRequiredMessage() {
						if ( $bar.hasClass( 'wpbc_setup_wizard_bar_collapsed' ) ) {
							wpbcSetupWizardSetCollapsed( false );
						}

						if ( $note.length ) {
							wpbcSetupWizardPulseElement( $note );
						}

						setTimeout( function() {
							wpbcSetupWizardPulseElement( jQuery( '#ajax_working .wpbc_inner_message.notice-warning' ).last() );
						}, 50 );
					}

					function wpbcSetupWizardSetSaved() {
						$bar.attr( 'data-wpbc-setup-is-saved', '1' );
						$continueButton
							.removeClass( 'disabled' )
							.removeAttr( 'aria-disabled' )
							.attr( 'href', $continueButton.attr( 'data-wpbc-setup-continue-url' ) || '#' )
							.text( continueTitle );
						if ( $note.length ) {
							$note
								.addClass( 'wpbc_setup_wizard_bar_note_saved' )
								.text( savedNote );
						}
					}

					function wpbcSetupWizardSetUnsaved() {
						$bar.attr( 'data-wpbc-setup-is-saved', '0' );
						$continueButton.attr( 'href', '#wpbc_setup_save_required' ).text( saveSelector ? saveAndContinueTitle : continueTitle );
						if ( saveSelector ) {
							$continueButton.removeClass( 'disabled' ).removeAttr( 'aria-disabled' );
						} else {
							$continueButton.addClass( 'disabled' ).attr( 'aria-disabled', 'true' );
						}
						if ( $note.length ) {
							$note
								.removeClass( 'wpbc_setup_wizard_bar_note_saved' )
								.html( saveRequiredNote );
						}
					}

					function wpbcSetupWizardSetSaveAndContinueBusy( isBusy ) {
						if ( ! saveSelector ) {
							return;
						}

						$continueButton.toggleClass( 'disabled', !! isBusy ).text( isBusy ? savingTitle : saveAndContinueTitle );
						if ( isBusy ) {
							$continueButton.attr( 'aria-disabled', 'true' );
						} else {
							$continueButton.removeAttr( 'aria-disabled' );
						}
					}

					function wpbcSetupWizardGetContinueUrl() {
						return $continueButton.attr( 'data-wpbc-setup-continue-url' ) || $continueButton.attr( 'href' ) || '';
					}

					function wpbcSetupWizardContinueAfterSave() {
						var continueUrl;

						if ( saveAndContinueRedirecting ) {
							return;
						}

						continueUrl = wpbcSetupWizardGetContinueUrl();
						if ( ! continueUrl || '#wpbc_setup_save_required' === continueUrl ) {
							wpbcSetupWizardSetSaveAndContinueBusy( false );
							return;
						}

						saveAndContinueRedirecting = true;
						window.location.href = continueUrl;
					}

					function wpbcSetupWizardMarkSaved( afterSavedCallback ) {
						if ( ! step || ! ajaxUrl || ! nonce ) {
							wpbcSetupWizardSetSaved();
							if ( 'function' === typeof afterSavedCallback ) {
								afterSavedCallback();
							}
							return;
						}

						jQuery.post( ajaxUrl, {
							action: 'WPBC_AJX_SETUP_WIZARD_MARK_STEP_SAVED',
							nonce: nonce,
							wpbc_setup_step: step
						} ).done( function( response ) {
							if ( 'string' === typeof response ) {
								try {
									response = JSON.parse( response );
								} catch ( _e ) {}
							}
							if ( response && response.success ) {
								wpbcSetupWizardSetSaved();
								if ( 'function' === typeof afterSavedCallback ) {
									afterSavedCallback();
								}
							}
						} ).fail( function() {
							if ( saveAndContinueRequested ) {
								wpbcSetupWizardSetSaveAndContinueBusy( false );
								saveAndContinueRequested = false;
							}
						} );
					}

					function wpbcSetupWizardSaveStarted() {
						saveClicked = true;
					}

					function wpbcSetupWizardLooksSuccessfulResponse( response ) {
						if ( ! response ) {
							return false;
						}

						return (
							!! response.success
							|| 'success' === response.status
							|| '1' === String( response.ajx_after_action_result || '' )
							|| ( response.ajx_data && '1' === String( response.ajx_data.ajx_after_action_result || '' ) )
							|| ( response.data && response.data.setup_step_saved )
						);
					}

					function wpbcSetupWizardGetAjaxAction( ajaxSettings ) {
						var data = ajaxSettings && ajaxSettings.data ? ajaxSettings.data : '';
						var matches;

						if ( ! data ) {
							return '';
						}

						if ( 'string' === typeof data ) {
							matches = data.match( /(?:^|&)action=([^&]+)/ );
							return matches && matches[1] ? decodeURIComponent( matches[1].replace( /\+/g, ' ' ) ) : '';
						}

						if ( window.FormData && data instanceof window.FormData && 'function' === typeof data.get ) {
							return data.get( 'action' ) || '';
						}

						if ( 'object' === typeof data && data.action ) {
							return data.action;
						}

						return '';
					}

					function wpbcSetupWizardIsExpectedSaveAjax( ajaxSettings ) {
						var ajaxAction;

						if ( ! saveAjaxAction ) {
							return true;
						}

						ajaxAction = wpbcSetupWizardGetAjaxAction( ajaxSettings );

						return saveAjaxAction === ajaxAction;
					}

					function wpbcSetupWizardHandleSavedEvent() {
						saveClicked = false;
						wpbcSetupWizardSetSaved();
						if ( saveAndContinueRequested ) {
							wpbcSetupWizardMarkSaved( wpbcSetupWizardContinueAfterSave );
							return;
						}
						wpbcSetupWizardMarkSaved();
					}

					function wpbcSetupWizardRegisterSavedEvent( eventName ) {
						eventName = ( eventName || '' ).replace( /^\s+|\s+$/g, '' );
						if ( ! eventName ) {
							return;
						}

						document.addEventListener( eventName, wpbcSetupWizardHandleSavedEvent, true );
						jQuery( document ).on( eventName + '.wpbc_setup_wizard', wpbcSetupWizardHandleSavedEvent );
					}

					function wpbcSetupWizardFindSaveControl() {
						var $saveControl = wpbcSetupWizardGetFirstElement( saveSelector );

						if ( $saveControl.length ) {
							return $saveControl;
						}

						if ( ! formSelector ) {
							return jQuery();
						}

						return wpbcSetupWizardGetFirstElement(
							formSelector + ' button[type="submit"],' +
							formSelector + ' input[type="submit"],' +
							formSelector + ' .wpbc_submit_button_trigger,' +
							formSelector + ' .wpbc_submit_button'
						);
					}

					function wpbcSetupWizardTriggerSaveAndContinue() {
						var $saveControl = wpbcSetupWizardFindSaveControl();

						if ( saveAndContinueRequested ) {
							return;
						}

						if ( ! $saveControl.length || $saveControl.hasClass( 'disabled' ) || 'true' === $saveControl.attr( 'aria-disabled' ) ) {
							if ( typeof wpbc_admin_show_message === 'function' ) {
								wpbc_admin_show_message( '<?php echo esc_js( __( 'Please save changes on this page before continuing setup.', 'booking' ) ); ?>', 'warning', 4000, false );
							}
							wpbcSetupWizardPulseSaveRequiredMessage();
							return;
						}

						saveAndContinueRequested = true;
						wpbcSetupWizardSaveStarted();
						wpbcSetupWizardSetSaveAndContinueBusy( true );
						if ( formSelector ) {
							jQuery( formSelector ).find( 'input[name="wpbc_setup_continue_after_save"]' ).val( '1' );
						}
						$saveControl.trigger( 'click' );
					}

					if ( 'manual_save_required' === saveBehavior ) {
						window.wpbc_setup_wizard_set_current_step_saved = wpbcSetupWizardSetSaved;
						window.wpbc_setup_wizard_mark_current_step_saved = wpbcSetupWizardMarkSaved;

						document.addEventListener( 'wpbc:bfb:form:before_save_payload', function( event ) {
							if ( ! event || ! event.detail || ! event.detail.payload || ! step ) {
								return;
							}
							wpbcSetupWizardSaveStarted();
							event.detail.payload.wpbc_setup = '1';
							event.detail.payload.wpbc_setup_step = step;
							if ( saveAndContinueRequested ) {
								event.detail.payload.wpbc_setup_continue_after_save = '1';
							}
						}, true );

						saveEvents.forEach( wpbcSetupWizardRegisterSavedEvent );

						if ( formSelector ) {
							jQuery( formSelector ).each( function() {
								var $form = jQuery( this );
								if ( ! $form.is( 'form' ) ) {
									return;
								}
								if ( ! $form.find( 'input[name="wpbc_setup_saved_step"]' ).length ) {
									$form.append( '<input type="hidden" name="wpbc_setup_saved_step" value="" />' );
								}
								if ( ! $form.find( 'input[name="wpbc_setup_step"]' ).length ) {
									$form.append( '<input type="hidden" name="wpbc_setup_step" value="" />' );
								}
								if ( ! $form.find( 'input[name="wpbc_setup"]' ).length ) {
									$form.append( '<input type="hidden" name="wpbc_setup" value="" />' );
								}
								if ( ! $form.find( 'input[name="wpbc_setup_continue_after_save"]' ).length ) {
									$form.append( '<input type="hidden" name="wpbc_setup_continue_after_save" value="" />' );
								}
								$form.find( 'input[name="wpbc_setup_saved_step"]' ).val( step );
								$form.find( 'input[name="wpbc_setup_step"]' ).val( step );
								$form.find( 'input[name="wpbc_setup"]' ).val( '1' );
								$form.find( 'input[name="wpbc_setup_continue_after_save"]' ).val( '0' );
								$form
									.off( 'change.wpbc_setup_wizard input.wpbc_setup_wizard', ':input' )
									.on( 'change.wpbc_setup_wizard input.wpbc_setup_wizard', ':input', function() {
										if ( jQuery( this ).is( '[name="wpbc_setup_saved_step"],[name="wpbc_setup_step"],[name="wpbc_setup"],[name="wpbc_setup_continue_after_save"],[name="form_visible_section"]' ) ) {
											return;
										}
										wpbcSetupWizardSetUnsaved();
									} );
								$form
									.off( 'submit.wpbc_setup_wizard' )
									.on( 'submit.wpbc_setup_wizard', function() {
										wpbcSetupWizardSaveStarted();
										$form.find( 'input[name="wpbc_setup_saved_step"]' ).val( step );
										$form.find( 'input[name="wpbc_setup_step"]' ).val( step );
										$form.find( 'input[name="wpbc_setup"]' ).val( '1' );
										$form.find( 'input[name="wpbc_setup_continue_after_save"]' ).val( saveAndContinueRequested ? '1' : '0' );
									} );
							} );
						}

						$continueButton.on( 'click', function( event ) {
							if ( '1' !== $bar.attr( 'data-wpbc-setup-is-saved' ) ) {
								event.preventDefault();
								if ( saveSelector ) {
									wpbcSetupWizardTriggerSaveAndContinue();
									return;
								}
								if ( typeof wpbc_admin_show_message === 'function' ) {
									wpbc_admin_show_message( '<?php echo esc_js( __( 'Please save changes on this page before continuing setup.', 'booking' ) ); ?>', 'warning', 4000, false );
								}
								wpbcSetupWizardPulseSaveRequiredMessage();
							}
						} );

						if ( saveSelector ) {
							jQuery( document )
								.on( 'mousedown.wpbc_setup_wizard click.wpbc_setup_wizard', saveSelector, wpbcSetupWizardSaveStarted )
								.on( 'keydown.wpbc_setup_wizard', saveSelector, function( event ) {
									if ( 13 === event.which || 32 === event.which ) {
										wpbcSetupWizardSaveStarted();
									}
								} );
						}

						jQuery( document ).ajaxComplete( function( _event, xhr, ajaxSettings ) {
							var response;
							if ( ! saveClicked ) {
								return;
							}
							if ( ! wpbcSetupWizardIsExpectedSaveAjax( ajaxSettings ) ) {
								return;
							}
							saveClicked = false;

							response = xhr && xhr.responseJSON ? xhr.responseJSON : null;
							if ( ! response && xhr && xhr.responseText ) {
								try {
									response = JSON.parse( xhr.responseText );
								} catch ( _e ) {}
							}
							if ( response && response.data && response.data.setup_step_saved ) {
								wpbcSetupWizardSetSaved();
								if ( saveAndContinueRequested ) {
									wpbcSetupWizardContinueAfterSave();
								}
							} else if ( wpbcSetupWizardLooksSuccessfulResponse( response ) ) {
								if ( saveAndContinueRequested ) {
									wpbcSetupWizardMarkSaved( wpbcSetupWizardContinueAfterSave );
								} else {
									wpbcSetupWizardMarkSaved();
								}
							} else if ( saveAndContinueRequested ) {
								wpbcSetupWizardSetSaveAndContinueBusy( false );
								saveAndContinueRequested = false;
							}
						} );
					}

					if ( highlightDisabled ) {
						highlightSelector = '';
					}

					if ( ! selector && ! scrollSelector && ! highlightSelector ) {
						return;
					}

					if ( ! highlightDisabled && highlightAll ) {
						try {
							$highlightTargets = jQuery( highlightSelector || selector ).filter( ':visible' );
						} catch ( _e ) {
							$highlightTargets = jQuery();
						}

						$highlightTargets.each( function() {
							wpbcSetupWizardHighlightElement( jQuery( this ) );
						} );
					} else if ( ! highlightDisabled ) {
						$highlightTargets = wpbcSetupWizardGetFirstElement( highlightSelector || selector );
						wpbcSetupWizardHighlightElement( $highlightTargets );
					}

					$target = $highlightTargets.first();

					setTimeout( function() {
						var $scrollTarget = wpbcSetupWizardGetFirstElement( scrollSelector || ( highlightDisabled ? selector : highlightSelector ) || selector );
						if ( ! $scrollTarget.length ) {
							$scrollTarget = $target;
						}
						wpbcSetupWizardScrollToElement( $scrollTarget );
					}, 250 );
				} );
			</script><?php
		}
	}

}
function wpbc_init_setup_wizard(){
	$setup_steps = new WPBC_SETUP_WIZARD_STEPS();
}
// $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
add_action( 'init',   'wpbc_init_setup_wizard'  );



/**
* On plugin  activation set all steps as completed in Live Demos
* @return void
*/
function wpbc_booking_activate_plugin__wizard() {
	if ( wpbc_is_this_demo() ) {
		$setup_steps  = new WPBC_SETUP_WIZARD_STEPS();
		$is_completed = true;
		$setup_steps->db__set_all_steps_as( $is_completed );
	}
}
add_bk_action( 'wpbc_other_versions_activation',  'wpbc_booking_activate_plugin__wizard'  );

```
