"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.up = up;
exports.down = down;
const kysely_1 = require("kysely");
async function up(db) {
    await (0, kysely_1.sql) `
    UPDATE system_metadata
    SET value = jsonb_set(
      value,
      '{ffmpeg,acceptedAudioCodecs}',
      (
        SELECT jsonb_agg(
          CASE
            WHEN elem = 'libopus' THEN 'opus'
            ELSE elem
          END
        )
        FROM jsonb_array_elements_text(value->'ffmpeg'->'acceptedAudioCodecs') elem
      )
    )
    WHERE key = 'system-config'
    AND value->'ffmpeg'->'acceptedAudioCodecs' ? 'libopus';
  `.execute(db);
    await (0, kysely_1.sql) `
    UPDATE system_metadata
    SET value = jsonb_set(
      value,
      '{ffmpeg,targetAudioCodec}',
      '"opus"'::jsonb
    )
    WHERE key = 'system-config'
    AND value->'ffmpeg'->>'targetAudioCodec' = 'libopus';
  `.execute(db);
}
async function down(db) {
    await (0, kysely_1.sql) `
    UPDATE system_metadata
    SET value = jsonb_set(
      value,
      '{ffmpeg,acceptedAudioCodecs}',
      (
        SELECT jsonb_agg(
          CASE
            WHEN elem = 'opus' THEN 'libopus'
            ELSE elem
          END
        )
        FROM jsonb_array_elements_text(value->'ffmpeg'->'acceptedAudioCodecs') elem
      )
    )
    WHERE key = 'system-config'
    AND value->'ffmpeg'->'acceptedAudioCodecs' ? 'opus';
  `.execute(db);
    await (0, kysely_1.sql) `
    UPDATE system_metadata
    SET value = jsonb_set(
      value,
      '{ffmpeg,targetAudioCodec}',
      '"libopus"'::jsonb
    )
    WHERE key = 'system-config'
    AND value->'ffmpeg'->>'targetAudioCodec' = 'opus';
  `.execute(db);
}
//# sourceMappingURL=1772609167000-UpdateOpusCodecName.js.map