decord/source/modules/gif_picker/native/GIFPicker.tsx

274 lines
9.5 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 10232
// Function ID: 10233
// Dependencies: [32, 19, 17, 10233, 676, 21, 4668, 10234, 698, 7964, 10237, 12, 10240, 589, 10241, 10242, 10243, 10246, 10247, 10251, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 10232
import closure_4 from "_slicedToArray" /* 32 */;
import importAllResult from "noop" /* 19 */;
import { View } from "get ActivityIndicator" /* 17 */;
import closure_7 from "getFormatFromUrl" /* 10233 */;
import ME from "ME" /* 676 */;
import jsxProd from "jsxProd" /* 21 */;
import createCacheKey from "createCacheKey" /* 4668 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
let c5 = importAllResult;
2026-08-24 06:08:38 +00:00
({ AnalyticEvents: closure_8, ChatInputComponentViewedTypes: c9, GIF_FETCH_LIMIT_IOS: c10, GIFPickerResultTypes: unpackModuleId, TooltipNames: closure_12 } = ME);
2026-07-29 08:29:29 +00:00
({ jsx: map1, jsxs: closure_14 } = jsxProd);
let closure_15 = createCacheKey.createStyles({ container: { flex: 1 } });
2026-07-20 16:05:17 +00:00
const memoResult = importAllResult.memo(function GIFPicker(bottomSheetRef) {
bottomSheetRef = bottomSheetRef.bottomSheetRef;
const channelId = bottomSheetRef.channelId;
const guildId = bottomSheetRef.guildId;
const initialQuery = bottomSheetRef.initialQuery;
let flag = bottomSheetRef.inActionSheet;
if (flag === undefined) {
flag = true;
}
const contentHorizontalPadding = bottomSheetRef.contentHorizontalPadding;
const onPressGIF = bottomSheetRef.onPressGIF;
2026-08-24 06:08:38 +00:00
closure_6 = undefined;
2026-07-29 08:29:29 +00:00
let first;
2026-08-24 06:08:38 +00:00
closure_8 = undefined;
2026-07-20 16:05:17 +00:00
let ref;
2026-08-24 06:08:38 +00:00
closure_10 = undefined;
2026-07-20 16:05:17 +00:00
let constants;
2026-08-24 06:08:38 +00:00
closure_12 = undefined;
2026-07-29 08:29:29 +00:00
let callback;
let first1;
let callback2;
let first2;
2026-08-24 06:08:38 +00:00
closure_17 = undefined;
2026-07-23 10:11:24 +00:00
let memo1;
2026-07-20 16:05:17 +00:00
let favorites;
2026-08-24 06:08:38 +00:00
closure_20 = undefined;
2026-07-20 16:05:17 +00:00
let resultItems;
let resultQuery;
2026-07-29 08:29:29 +00:00
callback2 = undefined;
2026-07-20 16:05:17 +00:00
({ selectedGifSrc, keyboardDismissMode } = bottomSheetRef);
const items = [channelId, guildId];
2026-07-23 10:11:24 +00:00
const effect = onPressGIF.useEffect(() => {
2026-07-20 16:05:17 +00:00
let obj = guildId(initialQuery[7]);
obj.initializeSearch();
guildId(initialQuery[7]).resetSearch();
if (null != channelId) {
2026-07-29 08:29:29 +00:00
obj = { type: null, channel_id: null, guild_id: null };
obj[0] = ref.GIF;
obj[1] = tmp4;
obj[2] = guildId;
channelId(initialQuery[8]).track(lib.CHAT_INPUT_COMPONENT_VIEWED, obj);
2026-07-20 16:05:17 +00:00
const obj3 = channelId(initialQuery[8]);
}
}, items);
2026-07-29 08:29:29 +00:00
let tmp3 = channelId;
let obj = initialQuery;
const tmp4 = channelId(initialQuery[9])();
2026-08-24 06:08:38 +00:00
closure_6 = tmp4;
2026-07-29 08:29:29 +00:00
const tmp5 = contentHorizontalPadding(onPressGIF.useState(0), 2);
first = tmp5[0];
closure_8 = tmp5[1];
const items1 = [tmp4, first, contentHorizontalPadding];
callback = onPressGIF.useCallback((nativeEvent) => {
lib(nativeEvent.nativeEvent.layout.width);
}, []);
2026-07-23 10:11:24 +00:00
const memo = onPressGIF.useMemo(() => {
2026-07-20 16:05:17 +00:00
let num = 2;
2026-08-24 06:08:38 +00:00
if (closure_6) {
2026-07-20 16:05:17 +00:00
num = 3;
}
2026-07-29 08:29:29 +00:00
const obj = { columns: num, columnWidth: null };
let num2 = contentHorizontalPadding;
if (contentHorizontalPadding == null) {
num2 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const diff = first - 2 * num2;
const sum = diff + bottomSheetRef(initialQuery[10]).GIF_PICKER_GUTTER_SPACING;
obj[1] = Math.max(0, sum / num - bottomSheetRef(initialQuery[10]).GIF_PICKER_GUTTER_SPACING);
2026-07-20 16:05:17 +00:00
return obj;
}, items1);
2026-07-29 08:29:29 +00:00
({ columns, columnWidth } = memo);
2026-07-23 10:11:24 +00:00
ref = onPressGIF.useRef(null);
2026-07-29 08:29:29 +00:00
const tmp10 = contentHorizontalPadding(onPressGIF.useState(false), 2);
closure_10 = tmp10[1];
constants = onPressGIF.useRef("");
closure_12 = onPressGIF.useRef(false);
const tmp = callback2();
[tmp12, c13] = contentHorizontalPadding(onPressGIF.useState(false), 2);
const tmp14 = contentHorizontalPadding(onPressGIF.useState(constants.SEARCH), 2);
first1 = tmp14[0];
callback2 = tmp14[1];
const tmp16 = contentHorizontalPadding(onPressGIF.useState(""), 2);
first2 = tmp16[0];
2026-08-24 06:08:38 +00:00
closure_17 = tmp17;
2026-07-20 16:05:17 +00:00
const items2 = [ref];
2026-07-29 08:29:29 +00:00
const callback1 = onPressGIF.useCallback(() => {
callback(false);
callback2(closure_11.SEARCH);
2026-08-24 06:08:38 +00:00
callback3("");
2026-07-20 16:05:17 +00:00
guildId(initialQuery[7]).resetSearch();
const current = ref.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.blur();
}
}, items2);
2026-07-29 08:29:29 +00:00
memo1 = onPressGIF.useMemo(() => bottomSheetRef(initialQuery[11]).debounce(guildId(initialQuery[7]).search, 200), []);
2026-08-24 06:08:38 +00:00
obj1 = bottomSheetRef(initialQuery[10]);
2026-07-29 08:29:29 +00:00
const favoriteGIFsMobile = obj1.useFavoriteGIFsMobile();
2026-07-20 16:05:17 +00:00
favorites = favoriteGIFsMobile.favorites;
2026-07-29 08:29:29 +00:00
const items3 = [favorites, first2];
closure_20 = onPressGIF.useMemo(() => bottomSheetRef(initialQuery[12]).filterFavoriteGIFsByQuery(favorites, first2), items3);
let obj2 = bottomSheetRef(initialQuery[13]);
const items4 = [first];
const stateFromStoresObject = obj2.useStateFromStoresObject(items4, () => {
if (first1 !== closure_11.FAVORITES) {
2026-08-24 06:08:38 +00:00
resultItems = first.getResultItems();
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
resultItems = closure_20;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return { resultItems, resultQuery: first.getResultQuery() };
2026-07-20 16:05:17 +00:00
});
resultItems = stateFromStoresObject.resultItems;
resultQuery = stateFromStoresObject.resultQuery;
2026-07-29 08:29:29 +00:00
const items5 = [memo1, ref, resultQuery];
callback2 = onPressGIF.useCallback((current) => {
2026-07-20 16:05:17 +00:00
let flag = arg1;
if (arg1 === undefined) {
flag = true;
}
2026-07-29 08:29:29 +00:00
if (closure_11.current !== current) {
closure_11.current = current;
callback2(closure_11.SEARCH);
const tmp21 = current.trim().length > 0;
let tmp2 = tmp21;
if (tmp2) {
2026-07-20 16:05:17 +00:00
tmp2 = resultQuery !== current;
}
2026-07-29 08:29:29 +00:00
c13(tmp2);
callback(tmp21);
if (flag) {
let search = memo1;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
search = guildId(initialQuery[7]).search;
2026-07-20 16:05:17 +00:00
}
let SEARCH = null;
if ("" !== current) {
2026-07-29 08:29:29 +00:00
SEARCH = tmp19.SEARCH;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
search(current, SEARCH, !flag, callback);
2026-07-20 16:05:17 +00:00
if (!flag) {
current = ref.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.setText(current);
}
}
2026-07-29 08:29:29 +00:00
tmp19 = closure_11;
const tmp22 = c13;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}, items5);
const items6 = [callback2, initialQuery];
2026-07-23 10:11:24 +00:00
const effect1 = onPressGIF.useEffect(() => {
2026-07-29 08:29:29 +00:00
if (!ref.current) {
2026-07-20 16:05:17 +00:00
let tmp3 = null != initialQuery;
if (tmp3) {
2026-07-29 08:29:29 +00:00
tmp3 = str.trim().length > 0;
2026-07-20 16:05:17 +00:00
}
if (tmp3) {
2026-07-29 08:29:29 +00:00
tmp.current = true;
callback2(str, false);
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
}, items6);
2026-07-23 10:11:24 +00:00
const effect2 = onPressGIF.useEffect(() => {
2026-07-29 08:29:29 +00:00
channelId(initialQuery[14]).acknowledgeTooltip(ref.GIF_PICKER_TOOLTIP);
2026-07-20 16:05:17 +00:00
const obj = channelId(initialQuery[14]);
const trendingSearchTerms = guildId(initialQuery[7]).fetchTrendingSearchTerms();
}, []);
2026-07-29 08:29:29 +00:00
const items7 = [resultQuery, ref];
2026-07-23 10:11:24 +00:00
const effect3 = onPressGIF.useEffect(() => {
2026-07-20 16:05:17 +00:00
if ("" !== resultQuery) {
2026-07-29 08:29:29 +00:00
const suggestions = guildId(initialQuery[7]).fetchSuggestions(tmp);
2026-07-20 16:05:17 +00:00
const obj = guildId(initialQuery[7]);
}
const current = ref.current;
let text;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
text = current.getText();
}
2026-07-29 08:29:29 +00:00
c13(resultQuery !== text);
}, items7);
const items8 = [callback2];
const items9 = [onPressGIF, resultItems.length, resultQuery];
const memo2 = onPressGIF.useMemo(() => _undefined(channelId(initialQuery[15]), {
2026-07-20 16:05:17 +00:00
onClickSuggestion(arg0) {
2026-07-29 08:29:29 +00:00
return callback(arg0, false);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}), items8);
const items10 = [bottomSheetRef, callback2];
const callback3 = onPressGIF.useCallback((gifId, index) => {
2026-07-20 16:05:17 +00:00
let obj = guildId(initialQuery[7]);
obj = { type: closure_11.SEARCH, index, offset: 0, limit: closure_10, results: resultItems.length, totalResults: resultItems.length, query: resultQuery, gifId: gifId.id };
obj.trackSelectGIF(obj);
onPressGIF(gifId);
2026-07-29 08:29:29 +00:00
}, items9);
const callback4 = onPressGIF.useCallback((arg0, arg1) => {
2026-07-20 16:05:17 +00:00
if (arg0 === closure_11.TRENDING_GIFS) {
2026-07-29 08:29:29 +00:00
callback(false);
callback2(arg0);
const trendingGIFs = guildId(initialQuery[7]).fetchTrendingGIFs(callback);
2026-07-20 16:05:17 +00:00
const obj = guildId(initialQuery[7]);
2026-07-29 08:29:29 +00:00
} else if (arg0 === tmp.FAVORITES) {
callback(false);
callback2(arg0);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
callback2(arg1, false);
2026-07-20 16:05:17 +00:00
}
const current = bottomSheetRef.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.expandActionSheet();
}
2026-07-29 08:29:29 +00:00
}, items10);
obj = { onLayout: callback, style: null, children: null };
const items11 = [tmp.container, ];
let tmp31 = null;
2026-07-20 16:05:17 +00:00
if (null != contentHorizontalPadding) {
2026-07-29 08:29:29 +00:00
obj = { paddingHorizontal: null };
obj[0] = contentHorizontalPadding;
tmp31 = obj;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
items11[1] = tmp31;
obj[1] = items11;
const items12 = [callback(tmp3(obj[16]), { categoryType: first1, columnWidth, onQueryClear: callback1, onQueryChange: callback2, onFavoritesQueryChange: tmp16[1], searchInputRef: ref }), ];
2026-07-20 16:05:17 +00:00
if (resultItems.length <= 0) {
2026-07-29 08:29:29 +00:00
if (!tmp10[0]) {
if (first2.length <= 0) {
obj1 = { columns: null, onSelectCategory: null, favoritesCategory: null, inActionSheet: null };
obj1[0] = columns;
obj1[1] = callback4;
let favoritesCategory;
if (true !== bottomSheetRef.hideFavorites) {
favoritesCategory = favoriteGIFsMobile.favoritesCategory;
}
obj1[2] = favoritesCategory;
obj1[3] = flag;
items12[1] = tmp32(tmp3(obj[19]), obj1);
obj[2] = items12;
2026-08-24 06:08:38 +00:00
return first1(closure_6, obj);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
if (0 === resultItems.length) {
if (!tmp12) {
obj2 = { categoryType: null, inActionSheet: null };
obj2[0] = first1;
obj2[1] = flag;
let tmp32Result = tmp32(tmp3(obj[17]), obj2);
}
}
tmp3 = tmp3(obj[18]);
obj = { columns, columnWidth, loading: tmp12, inActionSheet: flag, resultItems, onPressGIF: callback3, selectedGifSrc, keyboardDismissMode, ListFooterComponent: memo2 };
tmp32Result = tmp32(tmp3, obj);
2026-07-20 16:05:17 +00:00
});
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/gif_picker/native/GIFPicker.tsx");
2026-07-20 16:05:17 +00:00
export default memoResult;