<?php
/**
 * Dynamic PWA Manifest — adapts to BASE_URL so the same code works
 * on localhost/callout and on https://calloutservices.ng/
 */
require_once dirname(__DIR__) . '/app/Config/App.php';

$base = rtrim(BASE_URL, '/');                   // e.g. https://calloutservices.ng/callout
$path = parse_url($base, PHP_URL_PATH) ?? '';   // e.g. /callout  OR ''

header('Content-Type: application/manifest+json; charset=utf-8');
header('Cache-Control: public, max-age=86400');

echo json_encode([
  'name'        => APP_NAME,
  'short_name'  => 'Call-Out',
  'description' => 'On-demand artisan dispatch for Nigeria. Get skilled tradespeople at your location fast.',
  'start_url'   => $path . '/',
  'scope'       => $path . '/',
  'display'     => 'standalone',
  'display_override' => ['window-controls-overlay', 'standalone'],
  'orientation' => 'portrait-primary',
  'background_color' => '#0D1B2A',
  'theme_color' => '#0078D4',
  'lang'        => 'en-NG',
  'dir'         => 'ltr',
  'categories'  => ['productivity', 'utilities', 'lifestyle'],
  'icons' => [
    ['src' => $base . '/images/icons/icon-72.png',  'sizes' => '72x72',   'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-96.png',  'sizes' => '96x96',   'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-128.png', 'sizes' => '128x128', 'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-144.png', 'sizes' => '144x144', 'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-152.png', 'sizes' => '152x152', 'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'maskable'],
    ['src' => $base . '/images/icons/icon-384.png', 'sizes' => '384x384', 'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'any'],
    ['src' => $base . '/images/icons/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'maskable'],
  ],
  'shortcuts' => [
    [
      'name'        => 'Request a Service',
      'short_name'  => 'Request',
      'description' => 'Book a skilled artisan near you instantly',
      'url'         => $path . '/client/request',
      'icons'       => [['src' => $base . '/images/icons/icon-96.png', 'sizes' => '96x96']],
    ],
    [
      'name'        => 'Artisan Portal',
      'short_name'  => 'Artisan',
      'description' => 'View your jobs and availability',
      'url'         => $path . '/artisan/dashboard',
      'icons'       => [['src' => $base . '/images/icons/icon-96.png', 'sizes' => '96x96']],
    ],
  ],
  'related_applications'      => [],
  'prefer_related_applications' => false,
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
