PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.2.5
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.2.5
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
sellkit / assets / dist / js / elementor-init.js

elementor-init.js in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.2.5, at assets/dist/js/elementor-init.js

2,889 lines 86.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2 "use strict";
3
4 Object.defineProperty(exports, "__esModule", {
5 value: true
6 });
7 exports["default"] = _default;
8
9 var _i18n = require("@wordpress/i18n");
10
11 /* eslint no-undef: 0 */
12 // Temporary turned off no undefined variable for localStorage
13 var $ = jQuery;
14 var wcCountries = JSON.parse(wc_country_select_params.countries);
15
16 function _default() {
17 var parent = $('#sellkit-checkout-multistep-inner-wrap');
18 var sidebar = $('.sellkit-checkout-right-column');
19 var first = $('.sellkit-multistep-checkout-first');
20 var second = $('.sellkit-multistep-checkout-second');
21 var third = $('.sellkit-multistep-checkout-third');
22 var breadcrumb = $('.sellkit-checkout-widget-breadcrumb-desktop, .sellkit-checkout-widget-breadcrumb-mobile');
23 $('.go-to-shipping').on('click', function () {
24 // Checks if required fields are filled.
25 var requiredFieldsError = checkRequiredFields();
26
27 if (true === requiredFieldsError) {
28 return;
29 }
30
31 secondStepHeader();
32 var secondTrigger = true;
33 first.hide();
34
35 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
36 second.show();
37 } else {
38 third.show();
39 secondTrigger = false;
40 }
41
42 if ($(window).width() > 600 && secondTrigger) {
43 sidebar.css('background-color', '#effdf5');
44 } //Fix Header & wrapper height.
45
46
47 parent.css('height', 'auto');
48 second.css('height', 'auto');
49 second.css('min-height', $('.sellkit-checkout-left-column').height());
50 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
51
52 breadcrumb.find('.information').removeClass('current').addClass('blue-line');
53 breadcrumb.find('.shipping').addClass('current').removeClass('inactive');
54 });
55 $('.go-to-first').on('click', function () {
56 first.show();
57 third.hide();
58 second.hide();
59 parent.css('height', 'auto');
60 first.css('height', 'auto');
61 sidebar.css('background-color', '#ffffff'); // Manage Breadcrumb.
62
63 breadcrumb.find('.information').removeClass('blue-line').addClass('current');
64 breadcrumb.find('.shipping, .payment').removeClass('current').removeClass('blue-line').addClass('inactive');
65 });
66 $('.go-to-payment').on('click', function () {
67 // Checks if required fields are filled.
68 var requiredFieldsError = checkRequiredFields();
69
70 if (true === requiredFieldsError) {
71 return;
72 }
73
74 secondStepHeader();
75 second.hide();
76 first.hide();
77 third.show();
78 $('.sellkit-one-page-checkout-payment-heading').css('margin-top', '0px');
79 sidebar.css('background-color', '#ffffff'); //Fix Header & wrapper height.
80
81 parent.css('height', 'auto');
82 third.css('height', 'auto');
83 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
84
85 breadcrumb.find('.shipping').addClass('blue-line').removeClass('current');
86 breadcrumb.find('.payment').addClass('current').removeClass('inactive');
87 });
88 $('.go-to-second , .go-to-second-header').on('click', function () {
89 // Checks if required fields are filled.
90 var requiredFieldsError = checkRequiredFields();
91
92 if (true === requiredFieldsError) {
93 return;
94 }
95
96 var secondTrigger = true;
97
98 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
99 second.show();
100 first.hide();
101 } else {
102 second.hide();
103 first.show();
104 secondTrigger = false;
105 }
106
107 third.hide();
108 parent.css('height', 'auto');
109 second.css('height', 'auto');
110 second.css('height', $('.sellkit-checkout-left-column').height());
111 $('.multistep-headers').css('height', 'auto');
112
113 if ($(window).width() > 600 && secondTrigger) {
114 sidebar.css('background-color', '#effdf5');
115 } // Manage Breadcrumb.
116
117
118 breadcrumb.find('.shipping').addClass('current').removeClass('blue-line');
119 breadcrumb.find('.payment').removeClass('current').addClass('inactive');
120 }); //Inject login wrapper & functionality.
121
122 emailProcess();
123 LoginProcess(); // Billing method toggle.
124
125 manageBillingMethod(); // Mobile summary.
126
127 mobileSummary(); // Breadcrumb click management.
128
129 breadcrumbLinks(); // Fix shipping & billing fields space issue.
130
131 fixFieldSpaceIssue(); // Fields focus.
132
133 organizeFieldsonLoad();
134 fieldFocus();
135 jQuery(document).ajaxComplete(function () {
136 // Run after ajax
137 sellkitCheckoutUpdateCartItem();
138 applyCoupon();
139 couponToggle();
140 }); //Run when page loads.
141
142 sellkitCheckoutUpdateCartItem(); // Apply coupon.
143
144 applyCoupon(); // Coupon toggle.
145
146 couponToggle(); // Postal code autocomplete.
147
148 sellkitPostalCodeAutocomplete(); // Klarma checkout integration.
149
150 sellkitKlarmaIntegration(); // Fix state change issue on load.
151
152 fixStateIssueOnLoad(); // Shipping & billing country & state update on change
153
154 fixClientCountryOnReload(); // Configure bundled products.
155
156 sellkitCheckoutConfigureBundleProducts(); // Order bump.
157
158 sellkitCheckoutOrderBump();
159 }
160
161 var emailProcess = function emailProcess() {
162 var emailField = $('#billing_email');
163 var searchIcon = $('.jupiter-checkout-widget-email-search');
164 var errorText = $('.sellkit-checkout-widget-email-error');
165 var emptyError = $('.sellkit-checkout-widget-email-empty');
166 var passwordWrap = $('.sellkit-checkout-widget-password-field');
167 var passwordField = passwordWrap.find('#register_pass');
168 var usernameWrap = $('.sellkit-checkout-widget-username-field');
169 var usernameField = usernameWrap.find('input');
170 var loginBtn = $('.login-wrapper');
171 var createBox = $('.create-desc');
172 var createCheck = $('#createaccount');
173 emailField.on('keyup', function () {
174 var _this = this;
175
176 setTimeout(function () {
177 var emailAddress = $(_this).val();
178
179 if (_.isEmpty(emailAddress)) {
180 emptyError.show().css('display', 'inline-block');
181 errorText.hide();
182 createBox.css('display', 'none');
183 passwordWrap.addClass('login_hidden_section');
184 usernameWrap.addClass('login_hidden_section');
185 loginBtn.addClass('login_hidden_section');
186 searchIcon.hide();
187 return;
188 }
189
190 var check = validateEmailAddress(emailAddress);
191 $('#createaccount').prop('checked', false);
192
193 if (false === check) {
194 errorText.show().css('display', 'inline-block');
195 emptyError.hide();
196 createBox.css('display', 'none');
197 passwordWrap.addClass('login_hidden_section');
198 usernameWrap.addClass('login_hidden_section');
199 loginBtn.addClass('login_hidden_section');
200 searchIcon.hide();
201 return;
202 }
203
204 emptyError.hide();
205 errorText.hide();
206 searchIcon.show().css('display', 'inline-block');
207 wp.ajax.post({
208 action: 'sellkit_checkout_ajax_handler',
209 sub_action: 'search_for_email',
210 email: emailAddress,
211 dataType: 'json',
212 nonce: sellkit_elementor.nonce
213 }).done(function () {
214 successResultEmailCheck();
215 }).fail(function () {
216 errorResultEmailCheck();
217 });
218 }, 500);
219 });
220 usernameField.on('keyup', function () {
221 var _this2 = this;
222
223 setTimeout(function () {
224 var userValue = $(_this2).val();
225 wp.ajax.post({
226 action: 'sellkit_checkout_ajax_handler',
227 sub_action: 'search_for_username',
228 user: userValue,
229 dataType: 'json',
230 nonce: sellkit_elementor.nonce
231 }).done(function () {
232 $('.sellkit-checkout-widget-username-error').hide();
233 }).fail(function () {
234 $('.sellkit-checkout-widget-username-error').show();
235 });
236 }, 500);
237 }); // If user is going to create account show password and username fields if exists.
238
239 createCheck.on('click', function () {
240 if ($(this).is(':checked')) {
241 if (passwordField.length > 0) {
242 passwordWrap.removeClass('login_hidden_section');
243 }
244
245 if (usernameField.length > 0) {
246 usernameWrap.removeClass('login_hidden_section');
247 }
248 } else {
249 usernameWrap.addClass('login_hidden_section');
250 passwordWrap.addClass('login_hidden_section');
251 }
252 });
253
254 var successResultEmailCheck = function successResultEmailCheck() {
255 createBox.css('display', 'none');
256 passwordWrap.removeClass('login_hidden_section');
257 usernameWrap.addClass('login_hidden_section');
258 loginBtn.removeClass('login_hidden_section');
259 searchIcon.hide();
260 };
261
262 var errorResultEmailCheck = function errorResultEmailCheck() {
263 createBox.css('display', 'flex');
264 passwordWrap.addClass('login_hidden_section');
265 usernameWrap.addClass('login_hidden_section');
266 loginBtn.addClass('login_hidden_section');
267 searchIcon.hide();
268 };
269 };
270
271 var validateEmailAddress = function validateEmailAddress(emailAddress) {
272 var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
273 return pattern.test(emailAddress);
274 };
275
276 var LoginProcess = function LoginProcess() {
277 var submitBtn = $('.login-submit');
278 var email = $('.login-mail');
279 var pass = $('.login-pass');
280 var result = $('.login-result');
281 submitBtn.on('click', function () {
282 if ('' === email.val() || '' === pass.val()) {
283 result.text((0, _i18n.__)('Both Field required.', 'sellkit')).css({
284 color: 'red'
285 });
286 return;
287 }
288
289 wp.ajax.post({
290 beforeSend: function beforeSend() {
291 $('.login-submit').css('opacity', '0.5');
292 },
293 action: 'sellkit_checkout_ajax_handler',
294 sub_action: 'auth_user',
295 email: email.val(),
296 pass: pass.val(),
297 nonce: sellkit_elementor.nonce
298 }).done(function () {
299 location.reload();
300 }).fail(function (response) {
301 $('.login-submit').css('opacity', '1');
302 $('.login-result').html(response).css({
303 color: 'red'
304 });
305 });
306 });
307 };
308
309 var secondStepHeader = function secondStepHeader() {
310 var email = $('#billing_email');
311 $('.multistep-headers > .info-a > div > .mail').text(email.val());
312 var countryValue = $('#shipping_country option:selected').text();
313 var state = $('#sellkit-shipping_state');
314 var postcode = $('#shipping_postcode');
315 var city = $('#shipping_city');
316 var addressA = $('#shipping_address_1');
317 var addressB = $('#shipping_address_2');
318 var finalAddress = postcode.val() ? ', ' + postcode.val() : '';
319 finalAddress += addressB.val() ? ', ' + addressB.val() : '';
320 finalAddress += addressA.val() ? ', ' + addressA.val() : '';
321 finalAddress += city.val() ? ', ' + city.val() : '';
322 finalAddress += state.val() ? ', ' + state.val() : '';
323 finalAddress += countryValue && !countryValue.includes('/') ? ', ' + countryValue : '';
324
325 if (',' === finalAddress.charAt(0)) {
326 finalAddress = finalAddress.substring(1);
327 }
328
329 $('.multistep-headers > .info-b > div > .address').text(finalAddress);
330 var method = $('#shipping_method').find('input[type=radio]:checked');
331 var methodTxt = method.siblings('label').text();
332 $('.multistep-headers > .info-c > div > .method').text(methodTxt);
333 };
334
335 var manageBillingMethod = function manageBillingMethod() {
336 var billingWrap = $('.sellkit-one-page-checkout-billing');
337 var methodA = billingWrap.find('.method-a');
338 var methodB = billingWrap.find('.method-b'); // Get shipping values.
339
340 var name = $('#shipping_first_name');
341 var last = $('#shipping_last_name');
342 var addressA = $('#shipping_address_1');
343 var addressB = $('#shipping_address_2');
344 var country = $('#shipping_country');
345 var state = $('#sellkit-shipping_state');
346 var postcode = $('#shipping_postcode');
347 var city = $('#shipping_city');
348 methodA.on('click', function () {
349 billingWrap.find('.woocommerce-billing-fields__field-wrapper').hide();
350 $('#billing_first_name').val(name.val());
351 $('#billing_last_name').val(last.val());
352 $('#billing_address_1').val(addressA.val());
353 $('#billing_address_2').val(addressB.val());
354 $('#billing_country').val(country.val()).trigger('change');
355 $('#sellkit-billing_state').val(state.val()).trigger('change');
356 $('#billing_postcode').val(postcode.val());
357 $('#billing_city').val(city.val());
358 });
359 methodB.on('click', function () {
360 $('.inner_wrapper').css('height', 'auto');
361 billingWrap.find('.woocommerce-billing-fields__field-wrapper').show();
362 });
363 };
364
365 var mobileSummary = function mobileSummary() {
366 if ($(window).width() < 600) {
367 $('#order_review').addClass('sellkit-mobile-multistep-order-summary');
368 }
369
370 var toggleBtn = $('.summary_toggle > .title, .summary_toggle > i, .summary_toggle > .icon');
371 var wrap = $('.summary_toggle');
372 toggleBtn.on('click', function () {
373 $('#order_review').toggle();
374
375 if ('Hide order summary' === toggleBtn.text()) {
376 wrap.find('.title').text((0, _i18n.__)('Show order summary', 'sellkit'));
377 wrap.find('i').addClass('fa-chevron-down').removeClass('fa-chevron-up');
378 wrap.css('border-bottom-width', '0px');
379 } else {
380 wrap.find('.title').text((0, _i18n.__)('Hide order summary', 'sellkit'));
381 wrap.find('i').addClass('fa-chevron-up').removeClass('fa-chevron-down');
382 wrap.css('border-bottom-width', '1px');
383 }
384
385 var parent = $('#sellkit-checkout-multistep-inner-wrap');
386 parent.css('height', 'auto');
387 });
388 };
389
390 var fieldFocus = function fieldFocus() {
391 var $fields = $('.sellkit-checkout-local-fields').find('input, select, hidden, textarea, #sellkit-billing_state ,#sellkit-shipping_state, .validate-email');
392 $fields.each(function () {
393 var _this3 = this;
394
395 var miniTitle = $(this).parent().parent().parent().find('.mini-title');
396 var $thisValue = $(this).val(); // On load.
397
398 if (!_.isEmpty($thisValue)) {
399 $(this).addClass('filled').removeClass('empty');
400 miniTitle.css({
401 display: 'flex'
402 });
403 } // On change/focusOut
404
405
406 $(this).on('change input focusout', function (e) {
407 var changedValue = $(_this3).val();
408
409 if (changedValue || $(_this3).find('option').length) {
410 $(_this3).addClass('filled');
411 $(_this3).removeClass('empty');
412 $(_this3).parents('.sellkit-widget-checkout-fields').find('.mini-title').css('display', 'flex');
413 } else {
414 $(_this3).addClass('empty');
415 $(_this3).removeClass('filled');
416 $(_this3).parents('.sellkit-widget-checkout-fields').find('.mini-title').hide();
417 } // On focusout validate fields.
418
419
420 if ('focusout' === e.type) {
421 FieldsMiniTitles($(_this3), 'focusout');
422 var parent = $(_this3).parent().parent().parent(); // Required validation. return if required field rule is not followed.
423
424 if (parent.hasClass('validate-required')) {
425 if ('INPUT' === _this3.nodeName && 'checkbox' === $(_this3).attr('type')) {
426 if (!_this3.checked) {
427 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
428 return;
429 }
430 }
431
432 if (_.isEmpty($(_this3).val())) {
433 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
434 return;
435 }
436
437 parent.find('.sellkit-required-validation').css('display', 'none');
438 } // Required validation of this field if exists, passed successfully. now postcode validation.
439
440
441 if (parent.hasClass('sellkit-checkout-fields-validation-postcode')) {
442 var postcodeVal = $(_this3).val();
443
444 if (_.isEmpty(postcodeVal)) {
445 return;
446 } // Check field type to get related country value. we can't validate without country code.
447
448
449 var postcodeName = $(_this3).attr('name');
450 var postcodeCountry = $('#billing_country');
451
452 if (postcodeName.includes('shipping')) {
453 postcodeCountry = $('#shipping_country');
454 } // Keep validating only if country field is present.
455
456
457 if (!postcodeCountry.length) {
458 return;
459 }
460
461 var countryCode = postcodeCountry.val();
462
463 if (_.isEmpty(countryCode)) {
464 parent.find('.sellkit-checkout-field-global-errors').show().text((0, _i18n.__)('Please select a country.', 'sellkit'));
465 return;
466 } else {
467 // eslint-disable-line
468 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
469 }
470
471 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
472 postcodeValidation(postcodeVal, countryCode, $(_this3));
473 } // Phone validation using woocommerce way.
474
475
476 if (parent.hasClass('sellkit-checkout-fields-validation-phone')) {
477 var phone = $(_this3).val();
478
479 if (_.isEmpty(phone)) {
480 return;
481 }
482
483 phoneNumberValidation(phone, $(_this3));
484 }
485 }
486
487 if ('change' === e.type && ('billing_country' === $(_this3).attr('id') || 'shipping_country' === $(_this3).attr('id'))) {
488 var _countryCode = $(_this3).val();
489
490 var states = wcCountries[_countryCode];
491 var state = 'sellkit-shipping_state';
492
493 if ('billing_country' === $(_this3).attr('id')) {
494 state = 'sellkit-billing_state';
495 }
496
497 var stateField = document.getElementById(state);
498
499 if (_.isNull(stateField)) {
500 return;
501 }
502
503 $(stateField).empty();
504
505 for (var keys in states) {
506 var option = document.createElement('option');
507 option.value = keys;
508 option.innerHTML = states[keys];
509 stateField.appendChild(option);
510 }
511 }
512 });
513 });
514 };
515
516 var breadcrumbLinks = function breadcrumbLinks() {
517 var $parent = $('.sellkit-checkout-widget-breadcrumb-mobile, .sellkit-checkout-widget-breadcrumb-desktop');
518 var detector = $('.sellkit-multistep-checkout-first');
519 $parent.find('.information').on('click', function () {
520 $('.go-to-first').click();
521 });
522 $parent.find('.shipping').on('click', function () {
523 var display = detector.css('display');
524
525 if ('none' === display) {
526 $('.go-to-second').click();
527 } else {
528 $('.go-to-shipping').click();
529 }
530 });
531 $parent.find('.payment').on('click', function () {
532 $('.go-to-payment').click();
533 $('.information').removeClass('current').addClass('inactive, blue-line');
534 });
535 };
536
537 var fixFieldSpaceIssue = function fixFieldSpaceIssue() {
538 $(function () {
539 var shippingFields = $('#customer_details .sellkit-widget-checkout-fields');
540 shippingFields.each(function (index) {
541 if ($(shippingFields[index + 1]).length) {
542 var next = $(shippingFields[index + 1]).offset().top;
543 var current = $(shippingFields[index]).offset().top;
544
545 if (next > current) {
546 $(shippingFields[index]).addClass('sellkit-checkout-excluded-wrapper-fields');
547 }
548 } else {
549 $(shippingFields[index]).addClass('sellkit-checkout-excluded-wrapper-fields');
550 }
551 });
552 });
553 };
554
555 var organizeFieldsonLoad = function organizeFieldsonLoad() {
556 $(function () {
557 var fields = $('.sellkit-widget-checkout-fields').find('input, select, textarea');
558 fields.each(function () {
559 var tag = this.nodeName;
560
561 if ('SELECT' === tag) {
562 $(this).parent().parent().parent().addClass('sellkit-checkout-field-select');
563 }
564
565 FieldsMiniTitles($(this), 'load');
566 });
567 });
568 $(document).on('mousemove change', function (e) {
569 var fields = $('.sellkit-widget-checkout-fields').find('input, select, textarea');
570 fields.each(function () {
571 var tag = this.nodeName;
572
573 if ('SELECT' === tag) {
574 $(this).parent().parent().parent().addClass('sellkit-checkout-field-select');
575 }
576
577 FieldsMiniTitles($(this), e.type);
578 });
579 });
580 };
581
582 var FieldsMiniTitles = function FieldsMiniTitles(field, event) {
583 if (field.attr('multiple')) {
584 field.addClass('filled');
585 field.removeClass('empty');
586 field.parents('.sellkit-widget-checkout-fields').find('.mini-title').css('display', 'flex');
587 return;
588 }
589
590 if (_.isEmpty(field.val())) {
591 field.addClass('empty');
592 field.removeClass('filled');
593 field.parents('.sellkit-widget-checkout-fields').find('.mini-title').css('display', 'none');
594 } else {
595 field.addClass('filled');
596 field.removeClass('empty');
597 field.parents('.sellkit-widget-checkout-fields').find('.mini-title').css('display', 'flex');
598 } // Hide wrapper if field is hidden
599
600
601 if ('hidden' === field.attr('type')) {
602 field.parents('.sellkit-widget-checkout-fields').addClass('sellkit-hide-completely');
603 }
604
605 if ('change' !== event) {
606 return;
607 } // Hide Billing state wrapper when these fields are hidden.
608
609
610 if ('billing_country' === field.attr('id')) {
611 var $state = document.getElementById('sellkit-billing_state');
612
613 if (!_.isNull($state) && 'SELECT' === $state.nodeName && $('#sellkit-billing_state option').length < 1) {
614 var stateField = $('#sellkit-billing_state');
615 var parent = stateField.parent().parent().parent();
616 parent.removeClass('sellkit-checkout-field-select');
617 var placeholder = stateField.attr('placeholder');
618 var stateInput = document.createElement('input');
619 stateInput.setAttribute('type', 'text');
620 stateInput.setAttribute('id', 'sellkit-billing_state');
621 stateInput.setAttribute('name', 'billing_state');
622 stateInput.setAttribute('placeholder', placeholder); // Replace select field with text.
623
624 stateField.remove();
625 parent.find('.woocommerce-input-wrapper').append(stateInput);
626 }
627
628 var countryCode = field.val();
629 var states = wcCountries[countryCode];
630
631 if (!_.isNull($state) && 'INPUT' === $state.nodeName && !_.isEmpty(states)) {
632 var _stateField = $('#sellkit-billing_state');
633
634 var _placeholder = _stateField.attr('placeholder');
635
636 var _parent = _stateField.parent().parent().parent();
637
638 _parent.addClass('sellkit-checkout-field-select');
639
640 if (_.isUndefined(_placeholder) || _.isEmpty(_placeholder)) {
641 _placeholder = (0, _i18n.__)('State', 'sellkit');
642 } // Replace text field with select field.
643
644
645 _stateField.remove();
646
647 var stateSelect = document.createElement('select');
648 stateSelect.setAttribute('name', 'billing_state');
649 stateSelect.setAttribute('id', 'sellkit-billing_state');
650 stateSelect.setAttribute('placeholder', _placeholder);
651 stateSelect.addEventListener('change', function () {
652 sellkitSetAddressDetails();
653 });
654
655 for (var keys in states) {
656 var option = document.createElement('option');
657 option.value = keys;
658 option.innerHTML = states[keys];
659 stateSelect.appendChild(option);
660 }
661
662 _parent.find('.woocommerce-input-wrapper').append(stateSelect);
663 }
664 } // Remove select icon when field is text for the shipping/billing state fields.
665
666
667 if ('shipping_country' === field.attr('id')) {
668 var _$state = document.getElementById('sellkit-shipping_state');
669
670 if (!_.isNull(_$state) && 'SELECT' === _$state.nodeName && $('#sellkit-shipping_state option').length < 1) {
671 var _stateField2 = $('#sellkit-shipping_state');
672
673 var _parent2 = _stateField2.parent().parent().parent();
674
675 _parent2.removeClass('sellkit-checkout-field-select');
676
677 var _placeholder2 = _stateField2.attr('placeholder');
678
679 var _stateInput = document.createElement('input');
680
681 _stateInput.setAttribute('type', 'text');
682
683 _stateInput.setAttribute('id', 'sellkit-shipping_state');
684
685 _stateInput.setAttribute('name', 'shipping_state');
686
687 _stateInput.setAttribute('placeholder', _placeholder2); // Replace select field with text.
688
689
690 _stateField2.remove();
691
692 _parent2.find('.woocommerce-input-wrapper').append(_stateInput);
693 }
694
695 var _countryCode2 = field.val();
696
697 var _states = wcCountries[_countryCode2];
698
699 if (!_.isNull(_$state) && 'INPUT' === _$state.nodeName && !_.isEmpty(_states)) {
700 var _stateField3 = $('#sellkit-shipping_state');
701
702 var _placeholder3 = _stateField3.attr('placeholder');
703
704 var _parent3 = _stateField3.parent().parent().parent();
705
706 _parent3.addClass('sellkit-checkout-field-select');
707
708 if (_.isUndefined(_placeholder3) || _.isEmpty(_placeholder3)) {
709 _placeholder3 = (0, _i18n.__)('State', 'sellkit');
710 } // Replace text field with select field.
711
712
713 _stateField3.remove();
714
715 var _stateSelect = document.createElement('select');
716
717 _stateSelect.setAttribute('name', 'shipping_state');
718
719 _stateSelect.setAttribute('id', 'sellkit-shipping_state');
720
721 _stateSelect.setAttribute('placeholder', _placeholder3);
722
723 _stateSelect.addEventListener('change', function () {
724 sellkitSetAddressDetails();
725 });
726
727 for (var _keys in _states) {
728 var _option = document.createElement('option');
729
730 _option.value = _keys;
731 _option.innerHTML = _states[_keys];
732
733 _stateSelect.appendChild(_option);
734 }
735
736 _parent3.find('.woocommerce-input-wrapper').append(_stateSelect);
737 }
738 }
739 };
740 /**
741 * Change cart item quantity.
742 *
743 * @since 1.2.5
744 */
745
746
747 var sellkitCheckoutUpdateCartItem = function sellkitCheckoutUpdateCartItem() {
748 $('.sellkit-one-page-checkout-product-qty').off('change').on('change', function () {
749 $(this).attr('readonly', true);
750 wp.ajax.post({
751 action: 'sellkit_checkout_ajax_handler',
752 sub_action: 'change_cart_item_qty',
753 qty: $(this).val(),
754 id: $(this).attr('data-id'),
755 mode: 'edit',
756 related_checkout: $('#sellkit_current_page_id').val(),
757 nonce: sellkit_elementor.nonce
758 }).always(function () {
759 $(document.body).trigger('update_checkout');
760 $('.sellkit-one-page-checkout-product-qty').attr('readonly', false);
761 });
762 });
763 $('.sellkit-one-page-pay-method').on('click', function () {
764 $('.sellkit_payment_box').hide();
765 $(this).parent().parent().next().show();
766 });
767 var count = $('.sellkit-checkout-widget-order-summary-tfoot').children().length;
768
769 if (count <= 3) {
770 $('.cart-subtotal td').css('padding-bottom', '8px');
771 $('.cart-subtotal th').css('padding-bottom', '8px');
772 }
773 };
774 /**
775 * Apply a coupon.
776 *
777 * @since 1.2.5
778 */
779
780
781 var applyCoupon = function applyCoupon() {
782 $('.sellkit-apply-coupon').off('click').on('click', function () {
783 wp.ajax.post({
784 beforeSend: function beforeSend() {
785 $('.jx-apply-coupon').css('opacity', 0.5);
786 },
787 action: 'sellkit_checkout_ajax_handler',
788 sub_action: 'apply_coupon',
789 code: jQuery('.sellkit-custom-coupon-form').find('.jx-coupon').val(),
790 nonce: sellkit_elementor.nonce
791 }).done(function () {
792 $(document.body).trigger('update_checkout');
793 $('.jx-apply-coupon').css('opacity', 1);
794 }).fail(function () {
795 $('.jx-apply-coupon').css('opacity', 1);
796 });
797 });
798 };
799 /**
800 * Toggle coupon form on click event.
801 *
802 * @since 1.2.5
803 */
804
805
806 var couponToggle = function couponToggle() {
807 if ($('.sellkit-coupon-toggle').length) {
808 $('.sellkit-custom-coupon-form').css('display', 'none');
809 }
810
811 $('.sellkit-coupon-toggle').off('click').on('click', function () {
812 var direction = 'row';
813 var status = $('.sellkit-custom-coupon-form').css('display');
814 var displayValue = '';
815
816 if ($(window).width() < 600) {
817 direction = 'column';
818 }
819
820 if ('none' === status) {
821 displayValue = 'inline-flex';
822 } else {
823 displayValue = 'none';
824 }
825
826 $('.sellkit-custom-coupon-form').css({
827 display: displayValue,
828 flexDirection: direction
829 });
830 });
831 };
832 /**
833 * Validate postcode in WooCommerce way.
834 *
835 * @param {string} postcode
836 * @param {string} country
837 * @param {Object} element
838 */
839
840
841 var postcodeValidation = function postcodeValidation(postcode, country, element) {
842 var parentElement = element.attr('id');
843 wp.ajax.post({
844 action: 'sellkit_checkout_ajax_handler',
845 sub_action: 'validate_postcode',
846 post_code: postcode,
847 country_code: country,
848 parent: parentElement,
849 nonce: sellkit_elementor.nonce
850 }).done(function (response) {
851 var field = $('#' + response);
852 var parent = field.parent().parent().parent();
853 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
854 }).fail(function (response) {
855 var field = $('#' + response);
856 var parent = field.parent().parent().parent();
857 parent.find('.sellkit-checkout-field-global-errors').show().text((0, _i18n.__)('Postcode is not valid.', 'sellkit'));
858 });
859 };
860 /**
861 * Validate phone number in WooCommerce way.
862 *
863 * @param {string} phone
864 * @param {Object} element
865 */
866
867
868 var phoneNumberValidation = function phoneNumberValidation(phone, element) {
869 var parentElement = element.attr('id');
870 wp.ajax.post({
871 action: 'sellkit_checkout_ajax_handler',
872 sub_action: 'validate_phone_number',
873 phone_number: phone,
874 parent: parentElement,
875 nonce: sellkit_elementor.nonce
876 }).done(function (response) {
877 var field = $('#' + response);
878 var parent = field.parent().parent().parent();
879 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
880 }).fail(function (response) {
881 var field = $('#' + response);
882 var parent = field.parent().parent().parent();
883 parent.find('.sellkit-checkout-field-global-errors').show().text((0, _i18n.__)('Phone number is not valid.', 'sellkit'));
884 });
885 };
886 /**
887 * Auto populate city and state fields using postcode by getting information from third api : https://api.zippopotam.us/.
888 *
889 * @since 1.2.5
890 */
891
892
893 var sellkitPostalCodeAutocomplete = function sellkitPostalCodeAutocomplete() {
894 $('.post_code_autocomplete').find('input').on('paste focusout', function () {
895 var postcode = $(this).val();
896 var country = $('#shipping_country').val();
897 var state = $('#sellkit-shipping_state');
898 var city = $('#shipping_city');
899 var parent = $(this).parent().parent().parent();
900
901 if ('billing_postcode' === $(this).attr('id')) {
902 country = $('#billing_country').val();
903 state = $('#sellkit-billing_state');
904 city = $('#billing_city');
905 }
906
907 if (_.isEmpty(postcode) || _.isEmpty(country)) {
908 return;
909 }
910
911 wp.ajax.post({
912 action: 'sellkit_checkout_ajax_handler',
913 sub_action: 'sellkit_state_lookup_by_postcode',
914 country_value: country,
915 postcode_value: postcode,
916 nonce: sellkit_elementor.nonce
917 }).done(function (response) {
918 setError('');
919 var body = response;
920 var placeCity = body.places[0]['place name'];
921 var placeState = body.places[0]['state abbreviation'];
922 var countryResponse = body['country abbreviation'];
923
924 if (_.isEmpty(placeState)) {
925 placeState = body.places[0].state;
926 }
927
928 var countries = ['DE', 'TR', 'BD', 'DO', 'GB', 'GT', 'JP', 'TH', 'ZA'];
929
930 if (countries.includes(countryResponse)) {
931 placeState = fixConflictWooCommerceStatesWithApi(countryResponse, placeState, body);
932 }
933
934 setFields(placeCity, placeState);
935 }).fail(function (response) {
936 setError(response);
937 });
938
939 var setFields = function setFields(placeCity, placeState) {
940 state.val(placeState).addClass('filled');
941 city.val(placeCity).addClass('filled');
942 };
943
944 var setError = function setError(response) {
945 parent.find('.sellkit-checkout-field-global-errors').text(response);
946 };
947 });
948 };
949 /**
950 * Fix some countries states conflict between WooCommerce and https://api.zippopotam.us/.
951 *
952 * @param {string} country response country.
953 * @param {string} state response state.
954 * @param {Object} body response body.
955 * @return {string} state.
956 */
957
958
959 var fixConflictWooCommerceStatesWithApi = function fixConflictWooCommerceStatesWithApi(country, state, body) {
960 switch (country) {
961 case 'TR':
962 // Turkey.
963 state = 'TR' + state;
964 break;
965
966 case 'DE':
967 // Germany.
968 state = 'DE-' + state;
969 break;
970
971 case 'BD':
972 // Bangladesh.
973 state = sellkitCheckoutCountryFixAutoPopulate(state, country, body);
974 break;
975
976 case 'DO':
977 // Dominican Republic. Api has no proper response. we select first option
978 state = 'DO-01';
979 break;
980
981 case 'GB':
982 // United kingdom.
983 state = body.places[0].state;
984 break;
985
986 case 'GT':
987 // Guatemala.
988 state = 'GT-AV';
989 break;
990
991 case 'JP':
992 // Japan.
993 state = sellkitCheckoutCountryFixAutoPopulate(state, country, body);
994 break;
995
996 case 'TH':
997 // Thailand.
998 state = sellkitCheckoutCountryFixAutoPopulate(state, country, body);
999 break;
1000
1001 case 'ZA':
1002 // South Africa. API has no proper response. we select first option.
1003 state = 'EC';
1004 break;
1005
1006 default:
1007 return state;
1008 }
1009
1010 return state;
1011 };
1012 /**
1013 * Integration with Klarma checkout gateway.
1014 *
1015 * @since 1.2.5
1016 */
1017
1018
1019 var sellkitKlarmaIntegration = function sellkitKlarmaIntegration() {
1020 $(document).ready(function () {
1021 $('#sellkit-klarna-pay-button').on('click', function () {
1022 $('#payment_method_kco').trigger('click');
1023 });
1024 });
1025 };
1026 /**
1027 * Save client state and country on change event.
1028 *
1029 * @since 1.2.5
1030 */
1031
1032
1033 var fixClientCountryOnReload = function fixClientCountryOnReload() {
1034 $('#shipping_country, #billing_country, #sellkit-shipping_state, #sellkit-billing_state').on('change', function () {
1035 sellkitSetAddressDetails();
1036 });
1037 };
1038 /**
1039 * Ajax to save user state and country for both shipping and billing section if those fields are present.
1040 *
1041 * @since 1.2.5
1042 */
1043
1044
1045 var sellkitSetAddressDetails = function sellkitSetAddressDetails() {
1046 wp.ajax.post({
1047 action: 'sellkit_checkout_ajax_handler',
1048 sub_action: 'set_customer_details_ajax',
1049 country: document.querySelector('#billing_country') ? document.getElementById('billing_country').value : '',
1050 state: document.querySelector('#sellkit-billing_state') ? document.getElementById('sellkit-billing_state').value : '',
1051 shipping_country: document.querySelector('#shipping_country') ? document.getElementById('shipping_country').value : '',
1052 shipping_state: document.querySelector('#sellkit-shipping_state') ? document.getElementById('sellkit-shipping_state').value : '',
1053 nonce: sellkit_elementor.nonce
1054 }).always(function () {
1055 $(document.body).trigger('update_checkout');
1056 });
1057 };
1058 /**
1059 * On page load set shipping and billing state & country values.
1060 *
1061 * @since 1.2.5
1062 */
1063
1064
1065 var fixStateIssueOnLoad = function fixStateIssueOnLoad() {
1066 var primaryValue = '';
1067
1068 if (document.querySelector('#shipping_country')) {
1069 primaryValue = $('#shipping_country').val();
1070 $('#shipping_country').val($('#shipping_country option:eq(1)').val());
1071 $('#shipping_country').val(primaryValue).trigger('change');
1072 }
1073
1074 if (document.querySelector('#billing_country')) {
1075 primaryValue = $('#billing_country').val();
1076 $('#billing_country').val($('#billing_country option:eq(1)').val());
1077 $('#billing_country').val(primaryValue).trigger('change');
1078 }
1079 };
1080 /**
1081 * Modify cart items when bundle products are present.
1082 *
1083 * @since 1.2.5
1084 */
1085
1086
1087 var sellkitCheckoutConfigureBundleProducts = function sellkitCheckoutConfigureBundleProducts() {
1088 var radioProducts = $('.sellkit-checkout-bundle-item');
1089 radioProducts.off('change').on('change', function () {
1090 $('.sellkit-checkout-bump-order-products').each(function () {
1091 if ($(this).is(':checked')) {
1092 $(this).trigger('click');
1093 }
1094 });
1095 var product = $(this).val();
1096 var quantity = $(this).parent().parent().find('.sellkit-checkout-single-bundle-item-quantity').val();
1097 wp.ajax.post({
1098 action: 'sellkit_checkout_ajax_handler',
1099 sub_action: 'sellkit_checkout_modify_cart_by_bundle_products',
1100 id: product,
1101 qty: quantity,
1102 type: 'radio',
1103 nonce: sellkit_elementor.nonce
1104 }).always(function () {
1105 $(document.body).trigger('update_checkout');
1106 });
1107 });
1108 };
1109 /**
1110 * Manage to add or remove a bump product from cart.
1111 *
1112 * @since 1.2.5
1113 */
1114
1115
1116 var sellkitCheckoutOrderBump = function sellkitCheckoutOrderBump() {
1117 $('.sellkit-checkout-bump-order-products').on('click', function () {
1118 var subAction;
1119
1120 if ($(this).is(':checked')) {
1121 subAction = 'add';
1122 } else {
1123 subAction = 'remove';
1124 }
1125
1126 wp.ajax.post({
1127 action: 'sellkit_checkout_ajax_handler',
1128 sub_action: 'change_cart_item_qty',
1129 qty: $(this).attr('data-qty'),
1130 id: $(this).val(),
1131 mode: subAction,
1132 related_checkout: $('#sellkit_current_page_id').val(),
1133 nonce: sellkit_elementor.nonce
1134 }).always(function () {
1135 $(document.body).trigger('update_checkout');
1136 });
1137 });
1138 };
1139 /**
1140 * Checks if a required field is not filled.
1141 *
1142 * @return {boolean} state of error.
1143 * @since 1.2.5
1144 */
1145
1146
1147 var checkRequiredFields = function checkRequiredFields() {
1148 var fields = document.querySelectorAll('#sellkit-checkout-widget-shipping-fields > .validate-required');
1149 var error = false;
1150
1151 if (fields.length < 1) {
1152 return error;
1153 }
1154
1155 fields.forEach(function (item) {
1156 var target = $(item).find('input, select, textarea').val();
1157
1158 if ('' === target) {
1159 error = true;
1160 $(item).find('.sellkit-required-validation').css('display', 'inline-flex');
1161 }
1162 });
1163 return error;
1164 };
1165 /**
1166 * Loop through WooCommerce states and replace api returned value.
1167 *
1168 * @param {string} state
1169 * @param {string} countryAbbreviated
1170 * @param {Object} body
1171 * @return {string} state value.
1172 * @since 1.2.5
1173 */
1174
1175
1176 var sellkitCheckoutCountryFixAutoPopulate = function sellkitCheckoutCountryFixAutoPopulate(state, countryAbbreviated, body) {
1177 var value = '';
1178 var country = '';
1179
1180 if ('BD' === countryAbbreviated) {
1181 country = wcCountries.BD;
1182 }
1183
1184 if ('JP' === countryAbbreviated) {
1185 country = wcCountries.JP;
1186 state = state.substring(0, state.length - 3);
1187 }
1188
1189 if ('TH' === countryAbbreviated) {
1190 value = 'TH-37';
1191 country = wcCountries.TH;
1192 state = body.places[0].state;
1193 }
1194
1195 for (var key in country) {
1196 if (state === country[key]) {
1197 value = key;
1198 }
1199 }
1200
1201 return value;
1202 };
1203
1204 },{"@wordpress/i18n":12}],2:[function(require,module,exports){
1205 "use strict";
1206
1207 (function ($) {
1208 var SellkitFrontend = function SellkitFrontend() {
1209 var widgets = {
1210 'sellkit-product-images.default': require('./product-images')["default"],
1211 'sellkit-checkout.default': require('./checkout')["default"]
1212 };
1213
1214 function elementorInit() {
1215 for (var widget in widgets) {
1216 elementorFrontend.hooks.addAction("frontend/element_ready/".concat(widget), widgets[widget]);
1217 }
1218 }
1219
1220 this.init = function () {
1221 $(window).on('elementor/frontend/init', elementorInit);
1222 };
1223
1224 this.init();
1225 };
1226
1227 window.sellkitFrontend = new SellkitFrontend();
1228 })(jQuery);
1229
1230 },{"./checkout":1,"./product-images":3}],3:[function(require,module,exports){
1231 "use strict";
1232
1233 Object.defineProperty(exports, "__esModule", {
1234 value: true
1235 });
1236 exports["default"] = _default;
1237 var ProductImages = elementorModules.frontend.handlers.Base.extend({
1238 onInit: function onInit() {
1239 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments);
1240
1241 if (document.body.classList.contains('elementor-editor-active')) {
1242 this.$element.find('.woocommerce-product-gallery').wc_product_gallery();
1243 }
1244
1245 var self = this;
1246
1247 if (typeof window.elementor === 'undefined') {
1248 return;
1249 }
1250
1251 window.elementor.channels.editor.on('change', function (controlView) {
1252 self.onElementChange(controlView.model.get('name'), controlView);
1253 });
1254 this.handleThumbnailBorderRadius(this.getElementSettings('thumbnail_border_radius'));
1255 },
1256 onElementChange: function onElementChange(propertyName, controlView) {
1257 if ('thumbnail_border_radius' === propertyName) {
1258 var borderRadius = controlView.container.settings.get('thumbnail_border_radius');
1259 this.handleThumbnailBorderRadius(borderRadius);
1260 }
1261 },
1262 handleThumbnailBorderRadius: function handleThumbnailBorderRadius(borderRadius) {
1263 var unit = borderRadius.unit;
1264 this.$element.find('.flex-control-nav li').css({
1265 'border-radius': borderRadius.top + unit + ' ' + borderRadius.right + unit + ' ' + borderRadius.bottom + unit + ' ' + borderRadius.left + unit
1266 });
1267 },
1268 bindEvents: function bindEvents() {
1269 this.$element.find('.woocommerce-product-gallery__image a').on('click', function (e) {
1270 e.stopImmediatePropagation();
1271 e.preventDefault();
1272 });
1273 }
1274 });
1275
1276 function _default($scope) {
1277 new ProductImages({
1278 $element: $scope
1279 });
1280 }
1281
1282 },{}],4:[function(require,module,exports){
1283 function _defineProperty(obj, key, value) {
1284 if (key in obj) {
1285 Object.defineProperty(obj, key, {
1286 value: value,
1287 enumerable: true,
1288 configurable: true,
1289 writable: true
1290 });
1291 } else {
1292 obj[key] = value;
1293 }
1294
1295 return obj;
1296 }
1297
1298 module.exports = _defineProperty;
1299 },{}],5:[function(require,module,exports){
1300 function _interopRequireDefault(obj) {
1301 return obj && obj.__esModule ? obj : {
1302 "default": obj
1303 };
1304 }
1305
1306 module.exports = _interopRequireDefault;
1307 },{}],6:[function(require,module,exports){
1308 'use strict';
1309
1310 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
1311
1312 var postfix = _interopDefault(require('@tannin/postfix'));
1313 var evaluate = _interopDefault(require('@tannin/evaluate'));
1314
1315 /**
1316 * Given a C expression, returns a function which can be called to evaluate its
1317 * result.
1318 *
1319 * @example
1320 *
1321 * ```js
1322 * import compile from '@tannin/compile';
1323 *
1324 * const evaluate = compile( 'n > 1' );
1325 *
1326 * evaluate( { n: 2 } );
1327 * // ⇒ true
1328 * ```
1329 *
1330 * @param {string} expression C expression.
1331 *
1332 * @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
1333 */
1334 function compile( expression ) {
1335 var terms = postfix( expression );
1336
1337 return function( variables ) {
1338 return evaluate( terms, variables );
1339 };
1340 }
1341
1342 module.exports = compile;
1343
1344 },{"@tannin/evaluate":7,"@tannin/postfix":9}],7:[function(require,module,exports){
1345 'use strict';
1346
1347 /**
1348 * Operator callback functions.
1349 *
1350 * @type {Object}
1351 */
1352 var OPERATORS = {
1353 '!': function( a ) {
1354 return ! a;
1355 },
1356 '*': function( a, b ) {
1357 return a * b;
1358 },
1359 '/': function( a, b ) {
1360 return a / b;
1361 },
1362 '%': function( a, b ) {
1363 return a % b;
1364 },
1365 '+': function( a, b ) {
1366 return a + b;
1367 },
1368 '-': function( a, b ) {
1369 return a - b;
1370 },
1371 '<': function( a, b ) {
1372 return a < b;
1373 },
1374 '<=': function( a, b ) {
1375 return a <= b;
1376 },
1377 '>': function( a, b ) {
1378 return a > b;
1379 },
1380 '>=': function( a, b ) {
1381 return a >= b;
1382 },
1383 '==': function( a, b ) {
1384 return a === b;
1385 },
1386 '!=': function( a, b ) {
1387 return a !== b;
1388 },
1389 '&&': function( a, b ) {
1390 return a && b;
1391 },
1392 '||': function( a, b ) {
1393 return a || b;
1394 },
1395 '?:': function( a, b, c ) {
1396 if ( a ) {
1397 throw b;
1398 }
1399
1400 return c;
1401 },
1402 };
1403
1404 /**
1405 * Given an array of postfix terms and operand variables, returns the result of
1406 * the postfix evaluation.
1407 *
1408 * @example
1409 *
1410 * ```js
1411 * import evaluate from '@tannin/evaluate';
1412 *
1413 * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
1414 * const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
1415 *
1416 * evaluate( terms, {} );
1417 * // ⇒ 6.333333333333334
1418 * ```
1419 *
1420 * @param {string[]} postfix Postfix terms.
1421 * @param {Object} variables Operand variables.
1422 *
1423 * @return {*} Result of evaluation.
1424 */
1425 function evaluate( postfix, variables ) {
1426 var stack = [],
1427 i, j, args, getOperatorResult, term, value;
1428
1429 for ( i = 0; i < postfix.length; i++ ) {
1430 term = postfix[ i ];
1431
1432 getOperatorResult = OPERATORS[ term ];
1433 if ( getOperatorResult ) {
1434 // Pop from stack by number of function arguments.
1435 j = getOperatorResult.length;
1436 args = Array( j );
1437 while ( j-- ) {
1438 args[ j ] = stack.pop();
1439 }
1440
1441 try {
1442 value = getOperatorResult.apply( null, args );
1443 } catch ( earlyReturn ) {
1444 return earlyReturn;
1445 }
1446 } else if ( variables.hasOwnProperty( term ) ) {
1447 value = variables[ term ];
1448 } else {
1449 value = +term;
1450 }
1451
1452 stack.push( value );
1453 }
1454
1455 return stack[ 0 ];
1456 }
1457
1458 module.exports = evaluate;
1459
1460 },{}],8:[function(require,module,exports){
1461 'use strict';
1462
1463 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
1464
1465 var compile = _interopDefault(require('@tannin/compile'));
1466
1467 /**
1468 * Given a C expression, returns a function which, when called with a value,
1469 * evaluates the result with the value assumed to be the "n" variable of the
1470 * expression. The result will be coerced to its numeric equivalent.
1471 *
1472 * @param {string} expression C expression.
1473 *
1474 * @return {Function} Evaluator function.
1475 */
1476 function pluralForms( expression ) {
1477 var evaluate = compile( expression );
1478
1479 return function( n ) {
1480 return +evaluate( { n: n } );
1481 };
1482 }
1483
1484 module.exports = pluralForms;
1485
1486 },{"@tannin/compile":6}],9:[function(require,module,exports){
1487 'use strict';
1488
1489 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
1490
1491 /**
1492 * Operator precedence mapping.
1493 *
1494 * @type {Object}
1495 */
1496 PRECEDENCE = {
1497 '(': 9,
1498 '!': 8,
1499 '*': 7,
1500 '/': 7,
1501 '%': 7,
1502 '+': 6,
1503 '-': 6,
1504 '<': 5,
1505 '<=': 5,
1506 '>': 5,
1507 '>=': 5,
1508 '==': 4,
1509 '!=': 4,
1510 '&&': 3,
1511 '||': 2,
1512 '?': 1,
1513 '?:': 1,
1514 };
1515
1516 /**
1517 * Characters which signal pair opening, to be terminated by terminators.
1518 *
1519 * @type {string[]}
1520 */
1521 OPENERS = [ '(', '?' ];
1522
1523 /**
1524 * Characters which signal pair termination, the value an array with the
1525 * opener as its first member. The second member is an optional operator
1526 * replacement to push to the stack.
1527 *
1528 * @type {string[]}
1529 */
1530 TERMINATORS = {
1531 ')': [ '(' ],
1532 ':': [ '?', '?:' ],
1533 };
1534
1535 /**
1536 * Pattern matching operators and openers.
1537 *
1538 * @type {RegExp}
1539 */
1540 PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
1541
1542 /**
1543 * Given a C expression, returns the equivalent postfix (Reverse Polish)
1544 * notation terms as an array.
1545 *
1546 * If a postfix string is desired, simply `.join( ' ' )` the result.
1547 *
1548 * @example
1549 *
1550 * ```js
1551 * import postfix from '@tannin/postfix';
1552 *
1553 * postfix( 'n > 1' );
1554 * // ⇒ [ 'n', '1', '>' ]
1555 * ```
1556 *
1557 * @param {string} expression C expression.
1558 *
1559 * @return {string[]} Postfix terms.
1560 */
1561 function postfix( expression ) {
1562 var terms = [],
1563 stack = [],
1564 match, operator, term, element;
1565
1566 while ( ( match = expression.match( PATTERN ) ) ) {
1567 operator = match[ 0 ];
1568
1569 // Term is the string preceding the operator match. It may contain
1570 // whitespace, and may be empty (if operator is at beginning).
1571 term = expression.substr( 0, match.index ).trim();
1572 if ( term ) {
1573 terms.push( term );
1574 }
1575
1576 while ( ( element = stack.pop() ) ) {
1577 if ( TERMINATORS[ operator ] ) {
1578 if ( TERMINATORS[ operator ][ 0 ] === element ) {
1579 // Substitution works here under assumption that because
1580 // the assigned operator will no longer be a terminator, it
1581 // will be pushed to the stack during the condition below.
1582 operator = TERMINATORS[ operator ][ 1 ] || operator;
1583 break;
1584 }
1585 } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
1586 // Push to stack if either an opener or when pop reveals an
1587 // element of lower precedence.
1588 stack.push( element );
1589 break;
1590 }
1591
1592 // For each popped from stack, push to terms.
1593 terms.push( element );
1594 }
1595
1596 if ( ! TERMINATORS[ operator ] ) {
1597 stack.push( operator );
1598 }
1599
1600 // Slice matched fragment from expression to continue match.
1601 expression = expression.substr( match.index + operator.length );
1602 }
1603
1604 // Push remainder of operand, if exists, to terms.
1605 expression = expression.trim();
1606 if ( expression ) {
1607 terms.push( expression );
1608 }
1609
1610 // Pop remaining items from stack into terms.
1611 return terms.concat( stack.reverse() );
1612 }
1613
1614 module.exports = postfix;
1615
1616 },{}],10:[function(require,module,exports){
1617 "use strict";
1618
1619 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1620
1621 Object.defineProperty(exports, "__esModule", {
1622 value: true
1623 });
1624 exports.createI18n = void 0;
1625
1626 var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
1627
1628 var _tannin = _interopRequireDefault(require("tannin"));
1629
1630 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1631
1632 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1633
1634 /**
1635 * @typedef {Record<string,any>} LocaleData
1636 */
1637
1638 /**
1639 * Default locale data to use for Tannin domain when not otherwise provided.
1640 * Assumes an English plural forms expression.
1641 *
1642 * @type {LocaleData}
1643 */
1644 var DEFAULT_LOCALE_DATA = {
1645 '': {
1646 /** @param {number} n */
1647 plural_forms: function plural_forms(n) {
1648 return n === 1 ? 0 : 1;
1649 }
1650 }
1651 };
1652 /**
1653 * An i18n instance
1654 *
1655 * @typedef {Object} I18n
1656 * @property {Function} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a
1657 * Jed-formatted JSON object shape.
1658 * @property {Function} __ Retrieve the translation of text.
1659 * @property {Function} _x Retrieve translated string with gettext context.
1660 * @property {Function} _n Translates and retrieves the singular or plural form based on the supplied
1661 * number.
1662 * @property {Function} _nx Translates and retrieves the singular or plural form based on the supplied
1663 * number, with gettext context.
1664 * @property {Function} isRTL Check if current locale is RTL.
1665 */
1666
1667 /**
1668 * Create an i18n instance
1669 *
1670 * @param {LocaleData} [initialData] Locale data configuration.
1671 * @param {string} [initialDomain] Domain for which configuration applies.
1672 * @return {I18n} I18n instance
1673 */
1674
1675 var createI18n = function createI18n(initialData, initialDomain) {
1676 /**
1677 * The underlying instance of Tannin to which exported functions interface.
1678 *
1679 * @type {Tannin}
1680 */
1681 var tannin = new _tannin.default({});
1682 /**
1683 * Merges locale data into the Tannin instance by domain. Accepts data in a
1684 * Jed-formatted JSON object shape.
1685 *
1686 * @see http://messageformat.github.io/Jed/
1687 *
1688 * @param {LocaleData} [data] Locale data configuration.
1689 * @param {string} [domain] Domain for which configuration applies.
1690 */
1691
1692 var setLocaleData = function setLocaleData(data) {
1693 var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
1694 tannin.data[domain] = _objectSpread({}, DEFAULT_LOCALE_DATA, {}, tannin.data[domain], {}, data); // Populate default domain configuration (supported locale date which omits
1695 // a plural forms expression).
1696
1697 tannin.data[domain][''] = _objectSpread({}, DEFAULT_LOCALE_DATA[''], {}, tannin.data[domain]['']);
1698 };
1699 /**
1700 * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
1701 * otherwise previously assigned.
1702 *
1703 * @param {string|undefined} domain Domain to retrieve the translated text.
1704 * @param {string|undefined} context Context information for the translators.
1705 * @param {string} single Text to translate if non-plural. Used as
1706 * fallback return value on a caught error.
1707 * @param {string} [plural] The text to be used if the number is
1708 * plural.
1709 * @param {number} [number] The number to compare against to use
1710 * either the singular or plural form.
1711 *
1712 * @return {string} The translated string.
1713 */
1714
1715
1716 var dcnpgettext = function dcnpgettext() {
1717 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
1718 var context = arguments.length > 1 ? arguments[1] : undefined;
1719 var single = arguments.length > 2 ? arguments[2] : undefined;
1720 var plural = arguments.length > 3 ? arguments[3] : undefined;
1721 var number = arguments.length > 4 ? arguments[4] : undefined;
1722
1723 if (!tannin.data[domain]) {
1724 setLocaleData(undefined, domain);
1725 }
1726
1727 return tannin.dcnpgettext(domain, context, single, plural, number);
1728 };
1729 /**
1730 * Retrieve the translation of text.
1731 *
1732 * @see https://developer.wordpress.org/reference/functions/__/
1733 *
1734 * @param {string} text Text to translate.
1735 * @param {string} [domain] Domain to retrieve the translated text.
1736 *
1737 * @return {string} Translated text.
1738 */
1739
1740
1741 var __ = function __(text, domain) {
1742 return dcnpgettext(domain, undefined, text);
1743 };
1744 /**
1745 * Retrieve translated string with gettext context.
1746 *
1747 * @see https://developer.wordpress.org/reference/functions/_x/
1748 *
1749 * @param {string} text Text to translate.
1750 * @param {string} context Context information for the translators.
1751 * @param {string} [domain] Domain to retrieve the translated text.
1752 *
1753 * @return {string} Translated context string without pipe.
1754 */
1755
1756
1757 var _x = function _x(text, context, domain) {
1758 return dcnpgettext(domain, context, text);
1759 };
1760 /**
1761 * Translates and retrieves the singular or plural form based on the supplied
1762 * number.
1763 *
1764 * @see https://developer.wordpress.org/reference/functions/_n/
1765 *
1766 * @param {string} single The text to be used if the number is singular.
1767 * @param {string} plural The text to be used if the number is plural.
1768 * @param {number} number The number to compare against to use either the
1769 * singular or plural form.
1770 * @param {string} [domain] Domain to retrieve the translated text.
1771 *
1772 * @return {string} The translated singular or plural form.
1773 */
1774
1775
1776 var _n = function _n(single, plural, number, domain) {
1777 return dcnpgettext(domain, undefined, single, plural, number);
1778 };
1779 /**
1780 * Translates and retrieves the singular or plural form based on the supplied
1781 * number, with gettext context.
1782 *
1783 * @see https://developer.wordpress.org/reference/functions/_nx/
1784 *
1785 * @param {string} single The text to be used if the number is singular.
1786 * @param {string} plural The text to be used if the number is plural.
1787 * @param {number} number The number to compare against to use either the
1788 * singular or plural form.
1789 * @param {string} context Context information for the translators.
1790 * @param {string} [domain] Domain to retrieve the translated text.
1791 *
1792 * @return {string} The translated singular or plural form.
1793 */
1794
1795
1796 var _nx = function _nx(single, plural, number, context, domain) {
1797 return dcnpgettext(domain, context, single, plural, number);
1798 };
1799 /**
1800 * Check if current locale is RTL.
1801 *
1802 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
1803 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
1804 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
1805 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
1806 *
1807 * @return {boolean} Whether locale is RTL.
1808 */
1809
1810
1811 var isRTL = function isRTL() {
1812 return 'rtl' === _x('ltr', 'text direction');
1813 };
1814
1815 if (initialData) {
1816 setLocaleData(initialData, initialDomain);
1817 }
1818
1819 return {
1820 setLocaleData: setLocaleData,
1821 __: __,
1822 _x: _x,
1823 _n: _n,
1824 _nx: _nx,
1825 isRTL: isRTL
1826 };
1827 };
1828
1829 exports.createI18n = createI18n;
1830
1831 },{"@babel/runtime/helpers/defineProperty":4,"@babel/runtime/helpers/interopRequireDefault":5,"tannin":17}],11:[function(require,module,exports){
1832 "use strict";
1833
1834 Object.defineProperty(exports, "__esModule", {
1835 value: true
1836 });
1837 exports.isRTL = exports._nx = exports._n = exports._x = exports.__ = exports.setLocaleData = void 0;
1838
1839 var _createI18n = require("./create-i18n");
1840
1841 /**
1842 * Internal dependencies
1843 */
1844 var i18n = (0, _createI18n.createI18n)();
1845 /*
1846 * Comments in this file are duplicated from ./i18n due to
1847 * https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722
1848 */
1849
1850 /**
1851 * @typedef {import('./create-i18n').LocaleData} LocaleData
1852 */
1853
1854 /**
1855 * Merges locale data into the Tannin instance by domain. Accepts data in a
1856 * Jed-formatted JSON object shape.
1857 *
1858 * @see http://messageformat.github.io/Jed/
1859 *
1860 * @param {LocaleData} [data] Locale data configuration.
1861 * @param {string} [domain] Domain for which configuration applies.
1862 */
1863
1864 var setLocaleData = i18n.setLocaleData.bind(i18n);
1865 /**
1866 * Retrieve the translation of text.
1867 *
1868 * @see https://developer.wordpress.org/reference/functions/__/
1869 *
1870 * @param {string} text Text to translate.
1871 * @param {string} [domain] Domain to retrieve the translated text.
1872 *
1873 * @return {string} Translated text.
1874 */
1875
1876 exports.setLocaleData = setLocaleData;
1877
1878 var __ = i18n.__.bind(i18n);
1879 /**
1880 * Retrieve translated string with gettext context.
1881 *
1882 * @see https://developer.wordpress.org/reference/functions/_x/
1883 *
1884 * @param {string} text Text to translate.
1885 * @param {string} context Context information for the translators.
1886 * @param {string} [domain] Domain to retrieve the translated text.
1887 *
1888 * @return {string} Translated context string without pipe.
1889 */
1890
1891
1892 exports.__ = __;
1893
1894 var _x = i18n._x.bind(i18n);
1895 /**
1896 * Translates and retrieves the singular or plural form based on the supplied
1897 * number.
1898 *
1899 * @see https://developer.wordpress.org/reference/functions/_n/
1900 *
1901 * @param {string} single The text to be used if the number is singular.
1902 * @param {string} plural The text to be used if the number is plural.
1903 * @param {number} number The number to compare against to use either the
1904 * singular or plural form.
1905 * @param {string} [domain] Domain to retrieve the translated text.
1906 *
1907 * @return {string} The translated singular or plural form.
1908 */
1909
1910
1911 exports._x = _x;
1912
1913 var _n = i18n._n.bind(i18n);
1914 /**
1915 * Translates and retrieves the singular or plural form based on the supplied
1916 * number, with gettext context.
1917 *
1918 * @see https://developer.wordpress.org/reference/functions/_nx/
1919 *
1920 * @param {string} single The text to be used if the number is singular.
1921 * @param {string} plural The text to be used if the number is plural.
1922 * @param {number} number The number to compare against to use either the
1923 * singular or plural form.
1924 * @param {string} context Context information for the translators.
1925 * @param {string} [domain] Domain to retrieve the translated text.
1926 *
1927 * @return {string} The translated singular or plural form.
1928 */
1929
1930
1931 exports._n = _n;
1932
1933 var _nx = i18n._nx.bind(i18n);
1934 /**
1935 * Check if current locale is RTL.
1936 *
1937 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
1938 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
1939 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
1940 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
1941 *
1942 * @return {boolean} Whether locale is RTL.
1943 */
1944
1945
1946 exports._nx = _nx;
1947 var isRTL = i18n.isRTL.bind(i18n);
1948 exports.isRTL = isRTL;
1949
1950 },{"./create-i18n":10}],12:[function(require,module,exports){
1951 "use strict";
1952
1953 Object.defineProperty(exports, "__esModule", {
1954 value: true
1955 });
1956 var _exportNames = {
1957 sprintf: true,
1958 setLocaleData: true,
1959 __: true,
1960 _x: true,
1961 _n: true,
1962 _nx: true,
1963 isRTL: true
1964 };
1965 Object.defineProperty(exports, "sprintf", {
1966 enumerable: true,
1967 get: function get() {
1968 return _sprintf.sprintf;
1969 }
1970 });
1971 Object.defineProperty(exports, "setLocaleData", {
1972 enumerable: true,
1973 get: function get() {
1974 return _defaultI18n.setLocaleData;
1975 }
1976 });
1977 Object.defineProperty(exports, "__", {
1978 enumerable: true,
1979 get: function get() {
1980 return _defaultI18n.__;
1981 }
1982 });
1983 Object.defineProperty(exports, "_x", {
1984 enumerable: true,
1985 get: function get() {
1986 return _defaultI18n._x;
1987 }
1988 });
1989 Object.defineProperty(exports, "_n", {
1990 enumerable: true,
1991 get: function get() {
1992 return _defaultI18n._n;
1993 }
1994 });
1995 Object.defineProperty(exports, "_nx", {
1996 enumerable: true,
1997 get: function get() {
1998 return _defaultI18n._nx;
1999 }
2000 });
2001 Object.defineProperty(exports, "isRTL", {
2002 enumerable: true,
2003 get: function get() {
2004 return _defaultI18n.isRTL;
2005 }
2006 });
2007
2008 var _sprintf = require("./sprintf");
2009
2010 var _createI18n = require("./create-i18n");
2011
2012 Object.keys(_createI18n).forEach(function (key) {
2013 if (key === "default" || key === "__esModule") return;
2014 if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
2015 Object.defineProperty(exports, key, {
2016 enumerable: true,
2017 get: function get() {
2018 return _createI18n[key];
2019 }
2020 });
2021 });
2022
2023 var _defaultI18n = require("./default-i18n");
2024
2025 },{"./create-i18n":10,"./default-i18n":11,"./sprintf":13}],13:[function(require,module,exports){
2026 "use strict";
2027
2028 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2029
2030 Object.defineProperty(exports, "__esModule", {
2031 value: true
2032 });
2033 exports.sprintf = sprintf;
2034
2035 var _memize = _interopRequireDefault(require("memize"));
2036
2037 var _sprintfJs = _interopRequireDefault(require("sprintf-js"));
2038
2039 /**
2040 * External dependencies
2041 */
2042
2043 /**
2044 * Log to console, once per message; or more precisely, per referentially equal
2045 * argument set. Because Jed throws errors, we log these to the console instead
2046 * to avoid crashing the application.
2047 *
2048 * @param {...*} args Arguments to pass to `console.error`
2049 */
2050 var logErrorOnce = (0, _memize.default)(console.error); // eslint-disable-line no-console
2051
2052 /**
2053 * Returns a formatted string. If an error occurs in applying the format, the
2054 * original format string is returned.
2055 *
2056 * @param {string} format The format of the string to generate.
2057 * @param {...*} args Arguments to apply to the format.
2058 *
2059 * @see http://www.diveintojavascript.com/projects/javascript-sprintf
2060 *
2061 * @return {string} The formatted string.
2062 */
2063
2064 function sprintf(format) {
2065 try {
2066 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2067 args[_key - 1] = arguments[_key];
2068 }
2069
2070 return _sprintfJs.default.sprintf.apply(_sprintfJs.default, [format].concat(args));
2071 } catch (error) {
2072 logErrorOnce('sprintf error: \n\n' + error.toString());
2073 return format;
2074 }
2075 }
2076
2077 },{"@babel/runtime/helpers/interopRequireDefault":5,"memize":15,"sprintf-js":14}],14:[function(require,module,exports){
2078 /* global window, exports, define */
2079
2080 !function() {
2081 'use strict'
2082
2083 var re = {
2084 not_string: /[^s]/,
2085 not_bool: /[^t]/,
2086 not_type: /[^T]/,
2087 not_primitive: /[^v]/,
2088 number: /[diefg]/,
2089 numeric_arg: /[bcdiefguxX]/,
2090 json: /[j]/,
2091 not_json: /[^j]/,
2092 text: /^[^\x25]+/,
2093 modulo: /^\x25{2}/,
2094 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
2095 key: /^([a-z_][a-z_\d]*)/i,
2096 key_access: /^\.([a-z_][a-z_\d]*)/i,
2097 index_access: /^\[(\d+)\]/,
2098 sign: /^[+-]/
2099 }
2100
2101 function sprintf(key) {
2102 // `arguments` is not an array, but should be fine for this call
2103 return sprintf_format(sprintf_parse(key), arguments)
2104 }
2105
2106 function vsprintf(fmt, argv) {
2107 return sprintf.apply(null, [fmt].concat(argv || []))
2108 }
2109
2110 function sprintf_format(parse_tree, argv) {
2111 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign
2112 for (i = 0; i < tree_length; i++) {
2113 if (typeof parse_tree[i] === 'string') {
2114 output += parse_tree[i]
2115 }
2116 else if (typeof parse_tree[i] === 'object') {
2117 ph = parse_tree[i] // convenience purposes only
2118 if (ph.keys) { // keyword argument
2119 arg = argv[cursor]
2120 for (k = 0; k < ph.keys.length; k++) {
2121 if (arg == undefined) {
2122 throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1]))
2123 }
2124 arg = arg[ph.keys[k]]
2125 }
2126 }
2127 else if (ph.param_no) { // positional argument (explicit)
2128 arg = argv[ph.param_no]
2129 }
2130 else { // positional argument (implicit)
2131 arg = argv[cursor++]
2132 }
2133
2134 if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
2135 arg = arg()
2136 }
2137
2138 if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {
2139 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
2140 }
2141
2142 if (re.number.test(ph.type)) {
2143 is_positive = arg >= 0
2144 }
2145
2146 switch (ph.type) {
2147 case 'b':
2148 arg = parseInt(arg, 10).toString(2)
2149 break
2150 case 'c':
2151 arg = String.fromCharCode(parseInt(arg, 10))
2152 break
2153 case 'd':
2154 case 'i':
2155 arg = parseInt(arg, 10)
2156 break
2157 case 'j':
2158 arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)
2159 break
2160 case 'e':
2161 arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()
2162 break
2163 case 'f':
2164 arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)
2165 break
2166 case 'g':
2167 arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)
2168 break
2169 case 'o':
2170 arg = (parseInt(arg, 10) >>> 0).toString(8)
2171 break
2172 case 's':
2173 arg = String(arg)
2174 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
2175 break
2176 case 't':
2177 arg = String(!!arg)
2178 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
2179 break
2180 case 'T':
2181 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
2182 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
2183 break
2184 case 'u':
2185 arg = parseInt(arg, 10) >>> 0
2186 break
2187 case 'v':
2188 arg = arg.valueOf()
2189 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
2190 break
2191 case 'x':
2192 arg = (parseInt(arg, 10) >>> 0).toString(16)
2193 break
2194 case 'X':
2195 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
2196 break
2197 }
2198 if (re.json.test(ph.type)) {
2199 output += arg
2200 }
2201 else {
2202 if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
2203 sign = is_positive ? '+' : '-'
2204 arg = arg.toString().replace(re.sign, '')
2205 }
2206 else {
2207 sign = ''
2208 }
2209 pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '
2210 pad_length = ph.width - (sign + arg).length
2211 pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''
2212 output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
2213 }
2214 }
2215 }
2216 return output
2217 }
2218
2219 var sprintf_cache = Object.create(null)
2220
2221 function sprintf_parse(fmt) {
2222 if (sprintf_cache[fmt]) {
2223 return sprintf_cache[fmt]
2224 }
2225
2226 var _fmt = fmt, match, parse_tree = [], arg_names = 0
2227 while (_fmt) {
2228 if ((match = re.text.exec(_fmt)) !== null) {
2229 parse_tree.push(match[0])
2230 }
2231 else if ((match = re.modulo.exec(_fmt)) !== null) {
2232 parse_tree.push('%')
2233 }
2234 else if ((match = re.placeholder.exec(_fmt)) !== null) {
2235 if (match[2]) {
2236 arg_names |= 1
2237 var field_list = [], replacement_field = match[2], field_match = []
2238 if ((field_match = re.key.exec(replacement_field)) !== null) {
2239 field_list.push(field_match[1])
2240 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
2241 if ((field_match = re.key_access.exec(replacement_field)) !== null) {
2242 field_list.push(field_match[1])
2243 }
2244 else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
2245 field_list.push(field_match[1])
2246 }
2247 else {
2248 throw new SyntaxError('[sprintf] failed to parse named argument key')
2249 }
2250 }
2251 }
2252 else {
2253 throw new SyntaxError('[sprintf] failed to parse named argument key')
2254 }
2255 match[2] = field_list
2256 }
2257 else {
2258 arg_names |= 2
2259 }
2260 if (arg_names === 3) {
2261 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')
2262 }
2263
2264 parse_tree.push(
2265 {
2266 placeholder: match[0],
2267 param_no: match[1],
2268 keys: match[2],
2269 sign: match[3],
2270 pad_char: match[4],
2271 align: match[5],
2272 width: match[6],
2273 precision: match[7],
2274 type: match[8]
2275 }
2276 )
2277 }
2278 else {
2279 throw new SyntaxError('[sprintf] unexpected placeholder')
2280 }
2281 _fmt = _fmt.substring(match[0].length)
2282 }
2283 return sprintf_cache[fmt] = parse_tree
2284 }
2285
2286 /**
2287 * export to either browser or node.js
2288 */
2289 /* eslint-disable quote-props */
2290 if (typeof exports !== 'undefined') {
2291 exports['sprintf'] = sprintf
2292 exports['vsprintf'] = vsprintf
2293 }
2294 if (typeof window !== 'undefined') {
2295 window['sprintf'] = sprintf
2296 window['vsprintf'] = vsprintf
2297
2298 if (typeof define === 'function' && define['amd']) {
2299 define(function() {
2300 return {
2301 'sprintf': sprintf,
2302 'vsprintf': vsprintf
2303 }
2304 })
2305 }
2306 }
2307 /* eslint-enable quote-props */
2308 }(); // eslint-disable-line
2309
2310 },{}],15:[function(require,module,exports){
2311 (function (process){
2312 /**
2313 * Memize options object.
2314 *
2315 * @typedef MemizeOptions
2316 *
2317 * @property {number} [maxSize] Maximum size of the cache.
2318 */
2319
2320 /**
2321 * Internal cache entry.
2322 *
2323 * @typedef MemizeCacheNode
2324 *
2325 * @property {?MemizeCacheNode|undefined} [prev] Previous node.
2326 * @property {?MemizeCacheNode|undefined} [next] Next node.
2327 * @property {Array<*>} args Function arguments for cache
2328 * entry.
2329 * @property {*} val Function result.
2330 */
2331
2332 /**
2333 * Properties of the enhanced function for controlling cache.
2334 *
2335 * @typedef MemizeMemoizedFunction
2336 *
2337 * @property {()=>void} clear Clear the cache.
2338 */
2339
2340 /**
2341 * Accepts a function to be memoized, and returns a new memoized function, with
2342 * optional options.
2343 *
2344 * @template {Function} F
2345 *
2346 * @param {F} fn Function to memoize.
2347 * @param {MemizeOptions} [options] Options object.
2348 *
2349 * @return {F & MemizeMemoizedFunction} Memoized function.
2350 */
2351 function memize( fn, options ) {
2352 var size = 0;
2353
2354 /** @type {?MemizeCacheNode|undefined} */
2355 var head;
2356
2357 /** @type {?MemizeCacheNode|undefined} */
2358 var tail;
2359
2360 options = options || {};
2361
2362 function memoized( /* ...args */ ) {
2363 var node = head,
2364 len = arguments.length,
2365 args, i;
2366
2367 searchCache: while ( node ) {
2368 // Perform a shallow equality test to confirm that whether the node
2369 // under test is a candidate for the arguments passed. Two arrays
2370 // are shallowly equal if their length matches and each entry is
2371 // strictly equal between the two sets. Avoid abstracting to a
2372 // function which could incur an arguments leaking deoptimization.
2373
2374 // Check whether node arguments match arguments length
2375 if ( node.args.length !== arguments.length ) {
2376 node = node.next;
2377 continue;
2378 }
2379
2380 // Check whether node arguments match arguments values
2381 for ( i = 0; i < len; i++ ) {
2382 if ( node.args[ i ] !== arguments[ i ] ) {
2383 node = node.next;
2384 continue searchCache;
2385 }
2386 }
2387
2388 // At this point we can assume we've found a match
2389
2390 // Surface matched node to head if not already
2391 if ( node !== head ) {
2392 // As tail, shift to previous. Must only shift if not also
2393 // head, since if both head and tail, there is no previous.
2394 if ( node === tail ) {
2395 tail = node.prev;
2396 }
2397
2398 // Adjust siblings to point to each other. If node was tail,
2399 // this also handles new tail's empty `next` assignment.
2400 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
2401 if ( node.next ) {
2402 node.next.prev = node.prev;
2403 }
2404
2405 node.next = head;
2406 node.prev = null;
2407 /** @type {MemizeCacheNode} */ ( head ).prev = node;
2408 head = node;
2409 }
2410
2411 // Return immediately
2412 return node.val;
2413 }
2414
2415 // No cached value found. Continue to insertion phase:
2416
2417 // Create a copy of arguments (avoid leaking deoptimization)
2418 args = new Array( len );
2419 for ( i = 0; i < len; i++ ) {
2420 args[ i ] = arguments[ i ];
2421 }
2422
2423 node = {
2424 args: args,
2425
2426 // Generate the result from original function
2427 val: fn.apply( null, args ),
2428 };
2429
2430 // Don't need to check whether node is already head, since it would
2431 // have been returned above already if it was
2432
2433 // Shift existing head down list
2434 if ( head ) {
2435 head.prev = node;
2436 node.next = head;
2437 } else {
2438 // If no head, follows that there's no tail (at initial or reset)
2439 tail = node;
2440 }
2441
2442 // Trim tail if we're reached max size and are pending cache insertion
2443 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
2444 tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
2445 /** @type {MemizeCacheNode} */ ( tail ).next = null;
2446 } else {
2447 size++;
2448 }
2449
2450 head = node;
2451
2452 return node.val;
2453 }
2454
2455 memoized.clear = function() {
2456 head = null;
2457 tail = null;
2458 size = 0;
2459 };
2460
2461 if ( process.env.NODE_ENV === 'test' ) {
2462 // Cache is not exposed in the public API, but used in tests to ensure
2463 // expected list progression
2464 memoized.getCache = function() {
2465 return [ head, tail, size ];
2466 };
2467 }
2468
2469 // Ignore reason: There's not a clear solution to create an intersection of
2470 // the function with additional properties, where the goal is to retain the
2471 // function signature of the incoming argument and add control properties
2472 // on the return value.
2473
2474 // @ts-ignore
2475 return memoized;
2476 }
2477
2478 module.exports = memize;
2479
2480 }).call(this,require('_process'))
2481 },{"_process":16}],16:[function(require,module,exports){
2482 // shim for using process in browser
2483 var process = module.exports = {};
2484
2485 // cached from whatever global is present so that test runners that stub it
2486 // don't break things. But we need to wrap it in a try catch in case it is
2487 // wrapped in strict mode code which doesn't define any globals. It's inside a
2488 // function because try/catches deoptimize in certain engines.
2489
2490 var cachedSetTimeout;
2491 var cachedClearTimeout;
2492
2493 function defaultSetTimout() {
2494 throw new Error('setTimeout has not been defined');
2495 }
2496 function defaultClearTimeout () {
2497 throw new Error('clearTimeout has not been defined');
2498 }
2499 (function () {
2500 try {
2501 if (typeof setTimeout === 'function') {
2502 cachedSetTimeout = setTimeout;
2503 } else {
2504 cachedSetTimeout = defaultSetTimout;
2505 }
2506 } catch (e) {
2507 cachedSetTimeout = defaultSetTimout;
2508 }
2509 try {
2510 if (typeof clearTimeout === 'function') {
2511 cachedClearTimeout = clearTimeout;
2512 } else {
2513 cachedClearTimeout = defaultClearTimeout;
2514 }
2515 } catch (e) {
2516 cachedClearTimeout = defaultClearTimeout;
2517 }
2518 } ())
2519 function runTimeout(fun) {
2520 if (cachedSetTimeout === setTimeout) {
2521 //normal enviroments in sane situations
2522 return setTimeout(fun, 0);
2523 }
2524 // if setTimeout wasn't available but was latter defined
2525 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
2526 cachedSetTimeout = setTimeout;
2527 return setTimeout(fun, 0);
2528 }
2529 try {
2530 // when when somebody has screwed with setTimeout but no I.E. maddness
2531 return cachedSetTimeout(fun, 0);
2532 } catch(e){
2533 try {
2534 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
2535 return cachedSetTimeout.call(null, fun, 0);
2536 } catch(e){
2537 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
2538 return cachedSetTimeout.call(this, fun, 0);
2539 }
2540 }
2541
2542
2543 }
2544 function runClearTimeout(marker) {
2545 if (cachedClearTimeout === clearTimeout) {
2546 //normal enviroments in sane situations
2547 return clearTimeout(marker);
2548 }
2549 // if clearTimeout wasn't available but was latter defined
2550 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
2551 cachedClearTimeout = clearTimeout;
2552 return clearTimeout(marker);
2553 }
2554 try {
2555 // when when somebody has screwed with setTimeout but no I.E. maddness
2556 return cachedClearTimeout(marker);
2557 } catch (e){
2558 try {
2559 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
2560 return cachedClearTimeout.call(null, marker);
2561 } catch (e){
2562 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
2563 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
2564 return cachedClearTimeout.call(this, marker);
2565 }
2566 }
2567
2568
2569
2570 }
2571 var queue = [];
2572 var draining = false;
2573 var currentQueue;
2574 var queueIndex = -1;
2575
2576 function cleanUpNextTick() {
2577 if (!draining || !currentQueue) {
2578 return;
2579 }
2580 draining = false;
2581 if (currentQueue.length) {
2582 queue = currentQueue.concat(queue);
2583 } else {
2584 queueIndex = -1;
2585 }
2586 if (queue.length) {
2587 drainQueue();
2588 }
2589 }
2590
2591 function drainQueue() {
2592 if (draining) {
2593 return;
2594 }
2595 var timeout = runTimeout(cleanUpNextTick);
2596 draining = true;
2597
2598 var len = queue.length;
2599 while(len) {
2600 currentQueue = queue;
2601 queue = [];
2602 while (++queueIndex < len) {
2603 if (currentQueue) {
2604 currentQueue[queueIndex].run();
2605 }
2606 }
2607 queueIndex = -1;
2608 len = queue.length;
2609 }
2610 currentQueue = null;
2611 draining = false;
2612 runClearTimeout(timeout);
2613 }
2614
2615 process.nextTick = function (fun) {
2616 var args = new Array(arguments.length - 1);
2617 if (arguments.length > 1) {
2618 for (var i = 1; i < arguments.length; i++) {
2619 args[i - 1] = arguments[i];
2620 }
2621 }
2622 queue.push(new Item(fun, args));
2623 if (queue.length === 1 && !draining) {
2624 runTimeout(drainQueue);
2625 }
2626 };
2627
2628 // v8 likes predictible objects
2629 function Item(fun, array) {
2630 this.fun = fun;
2631 this.array = array;
2632 }
2633 Item.prototype.run = function () {
2634 this.fun.apply(null, this.array);
2635 };
2636 process.title = 'browser';
2637 process.browser = true;
2638 process.env = {};
2639 process.argv = [];
2640 process.version = ''; // empty string to avoid regexp issues
2641 process.versions = {};
2642
2643 function noop() {}
2644
2645 process.on = noop;
2646 process.addListener = noop;
2647 process.once = noop;
2648 process.off = noop;
2649 process.removeListener = noop;
2650 process.removeAllListeners = noop;
2651 process.emit = noop;
2652 process.prependListener = noop;
2653 process.prependOnceListener = noop;
2654
2655 process.listeners = function (name) { return [] }
2656
2657 process.binding = function (name) {
2658 throw new Error('process.binding is not supported');
2659 };
2660
2661 process.cwd = function () { return '/' };
2662 process.chdir = function (dir) {
2663 throw new Error('process.chdir is not supported');
2664 };
2665 process.umask = function() { return 0; };
2666
2667 },{}],17:[function(require,module,exports){
2668 'use strict';
2669
2670 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2671
2672 var pluralForms = _interopDefault(require('@tannin/plural-forms'));
2673
2674 /**
2675 * Tannin constructor options.
2676 *
2677 * @typedef {Object} TanninOptions
2678 *
2679 * @property {string} [contextDelimiter] Joiner in string lookup with context.
2680 * @property {Function} [onMissingKey] Callback to invoke when key missing.
2681 */
2682
2683 /**
2684 * Domain metadata.
2685 *
2686 * @typedef {Object} TanninDomainMetadata
2687 *
2688 * @property {string} [domain] Domain name.
2689 * @property {string} [lang] Language code.
2690 * @property {(string|Function)} [plural_forms] Plural forms expression or
2691 * function evaluator.
2692 */
2693
2694 /**
2695 * Domain translation pair respectively representing the singular and plural
2696 * translation.
2697 *
2698 * @typedef {[string,string]} TanninTranslation
2699 */
2700
2701 /**
2702 * Locale data domain. The key is used as reference for lookup, the value an
2703 * array of two string entries respectively representing the singular and plural
2704 * translation.
2705 *
2706 * @typedef {{[key:string]:TanninDomainMetadata|TanninTranslation,'':TanninDomainMetadata|TanninTranslation}} TanninLocaleDomain
2707 */
2708
2709 /**
2710 * Jed-formatted locale data.
2711 *
2712 * @see http://messageformat.github.io/Jed/
2713 *
2714 * @typedef {{[domain:string]:TanninLocaleDomain}} TanninLocaleData
2715 */
2716
2717 /**
2718 * Default Tannin constructor options.
2719 *
2720 * @type {TanninOptions}
2721 */
2722 var DEFAULT_OPTIONS = {
2723 contextDelimiter: '\u0004',
2724 onMissingKey: null,
2725 };
2726
2727 /**
2728 * Given a specific locale data's config `plural_forms` value, returns the
2729 * expression.
2730 *
2731 * @example
2732 *
2733 * ```
2734 * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)'
2735 * ```
2736 *
2737 * @param {string} pf Locale data plural forms.
2738 *
2739 * @return {string} Plural forms expression.
2740 */
2741 function getPluralExpression( pf ) {
2742 var parts, i, part;
2743
2744 parts = pf.split( ';' );
2745
2746 for ( i = 0; i < parts.length; i++ ) {
2747 part = parts[ i ].trim();
2748 if ( part.indexOf( 'plural=' ) === 0 ) {
2749 return part.substr( 7 );
2750 }
2751 }
2752 }
2753
2754 /**
2755 * Tannin constructor.
2756 *
2757 * @class
2758 *
2759 * @param {TanninLocaleData} data Jed-formatted locale data.
2760 * @param {TanninOptions} [options] Tannin options.
2761 */
2762 function Tannin( data, options ) {
2763 var key;
2764
2765 /**
2766 * Jed-formatted locale data.
2767 *
2768 * @name Tannin#data
2769 * @type {TanninLocaleData}
2770 */
2771 this.data = data;
2772
2773 /**
2774 * Plural forms function cache, keyed by plural forms string.
2775 *
2776 * @name Tannin#pluralForms
2777 * @type {Object<string,Function>}
2778 */
2779 this.pluralForms = {};
2780
2781 /**
2782 * Effective options for instance, including defaults.
2783 *
2784 * @name Tannin#options
2785 * @type {TanninOptions}
2786 */
2787 this.options = {};
2788
2789 for ( key in DEFAULT_OPTIONS ) {
2790 this.options[ key ] = options !== undefined && key in options
2791 ? options[ key ]
2792 : DEFAULT_OPTIONS[ key ];
2793 }
2794 }
2795
2796 /**
2797 * Returns the plural form index for the given domain and value.
2798 *
2799 * @param {string} domain Domain on which to calculate plural form.
2800 * @param {number} n Value for which plural form is to be calculated.
2801 *
2802 * @return {number} Plural form index.
2803 */
2804 Tannin.prototype.getPluralForm = function( domain, n ) {
2805 var getPluralForm = this.pluralForms[ domain ],
2806 config, plural, pf;
2807
2808 if ( ! getPluralForm ) {
2809 config = this.data[ domain ][ '' ];
2810
2811 pf = (
2812 config[ 'Plural-Forms' ] ||
2813 config[ 'plural-forms' ] ||
2814 // Ignore reason: As known, there's no way to document the empty
2815 // string property on a key to guarantee this as metadata.
2816 // @ts-ignore
2817 config.plural_forms
2818 );
2819
2820 if ( typeof pf !== 'function' ) {
2821 plural = getPluralExpression(
2822 config[ 'Plural-Forms' ] ||
2823 config[ 'plural-forms' ] ||
2824 // Ignore reason: As known, there's no way to document the empty
2825 // string property on a key to guarantee this as metadata.
2826 // @ts-ignore
2827 config.plural_forms
2828 );
2829
2830 pf = pluralForms( plural );
2831 }
2832
2833 getPluralForm = this.pluralForms[ domain ] = pf;
2834 }
2835
2836 return getPluralForm( n );
2837 };
2838
2839 /**
2840 * Translate a string.
2841 *
2842 * @param {string} domain Translation domain.
2843 * @param {string|void} context Context distinguishing terms of the same name.
2844 * @param {string} singular Primary key for translation lookup.
2845 * @param {string=} plural Fallback value used for non-zero plural
2846 * form index.
2847 * @param {number=} n Value to use in calculating plural form.
2848 *
2849 * @return {string} Translated string.
2850 */
2851 Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) {
2852 var index, key, entry;
2853
2854 if ( n === undefined ) {
2855 // Default to singular.
2856 index = 0;
2857 } else {
2858 // Find index by evaluating plural form for value.
2859 index = this.getPluralForm( domain, n );
2860 }
2861
2862 key = singular;
2863
2864 // If provided, context is prepended to key with delimiter.
2865 if ( context ) {
2866 key = context + this.options.contextDelimiter + singular;
2867 }
2868
2869 entry = this.data[ domain ][ key ];
2870
2871 // Verify not only that entry exists, but that the intended index is within
2872 // range and non-empty.
2873 if ( entry && entry[ index ] ) {
2874 return entry[ index ];
2875 }
2876
2877 if ( this.options.onMissingKey ) {
2878 this.options.onMissingKey( singular, domain );
2879 }
2880
2881 // If entry not found, fall back to singular vs. plural with zero index
2882 // representing the singular value.
2883 return index === 0 ? singular : plural;
2884 };
2885
2886 module.exports = Tannin;
2887
2888 },{"@tannin/plural-forms":8}]},{},[2]);
2889