<?php
$key = basename(__FILE__, '.php');
$mandatoryEmail = (bool)get_option('setrio_bizcal_mandatory_email', false);
$args['key'] = $key;
$args['wargs'] = array_replace((isset($args['wargs']) ? $args['wargs'] : array()), array(
	'label' => setrio_bizcal_message('lblPatientEmail'),
	'texts' => array(
		'invalid' => setrio_bizcal_message('lblEmailFieldNotValid'),
        'required' => setrio_bizcal_message('lblFieldMissing') . ' ' . setrio_bizcal_message('lblPatientEmail'),
	),
	'rules' => "[
        v => " . ($mandatoryEmail ? 'false' : 'true') . " || (!!v && !!v.trim().length) || objVal(\$data,'texts." . $key . ".required') || '',
		v => !v || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(v) || objVal(\$data,'texts." . $key . ".invalid') || '',
	]",
));

setrio_bizcal_get_template_part('vue/part/text', $args);