// Metro module 15464 (f15465). import * as Module19 from "react"; import { forwardRef, useMemo, useRef, useImperativeHandle, useEffect, useCallback } from "react"; import { View } from "react-native"; import ChannelStore from "../../../../../stores/ChannelStore"; import GuildStore from "../../../../../stores/GuildStore"; import RelationshipStore from "../../../../../stores/RelationshipStore"; import UserStore from "../../../../../stores/UserStore"; import SearchQueryStore from "../../stores/SearchQueryStore"; import { SEARCH_BAR_HEIGHT, SearchQueryTagTypes } from "../../../SearchConstants"; import { SearchFilterAddLocations } from "../../tracking/TrackingConstants"; import { SearchTypes } from "../../../../../Constants"; import { createStyles } from "../../../../../design/components/Styles/native/createStyles"; import Module712 from "../../../../../_bundle/Module712"; import { intl, t } from "../../../../../intl/index.native"; import { computeChannelName } from "../../../../channel/useChannelName"; import { useStateFromStores } from "../../../../../_bundle/Module589"; import MobileVisualRefreshExperiment from "../../../../themes/experiments/MobileVisualRefreshExperiment"; import { useFontScale } from "../../../../screen/native/useFontScale"; import SearchPlatformUtils, { toSearchBarTag } from "../../SearchPlatformUtils"; import SearchPlatformActionCreators from "../../SearchPlatformActionCreators"; import { AccessibilityAnnouncer } from "../../../../../_bundle/Module3902"; import Tracking from "../../tracking/Tracking"; import { isValidFilterAnswerForSubmit } from "../../../tokens/SearchTokens"; import TagListInput_native from "../../../../../design/components/TagListInput/native/TagListInput.native"; import SearchBarActivityIcon from "./SearchBarActivityIcon"; const useStyles = createStyles((a0, a1) => ({ searchBar: { ...a0 ? { minHeight: a1 + 2 } : { borderRadius: Module712.radii.round, minHeight: a1 } }, icon: { width: 32, minHeight: a1, justifyContent: "center", zIndex: 10 } })); const r50 = Module19.memo(forwardRef(function({ searchContext, setSuggestionsDismissed }, a1) { let ref; let searchContext2; ref = void 0; const styles = useStyles(MobileVisualRefreshExperiment("SearchBar"), SEARCH_BAR_HEIGHT * Math.min(2, useFontScale())); const stateFromStores = useStateFromStores([SearchQueryStore], () => SearchQueryStore.getTags(searchContext), [searchContext]); const memo2 = useMemo(() => stateFromStores.map(toSearchBarTag), [stateFromStores]); const memo = useMemo(() => { if (stateFromStores.length !== 0) { return intl.formatToPlainString(t["0zoRaK"], { text: stateFromStores.map((stateFromStore) => stateFromStore.text).join(", ") }); } }, [stateFromStores]); ref = useRef(null); searchContext2 = searchContext; const stateFromStores2 = useStateFromStores([SearchQueryStore], () => { let r89; const channelIds = SearchQueryStore.getChannelIds(searchContext2); const type = searchContext2.type; if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.GUILD !== type) { if (SearchTypes.CHANNEL === type) { const channel = ChannelStore.getChannel(searchContext2.channelId); return channel == null ? intl.string(t["5h0QOP"]) : intl.formatToPlainString(t.LDpotA, { guildName: computeChannelName(channel, UserStore, RelationshipStore, true) }); } if (SearchTypes.DMS === type) { return intl.string(t.m7OrlR); } return intl.string(t["5h0QOP"]); } if (channelIds.size === 0) { const name = GuildStore.getGuild(searchContext2.guildId)?.name; r89 = name == null ? intl.string(t["5h0QOP"]) : intl.formatToPlainString(t.LDpotA, { guildName: name }); } else { r89 = intl.string(t["5h0QOP"]); } return r89; }, [searchContext]); useImperativeHandle(a1, () => ({ setText: (a0) => { const current = ref.current; return current == null ? void 0 : current.setText(a0); }, getText: () => { const current = ref.current; let r6 = current == null ? void 0 : current.getText(); if (r6 == null) { r6 = ""; } return r6; }, blur: () => { const current = ref.current; return current == null ? void 0 : current.blur(); }, focus: () => { const current = ref.current; return current == null ? void 0 : current.focus(); }, isFocused: () => { const current = ref.current; let r6 = current == null ? void 0 : current.isFocused(); if (r6 == null) { r6 = false; } return r6; }, measure: (a0) => { const current = ref.current; return current == null ? void 0 : current.measure(a0); }, measureInWindow: (a0) => { const current = ref.current; return current == null ? void 0 : current.measureInWindow(a0); }, measureLayout: (a0, a1, a2) => { const current = ref.current; return current == null ? void 0 : current.measureLayout(a0, a1, a2); } })); useEffect(() => SearchPlatformUtils.subscribeTextInputValue(searchContext, (a0, a1, a2) => { if (!(a2 ? a2 : a0 == null)) { const current = ref.current; if (current != null) { current.setText(a0); } } }), [searchContext]); const callback = useCallback((a0) => { let c28031_0 = a0; if (SearchQueryStore.getTextInputValue(searchContext) !== a0) { SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => { a0.setTextInputValue(c28031_0, true); }); SearchPlatformUtils.syncAutocompleteDebounced(searchContext); if (!SearchQueryStore.isAutocompleteVisible(searchContext)) { if (SearchQueryStore.isInitialSearchQuery(searchContext)) { SearchPlatformUtils.fetchInitialMessages(searchContext); } else { SearchPlatformUtils.fetchInitialMessagesDebounced(searchContext); } } } }, [searchContext]); const callback2 = useCallback((a0) => { let c28032_0 = a0; const r10 = SearchQueryStore.getTags(searchContext)[a0]; let c28032_1 = r10; if (r10 != null) { AccessibilityAnnouncer.announce(intl.formatToPlainString(t.srlxB8, { text: r10.text })); if (r10.type === SearchQueryTagTypes.COMPLETE) { Tracking.trackSearchFilterRemove({ searchContext, searchTokenType: r10.searchTokenType, isDefault: r10.location === SearchFilterAddLocations.CLIENT_AUTO_ADD }); } SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => { a0.removeTag(c28032_0); if (c28032_1.type === SearchQueryTagTypes.PREFIX) { a0.restoreDraftTextInputValue(); } }); SearchPlatformUtils.syncAutocompleteDebounced(searchContext); const queryString = SearchQueryStore.getQueryString(searchContext); const searchResultsQuery = SearchQueryStore.getSearchResultsQuery(searchContext); const isInitialSearchQuery = SearchQueryStore.isInitialSearchQuery(searchContext); if (queryString !== searchResultsQuery) { if (isInitialSearchQuery) { SearchPlatformUtils.fetchInitialMessages(searchContext); } else { SearchPlatformUtils.fetchInitialMessagesDebounced(searchContext); } } } }, [searchContext]); const memo3 = useMemo(() => () => { setSuggestionsDismissed(); const prefixTag = SearchQueryStore.getPrefixTag(searchContext); const text = SearchQueryStore.getTextInputValue(searchContext).trim(); if (prefixTag != null && text !== "" && isValidFilterAnswerForSubmit(prefixTag.searchTokenType, text)) { SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => { a0.setTextInputValue(""); a0.addTag({ type: SearchQueryTagTypes.ANSWER, text }); a0.restoreDraftTextInputValue(); }); Tracking.trackSearchFilterAdd({ searchContext, searchTokenType: prefixTag.searchTokenType, location: prefixTag.location }); } if (!SearchQueryStore.isQueryStringEmpty(searchContext)) { SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => a0.markExplicitSearchSubmitted()); SearchPlatformUtils.fetchInitialMessages(searchContext); } }, [searchContext, setSuggestionsDismissed]); return } onChangeText={callback} onRemove={callback2} placeholder={stateFromStores2} onSubmitEditing={memo3} leadingFade horizontal autoClearInputOnTagAdd={false} />; })); export default r50;