<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
?>
<!-- Start Custom Webhook Configure Modal Form -->
<div id="CustomWebhookAPIModal" title="Custom Webhook Configure" class="" style="display: none;">
	<h5>How to configure Custom Webhook connection</h5>
	<p>
		<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST" target="_blank" rel="noopener">HTTP POST Docs</a> |
		<a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/JSON" target="_blank" rel="noopener">JSON Format Help</a>
	</p>
	<div id="custom-webhook-create-help" class="accordion">
		<h3>Step 1 - Create receiver endpoint</h3>
		<div>
			<p>Create a webhook endpoint in your app or server that accepts <strong>HTTP POST</strong> requests.</p>
		</div>

		<h3>Step 2 - Set JSON request parser</h3>
		<div>
			<p>Make sure the endpoint reads <code>Content-Type: application/json</code> and parses the JSON request body.</p>
		</div>

		<h3>Step 3 - Add endpoint URL here</h3>
		<div>
			<p>Paste the full endpoint URL here, for example <code>https://example.com/webhooks/wordform</code>, then click <strong>Save / Update</strong>.</p>
		</div>

		<h3>Step 4 - Connect forms</h3>
		<div>
			<p>After saving, connect only the forms you want by using <strong>Select Form + Select Application + Create Connection</strong>.</p>
		</div>
	</div>

	<div class="custom-webhook-connection-input-elements-wrapper" style="display: flex; flex-direction:column;">
		<div class="wordform-custom-webhook-app-feedback-msg"></div>
		<div>
			<label for="CustomWebhookUrl" class="wordai-label-webhook">
				<span class="dashicons dashicons-rest-api" aria-hidden="true"></span>
				Custom Webhook URL
				<a class="wordform-field-help-link" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST" target="_blank" rel="noopener" aria-label="How to get or prepare a webhook endpoint URL">
					<span class="dashicons dashicons-editor-help" aria-hidden="true"></span>
				</a>
			</label><br/>
			<input type="text" id="CustomWebhookUrl" name="custom-webhook-url" class="custom-webhook-url" value="<?php echo esc_url( $custom_webhook_url ); ?>" placeholder="https://example.com/webhooks/wordform">
		</div>

		<div class="wordform-connect-inline-actions">
			<button
				type="button"
				class="button button-secondary wordform-connect-check-webhook-endpoint-button"
				data-check-action="wordform_connect_check_webhook_endpoint"
				data-url-selector=".custom-webhook-url"
				data-feedback-selector=".wordform-custom-webhook-app-feedback-msg"
				data-application-slug="customwebhook"
				data-invalid-msg="Please enter a valid Custom Webhook URL."
			><i class="fa-solid fa-signal"></i> Check URL</button>
			<button
				class="button button-primary wordform-connect-save-update-webhook-like-app-button"
				data-save-action="wordform_connect_save_custom_webhook_data_as_wp_option_data"
				data-url-selector=".custom-webhook-url"
				data-feedback-selector=".wordform-custom-webhook-app-feedback-msg"
				data-url-param-key="customWebhookUrl"
				data-invalid-msg="Please enter a valid Custom Webhook URL."
			><i class="fa-solid fa-gear"></i> Save / Update</button>
		</div>
	</div>
</div>
<!-- End Custom Webhook Configure Modal Form -->
