{"version":3,"sources":["../../src/i18n/app-with-translation.tsx"],"names":["jsx","hoistNonReactStatics","i18next","useMemo","I18nextProvider","initReactI18next","appWithTranslation","WrappedComponent","props","_a","_b","pageProps","_nextI18Next","initialI18nStore","initialLocale","i18n"],"mappings":"AAoCI,cAAAA,MAAA,oBAjCJ,OAAOC,MAA0B,0BAEjC,OAAOC,MAAa,UACpB,OAAS,WAAAC,MAAe,QAExB,OAAS,mBAAAC,EAAiB,oBAAAC,MAAwB,gBAO3C,MAAMC,EAAyDC,GA0B9DN,EAzBqBO,GAAe,CAhB5C,IAAAC,EAAAC,EAiBE,KAAM,CAAE,UAAAC,CAAU,EAAKH,GAAiB,CAAC,EACnC,CAAE,aAAAI,CAAa,EAAID,GAAa,CAAC,EACjC,CAAE,iBAAAE,EAAkB,cAAAC,GAAgBJ,GAAAD,EAAAD,GAAA,YAAAA,EAAO,SAAP,YAAAC,EAAe,SAAf,KAAAC,EAAyB,IAAK,EAAIE,GAAgB,CAAC,EAGvFG,EAAOZ,EAAQ,KACpBD,EAAQ,IAAIG,CAAgB,EAAE,KAAK,CAClC,UAAWQ,EACX,IAAKC,EACL,YAAaA,EACb,cAAe,CACd,YAAa,EACd,CACD,CAAC,EACMZ,GACL,CAACY,EAAe,KAAK,UAAUD,CAAgB,CAAC,CAAC,EAEpD,OACCb,EAACI,EAAA,CAAgB,KAAMW,EACtB,SAAAf,EAACO,EAAA,CAAsC,GAAGC,GAAnBM,CAA0B,EAClD,CAEF,EAEgDP,CAAgB","sourcesContent":["/**\n * © 2022 WavePlay <dev@waveplay.com>\n */\nimport hoistNonReactStatics from 'hoist-non-react-statics'\n// @ts-ignore (peer dependency)\nimport i18next from 'i18next'\nimport { useMemo } from 'react'\n// @ts-ignore (peer dependency)\nimport { I18nextProvider, initReactI18next } from 'react-i18next'\nimport type { AppProps as NextJsAppProps } from 'next/app'\n\ntype AppProps = NextJsAppProps & {\n\tpageProps: any\n}\n\nexport const appWithTranslation = <Props extends AppProps = AppProps>(WrappedComponent: React.ComponentType<Props>) => {\n\tconst AppWithTranslation = (props: any) => {\n\t\tconst { pageProps } = (props as any) || {}\n\t\tconst { _nextI18Next } = pageProps || {}\n\t\tconst { initialI18nStore, initialLocale = props?.router?.locale ?? 'en' } = _nextI18Next || {}\n\n\t\t// Initialize + memoize i18n instance\n\t\tconst i18n = useMemo(() => {\n\t\t\ti18next.use(initReactI18next).init({\n\t\t\t\tresources: initialI18nStore,\n\t\t\t\tlng: initialLocale,\n\t\t\t\tfallbackLng: initialLocale,\n\t\t\t\tinterpolation: {\n\t\t\t\t\tescapeValue: false\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn i18next\n\t\t}, [initialLocale, JSON.stringify(initialI18nStore)])\n\n\t\treturn (\n\t\t\t<I18nextProvider i18n={i18n}>\n\t\t\t\t<WrappedComponent key={initialLocale} {...props} />\n\t\t\t</I18nextProvider>\n\t\t)\n\t}\n\n\treturn hoistNonReactStatics(AppWithTranslation, WrappedComponent)\n}\n"]}