/**
 * Ragreen - shared front-end config
 *
 * Relative (no leading slash), same reasoning as UPLOAD_URL in
 * api/config/config.php: this way it resolves correctly no matter which
 * domain/path structure serves this page - the old subfolder deployment
 * (playpulse-app.com/ragreen/public/...) or a subdomain whose document
 * root points straight at public/ (ragreen.playpulse-app.com/...). Both
 * work because public/api/ contains thin proxy files that forward to the
 * real api/ folder - see any file under public/api/ for details.
 */
const API_BASE = 'api';
const PLACEHOLDER_IMG = 'assets/img/logo-ragreen-green.png';

/**
 * Safely read and trim a form field's value. Plain jQuery `.val().trim()`
 * throws if the element doesn't exist on the page (e.g. an HTML file that's
 * out of sync with a newer JS file, missing a field the JS expects) -
 * `.val()` on an empty selection returns `undefined`, and `.trim()` on
 * `undefined` crashes the whole handler before it can even show an error.
 * This degrades to an empty string instead, so a missing field just means
 * "nothing typed there" rather than "the entire form breaks silently."
 */
function valTrim(selector) {
  const v = $(selector).val();
  return (v ?? '').toString().trim();
}
