@jackuait/blok 0.4.1-beta.1 → 0.4.1-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -17
- package/codemod/README.md +45 -7
- package/codemod/migrate-editorjs-to-blok.js +960 -92
- package/codemod/test.js +780 -77
- package/dist/blok.mjs +5 -2
- package/dist/chunks/blok-BU6NwVkN.mjs +13239 -0
- package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
- package/dist/chunks/i18next-loader-D8GzSwio.mjs +43 -0
- package/dist/{index-CEXLTV6f.mjs → chunks/index-C5e_WLFg.mjs} +2 -2
- package/dist/chunks/inline-tool-convert-CLUxkCe_.mjs +1990 -0
- package/dist/chunks/messages-0tDXLuyH.mjs +48 -0
- package/dist/chunks/messages-2_xedlYw.mjs +48 -0
- package/dist/chunks/messages-AHESHJm_.mjs +48 -0
- package/dist/chunks/messages-B5hdXZwA.mjs +48 -0
- package/dist/chunks/messages-B5jGUnOy.mjs +48 -0
- package/dist/chunks/messages-B5puUm7R.mjs +48 -0
- package/dist/chunks/messages-B66ZSDCJ.mjs +48 -0
- package/dist/chunks/messages-B9Oba7sq.mjs +48 -0
- package/dist/chunks/messages-BA0rcTCY.mjs +48 -0
- package/dist/chunks/messages-BBJgd5jG.mjs +48 -0
- package/dist/chunks/messages-BPqWKx5Z.mjs +48 -0
- package/dist/chunks/messages-Bdv-IkfG.mjs +48 -0
- package/dist/chunks/messages-BeUhMpsr.mjs +48 -0
- package/dist/chunks/messages-Bf6Y3_GI.mjs +48 -0
- package/dist/chunks/messages-BiExzWJv.mjs +48 -0
- package/dist/chunks/messages-BlpqL8vG.mjs +48 -0
- package/dist/chunks/messages-BmKCChWZ.mjs +48 -0
- package/dist/chunks/messages-Bn253WWC.mjs +48 -0
- package/dist/chunks/messages-BrJHUxQL.mjs +48 -0
- package/dist/chunks/messages-C5b7hr_E.mjs +48 -0
- package/dist/chunks/messages-C7I_AVH2.mjs +48 -0
- package/dist/chunks/messages-CJoBtXU6.mjs +48 -0
- package/dist/chunks/messages-CQj2JU2j.mjs +48 -0
- package/dist/chunks/messages-CUZ1x1QD.mjs +48 -0
- package/dist/chunks/messages-CUy1vn-b.mjs +48 -0
- package/dist/chunks/messages-CVeWVKsV.mjs +48 -0
- package/dist/chunks/messages-CXHd9SUK.mjs +48 -0
- package/dist/chunks/messages-CbMyJSzS.mjs +48 -0
- package/dist/chunks/messages-CbhuIWRJ.mjs +48 -0
- package/dist/chunks/messages-CeCjVKMW.mjs +48 -0
- package/dist/chunks/messages-Cj-t1bdy.mjs +48 -0
- package/dist/chunks/messages-CkFT2gle.mjs +48 -0
- package/dist/chunks/messages-Cm9aLHeX.mjs +48 -0
- package/dist/chunks/messages-CnvW8Slp.mjs +48 -0
- package/dist/chunks/messages-Cr-RJ7YB.mjs +48 -0
- package/dist/chunks/messages-CrsJ1TEJ.mjs +48 -0
- package/dist/chunks/messages-Cu08aLS3.mjs +48 -0
- package/dist/chunks/messages-CvaqJFN-.mjs +48 -0
- package/dist/chunks/messages-CyDU5lz9.mjs +48 -0
- package/dist/chunks/messages-CySyfkMU.mjs +48 -0
- package/dist/chunks/messages-Cyi2AMmz.mjs +48 -0
- package/dist/chunks/messages-D00OjS2n.mjs +48 -0
- package/dist/chunks/messages-DDLgIPDF.mjs +48 -0
- package/dist/chunks/messages-DMQIHGRj.mjs +48 -0
- package/dist/chunks/messages-DOlC_Tty.mjs +48 -0
- package/dist/chunks/messages-DV6shA9b.mjs +48 -0
- package/dist/chunks/messages-DY94ykcE.mjs +48 -0
- package/dist/chunks/messages-DbVquYKN.mjs +48 -0
- package/dist/chunks/messages-DcKOuncK.mjs +48 -0
- package/dist/chunks/messages-Dg92dXZ5.mjs +48 -0
- package/dist/chunks/messages-DnbbyJT3.mjs +48 -0
- package/dist/chunks/messages-DteYq0rv.mjs +48 -0
- package/dist/chunks/messages-GC2PhgV3.mjs +48 -0
- package/dist/chunks/messages-JGsXAReJ.mjs +48 -0
- package/dist/chunks/messages-JZUhXTuV.mjs +48 -0
- package/dist/chunks/messages-LvFKBBPa.mjs +48 -0
- package/dist/chunks/messages-NP1myMGI.mjs +48 -0
- package/dist/chunks/messages-Q4kc_ZtL.mjs +48 -0
- package/dist/chunks/messages-RvMHb2Ht.mjs +48 -0
- package/dist/chunks/messages-ftMcCEuO.mjs +48 -0
- package/dist/chunks/messages-o24dK6CU.mjs +48 -0
- package/dist/chunks/messages-pA5TvcAj.mjs +48 -0
- package/dist/chunks/messages-rRSHQDCX.mjs +48 -0
- package/dist/chunks/messages-srxrv8Yh.mjs +48 -0
- package/dist/chunks/messages-wdqp4610.mjs +48 -0
- package/dist/chunks/messages-zS1AXZ0y.mjs +48 -0
- package/dist/chunks/messages-zSzDzXej.mjs +48 -0
- package/dist/full.mjs +50 -0
- package/dist/locales.mjs +228 -0
- package/dist/messages-0tDXLuyH.mjs +48 -0
- package/dist/messages-2_xedlYw.mjs +48 -0
- package/dist/messages-AHESHJm_.mjs +48 -0
- package/dist/messages-B5hdXZwA.mjs +48 -0
- package/dist/messages-B5jGUnOy.mjs +48 -0
- package/dist/messages-B5puUm7R.mjs +48 -0
- package/dist/messages-B66ZSDCJ.mjs +48 -0
- package/dist/messages-B9Oba7sq.mjs +48 -0
- package/dist/messages-BA0rcTCY.mjs +48 -0
- package/dist/messages-BBJgd5jG.mjs +48 -0
- package/dist/messages-BPqWKx5Z.mjs +48 -0
- package/dist/messages-Bdv-IkfG.mjs +48 -0
- package/dist/messages-BeUhMpsr.mjs +48 -0
- package/dist/messages-Bf6Y3_GI.mjs +48 -0
- package/dist/messages-BiExzWJv.mjs +48 -0
- package/dist/messages-BlpqL8vG.mjs +48 -0
- package/dist/messages-BmKCChWZ.mjs +48 -0
- package/dist/messages-Bn253WWC.mjs +48 -0
- package/dist/messages-BrJHUxQL.mjs +48 -0
- package/dist/messages-C5b7hr_E.mjs +48 -0
- package/dist/messages-C7I_AVH2.mjs +48 -0
- package/dist/messages-CJoBtXU6.mjs +48 -0
- package/dist/messages-CQj2JU2j.mjs +48 -0
- package/dist/messages-CUZ1x1QD.mjs +48 -0
- package/dist/messages-CUy1vn-b.mjs +48 -0
- package/dist/messages-CVeWVKsV.mjs +48 -0
- package/dist/messages-CXHd9SUK.mjs +48 -0
- package/dist/messages-CbMyJSzS.mjs +48 -0
- package/dist/messages-CbhuIWRJ.mjs +48 -0
- package/dist/messages-CeCjVKMW.mjs +48 -0
- package/dist/messages-Cj-t1bdy.mjs +48 -0
- package/dist/messages-CkFT2gle.mjs +48 -0
- package/dist/messages-Cm9aLHeX.mjs +48 -0
- package/dist/messages-CnvW8Slp.mjs +48 -0
- package/dist/messages-Cr-RJ7YB.mjs +48 -0
- package/dist/messages-CrsJ1TEJ.mjs +48 -0
- package/dist/messages-Cu08aLS3.mjs +48 -0
- package/dist/messages-CvaqJFN-.mjs +48 -0
- package/dist/messages-CyDU5lz9.mjs +48 -0
- package/dist/messages-CySyfkMU.mjs +48 -0
- package/dist/messages-Cyi2AMmz.mjs +48 -0
- package/dist/messages-D00OjS2n.mjs +48 -0
- package/dist/messages-DDLgIPDF.mjs +48 -0
- package/dist/messages-DMQIHGRj.mjs +48 -0
- package/dist/messages-DOlC_Tty.mjs +48 -0
- package/dist/messages-DV6shA9b.mjs +48 -0
- package/dist/messages-DY94ykcE.mjs +48 -0
- package/dist/messages-DbVquYKN.mjs +48 -0
- package/dist/messages-DcKOuncK.mjs +48 -0
- package/dist/messages-Dg92dXZ5.mjs +48 -0
- package/dist/messages-DnbbyJT3.mjs +48 -0
- package/dist/messages-DteYq0rv.mjs +48 -0
- package/dist/messages-GC2PhgV3.mjs +48 -0
- package/dist/messages-JGsXAReJ.mjs +48 -0
- package/dist/messages-JZUhXTuV.mjs +48 -0
- package/dist/messages-LvFKBBPa.mjs +48 -0
- package/dist/messages-NP1myMGI.mjs +48 -0
- package/dist/messages-Q4kc_ZtL.mjs +48 -0
- package/dist/messages-RvMHb2Ht.mjs +48 -0
- package/dist/messages-ftMcCEuO.mjs +48 -0
- package/dist/messages-o24dK6CU.mjs +48 -0
- package/dist/messages-pA5TvcAj.mjs +48 -0
- package/dist/messages-rRSHQDCX.mjs +48 -0
- package/dist/messages-srxrv8Yh.mjs +48 -0
- package/dist/messages-wdqp4610.mjs +48 -0
- package/dist/messages-zS1AXZ0y.mjs +48 -0
- package/dist/messages-zSzDzXej.mjs +48 -0
- package/dist/tools.mjs +3126 -0
- package/dist/vendor.LICENSE.txt +26 -225
- package/package.json +63 -24
- package/src/blok.ts +267 -0
- package/src/components/__module.ts +139 -0
- package/src/components/block/api.ts +155 -0
- package/src/components/block/index.ts +1428 -0
- package/src/components/block-tunes/block-tune-delete.ts +51 -0
- package/src/components/blocks.ts +352 -0
- package/src/components/constants/data-attributes.ts +344 -0
- package/src/components/constants.ts +76 -0
- package/src/components/core.ts +392 -0
- package/src/components/dom.ts +773 -0
- package/src/components/domIterator.ts +189 -0
- package/src/components/errors/critical.ts +5 -0
- package/src/components/events/BlockChanged.ts +16 -0
- package/src/components/events/BlockHovered.ts +21 -0
- package/src/components/events/BlockSettingsClosed.ts +12 -0
- package/src/components/events/BlockSettingsOpened.ts +12 -0
- package/src/components/events/BlokMobileLayoutToggled.ts +15 -0
- package/src/components/events/FakeCursorAboutToBeToggled.ts +17 -0
- package/src/components/events/FakeCursorHaveBeenSet.ts +17 -0
- package/src/components/events/HistoryStateChanged.ts +19 -0
- package/src/components/events/RedactorDomChanged.ts +14 -0
- package/src/components/events/index.ts +46 -0
- package/src/components/flipper.ts +497 -0
- package/src/components/i18n/i18next-loader.ts +84 -0
- package/src/components/i18n/lightweight-i18n.ts +86 -0
- package/src/components/i18n/locales/TRANSLATION_GUIDELINES.md +113 -0
- package/src/components/i18n/locales/am/messages.json +45 -0
- package/src/components/i18n/locales/ar/messages.json +45 -0
- package/src/components/i18n/locales/az/messages.json +45 -0
- package/src/components/i18n/locales/bg/messages.json +45 -0
- package/src/components/i18n/locales/bn/messages.json +45 -0
- package/src/components/i18n/locales/bs/messages.json +45 -0
- package/src/components/i18n/locales/cs/messages.json +45 -0
- package/src/components/i18n/locales/da/messages.json +45 -0
- package/src/components/i18n/locales/de/messages.json +45 -0
- package/src/components/i18n/locales/dv/messages.json +45 -0
- package/src/components/i18n/locales/el/messages.json +45 -0
- package/src/components/i18n/locales/en/messages.json +45 -0
- package/src/components/i18n/locales/es/messages.json +45 -0
- package/src/components/i18n/locales/et/messages.json +45 -0
- package/src/components/i18n/locales/fa/messages.json +45 -0
- package/src/components/i18n/locales/fi/messages.json +45 -0
- package/src/components/i18n/locales/fil/messages.json +45 -0
- package/src/components/i18n/locales/fr/messages.json +45 -0
- package/src/components/i18n/locales/gu/messages.json +45 -0
- package/src/components/i18n/locales/he/messages.json +45 -0
- package/src/components/i18n/locales/hi/messages.json +45 -0
- package/src/components/i18n/locales/hr/messages.json +45 -0
- package/src/components/i18n/locales/hu/messages.json +45 -0
- package/src/components/i18n/locales/hy/messages.json +45 -0
- package/src/components/i18n/locales/id/messages.json +45 -0
- package/src/components/i18n/locales/index.ts +231 -0
- package/src/components/i18n/locales/it/messages.json +45 -0
- package/src/components/i18n/locales/ja/messages.json +45 -0
- package/src/components/i18n/locales/ka/messages.json +45 -0
- package/src/components/i18n/locales/km/messages.json +45 -0
- package/src/components/i18n/locales/kn/messages.json +45 -0
- package/src/components/i18n/locales/ko/messages.json +45 -0
- package/src/components/i18n/locales/ku/messages.json +45 -0
- package/src/components/i18n/locales/lo/messages.json +45 -0
- package/src/components/i18n/locales/lt/messages.json +45 -0
- package/src/components/i18n/locales/lv/messages.json +45 -0
- package/src/components/i18n/locales/mk/messages.json +45 -0
- package/src/components/i18n/locales/ml/messages.json +45 -0
- package/src/components/i18n/locales/mn/messages.json +45 -0
- package/src/components/i18n/locales/mr/messages.json +45 -0
- package/src/components/i18n/locales/ms/messages.json +45 -0
- package/src/components/i18n/locales/my/messages.json +45 -0
- package/src/components/i18n/locales/ne/messages.json +45 -0
- package/src/components/i18n/locales/nl/messages.json +45 -0
- package/src/components/i18n/locales/no/messages.json +45 -0
- package/src/components/i18n/locales/pa/messages.json +45 -0
- package/src/components/i18n/locales/pl/messages.json +45 -0
- package/src/components/i18n/locales/ps/messages.json +45 -0
- package/src/components/i18n/locales/pt/messages.json +45 -0
- package/src/components/i18n/locales/ro/messages.json +45 -0
- package/src/components/i18n/locales/ru/messages.json +45 -0
- package/src/components/i18n/locales/sd/messages.json +45 -0
- package/src/components/i18n/locales/si/messages.json +45 -0
- package/src/components/i18n/locales/sk/messages.json +45 -0
- package/src/components/i18n/locales/sl/messages.json +45 -0
- package/src/components/i18n/locales/sq/messages.json +45 -0
- package/src/components/i18n/locales/sr/messages.json +45 -0
- package/src/components/i18n/locales/sv/messages.json +45 -0
- package/src/components/i18n/locales/sw/messages.json +45 -0
- package/src/components/i18n/locales/ta/messages.json +45 -0
- package/src/components/i18n/locales/te/messages.json +45 -0
- package/src/components/i18n/locales/th/messages.json +45 -0
- package/src/components/i18n/locales/tr/messages.json +45 -0
- package/src/components/i18n/locales/ug/messages.json +45 -0
- package/src/components/i18n/locales/uk/messages.json +45 -0
- package/src/components/i18n/locales/ur/messages.json +45 -0
- package/src/components/i18n/locales/vi/messages.json +45 -0
- package/src/components/i18n/locales/yi/messages.json +45 -0
- package/src/components/i18n/locales/zh/messages.json +45 -0
- package/src/components/icons/index.ts +242 -0
- package/src/components/inline-tools/inline-tool-bold.ts +2213 -0
- package/src/components/inline-tools/inline-tool-convert.ts +142 -0
- package/src/components/inline-tools/inline-tool-italic.ts +500 -0
- package/src/components/inline-tools/inline-tool-link.ts +540 -0
- package/src/components/modules/api/blocks.ts +377 -0
- package/src/components/modules/api/caret.ts +125 -0
- package/src/components/modules/api/events.ts +51 -0
- package/src/components/modules/api/history.ts +73 -0
- package/src/components/modules/api/i18n.ts +35 -0
- package/src/components/modules/api/index.ts +39 -0
- package/src/components/modules/api/inlineToolbar.ts +33 -0
- package/src/components/modules/api/listeners.ts +56 -0
- package/src/components/modules/api/notifier.ts +46 -0
- package/src/components/modules/api/readonly.ts +39 -0
- package/src/components/modules/api/sanitizer.ts +30 -0
- package/src/components/modules/api/saver.ts +52 -0
- package/src/components/modules/api/selection.ts +48 -0
- package/src/components/modules/api/styles.ts +72 -0
- package/src/components/modules/api/toolbar.ts +79 -0
- package/src/components/modules/api/tools.ts +16 -0
- package/src/components/modules/api/tooltip.ts +67 -0
- package/src/components/modules/api/ui.ts +36 -0
- package/src/components/modules/blockEvents.ts +1591 -0
- package/src/components/modules/blockManager.ts +1356 -0
- package/src/components/modules/blockSelection.ts +708 -0
- package/src/components/modules/caret.ts +853 -0
- package/src/components/modules/crossBlockSelection.ts +329 -0
- package/src/components/modules/dragManager.ts +1204 -0
- package/src/components/modules/history.ts +1098 -0
- package/src/components/modules/i18n.ts +332 -0
- package/src/components/modules/index.ts +139 -0
- package/src/components/modules/modificationsObserver.ts +147 -0
- package/src/components/modules/paste.ts +1092 -0
- package/src/components/modules/readonly.ts +136 -0
- package/src/components/modules/rectangleSelection.ts +711 -0
- package/src/components/modules/renderer.ts +155 -0
- package/src/components/modules/saver.ts +283 -0
- package/src/components/modules/toolbar/blockSettings.ts +782 -0
- package/src/components/modules/toolbar/index.ts +1296 -0
- package/src/components/modules/toolbar/inline.ts +956 -0
- package/src/components/modules/tools.ts +625 -0
- package/src/components/modules/ui.ts +1283 -0
- package/src/components/polyfills.ts +113 -0
- package/src/components/selection.ts +1179 -0
- package/src/components/tools/base.ts +301 -0
- package/src/components/tools/block.ts +339 -0
- package/src/components/tools/collection.ts +67 -0
- package/src/components/tools/factory.ts +138 -0
- package/src/components/tools/inline.ts +71 -0
- package/src/components/tools/tune.ts +33 -0
- package/src/components/ui/toolbox.ts +610 -0
- package/src/components/utils/announcer.ts +205 -0
- package/src/components/utils/api.ts +20 -0
- package/src/components/utils/bem.ts +26 -0
- package/src/components/utils/blocks.ts +284 -0
- package/src/components/utils/caret.ts +1067 -0
- package/src/components/utils/data-model-transform.ts +382 -0
- package/src/components/utils/events.ts +117 -0
- package/src/components/utils/keyboard.ts +60 -0
- package/src/components/utils/listeners.ts +296 -0
- package/src/components/utils/mutations.ts +39 -0
- package/src/components/utils/notifier/draw.ts +190 -0
- package/src/components/utils/notifier/index.ts +66 -0
- package/src/components/utils/notifier/types.ts +1 -0
- package/src/components/utils/notifier.ts +77 -0
- package/src/components/utils/placeholder.ts +140 -0
- package/src/components/utils/popover/components/hint/hint.const.ts +10 -0
- package/src/components/utils/popover/components/hint/hint.ts +46 -0
- package/src/components/utils/popover/components/hint/index.ts +6 -0
- package/src/components/utils/popover/components/popover-header/index.ts +2 -0
- package/src/components/utils/popover/components/popover-header/popover-header.const.ts +8 -0
- package/src/components/utils/popover/components/popover-header/popover-header.ts +80 -0
- package/src/components/utils/popover/components/popover-header/popover-header.types.ts +14 -0
- package/src/components/utils/popover/components/popover-item/index.ts +13 -0
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +50 -0
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +680 -0
- package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.const.ts +14 -0
- package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts +136 -0
- package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.const.ts +20 -0
- package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.ts +117 -0
- package/src/components/utils/popover/components/popover-item/popover-item.ts +197 -0
- package/src/components/utils/popover/components/search-input/index.ts +2 -0
- package/src/components/utils/popover/components/search-input/search-input.const.ts +8 -0
- package/src/components/utils/popover/components/search-input/search-input.ts +178 -0
- package/src/components/utils/popover/components/search-input/search-input.types.ts +59 -0
- package/src/components/utils/popover/index.ts +13 -0
- package/src/components/utils/popover/popover-abstract.ts +457 -0
- package/src/components/utils/popover/popover-desktop.ts +682 -0
- package/src/components/utils/popover/popover-inline.ts +338 -0
- package/src/components/utils/popover/popover-mobile.ts +201 -0
- package/src/components/utils/popover/popover.const.ts +81 -0
- package/src/components/utils/popover/utils/popover-states-history.ts +72 -0
- package/src/components/utils/promise-queue.ts +43 -0
- package/src/components/utils/sanitizer.ts +537 -0
- package/src/components/utils/scroll-locker.ts +87 -0
- package/src/components/utils/shortcut.ts +231 -0
- package/src/components/utils/shortcuts.ts +113 -0
- package/src/components/utils/tools.ts +110 -0
- package/src/components/utils/tooltip.ts +591 -0
- package/src/components/utils/tw.ts +241 -0
- package/src/components/utils.ts +1081 -0
- package/src/env.d.ts +13 -0
- package/src/full.ts +69 -0
- package/src/locales.ts +51 -0
- package/src/stories/Block.stories.ts +498 -0
- package/src/stories/EditorModes.stories.ts +505 -0
- package/src/stories/Header.stories.ts +137 -0
- package/src/stories/InlineToolbar.stories.ts +498 -0
- package/src/stories/List.stories.ts +259 -0
- package/src/stories/Notifier.stories.ts +340 -0
- package/src/stories/Paragraph.stories.ts +112 -0
- package/src/stories/Placeholder.stories.ts +319 -0
- package/src/stories/Popover.stories.ts +759 -0
- package/src/stories/Selection.stories.ts +250 -0
- package/src/stories/StubBlock.stories.ts +156 -0
- package/src/stories/Toolbar.stories.ts +223 -0
- package/src/stories/Toolbox.stories.ts +166 -0
- package/src/stories/Tooltip.stories.ts +198 -0
- package/src/stories/helpers.ts +463 -0
- package/src/styles/main.css +126 -0
- package/src/tools/header/index.ts +647 -0
- package/src/tools/index.ts +45 -0
- package/src/tools/list/index.ts +1826 -0
- package/src/tools/paragraph/index.ts +412 -0
- package/src/tools/stub/index.ts +107 -0
- package/src/types-internal/blok-modules.d.ts +87 -0
- package/src/types-internal/html-janitor.d.ts +28 -0
- package/src/types-internal/module-config.d.ts +11 -0
- package/src/variants/all-locales.ts +155 -0
- package/src/variants/blok-maximum.ts +20 -0
- package/src/variants/blok-minimum.ts +243 -0
- package/types/api/blocks.d.ts +9 -1
- package/types/api/history.d.ts +7 -0
- package/types/api/i18n.d.ts +22 -3
- package/types/api/selection.d.ts +6 -0
- package/types/api/styles.d.ts +23 -10
- package/types/configs/blok-config.d.ts +29 -0
- package/types/configs/i18n-config.d.ts +52 -2
- package/types/configs/i18n-dictionary.d.ts +16 -90
- package/types/configs/sanitizer-config.d.ts +25 -1
- package/types/data-attributes.d.ts +170 -0
- package/types/data-formats/output-data.d.ts +15 -0
- package/types/full.d.ts +80 -0
- package/types/index.d.ts +30 -13
- package/types/locales.d.ts +59 -0
- package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
- package/types/tools/block-tool.d.ts +11 -2
- package/types/tools/header.d.ts +18 -0
- package/types/tools/index.d.ts +1 -0
- package/types/tools/list.d.ts +91 -0
- package/types/tools/paragraph.d.ts +71 -0
- package/types/tools/tool-settings.d.ts +99 -6
- package/types/tools/tool.d.ts +6 -0
- package/types/tools-entry.d.ts +49 -0
- package/types/utils/popover/popover-item.d.ts +24 -5
- package/types/utils/popover/popover.d.ts +13 -0
- package/dist/blok-C8XbyLHh.mjs +0 -25795
- package/dist/blok.umd.js +0 -181
|
@@ -0,0 +1,1292 @@
|
|
|
1
|
+
var Re = Object.defineProperty, Pe = Object.defineProperties;
|
|
2
|
+
var $e = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var re = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ne = Object.prototype.hasOwnProperty, ke = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ae = (o, e, t) => e in o ? Re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, d = (o, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
Ne.call(e, t) && ae(o, t, e[t]);
|
|
8
|
+
if (re)
|
|
9
|
+
for (var t of re(e))
|
|
10
|
+
ke.call(e, t) && ae(o, t, e[t]);
|
|
11
|
+
return o;
|
|
12
|
+
}, b = (o, e) => Pe(o, $e(e));
|
|
13
|
+
const p = (o) => typeof o == "string", U = () => {
|
|
14
|
+
let o, e;
|
|
15
|
+
const t = new Promise((i, s) => {
|
|
16
|
+
o = i, e = s;
|
|
17
|
+
});
|
|
18
|
+
return t.resolve = o, t.reject = e, t;
|
|
19
|
+
}, oe = (o) => o == null ? "" : "" + o, Fe = (o, e, t) => {
|
|
20
|
+
o.forEach((i) => {
|
|
21
|
+
e[i] && (t[i] = e[i]);
|
|
22
|
+
});
|
|
23
|
+
}, je = /###/g, le = (o) => o && o.indexOf("###") > -1 ? o.replace(je, ".") : o, ue = (o) => !o || p(o), H = (o, e, t) => {
|
|
24
|
+
const i = p(e) ? e.split(".") : e;
|
|
25
|
+
let s = 0;
|
|
26
|
+
for (; s < i.length - 1; ) {
|
|
27
|
+
if (ue(o)) return {};
|
|
28
|
+
const n = le(i[s]);
|
|
29
|
+
!o[n] && t && (o[n] = new t()), Object.prototype.hasOwnProperty.call(o, n) ? o = o[n] : o = {}, ++s;
|
|
30
|
+
}
|
|
31
|
+
return ue(o) ? {} : {
|
|
32
|
+
obj: o,
|
|
33
|
+
k: le(i[s])
|
|
34
|
+
};
|
|
35
|
+
}, fe = (o, e, t) => {
|
|
36
|
+
const {
|
|
37
|
+
obj: i,
|
|
38
|
+
k: s
|
|
39
|
+
} = H(o, e, Object);
|
|
40
|
+
if (i !== void 0 || e.length === 1) {
|
|
41
|
+
i[s] = t;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let n = e[e.length - 1], r = e.slice(0, e.length - 1), a = H(o, r, Object);
|
|
45
|
+
for (; a.obj === void 0 && r.length; )
|
|
46
|
+
n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), a = H(o, r, Object), a != null && a.obj && typeof a.obj[`${a.k}.${n}`] != "undefined" && (a.obj = void 0);
|
|
47
|
+
a.obj[`${a.k}.${n}`] = t;
|
|
48
|
+
}, Ee = (o, e, t, i) => {
|
|
49
|
+
const {
|
|
50
|
+
obj: s,
|
|
51
|
+
k: n
|
|
52
|
+
} = H(o, e, Object);
|
|
53
|
+
s[n] = s[n] || [], s[n].push(t);
|
|
54
|
+
}, Y = (o, e) => {
|
|
55
|
+
const {
|
|
56
|
+
obj: t,
|
|
57
|
+
k: i
|
|
58
|
+
} = H(o, e);
|
|
59
|
+
if (t && Object.prototype.hasOwnProperty.call(t, i))
|
|
60
|
+
return t[i];
|
|
61
|
+
}, Te = (o, e, t) => {
|
|
62
|
+
const i = Y(o, t);
|
|
63
|
+
return i !== void 0 ? i : Y(e, t);
|
|
64
|
+
}, be = (o, e, t) => {
|
|
65
|
+
for (const i in e)
|
|
66
|
+
i !== "__proto__" && i !== "constructor" && (i in o ? p(o[i]) || o[i] instanceof String || p(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) : be(o[i], e[i], t) : o[i] = e[i]);
|
|
67
|
+
return o;
|
|
68
|
+
}, D = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
69
|
+
var Ie = {
|
|
70
|
+
"&": "&",
|
|
71
|
+
"<": "<",
|
|
72
|
+
">": ">",
|
|
73
|
+
'"': """,
|
|
74
|
+
"'": "'",
|
|
75
|
+
"/": "/"
|
|
76
|
+
};
|
|
77
|
+
const De = (o) => p(o) ? o.replace(/[&<>"'\/]/g, (e) => Ie[e]) : o;
|
|
78
|
+
class Ve {
|
|
79
|
+
constructor(e) {
|
|
80
|
+
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
81
|
+
}
|
|
82
|
+
getRegExp(e) {
|
|
83
|
+
const t = this.regExpMap.get(e);
|
|
84
|
+
if (t !== void 0)
|
|
85
|
+
return t;
|
|
86
|
+
const i = new RegExp(e);
|
|
87
|
+
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const Ke = [" ", ",", "?", "!", ";"], Ae = new Ve(20), Ue = (o, e, t) => {
|
|
91
|
+
e = e || "", t = t || "";
|
|
92
|
+
const i = Ke.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
|
|
93
|
+
if (i.length === 0) return !0;
|
|
94
|
+
const s = Ae.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
|
|
95
|
+
let n = !s.test(o);
|
|
96
|
+
if (!n) {
|
|
97
|
+
const r = o.indexOf(t);
|
|
98
|
+
r > 0 && !s.test(o.substring(0, r)) && (n = !0);
|
|
99
|
+
}
|
|
100
|
+
return n;
|
|
101
|
+
}, q = (o, e, t = ".") => {
|
|
102
|
+
if (!o) return;
|
|
103
|
+
if (o[e])
|
|
104
|
+
return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
|
|
105
|
+
const i = e.split(t);
|
|
106
|
+
let s = o;
|
|
107
|
+
for (let n = 0; n < i.length; ) {
|
|
108
|
+
if (!s || typeof s != "object")
|
|
109
|
+
return;
|
|
110
|
+
let r, a = "";
|
|
111
|
+
for (let u = n; u < i.length; ++u)
|
|
112
|
+
if (u !== n && (a += t), a += i[u], r = s[a], r !== void 0) {
|
|
113
|
+
if (["string", "number", "boolean"].indexOf(typeof r) > -1 && u < i.length - 1)
|
|
114
|
+
continue;
|
|
115
|
+
n += u - n + 1;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
s = r;
|
|
119
|
+
}
|
|
120
|
+
return s;
|
|
121
|
+
}, B = (o) => o == null ? void 0 : o.replace("_", "-"), He = {
|
|
122
|
+
type: "logger",
|
|
123
|
+
log(o) {
|
|
124
|
+
this.output("log", o);
|
|
125
|
+
},
|
|
126
|
+
warn(o) {
|
|
127
|
+
this.output("warn", o);
|
|
128
|
+
},
|
|
129
|
+
error(o) {
|
|
130
|
+
this.output("error", o);
|
|
131
|
+
},
|
|
132
|
+
output(o, e) {
|
|
133
|
+
var t, i;
|
|
134
|
+
(i = (t = console == null ? void 0 : console[o]) == null ? void 0 : t.apply) == null || i.call(t, console, e);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
class _ {
|
|
138
|
+
constructor(e, t = {}) {
|
|
139
|
+
this.init(e, t);
|
|
140
|
+
}
|
|
141
|
+
init(e, t = {}) {
|
|
142
|
+
this.prefix = t.prefix || "i18next:", this.logger = e || He, this.options = t, this.debug = t.debug;
|
|
143
|
+
}
|
|
144
|
+
log(...e) {
|
|
145
|
+
return this.forward(e, "log", "", !0);
|
|
146
|
+
}
|
|
147
|
+
warn(...e) {
|
|
148
|
+
return this.forward(e, "warn", "", !0);
|
|
149
|
+
}
|
|
150
|
+
error(...e) {
|
|
151
|
+
return this.forward(e, "error", "");
|
|
152
|
+
}
|
|
153
|
+
deprecate(...e) {
|
|
154
|
+
return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
|
|
155
|
+
}
|
|
156
|
+
forward(e, t, i, s) {
|
|
157
|
+
return s && !this.debug ? null : (p(e[0]) && (e[0] = `${i}${this.prefix} ${e[0]}`), this.logger[t](e));
|
|
158
|
+
}
|
|
159
|
+
create(e) {
|
|
160
|
+
return new _(this.logger, d({
|
|
161
|
+
prefix: `${this.prefix}:${e}:`
|
|
162
|
+
}, this.options));
|
|
163
|
+
}
|
|
164
|
+
clone(e) {
|
|
165
|
+
return e = e || this.options, e.prefix = e.prefix || this.prefix, new _(this.logger, e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
var k = new _();
|
|
169
|
+
class G {
|
|
170
|
+
constructor() {
|
|
171
|
+
this.observers = {};
|
|
172
|
+
}
|
|
173
|
+
on(e, t) {
|
|
174
|
+
return e.split(" ").forEach((i) => {
|
|
175
|
+
this.observers[i] || (this.observers[i] = /* @__PURE__ */ new Map());
|
|
176
|
+
const s = this.observers[i].get(t) || 0;
|
|
177
|
+
this.observers[i].set(t, s + 1);
|
|
178
|
+
}), this;
|
|
179
|
+
}
|
|
180
|
+
off(e, t) {
|
|
181
|
+
if (this.observers[e]) {
|
|
182
|
+
if (!t) {
|
|
183
|
+
delete this.observers[e];
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.observers[e].delete(t);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
emit(e, ...t) {
|
|
190
|
+
this.observers[e] && Array.from(this.observers[e].entries()).forEach(([s, n]) => {
|
|
191
|
+
for (let r = 0; r < n; r++)
|
|
192
|
+
s(...t);
|
|
193
|
+
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([s, n]) => {
|
|
194
|
+
for (let r = 0; r < n; r++)
|
|
195
|
+
s.apply(s, [e, ...t]);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
class he extends G {
|
|
200
|
+
constructor(e, t = {
|
|
201
|
+
ns: ["translation"],
|
|
202
|
+
defaultNS: "translation"
|
|
203
|
+
}) {
|
|
204
|
+
super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
|
|
205
|
+
}
|
|
206
|
+
addNamespaces(e) {
|
|
207
|
+
this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
|
|
208
|
+
}
|
|
209
|
+
removeNamespaces(e) {
|
|
210
|
+
const t = this.options.ns.indexOf(e);
|
|
211
|
+
t > -1 && this.options.ns.splice(t, 1);
|
|
212
|
+
}
|
|
213
|
+
getResource(e, t, i, s = {}) {
|
|
214
|
+
var l, h;
|
|
215
|
+
const n = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, r = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
216
|
+
let a;
|
|
217
|
+
e.indexOf(".") > -1 ? a = e.split(".") : (a = [e, t], i && (Array.isArray(i) ? a.push(...i) : p(i) && n ? a.push(...i.split(n)) : a.push(i)));
|
|
218
|
+
const u = Y(this.data, a);
|
|
219
|
+
return !u && !t && !i && e.indexOf(".") > -1 && (e = a[0], t = a[1], i = a.slice(2).join(".")), u || !r || !p(i) ? u : q((h = (l = this.data) == null ? void 0 : l[e]) == null ? void 0 : h[t], i, n);
|
|
220
|
+
}
|
|
221
|
+
addResource(e, t, i, s, n = {
|
|
222
|
+
silent: !1
|
|
223
|
+
}) {
|
|
224
|
+
const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator;
|
|
225
|
+
let a = [e, t];
|
|
226
|
+
i && (a = a.concat(r ? i.split(r) : i)), e.indexOf(".") > -1 && (a = e.split("."), s = t, t = a[1]), this.addNamespaces(t), fe(this.data, a, s), n.silent || this.emit("added", e, t, i, s);
|
|
227
|
+
}
|
|
228
|
+
addResources(e, t, i, s = {
|
|
229
|
+
silent: !1
|
|
230
|
+
}) {
|
|
231
|
+
for (const n in i)
|
|
232
|
+
(p(i[n]) || Array.isArray(i[n])) && this.addResource(e, t, n, i[n], {
|
|
233
|
+
silent: !0
|
|
234
|
+
});
|
|
235
|
+
s.silent || this.emit("added", e, t, i);
|
|
236
|
+
}
|
|
237
|
+
addResourceBundle(e, t, i, s, n, r = {
|
|
238
|
+
silent: !1,
|
|
239
|
+
skipCopy: !1
|
|
240
|
+
}) {
|
|
241
|
+
let a = [e, t];
|
|
242
|
+
e.indexOf(".") > -1 && (a = e.split("."), s = i, i = t, t = a[1]), this.addNamespaces(t);
|
|
243
|
+
let u = Y(this.data, a) || {};
|
|
244
|
+
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ? be(u, i, n) : u = d(d({}, u), i), fe(this.data, a, u), r.silent || this.emit("added", e, t, i);
|
|
245
|
+
}
|
|
246
|
+
removeResourceBundle(e, t) {
|
|
247
|
+
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
248
|
+
}
|
|
249
|
+
hasResourceBundle(e, t) {
|
|
250
|
+
return this.getResource(e, t) !== void 0;
|
|
251
|
+
}
|
|
252
|
+
getResourceBundle(e, t) {
|
|
253
|
+
return t || (t = this.options.defaultNS), this.getResource(e, t);
|
|
254
|
+
}
|
|
255
|
+
getDataByLanguage(e) {
|
|
256
|
+
return this.data[e];
|
|
257
|
+
}
|
|
258
|
+
hasLanguageSomeTranslations(e) {
|
|
259
|
+
const t = this.getDataByLanguage(e);
|
|
260
|
+
return !!(t && Object.keys(t) || []).find((s) => t[s] && Object.keys(t[s]).length > 0);
|
|
261
|
+
}
|
|
262
|
+
toJSON() {
|
|
263
|
+
return this.data;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var Le = {
|
|
267
|
+
processors: {},
|
|
268
|
+
addPostProcessor(o) {
|
|
269
|
+
this.processors[o.name] = o;
|
|
270
|
+
},
|
|
271
|
+
handle(o, e, t, i, s) {
|
|
272
|
+
return o.forEach((n) => {
|
|
273
|
+
var r, a;
|
|
274
|
+
e = (a = (r = this.processors[n]) == null ? void 0 : r.process(e, t, i, s)) != null ? a : e;
|
|
275
|
+
}), e;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const we = Symbol("i18next/PATH_KEY");
|
|
279
|
+
function Me() {
|
|
280
|
+
const o = [], e = /* @__PURE__ */ Object.create(null);
|
|
281
|
+
let t;
|
|
282
|
+
return e.get = (i, s) => {
|
|
283
|
+
var n;
|
|
284
|
+
return (n = t == null ? void 0 : t.revoke) == null || n.call(t), s === we ? o : (o.push(s), t = Proxy.revocable(i, e), t.proxy);
|
|
285
|
+
}, Proxy.revocable(/* @__PURE__ */ Object.create(null), e).proxy;
|
|
286
|
+
}
|
|
287
|
+
function ee(o, e) {
|
|
288
|
+
var i;
|
|
289
|
+
const {
|
|
290
|
+
[we]: t
|
|
291
|
+
} = o(Me());
|
|
292
|
+
return t.join((i = e == null ? void 0 : e.keySeparator) != null ? i : ".");
|
|
293
|
+
}
|
|
294
|
+
const ce = {}, Z = (o) => !p(o) && typeof o != "boolean" && typeof o != "number";
|
|
295
|
+
class Q extends G {
|
|
296
|
+
constructor(e, t = {}) {
|
|
297
|
+
super(), Fe(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = k.create("translator");
|
|
298
|
+
}
|
|
299
|
+
changeLanguage(e) {
|
|
300
|
+
e && (this.language = e);
|
|
301
|
+
}
|
|
302
|
+
exists(e, t = {
|
|
303
|
+
interpolation: {}
|
|
304
|
+
}) {
|
|
305
|
+
const i = d({}, t);
|
|
306
|
+
if (e == null) return !1;
|
|
307
|
+
const s = this.resolve(e, i);
|
|
308
|
+
if ((s == null ? void 0 : s.res) === void 0) return !1;
|
|
309
|
+
const n = Z(s.res);
|
|
310
|
+
return !(i.returnObjects === !1 && n);
|
|
311
|
+
}
|
|
312
|
+
extractFromKey(e, t) {
|
|
313
|
+
let i = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
|
|
314
|
+
i === void 0 && (i = ":");
|
|
315
|
+
const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
316
|
+
let n = t.ns || this.options.defaultNS || [];
|
|
317
|
+
const r = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !Ue(e, i, s);
|
|
318
|
+
if (r && !a) {
|
|
319
|
+
const u = e.match(this.interpolator.nestingRegexp);
|
|
320
|
+
if (u && u.length > 0)
|
|
321
|
+
return {
|
|
322
|
+
key: e,
|
|
323
|
+
namespaces: p(n) ? [n] : n
|
|
324
|
+
};
|
|
325
|
+
const l = e.split(i);
|
|
326
|
+
(i !== s || i === s && this.options.ns.indexOf(l[0]) > -1) && (n = l.shift()), e = l.join(s);
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
key: e,
|
|
330
|
+
namespaces: p(n) ? [n] : n
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
translate(e, t, i) {
|
|
334
|
+
let s = typeof t == "object" ? d({}, t) : t;
|
|
335
|
+
if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof s == "object" && (s = d({}, s)), s || (s = {}), e == null) return "";
|
|
336
|
+
typeof e == "function" && (e = ee(e, d(d({}, this.options), s))), Array.isArray(e) || (e = [String(e)]);
|
|
337
|
+
const n = s.returnDetails !== void 0 ? s.returnDetails : this.options.returnDetails, r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, {
|
|
338
|
+
key: a,
|
|
339
|
+
namespaces: u
|
|
340
|
+
} = this.extractFromKey(e[e.length - 1], s), l = u[u.length - 1];
|
|
341
|
+
let h = s.nsSeparator !== void 0 ? s.nsSeparator : this.options.nsSeparator;
|
|
342
|
+
h === void 0 && (h = ":");
|
|
343
|
+
const f = s.lng || this.language, m = s.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
344
|
+
if ((f == null ? void 0 : f.toLowerCase()) === "cimode")
|
|
345
|
+
return m ? n ? {
|
|
346
|
+
res: `${l}${h}${a}`,
|
|
347
|
+
usedKey: a,
|
|
348
|
+
exactUsedKey: a,
|
|
349
|
+
usedLng: f,
|
|
350
|
+
usedNS: l,
|
|
351
|
+
usedParams: this.getUsedParamsDetails(s)
|
|
352
|
+
} : `${l}${h}${a}` : n ? {
|
|
353
|
+
res: a,
|
|
354
|
+
usedKey: a,
|
|
355
|
+
exactUsedKey: a,
|
|
356
|
+
usedLng: f,
|
|
357
|
+
usedNS: l,
|
|
358
|
+
usedParams: this.getUsedParamsDetails(s)
|
|
359
|
+
} : a;
|
|
360
|
+
const g = this.resolve(e, s);
|
|
361
|
+
let c = g == null ? void 0 : g.res;
|
|
362
|
+
const x = (g == null ? void 0 : g.usedKey) || a, y = (g == null ? void 0 : g.exactUsedKey) || a, R = ["[object Number]", "[object Function]", "[object RegExp]"], C = s.joinArrays !== void 0 ? s.joinArrays : this.options.joinArrays, T = !this.i18nFormat || this.i18nFormat.handleAsObject, O = s.count !== void 0 && !p(s.count), F = Q.hasDefaultValue(s), z = O ? this.pluralResolver.getSuffix(f, s.count, s) : "", j = s.ordinal && O ? this.pluralResolver.getSuffix(f, s.count, {
|
|
363
|
+
ordinal: !1
|
|
364
|
+
}) : "", V = O && !s.ordinal && s.count === 0, w = V && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${z}`] || s[`defaultValue${j}`] || s.defaultValue;
|
|
365
|
+
let S = c;
|
|
366
|
+
T && !c && F && (S = w);
|
|
367
|
+
const ve = Z(S), Ce = Object.prototype.toString.apply(S);
|
|
368
|
+
if (T && S && ve && R.indexOf(Ce) < 0 && !(p(C) && Array.isArray(S))) {
|
|
369
|
+
if (!s.returnObjects && !this.options.returnObjects) {
|
|
370
|
+
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
371
|
+
const $ = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, S, b(d({}, s), {
|
|
372
|
+
ns: u
|
|
373
|
+
})) : `key '${a} (${this.language})' returned an object instead of string.`;
|
|
374
|
+
return n ? (g.res = $, g.usedParams = this.getUsedParamsDetails(s), g) : $;
|
|
375
|
+
}
|
|
376
|
+
if (r) {
|
|
377
|
+
const $ = Array.isArray(S), P = $ ? [] : {}, te = $ ? y : x;
|
|
378
|
+
for (const N in S)
|
|
379
|
+
if (Object.prototype.hasOwnProperty.call(S, N)) {
|
|
380
|
+
const E = `${te}${r}${N}`;
|
|
381
|
+
F && !c ? P[N] = this.translate(E, b(d({}, s), {
|
|
382
|
+
defaultValue: Z(w) ? w[N] : void 0,
|
|
383
|
+
joinArrays: !1,
|
|
384
|
+
ns: u
|
|
385
|
+
})) : P[N] = this.translate(E, b(d({}, s), {
|
|
386
|
+
joinArrays: !1,
|
|
387
|
+
ns: u
|
|
388
|
+
})), P[N] === E && (P[N] = S[N]);
|
|
389
|
+
}
|
|
390
|
+
c = P;
|
|
391
|
+
}
|
|
392
|
+
} else if (T && p(C) && Array.isArray(c))
|
|
393
|
+
c = c.join(C), c && (c = this.extendTranslation(c, e, s, i));
|
|
394
|
+
else {
|
|
395
|
+
let $ = !1, P = !1;
|
|
396
|
+
!this.isValidLookup(c) && F && ($ = !0, c = w), this.isValidLookup(c) || (P = !0, c = a);
|
|
397
|
+
const N = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && P ? void 0 : c, E = F && w !== c && this.options.updateMissing;
|
|
398
|
+
if (P || $ || E) {
|
|
399
|
+
if (this.logger.log(E ? "updateKey" : "missingKey", f, l, a, E ? w : c), r) {
|
|
400
|
+
const v = this.resolve(a, b(d({}, s), {
|
|
401
|
+
keySeparator: !1
|
|
402
|
+
}));
|
|
403
|
+
v && v.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
404
|
+
}
|
|
405
|
+
let K = [];
|
|
406
|
+
const J = this.languageUtils.getFallbackCodes(this.options.fallbackLng, s.lng || this.language);
|
|
407
|
+
if (this.options.saveMissingTo === "fallback" && J && J[0])
|
|
408
|
+
for (let v = 0; v < J.length; v++)
|
|
409
|
+
K.push(J[v]);
|
|
410
|
+
else this.options.saveMissingTo === "all" ? K = this.languageUtils.toResolveHierarchy(s.lng || this.language) : K.push(s.lng || this.language);
|
|
411
|
+
const se = (v, I, A) => {
|
|
412
|
+
var ne;
|
|
413
|
+
const ie = F && A !== c ? A : N;
|
|
414
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, l, I, ie, E, s) : (ne = this.backendConnector) != null && ne.saveMissing && this.backendConnector.saveMissing(v, l, I, ie, E, s), this.emit("missingKey", v, l, I, c);
|
|
415
|
+
};
|
|
416
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && O ? K.forEach((v) => {
|
|
417
|
+
const I = this.pluralResolver.getSuffixes(v, s);
|
|
418
|
+
V && s[`defaultValue${this.options.pluralSeparator}zero`] && I.indexOf(`${this.options.pluralSeparator}zero`) < 0 && I.push(`${this.options.pluralSeparator}zero`), I.forEach((A) => {
|
|
419
|
+
se([v], a + A, s[`defaultValue${A}`] || w);
|
|
420
|
+
});
|
|
421
|
+
}) : se(K, a, w));
|
|
422
|
+
}
|
|
423
|
+
c = this.extendTranslation(c, e, s, g, i), P && c === a && this.options.appendNamespaceToMissingKey && (c = `${l}${h}${a}`), (P || $) && this.options.parseMissingKeyHandler && (c = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${l}${h}${a}` : a, $ ? c : void 0, s));
|
|
424
|
+
}
|
|
425
|
+
return n ? (g.res = c, g.usedParams = this.getUsedParamsDetails(s), g) : c;
|
|
426
|
+
}
|
|
427
|
+
extendTranslation(e, t, i, s, n) {
|
|
428
|
+
var u, l;
|
|
429
|
+
if ((u = this.i18nFormat) != null && u.parse)
|
|
430
|
+
e = this.i18nFormat.parse(e, d(d({}, this.options.interpolation.defaultVariables), i), i.lng || this.language || s.usedLng, s.usedNS, s.usedKey, {
|
|
431
|
+
resolved: s
|
|
432
|
+
});
|
|
433
|
+
else if (!i.skipInterpolation) {
|
|
434
|
+
i.interpolation && this.interpolator.init(b(d({}, i), {
|
|
435
|
+
interpolation: d(d({}, this.options.interpolation), i.interpolation)
|
|
436
|
+
}));
|
|
437
|
+
const h = p(e) && (((l = i == null ? void 0 : i.interpolation) == null ? void 0 : l.skipOnVariables) !== void 0 ? i.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
438
|
+
let f;
|
|
439
|
+
if (h) {
|
|
440
|
+
const g = e.match(this.interpolator.nestingRegexp);
|
|
441
|
+
f = g && g.length;
|
|
442
|
+
}
|
|
443
|
+
let m = i.replace && !p(i.replace) ? i.replace : i;
|
|
444
|
+
if (this.options.interpolation.defaultVariables && (m = d(d({}, this.options.interpolation.defaultVariables), m)), e = this.interpolator.interpolate(e, m, i.lng || this.language || s.usedLng, i), h) {
|
|
445
|
+
const g = e.match(this.interpolator.nestingRegexp), c = g && g.length;
|
|
446
|
+
f < c && (i.nest = !1);
|
|
447
|
+
}
|
|
448
|
+
!i.lng && s && s.res && (i.lng = this.language || s.usedLng), i.nest !== !1 && (e = this.interpolator.nest(e, (...g) => (n == null ? void 0 : n[0]) === g[0] && !i.context ? (this.logger.warn(`It seems you are nesting recursively key: ${g[0]} in key: ${t[0]}`), null) : this.translate(...g, t), i)), i.interpolation && this.interpolator.reset();
|
|
449
|
+
}
|
|
450
|
+
const r = i.postProcess || this.options.postProcess, a = p(r) ? [r] : r;
|
|
451
|
+
return e != null && (a != null && a.length) && i.applyPostProcessor !== !1 && (e = Le.handle(a, e, t, this.options && this.options.postProcessPassResolved ? d({
|
|
452
|
+
i18nResolved: b(d({}, s), {
|
|
453
|
+
usedParams: this.getUsedParamsDetails(i)
|
|
454
|
+
})
|
|
455
|
+
}, i) : i, this)), e;
|
|
456
|
+
}
|
|
457
|
+
resolve(e, t = {}) {
|
|
458
|
+
let i, s, n, r, a;
|
|
459
|
+
return p(e) && (e = [e]), e.forEach((u) => {
|
|
460
|
+
if (this.isValidLookup(i)) return;
|
|
461
|
+
const l = this.extractFromKey(u, t), h = l.key;
|
|
462
|
+
s = h;
|
|
463
|
+
let f = l.namespaces;
|
|
464
|
+
this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
|
|
465
|
+
const m = t.count !== void 0 && !p(t.count), g = m && !t.ordinal && t.count === 0, c = t.context !== void 0 && (p(t.context) || typeof t.context == "number") && t.context !== "", x = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
|
|
466
|
+
f.forEach((y) => {
|
|
467
|
+
var R, C;
|
|
468
|
+
this.isValidLookup(i) || (a = y, !ce[`${x[0]}-${y}`] && ((R = this.utils) != null && R.hasLoadedNamespace) && !((C = this.utils) != null && C.hasLoadedNamespace(a)) && (ce[`${x[0]}-${y}`] = !0, this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), x.forEach((T) => {
|
|
469
|
+
var z;
|
|
470
|
+
if (this.isValidLookup(i)) return;
|
|
471
|
+
r = T;
|
|
472
|
+
const O = [h];
|
|
473
|
+
if ((z = this.i18nFormat) != null && z.addLookupKeys)
|
|
474
|
+
this.i18nFormat.addLookupKeys(O, h, T, y, t);
|
|
475
|
+
else {
|
|
476
|
+
let j;
|
|
477
|
+
m && (j = this.pluralResolver.getSuffix(T, t.count, t));
|
|
478
|
+
const V = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
479
|
+
if (m && (t.ordinal && j.indexOf(w) === 0 && O.push(h + j.replace(w, this.options.pluralSeparator)), O.push(h + j), g && O.push(h + V)), c) {
|
|
480
|
+
const S = `${h}${this.options.contextSeparator || "_"}${t.context}`;
|
|
481
|
+
O.push(S), m && (t.ordinal && j.indexOf(w) === 0 && O.push(S + j.replace(w, this.options.pluralSeparator)), O.push(S + j), g && O.push(S + V));
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
let F;
|
|
485
|
+
for (; F = O.pop(); )
|
|
486
|
+
this.isValidLookup(i) || (n = F, i = this.getResource(T, y, F, t));
|
|
487
|
+
}));
|
|
488
|
+
});
|
|
489
|
+
}), {
|
|
490
|
+
res: i,
|
|
491
|
+
usedKey: s,
|
|
492
|
+
exactUsedKey: n,
|
|
493
|
+
usedLng: r,
|
|
494
|
+
usedNS: a
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
isValidLookup(e) {
|
|
498
|
+
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
|
|
499
|
+
}
|
|
500
|
+
getResource(e, t, i, s = {}) {
|
|
501
|
+
var n;
|
|
502
|
+
return (n = this.i18nFormat) != null && n.getResource ? this.i18nFormat.getResource(e, t, i, s) : this.resourceStore.getResource(e, t, i, s);
|
|
503
|
+
}
|
|
504
|
+
getUsedParamsDetails(e = {}) {
|
|
505
|
+
const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], i = e.replace && !p(e.replace);
|
|
506
|
+
let s = i ? e.replace : e;
|
|
507
|
+
if (i && typeof e.count != "undefined" && (s.count = e.count), this.options.interpolation.defaultVariables && (s = d(d({}, this.options.interpolation.defaultVariables), s)), !i) {
|
|
508
|
+
s = d({}, s);
|
|
509
|
+
for (const n of t)
|
|
510
|
+
delete s[n];
|
|
511
|
+
}
|
|
512
|
+
return s;
|
|
513
|
+
}
|
|
514
|
+
static hasDefaultValue(e) {
|
|
515
|
+
const t = "defaultValue";
|
|
516
|
+
for (const i in e)
|
|
517
|
+
if (Object.prototype.hasOwnProperty.call(e, i) && t === i.substring(0, t.length) && e[i] !== void 0)
|
|
518
|
+
return !0;
|
|
519
|
+
return !1;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
class de {
|
|
523
|
+
constructor(e) {
|
|
524
|
+
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = k.create("languageUtils");
|
|
525
|
+
}
|
|
526
|
+
getScriptPartFromCode(e) {
|
|
527
|
+
if (e = B(e), !e || e.indexOf("-") < 0) return null;
|
|
528
|
+
const t = e.split("-");
|
|
529
|
+
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
|
|
530
|
+
}
|
|
531
|
+
getLanguagePartFromCode(e) {
|
|
532
|
+
if (e = B(e), !e || e.indexOf("-") < 0) return e;
|
|
533
|
+
const t = e.split("-");
|
|
534
|
+
return this.formatLanguageCode(t[0]);
|
|
535
|
+
}
|
|
536
|
+
formatLanguageCode(e) {
|
|
537
|
+
if (p(e) && e.indexOf("-") > -1) {
|
|
538
|
+
let t;
|
|
539
|
+
try {
|
|
540
|
+
t = Intl.getCanonicalLocales(e)[0];
|
|
541
|
+
} catch (i) {
|
|
542
|
+
}
|
|
543
|
+
return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
|
|
544
|
+
}
|
|
545
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
|
|
546
|
+
}
|
|
547
|
+
isSupportedCode(e) {
|
|
548
|
+
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
|
|
549
|
+
}
|
|
550
|
+
getBestMatchFromCodes(e) {
|
|
551
|
+
if (!e) return null;
|
|
552
|
+
let t;
|
|
553
|
+
return e.forEach((i) => {
|
|
554
|
+
if (t) return;
|
|
555
|
+
const s = this.formatLanguageCode(i);
|
|
556
|
+
(!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
|
|
557
|
+
}), !t && this.options.supportedLngs && e.forEach((i) => {
|
|
558
|
+
if (t) return;
|
|
559
|
+
const s = this.getScriptPartFromCode(i);
|
|
560
|
+
if (this.isSupportedCode(s)) return t = s;
|
|
561
|
+
const n = this.getLanguagePartFromCode(i);
|
|
562
|
+
if (this.isSupportedCode(n)) return t = n;
|
|
563
|
+
t = this.options.supportedLngs.find((r) => {
|
|
564
|
+
if (r === n) return r;
|
|
565
|
+
if (!(r.indexOf("-") < 0 && n.indexOf("-") < 0) && (r.indexOf("-") > 0 && n.indexOf("-") < 0 && r.substring(0, r.indexOf("-")) === n || r.indexOf(n) === 0 && n.length > 1))
|
|
566
|
+
return r;
|
|
567
|
+
});
|
|
568
|
+
}), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
|
|
569
|
+
}
|
|
570
|
+
getFallbackCodes(e, t) {
|
|
571
|
+
if (!e) return [];
|
|
572
|
+
if (typeof e == "function" && (e = e(t)), p(e) && (e = [e]), Array.isArray(e)) return e;
|
|
573
|
+
if (!t) return e.default || [];
|
|
574
|
+
let i = e[t];
|
|
575
|
+
return i || (i = e[this.getScriptPartFromCode(t)]), i || (i = e[this.formatLanguageCode(t)]), i || (i = e[this.getLanguagePartFromCode(t)]), i || (i = e.default), i || [];
|
|
576
|
+
}
|
|
577
|
+
toResolveHierarchy(e, t) {
|
|
578
|
+
const i = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), s = [], n = (r) => {
|
|
579
|
+
r && (this.isSupportedCode(r) ? s.push(r) : this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`));
|
|
580
|
+
};
|
|
581
|
+
return p(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && n(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && n(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && n(this.getLanguagePartFromCode(e))) : p(e) && n(this.formatLanguageCode(e)), i.forEach((r) => {
|
|
582
|
+
s.indexOf(r) < 0 && n(this.formatLanguageCode(r));
|
|
583
|
+
}), s;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const ge = {
|
|
587
|
+
zero: 0,
|
|
588
|
+
one: 1,
|
|
589
|
+
two: 2,
|
|
590
|
+
few: 3,
|
|
591
|
+
many: 4,
|
|
592
|
+
other: 5
|
|
593
|
+
}, pe = {
|
|
594
|
+
select: (o) => o === 1 ? "one" : "other",
|
|
595
|
+
resolvedOptions: () => ({
|
|
596
|
+
pluralCategories: ["one", "other"]
|
|
597
|
+
})
|
|
598
|
+
};
|
|
599
|
+
class Be {
|
|
600
|
+
constructor(e, t = {}) {
|
|
601
|
+
this.languageUtils = e, this.options = t, this.logger = k.create("pluralResolver"), this.pluralRulesCache = {};
|
|
602
|
+
}
|
|
603
|
+
addRule(e, t) {
|
|
604
|
+
this.rules[e] = t;
|
|
605
|
+
}
|
|
606
|
+
clearCache() {
|
|
607
|
+
this.pluralRulesCache = {};
|
|
608
|
+
}
|
|
609
|
+
getRule(e, t = {}) {
|
|
610
|
+
const i = B(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
|
|
611
|
+
cleanedCode: i,
|
|
612
|
+
type: s
|
|
613
|
+
});
|
|
614
|
+
if (n in this.pluralRulesCache)
|
|
615
|
+
return this.pluralRulesCache[n];
|
|
616
|
+
let r;
|
|
617
|
+
try {
|
|
618
|
+
r = new Intl.PluralRules(i, {
|
|
619
|
+
type: s
|
|
620
|
+
});
|
|
621
|
+
} catch (a) {
|
|
622
|
+
if (!Intl)
|
|
623
|
+
return this.logger.error("No Intl support, please use an Intl polyfill!"), pe;
|
|
624
|
+
if (!e.match(/-|_/)) return pe;
|
|
625
|
+
const u = this.languageUtils.getLanguagePartFromCode(e);
|
|
626
|
+
r = this.getRule(u, t);
|
|
627
|
+
}
|
|
628
|
+
return this.pluralRulesCache[n] = r, r;
|
|
629
|
+
}
|
|
630
|
+
needsPlural(e, t = {}) {
|
|
631
|
+
let i = this.getRule(e, t);
|
|
632
|
+
return i || (i = this.getRule("dev", t)), (i == null ? void 0 : i.resolvedOptions().pluralCategories.length) > 1;
|
|
633
|
+
}
|
|
634
|
+
getPluralFormsOfKey(e, t, i = {}) {
|
|
635
|
+
return this.getSuffixes(e, i).map((s) => `${t}${s}`);
|
|
636
|
+
}
|
|
637
|
+
getSuffixes(e, t = {}) {
|
|
638
|
+
let i = this.getRule(e, t);
|
|
639
|
+
return i || (i = this.getRule("dev", t)), i ? i.resolvedOptions().pluralCategories.sort((s, n) => ge[s] - ge[n]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : [];
|
|
640
|
+
}
|
|
641
|
+
getSuffix(e, t, i = {}) {
|
|
642
|
+
const s = this.getRule(e, i);
|
|
643
|
+
return s ? `${this.options.prepend}${i.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, i));
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const me = (o, e, t, i = ".", s = !0) => {
|
|
647
|
+
let n = Te(o, e, t);
|
|
648
|
+
return !n && s && p(t) && (n = q(o, t, i), n === void 0 && (n = q(e, t, i))), n;
|
|
649
|
+
}, X = (o) => o.replace(/\$/g, "$$$$");
|
|
650
|
+
class xe {
|
|
651
|
+
constructor(e = {}) {
|
|
652
|
+
var t;
|
|
653
|
+
this.logger = k.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((i) => i), this.init(e);
|
|
654
|
+
}
|
|
655
|
+
init(e = {}) {
|
|
656
|
+
e.interpolation || (e.interpolation = {
|
|
657
|
+
escapeValue: !0
|
|
658
|
+
});
|
|
659
|
+
const {
|
|
660
|
+
escape: t,
|
|
661
|
+
escapeValue: i,
|
|
662
|
+
useRawValueToEscape: s,
|
|
663
|
+
prefix: n,
|
|
664
|
+
prefixEscaped: r,
|
|
665
|
+
suffix: a,
|
|
666
|
+
suffixEscaped: u,
|
|
667
|
+
formatSeparator: l,
|
|
668
|
+
unescapeSuffix: h,
|
|
669
|
+
unescapePrefix: f,
|
|
670
|
+
nestingPrefix: m,
|
|
671
|
+
nestingPrefixEscaped: g,
|
|
672
|
+
nestingSuffix: c,
|
|
673
|
+
nestingSuffixEscaped: x,
|
|
674
|
+
nestingOptionsSeparator: y,
|
|
675
|
+
maxReplaces: R,
|
|
676
|
+
alwaysFormat: C
|
|
677
|
+
} = e.interpolation;
|
|
678
|
+
this.escape = t !== void 0 ? t : De, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = n ? D(n) : r || "{{", this.suffix = a ? D(a) : u || "}}", this.formatSeparator = l || ",", this.unescapePrefix = h ? "" : f || "-", this.unescapeSuffix = this.unescapePrefix ? "" : h || "", this.nestingPrefix = m ? D(m) : g || D("$t("), this.nestingSuffix = c ? D(c) : x || D(")"), this.nestingOptionsSeparator = y || ",", this.maxReplaces = R || 1e3, this.alwaysFormat = C !== void 0 ? C : !1, this.resetRegExp();
|
|
679
|
+
}
|
|
680
|
+
reset() {
|
|
681
|
+
this.options && this.init(this.options);
|
|
682
|
+
}
|
|
683
|
+
resetRegExp() {
|
|
684
|
+
const e = (t, i) => (t == null ? void 0 : t.source) === i ? (t.lastIndex = 0, t) : new RegExp(i, "g");
|
|
685
|
+
this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
686
|
+
}
|
|
687
|
+
interpolate(e, t, i, s) {
|
|
688
|
+
var g;
|
|
689
|
+
let n, r, a;
|
|
690
|
+
const u = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, l = (c) => {
|
|
691
|
+
if (c.indexOf(this.formatSeparator) < 0) {
|
|
692
|
+
const C = me(t, u, c, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
693
|
+
return this.alwaysFormat ? this.format(C, void 0, i, b(d(d({}, s), t), {
|
|
694
|
+
interpolationkey: c
|
|
695
|
+
})) : C;
|
|
696
|
+
}
|
|
697
|
+
const x = c.split(this.formatSeparator), y = x.shift().trim(), R = x.join(this.formatSeparator).trim();
|
|
698
|
+
return this.format(me(t, u, y, this.options.keySeparator, this.options.ignoreJSONStructure), R, i, b(d(d({}, s), t), {
|
|
699
|
+
interpolationkey: y
|
|
700
|
+
}));
|
|
701
|
+
};
|
|
702
|
+
this.resetRegExp();
|
|
703
|
+
const h = (s == null ? void 0 : s.missingInterpolationHandler) || this.options.missingInterpolationHandler, f = ((g = s == null ? void 0 : s.interpolation) == null ? void 0 : g.skipOnVariables) !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
704
|
+
return [{
|
|
705
|
+
regex: this.regexpUnescape,
|
|
706
|
+
safeValue: (c) => X(c)
|
|
707
|
+
}, {
|
|
708
|
+
regex: this.regexp,
|
|
709
|
+
safeValue: (c) => this.escapeValue ? X(this.escape(c)) : X(c)
|
|
710
|
+
}].forEach((c) => {
|
|
711
|
+
for (a = 0; n = c.regex.exec(e); ) {
|
|
712
|
+
const x = n[1].trim();
|
|
713
|
+
if (r = l(x), r === void 0)
|
|
714
|
+
if (typeof h == "function") {
|
|
715
|
+
const R = h(e, n, s);
|
|
716
|
+
r = p(R) ? R : "";
|
|
717
|
+
} else if (s && Object.prototype.hasOwnProperty.call(s, x))
|
|
718
|
+
r = "";
|
|
719
|
+
else if (f) {
|
|
720
|
+
r = n[0];
|
|
721
|
+
continue;
|
|
722
|
+
} else
|
|
723
|
+
this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), r = "";
|
|
724
|
+
else !p(r) && !this.useRawValueToEscape && (r = oe(r));
|
|
725
|
+
const y = c.safeValue(r);
|
|
726
|
+
if (e = e.replace(n[0], y), f ? (c.regex.lastIndex += r.length, c.regex.lastIndex -= n[0].length) : c.regex.lastIndex = 0, a++, a >= this.maxReplaces)
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
}), e;
|
|
730
|
+
}
|
|
731
|
+
nest(e, t, i = {}) {
|
|
732
|
+
let s, n, r;
|
|
733
|
+
const a = (u, l) => {
|
|
734
|
+
var x;
|
|
735
|
+
const h = this.nestingOptionsSeparator;
|
|
736
|
+
if (u.indexOf(h) < 0) return u;
|
|
737
|
+
const f = u.split(new RegExp(`${h}[ ]*{`));
|
|
738
|
+
let m = `{${f[1]}`;
|
|
739
|
+
u = f[0], m = this.interpolate(m, r);
|
|
740
|
+
const g = m.match(/'/g), c = m.match(/"/g);
|
|
741
|
+
(((x = g == null ? void 0 : g.length) != null ? x : 0) % 2 === 0 && !c || c.length % 2 !== 0) && (m = m.replace(/'/g, '"'));
|
|
742
|
+
try {
|
|
743
|
+
r = JSON.parse(m), l && (r = d(d({}, l), r));
|
|
744
|
+
} catch (y) {
|
|
745
|
+
return this.logger.warn(`failed parsing options string in nesting for key ${u}`, y), `${u}${h}${m}`;
|
|
746
|
+
}
|
|
747
|
+
return r.defaultValue && r.defaultValue.indexOf(this.prefix) > -1 && delete r.defaultValue, u;
|
|
748
|
+
};
|
|
749
|
+
for (; s = this.nestingRegexp.exec(e); ) {
|
|
750
|
+
let u = [];
|
|
751
|
+
r = d({}, i), r = r.replace && !p(r.replace) ? r.replace : r, r.applyPostProcessor = !1, delete r.defaultValue;
|
|
752
|
+
const l = /{.*}/.test(s[1]) ? s[1].lastIndexOf("}") + 1 : s[1].indexOf(this.formatSeparator);
|
|
753
|
+
if (l !== -1 && (u = s[1].slice(l).split(this.formatSeparator).map((h) => h.trim()).filter(Boolean), s[1] = s[1].slice(0, l)), n = t(a.call(this, s[1].trim(), r), r), n && s[0] === e && !p(n)) return n;
|
|
754
|
+
p(n) || (n = oe(n)), n || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), n = ""), u.length && (n = u.reduce((h, f) => this.format(h, f, i.lng, b(d({}, i), {
|
|
755
|
+
interpolationkey: s[1].trim()
|
|
756
|
+
})), n.trim())), e = e.replace(s[0], n), this.regexp.lastIndex = 0;
|
|
757
|
+
}
|
|
758
|
+
return e;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
const ze = (o) => {
|
|
762
|
+
let e = o.toLowerCase().trim();
|
|
763
|
+
const t = {};
|
|
764
|
+
if (o.indexOf("(") > -1) {
|
|
765
|
+
const i = o.split("(");
|
|
766
|
+
e = i[0].toLowerCase().trim();
|
|
767
|
+
const s = i[1].substring(0, i[1].length - 1);
|
|
768
|
+
e === "currency" && s.indexOf(":") < 0 ? t.currency || (t.currency = s.trim()) : e === "relativetime" && s.indexOf(":") < 0 ? t.range || (t.range = s.trim()) : s.split(";").forEach((r) => {
|
|
769
|
+
if (r) {
|
|
770
|
+
const [a, ...u] = r.split(":"), l = u.join(":").trim().replace(/^'+|'+$/g, ""), h = a.trim();
|
|
771
|
+
t[h] || (t[h] = l), l === "false" && (t[h] = !1), l === "true" && (t[h] = !0), isNaN(l) || (t[h] = parseInt(l, 10));
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
formatName: e,
|
|
777
|
+
formatOptions: t
|
|
778
|
+
};
|
|
779
|
+
}, ye = (o) => {
|
|
780
|
+
const e = {};
|
|
781
|
+
return (t, i, s) => {
|
|
782
|
+
let n = s;
|
|
783
|
+
s && s.interpolationkey && s.formatParams && s.formatParams[s.interpolationkey] && s[s.interpolationkey] && (n = b(d({}, n), {
|
|
784
|
+
[s.interpolationkey]: void 0
|
|
785
|
+
}));
|
|
786
|
+
const r = i + JSON.stringify(n);
|
|
787
|
+
let a = e[r];
|
|
788
|
+
return a || (a = o(B(i), s), e[r] = a), a(t);
|
|
789
|
+
};
|
|
790
|
+
}, Je = (o) => (e, t, i) => o(B(t), i)(e);
|
|
791
|
+
class We {
|
|
792
|
+
constructor(e = {}) {
|
|
793
|
+
this.logger = k.create("formatter"), this.options = e, this.init(e);
|
|
794
|
+
}
|
|
795
|
+
init(e, t = {
|
|
796
|
+
interpolation: {}
|
|
797
|
+
}) {
|
|
798
|
+
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
799
|
+
const i = t.cacheInBuiltFormats ? ye : Je;
|
|
800
|
+
this.formats = {
|
|
801
|
+
number: i((s, n) => {
|
|
802
|
+
const r = new Intl.NumberFormat(s, d({}, n));
|
|
803
|
+
return (a) => r.format(a);
|
|
804
|
+
}),
|
|
805
|
+
currency: i((s, n) => {
|
|
806
|
+
const r = new Intl.NumberFormat(s, b(d({}, n), {
|
|
807
|
+
style: "currency"
|
|
808
|
+
}));
|
|
809
|
+
return (a) => r.format(a);
|
|
810
|
+
}),
|
|
811
|
+
datetime: i((s, n) => {
|
|
812
|
+
const r = new Intl.DateTimeFormat(s, d({}, n));
|
|
813
|
+
return (a) => r.format(a);
|
|
814
|
+
}),
|
|
815
|
+
relativetime: i((s, n) => {
|
|
816
|
+
const r = new Intl.RelativeTimeFormat(s, d({}, n));
|
|
817
|
+
return (a) => r.format(a, n.range || "day");
|
|
818
|
+
}),
|
|
819
|
+
list: i((s, n) => {
|
|
820
|
+
const r = new Intl.ListFormat(s, d({}, n));
|
|
821
|
+
return (a) => r.format(a);
|
|
822
|
+
})
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
add(e, t) {
|
|
826
|
+
this.formats[e.toLowerCase().trim()] = t;
|
|
827
|
+
}
|
|
828
|
+
addCached(e, t) {
|
|
829
|
+
this.formats[e.toLowerCase().trim()] = ye(t);
|
|
830
|
+
}
|
|
831
|
+
format(e, t, i, s = {}) {
|
|
832
|
+
const n = t.split(this.formatSeparator);
|
|
833
|
+
if (n.length > 1 && n[0].indexOf("(") > 1 && n[0].indexOf(")") < 0 && n.find((a) => a.indexOf(")") > -1)) {
|
|
834
|
+
const a = n.findIndex((u) => u.indexOf(")") > -1);
|
|
835
|
+
n[0] = [n[0], ...n.splice(1, a)].join(this.formatSeparator);
|
|
836
|
+
}
|
|
837
|
+
return n.reduce((a, u) => {
|
|
838
|
+
var f;
|
|
839
|
+
const {
|
|
840
|
+
formatName: l,
|
|
841
|
+
formatOptions: h
|
|
842
|
+
} = ze(u);
|
|
843
|
+
if (this.formats[l]) {
|
|
844
|
+
let m = a;
|
|
845
|
+
try {
|
|
846
|
+
const g = ((f = s == null ? void 0 : s.formatParams) == null ? void 0 : f[s.interpolationkey]) || {}, c = g.locale || g.lng || s.locale || s.lng || i;
|
|
847
|
+
m = this.formats[l](a, c, d(d(d({}, h), s), g));
|
|
848
|
+
} catch (g) {
|
|
849
|
+
this.logger.warn(g);
|
|
850
|
+
}
|
|
851
|
+
return m;
|
|
852
|
+
} else
|
|
853
|
+
this.logger.warn(`there was no format function for ${l}`);
|
|
854
|
+
return a;
|
|
855
|
+
}, e);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
const Ye = (o, e) => {
|
|
859
|
+
o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
|
|
860
|
+
};
|
|
861
|
+
class _e extends G {
|
|
862
|
+
constructor(e, t, i, s = {}) {
|
|
863
|
+
var n, r;
|
|
864
|
+
super(), this.backend = e, this.store = t, this.services = i, this.languageUtils = i.languageUtils, this.options = s, this.logger = k.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = s.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = s.maxRetries >= 0 ? s.maxRetries : 5, this.retryTimeout = s.retryTimeout >= 1 ? s.retryTimeout : 350, this.state = {}, this.queue = [], (r = (n = this.backend) == null ? void 0 : n.init) == null || r.call(n, i, s.backend, s);
|
|
865
|
+
}
|
|
866
|
+
queueLoad(e, t, i, s) {
|
|
867
|
+
const n = {}, r = {}, a = {}, u = {};
|
|
868
|
+
return e.forEach((l) => {
|
|
869
|
+
let h = !0;
|
|
870
|
+
t.forEach((f) => {
|
|
871
|
+
const m = `${l}|${f}`;
|
|
872
|
+
!i.reload && this.store.hasResourceBundle(l, f) ? this.state[m] = 2 : this.state[m] < 0 || (this.state[m] === 1 ? r[m] === void 0 && (r[m] = !0) : (this.state[m] = 1, h = !1, r[m] === void 0 && (r[m] = !0), n[m] === void 0 && (n[m] = !0), u[f] === void 0 && (u[f] = !0)));
|
|
873
|
+
}), h || (a[l] = !0);
|
|
874
|
+
}), (Object.keys(n).length || Object.keys(r).length) && this.queue.push({
|
|
875
|
+
pending: r,
|
|
876
|
+
pendingCount: Object.keys(r).length,
|
|
877
|
+
loaded: {},
|
|
878
|
+
errors: [],
|
|
879
|
+
callback: s
|
|
880
|
+
}), {
|
|
881
|
+
toLoad: Object.keys(n),
|
|
882
|
+
pending: Object.keys(r),
|
|
883
|
+
toLoadLanguages: Object.keys(a),
|
|
884
|
+
toLoadNamespaces: Object.keys(u)
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
loaded(e, t, i) {
|
|
888
|
+
const s = e.split("|"), n = s[0], r = s[1];
|
|
889
|
+
t && this.emit("failedLoading", n, r, t), !t && i && this.store.addResourceBundle(n, r, i, void 0, void 0, {
|
|
890
|
+
skipCopy: !0
|
|
891
|
+
}), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
|
|
892
|
+
const a = {};
|
|
893
|
+
this.queue.forEach((u) => {
|
|
894
|
+
Ee(u.loaded, [n], r), Ye(u, e), t && u.errors.push(t), u.pendingCount === 0 && !u.done && (Object.keys(u.loaded).forEach((l) => {
|
|
895
|
+
a[l] || (a[l] = {});
|
|
896
|
+
const h = u.loaded[l];
|
|
897
|
+
h.length && h.forEach((f) => {
|
|
898
|
+
a[l][f] === void 0 && (a[l][f] = !0);
|
|
899
|
+
});
|
|
900
|
+
}), u.done = !0, u.errors.length ? u.callback(u.errors) : u.callback());
|
|
901
|
+
}), this.emit("loaded", a), this.queue = this.queue.filter((u) => !u.done);
|
|
902
|
+
}
|
|
903
|
+
read(e, t, i, s = 0, n = this.retryTimeout, r) {
|
|
904
|
+
if (!e.length) return r(null, {});
|
|
905
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
906
|
+
this.waitingReads.push({
|
|
907
|
+
lng: e,
|
|
908
|
+
ns: t,
|
|
909
|
+
fcName: i,
|
|
910
|
+
tried: s,
|
|
911
|
+
wait: n,
|
|
912
|
+
callback: r
|
|
913
|
+
});
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
this.readingCalls++;
|
|
917
|
+
const a = (l, h) => {
|
|
918
|
+
if (this.readingCalls--, this.waitingReads.length > 0) {
|
|
919
|
+
const f = this.waitingReads.shift();
|
|
920
|
+
this.read(f.lng, f.ns, f.fcName, f.tried, f.wait, f.callback);
|
|
921
|
+
}
|
|
922
|
+
if (l && h && s < this.maxRetries) {
|
|
923
|
+
setTimeout(() => {
|
|
924
|
+
this.read.call(this, e, t, i, s + 1, n * 2, r);
|
|
925
|
+
}, n);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
r(l, h);
|
|
929
|
+
}, u = this.backend[i].bind(this.backend);
|
|
930
|
+
if (u.length === 2) {
|
|
931
|
+
try {
|
|
932
|
+
const l = u(e, t);
|
|
933
|
+
l && typeof l.then == "function" ? l.then((h) => a(null, h)).catch(a) : a(null, l);
|
|
934
|
+
} catch (l) {
|
|
935
|
+
a(l);
|
|
936
|
+
}
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
return u(e, t, a);
|
|
940
|
+
}
|
|
941
|
+
prepareLoading(e, t, i = {}, s) {
|
|
942
|
+
if (!this.backend)
|
|
943
|
+
return this.logger.warn("No backend was added via i18next.use. Will not load resources."), s && s();
|
|
944
|
+
p(e) && (e = this.languageUtils.toResolveHierarchy(e)), p(t) && (t = [t]);
|
|
945
|
+
const n = this.queueLoad(e, t, i, s);
|
|
946
|
+
if (!n.toLoad.length)
|
|
947
|
+
return n.pending.length || s(), null;
|
|
948
|
+
n.toLoad.forEach((r) => {
|
|
949
|
+
this.loadOne(r);
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
load(e, t, i) {
|
|
953
|
+
this.prepareLoading(e, t, {}, i);
|
|
954
|
+
}
|
|
955
|
+
reload(e, t, i) {
|
|
956
|
+
this.prepareLoading(e, t, {
|
|
957
|
+
reload: !0
|
|
958
|
+
}, i);
|
|
959
|
+
}
|
|
960
|
+
loadOne(e, t = "") {
|
|
961
|
+
const i = e.split("|"), s = i[0], n = i[1];
|
|
962
|
+
this.read(s, n, "read", void 0, void 0, (r, a) => {
|
|
963
|
+
r && this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`, r), !r && a && this.logger.log(`${t}loaded namespace ${n} for language ${s}`, a), this.loaded(e, r, a);
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
saveMissing(e, t, i, s, n, r = {}, a = () => {
|
|
967
|
+
}) {
|
|
968
|
+
var u, l, h, f, m;
|
|
969
|
+
if ((l = (u = this.services) == null ? void 0 : u.utils) != null && l.hasLoadedNamespace && !((f = (h = this.services) == null ? void 0 : h.utils) != null && f.hasLoadedNamespace(t))) {
|
|
970
|
+
this.logger.warn(`did not save key "${i}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
if (!(i == null || i === "")) {
|
|
974
|
+
if ((m = this.backend) != null && m.create) {
|
|
975
|
+
const g = b(d({}, r), {
|
|
976
|
+
isUpdate: n
|
|
977
|
+
}), c = this.backend.create.bind(this.backend);
|
|
978
|
+
if (c.length < 6)
|
|
979
|
+
try {
|
|
980
|
+
let x;
|
|
981
|
+
c.length === 5 ? x = c(e, t, i, s, g) : x = c(e, t, i, s), x && typeof x.then == "function" ? x.then((y) => a(null, y)).catch(a) : a(null, x);
|
|
982
|
+
} catch (x) {
|
|
983
|
+
a(x);
|
|
984
|
+
}
|
|
985
|
+
else
|
|
986
|
+
c(e, t, i, s, a, g);
|
|
987
|
+
}
|
|
988
|
+
!e || !e[0] || this.store.addResource(e[0], t, i, s);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
const Se = () => ({
|
|
993
|
+
debug: !1,
|
|
994
|
+
initAsync: !0,
|
|
995
|
+
ns: ["translation"],
|
|
996
|
+
defaultNS: ["translation"],
|
|
997
|
+
fallbackLng: ["dev"],
|
|
998
|
+
fallbackNS: !1,
|
|
999
|
+
supportedLngs: !1,
|
|
1000
|
+
nonExplicitSupportedLngs: !1,
|
|
1001
|
+
load: "all",
|
|
1002
|
+
preload: !1,
|
|
1003
|
+
simplifyPluralSuffix: !0,
|
|
1004
|
+
keySeparator: ".",
|
|
1005
|
+
nsSeparator: ":",
|
|
1006
|
+
pluralSeparator: "_",
|
|
1007
|
+
contextSeparator: "_",
|
|
1008
|
+
partialBundledLanguages: !1,
|
|
1009
|
+
saveMissing: !1,
|
|
1010
|
+
updateMissing: !1,
|
|
1011
|
+
saveMissingTo: "fallback",
|
|
1012
|
+
saveMissingPlurals: !0,
|
|
1013
|
+
missingKeyHandler: !1,
|
|
1014
|
+
missingInterpolationHandler: !1,
|
|
1015
|
+
postProcess: !1,
|
|
1016
|
+
postProcessPassResolved: !1,
|
|
1017
|
+
returnNull: !1,
|
|
1018
|
+
returnEmptyString: !0,
|
|
1019
|
+
returnObjects: !1,
|
|
1020
|
+
joinArrays: !1,
|
|
1021
|
+
returnedObjectHandler: !1,
|
|
1022
|
+
parseMissingKeyHandler: !1,
|
|
1023
|
+
appendNamespaceToMissingKey: !1,
|
|
1024
|
+
appendNamespaceToCIMode: !1,
|
|
1025
|
+
overloadTranslationOptionHandler: (o) => {
|
|
1026
|
+
let e = {};
|
|
1027
|
+
if (typeof o[1] == "object" && (e = o[1]), p(o[1]) && (e.defaultValue = o[1]), p(o[2]) && (e.tDescription = o[2]), typeof o[2] == "object" || typeof o[3] == "object") {
|
|
1028
|
+
const t = o[3] || o[2];
|
|
1029
|
+
Object.keys(t).forEach((i) => {
|
|
1030
|
+
e[i] = t[i];
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
return e;
|
|
1034
|
+
},
|
|
1035
|
+
interpolation: {
|
|
1036
|
+
escapeValue: !0,
|
|
1037
|
+
format: (o) => o,
|
|
1038
|
+
prefix: "{{",
|
|
1039
|
+
suffix: "}}",
|
|
1040
|
+
formatSeparator: ",",
|
|
1041
|
+
unescapePrefix: "-",
|
|
1042
|
+
nestingPrefix: "$t(",
|
|
1043
|
+
nestingSuffix: ")",
|
|
1044
|
+
nestingOptionsSeparator: ",",
|
|
1045
|
+
maxReplaces: 1e3,
|
|
1046
|
+
skipOnVariables: !0
|
|
1047
|
+
},
|
|
1048
|
+
cacheInBuiltFormats: !0
|
|
1049
|
+
}), Oe = (o) => {
|
|
1050
|
+
var e, t;
|
|
1051
|
+
return p(o.ns) && (o.ns = [o.ns]), p(o.fallbackLng) && (o.fallbackLng = [o.fallbackLng]), p(o.fallbackNS) && (o.fallbackNS = [o.fallbackNS]), ((t = (e = o.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (o.supportedLngs = o.supportedLngs.concat(["cimode"])), typeof o.initImmediate == "boolean" && (o.initAsync = o.initImmediate), o;
|
|
1052
|
+
}, W = () => {
|
|
1053
|
+
}, Qe = (o) => {
|
|
1054
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
|
|
1055
|
+
typeof o[t] == "function" && (o[t] = o[t].bind(o));
|
|
1056
|
+
});
|
|
1057
|
+
};
|
|
1058
|
+
class M extends G {
|
|
1059
|
+
constructor(e = {}, t) {
|
|
1060
|
+
if (super(), this.options = Oe(e), this.services = {}, this.logger = k, this.modules = {
|
|
1061
|
+
external: []
|
|
1062
|
+
}, Qe(this), t && !this.isInitialized && !e.isClone) {
|
|
1063
|
+
if (!this.options.initAsync)
|
|
1064
|
+
return this.init(e, t), this;
|
|
1065
|
+
setTimeout(() => {
|
|
1066
|
+
this.init(e, t);
|
|
1067
|
+
}, 0);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
init(e = {}, t) {
|
|
1071
|
+
this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (p(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
|
|
1072
|
+
const i = Se();
|
|
1073
|
+
this.options = d(d(d({}, i), this.options), Oe(e)), this.options.interpolation = d(d({}, i.interpolation), this.options.interpolation), e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = i.overloadTranslationOptionHandler);
|
|
1074
|
+
const s = (l) => l ? typeof l == "function" ? new l() : l : null;
|
|
1075
|
+
if (!this.options.isClone) {
|
|
1076
|
+
this.modules.logger ? k.init(s(this.modules.logger), this.options) : k.init(null, this.options);
|
|
1077
|
+
let l;
|
|
1078
|
+
this.modules.formatter ? l = this.modules.formatter : l = We;
|
|
1079
|
+
const h = new de(this.options);
|
|
1080
|
+
this.store = new he(this.options.resources, this.options);
|
|
1081
|
+
const f = this.services;
|
|
1082
|
+
f.logger = k, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
|
|
1083
|
+
prepend: this.options.pluralSeparator,
|
|
1084
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1085
|
+
}), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), l && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (f.formatter = s(l), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new xe(this.options), f.utils = {
|
|
1086
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1087
|
+
}, f.backendConnector = new _e(s(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (g, ...c) => {
|
|
1088
|
+
this.emit(g, ...c);
|
|
1089
|
+
}), this.modules.languageDetector && (f.languageDetector = s(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = s(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new Q(this.services, this.options), this.translator.on("*", (g, ...c) => {
|
|
1090
|
+
this.emit(g, ...c);
|
|
1091
|
+
}), this.modules.external.forEach((g) => {
|
|
1092
|
+
g.init && g.init(this);
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
if (this.format = this.options.interpolation.format, t || (t = W), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1096
|
+
const l = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1097
|
+
l.length > 0 && l[0] !== "dev" && (this.options.lng = l[0]);
|
|
1098
|
+
}
|
|
1099
|
+
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((l) => {
|
|
1100
|
+
this[l] = (...h) => this.store[l](...h);
|
|
1101
|
+
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((l) => {
|
|
1102
|
+
this[l] = (...h) => (this.store[l](...h), this);
|
|
1103
|
+
});
|
|
1104
|
+
const a = U(), u = () => {
|
|
1105
|
+
const l = (h, f) => {
|
|
1106
|
+
this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), a.resolve(f), t(h, f);
|
|
1107
|
+
};
|
|
1108
|
+
if (this.languages && !this.isInitialized) return l(null, this.t.bind(this));
|
|
1109
|
+
this.changeLanguage(this.options.lng, l);
|
|
1110
|
+
};
|
|
1111
|
+
return this.options.resources || !this.options.initAsync ? u() : setTimeout(u, 0), a;
|
|
1112
|
+
}
|
|
1113
|
+
loadResources(e, t = W) {
|
|
1114
|
+
var n, r;
|
|
1115
|
+
let i = t;
|
|
1116
|
+
const s = p(e) ? e : this.language;
|
|
1117
|
+
if (typeof e == "function" && (i = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1118
|
+
if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return i();
|
|
1119
|
+
const a = [], u = (l) => {
|
|
1120
|
+
if (!l || l === "cimode") return;
|
|
1121
|
+
this.services.languageUtils.toResolveHierarchy(l).forEach((f) => {
|
|
1122
|
+
f !== "cimode" && a.indexOf(f) < 0 && a.push(f);
|
|
1123
|
+
});
|
|
1124
|
+
};
|
|
1125
|
+
s ? u(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((h) => u(h)), (r = (n = this.options.preload) == null ? void 0 : n.forEach) == null || r.call(n, (l) => u(l)), this.services.backendConnector.load(a, this.options.ns, (l) => {
|
|
1126
|
+
!l && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), i(l);
|
|
1127
|
+
});
|
|
1128
|
+
} else
|
|
1129
|
+
i(null);
|
|
1130
|
+
}
|
|
1131
|
+
reloadResources(e, t, i) {
|
|
1132
|
+
const s = U();
|
|
1133
|
+
return typeof e == "function" && (i = e, e = void 0), typeof t == "function" && (i = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), i || (i = W), this.services.backendConnector.reload(e, t, (n) => {
|
|
1134
|
+
s.resolve(), i(n);
|
|
1135
|
+
}), s;
|
|
1136
|
+
}
|
|
1137
|
+
use(e) {
|
|
1138
|
+
if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1139
|
+
if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1140
|
+
return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && Le.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1141
|
+
}
|
|
1142
|
+
setResolvedLanguage(e) {
|
|
1143
|
+
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
|
|
1144
|
+
for (let t = 0; t < this.languages.length; t++) {
|
|
1145
|
+
const i = this.languages[t];
|
|
1146
|
+
if (!(["cimode", "dev"].indexOf(i) > -1) && this.store.hasLanguageSomeTranslations(i)) {
|
|
1147
|
+
this.resolvedLanguage = i;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
!this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
changeLanguage(e, t) {
|
|
1155
|
+
this.isLanguageChangingTo = e;
|
|
1156
|
+
const i = U();
|
|
1157
|
+
this.emit("languageChanging", e);
|
|
1158
|
+
const s = (a) => {
|
|
1159
|
+
this.language = a, this.languages = this.services.languageUtils.toResolveHierarchy(a), this.resolvedLanguage = void 0, this.setResolvedLanguage(a);
|
|
1160
|
+
}, n = (a, u) => {
|
|
1161
|
+
u ? this.isLanguageChangingTo === e && (s(u), this.translator.changeLanguage(u), this.isLanguageChangingTo = void 0, this.emit("languageChanged", u), this.logger.log("languageChanged", u)) : this.isLanguageChangingTo = void 0, i.resolve((...l) => this.t(...l)), t && t(a, (...l) => this.t(...l));
|
|
1162
|
+
}, r = (a) => {
|
|
1163
|
+
var h, f;
|
|
1164
|
+
!e && !a && this.services.languageDetector && (a = []);
|
|
1165
|
+
const u = p(a) ? a : a && a[0], l = this.store.hasLanguageSomeTranslations(u) ? u : this.services.languageUtils.getBestMatchFromCodes(p(a) ? [a] : a);
|
|
1166
|
+
l && (this.language || s(l), this.translator.language || this.translator.changeLanguage(l), (f = (h = this.services.languageDetector) == null ? void 0 : h.cacheUserLanguage) == null || f.call(h, l)), this.loadResources(l, (m) => {
|
|
1167
|
+
n(m, l);
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
return !e && this.services.languageDetector && !this.services.languageDetector.async ? r(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(r) : this.services.languageDetector.detect(r) : r(e), i;
|
|
1171
|
+
}
|
|
1172
|
+
getFixedT(e, t, i) {
|
|
1173
|
+
const s = (n, r, ...a) => {
|
|
1174
|
+
let u;
|
|
1175
|
+
typeof r != "object" ? u = this.options.overloadTranslationOptionHandler([n, r].concat(a)) : u = d({}, r), u.lng = u.lng || s.lng, u.lngs = u.lngs || s.lngs, u.ns = u.ns || s.ns, u.keyPrefix !== "" && (u.keyPrefix = u.keyPrefix || i || s.keyPrefix);
|
|
1176
|
+
const l = this.options.keySeparator || ".";
|
|
1177
|
+
let h;
|
|
1178
|
+
return u.keyPrefix && Array.isArray(n) ? h = n.map((f) => (typeof f == "function" && (f = ee(f, d(d({}, this.options), r))), `${u.keyPrefix}${l}${f}`)) : (typeof n == "function" && (n = ee(n, d(d({}, this.options), r))), h = u.keyPrefix ? `${u.keyPrefix}${l}${n}` : n), this.t(h, u);
|
|
1179
|
+
};
|
|
1180
|
+
return p(e) ? s.lng = e : s.lngs = e, s.ns = t, s.keyPrefix = i, s;
|
|
1181
|
+
}
|
|
1182
|
+
t(...e) {
|
|
1183
|
+
var t;
|
|
1184
|
+
return (t = this.translator) == null ? void 0 : t.translate(...e);
|
|
1185
|
+
}
|
|
1186
|
+
exists(...e) {
|
|
1187
|
+
var t;
|
|
1188
|
+
return (t = this.translator) == null ? void 0 : t.exists(...e);
|
|
1189
|
+
}
|
|
1190
|
+
setDefaultNamespace(e) {
|
|
1191
|
+
this.options.defaultNS = e;
|
|
1192
|
+
}
|
|
1193
|
+
hasLoadedNamespace(e, t = {}) {
|
|
1194
|
+
if (!this.isInitialized)
|
|
1195
|
+
return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1196
|
+
if (!this.languages || !this.languages.length)
|
|
1197
|
+
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1198
|
+
const i = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, n = this.languages[this.languages.length - 1];
|
|
1199
|
+
if (i.toLowerCase() === "cimode") return !0;
|
|
1200
|
+
const r = (a, u) => {
|
|
1201
|
+
const l = this.services.backendConnector.state[`${a}|${u}`];
|
|
1202
|
+
return l === -1 || l === 0 || l === 2;
|
|
1203
|
+
};
|
|
1204
|
+
if (t.precheck) {
|
|
1205
|
+
const a = t.precheck(this, r);
|
|
1206
|
+
if (a !== void 0) return a;
|
|
1207
|
+
}
|
|
1208
|
+
return !!(this.hasResourceBundle(i, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || r(i, e) && (!s || r(n, e)));
|
|
1209
|
+
}
|
|
1210
|
+
loadNamespaces(e, t) {
|
|
1211
|
+
const i = U();
|
|
1212
|
+
return this.options.ns ? (p(e) && (e = [e]), e.forEach((s) => {
|
|
1213
|
+
this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
|
|
1214
|
+
}), this.loadResources((s) => {
|
|
1215
|
+
i.resolve(), t && t(s);
|
|
1216
|
+
}), i) : (t && t(), Promise.resolve());
|
|
1217
|
+
}
|
|
1218
|
+
loadLanguages(e, t) {
|
|
1219
|
+
const i = U();
|
|
1220
|
+
p(e) && (e = [e]);
|
|
1221
|
+
const s = this.options.preload || [], n = e.filter((r) => s.indexOf(r) < 0 && this.services.languageUtils.isSupportedCode(r));
|
|
1222
|
+
return n.length ? (this.options.preload = s.concat(n), this.loadResources((r) => {
|
|
1223
|
+
i.resolve(), t && t(r);
|
|
1224
|
+
}), i) : (t && t(), Promise.resolve());
|
|
1225
|
+
}
|
|
1226
|
+
dir(e) {
|
|
1227
|
+
var s, n;
|
|
1228
|
+
if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e) return "rtl";
|
|
1229
|
+
try {
|
|
1230
|
+
const r = new Intl.Locale(e);
|
|
1231
|
+
if (r && r.getTextInfo) {
|
|
1232
|
+
const a = r.getTextInfo();
|
|
1233
|
+
if (a && a.direction) return a.direction;
|
|
1234
|
+
}
|
|
1235
|
+
} catch (r) {
|
|
1236
|
+
}
|
|
1237
|
+
const t = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"], i = ((n = this.services) == null ? void 0 : n.languageUtils) || new de(Se());
|
|
1238
|
+
return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(i.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1239
|
+
}
|
|
1240
|
+
static createInstance(e = {}, t) {
|
|
1241
|
+
const i = new M(e, t);
|
|
1242
|
+
return i.createInstance = M.createInstance, i;
|
|
1243
|
+
}
|
|
1244
|
+
cloneInstance(e = {}, t = W) {
|
|
1245
|
+
const i = e.forkResourceStore;
|
|
1246
|
+
i && delete e.forkResourceStore;
|
|
1247
|
+
const s = b(d(d({}, this.options), e), {
|
|
1248
|
+
isClone: !0
|
|
1249
|
+
}), n = new M(s);
|
|
1250
|
+
if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
|
|
1251
|
+
n[a] = this[a];
|
|
1252
|
+
}), n.services = d({}, this.services), n.services.utils = {
|
|
1253
|
+
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1254
|
+
}, i) {
|
|
1255
|
+
const a = Object.keys(this.store.data).reduce((u, l) => (u[l] = d({}, this.store.data[l]), u[l] = Object.keys(u[l]).reduce((h, f) => (h[f] = d({}, u[l][f]), h), u[l]), u), {});
|
|
1256
|
+
n.store = new he(a, s), n.services.resourceStore = n.store;
|
|
1257
|
+
}
|
|
1258
|
+
return e.interpolation && (n.services.interpolator = new xe(s)), n.translator = new Q(n.services, s), n.translator.on("*", (a, ...u) => {
|
|
1259
|
+
n.emit(a, ...u);
|
|
1260
|
+
}), n.init(s, t), n.translator.options = s, n.translator.backendConnector.services.utils = {
|
|
1261
|
+
hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
|
|
1262
|
+
}, n;
|
|
1263
|
+
}
|
|
1264
|
+
toJSON() {
|
|
1265
|
+
return {
|
|
1266
|
+
options: this.options,
|
|
1267
|
+
store: this.store,
|
|
1268
|
+
language: this.language,
|
|
1269
|
+
languages: this.languages,
|
|
1270
|
+
resolvedLanguage: this.resolvedLanguage
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
const L = M.createInstance();
|
|
1275
|
+
L.createInstance;
|
|
1276
|
+
L.dir;
|
|
1277
|
+
L.init;
|
|
1278
|
+
L.loadResources;
|
|
1279
|
+
L.reloadResources;
|
|
1280
|
+
L.use;
|
|
1281
|
+
L.changeLanguage;
|
|
1282
|
+
L.getFixedT;
|
|
1283
|
+
L.t;
|
|
1284
|
+
L.exists;
|
|
1285
|
+
L.setDefaultNamespace;
|
|
1286
|
+
L.hasLoadedNamespace;
|
|
1287
|
+
L.loadNamespaces;
|
|
1288
|
+
L.loadLanguages;
|
|
1289
|
+
export {
|
|
1290
|
+
L as default,
|
|
1291
|
+
ee as keyFromSelector
|
|
1292
|
+
};
|