<?php
namespace Engine\Theme\JSLoader\Export;

/**
 * Export autocomplete language strings to JavaScript.
 * Emits data into `_inputAutocomplete.LANG` used by the autocomplete UI.
 */
class Autocomplete extends AbstractExport
{
    public function rehashOutputFilename(array $hash): array
    {
        global $S;
        $hash['lang'] = $S['global']['lang'];
        return $hash;
    }

    public function gather(): static
    {
        $LANG = \App\Loader_Lang::getInstance()->loadAppFile('global.lang.php')->getAll();
        $this->data = ($LANG['autocomplete'] ?? []);
        return $this;
    }

    public function asJSON(): string
    {
        return $this->exportBulkVariables("_inputAutocomplete.LANG", $this->data);
    }
}
