<?php
/**
 * Connect Wizard: paste a URL, see your data, put it on a page.
 *
 * All logic lives in assets/js/datastream-wizard.js; this file is the
 * container and the translatable strings.
 *
 * @package DataStream
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div id="datastream-wizard" class="datastream-wizard"
	data-strings="<?php echo esc_attr( (string) wp_json_encode( array(
		'go'          => __( 'Connect', 'datastream-api-sync' ),
		'fetching'    => __( 'Asking the API…', 'datastream-api-sync' ),
		'needsKey'    => __( 'This API wants a key. Paste it here and DataStream will figure out where it goes:', 'datastream-api-sync' ),
		'keyGo'       => __( 'Try the key', 'datastream-api-sync' ),
		/* translators: 1: number of records, 2: number of fields */
		'found'       => __( 'Found %1$d records with %2$d fields!', 'datastream-api-sync' ),
		/* translators: %d: number of fields */
		'single'      => __( 'Found a single record with %d fields.', 'datastream-api-sync' ),
		'pickFields'  => __( 'Choose what to show', 'datastream-api-sync' ),
		'template'    => __( 'How should it look?', 'datastream-api-sync' ),
		'preview'     => __( 'Preview with your real data', 'datastream-api-sync' ),
		'nameIt'      => __( 'Name this stream', 'datastream-api-sync' ),
		'createPage'  => __( 'Create a draft page showing this data', 'datastream-api-sync' ),
		'create'      => __( 'Finish & sync', 'datastream-api-sync' ),
		'creating'    => __( 'Syncing your data…', 'datastream-api-sync' ),
		'doneTitle'   => __( 'Connected!', 'datastream-api-sync' ),
		/* translators: 1: number of records, 2: seconds elapsed */
		'doneBody'    => __( '%1$d records synced. From URL to done in %2$d seconds.', 'datastream-api-sync' ),
		'editPage'    => __( 'Open the draft page', 'datastream-api-sync' ),
		'copyCode'    => __( 'Copy shortcode', 'datastream-api-sync' ),
		'copied'      => __( 'Copied!', 'datastream-api-sync' ),
		'back'        => __( 'Back', 'datastream-api-sync' ),
		'next'        => __( 'Next', 'datastream-api-sync' ),
		'tryFun'      => __( 'No API yet? Try a fun one:', 'datastream-api-sync' ),
		'failed'      => __( 'That did not work.', 'datastream-api-sync' ),
		'urlLabel'    => __( 'Paste your API address (URL)', 'datastream-api-sync' ),
		'stepConnect' => __( 'Connect', 'datastream-api-sync' ),
		'stepChoose'  => __( 'Choose', 'datastream-api-sync' ),
		'stepPlace'   => __( 'Place', 'datastream-api-sync' ),
		'err404'      => __( 'The address answered with "not found" — check it for typos.', 'datastream-api-sync' ),
		'err401'      => __( 'The API wants a key before it will answer.', 'datastream-api-sync' ),
		'err403'      => __( 'The API refused — it may need a key, or it blocks servers.', 'datastream-api-sync' ),
		'err429'      => __( 'The API says "slow down" — wait a minute and try again.', 'datastream-api-sync' ),
		'err500'      => __( 'The API had an internal problem — try again; some APIs are slow to wake up.', 'datastream-api-sync' ),
	) ) ); ?>"
	data-rest="<?php echo esc_attr( esc_url_raw( rest_url( 'datastream/v1' ) ) ); ?>"
	data-samples="<?php echo esc_attr( (string) wp_json_encode( array(
		array(
			'label' => __( 'Cat facts', 'datastream-api-sync' ),
			'url'   => 'https://catfact.ninja/facts',
		),
		array(
			'label' => __( 'Random jokes', 'datastream-api-sync' ),
			'url'   => 'https://official-joke-api.appspot.com/jokes/ten',
		),
		array(
			'label' => __( 'Rick and Morty characters', 'datastream-api-sync' ),
			'url'   => 'https://rickandmortyapi.com/api/character',
		),
		array(
			'label' => __( 'Weather in Salt Lake City', 'datastream-api-sync' ),
			'url'   => 'https://api.open-meteo.com/v1/forecast?latitude=40.76&longitude=-111.89&current=temperature_2m,wind_speed_10m',
		),
	) ) ); ?>">
	<noscript><?php esc_html_e( 'The Connect Wizard needs JavaScript. Use the Advanced form below instead.', 'datastream-api-sync' ); ?></noscript>
</div>
<p class="description" style="margin-top:1em">
	<a href="<?php echo esc_url( admin_url( 'admin.php?page=datastream-settings&tab=streams&advanced=1' ) ); ?>"><?php esc_html_e( 'Advanced: configure a stream manually', 'datastream-api-sync' ); ?></a>
</p>
