// Metro module 8846 (f8847). import MediaEngineStore from "../../stores/MediaEngineStore"; import UserStore from "../../stores/UserStore"; import { Endpoints } from "../../Constants"; import { HTTP } from "../../_bundle/sendRequest"; import Dispatcher from "../../Dispatcher"; import VideoFilterImageError from "./VideoFilterImageError"; import { getLastUsedVideoBackgroundOption } from "./LastUsedVideoBackgroundOption"; import { getVideoBackgroundProtoFromOption, isCustomBackgroundOption } from "./VideoBackgroundUtils"; import { PreloadedUserSettingsActionCreators, UserSettingsDelay } from "../user_settings/UserSettingsProtoActionCreators"; let env5769 = {}; export async function saveLastUsedBackgroundOption(c26299_0) { let env29990; const r10 = env5769; let c26299_2 = r10; const r29 = env29990 = { $parent: r10 }; let c26299_1 = r29; env29990[0] = c26299_0; env29990[1] = void 0; await PreloadedUserSettingsActionCreators.updateAsync("voiceAndVideo", (a0) => { a0.videoBackgroundFilterDesktop = getVideoBackgroundProtoFromOption(env29990[0]); }, UserSettingsDelay.FREQUENT_USER_ACTION); if (isCustomBackgroundOption(env29990[0])) { env29990[1] = await HTTP.post({ url: Endpoints.VIDEO_FILTER_ASSET_LAST_USED(env29990[0].id), rejectWithError: false }); Dispatcher.dispatch({ type: "VIDEO_SAVE_LAST_USED_BACKGROUND_OPTION", backgroundOption: env29990[1].body }); } else { Dispatcher.dispatch({ type: "VIDEO_SAVE_LAST_USED_BACKGROUND_OPTION", backgroundOption: env29990[0] }); } } export async function fetchVideoFilterAssets() { let r59; let c26296_2; let c26296_3 = 0; let c29987_0, c29987_1; try { c29987_0 = void 0; c26296_3 = 1; c29987_0 = await HTTP.get({ url: Endpoints.VIDEO_FILTER_ASSETS, rejectWithError: false }); Dispatcher.dispatch({ type: "VIDEO_FILTER_ASSETS_FETCH_SUCCESS", assets: c29987_0.body }); r59 = c29987_0; c26296_3 = 0; } catch ($e) { const r24 = $e; let r8 = r24; c26296_2 = r24; if (c26296_3 !== 0) { while (true) { try { const r68 = c26296_2; c26296_3 = 0; c29987_1 = r68; Dispatcher.dispatch({ type: "VIDEO_FILTER_ASSETS_FETCH_FAILURE", error: c29987_1 }); throw c29987_1; } catch (r64) { r8 = r64; c26296_2 = r64; if (c26296_3 === 0) { break; } } } } throw r8; } return r59; } export async function uploadVideoFilterAsset(asset, type, c26297_2) { let body; let c26297_5; let c26297_6 = 0; let c29988_0, c29988_1; try { c29988_0 = void 0; c26297_6 = 1; c29988_0 = await HTTP.post({ url: Endpoints.VIDEO_FILTER_ASSETS, body: { type, asset, last_used: c26297_2 == null ? void 0 : c26297_2.toISOString() }, rejectWithError: false }); Dispatcher.dispatch({ type: "VIDEO_FILTER_ASSET_UPLOAD_SUCCESS", videoFilterAsset: c29988_0.body }); body = c29988_0.body; c26297_6 = 0; } catch ($e) { const r28 = $e; let r8 = r28; c26297_5 = r28; if (c26297_6 !== 0) { while (true) { try { const r79 = c26297_5; c26297_6 = 0; c29988_1 = r79; throw new VideoFilterImageError(c29988_1); } catch (r75) { r8 = r75; c26297_5 = r75; if (c26297_6 === 0) { break; } } } } throw r8; } return body; } export async function deleteVideoFilterAsset(c26298_0) { let c29989_0 = c26298_0; await HTTP.del({ url: Endpoints.VIDEO_FILTER_ASSET(c26298_0.id), rejectWithError: false }); let c29989_1 = getLastUsedVideoBackgroundOption(UserStore.getCurrentUser()); if (isCustomBackgroundOption(c29989_1) && c29989_1.id === c29989_0.id) { (0, saveLastUsedBackgroundOption)(null); } Dispatcher.dispatch({ type: "VIDEO_FILTER_ASSET_DELETE_SUCCESS", videoFilterAsset: c29989_0 }); } export function applyMediaFilterSettings(a0) { if (MediaEngineStore.isSupported()) { Dispatcher.dispatch({ type: "MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS", settings: a0 }); } } export function startApplyMediaFilterSettings() { if (MediaEngineStore.isSupported()) { Dispatcher.dispatch({ type: "MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS_START" }); } } export function errorApplyingMediaFilterSettings() { Dispatcher.dispatch({ type: "MEDIA_ENGINE_APPLY_MEDIA_FILTER_SETTINGS_ERROR" }); }