<?php
require __DIR__ . '/../../app/bootstrap.php';
require __DIR__ . '/../../app/database.php';
require_login();

header('Content-Type: application/json; charset=utf-8');

$text = isset($_GET['text']) ? trim((string)$_GET['text']) : '';
if ($text === '') {
    echo json_encode(array('slug' => ''));
    exit;
}

$slug = transliterate_tag_slug($text);
echo json_encode(array('slug' => $slug));
