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AEN,oBAAoB,EAAEO,mBAAmB,GAAE,GAAGtB,kGAA2B,CAACc,MAAM,CAAC;gBACzF,MAAM,EAAEC,oBAAoB,EAAEQ,kBAAkB,GAAE,GAAGF,iBAAiB;gBACtE,OAAO;oBACL,GAAGX,KAAK;oBACR,GAAGW,iBAAiB;oBACpBT,0BAA0B,EAAEV,sEAAc,CAACoB,mBAAmB,EAAEC,kBAAkB,CAAC;iBACpF,CAAC;YACJ,CAAC;YACD,OAAOb,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AAEI,MAAM,EAAED,uBAAuB,GAAE,GAAGL,iBAAiB,CAACoB,OAAO,CAAC;AAE9D,MAAMC,kBAAkB,GAAG,CAACf,KAAgB,GAAKA,KAAK,CAACM,YAAY,CAAC;AACpE,MAAMU,0BAA0B,GAAG,CAAChB,KAAgB,GACzDA,KAAK,CAACM,YAAY,CAACD,oBAAoB,CAAC;AACnC,MAAMY,gCAAgC,GAAG,CAACjB,KAAgB,GAC/DA,KAAK,CAACM,YAAY,CAACJ,0BAA0B,CAAC;AAEhD,iEAAeR,iBAAiB,CAACwB,OAAO,EAAC","sources":["webpack://quran.com/./src/components/QuranReader/TranslationView/TranslationText/FootnoteText.module.scss","webpack://quran.com/./src/components/QuranReader/TranslationView/TranslationText/TranslationText.module.scss","webpack://quran.com/./src/components/QuranReader/TranslationView/TranslationText/FootnoteText.tsx","webpack://quran.com/./src/components/QuranReader/TranslationView/TranslationText/index.tsx","webpack://quran.com/./src/redux/slices/QuranReader/translations.ts"],"sourcesContent":["// Exports\nmodule.exports = {\n\t\"footnoteContainer\": \"FootnoteText_footnoteContainer__2GrJa\",\n\t\"text\": \"FootnoteText_text__o_c03\",\n\t\"header\": \"FootnoteText_header__M_Q2C\"\n};\n","// Exports\nmodule.exports = {\n\t\"text\": \"TranslationText_text__4atf8\",\n\t\"translation-font-size-1\": \"TranslationText_translation-font-size-1__TqSPj\",\n\t\"translation-font-size-2\": \"TranslationText_translation-font-size-2__AW2i1\",\n\t\"translation-font-size-3\": \"TranslationText_translation-font-size-3__ww3t4\",\n\t\"translation-font-size-4\": \"TranslationText_translation-font-size-4__TKdKv\",\n\t\"translation-font-size-5\": \"TranslationText_translation-font-size-5__5bjGX\",\n\t\"translation-font-size-6\": \"TranslationText_translation-font-size-6__6SMJi\",\n\t\"translation-font-size-7\": \"TranslationText_translation-font-size-7__03ez5\",\n\t\"translation-font-size-8\": \"TranslationText_translation-font-size-8__IA0Tr\",\n\t\"translation-font-size-9\": \"TranslationText_translation-font-size-9__tq3IG\",\n\t\"translation-font-size-10\": \"TranslationText_translation-font-size-10__A9YEa\",\n\t\"ltr\": \"TranslationText_ltr__146rZ\",\n\t\"rtl\": \"TranslationText_rtl__ytrpw\",\n\t\"urdu\": \"TranslationText_urdu__9N37Y\",\n\t\"kurdish\": \"TranslationText_kurdish__je0yf\",\n\t\"divehi\": \"TranslationText_divehi__e3rqQ\",\n\t\"translationName\": \"TranslationText_translationName__Vm9Sj\"\n};\n","/* eslint-disable react/no-danger */\n\nimport React, { MouseEvent } from 'react';\n\nimport classNames from 'classnames';\nimport useTranslation from 'next-translate/useTranslation';\n\nimport styles from './FootnoteText.module.scss';\nimport transStyles from './TranslationText.module.scss';\n\nimport Button, { ButtonSize, ButtonShape, ButtonVariant } from '@/dls/Button/Button';\nimport Spinner from '@/dls/Spinner/Spinner';\nimport CloseIcon from '@/icons/close.svg';\nimport { getLanguageDataById, findLanguageIdByLocale } from '@/utils/locale';\nimport Footnote from 'types/Footnote';\n\ninterface FootnoteTextProps {\n footnoteName?: string; // can be a number or a string (e.g. \"sg\" or \"pl\")\n footnote: Footnote;\n onCloseClicked: () => void;\n onTextClicked?: (event: MouseEvent, isSubFootnote?: boolean) => void;\n isLoading?: boolean;\n}\n\nconst FootnoteText: React.FC<FootnoteTextProps> = ({\n footnoteName,\n footnote,\n onCloseClicked,\n onTextClicked,\n isLoading,\n}) => {\n const { t, lang } = useTranslation('quran-reader');\n\n const languageId = footnote?.languageId || findLanguageIdByLocale(lang);\n const landData = getLanguageDataById(languageId);\n\n return (\n <div className={styles.footnoteContainer}>\n <div className={styles.header}>\n <p>\n {t('footnote')} {footnoteName ? `- ${footnoteName}` : null}\n </p>\n <Button\n size={ButtonSize.Small}\n variant={ButtonVariant.Ghost}\n shape={ButtonShape.Circle}\n onClick={onCloseClicked}\n >\n <CloseIcon />\n </Button>\n </div>\n {isLoading ? (\n <Spinner />\n ) : (\n <div\n className={classNames(\n styles.text,\n transStyles[landData.direction],\n transStyles[landData.font],\n )}\n dangerouslySetInnerHTML={{ __html: footnote.text }}\n {...(onTextClicked && { onClick: onTextClicked })}\n />\n )}\n </div>\n );\n};\n\nexport default FootnoteText;\n","/* eslint-disable react-func/max-lines-per-function */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable react/no-danger */\n\nimport React, { MouseEvent, useState } from 'react';\n\nimport classNames from 'classnames';\nimport useTranslation from 'next-translate/useTranslation';\n\nimport FootnoteText from './FootnoteText';\nimport styles from './TranslationText.module.scss';\n\nimport { logButtonClick } from '@/utils/eventLogger';\nimport { getLanguageDataById } from '@/utils/locale';\nimport { getFootnote } from 'src/api';\nimport Footnote from 'types/Footnote';\n\ninterface Props {\n translationFontScale: number;\n text: string;\n resourceName?: string;\n languageId: number;\n}\n\nconst TranslationText: React.FC<Props> = ({\n translationFontScale,\n text,\n languageId,\n resourceName,\n}) => {\n const { t } = useTranslation('quran-reader');\n const [isLoading, setIsLoading] = useState(false);\n const [showFootnote, setShowFootnote] = useState(true);\n const [footnote, setFootnote] = useState<Footnote>(null);\n const [activeFootnoteName, setActiveFootnoteName] = useState<string | null>(null);\n const [activeSubFootnoteName, setActiveSubFootnoteName] = useState<string | null>(null);\n const [subFootnote, setSubFootnote] = useState<Footnote>(null);\n\n const PRE_DEFINED_FOOTNOTES = {\n sg: t('footnote-sg'),\n pl: t('footnote-pl'),\n dl: t('footnote-dl'),\n };\n\n const resetFootnote = () => {\n setFootnote(null);\n setSubFootnote(null);\n setIsLoading(false);\n setActiveFootnoteName(null);\n setActiveSubFootnoteName(null);\n };\n\n const resetSubFootnote = () => {\n setSubFootnote(null);\n setActiveSubFootnoteName(null);\n };\n\n /**\n * Handle when the translation text is clicked. This is needed to handle when a footnote\n * is clicked since we receive the translation text as HTML from BE. Any footnote will\n * be inside an <sup>...</sup> element. so when the translation container is clicked\n * we check whether the clicked element is of tag name SUP and if so, we handle showing the\n * footnote as following:\n *\n * 1. If it's not a sub-footnote (a footnote inside a footnote) which is all translations\n * except Bridge's Foundation translation:\n * 1. check if the sup element has foot_note attribute (the ID) and if it has:\n * 1. Check if we already have a footnote in the local state with the same ID:\n * 1. if yes, it means this is the second time the user clicks on the\n * footnote so we should close the footnote.\n * 2. if no, it means we need to call BE to fetch the footnote text by its ID.\n * 2. if not, it means it's a pre-defined footnote and in this case, we access the text\n * inside the element and check if it's in the list of pre-defined footnotes and if it\n * is, we get the value from the pre-defined footnotes and assign it as the footnote\n * text without having to call BE (only happens with Bridge's Foundation translation)\n * 2. If it's a sub-footnote it will only have pre-defined footnotes so we handle it the same\n * way as above (only happens with Bridge's Foundation translation, ex: Surah 30, Verse 11).\n *\n * @param {MouseEvent} event\n * @param {boolean} isSubFootnote whether we are handling a footnote or a sub-footnote (only happens\n * with Bridge's Foundation translation).\n */\n const onTextClicked = (event: MouseEvent, isSubFootnote = false) => {\n const target = event.target as HTMLElement;\n\n // if we just clicked on anything other than a footnote element, return early.\n if (target.tagName !== 'SUP') {\n return;\n }\n // we get the text inside the sup element and trim the extra spaces.\n const footnoteText = target.innerText.trim();\n\n // if it's the main footnote and not the sub footnote.\n if (!isSubFootnote) {\n const footNoteId = target.getAttribute('foot_note');\n\n // Set the activeFootnoteNumber to the current number of the footnote from the <sup> innerHTML\n setActiveFootnoteName(footnoteText);\n\n // if it's the normal case that needs us to call BE and not a fixed footnote like the ones found for Bridge's translation.\n if (footNoteId) {\n // if this is the second time to click the footnote, close it\n if (showFootnote && footnote && footnote.id === Number(footNoteId)) {\n logButtonClick('translation_footnote_double_click_to_close');\n resetFootnote();\n } else {\n logButtonClick('translation_show_footnote');\n resetSubFootnote();\n setShowFootnote(true);\n setIsLoading(true);\n getFootnote(footNoteId)\n .then((res) => {\n if (res.status !== 500) {\n setFootnote(res.footNote);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }\n } else if (footnote && footnote.id === footnoteText) {\n // if this is the second time we are clicking on the footnote, we close it.\n logButtonClick('translation_pre_defined_footnote_double_click_to_close');\n resetFootnote();\n } else if (PRE_DEFINED_FOOTNOTES[footnoteText]) {\n logButtonClick('translation_pre_defined_footnote');\n resetSubFootnote();\n setFootnote({\n id: footnoteText,\n text: PRE_DEFINED_FOOTNOTES[footnoteText],\n });\n }\n } else {\n // Set the activeSubFootnoteNumber to the current number of the footnote from the <sup> innerHTML\n setActiveSubFootnoteName(footnoteText);\n\n const subFootnoteId = `${footnote.id} - ${footnoteText}`;\n // if this is the second time we are clicking on the sub footnote, we close it.\n if (subFootnote && subFootnote.id === subFootnoteId) {\n logButtonClick('translation_sub_footnote_double_click_to_close');\n resetSubFootnote();\n } else if (PRE_DEFINED_FOOTNOTES[footnoteText]) {\n logButtonClick('translation_show_sub_footnote');\n setSubFootnote({\n id: subFootnoteId,\n text: PRE_DEFINED_FOOTNOTES[footnoteText],\n });\n }\n }\n };\n const hideFootnote = () => setShowFootnote(false);\n const langData = getLanguageDataById(languageId);\n\n const shouldShowFootnote = showFootnote && (footnote || isLoading);\n return (\n <div className={styles[`translation-font-size-${translationFontScale}`]}>\n <div\n onClick={(event) => onTextClicked(event)}\n className={classNames(styles.text, styles[langData.direction], styles[langData.font])}\n dangerouslySetInnerHTML={{ __html: text }}\n />\n {shouldShowFootnote && (\n <FootnoteText\n footnoteName={activeFootnoteName || undefined}\n footnote={footnote}\n isLoading={isLoading}\n onCloseClicked={() => {\n logButtonClick('translation_footnote_close');\n if (isLoading) {\n hideFootnote();\n } else {\n resetFootnote();\n }\n }}\n onTextClicked={(event) => onTextClicked(event, true)}\n />\n )}\n {subFootnote && (\n <FootnoteText\n footnoteName={activeSubFootnoteName || undefined}\n footnote={subFootnote}\n onCloseClicked={resetSubFootnote}\n />\n )}\n {resourceName && (\n <p\n className={classNames(\n styles.translationName,\n styles[langData.direction],\n styles[langData.font],\n )}\n // eslint-disable-next-line i18next/no-literal-string\n >\n — {resourceName}\n </p>\n )}\n </div>\n );\n};\n\nexport default TranslationText;\n","import { createSlice, PayloadAction } from '@reduxjs/toolkit';\n\nimport resetSettings from '@/redux/actions/reset-settings';\nimport syncUserPreferences from '@/redux/actions/sync-user-preferences';\nimport { getTranslationsInitialState } from '@/redux/defaultSettings/util';\nimport { RootState } from '@/redux/RootState';\nimport SliceName from '@/redux/types/SliceName';\nimport TranslationsSettings from '@/redux/types/TranslationsSettings';\nimport { areArraysEqual } from '@/utils/array';\nimport PreferenceGroup from 'types/auth/PreferenceGroup';\n\nexport const translationsSlice = createSlice({\n name: SliceName.TRANSLATIONS,\n initialState: getTranslationsInitialState(),\n reducers: {\n setSelectedTranslations: (\n state,\n action: PayloadAction<{ translations: number[]; locale: string }>,\n ) => ({\n ...state,\n // we need to before we compare because there is a corner case when the user changes the default translations then re-selects them which results in the same array as the default one but reversed e.g. instead of [20, 131] it becomes [131, 20].\n isUsingDefaultTranslations: areArraysEqual(\n getTranslationsInitialState(action.payload.locale).selectedTranslations,\n action.payload.translations,\n ), // check if the user is using the default translations on each translation change.\n selectedTranslations: action.payload.translations,\n }),\n },\n // reset the translation state to initial state\n // when `reset` action is dispatched\n extraReducers: (builder) => {\n builder.addCase(resetSettings, (state, action) => {\n return getTranslationsInitialState(action.payload.locale);\n });\n builder.addCase(syncUserPreferences, (state, action) => {\n const {\n payload: { userPreferences, locale },\n } = action;\n const remotePreferences = userPreferences[\n PreferenceGroup.TRANSLATIONS\n ] as TranslationsSettings;\n if (remotePreferences) {\n const { selectedTranslations: defaultTranslations } = getTranslationsInitialState(locale);\n const { selectedTranslations: remoteTranslations } = remotePreferences;\n return {\n ...state,\n ...remotePreferences,\n isUsingDefaultTranslations: areArraysEqual(defaultTranslations, remoteTranslations),\n };\n }\n return state;\n });\n },\n});\n\nexport const { setSelectedTranslations } = translationsSlice.actions;\n\nexport const selectTranslations = (state: RootState) => state.translations;\nexport const selectSelectedTranslations = (state: RootState) =>\n state.translations.selectedTranslations;\nexport const selectIsUsingDefaultTranslations = (state: RootState) =>\n state.translations.isUsingDefaultTranslations;\n\nexport default translationsSlice.reducer;\n"],"names":["React","classNames","useTranslation","styles","transStyles","Button","ButtonSize","ButtonShape","ButtonVariant","Spinner","CloseIcon","getLanguageDataById","findLanguageIdByLocale","FootnoteText","footnoteName","footnote","onCloseClicked","onTextClicked","isLoading","t","lang","languageId","landData","div","className","footnoteContainer","header","p","size","Small","variant","Ghost","shape","Circle","onClick","text","direction","font","dangerouslySetInnerHTML","__html","useState","logButtonClick","getFootnote","TranslationText","translationFontScale","resourceName","setIsLoading","showFootnote","setShowFootnote","setFootnote","activeFootnoteName","setActiveFootnoteName","activeSubFootnoteName","setActiveSubFootnoteName","subFootnote","setSubFootnote","PRE_DEFINED_FOOTNOTES","sg","pl","dl","resetFootnote","resetSubFootnote","event","isSubFootnote","target","tagName","footnoteText","innerText","trim","footNoteId","getAttribute","id","Number","then","res","status","footNote","finally","subFootnoteId","hideFootnote","langData","shouldShowFootnote","undefined","translationName","createSlice","resetSettings","syncUserPreferences","getTranslationsInitialState","SliceName","areArraysEqual","PreferenceGroup","translationsSlice","name","TRANSLATIONS","initialState","reducers","setSelectedTranslations","state","action","isUsingDefaultTranslations","payload","locale","selectedTranslations","translations","extraReducers","builder","addCase","userPreferences","remotePreferences","defaultTranslations","remoteTranslations","actions","selectTranslations","selectSelectedTranslations","selectIsUsingDefaultTranslations","reducer"],"sourceRoot":""}