@coveo/atomic 3.35.0-pre.b3e173655a → 3.35.0-pre.c86b349898
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/dist/atomic/_atomic.esm.js +1 -1
- package/dist/atomic/atomic.esm.js.map +1 -1
- package/dist/atomic/components/_index.d.ts +0 -2
- package/dist/atomic/components/_index.js +0 -1
- package/dist/atomic/components/atomic-category-facet.js +1 -1
- package/dist/atomic/components/atomic-citation.js +1 -1
- package/dist/atomic/components/atomic-facet-manager.js +1 -1
- package/dist/atomic/components/atomic-facet.js +1 -1
- package/dist/atomic/components/atomic-format-currency.js +1 -1
- package/dist/atomic/components/atomic-format-number.js +1 -1
- package/dist/atomic/components/atomic-format-unit.js +1 -1
- package/dist/atomic/components/atomic-generated-answer-feedback-modal.js +1 -1
- package/dist/atomic/components/atomic-html2.js +1 -1
- package/dist/atomic/components/atomic-insight-edit-toggle.js +1 -1
- package/dist/atomic/components/atomic-insight-facet.js +1 -1
- package/dist/atomic/components/atomic-insight-folded-result-list.js +1 -1
- package/dist/atomic/components/atomic-insight-full-search-button.js +1 -1
- package/dist/atomic/components/atomic-insight-history-toggle.js +1 -1
- package/dist/atomic/components/atomic-insight-layout.js +82 -1
- package/dist/atomic/components/atomic-insight-layout.js.map +1 -1
- package/dist/atomic/components/atomic-insight-no-results.js +1 -1
- package/dist/atomic/components/atomic-insight-numeric-facet.js +1 -1
- package/dist/atomic/components/atomic-insight-pager.js +3 -3
- package/dist/atomic/components/atomic-insight-query-error.js +1 -1
- package/dist/atomic/components/atomic-insight-refine-modal2.js +2 -2
- package/dist/atomic/components/atomic-insight-refine-toggle.js +1 -1
- package/dist/atomic/components/atomic-insight-result-action.js +1 -1
- package/dist/atomic/components/atomic-insight-result-attach-to-case-action.js +1 -1
- package/dist/atomic/components/atomic-insight-result-attach-to-case-indicator.js +1 -1
- package/dist/atomic/components/atomic-insight-result-children.js +1 -1
- package/dist/atomic/components/atomic-insight-result-list.js +1 -1
- package/dist/atomic/components/atomic-insight-result-quickview-action.js +1 -1
- package/dist/atomic/components/atomic-insight-result2.js +1 -1
- package/dist/atomic/components/atomic-insight-search-box.js +2 -2
- package/dist/atomic/components/atomic-insight-smart-snippet-feedback-modal2.js +2 -2
- package/dist/atomic/components/atomic-insight-tabs.js +1 -1
- package/dist/atomic/components/atomic-insight-user-actions-session2.js +1 -1
- package/dist/atomic/components/atomic-insight-user-actions-toggle.js +1 -1
- package/dist/atomic/components/atomic-ipx-body2.js +2 -2
- package/dist/atomic/components/atomic-ipx-button.js +2 -2
- package/dist/atomic/components/atomic-ipx-embedded.js +1 -1
- package/dist/atomic/components/atomic-ipx-modal.js +2 -2
- package/dist/atomic/components/atomic-ipx-recs-list.js +1 -1
- package/dist/atomic/components/atomic-ipx-refine-modal2.js +1 -1
- package/dist/atomic/components/atomic-ipx-refine-toggle.js +1 -1
- package/dist/atomic/components/atomic-ipx-result-link.js +1 -1
- package/dist/atomic/components/atomic-ipx-tabs.js +1 -1
- package/dist/atomic/components/atomic-load-more-results.js +1 -1
- package/dist/atomic/components/atomic-no-results.js +1 -1
- package/dist/atomic/components/atomic-numeric-facet.js +1 -1
- package/dist/atomic/components/atomic-query-error.js +1 -1
- package/dist/atomic/components/atomic-quickview-modal2.js +1 -1
- package/dist/atomic/components/atomic-quickview.js +1 -1
- package/dist/atomic/components/atomic-recs-error.js +1 -1
- package/dist/atomic/components/atomic-recs-interface.js +2915 -3
- package/dist/atomic/components/atomic-recs-interface.js.map +1 -1
- package/dist/atomic/components/atomic-recs-list.js +1 -1
- package/dist/atomic/components/atomic-refine-modal2.js +1 -1
- package/dist/atomic/components/atomic-refine-toggle.js +1 -1
- package/dist/atomic/components/atomic-result-children.js +1 -1
- package/dist/atomic/components/atomic-result-fields-list.js +1 -1
- package/dist/atomic/components/atomic-result-link.js +1 -1
- package/dist/atomic/components/atomic-result-list.js +1 -1
- package/dist/atomic/components/atomic-result-placeholder2.js +2 -2
- package/dist/atomic/components/atomic-result-table-placeholder2.js +1 -1
- package/dist/atomic/components/atomic-search-box-instant-results.js +1 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +1 -1
- package/dist/atomic/components/atomic-search-box.js +7 -3
- package/dist/atomic/components/atomic-search-box.js.map +1 -1
- package/dist/atomic/components/atomic-smart-snippet-answer2.js +1 -1
- package/dist/atomic/components/atomic-smart-snippet-collapse-wrapper2.js +2 -2
- package/dist/atomic/components/atomic-smart-snippet-expandable-answer2.js +1 -1
- package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
- package/dist/atomic/components/atomic-smart-snippet-source2.js +1 -1
- package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
- package/dist/atomic/components/atomic-sort-expression.js +1 -1
- package/dist/atomic/components/atomic-stencil-facet-date-input.js +3 -3
- package/dist/atomic/components/atomic-suggestion-renderer2.js +1 -1
- package/dist/atomic/components/atomic-tab-manager.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.js +3 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +5 -0
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.js +3 -0
- package/dist/atomic/components/components/common/breadbox/breadcrumb-button.js +6 -1
- package/dist/atomic/components/components/common/search-box/text-area-clear-button.js +1 -1
- package/dist/atomic/components/components/insight/atomic-insight-interface/analytics-config.js +31 -0
- package/dist/atomic/components/components/insight/atomic-insight-interface/atomic-insight-interface.js +258 -0
- package/dist/atomic/components/components/insight/index.js +2 -1
- package/dist/atomic/components/components/insight/lazy-index.js +3 -1
- package/dist/atomic/components/facet-number-input.js +2 -2
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/components/item-section-utils.js +1 -1
- package/dist/atomic/components/replace-breakpoint-utils.js +1 -1
- package/dist/atomic/components/replace-breakpoint-utils.js.map +1 -1
- package/dist/atomic/components/stencil-suggestion-manager.js +1 -1
- package/dist/atomic/components/stencil-suggestion-manager.js.map +1 -1
- package/dist/atomic/components/store.js +2 -30
- package/dist/atomic/components/store.js.map +1 -1
- package/dist/atomic/components/tab-button.js +1 -1
- package/dist/atomic/components/tab-popover.js +1 -1
- package/dist/atomic/components/utils.js +1 -17
- package/dist/atomic/components/utils.js.map +1 -1
- package/dist/atomic/lang/cs.json +1 -1
- package/dist/atomic/lang/da.json +1 -1
- package/dist/atomic/lang/de.json +1 -1
- package/dist/atomic/lang/dev.json +1 -1
- package/dist/atomic/lang/el.json +1 -1
- package/dist/atomic/lang/en.json +1 -1
- package/dist/atomic/lang/es.json +1 -1
- package/dist/atomic/lang/fi.json +1 -1
- package/dist/atomic/lang/fr.json +1 -1
- package/dist/atomic/lang/hu.json +1 -1
- package/dist/atomic/lang/id.json +1 -1
- package/dist/atomic/lang/it.json +1 -1
- package/dist/atomic/lang/ja.json +1 -1
- package/dist/atomic/lang/ko.json +1 -1
- package/dist/atomic/lang/nl.json +1 -1
- package/dist/atomic/lang/no.json +1 -1
- package/dist/atomic/lang/pl.json +1 -1
- package/dist/atomic/lang/pt-BR.json +1 -1
- package/dist/atomic/lang/pt.json +1 -1
- package/dist/atomic/lang/ru.json +1 -1
- package/dist/atomic/lang/sv.json +1 -1
- package/dist/atomic/lang/th.json +1 -1
- package/dist/atomic/lang/tr.json +1 -1
- package/dist/atomic/lang/zh-CN.json +1 -1
- package/dist/atomic/lang/zh-TW.json +1 -1
- package/dist/atomic/lang/zh.json +1 -1
- package/dist/atomic/{p-27cf779a.js → p-025a346a.js} +2 -2
- package/dist/atomic/{p-7e971d15.entry.js → p-044de1f9.entry.js} +2 -2
- package/dist/atomic/{p-fe59fb2d.entry.js → p-0535b93d.entry.js} +2 -2
- package/dist/atomic/{p-31a13850.js → p-0580b866.js} +2 -2
- package/dist/atomic/{p-0edea6f9.entry.js → p-05f1ff6f.entry.js} +2 -2
- package/dist/atomic/{p-3e9db2b5.entry.js → p-088d634c.entry.js} +2 -2
- package/dist/atomic/{p-4bdc6d5a.entry.js → p-0ee7cab8.entry.js} +2 -2
- package/dist/atomic/{p-0f449e9d.entry.js → p-14bad769.entry.js} +2 -2
- package/dist/atomic/{p-01511388.entry.js → p-15547bd5.entry.js} +2 -2
- package/dist/atomic/{p-b313058c.entry.js → p-182f9112.entry.js} +2 -2
- package/dist/atomic/{p-00069a4b.entry.js → p-1910eb7f.entry.js} +2 -2
- package/dist/atomic/{p-85145c88.entry.js → p-1c8bcadf.entry.js} +2 -2
- package/dist/atomic/p-1fca38e1.js +2 -0
- package/dist/atomic/{p-26598ee0.js.map → p-1fca38e1.js.map} +1 -1
- package/dist/atomic/{p-cafa4083.entry.js → p-21ab7750.entry.js} +2 -2
- package/dist/atomic/{p-9a6ec803.entry.js → p-229018fa.entry.js} +2 -2
- package/dist/atomic/{p-89d8bb0d.entry.js → p-22b76c96.entry.js} +2 -2
- package/dist/atomic/p-2559747d.js +2 -0
- package/dist/atomic/p-2559747d.js.map +1 -0
- package/dist/atomic/{p-36f63642.entry.js → p-26e0c1f8.entry.js} +2 -2
- package/dist/atomic/{p-c4fb6426.entry.js → p-2e13e2c0.entry.js} +2 -2
- package/dist/atomic/{p-6098b906.entry.js → p-2f437b47.entry.js} +2 -2
- package/dist/atomic/{p-998393ec.entry.js → p-2f517a54.entry.js} +2 -2
- package/dist/atomic/{p-06284430.entry.js → p-318c96f5.entry.js} +2 -2
- package/dist/atomic/{p-0ed76e65.entry.js → p-3272a04b.entry.js} +2 -2
- package/dist/atomic/{p-d211a422.entry.js → p-3291adda.entry.js} +2 -2
- package/dist/atomic/{p-dbc0ce5c.entry.js → p-33245038.entry.js} +2 -2
- package/dist/atomic/{p-fa658ef2.entry.js → p-35c2ee5f.entry.js} +2 -2
- package/dist/atomic/p-36270a85.entry.js +2 -0
- package/dist/atomic/p-36270a85.entry.js.map +1 -0
- package/dist/atomic/{p-3d55fce6.entry.js → p-36e2c945.entry.js} +2 -2
- package/dist/atomic/{p-af1b4924.entry.js → p-3bd8469f.entry.js} +2 -2
- package/dist/atomic/{p-e62fc40e.js → p-3ef52afa.js} +2 -2
- package/dist/atomic/{p-170c7da6.entry.js → p-400c28b6.entry.js} +2 -2
- package/dist/atomic/{p-fafd5042.entry.js → p-448091f7.entry.js} +2 -2
- package/dist/atomic/{p-fe3cd55b.entry.js → p-44d96103.entry.js} +2 -2
- package/dist/atomic/{p-da845e35.entry.js → p-463336ca.entry.js} +2 -2
- package/dist/atomic/{p-f9dd14b2.entry.js → p-479cb38a.entry.js} +2 -2
- package/dist/atomic/{p-a9383817.entry.js → p-47b41b27.entry.js} +2 -2
- package/dist/atomic/{p-be2a43f4.entry.js → p-48bab1a6.entry.js} +2 -2
- package/dist/atomic/{p-0c8e7d5f.entry.js → p-4cb91ee7.entry.js} +2 -2
- package/dist/atomic/{p-23d4dc54.entry.js → p-558f2191.entry.js} +2 -2
- package/dist/atomic/{p-8572a953.entry.js → p-55c41e00.entry.js} +2 -2
- package/dist/atomic/p-567b2841.entry.js +2 -0
- package/dist/atomic/{p-a1522fe5.entry.js.map → p-567b2841.entry.js.map} +1 -1
- package/dist/atomic/{p-2e4628bb.entry.js → p-57049cd2.entry.js} +2 -2
- package/dist/atomic/{p-edd4d5f7.js → p-5a2ef889.js} +2 -2
- package/dist/atomic/{p-dc128135.entry.js → p-5a83b7e5.entry.js} +2 -2
- package/dist/atomic/{p-10b5e0f3.entry.js → p-5b8cc4bc.entry.js} +2 -2
- package/dist/atomic/{p-87f69e53.entry.js → p-5cab535b.entry.js} +2 -2
- package/dist/atomic/p-5d0fc7e2.js +2 -0
- package/dist/atomic/{p-740cd5bc.entry.js → p-6439156c.entry.js} +2 -2
- package/dist/atomic/{p-7e9a1a1a.entry.js → p-66166975.entry.js} +2 -2
- package/dist/atomic/{p-97538903.entry.js → p-6698d5e9.entry.js} +2 -2
- package/dist/atomic/{p-0610b3e7.entry.js → p-6819f12c.entry.js} +2 -2
- package/dist/atomic/p-6b3429d3.js +2 -0
- package/dist/atomic/{p-6078667f.entry.js → p-7045745d.entry.js} +2 -2
- package/dist/atomic/{p-a130b00b.entry.js → p-70747efa.entry.js} +2 -2
- package/dist/atomic/{p-4830b9bb.entry.js → p-7242b46e.entry.js} +2 -2
- package/dist/atomic/{p-3af2fca0.js → p-7427daa3.js} +2 -2
- package/dist/atomic/{p-b320f270.entry.js → p-76c14d82.entry.js} +2 -2
- package/dist/atomic/{p-1435fb6f.entry.js → p-7741124a.entry.js} +2 -2
- package/dist/atomic/{p-cdeb5f2a.entry.js → p-77d00da1.entry.js} +2 -2
- package/dist/atomic/{p-519d9abd.entry.js → p-7fd58269.entry.js} +2 -2
- package/dist/atomic/p-7fe23afc.entry.js +2 -0
- package/dist/atomic/{p-c7af4b9e.entry.js.map → p-7fe23afc.entry.js.map} +1 -1
- package/dist/atomic/{p-f76b7ac3.entry.js → p-80290dd3.entry.js} +2 -2
- package/dist/atomic/{p-b6ae0244.entry.js → p-81bdbd07.entry.js} +2 -2
- package/dist/atomic/{p-dc28ee14.js → p-828ab4ff.js} +2 -2
- package/dist/atomic/{p-723f76a1.entry.js → p-82cd6398.entry.js} +2 -2
- package/dist/atomic/{p-fdcd187d.entry.js → p-851b9735.entry.js} +2 -2
- package/dist/atomic/{p-40c1dfcb.entry.js → p-874f0a4c.entry.js} +2 -2
- package/dist/atomic/{p-373448df.entry.js → p-8b0cf1d4.entry.js} +2 -2
- package/dist/atomic/{p-36112c34.entry.js → p-8b0d881e.entry.js} +2 -2
- package/dist/atomic/{p-ee957926.entry.js → p-8d5228da.entry.js} +2 -2
- package/dist/atomic/{p-c25f1437.entry.js → p-955092ed.entry.js} +2 -2
- package/dist/atomic/{p-47ab6c9f.entry.js → p-99d4c4bf.entry.js} +2 -2
- package/dist/atomic/{p-edede7d1.entry.js → p-9aad555a.entry.js} +2 -2
- package/dist/atomic/{p-2250f505.js → p-9ae68e86.js} +2 -2
- package/dist/atomic/{p-83d3857f.entry.js → p-9e6462cf.entry.js} +2 -2
- package/dist/atomic/p-9e6462cf.entry.js.map +1 -0
- package/dist/atomic/{p-00a6ab8c.entry.js → p-a0ebbbdf.entry.js} +2 -2
- package/dist/atomic/{p-7fd5b6ac.entry.js → p-a1798150.entry.js} +2 -2
- package/dist/atomic/{p-9239be63.entry.js → p-a54f3f24.entry.js} +2 -2
- package/dist/atomic/{p-24fd7df6.entry.js → p-a6dde0f6.entry.js} +2 -2
- package/dist/atomic/{p-a1e5f767.entry.js → p-a78cbb80.entry.js} +2 -2
- package/dist/atomic/p-aaa5a853.js +2 -0
- package/dist/atomic/p-aaa5a853.js.map +1 -0
- package/dist/atomic/{p-59b15bd6.entry.js → p-ae69f519.entry.js} +2 -2
- package/dist/atomic/{p-98dd6df1.entry.js → p-b06de6f8.entry.js} +2 -2
- package/dist/atomic/{p-fdd0aa42.entry.js → p-b1b583a0.entry.js} +2 -2
- package/dist/atomic/{p-3c9289b5.js → p-b29d121c.js} +2 -2
- package/dist/atomic/p-b628ed03.entry.js +2 -0
- package/dist/atomic/{p-a1ee594f.entry.js.map → p-b628ed03.entry.js.map} +1 -1
- package/dist/atomic/{p-cb3fd0f4.entry.js → p-b84108f3.entry.js} +2 -2
- package/dist/atomic/{p-fb1a1e2e.entry.js → p-b85c2c46.entry.js} +2 -2
- package/dist/atomic/{p-9260dd7d.entry.js → p-b9eeac20.entry.js} +2 -2
- package/dist/atomic/{p-b2b9e83f.entry.js → p-bc43df67.entry.js} +2 -2
- package/dist/atomic/{p-93601dc0.entry.js → p-bd01acd5.entry.js} +2 -2
- package/dist/atomic/{p-416d088e.entry.js → p-be011bd1.entry.js} +2 -2
- package/dist/atomic/{p-4f4c9a03.entry.js → p-c2a5dac0.entry.js} +2 -2
- package/dist/atomic/{p-93f1d551.entry.js → p-c5164dbf.entry.js} +2 -2
- package/dist/atomic/{p-3622ed6c.js → p-c619df9b.js} +2 -2
- package/dist/atomic/{p-1bbaf206.entry.js → p-c8190eb9.entry.js} +2 -2
- package/dist/atomic/{p-5ca21deb.js → p-ca37969c.js} +2 -2
- package/dist/atomic/{p-7cced247.entry.js → p-d0ab0125.entry.js} +2 -2
- package/dist/atomic/{p-2fb49fe8.entry.js → p-d8caa4d8.entry.js} +2 -2
- package/dist/atomic/{p-62e85c20.entry.js → p-da87ef51.entry.js} +2 -2
- package/dist/atomic/{p-367ec37d.entry.js → p-db2d92c5.entry.js} +2 -2
- package/dist/atomic/{p-dbf0c5a3.entry.js → p-db3b11ca.entry.js} +2 -2
- package/dist/atomic/p-dd0aac4c.entry.js +2 -0
- package/dist/atomic/p-dd0aac4c.entry.js.map +1 -0
- package/dist/atomic/{p-20b33c18.entry.js → p-dd24c66a.entry.js} +2 -2
- package/dist/atomic/{p-0f39889d.entry.js → p-dea22a8d.entry.js} +2 -2
- package/dist/atomic/{p-bbfe727a.entry.js → p-df8d38ca.entry.js} +2 -2
- package/dist/atomic/{p-f9608731.entry.js → p-e276c7e0.entry.js} +2 -2
- package/dist/atomic/{p-ce5b896e.entry.js → p-e455330c.entry.js} +2 -2
- package/dist/atomic/{p-59f043a0.entry.js → p-e49ad083.entry.js} +2 -2
- package/dist/atomic/{p-30c09377.entry.js → p-e6871a3f.entry.js} +2 -2
- package/dist/atomic/{p-c9f1790d.entry.js → p-e6dc9de7.entry.js} +2 -2
- package/dist/atomic/{p-6f1bffa2.entry.js → p-e8176ac8.entry.js} +2 -2
- package/dist/atomic/{p-52d5461a.entry.js → p-ed413091.entry.js} +2 -2
- package/dist/atomic/p-ef8f2239.entry.js +2 -0
- package/dist/atomic/{p-345c425d.entry.js.map → p-ef8f2239.entry.js.map} +1 -1
- package/dist/atomic/{p-3549a469.entry.js → p-f0c657f4.entry.js} +2 -2
- package/dist/atomic/{p-f936f55e.entry.js → p-f1241140.entry.js} +2 -2
- package/dist/atomic/p-f37dea9e.entry.js +2 -0
- package/dist/atomic/{p-b6415814.entry.js.map → p-f37dea9e.entry.js.map} +1 -1
- package/dist/atomic/p-f4818e53.entry.js +2 -0
- package/dist/atomic/p-f537c5af.js +2 -0
- package/dist/atomic/p-f537c5af.js.map +1 -0
- package/dist/atomic/{p-dd35e7ad.entry.js → p-f65ca329.entry.js} +2 -2
- package/dist/atomic/{p-6f34dd3a.entry.js → p-f800678c.entry.js} +2 -2
- package/dist/atomic/{p-e7a25b00.entry.js → p-fb517fba.entry.js} +2 -2
- package/dist/atomic/{p-97829295.entry.js → p-fc71835d.entry.js} +2 -2
- package/dist/atomic/{p-a5f66ecd.entry.js → p-fd1ef9e3.entry.js} +2 -2
- package/dist/cjs/_loader.cjs.js +1 -1
- package/dist/cjs/atomic-automatic-facet_2.cjs.entry.js +3 -3
- package/dist/cjs/atomic-breadbox.cjs.entry.js +2 -2
- package/dist/cjs/atomic-category-facet.cjs.entry.js +4 -4
- package/dist/cjs/atomic-citation.cjs.entry.js +1 -1
- package/dist/cjs/atomic-color-facet.cjs.entry.js +3 -3
- package/dist/cjs/atomic-facet-manager.cjs.entry.js +1 -1
- package/dist/cjs/atomic-facet-number-input.cjs.entry.js +2 -2
- package/dist/cjs/atomic-facet.cjs.entry.js +6 -6
- package/dist/cjs/atomic-field-condition.cjs.entry.js +4 -4
- package/dist/cjs/atomic-focus-trap.cjs.entry.js +2 -2
- package/dist/cjs/atomic-folded-result-list.cjs.entry.js +8 -8
- package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
- package/dist/cjs/atomic-generated-answer-feedback-modal.cjs.entry.js +3 -3
- package/dist/cjs/atomic-generated-answer.cjs.entry.js +3 -3
- package/dist/cjs/atomic-html.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-edit-toggle.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-facet.cjs.entry.js +5 -5
- package/dist/cjs/atomic-insight-folded-result-list.cjs.entry.js +8 -8
- package/dist/cjs/atomic-insight-full-search-button.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-generated-answer.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-history-toggle.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-layout.cjs.entry.js +85 -5
- package/dist/cjs/atomic-insight-layout.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-no-results.cjs.entry.js +3 -3
- package/dist/cjs/atomic-insight-numeric-facet.cjs.entry.js +6 -6
- package/dist/cjs/atomic-insight-pager.cjs.entry.js +4 -4
- package/dist/cjs/atomic-insight-query-error.cjs.entry.js +3 -3
- package/dist/cjs/atomic-insight-query-summary.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-refine-modal.cjs.entry.js +4 -5
- package/dist/cjs/atomic-insight-refine-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-refine-toggle.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-result-action-bar.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-result-action.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-result-attach-to-case-action.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-result-attach-to-case-indicator.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-result-children-template.cjs.entry.js +4 -4
- package/dist/cjs/atomic-insight-result-children.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-result-list.cjs.entry.js +8 -8
- package/dist/cjs/atomic-insight-result-quickview-action.cjs.entry.js +3 -3
- package/dist/cjs/atomic-insight-result-template.cjs.entry.js +4 -4
- package/dist/cjs/atomic-insight-result.cjs.entry.js +7 -7
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js +5 -5
- package/dist/cjs/atomic-insight-smart-snippet-feedback-modal.cjs.entry.js +4 -4
- package/dist/cjs/atomic-insight-smart-snippet-suggestions.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-smart-snippet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-tab.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-tabs.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-timeframe-facet.cjs.entry.js +4 -4
- package/dist/cjs/atomic-insight-user-actions-session_2.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-user-actions-toggle.cjs.entry.js +1 -1
- package/dist/cjs/atomic-ipx-body.cjs.entry.js +4 -4
- package/dist/cjs/atomic-ipx-button.cjs.entry.js +2 -2
- package/dist/cjs/atomic-ipx-embedded.cjs.entry.js +3 -3
- package/dist/cjs/atomic-ipx-modal.cjs.entry.js +4 -4
- package/dist/cjs/atomic-ipx-recs-list.cjs.entry.js +8 -8
- package/dist/cjs/atomic-ipx-refine-modal.cjs.entry.js +3 -4
- package/dist/cjs/atomic-ipx-refine-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-ipx-refine-toggle.cjs.entry.js +1 -1
- package/dist/cjs/atomic-ipx-result-link.cjs.entry.js +1 -1
- package/dist/cjs/atomic-ipx-tab.cjs.entry.js +1 -2
- package/dist/cjs/atomic-ipx-tab.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-ipx-tabs.cjs.entry.js +1 -1
- package/dist/cjs/atomic-load-more-results.cjs.entry.js +2 -3
- package/dist/cjs/atomic-load-more-results.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-no-results.cjs.entry.js +3 -3
- package/dist/cjs/atomic-notifications.cjs.entry.js +2 -2
- package/dist/cjs/atomic-numeric-facet.cjs.entry.js +6 -6
- package/dist/cjs/atomic-query-error.cjs.entry.js +3 -3
- package/dist/cjs/atomic-quickview-modal.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview.cjs.entry.js +3 -3
- package/dist/cjs/atomic-rating-facet.cjs.entry.js +4 -4
- package/dist/cjs/atomic-rating-range-facet.cjs.entry.js +3 -3
- package/dist/cjs/atomic-recs-error.cjs.entry.js +3 -3
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +2927 -18
- package/dist/cjs/atomic-recs-interface.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-recs-list.cjs.entry.js +8 -8
- package/dist/cjs/atomic-recs-result-template.cjs.entry.js +4 -4
- package/dist/cjs/atomic-recs-result.cjs.entry.js +6 -6
- package/dist/cjs/atomic-refine-modal.cjs.entry.js +3 -3
- package/dist/cjs/atomic-refine-toggle.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-children-template.cjs.entry.js +4 -4
- package/dist/cjs/atomic-result-children.cjs.entry.js +2 -2
- package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-icon.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-list.cjs.entry.js +9 -9
- package/dist/cjs/atomic-result-localized-text.cjs.entry.js +2 -2
- package/dist/cjs/atomic-result-multi-value-text.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-placeholder_8.cjs.entry.js +7 -7
- package/dist/cjs/atomic-result-printable-uri.cjs.entry.js +2 -2
- package/dist/cjs/atomic-result-section-children.cjs.entry.js +2 -2
- package/dist/cjs/atomic-result-section-emphasized.cjs.entry.js +2 -2
- package/dist/cjs/atomic-result-section-title-metadata.cjs.entry.js +2 -2
- package/dist/cjs/atomic-result-template.cjs.entry.js +4 -4
- package/dist/cjs/atomic-result.cjs.entry.js +6 -6
- package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box-query-suggestions.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box.cjs.entry.js +11 -7
- package/dist/cjs/atomic-search-box.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-segmented-facet.cjs.entry.js +2 -2
- package/dist/cjs/atomic-smart-snippet-answer_2.cjs.entry.js +3 -3
- package/dist/cjs/atomic-smart-snippet-collapse-wrapper_2.cjs.entry.js +3 -3
- package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +4 -4
- package/dist/cjs/atomic-smart-snippet-suggestions.cjs.entry.js +1 -1
- package/dist/cjs/atomic-smart-snippet.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +3 -3
- package/dist/cjs/atomic-sort-expression.cjs.entry.js +3 -3
- package/dist/cjs/atomic-stencil-facet-date-input.cjs.entry.js +3 -3
- package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js +1 -1
- package/dist/cjs/atomic-tab-bar_2.cjs.entry.js +1 -1
- package/dist/cjs/atomic-tab-button.cjs.entry.js +1 -1
- package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
- package/dist/cjs/atomic-timeframe-facet.cjs.entry.js +4 -4
- package/dist/cjs/atomic.cjs.js +1 -1
- package/dist/cjs/{cloned-facet-elements-70cd1601.js → cloned-facet-elements-3c7ea837.js} +2 -2
- package/dist/cjs/{cloned-facet-elements-70cd1601.js.map → cloned-facet-elements-3c7ea837.js.map} +1 -1
- package/dist/cjs/{display-options-69531e8d.js → display-options-10f84088.js} +2 -2
- package/dist/cjs/{display-options-69531e8d.js.map → display-options-10f84088.js.map} +1 -1
- package/dist/cjs/index-757bc886.js +0 -4
- package/dist/cjs/{item-layout-sections-b09ba4b3.js → item-layout-sections-73e27d24.js} +2 -2
- package/dist/cjs/{item-layout-sections-b09ba4b3.js.map → item-layout-sections-73e27d24.js.map} +1 -1
- package/dist/cjs/{item-section-utils-8579462c.js → item-section-utils-37848715.js} +2 -2
- package/dist/cjs/{item-section-utils-8579462c.js.map → item-section-utils-37848715.js.map} +1 -1
- package/dist/cjs/{props-utils-1e4ba1b0.js → props-utils-15a042f3.js} +2 -2
- package/dist/cjs/{props-utils-1e4ba1b0.js.map → props-utils-15a042f3.js.map} +1 -1
- package/dist/cjs/{replace-breakpoint-utils-7a084f54.js → replace-breakpoint-utils-47f2eaa4.js} +1 -2
- package/dist/cjs/replace-breakpoint-utils-47f2eaa4.js.map +1 -0
- package/dist/cjs/{result-template-common-84bd4057.js → result-template-common-bc03b2ad.js} +3 -3
- package/dist/cjs/{result-template-common-84bd4057.js.map → result-template-common-bc03b2ad.js.map} +1 -1
- package/dist/cjs/{stencil-accessibility-utils-aa4c9f6c.js → stencil-accessibility-utils-86cc7071.js} +2 -2
- package/dist/cjs/{stencil-accessibility-utils-aa4c9f6c.js.map → stencil-accessibility-utils-86cc7071.js.map} +1 -1
- package/dist/cjs/{stencil-facet-value-e67c9332.js → stencil-facet-value-5957b403.js} +2 -2
- package/dist/cjs/{stencil-facet-value-e67c9332.js.map → stencil-facet-value-5957b403.js.map} +1 -1
- package/dist/cjs/{stencil-facet-value-checkbox-62f07459.js → stencil-facet-value-checkbox-fed178ad.js} +2 -2
- package/dist/cjs/{stencil-facet-value-checkbox-62f07459.js.map → stencil-facet-value-checkbox-fed178ad.js.map} +1 -1
- package/dist/cjs/{stencil-item-list-common-17bd1046.js → stencil-item-list-common-b08abf21.js} +4 -4
- package/dist/cjs/{stencil-item-list-common-17bd1046.js.map → stencil-item-list-common-b08abf21.js.map} +1 -1
- package/dist/cjs/{stencil-suggestion-manager-2cba6d69.js → stencil-suggestion-manager-88cb88f2.js} +2 -2
- package/dist/cjs/stencil-suggestion-manager-88cb88f2.js.map +1 -0
- package/dist/cjs/{stencil-values-container-9f50ec1a.js → stencil-values-container-d20f9b28.js} +2 -2
- package/dist/cjs/{stencil-values-container-9f50ec1a.js.map → stencil-values-container-d20f9b28.js.map} +1 -1
- package/dist/cjs/{store-82abd941.js → store-7927ea61.js} +2 -33
- package/dist/cjs/store-7927ea61.js.map +1 -0
- package/dist/cjs/{timeframe-facet-common-b5535cca.js → timeframe-facet-common-4ea96ccb.js} +2 -2
- package/dist/cjs/{timeframe-facet-common-b5535cca.js.map → timeframe-facet-common-4ea96ccb.js.map} +1 -1
- package/dist/cjs/{utils-7153ae6b.js → utils-12b49e87.js} +1 -18
- package/dist/cjs/utils-12b49e87.js.map +1 -0
- package/dist/cjs/version.cjs.js +1 -1
- package/dist/esm/_loader.js +1 -1
- package/dist/esm/atomic-automatic-facet_2.entry.js +3 -3
- package/dist/esm/atomic-breadbox.entry.js +2 -2
- package/dist/esm/atomic-category-facet.entry.js +4 -4
- package/dist/esm/atomic-citation.entry.js +1 -1
- package/dist/esm/atomic-color-facet.entry.js +3 -3
- package/dist/esm/atomic-facet-manager.entry.js +1 -1
- package/dist/esm/atomic-facet-number-input.entry.js +2 -2
- package/dist/esm/atomic-facet.entry.js +6 -6
- package/dist/esm/atomic-field-condition.entry.js +4 -4
- package/dist/esm/atomic-focus-trap.entry.js +2 -2
- package/dist/esm/atomic-folded-result-list.entry.js +8 -8
- package/dist/esm/atomic-format-currency.entry.js +1 -1
- package/dist/esm/atomic-format-number.entry.js +1 -1
- package/dist/esm/atomic-format-unit.entry.js +1 -1
- package/dist/esm/atomic-generated-answer-feedback-modal.entry.js +3 -3
- package/dist/esm/atomic-generated-answer.entry.js +3 -3
- package/dist/esm/atomic-html.entry.js +1 -1
- package/dist/esm/atomic-insight-edit-toggle.entry.js +1 -1
- package/dist/esm/atomic-insight-facet.entry.js +5 -5
- package/dist/esm/atomic-insight-folded-result-list.entry.js +8 -8
- package/dist/esm/atomic-insight-full-search-button.entry.js +1 -1
- package/dist/esm/atomic-insight-generated-answer.entry.js +2 -2
- package/dist/esm/atomic-insight-history-toggle.entry.js +1 -1
- package/dist/esm/atomic-insight-layout.entry.js +83 -3
- package/dist/esm/atomic-insight-layout.entry.js.map +1 -1
- package/dist/esm/atomic-insight-no-results.entry.js +3 -3
- package/dist/esm/atomic-insight-numeric-facet.entry.js +6 -6
- package/dist/esm/atomic-insight-pager.entry.js +4 -4
- package/dist/esm/atomic-insight-query-error.entry.js +3 -3
- package/dist/esm/atomic-insight-query-summary.entry.js +2 -2
- package/dist/esm/atomic-insight-refine-modal.entry.js +4 -5
- package/dist/esm/atomic-insight-refine-modal.entry.js.map +1 -1
- package/dist/esm/atomic-insight-refine-toggle.entry.js +1 -1
- package/dist/esm/atomic-insight-result-action-bar.entry.js +2 -2
- package/dist/esm/atomic-insight-result-action.entry.js +1 -1
- package/dist/esm/atomic-insight-result-attach-to-case-action.entry.js +1 -1
- package/dist/esm/atomic-insight-result-attach-to-case-indicator.entry.js +1 -1
- package/dist/esm/atomic-insight-result-children-template.entry.js +4 -4
- package/dist/esm/atomic-insight-result-children.entry.js +2 -2
- package/dist/esm/atomic-insight-result-list.entry.js +8 -8
- package/dist/esm/atomic-insight-result-quickview-action.entry.js +3 -3
- package/dist/esm/atomic-insight-result-template.entry.js +4 -4
- package/dist/esm/atomic-insight-result.entry.js +7 -7
- package/dist/esm/atomic-insight-search-box.entry.js +5 -5
- package/dist/esm/atomic-insight-smart-snippet-feedback-modal.entry.js +4 -4
- package/dist/esm/atomic-insight-smart-snippet-suggestions.entry.js +1 -1
- package/dist/esm/atomic-insight-smart-snippet.entry.js +1 -1
- package/dist/esm/atomic-insight-tab.entry.js +2 -2
- package/dist/esm/atomic-insight-tabs.entry.js +1 -1
- package/dist/esm/atomic-insight-timeframe-facet.entry.js +4 -4
- package/dist/esm/atomic-insight-user-actions-session_2.entry.js +1 -1
- package/dist/esm/atomic-insight-user-actions-toggle.entry.js +1 -1
- package/dist/esm/atomic-ipx-body.entry.js +4 -4
- package/dist/esm/atomic-ipx-button.entry.js +2 -2
- package/dist/esm/atomic-ipx-embedded.entry.js +3 -3
- package/dist/esm/atomic-ipx-modal.entry.js +4 -4
- package/dist/esm/atomic-ipx-recs-list.entry.js +8 -8
- package/dist/esm/atomic-ipx-refine-modal.entry.js +3 -4
- package/dist/esm/atomic-ipx-refine-modal.entry.js.map +1 -1
- package/dist/esm/atomic-ipx-refine-toggle.entry.js +1 -1
- package/dist/esm/atomic-ipx-result-link.entry.js +1 -1
- package/dist/esm/atomic-ipx-tab.entry.js +1 -2
- package/dist/esm/atomic-ipx-tab.entry.js.map +1 -1
- package/dist/esm/atomic-ipx-tabs.entry.js +1 -1
- package/dist/esm/atomic-load-more-results.entry.js +2 -3
- package/dist/esm/atomic-load-more-results.entry.js.map +1 -1
- package/dist/esm/atomic-no-results.entry.js +3 -3
- package/dist/esm/atomic-notifications.entry.js +2 -2
- package/dist/esm/atomic-numeric-facet.entry.js +6 -6
- package/dist/esm/atomic-query-error.entry.js +3 -3
- package/dist/esm/atomic-quickview-modal.entry.js +1 -1
- package/dist/esm/atomic-quickview.entry.js +3 -3
- package/dist/esm/atomic-rating-facet.entry.js +4 -4
- package/dist/esm/atomic-rating-range-facet.entry.js +3 -3
- package/dist/esm/atomic-recs-error.entry.js +3 -3
- package/dist/esm/atomic-recs-interface.entry.js +2919 -10
- package/dist/esm/atomic-recs-interface.entry.js.map +1 -1
- package/dist/esm/atomic-recs-list.entry.js +8 -8
- package/dist/esm/atomic-recs-result-template.entry.js +4 -4
- package/dist/esm/atomic-recs-result.entry.js +6 -6
- package/dist/esm/atomic-refine-modal.entry.js +3 -3
- package/dist/esm/atomic-refine-toggle.entry.js +1 -1
- package/dist/esm/atomic-result-children-template.entry.js +4 -4
- package/dist/esm/atomic-result-children.entry.js +2 -2
- package/dist/esm/atomic-result-fields-list.entry.js +1 -1
- package/dist/esm/atomic-result-icon.entry.js +1 -1
- package/dist/esm/atomic-result-link.entry.js +1 -1
- package/dist/esm/atomic-result-list.entry.js +9 -9
- package/dist/esm/atomic-result-localized-text.entry.js +2 -2
- package/dist/esm/atomic-result-multi-value-text.entry.js +1 -1
- package/dist/esm/atomic-result-placeholder_8.entry.js +7 -7
- package/dist/esm/atomic-result-printable-uri.entry.js +2 -2
- package/dist/esm/atomic-result-section-children.entry.js +2 -2
- package/dist/esm/atomic-result-section-emphasized.entry.js +2 -2
- package/dist/esm/atomic-result-section-title-metadata.entry.js +2 -2
- package/dist/esm/atomic-result-template.entry.js +4 -4
- package/dist/esm/atomic-result.entry.js +6 -6
- package/dist/esm/atomic-search-box-instant-results.entry.js +1 -1
- package/dist/esm/atomic-search-box-query-suggestions.entry.js +1 -1
- package/dist/esm/atomic-search-box.entry.js +11 -7
- package/dist/esm/atomic-search-box.entry.js.map +1 -1
- package/dist/esm/atomic-segmented-facet.entry.js +2 -2
- package/dist/esm/atomic-smart-snippet-answer_2.entry.js +3 -3
- package/dist/esm/atomic-smart-snippet-collapse-wrapper_2.entry.js +3 -3
- package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +4 -4
- package/dist/esm/atomic-smart-snippet-suggestions.entry.js +1 -1
- package/dist/esm/atomic-smart-snippet.entry.js +2 -2
- package/dist/esm/atomic-sort-dropdown.entry.js +3 -3
- package/dist/esm/atomic-sort-expression.entry.js +3 -3
- package/dist/esm/atomic-stencil-facet-date-input.entry.js +3 -3
- package/dist/esm/atomic-suggestion-renderer.entry.js +1 -1
- package/dist/esm/atomic-tab-bar_2.entry.js +1 -1
- package/dist/esm/atomic-tab-button.entry.js +1 -1
- package/dist/esm/atomic-tab-manager.entry.js +1 -1
- package/dist/esm/atomic-timeframe-facet.entry.js +4 -4
- package/dist/esm/atomic.js +1 -1
- package/dist/esm/{cloned-facet-elements-807b566b.js → cloned-facet-elements-82071d0c.js} +2 -2
- package/dist/esm/{cloned-facet-elements-807b566b.js.map → cloned-facet-elements-82071d0c.js.map} +1 -1
- package/dist/esm/{display-options-1199eed5.js → display-options-b7c33617.js} +2 -2
- package/dist/esm/{display-options-1199eed5.js.map → display-options-b7c33617.js.map} +1 -1
- package/dist/esm/index-3f35faca.js +0 -4
- package/dist/esm/{item-layout-sections-8afb5049.js → item-layout-sections-26123790.js} +2 -2
- package/dist/esm/{item-layout-sections-8afb5049.js.map → item-layout-sections-26123790.js.map} +1 -1
- package/dist/esm/{item-section-utils-46828f30.js → item-section-utils-d8aa24b7.js} +2 -2
- package/dist/esm/{item-section-utils-46828f30.js.map → item-section-utils-d8aa24b7.js.map} +1 -1
- package/dist/esm/{props-utils-e97ad6bd.js → props-utils-6040b5d2.js} +2 -2
- package/dist/esm/{props-utils-e97ad6bd.js.map → props-utils-6040b5d2.js.map} +1 -1
- package/dist/esm/{replace-breakpoint-utils-7a336631.js → replace-breakpoint-utils-13ff9ca5.js} +2 -2
- package/dist/esm/replace-breakpoint-utils-13ff9ca5.js.map +1 -0
- package/dist/esm/{result-template-common-995b94f8.js → result-template-common-47799c7c.js} +3 -3
- package/dist/esm/{result-template-common-995b94f8.js.map → result-template-common-47799c7c.js.map} +1 -1
- package/dist/esm/{stencil-accessibility-utils-196a08f3.js → stencil-accessibility-utils-ae75044b.js} +2 -2
- package/dist/esm/{stencil-accessibility-utils-196a08f3.js.map → stencil-accessibility-utils-ae75044b.js.map} +1 -1
- package/dist/esm/{stencil-facet-value-30dc9b6c.js → stencil-facet-value-9deafe8e.js} +2 -2
- package/dist/esm/{stencil-facet-value-30dc9b6c.js.map → stencil-facet-value-9deafe8e.js.map} +1 -1
- package/dist/esm/{stencil-facet-value-checkbox-0637f7f8.js → stencil-facet-value-checkbox-c0df7c4e.js} +2 -2
- package/dist/esm/{stencil-facet-value-checkbox-0637f7f8.js.map → stencil-facet-value-checkbox-c0df7c4e.js.map} +1 -1
- package/dist/esm/{stencil-item-list-common-fc95e16b.js → stencil-item-list-common-d2833d51.js} +4 -4
- package/dist/esm/{stencil-item-list-common-fc95e16b.js.map → stencil-item-list-common-d2833d51.js.map} +1 -1
- package/dist/esm/{stencil-suggestion-manager-376f83e8.js → stencil-suggestion-manager-1f4ed8d0.js} +2 -2
- package/dist/esm/stencil-suggestion-manager-1f4ed8d0.js.map +1 -0
- package/dist/esm/{stencil-values-container-55a7e816.js → stencil-values-container-9b9cd73f.js} +2 -2
- package/dist/esm/{stencil-values-container-55a7e816.js.map → stencil-values-container-9b9cd73f.js.map} +1 -1
- package/dist/esm/{store-015afa83.js → store-7d2c2a8c.js} +3 -31
- package/dist/esm/store-7d2c2a8c.js.map +1 -0
- package/dist/esm/{timeframe-facet-common-eb1016d2.js → timeframe-facet-common-55fc72f3.js} +2 -2
- package/dist/esm/{timeframe-facet-common-eb1016d2.js.map → timeframe-facet-common-55fc72f3.js.map} +1 -1
- package/dist/esm/{utils-7161486d.js → utils-6400ebde.js} +2 -18
- package/dist/esm/utils-6400ebde.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts +2 -0
- package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts +1 -0
- package/dist/types/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.d.ts +2 -0
- package/dist/types/components/common/breadbox/breadcrumb-button.d.ts +2 -0
- package/dist/types/components/insight/atomic-insight-interface/atomic-insight-interface.d.ts +35 -42
- package/dist/types/components/insight/index.d.ts +1 -1
- package/dist/types/components/search/atomic-search-box/atomic-search-box.d.ts +1 -0
- package/dist/types/components.d.ts +4 -113
- package/dist/types/directives/hierarchical-path.d.ts +1 -1
- package/docs/atomic-docs.json +6 -421
- package/package.json +1 -1
- package/dist/atomic/components/analytics-config.js +0 -2918
- package/dist/atomic/components/analytics-config.js.map +0 -1
- package/dist/atomic/components/atomic-insight-interface.d.ts +0 -11
- package/dist/atomic/components/atomic-insight-interface.js +0 -332
- package/dist/atomic/components/atomic-insight-interface.js.map +0 -1
- package/dist/atomic/components/insight-layout.js +0 -87
- package/dist/atomic/components/insight-layout.js.map +0 -1
- package/dist/atomic/p-0e62bdd6.js +0 -2
- package/dist/atomic/p-0e62bdd6.js.map +0 -1
- package/dist/atomic/p-16f4ce98.js +0 -2
- package/dist/atomic/p-16f4ce98.js.map +0 -1
- package/dist/atomic/p-26598ee0.js +0 -2
- package/dist/atomic/p-28e882e8.js +0 -2
- package/dist/atomic/p-2e721bf7.entry.js +0 -2
- package/dist/atomic/p-2e721bf7.entry.js.map +0 -1
- package/dist/atomic/p-345c425d.entry.js +0 -2
- package/dist/atomic/p-4913eb5c.js +0 -2
- package/dist/atomic/p-4913eb5c.js.map +0 -1
- package/dist/atomic/p-5387f396.entry.js +0 -2
- package/dist/atomic/p-5387f396.entry.js.map +0 -1
- package/dist/atomic/p-56c97c3e.js +0 -2
- package/dist/atomic/p-768b172e.entry.js +0 -2
- package/dist/atomic/p-768b172e.entry.js.map +0 -1
- package/dist/atomic/p-83d3857f.entry.js.map +0 -1
- package/dist/atomic/p-a12e1c59.js +0 -2
- package/dist/atomic/p-a12e1c59.js.map +0 -1
- package/dist/atomic/p-a1522fe5.entry.js +0 -2
- package/dist/atomic/p-a1ee594f.entry.js +0 -2
- package/dist/atomic/p-b6415814.entry.js +0 -2
- package/dist/atomic/p-c2b4b401.entry.js +0 -2
- package/dist/atomic/p-c7af4b9e.entry.js +0 -2
- package/dist/atomic/p-cc0bf58b.js +0 -2
- package/dist/atomic/p-cc0bf58b.js.map +0 -1
- package/dist/cjs/analytics-config-c215586d.js +0 -2927
- package/dist/cjs/analytics-config-c215586d.js.map +0 -1
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +0 -307
- package/dist/cjs/atomic-insight-interface.cjs.entry.js.map +0 -1
- package/dist/cjs/insight-layout-b6ff92fd.js +0 -90
- package/dist/cjs/insight-layout-b6ff92fd.js.map +0 -1
- package/dist/cjs/replace-breakpoint-utils-7a084f54.js.map +0 -1
- package/dist/cjs/stencil-suggestion-manager-2cba6d69.js.map +0 -1
- package/dist/cjs/store-82abd941.js.map +0 -1
- package/dist/cjs/utils-7153ae6b.js.map +0 -1
- package/dist/esm/analytics-config-f3ba6c2b.js +0 -2918
- package/dist/esm/analytics-config-f3ba6c2b.js.map +0 -1
- package/dist/esm/atomic-insight-interface.entry.js +0 -303
- package/dist/esm/atomic-insight-interface.entry.js.map +0 -1
- package/dist/esm/insight-layout-a1e4b795.js +0 -87
- package/dist/esm/insight-layout-a1e4b795.js.map +0 -1
- package/dist/esm/replace-breakpoint-utils-7a336631.js.map +0 -1
- package/dist/esm/stencil-suggestion-manager-376f83e8.js.map +0 -1
- package/dist/esm/store-015afa83.js.map +0 -1
- package/dist/esm/utils-7161486d.js.map +0 -1
- /package/dist/atomic/{p-27cf779a.js.map → p-025a346a.js.map} +0 -0
- /package/dist/atomic/{p-7e971d15.entry.js.map → p-044de1f9.entry.js.map} +0 -0
- /package/dist/atomic/{p-fe59fb2d.entry.js.map → p-0535b93d.entry.js.map} +0 -0
- /package/dist/atomic/{p-31a13850.js.map → p-0580b866.js.map} +0 -0
- /package/dist/atomic/{p-0edea6f9.entry.js.map → p-05f1ff6f.entry.js.map} +0 -0
- /package/dist/atomic/{p-3e9db2b5.entry.js.map → p-088d634c.entry.js.map} +0 -0
- /package/dist/atomic/{p-4bdc6d5a.entry.js.map → p-0ee7cab8.entry.js.map} +0 -0
- /package/dist/atomic/{p-0f449e9d.entry.js.map → p-14bad769.entry.js.map} +0 -0
- /package/dist/atomic/{p-01511388.entry.js.map → p-15547bd5.entry.js.map} +0 -0
- /package/dist/atomic/{p-b313058c.entry.js.map → p-182f9112.entry.js.map} +0 -0
- /package/dist/atomic/{p-00069a4b.entry.js.map → p-1910eb7f.entry.js.map} +0 -0
- /package/dist/atomic/{p-85145c88.entry.js.map → p-1c8bcadf.entry.js.map} +0 -0
- /package/dist/atomic/{p-cafa4083.entry.js.map → p-21ab7750.entry.js.map} +0 -0
- /package/dist/atomic/{p-9a6ec803.entry.js.map → p-229018fa.entry.js.map} +0 -0
- /package/dist/atomic/{p-89d8bb0d.entry.js.map → p-22b76c96.entry.js.map} +0 -0
- /package/dist/atomic/{p-36f63642.entry.js.map → p-26e0c1f8.entry.js.map} +0 -0
- /package/dist/atomic/{p-c4fb6426.entry.js.map → p-2e13e2c0.entry.js.map} +0 -0
- /package/dist/atomic/{p-6098b906.entry.js.map → p-2f437b47.entry.js.map} +0 -0
- /package/dist/atomic/{p-998393ec.entry.js.map → p-2f517a54.entry.js.map} +0 -0
- /package/dist/atomic/{p-06284430.entry.js.map → p-318c96f5.entry.js.map} +0 -0
- /package/dist/atomic/{p-0ed76e65.entry.js.map → p-3272a04b.entry.js.map} +0 -0
- /package/dist/atomic/{p-d211a422.entry.js.map → p-3291adda.entry.js.map} +0 -0
- /package/dist/atomic/{p-dbc0ce5c.entry.js.map → p-33245038.entry.js.map} +0 -0
- /package/dist/atomic/{p-fa658ef2.entry.js.map → p-35c2ee5f.entry.js.map} +0 -0
- /package/dist/atomic/{p-3d55fce6.entry.js.map → p-36e2c945.entry.js.map} +0 -0
- /package/dist/atomic/{p-af1b4924.entry.js.map → p-3bd8469f.entry.js.map} +0 -0
- /package/dist/atomic/{p-e62fc40e.js.map → p-3ef52afa.js.map} +0 -0
- /package/dist/atomic/{p-170c7da6.entry.js.map → p-400c28b6.entry.js.map} +0 -0
- /package/dist/atomic/{p-fafd5042.entry.js.map → p-448091f7.entry.js.map} +0 -0
- /package/dist/atomic/{p-fe3cd55b.entry.js.map → p-44d96103.entry.js.map} +0 -0
- /package/dist/atomic/{p-da845e35.entry.js.map → p-463336ca.entry.js.map} +0 -0
- /package/dist/atomic/{p-f9dd14b2.entry.js.map → p-479cb38a.entry.js.map} +0 -0
- /package/dist/atomic/{p-a9383817.entry.js.map → p-47b41b27.entry.js.map} +0 -0
- /package/dist/atomic/{p-be2a43f4.entry.js.map → p-48bab1a6.entry.js.map} +0 -0
- /package/dist/atomic/{p-0c8e7d5f.entry.js.map → p-4cb91ee7.entry.js.map} +0 -0
- /package/dist/atomic/{p-23d4dc54.entry.js.map → p-558f2191.entry.js.map} +0 -0
- /package/dist/atomic/{p-8572a953.entry.js.map → p-55c41e00.entry.js.map} +0 -0
- /package/dist/atomic/{p-2e4628bb.entry.js.map → p-57049cd2.entry.js.map} +0 -0
- /package/dist/atomic/{p-edd4d5f7.js.map → p-5a2ef889.js.map} +0 -0
- /package/dist/atomic/{p-dc128135.entry.js.map → p-5a83b7e5.entry.js.map} +0 -0
- /package/dist/atomic/{p-10b5e0f3.entry.js.map → p-5b8cc4bc.entry.js.map} +0 -0
- /package/dist/atomic/{p-87f69e53.entry.js.map → p-5cab535b.entry.js.map} +0 -0
- /package/dist/atomic/{p-56c97c3e.js.map → p-5d0fc7e2.js.map} +0 -0
- /package/dist/atomic/{p-740cd5bc.entry.js.map → p-6439156c.entry.js.map} +0 -0
- /package/dist/atomic/{p-7e9a1a1a.entry.js.map → p-66166975.entry.js.map} +0 -0
- /package/dist/atomic/{p-97538903.entry.js.map → p-6698d5e9.entry.js.map} +0 -0
- /package/dist/atomic/{p-0610b3e7.entry.js.map → p-6819f12c.entry.js.map} +0 -0
- /package/dist/atomic/{p-28e882e8.js.map → p-6b3429d3.js.map} +0 -0
- /package/dist/atomic/{p-6078667f.entry.js.map → p-7045745d.entry.js.map} +0 -0
- /package/dist/atomic/{p-a130b00b.entry.js.map → p-70747efa.entry.js.map} +0 -0
- /package/dist/atomic/{p-4830b9bb.entry.js.map → p-7242b46e.entry.js.map} +0 -0
- /package/dist/atomic/{p-3af2fca0.js.map → p-7427daa3.js.map} +0 -0
- /package/dist/atomic/{p-b320f270.entry.js.map → p-76c14d82.entry.js.map} +0 -0
- /package/dist/atomic/{p-1435fb6f.entry.js.map → p-7741124a.entry.js.map} +0 -0
- /package/dist/atomic/{p-cdeb5f2a.entry.js.map → p-77d00da1.entry.js.map} +0 -0
- /package/dist/atomic/{p-519d9abd.entry.js.map → p-7fd58269.entry.js.map} +0 -0
- /package/dist/atomic/{p-f76b7ac3.entry.js.map → p-80290dd3.entry.js.map} +0 -0
- /package/dist/atomic/{p-b6ae0244.entry.js.map → p-81bdbd07.entry.js.map} +0 -0
- /package/dist/atomic/{p-dc28ee14.js.map → p-828ab4ff.js.map} +0 -0
- /package/dist/atomic/{p-723f76a1.entry.js.map → p-82cd6398.entry.js.map} +0 -0
- /package/dist/atomic/{p-fdcd187d.entry.js.map → p-851b9735.entry.js.map} +0 -0
- /package/dist/atomic/{p-40c1dfcb.entry.js.map → p-874f0a4c.entry.js.map} +0 -0
- /package/dist/atomic/{p-373448df.entry.js.map → p-8b0cf1d4.entry.js.map} +0 -0
- /package/dist/atomic/{p-36112c34.entry.js.map → p-8b0d881e.entry.js.map} +0 -0
- /package/dist/atomic/{p-ee957926.entry.js.map → p-8d5228da.entry.js.map} +0 -0
- /package/dist/atomic/{p-c25f1437.entry.js.map → p-955092ed.entry.js.map} +0 -0
- /package/dist/atomic/{p-47ab6c9f.entry.js.map → p-99d4c4bf.entry.js.map} +0 -0
- /package/dist/atomic/{p-edede7d1.entry.js.map → p-9aad555a.entry.js.map} +0 -0
- /package/dist/atomic/{p-2250f505.js.map → p-9ae68e86.js.map} +0 -0
- /package/dist/atomic/{p-00a6ab8c.entry.js.map → p-a0ebbbdf.entry.js.map} +0 -0
- /package/dist/atomic/{p-7fd5b6ac.entry.js.map → p-a1798150.entry.js.map} +0 -0
- /package/dist/atomic/{p-9239be63.entry.js.map → p-a54f3f24.entry.js.map} +0 -0
- /package/dist/atomic/{p-24fd7df6.entry.js.map → p-a6dde0f6.entry.js.map} +0 -0
- /package/dist/atomic/{p-a1e5f767.entry.js.map → p-a78cbb80.entry.js.map} +0 -0
- /package/dist/atomic/{p-59b15bd6.entry.js.map → p-ae69f519.entry.js.map} +0 -0
- /package/dist/atomic/{p-98dd6df1.entry.js.map → p-b06de6f8.entry.js.map} +0 -0
- /package/dist/atomic/{p-fdd0aa42.entry.js.map → p-b1b583a0.entry.js.map} +0 -0
- /package/dist/atomic/{p-3c9289b5.js.map → p-b29d121c.js.map} +0 -0
- /package/dist/atomic/{p-cb3fd0f4.entry.js.map → p-b84108f3.entry.js.map} +0 -0
- /package/dist/atomic/{p-fb1a1e2e.entry.js.map → p-b85c2c46.entry.js.map} +0 -0
- /package/dist/atomic/{p-9260dd7d.entry.js.map → p-b9eeac20.entry.js.map} +0 -0
- /package/dist/atomic/{p-b2b9e83f.entry.js.map → p-bc43df67.entry.js.map} +0 -0
- /package/dist/atomic/{p-93601dc0.entry.js.map → p-bd01acd5.entry.js.map} +0 -0
- /package/dist/atomic/{p-416d088e.entry.js.map → p-be011bd1.entry.js.map} +0 -0
- /package/dist/atomic/{p-4f4c9a03.entry.js.map → p-c2a5dac0.entry.js.map} +0 -0
- /package/dist/atomic/{p-93f1d551.entry.js.map → p-c5164dbf.entry.js.map} +0 -0
- /package/dist/atomic/{p-3622ed6c.js.map → p-c619df9b.js.map} +0 -0
- /package/dist/atomic/{p-1bbaf206.entry.js.map → p-c8190eb9.entry.js.map} +0 -0
- /package/dist/atomic/{p-5ca21deb.js.map → p-ca37969c.js.map} +0 -0
- /package/dist/atomic/{p-7cced247.entry.js.map → p-d0ab0125.entry.js.map} +0 -0
- /package/dist/atomic/{p-2fb49fe8.entry.js.map → p-d8caa4d8.entry.js.map} +0 -0
- /package/dist/atomic/{p-62e85c20.entry.js.map → p-da87ef51.entry.js.map} +0 -0
- /package/dist/atomic/{p-367ec37d.entry.js.map → p-db2d92c5.entry.js.map} +0 -0
- /package/dist/atomic/{p-dbf0c5a3.entry.js.map → p-db3b11ca.entry.js.map} +0 -0
- /package/dist/atomic/{p-20b33c18.entry.js.map → p-dd24c66a.entry.js.map} +0 -0
- /package/dist/atomic/{p-0f39889d.entry.js.map → p-dea22a8d.entry.js.map} +0 -0
- /package/dist/atomic/{p-bbfe727a.entry.js.map → p-df8d38ca.entry.js.map} +0 -0
- /package/dist/atomic/{p-f9608731.entry.js.map → p-e276c7e0.entry.js.map} +0 -0
- /package/dist/atomic/{p-ce5b896e.entry.js.map → p-e455330c.entry.js.map} +0 -0
- /package/dist/atomic/{p-59f043a0.entry.js.map → p-e49ad083.entry.js.map} +0 -0
- /package/dist/atomic/{p-30c09377.entry.js.map → p-e6871a3f.entry.js.map} +0 -0
- /package/dist/atomic/{p-c9f1790d.entry.js.map → p-e6dc9de7.entry.js.map} +0 -0
- /package/dist/atomic/{p-6f1bffa2.entry.js.map → p-e8176ac8.entry.js.map} +0 -0
- /package/dist/atomic/{p-52d5461a.entry.js.map → p-ed413091.entry.js.map} +0 -0
- /package/dist/atomic/{p-3549a469.entry.js.map → p-f0c657f4.entry.js.map} +0 -0
- /package/dist/atomic/{p-f936f55e.entry.js.map → p-f1241140.entry.js.map} +0 -0
- /package/dist/atomic/{p-c2b4b401.entry.js.map → p-f4818e53.entry.js.map} +0 -0
- /package/dist/atomic/{p-dd35e7ad.entry.js.map → p-f65ca329.entry.js.map} +0 -0
- /package/dist/atomic/{p-6f34dd3a.entry.js.map → p-f800678c.entry.js.map} +0 -0
- /package/dist/atomic/{p-e7a25b00.entry.js.map → p-fb517fba.entry.js.map} +0 -0
- /package/dist/atomic/{p-97829295.entry.js.map → p-fc71835d.entry.js.map} +0 -0
- /package/dist/atomic/{p-a5f66ecd.entry.js.map → p-fd1ef9e3.entry.js.map} +0 -0
@@ -1,15 +1,2924 @@
|
|
1
|
-
import { r as registerInstance, s as setNonce,
|
1
|
+
import { h, r as registerInstance, s as setNonce, g as getElement } from './index-3f35faca.js';
|
2
2
|
import { m as markParentAsReady } from './init-queue-fbe942c3.js';
|
3
3
|
import { loadRecommendationActions, loadSearchConfigurationActions, EcommerceDefaultFieldsToInclude, loadFieldActions, buildRecommendationEngine } from '@coveo/headless/recommendation';
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import './
|
8
|
-
import './
|
9
|
-
import '@coveo/headless';
|
10
|
-
import './purify-c7ebd240.js';
|
4
|
+
import { A as ArrayProp } from './props-utils-6040b5d2.js';
|
5
|
+
import { d as dayjs } from './dayjs.min-d04628c6.js';
|
6
|
+
import { VERSION } from '@coveo/headless';
|
7
|
+
import { D as DOMPurify } from './purify-c7ebd240.js';
|
8
|
+
import { u as unsetLoadingFlag, s as setLoadingFlag, a as createBaseStore } from './store-7d2c2a8c.js';
|
11
9
|
import '@coveo/bueno';
|
12
|
-
import './utils-
|
10
|
+
import './utils-6400ebde.js';
|
11
|
+
import './_commonjsHelpers-1789f0cf.js';
|
12
|
+
|
13
|
+
const isString = obj => typeof obj === 'string';
|
14
|
+
const defer = () => {
|
15
|
+
let res;
|
16
|
+
let rej;
|
17
|
+
const promise = new Promise((resolve, reject) => {
|
18
|
+
res = resolve;
|
19
|
+
rej = reject;
|
20
|
+
});
|
21
|
+
promise.resolve = res;
|
22
|
+
promise.reject = rej;
|
23
|
+
return promise;
|
24
|
+
};
|
25
|
+
const makeString = object => {
|
26
|
+
if (object == null) return '';
|
27
|
+
return '' + object;
|
28
|
+
};
|
29
|
+
const copy = (a, s, t) => {
|
30
|
+
a.forEach(m => {
|
31
|
+
if (s[m]) t[m] = s[m];
|
32
|
+
});
|
33
|
+
};
|
34
|
+
const lastOfPathSeparatorRegExp = /###/g;
|
35
|
+
const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
|
36
|
+
const canNotTraverseDeeper = object => !object || isString(object);
|
37
|
+
const getLastOfPath = (object, path, Empty) => {
|
38
|
+
const stack = !isString(path) ? path : path.split('.');
|
39
|
+
let stackIndex = 0;
|
40
|
+
while (stackIndex < stack.length - 1) {
|
41
|
+
if (canNotTraverseDeeper(object)) return {};
|
42
|
+
const key = cleanKey(stack[stackIndex]);
|
43
|
+
if (!object[key] && Empty) object[key] = new Empty();
|
44
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
45
|
+
object = object[key];
|
46
|
+
} else {
|
47
|
+
object = {};
|
48
|
+
}
|
49
|
+
++stackIndex;
|
50
|
+
}
|
51
|
+
if (canNotTraverseDeeper(object)) return {};
|
52
|
+
return {
|
53
|
+
obj: object,
|
54
|
+
k: cleanKey(stack[stackIndex])
|
55
|
+
};
|
56
|
+
};
|
57
|
+
const setPath = (object, path, newValue) => {
|
58
|
+
const {
|
59
|
+
obj,
|
60
|
+
k
|
61
|
+
} = getLastOfPath(object, path, Object);
|
62
|
+
if (obj !== undefined || path.length === 1) {
|
63
|
+
obj[k] = newValue;
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
let e = path[path.length - 1];
|
67
|
+
let p = path.slice(0, path.length - 1);
|
68
|
+
let last = getLastOfPath(object, p, Object);
|
69
|
+
while (last.obj === undefined && p.length) {
|
70
|
+
e = `${p[p.length - 1]}.${e}`;
|
71
|
+
p = p.slice(0, p.length - 1);
|
72
|
+
last = getLastOfPath(object, p, Object);
|
73
|
+
if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
|
74
|
+
last.obj = undefined;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
last.obj[`${last.k}.${e}`] = newValue;
|
78
|
+
};
|
79
|
+
const pushPath = (object, path, newValue, concat) => {
|
80
|
+
const {
|
81
|
+
obj,
|
82
|
+
k
|
83
|
+
} = getLastOfPath(object, path, Object);
|
84
|
+
obj[k] = obj[k] || [];
|
85
|
+
obj[k].push(newValue);
|
86
|
+
};
|
87
|
+
const getPath = (object, path) => {
|
88
|
+
const {
|
89
|
+
obj,
|
90
|
+
k
|
91
|
+
} = getLastOfPath(object, path);
|
92
|
+
if (!obj) return undefined;
|
93
|
+
if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
|
94
|
+
return obj[k];
|
95
|
+
};
|
96
|
+
const getPathWithDefaults = (data, defaultData, key) => {
|
97
|
+
const value = getPath(data, key);
|
98
|
+
if (value !== undefined) {
|
99
|
+
return value;
|
100
|
+
}
|
101
|
+
return getPath(defaultData, key);
|
102
|
+
};
|
103
|
+
const deepExtend = (target, source, overwrite) => {
|
104
|
+
for (const prop in source) {
|
105
|
+
if (prop !== '__proto__' && prop !== 'constructor') {
|
106
|
+
if (prop in target) {
|
107
|
+
if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
|
108
|
+
if (overwrite) target[prop] = source[prop];
|
109
|
+
} else {
|
110
|
+
deepExtend(target[prop], source[prop], overwrite);
|
111
|
+
}
|
112
|
+
} else {
|
113
|
+
target[prop] = source[prop];
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
return target;
|
118
|
+
};
|
119
|
+
const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
120
|
+
var _entityMap = {
|
121
|
+
'&': '&',
|
122
|
+
'<': '<',
|
123
|
+
'>': '>',
|
124
|
+
'"': '"',
|
125
|
+
"'": ''',
|
126
|
+
'/': '/'
|
127
|
+
};
|
128
|
+
const escape = data => {
|
129
|
+
if (isString(data)) {
|
130
|
+
return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
|
131
|
+
}
|
132
|
+
return data;
|
133
|
+
};
|
134
|
+
class RegExpCache {
|
135
|
+
constructor(capacity) {
|
136
|
+
this.capacity = capacity;
|
137
|
+
this.regExpMap = new Map();
|
138
|
+
this.regExpQueue = [];
|
139
|
+
}
|
140
|
+
getRegExp(pattern) {
|
141
|
+
const regExpFromCache = this.regExpMap.get(pattern);
|
142
|
+
if (regExpFromCache !== undefined) {
|
143
|
+
return regExpFromCache;
|
144
|
+
}
|
145
|
+
const regExpNew = new RegExp(pattern);
|
146
|
+
if (this.regExpQueue.length === this.capacity) {
|
147
|
+
this.regExpMap.delete(this.regExpQueue.shift());
|
148
|
+
}
|
149
|
+
this.regExpMap.set(pattern, regExpNew);
|
150
|
+
this.regExpQueue.push(pattern);
|
151
|
+
return regExpNew;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
const chars = [' ', ',', '?', '!', ';'];
|
155
|
+
const looksLikeObjectPathRegExpCache = new RegExpCache(20);
|
156
|
+
const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
157
|
+
nsSeparator = nsSeparator || '';
|
158
|
+
keySeparator = keySeparator || '';
|
159
|
+
const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
|
160
|
+
if (possibleChars.length === 0) return true;
|
161
|
+
const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
|
162
|
+
let matched = !r.test(key);
|
163
|
+
if (!matched) {
|
164
|
+
const ki = key.indexOf(keySeparator);
|
165
|
+
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
166
|
+
matched = true;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
return matched;
|
170
|
+
};
|
171
|
+
const deepFind = (obj, path, keySeparator = '.') => {
|
172
|
+
if (!obj) return undefined;
|
173
|
+
if (obj[path]) {
|
174
|
+
if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
|
175
|
+
return obj[path];
|
176
|
+
}
|
177
|
+
const tokens = path.split(keySeparator);
|
178
|
+
let current = obj;
|
179
|
+
for (let i = 0; i < tokens.length;) {
|
180
|
+
if (!current || typeof current !== 'object') {
|
181
|
+
return undefined;
|
182
|
+
}
|
183
|
+
let next;
|
184
|
+
let nextPath = '';
|
185
|
+
for (let j = i; j < tokens.length; ++j) {
|
186
|
+
if (j !== i) {
|
187
|
+
nextPath += keySeparator;
|
188
|
+
}
|
189
|
+
nextPath += tokens[j];
|
190
|
+
next = current[nextPath];
|
191
|
+
if (next !== undefined) {
|
192
|
+
if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
|
193
|
+
continue;
|
194
|
+
}
|
195
|
+
i += j - i + 1;
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
current = next;
|
200
|
+
}
|
201
|
+
return current;
|
202
|
+
};
|
203
|
+
const getCleanedCode = code => code?.replace('_', '-');
|
204
|
+
|
205
|
+
const consoleLogger = {
|
206
|
+
type: 'logger',
|
207
|
+
log(args) {
|
208
|
+
this.output('log', args);
|
209
|
+
},
|
210
|
+
warn(args) {
|
211
|
+
this.output('warn', args);
|
212
|
+
},
|
213
|
+
error(args) {
|
214
|
+
this.output('error', args);
|
215
|
+
},
|
216
|
+
output(type, args) {
|
217
|
+
console?.[type]?.apply?.(console, args);
|
218
|
+
}
|
219
|
+
};
|
220
|
+
class Logger {
|
221
|
+
constructor(concreteLogger, options = {}) {
|
222
|
+
this.init(concreteLogger, options);
|
223
|
+
}
|
224
|
+
init(concreteLogger, options = {}) {
|
225
|
+
this.prefix = options.prefix || 'i18next:';
|
226
|
+
this.logger = concreteLogger || consoleLogger;
|
227
|
+
this.options = options;
|
228
|
+
this.debug = options.debug;
|
229
|
+
}
|
230
|
+
log(...args) {
|
231
|
+
return this.forward(args, 'log', '', true);
|
232
|
+
}
|
233
|
+
warn(...args) {
|
234
|
+
return this.forward(args, 'warn', '', true);
|
235
|
+
}
|
236
|
+
error(...args) {
|
237
|
+
return this.forward(args, 'error', '');
|
238
|
+
}
|
239
|
+
deprecate(...args) {
|
240
|
+
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
241
|
+
}
|
242
|
+
forward(args, lvl, prefix, debugOnly) {
|
243
|
+
if (debugOnly && !this.debug) return null;
|
244
|
+
if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
245
|
+
return this.logger[lvl](args);
|
246
|
+
}
|
247
|
+
create(moduleName) {
|
248
|
+
return new Logger(this.logger, {
|
249
|
+
...{
|
250
|
+
prefix: `${this.prefix}:${moduleName}:`
|
251
|
+
},
|
252
|
+
...this.options
|
253
|
+
});
|
254
|
+
}
|
255
|
+
clone(options) {
|
256
|
+
options = options || this.options;
|
257
|
+
options.prefix = options.prefix || this.prefix;
|
258
|
+
return new Logger(this.logger, options);
|
259
|
+
}
|
260
|
+
}
|
261
|
+
var baseLogger = new Logger();
|
262
|
+
|
263
|
+
class EventEmitter {
|
264
|
+
constructor() {
|
265
|
+
this.observers = {};
|
266
|
+
}
|
267
|
+
on(events, listener) {
|
268
|
+
events.split(' ').forEach(event => {
|
269
|
+
if (!this.observers[event]) this.observers[event] = new Map();
|
270
|
+
const numListeners = this.observers[event].get(listener) || 0;
|
271
|
+
this.observers[event].set(listener, numListeners + 1);
|
272
|
+
});
|
273
|
+
return this;
|
274
|
+
}
|
275
|
+
off(event, listener) {
|
276
|
+
if (!this.observers[event]) return;
|
277
|
+
if (!listener) {
|
278
|
+
delete this.observers[event];
|
279
|
+
return;
|
280
|
+
}
|
281
|
+
this.observers[event].delete(listener);
|
282
|
+
}
|
283
|
+
emit(event, ...args) {
|
284
|
+
if (this.observers[event]) {
|
285
|
+
const cloned = Array.from(this.observers[event].entries());
|
286
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
287
|
+
for (let i = 0; i < numTimesAdded; i++) {
|
288
|
+
observer(...args);
|
289
|
+
}
|
290
|
+
});
|
291
|
+
}
|
292
|
+
if (this.observers['*']) {
|
293
|
+
const cloned = Array.from(this.observers['*'].entries());
|
294
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
295
|
+
for (let i = 0; i < numTimesAdded; i++) {
|
296
|
+
observer.apply(observer, [event, ...args]);
|
297
|
+
}
|
298
|
+
});
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
class ResourceStore extends EventEmitter {
|
304
|
+
constructor(data, options = {
|
305
|
+
ns: ['translation'],
|
306
|
+
defaultNS: 'translation'
|
307
|
+
}) {
|
308
|
+
super();
|
309
|
+
this.data = data || {};
|
310
|
+
this.options = options;
|
311
|
+
if (this.options.keySeparator === undefined) {
|
312
|
+
this.options.keySeparator = '.';
|
313
|
+
}
|
314
|
+
if (this.options.ignoreJSONStructure === undefined) {
|
315
|
+
this.options.ignoreJSONStructure = true;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
addNamespaces(ns) {
|
319
|
+
if (this.options.ns.indexOf(ns) < 0) {
|
320
|
+
this.options.ns.push(ns);
|
321
|
+
}
|
322
|
+
}
|
323
|
+
removeNamespaces(ns) {
|
324
|
+
const index = this.options.ns.indexOf(ns);
|
325
|
+
if (index > -1) {
|
326
|
+
this.options.ns.splice(index, 1);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
getResource(lng, ns, key, options = {}) {
|
330
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
331
|
+
const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
332
|
+
let path;
|
333
|
+
if (lng.indexOf('.') > -1) {
|
334
|
+
path = lng.split('.');
|
335
|
+
} else {
|
336
|
+
path = [lng, ns];
|
337
|
+
if (key) {
|
338
|
+
if (Array.isArray(key)) {
|
339
|
+
path.push(...key);
|
340
|
+
} else if (isString(key) && keySeparator) {
|
341
|
+
path.push(...key.split(keySeparator));
|
342
|
+
} else {
|
343
|
+
path.push(key);
|
344
|
+
}
|
345
|
+
}
|
346
|
+
}
|
347
|
+
const result = getPath(this.data, path);
|
348
|
+
if (!result && !ns && !key && lng.indexOf('.') > -1) {
|
349
|
+
lng = path[0];
|
350
|
+
ns = path[1];
|
351
|
+
key = path.slice(2).join('.');
|
352
|
+
}
|
353
|
+
if (result || !ignoreJSONStructure || !isString(key)) return result;
|
354
|
+
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
355
|
+
}
|
356
|
+
addResource(lng, ns, key, value, options = {
|
357
|
+
silent: false
|
358
|
+
}) {
|
359
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
360
|
+
let path = [lng, ns];
|
361
|
+
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
362
|
+
if (lng.indexOf('.') > -1) {
|
363
|
+
path = lng.split('.');
|
364
|
+
value = ns;
|
365
|
+
ns = path[1];
|
366
|
+
}
|
367
|
+
this.addNamespaces(ns);
|
368
|
+
setPath(this.data, path, value);
|
369
|
+
if (!options.silent) this.emit('added', lng, ns, key, value);
|
370
|
+
}
|
371
|
+
addResources(lng, ns, resources, options = {
|
372
|
+
silent: false
|
373
|
+
}) {
|
374
|
+
for (const m in resources) {
|
375
|
+
if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
|
376
|
+
silent: true
|
377
|
+
});
|
378
|
+
}
|
379
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
380
|
+
}
|
381
|
+
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
382
|
+
silent: false,
|
383
|
+
skipCopy: false
|
384
|
+
}) {
|
385
|
+
let path = [lng, ns];
|
386
|
+
if (lng.indexOf('.') > -1) {
|
387
|
+
path = lng.split('.');
|
388
|
+
deep = resources;
|
389
|
+
resources = ns;
|
390
|
+
ns = path[1];
|
391
|
+
}
|
392
|
+
this.addNamespaces(ns);
|
393
|
+
let pack = getPath(this.data, path) || {};
|
394
|
+
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
395
|
+
if (deep) {
|
396
|
+
deepExtend(pack, resources, overwrite);
|
397
|
+
} else {
|
398
|
+
pack = {
|
399
|
+
...pack,
|
400
|
+
...resources
|
401
|
+
};
|
402
|
+
}
|
403
|
+
setPath(this.data, path, pack);
|
404
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
405
|
+
}
|
406
|
+
removeResourceBundle(lng, ns) {
|
407
|
+
if (this.hasResourceBundle(lng, ns)) {
|
408
|
+
delete this.data[lng][ns];
|
409
|
+
}
|
410
|
+
this.removeNamespaces(ns);
|
411
|
+
this.emit('removed', lng, ns);
|
412
|
+
}
|
413
|
+
hasResourceBundle(lng, ns) {
|
414
|
+
return this.getResource(lng, ns) !== undefined;
|
415
|
+
}
|
416
|
+
getResourceBundle(lng, ns) {
|
417
|
+
if (!ns) ns = this.options.defaultNS;
|
418
|
+
return this.getResource(lng, ns);
|
419
|
+
}
|
420
|
+
getDataByLanguage(lng) {
|
421
|
+
return this.data[lng];
|
422
|
+
}
|
423
|
+
hasLanguageSomeTranslations(lng) {
|
424
|
+
const data = this.getDataByLanguage(lng);
|
425
|
+
const n = data && Object.keys(data) || [];
|
426
|
+
return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
|
427
|
+
}
|
428
|
+
toJSON() {
|
429
|
+
return this.data;
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
var postProcessor = {
|
434
|
+
processors: {},
|
435
|
+
addPostProcessor(module) {
|
436
|
+
this.processors[module.name] = module;
|
437
|
+
},
|
438
|
+
handle(processors, value, key, options, translator) {
|
439
|
+
processors.forEach(processor => {
|
440
|
+
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
441
|
+
});
|
442
|
+
return value;
|
443
|
+
}
|
444
|
+
};
|
445
|
+
|
446
|
+
const checkedLoadedFor = {};
|
447
|
+
const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
|
448
|
+
class Translator extends EventEmitter {
|
449
|
+
constructor(services, options = {}) {
|
450
|
+
super();
|
451
|
+
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
|
452
|
+
this.options = options;
|
453
|
+
if (this.options.keySeparator === undefined) {
|
454
|
+
this.options.keySeparator = '.';
|
455
|
+
}
|
456
|
+
this.logger = baseLogger.create('translator');
|
457
|
+
}
|
458
|
+
changeLanguage(lng) {
|
459
|
+
if (lng) this.language = lng;
|
460
|
+
}
|
461
|
+
exists(key, o = {
|
462
|
+
interpolation: {}
|
463
|
+
}) {
|
464
|
+
const opt = {
|
465
|
+
...o
|
466
|
+
};
|
467
|
+
if (key == null) return false;
|
468
|
+
const resolved = this.resolve(key, opt);
|
469
|
+
return resolved?.res !== undefined;
|
470
|
+
}
|
471
|
+
extractFromKey(key, opt) {
|
472
|
+
let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
|
473
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
474
|
+
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
475
|
+
let namespaces = opt.ns || this.options.defaultNS || [];
|
476
|
+
const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
477
|
+
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
478
|
+
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
479
|
+
const m = key.match(this.interpolator.nestingRegexp);
|
480
|
+
if (m && m.length > 0) {
|
481
|
+
return {
|
482
|
+
key,
|
483
|
+
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
484
|
+
};
|
485
|
+
}
|
486
|
+
const parts = key.split(nsSeparator);
|
487
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
488
|
+
key = parts.join(keySeparator);
|
489
|
+
}
|
490
|
+
return {
|
491
|
+
key,
|
492
|
+
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
493
|
+
};
|
494
|
+
}
|
495
|
+
translate(keys, o, lastKey) {
|
496
|
+
let opt = typeof o === 'object' ? {
|
497
|
+
...o
|
498
|
+
} : o;
|
499
|
+
if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
|
500
|
+
opt = this.options.overloadTranslationOptionHandler(arguments);
|
501
|
+
}
|
502
|
+
if (typeof options === 'object') opt = {
|
503
|
+
...opt
|
504
|
+
};
|
505
|
+
if (!opt) opt = {};
|
506
|
+
if (keys == null) return '';
|
507
|
+
if (!Array.isArray(keys)) keys = [String(keys)];
|
508
|
+
const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
|
509
|
+
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
510
|
+
const {
|
511
|
+
key,
|
512
|
+
namespaces
|
513
|
+
} = this.extractFromKey(keys[keys.length - 1], opt);
|
514
|
+
const namespace = namespaces[namespaces.length - 1];
|
515
|
+
let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
|
516
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
517
|
+
const lng = opt.lng || this.language;
|
518
|
+
const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
519
|
+
if (lng?.toLowerCase() === 'cimode') {
|
520
|
+
if (appendNamespaceToCIMode) {
|
521
|
+
if (returnDetails) {
|
522
|
+
return {
|
523
|
+
res: `${namespace}${nsSeparator}${key}`,
|
524
|
+
usedKey: key,
|
525
|
+
exactUsedKey: key,
|
526
|
+
usedLng: lng,
|
527
|
+
usedNS: namespace,
|
528
|
+
usedParams: this.getUsedParamsDetails(opt)
|
529
|
+
};
|
530
|
+
}
|
531
|
+
return `${namespace}${nsSeparator}${key}`;
|
532
|
+
}
|
533
|
+
if (returnDetails) {
|
534
|
+
return {
|
535
|
+
res: key,
|
536
|
+
usedKey: key,
|
537
|
+
exactUsedKey: key,
|
538
|
+
usedLng: lng,
|
539
|
+
usedNS: namespace,
|
540
|
+
usedParams: this.getUsedParamsDetails(opt)
|
541
|
+
};
|
542
|
+
}
|
543
|
+
return key;
|
544
|
+
}
|
545
|
+
const resolved = this.resolve(keys, opt);
|
546
|
+
let res = resolved?.res;
|
547
|
+
const resUsedKey = resolved?.usedKey || key;
|
548
|
+
const resExactUsedKey = resolved?.exactUsedKey || key;
|
549
|
+
const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
550
|
+
const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
|
551
|
+
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
552
|
+
const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
|
553
|
+
const hasDefaultValue = Translator.hasDefaultValue(opt);
|
554
|
+
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
|
555
|
+
const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
|
556
|
+
ordinal: false
|
557
|
+
}) : '';
|
558
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
559
|
+
const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
|
560
|
+
let resForObjHndl = res;
|
561
|
+
if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
|
562
|
+
resForObjHndl = defaultValue;
|
563
|
+
}
|
564
|
+
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
565
|
+
const resType = Object.prototype.toString.apply(resForObjHndl);
|
566
|
+
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
|
567
|
+
if (!opt.returnObjects && !this.options.returnObjects) {
|
568
|
+
if (!this.options.returnedObjectHandler) {
|
569
|
+
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
570
|
+
}
|
571
|
+
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
572
|
+
...opt,
|
573
|
+
ns: namespaces
|
574
|
+
}) : `key '${key} (${this.language})' returned an object instead of string.`;
|
575
|
+
if (returnDetails) {
|
576
|
+
resolved.res = r;
|
577
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
578
|
+
return resolved;
|
579
|
+
}
|
580
|
+
return r;
|
581
|
+
}
|
582
|
+
if (keySeparator) {
|
583
|
+
const resTypeIsArray = Array.isArray(resForObjHndl);
|
584
|
+
const copy = resTypeIsArray ? [] : {};
|
585
|
+
const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
586
|
+
for (const m in resForObjHndl) {
|
587
|
+
if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
|
588
|
+
const deepKey = `${newKeyToUse}${keySeparator}${m}`;
|
589
|
+
if (hasDefaultValue && !res) {
|
590
|
+
copy[m] = this.translate(deepKey, {
|
591
|
+
...opt,
|
592
|
+
defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
|
593
|
+
...{
|
594
|
+
joinArrays: false,
|
595
|
+
ns: namespaces
|
596
|
+
}
|
597
|
+
});
|
598
|
+
} else {
|
599
|
+
copy[m] = this.translate(deepKey, {
|
600
|
+
...opt,
|
601
|
+
...{
|
602
|
+
joinArrays: false,
|
603
|
+
ns: namespaces
|
604
|
+
}
|
605
|
+
});
|
606
|
+
}
|
607
|
+
if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
|
608
|
+
}
|
609
|
+
}
|
610
|
+
res = copy;
|
611
|
+
}
|
612
|
+
} else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
|
613
|
+
res = res.join(joinArrays);
|
614
|
+
if (res) res = this.extendTranslation(res, keys, opt, lastKey);
|
615
|
+
} else {
|
616
|
+
let usedDefault = false;
|
617
|
+
let usedKey = false;
|
618
|
+
if (!this.isValidLookup(res) && hasDefaultValue) {
|
619
|
+
usedDefault = true;
|
620
|
+
res = defaultValue;
|
621
|
+
}
|
622
|
+
if (!this.isValidLookup(res)) {
|
623
|
+
usedKey = true;
|
624
|
+
res = key;
|
625
|
+
}
|
626
|
+
const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
627
|
+
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
628
|
+
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
629
|
+
if (usedKey || usedDefault || updateMissing) {
|
630
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
631
|
+
if (keySeparator) {
|
632
|
+
const fk = this.resolve(key, {
|
633
|
+
...opt,
|
634
|
+
keySeparator: false
|
635
|
+
});
|
636
|
+
if (fk && fk.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.');
|
637
|
+
}
|
638
|
+
let lngs = [];
|
639
|
+
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
|
640
|
+
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
641
|
+
for (let i = 0; i < fallbackLngs.length; i++) {
|
642
|
+
lngs.push(fallbackLngs[i]);
|
643
|
+
}
|
644
|
+
} else if (this.options.saveMissingTo === 'all') {
|
645
|
+
lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
|
646
|
+
} else {
|
647
|
+
lngs.push(opt.lng || this.language);
|
648
|
+
}
|
649
|
+
const send = (l, k, specificDefaultValue) => {
|
650
|
+
const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
651
|
+
if (this.options.missingKeyHandler) {
|
652
|
+
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
|
653
|
+
} else if (this.backendConnector?.saveMissing) {
|
654
|
+
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
|
655
|
+
}
|
656
|
+
this.emit('missingKey', l, namespace, k, res);
|
657
|
+
};
|
658
|
+
if (this.options.saveMissing) {
|
659
|
+
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
660
|
+
lngs.forEach(language => {
|
661
|
+
const suffixes = this.pluralResolver.getSuffixes(language, opt);
|
662
|
+
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
|
663
|
+
suffixes.push(`${this.options.pluralSeparator}zero`);
|
664
|
+
}
|
665
|
+
suffixes.forEach(suffix => {
|
666
|
+
send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
|
667
|
+
});
|
668
|
+
});
|
669
|
+
} else {
|
670
|
+
send(lngs, key, defaultValue);
|
671
|
+
}
|
672
|
+
}
|
673
|
+
}
|
674
|
+
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
675
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
|
676
|
+
res = `${namespace}${nsSeparator}${key}`;
|
677
|
+
}
|
678
|
+
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
679
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
|
680
|
+
}
|
681
|
+
}
|
682
|
+
if (returnDetails) {
|
683
|
+
resolved.res = res;
|
684
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
685
|
+
return resolved;
|
686
|
+
}
|
687
|
+
return res;
|
688
|
+
}
|
689
|
+
extendTranslation(res, key, opt, resolved, lastKey) {
|
690
|
+
if (this.i18nFormat?.parse) {
|
691
|
+
res = this.i18nFormat.parse(res, {
|
692
|
+
...this.options.interpolation.defaultVariables,
|
693
|
+
...opt
|
694
|
+
}, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
695
|
+
resolved
|
696
|
+
});
|
697
|
+
} else if (!opt.skipInterpolation) {
|
698
|
+
if (opt.interpolation) this.interpolator.init({
|
699
|
+
...opt,
|
700
|
+
...{
|
701
|
+
interpolation: {
|
702
|
+
...this.options.interpolation,
|
703
|
+
...opt.interpolation
|
704
|
+
}
|
705
|
+
}
|
706
|
+
});
|
707
|
+
const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
708
|
+
let nestBef;
|
709
|
+
if (skipOnVariables) {
|
710
|
+
const nb = res.match(this.interpolator.nestingRegexp);
|
711
|
+
nestBef = nb && nb.length;
|
712
|
+
}
|
713
|
+
let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
|
714
|
+
if (this.options.interpolation.defaultVariables) data = {
|
715
|
+
...this.options.interpolation.defaultVariables,
|
716
|
+
...data
|
717
|
+
};
|
718
|
+
res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
|
719
|
+
if (skipOnVariables) {
|
720
|
+
const na = res.match(this.interpolator.nestingRegexp);
|
721
|
+
const nestAft = na && na.length;
|
722
|
+
if (nestBef < nestAft) opt.nest = false;
|
723
|
+
}
|
724
|
+
if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
|
725
|
+
if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
|
726
|
+
if (lastKey?.[0] === args[0] && !opt.context) {
|
727
|
+
this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
728
|
+
return null;
|
729
|
+
}
|
730
|
+
return this.translate(...args, key);
|
731
|
+
}, opt);
|
732
|
+
if (opt.interpolation) this.interpolator.reset();
|
733
|
+
}
|
734
|
+
const postProcess = opt.postProcess || this.options.postProcess;
|
735
|
+
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
736
|
+
if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
|
737
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
738
|
+
i18nResolved: {
|
739
|
+
...resolved,
|
740
|
+
usedParams: this.getUsedParamsDetails(opt)
|
741
|
+
},
|
742
|
+
...opt
|
743
|
+
} : opt, this);
|
744
|
+
}
|
745
|
+
return res;
|
746
|
+
}
|
747
|
+
resolve(keys, opt = {}) {
|
748
|
+
let found;
|
749
|
+
let usedKey;
|
750
|
+
let exactUsedKey;
|
751
|
+
let usedLng;
|
752
|
+
let usedNS;
|
753
|
+
if (isString(keys)) keys = [keys];
|
754
|
+
keys.forEach(k => {
|
755
|
+
if (this.isValidLookup(found)) return;
|
756
|
+
const extracted = this.extractFromKey(k, opt);
|
757
|
+
const key = extracted.key;
|
758
|
+
usedKey = key;
|
759
|
+
let namespaces = extracted.namespaces;
|
760
|
+
if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
|
761
|
+
const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
|
762
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
763
|
+
const needsContextHandling = opt.context !== undefined && (isString(opt.context) || typeof opt.context === 'number') && opt.context !== '';
|
764
|
+
const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
|
765
|
+
namespaces.forEach(ns => {
|
766
|
+
if (this.isValidLookup(found)) return;
|
767
|
+
usedNS = ns;
|
768
|
+
if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
|
769
|
+
checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
770
|
+
this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" 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!!!');
|
771
|
+
}
|
772
|
+
codes.forEach(code => {
|
773
|
+
if (this.isValidLookup(found)) return;
|
774
|
+
usedLng = code;
|
775
|
+
const finalKeys = [key];
|
776
|
+
if (this.i18nFormat?.addLookupKeys) {
|
777
|
+
this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
|
778
|
+
} else {
|
779
|
+
let pluralSuffix;
|
780
|
+
if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
|
781
|
+
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
782
|
+
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
783
|
+
if (needsPluralHandling) {
|
784
|
+
finalKeys.push(key + pluralSuffix);
|
785
|
+
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
786
|
+
finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
787
|
+
}
|
788
|
+
if (needsZeroSuffixLookup) {
|
789
|
+
finalKeys.push(key + zeroSuffix);
|
790
|
+
}
|
791
|
+
}
|
792
|
+
if (needsContextHandling) {
|
793
|
+
const contextKey = `${key}${this.options.contextSeparator}${opt.context}`;
|
794
|
+
finalKeys.push(contextKey);
|
795
|
+
if (needsPluralHandling) {
|
796
|
+
finalKeys.push(contextKey + pluralSuffix);
|
797
|
+
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
798
|
+
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
799
|
+
}
|
800
|
+
if (needsZeroSuffixLookup) {
|
801
|
+
finalKeys.push(contextKey + zeroSuffix);
|
802
|
+
}
|
803
|
+
}
|
804
|
+
}
|
805
|
+
}
|
806
|
+
let possibleKey;
|
807
|
+
while (possibleKey = finalKeys.pop()) {
|
808
|
+
if (!this.isValidLookup(found)) {
|
809
|
+
exactUsedKey = possibleKey;
|
810
|
+
found = this.getResource(code, ns, possibleKey, opt);
|
811
|
+
}
|
812
|
+
}
|
813
|
+
});
|
814
|
+
});
|
815
|
+
});
|
816
|
+
return {
|
817
|
+
res: found,
|
818
|
+
usedKey,
|
819
|
+
exactUsedKey,
|
820
|
+
usedLng,
|
821
|
+
usedNS
|
822
|
+
};
|
823
|
+
}
|
824
|
+
isValidLookup(res) {
|
825
|
+
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
826
|
+
}
|
827
|
+
getResource(code, ns, key, options = {}) {
|
828
|
+
if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
829
|
+
return this.resourceStore.getResource(code, ns, key, options);
|
830
|
+
}
|
831
|
+
getUsedParamsDetails(options = {}) {
|
832
|
+
const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
|
833
|
+
const useOptionsReplaceForData = options.replace && !isString(options.replace);
|
834
|
+
let data = useOptionsReplaceForData ? options.replace : options;
|
835
|
+
if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
|
836
|
+
data.count = options.count;
|
837
|
+
}
|
838
|
+
if (this.options.interpolation.defaultVariables) {
|
839
|
+
data = {
|
840
|
+
...this.options.interpolation.defaultVariables,
|
841
|
+
...data
|
842
|
+
};
|
843
|
+
}
|
844
|
+
if (!useOptionsReplaceForData) {
|
845
|
+
data = {
|
846
|
+
...data
|
847
|
+
};
|
848
|
+
for (const key of optionsKeys) {
|
849
|
+
delete data[key];
|
850
|
+
}
|
851
|
+
}
|
852
|
+
return data;
|
853
|
+
}
|
854
|
+
static hasDefaultValue(options) {
|
855
|
+
const prefix = 'defaultValue';
|
856
|
+
for (const option in options) {
|
857
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
858
|
+
return true;
|
859
|
+
}
|
860
|
+
}
|
861
|
+
return false;
|
862
|
+
}
|
863
|
+
}
|
864
|
+
|
865
|
+
class LanguageUtil {
|
866
|
+
constructor(options) {
|
867
|
+
this.options = options;
|
868
|
+
this.supportedLngs = this.options.supportedLngs || false;
|
869
|
+
this.logger = baseLogger.create('languageUtils');
|
870
|
+
}
|
871
|
+
getScriptPartFromCode(code) {
|
872
|
+
code = getCleanedCode(code);
|
873
|
+
if (!code || code.indexOf('-') < 0) return null;
|
874
|
+
const p = code.split('-');
|
875
|
+
if (p.length === 2) return null;
|
876
|
+
p.pop();
|
877
|
+
if (p[p.length - 1].toLowerCase() === 'x') return null;
|
878
|
+
return this.formatLanguageCode(p.join('-'));
|
879
|
+
}
|
880
|
+
getLanguagePartFromCode(code) {
|
881
|
+
code = getCleanedCode(code);
|
882
|
+
if (!code || code.indexOf('-') < 0) return code;
|
883
|
+
const p = code.split('-');
|
884
|
+
return this.formatLanguageCode(p[0]);
|
885
|
+
}
|
886
|
+
formatLanguageCode(code) {
|
887
|
+
if (isString(code) && code.indexOf('-') > -1) {
|
888
|
+
let formattedCode;
|
889
|
+
try {
|
890
|
+
formattedCode = Intl.getCanonicalLocales(code)[0];
|
891
|
+
} catch (e) {}
|
892
|
+
if (formattedCode && this.options.lowerCaseLng) {
|
893
|
+
formattedCode = formattedCode.toLowerCase();
|
894
|
+
}
|
895
|
+
if (formattedCode) return formattedCode;
|
896
|
+
if (this.options.lowerCaseLng) {
|
897
|
+
return code.toLowerCase();
|
898
|
+
}
|
899
|
+
return code;
|
900
|
+
}
|
901
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
902
|
+
}
|
903
|
+
isSupportedCode(code) {
|
904
|
+
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
905
|
+
code = this.getLanguagePartFromCode(code);
|
906
|
+
}
|
907
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
908
|
+
}
|
909
|
+
getBestMatchFromCodes(codes) {
|
910
|
+
if (!codes) return null;
|
911
|
+
let found;
|
912
|
+
codes.forEach(code => {
|
913
|
+
if (found) return;
|
914
|
+
const cleanedLng = this.formatLanguageCode(code);
|
915
|
+
if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
916
|
+
});
|
917
|
+
if (!found && this.options.supportedLngs) {
|
918
|
+
codes.forEach(code => {
|
919
|
+
if (found) return;
|
920
|
+
const lngScOnly = this.getScriptPartFromCode(code);
|
921
|
+
if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
|
922
|
+
const lngOnly = this.getLanguagePartFromCode(code);
|
923
|
+
if (this.isSupportedCode(lngOnly)) return found = lngOnly;
|
924
|
+
found = this.options.supportedLngs.find(supportedLng => {
|
925
|
+
if (supportedLng === lngOnly) return supportedLng;
|
926
|
+
if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
|
927
|
+
if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
|
928
|
+
if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
|
929
|
+
});
|
930
|
+
});
|
931
|
+
}
|
932
|
+
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
933
|
+
return found;
|
934
|
+
}
|
935
|
+
getFallbackCodes(fallbacks, code) {
|
936
|
+
if (!fallbacks) return [];
|
937
|
+
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
938
|
+
if (isString(fallbacks)) fallbacks = [fallbacks];
|
939
|
+
if (Array.isArray(fallbacks)) return fallbacks;
|
940
|
+
if (!code) return fallbacks.default || [];
|
941
|
+
let found = fallbacks[code];
|
942
|
+
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
943
|
+
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
944
|
+
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
945
|
+
if (!found) found = fallbacks.default;
|
946
|
+
return found || [];
|
947
|
+
}
|
948
|
+
toResolveHierarchy(code, fallbackCode) {
|
949
|
+
const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
|
950
|
+
const codes = [];
|
951
|
+
const addCode = c => {
|
952
|
+
if (!c) return;
|
953
|
+
if (this.isSupportedCode(c)) {
|
954
|
+
codes.push(c);
|
955
|
+
} else {
|
956
|
+
this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
957
|
+
}
|
958
|
+
};
|
959
|
+
if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
|
960
|
+
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
961
|
+
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
962
|
+
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
963
|
+
} else if (isString(code)) {
|
964
|
+
addCode(this.formatLanguageCode(code));
|
965
|
+
}
|
966
|
+
fallbackCodes.forEach(fc => {
|
967
|
+
if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
|
968
|
+
});
|
969
|
+
return codes;
|
970
|
+
}
|
971
|
+
}
|
972
|
+
|
973
|
+
const suffixesOrder = {
|
974
|
+
zero: 0,
|
975
|
+
one: 1,
|
976
|
+
two: 2,
|
977
|
+
few: 3,
|
978
|
+
many: 4,
|
979
|
+
other: 5
|
980
|
+
};
|
981
|
+
const dummyRule = {
|
982
|
+
select: count => count === 1 ? 'one' : 'other',
|
983
|
+
resolvedOptions: () => ({
|
984
|
+
pluralCategories: ['one', 'other']
|
985
|
+
})
|
986
|
+
};
|
987
|
+
class PluralResolver {
|
988
|
+
constructor(languageUtils, options = {}) {
|
989
|
+
this.languageUtils = languageUtils;
|
990
|
+
this.options = options;
|
991
|
+
this.logger = baseLogger.create('pluralResolver');
|
992
|
+
this.pluralRulesCache = {};
|
993
|
+
}
|
994
|
+
addRule(lng, obj) {
|
995
|
+
this.rules[lng] = obj;
|
996
|
+
}
|
997
|
+
clearCache() {
|
998
|
+
this.pluralRulesCache = {};
|
999
|
+
}
|
1000
|
+
getRule(code, options = {}) {
|
1001
|
+
const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
|
1002
|
+
const type = options.ordinal ? 'ordinal' : 'cardinal';
|
1003
|
+
const cacheKey = JSON.stringify({
|
1004
|
+
cleanedCode,
|
1005
|
+
type
|
1006
|
+
});
|
1007
|
+
if (cacheKey in this.pluralRulesCache) {
|
1008
|
+
return this.pluralRulesCache[cacheKey];
|
1009
|
+
}
|
1010
|
+
let rule;
|
1011
|
+
try {
|
1012
|
+
rule = new Intl.PluralRules(cleanedCode, {
|
1013
|
+
type
|
1014
|
+
});
|
1015
|
+
} catch (err) {
|
1016
|
+
if (!Intl) {
|
1017
|
+
this.logger.error('No Intl support, please use an Intl polyfill!');
|
1018
|
+
return dummyRule;
|
1019
|
+
}
|
1020
|
+
if (!code.match(/-|_/)) return dummyRule;
|
1021
|
+
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
1022
|
+
rule = this.getRule(lngPart, options);
|
1023
|
+
}
|
1024
|
+
this.pluralRulesCache[cacheKey] = rule;
|
1025
|
+
return rule;
|
1026
|
+
}
|
1027
|
+
needsPlural(code, options = {}) {
|
1028
|
+
let rule = this.getRule(code, options);
|
1029
|
+
if (!rule) rule = this.getRule('dev', options);
|
1030
|
+
return rule?.resolvedOptions().pluralCategories.length > 1;
|
1031
|
+
}
|
1032
|
+
getPluralFormsOfKey(code, key, options = {}) {
|
1033
|
+
return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
|
1034
|
+
}
|
1035
|
+
getSuffixes(code, options = {}) {
|
1036
|
+
let rule = this.getRule(code, options);
|
1037
|
+
if (!rule) rule = this.getRule('dev', options);
|
1038
|
+
if (!rule) return [];
|
1039
|
+
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
|
1040
|
+
}
|
1041
|
+
getSuffix(code, count, options = {}) {
|
1042
|
+
const rule = this.getRule(code, options);
|
1043
|
+
if (rule) {
|
1044
|
+
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
|
1045
|
+
}
|
1046
|
+
this.logger.warn(`no plural rule found for: ${code}`);
|
1047
|
+
return this.getSuffix('dev', count, options);
|
1048
|
+
}
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignoreJSONStructure = true) => {
|
1052
|
+
let path = getPathWithDefaults(data, defaultData, key);
|
1053
|
+
if (!path && ignoreJSONStructure && isString(key)) {
|
1054
|
+
path = deepFind(data, key, keySeparator);
|
1055
|
+
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
1056
|
+
}
|
1057
|
+
return path;
|
1058
|
+
};
|
1059
|
+
const regexSafe = val => val.replace(/\$/g, '$$$$');
|
1060
|
+
class Interpolator {
|
1061
|
+
constructor(options = {}) {
|
1062
|
+
this.logger = baseLogger.create('interpolator');
|
1063
|
+
this.options = options;
|
1064
|
+
this.format = options?.interpolation?.format || (value => value);
|
1065
|
+
this.init(options);
|
1066
|
+
}
|
1067
|
+
init(options = {}) {
|
1068
|
+
if (!options.interpolation) options.interpolation = {
|
1069
|
+
escapeValue: true
|
1070
|
+
};
|
1071
|
+
const {
|
1072
|
+
escape: escape$1,
|
1073
|
+
escapeValue,
|
1074
|
+
useRawValueToEscape,
|
1075
|
+
prefix,
|
1076
|
+
prefixEscaped,
|
1077
|
+
suffix,
|
1078
|
+
suffixEscaped,
|
1079
|
+
formatSeparator,
|
1080
|
+
unescapeSuffix,
|
1081
|
+
unescapePrefix,
|
1082
|
+
nestingPrefix,
|
1083
|
+
nestingPrefixEscaped,
|
1084
|
+
nestingSuffix,
|
1085
|
+
nestingSuffixEscaped,
|
1086
|
+
nestingOptionsSeparator,
|
1087
|
+
maxReplaces,
|
1088
|
+
alwaysFormat
|
1089
|
+
} = options.interpolation;
|
1090
|
+
this.escape = escape$1 !== undefined ? escape$1 : escape;
|
1091
|
+
this.escapeValue = escapeValue !== undefined ? escapeValue : true;
|
1092
|
+
this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
|
1093
|
+
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
|
1094
|
+
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
|
1095
|
+
this.formatSeparator = formatSeparator || ',';
|
1096
|
+
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
|
1097
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
|
1098
|
+
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
|
1099
|
+
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
|
1100
|
+
this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
|
1101
|
+
this.maxReplaces = maxReplaces || 1000;
|
1102
|
+
this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
|
1103
|
+
this.resetRegExp();
|
1104
|
+
}
|
1105
|
+
reset() {
|
1106
|
+
if (this.options) this.init(this.options);
|
1107
|
+
}
|
1108
|
+
resetRegExp() {
|
1109
|
+
const getOrResetRegExp = (existingRegExp, pattern) => {
|
1110
|
+
if (existingRegExp?.source === pattern) {
|
1111
|
+
existingRegExp.lastIndex = 0;
|
1112
|
+
return existingRegExp;
|
1113
|
+
}
|
1114
|
+
return new RegExp(pattern, 'g');
|
1115
|
+
};
|
1116
|
+
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
1117
|
+
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
1118
|
+
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
|
1119
|
+
}
|
1120
|
+
interpolate(str, data, lng, options) {
|
1121
|
+
let match;
|
1122
|
+
let value;
|
1123
|
+
let replaces;
|
1124
|
+
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
1125
|
+
const handleFormat = key => {
|
1126
|
+
if (key.indexOf(this.formatSeparator) < 0) {
|
1127
|
+
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
1128
|
+
return this.alwaysFormat ? this.format(path, undefined, lng, {
|
1129
|
+
...options,
|
1130
|
+
...data,
|
1131
|
+
interpolationkey: key
|
1132
|
+
}) : path;
|
1133
|
+
}
|
1134
|
+
const p = key.split(this.formatSeparator);
|
1135
|
+
const k = p.shift().trim();
|
1136
|
+
const f = p.join(this.formatSeparator).trim();
|
1137
|
+
return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
|
1138
|
+
...options,
|
1139
|
+
...data,
|
1140
|
+
interpolationkey: k
|
1141
|
+
});
|
1142
|
+
};
|
1143
|
+
this.resetRegExp();
|
1144
|
+
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
1145
|
+
const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
1146
|
+
const todos = [{
|
1147
|
+
regex: this.regexpUnescape,
|
1148
|
+
safeValue: val => regexSafe(val)
|
1149
|
+
}, {
|
1150
|
+
regex: this.regexp,
|
1151
|
+
safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
|
1152
|
+
}];
|
1153
|
+
todos.forEach(todo => {
|
1154
|
+
replaces = 0;
|
1155
|
+
while (match = todo.regex.exec(str)) {
|
1156
|
+
const matchedVar = match[1].trim();
|
1157
|
+
value = handleFormat(matchedVar);
|
1158
|
+
if (value === undefined) {
|
1159
|
+
if (typeof missingInterpolationHandler === 'function') {
|
1160
|
+
const temp = missingInterpolationHandler(str, match, options);
|
1161
|
+
value = isString(temp) ? temp : '';
|
1162
|
+
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
1163
|
+
value = '';
|
1164
|
+
} else if (skipOnVariables) {
|
1165
|
+
value = match[0];
|
1166
|
+
continue;
|
1167
|
+
} else {
|
1168
|
+
this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
|
1169
|
+
value = '';
|
1170
|
+
}
|
1171
|
+
} else if (!isString(value) && !this.useRawValueToEscape) {
|
1172
|
+
value = makeString(value);
|
1173
|
+
}
|
1174
|
+
const safeValue = todo.safeValue(value);
|
1175
|
+
str = str.replace(match[0], safeValue);
|
1176
|
+
if (skipOnVariables) {
|
1177
|
+
todo.regex.lastIndex += value.length;
|
1178
|
+
todo.regex.lastIndex -= match[0].length;
|
1179
|
+
} else {
|
1180
|
+
todo.regex.lastIndex = 0;
|
1181
|
+
}
|
1182
|
+
replaces++;
|
1183
|
+
if (replaces >= this.maxReplaces) {
|
1184
|
+
break;
|
1185
|
+
}
|
1186
|
+
}
|
1187
|
+
});
|
1188
|
+
return str;
|
1189
|
+
}
|
1190
|
+
nest(str, fc, options = {}) {
|
1191
|
+
let match;
|
1192
|
+
let value;
|
1193
|
+
let clonedOptions;
|
1194
|
+
const handleHasOptions = (key, inheritedOptions) => {
|
1195
|
+
const sep = this.nestingOptionsSeparator;
|
1196
|
+
if (key.indexOf(sep) < 0) return key;
|
1197
|
+
const c = key.split(new RegExp(`${sep}[ ]*{`));
|
1198
|
+
let optionsString = `{${c[1]}`;
|
1199
|
+
key = c[0];
|
1200
|
+
optionsString = this.interpolate(optionsString, clonedOptions);
|
1201
|
+
const matchedSingleQuotes = optionsString.match(/'/g);
|
1202
|
+
const matchedDoubleQuotes = optionsString.match(/"/g);
|
1203
|
+
if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
1204
|
+
optionsString = optionsString.replace(/'/g, '"');
|
1205
|
+
}
|
1206
|
+
try {
|
1207
|
+
clonedOptions = JSON.parse(optionsString);
|
1208
|
+
if (inheritedOptions) clonedOptions = {
|
1209
|
+
...inheritedOptions,
|
1210
|
+
...clonedOptions
|
1211
|
+
};
|
1212
|
+
} catch (e) {
|
1213
|
+
this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
|
1214
|
+
return `${key}${sep}${optionsString}`;
|
1215
|
+
}
|
1216
|
+
if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
|
1217
|
+
return key;
|
1218
|
+
};
|
1219
|
+
while (match = this.nestingRegexp.exec(str)) {
|
1220
|
+
let formatters = [];
|
1221
|
+
clonedOptions = {
|
1222
|
+
...options
|
1223
|
+
};
|
1224
|
+
clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
1225
|
+
clonedOptions.applyPostProcessor = false;
|
1226
|
+
delete clonedOptions.defaultValue;
|
1227
|
+
const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
|
1228
|
+
if (keyEndIndex !== -1) {
|
1229
|
+
formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
|
1230
|
+
match[1] = match[1].slice(0, keyEndIndex);
|
1231
|
+
}
|
1232
|
+
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
1233
|
+
if (value && match[0] === str && !isString(value)) return value;
|
1234
|
+
if (!isString(value)) value = makeString(value);
|
1235
|
+
if (!value) {
|
1236
|
+
this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
|
1237
|
+
value = '';
|
1238
|
+
}
|
1239
|
+
if (formatters.length) {
|
1240
|
+
value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
|
1241
|
+
...options,
|
1242
|
+
interpolationkey: match[1].trim()
|
1243
|
+
}), value.trim());
|
1244
|
+
}
|
1245
|
+
str = str.replace(match[0], value);
|
1246
|
+
this.regexp.lastIndex = 0;
|
1247
|
+
}
|
1248
|
+
return str;
|
1249
|
+
}
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
const parseFormatStr = formatStr => {
|
1253
|
+
let formatName = formatStr.toLowerCase().trim();
|
1254
|
+
const formatOptions = {};
|
1255
|
+
if (formatStr.indexOf('(') > -1) {
|
1256
|
+
const p = formatStr.split('(');
|
1257
|
+
formatName = p[0].toLowerCase().trim();
|
1258
|
+
const optStr = p[1].substring(0, p[1].length - 1);
|
1259
|
+
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
1260
|
+
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
1261
|
+
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
1262
|
+
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
1263
|
+
} else {
|
1264
|
+
const opts = optStr.split(';');
|
1265
|
+
opts.forEach(opt => {
|
1266
|
+
if (opt) {
|
1267
|
+
const [key, ...rest] = opt.split(':');
|
1268
|
+
const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
1269
|
+
const trimmedKey = key.trim();
|
1270
|
+
if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
|
1271
|
+
if (val === 'false') formatOptions[trimmedKey] = false;
|
1272
|
+
if (val === 'true') formatOptions[trimmedKey] = true;
|
1273
|
+
if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
|
1274
|
+
}
|
1275
|
+
});
|
1276
|
+
}
|
1277
|
+
}
|
1278
|
+
return {
|
1279
|
+
formatName,
|
1280
|
+
formatOptions
|
1281
|
+
};
|
1282
|
+
};
|
1283
|
+
const createCachedFormatter = fn => {
|
1284
|
+
const cache = {};
|
1285
|
+
return (v, l, o) => {
|
1286
|
+
let optForCache = o;
|
1287
|
+
if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
|
1288
|
+
optForCache = {
|
1289
|
+
...optForCache,
|
1290
|
+
[o.interpolationkey]: undefined
|
1291
|
+
};
|
1292
|
+
}
|
1293
|
+
const key = l + JSON.stringify(optForCache);
|
1294
|
+
let frm = cache[key];
|
1295
|
+
if (!frm) {
|
1296
|
+
frm = fn(getCleanedCode(l), o);
|
1297
|
+
cache[key] = frm;
|
1298
|
+
}
|
1299
|
+
return frm(v);
|
1300
|
+
};
|
1301
|
+
};
|
1302
|
+
const createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
|
1303
|
+
class Formatter {
|
1304
|
+
constructor(options = {}) {
|
1305
|
+
this.logger = baseLogger.create('formatter');
|
1306
|
+
this.options = options;
|
1307
|
+
this.init(options);
|
1308
|
+
}
|
1309
|
+
init(services, options = {
|
1310
|
+
interpolation: {}
|
1311
|
+
}) {
|
1312
|
+
this.formatSeparator = options.interpolation.formatSeparator || ',';
|
1313
|
+
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
1314
|
+
this.formats = {
|
1315
|
+
number: cf((lng, opt) => {
|
1316
|
+
const formatter = new Intl.NumberFormat(lng, {
|
1317
|
+
...opt
|
1318
|
+
});
|
1319
|
+
return val => formatter.format(val);
|
1320
|
+
}),
|
1321
|
+
currency: cf((lng, opt) => {
|
1322
|
+
const formatter = new Intl.NumberFormat(lng, {
|
1323
|
+
...opt,
|
1324
|
+
style: 'currency'
|
1325
|
+
});
|
1326
|
+
return val => formatter.format(val);
|
1327
|
+
}),
|
1328
|
+
datetime: cf((lng, opt) => {
|
1329
|
+
const formatter = new Intl.DateTimeFormat(lng, {
|
1330
|
+
...opt
|
1331
|
+
});
|
1332
|
+
return val => formatter.format(val);
|
1333
|
+
}),
|
1334
|
+
relativetime: cf((lng, opt) => {
|
1335
|
+
const formatter = new Intl.RelativeTimeFormat(lng, {
|
1336
|
+
...opt
|
1337
|
+
});
|
1338
|
+
return val => formatter.format(val, opt.range || 'day');
|
1339
|
+
}),
|
1340
|
+
list: cf((lng, opt) => {
|
1341
|
+
const formatter = new Intl.ListFormat(lng, {
|
1342
|
+
...opt
|
1343
|
+
});
|
1344
|
+
return val => formatter.format(val);
|
1345
|
+
})
|
1346
|
+
};
|
1347
|
+
}
|
1348
|
+
add(name, fc) {
|
1349
|
+
this.formats[name.toLowerCase().trim()] = fc;
|
1350
|
+
}
|
1351
|
+
addCached(name, fc) {
|
1352
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
1353
|
+
}
|
1354
|
+
format(value, format, lng, options = {}) {
|
1355
|
+
const formats = format.split(this.formatSeparator);
|
1356
|
+
if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
|
1357
|
+
const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
|
1358
|
+
formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
|
1359
|
+
}
|
1360
|
+
const result = formats.reduce((mem, f) => {
|
1361
|
+
const {
|
1362
|
+
formatName,
|
1363
|
+
formatOptions
|
1364
|
+
} = parseFormatStr(f);
|
1365
|
+
if (this.formats[formatName]) {
|
1366
|
+
let formatted = mem;
|
1367
|
+
try {
|
1368
|
+
const valOptions = options?.formatParams?.[options.interpolationkey] || {};
|
1369
|
+
const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
1370
|
+
formatted = this.formats[formatName](mem, l, {
|
1371
|
+
...formatOptions,
|
1372
|
+
...options,
|
1373
|
+
...valOptions
|
1374
|
+
});
|
1375
|
+
} catch (error) {
|
1376
|
+
this.logger.warn(error);
|
1377
|
+
}
|
1378
|
+
return formatted;
|
1379
|
+
} else {
|
1380
|
+
this.logger.warn(`there was no format function for ${formatName}`);
|
1381
|
+
}
|
1382
|
+
return mem;
|
1383
|
+
}, value);
|
1384
|
+
return result;
|
1385
|
+
}
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
const removePending = (q, name) => {
|
1389
|
+
if (q.pending[name] !== undefined) {
|
1390
|
+
delete q.pending[name];
|
1391
|
+
q.pendingCount--;
|
1392
|
+
}
|
1393
|
+
};
|
1394
|
+
class Connector extends EventEmitter {
|
1395
|
+
constructor(backend, store, services, options = {}) {
|
1396
|
+
super();
|
1397
|
+
this.backend = backend;
|
1398
|
+
this.store = store;
|
1399
|
+
this.services = services;
|
1400
|
+
this.languageUtils = services.languageUtils;
|
1401
|
+
this.options = options;
|
1402
|
+
this.logger = baseLogger.create('backendConnector');
|
1403
|
+
this.waitingReads = [];
|
1404
|
+
this.maxParallelReads = options.maxParallelReads || 10;
|
1405
|
+
this.readingCalls = 0;
|
1406
|
+
this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
1407
|
+
this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
1408
|
+
this.state = {};
|
1409
|
+
this.queue = [];
|
1410
|
+
this.backend?.init?.(services, options.backend, options);
|
1411
|
+
}
|
1412
|
+
queueLoad(languages, namespaces, options, callback) {
|
1413
|
+
const toLoad = {};
|
1414
|
+
const pending = {};
|
1415
|
+
const toLoadLanguages = {};
|
1416
|
+
const toLoadNamespaces = {};
|
1417
|
+
languages.forEach(lng => {
|
1418
|
+
let hasAllNamespaces = true;
|
1419
|
+
namespaces.forEach(ns => {
|
1420
|
+
const name = `${lng}|${ns}`;
|
1421
|
+
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
1422
|
+
this.state[name] = 2;
|
1423
|
+
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
1424
|
+
if (pending[name] === undefined) pending[name] = true;
|
1425
|
+
} else {
|
1426
|
+
this.state[name] = 1;
|
1427
|
+
hasAllNamespaces = false;
|
1428
|
+
if (pending[name] === undefined) pending[name] = true;
|
1429
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
1430
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
1431
|
+
}
|
1432
|
+
});
|
1433
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
1434
|
+
});
|
1435
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
1436
|
+
this.queue.push({
|
1437
|
+
pending,
|
1438
|
+
pendingCount: Object.keys(pending).length,
|
1439
|
+
loaded: {},
|
1440
|
+
errors: [],
|
1441
|
+
callback
|
1442
|
+
});
|
1443
|
+
}
|
1444
|
+
return {
|
1445
|
+
toLoad: Object.keys(toLoad),
|
1446
|
+
pending: Object.keys(pending),
|
1447
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
1448
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
1449
|
+
};
|
1450
|
+
}
|
1451
|
+
loaded(name, err, data) {
|
1452
|
+
const s = name.split('|');
|
1453
|
+
const lng = s[0];
|
1454
|
+
const ns = s[1];
|
1455
|
+
if (err) this.emit('failedLoading', lng, ns, err);
|
1456
|
+
if (!err && data) {
|
1457
|
+
this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
|
1458
|
+
skipCopy: true
|
1459
|
+
});
|
1460
|
+
}
|
1461
|
+
this.state[name] = err ? -1 : 2;
|
1462
|
+
if (err && data) this.state[name] = 0;
|
1463
|
+
const loaded = {};
|
1464
|
+
this.queue.forEach(q => {
|
1465
|
+
pushPath(q.loaded, [lng], ns);
|
1466
|
+
removePending(q, name);
|
1467
|
+
if (err) q.errors.push(err);
|
1468
|
+
if (q.pendingCount === 0 && !q.done) {
|
1469
|
+
Object.keys(q.loaded).forEach(l => {
|
1470
|
+
if (!loaded[l]) loaded[l] = {};
|
1471
|
+
const loadedKeys = q.loaded[l];
|
1472
|
+
if (loadedKeys.length) {
|
1473
|
+
loadedKeys.forEach(n => {
|
1474
|
+
if (loaded[l][n] === undefined) loaded[l][n] = true;
|
1475
|
+
});
|
1476
|
+
}
|
1477
|
+
});
|
1478
|
+
q.done = true;
|
1479
|
+
if (q.errors.length) {
|
1480
|
+
q.callback(q.errors);
|
1481
|
+
} else {
|
1482
|
+
q.callback();
|
1483
|
+
}
|
1484
|
+
}
|
1485
|
+
});
|
1486
|
+
this.emit('loaded', loaded);
|
1487
|
+
this.queue = this.queue.filter(q => !q.done);
|
1488
|
+
}
|
1489
|
+
read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
|
1490
|
+
if (!lng.length) return callback(null, {});
|
1491
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
1492
|
+
this.waitingReads.push({
|
1493
|
+
lng,
|
1494
|
+
ns,
|
1495
|
+
fcName,
|
1496
|
+
tried,
|
1497
|
+
wait,
|
1498
|
+
callback
|
1499
|
+
});
|
1500
|
+
return;
|
1501
|
+
}
|
1502
|
+
this.readingCalls++;
|
1503
|
+
const resolver = (err, data) => {
|
1504
|
+
this.readingCalls--;
|
1505
|
+
if (this.waitingReads.length > 0) {
|
1506
|
+
const next = this.waitingReads.shift();
|
1507
|
+
this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
1508
|
+
}
|
1509
|
+
if (err && data && tried < this.maxRetries) {
|
1510
|
+
setTimeout(() => {
|
1511
|
+
this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
|
1512
|
+
}, wait);
|
1513
|
+
return;
|
1514
|
+
}
|
1515
|
+
callback(err, data);
|
1516
|
+
};
|
1517
|
+
const fc = this.backend[fcName].bind(this.backend);
|
1518
|
+
if (fc.length === 2) {
|
1519
|
+
try {
|
1520
|
+
const r = fc(lng, ns);
|
1521
|
+
if (r && typeof r.then === 'function') {
|
1522
|
+
r.then(data => resolver(null, data)).catch(resolver);
|
1523
|
+
} else {
|
1524
|
+
resolver(null, r);
|
1525
|
+
}
|
1526
|
+
} catch (err) {
|
1527
|
+
resolver(err);
|
1528
|
+
}
|
1529
|
+
return;
|
1530
|
+
}
|
1531
|
+
return fc(lng, ns, resolver);
|
1532
|
+
}
|
1533
|
+
prepareLoading(languages, namespaces, options = {}, callback) {
|
1534
|
+
if (!this.backend) {
|
1535
|
+
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
1536
|
+
return callback && callback();
|
1537
|
+
}
|
1538
|
+
if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
|
1539
|
+
if (isString(namespaces)) namespaces = [namespaces];
|
1540
|
+
const toLoad = this.queueLoad(languages, namespaces, options, callback);
|
1541
|
+
if (!toLoad.toLoad.length) {
|
1542
|
+
if (!toLoad.pending.length) callback();
|
1543
|
+
return null;
|
1544
|
+
}
|
1545
|
+
toLoad.toLoad.forEach(name => {
|
1546
|
+
this.loadOne(name);
|
1547
|
+
});
|
1548
|
+
}
|
1549
|
+
load(languages, namespaces, callback) {
|
1550
|
+
this.prepareLoading(languages, namespaces, {}, callback);
|
1551
|
+
}
|
1552
|
+
reload(languages, namespaces, callback) {
|
1553
|
+
this.prepareLoading(languages, namespaces, {
|
1554
|
+
reload: true
|
1555
|
+
}, callback);
|
1556
|
+
}
|
1557
|
+
loadOne(name, prefix = '') {
|
1558
|
+
const s = name.split('|');
|
1559
|
+
const lng = s[0];
|
1560
|
+
const ns = s[1];
|
1561
|
+
this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
|
1562
|
+
if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
|
1563
|
+
if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
|
1564
|
+
this.loaded(name, err, data);
|
1565
|
+
});
|
1566
|
+
}
|
1567
|
+
saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
|
1568
|
+
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
|
1569
|
+
this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" 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!!!');
|
1570
|
+
return;
|
1571
|
+
}
|
1572
|
+
if (key === undefined || key === null || key === '') return;
|
1573
|
+
if (this.backend?.create) {
|
1574
|
+
const opts = {
|
1575
|
+
...options,
|
1576
|
+
isUpdate
|
1577
|
+
};
|
1578
|
+
const fc = this.backend.create.bind(this.backend);
|
1579
|
+
if (fc.length < 6) {
|
1580
|
+
try {
|
1581
|
+
let r;
|
1582
|
+
if (fc.length === 5) {
|
1583
|
+
r = fc(languages, namespace, key, fallbackValue, opts);
|
1584
|
+
} else {
|
1585
|
+
r = fc(languages, namespace, key, fallbackValue);
|
1586
|
+
}
|
1587
|
+
if (r && typeof r.then === 'function') {
|
1588
|
+
r.then(data => clb(null, data)).catch(clb);
|
1589
|
+
} else {
|
1590
|
+
clb(null, r);
|
1591
|
+
}
|
1592
|
+
} catch (err) {
|
1593
|
+
clb(err);
|
1594
|
+
}
|
1595
|
+
} else {
|
1596
|
+
fc(languages, namespace, key, fallbackValue, clb, opts);
|
1597
|
+
}
|
1598
|
+
}
|
1599
|
+
if (!languages || !languages[0]) return;
|
1600
|
+
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
1601
|
+
}
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
const get = () => ({
|
1605
|
+
debug: false,
|
1606
|
+
initAsync: true,
|
1607
|
+
ns: ['translation'],
|
1608
|
+
defaultNS: ['translation'],
|
1609
|
+
fallbackLng: ['dev'],
|
1610
|
+
fallbackNS: false,
|
1611
|
+
supportedLngs: false,
|
1612
|
+
nonExplicitSupportedLngs: false,
|
1613
|
+
load: 'all',
|
1614
|
+
preload: false,
|
1615
|
+
simplifyPluralSuffix: true,
|
1616
|
+
keySeparator: '.',
|
1617
|
+
nsSeparator: ':',
|
1618
|
+
pluralSeparator: '_',
|
1619
|
+
contextSeparator: '_',
|
1620
|
+
partialBundledLanguages: false,
|
1621
|
+
saveMissing: false,
|
1622
|
+
updateMissing: false,
|
1623
|
+
saveMissingTo: 'fallback',
|
1624
|
+
saveMissingPlurals: true,
|
1625
|
+
missingKeyHandler: false,
|
1626
|
+
missingInterpolationHandler: false,
|
1627
|
+
postProcess: false,
|
1628
|
+
postProcessPassResolved: false,
|
1629
|
+
returnNull: false,
|
1630
|
+
returnEmptyString: true,
|
1631
|
+
returnObjects: false,
|
1632
|
+
joinArrays: false,
|
1633
|
+
returnedObjectHandler: false,
|
1634
|
+
parseMissingKeyHandler: false,
|
1635
|
+
appendNamespaceToMissingKey: false,
|
1636
|
+
appendNamespaceToCIMode: false,
|
1637
|
+
overloadTranslationOptionHandler: args => {
|
1638
|
+
let ret = {};
|
1639
|
+
if (typeof args[1] === 'object') ret = args[1];
|
1640
|
+
if (isString(args[1])) ret.defaultValue = args[1];
|
1641
|
+
if (isString(args[2])) ret.tDescription = args[2];
|
1642
|
+
if (typeof args[2] === 'object' || typeof args[3] === 'object') {
|
1643
|
+
const options = args[3] || args[2];
|
1644
|
+
Object.keys(options).forEach(key => {
|
1645
|
+
ret[key] = options[key];
|
1646
|
+
});
|
1647
|
+
}
|
1648
|
+
return ret;
|
1649
|
+
},
|
1650
|
+
interpolation: {
|
1651
|
+
escapeValue: true,
|
1652
|
+
format: value => value,
|
1653
|
+
prefix: '{{',
|
1654
|
+
suffix: '}}',
|
1655
|
+
formatSeparator: ',',
|
1656
|
+
unescapePrefix: '-',
|
1657
|
+
nestingPrefix: '$t(',
|
1658
|
+
nestingSuffix: ')',
|
1659
|
+
nestingOptionsSeparator: ',',
|
1660
|
+
maxReplaces: 1000,
|
1661
|
+
skipOnVariables: true
|
1662
|
+
},
|
1663
|
+
cacheInBuiltFormats: true
|
1664
|
+
});
|
1665
|
+
const transformOptions = options => {
|
1666
|
+
if (isString(options.ns)) options.ns = [options.ns];
|
1667
|
+
if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
1668
|
+
if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
1669
|
+
if (options.supportedLngs?.indexOf?.('cimode') < 0) {
|
1670
|
+
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
1671
|
+
}
|
1672
|
+
if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
|
1673
|
+
return options;
|
1674
|
+
};
|
1675
|
+
|
1676
|
+
const noop = () => {};
|
1677
|
+
const bindMemberFunctions = inst => {
|
1678
|
+
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
1679
|
+
mems.forEach(mem => {
|
1680
|
+
if (typeof inst[mem] === 'function') {
|
1681
|
+
inst[mem] = inst[mem].bind(inst);
|
1682
|
+
}
|
1683
|
+
});
|
1684
|
+
};
|
1685
|
+
class I18n extends EventEmitter {
|
1686
|
+
constructor(options = {}, callback) {
|
1687
|
+
super();
|
1688
|
+
this.options = transformOptions(options);
|
1689
|
+
this.services = {};
|
1690
|
+
this.logger = baseLogger;
|
1691
|
+
this.modules = {
|
1692
|
+
external: []
|
1693
|
+
};
|
1694
|
+
bindMemberFunctions(this);
|
1695
|
+
if (callback && !this.isInitialized && !options.isClone) {
|
1696
|
+
if (!this.options.initAsync) {
|
1697
|
+
this.init(options, callback);
|
1698
|
+
return this;
|
1699
|
+
}
|
1700
|
+
setTimeout(() => {
|
1701
|
+
this.init(options, callback);
|
1702
|
+
}, 0);
|
1703
|
+
}
|
1704
|
+
}
|
1705
|
+
init(options = {}, callback) {
|
1706
|
+
this.isInitializing = true;
|
1707
|
+
if (typeof options === 'function') {
|
1708
|
+
callback = options;
|
1709
|
+
options = {};
|
1710
|
+
}
|
1711
|
+
if (options.defaultNS == null && options.ns) {
|
1712
|
+
if (isString(options.ns)) {
|
1713
|
+
options.defaultNS = options.ns;
|
1714
|
+
} else if (options.ns.indexOf('translation') < 0) {
|
1715
|
+
options.defaultNS = options.ns[0];
|
1716
|
+
}
|
1717
|
+
}
|
1718
|
+
const defOpts = get();
|
1719
|
+
this.options = {
|
1720
|
+
...defOpts,
|
1721
|
+
...this.options,
|
1722
|
+
...transformOptions(options)
|
1723
|
+
};
|
1724
|
+
this.options.interpolation = {
|
1725
|
+
...defOpts.interpolation,
|
1726
|
+
...this.options.interpolation
|
1727
|
+
};
|
1728
|
+
if (options.keySeparator !== undefined) {
|
1729
|
+
this.options.userDefinedKeySeparator = options.keySeparator;
|
1730
|
+
}
|
1731
|
+
if (options.nsSeparator !== undefined) {
|
1732
|
+
this.options.userDefinedNsSeparator = options.nsSeparator;
|
1733
|
+
}
|
1734
|
+
const createClassOnDemand = ClassOrObject => {
|
1735
|
+
if (!ClassOrObject) return null;
|
1736
|
+
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
1737
|
+
return ClassOrObject;
|
1738
|
+
};
|
1739
|
+
if (!this.options.isClone) {
|
1740
|
+
if (this.modules.logger) {
|
1741
|
+
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
1742
|
+
} else {
|
1743
|
+
baseLogger.init(null, this.options);
|
1744
|
+
}
|
1745
|
+
let formatter;
|
1746
|
+
if (this.modules.formatter) {
|
1747
|
+
formatter = this.modules.formatter;
|
1748
|
+
} else {
|
1749
|
+
formatter = Formatter;
|
1750
|
+
}
|
1751
|
+
const lu = new LanguageUtil(this.options);
|
1752
|
+
this.store = new ResourceStore(this.options.resources, this.options);
|
1753
|
+
const s = this.services;
|
1754
|
+
s.logger = baseLogger;
|
1755
|
+
s.resourceStore = this.store;
|
1756
|
+
s.languageUtils = lu;
|
1757
|
+
s.pluralResolver = new PluralResolver(lu, {
|
1758
|
+
prepend: this.options.pluralSeparator,
|
1759
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
1760
|
+
});
|
1761
|
+
const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
|
1762
|
+
if (usingLegacyFormatFunction) {
|
1763
|
+
this.logger.warn(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
1764
|
+
}
|
1765
|
+
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
1766
|
+
s.formatter = createClassOnDemand(formatter);
|
1767
|
+
if (s.formatter.init) s.formatter.init(s, this.options);
|
1768
|
+
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
1769
|
+
}
|
1770
|
+
s.interpolator = new Interpolator(this.options);
|
1771
|
+
s.utils = {
|
1772
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
1773
|
+
};
|
1774
|
+
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
1775
|
+
s.backendConnector.on('*', (event, ...args) => {
|
1776
|
+
this.emit(event, ...args);
|
1777
|
+
});
|
1778
|
+
if (this.modules.languageDetector) {
|
1779
|
+
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
1780
|
+
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
1781
|
+
}
|
1782
|
+
if (this.modules.i18nFormat) {
|
1783
|
+
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
1784
|
+
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
1785
|
+
}
|
1786
|
+
this.translator = new Translator(this.services, this.options);
|
1787
|
+
this.translator.on('*', (event, ...args) => {
|
1788
|
+
this.emit(event, ...args);
|
1789
|
+
});
|
1790
|
+
this.modules.external.forEach(m => {
|
1791
|
+
if (m.init) m.init(this);
|
1792
|
+
});
|
1793
|
+
}
|
1794
|
+
this.format = this.options.interpolation.format;
|
1795
|
+
if (!callback) callback = noop;
|
1796
|
+
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
1797
|
+
const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
1798
|
+
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
1799
|
+
}
|
1800
|
+
if (!this.services.languageDetector && !this.options.lng) {
|
1801
|
+
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
1802
|
+
}
|
1803
|
+
const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
1804
|
+
storeApi.forEach(fcName => {
|
1805
|
+
this[fcName] = (...args) => this.store[fcName](...args);
|
1806
|
+
});
|
1807
|
+
const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
|
1808
|
+
storeApiChained.forEach(fcName => {
|
1809
|
+
this[fcName] = (...args) => {
|
1810
|
+
this.store[fcName](...args);
|
1811
|
+
return this;
|
1812
|
+
};
|
1813
|
+
});
|
1814
|
+
const deferred = defer();
|
1815
|
+
const load = () => {
|
1816
|
+
const finish = (err, t) => {
|
1817
|
+
this.isInitializing = false;
|
1818
|
+
if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
|
1819
|
+
this.isInitialized = true;
|
1820
|
+
if (!this.options.isClone) this.logger.log('initialized', this.options);
|
1821
|
+
this.emit('initialized', this.options);
|
1822
|
+
deferred.resolve(t);
|
1823
|
+
callback(err, t);
|
1824
|
+
};
|
1825
|
+
if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
|
1826
|
+
this.changeLanguage(this.options.lng, finish);
|
1827
|
+
};
|
1828
|
+
if (this.options.resources || !this.options.initAsync) {
|
1829
|
+
load();
|
1830
|
+
} else {
|
1831
|
+
setTimeout(load, 0);
|
1832
|
+
}
|
1833
|
+
return deferred;
|
1834
|
+
}
|
1835
|
+
loadResources(language, callback = noop) {
|
1836
|
+
let usedCallback = callback;
|
1837
|
+
const usedLng = isString(language) ? language : this.language;
|
1838
|
+
if (typeof language === 'function') usedCallback = language;
|
1839
|
+
if (!this.options.resources || this.options.partialBundledLanguages) {
|
1840
|
+
if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
|
1841
|
+
const toLoad = [];
|
1842
|
+
const append = lng => {
|
1843
|
+
if (!lng) return;
|
1844
|
+
if (lng === 'cimode') return;
|
1845
|
+
const lngs = this.services.languageUtils.toResolveHierarchy(lng);
|
1846
|
+
lngs.forEach(l => {
|
1847
|
+
if (l === 'cimode') return;
|
1848
|
+
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
1849
|
+
});
|
1850
|
+
};
|
1851
|
+
if (!usedLng) {
|
1852
|
+
const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
1853
|
+
fallbacks.forEach(l => append(l));
|
1854
|
+
} else {
|
1855
|
+
append(usedLng);
|
1856
|
+
}
|
1857
|
+
this.options.preload?.forEach?.(l => append(l));
|
1858
|
+
this.services.backendConnector.load(toLoad, this.options.ns, e => {
|
1859
|
+
if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
|
1860
|
+
usedCallback(e);
|
1861
|
+
});
|
1862
|
+
} else {
|
1863
|
+
usedCallback(null);
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
reloadResources(lngs, ns, callback) {
|
1867
|
+
const deferred = defer();
|
1868
|
+
if (typeof lngs === 'function') {
|
1869
|
+
callback = lngs;
|
1870
|
+
lngs = undefined;
|
1871
|
+
}
|
1872
|
+
if (typeof ns === 'function') {
|
1873
|
+
callback = ns;
|
1874
|
+
ns = undefined;
|
1875
|
+
}
|
1876
|
+
if (!lngs) lngs = this.languages;
|
1877
|
+
if (!ns) ns = this.options.ns;
|
1878
|
+
if (!callback) callback = noop;
|
1879
|
+
this.services.backendConnector.reload(lngs, ns, err => {
|
1880
|
+
deferred.resolve();
|
1881
|
+
callback(err);
|
1882
|
+
});
|
1883
|
+
return deferred;
|
1884
|
+
}
|
1885
|
+
use(module) {
|
1886
|
+
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
1887
|
+
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
1888
|
+
if (module.type === 'backend') {
|
1889
|
+
this.modules.backend = module;
|
1890
|
+
}
|
1891
|
+
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
1892
|
+
this.modules.logger = module;
|
1893
|
+
}
|
1894
|
+
if (module.type === 'languageDetector') {
|
1895
|
+
this.modules.languageDetector = module;
|
1896
|
+
}
|
1897
|
+
if (module.type === 'i18nFormat') {
|
1898
|
+
this.modules.i18nFormat = module;
|
1899
|
+
}
|
1900
|
+
if (module.type === 'postProcessor') {
|
1901
|
+
postProcessor.addPostProcessor(module);
|
1902
|
+
}
|
1903
|
+
if (module.type === 'formatter') {
|
1904
|
+
this.modules.formatter = module;
|
1905
|
+
}
|
1906
|
+
if (module.type === '3rdParty') {
|
1907
|
+
this.modules.external.push(module);
|
1908
|
+
}
|
1909
|
+
return this;
|
1910
|
+
}
|
1911
|
+
setResolvedLanguage(l) {
|
1912
|
+
if (!l || !this.languages) return;
|
1913
|
+
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
1914
|
+
for (let li = 0; li < this.languages.length; li++) {
|
1915
|
+
const lngInLngs = this.languages[li];
|
1916
|
+
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
1917
|
+
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
1918
|
+
this.resolvedLanguage = lngInLngs;
|
1919
|
+
break;
|
1920
|
+
}
|
1921
|
+
}
|
1922
|
+
if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
|
1923
|
+
this.resolvedLanguage = l;
|
1924
|
+
this.languages.unshift(l);
|
1925
|
+
}
|
1926
|
+
}
|
1927
|
+
changeLanguage(lng, callback) {
|
1928
|
+
this.isLanguageChangingTo = lng;
|
1929
|
+
const deferred = defer();
|
1930
|
+
this.emit('languageChanging', lng);
|
1931
|
+
const setLngProps = l => {
|
1932
|
+
this.language = l;
|
1933
|
+
this.languages = this.services.languageUtils.toResolveHierarchy(l);
|
1934
|
+
this.resolvedLanguage = undefined;
|
1935
|
+
this.setResolvedLanguage(l);
|
1936
|
+
};
|
1937
|
+
const done = (err, l) => {
|
1938
|
+
if (l) {
|
1939
|
+
if (this.isLanguageChangingTo === lng) {
|
1940
|
+
setLngProps(l);
|
1941
|
+
this.translator.changeLanguage(l);
|
1942
|
+
this.isLanguageChangingTo = undefined;
|
1943
|
+
this.emit('languageChanged', l);
|
1944
|
+
this.logger.log('languageChanged', l);
|
1945
|
+
}
|
1946
|
+
} else {
|
1947
|
+
this.isLanguageChangingTo = undefined;
|
1948
|
+
}
|
1949
|
+
deferred.resolve((...args) => this.t(...args));
|
1950
|
+
if (callback) callback(err, (...args) => this.t(...args));
|
1951
|
+
};
|
1952
|
+
const setLng = lngs => {
|
1953
|
+
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
1954
|
+
const fl = isString(lngs) ? lngs : lngs && lngs[0];
|
1955
|
+
const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
|
1956
|
+
if (l) {
|
1957
|
+
if (!this.language) {
|
1958
|
+
setLngProps(l);
|
1959
|
+
}
|
1960
|
+
if (!this.translator.language) this.translator.changeLanguage(l);
|
1961
|
+
this.services.languageDetector?.cacheUserLanguage?.(l);
|
1962
|
+
}
|
1963
|
+
this.loadResources(l, err => {
|
1964
|
+
done(err, l);
|
1965
|
+
});
|
1966
|
+
};
|
1967
|
+
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
1968
|
+
setLng(this.services.languageDetector.detect());
|
1969
|
+
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
1970
|
+
if (this.services.languageDetector.detect.length === 0) {
|
1971
|
+
this.services.languageDetector.detect().then(setLng);
|
1972
|
+
} else {
|
1973
|
+
this.services.languageDetector.detect(setLng);
|
1974
|
+
}
|
1975
|
+
} else {
|
1976
|
+
setLng(lng);
|
1977
|
+
}
|
1978
|
+
return deferred;
|
1979
|
+
}
|
1980
|
+
getFixedT(lng, ns, keyPrefix) {
|
1981
|
+
const fixedT = (key, opts, ...rest) => {
|
1982
|
+
let o;
|
1983
|
+
if (typeof opts !== 'object') {
|
1984
|
+
o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
1985
|
+
} else {
|
1986
|
+
o = {
|
1987
|
+
...opts
|
1988
|
+
};
|
1989
|
+
}
|
1990
|
+
o.lng = o.lng || fixedT.lng;
|
1991
|
+
o.lngs = o.lngs || fixedT.lngs;
|
1992
|
+
o.ns = o.ns || fixedT.ns;
|
1993
|
+
if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
1994
|
+
const keySeparator = this.options.keySeparator || '.';
|
1995
|
+
let resultKey;
|
1996
|
+
if (o.keyPrefix && Array.isArray(key)) {
|
1997
|
+
resultKey = key.map(k => `${o.keyPrefix}${keySeparator}${k}`);
|
1998
|
+
} else {
|
1999
|
+
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
2000
|
+
}
|
2001
|
+
return this.t(resultKey, o);
|
2002
|
+
};
|
2003
|
+
if (isString(lng)) {
|
2004
|
+
fixedT.lng = lng;
|
2005
|
+
} else {
|
2006
|
+
fixedT.lngs = lng;
|
2007
|
+
}
|
2008
|
+
fixedT.ns = ns;
|
2009
|
+
fixedT.keyPrefix = keyPrefix;
|
2010
|
+
return fixedT;
|
2011
|
+
}
|
2012
|
+
t(...args) {
|
2013
|
+
return this.translator?.translate(...args);
|
2014
|
+
}
|
2015
|
+
exists(...args) {
|
2016
|
+
return this.translator?.exists(...args);
|
2017
|
+
}
|
2018
|
+
setDefaultNamespace(ns) {
|
2019
|
+
this.options.defaultNS = ns;
|
2020
|
+
}
|
2021
|
+
hasLoadedNamespace(ns, options = {}) {
|
2022
|
+
if (!this.isInitialized) {
|
2023
|
+
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
2024
|
+
return false;
|
2025
|
+
}
|
2026
|
+
if (!this.languages || !this.languages.length) {
|
2027
|
+
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
2028
|
+
return false;
|
2029
|
+
}
|
2030
|
+
const lng = options.lng || this.resolvedLanguage || this.languages[0];
|
2031
|
+
const fallbackLng = this.options ? this.options.fallbackLng : false;
|
2032
|
+
const lastLng = this.languages[this.languages.length - 1];
|
2033
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
2034
|
+
const loadNotPending = (l, n) => {
|
2035
|
+
const loadState = this.services.backendConnector.state[`${l}|${n}`];
|
2036
|
+
return loadState === -1 || loadState === 0 || loadState === 2;
|
2037
|
+
};
|
2038
|
+
if (options.precheck) {
|
2039
|
+
const preResult = options.precheck(this, loadNotPending);
|
2040
|
+
if (preResult !== undefined) return preResult;
|
2041
|
+
}
|
2042
|
+
if (this.hasResourceBundle(lng, ns)) return true;
|
2043
|
+
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
2044
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
2045
|
+
return false;
|
2046
|
+
}
|
2047
|
+
loadNamespaces(ns, callback) {
|
2048
|
+
const deferred = defer();
|
2049
|
+
if (!this.options.ns) {
|
2050
|
+
if (callback) callback();
|
2051
|
+
return Promise.resolve();
|
2052
|
+
}
|
2053
|
+
if (isString(ns)) ns = [ns];
|
2054
|
+
ns.forEach(n => {
|
2055
|
+
if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
|
2056
|
+
});
|
2057
|
+
this.loadResources(err => {
|
2058
|
+
deferred.resolve();
|
2059
|
+
if (callback) callback(err);
|
2060
|
+
});
|
2061
|
+
return deferred;
|
2062
|
+
}
|
2063
|
+
loadLanguages(lngs, callback) {
|
2064
|
+
const deferred = defer();
|
2065
|
+
if (isString(lngs)) lngs = [lngs];
|
2066
|
+
const preloaded = this.options.preload || [];
|
2067
|
+
const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
|
2068
|
+
if (!newLngs.length) {
|
2069
|
+
if (callback) callback();
|
2070
|
+
return Promise.resolve();
|
2071
|
+
}
|
2072
|
+
this.options.preload = preloaded.concat(newLngs);
|
2073
|
+
this.loadResources(err => {
|
2074
|
+
deferred.resolve();
|
2075
|
+
if (callback) callback(err);
|
2076
|
+
});
|
2077
|
+
return deferred;
|
2078
|
+
}
|
2079
|
+
dir(lng) {
|
2080
|
+
if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
|
2081
|
+
if (!lng) return 'rtl';
|
2082
|
+
try {
|
2083
|
+
const l = new Intl.Locale(lng);
|
2084
|
+
if (l && l.getTextInfo) {
|
2085
|
+
const ti = l.getTextInfo();
|
2086
|
+
if (ti && ti.direction) return ti.direction;
|
2087
|
+
}
|
2088
|
+
} catch (e) {}
|
2089
|
+
const rtlLngs = ['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'];
|
2090
|
+
const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
|
2091
|
+
if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
|
2092
|
+
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
2093
|
+
}
|
2094
|
+
static createInstance(options = {}, callback) {
|
2095
|
+
return new I18n(options, callback);
|
2096
|
+
}
|
2097
|
+
cloneInstance(options = {}, callback = noop) {
|
2098
|
+
const forkResourceStore = options.forkResourceStore;
|
2099
|
+
if (forkResourceStore) delete options.forkResourceStore;
|
2100
|
+
const mergedOptions = {
|
2101
|
+
...this.options,
|
2102
|
+
...options,
|
2103
|
+
...{
|
2104
|
+
isClone: true
|
2105
|
+
}
|
2106
|
+
};
|
2107
|
+
const clone = new I18n(mergedOptions);
|
2108
|
+
if (options.debug !== undefined || options.prefix !== undefined) {
|
2109
|
+
clone.logger = clone.logger.clone(options);
|
2110
|
+
}
|
2111
|
+
const membersToCopy = ['store', 'services', 'language'];
|
2112
|
+
membersToCopy.forEach(m => {
|
2113
|
+
clone[m] = this[m];
|
2114
|
+
});
|
2115
|
+
clone.services = {
|
2116
|
+
...this.services
|
2117
|
+
};
|
2118
|
+
clone.services.utils = {
|
2119
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
2120
|
+
};
|
2121
|
+
if (forkResourceStore) {
|
2122
|
+
const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
|
2123
|
+
prev[l] = {
|
2124
|
+
...this.store.data[l]
|
2125
|
+
};
|
2126
|
+
prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
|
2127
|
+
acc[n] = {
|
2128
|
+
...prev[l][n]
|
2129
|
+
};
|
2130
|
+
return acc;
|
2131
|
+
}, prev[l]);
|
2132
|
+
return prev;
|
2133
|
+
}, {});
|
2134
|
+
clone.store = new ResourceStore(clonedData, mergedOptions);
|
2135
|
+
clone.services.resourceStore = clone.store;
|
2136
|
+
}
|
2137
|
+
clone.translator = new Translator(clone.services, mergedOptions);
|
2138
|
+
clone.translator.on('*', (event, ...args) => {
|
2139
|
+
clone.emit(event, ...args);
|
2140
|
+
});
|
2141
|
+
clone.init(mergedOptions, callback);
|
2142
|
+
clone.translator.options = mergedOptions;
|
2143
|
+
clone.translator.backendConnector.services.utils = {
|
2144
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
2145
|
+
};
|
2146
|
+
return clone;
|
2147
|
+
}
|
2148
|
+
toJSON() {
|
2149
|
+
return {
|
2150
|
+
options: this.options,
|
2151
|
+
store: this.store,
|
2152
|
+
language: this.language,
|
2153
|
+
languages: this.languages,
|
2154
|
+
resolvedLanguage: this.resolvedLanguage
|
2155
|
+
};
|
2156
|
+
}
|
2157
|
+
}
|
2158
|
+
const instance = I18n.createInstance();
|
2159
|
+
instance.createInstance = I18n.createInstance;
|
2160
|
+
|
2161
|
+
function getWindow() {
|
2162
|
+
return window;
|
2163
|
+
}
|
2164
|
+
function getAtomicEnvironment(headlessVersion) {
|
2165
|
+
return {
|
2166
|
+
version: "3.35.0-pre.c86b349898",
|
2167
|
+
headlessVersion,
|
2168
|
+
};
|
2169
|
+
}
|
2170
|
+
function getAtomicVersion() {
|
2171
|
+
return getAtomicEnvironment('').version;
|
2172
|
+
}
|
2173
|
+
function setCoveoGlobal(globalVariableName, headlessVersion) {
|
2174
|
+
if (getWindow()[globalVariableName]) {
|
2175
|
+
return;
|
2176
|
+
}
|
2177
|
+
getWindow()[globalVariableName] = getAtomicEnvironment(headlessVersion);
|
2178
|
+
}
|
2179
|
+
|
2180
|
+
const locales = {
|
2181
|
+
af: () => import('./af-b3faf91e.js').then(function (n) { return n.a; }),
|
2182
|
+
am: () => import('./am-e9cb6364.js').then(function (n) { return n.a; }),
|
2183
|
+
'ar-DZ': () => import('./ar-dz-5ba0c69a.js').then(function (n) { return n.a; }),
|
2184
|
+
'ar-IQ': () => import('./ar-iq-3d2e5b8a.js').then(function (n) { return n.a; }),
|
2185
|
+
'ar-KW': () => import('./ar-kw-e126035d.js').then(function (n) { return n.a; }),
|
2186
|
+
'ar-LY': () => import('./ar-ly-2924eb0c.js').then(function (n) { return n.a; }),
|
2187
|
+
'ar-MA': () => import('./ar-ma-afb201be.js').then(function (n) { return n.a; }),
|
2188
|
+
'ar-SA': () => import('./ar-sa-10527551.js').then(function (n) { return n.a; }),
|
2189
|
+
'ar-TN': () => import('./ar-tn-fc69128d.js').then(function (n) { return n.a; }),
|
2190
|
+
ar: () => import('./ar-cb6d7ed9.js').then(function (n) { return n.a; }),
|
2191
|
+
az: () => import('./az-199a5a03.js').then(function (n) { return n.a; }),
|
2192
|
+
be: () => import('./be-794487fa.js').then(function (n) { return n.b; }),
|
2193
|
+
bg: () => import('./bg-c99d9a27.js').then(function (n) { return n.b; }),
|
2194
|
+
bi: () => import('./bi-124c11c0.js').then(function (n) { return n.b; }),
|
2195
|
+
bm: () => import('./bm-252381bb.js').then(function (n) { return n.b; }),
|
2196
|
+
'bn-BD': () => import('./bn-bd-3970b0f8.js').then(function (n) { return n.b; }),
|
2197
|
+
bn: () => import('./bn-b080ba5b.js').then(function (n) { return n.b; }),
|
2198
|
+
bo: () => import('./bo-e303874c.js').then(function (n) { return n.b; }),
|
2199
|
+
br: () => import('./br-6f4c4f3c.js').then(function (n) { return n.b; }),
|
2200
|
+
bs: () => import('./bs-b0d64727.js').then(function (n) { return n.b; }),
|
2201
|
+
ca: () => import('./ca-92df40c1.js').then(function (n) { return n.c; }),
|
2202
|
+
cs: () => import('./cs-24a0d8df.js').then(function (n) { return n.c; }),
|
2203
|
+
cv: () => import('./cv-5c3bf49d.js').then(function (n) { return n.c; }),
|
2204
|
+
cy: () => import('./cy-f6001872.js').then(function (n) { return n.c; }),
|
2205
|
+
'de-AT': () => import('./de-at-a40f7f74.js').then(function (n) { return n.d; }),
|
2206
|
+
da: () => import('./da-15f86fbe.js').then(function (n) { return n.d; }),
|
2207
|
+
'de-CH': () => import('./de-ch-a30a335b.js').then(function (n) { return n.d; }),
|
2208
|
+
de: () => import('./de-4ce42d40.js').then(function (n) { return n.d; }),
|
2209
|
+
dv: () => import('./dv-9f6bc9bf.js').then(function (n) { return n.d; }),
|
2210
|
+
el: () => import('./el-148a8b97.js').then(function (n) { return n.e; }),
|
2211
|
+
'en-AU': () => import('./en-au-71a08338.js').then(function (n) { return n.e; }),
|
2212
|
+
'en-CA': () => import('./en-ca-64578981.js').then(function (n) { return n.e; }),
|
2213
|
+
'en-GB': () => import('./en-gb-05fb760e.js').then(function (n) { return n.e; }),
|
2214
|
+
'en-IE': () => import('./en-ie-9f15184e.js').then(function (n) { return n.e; }),
|
2215
|
+
'en-IL': () => import('./en-il-dc1c6c06.js').then(function (n) { return n.e; }),
|
2216
|
+
'en-IN': () => import('./en-in-d7952971.js').then(function (n) { return n.e; }),
|
2217
|
+
'en-NZ': () => import('./en-nz-a0ca8c2c.js').then(function (n) { return n.e; }),
|
2218
|
+
'en-SG': () => import('./en-sg-572efd00.js').then(function (n) { return n.e; }),
|
2219
|
+
'en-TT': () => import('./en-tt-7b213249.js').then(function (n) { return n.e; }),
|
2220
|
+
eo: () => import('./eo-08ef2039.js').then(function (n) { return n.e; }),
|
2221
|
+
en: () => import('./en-9ec8ae09.js').then(function (n) { return n.e; }),
|
2222
|
+
'es-DO': () => import('./es-do-2eea52e8.js').then(function (n) { return n.e; }),
|
2223
|
+
'es-MX': () => import('./es-mx-3ec49afa.js').then(function (n) { return n.e; }),
|
2224
|
+
'es-PR': () => import('./es-pr-f87fb1b9.js').then(function (n) { return n.e; }),
|
2225
|
+
'es-US': () => import('./es-us-d9081646.js').then(function (n) { return n.e; }),
|
2226
|
+
et: () => import('./et-8c682b5a.js').then(function (n) { return n.e; }),
|
2227
|
+
es: () => import('./es-d6e72728.js').then(function (n) { return n.e; }),
|
2228
|
+
eu: () => import('./eu-63210626.js').then(function (n) { return n.e; }),
|
2229
|
+
fa: () => import('./fa-1f4a0a77.js').then(function (n) { return n.f; }),
|
2230
|
+
fo: () => import('./fo-72be1810.js').then(function (n) { return n.f; }),
|
2231
|
+
fi: () => import('./fi-cb158514.js').then(function (n) { return n.f; }),
|
2232
|
+
'fr-CA': () => import('./fr-ca-7fb4ed5c.js').then(function (n) { return n.f; }),
|
2233
|
+
'fr-CH': () => import('./fr-ch-36bbe813.js').then(function (n) { return n.f; }),
|
2234
|
+
fr: () => import('./fr-4da8b2ac.js').then(function (n) { return n.f; }),
|
2235
|
+
fy: () => import('./fy-b1eb2831.js').then(function (n) { return n.f; }),
|
2236
|
+
ga: () => import('./ga-85f2952b.js').then(function (n) { return n.g; }),
|
2237
|
+
gd: () => import('./gd-3408acaf.js').then(function (n) { return n.g; }),
|
2238
|
+
'gom-LATN': () => import('./gom-latn-e22fddc8.js').then(function (n) { return n.g; }),
|
2239
|
+
gl: () => import('./gl-cd87ea7f.js').then(function (n) { return n.g; }),
|
2240
|
+
gu: () => import('./gu-8cdbd4f7.js').then(function (n) { return n.g; }),
|
2241
|
+
he: () => import('./he-6d85be54.js').then(function (n) { return n.h; }),
|
2242
|
+
hi: () => import('./hi-f41b5a66.js').then(function (n) { return n.h; }),
|
2243
|
+
hr: () => import('./hr-cacc6068.js').then(function (n) { return n.h; }),
|
2244
|
+
hu: () => import('./hu-de350c06.js').then(function (n) { return n.h; }),
|
2245
|
+
ht: () => import('./ht-22455dcc.js').then(function (n) { return n.h; }),
|
2246
|
+
'hy-AM': () => import('./hy-am-81d1c652.js').then(function (n) { return n.h; }),
|
2247
|
+
id: () => import('./id-81fd66c1.js').then(function (n) { return n.i; }),
|
2248
|
+
is: () => import('./is-5856cbb7.js').then(function (n) { return n.i; }),
|
2249
|
+
'it-CH': () => import('./it-ch-dfcf6a22.js').then(function (n) { return n.i; }),
|
2250
|
+
it: () => import('./it-18c0d3e6.js').then(function (n) { return n.i; }),
|
2251
|
+
ja: () => import('./ja-c46d4b1e.js').then(function (n) { return n.j; }),
|
2252
|
+
jv: () => import('./jv-fbdffaf2.js').then(function (n) { return n.j; }),
|
2253
|
+
ka: () => import('./ka-75d2a2b0.js').then(function (n) { return n.k; }),
|
2254
|
+
kk: () => import('./kk-1a51a974.js').then(function (n) { return n.k; }),
|
2255
|
+
km: () => import('./km-8d0b4152.js').then(function (n) { return n.k; }),
|
2256
|
+
kn: () => import('./kn-00c6b4a1.js').then(function (n) { return n.k; }),
|
2257
|
+
ko: () => import('./ko-448cf08f.js').then(function (n) { return n.k; }),
|
2258
|
+
ku: () => import('./ku-e8f3148d.js').then(function (n) { return n.k; }),
|
2259
|
+
ky: () => import('./ky-4f94fb6d.js').then(function (n) { return n.k; }),
|
2260
|
+
lb: () => import('./lb-445912d6.js').then(function (n) { return n.l; }),
|
2261
|
+
lo: () => import('./lo-e8aa3f1e.js').then(function (n) { return n.l; }),
|
2262
|
+
lt: () => import('./lt-3b6cf273.js').then(function (n) { return n.l; }),
|
2263
|
+
lv: () => import('./lv-b0d8652a.js').then(function (n) { return n.l; }),
|
2264
|
+
me: () => import('./me-8a1db3ae.js').then(function (n) { return n.m; }),
|
2265
|
+
mi: () => import('./mi-4da080b1.js').then(function (n) { return n.m; }),
|
2266
|
+
mk: () => import('./mk-4c62fc73.js').then(function (n) { return n.m; }),
|
2267
|
+
ml: () => import('./ml-d2903289.js').then(function (n) { return n.m; }),
|
2268
|
+
mn: () => import('./mn-8fbea63e.js').then(function (n) { return n.m; }),
|
2269
|
+
mr: () => import('./mr-8d5ec43f.js').then(function (n) { return n.m; }),
|
2270
|
+
'ms-MY': () => import('./ms-my-64085af4.js').then(function (n) { return n.m; }),
|
2271
|
+
ms: () => import('./ms-af7e8df7.js').then(function (n) { return n.m; }),
|
2272
|
+
mt: () => import('./mt-d2f5e061.js').then(function (n) { return n.m; }),
|
2273
|
+
my: () => import('./my-ef5caaba.js').then(function (n) { return n.m; }),
|
2274
|
+
nb: () => import('./nb-a678fab7.js').then(function (n) { return n.n; }),
|
2275
|
+
ne: () => import('./ne-d1d187ce.js').then(function (n) { return n.n; }),
|
2276
|
+
'nl-BE': () => import('./nl-be-4928ae6e.js').then(function (n) { return n.n; }),
|
2277
|
+
nl: () => import('./nl-ad49428a.js').then(function (n) { return n.n; }),
|
2278
|
+
pl: () => import('./pl-132051d9.js').then(function (n) { return n.p; }),
|
2279
|
+
'pt-BR': () => import('./pt-br-f49d9112.js').then(function (n) { return n.p; }),
|
2280
|
+
pt: () => import('./pt-3074e2a4.js').then(function (n) { return n.p; }),
|
2281
|
+
rn: () => import('./rn-e771a818.js').then(function (n) { return n.r; }),
|
2282
|
+
ro: () => import('./ro-3332d691.js').then(function (n) { return n.r; }),
|
2283
|
+
ru: () => import('./ru-255491fa.js').then(function (n) { return n.r; }),
|
2284
|
+
rw: () => import('./rw-72e60f36.js').then(function (n) { return n.r; }),
|
2285
|
+
sd: () => import('./sd-b761056e.js').then(function (n) { return n.s; }),
|
2286
|
+
se: () => import('./se-3273560b.js').then(function (n) { return n.s; }),
|
2287
|
+
si: () => import('./si-53746844.js').then(function (n) { return n.s; }),
|
2288
|
+
sk: () => import('./sk-ef08302c.js').then(function (n) { return n.s; }),
|
2289
|
+
sl: () => import('./sl-dd5e34e6.js').then(function (n) { return n.s; }),
|
2290
|
+
sq: () => import('./sq-6b3a6a22.js').then(function (n) { return n.s; }),
|
2291
|
+
'sr-CYRL': () => import('./sr-cyrl-6db8de73.js').then(function (n) { return n.s; }),
|
2292
|
+
ss: () => import('./ss-db1ce75d.js').then(function (n) { return n.s; }),
|
2293
|
+
'sv-FI': () => import('./sv-fi-25e32c59.js').then(function (n) { return n.s; }),
|
2294
|
+
sr: () => import('./sr-810dc87c.js').then(function (n) { return n.s; }),
|
2295
|
+
sv: () => import('./sv-e70709e9.js').then(function (n) { return n.s; }),
|
2296
|
+
sw: () => import('./sw-964eb461.js').then(function (n) { return n.s; }),
|
2297
|
+
ta: () => import('./ta-5c6c5b31.js').then(function (n) { return n.t; }),
|
2298
|
+
te: () => import('./te-aabe177a.js').then(function (n) { return n.t; }),
|
2299
|
+
tet: () => import('./tet-b6ee9a63.js').then(function (n) { return n.t; }),
|
2300
|
+
tg: () => import('./tg-e80d07ba.js').then(function (n) { return n.t; }),
|
2301
|
+
th: () => import('./th-67e4d461.js').then(function (n) { return n.t; }),
|
2302
|
+
tk: () => import('./tk-7c2e6c39.js').then(function (n) { return n.t; }),
|
2303
|
+
'tl-PH': () => import('./tl-ph-02e6de6a.js').then(function (n) { return n.t; }),
|
2304
|
+
tlh: () => import('./tlh-c12b792d.js').then(function (n) { return n.t; }),
|
2305
|
+
tr: () => import('./tr-d44675c4.js').then(function (n) { return n.t; }),
|
2306
|
+
tzl: () => import('./tzl-daeb1470.js').then(function (n) { return n.t; }),
|
2307
|
+
'tzm-LATN': () => import('./tzm-latn-00c31214.js').then(function (n) { return n.t; }),
|
2308
|
+
tzm: () => import('./tzm-e5f35f92.js').then(function (n) { return n.t; }),
|
2309
|
+
'ug-CN': () => import('./ug-cn-1626e72b.js').then(function (n) { return n.u; }),
|
2310
|
+
uk: () => import('./uk-f519c388.js').then(function (n) { return n.u; }),
|
2311
|
+
ur: () => import('./ur-bc876bdc.js').then(function (n) { return n.u; }),
|
2312
|
+
'uz-LATN': () => import('./uz-latn-3dc9ee1b.js').then(function (n) { return n.u; }),
|
2313
|
+
uz: () => import('./uz-1cde51d4.js').then(function (n) { return n.u; }),
|
2314
|
+
vi: () => import('./vi-3defe54a.js').then(function (n) { return n.v; }),
|
2315
|
+
'x-PSEUDO': () => import('./x-pseudo-f9b053ff.js').then(function (n) { return n.x; }),
|
2316
|
+
yo: () => import('./yo-5985943f.js').then(function (n) { return n.y; }),
|
2317
|
+
'zh-CN': () => import('./zh-cn-24aeb427.js').then(function (n) { return n.z; }),
|
2318
|
+
'zh-HK': () => import('./zh-hk-3c82e78c.js').then(function (n) { return n.z; }),
|
2319
|
+
'zh-TW': () => import('./zh-tw-5bd132cd.js').then(function (n) { return n.z; }),
|
2320
|
+
zh: () => import('./zh-979f158a.js').then(function (n) { return n.z; }),
|
2321
|
+
'oc-LNC': () => import('./oc-lnc-46c2e869.js').then(function (n) { return n.o; }),
|
2322
|
+
nn: () => import('./nn-f793df24.js').then(function (n) { return n.n; }),
|
2323
|
+
'pa-IN': () => import('./pa-in-4738108d.js').then(function (n) { return n.p; }),
|
2324
|
+
};
|
2325
|
+
|
2326
|
+
const warn = (language) => console.warn(`Cannot load dayjs locale file for "${language}"`);
|
2327
|
+
const resolveLanguage = (languageInput) => {
|
2328
|
+
if (locales[languageInput]) {
|
2329
|
+
return languageInput;
|
2330
|
+
}
|
2331
|
+
if (languageInput.includes('-')) {
|
2332
|
+
const regionlessLanguage = languageInput.split('-')[0];
|
2333
|
+
if (locales[regionlessLanguage]) {
|
2334
|
+
return regionlessLanguage;
|
2335
|
+
}
|
2336
|
+
}
|
2337
|
+
return languageInput;
|
2338
|
+
};
|
2339
|
+
function loadDayjsLocale(languageInput) {
|
2340
|
+
const language = resolveLanguage(languageInput);
|
2341
|
+
if (!locales[language]) {
|
2342
|
+
warn(language);
|
2343
|
+
return;
|
2344
|
+
}
|
2345
|
+
try {
|
2346
|
+
locales[language]().then(() => dayjs.locale(language));
|
2347
|
+
}
|
2348
|
+
catch (_) {
|
2349
|
+
warn(language);
|
2350
|
+
}
|
2351
|
+
}
|
2352
|
+
|
2353
|
+
function _typeof$2(o) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$2(o); }
|
2354
|
+
function hasXMLHttpRequest() {
|
2355
|
+
return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof$2(XMLHttpRequest)) === 'object';
|
2356
|
+
}
|
2357
|
+
function isPromise(maybePromise) {
|
2358
|
+
return !!maybePromise && typeof maybePromise.then === 'function';
|
2359
|
+
}
|
2360
|
+
function makePromise(maybePromise) {
|
2361
|
+
if (isPromise(maybePromise)) {
|
2362
|
+
return maybePromise;
|
2363
|
+
}
|
2364
|
+
return Promise.resolve(maybePromise);
|
2365
|
+
}
|
2366
|
+
|
2367
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
2368
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
2369
|
+
function _defineProperty$1(e, r, t) { return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
2370
|
+
function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
|
2371
|
+
function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
2372
|
+
function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); }
|
2373
|
+
var fetchApi = typeof fetch === 'function' ? fetch : undefined;
|
2374
|
+
if (typeof global !== 'undefined' && global.fetch) {
|
2375
|
+
fetchApi = global.fetch;
|
2376
|
+
} else if (typeof window !== 'undefined' && window.fetch) {
|
2377
|
+
fetchApi = window.fetch;
|
2378
|
+
}
|
2379
|
+
var XmlHttpRequestApi;
|
2380
|
+
if (hasXMLHttpRequest()) {
|
2381
|
+
if (typeof global !== 'undefined' && global.XMLHttpRequest) {
|
2382
|
+
XmlHttpRequestApi = global.XMLHttpRequest;
|
2383
|
+
} else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
|
2384
|
+
XmlHttpRequestApi = window.XMLHttpRequest;
|
2385
|
+
}
|
2386
|
+
}
|
2387
|
+
var ActiveXObjectApi;
|
2388
|
+
if (typeof ActiveXObject === 'function') {
|
2389
|
+
if (typeof global !== 'undefined' && global.ActiveXObject) {
|
2390
|
+
ActiveXObjectApi = global.ActiveXObject;
|
2391
|
+
} else if (typeof window !== 'undefined' && window.ActiveXObject) {
|
2392
|
+
ActiveXObjectApi = window.ActiveXObject;
|
2393
|
+
}
|
2394
|
+
}
|
2395
|
+
if (typeof fetchApi !== 'function') fetchApi = undefined;
|
2396
|
+
if (!fetchApi && !XmlHttpRequestApi && !ActiveXObjectApi) {
|
2397
|
+
try {
|
2398
|
+
import('./browser-ponyfill-3a04ef55.js').then(function (n) { return n.b; }).then(function (mod) {
|
2399
|
+
fetchApi = mod.default;
|
2400
|
+
}).catch(function () {});
|
2401
|
+
} catch (e) {}
|
2402
|
+
}
|
2403
|
+
var addQueryString = function addQueryString(url, params) {
|
2404
|
+
if (params && _typeof$1(params) === 'object') {
|
2405
|
+
var queryString = '';
|
2406
|
+
for (var paramName in params) {
|
2407
|
+
queryString += '&' + encodeURIComponent(paramName) + '=' + encodeURIComponent(params[paramName]);
|
2408
|
+
}
|
2409
|
+
if (!queryString) return url;
|
2410
|
+
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
|
2411
|
+
}
|
2412
|
+
return url;
|
2413
|
+
};
|
2414
|
+
var fetchIt = function fetchIt(url, fetchOptions, callback, altFetch) {
|
2415
|
+
var resolver = function resolver(response) {
|
2416
|
+
if (!response.ok) return callback(response.statusText || 'Error', {
|
2417
|
+
status: response.status
|
2418
|
+
});
|
2419
|
+
response.text().then(function (data) {
|
2420
|
+
callback(null, {
|
2421
|
+
status: response.status,
|
2422
|
+
data: data
|
2423
|
+
});
|
2424
|
+
}).catch(callback);
|
2425
|
+
};
|
2426
|
+
if (altFetch) {
|
2427
|
+
var altResponse = altFetch(url, fetchOptions);
|
2428
|
+
if (altResponse instanceof Promise) {
|
2429
|
+
altResponse.then(resolver).catch(callback);
|
2430
|
+
return;
|
2431
|
+
}
|
2432
|
+
}
|
2433
|
+
if (typeof fetch === 'function') {
|
2434
|
+
fetch(url, fetchOptions).then(resolver).catch(callback);
|
2435
|
+
} else {
|
2436
|
+
fetchApi(url, fetchOptions).then(resolver).catch(callback);
|
2437
|
+
}
|
2438
|
+
};
|
2439
|
+
var omitFetchOptions = false;
|
2440
|
+
var requestWithFetch = function requestWithFetch(options, url, payload, callback) {
|
2441
|
+
if (options.queryStringParams) {
|
2442
|
+
url = addQueryString(url, options.queryStringParams);
|
2443
|
+
}
|
2444
|
+
var headers = _objectSpread$1({}, typeof options.customHeaders === 'function' ? options.customHeaders() : options.customHeaders);
|
2445
|
+
if (typeof window === 'undefined' && typeof global !== 'undefined' && typeof global.process !== 'undefined' && global.process.versions && global.process.versions.node) {
|
2446
|
+
headers['User-Agent'] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")");
|
2447
|
+
}
|
2448
|
+
if (payload) headers['Content-Type'] = 'application/json';
|
2449
|
+
var reqOptions = typeof options.requestOptions === 'function' ? options.requestOptions(payload) : options.requestOptions;
|
2450
|
+
var fetchOptions = _objectSpread$1({
|
2451
|
+
method: payload ? 'POST' : 'GET',
|
2452
|
+
body: payload ? options.stringify(payload) : undefined,
|
2453
|
+
headers: headers
|
2454
|
+
}, omitFetchOptions ? {} : reqOptions);
|
2455
|
+
var altFetch = typeof options.alternateFetch === 'function' && options.alternateFetch.length >= 1 ? options.alternateFetch : undefined;
|
2456
|
+
try {
|
2457
|
+
fetchIt(url, fetchOptions, callback, altFetch);
|
2458
|
+
} catch (e) {
|
2459
|
+
if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf('not implemented') < 0) {
|
2460
|
+
return callback(e);
|
2461
|
+
}
|
2462
|
+
try {
|
2463
|
+
Object.keys(reqOptions).forEach(function (opt) {
|
2464
|
+
delete fetchOptions[opt];
|
2465
|
+
});
|
2466
|
+
fetchIt(url, fetchOptions, callback, altFetch);
|
2467
|
+
omitFetchOptions = true;
|
2468
|
+
} catch (err) {
|
2469
|
+
callback(err);
|
2470
|
+
}
|
2471
|
+
}
|
2472
|
+
};
|
2473
|
+
var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) {
|
2474
|
+
if (payload && _typeof$1(payload) === 'object') {
|
2475
|
+
payload = addQueryString('', payload).slice(1);
|
2476
|
+
}
|
2477
|
+
if (options.queryStringParams) {
|
2478
|
+
url = addQueryString(url, options.queryStringParams);
|
2479
|
+
}
|
2480
|
+
try {
|
2481
|
+
var x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi('MSXML2.XMLHTTP.3.0');
|
2482
|
+
x.open(payload ? 'POST' : 'GET', url, 1);
|
2483
|
+
if (!options.crossDomain) {
|
2484
|
+
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
2485
|
+
}
|
2486
|
+
x.withCredentials = !!options.withCredentials;
|
2487
|
+
if (payload) {
|
2488
|
+
x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
2489
|
+
}
|
2490
|
+
if (x.overrideMimeType) {
|
2491
|
+
x.overrideMimeType('application/json');
|
2492
|
+
}
|
2493
|
+
var h = options.customHeaders;
|
2494
|
+
h = typeof h === 'function' ? h() : h;
|
2495
|
+
if (h) {
|
2496
|
+
for (var i in h) {
|
2497
|
+
x.setRequestHeader(i, h[i]);
|
2498
|
+
}
|
2499
|
+
}
|
2500
|
+
x.onreadystatechange = function () {
|
2501
|
+
x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
|
2502
|
+
status: x.status,
|
2503
|
+
data: x.responseText
|
2504
|
+
});
|
2505
|
+
};
|
2506
|
+
x.send(payload);
|
2507
|
+
} catch (e) {
|
2508
|
+
console && console.log(e);
|
2509
|
+
}
|
2510
|
+
};
|
2511
|
+
var request = function request(options, url, payload, callback) {
|
2512
|
+
if (typeof payload === 'function') {
|
2513
|
+
callback = payload;
|
2514
|
+
payload = undefined;
|
2515
|
+
}
|
2516
|
+
callback = callback || function () {};
|
2517
|
+
if (fetchApi && url.indexOf('file:') !== 0) {
|
2518
|
+
return requestWithFetch(options, url, payload, callback);
|
2519
|
+
}
|
2520
|
+
if (hasXMLHttpRequest() || typeof ActiveXObject === 'function') {
|
2521
|
+
return requestWithXmlHttpRequest(options, url, payload, callback);
|
2522
|
+
}
|
2523
|
+
callback(new Error('No fetch and no xhr implementation found!'));
|
2524
|
+
};
|
2525
|
+
|
2526
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2527
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
2528
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
2529
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
2530
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
2531
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
2532
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
2533
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
2534
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
2535
|
+
var getDefaults = function getDefaults() {
|
2536
|
+
return {
|
2537
|
+
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
2538
|
+
addPath: '/locales/add/{{lng}}/{{ns}}',
|
2539
|
+
parse: function parse(data) {
|
2540
|
+
return JSON.parse(data);
|
2541
|
+
},
|
2542
|
+
stringify: JSON.stringify,
|
2543
|
+
parsePayload: function parsePayload(namespace, key, fallbackValue) {
|
2544
|
+
return _defineProperty({}, key, fallbackValue || '');
|
2545
|
+
},
|
2546
|
+
parseLoadPayload: function parseLoadPayload(languages, namespaces) {
|
2547
|
+
return undefined;
|
2548
|
+
},
|
2549
|
+
request: request,
|
2550
|
+
reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000,
|
2551
|
+
customHeaders: {},
|
2552
|
+
queryStringParams: {},
|
2553
|
+
crossDomain: false,
|
2554
|
+
withCredentials: false,
|
2555
|
+
overrideMimeType: false,
|
2556
|
+
requestOptions: {
|
2557
|
+
mode: 'cors',
|
2558
|
+
credentials: 'same-origin',
|
2559
|
+
cache: 'default'
|
2560
|
+
}
|
2561
|
+
};
|
2562
|
+
};
|
2563
|
+
var Backend = function () {
|
2564
|
+
function Backend(services) {
|
2565
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2566
|
+
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2567
|
+
_classCallCheck(this, Backend);
|
2568
|
+
this.services = services;
|
2569
|
+
this.options = options;
|
2570
|
+
this.allOptions = allOptions;
|
2571
|
+
this.type = 'backend';
|
2572
|
+
this.init(services, options, allOptions);
|
2573
|
+
}
|
2574
|
+
return _createClass(Backend, [{
|
2575
|
+
key: "init",
|
2576
|
+
value: function init(services) {
|
2577
|
+
var _this = this;
|
2578
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2579
|
+
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2580
|
+
this.services = services;
|
2581
|
+
this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options || {}), options);
|
2582
|
+
this.allOptions = allOptions;
|
2583
|
+
if (this.services && this.options.reloadInterval) {
|
2584
|
+
var timer = setInterval(function () {
|
2585
|
+
return _this.reload();
|
2586
|
+
}, this.options.reloadInterval);
|
2587
|
+
if (_typeof(timer) === 'object' && typeof timer.unref === 'function') timer.unref();
|
2588
|
+
}
|
2589
|
+
}
|
2590
|
+
}, {
|
2591
|
+
key: "readMulti",
|
2592
|
+
value: function readMulti(languages, namespaces, callback) {
|
2593
|
+
this._readAny(languages, languages, namespaces, namespaces, callback);
|
2594
|
+
}
|
2595
|
+
}, {
|
2596
|
+
key: "read",
|
2597
|
+
value: function read(language, namespace, callback) {
|
2598
|
+
this._readAny([language], language, [namespace], namespace, callback);
|
2599
|
+
}
|
2600
|
+
}, {
|
2601
|
+
key: "_readAny",
|
2602
|
+
value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
|
2603
|
+
var _this2 = this;
|
2604
|
+
var loadPath = this.options.loadPath;
|
2605
|
+
if (typeof this.options.loadPath === 'function') {
|
2606
|
+
loadPath = this.options.loadPath(languages, namespaces);
|
2607
|
+
}
|
2608
|
+
loadPath = makePromise(loadPath);
|
2609
|
+
loadPath.then(function (resolvedLoadPath) {
|
2610
|
+
if (!resolvedLoadPath) return callback(null, {});
|
2611
|
+
var url = _this2.services.interpolator.interpolate(resolvedLoadPath, {
|
2612
|
+
lng: languages.join('+'),
|
2613
|
+
ns: namespaces.join('+')
|
2614
|
+
});
|
2615
|
+
_this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
|
2616
|
+
});
|
2617
|
+
}
|
2618
|
+
}, {
|
2619
|
+
key: "loadUrl",
|
2620
|
+
value: function loadUrl(url, callback, languages, namespaces) {
|
2621
|
+
var _this3 = this;
|
2622
|
+
var lng = typeof languages === 'string' ? [languages] : languages;
|
2623
|
+
var ns = typeof namespaces === 'string' ? [namespaces] : namespaces;
|
2624
|
+
var payload = this.options.parseLoadPayload(lng, ns);
|
2625
|
+
this.options.request(this.options, url, payload, function (err, res) {
|
2626
|
+
if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + url + '; status code: ' + res.status, true);
|
2627
|
+
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url + '; status code: ' + res.status, false);
|
2628
|
+
if (!res && err && err.message) {
|
2629
|
+
var errorMessage = err.message.toLowerCase();
|
2630
|
+
var isNetworkError = ['failed', 'fetch', 'network', 'load'].find(function (term) {
|
2631
|
+
return errorMessage.indexOf(term) > -1;
|
2632
|
+
});
|
2633
|
+
if (isNetworkError) {
|
2634
|
+
return callback('failed loading ' + url + ': ' + err.message, true);
|
2635
|
+
}
|
2636
|
+
}
|
2637
|
+
if (err) return callback(err, false);
|
2638
|
+
var ret, parseErr;
|
2639
|
+
try {
|
2640
|
+
if (typeof res.data === 'string') {
|
2641
|
+
ret = _this3.options.parse(res.data, languages, namespaces);
|
2642
|
+
} else {
|
2643
|
+
ret = res.data;
|
2644
|
+
}
|
2645
|
+
} catch (e) {
|
2646
|
+
parseErr = 'failed parsing ' + url + ' to json';
|
2647
|
+
}
|
2648
|
+
if (parseErr) return callback(parseErr, false);
|
2649
|
+
callback(null, ret);
|
2650
|
+
});
|
2651
|
+
}
|
2652
|
+
}, {
|
2653
|
+
key: "create",
|
2654
|
+
value: function create(languages, namespace, key, fallbackValue, callback) {
|
2655
|
+
var _this4 = this;
|
2656
|
+
if (!this.options.addPath) return;
|
2657
|
+
if (typeof languages === 'string') languages = [languages];
|
2658
|
+
var payload = this.options.parsePayload(namespace, key, fallbackValue);
|
2659
|
+
var finished = 0;
|
2660
|
+
var dataArray = [];
|
2661
|
+
var resArray = [];
|
2662
|
+
languages.forEach(function (lng) {
|
2663
|
+
var addPath = _this4.options.addPath;
|
2664
|
+
if (typeof _this4.options.addPath === 'function') {
|
2665
|
+
addPath = _this4.options.addPath(lng, namespace);
|
2666
|
+
}
|
2667
|
+
var url = _this4.services.interpolator.interpolate(addPath, {
|
2668
|
+
lng: lng,
|
2669
|
+
ns: namespace
|
2670
|
+
});
|
2671
|
+
_this4.options.request(_this4.options, url, payload, function (data, res) {
|
2672
|
+
finished += 1;
|
2673
|
+
dataArray.push(data);
|
2674
|
+
resArray.push(res);
|
2675
|
+
if (finished === languages.length) {
|
2676
|
+
if (typeof callback === 'function') callback(dataArray, resArray);
|
2677
|
+
}
|
2678
|
+
});
|
2679
|
+
});
|
2680
|
+
}
|
2681
|
+
}, {
|
2682
|
+
key: "reload",
|
2683
|
+
value: function reload() {
|
2684
|
+
var _this5 = this;
|
2685
|
+
var _this$services = this.services,
|
2686
|
+
backendConnector = _this$services.backendConnector,
|
2687
|
+
languageUtils = _this$services.languageUtils,
|
2688
|
+
logger = _this$services.logger;
|
2689
|
+
var currentLanguage = backendConnector.language;
|
2690
|
+
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return;
|
2691
|
+
var toLoad = [];
|
2692
|
+
var append = function append(lng) {
|
2693
|
+
var lngs = languageUtils.toResolveHierarchy(lng);
|
2694
|
+
lngs.forEach(function (l) {
|
2695
|
+
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
2696
|
+
});
|
2697
|
+
};
|
2698
|
+
append(currentLanguage);
|
2699
|
+
if (this.allOptions.preload) this.allOptions.preload.forEach(function (l) {
|
2700
|
+
return append(l);
|
2701
|
+
});
|
2702
|
+
toLoad.forEach(function (lng) {
|
2703
|
+
_this5.allOptions.ns.forEach(function (ns) {
|
2704
|
+
backendConnector.read(lng, ns, 'read', null, null, function (err, data) {
|
2705
|
+
if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
|
2706
|
+
if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
|
2707
|
+
backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
|
2708
|
+
});
|
2709
|
+
});
|
2710
|
+
});
|
2711
|
+
}
|
2712
|
+
}]);
|
2713
|
+
}();
|
2714
|
+
Backend.type = 'backend';
|
2715
|
+
|
2716
|
+
function getAssetPath(path) {
|
2717
|
+
const baseUrl = new URL('./', window.document.baseURI).href;
|
2718
|
+
const assetUrl = new URL(path, baseUrl);
|
2719
|
+
return assetUrl.origin !== window.location.origin
|
2720
|
+
? assetUrl.href
|
2721
|
+
: assetUrl.pathname;
|
2722
|
+
}
|
2723
|
+
|
2724
|
+
const availableLocales = [
|
2725
|
+
"dev",
|
2726
|
+
"en",
|
2727
|
+
"fr",
|
2728
|
+
"cs",
|
2729
|
+
"da",
|
2730
|
+
"de",
|
2731
|
+
"el",
|
2732
|
+
"es",
|
2733
|
+
"fi",
|
2734
|
+
"hu",
|
2735
|
+
"id",
|
2736
|
+
"it",
|
2737
|
+
"ja",
|
2738
|
+
"ko",
|
2739
|
+
"nl",
|
2740
|
+
"no",
|
2741
|
+
"pl",
|
2742
|
+
"pt",
|
2743
|
+
"pt-br",
|
2744
|
+
"ru",
|
2745
|
+
"sv",
|
2746
|
+
"th",
|
2747
|
+
"tr",
|
2748
|
+
"zh",
|
2749
|
+
"zh-cn",
|
2750
|
+
"zh-tw",
|
2751
|
+
"zn",
|
2752
|
+
"es-es"
|
2753
|
+
];
|
2754
|
+
|
2755
|
+
const i18nTranslationNamespace = 'translation';
|
2756
|
+
function isI18nLocaleAvailable(locale) {
|
2757
|
+
return availableLocales.includes(locale.toLowerCase());
|
2758
|
+
}
|
2759
|
+
function i18nBackendOptions(atomicInterface) {
|
2760
|
+
return {
|
2761
|
+
loadPath: `${getAssetPath(atomicInterface.languageAssetsPath)}/{{lng}}.json?lng={{lng}}&ns={{ns}}`,
|
2762
|
+
request: async (_options, url, _payload, callback) => {
|
2763
|
+
try {
|
2764
|
+
const [fetchUrl, searchParams] = url.split('?');
|
2765
|
+
const urlParams = new URLSearchParams(searchParams);
|
2766
|
+
const lng = urlParams.get('lng');
|
2767
|
+
const ns = urlParams.get('ns');
|
2768
|
+
if (!isI18nLocaleAvailable(lng)) {
|
2769
|
+
throw new Error(`Unsupported locale "${lng}"`);
|
2770
|
+
}
|
2771
|
+
if (ns !== i18nTranslationNamespace) {
|
2772
|
+
throw new Error(`Unsupported namespace "${ns}"`);
|
2773
|
+
}
|
2774
|
+
const response = await fetch(fetchUrl);
|
2775
|
+
if (response.status !== 200 && response.status !== 304) {
|
2776
|
+
throw new Error(`Unsuccessful request returned status "${response.status}"`);
|
2777
|
+
}
|
2778
|
+
callback(null, {
|
2779
|
+
status: response.status,
|
2780
|
+
data: await response.json(),
|
2781
|
+
});
|
2782
|
+
}
|
2783
|
+
catch (error) {
|
2784
|
+
callback(error, { status: 404, data: '' });
|
2785
|
+
}
|
2786
|
+
},
|
2787
|
+
};
|
2788
|
+
}
|
2789
|
+
function init18n(atomicInterface) {
|
2790
|
+
return atomicInterface.i18n.use(Backend).init({
|
2791
|
+
debug: atomicInterface.logLevel === 'debug',
|
2792
|
+
lng: atomicInterface.language,
|
2793
|
+
nsSeparator: '___',
|
2794
|
+
fallbackLng: 'en',
|
2795
|
+
backend: i18nBackendOptions(atomicInterface),
|
2796
|
+
interpolation: {
|
2797
|
+
escape: (str) => DOMPurify.sanitize(str),
|
2798
|
+
},
|
2799
|
+
compatibilityJSON: 'v4',
|
2800
|
+
});
|
2801
|
+
}
|
2802
|
+
|
2803
|
+
const mismatchedInterfaceAndEnginePropError = (interfaceKind, configurationName) => `A ${configurationName} is configured on the ${interfaceKind} interface element, but the ${interfaceKind} interface was initialized with an engine. You should only configure the ${configurationName} in the target engine.`;
|
2804
|
+
class CommonAtomicInterfaceHelper {
|
2805
|
+
constructor(atomicInterface, globalVariableName) {
|
2806
|
+
this.atomicInterface = atomicInterface;
|
2807
|
+
this.hangingComponentsInitialization = [];
|
2808
|
+
setCoveoGlobal(VERSION, globalVariableName);
|
2809
|
+
const { connectedCallback: originalConnectedCallback, render: originalRender, } = atomicInterface;
|
2810
|
+
atomicInterface.connectedCallback = () => {
|
2811
|
+
this.i18nPromise = init18n(atomicInterface);
|
2812
|
+
return (originalConnectedCallback &&
|
2813
|
+
originalConnectedCallback.call(atomicInterface));
|
2814
|
+
};
|
2815
|
+
atomicInterface.render = () => {
|
2816
|
+
if (atomicInterface.error) {
|
2817
|
+
return (h("atomic-component-error", { element: atomicInterface.host, error: atomicInterface.error }));
|
2818
|
+
}
|
2819
|
+
return originalRender && originalRender.call(atomicInterface);
|
2820
|
+
};
|
2821
|
+
}
|
2822
|
+
onComponentInitializing(event) {
|
2823
|
+
event.preventDefault();
|
2824
|
+
event.stopPropagation();
|
2825
|
+
if (this.atomicInterface.engine) {
|
2826
|
+
event.detail(this.atomicInterface.bindings);
|
2827
|
+
return;
|
2828
|
+
}
|
2829
|
+
this.hangingComponentsInitialization.push(event);
|
2830
|
+
}
|
2831
|
+
async onInitialization(initEngine) {
|
2832
|
+
if (this.atomicInterface.engine) {
|
2833
|
+
this.atomicInterface.engine.logger.warn(`The ${this.interfaceTagname} component "initialize" has already been called.`, this.atomicInterface.host);
|
2834
|
+
return;
|
2835
|
+
}
|
2836
|
+
this.atomicInterface.updateIconAssetsPath();
|
2837
|
+
initEngine();
|
2838
|
+
if (this.atomicInterface.registerFieldsToInclude) {
|
2839
|
+
this.atomicInterface.registerFieldsToInclude();
|
2840
|
+
}
|
2841
|
+
loadDayjsLocale(this.language);
|
2842
|
+
await this.i18nPromise;
|
2843
|
+
this.initComponents();
|
2844
|
+
}
|
2845
|
+
onAnalyticsChange() {
|
2846
|
+
const { engine, analytics } = this.atomicInterface;
|
2847
|
+
if (!this.engineIsCreated(engine)) {
|
2848
|
+
return;
|
2849
|
+
}
|
2850
|
+
if (!analytics) {
|
2851
|
+
engine.disableAnalytics();
|
2852
|
+
return;
|
2853
|
+
}
|
2854
|
+
engine.enableAnalytics();
|
2855
|
+
}
|
2856
|
+
onLanguageChange() {
|
2857
|
+
const { i18n, language } = this.atomicInterface;
|
2858
|
+
loadDayjsLocale(this.language);
|
2859
|
+
const { resolve, promise } = Promise.withResolvers();
|
2860
|
+
new Backend(i18n.services, i18nBackendOptions(this.atomicInterface)).read(this.language, i18nTranslationNamespace, async (_, data) => {
|
2861
|
+
i18n.addResourceBundle(this.language, i18nTranslationNamespace, data, true, false);
|
2862
|
+
await i18n.changeLanguage(language);
|
2863
|
+
resolve();
|
2864
|
+
});
|
2865
|
+
return promise;
|
2866
|
+
}
|
2867
|
+
engineIsCreated(engine) {
|
2868
|
+
if (!engine) {
|
2869
|
+
console.error(`You have to call "initialize" on the ${this.interfaceTagname} component before modifying the props or calling other public methods.`, this.atomicInterface.host);
|
2870
|
+
return false;
|
2871
|
+
}
|
2872
|
+
return true;
|
2873
|
+
}
|
2874
|
+
get interfaceTagname() {
|
2875
|
+
return this.atomicInterface.host.tagName.toLowerCase();
|
2876
|
+
}
|
2877
|
+
initComponents() {
|
2878
|
+
this.hangingComponentsInitialization.forEach((event) => event.detail(this.atomicInterface.bindings));
|
2879
|
+
}
|
2880
|
+
get language() {
|
2881
|
+
return this.atomicInterface.language || 'en';
|
2882
|
+
}
|
2883
|
+
}
|
2884
|
+
|
2885
|
+
function augmentWithExternalMiddleware(event, payload, config) {
|
2886
|
+
if (config.analytics?.analyticsClientMiddleware) {
|
2887
|
+
return config.analytics.analyticsClientMiddleware(event, payload);
|
2888
|
+
}
|
2889
|
+
return payload;
|
2890
|
+
}
|
2891
|
+
function augmentAnalyticsWithAtomicVersion(payload) {
|
2892
|
+
if (payload.customData) {
|
2893
|
+
payload.customData.coveoAtomicVersion = getAtomicVersion();
|
2894
|
+
}
|
2895
|
+
return payload;
|
2896
|
+
}
|
2897
|
+
function augmentAnalyticsConfigWithDocument() {
|
2898
|
+
return {
|
2899
|
+
documentLocation: document.location.href,
|
2900
|
+
...(document.referrer && { originLevel3: document.referrer }),
|
2901
|
+
};
|
2902
|
+
}
|
2903
|
+
const versionMatcher = /^(\d+\.\d+\.\d+)/;
|
2904
|
+
function augmentAnalyticsConfigWithAtomicVersion() {
|
2905
|
+
return {
|
2906
|
+
source: {
|
2907
|
+
'@coveo/atomic': versionMatcher.exec(getAtomicVersion())?.[0] || '0.0.0',
|
2908
|
+
},
|
2909
|
+
};
|
2910
|
+
}
|
2911
|
+
function getNextAnalyticsConfig(searchEngineConfig, enabled) {
|
2912
|
+
const configuration = {
|
2913
|
+
enabled,
|
2914
|
+
documentLocation: document.location.href,
|
2915
|
+
...(document.referrer && { originLevel3: document.referrer }),
|
2916
|
+
};
|
2917
|
+
const analyticsConfiguration = searchEngineConfig.analytics ?? {};
|
2918
|
+
Object.assign(analyticsConfiguration, augmentAnalyticsConfigWithAtomicVersion());
|
2919
|
+
Object.assign(configuration, analyticsConfiguration);
|
2920
|
+
return configuration;
|
2921
|
+
}
|
13
2922
|
|
14
2923
|
function getAnalyticsConfig(recsConfig, enabled) {
|
15
2924
|
switch (recsConfig.analytics?.analyticsMode) {
|
@@ -246,7 +3155,7 @@ const AtomicRecsInterface = class {
|
|
246
3155
|
}
|
247
3156
|
}
|
248
3157
|
render() {
|
249
|
-
return this.engine && h("slot", { key: '
|
3158
|
+
return this.engine && h("slot", { key: 'be34a0736aec2334bc13b2d75623adc7c9bc6604' });
|
250
3159
|
}
|
251
3160
|
get host() { return getElement(this); }
|
252
3161
|
static get watchers() { return {
|