50373.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. exports.id = 50373;
  2. exports.ids = [50373];
  3. exports.modules = {
  4. /***/ 61821:
  5. /***/ ((module) => {
  6. // Exports
  7. module.exports = {
  8. "footnoteContainer": "FootnoteText_footnoteContainer__2GrJa",
  9. "text": "FootnoteText_text__o_c03",
  10. "header": "FootnoteText_header__M_Q2C"
  11. };
  12. /***/ }),
  13. /***/ 68505:
  14. /***/ ((module) => {
  15. // Exports
  16. module.exports = {
  17. "text": "TranslationText_text__4atf8",
  18. "translation-font-size-1": "TranslationText_translation-font-size-1__TqSPj",
  19. "translation-font-size-2": "TranslationText_translation-font-size-2__AW2i1",
  20. "translation-font-size-3": "TranslationText_translation-font-size-3__ww3t4",
  21. "translation-font-size-4": "TranslationText_translation-font-size-4__TKdKv",
  22. "translation-font-size-5": "TranslationText_translation-font-size-5__5bjGX",
  23. "translation-font-size-6": "TranslationText_translation-font-size-6__6SMJi",
  24. "translation-font-size-7": "TranslationText_translation-font-size-7__03ez5",
  25. "translation-font-size-8": "TranslationText_translation-font-size-8__IA0Tr",
  26. "translation-font-size-9": "TranslationText_translation-font-size-9__tq3IG",
  27. "translation-font-size-10": "TranslationText_translation-font-size-10__A9YEa",
  28. "ltr": "TranslationText_ltr__146rZ",
  29. "rtl": "TranslationText_rtl__ytrpw",
  30. "urdu": "TranslationText_urdu__9N37Y",
  31. "kurdish": "TranslationText_kurdish__je0yf",
  32. "divehi": "TranslationText_divehi__e3rqQ",
  33. "translationName": "TranslationText_translationName__Vm9Sj"
  34. };
  35. /***/ }),
  36. /***/ 23575:
  37. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  38. "use strict";
  39. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  40. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  41. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  42. /* harmony export */ });
  43. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  44. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  45. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  46. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  47. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59003);
  48. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);
  49. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(60866);
  50. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3__);
  51. /* harmony import */ var _FootnoteText_module_scss__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(61821);
  52. /* harmony import */ var _FootnoteText_module_scss__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_FootnoteText_module_scss__WEBPACK_IMPORTED_MODULE_8__);
  53. /* harmony import */ var _TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(68505);
  54. /* harmony import */ var _TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_9__);
  55. /* harmony import */ var _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(50497);
  56. /* harmony import */ var _dls_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7190);
  57. /* harmony import */ var _icons_close_svg__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(51053);
  58. /* harmony import */ var _utils_locale__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(24709);
  59. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__]);
  60. _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  61. /* eslint-disable react/no-danger */
  62. const FootnoteText = ({ footnoteName , footnote , onCloseClicked , onTextClicked , isLoading , })=>{
  63. const { t , lang } = next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3___default()("quran-reader");
  64. const languageId = footnote?.languageId || (0,_utils_locale__WEBPACK_IMPORTED_MODULE_7__/* .findLanguageIdByLocale */ .zi)(lang);
  65. const landData = (0,_utils_locale__WEBPACK_IMPORTED_MODULE_7__/* .getLanguageDataById */ .j2)(languageId);
  66. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  67. className: (_FootnoteText_module_scss__WEBPACK_IMPORTED_MODULE_8___default().footnoteContainer),
  68. children: [
  69. /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  70. className: (_FootnoteText_module_scss__WEBPACK_IMPORTED_MODULE_8___default().header),
  71. children: [
  72. /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("p", {
  73. children: [
  74. t("footnote"),
  75. " ",
  76. footnoteName ? `- ${footnoteName}` : null
  77. ]
  78. }),
  79. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP, {
  80. size: _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__/* .ButtonSize.Small */ .qE.Small,
  81. variant: _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__/* .ButtonVariant.Ghost */ .Wu.Ghost,
  82. shape: _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__/* .ButtonShape.Circle */ .jL.Circle,
  83. onClick: onCloseClicked,
  84. children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_icons_close_svg__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {})
  85. })
  86. ]
  87. }),
  88. isLoading ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Spinner_Spinner__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {}) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  89. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_FootnoteText_module_scss__WEBPACK_IMPORTED_MODULE_8___default().text), (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_9___default())[landData.direction], (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_9___default())[landData.font]),
  90. dangerouslySetInnerHTML: {
  91. __html: footnote.text
  92. },
  93. ...onTextClicked && {
  94. onClick: onTextClicked
  95. }
  96. })
  97. ]
  98. });
  99. };
  100. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (FootnoteText);
  101. __webpack_async_result__();
  102. } catch(e) { __webpack_async_result__(e); } });
  103. /***/ }),
  104. /***/ 18809:
  105. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  106. "use strict";
  107. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  108. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  109. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  110. /* harmony export */ });
  111. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  112. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  113. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  114. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  115. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59003);
  116. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);
  117. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(60866);
  118. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3__);
  119. /* harmony import */ var _FootnoteText__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23575);
  120. /* harmony import */ var _TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(68505);
  121. /* harmony import */ var _TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8__);
  122. /* harmony import */ var _utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(55943);
  123. /* harmony import */ var _utils_locale__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(24709);
  124. /* harmony import */ var src_api__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(92684);
  125. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_FootnoteText__WEBPACK_IMPORTED_MODULE_4__, _utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__]);
  126. ([_FootnoteText__WEBPACK_IMPORTED_MODULE_4__, _utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  127. /* eslint-disable react-func/max-lines-per-function */ /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable react/no-danger */
  128. const TranslationText = ({ translationFontScale , text , languageId , resourceName , })=>{
  129. const { t } = next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3___default()("quran-reader");
  130. const { 0: isLoading , 1: setIsLoading } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
  131. const { 0: showFootnote , 1: setShowFootnote } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(true);
  132. const { 0: footnote , 1: setFootnote } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null);
  133. const { 0: activeFootnoteName , 1: setActiveFootnoteName } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null);
  134. const { 0: activeSubFootnoteName , 1: setActiveSubFootnoteName } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null);
  135. const { 0: subFootnote , 1: setSubFootnote } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null);
  136. const PRE_DEFINED_FOOTNOTES = {
  137. sg: t("footnote-sg"),
  138. pl: t("footnote-pl"),
  139. dl: t("footnote-dl")
  140. };
  141. const resetFootnote = ()=>{
  142. setFootnote(null);
  143. setSubFootnote(null);
  144. setIsLoading(false);
  145. setActiveFootnoteName(null);
  146. setActiveSubFootnoteName(null);
  147. };
  148. const resetSubFootnote = ()=>{
  149. setSubFootnote(null);
  150. setActiveSubFootnoteName(null);
  151. };
  152. /**
  153. * Handle when the translation text is clicked. This is needed to handle when a footnote
  154. * is clicked since we receive the translation text as HTML from BE. Any footnote will
  155. * be inside an <sup>...</sup> element. so when the translation container is clicked
  156. * we check whether the clicked element is of tag name SUP and if so, we handle showing the
  157. * footnote as following:
  158. *
  159. * 1. If it's not a sub-footnote (a footnote inside a footnote) which is all translations
  160. * except Bridge's Foundation translation:
  161. * 1. check if the sup element has foot_note attribute (the ID) and if it has:
  162. * 1. Check if we already have a footnote in the local state with the same ID:
  163. * 1. if yes, it means this is the second time the user clicks on the
  164. * footnote so we should close the footnote.
  165. * 2. if no, it means we need to call BE to fetch the footnote text by its ID.
  166. * 2. if not, it means it's a pre-defined footnote and in this case, we access the text
  167. * inside the element and check if it's in the list of pre-defined footnotes and if it
  168. * is, we get the value from the pre-defined footnotes and assign it as the footnote
  169. * text without having to call BE (only happens with Bridge's Foundation translation)
  170. * 2. If it's a sub-footnote it will only have pre-defined footnotes so we handle it the same
  171. * way as above (only happens with Bridge's Foundation translation, ex: Surah 30, Verse 11).
  172. *
  173. * @param {MouseEvent} event
  174. * @param {boolean} isSubFootnote whether we are handling a footnote or a sub-footnote (only happens
  175. * with Bridge's Foundation translation).
  176. */ const onTextClicked = (event, isSubFootnote = false)=>{
  177. const target = event.target;
  178. // if we just clicked on anything other than a footnote element, return early.
  179. if (target.tagName !== "SUP") {
  180. return;
  181. }
  182. // we get the text inside the sup element and trim the extra spaces.
  183. const footnoteText = target.innerText.trim();
  184. // if it's the main footnote and not the sub footnote.
  185. if (!isSubFootnote) {
  186. const footNoteId = target.getAttribute("foot_note");
  187. // Set the activeFootnoteNumber to the current number of the footnote from the <sup> innerHTML
  188. setActiveFootnoteName(footnoteText);
  189. // 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.
  190. if (footNoteId) {
  191. // if this is the second time to click the footnote, close it
  192. if (showFootnote && footnote && footnote.id === Number(footNoteId)) {
  193. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_footnote_double_click_to_close");
  194. resetFootnote();
  195. } else {
  196. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_show_footnote");
  197. resetSubFootnote();
  198. setShowFootnote(true);
  199. setIsLoading(true);
  200. (0,src_api__WEBPACK_IMPORTED_MODULE_7__/* .getFootnote */ .ei)(footNoteId).then((res)=>{
  201. if (res.status !== 500) {
  202. setFootnote(res.footNote);
  203. }
  204. }).finally(()=>{
  205. setIsLoading(false);
  206. });
  207. }
  208. } else if (footnote && footnote.id === footnoteText) {
  209. // if this is the second time we are clicking on the footnote, we close it.
  210. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_pre_defined_footnote_double_click_to_close");
  211. resetFootnote();
  212. } else if (PRE_DEFINED_FOOTNOTES[footnoteText]) {
  213. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_pre_defined_footnote");
  214. resetSubFootnote();
  215. setFootnote({
  216. id: footnoteText,
  217. text: PRE_DEFINED_FOOTNOTES[footnoteText]
  218. });
  219. }
  220. } else {
  221. // Set the activeSubFootnoteNumber to the current number of the footnote from the <sup> innerHTML
  222. setActiveSubFootnoteName(footnoteText);
  223. const subFootnoteId = `${footnote.id} - ${footnoteText}`;
  224. // if this is the second time we are clicking on the sub footnote, we close it.
  225. if (subFootnote && subFootnote.id === subFootnoteId) {
  226. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_sub_footnote_double_click_to_close");
  227. resetSubFootnote();
  228. } else if (PRE_DEFINED_FOOTNOTES[footnoteText]) {
  229. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_show_sub_footnote");
  230. setSubFootnote({
  231. id: subFootnoteId,
  232. text: PRE_DEFINED_FOOTNOTES[footnoteText]
  233. });
  234. }
  235. }
  236. };
  237. const hideFootnote = ()=>setShowFootnote(false);
  238. const langData = (0,_utils_locale__WEBPACK_IMPORTED_MODULE_6__/* .getLanguageDataById */ .j2)(languageId);
  239. const shouldShowFootnote = showFootnote && (footnote || isLoading);
  240. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  241. className: (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default())[`translation-font-size-${translationFontScale}`],
  242. children: [
  243. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  244. onClick: (event)=>onTextClicked(event),
  245. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default().text), (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default())[langData.direction], (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default())[langData.font]),
  246. dangerouslySetInnerHTML: {
  247. __html: text
  248. }
  249. }),
  250. shouldShowFootnote && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_FootnoteText__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
  251. footnoteName: activeFootnoteName || undefined,
  252. footnote: footnote,
  253. isLoading: isLoading,
  254. onCloseClicked: ()=>{
  255. (0,_utils_eventLogger__WEBPACK_IMPORTED_MODULE_5__/* .logButtonClick */ .MY)("translation_footnote_close");
  256. if (isLoading) {
  257. hideFootnote();
  258. } else {
  259. resetFootnote();
  260. }
  261. },
  262. onTextClicked: (event)=>onTextClicked(event, true)
  263. }),
  264. subFootnote && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_FootnoteText__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
  265. footnoteName: activeSubFootnoteName || undefined,
  266. footnote: subFootnote,
  267. onCloseClicked: resetSubFootnote
  268. }),
  269. resourceName && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("p", {
  270. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default().translationName), (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default())[langData.direction], (_TranslationText_module_scss__WEBPACK_IMPORTED_MODULE_8___default())[langData.font]),
  271. children: [
  272. "— ",
  273. resourceName
  274. ]
  275. })
  276. ]
  277. });
  278. };
  279. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TranslationText);
  280. __webpack_async_result__();
  281. } catch(e) { __webpack_async_result__(e); } });
  282. /***/ }),
  283. /***/ 88548:
  284. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  285. "use strict";
  286. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  287. /* harmony export */ "ZP": () => (__WEBPACK_DEFAULT_EXPORT__),
  288. /* harmony export */ "qw": () => (/* binding */ selectSelectedTranslations),
  289. /* harmony export */ "uz": () => (/* binding */ setSelectedTranslations),
  290. /* harmony export */ "z2": () => (/* binding */ selectIsUsingDefaultTranslations)
  291. /* harmony export */ });
  292. /* unused harmony exports translationsSlice, selectTranslations */
  293. /* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(75184);
  294. /* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__);
  295. /* harmony import */ var _redux_actions_reset_settings__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(78733);
  296. /* harmony import */ var _redux_actions_sync_user_preferences__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(91767);
  297. /* harmony import */ var _redux_defaultSettings_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(17241);
  298. /* harmony import */ var _redux_types_SliceName__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(61243);
  299. /* harmony import */ var _utils_array__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5639);
  300. /* harmony import */ var types_auth_PreferenceGroup__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(13591);
  301. const translationsSlice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__.createSlice)({
  302. name: _redux_types_SliceName__WEBPACK_IMPORTED_MODULE_4__/* ["default"].TRANSLATIONS */ .Z.TRANSLATIONS,
  303. initialState: (0,_redux_defaultSettings_util__WEBPACK_IMPORTED_MODULE_3__/* .getTranslationsInitialState */ .h0)(),
  304. reducers: {
  305. setSelectedTranslations: (state, action)=>({
  306. ...state,
  307. // 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].
  308. isUsingDefaultTranslations: (0,_utils_array__WEBPACK_IMPORTED_MODULE_6__/* .areArraysEqual */ .Hj)((0,_redux_defaultSettings_util__WEBPACK_IMPORTED_MODULE_3__/* .getTranslationsInitialState */ .h0)(action.payload.locale).selectedTranslations, action.payload.translations),
  309. selectedTranslations: action.payload.translations
  310. })
  311. },
  312. // reset the translation state to initial state
  313. // when `reset` action is dispatched
  314. extraReducers: (builder)=>{
  315. builder.addCase(_redux_actions_reset_settings__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z, (state, action)=>{
  316. return (0,_redux_defaultSettings_util__WEBPACK_IMPORTED_MODULE_3__/* .getTranslationsInitialState */ .h0)(action.payload.locale);
  317. });
  318. builder.addCase(_redux_actions_sync_user_preferences__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, (state, action)=>{
  319. const { payload: { userPreferences , locale } , } = action;
  320. const remotePreferences = userPreferences[types_auth_PreferenceGroup__WEBPACK_IMPORTED_MODULE_5__/* ["default"].TRANSLATIONS */ .Z.TRANSLATIONS];
  321. if (remotePreferences) {
  322. const { selectedTranslations: defaultTranslations } = (0,_redux_defaultSettings_util__WEBPACK_IMPORTED_MODULE_3__/* .getTranslationsInitialState */ .h0)(locale);
  323. const { selectedTranslations: remoteTranslations } = remotePreferences;
  324. return {
  325. ...state,
  326. ...remotePreferences,
  327. isUsingDefaultTranslations: (0,_utils_array__WEBPACK_IMPORTED_MODULE_6__/* .areArraysEqual */ .Hj)(defaultTranslations, remoteTranslations)
  328. };
  329. }
  330. return state;
  331. });
  332. }
  333. });
  334. const { setSelectedTranslations } = translationsSlice.actions;
  335. const selectTranslations = (state)=>state.translations;
  336. const selectSelectedTranslations = (state)=>state.translations.selectedTranslations;
  337. const selectIsUsingDefaultTranslations = (state)=>state.translations.isUsingDefaultTranslations;
  338. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (translationsSlice.reducer);
  339. /***/ })
  340. };
  341. ;
  342. //# sourceMappingURL=50373.js.map