<?php
/**
 * Boot island + <script> tag for the catalogue tab of /admin/import.
 *
 * The behaviour itself lives in public/assets/admin/import-catalogue.js — a static,
 * cacheable file. Only the values that PHP has to compute travel with the page.
 * JSON_HEX_TAG is what keeps a "</script>" inside any of these strings from closing
 * the island early.
 */
$__catBoot = [
    'csrf'             => Router::csrfToken(),
    'defaultVideoType' => Video::defaultType(),
    'aiCost'           => [
        'title'     => (float) ($_priceAi['rewrite_title'] ?? 0.30),
        'translate' => (float) ($_priceAi['translate'] ?? 0.40),
        'desc'      => (float) ($_priceAi['rewrite_description'] ?? 0.30),
        'transdesc' => (float) ($_priceAi['translate_description'] ?? 0.40),
    ],
    'aiCostPerLang'    => [
        'translate' => isset($_priceAiPerLang['translate']) ? (float) $_priceAiPerLang['translate'] : null,
        'transdesc' => isset($_priceAiPerLang['translate_description']) ? (float) $_priceAiPerLang['translate_description'] : null,
    ],
    'aiLanguages'      => array_map(fn($l) => ['code' => $l['code'], 'name' => $l['name']], $_enabledLangs),
    'aiDefaultLang'    => $_defaultLang['name'] ?? 'English',
];
?>
<script type="application/json" id="tp-cat-boot"><?= json_encode($__catBoot, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE) ?></script>
<script src="<?= AdminAssets::url('import-catalogue.js') ?>" defer></script>
